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 void vl_api_set_elog_main (elog_main_t * m);
90 int vl_api_set_elog_trace_api_messages (int enable);
92 #if VPP_API_TEST_BUILTIN == 0
102 vat_socket_connect (vat_main_t * vam)
105 vam->socket_client_main = &socket_client_main;
106 if ((rv = vl_socket_client_connect ((char *) vam->socket_name,
108 0 /* default socket rx, tx buffer */ )))
110 /* vpp expects the client index in network order */
111 vam->my_client_index = htonl (socket_client_main.client_index);
114 #else /* vpp built-in case, we don't do sockets... */
116 vat_socket_connect (vat_main_t * vam)
122 vl_socket_client_read (int wait)
128 vl_socket_client_write ()
134 vl_socket_client_msg_alloc (int nbytes)
142 vat_time_now (vat_main_t * vam)
144 #if VPP_API_TEST_BUILTIN
145 return vlib_time_now (vam->vlib_main);
147 return clib_time_now (&vam->clib_time);
152 errmsg (char *fmt, ...)
154 vat_main_t *vam = &vat_main;
159 s = va_format (0, fmt, &va);
164 #if VPP_API_TEST_BUILTIN
165 vlib_cli_output (vam->vlib_main, (char *) s);
168 if (vam->ifp != stdin)
169 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
170 vam->input_line_number);
172 fformat (vam->ofp, "%s\n", (char *) s);
180 #if VPP_API_TEST_BUILTIN == 0
182 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
184 vat_main_t *vam = va_arg (*args, vat_main_t *);
185 u32 *result = va_arg (*args, u32 *);
189 if (!unformat (input, "%s", &if_name))
192 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
200 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
205 /* Parse an IP4 address %d.%d.%d.%d. */
207 unformat_ip4_address (unformat_input_t * input, va_list * args)
209 u8 *result = va_arg (*args, u8 *);
212 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
215 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
227 unformat_ethernet_address (unformat_input_t * input, va_list * args)
229 u8 *result = va_arg (*args, u8 *);
232 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
233 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
237 for (i = 0; i < 6; i++)
238 if (a[i] >= (1 << 8))
241 for (i = 0; i < 6; i++)
247 /* Returns ethernet type as an int in host byte order. */
249 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
252 u16 *result = va_arg (*args, u16 *);
256 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
258 if (type >= (1 << 16))
266 /* Parse an IP6 address. */
268 unformat_ip6_address (unformat_input_t * input, va_list * args)
270 ip6_address_t *result = va_arg (*args, ip6_address_t *);
272 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
273 uword c, n_colon, double_colon_index;
275 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
276 double_colon_index = ARRAY_LEN (hex_quads);
277 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
280 if (c >= '0' && c <= '9')
282 else if (c >= 'a' && c <= 'f')
283 hex_digit = c + 10 - 'a';
284 else if (c >= 'A' && c <= 'F')
285 hex_digit = c + 10 - 'A';
286 else if (c == ':' && n_colon < 2)
290 unformat_put_input (input);
294 /* Too many hex quads. */
295 if (n_hex_quads >= ARRAY_LEN (hex_quads))
300 hex_quad = (hex_quad << 4) | hex_digit;
302 /* Hex quad must fit in 16 bits. */
303 if (n_hex_digits >= 4)
310 /* Save position of :: */
313 /* More than one :: ? */
314 if (double_colon_index < ARRAY_LEN (hex_quads))
316 double_colon_index = n_hex_quads;
319 if (n_colon > 0 && n_hex_digits > 0)
321 hex_quads[n_hex_quads++] = hex_quad;
327 if (n_hex_digits > 0)
328 hex_quads[n_hex_quads++] = hex_quad;
333 /* Expand :: to appropriate number of zero hex quads. */
334 if (double_colon_index < ARRAY_LEN (hex_quads))
336 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
338 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
339 hex_quads[n_zero + i] = hex_quads[i];
341 for (i = 0; i < n_zero; i++)
342 hex_quads[double_colon_index + i] = 0;
344 n_hex_quads = ARRAY_LEN (hex_quads);
347 /* Too few hex quads given. */
348 if (n_hex_quads < ARRAY_LEN (hex_quads))
351 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
352 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
359 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
361 u32 *r = va_arg (*args, u32 *);
364 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
365 foreach_ipsec_policy_action
373 format_ipsec_crypto_alg (u8 * s, va_list * args)
375 u32 i = va_arg (*args, u32);
380 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
381 foreach_ipsec_crypto_alg
384 return format (s, "unknown");
386 return format (s, "%s", t);
390 format_ipsec_integ_alg (u8 * s, va_list * args)
392 u32 i = va_arg (*args, u32);
397 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
398 foreach_ipsec_integ_alg
401 return format (s, "unknown");
403 return format (s, "%s", t);
406 #else /* VPP_API_TEST_BUILTIN == 1 */
408 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
410 vat_main_t *vam __clib_unused = va_arg (*args, vat_main_t *);
411 vnet_main_t *vnm = vnet_get_main ();
412 u32 *result = va_arg (*args, u32 *);
414 return unformat (input, "%U", unformat_vnet_sw_interface, vnm, result);
418 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
420 vat_main_t *vam __clib_unused = va_arg (*args, vat_main_t *);
421 vnet_main_t *vnm = vnet_get_main ();
422 u32 *result = va_arg (*args, u32 *);
424 return unformat (input, "%U", unformat_vnet_hw_interface, vnm, result);
427 #endif /* VPP_API_TEST_BUILTIN */
430 unformat_ipsec_api_crypto_alg (unformat_input_t * input, va_list * args)
432 u32 *r = va_arg (*args, u32 *);
435 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_API_CRYPTO_ALG_##f;
436 foreach_ipsec_crypto_alg
444 unformat_ipsec_api_integ_alg (unformat_input_t * input, va_list * args)
446 u32 *r = va_arg (*args, u32 *);
449 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_API_INTEG_ALG_##f;
450 foreach_ipsec_integ_alg
458 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
460 u8 *r = va_arg (*args, u8 *);
462 if (unformat (input, "kbps"))
463 *r = SSE2_QOS_RATE_KBPS;
464 else if (unformat (input, "pps"))
465 *r = SSE2_QOS_RATE_PPS;
472 unformat_policer_round_type (unformat_input_t * input, va_list * args)
474 u8 *r = va_arg (*args, u8 *);
476 if (unformat (input, "closest"))
477 *r = SSE2_QOS_ROUND_TO_CLOSEST;
478 else if (unformat (input, "up"))
479 *r = SSE2_QOS_ROUND_TO_UP;
480 else if (unformat (input, "down"))
481 *r = SSE2_QOS_ROUND_TO_DOWN;
488 unformat_policer_type (unformat_input_t * input, va_list * args)
490 u8 *r = va_arg (*args, u8 *);
492 if (unformat (input, "1r2c"))
493 *r = SSE2_QOS_POLICER_TYPE_1R2C;
494 else if (unformat (input, "1r3c"))
495 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
496 else if (unformat (input, "2r3c-2698"))
497 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
498 else if (unformat (input, "2r3c-4115"))
499 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
500 else if (unformat (input, "2r3c-mef5cf1"))
501 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
508 unformat_dscp (unformat_input_t * input, va_list * va)
510 u8 *r = va_arg (*va, u8 *);
513 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
522 unformat_policer_action_type (unformat_input_t * input, va_list * va)
524 sse2_qos_pol_action_params_st *a
525 = va_arg (*va, sse2_qos_pol_action_params_st *);
527 if (unformat (input, "drop"))
528 a->action_type = SSE2_QOS_ACTION_DROP;
529 else if (unformat (input, "transmit"))
530 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
531 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
532 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
539 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
541 u32 *r = va_arg (*va, u32 *);
544 if (unformat (input, "ip4"))
545 tid = POLICER_CLASSIFY_TABLE_IP4;
546 else if (unformat (input, "ip6"))
547 tid = POLICER_CLASSIFY_TABLE_IP6;
548 else if (unformat (input, "l2"))
549 tid = POLICER_CLASSIFY_TABLE_L2;
558 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
560 u32 *r = va_arg (*va, u32 *);
563 if (unformat (input, "ip4"))
564 tid = FLOW_CLASSIFY_TABLE_IP4;
565 else if (unformat (input, "ip6"))
566 tid = FLOW_CLASSIFY_TABLE_IP6;
574 #if (VPP_API_TEST_BUILTIN==0)
576 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
577 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
578 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
579 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
582 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
584 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
585 mfib_itf_attribute_t attr;
588 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
590 if (unformat (input, mfib_itf_flag_long_names[attr]))
591 *iflags |= (1 << attr);
593 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
595 if (unformat (input, mfib_itf_flag_names[attr]))
596 *iflags |= (1 << attr);
599 return (old == *iflags ? 0 : 1);
603 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
605 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
606 mfib_entry_attribute_t attr;
609 FOR_EACH_MFIB_ATTRIBUTE (attr)
611 if (unformat (input, mfib_flag_long_names[attr]))
612 *eflags |= (1 << attr);
614 FOR_EACH_MFIB_ATTRIBUTE (attr)
616 if (unformat (input, mfib_flag_names[attr]))
617 *eflags |= (1 << attr);
620 return (old == *eflags ? 0 : 1);
624 format_ip4_address (u8 * s, va_list * args)
626 u8 *a = va_arg (*args, u8 *);
627 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
631 format_ip6_address (u8 * s, va_list * args)
633 ip6_address_t *a = va_arg (*args, ip6_address_t *);
634 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
636 i_max_n_zero = ARRAY_LEN (a->as_u16);
638 i_first_zero = i_max_n_zero;
640 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
642 u32 is_zero = a->as_u16[i] == 0;
643 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
649 if ((!is_zero && n_zeros > max_n_zeros)
650 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
652 i_max_n_zero = i_first_zero;
653 max_n_zeros = n_zeros;
654 i_first_zero = ARRAY_LEN (a->as_u16);
659 last_double_colon = 0;
660 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
662 if (i == i_max_n_zero && max_n_zeros > 1)
664 s = format (s, "::");
665 i += max_n_zeros - 1;
666 last_double_colon = 1;
670 s = format (s, "%s%x",
671 (last_double_colon || i == 0) ? "" : ":",
672 clib_net_to_host_u16 (a->as_u16[i]));
673 last_double_colon = 0;
680 /* Format an IP46 address. */
682 format_ip46_address (u8 * s, va_list * args)
684 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
685 ip46_type_t type = va_arg (*args, ip46_type_t);
691 is_ip4 = ip46_address_is_ip4 (ip46);
702 format (s, "%U", format_ip4_address, &ip46->ip4) :
703 format (s, "%U", format_ip6_address, &ip46->ip6);
707 format_ethernet_address (u8 * s, va_list * args)
709 u8 *a = va_arg (*args, u8 *);
711 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
712 a[0], a[1], a[2], a[3], a[4], a[5]);
717 increment_v4_address (vl_api_ip4_address_t * i)
719 ip4_address_t *a = (ip4_address_t *) i;
722 v = ntohl (a->as_u32) + 1;
723 a->as_u32 = ntohl (v);
727 increment_v6_address (vl_api_ip6_address_t * i)
729 ip6_address_t *a = (ip6_address_t *) i;
732 v0 = clib_net_to_host_u64 (a->as_u64[0]);
733 v1 = clib_net_to_host_u64 (a->as_u64[1]);
738 a->as_u64[0] = clib_net_to_host_u64 (v0);
739 a->as_u64[1] = clib_net_to_host_u64 (v1);
743 increment_address (vl_api_address_t * a)
745 if (clib_net_to_host_u32 (a->af) == ADDRESS_IP4)
746 increment_v4_address (&a->un.ip4);
747 else if (clib_net_to_host_u32 (a->af) == ADDRESS_IP6)
748 increment_v6_address (&a->un.ip6);
752 set_ip4_address (vl_api_address_t * a, u32 v)
754 if (a->af == ADDRESS_IP4)
756 ip4_address_t *i = (ip4_address_t *) & a->un.ip4;
762 increment_mac_address (u8 * mac)
764 u64 tmp = *((u64 *) mac);
765 tmp = clib_net_to_host_u64 (tmp);
766 tmp += 1 << 16; /* skip unused (least significant) octets */
767 tmp = clib_host_to_net_u64 (tmp);
769 clib_memcpy (mac, &tmp, 6);
773 vat_json_object_add_address (vat_json_node_t * node,
774 const char *str, const vl_api_address_t * addr)
776 if (ADDRESS_IP6 == addr->af)
780 clib_memcpy (&ip6, &addr->un.ip6, sizeof (ip6));
781 vat_json_object_add_ip6 (node, str, ip6);
787 clib_memcpy (&ip4, &addr->un.ip4, sizeof (ip4));
788 vat_json_object_add_ip4 (node, str, ip4);
793 vat_json_object_add_prefix (vat_json_node_t * node,
794 const vl_api_prefix_t * prefix)
796 vat_json_object_add_uint (node, "len", prefix->len);
797 vat_json_object_add_address (node, "address", &prefix->address);
800 static void vl_api_create_loopback_reply_t_handler
801 (vl_api_create_loopback_reply_t * mp)
803 vat_main_t *vam = &vat_main;
804 i32 retval = ntohl (mp->retval);
806 vam->retval = retval;
807 vam->regenerate_interface_table = 1;
808 vam->sw_if_index = ntohl (mp->sw_if_index);
809 vam->result_ready = 1;
812 static void vl_api_create_loopback_reply_t_handler_json
813 (vl_api_create_loopback_reply_t * mp)
815 vat_main_t *vam = &vat_main;
816 vat_json_node_t node;
818 vat_json_init_object (&node);
819 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
820 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
822 vat_json_print (vam->ofp, &node);
823 vat_json_free (&node);
824 vam->retval = ntohl (mp->retval);
825 vam->result_ready = 1;
828 static void vl_api_create_loopback_instance_reply_t_handler
829 (vl_api_create_loopback_instance_reply_t * mp)
831 vat_main_t *vam = &vat_main;
832 i32 retval = ntohl (mp->retval);
834 vam->retval = retval;
835 vam->regenerate_interface_table = 1;
836 vam->sw_if_index = ntohl (mp->sw_if_index);
837 vam->result_ready = 1;
840 static void vl_api_create_loopback_instance_reply_t_handler_json
841 (vl_api_create_loopback_instance_reply_t * mp)
843 vat_main_t *vam = &vat_main;
844 vat_json_node_t node;
846 vat_json_init_object (&node);
847 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
848 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
850 vat_json_print (vam->ofp, &node);
851 vat_json_free (&node);
852 vam->retval = ntohl (mp->retval);
853 vam->result_ready = 1;
856 static void vl_api_af_packet_create_reply_t_handler
857 (vl_api_af_packet_create_reply_t * mp)
859 vat_main_t *vam = &vat_main;
860 i32 retval = ntohl (mp->retval);
862 vam->retval = retval;
863 vam->regenerate_interface_table = 1;
864 vam->sw_if_index = ntohl (mp->sw_if_index);
865 vam->result_ready = 1;
868 static void vl_api_af_packet_create_reply_t_handler_json
869 (vl_api_af_packet_create_reply_t * mp)
871 vat_main_t *vam = &vat_main;
872 vat_json_node_t node;
874 vat_json_init_object (&node);
875 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
876 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
878 vat_json_print (vam->ofp, &node);
879 vat_json_free (&node);
881 vam->retval = ntohl (mp->retval);
882 vam->result_ready = 1;
885 static void vl_api_create_vlan_subif_reply_t_handler
886 (vl_api_create_vlan_subif_reply_t * mp)
888 vat_main_t *vam = &vat_main;
889 i32 retval = ntohl (mp->retval);
891 vam->retval = retval;
892 vam->regenerate_interface_table = 1;
893 vam->sw_if_index = ntohl (mp->sw_if_index);
894 vam->result_ready = 1;
897 static void vl_api_create_vlan_subif_reply_t_handler_json
898 (vl_api_create_vlan_subif_reply_t * mp)
900 vat_main_t *vam = &vat_main;
901 vat_json_node_t node;
903 vat_json_init_object (&node);
904 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
905 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
907 vat_json_print (vam->ofp, &node);
908 vat_json_free (&node);
910 vam->retval = ntohl (mp->retval);
911 vam->result_ready = 1;
914 static void vl_api_create_subif_reply_t_handler
915 (vl_api_create_subif_reply_t * mp)
917 vat_main_t *vam = &vat_main;
918 i32 retval = ntohl (mp->retval);
920 vam->retval = retval;
921 vam->regenerate_interface_table = 1;
922 vam->sw_if_index = ntohl (mp->sw_if_index);
923 vam->result_ready = 1;
926 static void vl_api_create_subif_reply_t_handler_json
927 (vl_api_create_subif_reply_t * mp)
929 vat_main_t *vam = &vat_main;
930 vat_json_node_t node;
932 vat_json_init_object (&node);
933 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
934 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
936 vat_json_print (vam->ofp, &node);
937 vat_json_free (&node);
939 vam->retval = ntohl (mp->retval);
940 vam->result_ready = 1;
943 static void vl_api_interface_name_renumber_reply_t_handler
944 (vl_api_interface_name_renumber_reply_t * mp)
946 vat_main_t *vam = &vat_main;
947 i32 retval = ntohl (mp->retval);
949 vam->retval = retval;
950 vam->regenerate_interface_table = 1;
951 vam->result_ready = 1;
954 static void vl_api_interface_name_renumber_reply_t_handler_json
955 (vl_api_interface_name_renumber_reply_t * mp)
957 vat_main_t *vam = &vat_main;
958 vat_json_node_t node;
960 vat_json_init_object (&node);
961 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
963 vat_json_print (vam->ofp, &node);
964 vat_json_free (&node);
966 vam->retval = ntohl (mp->retval);
967 vam->result_ready = 1;
971 * Special-case: build the interface table, maintain
972 * the next loopback sw_if_index vbl.
974 static void vl_api_sw_interface_details_t_handler
975 (vl_api_sw_interface_details_t * mp)
977 vat_main_t *vam = &vat_main;
978 u8 *s = format (0, "%s%c", mp->interface_name, 0);
980 hash_set_mem (vam->sw_if_index_by_interface_name, s,
981 ntohl (mp->sw_if_index));
983 /* In sub interface case, fill the sub interface table entry */
984 if (mp->sw_if_index != mp->sup_sw_if_index)
986 sw_interface_subif_t *sub = NULL;
988 vec_add2 (vam->sw_if_subif_table, sub, 1);
990 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
991 strncpy ((char *) sub->interface_name, (char *) s,
992 vec_len (sub->interface_name));
993 sub->sw_if_index = ntohl (mp->sw_if_index);
994 sub->sub_id = ntohl (mp->sub_id);
996 sub->raw_flags = ntohl (mp->sub_if_flags & SUB_IF_API_FLAG_MASK_VNET);
998 sub->sub_number_of_tags = mp->sub_number_of_tags;
999 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
1000 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
1002 /* vlan tag rewrite */
1003 sub->vtr_op = ntohl (mp->vtr_op);
1004 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
1005 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
1006 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
1010 static void vl_api_sw_interface_details_t_handler_json
1011 (vl_api_sw_interface_details_t * mp)
1013 vat_main_t *vam = &vat_main;
1014 vat_json_node_t *node = NULL;
1016 if (VAT_JSON_ARRAY != vam->json_tree.type)
1018 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1019 vat_json_init_array (&vam->json_tree);
1021 node = vat_json_array_add (&vam->json_tree);
1023 vat_json_init_object (node);
1024 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1025 vat_json_object_add_uint (node, "sup_sw_if_index",
1026 ntohl (mp->sup_sw_if_index));
1027 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
1028 sizeof (mp->l2_address));
1029 vat_json_object_add_string_copy (node, "interface_name",
1030 mp->interface_name);
1031 vat_json_object_add_uint (node, "flags", mp->flags);
1032 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
1033 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
1034 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
1035 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
1036 vat_json_object_add_uint (node, "sub_number_of_tags",
1037 mp->sub_number_of_tags);
1038 vat_json_object_add_uint (node, "sub_outer_vlan_id",
1039 ntohs (mp->sub_outer_vlan_id));
1040 vat_json_object_add_uint (node, "sub_inner_vlan_id",
1041 ntohs (mp->sub_inner_vlan_id));
1042 vat_json_object_add_uint (node, "sub_if_flags", ntohl (mp->sub_if_flags));
1043 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
1044 vat_json_object_add_uint (node, "vtr_push_dot1q",
1045 ntohl (mp->vtr_push_dot1q));
1046 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
1047 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
1048 if (ntohl (mp->sub_if_flags) & SUB_IF_API_FLAG_DOT1AH)
1050 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
1052 format_ethernet_address,
1054 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
1056 format_ethernet_address,
1058 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
1059 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
1063 #if VPP_API_TEST_BUILTIN == 0
1064 static void vl_api_sw_interface_event_t_handler
1065 (vl_api_sw_interface_event_t * mp)
1067 vat_main_t *vam = &vat_main;
1068 if (vam->interface_event_display)
1069 errmsg ("interface flags: sw_if_index %d %s %s",
1070 ntohl (mp->sw_if_index),
1071 ((ntohl (mp->flags)) & IF_STATUS_API_FLAG_ADMIN_UP) ?
1072 "admin-up" : "admin-down",
1073 ((ntohl (mp->flags)) & IF_STATUS_API_FLAG_LINK_UP) ?
1074 "link-up" : "link-down");
1078 __clib_unused static void
1079 vl_api_sw_interface_event_t_handler_json (vl_api_sw_interface_event_t * mp)
1081 /* JSON output not supported */
1085 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
1087 vat_main_t *vam = &vat_main;
1088 i32 retval = ntohl (mp->retval);
1090 vam->retval = retval;
1091 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1092 vam->result_ready = 1;
1096 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1098 vat_main_t *vam = &vat_main;
1099 vat_json_node_t node;
1100 api_main_t *am = &api_main;
1104 vat_json_init_object (&node);
1105 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1106 vat_json_object_add_uint (&node, "reply_in_shmem",
1107 ntohl (mp->reply_in_shmem));
1108 /* Toss the shared-memory original... */
1109 pthread_mutex_lock (&am->vlib_rp->mutex);
1110 oldheap = svm_push_data_heap (am->vlib_rp);
1112 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1115 svm_pop_heap (oldheap);
1116 pthread_mutex_unlock (&am->vlib_rp->mutex);
1118 vat_json_print (vam->ofp, &node);
1119 vat_json_free (&node);
1121 vam->retval = ntohl (mp->retval);
1122 vam->result_ready = 1;
1126 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1128 vat_main_t *vam = &vat_main;
1129 i32 retval = ntohl (mp->retval);
1130 u32 length = vl_api_string_len (&mp->reply);
1132 vec_reset_length (vam->cmd_reply);
1134 vam->retval = retval;
1137 vec_validate (vam->cmd_reply, length);
1138 clib_memcpy ((char *) (vam->cmd_reply),
1139 vl_api_from_api_string (&mp->reply), length);
1140 vam->cmd_reply[length] = 0;
1142 vam->result_ready = 1;
1146 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1148 vat_main_t *vam = &vat_main;
1149 vat_json_node_t node;
1151 vec_reset_length (vam->cmd_reply);
1153 vat_json_init_object (&node);
1154 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1155 vat_json_object_add_string_copy (&node, "reply",
1156 vl_api_from_api_string (&mp->reply));
1158 vat_json_print (vam->ofp, &node);
1159 vat_json_free (&node);
1161 vam->retval = ntohl (mp->retval);
1162 vam->result_ready = 1;
1165 static void vl_api_classify_add_del_table_reply_t_handler
1166 (vl_api_classify_add_del_table_reply_t * mp)
1168 vat_main_t *vam = &vat_main;
1169 i32 retval = ntohl (mp->retval);
1170 if (vam->async_mode)
1172 vam->async_errors += (retval < 0);
1176 vam->retval = retval;
1178 ((mp->new_table_index != 0xFFFFFFFF) ||
1179 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1180 (mp->match_n_vectors != 0xFFFFFFFF)))
1182 * Note: this is just barely thread-safe, depends on
1183 * the main thread spinning waiting for an answer...
1185 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1186 ntohl (mp->new_table_index),
1187 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1188 vam->result_ready = 1;
1192 static void vl_api_classify_add_del_table_reply_t_handler_json
1193 (vl_api_classify_add_del_table_reply_t * mp)
1195 vat_main_t *vam = &vat_main;
1196 vat_json_node_t node;
1198 vat_json_init_object (&node);
1199 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1200 vat_json_object_add_uint (&node, "new_table_index",
1201 ntohl (mp->new_table_index));
1202 vat_json_object_add_uint (&node, "skip_n_vectors",
1203 ntohl (mp->skip_n_vectors));
1204 vat_json_object_add_uint (&node, "match_n_vectors",
1205 ntohl (mp->match_n_vectors));
1207 vat_json_print (vam->ofp, &node);
1208 vat_json_free (&node);
1210 vam->retval = ntohl (mp->retval);
1211 vam->result_ready = 1;
1214 static void vl_api_get_node_index_reply_t_handler
1215 (vl_api_get_node_index_reply_t * mp)
1217 vat_main_t *vam = &vat_main;
1218 i32 retval = ntohl (mp->retval);
1219 if (vam->async_mode)
1221 vam->async_errors += (retval < 0);
1225 vam->retval = retval;
1227 errmsg ("node index %d", ntohl (mp->node_index));
1228 vam->result_ready = 1;
1232 static void vl_api_get_node_index_reply_t_handler_json
1233 (vl_api_get_node_index_reply_t * mp)
1235 vat_main_t *vam = &vat_main;
1236 vat_json_node_t node;
1238 vat_json_init_object (&node);
1239 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1240 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1242 vat_json_print (vam->ofp, &node);
1243 vat_json_free (&node);
1245 vam->retval = ntohl (mp->retval);
1246 vam->result_ready = 1;
1249 static void vl_api_get_next_index_reply_t_handler
1250 (vl_api_get_next_index_reply_t * mp)
1252 vat_main_t *vam = &vat_main;
1253 i32 retval = ntohl (mp->retval);
1254 if (vam->async_mode)
1256 vam->async_errors += (retval < 0);
1260 vam->retval = retval;
1262 errmsg ("next node index %d", ntohl (mp->next_index));
1263 vam->result_ready = 1;
1267 static void vl_api_get_next_index_reply_t_handler_json
1268 (vl_api_get_next_index_reply_t * mp)
1270 vat_main_t *vam = &vat_main;
1271 vat_json_node_t node;
1273 vat_json_init_object (&node);
1274 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1275 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1277 vat_json_print (vam->ofp, &node);
1278 vat_json_free (&node);
1280 vam->retval = ntohl (mp->retval);
1281 vam->result_ready = 1;
1284 static void vl_api_add_node_next_reply_t_handler
1285 (vl_api_add_node_next_reply_t * mp)
1287 vat_main_t *vam = &vat_main;
1288 i32 retval = ntohl (mp->retval);
1289 if (vam->async_mode)
1291 vam->async_errors += (retval < 0);
1295 vam->retval = retval;
1297 errmsg ("next index %d", ntohl (mp->next_index));
1298 vam->result_ready = 1;
1302 static void vl_api_add_node_next_reply_t_handler_json
1303 (vl_api_add_node_next_reply_t * mp)
1305 vat_main_t *vam = &vat_main;
1306 vat_json_node_t node;
1308 vat_json_init_object (&node);
1309 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1310 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1312 vat_json_print (vam->ofp, &node);
1313 vat_json_free (&node);
1315 vam->retval = ntohl (mp->retval);
1316 vam->result_ready = 1;
1319 static void vl_api_show_version_reply_t_handler
1320 (vl_api_show_version_reply_t * mp)
1322 vat_main_t *vam = &vat_main;
1323 i32 retval = ntohl (mp->retval);
1327 errmsg (" program: %s", mp->program);
1328 errmsg (" version: %s", mp->version);
1329 errmsg (" build date: %s", mp->build_date);
1330 errmsg ("build directory: %s", mp->build_directory);
1332 vam->retval = retval;
1333 vam->result_ready = 1;
1336 static void vl_api_show_version_reply_t_handler_json
1337 (vl_api_show_version_reply_t * mp)
1339 vat_main_t *vam = &vat_main;
1340 vat_json_node_t node;
1342 vat_json_init_object (&node);
1343 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1344 vat_json_object_add_string_copy (&node, "program", mp->program);
1345 vat_json_object_add_string_copy (&node, "version", mp->version);
1346 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1347 vat_json_object_add_string_copy (&node, "build_directory",
1348 mp->build_directory);
1350 vat_json_print (vam->ofp, &node);
1351 vat_json_free (&node);
1353 vam->retval = ntohl (mp->retval);
1354 vam->result_ready = 1;
1357 static void vl_api_show_threads_reply_t_handler
1358 (vl_api_show_threads_reply_t * mp)
1360 vat_main_t *vam = &vat_main;
1361 i32 retval = ntohl (mp->retval);
1365 count = ntohl (mp->count);
1367 for (i = 0; i < count; i++)
1369 "\n%-2d %-11s %-11s %-5d %-6d %-4d %-6d",
1370 ntohl (mp->thread_data[i].id), mp->thread_data[i].name,
1371 mp->thread_data[i].type, ntohl (mp->thread_data[i].pid),
1372 ntohl (mp->thread_data[i].cpu_id), ntohl (mp->thread_data[i].core),
1373 ntohl (mp->thread_data[i].cpu_socket));
1375 vam->retval = retval;
1376 vam->result_ready = 1;
1379 static void vl_api_show_threads_reply_t_handler_json
1380 (vl_api_show_threads_reply_t * mp)
1382 vat_main_t *vam = &vat_main;
1383 vat_json_node_t node;
1384 vl_api_thread_data_t *td;
1385 i32 retval = ntohl (mp->retval);
1389 count = ntohl (mp->count);
1391 vat_json_init_object (&node);
1392 vat_json_object_add_int (&node, "retval", retval);
1393 vat_json_object_add_uint (&node, "count", count);
1395 for (i = 0; i < count; i++)
1397 td = &mp->thread_data[i];
1398 vat_json_object_add_uint (&node, "id", ntohl (td->id));
1399 vat_json_object_add_string_copy (&node, "name", td->name);
1400 vat_json_object_add_string_copy (&node, "type", td->type);
1401 vat_json_object_add_uint (&node, "pid", ntohl (td->pid));
1402 vat_json_object_add_int (&node, "cpu_id", ntohl (td->cpu_id));
1403 vat_json_object_add_int (&node, "core", ntohl (td->id));
1404 vat_json_object_add_int (&node, "cpu_socket", ntohl (td->cpu_socket));
1407 vat_json_print (vam->ofp, &node);
1408 vat_json_free (&node);
1410 vam->retval = retval;
1411 vam->result_ready = 1;
1415 api_show_threads (vat_main_t * vam)
1417 vl_api_show_threads_t *mp;
1421 "\n%-2s %-11s %-11s %-5s %-6s %-4s %-6s",
1422 "ID", "Name", "Type", "LWP", "cpu_id", "Core", "Socket");
1424 M (SHOW_THREADS, mp);
1432 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1434 u32 sw_if_index = ntohl (mp->sw_if_index);
1435 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1436 mp->mac_ip ? "mac/ip binding" : "address resolution",
1437 ntohl (mp->pid), format_ip4_address, mp->ip,
1438 format_vl_api_mac_address, &mp->mac, sw_if_index);
1442 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1444 /* JSON output not supported */
1448 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1450 u32 sw_if_index = ntohl (mp->sw_if_index);
1451 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1452 mp->mac_ip ? "mac/ip binding" : "address resolution",
1453 ntohl (mp->pid), format_vl_api_ip6_address, mp->ip,
1454 format_vl_api_mac_address, mp->mac, sw_if_index);
1458 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1460 /* JSON output not supported */
1464 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1466 u32 n_macs = ntohl (mp->n_macs);
1467 errmsg ("L2MAC event received with pid %d cl-idx %d for %d macs: \n",
1468 ntohl (mp->pid), mp->client_index, n_macs);
1470 for (i = 0; i < n_macs; i++)
1472 vl_api_mac_entry_t *mac = &mp->mac[i];
1473 errmsg (" [%d] sw_if_index %d mac_addr %U action %d \n",
1474 i + 1, ntohl (mac->sw_if_index),
1475 format_ethernet_address, mac->mac_addr, mac->action);
1482 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1484 /* JSON output not supported */
1487 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1488 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1491 * Special-case: build the bridge domain table, maintain
1492 * the next bd id vbl.
1494 static void vl_api_bridge_domain_details_t_handler
1495 (vl_api_bridge_domain_details_t * mp)
1497 vat_main_t *vam = &vat_main;
1498 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1501 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-6s %-3s",
1502 " ID", "LRN", "FWD", "FLD", "BVI", "UU-FWD", "#IF");
1504 print (vam->ofp, "%3d %3d %3d %3d %3d %6d %3d",
1505 ntohl (mp->bd_id), mp->learn, mp->forward,
1506 mp->flood, ntohl (mp->bvi_sw_if_index),
1507 ntohl (mp->uu_fwd_sw_if_index), n_sw_ifs);
1511 vl_api_bridge_domain_sw_if_t *sw_ifs;
1512 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1515 sw_ifs = mp->sw_if_details;
1516 for (i = 0; i < n_sw_ifs; i++)
1522 sw_if_index = ntohl (sw_ifs->sw_if_index);
1525 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1527 if ((u32) p->value[0] == sw_if_index)
1529 sw_if_name = (u8 *)(p->key);
1534 print (vam->ofp, "%7d %3d %s", sw_if_index,
1535 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1536 "sw_if_index not found!");
1543 static void vl_api_bridge_domain_details_t_handler_json
1544 (vl_api_bridge_domain_details_t * mp)
1546 vat_main_t *vam = &vat_main;
1547 vat_json_node_t *node, *array = NULL;
1548 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1550 if (VAT_JSON_ARRAY != vam->json_tree.type)
1552 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1553 vat_json_init_array (&vam->json_tree);
1555 node = vat_json_array_add (&vam->json_tree);
1557 vat_json_init_object (node);
1558 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1559 vat_json_object_add_uint (node, "flood", mp->flood);
1560 vat_json_object_add_uint (node, "forward", mp->forward);
1561 vat_json_object_add_uint (node, "learn", mp->learn);
1562 vat_json_object_add_uint (node, "bvi_sw_if_index",
1563 ntohl (mp->bvi_sw_if_index));
1564 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1565 array = vat_json_object_add (node, "sw_if");
1566 vat_json_init_array (array);
1572 vl_api_bridge_domain_sw_if_t *sw_ifs;
1575 sw_ifs = mp->sw_if_details;
1576 for (i = 0; i < n_sw_ifs; i++)
1578 node = vat_json_array_add (array);
1579 vat_json_init_object (node);
1580 vat_json_object_add_uint (node, "sw_if_index",
1581 ntohl (sw_ifs->sw_if_index));
1582 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1588 static void vl_api_control_ping_reply_t_handler
1589 (vl_api_control_ping_reply_t * mp)
1591 vat_main_t *vam = &vat_main;
1592 i32 retval = ntohl (mp->retval);
1593 if (vam->async_mode)
1595 vam->async_errors += (retval < 0);
1599 vam->retval = retval;
1600 vam->result_ready = 1;
1602 if (vam->socket_client_main)
1603 vam->socket_client_main->control_pings_outstanding--;
1606 static void vl_api_control_ping_reply_t_handler_json
1607 (vl_api_control_ping_reply_t * mp)
1609 vat_main_t *vam = &vat_main;
1610 i32 retval = ntohl (mp->retval);
1612 if (VAT_JSON_NONE != vam->json_tree.type)
1614 vat_json_print (vam->ofp, &vam->json_tree);
1615 vat_json_free (&vam->json_tree);
1616 vam->json_tree.type = VAT_JSON_NONE;
1621 vat_json_init_array (&vam->json_tree);
1622 vat_json_print (vam->ofp, &vam->json_tree);
1623 vam->json_tree.type = VAT_JSON_NONE;
1626 vam->retval = retval;
1627 vam->result_ready = 1;
1631 vl_api_bridge_domain_set_mac_age_reply_t_handler
1632 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1634 vat_main_t *vam = &vat_main;
1635 i32 retval = ntohl (mp->retval);
1636 if (vam->async_mode)
1638 vam->async_errors += (retval < 0);
1642 vam->retval = retval;
1643 vam->result_ready = 1;
1647 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1648 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1650 vat_main_t *vam = &vat_main;
1651 vat_json_node_t node;
1653 vat_json_init_object (&node);
1654 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1656 vat_json_print (vam->ofp, &node);
1657 vat_json_free (&node);
1659 vam->retval = ntohl (mp->retval);
1660 vam->result_ready = 1;
1664 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1666 vat_main_t *vam = &vat_main;
1667 i32 retval = ntohl (mp->retval);
1668 if (vam->async_mode)
1670 vam->async_errors += (retval < 0);
1674 vam->retval = retval;
1675 vam->result_ready = 1;
1679 static void vl_api_l2_flags_reply_t_handler_json
1680 (vl_api_l2_flags_reply_t * mp)
1682 vat_main_t *vam = &vat_main;
1683 vat_json_node_t node;
1685 vat_json_init_object (&node);
1686 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1687 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1688 ntohl (mp->resulting_feature_bitmap));
1690 vat_json_print (vam->ofp, &node);
1691 vat_json_free (&node);
1693 vam->retval = ntohl (mp->retval);
1694 vam->result_ready = 1;
1697 static void vl_api_bridge_flags_reply_t_handler
1698 (vl_api_bridge_flags_reply_t * mp)
1700 vat_main_t *vam = &vat_main;
1701 i32 retval = ntohl (mp->retval);
1702 if (vam->async_mode)
1704 vam->async_errors += (retval < 0);
1708 vam->retval = retval;
1709 vam->result_ready = 1;
1713 static void vl_api_bridge_flags_reply_t_handler_json
1714 (vl_api_bridge_flags_reply_t * mp)
1716 vat_main_t *vam = &vat_main;
1717 vat_json_node_t node;
1719 vat_json_init_object (&node);
1720 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1721 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1722 ntohl (mp->resulting_feature_bitmap));
1724 vat_json_print (vam->ofp, &node);
1725 vat_json_free (&node);
1727 vam->retval = ntohl (mp->retval);
1728 vam->result_ready = 1;
1732 vl_api_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_reply_t * mp)
1734 vat_main_t *vam = &vat_main;
1735 i32 retval = ntohl (mp->retval);
1736 if (vam->async_mode)
1738 vam->async_errors += (retval < 0);
1742 vam->retval = retval;
1743 vam->sw_if_index = ntohl (mp->sw_if_index);
1744 vam->result_ready = 1;
1749 static void vl_api_tap_create_v2_reply_t_handler_json
1750 (vl_api_tap_create_v2_reply_t * mp)
1752 vat_main_t *vam = &vat_main;
1753 vat_json_node_t node;
1755 vat_json_init_object (&node);
1756 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1757 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1759 vat_json_print (vam->ofp, &node);
1760 vat_json_free (&node);
1762 vam->retval = ntohl (mp->retval);
1763 vam->result_ready = 1;
1768 vl_api_tap_delete_v2_reply_t_handler (vl_api_tap_delete_v2_reply_t * mp)
1770 vat_main_t *vam = &vat_main;
1771 i32 retval = ntohl (mp->retval);
1772 if (vam->async_mode)
1774 vam->async_errors += (retval < 0);
1778 vam->retval = retval;
1779 vam->result_ready = 1;
1783 static void vl_api_tap_delete_v2_reply_t_handler_json
1784 (vl_api_tap_delete_v2_reply_t * mp)
1786 vat_main_t *vam = &vat_main;
1787 vat_json_node_t node;
1789 vat_json_init_object (&node);
1790 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1792 vat_json_print (vam->ofp, &node);
1793 vat_json_free (&node);
1795 vam->retval = ntohl (mp->retval);
1796 vam->result_ready = 1;
1800 vl_api_virtio_pci_create_reply_t_handler (vl_api_virtio_pci_create_reply_t *
1803 vat_main_t *vam = &vat_main;
1804 i32 retval = ntohl (mp->retval);
1805 if (vam->async_mode)
1807 vam->async_errors += (retval < 0);
1811 vam->retval = retval;
1812 vam->sw_if_index = ntohl (mp->sw_if_index);
1813 vam->result_ready = 1;
1817 static void vl_api_virtio_pci_create_reply_t_handler_json
1818 (vl_api_virtio_pci_create_reply_t * mp)
1820 vat_main_t *vam = &vat_main;
1821 vat_json_node_t node;
1823 vat_json_init_object (&node);
1824 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1825 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1827 vat_json_print (vam->ofp, &node);
1828 vat_json_free (&node);
1830 vam->retval = ntohl (mp->retval);
1831 vam->result_ready = 1;
1836 vl_api_virtio_pci_delete_reply_t_handler (vl_api_virtio_pci_delete_reply_t *
1839 vat_main_t *vam = &vat_main;
1840 i32 retval = ntohl (mp->retval);
1841 if (vam->async_mode)
1843 vam->async_errors += (retval < 0);
1847 vam->retval = retval;
1848 vam->result_ready = 1;
1852 static void vl_api_virtio_pci_delete_reply_t_handler_json
1853 (vl_api_virtio_pci_delete_reply_t * mp)
1855 vat_main_t *vam = &vat_main;
1856 vat_json_node_t node;
1858 vat_json_init_object (&node);
1859 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1861 vat_json_print (vam->ofp, &node);
1862 vat_json_free (&node);
1864 vam->retval = ntohl (mp->retval);
1865 vam->result_ready = 1;
1869 vl_api_bond_create_reply_t_handler (vl_api_bond_create_reply_t * mp)
1871 vat_main_t *vam = &vat_main;
1872 i32 retval = ntohl (mp->retval);
1874 if (vam->async_mode)
1876 vam->async_errors += (retval < 0);
1880 vam->retval = retval;
1881 vam->sw_if_index = ntohl (mp->sw_if_index);
1882 vam->result_ready = 1;
1886 static void vl_api_bond_create_reply_t_handler_json
1887 (vl_api_bond_create_reply_t * mp)
1889 vat_main_t *vam = &vat_main;
1890 vat_json_node_t node;
1892 vat_json_init_object (&node);
1893 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1894 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1896 vat_json_print (vam->ofp, &node);
1897 vat_json_free (&node);
1899 vam->retval = ntohl (mp->retval);
1900 vam->result_ready = 1;
1904 vl_api_bond_delete_reply_t_handler (vl_api_bond_delete_reply_t * mp)
1906 vat_main_t *vam = &vat_main;
1907 i32 retval = ntohl (mp->retval);
1909 if (vam->async_mode)
1911 vam->async_errors += (retval < 0);
1915 vam->retval = retval;
1916 vam->result_ready = 1;
1920 static void vl_api_bond_delete_reply_t_handler_json
1921 (vl_api_bond_delete_reply_t * mp)
1923 vat_main_t *vam = &vat_main;
1924 vat_json_node_t node;
1926 vat_json_init_object (&node);
1927 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1929 vat_json_print (vam->ofp, &node);
1930 vat_json_free (&node);
1932 vam->retval = ntohl (mp->retval);
1933 vam->result_ready = 1;
1937 vl_api_bond_enslave_reply_t_handler (vl_api_bond_enslave_reply_t * mp)
1939 vat_main_t *vam = &vat_main;
1940 i32 retval = ntohl (mp->retval);
1942 if (vam->async_mode)
1944 vam->async_errors += (retval < 0);
1948 vam->retval = retval;
1949 vam->result_ready = 1;
1953 static void vl_api_bond_enslave_reply_t_handler_json
1954 (vl_api_bond_enslave_reply_t * mp)
1956 vat_main_t *vam = &vat_main;
1957 vat_json_node_t node;
1959 vat_json_init_object (&node);
1960 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1962 vat_json_print (vam->ofp, &node);
1963 vat_json_free (&node);
1965 vam->retval = ntohl (mp->retval);
1966 vam->result_ready = 1;
1970 vl_api_bond_detach_slave_reply_t_handler (vl_api_bond_detach_slave_reply_t *
1973 vat_main_t *vam = &vat_main;
1974 i32 retval = ntohl (mp->retval);
1976 if (vam->async_mode)
1978 vam->async_errors += (retval < 0);
1982 vam->retval = retval;
1983 vam->result_ready = 1;
1987 static void vl_api_bond_detach_slave_reply_t_handler_json
1988 (vl_api_bond_detach_slave_reply_t * mp)
1990 vat_main_t *vam = &vat_main;
1991 vat_json_node_t node;
1993 vat_json_init_object (&node);
1994 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1996 vat_json_print (vam->ofp, &node);
1997 vat_json_free (&node);
1999 vam->retval = ntohl (mp->retval);
2000 vam->result_ready = 1;
2004 api_sw_interface_set_bond_weight (vat_main_t * vam)
2006 unformat_input_t *i = vam->input;
2007 vl_api_sw_interface_set_bond_weight_t *mp;
2008 u32 sw_if_index = ~0;
2010 u8 weight_enter = 0;
2013 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2015 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2017 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2019 else if (unformat (i, "weight %u", &weight))
2025 if (sw_if_index == ~0)
2027 errmsg ("missing interface name or sw_if_index");
2030 if (weight_enter == 0)
2032 errmsg ("missing valid weight");
2036 /* Construct the API message */
2037 M (SW_INTERFACE_SET_BOND_WEIGHT, mp);
2038 mp->sw_if_index = ntohl (sw_if_index);
2039 mp->weight = ntohl (weight);
2046 static void vl_api_sw_interface_bond_details_t_handler
2047 (vl_api_sw_interface_bond_details_t * mp)
2049 vat_main_t *vam = &vat_main;
2052 "%-16s %-12d %-12U %-13U %-14u %-14u",
2053 mp->interface_name, ntohl (mp->sw_if_index),
2054 format_bond_mode, ntohl (mp->mode), format_bond_load_balance,
2055 ntohl (mp->lb), ntohl (mp->active_slaves), ntohl (mp->slaves));
2058 static void vl_api_sw_interface_bond_details_t_handler_json
2059 (vl_api_sw_interface_bond_details_t * mp)
2061 vat_main_t *vam = &vat_main;
2062 vat_json_node_t *node = NULL;
2064 if (VAT_JSON_ARRAY != vam->json_tree.type)
2066 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2067 vat_json_init_array (&vam->json_tree);
2069 node = vat_json_array_add (&vam->json_tree);
2071 vat_json_init_object (node);
2072 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2073 vat_json_object_add_string_copy (node, "interface_name",
2074 mp->interface_name);
2075 vat_json_object_add_uint (node, "mode", ntohl (mp->mode));
2076 vat_json_object_add_uint (node, "load_balance", ntohl (mp->lb));
2077 vat_json_object_add_uint (node, "active_slaves", ntohl (mp->active_slaves));
2078 vat_json_object_add_uint (node, "slaves", ntohl (mp->slaves));
2082 api_sw_interface_bond_dump (vat_main_t * vam)
2084 vl_api_sw_interface_bond_dump_t *mp;
2085 vl_api_control_ping_t *mp_ping;
2089 "\n%-16s %-12s %-12s %-13s %-14s %-14s",
2090 "interface name", "sw_if_index", "mode", "load balance",
2091 "active slaves", "slaves");
2093 /* Get list of bond interfaces */
2094 M (SW_INTERFACE_BOND_DUMP, mp);
2097 /* Use a control ping for synchronization */
2098 MPING (CONTROL_PING, mp_ping);
2105 static void vl_api_sw_interface_slave_details_t_handler
2106 (vl_api_sw_interface_slave_details_t * mp)
2108 vat_main_t *vam = &vat_main;
2111 "%-25s %-12d %-7d %-12d %-10d %-10d", mp->interface_name,
2112 ntohl (mp->sw_if_index), mp->is_passive, mp->is_long_timeout,
2113 ntohl (mp->weight), mp->is_local_numa);
2116 static void vl_api_sw_interface_slave_details_t_handler_json
2117 (vl_api_sw_interface_slave_details_t * mp)
2119 vat_main_t *vam = &vat_main;
2120 vat_json_node_t *node = NULL;
2122 if (VAT_JSON_ARRAY != vam->json_tree.type)
2124 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2125 vat_json_init_array (&vam->json_tree);
2127 node = vat_json_array_add (&vam->json_tree);
2129 vat_json_init_object (node);
2130 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2131 vat_json_object_add_string_copy (node, "interface_name",
2132 mp->interface_name);
2133 vat_json_object_add_uint (node, "passive", mp->is_passive);
2134 vat_json_object_add_uint (node, "long_timeout", mp->is_long_timeout);
2135 vat_json_object_add_uint (node, "weight", ntohl (mp->weight));
2136 vat_json_object_add_uint (node, "is_local_numa", mp->is_local_numa);
2140 api_sw_interface_slave_dump (vat_main_t * vam)
2142 unformat_input_t *i = vam->input;
2143 vl_api_sw_interface_slave_dump_t *mp;
2144 vl_api_control_ping_t *mp_ping;
2145 u32 sw_if_index = ~0;
2146 u8 sw_if_index_set = 0;
2149 /* Parse args required to build the message */
2150 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2152 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2153 sw_if_index_set = 1;
2154 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2155 sw_if_index_set = 1;
2160 if (sw_if_index_set == 0)
2162 errmsg ("missing vpp interface name. ");
2167 "\n%-25s %-12s %-7s %-12s %-10s %-10s",
2168 "slave interface name", "sw_if_index", "passive", "long_timeout",
2169 "weight", "local numa");
2171 /* Get list of bond interfaces */
2172 M (SW_INTERFACE_SLAVE_DUMP, mp);
2173 mp->sw_if_index = ntohl (sw_if_index);
2176 /* Use a control ping for synchronization */
2177 MPING (CONTROL_PING, mp_ping);
2184 static void vl_api_mpls_tunnel_add_del_reply_t_handler
2185 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2187 vat_main_t *vam = &vat_main;
2188 i32 retval = ntohl (mp->retval);
2189 if (vam->async_mode)
2191 vam->async_errors += (retval < 0);
2195 vam->retval = retval;
2196 vam->sw_if_index = ntohl (mp->sw_if_index);
2197 vam->result_ready = 1;
2199 vam->regenerate_interface_table = 1;
2202 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
2203 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2205 vat_main_t *vam = &vat_main;
2206 vat_json_node_t node;
2208 vat_json_init_object (&node);
2209 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2210 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
2211 ntohl (mp->sw_if_index));
2213 vat_json_print (vam->ofp, &node);
2214 vat_json_free (&node);
2216 vam->retval = ntohl (mp->retval);
2217 vam->result_ready = 1;
2220 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
2221 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2223 vat_main_t *vam = &vat_main;
2224 i32 retval = ntohl (mp->retval);
2225 if (vam->async_mode)
2227 vam->async_errors += (retval < 0);
2231 vam->retval = retval;
2232 vam->sw_if_index = ntohl (mp->sw_if_index);
2233 vam->result_ready = 1;
2237 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
2238 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2240 vat_main_t *vam = &vat_main;
2241 vat_json_node_t node;
2243 vat_json_init_object (&node);
2244 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2245 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2247 vat_json_print (vam->ofp, &node);
2248 vat_json_free (&node);
2250 vam->retval = ntohl (mp->retval);
2251 vam->result_ready = 1;
2254 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
2255 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2257 vat_main_t *vam = &vat_main;
2258 i32 retval = ntohl (mp->retval);
2259 if (vam->async_mode)
2261 vam->async_errors += (retval < 0);
2265 vam->retval = retval;
2266 vam->result_ready = 1;
2270 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
2271 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2273 vat_main_t *vam = &vat_main;
2274 vat_json_node_t node;
2276 vat_json_init_object (&node);
2277 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2278 vat_json_object_add_uint (&node, "fwd_entry_index",
2279 clib_net_to_host_u32 (mp->fwd_entry_index));
2281 vat_json_print (vam->ofp, &node);
2282 vat_json_free (&node);
2284 vam->retval = ntohl (mp->retval);
2285 vam->result_ready = 1;
2289 format_lisp_transport_protocol (u8 * s, va_list * args)
2291 u32 proto = va_arg (*args, u32);
2296 return format (s, "udp");
2298 return format (s, "api");
2305 static void vl_api_one_get_transport_protocol_reply_t_handler
2306 (vl_api_one_get_transport_protocol_reply_t * mp)
2308 vat_main_t *vam = &vat_main;
2309 i32 retval = ntohl (mp->retval);
2310 if (vam->async_mode)
2312 vam->async_errors += (retval < 0);
2316 u32 proto = mp->protocol;
2317 print (vam->ofp, "Transport protocol: %U",
2318 format_lisp_transport_protocol, proto);
2319 vam->retval = retval;
2320 vam->result_ready = 1;
2324 static void vl_api_one_get_transport_protocol_reply_t_handler_json
2325 (vl_api_one_get_transport_protocol_reply_t * mp)
2327 vat_main_t *vam = &vat_main;
2328 vat_json_node_t node;
2331 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
2334 vat_json_init_object (&node);
2335 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2336 vat_json_object_add_string_copy (&node, "transport-protocol", s);
2339 vat_json_print (vam->ofp, &node);
2340 vat_json_free (&node);
2342 vam->retval = ntohl (mp->retval);
2343 vam->result_ready = 1;
2346 static void vl_api_one_add_del_locator_set_reply_t_handler
2347 (vl_api_one_add_del_locator_set_reply_t * mp)
2349 vat_main_t *vam = &vat_main;
2350 i32 retval = ntohl (mp->retval);
2351 if (vam->async_mode)
2353 vam->async_errors += (retval < 0);
2357 vam->retval = retval;
2358 vam->result_ready = 1;
2362 static void vl_api_one_add_del_locator_set_reply_t_handler_json
2363 (vl_api_one_add_del_locator_set_reply_t * mp)
2365 vat_main_t *vam = &vat_main;
2366 vat_json_node_t node;
2368 vat_json_init_object (&node);
2369 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2370 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
2372 vat_json_print (vam->ofp, &node);
2373 vat_json_free (&node);
2375 vam->retval = ntohl (mp->retval);
2376 vam->result_ready = 1;
2379 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
2380 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2382 vat_main_t *vam = &vat_main;
2383 i32 retval = ntohl (mp->retval);
2384 if (vam->async_mode)
2386 vam->async_errors += (retval < 0);
2390 vam->retval = retval;
2391 vam->sw_if_index = ntohl (mp->sw_if_index);
2392 vam->result_ready = 1;
2394 vam->regenerate_interface_table = 1;
2397 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
2398 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2400 vat_main_t *vam = &vat_main;
2401 vat_json_node_t node;
2403 vat_json_init_object (&node);
2404 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2405 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2407 vat_json_print (vam->ofp, &node);
2408 vat_json_free (&node);
2410 vam->retval = ntohl (mp->retval);
2411 vam->result_ready = 1;
2414 static void vl_api_vxlan_offload_rx_reply_t_handler
2415 (vl_api_vxlan_offload_rx_reply_t * mp)
2417 vat_main_t *vam = &vat_main;
2418 i32 retval = ntohl (mp->retval);
2419 if (vam->async_mode)
2421 vam->async_errors += (retval < 0);
2425 vam->retval = retval;
2426 vam->result_ready = 1;
2430 static void vl_api_vxlan_offload_rx_reply_t_handler_json
2431 (vl_api_vxlan_offload_rx_reply_t * mp)
2433 vat_main_t *vam = &vat_main;
2434 vat_json_node_t node;
2436 vat_json_init_object (&node);
2437 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2439 vat_json_print (vam->ofp, &node);
2440 vat_json_free (&node);
2442 vam->retval = ntohl (mp->retval);
2443 vam->result_ready = 1;
2446 static void vl_api_geneve_add_del_tunnel_reply_t_handler
2447 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2449 vat_main_t *vam = &vat_main;
2450 i32 retval = ntohl (mp->retval);
2451 if (vam->async_mode)
2453 vam->async_errors += (retval < 0);
2457 vam->retval = retval;
2458 vam->sw_if_index = ntohl (mp->sw_if_index);
2459 vam->result_ready = 1;
2463 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
2464 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2466 vat_main_t *vam = &vat_main;
2467 vat_json_node_t node;
2469 vat_json_init_object (&node);
2470 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2471 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2473 vat_json_print (vam->ofp, &node);
2474 vat_json_free (&node);
2476 vam->retval = ntohl (mp->retval);
2477 vam->result_ready = 1;
2480 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
2481 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2483 vat_main_t *vam = &vat_main;
2484 i32 retval = ntohl (mp->retval);
2485 if (vam->async_mode)
2487 vam->async_errors += (retval < 0);
2491 vam->retval = retval;
2492 vam->sw_if_index = ntohl (mp->sw_if_index);
2493 vam->result_ready = 1;
2495 vam->regenerate_interface_table = 1;
2498 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
2499 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2501 vat_main_t *vam = &vat_main;
2502 vat_json_node_t node;
2504 vat_json_init_object (&node);
2505 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2506 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2508 vat_json_print (vam->ofp, &node);
2509 vat_json_free (&node);
2511 vam->retval = ntohl (mp->retval);
2512 vam->result_ready = 1;
2515 static void vl_api_gre_tunnel_add_del_reply_t_handler
2516 (vl_api_gre_tunnel_add_del_reply_t * mp)
2518 vat_main_t *vam = &vat_main;
2519 i32 retval = ntohl (mp->retval);
2520 if (vam->async_mode)
2522 vam->async_errors += (retval < 0);
2526 vam->retval = retval;
2527 vam->sw_if_index = ntohl (mp->sw_if_index);
2528 vam->result_ready = 1;
2532 static void vl_api_gre_tunnel_add_del_reply_t_handler_json
2533 (vl_api_gre_tunnel_add_del_reply_t * mp)
2535 vat_main_t *vam = &vat_main;
2536 vat_json_node_t node;
2538 vat_json_init_object (&node);
2539 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2540 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2542 vat_json_print (vam->ofp, &node);
2543 vat_json_free (&node);
2545 vam->retval = ntohl (mp->retval);
2546 vam->result_ready = 1;
2549 static void vl_api_create_vhost_user_if_reply_t_handler
2550 (vl_api_create_vhost_user_if_reply_t * mp)
2552 vat_main_t *vam = &vat_main;
2553 i32 retval = ntohl (mp->retval);
2554 if (vam->async_mode)
2556 vam->async_errors += (retval < 0);
2560 vam->retval = retval;
2561 vam->sw_if_index = ntohl (mp->sw_if_index);
2562 vam->result_ready = 1;
2564 vam->regenerate_interface_table = 1;
2567 static void vl_api_create_vhost_user_if_reply_t_handler_json
2568 (vl_api_create_vhost_user_if_reply_t * mp)
2570 vat_main_t *vam = &vat_main;
2571 vat_json_node_t node;
2573 vat_json_init_object (&node);
2574 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2575 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2577 vat_json_print (vam->ofp, &node);
2578 vat_json_free (&node);
2580 vam->retval = ntohl (mp->retval);
2581 vam->result_ready = 1;
2584 static void vl_api_ip_address_details_t_handler
2585 (vl_api_ip_address_details_t * mp)
2587 vat_main_t *vam = &vat_main;
2588 static ip_address_details_t empty_ip_address_details = { {0} };
2589 ip_address_details_t *address = NULL;
2590 ip_details_t *current_ip_details = NULL;
2591 ip_details_t *details = NULL;
2593 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2595 if (!details || vam->current_sw_if_index >= vec_len (details)
2596 || !details[vam->current_sw_if_index].present)
2598 errmsg ("ip address details arrived but not stored");
2599 errmsg ("ip_dump should be called first");
2603 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2605 #define addresses (current_ip_details->addr)
2607 vec_validate_init_empty (addresses, vec_len (addresses),
2608 empty_ip_address_details);
2610 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2612 clib_memcpy (&address->ip, &mp->prefix.address.un, sizeof (address->ip));
2613 address->prefix_length = mp->prefix.len;
2617 static void vl_api_ip_address_details_t_handler_json
2618 (vl_api_ip_address_details_t * mp)
2620 vat_main_t *vam = &vat_main;
2621 vat_json_node_t *node = NULL;
2623 if (VAT_JSON_ARRAY != vam->json_tree.type)
2625 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2626 vat_json_init_array (&vam->json_tree);
2628 node = vat_json_array_add (&vam->json_tree);
2630 vat_json_init_object (node);
2631 vat_json_object_add_prefix (node, &mp->prefix);
2635 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2637 vat_main_t *vam = &vat_main;
2638 static ip_details_t empty_ip_details = { 0 };
2639 ip_details_t *ip = NULL;
2640 u32 sw_if_index = ~0;
2642 sw_if_index = ntohl (mp->sw_if_index);
2644 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2645 sw_if_index, empty_ip_details);
2647 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2654 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2656 vat_main_t *vam = &vat_main;
2658 if (VAT_JSON_ARRAY != vam->json_tree.type)
2660 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2661 vat_json_init_array (&vam->json_tree);
2663 vat_json_array_add_uint (&vam->json_tree,
2664 clib_net_to_host_u32 (mp->sw_if_index));
2668 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2672 s = format (0, "DHCP compl event: pid %d %s hostname %s host_addr %U "
2673 "host_mac %U router_addr %U",
2674 ntohl (mp->pid), mp->lease.is_ipv6 ? "ipv6" : "ipv4",
2676 format_ip4_address, mp->lease.host_address,
2677 format_ethernet_address, mp->lease.host_mac,
2678 format_ip4_address, mp->lease.router_address);
2680 for (i = 0; i < mp->lease.count; i++)
2682 format (s, " domain_server_addr %U", format_ip4_address,
2683 mp->lease.domain_server[i].address);
2685 errmsg ((char *) s);
2689 static void vl_api_dhcp_compl_event_t_handler_json
2690 (vl_api_dhcp_compl_event_t * mp)
2692 /* JSON output not supported */
2695 static void vl_api_get_first_msg_id_reply_t_handler
2696 (vl_api_get_first_msg_id_reply_t * mp)
2698 vat_main_t *vam = &vat_main;
2699 i32 retval = ntohl (mp->retval);
2701 if (vam->async_mode)
2703 vam->async_errors += (retval < 0);
2707 vam->retval = retval;
2708 vam->result_ready = 1;
2712 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2716 static void vl_api_get_first_msg_id_reply_t_handler_json
2717 (vl_api_get_first_msg_id_reply_t * mp)
2719 vat_main_t *vam = &vat_main;
2720 vat_json_node_t node;
2722 vat_json_init_object (&node);
2723 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2724 vat_json_object_add_uint (&node, "first_msg_id",
2725 (uint) ntohs (mp->first_msg_id));
2727 vat_json_print (vam->ofp, &node);
2728 vat_json_free (&node);
2730 vam->retval = ntohl (mp->retval);
2731 vam->result_ready = 1;
2734 static void vl_api_get_node_graph_reply_t_handler
2735 (vl_api_get_node_graph_reply_t * mp)
2737 vat_main_t *vam = &vat_main;
2738 api_main_t *am = &api_main;
2739 i32 retval = ntohl (mp->retval);
2740 u8 *pvt_copy, *reply;
2745 if (vam->async_mode)
2747 vam->async_errors += (retval < 0);
2751 vam->retval = retval;
2752 vam->result_ready = 1;
2755 /* "Should never happen..." */
2759 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2760 pvt_copy = vec_dup (reply);
2762 /* Toss the shared-memory original... */
2763 pthread_mutex_lock (&am->vlib_rp->mutex);
2764 oldheap = svm_push_data_heap (am->vlib_rp);
2768 svm_pop_heap (oldheap);
2769 pthread_mutex_unlock (&am->vlib_rp->mutex);
2771 if (vam->graph_nodes)
2773 hash_free (vam->graph_node_index_by_name);
2775 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2777 node = vam->graph_nodes[0][i];
2778 vec_free (node->name);
2779 vec_free (node->next_nodes);
2782 vec_free (vam->graph_nodes[0]);
2783 vec_free (vam->graph_nodes);
2786 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2787 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2788 vec_free (pvt_copy);
2790 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2792 node = vam->graph_nodes[0][i];
2793 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2797 static void vl_api_get_node_graph_reply_t_handler_json
2798 (vl_api_get_node_graph_reply_t * mp)
2800 vat_main_t *vam = &vat_main;
2801 api_main_t *am = &api_main;
2803 vat_json_node_t node;
2806 /* $$$$ make this real? */
2807 vat_json_init_object (&node);
2808 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2809 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2811 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2813 /* Toss the shared-memory original... */
2814 pthread_mutex_lock (&am->vlib_rp->mutex);
2815 oldheap = svm_push_data_heap (am->vlib_rp);
2819 svm_pop_heap (oldheap);
2820 pthread_mutex_unlock (&am->vlib_rp->mutex);
2822 vat_json_print (vam->ofp, &node);
2823 vat_json_free (&node);
2825 vam->retval = ntohl (mp->retval);
2826 vam->result_ready = 1;
2830 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2832 vat_main_t *vam = &vat_main;
2837 s = format (s, "%=16d%=16d%=16d",
2838 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2842 s = format (s, "%=16U%=16d%=16d",
2843 mp->is_ipv6 ? format_ip6_address :
2845 mp->ip_address, mp->priority, mp->weight);
2848 print (vam->ofp, "%v", s);
2853 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2855 vat_main_t *vam = &vat_main;
2856 vat_json_node_t *node = NULL;
2857 struct in6_addr ip6;
2860 if (VAT_JSON_ARRAY != vam->json_tree.type)
2862 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2863 vat_json_init_array (&vam->json_tree);
2865 node = vat_json_array_add (&vam->json_tree);
2866 vat_json_init_object (node);
2868 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2869 vat_json_object_add_uint (node, "priority", mp->priority);
2870 vat_json_object_add_uint (node, "weight", mp->weight);
2873 vat_json_object_add_uint (node, "sw_if_index",
2874 clib_net_to_host_u32 (mp->sw_if_index));
2879 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2880 vat_json_object_add_ip6 (node, "address", ip6);
2884 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2885 vat_json_object_add_ip4 (node, "address", ip4);
2891 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2894 vat_main_t *vam = &vat_main;
2897 ls_name = format (0, "%s", mp->ls_name);
2899 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2905 vl_api_one_locator_set_details_t_handler_json
2906 (vl_api_one_locator_set_details_t * mp)
2908 vat_main_t *vam = &vat_main;
2909 vat_json_node_t *node = 0;
2912 ls_name = format (0, "%s", mp->ls_name);
2913 vec_add1 (ls_name, 0);
2915 if (VAT_JSON_ARRAY != vam->json_tree.type)
2917 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2918 vat_json_init_array (&vam->json_tree);
2920 node = vat_json_array_add (&vam->json_tree);
2922 vat_json_init_object (node);
2923 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2924 vat_json_object_add_uint (node, "ls_index",
2925 clib_net_to_host_u32 (mp->ls_index));
2933 } __attribute__ ((__packed__)) lisp_nsh_api_t;
2936 unformat_nsh_address (unformat_input_t * input, va_list * args)
2938 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
2939 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
2943 format_nsh_address_vat (u8 * s, va_list * args)
2945 nsh_t *a = va_arg (*args, nsh_t *);
2946 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
2950 format_lisp_flat_eid (u8 * s, va_list * args)
2952 u32 type = va_arg (*args, u32);
2953 u8 *eid = va_arg (*args, u8 *);
2954 u32 eid_len = va_arg (*args, u32);
2959 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2961 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2963 return format (s, "%U", format_ethernet_address, eid);
2965 return format (s, "%U", format_nsh_address_vat, eid);
2971 format_lisp_eid_vat (u8 * s, va_list * args)
2973 u32 type = va_arg (*args, u32);
2974 u8 *eid = va_arg (*args, u8 *);
2975 u32 eid_len = va_arg (*args, u32);
2976 u8 *seid = va_arg (*args, u8 *);
2977 u32 seid_len = va_arg (*args, u32);
2978 u32 is_src_dst = va_arg (*args, u32);
2981 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2983 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2989 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
2991 vat_main_t *vam = &vat_main;
2992 u8 *s = 0, *eid = 0;
2994 if (~0 == mp->locator_set_index)
2995 s = format (0, "action: %d", mp->action);
2997 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2999 eid = format (0, "%U", format_lisp_eid_vat,
3003 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3006 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3007 clib_net_to_host_u32 (mp->vni),
3009 mp->is_local ? "local" : "remote",
3010 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3011 clib_net_to_host_u16 (mp->key_id), mp->key);
3018 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3021 vat_main_t *vam = &vat_main;
3022 vat_json_node_t *node = 0;
3025 if (VAT_JSON_ARRAY != vam->json_tree.type)
3027 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3028 vat_json_init_array (&vam->json_tree);
3030 node = vat_json_array_add (&vam->json_tree);
3032 vat_json_init_object (node);
3033 if (~0 == mp->locator_set_index)
3034 vat_json_object_add_uint (node, "action", mp->action);
3036 vat_json_object_add_uint (node, "locator_set_index",
3037 clib_net_to_host_u32 (mp->locator_set_index));
3039 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3040 if (mp->eid_type == 3)
3042 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3043 vat_json_init_object (nsh_json);
3044 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3045 vat_json_object_add_uint (nsh_json, "spi",
3046 clib_net_to_host_u32 (nsh->spi));
3047 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3051 eid = format (0, "%U", format_lisp_eid_vat,
3055 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3057 vat_json_object_add_string_copy (node, "eid", eid);
3060 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3061 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3062 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3066 vat_json_object_add_uint (node, "key_id",
3067 clib_net_to_host_u16 (mp->key_id));
3068 vat_json_object_add_string_copy (node, "key", mp->key);
3073 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3075 vat_main_t *vam = &vat_main;
3076 u8 *seid = 0, *deid = 0;
3077 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3079 deid = format (0, "%U", format_lisp_eid_vat,
3080 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3082 seid = format (0, "%U", format_lisp_eid_vat,
3083 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3089 format_ip_address_fcn = format_ip4_address;
3091 format_ip_address_fcn = format_ip6_address;
3094 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3095 clib_net_to_host_u32 (mp->vni),
3097 format_ip_address_fcn, mp->lloc,
3098 format_ip_address_fcn, mp->rloc,
3099 clib_net_to_host_u32 (mp->pkt_count),
3100 clib_net_to_host_u32 (mp->bytes));
3107 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3109 struct in6_addr ip6;
3111 vat_main_t *vam = &vat_main;
3112 vat_json_node_t *node = 0;
3113 u8 *deid = 0, *seid = 0;
3115 if (VAT_JSON_ARRAY != vam->json_tree.type)
3117 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3118 vat_json_init_array (&vam->json_tree);
3120 node = vat_json_array_add (&vam->json_tree);
3122 vat_json_init_object (node);
3123 deid = format (0, "%U", format_lisp_eid_vat,
3124 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3126 seid = format (0, "%U", format_lisp_eid_vat,
3127 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3132 vat_json_object_add_string_copy (node, "seid", seid);
3133 vat_json_object_add_string_copy (node, "deid", deid);
3134 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3138 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3139 vat_json_object_add_ip4 (node, "lloc", ip4);
3140 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3141 vat_json_object_add_ip4 (node, "rloc", ip4);
3145 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3146 vat_json_object_add_ip6 (node, "lloc", ip6);
3147 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3148 vat_json_object_add_ip6 (node, "rloc", ip6);
3150 vat_json_object_add_uint (node, "pkt_count",
3151 clib_net_to_host_u32 (mp->pkt_count));
3152 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3159 vl_api_one_eid_table_map_details_t_handler
3160 (vl_api_one_eid_table_map_details_t * mp)
3162 vat_main_t *vam = &vat_main;
3164 u8 *line = format (0, "%=10d%=10d",
3165 clib_net_to_host_u32 (mp->vni),
3166 clib_net_to_host_u32 (mp->dp_table));
3167 print (vam->ofp, "%v", line);
3172 vl_api_one_eid_table_map_details_t_handler_json
3173 (vl_api_one_eid_table_map_details_t * mp)
3175 vat_main_t *vam = &vat_main;
3176 vat_json_node_t *node = NULL;
3178 if (VAT_JSON_ARRAY != vam->json_tree.type)
3180 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3181 vat_json_init_array (&vam->json_tree);
3183 node = vat_json_array_add (&vam->json_tree);
3184 vat_json_init_object (node);
3185 vat_json_object_add_uint (node, "dp_table",
3186 clib_net_to_host_u32 (mp->dp_table));
3187 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3191 vl_api_one_eid_table_vni_details_t_handler
3192 (vl_api_one_eid_table_vni_details_t * mp)
3194 vat_main_t *vam = &vat_main;
3196 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3197 print (vam->ofp, "%v", line);
3202 vl_api_one_eid_table_vni_details_t_handler_json
3203 (vl_api_one_eid_table_vni_details_t * mp)
3205 vat_main_t *vam = &vat_main;
3206 vat_json_node_t *node = NULL;
3208 if (VAT_JSON_ARRAY != vam->json_tree.type)
3210 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3211 vat_json_init_array (&vam->json_tree);
3213 node = vat_json_array_add (&vam->json_tree);
3214 vat_json_init_object (node);
3215 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3219 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3220 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3222 vat_main_t *vam = &vat_main;
3223 int retval = clib_net_to_host_u32 (mp->retval);
3225 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3226 print (vam->ofp, "fallback threshold value: %d", mp->value);
3228 vam->retval = retval;
3229 vam->result_ready = 1;
3233 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3234 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3236 vat_main_t *vam = &vat_main;
3237 vat_json_node_t _node, *node = &_node;
3238 int retval = clib_net_to_host_u32 (mp->retval);
3240 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3241 vat_json_init_object (node);
3242 vat_json_object_add_uint (node, "value", mp->value);
3244 vat_json_print (vam->ofp, node);
3245 vat_json_free (node);
3247 vam->retval = retval;
3248 vam->result_ready = 1;
3252 vl_api_show_one_map_register_state_reply_t_handler
3253 (vl_api_show_one_map_register_state_reply_t * mp)
3255 vat_main_t *vam = &vat_main;
3256 int retval = clib_net_to_host_u32 (mp->retval);
3258 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3260 vam->retval = retval;
3261 vam->result_ready = 1;
3265 vl_api_show_one_map_register_state_reply_t_handler_json
3266 (vl_api_show_one_map_register_state_reply_t * mp)
3268 vat_main_t *vam = &vat_main;
3269 vat_json_node_t _node, *node = &_node;
3270 int retval = clib_net_to_host_u32 (mp->retval);
3272 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3274 vat_json_init_object (node);
3275 vat_json_object_add_string_copy (node, "state", s);
3277 vat_json_print (vam->ofp, node);
3278 vat_json_free (node);
3280 vam->retval = retval;
3281 vam->result_ready = 1;
3286 vl_api_show_one_rloc_probe_state_reply_t_handler
3287 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3289 vat_main_t *vam = &vat_main;
3290 int retval = clib_net_to_host_u32 (mp->retval);
3295 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3297 vam->retval = retval;
3298 vam->result_ready = 1;
3302 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3303 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3305 vat_main_t *vam = &vat_main;
3306 vat_json_node_t _node, *node = &_node;
3307 int retval = clib_net_to_host_u32 (mp->retval);
3309 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3310 vat_json_init_object (node);
3311 vat_json_object_add_string_copy (node, "state", s);
3313 vat_json_print (vam->ofp, node);
3314 vat_json_free (node);
3316 vam->retval = retval;
3317 vam->result_ready = 1;
3322 vl_api_show_one_stats_enable_disable_reply_t_handler
3323 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3325 vat_main_t *vam = &vat_main;
3326 int retval = clib_net_to_host_u32 (mp->retval);
3331 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3333 vam->retval = retval;
3334 vam->result_ready = 1;
3338 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3339 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3341 vat_main_t *vam = &vat_main;
3342 vat_json_node_t _node, *node = &_node;
3343 int retval = clib_net_to_host_u32 (mp->retval);
3345 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3346 vat_json_init_object (node);
3347 vat_json_object_add_string_copy (node, "state", s);
3349 vat_json_print (vam->ofp, node);
3350 vat_json_free (node);
3352 vam->retval = retval;
3353 vam->result_ready = 1;
3358 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3360 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3361 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3362 e->vni = clib_net_to_host_u32 (e->vni);
3366 gpe_fwd_entries_get_reply_t_net_to_host
3367 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3371 mp->count = clib_net_to_host_u32 (mp->count);
3372 for (i = 0; i < mp->count; i++)
3374 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3379 format_gpe_encap_mode (u8 * s, va_list * args)
3381 u32 mode = va_arg (*args, u32);
3386 return format (s, "lisp");
3388 return format (s, "vxlan");
3394 vl_api_gpe_get_encap_mode_reply_t_handler
3395 (vl_api_gpe_get_encap_mode_reply_t * mp)
3397 vat_main_t *vam = &vat_main;
3399 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3400 vam->retval = ntohl (mp->retval);
3401 vam->result_ready = 1;
3405 vl_api_gpe_get_encap_mode_reply_t_handler_json
3406 (vl_api_gpe_get_encap_mode_reply_t * mp)
3408 vat_main_t *vam = &vat_main;
3409 vat_json_node_t node;
3411 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3412 vec_add1 (encap_mode, 0);
3414 vat_json_init_object (&node);
3415 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3417 vec_free (encap_mode);
3418 vat_json_print (vam->ofp, &node);
3419 vat_json_free (&node);
3421 vam->retval = ntohl (mp->retval);
3422 vam->result_ready = 1;
3426 vl_api_gpe_fwd_entry_path_details_t_handler
3427 (vl_api_gpe_fwd_entry_path_details_t * mp)
3429 vat_main_t *vam = &vat_main;
3430 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3432 if (mp->lcl_loc.is_ip4)
3433 format_ip_address_fcn = format_ip4_address;
3435 format_ip_address_fcn = format_ip6_address;
3437 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3438 format_ip_address_fcn, &mp->lcl_loc,
3439 format_ip_address_fcn, &mp->rmt_loc);
3443 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3445 struct in6_addr ip6;
3450 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3451 vat_json_object_add_ip4 (n, "address", ip4);
3455 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3456 vat_json_object_add_ip6 (n, "address", ip6);
3458 vat_json_object_add_uint (n, "weight", loc->weight);
3462 vl_api_gpe_fwd_entry_path_details_t_handler_json
3463 (vl_api_gpe_fwd_entry_path_details_t * mp)
3465 vat_main_t *vam = &vat_main;
3466 vat_json_node_t *node = NULL;
3467 vat_json_node_t *loc_node;
3469 if (VAT_JSON_ARRAY != vam->json_tree.type)
3471 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3472 vat_json_init_array (&vam->json_tree);
3474 node = vat_json_array_add (&vam->json_tree);
3475 vat_json_init_object (node);
3477 loc_node = vat_json_object_add (node, "local_locator");
3478 vat_json_init_object (loc_node);
3479 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3481 loc_node = vat_json_object_add (node, "remote_locator");
3482 vat_json_init_object (loc_node);
3483 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3487 vl_api_gpe_fwd_entries_get_reply_t_handler
3488 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3490 vat_main_t *vam = &vat_main;
3492 int retval = clib_net_to_host_u32 (mp->retval);
3493 vl_api_gpe_fwd_entry_t *e;
3498 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3500 for (i = 0; i < mp->count; i++)
3502 e = &mp->entries[i];
3503 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3504 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3505 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3509 vam->retval = retval;
3510 vam->result_ready = 1;
3514 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3515 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3518 vat_main_t *vam = &vat_main;
3519 vat_json_node_t *e = 0, root;
3521 int retval = clib_net_to_host_u32 (mp->retval);
3522 vl_api_gpe_fwd_entry_t *fwd;
3527 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3528 vat_json_init_array (&root);
3530 for (i = 0; i < mp->count; i++)
3532 e = vat_json_array_add (&root);
3533 fwd = &mp->entries[i];
3535 vat_json_init_object (e);
3536 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3537 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3538 vat_json_object_add_int (e, "vni", fwd->vni);
3539 vat_json_object_add_int (e, "action", fwd->action);
3541 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3542 fwd->leid_prefix_len);
3544 vat_json_object_add_string_copy (e, "leid", s);
3547 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3548 fwd->reid_prefix_len);
3550 vat_json_object_add_string_copy (e, "reid", s);
3554 vat_json_print (vam->ofp, &root);
3555 vat_json_free (&root);
3558 vam->retval = retval;
3559 vam->result_ready = 1;
3563 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3564 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3566 vat_main_t *vam = &vat_main;
3568 int retval = clib_net_to_host_u32 (mp->retval);
3569 vl_api_gpe_native_fwd_rpath_t *r;
3574 n = clib_net_to_host_u32 (mp->count);
3576 for (i = 0; i < n; i++)
3578 r = &mp->entries[i];
3579 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3580 clib_net_to_host_u32 (r->fib_index),
3581 clib_net_to_host_u32 (r->nh_sw_if_index),
3582 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3586 vam->retval = retval;
3587 vam->result_ready = 1;
3591 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3592 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3594 vat_main_t *vam = &vat_main;
3595 vat_json_node_t root, *e;
3597 int retval = clib_net_to_host_u32 (mp->retval);
3598 vl_api_gpe_native_fwd_rpath_t *r;
3604 n = clib_net_to_host_u32 (mp->count);
3605 vat_json_init_array (&root);
3607 for (i = 0; i < n; i++)
3609 e = vat_json_array_add (&root);
3610 vat_json_init_object (e);
3611 r = &mp->entries[i];
3613 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3616 vat_json_object_add_string_copy (e, "ip4", s);
3619 vat_json_object_add_uint (e, "fib_index",
3620 clib_net_to_host_u32 (r->fib_index));
3621 vat_json_object_add_uint (e, "nh_sw_if_index",
3622 clib_net_to_host_u32 (r->nh_sw_if_index));
3625 vat_json_print (vam->ofp, &root);
3626 vat_json_free (&root);
3629 vam->retval = retval;
3630 vam->result_ready = 1;
3634 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3635 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3637 vat_main_t *vam = &vat_main;
3639 int retval = clib_net_to_host_u32 (mp->retval);
3644 n = clib_net_to_host_u32 (mp->count);
3646 for (i = 0; i < n; i++)
3647 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3650 vam->retval = retval;
3651 vam->result_ready = 1;
3655 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3656 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3658 vat_main_t *vam = &vat_main;
3659 vat_json_node_t root;
3661 int retval = clib_net_to_host_u32 (mp->retval);
3666 n = clib_net_to_host_u32 (mp->count);
3667 vat_json_init_array (&root);
3669 for (i = 0; i < n; i++)
3670 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3672 vat_json_print (vam->ofp, &root);
3673 vat_json_free (&root);
3676 vam->retval = retval;
3677 vam->result_ready = 1;
3681 vl_api_one_ndp_entries_get_reply_t_handler
3682 (vl_api_one_ndp_entries_get_reply_t * mp)
3684 vat_main_t *vam = &vat_main;
3686 int retval = clib_net_to_host_u32 (mp->retval);
3691 n = clib_net_to_host_u32 (mp->count);
3693 for (i = 0; i < n; i++)
3694 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3695 format_ethernet_address, mp->entries[i].mac);
3698 vam->retval = retval;
3699 vam->result_ready = 1;
3703 vl_api_one_ndp_entries_get_reply_t_handler_json
3704 (vl_api_one_ndp_entries_get_reply_t * mp)
3707 vat_main_t *vam = &vat_main;
3708 vat_json_node_t *e = 0, root;
3710 int retval = clib_net_to_host_u32 (mp->retval);
3711 vl_api_one_ndp_entry_t *arp_entry;
3716 n = clib_net_to_host_u32 (mp->count);
3717 vat_json_init_array (&root);
3719 for (i = 0; i < n; i++)
3721 e = vat_json_array_add (&root);
3722 arp_entry = &mp->entries[i];
3724 vat_json_init_object (e);
3725 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3728 vat_json_object_add_string_copy (e, "mac", s);
3731 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3733 vat_json_object_add_string_copy (e, "ip6", s);
3737 vat_json_print (vam->ofp, &root);
3738 vat_json_free (&root);
3741 vam->retval = retval;
3742 vam->result_ready = 1;
3746 vl_api_one_l2_arp_entries_get_reply_t_handler
3747 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3749 vat_main_t *vam = &vat_main;
3751 int retval = clib_net_to_host_u32 (mp->retval);
3756 n = clib_net_to_host_u32 (mp->count);
3758 for (i = 0; i < n; i++)
3759 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3760 format_ethernet_address, mp->entries[i].mac);
3763 vam->retval = retval;
3764 vam->result_ready = 1;
3768 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3769 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3772 vat_main_t *vam = &vat_main;
3773 vat_json_node_t *e = 0, root;
3775 int retval = clib_net_to_host_u32 (mp->retval);
3776 vl_api_one_l2_arp_entry_t *arp_entry;
3781 n = clib_net_to_host_u32 (mp->count);
3782 vat_json_init_array (&root);
3784 for (i = 0; i < n; i++)
3786 e = vat_json_array_add (&root);
3787 arp_entry = &mp->entries[i];
3789 vat_json_init_object (e);
3790 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3793 vat_json_object_add_string_copy (e, "mac", s);
3796 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3798 vat_json_object_add_string_copy (e, "ip4", s);
3802 vat_json_print (vam->ofp, &root);
3803 vat_json_free (&root);
3806 vam->retval = retval;
3807 vam->result_ready = 1;
3811 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
3813 vat_main_t *vam = &vat_main;
3815 int retval = clib_net_to_host_u32 (mp->retval);
3820 n = clib_net_to_host_u32 (mp->count);
3822 for (i = 0; i < n; i++)
3824 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3828 vam->retval = retval;
3829 vam->result_ready = 1;
3833 vl_api_one_ndp_bd_get_reply_t_handler_json
3834 (vl_api_one_ndp_bd_get_reply_t * mp)
3836 vat_main_t *vam = &vat_main;
3837 vat_json_node_t root;
3839 int retval = clib_net_to_host_u32 (mp->retval);
3844 n = clib_net_to_host_u32 (mp->count);
3845 vat_json_init_array (&root);
3847 for (i = 0; i < n; i++)
3849 vat_json_array_add_uint (&root,
3850 clib_net_to_host_u32 (mp->bridge_domains[i]));
3853 vat_json_print (vam->ofp, &root);
3854 vat_json_free (&root);
3857 vam->retval = retval;
3858 vam->result_ready = 1;
3862 vl_api_one_l2_arp_bd_get_reply_t_handler
3863 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3865 vat_main_t *vam = &vat_main;
3867 int retval = clib_net_to_host_u32 (mp->retval);
3872 n = clib_net_to_host_u32 (mp->count);
3874 for (i = 0; i < n; i++)
3876 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3880 vam->retval = retval;
3881 vam->result_ready = 1;
3885 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3886 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3888 vat_main_t *vam = &vat_main;
3889 vat_json_node_t root;
3891 int retval = clib_net_to_host_u32 (mp->retval);
3896 n = clib_net_to_host_u32 (mp->count);
3897 vat_json_init_array (&root);
3899 for (i = 0; i < n; i++)
3901 vat_json_array_add_uint (&root,
3902 clib_net_to_host_u32 (mp->bridge_domains[i]));
3905 vat_json_print (vam->ofp, &root);
3906 vat_json_free (&root);
3909 vam->retval = retval;
3910 vam->result_ready = 1;
3914 vl_api_one_adjacencies_get_reply_t_handler
3915 (vl_api_one_adjacencies_get_reply_t * mp)
3917 vat_main_t *vam = &vat_main;
3919 int retval = clib_net_to_host_u32 (mp->retval);
3920 vl_api_one_adjacency_t *a;
3925 n = clib_net_to_host_u32 (mp->count);
3927 for (i = 0; i < n; i++)
3929 a = &mp->adjacencies[i];
3930 print (vam->ofp, "%U %40U",
3931 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3932 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3936 vam->retval = retval;
3937 vam->result_ready = 1;
3941 vl_api_one_adjacencies_get_reply_t_handler_json
3942 (vl_api_one_adjacencies_get_reply_t * mp)
3945 vat_main_t *vam = &vat_main;
3946 vat_json_node_t *e = 0, root;
3948 int retval = clib_net_to_host_u32 (mp->retval);
3949 vl_api_one_adjacency_t *a;
3954 n = clib_net_to_host_u32 (mp->count);
3955 vat_json_init_array (&root);
3957 for (i = 0; i < n; i++)
3959 e = vat_json_array_add (&root);
3960 a = &mp->adjacencies[i];
3962 vat_json_init_object (e);
3963 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
3964 a->leid_prefix_len);
3966 vat_json_object_add_string_copy (e, "leid", s);
3969 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
3970 a->reid_prefix_len);
3972 vat_json_object_add_string_copy (e, "reid", s);
3976 vat_json_print (vam->ofp, &root);
3977 vat_json_free (&root);
3980 vam->retval = retval;
3981 vam->result_ready = 1;
3985 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
3987 vat_main_t *vam = &vat_main;
3989 print (vam->ofp, "%=20U",
3990 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3995 vl_api_one_map_server_details_t_handler_json
3996 (vl_api_one_map_server_details_t * mp)
3998 vat_main_t *vam = &vat_main;
3999 vat_json_node_t *node = NULL;
4000 struct in6_addr ip6;
4003 if (VAT_JSON_ARRAY != vam->json_tree.type)
4005 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4006 vat_json_init_array (&vam->json_tree);
4008 node = vat_json_array_add (&vam->json_tree);
4010 vat_json_init_object (node);
4013 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4014 vat_json_object_add_ip6 (node, "map-server", ip6);
4018 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4019 vat_json_object_add_ip4 (node, "map-server", ip4);
4024 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4027 vat_main_t *vam = &vat_main;
4029 print (vam->ofp, "%=20U",
4030 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4035 vl_api_one_map_resolver_details_t_handler_json
4036 (vl_api_one_map_resolver_details_t * mp)
4038 vat_main_t *vam = &vat_main;
4039 vat_json_node_t *node = NULL;
4040 struct in6_addr ip6;
4043 if (VAT_JSON_ARRAY != vam->json_tree.type)
4045 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4046 vat_json_init_array (&vam->json_tree);
4048 node = vat_json_array_add (&vam->json_tree);
4050 vat_json_init_object (node);
4053 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4054 vat_json_object_add_ip6 (node, "map resolver", ip6);
4058 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4059 vat_json_object_add_ip4 (node, "map resolver", ip4);
4064 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4066 vat_main_t *vam = &vat_main;
4067 i32 retval = ntohl (mp->retval);
4071 print (vam->ofp, "feature: %s\ngpe: %s",
4072 mp->feature_status ? "enabled" : "disabled",
4073 mp->gpe_status ? "enabled" : "disabled");
4076 vam->retval = retval;
4077 vam->result_ready = 1;
4081 vl_api_show_one_status_reply_t_handler_json
4082 (vl_api_show_one_status_reply_t * mp)
4084 vat_main_t *vam = &vat_main;
4085 vat_json_node_t node;
4086 u8 *gpe_status = NULL;
4087 u8 *feature_status = NULL;
4089 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4090 feature_status = format (0, "%s",
4091 mp->feature_status ? "enabled" : "disabled");
4092 vec_add1 (gpe_status, 0);
4093 vec_add1 (feature_status, 0);
4095 vat_json_init_object (&node);
4096 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4097 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4099 vec_free (gpe_status);
4100 vec_free (feature_status);
4102 vat_json_print (vam->ofp, &node);
4103 vat_json_free (&node);
4105 vam->retval = ntohl (mp->retval);
4106 vam->result_ready = 1;
4110 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4111 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4113 vat_main_t *vam = &vat_main;
4114 i32 retval = ntohl (mp->retval);
4118 print (vam->ofp, "%=20s", mp->locator_set_name);
4121 vam->retval = retval;
4122 vam->result_ready = 1;
4126 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4127 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4129 vat_main_t *vam = &vat_main;
4130 vat_json_node_t *node = NULL;
4132 if (VAT_JSON_ARRAY != vam->json_tree.type)
4134 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4135 vat_json_init_array (&vam->json_tree);
4137 node = vat_json_array_add (&vam->json_tree);
4139 vat_json_init_object (node);
4140 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4142 vat_json_print (vam->ofp, node);
4143 vat_json_free (node);
4145 vam->retval = ntohl (mp->retval);
4146 vam->result_ready = 1;
4150 format_lisp_map_request_mode (u8 * s, va_list * args)
4152 u32 mode = va_arg (*args, u32);
4157 return format (0, "dst-only");
4159 return format (0, "src-dst");
4165 vl_api_show_one_map_request_mode_reply_t_handler
4166 (vl_api_show_one_map_request_mode_reply_t * mp)
4168 vat_main_t *vam = &vat_main;
4169 i32 retval = ntohl (mp->retval);
4173 u32 mode = mp->mode;
4174 print (vam->ofp, "map_request_mode: %U",
4175 format_lisp_map_request_mode, mode);
4178 vam->retval = retval;
4179 vam->result_ready = 1;
4183 vl_api_show_one_map_request_mode_reply_t_handler_json
4184 (vl_api_show_one_map_request_mode_reply_t * mp)
4186 vat_main_t *vam = &vat_main;
4187 vat_json_node_t node;
4192 s = format (0, "%U", format_lisp_map_request_mode, mode);
4195 vat_json_init_object (&node);
4196 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4197 vat_json_print (vam->ofp, &node);
4198 vat_json_free (&node);
4201 vam->retval = ntohl (mp->retval);
4202 vam->result_ready = 1;
4206 vl_api_one_show_xtr_mode_reply_t_handler
4207 (vl_api_one_show_xtr_mode_reply_t * mp)
4209 vat_main_t *vam = &vat_main;
4210 i32 retval = ntohl (mp->retval);
4214 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4217 vam->retval = retval;
4218 vam->result_ready = 1;
4222 vl_api_one_show_xtr_mode_reply_t_handler_json
4223 (vl_api_one_show_xtr_mode_reply_t * mp)
4225 vat_main_t *vam = &vat_main;
4226 vat_json_node_t node;
4229 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4230 vec_add1 (status, 0);
4232 vat_json_init_object (&node);
4233 vat_json_object_add_string_copy (&node, "status", status);
4237 vat_json_print (vam->ofp, &node);
4238 vat_json_free (&node);
4240 vam->retval = ntohl (mp->retval);
4241 vam->result_ready = 1;
4245 vl_api_one_show_pitr_mode_reply_t_handler
4246 (vl_api_one_show_pitr_mode_reply_t * mp)
4248 vat_main_t *vam = &vat_main;
4249 i32 retval = ntohl (mp->retval);
4253 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4256 vam->retval = retval;
4257 vam->result_ready = 1;
4261 vl_api_one_show_pitr_mode_reply_t_handler_json
4262 (vl_api_one_show_pitr_mode_reply_t * mp)
4264 vat_main_t *vam = &vat_main;
4265 vat_json_node_t node;
4268 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4269 vec_add1 (status, 0);
4271 vat_json_init_object (&node);
4272 vat_json_object_add_string_copy (&node, "status", status);
4276 vat_json_print (vam->ofp, &node);
4277 vat_json_free (&node);
4279 vam->retval = ntohl (mp->retval);
4280 vam->result_ready = 1;
4284 vl_api_one_show_petr_mode_reply_t_handler
4285 (vl_api_one_show_petr_mode_reply_t * mp)
4287 vat_main_t *vam = &vat_main;
4288 i32 retval = ntohl (mp->retval);
4292 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4295 vam->retval = retval;
4296 vam->result_ready = 1;
4300 vl_api_one_show_petr_mode_reply_t_handler_json
4301 (vl_api_one_show_petr_mode_reply_t * mp)
4303 vat_main_t *vam = &vat_main;
4304 vat_json_node_t node;
4307 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4308 vec_add1 (status, 0);
4310 vat_json_init_object (&node);
4311 vat_json_object_add_string_copy (&node, "status", status);
4315 vat_json_print (vam->ofp, &node);
4316 vat_json_free (&node);
4318 vam->retval = ntohl (mp->retval);
4319 vam->result_ready = 1;
4323 vl_api_show_one_use_petr_reply_t_handler
4324 (vl_api_show_one_use_petr_reply_t * mp)
4326 vat_main_t *vam = &vat_main;
4327 i32 retval = ntohl (mp->retval);
4331 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4334 print (vam->ofp, "Proxy-ETR address; %U",
4335 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4340 vam->retval = retval;
4341 vam->result_ready = 1;
4345 vl_api_show_one_use_petr_reply_t_handler_json
4346 (vl_api_show_one_use_petr_reply_t * mp)
4348 vat_main_t *vam = &vat_main;
4349 vat_json_node_t node;
4352 struct in6_addr ip6;
4354 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4355 vec_add1 (status, 0);
4357 vat_json_init_object (&node);
4358 vat_json_object_add_string_copy (&node, "status", status);
4363 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4364 vat_json_object_add_ip6 (&node, "address", ip6);
4368 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4369 vat_json_object_add_ip4 (&node, "address", ip4);
4375 vat_json_print (vam->ofp, &node);
4376 vat_json_free (&node);
4378 vam->retval = ntohl (mp->retval);
4379 vam->result_ready = 1;
4383 vl_api_show_one_nsh_mapping_reply_t_handler
4384 (vl_api_show_one_nsh_mapping_reply_t * mp)
4386 vat_main_t *vam = &vat_main;
4387 i32 retval = ntohl (mp->retval);
4391 print (vam->ofp, "%-20s%-16s",
4392 mp->is_set ? "set" : "not-set",
4393 mp->is_set ? (char *) mp->locator_set_name : "");
4396 vam->retval = retval;
4397 vam->result_ready = 1;
4401 vl_api_show_one_nsh_mapping_reply_t_handler_json
4402 (vl_api_show_one_nsh_mapping_reply_t * mp)
4404 vat_main_t *vam = &vat_main;
4405 vat_json_node_t node;
4408 status = format (0, "%s", mp->is_set ? "yes" : "no");
4409 vec_add1 (status, 0);
4411 vat_json_init_object (&node);
4412 vat_json_object_add_string_copy (&node, "is_set", status);
4415 vat_json_object_add_string_copy (&node, "locator_set",
4416 mp->locator_set_name);
4421 vat_json_print (vam->ofp, &node);
4422 vat_json_free (&node);
4424 vam->retval = ntohl (mp->retval);
4425 vam->result_ready = 1;
4429 vl_api_show_one_map_register_ttl_reply_t_handler
4430 (vl_api_show_one_map_register_ttl_reply_t * mp)
4432 vat_main_t *vam = &vat_main;
4433 i32 retval = ntohl (mp->retval);
4435 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4439 print (vam->ofp, "ttl: %u", mp->ttl);
4442 vam->retval = retval;
4443 vam->result_ready = 1;
4447 vl_api_show_one_map_register_ttl_reply_t_handler_json
4448 (vl_api_show_one_map_register_ttl_reply_t * mp)
4450 vat_main_t *vam = &vat_main;
4451 vat_json_node_t node;
4453 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4454 vat_json_init_object (&node);
4455 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4457 vat_json_print (vam->ofp, &node);
4458 vat_json_free (&node);
4460 vam->retval = ntohl (mp->retval);
4461 vam->result_ready = 1;
4465 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4467 vat_main_t *vam = &vat_main;
4468 i32 retval = ntohl (mp->retval);
4472 print (vam->ofp, "%-20s%-16s",
4473 mp->status ? "enabled" : "disabled",
4474 mp->status ? (char *) mp->locator_set_name : "");
4477 vam->retval = retval;
4478 vam->result_ready = 1;
4482 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4484 vat_main_t *vam = &vat_main;
4485 vat_json_node_t node;
4488 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4489 vec_add1 (status, 0);
4491 vat_json_init_object (&node);
4492 vat_json_object_add_string_copy (&node, "status", status);
4495 vat_json_object_add_string_copy (&node, "locator_set",
4496 mp->locator_set_name);
4501 vat_json_print (vam->ofp, &node);
4502 vat_json_free (&node);
4504 vam->retval = ntohl (mp->retval);
4505 vam->result_ready = 1;
4509 format_policer_type (u8 * s, va_list * va)
4511 u32 i = va_arg (*va, u32);
4513 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4514 s = format (s, "1r2c");
4515 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4516 s = format (s, "1r3c");
4517 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4518 s = format (s, "2r3c-2698");
4519 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4520 s = format (s, "2r3c-4115");
4521 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4522 s = format (s, "2r3c-mef5cf1");
4524 s = format (s, "ILLEGAL");
4529 format_policer_rate_type (u8 * s, va_list * va)
4531 u32 i = va_arg (*va, u32);
4533 if (i == SSE2_QOS_RATE_KBPS)
4534 s = format (s, "kbps");
4535 else if (i == SSE2_QOS_RATE_PPS)
4536 s = format (s, "pps");
4538 s = format (s, "ILLEGAL");
4543 format_policer_round_type (u8 * s, va_list * va)
4545 u32 i = va_arg (*va, u32);
4547 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4548 s = format (s, "closest");
4549 else if (i == SSE2_QOS_ROUND_TO_UP)
4550 s = format (s, "up");
4551 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4552 s = format (s, "down");
4554 s = format (s, "ILLEGAL");
4559 format_policer_action_type (u8 * s, va_list * va)
4561 u32 i = va_arg (*va, u32);
4563 if (i == SSE2_QOS_ACTION_DROP)
4564 s = format (s, "drop");
4565 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4566 s = format (s, "transmit");
4567 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4568 s = format (s, "mark-and-transmit");
4570 s = format (s, "ILLEGAL");
4575 format_dscp (u8 * s, va_list * va)
4577 u32 i = va_arg (*va, u32);
4582 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4586 return format (s, "ILLEGAL");
4588 s = format (s, "%s", t);
4593 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4595 vat_main_t *vam = &vat_main;
4596 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4598 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4599 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4601 conform_dscp_str = format (0, "");
4603 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4604 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4606 exceed_dscp_str = format (0, "");
4608 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4609 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4611 violate_dscp_str = format (0, "");
4613 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4614 "rate type %U, round type %U, %s rate, %s color-aware, "
4615 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4616 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4617 "conform action %U%s, exceed action %U%s, violate action %U%s",
4619 format_policer_type, mp->type,
4622 clib_net_to_host_u64 (mp->cb),
4623 clib_net_to_host_u64 (mp->eb),
4624 format_policer_rate_type, mp->rate_type,
4625 format_policer_round_type, mp->round_type,
4626 mp->single_rate ? "single" : "dual",
4627 mp->color_aware ? "is" : "not",
4628 ntohl (mp->cir_tokens_per_period),
4629 ntohl (mp->pir_tokens_per_period),
4631 ntohl (mp->current_limit),
4632 ntohl (mp->current_bucket),
4633 ntohl (mp->extended_limit),
4634 ntohl (mp->extended_bucket),
4635 clib_net_to_host_u64 (mp->last_update_time),
4636 format_policer_action_type, mp->conform_action_type,
4638 format_policer_action_type, mp->exceed_action_type,
4640 format_policer_action_type, mp->violate_action_type,
4643 vec_free (conform_dscp_str);
4644 vec_free (exceed_dscp_str);
4645 vec_free (violate_dscp_str);
4648 static void vl_api_policer_details_t_handler_json
4649 (vl_api_policer_details_t * mp)
4651 vat_main_t *vam = &vat_main;
4652 vat_json_node_t *node;
4653 u8 *rate_type_str, *round_type_str, *type_str;
4654 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4656 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4658 format (0, "%U", format_policer_round_type, mp->round_type);
4659 type_str = format (0, "%U", format_policer_type, mp->type);
4660 conform_action_str = format (0, "%U", format_policer_action_type,
4661 mp->conform_action_type);
4662 exceed_action_str = format (0, "%U", format_policer_action_type,
4663 mp->exceed_action_type);
4664 violate_action_str = format (0, "%U", format_policer_action_type,
4665 mp->violate_action_type);
4667 if (VAT_JSON_ARRAY != vam->json_tree.type)
4669 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4670 vat_json_init_array (&vam->json_tree);
4672 node = vat_json_array_add (&vam->json_tree);
4674 vat_json_init_object (node);
4675 vat_json_object_add_string_copy (node, "name", mp->name);
4676 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4677 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4678 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4679 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4680 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4681 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4682 vat_json_object_add_string_copy (node, "type", type_str);
4683 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4684 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4685 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4686 vat_json_object_add_uint (node, "cir_tokens_per_period",
4687 ntohl (mp->cir_tokens_per_period));
4688 vat_json_object_add_uint (node, "eir_tokens_per_period",
4689 ntohl (mp->pir_tokens_per_period));
4690 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4691 vat_json_object_add_uint (node, "current_bucket",
4692 ntohl (mp->current_bucket));
4693 vat_json_object_add_uint (node, "extended_limit",
4694 ntohl (mp->extended_limit));
4695 vat_json_object_add_uint (node, "extended_bucket",
4696 ntohl (mp->extended_bucket));
4697 vat_json_object_add_uint (node, "last_update_time",
4698 ntohl (mp->last_update_time));
4699 vat_json_object_add_string_copy (node, "conform_action",
4700 conform_action_str);
4701 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4703 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4704 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4705 vec_free (dscp_str);
4707 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4708 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4710 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4711 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4712 vec_free (dscp_str);
4714 vat_json_object_add_string_copy (node, "violate_action",
4715 violate_action_str);
4716 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4718 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4719 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4720 vec_free (dscp_str);
4723 vec_free (rate_type_str);
4724 vec_free (round_type_str);
4725 vec_free (type_str);
4726 vec_free (conform_action_str);
4727 vec_free (exceed_action_str);
4728 vec_free (violate_action_str);
4732 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4735 vat_main_t *vam = &vat_main;
4736 int i, count = ntohl (mp->count);
4739 print (vam->ofp, "classify table ids (%d) : ", count);
4740 for (i = 0; i < count; i++)
4742 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4743 print (vam->ofp, (i < count - 1) ? "," : "");
4745 vam->retval = ntohl (mp->retval);
4746 vam->result_ready = 1;
4750 vl_api_classify_table_ids_reply_t_handler_json
4751 (vl_api_classify_table_ids_reply_t * mp)
4753 vat_main_t *vam = &vat_main;
4754 int i, count = ntohl (mp->count);
4758 vat_json_node_t node;
4760 vat_json_init_object (&node);
4761 for (i = 0; i < count; i++)
4763 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4765 vat_json_print (vam->ofp, &node);
4766 vat_json_free (&node);
4768 vam->retval = ntohl (mp->retval);
4769 vam->result_ready = 1;
4773 vl_api_classify_table_by_interface_reply_t_handler
4774 (vl_api_classify_table_by_interface_reply_t * mp)
4776 vat_main_t *vam = &vat_main;
4779 table_id = ntohl (mp->l2_table_id);
4781 print (vam->ofp, "l2 table id : %d", table_id);
4783 print (vam->ofp, "l2 table id : No input ACL tables configured");
4784 table_id = ntohl (mp->ip4_table_id);
4786 print (vam->ofp, "ip4 table id : %d", table_id);
4788 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4789 table_id = ntohl (mp->ip6_table_id);
4791 print (vam->ofp, "ip6 table id : %d", table_id);
4793 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4794 vam->retval = ntohl (mp->retval);
4795 vam->result_ready = 1;
4799 vl_api_classify_table_by_interface_reply_t_handler_json
4800 (vl_api_classify_table_by_interface_reply_t * mp)
4802 vat_main_t *vam = &vat_main;
4803 vat_json_node_t node;
4805 vat_json_init_object (&node);
4807 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4808 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4809 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4811 vat_json_print (vam->ofp, &node);
4812 vat_json_free (&node);
4814 vam->retval = ntohl (mp->retval);
4815 vam->result_ready = 1;
4818 static void vl_api_policer_add_del_reply_t_handler
4819 (vl_api_policer_add_del_reply_t * mp)
4821 vat_main_t *vam = &vat_main;
4822 i32 retval = ntohl (mp->retval);
4823 if (vam->async_mode)
4825 vam->async_errors += (retval < 0);
4829 vam->retval = retval;
4830 vam->result_ready = 1;
4831 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4833 * Note: this is just barely thread-safe, depends on
4834 * the main thread spinning waiting for an answer...
4836 errmsg ("policer index %d", ntohl (mp->policer_index));
4840 static void vl_api_policer_add_del_reply_t_handler_json
4841 (vl_api_policer_add_del_reply_t * mp)
4843 vat_main_t *vam = &vat_main;
4844 vat_json_node_t node;
4846 vat_json_init_object (&node);
4847 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4848 vat_json_object_add_uint (&node, "policer_index",
4849 ntohl (mp->policer_index));
4851 vat_json_print (vam->ofp, &node);
4852 vat_json_free (&node);
4854 vam->retval = ntohl (mp->retval);
4855 vam->result_ready = 1;
4858 /* Format hex dump. */
4860 format_hex_bytes (u8 * s, va_list * va)
4862 u8 *bytes = va_arg (*va, u8 *);
4863 int n_bytes = va_arg (*va, int);
4866 /* Print short or long form depending on byte count. */
4867 uword short_form = n_bytes <= 32;
4868 u32 indent = format_get_indent (s);
4873 for (i = 0; i < n_bytes; i++)
4875 if (!short_form && (i % 32) == 0)
4876 s = format (s, "%08x: ", i);
4877 s = format (s, "%02x", bytes[i]);
4878 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4879 s = format (s, "\n%U", format_white_space, indent);
4886 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4889 vat_main_t *vam = &vat_main;
4890 i32 retval = ntohl (mp->retval);
4893 print (vam->ofp, "classify table info :");
4894 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4895 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4896 ntohl (mp->miss_next_index));
4897 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4898 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4899 ntohl (mp->match_n_vectors));
4900 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4901 ntohl (mp->mask_length));
4903 vam->retval = retval;
4904 vam->result_ready = 1;
4908 vl_api_classify_table_info_reply_t_handler_json
4909 (vl_api_classify_table_info_reply_t * mp)
4911 vat_main_t *vam = &vat_main;
4912 vat_json_node_t node;
4914 i32 retval = ntohl (mp->retval);
4917 vat_json_init_object (&node);
4919 vat_json_object_add_int (&node, "sessions",
4920 ntohl (mp->active_sessions));
4921 vat_json_object_add_int (&node, "nexttbl",
4922 ntohl (mp->next_table_index));
4923 vat_json_object_add_int (&node, "nextnode",
4924 ntohl (mp->miss_next_index));
4925 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4926 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4927 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4928 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4929 ntohl (mp->mask_length), 0);
4930 vat_json_object_add_string_copy (&node, "mask", s);
4932 vat_json_print (vam->ofp, &node);
4933 vat_json_free (&node);
4935 vam->retval = ntohl (mp->retval);
4936 vam->result_ready = 1;
4940 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4943 vat_main_t *vam = &vat_main;
4945 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4946 ntohl (mp->hit_next_index), ntohl (mp->advance),
4947 ntohl (mp->opaque_index));
4948 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4949 ntohl (mp->match_length));
4953 vl_api_classify_session_details_t_handler_json
4954 (vl_api_classify_session_details_t * mp)
4956 vat_main_t *vam = &vat_main;
4957 vat_json_node_t *node = NULL;
4959 if (VAT_JSON_ARRAY != vam->json_tree.type)
4961 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4962 vat_json_init_array (&vam->json_tree);
4964 node = vat_json_array_add (&vam->json_tree);
4966 vat_json_init_object (node);
4967 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
4968 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
4969 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
4971 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
4973 vat_json_object_add_string_copy (node, "match", s);
4976 static void vl_api_pg_create_interface_reply_t_handler
4977 (vl_api_pg_create_interface_reply_t * mp)
4979 vat_main_t *vam = &vat_main;
4981 vam->retval = ntohl (mp->retval);
4982 vam->result_ready = 1;
4985 static void vl_api_pg_create_interface_reply_t_handler_json
4986 (vl_api_pg_create_interface_reply_t * mp)
4988 vat_main_t *vam = &vat_main;
4989 vat_json_node_t node;
4991 i32 retval = ntohl (mp->retval);
4994 vat_json_init_object (&node);
4996 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
4998 vat_json_print (vam->ofp, &node);
4999 vat_json_free (&node);
5001 vam->retval = ntohl (mp->retval);
5002 vam->result_ready = 1;
5005 static void vl_api_policer_classify_details_t_handler
5006 (vl_api_policer_classify_details_t * mp)
5008 vat_main_t *vam = &vat_main;
5010 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5011 ntohl (mp->table_index));
5014 static void vl_api_policer_classify_details_t_handler_json
5015 (vl_api_policer_classify_details_t * mp)
5017 vat_main_t *vam = &vat_main;
5018 vat_json_node_t *node;
5020 if (VAT_JSON_ARRAY != vam->json_tree.type)
5022 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5023 vat_json_init_array (&vam->json_tree);
5025 node = vat_json_array_add (&vam->json_tree);
5027 vat_json_init_object (node);
5028 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5029 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5032 static void vl_api_flow_classify_details_t_handler
5033 (vl_api_flow_classify_details_t * mp)
5035 vat_main_t *vam = &vat_main;
5037 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5038 ntohl (mp->table_index));
5041 static void vl_api_flow_classify_details_t_handler_json
5042 (vl_api_flow_classify_details_t * mp)
5044 vat_main_t *vam = &vat_main;
5045 vat_json_node_t *node;
5047 if (VAT_JSON_ARRAY != vam->json_tree.type)
5049 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5050 vat_json_init_array (&vam->json_tree);
5052 node = vat_json_array_add (&vam->json_tree);
5054 vat_json_init_object (node);
5055 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5056 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5059 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5060 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5061 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5062 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5063 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5064 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5065 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5066 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5067 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5068 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5071 * Generate boilerplate reply handlers, which
5072 * dig the return value out of the xxx_reply_t API message,
5073 * stick it into vam->retval, and set vam->result_ready
5075 * Could also do this by pointing N message decode slots at
5076 * a single function, but that could break in subtle ways.
5079 #define foreach_standard_reply_retval_handler \
5080 _(sw_interface_set_flags_reply) \
5081 _(sw_interface_add_del_address_reply) \
5082 _(sw_interface_set_rx_mode_reply) \
5083 _(sw_interface_set_rx_placement_reply) \
5084 _(sw_interface_set_table_reply) \
5085 _(sw_interface_set_mpls_enable_reply) \
5086 _(sw_interface_set_vpath_reply) \
5087 _(sw_interface_set_vxlan_bypass_reply) \
5088 _(sw_interface_set_geneve_bypass_reply) \
5089 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5090 _(sw_interface_set_l2_bridge_reply) \
5091 _(sw_interface_set_bond_weight_reply) \
5092 _(bridge_domain_add_del_reply) \
5093 _(sw_interface_set_l2_xconnect_reply) \
5094 _(l2fib_add_del_reply) \
5095 _(l2fib_flush_int_reply) \
5096 _(l2fib_flush_bd_reply) \
5097 _(ip_route_add_del_reply) \
5098 _(ip_table_add_del_reply) \
5099 _(ip_mroute_add_del_reply) \
5100 _(mpls_route_add_del_reply) \
5101 _(mpls_table_add_del_reply) \
5102 _(mpls_ip_bind_unbind_reply) \
5103 _(bier_route_add_del_reply) \
5104 _(bier_table_add_del_reply) \
5105 _(proxy_arp_add_del_reply) \
5106 _(proxy_arp_intfc_enable_disable_reply) \
5107 _(sw_interface_set_unnumbered_reply) \
5108 _(ip_neighbor_add_del_reply) \
5109 _(reset_fib_reply) \
5110 _(dhcp_proxy_config_reply) \
5111 _(dhcp_proxy_set_vss_reply) \
5112 _(dhcp_client_config_reply) \
5113 _(set_ip_flow_hash_reply) \
5114 _(sw_interface_ip6_enable_disable_reply) \
5115 _(ip6nd_proxy_add_del_reply) \
5116 _(sw_interface_ip6nd_ra_prefix_reply) \
5117 _(sw_interface_ip6nd_ra_config_reply) \
5118 _(set_arp_neighbor_limit_reply) \
5119 _(l2_patch_add_del_reply) \
5120 _(sr_mpls_policy_add_reply) \
5121 _(sr_mpls_policy_mod_reply) \
5122 _(sr_mpls_policy_del_reply) \
5123 _(sr_policy_add_reply) \
5124 _(sr_policy_mod_reply) \
5125 _(sr_policy_del_reply) \
5126 _(sr_localsid_add_del_reply) \
5127 _(sr_steering_add_del_reply) \
5128 _(classify_add_del_session_reply) \
5129 _(classify_set_interface_ip_table_reply) \
5130 _(classify_set_interface_l2_tables_reply) \
5131 _(l2tpv3_set_tunnel_cookies_reply) \
5132 _(l2tpv3_interface_enable_disable_reply) \
5133 _(l2tpv3_set_lookup_key_reply) \
5134 _(l2_fib_clear_table_reply) \
5135 _(l2_interface_efp_filter_reply) \
5136 _(l2_interface_vlan_tag_rewrite_reply) \
5137 _(modify_vhost_user_if_reply) \
5138 _(delete_vhost_user_if_reply) \
5139 _(ip_probe_neighbor_reply) \
5140 _(ip_scan_neighbor_enable_disable_reply) \
5141 _(want_ip4_arp_events_reply) \
5142 _(want_ip6_nd_events_reply) \
5143 _(want_l2_macs_events_reply) \
5144 _(input_acl_set_interface_reply) \
5145 _(ipsec_spd_add_del_reply) \
5146 _(ipsec_interface_add_del_spd_reply) \
5147 _(ipsec_spd_entry_add_del_reply) \
5148 _(ipsec_sad_entry_add_del_reply) \
5149 _(ipsec_tunnel_if_add_del_reply) \
5150 _(ipsec_tunnel_if_set_sa_reply) \
5151 _(delete_loopback_reply) \
5152 _(bd_ip_mac_add_del_reply) \
5153 _(bd_ip_mac_flush_reply) \
5154 _(want_interface_events_reply) \
5155 _(cop_interface_enable_disable_reply) \
5156 _(cop_whitelist_enable_disable_reply) \
5157 _(sw_interface_clear_stats_reply) \
5158 _(ioam_enable_reply) \
5159 _(ioam_disable_reply) \
5160 _(one_add_del_locator_reply) \
5161 _(one_add_del_local_eid_reply) \
5162 _(one_add_del_remote_mapping_reply) \
5163 _(one_add_del_adjacency_reply) \
5164 _(one_add_del_map_resolver_reply) \
5165 _(one_add_del_map_server_reply) \
5166 _(one_enable_disable_reply) \
5167 _(one_rloc_probe_enable_disable_reply) \
5168 _(one_map_register_enable_disable_reply) \
5169 _(one_map_register_set_ttl_reply) \
5170 _(one_set_transport_protocol_reply) \
5171 _(one_map_register_fallback_threshold_reply) \
5172 _(one_pitr_set_locator_set_reply) \
5173 _(one_map_request_mode_reply) \
5174 _(one_add_del_map_request_itr_rlocs_reply) \
5175 _(one_eid_table_add_del_map_reply) \
5176 _(one_use_petr_reply) \
5177 _(one_stats_enable_disable_reply) \
5178 _(one_add_del_l2_arp_entry_reply) \
5179 _(one_add_del_ndp_entry_reply) \
5180 _(one_stats_flush_reply) \
5181 _(one_enable_disable_xtr_mode_reply) \
5182 _(one_enable_disable_pitr_mode_reply) \
5183 _(one_enable_disable_petr_mode_reply) \
5184 _(gpe_enable_disable_reply) \
5185 _(gpe_set_encap_mode_reply) \
5186 _(gpe_add_del_iface_reply) \
5187 _(gpe_add_del_native_fwd_rpath_reply) \
5188 _(af_packet_delete_reply) \
5189 _(policer_classify_set_interface_reply) \
5190 _(netmap_create_reply) \
5191 _(netmap_delete_reply) \
5192 _(set_ipfix_exporter_reply) \
5193 _(set_ipfix_classify_stream_reply) \
5194 _(ipfix_classify_table_add_del_reply) \
5195 _(flow_classify_set_interface_reply) \
5196 _(sw_interface_span_enable_disable_reply) \
5197 _(pg_capture_reply) \
5198 _(pg_enable_disable_reply) \
5199 _(ip_source_and_port_range_check_add_del_reply) \
5200 _(ip_source_and_port_range_check_interface_add_del_reply)\
5201 _(delete_subif_reply) \
5202 _(l2_interface_pbb_tag_rewrite_reply) \
5204 _(feature_enable_disable_reply) \
5205 _(sw_interface_tag_add_del_reply) \
5206 _(hw_interface_set_mtu_reply) \
5207 _(p2p_ethernet_add_reply) \
5208 _(p2p_ethernet_del_reply) \
5209 _(lldp_config_reply) \
5210 _(sw_interface_set_lldp_reply) \
5211 _(tcp_configure_src_addresses_reply) \
5212 _(session_rule_add_del_reply) \
5213 _(ip_container_proxy_add_del_reply) \
5214 _(output_acl_set_interface_reply) \
5215 _(qos_record_enable_disable_reply)
5218 static void vl_api_##n##_t_handler \
5219 (vl_api_##n##_t * mp) \
5221 vat_main_t * vam = &vat_main; \
5222 i32 retval = ntohl(mp->retval); \
5223 if (vam->async_mode) { \
5224 vam->async_errors += (retval < 0); \
5226 vam->retval = retval; \
5227 vam->result_ready = 1; \
5230 foreach_standard_reply_retval_handler;
5234 static void vl_api_##n##_t_handler_json \
5235 (vl_api_##n##_t * mp) \
5237 vat_main_t * vam = &vat_main; \
5238 vat_json_node_t node; \
5239 vat_json_init_object(&node); \
5240 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5241 vat_json_print(vam->ofp, &node); \
5242 vam->retval = ntohl(mp->retval); \
5243 vam->result_ready = 1; \
5245 foreach_standard_reply_retval_handler;
5249 * Table of message reply handlers, must include boilerplate handlers
5253 #define foreach_vpe_api_reply_msg \
5254 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5255 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5256 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5257 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5258 _(CONTROL_PING_REPLY, control_ping_reply) \
5259 _(CLI_REPLY, cli_reply) \
5260 _(CLI_INBAND_REPLY, cli_inband_reply) \
5261 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5262 sw_interface_add_del_address_reply) \
5263 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5264 _(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
5265 _(SW_INTERFACE_RX_PLACEMENT_DETAILS, sw_interface_rx_placement_details) \
5266 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5267 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5268 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5269 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5270 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5271 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5272 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5273 sw_interface_set_l2_xconnect_reply) \
5274 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5275 sw_interface_set_l2_bridge_reply) \
5276 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5277 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5278 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5279 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5280 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5281 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5282 _(L2_FLAGS_REPLY, l2_flags_reply) \
5283 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5284 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5285 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5286 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5287 _(VIRTIO_PCI_CREATE_REPLY, virtio_pci_create_reply) \
5288 _(VIRTIO_PCI_DELETE_REPLY, virtio_pci_delete_reply) \
5289 _(SW_INTERFACE_VIRTIO_PCI_DETAILS, sw_interface_virtio_pci_details) \
5290 _(BOND_CREATE_REPLY, bond_create_reply) \
5291 _(BOND_DELETE_REPLY, bond_delete_reply) \
5292 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5293 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5294 _(SW_INTERFACE_SET_BOND_WEIGHT_REPLY, sw_interface_set_bond_weight_reply) \
5295 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5296 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5297 _(IP_ROUTE_ADD_DEL_REPLY, ip_route_add_del_reply) \
5298 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5299 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5300 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5301 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5302 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5303 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5304 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5305 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5306 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5307 proxy_arp_intfc_enable_disable_reply) \
5308 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5309 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5310 sw_interface_set_unnumbered_reply) \
5311 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5312 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5313 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5314 _(RESET_FIB_REPLY, reset_fib_reply) \
5315 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5316 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5317 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5318 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5319 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5320 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5321 sw_interface_ip6_enable_disable_reply) \
5322 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5323 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5324 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5325 sw_interface_ip6nd_ra_prefix_reply) \
5326 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5327 sw_interface_ip6nd_ra_config_reply) \
5328 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5329 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5330 _(SR_MPLS_POLICY_ADD_REPLY, sr_mpls_policy_add_reply) \
5331 _(SR_MPLS_POLICY_MOD_REPLY, sr_mpls_policy_mod_reply) \
5332 _(SR_MPLS_POLICY_DEL_REPLY, sr_mpls_policy_del_reply) \
5333 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5334 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5335 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5336 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5337 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5338 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5339 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5340 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5341 classify_set_interface_ip_table_reply) \
5342 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5343 classify_set_interface_l2_tables_reply) \
5344 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5345 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5346 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5347 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5348 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5349 l2tpv3_interface_enable_disable_reply) \
5350 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5351 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5352 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5353 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5354 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5355 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5356 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5357 _(GRE_TUNNEL_ADD_DEL_REPLY, gre_tunnel_add_del_reply) \
5358 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5359 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5360 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5361 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5362 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5363 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5364 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5365 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5366 _(SHOW_VERSION_REPLY, show_version_reply) \
5367 _(SHOW_THREADS_REPLY, show_threads_reply) \
5368 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5369 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5370 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5371 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5372 _(IP_PROBE_NEIGHBOR_REPLY, ip_probe_neighbor_reply) \
5373 _(IP_SCAN_NEIGHBOR_ENABLE_DISABLE_REPLY, ip_scan_neighbor_enable_disable_reply) \
5374 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5375 _(IP4_ARP_EVENT, ip4_arp_event) \
5376 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5377 _(IP6_ND_EVENT, ip6_nd_event) \
5378 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5379 _(L2_MACS_EVENT, l2_macs_event) \
5380 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5381 _(IP_ADDRESS_DETAILS, ip_address_details) \
5382 _(IP_DETAILS, ip_details) \
5383 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5384 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5385 _(IPSEC_SPD_ENTRY_ADD_DEL_REPLY, ipsec_spd_entry_add_del_reply) \
5386 _(IPSEC_SAD_ENTRY_ADD_DEL_REPLY, ipsec_sad_entry_add_del_reply) \
5387 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5388 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5389 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5390 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5391 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5392 _(BD_IP_MAC_FLUSH_REPLY, bd_ip_mac_flush_reply) \
5393 _(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
5394 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5395 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5396 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5397 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5398 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5399 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5400 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5401 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5402 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5403 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5404 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5405 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5406 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5407 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5408 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5409 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5410 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5411 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5412 one_map_register_enable_disable_reply) \
5413 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5414 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5415 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5416 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5417 one_map_register_fallback_threshold_reply) \
5418 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5419 one_rloc_probe_enable_disable_reply) \
5420 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5421 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5422 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5423 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5424 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5425 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5426 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5427 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5428 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5429 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5430 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5431 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5432 _(ONE_STATS_DETAILS, one_stats_details) \
5433 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5434 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5435 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5436 show_one_stats_enable_disable_reply) \
5437 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5438 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5439 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5440 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5441 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5442 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5443 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5444 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5445 one_enable_disable_pitr_mode_reply) \
5446 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5447 one_enable_disable_petr_mode_reply) \
5448 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5449 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5450 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5451 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5452 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5453 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5454 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5455 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5456 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5457 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5458 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5459 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5460 gpe_add_del_native_fwd_rpath_reply) \
5461 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5462 gpe_fwd_entry_path_details) \
5463 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5464 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5465 one_add_del_map_request_itr_rlocs_reply) \
5466 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5467 one_get_map_request_itr_rlocs_reply) \
5468 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5469 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5470 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5471 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5472 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5473 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5474 show_one_map_register_state_reply) \
5475 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5476 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5477 show_one_map_register_fallback_threshold_reply) \
5478 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5479 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5480 _(AF_PACKET_DETAILS, af_packet_details) \
5481 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5482 _(POLICER_DETAILS, policer_details) \
5483 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5484 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5485 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5486 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5487 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5488 _(MPLS_TABLE_DETAILS, mpls_table_details) \
5489 _(MPLS_ROUTE_DETAILS, mpls_route_details) \
5490 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5491 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5492 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5493 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5494 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5495 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5496 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5497 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5498 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5499 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5500 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5501 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5502 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5503 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5504 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5505 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5506 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5507 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5508 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5509 ip_source_and_port_range_check_add_del_reply) \
5510 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5511 ip_source_and_port_range_check_interface_add_del_reply) \
5512 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5513 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5514 _(SET_PUNT_REPLY, set_punt_reply) \
5515 _(IP_TABLE_DETAILS, ip_table_details) \
5516 _(IP_ROUTE_DETAILS, ip_route_details) \
5517 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5518 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5519 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5520 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5521 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5522 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5523 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5524 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5525 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5526 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5527 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5528 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5529 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5530 _(SESSION_RULES_DETAILS, session_rules_details) \
5531 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5532 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5533 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply)
5535 #define foreach_standalone_reply_msg \
5536 _(SW_INTERFACE_EVENT, sw_interface_event)
5544 #define STR_VTR_OP_CASE(op) \
5545 case L2_VTR_ ## op: \
5549 str_vtr_op (u32 vtr_op)
5553 STR_VTR_OP_CASE (DISABLED);
5554 STR_VTR_OP_CASE (PUSH_1);
5555 STR_VTR_OP_CASE (PUSH_2);
5556 STR_VTR_OP_CASE (POP_1);
5557 STR_VTR_OP_CASE (POP_2);
5558 STR_VTR_OP_CASE (TRANSLATE_1_1);
5559 STR_VTR_OP_CASE (TRANSLATE_1_2);
5560 STR_VTR_OP_CASE (TRANSLATE_2_1);
5561 STR_VTR_OP_CASE (TRANSLATE_2_2);
5568 dump_sub_interface_table (vat_main_t * vam)
5570 const sw_interface_subif_t *sub = NULL;
5572 if (vam->json_output)
5575 ("JSON output supported only for VPE API calls and dump_stats_table");
5580 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5581 "Interface", "sw_if_index",
5582 "sub id", "dot1ad", "tags", "outer id",
5583 "inner id", "exact", "default", "outer any", "inner any");
5585 vec_foreach (sub, vam->sw_if_subif_table)
5588 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5589 sub->interface_name,
5591 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5592 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5593 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5594 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5595 if (sub->vtr_op != L2_VTR_DISABLED)
5598 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5599 "tag1: %d tag2: %d ]",
5600 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5601 sub->vtr_tag1, sub->vtr_tag2);
5609 name_sort_cmp (void *a1, void *a2)
5611 name_sort_t *n1 = a1;
5612 name_sort_t *n2 = a2;
5614 return strcmp ((char *) n1->name, (char *) n2->name);
5618 dump_interface_table (vat_main_t * vam)
5621 name_sort_t *nses = 0, *ns;
5623 if (vam->json_output)
5626 ("JSON output supported only for VPE API calls and dump_stats_table");
5631 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5633 vec_add2 (nses, ns, 1);
5634 ns->name = (u8 *)(p->key);
5635 ns->value = (u32) p->value[0];
5639 vec_sort_with_function (nses, name_sort_cmp);
5641 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5642 vec_foreach (ns, nses)
5644 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5651 dump_ip_table (vat_main_t * vam, int is_ipv6)
5653 const ip_details_t *det = NULL;
5654 const ip_address_details_t *address = NULL;
5657 print (vam->ofp, "%-12s", "sw_if_index");
5659 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5666 print (vam->ofp, "%-12d", i);
5667 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5672 vec_foreach (address, det->addr)
5676 is_ipv6 ? format_ip6_address : format_ip4_address,
5677 address->ip, address->prefix_length);
5685 dump_ipv4_table (vat_main_t * vam)
5687 if (vam->json_output)
5690 ("JSON output supported only for VPE API calls and dump_stats_table");
5694 return dump_ip_table (vam, 0);
5698 dump_ipv6_table (vat_main_t * vam)
5700 if (vam->json_output)
5703 ("JSON output supported only for VPE API calls and dump_stats_table");
5707 return dump_ip_table (vam, 1);
5711 * Pass CLI buffers directly in the CLI_INBAND API message,
5712 * instead of an additional shared memory area.
5715 exec_inband (vat_main_t * vam)
5717 vl_api_cli_inband_t *mp;
5718 unformat_input_t *i = vam->input;
5721 if (vec_len (i->buffer) == 0)
5724 if (vam->exec_mode == 0 && unformat (i, "mode"))
5729 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5736 * In order for the CLI command to work, it
5737 * must be a vector ending in \n, not a C-string ending
5740 u32 len = vec_len (vam->input->buffer);
5741 M2 (CLI_INBAND, mp, len);
5742 vl_api_to_api_string (len - 1, (const char *) vam->input->buffer, &mp->cmd);
5746 /* json responses may or may not include a useful reply... */
5747 if (vec_len (vam->cmd_reply))
5748 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
5753 exec (vat_main_t * vam)
5755 return exec_inband (vam);
5759 api_create_loopback (vat_main_t * vam)
5761 unformat_input_t *i = vam->input;
5762 vl_api_create_loopback_t *mp;
5763 vl_api_create_loopback_instance_t *mp_lbi;
5766 u8 is_specified = 0;
5767 u32 user_instance = 0;
5770 clib_memset (mac_address, 0, sizeof (mac_address));
5772 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5774 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5776 if (unformat (i, "instance %d", &user_instance))
5784 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5785 mp_lbi->is_specified = is_specified;
5787 mp_lbi->user_instance = htonl (user_instance);
5789 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5794 /* Construct the API message */
5795 M (CREATE_LOOPBACK, mp);
5797 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5806 api_delete_loopback (vat_main_t * vam)
5808 unformat_input_t *i = vam->input;
5809 vl_api_delete_loopback_t *mp;
5810 u32 sw_if_index = ~0;
5813 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5815 if (unformat (i, "sw_if_index %d", &sw_if_index))
5821 if (sw_if_index == ~0)
5823 errmsg ("missing sw_if_index");
5827 /* Construct the API message */
5828 M (DELETE_LOOPBACK, mp);
5829 mp->sw_if_index = ntohl (sw_if_index);
5837 api_want_interface_events (vat_main_t * vam)
5839 unformat_input_t *i = vam->input;
5840 vl_api_want_interface_events_t *mp;
5844 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5846 if (unformat (i, "enable"))
5848 else if (unformat (i, "disable"))
5856 errmsg ("missing enable|disable");
5860 M (WANT_INTERFACE_EVENTS, mp);
5861 mp->enable_disable = enable;
5863 vam->interface_event_display = enable;
5871 /* Note: non-static, called once to set up the initial intfc table */
5873 api_sw_interface_dump (vat_main_t * vam)
5875 vl_api_sw_interface_dump_t *mp;
5876 vl_api_control_ping_t *mp_ping;
5878 name_sort_t *nses = 0, *ns;
5879 sw_interface_subif_t *sub = NULL;
5882 /* Toss the old name table */
5884 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5886 vec_add2 (nses, ns, 1);
5887 ns->name = (u8 *)(p->key);
5888 ns->value = (u32) p->value[0];
5892 hash_free (vam->sw_if_index_by_interface_name);
5894 vec_foreach (ns, nses) vec_free (ns->name);
5898 vec_foreach (sub, vam->sw_if_subif_table)
5900 vec_free (sub->interface_name);
5902 vec_free (vam->sw_if_subif_table);
5904 /* recreate the interface name hash table */
5905 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5908 * Ask for all interface names. Otherwise, the epic catalog of
5909 * name filters becomes ridiculously long, and vat ends up needing
5910 * to be taught about new interface types.
5912 M (SW_INTERFACE_DUMP, mp);
5915 /* Use a control ping for synchronization */
5916 MPING (CONTROL_PING, mp_ping);
5924 api_sw_interface_set_flags (vat_main_t * vam)
5926 unformat_input_t *i = vam->input;
5927 vl_api_sw_interface_set_flags_t *mp;
5929 u8 sw_if_index_set = 0;
5933 /* Parse args required to build the message */
5934 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5936 if (unformat (i, "admin-up"))
5938 else if (unformat (i, "admin-down"))
5941 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5942 sw_if_index_set = 1;
5943 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5944 sw_if_index_set = 1;
5949 if (sw_if_index_set == 0)
5951 errmsg ("missing interface name or sw_if_index");
5955 /* Construct the API message */
5956 M (SW_INTERFACE_SET_FLAGS, mp);
5957 mp->sw_if_index = ntohl (sw_if_index);
5958 mp->flags = ntohl ((admin_up) ? IF_STATUS_API_FLAG_ADMIN_UP : 0);
5963 /* Wait for a reply, return the good/bad news... */
5969 api_sw_interface_set_rx_mode (vat_main_t * vam)
5971 unformat_input_t *i = vam->input;
5972 vl_api_sw_interface_set_rx_mode_t *mp;
5974 u8 sw_if_index_set = 0;
5976 u8 queue_id_valid = 0;
5978 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
5980 /* Parse args required to build the message */
5981 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5983 if (unformat (i, "queue %d", &queue_id))
5985 else if (unformat (i, "polling"))
5986 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
5987 else if (unformat (i, "interrupt"))
5988 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
5989 else if (unformat (i, "adaptive"))
5990 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
5992 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5993 sw_if_index_set = 1;
5994 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5995 sw_if_index_set = 1;
6000 if (sw_if_index_set == 0)
6002 errmsg ("missing interface name or sw_if_index");
6005 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6007 errmsg ("missing rx-mode");
6011 /* Construct the API message */
6012 M (SW_INTERFACE_SET_RX_MODE, mp);
6013 mp->sw_if_index = ntohl (sw_if_index);
6014 mp->mode = (vl_api_rx_mode_t) mode;
6015 mp->queue_id_valid = queue_id_valid;
6016 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6021 /* Wait for a reply, return the good/bad news... */
6027 api_sw_interface_set_rx_placement (vat_main_t * vam)
6029 unformat_input_t *i = vam->input;
6030 vl_api_sw_interface_set_rx_placement_t *mp;
6032 u8 sw_if_index_set = 0;
6035 u32 queue_id, thread_index;
6037 /* Parse args required to build the message */
6038 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6040 if (unformat (i, "queue %d", &queue_id))
6042 else if (unformat (i, "main"))
6044 else if (unformat (i, "worker %d", &thread_index))
6047 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6048 sw_if_index_set = 1;
6049 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6050 sw_if_index_set = 1;
6055 if (sw_if_index_set == 0)
6057 errmsg ("missing interface name or sw_if_index");
6063 /* Construct the API message */
6064 M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
6065 mp->sw_if_index = ntohl (sw_if_index);
6066 mp->worker_id = ntohl (thread_index);
6067 mp->queue_id = ntohl (queue_id);
6068 mp->is_main = is_main;
6072 /* Wait for a reply, return the good/bad news... */
6077 static void vl_api_sw_interface_rx_placement_details_t_handler
6078 (vl_api_sw_interface_rx_placement_details_t * mp)
6080 vat_main_t *vam = &vat_main;
6081 u32 worker_id = ntohl (mp->worker_id);
6084 "\n%-11d %-11s %-6d %-5d %-9s",
6085 ntohl (mp->sw_if_index), (worker_id == 0) ? "main" : "worker",
6086 worker_id, ntohl (mp->queue_id),
6088 1) ? "polling" : ((mp->mode == 2) ? "interrupt" : "adaptive"));
6091 static void vl_api_sw_interface_rx_placement_details_t_handler_json
6092 (vl_api_sw_interface_rx_placement_details_t * mp)
6094 vat_main_t *vam = &vat_main;
6095 vat_json_node_t *node = NULL;
6097 if (VAT_JSON_ARRAY != vam->json_tree.type)
6099 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
6100 vat_json_init_array (&vam->json_tree);
6102 node = vat_json_array_add (&vam->json_tree);
6104 vat_json_init_object (node);
6105 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
6106 vat_json_object_add_uint (node, "worker_id", ntohl (mp->worker_id));
6107 vat_json_object_add_uint (node, "queue_id", ntohl (mp->queue_id));
6108 vat_json_object_add_uint (node, "mode", mp->mode);
6112 api_sw_interface_rx_placement_dump (vat_main_t * vam)
6114 unformat_input_t *i = vam->input;
6115 vl_api_sw_interface_rx_placement_dump_t *mp;
6116 vl_api_control_ping_t *mp_ping;
6119 u8 sw_if_index_set = 0;
6121 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6123 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6125 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6132 "\n%-11s %-11s %-6s %-5s %-4s",
6133 "sw_if_index", "main/worker", "thread", "queue", "mode");
6135 /* Dump Interface rx placement */
6136 M (SW_INTERFACE_RX_PLACEMENT_DUMP, mp);
6138 if (sw_if_index_set)
6139 mp->sw_if_index = htonl (sw_if_index);
6141 mp->sw_if_index = ~0;
6145 /* Use a control ping for synchronization */
6146 MPING (CONTROL_PING, mp_ping);
6154 api_sw_interface_clear_stats (vat_main_t * vam)
6156 unformat_input_t *i = vam->input;
6157 vl_api_sw_interface_clear_stats_t *mp;
6159 u8 sw_if_index_set = 0;
6162 /* Parse args required to build the message */
6163 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6165 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6166 sw_if_index_set = 1;
6167 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6168 sw_if_index_set = 1;
6173 /* Construct the API message */
6174 M (SW_INTERFACE_CLEAR_STATS, mp);
6176 if (sw_if_index_set == 1)
6177 mp->sw_if_index = ntohl (sw_if_index);
6179 mp->sw_if_index = ~0;
6184 /* Wait for a reply, return the good/bad news... */
6190 api_sw_interface_add_del_address (vat_main_t * vam)
6192 unformat_input_t *i = vam->input;
6193 vl_api_sw_interface_add_del_address_t *mp;
6195 u8 sw_if_index_set = 0;
6196 u8 is_add = 1, del_all = 0;
6197 u32 address_length = 0;
6198 u8 v4_address_set = 0;
6199 u8 v6_address_set = 0;
6200 ip4_address_t v4address;
6201 ip6_address_t v6address;
6204 /* Parse args required to build the message */
6205 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6207 if (unformat (i, "del-all"))
6209 else if (unformat (i, "del"))
6212 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6213 sw_if_index_set = 1;
6214 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6215 sw_if_index_set = 1;
6216 else if (unformat (i, "%U/%d",
6217 unformat_ip4_address, &v4address, &address_length))
6219 else if (unformat (i, "%U/%d",
6220 unformat_ip6_address, &v6address, &address_length))
6226 if (sw_if_index_set == 0)
6228 errmsg ("missing interface name or sw_if_index");
6231 if (v4_address_set && v6_address_set)
6233 errmsg ("both v4 and v6 addresses set");
6236 if (!v4_address_set && !v6_address_set && !del_all)
6238 errmsg ("no addresses set");
6242 /* Construct the API message */
6243 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6245 mp->sw_if_index = ntohl (sw_if_index);
6246 mp->is_add = is_add;
6247 mp->del_all = del_all;
6250 mp->prefix.address.af = ADDRESS_IP6;
6251 clib_memcpy (mp->prefix.address.un.ip6, &v6address, sizeof (v6address));
6255 mp->prefix.address.af = ADDRESS_IP4;
6256 clib_memcpy (mp->prefix.address.un.ip4, &v4address, sizeof (v4address));
6258 mp->prefix.len = address_length;
6263 /* Wait for a reply, return good/bad news */
6269 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6271 unformat_input_t *i = vam->input;
6272 vl_api_sw_interface_set_mpls_enable_t *mp;
6274 u8 sw_if_index_set = 0;
6278 /* Parse args required to build the message */
6279 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6281 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6282 sw_if_index_set = 1;
6283 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6284 sw_if_index_set = 1;
6285 else if (unformat (i, "disable"))
6287 else if (unformat (i, "dis"))
6293 if (sw_if_index_set == 0)
6295 errmsg ("missing interface name or sw_if_index");
6299 /* Construct the API message */
6300 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6302 mp->sw_if_index = ntohl (sw_if_index);
6303 mp->enable = enable;
6308 /* Wait for a reply... */
6314 api_sw_interface_set_table (vat_main_t * vam)
6316 unformat_input_t *i = vam->input;
6317 vl_api_sw_interface_set_table_t *mp;
6318 u32 sw_if_index, vrf_id = 0;
6319 u8 sw_if_index_set = 0;
6323 /* Parse args required to build the message */
6324 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6326 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6327 sw_if_index_set = 1;
6328 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6329 sw_if_index_set = 1;
6330 else if (unformat (i, "vrf %d", &vrf_id))
6332 else if (unformat (i, "ipv6"))
6338 if (sw_if_index_set == 0)
6340 errmsg ("missing interface name or sw_if_index");
6344 /* Construct the API message */
6345 M (SW_INTERFACE_SET_TABLE, mp);
6347 mp->sw_if_index = ntohl (sw_if_index);
6348 mp->is_ipv6 = is_ipv6;
6349 mp->vrf_id = ntohl (vrf_id);
6354 /* Wait for a reply... */
6359 static void vl_api_sw_interface_get_table_reply_t_handler
6360 (vl_api_sw_interface_get_table_reply_t * mp)
6362 vat_main_t *vam = &vat_main;
6364 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6366 vam->retval = ntohl (mp->retval);
6367 vam->result_ready = 1;
6371 static void vl_api_sw_interface_get_table_reply_t_handler_json
6372 (vl_api_sw_interface_get_table_reply_t * mp)
6374 vat_main_t *vam = &vat_main;
6375 vat_json_node_t node;
6377 vat_json_init_object (&node);
6378 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6379 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6381 vat_json_print (vam->ofp, &node);
6382 vat_json_free (&node);
6384 vam->retval = ntohl (mp->retval);
6385 vam->result_ready = 1;
6389 api_sw_interface_get_table (vat_main_t * vam)
6391 unformat_input_t *i = vam->input;
6392 vl_api_sw_interface_get_table_t *mp;
6394 u8 sw_if_index_set = 0;
6398 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6400 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6401 sw_if_index_set = 1;
6402 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6403 sw_if_index_set = 1;
6404 else if (unformat (i, "ipv6"))
6410 if (sw_if_index_set == 0)
6412 errmsg ("missing interface name or sw_if_index");
6416 M (SW_INTERFACE_GET_TABLE, mp);
6417 mp->sw_if_index = htonl (sw_if_index);
6418 mp->is_ipv6 = is_ipv6;
6426 api_sw_interface_set_vpath (vat_main_t * vam)
6428 unformat_input_t *i = vam->input;
6429 vl_api_sw_interface_set_vpath_t *mp;
6430 u32 sw_if_index = 0;
6431 u8 sw_if_index_set = 0;
6435 /* Parse args required to build the message */
6436 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6438 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6439 sw_if_index_set = 1;
6440 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6441 sw_if_index_set = 1;
6442 else if (unformat (i, "enable"))
6444 else if (unformat (i, "disable"))
6450 if (sw_if_index_set == 0)
6452 errmsg ("missing interface name or sw_if_index");
6456 /* Construct the API message */
6457 M (SW_INTERFACE_SET_VPATH, mp);
6459 mp->sw_if_index = ntohl (sw_if_index);
6460 mp->enable = is_enable;
6465 /* Wait for a reply... */
6471 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6473 unformat_input_t *i = vam->input;
6474 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6475 u32 sw_if_index = 0;
6476 u8 sw_if_index_set = 0;
6481 /* Parse args required to build the message */
6482 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6484 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6485 sw_if_index_set = 1;
6486 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6487 sw_if_index_set = 1;
6488 else if (unformat (i, "enable"))
6490 else if (unformat (i, "disable"))
6492 else if (unformat (i, "ip4"))
6494 else if (unformat (i, "ip6"))
6500 if (sw_if_index_set == 0)
6502 errmsg ("missing interface name or sw_if_index");
6506 /* Construct the API message */
6507 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6509 mp->sw_if_index = ntohl (sw_if_index);
6510 mp->enable = is_enable;
6511 mp->is_ipv6 = is_ipv6;
6516 /* Wait for a reply... */
6522 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6524 unformat_input_t *i = vam->input;
6525 vl_api_sw_interface_set_geneve_bypass_t *mp;
6526 u32 sw_if_index = 0;
6527 u8 sw_if_index_set = 0;
6532 /* Parse args required to build the message */
6533 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6535 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6536 sw_if_index_set = 1;
6537 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6538 sw_if_index_set = 1;
6539 else if (unformat (i, "enable"))
6541 else if (unformat (i, "disable"))
6543 else if (unformat (i, "ip4"))
6545 else if (unformat (i, "ip6"))
6551 if (sw_if_index_set == 0)
6553 errmsg ("missing interface name or sw_if_index");
6557 /* Construct the API message */
6558 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6560 mp->sw_if_index = ntohl (sw_if_index);
6561 mp->enable = is_enable;
6562 mp->is_ipv6 = is_ipv6;
6567 /* Wait for a reply... */
6573 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6575 unformat_input_t *i = vam->input;
6576 vl_api_sw_interface_set_l2_xconnect_t *mp;
6578 u8 rx_sw_if_index_set = 0;
6580 u8 tx_sw_if_index_set = 0;
6584 /* Parse args required to build the message */
6585 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6587 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6588 rx_sw_if_index_set = 1;
6589 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6590 tx_sw_if_index_set = 1;
6591 else if (unformat (i, "rx"))
6593 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6595 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6597 rx_sw_if_index_set = 1;
6602 else if (unformat (i, "tx"))
6604 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6606 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6608 tx_sw_if_index_set = 1;
6613 else if (unformat (i, "enable"))
6615 else if (unformat (i, "disable"))
6621 if (rx_sw_if_index_set == 0)
6623 errmsg ("missing rx interface name or rx_sw_if_index");
6627 if (enable && (tx_sw_if_index_set == 0))
6629 errmsg ("missing tx interface name or tx_sw_if_index");
6633 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6635 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6636 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6637 mp->enable = enable;
6645 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6647 unformat_input_t *i = vam->input;
6648 vl_api_sw_interface_set_l2_bridge_t *mp;
6649 vl_api_l2_port_type_t port_type;
6651 u8 rx_sw_if_index_set = 0;
6658 port_type = L2_API_PORT_TYPE_NORMAL;
6660 /* Parse args required to build the message */
6661 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6663 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6664 rx_sw_if_index_set = 1;
6665 else if (unformat (i, "bd_id %d", &bd_id))
6669 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6670 rx_sw_if_index_set = 1;
6671 else if (unformat (i, "shg %d", &shg))
6673 else if (unformat (i, "bvi"))
6674 port_type = L2_API_PORT_TYPE_BVI;
6675 else if (unformat (i, "uu-fwd"))
6676 port_type = L2_API_PORT_TYPE_UU_FWD;
6677 else if (unformat (i, "enable"))
6679 else if (unformat (i, "disable"))
6685 if (rx_sw_if_index_set == 0)
6687 errmsg ("missing rx interface name or sw_if_index");
6691 if (enable && (bd_id_set == 0))
6693 errmsg ("missing bridge domain");
6697 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6699 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6700 mp->bd_id = ntohl (bd_id);
6702 mp->port_type = ntohl (port_type);
6703 mp->enable = enable;
6711 api_bridge_domain_dump (vat_main_t * vam)
6713 unformat_input_t *i = vam->input;
6714 vl_api_bridge_domain_dump_t *mp;
6715 vl_api_control_ping_t *mp_ping;
6719 /* Parse args required to build the message */
6720 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6722 if (unformat (i, "bd_id %d", &bd_id))
6728 M (BRIDGE_DOMAIN_DUMP, mp);
6729 mp->bd_id = ntohl (bd_id);
6732 /* Use a control ping for synchronization */
6733 MPING (CONTROL_PING, mp_ping);
6741 api_bridge_domain_add_del (vat_main_t * vam)
6743 unformat_input_t *i = vam->input;
6744 vl_api_bridge_domain_add_del_t *mp;
6747 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6752 /* Parse args required to build the message */
6753 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6755 if (unformat (i, "bd_id %d", &bd_id))
6757 else if (unformat (i, "flood %d", &flood))
6759 else if (unformat (i, "uu-flood %d", &uu_flood))
6761 else if (unformat (i, "forward %d", &forward))
6763 else if (unformat (i, "learn %d", &learn))
6765 else if (unformat (i, "arp-term %d", &arp_term))
6767 else if (unformat (i, "mac-age %d", &mac_age))
6769 else if (unformat (i, "bd-tag %s", &bd_tag))
6771 else if (unformat (i, "del"))
6774 flood = uu_flood = forward = learn = 0;
6782 errmsg ("missing bridge domain");
6789 errmsg ("mac age must be less than 256 ");
6794 if ((bd_tag) && (vec_len (bd_tag) > 63))
6796 errmsg ("bd-tag cannot be longer than 63");
6801 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6803 mp->bd_id = ntohl (bd_id);
6805 mp->uu_flood = uu_flood;
6806 mp->forward = forward;
6808 mp->arp_term = arp_term;
6809 mp->is_add = is_add;
6810 mp->mac_age = (u8) mac_age;
6813 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
6814 mp->bd_tag[vec_len (bd_tag)] = 0;
6825 api_l2fib_flush_bd (vat_main_t * vam)
6827 unformat_input_t *i = vam->input;
6828 vl_api_l2fib_flush_bd_t *mp;
6832 /* Parse args required to build the message */
6833 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6835 if (unformat (i, "bd_id %d", &bd_id));
6842 errmsg ("missing bridge domain");
6846 M (L2FIB_FLUSH_BD, mp);
6848 mp->bd_id = htonl (bd_id);
6856 api_l2fib_flush_int (vat_main_t * vam)
6858 unformat_input_t *i = vam->input;
6859 vl_api_l2fib_flush_int_t *mp;
6860 u32 sw_if_index = ~0;
6863 /* Parse args required to build the message */
6864 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6866 if (unformat (i, "sw_if_index %d", &sw_if_index));
6868 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6873 if (sw_if_index == ~0)
6875 errmsg ("missing interface name or sw_if_index");
6879 M (L2FIB_FLUSH_INT, mp);
6881 mp->sw_if_index = ntohl (sw_if_index);
6889 api_l2fib_add_del (vat_main_t * vam)
6891 unformat_input_t *i = vam->input;
6892 vl_api_l2fib_add_del_t *mp;
6898 u32 sw_if_index = 0;
6899 u8 sw_if_index_set = 0;
6908 /* Parse args required to build the message */
6909 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6911 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
6913 else if (unformat (i, "bd_id %d", &bd_id))
6915 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6916 sw_if_index_set = 1;
6917 else if (unformat (i, "sw_if"))
6919 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6922 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6923 sw_if_index_set = 1;
6928 else if (unformat (i, "static"))
6930 else if (unformat (i, "filter"))
6935 else if (unformat (i, "bvi"))
6940 else if (unformat (i, "del"))
6942 else if (unformat (i, "count %d", &count))
6950 errmsg ("missing mac address");
6956 errmsg ("missing bridge domain");
6960 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
6962 errmsg ("missing interface name or sw_if_index");
6968 /* Turn on async mode */
6969 vam->async_mode = 1;
6970 vam->async_errors = 0;
6971 before = vat_time_now (vam);
6974 for (j = 0; j < count; j++)
6976 M (L2FIB_ADD_DEL, mp);
6978 clib_memcpy (mp->mac, mac, 6);
6979 mp->bd_id = ntohl (bd_id);
6980 mp->is_add = is_add;
6981 mp->sw_if_index = ntohl (sw_if_index);
6985 mp->static_mac = static_mac;
6986 mp->filter_mac = filter_mac;
6987 mp->bvi_mac = bvi_mac;
6989 increment_mac_address (mac);
6996 vl_api_control_ping_t *mp_ping;
6999 /* Shut off async mode */
7000 vam->async_mode = 0;
7002 MPING (CONTROL_PING, mp_ping);
7005 timeout = vat_time_now (vam) + 1.0;
7006 while (vat_time_now (vam) < timeout)
7007 if (vam->result_ready == 1)
7012 if (vam->retval == -99)
7015 if (vam->async_errors > 0)
7017 errmsg ("%d asynchronous errors", vam->async_errors);
7020 vam->async_errors = 0;
7021 after = vat_time_now (vam);
7023 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7024 count, after - before, count / (after - before));
7030 /* Wait for a reply... */
7034 /* Return the good/bad news */
7035 return (vam->retval);
7039 api_bridge_domain_set_mac_age (vat_main_t * vam)
7041 unformat_input_t *i = vam->input;
7042 vl_api_bridge_domain_set_mac_age_t *mp;
7047 /* Parse args required to build the message */
7048 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7050 if (unformat (i, "bd_id %d", &bd_id));
7051 else if (unformat (i, "mac-age %d", &mac_age));
7058 errmsg ("missing bridge domain");
7064 errmsg ("mac age must be less than 256 ");
7068 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7070 mp->bd_id = htonl (bd_id);
7071 mp->mac_age = (u8) mac_age;
7079 api_l2_flags (vat_main_t * vam)
7081 unformat_input_t *i = vam->input;
7082 vl_api_l2_flags_t *mp;
7085 u8 sw_if_index_set = 0;
7089 /* Parse args required to build the message */
7090 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7092 if (unformat (i, "sw_if_index %d", &sw_if_index))
7093 sw_if_index_set = 1;
7094 else if (unformat (i, "sw_if"))
7096 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7099 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7100 sw_if_index_set = 1;
7105 else if (unformat (i, "learn"))
7107 else if (unformat (i, "forward"))
7109 else if (unformat (i, "flood"))
7111 else if (unformat (i, "uu-flood"))
7112 flags |= L2_UU_FLOOD;
7113 else if (unformat (i, "arp-term"))
7114 flags |= L2_ARP_TERM;
7115 else if (unformat (i, "off"))
7117 else if (unformat (i, "disable"))
7123 if (sw_if_index_set == 0)
7125 errmsg ("missing interface name or sw_if_index");
7131 mp->sw_if_index = ntohl (sw_if_index);
7132 mp->feature_bitmap = ntohl (flags);
7133 mp->is_set = is_set;
7141 api_bridge_flags (vat_main_t * vam)
7143 unformat_input_t *i = vam->input;
7144 vl_api_bridge_flags_t *mp;
7148 bd_flags_t flags = 0;
7151 /* Parse args required to build the message */
7152 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7154 if (unformat (i, "bd_id %d", &bd_id))
7156 else if (unformat (i, "learn"))
7157 flags |= BRIDGE_API_FLAG_LEARN;
7158 else if (unformat (i, "forward"))
7159 flags |= BRIDGE_API_FLAG_FWD;
7160 else if (unformat (i, "flood"))
7161 flags |= BRIDGE_API_FLAG_FLOOD;
7162 else if (unformat (i, "uu-flood"))
7163 flags |= BRIDGE_API_FLAG_UU_FLOOD;
7164 else if (unformat (i, "arp-term"))
7165 flags |= BRIDGE_API_FLAG_ARP_TERM;
7166 else if (unformat (i, "off"))
7168 else if (unformat (i, "disable"))
7176 errmsg ("missing bridge domain");
7180 M (BRIDGE_FLAGS, mp);
7182 mp->bd_id = ntohl (bd_id);
7183 mp->flags = ntohl (flags);
7184 mp->is_set = is_set;
7192 api_bd_ip_mac_add_del (vat_main_t * vam)
7194 vl_api_address_t ip = VL_API_ZERO_ADDRESS;
7195 vl_api_mac_address_t mac = { 0 };
7196 unformat_input_t *i = vam->input;
7197 vl_api_bd_ip_mac_add_del_t *mp;
7206 /* Parse args required to build the message */
7207 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7209 if (unformat (i, "bd_id %d", &bd_id))
7213 else if (unformat (i, "%U", unformat_vl_api_address, &ip))
7217 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
7221 else if (unformat (i, "del"))
7229 errmsg ("missing bridge domain");
7232 else if (ip_set == 0)
7234 errmsg ("missing IP address");
7237 else if (mac_set == 0)
7239 errmsg ("missing MAC address");
7243 M (BD_IP_MAC_ADD_DEL, mp);
7245 mp->entry.bd_id = ntohl (bd_id);
7246 mp->is_add = is_add;
7248 clib_memcpy (&mp->entry.ip, &ip, sizeof (ip));
7249 clib_memcpy (&mp->entry.mac, &mac, sizeof (mac));
7257 api_bd_ip_mac_flush (vat_main_t * vam)
7259 unformat_input_t *i = vam->input;
7260 vl_api_bd_ip_mac_flush_t *mp;
7265 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7267 if (unformat (i, "bd_id %d", &bd_id))
7277 errmsg ("missing bridge domain");
7281 M (BD_IP_MAC_FLUSH, mp);
7283 mp->bd_id = ntohl (bd_id);
7290 static void vl_api_bd_ip_mac_details_t_handler
7291 (vl_api_bd_ip_mac_details_t * mp)
7293 vat_main_t *vam = &vat_main;
7297 ntohl (mp->entry.bd_id),
7298 format_vl_api_mac_address, mp->entry.mac,
7299 format_vl_api_address, &mp->entry.ip);
7302 static void vl_api_bd_ip_mac_details_t_handler_json
7303 (vl_api_bd_ip_mac_details_t * mp)
7305 vat_main_t *vam = &vat_main;
7306 vat_json_node_t *node = NULL;
7308 if (VAT_JSON_ARRAY != vam->json_tree.type)
7310 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7311 vat_json_init_array (&vam->json_tree);
7313 node = vat_json_array_add (&vam->json_tree);
7315 vat_json_init_object (node);
7316 vat_json_object_add_uint (node, "bd_id", ntohl (mp->entry.bd_id));
7317 vat_json_object_add_string_copy (node, "mac_address",
7318 format (0, "%U", format_vl_api_mac_address,
7322 ip = format (0, "%U", format_vl_api_address, &mp->entry.ip);
7323 vat_json_object_add_string_copy (node, "ip_address", ip);
7328 api_bd_ip_mac_dump (vat_main_t * vam)
7330 unformat_input_t *i = vam->input;
7331 vl_api_bd_ip_mac_dump_t *mp;
7332 vl_api_control_ping_t *mp_ping;
7337 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7339 if (unformat (i, "bd_id %d", &bd_id))
7348 "\n%-5s %-7s %-20s %-30s",
7349 "bd_id", "is_ipv6", "mac_address", "ip_address");
7351 /* Dump Bridge Domain Ip to Mac entries */
7352 M (BD_IP_MAC_DUMP, mp);
7355 mp->bd_id = htonl (bd_id);
7361 /* Use a control ping for synchronization */
7362 MPING (CONTROL_PING, mp_ping);
7370 api_tap_create_v2 (vat_main_t * vam)
7372 unformat_input_t *i = vam->input;
7373 vl_api_tap_create_v2_t *mp;
7374 #define TAP_FLAG_GSO (1 << 0)
7378 u8 *host_if_name = 0;
7380 u8 host_mac_addr[6];
7381 u8 host_mac_addr_set = 0;
7382 u8 *host_bridge = 0;
7383 ip4_address_t host_ip4_addr;
7384 ip4_address_t host_ip4_gw;
7385 u8 host_ip4_gw_set = 0;
7386 u32 host_ip4_prefix_len = 0;
7387 ip6_address_t host_ip6_addr;
7388 ip6_address_t host_ip6_gw;
7389 u8 host_ip6_gw_set = 0;
7390 u32 host_ip6_prefix_len = 0;
7391 u8 host_mtu_set = 0;
7392 u32 host_mtu_size = 0;
7395 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7397 clib_memset (mac_address, 0, sizeof (mac_address));
7399 /* Parse args required to build the message */
7400 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7402 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7406 else if (unformat (i, "id %u", &id))
7408 else if (unformat (i, "host-if-name %s", &host_if_name))
7410 else if (unformat (i, "host-ns %s", &host_ns))
7412 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
7414 host_mac_addr_set = 1;
7415 else if (unformat (i, "host-bridge %s", &host_bridge))
7417 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
7418 &host_ip4_addr, &host_ip4_prefix_len))
7420 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
7421 &host_ip6_addr, &host_ip6_prefix_len))
7423 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
7425 host_ip4_gw_set = 1;
7426 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
7428 host_ip6_gw_set = 1;
7429 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
7431 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
7433 else if (unformat (i, "host-mtu-size %d", &host_mtu_size))
7435 else if (unformat (i, "no-gso"))
7436 tap_flags &= ~TAP_FLAG_GSO;
7437 else if (unformat (i, "gso"))
7438 tap_flags |= TAP_FLAG_GSO;
7443 if (vec_len (host_if_name) > 63)
7445 errmsg ("tap name too long. ");
7448 if (vec_len (host_ns) > 63)
7450 errmsg ("host name space too long. ");
7453 if (vec_len (host_bridge) > 63)
7455 errmsg ("host bridge name too long. ");
7458 if (host_ip4_prefix_len > 32)
7460 errmsg ("host ip4 prefix length not valid. ");
7463 if (host_ip6_prefix_len > 128)
7465 errmsg ("host ip6 prefix length not valid. ");
7468 if (!is_pow2 (rx_ring_sz))
7470 errmsg ("rx ring size must be power of 2. ");
7473 if (rx_ring_sz > 32768)
7475 errmsg ("rx ring size must be 32768 or lower. ");
7478 if (!is_pow2 (tx_ring_sz))
7480 errmsg ("tx ring size must be power of 2. ");
7483 if (tx_ring_sz > 32768)
7485 errmsg ("tx ring size must be 32768 or lower. ");
7488 if (host_mtu_set && (host_mtu_size < 64 || host_mtu_size > 65355))
7490 errmsg ("host MTU size must be in between 64 and 65355. ");
7494 /* Construct the API message */
7495 M (TAP_CREATE_V2, mp);
7497 mp->use_random_mac = random_mac;
7499 mp->id = ntohl (id);
7500 mp->host_namespace_set = host_ns != 0;
7501 mp->host_bridge_set = host_bridge != 0;
7502 mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
7503 mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
7504 mp->rx_ring_sz = ntohs (rx_ring_sz);
7505 mp->tx_ring_sz = ntohs (tx_ring_sz);
7506 mp->host_mtu_set = host_mtu_set;
7507 mp->host_mtu_size = ntohl (host_mtu_size);
7508 mp->tap_flags = ntohl (tap_flags);
7510 if (random_mac == 0)
7511 clib_memcpy (mp->mac_address, mac_address, 6);
7512 if (host_mac_addr_set)
7513 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
7515 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
7517 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
7519 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
7520 if (host_ip4_prefix_len)
7521 clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
7522 if (host_ip6_prefix_len)
7523 clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
7524 if (host_ip4_gw_set)
7525 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
7526 if (host_ip6_gw_set)
7527 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
7530 vec_free (host_if_name);
7531 vec_free (host_bridge);
7536 /* Wait for a reply... */
7542 api_tap_delete_v2 (vat_main_t * vam)
7544 unformat_input_t *i = vam->input;
7545 vl_api_tap_delete_v2_t *mp;
7546 u32 sw_if_index = ~0;
7547 u8 sw_if_index_set = 0;
7550 /* Parse args required to build the message */
7551 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7553 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7554 sw_if_index_set = 1;
7555 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7556 sw_if_index_set = 1;
7561 if (sw_if_index_set == 0)
7563 errmsg ("missing vpp interface name. ");
7567 /* Construct the API message */
7568 M (TAP_DELETE_V2, mp);
7570 mp->sw_if_index = ntohl (sw_if_index);
7575 /* Wait for a reply... */
7581 unformat_vlib_pci_addr (unformat_input_t * input, va_list * args)
7583 vlib_pci_addr_t *addr = va_arg (*args, vlib_pci_addr_t *);
7586 if (!unformat (input, "%x:%x:%x.%x", &x[0], &x[1], &x[2], &x[3]))
7589 addr->domain = x[0];
7592 addr->function = x[3];
7598 api_virtio_pci_create (vat_main_t * vam)
7600 unformat_input_t *i = vam->input;
7601 vl_api_virtio_pci_create_t *mp;
7606 u64 features = (u64) ~ (0ULL);
7609 clib_memset (mac_address, 0, sizeof (mac_address));
7611 /* Parse args required to build the message */
7612 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7614 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7618 else if (unformat (i, "pci-addr %U", unformat_vlib_pci_addr, &pci_addr))
7620 else if (unformat (i, "features 0x%llx", &features))
7622 else if (unformat (i, "gso-enabled"))
7630 errmsg ("pci address must be non zero. ");
7634 /* Construct the API message */
7635 M (VIRTIO_PCI_CREATE, mp);
7637 mp->use_random_mac = random_mac;
7639 mp->pci_addr = htonl (pci_addr);
7640 mp->features = clib_host_to_net_u64 (features);
7641 mp->gso_enabled = gso_enabled;
7643 if (random_mac == 0)
7644 clib_memcpy (mp->mac_address, mac_address, 6);
7649 /* Wait for a reply... */
7655 api_virtio_pci_delete (vat_main_t * vam)
7657 unformat_input_t *i = vam->input;
7658 vl_api_virtio_pci_delete_t *mp;
7659 u32 sw_if_index = ~0;
7660 u8 sw_if_index_set = 0;
7663 /* Parse args required to build the message */
7664 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7666 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7667 sw_if_index_set = 1;
7668 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7669 sw_if_index_set = 1;
7674 if (sw_if_index_set == 0)
7676 errmsg ("missing vpp interface name. ");
7680 /* Construct the API message */
7681 M (VIRTIO_PCI_DELETE, mp);
7683 mp->sw_if_index = htonl (sw_if_index);
7688 /* Wait for a reply... */
7694 api_bond_create (vat_main_t * vam)
7696 unformat_input_t *i = vam->input;
7697 vl_api_bond_create_t *mp;
7707 clib_memset (mac_address, 0, sizeof (mac_address));
7710 /* Parse args required to build the message */
7711 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7713 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
7715 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
7716 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
7718 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
7721 else if (unformat (i, "numa-only"))
7723 else if (unformat (i, "id %u", &id))
7729 if (mode_is_set == 0)
7731 errmsg ("Missing bond mode. ");
7735 /* Construct the API message */
7736 M (BOND_CREATE, mp);
7738 mp->use_custom_mac = custom_mac;
7740 mp->mode = htonl (mode);
7741 mp->lb = htonl (lb);
7742 mp->id = htonl (id);
7743 mp->numa_only = numa_only;
7746 clib_memcpy (mp->mac_address, mac_address, 6);
7751 /* Wait for a reply... */
7757 api_bond_delete (vat_main_t * vam)
7759 unformat_input_t *i = vam->input;
7760 vl_api_bond_delete_t *mp;
7761 u32 sw_if_index = ~0;
7762 u8 sw_if_index_set = 0;
7765 /* Parse args required to build the message */
7766 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7768 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7769 sw_if_index_set = 1;
7770 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7771 sw_if_index_set = 1;
7776 if (sw_if_index_set == 0)
7778 errmsg ("missing vpp interface name. ");
7782 /* Construct the API message */
7783 M (BOND_DELETE, mp);
7785 mp->sw_if_index = ntohl (sw_if_index);
7790 /* Wait for a reply... */
7796 api_bond_enslave (vat_main_t * vam)
7798 unformat_input_t *i = vam->input;
7799 vl_api_bond_enslave_t *mp;
7800 u32 bond_sw_if_index;
7804 u32 bond_sw_if_index_is_set = 0;
7806 u8 sw_if_index_is_set = 0;
7808 /* Parse args required to build the message */
7809 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7811 if (unformat (i, "sw_if_index %d", &sw_if_index))
7812 sw_if_index_is_set = 1;
7813 else if (unformat (i, "bond %u", &bond_sw_if_index))
7814 bond_sw_if_index_is_set = 1;
7815 else if (unformat (i, "passive %d", &is_passive))
7817 else if (unformat (i, "long-timeout %d", &is_long_timeout))
7823 if (bond_sw_if_index_is_set == 0)
7825 errmsg ("Missing bond sw_if_index. ");
7828 if (sw_if_index_is_set == 0)
7830 errmsg ("Missing slave sw_if_index. ");
7834 /* Construct the API message */
7835 M (BOND_ENSLAVE, mp);
7837 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
7838 mp->sw_if_index = ntohl (sw_if_index);
7839 mp->is_long_timeout = is_long_timeout;
7840 mp->is_passive = is_passive;
7845 /* Wait for a reply... */
7851 api_bond_detach_slave (vat_main_t * vam)
7853 unformat_input_t *i = vam->input;
7854 vl_api_bond_detach_slave_t *mp;
7855 u32 sw_if_index = ~0;
7856 u8 sw_if_index_set = 0;
7859 /* Parse args required to build the message */
7860 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7862 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7863 sw_if_index_set = 1;
7864 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7865 sw_if_index_set = 1;
7870 if (sw_if_index_set == 0)
7872 errmsg ("missing vpp interface name. ");
7876 /* Construct the API message */
7877 M (BOND_DETACH_SLAVE, mp);
7879 mp->sw_if_index = ntohl (sw_if_index);
7884 /* Wait for a reply... */
7890 api_ip_table_add_del (vat_main_t * vam)
7892 unformat_input_t *i = vam->input;
7893 vl_api_ip_table_add_del_t *mp;
7899 /* Parse args required to build the message */
7900 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7902 if (unformat (i, "ipv6"))
7904 else if (unformat (i, "del"))
7906 else if (unformat (i, "add"))
7908 else if (unformat (i, "table %d", &table_id))
7912 clib_warning ("parse error '%U'", format_unformat_error, i);
7919 errmsg ("missing table-ID");
7923 /* Construct the API message */
7924 M (IP_TABLE_ADD_DEL, mp);
7926 mp->table.table_id = ntohl (table_id);
7927 mp->table.is_ip6 = is_ipv6;
7928 mp->is_add = is_add;
7933 /* Wait for a reply... */
7940 unformat_fib_path (unformat_input_t * input, va_list * args)
7942 vat_main_t *vam = va_arg (*args, vat_main_t *);
7943 vl_api_fib_path_t *path = va_arg (*args, vl_api_fib_path_t *);
7944 u32 weight, preference;
7945 mpls_label_t out_label;
7947 clib_memset (path, 0, sizeof (*path));
7949 path->sw_if_index = ~0;
7953 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7955 if (unformat (input, "%U %U",
7956 unformat_vl_api_ip4_address,
7957 &path->nh.address.ip4,
7958 api_unformat_sw_if_index, vam, &path->sw_if_index))
7960 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7962 else if (unformat (input, "%U %U",
7963 unformat_vl_api_ip6_address,
7964 &path->nh.address.ip6,
7965 api_unformat_sw_if_index, vam, &path->sw_if_index))
7967 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7969 else if (unformat (input, "weight %u", &weight))
7971 path->weight = weight;
7973 else if (unformat (input, "preference %u", &preference))
7975 path->preference = preference;
7977 else if (unformat (input, "%U next-hop-table %d",
7978 unformat_vl_api_ip4_address,
7979 &path->nh.address.ip4, &path->table_id))
7981 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7983 else if (unformat (input, "%U next-hop-table %d",
7984 unformat_vl_api_ip6_address,
7985 &path->nh.address.ip6, &path->table_id))
7987 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7989 else if (unformat (input, "%U",
7990 unformat_vl_api_ip4_address, &path->nh.address.ip4))
7993 * the recursive next-hops are by default in the default table
7996 path->sw_if_index = ~0;
7997 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7999 else if (unformat (input, "%U",
8000 unformat_vl_api_ip6_address, &path->nh.address.ip6))
8003 * the recursive next-hops are by default in the default table
8006 path->sw_if_index = ~0;
8007 path->proto = FIB_API_PATH_NH_PROTO_IP6;
8009 else if (unformat (input, "resolve-via-host"))
8011 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_HOST;
8013 else if (unformat (input, "resolve-via-attached"))
8015 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED;
8017 else if (unformat (input, "ip4-lookup-in-table %d", &path->table_id))
8019 path->type = FIB_API_PATH_TYPE_LOCAL;
8020 path->sw_if_index = ~0;
8021 path->proto = FIB_API_PATH_NH_PROTO_IP4;
8023 else if (unformat (input, "ip6-lookup-in-table %d", &path->table_id))
8025 path->type = FIB_API_PATH_TYPE_LOCAL;
8026 path->sw_if_index = ~0;
8027 path->proto = FIB_API_PATH_NH_PROTO_IP6;
8029 else if (unformat (input, "sw_if_index %d", &path->sw_if_index))
8031 else if (unformat (input, "via-label %d", &path->nh.via_label))
8033 path->proto = FIB_API_PATH_NH_PROTO_MPLS;
8034 path->sw_if_index = ~0;
8036 else if (unformat (input, "l2-input-on %d", &path->sw_if_index))
8038 path->proto = FIB_API_PATH_NH_PROTO_ETHERNET;
8039 path->type = FIB_API_PATH_TYPE_INTERFACE_RX;
8041 else if (unformat (input, "local"))
8043 path->type = FIB_API_PATH_TYPE_LOCAL;
8045 else if (unformat (input, "out-labels"))
8047 while (unformat (input, "%d", &out_label))
8049 path->label_stack[path->n_labels].label = out_label;
8050 path->label_stack[path->n_labels].is_uniform = 0;
8051 path->label_stack[path->n_labels].ttl = 64;
8055 else if (unformat (input, "via"))
8057 /* new path, back up and return */
8058 unformat_put_input (input);
8059 unformat_put_input (input);
8060 unformat_put_input (input);
8061 unformat_put_input (input);
8070 path->proto = ntohl (path->proto);
8071 path->type = ntohl (path->type);
8072 path->flags = ntohl (path->flags);
8073 path->table_id = ntohl (path->table_id);
8074 path->sw_if_index = ntohl (path->sw_if_index);
8080 api_ip_route_add_del (vat_main_t * vam)
8082 unformat_input_t *i = vam->input;
8083 vl_api_ip_route_add_del_t *mp;
8086 u8 is_multipath = 0;
8089 vl_api_prefix_t pfx = { };
8090 vl_api_fib_path_t paths[8];
8094 u32 random_add_del = 0;
8095 u32 *random_vector = 0;
8096 u32 random_seed = 0xdeaddabe;
8098 /* Parse args required to build the message */
8099 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8101 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
8103 else if (unformat (i, "del"))
8105 else if (unformat (i, "add"))
8107 else if (unformat (i, "vrf %d", &vrf_id))
8109 else if (unformat (i, "count %d", &count))
8111 else if (unformat (i, "random"))
8113 else if (unformat (i, "multipath"))
8115 else if (unformat (i, "seed %d", &random_seed))
8119 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8122 if (8 == path_count)
8124 errmsg ("max 8 paths");
8130 clib_warning ("parse error '%U'", format_unformat_error, i);
8137 errmsg ("specify a path; via ...");
8140 if (prefix_set == 0)
8142 errmsg ("missing prefix");
8146 /* Generate a pile of unique, random routes */
8149 ip4_address_t *i = (ip4_address_t *) & paths[0].nh.address.ip4;
8150 u32 this_random_address;
8153 random_hash = hash_create (count, sizeof (uword));
8155 hash_set (random_hash, i->as_u32, 1);
8156 for (j = 0; j <= count; j++)
8160 this_random_address = random_u32 (&random_seed);
8161 this_random_address =
8162 clib_host_to_net_u32 (this_random_address);
8164 while (hash_get (random_hash, this_random_address));
8165 vec_add1 (random_vector, this_random_address);
8166 hash_set (random_hash, this_random_address, 1);
8168 hash_free (random_hash);
8169 set_ip4_address (&pfx.address, random_vector[0]);
8174 /* Turn on async mode */
8175 vam->async_mode = 1;
8176 vam->async_errors = 0;
8177 before = vat_time_now (vam);
8180 for (j = 0; j < count; j++)
8182 /* Construct the API message */
8183 M2 (IP_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8185 mp->is_add = is_add;
8186 mp->is_multipath = is_multipath;
8188 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
8189 mp->route.table_id = ntohl (vrf_id);
8190 mp->route.n_paths = path_count;
8192 clib_memcpy (&mp->route.paths, &paths, sizeof (paths[0]) * path_count);
8195 set_ip4_address (&pfx.address, random_vector[j + 1]);
8197 increment_address (&pfx.address);
8200 /* If we receive SIGTERM, stop now... */
8205 /* When testing multiple add/del ops, use a control-ping to sync */
8208 vl_api_control_ping_t *mp_ping;
8212 /* Shut off async mode */
8213 vam->async_mode = 0;
8215 MPING (CONTROL_PING, mp_ping);
8218 timeout = vat_time_now (vam) + 1.0;
8219 while (vat_time_now (vam) < timeout)
8220 if (vam->result_ready == 1)
8225 if (vam->retval == -99)
8228 if (vam->async_errors > 0)
8230 errmsg ("%d asynchronous errors", vam->async_errors);
8233 vam->async_errors = 0;
8234 after = vat_time_now (vam);
8236 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8240 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8241 count, after - before, count / (after - before));
8247 /* Wait for a reply... */
8252 /* Return the good/bad news */
8253 return (vam->retval);
8257 api_ip_mroute_add_del (vat_main_t * vam)
8259 unformat_input_t *i = vam->input;
8260 u8 path_set = 0, prefix_set = 0, is_add = 1;
8261 vl_api_ip_mroute_add_del_t *mp;
8262 mfib_entry_flags_t eflags = 0;
8263 vl_api_mfib_path_t path;
8264 vl_api_mprefix_t pfx = { };
8268 /* Parse args required to build the message */
8269 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8271 if (unformat (i, "%U", unformat_vl_api_mprefix, &pfx))
8274 pfx.grp_address_length = htons (pfx.grp_address_length);
8276 else if (unformat (i, "del"))
8278 else if (unformat (i, "add"))
8280 else if (unformat (i, "vrf %d", &vrf_id))
8282 else if (unformat (i, "%U", unformat_mfib_itf_flags, &path.itf_flags))
8283 path.itf_flags = htonl (path.itf_flags);
8284 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8286 else if (unformat (i, "via %U", unformat_fib_path, vam, &path.path))
8290 clib_warning ("parse error '%U'", format_unformat_error, i);
8295 if (prefix_set == 0)
8297 errmsg ("missing addresses\n");
8302 errmsg ("missing path\n");
8306 /* Construct the API message */
8307 M (IP_MROUTE_ADD_DEL, mp);
8309 mp->is_add = is_add;
8310 mp->is_multipath = 1;
8312 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
8313 mp->route.table_id = htonl (vrf_id);
8314 mp->route.n_paths = 1;
8315 mp->route.entry_flags = htonl (eflags);
8317 clib_memcpy (&mp->route.paths, &path, sizeof (path));
8321 /* Wait for a reply... */
8327 api_mpls_table_add_del (vat_main_t * vam)
8329 unformat_input_t *i = vam->input;
8330 vl_api_mpls_table_add_del_t *mp;
8335 /* Parse args required to build the message */
8336 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8338 if (unformat (i, "table %d", &table_id))
8340 else if (unformat (i, "del"))
8342 else if (unformat (i, "add"))
8346 clib_warning ("parse error '%U'", format_unformat_error, i);
8353 errmsg ("missing table-ID");
8357 /* Construct the API message */
8358 M (MPLS_TABLE_ADD_DEL, mp);
8360 mp->mt_table.mt_table_id = ntohl (table_id);
8361 mp->mt_is_add = is_add;
8366 /* Wait for a reply... */
8373 api_mpls_route_add_del (vat_main_t * vam)
8375 u8 is_add = 1, path_count = 0, is_multipath = 0, is_eos = 0;
8376 mpls_label_t local_label = MPLS_LABEL_INVALID;
8377 unformat_input_t *i = vam->input;
8378 vl_api_mpls_route_add_del_t *mp;
8379 vl_api_fib_path_t paths[8];
8383 /* Parse args required to build the message */
8384 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8386 if (unformat (i, "%d", &local_label))
8388 else if (unformat (i, "eos"))
8390 else if (unformat (i, "non-eos"))
8392 else if (unformat (i, "del"))
8394 else if (unformat (i, "add"))
8396 else if (unformat (i, "multipath"))
8398 else if (unformat (i, "count %d", &count))
8402 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8405 if (8 == path_count)
8407 errmsg ("max 8 paths");
8413 clib_warning ("parse error '%U'", format_unformat_error, i);
8420 errmsg ("specify a path; via ...");
8424 if (MPLS_LABEL_INVALID == local_label)
8426 errmsg ("missing label");
8432 /* Turn on async mode */
8433 vam->async_mode = 1;
8434 vam->async_errors = 0;
8435 before = vat_time_now (vam);
8438 for (j = 0; j < count; j++)
8440 /* Construct the API message */
8441 M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8443 mp->mr_is_add = is_add;
8444 mp->mr_is_multipath = is_multipath;
8446 mp->mr_route.mr_label = local_label;
8447 mp->mr_route.mr_eos = is_eos;
8448 mp->mr_route.mr_table_id = 0;
8449 mp->mr_route.mr_n_paths = path_count;
8451 clib_memcpy (&mp->mr_route.mr_paths, paths,
8452 sizeof (paths[0]) * path_count);
8458 /* If we receive SIGTERM, stop now... */
8463 /* When testing multiple add/del ops, use a control-ping to sync */
8466 vl_api_control_ping_t *mp_ping;
8470 /* Shut off async mode */
8471 vam->async_mode = 0;
8473 MPING (CONTROL_PING, mp_ping);
8476 timeout = vat_time_now (vam) + 1.0;
8477 while (vat_time_now (vam) < timeout)
8478 if (vam->result_ready == 1)
8483 if (vam->retval == -99)
8486 if (vam->async_errors > 0)
8488 errmsg ("%d asynchronous errors", vam->async_errors);
8491 vam->async_errors = 0;
8492 after = vat_time_now (vam);
8494 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8498 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8499 count, after - before, count / (after - before));
8505 /* Wait for a reply... */
8510 /* Return the good/bad news */
8511 return (vam->retval);
8516 api_mpls_ip_bind_unbind (vat_main_t * vam)
8518 unformat_input_t *i = vam->input;
8519 vl_api_mpls_ip_bind_unbind_t *mp;
8520 u32 ip_table_id = 0;
8522 vl_api_prefix_t pfx;
8524 mpls_label_t local_label = MPLS_LABEL_INVALID;
8527 /* Parse args required to build the message */
8528 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8530 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
8532 else if (unformat (i, "%d", &local_label))
8534 else if (unformat (i, "table-id %d", &ip_table_id))
8536 else if (unformat (i, "unbind"))
8538 else if (unformat (i, "bind"))
8542 clib_warning ("parse error '%U'", format_unformat_error, i);
8549 errmsg ("IP prefix not set");
8553 if (MPLS_LABEL_INVALID == local_label)
8555 errmsg ("missing label");
8559 /* Construct the API message */
8560 M (MPLS_IP_BIND_UNBIND, mp);
8562 mp->mb_is_bind = is_bind;
8563 mp->mb_ip_table_id = ntohl (ip_table_id);
8564 mp->mb_mpls_table_id = 0;
8565 mp->mb_label = ntohl (local_label);
8566 clib_memcpy (&mp->mb_prefix, &pfx, sizeof (pfx));
8571 /* Wait for a reply... */
8578 api_sr_mpls_policy_add (vat_main_t * vam)
8580 unformat_input_t *i = vam->input;
8581 vl_api_sr_mpls_policy_add_t *mp;
8587 u32 *segments = NULL;
8590 /* Parse args required to build the message */
8591 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8593 if (unformat (i, "bsid %d", &bsid))
8595 else if (unformat (i, "weight %d", &weight))
8597 else if (unformat (i, "spray"))
8599 else if (unformat (i, "next %d", &sid))
8602 vec_add1 (segments, htonl (sid));
8606 clib_warning ("parse error '%U'", format_unformat_error, i);
8613 errmsg ("bsid not set");
8617 if (n_segments == 0)
8619 errmsg ("no sid in segment stack");
8623 /* Construct the API message */
8624 M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
8626 mp->bsid = htonl (bsid);
8627 mp->weight = htonl (weight);
8629 mp->n_segments = n_segments;
8630 memcpy (mp->segments, segments, sizeof (u32) * n_segments);
8631 vec_free (segments);
8636 /* Wait for a reply... */
8642 api_sr_mpls_policy_del (vat_main_t * vam)
8644 unformat_input_t *i = vam->input;
8645 vl_api_sr_mpls_policy_del_t *mp;
8649 /* Parse args required to build the message */
8650 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8652 if (unformat (i, "bsid %d", &bsid))
8656 clib_warning ("parse error '%U'", format_unformat_error, i);
8663 errmsg ("bsid not set");
8667 /* Construct the API message */
8668 M (SR_MPLS_POLICY_DEL, mp);
8670 mp->bsid = htonl (bsid);
8675 /* Wait for a reply... */
8681 api_bier_table_add_del (vat_main_t * vam)
8683 unformat_input_t *i = vam->input;
8684 vl_api_bier_table_add_del_t *mp;
8686 u32 set = 0, sub_domain = 0, hdr_len = 3;
8687 mpls_label_t local_label = MPLS_LABEL_INVALID;
8690 /* Parse args required to build the message */
8691 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8693 if (unformat (i, "sub-domain %d", &sub_domain))
8695 else if (unformat (i, "set %d", &set))
8697 else if (unformat (i, "label %d", &local_label))
8699 else if (unformat (i, "hdr-len %d", &hdr_len))
8701 else if (unformat (i, "add"))
8703 else if (unformat (i, "del"))
8707 clib_warning ("parse error '%U'", format_unformat_error, i);
8712 if (MPLS_LABEL_INVALID == local_label)
8714 errmsg ("missing label\n");
8718 /* Construct the API message */
8719 M (BIER_TABLE_ADD_DEL, mp);
8721 mp->bt_is_add = is_add;
8722 mp->bt_label = ntohl (local_label);
8723 mp->bt_tbl_id.bt_set = set;
8724 mp->bt_tbl_id.bt_sub_domain = sub_domain;
8725 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
8730 /* Wait for a reply... */
8737 api_bier_route_add_del (vat_main_t * vam)
8739 unformat_input_t *i = vam->input;
8740 vl_api_bier_route_add_del_t *mp;
8742 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
8743 ip4_address_t v4_next_hop_address;
8744 ip6_address_t v6_next_hop_address;
8745 u8 next_hop_set = 0;
8746 u8 next_hop_proto_is_ip4 = 1;
8747 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8750 /* Parse args required to build the message */
8751 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8753 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
8755 next_hop_proto_is_ip4 = 1;
8758 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
8760 next_hop_proto_is_ip4 = 0;
8763 if (unformat (i, "sub-domain %d", &sub_domain))
8765 else if (unformat (i, "set %d", &set))
8767 else if (unformat (i, "hdr-len %d", &hdr_len))
8769 else if (unformat (i, "bp %d", &bp))
8771 else if (unformat (i, "add"))
8773 else if (unformat (i, "del"))
8775 else if (unformat (i, "out-label %d", &next_hop_out_label))
8779 clib_warning ("parse error '%U'", format_unformat_error, i);
8784 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
8786 errmsg ("next hop / label set\n");
8791 errmsg ("bit=position not set\n");
8795 /* Construct the API message */
8796 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
8798 mp->br_is_add = is_add;
8799 mp->br_route.br_tbl_id.bt_set = set;
8800 mp->br_route.br_tbl_id.bt_sub_domain = sub_domain;
8801 mp->br_route.br_tbl_id.bt_hdr_len_id = hdr_len;
8802 mp->br_route.br_bp = ntohs (bp);
8803 mp->br_route.br_n_paths = 1;
8804 mp->br_route.br_paths[0].n_labels = 1;
8805 mp->br_route.br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
8806 mp->br_route.br_paths[0].proto = (next_hop_proto_is_ip4 ?
8807 FIB_API_PATH_NH_PROTO_IP4 :
8808 FIB_API_PATH_NH_PROTO_IP6);
8810 if (next_hop_proto_is_ip4)
8812 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip4,
8813 &v4_next_hop_address, sizeof (v4_next_hop_address));
8817 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip6,
8818 &v6_next_hop_address, sizeof (v6_next_hop_address));
8824 /* Wait for a reply... */
8831 api_proxy_arp_add_del (vat_main_t * vam)
8833 unformat_input_t *i = vam->input;
8834 vl_api_proxy_arp_add_del_t *mp;
8837 vl_api_ip4_address_t lo, hi;
8841 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8843 if (unformat (i, "vrf %d", &vrf_id))
8845 else if (unformat (i, "%U - %U", unformat_vl_api_ip4_address, &lo,
8846 unformat_vl_api_ip4_address, &hi))
8848 else if (unformat (i, "del"))
8852 clib_warning ("parse error '%U'", format_unformat_error, i);
8859 errmsg ("address range not set");
8863 M (PROXY_ARP_ADD_DEL, mp);
8865 mp->proxy.table_id = ntohl (vrf_id);
8866 mp->is_add = is_add;
8867 clib_memcpy (mp->proxy.low, &lo, sizeof (lo));
8868 clib_memcpy (mp->proxy.hi, &hi, sizeof (hi));
8876 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
8878 unformat_input_t *i = vam->input;
8879 vl_api_proxy_arp_intfc_enable_disable_t *mp;
8882 u8 sw_if_index_set = 0;
8885 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8887 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8888 sw_if_index_set = 1;
8889 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8890 sw_if_index_set = 1;
8891 else if (unformat (i, "enable"))
8893 else if (unformat (i, "disable"))
8897 clib_warning ("parse error '%U'", format_unformat_error, i);
8902 if (sw_if_index_set == 0)
8904 errmsg ("missing interface name or sw_if_index");
8908 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
8910 mp->sw_if_index = ntohl (sw_if_index);
8911 mp->enable_disable = enable;
8919 api_mpls_tunnel_add_del (vat_main_t * vam)
8921 unformat_input_t *i = vam->input;
8922 vl_api_mpls_tunnel_add_del_t *mp;
8924 vl_api_fib_path_t paths[8];
8925 u32 sw_if_index = ~0;
8931 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8933 if (unformat (i, "add"))
8937 (i, "del %U", api_unformat_sw_if_index, vam, &sw_if_index))
8939 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
8941 else if (unformat (i, "l2-only"))
8945 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8948 if (8 == path_count)
8950 errmsg ("max 8 paths");
8956 clib_warning ("parse error '%U'", format_unformat_error, i);
8961 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8963 mp->mt_is_add = is_add;
8964 mp->mt_tunnel.mt_sw_if_index = ntohl (sw_if_index);
8965 mp->mt_tunnel.mt_l2_only = l2_only;
8966 mp->mt_tunnel.mt_is_multicast = 0;
8967 mp->mt_tunnel.mt_n_paths = path_count;
8969 clib_memcpy (&mp->mt_tunnel.mt_paths, &paths,
8970 sizeof (paths[0]) * path_count);
8978 api_sw_interface_set_unnumbered (vat_main_t * vam)
8980 unformat_input_t *i = vam->input;
8981 vl_api_sw_interface_set_unnumbered_t *mp;
8983 u32 unnum_sw_index = ~0;
8985 u8 sw_if_index_set = 0;
8988 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8990 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8991 sw_if_index_set = 1;
8992 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8993 sw_if_index_set = 1;
8994 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
8996 else if (unformat (i, "del"))
9000 clib_warning ("parse error '%U'", format_unformat_error, i);
9005 if (sw_if_index_set == 0)
9007 errmsg ("missing interface name or sw_if_index");
9011 M (SW_INTERFACE_SET_UNNUMBERED, mp);
9013 mp->sw_if_index = ntohl (sw_if_index);
9014 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
9015 mp->is_add = is_add;
9023 api_ip_neighbor_add_del (vat_main_t * vam)
9025 vl_api_mac_address_t mac_address;
9026 unformat_input_t *i = vam->input;
9027 vl_api_ip_neighbor_add_del_t *mp;
9028 vl_api_address_t ip_address;
9030 u8 sw_if_index_set = 0;
9035 ip_neighbor_flags_t flags;
9037 flags = IP_NEIGHBOR_FLAG_NONE;
9038 clib_memset (&ip_address, 0, sizeof (ip_address));
9039 clib_memset (&mac_address, 0, sizeof (mac_address));
9041 /* Parse args required to build the message */
9042 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9044 if (unformat (i, "mac %U", unformat_vl_api_mac_address, &mac_address))
9048 else if (unformat (i, "del"))
9051 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9052 sw_if_index_set = 1;
9053 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9054 sw_if_index_set = 1;
9055 else if (unformat (i, "static"))
9056 flags |= IP_NEIGHBOR_FLAG_STATIC;
9057 else if (unformat (i, "no-fib-entry"))
9058 flags |= IP_NEIGHBOR_FLAG_NO_FIB_ENTRY;
9059 else if (unformat (i, "dst %U", unformat_vl_api_address, &ip_address))
9063 clib_warning ("parse error '%U'", format_unformat_error, i);
9068 if (sw_if_index_set == 0)
9070 errmsg ("missing interface name or sw_if_index");
9075 errmsg ("no address set");
9079 /* Construct the API message */
9080 M (IP_NEIGHBOR_ADD_DEL, mp);
9082 mp->neighbor.sw_if_index = ntohl (sw_if_index);
9083 mp->is_add = is_add;
9084 mp->neighbor.flags = htonl (flags);
9086 clib_memcpy (&mp->neighbor.mac_address, &mac_address,
9087 sizeof (mac_address));
9089 clib_memcpy (&mp->neighbor.ip_address, &ip_address, sizeof (ip_address));
9094 /* Wait for a reply, return good/bad news */
9100 api_create_vlan_subif (vat_main_t * vam)
9102 unformat_input_t *i = vam->input;
9103 vl_api_create_vlan_subif_t *mp;
9105 u8 sw_if_index_set = 0;
9110 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9112 if (unformat (i, "sw_if_index %d", &sw_if_index))
9113 sw_if_index_set = 1;
9115 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9116 sw_if_index_set = 1;
9117 else if (unformat (i, "vlan %d", &vlan_id))
9121 clib_warning ("parse error '%U'", format_unformat_error, i);
9126 if (sw_if_index_set == 0)
9128 errmsg ("missing interface name or sw_if_index");
9132 if (vlan_id_set == 0)
9134 errmsg ("missing vlan_id");
9137 M (CREATE_VLAN_SUBIF, mp);
9139 mp->sw_if_index = ntohl (sw_if_index);
9140 mp->vlan_id = ntohl (vlan_id);
9147 #define foreach_create_subif_bit \
9154 _(outer_vlan_id_any) \
9155 _(inner_vlan_id_any)
9157 #define foreach_create_subif_flag \
9162 _(4, "exact_match") \
9163 _(5, "default_sub") \
9164 _(6, "outer_vlan_id_any") \
9165 _(7, "inner_vlan_id_any")
9168 api_create_subif (vat_main_t * vam)
9170 unformat_input_t *i = vam->input;
9171 vl_api_create_subif_t *mp;
9173 u8 sw_if_index_set = 0;
9176 u32 __attribute__ ((unused)) no_tags = 0;
9177 u32 __attribute__ ((unused)) one_tag = 0;
9178 u32 __attribute__ ((unused)) two_tags = 0;
9179 u32 __attribute__ ((unused)) dot1ad = 0;
9180 u32 __attribute__ ((unused)) exact_match = 0;
9181 u32 __attribute__ ((unused)) default_sub = 0;
9182 u32 __attribute__ ((unused)) outer_vlan_id_any = 0;
9183 u32 __attribute__ ((unused)) inner_vlan_id_any = 0;
9185 u16 outer_vlan_id = 0;
9186 u16 inner_vlan_id = 0;
9189 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9191 if (unformat (i, "sw_if_index %d", &sw_if_index))
9192 sw_if_index_set = 1;
9194 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9195 sw_if_index_set = 1;
9196 else if (unformat (i, "sub_id %d", &sub_id))
9198 else if (unformat (i, "outer_vlan_id %d", &tmp))
9199 outer_vlan_id = tmp;
9200 else if (unformat (i, "inner_vlan_id %d", &tmp))
9201 inner_vlan_id = tmp;
9203 #define _(a) else if (unformat (i, #a)) a = 1 ;
9204 foreach_create_subif_bit
9208 clib_warning ("parse error '%U'", format_unformat_error, i);
9213 if (sw_if_index_set == 0)
9215 errmsg ("missing interface name or sw_if_index");
9219 if (sub_id_set == 0)
9221 errmsg ("missing sub_id");
9224 M (CREATE_SUBIF, mp);
9226 mp->sw_if_index = ntohl (sw_if_index);
9227 mp->sub_id = ntohl (sub_id);
9229 #define _(a,b) mp->sub_if_flags |= (1 << a);
9230 foreach_create_subif_flag;
9233 mp->outer_vlan_id = ntohs (outer_vlan_id);
9234 mp->inner_vlan_id = ntohs (inner_vlan_id);
9242 api_reset_fib (vat_main_t * vam)
9244 unformat_input_t *i = vam->input;
9245 vl_api_reset_fib_t *mp;
9251 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9253 if (unformat (i, "vrf %d", &vrf_id))
9255 else if (unformat (i, "ipv6"))
9259 clib_warning ("parse error '%U'", format_unformat_error, i);
9264 if (vrf_id_set == 0)
9266 errmsg ("missing vrf id");
9272 mp->vrf_id = ntohl (vrf_id);
9273 mp->is_ipv6 = is_ipv6;
9281 api_dhcp_proxy_config (vat_main_t * vam)
9283 unformat_input_t *i = vam->input;
9284 vl_api_dhcp_proxy_config_t *mp;
9286 u32 server_vrf_id = 0;
9288 u8 v4_address_set = 0;
9289 u8 v6_address_set = 0;
9290 ip4_address_t v4address;
9291 ip6_address_t v6address;
9292 u8 v4_src_address_set = 0;
9293 u8 v6_src_address_set = 0;
9294 ip4_address_t v4srcaddress;
9295 ip6_address_t v6srcaddress;
9298 /* Parse args required to build the message */
9299 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9301 if (unformat (i, "del"))
9303 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
9305 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
9307 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
9309 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
9311 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
9312 v4_src_address_set = 1;
9313 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
9314 v6_src_address_set = 1;
9319 if (v4_address_set && v6_address_set)
9321 errmsg ("both v4 and v6 server addresses set");
9324 if (!v4_address_set && !v6_address_set)
9326 errmsg ("no server addresses set");
9330 if (v4_src_address_set && v6_src_address_set)
9332 errmsg ("both v4 and v6 src addresses set");
9335 if (!v4_src_address_set && !v6_src_address_set)
9337 errmsg ("no src addresses set");
9341 if (!(v4_src_address_set && v4_address_set) &&
9342 !(v6_src_address_set && v6_address_set))
9344 errmsg ("no matching server and src addresses set");
9348 /* Construct the API message */
9349 M (DHCP_PROXY_CONFIG, mp);
9351 mp->is_add = is_add;
9352 mp->rx_vrf_id = ntohl (rx_vrf_id);
9353 mp->server_vrf_id = ntohl (server_vrf_id);
9357 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
9358 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
9362 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
9363 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
9369 /* Wait for a reply, return good/bad news */
9374 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
9375 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
9378 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
9380 vat_main_t *vam = &vat_main;
9381 u32 i, count = mp->count;
9382 vl_api_dhcp_server_t *s;
9386 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9387 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9388 ntohl (mp->rx_vrf_id),
9389 format_ip6_address, mp->dhcp_src_address,
9390 mp->vss_type, mp->vss_vpn_ascii_id,
9391 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9394 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9395 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9396 ntohl (mp->rx_vrf_id),
9397 format_ip4_address, mp->dhcp_src_address,
9398 mp->vss_type, mp->vss_vpn_ascii_id,
9399 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9401 for (i = 0; i < count; i++)
9403 s = &mp->servers[i];
9407 " Server Table-ID %d, Server Address %U",
9408 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
9411 " Server Table-ID %d, Server Address %U",
9412 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
9416 static void vl_api_dhcp_proxy_details_t_handler_json
9417 (vl_api_dhcp_proxy_details_t * mp)
9419 vat_main_t *vam = &vat_main;
9420 vat_json_node_t *node = NULL;
9421 u32 i, count = mp->count;
9423 struct in6_addr ip6;
9424 vl_api_dhcp_server_t *s;
9426 if (VAT_JSON_ARRAY != vam->json_tree.type)
9428 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9429 vat_json_init_array (&vam->json_tree);
9431 node = vat_json_array_add (&vam->json_tree);
9433 vat_json_init_object (node);
9434 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
9435 vat_json_object_add_bytes (node, "vss-type", &mp->vss_type,
9436 sizeof (mp->vss_type));
9437 vat_json_object_add_string_copy (node, "vss-vpn-ascii-id",
9438 mp->vss_vpn_ascii_id);
9439 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
9440 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
9444 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
9445 vat_json_object_add_ip6 (node, "src_address", ip6);
9449 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
9450 vat_json_object_add_ip4 (node, "src_address", ip4);
9453 for (i = 0; i < count; i++)
9455 s = &mp->servers[i];
9457 vat_json_object_add_uint (node, "server-table-id",
9458 ntohl (s->server_vrf_id));
9462 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
9463 vat_json_object_add_ip4 (node, "src_address", ip4);
9467 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
9468 vat_json_object_add_ip6 (node, "server_address", ip6);
9474 api_dhcp_proxy_dump (vat_main_t * vam)
9476 unformat_input_t *i = vam->input;
9477 vl_api_control_ping_t *mp_ping;
9478 vl_api_dhcp_proxy_dump_t *mp;
9482 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9484 if (unformat (i, "ipv6"))
9488 clib_warning ("parse error '%U'", format_unformat_error, i);
9493 M (DHCP_PROXY_DUMP, mp);
9495 mp->is_ip6 = is_ipv6;
9498 /* Use a control ping for synchronization */
9499 MPING (CONTROL_PING, mp_ping);
9507 api_dhcp_proxy_set_vss (vat_main_t * vam)
9509 unformat_input_t *i = vam->input;
9510 vl_api_dhcp_proxy_set_vss_t *mp;
9514 u8 vss_type = VSS_TYPE_DEFAULT;
9515 u8 *vpn_ascii_id = 0;
9520 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9522 if (unformat (i, "tbl_id %d", &tbl_id))
9524 else if (unformat (i, "vpn_ascii_id %s", &vpn_ascii_id))
9525 vss_type = VSS_TYPE_ASCII;
9526 else if (unformat (i, "fib_id %d", &fib_id))
9527 vss_type = VSS_TYPE_VPN_ID;
9528 else if (unformat (i, "oui %d", &oui))
9529 vss_type = VSS_TYPE_VPN_ID;
9530 else if (unformat (i, "ipv6"))
9532 else if (unformat (i, "del"))
9540 errmsg ("missing tbl_id ");
9541 vec_free (vpn_ascii_id);
9545 if ((vpn_ascii_id) && (vec_len (vpn_ascii_id) > 128))
9547 errmsg ("vpn_ascii_id cannot be longer than 128 ");
9548 vec_free (vpn_ascii_id);
9552 M (DHCP_PROXY_SET_VSS, mp);
9553 mp->tbl_id = ntohl (tbl_id);
9554 mp->vss_type = vss_type;
9557 clib_memcpy (mp->vpn_ascii_id, vpn_ascii_id, vec_len (vpn_ascii_id));
9558 mp->vpn_ascii_id[vec_len (vpn_ascii_id)] = 0;
9560 mp->vpn_index = ntohl (fib_id);
9561 mp->oui = ntohl (oui);
9562 mp->is_ipv6 = is_ipv6;
9563 mp->is_add = is_add;
9568 vec_free (vpn_ascii_id);
9573 api_dhcp_client_config (vat_main_t * vam)
9575 unformat_input_t *i = vam->input;
9576 vl_api_dhcp_client_config_t *mp;
9578 u8 sw_if_index_set = 0;
9581 u8 disable_event = 0;
9584 /* Parse args required to build the message */
9585 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9587 if (unformat (i, "del"))
9590 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9591 sw_if_index_set = 1;
9592 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9593 sw_if_index_set = 1;
9594 else if (unformat (i, "hostname %s", &hostname))
9596 else if (unformat (i, "disable_event"))
9602 if (sw_if_index_set == 0)
9604 errmsg ("missing interface name or sw_if_index");
9608 if (vec_len (hostname) > 63)
9610 errmsg ("hostname too long");
9612 vec_add1 (hostname, 0);
9614 /* Construct the API message */
9615 M (DHCP_CLIENT_CONFIG, mp);
9617 mp->is_add = is_add;
9618 mp->client.sw_if_index = htonl (sw_if_index);
9619 clib_memcpy (mp->client.hostname, hostname, vec_len (hostname));
9620 vec_free (hostname);
9621 mp->client.want_dhcp_event = disable_event ? 0 : 1;
9622 mp->client.pid = htonl (getpid ());
9627 /* Wait for a reply, return good/bad news */
9633 api_set_ip_flow_hash (vat_main_t * vam)
9635 unformat_input_t *i = vam->input;
9636 vl_api_set_ip_flow_hash_t *mp;
9648 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9650 if (unformat (i, "vrf %d", &vrf_id))
9652 else if (unformat (i, "ipv6"))
9654 else if (unformat (i, "src"))
9656 else if (unformat (i, "dst"))
9658 else if (unformat (i, "sport"))
9660 else if (unformat (i, "dport"))
9662 else if (unformat (i, "proto"))
9664 else if (unformat (i, "reverse"))
9669 clib_warning ("parse error '%U'", format_unformat_error, i);
9674 if (vrf_id_set == 0)
9676 errmsg ("missing vrf id");
9680 M (SET_IP_FLOW_HASH, mp);
9686 mp->reverse = reverse;
9687 mp->vrf_id = ntohl (vrf_id);
9688 mp->is_ipv6 = is_ipv6;
9696 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
9698 unformat_input_t *i = vam->input;
9699 vl_api_sw_interface_ip6_enable_disable_t *mp;
9701 u8 sw_if_index_set = 0;
9705 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9707 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9708 sw_if_index_set = 1;
9709 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9710 sw_if_index_set = 1;
9711 else if (unformat (i, "enable"))
9713 else if (unformat (i, "disable"))
9717 clib_warning ("parse error '%U'", format_unformat_error, i);
9722 if (sw_if_index_set == 0)
9724 errmsg ("missing interface name or sw_if_index");
9728 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
9730 mp->sw_if_index = ntohl (sw_if_index);
9731 mp->enable = enable;
9739 api_ip6nd_proxy_add_del (vat_main_t * vam)
9741 unformat_input_t *i = vam->input;
9742 vl_api_ip6nd_proxy_add_del_t *mp;
9743 u32 sw_if_index = ~0;
9744 u8 v6_address_set = 0;
9745 vl_api_ip6_address_t v6address;
9749 /* Parse args required to build the message */
9750 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9752 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9754 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9756 else if (unformat (i, "%U", unformat_vl_api_ip6_address, &v6address))
9758 if (unformat (i, "del"))
9762 clib_warning ("parse error '%U'", format_unformat_error, i);
9767 if (sw_if_index == ~0)
9769 errmsg ("missing interface name or sw_if_index");
9772 if (!v6_address_set)
9774 errmsg ("no address set");
9778 /* Construct the API message */
9779 M (IP6ND_PROXY_ADD_DEL, mp);
9781 mp->is_del = is_del;
9782 mp->sw_if_index = ntohl (sw_if_index);
9783 clib_memcpy (mp->ip, v6address, sizeof (v6address));
9788 /* Wait for a reply, return good/bad news */
9794 api_ip6nd_proxy_dump (vat_main_t * vam)
9796 vl_api_ip6nd_proxy_dump_t *mp;
9797 vl_api_control_ping_t *mp_ping;
9800 M (IP6ND_PROXY_DUMP, mp);
9804 /* Use a control ping for synchronization */
9805 MPING (CONTROL_PING, mp_ping);
9812 static void vl_api_ip6nd_proxy_details_t_handler
9813 (vl_api_ip6nd_proxy_details_t * mp)
9815 vat_main_t *vam = &vat_main;
9817 print (vam->ofp, "host %U sw_if_index %d",
9818 format_vl_api_ip6_address, mp->ip, ntohl (mp->sw_if_index));
9821 static void vl_api_ip6nd_proxy_details_t_handler_json
9822 (vl_api_ip6nd_proxy_details_t * mp)
9824 vat_main_t *vam = &vat_main;
9825 struct in6_addr ip6;
9826 vat_json_node_t *node = NULL;
9828 if (VAT_JSON_ARRAY != vam->json_tree.type)
9830 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9831 vat_json_init_array (&vam->json_tree);
9833 node = vat_json_array_add (&vam->json_tree);
9835 vat_json_init_object (node);
9836 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9838 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
9839 vat_json_object_add_ip6 (node, "host", ip6);
9843 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
9845 unformat_input_t *i = vam->input;
9846 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
9848 u8 sw_if_index_set = 0;
9849 u8 v6_address_set = 0;
9850 vl_api_prefix_t pfx;
9852 u8 no_advertise = 0;
9854 u8 no_autoconfig = 0;
9857 u32 val_lifetime = 0;
9858 u32 pref_lifetime = 0;
9861 /* Parse args required to build the message */
9862 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9864 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9865 sw_if_index_set = 1;
9866 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9867 sw_if_index_set = 1;
9868 else if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
9870 else if (unformat (i, "val_life %d", &val_lifetime))
9872 else if (unformat (i, "pref_life %d", &pref_lifetime))
9874 else if (unformat (i, "def"))
9876 else if (unformat (i, "noadv"))
9878 else if (unformat (i, "offl"))
9880 else if (unformat (i, "noauto"))
9882 else if (unformat (i, "nolink"))
9884 else if (unformat (i, "isno"))
9888 clib_warning ("parse error '%U'", format_unformat_error, i);
9893 if (sw_if_index_set == 0)
9895 errmsg ("missing interface name or sw_if_index");
9898 if (!v6_address_set)
9900 errmsg ("no address set");
9904 /* Construct the API message */
9905 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
9907 mp->sw_if_index = ntohl (sw_if_index);
9908 clib_memcpy (&mp->prefix, &pfx, sizeof (pfx));
9909 mp->use_default = use_default;
9910 mp->no_advertise = no_advertise;
9911 mp->off_link = off_link;
9912 mp->no_autoconfig = no_autoconfig;
9913 mp->no_onlink = no_onlink;
9915 mp->val_lifetime = ntohl (val_lifetime);
9916 mp->pref_lifetime = ntohl (pref_lifetime);
9921 /* Wait for a reply, return good/bad news */
9927 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
9929 unformat_input_t *i = vam->input;
9930 vl_api_sw_interface_ip6nd_ra_config_t *mp;
9932 u8 sw_if_index_set = 0;
9937 u8 send_unicast = 0;
9940 u8 default_router = 0;
9941 u32 max_interval = 0;
9942 u32 min_interval = 0;
9944 u32 initial_count = 0;
9945 u32 initial_interval = 0;
9949 /* Parse args required to build the message */
9950 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9952 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9953 sw_if_index_set = 1;
9954 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9955 sw_if_index_set = 1;
9956 else if (unformat (i, "maxint %d", &max_interval))
9958 else if (unformat (i, "minint %d", &min_interval))
9960 else if (unformat (i, "life %d", &lifetime))
9962 else if (unformat (i, "count %d", &initial_count))
9964 else if (unformat (i, "interval %d", &initial_interval))
9966 else if (unformat (i, "suppress") || unformat (i, "surpress"))
9968 else if (unformat (i, "managed"))
9970 else if (unformat (i, "other"))
9972 else if (unformat (i, "ll"))
9974 else if (unformat (i, "send"))
9976 else if (unformat (i, "cease"))
9978 else if (unformat (i, "isno"))
9980 else if (unformat (i, "def"))
9984 clib_warning ("parse error '%U'", format_unformat_error, i);
9989 if (sw_if_index_set == 0)
9991 errmsg ("missing interface name or sw_if_index");
9995 /* Construct the API message */
9996 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
9998 mp->sw_if_index = ntohl (sw_if_index);
9999 mp->max_interval = ntohl (max_interval);
10000 mp->min_interval = ntohl (min_interval);
10001 mp->lifetime = ntohl (lifetime);
10002 mp->initial_count = ntohl (initial_count);
10003 mp->initial_interval = ntohl (initial_interval);
10004 mp->suppress = suppress;
10005 mp->managed = managed;
10007 mp->ll_option = ll_option;
10008 mp->send_unicast = send_unicast;
10011 mp->default_router = default_router;
10016 /* Wait for a reply, return good/bad news */
10022 api_set_arp_neighbor_limit (vat_main_t * vam)
10024 unformat_input_t *i = vam->input;
10025 vl_api_set_arp_neighbor_limit_t *mp;
10031 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10033 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
10035 else if (unformat (i, "ipv6"))
10039 clib_warning ("parse error '%U'", format_unformat_error, i);
10044 if (limit_set == 0)
10046 errmsg ("missing limit value");
10050 M (SET_ARP_NEIGHBOR_LIMIT, mp);
10052 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
10053 mp->is_ipv6 = is_ipv6;
10061 api_l2_patch_add_del (vat_main_t * vam)
10063 unformat_input_t *i = vam->input;
10064 vl_api_l2_patch_add_del_t *mp;
10065 u32 rx_sw_if_index;
10066 u8 rx_sw_if_index_set = 0;
10067 u32 tx_sw_if_index;
10068 u8 tx_sw_if_index_set = 0;
10072 /* Parse args required to build the message */
10073 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10075 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
10076 rx_sw_if_index_set = 1;
10077 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
10078 tx_sw_if_index_set = 1;
10079 else if (unformat (i, "rx"))
10081 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10083 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10085 rx_sw_if_index_set = 1;
10090 else if (unformat (i, "tx"))
10092 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10094 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10096 tx_sw_if_index_set = 1;
10101 else if (unformat (i, "del"))
10107 if (rx_sw_if_index_set == 0)
10109 errmsg ("missing rx interface name or rx_sw_if_index");
10113 if (tx_sw_if_index_set == 0)
10115 errmsg ("missing tx interface name or tx_sw_if_index");
10119 M (L2_PATCH_ADD_DEL, mp);
10121 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
10122 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
10123 mp->is_add = is_add;
10131 u8 localsid_addr[16];
10140 api_sr_localsid_add_del (vat_main_t * vam)
10142 unformat_input_t *i = vam->input;
10143 vl_api_sr_localsid_add_del_t *mp;
10146 ip6_address_t localsid;
10150 u32 fib_table = ~(u32) 0;
10151 ip6_address_t nh_addr6;
10152 ip4_address_t nh_addr4;
10153 clib_memset (&nh_addr6, 0, sizeof (ip6_address_t));
10154 clib_memset (&nh_addr4, 0, sizeof (ip4_address_t));
10156 bool nexthop_set = 0;
10160 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10162 if (unformat (i, "del"))
10164 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
10165 else if (unformat (i, "next-hop %U", unformat_ip4_address, &nh_addr4))
10167 else if (unformat (i, "next-hop %U", unformat_ip6_address, &nh_addr6))
10169 else if (unformat (i, "behavior %u", &behavior));
10170 else if (unformat (i, "sw_if_index %u", &sw_if_index));
10171 else if (unformat (i, "fib-table %u", &fib_table));
10172 else if (unformat (i, "end.psp %u", &behavior));
10177 M (SR_LOCALSID_ADD_DEL, mp);
10179 clib_memcpy (mp->localsid.addr, &localsid, sizeof (mp->localsid));
10182 clib_memcpy (mp->nh_addr6, &nh_addr6, sizeof (mp->nh_addr6));
10183 clib_memcpy (mp->nh_addr4, &nh_addr4, sizeof (mp->nh_addr4));
10185 mp->behavior = behavior;
10186 mp->sw_if_index = ntohl (sw_if_index);
10187 mp->fib_table = ntohl (fib_table);
10188 mp->end_psp = end_psp;
10189 mp->is_del = is_del;
10197 api_ioam_enable (vat_main_t * vam)
10199 unformat_input_t *input = vam->input;
10200 vl_api_ioam_enable_t *mp;
10202 int has_trace_option = 0;
10203 int has_pot_option = 0;
10204 int has_seqno_option = 0;
10205 int has_analyse_option = 0;
10208 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10210 if (unformat (input, "trace"))
10211 has_trace_option = 1;
10212 else if (unformat (input, "pot"))
10213 has_pot_option = 1;
10214 else if (unformat (input, "seqno"))
10215 has_seqno_option = 1;
10216 else if (unformat (input, "analyse"))
10217 has_analyse_option = 1;
10221 M (IOAM_ENABLE, mp);
10222 mp->id = htons (id);
10223 mp->seqno = has_seqno_option;
10224 mp->analyse = has_analyse_option;
10225 mp->pot_enable = has_pot_option;
10226 mp->trace_enable = has_trace_option;
10235 api_ioam_disable (vat_main_t * vam)
10237 vl_api_ioam_disable_t *mp;
10240 M (IOAM_DISABLE, mp);
10246 #define foreach_tcp_proto_field \
10250 #define foreach_udp_proto_field \
10254 #define foreach_ip4_proto_field \
10266 u16 src_port, dst_port;
10269 #if VPP_API_TEST_BUILTIN == 0
10271 unformat_tcp_mask (unformat_input_t * input, va_list * args)
10273 u8 **maskp = va_arg (*args, u8 **);
10275 u8 found_something = 0;
10278 #define _(a) u8 a=0;
10279 foreach_tcp_proto_field;
10282 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10285 #define _(a) else if (unformat (input, #a)) a=1;
10286 foreach_tcp_proto_field
10292 #define _(a) found_something += a;
10293 foreach_tcp_proto_field;
10296 if (found_something == 0)
10299 vec_validate (mask, sizeof (*tcp) - 1);
10301 tcp = (tcp_header_t *) mask;
10303 #define _(a) if (a) clib_memset (&tcp->a, 0xff, sizeof (tcp->a));
10304 foreach_tcp_proto_field;
10312 unformat_udp_mask (unformat_input_t * input, va_list * args)
10314 u8 **maskp = va_arg (*args, u8 **);
10316 u8 found_something = 0;
10319 #define _(a) u8 a=0;
10320 foreach_udp_proto_field;
10323 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10326 #define _(a) else if (unformat (input, #a)) a=1;
10327 foreach_udp_proto_field
10333 #define _(a) found_something += a;
10334 foreach_udp_proto_field;
10337 if (found_something == 0)
10340 vec_validate (mask, sizeof (*udp) - 1);
10342 udp = (udp_header_t *) mask;
10344 #define _(a) if (a) clib_memset (&udp->a, 0xff, sizeof (udp->a));
10345 foreach_udp_proto_field;
10353 unformat_l4_mask (unformat_input_t * input, va_list * args)
10355 u8 **maskp = va_arg (*args, u8 **);
10356 u16 src_port = 0, dst_port = 0;
10357 tcpudp_header_t *tcpudp;
10359 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10361 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
10363 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
10365 else if (unformat (input, "src_port"))
10367 else if (unformat (input, "dst_port"))
10373 if (!src_port && !dst_port)
10377 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
10379 tcpudp = (tcpudp_header_t *) mask;
10380 tcpudp->src_port = src_port;
10381 tcpudp->dst_port = dst_port;
10389 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10391 u8 **maskp = va_arg (*args, u8 **);
10393 u8 found_something = 0;
10396 #define _(a) u8 a=0;
10397 foreach_ip4_proto_field;
10403 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10405 if (unformat (input, "version"))
10407 else if (unformat (input, "hdr_length"))
10409 else if (unformat (input, "src"))
10411 else if (unformat (input, "dst"))
10413 else if (unformat (input, "proto"))
10416 #define _(a) else if (unformat (input, #a)) a=1;
10417 foreach_ip4_proto_field
10423 #define _(a) found_something += a;
10424 foreach_ip4_proto_field;
10427 if (found_something == 0)
10430 vec_validate (mask, sizeof (*ip) - 1);
10432 ip = (ip4_header_t *) mask;
10434 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
10435 foreach_ip4_proto_field;
10438 ip->ip_version_and_header_length = 0;
10441 ip->ip_version_and_header_length |= 0xF0;
10444 ip->ip_version_and_header_length |= 0x0F;
10450 #define foreach_ip6_proto_field \
10453 _(payload_length) \
10458 unformat_ip6_mask (unformat_input_t * input, va_list * args)
10460 u8 **maskp = va_arg (*args, u8 **);
10462 u8 found_something = 0;
10464 u32 ip_version_traffic_class_and_flow_label;
10466 #define _(a) u8 a=0;
10467 foreach_ip6_proto_field;
10470 u8 traffic_class = 0;
10473 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10475 if (unformat (input, "version"))
10477 else if (unformat (input, "traffic-class"))
10479 else if (unformat (input, "flow-label"))
10481 else if (unformat (input, "src"))
10483 else if (unformat (input, "dst"))
10485 else if (unformat (input, "proto"))
10488 #define _(a) else if (unformat (input, #a)) a=1;
10489 foreach_ip6_proto_field
10495 #define _(a) found_something += a;
10496 foreach_ip6_proto_field;
10499 if (found_something == 0)
10502 vec_validate (mask, sizeof (*ip) - 1);
10504 ip = (ip6_header_t *) mask;
10506 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
10507 foreach_ip6_proto_field;
10510 ip_version_traffic_class_and_flow_label = 0;
10513 ip_version_traffic_class_and_flow_label |= 0xF0000000;
10516 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
10519 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
10521 ip->ip_version_traffic_class_and_flow_label =
10522 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10529 unformat_l3_mask (unformat_input_t * input, va_list * args)
10531 u8 **maskp = va_arg (*args, u8 **);
10533 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10535 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
10537 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
10546 unformat_l2_mask (unformat_input_t * input, va_list * args)
10548 u8 **maskp = va_arg (*args, u8 **);
10555 u8 ignore_tag1 = 0;
10556 u8 ignore_tag2 = 0;
10563 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10565 if (unformat (input, "src"))
10567 else if (unformat (input, "dst"))
10569 else if (unformat (input, "proto"))
10571 else if (unformat (input, "tag1"))
10573 else if (unformat (input, "tag2"))
10575 else if (unformat (input, "ignore-tag1"))
10577 else if (unformat (input, "ignore-tag2"))
10579 else if (unformat (input, "cos1"))
10581 else if (unformat (input, "cos2"))
10583 else if (unformat (input, "dot1q"))
10585 else if (unformat (input, "dot1ad"))
10590 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
10591 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10594 if (tag1 || ignore_tag1 || cos1 || dot1q)
10596 if (tag2 || ignore_tag2 || cos2 || dot1ad)
10599 vec_validate (mask, len - 1);
10602 clib_memset (mask, 0xff, 6);
10605 clib_memset (mask + 6, 0xff, 6);
10607 if (tag2 || dot1ad)
10609 /* inner vlan tag */
10618 mask[21] = mask[20] = 0xff;
10639 mask[16] = mask[17] = 0xff;
10649 mask[12] = mask[13] = 0xff;
10656 unformat_classify_mask (unformat_input_t * input, va_list * args)
10658 u8 **maskp = va_arg (*args, u8 **);
10659 u32 *skipp = va_arg (*args, u32 *);
10660 u32 *matchp = va_arg (*args, u32 *);
10668 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10670 if (unformat (input, "hex %U", unformat_hex_string, &mask))
10672 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
10674 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
10676 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
10690 if (mask || l2 || l3 || l4)
10692 if (l2 || l3 || l4)
10694 /* "With a free Ethernet header in every package" */
10696 vec_validate (l2, 13);
10700 vec_append (mask, l3);
10705 vec_append (mask, l4);
10710 /* Scan forward looking for the first significant mask octet */
10711 for (i = 0; i < vec_len (mask); i++)
10715 /* compute (skip, match) params */
10716 *skipp = i / sizeof (u32x4);
10717 vec_delete (mask, *skipp * sizeof (u32x4), 0);
10719 /* Pad mask to an even multiple of the vector size */
10720 while (vec_len (mask) % sizeof (u32x4))
10721 vec_add1 (mask, 0);
10723 match = vec_len (mask) / sizeof (u32x4);
10725 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
10727 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
10728 if (*tmp || *(tmp + 1))
10733 clib_warning ("BUG: match 0");
10735 _vec_len (mask) = match * sizeof (u32x4);
10745 #endif /* VPP_API_TEST_BUILTIN */
10747 #define foreach_l2_next \
10749 _(ethernet, ETHERNET_INPUT) \
10750 _(ip4, IP4_INPUT) \
10754 unformat_l2_next_index (unformat_input_t * input, va_list * args)
10756 u32 *miss_next_indexp = va_arg (*args, u32 *);
10757 u32 next_index = 0;
10761 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
10765 if (unformat (input, "%d", &tmp))
10774 *miss_next_indexp = next_index;
10778 #define foreach_ip_next \
10781 _(rewrite, REWRITE)
10784 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
10786 u32 *miss_next_indexp = va_arg (*args, u32 *);
10787 u32 next_index = 0;
10791 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
10795 if (unformat (input, "%d", &tmp))
10804 *miss_next_indexp = next_index;
10808 #define foreach_acl_next \
10812 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
10814 u32 *miss_next_indexp = va_arg (*args, u32 *);
10815 u32 next_index = 0;
10819 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
10823 if (unformat (input, "permit"))
10828 else if (unformat (input, "%d", &tmp))
10837 *miss_next_indexp = next_index;
10842 unformat_policer_precolor (unformat_input_t * input, va_list * args)
10844 u32 *r = va_arg (*args, u32 *);
10846 if (unformat (input, "conform-color"))
10847 *r = POLICE_CONFORM;
10848 else if (unformat (input, "exceed-color"))
10849 *r = POLICE_EXCEED;
10857 api_classify_add_del_table (vat_main_t * vam)
10859 unformat_input_t *i = vam->input;
10860 vl_api_classify_add_del_table_t *mp;
10867 u32 table_index = ~0;
10868 u32 next_table_index = ~0;
10869 u32 miss_next_index = ~0;
10870 u32 memory_size = 32 << 20;
10872 u32 current_data_flag = 0;
10873 int current_data_offset = 0;
10876 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10878 if (unformat (i, "del"))
10880 else if (unformat (i, "del-chain"))
10885 else if (unformat (i, "buckets %d", &nbuckets))
10887 else if (unformat (i, "memory_size %d", &memory_size))
10889 else if (unformat (i, "skip %d", &skip))
10891 else if (unformat (i, "match %d", &match))
10893 else if (unformat (i, "table %d", &table_index))
10895 else if (unformat (i, "mask %U", unformat_classify_mask,
10896 &mask, &skip, &match))
10898 else if (unformat (i, "next-table %d", &next_table_index))
10900 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
10903 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
10906 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
10909 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
10911 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
10917 if (is_add && mask == 0)
10919 errmsg ("Mask required");
10923 if (is_add && skip == ~0)
10925 errmsg ("skip count required");
10929 if (is_add && match == ~0)
10931 errmsg ("match count required");
10935 if (!is_add && table_index == ~0)
10937 errmsg ("table index required for delete");
10941 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
10943 mp->is_add = is_add;
10944 mp->del_chain = del_chain;
10945 mp->table_index = ntohl (table_index);
10946 mp->nbuckets = ntohl (nbuckets);
10947 mp->memory_size = ntohl (memory_size);
10948 mp->skip_n_vectors = ntohl (skip);
10949 mp->match_n_vectors = ntohl (match);
10950 mp->next_table_index = ntohl (next_table_index);
10951 mp->miss_next_index = ntohl (miss_next_index);
10952 mp->current_data_flag = ntohl (current_data_flag);
10953 mp->current_data_offset = ntohl (current_data_offset);
10954 mp->mask_len = ntohl (vec_len (mask));
10955 clib_memcpy (mp->mask, mask, vec_len (mask));
10964 #if VPP_API_TEST_BUILTIN == 0
10966 unformat_l4_match (unformat_input_t * input, va_list * args)
10968 u8 **matchp = va_arg (*args, u8 **);
10970 u8 *proto_header = 0;
10976 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10978 if (unformat (input, "src_port %d", &src_port))
10980 else if (unformat (input, "dst_port %d", &dst_port))
10986 h.src_port = clib_host_to_net_u16 (src_port);
10987 h.dst_port = clib_host_to_net_u16 (dst_port);
10988 vec_validate (proto_header, sizeof (h) - 1);
10989 memcpy (proto_header, &h, sizeof (h));
10991 *matchp = proto_header;
10997 unformat_ip4_match (unformat_input_t * input, va_list * args)
10999 u8 **matchp = va_arg (*args, u8 **);
11004 int hdr_length = 0;
11005 u32 hdr_length_val;
11006 int src = 0, dst = 0;
11007 ip4_address_t src_val, dst_val;
11014 int fragment_id = 0;
11015 u32 fragment_id_val;
11021 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11023 if (unformat (input, "version %d", &version_val))
11025 else if (unformat (input, "hdr_length %d", &hdr_length_val))
11027 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
11029 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
11031 else if (unformat (input, "proto %d", &proto_val))
11033 else if (unformat (input, "tos %d", &tos_val))
11035 else if (unformat (input, "length %d", &length_val))
11037 else if (unformat (input, "fragment_id %d", &fragment_id_val))
11039 else if (unformat (input, "ttl %d", &ttl_val))
11041 else if (unformat (input, "checksum %d", &checksum_val))
11047 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
11048 + ttl + checksum == 0)
11052 * Aligned because we use the real comparison functions
11054 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11056 ip = (ip4_header_t *) match;
11058 /* These are realistically matched in practice */
11060 ip->src_address.as_u32 = src_val.as_u32;
11063 ip->dst_address.as_u32 = dst_val.as_u32;
11066 ip->protocol = proto_val;
11069 /* These are not, but they're included for completeness */
11071 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
11074 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
11080 ip->length = clib_host_to_net_u16 (length_val);
11086 ip->checksum = clib_host_to_net_u16 (checksum_val);
11093 unformat_ip6_match (unformat_input_t * input, va_list * args)
11095 u8 **matchp = va_arg (*args, u8 **);
11100 u8 traffic_class = 0;
11101 u32 traffic_class_val = 0;
11104 int src = 0, dst = 0;
11105 ip6_address_t src_val, dst_val;
11108 int payload_length = 0;
11109 u32 payload_length_val;
11112 u32 ip_version_traffic_class_and_flow_label;
11114 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11116 if (unformat (input, "version %d", &version_val))
11118 else if (unformat (input, "traffic_class %d", &traffic_class_val))
11120 else if (unformat (input, "flow_label %d", &flow_label_val))
11122 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
11124 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
11126 else if (unformat (input, "proto %d", &proto_val))
11128 else if (unformat (input, "payload_length %d", &payload_length_val))
11129 payload_length = 1;
11130 else if (unformat (input, "hop_limit %d", &hop_limit_val))
11136 if (version + traffic_class + flow_label + src + dst + proto +
11137 payload_length + hop_limit == 0)
11141 * Aligned because we use the real comparison functions
11143 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11145 ip = (ip6_header_t *) match;
11148 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
11151 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
11154 ip->protocol = proto_val;
11156 ip_version_traffic_class_and_flow_label = 0;
11159 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
11162 ip_version_traffic_class_and_flow_label |=
11163 (traffic_class_val & 0xFF) << 20;
11166 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
11168 ip->ip_version_traffic_class_and_flow_label =
11169 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11171 if (payload_length)
11172 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
11175 ip->hop_limit = hop_limit_val;
11182 unformat_l3_match (unformat_input_t * input, va_list * args)
11184 u8 **matchp = va_arg (*args, u8 **);
11186 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11188 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
11190 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
11199 unformat_vlan_tag (unformat_input_t * input, va_list * args)
11201 u8 *tagp = va_arg (*args, u8 *);
11204 if (unformat (input, "%d", &tag))
11206 tagp[0] = (tag >> 8) & 0x0F;
11207 tagp[1] = tag & 0xFF;
11215 unformat_l2_match (unformat_input_t * input, va_list * args)
11217 u8 **matchp = va_arg (*args, u8 **);
11230 u8 ignore_tag1 = 0;
11231 u8 ignore_tag2 = 0;
11237 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11239 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
11242 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
11244 else if (unformat (input, "proto %U",
11245 unformat_ethernet_type_host_byte_order, &proto_val))
11247 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
11249 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
11251 else if (unformat (input, "ignore-tag1"))
11253 else if (unformat (input, "ignore-tag2"))
11255 else if (unformat (input, "cos1 %d", &cos1_val))
11257 else if (unformat (input, "cos2 %d", &cos2_val))
11262 if ((src + dst + proto + tag1 + tag2 +
11263 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11266 if (tag1 || ignore_tag1 || cos1)
11268 if (tag2 || ignore_tag2 || cos2)
11271 vec_validate_aligned (match, len - 1, sizeof (u32x4));
11274 clib_memcpy (match, dst_val, 6);
11277 clib_memcpy (match + 6, src_val, 6);
11281 /* inner vlan tag */
11282 match[19] = tag2_val[1];
11283 match[18] = tag2_val[0];
11285 match[18] |= (cos2_val & 0x7) << 5;
11288 match[21] = proto_val & 0xff;
11289 match[20] = proto_val >> 8;
11293 match[15] = tag1_val[1];
11294 match[14] = tag1_val[0];
11297 match[14] |= (cos1_val & 0x7) << 5;
11303 match[15] = tag1_val[1];
11304 match[14] = tag1_val[0];
11307 match[17] = proto_val & 0xff;
11308 match[16] = proto_val >> 8;
11311 match[14] |= (cos1_val & 0x7) << 5;
11317 match[18] |= (cos2_val & 0x7) << 5;
11319 match[14] |= (cos1_val & 0x7) << 5;
11322 match[13] = proto_val & 0xff;
11323 match[12] = proto_val >> 8;
11331 unformat_qos_source (unformat_input_t * input, va_list * args)
11333 int *qs = va_arg (*args, int *);
11335 if (unformat (input, "ip"))
11336 *qs = QOS_SOURCE_IP;
11337 else if (unformat (input, "mpls"))
11338 *qs = QOS_SOURCE_MPLS;
11339 else if (unformat (input, "ext"))
11340 *qs = QOS_SOURCE_EXT;
11341 else if (unformat (input, "vlan"))
11342 *qs = QOS_SOURCE_VLAN;
11351 api_unformat_classify_match (unformat_input_t * input, va_list * args)
11353 u8 **matchp = va_arg (*args, u8 **);
11354 u32 skip_n_vectors = va_arg (*args, u32);
11355 u32 match_n_vectors = va_arg (*args, u32);
11362 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11364 if (unformat (input, "hex %U", unformat_hex_string, &match))
11366 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
11368 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
11370 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11384 if (match || l2 || l3 || l4)
11386 if (l2 || l3 || l4)
11388 /* "Win a free Ethernet header in every packet" */
11390 vec_validate_aligned (l2, 13, sizeof (u32x4));
11394 vec_append_aligned (match, l3, sizeof (u32x4));
11399 vec_append_aligned (match, l4, sizeof (u32x4));
11404 /* Make sure the vector is big enough even if key is all 0's */
11405 vec_validate_aligned
11406 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11409 /* Set size, include skipped vectors */
11410 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11421 api_classify_add_del_session (vat_main_t * vam)
11423 unformat_input_t *i = vam->input;
11424 vl_api_classify_add_del_session_t *mp;
11426 u32 table_index = ~0;
11427 u32 hit_next_index = ~0;
11428 u32 opaque_index = ~0;
11431 u32 skip_n_vectors = 0;
11432 u32 match_n_vectors = 0;
11438 * Warning: you have to supply skip_n and match_n
11439 * because the API client cant simply look at the classify
11443 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11445 if (unformat (i, "del"))
11447 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
11450 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
11453 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
11456 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
11458 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
11460 else if (unformat (i, "opaque-index %d", &opaque_index))
11462 else if (unformat (i, "skip_n %d", &skip_n_vectors))
11464 else if (unformat (i, "match_n %d", &match_n_vectors))
11466 else if (unformat (i, "match %U", api_unformat_classify_match,
11467 &match, skip_n_vectors, match_n_vectors))
11469 else if (unformat (i, "advance %d", &advance))
11471 else if (unformat (i, "table-index %d", &table_index))
11473 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
11475 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
11477 else if (unformat (i, "action %d", &action))
11479 else if (unformat (i, "metadata %d", &metadata))
11485 if (table_index == ~0)
11487 errmsg ("Table index required");
11491 if (is_add && match == 0)
11493 errmsg ("Match value required");
11497 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
11499 mp->is_add = is_add;
11500 mp->table_index = ntohl (table_index);
11501 mp->hit_next_index = ntohl (hit_next_index);
11502 mp->opaque_index = ntohl (opaque_index);
11503 mp->advance = ntohl (advance);
11504 mp->action = action;
11505 mp->metadata = ntohl (metadata);
11506 mp->match_len = ntohl (vec_len (match));
11507 clib_memcpy (mp->match, match, vec_len (match));
11516 api_classify_set_interface_ip_table (vat_main_t * vam)
11518 unformat_input_t *i = vam->input;
11519 vl_api_classify_set_interface_ip_table_t *mp;
11521 int sw_if_index_set;
11522 u32 table_index = ~0;
11526 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11528 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11529 sw_if_index_set = 1;
11530 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11531 sw_if_index_set = 1;
11532 else if (unformat (i, "table %d", &table_index))
11536 clib_warning ("parse error '%U'", format_unformat_error, i);
11541 if (sw_if_index_set == 0)
11543 errmsg ("missing interface name or sw_if_index");
11548 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
11550 mp->sw_if_index = ntohl (sw_if_index);
11551 mp->table_index = ntohl (table_index);
11552 mp->is_ipv6 = is_ipv6;
11560 api_classify_set_interface_l2_tables (vat_main_t * vam)
11562 unformat_input_t *i = vam->input;
11563 vl_api_classify_set_interface_l2_tables_t *mp;
11565 int sw_if_index_set;
11566 u32 ip4_table_index = ~0;
11567 u32 ip6_table_index = ~0;
11568 u32 other_table_index = ~0;
11572 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11574 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11575 sw_if_index_set = 1;
11576 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11577 sw_if_index_set = 1;
11578 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11580 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11582 else if (unformat (i, "other-table %d", &other_table_index))
11584 else if (unformat (i, "is-input %d", &is_input))
11588 clib_warning ("parse error '%U'", format_unformat_error, i);
11593 if (sw_if_index_set == 0)
11595 errmsg ("missing interface name or sw_if_index");
11600 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
11602 mp->sw_if_index = ntohl (sw_if_index);
11603 mp->ip4_table_index = ntohl (ip4_table_index);
11604 mp->ip6_table_index = ntohl (ip6_table_index);
11605 mp->other_table_index = ntohl (other_table_index);
11606 mp->is_input = (u8) is_input;
11614 api_set_ipfix_exporter (vat_main_t * vam)
11616 unformat_input_t *i = vam->input;
11617 vl_api_set_ipfix_exporter_t *mp;
11618 ip4_address_t collector_address;
11619 u8 collector_address_set = 0;
11620 u32 collector_port = ~0;
11621 ip4_address_t src_address;
11622 u8 src_address_set = 0;
11625 u32 template_interval = ~0;
11626 u8 udp_checksum = 0;
11629 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11631 if (unformat (i, "collector_address %U", unformat_ip4_address,
11632 &collector_address))
11633 collector_address_set = 1;
11634 else if (unformat (i, "collector_port %d", &collector_port))
11636 else if (unformat (i, "src_address %U", unformat_ip4_address,
11638 src_address_set = 1;
11639 else if (unformat (i, "vrf_id %d", &vrf_id))
11641 else if (unformat (i, "path_mtu %d", &path_mtu))
11643 else if (unformat (i, "template_interval %d", &template_interval))
11645 else if (unformat (i, "udp_checksum"))
11651 if (collector_address_set == 0)
11653 errmsg ("collector_address required");
11657 if (src_address_set == 0)
11659 errmsg ("src_address required");
11663 M (SET_IPFIX_EXPORTER, mp);
11665 memcpy (mp->collector_address, collector_address.data,
11666 sizeof (collector_address.data));
11667 mp->collector_port = htons ((u16) collector_port);
11668 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
11669 mp->vrf_id = htonl (vrf_id);
11670 mp->path_mtu = htonl (path_mtu);
11671 mp->template_interval = htonl (template_interval);
11672 mp->udp_checksum = udp_checksum;
11680 api_set_ipfix_classify_stream (vat_main_t * vam)
11682 unformat_input_t *i = vam->input;
11683 vl_api_set_ipfix_classify_stream_t *mp;
11685 u32 src_port = UDP_DST_PORT_ipfix;
11688 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11690 if (unformat (i, "domain %d", &domain_id))
11692 else if (unformat (i, "src_port %d", &src_port))
11696 errmsg ("unknown input `%U'", format_unformat_error, i);
11701 M (SET_IPFIX_CLASSIFY_STREAM, mp);
11703 mp->domain_id = htonl (domain_id);
11704 mp->src_port = htons ((u16) src_port);
11712 api_ipfix_classify_table_add_del (vat_main_t * vam)
11714 unformat_input_t *i = vam->input;
11715 vl_api_ipfix_classify_table_add_del_t *mp;
11717 u32 classify_table_index = ~0;
11719 u8 transport_protocol = 255;
11722 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11724 if (unformat (i, "add"))
11726 else if (unformat (i, "del"))
11728 else if (unformat (i, "table %d", &classify_table_index))
11730 else if (unformat (i, "ip4"))
11732 else if (unformat (i, "ip6"))
11734 else if (unformat (i, "tcp"))
11735 transport_protocol = 6;
11736 else if (unformat (i, "udp"))
11737 transport_protocol = 17;
11740 errmsg ("unknown input `%U'", format_unformat_error, i);
11747 errmsg ("expecting: add|del");
11750 if (classify_table_index == ~0)
11752 errmsg ("classifier table not specified");
11755 if (ip_version == 0)
11757 errmsg ("IP version not specified");
11761 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
11763 mp->is_add = is_add;
11764 mp->table_id = htonl (classify_table_index);
11765 mp->ip_version = ip_version;
11766 mp->transport_protocol = transport_protocol;
11774 api_get_node_index (vat_main_t * vam)
11776 unformat_input_t *i = vam->input;
11777 vl_api_get_node_index_t *mp;
11781 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11783 if (unformat (i, "node %s", &name))
11790 errmsg ("node name required");
11793 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11795 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11799 M (GET_NODE_INDEX, mp);
11800 clib_memcpy (mp->node_name, name, vec_len (name));
11809 api_get_next_index (vat_main_t * vam)
11811 unformat_input_t *i = vam->input;
11812 vl_api_get_next_index_t *mp;
11813 u8 *node_name = 0, *next_node_name = 0;
11816 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11818 if (unformat (i, "node-name %s", &node_name))
11820 else if (unformat (i, "next-node-name %s", &next_node_name))
11824 if (node_name == 0)
11826 errmsg ("node name required");
11829 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
11831 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11835 if (next_node_name == 0)
11837 errmsg ("next node name required");
11840 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
11842 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
11846 M (GET_NEXT_INDEX, mp);
11847 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
11848 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
11849 vec_free (node_name);
11850 vec_free (next_node_name);
11858 api_add_node_next (vat_main_t * vam)
11860 unformat_input_t *i = vam->input;
11861 vl_api_add_node_next_t *mp;
11866 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11868 if (unformat (i, "node %s", &name))
11870 else if (unformat (i, "next %s", &next))
11877 errmsg ("node name required");
11880 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11882 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11887 errmsg ("next node required");
11890 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
11892 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
11896 M (ADD_NODE_NEXT, mp);
11897 clib_memcpy (mp->node_name, name, vec_len (name));
11898 clib_memcpy (mp->next_name, next, vec_len (next));
11908 api_l2tpv3_create_tunnel (vat_main_t * vam)
11910 unformat_input_t *i = vam->input;
11911 ip6_address_t client_address, our_address;
11912 int client_address_set = 0;
11913 int our_address_set = 0;
11914 u32 local_session_id = 0;
11915 u32 remote_session_id = 0;
11916 u64 local_cookie = 0;
11917 u64 remote_cookie = 0;
11918 u8 l2_sublayer_present = 0;
11919 vl_api_l2tpv3_create_tunnel_t *mp;
11922 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11924 if (unformat (i, "client_address %U", unformat_ip6_address,
11926 client_address_set = 1;
11927 else if (unformat (i, "our_address %U", unformat_ip6_address,
11929 our_address_set = 1;
11930 else if (unformat (i, "local_session_id %d", &local_session_id))
11932 else if (unformat (i, "remote_session_id %d", &remote_session_id))
11934 else if (unformat (i, "local_cookie %lld", &local_cookie))
11936 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
11938 else if (unformat (i, "l2-sublayer-present"))
11939 l2_sublayer_present = 1;
11944 if (client_address_set == 0)
11946 errmsg ("client_address required");
11950 if (our_address_set == 0)
11952 errmsg ("our_address required");
11956 M (L2TPV3_CREATE_TUNNEL, mp);
11958 clib_memcpy (mp->client_address, client_address.as_u8,
11959 sizeof (mp->client_address));
11961 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
11963 mp->local_session_id = ntohl (local_session_id);
11964 mp->remote_session_id = ntohl (remote_session_id);
11965 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
11966 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
11967 mp->l2_sublayer_present = l2_sublayer_present;
11976 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
11978 unformat_input_t *i = vam->input;
11980 u8 sw_if_index_set = 0;
11981 u64 new_local_cookie = 0;
11982 u64 new_remote_cookie = 0;
11983 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
11986 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11988 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11989 sw_if_index_set = 1;
11990 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11991 sw_if_index_set = 1;
11992 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
11994 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
12000 if (sw_if_index_set == 0)
12002 errmsg ("missing interface name or sw_if_index");
12006 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
12008 mp->sw_if_index = ntohl (sw_if_index);
12009 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
12010 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
12018 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
12020 unformat_input_t *i = vam->input;
12021 vl_api_l2tpv3_interface_enable_disable_t *mp;
12023 u8 sw_if_index_set = 0;
12024 u8 enable_disable = 1;
12027 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12029 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12030 sw_if_index_set = 1;
12031 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12032 sw_if_index_set = 1;
12033 else if (unformat (i, "enable"))
12034 enable_disable = 1;
12035 else if (unformat (i, "disable"))
12036 enable_disable = 0;
12041 if (sw_if_index_set == 0)
12043 errmsg ("missing interface name or sw_if_index");
12047 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
12049 mp->sw_if_index = ntohl (sw_if_index);
12050 mp->enable_disable = enable_disable;
12058 api_l2tpv3_set_lookup_key (vat_main_t * vam)
12060 unformat_input_t *i = vam->input;
12061 vl_api_l2tpv3_set_lookup_key_t *mp;
12065 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12067 if (unformat (i, "lookup_v6_src"))
12068 key = L2T_LOOKUP_SRC_ADDRESS;
12069 else if (unformat (i, "lookup_v6_dst"))
12070 key = L2T_LOOKUP_DST_ADDRESS;
12071 else if (unformat (i, "lookup_session_id"))
12072 key = L2T_LOOKUP_SESSION_ID;
12077 if (key == (u8) ~ 0)
12079 errmsg ("l2tp session lookup key unset");
12083 M (L2TPV3_SET_LOOKUP_KEY, mp);
12092 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
12093 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12095 vat_main_t *vam = &vat_main;
12097 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
12098 format_ip6_address, mp->our_address,
12099 format_ip6_address, mp->client_address,
12100 clib_net_to_host_u32 (mp->sw_if_index));
12103 " local cookies %016llx %016llx remote cookie %016llx",
12104 clib_net_to_host_u64 (mp->local_cookie[0]),
12105 clib_net_to_host_u64 (mp->local_cookie[1]),
12106 clib_net_to_host_u64 (mp->remote_cookie));
12108 print (vam->ofp, " local session-id %d remote session-id %d",
12109 clib_net_to_host_u32 (mp->local_session_id),
12110 clib_net_to_host_u32 (mp->remote_session_id));
12112 print (vam->ofp, " l2 specific sublayer %s\n",
12113 mp->l2_sublayer_present ? "preset" : "absent");
12117 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
12118 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12120 vat_main_t *vam = &vat_main;
12121 vat_json_node_t *node = NULL;
12122 struct in6_addr addr;
12124 if (VAT_JSON_ARRAY != vam->json_tree.type)
12126 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12127 vat_json_init_array (&vam->json_tree);
12129 node = vat_json_array_add (&vam->json_tree);
12131 vat_json_init_object (node);
12133 clib_memcpy (&addr, mp->our_address, sizeof (addr));
12134 vat_json_object_add_ip6 (node, "our_address", addr);
12135 clib_memcpy (&addr, mp->client_address, sizeof (addr));
12136 vat_json_object_add_ip6 (node, "client_address", addr);
12138 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
12139 vat_json_init_array (lc);
12140 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
12141 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
12142 vat_json_object_add_uint (node, "remote_cookie",
12143 clib_net_to_host_u64 (mp->remote_cookie));
12145 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
12146 vat_json_object_add_uint (node, "local_session_id",
12147 clib_net_to_host_u32 (mp->local_session_id));
12148 vat_json_object_add_uint (node, "remote_session_id",
12149 clib_net_to_host_u32 (mp->remote_session_id));
12150 vat_json_object_add_string_copy (node, "l2_sublayer",
12151 mp->l2_sublayer_present ? (u8 *) "present"
12152 : (u8 *) "absent");
12156 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
12158 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
12159 vl_api_control_ping_t *mp_ping;
12162 /* Get list of l2tpv3-tunnel interfaces */
12163 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
12166 /* Use a control ping for synchronization */
12167 MPING (CONTROL_PING, mp_ping);
12175 static void vl_api_sw_interface_tap_v2_details_t_handler
12176 (vl_api_sw_interface_tap_v2_details_t * mp)
12178 vat_main_t *vam = &vat_main;
12180 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
12181 mp->host_ip4_prefix_len);
12182 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
12183 mp->host_ip6_prefix_len);
12186 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s 0x%-08x",
12187 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
12188 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12189 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
12190 mp->host_bridge, ip4, ip6, ntohl (mp->tap_flags));
12196 static void vl_api_sw_interface_tap_v2_details_t_handler_json
12197 (vl_api_sw_interface_tap_v2_details_t * mp)
12199 vat_main_t *vam = &vat_main;
12200 vat_json_node_t *node = NULL;
12202 if (VAT_JSON_ARRAY != vam->json_tree.type)
12204 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12205 vat_json_init_array (&vam->json_tree);
12207 node = vat_json_array_add (&vam->json_tree);
12209 vat_json_init_object (node);
12210 vat_json_object_add_uint (node, "id", ntohl (mp->id));
12211 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12212 vat_json_object_add_uint (node, "tap_flags", ntohl (mp->tap_flags));
12213 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12214 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12215 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12216 vat_json_object_add_string_copy (node, "host_mac_addr",
12217 format (0, "%U", format_ethernet_address,
12218 &mp->host_mac_addr));
12219 vat_json_object_add_string_copy (node, "host_namespace",
12220 mp->host_namespace);
12221 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
12222 vat_json_object_add_string_copy (node, "host_ip4_addr",
12223 format (0, "%U/%d", format_ip4_address,
12225 mp->host_ip4_prefix_len));
12226 vat_json_object_add_string_copy (node, "host_ip6_addr",
12227 format (0, "%U/%d", format_ip6_address,
12229 mp->host_ip6_prefix_len));
12234 api_sw_interface_tap_v2_dump (vat_main_t * vam)
12236 vl_api_sw_interface_tap_v2_dump_t *mp;
12237 vl_api_control_ping_t *mp_ping;
12241 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
12242 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
12243 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
12246 /* Get list of tap interfaces */
12247 M (SW_INTERFACE_TAP_V2_DUMP, mp);
12250 /* Use a control ping for synchronization */
12251 MPING (CONTROL_PING, mp_ping);
12258 static void vl_api_sw_interface_virtio_pci_details_t_handler
12259 (vl_api_sw_interface_virtio_pci_details_t * mp)
12261 vat_main_t *vam = &vat_main;
12275 addr.as_u32 = ntohl (mp->pci_addr);
12276 u8 *pci_addr = format (0, "%04x:%02x:%02x.%x", addr.domain, addr.bus,
12277 addr.slot, addr.function);
12280 "\n%-12s %-12d %-12d %-12d %-17U 0x%-08llx",
12281 pci_addr, ntohl (mp->sw_if_index),
12282 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12283 format_ethernet_address, mp->mac_addr,
12284 clib_net_to_host_u64 (mp->features));
12285 vec_free (pci_addr);
12288 static void vl_api_sw_interface_virtio_pci_details_t_handler_json
12289 (vl_api_sw_interface_virtio_pci_details_t * mp)
12291 vat_main_t *vam = &vat_main;
12292 vat_json_node_t *node = NULL;
12294 if (VAT_JSON_ARRAY != vam->json_tree.type)
12296 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12297 vat_json_init_array (&vam->json_tree);
12299 node = vat_json_array_add (&vam->json_tree);
12301 vat_json_init_object (node);
12302 vat_json_object_add_uint (node, "pci-addr", ntohl (mp->pci_addr));
12303 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12304 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12305 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12306 vat_json_object_add_uint (node, "features",
12307 clib_net_to_host_u64 (mp->features));
12308 vat_json_object_add_string_copy (node, "mac_addr",
12309 format (0, "%U", format_ethernet_address,
12314 api_sw_interface_virtio_pci_dump (vat_main_t * vam)
12316 vl_api_sw_interface_virtio_pci_dump_t *mp;
12317 vl_api_control_ping_t *mp_ping;
12321 "\n%-12s %-12s %-12s %-12s %-17s %-08s",
12322 "pci_addr", "sw_if_index", "rx_ring_sz", "tx_ring_sz",
12323 "mac_addr", "features");
12325 /* Get list of tap interfaces */
12326 M (SW_INTERFACE_VIRTIO_PCI_DUMP, mp);
12329 /* Use a control ping for synchronization */
12330 MPING (CONTROL_PING, mp_ping);
12338 api_vxlan_offload_rx (vat_main_t * vam)
12340 unformat_input_t *line_input = vam->input;
12341 vl_api_vxlan_offload_rx_t *mp;
12342 u32 hw_if_index = ~0, rx_if_index = ~0;
12346 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12348 if (unformat (line_input, "del"))
12350 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
12353 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
12355 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
12358 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
12362 errmsg ("parse error '%U'", format_unformat_error, line_input);
12367 if (hw_if_index == ~0)
12369 errmsg ("no hw interface");
12373 if (rx_if_index == ~0)
12375 errmsg ("no rx tunnel");
12379 M (VXLAN_OFFLOAD_RX, mp);
12381 mp->hw_if_index = ntohl (hw_if_index);
12382 mp->sw_if_index = ntohl (rx_if_index);
12383 mp->enable = is_add;
12390 static uword unformat_vxlan_decap_next
12391 (unformat_input_t * input, va_list * args)
12393 u32 *result = va_arg (*args, u32 *);
12396 if (unformat (input, "l2"))
12397 *result = VXLAN_INPUT_NEXT_L2_INPUT;
12398 else if (unformat (input, "%d", &tmp))
12406 api_vxlan_add_del_tunnel (vat_main_t * vam)
12408 unformat_input_t *line_input = vam->input;
12409 vl_api_vxlan_add_del_tunnel_t *mp;
12410 ip46_address_t src, dst;
12412 u8 ipv4_set = 0, ipv6_set = 0;
12417 u32 mcast_sw_if_index = ~0;
12418 u32 encap_vrf_id = 0;
12419 u32 decap_next_index = ~0;
12423 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12424 clib_memset (&src, 0, sizeof src);
12425 clib_memset (&dst, 0, sizeof dst);
12427 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12429 if (unformat (line_input, "del"))
12431 else if (unformat (line_input, "instance %d", &instance))
12434 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12440 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12446 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12452 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12457 else if (unformat (line_input, "group %U %U",
12458 unformat_ip4_address, &dst.ip4,
12459 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12461 grp_set = dst_set = 1;
12464 else if (unformat (line_input, "group %U",
12465 unformat_ip4_address, &dst.ip4))
12467 grp_set = dst_set = 1;
12470 else if (unformat (line_input, "group %U %U",
12471 unformat_ip6_address, &dst.ip6,
12472 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12474 grp_set = dst_set = 1;
12477 else if (unformat (line_input, "group %U",
12478 unformat_ip6_address, &dst.ip6))
12480 grp_set = dst_set = 1;
12484 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12486 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12488 else if (unformat (line_input, "decap-next %U",
12489 unformat_vxlan_decap_next, &decap_next_index))
12491 else if (unformat (line_input, "vni %d", &vni))
12495 errmsg ("parse error '%U'", format_unformat_error, line_input);
12502 errmsg ("tunnel src address not specified");
12507 errmsg ("tunnel dst address not specified");
12511 if (grp_set && !ip46_address_is_multicast (&dst))
12513 errmsg ("tunnel group address not multicast");
12516 if (grp_set && mcast_sw_if_index == ~0)
12518 errmsg ("tunnel nonexistent multicast device");
12521 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12523 errmsg ("tunnel dst address must be unicast");
12528 if (ipv4_set && ipv6_set)
12530 errmsg ("both IPv4 and IPv6 addresses specified");
12534 if ((vni == 0) || (vni >> 24))
12536 errmsg ("vni not specified or out of range");
12540 M (VXLAN_ADD_DEL_TUNNEL, mp);
12544 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
12545 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
12549 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
12550 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
12553 mp->instance = htonl (instance);
12554 mp->encap_vrf_id = ntohl (encap_vrf_id);
12555 mp->decap_next_index = ntohl (decap_next_index);
12556 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12557 mp->vni = ntohl (vni);
12558 mp->is_add = is_add;
12559 mp->is_ipv6 = ipv6_set;
12566 static void vl_api_vxlan_tunnel_details_t_handler
12567 (vl_api_vxlan_tunnel_details_t * mp)
12569 vat_main_t *vam = &vat_main;
12570 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12571 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12573 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
12574 ntohl (mp->sw_if_index),
12575 ntohl (mp->instance),
12576 format_ip46_address, &src, IP46_TYPE_ANY,
12577 format_ip46_address, &dst, IP46_TYPE_ANY,
12578 ntohl (mp->encap_vrf_id),
12579 ntohl (mp->decap_next_index), ntohl (mp->vni),
12580 ntohl (mp->mcast_sw_if_index));
12583 static void vl_api_vxlan_tunnel_details_t_handler_json
12584 (vl_api_vxlan_tunnel_details_t * mp)
12586 vat_main_t *vam = &vat_main;
12587 vat_json_node_t *node = NULL;
12589 if (VAT_JSON_ARRAY != vam->json_tree.type)
12591 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12592 vat_json_init_array (&vam->json_tree);
12594 node = vat_json_array_add (&vam->json_tree);
12596 vat_json_init_object (node);
12597 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12599 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
12603 struct in6_addr ip6;
12605 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12606 vat_json_object_add_ip6 (node, "src_address", ip6);
12607 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12608 vat_json_object_add_ip6 (node, "dst_address", ip6);
12612 struct in_addr ip4;
12614 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12615 vat_json_object_add_ip4 (node, "src_address", ip4);
12616 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12617 vat_json_object_add_ip4 (node, "dst_address", ip4);
12619 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12620 vat_json_object_add_uint (node, "decap_next_index",
12621 ntohl (mp->decap_next_index));
12622 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12623 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12624 vat_json_object_add_uint (node, "mcast_sw_if_index",
12625 ntohl (mp->mcast_sw_if_index));
12629 api_vxlan_tunnel_dump (vat_main_t * vam)
12631 unformat_input_t *i = vam->input;
12632 vl_api_vxlan_tunnel_dump_t *mp;
12633 vl_api_control_ping_t *mp_ping;
12635 u8 sw_if_index_set = 0;
12638 /* Parse args required to build the message */
12639 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12641 if (unformat (i, "sw_if_index %d", &sw_if_index))
12642 sw_if_index_set = 1;
12647 if (sw_if_index_set == 0)
12652 if (!vam->json_output)
12654 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
12655 "sw_if_index", "instance", "src_address", "dst_address",
12656 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12659 /* Get list of vxlan-tunnel interfaces */
12660 M (VXLAN_TUNNEL_DUMP, mp);
12662 mp->sw_if_index = htonl (sw_if_index);
12666 /* Use a control ping for synchronization */
12667 MPING (CONTROL_PING, mp_ping);
12674 static uword unformat_geneve_decap_next
12675 (unformat_input_t * input, va_list * args)
12677 u32 *result = va_arg (*args, u32 *);
12680 if (unformat (input, "l2"))
12681 *result = GENEVE_INPUT_NEXT_L2_INPUT;
12682 else if (unformat (input, "%d", &tmp))
12690 api_geneve_add_del_tunnel (vat_main_t * vam)
12692 unformat_input_t *line_input = vam->input;
12693 vl_api_geneve_add_del_tunnel_t *mp;
12694 ip46_address_t src, dst;
12696 u8 ipv4_set = 0, ipv6_set = 0;
12700 u32 mcast_sw_if_index = ~0;
12701 u32 encap_vrf_id = 0;
12702 u32 decap_next_index = ~0;
12706 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12707 clib_memset (&src, 0, sizeof src);
12708 clib_memset (&dst, 0, sizeof dst);
12710 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12712 if (unformat (line_input, "del"))
12715 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12721 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12727 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12733 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12738 else if (unformat (line_input, "group %U %U",
12739 unformat_ip4_address, &dst.ip4,
12740 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12742 grp_set = dst_set = 1;
12745 else if (unformat (line_input, "group %U",
12746 unformat_ip4_address, &dst.ip4))
12748 grp_set = dst_set = 1;
12751 else if (unformat (line_input, "group %U %U",
12752 unformat_ip6_address, &dst.ip6,
12753 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12755 grp_set = dst_set = 1;
12758 else if (unformat (line_input, "group %U",
12759 unformat_ip6_address, &dst.ip6))
12761 grp_set = dst_set = 1;
12765 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12767 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12769 else if (unformat (line_input, "decap-next %U",
12770 unformat_geneve_decap_next, &decap_next_index))
12772 else if (unformat (line_input, "vni %d", &vni))
12776 errmsg ("parse error '%U'", format_unformat_error, line_input);
12783 errmsg ("tunnel src address not specified");
12788 errmsg ("tunnel dst address not specified");
12792 if (grp_set && !ip46_address_is_multicast (&dst))
12794 errmsg ("tunnel group address not multicast");
12797 if (grp_set && mcast_sw_if_index == ~0)
12799 errmsg ("tunnel nonexistent multicast device");
12802 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12804 errmsg ("tunnel dst address must be unicast");
12809 if (ipv4_set && ipv6_set)
12811 errmsg ("both IPv4 and IPv6 addresses specified");
12815 if ((vni == 0) || (vni >> 24))
12817 errmsg ("vni not specified or out of range");
12821 M (GENEVE_ADD_DEL_TUNNEL, mp);
12825 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
12826 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
12830 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
12831 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
12833 mp->encap_vrf_id = ntohl (encap_vrf_id);
12834 mp->decap_next_index = ntohl (decap_next_index);
12835 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12836 mp->vni = ntohl (vni);
12837 mp->is_add = is_add;
12838 mp->is_ipv6 = ipv6_set;
12845 static void vl_api_geneve_tunnel_details_t_handler
12846 (vl_api_geneve_tunnel_details_t * mp)
12848 vat_main_t *vam = &vat_main;
12849 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12850 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12852 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12853 ntohl (mp->sw_if_index),
12854 format_ip46_address, &src, IP46_TYPE_ANY,
12855 format_ip46_address, &dst, IP46_TYPE_ANY,
12856 ntohl (mp->encap_vrf_id),
12857 ntohl (mp->decap_next_index), ntohl (mp->vni),
12858 ntohl (mp->mcast_sw_if_index));
12861 static void vl_api_geneve_tunnel_details_t_handler_json
12862 (vl_api_geneve_tunnel_details_t * mp)
12864 vat_main_t *vam = &vat_main;
12865 vat_json_node_t *node = NULL;
12867 if (VAT_JSON_ARRAY != vam->json_tree.type)
12869 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12870 vat_json_init_array (&vam->json_tree);
12872 node = vat_json_array_add (&vam->json_tree);
12874 vat_json_init_object (node);
12875 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12878 struct in6_addr ip6;
12880 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12881 vat_json_object_add_ip6 (node, "src_address", ip6);
12882 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12883 vat_json_object_add_ip6 (node, "dst_address", ip6);
12887 struct in_addr ip4;
12889 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12890 vat_json_object_add_ip4 (node, "src_address", ip4);
12891 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12892 vat_json_object_add_ip4 (node, "dst_address", ip4);
12894 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12895 vat_json_object_add_uint (node, "decap_next_index",
12896 ntohl (mp->decap_next_index));
12897 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12898 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12899 vat_json_object_add_uint (node, "mcast_sw_if_index",
12900 ntohl (mp->mcast_sw_if_index));
12904 api_geneve_tunnel_dump (vat_main_t * vam)
12906 unformat_input_t *i = vam->input;
12907 vl_api_geneve_tunnel_dump_t *mp;
12908 vl_api_control_ping_t *mp_ping;
12910 u8 sw_if_index_set = 0;
12913 /* Parse args required to build the message */
12914 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12916 if (unformat (i, "sw_if_index %d", &sw_if_index))
12917 sw_if_index_set = 1;
12922 if (sw_if_index_set == 0)
12927 if (!vam->json_output)
12929 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12930 "sw_if_index", "local_address", "remote_address",
12931 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12934 /* Get list of geneve-tunnel interfaces */
12935 M (GENEVE_TUNNEL_DUMP, mp);
12937 mp->sw_if_index = htonl (sw_if_index);
12941 /* Use a control ping for synchronization */
12942 M (CONTROL_PING, mp_ping);
12950 api_gre_tunnel_add_del (vat_main_t * vam)
12952 unformat_input_t *line_input = vam->input;
12953 vl_api_address_t src = { }, dst =
12956 vl_api_gre_tunnel_add_del_t *mp;
12957 vl_api_gre_tunnel_type_t t_type;
12961 u32 outer_fib_id = 0;
12962 u32 session_id = 0;
12966 t_type = GRE_API_TUNNEL_TYPE_L3;
12968 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12970 if (unformat (line_input, "del"))
12972 else if (unformat (line_input, "instance %d", &instance))
12974 else if (unformat (line_input, "src %U", unformat_vl_api_address, &src))
12978 else if (unformat (line_input, "dst %U", unformat_vl_api_address, &dst))
12982 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
12984 else if (unformat (line_input, "teb"))
12985 t_type = GRE_API_TUNNEL_TYPE_TEB;
12986 else if (unformat (line_input, "erspan %d", &session_id))
12987 t_type = GRE_API_TUNNEL_TYPE_ERSPAN;
12990 errmsg ("parse error '%U'", format_unformat_error, line_input);
12997 errmsg ("tunnel src address not specified");
13002 errmsg ("tunnel dst address not specified");
13006 M (GRE_TUNNEL_ADD_DEL, mp);
13008 clib_memcpy (&mp->tunnel.src, &src, sizeof (mp->tunnel.src));
13009 clib_memcpy (&mp->tunnel.dst, &dst, sizeof (mp->tunnel.dst));
13011 mp->tunnel.instance = htonl (instance);
13012 mp->tunnel.outer_fib_id = htonl (outer_fib_id);
13013 mp->is_add = is_add;
13014 mp->tunnel.session_id = htons ((u16) session_id);
13015 mp->tunnel.type = htonl (t_type);
13022 static void vl_api_gre_tunnel_details_t_handler
13023 (vl_api_gre_tunnel_details_t * mp)
13025 vat_main_t *vam = &vat_main;
13027 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
13028 ntohl (mp->tunnel.sw_if_index),
13029 ntohl (mp->tunnel.instance),
13030 format_vl_api_address, &mp->tunnel.src,
13031 format_vl_api_address, &mp->tunnel.dst,
13032 mp->tunnel.type, ntohl (mp->tunnel.outer_fib_id),
13033 ntohl (mp->tunnel.session_id));
13036 static void vl_api_gre_tunnel_details_t_handler_json
13037 (vl_api_gre_tunnel_details_t * mp)
13039 vat_main_t *vam = &vat_main;
13040 vat_json_node_t *node = NULL;
13042 if (VAT_JSON_ARRAY != vam->json_tree.type)
13044 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13045 vat_json_init_array (&vam->json_tree);
13047 node = vat_json_array_add (&vam->json_tree);
13049 vat_json_init_object (node);
13050 vat_json_object_add_uint (node, "sw_if_index",
13051 ntohl (mp->tunnel.sw_if_index));
13052 vat_json_object_add_uint (node, "instance", ntohl (mp->tunnel.instance));
13054 vat_json_object_add_address (node, "src", &mp->tunnel.src);
13055 vat_json_object_add_address (node, "dst", &mp->tunnel.dst);
13056 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel.type);
13057 vat_json_object_add_uint (node, "outer_fib_id",
13058 ntohl (mp->tunnel.outer_fib_id));
13059 vat_json_object_add_uint (node, "session_id", mp->tunnel.session_id);
13063 api_gre_tunnel_dump (vat_main_t * vam)
13065 unformat_input_t *i = vam->input;
13066 vl_api_gre_tunnel_dump_t *mp;
13067 vl_api_control_ping_t *mp_ping;
13069 u8 sw_if_index_set = 0;
13072 /* Parse args required to build the message */
13073 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13075 if (unformat (i, "sw_if_index %d", &sw_if_index))
13076 sw_if_index_set = 1;
13081 if (sw_if_index_set == 0)
13086 if (!vam->json_output)
13088 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
13089 "sw_if_index", "instance", "src_address", "dst_address",
13090 "tunnel_type", "outer_fib_id", "session_id");
13093 /* Get list of gre-tunnel interfaces */
13094 M (GRE_TUNNEL_DUMP, mp);
13096 mp->sw_if_index = htonl (sw_if_index);
13100 /* Use a control ping for synchronization */
13101 MPING (CONTROL_PING, mp_ping);
13109 api_l2_fib_clear_table (vat_main_t * vam)
13111 // unformat_input_t * i = vam->input;
13112 vl_api_l2_fib_clear_table_t *mp;
13115 M (L2_FIB_CLEAR_TABLE, mp);
13123 api_l2_interface_efp_filter (vat_main_t * vam)
13125 unformat_input_t *i = vam->input;
13126 vl_api_l2_interface_efp_filter_t *mp;
13129 u8 sw_if_index_set = 0;
13132 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13134 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13135 sw_if_index_set = 1;
13136 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13137 sw_if_index_set = 1;
13138 else if (unformat (i, "enable"))
13140 else if (unformat (i, "disable"))
13144 clib_warning ("parse error '%U'", format_unformat_error, i);
13149 if (sw_if_index_set == 0)
13151 errmsg ("missing sw_if_index");
13155 M (L2_INTERFACE_EFP_FILTER, mp);
13157 mp->sw_if_index = ntohl (sw_if_index);
13158 mp->enable_disable = enable;
13165 #define foreach_vtr_op \
13166 _("disable", L2_VTR_DISABLED) \
13167 _("push-1", L2_VTR_PUSH_1) \
13168 _("push-2", L2_VTR_PUSH_2) \
13169 _("pop-1", L2_VTR_POP_1) \
13170 _("pop-2", L2_VTR_POP_2) \
13171 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
13172 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
13173 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
13174 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
13177 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
13179 unformat_input_t *i = vam->input;
13180 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
13182 u8 sw_if_index_set = 0;
13185 u32 push_dot1q = 1;
13190 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13192 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13193 sw_if_index_set = 1;
13194 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13195 sw_if_index_set = 1;
13196 else if (unformat (i, "vtr_op %d", &vtr_op))
13198 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
13201 else if (unformat (i, "push_dot1q %d", &push_dot1q))
13203 else if (unformat (i, "tag1 %d", &tag1))
13205 else if (unformat (i, "tag2 %d", &tag2))
13209 clib_warning ("parse error '%U'", format_unformat_error, i);
13214 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
13216 errmsg ("missing vtr operation or sw_if_index");
13220 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
13221 mp->sw_if_index = ntohl (sw_if_index);
13222 mp->vtr_op = ntohl (vtr_op);
13223 mp->push_dot1q = ntohl (push_dot1q);
13224 mp->tag1 = ntohl (tag1);
13225 mp->tag2 = ntohl (tag2);
13233 api_create_vhost_user_if (vat_main_t * vam)
13235 unformat_input_t *i = vam->input;
13236 vl_api_create_vhost_user_if_t *mp;
13239 u8 file_name_set = 0;
13240 u32 custom_dev_instance = ~0;
13242 u8 use_custom_mac = 0;
13243 u8 disable_mrg_rxbuf = 0;
13244 u8 disable_indirect_desc = 0;
13249 /* Shut up coverity */
13250 clib_memset (hwaddr, 0, sizeof (hwaddr));
13252 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13254 if (unformat (i, "socket %s", &file_name))
13258 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13260 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
13261 use_custom_mac = 1;
13262 else if (unformat (i, "server"))
13264 else if (unformat (i, "disable_mrg_rxbuf"))
13265 disable_mrg_rxbuf = 1;
13266 else if (unformat (i, "disable_indirect_desc"))
13267 disable_indirect_desc = 1;
13268 else if (unformat (i, "gso"))
13270 else if (unformat (i, "tag %s", &tag))
13276 if (file_name_set == 0)
13278 errmsg ("missing socket file name");
13282 if (vec_len (file_name) > 255)
13284 errmsg ("socket file name too long");
13287 vec_add1 (file_name, 0);
13289 M (CREATE_VHOST_USER_IF, mp);
13291 mp->is_server = is_server;
13292 mp->disable_mrg_rxbuf = disable_mrg_rxbuf;
13293 mp->disable_indirect_desc = disable_indirect_desc;
13294 mp->enable_gso = enable_gso;
13295 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13296 vec_free (file_name);
13297 if (custom_dev_instance != ~0)
13300 mp->custom_dev_instance = ntohl (custom_dev_instance);
13303 mp->use_custom_mac = use_custom_mac;
13304 clib_memcpy (mp->mac_address, hwaddr, 6);
13306 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
13315 api_modify_vhost_user_if (vat_main_t * vam)
13317 unformat_input_t *i = vam->input;
13318 vl_api_modify_vhost_user_if_t *mp;
13321 u8 file_name_set = 0;
13322 u32 custom_dev_instance = ~0;
13323 u8 sw_if_index_set = 0;
13324 u32 sw_if_index = (u32) ~ 0;
13328 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13330 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13331 sw_if_index_set = 1;
13332 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13333 sw_if_index_set = 1;
13334 else if (unformat (i, "socket %s", &file_name))
13338 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13340 else if (unformat (i, "server"))
13342 else if (unformat (i, "gso"))
13348 if (sw_if_index_set == 0)
13350 errmsg ("missing sw_if_index or interface name");
13354 if (file_name_set == 0)
13356 errmsg ("missing socket file name");
13360 if (vec_len (file_name) > 255)
13362 errmsg ("socket file name too long");
13365 vec_add1 (file_name, 0);
13367 M (MODIFY_VHOST_USER_IF, mp);
13369 mp->sw_if_index = ntohl (sw_if_index);
13370 mp->is_server = is_server;
13371 mp->enable_gso = enable_gso;
13372 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13373 vec_free (file_name);
13374 if (custom_dev_instance != ~0)
13377 mp->custom_dev_instance = ntohl (custom_dev_instance);
13386 api_delete_vhost_user_if (vat_main_t * vam)
13388 unformat_input_t *i = vam->input;
13389 vl_api_delete_vhost_user_if_t *mp;
13390 u32 sw_if_index = ~0;
13391 u8 sw_if_index_set = 0;
13394 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13396 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13397 sw_if_index_set = 1;
13398 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13399 sw_if_index_set = 1;
13404 if (sw_if_index_set == 0)
13406 errmsg ("missing sw_if_index or interface name");
13411 M (DELETE_VHOST_USER_IF, mp);
13413 mp->sw_if_index = ntohl (sw_if_index);
13420 static void vl_api_sw_interface_vhost_user_details_t_handler
13421 (vl_api_sw_interface_vhost_user_details_t * mp)
13423 vat_main_t *vam = &vat_main;
13425 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
13426 (char *) mp->interface_name,
13427 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
13428 clib_net_to_host_u64 (mp->features), mp->is_server,
13429 ntohl (mp->num_regions), (char *) mp->sock_filename);
13430 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
13433 static void vl_api_sw_interface_vhost_user_details_t_handler_json
13434 (vl_api_sw_interface_vhost_user_details_t * mp)
13436 vat_main_t *vam = &vat_main;
13437 vat_json_node_t *node = NULL;
13439 if (VAT_JSON_ARRAY != vam->json_tree.type)
13441 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13442 vat_json_init_array (&vam->json_tree);
13444 node = vat_json_array_add (&vam->json_tree);
13446 vat_json_init_object (node);
13447 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13448 vat_json_object_add_string_copy (node, "interface_name",
13449 mp->interface_name);
13450 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
13451 ntohl (mp->virtio_net_hdr_sz));
13452 vat_json_object_add_uint (node, "features",
13453 clib_net_to_host_u64 (mp->features));
13454 vat_json_object_add_uint (node, "is_server", mp->is_server);
13455 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
13456 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
13457 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
13461 api_sw_interface_vhost_user_dump (vat_main_t * vam)
13463 vl_api_sw_interface_vhost_user_dump_t *mp;
13464 vl_api_control_ping_t *mp_ping;
13467 "Interface name idx hdr_sz features server regions filename");
13469 /* Get list of vhost-user interfaces */
13470 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
13473 /* Use a control ping for synchronization */
13474 MPING (CONTROL_PING, mp_ping);
13482 api_show_version (vat_main_t * vam)
13484 vl_api_show_version_t *mp;
13487 M (SHOW_VERSION, mp);
13496 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
13498 unformat_input_t *line_input = vam->input;
13499 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
13500 ip4_address_t local4, remote4;
13501 ip6_address_t local6, remote6;
13503 u8 ipv4_set = 0, ipv6_set = 0;
13507 u32 mcast_sw_if_index = ~0;
13508 u32 encap_vrf_id = 0;
13509 u32 decap_vrf_id = 0;
13515 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13516 clib_memset (&local4, 0, sizeof local4);
13517 clib_memset (&remote4, 0, sizeof remote4);
13518 clib_memset (&local6, 0, sizeof local6);
13519 clib_memset (&remote6, 0, sizeof remote6);
13521 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13523 if (unformat (line_input, "del"))
13525 else if (unformat (line_input, "local %U",
13526 unformat_ip4_address, &local4))
13531 else if (unformat (line_input, "remote %U",
13532 unformat_ip4_address, &remote4))
13537 else if (unformat (line_input, "local %U",
13538 unformat_ip6_address, &local6))
13543 else if (unformat (line_input, "remote %U",
13544 unformat_ip6_address, &remote6))
13549 else if (unformat (line_input, "group %U %U",
13550 unformat_ip4_address, &remote4,
13551 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13553 grp_set = remote_set = 1;
13556 else if (unformat (line_input, "group %U",
13557 unformat_ip4_address, &remote4))
13559 grp_set = remote_set = 1;
13562 else if (unformat (line_input, "group %U %U",
13563 unformat_ip6_address, &remote6,
13564 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13566 grp_set = remote_set = 1;
13569 else if (unformat (line_input, "group %U",
13570 unformat_ip6_address, &remote6))
13572 grp_set = remote_set = 1;
13576 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13578 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13580 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
13582 else if (unformat (line_input, "vni %d", &vni))
13584 else if (unformat (line_input, "next-ip4"))
13586 else if (unformat (line_input, "next-ip6"))
13588 else if (unformat (line_input, "next-ethernet"))
13590 else if (unformat (line_input, "next-nsh"))
13594 errmsg ("parse error '%U'", format_unformat_error, line_input);
13599 if (local_set == 0)
13601 errmsg ("tunnel local address not specified");
13604 if (remote_set == 0)
13606 errmsg ("tunnel remote address not specified");
13609 if (grp_set && mcast_sw_if_index == ~0)
13611 errmsg ("tunnel nonexistent multicast device");
13614 if (ipv4_set && ipv6_set)
13616 errmsg ("both IPv4 and IPv6 addresses specified");
13622 errmsg ("vni not specified");
13626 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
13631 clib_memcpy (&mp->local, &local6, sizeof (local6));
13632 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
13636 clib_memcpy (&mp->local, &local4, sizeof (local4));
13637 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
13640 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13641 mp->encap_vrf_id = ntohl (encap_vrf_id);
13642 mp->decap_vrf_id = ntohl (decap_vrf_id);
13643 mp->protocol = protocol;
13644 mp->vni = ntohl (vni);
13645 mp->is_add = is_add;
13646 mp->is_ipv6 = ipv6_set;
13653 static void vl_api_vxlan_gpe_tunnel_details_t_handler
13654 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13656 vat_main_t *vam = &vat_main;
13657 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
13658 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
13660 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
13661 ntohl (mp->sw_if_index),
13662 format_ip46_address, &local, IP46_TYPE_ANY,
13663 format_ip46_address, &remote, IP46_TYPE_ANY,
13664 ntohl (mp->vni), mp->protocol,
13665 ntohl (mp->mcast_sw_if_index),
13666 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
13670 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
13671 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13673 vat_main_t *vam = &vat_main;
13674 vat_json_node_t *node = NULL;
13675 struct in_addr ip4;
13676 struct in6_addr ip6;
13678 if (VAT_JSON_ARRAY != vam->json_tree.type)
13680 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13681 vat_json_init_array (&vam->json_tree);
13683 node = vat_json_array_add (&vam->json_tree);
13685 vat_json_init_object (node);
13686 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13689 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
13690 vat_json_object_add_ip6 (node, "local", ip6);
13691 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
13692 vat_json_object_add_ip6 (node, "remote", ip6);
13696 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
13697 vat_json_object_add_ip4 (node, "local", ip4);
13698 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
13699 vat_json_object_add_ip4 (node, "remote", ip4);
13701 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13702 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
13703 vat_json_object_add_uint (node, "mcast_sw_if_index",
13704 ntohl (mp->mcast_sw_if_index));
13705 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13706 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
13707 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13711 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
13713 unformat_input_t *i = vam->input;
13714 vl_api_vxlan_gpe_tunnel_dump_t *mp;
13715 vl_api_control_ping_t *mp_ping;
13717 u8 sw_if_index_set = 0;
13720 /* Parse args required to build the message */
13721 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13723 if (unformat (i, "sw_if_index %d", &sw_if_index))
13724 sw_if_index_set = 1;
13729 if (sw_if_index_set == 0)
13734 if (!vam->json_output)
13736 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
13737 "sw_if_index", "local", "remote", "vni",
13738 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
13741 /* Get list of vxlan-tunnel interfaces */
13742 M (VXLAN_GPE_TUNNEL_DUMP, mp);
13744 mp->sw_if_index = htonl (sw_if_index);
13748 /* Use a control ping for synchronization */
13749 MPING (CONTROL_PING, mp_ping);
13756 static void vl_api_l2_fib_table_details_t_handler
13757 (vl_api_l2_fib_table_details_t * mp)
13759 vat_main_t *vam = &vat_main;
13761 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
13763 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
13764 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
13768 static void vl_api_l2_fib_table_details_t_handler_json
13769 (vl_api_l2_fib_table_details_t * mp)
13771 vat_main_t *vam = &vat_main;
13772 vat_json_node_t *node = NULL;
13774 if (VAT_JSON_ARRAY != vam->json_tree.type)
13776 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13777 vat_json_init_array (&vam->json_tree);
13779 node = vat_json_array_add (&vam->json_tree);
13781 vat_json_init_object (node);
13782 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
13783 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
13784 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13785 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
13786 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
13787 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
13791 api_l2_fib_table_dump (vat_main_t * vam)
13793 unformat_input_t *i = vam->input;
13794 vl_api_l2_fib_table_dump_t *mp;
13795 vl_api_control_ping_t *mp_ping;
13800 /* Parse args required to build the message */
13801 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13803 if (unformat (i, "bd_id %d", &bd_id))
13809 if (bd_id_set == 0)
13811 errmsg ("missing bridge domain");
13815 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
13817 /* Get list of l2 fib entries */
13818 M (L2_FIB_TABLE_DUMP, mp);
13820 mp->bd_id = ntohl (bd_id);
13823 /* Use a control ping for synchronization */
13824 MPING (CONTROL_PING, mp_ping);
13833 api_interface_name_renumber (vat_main_t * vam)
13835 unformat_input_t *line_input = vam->input;
13836 vl_api_interface_name_renumber_t *mp;
13837 u32 sw_if_index = ~0;
13838 u32 new_show_dev_instance = ~0;
13841 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13843 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
13846 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13848 else if (unformat (line_input, "new_show_dev_instance %d",
13849 &new_show_dev_instance))
13855 if (sw_if_index == ~0)
13857 errmsg ("missing interface name or sw_if_index");
13861 if (new_show_dev_instance == ~0)
13863 errmsg ("missing new_show_dev_instance");
13867 M (INTERFACE_NAME_RENUMBER, mp);
13869 mp->sw_if_index = ntohl (sw_if_index);
13870 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
13878 api_ip_probe_neighbor (vat_main_t * vam)
13880 unformat_input_t *i = vam->input;
13881 vl_api_ip_probe_neighbor_t *mp;
13882 vl_api_address_t dst_adr = { };
13888 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13890 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13892 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13894 else if (unformat (i, "address %U", unformat_vl_api_address, &dst_adr))
13902 errmsg ("missing interface");
13908 errmsg ("missing addresses");
13912 M (IP_PROBE_NEIGHBOR, mp);
13914 mp->sw_if_index = ntohl (sw_if_index);
13915 clib_memcpy (&mp->dst, &dst_adr, sizeof (dst_adr));
13923 api_ip_scan_neighbor_enable_disable (vat_main_t * vam)
13925 unformat_input_t *i = vam->input;
13926 vl_api_ip_scan_neighbor_enable_disable_t *mp;
13927 u8 mode = IP_SCAN_V46_NEIGHBORS;
13928 u32 interval = 0, time = 0, update = 0, delay = 0, stale = 0;
13931 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13933 if (unformat (i, "ip4"))
13934 mode = IP_SCAN_V4_NEIGHBORS;
13935 else if (unformat (i, "ip6"))
13936 mode = IP_SCAN_V6_NEIGHBORS;
13937 if (unformat (i, "both"))
13938 mode = IP_SCAN_V46_NEIGHBORS;
13939 else if (unformat (i, "disable"))
13940 mode = IP_SCAN_DISABLED;
13941 else if (unformat (i, "interval %d", &interval))
13943 else if (unformat (i, "max-time %d", &time))
13945 else if (unformat (i, "max-update %d", &update))
13947 else if (unformat (i, "delay %d", &delay))
13949 else if (unformat (i, "stale %d", &stale))
13955 if (interval > 255)
13957 errmsg ("interval cannot exceed 255 minutes.");
13962 errmsg ("max-time cannot exceed 255 usec.");
13967 errmsg ("max-update cannot exceed 255.");
13972 errmsg ("delay cannot exceed 255 msec.");
13977 errmsg ("stale cannot exceed 255 minutes.");
13981 M (IP_SCAN_NEIGHBOR_ENABLE_DISABLE, mp);
13983 mp->scan_interval = interval;
13984 mp->max_proc_time = time;
13985 mp->max_update = update;
13986 mp->scan_int_delay = delay;
13987 mp->stale_threshold = stale;
13995 api_want_ip4_arp_events (vat_main_t * vam)
13997 unformat_input_t *line_input = vam->input;
13998 vl_api_want_ip4_arp_events_t *mp;
13999 ip4_address_t address;
14000 int address_set = 0;
14001 u32 enable_disable = 1;
14004 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14006 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
14008 else if (unformat (line_input, "del"))
14009 enable_disable = 0;
14014 if (address_set == 0)
14016 errmsg ("missing addresses");
14020 M (WANT_IP4_ARP_EVENTS, mp);
14021 mp->enable_disable = enable_disable;
14022 mp->pid = htonl (getpid ());
14023 clib_memcpy (mp->ip, &address, sizeof (address));
14031 api_want_ip6_nd_events (vat_main_t * vam)
14033 unformat_input_t *line_input = vam->input;
14034 vl_api_want_ip6_nd_events_t *mp;
14035 vl_api_ip6_address_t address;
14036 int address_set = 0;
14037 u32 enable_disable = 1;
14040 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14043 (line_input, "address %U", unformat_vl_api_ip6_address, &address))
14045 else if (unformat (line_input, "del"))
14046 enable_disable = 0;
14051 if (address_set == 0)
14053 errmsg ("missing addresses");
14057 M (WANT_IP6_ND_EVENTS, mp);
14058 mp->enable_disable = enable_disable;
14059 mp->pid = htonl (getpid ());
14060 clib_memcpy (&mp->ip, &address, sizeof (address));
14068 api_want_l2_macs_events (vat_main_t * vam)
14070 unformat_input_t *line_input = vam->input;
14071 vl_api_want_l2_macs_events_t *mp;
14072 u8 enable_disable = 1;
14073 u32 scan_delay = 0;
14074 u32 max_macs_in_event = 0;
14075 u32 learn_limit = 0;
14078 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14080 if (unformat (line_input, "learn-limit %d", &learn_limit))
14082 else if (unformat (line_input, "scan-delay %d", &scan_delay))
14084 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
14086 else if (unformat (line_input, "disable"))
14087 enable_disable = 0;
14092 M (WANT_L2_MACS_EVENTS, mp);
14093 mp->enable_disable = enable_disable;
14094 mp->pid = htonl (getpid ());
14095 mp->learn_limit = htonl (learn_limit);
14096 mp->scan_delay = (u8) scan_delay;
14097 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
14104 api_input_acl_set_interface (vat_main_t * vam)
14106 unformat_input_t *i = vam->input;
14107 vl_api_input_acl_set_interface_t *mp;
14109 int sw_if_index_set;
14110 u32 ip4_table_index = ~0;
14111 u32 ip6_table_index = ~0;
14112 u32 l2_table_index = ~0;
14116 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14118 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14119 sw_if_index_set = 1;
14120 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14121 sw_if_index_set = 1;
14122 else if (unformat (i, "del"))
14124 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14126 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14128 else if (unformat (i, "l2-table %d", &l2_table_index))
14132 clib_warning ("parse error '%U'", format_unformat_error, i);
14137 if (sw_if_index_set == 0)
14139 errmsg ("missing interface name or sw_if_index");
14143 M (INPUT_ACL_SET_INTERFACE, mp);
14145 mp->sw_if_index = ntohl (sw_if_index);
14146 mp->ip4_table_index = ntohl (ip4_table_index);
14147 mp->ip6_table_index = ntohl (ip6_table_index);
14148 mp->l2_table_index = ntohl (l2_table_index);
14149 mp->is_add = is_add;
14157 api_output_acl_set_interface (vat_main_t * vam)
14159 unformat_input_t *i = vam->input;
14160 vl_api_output_acl_set_interface_t *mp;
14162 int sw_if_index_set;
14163 u32 ip4_table_index = ~0;
14164 u32 ip6_table_index = ~0;
14165 u32 l2_table_index = ~0;
14169 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14171 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14172 sw_if_index_set = 1;
14173 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14174 sw_if_index_set = 1;
14175 else if (unformat (i, "del"))
14177 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14179 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14181 else if (unformat (i, "l2-table %d", &l2_table_index))
14185 clib_warning ("parse error '%U'", format_unformat_error, i);
14190 if (sw_if_index_set == 0)
14192 errmsg ("missing interface name or sw_if_index");
14196 M (OUTPUT_ACL_SET_INTERFACE, mp);
14198 mp->sw_if_index = ntohl (sw_if_index);
14199 mp->ip4_table_index = ntohl (ip4_table_index);
14200 mp->ip6_table_index = ntohl (ip6_table_index);
14201 mp->l2_table_index = ntohl (l2_table_index);
14202 mp->is_add = is_add;
14210 api_ip_address_dump (vat_main_t * vam)
14212 unformat_input_t *i = vam->input;
14213 vl_api_ip_address_dump_t *mp;
14214 vl_api_control_ping_t *mp_ping;
14215 u32 sw_if_index = ~0;
14216 u8 sw_if_index_set = 0;
14221 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14223 if (unformat (i, "sw_if_index %d", &sw_if_index))
14224 sw_if_index_set = 1;
14226 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14227 sw_if_index_set = 1;
14228 else if (unformat (i, "ipv4"))
14230 else if (unformat (i, "ipv6"))
14236 if (ipv4_set && ipv6_set)
14238 errmsg ("ipv4 and ipv6 flags cannot be both set");
14242 if ((!ipv4_set) && (!ipv6_set))
14244 errmsg ("no ipv4 nor ipv6 flag set");
14248 if (sw_if_index_set == 0)
14250 errmsg ("missing interface name or sw_if_index");
14254 vam->current_sw_if_index = sw_if_index;
14255 vam->is_ipv6 = ipv6_set;
14257 M (IP_ADDRESS_DUMP, mp);
14258 mp->sw_if_index = ntohl (sw_if_index);
14259 mp->is_ipv6 = ipv6_set;
14262 /* Use a control ping for synchronization */
14263 MPING (CONTROL_PING, mp_ping);
14271 api_ip_dump (vat_main_t * vam)
14273 vl_api_ip_dump_t *mp;
14274 vl_api_control_ping_t *mp_ping;
14275 unformat_input_t *in = vam->input;
14282 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
14284 if (unformat (in, "ipv4"))
14286 else if (unformat (in, "ipv6"))
14292 if (ipv4_set && ipv6_set)
14294 errmsg ("ipv4 and ipv6 flags cannot be both set");
14298 if ((!ipv4_set) && (!ipv6_set))
14300 errmsg ("no ipv4 nor ipv6 flag set");
14304 is_ipv6 = ipv6_set;
14305 vam->is_ipv6 = is_ipv6;
14307 /* free old data */
14308 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
14310 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
14312 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
14315 mp->is_ipv6 = ipv6_set;
14318 /* Use a control ping for synchronization */
14319 MPING (CONTROL_PING, mp_ping);
14327 api_ipsec_spd_add_del (vat_main_t * vam)
14329 unformat_input_t *i = vam->input;
14330 vl_api_ipsec_spd_add_del_t *mp;
14335 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14337 if (unformat (i, "spd_id %d", &spd_id))
14339 else if (unformat (i, "del"))
14343 clib_warning ("parse error '%U'", format_unformat_error, i);
14349 errmsg ("spd_id must be set");
14353 M (IPSEC_SPD_ADD_DEL, mp);
14355 mp->spd_id = ntohl (spd_id);
14356 mp->is_add = is_add;
14364 api_ipsec_interface_add_del_spd (vat_main_t * vam)
14366 unformat_input_t *i = vam->input;
14367 vl_api_ipsec_interface_add_del_spd_t *mp;
14369 u8 sw_if_index_set = 0;
14370 u32 spd_id = (u32) ~ 0;
14374 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14376 if (unformat (i, "del"))
14378 else if (unformat (i, "spd_id %d", &spd_id))
14381 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14382 sw_if_index_set = 1;
14383 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14384 sw_if_index_set = 1;
14387 clib_warning ("parse error '%U'", format_unformat_error, i);
14393 if (spd_id == (u32) ~ 0)
14395 errmsg ("spd_id must be set");
14399 if (sw_if_index_set == 0)
14401 errmsg ("missing interface name or sw_if_index");
14405 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
14407 mp->spd_id = ntohl (spd_id);
14408 mp->sw_if_index = ntohl (sw_if_index);
14409 mp->is_add = is_add;
14417 api_ipsec_spd_entry_add_del (vat_main_t * vam)
14419 unformat_input_t *i = vam->input;
14420 vl_api_ipsec_spd_entry_add_del_t *mp;
14421 u8 is_add = 1, is_outbound = 0;
14422 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
14424 u32 rport_start = 0, rport_stop = (u32) ~ 0;
14425 u32 lport_start = 0, lport_stop = (u32) ~ 0;
14426 vl_api_address_t laddr_start = { }, laddr_stop =
14435 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14437 if (unformat (i, "del"))
14439 if (unformat (i, "outbound"))
14441 if (unformat (i, "inbound"))
14443 else if (unformat (i, "spd_id %d", &spd_id))
14445 else if (unformat (i, "sa_id %d", &sa_id))
14447 else if (unformat (i, "priority %d", &priority))
14449 else if (unformat (i, "protocol %d", &protocol))
14451 else if (unformat (i, "lport_start %d", &lport_start))
14453 else if (unformat (i, "lport_stop %d", &lport_stop))
14455 else if (unformat (i, "rport_start %d", &rport_start))
14457 else if (unformat (i, "rport_stop %d", &rport_stop))
14459 else if (unformat (i, "laddr_start %U",
14460 unformat_vl_api_address, &laddr_start))
14462 else if (unformat (i, "laddr_stop %U", unformat_vl_api_address,
14465 else if (unformat (i, "raddr_start %U", unformat_vl_api_address,
14468 else if (unformat (i, "raddr_stop %U", unformat_vl_api_address,
14472 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
14474 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
14476 clib_warning ("unsupported action: 'resolve'");
14482 clib_warning ("parse error '%U'", format_unformat_error, i);
14488 M (IPSEC_SPD_ENTRY_ADD_DEL, mp);
14490 mp->is_add = is_add;
14492 mp->entry.spd_id = ntohl (spd_id);
14493 mp->entry.priority = ntohl (priority);
14494 mp->entry.is_outbound = is_outbound;
14496 clib_memcpy (&mp->entry.remote_address_start, &raddr_start,
14497 sizeof (vl_api_address_t));
14498 clib_memcpy (&mp->entry.remote_address_stop, &raddr_stop,
14499 sizeof (vl_api_address_t));
14500 clib_memcpy (&mp->entry.local_address_start, &laddr_start,
14501 sizeof (vl_api_address_t));
14502 clib_memcpy (&mp->entry.local_address_stop, &laddr_stop,
14503 sizeof (vl_api_address_t));
14505 mp->entry.protocol = (u8) protocol;
14506 mp->entry.local_port_start = ntohs ((u16) lport_start);
14507 mp->entry.local_port_stop = ntohs ((u16) lport_stop);
14508 mp->entry.remote_port_start = ntohs ((u16) rport_start);
14509 mp->entry.remote_port_stop = ntohs ((u16) rport_stop);
14510 mp->entry.policy = (u8) policy;
14511 mp->entry.sa_id = ntohl (sa_id);
14519 api_ipsec_sad_entry_add_del (vat_main_t * vam)
14521 unformat_input_t *i = vam->input;
14522 vl_api_ipsec_sad_entry_add_del_t *mp;
14523 u32 sad_id = 0, spi = 0;
14524 u8 *ck = 0, *ik = 0;
14527 vl_api_ipsec_crypto_alg_t crypto_alg = IPSEC_API_CRYPTO_ALG_NONE;
14528 vl_api_ipsec_integ_alg_t integ_alg = IPSEC_API_INTEG_ALG_NONE;
14529 vl_api_ipsec_sad_flags_t flags = IPSEC_API_SAD_FLAG_NONE;
14530 vl_api_ipsec_proto_t protocol = IPSEC_API_PROTO_AH;
14531 vl_api_address_t tun_src, tun_dst;
14534 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14536 if (unformat (i, "del"))
14538 else if (unformat (i, "sad_id %d", &sad_id))
14540 else if (unformat (i, "spi %d", &spi))
14542 else if (unformat (i, "esp"))
14543 protocol = IPSEC_API_PROTO_ESP;
14545 if (unformat (i, "tunnel_src %U", unformat_vl_api_address, &tun_src))
14547 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
14548 if (ADDRESS_IP6 == tun_src.af)
14549 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
14552 if (unformat (i, "tunnel_dst %U", unformat_vl_api_address, &tun_dst))
14554 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
14555 if (ADDRESS_IP6 == tun_src.af)
14556 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
14559 if (unformat (i, "crypto_alg %U",
14560 unformat_ipsec_api_crypto_alg, &crypto_alg))
14562 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14564 else if (unformat (i, "integ_alg %U",
14565 unformat_ipsec_api_integ_alg, &integ_alg))
14567 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14571 clib_warning ("parse error '%U'", format_unformat_error, i);
14577 M (IPSEC_SAD_ENTRY_ADD_DEL, mp);
14579 mp->is_add = is_add;
14580 mp->entry.sad_id = ntohl (sad_id);
14581 mp->entry.protocol = protocol;
14582 mp->entry.spi = ntohl (spi);
14583 mp->entry.flags = flags;
14585 mp->entry.crypto_algorithm = crypto_alg;
14586 mp->entry.integrity_algorithm = integ_alg;
14587 mp->entry.crypto_key.length = vec_len (ck);
14588 mp->entry.integrity_key.length = vec_len (ik);
14590 if (mp->entry.crypto_key.length > sizeof (mp->entry.crypto_key.data))
14591 mp->entry.crypto_key.length = sizeof (mp->entry.crypto_key.data);
14593 if (mp->entry.integrity_key.length > sizeof (mp->entry.integrity_key.data))
14594 mp->entry.integrity_key.length = sizeof (mp->entry.integrity_key.data);
14597 clib_memcpy (mp->entry.crypto_key.data, ck, mp->entry.crypto_key.length);
14599 clib_memcpy (mp->entry.integrity_key.data, ik,
14600 mp->entry.integrity_key.length);
14602 if (flags & IPSEC_API_SAD_FLAG_IS_TUNNEL)
14604 clib_memcpy (&mp->entry.tunnel_src, &tun_src,
14605 sizeof (mp->entry.tunnel_src));
14606 clib_memcpy (&mp->entry.tunnel_dst, &tun_dst,
14607 sizeof (mp->entry.tunnel_dst));
14616 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
14618 unformat_input_t *i = vam->input;
14619 vl_api_ipsec_tunnel_if_add_del_t *mp;
14620 u32 local_spi = 0, remote_spi = 0;
14621 u32 crypto_alg = 0, integ_alg = 0;
14622 u8 *lck = NULL, *rck = NULL;
14623 u8 *lik = NULL, *rik = NULL;
14624 vl_api_address_t local_ip = { 0 };
14625 vl_api_address_t remote_ip = { 0 };
14629 u8 anti_replay = 0;
14635 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14637 if (unformat (i, "del"))
14639 else if (unformat (i, "esn"))
14641 else if (unformat (i, "anti-replay"))
14643 else if (unformat (i, "count %d", &count))
14645 else if (unformat (i, "local_spi %d", &local_spi))
14647 else if (unformat (i, "remote_spi %d", &remote_spi))
14650 if (unformat (i, "local_ip %U", unformat_vl_api_address, &local_ip))
14653 if (unformat (i, "remote_ip %U", unformat_vl_api_address, &remote_ip))
14655 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
14658 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
14660 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
14662 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
14666 (i, "crypto_alg %U", unformat_ipsec_api_crypto_alg, &crypto_alg))
14668 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
14670 errmsg ("unsupported crypto-alg: '%U'\n",
14671 format_ipsec_crypto_alg, crypto_alg);
14677 (i, "integ_alg %U", unformat_ipsec_api_integ_alg, &integ_alg))
14679 if (integ_alg >= IPSEC_INTEG_N_ALG)
14681 errmsg ("unsupported integ-alg: '%U'\n",
14682 format_ipsec_integ_alg, integ_alg);
14686 else if (unformat (i, "instance %u", &instance))
14690 errmsg ("parse error '%U'\n", format_unformat_error, i);
14697 /* Turn on async mode */
14698 vam->async_mode = 1;
14699 vam->async_errors = 0;
14700 before = vat_time_now (vam);
14703 for (jj = 0; jj < count; jj++)
14705 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
14707 mp->is_add = is_add;
14709 mp->anti_replay = anti_replay;
14712 increment_address (&remote_ip);
14714 clib_memcpy (&mp->local_ip, &local_ip, sizeof (local_ip));
14715 clib_memcpy (&mp->remote_ip, &remote_ip, sizeof (remote_ip));
14717 mp->local_spi = htonl (local_spi + jj);
14718 mp->remote_spi = htonl (remote_spi + jj);
14719 mp->crypto_alg = (u8) crypto_alg;
14721 mp->local_crypto_key_len = 0;
14724 mp->local_crypto_key_len = vec_len (lck);
14725 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
14726 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
14727 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
14730 mp->remote_crypto_key_len = 0;
14733 mp->remote_crypto_key_len = vec_len (rck);
14734 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
14735 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
14736 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
14739 mp->integ_alg = (u8) integ_alg;
14741 mp->local_integ_key_len = 0;
14744 mp->local_integ_key_len = vec_len (lik);
14745 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
14746 mp->local_integ_key_len = sizeof (mp->local_integ_key);
14747 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
14750 mp->remote_integ_key_len = 0;
14753 mp->remote_integ_key_len = vec_len (rik);
14754 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
14755 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
14756 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
14761 mp->renumber = renumber;
14762 mp->show_instance = ntohl (instance);
14767 /* When testing multiple add/del ops, use a control-ping to sync */
14770 vl_api_control_ping_t *mp_ping;
14774 /* Shut off async mode */
14775 vam->async_mode = 0;
14777 MPING (CONTROL_PING, mp_ping);
14780 timeout = vat_time_now (vam) + 1.0;
14781 while (vat_time_now (vam) < timeout)
14782 if (vam->result_ready == 1)
14787 if (vam->retval == -99)
14788 errmsg ("timeout");
14790 if (vam->async_errors > 0)
14792 errmsg ("%d asynchronous errors", vam->async_errors);
14795 vam->async_errors = 0;
14796 after = vat_time_now (vam);
14798 /* slim chance, but we might have eaten SIGTERM on the first iteration */
14802 print (vam->ofp, "%d tunnels in %.6f secs, %.2f tunnels/sec",
14803 count, after - before, count / (after - before));
14807 /* Wait for a reply... */
14816 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
14818 vat_main_t *vam = &vat_main;
14820 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
14821 "crypto_key %U integ_alg %u integ_key %U flags %x "
14822 "tunnel_src_addr %U tunnel_dst_addr %U "
14823 "salt %u seq_outbound %lu last_seq_inbound %lu "
14824 "replay_window %lu\n",
14825 ntohl (mp->entry.sad_id),
14826 ntohl (mp->sw_if_index),
14827 ntohl (mp->entry.spi),
14828 ntohl (mp->entry.protocol),
14829 ntohl (mp->entry.crypto_algorithm),
14830 format_hex_bytes, mp->entry.crypto_key.data,
14831 mp->entry.crypto_key.length, ntohl (mp->entry.integrity_algorithm),
14832 format_hex_bytes, mp->entry.integrity_key.data,
14833 mp->entry.integrity_key.length, ntohl (mp->entry.flags),
14834 format_vl_api_address, &mp->entry.tunnel_src, format_vl_api_address,
14835 &mp->entry.tunnel_dst, ntohl (mp->salt),
14836 clib_net_to_host_u64 (mp->seq_outbound),
14837 clib_net_to_host_u64 (mp->last_seq_inbound),
14838 clib_net_to_host_u64 (mp->replay_window));
14841 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
14842 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
14844 static void vl_api_ipsec_sa_details_t_handler_json
14845 (vl_api_ipsec_sa_details_t * mp)
14847 vat_main_t *vam = &vat_main;
14848 vat_json_node_t *node = NULL;
14849 vl_api_ipsec_sad_flags_t flags;
14851 if (VAT_JSON_ARRAY != vam->json_tree.type)
14853 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14854 vat_json_init_array (&vam->json_tree);
14856 node = vat_json_array_add (&vam->json_tree);
14858 vat_json_init_object (node);
14859 vat_json_object_add_uint (node, "sa_id", ntohl (mp->entry.sad_id));
14860 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14861 vat_json_object_add_uint (node, "spi", ntohl (mp->entry.spi));
14862 vat_json_object_add_uint (node, "proto", ntohl (mp->entry.protocol));
14863 vat_json_object_add_uint (node, "crypto_alg",
14864 ntohl (mp->entry.crypto_algorithm));
14865 vat_json_object_add_uint (node, "integ_alg",
14866 ntohl (mp->entry.integrity_algorithm));
14867 flags = ntohl (mp->entry.flags);
14868 vat_json_object_add_uint (node, "use_esn",
14869 ! !(flags & IPSEC_API_SAD_FLAG_USE_ESN));
14870 vat_json_object_add_uint (node, "use_anti_replay",
14871 ! !(flags & IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY));
14872 vat_json_object_add_uint (node, "is_tunnel",
14873 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL));
14874 vat_json_object_add_uint (node, "is_tunnel_ip6",
14875 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL_V6));
14876 vat_json_object_add_uint (node, "udp_encap",
14877 ! !(flags & IPSEC_API_SAD_FLAG_UDP_ENCAP));
14878 vat_json_object_add_bytes (node, "crypto_key", mp->entry.crypto_key.data,
14879 mp->entry.crypto_key.length);
14880 vat_json_object_add_bytes (node, "integ_key", mp->entry.integrity_key.data,
14881 mp->entry.integrity_key.length);
14882 vat_json_object_add_address (node, "src", &mp->entry.tunnel_src);
14883 vat_json_object_add_address (node, "dst", &mp->entry.tunnel_dst);
14884 vat_json_object_add_uint (node, "replay_window",
14885 clib_net_to_host_u64 (mp->replay_window));
14889 api_ipsec_sa_dump (vat_main_t * vam)
14891 unformat_input_t *i = vam->input;
14892 vl_api_ipsec_sa_dump_t *mp;
14893 vl_api_control_ping_t *mp_ping;
14897 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14899 if (unformat (i, "sa_id %d", &sa_id))
14903 clib_warning ("parse error '%U'", format_unformat_error, i);
14908 M (IPSEC_SA_DUMP, mp);
14910 mp->sa_id = ntohl (sa_id);
14914 /* Use a control ping for synchronization */
14915 M (CONTROL_PING, mp_ping);
14923 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
14925 unformat_input_t *i = vam->input;
14926 vl_api_ipsec_tunnel_if_set_sa_t *mp;
14927 u32 sw_if_index = ~0;
14929 u8 is_outbound = (u8) ~ 0;
14932 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14934 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14936 else if (unformat (i, "sa_id %d", &sa_id))
14938 else if (unformat (i, "outbound"))
14940 else if (unformat (i, "inbound"))
14944 clib_warning ("parse error '%U'", format_unformat_error, i);
14949 if (sw_if_index == ~0)
14951 errmsg ("interface must be specified");
14957 errmsg ("SA ID must be specified");
14961 M (IPSEC_TUNNEL_IF_SET_SA, mp);
14963 mp->sw_if_index = htonl (sw_if_index);
14964 mp->sa_id = htonl (sa_id);
14965 mp->is_outbound = is_outbound;
14974 api_get_first_msg_id (vat_main_t * vam)
14976 vl_api_get_first_msg_id_t *mp;
14977 unformat_input_t *i = vam->input;
14982 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14984 if (unformat (i, "client %s", &name))
14992 errmsg ("missing client name");
14995 vec_add1 (name, 0);
14997 if (vec_len (name) > 63)
14999 errmsg ("client name too long");
15003 M (GET_FIRST_MSG_ID, mp);
15004 clib_memcpy (mp->name, name, vec_len (name));
15011 api_cop_interface_enable_disable (vat_main_t * vam)
15013 unformat_input_t *line_input = vam->input;
15014 vl_api_cop_interface_enable_disable_t *mp;
15015 u32 sw_if_index = ~0;
15016 u8 enable_disable = 1;
15019 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15021 if (unformat (line_input, "disable"))
15022 enable_disable = 0;
15023 if (unformat (line_input, "enable"))
15024 enable_disable = 1;
15025 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15026 vam, &sw_if_index))
15028 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15034 if (sw_if_index == ~0)
15036 errmsg ("missing interface name or sw_if_index");
15040 /* Construct the API message */
15041 M (COP_INTERFACE_ENABLE_DISABLE, mp);
15042 mp->sw_if_index = ntohl (sw_if_index);
15043 mp->enable_disable = enable_disable;
15047 /* Wait for the reply */
15053 api_cop_whitelist_enable_disable (vat_main_t * vam)
15055 unformat_input_t *line_input = vam->input;
15056 vl_api_cop_whitelist_enable_disable_t *mp;
15057 u32 sw_if_index = ~0;
15058 u8 ip4 = 0, ip6 = 0, default_cop = 0;
15062 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15064 if (unformat (line_input, "ip4"))
15066 else if (unformat (line_input, "ip6"))
15068 else if (unformat (line_input, "default"))
15070 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15071 vam, &sw_if_index))
15073 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15075 else if (unformat (line_input, "fib-id %d", &fib_id))
15081 if (sw_if_index == ~0)
15083 errmsg ("missing interface name or sw_if_index");
15087 /* Construct the API message */
15088 M (COP_WHITELIST_ENABLE_DISABLE, mp);
15089 mp->sw_if_index = ntohl (sw_if_index);
15090 mp->fib_id = ntohl (fib_id);
15093 mp->default_cop = default_cop;
15097 /* Wait for the reply */
15103 api_get_node_graph (vat_main_t * vam)
15105 vl_api_get_node_graph_t *mp;
15108 M (GET_NODE_GRAPH, mp);
15112 /* Wait for the reply */
15118 /** Used for parsing LISP eids */
15119 typedef CLIB_PACKED(struct{
15120 u8 addr[16]; /**< eid address */
15121 u32 len; /**< prefix length if IP */
15122 u8 type; /**< type of eid */
15127 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
15129 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
15131 clib_memset (a, 0, sizeof (a[0]));
15133 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
15135 a->type = 0; /* ipv4 type */
15137 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
15139 a->type = 1; /* ipv6 type */
15141 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
15143 a->type = 2; /* mac type */
15145 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
15147 a->type = 3; /* NSH type */
15148 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
15149 nsh->spi = clib_host_to_net_u32 (nsh->spi);
15156 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
15165 lisp_eid_size_vat (u8 type)
15182 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
15184 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
15188 api_one_add_del_locator_set (vat_main_t * vam)
15190 unformat_input_t *input = vam->input;
15191 vl_api_one_add_del_locator_set_t *mp;
15193 u8 *locator_set_name = NULL;
15194 u8 locator_set_name_set = 0;
15195 vl_api_local_locator_t locator, *locators = 0;
15196 u32 sw_if_index, priority, weight;
15200 /* Parse args required to build the message */
15201 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15203 if (unformat (input, "del"))
15207 else if (unformat (input, "locator-set %s", &locator_set_name))
15209 locator_set_name_set = 1;
15211 else if (unformat (input, "sw_if_index %u p %u w %u",
15212 &sw_if_index, &priority, &weight))
15214 locator.sw_if_index = htonl (sw_if_index);
15215 locator.priority = priority;
15216 locator.weight = weight;
15217 vec_add1 (locators, locator);
15221 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
15222 &sw_if_index, &priority, &weight))
15224 locator.sw_if_index = htonl (sw_if_index);
15225 locator.priority = priority;
15226 locator.weight = weight;
15227 vec_add1 (locators, locator);
15233 if (locator_set_name_set == 0)
15235 errmsg ("missing locator-set name");
15236 vec_free (locators);
15240 if (vec_len (locator_set_name) > 64)
15242 errmsg ("locator-set name too long");
15243 vec_free (locator_set_name);
15244 vec_free (locators);
15247 vec_add1 (locator_set_name, 0);
15249 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
15251 /* Construct the API message */
15252 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
15254 mp->is_add = is_add;
15255 clib_memcpy (mp->locator_set_name, locator_set_name,
15256 vec_len (locator_set_name));
15257 vec_free (locator_set_name);
15259 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
15261 clib_memcpy (mp->locators, locators, data_len);
15262 vec_free (locators);
15267 /* Wait for a reply... */
15272 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
15275 api_one_add_del_locator (vat_main_t * vam)
15277 unformat_input_t *input = vam->input;
15278 vl_api_one_add_del_locator_t *mp;
15279 u32 tmp_if_index = ~0;
15280 u32 sw_if_index = ~0;
15281 u8 sw_if_index_set = 0;
15282 u8 sw_if_index_if_name_set = 0;
15284 u8 priority_set = 0;
15288 u8 *locator_set_name = NULL;
15289 u8 locator_set_name_set = 0;
15292 /* Parse args required to build the message */
15293 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15295 if (unformat (input, "del"))
15299 else if (unformat (input, "locator-set %s", &locator_set_name))
15301 locator_set_name_set = 1;
15303 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
15306 sw_if_index_if_name_set = 1;
15307 sw_if_index = tmp_if_index;
15309 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
15311 sw_if_index_set = 1;
15312 sw_if_index = tmp_if_index;
15314 else if (unformat (input, "p %d", &priority))
15318 else if (unformat (input, "w %d", &weight))
15326 if (locator_set_name_set == 0)
15328 errmsg ("missing locator-set name");
15332 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
15334 errmsg ("missing sw_if_index");
15335 vec_free (locator_set_name);
15339 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
15341 errmsg ("cannot use both params interface name and sw_if_index");
15342 vec_free (locator_set_name);
15346 if (priority_set == 0)
15348 errmsg ("missing locator-set priority");
15349 vec_free (locator_set_name);
15353 if (weight_set == 0)
15355 errmsg ("missing locator-set weight");
15356 vec_free (locator_set_name);
15360 if (vec_len (locator_set_name) > 64)
15362 errmsg ("locator-set name too long");
15363 vec_free (locator_set_name);
15366 vec_add1 (locator_set_name, 0);
15368 /* Construct the API message */
15369 M (ONE_ADD_DEL_LOCATOR, mp);
15371 mp->is_add = is_add;
15372 mp->sw_if_index = ntohl (sw_if_index);
15373 mp->priority = priority;
15374 mp->weight = weight;
15375 clib_memcpy (mp->locator_set_name, locator_set_name,
15376 vec_len (locator_set_name));
15377 vec_free (locator_set_name);
15382 /* Wait for a reply... */
15387 #define api_lisp_add_del_locator api_one_add_del_locator
15390 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
15392 u32 *key_id = va_arg (*args, u32 *);
15395 if (unformat (input, "%s", &s))
15397 if (!strcmp ((char *) s, "sha1"))
15398 key_id[0] = HMAC_SHA_1_96;
15399 else if (!strcmp ((char *) s, "sha256"))
15400 key_id[0] = HMAC_SHA_256_128;
15403 clib_warning ("invalid key_id: '%s'", s);
15404 key_id[0] = HMAC_NO_KEY;
15415 api_one_add_del_local_eid (vat_main_t * vam)
15417 unformat_input_t *input = vam->input;
15418 vl_api_one_add_del_local_eid_t *mp;
15421 lisp_eid_vat_t _eid, *eid = &_eid;
15422 u8 *locator_set_name = 0;
15423 u8 locator_set_name_set = 0;
15429 /* Parse args required to build the message */
15430 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15432 if (unformat (input, "del"))
15436 else if (unformat (input, "vni %d", &vni))
15440 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15444 else if (unformat (input, "locator-set %s", &locator_set_name))
15446 locator_set_name_set = 1;
15448 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
15450 else if (unformat (input, "secret-key %_%v%_", &key))
15456 if (locator_set_name_set == 0)
15458 errmsg ("missing locator-set name");
15464 errmsg ("EID address not set!");
15465 vec_free (locator_set_name);
15469 if (key && (0 == key_id))
15471 errmsg ("invalid key_id!");
15475 if (vec_len (key) > 64)
15477 errmsg ("key too long");
15482 if (vec_len (locator_set_name) > 64)
15484 errmsg ("locator-set name too long");
15485 vec_free (locator_set_name);
15488 vec_add1 (locator_set_name, 0);
15490 /* Construct the API message */
15491 M (ONE_ADD_DEL_LOCAL_EID, mp);
15493 mp->is_add = is_add;
15494 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15495 mp->eid_type = eid->type;
15496 mp->prefix_len = eid->len;
15497 mp->vni = clib_host_to_net_u32 (vni);
15498 mp->key_id = clib_host_to_net_u16 (key_id);
15499 clib_memcpy (mp->locator_set_name, locator_set_name,
15500 vec_len (locator_set_name));
15501 clib_memcpy (mp->key, key, vec_len (key));
15503 vec_free (locator_set_name);
15509 /* Wait for a reply... */
15514 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
15517 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
15519 u32 dp_table = 0, vni = 0;;
15520 unformat_input_t *input = vam->input;
15521 vl_api_gpe_add_del_fwd_entry_t *mp;
15523 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
15524 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
15525 u8 rmt_eid_set = 0, lcl_eid_set = 0;
15526 u32 action = ~0, w;
15527 ip4_address_t rmt_rloc4, lcl_rloc4;
15528 ip6_address_t rmt_rloc6, lcl_rloc6;
15529 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
15532 clib_memset (&rloc, 0, sizeof (rloc));
15534 /* Parse args required to build the message */
15535 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15537 if (unformat (input, "del"))
15539 else if (unformat (input, "add"))
15541 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
15545 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
15549 else if (unformat (input, "vrf %d", &dp_table))
15551 else if (unformat (input, "bd %d", &dp_table))
15553 else if (unformat (input, "vni %d", &vni))
15555 else if (unformat (input, "w %d", &w))
15559 errmsg ("No RLOC configured for setting priority/weight!");
15562 curr_rloc->weight = w;
15564 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
15565 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
15569 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
15571 vec_add1 (lcl_locs, rloc);
15573 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
15574 vec_add1 (rmt_locs, rloc);
15575 /* weight saved in rmt loc */
15576 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15578 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
15579 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
15582 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
15584 vec_add1 (lcl_locs, rloc);
15586 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
15587 vec_add1 (rmt_locs, rloc);
15588 /* weight saved in rmt loc */
15589 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15591 else if (unformat (input, "action %d", &action))
15597 clib_warning ("parse error '%U'", format_unformat_error, input);
15604 errmsg ("remote eid addresses not set");
15608 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
15610 errmsg ("eid types don't match");
15614 if (0 == rmt_locs && (u32) ~ 0 == action)
15616 errmsg ("action not set for negative mapping");
15620 /* Construct the API message */
15621 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
15622 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
15624 mp->is_add = is_add;
15625 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
15626 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
15627 mp->eid_type = rmt_eid->type;
15628 mp->dp_table = clib_host_to_net_u32 (dp_table);
15629 mp->vni = clib_host_to_net_u32 (vni);
15630 mp->rmt_len = rmt_eid->len;
15631 mp->lcl_len = lcl_eid->len;
15632 mp->action = action;
15634 if (0 != rmt_locs && 0 != lcl_locs)
15636 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
15637 clib_memcpy (mp->locs, lcl_locs,
15638 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
15640 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
15641 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
15642 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
15644 vec_free (lcl_locs);
15645 vec_free (rmt_locs);
15650 /* Wait for a reply... */
15656 api_one_add_del_map_server (vat_main_t * vam)
15658 unformat_input_t *input = vam->input;
15659 vl_api_one_add_del_map_server_t *mp;
15663 ip4_address_t ipv4;
15664 ip6_address_t ipv6;
15667 /* Parse args required to build the message */
15668 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15670 if (unformat (input, "del"))
15674 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15678 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15686 if (ipv4_set && ipv6_set)
15688 errmsg ("both eid v4 and v6 addresses set");
15692 if (!ipv4_set && !ipv6_set)
15694 errmsg ("eid addresses not set");
15698 /* Construct the API message */
15699 M (ONE_ADD_DEL_MAP_SERVER, mp);
15701 mp->is_add = is_add;
15705 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
15710 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
15716 /* Wait for a reply... */
15721 #define api_lisp_add_del_map_server api_one_add_del_map_server
15724 api_one_add_del_map_resolver (vat_main_t * vam)
15726 unformat_input_t *input = vam->input;
15727 vl_api_one_add_del_map_resolver_t *mp;
15731 ip4_address_t ipv4;
15732 ip6_address_t ipv6;
15735 /* Parse args required to build the message */
15736 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15738 if (unformat (input, "del"))
15742 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15746 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15754 if (ipv4_set && ipv6_set)
15756 errmsg ("both eid v4 and v6 addresses set");
15760 if (!ipv4_set && !ipv6_set)
15762 errmsg ("eid addresses not set");
15766 /* Construct the API message */
15767 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
15769 mp->is_add = is_add;
15773 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
15778 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
15784 /* Wait for a reply... */
15789 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
15792 api_lisp_gpe_enable_disable (vat_main_t * vam)
15794 unformat_input_t *input = vam->input;
15795 vl_api_gpe_enable_disable_t *mp;
15800 /* Parse args required to build the message */
15801 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15803 if (unformat (input, "enable"))
15808 else if (unformat (input, "disable"))
15819 errmsg ("Value not set");
15823 /* Construct the API message */
15824 M (GPE_ENABLE_DISABLE, mp);
15831 /* Wait for a reply... */
15837 api_one_rloc_probe_enable_disable (vat_main_t * vam)
15839 unformat_input_t *input = vam->input;
15840 vl_api_one_rloc_probe_enable_disable_t *mp;
15845 /* Parse args required to build the message */
15846 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15848 if (unformat (input, "enable"))
15853 else if (unformat (input, "disable"))
15861 errmsg ("Value not set");
15865 /* Construct the API message */
15866 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
15868 mp->is_enabled = is_en;
15873 /* Wait for a reply... */
15878 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
15881 api_one_map_register_enable_disable (vat_main_t * vam)
15883 unformat_input_t *input = vam->input;
15884 vl_api_one_map_register_enable_disable_t *mp;
15889 /* Parse args required to build the message */
15890 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15892 if (unformat (input, "enable"))
15897 else if (unformat (input, "disable"))
15905 errmsg ("Value not set");
15909 /* Construct the API message */
15910 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
15912 mp->is_enabled = is_en;
15917 /* Wait for a reply... */
15922 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
15925 api_one_enable_disable (vat_main_t * vam)
15927 unformat_input_t *input = vam->input;
15928 vl_api_one_enable_disable_t *mp;
15933 /* Parse args required to build the message */
15934 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15936 if (unformat (input, "enable"))
15941 else if (unformat (input, "disable"))
15951 errmsg ("Value not set");
15955 /* Construct the API message */
15956 M (ONE_ENABLE_DISABLE, mp);
15963 /* Wait for a reply... */
15968 #define api_lisp_enable_disable api_one_enable_disable
15971 api_one_enable_disable_xtr_mode (vat_main_t * vam)
15973 unformat_input_t *input = vam->input;
15974 vl_api_one_enable_disable_xtr_mode_t *mp;
15979 /* Parse args required to build the message */
15980 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15982 if (unformat (input, "enable"))
15987 else if (unformat (input, "disable"))
15997 errmsg ("Value not set");
16001 /* Construct the API message */
16002 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
16009 /* Wait for a reply... */
16015 api_one_show_xtr_mode (vat_main_t * vam)
16017 vl_api_one_show_xtr_mode_t *mp;
16020 /* Construct the API message */
16021 M (ONE_SHOW_XTR_MODE, mp);
16026 /* Wait for a reply... */
16032 api_one_enable_disable_pitr_mode (vat_main_t * vam)
16034 unformat_input_t *input = vam->input;
16035 vl_api_one_enable_disable_pitr_mode_t *mp;
16040 /* Parse args required to build the message */
16041 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16043 if (unformat (input, "enable"))
16048 else if (unformat (input, "disable"))
16058 errmsg ("Value not set");
16062 /* Construct the API message */
16063 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
16070 /* Wait for a reply... */
16076 api_one_show_pitr_mode (vat_main_t * vam)
16078 vl_api_one_show_pitr_mode_t *mp;
16081 /* Construct the API message */
16082 M (ONE_SHOW_PITR_MODE, mp);
16087 /* Wait for a reply... */
16093 api_one_enable_disable_petr_mode (vat_main_t * vam)
16095 unformat_input_t *input = vam->input;
16096 vl_api_one_enable_disable_petr_mode_t *mp;
16101 /* Parse args required to build the message */
16102 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16104 if (unformat (input, "enable"))
16109 else if (unformat (input, "disable"))
16119 errmsg ("Value not set");
16123 /* Construct the API message */
16124 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
16131 /* Wait for a reply... */
16137 api_one_show_petr_mode (vat_main_t * vam)
16139 vl_api_one_show_petr_mode_t *mp;
16142 /* Construct the API message */
16143 M (ONE_SHOW_PETR_MODE, mp);
16148 /* Wait for a reply... */
16154 api_show_one_map_register_state (vat_main_t * vam)
16156 vl_api_show_one_map_register_state_t *mp;
16159 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
16164 /* wait for reply */
16169 #define api_show_lisp_map_register_state api_show_one_map_register_state
16172 api_show_one_rloc_probe_state (vat_main_t * vam)
16174 vl_api_show_one_rloc_probe_state_t *mp;
16177 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
16182 /* wait for reply */
16187 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
16190 api_one_add_del_ndp_entry (vat_main_t * vam)
16192 vl_api_one_add_del_ndp_entry_t *mp;
16193 unformat_input_t *input = vam->input;
16198 u8 mac[6] = { 0, };
16199 u8 ip6[16] = { 0, };
16203 /* Parse args required to build the message */
16204 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16206 if (unformat (input, "del"))
16208 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16210 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
16212 else if (unformat (input, "bd %d", &bd))
16216 errmsg ("parse error '%U'", format_unformat_error, input);
16221 if (!bd_set || !ip_set || (!mac_set && is_add))
16223 errmsg ("Missing BD, IP or MAC!");
16227 M (ONE_ADD_DEL_NDP_ENTRY, mp);
16228 mp->is_add = is_add;
16229 clib_memcpy (mp->mac, mac, 6);
16230 mp->bd = clib_host_to_net_u32 (bd);
16231 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
16236 /* wait for reply */
16242 api_one_add_del_l2_arp_entry (vat_main_t * vam)
16244 vl_api_one_add_del_l2_arp_entry_t *mp;
16245 unformat_input_t *input = vam->input;
16250 u8 mac[6] = { 0, };
16251 u32 ip4 = 0, bd = ~0;
16254 /* Parse args required to build the message */
16255 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16257 if (unformat (input, "del"))
16259 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16261 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
16263 else if (unformat (input, "bd %d", &bd))
16267 errmsg ("parse error '%U'", format_unformat_error, input);
16272 if (!bd_set || !ip_set || (!mac_set && is_add))
16274 errmsg ("Missing BD, IP or MAC!");
16278 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
16279 mp->is_add = is_add;
16280 clib_memcpy (mp->mac, mac, 6);
16281 mp->bd = clib_host_to_net_u32 (bd);
16287 /* wait for reply */
16293 api_one_ndp_bd_get (vat_main_t * vam)
16295 vl_api_one_ndp_bd_get_t *mp;
16298 M (ONE_NDP_BD_GET, mp);
16303 /* wait for reply */
16309 api_one_ndp_entries_get (vat_main_t * vam)
16311 vl_api_one_ndp_entries_get_t *mp;
16312 unformat_input_t *input = vam->input;
16317 /* Parse args required to build the message */
16318 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16320 if (unformat (input, "bd %d", &bd))
16324 errmsg ("parse error '%U'", format_unformat_error, input);
16331 errmsg ("Expected bridge domain!");
16335 M (ONE_NDP_ENTRIES_GET, mp);
16336 mp->bd = clib_host_to_net_u32 (bd);
16341 /* wait for reply */
16347 api_one_l2_arp_bd_get (vat_main_t * vam)
16349 vl_api_one_l2_arp_bd_get_t *mp;
16352 M (ONE_L2_ARP_BD_GET, mp);
16357 /* wait for reply */
16363 api_one_l2_arp_entries_get (vat_main_t * vam)
16365 vl_api_one_l2_arp_entries_get_t *mp;
16366 unformat_input_t *input = vam->input;
16371 /* Parse args required to build the message */
16372 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16374 if (unformat (input, "bd %d", &bd))
16378 errmsg ("parse error '%U'", format_unformat_error, input);
16385 errmsg ("Expected bridge domain!");
16389 M (ONE_L2_ARP_ENTRIES_GET, mp);
16390 mp->bd = clib_host_to_net_u32 (bd);
16395 /* wait for reply */
16401 api_one_stats_enable_disable (vat_main_t * vam)
16403 vl_api_one_stats_enable_disable_t *mp;
16404 unformat_input_t *input = vam->input;
16409 /* Parse args required to build the message */
16410 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16412 if (unformat (input, "enable"))
16417 else if (unformat (input, "disable"))
16427 errmsg ("Value not set");
16431 M (ONE_STATS_ENABLE_DISABLE, mp);
16437 /* wait for reply */
16443 api_show_one_stats_enable_disable (vat_main_t * vam)
16445 vl_api_show_one_stats_enable_disable_t *mp;
16448 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
16453 /* wait for reply */
16459 api_show_one_map_request_mode (vat_main_t * vam)
16461 vl_api_show_one_map_request_mode_t *mp;
16464 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
16469 /* wait for reply */
16474 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
16477 api_one_map_request_mode (vat_main_t * vam)
16479 unformat_input_t *input = vam->input;
16480 vl_api_one_map_request_mode_t *mp;
16484 /* Parse args required to build the message */
16485 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16487 if (unformat (input, "dst-only"))
16489 else if (unformat (input, "src-dst"))
16493 errmsg ("parse error '%U'", format_unformat_error, input);
16498 M (ONE_MAP_REQUEST_MODE, mp);
16505 /* wait for reply */
16510 #define api_lisp_map_request_mode api_one_map_request_mode
16513 * Enable/disable ONE proxy ITR.
16515 * @param vam vpp API test context
16516 * @return return code
16519 api_one_pitr_set_locator_set (vat_main_t * vam)
16521 u8 ls_name_set = 0;
16522 unformat_input_t *input = vam->input;
16523 vl_api_one_pitr_set_locator_set_t *mp;
16528 /* Parse args required to build the message */
16529 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16531 if (unformat (input, "del"))
16533 else if (unformat (input, "locator-set %s", &ls_name))
16537 errmsg ("parse error '%U'", format_unformat_error, input);
16544 errmsg ("locator-set name not set!");
16548 M (ONE_PITR_SET_LOCATOR_SET, mp);
16550 mp->is_add = is_add;
16551 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16552 vec_free (ls_name);
16557 /* wait for reply */
16562 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
16565 api_one_nsh_set_locator_set (vat_main_t * vam)
16567 u8 ls_name_set = 0;
16568 unformat_input_t *input = vam->input;
16569 vl_api_one_nsh_set_locator_set_t *mp;
16574 /* Parse args required to build the message */
16575 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16577 if (unformat (input, "del"))
16579 else if (unformat (input, "ls %s", &ls_name))
16583 errmsg ("parse error '%U'", format_unformat_error, input);
16588 if (!ls_name_set && is_add)
16590 errmsg ("locator-set name not set!");
16594 M (ONE_NSH_SET_LOCATOR_SET, mp);
16596 mp->is_add = is_add;
16597 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16598 vec_free (ls_name);
16603 /* wait for reply */
16609 api_show_one_pitr (vat_main_t * vam)
16611 vl_api_show_one_pitr_t *mp;
16614 if (!vam->json_output)
16616 print (vam->ofp, "%=20s", "lisp status:");
16619 M (SHOW_ONE_PITR, mp);
16623 /* Wait for a reply... */
16628 #define api_show_lisp_pitr api_show_one_pitr
16631 api_one_use_petr (vat_main_t * vam)
16633 unformat_input_t *input = vam->input;
16634 vl_api_one_use_petr_t *mp;
16639 clib_memset (&ip, 0, sizeof (ip));
16641 /* Parse args required to build the message */
16642 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16644 if (unformat (input, "disable"))
16647 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
16650 ip_addr_version (&ip) = IP4;
16653 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
16656 ip_addr_version (&ip) = IP6;
16660 errmsg ("parse error '%U'", format_unformat_error, input);
16665 M (ONE_USE_PETR, mp);
16667 mp->is_add = is_add;
16670 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
16672 clib_memcpy (mp->address, &ip, 4);
16674 clib_memcpy (mp->address, &ip, 16);
16680 /* wait for reply */
16685 #define api_lisp_use_petr api_one_use_petr
16688 api_show_one_nsh_mapping (vat_main_t * vam)
16690 vl_api_show_one_use_petr_t *mp;
16693 if (!vam->json_output)
16695 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
16698 M (SHOW_ONE_NSH_MAPPING, mp);
16702 /* Wait for a reply... */
16708 api_show_one_use_petr (vat_main_t * vam)
16710 vl_api_show_one_use_petr_t *mp;
16713 if (!vam->json_output)
16715 print (vam->ofp, "%=20s", "Proxy-ETR status:");
16718 M (SHOW_ONE_USE_PETR, mp);
16722 /* Wait for a reply... */
16727 #define api_show_lisp_use_petr api_show_one_use_petr
16730 * Add/delete mapping between vni and vrf
16733 api_one_eid_table_add_del_map (vat_main_t * vam)
16735 unformat_input_t *input = vam->input;
16736 vl_api_one_eid_table_add_del_map_t *mp;
16737 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
16738 u32 vni, vrf, bd_index;
16741 /* Parse args required to build the message */
16742 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16744 if (unformat (input, "del"))
16746 else if (unformat (input, "vrf %d", &vrf))
16748 else if (unformat (input, "bd_index %d", &bd_index))
16750 else if (unformat (input, "vni %d", &vni))
16756 if (!vni_set || (!vrf_set && !bd_index_set))
16758 errmsg ("missing arguments!");
16762 if (vrf_set && bd_index_set)
16764 errmsg ("error: both vrf and bd entered!");
16768 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
16770 mp->is_add = is_add;
16771 mp->vni = htonl (vni);
16772 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
16773 mp->is_l2 = bd_index_set;
16778 /* wait for reply */
16783 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
16786 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
16788 u32 *action = va_arg (*args, u32 *);
16791 if (unformat (input, "%s", &s))
16793 if (!strcmp ((char *) s, "no-action"))
16795 else if (!strcmp ((char *) s, "natively-forward"))
16797 else if (!strcmp ((char *) s, "send-map-request"))
16799 else if (!strcmp ((char *) s, "drop"))
16803 clib_warning ("invalid action: '%s'", s);
16815 * Add/del remote mapping to/from ONE control plane
16817 * @param vam vpp API test context
16818 * @return return code
16821 api_one_add_del_remote_mapping (vat_main_t * vam)
16823 unformat_input_t *input = vam->input;
16824 vl_api_one_add_del_remote_mapping_t *mp;
16826 lisp_eid_vat_t _eid, *eid = &_eid;
16827 lisp_eid_vat_t _seid, *seid = &_seid;
16828 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
16829 u32 action = ~0, p, w, data_len;
16830 ip4_address_t rloc4;
16831 ip6_address_t rloc6;
16832 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
16835 clib_memset (&rloc, 0, sizeof (rloc));
16837 /* Parse args required to build the message */
16838 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16840 if (unformat (input, "del-all"))
16844 else if (unformat (input, "del"))
16848 else if (unformat (input, "add"))
16852 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
16856 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
16860 else if (unformat (input, "vni %d", &vni))
16864 else if (unformat (input, "p %d w %d", &p, &w))
16868 errmsg ("No RLOC configured for setting priority/weight!");
16871 curr_rloc->priority = p;
16872 curr_rloc->weight = w;
16874 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
16877 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
16878 vec_add1 (rlocs, rloc);
16879 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16881 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
16884 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
16885 vec_add1 (rlocs, rloc);
16886 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16888 else if (unformat (input, "action %U",
16889 unformat_negative_mapping_action, &action))
16895 clib_warning ("parse error '%U'", format_unformat_error, input);
16902 errmsg ("missing params!");
16906 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
16908 errmsg ("no action set for negative map-reply!");
16912 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
16914 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
16915 mp->is_add = is_add;
16916 mp->vni = htonl (vni);
16917 mp->action = (u8) action;
16918 mp->is_src_dst = seid_set;
16919 mp->eid_len = eid->len;
16920 mp->seid_len = seid->len;
16921 mp->del_all = del_all;
16922 mp->eid_type = eid->type;
16923 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
16924 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
16926 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
16927 clib_memcpy (mp->rlocs, rlocs, data_len);
16933 /* Wait for a reply... */
16938 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
16941 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
16942 * forwarding entries in data-plane accordingly.
16944 * @param vam vpp API test context
16945 * @return return code
16948 api_one_add_del_adjacency (vat_main_t * vam)
16950 unformat_input_t *input = vam->input;
16951 vl_api_one_add_del_adjacency_t *mp;
16953 ip4_address_t leid4, reid4;
16954 ip6_address_t leid6, reid6;
16955 u8 reid_mac[6] = { 0 };
16956 u8 leid_mac[6] = { 0 };
16957 u8 reid_type, leid_type;
16958 u32 leid_len = 0, reid_len = 0, len;
16962 leid_type = reid_type = (u8) ~ 0;
16964 /* Parse args required to build the message */
16965 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16967 if (unformat (input, "del"))
16971 else if (unformat (input, "add"))
16975 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
16978 reid_type = 0; /* ipv4 */
16981 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
16984 reid_type = 1; /* ipv6 */
16987 else if (unformat (input, "reid %U", unformat_ethernet_address,
16990 reid_type = 2; /* mac */
16992 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
16995 leid_type = 0; /* ipv4 */
16998 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
17001 leid_type = 1; /* ipv6 */
17004 else if (unformat (input, "leid %U", unformat_ethernet_address,
17007 leid_type = 2; /* mac */
17009 else if (unformat (input, "vni %d", &vni))
17015 errmsg ("parse error '%U'", format_unformat_error, input);
17020 if ((u8) ~ 0 == reid_type)
17022 errmsg ("missing params!");
17026 if (leid_type != reid_type)
17028 errmsg ("remote and local EIDs are of different types!");
17032 M (ONE_ADD_DEL_ADJACENCY, mp);
17033 mp->is_add = is_add;
17034 mp->vni = htonl (vni);
17035 mp->leid_len = leid_len;
17036 mp->reid_len = reid_len;
17037 mp->eid_type = reid_type;
17039 switch (mp->eid_type)
17042 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
17043 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
17046 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
17047 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
17050 clib_memcpy (mp->leid, leid_mac, 6);
17051 clib_memcpy (mp->reid, reid_mac, 6);
17054 errmsg ("unknown EID type %d!", mp->eid_type);
17061 /* Wait for a reply... */
17066 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
17069 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
17071 u32 *mode = va_arg (*args, u32 *);
17073 if (unformat (input, "lisp"))
17075 else if (unformat (input, "vxlan"))
17084 api_gpe_get_encap_mode (vat_main_t * vam)
17086 vl_api_gpe_get_encap_mode_t *mp;
17089 /* Construct the API message */
17090 M (GPE_GET_ENCAP_MODE, mp);
17095 /* Wait for a reply... */
17101 api_gpe_set_encap_mode (vat_main_t * vam)
17103 unformat_input_t *input = vam->input;
17104 vl_api_gpe_set_encap_mode_t *mp;
17108 /* Parse args required to build the message */
17109 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17111 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
17117 /* Construct the API message */
17118 M (GPE_SET_ENCAP_MODE, mp);
17125 /* Wait for a reply... */
17131 api_lisp_gpe_add_del_iface (vat_main_t * vam)
17133 unformat_input_t *input = vam->input;
17134 vl_api_gpe_add_del_iface_t *mp;
17135 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
17136 u32 dp_table = 0, vni = 0;
17139 /* Parse args required to build the message */
17140 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17142 if (unformat (input, "up"))
17147 else if (unformat (input, "down"))
17152 else if (unformat (input, "table_id %d", &dp_table))
17156 else if (unformat (input, "bd_id %d", &dp_table))
17161 else if (unformat (input, "vni %d", &vni))
17169 if (action_set == 0)
17171 errmsg ("Action not set");
17174 if (dp_table_set == 0 || vni_set == 0)
17176 errmsg ("vni and dp_table must be set");
17180 /* Construct the API message */
17181 M (GPE_ADD_DEL_IFACE, mp);
17183 mp->is_add = is_add;
17184 mp->dp_table = clib_host_to_net_u32 (dp_table);
17186 mp->vni = clib_host_to_net_u32 (vni);
17191 /* Wait for a reply... */
17197 api_one_map_register_fallback_threshold (vat_main_t * vam)
17199 unformat_input_t *input = vam->input;
17200 vl_api_one_map_register_fallback_threshold_t *mp;
17205 /* Parse args required to build the message */
17206 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17208 if (unformat (input, "%u", &value))
17212 clib_warning ("parse error '%U'", format_unformat_error, input);
17219 errmsg ("fallback threshold value is missing!");
17223 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17224 mp->value = clib_host_to_net_u32 (value);
17229 /* Wait for a reply... */
17235 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
17237 vl_api_show_one_map_register_fallback_threshold_t *mp;
17240 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17245 /* Wait for a reply... */
17251 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
17253 u32 *proto = va_arg (*args, u32 *);
17255 if (unformat (input, "udp"))
17257 else if (unformat (input, "api"))
17266 api_one_set_transport_protocol (vat_main_t * vam)
17268 unformat_input_t *input = vam->input;
17269 vl_api_one_set_transport_protocol_t *mp;
17274 /* Parse args required to build the message */
17275 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17277 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
17281 clib_warning ("parse error '%U'", format_unformat_error, input);
17288 errmsg ("Transport protocol missing!");
17292 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
17293 mp->protocol = (u8) protocol;
17298 /* Wait for a reply... */
17304 api_one_get_transport_protocol (vat_main_t * vam)
17306 vl_api_one_get_transport_protocol_t *mp;
17309 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
17314 /* Wait for a reply... */
17320 api_one_map_register_set_ttl (vat_main_t * vam)
17322 unformat_input_t *input = vam->input;
17323 vl_api_one_map_register_set_ttl_t *mp;
17328 /* Parse args required to build the message */
17329 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17331 if (unformat (input, "%u", &ttl))
17335 clib_warning ("parse error '%U'", format_unformat_error, input);
17342 errmsg ("TTL value missing!");
17346 M (ONE_MAP_REGISTER_SET_TTL, mp);
17347 mp->ttl = clib_host_to_net_u32 (ttl);
17352 /* Wait for a reply... */
17358 api_show_one_map_register_ttl (vat_main_t * vam)
17360 vl_api_show_one_map_register_ttl_t *mp;
17363 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
17368 /* Wait for a reply... */
17374 * Add/del map request itr rlocs from ONE control plane and updates
17376 * @param vam vpp API test context
17377 * @return return code
17380 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
17382 unformat_input_t *input = vam->input;
17383 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
17384 u8 *locator_set_name = 0;
17385 u8 locator_set_name_set = 0;
17389 /* Parse args required to build the message */
17390 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17392 if (unformat (input, "del"))
17396 else if (unformat (input, "%_%v%_", &locator_set_name))
17398 locator_set_name_set = 1;
17402 clib_warning ("parse error '%U'", format_unformat_error, input);
17407 if (is_add && !locator_set_name_set)
17409 errmsg ("itr-rloc is not set!");
17413 if (is_add && vec_len (locator_set_name) > 64)
17415 errmsg ("itr-rloc locator-set name too long");
17416 vec_free (locator_set_name);
17420 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
17421 mp->is_add = is_add;
17424 clib_memcpy (mp->locator_set_name, locator_set_name,
17425 vec_len (locator_set_name));
17429 clib_memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
17431 vec_free (locator_set_name);
17436 /* Wait for a reply... */
17441 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
17444 api_one_locator_dump (vat_main_t * vam)
17446 unformat_input_t *input = vam->input;
17447 vl_api_one_locator_dump_t *mp;
17448 vl_api_control_ping_t *mp_ping;
17449 u8 is_index_set = 0, is_name_set = 0;
17454 /* Parse args required to build the message */
17455 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17457 if (unformat (input, "ls_name %_%v%_", &ls_name))
17461 else if (unformat (input, "ls_index %d", &ls_index))
17467 errmsg ("parse error '%U'", format_unformat_error, input);
17472 if (!is_index_set && !is_name_set)
17474 errmsg ("error: expected one of index or name!");
17478 if (is_index_set && is_name_set)
17480 errmsg ("error: only one param expected!");
17484 if (vec_len (ls_name) > 62)
17486 errmsg ("error: locator set name too long!");
17490 if (!vam->json_output)
17492 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
17495 M (ONE_LOCATOR_DUMP, mp);
17496 mp->is_index_set = is_index_set;
17499 mp->ls_index = clib_host_to_net_u32 (ls_index);
17502 vec_add1 (ls_name, 0);
17503 strncpy ((char *) mp->ls_name, (char *) ls_name,
17504 sizeof (mp->ls_name) - 1);
17510 /* Use a control ping for synchronization */
17511 MPING (CONTROL_PING, mp_ping);
17514 /* Wait for a reply... */
17519 #define api_lisp_locator_dump api_one_locator_dump
17522 api_one_locator_set_dump (vat_main_t * vam)
17524 vl_api_one_locator_set_dump_t *mp;
17525 vl_api_control_ping_t *mp_ping;
17526 unformat_input_t *input = vam->input;
17530 /* Parse args required to build the message */
17531 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17533 if (unformat (input, "local"))
17537 else if (unformat (input, "remote"))
17543 errmsg ("parse error '%U'", format_unformat_error, input);
17548 if (!vam->json_output)
17550 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
17553 M (ONE_LOCATOR_SET_DUMP, mp);
17555 mp->filter = filter;
17560 /* Use a control ping for synchronization */
17561 MPING (CONTROL_PING, mp_ping);
17564 /* Wait for a reply... */
17569 #define api_lisp_locator_set_dump api_one_locator_set_dump
17572 api_one_eid_table_map_dump (vat_main_t * vam)
17576 unformat_input_t *input = vam->input;
17577 vl_api_one_eid_table_map_dump_t *mp;
17578 vl_api_control_ping_t *mp_ping;
17581 /* Parse args required to build the message */
17582 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17584 if (unformat (input, "l2"))
17589 else if (unformat (input, "l3"))
17596 errmsg ("parse error '%U'", format_unformat_error, input);
17603 errmsg ("expected one of 'l2' or 'l3' parameter!");
17607 if (!vam->json_output)
17609 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
17612 M (ONE_EID_TABLE_MAP_DUMP, mp);
17618 /* Use a control ping for synchronization */
17619 MPING (CONTROL_PING, mp_ping);
17622 /* Wait for a reply... */
17627 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
17630 api_one_eid_table_vni_dump (vat_main_t * vam)
17632 vl_api_one_eid_table_vni_dump_t *mp;
17633 vl_api_control_ping_t *mp_ping;
17636 if (!vam->json_output)
17638 print (vam->ofp, "VNI");
17641 M (ONE_EID_TABLE_VNI_DUMP, mp);
17646 /* Use a control ping for synchronization */
17647 MPING (CONTROL_PING, mp_ping);
17650 /* Wait for a reply... */
17655 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
17658 api_one_eid_table_dump (vat_main_t * vam)
17660 unformat_input_t *i = vam->input;
17661 vl_api_one_eid_table_dump_t *mp;
17662 vl_api_control_ping_t *mp_ping;
17663 struct in_addr ip4;
17664 struct in6_addr ip6;
17666 u8 eid_type = ~0, eid_set = 0;
17667 u32 prefix_length = ~0, t, vni = 0;
17670 lisp_nsh_api_t nsh;
17672 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17674 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
17680 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
17686 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
17691 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
17696 else if (unformat (i, "vni %d", &t))
17700 else if (unformat (i, "local"))
17704 else if (unformat (i, "remote"))
17710 errmsg ("parse error '%U'", format_unformat_error, i);
17715 if (!vam->json_output)
17717 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
17718 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
17721 M (ONE_EID_TABLE_DUMP, mp);
17723 mp->filter = filter;
17727 mp->vni = htonl (vni);
17728 mp->eid_type = eid_type;
17732 mp->prefix_length = prefix_length;
17733 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
17736 mp->prefix_length = prefix_length;
17737 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
17740 clib_memcpy (mp->eid, mac, sizeof (mac));
17743 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
17746 errmsg ("unknown EID type %d!", eid_type);
17754 /* Use a control ping for synchronization */
17755 MPING (CONTROL_PING, mp_ping);
17758 /* Wait for a reply... */
17763 #define api_lisp_eid_table_dump api_one_eid_table_dump
17766 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
17768 unformat_input_t *i = vam->input;
17769 vl_api_gpe_fwd_entries_get_t *mp;
17774 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17776 if (unformat (i, "vni %d", &vni))
17782 errmsg ("parse error '%U'", format_unformat_error, i);
17789 errmsg ("vni not set!");
17793 if (!vam->json_output)
17795 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
17799 M (GPE_FWD_ENTRIES_GET, mp);
17800 mp->vni = clib_host_to_net_u32 (vni);
17805 /* Wait for a reply... */
17810 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
17811 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
17812 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
17813 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
17814 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
17815 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
17816 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
17817 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
17820 api_one_adjacencies_get (vat_main_t * vam)
17822 unformat_input_t *i = vam->input;
17823 vl_api_one_adjacencies_get_t *mp;
17828 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17830 if (unformat (i, "vni %d", &vni))
17836 errmsg ("parse error '%U'", format_unformat_error, i);
17843 errmsg ("vni not set!");
17847 if (!vam->json_output)
17849 print (vam->ofp, "%s %40s", "leid", "reid");
17852 M (ONE_ADJACENCIES_GET, mp);
17853 mp->vni = clib_host_to_net_u32 (vni);
17858 /* Wait for a reply... */
17863 #define api_lisp_adjacencies_get api_one_adjacencies_get
17866 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
17868 unformat_input_t *i = vam->input;
17869 vl_api_gpe_native_fwd_rpaths_get_t *mp;
17871 u8 ip_family_set = 0, is_ip4 = 1;
17873 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17875 if (unformat (i, "ip4"))
17880 else if (unformat (i, "ip6"))
17887 errmsg ("parse error '%U'", format_unformat_error, i);
17892 if (!ip_family_set)
17894 errmsg ("ip family not set!");
17898 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
17899 mp->is_ip4 = is_ip4;
17904 /* Wait for a reply... */
17910 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
17912 vl_api_gpe_fwd_entry_vnis_get_t *mp;
17915 if (!vam->json_output)
17917 print (vam->ofp, "VNIs");
17920 M (GPE_FWD_ENTRY_VNIS_GET, mp);
17925 /* Wait for a reply... */
17931 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
17933 unformat_input_t *i = vam->input;
17934 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
17936 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
17937 struct in_addr ip4;
17938 struct in6_addr ip6;
17939 u32 table_id = 0, nh_sw_if_index = ~0;
17941 clib_memset (&ip4, 0, sizeof (ip4));
17942 clib_memset (&ip6, 0, sizeof (ip6));
17944 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17946 if (unformat (i, "del"))
17948 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
17949 api_unformat_sw_if_index, vam, &nh_sw_if_index))
17954 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
17955 api_unformat_sw_if_index, vam, &nh_sw_if_index))
17960 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
17964 nh_sw_if_index = ~0;
17966 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
17970 nh_sw_if_index = ~0;
17972 else if (unformat (i, "table %d", &table_id))
17976 errmsg ("parse error '%U'", format_unformat_error, i);
17983 errmsg ("nh addr not set!");
17987 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
17988 mp->is_add = is_add;
17989 mp->table_id = clib_host_to_net_u32 (table_id);
17990 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
17991 mp->is_ip4 = is_ip4;
17993 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
17995 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
18000 /* Wait for a reply... */
18006 api_one_map_server_dump (vat_main_t * vam)
18008 vl_api_one_map_server_dump_t *mp;
18009 vl_api_control_ping_t *mp_ping;
18012 if (!vam->json_output)
18014 print (vam->ofp, "%=20s", "Map server");
18017 M (ONE_MAP_SERVER_DUMP, mp);
18021 /* Use a control ping for synchronization */
18022 MPING (CONTROL_PING, mp_ping);
18025 /* Wait for a reply... */
18030 #define api_lisp_map_server_dump api_one_map_server_dump
18033 api_one_map_resolver_dump (vat_main_t * vam)
18035 vl_api_one_map_resolver_dump_t *mp;
18036 vl_api_control_ping_t *mp_ping;
18039 if (!vam->json_output)
18041 print (vam->ofp, "%=20s", "Map resolver");
18044 M (ONE_MAP_RESOLVER_DUMP, mp);
18048 /* Use a control ping for synchronization */
18049 MPING (CONTROL_PING, mp_ping);
18052 /* Wait for a reply... */
18057 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
18060 api_one_stats_flush (vat_main_t * vam)
18062 vl_api_one_stats_flush_t *mp;
18065 M (ONE_STATS_FLUSH, mp);
18072 api_one_stats_dump (vat_main_t * vam)
18074 vl_api_one_stats_dump_t *mp;
18075 vl_api_control_ping_t *mp_ping;
18078 M (ONE_STATS_DUMP, mp);
18082 /* Use a control ping for synchronization */
18083 MPING (CONTROL_PING, mp_ping);
18086 /* Wait for a reply... */
18092 api_show_one_status (vat_main_t * vam)
18094 vl_api_show_one_status_t *mp;
18097 if (!vam->json_output)
18099 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
18102 M (SHOW_ONE_STATUS, mp);
18105 /* Wait for a reply... */
18110 #define api_show_lisp_status api_show_one_status
18113 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
18115 vl_api_gpe_fwd_entry_path_dump_t *mp;
18116 vl_api_control_ping_t *mp_ping;
18117 unformat_input_t *i = vam->input;
18118 u32 fwd_entry_index = ~0;
18121 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18123 if (unformat (i, "index %d", &fwd_entry_index))
18129 if (~0 == fwd_entry_index)
18131 errmsg ("no index specified!");
18135 if (!vam->json_output)
18137 print (vam->ofp, "first line");
18140 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
18144 /* Use a control ping for synchronization */
18145 MPING (CONTROL_PING, mp_ping);
18148 /* Wait for a reply... */
18154 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
18156 vl_api_one_get_map_request_itr_rlocs_t *mp;
18159 if (!vam->json_output)
18161 print (vam->ofp, "%=20s", "itr-rlocs:");
18164 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
18167 /* Wait for a reply... */
18172 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
18175 api_af_packet_create (vat_main_t * vam)
18177 unformat_input_t *i = vam->input;
18178 vl_api_af_packet_create_t *mp;
18179 u8 *host_if_name = 0;
18181 u8 random_hw_addr = 1;
18184 clib_memset (hw_addr, 0, sizeof (hw_addr));
18186 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18188 if (unformat (i, "name %s", &host_if_name))
18189 vec_add1 (host_if_name, 0);
18190 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18191 random_hw_addr = 0;
18196 if (!vec_len (host_if_name))
18198 errmsg ("host-interface name must be specified");
18202 if (vec_len (host_if_name) > 64)
18204 errmsg ("host-interface name too long");
18208 M (AF_PACKET_CREATE, mp);
18210 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18211 clib_memcpy (mp->hw_addr, hw_addr, 6);
18212 mp->use_random_hw_addr = random_hw_addr;
18213 vec_free (host_if_name);
18221 fprintf (vam->ofp ? vam->ofp : stderr,
18222 " new sw_if_index = %d\n", vam->sw_if_index);
18229 api_af_packet_delete (vat_main_t * vam)
18231 unformat_input_t *i = vam->input;
18232 vl_api_af_packet_delete_t *mp;
18233 u8 *host_if_name = 0;
18236 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18238 if (unformat (i, "name %s", &host_if_name))
18239 vec_add1 (host_if_name, 0);
18244 if (!vec_len (host_if_name))
18246 errmsg ("host-interface name must be specified");
18250 if (vec_len (host_if_name) > 64)
18252 errmsg ("host-interface name too long");
18256 M (AF_PACKET_DELETE, mp);
18258 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18259 vec_free (host_if_name);
18266 static void vl_api_af_packet_details_t_handler
18267 (vl_api_af_packet_details_t * mp)
18269 vat_main_t *vam = &vat_main;
18271 print (vam->ofp, "%-16s %d",
18272 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
18275 static void vl_api_af_packet_details_t_handler_json
18276 (vl_api_af_packet_details_t * mp)
18278 vat_main_t *vam = &vat_main;
18279 vat_json_node_t *node = NULL;
18281 if (VAT_JSON_ARRAY != vam->json_tree.type)
18283 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18284 vat_json_init_array (&vam->json_tree);
18286 node = vat_json_array_add (&vam->json_tree);
18288 vat_json_init_object (node);
18289 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
18290 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
18294 api_af_packet_dump (vat_main_t * vam)
18296 vl_api_af_packet_dump_t *mp;
18297 vl_api_control_ping_t *mp_ping;
18300 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
18301 /* Get list of tap interfaces */
18302 M (AF_PACKET_DUMP, mp);
18305 /* Use a control ping for synchronization */
18306 MPING (CONTROL_PING, mp_ping);
18314 api_policer_add_del (vat_main_t * vam)
18316 unformat_input_t *i = vam->input;
18317 vl_api_policer_add_del_t *mp;
18327 u8 color_aware = 0;
18328 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
18331 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
18332 conform_action.dscp = 0;
18333 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
18334 exceed_action.dscp = 0;
18335 violate_action.action_type = SSE2_QOS_ACTION_DROP;
18336 violate_action.dscp = 0;
18338 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18340 if (unformat (i, "del"))
18342 else if (unformat (i, "name %s", &name))
18343 vec_add1 (name, 0);
18344 else if (unformat (i, "cir %u", &cir))
18346 else if (unformat (i, "eir %u", &eir))
18348 else if (unformat (i, "cb %u", &cb))
18350 else if (unformat (i, "eb %u", &eb))
18352 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
18355 else if (unformat (i, "round_type %U", unformat_policer_round_type,
18358 else if (unformat (i, "type %U", unformat_policer_type, &type))
18360 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
18363 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
18366 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
18369 else if (unformat (i, "color-aware"))
18375 if (!vec_len (name))
18377 errmsg ("policer name must be specified");
18381 if (vec_len (name) > 64)
18383 errmsg ("policer name too long");
18387 M (POLICER_ADD_DEL, mp);
18389 clib_memcpy (mp->name, name, vec_len (name));
18391 mp->is_add = is_add;
18392 mp->cir = ntohl (cir);
18393 mp->eir = ntohl (eir);
18394 mp->cb = clib_net_to_host_u64 (cb);
18395 mp->eb = clib_net_to_host_u64 (eb);
18396 mp->rate_type = rate_type;
18397 mp->round_type = round_type;
18399 mp->conform_action_type = conform_action.action_type;
18400 mp->conform_dscp = conform_action.dscp;
18401 mp->exceed_action_type = exceed_action.action_type;
18402 mp->exceed_dscp = exceed_action.dscp;
18403 mp->violate_action_type = violate_action.action_type;
18404 mp->violate_dscp = violate_action.dscp;
18405 mp->color_aware = color_aware;
18413 api_policer_dump (vat_main_t * vam)
18415 unformat_input_t *i = vam->input;
18416 vl_api_policer_dump_t *mp;
18417 vl_api_control_ping_t *mp_ping;
18418 u8 *match_name = 0;
18419 u8 match_name_valid = 0;
18422 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18424 if (unformat (i, "name %s", &match_name))
18426 vec_add1 (match_name, 0);
18427 match_name_valid = 1;
18433 M (POLICER_DUMP, mp);
18434 mp->match_name_valid = match_name_valid;
18435 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
18436 vec_free (match_name);
18440 /* Use a control ping for synchronization */
18441 MPING (CONTROL_PING, mp_ping);
18444 /* Wait for a reply... */
18450 api_policer_classify_set_interface (vat_main_t * vam)
18452 unformat_input_t *i = vam->input;
18453 vl_api_policer_classify_set_interface_t *mp;
18455 int sw_if_index_set;
18456 u32 ip4_table_index = ~0;
18457 u32 ip6_table_index = ~0;
18458 u32 l2_table_index = ~0;
18462 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18464 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18465 sw_if_index_set = 1;
18466 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18467 sw_if_index_set = 1;
18468 else if (unformat (i, "del"))
18470 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18472 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18474 else if (unformat (i, "l2-table %d", &l2_table_index))
18478 clib_warning ("parse error '%U'", format_unformat_error, i);
18483 if (sw_if_index_set == 0)
18485 errmsg ("missing interface name or sw_if_index");
18489 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
18491 mp->sw_if_index = ntohl (sw_if_index);
18492 mp->ip4_table_index = ntohl (ip4_table_index);
18493 mp->ip6_table_index = ntohl (ip6_table_index);
18494 mp->l2_table_index = ntohl (l2_table_index);
18495 mp->is_add = is_add;
18503 api_policer_classify_dump (vat_main_t * vam)
18505 unformat_input_t *i = vam->input;
18506 vl_api_policer_classify_dump_t *mp;
18507 vl_api_control_ping_t *mp_ping;
18508 u8 type = POLICER_CLASSIFY_N_TABLES;
18511 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
18515 errmsg ("classify table type must be specified");
18519 if (!vam->json_output)
18521 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
18524 M (POLICER_CLASSIFY_DUMP, mp);
18529 /* Use a control ping for synchronization */
18530 MPING (CONTROL_PING, mp_ping);
18533 /* Wait for a reply... */
18539 api_netmap_create (vat_main_t * vam)
18541 unformat_input_t *i = vam->input;
18542 vl_api_netmap_create_t *mp;
18545 u8 random_hw_addr = 1;
18550 clib_memset (hw_addr, 0, sizeof (hw_addr));
18552 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18554 if (unformat (i, "name %s", &if_name))
18555 vec_add1 (if_name, 0);
18556 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18557 random_hw_addr = 0;
18558 else if (unformat (i, "pipe"))
18560 else if (unformat (i, "master"))
18562 else if (unformat (i, "slave"))
18568 if (!vec_len (if_name))
18570 errmsg ("interface name must be specified");
18574 if (vec_len (if_name) > 64)
18576 errmsg ("interface name too long");
18580 M (NETMAP_CREATE, mp);
18582 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18583 clib_memcpy (mp->hw_addr, hw_addr, 6);
18584 mp->use_random_hw_addr = random_hw_addr;
18585 mp->is_pipe = is_pipe;
18586 mp->is_master = is_master;
18587 vec_free (if_name);
18595 api_netmap_delete (vat_main_t * vam)
18597 unformat_input_t *i = vam->input;
18598 vl_api_netmap_delete_t *mp;
18602 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18604 if (unformat (i, "name %s", &if_name))
18605 vec_add1 (if_name, 0);
18610 if (!vec_len (if_name))
18612 errmsg ("interface name must be specified");
18616 if (vec_len (if_name) > 64)
18618 errmsg ("interface name too long");
18622 M (NETMAP_DELETE, mp);
18624 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18625 vec_free (if_name);
18633 format_fib_api_path_nh_proto (u8 * s, va_list * args)
18635 vl_api_fib_path_nh_proto_t proto =
18636 va_arg (*args, vl_api_fib_path_nh_proto_t);
18640 case FIB_API_PATH_NH_PROTO_IP4:
18641 s = format (s, "ip4");
18643 case FIB_API_PATH_NH_PROTO_IP6:
18644 s = format (s, "ip6");
18646 case FIB_API_PATH_NH_PROTO_MPLS:
18647 s = format (s, "mpls");
18649 case FIB_API_PATH_NH_PROTO_BIER:
18650 s = format (s, "bier");
18652 case FIB_API_PATH_NH_PROTO_ETHERNET:
18653 s = format (s, "ethernet");
18661 format_vl_api_ip_address_union (u8 * s, va_list * args)
18663 vl_api_address_family_t af = va_arg (*args, vl_api_address_family_t);
18664 const vl_api_address_union_t *u = va_arg (*args, vl_api_address_union_t *);
18669 s = format (s, "%U", format_ip4_address, u->ip4);
18672 s = format (s, "%U", format_ip6_address, u->ip6);
18679 format_vl_api_fib_path_type (u8 * s, va_list * args)
18681 vl_api_fib_path_type_t t = va_arg (*args, vl_api_fib_path_type_t);
18685 case FIB_API_PATH_TYPE_NORMAL:
18686 s = format (s, "normal");
18688 case FIB_API_PATH_TYPE_LOCAL:
18689 s = format (s, "local");
18691 case FIB_API_PATH_TYPE_DROP:
18692 s = format (s, "drop");
18694 case FIB_API_PATH_TYPE_UDP_ENCAP:
18695 s = format (s, "udp-encap");
18697 case FIB_API_PATH_TYPE_BIER_IMP:
18698 s = format (s, "bier-imp");
18700 case FIB_API_PATH_TYPE_ICMP_UNREACH:
18701 s = format (s, "unreach");
18703 case FIB_API_PATH_TYPE_ICMP_PROHIBIT:
18704 s = format (s, "prohibit");
18706 case FIB_API_PATH_TYPE_SOURCE_LOOKUP:
18707 s = format (s, "src-lookup");
18709 case FIB_API_PATH_TYPE_DVR:
18710 s = format (s, "dvr");
18712 case FIB_API_PATH_TYPE_INTERFACE_RX:
18713 s = format (s, "interface-rx");
18715 case FIB_API_PATH_TYPE_CLASSIFY:
18716 s = format (s, "classify");
18724 vl_api_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
18727 " weight %d, sw_if_index %d, type %U, afi %U, next_hop %U",
18728 ntohl (fp->weight), ntohl (fp->sw_if_index),
18729 format_vl_api_fib_path_type, fp->type,
18730 format_fib_api_path_nh_proto, fp->proto,
18731 format_vl_api_ip_address_union, &fp->nh.address);
18735 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
18736 vl_api_fib_path_t * fp)
18738 struct in_addr ip4;
18739 struct in6_addr ip6;
18741 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
18742 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
18743 vat_json_object_add_uint (node, "type", fp->type);
18744 vat_json_object_add_uint (node, "next_hop_proto", fp->proto);
18745 if (fp->proto == FIB_API_PATH_NH_PROTO_IP4)
18747 clib_memcpy (&ip4, &fp->nh.address.ip4, sizeof (ip4));
18748 vat_json_object_add_ip4 (node, "next_hop", ip4);
18750 else if (fp->proto == FIB_API_PATH_NH_PROTO_IP4)
18752 clib_memcpy (&ip6, &fp->nh.address.ip6, sizeof (ip6));
18753 vat_json_object_add_ip6 (node, "next_hop", ip6);
18758 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
18760 vat_main_t *vam = &vat_main;
18761 int count = ntohl (mp->mt_tunnel.mt_n_paths);
18762 vl_api_fib_path_t *fp;
18765 print (vam->ofp, "sw_if_index %d via:",
18766 ntohl (mp->mt_tunnel.mt_sw_if_index));
18767 fp = mp->mt_tunnel.mt_paths;
18768 for (i = 0; i < count; i++)
18770 vl_api_fib_path_print (vam, fp);
18774 print (vam->ofp, "");
18777 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
18778 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
18781 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
18783 vat_main_t *vam = &vat_main;
18784 vat_json_node_t *node = NULL;
18785 int count = ntohl (mp->mt_tunnel.mt_n_paths);
18786 vl_api_fib_path_t *fp;
18789 if (VAT_JSON_ARRAY != vam->json_tree.type)
18791 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18792 vat_json_init_array (&vam->json_tree);
18794 node = vat_json_array_add (&vam->json_tree);
18796 vat_json_init_object (node);
18797 vat_json_object_add_uint (node, "sw_if_index",
18798 ntohl (mp->mt_tunnel.mt_sw_if_index));
18800 vat_json_object_add_uint (node, "l2_only", mp->mt_tunnel.mt_l2_only);
18802 fp = mp->mt_tunnel.mt_paths;
18803 for (i = 0; i < count; i++)
18805 vl_api_mpls_fib_path_json_print (node, fp);
18811 api_mpls_tunnel_dump (vat_main_t * vam)
18813 vl_api_mpls_tunnel_dump_t *mp;
18814 vl_api_control_ping_t *mp_ping;
18817 M (MPLS_TUNNEL_DUMP, mp);
18821 /* Use a control ping for synchronization */
18822 MPING (CONTROL_PING, mp_ping);
18829 #define vl_api_mpls_table_details_t_endian vl_noop_handler
18830 #define vl_api_mpls_table_details_t_print vl_noop_handler
18834 vl_api_mpls_table_details_t_handler (vl_api_mpls_table_details_t * mp)
18836 vat_main_t *vam = &vat_main;
18838 print (vam->ofp, "table-id %d,", ntohl (mp->mt_table.mt_table_id));
18841 static void vl_api_mpls_table_details_t_handler_json
18842 (vl_api_mpls_table_details_t * mp)
18844 vat_main_t *vam = &vat_main;
18845 vat_json_node_t *node = NULL;
18847 if (VAT_JSON_ARRAY != vam->json_tree.type)
18849 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18850 vat_json_init_array (&vam->json_tree);
18852 node = vat_json_array_add (&vam->json_tree);
18854 vat_json_init_object (node);
18855 vat_json_object_add_uint (node, "table", ntohl (mp->mt_table.mt_table_id));
18859 api_mpls_table_dump (vat_main_t * vam)
18861 vl_api_mpls_table_dump_t *mp;
18862 vl_api_control_ping_t *mp_ping;
18865 M (MPLS_TABLE_DUMP, mp);
18868 /* Use a control ping for synchronization */
18869 MPING (CONTROL_PING, mp_ping);
18876 #define vl_api_mpls_route_details_t_endian vl_noop_handler
18877 #define vl_api_mpls_route_details_t_print vl_noop_handler
18880 vl_api_mpls_route_details_t_handler (vl_api_mpls_route_details_t * mp)
18882 vat_main_t *vam = &vat_main;
18883 int count = (int) clib_net_to_host_u32 (mp->mr_route.mr_n_paths);
18884 vl_api_fib_path_t *fp;
18888 "table-id %d, label %u, ess_bit %u",
18889 ntohl (mp->mr_route.mr_table_id),
18890 ntohl (mp->mr_route.mr_label), mp->mr_route.mr_eos);
18891 fp = mp->mr_route.mr_paths;
18892 for (i = 0; i < count; i++)
18894 vl_api_fib_path_print (vam, fp);
18899 static void vl_api_mpls_route_details_t_handler_json
18900 (vl_api_mpls_route_details_t * mp)
18902 vat_main_t *vam = &vat_main;
18903 int count = (int) clib_host_to_net_u32 (mp->mr_route.mr_n_paths);
18904 vat_json_node_t *node = NULL;
18905 vl_api_fib_path_t *fp;
18908 if (VAT_JSON_ARRAY != vam->json_tree.type)
18910 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18911 vat_json_init_array (&vam->json_tree);
18913 node = vat_json_array_add (&vam->json_tree);
18915 vat_json_init_object (node);
18916 vat_json_object_add_uint (node, "table", ntohl (mp->mr_route.mr_table_id));
18917 vat_json_object_add_uint (node, "s_bit", mp->mr_route.mr_eos);
18918 vat_json_object_add_uint (node, "label", ntohl (mp->mr_route.mr_label));
18919 vat_json_object_add_uint (node, "path_count", count);
18920 fp = mp->mr_route.mr_paths;
18921 for (i = 0; i < count; i++)
18923 vl_api_mpls_fib_path_json_print (node, fp);
18929 api_mpls_route_dump (vat_main_t * vam)
18931 unformat_input_t *input = vam->input;
18932 vl_api_mpls_route_dump_t *mp;
18933 vl_api_control_ping_t *mp_ping;
18937 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18939 if (unformat (input, "table_id %d", &table_id))
18944 if (table_id == ~0)
18946 errmsg ("missing table id");
18950 M (MPLS_ROUTE_DUMP, mp);
18952 mp->table.mt_table_id = ntohl (table_id);
18955 /* Use a control ping for synchronization */
18956 MPING (CONTROL_PING, mp_ping);
18963 #define vl_api_ip_table_details_t_endian vl_noop_handler
18964 #define vl_api_ip_table_details_t_print vl_noop_handler
18967 vl_api_ip_table_details_t_handler (vl_api_ip_table_details_t * mp)
18969 vat_main_t *vam = &vat_main;
18972 "%s; table-id %d, prefix %U/%d",
18973 mp->table.name, ntohl (mp->table.table_id));
18977 static void vl_api_ip_table_details_t_handler_json
18978 (vl_api_ip_table_details_t * mp)
18980 vat_main_t *vam = &vat_main;
18981 vat_json_node_t *node = NULL;
18983 if (VAT_JSON_ARRAY != vam->json_tree.type)
18985 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18986 vat_json_init_array (&vam->json_tree);
18988 node = vat_json_array_add (&vam->json_tree);
18990 vat_json_init_object (node);
18991 vat_json_object_add_uint (node, "table", ntohl (mp->table.table_id));
18995 api_ip_table_dump (vat_main_t * vam)
18997 vl_api_ip_table_dump_t *mp;
18998 vl_api_control_ping_t *mp_ping;
19001 M (IP_TABLE_DUMP, mp);
19004 /* Use a control ping for synchronization */
19005 MPING (CONTROL_PING, mp_ping);
19013 api_ip_mtable_dump (vat_main_t * vam)
19015 vl_api_ip_mtable_dump_t *mp;
19016 vl_api_control_ping_t *mp_ping;
19019 M (IP_MTABLE_DUMP, mp);
19022 /* Use a control ping for synchronization */
19023 MPING (CONTROL_PING, mp_ping);
19031 api_ip_mroute_dump (vat_main_t * vam)
19033 unformat_input_t *input = vam->input;
19034 vl_api_control_ping_t *mp_ping;
19035 vl_api_ip_mroute_dump_t *mp;
19040 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19042 if (unformat (input, "table_id %d", &table_id))
19044 else if (unformat (input, "ip6"))
19046 else if (unformat (input, "ip4"))
19051 if (table_id == ~0)
19053 errmsg ("missing table id");
19057 M (IP_MROUTE_DUMP, mp);
19058 mp->table.table_id = table_id;
19059 mp->table.is_ip6 = is_ip6;
19062 /* Use a control ping for synchronization */
19063 MPING (CONTROL_PING, mp_ping);
19070 static void vl_api_ip_neighbor_details_t_handler
19071 (vl_api_ip_neighbor_details_t * mp)
19073 vat_main_t *vam = &vat_main;
19075 print (vam->ofp, "%c %U %U",
19076 (ntohl (mp->neighbor.flags) & IP_NEIGHBOR_FLAG_STATIC) ? 'S' : 'D',
19077 format_vl_api_mac_address, &mp->neighbor.mac_address,
19078 format_vl_api_address, &mp->neighbor.ip_address);
19081 static void vl_api_ip_neighbor_details_t_handler_json
19082 (vl_api_ip_neighbor_details_t * mp)
19085 vat_main_t *vam = &vat_main;
19086 vat_json_node_t *node;
19088 if (VAT_JSON_ARRAY != vam->json_tree.type)
19090 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19091 vat_json_init_array (&vam->json_tree);
19093 node = vat_json_array_add (&vam->json_tree);
19095 vat_json_init_object (node);
19096 vat_json_object_add_string_copy
19098 ((ntohl (mp->neighbor.flags) & IP_NEIGHBOR_FLAG_STATIC) ?
19099 (u8 *) "static" : (u8 *) "dynamic"));
19101 vat_json_object_add_string_copy (node, "link_layer",
19102 format (0, "%U", format_vl_api_mac_address,
19103 &mp->neighbor.mac_address));
19104 vat_json_object_add_address (node, "ip", &mp->neighbor.ip_address);
19108 api_ip_neighbor_dump (vat_main_t * vam)
19110 unformat_input_t *i = vam->input;
19111 vl_api_ip_neighbor_dump_t *mp;
19112 vl_api_control_ping_t *mp_ping;
19114 u32 sw_if_index = ~0;
19117 /* Parse args required to build the message */
19118 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19120 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19122 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19124 else if (unformat (i, "ip6"))
19130 if (sw_if_index == ~0)
19132 errmsg ("missing interface name or sw_if_index");
19136 M (IP_NEIGHBOR_DUMP, mp);
19137 mp->is_ipv6 = (u8) is_ipv6;
19138 mp->sw_if_index = ntohl (sw_if_index);
19141 /* Use a control ping for synchronization */
19142 MPING (CONTROL_PING, mp_ping);
19149 #define vl_api_ip_route_details_t_endian vl_noop_handler
19150 #define vl_api_ip_route_details_t_print vl_noop_handler
19153 vl_api_ip_route_details_t_handler (vl_api_ip_route_details_t * mp)
19155 vat_main_t *vam = &vat_main;
19156 u8 count = mp->route.n_paths;
19157 vl_api_fib_path_t *fp;
19161 "table-id %d, prefix %U/%d",
19162 ntohl (mp->route.table_id),
19163 format_ip46_address, mp->route.prefix.address, mp->route.prefix.len);
19164 for (i = 0; i < count; i++)
19166 fp = &mp->route.paths[i];
19168 vl_api_fib_path_print (vam, fp);
19173 static void vl_api_ip_route_details_t_handler_json
19174 (vl_api_ip_route_details_t * mp)
19176 vat_main_t *vam = &vat_main;
19177 u8 count = mp->route.n_paths;
19178 vat_json_node_t *node = NULL;
19179 struct in_addr ip4;
19180 struct in6_addr ip6;
19181 vl_api_fib_path_t *fp;
19184 if (VAT_JSON_ARRAY != vam->json_tree.type)
19186 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19187 vat_json_init_array (&vam->json_tree);
19189 node = vat_json_array_add (&vam->json_tree);
19191 vat_json_init_object (node);
19192 vat_json_object_add_uint (node, "table", ntohl (mp->route.table_id));
19193 if (ADDRESS_IP6 == mp->route.prefix.address.af)
19195 clib_memcpy (&ip6, &mp->route.prefix.address.un.ip6, sizeof (ip6));
19196 vat_json_object_add_ip6 (node, "prefix", ip6);
19200 clib_memcpy (&ip4, &mp->route.prefix.address.un.ip4, sizeof (ip4));
19201 vat_json_object_add_ip4 (node, "prefix", ip4);
19203 vat_json_object_add_uint (node, "mask_length", mp->route.prefix.len);
19204 vat_json_object_add_uint (node, "path_count", count);
19205 for (i = 0; i < count; i++)
19207 fp = &mp->route.paths[i];
19208 vl_api_mpls_fib_path_json_print (node, fp);
19213 api_ip_route_dump (vat_main_t * vam)
19215 unformat_input_t *input = vam->input;
19216 vl_api_ip_route_dump_t *mp;
19217 vl_api_control_ping_t *mp_ping;
19223 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19225 if (unformat (input, "table_id %d", &table_id))
19227 else if (unformat (input, "ip6"))
19229 else if (unformat (input, "ip4"))
19234 if (table_id == ~0)
19236 errmsg ("missing table id");
19240 M (IP_ROUTE_DUMP, mp);
19242 mp->table.table_id = table_id;
19243 mp->table.is_ip6 = is_ip6;
19247 /* Use a control ping for synchronization */
19248 MPING (CONTROL_PING, mp_ping);
19256 api_classify_table_ids (vat_main_t * vam)
19258 vl_api_classify_table_ids_t *mp;
19261 /* Construct the API message */
19262 M (CLASSIFY_TABLE_IDS, mp);
19271 api_classify_table_by_interface (vat_main_t * vam)
19273 unformat_input_t *input = vam->input;
19274 vl_api_classify_table_by_interface_t *mp;
19276 u32 sw_if_index = ~0;
19278 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19280 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19282 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19287 if (sw_if_index == ~0)
19289 errmsg ("missing interface name or sw_if_index");
19293 /* Construct the API message */
19294 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
19296 mp->sw_if_index = ntohl (sw_if_index);
19304 api_classify_table_info (vat_main_t * vam)
19306 unformat_input_t *input = vam->input;
19307 vl_api_classify_table_info_t *mp;
19311 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19313 if (unformat (input, "table_id %d", &table_id))
19318 if (table_id == ~0)
19320 errmsg ("missing table id");
19324 /* Construct the API message */
19325 M (CLASSIFY_TABLE_INFO, mp);
19327 mp->table_id = ntohl (table_id);
19335 api_classify_session_dump (vat_main_t * vam)
19337 unformat_input_t *input = vam->input;
19338 vl_api_classify_session_dump_t *mp;
19339 vl_api_control_ping_t *mp_ping;
19343 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19345 if (unformat (input, "table_id %d", &table_id))
19350 if (table_id == ~0)
19352 errmsg ("missing table id");
19356 /* Construct the API message */
19357 M (CLASSIFY_SESSION_DUMP, mp);
19359 mp->table_id = ntohl (table_id);
19362 /* Use a control ping for synchronization */
19363 MPING (CONTROL_PING, mp_ping);
19371 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
19373 vat_main_t *vam = &vat_main;
19375 print (vam->ofp, "collector_address %U, collector_port %d, "
19376 "src_address %U, vrf_id %d, path_mtu %u, "
19377 "template_interval %u, udp_checksum %d",
19378 format_ip4_address, mp->collector_address,
19379 ntohs (mp->collector_port),
19380 format_ip4_address, mp->src_address,
19381 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
19382 ntohl (mp->template_interval), mp->udp_checksum);
19385 vam->result_ready = 1;
19389 vl_api_ipfix_exporter_details_t_handler_json
19390 (vl_api_ipfix_exporter_details_t * mp)
19392 vat_main_t *vam = &vat_main;
19393 vat_json_node_t node;
19394 struct in_addr collector_address;
19395 struct in_addr src_address;
19397 vat_json_init_object (&node);
19398 clib_memcpy (&collector_address, &mp->collector_address,
19399 sizeof (collector_address));
19400 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
19401 vat_json_object_add_uint (&node, "collector_port",
19402 ntohs (mp->collector_port));
19403 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
19404 vat_json_object_add_ip4 (&node, "src_address", src_address);
19405 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
19406 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
19407 vat_json_object_add_uint (&node, "template_interval",
19408 ntohl (mp->template_interval));
19409 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
19411 vat_json_print (vam->ofp, &node);
19412 vat_json_free (&node);
19414 vam->result_ready = 1;
19418 api_ipfix_exporter_dump (vat_main_t * vam)
19420 vl_api_ipfix_exporter_dump_t *mp;
19423 /* Construct the API message */
19424 M (IPFIX_EXPORTER_DUMP, mp);
19433 api_ipfix_classify_stream_dump (vat_main_t * vam)
19435 vl_api_ipfix_classify_stream_dump_t *mp;
19438 /* Construct the API message */
19439 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
19450 vl_api_ipfix_classify_stream_details_t_handler
19451 (vl_api_ipfix_classify_stream_details_t * mp)
19453 vat_main_t *vam = &vat_main;
19454 print (vam->ofp, "domain_id %d, src_port %d",
19455 ntohl (mp->domain_id), ntohs (mp->src_port));
19457 vam->result_ready = 1;
19461 vl_api_ipfix_classify_stream_details_t_handler_json
19462 (vl_api_ipfix_classify_stream_details_t * mp)
19464 vat_main_t *vam = &vat_main;
19465 vat_json_node_t node;
19467 vat_json_init_object (&node);
19468 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
19469 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
19471 vat_json_print (vam->ofp, &node);
19472 vat_json_free (&node);
19474 vam->result_ready = 1;
19478 api_ipfix_classify_table_dump (vat_main_t * vam)
19480 vl_api_ipfix_classify_table_dump_t *mp;
19481 vl_api_control_ping_t *mp_ping;
19484 if (!vam->json_output)
19486 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
19487 "transport_protocol");
19490 /* Construct the API message */
19491 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
19496 /* Use a control ping for synchronization */
19497 MPING (CONTROL_PING, mp_ping);
19505 vl_api_ipfix_classify_table_details_t_handler
19506 (vl_api_ipfix_classify_table_details_t * mp)
19508 vat_main_t *vam = &vat_main;
19509 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
19510 mp->transport_protocol);
19514 vl_api_ipfix_classify_table_details_t_handler_json
19515 (vl_api_ipfix_classify_table_details_t * mp)
19517 vat_json_node_t *node = NULL;
19518 vat_main_t *vam = &vat_main;
19520 if (VAT_JSON_ARRAY != vam->json_tree.type)
19522 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19523 vat_json_init_array (&vam->json_tree);
19526 node = vat_json_array_add (&vam->json_tree);
19527 vat_json_init_object (node);
19529 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
19530 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
19531 vat_json_object_add_uint (node, "transport_protocol",
19532 mp->transport_protocol);
19536 api_sw_interface_span_enable_disable (vat_main_t * vam)
19538 unformat_input_t *i = vam->input;
19539 vl_api_sw_interface_span_enable_disable_t *mp;
19540 u32 src_sw_if_index = ~0;
19541 u32 dst_sw_if_index = ~0;
19546 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19549 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
19551 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
19555 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
19557 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
19559 else if (unformat (i, "disable"))
19561 else if (unformat (i, "rx"))
19563 else if (unformat (i, "tx"))
19565 else if (unformat (i, "both"))
19567 else if (unformat (i, "l2"))
19573 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
19575 mp->sw_if_index_from = htonl (src_sw_if_index);
19576 mp->sw_if_index_to = htonl (dst_sw_if_index);
19586 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
19589 vat_main_t *vam = &vat_main;
19590 u8 *sw_if_from_name = 0;
19591 u8 *sw_if_to_name = 0;
19592 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19593 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19594 char *states[] = { "none", "rx", "tx", "both" };
19598 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19600 if ((u32) p->value[0] == sw_if_index_from)
19602 sw_if_from_name = (u8 *)(p->key);
19606 if ((u32) p->value[0] == sw_if_index_to)
19608 sw_if_to_name = (u8 *)(p->key);
19609 if (sw_if_from_name)
19614 print (vam->ofp, "%20s => %20s (%s) %s",
19615 sw_if_from_name, sw_if_to_name, states[mp->state],
19616 mp->is_l2 ? "l2" : "device");
19620 vl_api_sw_interface_span_details_t_handler_json
19621 (vl_api_sw_interface_span_details_t * mp)
19623 vat_main_t *vam = &vat_main;
19624 vat_json_node_t *node = NULL;
19625 u8 *sw_if_from_name = 0;
19626 u8 *sw_if_to_name = 0;
19627 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19628 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19632 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19634 if ((u32) p->value[0] == sw_if_index_from)
19636 sw_if_from_name = (u8 *)(p->key);
19640 if ((u32) p->value[0] == sw_if_index_to)
19642 sw_if_to_name = (u8 *)(p->key);
19643 if (sw_if_from_name)
19649 if (VAT_JSON_ARRAY != vam->json_tree.type)
19651 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19652 vat_json_init_array (&vam->json_tree);
19654 node = vat_json_array_add (&vam->json_tree);
19656 vat_json_init_object (node);
19657 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
19658 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
19659 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
19660 if (0 != sw_if_to_name)
19662 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
19664 vat_json_object_add_uint (node, "state", mp->state);
19665 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
19669 api_sw_interface_span_dump (vat_main_t * vam)
19671 unformat_input_t *input = vam->input;
19672 vl_api_sw_interface_span_dump_t *mp;
19673 vl_api_control_ping_t *mp_ping;
19677 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19679 if (unformat (input, "l2"))
19685 M (SW_INTERFACE_SPAN_DUMP, mp);
19689 /* Use a control ping for synchronization */
19690 MPING (CONTROL_PING, mp_ping);
19698 api_pg_create_interface (vat_main_t * vam)
19700 unformat_input_t *input = vam->input;
19701 vl_api_pg_create_interface_t *mp;
19703 u32 if_id = ~0, gso_size = 0;
19704 u8 gso_enabled = 0;
19706 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19708 if (unformat (input, "if_id %d", &if_id))
19710 else if (unformat (input, "gso-enabled"))
19713 if (unformat (input, "gso-size %u", &gso_size))
19717 errmsg ("missing gso-size");
19726 errmsg ("missing pg interface index");
19730 /* Construct the API message */
19731 M (PG_CREATE_INTERFACE, mp);
19733 mp->interface_id = ntohl (if_id);
19734 mp->gso_enabled = gso_enabled;
19742 api_pg_capture (vat_main_t * vam)
19744 unformat_input_t *input = vam->input;
19745 vl_api_pg_capture_t *mp;
19750 u8 pcap_file_set = 0;
19753 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19755 if (unformat (input, "if_id %d", &if_id))
19757 else if (unformat (input, "pcap %s", &pcap_file))
19759 else if (unformat (input, "count %d", &count))
19761 else if (unformat (input, "disable"))
19768 errmsg ("missing pg interface index");
19771 if (pcap_file_set > 0)
19773 if (vec_len (pcap_file) > 255)
19775 errmsg ("pcap file name is too long");
19780 u32 name_len = vec_len (pcap_file);
19781 /* Construct the API message */
19782 M (PG_CAPTURE, mp);
19784 mp->interface_id = ntohl (if_id);
19785 mp->is_enabled = enable;
19786 mp->count = ntohl (count);
19787 mp->pcap_name_length = ntohl (name_len);
19788 if (pcap_file_set != 0)
19790 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
19792 vec_free (pcap_file);
19800 api_pg_enable_disable (vat_main_t * vam)
19802 unformat_input_t *input = vam->input;
19803 vl_api_pg_enable_disable_t *mp;
19806 u8 stream_name_set = 0;
19807 u8 *stream_name = 0;
19809 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19811 if (unformat (input, "stream %s", &stream_name))
19812 stream_name_set = 1;
19813 else if (unformat (input, "disable"))
19819 if (stream_name_set > 0)
19821 if (vec_len (stream_name) > 255)
19823 errmsg ("stream name too long");
19828 u32 name_len = vec_len (stream_name);
19829 /* Construct the API message */
19830 M (PG_ENABLE_DISABLE, mp);
19832 mp->is_enabled = enable;
19833 if (stream_name_set != 0)
19835 mp->stream_name_length = ntohl (name_len);
19836 clib_memcpy (mp->stream_name, stream_name, name_len);
19838 vec_free (stream_name);
19846 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
19848 unformat_input_t *input = vam->input;
19849 vl_api_ip_source_and_port_range_check_add_del_t *mp;
19851 u16 *low_ports = 0;
19852 u16 *high_ports = 0;
19855 vl_api_prefix_t prefix;
19862 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19864 if (unformat (input, "%U", unformat_vl_api_prefix, &prefix))
19866 else if (unformat (input, "vrf %d", &vrf_id))
19868 else if (unformat (input, "del"))
19870 else if (unformat (input, "port %d", &tmp))
19872 if (tmp == 0 || tmp > 65535)
19874 errmsg ("port %d out of range", tmp);
19878 this_hi = this_low + 1;
19879 vec_add1 (low_ports, this_low);
19880 vec_add1 (high_ports, this_hi);
19882 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
19884 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
19886 errmsg ("incorrect range parameters");
19890 /* Note: in debug CLI +1 is added to high before
19891 passing to real fn that does "the work"
19892 (ip_source_and_port_range_check_add_del).
19893 This fn is a wrapper around the binary API fn a
19894 control plane will call, which expects this increment
19895 to have occurred. Hence letting the binary API control
19896 plane fn do the increment for consistency between VAT
19897 and other control planes.
19900 vec_add1 (low_ports, this_low);
19901 vec_add1 (high_ports, this_hi);
19907 if (prefix_set == 0)
19909 errmsg ("<address>/<mask> not specified");
19915 errmsg ("VRF ID required, not specified");
19922 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
19926 if (vec_len (low_ports) == 0)
19928 errmsg ("At least one port or port range required");
19932 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
19934 mp->is_add = is_add;
19936 clib_memcpy (&mp->prefix, &prefix, sizeof (prefix));
19938 mp->number_of_ranges = vec_len (low_ports);
19940 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
19941 vec_free (low_ports);
19943 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
19944 vec_free (high_ports);
19946 mp->vrf_id = ntohl (vrf_id);
19954 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
19956 unformat_input_t *input = vam->input;
19957 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
19958 u32 sw_if_index = ~0;
19960 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
19961 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
19965 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19967 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19969 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19971 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
19973 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
19975 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
19977 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
19979 else if (unformat (input, "del"))
19985 if (sw_if_index == ~0)
19987 errmsg ("Interface required but not specified");
19993 errmsg ("VRF ID required but not specified");
19997 if (tcp_out_vrf_id == 0
19998 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
20001 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
20005 /* Construct the API message */
20006 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
20008 mp->sw_if_index = ntohl (sw_if_index);
20009 mp->is_add = is_add;
20010 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
20011 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
20012 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
20013 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
20018 /* Wait for a reply... */
20024 api_set_punt (vat_main_t * vam)
20026 unformat_input_t *i = vam->input;
20027 vl_api_address_family_t af;
20028 vl_api_set_punt_t *mp;
20034 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20036 if (unformat (i, "%U", unformat_vl_api_address_family, &af))
20038 else if (unformat (i, "protocol %d", &protocol))
20040 else if (unformat (i, "port %d", &port))
20042 else if (unformat (i, "del"))
20046 clib_warning ("parse error '%U'", format_unformat_error, i);
20053 mp->is_add = (u8) is_add;
20054 mp->punt.type = PUNT_API_TYPE_L4;
20055 mp->punt.punt.l4.af = af;
20056 mp->punt.punt.l4.protocol = (u8) protocol;
20057 mp->punt.punt.l4.port = htons ((u16) port);
20065 api_delete_subif (vat_main_t * vam)
20067 unformat_input_t *i = vam->input;
20068 vl_api_delete_subif_t *mp;
20069 u32 sw_if_index = ~0;
20072 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20074 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20076 if (unformat (i, "sw_if_index %d", &sw_if_index))
20082 if (sw_if_index == ~0)
20084 errmsg ("missing sw_if_index");
20088 /* Construct the API message */
20089 M (DELETE_SUBIF, mp);
20090 mp->sw_if_index = ntohl (sw_if_index);
20097 #define foreach_pbb_vtr_op \
20098 _("disable", L2_VTR_DISABLED) \
20099 _("pop", L2_VTR_POP_2) \
20100 _("push", L2_VTR_PUSH_2)
20103 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
20105 unformat_input_t *i = vam->input;
20106 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
20107 u32 sw_if_index = ~0, vtr_op = ~0;
20108 u16 outer_tag = ~0;
20109 u8 dmac[6], smac[6];
20110 u8 dmac_set = 0, smac_set = 0;
20116 /* Shut up coverity */
20117 clib_memset (dmac, 0, sizeof (dmac));
20118 clib_memset (smac, 0, sizeof (smac));
20120 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20122 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20124 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20126 else if (unformat (i, "vtr_op %d", &vtr_op))
20128 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
20131 else if (unformat (i, "translate_pbb_stag"))
20133 if (unformat (i, "%d", &tmp))
20135 vtr_op = L2_VTR_TRANSLATE_2_1;
20141 ("translate_pbb_stag operation requires outer tag definition");
20145 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
20147 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
20149 else if (unformat (i, "sid %d", &sid))
20151 else if (unformat (i, "vlanid %d", &tmp))
20155 clib_warning ("parse error '%U'", format_unformat_error, i);
20160 if ((sw_if_index == ~0) || (vtr_op == ~0))
20162 errmsg ("missing sw_if_index or vtr operation");
20165 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
20166 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
20169 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
20173 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
20174 mp->sw_if_index = ntohl (sw_if_index);
20175 mp->vtr_op = ntohl (vtr_op);
20176 mp->outer_tag = ntohs (outer_tag);
20177 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
20178 clib_memcpy (mp->b_smac, smac, sizeof (smac));
20179 mp->b_vlanid = ntohs (vlanid);
20180 mp->i_sid = ntohl (sid);
20188 api_flow_classify_set_interface (vat_main_t * vam)
20190 unformat_input_t *i = vam->input;
20191 vl_api_flow_classify_set_interface_t *mp;
20193 int sw_if_index_set;
20194 u32 ip4_table_index = ~0;
20195 u32 ip6_table_index = ~0;
20199 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20201 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20202 sw_if_index_set = 1;
20203 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20204 sw_if_index_set = 1;
20205 else if (unformat (i, "del"))
20207 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20209 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20213 clib_warning ("parse error '%U'", format_unformat_error, i);
20218 if (sw_if_index_set == 0)
20220 errmsg ("missing interface name or sw_if_index");
20224 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
20226 mp->sw_if_index = ntohl (sw_if_index);
20227 mp->ip4_table_index = ntohl (ip4_table_index);
20228 mp->ip6_table_index = ntohl (ip6_table_index);
20229 mp->is_add = is_add;
20237 api_flow_classify_dump (vat_main_t * vam)
20239 unformat_input_t *i = vam->input;
20240 vl_api_flow_classify_dump_t *mp;
20241 vl_api_control_ping_t *mp_ping;
20242 u8 type = FLOW_CLASSIFY_N_TABLES;
20245 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
20249 errmsg ("classify table type must be specified");
20253 if (!vam->json_output)
20255 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20258 M (FLOW_CLASSIFY_DUMP, mp);
20263 /* Use a control ping for synchronization */
20264 MPING (CONTROL_PING, mp_ping);
20267 /* Wait for a reply... */
20273 api_feature_enable_disable (vat_main_t * vam)
20275 unformat_input_t *i = vam->input;
20276 vl_api_feature_enable_disable_t *mp;
20278 u8 *feature_name = 0;
20279 u32 sw_if_index = ~0;
20283 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20285 if (unformat (i, "arc_name %s", &arc_name))
20287 else if (unformat (i, "feature_name %s", &feature_name))
20290 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20292 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20294 else if (unformat (i, "disable"))
20302 errmsg ("missing arc name");
20305 if (vec_len (arc_name) > 63)
20307 errmsg ("arc name too long");
20310 if (feature_name == 0)
20312 errmsg ("missing feature name");
20315 if (vec_len (feature_name) > 63)
20317 errmsg ("feature name too long");
20320 if (sw_if_index == ~0)
20322 errmsg ("missing interface name or sw_if_index");
20326 /* Construct the API message */
20327 M (FEATURE_ENABLE_DISABLE, mp);
20328 mp->sw_if_index = ntohl (sw_if_index);
20329 mp->enable = enable;
20330 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
20331 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
20332 vec_free (arc_name);
20333 vec_free (feature_name);
20341 api_sw_interface_tag_add_del (vat_main_t * vam)
20343 unformat_input_t *i = vam->input;
20344 vl_api_sw_interface_tag_add_del_t *mp;
20345 u32 sw_if_index = ~0;
20350 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20352 if (unformat (i, "tag %s", &tag))
20354 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20356 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20358 else if (unformat (i, "del"))
20364 if (sw_if_index == ~0)
20366 errmsg ("missing interface name or sw_if_index");
20370 if (enable && (tag == 0))
20372 errmsg ("no tag specified");
20376 /* Construct the API message */
20377 M (SW_INTERFACE_TAG_ADD_DEL, mp);
20378 mp->sw_if_index = ntohl (sw_if_index);
20379 mp->is_add = enable;
20381 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
20389 static void vl_api_l2_xconnect_details_t_handler
20390 (vl_api_l2_xconnect_details_t * mp)
20392 vat_main_t *vam = &vat_main;
20394 print (vam->ofp, "%15d%15d",
20395 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
20398 static void vl_api_l2_xconnect_details_t_handler_json
20399 (vl_api_l2_xconnect_details_t * mp)
20401 vat_main_t *vam = &vat_main;
20402 vat_json_node_t *node = NULL;
20404 if (VAT_JSON_ARRAY != vam->json_tree.type)
20406 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20407 vat_json_init_array (&vam->json_tree);
20409 node = vat_json_array_add (&vam->json_tree);
20411 vat_json_init_object (node);
20412 vat_json_object_add_uint (node, "rx_sw_if_index",
20413 ntohl (mp->rx_sw_if_index));
20414 vat_json_object_add_uint (node, "tx_sw_if_index",
20415 ntohl (mp->tx_sw_if_index));
20419 api_l2_xconnect_dump (vat_main_t * vam)
20421 vl_api_l2_xconnect_dump_t *mp;
20422 vl_api_control_ping_t *mp_ping;
20425 if (!vam->json_output)
20427 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
20430 M (L2_XCONNECT_DUMP, mp);
20434 /* Use a control ping for synchronization */
20435 MPING (CONTROL_PING, mp_ping);
20443 api_hw_interface_set_mtu (vat_main_t * vam)
20445 unformat_input_t *i = vam->input;
20446 vl_api_hw_interface_set_mtu_t *mp;
20447 u32 sw_if_index = ~0;
20451 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20453 if (unformat (i, "mtu %d", &mtu))
20455 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20457 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20463 if (sw_if_index == ~0)
20465 errmsg ("missing interface name or sw_if_index");
20471 errmsg ("no mtu specified");
20475 /* Construct the API message */
20476 M (HW_INTERFACE_SET_MTU, mp);
20477 mp->sw_if_index = ntohl (sw_if_index);
20478 mp->mtu = ntohs ((u16) mtu);
20486 api_p2p_ethernet_add (vat_main_t * vam)
20488 unformat_input_t *i = vam->input;
20489 vl_api_p2p_ethernet_add_t *mp;
20490 u32 parent_if_index = ~0;
20496 clib_memset (remote_mac, 0, sizeof (remote_mac));
20497 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20499 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20501 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20505 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20507 else if (unformat (i, "sub_id %d", &sub_id))
20511 clib_warning ("parse error '%U'", format_unformat_error, i);
20516 if (parent_if_index == ~0)
20518 errmsg ("missing interface name or sw_if_index");
20523 errmsg ("missing remote mac address");
20528 errmsg ("missing sub-interface id");
20532 M (P2P_ETHERNET_ADD, mp);
20533 mp->parent_if_index = ntohl (parent_if_index);
20534 mp->subif_id = ntohl (sub_id);
20535 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20543 api_p2p_ethernet_del (vat_main_t * vam)
20545 unformat_input_t *i = vam->input;
20546 vl_api_p2p_ethernet_del_t *mp;
20547 u32 parent_if_index = ~0;
20552 clib_memset (remote_mac, 0, sizeof (remote_mac));
20553 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20555 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20557 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20561 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20565 clib_warning ("parse error '%U'", format_unformat_error, i);
20570 if (parent_if_index == ~0)
20572 errmsg ("missing interface name or sw_if_index");
20577 errmsg ("missing remote mac address");
20581 M (P2P_ETHERNET_DEL, mp);
20582 mp->parent_if_index = ntohl (parent_if_index);
20583 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20591 api_lldp_config (vat_main_t * vam)
20593 unformat_input_t *i = vam->input;
20594 vl_api_lldp_config_t *mp;
20596 int tx_interval = 0;
20597 u8 *sys_name = NULL;
20600 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20602 if (unformat (i, "system-name %s", &sys_name))
20604 else if (unformat (i, "tx-hold %d", &tx_hold))
20606 else if (unformat (i, "tx-interval %d", &tx_interval))
20610 clib_warning ("parse error '%U'", format_unformat_error, i);
20615 vec_add1 (sys_name, 0);
20617 M (LLDP_CONFIG, mp);
20618 mp->tx_hold = htonl (tx_hold);
20619 mp->tx_interval = htonl (tx_interval);
20620 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
20621 vec_free (sys_name);
20629 api_sw_interface_set_lldp (vat_main_t * vam)
20631 unformat_input_t *i = vam->input;
20632 vl_api_sw_interface_set_lldp_t *mp;
20633 u32 sw_if_index = ~0;
20635 u8 *port_desc = NULL, *mgmt_oid = NULL;
20636 ip4_address_t ip4_addr;
20637 ip6_address_t ip6_addr;
20640 clib_memset (&ip4_addr, 0, sizeof (ip4_addr));
20641 clib_memset (&ip6_addr, 0, sizeof (ip6_addr));
20643 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20645 if (unformat (i, "disable"))
20648 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20650 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20652 else if (unformat (i, "port-desc %s", &port_desc))
20654 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
20656 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
20658 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
20664 if (sw_if_index == ~0)
20666 errmsg ("missing interface name or sw_if_index");
20670 /* Construct the API message */
20671 vec_add1 (port_desc, 0);
20672 vec_add1 (mgmt_oid, 0);
20673 M (SW_INTERFACE_SET_LLDP, mp);
20674 mp->sw_if_index = ntohl (sw_if_index);
20675 mp->enable = enable;
20676 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
20677 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
20678 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
20679 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
20680 vec_free (port_desc);
20681 vec_free (mgmt_oid);
20689 api_tcp_configure_src_addresses (vat_main_t * vam)
20691 vl_api_tcp_configure_src_addresses_t *mp;
20692 unformat_input_t *i = vam->input;
20693 ip4_address_t v4first, v4last;
20694 ip6_address_t v6first, v6last;
20699 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20701 if (unformat (i, "%U - %U",
20702 unformat_ip4_address, &v4first,
20703 unformat_ip4_address, &v4last))
20707 errmsg ("one range per message (range already set)");
20712 else if (unformat (i, "%U - %U",
20713 unformat_ip6_address, &v6first,
20714 unformat_ip6_address, &v6last))
20718 errmsg ("one range per message (range already set)");
20723 else if (unformat (i, "vrf %d", &vrf_id))
20729 if (range_set == 0)
20731 errmsg ("address range not set");
20735 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
20736 mp->vrf_id = ntohl (vrf_id);
20738 if (range_set == 2)
20741 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
20742 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
20747 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
20748 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
20755 static void vl_api_app_namespace_add_del_reply_t_handler
20756 (vl_api_app_namespace_add_del_reply_t * mp)
20758 vat_main_t *vam = &vat_main;
20759 i32 retval = ntohl (mp->retval);
20760 if (vam->async_mode)
20762 vam->async_errors += (retval < 0);
20766 vam->retval = retval;
20768 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
20769 vam->result_ready = 1;
20773 static void vl_api_app_namespace_add_del_reply_t_handler_json
20774 (vl_api_app_namespace_add_del_reply_t * mp)
20776 vat_main_t *vam = &vat_main;
20777 vat_json_node_t node;
20779 vat_json_init_object (&node);
20780 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
20781 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
20783 vat_json_print (vam->ofp, &node);
20784 vat_json_free (&node);
20786 vam->retval = ntohl (mp->retval);
20787 vam->result_ready = 1;
20791 api_app_namespace_add_del (vat_main_t * vam)
20793 vl_api_app_namespace_add_del_t *mp;
20794 unformat_input_t *i = vam->input;
20795 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
20796 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
20800 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20802 if (unformat (i, "id %_%v%_", &ns_id))
20804 else if (unformat (i, "secret %lu", &secret))
20806 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20807 sw_if_index_set = 1;
20808 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
20810 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
20815 if (!ns_id || !secret_set || !sw_if_index_set)
20817 errmsg ("namespace id, secret and sw_if_index must be set");
20820 if (vec_len (ns_id) > 64)
20822 errmsg ("namespace id too long");
20825 M (APP_NAMESPACE_ADD_DEL, mp);
20827 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
20828 mp->namespace_id_len = vec_len (ns_id);
20829 mp->secret = clib_host_to_net_u64 (secret);
20830 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
20831 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
20832 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
20840 api_sock_init_shm (vat_main_t * vam)
20842 #if VPP_API_TEST_BUILTIN == 0
20843 unformat_input_t *i = vam->input;
20844 vl_api_shm_elem_config_t *config = 0;
20845 u64 size = 64 << 20;
20848 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20850 if (unformat (i, "size %U", unformat_memory_size, &size))
20857 * Canned custom ring allocator config.
20858 * Should probably parse all of this
20860 vec_validate (config, 6);
20861 config[0].type = VL_API_VLIB_RING;
20862 config[0].size = 256;
20863 config[0].count = 32;
20865 config[1].type = VL_API_VLIB_RING;
20866 config[1].size = 1024;
20867 config[1].count = 16;
20869 config[2].type = VL_API_VLIB_RING;
20870 config[2].size = 4096;
20871 config[2].count = 2;
20873 config[3].type = VL_API_CLIENT_RING;
20874 config[3].size = 256;
20875 config[3].count = 32;
20877 config[4].type = VL_API_CLIENT_RING;
20878 config[4].size = 1024;
20879 config[4].count = 16;
20881 config[5].type = VL_API_CLIENT_RING;
20882 config[5].size = 4096;
20883 config[5].count = 2;
20885 config[6].type = VL_API_QUEUE;
20886 config[6].count = 128;
20887 config[6].size = sizeof (uword);
20889 rv = vl_socket_client_init_shm (config, 1 /* want_pthread */ );
20891 vam->client_index_invalid = 1;
20899 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
20901 vat_main_t *vam = &vat_main;
20906 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
20907 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
20908 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
20909 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
20910 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
20911 clib_net_to_host_u32 (mp->action_index), mp->tag);
20916 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
20917 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
20918 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
20919 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
20920 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
20921 clib_net_to_host_u32 (mp->action_index), mp->tag);
20926 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
20929 vat_main_t *vam = &vat_main;
20930 vat_json_node_t *node = NULL;
20931 struct in6_addr ip6;
20932 struct in_addr ip4;
20934 if (VAT_JSON_ARRAY != vam->json_tree.type)
20936 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20937 vat_json_init_array (&vam->json_tree);
20939 node = vat_json_array_add (&vam->json_tree);
20940 vat_json_init_object (node);
20942 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
20943 vat_json_object_add_uint (node, "appns_index",
20944 clib_net_to_host_u32 (mp->appns_index));
20945 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
20946 vat_json_object_add_uint (node, "scope", mp->scope);
20947 vat_json_object_add_uint (node, "action_index",
20948 clib_net_to_host_u32 (mp->action_index));
20949 vat_json_object_add_uint (node, "lcl_port",
20950 clib_net_to_host_u16 (mp->lcl_port));
20951 vat_json_object_add_uint (node, "rmt_port",
20952 clib_net_to_host_u16 (mp->rmt_port));
20953 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
20954 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
20955 vat_json_object_add_string_copy (node, "tag", mp->tag);
20958 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
20959 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
20960 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
20961 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
20965 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
20966 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
20967 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
20968 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
20973 api_session_rule_add_del (vat_main_t * vam)
20975 vl_api_session_rule_add_del_t *mp;
20976 unformat_input_t *i = vam->input;
20977 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
20978 u32 appns_index = 0, scope = 0;
20979 ip4_address_t lcl_ip4, rmt_ip4;
20980 ip6_address_t lcl_ip6, rmt_ip6;
20981 u8 is_ip4 = 1, conn_set = 0;
20982 u8 is_add = 1, *tag = 0;
20985 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20987 if (unformat (i, "del"))
20989 else if (unformat (i, "add"))
20991 else if (unformat (i, "proto tcp"))
20993 else if (unformat (i, "proto udp"))
20995 else if (unformat (i, "appns %d", &appns_index))
20997 else if (unformat (i, "scope %d", &scope))
20999 else if (unformat (i, "tag %_%v%_", &tag))
21003 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
21004 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
21012 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
21013 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
21019 else if (unformat (i, "action %d", &action))
21024 if (proto == ~0 || !conn_set || action == ~0)
21026 errmsg ("transport proto, connection and action must be set");
21032 errmsg ("scope should be 0-3");
21036 M (SESSION_RULE_ADD_DEL, mp);
21038 mp->is_ip4 = is_ip4;
21039 mp->transport_proto = proto;
21040 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
21041 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
21042 mp->lcl_plen = lcl_plen;
21043 mp->rmt_plen = rmt_plen;
21044 mp->action_index = clib_host_to_net_u32 (action);
21045 mp->appns_index = clib_host_to_net_u32 (appns_index);
21047 mp->is_add = is_add;
21050 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
21051 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
21055 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
21056 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
21060 clib_memcpy (mp->tag, tag, vec_len (tag));
21070 api_session_rules_dump (vat_main_t * vam)
21072 vl_api_session_rules_dump_t *mp;
21073 vl_api_control_ping_t *mp_ping;
21076 if (!vam->json_output)
21078 print (vam->ofp, "%=20s", "Session Rules");
21081 M (SESSION_RULES_DUMP, mp);
21085 /* Use a control ping for synchronization */
21086 MPING (CONTROL_PING, mp_ping);
21089 /* Wait for a reply... */
21095 api_ip_container_proxy_add_del (vat_main_t * vam)
21097 vl_api_ip_container_proxy_add_del_t *mp;
21098 unformat_input_t *i = vam->input;
21099 u32 sw_if_index = ~0;
21100 vl_api_prefix_t pfx = { };
21104 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21106 if (unformat (i, "del"))
21108 else if (unformat (i, "add"))
21110 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
21112 else if (unformat (i, "sw_if_index %u", &sw_if_index))
21117 if (sw_if_index == ~0 || pfx.len == 0)
21119 errmsg ("address and sw_if_index must be set");
21123 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
21125 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
21126 mp->is_add = is_add;
21127 clib_memcpy (&mp->pfx, &pfx, sizeof (pfx));
21135 api_qos_record_enable_disable (vat_main_t * vam)
21137 unformat_input_t *i = vam->input;
21138 vl_api_qos_record_enable_disable_t *mp;
21139 u32 sw_if_index, qs = 0xff;
21140 u8 sw_if_index_set = 0;
21144 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21146 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21147 sw_if_index_set = 1;
21148 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21149 sw_if_index_set = 1;
21150 else if (unformat (i, "%U", unformat_qos_source, &qs))
21152 else if (unformat (i, "disable"))
21156 clib_warning ("parse error '%U'", format_unformat_error, i);
21161 if (sw_if_index_set == 0)
21163 errmsg ("missing interface name or sw_if_index");
21168 errmsg ("input location must be specified");
21172 M (QOS_RECORD_ENABLE_DISABLE, mp);
21174 mp->record.sw_if_index = ntohl (sw_if_index);
21175 mp->record.input_source = qs;
21176 mp->enable = enable;
21185 q_or_quit (vat_main_t * vam)
21187 #if VPP_API_TEST_BUILTIN == 0
21188 longjmp (vam->jump_buf, 1);
21190 return 0; /* not so much */
21194 q (vat_main_t * vam)
21196 return q_or_quit (vam);
21200 quit (vat_main_t * vam)
21202 return q_or_quit (vam);
21206 comment (vat_main_t * vam)
21212 elog_save (vat_main_t * vam)
21214 #if VPP_API_TEST_BUILTIN == 0
21215 elog_main_t *em = &vam->elog_main;
21216 unformat_input_t *i = vam->input;
21217 char *file, *chroot_file;
21218 clib_error_t *error;
21220 if (!unformat (i, "%s", &file))
21222 errmsg ("expected file name, got `%U'", format_unformat_error, i);
21226 /* It's fairly hard to get "../oopsie" through unformat; just in case */
21227 if (strstr (file, "..") || index (file, '/'))
21229 errmsg ("illegal characters in filename '%s'", file);
21233 chroot_file = (char *) format (0, "/tmp/%s%c", file, 0);
21237 errmsg ("Saving %wd of %wd events to %s",
21238 elog_n_events_in_buffer (em),
21239 elog_buffer_capacity (em), chroot_file);
21241 error = elog_write_file (em, chroot_file, 1 /* flush ring */ );
21242 vec_free (chroot_file);
21245 clib_error_report (error);
21247 errmsg ("Use the vpp event loger...");
21254 elog_setup (vat_main_t * vam)
21256 #if VPP_API_TEST_BUILTIN == 0
21257 elog_main_t *em = &vam->elog_main;
21258 unformat_input_t *i = vam->input;
21259 u32 nevents = 128 << 10;
21261 (void) unformat (i, "nevents %d", &nevents);
21263 elog_init (em, nevents);
21264 vl_api_set_elog_main (em);
21265 vl_api_set_elog_trace_api_messages (1);
21266 errmsg ("Event logger initialized with %u events", nevents);
21268 errmsg ("Use the vpp event loger...");
21274 elog_enable (vat_main_t * vam)
21276 #if VPP_API_TEST_BUILTIN == 0
21277 elog_main_t *em = &vam->elog_main;
21279 elog_enable_disable (em, 1 /* enable */ );
21280 vl_api_set_elog_trace_api_messages (1);
21281 errmsg ("Event logger enabled...");
21283 errmsg ("Use the vpp event loger...");
21289 elog_disable (vat_main_t * vam)
21291 #if VPP_API_TEST_BUILTIN == 0
21292 elog_main_t *em = &vam->elog_main;
21294 elog_enable_disable (em, 0 /* enable */ );
21295 vl_api_set_elog_trace_api_messages (1);
21296 errmsg ("Event logger disabled...");
21298 errmsg ("Use the vpp event loger...");
21304 statseg (vat_main_t * vam)
21306 ssvm_private_t *ssvmp = &vam->stat_segment;
21307 ssvm_shared_header_t *shared_header = ssvmp->sh;
21308 vlib_counter_t **counters;
21309 u64 thread0_index1_packets;
21310 u64 thread0_index1_bytes;
21311 f64 vector_rate, input_rate;
21314 uword *counter_vector_by_name;
21315 if (vam->stat_segment_lockp == 0)
21317 errmsg ("Stat segment not mapped...");
21321 /* look up "/if/rx for sw_if_index 1 as a test */
21323 clib_spinlock_lock (vam->stat_segment_lockp);
21325 counter_vector_by_name = (uword *) shared_header->opaque[1];
21327 p = hash_get_mem (counter_vector_by_name, "/if/rx");
21330 clib_spinlock_unlock (vam->stat_segment_lockp);
21331 errmsg ("/if/tx not found?");
21335 /* Fish per-thread vector of combined counters from shared memory */
21336 counters = (vlib_counter_t **) p[0];
21338 if (vec_len (counters[0]) < 2)
21340 clib_spinlock_unlock (vam->stat_segment_lockp);
21341 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
21345 /* Read thread 0 sw_if_index 1 counter */
21346 thread0_index1_packets = counters[0][1].packets;
21347 thread0_index1_bytes = counters[0][1].bytes;
21349 p = hash_get_mem (counter_vector_by_name, "vector_rate");
21352 clib_spinlock_unlock (vam->stat_segment_lockp);
21353 errmsg ("vector_rate not found?");
21357 vector_rate = *(f64 *) (p[0]);
21358 p = hash_get_mem (counter_vector_by_name, "input_rate");
21361 clib_spinlock_unlock (vam->stat_segment_lockp);
21362 errmsg ("input_rate not found?");
21365 input_rate = *(f64 *) (p[0]);
21367 clib_spinlock_unlock (vam->stat_segment_lockp);
21369 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
21370 vector_rate, input_rate);
21371 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
21372 thread0_index1_packets, thread0_index1_bytes);
21378 cmd_cmp (void *a1, void *a2)
21383 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
21387 help (vat_main_t * vam)
21392 unformat_input_t *i = vam->input;
21395 if (unformat (i, "%s", &name))
21399 vec_add1 (name, 0);
21401 hs = hash_get_mem (vam->help_by_name, name);
21403 print (vam->ofp, "usage: %s %s", name, hs[0]);
21405 print (vam->ofp, "No such msg / command '%s'", name);
21410 print (vam->ofp, "Help is available for the following:");
21413 hash_foreach_pair (p, vam->function_by_name,
21415 vec_add1 (cmds, (u8 *)(p->key));
21419 vec_sort_with_function (cmds, cmd_cmp);
21421 for (j = 0; j < vec_len (cmds); j++)
21422 print (vam->ofp, "%s", cmds[j]);
21429 set (vat_main_t * vam)
21431 u8 *name = 0, *value = 0;
21432 unformat_input_t *i = vam->input;
21434 if (unformat (i, "%s", &name))
21436 /* The input buffer is a vector, not a string. */
21437 value = vec_dup (i->buffer);
21438 vec_delete (value, i->index, 0);
21439 /* Almost certainly has a trailing newline */
21440 if (value[vec_len (value) - 1] == '\n')
21441 value[vec_len (value) - 1] = 0;
21442 /* Make sure it's a proper string, one way or the other */
21443 vec_add1 (value, 0);
21444 (void) clib_macro_set_value (&vam->macro_main,
21445 (char *) name, (char *) value);
21448 errmsg ("usage: set <name> <value>");
21456 unset (vat_main_t * vam)
21460 if (unformat (vam->input, "%s", &name))
21461 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
21462 errmsg ("unset: %s wasn't set", name);
21475 macro_sort_cmp (void *a1, void *a2)
21477 macro_sort_t *s1 = a1;
21478 macro_sort_t *s2 = a2;
21480 return strcmp ((char *) (s1->name), (char *) (s2->name));
21484 dump_macro_table (vat_main_t * vam)
21486 macro_sort_t *sort_me = 0, *sm;
21491 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
21493 vec_add2 (sort_me, sm, 1);
21494 sm->name = (u8 *)(p->key);
21495 sm->value = (u8 *) (p->value[0]);
21499 vec_sort_with_function (sort_me, macro_sort_cmp);
21501 if (vec_len (sort_me))
21502 print (vam->ofp, "%-15s%s", "Name", "Value");
21504 print (vam->ofp, "The macro table is empty...");
21506 for (i = 0; i < vec_len (sort_me); i++)
21507 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
21512 dump_node_table (vat_main_t * vam)
21515 vlib_node_t *node, *next_node;
21517 if (vec_len (vam->graph_nodes) == 0)
21519 print (vam->ofp, "Node table empty, issue get_node_graph...");
21523 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
21525 node = vam->graph_nodes[0][i];
21526 print (vam->ofp, "[%d] %s", i, node->name);
21527 for (j = 0; j < vec_len (node->next_nodes); j++)
21529 if (node->next_nodes[j] != ~0)
21531 next_node = vam->graph_nodes[0][node->next_nodes[j]];
21532 print (vam->ofp, " [%d] %s", j, next_node->name);
21540 value_sort_cmp (void *a1, void *a2)
21542 name_sort_t *n1 = a1;
21543 name_sort_t *n2 = a2;
21545 if (n1->value < n2->value)
21547 if (n1->value > n2->value)
21554 dump_msg_api_table (vat_main_t * vam)
21556 api_main_t *am = &api_main;
21557 name_sort_t *nses = 0, *ns;
21562 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
21564 vec_add2 (nses, ns, 1);
21565 ns->name = (u8 *)(hp->key);
21566 ns->value = (u32) hp->value[0];
21570 vec_sort_with_function (nses, value_sort_cmp);
21572 for (i = 0; i < vec_len (nses); i++)
21573 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
21579 get_msg_id (vat_main_t * vam)
21584 if (unformat (vam->input, "%s", &name_and_crc))
21586 message_index = vl_msg_api_get_msg_index (name_and_crc);
21587 if (message_index == ~0)
21589 print (vam->ofp, " '%s' not found", name_and_crc);
21592 print (vam->ofp, " '%s' has message index %d",
21593 name_and_crc, message_index);
21596 errmsg ("name_and_crc required...");
21601 search_node_table (vat_main_t * vam)
21603 unformat_input_t *line_input = vam->input;
21606 vlib_node_t *node, *next_node;
21609 if (vam->graph_node_index_by_name == 0)
21611 print (vam->ofp, "Node table empty, issue get_node_graph...");
21615 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21617 if (unformat (line_input, "%s", &node_to_find))
21619 vec_add1 (node_to_find, 0);
21620 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
21623 print (vam->ofp, "%s not found...", node_to_find);
21626 node = vam->graph_nodes[0][p[0]];
21627 print (vam->ofp, "[%d] %s", p[0], node->name);
21628 for (j = 0; j < vec_len (node->next_nodes); j++)
21630 if (node->next_nodes[j] != ~0)
21632 next_node = vam->graph_nodes[0][node->next_nodes[j]];
21633 print (vam->ofp, " [%d] %s", j, next_node->name);
21640 clib_warning ("parse error '%U'", format_unformat_error,
21646 vec_free (node_to_find);
21655 script (vat_main_t * vam)
21657 #if (VPP_API_TEST_BUILTIN==0)
21659 char *save_current_file;
21660 unformat_input_t save_input;
21661 jmp_buf save_jump_buf;
21662 u32 save_line_number;
21664 FILE *new_fp, *save_ifp;
21666 if (unformat (vam->input, "%s", &s))
21668 new_fp = fopen ((char *) s, "r");
21671 errmsg ("Couldn't open script file %s", s);
21678 errmsg ("Missing script name");
21682 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
21683 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
21684 save_ifp = vam->ifp;
21685 save_line_number = vam->input_line_number;
21686 save_current_file = (char *) vam->current_file;
21688 vam->input_line_number = 0;
21690 vam->current_file = s;
21693 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
21694 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
21695 vam->ifp = save_ifp;
21696 vam->input_line_number = save_line_number;
21697 vam->current_file = (u8 *) save_current_file;
21702 clib_warning ("use the exec command...");
21708 echo (vat_main_t * vam)
21710 print (vam->ofp, "%v", vam->input->buffer);
21714 /* List of API message constructors, CLI names map to api_xxx */
21715 #define foreach_vpe_api_msg \
21716 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
21717 _(sw_interface_dump,"") \
21718 _(sw_interface_set_flags, \
21719 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
21720 _(sw_interface_add_del_address, \
21721 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
21722 _(sw_interface_set_rx_mode, \
21723 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
21724 _(sw_interface_set_rx_placement, \
21725 "<intfc> | sw_if_index <id> [queue <id>] [worker <id> | main]") \
21726 _(sw_interface_rx_placement_dump, \
21727 "[<intfc> | sw_if_index <id>]") \
21728 _(sw_interface_set_table, \
21729 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
21730 _(sw_interface_set_mpls_enable, \
21731 "<intfc> | sw_if_index [disable | dis]") \
21732 _(sw_interface_set_vpath, \
21733 "<intfc> | sw_if_index <id> enable | disable") \
21734 _(sw_interface_set_vxlan_bypass, \
21735 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21736 _(sw_interface_set_geneve_bypass, \
21737 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21738 _(sw_interface_set_l2_xconnect, \
21739 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
21740 "enable | disable") \
21741 _(sw_interface_set_l2_bridge, \
21742 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
21743 "[shg <split-horizon-group>] [bvi]\n" \
21744 "enable | disable") \
21745 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
21746 _(bridge_domain_add_del, \
21747 "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") \
21748 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
21750 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
21751 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
21752 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
21754 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21756 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21758 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>] [host-mtu-size <mtu>] [gso | no-gso]") \
21760 "<vpp-if-name> | sw_if_index <id>") \
21761 _(sw_interface_tap_v2_dump, "") \
21762 _(virtio_pci_create, \
21763 "pci-addr <pci-address> [use_random_mac | hw-addr <mac-addr>] [features <hex-value>] [gso-enabled]") \
21764 _(virtio_pci_delete, \
21765 "<vpp-if-name> | sw_if_index <id>") \
21766 _(sw_interface_virtio_pci_dump, "") \
21768 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
21769 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \
21772 "<vpp-if-name> | sw_if_index <id>") \
21774 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
21775 _(bond_detach_slave, \
21776 "sw_if_index <n>") \
21777 _(sw_interface_set_bond_weight, "<intfc> | sw_if_index <nn> weight <value>") \
21778 _(sw_interface_bond_dump, "") \
21779 _(sw_interface_slave_dump, \
21780 "<vpp-if-name> | sw_if_index <id>") \
21781 _(ip_table_add_del, \
21782 "table <n> [ipv6] [add | del]\n") \
21783 _(ip_route_add_del, \
21784 "<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
21785 "[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
21786 "[weight <n>] [drop] [local] [classify <n>] [out-label <n>]\n" \
21787 "[multipath] [count <n>] [del]") \
21788 _(ip_mroute_add_del, \
21789 "<src> <grp>/<mask> [table-id <n>]\n" \
21790 "[<intfc> | sw_if_index <id>] [local] [del]") \
21791 _(mpls_table_add_del, \
21792 "table <n> [add | del]\n") \
21793 _(mpls_route_add_del, \
21794 "<label> <eos> via <addr | next-hop-table <n> | via-label <n> |\n" \
21795 "lookup-ip4-table <n> | lookup-in-ip6-table <n> |\n" \
21796 "l2-input-on <intfc> | l2-input-on sw_if_index <id>>\n" \
21797 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>] [weight <n>]\n" \
21798 "[drop] [local] [classify <n>] [out-label <n>] [multipath]\n" \
21799 "[count <n>] [del]") \
21800 _(mpls_ip_bind_unbind, \
21801 "<label> <addr/len>") \
21802 _(mpls_tunnel_add_del, \
21803 "[add | del <intfc | sw_if_index <id>>] via <addr | via-label <n>>\n" \
21804 "[<intfc> | sw_if_index <id> | next-hop-table <id>]\n" \
21805 "[l2-only] [out-label <n>]") \
21806 _(sr_mpls_policy_add, \
21807 "bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
21808 _(sr_mpls_policy_del, \
21810 _(bier_table_add_del, \
21811 "<label> <sub-domain> <set> <bsl> [del]") \
21812 _(bier_route_add_del, \
21813 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
21814 "[<intfc> | sw_if_index <id>]" \
21815 "[weight <n>] [del] [multipath]") \
21816 _(proxy_arp_add_del, \
21817 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
21818 _(proxy_arp_intfc_enable_disable, \
21819 "<intfc> | sw_if_index <id> enable | disable") \
21820 _(sw_interface_set_unnumbered, \
21821 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
21822 _(ip_neighbor_add_del, \
21823 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
21824 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
21825 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
21826 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
21827 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
21828 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
21829 "[outer_vlan_id_any][inner_vlan_id_any]") \
21830 _(reset_fib, "vrf <n> [ipv6]") \
21831 _(dhcp_proxy_config, \
21832 "svr <v46-address> src <v46-address>\n" \
21833 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
21834 _(dhcp_proxy_set_vss, \
21835 "tbl_id <n> [fib_id <n> oui <n> | vpn_ascii_id <text>] [ipv6] [del]") \
21836 _(dhcp_proxy_dump, "ip6") \
21837 _(dhcp_client_config, \
21838 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
21839 _(set_ip_flow_hash, \
21840 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
21841 _(sw_interface_ip6_enable_disable, \
21842 "<intfc> | sw_if_index <id> enable | disable") \
21843 _(ip6nd_proxy_add_del, \
21844 "<intfc> | sw_if_index <id> <ip6-address>") \
21845 _(ip6nd_proxy_dump, "") \
21846 _(sw_interface_ip6nd_ra_prefix, \
21847 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
21848 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
21849 "[nolink] [isno]") \
21850 _(sw_interface_ip6nd_ra_config, \
21851 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
21852 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
21853 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
21854 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
21855 _(l2_patch_add_del, \
21856 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
21857 "enable | disable") \
21858 _(sr_localsid_add_del, \
21859 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
21860 "fib-table <num> (end.psp) sw_if_index <num>") \
21861 _(classify_add_del_table, \
21862 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
21863 " [del] [del-chain] mask <mask-value>\n" \
21864 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
21865 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
21866 _(classify_add_del_session, \
21867 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
21868 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
21869 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
21870 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
21871 _(classify_set_interface_ip_table, \
21872 "<intfc> | sw_if_index <nn> table <nn>") \
21873 _(classify_set_interface_l2_tables, \
21874 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21875 " [other-table <nn>]") \
21876 _(get_node_index, "node <node-name") \
21877 _(add_node_next, "node <node-name> next <next-node-name>") \
21878 _(l2tpv3_create_tunnel, \
21879 "client_address <ip6-addr> our_address <ip6-addr>\n" \
21880 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
21881 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
21882 _(l2tpv3_set_tunnel_cookies, \
21883 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
21884 "[new_remote_cookie <nn>]\n") \
21885 _(l2tpv3_interface_enable_disable, \
21886 "<intfc> | sw_if_index <nn> enable | disable") \
21887 _(l2tpv3_set_lookup_key, \
21888 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
21889 _(sw_if_l2tpv3_tunnel_dump, "") \
21890 _(vxlan_offload_rx, \
21891 "hw { <interface name> | hw_if_index <nn>} " \
21892 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
21893 _(vxlan_add_del_tunnel, \
21894 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
21895 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
21896 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
21897 _(geneve_add_del_tunnel, \
21898 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
21899 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21900 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
21901 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21902 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21903 _(gre_tunnel_add_del, \
21904 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
21905 "[teb | erspan <session-id>] [del]") \
21906 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21907 _(l2_fib_clear_table, "") \
21908 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
21909 _(l2_interface_vlan_tag_rewrite, \
21910 "<intfc> | sw_if_index <nn> \n" \
21911 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
21912 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
21913 _(create_vhost_user_if, \
21914 "socket <filename> [server] [renumber <dev_instance>] " \
21915 "[disable_mrg_rxbuf] [disable_indirect_desc] [gso] " \
21916 "[mac <mac_address>]") \
21917 _(modify_vhost_user_if, \
21918 "<intfc> | sw_if_index <nn> socket <filename>\n" \
21919 "[server] [renumber <dev_instance>] [gso]") \
21920 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
21921 _(sw_interface_vhost_user_dump, "") \
21922 _(show_version, "") \
21923 _(show_threads, "") \
21924 _(vxlan_gpe_add_del_tunnel, \
21925 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
21926 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21927 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
21928 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
21929 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21930 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
21931 _(interface_name_renumber, \
21932 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
21933 _(input_acl_set_interface, \
21934 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21935 " [l2-table <nn>] [del]") \
21936 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
21937 _(ip_scan_neighbor_enable_disable, "[ip4|ip6|both|disable] [interval <n-min>]\n" \
21938 " [max-time <n-usec>] [max-update <n>] [delay <n-msec>] [stale <n-min>]") \
21939 _(want_ip4_arp_events, "address <ip4-address> [del]") \
21940 _(want_ip6_nd_events, "address <ip6-address> [del]") \
21941 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
21942 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
21943 _(ip_dump, "ipv4 | ipv6") \
21944 _(ipsec_spd_add_del, "spd_id <n> [del]") \
21945 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
21947 _(ipsec_sad_entry_add_del, "sad_id <n> spi <n> crypto_alg <alg>\n" \
21948 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
21949 " integ_alg <alg> integ_key <hex>") \
21950 _(ipsec_spd_entry_add_del, "spd_id <n> priority <n> action <action>\n" \
21951 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
21952 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
21953 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
21954 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
21955 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
21956 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
21957 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
21958 " [instance <n>]") \
21959 _(ipsec_sa_dump, "[sa_id <n>]") \
21960 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
21961 _(delete_loopback,"sw_if_index <nn>") \
21962 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
21963 _(bd_ip_mac_flush, "bd_id <bridge-domain-id>") \
21964 _(bd_ip_mac_dump, "[bd_id] <bridge-domain-id>") \
21965 _(want_interface_events, "enable|disable") \
21966 _(get_first_msg_id, "client <name>") \
21967 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
21968 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
21969 "fib-id <nn> [ip4][ip6][default]") \
21970 _(get_node_graph, " ") \
21971 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
21972 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
21973 _(ioam_disable, "") \
21974 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
21975 " sw_if_index <sw_if_index> p <priority> " \
21976 "w <weight>] [del]") \
21977 _(one_add_del_locator, "locator-set <locator_name> " \
21978 "iface <intf> | sw_if_index <sw_if_index> " \
21979 "p <priority> w <weight> [del]") \
21980 _(one_add_del_local_eid,"vni <vni> eid " \
21981 "<ipv4|ipv6>/<prefix> | <L2 address> " \
21982 "locator-set <locator_name> [del]" \
21983 "[key-id sha1|sha256 secret-key <secret-key>]")\
21984 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
21985 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
21986 _(one_enable_disable, "enable|disable") \
21987 _(one_map_register_enable_disable, "enable|disable") \
21988 _(one_map_register_fallback_threshold, "<value>") \
21989 _(one_rloc_probe_enable_disable, "enable|disable") \
21990 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
21992 "rloc <locator> p <prio> " \
21993 "w <weight> [rloc <loc> ... ] " \
21994 "action <action> [del-all]") \
21995 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
21997 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
21998 _(one_use_petr, "ip-address> | disable") \
21999 _(one_map_request_mode, "src-dst|dst-only") \
22000 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
22001 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
22002 _(one_locator_set_dump, "[local | remote]") \
22003 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
22004 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
22005 "[local] | [remote]") \
22006 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
22007 _(one_ndp_bd_get, "") \
22008 _(one_ndp_entries_get, "bd <bridge-domain>") \
22009 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
22010 _(one_l2_arp_bd_get, "") \
22011 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
22012 _(one_stats_enable_disable, "enable|disable") \
22013 _(show_one_stats_enable_disable, "") \
22014 _(one_eid_table_vni_dump, "") \
22015 _(one_eid_table_map_dump, "l2|l3") \
22016 _(one_map_resolver_dump, "") \
22017 _(one_map_server_dump, "") \
22018 _(one_adjacencies_get, "vni <vni>") \
22019 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
22020 _(show_one_rloc_probe_state, "") \
22021 _(show_one_map_register_state, "") \
22022 _(show_one_status, "") \
22023 _(one_stats_dump, "") \
22024 _(one_stats_flush, "") \
22025 _(one_get_map_request_itr_rlocs, "") \
22026 _(one_map_register_set_ttl, "<ttl>") \
22027 _(one_set_transport_protocol, "udp|api") \
22028 _(one_get_transport_protocol, "") \
22029 _(one_enable_disable_xtr_mode, "enable|disable") \
22030 _(one_show_xtr_mode, "") \
22031 _(one_enable_disable_pitr_mode, "enable|disable") \
22032 _(one_show_pitr_mode, "") \
22033 _(one_enable_disable_petr_mode, "enable|disable") \
22034 _(one_show_petr_mode, "") \
22035 _(show_one_nsh_mapping, "") \
22036 _(show_one_pitr, "") \
22037 _(show_one_use_petr, "") \
22038 _(show_one_map_request_mode, "") \
22039 _(show_one_map_register_ttl, "") \
22040 _(show_one_map_register_fallback_threshold, "") \
22041 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
22042 " sw_if_index <sw_if_index> p <priority> " \
22043 "w <weight>] [del]") \
22044 _(lisp_add_del_locator, "locator-set <locator_name> " \
22045 "iface <intf> | sw_if_index <sw_if_index> " \
22046 "p <priority> w <weight> [del]") \
22047 _(lisp_add_del_local_eid,"vni <vni> eid " \
22048 "<ipv4|ipv6>/<prefix> | <L2 address> " \
22049 "locator-set <locator_name> [del]" \
22050 "[key-id sha1|sha256 secret-key <secret-key>]") \
22051 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
22052 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
22053 _(lisp_enable_disable, "enable|disable") \
22054 _(lisp_map_register_enable_disable, "enable|disable") \
22055 _(lisp_rloc_probe_enable_disable, "enable|disable") \
22056 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
22058 "rloc <locator> p <prio> " \
22059 "w <weight> [rloc <loc> ... ] " \
22060 "action <action> [del-all]") \
22061 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
22063 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
22064 _(lisp_use_petr, "<ip-address> | disable") \
22065 _(lisp_map_request_mode, "src-dst|dst-only") \
22066 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
22067 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
22068 _(lisp_locator_set_dump, "[local | remote]") \
22069 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
22070 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
22071 "[local] | [remote]") \
22072 _(lisp_eid_table_vni_dump, "") \
22073 _(lisp_eid_table_map_dump, "l2|l3") \
22074 _(lisp_map_resolver_dump, "") \
22075 _(lisp_map_server_dump, "") \
22076 _(lisp_adjacencies_get, "vni <vni>") \
22077 _(gpe_fwd_entry_vnis_get, "") \
22078 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
22079 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
22080 "[table <table-id>]") \
22081 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
22082 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
22083 _(gpe_set_encap_mode, "lisp|vxlan") \
22084 _(gpe_get_encap_mode, "") \
22085 _(lisp_gpe_add_del_iface, "up|down") \
22086 _(lisp_gpe_enable_disable, "enable|disable") \
22087 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
22088 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
22089 _(show_lisp_rloc_probe_state, "") \
22090 _(show_lisp_map_register_state, "") \
22091 _(show_lisp_status, "") \
22092 _(lisp_get_map_request_itr_rlocs, "") \
22093 _(show_lisp_pitr, "") \
22094 _(show_lisp_use_petr, "") \
22095 _(show_lisp_map_request_mode, "") \
22096 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
22097 _(af_packet_delete, "name <host interface name>") \
22098 _(af_packet_dump, "") \
22099 _(policer_add_del, "name <policer name> <params> [del]") \
22100 _(policer_dump, "[name <policer name>]") \
22101 _(policer_classify_set_interface, \
22102 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22103 " [l2-table <nn>] [del]") \
22104 _(policer_classify_dump, "type [ip4|ip6|l2]") \
22105 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
22106 "[master|slave]") \
22107 _(netmap_delete, "name <interface name>") \
22108 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
22109 _(mpls_table_dump, "") \
22110 _(mpls_route_dump, "table-id <ID>") \
22111 _(classify_table_ids, "") \
22112 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
22113 _(classify_table_info, "table_id <nn>") \
22114 _(classify_session_dump, "table_id <nn>") \
22115 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
22116 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
22117 "[template_interval <nn>] [udp_checksum]") \
22118 _(ipfix_exporter_dump, "") \
22119 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
22120 _(ipfix_classify_stream_dump, "") \
22121 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
22122 _(ipfix_classify_table_dump, "") \
22123 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
22124 _(sw_interface_span_dump, "[l2]") \
22125 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
22126 _(pg_create_interface, "if_id <nn> [gso-enabled gso-size <size>]") \
22127 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
22128 _(pg_enable_disable, "[stream <id>] disable") \
22129 _(ip_source_and_port_range_check_add_del, \
22130 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
22131 _(ip_source_and_port_range_check_interface_add_del, \
22132 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
22133 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
22134 _(delete_subif,"<intfc> | sw_if_index <nn>") \
22135 _(l2_interface_pbb_tag_rewrite, \
22136 "<intfc> | sw_if_index <nn> \n" \
22137 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
22138 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
22139 _(set_punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
22140 _(flow_classify_set_interface, \
22141 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
22142 _(flow_classify_dump, "type [ip4|ip6]") \
22143 _(ip_table_dump, "") \
22144 _(ip_route_dump, "table-id [ip4|ip6]") \
22145 _(ip_mtable_dump, "") \
22146 _(ip_mroute_dump, "table-id [ip4|ip6]") \
22147 _(feature_enable_disable, "arc_name <arc_name> " \
22148 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
22149 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
22151 _(l2_xconnect_dump, "") \
22152 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
22153 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
22154 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
22155 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
22156 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
22157 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
22158 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
22159 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
22160 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
22161 _(sock_init_shm, "size <nnn>") \
22162 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
22163 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
22164 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
22165 _(session_rules_dump, "") \
22166 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
22167 _(output_acl_set_interface, \
22168 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22169 " [l2-table <nn>] [del]") \
22170 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
22172 /* List of command functions, CLI names map directly to functions */
22173 #define foreach_cli_function \
22174 _(comment, "usage: comment <ignore-rest-of-line>") \
22175 _(dump_interface_table, "usage: dump_interface_table") \
22176 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
22177 _(dump_ipv4_table, "usage: dump_ipv4_table") \
22178 _(dump_ipv6_table, "usage: dump_ipv6_table") \
22179 _(dump_macro_table, "usage: dump_macro_table ") \
22180 _(dump_node_table, "usage: dump_node_table") \
22181 _(dump_msg_api_table, "usage: dump_msg_api_table") \
22182 _(elog_setup, "usage: elog_setup [nevents, default 128K]") \
22183 _(elog_disable, "usage: elog_disable") \
22184 _(elog_enable, "usage: elog_enable") \
22185 _(elog_save, "usage: elog_save <filename>") \
22186 _(get_msg_id, "usage: get_msg_id name_and_crc") \
22187 _(echo, "usage: echo <message>") \
22188 _(exec, "usage: exec <vpe-debug-CLI-command>") \
22189 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
22190 _(help, "usage: help") \
22191 _(q, "usage: quit") \
22192 _(quit, "usage: quit") \
22193 _(search_node_table, "usage: search_node_table <name>...") \
22194 _(set, "usage: set <variable-name> <value>") \
22195 _(script, "usage: script <file-name>") \
22196 _(statseg, "usage: statseg") \
22197 _(unset, "usage: unset <variable-name>")
22200 static void vl_api_##n##_t_handler_uni \
22201 (vl_api_##n##_t * mp) \
22203 vat_main_t * vam = &vat_main; \
22204 if (vam->json_output) { \
22205 vl_api_##n##_t_handler_json(mp); \
22207 vl_api_##n##_t_handler(mp); \
22210 foreach_vpe_api_reply_msg;
22211 #if VPP_API_TEST_BUILTIN == 0
22212 foreach_standalone_reply_msg;
22217 vat_api_hookup (vat_main_t * vam)
22220 vl_msg_api_set_handlers(VL_API_##N, #n, \
22221 vl_api_##n##_t_handler_uni, \
22223 vl_api_##n##_t_endian, \
22224 vl_api_##n##_t_print, \
22225 sizeof(vl_api_##n##_t), 1);
22226 foreach_vpe_api_reply_msg;
22227 #if VPP_API_TEST_BUILTIN == 0
22228 foreach_standalone_reply_msg;
22232 #if (VPP_API_TEST_BUILTIN==0)
22233 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
22235 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
22237 vam->function_by_name = hash_create_string (0, sizeof (uword));
22239 vam->help_by_name = hash_create_string (0, sizeof (uword));
22242 /* API messages we can send */
22243 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
22244 foreach_vpe_api_msg;
22248 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
22249 foreach_vpe_api_msg;
22252 /* CLI functions */
22253 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
22254 foreach_cli_function;
22258 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
22259 foreach_cli_function;
22263 #if VPP_API_TEST_BUILTIN
22264 static clib_error_t *
22265 vat_api_hookup_shim (vlib_main_t * vm)
22267 vat_api_hookup (&vat_main);
22271 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
22275 * fd.io coding-style-patch-verification: ON
22278 * eval: (c-set-style "gnu")