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 hostname %s host_addr %U "
2675 "host_mac %U router_addr %U",
2676 ntohl (mp->pid), mp->lease.hostname,
2677 format_ip4_address, mp->lease.host_address,
2678 format_ethernet_address, mp->lease.host_mac,
2679 format_ip4_address, mp->lease.router_address);
2681 for (i = 0; i < mp->lease.count; i++)
2683 format (s, " domain_server_addr %U", format_ip4_address,
2684 mp->lease.domain_server[i].address);
2686 errmsg ((char *) s);
2690 static void vl_api_dhcp_compl_event_t_handler_json
2691 (vl_api_dhcp_compl_event_t * mp)
2693 /* JSON output not supported */
2696 static void vl_api_get_first_msg_id_reply_t_handler
2697 (vl_api_get_first_msg_id_reply_t * mp)
2699 vat_main_t *vam = &vat_main;
2700 i32 retval = ntohl (mp->retval);
2702 if (vam->async_mode)
2704 vam->async_errors += (retval < 0);
2708 vam->retval = retval;
2709 vam->result_ready = 1;
2713 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2717 static void vl_api_get_first_msg_id_reply_t_handler_json
2718 (vl_api_get_first_msg_id_reply_t * mp)
2720 vat_main_t *vam = &vat_main;
2721 vat_json_node_t node;
2723 vat_json_init_object (&node);
2724 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2725 vat_json_object_add_uint (&node, "first_msg_id",
2726 (uint) ntohs (mp->first_msg_id));
2728 vat_json_print (vam->ofp, &node);
2729 vat_json_free (&node);
2731 vam->retval = ntohl (mp->retval);
2732 vam->result_ready = 1;
2735 static void vl_api_get_node_graph_reply_t_handler
2736 (vl_api_get_node_graph_reply_t * mp)
2738 vat_main_t *vam = &vat_main;
2739 api_main_t *am = &api_main;
2740 i32 retval = ntohl (mp->retval);
2741 u8 *pvt_copy, *reply;
2746 if (vam->async_mode)
2748 vam->async_errors += (retval < 0);
2752 vam->retval = retval;
2753 vam->result_ready = 1;
2756 /* "Should never happen..." */
2760 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2761 pvt_copy = vec_dup (reply);
2763 /* Toss the shared-memory original... */
2764 pthread_mutex_lock (&am->vlib_rp->mutex);
2765 oldheap = svm_push_data_heap (am->vlib_rp);
2769 svm_pop_heap (oldheap);
2770 pthread_mutex_unlock (&am->vlib_rp->mutex);
2772 if (vam->graph_nodes)
2774 hash_free (vam->graph_node_index_by_name);
2776 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2778 node = vam->graph_nodes[0][i];
2779 vec_free (node->name);
2780 vec_free (node->next_nodes);
2783 vec_free (vam->graph_nodes[0]);
2784 vec_free (vam->graph_nodes);
2787 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2788 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2789 vec_free (pvt_copy);
2791 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2793 node = vam->graph_nodes[0][i];
2794 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2798 static void vl_api_get_node_graph_reply_t_handler_json
2799 (vl_api_get_node_graph_reply_t * mp)
2801 vat_main_t *vam = &vat_main;
2802 api_main_t *am = &api_main;
2804 vat_json_node_t node;
2807 /* $$$$ make this real? */
2808 vat_json_init_object (&node);
2809 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2810 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2812 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2814 /* Toss the shared-memory original... */
2815 pthread_mutex_lock (&am->vlib_rp->mutex);
2816 oldheap = svm_push_data_heap (am->vlib_rp);
2820 svm_pop_heap (oldheap);
2821 pthread_mutex_unlock (&am->vlib_rp->mutex);
2823 vat_json_print (vam->ofp, &node);
2824 vat_json_free (&node);
2826 vam->retval = ntohl (mp->retval);
2827 vam->result_ready = 1;
2831 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2833 vat_main_t *vam = &vat_main;
2838 s = format (s, "%=16d%=16d%=16d",
2839 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2843 s = format (s, "%=16U%=16d%=16d",
2844 mp->is_ipv6 ? format_ip6_address :
2846 mp->ip_address, mp->priority, mp->weight);
2849 print (vam->ofp, "%v", s);
2854 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2856 vat_main_t *vam = &vat_main;
2857 vat_json_node_t *node = NULL;
2858 struct in6_addr ip6;
2861 if (VAT_JSON_ARRAY != vam->json_tree.type)
2863 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2864 vat_json_init_array (&vam->json_tree);
2866 node = vat_json_array_add (&vam->json_tree);
2867 vat_json_init_object (node);
2869 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2870 vat_json_object_add_uint (node, "priority", mp->priority);
2871 vat_json_object_add_uint (node, "weight", mp->weight);
2874 vat_json_object_add_uint (node, "sw_if_index",
2875 clib_net_to_host_u32 (mp->sw_if_index));
2880 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2881 vat_json_object_add_ip6 (node, "address", ip6);
2885 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2886 vat_json_object_add_ip4 (node, "address", ip4);
2892 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2895 vat_main_t *vam = &vat_main;
2898 ls_name = format (0, "%s", mp->ls_name);
2900 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2906 vl_api_one_locator_set_details_t_handler_json
2907 (vl_api_one_locator_set_details_t * mp)
2909 vat_main_t *vam = &vat_main;
2910 vat_json_node_t *node = 0;
2913 ls_name = format (0, "%s", mp->ls_name);
2914 vec_add1 (ls_name, 0);
2916 if (VAT_JSON_ARRAY != vam->json_tree.type)
2918 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2919 vat_json_init_array (&vam->json_tree);
2921 node = vat_json_array_add (&vam->json_tree);
2923 vat_json_init_object (node);
2924 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2925 vat_json_object_add_uint (node, "ls_index",
2926 clib_net_to_host_u32 (mp->ls_index));
2934 } __attribute__ ((__packed__)) lisp_nsh_api_t;
2937 unformat_nsh_address (unformat_input_t * input, va_list * args)
2939 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
2940 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
2944 format_nsh_address_vat (u8 * s, va_list * args)
2946 nsh_t *a = va_arg (*args, nsh_t *);
2947 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
2951 format_lisp_flat_eid (u8 * s, va_list * args)
2953 u32 type = va_arg (*args, u32);
2954 u8 *eid = va_arg (*args, u8 *);
2955 u32 eid_len = va_arg (*args, u32);
2960 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2962 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2964 return format (s, "%U", format_ethernet_address, eid);
2966 return format (s, "%U", format_nsh_address_vat, eid);
2972 format_lisp_eid_vat (u8 * s, va_list * args)
2974 u32 type = va_arg (*args, u32);
2975 u8 *eid = va_arg (*args, u8 *);
2976 u32 eid_len = va_arg (*args, u32);
2977 u8 *seid = va_arg (*args, u8 *);
2978 u32 seid_len = va_arg (*args, u32);
2979 u32 is_src_dst = va_arg (*args, u32);
2982 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2984 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2990 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
2992 vat_main_t *vam = &vat_main;
2993 u8 *s = 0, *eid = 0;
2995 if (~0 == mp->locator_set_index)
2996 s = format (0, "action: %d", mp->action);
2998 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3000 eid = format (0, "%U", format_lisp_eid_vat,
3004 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3007 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3008 clib_net_to_host_u32 (mp->vni),
3010 mp->is_local ? "local" : "remote",
3011 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3012 clib_net_to_host_u16 (mp->key_id), mp->key);
3019 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3022 vat_main_t *vam = &vat_main;
3023 vat_json_node_t *node = 0;
3026 if (VAT_JSON_ARRAY != vam->json_tree.type)
3028 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3029 vat_json_init_array (&vam->json_tree);
3031 node = vat_json_array_add (&vam->json_tree);
3033 vat_json_init_object (node);
3034 if (~0 == mp->locator_set_index)
3035 vat_json_object_add_uint (node, "action", mp->action);
3037 vat_json_object_add_uint (node, "locator_set_index",
3038 clib_net_to_host_u32 (mp->locator_set_index));
3040 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3041 if (mp->eid_type == 3)
3043 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3044 vat_json_init_object (nsh_json);
3045 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3046 vat_json_object_add_uint (nsh_json, "spi",
3047 clib_net_to_host_u32 (nsh->spi));
3048 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3052 eid = format (0, "%U", format_lisp_eid_vat,
3056 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3058 vat_json_object_add_string_copy (node, "eid", eid);
3061 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3062 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3063 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3067 vat_json_object_add_uint (node, "key_id",
3068 clib_net_to_host_u16 (mp->key_id));
3069 vat_json_object_add_string_copy (node, "key", mp->key);
3074 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3076 vat_main_t *vam = &vat_main;
3077 u8 *seid = 0, *deid = 0;
3078 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3080 deid = format (0, "%U", format_lisp_eid_vat,
3081 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3083 seid = format (0, "%U", format_lisp_eid_vat,
3084 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3090 format_ip_address_fcn = format_ip4_address;
3092 format_ip_address_fcn = format_ip6_address;
3095 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3096 clib_net_to_host_u32 (mp->vni),
3098 format_ip_address_fcn, mp->lloc,
3099 format_ip_address_fcn, mp->rloc,
3100 clib_net_to_host_u32 (mp->pkt_count),
3101 clib_net_to_host_u32 (mp->bytes));
3108 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3110 struct in6_addr ip6;
3112 vat_main_t *vam = &vat_main;
3113 vat_json_node_t *node = 0;
3114 u8 *deid = 0, *seid = 0;
3116 if (VAT_JSON_ARRAY != vam->json_tree.type)
3118 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3119 vat_json_init_array (&vam->json_tree);
3121 node = vat_json_array_add (&vam->json_tree);
3123 vat_json_init_object (node);
3124 deid = format (0, "%U", format_lisp_eid_vat,
3125 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3127 seid = format (0, "%U", format_lisp_eid_vat,
3128 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3133 vat_json_object_add_string_copy (node, "seid", seid);
3134 vat_json_object_add_string_copy (node, "deid", deid);
3135 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3139 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3140 vat_json_object_add_ip4 (node, "lloc", ip4);
3141 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3142 vat_json_object_add_ip4 (node, "rloc", ip4);
3146 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3147 vat_json_object_add_ip6 (node, "lloc", ip6);
3148 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3149 vat_json_object_add_ip6 (node, "rloc", ip6);
3151 vat_json_object_add_uint (node, "pkt_count",
3152 clib_net_to_host_u32 (mp->pkt_count));
3153 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3160 vl_api_one_eid_table_map_details_t_handler
3161 (vl_api_one_eid_table_map_details_t * mp)
3163 vat_main_t *vam = &vat_main;
3165 u8 *line = format (0, "%=10d%=10d",
3166 clib_net_to_host_u32 (mp->vni),
3167 clib_net_to_host_u32 (mp->dp_table));
3168 print (vam->ofp, "%v", line);
3173 vl_api_one_eid_table_map_details_t_handler_json
3174 (vl_api_one_eid_table_map_details_t * mp)
3176 vat_main_t *vam = &vat_main;
3177 vat_json_node_t *node = NULL;
3179 if (VAT_JSON_ARRAY != vam->json_tree.type)
3181 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3182 vat_json_init_array (&vam->json_tree);
3184 node = vat_json_array_add (&vam->json_tree);
3185 vat_json_init_object (node);
3186 vat_json_object_add_uint (node, "dp_table",
3187 clib_net_to_host_u32 (mp->dp_table));
3188 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3192 vl_api_one_eid_table_vni_details_t_handler
3193 (vl_api_one_eid_table_vni_details_t * mp)
3195 vat_main_t *vam = &vat_main;
3197 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3198 print (vam->ofp, "%v", line);
3203 vl_api_one_eid_table_vni_details_t_handler_json
3204 (vl_api_one_eid_table_vni_details_t * mp)
3206 vat_main_t *vam = &vat_main;
3207 vat_json_node_t *node = NULL;
3209 if (VAT_JSON_ARRAY != vam->json_tree.type)
3211 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3212 vat_json_init_array (&vam->json_tree);
3214 node = vat_json_array_add (&vam->json_tree);
3215 vat_json_init_object (node);
3216 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3220 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3221 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3223 vat_main_t *vam = &vat_main;
3224 int retval = clib_net_to_host_u32 (mp->retval);
3226 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3227 print (vam->ofp, "fallback threshold value: %d", mp->value);
3229 vam->retval = retval;
3230 vam->result_ready = 1;
3234 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3235 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3237 vat_main_t *vam = &vat_main;
3238 vat_json_node_t _node, *node = &_node;
3239 int retval = clib_net_to_host_u32 (mp->retval);
3241 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3242 vat_json_init_object (node);
3243 vat_json_object_add_uint (node, "value", mp->value);
3245 vat_json_print (vam->ofp, node);
3246 vat_json_free (node);
3248 vam->retval = retval;
3249 vam->result_ready = 1;
3253 vl_api_show_one_map_register_state_reply_t_handler
3254 (vl_api_show_one_map_register_state_reply_t * mp)
3256 vat_main_t *vam = &vat_main;
3257 int retval = clib_net_to_host_u32 (mp->retval);
3259 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3261 vam->retval = retval;
3262 vam->result_ready = 1;
3266 vl_api_show_one_map_register_state_reply_t_handler_json
3267 (vl_api_show_one_map_register_state_reply_t * mp)
3269 vat_main_t *vam = &vat_main;
3270 vat_json_node_t _node, *node = &_node;
3271 int retval = clib_net_to_host_u32 (mp->retval);
3273 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3275 vat_json_init_object (node);
3276 vat_json_object_add_string_copy (node, "state", s);
3278 vat_json_print (vam->ofp, node);
3279 vat_json_free (node);
3281 vam->retval = retval;
3282 vam->result_ready = 1;
3287 vl_api_show_one_rloc_probe_state_reply_t_handler
3288 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3290 vat_main_t *vam = &vat_main;
3291 int retval = clib_net_to_host_u32 (mp->retval);
3296 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3298 vam->retval = retval;
3299 vam->result_ready = 1;
3303 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3304 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3306 vat_main_t *vam = &vat_main;
3307 vat_json_node_t _node, *node = &_node;
3308 int retval = clib_net_to_host_u32 (mp->retval);
3310 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3311 vat_json_init_object (node);
3312 vat_json_object_add_string_copy (node, "state", s);
3314 vat_json_print (vam->ofp, node);
3315 vat_json_free (node);
3317 vam->retval = retval;
3318 vam->result_ready = 1;
3323 vl_api_show_one_stats_enable_disable_reply_t_handler
3324 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3326 vat_main_t *vam = &vat_main;
3327 int retval = clib_net_to_host_u32 (mp->retval);
3332 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3334 vam->retval = retval;
3335 vam->result_ready = 1;
3339 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3340 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3342 vat_main_t *vam = &vat_main;
3343 vat_json_node_t _node, *node = &_node;
3344 int retval = clib_net_to_host_u32 (mp->retval);
3346 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3347 vat_json_init_object (node);
3348 vat_json_object_add_string_copy (node, "state", s);
3350 vat_json_print (vam->ofp, node);
3351 vat_json_free (node);
3353 vam->retval = retval;
3354 vam->result_ready = 1;
3359 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3361 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3362 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3363 e->vni = clib_net_to_host_u32 (e->vni);
3367 gpe_fwd_entries_get_reply_t_net_to_host
3368 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3372 mp->count = clib_net_to_host_u32 (mp->count);
3373 for (i = 0; i < mp->count; i++)
3375 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3380 format_gpe_encap_mode (u8 * s, va_list * args)
3382 u32 mode = va_arg (*args, u32);
3387 return format (s, "lisp");
3389 return format (s, "vxlan");
3395 vl_api_gpe_get_encap_mode_reply_t_handler
3396 (vl_api_gpe_get_encap_mode_reply_t * mp)
3398 vat_main_t *vam = &vat_main;
3400 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3401 vam->retval = ntohl (mp->retval);
3402 vam->result_ready = 1;
3406 vl_api_gpe_get_encap_mode_reply_t_handler_json
3407 (vl_api_gpe_get_encap_mode_reply_t * mp)
3409 vat_main_t *vam = &vat_main;
3410 vat_json_node_t node;
3412 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3413 vec_add1 (encap_mode, 0);
3415 vat_json_init_object (&node);
3416 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3418 vec_free (encap_mode);
3419 vat_json_print (vam->ofp, &node);
3420 vat_json_free (&node);
3422 vam->retval = ntohl (mp->retval);
3423 vam->result_ready = 1;
3427 vl_api_gpe_fwd_entry_path_details_t_handler
3428 (vl_api_gpe_fwd_entry_path_details_t * mp)
3430 vat_main_t *vam = &vat_main;
3431 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3433 if (mp->lcl_loc.is_ip4)
3434 format_ip_address_fcn = format_ip4_address;
3436 format_ip_address_fcn = format_ip6_address;
3438 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3439 format_ip_address_fcn, &mp->lcl_loc,
3440 format_ip_address_fcn, &mp->rmt_loc);
3444 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3446 struct in6_addr ip6;
3451 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3452 vat_json_object_add_ip4 (n, "address", ip4);
3456 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3457 vat_json_object_add_ip6 (n, "address", ip6);
3459 vat_json_object_add_uint (n, "weight", loc->weight);
3463 vl_api_gpe_fwd_entry_path_details_t_handler_json
3464 (vl_api_gpe_fwd_entry_path_details_t * mp)
3466 vat_main_t *vam = &vat_main;
3467 vat_json_node_t *node = NULL;
3468 vat_json_node_t *loc_node;
3470 if (VAT_JSON_ARRAY != vam->json_tree.type)
3472 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3473 vat_json_init_array (&vam->json_tree);
3475 node = vat_json_array_add (&vam->json_tree);
3476 vat_json_init_object (node);
3478 loc_node = vat_json_object_add (node, "local_locator");
3479 vat_json_init_object (loc_node);
3480 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3482 loc_node = vat_json_object_add (node, "remote_locator");
3483 vat_json_init_object (loc_node);
3484 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3488 vl_api_gpe_fwd_entries_get_reply_t_handler
3489 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3491 vat_main_t *vam = &vat_main;
3493 int retval = clib_net_to_host_u32 (mp->retval);
3494 vl_api_gpe_fwd_entry_t *e;
3499 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3501 for (i = 0; i < mp->count; i++)
3503 e = &mp->entries[i];
3504 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3505 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3506 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3510 vam->retval = retval;
3511 vam->result_ready = 1;
3515 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3516 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3519 vat_main_t *vam = &vat_main;
3520 vat_json_node_t *e = 0, root;
3522 int retval = clib_net_to_host_u32 (mp->retval);
3523 vl_api_gpe_fwd_entry_t *fwd;
3528 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3529 vat_json_init_array (&root);
3531 for (i = 0; i < mp->count; i++)
3533 e = vat_json_array_add (&root);
3534 fwd = &mp->entries[i];
3536 vat_json_init_object (e);
3537 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3538 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3539 vat_json_object_add_int (e, "vni", fwd->vni);
3540 vat_json_object_add_int (e, "action", fwd->action);
3542 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3543 fwd->leid_prefix_len);
3545 vat_json_object_add_string_copy (e, "leid", s);
3548 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3549 fwd->reid_prefix_len);
3551 vat_json_object_add_string_copy (e, "reid", s);
3555 vat_json_print (vam->ofp, &root);
3556 vat_json_free (&root);
3559 vam->retval = retval;
3560 vam->result_ready = 1;
3564 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3565 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3567 vat_main_t *vam = &vat_main;
3569 int retval = clib_net_to_host_u32 (mp->retval);
3570 vl_api_gpe_native_fwd_rpath_t *r;
3575 n = clib_net_to_host_u32 (mp->count);
3577 for (i = 0; i < n; i++)
3579 r = &mp->entries[i];
3580 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3581 clib_net_to_host_u32 (r->fib_index),
3582 clib_net_to_host_u32 (r->nh_sw_if_index),
3583 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3587 vam->retval = retval;
3588 vam->result_ready = 1;
3592 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3593 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3595 vat_main_t *vam = &vat_main;
3596 vat_json_node_t root, *e;
3598 int retval = clib_net_to_host_u32 (mp->retval);
3599 vl_api_gpe_native_fwd_rpath_t *r;
3605 n = clib_net_to_host_u32 (mp->count);
3606 vat_json_init_array (&root);
3608 for (i = 0; i < n; i++)
3610 e = vat_json_array_add (&root);
3611 vat_json_init_object (e);
3612 r = &mp->entries[i];
3614 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3617 vat_json_object_add_string_copy (e, "ip4", s);
3620 vat_json_object_add_uint (e, "fib_index",
3621 clib_net_to_host_u32 (r->fib_index));
3622 vat_json_object_add_uint (e, "nh_sw_if_index",
3623 clib_net_to_host_u32 (r->nh_sw_if_index));
3626 vat_json_print (vam->ofp, &root);
3627 vat_json_free (&root);
3630 vam->retval = retval;
3631 vam->result_ready = 1;
3635 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3636 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3638 vat_main_t *vam = &vat_main;
3640 int retval = clib_net_to_host_u32 (mp->retval);
3645 n = clib_net_to_host_u32 (mp->count);
3647 for (i = 0; i < n; i++)
3648 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3651 vam->retval = retval;
3652 vam->result_ready = 1;
3656 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3657 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3659 vat_main_t *vam = &vat_main;
3660 vat_json_node_t root;
3662 int retval = clib_net_to_host_u32 (mp->retval);
3667 n = clib_net_to_host_u32 (mp->count);
3668 vat_json_init_array (&root);
3670 for (i = 0; i < n; i++)
3671 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3673 vat_json_print (vam->ofp, &root);
3674 vat_json_free (&root);
3677 vam->retval = retval;
3678 vam->result_ready = 1;
3682 vl_api_one_ndp_entries_get_reply_t_handler
3683 (vl_api_one_ndp_entries_get_reply_t * mp)
3685 vat_main_t *vam = &vat_main;
3687 int retval = clib_net_to_host_u32 (mp->retval);
3692 n = clib_net_to_host_u32 (mp->count);
3694 for (i = 0; i < n; i++)
3695 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3696 format_ethernet_address, mp->entries[i].mac);
3699 vam->retval = retval;
3700 vam->result_ready = 1;
3704 vl_api_one_ndp_entries_get_reply_t_handler_json
3705 (vl_api_one_ndp_entries_get_reply_t * mp)
3708 vat_main_t *vam = &vat_main;
3709 vat_json_node_t *e = 0, root;
3711 int retval = clib_net_to_host_u32 (mp->retval);
3712 vl_api_one_ndp_entry_t *arp_entry;
3717 n = clib_net_to_host_u32 (mp->count);
3718 vat_json_init_array (&root);
3720 for (i = 0; i < n; i++)
3722 e = vat_json_array_add (&root);
3723 arp_entry = &mp->entries[i];
3725 vat_json_init_object (e);
3726 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3729 vat_json_object_add_string_copy (e, "mac", s);
3732 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3734 vat_json_object_add_string_copy (e, "ip6", s);
3738 vat_json_print (vam->ofp, &root);
3739 vat_json_free (&root);
3742 vam->retval = retval;
3743 vam->result_ready = 1;
3747 vl_api_one_l2_arp_entries_get_reply_t_handler
3748 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3750 vat_main_t *vam = &vat_main;
3752 int retval = clib_net_to_host_u32 (mp->retval);
3757 n = clib_net_to_host_u32 (mp->count);
3759 for (i = 0; i < n; i++)
3760 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3761 format_ethernet_address, mp->entries[i].mac);
3764 vam->retval = retval;
3765 vam->result_ready = 1;
3769 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3770 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3773 vat_main_t *vam = &vat_main;
3774 vat_json_node_t *e = 0, root;
3776 int retval = clib_net_to_host_u32 (mp->retval);
3777 vl_api_one_l2_arp_entry_t *arp_entry;
3782 n = clib_net_to_host_u32 (mp->count);
3783 vat_json_init_array (&root);
3785 for (i = 0; i < n; i++)
3787 e = vat_json_array_add (&root);
3788 arp_entry = &mp->entries[i];
3790 vat_json_init_object (e);
3791 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3794 vat_json_object_add_string_copy (e, "mac", s);
3797 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3799 vat_json_object_add_string_copy (e, "ip4", s);
3803 vat_json_print (vam->ofp, &root);
3804 vat_json_free (&root);
3807 vam->retval = retval;
3808 vam->result_ready = 1;
3812 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
3814 vat_main_t *vam = &vat_main;
3816 int retval = clib_net_to_host_u32 (mp->retval);
3821 n = clib_net_to_host_u32 (mp->count);
3823 for (i = 0; i < n; i++)
3825 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3829 vam->retval = retval;
3830 vam->result_ready = 1;
3834 vl_api_one_ndp_bd_get_reply_t_handler_json
3835 (vl_api_one_ndp_bd_get_reply_t * mp)
3837 vat_main_t *vam = &vat_main;
3838 vat_json_node_t root;
3840 int retval = clib_net_to_host_u32 (mp->retval);
3845 n = clib_net_to_host_u32 (mp->count);
3846 vat_json_init_array (&root);
3848 for (i = 0; i < n; i++)
3850 vat_json_array_add_uint (&root,
3851 clib_net_to_host_u32 (mp->bridge_domains[i]));
3854 vat_json_print (vam->ofp, &root);
3855 vat_json_free (&root);
3858 vam->retval = retval;
3859 vam->result_ready = 1;
3863 vl_api_one_l2_arp_bd_get_reply_t_handler
3864 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3866 vat_main_t *vam = &vat_main;
3868 int retval = clib_net_to_host_u32 (mp->retval);
3873 n = clib_net_to_host_u32 (mp->count);
3875 for (i = 0; i < n; i++)
3877 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3881 vam->retval = retval;
3882 vam->result_ready = 1;
3886 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3887 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3889 vat_main_t *vam = &vat_main;
3890 vat_json_node_t root;
3892 int retval = clib_net_to_host_u32 (mp->retval);
3897 n = clib_net_to_host_u32 (mp->count);
3898 vat_json_init_array (&root);
3900 for (i = 0; i < n; i++)
3902 vat_json_array_add_uint (&root,
3903 clib_net_to_host_u32 (mp->bridge_domains[i]));
3906 vat_json_print (vam->ofp, &root);
3907 vat_json_free (&root);
3910 vam->retval = retval;
3911 vam->result_ready = 1;
3915 vl_api_one_adjacencies_get_reply_t_handler
3916 (vl_api_one_adjacencies_get_reply_t * mp)
3918 vat_main_t *vam = &vat_main;
3920 int retval = clib_net_to_host_u32 (mp->retval);
3921 vl_api_one_adjacency_t *a;
3926 n = clib_net_to_host_u32 (mp->count);
3928 for (i = 0; i < n; i++)
3930 a = &mp->adjacencies[i];
3931 print (vam->ofp, "%U %40U",
3932 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3933 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3937 vam->retval = retval;
3938 vam->result_ready = 1;
3942 vl_api_one_adjacencies_get_reply_t_handler_json
3943 (vl_api_one_adjacencies_get_reply_t * mp)
3946 vat_main_t *vam = &vat_main;
3947 vat_json_node_t *e = 0, root;
3949 int retval = clib_net_to_host_u32 (mp->retval);
3950 vl_api_one_adjacency_t *a;
3955 n = clib_net_to_host_u32 (mp->count);
3956 vat_json_init_array (&root);
3958 for (i = 0; i < n; i++)
3960 e = vat_json_array_add (&root);
3961 a = &mp->adjacencies[i];
3963 vat_json_init_object (e);
3964 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
3965 a->leid_prefix_len);
3967 vat_json_object_add_string_copy (e, "leid", s);
3970 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
3971 a->reid_prefix_len);
3973 vat_json_object_add_string_copy (e, "reid", s);
3977 vat_json_print (vam->ofp, &root);
3978 vat_json_free (&root);
3981 vam->retval = retval;
3982 vam->result_ready = 1;
3986 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
3988 vat_main_t *vam = &vat_main;
3990 print (vam->ofp, "%=20U",
3991 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3996 vl_api_one_map_server_details_t_handler_json
3997 (vl_api_one_map_server_details_t * mp)
3999 vat_main_t *vam = &vat_main;
4000 vat_json_node_t *node = NULL;
4001 struct in6_addr ip6;
4004 if (VAT_JSON_ARRAY != vam->json_tree.type)
4006 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4007 vat_json_init_array (&vam->json_tree);
4009 node = vat_json_array_add (&vam->json_tree);
4011 vat_json_init_object (node);
4014 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4015 vat_json_object_add_ip6 (node, "map-server", ip6);
4019 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4020 vat_json_object_add_ip4 (node, "map-server", ip4);
4025 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4028 vat_main_t *vam = &vat_main;
4030 print (vam->ofp, "%=20U",
4031 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4036 vl_api_one_map_resolver_details_t_handler_json
4037 (vl_api_one_map_resolver_details_t * mp)
4039 vat_main_t *vam = &vat_main;
4040 vat_json_node_t *node = NULL;
4041 struct in6_addr ip6;
4044 if (VAT_JSON_ARRAY != vam->json_tree.type)
4046 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4047 vat_json_init_array (&vam->json_tree);
4049 node = vat_json_array_add (&vam->json_tree);
4051 vat_json_init_object (node);
4054 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4055 vat_json_object_add_ip6 (node, "map resolver", ip6);
4059 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4060 vat_json_object_add_ip4 (node, "map resolver", ip4);
4065 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4067 vat_main_t *vam = &vat_main;
4068 i32 retval = ntohl (mp->retval);
4072 print (vam->ofp, "feature: %s\ngpe: %s",
4073 mp->feature_status ? "enabled" : "disabled",
4074 mp->gpe_status ? "enabled" : "disabled");
4077 vam->retval = retval;
4078 vam->result_ready = 1;
4082 vl_api_show_one_status_reply_t_handler_json
4083 (vl_api_show_one_status_reply_t * mp)
4085 vat_main_t *vam = &vat_main;
4086 vat_json_node_t node;
4087 u8 *gpe_status = NULL;
4088 u8 *feature_status = NULL;
4090 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4091 feature_status = format (0, "%s",
4092 mp->feature_status ? "enabled" : "disabled");
4093 vec_add1 (gpe_status, 0);
4094 vec_add1 (feature_status, 0);
4096 vat_json_init_object (&node);
4097 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4098 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4100 vec_free (gpe_status);
4101 vec_free (feature_status);
4103 vat_json_print (vam->ofp, &node);
4104 vat_json_free (&node);
4106 vam->retval = ntohl (mp->retval);
4107 vam->result_ready = 1;
4111 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4112 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4114 vat_main_t *vam = &vat_main;
4115 i32 retval = ntohl (mp->retval);
4119 print (vam->ofp, "%=20s", mp->locator_set_name);
4122 vam->retval = retval;
4123 vam->result_ready = 1;
4127 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4128 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4130 vat_main_t *vam = &vat_main;
4131 vat_json_node_t *node = NULL;
4133 if (VAT_JSON_ARRAY != vam->json_tree.type)
4135 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4136 vat_json_init_array (&vam->json_tree);
4138 node = vat_json_array_add (&vam->json_tree);
4140 vat_json_init_object (node);
4141 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4143 vat_json_print (vam->ofp, node);
4144 vat_json_free (node);
4146 vam->retval = ntohl (mp->retval);
4147 vam->result_ready = 1;
4151 format_lisp_map_request_mode (u8 * s, va_list * args)
4153 u32 mode = va_arg (*args, u32);
4158 return format (0, "dst-only");
4160 return format (0, "src-dst");
4166 vl_api_show_one_map_request_mode_reply_t_handler
4167 (vl_api_show_one_map_request_mode_reply_t * mp)
4169 vat_main_t *vam = &vat_main;
4170 i32 retval = ntohl (mp->retval);
4174 u32 mode = mp->mode;
4175 print (vam->ofp, "map_request_mode: %U",
4176 format_lisp_map_request_mode, mode);
4179 vam->retval = retval;
4180 vam->result_ready = 1;
4184 vl_api_show_one_map_request_mode_reply_t_handler_json
4185 (vl_api_show_one_map_request_mode_reply_t * mp)
4187 vat_main_t *vam = &vat_main;
4188 vat_json_node_t node;
4193 s = format (0, "%U", format_lisp_map_request_mode, mode);
4196 vat_json_init_object (&node);
4197 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4198 vat_json_print (vam->ofp, &node);
4199 vat_json_free (&node);
4202 vam->retval = ntohl (mp->retval);
4203 vam->result_ready = 1;
4207 vl_api_one_show_xtr_mode_reply_t_handler
4208 (vl_api_one_show_xtr_mode_reply_t * mp)
4210 vat_main_t *vam = &vat_main;
4211 i32 retval = ntohl (mp->retval);
4215 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4218 vam->retval = retval;
4219 vam->result_ready = 1;
4223 vl_api_one_show_xtr_mode_reply_t_handler_json
4224 (vl_api_one_show_xtr_mode_reply_t * mp)
4226 vat_main_t *vam = &vat_main;
4227 vat_json_node_t node;
4230 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4231 vec_add1 (status, 0);
4233 vat_json_init_object (&node);
4234 vat_json_object_add_string_copy (&node, "status", status);
4238 vat_json_print (vam->ofp, &node);
4239 vat_json_free (&node);
4241 vam->retval = ntohl (mp->retval);
4242 vam->result_ready = 1;
4246 vl_api_one_show_pitr_mode_reply_t_handler
4247 (vl_api_one_show_pitr_mode_reply_t * mp)
4249 vat_main_t *vam = &vat_main;
4250 i32 retval = ntohl (mp->retval);
4254 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4257 vam->retval = retval;
4258 vam->result_ready = 1;
4262 vl_api_one_show_pitr_mode_reply_t_handler_json
4263 (vl_api_one_show_pitr_mode_reply_t * mp)
4265 vat_main_t *vam = &vat_main;
4266 vat_json_node_t node;
4269 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4270 vec_add1 (status, 0);
4272 vat_json_init_object (&node);
4273 vat_json_object_add_string_copy (&node, "status", status);
4277 vat_json_print (vam->ofp, &node);
4278 vat_json_free (&node);
4280 vam->retval = ntohl (mp->retval);
4281 vam->result_ready = 1;
4285 vl_api_one_show_petr_mode_reply_t_handler
4286 (vl_api_one_show_petr_mode_reply_t * mp)
4288 vat_main_t *vam = &vat_main;
4289 i32 retval = ntohl (mp->retval);
4293 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4296 vam->retval = retval;
4297 vam->result_ready = 1;
4301 vl_api_one_show_petr_mode_reply_t_handler_json
4302 (vl_api_one_show_petr_mode_reply_t * mp)
4304 vat_main_t *vam = &vat_main;
4305 vat_json_node_t node;
4308 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4309 vec_add1 (status, 0);
4311 vat_json_init_object (&node);
4312 vat_json_object_add_string_copy (&node, "status", status);
4316 vat_json_print (vam->ofp, &node);
4317 vat_json_free (&node);
4319 vam->retval = ntohl (mp->retval);
4320 vam->result_ready = 1;
4324 vl_api_show_one_use_petr_reply_t_handler
4325 (vl_api_show_one_use_petr_reply_t * mp)
4327 vat_main_t *vam = &vat_main;
4328 i32 retval = ntohl (mp->retval);
4332 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4335 print (vam->ofp, "Proxy-ETR address; %U",
4336 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4341 vam->retval = retval;
4342 vam->result_ready = 1;
4346 vl_api_show_one_use_petr_reply_t_handler_json
4347 (vl_api_show_one_use_petr_reply_t * mp)
4349 vat_main_t *vam = &vat_main;
4350 vat_json_node_t node;
4353 struct in6_addr ip6;
4355 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4356 vec_add1 (status, 0);
4358 vat_json_init_object (&node);
4359 vat_json_object_add_string_copy (&node, "status", status);
4364 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4365 vat_json_object_add_ip6 (&node, "address", ip6);
4369 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4370 vat_json_object_add_ip4 (&node, "address", ip4);
4376 vat_json_print (vam->ofp, &node);
4377 vat_json_free (&node);
4379 vam->retval = ntohl (mp->retval);
4380 vam->result_ready = 1;
4384 vl_api_show_one_nsh_mapping_reply_t_handler
4385 (vl_api_show_one_nsh_mapping_reply_t * mp)
4387 vat_main_t *vam = &vat_main;
4388 i32 retval = ntohl (mp->retval);
4392 print (vam->ofp, "%-20s%-16s",
4393 mp->is_set ? "set" : "not-set",
4394 mp->is_set ? (char *) mp->locator_set_name : "");
4397 vam->retval = retval;
4398 vam->result_ready = 1;
4402 vl_api_show_one_nsh_mapping_reply_t_handler_json
4403 (vl_api_show_one_nsh_mapping_reply_t * mp)
4405 vat_main_t *vam = &vat_main;
4406 vat_json_node_t node;
4409 status = format (0, "%s", mp->is_set ? "yes" : "no");
4410 vec_add1 (status, 0);
4412 vat_json_init_object (&node);
4413 vat_json_object_add_string_copy (&node, "is_set", status);
4416 vat_json_object_add_string_copy (&node, "locator_set",
4417 mp->locator_set_name);
4422 vat_json_print (vam->ofp, &node);
4423 vat_json_free (&node);
4425 vam->retval = ntohl (mp->retval);
4426 vam->result_ready = 1;
4430 vl_api_show_one_map_register_ttl_reply_t_handler
4431 (vl_api_show_one_map_register_ttl_reply_t * mp)
4433 vat_main_t *vam = &vat_main;
4434 i32 retval = ntohl (mp->retval);
4436 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4440 print (vam->ofp, "ttl: %u", mp->ttl);
4443 vam->retval = retval;
4444 vam->result_ready = 1;
4448 vl_api_show_one_map_register_ttl_reply_t_handler_json
4449 (vl_api_show_one_map_register_ttl_reply_t * mp)
4451 vat_main_t *vam = &vat_main;
4452 vat_json_node_t node;
4454 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4455 vat_json_init_object (&node);
4456 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4458 vat_json_print (vam->ofp, &node);
4459 vat_json_free (&node);
4461 vam->retval = ntohl (mp->retval);
4462 vam->result_ready = 1;
4466 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4468 vat_main_t *vam = &vat_main;
4469 i32 retval = ntohl (mp->retval);
4473 print (vam->ofp, "%-20s%-16s",
4474 mp->status ? "enabled" : "disabled",
4475 mp->status ? (char *) mp->locator_set_name : "");
4478 vam->retval = retval;
4479 vam->result_ready = 1;
4483 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4485 vat_main_t *vam = &vat_main;
4486 vat_json_node_t node;
4489 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4490 vec_add1 (status, 0);
4492 vat_json_init_object (&node);
4493 vat_json_object_add_string_copy (&node, "status", status);
4496 vat_json_object_add_string_copy (&node, "locator_set",
4497 mp->locator_set_name);
4502 vat_json_print (vam->ofp, &node);
4503 vat_json_free (&node);
4505 vam->retval = ntohl (mp->retval);
4506 vam->result_ready = 1;
4510 format_policer_type (u8 * s, va_list * va)
4512 u32 i = va_arg (*va, u32);
4514 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4515 s = format (s, "1r2c");
4516 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4517 s = format (s, "1r3c");
4518 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4519 s = format (s, "2r3c-2698");
4520 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4521 s = format (s, "2r3c-4115");
4522 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4523 s = format (s, "2r3c-mef5cf1");
4525 s = format (s, "ILLEGAL");
4530 format_policer_rate_type (u8 * s, va_list * va)
4532 u32 i = va_arg (*va, u32);
4534 if (i == SSE2_QOS_RATE_KBPS)
4535 s = format (s, "kbps");
4536 else if (i == SSE2_QOS_RATE_PPS)
4537 s = format (s, "pps");
4539 s = format (s, "ILLEGAL");
4544 format_policer_round_type (u8 * s, va_list * va)
4546 u32 i = va_arg (*va, u32);
4548 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4549 s = format (s, "closest");
4550 else if (i == SSE2_QOS_ROUND_TO_UP)
4551 s = format (s, "up");
4552 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4553 s = format (s, "down");
4555 s = format (s, "ILLEGAL");
4560 format_policer_action_type (u8 * s, va_list * va)
4562 u32 i = va_arg (*va, u32);
4564 if (i == SSE2_QOS_ACTION_DROP)
4565 s = format (s, "drop");
4566 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4567 s = format (s, "transmit");
4568 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4569 s = format (s, "mark-and-transmit");
4571 s = format (s, "ILLEGAL");
4576 format_dscp (u8 * s, va_list * va)
4578 u32 i = va_arg (*va, u32);
4583 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4587 return format (s, "ILLEGAL");
4589 s = format (s, "%s", t);
4594 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4596 vat_main_t *vam = &vat_main;
4597 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4599 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4600 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4602 conform_dscp_str = format (0, "");
4604 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4605 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4607 exceed_dscp_str = format (0, "");
4609 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4610 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4612 violate_dscp_str = format (0, "");
4614 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4615 "rate type %U, round type %U, %s rate, %s color-aware, "
4616 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4617 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4618 "conform action %U%s, exceed action %U%s, violate action %U%s",
4620 format_policer_type, mp->type,
4623 clib_net_to_host_u64 (mp->cb),
4624 clib_net_to_host_u64 (mp->eb),
4625 format_policer_rate_type, mp->rate_type,
4626 format_policer_round_type, mp->round_type,
4627 mp->single_rate ? "single" : "dual",
4628 mp->color_aware ? "is" : "not",
4629 ntohl (mp->cir_tokens_per_period),
4630 ntohl (mp->pir_tokens_per_period),
4632 ntohl (mp->current_limit),
4633 ntohl (mp->current_bucket),
4634 ntohl (mp->extended_limit),
4635 ntohl (mp->extended_bucket),
4636 clib_net_to_host_u64 (mp->last_update_time),
4637 format_policer_action_type, mp->conform_action_type,
4639 format_policer_action_type, mp->exceed_action_type,
4641 format_policer_action_type, mp->violate_action_type,
4644 vec_free (conform_dscp_str);
4645 vec_free (exceed_dscp_str);
4646 vec_free (violate_dscp_str);
4649 static void vl_api_policer_details_t_handler_json
4650 (vl_api_policer_details_t * mp)
4652 vat_main_t *vam = &vat_main;
4653 vat_json_node_t *node;
4654 u8 *rate_type_str, *round_type_str, *type_str;
4655 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4657 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4659 format (0, "%U", format_policer_round_type, mp->round_type);
4660 type_str = format (0, "%U", format_policer_type, mp->type);
4661 conform_action_str = format (0, "%U", format_policer_action_type,
4662 mp->conform_action_type);
4663 exceed_action_str = format (0, "%U", format_policer_action_type,
4664 mp->exceed_action_type);
4665 violate_action_str = format (0, "%U", format_policer_action_type,
4666 mp->violate_action_type);
4668 if (VAT_JSON_ARRAY != vam->json_tree.type)
4670 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4671 vat_json_init_array (&vam->json_tree);
4673 node = vat_json_array_add (&vam->json_tree);
4675 vat_json_init_object (node);
4676 vat_json_object_add_string_copy (node, "name", mp->name);
4677 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4678 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4679 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4680 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4681 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4682 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4683 vat_json_object_add_string_copy (node, "type", type_str);
4684 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4685 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4686 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4687 vat_json_object_add_uint (node, "cir_tokens_per_period",
4688 ntohl (mp->cir_tokens_per_period));
4689 vat_json_object_add_uint (node, "eir_tokens_per_period",
4690 ntohl (mp->pir_tokens_per_period));
4691 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4692 vat_json_object_add_uint (node, "current_bucket",
4693 ntohl (mp->current_bucket));
4694 vat_json_object_add_uint (node, "extended_limit",
4695 ntohl (mp->extended_limit));
4696 vat_json_object_add_uint (node, "extended_bucket",
4697 ntohl (mp->extended_bucket));
4698 vat_json_object_add_uint (node, "last_update_time",
4699 ntohl (mp->last_update_time));
4700 vat_json_object_add_string_copy (node, "conform_action",
4701 conform_action_str);
4702 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4704 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4705 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4706 vec_free (dscp_str);
4708 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4709 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4711 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4712 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4713 vec_free (dscp_str);
4715 vat_json_object_add_string_copy (node, "violate_action",
4716 violate_action_str);
4717 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4719 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4720 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4721 vec_free (dscp_str);
4724 vec_free (rate_type_str);
4725 vec_free (round_type_str);
4726 vec_free (type_str);
4727 vec_free (conform_action_str);
4728 vec_free (exceed_action_str);
4729 vec_free (violate_action_str);
4733 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4736 vat_main_t *vam = &vat_main;
4737 int i, count = ntohl (mp->count);
4740 print (vam->ofp, "classify table ids (%d) : ", count);
4741 for (i = 0; i < count; i++)
4743 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4744 print (vam->ofp, (i < count - 1) ? "," : "");
4746 vam->retval = ntohl (mp->retval);
4747 vam->result_ready = 1;
4751 vl_api_classify_table_ids_reply_t_handler_json
4752 (vl_api_classify_table_ids_reply_t * mp)
4754 vat_main_t *vam = &vat_main;
4755 int i, count = ntohl (mp->count);
4759 vat_json_node_t node;
4761 vat_json_init_object (&node);
4762 for (i = 0; i < count; i++)
4764 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4766 vat_json_print (vam->ofp, &node);
4767 vat_json_free (&node);
4769 vam->retval = ntohl (mp->retval);
4770 vam->result_ready = 1;
4774 vl_api_classify_table_by_interface_reply_t_handler
4775 (vl_api_classify_table_by_interface_reply_t * mp)
4777 vat_main_t *vam = &vat_main;
4780 table_id = ntohl (mp->l2_table_id);
4782 print (vam->ofp, "l2 table id : %d", table_id);
4784 print (vam->ofp, "l2 table id : No input ACL tables configured");
4785 table_id = ntohl (mp->ip4_table_id);
4787 print (vam->ofp, "ip4 table id : %d", table_id);
4789 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4790 table_id = ntohl (mp->ip6_table_id);
4792 print (vam->ofp, "ip6 table id : %d", table_id);
4794 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4795 vam->retval = ntohl (mp->retval);
4796 vam->result_ready = 1;
4800 vl_api_classify_table_by_interface_reply_t_handler_json
4801 (vl_api_classify_table_by_interface_reply_t * mp)
4803 vat_main_t *vam = &vat_main;
4804 vat_json_node_t node;
4806 vat_json_init_object (&node);
4808 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4809 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4810 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4812 vat_json_print (vam->ofp, &node);
4813 vat_json_free (&node);
4815 vam->retval = ntohl (mp->retval);
4816 vam->result_ready = 1;
4819 static void vl_api_policer_add_del_reply_t_handler
4820 (vl_api_policer_add_del_reply_t * mp)
4822 vat_main_t *vam = &vat_main;
4823 i32 retval = ntohl (mp->retval);
4824 if (vam->async_mode)
4826 vam->async_errors += (retval < 0);
4830 vam->retval = retval;
4831 vam->result_ready = 1;
4832 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4834 * Note: this is just barely thread-safe, depends on
4835 * the main thread spinning waiting for an answer...
4837 errmsg ("policer index %d", ntohl (mp->policer_index));
4841 static void vl_api_policer_add_del_reply_t_handler_json
4842 (vl_api_policer_add_del_reply_t * mp)
4844 vat_main_t *vam = &vat_main;
4845 vat_json_node_t node;
4847 vat_json_init_object (&node);
4848 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4849 vat_json_object_add_uint (&node, "policer_index",
4850 ntohl (mp->policer_index));
4852 vat_json_print (vam->ofp, &node);
4853 vat_json_free (&node);
4855 vam->retval = ntohl (mp->retval);
4856 vam->result_ready = 1;
4859 /* Format hex dump. */
4861 format_hex_bytes (u8 * s, va_list * va)
4863 u8 *bytes = va_arg (*va, u8 *);
4864 int n_bytes = va_arg (*va, int);
4867 /* Print short or long form depending on byte count. */
4868 uword short_form = n_bytes <= 32;
4869 u32 indent = format_get_indent (s);
4874 for (i = 0; i < n_bytes; i++)
4876 if (!short_form && (i % 32) == 0)
4877 s = format (s, "%08x: ", i);
4878 s = format (s, "%02x", bytes[i]);
4879 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4880 s = format (s, "\n%U", format_white_space, indent);
4887 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4890 vat_main_t *vam = &vat_main;
4891 i32 retval = ntohl (mp->retval);
4894 print (vam->ofp, "classify table info :");
4895 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4896 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4897 ntohl (mp->miss_next_index));
4898 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4899 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4900 ntohl (mp->match_n_vectors));
4901 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4902 ntohl (mp->mask_length));
4904 vam->retval = retval;
4905 vam->result_ready = 1;
4909 vl_api_classify_table_info_reply_t_handler_json
4910 (vl_api_classify_table_info_reply_t * mp)
4912 vat_main_t *vam = &vat_main;
4913 vat_json_node_t node;
4915 i32 retval = ntohl (mp->retval);
4918 vat_json_init_object (&node);
4920 vat_json_object_add_int (&node, "sessions",
4921 ntohl (mp->active_sessions));
4922 vat_json_object_add_int (&node, "nexttbl",
4923 ntohl (mp->next_table_index));
4924 vat_json_object_add_int (&node, "nextnode",
4925 ntohl (mp->miss_next_index));
4926 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4927 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4928 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4929 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4930 ntohl (mp->mask_length), 0);
4931 vat_json_object_add_string_copy (&node, "mask", s);
4933 vat_json_print (vam->ofp, &node);
4934 vat_json_free (&node);
4936 vam->retval = ntohl (mp->retval);
4937 vam->result_ready = 1;
4941 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4944 vat_main_t *vam = &vat_main;
4946 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4947 ntohl (mp->hit_next_index), ntohl (mp->advance),
4948 ntohl (mp->opaque_index));
4949 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4950 ntohl (mp->match_length));
4954 vl_api_classify_session_details_t_handler_json
4955 (vl_api_classify_session_details_t * mp)
4957 vat_main_t *vam = &vat_main;
4958 vat_json_node_t *node = NULL;
4960 if (VAT_JSON_ARRAY != vam->json_tree.type)
4962 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4963 vat_json_init_array (&vam->json_tree);
4965 node = vat_json_array_add (&vam->json_tree);
4967 vat_json_init_object (node);
4968 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
4969 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
4970 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
4972 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
4974 vat_json_object_add_string_copy (node, "match", s);
4977 static void vl_api_pg_create_interface_reply_t_handler
4978 (vl_api_pg_create_interface_reply_t * mp)
4980 vat_main_t *vam = &vat_main;
4982 vam->retval = ntohl (mp->retval);
4983 vam->result_ready = 1;
4986 static void vl_api_pg_create_interface_reply_t_handler_json
4987 (vl_api_pg_create_interface_reply_t * mp)
4989 vat_main_t *vam = &vat_main;
4990 vat_json_node_t node;
4992 i32 retval = ntohl (mp->retval);
4995 vat_json_init_object (&node);
4997 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
4999 vat_json_print (vam->ofp, &node);
5000 vat_json_free (&node);
5002 vam->retval = ntohl (mp->retval);
5003 vam->result_ready = 1;
5006 static void vl_api_policer_classify_details_t_handler
5007 (vl_api_policer_classify_details_t * mp)
5009 vat_main_t *vam = &vat_main;
5011 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5012 ntohl (mp->table_index));
5015 static void vl_api_policer_classify_details_t_handler_json
5016 (vl_api_policer_classify_details_t * mp)
5018 vat_main_t *vam = &vat_main;
5019 vat_json_node_t *node;
5021 if (VAT_JSON_ARRAY != vam->json_tree.type)
5023 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5024 vat_json_init_array (&vam->json_tree);
5026 node = vat_json_array_add (&vam->json_tree);
5028 vat_json_init_object (node);
5029 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5030 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5033 static void vl_api_flow_classify_details_t_handler
5034 (vl_api_flow_classify_details_t * mp)
5036 vat_main_t *vam = &vat_main;
5038 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5039 ntohl (mp->table_index));
5042 static void vl_api_flow_classify_details_t_handler_json
5043 (vl_api_flow_classify_details_t * mp)
5045 vat_main_t *vam = &vat_main;
5046 vat_json_node_t *node;
5048 if (VAT_JSON_ARRAY != vam->json_tree.type)
5050 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5051 vat_json_init_array (&vam->json_tree);
5053 node = vat_json_array_add (&vam->json_tree);
5055 vat_json_init_object (node);
5056 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5057 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5060 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5061 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5062 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5063 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5064 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5065 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5066 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5067 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5068 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5069 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5072 * Generate boilerplate reply handlers, which
5073 * dig the return value out of the xxx_reply_t API message,
5074 * stick it into vam->retval, and set vam->result_ready
5076 * Could also do this by pointing N message decode slots at
5077 * a single function, but that could break in subtle ways.
5080 #define foreach_standard_reply_retval_handler \
5081 _(sw_interface_set_flags_reply) \
5082 _(sw_interface_add_del_address_reply) \
5083 _(sw_interface_set_rx_mode_reply) \
5084 _(sw_interface_set_rx_placement_reply) \
5085 _(sw_interface_set_table_reply) \
5086 _(sw_interface_set_mpls_enable_reply) \
5087 _(sw_interface_set_vpath_reply) \
5088 _(sw_interface_set_vxlan_bypass_reply) \
5089 _(sw_interface_set_geneve_bypass_reply) \
5090 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5091 _(sw_interface_set_l2_bridge_reply) \
5092 _(sw_interface_set_bond_weight_reply) \
5093 _(bridge_domain_add_del_reply) \
5094 _(sw_interface_set_l2_xconnect_reply) \
5095 _(l2fib_add_del_reply) \
5096 _(l2fib_flush_int_reply) \
5097 _(l2fib_flush_bd_reply) \
5098 _(ip_route_add_del_reply) \
5099 _(ip_table_add_del_reply) \
5100 _(ip_mroute_add_del_reply) \
5101 _(mpls_route_add_del_reply) \
5102 _(mpls_table_add_del_reply) \
5103 _(mpls_ip_bind_unbind_reply) \
5104 _(bier_route_add_del_reply) \
5105 _(bier_table_add_del_reply) \
5106 _(proxy_arp_add_del_reply) \
5107 _(proxy_arp_intfc_enable_disable_reply) \
5108 _(sw_interface_set_unnumbered_reply) \
5109 _(ip_neighbor_add_del_reply) \
5110 _(reset_fib_reply) \
5111 _(dhcp_proxy_config_reply) \
5112 _(dhcp_proxy_set_vss_reply) \
5113 _(dhcp_client_config_reply) \
5114 _(set_ip_flow_hash_reply) \
5115 _(sw_interface_ip6_enable_disable_reply) \
5116 _(ip6nd_proxy_add_del_reply) \
5117 _(sw_interface_ip6nd_ra_prefix_reply) \
5118 _(sw_interface_ip6nd_ra_config_reply) \
5119 _(set_arp_neighbor_limit_reply) \
5120 _(l2_patch_add_del_reply) \
5121 _(sr_mpls_policy_add_reply) \
5122 _(sr_mpls_policy_mod_reply) \
5123 _(sr_mpls_policy_del_reply) \
5124 _(sr_policy_add_reply) \
5125 _(sr_policy_mod_reply) \
5126 _(sr_policy_del_reply) \
5127 _(sr_localsid_add_del_reply) \
5128 _(sr_steering_add_del_reply) \
5129 _(classify_add_del_session_reply) \
5130 _(classify_set_interface_ip_table_reply) \
5131 _(classify_set_interface_l2_tables_reply) \
5132 _(l2tpv3_set_tunnel_cookies_reply) \
5133 _(l2tpv3_interface_enable_disable_reply) \
5134 _(l2tpv3_set_lookup_key_reply) \
5135 _(l2_fib_clear_table_reply) \
5136 _(l2_interface_efp_filter_reply) \
5137 _(l2_interface_vlan_tag_rewrite_reply) \
5138 _(modify_vhost_user_if_reply) \
5139 _(delete_vhost_user_if_reply) \
5140 _(ip_probe_neighbor_reply) \
5141 _(ip_scan_neighbor_enable_disable_reply) \
5142 _(want_ip4_arp_events_reply) \
5143 _(want_ip6_nd_events_reply) \
5144 _(want_l2_macs_events_reply) \
5145 _(input_acl_set_interface_reply) \
5146 _(ipsec_spd_add_del_reply) \
5147 _(ipsec_interface_add_del_spd_reply) \
5148 _(ipsec_spd_entry_add_del_reply) \
5149 _(ipsec_sad_entry_add_del_reply) \
5150 _(ipsec_tunnel_if_add_del_reply) \
5151 _(ipsec_tunnel_if_set_sa_reply) \
5152 _(delete_loopback_reply) \
5153 _(bd_ip_mac_add_del_reply) \
5154 _(bd_ip_mac_flush_reply) \
5155 _(want_interface_events_reply) \
5156 _(cop_interface_enable_disable_reply) \
5157 _(cop_whitelist_enable_disable_reply) \
5158 _(sw_interface_clear_stats_reply) \
5159 _(ioam_enable_reply) \
5160 _(ioam_disable_reply) \
5161 _(one_add_del_locator_reply) \
5162 _(one_add_del_local_eid_reply) \
5163 _(one_add_del_remote_mapping_reply) \
5164 _(one_add_del_adjacency_reply) \
5165 _(one_add_del_map_resolver_reply) \
5166 _(one_add_del_map_server_reply) \
5167 _(one_enable_disable_reply) \
5168 _(one_rloc_probe_enable_disable_reply) \
5169 _(one_map_register_enable_disable_reply) \
5170 _(one_map_register_set_ttl_reply) \
5171 _(one_set_transport_protocol_reply) \
5172 _(one_map_register_fallback_threshold_reply) \
5173 _(one_pitr_set_locator_set_reply) \
5174 _(one_map_request_mode_reply) \
5175 _(one_add_del_map_request_itr_rlocs_reply) \
5176 _(one_eid_table_add_del_map_reply) \
5177 _(one_use_petr_reply) \
5178 _(one_stats_enable_disable_reply) \
5179 _(one_add_del_l2_arp_entry_reply) \
5180 _(one_add_del_ndp_entry_reply) \
5181 _(one_stats_flush_reply) \
5182 _(one_enable_disable_xtr_mode_reply) \
5183 _(one_enable_disable_pitr_mode_reply) \
5184 _(one_enable_disable_petr_mode_reply) \
5185 _(gpe_enable_disable_reply) \
5186 _(gpe_set_encap_mode_reply) \
5187 _(gpe_add_del_iface_reply) \
5188 _(gpe_add_del_native_fwd_rpath_reply) \
5189 _(af_packet_delete_reply) \
5190 _(policer_classify_set_interface_reply) \
5191 _(netmap_create_reply) \
5192 _(netmap_delete_reply) \
5193 _(set_ipfix_exporter_reply) \
5194 _(set_ipfix_classify_stream_reply) \
5195 _(ipfix_classify_table_add_del_reply) \
5196 _(flow_classify_set_interface_reply) \
5197 _(sw_interface_span_enable_disable_reply) \
5198 _(pg_capture_reply) \
5199 _(pg_enable_disable_reply) \
5200 _(ip_source_and_port_range_check_add_del_reply) \
5201 _(ip_source_and_port_range_check_interface_add_del_reply)\
5202 _(delete_subif_reply) \
5203 _(l2_interface_pbb_tag_rewrite_reply) \
5205 _(feature_enable_disable_reply) \
5206 _(sw_interface_tag_add_del_reply) \
5207 _(hw_interface_set_mtu_reply) \
5208 _(p2p_ethernet_add_reply) \
5209 _(p2p_ethernet_del_reply) \
5210 _(lldp_config_reply) \
5211 _(sw_interface_set_lldp_reply) \
5212 _(tcp_configure_src_addresses_reply) \
5213 _(session_rule_add_del_reply) \
5214 _(ip_container_proxy_add_del_reply) \
5215 _(output_acl_set_interface_reply) \
5216 _(qos_record_enable_disable_reply)
5219 static void vl_api_##n##_t_handler \
5220 (vl_api_##n##_t * mp) \
5222 vat_main_t * vam = &vat_main; \
5223 i32 retval = ntohl(mp->retval); \
5224 if (vam->async_mode) { \
5225 vam->async_errors += (retval < 0); \
5227 vam->retval = retval; \
5228 vam->result_ready = 1; \
5231 foreach_standard_reply_retval_handler;
5235 static void vl_api_##n##_t_handler_json \
5236 (vl_api_##n##_t * mp) \
5238 vat_main_t * vam = &vat_main; \
5239 vat_json_node_t node; \
5240 vat_json_init_object(&node); \
5241 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5242 vat_json_print(vam->ofp, &node); \
5243 vam->retval = ntohl(mp->retval); \
5244 vam->result_ready = 1; \
5246 foreach_standard_reply_retval_handler;
5250 * Table of message reply handlers, must include boilerplate handlers
5254 #define foreach_vpe_api_reply_msg \
5255 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5256 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5257 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5258 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5259 _(CONTROL_PING_REPLY, control_ping_reply) \
5260 _(CLI_REPLY, cli_reply) \
5261 _(CLI_INBAND_REPLY, cli_inband_reply) \
5262 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5263 sw_interface_add_del_address_reply) \
5264 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5265 _(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
5266 _(SW_INTERFACE_RX_PLACEMENT_DETAILS, sw_interface_rx_placement_details) \
5267 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5268 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5269 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5270 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5271 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5272 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5273 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5274 sw_interface_set_l2_xconnect_reply) \
5275 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5276 sw_interface_set_l2_bridge_reply) \
5277 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5278 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5279 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5280 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5281 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5282 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5283 _(L2_FLAGS_REPLY, l2_flags_reply) \
5284 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5285 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5286 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5287 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5288 _(VIRTIO_PCI_CREATE_REPLY, virtio_pci_create_reply) \
5289 _(VIRTIO_PCI_DELETE_REPLY, virtio_pci_delete_reply) \
5290 _(SW_INTERFACE_VIRTIO_PCI_DETAILS, sw_interface_virtio_pci_details) \
5291 _(BOND_CREATE_REPLY, bond_create_reply) \
5292 _(BOND_DELETE_REPLY, bond_delete_reply) \
5293 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5294 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5295 _(SW_INTERFACE_SET_BOND_WEIGHT_REPLY, sw_interface_set_bond_weight_reply) \
5296 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5297 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5298 _(IP_ROUTE_ADD_DEL_REPLY, ip_route_add_del_reply) \
5299 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5300 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5301 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5302 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5303 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5304 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5305 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5306 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5307 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5308 proxy_arp_intfc_enable_disable_reply) \
5309 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5310 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5311 sw_interface_set_unnumbered_reply) \
5312 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5313 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5314 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5315 _(RESET_FIB_REPLY, reset_fib_reply) \
5316 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5317 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5318 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5319 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5320 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5321 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5322 sw_interface_ip6_enable_disable_reply) \
5323 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5324 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5325 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5326 sw_interface_ip6nd_ra_prefix_reply) \
5327 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5328 sw_interface_ip6nd_ra_config_reply) \
5329 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5330 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5331 _(SR_MPLS_POLICY_ADD_REPLY, sr_mpls_policy_add_reply) \
5332 _(SR_MPLS_POLICY_MOD_REPLY, sr_mpls_policy_mod_reply) \
5333 _(SR_MPLS_POLICY_DEL_REPLY, sr_mpls_policy_del_reply) \
5334 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5335 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5336 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5337 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5338 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5339 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5340 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5341 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5342 classify_set_interface_ip_table_reply) \
5343 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5344 classify_set_interface_l2_tables_reply) \
5345 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5346 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5347 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5348 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5349 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5350 l2tpv3_interface_enable_disable_reply) \
5351 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5352 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5353 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5354 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5355 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5356 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5357 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5358 _(GRE_TUNNEL_ADD_DEL_REPLY, gre_tunnel_add_del_reply) \
5359 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5360 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5361 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5362 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5363 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5364 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5365 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5366 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5367 _(SHOW_VERSION_REPLY, show_version_reply) \
5368 _(SHOW_THREADS_REPLY, show_threads_reply) \
5369 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5370 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5371 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5372 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5373 _(IP_PROBE_NEIGHBOR_REPLY, ip_probe_neighbor_reply) \
5374 _(IP_SCAN_NEIGHBOR_ENABLE_DISABLE_REPLY, ip_scan_neighbor_enable_disable_reply) \
5375 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5376 _(IP4_ARP_EVENT, ip4_arp_event) \
5377 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5378 _(IP6_ND_EVENT, ip6_nd_event) \
5379 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5380 _(L2_MACS_EVENT, l2_macs_event) \
5381 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5382 _(IP_ADDRESS_DETAILS, ip_address_details) \
5383 _(IP_DETAILS, ip_details) \
5384 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5385 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5386 _(IPSEC_SPD_ENTRY_ADD_DEL_REPLY, ipsec_spd_entry_add_del_reply) \
5387 _(IPSEC_SAD_ENTRY_ADD_DEL_REPLY, ipsec_sad_entry_add_del_reply) \
5388 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5389 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5390 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5391 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5392 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5393 _(BD_IP_MAC_FLUSH_REPLY, bd_ip_mac_flush_reply) \
5394 _(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
5395 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5396 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5397 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5398 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5399 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5400 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5401 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5402 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5403 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5404 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5405 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5406 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5407 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5408 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5409 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5410 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5411 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5412 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5413 one_map_register_enable_disable_reply) \
5414 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5415 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5416 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5417 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5418 one_map_register_fallback_threshold_reply) \
5419 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5420 one_rloc_probe_enable_disable_reply) \
5421 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5422 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5423 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5424 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5425 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5426 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5427 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5428 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5429 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5430 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5431 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5432 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5433 _(ONE_STATS_DETAILS, one_stats_details) \
5434 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5435 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5436 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5437 show_one_stats_enable_disable_reply) \
5438 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5439 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5440 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5441 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5442 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5443 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5444 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5445 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5446 one_enable_disable_pitr_mode_reply) \
5447 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5448 one_enable_disable_petr_mode_reply) \
5449 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5450 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5451 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5452 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5453 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5454 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5455 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5456 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5457 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5458 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5459 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5460 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5461 gpe_add_del_native_fwd_rpath_reply) \
5462 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5463 gpe_fwd_entry_path_details) \
5464 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5465 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5466 one_add_del_map_request_itr_rlocs_reply) \
5467 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5468 one_get_map_request_itr_rlocs_reply) \
5469 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5470 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5471 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5472 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5473 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5474 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5475 show_one_map_register_state_reply) \
5476 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5477 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5478 show_one_map_register_fallback_threshold_reply) \
5479 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5480 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5481 _(AF_PACKET_DETAILS, af_packet_details) \
5482 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5483 _(POLICER_DETAILS, policer_details) \
5484 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5485 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5486 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5487 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5488 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5489 _(MPLS_TABLE_DETAILS, mpls_table_details) \
5490 _(MPLS_ROUTE_DETAILS, mpls_route_details) \
5491 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5492 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5493 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5494 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5495 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5496 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5497 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5498 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5499 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5500 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5501 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5502 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5503 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5504 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5505 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5506 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5507 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5508 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5509 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5510 ip_source_and_port_range_check_add_del_reply) \
5511 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5512 ip_source_and_port_range_check_interface_add_del_reply) \
5513 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5514 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5515 _(SET_PUNT_REPLY, set_punt_reply) \
5516 _(IP_TABLE_DETAILS, ip_table_details) \
5517 _(IP_ROUTE_DETAILS, ip_route_details) \
5518 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5519 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5520 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5521 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5522 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5523 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5524 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5525 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5526 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5527 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5528 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5529 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5530 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5531 _(SESSION_RULES_DETAILS, session_rules_details) \
5532 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5533 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5534 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply)
5536 #define foreach_standalone_reply_msg \
5537 _(SW_INTERFACE_EVENT, sw_interface_event)
5545 #define STR_VTR_OP_CASE(op) \
5546 case L2_VTR_ ## op: \
5550 str_vtr_op (u32 vtr_op)
5554 STR_VTR_OP_CASE (DISABLED);
5555 STR_VTR_OP_CASE (PUSH_1);
5556 STR_VTR_OP_CASE (PUSH_2);
5557 STR_VTR_OP_CASE (POP_1);
5558 STR_VTR_OP_CASE (POP_2);
5559 STR_VTR_OP_CASE (TRANSLATE_1_1);
5560 STR_VTR_OP_CASE (TRANSLATE_1_2);
5561 STR_VTR_OP_CASE (TRANSLATE_2_1);
5562 STR_VTR_OP_CASE (TRANSLATE_2_2);
5569 dump_sub_interface_table (vat_main_t * vam)
5571 const sw_interface_subif_t *sub = NULL;
5573 if (vam->json_output)
5576 ("JSON output supported only for VPE API calls and dump_stats_table");
5581 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5582 "Interface", "sw_if_index",
5583 "sub id", "dot1ad", "tags", "outer id",
5584 "inner id", "exact", "default", "outer any", "inner any");
5586 vec_foreach (sub, vam->sw_if_subif_table)
5589 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5590 sub->interface_name,
5592 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5593 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5594 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5595 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5596 if (sub->vtr_op != L2_VTR_DISABLED)
5599 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5600 "tag1: %d tag2: %d ]",
5601 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5602 sub->vtr_tag1, sub->vtr_tag2);
5610 name_sort_cmp (void *a1, void *a2)
5612 name_sort_t *n1 = a1;
5613 name_sort_t *n2 = a2;
5615 return strcmp ((char *) n1->name, (char *) n2->name);
5619 dump_interface_table (vat_main_t * vam)
5622 name_sort_t *nses = 0, *ns;
5624 if (vam->json_output)
5627 ("JSON output supported only for VPE API calls and dump_stats_table");
5632 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5634 vec_add2 (nses, ns, 1);
5635 ns->name = (u8 *)(p->key);
5636 ns->value = (u32) p->value[0];
5640 vec_sort_with_function (nses, name_sort_cmp);
5642 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5643 vec_foreach (ns, nses)
5645 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5652 dump_ip_table (vat_main_t * vam, int is_ipv6)
5654 const ip_details_t *det = NULL;
5655 const ip_address_details_t *address = NULL;
5658 print (vam->ofp, "%-12s", "sw_if_index");
5660 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5667 print (vam->ofp, "%-12d", i);
5668 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5673 vec_foreach (address, det->addr)
5677 is_ipv6 ? format_ip6_address : format_ip4_address,
5678 address->ip, address->prefix_length);
5686 dump_ipv4_table (vat_main_t * vam)
5688 if (vam->json_output)
5691 ("JSON output supported only for VPE API calls and dump_stats_table");
5695 return dump_ip_table (vam, 0);
5699 dump_ipv6_table (vat_main_t * vam)
5701 if (vam->json_output)
5704 ("JSON output supported only for VPE API calls and dump_stats_table");
5708 return dump_ip_table (vam, 1);
5712 * Pass CLI buffers directly in the CLI_INBAND API message,
5713 * instead of an additional shared memory area.
5716 exec_inband (vat_main_t * vam)
5718 vl_api_cli_inband_t *mp;
5719 unformat_input_t *i = vam->input;
5722 if (vec_len (i->buffer) == 0)
5725 if (vam->exec_mode == 0 && unformat (i, "mode"))
5730 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5737 * In order for the CLI command to work, it
5738 * must be a vector ending in \n, not a C-string ending
5741 u32 len = vec_len (vam->input->buffer);
5742 M2 (CLI_INBAND, mp, len);
5743 vl_api_to_api_string (len - 1, (const char *) vam->input->buffer, &mp->cmd);
5747 /* json responses may or may not include a useful reply... */
5748 if (vec_len (vam->cmd_reply))
5749 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
5754 exec (vat_main_t * vam)
5756 return exec_inband (vam);
5760 api_create_loopback (vat_main_t * vam)
5762 unformat_input_t *i = vam->input;
5763 vl_api_create_loopback_t *mp;
5764 vl_api_create_loopback_instance_t *mp_lbi;
5767 u8 is_specified = 0;
5768 u32 user_instance = 0;
5771 clib_memset (mac_address, 0, sizeof (mac_address));
5773 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5775 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5777 if (unformat (i, "instance %d", &user_instance))
5785 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5786 mp_lbi->is_specified = is_specified;
5788 mp_lbi->user_instance = htonl (user_instance);
5790 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5795 /* Construct the API message */
5796 M (CREATE_LOOPBACK, mp);
5798 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5807 api_delete_loopback (vat_main_t * vam)
5809 unformat_input_t *i = vam->input;
5810 vl_api_delete_loopback_t *mp;
5811 u32 sw_if_index = ~0;
5814 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5816 if (unformat (i, "sw_if_index %d", &sw_if_index))
5822 if (sw_if_index == ~0)
5824 errmsg ("missing sw_if_index");
5828 /* Construct the API message */
5829 M (DELETE_LOOPBACK, mp);
5830 mp->sw_if_index = ntohl (sw_if_index);
5838 api_want_interface_events (vat_main_t * vam)
5840 unformat_input_t *i = vam->input;
5841 vl_api_want_interface_events_t *mp;
5845 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5847 if (unformat (i, "enable"))
5849 else if (unformat (i, "disable"))
5857 errmsg ("missing enable|disable");
5861 M (WANT_INTERFACE_EVENTS, mp);
5862 mp->enable_disable = enable;
5864 vam->interface_event_display = enable;
5872 /* Note: non-static, called once to set up the initial intfc table */
5874 api_sw_interface_dump (vat_main_t * vam)
5876 vl_api_sw_interface_dump_t *mp;
5877 vl_api_control_ping_t *mp_ping;
5879 name_sort_t *nses = 0, *ns;
5880 sw_interface_subif_t *sub = NULL;
5883 /* Toss the old name table */
5885 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5887 vec_add2 (nses, ns, 1);
5888 ns->name = (u8 *)(p->key);
5889 ns->value = (u32) p->value[0];
5893 hash_free (vam->sw_if_index_by_interface_name);
5895 vec_foreach (ns, nses) vec_free (ns->name);
5899 vec_foreach (sub, vam->sw_if_subif_table)
5901 vec_free (sub->interface_name);
5903 vec_free (vam->sw_if_subif_table);
5905 /* recreate the interface name hash table */
5906 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5909 * Ask for all interface names. Otherwise, the epic catalog of
5910 * name filters becomes ridiculously long, and vat ends up needing
5911 * to be taught about new interface types.
5913 M (SW_INTERFACE_DUMP, mp);
5916 /* Use a control ping for synchronization */
5917 MPING (CONTROL_PING, mp_ping);
5925 api_sw_interface_set_flags (vat_main_t * vam)
5927 unformat_input_t *i = vam->input;
5928 vl_api_sw_interface_set_flags_t *mp;
5930 u8 sw_if_index_set = 0;
5934 /* Parse args required to build the message */
5935 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5937 if (unformat (i, "admin-up"))
5939 else if (unformat (i, "admin-down"))
5942 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5943 sw_if_index_set = 1;
5944 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5945 sw_if_index_set = 1;
5950 if (sw_if_index_set == 0)
5952 errmsg ("missing interface name or sw_if_index");
5956 /* Construct the API message */
5957 M (SW_INTERFACE_SET_FLAGS, mp);
5958 mp->sw_if_index = ntohl (sw_if_index);
5959 mp->flags = ntohl ((admin_up) ? IF_STATUS_API_FLAG_ADMIN_UP : 0);
5964 /* Wait for a reply, return the good/bad news... */
5970 api_sw_interface_set_rx_mode (vat_main_t * vam)
5972 unformat_input_t *i = vam->input;
5973 vl_api_sw_interface_set_rx_mode_t *mp;
5975 u8 sw_if_index_set = 0;
5977 u8 queue_id_valid = 0;
5979 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
5981 /* Parse args required to build the message */
5982 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5984 if (unformat (i, "queue %d", &queue_id))
5986 else if (unformat (i, "polling"))
5987 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
5988 else if (unformat (i, "interrupt"))
5989 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
5990 else if (unformat (i, "adaptive"))
5991 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
5993 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5994 sw_if_index_set = 1;
5995 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5996 sw_if_index_set = 1;
6001 if (sw_if_index_set == 0)
6003 errmsg ("missing interface name or sw_if_index");
6006 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6008 errmsg ("missing rx-mode");
6012 /* Construct the API message */
6013 M (SW_INTERFACE_SET_RX_MODE, mp);
6014 mp->sw_if_index = ntohl (sw_if_index);
6015 mp->mode = (vl_api_rx_mode_t) mode;
6016 mp->queue_id_valid = queue_id_valid;
6017 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6022 /* Wait for a reply, return the good/bad news... */
6028 api_sw_interface_set_rx_placement (vat_main_t * vam)
6030 unformat_input_t *i = vam->input;
6031 vl_api_sw_interface_set_rx_placement_t *mp;
6033 u8 sw_if_index_set = 0;
6036 u32 queue_id, thread_index;
6038 /* Parse args required to build the message */
6039 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6041 if (unformat (i, "queue %d", &queue_id))
6043 else if (unformat (i, "main"))
6045 else if (unformat (i, "worker %d", &thread_index))
6048 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6049 sw_if_index_set = 1;
6050 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6051 sw_if_index_set = 1;
6056 if (sw_if_index_set == 0)
6058 errmsg ("missing interface name or sw_if_index");
6064 /* Construct the API message */
6065 M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
6066 mp->sw_if_index = ntohl (sw_if_index);
6067 mp->worker_id = ntohl (thread_index);
6068 mp->queue_id = ntohl (queue_id);
6069 mp->is_main = is_main;
6073 /* Wait for a reply, return the good/bad news... */
6078 static void vl_api_sw_interface_rx_placement_details_t_handler
6079 (vl_api_sw_interface_rx_placement_details_t * mp)
6081 vat_main_t *vam = &vat_main;
6082 u32 worker_id = ntohl (mp->worker_id);
6085 "\n%-11d %-11s %-6d %-5d %-9s",
6086 ntohl (mp->sw_if_index), (worker_id == 0) ? "main" : "worker",
6087 worker_id, ntohl (mp->queue_id),
6089 1) ? "polling" : ((mp->mode == 2) ? "interrupt" : "adaptive"));
6092 static void vl_api_sw_interface_rx_placement_details_t_handler_json
6093 (vl_api_sw_interface_rx_placement_details_t * mp)
6095 vat_main_t *vam = &vat_main;
6096 vat_json_node_t *node = NULL;
6098 if (VAT_JSON_ARRAY != vam->json_tree.type)
6100 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
6101 vat_json_init_array (&vam->json_tree);
6103 node = vat_json_array_add (&vam->json_tree);
6105 vat_json_init_object (node);
6106 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
6107 vat_json_object_add_uint (node, "worker_id", ntohl (mp->worker_id));
6108 vat_json_object_add_uint (node, "queue_id", ntohl (mp->queue_id));
6109 vat_json_object_add_uint (node, "mode", mp->mode);
6113 api_sw_interface_rx_placement_dump (vat_main_t * vam)
6115 unformat_input_t *i = vam->input;
6116 vl_api_sw_interface_rx_placement_dump_t *mp;
6117 vl_api_control_ping_t *mp_ping;
6120 u8 sw_if_index_set = 0;
6122 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6124 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6126 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6133 "\n%-11s %-11s %-6s %-5s %-4s",
6134 "sw_if_index", "main/worker", "thread", "queue", "mode");
6136 /* Dump Interface rx placement */
6137 M (SW_INTERFACE_RX_PLACEMENT_DUMP, mp);
6139 if (sw_if_index_set)
6140 mp->sw_if_index = htonl (sw_if_index);
6142 mp->sw_if_index = ~0;
6146 /* Use a control ping for synchronization */
6147 MPING (CONTROL_PING, mp_ping);
6155 api_sw_interface_clear_stats (vat_main_t * vam)
6157 unformat_input_t *i = vam->input;
6158 vl_api_sw_interface_clear_stats_t *mp;
6160 u8 sw_if_index_set = 0;
6163 /* Parse args required to build the message */
6164 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6166 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6167 sw_if_index_set = 1;
6168 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6169 sw_if_index_set = 1;
6174 /* Construct the API message */
6175 M (SW_INTERFACE_CLEAR_STATS, mp);
6177 if (sw_if_index_set == 1)
6178 mp->sw_if_index = ntohl (sw_if_index);
6180 mp->sw_if_index = ~0;
6185 /* Wait for a reply, return the good/bad news... */
6191 api_sw_interface_add_del_address (vat_main_t * vam)
6193 unformat_input_t *i = vam->input;
6194 vl_api_sw_interface_add_del_address_t *mp;
6196 u8 sw_if_index_set = 0;
6197 u8 is_add = 1, del_all = 0;
6198 u32 address_length = 0;
6199 u8 v4_address_set = 0;
6200 u8 v6_address_set = 0;
6201 ip4_address_t v4address;
6202 ip6_address_t v6address;
6205 /* Parse args required to build the message */
6206 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6208 if (unformat (i, "del-all"))
6210 else if (unformat (i, "del"))
6213 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6214 sw_if_index_set = 1;
6215 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6216 sw_if_index_set = 1;
6217 else if (unformat (i, "%U/%d",
6218 unformat_ip4_address, &v4address, &address_length))
6220 else if (unformat (i, "%U/%d",
6221 unformat_ip6_address, &v6address, &address_length))
6227 if (sw_if_index_set == 0)
6229 errmsg ("missing interface name or sw_if_index");
6232 if (v4_address_set && v6_address_set)
6234 errmsg ("both v4 and v6 addresses set");
6237 if (!v4_address_set && !v6_address_set && !del_all)
6239 errmsg ("no addresses set");
6243 /* Construct the API message */
6244 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6246 mp->sw_if_index = ntohl (sw_if_index);
6247 mp->is_add = is_add;
6248 mp->del_all = del_all;
6251 mp->prefix.address.af = ADDRESS_IP6;
6252 clib_memcpy (mp->prefix.address.un.ip6, &v6address, sizeof (v6address));
6256 mp->prefix.address.af = ADDRESS_IP4;
6257 clib_memcpy (mp->prefix.address.un.ip4, &v4address, sizeof (v4address));
6259 mp->prefix.len = address_length;
6264 /* Wait for a reply, return good/bad news */
6270 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6272 unformat_input_t *i = vam->input;
6273 vl_api_sw_interface_set_mpls_enable_t *mp;
6275 u8 sw_if_index_set = 0;
6279 /* Parse args required to build the message */
6280 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6282 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6283 sw_if_index_set = 1;
6284 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6285 sw_if_index_set = 1;
6286 else if (unformat (i, "disable"))
6288 else if (unformat (i, "dis"))
6294 if (sw_if_index_set == 0)
6296 errmsg ("missing interface name or sw_if_index");
6300 /* Construct the API message */
6301 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6303 mp->sw_if_index = ntohl (sw_if_index);
6304 mp->enable = enable;
6309 /* Wait for a reply... */
6315 api_sw_interface_set_table (vat_main_t * vam)
6317 unformat_input_t *i = vam->input;
6318 vl_api_sw_interface_set_table_t *mp;
6319 u32 sw_if_index, vrf_id = 0;
6320 u8 sw_if_index_set = 0;
6324 /* Parse args required to build the message */
6325 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6327 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6328 sw_if_index_set = 1;
6329 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6330 sw_if_index_set = 1;
6331 else if (unformat (i, "vrf %d", &vrf_id))
6333 else if (unformat (i, "ipv6"))
6339 if (sw_if_index_set == 0)
6341 errmsg ("missing interface name or sw_if_index");
6345 /* Construct the API message */
6346 M (SW_INTERFACE_SET_TABLE, mp);
6348 mp->sw_if_index = ntohl (sw_if_index);
6349 mp->is_ipv6 = is_ipv6;
6350 mp->vrf_id = ntohl (vrf_id);
6355 /* Wait for a reply... */
6360 static void vl_api_sw_interface_get_table_reply_t_handler
6361 (vl_api_sw_interface_get_table_reply_t * mp)
6363 vat_main_t *vam = &vat_main;
6365 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6367 vam->retval = ntohl (mp->retval);
6368 vam->result_ready = 1;
6372 static void vl_api_sw_interface_get_table_reply_t_handler_json
6373 (vl_api_sw_interface_get_table_reply_t * mp)
6375 vat_main_t *vam = &vat_main;
6376 vat_json_node_t node;
6378 vat_json_init_object (&node);
6379 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6380 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6382 vat_json_print (vam->ofp, &node);
6383 vat_json_free (&node);
6385 vam->retval = ntohl (mp->retval);
6386 vam->result_ready = 1;
6390 api_sw_interface_get_table (vat_main_t * vam)
6392 unformat_input_t *i = vam->input;
6393 vl_api_sw_interface_get_table_t *mp;
6395 u8 sw_if_index_set = 0;
6399 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6401 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6402 sw_if_index_set = 1;
6403 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6404 sw_if_index_set = 1;
6405 else if (unformat (i, "ipv6"))
6411 if (sw_if_index_set == 0)
6413 errmsg ("missing interface name or sw_if_index");
6417 M (SW_INTERFACE_GET_TABLE, mp);
6418 mp->sw_if_index = htonl (sw_if_index);
6419 mp->is_ipv6 = is_ipv6;
6427 api_sw_interface_set_vpath (vat_main_t * vam)
6429 unformat_input_t *i = vam->input;
6430 vl_api_sw_interface_set_vpath_t *mp;
6431 u32 sw_if_index = 0;
6432 u8 sw_if_index_set = 0;
6436 /* Parse args required to build the message */
6437 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6439 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6440 sw_if_index_set = 1;
6441 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6442 sw_if_index_set = 1;
6443 else if (unformat (i, "enable"))
6445 else if (unformat (i, "disable"))
6451 if (sw_if_index_set == 0)
6453 errmsg ("missing interface name or sw_if_index");
6457 /* Construct the API message */
6458 M (SW_INTERFACE_SET_VPATH, mp);
6460 mp->sw_if_index = ntohl (sw_if_index);
6461 mp->enable = is_enable;
6466 /* Wait for a reply... */
6472 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6474 unformat_input_t *i = vam->input;
6475 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6476 u32 sw_if_index = 0;
6477 u8 sw_if_index_set = 0;
6482 /* Parse args required to build the message */
6483 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6485 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6486 sw_if_index_set = 1;
6487 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6488 sw_if_index_set = 1;
6489 else if (unformat (i, "enable"))
6491 else if (unformat (i, "disable"))
6493 else if (unformat (i, "ip4"))
6495 else if (unformat (i, "ip6"))
6501 if (sw_if_index_set == 0)
6503 errmsg ("missing interface name or sw_if_index");
6507 /* Construct the API message */
6508 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6510 mp->sw_if_index = ntohl (sw_if_index);
6511 mp->enable = is_enable;
6512 mp->is_ipv6 = is_ipv6;
6517 /* Wait for a reply... */
6523 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6525 unformat_input_t *i = vam->input;
6526 vl_api_sw_interface_set_geneve_bypass_t *mp;
6527 u32 sw_if_index = 0;
6528 u8 sw_if_index_set = 0;
6533 /* Parse args required to build the message */
6534 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6536 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6537 sw_if_index_set = 1;
6538 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6539 sw_if_index_set = 1;
6540 else if (unformat (i, "enable"))
6542 else if (unformat (i, "disable"))
6544 else if (unformat (i, "ip4"))
6546 else if (unformat (i, "ip6"))
6552 if (sw_if_index_set == 0)
6554 errmsg ("missing interface name or sw_if_index");
6558 /* Construct the API message */
6559 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6561 mp->sw_if_index = ntohl (sw_if_index);
6562 mp->enable = is_enable;
6563 mp->is_ipv6 = is_ipv6;
6568 /* Wait for a reply... */
6574 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6576 unformat_input_t *i = vam->input;
6577 vl_api_sw_interface_set_l2_xconnect_t *mp;
6579 u8 rx_sw_if_index_set = 0;
6581 u8 tx_sw_if_index_set = 0;
6585 /* Parse args required to build the message */
6586 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6588 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6589 rx_sw_if_index_set = 1;
6590 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6591 tx_sw_if_index_set = 1;
6592 else if (unformat (i, "rx"))
6594 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6596 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6598 rx_sw_if_index_set = 1;
6603 else if (unformat (i, "tx"))
6605 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6607 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6609 tx_sw_if_index_set = 1;
6614 else if (unformat (i, "enable"))
6616 else if (unformat (i, "disable"))
6622 if (rx_sw_if_index_set == 0)
6624 errmsg ("missing rx interface name or rx_sw_if_index");
6628 if (enable && (tx_sw_if_index_set == 0))
6630 errmsg ("missing tx interface name or tx_sw_if_index");
6634 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6636 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6637 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6638 mp->enable = enable;
6646 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6648 unformat_input_t *i = vam->input;
6649 vl_api_sw_interface_set_l2_bridge_t *mp;
6650 vl_api_l2_port_type_t port_type;
6652 u8 rx_sw_if_index_set = 0;
6659 port_type = L2_API_PORT_TYPE_NORMAL;
6661 /* Parse args required to build the message */
6662 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6664 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6665 rx_sw_if_index_set = 1;
6666 else if (unformat (i, "bd_id %d", &bd_id))
6670 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6671 rx_sw_if_index_set = 1;
6672 else if (unformat (i, "shg %d", &shg))
6674 else if (unformat (i, "bvi"))
6675 port_type = L2_API_PORT_TYPE_BVI;
6676 else if (unformat (i, "uu-fwd"))
6677 port_type = L2_API_PORT_TYPE_UU_FWD;
6678 else if (unformat (i, "enable"))
6680 else if (unformat (i, "disable"))
6686 if (rx_sw_if_index_set == 0)
6688 errmsg ("missing rx interface name or sw_if_index");
6692 if (enable && (bd_id_set == 0))
6694 errmsg ("missing bridge domain");
6698 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6700 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6701 mp->bd_id = ntohl (bd_id);
6703 mp->port_type = ntohl (port_type);
6704 mp->enable = enable;
6712 api_bridge_domain_dump (vat_main_t * vam)
6714 unformat_input_t *i = vam->input;
6715 vl_api_bridge_domain_dump_t *mp;
6716 vl_api_control_ping_t *mp_ping;
6720 /* Parse args required to build the message */
6721 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6723 if (unformat (i, "bd_id %d", &bd_id))
6729 M (BRIDGE_DOMAIN_DUMP, mp);
6730 mp->bd_id = ntohl (bd_id);
6733 /* Use a control ping for synchronization */
6734 MPING (CONTROL_PING, mp_ping);
6742 api_bridge_domain_add_del (vat_main_t * vam)
6744 unformat_input_t *i = vam->input;
6745 vl_api_bridge_domain_add_del_t *mp;
6748 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6753 /* Parse args required to build the message */
6754 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6756 if (unformat (i, "bd_id %d", &bd_id))
6758 else if (unformat (i, "flood %d", &flood))
6760 else if (unformat (i, "uu-flood %d", &uu_flood))
6762 else if (unformat (i, "forward %d", &forward))
6764 else if (unformat (i, "learn %d", &learn))
6766 else if (unformat (i, "arp-term %d", &arp_term))
6768 else if (unformat (i, "mac-age %d", &mac_age))
6770 else if (unformat (i, "bd-tag %s", &bd_tag))
6772 else if (unformat (i, "del"))
6775 flood = uu_flood = forward = learn = 0;
6783 errmsg ("missing bridge domain");
6790 errmsg ("mac age must be less than 256 ");
6795 if ((bd_tag) && (vec_len (bd_tag) > 63))
6797 errmsg ("bd-tag cannot be longer than 63");
6802 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6804 mp->bd_id = ntohl (bd_id);
6806 mp->uu_flood = uu_flood;
6807 mp->forward = forward;
6809 mp->arp_term = arp_term;
6810 mp->is_add = is_add;
6811 mp->mac_age = (u8) mac_age;
6814 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
6815 mp->bd_tag[vec_len (bd_tag)] = 0;
6826 api_l2fib_flush_bd (vat_main_t * vam)
6828 unformat_input_t *i = vam->input;
6829 vl_api_l2fib_flush_bd_t *mp;
6833 /* Parse args required to build the message */
6834 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6836 if (unformat (i, "bd_id %d", &bd_id));
6843 errmsg ("missing bridge domain");
6847 M (L2FIB_FLUSH_BD, mp);
6849 mp->bd_id = htonl (bd_id);
6857 api_l2fib_flush_int (vat_main_t * vam)
6859 unformat_input_t *i = vam->input;
6860 vl_api_l2fib_flush_int_t *mp;
6861 u32 sw_if_index = ~0;
6864 /* Parse args required to build the message */
6865 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6867 if (unformat (i, "sw_if_index %d", &sw_if_index));
6869 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6874 if (sw_if_index == ~0)
6876 errmsg ("missing interface name or sw_if_index");
6880 M (L2FIB_FLUSH_INT, mp);
6882 mp->sw_if_index = ntohl (sw_if_index);
6890 api_l2fib_add_del (vat_main_t * vam)
6892 unformat_input_t *i = vam->input;
6893 vl_api_l2fib_add_del_t *mp;
6899 u32 sw_if_index = 0;
6900 u8 sw_if_index_set = 0;
6909 /* Parse args required to build the message */
6910 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6912 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
6914 else if (unformat (i, "bd_id %d", &bd_id))
6916 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6917 sw_if_index_set = 1;
6918 else if (unformat (i, "sw_if"))
6920 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6923 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6924 sw_if_index_set = 1;
6929 else if (unformat (i, "static"))
6931 else if (unformat (i, "filter"))
6936 else if (unformat (i, "bvi"))
6941 else if (unformat (i, "del"))
6943 else if (unformat (i, "count %d", &count))
6951 errmsg ("missing mac address");
6957 errmsg ("missing bridge domain");
6961 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
6963 errmsg ("missing interface name or sw_if_index");
6969 /* Turn on async mode */
6970 vam->async_mode = 1;
6971 vam->async_errors = 0;
6972 before = vat_time_now (vam);
6975 for (j = 0; j < count; j++)
6977 M (L2FIB_ADD_DEL, mp);
6979 clib_memcpy (mp->mac, mac, 6);
6980 mp->bd_id = ntohl (bd_id);
6981 mp->is_add = is_add;
6982 mp->sw_if_index = ntohl (sw_if_index);
6986 mp->static_mac = static_mac;
6987 mp->filter_mac = filter_mac;
6988 mp->bvi_mac = bvi_mac;
6990 increment_mac_address (mac);
6997 vl_api_control_ping_t *mp_ping;
7000 /* Shut off async mode */
7001 vam->async_mode = 0;
7003 MPING (CONTROL_PING, mp_ping);
7006 timeout = vat_time_now (vam) + 1.0;
7007 while (vat_time_now (vam) < timeout)
7008 if (vam->result_ready == 1)
7013 if (vam->retval == -99)
7016 if (vam->async_errors > 0)
7018 errmsg ("%d asynchronous errors", vam->async_errors);
7021 vam->async_errors = 0;
7022 after = vat_time_now (vam);
7024 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7025 count, after - before, count / (after - before));
7031 /* Wait for a reply... */
7035 /* Return the good/bad news */
7036 return (vam->retval);
7040 api_bridge_domain_set_mac_age (vat_main_t * vam)
7042 unformat_input_t *i = vam->input;
7043 vl_api_bridge_domain_set_mac_age_t *mp;
7048 /* Parse args required to build the message */
7049 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7051 if (unformat (i, "bd_id %d", &bd_id));
7052 else if (unformat (i, "mac-age %d", &mac_age));
7059 errmsg ("missing bridge domain");
7065 errmsg ("mac age must be less than 256 ");
7069 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7071 mp->bd_id = htonl (bd_id);
7072 mp->mac_age = (u8) mac_age;
7080 api_l2_flags (vat_main_t * vam)
7082 unformat_input_t *i = vam->input;
7083 vl_api_l2_flags_t *mp;
7086 u8 sw_if_index_set = 0;
7090 /* Parse args required to build the message */
7091 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7093 if (unformat (i, "sw_if_index %d", &sw_if_index))
7094 sw_if_index_set = 1;
7095 else if (unformat (i, "sw_if"))
7097 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7100 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7101 sw_if_index_set = 1;
7106 else if (unformat (i, "learn"))
7108 else if (unformat (i, "forward"))
7110 else if (unformat (i, "flood"))
7112 else if (unformat (i, "uu-flood"))
7113 flags |= L2_UU_FLOOD;
7114 else if (unformat (i, "arp-term"))
7115 flags |= L2_ARP_TERM;
7116 else if (unformat (i, "off"))
7118 else if (unformat (i, "disable"))
7124 if (sw_if_index_set == 0)
7126 errmsg ("missing interface name or sw_if_index");
7132 mp->sw_if_index = ntohl (sw_if_index);
7133 mp->feature_bitmap = ntohl (flags);
7134 mp->is_set = is_set;
7142 api_bridge_flags (vat_main_t * vam)
7144 unformat_input_t *i = vam->input;
7145 vl_api_bridge_flags_t *mp;
7149 bd_flags_t flags = 0;
7152 /* Parse args required to build the message */
7153 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7155 if (unformat (i, "bd_id %d", &bd_id))
7157 else if (unformat (i, "learn"))
7158 flags |= BRIDGE_API_FLAG_LEARN;
7159 else if (unformat (i, "forward"))
7160 flags |= BRIDGE_API_FLAG_FWD;
7161 else if (unformat (i, "flood"))
7162 flags |= BRIDGE_API_FLAG_FLOOD;
7163 else if (unformat (i, "uu-flood"))
7164 flags |= BRIDGE_API_FLAG_UU_FLOOD;
7165 else if (unformat (i, "arp-term"))
7166 flags |= BRIDGE_API_FLAG_ARP_TERM;
7167 else if (unformat (i, "off"))
7169 else if (unformat (i, "disable"))
7177 errmsg ("missing bridge domain");
7181 M (BRIDGE_FLAGS, mp);
7183 mp->bd_id = ntohl (bd_id);
7184 mp->flags = ntohl (flags);
7185 mp->is_set = is_set;
7193 api_bd_ip_mac_add_del (vat_main_t * vam)
7195 vl_api_address_t ip = VL_API_ZERO_ADDRESS;
7196 vl_api_mac_address_t mac = { 0 };
7197 unformat_input_t *i = vam->input;
7198 vl_api_bd_ip_mac_add_del_t *mp;
7207 /* Parse args required to build the message */
7208 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7210 if (unformat (i, "bd_id %d", &bd_id))
7214 else if (unformat (i, "%U", unformat_vl_api_address, &ip))
7218 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
7222 else if (unformat (i, "del"))
7230 errmsg ("missing bridge domain");
7233 else if (ip_set == 0)
7235 errmsg ("missing IP address");
7238 else if (mac_set == 0)
7240 errmsg ("missing MAC address");
7244 M (BD_IP_MAC_ADD_DEL, mp);
7246 mp->entry.bd_id = ntohl (bd_id);
7247 mp->is_add = is_add;
7249 clib_memcpy (&mp->entry.ip, &ip, sizeof (ip));
7250 clib_memcpy (&mp->entry.mac, &mac, sizeof (mac));
7258 api_bd_ip_mac_flush (vat_main_t * vam)
7260 unformat_input_t *i = vam->input;
7261 vl_api_bd_ip_mac_flush_t *mp;
7266 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7268 if (unformat (i, "bd_id %d", &bd_id))
7278 errmsg ("missing bridge domain");
7282 M (BD_IP_MAC_FLUSH, mp);
7284 mp->bd_id = ntohl (bd_id);
7291 static void vl_api_bd_ip_mac_details_t_handler
7292 (vl_api_bd_ip_mac_details_t * mp)
7294 vat_main_t *vam = &vat_main;
7298 ntohl (mp->entry.bd_id),
7299 format_vl_api_mac_address, mp->entry.mac,
7300 format_vl_api_address, &mp->entry.ip);
7303 static void vl_api_bd_ip_mac_details_t_handler_json
7304 (vl_api_bd_ip_mac_details_t * mp)
7306 vat_main_t *vam = &vat_main;
7307 vat_json_node_t *node = NULL;
7309 if (VAT_JSON_ARRAY != vam->json_tree.type)
7311 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7312 vat_json_init_array (&vam->json_tree);
7314 node = vat_json_array_add (&vam->json_tree);
7316 vat_json_init_object (node);
7317 vat_json_object_add_uint (node, "bd_id", ntohl (mp->entry.bd_id));
7318 vat_json_object_add_string_copy (node, "mac_address",
7319 format (0, "%U", format_vl_api_mac_address,
7323 ip = format (0, "%U", format_vl_api_address, &mp->entry.ip);
7324 vat_json_object_add_string_copy (node, "ip_address", ip);
7329 api_bd_ip_mac_dump (vat_main_t * vam)
7331 unformat_input_t *i = vam->input;
7332 vl_api_bd_ip_mac_dump_t *mp;
7333 vl_api_control_ping_t *mp_ping;
7338 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7340 if (unformat (i, "bd_id %d", &bd_id))
7349 "\n%-5s %-7s %-20s %-30s",
7350 "bd_id", "is_ipv6", "mac_address", "ip_address");
7352 /* Dump Bridge Domain Ip to Mac entries */
7353 M (BD_IP_MAC_DUMP, mp);
7356 mp->bd_id = htonl (bd_id);
7362 /* Use a control ping for synchronization */
7363 MPING (CONTROL_PING, mp_ping);
7371 api_tap_create_v2 (vat_main_t * vam)
7373 unformat_input_t *i = vam->input;
7374 vl_api_tap_create_v2_t *mp;
7375 #define TAP_FLAG_GSO (1 << 0)
7379 u8 *host_if_name = 0;
7381 u8 host_mac_addr[6];
7382 u8 host_mac_addr_set = 0;
7383 u8 *host_bridge = 0;
7384 ip4_address_t host_ip4_addr;
7385 ip4_address_t host_ip4_gw;
7386 u8 host_ip4_gw_set = 0;
7387 u32 host_ip4_prefix_len = 0;
7388 ip6_address_t host_ip6_addr;
7389 ip6_address_t host_ip6_gw;
7390 u8 host_ip6_gw_set = 0;
7391 u32 host_ip6_prefix_len = 0;
7392 u8 host_mtu_set = 0;
7393 u32 host_mtu_size = 0;
7396 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7398 clib_memset (mac_address, 0, sizeof (mac_address));
7400 /* Parse args required to build the message */
7401 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7403 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7407 else if (unformat (i, "id %u", &id))
7409 else if (unformat (i, "host-if-name %s", &host_if_name))
7411 else if (unformat (i, "host-ns %s", &host_ns))
7413 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
7415 host_mac_addr_set = 1;
7416 else if (unformat (i, "host-bridge %s", &host_bridge))
7418 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
7419 &host_ip4_addr, &host_ip4_prefix_len))
7421 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
7422 &host_ip6_addr, &host_ip6_prefix_len))
7424 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
7426 host_ip4_gw_set = 1;
7427 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
7429 host_ip6_gw_set = 1;
7430 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
7432 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
7434 else if (unformat (i, "host-mtu-size %d", &host_mtu_size))
7436 else if (unformat (i, "no-gso"))
7437 tap_flags &= ~TAP_FLAG_GSO;
7438 else if (unformat (i, "gso"))
7439 tap_flags |= TAP_FLAG_GSO;
7444 if (vec_len (host_if_name) > 63)
7446 errmsg ("tap name too long. ");
7449 if (vec_len (host_ns) > 63)
7451 errmsg ("host name space too long. ");
7454 if (vec_len (host_bridge) > 63)
7456 errmsg ("host bridge name too long. ");
7459 if (host_ip4_prefix_len > 32)
7461 errmsg ("host ip4 prefix length not valid. ");
7464 if (host_ip6_prefix_len > 128)
7466 errmsg ("host ip6 prefix length not valid. ");
7469 if (!is_pow2 (rx_ring_sz))
7471 errmsg ("rx ring size must be power of 2. ");
7474 if (rx_ring_sz > 32768)
7476 errmsg ("rx ring size must be 32768 or lower. ");
7479 if (!is_pow2 (tx_ring_sz))
7481 errmsg ("tx ring size must be power of 2. ");
7484 if (tx_ring_sz > 32768)
7486 errmsg ("tx ring size must be 32768 or lower. ");
7489 if (host_mtu_set && (host_mtu_size < 64 || host_mtu_size > 65355))
7491 errmsg ("host MTU size must be in between 64 and 65355. ");
7495 /* Construct the API message */
7496 M (TAP_CREATE_V2, mp);
7498 mp->use_random_mac = random_mac;
7500 mp->id = ntohl (id);
7501 mp->host_namespace_set = host_ns != 0;
7502 mp->host_bridge_set = host_bridge != 0;
7503 mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
7504 mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
7505 mp->rx_ring_sz = ntohs (rx_ring_sz);
7506 mp->tx_ring_sz = ntohs (tx_ring_sz);
7507 mp->host_mtu_set = host_mtu_set;
7508 mp->host_mtu_size = ntohl (host_mtu_size);
7509 mp->tap_flags = ntohl (tap_flags);
7511 if (random_mac == 0)
7512 clib_memcpy (mp->mac_address, mac_address, 6);
7513 if (host_mac_addr_set)
7514 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
7516 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
7518 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
7520 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
7521 if (host_ip4_prefix_len)
7522 clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
7523 if (host_ip6_prefix_len)
7524 clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
7525 if (host_ip4_gw_set)
7526 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
7527 if (host_ip6_gw_set)
7528 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
7531 vec_free (host_if_name);
7532 vec_free (host_bridge);
7537 /* Wait for a reply... */
7543 api_tap_delete_v2 (vat_main_t * vam)
7545 unformat_input_t *i = vam->input;
7546 vl_api_tap_delete_v2_t *mp;
7547 u32 sw_if_index = ~0;
7548 u8 sw_if_index_set = 0;
7551 /* Parse args required to build the message */
7552 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7554 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7555 sw_if_index_set = 1;
7556 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7557 sw_if_index_set = 1;
7562 if (sw_if_index_set == 0)
7564 errmsg ("missing vpp interface name. ");
7568 /* Construct the API message */
7569 M (TAP_DELETE_V2, mp);
7571 mp->sw_if_index = ntohl (sw_if_index);
7576 /* Wait for a reply... */
7582 unformat_vlib_pci_addr (unformat_input_t * input, va_list * args)
7584 vlib_pci_addr_t *addr = va_arg (*args, vlib_pci_addr_t *);
7587 if (!unformat (input, "%x:%x:%x.%x", &x[0], &x[1], &x[2], &x[3]))
7590 addr->domain = x[0];
7593 addr->function = x[3];
7599 api_virtio_pci_create (vat_main_t * vam)
7601 unformat_input_t *i = vam->input;
7602 vl_api_virtio_pci_create_t *mp;
7607 u64 features = (u64) ~ (0ULL);
7610 clib_memset (mac_address, 0, sizeof (mac_address));
7612 /* Parse args required to build the message */
7613 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7615 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7619 else if (unformat (i, "pci-addr %U", unformat_vlib_pci_addr, &pci_addr))
7621 else if (unformat (i, "features 0x%llx", &features))
7623 else if (unformat (i, "gso-enabled"))
7631 errmsg ("pci address must be non zero. ");
7635 /* Construct the API message */
7636 M (VIRTIO_PCI_CREATE, mp);
7638 mp->use_random_mac = random_mac;
7640 mp->pci_addr = htonl (pci_addr);
7641 mp->features = clib_host_to_net_u64 (features);
7642 mp->gso_enabled = gso_enabled;
7644 if (random_mac == 0)
7645 clib_memcpy (mp->mac_address, mac_address, 6);
7650 /* Wait for a reply... */
7656 api_virtio_pci_delete (vat_main_t * vam)
7658 unformat_input_t *i = vam->input;
7659 vl_api_virtio_pci_delete_t *mp;
7660 u32 sw_if_index = ~0;
7661 u8 sw_if_index_set = 0;
7664 /* Parse args required to build the message */
7665 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7667 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7668 sw_if_index_set = 1;
7669 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7670 sw_if_index_set = 1;
7675 if (sw_if_index_set == 0)
7677 errmsg ("missing vpp interface name. ");
7681 /* Construct the API message */
7682 M (VIRTIO_PCI_DELETE, mp);
7684 mp->sw_if_index = htonl (sw_if_index);
7689 /* Wait for a reply... */
7695 api_bond_create (vat_main_t * vam)
7697 unformat_input_t *i = vam->input;
7698 vl_api_bond_create_t *mp;
7708 clib_memset (mac_address, 0, sizeof (mac_address));
7711 /* Parse args required to build the message */
7712 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7714 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
7716 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
7717 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
7719 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
7722 else if (unformat (i, "numa-only"))
7724 else if (unformat (i, "id %u", &id))
7730 if (mode_is_set == 0)
7732 errmsg ("Missing bond mode. ");
7736 /* Construct the API message */
7737 M (BOND_CREATE, mp);
7739 mp->use_custom_mac = custom_mac;
7741 mp->mode = htonl (mode);
7742 mp->lb = htonl (lb);
7743 mp->id = htonl (id);
7744 mp->numa_only = numa_only;
7747 clib_memcpy (mp->mac_address, mac_address, 6);
7752 /* Wait for a reply... */
7758 api_bond_delete (vat_main_t * vam)
7760 unformat_input_t *i = vam->input;
7761 vl_api_bond_delete_t *mp;
7762 u32 sw_if_index = ~0;
7763 u8 sw_if_index_set = 0;
7766 /* Parse args required to build the message */
7767 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7769 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7770 sw_if_index_set = 1;
7771 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7772 sw_if_index_set = 1;
7777 if (sw_if_index_set == 0)
7779 errmsg ("missing vpp interface name. ");
7783 /* Construct the API message */
7784 M (BOND_DELETE, mp);
7786 mp->sw_if_index = ntohl (sw_if_index);
7791 /* Wait for a reply... */
7797 api_bond_enslave (vat_main_t * vam)
7799 unformat_input_t *i = vam->input;
7800 vl_api_bond_enslave_t *mp;
7801 u32 bond_sw_if_index;
7805 u32 bond_sw_if_index_is_set = 0;
7807 u8 sw_if_index_is_set = 0;
7809 /* Parse args required to build the message */
7810 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7812 if (unformat (i, "sw_if_index %d", &sw_if_index))
7813 sw_if_index_is_set = 1;
7814 else if (unformat (i, "bond %u", &bond_sw_if_index))
7815 bond_sw_if_index_is_set = 1;
7816 else if (unformat (i, "passive %d", &is_passive))
7818 else if (unformat (i, "long-timeout %d", &is_long_timeout))
7824 if (bond_sw_if_index_is_set == 0)
7826 errmsg ("Missing bond sw_if_index. ");
7829 if (sw_if_index_is_set == 0)
7831 errmsg ("Missing slave sw_if_index. ");
7835 /* Construct the API message */
7836 M (BOND_ENSLAVE, mp);
7838 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
7839 mp->sw_if_index = ntohl (sw_if_index);
7840 mp->is_long_timeout = is_long_timeout;
7841 mp->is_passive = is_passive;
7846 /* Wait for a reply... */
7852 api_bond_detach_slave (vat_main_t * vam)
7854 unformat_input_t *i = vam->input;
7855 vl_api_bond_detach_slave_t *mp;
7856 u32 sw_if_index = ~0;
7857 u8 sw_if_index_set = 0;
7860 /* Parse args required to build the message */
7861 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7863 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7864 sw_if_index_set = 1;
7865 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7866 sw_if_index_set = 1;
7871 if (sw_if_index_set == 0)
7873 errmsg ("missing vpp interface name. ");
7877 /* Construct the API message */
7878 M (BOND_DETACH_SLAVE, mp);
7880 mp->sw_if_index = ntohl (sw_if_index);
7885 /* Wait for a reply... */
7891 api_ip_table_add_del (vat_main_t * vam)
7893 unformat_input_t *i = vam->input;
7894 vl_api_ip_table_add_del_t *mp;
7900 /* Parse args required to build the message */
7901 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7903 if (unformat (i, "ipv6"))
7905 else if (unformat (i, "del"))
7907 else if (unformat (i, "add"))
7909 else if (unformat (i, "table %d", &table_id))
7913 clib_warning ("parse error '%U'", format_unformat_error, i);
7920 errmsg ("missing table-ID");
7924 /* Construct the API message */
7925 M (IP_TABLE_ADD_DEL, mp);
7927 mp->table.table_id = ntohl (table_id);
7928 mp->table.is_ip6 = is_ipv6;
7929 mp->is_add = is_add;
7934 /* Wait for a reply... */
7941 unformat_fib_path (unformat_input_t * input, va_list * args)
7943 vat_main_t *vam = va_arg (*args, vat_main_t *);
7944 vl_api_fib_path_t *path = va_arg (*args, vl_api_fib_path_t *);
7945 u32 weight, preference;
7946 mpls_label_t out_label;
7948 clib_memset (path, 0, sizeof (*path));
7950 path->sw_if_index = ~0;
7954 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7956 if (unformat (input, "%U %U",
7957 unformat_vl_api_ip4_address,
7958 &path->nh.address.ip4,
7959 api_unformat_sw_if_index, vam, &path->sw_if_index))
7961 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7963 else if (unformat (input, "%U %U",
7964 unformat_vl_api_ip6_address,
7965 &path->nh.address.ip6,
7966 api_unformat_sw_if_index, vam, &path->sw_if_index))
7968 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7970 else if (unformat (input, "weight %u", &weight))
7972 path->weight = weight;
7974 else if (unformat (input, "preference %u", &preference))
7976 path->preference = preference;
7978 else if (unformat (input, "%U next-hop-table %d",
7979 unformat_vl_api_ip4_address,
7980 &path->nh.address.ip4, &path->table_id))
7982 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7984 else if (unformat (input, "%U next-hop-table %d",
7985 unformat_vl_api_ip6_address,
7986 &path->nh.address.ip6, &path->table_id))
7988 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7990 else if (unformat (input, "%U",
7991 unformat_vl_api_ip4_address, &path->nh.address.ip4))
7994 * the recursive next-hops are by default in the default table
7997 path->sw_if_index = ~0;
7998 path->proto = FIB_API_PATH_NH_PROTO_IP4;
8000 else if (unformat (input, "%U",
8001 unformat_vl_api_ip6_address, &path->nh.address.ip6))
8004 * the recursive next-hops are by default in the default table
8007 path->sw_if_index = ~0;
8008 path->proto = FIB_API_PATH_NH_PROTO_IP6;
8010 else if (unformat (input, "resolve-via-host"))
8012 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_HOST;
8014 else if (unformat (input, "resolve-via-attached"))
8016 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED;
8018 else if (unformat (input, "ip4-lookup-in-table %d", &path->table_id))
8020 path->type = FIB_API_PATH_TYPE_LOCAL;
8021 path->sw_if_index = ~0;
8022 path->proto = FIB_API_PATH_NH_PROTO_IP4;
8024 else if (unformat (input, "ip6-lookup-in-table %d", &path->table_id))
8026 path->type = FIB_API_PATH_TYPE_LOCAL;
8027 path->sw_if_index = ~0;
8028 path->proto = FIB_API_PATH_NH_PROTO_IP6;
8030 else if (unformat (input, "sw_if_index %d", &path->sw_if_index))
8032 else if (unformat (input, "via-label %d", &path->nh.via_label))
8034 path->proto = FIB_API_PATH_NH_PROTO_MPLS;
8035 path->sw_if_index = ~0;
8037 else if (unformat (input, "l2-input-on %d", &path->sw_if_index))
8039 path->proto = FIB_API_PATH_NH_PROTO_ETHERNET;
8040 path->type = FIB_API_PATH_TYPE_INTERFACE_RX;
8042 else if (unformat (input, "local"))
8044 path->type = FIB_API_PATH_TYPE_LOCAL;
8046 else if (unformat (input, "out-labels"))
8048 while (unformat (input, "%d", &out_label))
8050 path->label_stack[path->n_labels].label = out_label;
8051 path->label_stack[path->n_labels].is_uniform = 0;
8052 path->label_stack[path->n_labels].ttl = 64;
8056 else if (unformat (input, "via"))
8058 /* new path, back up and return */
8059 unformat_put_input (input);
8060 unformat_put_input (input);
8061 unformat_put_input (input);
8062 unformat_put_input (input);
8071 path->proto = ntohl (path->proto);
8072 path->type = ntohl (path->type);
8073 path->flags = ntohl (path->flags);
8074 path->table_id = ntohl (path->table_id);
8075 path->sw_if_index = ntohl (path->sw_if_index);
8081 api_ip_route_add_del (vat_main_t * vam)
8083 unformat_input_t *i = vam->input;
8084 vl_api_ip_route_add_del_t *mp;
8087 u8 is_multipath = 0;
8090 vl_api_prefix_t pfx = { };
8091 vl_api_fib_path_t paths[8];
8095 u32 random_add_del = 0;
8096 u32 *random_vector = 0;
8097 u32 random_seed = 0xdeaddabe;
8099 /* Parse args required to build the message */
8100 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8102 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
8104 else if (unformat (i, "del"))
8106 else if (unformat (i, "add"))
8108 else if (unformat (i, "vrf %d", &vrf_id))
8110 else if (unformat (i, "count %d", &count))
8112 else if (unformat (i, "random"))
8114 else if (unformat (i, "multipath"))
8116 else if (unformat (i, "seed %d", &random_seed))
8120 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8123 if (8 == path_count)
8125 errmsg ("max 8 paths");
8131 clib_warning ("parse error '%U'", format_unformat_error, i);
8138 errmsg ("specify a path; via ...");
8141 if (prefix_set == 0)
8143 errmsg ("missing prefix");
8147 /* Generate a pile of unique, random routes */
8150 ip4_address_t *i = (ip4_address_t *) & paths[0].nh.address.ip4;
8151 u32 this_random_address;
8154 random_hash = hash_create (count, sizeof (uword));
8156 hash_set (random_hash, i->as_u32, 1);
8157 for (j = 0; j <= count; j++)
8161 this_random_address = random_u32 (&random_seed);
8162 this_random_address =
8163 clib_host_to_net_u32 (this_random_address);
8165 while (hash_get (random_hash, this_random_address));
8166 vec_add1 (random_vector, this_random_address);
8167 hash_set (random_hash, this_random_address, 1);
8169 hash_free (random_hash);
8170 set_ip4_address (&pfx.address, random_vector[0]);
8175 /* Turn on async mode */
8176 vam->async_mode = 1;
8177 vam->async_errors = 0;
8178 before = vat_time_now (vam);
8181 for (j = 0; j < count; j++)
8183 /* Construct the API message */
8184 M2 (IP_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8186 mp->is_add = is_add;
8187 mp->is_multipath = is_multipath;
8189 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
8190 mp->route.table_id = ntohl (vrf_id);
8191 mp->route.n_paths = path_count;
8193 clib_memcpy (&mp->route.paths, &paths, sizeof (paths[0]) * path_count);
8196 set_ip4_address (&pfx.address, random_vector[j + 1]);
8198 increment_address (&pfx.address);
8201 /* If we receive SIGTERM, stop now... */
8206 /* When testing multiple add/del ops, use a control-ping to sync */
8209 vl_api_control_ping_t *mp_ping;
8213 /* Shut off async mode */
8214 vam->async_mode = 0;
8216 MPING (CONTROL_PING, mp_ping);
8219 timeout = vat_time_now (vam) + 1.0;
8220 while (vat_time_now (vam) < timeout)
8221 if (vam->result_ready == 1)
8226 if (vam->retval == -99)
8229 if (vam->async_errors > 0)
8231 errmsg ("%d asynchronous errors", vam->async_errors);
8234 vam->async_errors = 0;
8235 after = vat_time_now (vam);
8237 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8241 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8242 count, after - before, count / (after - before));
8248 /* Wait for a reply... */
8253 /* Return the good/bad news */
8254 return (vam->retval);
8258 api_ip_mroute_add_del (vat_main_t * vam)
8260 unformat_input_t *i = vam->input;
8261 u8 path_set = 0, prefix_set = 0, is_add = 1;
8262 vl_api_ip_mroute_add_del_t *mp;
8263 mfib_entry_flags_t eflags = 0;
8264 vl_api_mfib_path_t path;
8265 vl_api_mprefix_t pfx = { };
8269 /* Parse args required to build the message */
8270 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8272 if (unformat (i, "%U", unformat_vl_api_mprefix, &pfx))
8275 pfx.grp_address_length = htons (pfx.grp_address_length);
8277 else if (unformat (i, "del"))
8279 else if (unformat (i, "add"))
8281 else if (unformat (i, "vrf %d", &vrf_id))
8283 else if (unformat (i, "%U", unformat_mfib_itf_flags, &path.itf_flags))
8284 path.itf_flags = htonl (path.itf_flags);
8285 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8287 else if (unformat (i, "via %U", unformat_fib_path, vam, &path.path))
8291 clib_warning ("parse error '%U'", format_unformat_error, i);
8296 if (prefix_set == 0)
8298 errmsg ("missing addresses\n");
8303 errmsg ("missing path\n");
8307 /* Construct the API message */
8308 M (IP_MROUTE_ADD_DEL, mp);
8310 mp->is_add = is_add;
8311 mp->is_multipath = 1;
8313 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
8314 mp->route.table_id = htonl (vrf_id);
8315 mp->route.n_paths = 1;
8316 mp->route.entry_flags = htonl (eflags);
8318 clib_memcpy (&mp->route.paths, &path, sizeof (path));
8322 /* Wait for a reply... */
8328 api_mpls_table_add_del (vat_main_t * vam)
8330 unformat_input_t *i = vam->input;
8331 vl_api_mpls_table_add_del_t *mp;
8336 /* Parse args required to build the message */
8337 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8339 if (unformat (i, "table %d", &table_id))
8341 else if (unformat (i, "del"))
8343 else if (unformat (i, "add"))
8347 clib_warning ("parse error '%U'", format_unformat_error, i);
8354 errmsg ("missing table-ID");
8358 /* Construct the API message */
8359 M (MPLS_TABLE_ADD_DEL, mp);
8361 mp->mt_table.mt_table_id = ntohl (table_id);
8362 mp->mt_is_add = is_add;
8367 /* Wait for a reply... */
8374 api_mpls_route_add_del (vat_main_t * vam)
8376 u8 is_add = 1, path_count = 0, is_multipath = 0, is_eos = 0;
8377 mpls_label_t local_label = MPLS_LABEL_INVALID;
8378 unformat_input_t *i = vam->input;
8379 vl_api_mpls_route_add_del_t *mp;
8380 vl_api_fib_path_t paths[8];
8384 /* Parse args required to build the message */
8385 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8387 if (unformat (i, "%d", &local_label))
8389 else if (unformat (i, "eos"))
8391 else if (unformat (i, "non-eos"))
8393 else if (unformat (i, "del"))
8395 else if (unformat (i, "add"))
8397 else if (unformat (i, "multipath"))
8399 else if (unformat (i, "count %d", &count))
8403 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8406 if (8 == path_count)
8408 errmsg ("max 8 paths");
8414 clib_warning ("parse error '%U'", format_unformat_error, i);
8421 errmsg ("specify a path; via ...");
8425 if (MPLS_LABEL_INVALID == local_label)
8427 errmsg ("missing label");
8433 /* Turn on async mode */
8434 vam->async_mode = 1;
8435 vam->async_errors = 0;
8436 before = vat_time_now (vam);
8439 for (j = 0; j < count; j++)
8441 /* Construct the API message */
8442 M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8444 mp->mr_is_add = is_add;
8445 mp->mr_is_multipath = is_multipath;
8447 mp->mr_route.mr_label = local_label;
8448 mp->mr_route.mr_eos = is_eos;
8449 mp->mr_route.mr_table_id = 0;
8450 mp->mr_route.mr_n_paths = path_count;
8452 clib_memcpy (&mp->mr_route.mr_paths, paths,
8453 sizeof (paths[0]) * path_count);
8459 /* If we receive SIGTERM, stop now... */
8464 /* When testing multiple add/del ops, use a control-ping to sync */
8467 vl_api_control_ping_t *mp_ping;
8471 /* Shut off async mode */
8472 vam->async_mode = 0;
8474 MPING (CONTROL_PING, mp_ping);
8477 timeout = vat_time_now (vam) + 1.0;
8478 while (vat_time_now (vam) < timeout)
8479 if (vam->result_ready == 1)
8484 if (vam->retval == -99)
8487 if (vam->async_errors > 0)
8489 errmsg ("%d asynchronous errors", vam->async_errors);
8492 vam->async_errors = 0;
8493 after = vat_time_now (vam);
8495 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8499 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8500 count, after - before, count / (after - before));
8506 /* Wait for a reply... */
8511 /* Return the good/bad news */
8512 return (vam->retval);
8517 api_mpls_ip_bind_unbind (vat_main_t * vam)
8519 unformat_input_t *i = vam->input;
8520 vl_api_mpls_ip_bind_unbind_t *mp;
8521 u32 ip_table_id = 0;
8523 vl_api_prefix_t pfx;
8525 mpls_label_t local_label = MPLS_LABEL_INVALID;
8528 /* Parse args required to build the message */
8529 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8531 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
8533 else if (unformat (i, "%d", &local_label))
8535 else if (unformat (i, "table-id %d", &ip_table_id))
8537 else if (unformat (i, "unbind"))
8539 else if (unformat (i, "bind"))
8543 clib_warning ("parse error '%U'", format_unformat_error, i);
8550 errmsg ("IP prefix not set");
8554 if (MPLS_LABEL_INVALID == local_label)
8556 errmsg ("missing label");
8560 /* Construct the API message */
8561 M (MPLS_IP_BIND_UNBIND, mp);
8563 mp->mb_is_bind = is_bind;
8564 mp->mb_ip_table_id = ntohl (ip_table_id);
8565 mp->mb_mpls_table_id = 0;
8566 mp->mb_label = ntohl (local_label);
8567 clib_memcpy (&mp->mb_prefix, &pfx, sizeof (pfx));
8572 /* Wait for a reply... */
8579 api_sr_mpls_policy_add (vat_main_t * vam)
8581 unformat_input_t *i = vam->input;
8582 vl_api_sr_mpls_policy_add_t *mp;
8588 u32 *segments = NULL;
8591 /* Parse args required to build the message */
8592 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8594 if (unformat (i, "bsid %d", &bsid))
8596 else if (unformat (i, "weight %d", &weight))
8598 else if (unformat (i, "spray"))
8600 else if (unformat (i, "next %d", &sid))
8603 vec_add1 (segments, htonl (sid));
8607 clib_warning ("parse error '%U'", format_unformat_error, i);
8614 errmsg ("bsid not set");
8618 if (n_segments == 0)
8620 errmsg ("no sid in segment stack");
8624 /* Construct the API message */
8625 M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
8627 mp->bsid = htonl (bsid);
8628 mp->weight = htonl (weight);
8630 mp->n_segments = n_segments;
8631 memcpy (mp->segments, segments, sizeof (u32) * n_segments);
8632 vec_free (segments);
8637 /* Wait for a reply... */
8643 api_sr_mpls_policy_del (vat_main_t * vam)
8645 unformat_input_t *i = vam->input;
8646 vl_api_sr_mpls_policy_del_t *mp;
8650 /* Parse args required to build the message */
8651 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8653 if (unformat (i, "bsid %d", &bsid))
8657 clib_warning ("parse error '%U'", format_unformat_error, i);
8664 errmsg ("bsid not set");
8668 /* Construct the API message */
8669 M (SR_MPLS_POLICY_DEL, mp);
8671 mp->bsid = htonl (bsid);
8676 /* Wait for a reply... */
8682 api_bier_table_add_del (vat_main_t * vam)
8684 unformat_input_t *i = vam->input;
8685 vl_api_bier_table_add_del_t *mp;
8687 u32 set = 0, sub_domain = 0, hdr_len = 3;
8688 mpls_label_t local_label = MPLS_LABEL_INVALID;
8691 /* Parse args required to build the message */
8692 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8694 if (unformat (i, "sub-domain %d", &sub_domain))
8696 else if (unformat (i, "set %d", &set))
8698 else if (unformat (i, "label %d", &local_label))
8700 else if (unformat (i, "hdr-len %d", &hdr_len))
8702 else if (unformat (i, "add"))
8704 else if (unformat (i, "del"))
8708 clib_warning ("parse error '%U'", format_unformat_error, i);
8713 if (MPLS_LABEL_INVALID == local_label)
8715 errmsg ("missing label\n");
8719 /* Construct the API message */
8720 M (BIER_TABLE_ADD_DEL, mp);
8722 mp->bt_is_add = is_add;
8723 mp->bt_label = ntohl (local_label);
8724 mp->bt_tbl_id.bt_set = set;
8725 mp->bt_tbl_id.bt_sub_domain = sub_domain;
8726 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
8731 /* Wait for a reply... */
8738 api_bier_route_add_del (vat_main_t * vam)
8740 unformat_input_t *i = vam->input;
8741 vl_api_bier_route_add_del_t *mp;
8743 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
8744 ip4_address_t v4_next_hop_address;
8745 ip6_address_t v6_next_hop_address;
8746 u8 next_hop_set = 0;
8747 u8 next_hop_proto_is_ip4 = 1;
8748 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8751 /* Parse args required to build the message */
8752 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8754 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
8756 next_hop_proto_is_ip4 = 1;
8759 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
8761 next_hop_proto_is_ip4 = 0;
8764 if (unformat (i, "sub-domain %d", &sub_domain))
8766 else if (unformat (i, "set %d", &set))
8768 else if (unformat (i, "hdr-len %d", &hdr_len))
8770 else if (unformat (i, "bp %d", &bp))
8772 else if (unformat (i, "add"))
8774 else if (unformat (i, "del"))
8776 else if (unformat (i, "out-label %d", &next_hop_out_label))
8780 clib_warning ("parse error '%U'", format_unformat_error, i);
8785 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
8787 errmsg ("next hop / label set\n");
8792 errmsg ("bit=position not set\n");
8796 /* Construct the API message */
8797 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
8799 mp->br_is_add = is_add;
8800 mp->br_route.br_tbl_id.bt_set = set;
8801 mp->br_route.br_tbl_id.bt_sub_domain = sub_domain;
8802 mp->br_route.br_tbl_id.bt_hdr_len_id = hdr_len;
8803 mp->br_route.br_bp = ntohs (bp);
8804 mp->br_route.br_n_paths = 1;
8805 mp->br_route.br_paths[0].n_labels = 1;
8806 mp->br_route.br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
8807 mp->br_route.br_paths[0].proto = (next_hop_proto_is_ip4 ?
8808 FIB_API_PATH_NH_PROTO_IP4 :
8809 FIB_API_PATH_NH_PROTO_IP6);
8811 if (next_hop_proto_is_ip4)
8813 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip4,
8814 &v4_next_hop_address, sizeof (v4_next_hop_address));
8818 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip6,
8819 &v6_next_hop_address, sizeof (v6_next_hop_address));
8825 /* Wait for a reply... */
8832 api_proxy_arp_add_del (vat_main_t * vam)
8834 unformat_input_t *i = vam->input;
8835 vl_api_proxy_arp_add_del_t *mp;
8838 vl_api_ip4_address_t lo, hi;
8842 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8844 if (unformat (i, "vrf %d", &vrf_id))
8846 else if (unformat (i, "%U - %U", unformat_vl_api_ip4_address, &lo,
8847 unformat_vl_api_ip4_address, &hi))
8849 else if (unformat (i, "del"))
8853 clib_warning ("parse error '%U'", format_unformat_error, i);
8860 errmsg ("address range not set");
8864 M (PROXY_ARP_ADD_DEL, mp);
8866 mp->proxy.table_id = ntohl (vrf_id);
8867 mp->is_add = is_add;
8868 clib_memcpy (mp->proxy.low, &lo, sizeof (lo));
8869 clib_memcpy (mp->proxy.hi, &hi, sizeof (hi));
8877 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
8879 unformat_input_t *i = vam->input;
8880 vl_api_proxy_arp_intfc_enable_disable_t *mp;
8883 u8 sw_if_index_set = 0;
8886 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8888 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8889 sw_if_index_set = 1;
8890 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8891 sw_if_index_set = 1;
8892 else if (unformat (i, "enable"))
8894 else if (unformat (i, "disable"))
8898 clib_warning ("parse error '%U'", format_unformat_error, i);
8903 if (sw_if_index_set == 0)
8905 errmsg ("missing interface name or sw_if_index");
8909 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
8911 mp->sw_if_index = ntohl (sw_if_index);
8912 mp->enable_disable = enable;
8920 api_mpls_tunnel_add_del (vat_main_t * vam)
8922 unformat_input_t *i = vam->input;
8923 vl_api_mpls_tunnel_add_del_t *mp;
8925 vl_api_fib_path_t paths[8];
8926 u32 sw_if_index = ~0;
8932 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8934 if (unformat (i, "add"))
8938 (i, "del %U", api_unformat_sw_if_index, vam, &sw_if_index))
8940 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
8942 else if (unformat (i, "l2-only"))
8946 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8949 if (8 == path_count)
8951 errmsg ("max 8 paths");
8957 clib_warning ("parse error '%U'", format_unformat_error, i);
8962 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8964 mp->mt_is_add = is_add;
8965 mp->mt_tunnel.mt_sw_if_index = ntohl (sw_if_index);
8966 mp->mt_tunnel.mt_l2_only = l2_only;
8967 mp->mt_tunnel.mt_is_multicast = 0;
8968 mp->mt_tunnel.mt_n_paths = path_count;
8970 clib_memcpy (&mp->mt_tunnel.mt_paths, &paths,
8971 sizeof (paths[0]) * path_count);
8979 api_sw_interface_set_unnumbered (vat_main_t * vam)
8981 unformat_input_t *i = vam->input;
8982 vl_api_sw_interface_set_unnumbered_t *mp;
8984 u32 unnum_sw_index = ~0;
8986 u8 sw_if_index_set = 0;
8989 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8991 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8992 sw_if_index_set = 1;
8993 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8994 sw_if_index_set = 1;
8995 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
8997 else if (unformat (i, "del"))
9001 clib_warning ("parse error '%U'", format_unformat_error, i);
9006 if (sw_if_index_set == 0)
9008 errmsg ("missing interface name or sw_if_index");
9012 M (SW_INTERFACE_SET_UNNUMBERED, mp);
9014 mp->sw_if_index = ntohl (sw_if_index);
9015 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
9016 mp->is_add = is_add;
9024 api_ip_neighbor_add_del (vat_main_t * vam)
9026 vl_api_mac_address_t mac_address;
9027 unformat_input_t *i = vam->input;
9028 vl_api_ip_neighbor_add_del_t *mp;
9029 vl_api_address_t ip_address;
9031 u8 sw_if_index_set = 0;
9036 ip_neighbor_flags_t flags;
9038 flags = IP_NEIGHBOR_FLAG_NONE;
9039 clib_memset (&ip_address, 0, sizeof (ip_address));
9040 clib_memset (&mac_address, 0, sizeof (mac_address));
9042 /* Parse args required to build the message */
9043 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9045 if (unformat (i, "mac %U", unformat_vl_api_mac_address, &mac_address))
9049 else if (unformat (i, "del"))
9052 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9053 sw_if_index_set = 1;
9054 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9055 sw_if_index_set = 1;
9056 else if (unformat (i, "static"))
9057 flags |= IP_NEIGHBOR_FLAG_STATIC;
9058 else if (unformat (i, "no-fib-entry"))
9059 flags |= IP_NEIGHBOR_FLAG_NO_FIB_ENTRY;
9060 else if (unformat (i, "dst %U", unformat_vl_api_address, &ip_address))
9064 clib_warning ("parse error '%U'", format_unformat_error, i);
9069 if (sw_if_index_set == 0)
9071 errmsg ("missing interface name or sw_if_index");
9076 errmsg ("no address set");
9080 /* Construct the API message */
9081 M (IP_NEIGHBOR_ADD_DEL, mp);
9083 mp->neighbor.sw_if_index = ntohl (sw_if_index);
9084 mp->is_add = is_add;
9085 mp->neighbor.flags = htonl (flags);
9087 clib_memcpy (&mp->neighbor.mac_address, &mac_address,
9088 sizeof (mac_address));
9090 clib_memcpy (&mp->neighbor.ip_address, &ip_address, sizeof (ip_address));
9095 /* Wait for a reply, return good/bad news */
9101 api_create_vlan_subif (vat_main_t * vam)
9103 unformat_input_t *i = vam->input;
9104 vl_api_create_vlan_subif_t *mp;
9106 u8 sw_if_index_set = 0;
9111 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9113 if (unformat (i, "sw_if_index %d", &sw_if_index))
9114 sw_if_index_set = 1;
9116 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9117 sw_if_index_set = 1;
9118 else if (unformat (i, "vlan %d", &vlan_id))
9122 clib_warning ("parse error '%U'", format_unformat_error, i);
9127 if (sw_if_index_set == 0)
9129 errmsg ("missing interface name or sw_if_index");
9133 if (vlan_id_set == 0)
9135 errmsg ("missing vlan_id");
9138 M (CREATE_VLAN_SUBIF, mp);
9140 mp->sw_if_index = ntohl (sw_if_index);
9141 mp->vlan_id = ntohl (vlan_id);
9148 #define foreach_create_subif_bit \
9155 _(outer_vlan_id_any) \
9156 _(inner_vlan_id_any)
9158 #define foreach_create_subif_flag \
9163 _(4, "exact_match") \
9164 _(5, "default_sub") \
9165 _(6, "outer_vlan_id_any") \
9166 _(7, "inner_vlan_id_any")
9169 api_create_subif (vat_main_t * vam)
9171 unformat_input_t *i = vam->input;
9172 vl_api_create_subif_t *mp;
9174 u8 sw_if_index_set = 0;
9177 u32 __attribute__ ((unused)) no_tags = 0;
9178 u32 __attribute__ ((unused)) one_tag = 0;
9179 u32 __attribute__ ((unused)) two_tags = 0;
9180 u32 __attribute__ ((unused)) dot1ad = 0;
9181 u32 __attribute__ ((unused)) exact_match = 0;
9182 u32 __attribute__ ((unused)) default_sub = 0;
9183 u32 __attribute__ ((unused)) outer_vlan_id_any = 0;
9184 u32 __attribute__ ((unused)) inner_vlan_id_any = 0;
9186 u16 outer_vlan_id = 0;
9187 u16 inner_vlan_id = 0;
9190 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9192 if (unformat (i, "sw_if_index %d", &sw_if_index))
9193 sw_if_index_set = 1;
9195 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9196 sw_if_index_set = 1;
9197 else if (unformat (i, "sub_id %d", &sub_id))
9199 else if (unformat (i, "outer_vlan_id %d", &tmp))
9200 outer_vlan_id = tmp;
9201 else if (unformat (i, "inner_vlan_id %d", &tmp))
9202 inner_vlan_id = tmp;
9204 #define _(a) else if (unformat (i, #a)) a = 1 ;
9205 foreach_create_subif_bit
9209 clib_warning ("parse error '%U'", format_unformat_error, i);
9214 if (sw_if_index_set == 0)
9216 errmsg ("missing interface name or sw_if_index");
9220 if (sub_id_set == 0)
9222 errmsg ("missing sub_id");
9225 M (CREATE_SUBIF, mp);
9227 mp->sw_if_index = ntohl (sw_if_index);
9228 mp->sub_id = ntohl (sub_id);
9230 #define _(a,b) mp->sub_if_flags |= (1 << a);
9231 foreach_create_subif_flag;
9234 mp->outer_vlan_id = ntohs (outer_vlan_id);
9235 mp->inner_vlan_id = ntohs (inner_vlan_id);
9243 api_reset_fib (vat_main_t * vam)
9245 unformat_input_t *i = vam->input;
9246 vl_api_reset_fib_t *mp;
9252 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9254 if (unformat (i, "vrf %d", &vrf_id))
9256 else if (unformat (i, "ipv6"))
9260 clib_warning ("parse error '%U'", format_unformat_error, i);
9265 if (vrf_id_set == 0)
9267 errmsg ("missing vrf id");
9273 mp->vrf_id = ntohl (vrf_id);
9274 mp->is_ipv6 = is_ipv6;
9282 api_dhcp_proxy_config (vat_main_t * vam)
9284 unformat_input_t *i = vam->input;
9285 vl_api_dhcp_proxy_config_t *mp;
9287 u32 server_vrf_id = 0;
9289 u8 v4_address_set = 0;
9290 u8 v6_address_set = 0;
9291 ip4_address_t v4address;
9292 ip6_address_t v6address;
9293 u8 v4_src_address_set = 0;
9294 u8 v6_src_address_set = 0;
9295 ip4_address_t v4srcaddress;
9296 ip6_address_t v6srcaddress;
9299 /* Parse args required to build the message */
9300 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9302 if (unformat (i, "del"))
9304 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
9306 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
9308 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
9310 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
9312 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
9313 v4_src_address_set = 1;
9314 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
9315 v6_src_address_set = 1;
9320 if (v4_address_set && v6_address_set)
9322 errmsg ("both v4 and v6 server addresses set");
9325 if (!v4_address_set && !v6_address_set)
9327 errmsg ("no server addresses set");
9331 if (v4_src_address_set && v6_src_address_set)
9333 errmsg ("both v4 and v6 src addresses set");
9336 if (!v4_src_address_set && !v6_src_address_set)
9338 errmsg ("no src addresses set");
9342 if (!(v4_src_address_set && v4_address_set) &&
9343 !(v6_src_address_set && v6_address_set))
9345 errmsg ("no matching server and src addresses set");
9349 /* Construct the API message */
9350 M (DHCP_PROXY_CONFIG, mp);
9352 mp->is_add = is_add;
9353 mp->rx_vrf_id = ntohl (rx_vrf_id);
9354 mp->server_vrf_id = ntohl (server_vrf_id);
9357 clib_memcpy (&mp->dhcp_server.un, &v6address, sizeof (v6address));
9358 clib_memcpy (&mp->dhcp_src_address.un, &v6srcaddress,
9359 sizeof (v6address));
9363 clib_memcpy (&mp->dhcp_server.un, &v4address, sizeof (v4address));
9364 clib_memcpy (&mp->dhcp_src_address.un, &v4srcaddress,
9365 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_uint (node, "vss-type", ntohl (mp->vss_type));
9438 vat_json_object_add_string_copy (node, "vss-vpn-ascii-id",
9439 mp->vss_vpn_ascii_id);
9440 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
9441 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
9445 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
9446 vat_json_object_add_ip6 (node, "src_address", ip6);
9450 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
9451 vat_json_object_add_ip4 (node, "src_address", ip4);
9454 for (i = 0; i < count; i++)
9456 s = &mp->servers[i];
9458 vat_json_object_add_uint (node, "server-table-id",
9459 ntohl (s->server_vrf_id));
9463 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
9464 vat_json_object_add_ip4 (node, "src_address", ip4);
9468 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
9469 vat_json_object_add_ip6 (node, "server_address", ip6);
9475 api_dhcp_proxy_dump (vat_main_t * vam)
9477 unformat_input_t *i = vam->input;
9478 vl_api_control_ping_t *mp_ping;
9479 vl_api_dhcp_proxy_dump_t *mp;
9483 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9485 if (unformat (i, "ipv6"))
9489 clib_warning ("parse error '%U'", format_unformat_error, i);
9494 M (DHCP_PROXY_DUMP, mp);
9496 mp->is_ip6 = is_ipv6;
9499 /* Use a control ping for synchronization */
9500 MPING (CONTROL_PING, mp_ping);
9508 api_dhcp_proxy_set_vss (vat_main_t * vam)
9510 unformat_input_t *i = vam->input;
9511 vl_api_dhcp_proxy_set_vss_t *mp;
9515 u8 vss_type = VSS_TYPE_DEFAULT;
9516 u8 *vpn_ascii_id = 0;
9521 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9523 if (unformat (i, "tbl_id %d", &tbl_id))
9525 else if (unformat (i, "vpn_ascii_id %s", &vpn_ascii_id))
9526 vss_type = VSS_TYPE_ASCII;
9527 else if (unformat (i, "fib_id %d", &fib_id))
9528 vss_type = VSS_TYPE_VPN_ID;
9529 else if (unformat (i, "oui %d", &oui))
9530 vss_type = VSS_TYPE_VPN_ID;
9531 else if (unformat (i, "ipv6"))
9533 else if (unformat (i, "del"))
9541 errmsg ("missing tbl_id ");
9542 vec_free (vpn_ascii_id);
9546 if ((vpn_ascii_id) && (vec_len (vpn_ascii_id) > 128))
9548 errmsg ("vpn_ascii_id cannot be longer than 128 ");
9549 vec_free (vpn_ascii_id);
9553 M (DHCP_PROXY_SET_VSS, mp);
9554 mp->tbl_id = ntohl (tbl_id);
9555 mp->vss_type = vss_type;
9558 clib_memcpy (mp->vpn_ascii_id, vpn_ascii_id, vec_len (vpn_ascii_id));
9559 mp->vpn_ascii_id[vec_len (vpn_ascii_id)] = 0;
9561 mp->vpn_index = ntohl (fib_id);
9562 mp->oui = ntohl (oui);
9563 mp->is_ipv6 = is_ipv6;
9564 mp->is_add = is_add;
9569 vec_free (vpn_ascii_id);
9574 api_dhcp_client_config (vat_main_t * vam)
9576 unformat_input_t *i = vam->input;
9577 vl_api_dhcp_client_config_t *mp;
9579 u8 sw_if_index_set = 0;
9582 u8 disable_event = 0;
9585 /* Parse args required to build the message */
9586 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9588 if (unformat (i, "del"))
9591 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9592 sw_if_index_set = 1;
9593 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9594 sw_if_index_set = 1;
9595 else if (unformat (i, "hostname %s", &hostname))
9597 else if (unformat (i, "disable_event"))
9603 if (sw_if_index_set == 0)
9605 errmsg ("missing interface name or sw_if_index");
9609 if (vec_len (hostname) > 63)
9611 errmsg ("hostname too long");
9613 vec_add1 (hostname, 0);
9615 /* Construct the API message */
9616 M (DHCP_CLIENT_CONFIG, mp);
9618 mp->is_add = is_add;
9619 mp->client.sw_if_index = htonl (sw_if_index);
9620 clib_memcpy (mp->client.hostname, hostname, vec_len (hostname));
9621 vec_free (hostname);
9622 mp->client.want_dhcp_event = disable_event ? 0 : 1;
9623 mp->client.pid = htonl (getpid ());
9628 /* Wait for a reply, return good/bad news */
9634 api_set_ip_flow_hash (vat_main_t * vam)
9636 unformat_input_t *i = vam->input;
9637 vl_api_set_ip_flow_hash_t *mp;
9649 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9651 if (unformat (i, "vrf %d", &vrf_id))
9653 else if (unformat (i, "ipv6"))
9655 else if (unformat (i, "src"))
9657 else if (unformat (i, "dst"))
9659 else if (unformat (i, "sport"))
9661 else if (unformat (i, "dport"))
9663 else if (unformat (i, "proto"))
9665 else if (unformat (i, "reverse"))
9670 clib_warning ("parse error '%U'", format_unformat_error, i);
9675 if (vrf_id_set == 0)
9677 errmsg ("missing vrf id");
9681 M (SET_IP_FLOW_HASH, mp);
9687 mp->reverse = reverse;
9688 mp->vrf_id = ntohl (vrf_id);
9689 mp->is_ipv6 = is_ipv6;
9697 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
9699 unformat_input_t *i = vam->input;
9700 vl_api_sw_interface_ip6_enable_disable_t *mp;
9702 u8 sw_if_index_set = 0;
9706 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9708 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9709 sw_if_index_set = 1;
9710 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9711 sw_if_index_set = 1;
9712 else if (unformat (i, "enable"))
9714 else if (unformat (i, "disable"))
9718 clib_warning ("parse error '%U'", format_unformat_error, i);
9723 if (sw_if_index_set == 0)
9725 errmsg ("missing interface name or sw_if_index");
9729 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
9731 mp->sw_if_index = ntohl (sw_if_index);
9732 mp->enable = enable;
9740 api_ip6nd_proxy_add_del (vat_main_t * vam)
9742 unformat_input_t *i = vam->input;
9743 vl_api_ip6nd_proxy_add_del_t *mp;
9744 u32 sw_if_index = ~0;
9745 u8 v6_address_set = 0;
9746 vl_api_ip6_address_t v6address;
9750 /* Parse args required to build the message */
9751 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9753 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9755 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9757 else if (unformat (i, "%U", unformat_vl_api_ip6_address, &v6address))
9759 if (unformat (i, "del"))
9763 clib_warning ("parse error '%U'", format_unformat_error, i);
9768 if (sw_if_index == ~0)
9770 errmsg ("missing interface name or sw_if_index");
9773 if (!v6_address_set)
9775 errmsg ("no address set");
9779 /* Construct the API message */
9780 M (IP6ND_PROXY_ADD_DEL, mp);
9782 mp->is_del = is_del;
9783 mp->sw_if_index = ntohl (sw_if_index);
9784 clib_memcpy (mp->ip, v6address, sizeof (v6address));
9789 /* Wait for a reply, return good/bad news */
9795 api_ip6nd_proxy_dump (vat_main_t * vam)
9797 vl_api_ip6nd_proxy_dump_t *mp;
9798 vl_api_control_ping_t *mp_ping;
9801 M (IP6ND_PROXY_DUMP, mp);
9805 /* Use a control ping for synchronization */
9806 MPING (CONTROL_PING, mp_ping);
9813 static void vl_api_ip6nd_proxy_details_t_handler
9814 (vl_api_ip6nd_proxy_details_t * mp)
9816 vat_main_t *vam = &vat_main;
9818 print (vam->ofp, "host %U sw_if_index %d",
9819 format_vl_api_ip6_address, mp->ip, ntohl (mp->sw_if_index));
9822 static void vl_api_ip6nd_proxy_details_t_handler_json
9823 (vl_api_ip6nd_proxy_details_t * mp)
9825 vat_main_t *vam = &vat_main;
9826 struct in6_addr ip6;
9827 vat_json_node_t *node = NULL;
9829 if (VAT_JSON_ARRAY != vam->json_tree.type)
9831 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9832 vat_json_init_array (&vam->json_tree);
9834 node = vat_json_array_add (&vam->json_tree);
9836 vat_json_init_object (node);
9837 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9839 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
9840 vat_json_object_add_ip6 (node, "host", ip6);
9844 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
9846 unformat_input_t *i = vam->input;
9847 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
9849 u8 sw_if_index_set = 0;
9850 u8 v6_address_set = 0;
9851 vl_api_prefix_t pfx;
9853 u8 no_advertise = 0;
9855 u8 no_autoconfig = 0;
9858 u32 val_lifetime = 0;
9859 u32 pref_lifetime = 0;
9862 /* Parse args required to build the message */
9863 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9865 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9866 sw_if_index_set = 1;
9867 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9868 sw_if_index_set = 1;
9869 else if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
9871 else if (unformat (i, "val_life %d", &val_lifetime))
9873 else if (unformat (i, "pref_life %d", &pref_lifetime))
9875 else if (unformat (i, "def"))
9877 else if (unformat (i, "noadv"))
9879 else if (unformat (i, "offl"))
9881 else if (unformat (i, "noauto"))
9883 else if (unformat (i, "nolink"))
9885 else if (unformat (i, "isno"))
9889 clib_warning ("parse error '%U'", format_unformat_error, i);
9894 if (sw_if_index_set == 0)
9896 errmsg ("missing interface name or sw_if_index");
9899 if (!v6_address_set)
9901 errmsg ("no address set");
9905 /* Construct the API message */
9906 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
9908 mp->sw_if_index = ntohl (sw_if_index);
9909 clib_memcpy (&mp->prefix, &pfx, sizeof (pfx));
9910 mp->use_default = use_default;
9911 mp->no_advertise = no_advertise;
9912 mp->off_link = off_link;
9913 mp->no_autoconfig = no_autoconfig;
9914 mp->no_onlink = no_onlink;
9916 mp->val_lifetime = ntohl (val_lifetime);
9917 mp->pref_lifetime = ntohl (pref_lifetime);
9922 /* Wait for a reply, return good/bad news */
9928 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
9930 unformat_input_t *i = vam->input;
9931 vl_api_sw_interface_ip6nd_ra_config_t *mp;
9933 u8 sw_if_index_set = 0;
9938 u8 send_unicast = 0;
9941 u8 default_router = 0;
9942 u32 max_interval = 0;
9943 u32 min_interval = 0;
9945 u32 initial_count = 0;
9946 u32 initial_interval = 0;
9950 /* Parse args required to build the message */
9951 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9953 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9954 sw_if_index_set = 1;
9955 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9956 sw_if_index_set = 1;
9957 else if (unformat (i, "maxint %d", &max_interval))
9959 else if (unformat (i, "minint %d", &min_interval))
9961 else if (unformat (i, "life %d", &lifetime))
9963 else if (unformat (i, "count %d", &initial_count))
9965 else if (unformat (i, "interval %d", &initial_interval))
9967 else if (unformat (i, "suppress") || unformat (i, "surpress"))
9969 else if (unformat (i, "managed"))
9971 else if (unformat (i, "other"))
9973 else if (unformat (i, "ll"))
9975 else if (unformat (i, "send"))
9977 else if (unformat (i, "cease"))
9979 else if (unformat (i, "isno"))
9981 else if (unformat (i, "def"))
9985 clib_warning ("parse error '%U'", format_unformat_error, i);
9990 if (sw_if_index_set == 0)
9992 errmsg ("missing interface name or sw_if_index");
9996 /* Construct the API message */
9997 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
9999 mp->sw_if_index = ntohl (sw_if_index);
10000 mp->max_interval = ntohl (max_interval);
10001 mp->min_interval = ntohl (min_interval);
10002 mp->lifetime = ntohl (lifetime);
10003 mp->initial_count = ntohl (initial_count);
10004 mp->initial_interval = ntohl (initial_interval);
10005 mp->suppress = suppress;
10006 mp->managed = managed;
10008 mp->ll_option = ll_option;
10009 mp->send_unicast = send_unicast;
10012 mp->default_router = default_router;
10017 /* Wait for a reply, return good/bad news */
10023 api_set_arp_neighbor_limit (vat_main_t * vam)
10025 unformat_input_t *i = vam->input;
10026 vl_api_set_arp_neighbor_limit_t *mp;
10032 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10034 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
10036 else if (unformat (i, "ipv6"))
10040 clib_warning ("parse error '%U'", format_unformat_error, i);
10045 if (limit_set == 0)
10047 errmsg ("missing limit value");
10051 M (SET_ARP_NEIGHBOR_LIMIT, mp);
10053 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
10054 mp->is_ipv6 = is_ipv6;
10062 api_l2_patch_add_del (vat_main_t * vam)
10064 unformat_input_t *i = vam->input;
10065 vl_api_l2_patch_add_del_t *mp;
10066 u32 rx_sw_if_index;
10067 u8 rx_sw_if_index_set = 0;
10068 u32 tx_sw_if_index;
10069 u8 tx_sw_if_index_set = 0;
10073 /* Parse args required to build the message */
10074 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10076 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
10077 rx_sw_if_index_set = 1;
10078 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
10079 tx_sw_if_index_set = 1;
10080 else if (unformat (i, "rx"))
10082 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10084 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10086 rx_sw_if_index_set = 1;
10091 else if (unformat (i, "tx"))
10093 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10095 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10097 tx_sw_if_index_set = 1;
10102 else if (unformat (i, "del"))
10108 if (rx_sw_if_index_set == 0)
10110 errmsg ("missing rx interface name or rx_sw_if_index");
10114 if (tx_sw_if_index_set == 0)
10116 errmsg ("missing tx interface name or tx_sw_if_index");
10120 M (L2_PATCH_ADD_DEL, mp);
10122 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
10123 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
10124 mp->is_add = is_add;
10132 u8 localsid_addr[16];
10141 api_sr_localsid_add_del (vat_main_t * vam)
10143 unformat_input_t *i = vam->input;
10144 vl_api_sr_localsid_add_del_t *mp;
10147 ip6_address_t localsid;
10151 u32 fib_table = ~(u32) 0;
10152 ip6_address_t nh_addr6;
10153 ip4_address_t nh_addr4;
10154 clib_memset (&nh_addr6, 0, sizeof (ip6_address_t));
10155 clib_memset (&nh_addr4, 0, sizeof (ip4_address_t));
10157 bool nexthop_set = 0;
10161 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10163 if (unformat (i, "del"))
10165 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
10166 else if (unformat (i, "next-hop %U", unformat_ip4_address, &nh_addr4))
10168 else if (unformat (i, "next-hop %U", unformat_ip6_address, &nh_addr6))
10170 else if (unformat (i, "behavior %u", &behavior));
10171 else if (unformat (i, "sw_if_index %u", &sw_if_index));
10172 else if (unformat (i, "fib-table %u", &fib_table));
10173 else if (unformat (i, "end.psp %u", &behavior));
10178 M (SR_LOCALSID_ADD_DEL, mp);
10180 clib_memcpy (mp->localsid.addr, &localsid, sizeof (mp->localsid));
10183 clib_memcpy (mp->nh_addr6, &nh_addr6, sizeof (mp->nh_addr6));
10184 clib_memcpy (mp->nh_addr4, &nh_addr4, sizeof (mp->nh_addr4));
10186 mp->behavior = behavior;
10187 mp->sw_if_index = ntohl (sw_if_index);
10188 mp->fib_table = ntohl (fib_table);
10189 mp->end_psp = end_psp;
10190 mp->is_del = is_del;
10198 api_ioam_enable (vat_main_t * vam)
10200 unformat_input_t *input = vam->input;
10201 vl_api_ioam_enable_t *mp;
10203 int has_trace_option = 0;
10204 int has_pot_option = 0;
10205 int has_seqno_option = 0;
10206 int has_analyse_option = 0;
10209 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10211 if (unformat (input, "trace"))
10212 has_trace_option = 1;
10213 else if (unformat (input, "pot"))
10214 has_pot_option = 1;
10215 else if (unformat (input, "seqno"))
10216 has_seqno_option = 1;
10217 else if (unformat (input, "analyse"))
10218 has_analyse_option = 1;
10222 M (IOAM_ENABLE, mp);
10223 mp->id = htons (id);
10224 mp->seqno = has_seqno_option;
10225 mp->analyse = has_analyse_option;
10226 mp->pot_enable = has_pot_option;
10227 mp->trace_enable = has_trace_option;
10236 api_ioam_disable (vat_main_t * vam)
10238 vl_api_ioam_disable_t *mp;
10241 M (IOAM_DISABLE, mp);
10247 #define foreach_tcp_proto_field \
10251 #define foreach_udp_proto_field \
10255 #define foreach_ip4_proto_field \
10267 u16 src_port, dst_port;
10270 #if VPP_API_TEST_BUILTIN == 0
10272 unformat_tcp_mask (unformat_input_t * input, va_list * args)
10274 u8 **maskp = va_arg (*args, u8 **);
10276 u8 found_something = 0;
10279 #define _(a) u8 a=0;
10280 foreach_tcp_proto_field;
10283 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10286 #define _(a) else if (unformat (input, #a)) a=1;
10287 foreach_tcp_proto_field
10293 #define _(a) found_something += a;
10294 foreach_tcp_proto_field;
10297 if (found_something == 0)
10300 vec_validate (mask, sizeof (*tcp) - 1);
10302 tcp = (tcp_header_t *) mask;
10304 #define _(a) if (a) clib_memset (&tcp->a, 0xff, sizeof (tcp->a));
10305 foreach_tcp_proto_field;
10313 unformat_udp_mask (unformat_input_t * input, va_list * args)
10315 u8 **maskp = va_arg (*args, u8 **);
10317 u8 found_something = 0;
10320 #define _(a) u8 a=0;
10321 foreach_udp_proto_field;
10324 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10327 #define _(a) else if (unformat (input, #a)) a=1;
10328 foreach_udp_proto_field
10334 #define _(a) found_something += a;
10335 foreach_udp_proto_field;
10338 if (found_something == 0)
10341 vec_validate (mask, sizeof (*udp) - 1);
10343 udp = (udp_header_t *) mask;
10345 #define _(a) if (a) clib_memset (&udp->a, 0xff, sizeof (udp->a));
10346 foreach_udp_proto_field;
10354 unformat_l4_mask (unformat_input_t * input, va_list * args)
10356 u8 **maskp = va_arg (*args, u8 **);
10357 u16 src_port = 0, dst_port = 0;
10358 tcpudp_header_t *tcpudp;
10360 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10362 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
10364 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
10366 else if (unformat (input, "src_port"))
10368 else if (unformat (input, "dst_port"))
10374 if (!src_port && !dst_port)
10378 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
10380 tcpudp = (tcpudp_header_t *) mask;
10381 tcpudp->src_port = src_port;
10382 tcpudp->dst_port = dst_port;
10390 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10392 u8 **maskp = va_arg (*args, u8 **);
10394 u8 found_something = 0;
10397 #define _(a) u8 a=0;
10398 foreach_ip4_proto_field;
10404 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10406 if (unformat (input, "version"))
10408 else if (unformat (input, "hdr_length"))
10410 else if (unformat (input, "src"))
10412 else if (unformat (input, "dst"))
10414 else if (unformat (input, "proto"))
10417 #define _(a) else if (unformat (input, #a)) a=1;
10418 foreach_ip4_proto_field
10424 #define _(a) found_something += a;
10425 foreach_ip4_proto_field;
10428 if (found_something == 0)
10431 vec_validate (mask, sizeof (*ip) - 1);
10433 ip = (ip4_header_t *) mask;
10435 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
10436 foreach_ip4_proto_field;
10439 ip->ip_version_and_header_length = 0;
10442 ip->ip_version_and_header_length |= 0xF0;
10445 ip->ip_version_and_header_length |= 0x0F;
10451 #define foreach_ip6_proto_field \
10454 _(payload_length) \
10459 unformat_ip6_mask (unformat_input_t * input, va_list * args)
10461 u8 **maskp = va_arg (*args, u8 **);
10463 u8 found_something = 0;
10465 u32 ip_version_traffic_class_and_flow_label;
10467 #define _(a) u8 a=0;
10468 foreach_ip6_proto_field;
10471 u8 traffic_class = 0;
10474 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10476 if (unformat (input, "version"))
10478 else if (unformat (input, "traffic-class"))
10480 else if (unformat (input, "flow-label"))
10482 else if (unformat (input, "src"))
10484 else if (unformat (input, "dst"))
10486 else if (unformat (input, "proto"))
10489 #define _(a) else if (unformat (input, #a)) a=1;
10490 foreach_ip6_proto_field
10496 #define _(a) found_something += a;
10497 foreach_ip6_proto_field;
10500 if (found_something == 0)
10503 vec_validate (mask, sizeof (*ip) - 1);
10505 ip = (ip6_header_t *) mask;
10507 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
10508 foreach_ip6_proto_field;
10511 ip_version_traffic_class_and_flow_label = 0;
10514 ip_version_traffic_class_and_flow_label |= 0xF0000000;
10517 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
10520 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
10522 ip->ip_version_traffic_class_and_flow_label =
10523 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10530 unformat_l3_mask (unformat_input_t * input, va_list * args)
10532 u8 **maskp = va_arg (*args, u8 **);
10534 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10536 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
10538 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
10547 unformat_l2_mask (unformat_input_t * input, va_list * args)
10549 u8 **maskp = va_arg (*args, u8 **);
10556 u8 ignore_tag1 = 0;
10557 u8 ignore_tag2 = 0;
10564 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10566 if (unformat (input, "src"))
10568 else if (unformat (input, "dst"))
10570 else if (unformat (input, "proto"))
10572 else if (unformat (input, "tag1"))
10574 else if (unformat (input, "tag2"))
10576 else if (unformat (input, "ignore-tag1"))
10578 else if (unformat (input, "ignore-tag2"))
10580 else if (unformat (input, "cos1"))
10582 else if (unformat (input, "cos2"))
10584 else if (unformat (input, "dot1q"))
10586 else if (unformat (input, "dot1ad"))
10591 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
10592 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10595 if (tag1 || ignore_tag1 || cos1 || dot1q)
10597 if (tag2 || ignore_tag2 || cos2 || dot1ad)
10600 vec_validate (mask, len - 1);
10603 clib_memset (mask, 0xff, 6);
10606 clib_memset (mask + 6, 0xff, 6);
10608 if (tag2 || dot1ad)
10610 /* inner vlan tag */
10619 mask[21] = mask[20] = 0xff;
10640 mask[16] = mask[17] = 0xff;
10650 mask[12] = mask[13] = 0xff;
10657 unformat_classify_mask (unformat_input_t * input, va_list * args)
10659 u8 **maskp = va_arg (*args, u8 **);
10660 u32 *skipp = va_arg (*args, u32 *);
10661 u32 *matchp = va_arg (*args, u32 *);
10669 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10671 if (unformat (input, "hex %U", unformat_hex_string, &mask))
10673 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
10675 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
10677 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
10691 if (mask || l2 || l3 || l4)
10693 if (l2 || l3 || l4)
10695 /* "With a free Ethernet header in every package" */
10697 vec_validate (l2, 13);
10701 vec_append (mask, l3);
10706 vec_append (mask, l4);
10711 /* Scan forward looking for the first significant mask octet */
10712 for (i = 0; i < vec_len (mask); i++)
10716 /* compute (skip, match) params */
10717 *skipp = i / sizeof (u32x4);
10718 vec_delete (mask, *skipp * sizeof (u32x4), 0);
10720 /* Pad mask to an even multiple of the vector size */
10721 while (vec_len (mask) % sizeof (u32x4))
10722 vec_add1 (mask, 0);
10724 match = vec_len (mask) / sizeof (u32x4);
10726 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
10728 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
10729 if (*tmp || *(tmp + 1))
10734 clib_warning ("BUG: match 0");
10736 _vec_len (mask) = match * sizeof (u32x4);
10746 #endif /* VPP_API_TEST_BUILTIN */
10748 #define foreach_l2_next \
10750 _(ethernet, ETHERNET_INPUT) \
10751 _(ip4, IP4_INPUT) \
10755 unformat_l2_next_index (unformat_input_t * input, va_list * args)
10757 u32 *miss_next_indexp = va_arg (*args, u32 *);
10758 u32 next_index = 0;
10762 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
10766 if (unformat (input, "%d", &tmp))
10775 *miss_next_indexp = next_index;
10779 #define foreach_ip_next \
10782 _(rewrite, REWRITE)
10785 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
10787 u32 *miss_next_indexp = va_arg (*args, u32 *);
10788 u32 next_index = 0;
10792 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
10796 if (unformat (input, "%d", &tmp))
10805 *miss_next_indexp = next_index;
10809 #define foreach_acl_next \
10813 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
10815 u32 *miss_next_indexp = va_arg (*args, u32 *);
10816 u32 next_index = 0;
10820 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
10824 if (unformat (input, "permit"))
10829 else if (unformat (input, "%d", &tmp))
10838 *miss_next_indexp = next_index;
10843 unformat_policer_precolor (unformat_input_t * input, va_list * args)
10845 u32 *r = va_arg (*args, u32 *);
10847 if (unformat (input, "conform-color"))
10848 *r = POLICE_CONFORM;
10849 else if (unformat (input, "exceed-color"))
10850 *r = POLICE_EXCEED;
10858 api_classify_add_del_table (vat_main_t * vam)
10860 unformat_input_t *i = vam->input;
10861 vl_api_classify_add_del_table_t *mp;
10868 u32 table_index = ~0;
10869 u32 next_table_index = ~0;
10870 u32 miss_next_index = ~0;
10871 u32 memory_size = 32 << 20;
10873 u32 current_data_flag = 0;
10874 int current_data_offset = 0;
10877 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10879 if (unformat (i, "del"))
10881 else if (unformat (i, "del-chain"))
10886 else if (unformat (i, "buckets %d", &nbuckets))
10888 else if (unformat (i, "memory_size %d", &memory_size))
10890 else if (unformat (i, "skip %d", &skip))
10892 else if (unformat (i, "match %d", &match))
10894 else if (unformat (i, "table %d", &table_index))
10896 else if (unformat (i, "mask %U", unformat_classify_mask,
10897 &mask, &skip, &match))
10899 else if (unformat (i, "next-table %d", &next_table_index))
10901 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
10904 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
10907 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
10910 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
10912 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
10918 if (is_add && mask == 0)
10920 errmsg ("Mask required");
10924 if (is_add && skip == ~0)
10926 errmsg ("skip count required");
10930 if (is_add && match == ~0)
10932 errmsg ("match count required");
10936 if (!is_add && table_index == ~0)
10938 errmsg ("table index required for delete");
10942 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
10944 mp->is_add = is_add;
10945 mp->del_chain = del_chain;
10946 mp->table_index = ntohl (table_index);
10947 mp->nbuckets = ntohl (nbuckets);
10948 mp->memory_size = ntohl (memory_size);
10949 mp->skip_n_vectors = ntohl (skip);
10950 mp->match_n_vectors = ntohl (match);
10951 mp->next_table_index = ntohl (next_table_index);
10952 mp->miss_next_index = ntohl (miss_next_index);
10953 mp->current_data_flag = ntohl (current_data_flag);
10954 mp->current_data_offset = ntohl (current_data_offset);
10955 mp->mask_len = ntohl (vec_len (mask));
10956 clib_memcpy (mp->mask, mask, vec_len (mask));
10965 #if VPP_API_TEST_BUILTIN == 0
10967 unformat_l4_match (unformat_input_t * input, va_list * args)
10969 u8 **matchp = va_arg (*args, u8 **);
10971 u8 *proto_header = 0;
10977 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10979 if (unformat (input, "src_port %d", &src_port))
10981 else if (unformat (input, "dst_port %d", &dst_port))
10987 h.src_port = clib_host_to_net_u16 (src_port);
10988 h.dst_port = clib_host_to_net_u16 (dst_port);
10989 vec_validate (proto_header, sizeof (h) - 1);
10990 memcpy (proto_header, &h, sizeof (h));
10992 *matchp = proto_header;
10998 unformat_ip4_match (unformat_input_t * input, va_list * args)
11000 u8 **matchp = va_arg (*args, u8 **);
11005 int hdr_length = 0;
11006 u32 hdr_length_val;
11007 int src = 0, dst = 0;
11008 ip4_address_t src_val, dst_val;
11015 int fragment_id = 0;
11016 u32 fragment_id_val;
11022 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11024 if (unformat (input, "version %d", &version_val))
11026 else if (unformat (input, "hdr_length %d", &hdr_length_val))
11028 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
11030 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
11032 else if (unformat (input, "proto %d", &proto_val))
11034 else if (unformat (input, "tos %d", &tos_val))
11036 else if (unformat (input, "length %d", &length_val))
11038 else if (unformat (input, "fragment_id %d", &fragment_id_val))
11040 else if (unformat (input, "ttl %d", &ttl_val))
11042 else if (unformat (input, "checksum %d", &checksum_val))
11048 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
11049 + ttl + checksum == 0)
11053 * Aligned because we use the real comparison functions
11055 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11057 ip = (ip4_header_t *) match;
11059 /* These are realistically matched in practice */
11061 ip->src_address.as_u32 = src_val.as_u32;
11064 ip->dst_address.as_u32 = dst_val.as_u32;
11067 ip->protocol = proto_val;
11070 /* These are not, but they're included for completeness */
11072 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
11075 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
11081 ip->length = clib_host_to_net_u16 (length_val);
11087 ip->checksum = clib_host_to_net_u16 (checksum_val);
11094 unformat_ip6_match (unformat_input_t * input, va_list * args)
11096 u8 **matchp = va_arg (*args, u8 **);
11101 u8 traffic_class = 0;
11102 u32 traffic_class_val = 0;
11105 int src = 0, dst = 0;
11106 ip6_address_t src_val, dst_val;
11109 int payload_length = 0;
11110 u32 payload_length_val;
11113 u32 ip_version_traffic_class_and_flow_label;
11115 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11117 if (unformat (input, "version %d", &version_val))
11119 else if (unformat (input, "traffic_class %d", &traffic_class_val))
11121 else if (unformat (input, "flow_label %d", &flow_label_val))
11123 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
11125 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
11127 else if (unformat (input, "proto %d", &proto_val))
11129 else if (unformat (input, "payload_length %d", &payload_length_val))
11130 payload_length = 1;
11131 else if (unformat (input, "hop_limit %d", &hop_limit_val))
11137 if (version + traffic_class + flow_label + src + dst + proto +
11138 payload_length + hop_limit == 0)
11142 * Aligned because we use the real comparison functions
11144 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11146 ip = (ip6_header_t *) match;
11149 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
11152 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
11155 ip->protocol = proto_val;
11157 ip_version_traffic_class_and_flow_label = 0;
11160 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
11163 ip_version_traffic_class_and_flow_label |=
11164 (traffic_class_val & 0xFF) << 20;
11167 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
11169 ip->ip_version_traffic_class_and_flow_label =
11170 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11172 if (payload_length)
11173 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
11176 ip->hop_limit = hop_limit_val;
11183 unformat_l3_match (unformat_input_t * input, va_list * args)
11185 u8 **matchp = va_arg (*args, u8 **);
11187 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11189 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
11191 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
11200 unformat_vlan_tag (unformat_input_t * input, va_list * args)
11202 u8 *tagp = va_arg (*args, u8 *);
11205 if (unformat (input, "%d", &tag))
11207 tagp[0] = (tag >> 8) & 0x0F;
11208 tagp[1] = tag & 0xFF;
11216 unformat_l2_match (unformat_input_t * input, va_list * args)
11218 u8 **matchp = va_arg (*args, u8 **);
11231 u8 ignore_tag1 = 0;
11232 u8 ignore_tag2 = 0;
11238 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11240 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
11243 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
11245 else if (unformat (input, "proto %U",
11246 unformat_ethernet_type_host_byte_order, &proto_val))
11248 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
11250 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
11252 else if (unformat (input, "ignore-tag1"))
11254 else if (unformat (input, "ignore-tag2"))
11256 else if (unformat (input, "cos1 %d", &cos1_val))
11258 else if (unformat (input, "cos2 %d", &cos2_val))
11263 if ((src + dst + proto + tag1 + tag2 +
11264 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11267 if (tag1 || ignore_tag1 || cos1)
11269 if (tag2 || ignore_tag2 || cos2)
11272 vec_validate_aligned (match, len - 1, sizeof (u32x4));
11275 clib_memcpy (match, dst_val, 6);
11278 clib_memcpy (match + 6, src_val, 6);
11282 /* inner vlan tag */
11283 match[19] = tag2_val[1];
11284 match[18] = tag2_val[0];
11286 match[18] |= (cos2_val & 0x7) << 5;
11289 match[21] = proto_val & 0xff;
11290 match[20] = proto_val >> 8;
11294 match[15] = tag1_val[1];
11295 match[14] = tag1_val[0];
11298 match[14] |= (cos1_val & 0x7) << 5;
11304 match[15] = tag1_val[1];
11305 match[14] = tag1_val[0];
11308 match[17] = proto_val & 0xff;
11309 match[16] = proto_val >> 8;
11312 match[14] |= (cos1_val & 0x7) << 5;
11318 match[18] |= (cos2_val & 0x7) << 5;
11320 match[14] |= (cos1_val & 0x7) << 5;
11323 match[13] = proto_val & 0xff;
11324 match[12] = proto_val >> 8;
11332 unformat_qos_source (unformat_input_t * input, va_list * args)
11334 int *qs = va_arg (*args, int *);
11336 if (unformat (input, "ip"))
11337 *qs = QOS_SOURCE_IP;
11338 else if (unformat (input, "mpls"))
11339 *qs = QOS_SOURCE_MPLS;
11340 else if (unformat (input, "ext"))
11341 *qs = QOS_SOURCE_EXT;
11342 else if (unformat (input, "vlan"))
11343 *qs = QOS_SOURCE_VLAN;
11352 api_unformat_classify_match (unformat_input_t * input, va_list * args)
11354 u8 **matchp = va_arg (*args, u8 **);
11355 u32 skip_n_vectors = va_arg (*args, u32);
11356 u32 match_n_vectors = va_arg (*args, u32);
11363 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11365 if (unformat (input, "hex %U", unformat_hex_string, &match))
11367 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
11369 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
11371 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11385 if (match || l2 || l3 || l4)
11387 if (l2 || l3 || l4)
11389 /* "Win a free Ethernet header in every packet" */
11391 vec_validate_aligned (l2, 13, sizeof (u32x4));
11395 vec_append_aligned (match, l3, sizeof (u32x4));
11400 vec_append_aligned (match, l4, sizeof (u32x4));
11405 /* Make sure the vector is big enough even if key is all 0's */
11406 vec_validate_aligned
11407 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11410 /* Set size, include skipped vectors */
11411 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11422 api_classify_add_del_session (vat_main_t * vam)
11424 unformat_input_t *i = vam->input;
11425 vl_api_classify_add_del_session_t *mp;
11427 u32 table_index = ~0;
11428 u32 hit_next_index = ~0;
11429 u32 opaque_index = ~0;
11432 u32 skip_n_vectors = 0;
11433 u32 match_n_vectors = 0;
11439 * Warning: you have to supply skip_n and match_n
11440 * because the API client cant simply look at the classify
11444 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11446 if (unformat (i, "del"))
11448 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
11451 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
11454 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
11457 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
11459 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
11461 else if (unformat (i, "opaque-index %d", &opaque_index))
11463 else if (unformat (i, "skip_n %d", &skip_n_vectors))
11465 else if (unformat (i, "match_n %d", &match_n_vectors))
11467 else if (unformat (i, "match %U", api_unformat_classify_match,
11468 &match, skip_n_vectors, match_n_vectors))
11470 else if (unformat (i, "advance %d", &advance))
11472 else if (unformat (i, "table-index %d", &table_index))
11474 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
11476 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
11478 else if (unformat (i, "action %d", &action))
11480 else if (unformat (i, "metadata %d", &metadata))
11486 if (table_index == ~0)
11488 errmsg ("Table index required");
11492 if (is_add && match == 0)
11494 errmsg ("Match value required");
11498 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
11500 mp->is_add = is_add;
11501 mp->table_index = ntohl (table_index);
11502 mp->hit_next_index = ntohl (hit_next_index);
11503 mp->opaque_index = ntohl (opaque_index);
11504 mp->advance = ntohl (advance);
11505 mp->action = action;
11506 mp->metadata = ntohl (metadata);
11507 mp->match_len = ntohl (vec_len (match));
11508 clib_memcpy (mp->match, match, vec_len (match));
11517 api_classify_set_interface_ip_table (vat_main_t * vam)
11519 unformat_input_t *i = vam->input;
11520 vl_api_classify_set_interface_ip_table_t *mp;
11522 int sw_if_index_set;
11523 u32 table_index = ~0;
11527 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11529 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11530 sw_if_index_set = 1;
11531 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11532 sw_if_index_set = 1;
11533 else if (unformat (i, "table %d", &table_index))
11537 clib_warning ("parse error '%U'", format_unformat_error, i);
11542 if (sw_if_index_set == 0)
11544 errmsg ("missing interface name or sw_if_index");
11549 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
11551 mp->sw_if_index = ntohl (sw_if_index);
11552 mp->table_index = ntohl (table_index);
11553 mp->is_ipv6 = is_ipv6;
11561 api_classify_set_interface_l2_tables (vat_main_t * vam)
11563 unformat_input_t *i = vam->input;
11564 vl_api_classify_set_interface_l2_tables_t *mp;
11566 int sw_if_index_set;
11567 u32 ip4_table_index = ~0;
11568 u32 ip6_table_index = ~0;
11569 u32 other_table_index = ~0;
11573 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11575 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11576 sw_if_index_set = 1;
11577 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11578 sw_if_index_set = 1;
11579 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11581 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11583 else if (unformat (i, "other-table %d", &other_table_index))
11585 else if (unformat (i, "is-input %d", &is_input))
11589 clib_warning ("parse error '%U'", format_unformat_error, i);
11594 if (sw_if_index_set == 0)
11596 errmsg ("missing interface name or sw_if_index");
11601 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
11603 mp->sw_if_index = ntohl (sw_if_index);
11604 mp->ip4_table_index = ntohl (ip4_table_index);
11605 mp->ip6_table_index = ntohl (ip6_table_index);
11606 mp->other_table_index = ntohl (other_table_index);
11607 mp->is_input = (u8) is_input;
11615 api_set_ipfix_exporter (vat_main_t * vam)
11617 unformat_input_t *i = vam->input;
11618 vl_api_set_ipfix_exporter_t *mp;
11619 ip4_address_t collector_address;
11620 u8 collector_address_set = 0;
11621 u32 collector_port = ~0;
11622 ip4_address_t src_address;
11623 u8 src_address_set = 0;
11626 u32 template_interval = ~0;
11627 u8 udp_checksum = 0;
11630 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11632 if (unformat (i, "collector_address %U", unformat_ip4_address,
11633 &collector_address))
11634 collector_address_set = 1;
11635 else if (unformat (i, "collector_port %d", &collector_port))
11637 else if (unformat (i, "src_address %U", unformat_ip4_address,
11639 src_address_set = 1;
11640 else if (unformat (i, "vrf_id %d", &vrf_id))
11642 else if (unformat (i, "path_mtu %d", &path_mtu))
11644 else if (unformat (i, "template_interval %d", &template_interval))
11646 else if (unformat (i, "udp_checksum"))
11652 if (collector_address_set == 0)
11654 errmsg ("collector_address required");
11658 if (src_address_set == 0)
11660 errmsg ("src_address required");
11664 M (SET_IPFIX_EXPORTER, mp);
11666 memcpy (mp->collector_address, collector_address.data,
11667 sizeof (collector_address.data));
11668 mp->collector_port = htons ((u16) collector_port);
11669 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
11670 mp->vrf_id = htonl (vrf_id);
11671 mp->path_mtu = htonl (path_mtu);
11672 mp->template_interval = htonl (template_interval);
11673 mp->udp_checksum = udp_checksum;
11681 api_set_ipfix_classify_stream (vat_main_t * vam)
11683 unformat_input_t *i = vam->input;
11684 vl_api_set_ipfix_classify_stream_t *mp;
11686 u32 src_port = UDP_DST_PORT_ipfix;
11689 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11691 if (unformat (i, "domain %d", &domain_id))
11693 else if (unformat (i, "src_port %d", &src_port))
11697 errmsg ("unknown input `%U'", format_unformat_error, i);
11702 M (SET_IPFIX_CLASSIFY_STREAM, mp);
11704 mp->domain_id = htonl (domain_id);
11705 mp->src_port = htons ((u16) src_port);
11713 api_ipfix_classify_table_add_del (vat_main_t * vam)
11715 unformat_input_t *i = vam->input;
11716 vl_api_ipfix_classify_table_add_del_t *mp;
11718 u32 classify_table_index = ~0;
11720 u8 transport_protocol = 255;
11723 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11725 if (unformat (i, "add"))
11727 else if (unformat (i, "del"))
11729 else if (unformat (i, "table %d", &classify_table_index))
11731 else if (unformat (i, "ip4"))
11733 else if (unformat (i, "ip6"))
11735 else if (unformat (i, "tcp"))
11736 transport_protocol = 6;
11737 else if (unformat (i, "udp"))
11738 transport_protocol = 17;
11741 errmsg ("unknown input `%U'", format_unformat_error, i);
11748 errmsg ("expecting: add|del");
11751 if (classify_table_index == ~0)
11753 errmsg ("classifier table not specified");
11756 if (ip_version == 0)
11758 errmsg ("IP version not specified");
11762 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
11764 mp->is_add = is_add;
11765 mp->table_id = htonl (classify_table_index);
11766 mp->ip_version = ip_version;
11767 mp->transport_protocol = transport_protocol;
11775 api_get_node_index (vat_main_t * vam)
11777 unformat_input_t *i = vam->input;
11778 vl_api_get_node_index_t *mp;
11782 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11784 if (unformat (i, "node %s", &name))
11791 errmsg ("node name required");
11794 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11796 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11800 M (GET_NODE_INDEX, mp);
11801 clib_memcpy (mp->node_name, name, vec_len (name));
11810 api_get_next_index (vat_main_t * vam)
11812 unformat_input_t *i = vam->input;
11813 vl_api_get_next_index_t *mp;
11814 u8 *node_name = 0, *next_node_name = 0;
11817 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11819 if (unformat (i, "node-name %s", &node_name))
11821 else if (unformat (i, "next-node-name %s", &next_node_name))
11825 if (node_name == 0)
11827 errmsg ("node name required");
11830 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
11832 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11836 if (next_node_name == 0)
11838 errmsg ("next node name required");
11841 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
11843 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
11847 M (GET_NEXT_INDEX, mp);
11848 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
11849 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
11850 vec_free (node_name);
11851 vec_free (next_node_name);
11859 api_add_node_next (vat_main_t * vam)
11861 unformat_input_t *i = vam->input;
11862 vl_api_add_node_next_t *mp;
11867 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11869 if (unformat (i, "node %s", &name))
11871 else if (unformat (i, "next %s", &next))
11878 errmsg ("node name required");
11881 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11883 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11888 errmsg ("next node required");
11891 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
11893 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
11897 M (ADD_NODE_NEXT, mp);
11898 clib_memcpy (mp->node_name, name, vec_len (name));
11899 clib_memcpy (mp->next_name, next, vec_len (next));
11909 api_l2tpv3_create_tunnel (vat_main_t * vam)
11911 unformat_input_t *i = vam->input;
11912 ip6_address_t client_address, our_address;
11913 int client_address_set = 0;
11914 int our_address_set = 0;
11915 u32 local_session_id = 0;
11916 u32 remote_session_id = 0;
11917 u64 local_cookie = 0;
11918 u64 remote_cookie = 0;
11919 u8 l2_sublayer_present = 0;
11920 vl_api_l2tpv3_create_tunnel_t *mp;
11923 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11925 if (unformat (i, "client_address %U", unformat_ip6_address,
11927 client_address_set = 1;
11928 else if (unformat (i, "our_address %U", unformat_ip6_address,
11930 our_address_set = 1;
11931 else if (unformat (i, "local_session_id %d", &local_session_id))
11933 else if (unformat (i, "remote_session_id %d", &remote_session_id))
11935 else if (unformat (i, "local_cookie %lld", &local_cookie))
11937 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
11939 else if (unformat (i, "l2-sublayer-present"))
11940 l2_sublayer_present = 1;
11945 if (client_address_set == 0)
11947 errmsg ("client_address required");
11951 if (our_address_set == 0)
11953 errmsg ("our_address required");
11957 M (L2TPV3_CREATE_TUNNEL, mp);
11959 clib_memcpy (mp->client_address, client_address.as_u8,
11960 sizeof (mp->client_address));
11962 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
11964 mp->local_session_id = ntohl (local_session_id);
11965 mp->remote_session_id = ntohl (remote_session_id);
11966 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
11967 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
11968 mp->l2_sublayer_present = l2_sublayer_present;
11977 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
11979 unformat_input_t *i = vam->input;
11981 u8 sw_if_index_set = 0;
11982 u64 new_local_cookie = 0;
11983 u64 new_remote_cookie = 0;
11984 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
11987 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11989 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11990 sw_if_index_set = 1;
11991 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11992 sw_if_index_set = 1;
11993 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
11995 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
12001 if (sw_if_index_set == 0)
12003 errmsg ("missing interface name or sw_if_index");
12007 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
12009 mp->sw_if_index = ntohl (sw_if_index);
12010 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
12011 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
12019 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
12021 unformat_input_t *i = vam->input;
12022 vl_api_l2tpv3_interface_enable_disable_t *mp;
12024 u8 sw_if_index_set = 0;
12025 u8 enable_disable = 1;
12028 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12030 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12031 sw_if_index_set = 1;
12032 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12033 sw_if_index_set = 1;
12034 else if (unformat (i, "enable"))
12035 enable_disable = 1;
12036 else if (unformat (i, "disable"))
12037 enable_disable = 0;
12042 if (sw_if_index_set == 0)
12044 errmsg ("missing interface name or sw_if_index");
12048 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
12050 mp->sw_if_index = ntohl (sw_if_index);
12051 mp->enable_disable = enable_disable;
12059 api_l2tpv3_set_lookup_key (vat_main_t * vam)
12061 unformat_input_t *i = vam->input;
12062 vl_api_l2tpv3_set_lookup_key_t *mp;
12066 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12068 if (unformat (i, "lookup_v6_src"))
12069 key = L2T_LOOKUP_SRC_ADDRESS;
12070 else if (unformat (i, "lookup_v6_dst"))
12071 key = L2T_LOOKUP_DST_ADDRESS;
12072 else if (unformat (i, "lookup_session_id"))
12073 key = L2T_LOOKUP_SESSION_ID;
12078 if (key == (u8) ~ 0)
12080 errmsg ("l2tp session lookup key unset");
12084 M (L2TPV3_SET_LOOKUP_KEY, mp);
12093 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
12094 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12096 vat_main_t *vam = &vat_main;
12098 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
12099 format_ip6_address, mp->our_address,
12100 format_ip6_address, mp->client_address,
12101 clib_net_to_host_u32 (mp->sw_if_index));
12104 " local cookies %016llx %016llx remote cookie %016llx",
12105 clib_net_to_host_u64 (mp->local_cookie[0]),
12106 clib_net_to_host_u64 (mp->local_cookie[1]),
12107 clib_net_to_host_u64 (mp->remote_cookie));
12109 print (vam->ofp, " local session-id %d remote session-id %d",
12110 clib_net_to_host_u32 (mp->local_session_id),
12111 clib_net_to_host_u32 (mp->remote_session_id));
12113 print (vam->ofp, " l2 specific sublayer %s\n",
12114 mp->l2_sublayer_present ? "preset" : "absent");
12118 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
12119 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12121 vat_main_t *vam = &vat_main;
12122 vat_json_node_t *node = NULL;
12123 struct in6_addr addr;
12125 if (VAT_JSON_ARRAY != vam->json_tree.type)
12127 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12128 vat_json_init_array (&vam->json_tree);
12130 node = vat_json_array_add (&vam->json_tree);
12132 vat_json_init_object (node);
12134 clib_memcpy (&addr, mp->our_address, sizeof (addr));
12135 vat_json_object_add_ip6 (node, "our_address", addr);
12136 clib_memcpy (&addr, mp->client_address, sizeof (addr));
12137 vat_json_object_add_ip6 (node, "client_address", addr);
12139 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
12140 vat_json_init_array (lc);
12141 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
12142 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
12143 vat_json_object_add_uint (node, "remote_cookie",
12144 clib_net_to_host_u64 (mp->remote_cookie));
12146 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
12147 vat_json_object_add_uint (node, "local_session_id",
12148 clib_net_to_host_u32 (mp->local_session_id));
12149 vat_json_object_add_uint (node, "remote_session_id",
12150 clib_net_to_host_u32 (mp->remote_session_id));
12151 vat_json_object_add_string_copy (node, "l2_sublayer",
12152 mp->l2_sublayer_present ? (u8 *) "present"
12153 : (u8 *) "absent");
12157 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
12159 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
12160 vl_api_control_ping_t *mp_ping;
12163 /* Get list of l2tpv3-tunnel interfaces */
12164 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
12167 /* Use a control ping for synchronization */
12168 MPING (CONTROL_PING, mp_ping);
12176 static void vl_api_sw_interface_tap_v2_details_t_handler
12177 (vl_api_sw_interface_tap_v2_details_t * mp)
12179 vat_main_t *vam = &vat_main;
12181 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
12182 mp->host_ip4_prefix_len);
12183 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
12184 mp->host_ip6_prefix_len);
12187 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s 0x%-08x",
12188 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
12189 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12190 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
12191 mp->host_bridge, ip4, ip6, ntohl (mp->tap_flags));
12197 static void vl_api_sw_interface_tap_v2_details_t_handler_json
12198 (vl_api_sw_interface_tap_v2_details_t * mp)
12200 vat_main_t *vam = &vat_main;
12201 vat_json_node_t *node = NULL;
12203 if (VAT_JSON_ARRAY != vam->json_tree.type)
12205 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12206 vat_json_init_array (&vam->json_tree);
12208 node = vat_json_array_add (&vam->json_tree);
12210 vat_json_init_object (node);
12211 vat_json_object_add_uint (node, "id", ntohl (mp->id));
12212 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12213 vat_json_object_add_uint (node, "tap_flags", ntohl (mp->tap_flags));
12214 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12215 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12216 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12217 vat_json_object_add_string_copy (node, "host_mac_addr",
12218 format (0, "%U", format_ethernet_address,
12219 &mp->host_mac_addr));
12220 vat_json_object_add_string_copy (node, "host_namespace",
12221 mp->host_namespace);
12222 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
12223 vat_json_object_add_string_copy (node, "host_ip4_addr",
12224 format (0, "%U/%d", format_ip4_address,
12226 mp->host_ip4_prefix_len));
12227 vat_json_object_add_string_copy (node, "host_ip6_addr",
12228 format (0, "%U/%d", format_ip6_address,
12230 mp->host_ip6_prefix_len));
12235 api_sw_interface_tap_v2_dump (vat_main_t * vam)
12237 vl_api_sw_interface_tap_v2_dump_t *mp;
12238 vl_api_control_ping_t *mp_ping;
12242 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
12243 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
12244 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
12247 /* Get list of tap interfaces */
12248 M (SW_INTERFACE_TAP_V2_DUMP, mp);
12251 /* Use a control ping for synchronization */
12252 MPING (CONTROL_PING, mp_ping);
12259 static void vl_api_sw_interface_virtio_pci_details_t_handler
12260 (vl_api_sw_interface_virtio_pci_details_t * mp)
12262 vat_main_t *vam = &vat_main;
12276 addr.as_u32 = ntohl (mp->pci_addr);
12277 u8 *pci_addr = format (0, "%04x:%02x:%02x.%x", addr.domain, addr.bus,
12278 addr.slot, addr.function);
12281 "\n%-12s %-12d %-12d %-12d %-17U 0x%-08llx",
12282 pci_addr, ntohl (mp->sw_if_index),
12283 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12284 format_ethernet_address, mp->mac_addr,
12285 clib_net_to_host_u64 (mp->features));
12286 vec_free (pci_addr);
12289 static void vl_api_sw_interface_virtio_pci_details_t_handler_json
12290 (vl_api_sw_interface_virtio_pci_details_t * mp)
12292 vat_main_t *vam = &vat_main;
12293 vat_json_node_t *node = NULL;
12295 if (VAT_JSON_ARRAY != vam->json_tree.type)
12297 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12298 vat_json_init_array (&vam->json_tree);
12300 node = vat_json_array_add (&vam->json_tree);
12302 vat_json_init_object (node);
12303 vat_json_object_add_uint (node, "pci-addr", ntohl (mp->pci_addr));
12304 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12305 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12306 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12307 vat_json_object_add_uint (node, "features",
12308 clib_net_to_host_u64 (mp->features));
12309 vat_json_object_add_string_copy (node, "mac_addr",
12310 format (0, "%U", format_ethernet_address,
12315 api_sw_interface_virtio_pci_dump (vat_main_t * vam)
12317 vl_api_sw_interface_virtio_pci_dump_t *mp;
12318 vl_api_control_ping_t *mp_ping;
12322 "\n%-12s %-12s %-12s %-12s %-17s %-08s",
12323 "pci_addr", "sw_if_index", "rx_ring_sz", "tx_ring_sz",
12324 "mac_addr", "features");
12326 /* Get list of tap interfaces */
12327 M (SW_INTERFACE_VIRTIO_PCI_DUMP, mp);
12330 /* Use a control ping for synchronization */
12331 MPING (CONTROL_PING, mp_ping);
12339 api_vxlan_offload_rx (vat_main_t * vam)
12341 unformat_input_t *line_input = vam->input;
12342 vl_api_vxlan_offload_rx_t *mp;
12343 u32 hw_if_index = ~0, rx_if_index = ~0;
12347 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12349 if (unformat (line_input, "del"))
12351 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
12354 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
12356 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
12359 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
12363 errmsg ("parse error '%U'", format_unformat_error, line_input);
12368 if (hw_if_index == ~0)
12370 errmsg ("no hw interface");
12374 if (rx_if_index == ~0)
12376 errmsg ("no rx tunnel");
12380 M (VXLAN_OFFLOAD_RX, mp);
12382 mp->hw_if_index = ntohl (hw_if_index);
12383 mp->sw_if_index = ntohl (rx_if_index);
12384 mp->enable = is_add;
12391 static uword unformat_vxlan_decap_next
12392 (unformat_input_t * input, va_list * args)
12394 u32 *result = va_arg (*args, u32 *);
12397 if (unformat (input, "l2"))
12398 *result = VXLAN_INPUT_NEXT_L2_INPUT;
12399 else if (unformat (input, "%d", &tmp))
12407 api_vxlan_add_del_tunnel (vat_main_t * vam)
12409 unformat_input_t *line_input = vam->input;
12410 vl_api_vxlan_add_del_tunnel_t *mp;
12411 ip46_address_t src, dst;
12413 u8 ipv4_set = 0, ipv6_set = 0;
12418 u32 mcast_sw_if_index = ~0;
12419 u32 encap_vrf_id = 0;
12420 u32 decap_next_index = ~0;
12424 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12425 clib_memset (&src, 0, sizeof src);
12426 clib_memset (&dst, 0, sizeof dst);
12428 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12430 if (unformat (line_input, "del"))
12432 else if (unformat (line_input, "instance %d", &instance))
12435 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12441 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12447 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12453 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12458 else if (unformat (line_input, "group %U %U",
12459 unformat_ip4_address, &dst.ip4,
12460 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12462 grp_set = dst_set = 1;
12465 else if (unformat (line_input, "group %U",
12466 unformat_ip4_address, &dst.ip4))
12468 grp_set = dst_set = 1;
12471 else if (unformat (line_input, "group %U %U",
12472 unformat_ip6_address, &dst.ip6,
12473 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12475 grp_set = dst_set = 1;
12478 else if (unformat (line_input, "group %U",
12479 unformat_ip6_address, &dst.ip6))
12481 grp_set = dst_set = 1;
12485 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12487 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12489 else if (unformat (line_input, "decap-next %U",
12490 unformat_vxlan_decap_next, &decap_next_index))
12492 else if (unformat (line_input, "vni %d", &vni))
12496 errmsg ("parse error '%U'", format_unformat_error, line_input);
12503 errmsg ("tunnel src address not specified");
12508 errmsg ("tunnel dst address not specified");
12512 if (grp_set && !ip46_address_is_multicast (&dst))
12514 errmsg ("tunnel group address not multicast");
12517 if (grp_set && mcast_sw_if_index == ~0)
12519 errmsg ("tunnel nonexistent multicast device");
12522 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12524 errmsg ("tunnel dst address must be unicast");
12529 if (ipv4_set && ipv6_set)
12531 errmsg ("both IPv4 and IPv6 addresses specified");
12535 if ((vni == 0) || (vni >> 24))
12537 errmsg ("vni not specified or out of range");
12541 M (VXLAN_ADD_DEL_TUNNEL, mp);
12545 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
12546 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
12550 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
12551 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
12554 mp->instance = htonl (instance);
12555 mp->encap_vrf_id = ntohl (encap_vrf_id);
12556 mp->decap_next_index = ntohl (decap_next_index);
12557 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12558 mp->vni = ntohl (vni);
12559 mp->is_add = is_add;
12560 mp->is_ipv6 = ipv6_set;
12567 static void vl_api_vxlan_tunnel_details_t_handler
12568 (vl_api_vxlan_tunnel_details_t * mp)
12570 vat_main_t *vam = &vat_main;
12571 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12572 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12574 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
12575 ntohl (mp->sw_if_index),
12576 ntohl (mp->instance),
12577 format_ip46_address, &src, IP46_TYPE_ANY,
12578 format_ip46_address, &dst, IP46_TYPE_ANY,
12579 ntohl (mp->encap_vrf_id),
12580 ntohl (mp->decap_next_index), ntohl (mp->vni),
12581 ntohl (mp->mcast_sw_if_index));
12584 static void vl_api_vxlan_tunnel_details_t_handler_json
12585 (vl_api_vxlan_tunnel_details_t * mp)
12587 vat_main_t *vam = &vat_main;
12588 vat_json_node_t *node = NULL;
12590 if (VAT_JSON_ARRAY != vam->json_tree.type)
12592 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12593 vat_json_init_array (&vam->json_tree);
12595 node = vat_json_array_add (&vam->json_tree);
12597 vat_json_init_object (node);
12598 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12600 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
12604 struct in6_addr ip6;
12606 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12607 vat_json_object_add_ip6 (node, "src_address", ip6);
12608 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12609 vat_json_object_add_ip6 (node, "dst_address", ip6);
12613 struct in_addr ip4;
12615 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12616 vat_json_object_add_ip4 (node, "src_address", ip4);
12617 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12618 vat_json_object_add_ip4 (node, "dst_address", ip4);
12620 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12621 vat_json_object_add_uint (node, "decap_next_index",
12622 ntohl (mp->decap_next_index));
12623 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12624 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12625 vat_json_object_add_uint (node, "mcast_sw_if_index",
12626 ntohl (mp->mcast_sw_if_index));
12630 api_vxlan_tunnel_dump (vat_main_t * vam)
12632 unformat_input_t *i = vam->input;
12633 vl_api_vxlan_tunnel_dump_t *mp;
12634 vl_api_control_ping_t *mp_ping;
12636 u8 sw_if_index_set = 0;
12639 /* Parse args required to build the message */
12640 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12642 if (unformat (i, "sw_if_index %d", &sw_if_index))
12643 sw_if_index_set = 1;
12648 if (sw_if_index_set == 0)
12653 if (!vam->json_output)
12655 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
12656 "sw_if_index", "instance", "src_address", "dst_address",
12657 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12660 /* Get list of vxlan-tunnel interfaces */
12661 M (VXLAN_TUNNEL_DUMP, mp);
12663 mp->sw_if_index = htonl (sw_if_index);
12667 /* Use a control ping for synchronization */
12668 MPING (CONTROL_PING, mp_ping);
12675 static uword unformat_geneve_decap_next
12676 (unformat_input_t * input, va_list * args)
12678 u32 *result = va_arg (*args, u32 *);
12681 if (unformat (input, "l2"))
12682 *result = GENEVE_INPUT_NEXT_L2_INPUT;
12683 else if (unformat (input, "%d", &tmp))
12691 api_geneve_add_del_tunnel (vat_main_t * vam)
12693 unformat_input_t *line_input = vam->input;
12694 vl_api_geneve_add_del_tunnel_t *mp;
12695 ip46_address_t src, dst;
12697 u8 ipv4_set = 0, ipv6_set = 0;
12701 u32 mcast_sw_if_index = ~0;
12702 u32 encap_vrf_id = 0;
12703 u32 decap_next_index = ~0;
12707 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12708 clib_memset (&src, 0, sizeof src);
12709 clib_memset (&dst, 0, sizeof dst);
12711 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12713 if (unformat (line_input, "del"))
12716 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12722 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12728 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12734 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12739 else if (unformat (line_input, "group %U %U",
12740 unformat_ip4_address, &dst.ip4,
12741 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12743 grp_set = dst_set = 1;
12746 else if (unformat (line_input, "group %U",
12747 unformat_ip4_address, &dst.ip4))
12749 grp_set = dst_set = 1;
12752 else if (unformat (line_input, "group %U %U",
12753 unformat_ip6_address, &dst.ip6,
12754 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12756 grp_set = dst_set = 1;
12759 else if (unformat (line_input, "group %U",
12760 unformat_ip6_address, &dst.ip6))
12762 grp_set = dst_set = 1;
12766 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12768 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12770 else if (unformat (line_input, "decap-next %U",
12771 unformat_geneve_decap_next, &decap_next_index))
12773 else if (unformat (line_input, "vni %d", &vni))
12777 errmsg ("parse error '%U'", format_unformat_error, line_input);
12784 errmsg ("tunnel src address not specified");
12789 errmsg ("tunnel dst address not specified");
12793 if (grp_set && !ip46_address_is_multicast (&dst))
12795 errmsg ("tunnel group address not multicast");
12798 if (grp_set && mcast_sw_if_index == ~0)
12800 errmsg ("tunnel nonexistent multicast device");
12803 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12805 errmsg ("tunnel dst address must be unicast");
12810 if (ipv4_set && ipv6_set)
12812 errmsg ("both IPv4 and IPv6 addresses specified");
12816 if ((vni == 0) || (vni >> 24))
12818 errmsg ("vni not specified or out of range");
12822 M (GENEVE_ADD_DEL_TUNNEL, mp);
12826 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
12827 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
12831 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
12832 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
12834 mp->encap_vrf_id = ntohl (encap_vrf_id);
12835 mp->decap_next_index = ntohl (decap_next_index);
12836 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12837 mp->vni = ntohl (vni);
12838 mp->is_add = is_add;
12839 mp->is_ipv6 = ipv6_set;
12846 static void vl_api_geneve_tunnel_details_t_handler
12847 (vl_api_geneve_tunnel_details_t * mp)
12849 vat_main_t *vam = &vat_main;
12850 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12851 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12853 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12854 ntohl (mp->sw_if_index),
12855 format_ip46_address, &src, IP46_TYPE_ANY,
12856 format_ip46_address, &dst, IP46_TYPE_ANY,
12857 ntohl (mp->encap_vrf_id),
12858 ntohl (mp->decap_next_index), ntohl (mp->vni),
12859 ntohl (mp->mcast_sw_if_index));
12862 static void vl_api_geneve_tunnel_details_t_handler_json
12863 (vl_api_geneve_tunnel_details_t * mp)
12865 vat_main_t *vam = &vat_main;
12866 vat_json_node_t *node = NULL;
12868 if (VAT_JSON_ARRAY != vam->json_tree.type)
12870 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12871 vat_json_init_array (&vam->json_tree);
12873 node = vat_json_array_add (&vam->json_tree);
12875 vat_json_init_object (node);
12876 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12879 struct in6_addr ip6;
12881 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12882 vat_json_object_add_ip6 (node, "src_address", ip6);
12883 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12884 vat_json_object_add_ip6 (node, "dst_address", ip6);
12888 struct in_addr ip4;
12890 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12891 vat_json_object_add_ip4 (node, "src_address", ip4);
12892 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12893 vat_json_object_add_ip4 (node, "dst_address", ip4);
12895 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12896 vat_json_object_add_uint (node, "decap_next_index",
12897 ntohl (mp->decap_next_index));
12898 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12899 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12900 vat_json_object_add_uint (node, "mcast_sw_if_index",
12901 ntohl (mp->mcast_sw_if_index));
12905 api_geneve_tunnel_dump (vat_main_t * vam)
12907 unformat_input_t *i = vam->input;
12908 vl_api_geneve_tunnel_dump_t *mp;
12909 vl_api_control_ping_t *mp_ping;
12911 u8 sw_if_index_set = 0;
12914 /* Parse args required to build the message */
12915 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12917 if (unformat (i, "sw_if_index %d", &sw_if_index))
12918 sw_if_index_set = 1;
12923 if (sw_if_index_set == 0)
12928 if (!vam->json_output)
12930 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12931 "sw_if_index", "local_address", "remote_address",
12932 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12935 /* Get list of geneve-tunnel interfaces */
12936 M (GENEVE_TUNNEL_DUMP, mp);
12938 mp->sw_if_index = htonl (sw_if_index);
12942 /* Use a control ping for synchronization */
12943 M (CONTROL_PING, mp_ping);
12951 api_gre_tunnel_add_del (vat_main_t * vam)
12953 unformat_input_t *line_input = vam->input;
12954 vl_api_address_t src = { }, dst =
12957 vl_api_gre_tunnel_add_del_t *mp;
12958 vl_api_gre_tunnel_type_t t_type;
12962 u32 outer_fib_id = 0;
12963 u32 session_id = 0;
12967 t_type = GRE_API_TUNNEL_TYPE_L3;
12969 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12971 if (unformat (line_input, "del"))
12973 else if (unformat (line_input, "instance %d", &instance))
12975 else if (unformat (line_input, "src %U", unformat_vl_api_address, &src))
12979 else if (unformat (line_input, "dst %U", unformat_vl_api_address, &dst))
12983 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
12985 else if (unformat (line_input, "teb"))
12986 t_type = GRE_API_TUNNEL_TYPE_TEB;
12987 else if (unformat (line_input, "erspan %d", &session_id))
12988 t_type = GRE_API_TUNNEL_TYPE_ERSPAN;
12991 errmsg ("parse error '%U'", format_unformat_error, line_input);
12998 errmsg ("tunnel src address not specified");
13003 errmsg ("tunnel dst address not specified");
13007 M (GRE_TUNNEL_ADD_DEL, mp);
13009 clib_memcpy (&mp->tunnel.src, &src, sizeof (mp->tunnel.src));
13010 clib_memcpy (&mp->tunnel.dst, &dst, sizeof (mp->tunnel.dst));
13012 mp->tunnel.instance = htonl (instance);
13013 mp->tunnel.outer_fib_id = htonl (outer_fib_id);
13014 mp->is_add = is_add;
13015 mp->tunnel.session_id = htons ((u16) session_id);
13016 mp->tunnel.type = htonl (t_type);
13023 static void vl_api_gre_tunnel_details_t_handler
13024 (vl_api_gre_tunnel_details_t * mp)
13026 vat_main_t *vam = &vat_main;
13028 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
13029 ntohl (mp->tunnel.sw_if_index),
13030 ntohl (mp->tunnel.instance),
13031 format_vl_api_address, &mp->tunnel.src,
13032 format_vl_api_address, &mp->tunnel.dst,
13033 mp->tunnel.type, ntohl (mp->tunnel.outer_fib_id),
13034 ntohl (mp->tunnel.session_id));
13037 static void vl_api_gre_tunnel_details_t_handler_json
13038 (vl_api_gre_tunnel_details_t * mp)
13040 vat_main_t *vam = &vat_main;
13041 vat_json_node_t *node = NULL;
13043 if (VAT_JSON_ARRAY != vam->json_tree.type)
13045 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13046 vat_json_init_array (&vam->json_tree);
13048 node = vat_json_array_add (&vam->json_tree);
13050 vat_json_init_object (node);
13051 vat_json_object_add_uint (node, "sw_if_index",
13052 ntohl (mp->tunnel.sw_if_index));
13053 vat_json_object_add_uint (node, "instance", ntohl (mp->tunnel.instance));
13055 vat_json_object_add_address (node, "src", &mp->tunnel.src);
13056 vat_json_object_add_address (node, "dst", &mp->tunnel.dst);
13057 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel.type);
13058 vat_json_object_add_uint (node, "outer_fib_id",
13059 ntohl (mp->tunnel.outer_fib_id));
13060 vat_json_object_add_uint (node, "session_id", mp->tunnel.session_id);
13064 api_gre_tunnel_dump (vat_main_t * vam)
13066 unformat_input_t *i = vam->input;
13067 vl_api_gre_tunnel_dump_t *mp;
13068 vl_api_control_ping_t *mp_ping;
13070 u8 sw_if_index_set = 0;
13073 /* Parse args required to build the message */
13074 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13076 if (unformat (i, "sw_if_index %d", &sw_if_index))
13077 sw_if_index_set = 1;
13082 if (sw_if_index_set == 0)
13087 if (!vam->json_output)
13089 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
13090 "sw_if_index", "instance", "src_address", "dst_address",
13091 "tunnel_type", "outer_fib_id", "session_id");
13094 /* Get list of gre-tunnel interfaces */
13095 M (GRE_TUNNEL_DUMP, mp);
13097 mp->sw_if_index = htonl (sw_if_index);
13101 /* Use a control ping for synchronization */
13102 MPING (CONTROL_PING, mp_ping);
13110 api_l2_fib_clear_table (vat_main_t * vam)
13112 // unformat_input_t * i = vam->input;
13113 vl_api_l2_fib_clear_table_t *mp;
13116 M (L2_FIB_CLEAR_TABLE, mp);
13124 api_l2_interface_efp_filter (vat_main_t * vam)
13126 unformat_input_t *i = vam->input;
13127 vl_api_l2_interface_efp_filter_t *mp;
13130 u8 sw_if_index_set = 0;
13133 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13135 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13136 sw_if_index_set = 1;
13137 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13138 sw_if_index_set = 1;
13139 else if (unformat (i, "enable"))
13141 else if (unformat (i, "disable"))
13145 clib_warning ("parse error '%U'", format_unformat_error, i);
13150 if (sw_if_index_set == 0)
13152 errmsg ("missing sw_if_index");
13156 M (L2_INTERFACE_EFP_FILTER, mp);
13158 mp->sw_if_index = ntohl (sw_if_index);
13159 mp->enable_disable = enable;
13166 #define foreach_vtr_op \
13167 _("disable", L2_VTR_DISABLED) \
13168 _("push-1", L2_VTR_PUSH_1) \
13169 _("push-2", L2_VTR_PUSH_2) \
13170 _("pop-1", L2_VTR_POP_1) \
13171 _("pop-2", L2_VTR_POP_2) \
13172 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
13173 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
13174 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
13175 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
13178 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
13180 unformat_input_t *i = vam->input;
13181 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
13183 u8 sw_if_index_set = 0;
13186 u32 push_dot1q = 1;
13191 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13193 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13194 sw_if_index_set = 1;
13195 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13196 sw_if_index_set = 1;
13197 else if (unformat (i, "vtr_op %d", &vtr_op))
13199 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
13202 else if (unformat (i, "push_dot1q %d", &push_dot1q))
13204 else if (unformat (i, "tag1 %d", &tag1))
13206 else if (unformat (i, "tag2 %d", &tag2))
13210 clib_warning ("parse error '%U'", format_unformat_error, i);
13215 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
13217 errmsg ("missing vtr operation or sw_if_index");
13221 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
13222 mp->sw_if_index = ntohl (sw_if_index);
13223 mp->vtr_op = ntohl (vtr_op);
13224 mp->push_dot1q = ntohl (push_dot1q);
13225 mp->tag1 = ntohl (tag1);
13226 mp->tag2 = ntohl (tag2);
13234 api_create_vhost_user_if (vat_main_t * vam)
13236 unformat_input_t *i = vam->input;
13237 vl_api_create_vhost_user_if_t *mp;
13240 u8 file_name_set = 0;
13241 u32 custom_dev_instance = ~0;
13243 u8 use_custom_mac = 0;
13244 u8 disable_mrg_rxbuf = 0;
13245 u8 disable_indirect_desc = 0;
13250 /* Shut up coverity */
13251 clib_memset (hwaddr, 0, sizeof (hwaddr));
13253 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13255 if (unformat (i, "socket %s", &file_name))
13259 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13261 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
13262 use_custom_mac = 1;
13263 else if (unformat (i, "server"))
13265 else if (unformat (i, "disable_mrg_rxbuf"))
13266 disable_mrg_rxbuf = 1;
13267 else if (unformat (i, "disable_indirect_desc"))
13268 disable_indirect_desc = 1;
13269 else if (unformat (i, "gso"))
13271 else if (unformat (i, "tag %s", &tag))
13277 if (file_name_set == 0)
13279 errmsg ("missing socket file name");
13283 if (vec_len (file_name) > 255)
13285 errmsg ("socket file name too long");
13288 vec_add1 (file_name, 0);
13290 M (CREATE_VHOST_USER_IF, mp);
13292 mp->is_server = is_server;
13293 mp->disable_mrg_rxbuf = disable_mrg_rxbuf;
13294 mp->disable_indirect_desc = disable_indirect_desc;
13295 mp->enable_gso = enable_gso;
13296 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13297 vec_free (file_name);
13298 if (custom_dev_instance != ~0)
13301 mp->custom_dev_instance = ntohl (custom_dev_instance);
13304 mp->use_custom_mac = use_custom_mac;
13305 clib_memcpy (mp->mac_address, hwaddr, 6);
13307 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
13316 api_modify_vhost_user_if (vat_main_t * vam)
13318 unformat_input_t *i = vam->input;
13319 vl_api_modify_vhost_user_if_t *mp;
13322 u8 file_name_set = 0;
13323 u32 custom_dev_instance = ~0;
13324 u8 sw_if_index_set = 0;
13325 u32 sw_if_index = (u32) ~ 0;
13329 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13331 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13332 sw_if_index_set = 1;
13333 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13334 sw_if_index_set = 1;
13335 else if (unformat (i, "socket %s", &file_name))
13339 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13341 else if (unformat (i, "server"))
13343 else if (unformat (i, "gso"))
13349 if (sw_if_index_set == 0)
13351 errmsg ("missing sw_if_index or interface name");
13355 if (file_name_set == 0)
13357 errmsg ("missing socket file name");
13361 if (vec_len (file_name) > 255)
13363 errmsg ("socket file name too long");
13366 vec_add1 (file_name, 0);
13368 M (MODIFY_VHOST_USER_IF, mp);
13370 mp->sw_if_index = ntohl (sw_if_index);
13371 mp->is_server = is_server;
13372 mp->enable_gso = enable_gso;
13373 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13374 vec_free (file_name);
13375 if (custom_dev_instance != ~0)
13378 mp->custom_dev_instance = ntohl (custom_dev_instance);
13387 api_delete_vhost_user_if (vat_main_t * vam)
13389 unformat_input_t *i = vam->input;
13390 vl_api_delete_vhost_user_if_t *mp;
13391 u32 sw_if_index = ~0;
13392 u8 sw_if_index_set = 0;
13395 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13397 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13398 sw_if_index_set = 1;
13399 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13400 sw_if_index_set = 1;
13405 if (sw_if_index_set == 0)
13407 errmsg ("missing sw_if_index or interface name");
13412 M (DELETE_VHOST_USER_IF, mp);
13414 mp->sw_if_index = ntohl (sw_if_index);
13421 static void vl_api_sw_interface_vhost_user_details_t_handler
13422 (vl_api_sw_interface_vhost_user_details_t * mp)
13424 vat_main_t *vam = &vat_main;
13426 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
13427 (char *) mp->interface_name,
13428 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
13429 clib_net_to_host_u64 (mp->features), mp->is_server,
13430 ntohl (mp->num_regions), (char *) mp->sock_filename);
13431 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
13434 static void vl_api_sw_interface_vhost_user_details_t_handler_json
13435 (vl_api_sw_interface_vhost_user_details_t * mp)
13437 vat_main_t *vam = &vat_main;
13438 vat_json_node_t *node = NULL;
13440 if (VAT_JSON_ARRAY != vam->json_tree.type)
13442 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13443 vat_json_init_array (&vam->json_tree);
13445 node = vat_json_array_add (&vam->json_tree);
13447 vat_json_init_object (node);
13448 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13449 vat_json_object_add_string_copy (node, "interface_name",
13450 mp->interface_name);
13451 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
13452 ntohl (mp->virtio_net_hdr_sz));
13453 vat_json_object_add_uint (node, "features",
13454 clib_net_to_host_u64 (mp->features));
13455 vat_json_object_add_uint (node, "is_server", mp->is_server);
13456 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
13457 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
13458 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
13462 api_sw_interface_vhost_user_dump (vat_main_t * vam)
13464 vl_api_sw_interface_vhost_user_dump_t *mp;
13465 vl_api_control_ping_t *mp_ping;
13468 "Interface name idx hdr_sz features server regions filename");
13470 /* Get list of vhost-user interfaces */
13471 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
13474 /* Use a control ping for synchronization */
13475 MPING (CONTROL_PING, mp_ping);
13483 api_show_version (vat_main_t * vam)
13485 vl_api_show_version_t *mp;
13488 M (SHOW_VERSION, mp);
13497 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
13499 unformat_input_t *line_input = vam->input;
13500 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
13501 ip4_address_t local4, remote4;
13502 ip6_address_t local6, remote6;
13504 u8 ipv4_set = 0, ipv6_set = 0;
13508 u32 mcast_sw_if_index = ~0;
13509 u32 encap_vrf_id = 0;
13510 u32 decap_vrf_id = 0;
13516 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13517 clib_memset (&local4, 0, sizeof local4);
13518 clib_memset (&remote4, 0, sizeof remote4);
13519 clib_memset (&local6, 0, sizeof local6);
13520 clib_memset (&remote6, 0, sizeof remote6);
13522 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13524 if (unformat (line_input, "del"))
13526 else if (unformat (line_input, "local %U",
13527 unformat_ip4_address, &local4))
13532 else if (unformat (line_input, "remote %U",
13533 unformat_ip4_address, &remote4))
13538 else if (unformat (line_input, "local %U",
13539 unformat_ip6_address, &local6))
13544 else if (unformat (line_input, "remote %U",
13545 unformat_ip6_address, &remote6))
13550 else if (unformat (line_input, "group %U %U",
13551 unformat_ip4_address, &remote4,
13552 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13554 grp_set = remote_set = 1;
13557 else if (unformat (line_input, "group %U",
13558 unformat_ip4_address, &remote4))
13560 grp_set = remote_set = 1;
13563 else if (unformat (line_input, "group %U %U",
13564 unformat_ip6_address, &remote6,
13565 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13567 grp_set = remote_set = 1;
13570 else if (unformat (line_input, "group %U",
13571 unformat_ip6_address, &remote6))
13573 grp_set = remote_set = 1;
13577 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13579 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13581 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
13583 else if (unformat (line_input, "vni %d", &vni))
13585 else if (unformat (line_input, "next-ip4"))
13587 else if (unformat (line_input, "next-ip6"))
13589 else if (unformat (line_input, "next-ethernet"))
13591 else if (unformat (line_input, "next-nsh"))
13595 errmsg ("parse error '%U'", format_unformat_error, line_input);
13600 if (local_set == 0)
13602 errmsg ("tunnel local address not specified");
13605 if (remote_set == 0)
13607 errmsg ("tunnel remote address not specified");
13610 if (grp_set && mcast_sw_if_index == ~0)
13612 errmsg ("tunnel nonexistent multicast device");
13615 if (ipv4_set && ipv6_set)
13617 errmsg ("both IPv4 and IPv6 addresses specified");
13623 errmsg ("vni not specified");
13627 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
13632 clib_memcpy (&mp->local, &local6, sizeof (local6));
13633 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
13637 clib_memcpy (&mp->local, &local4, sizeof (local4));
13638 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
13641 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13642 mp->encap_vrf_id = ntohl (encap_vrf_id);
13643 mp->decap_vrf_id = ntohl (decap_vrf_id);
13644 mp->protocol = protocol;
13645 mp->vni = ntohl (vni);
13646 mp->is_add = is_add;
13647 mp->is_ipv6 = ipv6_set;
13654 static void vl_api_vxlan_gpe_tunnel_details_t_handler
13655 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13657 vat_main_t *vam = &vat_main;
13658 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
13659 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
13661 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
13662 ntohl (mp->sw_if_index),
13663 format_ip46_address, &local, IP46_TYPE_ANY,
13664 format_ip46_address, &remote, IP46_TYPE_ANY,
13665 ntohl (mp->vni), mp->protocol,
13666 ntohl (mp->mcast_sw_if_index),
13667 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
13671 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
13672 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13674 vat_main_t *vam = &vat_main;
13675 vat_json_node_t *node = NULL;
13676 struct in_addr ip4;
13677 struct in6_addr ip6;
13679 if (VAT_JSON_ARRAY != vam->json_tree.type)
13681 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13682 vat_json_init_array (&vam->json_tree);
13684 node = vat_json_array_add (&vam->json_tree);
13686 vat_json_init_object (node);
13687 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13690 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
13691 vat_json_object_add_ip6 (node, "local", ip6);
13692 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
13693 vat_json_object_add_ip6 (node, "remote", ip6);
13697 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
13698 vat_json_object_add_ip4 (node, "local", ip4);
13699 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
13700 vat_json_object_add_ip4 (node, "remote", ip4);
13702 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13703 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
13704 vat_json_object_add_uint (node, "mcast_sw_if_index",
13705 ntohl (mp->mcast_sw_if_index));
13706 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13707 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
13708 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13712 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
13714 unformat_input_t *i = vam->input;
13715 vl_api_vxlan_gpe_tunnel_dump_t *mp;
13716 vl_api_control_ping_t *mp_ping;
13718 u8 sw_if_index_set = 0;
13721 /* Parse args required to build the message */
13722 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13724 if (unformat (i, "sw_if_index %d", &sw_if_index))
13725 sw_if_index_set = 1;
13730 if (sw_if_index_set == 0)
13735 if (!vam->json_output)
13737 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
13738 "sw_if_index", "local", "remote", "vni",
13739 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
13742 /* Get list of vxlan-tunnel interfaces */
13743 M (VXLAN_GPE_TUNNEL_DUMP, mp);
13745 mp->sw_if_index = htonl (sw_if_index);
13749 /* Use a control ping for synchronization */
13750 MPING (CONTROL_PING, mp_ping);
13757 static void vl_api_l2_fib_table_details_t_handler
13758 (vl_api_l2_fib_table_details_t * mp)
13760 vat_main_t *vam = &vat_main;
13762 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
13764 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
13765 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
13769 static void vl_api_l2_fib_table_details_t_handler_json
13770 (vl_api_l2_fib_table_details_t * mp)
13772 vat_main_t *vam = &vat_main;
13773 vat_json_node_t *node = NULL;
13775 if (VAT_JSON_ARRAY != vam->json_tree.type)
13777 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13778 vat_json_init_array (&vam->json_tree);
13780 node = vat_json_array_add (&vam->json_tree);
13782 vat_json_init_object (node);
13783 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
13784 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
13785 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13786 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
13787 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
13788 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
13792 api_l2_fib_table_dump (vat_main_t * vam)
13794 unformat_input_t *i = vam->input;
13795 vl_api_l2_fib_table_dump_t *mp;
13796 vl_api_control_ping_t *mp_ping;
13801 /* Parse args required to build the message */
13802 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13804 if (unformat (i, "bd_id %d", &bd_id))
13810 if (bd_id_set == 0)
13812 errmsg ("missing bridge domain");
13816 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
13818 /* Get list of l2 fib entries */
13819 M (L2_FIB_TABLE_DUMP, mp);
13821 mp->bd_id = ntohl (bd_id);
13824 /* Use a control ping for synchronization */
13825 MPING (CONTROL_PING, mp_ping);
13834 api_interface_name_renumber (vat_main_t * vam)
13836 unformat_input_t *line_input = vam->input;
13837 vl_api_interface_name_renumber_t *mp;
13838 u32 sw_if_index = ~0;
13839 u32 new_show_dev_instance = ~0;
13842 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13844 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
13847 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13849 else if (unformat (line_input, "new_show_dev_instance %d",
13850 &new_show_dev_instance))
13856 if (sw_if_index == ~0)
13858 errmsg ("missing interface name or sw_if_index");
13862 if (new_show_dev_instance == ~0)
13864 errmsg ("missing new_show_dev_instance");
13868 M (INTERFACE_NAME_RENUMBER, mp);
13870 mp->sw_if_index = ntohl (sw_if_index);
13871 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
13879 api_ip_probe_neighbor (vat_main_t * vam)
13881 unformat_input_t *i = vam->input;
13882 vl_api_ip_probe_neighbor_t *mp;
13883 vl_api_address_t dst_adr = { };
13889 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13891 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13893 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13895 else if (unformat (i, "address %U", unformat_vl_api_address, &dst_adr))
13903 errmsg ("missing interface");
13909 errmsg ("missing addresses");
13913 M (IP_PROBE_NEIGHBOR, mp);
13915 mp->sw_if_index = ntohl (sw_if_index);
13916 clib_memcpy (&mp->dst, &dst_adr, sizeof (dst_adr));
13924 api_ip_scan_neighbor_enable_disable (vat_main_t * vam)
13926 unformat_input_t *i = vam->input;
13927 vl_api_ip_scan_neighbor_enable_disable_t *mp;
13928 u8 mode = IP_SCAN_V46_NEIGHBORS;
13929 u32 interval = 0, time = 0, update = 0, delay = 0, stale = 0;
13932 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13934 if (unformat (i, "ip4"))
13935 mode = IP_SCAN_V4_NEIGHBORS;
13936 else if (unformat (i, "ip6"))
13937 mode = IP_SCAN_V6_NEIGHBORS;
13938 if (unformat (i, "both"))
13939 mode = IP_SCAN_V46_NEIGHBORS;
13940 else if (unformat (i, "disable"))
13941 mode = IP_SCAN_DISABLED;
13942 else if (unformat (i, "interval %d", &interval))
13944 else if (unformat (i, "max-time %d", &time))
13946 else if (unformat (i, "max-update %d", &update))
13948 else if (unformat (i, "delay %d", &delay))
13950 else if (unformat (i, "stale %d", &stale))
13956 if (interval > 255)
13958 errmsg ("interval cannot exceed 255 minutes.");
13963 errmsg ("max-time cannot exceed 255 usec.");
13968 errmsg ("max-update cannot exceed 255.");
13973 errmsg ("delay cannot exceed 255 msec.");
13978 errmsg ("stale cannot exceed 255 minutes.");
13982 M (IP_SCAN_NEIGHBOR_ENABLE_DISABLE, mp);
13984 mp->scan_interval = interval;
13985 mp->max_proc_time = time;
13986 mp->max_update = update;
13987 mp->scan_int_delay = delay;
13988 mp->stale_threshold = stale;
13996 api_want_ip4_arp_events (vat_main_t * vam)
13998 unformat_input_t *line_input = vam->input;
13999 vl_api_want_ip4_arp_events_t *mp;
14000 ip4_address_t address;
14001 int address_set = 0;
14002 u32 enable_disable = 1;
14005 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14007 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
14009 else if (unformat (line_input, "del"))
14010 enable_disable = 0;
14015 if (address_set == 0)
14017 errmsg ("missing addresses");
14021 M (WANT_IP4_ARP_EVENTS, mp);
14022 mp->enable_disable = enable_disable;
14023 mp->pid = htonl (getpid ());
14024 clib_memcpy (mp->ip, &address, sizeof (address));
14032 api_want_ip6_nd_events (vat_main_t * vam)
14034 unformat_input_t *line_input = vam->input;
14035 vl_api_want_ip6_nd_events_t *mp;
14036 vl_api_ip6_address_t address;
14037 int address_set = 0;
14038 u32 enable_disable = 1;
14041 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14044 (line_input, "address %U", unformat_vl_api_ip6_address, &address))
14046 else if (unformat (line_input, "del"))
14047 enable_disable = 0;
14052 if (address_set == 0)
14054 errmsg ("missing addresses");
14058 M (WANT_IP6_ND_EVENTS, mp);
14059 mp->enable_disable = enable_disable;
14060 mp->pid = htonl (getpid ());
14061 clib_memcpy (&mp->ip, &address, sizeof (address));
14069 api_want_l2_macs_events (vat_main_t * vam)
14071 unformat_input_t *line_input = vam->input;
14072 vl_api_want_l2_macs_events_t *mp;
14073 u8 enable_disable = 1;
14074 u32 scan_delay = 0;
14075 u32 max_macs_in_event = 0;
14076 u32 learn_limit = 0;
14079 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14081 if (unformat (line_input, "learn-limit %d", &learn_limit))
14083 else if (unformat (line_input, "scan-delay %d", &scan_delay))
14085 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
14087 else if (unformat (line_input, "disable"))
14088 enable_disable = 0;
14093 M (WANT_L2_MACS_EVENTS, mp);
14094 mp->enable_disable = enable_disable;
14095 mp->pid = htonl (getpid ());
14096 mp->learn_limit = htonl (learn_limit);
14097 mp->scan_delay = (u8) scan_delay;
14098 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
14105 api_input_acl_set_interface (vat_main_t * vam)
14107 unformat_input_t *i = vam->input;
14108 vl_api_input_acl_set_interface_t *mp;
14110 int sw_if_index_set;
14111 u32 ip4_table_index = ~0;
14112 u32 ip6_table_index = ~0;
14113 u32 l2_table_index = ~0;
14117 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14119 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14120 sw_if_index_set = 1;
14121 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14122 sw_if_index_set = 1;
14123 else if (unformat (i, "del"))
14125 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14127 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14129 else if (unformat (i, "l2-table %d", &l2_table_index))
14133 clib_warning ("parse error '%U'", format_unformat_error, i);
14138 if (sw_if_index_set == 0)
14140 errmsg ("missing interface name or sw_if_index");
14144 M (INPUT_ACL_SET_INTERFACE, mp);
14146 mp->sw_if_index = ntohl (sw_if_index);
14147 mp->ip4_table_index = ntohl (ip4_table_index);
14148 mp->ip6_table_index = ntohl (ip6_table_index);
14149 mp->l2_table_index = ntohl (l2_table_index);
14150 mp->is_add = is_add;
14158 api_output_acl_set_interface (vat_main_t * vam)
14160 unformat_input_t *i = vam->input;
14161 vl_api_output_acl_set_interface_t *mp;
14163 int sw_if_index_set;
14164 u32 ip4_table_index = ~0;
14165 u32 ip6_table_index = ~0;
14166 u32 l2_table_index = ~0;
14170 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14172 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14173 sw_if_index_set = 1;
14174 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14175 sw_if_index_set = 1;
14176 else if (unformat (i, "del"))
14178 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14180 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14182 else if (unformat (i, "l2-table %d", &l2_table_index))
14186 clib_warning ("parse error '%U'", format_unformat_error, i);
14191 if (sw_if_index_set == 0)
14193 errmsg ("missing interface name or sw_if_index");
14197 M (OUTPUT_ACL_SET_INTERFACE, mp);
14199 mp->sw_if_index = ntohl (sw_if_index);
14200 mp->ip4_table_index = ntohl (ip4_table_index);
14201 mp->ip6_table_index = ntohl (ip6_table_index);
14202 mp->l2_table_index = ntohl (l2_table_index);
14203 mp->is_add = is_add;
14211 api_ip_address_dump (vat_main_t * vam)
14213 unformat_input_t *i = vam->input;
14214 vl_api_ip_address_dump_t *mp;
14215 vl_api_control_ping_t *mp_ping;
14216 u32 sw_if_index = ~0;
14217 u8 sw_if_index_set = 0;
14222 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14224 if (unformat (i, "sw_if_index %d", &sw_if_index))
14225 sw_if_index_set = 1;
14227 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14228 sw_if_index_set = 1;
14229 else if (unformat (i, "ipv4"))
14231 else if (unformat (i, "ipv6"))
14237 if (ipv4_set && ipv6_set)
14239 errmsg ("ipv4 and ipv6 flags cannot be both set");
14243 if ((!ipv4_set) && (!ipv6_set))
14245 errmsg ("no ipv4 nor ipv6 flag set");
14249 if (sw_if_index_set == 0)
14251 errmsg ("missing interface name or sw_if_index");
14255 vam->current_sw_if_index = sw_if_index;
14256 vam->is_ipv6 = ipv6_set;
14258 M (IP_ADDRESS_DUMP, mp);
14259 mp->sw_if_index = ntohl (sw_if_index);
14260 mp->is_ipv6 = ipv6_set;
14263 /* Use a control ping for synchronization */
14264 MPING (CONTROL_PING, mp_ping);
14272 api_ip_dump (vat_main_t * vam)
14274 vl_api_ip_dump_t *mp;
14275 vl_api_control_ping_t *mp_ping;
14276 unformat_input_t *in = vam->input;
14283 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
14285 if (unformat (in, "ipv4"))
14287 else if (unformat (in, "ipv6"))
14293 if (ipv4_set && ipv6_set)
14295 errmsg ("ipv4 and ipv6 flags cannot be both set");
14299 if ((!ipv4_set) && (!ipv6_set))
14301 errmsg ("no ipv4 nor ipv6 flag set");
14305 is_ipv6 = ipv6_set;
14306 vam->is_ipv6 = is_ipv6;
14308 /* free old data */
14309 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
14311 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
14313 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
14316 mp->is_ipv6 = ipv6_set;
14319 /* Use a control ping for synchronization */
14320 MPING (CONTROL_PING, mp_ping);
14328 api_ipsec_spd_add_del (vat_main_t * vam)
14330 unformat_input_t *i = vam->input;
14331 vl_api_ipsec_spd_add_del_t *mp;
14336 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14338 if (unformat (i, "spd_id %d", &spd_id))
14340 else if (unformat (i, "del"))
14344 clib_warning ("parse error '%U'", format_unformat_error, i);
14350 errmsg ("spd_id must be set");
14354 M (IPSEC_SPD_ADD_DEL, mp);
14356 mp->spd_id = ntohl (spd_id);
14357 mp->is_add = is_add;
14365 api_ipsec_interface_add_del_spd (vat_main_t * vam)
14367 unformat_input_t *i = vam->input;
14368 vl_api_ipsec_interface_add_del_spd_t *mp;
14370 u8 sw_if_index_set = 0;
14371 u32 spd_id = (u32) ~ 0;
14375 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14377 if (unformat (i, "del"))
14379 else if (unformat (i, "spd_id %d", &spd_id))
14382 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14383 sw_if_index_set = 1;
14384 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14385 sw_if_index_set = 1;
14388 clib_warning ("parse error '%U'", format_unformat_error, i);
14394 if (spd_id == (u32) ~ 0)
14396 errmsg ("spd_id must be set");
14400 if (sw_if_index_set == 0)
14402 errmsg ("missing interface name or sw_if_index");
14406 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
14408 mp->spd_id = ntohl (spd_id);
14409 mp->sw_if_index = ntohl (sw_if_index);
14410 mp->is_add = is_add;
14418 api_ipsec_spd_entry_add_del (vat_main_t * vam)
14420 unformat_input_t *i = vam->input;
14421 vl_api_ipsec_spd_entry_add_del_t *mp;
14422 u8 is_add = 1, is_outbound = 0;
14423 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
14425 u32 rport_start = 0, rport_stop = (u32) ~ 0;
14426 u32 lport_start = 0, lport_stop = (u32) ~ 0;
14427 vl_api_address_t laddr_start = { }, laddr_stop =
14436 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14438 if (unformat (i, "del"))
14440 if (unformat (i, "outbound"))
14442 if (unformat (i, "inbound"))
14444 else if (unformat (i, "spd_id %d", &spd_id))
14446 else if (unformat (i, "sa_id %d", &sa_id))
14448 else if (unformat (i, "priority %d", &priority))
14450 else if (unformat (i, "protocol %d", &protocol))
14452 else if (unformat (i, "lport_start %d", &lport_start))
14454 else if (unformat (i, "lport_stop %d", &lport_stop))
14456 else if (unformat (i, "rport_start %d", &rport_start))
14458 else if (unformat (i, "rport_stop %d", &rport_stop))
14460 else if (unformat (i, "laddr_start %U",
14461 unformat_vl_api_address, &laddr_start))
14463 else if (unformat (i, "laddr_stop %U", unformat_vl_api_address,
14466 else if (unformat (i, "raddr_start %U", unformat_vl_api_address,
14469 else if (unformat (i, "raddr_stop %U", unformat_vl_api_address,
14473 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
14475 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
14477 clib_warning ("unsupported action: 'resolve'");
14483 clib_warning ("parse error '%U'", format_unformat_error, i);
14489 M (IPSEC_SPD_ENTRY_ADD_DEL, mp);
14491 mp->is_add = is_add;
14493 mp->entry.spd_id = ntohl (spd_id);
14494 mp->entry.priority = ntohl (priority);
14495 mp->entry.is_outbound = is_outbound;
14497 clib_memcpy (&mp->entry.remote_address_start, &raddr_start,
14498 sizeof (vl_api_address_t));
14499 clib_memcpy (&mp->entry.remote_address_stop, &raddr_stop,
14500 sizeof (vl_api_address_t));
14501 clib_memcpy (&mp->entry.local_address_start, &laddr_start,
14502 sizeof (vl_api_address_t));
14503 clib_memcpy (&mp->entry.local_address_stop, &laddr_stop,
14504 sizeof (vl_api_address_t));
14506 mp->entry.protocol = (u8) protocol;
14507 mp->entry.local_port_start = ntohs ((u16) lport_start);
14508 mp->entry.local_port_stop = ntohs ((u16) lport_stop);
14509 mp->entry.remote_port_start = ntohs ((u16) rport_start);
14510 mp->entry.remote_port_stop = ntohs ((u16) rport_stop);
14511 mp->entry.policy = (u8) policy;
14512 mp->entry.sa_id = ntohl (sa_id);
14520 api_ipsec_sad_entry_add_del (vat_main_t * vam)
14522 unformat_input_t *i = vam->input;
14523 vl_api_ipsec_sad_entry_add_del_t *mp;
14524 u32 sad_id = 0, spi = 0;
14525 u8 *ck = 0, *ik = 0;
14528 vl_api_ipsec_crypto_alg_t crypto_alg = IPSEC_API_CRYPTO_ALG_NONE;
14529 vl_api_ipsec_integ_alg_t integ_alg = IPSEC_API_INTEG_ALG_NONE;
14530 vl_api_ipsec_sad_flags_t flags = IPSEC_API_SAD_FLAG_NONE;
14531 vl_api_ipsec_proto_t protocol = IPSEC_API_PROTO_AH;
14532 vl_api_address_t tun_src, tun_dst;
14535 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14537 if (unformat (i, "del"))
14539 else if (unformat (i, "sad_id %d", &sad_id))
14541 else if (unformat (i, "spi %d", &spi))
14543 else if (unformat (i, "esp"))
14544 protocol = IPSEC_API_PROTO_ESP;
14546 if (unformat (i, "tunnel_src %U", unformat_vl_api_address, &tun_src))
14548 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
14549 if (ADDRESS_IP6 == tun_src.af)
14550 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
14553 if (unformat (i, "tunnel_dst %U", unformat_vl_api_address, &tun_dst))
14555 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
14556 if (ADDRESS_IP6 == tun_src.af)
14557 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
14560 if (unformat (i, "crypto_alg %U",
14561 unformat_ipsec_api_crypto_alg, &crypto_alg))
14563 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14565 else if (unformat (i, "integ_alg %U",
14566 unformat_ipsec_api_integ_alg, &integ_alg))
14568 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14572 clib_warning ("parse error '%U'", format_unformat_error, i);
14578 M (IPSEC_SAD_ENTRY_ADD_DEL, mp);
14580 mp->is_add = is_add;
14581 mp->entry.sad_id = ntohl (sad_id);
14582 mp->entry.protocol = protocol;
14583 mp->entry.spi = ntohl (spi);
14584 mp->entry.flags = flags;
14586 mp->entry.crypto_algorithm = crypto_alg;
14587 mp->entry.integrity_algorithm = integ_alg;
14588 mp->entry.crypto_key.length = vec_len (ck);
14589 mp->entry.integrity_key.length = vec_len (ik);
14591 if (mp->entry.crypto_key.length > sizeof (mp->entry.crypto_key.data))
14592 mp->entry.crypto_key.length = sizeof (mp->entry.crypto_key.data);
14594 if (mp->entry.integrity_key.length > sizeof (mp->entry.integrity_key.data))
14595 mp->entry.integrity_key.length = sizeof (mp->entry.integrity_key.data);
14598 clib_memcpy (mp->entry.crypto_key.data, ck, mp->entry.crypto_key.length);
14600 clib_memcpy (mp->entry.integrity_key.data, ik,
14601 mp->entry.integrity_key.length);
14603 if (flags & IPSEC_API_SAD_FLAG_IS_TUNNEL)
14605 clib_memcpy (&mp->entry.tunnel_src, &tun_src,
14606 sizeof (mp->entry.tunnel_src));
14607 clib_memcpy (&mp->entry.tunnel_dst, &tun_dst,
14608 sizeof (mp->entry.tunnel_dst));
14617 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
14619 unformat_input_t *i = vam->input;
14620 vl_api_ipsec_tunnel_if_add_del_t *mp;
14621 u32 local_spi = 0, remote_spi = 0;
14622 u32 crypto_alg = 0, integ_alg = 0;
14623 u8 *lck = NULL, *rck = NULL;
14624 u8 *lik = NULL, *rik = NULL;
14625 vl_api_address_t local_ip = { 0 };
14626 vl_api_address_t remote_ip = { 0 };
14630 u8 anti_replay = 0;
14636 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14638 if (unformat (i, "del"))
14640 else if (unformat (i, "esn"))
14642 else if (unformat (i, "anti-replay"))
14644 else if (unformat (i, "count %d", &count))
14646 else if (unformat (i, "local_spi %d", &local_spi))
14648 else if (unformat (i, "remote_spi %d", &remote_spi))
14651 if (unformat (i, "local_ip %U", unformat_vl_api_address, &local_ip))
14654 if (unformat (i, "remote_ip %U", unformat_vl_api_address, &remote_ip))
14656 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
14659 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
14661 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
14663 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
14667 (i, "crypto_alg %U", unformat_ipsec_api_crypto_alg, &crypto_alg))
14669 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
14671 errmsg ("unsupported crypto-alg: '%U'\n",
14672 format_ipsec_crypto_alg, crypto_alg);
14678 (i, "integ_alg %U", unformat_ipsec_api_integ_alg, &integ_alg))
14680 if (integ_alg >= IPSEC_INTEG_N_ALG)
14682 errmsg ("unsupported integ-alg: '%U'\n",
14683 format_ipsec_integ_alg, integ_alg);
14687 else if (unformat (i, "instance %u", &instance))
14691 errmsg ("parse error '%U'\n", format_unformat_error, i);
14698 /* Turn on async mode */
14699 vam->async_mode = 1;
14700 vam->async_errors = 0;
14701 before = vat_time_now (vam);
14704 for (jj = 0; jj < count; jj++)
14706 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
14708 mp->is_add = is_add;
14710 mp->anti_replay = anti_replay;
14713 increment_address (&remote_ip);
14715 clib_memcpy (&mp->local_ip, &local_ip, sizeof (local_ip));
14716 clib_memcpy (&mp->remote_ip, &remote_ip, sizeof (remote_ip));
14718 mp->local_spi = htonl (local_spi + jj);
14719 mp->remote_spi = htonl (remote_spi + jj);
14720 mp->crypto_alg = (u8) crypto_alg;
14722 mp->local_crypto_key_len = 0;
14725 mp->local_crypto_key_len = vec_len (lck);
14726 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
14727 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
14728 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
14731 mp->remote_crypto_key_len = 0;
14734 mp->remote_crypto_key_len = vec_len (rck);
14735 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
14736 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
14737 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
14740 mp->integ_alg = (u8) integ_alg;
14742 mp->local_integ_key_len = 0;
14745 mp->local_integ_key_len = vec_len (lik);
14746 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
14747 mp->local_integ_key_len = sizeof (mp->local_integ_key);
14748 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
14751 mp->remote_integ_key_len = 0;
14754 mp->remote_integ_key_len = vec_len (rik);
14755 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
14756 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
14757 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
14762 mp->renumber = renumber;
14763 mp->show_instance = ntohl (instance);
14768 /* When testing multiple add/del ops, use a control-ping to sync */
14771 vl_api_control_ping_t *mp_ping;
14775 /* Shut off async mode */
14776 vam->async_mode = 0;
14778 MPING (CONTROL_PING, mp_ping);
14781 timeout = vat_time_now (vam) + 1.0;
14782 while (vat_time_now (vam) < timeout)
14783 if (vam->result_ready == 1)
14788 if (vam->retval == -99)
14789 errmsg ("timeout");
14791 if (vam->async_errors > 0)
14793 errmsg ("%d asynchronous errors", vam->async_errors);
14796 vam->async_errors = 0;
14797 after = vat_time_now (vam);
14799 /* slim chance, but we might have eaten SIGTERM on the first iteration */
14803 print (vam->ofp, "%d tunnels in %.6f secs, %.2f tunnels/sec",
14804 count, after - before, count / (after - before));
14808 /* Wait for a reply... */
14817 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
14819 vat_main_t *vam = &vat_main;
14821 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
14822 "crypto_key %U integ_alg %u integ_key %U flags %x "
14823 "tunnel_src_addr %U tunnel_dst_addr %U "
14824 "salt %u seq_outbound %lu last_seq_inbound %lu "
14825 "replay_window %lu\n",
14826 ntohl (mp->entry.sad_id),
14827 ntohl (mp->sw_if_index),
14828 ntohl (mp->entry.spi),
14829 ntohl (mp->entry.protocol),
14830 ntohl (mp->entry.crypto_algorithm),
14831 format_hex_bytes, mp->entry.crypto_key.data,
14832 mp->entry.crypto_key.length, ntohl (mp->entry.integrity_algorithm),
14833 format_hex_bytes, mp->entry.integrity_key.data,
14834 mp->entry.integrity_key.length, ntohl (mp->entry.flags),
14835 format_vl_api_address, &mp->entry.tunnel_src, format_vl_api_address,
14836 &mp->entry.tunnel_dst, ntohl (mp->salt),
14837 clib_net_to_host_u64 (mp->seq_outbound),
14838 clib_net_to_host_u64 (mp->last_seq_inbound),
14839 clib_net_to_host_u64 (mp->replay_window));
14842 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
14843 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
14845 static void vl_api_ipsec_sa_details_t_handler_json
14846 (vl_api_ipsec_sa_details_t * mp)
14848 vat_main_t *vam = &vat_main;
14849 vat_json_node_t *node = NULL;
14850 vl_api_ipsec_sad_flags_t flags;
14852 if (VAT_JSON_ARRAY != vam->json_tree.type)
14854 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14855 vat_json_init_array (&vam->json_tree);
14857 node = vat_json_array_add (&vam->json_tree);
14859 vat_json_init_object (node);
14860 vat_json_object_add_uint (node, "sa_id", ntohl (mp->entry.sad_id));
14861 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14862 vat_json_object_add_uint (node, "spi", ntohl (mp->entry.spi));
14863 vat_json_object_add_uint (node, "proto", ntohl (mp->entry.protocol));
14864 vat_json_object_add_uint (node, "crypto_alg",
14865 ntohl (mp->entry.crypto_algorithm));
14866 vat_json_object_add_uint (node, "integ_alg",
14867 ntohl (mp->entry.integrity_algorithm));
14868 flags = ntohl (mp->entry.flags);
14869 vat_json_object_add_uint (node, "use_esn",
14870 ! !(flags & IPSEC_API_SAD_FLAG_USE_ESN));
14871 vat_json_object_add_uint (node, "use_anti_replay",
14872 ! !(flags & IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY));
14873 vat_json_object_add_uint (node, "is_tunnel",
14874 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL));
14875 vat_json_object_add_uint (node, "is_tunnel_ip6",
14876 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL_V6));
14877 vat_json_object_add_uint (node, "udp_encap",
14878 ! !(flags & IPSEC_API_SAD_FLAG_UDP_ENCAP));
14879 vat_json_object_add_bytes (node, "crypto_key", mp->entry.crypto_key.data,
14880 mp->entry.crypto_key.length);
14881 vat_json_object_add_bytes (node, "integ_key", mp->entry.integrity_key.data,
14882 mp->entry.integrity_key.length);
14883 vat_json_object_add_address (node, "src", &mp->entry.tunnel_src);
14884 vat_json_object_add_address (node, "dst", &mp->entry.tunnel_dst);
14885 vat_json_object_add_uint (node, "replay_window",
14886 clib_net_to_host_u64 (mp->replay_window));
14890 api_ipsec_sa_dump (vat_main_t * vam)
14892 unformat_input_t *i = vam->input;
14893 vl_api_ipsec_sa_dump_t *mp;
14894 vl_api_control_ping_t *mp_ping;
14898 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14900 if (unformat (i, "sa_id %d", &sa_id))
14904 clib_warning ("parse error '%U'", format_unformat_error, i);
14909 M (IPSEC_SA_DUMP, mp);
14911 mp->sa_id = ntohl (sa_id);
14915 /* Use a control ping for synchronization */
14916 M (CONTROL_PING, mp_ping);
14924 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
14926 unformat_input_t *i = vam->input;
14927 vl_api_ipsec_tunnel_if_set_sa_t *mp;
14928 u32 sw_if_index = ~0;
14930 u8 is_outbound = (u8) ~ 0;
14933 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14935 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14937 else if (unformat (i, "sa_id %d", &sa_id))
14939 else if (unformat (i, "outbound"))
14941 else if (unformat (i, "inbound"))
14945 clib_warning ("parse error '%U'", format_unformat_error, i);
14950 if (sw_if_index == ~0)
14952 errmsg ("interface must be specified");
14958 errmsg ("SA ID must be specified");
14962 M (IPSEC_TUNNEL_IF_SET_SA, mp);
14964 mp->sw_if_index = htonl (sw_if_index);
14965 mp->sa_id = htonl (sa_id);
14966 mp->is_outbound = is_outbound;
14975 api_get_first_msg_id (vat_main_t * vam)
14977 vl_api_get_first_msg_id_t *mp;
14978 unformat_input_t *i = vam->input;
14983 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14985 if (unformat (i, "client %s", &name))
14993 errmsg ("missing client name");
14996 vec_add1 (name, 0);
14998 if (vec_len (name) > 63)
15000 errmsg ("client name too long");
15004 M (GET_FIRST_MSG_ID, mp);
15005 clib_memcpy (mp->name, name, vec_len (name));
15012 api_cop_interface_enable_disable (vat_main_t * vam)
15014 unformat_input_t *line_input = vam->input;
15015 vl_api_cop_interface_enable_disable_t *mp;
15016 u32 sw_if_index = ~0;
15017 u8 enable_disable = 1;
15020 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15022 if (unformat (line_input, "disable"))
15023 enable_disable = 0;
15024 if (unformat (line_input, "enable"))
15025 enable_disable = 1;
15026 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15027 vam, &sw_if_index))
15029 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15035 if (sw_if_index == ~0)
15037 errmsg ("missing interface name or sw_if_index");
15041 /* Construct the API message */
15042 M (COP_INTERFACE_ENABLE_DISABLE, mp);
15043 mp->sw_if_index = ntohl (sw_if_index);
15044 mp->enable_disable = enable_disable;
15048 /* Wait for the reply */
15054 api_cop_whitelist_enable_disable (vat_main_t * vam)
15056 unformat_input_t *line_input = vam->input;
15057 vl_api_cop_whitelist_enable_disable_t *mp;
15058 u32 sw_if_index = ~0;
15059 u8 ip4 = 0, ip6 = 0, default_cop = 0;
15063 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15065 if (unformat (line_input, "ip4"))
15067 else if (unformat (line_input, "ip6"))
15069 else if (unformat (line_input, "default"))
15071 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15072 vam, &sw_if_index))
15074 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15076 else if (unformat (line_input, "fib-id %d", &fib_id))
15082 if (sw_if_index == ~0)
15084 errmsg ("missing interface name or sw_if_index");
15088 /* Construct the API message */
15089 M (COP_WHITELIST_ENABLE_DISABLE, mp);
15090 mp->sw_if_index = ntohl (sw_if_index);
15091 mp->fib_id = ntohl (fib_id);
15094 mp->default_cop = default_cop;
15098 /* Wait for the reply */
15104 api_get_node_graph (vat_main_t * vam)
15106 vl_api_get_node_graph_t *mp;
15109 M (GET_NODE_GRAPH, mp);
15113 /* Wait for the reply */
15119 /** Used for parsing LISP eids */
15120 typedef CLIB_PACKED(struct{
15121 u8 addr[16]; /**< eid address */
15122 u32 len; /**< prefix length if IP */
15123 u8 type; /**< type of eid */
15128 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
15130 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
15132 clib_memset (a, 0, sizeof (a[0]));
15134 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
15136 a->type = 0; /* ipv4 type */
15138 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
15140 a->type = 1; /* ipv6 type */
15142 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
15144 a->type = 2; /* mac type */
15146 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
15148 a->type = 3; /* NSH type */
15149 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
15150 nsh->spi = clib_host_to_net_u32 (nsh->spi);
15157 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
15166 lisp_eid_size_vat (u8 type)
15183 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
15185 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
15189 api_one_add_del_locator_set (vat_main_t * vam)
15191 unformat_input_t *input = vam->input;
15192 vl_api_one_add_del_locator_set_t *mp;
15194 u8 *locator_set_name = NULL;
15195 u8 locator_set_name_set = 0;
15196 vl_api_local_locator_t locator, *locators = 0;
15197 u32 sw_if_index, priority, weight;
15201 /* Parse args required to build the message */
15202 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15204 if (unformat (input, "del"))
15208 else if (unformat (input, "locator-set %s", &locator_set_name))
15210 locator_set_name_set = 1;
15212 else if (unformat (input, "sw_if_index %u p %u w %u",
15213 &sw_if_index, &priority, &weight))
15215 locator.sw_if_index = htonl (sw_if_index);
15216 locator.priority = priority;
15217 locator.weight = weight;
15218 vec_add1 (locators, locator);
15222 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
15223 &sw_if_index, &priority, &weight))
15225 locator.sw_if_index = htonl (sw_if_index);
15226 locator.priority = priority;
15227 locator.weight = weight;
15228 vec_add1 (locators, locator);
15234 if (locator_set_name_set == 0)
15236 errmsg ("missing locator-set name");
15237 vec_free (locators);
15241 if (vec_len (locator_set_name) > 64)
15243 errmsg ("locator-set name too long");
15244 vec_free (locator_set_name);
15245 vec_free (locators);
15248 vec_add1 (locator_set_name, 0);
15250 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
15252 /* Construct the API message */
15253 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
15255 mp->is_add = is_add;
15256 clib_memcpy (mp->locator_set_name, locator_set_name,
15257 vec_len (locator_set_name));
15258 vec_free (locator_set_name);
15260 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
15262 clib_memcpy (mp->locators, locators, data_len);
15263 vec_free (locators);
15268 /* Wait for a reply... */
15273 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
15276 api_one_add_del_locator (vat_main_t * vam)
15278 unformat_input_t *input = vam->input;
15279 vl_api_one_add_del_locator_t *mp;
15280 u32 tmp_if_index = ~0;
15281 u32 sw_if_index = ~0;
15282 u8 sw_if_index_set = 0;
15283 u8 sw_if_index_if_name_set = 0;
15285 u8 priority_set = 0;
15289 u8 *locator_set_name = NULL;
15290 u8 locator_set_name_set = 0;
15293 /* Parse args required to build the message */
15294 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15296 if (unformat (input, "del"))
15300 else if (unformat (input, "locator-set %s", &locator_set_name))
15302 locator_set_name_set = 1;
15304 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
15307 sw_if_index_if_name_set = 1;
15308 sw_if_index = tmp_if_index;
15310 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
15312 sw_if_index_set = 1;
15313 sw_if_index = tmp_if_index;
15315 else if (unformat (input, "p %d", &priority))
15319 else if (unformat (input, "w %d", &weight))
15327 if (locator_set_name_set == 0)
15329 errmsg ("missing locator-set name");
15333 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
15335 errmsg ("missing sw_if_index");
15336 vec_free (locator_set_name);
15340 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
15342 errmsg ("cannot use both params interface name and sw_if_index");
15343 vec_free (locator_set_name);
15347 if (priority_set == 0)
15349 errmsg ("missing locator-set priority");
15350 vec_free (locator_set_name);
15354 if (weight_set == 0)
15356 errmsg ("missing locator-set weight");
15357 vec_free (locator_set_name);
15361 if (vec_len (locator_set_name) > 64)
15363 errmsg ("locator-set name too long");
15364 vec_free (locator_set_name);
15367 vec_add1 (locator_set_name, 0);
15369 /* Construct the API message */
15370 M (ONE_ADD_DEL_LOCATOR, mp);
15372 mp->is_add = is_add;
15373 mp->sw_if_index = ntohl (sw_if_index);
15374 mp->priority = priority;
15375 mp->weight = weight;
15376 clib_memcpy (mp->locator_set_name, locator_set_name,
15377 vec_len (locator_set_name));
15378 vec_free (locator_set_name);
15383 /* Wait for a reply... */
15388 #define api_lisp_add_del_locator api_one_add_del_locator
15391 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
15393 u32 *key_id = va_arg (*args, u32 *);
15396 if (unformat (input, "%s", &s))
15398 if (!strcmp ((char *) s, "sha1"))
15399 key_id[0] = HMAC_SHA_1_96;
15400 else if (!strcmp ((char *) s, "sha256"))
15401 key_id[0] = HMAC_SHA_256_128;
15404 clib_warning ("invalid key_id: '%s'", s);
15405 key_id[0] = HMAC_NO_KEY;
15416 api_one_add_del_local_eid (vat_main_t * vam)
15418 unformat_input_t *input = vam->input;
15419 vl_api_one_add_del_local_eid_t *mp;
15422 lisp_eid_vat_t _eid, *eid = &_eid;
15423 u8 *locator_set_name = 0;
15424 u8 locator_set_name_set = 0;
15430 /* Parse args required to build the message */
15431 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15433 if (unformat (input, "del"))
15437 else if (unformat (input, "vni %d", &vni))
15441 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15445 else if (unformat (input, "locator-set %s", &locator_set_name))
15447 locator_set_name_set = 1;
15449 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
15451 else if (unformat (input, "secret-key %_%v%_", &key))
15457 if (locator_set_name_set == 0)
15459 errmsg ("missing locator-set name");
15465 errmsg ("EID address not set!");
15466 vec_free (locator_set_name);
15470 if (key && (0 == key_id))
15472 errmsg ("invalid key_id!");
15476 if (vec_len (key) > 64)
15478 errmsg ("key too long");
15483 if (vec_len (locator_set_name) > 64)
15485 errmsg ("locator-set name too long");
15486 vec_free (locator_set_name);
15489 vec_add1 (locator_set_name, 0);
15491 /* Construct the API message */
15492 M (ONE_ADD_DEL_LOCAL_EID, mp);
15494 mp->is_add = is_add;
15495 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15496 mp->eid_type = eid->type;
15497 mp->prefix_len = eid->len;
15498 mp->vni = clib_host_to_net_u32 (vni);
15499 mp->key_id = clib_host_to_net_u16 (key_id);
15500 clib_memcpy (mp->locator_set_name, locator_set_name,
15501 vec_len (locator_set_name));
15502 clib_memcpy (mp->key, key, vec_len (key));
15504 vec_free (locator_set_name);
15510 /* Wait for a reply... */
15515 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
15518 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
15520 u32 dp_table = 0, vni = 0;;
15521 unformat_input_t *input = vam->input;
15522 vl_api_gpe_add_del_fwd_entry_t *mp;
15524 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
15525 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
15526 u8 rmt_eid_set = 0, lcl_eid_set = 0;
15527 u32 action = ~0, w;
15528 ip4_address_t rmt_rloc4, lcl_rloc4;
15529 ip6_address_t rmt_rloc6, lcl_rloc6;
15530 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
15533 clib_memset (&rloc, 0, sizeof (rloc));
15535 /* Parse args required to build the message */
15536 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15538 if (unformat (input, "del"))
15540 else if (unformat (input, "add"))
15542 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
15546 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
15550 else if (unformat (input, "vrf %d", &dp_table))
15552 else if (unformat (input, "bd %d", &dp_table))
15554 else if (unformat (input, "vni %d", &vni))
15556 else if (unformat (input, "w %d", &w))
15560 errmsg ("No RLOC configured for setting priority/weight!");
15563 curr_rloc->weight = w;
15565 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
15566 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
15570 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
15572 vec_add1 (lcl_locs, rloc);
15574 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
15575 vec_add1 (rmt_locs, rloc);
15576 /* weight saved in rmt loc */
15577 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15579 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
15580 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
15583 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
15585 vec_add1 (lcl_locs, rloc);
15587 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
15588 vec_add1 (rmt_locs, rloc);
15589 /* weight saved in rmt loc */
15590 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15592 else if (unformat (input, "action %d", &action))
15598 clib_warning ("parse error '%U'", format_unformat_error, input);
15605 errmsg ("remote eid addresses not set");
15609 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
15611 errmsg ("eid types don't match");
15615 if (0 == rmt_locs && (u32) ~ 0 == action)
15617 errmsg ("action not set for negative mapping");
15621 /* Construct the API message */
15622 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
15623 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
15625 mp->is_add = is_add;
15626 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
15627 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
15628 mp->eid_type = rmt_eid->type;
15629 mp->dp_table = clib_host_to_net_u32 (dp_table);
15630 mp->vni = clib_host_to_net_u32 (vni);
15631 mp->rmt_len = rmt_eid->len;
15632 mp->lcl_len = lcl_eid->len;
15633 mp->action = action;
15635 if (0 != rmt_locs && 0 != lcl_locs)
15637 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
15638 clib_memcpy (mp->locs, lcl_locs,
15639 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
15641 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
15642 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
15643 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
15645 vec_free (lcl_locs);
15646 vec_free (rmt_locs);
15651 /* Wait for a reply... */
15657 api_one_add_del_map_server (vat_main_t * vam)
15659 unformat_input_t *input = vam->input;
15660 vl_api_one_add_del_map_server_t *mp;
15664 ip4_address_t ipv4;
15665 ip6_address_t ipv6;
15668 /* Parse args required to build the message */
15669 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15671 if (unformat (input, "del"))
15675 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15679 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15687 if (ipv4_set && ipv6_set)
15689 errmsg ("both eid v4 and v6 addresses set");
15693 if (!ipv4_set && !ipv6_set)
15695 errmsg ("eid addresses not set");
15699 /* Construct the API message */
15700 M (ONE_ADD_DEL_MAP_SERVER, mp);
15702 mp->is_add = is_add;
15706 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
15711 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
15717 /* Wait for a reply... */
15722 #define api_lisp_add_del_map_server api_one_add_del_map_server
15725 api_one_add_del_map_resolver (vat_main_t * vam)
15727 unformat_input_t *input = vam->input;
15728 vl_api_one_add_del_map_resolver_t *mp;
15732 ip4_address_t ipv4;
15733 ip6_address_t ipv6;
15736 /* Parse args required to build the message */
15737 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15739 if (unformat (input, "del"))
15743 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15747 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15755 if (ipv4_set && ipv6_set)
15757 errmsg ("both eid v4 and v6 addresses set");
15761 if (!ipv4_set && !ipv6_set)
15763 errmsg ("eid addresses not set");
15767 /* Construct the API message */
15768 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
15770 mp->is_add = is_add;
15774 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
15779 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
15785 /* Wait for a reply... */
15790 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
15793 api_lisp_gpe_enable_disable (vat_main_t * vam)
15795 unformat_input_t *input = vam->input;
15796 vl_api_gpe_enable_disable_t *mp;
15801 /* Parse args required to build the message */
15802 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15804 if (unformat (input, "enable"))
15809 else if (unformat (input, "disable"))
15820 errmsg ("Value not set");
15824 /* Construct the API message */
15825 M (GPE_ENABLE_DISABLE, mp);
15832 /* Wait for a reply... */
15838 api_one_rloc_probe_enable_disable (vat_main_t * vam)
15840 unformat_input_t *input = vam->input;
15841 vl_api_one_rloc_probe_enable_disable_t *mp;
15846 /* Parse args required to build the message */
15847 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15849 if (unformat (input, "enable"))
15854 else if (unformat (input, "disable"))
15862 errmsg ("Value not set");
15866 /* Construct the API message */
15867 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
15869 mp->is_enabled = is_en;
15874 /* Wait for a reply... */
15879 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
15882 api_one_map_register_enable_disable (vat_main_t * vam)
15884 unformat_input_t *input = vam->input;
15885 vl_api_one_map_register_enable_disable_t *mp;
15890 /* Parse args required to build the message */
15891 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15893 if (unformat (input, "enable"))
15898 else if (unformat (input, "disable"))
15906 errmsg ("Value not set");
15910 /* Construct the API message */
15911 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
15913 mp->is_enabled = is_en;
15918 /* Wait for a reply... */
15923 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
15926 api_one_enable_disable (vat_main_t * vam)
15928 unformat_input_t *input = vam->input;
15929 vl_api_one_enable_disable_t *mp;
15934 /* Parse args required to build the message */
15935 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15937 if (unformat (input, "enable"))
15942 else if (unformat (input, "disable"))
15952 errmsg ("Value not set");
15956 /* Construct the API message */
15957 M (ONE_ENABLE_DISABLE, mp);
15964 /* Wait for a reply... */
15969 #define api_lisp_enable_disable api_one_enable_disable
15972 api_one_enable_disable_xtr_mode (vat_main_t * vam)
15974 unformat_input_t *input = vam->input;
15975 vl_api_one_enable_disable_xtr_mode_t *mp;
15980 /* Parse args required to build the message */
15981 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15983 if (unformat (input, "enable"))
15988 else if (unformat (input, "disable"))
15998 errmsg ("Value not set");
16002 /* Construct the API message */
16003 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
16010 /* Wait for a reply... */
16016 api_one_show_xtr_mode (vat_main_t * vam)
16018 vl_api_one_show_xtr_mode_t *mp;
16021 /* Construct the API message */
16022 M (ONE_SHOW_XTR_MODE, mp);
16027 /* Wait for a reply... */
16033 api_one_enable_disable_pitr_mode (vat_main_t * vam)
16035 unformat_input_t *input = vam->input;
16036 vl_api_one_enable_disable_pitr_mode_t *mp;
16041 /* Parse args required to build the message */
16042 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16044 if (unformat (input, "enable"))
16049 else if (unformat (input, "disable"))
16059 errmsg ("Value not set");
16063 /* Construct the API message */
16064 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
16071 /* Wait for a reply... */
16077 api_one_show_pitr_mode (vat_main_t * vam)
16079 vl_api_one_show_pitr_mode_t *mp;
16082 /* Construct the API message */
16083 M (ONE_SHOW_PITR_MODE, mp);
16088 /* Wait for a reply... */
16094 api_one_enable_disable_petr_mode (vat_main_t * vam)
16096 unformat_input_t *input = vam->input;
16097 vl_api_one_enable_disable_petr_mode_t *mp;
16102 /* Parse args required to build the message */
16103 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16105 if (unformat (input, "enable"))
16110 else if (unformat (input, "disable"))
16120 errmsg ("Value not set");
16124 /* Construct the API message */
16125 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
16132 /* Wait for a reply... */
16138 api_one_show_petr_mode (vat_main_t * vam)
16140 vl_api_one_show_petr_mode_t *mp;
16143 /* Construct the API message */
16144 M (ONE_SHOW_PETR_MODE, mp);
16149 /* Wait for a reply... */
16155 api_show_one_map_register_state (vat_main_t * vam)
16157 vl_api_show_one_map_register_state_t *mp;
16160 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
16165 /* wait for reply */
16170 #define api_show_lisp_map_register_state api_show_one_map_register_state
16173 api_show_one_rloc_probe_state (vat_main_t * vam)
16175 vl_api_show_one_rloc_probe_state_t *mp;
16178 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
16183 /* wait for reply */
16188 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
16191 api_one_add_del_ndp_entry (vat_main_t * vam)
16193 vl_api_one_add_del_ndp_entry_t *mp;
16194 unformat_input_t *input = vam->input;
16199 u8 mac[6] = { 0, };
16200 u8 ip6[16] = { 0, };
16204 /* Parse args required to build the message */
16205 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16207 if (unformat (input, "del"))
16209 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16211 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
16213 else if (unformat (input, "bd %d", &bd))
16217 errmsg ("parse error '%U'", format_unformat_error, input);
16222 if (!bd_set || !ip_set || (!mac_set && is_add))
16224 errmsg ("Missing BD, IP or MAC!");
16228 M (ONE_ADD_DEL_NDP_ENTRY, mp);
16229 mp->is_add = is_add;
16230 clib_memcpy (mp->mac, mac, 6);
16231 mp->bd = clib_host_to_net_u32 (bd);
16232 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
16237 /* wait for reply */
16243 api_one_add_del_l2_arp_entry (vat_main_t * vam)
16245 vl_api_one_add_del_l2_arp_entry_t *mp;
16246 unformat_input_t *input = vam->input;
16251 u8 mac[6] = { 0, };
16252 u32 ip4 = 0, bd = ~0;
16255 /* Parse args required to build the message */
16256 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16258 if (unformat (input, "del"))
16260 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16262 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
16264 else if (unformat (input, "bd %d", &bd))
16268 errmsg ("parse error '%U'", format_unformat_error, input);
16273 if (!bd_set || !ip_set || (!mac_set && is_add))
16275 errmsg ("Missing BD, IP or MAC!");
16279 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
16280 mp->is_add = is_add;
16281 clib_memcpy (mp->mac, mac, 6);
16282 mp->bd = clib_host_to_net_u32 (bd);
16288 /* wait for reply */
16294 api_one_ndp_bd_get (vat_main_t * vam)
16296 vl_api_one_ndp_bd_get_t *mp;
16299 M (ONE_NDP_BD_GET, mp);
16304 /* wait for reply */
16310 api_one_ndp_entries_get (vat_main_t * vam)
16312 vl_api_one_ndp_entries_get_t *mp;
16313 unformat_input_t *input = vam->input;
16318 /* Parse args required to build the message */
16319 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16321 if (unformat (input, "bd %d", &bd))
16325 errmsg ("parse error '%U'", format_unformat_error, input);
16332 errmsg ("Expected bridge domain!");
16336 M (ONE_NDP_ENTRIES_GET, mp);
16337 mp->bd = clib_host_to_net_u32 (bd);
16342 /* wait for reply */
16348 api_one_l2_arp_bd_get (vat_main_t * vam)
16350 vl_api_one_l2_arp_bd_get_t *mp;
16353 M (ONE_L2_ARP_BD_GET, mp);
16358 /* wait for reply */
16364 api_one_l2_arp_entries_get (vat_main_t * vam)
16366 vl_api_one_l2_arp_entries_get_t *mp;
16367 unformat_input_t *input = vam->input;
16372 /* Parse args required to build the message */
16373 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16375 if (unformat (input, "bd %d", &bd))
16379 errmsg ("parse error '%U'", format_unformat_error, input);
16386 errmsg ("Expected bridge domain!");
16390 M (ONE_L2_ARP_ENTRIES_GET, mp);
16391 mp->bd = clib_host_to_net_u32 (bd);
16396 /* wait for reply */
16402 api_one_stats_enable_disable (vat_main_t * vam)
16404 vl_api_one_stats_enable_disable_t *mp;
16405 unformat_input_t *input = vam->input;
16410 /* Parse args required to build the message */
16411 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16413 if (unformat (input, "enable"))
16418 else if (unformat (input, "disable"))
16428 errmsg ("Value not set");
16432 M (ONE_STATS_ENABLE_DISABLE, mp);
16438 /* wait for reply */
16444 api_show_one_stats_enable_disable (vat_main_t * vam)
16446 vl_api_show_one_stats_enable_disable_t *mp;
16449 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
16454 /* wait for reply */
16460 api_show_one_map_request_mode (vat_main_t * vam)
16462 vl_api_show_one_map_request_mode_t *mp;
16465 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
16470 /* wait for reply */
16475 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
16478 api_one_map_request_mode (vat_main_t * vam)
16480 unformat_input_t *input = vam->input;
16481 vl_api_one_map_request_mode_t *mp;
16485 /* Parse args required to build the message */
16486 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16488 if (unformat (input, "dst-only"))
16490 else if (unformat (input, "src-dst"))
16494 errmsg ("parse error '%U'", format_unformat_error, input);
16499 M (ONE_MAP_REQUEST_MODE, mp);
16506 /* wait for reply */
16511 #define api_lisp_map_request_mode api_one_map_request_mode
16514 * Enable/disable ONE proxy ITR.
16516 * @param vam vpp API test context
16517 * @return return code
16520 api_one_pitr_set_locator_set (vat_main_t * vam)
16522 u8 ls_name_set = 0;
16523 unformat_input_t *input = vam->input;
16524 vl_api_one_pitr_set_locator_set_t *mp;
16529 /* Parse args required to build the message */
16530 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16532 if (unformat (input, "del"))
16534 else if (unformat (input, "locator-set %s", &ls_name))
16538 errmsg ("parse error '%U'", format_unformat_error, input);
16545 errmsg ("locator-set name not set!");
16549 M (ONE_PITR_SET_LOCATOR_SET, mp);
16551 mp->is_add = is_add;
16552 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16553 vec_free (ls_name);
16558 /* wait for reply */
16563 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
16566 api_one_nsh_set_locator_set (vat_main_t * vam)
16568 u8 ls_name_set = 0;
16569 unformat_input_t *input = vam->input;
16570 vl_api_one_nsh_set_locator_set_t *mp;
16575 /* Parse args required to build the message */
16576 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16578 if (unformat (input, "del"))
16580 else if (unformat (input, "ls %s", &ls_name))
16584 errmsg ("parse error '%U'", format_unformat_error, input);
16589 if (!ls_name_set && is_add)
16591 errmsg ("locator-set name not set!");
16595 M (ONE_NSH_SET_LOCATOR_SET, mp);
16597 mp->is_add = is_add;
16598 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16599 vec_free (ls_name);
16604 /* wait for reply */
16610 api_show_one_pitr (vat_main_t * vam)
16612 vl_api_show_one_pitr_t *mp;
16615 if (!vam->json_output)
16617 print (vam->ofp, "%=20s", "lisp status:");
16620 M (SHOW_ONE_PITR, mp);
16624 /* Wait for a reply... */
16629 #define api_show_lisp_pitr api_show_one_pitr
16632 api_one_use_petr (vat_main_t * vam)
16634 unformat_input_t *input = vam->input;
16635 vl_api_one_use_petr_t *mp;
16640 clib_memset (&ip, 0, sizeof (ip));
16642 /* Parse args required to build the message */
16643 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16645 if (unformat (input, "disable"))
16648 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
16651 ip_addr_version (&ip) = IP4;
16654 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
16657 ip_addr_version (&ip) = IP6;
16661 errmsg ("parse error '%U'", format_unformat_error, input);
16666 M (ONE_USE_PETR, mp);
16668 mp->is_add = is_add;
16671 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
16673 clib_memcpy (mp->address, &ip, 4);
16675 clib_memcpy (mp->address, &ip, 16);
16681 /* wait for reply */
16686 #define api_lisp_use_petr api_one_use_petr
16689 api_show_one_nsh_mapping (vat_main_t * vam)
16691 vl_api_show_one_use_petr_t *mp;
16694 if (!vam->json_output)
16696 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
16699 M (SHOW_ONE_NSH_MAPPING, mp);
16703 /* Wait for a reply... */
16709 api_show_one_use_petr (vat_main_t * vam)
16711 vl_api_show_one_use_petr_t *mp;
16714 if (!vam->json_output)
16716 print (vam->ofp, "%=20s", "Proxy-ETR status:");
16719 M (SHOW_ONE_USE_PETR, mp);
16723 /* Wait for a reply... */
16728 #define api_show_lisp_use_petr api_show_one_use_petr
16731 * Add/delete mapping between vni and vrf
16734 api_one_eid_table_add_del_map (vat_main_t * vam)
16736 unformat_input_t *input = vam->input;
16737 vl_api_one_eid_table_add_del_map_t *mp;
16738 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
16739 u32 vni, vrf, bd_index;
16742 /* Parse args required to build the message */
16743 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16745 if (unformat (input, "del"))
16747 else if (unformat (input, "vrf %d", &vrf))
16749 else if (unformat (input, "bd_index %d", &bd_index))
16751 else if (unformat (input, "vni %d", &vni))
16757 if (!vni_set || (!vrf_set && !bd_index_set))
16759 errmsg ("missing arguments!");
16763 if (vrf_set && bd_index_set)
16765 errmsg ("error: both vrf and bd entered!");
16769 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
16771 mp->is_add = is_add;
16772 mp->vni = htonl (vni);
16773 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
16774 mp->is_l2 = bd_index_set;
16779 /* wait for reply */
16784 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
16787 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
16789 u32 *action = va_arg (*args, u32 *);
16792 if (unformat (input, "%s", &s))
16794 if (!strcmp ((char *) s, "no-action"))
16796 else if (!strcmp ((char *) s, "natively-forward"))
16798 else if (!strcmp ((char *) s, "send-map-request"))
16800 else if (!strcmp ((char *) s, "drop"))
16804 clib_warning ("invalid action: '%s'", s);
16816 * Add/del remote mapping to/from ONE control plane
16818 * @param vam vpp API test context
16819 * @return return code
16822 api_one_add_del_remote_mapping (vat_main_t * vam)
16824 unformat_input_t *input = vam->input;
16825 vl_api_one_add_del_remote_mapping_t *mp;
16827 lisp_eid_vat_t _eid, *eid = &_eid;
16828 lisp_eid_vat_t _seid, *seid = &_seid;
16829 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
16830 u32 action = ~0, p, w, data_len;
16831 ip4_address_t rloc4;
16832 ip6_address_t rloc6;
16833 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
16836 clib_memset (&rloc, 0, sizeof (rloc));
16838 /* Parse args required to build the message */
16839 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16841 if (unformat (input, "del-all"))
16845 else if (unformat (input, "del"))
16849 else if (unformat (input, "add"))
16853 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
16857 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
16861 else if (unformat (input, "vni %d", &vni))
16865 else if (unformat (input, "p %d w %d", &p, &w))
16869 errmsg ("No RLOC configured for setting priority/weight!");
16872 curr_rloc->priority = p;
16873 curr_rloc->weight = w;
16875 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
16878 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
16879 vec_add1 (rlocs, rloc);
16880 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16882 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
16885 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
16886 vec_add1 (rlocs, rloc);
16887 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16889 else if (unformat (input, "action %U",
16890 unformat_negative_mapping_action, &action))
16896 clib_warning ("parse error '%U'", format_unformat_error, input);
16903 errmsg ("missing params!");
16907 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
16909 errmsg ("no action set for negative map-reply!");
16913 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
16915 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
16916 mp->is_add = is_add;
16917 mp->vni = htonl (vni);
16918 mp->action = (u8) action;
16919 mp->is_src_dst = seid_set;
16920 mp->eid_len = eid->len;
16921 mp->seid_len = seid->len;
16922 mp->del_all = del_all;
16923 mp->eid_type = eid->type;
16924 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
16925 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
16927 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
16928 clib_memcpy (mp->rlocs, rlocs, data_len);
16934 /* Wait for a reply... */
16939 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
16942 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
16943 * forwarding entries in data-plane accordingly.
16945 * @param vam vpp API test context
16946 * @return return code
16949 api_one_add_del_adjacency (vat_main_t * vam)
16951 unformat_input_t *input = vam->input;
16952 vl_api_one_add_del_adjacency_t *mp;
16954 ip4_address_t leid4, reid4;
16955 ip6_address_t leid6, reid6;
16956 u8 reid_mac[6] = { 0 };
16957 u8 leid_mac[6] = { 0 };
16958 u8 reid_type, leid_type;
16959 u32 leid_len = 0, reid_len = 0, len;
16963 leid_type = reid_type = (u8) ~ 0;
16965 /* Parse args required to build the message */
16966 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16968 if (unformat (input, "del"))
16972 else if (unformat (input, "add"))
16976 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
16979 reid_type = 0; /* ipv4 */
16982 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
16985 reid_type = 1; /* ipv6 */
16988 else if (unformat (input, "reid %U", unformat_ethernet_address,
16991 reid_type = 2; /* mac */
16993 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
16996 leid_type = 0; /* ipv4 */
16999 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
17002 leid_type = 1; /* ipv6 */
17005 else if (unformat (input, "leid %U", unformat_ethernet_address,
17008 leid_type = 2; /* mac */
17010 else if (unformat (input, "vni %d", &vni))
17016 errmsg ("parse error '%U'", format_unformat_error, input);
17021 if ((u8) ~ 0 == reid_type)
17023 errmsg ("missing params!");
17027 if (leid_type != reid_type)
17029 errmsg ("remote and local EIDs are of different types!");
17033 M (ONE_ADD_DEL_ADJACENCY, mp);
17034 mp->is_add = is_add;
17035 mp->vni = htonl (vni);
17036 mp->leid_len = leid_len;
17037 mp->reid_len = reid_len;
17038 mp->eid_type = reid_type;
17040 switch (mp->eid_type)
17043 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
17044 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
17047 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
17048 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
17051 clib_memcpy (mp->leid, leid_mac, 6);
17052 clib_memcpy (mp->reid, reid_mac, 6);
17055 errmsg ("unknown EID type %d!", mp->eid_type);
17062 /* Wait for a reply... */
17067 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
17070 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
17072 u32 *mode = va_arg (*args, u32 *);
17074 if (unformat (input, "lisp"))
17076 else if (unformat (input, "vxlan"))
17085 api_gpe_get_encap_mode (vat_main_t * vam)
17087 vl_api_gpe_get_encap_mode_t *mp;
17090 /* Construct the API message */
17091 M (GPE_GET_ENCAP_MODE, mp);
17096 /* Wait for a reply... */
17102 api_gpe_set_encap_mode (vat_main_t * vam)
17104 unformat_input_t *input = vam->input;
17105 vl_api_gpe_set_encap_mode_t *mp;
17109 /* Parse args required to build the message */
17110 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17112 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
17118 /* Construct the API message */
17119 M (GPE_SET_ENCAP_MODE, mp);
17126 /* Wait for a reply... */
17132 api_lisp_gpe_add_del_iface (vat_main_t * vam)
17134 unformat_input_t *input = vam->input;
17135 vl_api_gpe_add_del_iface_t *mp;
17136 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
17137 u32 dp_table = 0, vni = 0;
17140 /* Parse args required to build the message */
17141 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17143 if (unformat (input, "up"))
17148 else if (unformat (input, "down"))
17153 else if (unformat (input, "table_id %d", &dp_table))
17157 else if (unformat (input, "bd_id %d", &dp_table))
17162 else if (unformat (input, "vni %d", &vni))
17170 if (action_set == 0)
17172 errmsg ("Action not set");
17175 if (dp_table_set == 0 || vni_set == 0)
17177 errmsg ("vni and dp_table must be set");
17181 /* Construct the API message */
17182 M (GPE_ADD_DEL_IFACE, mp);
17184 mp->is_add = is_add;
17185 mp->dp_table = clib_host_to_net_u32 (dp_table);
17187 mp->vni = clib_host_to_net_u32 (vni);
17192 /* Wait for a reply... */
17198 api_one_map_register_fallback_threshold (vat_main_t * vam)
17200 unformat_input_t *input = vam->input;
17201 vl_api_one_map_register_fallback_threshold_t *mp;
17206 /* Parse args required to build the message */
17207 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17209 if (unformat (input, "%u", &value))
17213 clib_warning ("parse error '%U'", format_unformat_error, input);
17220 errmsg ("fallback threshold value is missing!");
17224 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17225 mp->value = clib_host_to_net_u32 (value);
17230 /* Wait for a reply... */
17236 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
17238 vl_api_show_one_map_register_fallback_threshold_t *mp;
17241 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17246 /* Wait for a reply... */
17252 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
17254 u32 *proto = va_arg (*args, u32 *);
17256 if (unformat (input, "udp"))
17258 else if (unformat (input, "api"))
17267 api_one_set_transport_protocol (vat_main_t * vam)
17269 unformat_input_t *input = vam->input;
17270 vl_api_one_set_transport_protocol_t *mp;
17275 /* Parse args required to build the message */
17276 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17278 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
17282 clib_warning ("parse error '%U'", format_unformat_error, input);
17289 errmsg ("Transport protocol missing!");
17293 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
17294 mp->protocol = (u8) protocol;
17299 /* Wait for a reply... */
17305 api_one_get_transport_protocol (vat_main_t * vam)
17307 vl_api_one_get_transport_protocol_t *mp;
17310 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
17315 /* Wait for a reply... */
17321 api_one_map_register_set_ttl (vat_main_t * vam)
17323 unformat_input_t *input = vam->input;
17324 vl_api_one_map_register_set_ttl_t *mp;
17329 /* Parse args required to build the message */
17330 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17332 if (unformat (input, "%u", &ttl))
17336 clib_warning ("parse error '%U'", format_unformat_error, input);
17343 errmsg ("TTL value missing!");
17347 M (ONE_MAP_REGISTER_SET_TTL, mp);
17348 mp->ttl = clib_host_to_net_u32 (ttl);
17353 /* Wait for a reply... */
17359 api_show_one_map_register_ttl (vat_main_t * vam)
17361 vl_api_show_one_map_register_ttl_t *mp;
17364 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
17369 /* Wait for a reply... */
17375 * Add/del map request itr rlocs from ONE control plane and updates
17377 * @param vam vpp API test context
17378 * @return return code
17381 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
17383 unformat_input_t *input = vam->input;
17384 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
17385 u8 *locator_set_name = 0;
17386 u8 locator_set_name_set = 0;
17390 /* Parse args required to build the message */
17391 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17393 if (unformat (input, "del"))
17397 else if (unformat (input, "%_%v%_", &locator_set_name))
17399 locator_set_name_set = 1;
17403 clib_warning ("parse error '%U'", format_unformat_error, input);
17408 if (is_add && !locator_set_name_set)
17410 errmsg ("itr-rloc is not set!");
17414 if (is_add && vec_len (locator_set_name) > 64)
17416 errmsg ("itr-rloc locator-set name too long");
17417 vec_free (locator_set_name);
17421 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
17422 mp->is_add = is_add;
17425 clib_memcpy (mp->locator_set_name, locator_set_name,
17426 vec_len (locator_set_name));
17430 clib_memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
17432 vec_free (locator_set_name);
17437 /* Wait for a reply... */
17442 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
17445 api_one_locator_dump (vat_main_t * vam)
17447 unformat_input_t *input = vam->input;
17448 vl_api_one_locator_dump_t *mp;
17449 vl_api_control_ping_t *mp_ping;
17450 u8 is_index_set = 0, is_name_set = 0;
17455 /* Parse args required to build the message */
17456 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17458 if (unformat (input, "ls_name %_%v%_", &ls_name))
17462 else if (unformat (input, "ls_index %d", &ls_index))
17468 errmsg ("parse error '%U'", format_unformat_error, input);
17473 if (!is_index_set && !is_name_set)
17475 errmsg ("error: expected one of index or name!");
17479 if (is_index_set && is_name_set)
17481 errmsg ("error: only one param expected!");
17485 if (vec_len (ls_name) > 62)
17487 errmsg ("error: locator set name too long!");
17491 if (!vam->json_output)
17493 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
17496 M (ONE_LOCATOR_DUMP, mp);
17497 mp->is_index_set = is_index_set;
17500 mp->ls_index = clib_host_to_net_u32 (ls_index);
17503 vec_add1 (ls_name, 0);
17504 strncpy ((char *) mp->ls_name, (char *) ls_name,
17505 sizeof (mp->ls_name) - 1);
17511 /* Use a control ping for synchronization */
17512 MPING (CONTROL_PING, mp_ping);
17515 /* Wait for a reply... */
17520 #define api_lisp_locator_dump api_one_locator_dump
17523 api_one_locator_set_dump (vat_main_t * vam)
17525 vl_api_one_locator_set_dump_t *mp;
17526 vl_api_control_ping_t *mp_ping;
17527 unformat_input_t *input = vam->input;
17531 /* Parse args required to build the message */
17532 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17534 if (unformat (input, "local"))
17538 else if (unformat (input, "remote"))
17544 errmsg ("parse error '%U'", format_unformat_error, input);
17549 if (!vam->json_output)
17551 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
17554 M (ONE_LOCATOR_SET_DUMP, mp);
17556 mp->filter = filter;
17561 /* Use a control ping for synchronization */
17562 MPING (CONTROL_PING, mp_ping);
17565 /* Wait for a reply... */
17570 #define api_lisp_locator_set_dump api_one_locator_set_dump
17573 api_one_eid_table_map_dump (vat_main_t * vam)
17577 unformat_input_t *input = vam->input;
17578 vl_api_one_eid_table_map_dump_t *mp;
17579 vl_api_control_ping_t *mp_ping;
17582 /* Parse args required to build the message */
17583 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17585 if (unformat (input, "l2"))
17590 else if (unformat (input, "l3"))
17597 errmsg ("parse error '%U'", format_unformat_error, input);
17604 errmsg ("expected one of 'l2' or 'l3' parameter!");
17608 if (!vam->json_output)
17610 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
17613 M (ONE_EID_TABLE_MAP_DUMP, mp);
17619 /* Use a control ping for synchronization */
17620 MPING (CONTROL_PING, mp_ping);
17623 /* Wait for a reply... */
17628 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
17631 api_one_eid_table_vni_dump (vat_main_t * vam)
17633 vl_api_one_eid_table_vni_dump_t *mp;
17634 vl_api_control_ping_t *mp_ping;
17637 if (!vam->json_output)
17639 print (vam->ofp, "VNI");
17642 M (ONE_EID_TABLE_VNI_DUMP, mp);
17647 /* Use a control ping for synchronization */
17648 MPING (CONTROL_PING, mp_ping);
17651 /* Wait for a reply... */
17656 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
17659 api_one_eid_table_dump (vat_main_t * vam)
17661 unformat_input_t *i = vam->input;
17662 vl_api_one_eid_table_dump_t *mp;
17663 vl_api_control_ping_t *mp_ping;
17664 struct in_addr ip4;
17665 struct in6_addr ip6;
17667 u8 eid_type = ~0, eid_set = 0;
17668 u32 prefix_length = ~0, t, vni = 0;
17671 lisp_nsh_api_t nsh;
17673 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17675 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
17681 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
17687 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
17692 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
17697 else if (unformat (i, "vni %d", &t))
17701 else if (unformat (i, "local"))
17705 else if (unformat (i, "remote"))
17711 errmsg ("parse error '%U'", format_unformat_error, i);
17716 if (!vam->json_output)
17718 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
17719 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
17722 M (ONE_EID_TABLE_DUMP, mp);
17724 mp->filter = filter;
17728 mp->vni = htonl (vni);
17729 mp->eid_type = eid_type;
17733 mp->prefix_length = prefix_length;
17734 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
17737 mp->prefix_length = prefix_length;
17738 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
17741 clib_memcpy (mp->eid, mac, sizeof (mac));
17744 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
17747 errmsg ("unknown EID type %d!", eid_type);
17755 /* Use a control ping for synchronization */
17756 MPING (CONTROL_PING, mp_ping);
17759 /* Wait for a reply... */
17764 #define api_lisp_eid_table_dump api_one_eid_table_dump
17767 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
17769 unformat_input_t *i = vam->input;
17770 vl_api_gpe_fwd_entries_get_t *mp;
17775 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17777 if (unformat (i, "vni %d", &vni))
17783 errmsg ("parse error '%U'", format_unformat_error, i);
17790 errmsg ("vni not set!");
17794 if (!vam->json_output)
17796 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
17800 M (GPE_FWD_ENTRIES_GET, mp);
17801 mp->vni = clib_host_to_net_u32 (vni);
17806 /* Wait for a reply... */
17811 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
17812 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
17813 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
17814 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
17815 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
17816 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
17817 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
17818 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
17821 api_one_adjacencies_get (vat_main_t * vam)
17823 unformat_input_t *i = vam->input;
17824 vl_api_one_adjacencies_get_t *mp;
17829 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17831 if (unformat (i, "vni %d", &vni))
17837 errmsg ("parse error '%U'", format_unformat_error, i);
17844 errmsg ("vni not set!");
17848 if (!vam->json_output)
17850 print (vam->ofp, "%s %40s", "leid", "reid");
17853 M (ONE_ADJACENCIES_GET, mp);
17854 mp->vni = clib_host_to_net_u32 (vni);
17859 /* Wait for a reply... */
17864 #define api_lisp_adjacencies_get api_one_adjacencies_get
17867 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
17869 unformat_input_t *i = vam->input;
17870 vl_api_gpe_native_fwd_rpaths_get_t *mp;
17872 u8 ip_family_set = 0, is_ip4 = 1;
17874 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17876 if (unformat (i, "ip4"))
17881 else if (unformat (i, "ip6"))
17888 errmsg ("parse error '%U'", format_unformat_error, i);
17893 if (!ip_family_set)
17895 errmsg ("ip family not set!");
17899 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
17900 mp->is_ip4 = is_ip4;
17905 /* Wait for a reply... */
17911 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
17913 vl_api_gpe_fwd_entry_vnis_get_t *mp;
17916 if (!vam->json_output)
17918 print (vam->ofp, "VNIs");
17921 M (GPE_FWD_ENTRY_VNIS_GET, mp);
17926 /* Wait for a reply... */
17932 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
17934 unformat_input_t *i = vam->input;
17935 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
17937 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
17938 struct in_addr ip4;
17939 struct in6_addr ip6;
17940 u32 table_id = 0, nh_sw_if_index = ~0;
17942 clib_memset (&ip4, 0, sizeof (ip4));
17943 clib_memset (&ip6, 0, sizeof (ip6));
17945 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17947 if (unformat (i, "del"))
17949 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
17950 api_unformat_sw_if_index, vam, &nh_sw_if_index))
17955 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
17956 api_unformat_sw_if_index, vam, &nh_sw_if_index))
17961 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
17965 nh_sw_if_index = ~0;
17967 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
17971 nh_sw_if_index = ~0;
17973 else if (unformat (i, "table %d", &table_id))
17977 errmsg ("parse error '%U'", format_unformat_error, i);
17984 errmsg ("nh addr not set!");
17988 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
17989 mp->is_add = is_add;
17990 mp->table_id = clib_host_to_net_u32 (table_id);
17991 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
17992 mp->is_ip4 = is_ip4;
17994 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
17996 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
18001 /* Wait for a reply... */
18007 api_one_map_server_dump (vat_main_t * vam)
18009 vl_api_one_map_server_dump_t *mp;
18010 vl_api_control_ping_t *mp_ping;
18013 if (!vam->json_output)
18015 print (vam->ofp, "%=20s", "Map server");
18018 M (ONE_MAP_SERVER_DUMP, mp);
18022 /* Use a control ping for synchronization */
18023 MPING (CONTROL_PING, mp_ping);
18026 /* Wait for a reply... */
18031 #define api_lisp_map_server_dump api_one_map_server_dump
18034 api_one_map_resolver_dump (vat_main_t * vam)
18036 vl_api_one_map_resolver_dump_t *mp;
18037 vl_api_control_ping_t *mp_ping;
18040 if (!vam->json_output)
18042 print (vam->ofp, "%=20s", "Map resolver");
18045 M (ONE_MAP_RESOLVER_DUMP, mp);
18049 /* Use a control ping for synchronization */
18050 MPING (CONTROL_PING, mp_ping);
18053 /* Wait for a reply... */
18058 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
18061 api_one_stats_flush (vat_main_t * vam)
18063 vl_api_one_stats_flush_t *mp;
18066 M (ONE_STATS_FLUSH, mp);
18073 api_one_stats_dump (vat_main_t * vam)
18075 vl_api_one_stats_dump_t *mp;
18076 vl_api_control_ping_t *mp_ping;
18079 M (ONE_STATS_DUMP, mp);
18083 /* Use a control ping for synchronization */
18084 MPING (CONTROL_PING, mp_ping);
18087 /* Wait for a reply... */
18093 api_show_one_status (vat_main_t * vam)
18095 vl_api_show_one_status_t *mp;
18098 if (!vam->json_output)
18100 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
18103 M (SHOW_ONE_STATUS, mp);
18106 /* Wait for a reply... */
18111 #define api_show_lisp_status api_show_one_status
18114 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
18116 vl_api_gpe_fwd_entry_path_dump_t *mp;
18117 vl_api_control_ping_t *mp_ping;
18118 unformat_input_t *i = vam->input;
18119 u32 fwd_entry_index = ~0;
18122 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18124 if (unformat (i, "index %d", &fwd_entry_index))
18130 if (~0 == fwd_entry_index)
18132 errmsg ("no index specified!");
18136 if (!vam->json_output)
18138 print (vam->ofp, "first line");
18141 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
18145 /* Use a control ping for synchronization */
18146 MPING (CONTROL_PING, mp_ping);
18149 /* Wait for a reply... */
18155 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
18157 vl_api_one_get_map_request_itr_rlocs_t *mp;
18160 if (!vam->json_output)
18162 print (vam->ofp, "%=20s", "itr-rlocs:");
18165 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
18168 /* Wait for a reply... */
18173 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
18176 api_af_packet_create (vat_main_t * vam)
18178 unformat_input_t *i = vam->input;
18179 vl_api_af_packet_create_t *mp;
18180 u8 *host_if_name = 0;
18182 u8 random_hw_addr = 1;
18185 clib_memset (hw_addr, 0, sizeof (hw_addr));
18187 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18189 if (unformat (i, "name %s", &host_if_name))
18190 vec_add1 (host_if_name, 0);
18191 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18192 random_hw_addr = 0;
18197 if (!vec_len (host_if_name))
18199 errmsg ("host-interface name must be specified");
18203 if (vec_len (host_if_name) > 64)
18205 errmsg ("host-interface name too long");
18209 M (AF_PACKET_CREATE, mp);
18211 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18212 clib_memcpy (mp->hw_addr, hw_addr, 6);
18213 mp->use_random_hw_addr = random_hw_addr;
18214 vec_free (host_if_name);
18222 fprintf (vam->ofp ? vam->ofp : stderr,
18223 " new sw_if_index = %d\n", vam->sw_if_index);
18230 api_af_packet_delete (vat_main_t * vam)
18232 unformat_input_t *i = vam->input;
18233 vl_api_af_packet_delete_t *mp;
18234 u8 *host_if_name = 0;
18237 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18239 if (unformat (i, "name %s", &host_if_name))
18240 vec_add1 (host_if_name, 0);
18245 if (!vec_len (host_if_name))
18247 errmsg ("host-interface name must be specified");
18251 if (vec_len (host_if_name) > 64)
18253 errmsg ("host-interface name too long");
18257 M (AF_PACKET_DELETE, mp);
18259 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18260 vec_free (host_if_name);
18267 static void vl_api_af_packet_details_t_handler
18268 (vl_api_af_packet_details_t * mp)
18270 vat_main_t *vam = &vat_main;
18272 print (vam->ofp, "%-16s %d",
18273 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
18276 static void vl_api_af_packet_details_t_handler_json
18277 (vl_api_af_packet_details_t * mp)
18279 vat_main_t *vam = &vat_main;
18280 vat_json_node_t *node = NULL;
18282 if (VAT_JSON_ARRAY != vam->json_tree.type)
18284 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18285 vat_json_init_array (&vam->json_tree);
18287 node = vat_json_array_add (&vam->json_tree);
18289 vat_json_init_object (node);
18290 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
18291 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
18295 api_af_packet_dump (vat_main_t * vam)
18297 vl_api_af_packet_dump_t *mp;
18298 vl_api_control_ping_t *mp_ping;
18301 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
18302 /* Get list of tap interfaces */
18303 M (AF_PACKET_DUMP, mp);
18306 /* Use a control ping for synchronization */
18307 MPING (CONTROL_PING, mp_ping);
18315 api_policer_add_del (vat_main_t * vam)
18317 unformat_input_t *i = vam->input;
18318 vl_api_policer_add_del_t *mp;
18328 u8 color_aware = 0;
18329 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
18332 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
18333 conform_action.dscp = 0;
18334 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
18335 exceed_action.dscp = 0;
18336 violate_action.action_type = SSE2_QOS_ACTION_DROP;
18337 violate_action.dscp = 0;
18339 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18341 if (unformat (i, "del"))
18343 else if (unformat (i, "name %s", &name))
18344 vec_add1 (name, 0);
18345 else if (unformat (i, "cir %u", &cir))
18347 else if (unformat (i, "eir %u", &eir))
18349 else if (unformat (i, "cb %u", &cb))
18351 else if (unformat (i, "eb %u", &eb))
18353 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
18356 else if (unformat (i, "round_type %U", unformat_policer_round_type,
18359 else if (unformat (i, "type %U", unformat_policer_type, &type))
18361 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
18364 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
18367 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
18370 else if (unformat (i, "color-aware"))
18376 if (!vec_len (name))
18378 errmsg ("policer name must be specified");
18382 if (vec_len (name) > 64)
18384 errmsg ("policer name too long");
18388 M (POLICER_ADD_DEL, mp);
18390 clib_memcpy (mp->name, name, vec_len (name));
18392 mp->is_add = is_add;
18393 mp->cir = ntohl (cir);
18394 mp->eir = ntohl (eir);
18395 mp->cb = clib_net_to_host_u64 (cb);
18396 mp->eb = clib_net_to_host_u64 (eb);
18397 mp->rate_type = rate_type;
18398 mp->round_type = round_type;
18400 mp->conform_action_type = conform_action.action_type;
18401 mp->conform_dscp = conform_action.dscp;
18402 mp->exceed_action_type = exceed_action.action_type;
18403 mp->exceed_dscp = exceed_action.dscp;
18404 mp->violate_action_type = violate_action.action_type;
18405 mp->violate_dscp = violate_action.dscp;
18406 mp->color_aware = color_aware;
18414 api_policer_dump (vat_main_t * vam)
18416 unformat_input_t *i = vam->input;
18417 vl_api_policer_dump_t *mp;
18418 vl_api_control_ping_t *mp_ping;
18419 u8 *match_name = 0;
18420 u8 match_name_valid = 0;
18423 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18425 if (unformat (i, "name %s", &match_name))
18427 vec_add1 (match_name, 0);
18428 match_name_valid = 1;
18434 M (POLICER_DUMP, mp);
18435 mp->match_name_valid = match_name_valid;
18436 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
18437 vec_free (match_name);
18441 /* Use a control ping for synchronization */
18442 MPING (CONTROL_PING, mp_ping);
18445 /* Wait for a reply... */
18451 api_policer_classify_set_interface (vat_main_t * vam)
18453 unformat_input_t *i = vam->input;
18454 vl_api_policer_classify_set_interface_t *mp;
18456 int sw_if_index_set;
18457 u32 ip4_table_index = ~0;
18458 u32 ip6_table_index = ~0;
18459 u32 l2_table_index = ~0;
18463 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18465 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18466 sw_if_index_set = 1;
18467 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18468 sw_if_index_set = 1;
18469 else if (unformat (i, "del"))
18471 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18473 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18475 else if (unformat (i, "l2-table %d", &l2_table_index))
18479 clib_warning ("parse error '%U'", format_unformat_error, i);
18484 if (sw_if_index_set == 0)
18486 errmsg ("missing interface name or sw_if_index");
18490 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
18492 mp->sw_if_index = ntohl (sw_if_index);
18493 mp->ip4_table_index = ntohl (ip4_table_index);
18494 mp->ip6_table_index = ntohl (ip6_table_index);
18495 mp->l2_table_index = ntohl (l2_table_index);
18496 mp->is_add = is_add;
18504 api_policer_classify_dump (vat_main_t * vam)
18506 unformat_input_t *i = vam->input;
18507 vl_api_policer_classify_dump_t *mp;
18508 vl_api_control_ping_t *mp_ping;
18509 u8 type = POLICER_CLASSIFY_N_TABLES;
18512 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
18516 errmsg ("classify table type must be specified");
18520 if (!vam->json_output)
18522 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
18525 M (POLICER_CLASSIFY_DUMP, mp);
18530 /* Use a control ping for synchronization */
18531 MPING (CONTROL_PING, mp_ping);
18534 /* Wait for a reply... */
18540 api_netmap_create (vat_main_t * vam)
18542 unformat_input_t *i = vam->input;
18543 vl_api_netmap_create_t *mp;
18546 u8 random_hw_addr = 1;
18551 clib_memset (hw_addr, 0, sizeof (hw_addr));
18553 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18555 if (unformat (i, "name %s", &if_name))
18556 vec_add1 (if_name, 0);
18557 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18558 random_hw_addr = 0;
18559 else if (unformat (i, "pipe"))
18561 else if (unformat (i, "master"))
18563 else if (unformat (i, "slave"))
18569 if (!vec_len (if_name))
18571 errmsg ("interface name must be specified");
18575 if (vec_len (if_name) > 64)
18577 errmsg ("interface name too long");
18581 M (NETMAP_CREATE, mp);
18583 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18584 clib_memcpy (mp->hw_addr, hw_addr, 6);
18585 mp->use_random_hw_addr = random_hw_addr;
18586 mp->is_pipe = is_pipe;
18587 mp->is_master = is_master;
18588 vec_free (if_name);
18596 api_netmap_delete (vat_main_t * vam)
18598 unformat_input_t *i = vam->input;
18599 vl_api_netmap_delete_t *mp;
18603 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18605 if (unformat (i, "name %s", &if_name))
18606 vec_add1 (if_name, 0);
18611 if (!vec_len (if_name))
18613 errmsg ("interface name must be specified");
18617 if (vec_len (if_name) > 64)
18619 errmsg ("interface name too long");
18623 M (NETMAP_DELETE, mp);
18625 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18626 vec_free (if_name);
18634 format_fib_api_path_nh_proto (u8 * s, va_list * args)
18636 vl_api_fib_path_nh_proto_t proto =
18637 va_arg (*args, vl_api_fib_path_nh_proto_t);
18641 case FIB_API_PATH_NH_PROTO_IP4:
18642 s = format (s, "ip4");
18644 case FIB_API_PATH_NH_PROTO_IP6:
18645 s = format (s, "ip6");
18647 case FIB_API_PATH_NH_PROTO_MPLS:
18648 s = format (s, "mpls");
18650 case FIB_API_PATH_NH_PROTO_BIER:
18651 s = format (s, "bier");
18653 case FIB_API_PATH_NH_PROTO_ETHERNET:
18654 s = format (s, "ethernet");
18662 format_vl_api_ip_address_union (u8 * s, va_list * args)
18664 vl_api_address_family_t af = va_arg (*args, vl_api_address_family_t);
18665 const vl_api_address_union_t *u = va_arg (*args, vl_api_address_union_t *);
18670 s = format (s, "%U", format_ip4_address, u->ip4);
18673 s = format (s, "%U", format_ip6_address, u->ip6);
18680 format_vl_api_fib_path_type (u8 * s, va_list * args)
18682 vl_api_fib_path_type_t t = va_arg (*args, vl_api_fib_path_type_t);
18686 case FIB_API_PATH_TYPE_NORMAL:
18687 s = format (s, "normal");
18689 case FIB_API_PATH_TYPE_LOCAL:
18690 s = format (s, "local");
18692 case FIB_API_PATH_TYPE_DROP:
18693 s = format (s, "drop");
18695 case FIB_API_PATH_TYPE_UDP_ENCAP:
18696 s = format (s, "udp-encap");
18698 case FIB_API_PATH_TYPE_BIER_IMP:
18699 s = format (s, "bier-imp");
18701 case FIB_API_PATH_TYPE_ICMP_UNREACH:
18702 s = format (s, "unreach");
18704 case FIB_API_PATH_TYPE_ICMP_PROHIBIT:
18705 s = format (s, "prohibit");
18707 case FIB_API_PATH_TYPE_SOURCE_LOOKUP:
18708 s = format (s, "src-lookup");
18710 case FIB_API_PATH_TYPE_DVR:
18711 s = format (s, "dvr");
18713 case FIB_API_PATH_TYPE_INTERFACE_RX:
18714 s = format (s, "interface-rx");
18716 case FIB_API_PATH_TYPE_CLASSIFY:
18717 s = format (s, "classify");
18725 vl_api_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
18728 " weight %d, sw_if_index %d, type %U, afi %U, next_hop %U",
18729 ntohl (fp->weight), ntohl (fp->sw_if_index),
18730 format_vl_api_fib_path_type, fp->type,
18731 format_fib_api_path_nh_proto, fp->proto,
18732 format_vl_api_ip_address_union, &fp->nh.address);
18736 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
18737 vl_api_fib_path_t * fp)
18739 struct in_addr ip4;
18740 struct in6_addr ip6;
18742 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
18743 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
18744 vat_json_object_add_uint (node, "type", fp->type);
18745 vat_json_object_add_uint (node, "next_hop_proto", fp->proto);
18746 if (fp->proto == FIB_API_PATH_NH_PROTO_IP4)
18748 clib_memcpy (&ip4, &fp->nh.address.ip4, sizeof (ip4));
18749 vat_json_object_add_ip4 (node, "next_hop", ip4);
18751 else if (fp->proto == FIB_API_PATH_NH_PROTO_IP4)
18753 clib_memcpy (&ip6, &fp->nh.address.ip6, sizeof (ip6));
18754 vat_json_object_add_ip6 (node, "next_hop", ip6);
18759 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
18761 vat_main_t *vam = &vat_main;
18762 int count = ntohl (mp->mt_tunnel.mt_n_paths);
18763 vl_api_fib_path_t *fp;
18766 print (vam->ofp, "sw_if_index %d via:",
18767 ntohl (mp->mt_tunnel.mt_sw_if_index));
18768 fp = mp->mt_tunnel.mt_paths;
18769 for (i = 0; i < count; i++)
18771 vl_api_fib_path_print (vam, fp);
18775 print (vam->ofp, "");
18778 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
18779 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
18782 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
18784 vat_main_t *vam = &vat_main;
18785 vat_json_node_t *node = NULL;
18786 int count = ntohl (mp->mt_tunnel.mt_n_paths);
18787 vl_api_fib_path_t *fp;
18790 if (VAT_JSON_ARRAY != vam->json_tree.type)
18792 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18793 vat_json_init_array (&vam->json_tree);
18795 node = vat_json_array_add (&vam->json_tree);
18797 vat_json_init_object (node);
18798 vat_json_object_add_uint (node, "sw_if_index",
18799 ntohl (mp->mt_tunnel.mt_sw_if_index));
18801 vat_json_object_add_uint (node, "l2_only", mp->mt_tunnel.mt_l2_only);
18803 fp = mp->mt_tunnel.mt_paths;
18804 for (i = 0; i < count; i++)
18806 vl_api_mpls_fib_path_json_print (node, fp);
18812 api_mpls_tunnel_dump (vat_main_t * vam)
18814 vl_api_mpls_tunnel_dump_t *mp;
18815 vl_api_control_ping_t *mp_ping;
18818 M (MPLS_TUNNEL_DUMP, mp);
18822 /* Use a control ping for synchronization */
18823 MPING (CONTROL_PING, mp_ping);
18830 #define vl_api_mpls_table_details_t_endian vl_noop_handler
18831 #define vl_api_mpls_table_details_t_print vl_noop_handler
18835 vl_api_mpls_table_details_t_handler (vl_api_mpls_table_details_t * mp)
18837 vat_main_t *vam = &vat_main;
18839 print (vam->ofp, "table-id %d,", ntohl (mp->mt_table.mt_table_id));
18842 static void vl_api_mpls_table_details_t_handler_json
18843 (vl_api_mpls_table_details_t * mp)
18845 vat_main_t *vam = &vat_main;
18846 vat_json_node_t *node = NULL;
18848 if (VAT_JSON_ARRAY != vam->json_tree.type)
18850 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18851 vat_json_init_array (&vam->json_tree);
18853 node = vat_json_array_add (&vam->json_tree);
18855 vat_json_init_object (node);
18856 vat_json_object_add_uint (node, "table", ntohl (mp->mt_table.mt_table_id));
18860 api_mpls_table_dump (vat_main_t * vam)
18862 vl_api_mpls_table_dump_t *mp;
18863 vl_api_control_ping_t *mp_ping;
18866 M (MPLS_TABLE_DUMP, mp);
18869 /* Use a control ping for synchronization */
18870 MPING (CONTROL_PING, mp_ping);
18877 #define vl_api_mpls_route_details_t_endian vl_noop_handler
18878 #define vl_api_mpls_route_details_t_print vl_noop_handler
18881 vl_api_mpls_route_details_t_handler (vl_api_mpls_route_details_t * mp)
18883 vat_main_t *vam = &vat_main;
18884 int count = (int) clib_net_to_host_u32 (mp->mr_route.mr_n_paths);
18885 vl_api_fib_path_t *fp;
18889 "table-id %d, label %u, ess_bit %u",
18890 ntohl (mp->mr_route.mr_table_id),
18891 ntohl (mp->mr_route.mr_label), mp->mr_route.mr_eos);
18892 fp = mp->mr_route.mr_paths;
18893 for (i = 0; i < count; i++)
18895 vl_api_fib_path_print (vam, fp);
18900 static void vl_api_mpls_route_details_t_handler_json
18901 (vl_api_mpls_route_details_t * mp)
18903 vat_main_t *vam = &vat_main;
18904 int count = (int) clib_host_to_net_u32 (mp->mr_route.mr_n_paths);
18905 vat_json_node_t *node = NULL;
18906 vl_api_fib_path_t *fp;
18909 if (VAT_JSON_ARRAY != vam->json_tree.type)
18911 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18912 vat_json_init_array (&vam->json_tree);
18914 node = vat_json_array_add (&vam->json_tree);
18916 vat_json_init_object (node);
18917 vat_json_object_add_uint (node, "table", ntohl (mp->mr_route.mr_table_id));
18918 vat_json_object_add_uint (node, "s_bit", mp->mr_route.mr_eos);
18919 vat_json_object_add_uint (node, "label", ntohl (mp->mr_route.mr_label));
18920 vat_json_object_add_uint (node, "path_count", count);
18921 fp = mp->mr_route.mr_paths;
18922 for (i = 0; i < count; i++)
18924 vl_api_mpls_fib_path_json_print (node, fp);
18930 api_mpls_route_dump (vat_main_t * vam)
18932 unformat_input_t *input = vam->input;
18933 vl_api_mpls_route_dump_t *mp;
18934 vl_api_control_ping_t *mp_ping;
18938 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18940 if (unformat (input, "table_id %d", &table_id))
18945 if (table_id == ~0)
18947 errmsg ("missing table id");
18951 M (MPLS_ROUTE_DUMP, mp);
18953 mp->table.mt_table_id = ntohl (table_id);
18956 /* Use a control ping for synchronization */
18957 MPING (CONTROL_PING, mp_ping);
18964 #define vl_api_ip_table_details_t_endian vl_noop_handler
18965 #define vl_api_ip_table_details_t_print vl_noop_handler
18968 vl_api_ip_table_details_t_handler (vl_api_ip_table_details_t * mp)
18970 vat_main_t *vam = &vat_main;
18973 "%s; table-id %d, prefix %U/%d",
18974 mp->table.name, ntohl (mp->table.table_id));
18978 static void vl_api_ip_table_details_t_handler_json
18979 (vl_api_ip_table_details_t * mp)
18981 vat_main_t *vam = &vat_main;
18982 vat_json_node_t *node = NULL;
18984 if (VAT_JSON_ARRAY != vam->json_tree.type)
18986 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18987 vat_json_init_array (&vam->json_tree);
18989 node = vat_json_array_add (&vam->json_tree);
18991 vat_json_init_object (node);
18992 vat_json_object_add_uint (node, "table", ntohl (mp->table.table_id));
18996 api_ip_table_dump (vat_main_t * vam)
18998 vl_api_ip_table_dump_t *mp;
18999 vl_api_control_ping_t *mp_ping;
19002 M (IP_TABLE_DUMP, mp);
19005 /* Use a control ping for synchronization */
19006 MPING (CONTROL_PING, mp_ping);
19014 api_ip_mtable_dump (vat_main_t * vam)
19016 vl_api_ip_mtable_dump_t *mp;
19017 vl_api_control_ping_t *mp_ping;
19020 M (IP_MTABLE_DUMP, mp);
19023 /* Use a control ping for synchronization */
19024 MPING (CONTROL_PING, mp_ping);
19032 api_ip_mroute_dump (vat_main_t * vam)
19034 unformat_input_t *input = vam->input;
19035 vl_api_control_ping_t *mp_ping;
19036 vl_api_ip_mroute_dump_t *mp;
19041 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19043 if (unformat (input, "table_id %d", &table_id))
19045 else if (unformat (input, "ip6"))
19047 else if (unformat (input, "ip4"))
19052 if (table_id == ~0)
19054 errmsg ("missing table id");
19058 M (IP_MROUTE_DUMP, mp);
19059 mp->table.table_id = table_id;
19060 mp->table.is_ip6 = is_ip6;
19063 /* Use a control ping for synchronization */
19064 MPING (CONTROL_PING, mp_ping);
19071 static void vl_api_ip_neighbor_details_t_handler
19072 (vl_api_ip_neighbor_details_t * mp)
19074 vat_main_t *vam = &vat_main;
19076 print (vam->ofp, "%c %U %U",
19077 (ntohl (mp->neighbor.flags) & IP_NEIGHBOR_FLAG_STATIC) ? 'S' : 'D',
19078 format_vl_api_mac_address, &mp->neighbor.mac_address,
19079 format_vl_api_address, &mp->neighbor.ip_address);
19082 static void vl_api_ip_neighbor_details_t_handler_json
19083 (vl_api_ip_neighbor_details_t * mp)
19086 vat_main_t *vam = &vat_main;
19087 vat_json_node_t *node;
19089 if (VAT_JSON_ARRAY != vam->json_tree.type)
19091 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19092 vat_json_init_array (&vam->json_tree);
19094 node = vat_json_array_add (&vam->json_tree);
19096 vat_json_init_object (node);
19097 vat_json_object_add_string_copy
19099 ((ntohl (mp->neighbor.flags) & IP_NEIGHBOR_FLAG_STATIC) ?
19100 (u8 *) "static" : (u8 *) "dynamic"));
19102 vat_json_object_add_string_copy (node, "link_layer",
19103 format (0, "%U", format_vl_api_mac_address,
19104 &mp->neighbor.mac_address));
19105 vat_json_object_add_address (node, "ip", &mp->neighbor.ip_address);
19109 api_ip_neighbor_dump (vat_main_t * vam)
19111 unformat_input_t *i = vam->input;
19112 vl_api_ip_neighbor_dump_t *mp;
19113 vl_api_control_ping_t *mp_ping;
19115 u32 sw_if_index = ~0;
19118 /* Parse args required to build the message */
19119 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19121 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19123 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19125 else if (unformat (i, "ip6"))
19131 if (sw_if_index == ~0)
19133 errmsg ("missing interface name or sw_if_index");
19137 M (IP_NEIGHBOR_DUMP, mp);
19138 mp->is_ipv6 = (u8) is_ipv6;
19139 mp->sw_if_index = ntohl (sw_if_index);
19142 /* Use a control ping for synchronization */
19143 MPING (CONTROL_PING, mp_ping);
19150 #define vl_api_ip_route_details_t_endian vl_noop_handler
19151 #define vl_api_ip_route_details_t_print vl_noop_handler
19154 vl_api_ip_route_details_t_handler (vl_api_ip_route_details_t * mp)
19156 vat_main_t *vam = &vat_main;
19157 u8 count = mp->route.n_paths;
19158 vl_api_fib_path_t *fp;
19162 "table-id %d, prefix %U/%d",
19163 ntohl (mp->route.table_id),
19164 format_ip46_address, mp->route.prefix.address, mp->route.prefix.len);
19165 for (i = 0; i < count; i++)
19167 fp = &mp->route.paths[i];
19169 vl_api_fib_path_print (vam, fp);
19174 static void vl_api_ip_route_details_t_handler_json
19175 (vl_api_ip_route_details_t * mp)
19177 vat_main_t *vam = &vat_main;
19178 u8 count = mp->route.n_paths;
19179 vat_json_node_t *node = NULL;
19180 struct in_addr ip4;
19181 struct in6_addr ip6;
19182 vl_api_fib_path_t *fp;
19185 if (VAT_JSON_ARRAY != vam->json_tree.type)
19187 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19188 vat_json_init_array (&vam->json_tree);
19190 node = vat_json_array_add (&vam->json_tree);
19192 vat_json_init_object (node);
19193 vat_json_object_add_uint (node, "table", ntohl (mp->route.table_id));
19194 if (ADDRESS_IP6 == mp->route.prefix.address.af)
19196 clib_memcpy (&ip6, &mp->route.prefix.address.un.ip6, sizeof (ip6));
19197 vat_json_object_add_ip6 (node, "prefix", ip6);
19201 clib_memcpy (&ip4, &mp->route.prefix.address.un.ip4, sizeof (ip4));
19202 vat_json_object_add_ip4 (node, "prefix", ip4);
19204 vat_json_object_add_uint (node, "mask_length", mp->route.prefix.len);
19205 vat_json_object_add_uint (node, "path_count", count);
19206 for (i = 0; i < count; i++)
19208 fp = &mp->route.paths[i];
19209 vl_api_mpls_fib_path_json_print (node, fp);
19214 api_ip_route_dump (vat_main_t * vam)
19216 unformat_input_t *input = vam->input;
19217 vl_api_ip_route_dump_t *mp;
19218 vl_api_control_ping_t *mp_ping;
19224 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19226 if (unformat (input, "table_id %d", &table_id))
19228 else if (unformat (input, "ip6"))
19230 else if (unformat (input, "ip4"))
19235 if (table_id == ~0)
19237 errmsg ("missing table id");
19241 M (IP_ROUTE_DUMP, mp);
19243 mp->table.table_id = table_id;
19244 mp->table.is_ip6 = is_ip6;
19248 /* Use a control ping for synchronization */
19249 MPING (CONTROL_PING, mp_ping);
19257 api_classify_table_ids (vat_main_t * vam)
19259 vl_api_classify_table_ids_t *mp;
19262 /* Construct the API message */
19263 M (CLASSIFY_TABLE_IDS, mp);
19272 api_classify_table_by_interface (vat_main_t * vam)
19274 unformat_input_t *input = vam->input;
19275 vl_api_classify_table_by_interface_t *mp;
19277 u32 sw_if_index = ~0;
19279 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19281 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19283 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19288 if (sw_if_index == ~0)
19290 errmsg ("missing interface name or sw_if_index");
19294 /* Construct the API message */
19295 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
19297 mp->sw_if_index = ntohl (sw_if_index);
19305 api_classify_table_info (vat_main_t * vam)
19307 unformat_input_t *input = vam->input;
19308 vl_api_classify_table_info_t *mp;
19312 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19314 if (unformat (input, "table_id %d", &table_id))
19319 if (table_id == ~0)
19321 errmsg ("missing table id");
19325 /* Construct the API message */
19326 M (CLASSIFY_TABLE_INFO, mp);
19328 mp->table_id = ntohl (table_id);
19336 api_classify_session_dump (vat_main_t * vam)
19338 unformat_input_t *input = vam->input;
19339 vl_api_classify_session_dump_t *mp;
19340 vl_api_control_ping_t *mp_ping;
19344 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19346 if (unformat (input, "table_id %d", &table_id))
19351 if (table_id == ~0)
19353 errmsg ("missing table id");
19357 /* Construct the API message */
19358 M (CLASSIFY_SESSION_DUMP, mp);
19360 mp->table_id = ntohl (table_id);
19363 /* Use a control ping for synchronization */
19364 MPING (CONTROL_PING, mp_ping);
19372 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
19374 vat_main_t *vam = &vat_main;
19376 print (vam->ofp, "collector_address %U, collector_port %d, "
19377 "src_address %U, vrf_id %d, path_mtu %u, "
19378 "template_interval %u, udp_checksum %d",
19379 format_ip4_address, mp->collector_address,
19380 ntohs (mp->collector_port),
19381 format_ip4_address, mp->src_address,
19382 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
19383 ntohl (mp->template_interval), mp->udp_checksum);
19386 vam->result_ready = 1;
19390 vl_api_ipfix_exporter_details_t_handler_json
19391 (vl_api_ipfix_exporter_details_t * mp)
19393 vat_main_t *vam = &vat_main;
19394 vat_json_node_t node;
19395 struct in_addr collector_address;
19396 struct in_addr src_address;
19398 vat_json_init_object (&node);
19399 clib_memcpy (&collector_address, &mp->collector_address,
19400 sizeof (collector_address));
19401 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
19402 vat_json_object_add_uint (&node, "collector_port",
19403 ntohs (mp->collector_port));
19404 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
19405 vat_json_object_add_ip4 (&node, "src_address", src_address);
19406 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
19407 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
19408 vat_json_object_add_uint (&node, "template_interval",
19409 ntohl (mp->template_interval));
19410 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
19412 vat_json_print (vam->ofp, &node);
19413 vat_json_free (&node);
19415 vam->result_ready = 1;
19419 api_ipfix_exporter_dump (vat_main_t * vam)
19421 vl_api_ipfix_exporter_dump_t *mp;
19424 /* Construct the API message */
19425 M (IPFIX_EXPORTER_DUMP, mp);
19434 api_ipfix_classify_stream_dump (vat_main_t * vam)
19436 vl_api_ipfix_classify_stream_dump_t *mp;
19439 /* Construct the API message */
19440 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
19451 vl_api_ipfix_classify_stream_details_t_handler
19452 (vl_api_ipfix_classify_stream_details_t * mp)
19454 vat_main_t *vam = &vat_main;
19455 print (vam->ofp, "domain_id %d, src_port %d",
19456 ntohl (mp->domain_id), ntohs (mp->src_port));
19458 vam->result_ready = 1;
19462 vl_api_ipfix_classify_stream_details_t_handler_json
19463 (vl_api_ipfix_classify_stream_details_t * mp)
19465 vat_main_t *vam = &vat_main;
19466 vat_json_node_t node;
19468 vat_json_init_object (&node);
19469 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
19470 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
19472 vat_json_print (vam->ofp, &node);
19473 vat_json_free (&node);
19475 vam->result_ready = 1;
19479 api_ipfix_classify_table_dump (vat_main_t * vam)
19481 vl_api_ipfix_classify_table_dump_t *mp;
19482 vl_api_control_ping_t *mp_ping;
19485 if (!vam->json_output)
19487 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
19488 "transport_protocol");
19491 /* Construct the API message */
19492 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
19497 /* Use a control ping for synchronization */
19498 MPING (CONTROL_PING, mp_ping);
19506 vl_api_ipfix_classify_table_details_t_handler
19507 (vl_api_ipfix_classify_table_details_t * mp)
19509 vat_main_t *vam = &vat_main;
19510 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
19511 mp->transport_protocol);
19515 vl_api_ipfix_classify_table_details_t_handler_json
19516 (vl_api_ipfix_classify_table_details_t * mp)
19518 vat_json_node_t *node = NULL;
19519 vat_main_t *vam = &vat_main;
19521 if (VAT_JSON_ARRAY != vam->json_tree.type)
19523 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19524 vat_json_init_array (&vam->json_tree);
19527 node = vat_json_array_add (&vam->json_tree);
19528 vat_json_init_object (node);
19530 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
19531 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
19532 vat_json_object_add_uint (node, "transport_protocol",
19533 mp->transport_protocol);
19537 api_sw_interface_span_enable_disable (vat_main_t * vam)
19539 unformat_input_t *i = vam->input;
19540 vl_api_sw_interface_span_enable_disable_t *mp;
19541 u32 src_sw_if_index = ~0;
19542 u32 dst_sw_if_index = ~0;
19547 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19550 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
19552 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
19556 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
19558 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
19560 else if (unformat (i, "disable"))
19562 else if (unformat (i, "rx"))
19564 else if (unformat (i, "tx"))
19566 else if (unformat (i, "both"))
19568 else if (unformat (i, "l2"))
19574 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
19576 mp->sw_if_index_from = htonl (src_sw_if_index);
19577 mp->sw_if_index_to = htonl (dst_sw_if_index);
19587 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
19590 vat_main_t *vam = &vat_main;
19591 u8 *sw_if_from_name = 0;
19592 u8 *sw_if_to_name = 0;
19593 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19594 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19595 char *states[] = { "none", "rx", "tx", "both" };
19599 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19601 if ((u32) p->value[0] == sw_if_index_from)
19603 sw_if_from_name = (u8 *)(p->key);
19607 if ((u32) p->value[0] == sw_if_index_to)
19609 sw_if_to_name = (u8 *)(p->key);
19610 if (sw_if_from_name)
19615 print (vam->ofp, "%20s => %20s (%s) %s",
19616 sw_if_from_name, sw_if_to_name, states[mp->state],
19617 mp->is_l2 ? "l2" : "device");
19621 vl_api_sw_interface_span_details_t_handler_json
19622 (vl_api_sw_interface_span_details_t * mp)
19624 vat_main_t *vam = &vat_main;
19625 vat_json_node_t *node = NULL;
19626 u8 *sw_if_from_name = 0;
19627 u8 *sw_if_to_name = 0;
19628 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19629 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19633 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19635 if ((u32) p->value[0] == sw_if_index_from)
19637 sw_if_from_name = (u8 *)(p->key);
19641 if ((u32) p->value[0] == sw_if_index_to)
19643 sw_if_to_name = (u8 *)(p->key);
19644 if (sw_if_from_name)
19650 if (VAT_JSON_ARRAY != vam->json_tree.type)
19652 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19653 vat_json_init_array (&vam->json_tree);
19655 node = vat_json_array_add (&vam->json_tree);
19657 vat_json_init_object (node);
19658 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
19659 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
19660 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
19661 if (0 != sw_if_to_name)
19663 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
19665 vat_json_object_add_uint (node, "state", mp->state);
19666 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
19670 api_sw_interface_span_dump (vat_main_t * vam)
19672 unformat_input_t *input = vam->input;
19673 vl_api_sw_interface_span_dump_t *mp;
19674 vl_api_control_ping_t *mp_ping;
19678 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19680 if (unformat (input, "l2"))
19686 M (SW_INTERFACE_SPAN_DUMP, mp);
19690 /* Use a control ping for synchronization */
19691 MPING (CONTROL_PING, mp_ping);
19699 api_pg_create_interface (vat_main_t * vam)
19701 unformat_input_t *input = vam->input;
19702 vl_api_pg_create_interface_t *mp;
19704 u32 if_id = ~0, gso_size = 0;
19705 u8 gso_enabled = 0;
19707 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19709 if (unformat (input, "if_id %d", &if_id))
19711 else if (unformat (input, "gso-enabled"))
19714 if (unformat (input, "gso-size %u", &gso_size))
19718 errmsg ("missing gso-size");
19727 errmsg ("missing pg interface index");
19731 /* Construct the API message */
19732 M (PG_CREATE_INTERFACE, mp);
19734 mp->interface_id = ntohl (if_id);
19735 mp->gso_enabled = gso_enabled;
19743 api_pg_capture (vat_main_t * vam)
19745 unformat_input_t *input = vam->input;
19746 vl_api_pg_capture_t *mp;
19751 u8 pcap_file_set = 0;
19754 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19756 if (unformat (input, "if_id %d", &if_id))
19758 else if (unformat (input, "pcap %s", &pcap_file))
19760 else if (unformat (input, "count %d", &count))
19762 else if (unformat (input, "disable"))
19769 errmsg ("missing pg interface index");
19772 if (pcap_file_set > 0)
19774 if (vec_len (pcap_file) > 255)
19776 errmsg ("pcap file name is too long");
19781 u32 name_len = vec_len (pcap_file);
19782 /* Construct the API message */
19783 M (PG_CAPTURE, mp);
19785 mp->interface_id = ntohl (if_id);
19786 mp->is_enabled = enable;
19787 mp->count = ntohl (count);
19788 mp->pcap_name_length = ntohl (name_len);
19789 if (pcap_file_set != 0)
19791 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
19793 vec_free (pcap_file);
19801 api_pg_enable_disable (vat_main_t * vam)
19803 unformat_input_t *input = vam->input;
19804 vl_api_pg_enable_disable_t *mp;
19807 u8 stream_name_set = 0;
19808 u8 *stream_name = 0;
19810 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19812 if (unformat (input, "stream %s", &stream_name))
19813 stream_name_set = 1;
19814 else if (unformat (input, "disable"))
19820 if (stream_name_set > 0)
19822 if (vec_len (stream_name) > 255)
19824 errmsg ("stream name too long");
19829 u32 name_len = vec_len (stream_name);
19830 /* Construct the API message */
19831 M (PG_ENABLE_DISABLE, mp);
19833 mp->is_enabled = enable;
19834 if (stream_name_set != 0)
19836 mp->stream_name_length = ntohl (name_len);
19837 clib_memcpy (mp->stream_name, stream_name, name_len);
19839 vec_free (stream_name);
19847 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
19849 unformat_input_t *input = vam->input;
19850 vl_api_ip_source_and_port_range_check_add_del_t *mp;
19852 u16 *low_ports = 0;
19853 u16 *high_ports = 0;
19856 vl_api_prefix_t prefix;
19863 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19865 if (unformat (input, "%U", unformat_vl_api_prefix, &prefix))
19867 else if (unformat (input, "vrf %d", &vrf_id))
19869 else if (unformat (input, "del"))
19871 else if (unformat (input, "port %d", &tmp))
19873 if (tmp == 0 || tmp > 65535)
19875 errmsg ("port %d out of range", tmp);
19879 this_hi = this_low + 1;
19880 vec_add1 (low_ports, this_low);
19881 vec_add1 (high_ports, this_hi);
19883 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
19885 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
19887 errmsg ("incorrect range parameters");
19891 /* Note: in debug CLI +1 is added to high before
19892 passing to real fn that does "the work"
19893 (ip_source_and_port_range_check_add_del).
19894 This fn is a wrapper around the binary API fn a
19895 control plane will call, which expects this increment
19896 to have occurred. Hence letting the binary API control
19897 plane fn do the increment for consistency between VAT
19898 and other control planes.
19901 vec_add1 (low_ports, this_low);
19902 vec_add1 (high_ports, this_hi);
19908 if (prefix_set == 0)
19910 errmsg ("<address>/<mask> not specified");
19916 errmsg ("VRF ID required, not specified");
19923 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
19927 if (vec_len (low_ports) == 0)
19929 errmsg ("At least one port or port range required");
19933 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
19935 mp->is_add = is_add;
19937 clib_memcpy (&mp->prefix, &prefix, sizeof (prefix));
19939 mp->number_of_ranges = vec_len (low_ports);
19941 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
19942 vec_free (low_ports);
19944 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
19945 vec_free (high_ports);
19947 mp->vrf_id = ntohl (vrf_id);
19955 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
19957 unformat_input_t *input = vam->input;
19958 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
19959 u32 sw_if_index = ~0;
19961 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
19962 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
19966 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19968 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19970 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19972 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
19974 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
19976 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
19978 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
19980 else if (unformat (input, "del"))
19986 if (sw_if_index == ~0)
19988 errmsg ("Interface required but not specified");
19994 errmsg ("VRF ID required but not specified");
19998 if (tcp_out_vrf_id == 0
19999 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
20002 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
20006 /* Construct the API message */
20007 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
20009 mp->sw_if_index = ntohl (sw_if_index);
20010 mp->is_add = is_add;
20011 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
20012 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
20013 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
20014 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
20019 /* Wait for a reply... */
20025 api_set_punt (vat_main_t * vam)
20027 unformat_input_t *i = vam->input;
20028 vl_api_address_family_t af;
20029 vl_api_set_punt_t *mp;
20035 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20037 if (unformat (i, "%U", unformat_vl_api_address_family, &af))
20039 else if (unformat (i, "protocol %d", &protocol))
20041 else if (unformat (i, "port %d", &port))
20043 else if (unformat (i, "del"))
20047 clib_warning ("parse error '%U'", format_unformat_error, i);
20054 mp->is_add = (u8) is_add;
20055 mp->punt.type = PUNT_API_TYPE_L4;
20056 mp->punt.punt.l4.af = af;
20057 mp->punt.punt.l4.protocol = (u8) protocol;
20058 mp->punt.punt.l4.port = htons ((u16) port);
20066 api_delete_subif (vat_main_t * vam)
20068 unformat_input_t *i = vam->input;
20069 vl_api_delete_subif_t *mp;
20070 u32 sw_if_index = ~0;
20073 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20075 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20077 if (unformat (i, "sw_if_index %d", &sw_if_index))
20083 if (sw_if_index == ~0)
20085 errmsg ("missing sw_if_index");
20089 /* Construct the API message */
20090 M (DELETE_SUBIF, mp);
20091 mp->sw_if_index = ntohl (sw_if_index);
20098 #define foreach_pbb_vtr_op \
20099 _("disable", L2_VTR_DISABLED) \
20100 _("pop", L2_VTR_POP_2) \
20101 _("push", L2_VTR_PUSH_2)
20104 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
20106 unformat_input_t *i = vam->input;
20107 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
20108 u32 sw_if_index = ~0, vtr_op = ~0;
20109 u16 outer_tag = ~0;
20110 u8 dmac[6], smac[6];
20111 u8 dmac_set = 0, smac_set = 0;
20117 /* Shut up coverity */
20118 clib_memset (dmac, 0, sizeof (dmac));
20119 clib_memset (smac, 0, sizeof (smac));
20121 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20123 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20125 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20127 else if (unformat (i, "vtr_op %d", &vtr_op))
20129 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
20132 else if (unformat (i, "translate_pbb_stag"))
20134 if (unformat (i, "%d", &tmp))
20136 vtr_op = L2_VTR_TRANSLATE_2_1;
20142 ("translate_pbb_stag operation requires outer tag definition");
20146 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
20148 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
20150 else if (unformat (i, "sid %d", &sid))
20152 else if (unformat (i, "vlanid %d", &tmp))
20156 clib_warning ("parse error '%U'", format_unformat_error, i);
20161 if ((sw_if_index == ~0) || (vtr_op == ~0))
20163 errmsg ("missing sw_if_index or vtr operation");
20166 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
20167 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
20170 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
20174 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
20175 mp->sw_if_index = ntohl (sw_if_index);
20176 mp->vtr_op = ntohl (vtr_op);
20177 mp->outer_tag = ntohs (outer_tag);
20178 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
20179 clib_memcpy (mp->b_smac, smac, sizeof (smac));
20180 mp->b_vlanid = ntohs (vlanid);
20181 mp->i_sid = ntohl (sid);
20189 api_flow_classify_set_interface (vat_main_t * vam)
20191 unformat_input_t *i = vam->input;
20192 vl_api_flow_classify_set_interface_t *mp;
20194 int sw_if_index_set;
20195 u32 ip4_table_index = ~0;
20196 u32 ip6_table_index = ~0;
20200 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20202 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20203 sw_if_index_set = 1;
20204 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20205 sw_if_index_set = 1;
20206 else if (unformat (i, "del"))
20208 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20210 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20214 clib_warning ("parse error '%U'", format_unformat_error, i);
20219 if (sw_if_index_set == 0)
20221 errmsg ("missing interface name or sw_if_index");
20225 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
20227 mp->sw_if_index = ntohl (sw_if_index);
20228 mp->ip4_table_index = ntohl (ip4_table_index);
20229 mp->ip6_table_index = ntohl (ip6_table_index);
20230 mp->is_add = is_add;
20238 api_flow_classify_dump (vat_main_t * vam)
20240 unformat_input_t *i = vam->input;
20241 vl_api_flow_classify_dump_t *mp;
20242 vl_api_control_ping_t *mp_ping;
20243 u8 type = FLOW_CLASSIFY_N_TABLES;
20246 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
20250 errmsg ("classify table type must be specified");
20254 if (!vam->json_output)
20256 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20259 M (FLOW_CLASSIFY_DUMP, mp);
20264 /* Use a control ping for synchronization */
20265 MPING (CONTROL_PING, mp_ping);
20268 /* Wait for a reply... */
20274 api_feature_enable_disable (vat_main_t * vam)
20276 unformat_input_t *i = vam->input;
20277 vl_api_feature_enable_disable_t *mp;
20279 u8 *feature_name = 0;
20280 u32 sw_if_index = ~0;
20284 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20286 if (unformat (i, "arc_name %s", &arc_name))
20288 else if (unformat (i, "feature_name %s", &feature_name))
20291 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20293 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20295 else if (unformat (i, "disable"))
20303 errmsg ("missing arc name");
20306 if (vec_len (arc_name) > 63)
20308 errmsg ("arc name too long");
20311 if (feature_name == 0)
20313 errmsg ("missing feature name");
20316 if (vec_len (feature_name) > 63)
20318 errmsg ("feature name too long");
20321 if (sw_if_index == ~0)
20323 errmsg ("missing interface name or sw_if_index");
20327 /* Construct the API message */
20328 M (FEATURE_ENABLE_DISABLE, mp);
20329 mp->sw_if_index = ntohl (sw_if_index);
20330 mp->enable = enable;
20331 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
20332 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
20333 vec_free (arc_name);
20334 vec_free (feature_name);
20342 api_sw_interface_tag_add_del (vat_main_t * vam)
20344 unformat_input_t *i = vam->input;
20345 vl_api_sw_interface_tag_add_del_t *mp;
20346 u32 sw_if_index = ~0;
20351 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20353 if (unformat (i, "tag %s", &tag))
20355 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20357 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20359 else if (unformat (i, "del"))
20365 if (sw_if_index == ~0)
20367 errmsg ("missing interface name or sw_if_index");
20371 if (enable && (tag == 0))
20373 errmsg ("no tag specified");
20377 /* Construct the API message */
20378 M (SW_INTERFACE_TAG_ADD_DEL, mp);
20379 mp->sw_if_index = ntohl (sw_if_index);
20380 mp->is_add = enable;
20382 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
20390 static void vl_api_l2_xconnect_details_t_handler
20391 (vl_api_l2_xconnect_details_t * mp)
20393 vat_main_t *vam = &vat_main;
20395 print (vam->ofp, "%15d%15d",
20396 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
20399 static void vl_api_l2_xconnect_details_t_handler_json
20400 (vl_api_l2_xconnect_details_t * mp)
20402 vat_main_t *vam = &vat_main;
20403 vat_json_node_t *node = NULL;
20405 if (VAT_JSON_ARRAY != vam->json_tree.type)
20407 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20408 vat_json_init_array (&vam->json_tree);
20410 node = vat_json_array_add (&vam->json_tree);
20412 vat_json_init_object (node);
20413 vat_json_object_add_uint (node, "rx_sw_if_index",
20414 ntohl (mp->rx_sw_if_index));
20415 vat_json_object_add_uint (node, "tx_sw_if_index",
20416 ntohl (mp->tx_sw_if_index));
20420 api_l2_xconnect_dump (vat_main_t * vam)
20422 vl_api_l2_xconnect_dump_t *mp;
20423 vl_api_control_ping_t *mp_ping;
20426 if (!vam->json_output)
20428 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
20431 M (L2_XCONNECT_DUMP, mp);
20435 /* Use a control ping for synchronization */
20436 MPING (CONTROL_PING, mp_ping);
20444 api_hw_interface_set_mtu (vat_main_t * vam)
20446 unformat_input_t *i = vam->input;
20447 vl_api_hw_interface_set_mtu_t *mp;
20448 u32 sw_if_index = ~0;
20452 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20454 if (unformat (i, "mtu %d", &mtu))
20456 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20458 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20464 if (sw_if_index == ~0)
20466 errmsg ("missing interface name or sw_if_index");
20472 errmsg ("no mtu specified");
20476 /* Construct the API message */
20477 M (HW_INTERFACE_SET_MTU, mp);
20478 mp->sw_if_index = ntohl (sw_if_index);
20479 mp->mtu = ntohs ((u16) mtu);
20487 api_p2p_ethernet_add (vat_main_t * vam)
20489 unformat_input_t *i = vam->input;
20490 vl_api_p2p_ethernet_add_t *mp;
20491 u32 parent_if_index = ~0;
20497 clib_memset (remote_mac, 0, sizeof (remote_mac));
20498 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20500 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20502 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20506 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20508 else if (unformat (i, "sub_id %d", &sub_id))
20512 clib_warning ("parse error '%U'", format_unformat_error, i);
20517 if (parent_if_index == ~0)
20519 errmsg ("missing interface name or sw_if_index");
20524 errmsg ("missing remote mac address");
20529 errmsg ("missing sub-interface id");
20533 M (P2P_ETHERNET_ADD, mp);
20534 mp->parent_if_index = ntohl (parent_if_index);
20535 mp->subif_id = ntohl (sub_id);
20536 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20544 api_p2p_ethernet_del (vat_main_t * vam)
20546 unformat_input_t *i = vam->input;
20547 vl_api_p2p_ethernet_del_t *mp;
20548 u32 parent_if_index = ~0;
20553 clib_memset (remote_mac, 0, sizeof (remote_mac));
20554 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20556 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20558 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20562 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20566 clib_warning ("parse error '%U'", format_unformat_error, i);
20571 if (parent_if_index == ~0)
20573 errmsg ("missing interface name or sw_if_index");
20578 errmsg ("missing remote mac address");
20582 M (P2P_ETHERNET_DEL, mp);
20583 mp->parent_if_index = ntohl (parent_if_index);
20584 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20592 api_lldp_config (vat_main_t * vam)
20594 unformat_input_t *i = vam->input;
20595 vl_api_lldp_config_t *mp;
20597 int tx_interval = 0;
20598 u8 *sys_name = NULL;
20601 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20603 if (unformat (i, "system-name %s", &sys_name))
20605 else if (unformat (i, "tx-hold %d", &tx_hold))
20607 else if (unformat (i, "tx-interval %d", &tx_interval))
20611 clib_warning ("parse error '%U'", format_unformat_error, i);
20616 vec_add1 (sys_name, 0);
20618 M (LLDP_CONFIG, mp);
20619 mp->tx_hold = htonl (tx_hold);
20620 mp->tx_interval = htonl (tx_interval);
20621 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
20622 vec_free (sys_name);
20630 api_sw_interface_set_lldp (vat_main_t * vam)
20632 unformat_input_t *i = vam->input;
20633 vl_api_sw_interface_set_lldp_t *mp;
20634 u32 sw_if_index = ~0;
20636 u8 *port_desc = NULL, *mgmt_oid = NULL;
20637 ip4_address_t ip4_addr;
20638 ip6_address_t ip6_addr;
20641 clib_memset (&ip4_addr, 0, sizeof (ip4_addr));
20642 clib_memset (&ip6_addr, 0, sizeof (ip6_addr));
20644 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20646 if (unformat (i, "disable"))
20649 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20651 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20653 else if (unformat (i, "port-desc %s", &port_desc))
20655 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
20657 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
20659 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
20665 if (sw_if_index == ~0)
20667 errmsg ("missing interface name or sw_if_index");
20671 /* Construct the API message */
20672 vec_add1 (port_desc, 0);
20673 vec_add1 (mgmt_oid, 0);
20674 M (SW_INTERFACE_SET_LLDP, mp);
20675 mp->sw_if_index = ntohl (sw_if_index);
20676 mp->enable = enable;
20677 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
20678 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
20679 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
20680 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
20681 vec_free (port_desc);
20682 vec_free (mgmt_oid);
20690 api_tcp_configure_src_addresses (vat_main_t * vam)
20692 vl_api_tcp_configure_src_addresses_t *mp;
20693 unformat_input_t *i = vam->input;
20694 ip4_address_t v4first, v4last;
20695 ip6_address_t v6first, v6last;
20700 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20702 if (unformat (i, "%U - %U",
20703 unformat_ip4_address, &v4first,
20704 unformat_ip4_address, &v4last))
20708 errmsg ("one range per message (range already set)");
20713 else if (unformat (i, "%U - %U",
20714 unformat_ip6_address, &v6first,
20715 unformat_ip6_address, &v6last))
20719 errmsg ("one range per message (range already set)");
20724 else if (unformat (i, "vrf %d", &vrf_id))
20730 if (range_set == 0)
20732 errmsg ("address range not set");
20736 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
20737 mp->vrf_id = ntohl (vrf_id);
20739 if (range_set == 2)
20742 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
20743 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
20748 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
20749 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
20756 static void vl_api_app_namespace_add_del_reply_t_handler
20757 (vl_api_app_namespace_add_del_reply_t * mp)
20759 vat_main_t *vam = &vat_main;
20760 i32 retval = ntohl (mp->retval);
20761 if (vam->async_mode)
20763 vam->async_errors += (retval < 0);
20767 vam->retval = retval;
20769 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
20770 vam->result_ready = 1;
20774 static void vl_api_app_namespace_add_del_reply_t_handler_json
20775 (vl_api_app_namespace_add_del_reply_t * mp)
20777 vat_main_t *vam = &vat_main;
20778 vat_json_node_t node;
20780 vat_json_init_object (&node);
20781 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
20782 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
20784 vat_json_print (vam->ofp, &node);
20785 vat_json_free (&node);
20787 vam->retval = ntohl (mp->retval);
20788 vam->result_ready = 1;
20792 api_app_namespace_add_del (vat_main_t * vam)
20794 vl_api_app_namespace_add_del_t *mp;
20795 unformat_input_t *i = vam->input;
20796 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
20797 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
20801 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20803 if (unformat (i, "id %_%v%_", &ns_id))
20805 else if (unformat (i, "secret %lu", &secret))
20807 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20808 sw_if_index_set = 1;
20809 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
20811 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
20816 if (!ns_id || !secret_set || !sw_if_index_set)
20818 errmsg ("namespace id, secret and sw_if_index must be set");
20821 if (vec_len (ns_id) > 64)
20823 errmsg ("namespace id too long");
20826 M (APP_NAMESPACE_ADD_DEL, mp);
20828 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
20829 mp->namespace_id_len = vec_len (ns_id);
20830 mp->secret = clib_host_to_net_u64 (secret);
20831 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
20832 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
20833 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
20841 api_sock_init_shm (vat_main_t * vam)
20843 #if VPP_API_TEST_BUILTIN == 0
20844 unformat_input_t *i = vam->input;
20845 vl_api_shm_elem_config_t *config = 0;
20846 u64 size = 64 << 20;
20849 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20851 if (unformat (i, "size %U", unformat_memory_size, &size))
20858 * Canned custom ring allocator config.
20859 * Should probably parse all of this
20861 vec_validate (config, 6);
20862 config[0].type = VL_API_VLIB_RING;
20863 config[0].size = 256;
20864 config[0].count = 32;
20866 config[1].type = VL_API_VLIB_RING;
20867 config[1].size = 1024;
20868 config[1].count = 16;
20870 config[2].type = VL_API_VLIB_RING;
20871 config[2].size = 4096;
20872 config[2].count = 2;
20874 config[3].type = VL_API_CLIENT_RING;
20875 config[3].size = 256;
20876 config[3].count = 32;
20878 config[4].type = VL_API_CLIENT_RING;
20879 config[4].size = 1024;
20880 config[4].count = 16;
20882 config[5].type = VL_API_CLIENT_RING;
20883 config[5].size = 4096;
20884 config[5].count = 2;
20886 config[6].type = VL_API_QUEUE;
20887 config[6].count = 128;
20888 config[6].size = sizeof (uword);
20890 rv = vl_socket_client_init_shm (config, 1 /* want_pthread */ );
20892 vam->client_index_invalid = 1;
20900 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
20902 vat_main_t *vam = &vat_main;
20907 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
20908 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
20909 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
20910 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
20911 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
20912 clib_net_to_host_u32 (mp->action_index), mp->tag);
20917 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
20918 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
20919 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
20920 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
20921 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
20922 clib_net_to_host_u32 (mp->action_index), mp->tag);
20927 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
20930 vat_main_t *vam = &vat_main;
20931 vat_json_node_t *node = NULL;
20932 struct in6_addr ip6;
20933 struct in_addr ip4;
20935 if (VAT_JSON_ARRAY != vam->json_tree.type)
20937 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20938 vat_json_init_array (&vam->json_tree);
20940 node = vat_json_array_add (&vam->json_tree);
20941 vat_json_init_object (node);
20943 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
20944 vat_json_object_add_uint (node, "appns_index",
20945 clib_net_to_host_u32 (mp->appns_index));
20946 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
20947 vat_json_object_add_uint (node, "scope", mp->scope);
20948 vat_json_object_add_uint (node, "action_index",
20949 clib_net_to_host_u32 (mp->action_index));
20950 vat_json_object_add_uint (node, "lcl_port",
20951 clib_net_to_host_u16 (mp->lcl_port));
20952 vat_json_object_add_uint (node, "rmt_port",
20953 clib_net_to_host_u16 (mp->rmt_port));
20954 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
20955 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
20956 vat_json_object_add_string_copy (node, "tag", mp->tag);
20959 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
20960 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
20961 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
20962 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
20966 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
20967 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
20968 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
20969 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
20974 api_session_rule_add_del (vat_main_t * vam)
20976 vl_api_session_rule_add_del_t *mp;
20977 unformat_input_t *i = vam->input;
20978 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
20979 u32 appns_index = 0, scope = 0;
20980 ip4_address_t lcl_ip4, rmt_ip4;
20981 ip6_address_t lcl_ip6, rmt_ip6;
20982 u8 is_ip4 = 1, conn_set = 0;
20983 u8 is_add = 1, *tag = 0;
20986 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20988 if (unformat (i, "del"))
20990 else if (unformat (i, "add"))
20992 else if (unformat (i, "proto tcp"))
20994 else if (unformat (i, "proto udp"))
20996 else if (unformat (i, "appns %d", &appns_index))
20998 else if (unformat (i, "scope %d", &scope))
21000 else if (unformat (i, "tag %_%v%_", &tag))
21004 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
21005 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
21013 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
21014 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
21020 else if (unformat (i, "action %d", &action))
21025 if (proto == ~0 || !conn_set || action == ~0)
21027 errmsg ("transport proto, connection and action must be set");
21033 errmsg ("scope should be 0-3");
21037 M (SESSION_RULE_ADD_DEL, mp);
21039 mp->is_ip4 = is_ip4;
21040 mp->transport_proto = proto;
21041 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
21042 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
21043 mp->lcl_plen = lcl_plen;
21044 mp->rmt_plen = rmt_plen;
21045 mp->action_index = clib_host_to_net_u32 (action);
21046 mp->appns_index = clib_host_to_net_u32 (appns_index);
21048 mp->is_add = is_add;
21051 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
21052 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
21056 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
21057 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
21061 clib_memcpy (mp->tag, tag, vec_len (tag));
21071 api_session_rules_dump (vat_main_t * vam)
21073 vl_api_session_rules_dump_t *mp;
21074 vl_api_control_ping_t *mp_ping;
21077 if (!vam->json_output)
21079 print (vam->ofp, "%=20s", "Session Rules");
21082 M (SESSION_RULES_DUMP, mp);
21086 /* Use a control ping for synchronization */
21087 MPING (CONTROL_PING, mp_ping);
21090 /* Wait for a reply... */
21096 api_ip_container_proxy_add_del (vat_main_t * vam)
21098 vl_api_ip_container_proxy_add_del_t *mp;
21099 unformat_input_t *i = vam->input;
21100 u32 sw_if_index = ~0;
21101 vl_api_prefix_t pfx = { };
21105 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21107 if (unformat (i, "del"))
21109 else if (unformat (i, "add"))
21111 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
21113 else if (unformat (i, "sw_if_index %u", &sw_if_index))
21118 if (sw_if_index == ~0 || pfx.len == 0)
21120 errmsg ("address and sw_if_index must be set");
21124 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
21126 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
21127 mp->is_add = is_add;
21128 clib_memcpy (&mp->pfx, &pfx, sizeof (pfx));
21136 api_qos_record_enable_disable (vat_main_t * vam)
21138 unformat_input_t *i = vam->input;
21139 vl_api_qos_record_enable_disable_t *mp;
21140 u32 sw_if_index, qs = 0xff;
21141 u8 sw_if_index_set = 0;
21145 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21147 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21148 sw_if_index_set = 1;
21149 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21150 sw_if_index_set = 1;
21151 else if (unformat (i, "%U", unformat_qos_source, &qs))
21153 else if (unformat (i, "disable"))
21157 clib_warning ("parse error '%U'", format_unformat_error, i);
21162 if (sw_if_index_set == 0)
21164 errmsg ("missing interface name or sw_if_index");
21169 errmsg ("input location must be specified");
21173 M (QOS_RECORD_ENABLE_DISABLE, mp);
21175 mp->record.sw_if_index = ntohl (sw_if_index);
21176 mp->record.input_source = qs;
21177 mp->enable = enable;
21186 q_or_quit (vat_main_t * vam)
21188 #if VPP_API_TEST_BUILTIN == 0
21189 longjmp (vam->jump_buf, 1);
21191 return 0; /* not so much */
21195 q (vat_main_t * vam)
21197 return q_or_quit (vam);
21201 quit (vat_main_t * vam)
21203 return q_or_quit (vam);
21207 comment (vat_main_t * vam)
21213 elog_save (vat_main_t * vam)
21215 #if VPP_API_TEST_BUILTIN == 0
21216 elog_main_t *em = &vam->elog_main;
21217 unformat_input_t *i = vam->input;
21218 char *file, *chroot_file;
21219 clib_error_t *error;
21221 if (!unformat (i, "%s", &file))
21223 errmsg ("expected file name, got `%U'", format_unformat_error, i);
21227 /* It's fairly hard to get "../oopsie" through unformat; just in case */
21228 if (strstr (file, "..") || index (file, '/'))
21230 errmsg ("illegal characters in filename '%s'", file);
21234 chroot_file = (char *) format (0, "/tmp/%s%c", file, 0);
21238 errmsg ("Saving %wd of %wd events to %s",
21239 elog_n_events_in_buffer (em),
21240 elog_buffer_capacity (em), chroot_file);
21242 error = elog_write_file (em, chroot_file, 1 /* flush ring */ );
21243 vec_free (chroot_file);
21246 clib_error_report (error);
21248 errmsg ("Use the vpp event loger...");
21255 elog_setup (vat_main_t * vam)
21257 #if VPP_API_TEST_BUILTIN == 0
21258 elog_main_t *em = &vam->elog_main;
21259 unformat_input_t *i = vam->input;
21260 u32 nevents = 128 << 10;
21262 (void) unformat (i, "nevents %d", &nevents);
21264 elog_init (em, nevents);
21265 vl_api_set_elog_main (em);
21266 vl_api_set_elog_trace_api_messages (1);
21267 errmsg ("Event logger initialized with %u events", nevents);
21269 errmsg ("Use the vpp event loger...");
21275 elog_enable (vat_main_t * vam)
21277 #if VPP_API_TEST_BUILTIN == 0
21278 elog_main_t *em = &vam->elog_main;
21280 elog_enable_disable (em, 1 /* enable */ );
21281 vl_api_set_elog_trace_api_messages (1);
21282 errmsg ("Event logger enabled...");
21284 errmsg ("Use the vpp event loger...");
21290 elog_disable (vat_main_t * vam)
21292 #if VPP_API_TEST_BUILTIN == 0
21293 elog_main_t *em = &vam->elog_main;
21295 elog_enable_disable (em, 0 /* enable */ );
21296 vl_api_set_elog_trace_api_messages (1);
21297 errmsg ("Event logger disabled...");
21299 errmsg ("Use the vpp event loger...");
21305 statseg (vat_main_t * vam)
21307 ssvm_private_t *ssvmp = &vam->stat_segment;
21308 ssvm_shared_header_t *shared_header = ssvmp->sh;
21309 vlib_counter_t **counters;
21310 u64 thread0_index1_packets;
21311 u64 thread0_index1_bytes;
21312 f64 vector_rate, input_rate;
21315 uword *counter_vector_by_name;
21316 if (vam->stat_segment_lockp == 0)
21318 errmsg ("Stat segment not mapped...");
21322 /* look up "/if/rx for sw_if_index 1 as a test */
21324 clib_spinlock_lock (vam->stat_segment_lockp);
21326 counter_vector_by_name = (uword *) shared_header->opaque[1];
21328 p = hash_get_mem (counter_vector_by_name, "/if/rx");
21331 clib_spinlock_unlock (vam->stat_segment_lockp);
21332 errmsg ("/if/tx not found?");
21336 /* Fish per-thread vector of combined counters from shared memory */
21337 counters = (vlib_counter_t **) p[0];
21339 if (vec_len (counters[0]) < 2)
21341 clib_spinlock_unlock (vam->stat_segment_lockp);
21342 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
21346 /* Read thread 0 sw_if_index 1 counter */
21347 thread0_index1_packets = counters[0][1].packets;
21348 thread0_index1_bytes = counters[0][1].bytes;
21350 p = hash_get_mem (counter_vector_by_name, "vector_rate");
21353 clib_spinlock_unlock (vam->stat_segment_lockp);
21354 errmsg ("vector_rate not found?");
21358 vector_rate = *(f64 *) (p[0]);
21359 p = hash_get_mem (counter_vector_by_name, "input_rate");
21362 clib_spinlock_unlock (vam->stat_segment_lockp);
21363 errmsg ("input_rate not found?");
21366 input_rate = *(f64 *) (p[0]);
21368 clib_spinlock_unlock (vam->stat_segment_lockp);
21370 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
21371 vector_rate, input_rate);
21372 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
21373 thread0_index1_packets, thread0_index1_bytes);
21379 cmd_cmp (void *a1, void *a2)
21384 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
21388 help (vat_main_t * vam)
21393 unformat_input_t *i = vam->input;
21396 if (unformat (i, "%s", &name))
21400 vec_add1 (name, 0);
21402 hs = hash_get_mem (vam->help_by_name, name);
21404 print (vam->ofp, "usage: %s %s", name, hs[0]);
21406 print (vam->ofp, "No such msg / command '%s'", name);
21411 print (vam->ofp, "Help is available for the following:");
21414 hash_foreach_pair (p, vam->function_by_name,
21416 vec_add1 (cmds, (u8 *)(p->key));
21420 vec_sort_with_function (cmds, cmd_cmp);
21422 for (j = 0; j < vec_len (cmds); j++)
21423 print (vam->ofp, "%s", cmds[j]);
21430 set (vat_main_t * vam)
21432 u8 *name = 0, *value = 0;
21433 unformat_input_t *i = vam->input;
21435 if (unformat (i, "%s", &name))
21437 /* The input buffer is a vector, not a string. */
21438 value = vec_dup (i->buffer);
21439 vec_delete (value, i->index, 0);
21440 /* Almost certainly has a trailing newline */
21441 if (value[vec_len (value) - 1] == '\n')
21442 value[vec_len (value) - 1] = 0;
21443 /* Make sure it's a proper string, one way or the other */
21444 vec_add1 (value, 0);
21445 (void) clib_macro_set_value (&vam->macro_main,
21446 (char *) name, (char *) value);
21449 errmsg ("usage: set <name> <value>");
21457 unset (vat_main_t * vam)
21461 if (unformat (vam->input, "%s", &name))
21462 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
21463 errmsg ("unset: %s wasn't set", name);
21476 macro_sort_cmp (void *a1, void *a2)
21478 macro_sort_t *s1 = a1;
21479 macro_sort_t *s2 = a2;
21481 return strcmp ((char *) (s1->name), (char *) (s2->name));
21485 dump_macro_table (vat_main_t * vam)
21487 macro_sort_t *sort_me = 0, *sm;
21492 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
21494 vec_add2 (sort_me, sm, 1);
21495 sm->name = (u8 *)(p->key);
21496 sm->value = (u8 *) (p->value[0]);
21500 vec_sort_with_function (sort_me, macro_sort_cmp);
21502 if (vec_len (sort_me))
21503 print (vam->ofp, "%-15s%s", "Name", "Value");
21505 print (vam->ofp, "The macro table is empty...");
21507 for (i = 0; i < vec_len (sort_me); i++)
21508 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
21513 dump_node_table (vat_main_t * vam)
21516 vlib_node_t *node, *next_node;
21518 if (vec_len (vam->graph_nodes) == 0)
21520 print (vam->ofp, "Node table empty, issue get_node_graph...");
21524 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
21526 node = vam->graph_nodes[0][i];
21527 print (vam->ofp, "[%d] %s", i, node->name);
21528 for (j = 0; j < vec_len (node->next_nodes); j++)
21530 if (node->next_nodes[j] != ~0)
21532 next_node = vam->graph_nodes[0][node->next_nodes[j]];
21533 print (vam->ofp, " [%d] %s", j, next_node->name);
21541 value_sort_cmp (void *a1, void *a2)
21543 name_sort_t *n1 = a1;
21544 name_sort_t *n2 = a2;
21546 if (n1->value < n2->value)
21548 if (n1->value > n2->value)
21555 dump_msg_api_table (vat_main_t * vam)
21557 api_main_t *am = &api_main;
21558 name_sort_t *nses = 0, *ns;
21563 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
21565 vec_add2 (nses, ns, 1);
21566 ns->name = (u8 *)(hp->key);
21567 ns->value = (u32) hp->value[0];
21571 vec_sort_with_function (nses, value_sort_cmp);
21573 for (i = 0; i < vec_len (nses); i++)
21574 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
21580 get_msg_id (vat_main_t * vam)
21585 if (unformat (vam->input, "%s", &name_and_crc))
21587 message_index = vl_msg_api_get_msg_index (name_and_crc);
21588 if (message_index == ~0)
21590 print (vam->ofp, " '%s' not found", name_and_crc);
21593 print (vam->ofp, " '%s' has message index %d",
21594 name_and_crc, message_index);
21597 errmsg ("name_and_crc required...");
21602 search_node_table (vat_main_t * vam)
21604 unformat_input_t *line_input = vam->input;
21607 vlib_node_t *node, *next_node;
21610 if (vam->graph_node_index_by_name == 0)
21612 print (vam->ofp, "Node table empty, issue get_node_graph...");
21616 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21618 if (unformat (line_input, "%s", &node_to_find))
21620 vec_add1 (node_to_find, 0);
21621 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
21624 print (vam->ofp, "%s not found...", node_to_find);
21627 node = vam->graph_nodes[0][p[0]];
21628 print (vam->ofp, "[%d] %s", p[0], node->name);
21629 for (j = 0; j < vec_len (node->next_nodes); j++)
21631 if (node->next_nodes[j] != ~0)
21633 next_node = vam->graph_nodes[0][node->next_nodes[j]];
21634 print (vam->ofp, " [%d] %s", j, next_node->name);
21641 clib_warning ("parse error '%U'", format_unformat_error,
21647 vec_free (node_to_find);
21656 script (vat_main_t * vam)
21658 #if (VPP_API_TEST_BUILTIN==0)
21660 char *save_current_file;
21661 unformat_input_t save_input;
21662 jmp_buf save_jump_buf;
21663 u32 save_line_number;
21665 FILE *new_fp, *save_ifp;
21667 if (unformat (vam->input, "%s", &s))
21669 new_fp = fopen ((char *) s, "r");
21672 errmsg ("Couldn't open script file %s", s);
21679 errmsg ("Missing script name");
21683 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
21684 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
21685 save_ifp = vam->ifp;
21686 save_line_number = vam->input_line_number;
21687 save_current_file = (char *) vam->current_file;
21689 vam->input_line_number = 0;
21691 vam->current_file = s;
21694 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
21695 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
21696 vam->ifp = save_ifp;
21697 vam->input_line_number = save_line_number;
21698 vam->current_file = (u8 *) save_current_file;
21703 clib_warning ("use the exec command...");
21709 echo (vat_main_t * vam)
21711 print (vam->ofp, "%v", vam->input->buffer);
21715 /* List of API message constructors, CLI names map to api_xxx */
21716 #define foreach_vpe_api_msg \
21717 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
21718 _(sw_interface_dump,"") \
21719 _(sw_interface_set_flags, \
21720 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
21721 _(sw_interface_add_del_address, \
21722 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
21723 _(sw_interface_set_rx_mode, \
21724 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
21725 _(sw_interface_set_rx_placement, \
21726 "<intfc> | sw_if_index <id> [queue <id>] [worker <id> | main]") \
21727 _(sw_interface_rx_placement_dump, \
21728 "[<intfc> | sw_if_index <id>]") \
21729 _(sw_interface_set_table, \
21730 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
21731 _(sw_interface_set_mpls_enable, \
21732 "<intfc> | sw_if_index [disable | dis]") \
21733 _(sw_interface_set_vpath, \
21734 "<intfc> | sw_if_index <id> enable | disable") \
21735 _(sw_interface_set_vxlan_bypass, \
21736 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21737 _(sw_interface_set_geneve_bypass, \
21738 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21739 _(sw_interface_set_l2_xconnect, \
21740 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
21741 "enable | disable") \
21742 _(sw_interface_set_l2_bridge, \
21743 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
21744 "[shg <split-horizon-group>] [bvi]\n" \
21745 "enable | disable") \
21746 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
21747 _(bridge_domain_add_del, \
21748 "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") \
21749 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
21751 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
21752 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
21753 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
21755 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21757 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21759 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>] [host-mtu-size <mtu>] [gso | no-gso]") \
21761 "<vpp-if-name> | sw_if_index <id>") \
21762 _(sw_interface_tap_v2_dump, "") \
21763 _(virtio_pci_create, \
21764 "pci-addr <pci-address> [use_random_mac | hw-addr <mac-addr>] [features <hex-value>] [gso-enabled]") \
21765 _(virtio_pci_delete, \
21766 "<vpp-if-name> | sw_if_index <id>") \
21767 _(sw_interface_virtio_pci_dump, "") \
21769 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
21770 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \
21773 "<vpp-if-name> | sw_if_index <id>") \
21775 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
21776 _(bond_detach_slave, \
21777 "sw_if_index <n>") \
21778 _(sw_interface_set_bond_weight, "<intfc> | sw_if_index <nn> weight <value>") \
21779 _(sw_interface_bond_dump, "") \
21780 _(sw_interface_slave_dump, \
21781 "<vpp-if-name> | sw_if_index <id>") \
21782 _(ip_table_add_del, \
21783 "table <n> [ipv6] [add | del]\n") \
21784 _(ip_route_add_del, \
21785 "<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
21786 "[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
21787 "[weight <n>] [drop] [local] [classify <n>] [out-label <n>]\n" \
21788 "[multipath] [count <n>] [del]") \
21789 _(ip_mroute_add_del, \
21790 "<src> <grp>/<mask> [table-id <n>]\n" \
21791 "[<intfc> | sw_if_index <id>] [local] [del]") \
21792 _(mpls_table_add_del, \
21793 "table <n> [add | del]\n") \
21794 _(mpls_route_add_del, \
21795 "<label> <eos> via <addr | next-hop-table <n> | via-label <n> |\n" \
21796 "lookup-ip4-table <n> | lookup-in-ip6-table <n> |\n" \
21797 "l2-input-on <intfc> | l2-input-on sw_if_index <id>>\n" \
21798 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>] [weight <n>]\n" \
21799 "[drop] [local] [classify <n>] [out-label <n>] [multipath]\n" \
21800 "[count <n>] [del]") \
21801 _(mpls_ip_bind_unbind, \
21802 "<label> <addr/len>") \
21803 _(mpls_tunnel_add_del, \
21804 "[add | del <intfc | sw_if_index <id>>] via <addr | via-label <n>>\n" \
21805 "[<intfc> | sw_if_index <id> | next-hop-table <id>]\n" \
21806 "[l2-only] [out-label <n>]") \
21807 _(sr_mpls_policy_add, \
21808 "bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
21809 _(sr_mpls_policy_del, \
21811 _(bier_table_add_del, \
21812 "<label> <sub-domain> <set> <bsl> [del]") \
21813 _(bier_route_add_del, \
21814 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
21815 "[<intfc> | sw_if_index <id>]" \
21816 "[weight <n>] [del] [multipath]") \
21817 _(proxy_arp_add_del, \
21818 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
21819 _(proxy_arp_intfc_enable_disable, \
21820 "<intfc> | sw_if_index <id> enable | disable") \
21821 _(sw_interface_set_unnumbered, \
21822 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
21823 _(ip_neighbor_add_del, \
21824 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
21825 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
21826 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
21827 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
21828 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
21829 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
21830 "[outer_vlan_id_any][inner_vlan_id_any]") \
21831 _(reset_fib, "vrf <n> [ipv6]") \
21832 _(dhcp_proxy_config, \
21833 "svr <v46-address> src <v46-address>\n" \
21834 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
21835 _(dhcp_proxy_set_vss, \
21836 "tbl_id <n> [fib_id <n> oui <n> | vpn_ascii_id <text>] [ipv6] [del]") \
21837 _(dhcp_proxy_dump, "ip6") \
21838 _(dhcp_client_config, \
21839 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
21840 _(set_ip_flow_hash, \
21841 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
21842 _(sw_interface_ip6_enable_disable, \
21843 "<intfc> | sw_if_index <id> enable | disable") \
21844 _(ip6nd_proxy_add_del, \
21845 "<intfc> | sw_if_index <id> <ip6-address>") \
21846 _(ip6nd_proxy_dump, "") \
21847 _(sw_interface_ip6nd_ra_prefix, \
21848 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
21849 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
21850 "[nolink] [isno]") \
21851 _(sw_interface_ip6nd_ra_config, \
21852 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
21853 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
21854 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
21855 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
21856 _(l2_patch_add_del, \
21857 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
21858 "enable | disable") \
21859 _(sr_localsid_add_del, \
21860 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
21861 "fib-table <num> (end.psp) sw_if_index <num>") \
21862 _(classify_add_del_table, \
21863 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
21864 " [del] [del-chain] mask <mask-value>\n" \
21865 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
21866 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
21867 _(classify_add_del_session, \
21868 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
21869 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
21870 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
21871 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
21872 _(classify_set_interface_ip_table, \
21873 "<intfc> | sw_if_index <nn> table <nn>") \
21874 _(classify_set_interface_l2_tables, \
21875 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21876 " [other-table <nn>]") \
21877 _(get_node_index, "node <node-name") \
21878 _(add_node_next, "node <node-name> next <next-node-name>") \
21879 _(l2tpv3_create_tunnel, \
21880 "client_address <ip6-addr> our_address <ip6-addr>\n" \
21881 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
21882 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
21883 _(l2tpv3_set_tunnel_cookies, \
21884 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
21885 "[new_remote_cookie <nn>]\n") \
21886 _(l2tpv3_interface_enable_disable, \
21887 "<intfc> | sw_if_index <nn> enable | disable") \
21888 _(l2tpv3_set_lookup_key, \
21889 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
21890 _(sw_if_l2tpv3_tunnel_dump, "") \
21891 _(vxlan_offload_rx, \
21892 "hw { <interface name> | hw_if_index <nn>} " \
21893 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
21894 _(vxlan_add_del_tunnel, \
21895 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
21896 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
21897 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
21898 _(geneve_add_del_tunnel, \
21899 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
21900 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21901 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
21902 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21903 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21904 _(gre_tunnel_add_del, \
21905 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
21906 "[teb | erspan <session-id>] [del]") \
21907 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21908 _(l2_fib_clear_table, "") \
21909 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
21910 _(l2_interface_vlan_tag_rewrite, \
21911 "<intfc> | sw_if_index <nn> \n" \
21912 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
21913 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
21914 _(create_vhost_user_if, \
21915 "socket <filename> [server] [renumber <dev_instance>] " \
21916 "[disable_mrg_rxbuf] [disable_indirect_desc] [gso] " \
21917 "[mac <mac_address>]") \
21918 _(modify_vhost_user_if, \
21919 "<intfc> | sw_if_index <nn> socket <filename>\n" \
21920 "[server] [renumber <dev_instance>] [gso]") \
21921 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
21922 _(sw_interface_vhost_user_dump, "") \
21923 _(show_version, "") \
21924 _(show_threads, "") \
21925 _(vxlan_gpe_add_del_tunnel, \
21926 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
21927 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21928 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
21929 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
21930 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21931 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
21932 _(interface_name_renumber, \
21933 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
21934 _(input_acl_set_interface, \
21935 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21936 " [l2-table <nn>] [del]") \
21937 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
21938 _(ip_scan_neighbor_enable_disable, "[ip4|ip6|both|disable] [interval <n-min>]\n" \
21939 " [max-time <n-usec>] [max-update <n>] [delay <n-msec>] [stale <n-min>]") \
21940 _(want_ip4_arp_events, "address <ip4-address> [del]") \
21941 _(want_ip6_nd_events, "address <ip6-address> [del]") \
21942 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
21943 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
21944 _(ip_dump, "ipv4 | ipv6") \
21945 _(ipsec_spd_add_del, "spd_id <n> [del]") \
21946 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
21948 _(ipsec_sad_entry_add_del, "sad_id <n> spi <n> crypto_alg <alg>\n" \
21949 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
21950 " integ_alg <alg> integ_key <hex>") \
21951 _(ipsec_spd_entry_add_del, "spd_id <n> priority <n> action <action>\n" \
21952 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
21953 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
21954 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
21955 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
21956 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
21957 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
21958 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
21959 " [instance <n>]") \
21960 _(ipsec_sa_dump, "[sa_id <n>]") \
21961 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
21962 _(delete_loopback,"sw_if_index <nn>") \
21963 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
21964 _(bd_ip_mac_flush, "bd_id <bridge-domain-id>") \
21965 _(bd_ip_mac_dump, "[bd_id] <bridge-domain-id>") \
21966 _(want_interface_events, "enable|disable") \
21967 _(get_first_msg_id, "client <name>") \
21968 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
21969 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
21970 "fib-id <nn> [ip4][ip6][default]") \
21971 _(get_node_graph, " ") \
21972 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
21973 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
21974 _(ioam_disable, "") \
21975 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
21976 " sw_if_index <sw_if_index> p <priority> " \
21977 "w <weight>] [del]") \
21978 _(one_add_del_locator, "locator-set <locator_name> " \
21979 "iface <intf> | sw_if_index <sw_if_index> " \
21980 "p <priority> w <weight> [del]") \
21981 _(one_add_del_local_eid,"vni <vni> eid " \
21982 "<ipv4|ipv6>/<prefix> | <L2 address> " \
21983 "locator-set <locator_name> [del]" \
21984 "[key-id sha1|sha256 secret-key <secret-key>]")\
21985 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
21986 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
21987 _(one_enable_disable, "enable|disable") \
21988 _(one_map_register_enable_disable, "enable|disable") \
21989 _(one_map_register_fallback_threshold, "<value>") \
21990 _(one_rloc_probe_enable_disable, "enable|disable") \
21991 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
21993 "rloc <locator> p <prio> " \
21994 "w <weight> [rloc <loc> ... ] " \
21995 "action <action> [del-all]") \
21996 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
21998 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
21999 _(one_use_petr, "ip-address> | disable") \
22000 _(one_map_request_mode, "src-dst|dst-only") \
22001 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
22002 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
22003 _(one_locator_set_dump, "[local | remote]") \
22004 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
22005 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
22006 "[local] | [remote]") \
22007 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
22008 _(one_ndp_bd_get, "") \
22009 _(one_ndp_entries_get, "bd <bridge-domain>") \
22010 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
22011 _(one_l2_arp_bd_get, "") \
22012 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
22013 _(one_stats_enable_disable, "enable|disable") \
22014 _(show_one_stats_enable_disable, "") \
22015 _(one_eid_table_vni_dump, "") \
22016 _(one_eid_table_map_dump, "l2|l3") \
22017 _(one_map_resolver_dump, "") \
22018 _(one_map_server_dump, "") \
22019 _(one_adjacencies_get, "vni <vni>") \
22020 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
22021 _(show_one_rloc_probe_state, "") \
22022 _(show_one_map_register_state, "") \
22023 _(show_one_status, "") \
22024 _(one_stats_dump, "") \
22025 _(one_stats_flush, "") \
22026 _(one_get_map_request_itr_rlocs, "") \
22027 _(one_map_register_set_ttl, "<ttl>") \
22028 _(one_set_transport_protocol, "udp|api") \
22029 _(one_get_transport_protocol, "") \
22030 _(one_enable_disable_xtr_mode, "enable|disable") \
22031 _(one_show_xtr_mode, "") \
22032 _(one_enable_disable_pitr_mode, "enable|disable") \
22033 _(one_show_pitr_mode, "") \
22034 _(one_enable_disable_petr_mode, "enable|disable") \
22035 _(one_show_petr_mode, "") \
22036 _(show_one_nsh_mapping, "") \
22037 _(show_one_pitr, "") \
22038 _(show_one_use_petr, "") \
22039 _(show_one_map_request_mode, "") \
22040 _(show_one_map_register_ttl, "") \
22041 _(show_one_map_register_fallback_threshold, "") \
22042 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
22043 " sw_if_index <sw_if_index> p <priority> " \
22044 "w <weight>] [del]") \
22045 _(lisp_add_del_locator, "locator-set <locator_name> " \
22046 "iface <intf> | sw_if_index <sw_if_index> " \
22047 "p <priority> w <weight> [del]") \
22048 _(lisp_add_del_local_eid,"vni <vni> eid " \
22049 "<ipv4|ipv6>/<prefix> | <L2 address> " \
22050 "locator-set <locator_name> [del]" \
22051 "[key-id sha1|sha256 secret-key <secret-key>]") \
22052 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
22053 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
22054 _(lisp_enable_disable, "enable|disable") \
22055 _(lisp_map_register_enable_disable, "enable|disable") \
22056 _(lisp_rloc_probe_enable_disable, "enable|disable") \
22057 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
22059 "rloc <locator> p <prio> " \
22060 "w <weight> [rloc <loc> ... ] " \
22061 "action <action> [del-all]") \
22062 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
22064 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
22065 _(lisp_use_petr, "<ip-address> | disable") \
22066 _(lisp_map_request_mode, "src-dst|dst-only") \
22067 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
22068 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
22069 _(lisp_locator_set_dump, "[local | remote]") \
22070 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
22071 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
22072 "[local] | [remote]") \
22073 _(lisp_eid_table_vni_dump, "") \
22074 _(lisp_eid_table_map_dump, "l2|l3") \
22075 _(lisp_map_resolver_dump, "") \
22076 _(lisp_map_server_dump, "") \
22077 _(lisp_adjacencies_get, "vni <vni>") \
22078 _(gpe_fwd_entry_vnis_get, "") \
22079 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
22080 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
22081 "[table <table-id>]") \
22082 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
22083 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
22084 _(gpe_set_encap_mode, "lisp|vxlan") \
22085 _(gpe_get_encap_mode, "") \
22086 _(lisp_gpe_add_del_iface, "up|down") \
22087 _(lisp_gpe_enable_disable, "enable|disable") \
22088 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
22089 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
22090 _(show_lisp_rloc_probe_state, "") \
22091 _(show_lisp_map_register_state, "") \
22092 _(show_lisp_status, "") \
22093 _(lisp_get_map_request_itr_rlocs, "") \
22094 _(show_lisp_pitr, "") \
22095 _(show_lisp_use_petr, "") \
22096 _(show_lisp_map_request_mode, "") \
22097 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
22098 _(af_packet_delete, "name <host interface name>") \
22099 _(af_packet_dump, "") \
22100 _(policer_add_del, "name <policer name> <params> [del]") \
22101 _(policer_dump, "[name <policer name>]") \
22102 _(policer_classify_set_interface, \
22103 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22104 " [l2-table <nn>] [del]") \
22105 _(policer_classify_dump, "type [ip4|ip6|l2]") \
22106 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
22107 "[master|slave]") \
22108 _(netmap_delete, "name <interface name>") \
22109 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
22110 _(mpls_table_dump, "") \
22111 _(mpls_route_dump, "table-id <ID>") \
22112 _(classify_table_ids, "") \
22113 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
22114 _(classify_table_info, "table_id <nn>") \
22115 _(classify_session_dump, "table_id <nn>") \
22116 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
22117 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
22118 "[template_interval <nn>] [udp_checksum]") \
22119 _(ipfix_exporter_dump, "") \
22120 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
22121 _(ipfix_classify_stream_dump, "") \
22122 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
22123 _(ipfix_classify_table_dump, "") \
22124 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
22125 _(sw_interface_span_dump, "[l2]") \
22126 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
22127 _(pg_create_interface, "if_id <nn> [gso-enabled gso-size <size>]") \
22128 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
22129 _(pg_enable_disable, "[stream <id>] disable") \
22130 _(ip_source_and_port_range_check_add_del, \
22131 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
22132 _(ip_source_and_port_range_check_interface_add_del, \
22133 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
22134 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
22135 _(delete_subif,"<intfc> | sw_if_index <nn>") \
22136 _(l2_interface_pbb_tag_rewrite, \
22137 "<intfc> | sw_if_index <nn> \n" \
22138 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
22139 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
22140 _(set_punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
22141 _(flow_classify_set_interface, \
22142 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
22143 _(flow_classify_dump, "type [ip4|ip6]") \
22144 _(ip_table_dump, "") \
22145 _(ip_route_dump, "table-id [ip4|ip6]") \
22146 _(ip_mtable_dump, "") \
22147 _(ip_mroute_dump, "table-id [ip4|ip6]") \
22148 _(feature_enable_disable, "arc_name <arc_name> " \
22149 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
22150 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
22152 _(l2_xconnect_dump, "") \
22153 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
22154 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
22155 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
22156 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
22157 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
22158 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
22159 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
22160 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
22161 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
22162 _(sock_init_shm, "size <nnn>") \
22163 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
22164 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
22165 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
22166 _(session_rules_dump, "") \
22167 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
22168 _(output_acl_set_interface, \
22169 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22170 " [l2-table <nn>] [del]") \
22171 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
22173 /* List of command functions, CLI names map directly to functions */
22174 #define foreach_cli_function \
22175 _(comment, "usage: comment <ignore-rest-of-line>") \
22176 _(dump_interface_table, "usage: dump_interface_table") \
22177 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
22178 _(dump_ipv4_table, "usage: dump_ipv4_table") \
22179 _(dump_ipv6_table, "usage: dump_ipv6_table") \
22180 _(dump_macro_table, "usage: dump_macro_table ") \
22181 _(dump_node_table, "usage: dump_node_table") \
22182 _(dump_msg_api_table, "usage: dump_msg_api_table") \
22183 _(elog_setup, "usage: elog_setup [nevents, default 128K]") \
22184 _(elog_disable, "usage: elog_disable") \
22185 _(elog_enable, "usage: elog_enable") \
22186 _(elog_save, "usage: elog_save <filename>") \
22187 _(get_msg_id, "usage: get_msg_id name_and_crc") \
22188 _(echo, "usage: echo <message>") \
22189 _(exec, "usage: exec <vpe-debug-CLI-command>") \
22190 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
22191 _(help, "usage: help") \
22192 _(q, "usage: quit") \
22193 _(quit, "usage: quit") \
22194 _(search_node_table, "usage: search_node_table <name>...") \
22195 _(set, "usage: set <variable-name> <value>") \
22196 _(script, "usage: script <file-name>") \
22197 _(statseg, "usage: statseg") \
22198 _(unset, "usage: unset <variable-name>")
22201 static void vl_api_##n##_t_handler_uni \
22202 (vl_api_##n##_t * mp) \
22204 vat_main_t * vam = &vat_main; \
22205 if (vam->json_output) { \
22206 vl_api_##n##_t_handler_json(mp); \
22208 vl_api_##n##_t_handler(mp); \
22211 foreach_vpe_api_reply_msg;
22212 #if VPP_API_TEST_BUILTIN == 0
22213 foreach_standalone_reply_msg;
22218 vat_api_hookup (vat_main_t * vam)
22221 vl_msg_api_set_handlers(VL_API_##N, #n, \
22222 vl_api_##n##_t_handler_uni, \
22224 vl_api_##n##_t_endian, \
22225 vl_api_##n##_t_print, \
22226 sizeof(vl_api_##n##_t), 1);
22227 foreach_vpe_api_reply_msg;
22228 #if VPP_API_TEST_BUILTIN == 0
22229 foreach_standalone_reply_msg;
22233 #if (VPP_API_TEST_BUILTIN==0)
22234 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
22236 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
22238 vam->function_by_name = hash_create_string (0, sizeof (uword));
22240 vam->help_by_name = hash_create_string (0, sizeof (uword));
22243 /* API messages we can send */
22244 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
22245 foreach_vpe_api_msg;
22249 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
22250 foreach_vpe_api_msg;
22253 /* CLI functions */
22254 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
22255 foreach_cli_function;
22259 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
22260 foreach_cli_function;
22264 #if VPP_API_TEST_BUILTIN
22265 static clib_error_t *
22266 vat_api_hookup_shim (vlib_main_t * vm)
22268 vat_api_hookup (&vat_main);
22272 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
22276 * fd.io coding-style-patch-verification: ON
22279 * eval: (c-set-style "gnu")