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 <vlib/pci/pci.h>
22 #include <vpp/api/types.h>
23 #include <vppinfra/socket.h>
24 #include <vlibapi/api.h>
25 #include <vlibmemory/api.h>
26 #include <vnet/ip/ip.h>
27 #include <vnet/ip/ip_neighbor.h>
28 #include <vnet/ip/ip_types_api.h>
29 #include <vnet/l2/l2_input.h>
30 #include <vnet/l2tp/l2tp.h>
31 #include <vnet/vxlan/vxlan.h>
32 #include <vnet/geneve/geneve.h>
33 #include <vnet/gre/gre.h>
34 #include <vnet/vxlan-gpe/vxlan_gpe.h>
35 #include <vnet/lisp-gpe/lisp_gpe.h>
37 #include <vpp/api/vpe_msg_enum.h>
38 #include <vnet/l2/l2_classify.h>
39 #include <vnet/l2/l2_vtr.h>
40 #include <vnet/classify/in_out_acl.h>
41 #include <vnet/classify/policer_classify.h>
42 #include <vnet/classify/flow_classify.h>
43 #include <vnet/mpls/mpls.h>
44 #include <vnet/ipsec/ipsec.h>
46 #include <vnet/cop/cop.h>
47 #include <vnet/ip/ip6_hop_by_hop.h>
48 #include <vnet/ip/ip_source_and_port_range_check.h>
49 #include <vnet/policer/xlate.h>
50 #include <vnet/span/span.h>
51 #include <vnet/policer/policer.h>
52 #include <vnet/policer/police.h>
53 #include <vnet/mfib/mfib_types.h>
54 #include <vnet/dhcp/dhcp_proxy.h>
55 #include <vnet/bonding/node.h>
56 #include <vnet/qos/qos_types.h>
57 #include <vnet/ethernet/ethernet_types_api.h>
58 #include <vnet/ip/ip_types_api.h>
59 #include "vat/json_format.h"
60 #include <vnet/ip/ip_types_api.h>
61 #include <vnet/ethernet/ethernet_types_api.h>
66 #define vl_typedefs /* define message structures */
67 #include <vpp/api/vpe_all_api_h.h>
70 /* declare message handlers for each api */
72 #define vl_endianfun /* define message structures */
73 #include <vpp/api/vpe_all_api_h.h>
76 /* instantiate all the print functions we know about */
77 #if VPP_API_TEST_BUILTIN == 0
78 #define vl_print(handle, ...)
80 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
83 #include <vpp/api/vpe_all_api_h.h>
86 #define __plugin_msg_base 0
87 #include <vlibapi/vat_helper_macros.h>
89 #include <vnet/format_fns.h>
91 void vl_api_set_elog_main (elog_main_t * m);
92 int vl_api_set_elog_trace_api_messages (int enable);
94 #if VPP_API_TEST_BUILTIN == 0
104 vat_socket_connect (vat_main_t * vam)
107 vam->socket_client_main = &socket_client_main;
108 if ((rv = vl_socket_client_connect ((char *) vam->socket_name,
110 0 /* default socket rx, tx buffer */ )))
112 /* vpp expects the client index in network order */
113 vam->my_client_index = htonl (socket_client_main.client_index);
116 #else /* vpp built-in case, we don't do sockets... */
118 vat_socket_connect (vat_main_t * vam)
124 vl_socket_client_read (int wait)
130 vl_socket_client_write ()
136 vl_socket_client_msg_alloc (int nbytes)
144 vat_time_now (vat_main_t * vam)
146 #if VPP_API_TEST_BUILTIN
147 return vlib_time_now (vam->vlib_main);
149 return clib_time_now (&vam->clib_time);
154 errmsg (char *fmt, ...)
156 vat_main_t *vam = &vat_main;
161 s = va_format (0, fmt, &va);
166 #if VPP_API_TEST_BUILTIN
167 vlib_cli_output (vam->vlib_main, (char *) s);
170 if (vam->ifp != stdin)
171 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
172 vam->input_line_number);
174 fformat (vam->ofp, "%s\n", (char *) s);
182 #if VPP_API_TEST_BUILTIN == 0
184 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
186 vat_main_t *vam = va_arg (*args, vat_main_t *);
187 u32 *result = va_arg (*args, u32 *);
191 if (!unformat (input, "%s", &if_name))
194 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
202 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
207 /* Parse an IP4 address %d.%d.%d.%d. */
209 unformat_ip4_address (unformat_input_t * input, va_list * args)
211 u8 *result = va_arg (*args, u8 *);
214 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
217 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
229 unformat_ethernet_address (unformat_input_t * input, va_list * args)
231 u8 *result = va_arg (*args, u8 *);
234 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
235 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
239 for (i = 0; i < 6; i++)
240 if (a[i] >= (1 << 8))
243 for (i = 0; i < 6; i++)
249 /* Returns ethernet type as an int in host byte order. */
251 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
254 u16 *result = va_arg (*args, u16 *);
258 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
260 if (type >= (1 << 16))
268 /* Parse an IP6 address. */
270 unformat_ip6_address (unformat_input_t * input, va_list * args)
272 ip6_address_t *result = va_arg (*args, ip6_address_t *);
274 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
275 uword c, n_colon, double_colon_index;
277 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
278 double_colon_index = ARRAY_LEN (hex_quads);
279 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
282 if (c >= '0' && c <= '9')
284 else if (c >= 'a' && c <= 'f')
285 hex_digit = c + 10 - 'a';
286 else if (c >= 'A' && c <= 'F')
287 hex_digit = c + 10 - 'A';
288 else if (c == ':' && n_colon < 2)
292 unformat_put_input (input);
296 /* Too many hex quads. */
297 if (n_hex_quads >= ARRAY_LEN (hex_quads))
302 hex_quad = (hex_quad << 4) | hex_digit;
304 /* Hex quad must fit in 16 bits. */
305 if (n_hex_digits >= 4)
312 /* Save position of :: */
315 /* More than one :: ? */
316 if (double_colon_index < ARRAY_LEN (hex_quads))
318 double_colon_index = n_hex_quads;
321 if (n_colon > 0 && n_hex_digits > 0)
323 hex_quads[n_hex_quads++] = hex_quad;
329 if (n_hex_digits > 0)
330 hex_quads[n_hex_quads++] = hex_quad;
335 /* Expand :: to appropriate number of zero hex quads. */
336 if (double_colon_index < ARRAY_LEN (hex_quads))
338 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
340 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
341 hex_quads[n_zero + i] = hex_quads[i];
343 for (i = 0; i < n_zero; i++)
344 hex_quads[double_colon_index + i] = 0;
346 n_hex_quads = ARRAY_LEN (hex_quads);
349 /* Too few hex quads given. */
350 if (n_hex_quads < ARRAY_LEN (hex_quads))
353 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
354 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
361 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
363 u32 *r = va_arg (*args, u32 *);
366 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
367 foreach_ipsec_policy_action
375 format_ipsec_crypto_alg (u8 * s, va_list * args)
377 u32 i = va_arg (*args, u32);
382 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
383 foreach_ipsec_crypto_alg
386 return format (s, "unknown");
388 return format (s, "%s", t);
392 format_ipsec_integ_alg (u8 * s, va_list * args)
394 u32 i = va_arg (*args, u32);
399 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
400 foreach_ipsec_integ_alg
403 return format (s, "unknown");
405 return format (s, "%s", t);
408 #else /* VPP_API_TEST_BUILTIN == 1 */
410 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
412 vat_main_t *vam __clib_unused = va_arg (*args, vat_main_t *);
413 vnet_main_t *vnm = vnet_get_main ();
414 u32 *result = va_arg (*args, u32 *);
416 return unformat (input, "%U", unformat_vnet_sw_interface, vnm, result);
420 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
422 vat_main_t *vam __clib_unused = va_arg (*args, vat_main_t *);
423 vnet_main_t *vnm = vnet_get_main ();
424 u32 *result = va_arg (*args, u32 *);
426 return unformat (input, "%U", unformat_vnet_hw_interface, vnm, result);
429 #endif /* VPP_API_TEST_BUILTIN */
432 unformat_ipsec_api_crypto_alg (unformat_input_t * input, va_list * args)
434 u32 *r = va_arg (*args, u32 *);
437 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_API_CRYPTO_ALG_##f;
438 foreach_ipsec_crypto_alg
446 unformat_ipsec_api_integ_alg (unformat_input_t * input, va_list * args)
448 u32 *r = va_arg (*args, u32 *);
451 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_API_INTEG_ALG_##f;
452 foreach_ipsec_integ_alg
460 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
462 u8 *r = va_arg (*args, u8 *);
464 if (unformat (input, "kbps"))
465 *r = SSE2_QOS_RATE_KBPS;
466 else if (unformat (input, "pps"))
467 *r = SSE2_QOS_RATE_PPS;
474 unformat_policer_round_type (unformat_input_t * input, va_list * args)
476 u8 *r = va_arg (*args, u8 *);
478 if (unformat (input, "closest"))
479 *r = SSE2_QOS_ROUND_TO_CLOSEST;
480 else if (unformat (input, "up"))
481 *r = SSE2_QOS_ROUND_TO_UP;
482 else if (unformat (input, "down"))
483 *r = SSE2_QOS_ROUND_TO_DOWN;
490 unformat_policer_type (unformat_input_t * input, va_list * args)
492 u8 *r = va_arg (*args, u8 *);
494 if (unformat (input, "1r2c"))
495 *r = SSE2_QOS_POLICER_TYPE_1R2C;
496 else if (unformat (input, "1r3c"))
497 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
498 else if (unformat (input, "2r3c-2698"))
499 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
500 else if (unformat (input, "2r3c-4115"))
501 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
502 else if (unformat (input, "2r3c-mef5cf1"))
503 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
510 unformat_dscp (unformat_input_t * input, va_list * va)
512 u8 *r = va_arg (*va, u8 *);
515 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
524 unformat_policer_action_type (unformat_input_t * input, va_list * va)
526 sse2_qos_pol_action_params_st *a
527 = va_arg (*va, sse2_qos_pol_action_params_st *);
529 if (unformat (input, "drop"))
530 a->action_type = SSE2_QOS_ACTION_DROP;
531 else if (unformat (input, "transmit"))
532 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
533 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
534 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
541 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
543 u32 *r = va_arg (*va, u32 *);
546 if (unformat (input, "ip4"))
547 tid = POLICER_CLASSIFY_TABLE_IP4;
548 else if (unformat (input, "ip6"))
549 tid = POLICER_CLASSIFY_TABLE_IP6;
550 else if (unformat (input, "l2"))
551 tid = POLICER_CLASSIFY_TABLE_L2;
560 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
562 u32 *r = va_arg (*va, u32 *);
565 if (unformat (input, "ip4"))
566 tid = FLOW_CLASSIFY_TABLE_IP4;
567 else if (unformat (input, "ip6"))
568 tid = FLOW_CLASSIFY_TABLE_IP6;
576 #if (VPP_API_TEST_BUILTIN==0)
578 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
579 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
580 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
581 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
584 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
586 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
587 mfib_itf_attribute_t attr;
590 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
592 if (unformat (input, mfib_itf_flag_long_names[attr]))
593 *iflags |= (1 << attr);
595 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
597 if (unformat (input, mfib_itf_flag_names[attr]))
598 *iflags |= (1 << attr);
601 return (old == *iflags ? 0 : 1);
605 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
607 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
608 mfib_entry_attribute_t attr;
611 FOR_EACH_MFIB_ATTRIBUTE (attr)
613 if (unformat (input, mfib_flag_long_names[attr]))
614 *eflags |= (1 << attr);
616 FOR_EACH_MFIB_ATTRIBUTE (attr)
618 if (unformat (input, mfib_flag_names[attr]))
619 *eflags |= (1 << attr);
622 return (old == *eflags ? 0 : 1);
626 format_ip4_address (u8 * s, va_list * args)
628 u8 *a = va_arg (*args, u8 *);
629 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
633 format_ip6_address (u8 * s, va_list * args)
635 ip6_address_t *a = va_arg (*args, ip6_address_t *);
636 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
638 i_max_n_zero = ARRAY_LEN (a->as_u16);
640 i_first_zero = i_max_n_zero;
642 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
644 u32 is_zero = a->as_u16[i] == 0;
645 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
651 if ((!is_zero && n_zeros > max_n_zeros)
652 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
654 i_max_n_zero = i_first_zero;
655 max_n_zeros = n_zeros;
656 i_first_zero = ARRAY_LEN (a->as_u16);
661 last_double_colon = 0;
662 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
664 if (i == i_max_n_zero && max_n_zeros > 1)
666 s = format (s, "::");
667 i += max_n_zeros - 1;
668 last_double_colon = 1;
672 s = format (s, "%s%x",
673 (last_double_colon || i == 0) ? "" : ":",
674 clib_net_to_host_u16 (a->as_u16[i]));
675 last_double_colon = 0;
682 /* Format an IP46 address. */
684 format_ip46_address (u8 * s, va_list * args)
686 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
687 ip46_type_t type = va_arg (*args, ip46_type_t);
693 is_ip4 = ip46_address_is_ip4 (ip46);
704 format (s, "%U", format_ip4_address, &ip46->ip4) :
705 format (s, "%U", format_ip6_address, &ip46->ip6);
709 format_ethernet_address (u8 * s, va_list * args)
711 u8 *a = va_arg (*args, u8 *);
713 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
714 a[0], a[1], a[2], a[3], a[4], a[5]);
719 increment_v4_address (vl_api_ip4_address_t * i)
721 ip4_address_t *a = (ip4_address_t *) i;
724 v = ntohl (a->as_u32) + 1;
725 a->as_u32 = ntohl (v);
729 increment_v6_address (vl_api_ip6_address_t * i)
731 ip6_address_t *a = (ip6_address_t *) i;
734 v0 = clib_net_to_host_u64 (a->as_u64[0]);
735 v1 = clib_net_to_host_u64 (a->as_u64[1]);
740 a->as_u64[0] = clib_net_to_host_u64 (v0);
741 a->as_u64[1] = clib_net_to_host_u64 (v1);
745 increment_address (vl_api_address_t * a)
747 if (clib_net_to_host_u32 (a->af) == ADDRESS_IP4)
748 increment_v4_address (&a->un.ip4);
749 else if (clib_net_to_host_u32 (a->af) == ADDRESS_IP6)
750 increment_v6_address (&a->un.ip6);
754 set_ip4_address (vl_api_address_t * a, u32 v)
756 if (a->af == ADDRESS_IP4)
758 ip4_address_t *i = (ip4_address_t *) & a->un.ip4;
764 increment_mac_address (u8 * mac)
766 u64 tmp = *((u64 *) mac);
767 tmp = clib_net_to_host_u64 (tmp);
768 tmp += 1 << 16; /* skip unused (least significant) octets */
769 tmp = clib_host_to_net_u64 (tmp);
771 clib_memcpy (mac, &tmp, 6);
775 vat_json_object_add_address (vat_json_node_t * node,
776 const char *str, const vl_api_address_t * addr)
778 if (ADDRESS_IP6 == addr->af)
782 clib_memcpy (&ip6, &addr->un.ip6, sizeof (ip6));
783 vat_json_object_add_ip6 (node, str, ip6);
789 clib_memcpy (&ip4, &addr->un.ip4, sizeof (ip4));
790 vat_json_object_add_ip4 (node, str, ip4);
795 vat_json_object_add_prefix (vat_json_node_t * node,
796 const vl_api_prefix_t * prefix)
798 vat_json_object_add_uint (node, "len", prefix->len);
799 vat_json_object_add_address (node, "address", &prefix->address);
802 static void vl_api_create_loopback_reply_t_handler
803 (vl_api_create_loopback_reply_t * mp)
805 vat_main_t *vam = &vat_main;
806 i32 retval = ntohl (mp->retval);
808 vam->retval = retval;
809 vam->regenerate_interface_table = 1;
810 vam->sw_if_index = ntohl (mp->sw_if_index);
811 vam->result_ready = 1;
814 static void vl_api_create_loopback_reply_t_handler_json
815 (vl_api_create_loopback_reply_t * mp)
817 vat_main_t *vam = &vat_main;
818 vat_json_node_t node;
820 vat_json_init_object (&node);
821 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
822 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
824 vat_json_print (vam->ofp, &node);
825 vat_json_free (&node);
826 vam->retval = ntohl (mp->retval);
827 vam->result_ready = 1;
830 static void vl_api_create_loopback_instance_reply_t_handler
831 (vl_api_create_loopback_instance_reply_t * mp)
833 vat_main_t *vam = &vat_main;
834 i32 retval = ntohl (mp->retval);
836 vam->retval = retval;
837 vam->regenerate_interface_table = 1;
838 vam->sw_if_index = ntohl (mp->sw_if_index);
839 vam->result_ready = 1;
842 static void vl_api_create_loopback_instance_reply_t_handler_json
843 (vl_api_create_loopback_instance_reply_t * mp)
845 vat_main_t *vam = &vat_main;
846 vat_json_node_t node;
848 vat_json_init_object (&node);
849 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
850 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
852 vat_json_print (vam->ofp, &node);
853 vat_json_free (&node);
854 vam->retval = ntohl (mp->retval);
855 vam->result_ready = 1;
858 static void vl_api_af_packet_create_reply_t_handler
859 (vl_api_af_packet_create_reply_t * mp)
861 vat_main_t *vam = &vat_main;
862 i32 retval = ntohl (mp->retval);
864 vam->retval = retval;
865 vam->regenerate_interface_table = 1;
866 vam->sw_if_index = ntohl (mp->sw_if_index);
867 vam->result_ready = 1;
870 static void vl_api_af_packet_create_reply_t_handler_json
871 (vl_api_af_packet_create_reply_t * mp)
873 vat_main_t *vam = &vat_main;
874 vat_json_node_t node;
876 vat_json_init_object (&node);
877 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
878 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
880 vat_json_print (vam->ofp, &node);
881 vat_json_free (&node);
883 vam->retval = ntohl (mp->retval);
884 vam->result_ready = 1;
887 static void vl_api_create_vlan_subif_reply_t_handler
888 (vl_api_create_vlan_subif_reply_t * mp)
890 vat_main_t *vam = &vat_main;
891 i32 retval = ntohl (mp->retval);
893 vam->retval = retval;
894 vam->regenerate_interface_table = 1;
895 vam->sw_if_index = ntohl (mp->sw_if_index);
896 vam->result_ready = 1;
899 static void vl_api_create_vlan_subif_reply_t_handler_json
900 (vl_api_create_vlan_subif_reply_t * mp)
902 vat_main_t *vam = &vat_main;
903 vat_json_node_t node;
905 vat_json_init_object (&node);
906 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
907 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
909 vat_json_print (vam->ofp, &node);
910 vat_json_free (&node);
912 vam->retval = ntohl (mp->retval);
913 vam->result_ready = 1;
916 static void vl_api_create_subif_reply_t_handler
917 (vl_api_create_subif_reply_t * mp)
919 vat_main_t *vam = &vat_main;
920 i32 retval = ntohl (mp->retval);
922 vam->retval = retval;
923 vam->regenerate_interface_table = 1;
924 vam->sw_if_index = ntohl (mp->sw_if_index);
925 vam->result_ready = 1;
928 static void vl_api_create_subif_reply_t_handler_json
929 (vl_api_create_subif_reply_t * mp)
931 vat_main_t *vam = &vat_main;
932 vat_json_node_t node;
934 vat_json_init_object (&node);
935 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
936 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
938 vat_json_print (vam->ofp, &node);
939 vat_json_free (&node);
941 vam->retval = ntohl (mp->retval);
942 vam->result_ready = 1;
945 static void vl_api_interface_name_renumber_reply_t_handler
946 (vl_api_interface_name_renumber_reply_t * mp)
948 vat_main_t *vam = &vat_main;
949 i32 retval = ntohl (mp->retval);
951 vam->retval = retval;
952 vam->regenerate_interface_table = 1;
953 vam->result_ready = 1;
956 static void vl_api_interface_name_renumber_reply_t_handler_json
957 (vl_api_interface_name_renumber_reply_t * mp)
959 vat_main_t *vam = &vat_main;
960 vat_json_node_t node;
962 vat_json_init_object (&node);
963 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
965 vat_json_print (vam->ofp, &node);
966 vat_json_free (&node);
968 vam->retval = ntohl (mp->retval);
969 vam->result_ready = 1;
973 * Special-case: build the interface table, maintain
974 * the next loopback sw_if_index vbl.
976 static void vl_api_sw_interface_details_t_handler
977 (vl_api_sw_interface_details_t * mp)
979 vat_main_t *vam = &vat_main;
980 u8 *s = format (0, "%s%c", mp->interface_name, 0);
982 hash_set_mem (vam->sw_if_index_by_interface_name, s,
983 ntohl (mp->sw_if_index));
985 /* In sub interface case, fill the sub interface table entry */
986 if (mp->sw_if_index != mp->sup_sw_if_index)
988 sw_interface_subif_t *sub = NULL;
990 vec_add2 (vam->sw_if_subif_table, sub, 1);
992 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
993 strncpy ((char *) sub->interface_name, (char *) s,
994 vec_len (sub->interface_name));
995 sub->sw_if_index = ntohl (mp->sw_if_index);
996 sub->sub_id = ntohl (mp->sub_id);
998 sub->raw_flags = ntohl (mp->sub_if_flags & SUB_IF_API_FLAG_MASK_VNET);
1000 sub->sub_number_of_tags = mp->sub_number_of_tags;
1001 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
1002 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
1004 /* vlan tag rewrite */
1005 sub->vtr_op = ntohl (mp->vtr_op);
1006 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
1007 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
1008 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
1012 static void vl_api_sw_interface_details_t_handler_json
1013 (vl_api_sw_interface_details_t * mp)
1015 vat_main_t *vam = &vat_main;
1016 vat_json_node_t *node = NULL;
1018 if (VAT_JSON_ARRAY != vam->json_tree.type)
1020 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1021 vat_json_init_array (&vam->json_tree);
1023 node = vat_json_array_add (&vam->json_tree);
1025 vat_json_init_object (node);
1026 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1027 vat_json_object_add_uint (node, "sup_sw_if_index",
1028 ntohl (mp->sup_sw_if_index));
1029 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
1030 sizeof (mp->l2_address));
1031 vat_json_object_add_string_copy (node, "interface_name",
1032 mp->interface_name);
1033 vat_json_object_add_uint (node, "flags", mp->flags);
1034 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
1035 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
1036 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
1037 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
1038 vat_json_object_add_uint (node, "sub_number_of_tags",
1039 mp->sub_number_of_tags);
1040 vat_json_object_add_uint (node, "sub_outer_vlan_id",
1041 ntohs (mp->sub_outer_vlan_id));
1042 vat_json_object_add_uint (node, "sub_inner_vlan_id",
1043 ntohs (mp->sub_inner_vlan_id));
1044 vat_json_object_add_uint (node, "sub_if_flags", ntohl (mp->sub_if_flags));
1045 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
1046 vat_json_object_add_uint (node, "vtr_push_dot1q",
1047 ntohl (mp->vtr_push_dot1q));
1048 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
1049 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
1050 if (ntohl (mp->sub_if_flags) & SUB_IF_API_FLAG_DOT1AH)
1052 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
1054 format_ethernet_address,
1056 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
1058 format_ethernet_address,
1060 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
1061 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
1065 #if VPP_API_TEST_BUILTIN == 0
1066 static void vl_api_sw_interface_event_t_handler
1067 (vl_api_sw_interface_event_t * mp)
1069 vat_main_t *vam = &vat_main;
1070 if (vam->interface_event_display)
1071 errmsg ("interface flags: sw_if_index %d %s %s",
1072 ntohl (mp->sw_if_index),
1073 ((ntohl (mp->flags)) & IF_STATUS_API_FLAG_ADMIN_UP) ?
1074 "admin-up" : "admin-down",
1075 ((ntohl (mp->flags)) & IF_STATUS_API_FLAG_LINK_UP) ?
1076 "link-up" : "link-down");
1080 __clib_unused static void
1081 vl_api_sw_interface_event_t_handler_json (vl_api_sw_interface_event_t * mp)
1083 /* JSON output not supported */
1087 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
1089 vat_main_t *vam = &vat_main;
1090 i32 retval = ntohl (mp->retval);
1092 vam->retval = retval;
1093 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1094 vam->result_ready = 1;
1098 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1100 vat_main_t *vam = &vat_main;
1101 vat_json_node_t node;
1102 api_main_t *am = &api_main;
1106 vat_json_init_object (&node);
1107 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1108 vat_json_object_add_uint (&node, "reply_in_shmem",
1109 ntohl (mp->reply_in_shmem));
1110 /* Toss the shared-memory original... */
1111 pthread_mutex_lock (&am->vlib_rp->mutex);
1112 oldheap = svm_push_data_heap (am->vlib_rp);
1114 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1117 svm_pop_heap (oldheap);
1118 pthread_mutex_unlock (&am->vlib_rp->mutex);
1120 vat_json_print (vam->ofp, &node);
1121 vat_json_free (&node);
1123 vam->retval = ntohl (mp->retval);
1124 vam->result_ready = 1;
1128 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1130 vat_main_t *vam = &vat_main;
1131 i32 retval = ntohl (mp->retval);
1132 u32 length = vl_api_string_len (&mp->reply);
1134 vec_reset_length (vam->cmd_reply);
1136 vam->retval = retval;
1139 vec_validate (vam->cmd_reply, length);
1140 clib_memcpy ((char *) (vam->cmd_reply),
1141 vl_api_from_api_string (&mp->reply), length);
1142 vam->cmd_reply[length] = 0;
1144 vam->result_ready = 1;
1148 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1150 vat_main_t *vam = &vat_main;
1151 vat_json_node_t node;
1153 vec_reset_length (vam->cmd_reply);
1155 vat_json_init_object (&node);
1156 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1157 vat_json_object_add_string_copy (&node, "reply",
1158 vl_api_from_api_string (&mp->reply));
1160 vat_json_print (vam->ofp, &node);
1161 vat_json_free (&node);
1163 vam->retval = ntohl (mp->retval);
1164 vam->result_ready = 1;
1167 static void vl_api_classify_add_del_table_reply_t_handler
1168 (vl_api_classify_add_del_table_reply_t * mp)
1170 vat_main_t *vam = &vat_main;
1171 i32 retval = ntohl (mp->retval);
1172 if (vam->async_mode)
1174 vam->async_errors += (retval < 0);
1178 vam->retval = retval;
1180 ((mp->new_table_index != 0xFFFFFFFF) ||
1181 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1182 (mp->match_n_vectors != 0xFFFFFFFF)))
1184 * Note: this is just barely thread-safe, depends on
1185 * the main thread spinning waiting for an answer...
1187 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1188 ntohl (mp->new_table_index),
1189 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1190 vam->result_ready = 1;
1194 static void vl_api_classify_add_del_table_reply_t_handler_json
1195 (vl_api_classify_add_del_table_reply_t * mp)
1197 vat_main_t *vam = &vat_main;
1198 vat_json_node_t node;
1200 vat_json_init_object (&node);
1201 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1202 vat_json_object_add_uint (&node, "new_table_index",
1203 ntohl (mp->new_table_index));
1204 vat_json_object_add_uint (&node, "skip_n_vectors",
1205 ntohl (mp->skip_n_vectors));
1206 vat_json_object_add_uint (&node, "match_n_vectors",
1207 ntohl (mp->match_n_vectors));
1209 vat_json_print (vam->ofp, &node);
1210 vat_json_free (&node);
1212 vam->retval = ntohl (mp->retval);
1213 vam->result_ready = 1;
1216 static void vl_api_get_node_index_reply_t_handler
1217 (vl_api_get_node_index_reply_t * mp)
1219 vat_main_t *vam = &vat_main;
1220 i32 retval = ntohl (mp->retval);
1221 if (vam->async_mode)
1223 vam->async_errors += (retval < 0);
1227 vam->retval = retval;
1229 errmsg ("node index %d", ntohl (mp->node_index));
1230 vam->result_ready = 1;
1234 static void vl_api_get_node_index_reply_t_handler_json
1235 (vl_api_get_node_index_reply_t * mp)
1237 vat_main_t *vam = &vat_main;
1238 vat_json_node_t node;
1240 vat_json_init_object (&node);
1241 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1242 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1244 vat_json_print (vam->ofp, &node);
1245 vat_json_free (&node);
1247 vam->retval = ntohl (mp->retval);
1248 vam->result_ready = 1;
1251 static void vl_api_get_next_index_reply_t_handler
1252 (vl_api_get_next_index_reply_t * mp)
1254 vat_main_t *vam = &vat_main;
1255 i32 retval = ntohl (mp->retval);
1256 if (vam->async_mode)
1258 vam->async_errors += (retval < 0);
1262 vam->retval = retval;
1264 errmsg ("next node index %d", ntohl (mp->next_index));
1265 vam->result_ready = 1;
1269 static void vl_api_get_next_index_reply_t_handler_json
1270 (vl_api_get_next_index_reply_t * mp)
1272 vat_main_t *vam = &vat_main;
1273 vat_json_node_t node;
1275 vat_json_init_object (&node);
1276 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1277 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1279 vat_json_print (vam->ofp, &node);
1280 vat_json_free (&node);
1282 vam->retval = ntohl (mp->retval);
1283 vam->result_ready = 1;
1286 static void vl_api_add_node_next_reply_t_handler
1287 (vl_api_add_node_next_reply_t * mp)
1289 vat_main_t *vam = &vat_main;
1290 i32 retval = ntohl (mp->retval);
1291 if (vam->async_mode)
1293 vam->async_errors += (retval < 0);
1297 vam->retval = retval;
1299 errmsg ("next index %d", ntohl (mp->next_index));
1300 vam->result_ready = 1;
1304 static void vl_api_add_node_next_reply_t_handler_json
1305 (vl_api_add_node_next_reply_t * mp)
1307 vat_main_t *vam = &vat_main;
1308 vat_json_node_t node;
1310 vat_json_init_object (&node);
1311 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1312 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1314 vat_json_print (vam->ofp, &node);
1315 vat_json_free (&node);
1317 vam->retval = ntohl (mp->retval);
1318 vam->result_ready = 1;
1321 static void vl_api_show_version_reply_t_handler
1322 (vl_api_show_version_reply_t * mp)
1324 vat_main_t *vam = &vat_main;
1325 i32 retval = ntohl (mp->retval);
1329 errmsg (" program: %s", mp->program);
1330 errmsg (" version: %s", mp->version);
1331 errmsg (" build date: %s", mp->build_date);
1332 errmsg ("build directory: %s", mp->build_directory);
1334 vam->retval = retval;
1335 vam->result_ready = 1;
1338 static void vl_api_show_version_reply_t_handler_json
1339 (vl_api_show_version_reply_t * mp)
1341 vat_main_t *vam = &vat_main;
1342 vat_json_node_t node;
1344 vat_json_init_object (&node);
1345 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1346 vat_json_object_add_string_copy (&node, "program", mp->program);
1347 vat_json_object_add_string_copy (&node, "version", mp->version);
1348 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1349 vat_json_object_add_string_copy (&node, "build_directory",
1350 mp->build_directory);
1352 vat_json_print (vam->ofp, &node);
1353 vat_json_free (&node);
1355 vam->retval = ntohl (mp->retval);
1356 vam->result_ready = 1;
1359 static void vl_api_show_threads_reply_t_handler
1360 (vl_api_show_threads_reply_t * mp)
1362 vat_main_t *vam = &vat_main;
1363 i32 retval = ntohl (mp->retval);
1367 count = ntohl (mp->count);
1369 for (i = 0; i < count; i++)
1371 "\n%-2d %-11s %-11s %-5d %-6d %-4d %-6d",
1372 ntohl (mp->thread_data[i].id), mp->thread_data[i].name,
1373 mp->thread_data[i].type, ntohl (mp->thread_data[i].pid),
1374 ntohl (mp->thread_data[i].cpu_id), ntohl (mp->thread_data[i].core),
1375 ntohl (mp->thread_data[i].cpu_socket));
1377 vam->retval = retval;
1378 vam->result_ready = 1;
1381 static void vl_api_show_threads_reply_t_handler_json
1382 (vl_api_show_threads_reply_t * mp)
1384 vat_main_t *vam = &vat_main;
1385 vat_json_node_t node;
1386 vl_api_thread_data_t *td;
1387 i32 retval = ntohl (mp->retval);
1391 count = ntohl (mp->count);
1393 vat_json_init_object (&node);
1394 vat_json_object_add_int (&node, "retval", retval);
1395 vat_json_object_add_uint (&node, "count", count);
1397 for (i = 0; i < count; i++)
1399 td = &mp->thread_data[i];
1400 vat_json_object_add_uint (&node, "id", ntohl (td->id));
1401 vat_json_object_add_string_copy (&node, "name", td->name);
1402 vat_json_object_add_string_copy (&node, "type", td->type);
1403 vat_json_object_add_uint (&node, "pid", ntohl (td->pid));
1404 vat_json_object_add_int (&node, "cpu_id", ntohl (td->cpu_id));
1405 vat_json_object_add_int (&node, "core", ntohl (td->id));
1406 vat_json_object_add_int (&node, "cpu_socket", ntohl (td->cpu_socket));
1409 vat_json_print (vam->ofp, &node);
1410 vat_json_free (&node);
1412 vam->retval = retval;
1413 vam->result_ready = 1;
1417 api_show_threads (vat_main_t * vam)
1419 vl_api_show_threads_t *mp;
1423 "\n%-2s %-11s %-11s %-5s %-6s %-4s %-6s",
1424 "ID", "Name", "Type", "LWP", "cpu_id", "Core", "Socket");
1426 M (SHOW_THREADS, mp);
1434 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1436 u32 sw_if_index = ntohl (mp->sw_if_index);
1437 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1438 mp->mac_ip ? "mac/ip binding" : "address resolution",
1439 ntohl (mp->pid), format_ip4_address, mp->ip,
1440 format_vl_api_mac_address, &mp->mac, sw_if_index);
1444 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1446 /* JSON output not supported */
1450 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1452 u32 sw_if_index = ntohl (mp->sw_if_index);
1453 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1454 mp->mac_ip ? "mac/ip binding" : "address resolution",
1455 ntohl (mp->pid), format_vl_api_ip6_address, mp->ip,
1456 format_vl_api_mac_address, mp->mac, sw_if_index);
1460 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1462 /* JSON output not supported */
1466 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1468 u32 n_macs = ntohl (mp->n_macs);
1469 errmsg ("L2MAC event received with pid %d cl-idx %d for %d macs: \n",
1470 ntohl (mp->pid), mp->client_index, n_macs);
1472 for (i = 0; i < n_macs; i++)
1474 vl_api_mac_entry_t *mac = &mp->mac[i];
1475 errmsg (" [%d] sw_if_index %d mac_addr %U action %d \n",
1476 i + 1, ntohl (mac->sw_if_index),
1477 format_ethernet_address, mac->mac_addr, mac->action);
1484 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1486 /* JSON output not supported */
1489 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1490 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1493 * Special-case: build the bridge domain table, maintain
1494 * the next bd id vbl.
1496 static void vl_api_bridge_domain_details_t_handler
1497 (vl_api_bridge_domain_details_t * mp)
1499 vat_main_t *vam = &vat_main;
1500 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1503 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-6s %-3s",
1504 " ID", "LRN", "FWD", "FLD", "BVI", "UU-FWD", "#IF");
1506 print (vam->ofp, "%3d %3d %3d %3d %3d %6d %3d",
1507 ntohl (mp->bd_id), mp->learn, mp->forward,
1508 mp->flood, ntohl (mp->bvi_sw_if_index),
1509 ntohl (mp->uu_fwd_sw_if_index), n_sw_ifs);
1513 vl_api_bridge_domain_sw_if_t *sw_ifs;
1514 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1517 sw_ifs = mp->sw_if_details;
1518 for (i = 0; i < n_sw_ifs; i++)
1524 sw_if_index = ntohl (sw_ifs->sw_if_index);
1527 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1529 if ((u32) p->value[0] == sw_if_index)
1531 sw_if_name = (u8 *)(p->key);
1536 print (vam->ofp, "%7d %3d %s", sw_if_index,
1537 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1538 "sw_if_index not found!");
1545 static void vl_api_bridge_domain_details_t_handler_json
1546 (vl_api_bridge_domain_details_t * mp)
1548 vat_main_t *vam = &vat_main;
1549 vat_json_node_t *node, *array = NULL;
1550 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1552 if (VAT_JSON_ARRAY != vam->json_tree.type)
1554 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1555 vat_json_init_array (&vam->json_tree);
1557 node = vat_json_array_add (&vam->json_tree);
1559 vat_json_init_object (node);
1560 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1561 vat_json_object_add_uint (node, "flood", mp->flood);
1562 vat_json_object_add_uint (node, "forward", mp->forward);
1563 vat_json_object_add_uint (node, "learn", mp->learn);
1564 vat_json_object_add_uint (node, "bvi_sw_if_index",
1565 ntohl (mp->bvi_sw_if_index));
1566 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1567 array = vat_json_object_add (node, "sw_if");
1568 vat_json_init_array (array);
1574 vl_api_bridge_domain_sw_if_t *sw_ifs;
1577 sw_ifs = mp->sw_if_details;
1578 for (i = 0; i < n_sw_ifs; i++)
1580 node = vat_json_array_add (array);
1581 vat_json_init_object (node);
1582 vat_json_object_add_uint (node, "sw_if_index",
1583 ntohl (sw_ifs->sw_if_index));
1584 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1590 static void vl_api_control_ping_reply_t_handler
1591 (vl_api_control_ping_reply_t * mp)
1593 vat_main_t *vam = &vat_main;
1594 i32 retval = ntohl (mp->retval);
1595 if (vam->async_mode)
1597 vam->async_errors += (retval < 0);
1601 vam->retval = retval;
1602 vam->result_ready = 1;
1604 if (vam->socket_client_main)
1605 vam->socket_client_main->control_pings_outstanding--;
1608 static void vl_api_control_ping_reply_t_handler_json
1609 (vl_api_control_ping_reply_t * mp)
1611 vat_main_t *vam = &vat_main;
1612 i32 retval = ntohl (mp->retval);
1614 if (VAT_JSON_NONE != vam->json_tree.type)
1616 vat_json_print (vam->ofp, &vam->json_tree);
1617 vat_json_free (&vam->json_tree);
1618 vam->json_tree.type = VAT_JSON_NONE;
1623 vat_json_init_array (&vam->json_tree);
1624 vat_json_print (vam->ofp, &vam->json_tree);
1625 vam->json_tree.type = VAT_JSON_NONE;
1628 vam->retval = retval;
1629 vam->result_ready = 1;
1633 vl_api_bridge_domain_set_mac_age_reply_t_handler
1634 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1636 vat_main_t *vam = &vat_main;
1637 i32 retval = ntohl (mp->retval);
1638 if (vam->async_mode)
1640 vam->async_errors += (retval < 0);
1644 vam->retval = retval;
1645 vam->result_ready = 1;
1649 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1650 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1652 vat_main_t *vam = &vat_main;
1653 vat_json_node_t node;
1655 vat_json_init_object (&node);
1656 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1658 vat_json_print (vam->ofp, &node);
1659 vat_json_free (&node);
1661 vam->retval = ntohl (mp->retval);
1662 vam->result_ready = 1;
1666 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1668 vat_main_t *vam = &vat_main;
1669 i32 retval = ntohl (mp->retval);
1670 if (vam->async_mode)
1672 vam->async_errors += (retval < 0);
1676 vam->retval = retval;
1677 vam->result_ready = 1;
1681 static void vl_api_l2_flags_reply_t_handler_json
1682 (vl_api_l2_flags_reply_t * mp)
1684 vat_main_t *vam = &vat_main;
1685 vat_json_node_t node;
1687 vat_json_init_object (&node);
1688 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1689 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1690 ntohl (mp->resulting_feature_bitmap));
1692 vat_json_print (vam->ofp, &node);
1693 vat_json_free (&node);
1695 vam->retval = ntohl (mp->retval);
1696 vam->result_ready = 1;
1699 static void vl_api_bridge_flags_reply_t_handler
1700 (vl_api_bridge_flags_reply_t * mp)
1702 vat_main_t *vam = &vat_main;
1703 i32 retval = ntohl (mp->retval);
1704 if (vam->async_mode)
1706 vam->async_errors += (retval < 0);
1710 vam->retval = retval;
1711 vam->result_ready = 1;
1715 static void vl_api_bridge_flags_reply_t_handler_json
1716 (vl_api_bridge_flags_reply_t * mp)
1718 vat_main_t *vam = &vat_main;
1719 vat_json_node_t node;
1721 vat_json_init_object (&node);
1722 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1723 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1724 ntohl (mp->resulting_feature_bitmap));
1726 vat_json_print (vam->ofp, &node);
1727 vat_json_free (&node);
1729 vam->retval = ntohl (mp->retval);
1730 vam->result_ready = 1;
1734 vl_api_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_reply_t * mp)
1736 vat_main_t *vam = &vat_main;
1737 i32 retval = ntohl (mp->retval);
1738 if (vam->async_mode)
1740 vam->async_errors += (retval < 0);
1744 vam->retval = retval;
1745 vam->sw_if_index = ntohl (mp->sw_if_index);
1746 vam->result_ready = 1;
1751 static void vl_api_tap_create_v2_reply_t_handler_json
1752 (vl_api_tap_create_v2_reply_t * mp)
1754 vat_main_t *vam = &vat_main;
1755 vat_json_node_t node;
1757 vat_json_init_object (&node);
1758 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1759 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1761 vat_json_print (vam->ofp, &node);
1762 vat_json_free (&node);
1764 vam->retval = ntohl (mp->retval);
1765 vam->result_ready = 1;
1770 vl_api_tap_delete_v2_reply_t_handler (vl_api_tap_delete_v2_reply_t * mp)
1772 vat_main_t *vam = &vat_main;
1773 i32 retval = ntohl (mp->retval);
1774 if (vam->async_mode)
1776 vam->async_errors += (retval < 0);
1780 vam->retval = retval;
1781 vam->result_ready = 1;
1785 static void vl_api_tap_delete_v2_reply_t_handler_json
1786 (vl_api_tap_delete_v2_reply_t * mp)
1788 vat_main_t *vam = &vat_main;
1789 vat_json_node_t node;
1791 vat_json_init_object (&node);
1792 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1794 vat_json_print (vam->ofp, &node);
1795 vat_json_free (&node);
1797 vam->retval = ntohl (mp->retval);
1798 vam->result_ready = 1;
1802 vl_api_virtio_pci_create_reply_t_handler (vl_api_virtio_pci_create_reply_t *
1805 vat_main_t *vam = &vat_main;
1806 i32 retval = ntohl (mp->retval);
1807 if (vam->async_mode)
1809 vam->async_errors += (retval < 0);
1813 vam->retval = retval;
1814 vam->sw_if_index = ntohl (mp->sw_if_index);
1815 vam->result_ready = 1;
1819 static void vl_api_virtio_pci_create_reply_t_handler_json
1820 (vl_api_virtio_pci_create_reply_t * mp)
1822 vat_main_t *vam = &vat_main;
1823 vat_json_node_t node;
1825 vat_json_init_object (&node);
1826 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1827 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1829 vat_json_print (vam->ofp, &node);
1830 vat_json_free (&node);
1832 vam->retval = ntohl (mp->retval);
1833 vam->result_ready = 1;
1838 vl_api_virtio_pci_delete_reply_t_handler (vl_api_virtio_pci_delete_reply_t *
1841 vat_main_t *vam = &vat_main;
1842 i32 retval = ntohl (mp->retval);
1843 if (vam->async_mode)
1845 vam->async_errors += (retval < 0);
1849 vam->retval = retval;
1850 vam->result_ready = 1;
1854 static void vl_api_virtio_pci_delete_reply_t_handler_json
1855 (vl_api_virtio_pci_delete_reply_t * mp)
1857 vat_main_t *vam = &vat_main;
1858 vat_json_node_t node;
1860 vat_json_init_object (&node);
1861 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1863 vat_json_print (vam->ofp, &node);
1864 vat_json_free (&node);
1866 vam->retval = ntohl (mp->retval);
1867 vam->result_ready = 1;
1871 vl_api_bond_create_reply_t_handler (vl_api_bond_create_reply_t * mp)
1873 vat_main_t *vam = &vat_main;
1874 i32 retval = ntohl (mp->retval);
1876 if (vam->async_mode)
1878 vam->async_errors += (retval < 0);
1882 vam->retval = retval;
1883 vam->sw_if_index = ntohl (mp->sw_if_index);
1884 vam->result_ready = 1;
1888 static void vl_api_bond_create_reply_t_handler_json
1889 (vl_api_bond_create_reply_t * mp)
1891 vat_main_t *vam = &vat_main;
1892 vat_json_node_t node;
1894 vat_json_init_object (&node);
1895 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1896 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1898 vat_json_print (vam->ofp, &node);
1899 vat_json_free (&node);
1901 vam->retval = ntohl (mp->retval);
1902 vam->result_ready = 1;
1906 vl_api_bond_delete_reply_t_handler (vl_api_bond_delete_reply_t * mp)
1908 vat_main_t *vam = &vat_main;
1909 i32 retval = ntohl (mp->retval);
1911 if (vam->async_mode)
1913 vam->async_errors += (retval < 0);
1917 vam->retval = retval;
1918 vam->result_ready = 1;
1922 static void vl_api_bond_delete_reply_t_handler_json
1923 (vl_api_bond_delete_reply_t * mp)
1925 vat_main_t *vam = &vat_main;
1926 vat_json_node_t node;
1928 vat_json_init_object (&node);
1929 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1931 vat_json_print (vam->ofp, &node);
1932 vat_json_free (&node);
1934 vam->retval = ntohl (mp->retval);
1935 vam->result_ready = 1;
1939 vl_api_bond_enslave_reply_t_handler (vl_api_bond_enslave_reply_t * mp)
1941 vat_main_t *vam = &vat_main;
1942 i32 retval = ntohl (mp->retval);
1944 if (vam->async_mode)
1946 vam->async_errors += (retval < 0);
1950 vam->retval = retval;
1951 vam->result_ready = 1;
1955 static void vl_api_bond_enslave_reply_t_handler_json
1956 (vl_api_bond_enslave_reply_t * mp)
1958 vat_main_t *vam = &vat_main;
1959 vat_json_node_t node;
1961 vat_json_init_object (&node);
1962 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1964 vat_json_print (vam->ofp, &node);
1965 vat_json_free (&node);
1967 vam->retval = ntohl (mp->retval);
1968 vam->result_ready = 1;
1972 vl_api_bond_detach_slave_reply_t_handler (vl_api_bond_detach_slave_reply_t *
1975 vat_main_t *vam = &vat_main;
1976 i32 retval = ntohl (mp->retval);
1978 if (vam->async_mode)
1980 vam->async_errors += (retval < 0);
1984 vam->retval = retval;
1985 vam->result_ready = 1;
1989 static void vl_api_bond_detach_slave_reply_t_handler_json
1990 (vl_api_bond_detach_slave_reply_t * mp)
1992 vat_main_t *vam = &vat_main;
1993 vat_json_node_t node;
1995 vat_json_init_object (&node);
1996 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1998 vat_json_print (vam->ofp, &node);
1999 vat_json_free (&node);
2001 vam->retval = ntohl (mp->retval);
2002 vam->result_ready = 1;
2006 api_sw_interface_set_bond_weight (vat_main_t * vam)
2008 unformat_input_t *i = vam->input;
2009 vl_api_sw_interface_set_bond_weight_t *mp;
2010 u32 sw_if_index = ~0;
2012 u8 weight_enter = 0;
2015 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2017 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2019 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2021 else if (unformat (i, "weight %u", &weight))
2027 if (sw_if_index == ~0)
2029 errmsg ("missing interface name or sw_if_index");
2032 if (weight_enter == 0)
2034 errmsg ("missing valid weight");
2038 /* Construct the API message */
2039 M (SW_INTERFACE_SET_BOND_WEIGHT, mp);
2040 mp->sw_if_index = ntohl (sw_if_index);
2041 mp->weight = ntohl (weight);
2048 static void vl_api_sw_interface_bond_details_t_handler
2049 (vl_api_sw_interface_bond_details_t * mp)
2051 vat_main_t *vam = &vat_main;
2054 "%-16s %-12d %-12U %-13U %-14u %-14u",
2055 mp->interface_name, ntohl (mp->sw_if_index),
2056 format_bond_mode, ntohl (mp->mode), format_bond_load_balance,
2057 ntohl (mp->lb), ntohl (mp->active_slaves), ntohl (mp->slaves));
2060 static void vl_api_sw_interface_bond_details_t_handler_json
2061 (vl_api_sw_interface_bond_details_t * mp)
2063 vat_main_t *vam = &vat_main;
2064 vat_json_node_t *node = NULL;
2066 if (VAT_JSON_ARRAY != vam->json_tree.type)
2068 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2069 vat_json_init_array (&vam->json_tree);
2071 node = vat_json_array_add (&vam->json_tree);
2073 vat_json_init_object (node);
2074 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2075 vat_json_object_add_string_copy (node, "interface_name",
2076 mp->interface_name);
2077 vat_json_object_add_uint (node, "mode", ntohl (mp->mode));
2078 vat_json_object_add_uint (node, "load_balance", ntohl (mp->lb));
2079 vat_json_object_add_uint (node, "active_slaves", ntohl (mp->active_slaves));
2080 vat_json_object_add_uint (node, "slaves", ntohl (mp->slaves));
2084 api_sw_interface_bond_dump (vat_main_t * vam)
2086 vl_api_sw_interface_bond_dump_t *mp;
2087 vl_api_control_ping_t *mp_ping;
2091 "\n%-16s %-12s %-12s %-13s %-14s %-14s",
2092 "interface name", "sw_if_index", "mode", "load balance",
2093 "active slaves", "slaves");
2095 /* Get list of bond interfaces */
2096 M (SW_INTERFACE_BOND_DUMP, mp);
2099 /* Use a control ping for synchronization */
2100 MPING (CONTROL_PING, mp_ping);
2107 static void vl_api_sw_interface_slave_details_t_handler
2108 (vl_api_sw_interface_slave_details_t * mp)
2110 vat_main_t *vam = &vat_main;
2113 "%-25s %-12d %-7d %-12d %-10d %-10d", mp->interface_name,
2114 ntohl (mp->sw_if_index), mp->is_passive, mp->is_long_timeout,
2115 ntohl (mp->weight), mp->is_local_numa);
2118 static void vl_api_sw_interface_slave_details_t_handler_json
2119 (vl_api_sw_interface_slave_details_t * mp)
2121 vat_main_t *vam = &vat_main;
2122 vat_json_node_t *node = NULL;
2124 if (VAT_JSON_ARRAY != vam->json_tree.type)
2126 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2127 vat_json_init_array (&vam->json_tree);
2129 node = vat_json_array_add (&vam->json_tree);
2131 vat_json_init_object (node);
2132 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2133 vat_json_object_add_string_copy (node, "interface_name",
2134 mp->interface_name);
2135 vat_json_object_add_uint (node, "passive", mp->is_passive);
2136 vat_json_object_add_uint (node, "long_timeout", mp->is_long_timeout);
2137 vat_json_object_add_uint (node, "weight", ntohl (mp->weight));
2138 vat_json_object_add_uint (node, "is_local_numa", mp->is_local_numa);
2142 api_sw_interface_slave_dump (vat_main_t * vam)
2144 unformat_input_t *i = vam->input;
2145 vl_api_sw_interface_slave_dump_t *mp;
2146 vl_api_control_ping_t *mp_ping;
2147 u32 sw_if_index = ~0;
2148 u8 sw_if_index_set = 0;
2151 /* Parse args required to build the message */
2152 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2154 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2155 sw_if_index_set = 1;
2156 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2157 sw_if_index_set = 1;
2162 if (sw_if_index_set == 0)
2164 errmsg ("missing vpp interface name. ");
2169 "\n%-25s %-12s %-7s %-12s %-10s %-10s",
2170 "slave interface name", "sw_if_index", "passive", "long_timeout",
2171 "weight", "local numa");
2173 /* Get list of bond interfaces */
2174 M (SW_INTERFACE_SLAVE_DUMP, mp);
2175 mp->sw_if_index = ntohl (sw_if_index);
2178 /* Use a control ping for synchronization */
2179 MPING (CONTROL_PING, mp_ping);
2186 static void vl_api_mpls_tunnel_add_del_reply_t_handler
2187 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2189 vat_main_t *vam = &vat_main;
2190 i32 retval = ntohl (mp->retval);
2191 if (vam->async_mode)
2193 vam->async_errors += (retval < 0);
2197 vam->retval = retval;
2198 vam->sw_if_index = ntohl (mp->sw_if_index);
2199 vam->result_ready = 1;
2201 vam->regenerate_interface_table = 1;
2204 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
2205 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2207 vat_main_t *vam = &vat_main;
2208 vat_json_node_t node;
2210 vat_json_init_object (&node);
2211 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2212 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
2213 ntohl (mp->sw_if_index));
2215 vat_json_print (vam->ofp, &node);
2216 vat_json_free (&node);
2218 vam->retval = ntohl (mp->retval);
2219 vam->result_ready = 1;
2222 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
2223 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2225 vat_main_t *vam = &vat_main;
2226 i32 retval = ntohl (mp->retval);
2227 if (vam->async_mode)
2229 vam->async_errors += (retval < 0);
2233 vam->retval = retval;
2234 vam->sw_if_index = ntohl (mp->sw_if_index);
2235 vam->result_ready = 1;
2239 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
2240 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2242 vat_main_t *vam = &vat_main;
2243 vat_json_node_t node;
2245 vat_json_init_object (&node);
2246 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2247 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2249 vat_json_print (vam->ofp, &node);
2250 vat_json_free (&node);
2252 vam->retval = ntohl (mp->retval);
2253 vam->result_ready = 1;
2256 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
2257 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2259 vat_main_t *vam = &vat_main;
2260 i32 retval = ntohl (mp->retval);
2261 if (vam->async_mode)
2263 vam->async_errors += (retval < 0);
2267 vam->retval = retval;
2268 vam->result_ready = 1;
2272 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
2273 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2275 vat_main_t *vam = &vat_main;
2276 vat_json_node_t node;
2278 vat_json_init_object (&node);
2279 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2280 vat_json_object_add_uint (&node, "fwd_entry_index",
2281 clib_net_to_host_u32 (mp->fwd_entry_index));
2283 vat_json_print (vam->ofp, &node);
2284 vat_json_free (&node);
2286 vam->retval = ntohl (mp->retval);
2287 vam->result_ready = 1;
2291 format_lisp_transport_protocol (u8 * s, va_list * args)
2293 u32 proto = va_arg (*args, u32);
2298 return format (s, "udp");
2300 return format (s, "api");
2307 static void vl_api_one_get_transport_protocol_reply_t_handler
2308 (vl_api_one_get_transport_protocol_reply_t * mp)
2310 vat_main_t *vam = &vat_main;
2311 i32 retval = ntohl (mp->retval);
2312 if (vam->async_mode)
2314 vam->async_errors += (retval < 0);
2318 u32 proto = mp->protocol;
2319 print (vam->ofp, "Transport protocol: %U",
2320 format_lisp_transport_protocol, proto);
2321 vam->retval = retval;
2322 vam->result_ready = 1;
2326 static void vl_api_one_get_transport_protocol_reply_t_handler_json
2327 (vl_api_one_get_transport_protocol_reply_t * mp)
2329 vat_main_t *vam = &vat_main;
2330 vat_json_node_t node;
2333 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
2336 vat_json_init_object (&node);
2337 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2338 vat_json_object_add_string_copy (&node, "transport-protocol", s);
2341 vat_json_print (vam->ofp, &node);
2342 vat_json_free (&node);
2344 vam->retval = ntohl (mp->retval);
2345 vam->result_ready = 1;
2348 static void vl_api_one_add_del_locator_set_reply_t_handler
2349 (vl_api_one_add_del_locator_set_reply_t * mp)
2351 vat_main_t *vam = &vat_main;
2352 i32 retval = ntohl (mp->retval);
2353 if (vam->async_mode)
2355 vam->async_errors += (retval < 0);
2359 vam->retval = retval;
2360 vam->result_ready = 1;
2364 static void vl_api_one_add_del_locator_set_reply_t_handler_json
2365 (vl_api_one_add_del_locator_set_reply_t * mp)
2367 vat_main_t *vam = &vat_main;
2368 vat_json_node_t node;
2370 vat_json_init_object (&node);
2371 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2372 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
2374 vat_json_print (vam->ofp, &node);
2375 vat_json_free (&node);
2377 vam->retval = ntohl (mp->retval);
2378 vam->result_ready = 1;
2381 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
2382 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2384 vat_main_t *vam = &vat_main;
2385 i32 retval = ntohl (mp->retval);
2386 if (vam->async_mode)
2388 vam->async_errors += (retval < 0);
2392 vam->retval = retval;
2393 vam->sw_if_index = ntohl (mp->sw_if_index);
2394 vam->result_ready = 1;
2396 vam->regenerate_interface_table = 1;
2399 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
2400 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2402 vat_main_t *vam = &vat_main;
2403 vat_json_node_t node;
2405 vat_json_init_object (&node);
2406 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2407 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2409 vat_json_print (vam->ofp, &node);
2410 vat_json_free (&node);
2412 vam->retval = ntohl (mp->retval);
2413 vam->result_ready = 1;
2416 static void vl_api_vxlan_offload_rx_reply_t_handler
2417 (vl_api_vxlan_offload_rx_reply_t * mp)
2419 vat_main_t *vam = &vat_main;
2420 i32 retval = ntohl (mp->retval);
2421 if (vam->async_mode)
2423 vam->async_errors += (retval < 0);
2427 vam->retval = retval;
2428 vam->result_ready = 1;
2432 static void vl_api_vxlan_offload_rx_reply_t_handler_json
2433 (vl_api_vxlan_offload_rx_reply_t * mp)
2435 vat_main_t *vam = &vat_main;
2436 vat_json_node_t node;
2438 vat_json_init_object (&node);
2439 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2441 vat_json_print (vam->ofp, &node);
2442 vat_json_free (&node);
2444 vam->retval = ntohl (mp->retval);
2445 vam->result_ready = 1;
2448 static void vl_api_geneve_add_del_tunnel_reply_t_handler
2449 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2451 vat_main_t *vam = &vat_main;
2452 i32 retval = ntohl (mp->retval);
2453 if (vam->async_mode)
2455 vam->async_errors += (retval < 0);
2459 vam->retval = retval;
2460 vam->sw_if_index = ntohl (mp->sw_if_index);
2461 vam->result_ready = 1;
2465 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
2466 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2468 vat_main_t *vam = &vat_main;
2469 vat_json_node_t node;
2471 vat_json_init_object (&node);
2472 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2473 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2475 vat_json_print (vam->ofp, &node);
2476 vat_json_free (&node);
2478 vam->retval = ntohl (mp->retval);
2479 vam->result_ready = 1;
2482 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
2483 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2485 vat_main_t *vam = &vat_main;
2486 i32 retval = ntohl (mp->retval);
2487 if (vam->async_mode)
2489 vam->async_errors += (retval < 0);
2493 vam->retval = retval;
2494 vam->sw_if_index = ntohl (mp->sw_if_index);
2495 vam->result_ready = 1;
2497 vam->regenerate_interface_table = 1;
2500 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
2501 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2503 vat_main_t *vam = &vat_main;
2504 vat_json_node_t node;
2506 vat_json_init_object (&node);
2507 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2508 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2510 vat_json_print (vam->ofp, &node);
2511 vat_json_free (&node);
2513 vam->retval = ntohl (mp->retval);
2514 vam->result_ready = 1;
2517 static void vl_api_gre_tunnel_add_del_reply_t_handler
2518 (vl_api_gre_tunnel_add_del_reply_t * mp)
2520 vat_main_t *vam = &vat_main;
2521 i32 retval = ntohl (mp->retval);
2522 if (vam->async_mode)
2524 vam->async_errors += (retval < 0);
2528 vam->retval = retval;
2529 vam->sw_if_index = ntohl (mp->sw_if_index);
2530 vam->result_ready = 1;
2534 static void vl_api_gre_tunnel_add_del_reply_t_handler_json
2535 (vl_api_gre_tunnel_add_del_reply_t * mp)
2537 vat_main_t *vam = &vat_main;
2538 vat_json_node_t node;
2540 vat_json_init_object (&node);
2541 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2542 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2544 vat_json_print (vam->ofp, &node);
2545 vat_json_free (&node);
2547 vam->retval = ntohl (mp->retval);
2548 vam->result_ready = 1;
2551 static void vl_api_create_vhost_user_if_reply_t_handler
2552 (vl_api_create_vhost_user_if_reply_t * mp)
2554 vat_main_t *vam = &vat_main;
2555 i32 retval = ntohl (mp->retval);
2556 if (vam->async_mode)
2558 vam->async_errors += (retval < 0);
2562 vam->retval = retval;
2563 vam->sw_if_index = ntohl (mp->sw_if_index);
2564 vam->result_ready = 1;
2566 vam->regenerate_interface_table = 1;
2569 static void vl_api_create_vhost_user_if_reply_t_handler_json
2570 (vl_api_create_vhost_user_if_reply_t * mp)
2572 vat_main_t *vam = &vat_main;
2573 vat_json_node_t node;
2575 vat_json_init_object (&node);
2576 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2577 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2579 vat_json_print (vam->ofp, &node);
2580 vat_json_free (&node);
2582 vam->retval = ntohl (mp->retval);
2583 vam->result_ready = 1;
2586 static void vl_api_ip_address_details_t_handler
2587 (vl_api_ip_address_details_t * mp)
2589 vat_main_t *vam = &vat_main;
2590 static ip_address_details_t empty_ip_address_details = { {0} };
2591 ip_address_details_t *address = NULL;
2592 ip_details_t *current_ip_details = NULL;
2593 ip_details_t *details = NULL;
2595 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2597 if (!details || vam->current_sw_if_index >= vec_len (details)
2598 || !details[vam->current_sw_if_index].present)
2600 errmsg ("ip address details arrived but not stored");
2601 errmsg ("ip_dump should be called first");
2605 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2607 #define addresses (current_ip_details->addr)
2609 vec_validate_init_empty (addresses, vec_len (addresses),
2610 empty_ip_address_details);
2612 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2614 clib_memcpy (&address->ip, &mp->prefix.address.un, sizeof (address->ip));
2615 address->prefix_length = mp->prefix.len;
2619 static void vl_api_ip_address_details_t_handler_json
2620 (vl_api_ip_address_details_t * mp)
2622 vat_main_t *vam = &vat_main;
2623 vat_json_node_t *node = NULL;
2625 if (VAT_JSON_ARRAY != vam->json_tree.type)
2627 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2628 vat_json_init_array (&vam->json_tree);
2630 node = vat_json_array_add (&vam->json_tree);
2632 vat_json_init_object (node);
2633 vat_json_object_add_prefix (node, &mp->prefix);
2637 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2639 vat_main_t *vam = &vat_main;
2640 static ip_details_t empty_ip_details = { 0 };
2641 ip_details_t *ip = NULL;
2642 u32 sw_if_index = ~0;
2644 sw_if_index = ntohl (mp->sw_if_index);
2646 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2647 sw_if_index, empty_ip_details);
2649 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2656 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2658 vat_main_t *vam = &vat_main;
2660 if (VAT_JSON_ARRAY != vam->json_tree.type)
2662 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2663 vat_json_init_array (&vam->json_tree);
2665 vat_json_array_add_uint (&vam->json_tree,
2666 clib_net_to_host_u32 (mp->sw_if_index));
2670 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2674 s = format (0, "DHCP compl event: pid %d %s hostname %s host_addr %U "
2675 "host_mac %U router_addr %U",
2676 ntohl (mp->pid), mp->lease.is_ipv6 ? "ipv6" : "ipv4",
2678 format_ip4_address, mp->lease.host_address,
2679 format_ethernet_address, mp->lease.host_mac,
2680 format_ip4_address, mp->lease.router_address);
2682 for (i = 0; i < mp->lease.count; i++)
2684 format (s, " domain_server_addr %U", format_ip4_address,
2685 mp->lease.domain_server[i].address);
2687 errmsg ((char *) s);
2691 static void vl_api_dhcp_compl_event_t_handler_json
2692 (vl_api_dhcp_compl_event_t * mp)
2694 /* JSON output not supported */
2697 static void vl_api_get_first_msg_id_reply_t_handler
2698 (vl_api_get_first_msg_id_reply_t * mp)
2700 vat_main_t *vam = &vat_main;
2701 i32 retval = ntohl (mp->retval);
2703 if (vam->async_mode)
2705 vam->async_errors += (retval < 0);
2709 vam->retval = retval;
2710 vam->result_ready = 1;
2714 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2718 static void vl_api_get_first_msg_id_reply_t_handler_json
2719 (vl_api_get_first_msg_id_reply_t * mp)
2721 vat_main_t *vam = &vat_main;
2722 vat_json_node_t node;
2724 vat_json_init_object (&node);
2725 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2726 vat_json_object_add_uint (&node, "first_msg_id",
2727 (uint) ntohs (mp->first_msg_id));
2729 vat_json_print (vam->ofp, &node);
2730 vat_json_free (&node);
2732 vam->retval = ntohl (mp->retval);
2733 vam->result_ready = 1;
2736 static void vl_api_get_node_graph_reply_t_handler
2737 (vl_api_get_node_graph_reply_t * mp)
2739 vat_main_t *vam = &vat_main;
2740 api_main_t *am = &api_main;
2741 i32 retval = ntohl (mp->retval);
2742 u8 *pvt_copy, *reply;
2747 if (vam->async_mode)
2749 vam->async_errors += (retval < 0);
2753 vam->retval = retval;
2754 vam->result_ready = 1;
2757 /* "Should never happen..." */
2761 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2762 pvt_copy = vec_dup (reply);
2764 /* Toss the shared-memory original... */
2765 pthread_mutex_lock (&am->vlib_rp->mutex);
2766 oldheap = svm_push_data_heap (am->vlib_rp);
2770 svm_pop_heap (oldheap);
2771 pthread_mutex_unlock (&am->vlib_rp->mutex);
2773 if (vam->graph_nodes)
2775 hash_free (vam->graph_node_index_by_name);
2777 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2779 node = vam->graph_nodes[0][i];
2780 vec_free (node->name);
2781 vec_free (node->next_nodes);
2784 vec_free (vam->graph_nodes[0]);
2785 vec_free (vam->graph_nodes);
2788 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2789 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2790 vec_free (pvt_copy);
2792 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2794 node = vam->graph_nodes[0][i];
2795 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2799 static void vl_api_get_node_graph_reply_t_handler_json
2800 (vl_api_get_node_graph_reply_t * mp)
2802 vat_main_t *vam = &vat_main;
2803 api_main_t *am = &api_main;
2805 vat_json_node_t node;
2808 /* $$$$ make this real? */
2809 vat_json_init_object (&node);
2810 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2811 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2813 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2815 /* Toss the shared-memory original... */
2816 pthread_mutex_lock (&am->vlib_rp->mutex);
2817 oldheap = svm_push_data_heap (am->vlib_rp);
2821 svm_pop_heap (oldheap);
2822 pthread_mutex_unlock (&am->vlib_rp->mutex);
2824 vat_json_print (vam->ofp, &node);
2825 vat_json_free (&node);
2827 vam->retval = ntohl (mp->retval);
2828 vam->result_ready = 1;
2832 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2834 vat_main_t *vam = &vat_main;
2839 s = format (s, "%=16d%=16d%=16d",
2840 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2844 s = format (s, "%=16U%=16d%=16d",
2845 mp->is_ipv6 ? format_ip6_address :
2847 mp->ip_address, mp->priority, mp->weight);
2850 print (vam->ofp, "%v", s);
2855 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2857 vat_main_t *vam = &vat_main;
2858 vat_json_node_t *node = NULL;
2859 struct in6_addr ip6;
2862 if (VAT_JSON_ARRAY != vam->json_tree.type)
2864 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2865 vat_json_init_array (&vam->json_tree);
2867 node = vat_json_array_add (&vam->json_tree);
2868 vat_json_init_object (node);
2870 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2871 vat_json_object_add_uint (node, "priority", mp->priority);
2872 vat_json_object_add_uint (node, "weight", mp->weight);
2875 vat_json_object_add_uint (node, "sw_if_index",
2876 clib_net_to_host_u32 (mp->sw_if_index));
2881 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2882 vat_json_object_add_ip6 (node, "address", ip6);
2886 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2887 vat_json_object_add_ip4 (node, "address", ip4);
2893 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2896 vat_main_t *vam = &vat_main;
2899 ls_name = format (0, "%s", mp->ls_name);
2901 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2907 vl_api_one_locator_set_details_t_handler_json
2908 (vl_api_one_locator_set_details_t * mp)
2910 vat_main_t *vam = &vat_main;
2911 vat_json_node_t *node = 0;
2914 ls_name = format (0, "%s", mp->ls_name);
2915 vec_add1 (ls_name, 0);
2917 if (VAT_JSON_ARRAY != vam->json_tree.type)
2919 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2920 vat_json_init_array (&vam->json_tree);
2922 node = vat_json_array_add (&vam->json_tree);
2924 vat_json_init_object (node);
2925 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2926 vat_json_object_add_uint (node, "ls_index",
2927 clib_net_to_host_u32 (mp->ls_index));
2935 } __attribute__ ((__packed__)) lisp_nsh_api_t;
2938 unformat_nsh_address (unformat_input_t * input, va_list * args)
2940 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
2941 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
2945 format_nsh_address_vat (u8 * s, va_list * args)
2947 nsh_t *a = va_arg (*args, nsh_t *);
2948 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
2952 format_lisp_flat_eid (u8 * s, va_list * args)
2954 u32 type = va_arg (*args, u32);
2955 u8 *eid = va_arg (*args, u8 *);
2956 u32 eid_len = va_arg (*args, u32);
2961 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2963 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2965 return format (s, "%U", format_ethernet_address, eid);
2967 return format (s, "%U", format_nsh_address_vat, eid);
2973 format_lisp_eid_vat (u8 * s, va_list * args)
2975 u32 type = va_arg (*args, u32);
2976 u8 *eid = va_arg (*args, u8 *);
2977 u32 eid_len = va_arg (*args, u32);
2978 u8 *seid = va_arg (*args, u8 *);
2979 u32 seid_len = va_arg (*args, u32);
2980 u32 is_src_dst = va_arg (*args, u32);
2983 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2985 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2991 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
2993 vat_main_t *vam = &vat_main;
2994 u8 *s = 0, *eid = 0;
2996 if (~0 == mp->locator_set_index)
2997 s = format (0, "action: %d", mp->action);
2999 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3001 eid = format (0, "%U", format_lisp_eid_vat,
3005 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3008 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3009 clib_net_to_host_u32 (mp->vni),
3011 mp->is_local ? "local" : "remote",
3012 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3013 clib_net_to_host_u16 (mp->key_id), mp->key);
3020 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3023 vat_main_t *vam = &vat_main;
3024 vat_json_node_t *node = 0;
3027 if (VAT_JSON_ARRAY != vam->json_tree.type)
3029 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3030 vat_json_init_array (&vam->json_tree);
3032 node = vat_json_array_add (&vam->json_tree);
3034 vat_json_init_object (node);
3035 if (~0 == mp->locator_set_index)
3036 vat_json_object_add_uint (node, "action", mp->action);
3038 vat_json_object_add_uint (node, "locator_set_index",
3039 clib_net_to_host_u32 (mp->locator_set_index));
3041 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3042 if (mp->eid_type == 3)
3044 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3045 vat_json_init_object (nsh_json);
3046 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3047 vat_json_object_add_uint (nsh_json, "spi",
3048 clib_net_to_host_u32 (nsh->spi));
3049 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3053 eid = format (0, "%U", format_lisp_eid_vat,
3057 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3059 vat_json_object_add_string_copy (node, "eid", eid);
3062 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3063 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3064 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3068 vat_json_object_add_uint (node, "key_id",
3069 clib_net_to_host_u16 (mp->key_id));
3070 vat_json_object_add_string_copy (node, "key", mp->key);
3075 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3077 vat_main_t *vam = &vat_main;
3078 u8 *seid = 0, *deid = 0;
3079 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3081 deid = format (0, "%U", format_lisp_eid_vat,
3082 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3084 seid = format (0, "%U", format_lisp_eid_vat,
3085 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3091 format_ip_address_fcn = format_ip4_address;
3093 format_ip_address_fcn = format_ip6_address;
3096 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3097 clib_net_to_host_u32 (mp->vni),
3099 format_ip_address_fcn, mp->lloc,
3100 format_ip_address_fcn, mp->rloc,
3101 clib_net_to_host_u32 (mp->pkt_count),
3102 clib_net_to_host_u32 (mp->bytes));
3109 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3111 struct in6_addr ip6;
3113 vat_main_t *vam = &vat_main;
3114 vat_json_node_t *node = 0;
3115 u8 *deid = 0, *seid = 0;
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);
3124 vat_json_init_object (node);
3125 deid = format (0, "%U", format_lisp_eid_vat,
3126 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3128 seid = format (0, "%U", format_lisp_eid_vat,
3129 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3134 vat_json_object_add_string_copy (node, "seid", seid);
3135 vat_json_object_add_string_copy (node, "deid", deid);
3136 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3140 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3141 vat_json_object_add_ip4 (node, "lloc", ip4);
3142 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3143 vat_json_object_add_ip4 (node, "rloc", ip4);
3147 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3148 vat_json_object_add_ip6 (node, "lloc", ip6);
3149 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3150 vat_json_object_add_ip6 (node, "rloc", ip6);
3152 vat_json_object_add_uint (node, "pkt_count",
3153 clib_net_to_host_u32 (mp->pkt_count));
3154 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3161 vl_api_one_eid_table_map_details_t_handler
3162 (vl_api_one_eid_table_map_details_t * mp)
3164 vat_main_t *vam = &vat_main;
3166 u8 *line = format (0, "%=10d%=10d",
3167 clib_net_to_host_u32 (mp->vni),
3168 clib_net_to_host_u32 (mp->dp_table));
3169 print (vam->ofp, "%v", line);
3174 vl_api_one_eid_table_map_details_t_handler_json
3175 (vl_api_one_eid_table_map_details_t * mp)
3177 vat_main_t *vam = &vat_main;
3178 vat_json_node_t *node = NULL;
3180 if (VAT_JSON_ARRAY != vam->json_tree.type)
3182 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3183 vat_json_init_array (&vam->json_tree);
3185 node = vat_json_array_add (&vam->json_tree);
3186 vat_json_init_object (node);
3187 vat_json_object_add_uint (node, "dp_table",
3188 clib_net_to_host_u32 (mp->dp_table));
3189 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3193 vl_api_one_eid_table_vni_details_t_handler
3194 (vl_api_one_eid_table_vni_details_t * mp)
3196 vat_main_t *vam = &vat_main;
3198 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3199 print (vam->ofp, "%v", line);
3204 vl_api_one_eid_table_vni_details_t_handler_json
3205 (vl_api_one_eid_table_vni_details_t * mp)
3207 vat_main_t *vam = &vat_main;
3208 vat_json_node_t *node = NULL;
3210 if (VAT_JSON_ARRAY != vam->json_tree.type)
3212 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3213 vat_json_init_array (&vam->json_tree);
3215 node = vat_json_array_add (&vam->json_tree);
3216 vat_json_init_object (node);
3217 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3221 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3222 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3224 vat_main_t *vam = &vat_main;
3225 int retval = clib_net_to_host_u32 (mp->retval);
3227 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3228 print (vam->ofp, "fallback threshold value: %d", mp->value);
3230 vam->retval = retval;
3231 vam->result_ready = 1;
3235 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3236 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3238 vat_main_t *vam = &vat_main;
3239 vat_json_node_t _node, *node = &_node;
3240 int retval = clib_net_to_host_u32 (mp->retval);
3242 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3243 vat_json_init_object (node);
3244 vat_json_object_add_uint (node, "value", mp->value);
3246 vat_json_print (vam->ofp, node);
3247 vat_json_free (node);
3249 vam->retval = retval;
3250 vam->result_ready = 1;
3254 vl_api_show_one_map_register_state_reply_t_handler
3255 (vl_api_show_one_map_register_state_reply_t * mp)
3257 vat_main_t *vam = &vat_main;
3258 int retval = clib_net_to_host_u32 (mp->retval);
3260 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3262 vam->retval = retval;
3263 vam->result_ready = 1;
3267 vl_api_show_one_map_register_state_reply_t_handler_json
3268 (vl_api_show_one_map_register_state_reply_t * mp)
3270 vat_main_t *vam = &vat_main;
3271 vat_json_node_t _node, *node = &_node;
3272 int retval = clib_net_to_host_u32 (mp->retval);
3274 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3276 vat_json_init_object (node);
3277 vat_json_object_add_string_copy (node, "state", s);
3279 vat_json_print (vam->ofp, node);
3280 vat_json_free (node);
3282 vam->retval = retval;
3283 vam->result_ready = 1;
3288 vl_api_show_one_rloc_probe_state_reply_t_handler
3289 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3291 vat_main_t *vam = &vat_main;
3292 int retval = clib_net_to_host_u32 (mp->retval);
3297 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3299 vam->retval = retval;
3300 vam->result_ready = 1;
3304 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3305 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3307 vat_main_t *vam = &vat_main;
3308 vat_json_node_t _node, *node = &_node;
3309 int retval = clib_net_to_host_u32 (mp->retval);
3311 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3312 vat_json_init_object (node);
3313 vat_json_object_add_string_copy (node, "state", s);
3315 vat_json_print (vam->ofp, node);
3316 vat_json_free (node);
3318 vam->retval = retval;
3319 vam->result_ready = 1;
3324 vl_api_show_one_stats_enable_disable_reply_t_handler
3325 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3327 vat_main_t *vam = &vat_main;
3328 int retval = clib_net_to_host_u32 (mp->retval);
3333 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3335 vam->retval = retval;
3336 vam->result_ready = 1;
3340 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3341 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3343 vat_main_t *vam = &vat_main;
3344 vat_json_node_t _node, *node = &_node;
3345 int retval = clib_net_to_host_u32 (mp->retval);
3347 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3348 vat_json_init_object (node);
3349 vat_json_object_add_string_copy (node, "state", s);
3351 vat_json_print (vam->ofp, node);
3352 vat_json_free (node);
3354 vam->retval = retval;
3355 vam->result_ready = 1;
3360 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3362 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3363 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3364 e->vni = clib_net_to_host_u32 (e->vni);
3368 gpe_fwd_entries_get_reply_t_net_to_host
3369 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3373 mp->count = clib_net_to_host_u32 (mp->count);
3374 for (i = 0; i < mp->count; i++)
3376 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3381 format_gpe_encap_mode (u8 * s, va_list * args)
3383 u32 mode = va_arg (*args, u32);
3388 return format (s, "lisp");
3390 return format (s, "vxlan");
3396 vl_api_gpe_get_encap_mode_reply_t_handler
3397 (vl_api_gpe_get_encap_mode_reply_t * mp)
3399 vat_main_t *vam = &vat_main;
3401 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3402 vam->retval = ntohl (mp->retval);
3403 vam->result_ready = 1;
3407 vl_api_gpe_get_encap_mode_reply_t_handler_json
3408 (vl_api_gpe_get_encap_mode_reply_t * mp)
3410 vat_main_t *vam = &vat_main;
3411 vat_json_node_t node;
3413 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3414 vec_add1 (encap_mode, 0);
3416 vat_json_init_object (&node);
3417 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3419 vec_free (encap_mode);
3420 vat_json_print (vam->ofp, &node);
3421 vat_json_free (&node);
3423 vam->retval = ntohl (mp->retval);
3424 vam->result_ready = 1;
3428 vl_api_gpe_fwd_entry_path_details_t_handler
3429 (vl_api_gpe_fwd_entry_path_details_t * mp)
3431 vat_main_t *vam = &vat_main;
3432 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3434 if (mp->lcl_loc.is_ip4)
3435 format_ip_address_fcn = format_ip4_address;
3437 format_ip_address_fcn = format_ip6_address;
3439 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3440 format_ip_address_fcn, &mp->lcl_loc,
3441 format_ip_address_fcn, &mp->rmt_loc);
3445 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3447 struct in6_addr ip6;
3452 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3453 vat_json_object_add_ip4 (n, "address", ip4);
3457 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3458 vat_json_object_add_ip6 (n, "address", ip6);
3460 vat_json_object_add_uint (n, "weight", loc->weight);
3464 vl_api_gpe_fwd_entry_path_details_t_handler_json
3465 (vl_api_gpe_fwd_entry_path_details_t * mp)
3467 vat_main_t *vam = &vat_main;
3468 vat_json_node_t *node = NULL;
3469 vat_json_node_t *loc_node;
3471 if (VAT_JSON_ARRAY != vam->json_tree.type)
3473 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3474 vat_json_init_array (&vam->json_tree);
3476 node = vat_json_array_add (&vam->json_tree);
3477 vat_json_init_object (node);
3479 loc_node = vat_json_object_add (node, "local_locator");
3480 vat_json_init_object (loc_node);
3481 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3483 loc_node = vat_json_object_add (node, "remote_locator");
3484 vat_json_init_object (loc_node);
3485 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3489 vl_api_gpe_fwd_entries_get_reply_t_handler
3490 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3492 vat_main_t *vam = &vat_main;
3494 int retval = clib_net_to_host_u32 (mp->retval);
3495 vl_api_gpe_fwd_entry_t *e;
3500 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3502 for (i = 0; i < mp->count; i++)
3504 e = &mp->entries[i];
3505 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3506 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3507 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3511 vam->retval = retval;
3512 vam->result_ready = 1;
3516 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3517 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3520 vat_main_t *vam = &vat_main;
3521 vat_json_node_t *e = 0, root;
3523 int retval = clib_net_to_host_u32 (mp->retval);
3524 vl_api_gpe_fwd_entry_t *fwd;
3529 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3530 vat_json_init_array (&root);
3532 for (i = 0; i < mp->count; i++)
3534 e = vat_json_array_add (&root);
3535 fwd = &mp->entries[i];
3537 vat_json_init_object (e);
3538 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3539 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3540 vat_json_object_add_int (e, "vni", fwd->vni);
3541 vat_json_object_add_int (e, "action", fwd->action);
3543 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3544 fwd->leid_prefix_len);
3546 vat_json_object_add_string_copy (e, "leid", s);
3549 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3550 fwd->reid_prefix_len);
3552 vat_json_object_add_string_copy (e, "reid", s);
3556 vat_json_print (vam->ofp, &root);
3557 vat_json_free (&root);
3560 vam->retval = retval;
3561 vam->result_ready = 1;
3565 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3566 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3568 vat_main_t *vam = &vat_main;
3570 int retval = clib_net_to_host_u32 (mp->retval);
3571 vl_api_gpe_native_fwd_rpath_t *r;
3576 n = clib_net_to_host_u32 (mp->count);
3578 for (i = 0; i < n; i++)
3580 r = &mp->entries[i];
3581 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3582 clib_net_to_host_u32 (r->fib_index),
3583 clib_net_to_host_u32 (r->nh_sw_if_index),
3584 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3588 vam->retval = retval;
3589 vam->result_ready = 1;
3593 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3594 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3596 vat_main_t *vam = &vat_main;
3597 vat_json_node_t root, *e;
3599 int retval = clib_net_to_host_u32 (mp->retval);
3600 vl_api_gpe_native_fwd_rpath_t *r;
3606 n = clib_net_to_host_u32 (mp->count);
3607 vat_json_init_array (&root);
3609 for (i = 0; i < n; i++)
3611 e = vat_json_array_add (&root);
3612 vat_json_init_object (e);
3613 r = &mp->entries[i];
3615 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3618 vat_json_object_add_string_copy (e, "ip4", s);
3621 vat_json_object_add_uint (e, "fib_index",
3622 clib_net_to_host_u32 (r->fib_index));
3623 vat_json_object_add_uint (e, "nh_sw_if_index",
3624 clib_net_to_host_u32 (r->nh_sw_if_index));
3627 vat_json_print (vam->ofp, &root);
3628 vat_json_free (&root);
3631 vam->retval = retval;
3632 vam->result_ready = 1;
3636 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3637 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3639 vat_main_t *vam = &vat_main;
3641 int retval = clib_net_to_host_u32 (mp->retval);
3646 n = clib_net_to_host_u32 (mp->count);
3648 for (i = 0; i < n; i++)
3649 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3652 vam->retval = retval;
3653 vam->result_ready = 1;
3657 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3658 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3660 vat_main_t *vam = &vat_main;
3661 vat_json_node_t root;
3663 int retval = clib_net_to_host_u32 (mp->retval);
3668 n = clib_net_to_host_u32 (mp->count);
3669 vat_json_init_array (&root);
3671 for (i = 0; i < n; i++)
3672 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3674 vat_json_print (vam->ofp, &root);
3675 vat_json_free (&root);
3678 vam->retval = retval;
3679 vam->result_ready = 1;
3683 vl_api_one_ndp_entries_get_reply_t_handler
3684 (vl_api_one_ndp_entries_get_reply_t * mp)
3686 vat_main_t *vam = &vat_main;
3688 int retval = clib_net_to_host_u32 (mp->retval);
3693 n = clib_net_to_host_u32 (mp->count);
3695 for (i = 0; i < n; i++)
3696 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3697 format_ethernet_address, mp->entries[i].mac);
3700 vam->retval = retval;
3701 vam->result_ready = 1;
3705 vl_api_one_ndp_entries_get_reply_t_handler_json
3706 (vl_api_one_ndp_entries_get_reply_t * mp)
3709 vat_main_t *vam = &vat_main;
3710 vat_json_node_t *e = 0, root;
3712 int retval = clib_net_to_host_u32 (mp->retval);
3713 vl_api_one_ndp_entry_t *arp_entry;
3718 n = clib_net_to_host_u32 (mp->count);
3719 vat_json_init_array (&root);
3721 for (i = 0; i < n; i++)
3723 e = vat_json_array_add (&root);
3724 arp_entry = &mp->entries[i];
3726 vat_json_init_object (e);
3727 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3730 vat_json_object_add_string_copy (e, "mac", s);
3733 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3735 vat_json_object_add_string_copy (e, "ip6", s);
3739 vat_json_print (vam->ofp, &root);
3740 vat_json_free (&root);
3743 vam->retval = retval;
3744 vam->result_ready = 1;
3748 vl_api_one_l2_arp_entries_get_reply_t_handler
3749 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3751 vat_main_t *vam = &vat_main;
3753 int retval = clib_net_to_host_u32 (mp->retval);
3758 n = clib_net_to_host_u32 (mp->count);
3760 for (i = 0; i < n; i++)
3761 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3762 format_ethernet_address, mp->entries[i].mac);
3765 vam->retval = retval;
3766 vam->result_ready = 1;
3770 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3771 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3774 vat_main_t *vam = &vat_main;
3775 vat_json_node_t *e = 0, root;
3777 int retval = clib_net_to_host_u32 (mp->retval);
3778 vl_api_one_l2_arp_entry_t *arp_entry;
3783 n = clib_net_to_host_u32 (mp->count);
3784 vat_json_init_array (&root);
3786 for (i = 0; i < n; i++)
3788 e = vat_json_array_add (&root);
3789 arp_entry = &mp->entries[i];
3791 vat_json_init_object (e);
3792 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3795 vat_json_object_add_string_copy (e, "mac", s);
3798 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3800 vat_json_object_add_string_copy (e, "ip4", s);
3804 vat_json_print (vam->ofp, &root);
3805 vat_json_free (&root);
3808 vam->retval = retval;
3809 vam->result_ready = 1;
3813 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
3815 vat_main_t *vam = &vat_main;
3817 int retval = clib_net_to_host_u32 (mp->retval);
3822 n = clib_net_to_host_u32 (mp->count);
3824 for (i = 0; i < n; i++)
3826 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3830 vam->retval = retval;
3831 vam->result_ready = 1;
3835 vl_api_one_ndp_bd_get_reply_t_handler_json
3836 (vl_api_one_ndp_bd_get_reply_t * mp)
3838 vat_main_t *vam = &vat_main;
3839 vat_json_node_t root;
3841 int retval = clib_net_to_host_u32 (mp->retval);
3846 n = clib_net_to_host_u32 (mp->count);
3847 vat_json_init_array (&root);
3849 for (i = 0; i < n; i++)
3851 vat_json_array_add_uint (&root,
3852 clib_net_to_host_u32 (mp->bridge_domains[i]));
3855 vat_json_print (vam->ofp, &root);
3856 vat_json_free (&root);
3859 vam->retval = retval;
3860 vam->result_ready = 1;
3864 vl_api_one_l2_arp_bd_get_reply_t_handler
3865 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3867 vat_main_t *vam = &vat_main;
3869 int retval = clib_net_to_host_u32 (mp->retval);
3874 n = clib_net_to_host_u32 (mp->count);
3876 for (i = 0; i < n; i++)
3878 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3882 vam->retval = retval;
3883 vam->result_ready = 1;
3887 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3888 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3890 vat_main_t *vam = &vat_main;
3891 vat_json_node_t root;
3893 int retval = clib_net_to_host_u32 (mp->retval);
3898 n = clib_net_to_host_u32 (mp->count);
3899 vat_json_init_array (&root);
3901 for (i = 0; i < n; i++)
3903 vat_json_array_add_uint (&root,
3904 clib_net_to_host_u32 (mp->bridge_domains[i]));
3907 vat_json_print (vam->ofp, &root);
3908 vat_json_free (&root);
3911 vam->retval = retval;
3912 vam->result_ready = 1;
3916 vl_api_one_adjacencies_get_reply_t_handler
3917 (vl_api_one_adjacencies_get_reply_t * mp)
3919 vat_main_t *vam = &vat_main;
3921 int retval = clib_net_to_host_u32 (mp->retval);
3922 vl_api_one_adjacency_t *a;
3927 n = clib_net_to_host_u32 (mp->count);
3929 for (i = 0; i < n; i++)
3931 a = &mp->adjacencies[i];
3932 print (vam->ofp, "%U %40U",
3933 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3934 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3938 vam->retval = retval;
3939 vam->result_ready = 1;
3943 vl_api_one_adjacencies_get_reply_t_handler_json
3944 (vl_api_one_adjacencies_get_reply_t * mp)
3947 vat_main_t *vam = &vat_main;
3948 vat_json_node_t *e = 0, root;
3950 int retval = clib_net_to_host_u32 (mp->retval);
3951 vl_api_one_adjacency_t *a;
3956 n = clib_net_to_host_u32 (mp->count);
3957 vat_json_init_array (&root);
3959 for (i = 0; i < n; i++)
3961 e = vat_json_array_add (&root);
3962 a = &mp->adjacencies[i];
3964 vat_json_init_object (e);
3965 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
3966 a->leid_prefix_len);
3968 vat_json_object_add_string_copy (e, "leid", s);
3971 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
3972 a->reid_prefix_len);
3974 vat_json_object_add_string_copy (e, "reid", s);
3978 vat_json_print (vam->ofp, &root);
3979 vat_json_free (&root);
3982 vam->retval = retval;
3983 vam->result_ready = 1;
3987 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
3989 vat_main_t *vam = &vat_main;
3991 print (vam->ofp, "%=20U",
3992 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3997 vl_api_one_map_server_details_t_handler_json
3998 (vl_api_one_map_server_details_t * mp)
4000 vat_main_t *vam = &vat_main;
4001 vat_json_node_t *node = NULL;
4002 struct in6_addr ip6;
4005 if (VAT_JSON_ARRAY != vam->json_tree.type)
4007 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4008 vat_json_init_array (&vam->json_tree);
4010 node = vat_json_array_add (&vam->json_tree);
4012 vat_json_init_object (node);
4015 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4016 vat_json_object_add_ip6 (node, "map-server", ip6);
4020 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4021 vat_json_object_add_ip4 (node, "map-server", ip4);
4026 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4029 vat_main_t *vam = &vat_main;
4031 print (vam->ofp, "%=20U",
4032 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4037 vl_api_one_map_resolver_details_t_handler_json
4038 (vl_api_one_map_resolver_details_t * mp)
4040 vat_main_t *vam = &vat_main;
4041 vat_json_node_t *node = NULL;
4042 struct in6_addr ip6;
4045 if (VAT_JSON_ARRAY != vam->json_tree.type)
4047 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4048 vat_json_init_array (&vam->json_tree);
4050 node = vat_json_array_add (&vam->json_tree);
4052 vat_json_init_object (node);
4055 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4056 vat_json_object_add_ip6 (node, "map resolver", ip6);
4060 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4061 vat_json_object_add_ip4 (node, "map resolver", ip4);
4066 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4068 vat_main_t *vam = &vat_main;
4069 i32 retval = ntohl (mp->retval);
4073 print (vam->ofp, "feature: %s\ngpe: %s",
4074 mp->feature_status ? "enabled" : "disabled",
4075 mp->gpe_status ? "enabled" : "disabled");
4078 vam->retval = retval;
4079 vam->result_ready = 1;
4083 vl_api_show_one_status_reply_t_handler_json
4084 (vl_api_show_one_status_reply_t * mp)
4086 vat_main_t *vam = &vat_main;
4087 vat_json_node_t node;
4088 u8 *gpe_status = NULL;
4089 u8 *feature_status = NULL;
4091 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4092 feature_status = format (0, "%s",
4093 mp->feature_status ? "enabled" : "disabled");
4094 vec_add1 (gpe_status, 0);
4095 vec_add1 (feature_status, 0);
4097 vat_json_init_object (&node);
4098 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4099 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4101 vec_free (gpe_status);
4102 vec_free (feature_status);
4104 vat_json_print (vam->ofp, &node);
4105 vat_json_free (&node);
4107 vam->retval = ntohl (mp->retval);
4108 vam->result_ready = 1;
4112 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4113 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4115 vat_main_t *vam = &vat_main;
4116 i32 retval = ntohl (mp->retval);
4120 print (vam->ofp, "%=20s", mp->locator_set_name);
4123 vam->retval = retval;
4124 vam->result_ready = 1;
4128 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4129 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4131 vat_main_t *vam = &vat_main;
4132 vat_json_node_t *node = NULL;
4134 if (VAT_JSON_ARRAY != vam->json_tree.type)
4136 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4137 vat_json_init_array (&vam->json_tree);
4139 node = vat_json_array_add (&vam->json_tree);
4141 vat_json_init_object (node);
4142 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4144 vat_json_print (vam->ofp, node);
4145 vat_json_free (node);
4147 vam->retval = ntohl (mp->retval);
4148 vam->result_ready = 1;
4152 format_lisp_map_request_mode (u8 * s, va_list * args)
4154 u32 mode = va_arg (*args, u32);
4159 return format (0, "dst-only");
4161 return format (0, "src-dst");
4167 vl_api_show_one_map_request_mode_reply_t_handler
4168 (vl_api_show_one_map_request_mode_reply_t * mp)
4170 vat_main_t *vam = &vat_main;
4171 i32 retval = ntohl (mp->retval);
4175 u32 mode = mp->mode;
4176 print (vam->ofp, "map_request_mode: %U",
4177 format_lisp_map_request_mode, mode);
4180 vam->retval = retval;
4181 vam->result_ready = 1;
4185 vl_api_show_one_map_request_mode_reply_t_handler_json
4186 (vl_api_show_one_map_request_mode_reply_t * mp)
4188 vat_main_t *vam = &vat_main;
4189 vat_json_node_t node;
4194 s = format (0, "%U", format_lisp_map_request_mode, mode);
4197 vat_json_init_object (&node);
4198 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4199 vat_json_print (vam->ofp, &node);
4200 vat_json_free (&node);
4203 vam->retval = ntohl (mp->retval);
4204 vam->result_ready = 1;
4208 vl_api_one_show_xtr_mode_reply_t_handler
4209 (vl_api_one_show_xtr_mode_reply_t * mp)
4211 vat_main_t *vam = &vat_main;
4212 i32 retval = ntohl (mp->retval);
4216 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4219 vam->retval = retval;
4220 vam->result_ready = 1;
4224 vl_api_one_show_xtr_mode_reply_t_handler_json
4225 (vl_api_one_show_xtr_mode_reply_t * mp)
4227 vat_main_t *vam = &vat_main;
4228 vat_json_node_t node;
4231 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4232 vec_add1 (status, 0);
4234 vat_json_init_object (&node);
4235 vat_json_object_add_string_copy (&node, "status", status);
4239 vat_json_print (vam->ofp, &node);
4240 vat_json_free (&node);
4242 vam->retval = ntohl (mp->retval);
4243 vam->result_ready = 1;
4247 vl_api_one_show_pitr_mode_reply_t_handler
4248 (vl_api_one_show_pitr_mode_reply_t * mp)
4250 vat_main_t *vam = &vat_main;
4251 i32 retval = ntohl (mp->retval);
4255 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4258 vam->retval = retval;
4259 vam->result_ready = 1;
4263 vl_api_one_show_pitr_mode_reply_t_handler_json
4264 (vl_api_one_show_pitr_mode_reply_t * mp)
4266 vat_main_t *vam = &vat_main;
4267 vat_json_node_t node;
4270 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4271 vec_add1 (status, 0);
4273 vat_json_init_object (&node);
4274 vat_json_object_add_string_copy (&node, "status", status);
4278 vat_json_print (vam->ofp, &node);
4279 vat_json_free (&node);
4281 vam->retval = ntohl (mp->retval);
4282 vam->result_ready = 1;
4286 vl_api_one_show_petr_mode_reply_t_handler
4287 (vl_api_one_show_petr_mode_reply_t * mp)
4289 vat_main_t *vam = &vat_main;
4290 i32 retval = ntohl (mp->retval);
4294 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4297 vam->retval = retval;
4298 vam->result_ready = 1;
4302 vl_api_one_show_petr_mode_reply_t_handler_json
4303 (vl_api_one_show_petr_mode_reply_t * mp)
4305 vat_main_t *vam = &vat_main;
4306 vat_json_node_t node;
4309 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4310 vec_add1 (status, 0);
4312 vat_json_init_object (&node);
4313 vat_json_object_add_string_copy (&node, "status", status);
4317 vat_json_print (vam->ofp, &node);
4318 vat_json_free (&node);
4320 vam->retval = ntohl (mp->retval);
4321 vam->result_ready = 1;
4325 vl_api_show_one_use_petr_reply_t_handler
4326 (vl_api_show_one_use_petr_reply_t * mp)
4328 vat_main_t *vam = &vat_main;
4329 i32 retval = ntohl (mp->retval);
4333 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4336 print (vam->ofp, "Proxy-ETR address; %U",
4337 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4342 vam->retval = retval;
4343 vam->result_ready = 1;
4347 vl_api_show_one_use_petr_reply_t_handler_json
4348 (vl_api_show_one_use_petr_reply_t * mp)
4350 vat_main_t *vam = &vat_main;
4351 vat_json_node_t node;
4354 struct in6_addr ip6;
4356 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4357 vec_add1 (status, 0);
4359 vat_json_init_object (&node);
4360 vat_json_object_add_string_copy (&node, "status", status);
4365 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4366 vat_json_object_add_ip6 (&node, "address", ip6);
4370 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4371 vat_json_object_add_ip4 (&node, "address", ip4);
4377 vat_json_print (vam->ofp, &node);
4378 vat_json_free (&node);
4380 vam->retval = ntohl (mp->retval);
4381 vam->result_ready = 1;
4385 vl_api_show_one_nsh_mapping_reply_t_handler
4386 (vl_api_show_one_nsh_mapping_reply_t * mp)
4388 vat_main_t *vam = &vat_main;
4389 i32 retval = ntohl (mp->retval);
4393 print (vam->ofp, "%-20s%-16s",
4394 mp->is_set ? "set" : "not-set",
4395 mp->is_set ? (char *) mp->locator_set_name : "");
4398 vam->retval = retval;
4399 vam->result_ready = 1;
4403 vl_api_show_one_nsh_mapping_reply_t_handler_json
4404 (vl_api_show_one_nsh_mapping_reply_t * mp)
4406 vat_main_t *vam = &vat_main;
4407 vat_json_node_t node;
4410 status = format (0, "%s", mp->is_set ? "yes" : "no");
4411 vec_add1 (status, 0);
4413 vat_json_init_object (&node);
4414 vat_json_object_add_string_copy (&node, "is_set", status);
4417 vat_json_object_add_string_copy (&node, "locator_set",
4418 mp->locator_set_name);
4423 vat_json_print (vam->ofp, &node);
4424 vat_json_free (&node);
4426 vam->retval = ntohl (mp->retval);
4427 vam->result_ready = 1;
4431 vl_api_show_one_map_register_ttl_reply_t_handler
4432 (vl_api_show_one_map_register_ttl_reply_t * mp)
4434 vat_main_t *vam = &vat_main;
4435 i32 retval = ntohl (mp->retval);
4437 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4441 print (vam->ofp, "ttl: %u", mp->ttl);
4444 vam->retval = retval;
4445 vam->result_ready = 1;
4449 vl_api_show_one_map_register_ttl_reply_t_handler_json
4450 (vl_api_show_one_map_register_ttl_reply_t * mp)
4452 vat_main_t *vam = &vat_main;
4453 vat_json_node_t node;
4455 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4456 vat_json_init_object (&node);
4457 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4459 vat_json_print (vam->ofp, &node);
4460 vat_json_free (&node);
4462 vam->retval = ntohl (mp->retval);
4463 vam->result_ready = 1;
4467 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4469 vat_main_t *vam = &vat_main;
4470 i32 retval = ntohl (mp->retval);
4474 print (vam->ofp, "%-20s%-16s",
4475 mp->status ? "enabled" : "disabled",
4476 mp->status ? (char *) mp->locator_set_name : "");
4479 vam->retval = retval;
4480 vam->result_ready = 1;
4484 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4486 vat_main_t *vam = &vat_main;
4487 vat_json_node_t node;
4490 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4491 vec_add1 (status, 0);
4493 vat_json_init_object (&node);
4494 vat_json_object_add_string_copy (&node, "status", status);
4497 vat_json_object_add_string_copy (&node, "locator_set",
4498 mp->locator_set_name);
4503 vat_json_print (vam->ofp, &node);
4504 vat_json_free (&node);
4506 vam->retval = ntohl (mp->retval);
4507 vam->result_ready = 1;
4511 format_policer_type (u8 * s, va_list * va)
4513 u32 i = va_arg (*va, u32);
4515 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4516 s = format (s, "1r2c");
4517 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4518 s = format (s, "1r3c");
4519 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4520 s = format (s, "2r3c-2698");
4521 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4522 s = format (s, "2r3c-4115");
4523 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4524 s = format (s, "2r3c-mef5cf1");
4526 s = format (s, "ILLEGAL");
4531 format_policer_rate_type (u8 * s, va_list * va)
4533 u32 i = va_arg (*va, u32);
4535 if (i == SSE2_QOS_RATE_KBPS)
4536 s = format (s, "kbps");
4537 else if (i == SSE2_QOS_RATE_PPS)
4538 s = format (s, "pps");
4540 s = format (s, "ILLEGAL");
4545 format_policer_round_type (u8 * s, va_list * va)
4547 u32 i = va_arg (*va, u32);
4549 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4550 s = format (s, "closest");
4551 else if (i == SSE2_QOS_ROUND_TO_UP)
4552 s = format (s, "up");
4553 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4554 s = format (s, "down");
4556 s = format (s, "ILLEGAL");
4561 format_policer_action_type (u8 * s, va_list * va)
4563 u32 i = va_arg (*va, u32);
4565 if (i == SSE2_QOS_ACTION_DROP)
4566 s = format (s, "drop");
4567 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4568 s = format (s, "transmit");
4569 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4570 s = format (s, "mark-and-transmit");
4572 s = format (s, "ILLEGAL");
4577 format_dscp (u8 * s, va_list * va)
4579 u32 i = va_arg (*va, u32);
4584 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4588 return format (s, "ILLEGAL");
4590 s = format (s, "%s", t);
4595 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4597 vat_main_t *vam = &vat_main;
4598 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4600 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4601 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4603 conform_dscp_str = format (0, "");
4605 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4606 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4608 exceed_dscp_str = format (0, "");
4610 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4611 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4613 violate_dscp_str = format (0, "");
4615 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4616 "rate type %U, round type %U, %s rate, %s color-aware, "
4617 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4618 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4619 "conform action %U%s, exceed action %U%s, violate action %U%s",
4621 format_policer_type, mp->type,
4624 clib_net_to_host_u64 (mp->cb),
4625 clib_net_to_host_u64 (mp->eb),
4626 format_policer_rate_type, mp->rate_type,
4627 format_policer_round_type, mp->round_type,
4628 mp->single_rate ? "single" : "dual",
4629 mp->color_aware ? "is" : "not",
4630 ntohl (mp->cir_tokens_per_period),
4631 ntohl (mp->pir_tokens_per_period),
4633 ntohl (mp->current_limit),
4634 ntohl (mp->current_bucket),
4635 ntohl (mp->extended_limit),
4636 ntohl (mp->extended_bucket),
4637 clib_net_to_host_u64 (mp->last_update_time),
4638 format_policer_action_type, mp->conform_action_type,
4640 format_policer_action_type, mp->exceed_action_type,
4642 format_policer_action_type, mp->violate_action_type,
4645 vec_free (conform_dscp_str);
4646 vec_free (exceed_dscp_str);
4647 vec_free (violate_dscp_str);
4650 static void vl_api_policer_details_t_handler_json
4651 (vl_api_policer_details_t * mp)
4653 vat_main_t *vam = &vat_main;
4654 vat_json_node_t *node;
4655 u8 *rate_type_str, *round_type_str, *type_str;
4656 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4658 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4660 format (0, "%U", format_policer_round_type, mp->round_type);
4661 type_str = format (0, "%U", format_policer_type, mp->type);
4662 conform_action_str = format (0, "%U", format_policer_action_type,
4663 mp->conform_action_type);
4664 exceed_action_str = format (0, "%U", format_policer_action_type,
4665 mp->exceed_action_type);
4666 violate_action_str = format (0, "%U", format_policer_action_type,
4667 mp->violate_action_type);
4669 if (VAT_JSON_ARRAY != vam->json_tree.type)
4671 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4672 vat_json_init_array (&vam->json_tree);
4674 node = vat_json_array_add (&vam->json_tree);
4676 vat_json_init_object (node);
4677 vat_json_object_add_string_copy (node, "name", mp->name);
4678 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4679 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4680 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4681 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4682 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4683 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4684 vat_json_object_add_string_copy (node, "type", type_str);
4685 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4686 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4687 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4688 vat_json_object_add_uint (node, "cir_tokens_per_period",
4689 ntohl (mp->cir_tokens_per_period));
4690 vat_json_object_add_uint (node, "eir_tokens_per_period",
4691 ntohl (mp->pir_tokens_per_period));
4692 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4693 vat_json_object_add_uint (node, "current_bucket",
4694 ntohl (mp->current_bucket));
4695 vat_json_object_add_uint (node, "extended_limit",
4696 ntohl (mp->extended_limit));
4697 vat_json_object_add_uint (node, "extended_bucket",
4698 ntohl (mp->extended_bucket));
4699 vat_json_object_add_uint (node, "last_update_time",
4700 ntohl (mp->last_update_time));
4701 vat_json_object_add_string_copy (node, "conform_action",
4702 conform_action_str);
4703 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4705 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4706 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4707 vec_free (dscp_str);
4709 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4710 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4712 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4713 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4714 vec_free (dscp_str);
4716 vat_json_object_add_string_copy (node, "violate_action",
4717 violate_action_str);
4718 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4720 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4721 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4722 vec_free (dscp_str);
4725 vec_free (rate_type_str);
4726 vec_free (round_type_str);
4727 vec_free (type_str);
4728 vec_free (conform_action_str);
4729 vec_free (exceed_action_str);
4730 vec_free (violate_action_str);
4734 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4737 vat_main_t *vam = &vat_main;
4738 int i, count = ntohl (mp->count);
4741 print (vam->ofp, "classify table ids (%d) : ", count);
4742 for (i = 0; i < count; i++)
4744 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4745 print (vam->ofp, (i < count - 1) ? "," : "");
4747 vam->retval = ntohl (mp->retval);
4748 vam->result_ready = 1;
4752 vl_api_classify_table_ids_reply_t_handler_json
4753 (vl_api_classify_table_ids_reply_t * mp)
4755 vat_main_t *vam = &vat_main;
4756 int i, count = ntohl (mp->count);
4760 vat_json_node_t node;
4762 vat_json_init_object (&node);
4763 for (i = 0; i < count; i++)
4765 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4767 vat_json_print (vam->ofp, &node);
4768 vat_json_free (&node);
4770 vam->retval = ntohl (mp->retval);
4771 vam->result_ready = 1;
4775 vl_api_classify_table_by_interface_reply_t_handler
4776 (vl_api_classify_table_by_interface_reply_t * mp)
4778 vat_main_t *vam = &vat_main;
4781 table_id = ntohl (mp->l2_table_id);
4783 print (vam->ofp, "l2 table id : %d", table_id);
4785 print (vam->ofp, "l2 table id : No input ACL tables configured");
4786 table_id = ntohl (mp->ip4_table_id);
4788 print (vam->ofp, "ip4 table id : %d", table_id);
4790 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4791 table_id = ntohl (mp->ip6_table_id);
4793 print (vam->ofp, "ip6 table id : %d", table_id);
4795 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4796 vam->retval = ntohl (mp->retval);
4797 vam->result_ready = 1;
4801 vl_api_classify_table_by_interface_reply_t_handler_json
4802 (vl_api_classify_table_by_interface_reply_t * mp)
4804 vat_main_t *vam = &vat_main;
4805 vat_json_node_t node;
4807 vat_json_init_object (&node);
4809 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4810 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4811 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4813 vat_json_print (vam->ofp, &node);
4814 vat_json_free (&node);
4816 vam->retval = ntohl (mp->retval);
4817 vam->result_ready = 1;
4820 static void vl_api_policer_add_del_reply_t_handler
4821 (vl_api_policer_add_del_reply_t * mp)
4823 vat_main_t *vam = &vat_main;
4824 i32 retval = ntohl (mp->retval);
4825 if (vam->async_mode)
4827 vam->async_errors += (retval < 0);
4831 vam->retval = retval;
4832 vam->result_ready = 1;
4833 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4835 * Note: this is just barely thread-safe, depends on
4836 * the main thread spinning waiting for an answer...
4838 errmsg ("policer index %d", ntohl (mp->policer_index));
4842 static void vl_api_policer_add_del_reply_t_handler_json
4843 (vl_api_policer_add_del_reply_t * mp)
4845 vat_main_t *vam = &vat_main;
4846 vat_json_node_t node;
4848 vat_json_init_object (&node);
4849 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4850 vat_json_object_add_uint (&node, "policer_index",
4851 ntohl (mp->policer_index));
4853 vat_json_print (vam->ofp, &node);
4854 vat_json_free (&node);
4856 vam->retval = ntohl (mp->retval);
4857 vam->result_ready = 1;
4860 /* Format hex dump. */
4862 format_hex_bytes (u8 * s, va_list * va)
4864 u8 *bytes = va_arg (*va, u8 *);
4865 int n_bytes = va_arg (*va, int);
4868 /* Print short or long form depending on byte count. */
4869 uword short_form = n_bytes <= 32;
4870 u32 indent = format_get_indent (s);
4875 for (i = 0; i < n_bytes; i++)
4877 if (!short_form && (i % 32) == 0)
4878 s = format (s, "%08x: ", i);
4879 s = format (s, "%02x", bytes[i]);
4880 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4881 s = format (s, "\n%U", format_white_space, indent);
4888 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4891 vat_main_t *vam = &vat_main;
4892 i32 retval = ntohl (mp->retval);
4895 print (vam->ofp, "classify table info :");
4896 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4897 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4898 ntohl (mp->miss_next_index));
4899 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4900 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4901 ntohl (mp->match_n_vectors));
4902 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4903 ntohl (mp->mask_length));
4905 vam->retval = retval;
4906 vam->result_ready = 1;
4910 vl_api_classify_table_info_reply_t_handler_json
4911 (vl_api_classify_table_info_reply_t * mp)
4913 vat_main_t *vam = &vat_main;
4914 vat_json_node_t node;
4916 i32 retval = ntohl (mp->retval);
4919 vat_json_init_object (&node);
4921 vat_json_object_add_int (&node, "sessions",
4922 ntohl (mp->active_sessions));
4923 vat_json_object_add_int (&node, "nexttbl",
4924 ntohl (mp->next_table_index));
4925 vat_json_object_add_int (&node, "nextnode",
4926 ntohl (mp->miss_next_index));
4927 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4928 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4929 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4930 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4931 ntohl (mp->mask_length), 0);
4932 vat_json_object_add_string_copy (&node, "mask", s);
4934 vat_json_print (vam->ofp, &node);
4935 vat_json_free (&node);
4937 vam->retval = ntohl (mp->retval);
4938 vam->result_ready = 1;
4942 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4945 vat_main_t *vam = &vat_main;
4947 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4948 ntohl (mp->hit_next_index), ntohl (mp->advance),
4949 ntohl (mp->opaque_index));
4950 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4951 ntohl (mp->match_length));
4955 vl_api_classify_session_details_t_handler_json
4956 (vl_api_classify_session_details_t * mp)
4958 vat_main_t *vam = &vat_main;
4959 vat_json_node_t *node = NULL;
4961 if (VAT_JSON_ARRAY != vam->json_tree.type)
4963 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4964 vat_json_init_array (&vam->json_tree);
4966 node = vat_json_array_add (&vam->json_tree);
4968 vat_json_init_object (node);
4969 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
4970 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
4971 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
4973 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
4975 vat_json_object_add_string_copy (node, "match", s);
4978 static void vl_api_pg_create_interface_reply_t_handler
4979 (vl_api_pg_create_interface_reply_t * mp)
4981 vat_main_t *vam = &vat_main;
4983 vam->retval = ntohl (mp->retval);
4984 vam->result_ready = 1;
4987 static void vl_api_pg_create_interface_reply_t_handler_json
4988 (vl_api_pg_create_interface_reply_t * mp)
4990 vat_main_t *vam = &vat_main;
4991 vat_json_node_t node;
4993 i32 retval = ntohl (mp->retval);
4996 vat_json_init_object (&node);
4998 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
5000 vat_json_print (vam->ofp, &node);
5001 vat_json_free (&node);
5003 vam->retval = ntohl (mp->retval);
5004 vam->result_ready = 1;
5007 static void vl_api_policer_classify_details_t_handler
5008 (vl_api_policer_classify_details_t * mp)
5010 vat_main_t *vam = &vat_main;
5012 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5013 ntohl (mp->table_index));
5016 static void vl_api_policer_classify_details_t_handler_json
5017 (vl_api_policer_classify_details_t * mp)
5019 vat_main_t *vam = &vat_main;
5020 vat_json_node_t *node;
5022 if (VAT_JSON_ARRAY != vam->json_tree.type)
5024 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5025 vat_json_init_array (&vam->json_tree);
5027 node = vat_json_array_add (&vam->json_tree);
5029 vat_json_init_object (node);
5030 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5031 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5034 static void vl_api_flow_classify_details_t_handler
5035 (vl_api_flow_classify_details_t * mp)
5037 vat_main_t *vam = &vat_main;
5039 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5040 ntohl (mp->table_index));
5043 static void vl_api_flow_classify_details_t_handler_json
5044 (vl_api_flow_classify_details_t * mp)
5046 vat_main_t *vam = &vat_main;
5047 vat_json_node_t *node;
5049 if (VAT_JSON_ARRAY != vam->json_tree.type)
5051 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5052 vat_json_init_array (&vam->json_tree);
5054 node = vat_json_array_add (&vam->json_tree);
5056 vat_json_init_object (node);
5057 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5058 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5061 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5062 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5063 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5064 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5065 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5066 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5067 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5068 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5069 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5070 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5073 * Generate boilerplate reply handlers, which
5074 * dig the return value out of the xxx_reply_t API message,
5075 * stick it into vam->retval, and set vam->result_ready
5077 * Could also do this by pointing N message decode slots at
5078 * a single function, but that could break in subtle ways.
5081 #define foreach_standard_reply_retval_handler \
5082 _(sw_interface_set_flags_reply) \
5083 _(sw_interface_add_del_address_reply) \
5084 _(sw_interface_set_rx_mode_reply) \
5085 _(sw_interface_set_rx_placement_reply) \
5086 _(sw_interface_set_table_reply) \
5087 _(sw_interface_set_mpls_enable_reply) \
5088 _(sw_interface_set_vpath_reply) \
5089 _(sw_interface_set_vxlan_bypass_reply) \
5090 _(sw_interface_set_geneve_bypass_reply) \
5091 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5092 _(sw_interface_set_l2_bridge_reply) \
5093 _(sw_interface_set_bond_weight_reply) \
5094 _(bridge_domain_add_del_reply) \
5095 _(sw_interface_set_l2_xconnect_reply) \
5096 _(l2fib_add_del_reply) \
5097 _(l2fib_flush_int_reply) \
5098 _(l2fib_flush_bd_reply) \
5099 _(ip_route_add_del_reply) \
5100 _(ip_table_add_del_reply) \
5101 _(ip_mroute_add_del_reply) \
5102 _(mpls_route_add_del_reply) \
5103 _(mpls_table_add_del_reply) \
5104 _(mpls_ip_bind_unbind_reply) \
5105 _(bier_route_add_del_reply) \
5106 _(bier_table_add_del_reply) \
5107 _(proxy_arp_add_del_reply) \
5108 _(proxy_arp_intfc_enable_disable_reply) \
5109 _(sw_interface_set_unnumbered_reply) \
5110 _(ip_neighbor_add_del_reply) \
5111 _(reset_fib_reply) \
5112 _(dhcp_proxy_config_reply) \
5113 _(dhcp_proxy_set_vss_reply) \
5114 _(dhcp_client_config_reply) \
5115 _(set_ip_flow_hash_reply) \
5116 _(sw_interface_ip6_enable_disable_reply) \
5117 _(ip6nd_proxy_add_del_reply) \
5118 _(sw_interface_ip6nd_ra_prefix_reply) \
5119 _(sw_interface_ip6nd_ra_config_reply) \
5120 _(set_arp_neighbor_limit_reply) \
5121 _(l2_patch_add_del_reply) \
5122 _(sr_mpls_policy_add_reply) \
5123 _(sr_mpls_policy_mod_reply) \
5124 _(sr_mpls_policy_del_reply) \
5125 _(sr_policy_add_reply) \
5126 _(sr_policy_mod_reply) \
5127 _(sr_policy_del_reply) \
5128 _(sr_localsid_add_del_reply) \
5129 _(sr_steering_add_del_reply) \
5130 _(classify_add_del_session_reply) \
5131 _(classify_set_interface_ip_table_reply) \
5132 _(classify_set_interface_l2_tables_reply) \
5133 _(l2tpv3_set_tunnel_cookies_reply) \
5134 _(l2tpv3_interface_enable_disable_reply) \
5135 _(l2tpv3_set_lookup_key_reply) \
5136 _(l2_fib_clear_table_reply) \
5137 _(l2_interface_efp_filter_reply) \
5138 _(l2_interface_vlan_tag_rewrite_reply) \
5139 _(modify_vhost_user_if_reply) \
5140 _(delete_vhost_user_if_reply) \
5141 _(ip_probe_neighbor_reply) \
5142 _(ip_scan_neighbor_enable_disable_reply) \
5143 _(want_ip4_arp_events_reply) \
5144 _(want_ip6_nd_events_reply) \
5145 _(want_l2_macs_events_reply) \
5146 _(input_acl_set_interface_reply) \
5147 _(ipsec_spd_add_del_reply) \
5148 _(ipsec_interface_add_del_spd_reply) \
5149 _(ipsec_spd_entry_add_del_reply) \
5150 _(ipsec_sad_entry_add_del_reply) \
5151 _(ipsec_tunnel_if_add_del_reply) \
5152 _(ipsec_tunnel_if_set_sa_reply) \
5153 _(delete_loopback_reply) \
5154 _(bd_ip_mac_add_del_reply) \
5155 _(bd_ip_mac_flush_reply) \
5156 _(want_interface_events_reply) \
5157 _(cop_interface_enable_disable_reply) \
5158 _(cop_whitelist_enable_disable_reply) \
5159 _(sw_interface_clear_stats_reply) \
5160 _(ioam_enable_reply) \
5161 _(ioam_disable_reply) \
5162 _(one_add_del_locator_reply) \
5163 _(one_add_del_local_eid_reply) \
5164 _(one_add_del_remote_mapping_reply) \
5165 _(one_add_del_adjacency_reply) \
5166 _(one_add_del_map_resolver_reply) \
5167 _(one_add_del_map_server_reply) \
5168 _(one_enable_disable_reply) \
5169 _(one_rloc_probe_enable_disable_reply) \
5170 _(one_map_register_enable_disable_reply) \
5171 _(one_map_register_set_ttl_reply) \
5172 _(one_set_transport_protocol_reply) \
5173 _(one_map_register_fallback_threshold_reply) \
5174 _(one_pitr_set_locator_set_reply) \
5175 _(one_map_request_mode_reply) \
5176 _(one_add_del_map_request_itr_rlocs_reply) \
5177 _(one_eid_table_add_del_map_reply) \
5178 _(one_use_petr_reply) \
5179 _(one_stats_enable_disable_reply) \
5180 _(one_add_del_l2_arp_entry_reply) \
5181 _(one_add_del_ndp_entry_reply) \
5182 _(one_stats_flush_reply) \
5183 _(one_enable_disable_xtr_mode_reply) \
5184 _(one_enable_disable_pitr_mode_reply) \
5185 _(one_enable_disable_petr_mode_reply) \
5186 _(gpe_enable_disable_reply) \
5187 _(gpe_set_encap_mode_reply) \
5188 _(gpe_add_del_iface_reply) \
5189 _(gpe_add_del_native_fwd_rpath_reply) \
5190 _(af_packet_delete_reply) \
5191 _(policer_classify_set_interface_reply) \
5192 _(netmap_create_reply) \
5193 _(netmap_delete_reply) \
5194 _(set_ipfix_exporter_reply) \
5195 _(set_ipfix_classify_stream_reply) \
5196 _(ipfix_classify_table_add_del_reply) \
5197 _(flow_classify_set_interface_reply) \
5198 _(sw_interface_span_enable_disable_reply) \
5199 _(pg_capture_reply) \
5200 _(pg_enable_disable_reply) \
5201 _(ip_source_and_port_range_check_add_del_reply) \
5202 _(ip_source_and_port_range_check_interface_add_del_reply)\
5203 _(delete_subif_reply) \
5204 _(l2_interface_pbb_tag_rewrite_reply) \
5206 _(feature_enable_disable_reply) \
5207 _(sw_interface_tag_add_del_reply) \
5208 _(hw_interface_set_mtu_reply) \
5209 _(p2p_ethernet_add_reply) \
5210 _(p2p_ethernet_del_reply) \
5211 _(lldp_config_reply) \
5212 _(sw_interface_set_lldp_reply) \
5213 _(tcp_configure_src_addresses_reply) \
5214 _(session_rule_add_del_reply) \
5215 _(ip_container_proxy_add_del_reply) \
5216 _(output_acl_set_interface_reply) \
5217 _(qos_record_enable_disable_reply)
5220 static void vl_api_##n##_t_handler \
5221 (vl_api_##n##_t * mp) \
5223 vat_main_t * vam = &vat_main; \
5224 i32 retval = ntohl(mp->retval); \
5225 if (vam->async_mode) { \
5226 vam->async_errors += (retval < 0); \
5228 vam->retval = retval; \
5229 vam->result_ready = 1; \
5232 foreach_standard_reply_retval_handler;
5236 static void vl_api_##n##_t_handler_json \
5237 (vl_api_##n##_t * mp) \
5239 vat_main_t * vam = &vat_main; \
5240 vat_json_node_t node; \
5241 vat_json_init_object(&node); \
5242 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5243 vat_json_print(vam->ofp, &node); \
5244 vam->retval = ntohl(mp->retval); \
5245 vam->result_ready = 1; \
5247 foreach_standard_reply_retval_handler;
5251 * Table of message reply handlers, must include boilerplate handlers
5255 #define foreach_vpe_api_reply_msg \
5256 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5257 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5258 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5259 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5260 _(CONTROL_PING_REPLY, control_ping_reply) \
5261 _(CLI_REPLY, cli_reply) \
5262 _(CLI_INBAND_REPLY, cli_inband_reply) \
5263 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5264 sw_interface_add_del_address_reply) \
5265 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5266 _(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
5267 _(SW_INTERFACE_RX_PLACEMENT_DETAILS, sw_interface_rx_placement_details) \
5268 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5269 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5270 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5271 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5272 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5273 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5274 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5275 sw_interface_set_l2_xconnect_reply) \
5276 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5277 sw_interface_set_l2_bridge_reply) \
5278 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5279 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5280 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5281 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5282 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5283 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5284 _(L2_FLAGS_REPLY, l2_flags_reply) \
5285 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5286 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5287 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5288 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5289 _(VIRTIO_PCI_CREATE_REPLY, virtio_pci_create_reply) \
5290 _(VIRTIO_PCI_DELETE_REPLY, virtio_pci_delete_reply) \
5291 _(SW_INTERFACE_VIRTIO_PCI_DETAILS, sw_interface_virtio_pci_details) \
5292 _(BOND_CREATE_REPLY, bond_create_reply) \
5293 _(BOND_DELETE_REPLY, bond_delete_reply) \
5294 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5295 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5296 _(SW_INTERFACE_SET_BOND_WEIGHT_REPLY, sw_interface_set_bond_weight_reply) \
5297 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5298 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5299 _(IP_ROUTE_ADD_DEL_REPLY, ip_route_add_del_reply) \
5300 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5301 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5302 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5303 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5304 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5305 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5306 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5307 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5308 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5309 proxy_arp_intfc_enable_disable_reply) \
5310 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5311 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5312 sw_interface_set_unnumbered_reply) \
5313 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5314 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5315 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5316 _(RESET_FIB_REPLY, reset_fib_reply) \
5317 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5318 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5319 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5320 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5321 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5322 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5323 sw_interface_ip6_enable_disable_reply) \
5324 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5325 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5326 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5327 sw_interface_ip6nd_ra_prefix_reply) \
5328 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5329 sw_interface_ip6nd_ra_config_reply) \
5330 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5331 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5332 _(SR_MPLS_POLICY_ADD_REPLY, sr_mpls_policy_add_reply) \
5333 _(SR_MPLS_POLICY_MOD_REPLY, sr_mpls_policy_mod_reply) \
5334 _(SR_MPLS_POLICY_DEL_REPLY, sr_mpls_policy_del_reply) \
5335 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5336 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5337 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5338 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5339 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5340 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5341 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5342 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5343 classify_set_interface_ip_table_reply) \
5344 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5345 classify_set_interface_l2_tables_reply) \
5346 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5347 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5348 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5349 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5350 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5351 l2tpv3_interface_enable_disable_reply) \
5352 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5353 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5354 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5355 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5356 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5357 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5358 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5359 _(GRE_TUNNEL_ADD_DEL_REPLY, gre_tunnel_add_del_reply) \
5360 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5361 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5362 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5363 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5364 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5365 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5366 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5367 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5368 _(SHOW_VERSION_REPLY, show_version_reply) \
5369 _(SHOW_THREADS_REPLY, show_threads_reply) \
5370 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5371 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5372 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5373 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5374 _(IP_PROBE_NEIGHBOR_REPLY, ip_probe_neighbor_reply) \
5375 _(IP_SCAN_NEIGHBOR_ENABLE_DISABLE_REPLY, ip_scan_neighbor_enable_disable_reply) \
5376 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5377 _(IP4_ARP_EVENT, ip4_arp_event) \
5378 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5379 _(IP6_ND_EVENT, ip6_nd_event) \
5380 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5381 _(L2_MACS_EVENT, l2_macs_event) \
5382 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5383 _(IP_ADDRESS_DETAILS, ip_address_details) \
5384 _(IP_DETAILS, ip_details) \
5385 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5386 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5387 _(IPSEC_SPD_ENTRY_ADD_DEL_REPLY, ipsec_spd_entry_add_del_reply) \
5388 _(IPSEC_SAD_ENTRY_ADD_DEL_REPLY, ipsec_sad_entry_add_del_reply) \
5389 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5390 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5391 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5392 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5393 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5394 _(BD_IP_MAC_FLUSH_REPLY, bd_ip_mac_flush_reply) \
5395 _(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
5396 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5397 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5398 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5399 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5400 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5401 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5402 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5403 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5404 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5405 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5406 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5407 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5408 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5409 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5410 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5411 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5412 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5413 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5414 one_map_register_enable_disable_reply) \
5415 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5416 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5417 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5418 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5419 one_map_register_fallback_threshold_reply) \
5420 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5421 one_rloc_probe_enable_disable_reply) \
5422 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5423 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5424 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5425 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5426 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5427 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5428 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5429 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5430 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5431 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5432 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5433 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5434 _(ONE_STATS_DETAILS, one_stats_details) \
5435 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5436 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5437 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5438 show_one_stats_enable_disable_reply) \
5439 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5440 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5441 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5442 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5443 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5444 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5445 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5446 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5447 one_enable_disable_pitr_mode_reply) \
5448 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5449 one_enable_disable_petr_mode_reply) \
5450 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5451 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5452 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5453 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5454 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5455 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5456 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5457 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5458 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5459 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5460 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5461 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5462 gpe_add_del_native_fwd_rpath_reply) \
5463 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5464 gpe_fwd_entry_path_details) \
5465 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5466 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5467 one_add_del_map_request_itr_rlocs_reply) \
5468 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5469 one_get_map_request_itr_rlocs_reply) \
5470 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5471 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5472 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5473 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5474 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5475 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5476 show_one_map_register_state_reply) \
5477 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5478 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5479 show_one_map_register_fallback_threshold_reply) \
5480 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5481 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5482 _(AF_PACKET_DETAILS, af_packet_details) \
5483 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5484 _(POLICER_DETAILS, policer_details) \
5485 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5486 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5487 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5488 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5489 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5490 _(MPLS_TABLE_DETAILS, mpls_table_details) \
5491 _(MPLS_ROUTE_DETAILS, mpls_route_details) \
5492 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5493 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5494 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5495 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5496 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5497 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5498 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5499 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5500 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5501 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5502 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5503 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5504 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5505 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5506 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5507 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5508 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5509 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5510 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5511 ip_source_and_port_range_check_add_del_reply) \
5512 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5513 ip_source_and_port_range_check_interface_add_del_reply) \
5514 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5515 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5516 _(SET_PUNT_REPLY, set_punt_reply) \
5517 _(IP_TABLE_DETAILS, ip_table_details) \
5518 _(IP_ROUTE_DETAILS, ip_route_details) \
5519 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5520 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5521 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5522 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5523 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5524 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5525 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5526 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5527 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5528 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5529 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5530 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5531 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5532 _(SESSION_RULES_DETAILS, session_rules_details) \
5533 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5534 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5535 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply)
5537 #define foreach_standalone_reply_msg \
5538 _(SW_INTERFACE_EVENT, sw_interface_event)
5546 #define STR_VTR_OP_CASE(op) \
5547 case L2_VTR_ ## op: \
5551 str_vtr_op (u32 vtr_op)
5555 STR_VTR_OP_CASE (DISABLED);
5556 STR_VTR_OP_CASE (PUSH_1);
5557 STR_VTR_OP_CASE (PUSH_2);
5558 STR_VTR_OP_CASE (POP_1);
5559 STR_VTR_OP_CASE (POP_2);
5560 STR_VTR_OP_CASE (TRANSLATE_1_1);
5561 STR_VTR_OP_CASE (TRANSLATE_1_2);
5562 STR_VTR_OP_CASE (TRANSLATE_2_1);
5563 STR_VTR_OP_CASE (TRANSLATE_2_2);
5570 dump_sub_interface_table (vat_main_t * vam)
5572 const sw_interface_subif_t *sub = NULL;
5574 if (vam->json_output)
5577 ("JSON output supported only for VPE API calls and dump_stats_table");
5582 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5583 "Interface", "sw_if_index",
5584 "sub id", "dot1ad", "tags", "outer id",
5585 "inner id", "exact", "default", "outer any", "inner any");
5587 vec_foreach (sub, vam->sw_if_subif_table)
5590 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5591 sub->interface_name,
5593 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5594 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5595 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5596 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5597 if (sub->vtr_op != L2_VTR_DISABLED)
5600 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5601 "tag1: %d tag2: %d ]",
5602 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5603 sub->vtr_tag1, sub->vtr_tag2);
5611 name_sort_cmp (void *a1, void *a2)
5613 name_sort_t *n1 = a1;
5614 name_sort_t *n2 = a2;
5616 return strcmp ((char *) n1->name, (char *) n2->name);
5620 dump_interface_table (vat_main_t * vam)
5623 name_sort_t *nses = 0, *ns;
5625 if (vam->json_output)
5628 ("JSON output supported only for VPE API calls and dump_stats_table");
5633 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5635 vec_add2 (nses, ns, 1);
5636 ns->name = (u8 *)(p->key);
5637 ns->value = (u32) p->value[0];
5641 vec_sort_with_function (nses, name_sort_cmp);
5643 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5644 vec_foreach (ns, nses)
5646 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5653 dump_ip_table (vat_main_t * vam, int is_ipv6)
5655 const ip_details_t *det = NULL;
5656 const ip_address_details_t *address = NULL;
5659 print (vam->ofp, "%-12s", "sw_if_index");
5661 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5668 print (vam->ofp, "%-12d", i);
5669 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5674 vec_foreach (address, det->addr)
5678 is_ipv6 ? format_ip6_address : format_ip4_address,
5679 address->ip, address->prefix_length);
5687 dump_ipv4_table (vat_main_t * vam)
5689 if (vam->json_output)
5692 ("JSON output supported only for VPE API calls and dump_stats_table");
5696 return dump_ip_table (vam, 0);
5700 dump_ipv6_table (vat_main_t * vam)
5702 if (vam->json_output)
5705 ("JSON output supported only for VPE API calls and dump_stats_table");
5709 return dump_ip_table (vam, 1);
5713 * Pass CLI buffers directly in the CLI_INBAND API message,
5714 * instead of an additional shared memory area.
5717 exec_inband (vat_main_t * vam)
5719 vl_api_cli_inband_t *mp;
5720 unformat_input_t *i = vam->input;
5723 if (vec_len (i->buffer) == 0)
5726 if (vam->exec_mode == 0 && unformat (i, "mode"))
5731 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5738 * In order for the CLI command to work, it
5739 * must be a vector ending in \n, not a C-string ending
5742 u32 len = vec_len (vam->input->buffer);
5743 M2 (CLI_INBAND, mp, len);
5744 vl_api_to_api_string (len - 1, (const char *) vam->input->buffer, &mp->cmd);
5748 /* json responses may or may not include a useful reply... */
5749 if (vec_len (vam->cmd_reply))
5750 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
5755 exec (vat_main_t * vam)
5757 return exec_inband (vam);
5761 api_create_loopback (vat_main_t * vam)
5763 unformat_input_t *i = vam->input;
5764 vl_api_create_loopback_t *mp;
5765 vl_api_create_loopback_instance_t *mp_lbi;
5768 u8 is_specified = 0;
5769 u32 user_instance = 0;
5772 clib_memset (mac_address, 0, sizeof (mac_address));
5774 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5776 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5778 if (unformat (i, "instance %d", &user_instance))
5786 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5787 mp_lbi->is_specified = is_specified;
5789 mp_lbi->user_instance = htonl (user_instance);
5791 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5796 /* Construct the API message */
5797 M (CREATE_LOOPBACK, mp);
5799 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5808 api_delete_loopback (vat_main_t * vam)
5810 unformat_input_t *i = vam->input;
5811 vl_api_delete_loopback_t *mp;
5812 u32 sw_if_index = ~0;
5815 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5817 if (unformat (i, "sw_if_index %d", &sw_if_index))
5823 if (sw_if_index == ~0)
5825 errmsg ("missing sw_if_index");
5829 /* Construct the API message */
5830 M (DELETE_LOOPBACK, mp);
5831 mp->sw_if_index = ntohl (sw_if_index);
5839 api_want_interface_events (vat_main_t * vam)
5841 unformat_input_t *i = vam->input;
5842 vl_api_want_interface_events_t *mp;
5846 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5848 if (unformat (i, "enable"))
5850 else if (unformat (i, "disable"))
5858 errmsg ("missing enable|disable");
5862 M (WANT_INTERFACE_EVENTS, mp);
5863 mp->enable_disable = enable;
5865 vam->interface_event_display = enable;
5873 /* Note: non-static, called once to set up the initial intfc table */
5875 api_sw_interface_dump (vat_main_t * vam)
5877 vl_api_sw_interface_dump_t *mp;
5878 vl_api_control_ping_t *mp_ping;
5880 name_sort_t *nses = 0, *ns;
5881 sw_interface_subif_t *sub = NULL;
5884 /* Toss the old name table */
5886 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5888 vec_add2 (nses, ns, 1);
5889 ns->name = (u8 *)(p->key);
5890 ns->value = (u32) p->value[0];
5894 hash_free (vam->sw_if_index_by_interface_name);
5896 vec_foreach (ns, nses) vec_free (ns->name);
5900 vec_foreach (sub, vam->sw_if_subif_table)
5902 vec_free (sub->interface_name);
5904 vec_free (vam->sw_if_subif_table);
5906 /* recreate the interface name hash table */
5907 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5910 * Ask for all interface names. Otherwise, the epic catalog of
5911 * name filters becomes ridiculously long, and vat ends up needing
5912 * to be taught about new interface types.
5914 M (SW_INTERFACE_DUMP, mp);
5917 /* Use a control ping for synchronization */
5918 MPING (CONTROL_PING, mp_ping);
5926 api_sw_interface_set_flags (vat_main_t * vam)
5928 unformat_input_t *i = vam->input;
5929 vl_api_sw_interface_set_flags_t *mp;
5931 u8 sw_if_index_set = 0;
5935 /* Parse args required to build the message */
5936 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5938 if (unformat (i, "admin-up"))
5940 else if (unformat (i, "admin-down"))
5943 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5944 sw_if_index_set = 1;
5945 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5946 sw_if_index_set = 1;
5951 if (sw_if_index_set == 0)
5953 errmsg ("missing interface name or sw_if_index");
5957 /* Construct the API message */
5958 M (SW_INTERFACE_SET_FLAGS, mp);
5959 mp->sw_if_index = ntohl (sw_if_index);
5960 mp->flags = ntohl ((admin_up) ? IF_STATUS_API_FLAG_ADMIN_UP : 0);
5965 /* Wait for a reply, return the good/bad news... */
5971 api_sw_interface_set_rx_mode (vat_main_t * vam)
5973 unformat_input_t *i = vam->input;
5974 vl_api_sw_interface_set_rx_mode_t *mp;
5976 u8 sw_if_index_set = 0;
5978 u8 queue_id_valid = 0;
5980 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
5982 /* Parse args required to build the message */
5983 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5985 if (unformat (i, "queue %d", &queue_id))
5987 else if (unformat (i, "polling"))
5988 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
5989 else if (unformat (i, "interrupt"))
5990 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
5991 else if (unformat (i, "adaptive"))
5992 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
5994 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5995 sw_if_index_set = 1;
5996 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5997 sw_if_index_set = 1;
6002 if (sw_if_index_set == 0)
6004 errmsg ("missing interface name or sw_if_index");
6007 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6009 errmsg ("missing rx-mode");
6013 /* Construct the API message */
6014 M (SW_INTERFACE_SET_RX_MODE, mp);
6015 mp->sw_if_index = ntohl (sw_if_index);
6016 mp->mode = (vl_api_rx_mode_t) mode;
6017 mp->queue_id_valid = queue_id_valid;
6018 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6023 /* Wait for a reply, return the good/bad news... */
6029 api_sw_interface_set_rx_placement (vat_main_t * vam)
6031 unformat_input_t *i = vam->input;
6032 vl_api_sw_interface_set_rx_placement_t *mp;
6034 u8 sw_if_index_set = 0;
6037 u32 queue_id, thread_index;
6039 /* Parse args required to build the message */
6040 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6042 if (unformat (i, "queue %d", &queue_id))
6044 else if (unformat (i, "main"))
6046 else if (unformat (i, "worker %d", &thread_index))
6049 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6050 sw_if_index_set = 1;
6051 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6052 sw_if_index_set = 1;
6057 if (sw_if_index_set == 0)
6059 errmsg ("missing interface name or sw_if_index");
6065 /* Construct the API message */
6066 M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
6067 mp->sw_if_index = ntohl (sw_if_index);
6068 mp->worker_id = ntohl (thread_index);
6069 mp->queue_id = ntohl (queue_id);
6070 mp->is_main = is_main;
6074 /* Wait for a reply, return the good/bad news... */
6079 static void vl_api_sw_interface_rx_placement_details_t_handler
6080 (vl_api_sw_interface_rx_placement_details_t * mp)
6082 vat_main_t *vam = &vat_main;
6083 u32 worker_id = ntohl (mp->worker_id);
6086 "\n%-11d %-11s %-6d %-5d %-9s",
6087 ntohl (mp->sw_if_index), (worker_id == 0) ? "main" : "worker",
6088 worker_id, ntohl (mp->queue_id),
6090 1) ? "polling" : ((mp->mode == 2) ? "interrupt" : "adaptive"));
6093 static void vl_api_sw_interface_rx_placement_details_t_handler_json
6094 (vl_api_sw_interface_rx_placement_details_t * mp)
6096 vat_main_t *vam = &vat_main;
6097 vat_json_node_t *node = NULL;
6099 if (VAT_JSON_ARRAY != vam->json_tree.type)
6101 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
6102 vat_json_init_array (&vam->json_tree);
6104 node = vat_json_array_add (&vam->json_tree);
6106 vat_json_init_object (node);
6107 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
6108 vat_json_object_add_uint (node, "worker_id", ntohl (mp->worker_id));
6109 vat_json_object_add_uint (node, "queue_id", ntohl (mp->queue_id));
6110 vat_json_object_add_uint (node, "mode", mp->mode);
6114 api_sw_interface_rx_placement_dump (vat_main_t * vam)
6116 unformat_input_t *i = vam->input;
6117 vl_api_sw_interface_rx_placement_dump_t *mp;
6118 vl_api_control_ping_t *mp_ping;
6121 u8 sw_if_index_set = 0;
6123 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6125 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6127 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6134 "\n%-11s %-11s %-6s %-5s %-4s",
6135 "sw_if_index", "main/worker", "thread", "queue", "mode");
6137 /* Dump Interface rx placement */
6138 M (SW_INTERFACE_RX_PLACEMENT_DUMP, mp);
6140 if (sw_if_index_set)
6141 mp->sw_if_index = htonl (sw_if_index);
6143 mp->sw_if_index = ~0;
6147 /* Use a control ping for synchronization */
6148 MPING (CONTROL_PING, mp_ping);
6156 api_sw_interface_clear_stats (vat_main_t * vam)
6158 unformat_input_t *i = vam->input;
6159 vl_api_sw_interface_clear_stats_t *mp;
6161 u8 sw_if_index_set = 0;
6164 /* Parse args required to build the message */
6165 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6167 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6168 sw_if_index_set = 1;
6169 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6170 sw_if_index_set = 1;
6175 /* Construct the API message */
6176 M (SW_INTERFACE_CLEAR_STATS, mp);
6178 if (sw_if_index_set == 1)
6179 mp->sw_if_index = ntohl (sw_if_index);
6181 mp->sw_if_index = ~0;
6186 /* Wait for a reply, return the good/bad news... */
6192 api_sw_interface_add_del_address (vat_main_t * vam)
6194 unformat_input_t *i = vam->input;
6195 vl_api_sw_interface_add_del_address_t *mp;
6197 u8 sw_if_index_set = 0;
6198 u8 is_add = 1, del_all = 0;
6199 u32 address_length = 0;
6200 u8 v4_address_set = 0;
6201 u8 v6_address_set = 0;
6202 ip4_address_t v4address;
6203 ip6_address_t v6address;
6206 /* Parse args required to build the message */
6207 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6209 if (unformat (i, "del-all"))
6211 else if (unformat (i, "del"))
6214 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6215 sw_if_index_set = 1;
6216 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6217 sw_if_index_set = 1;
6218 else if (unformat (i, "%U/%d",
6219 unformat_ip4_address, &v4address, &address_length))
6221 else if (unformat (i, "%U/%d",
6222 unformat_ip6_address, &v6address, &address_length))
6228 if (sw_if_index_set == 0)
6230 errmsg ("missing interface name or sw_if_index");
6233 if (v4_address_set && v6_address_set)
6235 errmsg ("both v4 and v6 addresses set");
6238 if (!v4_address_set && !v6_address_set && !del_all)
6240 errmsg ("no addresses set");
6244 /* Construct the API message */
6245 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6247 mp->sw_if_index = ntohl (sw_if_index);
6248 mp->is_add = is_add;
6249 mp->del_all = del_all;
6252 mp->prefix.address.af = ADDRESS_IP6;
6253 clib_memcpy (mp->prefix.address.un.ip6, &v6address, sizeof (v6address));
6257 mp->prefix.address.af = ADDRESS_IP4;
6258 clib_memcpy (mp->prefix.address.un.ip4, &v4address, sizeof (v4address));
6260 mp->prefix.len = address_length;
6265 /* Wait for a reply, return good/bad news */
6271 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6273 unformat_input_t *i = vam->input;
6274 vl_api_sw_interface_set_mpls_enable_t *mp;
6276 u8 sw_if_index_set = 0;
6280 /* Parse args required to build the message */
6281 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6283 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6284 sw_if_index_set = 1;
6285 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6286 sw_if_index_set = 1;
6287 else if (unformat (i, "disable"))
6289 else if (unformat (i, "dis"))
6295 if (sw_if_index_set == 0)
6297 errmsg ("missing interface name or sw_if_index");
6301 /* Construct the API message */
6302 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6304 mp->sw_if_index = ntohl (sw_if_index);
6305 mp->enable = enable;
6310 /* Wait for a reply... */
6316 api_sw_interface_set_table (vat_main_t * vam)
6318 unformat_input_t *i = vam->input;
6319 vl_api_sw_interface_set_table_t *mp;
6320 u32 sw_if_index, vrf_id = 0;
6321 u8 sw_if_index_set = 0;
6325 /* Parse args required to build the message */
6326 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6328 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6329 sw_if_index_set = 1;
6330 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6331 sw_if_index_set = 1;
6332 else if (unformat (i, "vrf %d", &vrf_id))
6334 else if (unformat (i, "ipv6"))
6340 if (sw_if_index_set == 0)
6342 errmsg ("missing interface name or sw_if_index");
6346 /* Construct the API message */
6347 M (SW_INTERFACE_SET_TABLE, mp);
6349 mp->sw_if_index = ntohl (sw_if_index);
6350 mp->is_ipv6 = is_ipv6;
6351 mp->vrf_id = ntohl (vrf_id);
6356 /* Wait for a reply... */
6361 static void vl_api_sw_interface_get_table_reply_t_handler
6362 (vl_api_sw_interface_get_table_reply_t * mp)
6364 vat_main_t *vam = &vat_main;
6366 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6368 vam->retval = ntohl (mp->retval);
6369 vam->result_ready = 1;
6373 static void vl_api_sw_interface_get_table_reply_t_handler_json
6374 (vl_api_sw_interface_get_table_reply_t * mp)
6376 vat_main_t *vam = &vat_main;
6377 vat_json_node_t node;
6379 vat_json_init_object (&node);
6380 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6381 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6383 vat_json_print (vam->ofp, &node);
6384 vat_json_free (&node);
6386 vam->retval = ntohl (mp->retval);
6387 vam->result_ready = 1;
6391 api_sw_interface_get_table (vat_main_t * vam)
6393 unformat_input_t *i = vam->input;
6394 vl_api_sw_interface_get_table_t *mp;
6396 u8 sw_if_index_set = 0;
6400 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6402 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6403 sw_if_index_set = 1;
6404 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6405 sw_if_index_set = 1;
6406 else if (unformat (i, "ipv6"))
6412 if (sw_if_index_set == 0)
6414 errmsg ("missing interface name or sw_if_index");
6418 M (SW_INTERFACE_GET_TABLE, mp);
6419 mp->sw_if_index = htonl (sw_if_index);
6420 mp->is_ipv6 = is_ipv6;
6428 api_sw_interface_set_vpath (vat_main_t * vam)
6430 unformat_input_t *i = vam->input;
6431 vl_api_sw_interface_set_vpath_t *mp;
6432 u32 sw_if_index = 0;
6433 u8 sw_if_index_set = 0;
6437 /* Parse args required to build the message */
6438 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6440 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6441 sw_if_index_set = 1;
6442 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6443 sw_if_index_set = 1;
6444 else if (unformat (i, "enable"))
6446 else if (unformat (i, "disable"))
6452 if (sw_if_index_set == 0)
6454 errmsg ("missing interface name or sw_if_index");
6458 /* Construct the API message */
6459 M (SW_INTERFACE_SET_VPATH, mp);
6461 mp->sw_if_index = ntohl (sw_if_index);
6462 mp->enable = is_enable;
6467 /* Wait for a reply... */
6473 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6475 unformat_input_t *i = vam->input;
6476 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6477 u32 sw_if_index = 0;
6478 u8 sw_if_index_set = 0;
6483 /* Parse args required to build the message */
6484 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6486 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6487 sw_if_index_set = 1;
6488 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6489 sw_if_index_set = 1;
6490 else if (unformat (i, "enable"))
6492 else if (unformat (i, "disable"))
6494 else if (unformat (i, "ip4"))
6496 else if (unformat (i, "ip6"))
6502 if (sw_if_index_set == 0)
6504 errmsg ("missing interface name or sw_if_index");
6508 /* Construct the API message */
6509 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6511 mp->sw_if_index = ntohl (sw_if_index);
6512 mp->enable = is_enable;
6513 mp->is_ipv6 = is_ipv6;
6518 /* Wait for a reply... */
6524 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6526 unformat_input_t *i = vam->input;
6527 vl_api_sw_interface_set_geneve_bypass_t *mp;
6528 u32 sw_if_index = 0;
6529 u8 sw_if_index_set = 0;
6534 /* Parse args required to build the message */
6535 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6537 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6538 sw_if_index_set = 1;
6539 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6540 sw_if_index_set = 1;
6541 else if (unformat (i, "enable"))
6543 else if (unformat (i, "disable"))
6545 else if (unformat (i, "ip4"))
6547 else if (unformat (i, "ip6"))
6553 if (sw_if_index_set == 0)
6555 errmsg ("missing interface name or sw_if_index");
6559 /* Construct the API message */
6560 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6562 mp->sw_if_index = ntohl (sw_if_index);
6563 mp->enable = is_enable;
6564 mp->is_ipv6 = is_ipv6;
6569 /* Wait for a reply... */
6575 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6577 unformat_input_t *i = vam->input;
6578 vl_api_sw_interface_set_l2_xconnect_t *mp;
6580 u8 rx_sw_if_index_set = 0;
6582 u8 tx_sw_if_index_set = 0;
6586 /* Parse args required to build the message */
6587 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6589 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6590 rx_sw_if_index_set = 1;
6591 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6592 tx_sw_if_index_set = 1;
6593 else if (unformat (i, "rx"))
6595 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6597 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6599 rx_sw_if_index_set = 1;
6604 else if (unformat (i, "tx"))
6606 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6608 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6610 tx_sw_if_index_set = 1;
6615 else if (unformat (i, "enable"))
6617 else if (unformat (i, "disable"))
6623 if (rx_sw_if_index_set == 0)
6625 errmsg ("missing rx interface name or rx_sw_if_index");
6629 if (enable && (tx_sw_if_index_set == 0))
6631 errmsg ("missing tx interface name or tx_sw_if_index");
6635 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6637 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6638 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6639 mp->enable = enable;
6647 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6649 unformat_input_t *i = vam->input;
6650 vl_api_sw_interface_set_l2_bridge_t *mp;
6651 vl_api_l2_port_type_t port_type;
6653 u8 rx_sw_if_index_set = 0;
6660 port_type = L2_API_PORT_TYPE_NORMAL;
6662 /* Parse args required to build the message */
6663 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6665 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6666 rx_sw_if_index_set = 1;
6667 else if (unformat (i, "bd_id %d", &bd_id))
6671 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6672 rx_sw_if_index_set = 1;
6673 else if (unformat (i, "shg %d", &shg))
6675 else if (unformat (i, "bvi"))
6676 port_type = L2_API_PORT_TYPE_BVI;
6677 else if (unformat (i, "uu-fwd"))
6678 port_type = L2_API_PORT_TYPE_UU_FWD;
6679 else if (unformat (i, "enable"))
6681 else if (unformat (i, "disable"))
6687 if (rx_sw_if_index_set == 0)
6689 errmsg ("missing rx interface name or sw_if_index");
6693 if (enable && (bd_id_set == 0))
6695 errmsg ("missing bridge domain");
6699 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6701 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6702 mp->bd_id = ntohl (bd_id);
6704 mp->port_type = ntohl (port_type);
6705 mp->enable = enable;
6713 api_bridge_domain_dump (vat_main_t * vam)
6715 unformat_input_t *i = vam->input;
6716 vl_api_bridge_domain_dump_t *mp;
6717 vl_api_control_ping_t *mp_ping;
6721 /* Parse args required to build the message */
6722 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6724 if (unformat (i, "bd_id %d", &bd_id))
6730 M (BRIDGE_DOMAIN_DUMP, mp);
6731 mp->bd_id = ntohl (bd_id);
6734 /* Use a control ping for synchronization */
6735 MPING (CONTROL_PING, mp_ping);
6743 api_bridge_domain_add_del (vat_main_t * vam)
6745 unformat_input_t *i = vam->input;
6746 vl_api_bridge_domain_add_del_t *mp;
6749 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6754 /* Parse args required to build the message */
6755 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6757 if (unformat (i, "bd_id %d", &bd_id))
6759 else if (unformat (i, "flood %d", &flood))
6761 else if (unformat (i, "uu-flood %d", &uu_flood))
6763 else if (unformat (i, "forward %d", &forward))
6765 else if (unformat (i, "learn %d", &learn))
6767 else if (unformat (i, "arp-term %d", &arp_term))
6769 else if (unformat (i, "mac-age %d", &mac_age))
6771 else if (unformat (i, "bd-tag %s", &bd_tag))
6773 else if (unformat (i, "del"))
6776 flood = uu_flood = forward = learn = 0;
6784 errmsg ("missing bridge domain");
6791 errmsg ("mac age must be less than 256 ");
6796 if ((bd_tag) && (vec_len (bd_tag) > 63))
6798 errmsg ("bd-tag cannot be longer than 63");
6803 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6805 mp->bd_id = ntohl (bd_id);
6807 mp->uu_flood = uu_flood;
6808 mp->forward = forward;
6810 mp->arp_term = arp_term;
6811 mp->is_add = is_add;
6812 mp->mac_age = (u8) mac_age;
6815 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
6816 mp->bd_tag[vec_len (bd_tag)] = 0;
6827 api_l2fib_flush_bd (vat_main_t * vam)
6829 unformat_input_t *i = vam->input;
6830 vl_api_l2fib_flush_bd_t *mp;
6834 /* Parse args required to build the message */
6835 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6837 if (unformat (i, "bd_id %d", &bd_id));
6844 errmsg ("missing bridge domain");
6848 M (L2FIB_FLUSH_BD, mp);
6850 mp->bd_id = htonl (bd_id);
6858 api_l2fib_flush_int (vat_main_t * vam)
6860 unformat_input_t *i = vam->input;
6861 vl_api_l2fib_flush_int_t *mp;
6862 u32 sw_if_index = ~0;
6865 /* Parse args required to build the message */
6866 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6868 if (unformat (i, "sw_if_index %d", &sw_if_index));
6870 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6875 if (sw_if_index == ~0)
6877 errmsg ("missing interface name or sw_if_index");
6881 M (L2FIB_FLUSH_INT, mp);
6883 mp->sw_if_index = ntohl (sw_if_index);
6891 api_l2fib_add_del (vat_main_t * vam)
6893 unformat_input_t *i = vam->input;
6894 vl_api_l2fib_add_del_t *mp;
6900 u32 sw_if_index = 0;
6901 u8 sw_if_index_set = 0;
6910 /* Parse args required to build the message */
6911 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6913 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
6915 else if (unformat (i, "bd_id %d", &bd_id))
6917 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6918 sw_if_index_set = 1;
6919 else if (unformat (i, "sw_if"))
6921 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6924 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6925 sw_if_index_set = 1;
6930 else if (unformat (i, "static"))
6932 else if (unformat (i, "filter"))
6937 else if (unformat (i, "bvi"))
6942 else if (unformat (i, "del"))
6944 else if (unformat (i, "count %d", &count))
6952 errmsg ("missing mac address");
6958 errmsg ("missing bridge domain");
6962 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
6964 errmsg ("missing interface name or sw_if_index");
6970 /* Turn on async mode */
6971 vam->async_mode = 1;
6972 vam->async_errors = 0;
6973 before = vat_time_now (vam);
6976 for (j = 0; j < count; j++)
6978 M (L2FIB_ADD_DEL, mp);
6980 clib_memcpy (mp->mac, mac, 6);
6981 mp->bd_id = ntohl (bd_id);
6982 mp->is_add = is_add;
6983 mp->sw_if_index = ntohl (sw_if_index);
6987 mp->static_mac = static_mac;
6988 mp->filter_mac = filter_mac;
6989 mp->bvi_mac = bvi_mac;
6991 increment_mac_address (mac);
6998 vl_api_control_ping_t *mp_ping;
7001 /* Shut off async mode */
7002 vam->async_mode = 0;
7004 MPING (CONTROL_PING, mp_ping);
7007 timeout = vat_time_now (vam) + 1.0;
7008 while (vat_time_now (vam) < timeout)
7009 if (vam->result_ready == 1)
7014 if (vam->retval == -99)
7017 if (vam->async_errors > 0)
7019 errmsg ("%d asynchronous errors", vam->async_errors);
7022 vam->async_errors = 0;
7023 after = vat_time_now (vam);
7025 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7026 count, after - before, count / (after - before));
7032 /* Wait for a reply... */
7036 /* Return the good/bad news */
7037 return (vam->retval);
7041 api_bridge_domain_set_mac_age (vat_main_t * vam)
7043 unformat_input_t *i = vam->input;
7044 vl_api_bridge_domain_set_mac_age_t *mp;
7049 /* Parse args required to build the message */
7050 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7052 if (unformat (i, "bd_id %d", &bd_id));
7053 else if (unformat (i, "mac-age %d", &mac_age));
7060 errmsg ("missing bridge domain");
7066 errmsg ("mac age must be less than 256 ");
7070 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7072 mp->bd_id = htonl (bd_id);
7073 mp->mac_age = (u8) mac_age;
7081 api_l2_flags (vat_main_t * vam)
7083 unformat_input_t *i = vam->input;
7084 vl_api_l2_flags_t *mp;
7087 u8 sw_if_index_set = 0;
7091 /* Parse args required to build the message */
7092 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7094 if (unformat (i, "sw_if_index %d", &sw_if_index))
7095 sw_if_index_set = 1;
7096 else if (unformat (i, "sw_if"))
7098 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7101 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7102 sw_if_index_set = 1;
7107 else if (unformat (i, "learn"))
7109 else if (unformat (i, "forward"))
7111 else if (unformat (i, "flood"))
7113 else if (unformat (i, "uu-flood"))
7114 flags |= L2_UU_FLOOD;
7115 else if (unformat (i, "arp-term"))
7116 flags |= L2_ARP_TERM;
7117 else if (unformat (i, "off"))
7119 else if (unformat (i, "disable"))
7125 if (sw_if_index_set == 0)
7127 errmsg ("missing interface name or sw_if_index");
7133 mp->sw_if_index = ntohl (sw_if_index);
7134 mp->feature_bitmap = ntohl (flags);
7135 mp->is_set = is_set;
7143 api_bridge_flags (vat_main_t * vam)
7145 unformat_input_t *i = vam->input;
7146 vl_api_bridge_flags_t *mp;
7150 bd_flags_t flags = 0;
7153 /* Parse args required to build the message */
7154 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7156 if (unformat (i, "bd_id %d", &bd_id))
7158 else if (unformat (i, "learn"))
7159 flags |= BRIDGE_API_FLAG_LEARN;
7160 else if (unformat (i, "forward"))
7161 flags |= BRIDGE_API_FLAG_FWD;
7162 else if (unformat (i, "flood"))
7163 flags |= BRIDGE_API_FLAG_FLOOD;
7164 else if (unformat (i, "uu-flood"))
7165 flags |= BRIDGE_API_FLAG_UU_FLOOD;
7166 else if (unformat (i, "arp-term"))
7167 flags |= BRIDGE_API_FLAG_ARP_TERM;
7168 else if (unformat (i, "off"))
7170 else if (unformat (i, "disable"))
7178 errmsg ("missing bridge domain");
7182 M (BRIDGE_FLAGS, mp);
7184 mp->bd_id = ntohl (bd_id);
7185 mp->flags = ntohl (flags);
7186 mp->is_set = is_set;
7194 api_bd_ip_mac_add_del (vat_main_t * vam)
7196 vl_api_address_t ip = VL_API_ZERO_ADDRESS;
7197 vl_api_mac_address_t mac = { 0 };
7198 unformat_input_t *i = vam->input;
7199 vl_api_bd_ip_mac_add_del_t *mp;
7208 /* Parse args required to build the message */
7209 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7211 if (unformat (i, "bd_id %d", &bd_id))
7215 else if (unformat (i, "%U", unformat_vl_api_address, &ip))
7219 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
7223 else if (unformat (i, "del"))
7231 errmsg ("missing bridge domain");
7234 else if (ip_set == 0)
7236 errmsg ("missing IP address");
7239 else if (mac_set == 0)
7241 errmsg ("missing MAC address");
7245 M (BD_IP_MAC_ADD_DEL, mp);
7247 mp->entry.bd_id = ntohl (bd_id);
7248 mp->is_add = is_add;
7250 clib_memcpy (&mp->entry.ip, &ip, sizeof (ip));
7251 clib_memcpy (&mp->entry.mac, &mac, sizeof (mac));
7259 api_bd_ip_mac_flush (vat_main_t * vam)
7261 unformat_input_t *i = vam->input;
7262 vl_api_bd_ip_mac_flush_t *mp;
7267 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7269 if (unformat (i, "bd_id %d", &bd_id))
7279 errmsg ("missing bridge domain");
7283 M (BD_IP_MAC_FLUSH, mp);
7285 mp->bd_id = ntohl (bd_id);
7292 static void vl_api_bd_ip_mac_details_t_handler
7293 (vl_api_bd_ip_mac_details_t * mp)
7295 vat_main_t *vam = &vat_main;
7299 ntohl (mp->entry.bd_id),
7300 format_vl_api_mac_address, mp->entry.mac,
7301 format_vl_api_address, &mp->entry.ip);
7304 static void vl_api_bd_ip_mac_details_t_handler_json
7305 (vl_api_bd_ip_mac_details_t * mp)
7307 vat_main_t *vam = &vat_main;
7308 vat_json_node_t *node = NULL;
7310 if (VAT_JSON_ARRAY != vam->json_tree.type)
7312 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7313 vat_json_init_array (&vam->json_tree);
7315 node = vat_json_array_add (&vam->json_tree);
7317 vat_json_init_object (node);
7318 vat_json_object_add_uint (node, "bd_id", ntohl (mp->entry.bd_id));
7319 vat_json_object_add_string_copy (node, "mac_address",
7320 format (0, "%U", format_vl_api_mac_address,
7324 ip = format (0, "%U", format_vl_api_address, &mp->entry.ip);
7325 vat_json_object_add_string_copy (node, "ip_address", ip);
7330 api_bd_ip_mac_dump (vat_main_t * vam)
7332 unformat_input_t *i = vam->input;
7333 vl_api_bd_ip_mac_dump_t *mp;
7334 vl_api_control_ping_t *mp_ping;
7339 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7341 if (unformat (i, "bd_id %d", &bd_id))
7350 "\n%-5s %-7s %-20s %-30s",
7351 "bd_id", "is_ipv6", "mac_address", "ip_address");
7353 /* Dump Bridge Domain Ip to Mac entries */
7354 M (BD_IP_MAC_DUMP, mp);
7357 mp->bd_id = htonl (bd_id);
7363 /* Use a control ping for synchronization */
7364 MPING (CONTROL_PING, mp_ping);
7372 api_tap_create_v2 (vat_main_t * vam)
7374 unformat_input_t *i = vam->input;
7375 vl_api_tap_create_v2_t *mp;
7376 #define TAP_FLAG_GSO (1 << 0)
7380 u8 *host_if_name = 0;
7382 u8 host_mac_addr[6];
7383 u8 host_mac_addr_set = 0;
7384 u8 *host_bridge = 0;
7385 ip4_address_t host_ip4_addr;
7386 ip4_address_t host_ip4_gw;
7387 u8 host_ip4_gw_set = 0;
7388 u32 host_ip4_prefix_len = 0;
7389 ip6_address_t host_ip6_addr;
7390 ip6_address_t host_ip6_gw;
7391 u8 host_ip6_gw_set = 0;
7392 u32 host_ip6_prefix_len = 0;
7393 u8 host_mtu_set = 0;
7394 u32 host_mtu_size = 0;
7397 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7399 clib_memset (mac_address, 0, sizeof (mac_address));
7401 /* Parse args required to build the message */
7402 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7404 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7408 else if (unformat (i, "id %u", &id))
7410 else if (unformat (i, "host-if-name %s", &host_if_name))
7412 else if (unformat (i, "host-ns %s", &host_ns))
7414 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
7416 host_mac_addr_set = 1;
7417 else if (unformat (i, "host-bridge %s", &host_bridge))
7419 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
7420 &host_ip4_addr, &host_ip4_prefix_len))
7422 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
7423 &host_ip6_addr, &host_ip6_prefix_len))
7425 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
7427 host_ip4_gw_set = 1;
7428 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
7430 host_ip6_gw_set = 1;
7431 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
7433 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
7435 else if (unformat (i, "host-mtu-size %d", &host_mtu_size))
7437 else if (unformat (i, "no-gso"))
7438 tap_flags &= ~TAP_FLAG_GSO;
7439 else if (unformat (i, "gso"))
7440 tap_flags |= TAP_FLAG_GSO;
7445 if (vec_len (host_if_name) > 63)
7447 errmsg ("tap name too long. ");
7450 if (vec_len (host_ns) > 63)
7452 errmsg ("host name space too long. ");
7455 if (vec_len (host_bridge) > 63)
7457 errmsg ("host bridge name too long. ");
7460 if (host_ip4_prefix_len > 32)
7462 errmsg ("host ip4 prefix length not valid. ");
7465 if (host_ip6_prefix_len > 128)
7467 errmsg ("host ip6 prefix length not valid. ");
7470 if (!is_pow2 (rx_ring_sz))
7472 errmsg ("rx ring size must be power of 2. ");
7475 if (rx_ring_sz > 32768)
7477 errmsg ("rx ring size must be 32768 or lower. ");
7480 if (!is_pow2 (tx_ring_sz))
7482 errmsg ("tx ring size must be power of 2. ");
7485 if (tx_ring_sz > 32768)
7487 errmsg ("tx ring size must be 32768 or lower. ");
7490 if (host_mtu_set && (host_mtu_size < 64 || host_mtu_size > 65355))
7492 errmsg ("host MTU size must be in between 64 and 65355. ");
7496 /* Construct the API message */
7497 M (TAP_CREATE_V2, mp);
7499 mp->use_random_mac = random_mac;
7501 mp->id = ntohl (id);
7502 mp->host_namespace_set = host_ns != 0;
7503 mp->host_bridge_set = host_bridge != 0;
7504 mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
7505 mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
7506 mp->rx_ring_sz = ntohs (rx_ring_sz);
7507 mp->tx_ring_sz = ntohs (tx_ring_sz);
7508 mp->host_mtu_set = host_mtu_set;
7509 mp->host_mtu_size = ntohl (host_mtu_size);
7510 mp->tap_flags = ntohl (tap_flags);
7512 if (random_mac == 0)
7513 clib_memcpy (mp->mac_address, mac_address, 6);
7514 if (host_mac_addr_set)
7515 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
7517 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
7519 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
7521 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
7522 if (host_ip4_prefix_len)
7523 clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
7524 if (host_ip6_prefix_len)
7525 clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
7526 if (host_ip4_gw_set)
7527 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
7528 if (host_ip6_gw_set)
7529 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
7532 vec_free (host_if_name);
7533 vec_free (host_bridge);
7538 /* Wait for a reply... */
7544 api_tap_delete_v2 (vat_main_t * vam)
7546 unformat_input_t *i = vam->input;
7547 vl_api_tap_delete_v2_t *mp;
7548 u32 sw_if_index = ~0;
7549 u8 sw_if_index_set = 0;
7552 /* Parse args required to build the message */
7553 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7555 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7556 sw_if_index_set = 1;
7557 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7558 sw_if_index_set = 1;
7563 if (sw_if_index_set == 0)
7565 errmsg ("missing vpp interface name. ");
7569 /* Construct the API message */
7570 M (TAP_DELETE_V2, mp);
7572 mp->sw_if_index = ntohl (sw_if_index);
7577 /* Wait for a reply... */
7583 unformat_vlib_pci_addr (unformat_input_t * input, va_list * args)
7585 vlib_pci_addr_t *addr = va_arg (*args, vlib_pci_addr_t *);
7588 if (!unformat (input, "%x:%x:%x.%x", &x[0], &x[1], &x[2], &x[3]))
7591 addr->domain = x[0];
7594 addr->function = x[3];
7600 api_virtio_pci_create (vat_main_t * vam)
7602 unformat_input_t *i = vam->input;
7603 vl_api_virtio_pci_create_t *mp;
7608 u64 features = (u64) ~ (0ULL);
7611 clib_memset (mac_address, 0, sizeof (mac_address));
7613 /* Parse args required to build the message */
7614 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7616 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7620 else if (unformat (i, "pci-addr %U", unformat_vlib_pci_addr, &pci_addr))
7622 else if (unformat (i, "features 0x%llx", &features))
7624 else if (unformat (i, "gso-enabled"))
7632 errmsg ("pci address must be non zero. ");
7636 /* Construct the API message */
7637 M (VIRTIO_PCI_CREATE, mp);
7639 mp->use_random_mac = random_mac;
7641 mp->pci_addr = htonl (pci_addr);
7642 mp->features = clib_host_to_net_u64 (features);
7643 mp->gso_enabled = gso_enabled;
7645 if (random_mac == 0)
7646 clib_memcpy (mp->mac_address, mac_address, 6);
7651 /* Wait for a reply... */
7657 api_virtio_pci_delete (vat_main_t * vam)
7659 unformat_input_t *i = vam->input;
7660 vl_api_virtio_pci_delete_t *mp;
7661 u32 sw_if_index = ~0;
7662 u8 sw_if_index_set = 0;
7665 /* Parse args required to build the message */
7666 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7668 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7669 sw_if_index_set = 1;
7670 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7671 sw_if_index_set = 1;
7676 if (sw_if_index_set == 0)
7678 errmsg ("missing vpp interface name. ");
7682 /* Construct the API message */
7683 M (VIRTIO_PCI_DELETE, mp);
7685 mp->sw_if_index = htonl (sw_if_index);
7690 /* Wait for a reply... */
7696 api_bond_create (vat_main_t * vam)
7698 unformat_input_t *i = vam->input;
7699 vl_api_bond_create_t *mp;
7709 clib_memset (mac_address, 0, sizeof (mac_address));
7712 /* Parse args required to build the message */
7713 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7715 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
7717 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
7718 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
7720 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
7723 else if (unformat (i, "numa-only"))
7725 else if (unformat (i, "id %u", &id))
7731 if (mode_is_set == 0)
7733 errmsg ("Missing bond mode. ");
7737 /* Construct the API message */
7738 M (BOND_CREATE, mp);
7740 mp->use_custom_mac = custom_mac;
7742 mp->mode = htonl (mode);
7743 mp->lb = htonl (lb);
7744 mp->id = htonl (id);
7745 mp->numa_only = numa_only;
7748 clib_memcpy (mp->mac_address, mac_address, 6);
7753 /* Wait for a reply... */
7759 api_bond_delete (vat_main_t * vam)
7761 unformat_input_t *i = vam->input;
7762 vl_api_bond_delete_t *mp;
7763 u32 sw_if_index = ~0;
7764 u8 sw_if_index_set = 0;
7767 /* Parse args required to build the message */
7768 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7770 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7771 sw_if_index_set = 1;
7772 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7773 sw_if_index_set = 1;
7778 if (sw_if_index_set == 0)
7780 errmsg ("missing vpp interface name. ");
7784 /* Construct the API message */
7785 M (BOND_DELETE, mp);
7787 mp->sw_if_index = ntohl (sw_if_index);
7792 /* Wait for a reply... */
7798 api_bond_enslave (vat_main_t * vam)
7800 unformat_input_t *i = vam->input;
7801 vl_api_bond_enslave_t *mp;
7802 u32 bond_sw_if_index;
7806 u32 bond_sw_if_index_is_set = 0;
7808 u8 sw_if_index_is_set = 0;
7810 /* Parse args required to build the message */
7811 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7813 if (unformat (i, "sw_if_index %d", &sw_if_index))
7814 sw_if_index_is_set = 1;
7815 else if (unformat (i, "bond %u", &bond_sw_if_index))
7816 bond_sw_if_index_is_set = 1;
7817 else if (unformat (i, "passive %d", &is_passive))
7819 else if (unformat (i, "long-timeout %d", &is_long_timeout))
7825 if (bond_sw_if_index_is_set == 0)
7827 errmsg ("Missing bond sw_if_index. ");
7830 if (sw_if_index_is_set == 0)
7832 errmsg ("Missing slave sw_if_index. ");
7836 /* Construct the API message */
7837 M (BOND_ENSLAVE, mp);
7839 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
7840 mp->sw_if_index = ntohl (sw_if_index);
7841 mp->is_long_timeout = is_long_timeout;
7842 mp->is_passive = is_passive;
7847 /* Wait for a reply... */
7853 api_bond_detach_slave (vat_main_t * vam)
7855 unformat_input_t *i = vam->input;
7856 vl_api_bond_detach_slave_t *mp;
7857 u32 sw_if_index = ~0;
7858 u8 sw_if_index_set = 0;
7861 /* Parse args required to build the message */
7862 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7864 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7865 sw_if_index_set = 1;
7866 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7867 sw_if_index_set = 1;
7872 if (sw_if_index_set == 0)
7874 errmsg ("missing vpp interface name. ");
7878 /* Construct the API message */
7879 M (BOND_DETACH_SLAVE, mp);
7881 mp->sw_if_index = ntohl (sw_if_index);
7886 /* Wait for a reply... */
7892 api_ip_table_add_del (vat_main_t * vam)
7894 unformat_input_t *i = vam->input;
7895 vl_api_ip_table_add_del_t *mp;
7901 /* Parse args required to build the message */
7902 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7904 if (unformat (i, "ipv6"))
7906 else if (unformat (i, "del"))
7908 else if (unformat (i, "add"))
7910 else if (unformat (i, "table %d", &table_id))
7914 clib_warning ("parse error '%U'", format_unformat_error, i);
7921 errmsg ("missing table-ID");
7925 /* Construct the API message */
7926 M (IP_TABLE_ADD_DEL, mp);
7928 mp->table.table_id = ntohl (table_id);
7929 mp->table.is_ip6 = is_ipv6;
7930 mp->is_add = is_add;
7935 /* Wait for a reply... */
7942 unformat_fib_path (unformat_input_t * input, va_list * args)
7944 vat_main_t *vam = va_arg (*args, vat_main_t *);
7945 vl_api_fib_path_t *path = va_arg (*args, vl_api_fib_path_t *);
7946 u32 weight, preference;
7947 mpls_label_t out_label;
7949 clib_memset (path, 0, sizeof (*path));
7951 path->sw_if_index = ~0;
7955 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7957 if (unformat (input, "%U %U",
7958 unformat_vl_api_ip4_address,
7959 &path->nh.address.ip4,
7960 api_unformat_sw_if_index, vam, &path->sw_if_index))
7962 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7964 else if (unformat (input, "%U %U",
7965 unformat_vl_api_ip6_address,
7966 &path->nh.address.ip6,
7967 api_unformat_sw_if_index, vam, &path->sw_if_index))
7969 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7971 else if (unformat (input, "weight %u", &weight))
7973 path->weight = weight;
7975 else if (unformat (input, "preference %u", &preference))
7977 path->preference = preference;
7979 else if (unformat (input, "%U next-hop-table %d",
7980 unformat_vl_api_ip4_address,
7981 &path->nh.address.ip4, &path->table_id))
7983 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7985 else if (unformat (input, "%U next-hop-table %d",
7986 unformat_vl_api_ip6_address,
7987 &path->nh.address.ip6, &path->table_id))
7989 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7991 else if (unformat (input, "%U",
7992 unformat_vl_api_ip4_address, &path->nh.address.ip4))
7995 * the recursive next-hops are by default in the default table
7998 path->sw_if_index = ~0;
7999 path->proto = FIB_API_PATH_NH_PROTO_IP4;
8001 else if (unformat (input, "%U",
8002 unformat_vl_api_ip6_address, &path->nh.address.ip6))
8005 * the recursive next-hops are by default in the default table
8008 path->sw_if_index = ~0;
8009 path->proto = FIB_API_PATH_NH_PROTO_IP6;
8011 else if (unformat (input, "resolve-via-host"))
8013 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_HOST;
8015 else if (unformat (input, "resolve-via-attached"))
8017 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED;
8019 else if (unformat (input, "ip4-lookup-in-table %d", &path->table_id))
8021 path->type = FIB_API_PATH_TYPE_LOCAL;
8022 path->sw_if_index = ~0;
8023 path->proto = FIB_API_PATH_NH_PROTO_IP4;
8025 else if (unformat (input, "ip6-lookup-in-table %d", &path->table_id))
8027 path->type = FIB_API_PATH_TYPE_LOCAL;
8028 path->sw_if_index = ~0;
8029 path->proto = FIB_API_PATH_NH_PROTO_IP6;
8031 else if (unformat (input, "sw_if_index %d", &path->sw_if_index))
8033 else if (unformat (input, "via-label %d", &path->nh.via_label))
8035 path->proto = FIB_API_PATH_NH_PROTO_MPLS;
8036 path->sw_if_index = ~0;
8038 else if (unformat (input, "l2-input-on %d", &path->sw_if_index))
8040 path->proto = FIB_API_PATH_NH_PROTO_ETHERNET;
8041 path->type = FIB_API_PATH_TYPE_INTERFACE_RX;
8043 else if (unformat (input, "local"))
8045 path->type = FIB_API_PATH_TYPE_LOCAL;
8047 else if (unformat (input, "out-labels"))
8049 while (unformat (input, "%d", &out_label))
8051 path->label_stack[path->n_labels].label = out_label;
8052 path->label_stack[path->n_labels].is_uniform = 0;
8053 path->label_stack[path->n_labels].ttl = 64;
8057 else if (unformat (input, "via"))
8059 /* new path, back up and return */
8060 unformat_put_input (input);
8061 unformat_put_input (input);
8062 unformat_put_input (input);
8063 unformat_put_input (input);
8072 path->proto = ntohl (path->proto);
8073 path->type = ntohl (path->type);
8074 path->flags = ntohl (path->flags);
8075 path->table_id = ntohl (path->table_id);
8076 path->sw_if_index = ntohl (path->sw_if_index);
8082 api_ip_route_add_del (vat_main_t * vam)
8084 unformat_input_t *i = vam->input;
8085 vl_api_ip_route_add_del_t *mp;
8088 u8 is_multipath = 0;
8091 vl_api_prefix_t pfx = { };
8092 vl_api_fib_path_t paths[8];
8096 u32 random_add_del = 0;
8097 u32 *random_vector = 0;
8098 u32 random_seed = 0xdeaddabe;
8100 /* Parse args required to build the message */
8101 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8103 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
8105 else if (unformat (i, "del"))
8107 else if (unformat (i, "add"))
8109 else if (unformat (i, "vrf %d", &vrf_id))
8111 else if (unformat (i, "count %d", &count))
8113 else if (unformat (i, "random"))
8115 else if (unformat (i, "multipath"))
8117 else if (unformat (i, "seed %d", &random_seed))
8121 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8124 if (8 == path_count)
8126 errmsg ("max 8 paths");
8132 clib_warning ("parse error '%U'", format_unformat_error, i);
8139 errmsg ("specify a path; via ...");
8142 if (prefix_set == 0)
8144 errmsg ("missing prefix");
8148 /* Generate a pile of unique, random routes */
8151 ip4_address_t *i = (ip4_address_t *) & paths[0].nh.address.ip4;
8152 u32 this_random_address;
8155 random_hash = hash_create (count, sizeof (uword));
8157 hash_set (random_hash, i->as_u32, 1);
8158 for (j = 0; j <= count; j++)
8162 this_random_address = random_u32 (&random_seed);
8163 this_random_address =
8164 clib_host_to_net_u32 (this_random_address);
8166 while (hash_get (random_hash, this_random_address));
8167 vec_add1 (random_vector, this_random_address);
8168 hash_set (random_hash, this_random_address, 1);
8170 hash_free (random_hash);
8171 set_ip4_address (&pfx.address, random_vector[0]);
8176 /* Turn on async mode */
8177 vam->async_mode = 1;
8178 vam->async_errors = 0;
8179 before = vat_time_now (vam);
8182 for (j = 0; j < count; j++)
8184 /* Construct the API message */
8185 M2 (IP_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8187 mp->is_add = is_add;
8188 mp->is_multipath = is_multipath;
8190 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
8191 mp->route.table_id = ntohl (vrf_id);
8192 mp->route.n_paths = path_count;
8194 clib_memcpy (&mp->route.paths, &paths, sizeof (paths[0]) * path_count);
8197 set_ip4_address (&pfx.address, random_vector[j + 1]);
8199 increment_address (&pfx.address);
8202 /* If we receive SIGTERM, stop now... */
8207 /* When testing multiple add/del ops, use a control-ping to sync */
8210 vl_api_control_ping_t *mp_ping;
8214 /* Shut off async mode */
8215 vam->async_mode = 0;
8217 MPING (CONTROL_PING, mp_ping);
8220 timeout = vat_time_now (vam) + 1.0;
8221 while (vat_time_now (vam) < timeout)
8222 if (vam->result_ready == 1)
8227 if (vam->retval == -99)
8230 if (vam->async_errors > 0)
8232 errmsg ("%d asynchronous errors", vam->async_errors);
8235 vam->async_errors = 0;
8236 after = vat_time_now (vam);
8238 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8242 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8243 count, after - before, count / (after - before));
8249 /* Wait for a reply... */
8254 /* Return the good/bad news */
8255 return (vam->retval);
8259 api_ip_mroute_add_del (vat_main_t * vam)
8261 unformat_input_t *i = vam->input;
8262 u8 path_set = 0, prefix_set = 0, is_add = 1;
8263 vl_api_ip_mroute_add_del_t *mp;
8264 mfib_entry_flags_t eflags = 0;
8265 vl_api_mfib_path_t path;
8266 vl_api_mprefix_t pfx = { };
8270 /* Parse args required to build the message */
8271 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8273 if (unformat (i, "%U", unformat_vl_api_mprefix, &pfx))
8276 pfx.grp_address_length = htons (pfx.grp_address_length);
8278 else if (unformat (i, "del"))
8280 else if (unformat (i, "add"))
8282 else if (unformat (i, "vrf %d", &vrf_id))
8284 else if (unformat (i, "%U", unformat_mfib_itf_flags, &path.itf_flags))
8285 path.itf_flags = htonl (path.itf_flags);
8286 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8288 else if (unformat (i, "via %U", unformat_fib_path, vam, &path.path))
8292 clib_warning ("parse error '%U'", format_unformat_error, i);
8297 if (prefix_set == 0)
8299 errmsg ("missing addresses\n");
8304 errmsg ("missing path\n");
8308 /* Construct the API message */
8309 M (IP_MROUTE_ADD_DEL, mp);
8311 mp->is_add = is_add;
8312 mp->is_multipath = 1;
8314 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
8315 mp->route.table_id = htonl (vrf_id);
8316 mp->route.n_paths = 1;
8317 mp->route.entry_flags = htonl (eflags);
8319 clib_memcpy (&mp->route.paths, &path, sizeof (path));
8323 /* Wait for a reply... */
8329 api_mpls_table_add_del (vat_main_t * vam)
8331 unformat_input_t *i = vam->input;
8332 vl_api_mpls_table_add_del_t *mp;
8337 /* Parse args required to build the message */
8338 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8340 if (unformat (i, "table %d", &table_id))
8342 else if (unformat (i, "del"))
8344 else if (unformat (i, "add"))
8348 clib_warning ("parse error '%U'", format_unformat_error, i);
8355 errmsg ("missing table-ID");
8359 /* Construct the API message */
8360 M (MPLS_TABLE_ADD_DEL, mp);
8362 mp->mt_table.mt_table_id = ntohl (table_id);
8363 mp->mt_is_add = is_add;
8368 /* Wait for a reply... */
8375 api_mpls_route_add_del (vat_main_t * vam)
8377 u8 is_add = 1, path_count = 0, is_multipath = 0, is_eos = 0;
8378 mpls_label_t local_label = MPLS_LABEL_INVALID;
8379 unformat_input_t *i = vam->input;
8380 vl_api_mpls_route_add_del_t *mp;
8381 vl_api_fib_path_t paths[8];
8385 /* Parse args required to build the message */
8386 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8388 if (unformat (i, "%d", &local_label))
8390 else if (unformat (i, "eos"))
8392 else if (unformat (i, "non-eos"))
8394 else if (unformat (i, "del"))
8396 else if (unformat (i, "add"))
8398 else if (unformat (i, "multipath"))
8400 else if (unformat (i, "count %d", &count))
8404 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8407 if (8 == path_count)
8409 errmsg ("max 8 paths");
8415 clib_warning ("parse error '%U'", format_unformat_error, i);
8422 errmsg ("specify a path; via ...");
8426 if (MPLS_LABEL_INVALID == local_label)
8428 errmsg ("missing label");
8434 /* Turn on async mode */
8435 vam->async_mode = 1;
8436 vam->async_errors = 0;
8437 before = vat_time_now (vam);
8440 for (j = 0; j < count; j++)
8442 /* Construct the API message */
8443 M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8445 mp->mr_is_add = is_add;
8446 mp->mr_is_multipath = is_multipath;
8448 mp->mr_route.mr_label = local_label;
8449 mp->mr_route.mr_eos = is_eos;
8450 mp->mr_route.mr_table_id = 0;
8451 mp->mr_route.mr_n_paths = path_count;
8453 clib_memcpy (&mp->mr_route.mr_paths, paths,
8454 sizeof (paths[0]) * path_count);
8460 /* If we receive SIGTERM, stop now... */
8465 /* When testing multiple add/del ops, use a control-ping to sync */
8468 vl_api_control_ping_t *mp_ping;
8472 /* Shut off async mode */
8473 vam->async_mode = 0;
8475 MPING (CONTROL_PING, mp_ping);
8478 timeout = vat_time_now (vam) + 1.0;
8479 while (vat_time_now (vam) < timeout)
8480 if (vam->result_ready == 1)
8485 if (vam->retval == -99)
8488 if (vam->async_errors > 0)
8490 errmsg ("%d asynchronous errors", vam->async_errors);
8493 vam->async_errors = 0;
8494 after = vat_time_now (vam);
8496 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8500 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8501 count, after - before, count / (after - before));
8507 /* Wait for a reply... */
8512 /* Return the good/bad news */
8513 return (vam->retval);
8518 api_mpls_ip_bind_unbind (vat_main_t * vam)
8520 unformat_input_t *i = vam->input;
8521 vl_api_mpls_ip_bind_unbind_t *mp;
8522 u32 ip_table_id = 0;
8524 vl_api_prefix_t pfx;
8526 mpls_label_t local_label = MPLS_LABEL_INVALID;
8529 /* Parse args required to build the message */
8530 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8532 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
8534 else if (unformat (i, "%d", &local_label))
8536 else if (unformat (i, "table-id %d", &ip_table_id))
8538 else if (unformat (i, "unbind"))
8540 else if (unformat (i, "bind"))
8544 clib_warning ("parse error '%U'", format_unformat_error, i);
8551 errmsg ("IP prefix not set");
8555 if (MPLS_LABEL_INVALID == local_label)
8557 errmsg ("missing label");
8561 /* Construct the API message */
8562 M (MPLS_IP_BIND_UNBIND, mp);
8564 mp->mb_is_bind = is_bind;
8565 mp->mb_ip_table_id = ntohl (ip_table_id);
8566 mp->mb_mpls_table_id = 0;
8567 mp->mb_label = ntohl (local_label);
8568 clib_memcpy (&mp->mb_prefix, &pfx, sizeof (pfx));
8573 /* Wait for a reply... */
8580 api_sr_mpls_policy_add (vat_main_t * vam)
8582 unformat_input_t *i = vam->input;
8583 vl_api_sr_mpls_policy_add_t *mp;
8589 u32 *segments = NULL;
8592 /* Parse args required to build the message */
8593 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8595 if (unformat (i, "bsid %d", &bsid))
8597 else if (unformat (i, "weight %d", &weight))
8599 else if (unformat (i, "spray"))
8601 else if (unformat (i, "next %d", &sid))
8604 vec_add1 (segments, htonl (sid));
8608 clib_warning ("parse error '%U'", format_unformat_error, i);
8615 errmsg ("bsid not set");
8619 if (n_segments == 0)
8621 errmsg ("no sid in segment stack");
8625 /* Construct the API message */
8626 M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
8628 mp->bsid = htonl (bsid);
8629 mp->weight = htonl (weight);
8631 mp->n_segments = n_segments;
8632 memcpy (mp->segments, segments, sizeof (u32) * n_segments);
8633 vec_free (segments);
8638 /* Wait for a reply... */
8644 api_sr_mpls_policy_del (vat_main_t * vam)
8646 unformat_input_t *i = vam->input;
8647 vl_api_sr_mpls_policy_del_t *mp;
8651 /* Parse args required to build the message */
8652 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8654 if (unformat (i, "bsid %d", &bsid))
8658 clib_warning ("parse error '%U'", format_unformat_error, i);
8665 errmsg ("bsid not set");
8669 /* Construct the API message */
8670 M (SR_MPLS_POLICY_DEL, mp);
8672 mp->bsid = htonl (bsid);
8677 /* Wait for a reply... */
8683 api_bier_table_add_del (vat_main_t * vam)
8685 unformat_input_t *i = vam->input;
8686 vl_api_bier_table_add_del_t *mp;
8688 u32 set = 0, sub_domain = 0, hdr_len = 3;
8689 mpls_label_t local_label = MPLS_LABEL_INVALID;
8692 /* Parse args required to build the message */
8693 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8695 if (unformat (i, "sub-domain %d", &sub_domain))
8697 else if (unformat (i, "set %d", &set))
8699 else if (unformat (i, "label %d", &local_label))
8701 else if (unformat (i, "hdr-len %d", &hdr_len))
8703 else if (unformat (i, "add"))
8705 else if (unformat (i, "del"))
8709 clib_warning ("parse error '%U'", format_unformat_error, i);
8714 if (MPLS_LABEL_INVALID == local_label)
8716 errmsg ("missing label\n");
8720 /* Construct the API message */
8721 M (BIER_TABLE_ADD_DEL, mp);
8723 mp->bt_is_add = is_add;
8724 mp->bt_label = ntohl (local_label);
8725 mp->bt_tbl_id.bt_set = set;
8726 mp->bt_tbl_id.bt_sub_domain = sub_domain;
8727 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
8732 /* Wait for a reply... */
8739 api_bier_route_add_del (vat_main_t * vam)
8741 unformat_input_t *i = vam->input;
8742 vl_api_bier_route_add_del_t *mp;
8744 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
8745 ip4_address_t v4_next_hop_address;
8746 ip6_address_t v6_next_hop_address;
8747 u8 next_hop_set = 0;
8748 u8 next_hop_proto_is_ip4 = 1;
8749 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8752 /* Parse args required to build the message */
8753 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8755 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
8757 next_hop_proto_is_ip4 = 1;
8760 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
8762 next_hop_proto_is_ip4 = 0;
8765 if (unformat (i, "sub-domain %d", &sub_domain))
8767 else if (unformat (i, "set %d", &set))
8769 else if (unformat (i, "hdr-len %d", &hdr_len))
8771 else if (unformat (i, "bp %d", &bp))
8773 else if (unformat (i, "add"))
8775 else if (unformat (i, "del"))
8777 else if (unformat (i, "out-label %d", &next_hop_out_label))
8781 clib_warning ("parse error '%U'", format_unformat_error, i);
8786 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
8788 errmsg ("next hop / label set\n");
8793 errmsg ("bit=position not set\n");
8797 /* Construct the API message */
8798 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
8800 mp->br_is_add = is_add;
8801 mp->br_route.br_tbl_id.bt_set = set;
8802 mp->br_route.br_tbl_id.bt_sub_domain = sub_domain;
8803 mp->br_route.br_tbl_id.bt_hdr_len_id = hdr_len;
8804 mp->br_route.br_bp = ntohs (bp);
8805 mp->br_route.br_n_paths = 1;
8806 mp->br_route.br_paths[0].n_labels = 1;
8807 mp->br_route.br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
8808 mp->br_route.br_paths[0].proto = (next_hop_proto_is_ip4 ?
8809 FIB_API_PATH_NH_PROTO_IP4 :
8810 FIB_API_PATH_NH_PROTO_IP6);
8812 if (next_hop_proto_is_ip4)
8814 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip4,
8815 &v4_next_hop_address, sizeof (v4_next_hop_address));
8819 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip6,
8820 &v6_next_hop_address, sizeof (v6_next_hop_address));
8826 /* Wait for a reply... */
8833 api_proxy_arp_add_del (vat_main_t * vam)
8835 unformat_input_t *i = vam->input;
8836 vl_api_proxy_arp_add_del_t *mp;
8839 vl_api_ip4_address_t lo, hi;
8843 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8845 if (unformat (i, "vrf %d", &vrf_id))
8847 else if (unformat (i, "%U - %U", unformat_vl_api_ip4_address, &lo,
8848 unformat_vl_api_ip4_address, &hi))
8850 else if (unformat (i, "del"))
8854 clib_warning ("parse error '%U'", format_unformat_error, i);
8861 errmsg ("address range not set");
8865 M (PROXY_ARP_ADD_DEL, mp);
8867 mp->proxy.table_id = ntohl (vrf_id);
8868 mp->is_add = is_add;
8869 clib_memcpy (mp->proxy.low, &lo, sizeof (lo));
8870 clib_memcpy (mp->proxy.hi, &hi, sizeof (hi));
8878 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
8880 unformat_input_t *i = vam->input;
8881 vl_api_proxy_arp_intfc_enable_disable_t *mp;
8884 u8 sw_if_index_set = 0;
8887 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8889 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8890 sw_if_index_set = 1;
8891 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8892 sw_if_index_set = 1;
8893 else if (unformat (i, "enable"))
8895 else if (unformat (i, "disable"))
8899 clib_warning ("parse error '%U'", format_unformat_error, i);
8904 if (sw_if_index_set == 0)
8906 errmsg ("missing interface name or sw_if_index");
8910 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
8912 mp->sw_if_index = ntohl (sw_if_index);
8913 mp->enable_disable = enable;
8921 api_mpls_tunnel_add_del (vat_main_t * vam)
8923 unformat_input_t *i = vam->input;
8924 vl_api_mpls_tunnel_add_del_t *mp;
8926 vl_api_fib_path_t paths[8];
8927 u32 sw_if_index = ~0;
8933 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8935 if (unformat (i, "add"))
8939 (i, "del %U", api_unformat_sw_if_index, vam, &sw_if_index))
8941 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
8943 else if (unformat (i, "l2-only"))
8947 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8950 if (8 == path_count)
8952 errmsg ("max 8 paths");
8958 clib_warning ("parse error '%U'", format_unformat_error, i);
8963 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8965 mp->mt_is_add = is_add;
8966 mp->mt_tunnel.mt_sw_if_index = ntohl (sw_if_index);
8967 mp->mt_tunnel.mt_l2_only = l2_only;
8968 mp->mt_tunnel.mt_is_multicast = 0;
8969 mp->mt_tunnel.mt_n_paths = path_count;
8971 clib_memcpy (&mp->mt_tunnel.mt_paths, &paths,
8972 sizeof (paths[0]) * path_count);
8980 api_sw_interface_set_unnumbered (vat_main_t * vam)
8982 unformat_input_t *i = vam->input;
8983 vl_api_sw_interface_set_unnumbered_t *mp;
8985 u32 unnum_sw_index = ~0;
8987 u8 sw_if_index_set = 0;
8990 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8992 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8993 sw_if_index_set = 1;
8994 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8995 sw_if_index_set = 1;
8996 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
8998 else if (unformat (i, "del"))
9002 clib_warning ("parse error '%U'", format_unformat_error, i);
9007 if (sw_if_index_set == 0)
9009 errmsg ("missing interface name or sw_if_index");
9013 M (SW_INTERFACE_SET_UNNUMBERED, mp);
9015 mp->sw_if_index = ntohl (sw_if_index);
9016 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
9017 mp->is_add = is_add;
9025 api_ip_neighbor_add_del (vat_main_t * vam)
9027 vl_api_mac_address_t mac_address;
9028 unformat_input_t *i = vam->input;
9029 vl_api_ip_neighbor_add_del_t *mp;
9030 vl_api_address_t ip_address;
9032 u8 sw_if_index_set = 0;
9037 ip_neighbor_flags_t flags;
9039 flags = IP_NEIGHBOR_FLAG_NONE;
9040 clib_memset (&ip_address, 0, sizeof (ip_address));
9041 clib_memset (&mac_address, 0, sizeof (mac_address));
9043 /* Parse args required to build the message */
9044 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9046 if (unformat (i, "mac %U", unformat_vl_api_mac_address, &mac_address))
9050 else if (unformat (i, "del"))
9053 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9054 sw_if_index_set = 1;
9055 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9056 sw_if_index_set = 1;
9057 else if (unformat (i, "static"))
9058 flags |= IP_NEIGHBOR_FLAG_STATIC;
9059 else if (unformat (i, "no-fib-entry"))
9060 flags |= IP_NEIGHBOR_FLAG_NO_FIB_ENTRY;
9061 else if (unformat (i, "dst %U", unformat_vl_api_address, &ip_address))
9065 clib_warning ("parse error '%U'", format_unformat_error, i);
9070 if (sw_if_index_set == 0)
9072 errmsg ("missing interface name or sw_if_index");
9077 errmsg ("no address set");
9081 /* Construct the API message */
9082 M (IP_NEIGHBOR_ADD_DEL, mp);
9084 mp->neighbor.sw_if_index = ntohl (sw_if_index);
9085 mp->is_add = is_add;
9086 mp->neighbor.flags = htonl (flags);
9088 clib_memcpy (&mp->neighbor.mac_address, &mac_address,
9089 sizeof (mac_address));
9091 clib_memcpy (&mp->neighbor.ip_address, &ip_address, sizeof (ip_address));
9096 /* Wait for a reply, return good/bad news */
9102 api_create_vlan_subif (vat_main_t * vam)
9104 unformat_input_t *i = vam->input;
9105 vl_api_create_vlan_subif_t *mp;
9107 u8 sw_if_index_set = 0;
9112 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9114 if (unformat (i, "sw_if_index %d", &sw_if_index))
9115 sw_if_index_set = 1;
9117 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9118 sw_if_index_set = 1;
9119 else if (unformat (i, "vlan %d", &vlan_id))
9123 clib_warning ("parse error '%U'", format_unformat_error, i);
9128 if (sw_if_index_set == 0)
9130 errmsg ("missing interface name or sw_if_index");
9134 if (vlan_id_set == 0)
9136 errmsg ("missing vlan_id");
9139 M (CREATE_VLAN_SUBIF, mp);
9141 mp->sw_if_index = ntohl (sw_if_index);
9142 mp->vlan_id = ntohl (vlan_id);
9149 #define foreach_create_subif_bit \
9156 _(outer_vlan_id_any) \
9157 _(inner_vlan_id_any)
9159 #define foreach_create_subif_flag \
9164 _(4, "exact_match") \
9165 _(5, "default_sub") \
9166 _(6, "outer_vlan_id_any") \
9167 _(7, "inner_vlan_id_any")
9170 api_create_subif (vat_main_t * vam)
9172 unformat_input_t *i = vam->input;
9173 vl_api_create_subif_t *mp;
9175 u8 sw_if_index_set = 0;
9178 u32 __attribute__ ((unused)) no_tags = 0;
9179 u32 __attribute__ ((unused)) one_tag = 0;
9180 u32 __attribute__ ((unused)) two_tags = 0;
9181 u32 __attribute__ ((unused)) dot1ad = 0;
9182 u32 __attribute__ ((unused)) exact_match = 0;
9183 u32 __attribute__ ((unused)) default_sub = 0;
9184 u32 __attribute__ ((unused)) outer_vlan_id_any = 0;
9185 u32 __attribute__ ((unused)) inner_vlan_id_any = 0;
9187 u16 outer_vlan_id = 0;
9188 u16 inner_vlan_id = 0;
9191 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9193 if (unformat (i, "sw_if_index %d", &sw_if_index))
9194 sw_if_index_set = 1;
9196 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9197 sw_if_index_set = 1;
9198 else if (unformat (i, "sub_id %d", &sub_id))
9200 else if (unformat (i, "outer_vlan_id %d", &tmp))
9201 outer_vlan_id = tmp;
9202 else if (unformat (i, "inner_vlan_id %d", &tmp))
9203 inner_vlan_id = tmp;
9205 #define _(a) else if (unformat (i, #a)) a = 1 ;
9206 foreach_create_subif_bit
9210 clib_warning ("parse error '%U'", format_unformat_error, i);
9215 if (sw_if_index_set == 0)
9217 errmsg ("missing interface name or sw_if_index");
9221 if (sub_id_set == 0)
9223 errmsg ("missing sub_id");
9226 M (CREATE_SUBIF, mp);
9228 mp->sw_if_index = ntohl (sw_if_index);
9229 mp->sub_id = ntohl (sub_id);
9231 #define _(a,b) mp->sub_if_flags |= (1 << a);
9232 foreach_create_subif_flag;
9235 mp->outer_vlan_id = ntohs (outer_vlan_id);
9236 mp->inner_vlan_id = ntohs (inner_vlan_id);
9244 api_reset_fib (vat_main_t * vam)
9246 unformat_input_t *i = vam->input;
9247 vl_api_reset_fib_t *mp;
9253 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9255 if (unformat (i, "vrf %d", &vrf_id))
9257 else if (unformat (i, "ipv6"))
9261 clib_warning ("parse error '%U'", format_unformat_error, i);
9266 if (vrf_id_set == 0)
9268 errmsg ("missing vrf id");
9274 mp->vrf_id = ntohl (vrf_id);
9275 mp->is_ipv6 = is_ipv6;
9283 api_dhcp_proxy_config (vat_main_t * vam)
9285 unformat_input_t *i = vam->input;
9286 vl_api_dhcp_proxy_config_t *mp;
9288 u32 server_vrf_id = 0;
9290 u8 v4_address_set = 0;
9291 u8 v6_address_set = 0;
9292 ip4_address_t v4address;
9293 ip6_address_t v6address;
9294 u8 v4_src_address_set = 0;
9295 u8 v6_src_address_set = 0;
9296 ip4_address_t v4srcaddress;
9297 ip6_address_t v6srcaddress;
9300 /* Parse args required to build the message */
9301 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9303 if (unformat (i, "del"))
9305 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
9307 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
9309 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
9311 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
9313 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
9314 v4_src_address_set = 1;
9315 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
9316 v6_src_address_set = 1;
9321 if (v4_address_set && v6_address_set)
9323 errmsg ("both v4 and v6 server addresses set");
9326 if (!v4_address_set && !v6_address_set)
9328 errmsg ("no server addresses set");
9332 if (v4_src_address_set && v6_src_address_set)
9334 errmsg ("both v4 and v6 src addresses set");
9337 if (!v4_src_address_set && !v6_src_address_set)
9339 errmsg ("no src addresses set");
9343 if (!(v4_src_address_set && v4_address_set) &&
9344 !(v6_src_address_set && v6_address_set))
9346 errmsg ("no matching server and src addresses set");
9350 /* Construct the API message */
9351 M (DHCP_PROXY_CONFIG, mp);
9353 mp->is_add = is_add;
9354 mp->rx_vrf_id = ntohl (rx_vrf_id);
9355 mp->server_vrf_id = ntohl (server_vrf_id);
9359 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
9360 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
9364 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
9365 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
9371 /* Wait for a reply, return good/bad news */
9376 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
9377 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
9380 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
9382 vat_main_t *vam = &vat_main;
9383 u32 i, count = mp->count;
9384 vl_api_dhcp_server_t *s;
9388 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9389 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9390 ntohl (mp->rx_vrf_id),
9391 format_ip6_address, mp->dhcp_src_address,
9392 mp->vss_type, mp->vss_vpn_ascii_id,
9393 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9396 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9397 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9398 ntohl (mp->rx_vrf_id),
9399 format_ip4_address, mp->dhcp_src_address,
9400 mp->vss_type, mp->vss_vpn_ascii_id,
9401 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9403 for (i = 0; i < count; i++)
9405 s = &mp->servers[i];
9409 " Server Table-ID %d, Server Address %U",
9410 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
9413 " Server Table-ID %d, Server Address %U",
9414 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
9418 static void vl_api_dhcp_proxy_details_t_handler_json
9419 (vl_api_dhcp_proxy_details_t * mp)
9421 vat_main_t *vam = &vat_main;
9422 vat_json_node_t *node = NULL;
9423 u32 i, count = mp->count;
9425 struct in6_addr ip6;
9426 vl_api_dhcp_server_t *s;
9428 if (VAT_JSON_ARRAY != vam->json_tree.type)
9430 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9431 vat_json_init_array (&vam->json_tree);
9433 node = vat_json_array_add (&vam->json_tree);
9435 vat_json_init_object (node);
9436 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
9437 vat_json_object_add_bytes (node, "vss-type", &mp->vss_type,
9438 sizeof (mp->vss_type));
9439 vat_json_object_add_string_copy (node, "vss-vpn-ascii-id",
9440 mp->vss_vpn_ascii_id);
9441 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
9442 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
9446 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
9447 vat_json_object_add_ip6 (node, "src_address", ip6);
9451 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
9452 vat_json_object_add_ip4 (node, "src_address", ip4);
9455 for (i = 0; i < count; i++)
9457 s = &mp->servers[i];
9459 vat_json_object_add_uint (node, "server-table-id",
9460 ntohl (s->server_vrf_id));
9464 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
9465 vat_json_object_add_ip4 (node, "src_address", ip4);
9469 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
9470 vat_json_object_add_ip6 (node, "server_address", ip6);
9476 api_dhcp_proxy_dump (vat_main_t * vam)
9478 unformat_input_t *i = vam->input;
9479 vl_api_control_ping_t *mp_ping;
9480 vl_api_dhcp_proxy_dump_t *mp;
9484 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9486 if (unformat (i, "ipv6"))
9490 clib_warning ("parse error '%U'", format_unformat_error, i);
9495 M (DHCP_PROXY_DUMP, mp);
9497 mp->is_ip6 = is_ipv6;
9500 /* Use a control ping for synchronization */
9501 MPING (CONTROL_PING, mp_ping);
9509 api_dhcp_proxy_set_vss (vat_main_t * vam)
9511 unformat_input_t *i = vam->input;
9512 vl_api_dhcp_proxy_set_vss_t *mp;
9516 u8 vss_type = VSS_TYPE_DEFAULT;
9517 u8 *vpn_ascii_id = 0;
9522 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9524 if (unformat (i, "tbl_id %d", &tbl_id))
9526 else if (unformat (i, "vpn_ascii_id %s", &vpn_ascii_id))
9527 vss_type = VSS_TYPE_ASCII;
9528 else if (unformat (i, "fib_id %d", &fib_id))
9529 vss_type = VSS_TYPE_VPN_ID;
9530 else if (unformat (i, "oui %d", &oui))
9531 vss_type = VSS_TYPE_VPN_ID;
9532 else if (unformat (i, "ipv6"))
9534 else if (unformat (i, "del"))
9542 errmsg ("missing tbl_id ");
9543 vec_free (vpn_ascii_id);
9547 if ((vpn_ascii_id) && (vec_len (vpn_ascii_id) > 128))
9549 errmsg ("vpn_ascii_id cannot be longer than 128 ");
9550 vec_free (vpn_ascii_id);
9554 M (DHCP_PROXY_SET_VSS, mp);
9555 mp->tbl_id = ntohl (tbl_id);
9556 mp->vss_type = vss_type;
9559 clib_memcpy (mp->vpn_ascii_id, vpn_ascii_id, vec_len (vpn_ascii_id));
9560 mp->vpn_ascii_id[vec_len (vpn_ascii_id)] = 0;
9562 mp->vpn_index = ntohl (fib_id);
9563 mp->oui = ntohl (oui);
9564 mp->is_ipv6 = is_ipv6;
9565 mp->is_add = is_add;
9570 vec_free (vpn_ascii_id);
9575 api_dhcp_client_config (vat_main_t * vam)
9577 unformat_input_t *i = vam->input;
9578 vl_api_dhcp_client_config_t *mp;
9580 u8 sw_if_index_set = 0;
9583 u8 disable_event = 0;
9586 /* Parse args required to build the message */
9587 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9589 if (unformat (i, "del"))
9592 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9593 sw_if_index_set = 1;
9594 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9595 sw_if_index_set = 1;
9596 else if (unformat (i, "hostname %s", &hostname))
9598 else if (unformat (i, "disable_event"))
9604 if (sw_if_index_set == 0)
9606 errmsg ("missing interface name or sw_if_index");
9610 if (vec_len (hostname) > 63)
9612 errmsg ("hostname too long");
9614 vec_add1 (hostname, 0);
9616 /* Construct the API message */
9617 M (DHCP_CLIENT_CONFIG, mp);
9619 mp->is_add = is_add;
9620 mp->client.sw_if_index = htonl (sw_if_index);
9621 clib_memcpy (mp->client.hostname, hostname, vec_len (hostname));
9622 vec_free (hostname);
9623 mp->client.want_dhcp_event = disable_event ? 0 : 1;
9624 mp->client.pid = htonl (getpid ());
9629 /* Wait for a reply, return good/bad news */
9635 api_set_ip_flow_hash (vat_main_t * vam)
9637 unformat_input_t *i = vam->input;
9638 vl_api_set_ip_flow_hash_t *mp;
9650 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9652 if (unformat (i, "vrf %d", &vrf_id))
9654 else if (unformat (i, "ipv6"))
9656 else if (unformat (i, "src"))
9658 else if (unformat (i, "dst"))
9660 else if (unformat (i, "sport"))
9662 else if (unformat (i, "dport"))
9664 else if (unformat (i, "proto"))
9666 else if (unformat (i, "reverse"))
9671 clib_warning ("parse error '%U'", format_unformat_error, i);
9676 if (vrf_id_set == 0)
9678 errmsg ("missing vrf id");
9682 M (SET_IP_FLOW_HASH, mp);
9688 mp->reverse = reverse;
9689 mp->vrf_id = ntohl (vrf_id);
9690 mp->is_ipv6 = is_ipv6;
9698 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
9700 unformat_input_t *i = vam->input;
9701 vl_api_sw_interface_ip6_enable_disable_t *mp;
9703 u8 sw_if_index_set = 0;
9707 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9709 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9710 sw_if_index_set = 1;
9711 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9712 sw_if_index_set = 1;
9713 else if (unformat (i, "enable"))
9715 else if (unformat (i, "disable"))
9719 clib_warning ("parse error '%U'", format_unformat_error, i);
9724 if (sw_if_index_set == 0)
9726 errmsg ("missing interface name or sw_if_index");
9730 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
9732 mp->sw_if_index = ntohl (sw_if_index);
9733 mp->enable = enable;
9741 api_ip6nd_proxy_add_del (vat_main_t * vam)
9743 unformat_input_t *i = vam->input;
9744 vl_api_ip6nd_proxy_add_del_t *mp;
9745 u32 sw_if_index = ~0;
9746 u8 v6_address_set = 0;
9747 vl_api_ip6_address_t v6address;
9751 /* Parse args required to build the message */
9752 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9754 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9756 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9758 else if (unformat (i, "%U", unformat_vl_api_ip6_address, &v6address))
9760 if (unformat (i, "del"))
9764 clib_warning ("parse error '%U'", format_unformat_error, i);
9769 if (sw_if_index == ~0)
9771 errmsg ("missing interface name or sw_if_index");
9774 if (!v6_address_set)
9776 errmsg ("no address set");
9780 /* Construct the API message */
9781 M (IP6ND_PROXY_ADD_DEL, mp);
9783 mp->is_del = is_del;
9784 mp->sw_if_index = ntohl (sw_if_index);
9785 clib_memcpy (mp->ip, v6address, sizeof (v6address));
9790 /* Wait for a reply, return good/bad news */
9796 api_ip6nd_proxy_dump (vat_main_t * vam)
9798 vl_api_ip6nd_proxy_dump_t *mp;
9799 vl_api_control_ping_t *mp_ping;
9802 M (IP6ND_PROXY_DUMP, mp);
9806 /* Use a control ping for synchronization */
9807 MPING (CONTROL_PING, mp_ping);
9814 static void vl_api_ip6nd_proxy_details_t_handler
9815 (vl_api_ip6nd_proxy_details_t * mp)
9817 vat_main_t *vam = &vat_main;
9819 print (vam->ofp, "host %U sw_if_index %d",
9820 format_vl_api_ip6_address, mp->ip, ntohl (mp->sw_if_index));
9823 static void vl_api_ip6nd_proxy_details_t_handler_json
9824 (vl_api_ip6nd_proxy_details_t * mp)
9826 vat_main_t *vam = &vat_main;
9827 struct in6_addr ip6;
9828 vat_json_node_t *node = NULL;
9830 if (VAT_JSON_ARRAY != vam->json_tree.type)
9832 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9833 vat_json_init_array (&vam->json_tree);
9835 node = vat_json_array_add (&vam->json_tree);
9837 vat_json_init_object (node);
9838 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9840 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
9841 vat_json_object_add_ip6 (node, "host", ip6);
9845 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
9847 unformat_input_t *i = vam->input;
9848 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
9850 u8 sw_if_index_set = 0;
9851 u8 v6_address_set = 0;
9852 vl_api_prefix_t pfx;
9854 u8 no_advertise = 0;
9856 u8 no_autoconfig = 0;
9859 u32 val_lifetime = 0;
9860 u32 pref_lifetime = 0;
9863 /* Parse args required to build the message */
9864 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9866 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9867 sw_if_index_set = 1;
9868 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9869 sw_if_index_set = 1;
9870 else if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
9872 else if (unformat (i, "val_life %d", &val_lifetime))
9874 else if (unformat (i, "pref_life %d", &pref_lifetime))
9876 else if (unformat (i, "def"))
9878 else if (unformat (i, "noadv"))
9880 else if (unformat (i, "offl"))
9882 else if (unformat (i, "noauto"))
9884 else if (unformat (i, "nolink"))
9886 else if (unformat (i, "isno"))
9890 clib_warning ("parse error '%U'", format_unformat_error, i);
9895 if (sw_if_index_set == 0)
9897 errmsg ("missing interface name or sw_if_index");
9900 if (!v6_address_set)
9902 errmsg ("no address set");
9906 /* Construct the API message */
9907 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
9909 mp->sw_if_index = ntohl (sw_if_index);
9910 clib_memcpy (&mp->prefix, &pfx, sizeof (pfx));
9911 mp->use_default = use_default;
9912 mp->no_advertise = no_advertise;
9913 mp->off_link = off_link;
9914 mp->no_autoconfig = no_autoconfig;
9915 mp->no_onlink = no_onlink;
9917 mp->val_lifetime = ntohl (val_lifetime);
9918 mp->pref_lifetime = ntohl (pref_lifetime);
9923 /* Wait for a reply, return good/bad news */
9929 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
9931 unformat_input_t *i = vam->input;
9932 vl_api_sw_interface_ip6nd_ra_config_t *mp;
9934 u8 sw_if_index_set = 0;
9939 u8 send_unicast = 0;
9942 u8 default_router = 0;
9943 u32 max_interval = 0;
9944 u32 min_interval = 0;
9946 u32 initial_count = 0;
9947 u32 initial_interval = 0;
9951 /* Parse args required to build the message */
9952 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9954 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9955 sw_if_index_set = 1;
9956 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9957 sw_if_index_set = 1;
9958 else if (unformat (i, "maxint %d", &max_interval))
9960 else if (unformat (i, "minint %d", &min_interval))
9962 else if (unformat (i, "life %d", &lifetime))
9964 else if (unformat (i, "count %d", &initial_count))
9966 else if (unformat (i, "interval %d", &initial_interval))
9968 else if (unformat (i, "suppress") || unformat (i, "surpress"))
9970 else if (unformat (i, "managed"))
9972 else if (unformat (i, "other"))
9974 else if (unformat (i, "ll"))
9976 else if (unformat (i, "send"))
9978 else if (unformat (i, "cease"))
9980 else if (unformat (i, "isno"))
9982 else if (unformat (i, "def"))
9986 clib_warning ("parse error '%U'", format_unformat_error, i);
9991 if (sw_if_index_set == 0)
9993 errmsg ("missing interface name or sw_if_index");
9997 /* Construct the API message */
9998 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
10000 mp->sw_if_index = ntohl (sw_if_index);
10001 mp->max_interval = ntohl (max_interval);
10002 mp->min_interval = ntohl (min_interval);
10003 mp->lifetime = ntohl (lifetime);
10004 mp->initial_count = ntohl (initial_count);
10005 mp->initial_interval = ntohl (initial_interval);
10006 mp->suppress = suppress;
10007 mp->managed = managed;
10009 mp->ll_option = ll_option;
10010 mp->send_unicast = send_unicast;
10013 mp->default_router = default_router;
10018 /* Wait for a reply, return good/bad news */
10024 api_set_arp_neighbor_limit (vat_main_t * vam)
10026 unformat_input_t *i = vam->input;
10027 vl_api_set_arp_neighbor_limit_t *mp;
10033 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10035 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
10037 else if (unformat (i, "ipv6"))
10041 clib_warning ("parse error '%U'", format_unformat_error, i);
10046 if (limit_set == 0)
10048 errmsg ("missing limit value");
10052 M (SET_ARP_NEIGHBOR_LIMIT, mp);
10054 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
10055 mp->is_ipv6 = is_ipv6;
10063 api_l2_patch_add_del (vat_main_t * vam)
10065 unformat_input_t *i = vam->input;
10066 vl_api_l2_patch_add_del_t *mp;
10067 u32 rx_sw_if_index;
10068 u8 rx_sw_if_index_set = 0;
10069 u32 tx_sw_if_index;
10070 u8 tx_sw_if_index_set = 0;
10074 /* Parse args required to build the message */
10075 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10077 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
10078 rx_sw_if_index_set = 1;
10079 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
10080 tx_sw_if_index_set = 1;
10081 else if (unformat (i, "rx"))
10083 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10085 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10087 rx_sw_if_index_set = 1;
10092 else if (unformat (i, "tx"))
10094 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10096 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10098 tx_sw_if_index_set = 1;
10103 else if (unformat (i, "del"))
10109 if (rx_sw_if_index_set == 0)
10111 errmsg ("missing rx interface name or rx_sw_if_index");
10115 if (tx_sw_if_index_set == 0)
10117 errmsg ("missing tx interface name or tx_sw_if_index");
10121 M (L2_PATCH_ADD_DEL, mp);
10123 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
10124 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
10125 mp->is_add = is_add;
10133 u8 localsid_addr[16];
10142 api_sr_localsid_add_del (vat_main_t * vam)
10144 unformat_input_t *i = vam->input;
10145 vl_api_sr_localsid_add_del_t *mp;
10148 ip6_address_t localsid;
10152 u32 fib_table = ~(u32) 0;
10153 ip6_address_t nh_addr6;
10154 ip4_address_t nh_addr4;
10155 clib_memset (&nh_addr6, 0, sizeof (ip6_address_t));
10156 clib_memset (&nh_addr4, 0, sizeof (ip4_address_t));
10158 bool nexthop_set = 0;
10162 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10164 if (unformat (i, "del"))
10166 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
10167 else if (unformat (i, "next-hop %U", unformat_ip4_address, &nh_addr4))
10169 else if (unformat (i, "next-hop %U", unformat_ip6_address, &nh_addr6))
10171 else if (unformat (i, "behavior %u", &behavior));
10172 else if (unformat (i, "sw_if_index %u", &sw_if_index));
10173 else if (unformat (i, "fib-table %u", &fib_table));
10174 else if (unformat (i, "end.psp %u", &behavior));
10179 M (SR_LOCALSID_ADD_DEL, mp);
10181 clib_memcpy (mp->localsid.addr, &localsid, sizeof (mp->localsid));
10184 clib_memcpy (mp->nh_addr6, &nh_addr6, sizeof (mp->nh_addr6));
10185 clib_memcpy (mp->nh_addr4, &nh_addr4, sizeof (mp->nh_addr4));
10187 mp->behavior = behavior;
10188 mp->sw_if_index = ntohl (sw_if_index);
10189 mp->fib_table = ntohl (fib_table);
10190 mp->end_psp = end_psp;
10191 mp->is_del = is_del;
10199 api_ioam_enable (vat_main_t * vam)
10201 unformat_input_t *input = vam->input;
10202 vl_api_ioam_enable_t *mp;
10204 int has_trace_option = 0;
10205 int has_pot_option = 0;
10206 int has_seqno_option = 0;
10207 int has_analyse_option = 0;
10210 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10212 if (unformat (input, "trace"))
10213 has_trace_option = 1;
10214 else if (unformat (input, "pot"))
10215 has_pot_option = 1;
10216 else if (unformat (input, "seqno"))
10217 has_seqno_option = 1;
10218 else if (unformat (input, "analyse"))
10219 has_analyse_option = 1;
10223 M (IOAM_ENABLE, mp);
10224 mp->id = htons (id);
10225 mp->seqno = has_seqno_option;
10226 mp->analyse = has_analyse_option;
10227 mp->pot_enable = has_pot_option;
10228 mp->trace_enable = has_trace_option;
10237 api_ioam_disable (vat_main_t * vam)
10239 vl_api_ioam_disable_t *mp;
10242 M (IOAM_DISABLE, mp);
10248 #define foreach_tcp_proto_field \
10252 #define foreach_udp_proto_field \
10256 #define foreach_ip4_proto_field \
10268 u16 src_port, dst_port;
10271 #if VPP_API_TEST_BUILTIN == 0
10273 unformat_tcp_mask (unformat_input_t * input, va_list * args)
10275 u8 **maskp = va_arg (*args, u8 **);
10277 u8 found_something = 0;
10280 #define _(a) u8 a=0;
10281 foreach_tcp_proto_field;
10284 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10287 #define _(a) else if (unformat (input, #a)) a=1;
10288 foreach_tcp_proto_field
10294 #define _(a) found_something += a;
10295 foreach_tcp_proto_field;
10298 if (found_something == 0)
10301 vec_validate (mask, sizeof (*tcp) - 1);
10303 tcp = (tcp_header_t *) mask;
10305 #define _(a) if (a) clib_memset (&tcp->a, 0xff, sizeof (tcp->a));
10306 foreach_tcp_proto_field;
10314 unformat_udp_mask (unformat_input_t * input, va_list * args)
10316 u8 **maskp = va_arg (*args, u8 **);
10318 u8 found_something = 0;
10321 #define _(a) u8 a=0;
10322 foreach_udp_proto_field;
10325 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10328 #define _(a) else if (unformat (input, #a)) a=1;
10329 foreach_udp_proto_field
10335 #define _(a) found_something += a;
10336 foreach_udp_proto_field;
10339 if (found_something == 0)
10342 vec_validate (mask, sizeof (*udp) - 1);
10344 udp = (udp_header_t *) mask;
10346 #define _(a) if (a) clib_memset (&udp->a, 0xff, sizeof (udp->a));
10347 foreach_udp_proto_field;
10355 unformat_l4_mask (unformat_input_t * input, va_list * args)
10357 u8 **maskp = va_arg (*args, u8 **);
10358 u16 src_port = 0, dst_port = 0;
10359 tcpudp_header_t *tcpudp;
10361 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10363 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
10365 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
10367 else if (unformat (input, "src_port"))
10369 else if (unformat (input, "dst_port"))
10375 if (!src_port && !dst_port)
10379 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
10381 tcpudp = (tcpudp_header_t *) mask;
10382 tcpudp->src_port = src_port;
10383 tcpudp->dst_port = dst_port;
10391 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10393 u8 **maskp = va_arg (*args, u8 **);
10395 u8 found_something = 0;
10398 #define _(a) u8 a=0;
10399 foreach_ip4_proto_field;
10405 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10407 if (unformat (input, "version"))
10409 else if (unformat (input, "hdr_length"))
10411 else if (unformat (input, "src"))
10413 else if (unformat (input, "dst"))
10415 else if (unformat (input, "proto"))
10418 #define _(a) else if (unformat (input, #a)) a=1;
10419 foreach_ip4_proto_field
10425 #define _(a) found_something += a;
10426 foreach_ip4_proto_field;
10429 if (found_something == 0)
10432 vec_validate (mask, sizeof (*ip) - 1);
10434 ip = (ip4_header_t *) mask;
10436 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
10437 foreach_ip4_proto_field;
10440 ip->ip_version_and_header_length = 0;
10443 ip->ip_version_and_header_length |= 0xF0;
10446 ip->ip_version_and_header_length |= 0x0F;
10452 #define foreach_ip6_proto_field \
10455 _(payload_length) \
10460 unformat_ip6_mask (unformat_input_t * input, va_list * args)
10462 u8 **maskp = va_arg (*args, u8 **);
10464 u8 found_something = 0;
10466 u32 ip_version_traffic_class_and_flow_label;
10468 #define _(a) u8 a=0;
10469 foreach_ip6_proto_field;
10472 u8 traffic_class = 0;
10475 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10477 if (unformat (input, "version"))
10479 else if (unformat (input, "traffic-class"))
10481 else if (unformat (input, "flow-label"))
10483 else if (unformat (input, "src"))
10485 else if (unformat (input, "dst"))
10487 else if (unformat (input, "proto"))
10490 #define _(a) else if (unformat (input, #a)) a=1;
10491 foreach_ip6_proto_field
10497 #define _(a) found_something += a;
10498 foreach_ip6_proto_field;
10501 if (found_something == 0)
10504 vec_validate (mask, sizeof (*ip) - 1);
10506 ip = (ip6_header_t *) mask;
10508 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
10509 foreach_ip6_proto_field;
10512 ip_version_traffic_class_and_flow_label = 0;
10515 ip_version_traffic_class_and_flow_label |= 0xF0000000;
10518 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
10521 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
10523 ip->ip_version_traffic_class_and_flow_label =
10524 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10531 unformat_l3_mask (unformat_input_t * input, va_list * args)
10533 u8 **maskp = va_arg (*args, u8 **);
10535 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10537 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
10539 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
10548 unformat_l2_mask (unformat_input_t * input, va_list * args)
10550 u8 **maskp = va_arg (*args, u8 **);
10557 u8 ignore_tag1 = 0;
10558 u8 ignore_tag2 = 0;
10565 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10567 if (unformat (input, "src"))
10569 else if (unformat (input, "dst"))
10571 else if (unformat (input, "proto"))
10573 else if (unformat (input, "tag1"))
10575 else if (unformat (input, "tag2"))
10577 else if (unformat (input, "ignore-tag1"))
10579 else if (unformat (input, "ignore-tag2"))
10581 else if (unformat (input, "cos1"))
10583 else if (unformat (input, "cos2"))
10585 else if (unformat (input, "dot1q"))
10587 else if (unformat (input, "dot1ad"))
10592 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
10593 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10596 if (tag1 || ignore_tag1 || cos1 || dot1q)
10598 if (tag2 || ignore_tag2 || cos2 || dot1ad)
10601 vec_validate (mask, len - 1);
10604 clib_memset (mask, 0xff, 6);
10607 clib_memset (mask + 6, 0xff, 6);
10609 if (tag2 || dot1ad)
10611 /* inner vlan tag */
10620 mask[21] = mask[20] = 0xff;
10641 mask[16] = mask[17] = 0xff;
10651 mask[12] = mask[13] = 0xff;
10658 unformat_classify_mask (unformat_input_t * input, va_list * args)
10660 u8 **maskp = va_arg (*args, u8 **);
10661 u32 *skipp = va_arg (*args, u32 *);
10662 u32 *matchp = va_arg (*args, u32 *);
10670 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10672 if (unformat (input, "hex %U", unformat_hex_string, &mask))
10674 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
10676 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
10678 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
10692 if (mask || l2 || l3 || l4)
10694 if (l2 || l3 || l4)
10696 /* "With a free Ethernet header in every package" */
10698 vec_validate (l2, 13);
10702 vec_append (mask, l3);
10707 vec_append (mask, l4);
10712 /* Scan forward looking for the first significant mask octet */
10713 for (i = 0; i < vec_len (mask); i++)
10717 /* compute (skip, match) params */
10718 *skipp = i / sizeof (u32x4);
10719 vec_delete (mask, *skipp * sizeof (u32x4), 0);
10721 /* Pad mask to an even multiple of the vector size */
10722 while (vec_len (mask) % sizeof (u32x4))
10723 vec_add1 (mask, 0);
10725 match = vec_len (mask) / sizeof (u32x4);
10727 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
10729 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
10730 if (*tmp || *(tmp + 1))
10735 clib_warning ("BUG: match 0");
10737 _vec_len (mask) = match * sizeof (u32x4);
10747 #endif /* VPP_API_TEST_BUILTIN */
10749 #define foreach_l2_next \
10751 _(ethernet, ETHERNET_INPUT) \
10752 _(ip4, IP4_INPUT) \
10756 unformat_l2_next_index (unformat_input_t * input, va_list * args)
10758 u32 *miss_next_indexp = va_arg (*args, u32 *);
10759 u32 next_index = 0;
10763 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
10767 if (unformat (input, "%d", &tmp))
10776 *miss_next_indexp = next_index;
10780 #define foreach_ip_next \
10783 _(rewrite, REWRITE)
10786 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
10788 u32 *miss_next_indexp = va_arg (*args, u32 *);
10789 u32 next_index = 0;
10793 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
10797 if (unformat (input, "%d", &tmp))
10806 *miss_next_indexp = next_index;
10810 #define foreach_acl_next \
10814 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
10816 u32 *miss_next_indexp = va_arg (*args, u32 *);
10817 u32 next_index = 0;
10821 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
10825 if (unformat (input, "permit"))
10830 else if (unformat (input, "%d", &tmp))
10839 *miss_next_indexp = next_index;
10844 unformat_policer_precolor (unformat_input_t * input, va_list * args)
10846 u32 *r = va_arg (*args, u32 *);
10848 if (unformat (input, "conform-color"))
10849 *r = POLICE_CONFORM;
10850 else if (unformat (input, "exceed-color"))
10851 *r = POLICE_EXCEED;
10859 api_classify_add_del_table (vat_main_t * vam)
10861 unformat_input_t *i = vam->input;
10862 vl_api_classify_add_del_table_t *mp;
10869 u32 table_index = ~0;
10870 u32 next_table_index = ~0;
10871 u32 miss_next_index = ~0;
10872 u32 memory_size = 32 << 20;
10874 u32 current_data_flag = 0;
10875 int current_data_offset = 0;
10878 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10880 if (unformat (i, "del"))
10882 else if (unformat (i, "del-chain"))
10887 else if (unformat (i, "buckets %d", &nbuckets))
10889 else if (unformat (i, "memory_size %d", &memory_size))
10891 else if (unformat (i, "skip %d", &skip))
10893 else if (unformat (i, "match %d", &match))
10895 else if (unformat (i, "table %d", &table_index))
10897 else if (unformat (i, "mask %U", unformat_classify_mask,
10898 &mask, &skip, &match))
10900 else if (unformat (i, "next-table %d", &next_table_index))
10902 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
10905 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
10908 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
10911 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
10913 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
10919 if (is_add && mask == 0)
10921 errmsg ("Mask required");
10925 if (is_add && skip == ~0)
10927 errmsg ("skip count required");
10931 if (is_add && match == ~0)
10933 errmsg ("match count required");
10937 if (!is_add && table_index == ~0)
10939 errmsg ("table index required for delete");
10943 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
10945 mp->is_add = is_add;
10946 mp->del_chain = del_chain;
10947 mp->table_index = ntohl (table_index);
10948 mp->nbuckets = ntohl (nbuckets);
10949 mp->memory_size = ntohl (memory_size);
10950 mp->skip_n_vectors = ntohl (skip);
10951 mp->match_n_vectors = ntohl (match);
10952 mp->next_table_index = ntohl (next_table_index);
10953 mp->miss_next_index = ntohl (miss_next_index);
10954 mp->current_data_flag = ntohl (current_data_flag);
10955 mp->current_data_offset = ntohl (current_data_offset);
10956 mp->mask_len = ntohl (vec_len (mask));
10957 clib_memcpy (mp->mask, mask, vec_len (mask));
10966 #if VPP_API_TEST_BUILTIN == 0
10968 unformat_l4_match (unformat_input_t * input, va_list * args)
10970 u8 **matchp = va_arg (*args, u8 **);
10972 u8 *proto_header = 0;
10978 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10980 if (unformat (input, "src_port %d", &src_port))
10982 else if (unformat (input, "dst_port %d", &dst_port))
10988 h.src_port = clib_host_to_net_u16 (src_port);
10989 h.dst_port = clib_host_to_net_u16 (dst_port);
10990 vec_validate (proto_header, sizeof (h) - 1);
10991 memcpy (proto_header, &h, sizeof (h));
10993 *matchp = proto_header;
10999 unformat_ip4_match (unformat_input_t * input, va_list * args)
11001 u8 **matchp = va_arg (*args, u8 **);
11006 int hdr_length = 0;
11007 u32 hdr_length_val;
11008 int src = 0, dst = 0;
11009 ip4_address_t src_val, dst_val;
11016 int fragment_id = 0;
11017 u32 fragment_id_val;
11023 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11025 if (unformat (input, "version %d", &version_val))
11027 else if (unformat (input, "hdr_length %d", &hdr_length_val))
11029 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
11031 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
11033 else if (unformat (input, "proto %d", &proto_val))
11035 else if (unformat (input, "tos %d", &tos_val))
11037 else if (unformat (input, "length %d", &length_val))
11039 else if (unformat (input, "fragment_id %d", &fragment_id_val))
11041 else if (unformat (input, "ttl %d", &ttl_val))
11043 else if (unformat (input, "checksum %d", &checksum_val))
11049 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
11050 + ttl + checksum == 0)
11054 * Aligned because we use the real comparison functions
11056 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11058 ip = (ip4_header_t *) match;
11060 /* These are realistically matched in practice */
11062 ip->src_address.as_u32 = src_val.as_u32;
11065 ip->dst_address.as_u32 = dst_val.as_u32;
11068 ip->protocol = proto_val;
11071 /* These are not, but they're included for completeness */
11073 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
11076 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
11082 ip->length = clib_host_to_net_u16 (length_val);
11088 ip->checksum = clib_host_to_net_u16 (checksum_val);
11095 unformat_ip6_match (unformat_input_t * input, va_list * args)
11097 u8 **matchp = va_arg (*args, u8 **);
11102 u8 traffic_class = 0;
11103 u32 traffic_class_val = 0;
11106 int src = 0, dst = 0;
11107 ip6_address_t src_val, dst_val;
11110 int payload_length = 0;
11111 u32 payload_length_val;
11114 u32 ip_version_traffic_class_and_flow_label;
11116 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11118 if (unformat (input, "version %d", &version_val))
11120 else if (unformat (input, "traffic_class %d", &traffic_class_val))
11122 else if (unformat (input, "flow_label %d", &flow_label_val))
11124 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
11126 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
11128 else if (unformat (input, "proto %d", &proto_val))
11130 else if (unformat (input, "payload_length %d", &payload_length_val))
11131 payload_length = 1;
11132 else if (unformat (input, "hop_limit %d", &hop_limit_val))
11138 if (version + traffic_class + flow_label + src + dst + proto +
11139 payload_length + hop_limit == 0)
11143 * Aligned because we use the real comparison functions
11145 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11147 ip = (ip6_header_t *) match;
11150 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
11153 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
11156 ip->protocol = proto_val;
11158 ip_version_traffic_class_and_flow_label = 0;
11161 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
11164 ip_version_traffic_class_and_flow_label |=
11165 (traffic_class_val & 0xFF) << 20;
11168 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
11170 ip->ip_version_traffic_class_and_flow_label =
11171 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11173 if (payload_length)
11174 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
11177 ip->hop_limit = hop_limit_val;
11184 unformat_l3_match (unformat_input_t * input, va_list * args)
11186 u8 **matchp = va_arg (*args, u8 **);
11188 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11190 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
11192 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
11201 unformat_vlan_tag (unformat_input_t * input, va_list * args)
11203 u8 *tagp = va_arg (*args, u8 *);
11206 if (unformat (input, "%d", &tag))
11208 tagp[0] = (tag >> 8) & 0x0F;
11209 tagp[1] = tag & 0xFF;
11217 unformat_l2_match (unformat_input_t * input, va_list * args)
11219 u8 **matchp = va_arg (*args, u8 **);
11232 u8 ignore_tag1 = 0;
11233 u8 ignore_tag2 = 0;
11239 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11241 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
11244 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
11246 else if (unformat (input, "proto %U",
11247 unformat_ethernet_type_host_byte_order, &proto_val))
11249 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
11251 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
11253 else if (unformat (input, "ignore-tag1"))
11255 else if (unformat (input, "ignore-tag2"))
11257 else if (unformat (input, "cos1 %d", &cos1_val))
11259 else if (unformat (input, "cos2 %d", &cos2_val))
11264 if ((src + dst + proto + tag1 + tag2 +
11265 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11268 if (tag1 || ignore_tag1 || cos1)
11270 if (tag2 || ignore_tag2 || cos2)
11273 vec_validate_aligned (match, len - 1, sizeof (u32x4));
11276 clib_memcpy (match, dst_val, 6);
11279 clib_memcpy (match + 6, src_val, 6);
11283 /* inner vlan tag */
11284 match[19] = tag2_val[1];
11285 match[18] = tag2_val[0];
11287 match[18] |= (cos2_val & 0x7) << 5;
11290 match[21] = proto_val & 0xff;
11291 match[20] = proto_val >> 8;
11295 match[15] = tag1_val[1];
11296 match[14] = tag1_val[0];
11299 match[14] |= (cos1_val & 0x7) << 5;
11305 match[15] = tag1_val[1];
11306 match[14] = tag1_val[0];
11309 match[17] = proto_val & 0xff;
11310 match[16] = proto_val >> 8;
11313 match[14] |= (cos1_val & 0x7) << 5;
11319 match[18] |= (cos2_val & 0x7) << 5;
11321 match[14] |= (cos1_val & 0x7) << 5;
11324 match[13] = proto_val & 0xff;
11325 match[12] = proto_val >> 8;
11333 unformat_qos_source (unformat_input_t * input, va_list * args)
11335 int *qs = va_arg (*args, int *);
11337 if (unformat (input, "ip"))
11338 *qs = QOS_SOURCE_IP;
11339 else if (unformat (input, "mpls"))
11340 *qs = QOS_SOURCE_MPLS;
11341 else if (unformat (input, "ext"))
11342 *qs = QOS_SOURCE_EXT;
11343 else if (unformat (input, "vlan"))
11344 *qs = QOS_SOURCE_VLAN;
11353 api_unformat_classify_match (unformat_input_t * input, va_list * args)
11355 u8 **matchp = va_arg (*args, u8 **);
11356 u32 skip_n_vectors = va_arg (*args, u32);
11357 u32 match_n_vectors = va_arg (*args, u32);
11364 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11366 if (unformat (input, "hex %U", unformat_hex_string, &match))
11368 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
11370 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
11372 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11386 if (match || l2 || l3 || l4)
11388 if (l2 || l3 || l4)
11390 /* "Win a free Ethernet header in every packet" */
11392 vec_validate_aligned (l2, 13, sizeof (u32x4));
11396 vec_append_aligned (match, l3, sizeof (u32x4));
11401 vec_append_aligned (match, l4, sizeof (u32x4));
11406 /* Make sure the vector is big enough even if key is all 0's */
11407 vec_validate_aligned
11408 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11411 /* Set size, include skipped vectors */
11412 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11423 api_classify_add_del_session (vat_main_t * vam)
11425 unformat_input_t *i = vam->input;
11426 vl_api_classify_add_del_session_t *mp;
11428 u32 table_index = ~0;
11429 u32 hit_next_index = ~0;
11430 u32 opaque_index = ~0;
11433 u32 skip_n_vectors = 0;
11434 u32 match_n_vectors = 0;
11440 * Warning: you have to supply skip_n and match_n
11441 * because the API client cant simply look at the classify
11445 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11447 if (unformat (i, "del"))
11449 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
11452 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
11455 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
11458 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
11460 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
11462 else if (unformat (i, "opaque-index %d", &opaque_index))
11464 else if (unformat (i, "skip_n %d", &skip_n_vectors))
11466 else if (unformat (i, "match_n %d", &match_n_vectors))
11468 else if (unformat (i, "match %U", api_unformat_classify_match,
11469 &match, skip_n_vectors, match_n_vectors))
11471 else if (unformat (i, "advance %d", &advance))
11473 else if (unformat (i, "table-index %d", &table_index))
11475 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
11477 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
11479 else if (unformat (i, "action %d", &action))
11481 else if (unformat (i, "metadata %d", &metadata))
11487 if (table_index == ~0)
11489 errmsg ("Table index required");
11493 if (is_add && match == 0)
11495 errmsg ("Match value required");
11499 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
11501 mp->is_add = is_add;
11502 mp->table_index = ntohl (table_index);
11503 mp->hit_next_index = ntohl (hit_next_index);
11504 mp->opaque_index = ntohl (opaque_index);
11505 mp->advance = ntohl (advance);
11506 mp->action = action;
11507 mp->metadata = ntohl (metadata);
11508 mp->match_len = ntohl (vec_len (match));
11509 clib_memcpy (mp->match, match, vec_len (match));
11518 api_classify_set_interface_ip_table (vat_main_t * vam)
11520 unformat_input_t *i = vam->input;
11521 vl_api_classify_set_interface_ip_table_t *mp;
11523 int sw_if_index_set;
11524 u32 table_index = ~0;
11528 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11530 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11531 sw_if_index_set = 1;
11532 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11533 sw_if_index_set = 1;
11534 else if (unformat (i, "table %d", &table_index))
11538 clib_warning ("parse error '%U'", format_unformat_error, i);
11543 if (sw_if_index_set == 0)
11545 errmsg ("missing interface name or sw_if_index");
11550 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
11552 mp->sw_if_index = ntohl (sw_if_index);
11553 mp->table_index = ntohl (table_index);
11554 mp->is_ipv6 = is_ipv6;
11562 api_classify_set_interface_l2_tables (vat_main_t * vam)
11564 unformat_input_t *i = vam->input;
11565 vl_api_classify_set_interface_l2_tables_t *mp;
11567 int sw_if_index_set;
11568 u32 ip4_table_index = ~0;
11569 u32 ip6_table_index = ~0;
11570 u32 other_table_index = ~0;
11574 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11576 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11577 sw_if_index_set = 1;
11578 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11579 sw_if_index_set = 1;
11580 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11582 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11584 else if (unformat (i, "other-table %d", &other_table_index))
11586 else if (unformat (i, "is-input %d", &is_input))
11590 clib_warning ("parse error '%U'", format_unformat_error, i);
11595 if (sw_if_index_set == 0)
11597 errmsg ("missing interface name or sw_if_index");
11602 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
11604 mp->sw_if_index = ntohl (sw_if_index);
11605 mp->ip4_table_index = ntohl (ip4_table_index);
11606 mp->ip6_table_index = ntohl (ip6_table_index);
11607 mp->other_table_index = ntohl (other_table_index);
11608 mp->is_input = (u8) is_input;
11616 api_set_ipfix_exporter (vat_main_t * vam)
11618 unformat_input_t *i = vam->input;
11619 vl_api_set_ipfix_exporter_t *mp;
11620 ip4_address_t collector_address;
11621 u8 collector_address_set = 0;
11622 u32 collector_port = ~0;
11623 ip4_address_t src_address;
11624 u8 src_address_set = 0;
11627 u32 template_interval = ~0;
11628 u8 udp_checksum = 0;
11631 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11633 if (unformat (i, "collector_address %U", unformat_ip4_address,
11634 &collector_address))
11635 collector_address_set = 1;
11636 else if (unformat (i, "collector_port %d", &collector_port))
11638 else if (unformat (i, "src_address %U", unformat_ip4_address,
11640 src_address_set = 1;
11641 else if (unformat (i, "vrf_id %d", &vrf_id))
11643 else if (unformat (i, "path_mtu %d", &path_mtu))
11645 else if (unformat (i, "template_interval %d", &template_interval))
11647 else if (unformat (i, "udp_checksum"))
11653 if (collector_address_set == 0)
11655 errmsg ("collector_address required");
11659 if (src_address_set == 0)
11661 errmsg ("src_address required");
11665 M (SET_IPFIX_EXPORTER, mp);
11667 memcpy (mp->collector_address, collector_address.data,
11668 sizeof (collector_address.data));
11669 mp->collector_port = htons ((u16) collector_port);
11670 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
11671 mp->vrf_id = htonl (vrf_id);
11672 mp->path_mtu = htonl (path_mtu);
11673 mp->template_interval = htonl (template_interval);
11674 mp->udp_checksum = udp_checksum;
11682 api_set_ipfix_classify_stream (vat_main_t * vam)
11684 unformat_input_t *i = vam->input;
11685 vl_api_set_ipfix_classify_stream_t *mp;
11687 u32 src_port = UDP_DST_PORT_ipfix;
11690 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11692 if (unformat (i, "domain %d", &domain_id))
11694 else if (unformat (i, "src_port %d", &src_port))
11698 errmsg ("unknown input `%U'", format_unformat_error, i);
11703 M (SET_IPFIX_CLASSIFY_STREAM, mp);
11705 mp->domain_id = htonl (domain_id);
11706 mp->src_port = htons ((u16) src_port);
11714 api_ipfix_classify_table_add_del (vat_main_t * vam)
11716 unformat_input_t *i = vam->input;
11717 vl_api_ipfix_classify_table_add_del_t *mp;
11719 u32 classify_table_index = ~0;
11721 u8 transport_protocol = 255;
11724 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11726 if (unformat (i, "add"))
11728 else if (unformat (i, "del"))
11730 else if (unformat (i, "table %d", &classify_table_index))
11732 else if (unformat (i, "ip4"))
11734 else if (unformat (i, "ip6"))
11736 else if (unformat (i, "tcp"))
11737 transport_protocol = 6;
11738 else if (unformat (i, "udp"))
11739 transport_protocol = 17;
11742 errmsg ("unknown input `%U'", format_unformat_error, i);
11749 errmsg ("expecting: add|del");
11752 if (classify_table_index == ~0)
11754 errmsg ("classifier table not specified");
11757 if (ip_version == 0)
11759 errmsg ("IP version not specified");
11763 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
11765 mp->is_add = is_add;
11766 mp->table_id = htonl (classify_table_index);
11767 mp->ip_version = ip_version;
11768 mp->transport_protocol = transport_protocol;
11776 api_get_node_index (vat_main_t * vam)
11778 unformat_input_t *i = vam->input;
11779 vl_api_get_node_index_t *mp;
11783 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11785 if (unformat (i, "node %s", &name))
11792 errmsg ("node name required");
11795 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11797 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11801 M (GET_NODE_INDEX, mp);
11802 clib_memcpy (mp->node_name, name, vec_len (name));
11811 api_get_next_index (vat_main_t * vam)
11813 unformat_input_t *i = vam->input;
11814 vl_api_get_next_index_t *mp;
11815 u8 *node_name = 0, *next_node_name = 0;
11818 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11820 if (unformat (i, "node-name %s", &node_name))
11822 else if (unformat (i, "next-node-name %s", &next_node_name))
11826 if (node_name == 0)
11828 errmsg ("node name required");
11831 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
11833 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11837 if (next_node_name == 0)
11839 errmsg ("next node name required");
11842 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
11844 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
11848 M (GET_NEXT_INDEX, mp);
11849 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
11850 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
11851 vec_free (node_name);
11852 vec_free (next_node_name);
11860 api_add_node_next (vat_main_t * vam)
11862 unformat_input_t *i = vam->input;
11863 vl_api_add_node_next_t *mp;
11868 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11870 if (unformat (i, "node %s", &name))
11872 else if (unformat (i, "next %s", &next))
11879 errmsg ("node name required");
11882 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11884 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11889 errmsg ("next node required");
11892 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
11894 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
11898 M (ADD_NODE_NEXT, mp);
11899 clib_memcpy (mp->node_name, name, vec_len (name));
11900 clib_memcpy (mp->next_name, next, vec_len (next));
11910 api_l2tpv3_create_tunnel (vat_main_t * vam)
11912 unformat_input_t *i = vam->input;
11913 ip6_address_t client_address, our_address;
11914 int client_address_set = 0;
11915 int our_address_set = 0;
11916 u32 local_session_id = 0;
11917 u32 remote_session_id = 0;
11918 u64 local_cookie = 0;
11919 u64 remote_cookie = 0;
11920 u8 l2_sublayer_present = 0;
11921 vl_api_l2tpv3_create_tunnel_t *mp;
11924 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11926 if (unformat (i, "client_address %U", unformat_ip6_address,
11928 client_address_set = 1;
11929 else if (unformat (i, "our_address %U", unformat_ip6_address,
11931 our_address_set = 1;
11932 else if (unformat (i, "local_session_id %d", &local_session_id))
11934 else if (unformat (i, "remote_session_id %d", &remote_session_id))
11936 else if (unformat (i, "local_cookie %lld", &local_cookie))
11938 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
11940 else if (unformat (i, "l2-sublayer-present"))
11941 l2_sublayer_present = 1;
11946 if (client_address_set == 0)
11948 errmsg ("client_address required");
11952 if (our_address_set == 0)
11954 errmsg ("our_address required");
11958 M (L2TPV3_CREATE_TUNNEL, mp);
11960 clib_memcpy (mp->client_address, client_address.as_u8,
11961 sizeof (mp->client_address));
11963 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
11965 mp->local_session_id = ntohl (local_session_id);
11966 mp->remote_session_id = ntohl (remote_session_id);
11967 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
11968 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
11969 mp->l2_sublayer_present = l2_sublayer_present;
11978 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
11980 unformat_input_t *i = vam->input;
11982 u8 sw_if_index_set = 0;
11983 u64 new_local_cookie = 0;
11984 u64 new_remote_cookie = 0;
11985 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
11988 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11990 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11991 sw_if_index_set = 1;
11992 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11993 sw_if_index_set = 1;
11994 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
11996 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
12002 if (sw_if_index_set == 0)
12004 errmsg ("missing interface name or sw_if_index");
12008 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
12010 mp->sw_if_index = ntohl (sw_if_index);
12011 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
12012 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
12020 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
12022 unformat_input_t *i = vam->input;
12023 vl_api_l2tpv3_interface_enable_disable_t *mp;
12025 u8 sw_if_index_set = 0;
12026 u8 enable_disable = 1;
12029 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12031 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12032 sw_if_index_set = 1;
12033 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12034 sw_if_index_set = 1;
12035 else if (unformat (i, "enable"))
12036 enable_disable = 1;
12037 else if (unformat (i, "disable"))
12038 enable_disable = 0;
12043 if (sw_if_index_set == 0)
12045 errmsg ("missing interface name or sw_if_index");
12049 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
12051 mp->sw_if_index = ntohl (sw_if_index);
12052 mp->enable_disable = enable_disable;
12060 api_l2tpv3_set_lookup_key (vat_main_t * vam)
12062 unformat_input_t *i = vam->input;
12063 vl_api_l2tpv3_set_lookup_key_t *mp;
12067 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12069 if (unformat (i, "lookup_v6_src"))
12070 key = L2T_LOOKUP_SRC_ADDRESS;
12071 else if (unformat (i, "lookup_v6_dst"))
12072 key = L2T_LOOKUP_DST_ADDRESS;
12073 else if (unformat (i, "lookup_session_id"))
12074 key = L2T_LOOKUP_SESSION_ID;
12079 if (key == (u8) ~ 0)
12081 errmsg ("l2tp session lookup key unset");
12085 M (L2TPV3_SET_LOOKUP_KEY, mp);
12094 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
12095 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12097 vat_main_t *vam = &vat_main;
12099 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
12100 format_ip6_address, mp->our_address,
12101 format_ip6_address, mp->client_address,
12102 clib_net_to_host_u32 (mp->sw_if_index));
12105 " local cookies %016llx %016llx remote cookie %016llx",
12106 clib_net_to_host_u64 (mp->local_cookie[0]),
12107 clib_net_to_host_u64 (mp->local_cookie[1]),
12108 clib_net_to_host_u64 (mp->remote_cookie));
12110 print (vam->ofp, " local session-id %d remote session-id %d",
12111 clib_net_to_host_u32 (mp->local_session_id),
12112 clib_net_to_host_u32 (mp->remote_session_id));
12114 print (vam->ofp, " l2 specific sublayer %s\n",
12115 mp->l2_sublayer_present ? "preset" : "absent");
12119 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
12120 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12122 vat_main_t *vam = &vat_main;
12123 vat_json_node_t *node = NULL;
12124 struct in6_addr addr;
12126 if (VAT_JSON_ARRAY != vam->json_tree.type)
12128 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12129 vat_json_init_array (&vam->json_tree);
12131 node = vat_json_array_add (&vam->json_tree);
12133 vat_json_init_object (node);
12135 clib_memcpy (&addr, mp->our_address, sizeof (addr));
12136 vat_json_object_add_ip6 (node, "our_address", addr);
12137 clib_memcpy (&addr, mp->client_address, sizeof (addr));
12138 vat_json_object_add_ip6 (node, "client_address", addr);
12140 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
12141 vat_json_init_array (lc);
12142 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
12143 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
12144 vat_json_object_add_uint (node, "remote_cookie",
12145 clib_net_to_host_u64 (mp->remote_cookie));
12147 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
12148 vat_json_object_add_uint (node, "local_session_id",
12149 clib_net_to_host_u32 (mp->local_session_id));
12150 vat_json_object_add_uint (node, "remote_session_id",
12151 clib_net_to_host_u32 (mp->remote_session_id));
12152 vat_json_object_add_string_copy (node, "l2_sublayer",
12153 mp->l2_sublayer_present ? (u8 *) "present"
12154 : (u8 *) "absent");
12158 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
12160 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
12161 vl_api_control_ping_t *mp_ping;
12164 /* Get list of l2tpv3-tunnel interfaces */
12165 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
12168 /* Use a control ping for synchronization */
12169 MPING (CONTROL_PING, mp_ping);
12177 static void vl_api_sw_interface_tap_v2_details_t_handler
12178 (vl_api_sw_interface_tap_v2_details_t * mp)
12180 vat_main_t *vam = &vat_main;
12182 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
12183 mp->host_ip4_prefix_len);
12184 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
12185 mp->host_ip6_prefix_len);
12188 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s 0x%-08x",
12189 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
12190 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12191 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
12192 mp->host_bridge, ip4, ip6, ntohl (mp->tap_flags));
12198 static void vl_api_sw_interface_tap_v2_details_t_handler_json
12199 (vl_api_sw_interface_tap_v2_details_t * mp)
12201 vat_main_t *vam = &vat_main;
12202 vat_json_node_t *node = NULL;
12204 if (VAT_JSON_ARRAY != vam->json_tree.type)
12206 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12207 vat_json_init_array (&vam->json_tree);
12209 node = vat_json_array_add (&vam->json_tree);
12211 vat_json_init_object (node);
12212 vat_json_object_add_uint (node, "id", ntohl (mp->id));
12213 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12214 vat_json_object_add_uint (node, "tap_flags", ntohl (mp->tap_flags));
12215 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12216 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12217 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12218 vat_json_object_add_string_copy (node, "host_mac_addr",
12219 format (0, "%U", format_ethernet_address,
12220 &mp->host_mac_addr));
12221 vat_json_object_add_string_copy (node, "host_namespace",
12222 mp->host_namespace);
12223 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
12224 vat_json_object_add_string_copy (node, "host_ip4_addr",
12225 format (0, "%U/%d", format_ip4_address,
12227 mp->host_ip4_prefix_len));
12228 vat_json_object_add_string_copy (node, "host_ip6_addr",
12229 format (0, "%U/%d", format_ip6_address,
12231 mp->host_ip6_prefix_len));
12236 api_sw_interface_tap_v2_dump (vat_main_t * vam)
12238 vl_api_sw_interface_tap_v2_dump_t *mp;
12239 vl_api_control_ping_t *mp_ping;
12243 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
12244 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
12245 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
12248 /* Get list of tap interfaces */
12249 M (SW_INTERFACE_TAP_V2_DUMP, mp);
12252 /* Use a control ping for synchronization */
12253 MPING (CONTROL_PING, mp_ping);
12260 static void vl_api_sw_interface_virtio_pci_details_t_handler
12261 (vl_api_sw_interface_virtio_pci_details_t * mp)
12263 vat_main_t *vam = &vat_main;
12277 addr.as_u32 = ntohl (mp->pci_addr);
12278 u8 *pci_addr = format (0, "%04x:%02x:%02x.%x", addr.domain, addr.bus,
12279 addr.slot, addr.function);
12282 "\n%-12s %-12d %-12d %-12d %-17U 0x%-08llx",
12283 pci_addr, ntohl (mp->sw_if_index),
12284 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12285 format_ethernet_address, mp->mac_addr,
12286 clib_net_to_host_u64 (mp->features));
12287 vec_free (pci_addr);
12290 static void vl_api_sw_interface_virtio_pci_details_t_handler_json
12291 (vl_api_sw_interface_virtio_pci_details_t * mp)
12293 vat_main_t *vam = &vat_main;
12294 vat_json_node_t *node = NULL;
12296 if (VAT_JSON_ARRAY != vam->json_tree.type)
12298 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12299 vat_json_init_array (&vam->json_tree);
12301 node = vat_json_array_add (&vam->json_tree);
12303 vat_json_init_object (node);
12304 vat_json_object_add_uint (node, "pci-addr", ntohl (mp->pci_addr));
12305 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12306 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12307 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12308 vat_json_object_add_uint (node, "features",
12309 clib_net_to_host_u64 (mp->features));
12310 vat_json_object_add_string_copy (node, "mac_addr",
12311 format (0, "%U", format_ethernet_address,
12316 api_sw_interface_virtio_pci_dump (vat_main_t * vam)
12318 vl_api_sw_interface_virtio_pci_dump_t *mp;
12319 vl_api_control_ping_t *mp_ping;
12323 "\n%-12s %-12s %-12s %-12s %-17s %-08s",
12324 "pci_addr", "sw_if_index", "rx_ring_sz", "tx_ring_sz",
12325 "mac_addr", "features");
12327 /* Get list of tap interfaces */
12328 M (SW_INTERFACE_VIRTIO_PCI_DUMP, mp);
12331 /* Use a control ping for synchronization */
12332 MPING (CONTROL_PING, mp_ping);
12340 api_vxlan_offload_rx (vat_main_t * vam)
12342 unformat_input_t *line_input = vam->input;
12343 vl_api_vxlan_offload_rx_t *mp;
12344 u32 hw_if_index = ~0, rx_if_index = ~0;
12348 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12350 if (unformat (line_input, "del"))
12352 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
12355 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
12357 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
12360 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
12364 errmsg ("parse error '%U'", format_unformat_error, line_input);
12369 if (hw_if_index == ~0)
12371 errmsg ("no hw interface");
12375 if (rx_if_index == ~0)
12377 errmsg ("no rx tunnel");
12381 M (VXLAN_OFFLOAD_RX, mp);
12383 mp->hw_if_index = ntohl (hw_if_index);
12384 mp->sw_if_index = ntohl (rx_if_index);
12385 mp->enable = is_add;
12392 static uword unformat_vxlan_decap_next
12393 (unformat_input_t * input, va_list * args)
12395 u32 *result = va_arg (*args, u32 *);
12398 if (unformat (input, "l2"))
12399 *result = VXLAN_INPUT_NEXT_L2_INPUT;
12400 else if (unformat (input, "%d", &tmp))
12408 api_vxlan_add_del_tunnel (vat_main_t * vam)
12410 unformat_input_t *line_input = vam->input;
12411 vl_api_vxlan_add_del_tunnel_t *mp;
12412 ip46_address_t src, dst;
12414 u8 ipv4_set = 0, ipv6_set = 0;
12419 u32 mcast_sw_if_index = ~0;
12420 u32 encap_vrf_id = 0;
12421 u32 decap_next_index = ~0;
12425 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12426 clib_memset (&src, 0, sizeof src);
12427 clib_memset (&dst, 0, sizeof dst);
12429 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12431 if (unformat (line_input, "del"))
12433 else if (unformat (line_input, "instance %d", &instance))
12436 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12442 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12448 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12454 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12459 else if (unformat (line_input, "group %U %U",
12460 unformat_ip4_address, &dst.ip4,
12461 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12463 grp_set = dst_set = 1;
12466 else if (unformat (line_input, "group %U",
12467 unformat_ip4_address, &dst.ip4))
12469 grp_set = dst_set = 1;
12472 else if (unformat (line_input, "group %U %U",
12473 unformat_ip6_address, &dst.ip6,
12474 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12476 grp_set = dst_set = 1;
12479 else if (unformat (line_input, "group %U",
12480 unformat_ip6_address, &dst.ip6))
12482 grp_set = dst_set = 1;
12486 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12488 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12490 else if (unformat (line_input, "decap-next %U",
12491 unformat_vxlan_decap_next, &decap_next_index))
12493 else if (unformat (line_input, "vni %d", &vni))
12497 errmsg ("parse error '%U'", format_unformat_error, line_input);
12504 errmsg ("tunnel src address not specified");
12509 errmsg ("tunnel dst address not specified");
12513 if (grp_set && !ip46_address_is_multicast (&dst))
12515 errmsg ("tunnel group address not multicast");
12518 if (grp_set && mcast_sw_if_index == ~0)
12520 errmsg ("tunnel nonexistent multicast device");
12523 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12525 errmsg ("tunnel dst address must be unicast");
12530 if (ipv4_set && ipv6_set)
12532 errmsg ("both IPv4 and IPv6 addresses specified");
12536 if ((vni == 0) || (vni >> 24))
12538 errmsg ("vni not specified or out of range");
12542 M (VXLAN_ADD_DEL_TUNNEL, mp);
12546 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
12547 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
12551 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
12552 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
12555 mp->instance = htonl (instance);
12556 mp->encap_vrf_id = ntohl (encap_vrf_id);
12557 mp->decap_next_index = ntohl (decap_next_index);
12558 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12559 mp->vni = ntohl (vni);
12560 mp->is_add = is_add;
12561 mp->is_ipv6 = ipv6_set;
12568 static void vl_api_vxlan_tunnel_details_t_handler
12569 (vl_api_vxlan_tunnel_details_t * mp)
12571 vat_main_t *vam = &vat_main;
12572 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12573 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12575 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
12576 ntohl (mp->sw_if_index),
12577 ntohl (mp->instance),
12578 format_ip46_address, &src, IP46_TYPE_ANY,
12579 format_ip46_address, &dst, IP46_TYPE_ANY,
12580 ntohl (mp->encap_vrf_id),
12581 ntohl (mp->decap_next_index), ntohl (mp->vni),
12582 ntohl (mp->mcast_sw_if_index));
12585 static void vl_api_vxlan_tunnel_details_t_handler_json
12586 (vl_api_vxlan_tunnel_details_t * mp)
12588 vat_main_t *vam = &vat_main;
12589 vat_json_node_t *node = NULL;
12591 if (VAT_JSON_ARRAY != vam->json_tree.type)
12593 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12594 vat_json_init_array (&vam->json_tree);
12596 node = vat_json_array_add (&vam->json_tree);
12598 vat_json_init_object (node);
12599 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12601 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
12605 struct in6_addr ip6;
12607 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12608 vat_json_object_add_ip6 (node, "src_address", ip6);
12609 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12610 vat_json_object_add_ip6 (node, "dst_address", ip6);
12614 struct in_addr ip4;
12616 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12617 vat_json_object_add_ip4 (node, "src_address", ip4);
12618 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12619 vat_json_object_add_ip4 (node, "dst_address", ip4);
12621 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12622 vat_json_object_add_uint (node, "decap_next_index",
12623 ntohl (mp->decap_next_index));
12624 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12625 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12626 vat_json_object_add_uint (node, "mcast_sw_if_index",
12627 ntohl (mp->mcast_sw_if_index));
12631 api_vxlan_tunnel_dump (vat_main_t * vam)
12633 unformat_input_t *i = vam->input;
12634 vl_api_vxlan_tunnel_dump_t *mp;
12635 vl_api_control_ping_t *mp_ping;
12637 u8 sw_if_index_set = 0;
12640 /* Parse args required to build the message */
12641 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12643 if (unformat (i, "sw_if_index %d", &sw_if_index))
12644 sw_if_index_set = 1;
12649 if (sw_if_index_set == 0)
12654 if (!vam->json_output)
12656 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
12657 "sw_if_index", "instance", "src_address", "dst_address",
12658 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12661 /* Get list of vxlan-tunnel interfaces */
12662 M (VXLAN_TUNNEL_DUMP, mp);
12664 mp->sw_if_index = htonl (sw_if_index);
12668 /* Use a control ping for synchronization */
12669 MPING (CONTROL_PING, mp_ping);
12676 static uword unformat_geneve_decap_next
12677 (unformat_input_t * input, va_list * args)
12679 u32 *result = va_arg (*args, u32 *);
12682 if (unformat (input, "l2"))
12683 *result = GENEVE_INPUT_NEXT_L2_INPUT;
12684 else if (unformat (input, "%d", &tmp))
12692 api_geneve_add_del_tunnel (vat_main_t * vam)
12694 unformat_input_t *line_input = vam->input;
12695 vl_api_geneve_add_del_tunnel_t *mp;
12696 ip46_address_t src, dst;
12698 u8 ipv4_set = 0, ipv6_set = 0;
12702 u32 mcast_sw_if_index = ~0;
12703 u32 encap_vrf_id = 0;
12704 u32 decap_next_index = ~0;
12708 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12709 clib_memset (&src, 0, sizeof src);
12710 clib_memset (&dst, 0, sizeof dst);
12712 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12714 if (unformat (line_input, "del"))
12717 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12723 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12729 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12735 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12740 else if (unformat (line_input, "group %U %U",
12741 unformat_ip4_address, &dst.ip4,
12742 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12744 grp_set = dst_set = 1;
12747 else if (unformat (line_input, "group %U",
12748 unformat_ip4_address, &dst.ip4))
12750 grp_set = dst_set = 1;
12753 else if (unformat (line_input, "group %U %U",
12754 unformat_ip6_address, &dst.ip6,
12755 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12757 grp_set = dst_set = 1;
12760 else if (unformat (line_input, "group %U",
12761 unformat_ip6_address, &dst.ip6))
12763 grp_set = dst_set = 1;
12767 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12769 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12771 else if (unformat (line_input, "decap-next %U",
12772 unformat_geneve_decap_next, &decap_next_index))
12774 else if (unformat (line_input, "vni %d", &vni))
12778 errmsg ("parse error '%U'", format_unformat_error, line_input);
12785 errmsg ("tunnel src address not specified");
12790 errmsg ("tunnel dst address not specified");
12794 if (grp_set && !ip46_address_is_multicast (&dst))
12796 errmsg ("tunnel group address not multicast");
12799 if (grp_set && mcast_sw_if_index == ~0)
12801 errmsg ("tunnel nonexistent multicast device");
12804 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12806 errmsg ("tunnel dst address must be unicast");
12811 if (ipv4_set && ipv6_set)
12813 errmsg ("both IPv4 and IPv6 addresses specified");
12817 if ((vni == 0) || (vni >> 24))
12819 errmsg ("vni not specified or out of range");
12823 M (GENEVE_ADD_DEL_TUNNEL, mp);
12827 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
12828 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
12832 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
12833 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
12835 mp->encap_vrf_id = ntohl (encap_vrf_id);
12836 mp->decap_next_index = ntohl (decap_next_index);
12837 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12838 mp->vni = ntohl (vni);
12839 mp->is_add = is_add;
12840 mp->is_ipv6 = ipv6_set;
12847 static void vl_api_geneve_tunnel_details_t_handler
12848 (vl_api_geneve_tunnel_details_t * mp)
12850 vat_main_t *vam = &vat_main;
12851 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12852 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12854 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12855 ntohl (mp->sw_if_index),
12856 format_ip46_address, &src, IP46_TYPE_ANY,
12857 format_ip46_address, &dst, IP46_TYPE_ANY,
12858 ntohl (mp->encap_vrf_id),
12859 ntohl (mp->decap_next_index), ntohl (mp->vni),
12860 ntohl (mp->mcast_sw_if_index));
12863 static void vl_api_geneve_tunnel_details_t_handler_json
12864 (vl_api_geneve_tunnel_details_t * mp)
12866 vat_main_t *vam = &vat_main;
12867 vat_json_node_t *node = NULL;
12869 if (VAT_JSON_ARRAY != vam->json_tree.type)
12871 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12872 vat_json_init_array (&vam->json_tree);
12874 node = vat_json_array_add (&vam->json_tree);
12876 vat_json_init_object (node);
12877 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12880 struct in6_addr ip6;
12882 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12883 vat_json_object_add_ip6 (node, "src_address", ip6);
12884 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12885 vat_json_object_add_ip6 (node, "dst_address", ip6);
12889 struct in_addr ip4;
12891 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12892 vat_json_object_add_ip4 (node, "src_address", ip4);
12893 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12894 vat_json_object_add_ip4 (node, "dst_address", ip4);
12896 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12897 vat_json_object_add_uint (node, "decap_next_index",
12898 ntohl (mp->decap_next_index));
12899 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12900 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12901 vat_json_object_add_uint (node, "mcast_sw_if_index",
12902 ntohl (mp->mcast_sw_if_index));
12906 api_geneve_tunnel_dump (vat_main_t * vam)
12908 unformat_input_t *i = vam->input;
12909 vl_api_geneve_tunnel_dump_t *mp;
12910 vl_api_control_ping_t *mp_ping;
12912 u8 sw_if_index_set = 0;
12915 /* Parse args required to build the message */
12916 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12918 if (unformat (i, "sw_if_index %d", &sw_if_index))
12919 sw_if_index_set = 1;
12924 if (sw_if_index_set == 0)
12929 if (!vam->json_output)
12931 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12932 "sw_if_index", "local_address", "remote_address",
12933 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12936 /* Get list of geneve-tunnel interfaces */
12937 M (GENEVE_TUNNEL_DUMP, mp);
12939 mp->sw_if_index = htonl (sw_if_index);
12943 /* Use a control ping for synchronization */
12944 M (CONTROL_PING, mp_ping);
12952 api_gre_tunnel_add_del (vat_main_t * vam)
12954 unformat_input_t *line_input = vam->input;
12955 vl_api_address_t src = { }, dst =
12958 vl_api_gre_tunnel_add_del_t *mp;
12959 vl_api_gre_tunnel_type_t t_type;
12963 u32 outer_fib_id = 0;
12964 u32 session_id = 0;
12968 t_type = GRE_API_TUNNEL_TYPE_L3;
12970 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12972 if (unformat (line_input, "del"))
12974 else if (unformat (line_input, "instance %d", &instance))
12976 else if (unformat (line_input, "src %U", unformat_vl_api_address, &src))
12980 else if (unformat (line_input, "dst %U", unformat_vl_api_address, &dst))
12984 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
12986 else if (unformat (line_input, "teb"))
12987 t_type = GRE_API_TUNNEL_TYPE_TEB;
12988 else if (unformat (line_input, "erspan %d", &session_id))
12989 t_type = GRE_API_TUNNEL_TYPE_ERSPAN;
12992 errmsg ("parse error '%U'", format_unformat_error, line_input);
12999 errmsg ("tunnel src address not specified");
13004 errmsg ("tunnel dst address not specified");
13008 M (GRE_TUNNEL_ADD_DEL, mp);
13010 clib_memcpy (&mp->tunnel.src, &src, sizeof (mp->tunnel.src));
13011 clib_memcpy (&mp->tunnel.dst, &dst, sizeof (mp->tunnel.dst));
13013 mp->tunnel.instance = htonl (instance);
13014 mp->tunnel.outer_fib_id = htonl (outer_fib_id);
13015 mp->is_add = is_add;
13016 mp->tunnel.session_id = htons ((u16) session_id);
13017 mp->tunnel.type = htonl (t_type);
13024 static void vl_api_gre_tunnel_details_t_handler
13025 (vl_api_gre_tunnel_details_t * mp)
13027 vat_main_t *vam = &vat_main;
13029 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
13030 ntohl (mp->tunnel.sw_if_index),
13031 ntohl (mp->tunnel.instance),
13032 format_vl_api_address, &mp->tunnel.src,
13033 format_vl_api_address, &mp->tunnel.dst,
13034 mp->tunnel.type, ntohl (mp->tunnel.outer_fib_id),
13035 ntohl (mp->tunnel.session_id));
13038 static void vl_api_gre_tunnel_details_t_handler_json
13039 (vl_api_gre_tunnel_details_t * mp)
13041 vat_main_t *vam = &vat_main;
13042 vat_json_node_t *node = NULL;
13044 if (VAT_JSON_ARRAY != vam->json_tree.type)
13046 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13047 vat_json_init_array (&vam->json_tree);
13049 node = vat_json_array_add (&vam->json_tree);
13051 vat_json_init_object (node);
13052 vat_json_object_add_uint (node, "sw_if_index",
13053 ntohl (mp->tunnel.sw_if_index));
13054 vat_json_object_add_uint (node, "instance", ntohl (mp->tunnel.instance));
13056 vat_json_object_add_address (node, "src", &mp->tunnel.src);
13057 vat_json_object_add_address (node, "dst", &mp->tunnel.dst);
13058 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel.type);
13059 vat_json_object_add_uint (node, "outer_fib_id",
13060 ntohl (mp->tunnel.outer_fib_id));
13061 vat_json_object_add_uint (node, "session_id", mp->tunnel.session_id);
13065 api_gre_tunnel_dump (vat_main_t * vam)
13067 unformat_input_t *i = vam->input;
13068 vl_api_gre_tunnel_dump_t *mp;
13069 vl_api_control_ping_t *mp_ping;
13071 u8 sw_if_index_set = 0;
13074 /* Parse args required to build the message */
13075 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13077 if (unformat (i, "sw_if_index %d", &sw_if_index))
13078 sw_if_index_set = 1;
13083 if (sw_if_index_set == 0)
13088 if (!vam->json_output)
13090 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
13091 "sw_if_index", "instance", "src_address", "dst_address",
13092 "tunnel_type", "outer_fib_id", "session_id");
13095 /* Get list of gre-tunnel interfaces */
13096 M (GRE_TUNNEL_DUMP, mp);
13098 mp->sw_if_index = htonl (sw_if_index);
13102 /* Use a control ping for synchronization */
13103 MPING (CONTROL_PING, mp_ping);
13111 api_l2_fib_clear_table (vat_main_t * vam)
13113 // unformat_input_t * i = vam->input;
13114 vl_api_l2_fib_clear_table_t *mp;
13117 M (L2_FIB_CLEAR_TABLE, mp);
13125 api_l2_interface_efp_filter (vat_main_t * vam)
13127 unformat_input_t *i = vam->input;
13128 vl_api_l2_interface_efp_filter_t *mp;
13131 u8 sw_if_index_set = 0;
13134 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13136 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13137 sw_if_index_set = 1;
13138 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13139 sw_if_index_set = 1;
13140 else if (unformat (i, "enable"))
13142 else if (unformat (i, "disable"))
13146 clib_warning ("parse error '%U'", format_unformat_error, i);
13151 if (sw_if_index_set == 0)
13153 errmsg ("missing sw_if_index");
13157 M (L2_INTERFACE_EFP_FILTER, mp);
13159 mp->sw_if_index = ntohl (sw_if_index);
13160 mp->enable_disable = enable;
13167 #define foreach_vtr_op \
13168 _("disable", L2_VTR_DISABLED) \
13169 _("push-1", L2_VTR_PUSH_1) \
13170 _("push-2", L2_VTR_PUSH_2) \
13171 _("pop-1", L2_VTR_POP_1) \
13172 _("pop-2", L2_VTR_POP_2) \
13173 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
13174 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
13175 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
13176 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
13179 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
13181 unformat_input_t *i = vam->input;
13182 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
13184 u8 sw_if_index_set = 0;
13187 u32 push_dot1q = 1;
13192 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13194 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13195 sw_if_index_set = 1;
13196 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13197 sw_if_index_set = 1;
13198 else if (unformat (i, "vtr_op %d", &vtr_op))
13200 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
13203 else if (unformat (i, "push_dot1q %d", &push_dot1q))
13205 else if (unformat (i, "tag1 %d", &tag1))
13207 else if (unformat (i, "tag2 %d", &tag2))
13211 clib_warning ("parse error '%U'", format_unformat_error, i);
13216 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
13218 errmsg ("missing vtr operation or sw_if_index");
13222 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
13223 mp->sw_if_index = ntohl (sw_if_index);
13224 mp->vtr_op = ntohl (vtr_op);
13225 mp->push_dot1q = ntohl (push_dot1q);
13226 mp->tag1 = ntohl (tag1);
13227 mp->tag2 = ntohl (tag2);
13235 api_create_vhost_user_if (vat_main_t * vam)
13237 unformat_input_t *i = vam->input;
13238 vl_api_create_vhost_user_if_t *mp;
13241 u8 file_name_set = 0;
13242 u32 custom_dev_instance = ~0;
13244 u8 use_custom_mac = 0;
13245 u8 disable_mrg_rxbuf = 0;
13246 u8 disable_indirect_desc = 0;
13251 /* Shut up coverity */
13252 clib_memset (hwaddr, 0, sizeof (hwaddr));
13254 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13256 if (unformat (i, "socket %s", &file_name))
13260 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13262 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
13263 use_custom_mac = 1;
13264 else if (unformat (i, "server"))
13266 else if (unformat (i, "disable_mrg_rxbuf"))
13267 disable_mrg_rxbuf = 1;
13268 else if (unformat (i, "disable_indirect_desc"))
13269 disable_indirect_desc = 1;
13270 else if (unformat (i, "gso"))
13272 else if (unformat (i, "tag %s", &tag))
13278 if (file_name_set == 0)
13280 errmsg ("missing socket file name");
13284 if (vec_len (file_name) > 255)
13286 errmsg ("socket file name too long");
13289 vec_add1 (file_name, 0);
13291 M (CREATE_VHOST_USER_IF, mp);
13293 mp->is_server = is_server;
13294 mp->disable_mrg_rxbuf = disable_mrg_rxbuf;
13295 mp->disable_indirect_desc = disable_indirect_desc;
13296 mp->enable_gso = enable_gso;
13297 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13298 vec_free (file_name);
13299 if (custom_dev_instance != ~0)
13302 mp->custom_dev_instance = ntohl (custom_dev_instance);
13305 mp->use_custom_mac = use_custom_mac;
13306 clib_memcpy (mp->mac_address, hwaddr, 6);
13308 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
13317 api_modify_vhost_user_if (vat_main_t * vam)
13319 unformat_input_t *i = vam->input;
13320 vl_api_modify_vhost_user_if_t *mp;
13323 u8 file_name_set = 0;
13324 u32 custom_dev_instance = ~0;
13325 u8 sw_if_index_set = 0;
13326 u32 sw_if_index = (u32) ~ 0;
13330 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13332 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13333 sw_if_index_set = 1;
13334 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13335 sw_if_index_set = 1;
13336 else if (unformat (i, "socket %s", &file_name))
13340 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13342 else if (unformat (i, "server"))
13344 else if (unformat (i, "gso"))
13350 if (sw_if_index_set == 0)
13352 errmsg ("missing sw_if_index or interface name");
13356 if (file_name_set == 0)
13358 errmsg ("missing socket file name");
13362 if (vec_len (file_name) > 255)
13364 errmsg ("socket file name too long");
13367 vec_add1 (file_name, 0);
13369 M (MODIFY_VHOST_USER_IF, mp);
13371 mp->sw_if_index = ntohl (sw_if_index);
13372 mp->is_server = is_server;
13373 mp->enable_gso = enable_gso;
13374 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13375 vec_free (file_name);
13376 if (custom_dev_instance != ~0)
13379 mp->custom_dev_instance = ntohl (custom_dev_instance);
13388 api_delete_vhost_user_if (vat_main_t * vam)
13390 unformat_input_t *i = vam->input;
13391 vl_api_delete_vhost_user_if_t *mp;
13392 u32 sw_if_index = ~0;
13393 u8 sw_if_index_set = 0;
13396 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13398 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13399 sw_if_index_set = 1;
13400 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13401 sw_if_index_set = 1;
13406 if (sw_if_index_set == 0)
13408 errmsg ("missing sw_if_index or interface name");
13413 M (DELETE_VHOST_USER_IF, mp);
13415 mp->sw_if_index = ntohl (sw_if_index);
13422 static void vl_api_sw_interface_vhost_user_details_t_handler
13423 (vl_api_sw_interface_vhost_user_details_t * mp)
13425 vat_main_t *vam = &vat_main;
13427 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
13428 (char *) mp->interface_name,
13429 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
13430 clib_net_to_host_u64 (mp->features), mp->is_server,
13431 ntohl (mp->num_regions), (char *) mp->sock_filename);
13432 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
13435 static void vl_api_sw_interface_vhost_user_details_t_handler_json
13436 (vl_api_sw_interface_vhost_user_details_t * mp)
13438 vat_main_t *vam = &vat_main;
13439 vat_json_node_t *node = NULL;
13441 if (VAT_JSON_ARRAY != vam->json_tree.type)
13443 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13444 vat_json_init_array (&vam->json_tree);
13446 node = vat_json_array_add (&vam->json_tree);
13448 vat_json_init_object (node);
13449 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13450 vat_json_object_add_string_copy (node, "interface_name",
13451 mp->interface_name);
13452 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
13453 ntohl (mp->virtio_net_hdr_sz));
13454 vat_json_object_add_uint (node, "features",
13455 clib_net_to_host_u64 (mp->features));
13456 vat_json_object_add_uint (node, "is_server", mp->is_server);
13457 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
13458 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
13459 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
13463 api_sw_interface_vhost_user_dump (vat_main_t * vam)
13465 vl_api_sw_interface_vhost_user_dump_t *mp;
13466 vl_api_control_ping_t *mp_ping;
13469 "Interface name idx hdr_sz features server regions filename");
13471 /* Get list of vhost-user interfaces */
13472 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
13475 /* Use a control ping for synchronization */
13476 MPING (CONTROL_PING, mp_ping);
13484 api_show_version (vat_main_t * vam)
13486 vl_api_show_version_t *mp;
13489 M (SHOW_VERSION, mp);
13498 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
13500 unformat_input_t *line_input = vam->input;
13501 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
13502 ip4_address_t local4, remote4;
13503 ip6_address_t local6, remote6;
13505 u8 ipv4_set = 0, ipv6_set = 0;
13509 u32 mcast_sw_if_index = ~0;
13510 u32 encap_vrf_id = 0;
13511 u32 decap_vrf_id = 0;
13517 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13518 clib_memset (&local4, 0, sizeof local4);
13519 clib_memset (&remote4, 0, sizeof remote4);
13520 clib_memset (&local6, 0, sizeof local6);
13521 clib_memset (&remote6, 0, sizeof remote6);
13523 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13525 if (unformat (line_input, "del"))
13527 else if (unformat (line_input, "local %U",
13528 unformat_ip4_address, &local4))
13533 else if (unformat (line_input, "remote %U",
13534 unformat_ip4_address, &remote4))
13539 else if (unformat (line_input, "local %U",
13540 unformat_ip6_address, &local6))
13545 else if (unformat (line_input, "remote %U",
13546 unformat_ip6_address, &remote6))
13551 else if (unformat (line_input, "group %U %U",
13552 unformat_ip4_address, &remote4,
13553 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13555 grp_set = remote_set = 1;
13558 else if (unformat (line_input, "group %U",
13559 unformat_ip4_address, &remote4))
13561 grp_set = remote_set = 1;
13564 else if (unformat (line_input, "group %U %U",
13565 unformat_ip6_address, &remote6,
13566 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13568 grp_set = remote_set = 1;
13571 else if (unformat (line_input, "group %U",
13572 unformat_ip6_address, &remote6))
13574 grp_set = remote_set = 1;
13578 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13580 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13582 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
13584 else if (unformat (line_input, "vni %d", &vni))
13586 else if (unformat (line_input, "next-ip4"))
13588 else if (unformat (line_input, "next-ip6"))
13590 else if (unformat (line_input, "next-ethernet"))
13592 else if (unformat (line_input, "next-nsh"))
13596 errmsg ("parse error '%U'", format_unformat_error, line_input);
13601 if (local_set == 0)
13603 errmsg ("tunnel local address not specified");
13606 if (remote_set == 0)
13608 errmsg ("tunnel remote address not specified");
13611 if (grp_set && mcast_sw_if_index == ~0)
13613 errmsg ("tunnel nonexistent multicast device");
13616 if (ipv4_set && ipv6_set)
13618 errmsg ("both IPv4 and IPv6 addresses specified");
13624 errmsg ("vni not specified");
13628 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
13633 clib_memcpy (&mp->local, &local6, sizeof (local6));
13634 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
13638 clib_memcpy (&mp->local, &local4, sizeof (local4));
13639 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
13642 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13643 mp->encap_vrf_id = ntohl (encap_vrf_id);
13644 mp->decap_vrf_id = ntohl (decap_vrf_id);
13645 mp->protocol = protocol;
13646 mp->vni = ntohl (vni);
13647 mp->is_add = is_add;
13648 mp->is_ipv6 = ipv6_set;
13655 static void vl_api_vxlan_gpe_tunnel_details_t_handler
13656 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13658 vat_main_t *vam = &vat_main;
13659 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
13660 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
13662 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
13663 ntohl (mp->sw_if_index),
13664 format_ip46_address, &local, IP46_TYPE_ANY,
13665 format_ip46_address, &remote, IP46_TYPE_ANY,
13666 ntohl (mp->vni), mp->protocol,
13667 ntohl (mp->mcast_sw_if_index),
13668 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
13672 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
13673 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13675 vat_main_t *vam = &vat_main;
13676 vat_json_node_t *node = NULL;
13677 struct in_addr ip4;
13678 struct in6_addr ip6;
13680 if (VAT_JSON_ARRAY != vam->json_tree.type)
13682 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13683 vat_json_init_array (&vam->json_tree);
13685 node = vat_json_array_add (&vam->json_tree);
13687 vat_json_init_object (node);
13688 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13691 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
13692 vat_json_object_add_ip6 (node, "local", ip6);
13693 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
13694 vat_json_object_add_ip6 (node, "remote", ip6);
13698 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
13699 vat_json_object_add_ip4 (node, "local", ip4);
13700 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
13701 vat_json_object_add_ip4 (node, "remote", ip4);
13703 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13704 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
13705 vat_json_object_add_uint (node, "mcast_sw_if_index",
13706 ntohl (mp->mcast_sw_if_index));
13707 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13708 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
13709 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13713 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
13715 unformat_input_t *i = vam->input;
13716 vl_api_vxlan_gpe_tunnel_dump_t *mp;
13717 vl_api_control_ping_t *mp_ping;
13719 u8 sw_if_index_set = 0;
13722 /* Parse args required to build the message */
13723 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13725 if (unformat (i, "sw_if_index %d", &sw_if_index))
13726 sw_if_index_set = 1;
13731 if (sw_if_index_set == 0)
13736 if (!vam->json_output)
13738 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
13739 "sw_if_index", "local", "remote", "vni",
13740 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
13743 /* Get list of vxlan-tunnel interfaces */
13744 M (VXLAN_GPE_TUNNEL_DUMP, mp);
13746 mp->sw_if_index = htonl (sw_if_index);
13750 /* Use a control ping for synchronization */
13751 MPING (CONTROL_PING, mp_ping);
13758 static void vl_api_l2_fib_table_details_t_handler
13759 (vl_api_l2_fib_table_details_t * mp)
13761 vat_main_t *vam = &vat_main;
13763 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
13765 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
13766 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
13770 static void vl_api_l2_fib_table_details_t_handler_json
13771 (vl_api_l2_fib_table_details_t * mp)
13773 vat_main_t *vam = &vat_main;
13774 vat_json_node_t *node = NULL;
13776 if (VAT_JSON_ARRAY != vam->json_tree.type)
13778 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13779 vat_json_init_array (&vam->json_tree);
13781 node = vat_json_array_add (&vam->json_tree);
13783 vat_json_init_object (node);
13784 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
13785 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
13786 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13787 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
13788 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
13789 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
13793 api_l2_fib_table_dump (vat_main_t * vam)
13795 unformat_input_t *i = vam->input;
13796 vl_api_l2_fib_table_dump_t *mp;
13797 vl_api_control_ping_t *mp_ping;
13802 /* Parse args required to build the message */
13803 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13805 if (unformat (i, "bd_id %d", &bd_id))
13811 if (bd_id_set == 0)
13813 errmsg ("missing bridge domain");
13817 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
13819 /* Get list of l2 fib entries */
13820 M (L2_FIB_TABLE_DUMP, mp);
13822 mp->bd_id = ntohl (bd_id);
13825 /* Use a control ping for synchronization */
13826 MPING (CONTROL_PING, mp_ping);
13835 api_interface_name_renumber (vat_main_t * vam)
13837 unformat_input_t *line_input = vam->input;
13838 vl_api_interface_name_renumber_t *mp;
13839 u32 sw_if_index = ~0;
13840 u32 new_show_dev_instance = ~0;
13843 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13845 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
13848 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13850 else if (unformat (line_input, "new_show_dev_instance %d",
13851 &new_show_dev_instance))
13857 if (sw_if_index == ~0)
13859 errmsg ("missing interface name or sw_if_index");
13863 if (new_show_dev_instance == ~0)
13865 errmsg ("missing new_show_dev_instance");
13869 M (INTERFACE_NAME_RENUMBER, mp);
13871 mp->sw_if_index = ntohl (sw_if_index);
13872 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
13880 api_ip_probe_neighbor (vat_main_t * vam)
13882 unformat_input_t *i = vam->input;
13883 vl_api_ip_probe_neighbor_t *mp;
13884 vl_api_address_t dst_adr = { };
13890 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13892 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13894 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13896 else if (unformat (i, "address %U", unformat_vl_api_address, &dst_adr))
13904 errmsg ("missing interface");
13910 errmsg ("missing addresses");
13914 M (IP_PROBE_NEIGHBOR, mp);
13916 mp->sw_if_index = ntohl (sw_if_index);
13917 clib_memcpy (&mp->dst, &dst_adr, sizeof (dst_adr));
13925 api_ip_scan_neighbor_enable_disable (vat_main_t * vam)
13927 unformat_input_t *i = vam->input;
13928 vl_api_ip_scan_neighbor_enable_disable_t *mp;
13929 u8 mode = IP_SCAN_V46_NEIGHBORS;
13930 u32 interval = 0, time = 0, update = 0, delay = 0, stale = 0;
13933 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13935 if (unformat (i, "ip4"))
13936 mode = IP_SCAN_V4_NEIGHBORS;
13937 else if (unformat (i, "ip6"))
13938 mode = IP_SCAN_V6_NEIGHBORS;
13939 if (unformat (i, "both"))
13940 mode = IP_SCAN_V46_NEIGHBORS;
13941 else if (unformat (i, "disable"))
13942 mode = IP_SCAN_DISABLED;
13943 else if (unformat (i, "interval %d", &interval))
13945 else if (unformat (i, "max-time %d", &time))
13947 else if (unformat (i, "max-update %d", &update))
13949 else if (unformat (i, "delay %d", &delay))
13951 else if (unformat (i, "stale %d", &stale))
13957 if (interval > 255)
13959 errmsg ("interval cannot exceed 255 minutes.");
13964 errmsg ("max-time cannot exceed 255 usec.");
13969 errmsg ("max-update cannot exceed 255.");
13974 errmsg ("delay cannot exceed 255 msec.");
13979 errmsg ("stale cannot exceed 255 minutes.");
13983 M (IP_SCAN_NEIGHBOR_ENABLE_DISABLE, mp);
13985 mp->scan_interval = interval;
13986 mp->max_proc_time = time;
13987 mp->max_update = update;
13988 mp->scan_int_delay = delay;
13989 mp->stale_threshold = stale;
13997 api_want_ip4_arp_events (vat_main_t * vam)
13999 unformat_input_t *line_input = vam->input;
14000 vl_api_want_ip4_arp_events_t *mp;
14001 ip4_address_t address;
14002 int address_set = 0;
14003 u32 enable_disable = 1;
14006 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14008 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
14010 else if (unformat (line_input, "del"))
14011 enable_disable = 0;
14016 if (address_set == 0)
14018 errmsg ("missing addresses");
14022 M (WANT_IP4_ARP_EVENTS, mp);
14023 mp->enable_disable = enable_disable;
14024 mp->pid = htonl (getpid ());
14025 clib_memcpy (mp->ip, &address, sizeof (address));
14033 api_want_ip6_nd_events (vat_main_t * vam)
14035 unformat_input_t *line_input = vam->input;
14036 vl_api_want_ip6_nd_events_t *mp;
14037 vl_api_ip6_address_t address;
14038 int address_set = 0;
14039 u32 enable_disable = 1;
14042 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14045 (line_input, "address %U", unformat_vl_api_ip6_address, &address))
14047 else if (unformat (line_input, "del"))
14048 enable_disable = 0;
14053 if (address_set == 0)
14055 errmsg ("missing addresses");
14059 M (WANT_IP6_ND_EVENTS, mp);
14060 mp->enable_disable = enable_disable;
14061 mp->pid = htonl (getpid ());
14062 clib_memcpy (&mp->ip, &address, sizeof (address));
14070 api_want_l2_macs_events (vat_main_t * vam)
14072 unformat_input_t *line_input = vam->input;
14073 vl_api_want_l2_macs_events_t *mp;
14074 u8 enable_disable = 1;
14075 u32 scan_delay = 0;
14076 u32 max_macs_in_event = 0;
14077 u32 learn_limit = 0;
14080 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14082 if (unformat (line_input, "learn-limit %d", &learn_limit))
14084 else if (unformat (line_input, "scan-delay %d", &scan_delay))
14086 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
14088 else if (unformat (line_input, "disable"))
14089 enable_disable = 0;
14094 M (WANT_L2_MACS_EVENTS, mp);
14095 mp->enable_disable = enable_disable;
14096 mp->pid = htonl (getpid ());
14097 mp->learn_limit = htonl (learn_limit);
14098 mp->scan_delay = (u8) scan_delay;
14099 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
14106 api_input_acl_set_interface (vat_main_t * vam)
14108 unformat_input_t *i = vam->input;
14109 vl_api_input_acl_set_interface_t *mp;
14111 int sw_if_index_set;
14112 u32 ip4_table_index = ~0;
14113 u32 ip6_table_index = ~0;
14114 u32 l2_table_index = ~0;
14118 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14120 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14121 sw_if_index_set = 1;
14122 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14123 sw_if_index_set = 1;
14124 else if (unformat (i, "del"))
14126 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14128 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14130 else if (unformat (i, "l2-table %d", &l2_table_index))
14134 clib_warning ("parse error '%U'", format_unformat_error, i);
14139 if (sw_if_index_set == 0)
14141 errmsg ("missing interface name or sw_if_index");
14145 M (INPUT_ACL_SET_INTERFACE, mp);
14147 mp->sw_if_index = ntohl (sw_if_index);
14148 mp->ip4_table_index = ntohl (ip4_table_index);
14149 mp->ip6_table_index = ntohl (ip6_table_index);
14150 mp->l2_table_index = ntohl (l2_table_index);
14151 mp->is_add = is_add;
14159 api_output_acl_set_interface (vat_main_t * vam)
14161 unformat_input_t *i = vam->input;
14162 vl_api_output_acl_set_interface_t *mp;
14164 int sw_if_index_set;
14165 u32 ip4_table_index = ~0;
14166 u32 ip6_table_index = ~0;
14167 u32 l2_table_index = ~0;
14171 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14173 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14174 sw_if_index_set = 1;
14175 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14176 sw_if_index_set = 1;
14177 else if (unformat (i, "del"))
14179 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14181 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14183 else if (unformat (i, "l2-table %d", &l2_table_index))
14187 clib_warning ("parse error '%U'", format_unformat_error, i);
14192 if (sw_if_index_set == 0)
14194 errmsg ("missing interface name or sw_if_index");
14198 M (OUTPUT_ACL_SET_INTERFACE, mp);
14200 mp->sw_if_index = ntohl (sw_if_index);
14201 mp->ip4_table_index = ntohl (ip4_table_index);
14202 mp->ip6_table_index = ntohl (ip6_table_index);
14203 mp->l2_table_index = ntohl (l2_table_index);
14204 mp->is_add = is_add;
14212 api_ip_address_dump (vat_main_t * vam)
14214 unformat_input_t *i = vam->input;
14215 vl_api_ip_address_dump_t *mp;
14216 vl_api_control_ping_t *mp_ping;
14217 u32 sw_if_index = ~0;
14218 u8 sw_if_index_set = 0;
14223 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14225 if (unformat (i, "sw_if_index %d", &sw_if_index))
14226 sw_if_index_set = 1;
14228 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14229 sw_if_index_set = 1;
14230 else if (unformat (i, "ipv4"))
14232 else if (unformat (i, "ipv6"))
14238 if (ipv4_set && ipv6_set)
14240 errmsg ("ipv4 and ipv6 flags cannot be both set");
14244 if ((!ipv4_set) && (!ipv6_set))
14246 errmsg ("no ipv4 nor ipv6 flag set");
14250 if (sw_if_index_set == 0)
14252 errmsg ("missing interface name or sw_if_index");
14256 vam->current_sw_if_index = sw_if_index;
14257 vam->is_ipv6 = ipv6_set;
14259 M (IP_ADDRESS_DUMP, mp);
14260 mp->sw_if_index = ntohl (sw_if_index);
14261 mp->is_ipv6 = ipv6_set;
14264 /* Use a control ping for synchronization */
14265 MPING (CONTROL_PING, mp_ping);
14273 api_ip_dump (vat_main_t * vam)
14275 vl_api_ip_dump_t *mp;
14276 vl_api_control_ping_t *mp_ping;
14277 unformat_input_t *in = vam->input;
14284 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
14286 if (unformat (in, "ipv4"))
14288 else if (unformat (in, "ipv6"))
14294 if (ipv4_set && ipv6_set)
14296 errmsg ("ipv4 and ipv6 flags cannot be both set");
14300 if ((!ipv4_set) && (!ipv6_set))
14302 errmsg ("no ipv4 nor ipv6 flag set");
14306 is_ipv6 = ipv6_set;
14307 vam->is_ipv6 = is_ipv6;
14309 /* free old data */
14310 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
14312 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
14314 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
14317 mp->is_ipv6 = ipv6_set;
14320 /* Use a control ping for synchronization */
14321 MPING (CONTROL_PING, mp_ping);
14329 api_ipsec_spd_add_del (vat_main_t * vam)
14331 unformat_input_t *i = vam->input;
14332 vl_api_ipsec_spd_add_del_t *mp;
14337 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14339 if (unformat (i, "spd_id %d", &spd_id))
14341 else if (unformat (i, "del"))
14345 clib_warning ("parse error '%U'", format_unformat_error, i);
14351 errmsg ("spd_id must be set");
14355 M (IPSEC_SPD_ADD_DEL, mp);
14357 mp->spd_id = ntohl (spd_id);
14358 mp->is_add = is_add;
14366 api_ipsec_interface_add_del_spd (vat_main_t * vam)
14368 unformat_input_t *i = vam->input;
14369 vl_api_ipsec_interface_add_del_spd_t *mp;
14371 u8 sw_if_index_set = 0;
14372 u32 spd_id = (u32) ~ 0;
14376 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14378 if (unformat (i, "del"))
14380 else if (unformat (i, "spd_id %d", &spd_id))
14383 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14384 sw_if_index_set = 1;
14385 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14386 sw_if_index_set = 1;
14389 clib_warning ("parse error '%U'", format_unformat_error, i);
14395 if (spd_id == (u32) ~ 0)
14397 errmsg ("spd_id must be set");
14401 if (sw_if_index_set == 0)
14403 errmsg ("missing interface name or sw_if_index");
14407 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
14409 mp->spd_id = ntohl (spd_id);
14410 mp->sw_if_index = ntohl (sw_if_index);
14411 mp->is_add = is_add;
14419 api_ipsec_spd_entry_add_del (vat_main_t * vam)
14421 unformat_input_t *i = vam->input;
14422 vl_api_ipsec_spd_entry_add_del_t *mp;
14423 u8 is_add = 1, is_outbound = 0;
14424 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
14426 u32 rport_start = 0, rport_stop = (u32) ~ 0;
14427 u32 lport_start = 0, lport_stop = (u32) ~ 0;
14428 vl_api_address_t laddr_start = { }, laddr_stop =
14437 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14439 if (unformat (i, "del"))
14441 if (unformat (i, "outbound"))
14443 if (unformat (i, "inbound"))
14445 else if (unformat (i, "spd_id %d", &spd_id))
14447 else if (unformat (i, "sa_id %d", &sa_id))
14449 else if (unformat (i, "priority %d", &priority))
14451 else if (unformat (i, "protocol %d", &protocol))
14453 else if (unformat (i, "lport_start %d", &lport_start))
14455 else if (unformat (i, "lport_stop %d", &lport_stop))
14457 else if (unformat (i, "rport_start %d", &rport_start))
14459 else if (unformat (i, "rport_stop %d", &rport_stop))
14461 else if (unformat (i, "laddr_start %U",
14462 unformat_vl_api_address, &laddr_start))
14464 else if (unformat (i, "laddr_stop %U", unformat_vl_api_address,
14467 else if (unformat (i, "raddr_start %U", unformat_vl_api_address,
14470 else if (unformat (i, "raddr_stop %U", unformat_vl_api_address,
14474 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
14476 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
14478 clib_warning ("unsupported action: 'resolve'");
14484 clib_warning ("parse error '%U'", format_unformat_error, i);
14490 M (IPSEC_SPD_ENTRY_ADD_DEL, mp);
14492 mp->is_add = is_add;
14494 mp->entry.spd_id = ntohl (spd_id);
14495 mp->entry.priority = ntohl (priority);
14496 mp->entry.is_outbound = is_outbound;
14498 clib_memcpy (&mp->entry.remote_address_start, &raddr_start,
14499 sizeof (vl_api_address_t));
14500 clib_memcpy (&mp->entry.remote_address_stop, &raddr_stop,
14501 sizeof (vl_api_address_t));
14502 clib_memcpy (&mp->entry.local_address_start, &laddr_start,
14503 sizeof (vl_api_address_t));
14504 clib_memcpy (&mp->entry.local_address_stop, &laddr_stop,
14505 sizeof (vl_api_address_t));
14507 mp->entry.protocol = (u8) protocol;
14508 mp->entry.local_port_start = ntohs ((u16) lport_start);
14509 mp->entry.local_port_stop = ntohs ((u16) lport_stop);
14510 mp->entry.remote_port_start = ntohs ((u16) rport_start);
14511 mp->entry.remote_port_stop = ntohs ((u16) rport_stop);
14512 mp->entry.policy = (u8) policy;
14513 mp->entry.sa_id = ntohl (sa_id);
14521 api_ipsec_sad_entry_add_del (vat_main_t * vam)
14523 unformat_input_t *i = vam->input;
14524 vl_api_ipsec_sad_entry_add_del_t *mp;
14525 u32 sad_id = 0, spi = 0;
14526 u8 *ck = 0, *ik = 0;
14529 vl_api_ipsec_crypto_alg_t crypto_alg = IPSEC_API_CRYPTO_ALG_NONE;
14530 vl_api_ipsec_integ_alg_t integ_alg = IPSEC_API_INTEG_ALG_NONE;
14531 vl_api_ipsec_sad_flags_t flags = IPSEC_API_SAD_FLAG_NONE;
14532 vl_api_ipsec_proto_t protocol = IPSEC_API_PROTO_AH;
14533 vl_api_address_t tun_src, tun_dst;
14536 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14538 if (unformat (i, "del"))
14540 else if (unformat (i, "sad_id %d", &sad_id))
14542 else if (unformat (i, "spi %d", &spi))
14544 else if (unformat (i, "esp"))
14545 protocol = IPSEC_API_PROTO_ESP;
14547 if (unformat (i, "tunnel_src %U", unformat_vl_api_address, &tun_src))
14549 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
14550 if (ADDRESS_IP6 == tun_src.af)
14551 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
14554 if (unformat (i, "tunnel_dst %U", unformat_vl_api_address, &tun_dst))
14556 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
14557 if (ADDRESS_IP6 == tun_src.af)
14558 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
14561 if (unformat (i, "crypto_alg %U",
14562 unformat_ipsec_api_crypto_alg, &crypto_alg))
14564 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14566 else if (unformat (i, "integ_alg %U",
14567 unformat_ipsec_api_integ_alg, &integ_alg))
14569 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14573 clib_warning ("parse error '%U'", format_unformat_error, i);
14579 M (IPSEC_SAD_ENTRY_ADD_DEL, mp);
14581 mp->is_add = is_add;
14582 mp->entry.sad_id = ntohl (sad_id);
14583 mp->entry.protocol = protocol;
14584 mp->entry.spi = ntohl (spi);
14585 mp->entry.flags = flags;
14587 mp->entry.crypto_algorithm = crypto_alg;
14588 mp->entry.integrity_algorithm = integ_alg;
14589 mp->entry.crypto_key.length = vec_len (ck);
14590 mp->entry.integrity_key.length = vec_len (ik);
14592 if (mp->entry.crypto_key.length > sizeof (mp->entry.crypto_key.data))
14593 mp->entry.crypto_key.length = sizeof (mp->entry.crypto_key.data);
14595 if (mp->entry.integrity_key.length > sizeof (mp->entry.integrity_key.data))
14596 mp->entry.integrity_key.length = sizeof (mp->entry.integrity_key.data);
14599 clib_memcpy (mp->entry.crypto_key.data, ck, mp->entry.crypto_key.length);
14601 clib_memcpy (mp->entry.integrity_key.data, ik,
14602 mp->entry.integrity_key.length);
14604 if (flags & IPSEC_API_SAD_FLAG_IS_TUNNEL)
14606 clib_memcpy (&mp->entry.tunnel_src, &tun_src,
14607 sizeof (mp->entry.tunnel_src));
14608 clib_memcpy (&mp->entry.tunnel_dst, &tun_dst,
14609 sizeof (mp->entry.tunnel_dst));
14618 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
14620 unformat_input_t *i = vam->input;
14621 vl_api_ipsec_tunnel_if_add_del_t *mp;
14622 u32 local_spi = 0, remote_spi = 0;
14623 u32 crypto_alg = 0, integ_alg = 0;
14624 u8 *lck = NULL, *rck = NULL;
14625 u8 *lik = NULL, *rik = NULL;
14626 vl_api_address_t local_ip = { 0 };
14627 vl_api_address_t remote_ip = { 0 };
14631 u8 anti_replay = 0;
14637 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14639 if (unformat (i, "del"))
14641 else if (unformat (i, "esn"))
14643 else if (unformat (i, "anti-replay"))
14645 else if (unformat (i, "count %d", &count))
14647 else if (unformat (i, "local_spi %d", &local_spi))
14649 else if (unformat (i, "remote_spi %d", &remote_spi))
14652 if (unformat (i, "local_ip %U", unformat_vl_api_address, &local_ip))
14655 if (unformat (i, "remote_ip %U", unformat_vl_api_address, &remote_ip))
14657 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
14660 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
14662 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
14664 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
14668 (i, "crypto_alg %U", unformat_ipsec_api_crypto_alg, &crypto_alg))
14670 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
14672 errmsg ("unsupported crypto-alg: '%U'\n",
14673 format_ipsec_crypto_alg, crypto_alg);
14679 (i, "integ_alg %U", unformat_ipsec_api_integ_alg, &integ_alg))
14681 if (integ_alg >= IPSEC_INTEG_N_ALG)
14683 errmsg ("unsupported integ-alg: '%U'\n",
14684 format_ipsec_integ_alg, integ_alg);
14688 else if (unformat (i, "instance %u", &instance))
14692 errmsg ("parse error '%U'\n", format_unformat_error, i);
14699 /* Turn on async mode */
14700 vam->async_mode = 1;
14701 vam->async_errors = 0;
14702 before = vat_time_now (vam);
14705 for (jj = 0; jj < count; jj++)
14707 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
14709 mp->is_add = is_add;
14711 mp->anti_replay = anti_replay;
14714 increment_address (&remote_ip);
14716 clib_memcpy (&mp->local_ip, &local_ip, sizeof (local_ip));
14717 clib_memcpy (&mp->remote_ip, &remote_ip, sizeof (remote_ip));
14719 mp->local_spi = htonl (local_spi + jj);
14720 mp->remote_spi = htonl (remote_spi + jj);
14721 mp->crypto_alg = (u8) crypto_alg;
14723 mp->local_crypto_key_len = 0;
14726 mp->local_crypto_key_len = vec_len (lck);
14727 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
14728 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
14729 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
14732 mp->remote_crypto_key_len = 0;
14735 mp->remote_crypto_key_len = vec_len (rck);
14736 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
14737 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
14738 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
14741 mp->integ_alg = (u8) integ_alg;
14743 mp->local_integ_key_len = 0;
14746 mp->local_integ_key_len = vec_len (lik);
14747 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
14748 mp->local_integ_key_len = sizeof (mp->local_integ_key);
14749 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
14752 mp->remote_integ_key_len = 0;
14755 mp->remote_integ_key_len = vec_len (rik);
14756 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
14757 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
14758 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
14763 mp->renumber = renumber;
14764 mp->show_instance = ntohl (instance);
14769 /* When testing multiple add/del ops, use a control-ping to sync */
14772 vl_api_control_ping_t *mp_ping;
14776 /* Shut off async mode */
14777 vam->async_mode = 0;
14779 MPING (CONTROL_PING, mp_ping);
14782 timeout = vat_time_now (vam) + 1.0;
14783 while (vat_time_now (vam) < timeout)
14784 if (vam->result_ready == 1)
14789 if (vam->retval == -99)
14790 errmsg ("timeout");
14792 if (vam->async_errors > 0)
14794 errmsg ("%d asynchronous errors", vam->async_errors);
14797 vam->async_errors = 0;
14798 after = vat_time_now (vam);
14800 /* slim chance, but we might have eaten SIGTERM on the first iteration */
14804 print (vam->ofp, "%d tunnels in %.6f secs, %.2f tunnels/sec",
14805 count, after - before, count / (after - before));
14809 /* Wait for a reply... */
14818 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
14820 vat_main_t *vam = &vat_main;
14822 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
14823 "crypto_key %U integ_alg %u integ_key %U flags %x "
14824 "tunnel_src_addr %U tunnel_dst_addr %U "
14825 "salt %u seq_outbound %lu last_seq_inbound %lu "
14826 "replay_window %lu\n",
14827 ntohl (mp->entry.sad_id),
14828 ntohl (mp->sw_if_index),
14829 ntohl (mp->entry.spi),
14830 ntohl (mp->entry.protocol),
14831 ntohl (mp->entry.crypto_algorithm),
14832 format_hex_bytes, mp->entry.crypto_key.data,
14833 mp->entry.crypto_key.length, ntohl (mp->entry.integrity_algorithm),
14834 format_hex_bytes, mp->entry.integrity_key.data,
14835 mp->entry.integrity_key.length, ntohl (mp->entry.flags),
14836 format_vl_api_address, &mp->entry.tunnel_src, format_vl_api_address,
14837 &mp->entry.tunnel_dst, ntohl (mp->salt),
14838 clib_net_to_host_u64 (mp->seq_outbound),
14839 clib_net_to_host_u64 (mp->last_seq_inbound),
14840 clib_net_to_host_u64 (mp->replay_window));
14843 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
14844 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
14846 static void vl_api_ipsec_sa_details_t_handler_json
14847 (vl_api_ipsec_sa_details_t * mp)
14849 vat_main_t *vam = &vat_main;
14850 vat_json_node_t *node = NULL;
14851 vl_api_ipsec_sad_flags_t flags;
14853 if (VAT_JSON_ARRAY != vam->json_tree.type)
14855 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14856 vat_json_init_array (&vam->json_tree);
14858 node = vat_json_array_add (&vam->json_tree);
14860 vat_json_init_object (node);
14861 vat_json_object_add_uint (node, "sa_id", ntohl (mp->entry.sad_id));
14862 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14863 vat_json_object_add_uint (node, "spi", ntohl (mp->entry.spi));
14864 vat_json_object_add_uint (node, "proto", ntohl (mp->entry.protocol));
14865 vat_json_object_add_uint (node, "crypto_alg",
14866 ntohl (mp->entry.crypto_algorithm));
14867 vat_json_object_add_uint (node, "integ_alg",
14868 ntohl (mp->entry.integrity_algorithm));
14869 flags = ntohl (mp->entry.flags);
14870 vat_json_object_add_uint (node, "use_esn",
14871 ! !(flags & IPSEC_API_SAD_FLAG_USE_ESN));
14872 vat_json_object_add_uint (node, "use_anti_replay",
14873 ! !(flags & IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY));
14874 vat_json_object_add_uint (node, "is_tunnel",
14875 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL));
14876 vat_json_object_add_uint (node, "is_tunnel_ip6",
14877 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL_V6));
14878 vat_json_object_add_uint (node, "udp_encap",
14879 ! !(flags & IPSEC_API_SAD_FLAG_UDP_ENCAP));
14880 vat_json_object_add_bytes (node, "crypto_key", mp->entry.crypto_key.data,
14881 mp->entry.crypto_key.length);
14882 vat_json_object_add_bytes (node, "integ_key", mp->entry.integrity_key.data,
14883 mp->entry.integrity_key.length);
14884 vat_json_object_add_address (node, "src", &mp->entry.tunnel_src);
14885 vat_json_object_add_address (node, "dst", &mp->entry.tunnel_dst);
14886 vat_json_object_add_uint (node, "replay_window",
14887 clib_net_to_host_u64 (mp->replay_window));
14891 api_ipsec_sa_dump (vat_main_t * vam)
14893 unformat_input_t *i = vam->input;
14894 vl_api_ipsec_sa_dump_t *mp;
14895 vl_api_control_ping_t *mp_ping;
14899 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14901 if (unformat (i, "sa_id %d", &sa_id))
14905 clib_warning ("parse error '%U'", format_unformat_error, i);
14910 M (IPSEC_SA_DUMP, mp);
14912 mp->sa_id = ntohl (sa_id);
14916 /* Use a control ping for synchronization */
14917 M (CONTROL_PING, mp_ping);
14925 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
14927 unformat_input_t *i = vam->input;
14928 vl_api_ipsec_tunnel_if_set_sa_t *mp;
14929 u32 sw_if_index = ~0;
14931 u8 is_outbound = (u8) ~ 0;
14934 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14936 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14938 else if (unformat (i, "sa_id %d", &sa_id))
14940 else if (unformat (i, "outbound"))
14942 else if (unformat (i, "inbound"))
14946 clib_warning ("parse error '%U'", format_unformat_error, i);
14951 if (sw_if_index == ~0)
14953 errmsg ("interface must be specified");
14959 errmsg ("SA ID must be specified");
14963 M (IPSEC_TUNNEL_IF_SET_SA, mp);
14965 mp->sw_if_index = htonl (sw_if_index);
14966 mp->sa_id = htonl (sa_id);
14967 mp->is_outbound = is_outbound;
14976 api_get_first_msg_id (vat_main_t * vam)
14978 vl_api_get_first_msg_id_t *mp;
14979 unformat_input_t *i = vam->input;
14984 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14986 if (unformat (i, "client %s", &name))
14994 errmsg ("missing client name");
14997 vec_add1 (name, 0);
14999 if (vec_len (name) > 63)
15001 errmsg ("client name too long");
15005 M (GET_FIRST_MSG_ID, mp);
15006 clib_memcpy (mp->name, name, vec_len (name));
15013 api_cop_interface_enable_disable (vat_main_t * vam)
15015 unformat_input_t *line_input = vam->input;
15016 vl_api_cop_interface_enable_disable_t *mp;
15017 u32 sw_if_index = ~0;
15018 u8 enable_disable = 1;
15021 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15023 if (unformat (line_input, "disable"))
15024 enable_disable = 0;
15025 if (unformat (line_input, "enable"))
15026 enable_disable = 1;
15027 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15028 vam, &sw_if_index))
15030 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15036 if (sw_if_index == ~0)
15038 errmsg ("missing interface name or sw_if_index");
15042 /* Construct the API message */
15043 M (COP_INTERFACE_ENABLE_DISABLE, mp);
15044 mp->sw_if_index = ntohl (sw_if_index);
15045 mp->enable_disable = enable_disable;
15049 /* Wait for the reply */
15055 api_cop_whitelist_enable_disable (vat_main_t * vam)
15057 unformat_input_t *line_input = vam->input;
15058 vl_api_cop_whitelist_enable_disable_t *mp;
15059 u32 sw_if_index = ~0;
15060 u8 ip4 = 0, ip6 = 0, default_cop = 0;
15064 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15066 if (unformat (line_input, "ip4"))
15068 else if (unformat (line_input, "ip6"))
15070 else if (unformat (line_input, "default"))
15072 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15073 vam, &sw_if_index))
15075 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15077 else if (unformat (line_input, "fib-id %d", &fib_id))
15083 if (sw_if_index == ~0)
15085 errmsg ("missing interface name or sw_if_index");
15089 /* Construct the API message */
15090 M (COP_WHITELIST_ENABLE_DISABLE, mp);
15091 mp->sw_if_index = ntohl (sw_if_index);
15092 mp->fib_id = ntohl (fib_id);
15095 mp->default_cop = default_cop;
15099 /* Wait for the reply */
15105 api_get_node_graph (vat_main_t * vam)
15107 vl_api_get_node_graph_t *mp;
15110 M (GET_NODE_GRAPH, mp);
15114 /* Wait for the reply */
15120 /** Used for parsing LISP eids */
15121 typedef CLIB_PACKED(struct{
15122 u8 addr[16]; /**< eid address */
15123 u32 len; /**< prefix length if IP */
15124 u8 type; /**< type of eid */
15129 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
15131 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
15133 clib_memset (a, 0, sizeof (a[0]));
15135 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
15137 a->type = 0; /* ipv4 type */
15139 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
15141 a->type = 1; /* ipv6 type */
15143 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
15145 a->type = 2; /* mac type */
15147 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
15149 a->type = 3; /* NSH type */
15150 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
15151 nsh->spi = clib_host_to_net_u32 (nsh->spi);
15158 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
15167 lisp_eid_size_vat (u8 type)
15184 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
15186 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
15190 api_one_add_del_locator_set (vat_main_t * vam)
15192 unformat_input_t *input = vam->input;
15193 vl_api_one_add_del_locator_set_t *mp;
15195 u8 *locator_set_name = NULL;
15196 u8 locator_set_name_set = 0;
15197 vl_api_local_locator_t locator, *locators = 0;
15198 u32 sw_if_index, priority, weight;
15202 /* Parse args required to build the message */
15203 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15205 if (unformat (input, "del"))
15209 else if (unformat (input, "locator-set %s", &locator_set_name))
15211 locator_set_name_set = 1;
15213 else if (unformat (input, "sw_if_index %u p %u w %u",
15214 &sw_if_index, &priority, &weight))
15216 locator.sw_if_index = htonl (sw_if_index);
15217 locator.priority = priority;
15218 locator.weight = weight;
15219 vec_add1 (locators, locator);
15223 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
15224 &sw_if_index, &priority, &weight))
15226 locator.sw_if_index = htonl (sw_if_index);
15227 locator.priority = priority;
15228 locator.weight = weight;
15229 vec_add1 (locators, locator);
15235 if (locator_set_name_set == 0)
15237 errmsg ("missing locator-set name");
15238 vec_free (locators);
15242 if (vec_len (locator_set_name) > 64)
15244 errmsg ("locator-set name too long");
15245 vec_free (locator_set_name);
15246 vec_free (locators);
15249 vec_add1 (locator_set_name, 0);
15251 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
15253 /* Construct the API message */
15254 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
15256 mp->is_add = is_add;
15257 clib_memcpy (mp->locator_set_name, locator_set_name,
15258 vec_len (locator_set_name));
15259 vec_free (locator_set_name);
15261 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
15263 clib_memcpy (mp->locators, locators, data_len);
15264 vec_free (locators);
15269 /* Wait for a reply... */
15274 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
15277 api_one_add_del_locator (vat_main_t * vam)
15279 unformat_input_t *input = vam->input;
15280 vl_api_one_add_del_locator_t *mp;
15281 u32 tmp_if_index = ~0;
15282 u32 sw_if_index = ~0;
15283 u8 sw_if_index_set = 0;
15284 u8 sw_if_index_if_name_set = 0;
15286 u8 priority_set = 0;
15290 u8 *locator_set_name = NULL;
15291 u8 locator_set_name_set = 0;
15294 /* Parse args required to build the message */
15295 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15297 if (unformat (input, "del"))
15301 else if (unformat (input, "locator-set %s", &locator_set_name))
15303 locator_set_name_set = 1;
15305 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
15308 sw_if_index_if_name_set = 1;
15309 sw_if_index = tmp_if_index;
15311 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
15313 sw_if_index_set = 1;
15314 sw_if_index = tmp_if_index;
15316 else if (unformat (input, "p %d", &priority))
15320 else if (unformat (input, "w %d", &weight))
15328 if (locator_set_name_set == 0)
15330 errmsg ("missing locator-set name");
15334 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
15336 errmsg ("missing sw_if_index");
15337 vec_free (locator_set_name);
15341 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
15343 errmsg ("cannot use both params interface name and sw_if_index");
15344 vec_free (locator_set_name);
15348 if (priority_set == 0)
15350 errmsg ("missing locator-set priority");
15351 vec_free (locator_set_name);
15355 if (weight_set == 0)
15357 errmsg ("missing locator-set weight");
15358 vec_free (locator_set_name);
15362 if (vec_len (locator_set_name) > 64)
15364 errmsg ("locator-set name too long");
15365 vec_free (locator_set_name);
15368 vec_add1 (locator_set_name, 0);
15370 /* Construct the API message */
15371 M (ONE_ADD_DEL_LOCATOR, mp);
15373 mp->is_add = is_add;
15374 mp->sw_if_index = ntohl (sw_if_index);
15375 mp->priority = priority;
15376 mp->weight = weight;
15377 clib_memcpy (mp->locator_set_name, locator_set_name,
15378 vec_len (locator_set_name));
15379 vec_free (locator_set_name);
15384 /* Wait for a reply... */
15389 #define api_lisp_add_del_locator api_one_add_del_locator
15392 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
15394 u32 *key_id = va_arg (*args, u32 *);
15397 if (unformat (input, "%s", &s))
15399 if (!strcmp ((char *) s, "sha1"))
15400 key_id[0] = HMAC_SHA_1_96;
15401 else if (!strcmp ((char *) s, "sha256"))
15402 key_id[0] = HMAC_SHA_256_128;
15405 clib_warning ("invalid key_id: '%s'", s);
15406 key_id[0] = HMAC_NO_KEY;
15417 api_one_add_del_local_eid (vat_main_t * vam)
15419 unformat_input_t *input = vam->input;
15420 vl_api_one_add_del_local_eid_t *mp;
15423 lisp_eid_vat_t _eid, *eid = &_eid;
15424 u8 *locator_set_name = 0;
15425 u8 locator_set_name_set = 0;
15431 /* Parse args required to build the message */
15432 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15434 if (unformat (input, "del"))
15438 else if (unformat (input, "vni %d", &vni))
15442 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15446 else if (unformat (input, "locator-set %s", &locator_set_name))
15448 locator_set_name_set = 1;
15450 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
15452 else if (unformat (input, "secret-key %_%v%_", &key))
15458 if (locator_set_name_set == 0)
15460 errmsg ("missing locator-set name");
15466 errmsg ("EID address not set!");
15467 vec_free (locator_set_name);
15471 if (key && (0 == key_id))
15473 errmsg ("invalid key_id!");
15477 if (vec_len (key) > 64)
15479 errmsg ("key too long");
15484 if (vec_len (locator_set_name) > 64)
15486 errmsg ("locator-set name too long");
15487 vec_free (locator_set_name);
15490 vec_add1 (locator_set_name, 0);
15492 /* Construct the API message */
15493 M (ONE_ADD_DEL_LOCAL_EID, mp);
15495 mp->is_add = is_add;
15496 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15497 mp->eid_type = eid->type;
15498 mp->prefix_len = eid->len;
15499 mp->vni = clib_host_to_net_u32 (vni);
15500 mp->key_id = clib_host_to_net_u16 (key_id);
15501 clib_memcpy (mp->locator_set_name, locator_set_name,
15502 vec_len (locator_set_name));
15503 clib_memcpy (mp->key, key, vec_len (key));
15505 vec_free (locator_set_name);
15511 /* Wait for a reply... */
15516 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
15519 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
15521 u32 dp_table = 0, vni = 0;;
15522 unformat_input_t *input = vam->input;
15523 vl_api_gpe_add_del_fwd_entry_t *mp;
15525 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
15526 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
15527 u8 rmt_eid_set = 0, lcl_eid_set = 0;
15528 u32 action = ~0, w;
15529 ip4_address_t rmt_rloc4, lcl_rloc4;
15530 ip6_address_t rmt_rloc6, lcl_rloc6;
15531 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
15534 clib_memset (&rloc, 0, sizeof (rloc));
15536 /* Parse args required to build the message */
15537 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15539 if (unformat (input, "del"))
15541 else if (unformat (input, "add"))
15543 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
15547 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
15551 else if (unformat (input, "vrf %d", &dp_table))
15553 else if (unformat (input, "bd %d", &dp_table))
15555 else if (unformat (input, "vni %d", &vni))
15557 else if (unformat (input, "w %d", &w))
15561 errmsg ("No RLOC configured for setting priority/weight!");
15564 curr_rloc->weight = w;
15566 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
15567 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
15571 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
15573 vec_add1 (lcl_locs, rloc);
15575 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
15576 vec_add1 (rmt_locs, rloc);
15577 /* weight saved in rmt loc */
15578 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15580 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
15581 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
15584 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
15586 vec_add1 (lcl_locs, rloc);
15588 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
15589 vec_add1 (rmt_locs, rloc);
15590 /* weight saved in rmt loc */
15591 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15593 else if (unformat (input, "action %d", &action))
15599 clib_warning ("parse error '%U'", format_unformat_error, input);
15606 errmsg ("remote eid addresses not set");
15610 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
15612 errmsg ("eid types don't match");
15616 if (0 == rmt_locs && (u32) ~ 0 == action)
15618 errmsg ("action not set for negative mapping");
15622 /* Construct the API message */
15623 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
15624 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
15626 mp->is_add = is_add;
15627 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
15628 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
15629 mp->eid_type = rmt_eid->type;
15630 mp->dp_table = clib_host_to_net_u32 (dp_table);
15631 mp->vni = clib_host_to_net_u32 (vni);
15632 mp->rmt_len = rmt_eid->len;
15633 mp->lcl_len = lcl_eid->len;
15634 mp->action = action;
15636 if (0 != rmt_locs && 0 != lcl_locs)
15638 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
15639 clib_memcpy (mp->locs, lcl_locs,
15640 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
15642 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
15643 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
15644 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
15646 vec_free (lcl_locs);
15647 vec_free (rmt_locs);
15652 /* Wait for a reply... */
15658 api_one_add_del_map_server (vat_main_t * vam)
15660 unformat_input_t *input = vam->input;
15661 vl_api_one_add_del_map_server_t *mp;
15665 ip4_address_t ipv4;
15666 ip6_address_t ipv6;
15669 /* Parse args required to build the message */
15670 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15672 if (unformat (input, "del"))
15676 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15680 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15688 if (ipv4_set && ipv6_set)
15690 errmsg ("both eid v4 and v6 addresses set");
15694 if (!ipv4_set && !ipv6_set)
15696 errmsg ("eid addresses not set");
15700 /* Construct the API message */
15701 M (ONE_ADD_DEL_MAP_SERVER, mp);
15703 mp->is_add = is_add;
15707 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
15712 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
15718 /* Wait for a reply... */
15723 #define api_lisp_add_del_map_server api_one_add_del_map_server
15726 api_one_add_del_map_resolver (vat_main_t * vam)
15728 unformat_input_t *input = vam->input;
15729 vl_api_one_add_del_map_resolver_t *mp;
15733 ip4_address_t ipv4;
15734 ip6_address_t ipv6;
15737 /* Parse args required to build the message */
15738 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15740 if (unformat (input, "del"))
15744 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15748 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15756 if (ipv4_set && ipv6_set)
15758 errmsg ("both eid v4 and v6 addresses set");
15762 if (!ipv4_set && !ipv6_set)
15764 errmsg ("eid addresses not set");
15768 /* Construct the API message */
15769 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
15771 mp->is_add = is_add;
15775 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
15780 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
15786 /* Wait for a reply... */
15791 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
15794 api_lisp_gpe_enable_disable (vat_main_t * vam)
15796 unformat_input_t *input = vam->input;
15797 vl_api_gpe_enable_disable_t *mp;
15802 /* Parse args required to build the message */
15803 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15805 if (unformat (input, "enable"))
15810 else if (unformat (input, "disable"))
15821 errmsg ("Value not set");
15825 /* Construct the API message */
15826 M (GPE_ENABLE_DISABLE, mp);
15833 /* Wait for a reply... */
15839 api_one_rloc_probe_enable_disable (vat_main_t * vam)
15841 unformat_input_t *input = vam->input;
15842 vl_api_one_rloc_probe_enable_disable_t *mp;
15847 /* Parse args required to build the message */
15848 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15850 if (unformat (input, "enable"))
15855 else if (unformat (input, "disable"))
15863 errmsg ("Value not set");
15867 /* Construct the API message */
15868 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
15870 mp->is_enabled = is_en;
15875 /* Wait for a reply... */
15880 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
15883 api_one_map_register_enable_disable (vat_main_t * vam)
15885 unformat_input_t *input = vam->input;
15886 vl_api_one_map_register_enable_disable_t *mp;
15891 /* Parse args required to build the message */
15892 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15894 if (unformat (input, "enable"))
15899 else if (unformat (input, "disable"))
15907 errmsg ("Value not set");
15911 /* Construct the API message */
15912 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
15914 mp->is_enabled = is_en;
15919 /* Wait for a reply... */
15924 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
15927 api_one_enable_disable (vat_main_t * vam)
15929 unformat_input_t *input = vam->input;
15930 vl_api_one_enable_disable_t *mp;
15935 /* Parse args required to build the message */
15936 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15938 if (unformat (input, "enable"))
15943 else if (unformat (input, "disable"))
15953 errmsg ("Value not set");
15957 /* Construct the API message */
15958 M (ONE_ENABLE_DISABLE, mp);
15965 /* Wait for a reply... */
15970 #define api_lisp_enable_disable api_one_enable_disable
15973 api_one_enable_disable_xtr_mode (vat_main_t * vam)
15975 unformat_input_t *input = vam->input;
15976 vl_api_one_enable_disable_xtr_mode_t *mp;
15981 /* Parse args required to build the message */
15982 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15984 if (unformat (input, "enable"))
15989 else if (unformat (input, "disable"))
15999 errmsg ("Value not set");
16003 /* Construct the API message */
16004 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
16011 /* Wait for a reply... */
16017 api_one_show_xtr_mode (vat_main_t * vam)
16019 vl_api_one_show_xtr_mode_t *mp;
16022 /* Construct the API message */
16023 M (ONE_SHOW_XTR_MODE, mp);
16028 /* Wait for a reply... */
16034 api_one_enable_disable_pitr_mode (vat_main_t * vam)
16036 unformat_input_t *input = vam->input;
16037 vl_api_one_enable_disable_pitr_mode_t *mp;
16042 /* Parse args required to build the message */
16043 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16045 if (unformat (input, "enable"))
16050 else if (unformat (input, "disable"))
16060 errmsg ("Value not set");
16064 /* Construct the API message */
16065 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
16072 /* Wait for a reply... */
16078 api_one_show_pitr_mode (vat_main_t * vam)
16080 vl_api_one_show_pitr_mode_t *mp;
16083 /* Construct the API message */
16084 M (ONE_SHOW_PITR_MODE, mp);
16089 /* Wait for a reply... */
16095 api_one_enable_disable_petr_mode (vat_main_t * vam)
16097 unformat_input_t *input = vam->input;
16098 vl_api_one_enable_disable_petr_mode_t *mp;
16103 /* Parse args required to build the message */
16104 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16106 if (unformat (input, "enable"))
16111 else if (unformat (input, "disable"))
16121 errmsg ("Value not set");
16125 /* Construct the API message */
16126 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
16133 /* Wait for a reply... */
16139 api_one_show_petr_mode (vat_main_t * vam)
16141 vl_api_one_show_petr_mode_t *mp;
16144 /* Construct the API message */
16145 M (ONE_SHOW_PETR_MODE, mp);
16150 /* Wait for a reply... */
16156 api_show_one_map_register_state (vat_main_t * vam)
16158 vl_api_show_one_map_register_state_t *mp;
16161 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
16166 /* wait for reply */
16171 #define api_show_lisp_map_register_state api_show_one_map_register_state
16174 api_show_one_rloc_probe_state (vat_main_t * vam)
16176 vl_api_show_one_rloc_probe_state_t *mp;
16179 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
16184 /* wait for reply */
16189 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
16192 api_one_add_del_ndp_entry (vat_main_t * vam)
16194 vl_api_one_add_del_ndp_entry_t *mp;
16195 unformat_input_t *input = vam->input;
16200 u8 mac[6] = { 0, };
16201 u8 ip6[16] = { 0, };
16205 /* Parse args required to build the message */
16206 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16208 if (unformat (input, "del"))
16210 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16212 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
16214 else if (unformat (input, "bd %d", &bd))
16218 errmsg ("parse error '%U'", format_unformat_error, input);
16223 if (!bd_set || !ip_set || (!mac_set && is_add))
16225 errmsg ("Missing BD, IP or MAC!");
16229 M (ONE_ADD_DEL_NDP_ENTRY, mp);
16230 mp->is_add = is_add;
16231 clib_memcpy (mp->mac, mac, 6);
16232 mp->bd = clib_host_to_net_u32 (bd);
16233 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
16238 /* wait for reply */
16244 api_one_add_del_l2_arp_entry (vat_main_t * vam)
16246 vl_api_one_add_del_l2_arp_entry_t *mp;
16247 unformat_input_t *input = vam->input;
16252 u8 mac[6] = { 0, };
16253 u32 ip4 = 0, bd = ~0;
16256 /* Parse args required to build the message */
16257 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16259 if (unformat (input, "del"))
16261 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16263 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
16265 else if (unformat (input, "bd %d", &bd))
16269 errmsg ("parse error '%U'", format_unformat_error, input);
16274 if (!bd_set || !ip_set || (!mac_set && is_add))
16276 errmsg ("Missing BD, IP or MAC!");
16280 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
16281 mp->is_add = is_add;
16282 clib_memcpy (mp->mac, mac, 6);
16283 mp->bd = clib_host_to_net_u32 (bd);
16289 /* wait for reply */
16295 api_one_ndp_bd_get (vat_main_t * vam)
16297 vl_api_one_ndp_bd_get_t *mp;
16300 M (ONE_NDP_BD_GET, mp);
16305 /* wait for reply */
16311 api_one_ndp_entries_get (vat_main_t * vam)
16313 vl_api_one_ndp_entries_get_t *mp;
16314 unformat_input_t *input = vam->input;
16319 /* Parse args required to build the message */
16320 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16322 if (unformat (input, "bd %d", &bd))
16326 errmsg ("parse error '%U'", format_unformat_error, input);
16333 errmsg ("Expected bridge domain!");
16337 M (ONE_NDP_ENTRIES_GET, mp);
16338 mp->bd = clib_host_to_net_u32 (bd);
16343 /* wait for reply */
16349 api_one_l2_arp_bd_get (vat_main_t * vam)
16351 vl_api_one_l2_arp_bd_get_t *mp;
16354 M (ONE_L2_ARP_BD_GET, mp);
16359 /* wait for reply */
16365 api_one_l2_arp_entries_get (vat_main_t * vam)
16367 vl_api_one_l2_arp_entries_get_t *mp;
16368 unformat_input_t *input = vam->input;
16373 /* Parse args required to build the message */
16374 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16376 if (unformat (input, "bd %d", &bd))
16380 errmsg ("parse error '%U'", format_unformat_error, input);
16387 errmsg ("Expected bridge domain!");
16391 M (ONE_L2_ARP_ENTRIES_GET, mp);
16392 mp->bd = clib_host_to_net_u32 (bd);
16397 /* wait for reply */
16403 api_one_stats_enable_disable (vat_main_t * vam)
16405 vl_api_one_stats_enable_disable_t *mp;
16406 unformat_input_t *input = vam->input;
16411 /* Parse args required to build the message */
16412 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16414 if (unformat (input, "enable"))
16419 else if (unformat (input, "disable"))
16429 errmsg ("Value not set");
16433 M (ONE_STATS_ENABLE_DISABLE, mp);
16439 /* wait for reply */
16445 api_show_one_stats_enable_disable (vat_main_t * vam)
16447 vl_api_show_one_stats_enable_disable_t *mp;
16450 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
16455 /* wait for reply */
16461 api_show_one_map_request_mode (vat_main_t * vam)
16463 vl_api_show_one_map_request_mode_t *mp;
16466 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
16471 /* wait for reply */
16476 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
16479 api_one_map_request_mode (vat_main_t * vam)
16481 unformat_input_t *input = vam->input;
16482 vl_api_one_map_request_mode_t *mp;
16486 /* Parse args required to build the message */
16487 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16489 if (unformat (input, "dst-only"))
16491 else if (unformat (input, "src-dst"))
16495 errmsg ("parse error '%U'", format_unformat_error, input);
16500 M (ONE_MAP_REQUEST_MODE, mp);
16507 /* wait for reply */
16512 #define api_lisp_map_request_mode api_one_map_request_mode
16515 * Enable/disable ONE proxy ITR.
16517 * @param vam vpp API test context
16518 * @return return code
16521 api_one_pitr_set_locator_set (vat_main_t * vam)
16523 u8 ls_name_set = 0;
16524 unformat_input_t *input = vam->input;
16525 vl_api_one_pitr_set_locator_set_t *mp;
16530 /* Parse args required to build the message */
16531 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16533 if (unformat (input, "del"))
16535 else if (unformat (input, "locator-set %s", &ls_name))
16539 errmsg ("parse error '%U'", format_unformat_error, input);
16546 errmsg ("locator-set name not set!");
16550 M (ONE_PITR_SET_LOCATOR_SET, mp);
16552 mp->is_add = is_add;
16553 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16554 vec_free (ls_name);
16559 /* wait for reply */
16564 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
16567 api_one_nsh_set_locator_set (vat_main_t * vam)
16569 u8 ls_name_set = 0;
16570 unformat_input_t *input = vam->input;
16571 vl_api_one_nsh_set_locator_set_t *mp;
16576 /* Parse args required to build the message */
16577 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16579 if (unformat (input, "del"))
16581 else if (unformat (input, "ls %s", &ls_name))
16585 errmsg ("parse error '%U'", format_unformat_error, input);
16590 if (!ls_name_set && is_add)
16592 errmsg ("locator-set name not set!");
16596 M (ONE_NSH_SET_LOCATOR_SET, mp);
16598 mp->is_add = is_add;
16599 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16600 vec_free (ls_name);
16605 /* wait for reply */
16611 api_show_one_pitr (vat_main_t * vam)
16613 vl_api_show_one_pitr_t *mp;
16616 if (!vam->json_output)
16618 print (vam->ofp, "%=20s", "lisp status:");
16621 M (SHOW_ONE_PITR, mp);
16625 /* Wait for a reply... */
16630 #define api_show_lisp_pitr api_show_one_pitr
16633 api_one_use_petr (vat_main_t * vam)
16635 unformat_input_t *input = vam->input;
16636 vl_api_one_use_petr_t *mp;
16641 clib_memset (&ip, 0, sizeof (ip));
16643 /* Parse args required to build the message */
16644 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16646 if (unformat (input, "disable"))
16649 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
16652 ip_addr_version (&ip) = IP4;
16655 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
16658 ip_addr_version (&ip) = IP6;
16662 errmsg ("parse error '%U'", format_unformat_error, input);
16667 M (ONE_USE_PETR, mp);
16669 mp->is_add = is_add;
16672 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
16674 clib_memcpy (mp->address, &ip, 4);
16676 clib_memcpy (mp->address, &ip, 16);
16682 /* wait for reply */
16687 #define api_lisp_use_petr api_one_use_petr
16690 api_show_one_nsh_mapping (vat_main_t * vam)
16692 vl_api_show_one_use_petr_t *mp;
16695 if (!vam->json_output)
16697 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
16700 M (SHOW_ONE_NSH_MAPPING, mp);
16704 /* Wait for a reply... */
16710 api_show_one_use_petr (vat_main_t * vam)
16712 vl_api_show_one_use_petr_t *mp;
16715 if (!vam->json_output)
16717 print (vam->ofp, "%=20s", "Proxy-ETR status:");
16720 M (SHOW_ONE_USE_PETR, mp);
16724 /* Wait for a reply... */
16729 #define api_show_lisp_use_petr api_show_one_use_petr
16732 * Add/delete mapping between vni and vrf
16735 api_one_eid_table_add_del_map (vat_main_t * vam)
16737 unformat_input_t *input = vam->input;
16738 vl_api_one_eid_table_add_del_map_t *mp;
16739 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
16740 u32 vni, vrf, bd_index;
16743 /* Parse args required to build the message */
16744 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16746 if (unformat (input, "del"))
16748 else if (unformat (input, "vrf %d", &vrf))
16750 else if (unformat (input, "bd_index %d", &bd_index))
16752 else if (unformat (input, "vni %d", &vni))
16758 if (!vni_set || (!vrf_set && !bd_index_set))
16760 errmsg ("missing arguments!");
16764 if (vrf_set && bd_index_set)
16766 errmsg ("error: both vrf and bd entered!");
16770 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
16772 mp->is_add = is_add;
16773 mp->vni = htonl (vni);
16774 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
16775 mp->is_l2 = bd_index_set;
16780 /* wait for reply */
16785 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
16788 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
16790 u32 *action = va_arg (*args, u32 *);
16793 if (unformat (input, "%s", &s))
16795 if (!strcmp ((char *) s, "no-action"))
16797 else if (!strcmp ((char *) s, "natively-forward"))
16799 else if (!strcmp ((char *) s, "send-map-request"))
16801 else if (!strcmp ((char *) s, "drop"))
16805 clib_warning ("invalid action: '%s'", s);
16817 * Add/del remote mapping to/from ONE control plane
16819 * @param vam vpp API test context
16820 * @return return code
16823 api_one_add_del_remote_mapping (vat_main_t * vam)
16825 unformat_input_t *input = vam->input;
16826 vl_api_one_add_del_remote_mapping_t *mp;
16828 lisp_eid_vat_t _eid, *eid = &_eid;
16829 lisp_eid_vat_t _seid, *seid = &_seid;
16830 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
16831 u32 action = ~0, p, w, data_len;
16832 ip4_address_t rloc4;
16833 ip6_address_t rloc6;
16834 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
16837 clib_memset (&rloc, 0, sizeof (rloc));
16839 /* Parse args required to build the message */
16840 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16842 if (unformat (input, "del-all"))
16846 else if (unformat (input, "del"))
16850 else if (unformat (input, "add"))
16854 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
16858 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
16862 else if (unformat (input, "vni %d", &vni))
16866 else if (unformat (input, "p %d w %d", &p, &w))
16870 errmsg ("No RLOC configured for setting priority/weight!");
16873 curr_rloc->priority = p;
16874 curr_rloc->weight = w;
16876 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
16879 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
16880 vec_add1 (rlocs, rloc);
16881 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16883 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
16886 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
16887 vec_add1 (rlocs, rloc);
16888 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16890 else if (unformat (input, "action %U",
16891 unformat_negative_mapping_action, &action))
16897 clib_warning ("parse error '%U'", format_unformat_error, input);
16904 errmsg ("missing params!");
16908 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
16910 errmsg ("no action set for negative map-reply!");
16914 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
16916 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
16917 mp->is_add = is_add;
16918 mp->vni = htonl (vni);
16919 mp->action = (u8) action;
16920 mp->is_src_dst = seid_set;
16921 mp->eid_len = eid->len;
16922 mp->seid_len = seid->len;
16923 mp->del_all = del_all;
16924 mp->eid_type = eid->type;
16925 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
16926 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
16928 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
16929 clib_memcpy (mp->rlocs, rlocs, data_len);
16935 /* Wait for a reply... */
16940 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
16943 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
16944 * forwarding entries in data-plane accordingly.
16946 * @param vam vpp API test context
16947 * @return return code
16950 api_one_add_del_adjacency (vat_main_t * vam)
16952 unformat_input_t *input = vam->input;
16953 vl_api_one_add_del_adjacency_t *mp;
16955 ip4_address_t leid4, reid4;
16956 ip6_address_t leid6, reid6;
16957 u8 reid_mac[6] = { 0 };
16958 u8 leid_mac[6] = { 0 };
16959 u8 reid_type, leid_type;
16960 u32 leid_len = 0, reid_len = 0, len;
16964 leid_type = reid_type = (u8) ~ 0;
16966 /* Parse args required to build the message */
16967 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16969 if (unformat (input, "del"))
16973 else if (unformat (input, "add"))
16977 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
16980 reid_type = 0; /* ipv4 */
16983 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
16986 reid_type = 1; /* ipv6 */
16989 else if (unformat (input, "reid %U", unformat_ethernet_address,
16992 reid_type = 2; /* mac */
16994 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
16997 leid_type = 0; /* ipv4 */
17000 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
17003 leid_type = 1; /* ipv6 */
17006 else if (unformat (input, "leid %U", unformat_ethernet_address,
17009 leid_type = 2; /* mac */
17011 else if (unformat (input, "vni %d", &vni))
17017 errmsg ("parse error '%U'", format_unformat_error, input);
17022 if ((u8) ~ 0 == reid_type)
17024 errmsg ("missing params!");
17028 if (leid_type != reid_type)
17030 errmsg ("remote and local EIDs are of different types!");
17034 M (ONE_ADD_DEL_ADJACENCY, mp);
17035 mp->is_add = is_add;
17036 mp->vni = htonl (vni);
17037 mp->leid_len = leid_len;
17038 mp->reid_len = reid_len;
17039 mp->eid_type = reid_type;
17041 switch (mp->eid_type)
17044 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
17045 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
17048 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
17049 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
17052 clib_memcpy (mp->leid, leid_mac, 6);
17053 clib_memcpy (mp->reid, reid_mac, 6);
17056 errmsg ("unknown EID type %d!", mp->eid_type);
17063 /* Wait for a reply... */
17068 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
17071 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
17073 u32 *mode = va_arg (*args, u32 *);
17075 if (unformat (input, "lisp"))
17077 else if (unformat (input, "vxlan"))
17086 api_gpe_get_encap_mode (vat_main_t * vam)
17088 vl_api_gpe_get_encap_mode_t *mp;
17091 /* Construct the API message */
17092 M (GPE_GET_ENCAP_MODE, mp);
17097 /* Wait for a reply... */
17103 api_gpe_set_encap_mode (vat_main_t * vam)
17105 unformat_input_t *input = vam->input;
17106 vl_api_gpe_set_encap_mode_t *mp;
17110 /* Parse args required to build the message */
17111 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17113 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
17119 /* Construct the API message */
17120 M (GPE_SET_ENCAP_MODE, mp);
17127 /* Wait for a reply... */
17133 api_lisp_gpe_add_del_iface (vat_main_t * vam)
17135 unformat_input_t *input = vam->input;
17136 vl_api_gpe_add_del_iface_t *mp;
17137 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
17138 u32 dp_table = 0, vni = 0;
17141 /* Parse args required to build the message */
17142 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17144 if (unformat (input, "up"))
17149 else if (unformat (input, "down"))
17154 else if (unformat (input, "table_id %d", &dp_table))
17158 else if (unformat (input, "bd_id %d", &dp_table))
17163 else if (unformat (input, "vni %d", &vni))
17171 if (action_set == 0)
17173 errmsg ("Action not set");
17176 if (dp_table_set == 0 || vni_set == 0)
17178 errmsg ("vni and dp_table must be set");
17182 /* Construct the API message */
17183 M (GPE_ADD_DEL_IFACE, mp);
17185 mp->is_add = is_add;
17186 mp->dp_table = clib_host_to_net_u32 (dp_table);
17188 mp->vni = clib_host_to_net_u32 (vni);
17193 /* Wait for a reply... */
17199 api_one_map_register_fallback_threshold (vat_main_t * vam)
17201 unformat_input_t *input = vam->input;
17202 vl_api_one_map_register_fallback_threshold_t *mp;
17207 /* Parse args required to build the message */
17208 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17210 if (unformat (input, "%u", &value))
17214 clib_warning ("parse error '%U'", format_unformat_error, input);
17221 errmsg ("fallback threshold value is missing!");
17225 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17226 mp->value = clib_host_to_net_u32 (value);
17231 /* Wait for a reply... */
17237 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
17239 vl_api_show_one_map_register_fallback_threshold_t *mp;
17242 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17247 /* Wait for a reply... */
17253 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
17255 u32 *proto = va_arg (*args, u32 *);
17257 if (unformat (input, "udp"))
17259 else if (unformat (input, "api"))
17268 api_one_set_transport_protocol (vat_main_t * vam)
17270 unformat_input_t *input = vam->input;
17271 vl_api_one_set_transport_protocol_t *mp;
17276 /* Parse args required to build the message */
17277 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17279 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
17283 clib_warning ("parse error '%U'", format_unformat_error, input);
17290 errmsg ("Transport protocol missing!");
17294 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
17295 mp->protocol = (u8) protocol;
17300 /* Wait for a reply... */
17306 api_one_get_transport_protocol (vat_main_t * vam)
17308 vl_api_one_get_transport_protocol_t *mp;
17311 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
17316 /* Wait for a reply... */
17322 api_one_map_register_set_ttl (vat_main_t * vam)
17324 unformat_input_t *input = vam->input;
17325 vl_api_one_map_register_set_ttl_t *mp;
17330 /* Parse args required to build the message */
17331 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17333 if (unformat (input, "%u", &ttl))
17337 clib_warning ("parse error '%U'", format_unformat_error, input);
17344 errmsg ("TTL value missing!");
17348 M (ONE_MAP_REGISTER_SET_TTL, mp);
17349 mp->ttl = clib_host_to_net_u32 (ttl);
17354 /* Wait for a reply... */
17360 api_show_one_map_register_ttl (vat_main_t * vam)
17362 vl_api_show_one_map_register_ttl_t *mp;
17365 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
17370 /* Wait for a reply... */
17376 * Add/del map request itr rlocs from ONE control plane and updates
17378 * @param vam vpp API test context
17379 * @return return code
17382 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
17384 unformat_input_t *input = vam->input;
17385 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
17386 u8 *locator_set_name = 0;
17387 u8 locator_set_name_set = 0;
17391 /* Parse args required to build the message */
17392 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17394 if (unformat (input, "del"))
17398 else if (unformat (input, "%_%v%_", &locator_set_name))
17400 locator_set_name_set = 1;
17404 clib_warning ("parse error '%U'", format_unformat_error, input);
17409 if (is_add && !locator_set_name_set)
17411 errmsg ("itr-rloc is not set!");
17415 if (is_add && vec_len (locator_set_name) > 64)
17417 errmsg ("itr-rloc locator-set name too long");
17418 vec_free (locator_set_name);
17422 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
17423 mp->is_add = is_add;
17426 clib_memcpy (mp->locator_set_name, locator_set_name,
17427 vec_len (locator_set_name));
17431 clib_memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
17433 vec_free (locator_set_name);
17438 /* Wait for a reply... */
17443 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
17446 api_one_locator_dump (vat_main_t * vam)
17448 unformat_input_t *input = vam->input;
17449 vl_api_one_locator_dump_t *mp;
17450 vl_api_control_ping_t *mp_ping;
17451 u8 is_index_set = 0, is_name_set = 0;
17456 /* Parse args required to build the message */
17457 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17459 if (unformat (input, "ls_name %_%v%_", &ls_name))
17463 else if (unformat (input, "ls_index %d", &ls_index))
17469 errmsg ("parse error '%U'", format_unformat_error, input);
17474 if (!is_index_set && !is_name_set)
17476 errmsg ("error: expected one of index or name!");
17480 if (is_index_set && is_name_set)
17482 errmsg ("error: only one param expected!");
17486 if (vec_len (ls_name) > 62)
17488 errmsg ("error: locator set name too long!");
17492 if (!vam->json_output)
17494 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
17497 M (ONE_LOCATOR_DUMP, mp);
17498 mp->is_index_set = is_index_set;
17501 mp->ls_index = clib_host_to_net_u32 (ls_index);
17504 vec_add1 (ls_name, 0);
17505 strncpy ((char *) mp->ls_name, (char *) ls_name,
17506 sizeof (mp->ls_name) - 1);
17512 /* Use a control ping for synchronization */
17513 MPING (CONTROL_PING, mp_ping);
17516 /* Wait for a reply... */
17521 #define api_lisp_locator_dump api_one_locator_dump
17524 api_one_locator_set_dump (vat_main_t * vam)
17526 vl_api_one_locator_set_dump_t *mp;
17527 vl_api_control_ping_t *mp_ping;
17528 unformat_input_t *input = vam->input;
17532 /* Parse args required to build the message */
17533 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17535 if (unformat (input, "local"))
17539 else if (unformat (input, "remote"))
17545 errmsg ("parse error '%U'", format_unformat_error, input);
17550 if (!vam->json_output)
17552 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
17555 M (ONE_LOCATOR_SET_DUMP, mp);
17557 mp->filter = filter;
17562 /* Use a control ping for synchronization */
17563 MPING (CONTROL_PING, mp_ping);
17566 /* Wait for a reply... */
17571 #define api_lisp_locator_set_dump api_one_locator_set_dump
17574 api_one_eid_table_map_dump (vat_main_t * vam)
17578 unformat_input_t *input = vam->input;
17579 vl_api_one_eid_table_map_dump_t *mp;
17580 vl_api_control_ping_t *mp_ping;
17583 /* Parse args required to build the message */
17584 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17586 if (unformat (input, "l2"))
17591 else if (unformat (input, "l3"))
17598 errmsg ("parse error '%U'", format_unformat_error, input);
17605 errmsg ("expected one of 'l2' or 'l3' parameter!");
17609 if (!vam->json_output)
17611 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
17614 M (ONE_EID_TABLE_MAP_DUMP, mp);
17620 /* Use a control ping for synchronization */
17621 MPING (CONTROL_PING, mp_ping);
17624 /* Wait for a reply... */
17629 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
17632 api_one_eid_table_vni_dump (vat_main_t * vam)
17634 vl_api_one_eid_table_vni_dump_t *mp;
17635 vl_api_control_ping_t *mp_ping;
17638 if (!vam->json_output)
17640 print (vam->ofp, "VNI");
17643 M (ONE_EID_TABLE_VNI_DUMP, mp);
17648 /* Use a control ping for synchronization */
17649 MPING (CONTROL_PING, mp_ping);
17652 /* Wait for a reply... */
17657 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
17660 api_one_eid_table_dump (vat_main_t * vam)
17662 unformat_input_t *i = vam->input;
17663 vl_api_one_eid_table_dump_t *mp;
17664 vl_api_control_ping_t *mp_ping;
17665 struct in_addr ip4;
17666 struct in6_addr ip6;
17668 u8 eid_type = ~0, eid_set = 0;
17669 u32 prefix_length = ~0, t, vni = 0;
17672 lisp_nsh_api_t nsh;
17674 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17676 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
17682 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
17688 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
17693 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
17698 else if (unformat (i, "vni %d", &t))
17702 else if (unformat (i, "local"))
17706 else if (unformat (i, "remote"))
17712 errmsg ("parse error '%U'", format_unformat_error, i);
17717 if (!vam->json_output)
17719 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
17720 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
17723 M (ONE_EID_TABLE_DUMP, mp);
17725 mp->filter = filter;
17729 mp->vni = htonl (vni);
17730 mp->eid_type = eid_type;
17734 mp->prefix_length = prefix_length;
17735 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
17738 mp->prefix_length = prefix_length;
17739 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
17742 clib_memcpy (mp->eid, mac, sizeof (mac));
17745 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
17748 errmsg ("unknown EID type %d!", eid_type);
17756 /* Use a control ping for synchronization */
17757 MPING (CONTROL_PING, mp_ping);
17760 /* Wait for a reply... */
17765 #define api_lisp_eid_table_dump api_one_eid_table_dump
17768 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
17770 unformat_input_t *i = vam->input;
17771 vl_api_gpe_fwd_entries_get_t *mp;
17776 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17778 if (unformat (i, "vni %d", &vni))
17784 errmsg ("parse error '%U'", format_unformat_error, i);
17791 errmsg ("vni not set!");
17795 if (!vam->json_output)
17797 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
17801 M (GPE_FWD_ENTRIES_GET, mp);
17802 mp->vni = clib_host_to_net_u32 (vni);
17807 /* Wait for a reply... */
17812 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
17813 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
17814 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
17815 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
17816 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
17817 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
17818 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
17819 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
17822 api_one_adjacencies_get (vat_main_t * vam)
17824 unformat_input_t *i = vam->input;
17825 vl_api_one_adjacencies_get_t *mp;
17830 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17832 if (unformat (i, "vni %d", &vni))
17838 errmsg ("parse error '%U'", format_unformat_error, i);
17845 errmsg ("vni not set!");
17849 if (!vam->json_output)
17851 print (vam->ofp, "%s %40s", "leid", "reid");
17854 M (ONE_ADJACENCIES_GET, mp);
17855 mp->vni = clib_host_to_net_u32 (vni);
17860 /* Wait for a reply... */
17865 #define api_lisp_adjacencies_get api_one_adjacencies_get
17868 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
17870 unformat_input_t *i = vam->input;
17871 vl_api_gpe_native_fwd_rpaths_get_t *mp;
17873 u8 ip_family_set = 0, is_ip4 = 1;
17875 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17877 if (unformat (i, "ip4"))
17882 else if (unformat (i, "ip6"))
17889 errmsg ("parse error '%U'", format_unformat_error, i);
17894 if (!ip_family_set)
17896 errmsg ("ip family not set!");
17900 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
17901 mp->is_ip4 = is_ip4;
17906 /* Wait for a reply... */
17912 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
17914 vl_api_gpe_fwd_entry_vnis_get_t *mp;
17917 if (!vam->json_output)
17919 print (vam->ofp, "VNIs");
17922 M (GPE_FWD_ENTRY_VNIS_GET, mp);
17927 /* Wait for a reply... */
17933 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
17935 unformat_input_t *i = vam->input;
17936 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
17938 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
17939 struct in_addr ip4;
17940 struct in6_addr ip6;
17941 u32 table_id = 0, nh_sw_if_index = ~0;
17943 clib_memset (&ip4, 0, sizeof (ip4));
17944 clib_memset (&ip6, 0, sizeof (ip6));
17946 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17948 if (unformat (i, "del"))
17950 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
17951 api_unformat_sw_if_index, vam, &nh_sw_if_index))
17956 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
17957 api_unformat_sw_if_index, vam, &nh_sw_if_index))
17962 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
17966 nh_sw_if_index = ~0;
17968 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
17972 nh_sw_if_index = ~0;
17974 else if (unformat (i, "table %d", &table_id))
17978 errmsg ("parse error '%U'", format_unformat_error, i);
17985 errmsg ("nh addr not set!");
17989 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
17990 mp->is_add = is_add;
17991 mp->table_id = clib_host_to_net_u32 (table_id);
17992 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
17993 mp->is_ip4 = is_ip4;
17995 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
17997 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
18002 /* Wait for a reply... */
18008 api_one_map_server_dump (vat_main_t * vam)
18010 vl_api_one_map_server_dump_t *mp;
18011 vl_api_control_ping_t *mp_ping;
18014 if (!vam->json_output)
18016 print (vam->ofp, "%=20s", "Map server");
18019 M (ONE_MAP_SERVER_DUMP, mp);
18023 /* Use a control ping for synchronization */
18024 MPING (CONTROL_PING, mp_ping);
18027 /* Wait for a reply... */
18032 #define api_lisp_map_server_dump api_one_map_server_dump
18035 api_one_map_resolver_dump (vat_main_t * vam)
18037 vl_api_one_map_resolver_dump_t *mp;
18038 vl_api_control_ping_t *mp_ping;
18041 if (!vam->json_output)
18043 print (vam->ofp, "%=20s", "Map resolver");
18046 M (ONE_MAP_RESOLVER_DUMP, mp);
18050 /* Use a control ping for synchronization */
18051 MPING (CONTROL_PING, mp_ping);
18054 /* Wait for a reply... */
18059 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
18062 api_one_stats_flush (vat_main_t * vam)
18064 vl_api_one_stats_flush_t *mp;
18067 M (ONE_STATS_FLUSH, mp);
18074 api_one_stats_dump (vat_main_t * vam)
18076 vl_api_one_stats_dump_t *mp;
18077 vl_api_control_ping_t *mp_ping;
18080 M (ONE_STATS_DUMP, mp);
18084 /* Use a control ping for synchronization */
18085 MPING (CONTROL_PING, mp_ping);
18088 /* Wait for a reply... */
18094 api_show_one_status (vat_main_t * vam)
18096 vl_api_show_one_status_t *mp;
18099 if (!vam->json_output)
18101 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
18104 M (SHOW_ONE_STATUS, mp);
18107 /* Wait for a reply... */
18112 #define api_show_lisp_status api_show_one_status
18115 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
18117 vl_api_gpe_fwd_entry_path_dump_t *mp;
18118 vl_api_control_ping_t *mp_ping;
18119 unformat_input_t *i = vam->input;
18120 u32 fwd_entry_index = ~0;
18123 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18125 if (unformat (i, "index %d", &fwd_entry_index))
18131 if (~0 == fwd_entry_index)
18133 errmsg ("no index specified!");
18137 if (!vam->json_output)
18139 print (vam->ofp, "first line");
18142 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
18146 /* Use a control ping for synchronization */
18147 MPING (CONTROL_PING, mp_ping);
18150 /* Wait for a reply... */
18156 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
18158 vl_api_one_get_map_request_itr_rlocs_t *mp;
18161 if (!vam->json_output)
18163 print (vam->ofp, "%=20s", "itr-rlocs:");
18166 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
18169 /* Wait for a reply... */
18174 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
18177 api_af_packet_create (vat_main_t * vam)
18179 unformat_input_t *i = vam->input;
18180 vl_api_af_packet_create_t *mp;
18181 u8 *host_if_name = 0;
18183 u8 random_hw_addr = 1;
18186 clib_memset (hw_addr, 0, sizeof (hw_addr));
18188 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18190 if (unformat (i, "name %s", &host_if_name))
18191 vec_add1 (host_if_name, 0);
18192 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18193 random_hw_addr = 0;
18198 if (!vec_len (host_if_name))
18200 errmsg ("host-interface name must be specified");
18204 if (vec_len (host_if_name) > 64)
18206 errmsg ("host-interface name too long");
18210 M (AF_PACKET_CREATE, mp);
18212 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18213 clib_memcpy (mp->hw_addr, hw_addr, 6);
18214 mp->use_random_hw_addr = random_hw_addr;
18215 vec_free (host_if_name);
18223 fprintf (vam->ofp ? vam->ofp : stderr,
18224 " new sw_if_index = %d\n", vam->sw_if_index);
18231 api_af_packet_delete (vat_main_t * vam)
18233 unformat_input_t *i = vam->input;
18234 vl_api_af_packet_delete_t *mp;
18235 u8 *host_if_name = 0;
18238 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18240 if (unformat (i, "name %s", &host_if_name))
18241 vec_add1 (host_if_name, 0);
18246 if (!vec_len (host_if_name))
18248 errmsg ("host-interface name must be specified");
18252 if (vec_len (host_if_name) > 64)
18254 errmsg ("host-interface name too long");
18258 M (AF_PACKET_DELETE, mp);
18260 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18261 vec_free (host_if_name);
18268 static void vl_api_af_packet_details_t_handler
18269 (vl_api_af_packet_details_t * mp)
18271 vat_main_t *vam = &vat_main;
18273 print (vam->ofp, "%-16s %d",
18274 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
18277 static void vl_api_af_packet_details_t_handler_json
18278 (vl_api_af_packet_details_t * mp)
18280 vat_main_t *vam = &vat_main;
18281 vat_json_node_t *node = NULL;
18283 if (VAT_JSON_ARRAY != vam->json_tree.type)
18285 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18286 vat_json_init_array (&vam->json_tree);
18288 node = vat_json_array_add (&vam->json_tree);
18290 vat_json_init_object (node);
18291 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
18292 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
18296 api_af_packet_dump (vat_main_t * vam)
18298 vl_api_af_packet_dump_t *mp;
18299 vl_api_control_ping_t *mp_ping;
18302 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
18303 /* Get list of tap interfaces */
18304 M (AF_PACKET_DUMP, mp);
18307 /* Use a control ping for synchronization */
18308 MPING (CONTROL_PING, mp_ping);
18316 api_policer_add_del (vat_main_t * vam)
18318 unformat_input_t *i = vam->input;
18319 vl_api_policer_add_del_t *mp;
18329 u8 color_aware = 0;
18330 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
18333 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
18334 conform_action.dscp = 0;
18335 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
18336 exceed_action.dscp = 0;
18337 violate_action.action_type = SSE2_QOS_ACTION_DROP;
18338 violate_action.dscp = 0;
18340 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18342 if (unformat (i, "del"))
18344 else if (unformat (i, "name %s", &name))
18345 vec_add1 (name, 0);
18346 else if (unformat (i, "cir %u", &cir))
18348 else if (unformat (i, "eir %u", &eir))
18350 else if (unformat (i, "cb %u", &cb))
18352 else if (unformat (i, "eb %u", &eb))
18354 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
18357 else if (unformat (i, "round_type %U", unformat_policer_round_type,
18360 else if (unformat (i, "type %U", unformat_policer_type, &type))
18362 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
18365 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
18368 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
18371 else if (unformat (i, "color-aware"))
18377 if (!vec_len (name))
18379 errmsg ("policer name must be specified");
18383 if (vec_len (name) > 64)
18385 errmsg ("policer name too long");
18389 M (POLICER_ADD_DEL, mp);
18391 clib_memcpy (mp->name, name, vec_len (name));
18393 mp->is_add = is_add;
18394 mp->cir = ntohl (cir);
18395 mp->eir = ntohl (eir);
18396 mp->cb = clib_net_to_host_u64 (cb);
18397 mp->eb = clib_net_to_host_u64 (eb);
18398 mp->rate_type = rate_type;
18399 mp->round_type = round_type;
18401 mp->conform_action_type = conform_action.action_type;
18402 mp->conform_dscp = conform_action.dscp;
18403 mp->exceed_action_type = exceed_action.action_type;
18404 mp->exceed_dscp = exceed_action.dscp;
18405 mp->violate_action_type = violate_action.action_type;
18406 mp->violate_dscp = violate_action.dscp;
18407 mp->color_aware = color_aware;
18415 api_policer_dump (vat_main_t * vam)
18417 unformat_input_t *i = vam->input;
18418 vl_api_policer_dump_t *mp;
18419 vl_api_control_ping_t *mp_ping;
18420 u8 *match_name = 0;
18421 u8 match_name_valid = 0;
18424 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18426 if (unformat (i, "name %s", &match_name))
18428 vec_add1 (match_name, 0);
18429 match_name_valid = 1;
18435 M (POLICER_DUMP, mp);
18436 mp->match_name_valid = match_name_valid;
18437 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
18438 vec_free (match_name);
18442 /* Use a control ping for synchronization */
18443 MPING (CONTROL_PING, mp_ping);
18446 /* Wait for a reply... */
18452 api_policer_classify_set_interface (vat_main_t * vam)
18454 unformat_input_t *i = vam->input;
18455 vl_api_policer_classify_set_interface_t *mp;
18457 int sw_if_index_set;
18458 u32 ip4_table_index = ~0;
18459 u32 ip6_table_index = ~0;
18460 u32 l2_table_index = ~0;
18464 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18466 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18467 sw_if_index_set = 1;
18468 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18469 sw_if_index_set = 1;
18470 else if (unformat (i, "del"))
18472 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18474 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18476 else if (unformat (i, "l2-table %d", &l2_table_index))
18480 clib_warning ("parse error '%U'", format_unformat_error, i);
18485 if (sw_if_index_set == 0)
18487 errmsg ("missing interface name or sw_if_index");
18491 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
18493 mp->sw_if_index = ntohl (sw_if_index);
18494 mp->ip4_table_index = ntohl (ip4_table_index);
18495 mp->ip6_table_index = ntohl (ip6_table_index);
18496 mp->l2_table_index = ntohl (l2_table_index);
18497 mp->is_add = is_add;
18505 api_policer_classify_dump (vat_main_t * vam)
18507 unformat_input_t *i = vam->input;
18508 vl_api_policer_classify_dump_t *mp;
18509 vl_api_control_ping_t *mp_ping;
18510 u8 type = POLICER_CLASSIFY_N_TABLES;
18513 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
18517 errmsg ("classify table type must be specified");
18521 if (!vam->json_output)
18523 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
18526 M (POLICER_CLASSIFY_DUMP, mp);
18531 /* Use a control ping for synchronization */
18532 MPING (CONTROL_PING, mp_ping);
18535 /* Wait for a reply... */
18541 api_netmap_create (vat_main_t * vam)
18543 unformat_input_t *i = vam->input;
18544 vl_api_netmap_create_t *mp;
18547 u8 random_hw_addr = 1;
18552 clib_memset (hw_addr, 0, sizeof (hw_addr));
18554 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18556 if (unformat (i, "name %s", &if_name))
18557 vec_add1 (if_name, 0);
18558 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18559 random_hw_addr = 0;
18560 else if (unformat (i, "pipe"))
18562 else if (unformat (i, "master"))
18564 else if (unformat (i, "slave"))
18570 if (!vec_len (if_name))
18572 errmsg ("interface name must be specified");
18576 if (vec_len (if_name) > 64)
18578 errmsg ("interface name too long");
18582 M (NETMAP_CREATE, mp);
18584 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18585 clib_memcpy (mp->hw_addr, hw_addr, 6);
18586 mp->use_random_hw_addr = random_hw_addr;
18587 mp->is_pipe = is_pipe;
18588 mp->is_master = is_master;
18589 vec_free (if_name);
18597 api_netmap_delete (vat_main_t * vam)
18599 unformat_input_t *i = vam->input;
18600 vl_api_netmap_delete_t *mp;
18604 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18606 if (unformat (i, "name %s", &if_name))
18607 vec_add1 (if_name, 0);
18612 if (!vec_len (if_name))
18614 errmsg ("interface name must be specified");
18618 if (vec_len (if_name) > 64)
18620 errmsg ("interface name too long");
18624 M (NETMAP_DELETE, mp);
18626 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18627 vec_free (if_name);
18635 format_fib_api_path_nh_proto (u8 * s, va_list * args)
18637 vl_api_fib_path_nh_proto_t proto =
18638 va_arg (*args, vl_api_fib_path_nh_proto_t);
18642 case FIB_API_PATH_NH_PROTO_IP4:
18643 s = format (s, "ip4");
18645 case FIB_API_PATH_NH_PROTO_IP6:
18646 s = format (s, "ip6");
18648 case FIB_API_PATH_NH_PROTO_MPLS:
18649 s = format (s, "mpls");
18651 case FIB_API_PATH_NH_PROTO_BIER:
18652 s = format (s, "bier");
18654 case FIB_API_PATH_NH_PROTO_ETHERNET:
18655 s = format (s, "ethernet");
18663 format_vl_api_ip_address_union (u8 * s, va_list * args)
18665 vl_api_address_family_t af = va_arg (*args, vl_api_address_family_t);
18666 const vl_api_address_union_t *u = va_arg (*args, vl_api_address_union_t *);
18671 s = format (s, "%U", format_ip4_address, u->ip4);
18674 s = format (s, "%U", format_ip6_address, u->ip6);
18681 format_vl_api_fib_path_type (u8 * s, va_list * args)
18683 vl_api_fib_path_type_t t = va_arg (*args, vl_api_fib_path_type_t);
18687 case FIB_API_PATH_TYPE_NORMAL:
18688 s = format (s, "normal");
18690 case FIB_API_PATH_TYPE_LOCAL:
18691 s = format (s, "local");
18693 case FIB_API_PATH_TYPE_DROP:
18694 s = format (s, "drop");
18696 case FIB_API_PATH_TYPE_UDP_ENCAP:
18697 s = format (s, "udp-encap");
18699 case FIB_API_PATH_TYPE_BIER_IMP:
18700 s = format (s, "bier-imp");
18702 case FIB_API_PATH_TYPE_ICMP_UNREACH:
18703 s = format (s, "unreach");
18705 case FIB_API_PATH_TYPE_ICMP_PROHIBIT:
18706 s = format (s, "prohibit");
18708 case FIB_API_PATH_TYPE_SOURCE_LOOKUP:
18709 s = format (s, "src-lookup");
18711 case FIB_API_PATH_TYPE_DVR:
18712 s = format (s, "dvr");
18714 case FIB_API_PATH_TYPE_INTERFACE_RX:
18715 s = format (s, "interface-rx");
18717 case FIB_API_PATH_TYPE_CLASSIFY:
18718 s = format (s, "classify");
18726 vl_api_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
18729 " weight %d, sw_if_index %d, type %U, afi %U, next_hop %U",
18730 ntohl (fp->weight), ntohl (fp->sw_if_index),
18731 format_vl_api_fib_path_type, fp->type,
18732 format_fib_api_path_nh_proto, fp->proto,
18733 format_vl_api_ip_address_union, &fp->nh.address);
18737 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
18738 vl_api_fib_path_t * fp)
18740 struct in_addr ip4;
18741 struct in6_addr ip6;
18743 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
18744 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
18745 vat_json_object_add_uint (node, "type", fp->type);
18746 vat_json_object_add_uint (node, "next_hop_proto", fp->proto);
18747 if (fp->proto == FIB_API_PATH_NH_PROTO_IP4)
18749 clib_memcpy (&ip4, &fp->nh.address.ip4, sizeof (ip4));
18750 vat_json_object_add_ip4 (node, "next_hop", ip4);
18752 else if (fp->proto == FIB_API_PATH_NH_PROTO_IP4)
18754 clib_memcpy (&ip6, &fp->nh.address.ip6, sizeof (ip6));
18755 vat_json_object_add_ip6 (node, "next_hop", ip6);
18760 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
18762 vat_main_t *vam = &vat_main;
18763 int count = ntohl (mp->mt_tunnel.mt_n_paths);
18764 vl_api_fib_path_t *fp;
18767 print (vam->ofp, "sw_if_index %d via:",
18768 ntohl (mp->mt_tunnel.mt_sw_if_index));
18769 fp = mp->mt_tunnel.mt_paths;
18770 for (i = 0; i < count; i++)
18772 vl_api_fib_path_print (vam, fp);
18776 print (vam->ofp, "");
18779 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
18780 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
18783 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
18785 vat_main_t *vam = &vat_main;
18786 vat_json_node_t *node = NULL;
18787 int count = ntohl (mp->mt_tunnel.mt_n_paths);
18788 vl_api_fib_path_t *fp;
18791 if (VAT_JSON_ARRAY != vam->json_tree.type)
18793 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18794 vat_json_init_array (&vam->json_tree);
18796 node = vat_json_array_add (&vam->json_tree);
18798 vat_json_init_object (node);
18799 vat_json_object_add_uint (node, "sw_if_index",
18800 ntohl (mp->mt_tunnel.mt_sw_if_index));
18802 vat_json_object_add_uint (node, "l2_only", mp->mt_tunnel.mt_l2_only);
18804 fp = mp->mt_tunnel.mt_paths;
18805 for (i = 0; i < count; i++)
18807 vl_api_mpls_fib_path_json_print (node, fp);
18813 api_mpls_tunnel_dump (vat_main_t * vam)
18815 vl_api_mpls_tunnel_dump_t *mp;
18816 vl_api_control_ping_t *mp_ping;
18819 M (MPLS_TUNNEL_DUMP, mp);
18823 /* Use a control ping for synchronization */
18824 MPING (CONTROL_PING, mp_ping);
18831 #define vl_api_mpls_table_details_t_endian vl_noop_handler
18832 #define vl_api_mpls_table_details_t_print vl_noop_handler
18836 vl_api_mpls_table_details_t_handler (vl_api_mpls_table_details_t * mp)
18838 vat_main_t *vam = &vat_main;
18840 print (vam->ofp, "table-id %d,", ntohl (mp->mt_table.mt_table_id));
18843 static void vl_api_mpls_table_details_t_handler_json
18844 (vl_api_mpls_table_details_t * mp)
18846 vat_main_t *vam = &vat_main;
18847 vat_json_node_t *node = NULL;
18849 if (VAT_JSON_ARRAY != vam->json_tree.type)
18851 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18852 vat_json_init_array (&vam->json_tree);
18854 node = vat_json_array_add (&vam->json_tree);
18856 vat_json_init_object (node);
18857 vat_json_object_add_uint (node, "table", ntohl (mp->mt_table.mt_table_id));
18861 api_mpls_table_dump (vat_main_t * vam)
18863 vl_api_mpls_table_dump_t *mp;
18864 vl_api_control_ping_t *mp_ping;
18867 M (MPLS_TABLE_DUMP, mp);
18870 /* Use a control ping for synchronization */
18871 MPING (CONTROL_PING, mp_ping);
18878 #define vl_api_mpls_route_details_t_endian vl_noop_handler
18879 #define vl_api_mpls_route_details_t_print vl_noop_handler
18882 vl_api_mpls_route_details_t_handler (vl_api_mpls_route_details_t * mp)
18884 vat_main_t *vam = &vat_main;
18885 int count = (int) clib_net_to_host_u32 (mp->mr_route.mr_n_paths);
18886 vl_api_fib_path_t *fp;
18890 "table-id %d, label %u, ess_bit %u",
18891 ntohl (mp->mr_route.mr_table_id),
18892 ntohl (mp->mr_route.mr_label), mp->mr_route.mr_eos);
18893 fp = mp->mr_route.mr_paths;
18894 for (i = 0; i < count; i++)
18896 vl_api_fib_path_print (vam, fp);
18901 static void vl_api_mpls_route_details_t_handler_json
18902 (vl_api_mpls_route_details_t * mp)
18904 vat_main_t *vam = &vat_main;
18905 int count = (int) clib_host_to_net_u32 (mp->mr_route.mr_n_paths);
18906 vat_json_node_t *node = NULL;
18907 vl_api_fib_path_t *fp;
18910 if (VAT_JSON_ARRAY != vam->json_tree.type)
18912 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18913 vat_json_init_array (&vam->json_tree);
18915 node = vat_json_array_add (&vam->json_tree);
18917 vat_json_init_object (node);
18918 vat_json_object_add_uint (node, "table", ntohl (mp->mr_route.mr_table_id));
18919 vat_json_object_add_uint (node, "s_bit", mp->mr_route.mr_eos);
18920 vat_json_object_add_uint (node, "label", ntohl (mp->mr_route.mr_label));
18921 vat_json_object_add_uint (node, "path_count", count);
18922 fp = mp->mr_route.mr_paths;
18923 for (i = 0; i < count; i++)
18925 vl_api_mpls_fib_path_json_print (node, fp);
18931 api_mpls_route_dump (vat_main_t * vam)
18933 unformat_input_t *input = vam->input;
18934 vl_api_mpls_route_dump_t *mp;
18935 vl_api_control_ping_t *mp_ping;
18939 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18941 if (unformat (input, "table_id %d", &table_id))
18946 if (table_id == ~0)
18948 errmsg ("missing table id");
18952 M (MPLS_ROUTE_DUMP, mp);
18954 mp->table.mt_table_id = ntohl (table_id);
18957 /* Use a control ping for synchronization */
18958 MPING (CONTROL_PING, mp_ping);
18965 #define vl_api_ip_table_details_t_endian vl_noop_handler
18966 #define vl_api_ip_table_details_t_print vl_noop_handler
18969 vl_api_ip_table_details_t_handler (vl_api_ip_table_details_t * mp)
18971 vat_main_t *vam = &vat_main;
18974 "%s; table-id %d, prefix %U/%d",
18975 mp->table.name, ntohl (mp->table.table_id));
18979 static void vl_api_ip_table_details_t_handler_json
18980 (vl_api_ip_table_details_t * mp)
18982 vat_main_t *vam = &vat_main;
18983 vat_json_node_t *node = NULL;
18985 if (VAT_JSON_ARRAY != vam->json_tree.type)
18987 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18988 vat_json_init_array (&vam->json_tree);
18990 node = vat_json_array_add (&vam->json_tree);
18992 vat_json_init_object (node);
18993 vat_json_object_add_uint (node, "table", ntohl (mp->table.table_id));
18997 api_ip_table_dump (vat_main_t * vam)
18999 vl_api_ip_table_dump_t *mp;
19000 vl_api_control_ping_t *mp_ping;
19003 M (IP_TABLE_DUMP, mp);
19006 /* Use a control ping for synchronization */
19007 MPING (CONTROL_PING, mp_ping);
19015 api_ip_mtable_dump (vat_main_t * vam)
19017 vl_api_ip_mtable_dump_t *mp;
19018 vl_api_control_ping_t *mp_ping;
19021 M (IP_MTABLE_DUMP, mp);
19024 /* Use a control ping for synchronization */
19025 MPING (CONTROL_PING, mp_ping);
19033 api_ip_mroute_dump (vat_main_t * vam)
19035 unformat_input_t *input = vam->input;
19036 vl_api_control_ping_t *mp_ping;
19037 vl_api_ip_mroute_dump_t *mp;
19042 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19044 if (unformat (input, "table_id %d", &table_id))
19046 else if (unformat (input, "ip6"))
19048 else if (unformat (input, "ip4"))
19053 if (table_id == ~0)
19055 errmsg ("missing table id");
19059 M (IP_MROUTE_DUMP, mp);
19060 mp->table.table_id = table_id;
19061 mp->table.is_ip6 = is_ip6;
19064 /* Use a control ping for synchronization */
19065 MPING (CONTROL_PING, mp_ping);
19072 static void vl_api_ip_neighbor_details_t_handler
19073 (vl_api_ip_neighbor_details_t * mp)
19075 vat_main_t *vam = &vat_main;
19077 print (vam->ofp, "%c %U %U",
19078 (ntohl (mp->neighbor.flags) & IP_NEIGHBOR_FLAG_STATIC) ? 'S' : 'D',
19079 format_vl_api_mac_address, &mp->neighbor.mac_address,
19080 format_vl_api_address, &mp->neighbor.ip_address);
19083 static void vl_api_ip_neighbor_details_t_handler_json
19084 (vl_api_ip_neighbor_details_t * mp)
19087 vat_main_t *vam = &vat_main;
19088 vat_json_node_t *node;
19090 if (VAT_JSON_ARRAY != vam->json_tree.type)
19092 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19093 vat_json_init_array (&vam->json_tree);
19095 node = vat_json_array_add (&vam->json_tree);
19097 vat_json_init_object (node);
19098 vat_json_object_add_string_copy
19100 ((ntohl (mp->neighbor.flags) & IP_NEIGHBOR_FLAG_STATIC) ?
19101 (u8 *) "static" : (u8 *) "dynamic"));
19103 vat_json_object_add_string_copy (node, "link_layer",
19104 format (0, "%U", format_vl_api_mac_address,
19105 &mp->neighbor.mac_address));
19106 vat_json_object_add_address (node, "ip", &mp->neighbor.ip_address);
19110 api_ip_neighbor_dump (vat_main_t * vam)
19112 unformat_input_t *i = vam->input;
19113 vl_api_ip_neighbor_dump_t *mp;
19114 vl_api_control_ping_t *mp_ping;
19116 u32 sw_if_index = ~0;
19119 /* Parse args required to build the message */
19120 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19122 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19124 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19126 else if (unformat (i, "ip6"))
19132 if (sw_if_index == ~0)
19134 errmsg ("missing interface name or sw_if_index");
19138 M (IP_NEIGHBOR_DUMP, mp);
19139 mp->is_ipv6 = (u8) is_ipv6;
19140 mp->sw_if_index = ntohl (sw_if_index);
19143 /* Use a control ping for synchronization */
19144 MPING (CONTROL_PING, mp_ping);
19151 #define vl_api_ip_route_details_t_endian vl_noop_handler
19152 #define vl_api_ip_route_details_t_print vl_noop_handler
19155 vl_api_ip_route_details_t_handler (vl_api_ip_route_details_t * mp)
19157 vat_main_t *vam = &vat_main;
19158 u8 count = mp->route.n_paths;
19159 vl_api_fib_path_t *fp;
19163 "table-id %d, prefix %U/%d",
19164 ntohl (mp->route.table_id),
19165 format_ip46_address, mp->route.prefix.address, mp->route.prefix.len);
19166 for (i = 0; i < count; i++)
19168 fp = &mp->route.paths[i];
19170 vl_api_fib_path_print (vam, fp);
19175 static void vl_api_ip_route_details_t_handler_json
19176 (vl_api_ip_route_details_t * mp)
19178 vat_main_t *vam = &vat_main;
19179 u8 count = mp->route.n_paths;
19180 vat_json_node_t *node = NULL;
19181 struct in_addr ip4;
19182 struct in6_addr ip6;
19183 vl_api_fib_path_t *fp;
19186 if (VAT_JSON_ARRAY != vam->json_tree.type)
19188 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19189 vat_json_init_array (&vam->json_tree);
19191 node = vat_json_array_add (&vam->json_tree);
19193 vat_json_init_object (node);
19194 vat_json_object_add_uint (node, "table", ntohl (mp->route.table_id));
19195 if (ADDRESS_IP6 == mp->route.prefix.address.af)
19197 clib_memcpy (&ip6, &mp->route.prefix.address.un.ip6, sizeof (ip6));
19198 vat_json_object_add_ip6 (node, "prefix", ip6);
19202 clib_memcpy (&ip4, &mp->route.prefix.address.un.ip4, sizeof (ip4));
19203 vat_json_object_add_ip4 (node, "prefix", ip4);
19205 vat_json_object_add_uint (node, "mask_length", mp->route.prefix.len);
19206 vat_json_object_add_uint (node, "path_count", count);
19207 for (i = 0; i < count; i++)
19209 fp = &mp->route.paths[i];
19210 vl_api_mpls_fib_path_json_print (node, fp);
19215 api_ip_route_dump (vat_main_t * vam)
19217 unformat_input_t *input = vam->input;
19218 vl_api_ip_route_dump_t *mp;
19219 vl_api_control_ping_t *mp_ping;
19225 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19227 if (unformat (input, "table_id %d", &table_id))
19229 else if (unformat (input, "ip6"))
19231 else if (unformat (input, "ip4"))
19236 if (table_id == ~0)
19238 errmsg ("missing table id");
19242 M (IP_ROUTE_DUMP, mp);
19244 mp->table.table_id = table_id;
19245 mp->table.is_ip6 = is_ip6;
19249 /* Use a control ping for synchronization */
19250 MPING (CONTROL_PING, mp_ping);
19258 api_classify_table_ids (vat_main_t * vam)
19260 vl_api_classify_table_ids_t *mp;
19263 /* Construct the API message */
19264 M (CLASSIFY_TABLE_IDS, mp);
19273 api_classify_table_by_interface (vat_main_t * vam)
19275 unformat_input_t *input = vam->input;
19276 vl_api_classify_table_by_interface_t *mp;
19278 u32 sw_if_index = ~0;
19280 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19282 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19284 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19289 if (sw_if_index == ~0)
19291 errmsg ("missing interface name or sw_if_index");
19295 /* Construct the API message */
19296 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
19298 mp->sw_if_index = ntohl (sw_if_index);
19306 api_classify_table_info (vat_main_t * vam)
19308 unformat_input_t *input = vam->input;
19309 vl_api_classify_table_info_t *mp;
19313 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19315 if (unformat (input, "table_id %d", &table_id))
19320 if (table_id == ~0)
19322 errmsg ("missing table id");
19326 /* Construct the API message */
19327 M (CLASSIFY_TABLE_INFO, mp);
19329 mp->table_id = ntohl (table_id);
19337 api_classify_session_dump (vat_main_t * vam)
19339 unformat_input_t *input = vam->input;
19340 vl_api_classify_session_dump_t *mp;
19341 vl_api_control_ping_t *mp_ping;
19345 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19347 if (unformat (input, "table_id %d", &table_id))
19352 if (table_id == ~0)
19354 errmsg ("missing table id");
19358 /* Construct the API message */
19359 M (CLASSIFY_SESSION_DUMP, mp);
19361 mp->table_id = ntohl (table_id);
19364 /* Use a control ping for synchronization */
19365 MPING (CONTROL_PING, mp_ping);
19373 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
19375 vat_main_t *vam = &vat_main;
19377 print (vam->ofp, "collector_address %U, collector_port %d, "
19378 "src_address %U, vrf_id %d, path_mtu %u, "
19379 "template_interval %u, udp_checksum %d",
19380 format_ip4_address, mp->collector_address,
19381 ntohs (mp->collector_port),
19382 format_ip4_address, mp->src_address,
19383 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
19384 ntohl (mp->template_interval), mp->udp_checksum);
19387 vam->result_ready = 1;
19391 vl_api_ipfix_exporter_details_t_handler_json
19392 (vl_api_ipfix_exporter_details_t * mp)
19394 vat_main_t *vam = &vat_main;
19395 vat_json_node_t node;
19396 struct in_addr collector_address;
19397 struct in_addr src_address;
19399 vat_json_init_object (&node);
19400 clib_memcpy (&collector_address, &mp->collector_address,
19401 sizeof (collector_address));
19402 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
19403 vat_json_object_add_uint (&node, "collector_port",
19404 ntohs (mp->collector_port));
19405 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
19406 vat_json_object_add_ip4 (&node, "src_address", src_address);
19407 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
19408 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
19409 vat_json_object_add_uint (&node, "template_interval",
19410 ntohl (mp->template_interval));
19411 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
19413 vat_json_print (vam->ofp, &node);
19414 vat_json_free (&node);
19416 vam->result_ready = 1;
19420 api_ipfix_exporter_dump (vat_main_t * vam)
19422 vl_api_ipfix_exporter_dump_t *mp;
19425 /* Construct the API message */
19426 M (IPFIX_EXPORTER_DUMP, mp);
19435 api_ipfix_classify_stream_dump (vat_main_t * vam)
19437 vl_api_ipfix_classify_stream_dump_t *mp;
19440 /* Construct the API message */
19441 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
19452 vl_api_ipfix_classify_stream_details_t_handler
19453 (vl_api_ipfix_classify_stream_details_t * mp)
19455 vat_main_t *vam = &vat_main;
19456 print (vam->ofp, "domain_id %d, src_port %d",
19457 ntohl (mp->domain_id), ntohs (mp->src_port));
19459 vam->result_ready = 1;
19463 vl_api_ipfix_classify_stream_details_t_handler_json
19464 (vl_api_ipfix_classify_stream_details_t * mp)
19466 vat_main_t *vam = &vat_main;
19467 vat_json_node_t node;
19469 vat_json_init_object (&node);
19470 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
19471 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
19473 vat_json_print (vam->ofp, &node);
19474 vat_json_free (&node);
19476 vam->result_ready = 1;
19480 api_ipfix_classify_table_dump (vat_main_t * vam)
19482 vl_api_ipfix_classify_table_dump_t *mp;
19483 vl_api_control_ping_t *mp_ping;
19486 if (!vam->json_output)
19488 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
19489 "transport_protocol");
19492 /* Construct the API message */
19493 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
19498 /* Use a control ping for synchronization */
19499 MPING (CONTROL_PING, mp_ping);
19507 vl_api_ipfix_classify_table_details_t_handler
19508 (vl_api_ipfix_classify_table_details_t * mp)
19510 vat_main_t *vam = &vat_main;
19511 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
19512 mp->transport_protocol);
19516 vl_api_ipfix_classify_table_details_t_handler_json
19517 (vl_api_ipfix_classify_table_details_t * mp)
19519 vat_json_node_t *node = NULL;
19520 vat_main_t *vam = &vat_main;
19522 if (VAT_JSON_ARRAY != vam->json_tree.type)
19524 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19525 vat_json_init_array (&vam->json_tree);
19528 node = vat_json_array_add (&vam->json_tree);
19529 vat_json_init_object (node);
19531 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
19532 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
19533 vat_json_object_add_uint (node, "transport_protocol",
19534 mp->transport_protocol);
19538 api_sw_interface_span_enable_disable (vat_main_t * vam)
19540 unformat_input_t *i = vam->input;
19541 vl_api_sw_interface_span_enable_disable_t *mp;
19542 u32 src_sw_if_index = ~0;
19543 u32 dst_sw_if_index = ~0;
19548 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19551 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
19553 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
19557 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
19559 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
19561 else if (unformat (i, "disable"))
19563 else if (unformat (i, "rx"))
19565 else if (unformat (i, "tx"))
19567 else if (unformat (i, "both"))
19569 else if (unformat (i, "l2"))
19575 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
19577 mp->sw_if_index_from = htonl (src_sw_if_index);
19578 mp->sw_if_index_to = htonl (dst_sw_if_index);
19588 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
19591 vat_main_t *vam = &vat_main;
19592 u8 *sw_if_from_name = 0;
19593 u8 *sw_if_to_name = 0;
19594 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19595 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19596 char *states[] = { "none", "rx", "tx", "both" };
19600 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19602 if ((u32) p->value[0] == sw_if_index_from)
19604 sw_if_from_name = (u8 *)(p->key);
19608 if ((u32) p->value[0] == sw_if_index_to)
19610 sw_if_to_name = (u8 *)(p->key);
19611 if (sw_if_from_name)
19616 print (vam->ofp, "%20s => %20s (%s) %s",
19617 sw_if_from_name, sw_if_to_name, states[mp->state],
19618 mp->is_l2 ? "l2" : "device");
19622 vl_api_sw_interface_span_details_t_handler_json
19623 (vl_api_sw_interface_span_details_t * mp)
19625 vat_main_t *vam = &vat_main;
19626 vat_json_node_t *node = NULL;
19627 u8 *sw_if_from_name = 0;
19628 u8 *sw_if_to_name = 0;
19629 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19630 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19634 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19636 if ((u32) p->value[0] == sw_if_index_from)
19638 sw_if_from_name = (u8 *)(p->key);
19642 if ((u32) p->value[0] == sw_if_index_to)
19644 sw_if_to_name = (u8 *)(p->key);
19645 if (sw_if_from_name)
19651 if (VAT_JSON_ARRAY != vam->json_tree.type)
19653 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19654 vat_json_init_array (&vam->json_tree);
19656 node = vat_json_array_add (&vam->json_tree);
19658 vat_json_init_object (node);
19659 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
19660 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
19661 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
19662 if (0 != sw_if_to_name)
19664 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
19666 vat_json_object_add_uint (node, "state", mp->state);
19667 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
19671 api_sw_interface_span_dump (vat_main_t * vam)
19673 unformat_input_t *input = vam->input;
19674 vl_api_sw_interface_span_dump_t *mp;
19675 vl_api_control_ping_t *mp_ping;
19679 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19681 if (unformat (input, "l2"))
19687 M (SW_INTERFACE_SPAN_DUMP, mp);
19691 /* Use a control ping for synchronization */
19692 MPING (CONTROL_PING, mp_ping);
19700 api_pg_create_interface (vat_main_t * vam)
19702 unformat_input_t *input = vam->input;
19703 vl_api_pg_create_interface_t *mp;
19705 u32 if_id = ~0, gso_size = 0;
19706 u8 gso_enabled = 0;
19708 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19710 if (unformat (input, "if_id %d", &if_id))
19712 else if (unformat (input, "gso-enabled"))
19715 if (unformat (input, "gso-size %u", &gso_size))
19719 errmsg ("missing gso-size");
19728 errmsg ("missing pg interface index");
19732 /* Construct the API message */
19733 M (PG_CREATE_INTERFACE, mp);
19735 mp->interface_id = ntohl (if_id);
19736 mp->gso_enabled = gso_enabled;
19744 api_pg_capture (vat_main_t * vam)
19746 unformat_input_t *input = vam->input;
19747 vl_api_pg_capture_t *mp;
19752 u8 pcap_file_set = 0;
19755 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19757 if (unformat (input, "if_id %d", &if_id))
19759 else if (unformat (input, "pcap %s", &pcap_file))
19761 else if (unformat (input, "count %d", &count))
19763 else if (unformat (input, "disable"))
19770 errmsg ("missing pg interface index");
19773 if (pcap_file_set > 0)
19775 if (vec_len (pcap_file) > 255)
19777 errmsg ("pcap file name is too long");
19782 u32 name_len = vec_len (pcap_file);
19783 /* Construct the API message */
19784 M (PG_CAPTURE, mp);
19786 mp->interface_id = ntohl (if_id);
19787 mp->is_enabled = enable;
19788 mp->count = ntohl (count);
19789 mp->pcap_name_length = ntohl (name_len);
19790 if (pcap_file_set != 0)
19792 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
19794 vec_free (pcap_file);
19802 api_pg_enable_disable (vat_main_t * vam)
19804 unformat_input_t *input = vam->input;
19805 vl_api_pg_enable_disable_t *mp;
19808 u8 stream_name_set = 0;
19809 u8 *stream_name = 0;
19811 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19813 if (unformat (input, "stream %s", &stream_name))
19814 stream_name_set = 1;
19815 else if (unformat (input, "disable"))
19821 if (stream_name_set > 0)
19823 if (vec_len (stream_name) > 255)
19825 errmsg ("stream name too long");
19830 u32 name_len = vec_len (stream_name);
19831 /* Construct the API message */
19832 M (PG_ENABLE_DISABLE, mp);
19834 mp->is_enabled = enable;
19835 if (stream_name_set != 0)
19837 mp->stream_name_length = ntohl (name_len);
19838 clib_memcpy (mp->stream_name, stream_name, name_len);
19840 vec_free (stream_name);
19848 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
19850 unformat_input_t *input = vam->input;
19851 vl_api_ip_source_and_port_range_check_add_del_t *mp;
19853 u16 *low_ports = 0;
19854 u16 *high_ports = 0;
19857 vl_api_prefix_t prefix;
19864 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19866 if (unformat (input, "%U", unformat_vl_api_prefix, &prefix))
19868 else if (unformat (input, "vrf %d", &vrf_id))
19870 else if (unformat (input, "del"))
19872 else if (unformat (input, "port %d", &tmp))
19874 if (tmp == 0 || tmp > 65535)
19876 errmsg ("port %d out of range", tmp);
19880 this_hi = this_low + 1;
19881 vec_add1 (low_ports, this_low);
19882 vec_add1 (high_ports, this_hi);
19884 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
19886 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
19888 errmsg ("incorrect range parameters");
19892 /* Note: in debug CLI +1 is added to high before
19893 passing to real fn that does "the work"
19894 (ip_source_and_port_range_check_add_del).
19895 This fn is a wrapper around the binary API fn a
19896 control plane will call, which expects this increment
19897 to have occurred. Hence letting the binary API control
19898 plane fn do the increment for consistency between VAT
19899 and other control planes.
19902 vec_add1 (low_ports, this_low);
19903 vec_add1 (high_ports, this_hi);
19909 if (prefix_set == 0)
19911 errmsg ("<address>/<mask> not specified");
19917 errmsg ("VRF ID required, not specified");
19924 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
19928 if (vec_len (low_ports) == 0)
19930 errmsg ("At least one port or port range required");
19934 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
19936 mp->is_add = is_add;
19938 clib_memcpy (&mp->prefix, &prefix, sizeof (prefix));
19940 mp->number_of_ranges = vec_len (low_ports);
19942 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
19943 vec_free (low_ports);
19945 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
19946 vec_free (high_ports);
19948 mp->vrf_id = ntohl (vrf_id);
19956 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
19958 unformat_input_t *input = vam->input;
19959 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
19960 u32 sw_if_index = ~0;
19962 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
19963 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
19967 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19969 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19971 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19973 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
19975 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
19977 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
19979 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
19981 else if (unformat (input, "del"))
19987 if (sw_if_index == ~0)
19989 errmsg ("Interface required but not specified");
19995 errmsg ("VRF ID required but not specified");
19999 if (tcp_out_vrf_id == 0
20000 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
20003 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
20007 /* Construct the API message */
20008 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
20010 mp->sw_if_index = ntohl (sw_if_index);
20011 mp->is_add = is_add;
20012 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
20013 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
20014 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
20015 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
20020 /* Wait for a reply... */
20026 api_set_punt (vat_main_t * vam)
20028 unformat_input_t *i = vam->input;
20029 vl_api_address_family_t af;
20030 vl_api_set_punt_t *mp;
20036 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20038 if (unformat (i, "%U", unformat_vl_api_address_family, &af))
20040 else if (unformat (i, "protocol %d", &protocol))
20042 else if (unformat (i, "port %d", &port))
20044 else if (unformat (i, "del"))
20048 clib_warning ("parse error '%U'", format_unformat_error, i);
20055 mp->is_add = (u8) is_add;
20056 mp->punt.type = PUNT_API_TYPE_L4;
20057 mp->punt.punt.l4.af = af;
20058 mp->punt.punt.l4.protocol = (u8) protocol;
20059 mp->punt.punt.l4.port = htons ((u16) port);
20067 api_delete_subif (vat_main_t * vam)
20069 unformat_input_t *i = vam->input;
20070 vl_api_delete_subif_t *mp;
20071 u32 sw_if_index = ~0;
20074 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20076 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20078 if (unformat (i, "sw_if_index %d", &sw_if_index))
20084 if (sw_if_index == ~0)
20086 errmsg ("missing sw_if_index");
20090 /* Construct the API message */
20091 M (DELETE_SUBIF, mp);
20092 mp->sw_if_index = ntohl (sw_if_index);
20099 #define foreach_pbb_vtr_op \
20100 _("disable", L2_VTR_DISABLED) \
20101 _("pop", L2_VTR_POP_2) \
20102 _("push", L2_VTR_PUSH_2)
20105 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
20107 unformat_input_t *i = vam->input;
20108 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
20109 u32 sw_if_index = ~0, vtr_op = ~0;
20110 u16 outer_tag = ~0;
20111 u8 dmac[6], smac[6];
20112 u8 dmac_set = 0, smac_set = 0;
20118 /* Shut up coverity */
20119 clib_memset (dmac, 0, sizeof (dmac));
20120 clib_memset (smac, 0, sizeof (smac));
20122 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20124 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20126 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20128 else if (unformat (i, "vtr_op %d", &vtr_op))
20130 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
20133 else if (unformat (i, "translate_pbb_stag"))
20135 if (unformat (i, "%d", &tmp))
20137 vtr_op = L2_VTR_TRANSLATE_2_1;
20143 ("translate_pbb_stag operation requires outer tag definition");
20147 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
20149 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
20151 else if (unformat (i, "sid %d", &sid))
20153 else if (unformat (i, "vlanid %d", &tmp))
20157 clib_warning ("parse error '%U'", format_unformat_error, i);
20162 if ((sw_if_index == ~0) || (vtr_op == ~0))
20164 errmsg ("missing sw_if_index or vtr operation");
20167 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
20168 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
20171 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
20175 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
20176 mp->sw_if_index = ntohl (sw_if_index);
20177 mp->vtr_op = ntohl (vtr_op);
20178 mp->outer_tag = ntohs (outer_tag);
20179 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
20180 clib_memcpy (mp->b_smac, smac, sizeof (smac));
20181 mp->b_vlanid = ntohs (vlanid);
20182 mp->i_sid = ntohl (sid);
20190 api_flow_classify_set_interface (vat_main_t * vam)
20192 unformat_input_t *i = vam->input;
20193 vl_api_flow_classify_set_interface_t *mp;
20195 int sw_if_index_set;
20196 u32 ip4_table_index = ~0;
20197 u32 ip6_table_index = ~0;
20201 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20203 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20204 sw_if_index_set = 1;
20205 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20206 sw_if_index_set = 1;
20207 else if (unformat (i, "del"))
20209 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20211 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20215 clib_warning ("parse error '%U'", format_unformat_error, i);
20220 if (sw_if_index_set == 0)
20222 errmsg ("missing interface name or sw_if_index");
20226 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
20228 mp->sw_if_index = ntohl (sw_if_index);
20229 mp->ip4_table_index = ntohl (ip4_table_index);
20230 mp->ip6_table_index = ntohl (ip6_table_index);
20231 mp->is_add = is_add;
20239 api_flow_classify_dump (vat_main_t * vam)
20241 unformat_input_t *i = vam->input;
20242 vl_api_flow_classify_dump_t *mp;
20243 vl_api_control_ping_t *mp_ping;
20244 u8 type = FLOW_CLASSIFY_N_TABLES;
20247 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
20251 errmsg ("classify table type must be specified");
20255 if (!vam->json_output)
20257 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20260 M (FLOW_CLASSIFY_DUMP, mp);
20265 /* Use a control ping for synchronization */
20266 MPING (CONTROL_PING, mp_ping);
20269 /* Wait for a reply... */
20275 api_feature_enable_disable (vat_main_t * vam)
20277 unformat_input_t *i = vam->input;
20278 vl_api_feature_enable_disable_t *mp;
20280 u8 *feature_name = 0;
20281 u32 sw_if_index = ~0;
20285 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20287 if (unformat (i, "arc_name %s", &arc_name))
20289 else if (unformat (i, "feature_name %s", &feature_name))
20292 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20294 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20296 else if (unformat (i, "disable"))
20304 errmsg ("missing arc name");
20307 if (vec_len (arc_name) > 63)
20309 errmsg ("arc name too long");
20312 if (feature_name == 0)
20314 errmsg ("missing feature name");
20317 if (vec_len (feature_name) > 63)
20319 errmsg ("feature name too long");
20322 if (sw_if_index == ~0)
20324 errmsg ("missing interface name or sw_if_index");
20328 /* Construct the API message */
20329 M (FEATURE_ENABLE_DISABLE, mp);
20330 mp->sw_if_index = ntohl (sw_if_index);
20331 mp->enable = enable;
20332 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
20333 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
20334 vec_free (arc_name);
20335 vec_free (feature_name);
20343 api_sw_interface_tag_add_del (vat_main_t * vam)
20345 unformat_input_t *i = vam->input;
20346 vl_api_sw_interface_tag_add_del_t *mp;
20347 u32 sw_if_index = ~0;
20352 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20354 if (unformat (i, "tag %s", &tag))
20356 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20358 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20360 else if (unformat (i, "del"))
20366 if (sw_if_index == ~0)
20368 errmsg ("missing interface name or sw_if_index");
20372 if (enable && (tag == 0))
20374 errmsg ("no tag specified");
20378 /* Construct the API message */
20379 M (SW_INTERFACE_TAG_ADD_DEL, mp);
20380 mp->sw_if_index = ntohl (sw_if_index);
20381 mp->is_add = enable;
20383 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
20391 static void vl_api_l2_xconnect_details_t_handler
20392 (vl_api_l2_xconnect_details_t * mp)
20394 vat_main_t *vam = &vat_main;
20396 print (vam->ofp, "%15d%15d",
20397 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
20400 static void vl_api_l2_xconnect_details_t_handler_json
20401 (vl_api_l2_xconnect_details_t * mp)
20403 vat_main_t *vam = &vat_main;
20404 vat_json_node_t *node = NULL;
20406 if (VAT_JSON_ARRAY != vam->json_tree.type)
20408 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20409 vat_json_init_array (&vam->json_tree);
20411 node = vat_json_array_add (&vam->json_tree);
20413 vat_json_init_object (node);
20414 vat_json_object_add_uint (node, "rx_sw_if_index",
20415 ntohl (mp->rx_sw_if_index));
20416 vat_json_object_add_uint (node, "tx_sw_if_index",
20417 ntohl (mp->tx_sw_if_index));
20421 api_l2_xconnect_dump (vat_main_t * vam)
20423 vl_api_l2_xconnect_dump_t *mp;
20424 vl_api_control_ping_t *mp_ping;
20427 if (!vam->json_output)
20429 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
20432 M (L2_XCONNECT_DUMP, mp);
20436 /* Use a control ping for synchronization */
20437 MPING (CONTROL_PING, mp_ping);
20445 api_hw_interface_set_mtu (vat_main_t * vam)
20447 unformat_input_t *i = vam->input;
20448 vl_api_hw_interface_set_mtu_t *mp;
20449 u32 sw_if_index = ~0;
20453 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20455 if (unformat (i, "mtu %d", &mtu))
20457 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20459 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20465 if (sw_if_index == ~0)
20467 errmsg ("missing interface name or sw_if_index");
20473 errmsg ("no mtu specified");
20477 /* Construct the API message */
20478 M (HW_INTERFACE_SET_MTU, mp);
20479 mp->sw_if_index = ntohl (sw_if_index);
20480 mp->mtu = ntohs ((u16) mtu);
20488 api_p2p_ethernet_add (vat_main_t * vam)
20490 unformat_input_t *i = vam->input;
20491 vl_api_p2p_ethernet_add_t *mp;
20492 u32 parent_if_index = ~0;
20498 clib_memset (remote_mac, 0, sizeof (remote_mac));
20499 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20501 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20503 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20507 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20509 else if (unformat (i, "sub_id %d", &sub_id))
20513 clib_warning ("parse error '%U'", format_unformat_error, i);
20518 if (parent_if_index == ~0)
20520 errmsg ("missing interface name or sw_if_index");
20525 errmsg ("missing remote mac address");
20530 errmsg ("missing sub-interface id");
20534 M (P2P_ETHERNET_ADD, mp);
20535 mp->parent_if_index = ntohl (parent_if_index);
20536 mp->subif_id = ntohl (sub_id);
20537 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20545 api_p2p_ethernet_del (vat_main_t * vam)
20547 unformat_input_t *i = vam->input;
20548 vl_api_p2p_ethernet_del_t *mp;
20549 u32 parent_if_index = ~0;
20554 clib_memset (remote_mac, 0, sizeof (remote_mac));
20555 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20557 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20559 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20563 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20567 clib_warning ("parse error '%U'", format_unformat_error, i);
20572 if (parent_if_index == ~0)
20574 errmsg ("missing interface name or sw_if_index");
20579 errmsg ("missing remote mac address");
20583 M (P2P_ETHERNET_DEL, mp);
20584 mp->parent_if_index = ntohl (parent_if_index);
20585 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20593 api_lldp_config (vat_main_t * vam)
20595 unformat_input_t *i = vam->input;
20596 vl_api_lldp_config_t *mp;
20598 int tx_interval = 0;
20599 u8 *sys_name = NULL;
20602 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20604 if (unformat (i, "system-name %s", &sys_name))
20606 else if (unformat (i, "tx-hold %d", &tx_hold))
20608 else if (unformat (i, "tx-interval %d", &tx_interval))
20612 clib_warning ("parse error '%U'", format_unformat_error, i);
20617 vec_add1 (sys_name, 0);
20619 M (LLDP_CONFIG, mp);
20620 mp->tx_hold = htonl (tx_hold);
20621 mp->tx_interval = htonl (tx_interval);
20622 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
20623 vec_free (sys_name);
20631 api_sw_interface_set_lldp (vat_main_t * vam)
20633 unformat_input_t *i = vam->input;
20634 vl_api_sw_interface_set_lldp_t *mp;
20635 u32 sw_if_index = ~0;
20637 u8 *port_desc = NULL, *mgmt_oid = NULL;
20638 ip4_address_t ip4_addr;
20639 ip6_address_t ip6_addr;
20642 clib_memset (&ip4_addr, 0, sizeof (ip4_addr));
20643 clib_memset (&ip6_addr, 0, sizeof (ip6_addr));
20645 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20647 if (unformat (i, "disable"))
20650 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20652 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20654 else if (unformat (i, "port-desc %s", &port_desc))
20656 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
20658 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
20660 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
20666 if (sw_if_index == ~0)
20668 errmsg ("missing interface name or sw_if_index");
20672 /* Construct the API message */
20673 vec_add1 (port_desc, 0);
20674 vec_add1 (mgmt_oid, 0);
20675 M (SW_INTERFACE_SET_LLDP, mp);
20676 mp->sw_if_index = ntohl (sw_if_index);
20677 mp->enable = enable;
20678 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
20679 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
20680 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
20681 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
20682 vec_free (port_desc);
20683 vec_free (mgmt_oid);
20691 api_tcp_configure_src_addresses (vat_main_t * vam)
20693 vl_api_tcp_configure_src_addresses_t *mp;
20694 unformat_input_t *i = vam->input;
20695 ip4_address_t v4first, v4last;
20696 ip6_address_t v6first, v6last;
20701 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20703 if (unformat (i, "%U - %U",
20704 unformat_ip4_address, &v4first,
20705 unformat_ip4_address, &v4last))
20709 errmsg ("one range per message (range already set)");
20714 else if (unformat (i, "%U - %U",
20715 unformat_ip6_address, &v6first,
20716 unformat_ip6_address, &v6last))
20720 errmsg ("one range per message (range already set)");
20725 else if (unformat (i, "vrf %d", &vrf_id))
20731 if (range_set == 0)
20733 errmsg ("address range not set");
20737 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
20738 mp->vrf_id = ntohl (vrf_id);
20740 if (range_set == 2)
20743 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
20744 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
20749 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
20750 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
20757 static void vl_api_app_namespace_add_del_reply_t_handler
20758 (vl_api_app_namespace_add_del_reply_t * mp)
20760 vat_main_t *vam = &vat_main;
20761 i32 retval = ntohl (mp->retval);
20762 if (vam->async_mode)
20764 vam->async_errors += (retval < 0);
20768 vam->retval = retval;
20770 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
20771 vam->result_ready = 1;
20775 static void vl_api_app_namespace_add_del_reply_t_handler_json
20776 (vl_api_app_namespace_add_del_reply_t * mp)
20778 vat_main_t *vam = &vat_main;
20779 vat_json_node_t node;
20781 vat_json_init_object (&node);
20782 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
20783 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
20785 vat_json_print (vam->ofp, &node);
20786 vat_json_free (&node);
20788 vam->retval = ntohl (mp->retval);
20789 vam->result_ready = 1;
20793 api_app_namespace_add_del (vat_main_t * vam)
20795 vl_api_app_namespace_add_del_t *mp;
20796 unformat_input_t *i = vam->input;
20797 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
20798 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
20802 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20804 if (unformat (i, "id %_%v%_", &ns_id))
20806 else if (unformat (i, "secret %lu", &secret))
20808 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20809 sw_if_index_set = 1;
20810 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
20812 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
20817 if (!ns_id || !secret_set || !sw_if_index_set)
20819 errmsg ("namespace id, secret and sw_if_index must be set");
20822 if (vec_len (ns_id) > 64)
20824 errmsg ("namespace id too long");
20827 M (APP_NAMESPACE_ADD_DEL, mp);
20829 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
20830 mp->namespace_id_len = vec_len (ns_id);
20831 mp->secret = clib_host_to_net_u64 (secret);
20832 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
20833 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
20834 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
20842 api_sock_init_shm (vat_main_t * vam)
20844 #if VPP_API_TEST_BUILTIN == 0
20845 unformat_input_t *i = vam->input;
20846 vl_api_shm_elem_config_t *config = 0;
20847 u64 size = 64 << 20;
20850 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20852 if (unformat (i, "size %U", unformat_memory_size, &size))
20859 * Canned custom ring allocator config.
20860 * Should probably parse all of this
20862 vec_validate (config, 6);
20863 config[0].type = VL_API_VLIB_RING;
20864 config[0].size = 256;
20865 config[0].count = 32;
20867 config[1].type = VL_API_VLIB_RING;
20868 config[1].size = 1024;
20869 config[1].count = 16;
20871 config[2].type = VL_API_VLIB_RING;
20872 config[2].size = 4096;
20873 config[2].count = 2;
20875 config[3].type = VL_API_CLIENT_RING;
20876 config[3].size = 256;
20877 config[3].count = 32;
20879 config[4].type = VL_API_CLIENT_RING;
20880 config[4].size = 1024;
20881 config[4].count = 16;
20883 config[5].type = VL_API_CLIENT_RING;
20884 config[5].size = 4096;
20885 config[5].count = 2;
20887 config[6].type = VL_API_QUEUE;
20888 config[6].count = 128;
20889 config[6].size = sizeof (uword);
20891 rv = vl_socket_client_init_shm (config, 1 /* want_pthread */ );
20893 vam->client_index_invalid = 1;
20901 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
20903 vat_main_t *vam = &vat_main;
20908 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
20909 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
20910 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
20911 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
20912 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
20913 clib_net_to_host_u32 (mp->action_index), mp->tag);
20918 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
20919 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
20920 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
20921 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
20922 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
20923 clib_net_to_host_u32 (mp->action_index), mp->tag);
20928 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
20931 vat_main_t *vam = &vat_main;
20932 vat_json_node_t *node = NULL;
20933 struct in6_addr ip6;
20934 struct in_addr ip4;
20936 if (VAT_JSON_ARRAY != vam->json_tree.type)
20938 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20939 vat_json_init_array (&vam->json_tree);
20941 node = vat_json_array_add (&vam->json_tree);
20942 vat_json_init_object (node);
20944 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
20945 vat_json_object_add_uint (node, "appns_index",
20946 clib_net_to_host_u32 (mp->appns_index));
20947 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
20948 vat_json_object_add_uint (node, "scope", mp->scope);
20949 vat_json_object_add_uint (node, "action_index",
20950 clib_net_to_host_u32 (mp->action_index));
20951 vat_json_object_add_uint (node, "lcl_port",
20952 clib_net_to_host_u16 (mp->lcl_port));
20953 vat_json_object_add_uint (node, "rmt_port",
20954 clib_net_to_host_u16 (mp->rmt_port));
20955 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
20956 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
20957 vat_json_object_add_string_copy (node, "tag", mp->tag);
20960 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
20961 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
20962 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
20963 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
20967 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
20968 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
20969 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
20970 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
20975 api_session_rule_add_del (vat_main_t * vam)
20977 vl_api_session_rule_add_del_t *mp;
20978 unformat_input_t *i = vam->input;
20979 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
20980 u32 appns_index = 0, scope = 0;
20981 ip4_address_t lcl_ip4, rmt_ip4;
20982 ip6_address_t lcl_ip6, rmt_ip6;
20983 u8 is_ip4 = 1, conn_set = 0;
20984 u8 is_add = 1, *tag = 0;
20987 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20989 if (unformat (i, "del"))
20991 else if (unformat (i, "add"))
20993 else if (unformat (i, "proto tcp"))
20995 else if (unformat (i, "proto udp"))
20997 else if (unformat (i, "appns %d", &appns_index))
20999 else if (unformat (i, "scope %d", &scope))
21001 else if (unformat (i, "tag %_%v%_", &tag))
21005 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
21006 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
21014 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
21015 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
21021 else if (unformat (i, "action %d", &action))
21026 if (proto == ~0 || !conn_set || action == ~0)
21028 errmsg ("transport proto, connection and action must be set");
21034 errmsg ("scope should be 0-3");
21038 M (SESSION_RULE_ADD_DEL, mp);
21040 mp->is_ip4 = is_ip4;
21041 mp->transport_proto = proto;
21042 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
21043 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
21044 mp->lcl_plen = lcl_plen;
21045 mp->rmt_plen = rmt_plen;
21046 mp->action_index = clib_host_to_net_u32 (action);
21047 mp->appns_index = clib_host_to_net_u32 (appns_index);
21049 mp->is_add = is_add;
21052 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
21053 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
21057 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
21058 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
21062 clib_memcpy (mp->tag, tag, vec_len (tag));
21072 api_session_rules_dump (vat_main_t * vam)
21074 vl_api_session_rules_dump_t *mp;
21075 vl_api_control_ping_t *mp_ping;
21078 if (!vam->json_output)
21080 print (vam->ofp, "%=20s", "Session Rules");
21083 M (SESSION_RULES_DUMP, mp);
21087 /* Use a control ping for synchronization */
21088 MPING (CONTROL_PING, mp_ping);
21091 /* Wait for a reply... */
21097 api_ip_container_proxy_add_del (vat_main_t * vam)
21099 vl_api_ip_container_proxy_add_del_t *mp;
21100 unformat_input_t *i = vam->input;
21101 u32 sw_if_index = ~0;
21102 vl_api_prefix_t pfx = { };
21106 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21108 if (unformat (i, "del"))
21110 else if (unformat (i, "add"))
21112 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
21114 else if (unformat (i, "sw_if_index %u", &sw_if_index))
21119 if (sw_if_index == ~0 || pfx.len == 0)
21121 errmsg ("address and sw_if_index must be set");
21125 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
21127 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
21128 mp->is_add = is_add;
21129 clib_memcpy (&mp->pfx, &pfx, sizeof (pfx));
21137 api_qos_record_enable_disable (vat_main_t * vam)
21139 unformat_input_t *i = vam->input;
21140 vl_api_qos_record_enable_disable_t *mp;
21141 u32 sw_if_index, qs = 0xff;
21142 u8 sw_if_index_set = 0;
21146 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21148 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21149 sw_if_index_set = 1;
21150 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21151 sw_if_index_set = 1;
21152 else if (unformat (i, "%U", unformat_qos_source, &qs))
21154 else if (unformat (i, "disable"))
21158 clib_warning ("parse error '%U'", format_unformat_error, i);
21163 if (sw_if_index_set == 0)
21165 errmsg ("missing interface name or sw_if_index");
21170 errmsg ("input location must be specified");
21174 M (QOS_RECORD_ENABLE_DISABLE, mp);
21176 mp->record.sw_if_index = ntohl (sw_if_index);
21177 mp->record.input_source = qs;
21178 mp->enable = enable;
21187 q_or_quit (vat_main_t * vam)
21189 #if VPP_API_TEST_BUILTIN == 0
21190 longjmp (vam->jump_buf, 1);
21192 return 0; /* not so much */
21196 q (vat_main_t * vam)
21198 return q_or_quit (vam);
21202 quit (vat_main_t * vam)
21204 return q_or_quit (vam);
21208 comment (vat_main_t * vam)
21214 elog_save (vat_main_t * vam)
21216 #if VPP_API_TEST_BUILTIN == 0
21217 elog_main_t *em = &vam->elog_main;
21218 unformat_input_t *i = vam->input;
21219 char *file, *chroot_file;
21220 clib_error_t *error;
21222 if (!unformat (i, "%s", &file))
21224 errmsg ("expected file name, got `%U'", format_unformat_error, i);
21228 /* It's fairly hard to get "../oopsie" through unformat; just in case */
21229 if (strstr (file, "..") || index (file, '/'))
21231 errmsg ("illegal characters in filename '%s'", file);
21235 chroot_file = (char *) format (0, "/tmp/%s%c", file, 0);
21239 errmsg ("Saving %wd of %wd events to %s",
21240 elog_n_events_in_buffer (em),
21241 elog_buffer_capacity (em), chroot_file);
21243 error = elog_write_file (em, chroot_file, 1 /* flush ring */ );
21244 vec_free (chroot_file);
21247 clib_error_report (error);
21249 errmsg ("Use the vpp event loger...");
21256 elog_setup (vat_main_t * vam)
21258 #if VPP_API_TEST_BUILTIN == 0
21259 elog_main_t *em = &vam->elog_main;
21260 unformat_input_t *i = vam->input;
21261 u32 nevents = 128 << 10;
21263 (void) unformat (i, "nevents %d", &nevents);
21265 elog_init (em, nevents);
21266 vl_api_set_elog_main (em);
21267 vl_api_set_elog_trace_api_messages (1);
21268 errmsg ("Event logger initialized with %u events", nevents);
21270 errmsg ("Use the vpp event loger...");
21276 elog_enable (vat_main_t * vam)
21278 #if VPP_API_TEST_BUILTIN == 0
21279 elog_main_t *em = &vam->elog_main;
21281 elog_enable_disable (em, 1 /* enable */ );
21282 vl_api_set_elog_trace_api_messages (1);
21283 errmsg ("Event logger enabled...");
21285 errmsg ("Use the vpp event loger...");
21291 elog_disable (vat_main_t * vam)
21293 #if VPP_API_TEST_BUILTIN == 0
21294 elog_main_t *em = &vam->elog_main;
21296 elog_enable_disable (em, 0 /* enable */ );
21297 vl_api_set_elog_trace_api_messages (1);
21298 errmsg ("Event logger disabled...");
21300 errmsg ("Use the vpp event loger...");
21306 statseg (vat_main_t * vam)
21308 ssvm_private_t *ssvmp = &vam->stat_segment;
21309 ssvm_shared_header_t *shared_header = ssvmp->sh;
21310 vlib_counter_t **counters;
21311 u64 thread0_index1_packets;
21312 u64 thread0_index1_bytes;
21313 f64 vector_rate, input_rate;
21316 uword *counter_vector_by_name;
21317 if (vam->stat_segment_lockp == 0)
21319 errmsg ("Stat segment not mapped...");
21323 /* look up "/if/rx for sw_if_index 1 as a test */
21325 clib_spinlock_lock (vam->stat_segment_lockp);
21327 counter_vector_by_name = (uword *) shared_header->opaque[1];
21329 p = hash_get_mem (counter_vector_by_name, "/if/rx");
21332 clib_spinlock_unlock (vam->stat_segment_lockp);
21333 errmsg ("/if/tx not found?");
21337 /* Fish per-thread vector of combined counters from shared memory */
21338 counters = (vlib_counter_t **) p[0];
21340 if (vec_len (counters[0]) < 2)
21342 clib_spinlock_unlock (vam->stat_segment_lockp);
21343 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
21347 /* Read thread 0 sw_if_index 1 counter */
21348 thread0_index1_packets = counters[0][1].packets;
21349 thread0_index1_bytes = counters[0][1].bytes;
21351 p = hash_get_mem (counter_vector_by_name, "vector_rate");
21354 clib_spinlock_unlock (vam->stat_segment_lockp);
21355 errmsg ("vector_rate not found?");
21359 vector_rate = *(f64 *) (p[0]);
21360 p = hash_get_mem (counter_vector_by_name, "input_rate");
21363 clib_spinlock_unlock (vam->stat_segment_lockp);
21364 errmsg ("input_rate not found?");
21367 input_rate = *(f64 *) (p[0]);
21369 clib_spinlock_unlock (vam->stat_segment_lockp);
21371 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
21372 vector_rate, input_rate);
21373 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
21374 thread0_index1_packets, thread0_index1_bytes);
21380 cmd_cmp (void *a1, void *a2)
21385 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
21389 help (vat_main_t * vam)
21394 unformat_input_t *i = vam->input;
21397 if (unformat (i, "%s", &name))
21401 vec_add1 (name, 0);
21403 hs = hash_get_mem (vam->help_by_name, name);
21405 print (vam->ofp, "usage: %s %s", name, hs[0]);
21407 print (vam->ofp, "No such msg / command '%s'", name);
21412 print (vam->ofp, "Help is available for the following:");
21415 hash_foreach_pair (p, vam->function_by_name,
21417 vec_add1 (cmds, (u8 *)(p->key));
21421 vec_sort_with_function (cmds, cmd_cmp);
21423 for (j = 0; j < vec_len (cmds); j++)
21424 print (vam->ofp, "%s", cmds[j]);
21431 set (vat_main_t * vam)
21433 u8 *name = 0, *value = 0;
21434 unformat_input_t *i = vam->input;
21436 if (unformat (i, "%s", &name))
21438 /* The input buffer is a vector, not a string. */
21439 value = vec_dup (i->buffer);
21440 vec_delete (value, i->index, 0);
21441 /* Almost certainly has a trailing newline */
21442 if (value[vec_len (value) - 1] == '\n')
21443 value[vec_len (value) - 1] = 0;
21444 /* Make sure it's a proper string, one way or the other */
21445 vec_add1 (value, 0);
21446 (void) clib_macro_set_value (&vam->macro_main,
21447 (char *) name, (char *) value);
21450 errmsg ("usage: set <name> <value>");
21458 unset (vat_main_t * vam)
21462 if (unformat (vam->input, "%s", &name))
21463 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
21464 errmsg ("unset: %s wasn't set", name);
21477 macro_sort_cmp (void *a1, void *a2)
21479 macro_sort_t *s1 = a1;
21480 macro_sort_t *s2 = a2;
21482 return strcmp ((char *) (s1->name), (char *) (s2->name));
21486 dump_macro_table (vat_main_t * vam)
21488 macro_sort_t *sort_me = 0, *sm;
21493 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
21495 vec_add2 (sort_me, sm, 1);
21496 sm->name = (u8 *)(p->key);
21497 sm->value = (u8 *) (p->value[0]);
21501 vec_sort_with_function (sort_me, macro_sort_cmp);
21503 if (vec_len (sort_me))
21504 print (vam->ofp, "%-15s%s", "Name", "Value");
21506 print (vam->ofp, "The macro table is empty...");
21508 for (i = 0; i < vec_len (sort_me); i++)
21509 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
21514 dump_node_table (vat_main_t * vam)
21517 vlib_node_t *node, *next_node;
21519 if (vec_len (vam->graph_nodes) == 0)
21521 print (vam->ofp, "Node table empty, issue get_node_graph...");
21525 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
21527 node = vam->graph_nodes[0][i];
21528 print (vam->ofp, "[%d] %s", i, node->name);
21529 for (j = 0; j < vec_len (node->next_nodes); j++)
21531 if (node->next_nodes[j] != ~0)
21533 next_node = vam->graph_nodes[0][node->next_nodes[j]];
21534 print (vam->ofp, " [%d] %s", j, next_node->name);
21542 value_sort_cmp (void *a1, void *a2)
21544 name_sort_t *n1 = a1;
21545 name_sort_t *n2 = a2;
21547 if (n1->value < n2->value)
21549 if (n1->value > n2->value)
21556 dump_msg_api_table (vat_main_t * vam)
21558 api_main_t *am = &api_main;
21559 name_sort_t *nses = 0, *ns;
21564 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
21566 vec_add2 (nses, ns, 1);
21567 ns->name = (u8 *)(hp->key);
21568 ns->value = (u32) hp->value[0];
21572 vec_sort_with_function (nses, value_sort_cmp);
21574 for (i = 0; i < vec_len (nses); i++)
21575 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
21581 get_msg_id (vat_main_t * vam)
21586 if (unformat (vam->input, "%s", &name_and_crc))
21588 message_index = vl_msg_api_get_msg_index (name_and_crc);
21589 if (message_index == ~0)
21591 print (vam->ofp, " '%s' not found", name_and_crc);
21594 print (vam->ofp, " '%s' has message index %d",
21595 name_and_crc, message_index);
21598 errmsg ("name_and_crc required...");
21603 search_node_table (vat_main_t * vam)
21605 unformat_input_t *line_input = vam->input;
21608 vlib_node_t *node, *next_node;
21611 if (vam->graph_node_index_by_name == 0)
21613 print (vam->ofp, "Node table empty, issue get_node_graph...");
21617 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21619 if (unformat (line_input, "%s", &node_to_find))
21621 vec_add1 (node_to_find, 0);
21622 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
21625 print (vam->ofp, "%s not found...", node_to_find);
21628 node = vam->graph_nodes[0][p[0]];
21629 print (vam->ofp, "[%d] %s", p[0], node->name);
21630 for (j = 0; j < vec_len (node->next_nodes); j++)
21632 if (node->next_nodes[j] != ~0)
21634 next_node = vam->graph_nodes[0][node->next_nodes[j]];
21635 print (vam->ofp, " [%d] %s", j, next_node->name);
21642 clib_warning ("parse error '%U'", format_unformat_error,
21648 vec_free (node_to_find);
21657 script (vat_main_t * vam)
21659 #if (VPP_API_TEST_BUILTIN==0)
21661 char *save_current_file;
21662 unformat_input_t save_input;
21663 jmp_buf save_jump_buf;
21664 u32 save_line_number;
21666 FILE *new_fp, *save_ifp;
21668 if (unformat (vam->input, "%s", &s))
21670 new_fp = fopen ((char *) s, "r");
21673 errmsg ("Couldn't open script file %s", s);
21680 errmsg ("Missing script name");
21684 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
21685 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
21686 save_ifp = vam->ifp;
21687 save_line_number = vam->input_line_number;
21688 save_current_file = (char *) vam->current_file;
21690 vam->input_line_number = 0;
21692 vam->current_file = s;
21695 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
21696 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
21697 vam->ifp = save_ifp;
21698 vam->input_line_number = save_line_number;
21699 vam->current_file = (u8 *) save_current_file;
21704 clib_warning ("use the exec command...");
21710 echo (vat_main_t * vam)
21712 print (vam->ofp, "%v", vam->input->buffer);
21716 /* List of API message constructors, CLI names map to api_xxx */
21717 #define foreach_vpe_api_msg \
21718 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
21719 _(sw_interface_dump,"") \
21720 _(sw_interface_set_flags, \
21721 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
21722 _(sw_interface_add_del_address, \
21723 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
21724 _(sw_interface_set_rx_mode, \
21725 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
21726 _(sw_interface_set_rx_placement, \
21727 "<intfc> | sw_if_index <id> [queue <id>] [worker <id> | main]") \
21728 _(sw_interface_rx_placement_dump, \
21729 "[<intfc> | sw_if_index <id>]") \
21730 _(sw_interface_set_table, \
21731 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
21732 _(sw_interface_set_mpls_enable, \
21733 "<intfc> | sw_if_index [disable | dis]") \
21734 _(sw_interface_set_vpath, \
21735 "<intfc> | sw_if_index <id> enable | disable") \
21736 _(sw_interface_set_vxlan_bypass, \
21737 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21738 _(sw_interface_set_geneve_bypass, \
21739 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21740 _(sw_interface_set_l2_xconnect, \
21741 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
21742 "enable | disable") \
21743 _(sw_interface_set_l2_bridge, \
21744 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
21745 "[shg <split-horizon-group>] [bvi]\n" \
21746 "enable | disable") \
21747 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
21748 _(bridge_domain_add_del, \
21749 "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 <text>] [del]\n") \
21750 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
21752 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
21753 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
21754 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
21756 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21758 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21760 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>] [host-mtu-size <mtu>] [gso | no-gso]") \
21762 "<vpp-if-name> | sw_if_index <id>") \
21763 _(sw_interface_tap_v2_dump, "") \
21764 _(virtio_pci_create, \
21765 "pci-addr <pci-address> [use_random_mac | hw-addr <mac-addr>] [features <hex-value>] [gso-enabled]") \
21766 _(virtio_pci_delete, \
21767 "<vpp-if-name> | sw_if_index <id>") \
21768 _(sw_interface_virtio_pci_dump, "") \
21770 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
21771 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \
21774 "<vpp-if-name> | sw_if_index <id>") \
21776 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
21777 _(bond_detach_slave, \
21778 "sw_if_index <n>") \
21779 _(sw_interface_set_bond_weight, "<intfc> | sw_if_index <nn> weight <value>") \
21780 _(sw_interface_bond_dump, "") \
21781 _(sw_interface_slave_dump, \
21782 "<vpp-if-name> | sw_if_index <id>") \
21783 _(ip_table_add_del, \
21784 "table <n> [ipv6] [add | del]\n") \
21785 _(ip_route_add_del, \
21786 "<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
21787 "[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
21788 "[weight <n>] [drop] [local] [classify <n>] [out-label <n>]\n" \
21789 "[multipath] [count <n>] [del]") \
21790 _(ip_mroute_add_del, \
21791 "<src> <grp>/<mask> [table-id <n>]\n" \
21792 "[<intfc> | sw_if_index <id>] [local] [del]") \
21793 _(mpls_table_add_del, \
21794 "table <n> [add | del]\n") \
21795 _(mpls_route_add_del, \
21796 "<label> <eos> via <addr | next-hop-table <n> | via-label <n> |\n" \
21797 "lookup-ip4-table <n> | lookup-in-ip6-table <n> |\n" \
21798 "l2-input-on <intfc> | l2-input-on sw_if_index <id>>\n" \
21799 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>] [weight <n>]\n" \
21800 "[drop] [local] [classify <n>] [out-label <n>] [multipath]\n" \
21801 "[count <n>] [del]") \
21802 _(mpls_ip_bind_unbind, \
21803 "<label> <addr/len>") \
21804 _(mpls_tunnel_add_del, \
21805 "[add | del <intfc | sw_if_index <id>>] via <addr | via-label <n>>\n" \
21806 "[<intfc> | sw_if_index <id> | next-hop-table <id>]\n" \
21807 "[l2-only] [out-label <n>]") \
21808 _(sr_mpls_policy_add, \
21809 "bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
21810 _(sr_mpls_policy_del, \
21812 _(bier_table_add_del, \
21813 "<label> <sub-domain> <set> <bsl> [del]") \
21814 _(bier_route_add_del, \
21815 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
21816 "[<intfc> | sw_if_index <id>]" \
21817 "[weight <n>] [del] [multipath]") \
21818 _(proxy_arp_add_del, \
21819 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
21820 _(proxy_arp_intfc_enable_disable, \
21821 "<intfc> | sw_if_index <id> enable | disable") \
21822 _(sw_interface_set_unnumbered, \
21823 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
21824 _(ip_neighbor_add_del, \
21825 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
21826 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
21827 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
21828 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
21829 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
21830 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
21831 "[outer_vlan_id_any][inner_vlan_id_any]") \
21832 _(reset_fib, "vrf <n> [ipv6]") \
21833 _(dhcp_proxy_config, \
21834 "svr <v46-address> src <v46-address>\n" \
21835 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
21836 _(dhcp_proxy_set_vss, \
21837 "tbl_id <n> [fib_id <n> oui <n> | vpn_ascii_id <text>] [ipv6] [del]") \
21838 _(dhcp_proxy_dump, "ip6") \
21839 _(dhcp_client_config, \
21840 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
21841 _(set_ip_flow_hash, \
21842 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
21843 _(sw_interface_ip6_enable_disable, \
21844 "<intfc> | sw_if_index <id> enable | disable") \
21845 _(ip6nd_proxy_add_del, \
21846 "<intfc> | sw_if_index <id> <ip6-address>") \
21847 _(ip6nd_proxy_dump, "") \
21848 _(sw_interface_ip6nd_ra_prefix, \
21849 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
21850 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
21851 "[nolink] [isno]") \
21852 _(sw_interface_ip6nd_ra_config, \
21853 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
21854 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
21855 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
21856 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
21857 _(l2_patch_add_del, \
21858 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
21859 "enable | disable") \
21860 _(sr_localsid_add_del, \
21861 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
21862 "fib-table <num> (end.psp) sw_if_index <num>") \
21863 _(classify_add_del_table, \
21864 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
21865 " [del] [del-chain] mask <mask-value>\n" \
21866 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
21867 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
21868 _(classify_add_del_session, \
21869 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
21870 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
21871 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
21872 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
21873 _(classify_set_interface_ip_table, \
21874 "<intfc> | sw_if_index <nn> table <nn>") \
21875 _(classify_set_interface_l2_tables, \
21876 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21877 " [other-table <nn>]") \
21878 _(get_node_index, "node <node-name") \
21879 _(add_node_next, "node <node-name> next <next-node-name>") \
21880 _(l2tpv3_create_tunnel, \
21881 "client_address <ip6-addr> our_address <ip6-addr>\n" \
21882 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
21883 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
21884 _(l2tpv3_set_tunnel_cookies, \
21885 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
21886 "[new_remote_cookie <nn>]\n") \
21887 _(l2tpv3_interface_enable_disable, \
21888 "<intfc> | sw_if_index <nn> enable | disable") \
21889 _(l2tpv3_set_lookup_key, \
21890 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
21891 _(sw_if_l2tpv3_tunnel_dump, "") \
21892 _(vxlan_offload_rx, \
21893 "hw { <interface name> | hw_if_index <nn>} " \
21894 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
21895 _(vxlan_add_del_tunnel, \
21896 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
21897 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
21898 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
21899 _(geneve_add_del_tunnel, \
21900 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
21901 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21902 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
21903 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21904 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21905 _(gre_tunnel_add_del, \
21906 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
21907 "[teb | erspan <session-id>] [del]") \
21908 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21909 _(l2_fib_clear_table, "") \
21910 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
21911 _(l2_interface_vlan_tag_rewrite, \
21912 "<intfc> | sw_if_index <nn> \n" \
21913 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
21914 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
21915 _(create_vhost_user_if, \
21916 "socket <filename> [server] [renumber <dev_instance>] " \
21917 "[disable_mrg_rxbuf] [disable_indirect_desc] [gso] " \
21918 "[mac <mac_address>]") \
21919 _(modify_vhost_user_if, \
21920 "<intfc> | sw_if_index <nn> socket <filename>\n" \
21921 "[server] [renumber <dev_instance>] [gso]") \
21922 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
21923 _(sw_interface_vhost_user_dump, "") \
21924 _(show_version, "") \
21925 _(show_threads, "") \
21926 _(vxlan_gpe_add_del_tunnel, \
21927 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
21928 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21929 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
21930 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
21931 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21932 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
21933 _(interface_name_renumber, \
21934 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
21935 _(input_acl_set_interface, \
21936 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21937 " [l2-table <nn>] [del]") \
21938 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
21939 _(ip_scan_neighbor_enable_disable, "[ip4|ip6|both|disable] [interval <n-min>]\n" \
21940 " [max-time <n-usec>] [max-update <n>] [delay <n-msec>] [stale <n-min>]") \
21941 _(want_ip4_arp_events, "address <ip4-address> [del]") \
21942 _(want_ip6_nd_events, "address <ip6-address> [del]") \
21943 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
21944 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
21945 _(ip_dump, "ipv4 | ipv6") \
21946 _(ipsec_spd_add_del, "spd_id <n> [del]") \
21947 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
21949 _(ipsec_sad_entry_add_del, "sad_id <n> spi <n> crypto_alg <alg>\n" \
21950 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
21951 " integ_alg <alg> integ_key <hex>") \
21952 _(ipsec_spd_entry_add_del, "spd_id <n> priority <n> action <action>\n" \
21953 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
21954 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
21955 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
21956 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
21957 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
21958 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
21959 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
21960 " [instance <n>]") \
21961 _(ipsec_sa_dump, "[sa_id <n>]") \
21962 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
21963 _(delete_loopback,"sw_if_index <nn>") \
21964 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
21965 _(bd_ip_mac_flush, "bd_id <bridge-domain-id>") \
21966 _(bd_ip_mac_dump, "[bd_id] <bridge-domain-id>") \
21967 _(want_interface_events, "enable|disable") \
21968 _(get_first_msg_id, "client <name>") \
21969 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
21970 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
21971 "fib-id <nn> [ip4][ip6][default]") \
21972 _(get_node_graph, " ") \
21973 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
21974 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
21975 _(ioam_disable, "") \
21976 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
21977 " sw_if_index <sw_if_index> p <priority> " \
21978 "w <weight>] [del]") \
21979 _(one_add_del_locator, "locator-set <locator_name> " \
21980 "iface <intf> | sw_if_index <sw_if_index> " \
21981 "p <priority> w <weight> [del]") \
21982 _(one_add_del_local_eid,"vni <vni> eid " \
21983 "<ipv4|ipv6>/<prefix> | <L2 address> " \
21984 "locator-set <locator_name> [del]" \
21985 "[key-id sha1|sha256 secret-key <secret-key>]")\
21986 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
21987 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
21988 _(one_enable_disable, "enable|disable") \
21989 _(one_map_register_enable_disable, "enable|disable") \
21990 _(one_map_register_fallback_threshold, "<value>") \
21991 _(one_rloc_probe_enable_disable, "enable|disable") \
21992 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
21994 "rloc <locator> p <prio> " \
21995 "w <weight> [rloc <loc> ... ] " \
21996 "action <action> [del-all]") \
21997 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
21999 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
22000 _(one_use_petr, "ip-address> | disable") \
22001 _(one_map_request_mode, "src-dst|dst-only") \
22002 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
22003 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
22004 _(one_locator_set_dump, "[local | remote]") \
22005 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
22006 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
22007 "[local] | [remote]") \
22008 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
22009 _(one_ndp_bd_get, "") \
22010 _(one_ndp_entries_get, "bd <bridge-domain>") \
22011 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
22012 _(one_l2_arp_bd_get, "") \
22013 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
22014 _(one_stats_enable_disable, "enable|disable") \
22015 _(show_one_stats_enable_disable, "") \
22016 _(one_eid_table_vni_dump, "") \
22017 _(one_eid_table_map_dump, "l2|l3") \
22018 _(one_map_resolver_dump, "") \
22019 _(one_map_server_dump, "") \
22020 _(one_adjacencies_get, "vni <vni>") \
22021 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
22022 _(show_one_rloc_probe_state, "") \
22023 _(show_one_map_register_state, "") \
22024 _(show_one_status, "") \
22025 _(one_stats_dump, "") \
22026 _(one_stats_flush, "") \
22027 _(one_get_map_request_itr_rlocs, "") \
22028 _(one_map_register_set_ttl, "<ttl>") \
22029 _(one_set_transport_protocol, "udp|api") \
22030 _(one_get_transport_protocol, "") \
22031 _(one_enable_disable_xtr_mode, "enable|disable") \
22032 _(one_show_xtr_mode, "") \
22033 _(one_enable_disable_pitr_mode, "enable|disable") \
22034 _(one_show_pitr_mode, "") \
22035 _(one_enable_disable_petr_mode, "enable|disable") \
22036 _(one_show_petr_mode, "") \
22037 _(show_one_nsh_mapping, "") \
22038 _(show_one_pitr, "") \
22039 _(show_one_use_petr, "") \
22040 _(show_one_map_request_mode, "") \
22041 _(show_one_map_register_ttl, "") \
22042 _(show_one_map_register_fallback_threshold, "") \
22043 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
22044 " sw_if_index <sw_if_index> p <priority> " \
22045 "w <weight>] [del]") \
22046 _(lisp_add_del_locator, "locator-set <locator_name> " \
22047 "iface <intf> | sw_if_index <sw_if_index> " \
22048 "p <priority> w <weight> [del]") \
22049 _(lisp_add_del_local_eid,"vni <vni> eid " \
22050 "<ipv4|ipv6>/<prefix> | <L2 address> " \
22051 "locator-set <locator_name> [del]" \
22052 "[key-id sha1|sha256 secret-key <secret-key>]") \
22053 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
22054 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
22055 _(lisp_enable_disable, "enable|disable") \
22056 _(lisp_map_register_enable_disable, "enable|disable") \
22057 _(lisp_rloc_probe_enable_disable, "enable|disable") \
22058 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
22060 "rloc <locator> p <prio> " \
22061 "w <weight> [rloc <loc> ... ] " \
22062 "action <action> [del-all]") \
22063 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
22065 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
22066 _(lisp_use_petr, "<ip-address> | disable") \
22067 _(lisp_map_request_mode, "src-dst|dst-only") \
22068 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
22069 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
22070 _(lisp_locator_set_dump, "[local | remote]") \
22071 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
22072 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
22073 "[local] | [remote]") \
22074 _(lisp_eid_table_vni_dump, "") \
22075 _(lisp_eid_table_map_dump, "l2|l3") \
22076 _(lisp_map_resolver_dump, "") \
22077 _(lisp_map_server_dump, "") \
22078 _(lisp_adjacencies_get, "vni <vni>") \
22079 _(gpe_fwd_entry_vnis_get, "") \
22080 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
22081 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
22082 "[table <table-id>]") \
22083 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
22084 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
22085 _(gpe_set_encap_mode, "lisp|vxlan") \
22086 _(gpe_get_encap_mode, "") \
22087 _(lisp_gpe_add_del_iface, "up|down") \
22088 _(lisp_gpe_enable_disable, "enable|disable") \
22089 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
22090 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
22091 _(show_lisp_rloc_probe_state, "") \
22092 _(show_lisp_map_register_state, "") \
22093 _(show_lisp_status, "") \
22094 _(lisp_get_map_request_itr_rlocs, "") \
22095 _(show_lisp_pitr, "") \
22096 _(show_lisp_use_petr, "") \
22097 _(show_lisp_map_request_mode, "") \
22098 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
22099 _(af_packet_delete, "name <host interface name>") \
22100 _(af_packet_dump, "") \
22101 _(policer_add_del, "name <policer name> <params> [del]") \
22102 _(policer_dump, "[name <policer name>]") \
22103 _(policer_classify_set_interface, \
22104 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22105 " [l2-table <nn>] [del]") \
22106 _(policer_classify_dump, "type [ip4|ip6|l2]") \
22107 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
22108 "[master|slave]") \
22109 _(netmap_delete, "name <interface name>") \
22110 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
22111 _(mpls_table_dump, "") \
22112 _(mpls_route_dump, "table-id <ID>") \
22113 _(classify_table_ids, "") \
22114 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
22115 _(classify_table_info, "table_id <nn>") \
22116 _(classify_session_dump, "table_id <nn>") \
22117 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
22118 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
22119 "[template_interval <nn>] [udp_checksum]") \
22120 _(ipfix_exporter_dump, "") \
22121 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
22122 _(ipfix_classify_stream_dump, "") \
22123 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
22124 _(ipfix_classify_table_dump, "") \
22125 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
22126 _(sw_interface_span_dump, "[l2]") \
22127 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
22128 _(pg_create_interface, "if_id <nn> [gso-enabled gso-size <size>]") \
22129 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
22130 _(pg_enable_disable, "[stream <id>] disable") \
22131 _(ip_source_and_port_range_check_add_del, \
22132 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
22133 _(ip_source_and_port_range_check_interface_add_del, \
22134 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
22135 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
22136 _(delete_subif,"<intfc> | sw_if_index <nn>") \
22137 _(l2_interface_pbb_tag_rewrite, \
22138 "<intfc> | sw_if_index <nn> \n" \
22139 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
22140 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
22141 _(set_punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
22142 _(flow_classify_set_interface, \
22143 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
22144 _(flow_classify_dump, "type [ip4|ip6]") \
22145 _(ip_table_dump, "") \
22146 _(ip_route_dump, "table-id [ip4|ip6]") \
22147 _(ip_mtable_dump, "") \
22148 _(ip_mroute_dump, "table-id [ip4|ip6]") \
22149 _(feature_enable_disable, "arc_name <arc_name> " \
22150 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
22151 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
22153 _(l2_xconnect_dump, "") \
22154 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
22155 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
22156 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
22157 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
22158 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
22159 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
22160 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
22161 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
22162 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
22163 _(sock_init_shm, "size <nnn>") \
22164 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
22165 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
22166 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
22167 _(session_rules_dump, "") \
22168 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
22169 _(output_acl_set_interface, \
22170 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22171 " [l2-table <nn>] [del]") \
22172 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
22174 /* List of command functions, CLI names map directly to functions */
22175 #define foreach_cli_function \
22176 _(comment, "usage: comment <ignore-rest-of-line>") \
22177 _(dump_interface_table, "usage: dump_interface_table") \
22178 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
22179 _(dump_ipv4_table, "usage: dump_ipv4_table") \
22180 _(dump_ipv6_table, "usage: dump_ipv6_table") \
22181 _(dump_macro_table, "usage: dump_macro_table ") \
22182 _(dump_node_table, "usage: dump_node_table") \
22183 _(dump_msg_api_table, "usage: dump_msg_api_table") \
22184 _(elog_setup, "usage: elog_setup [nevents, default 128K]") \
22185 _(elog_disable, "usage: elog_disable") \
22186 _(elog_enable, "usage: elog_enable") \
22187 _(elog_save, "usage: elog_save <filename>") \
22188 _(get_msg_id, "usage: get_msg_id name_and_crc") \
22189 _(echo, "usage: echo <message>") \
22190 _(exec, "usage: exec <vpe-debug-CLI-command>") \
22191 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
22192 _(help, "usage: help") \
22193 _(q, "usage: quit") \
22194 _(quit, "usage: quit") \
22195 _(search_node_table, "usage: search_node_table <name>...") \
22196 _(set, "usage: set <variable-name> <value>") \
22197 _(script, "usage: script <file-name>") \
22198 _(statseg, "usage: statseg") \
22199 _(unset, "usage: unset <variable-name>")
22202 static void vl_api_##n##_t_handler_uni \
22203 (vl_api_##n##_t * mp) \
22205 vat_main_t * vam = &vat_main; \
22206 if (vam->json_output) { \
22207 vl_api_##n##_t_handler_json(mp); \
22209 vl_api_##n##_t_handler(mp); \
22212 foreach_vpe_api_reply_msg;
22213 #if VPP_API_TEST_BUILTIN == 0
22214 foreach_standalone_reply_msg;
22219 vat_api_hookup (vat_main_t * vam)
22222 vl_msg_api_set_handlers(VL_API_##N, #n, \
22223 vl_api_##n##_t_handler_uni, \
22225 vl_api_##n##_t_endian, \
22226 vl_api_##n##_t_print, \
22227 sizeof(vl_api_##n##_t), 1);
22228 foreach_vpe_api_reply_msg;
22229 #if VPP_API_TEST_BUILTIN == 0
22230 foreach_standalone_reply_msg;
22234 #if (VPP_API_TEST_BUILTIN==0)
22235 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
22237 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
22239 vam->function_by_name = hash_create_string (0, sizeof (uword));
22241 vam->help_by_name = hash_create_string (0, sizeof (uword));
22244 /* API messages we can send */
22245 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
22246 foreach_vpe_api_msg;
22250 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
22251 foreach_vpe_api_msg;
22254 /* CLI functions */
22255 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
22256 foreach_cli_function;
22260 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
22261 foreach_cli_function;
22265 #if VPP_API_TEST_BUILTIN
22266 static clib_error_t *
22267 vat_api_hookup_shim (vlib_main_t * vm)
22269 vat_api_hookup (&vat_main);
22273 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
22277 * fd.io coding-style-patch-verification: ON
22280 * eval: (c-set-style "gnu")