2 *------------------------------------------------------------------
5 * Copyright (c) 2014-2020 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-neighbor/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/gre/gre.h>
33 #include <vnet/vxlan-gpe/vxlan_gpe.h>
34 #include <vnet/lisp-gpe/lisp_gpe.h>
36 #include <vpp/api/vpe_msg_enum.h>
37 #include <vnet/l2/l2_classify.h>
38 #include <vnet/l2/l2_vtr.h>
39 #include <vnet/classify/in_out_acl.h>
40 #include <vnet/classify/policer_classify.h>
41 #include <vnet/classify/flow_classify.h>
42 #include <vnet/mpls/mpls.h>
43 #include <vnet/ipsec/ipsec.h>
45 #include <vnet/ip/ip6_hop_by_hop.h>
46 #include <vnet/ip/ip_source_and_port_range_check.h>
47 #include <vnet/policer/xlate.h>
48 #include <vnet/span/span.h>
49 #include <vnet/policer/policer.h>
50 #include <vnet/policer/police.h>
51 #include <vnet/mfib/mfib_types.h>
52 #include <vnet/bonding/node.h>
53 #include <vnet/qos/qos_types.h>
54 #include <vnet/ethernet/ethernet_types_api.h>
55 #include <vnet/ip/ip_types_api.h>
56 #include "vat/json_format.h"
57 #include <vnet/ip/ip_types_api.h>
58 #include <vnet/ethernet/ethernet_types_api.h>
63 #define vl_typedefs /* define message structures */
64 #include <vpp/api/vpe_all_api_h.h>
67 /* declare message handlers for each api */
69 #define vl_endianfun /* define message structures */
70 #include <vpp/api/vpe_all_api_h.h>
73 /* instantiate all the print functions we know about */
74 #if VPP_API_TEST_BUILTIN == 0
75 #define vl_print(handle, ...)
77 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
80 #include <vpp/api/vpe_all_api_h.h>
83 #define __plugin_msg_base 0
84 #include <vlibapi/vat_helper_macros.h>
86 #include <vnet/format_fns.h>
88 void vl_api_set_elog_main (elog_main_t * m);
89 int vl_api_set_elog_trace_api_messages (int enable);
91 #if VPP_API_TEST_BUILTIN == 0
101 vat_socket_connect (vat_main_t * vam)
104 api_main_t *am = vlibapi_get_main ();
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 */ )))
111 /* vpp expects the client index in network order */
112 vam->my_client_index = htonl (socket_client_main.client_index);
113 am->my_client_index = vam->my_client_index;
116 #else /* vpp built-in case, we don't do sockets... */
118 vat_socket_connect (vat_main_t * vam)
124 vl_socket_client_read (int wait)
130 vl_socket_client_write ()
136 vl_socket_client_msg_alloc (int nbytes)
144 vat_time_now (vat_main_t * vam)
146 #if VPP_API_TEST_BUILTIN
147 return vlib_time_now (vam->vlib_main);
149 return clib_time_now (&vam->clib_time);
154 errmsg (char *fmt, ...)
156 vat_main_t *vam = &vat_main;
161 s = va_format (0, fmt, &va);
166 #if VPP_API_TEST_BUILTIN
167 vlib_cli_output (vam->vlib_main, (char *) s);
170 if (vam->ifp != stdin)
171 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
172 vam->input_line_number);
174 fformat (vam->ofp, "%s\n", (char *) s);
182 #if VPP_API_TEST_BUILTIN == 0
184 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
186 vat_main_t *vam = va_arg (*args, vat_main_t *);
187 u32 *result = va_arg (*args, u32 *);
191 if (!unformat (input, "%s", &if_name))
194 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
202 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
207 /* Parse an IP4 address %d.%d.%d.%d. */
209 unformat_ip4_address (unformat_input_t * input, va_list * args)
211 u8 *result = va_arg (*args, u8 *);
214 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
217 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
229 unformat_ethernet_address (unformat_input_t * input, va_list * args)
231 u8 *result = va_arg (*args, u8 *);
234 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
235 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
239 for (i = 0; i < 6; i++)
240 if (a[i] >= (1 << 8))
243 for (i = 0; i < 6; i++)
249 /* Returns ethernet type as an int in host byte order. */
251 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
254 u16 *result = va_arg (*args, u16 *);
258 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
260 if (type >= (1 << 16))
268 /* Parse an IP46 address. */
270 unformat_ip46_address (unformat_input_t * input, va_list * args)
272 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
273 ip46_type_t type = va_arg (*args, ip46_type_t);
274 if ((type != IP46_TYPE_IP6) &&
275 unformat (input, "%U", unformat_ip4_address, &ip46->ip4))
277 ip46_address_mask_ip4 (ip46);
280 else if ((type != IP46_TYPE_IP4) &&
281 unformat (input, "%U", unformat_ip6_address, &ip46->ip6))
288 /* Parse an IP6 address. */
290 unformat_ip6_address (unformat_input_t * input, va_list * args)
292 ip6_address_t *result = va_arg (*args, ip6_address_t *);
294 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
295 uword c, n_colon, double_colon_index;
297 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
298 double_colon_index = ARRAY_LEN (hex_quads);
299 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
302 if (c >= '0' && c <= '9')
304 else if (c >= 'a' && c <= 'f')
305 hex_digit = c + 10 - 'a';
306 else if (c >= 'A' && c <= 'F')
307 hex_digit = c + 10 - 'A';
308 else if (c == ':' && n_colon < 2)
312 unformat_put_input (input);
316 /* Too many hex quads. */
317 if (n_hex_quads >= ARRAY_LEN (hex_quads))
322 hex_quad = (hex_quad << 4) | hex_digit;
324 /* Hex quad must fit in 16 bits. */
325 if (n_hex_digits >= 4)
332 /* Save position of :: */
335 /* More than one :: ? */
336 if (double_colon_index < ARRAY_LEN (hex_quads))
338 double_colon_index = n_hex_quads;
341 if (n_colon > 0 && n_hex_digits > 0)
343 hex_quads[n_hex_quads++] = hex_quad;
349 if (n_hex_digits > 0)
350 hex_quads[n_hex_quads++] = hex_quad;
355 /* Expand :: to appropriate number of zero hex quads. */
356 if (double_colon_index < ARRAY_LEN (hex_quads))
358 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
360 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
361 hex_quads[n_zero + i] = hex_quads[i];
363 for (i = 0; i < n_zero; i++)
364 hex_quads[double_colon_index + i] = 0;
366 n_hex_quads = ARRAY_LEN (hex_quads);
369 /* Too few hex quads given. */
370 if (n_hex_quads < ARRAY_LEN (hex_quads))
373 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
374 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
381 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
383 u32 *r = va_arg (*args, u32 *);
386 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
387 foreach_ipsec_policy_action
395 format_ipsec_crypto_alg (u8 * s, va_list * args)
397 u32 i = va_arg (*args, u32);
402 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
403 foreach_ipsec_crypto_alg
406 return format (s, "unknown");
408 return format (s, "%s", t);
412 format_ipsec_integ_alg (u8 * s, va_list * args)
414 u32 i = va_arg (*args, u32);
419 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
420 foreach_ipsec_integ_alg
423 return format (s, "unknown");
425 return format (s, "%s", t);
428 #else /* VPP_API_TEST_BUILTIN == 1 */
430 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
432 vat_main_t *vam __clib_unused = va_arg (*args, vat_main_t *);
433 vnet_main_t *vnm = vnet_get_main ();
434 u32 *result = va_arg (*args, u32 *);
436 return unformat (input, "%U", unformat_vnet_sw_interface, vnm, result);
440 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
442 vat_main_t *vam __clib_unused = va_arg (*args, vat_main_t *);
443 vnet_main_t *vnm = vnet_get_main ();
444 u32 *result = va_arg (*args, u32 *);
446 return unformat (input, "%U", unformat_vnet_hw_interface, vnm, result);
449 #endif /* VPP_API_TEST_BUILTIN */
452 unformat_ipsec_api_crypto_alg (unformat_input_t * input, va_list * args)
454 u32 *r = va_arg (*args, u32 *);
457 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_API_CRYPTO_ALG_##f;
458 foreach_ipsec_crypto_alg
466 unformat_ipsec_api_integ_alg (unformat_input_t * input, va_list * args)
468 u32 *r = va_arg (*args, u32 *);
471 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_API_INTEG_ALG_##f;
472 foreach_ipsec_integ_alg
480 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
482 u8 *r = va_arg (*args, u8 *);
484 if (unformat (input, "kbps"))
485 *r = SSE2_QOS_RATE_KBPS;
486 else if (unformat (input, "pps"))
487 *r = SSE2_QOS_RATE_PPS;
494 unformat_policer_round_type (unformat_input_t * input, va_list * args)
496 u8 *r = va_arg (*args, u8 *);
498 if (unformat (input, "closest"))
499 *r = SSE2_QOS_ROUND_TO_CLOSEST;
500 else if (unformat (input, "up"))
501 *r = SSE2_QOS_ROUND_TO_UP;
502 else if (unformat (input, "down"))
503 *r = SSE2_QOS_ROUND_TO_DOWN;
510 unformat_policer_type (unformat_input_t * input, va_list * args)
512 u8 *r = va_arg (*args, u8 *);
514 if (unformat (input, "1r2c"))
515 *r = SSE2_QOS_POLICER_TYPE_1R2C;
516 else if (unformat (input, "1r3c"))
517 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
518 else if (unformat (input, "2r3c-2698"))
519 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
520 else if (unformat (input, "2r3c-4115"))
521 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
522 else if (unformat (input, "2r3c-mef5cf1"))
523 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
530 unformat_dscp (unformat_input_t * input, va_list * va)
532 u8 *r = va_arg (*va, u8 *);
535 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
544 unformat_policer_action_type (unformat_input_t * input, va_list * va)
546 sse2_qos_pol_action_params_st *a
547 = va_arg (*va, sse2_qos_pol_action_params_st *);
549 if (unformat (input, "drop"))
550 a->action_type = SSE2_QOS_ACTION_DROP;
551 else if (unformat (input, "transmit"))
552 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
553 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
554 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
561 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
563 u32 *r = va_arg (*va, u32 *);
566 if (unformat (input, "ip4"))
567 tid = POLICER_CLASSIFY_TABLE_IP4;
568 else if (unformat (input, "ip6"))
569 tid = POLICER_CLASSIFY_TABLE_IP6;
570 else if (unformat (input, "l2"))
571 tid = POLICER_CLASSIFY_TABLE_L2;
580 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
582 u32 *r = va_arg (*va, u32 *);
585 if (unformat (input, "ip4"))
586 tid = FLOW_CLASSIFY_TABLE_IP4;
587 else if (unformat (input, "ip6"))
588 tid = FLOW_CLASSIFY_TABLE_IP6;
596 #if (VPP_API_TEST_BUILTIN==0)
598 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
599 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
600 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
601 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
604 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
606 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
607 mfib_itf_attribute_t attr;
610 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
612 if (unformat (input, mfib_itf_flag_long_names[attr]))
613 *iflags |= (1 << attr);
615 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
617 if (unformat (input, mfib_itf_flag_names[attr]))
618 *iflags |= (1 << attr);
621 return (old == *iflags ? 0 : 1);
625 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
627 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
628 mfib_entry_attribute_t attr;
631 FOR_EACH_MFIB_ATTRIBUTE (attr)
633 if (unformat (input, mfib_flag_long_names[attr]))
634 *eflags |= (1 << attr);
636 FOR_EACH_MFIB_ATTRIBUTE (attr)
638 if (unformat (input, mfib_flag_names[attr]))
639 *eflags |= (1 << attr);
642 return (old == *eflags ? 0 : 1);
646 format_ip4_address (u8 * s, va_list * args)
648 u8 *a = va_arg (*args, u8 *);
649 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
653 format_ip6_address (u8 * s, va_list * args)
655 ip6_address_t *a = va_arg (*args, ip6_address_t *);
656 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
658 i_max_n_zero = ARRAY_LEN (a->as_u16);
660 i_first_zero = i_max_n_zero;
662 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
664 u32 is_zero = a->as_u16[i] == 0;
665 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
671 if ((!is_zero && n_zeros > max_n_zeros)
672 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
674 i_max_n_zero = i_first_zero;
675 max_n_zeros = n_zeros;
676 i_first_zero = ARRAY_LEN (a->as_u16);
681 last_double_colon = 0;
682 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
684 if (i == i_max_n_zero && max_n_zeros > 1)
686 s = format (s, "::");
687 i += max_n_zeros - 1;
688 last_double_colon = 1;
692 s = format (s, "%s%x",
693 (last_double_colon || i == 0) ? "" : ":",
694 clib_net_to_host_u16 (a->as_u16[i]));
695 last_double_colon = 0;
702 /* Format an IP46 address. */
704 format_ip46_address (u8 * s, va_list * args)
706 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
707 ip46_type_t type = va_arg (*args, ip46_type_t);
713 is_ip4 = ip46_address_is_ip4 (ip46);
724 format (s, "%U", format_ip4_address, &ip46->ip4) :
725 format (s, "%U", format_ip6_address, &ip46->ip6);
729 format_ethernet_address (u8 * s, va_list * args)
731 u8 *a = va_arg (*args, u8 *);
733 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
734 a[0], a[1], a[2], a[3], a[4], a[5]);
739 increment_v4_address (vl_api_ip4_address_t * i)
741 ip4_address_t *a = (ip4_address_t *) i;
744 v = ntohl (a->as_u32) + 1;
745 a->as_u32 = ntohl (v);
749 increment_v6_address (vl_api_ip6_address_t * i)
751 ip6_address_t *a = (ip6_address_t *) i;
754 v0 = clib_net_to_host_u64 (a->as_u64[0]);
755 v1 = clib_net_to_host_u64 (a->as_u64[1]);
760 a->as_u64[0] = clib_net_to_host_u64 (v0);
761 a->as_u64[1] = clib_net_to_host_u64 (v1);
765 increment_address (vl_api_address_t * a)
767 if (a->af == ADDRESS_IP4)
768 increment_v4_address (&a->un.ip4);
769 else if (a->af == ADDRESS_IP6)
770 increment_v6_address (&a->un.ip6);
774 set_ip4_address (vl_api_address_t * a, u32 v)
776 if (a->af == ADDRESS_IP4)
778 ip4_address_t *i = (ip4_address_t *) & a->un.ip4;
784 ip_set (ip46_address_t * dst, void *src, u8 is_ip4)
787 dst->ip4.as_u32 = ((ip4_address_t *) src)->as_u32;
789 clib_memcpy_fast (&dst->ip6, (ip6_address_t *) src,
790 sizeof (ip6_address_t));
794 increment_mac_address (u8 * mac)
796 u64 tmp = *((u64 *) mac);
797 tmp = clib_net_to_host_u64 (tmp);
798 tmp += 1 << 16; /* skip unused (least significant) octets */
799 tmp = clib_host_to_net_u64 (tmp);
801 clib_memcpy (mac, &tmp, 6);
805 vat_json_object_add_address (vat_json_node_t * node,
806 const char *str, const vl_api_address_t * addr)
808 if (ADDRESS_IP6 == addr->af)
812 clib_memcpy (&ip6, &addr->un.ip6, sizeof (ip6));
813 vat_json_object_add_ip6 (node, str, ip6);
819 clib_memcpy (&ip4, &addr->un.ip4, sizeof (ip4));
820 vat_json_object_add_ip4 (node, str, ip4);
825 vat_json_object_add_prefix (vat_json_node_t * node,
826 const vl_api_prefix_t * prefix)
828 vat_json_object_add_uint (node, "len", prefix->len);
829 vat_json_object_add_address (node, "address", &prefix->address);
832 static void vl_api_create_loopback_reply_t_handler
833 (vl_api_create_loopback_reply_t * mp)
835 vat_main_t *vam = &vat_main;
836 i32 retval = ntohl (mp->retval);
838 vam->retval = retval;
839 vam->regenerate_interface_table = 1;
840 vam->sw_if_index = ntohl (mp->sw_if_index);
841 vam->result_ready = 1;
844 static void vl_api_create_loopback_reply_t_handler_json
845 (vl_api_create_loopback_reply_t * mp)
847 vat_main_t *vam = &vat_main;
848 vat_json_node_t node;
850 vat_json_init_object (&node);
851 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
852 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
854 vat_json_print (vam->ofp, &node);
855 vat_json_free (&node);
856 vam->retval = ntohl (mp->retval);
857 vam->result_ready = 1;
860 static void vl_api_create_loopback_instance_reply_t_handler
861 (vl_api_create_loopback_instance_reply_t * mp)
863 vat_main_t *vam = &vat_main;
864 i32 retval = ntohl (mp->retval);
866 vam->retval = retval;
867 vam->regenerate_interface_table = 1;
868 vam->sw_if_index = ntohl (mp->sw_if_index);
869 vam->result_ready = 1;
872 static void vl_api_create_loopback_instance_reply_t_handler_json
873 (vl_api_create_loopback_instance_reply_t * mp)
875 vat_main_t *vam = &vat_main;
876 vat_json_node_t node;
878 vat_json_init_object (&node);
879 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
880 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
882 vat_json_print (vam->ofp, &node);
883 vat_json_free (&node);
884 vam->retval = ntohl (mp->retval);
885 vam->result_ready = 1;
888 static void vl_api_af_packet_create_reply_t_handler
889 (vl_api_af_packet_create_reply_t * mp)
891 vat_main_t *vam = &vat_main;
892 i32 retval = ntohl (mp->retval);
894 vam->retval = retval;
895 vam->regenerate_interface_table = 1;
896 vam->sw_if_index = ntohl (mp->sw_if_index);
897 vam->result_ready = 1;
900 static void vl_api_af_packet_create_reply_t_handler_json
901 (vl_api_af_packet_create_reply_t * mp)
903 vat_main_t *vam = &vat_main;
904 vat_json_node_t node;
906 vat_json_init_object (&node);
907 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
908 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
910 vat_json_print (vam->ofp, &node);
911 vat_json_free (&node);
913 vam->retval = ntohl (mp->retval);
914 vam->result_ready = 1;
917 static void vl_api_create_vlan_subif_reply_t_handler
918 (vl_api_create_vlan_subif_reply_t * mp)
920 vat_main_t *vam = &vat_main;
921 i32 retval = ntohl (mp->retval);
923 vam->retval = retval;
924 vam->regenerate_interface_table = 1;
925 vam->sw_if_index = ntohl (mp->sw_if_index);
926 vam->result_ready = 1;
929 static void vl_api_create_vlan_subif_reply_t_handler_json
930 (vl_api_create_vlan_subif_reply_t * mp)
932 vat_main_t *vam = &vat_main;
933 vat_json_node_t node;
935 vat_json_init_object (&node);
936 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
937 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
939 vat_json_print (vam->ofp, &node);
940 vat_json_free (&node);
942 vam->retval = ntohl (mp->retval);
943 vam->result_ready = 1;
946 static void vl_api_create_subif_reply_t_handler
947 (vl_api_create_subif_reply_t * mp)
949 vat_main_t *vam = &vat_main;
950 i32 retval = ntohl (mp->retval);
952 vam->retval = retval;
953 vam->regenerate_interface_table = 1;
954 vam->sw_if_index = ntohl (mp->sw_if_index);
955 vam->result_ready = 1;
958 static void vl_api_create_subif_reply_t_handler_json
959 (vl_api_create_subif_reply_t * mp)
961 vat_main_t *vam = &vat_main;
962 vat_json_node_t node;
964 vat_json_init_object (&node);
965 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
966 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
968 vat_json_print (vam->ofp, &node);
969 vat_json_free (&node);
971 vam->retval = ntohl (mp->retval);
972 vam->result_ready = 1;
975 static void vl_api_interface_name_renumber_reply_t_handler
976 (vl_api_interface_name_renumber_reply_t * mp)
978 vat_main_t *vam = &vat_main;
979 i32 retval = ntohl (mp->retval);
981 vam->retval = retval;
982 vam->regenerate_interface_table = 1;
983 vam->result_ready = 1;
986 static void vl_api_interface_name_renumber_reply_t_handler_json
987 (vl_api_interface_name_renumber_reply_t * mp)
989 vat_main_t *vam = &vat_main;
990 vat_json_node_t node;
992 vat_json_init_object (&node);
993 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
995 vat_json_print (vam->ofp, &node);
996 vat_json_free (&node);
998 vam->retval = ntohl (mp->retval);
999 vam->result_ready = 1;
1003 * Special-case: build the interface table, maintain
1004 * the next loopback sw_if_index vbl.
1006 static void vl_api_sw_interface_details_t_handler
1007 (vl_api_sw_interface_details_t * mp)
1009 vat_main_t *vam = &vat_main;
1010 u8 *s = format (0, "%s%c", mp->interface_name, 0);
1012 hash_set_mem (vam->sw_if_index_by_interface_name, s,
1013 ntohl (mp->sw_if_index));
1015 /* In sub interface case, fill the sub interface table entry */
1016 if (mp->sw_if_index != mp->sup_sw_if_index)
1018 sw_interface_subif_t *sub = NULL;
1020 vec_add2 (vam->sw_if_subif_table, sub, 1);
1022 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
1023 strncpy ((char *) sub->interface_name, (char *) s,
1024 vec_len (sub->interface_name));
1025 sub->sw_if_index = ntohl (mp->sw_if_index);
1026 sub->sub_id = ntohl (mp->sub_id);
1028 sub->raw_flags = ntohl (mp->sub_if_flags & SUB_IF_API_FLAG_MASK_VNET);
1030 sub->sub_number_of_tags = mp->sub_number_of_tags;
1031 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
1032 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
1034 /* vlan tag rewrite */
1035 sub->vtr_op = ntohl (mp->vtr_op);
1036 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
1037 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
1038 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
1042 static void vl_api_sw_interface_details_t_handler_json
1043 (vl_api_sw_interface_details_t * mp)
1045 vat_main_t *vam = &vat_main;
1046 vat_json_node_t *node = NULL;
1048 if (VAT_JSON_ARRAY != vam->json_tree.type)
1050 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1051 vat_json_init_array (&vam->json_tree);
1053 node = vat_json_array_add (&vam->json_tree);
1055 vat_json_init_object (node);
1056 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1057 vat_json_object_add_uint (node, "sup_sw_if_index",
1058 ntohl (mp->sup_sw_if_index));
1059 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
1060 sizeof (mp->l2_address));
1061 vat_json_object_add_string_copy (node, "interface_name",
1062 mp->interface_name);
1063 vat_json_object_add_string_copy (node, "interface_dev_type",
1064 mp->interface_dev_type);
1065 vat_json_object_add_uint (node, "flags", mp->flags);
1066 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
1067 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
1068 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
1069 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
1070 vat_json_object_add_uint (node, "sub_number_of_tags",
1071 mp->sub_number_of_tags);
1072 vat_json_object_add_uint (node, "sub_outer_vlan_id",
1073 ntohs (mp->sub_outer_vlan_id));
1074 vat_json_object_add_uint (node, "sub_inner_vlan_id",
1075 ntohs (mp->sub_inner_vlan_id));
1076 vat_json_object_add_uint (node, "sub_if_flags", ntohl (mp->sub_if_flags));
1077 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
1078 vat_json_object_add_uint (node, "vtr_push_dot1q",
1079 ntohl (mp->vtr_push_dot1q));
1080 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
1081 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
1082 if (ntohl (mp->sub_if_flags) & SUB_IF_API_FLAG_DOT1AH)
1084 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
1086 format_ethernet_address,
1088 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
1090 format_ethernet_address,
1092 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
1093 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
1097 #if VPP_API_TEST_BUILTIN == 0
1098 static void vl_api_sw_interface_event_t_handler
1099 (vl_api_sw_interface_event_t * mp)
1101 vat_main_t *vam = &vat_main;
1102 if (vam->interface_event_display)
1103 errmsg ("interface flags: sw_if_index %d %s %s",
1104 ntohl (mp->sw_if_index),
1105 ((ntohl (mp->flags)) & IF_STATUS_API_FLAG_ADMIN_UP) ?
1106 "admin-up" : "admin-down",
1107 ((ntohl (mp->flags)) & IF_STATUS_API_FLAG_LINK_UP) ?
1108 "link-up" : "link-down");
1112 __clib_unused static void
1113 vl_api_sw_interface_event_t_handler_json (vl_api_sw_interface_event_t * mp)
1115 /* JSON output not supported */
1119 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
1121 vat_main_t *vam = &vat_main;
1122 i32 retval = ntohl (mp->retval);
1124 vam->retval = retval;
1125 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1126 vam->result_ready = 1;
1130 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1132 vat_main_t *vam = &vat_main;
1133 vat_json_node_t node;
1137 vat_json_init_object (&node);
1138 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1139 vat_json_object_add_uint (&node, "reply_in_shmem",
1140 ntohl (mp->reply_in_shmem));
1141 /* Toss the shared-memory original... */
1142 oldheap = vl_msg_push_heap ();
1144 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1147 vl_msg_pop_heap (oldheap);
1149 vat_json_print (vam->ofp, &node);
1150 vat_json_free (&node);
1152 vam->retval = ntohl (mp->retval);
1153 vam->result_ready = 1;
1157 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1159 vat_main_t *vam = &vat_main;
1160 i32 retval = ntohl (mp->retval);
1162 vec_reset_length (vam->cmd_reply);
1164 vam->retval = retval;
1166 vam->cmd_reply = vl_api_from_api_to_new_vec (mp, &mp->reply);
1167 vam->result_ready = 1;
1171 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1173 vat_main_t *vam = &vat_main;
1174 vat_json_node_t node;
1175 u8 *reply = 0; /* reply vector */
1177 reply = vl_api_from_api_to_new_vec (mp, &mp->reply);
1178 vec_reset_length (vam->cmd_reply);
1180 vat_json_init_object (&node);
1181 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1182 vat_json_object_add_string_copy (&node, "reply", reply);
1184 vat_json_print (vam->ofp, &node);
1185 vat_json_free (&node);
1188 vam->retval = ntohl (mp->retval);
1189 vam->result_ready = 1;
1192 static void vl_api_classify_add_del_table_reply_t_handler
1193 (vl_api_classify_add_del_table_reply_t * mp)
1195 vat_main_t *vam = &vat_main;
1196 i32 retval = ntohl (mp->retval);
1197 if (vam->async_mode)
1199 vam->async_errors += (retval < 0);
1203 vam->retval = retval;
1205 ((mp->new_table_index != 0xFFFFFFFF) ||
1206 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1207 (mp->match_n_vectors != 0xFFFFFFFF)))
1209 * Note: this is just barely thread-safe, depends on
1210 * the main thread spinning waiting for an answer...
1212 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1213 ntohl (mp->new_table_index),
1214 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1215 vam->result_ready = 1;
1219 static void vl_api_classify_add_del_table_reply_t_handler_json
1220 (vl_api_classify_add_del_table_reply_t * mp)
1222 vat_main_t *vam = &vat_main;
1223 vat_json_node_t node;
1225 vat_json_init_object (&node);
1226 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1227 vat_json_object_add_uint (&node, "new_table_index",
1228 ntohl (mp->new_table_index));
1229 vat_json_object_add_uint (&node, "skip_n_vectors",
1230 ntohl (mp->skip_n_vectors));
1231 vat_json_object_add_uint (&node, "match_n_vectors",
1232 ntohl (mp->match_n_vectors));
1234 vat_json_print (vam->ofp, &node);
1235 vat_json_free (&node);
1237 vam->retval = ntohl (mp->retval);
1238 vam->result_ready = 1;
1241 static void vl_api_get_node_index_reply_t_handler
1242 (vl_api_get_node_index_reply_t * mp)
1244 vat_main_t *vam = &vat_main;
1245 i32 retval = ntohl (mp->retval);
1246 if (vam->async_mode)
1248 vam->async_errors += (retval < 0);
1252 vam->retval = retval;
1254 errmsg ("node index %d", ntohl (mp->node_index));
1255 vam->result_ready = 1;
1259 static void vl_api_get_node_index_reply_t_handler_json
1260 (vl_api_get_node_index_reply_t * mp)
1262 vat_main_t *vam = &vat_main;
1263 vat_json_node_t node;
1265 vat_json_init_object (&node);
1266 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1267 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1269 vat_json_print (vam->ofp, &node);
1270 vat_json_free (&node);
1272 vam->retval = ntohl (mp->retval);
1273 vam->result_ready = 1;
1276 static void vl_api_get_next_index_reply_t_handler
1277 (vl_api_get_next_index_reply_t * mp)
1279 vat_main_t *vam = &vat_main;
1280 i32 retval = ntohl (mp->retval);
1281 if (vam->async_mode)
1283 vam->async_errors += (retval < 0);
1287 vam->retval = retval;
1289 errmsg ("next node index %d", ntohl (mp->next_index));
1290 vam->result_ready = 1;
1294 static void vl_api_get_next_index_reply_t_handler_json
1295 (vl_api_get_next_index_reply_t * mp)
1297 vat_main_t *vam = &vat_main;
1298 vat_json_node_t node;
1300 vat_json_init_object (&node);
1301 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1302 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1304 vat_json_print (vam->ofp, &node);
1305 vat_json_free (&node);
1307 vam->retval = ntohl (mp->retval);
1308 vam->result_ready = 1;
1311 static void vl_api_add_node_next_reply_t_handler
1312 (vl_api_add_node_next_reply_t * mp)
1314 vat_main_t *vam = &vat_main;
1315 i32 retval = ntohl (mp->retval);
1316 if (vam->async_mode)
1318 vam->async_errors += (retval < 0);
1322 vam->retval = retval;
1324 errmsg ("next index %d", ntohl (mp->next_index));
1325 vam->result_ready = 1;
1329 static void vl_api_add_node_next_reply_t_handler_json
1330 (vl_api_add_node_next_reply_t * mp)
1332 vat_main_t *vam = &vat_main;
1333 vat_json_node_t node;
1335 vat_json_init_object (&node);
1336 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1337 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1339 vat_json_print (vam->ofp, &node);
1340 vat_json_free (&node);
1342 vam->retval = ntohl (mp->retval);
1343 vam->result_ready = 1;
1346 static void vl_api_show_version_reply_t_handler
1347 (vl_api_show_version_reply_t * mp)
1349 vat_main_t *vam = &vat_main;
1350 i32 retval = ntohl (mp->retval);
1354 errmsg (" program: %s", mp->program);
1355 errmsg (" version: %s", mp->version);
1356 errmsg (" build date: %s", mp->build_date);
1357 errmsg ("build directory: %s", mp->build_directory);
1359 vam->retval = retval;
1360 vam->result_ready = 1;
1363 static void vl_api_show_version_reply_t_handler_json
1364 (vl_api_show_version_reply_t * mp)
1366 vat_main_t *vam = &vat_main;
1367 vat_json_node_t node;
1369 vat_json_init_object (&node);
1370 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1371 vat_json_object_add_string_copy (&node, "program", mp->program);
1372 vat_json_object_add_string_copy (&node, "version", mp->version);
1373 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1374 vat_json_object_add_string_copy (&node, "build_directory",
1375 mp->build_directory);
1377 vat_json_print (vam->ofp, &node);
1378 vat_json_free (&node);
1380 vam->retval = ntohl (mp->retval);
1381 vam->result_ready = 1;
1384 static void vl_api_show_threads_reply_t_handler
1385 (vl_api_show_threads_reply_t * mp)
1387 vat_main_t *vam = &vat_main;
1388 i32 retval = ntohl (mp->retval);
1392 count = ntohl (mp->count);
1394 for (i = 0; i < count; i++)
1396 "\n%-2d %-11s %-11s %-5d %-6d %-4d %-6d",
1397 ntohl (mp->thread_data[i].id), mp->thread_data[i].name,
1398 mp->thread_data[i].type, ntohl (mp->thread_data[i].pid),
1399 ntohl (mp->thread_data[i].cpu_id), ntohl (mp->thread_data[i].core),
1400 ntohl (mp->thread_data[i].cpu_socket));
1402 vam->retval = retval;
1403 vam->result_ready = 1;
1406 static void vl_api_show_threads_reply_t_handler_json
1407 (vl_api_show_threads_reply_t * mp)
1409 vat_main_t *vam = &vat_main;
1410 vat_json_node_t node;
1411 vl_api_thread_data_t *td;
1412 i32 retval = ntohl (mp->retval);
1416 count = ntohl (mp->count);
1418 vat_json_init_object (&node);
1419 vat_json_object_add_int (&node, "retval", retval);
1420 vat_json_object_add_uint (&node, "count", count);
1422 for (i = 0; i < count; i++)
1424 td = &mp->thread_data[i];
1425 vat_json_object_add_uint (&node, "id", ntohl (td->id));
1426 vat_json_object_add_string_copy (&node, "name", td->name);
1427 vat_json_object_add_string_copy (&node, "type", td->type);
1428 vat_json_object_add_uint (&node, "pid", ntohl (td->pid));
1429 vat_json_object_add_int (&node, "cpu_id", ntohl (td->cpu_id));
1430 vat_json_object_add_int (&node, "core", ntohl (td->id));
1431 vat_json_object_add_int (&node, "cpu_socket", ntohl (td->cpu_socket));
1434 vat_json_print (vam->ofp, &node);
1435 vat_json_free (&node);
1437 vam->retval = retval;
1438 vam->result_ready = 1;
1442 api_show_threads (vat_main_t * vam)
1444 vl_api_show_threads_t *mp;
1448 "\n%-2s %-11s %-11s %-5s %-6s %-4s %-6s",
1449 "ID", "Name", "Type", "LWP", "cpu_id", "Core", "Socket");
1451 M (SHOW_THREADS, mp);
1459 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1461 u32 n_macs = ntohl (mp->n_macs);
1462 errmsg ("L2MAC event received with pid %d cl-idx %d for %d macs: \n",
1463 ntohl (mp->pid), mp->client_index, n_macs);
1465 for (i = 0; i < n_macs; i++)
1467 vl_api_mac_entry_t *mac = &mp->mac[i];
1468 errmsg (" [%d] sw_if_index %d mac_addr %U action %d \n",
1469 i + 1, ntohl (mac->sw_if_index),
1470 format_ethernet_address, mac->mac_addr, mac->action);
1477 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1479 /* JSON output not supported */
1482 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1483 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1486 * Special-case: build the bridge domain table, maintain
1487 * the next bd id vbl.
1489 static void vl_api_bridge_domain_details_t_handler
1490 (vl_api_bridge_domain_details_t * mp)
1492 vat_main_t *vam = &vat_main;
1493 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1496 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-6s %-3s",
1497 " ID", "LRN", "FWD", "FLD", "BVI", "UU-FWD", "#IF");
1499 print (vam->ofp, "%3d %3d %3d %3d %3d %6d %3d",
1500 ntohl (mp->bd_id), mp->learn, mp->forward,
1501 mp->flood, ntohl (mp->bvi_sw_if_index),
1502 ntohl (mp->uu_fwd_sw_if_index), n_sw_ifs);
1506 vl_api_bridge_domain_sw_if_t *sw_ifs;
1507 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1510 sw_ifs = mp->sw_if_details;
1511 for (i = 0; i < n_sw_ifs; i++)
1517 sw_if_index = ntohl (sw_ifs->sw_if_index);
1520 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1522 if ((u32) p->value[0] == sw_if_index)
1524 sw_if_name = (u8 *)(p->key);
1529 print (vam->ofp, "%7d %3d %s", sw_if_index,
1530 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1531 "sw_if_index not found!");
1538 static void vl_api_bridge_domain_details_t_handler_json
1539 (vl_api_bridge_domain_details_t * mp)
1541 vat_main_t *vam = &vat_main;
1542 vat_json_node_t *node, *array = NULL;
1543 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1545 if (VAT_JSON_ARRAY != vam->json_tree.type)
1547 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1548 vat_json_init_array (&vam->json_tree);
1550 node = vat_json_array_add (&vam->json_tree);
1552 vat_json_init_object (node);
1553 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1554 vat_json_object_add_uint (node, "flood", mp->flood);
1555 vat_json_object_add_uint (node, "forward", mp->forward);
1556 vat_json_object_add_uint (node, "learn", mp->learn);
1557 vat_json_object_add_uint (node, "bvi_sw_if_index",
1558 ntohl (mp->bvi_sw_if_index));
1559 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1560 array = vat_json_object_add (node, "sw_if");
1561 vat_json_init_array (array);
1567 vl_api_bridge_domain_sw_if_t *sw_ifs;
1570 sw_ifs = mp->sw_if_details;
1571 for (i = 0; i < n_sw_ifs; i++)
1573 node = vat_json_array_add (array);
1574 vat_json_init_object (node);
1575 vat_json_object_add_uint (node, "sw_if_index",
1576 ntohl (sw_ifs->sw_if_index));
1577 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1583 static void vl_api_control_ping_reply_t_handler
1584 (vl_api_control_ping_reply_t * mp)
1586 vat_main_t *vam = &vat_main;
1587 i32 retval = ntohl (mp->retval);
1588 if (vam->async_mode)
1590 vam->async_errors += (retval < 0);
1594 vam->retval = retval;
1595 vam->result_ready = 1;
1597 if (vam->socket_client_main)
1598 vam->socket_client_main->control_pings_outstanding--;
1601 static void vl_api_control_ping_reply_t_handler_json
1602 (vl_api_control_ping_reply_t * mp)
1604 vat_main_t *vam = &vat_main;
1605 i32 retval = ntohl (mp->retval);
1607 if (VAT_JSON_NONE != vam->json_tree.type)
1609 vat_json_print (vam->ofp, &vam->json_tree);
1610 vat_json_free (&vam->json_tree);
1611 vam->json_tree.type = VAT_JSON_NONE;
1616 vat_json_init_array (&vam->json_tree);
1617 vat_json_print (vam->ofp, &vam->json_tree);
1618 vam->json_tree.type = VAT_JSON_NONE;
1621 vam->retval = retval;
1622 vam->result_ready = 1;
1626 vl_api_bridge_domain_set_mac_age_reply_t_handler
1627 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1629 vat_main_t *vam = &vat_main;
1630 i32 retval = ntohl (mp->retval);
1631 if (vam->async_mode)
1633 vam->async_errors += (retval < 0);
1637 vam->retval = retval;
1638 vam->result_ready = 1;
1642 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1643 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1645 vat_main_t *vam = &vat_main;
1646 vat_json_node_t node;
1648 vat_json_init_object (&node);
1649 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1651 vat_json_print (vam->ofp, &node);
1652 vat_json_free (&node);
1654 vam->retval = ntohl (mp->retval);
1655 vam->result_ready = 1;
1659 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1661 vat_main_t *vam = &vat_main;
1662 i32 retval = ntohl (mp->retval);
1663 if (vam->async_mode)
1665 vam->async_errors += (retval < 0);
1669 vam->retval = retval;
1670 vam->result_ready = 1;
1674 static void vl_api_l2_flags_reply_t_handler_json
1675 (vl_api_l2_flags_reply_t * mp)
1677 vat_main_t *vam = &vat_main;
1678 vat_json_node_t node;
1680 vat_json_init_object (&node);
1681 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1682 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1683 ntohl (mp->resulting_feature_bitmap));
1685 vat_json_print (vam->ofp, &node);
1686 vat_json_free (&node);
1688 vam->retval = ntohl (mp->retval);
1689 vam->result_ready = 1;
1692 static void vl_api_bridge_flags_reply_t_handler
1693 (vl_api_bridge_flags_reply_t * mp)
1695 vat_main_t *vam = &vat_main;
1696 i32 retval = ntohl (mp->retval);
1697 if (vam->async_mode)
1699 vam->async_errors += (retval < 0);
1703 vam->retval = retval;
1704 vam->result_ready = 1;
1708 static void vl_api_bridge_flags_reply_t_handler_json
1709 (vl_api_bridge_flags_reply_t * mp)
1711 vat_main_t *vam = &vat_main;
1712 vat_json_node_t node;
1714 vat_json_init_object (&node);
1715 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1716 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1717 ntohl (mp->resulting_feature_bitmap));
1719 vat_json_print (vam->ofp, &node);
1720 vat_json_free (&node);
1722 vam->retval = ntohl (mp->retval);
1723 vam->result_ready = 1;
1727 vl_api_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_reply_t * mp)
1729 vat_main_t *vam = &vat_main;
1730 i32 retval = ntohl (mp->retval);
1731 if (vam->async_mode)
1733 vam->async_errors += (retval < 0);
1737 vam->retval = retval;
1738 vam->sw_if_index = ntohl (mp->sw_if_index);
1739 vam->result_ready = 1;
1744 static void vl_api_tap_create_v2_reply_t_handler_json
1745 (vl_api_tap_create_v2_reply_t * mp)
1747 vat_main_t *vam = &vat_main;
1748 vat_json_node_t node;
1750 vat_json_init_object (&node);
1751 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1752 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1754 vat_json_print (vam->ofp, &node);
1755 vat_json_free (&node);
1757 vam->retval = ntohl (mp->retval);
1758 vam->result_ready = 1;
1763 vl_api_tap_delete_v2_reply_t_handler (vl_api_tap_delete_v2_reply_t * mp)
1765 vat_main_t *vam = &vat_main;
1766 i32 retval = ntohl (mp->retval);
1767 if (vam->async_mode)
1769 vam->async_errors += (retval < 0);
1773 vam->retval = retval;
1774 vam->result_ready = 1;
1778 static void vl_api_tap_delete_v2_reply_t_handler_json
1779 (vl_api_tap_delete_v2_reply_t * mp)
1781 vat_main_t *vam = &vat_main;
1782 vat_json_node_t node;
1784 vat_json_init_object (&node);
1785 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1787 vat_json_print (vam->ofp, &node);
1788 vat_json_free (&node);
1790 vam->retval = ntohl (mp->retval);
1791 vam->result_ready = 1;
1795 vl_api_virtio_pci_create_reply_t_handler (vl_api_virtio_pci_create_reply_t *
1798 vat_main_t *vam = &vat_main;
1799 i32 retval = ntohl (mp->retval);
1800 if (vam->async_mode)
1802 vam->async_errors += (retval < 0);
1806 vam->retval = retval;
1807 vam->sw_if_index = ntohl (mp->sw_if_index);
1808 vam->result_ready = 1;
1812 static void vl_api_virtio_pci_create_reply_t_handler_json
1813 (vl_api_virtio_pci_create_reply_t * mp)
1815 vat_main_t *vam = &vat_main;
1816 vat_json_node_t node;
1818 vat_json_init_object (&node);
1819 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1820 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1822 vat_json_print (vam->ofp, &node);
1823 vat_json_free (&node);
1825 vam->retval = ntohl (mp->retval);
1826 vam->result_ready = 1;
1831 vl_api_virtio_pci_create_v2_reply_t_handler
1832 (vl_api_virtio_pci_create_v2_reply_t * mp)
1834 vat_main_t *vam = &vat_main;
1835 i32 retval = ntohl (mp->retval);
1836 if (vam->async_mode)
1838 vam->async_errors += (retval < 0);
1842 vam->retval = retval;
1843 vam->sw_if_index = ntohl (mp->sw_if_index);
1844 vam->result_ready = 1;
1848 static void vl_api_virtio_pci_create_v2_reply_t_handler_json
1849 (vl_api_virtio_pci_create_v2_reply_t * mp)
1851 vat_main_t *vam = &vat_main;
1852 vat_json_node_t node;
1854 vat_json_init_object (&node);
1855 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1856 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1858 vat_json_print (vam->ofp, &node);
1859 vat_json_free (&node);
1861 vam->retval = ntohl (mp->retval);
1862 vam->result_ready = 1;
1866 vl_api_virtio_pci_delete_reply_t_handler (vl_api_virtio_pci_delete_reply_t *
1869 vat_main_t *vam = &vat_main;
1870 i32 retval = ntohl (mp->retval);
1871 if (vam->async_mode)
1873 vam->async_errors += (retval < 0);
1877 vam->retval = retval;
1878 vam->result_ready = 1;
1882 static void vl_api_virtio_pci_delete_reply_t_handler_json
1883 (vl_api_virtio_pci_delete_reply_t * mp)
1885 vat_main_t *vam = &vat_main;
1886 vat_json_node_t node;
1888 vat_json_init_object (&node);
1889 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1891 vat_json_print (vam->ofp, &node);
1892 vat_json_free (&node);
1894 vam->retval = ntohl (mp->retval);
1895 vam->result_ready = 1;
1899 vl_api_bond_create_reply_t_handler (vl_api_bond_create_reply_t * mp)
1901 vat_main_t *vam = &vat_main;
1902 i32 retval = ntohl (mp->retval);
1904 if (vam->async_mode)
1906 vam->async_errors += (retval < 0);
1910 vam->retval = retval;
1911 vam->sw_if_index = ntohl (mp->sw_if_index);
1912 vam->result_ready = 1;
1916 static void vl_api_bond_create_reply_t_handler_json
1917 (vl_api_bond_create_reply_t * mp)
1919 vat_main_t *vam = &vat_main;
1920 vat_json_node_t node;
1922 vat_json_init_object (&node);
1923 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1924 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1926 vat_json_print (vam->ofp, &node);
1927 vat_json_free (&node);
1929 vam->retval = ntohl (mp->retval);
1930 vam->result_ready = 1;
1934 vl_api_bond_create2_reply_t_handler (vl_api_bond_create2_reply_t * mp)
1936 vat_main_t *vam = &vat_main;
1937 i32 retval = ntohl (mp->retval);
1939 if (vam->async_mode)
1941 vam->async_errors += (retval < 0);
1945 vam->retval = retval;
1946 vam->sw_if_index = ntohl (mp->sw_if_index);
1947 vam->result_ready = 1;
1951 static void vl_api_bond_create2_reply_t_handler_json
1952 (vl_api_bond_create2_reply_t * mp)
1954 vat_main_t *vam = &vat_main;
1955 vat_json_node_t node;
1957 vat_json_init_object (&node);
1958 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1959 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1961 vat_json_print (vam->ofp, &node);
1962 vat_json_free (&node);
1964 vam->retval = ntohl (mp->retval);
1965 vam->result_ready = 1;
1969 vl_api_bond_delete_reply_t_handler (vl_api_bond_delete_reply_t * mp)
1971 vat_main_t *vam = &vat_main;
1972 i32 retval = ntohl (mp->retval);
1974 if (vam->async_mode)
1976 vam->async_errors += (retval < 0);
1980 vam->retval = retval;
1981 vam->result_ready = 1;
1985 static void vl_api_bond_delete_reply_t_handler_json
1986 (vl_api_bond_delete_reply_t * mp)
1988 vat_main_t *vam = &vat_main;
1989 vat_json_node_t node;
1991 vat_json_init_object (&node);
1992 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1994 vat_json_print (vam->ofp, &node);
1995 vat_json_free (&node);
1997 vam->retval = ntohl (mp->retval);
1998 vam->result_ready = 1;
2002 vl_api_bond_add_member_reply_t_handler (vl_api_bond_add_member_reply_t * mp)
2004 vat_main_t *vam = &vat_main;
2005 i32 retval = ntohl (mp->retval);
2007 if (vam->async_mode)
2009 vam->async_errors += (retval < 0);
2013 vam->retval = retval;
2014 vam->result_ready = 1;
2018 static void vl_api_bond_add_member_reply_t_handler_json
2019 (vl_api_bond_add_member_reply_t * mp)
2021 vat_main_t *vam = &vat_main;
2022 vat_json_node_t node;
2024 vat_json_init_object (&node);
2025 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2027 vat_json_print (vam->ofp, &node);
2028 vat_json_free (&node);
2030 vam->retval = ntohl (mp->retval);
2031 vam->result_ready = 1;
2035 vl_api_bond_detach_member_reply_t_handler (vl_api_bond_detach_member_reply_t *
2038 vat_main_t *vam = &vat_main;
2039 i32 retval = ntohl (mp->retval);
2041 if (vam->async_mode)
2043 vam->async_errors += (retval < 0);
2047 vam->retval = retval;
2048 vam->result_ready = 1;
2052 static void vl_api_bond_detach_member_reply_t_handler_json
2053 (vl_api_bond_detach_member_reply_t * mp)
2055 vat_main_t *vam = &vat_main;
2056 vat_json_node_t node;
2058 vat_json_init_object (&node);
2059 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2061 vat_json_print (vam->ofp, &node);
2062 vat_json_free (&node);
2064 vam->retval = ntohl (mp->retval);
2065 vam->result_ready = 1;
2069 api_sw_interface_set_bond_weight (vat_main_t * vam)
2071 unformat_input_t *i = vam->input;
2072 vl_api_sw_interface_set_bond_weight_t *mp;
2073 u32 sw_if_index = ~0;
2075 u8 weight_enter = 0;
2078 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2080 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2082 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2084 else if (unformat (i, "weight %u", &weight))
2090 if (sw_if_index == ~0)
2092 errmsg ("missing interface name or sw_if_index");
2095 if (weight_enter == 0)
2097 errmsg ("missing valid weight");
2101 /* Construct the API message */
2102 M (SW_INTERFACE_SET_BOND_WEIGHT, mp);
2103 mp->sw_if_index = ntohl (sw_if_index);
2104 mp->weight = ntohl (weight);
2111 static void vl_api_sw_bond_interface_details_t_handler
2112 (vl_api_sw_bond_interface_details_t * mp)
2114 vat_main_t *vam = &vat_main;
2117 "%-16s %-12d %-12U %-13U %-14u %-14u",
2118 mp->interface_name, ntohl (mp->sw_if_index),
2119 format_bond_mode, ntohl (mp->mode), format_bond_load_balance,
2120 ntohl (mp->lb), ntohl (mp->active_members), ntohl (mp->members));
2123 static void vl_api_sw_bond_interface_details_t_handler_json
2124 (vl_api_sw_bond_interface_details_t * mp)
2126 vat_main_t *vam = &vat_main;
2127 vat_json_node_t *node = NULL;
2129 if (VAT_JSON_ARRAY != vam->json_tree.type)
2131 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2132 vat_json_init_array (&vam->json_tree);
2134 node = vat_json_array_add (&vam->json_tree);
2136 vat_json_init_object (node);
2137 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2138 vat_json_object_add_string_copy (node, "interface_name",
2139 mp->interface_name);
2140 vat_json_object_add_uint (node, "mode", ntohl (mp->mode));
2141 vat_json_object_add_uint (node, "load_balance", ntohl (mp->lb));
2142 vat_json_object_add_uint (node, "active_members",
2143 ntohl (mp->active_members));
2144 vat_json_object_add_uint (node, "members", ntohl (mp->members));
2148 api_sw_bond_interface_dump (vat_main_t * vam)
2150 unformat_input_t *i = vam->input;
2151 vl_api_sw_bond_interface_dump_t *mp;
2152 vl_api_control_ping_t *mp_ping;
2154 u32 sw_if_index = ~0;
2156 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2158 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2160 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2167 "\n%-16s %-12s %-12s %-13s %-14s %-14s",
2168 "interface name", "sw_if_index", "mode", "load balance",
2169 "active members", "members");
2171 /* Get list of bond interfaces */
2172 M (SW_BOND_INTERFACE_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_sw_member_interface_details_t_handler
2185 (vl_api_sw_member_interface_details_t * mp)
2187 vat_main_t *vam = &vat_main;
2190 "%-25s %-12d %-7d %-12d %-10d %-10d", mp->interface_name,
2191 ntohl (mp->sw_if_index), mp->is_passive, mp->is_long_timeout,
2192 ntohl (mp->weight), mp->is_local_numa);
2195 static void vl_api_sw_member_interface_details_t_handler_json
2196 (vl_api_sw_member_interface_details_t * mp)
2198 vat_main_t *vam = &vat_main;
2199 vat_json_node_t *node = NULL;
2201 if (VAT_JSON_ARRAY != vam->json_tree.type)
2203 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2204 vat_json_init_array (&vam->json_tree);
2206 node = vat_json_array_add (&vam->json_tree);
2208 vat_json_init_object (node);
2209 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2210 vat_json_object_add_string_copy (node, "interface_name",
2211 mp->interface_name);
2212 vat_json_object_add_uint (node, "passive", mp->is_passive);
2213 vat_json_object_add_uint (node, "long_timeout", mp->is_long_timeout);
2214 vat_json_object_add_uint (node, "weight", ntohl (mp->weight));
2215 vat_json_object_add_uint (node, "is_local_numa", mp->is_local_numa);
2219 api_sw_member_interface_dump (vat_main_t * vam)
2221 unformat_input_t *i = vam->input;
2222 vl_api_sw_member_interface_dump_t *mp;
2223 vl_api_control_ping_t *mp_ping;
2224 u32 sw_if_index = ~0;
2225 u8 sw_if_index_set = 0;
2228 /* Parse args required to build the message */
2229 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2231 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2232 sw_if_index_set = 1;
2233 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2234 sw_if_index_set = 1;
2239 if (sw_if_index_set == 0)
2241 errmsg ("missing vpp interface name. ");
2246 "\n%-25s %-12s %-7s %-12s %-10s %-10s",
2247 "member interface name", "sw_if_index", "passive", "long_timeout",
2248 "weight", "local numa");
2250 /* Get list of bond interfaces */
2251 M (SW_MEMBER_INTERFACE_DUMP, mp);
2252 mp->sw_if_index = ntohl (sw_if_index);
2255 /* Use a control ping for synchronization */
2256 MPING (CONTROL_PING, mp_ping);
2263 static void vl_api_mpls_tunnel_add_del_reply_t_handler
2264 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2266 vat_main_t *vam = &vat_main;
2267 i32 retval = ntohl (mp->retval);
2268 if (vam->async_mode)
2270 vam->async_errors += (retval < 0);
2274 vam->retval = retval;
2275 vam->sw_if_index = ntohl (mp->sw_if_index);
2276 vam->result_ready = 1;
2278 vam->regenerate_interface_table = 1;
2281 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
2282 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2284 vat_main_t *vam = &vat_main;
2285 vat_json_node_t node;
2287 vat_json_init_object (&node);
2288 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2289 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
2290 ntohl (mp->sw_if_index));
2292 vat_json_print (vam->ofp, &node);
2293 vat_json_free (&node);
2295 vam->retval = ntohl (mp->retval);
2296 vam->result_ready = 1;
2299 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
2300 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2302 vat_main_t *vam = &vat_main;
2303 i32 retval = ntohl (mp->retval);
2304 if (vam->async_mode)
2306 vam->async_errors += (retval < 0);
2310 vam->retval = retval;
2311 vam->sw_if_index = ntohl (mp->sw_if_index);
2312 vam->result_ready = 1;
2316 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
2317 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2319 vat_main_t *vam = &vat_main;
2320 vat_json_node_t node;
2322 vat_json_init_object (&node);
2323 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2324 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2326 vat_json_print (vam->ofp, &node);
2327 vat_json_free (&node);
2329 vam->retval = ntohl (mp->retval);
2330 vam->result_ready = 1;
2333 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
2334 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2336 vat_main_t *vam = &vat_main;
2337 i32 retval = ntohl (mp->retval);
2338 if (vam->async_mode)
2340 vam->async_errors += (retval < 0);
2344 vam->retval = retval;
2345 vam->result_ready = 1;
2349 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
2350 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2352 vat_main_t *vam = &vat_main;
2353 vat_json_node_t node;
2355 vat_json_init_object (&node);
2356 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2357 vat_json_object_add_uint (&node, "fwd_entry_index",
2358 clib_net_to_host_u32 (mp->fwd_entry_index));
2360 vat_json_print (vam->ofp, &node);
2361 vat_json_free (&node);
2363 vam->retval = ntohl (mp->retval);
2364 vam->result_ready = 1;
2368 format_lisp_transport_protocol (u8 * s, va_list * args)
2370 u32 proto = va_arg (*args, u32);
2375 return format (s, "udp");
2377 return format (s, "api");
2384 static void vl_api_one_get_transport_protocol_reply_t_handler
2385 (vl_api_one_get_transport_protocol_reply_t * mp)
2387 vat_main_t *vam = &vat_main;
2388 i32 retval = ntohl (mp->retval);
2389 if (vam->async_mode)
2391 vam->async_errors += (retval < 0);
2395 u32 proto = mp->protocol;
2396 print (vam->ofp, "Transport protocol: %U",
2397 format_lisp_transport_protocol, proto);
2398 vam->retval = retval;
2399 vam->result_ready = 1;
2403 static void vl_api_one_get_transport_protocol_reply_t_handler_json
2404 (vl_api_one_get_transport_protocol_reply_t * mp)
2406 vat_main_t *vam = &vat_main;
2407 vat_json_node_t node;
2410 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
2413 vat_json_init_object (&node);
2414 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2415 vat_json_object_add_string_copy (&node, "transport-protocol", s);
2418 vat_json_print (vam->ofp, &node);
2419 vat_json_free (&node);
2421 vam->retval = ntohl (mp->retval);
2422 vam->result_ready = 1;
2425 static void vl_api_one_add_del_locator_set_reply_t_handler
2426 (vl_api_one_add_del_locator_set_reply_t * mp)
2428 vat_main_t *vam = &vat_main;
2429 i32 retval = ntohl (mp->retval);
2430 if (vam->async_mode)
2432 vam->async_errors += (retval < 0);
2436 vam->retval = retval;
2437 vam->result_ready = 1;
2441 static void vl_api_one_add_del_locator_set_reply_t_handler_json
2442 (vl_api_one_add_del_locator_set_reply_t * mp)
2444 vat_main_t *vam = &vat_main;
2445 vat_json_node_t node;
2447 vat_json_init_object (&node);
2448 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2449 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
2451 vat_json_print (vam->ofp, &node);
2452 vat_json_free (&node);
2454 vam->retval = ntohl (mp->retval);
2455 vam->result_ready = 1;
2458 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
2459 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2461 vat_main_t *vam = &vat_main;
2462 i32 retval = ntohl (mp->retval);
2463 if (vam->async_mode)
2465 vam->async_errors += (retval < 0);
2469 vam->retval = retval;
2470 vam->sw_if_index = ntohl (mp->sw_if_index);
2471 vam->result_ready = 1;
2473 vam->regenerate_interface_table = 1;
2476 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
2477 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2479 vat_main_t *vam = &vat_main;
2480 vat_json_node_t node;
2482 vat_json_init_object (&node);
2483 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2484 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2486 vat_json_print (vam->ofp, &node);
2487 vat_json_free (&node);
2489 vam->retval = ntohl (mp->retval);
2490 vam->result_ready = 1;
2493 static void vl_api_vxlan_offload_rx_reply_t_handler
2494 (vl_api_vxlan_offload_rx_reply_t * mp)
2496 vat_main_t *vam = &vat_main;
2497 i32 retval = ntohl (mp->retval);
2498 if (vam->async_mode)
2500 vam->async_errors += (retval < 0);
2504 vam->retval = retval;
2505 vam->result_ready = 1;
2509 static void vl_api_vxlan_offload_rx_reply_t_handler_json
2510 (vl_api_vxlan_offload_rx_reply_t * mp)
2512 vat_main_t *vam = &vat_main;
2513 vat_json_node_t node;
2515 vat_json_init_object (&node);
2516 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2518 vat_json_print (vam->ofp, &node);
2519 vat_json_free (&node);
2521 vam->retval = ntohl (mp->retval);
2522 vam->result_ready = 1;
2525 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
2526 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2528 vat_main_t *vam = &vat_main;
2529 i32 retval = ntohl (mp->retval);
2530 if (vam->async_mode)
2532 vam->async_errors += (retval < 0);
2536 vam->retval = retval;
2537 vam->sw_if_index = ntohl (mp->sw_if_index);
2538 vam->result_ready = 1;
2540 vam->regenerate_interface_table = 1;
2543 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
2544 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2546 vat_main_t *vam = &vat_main;
2547 vat_json_node_t node;
2549 vat_json_init_object (&node);
2550 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2551 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2553 vat_json_print (vam->ofp, &node);
2554 vat_json_free (&node);
2556 vam->retval = ntohl (mp->retval);
2557 vam->result_ready = 1;
2560 static void vl_api_gre_tunnel_add_del_reply_t_handler
2561 (vl_api_gre_tunnel_add_del_reply_t * mp)
2563 vat_main_t *vam = &vat_main;
2564 i32 retval = ntohl (mp->retval);
2565 if (vam->async_mode)
2567 vam->async_errors += (retval < 0);
2571 vam->retval = retval;
2572 vam->sw_if_index = ntohl (mp->sw_if_index);
2573 vam->result_ready = 1;
2577 static void vl_api_gre_tunnel_add_del_reply_t_handler_json
2578 (vl_api_gre_tunnel_add_del_reply_t * mp)
2580 vat_main_t *vam = &vat_main;
2581 vat_json_node_t node;
2583 vat_json_init_object (&node);
2584 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2585 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2587 vat_json_print (vam->ofp, &node);
2588 vat_json_free (&node);
2590 vam->retval = ntohl (mp->retval);
2591 vam->result_ready = 1;
2594 static void vl_api_create_vhost_user_if_reply_t_handler
2595 (vl_api_create_vhost_user_if_reply_t * mp)
2597 vat_main_t *vam = &vat_main;
2598 i32 retval = ntohl (mp->retval);
2599 if (vam->async_mode)
2601 vam->async_errors += (retval < 0);
2605 vam->retval = retval;
2606 vam->sw_if_index = ntohl (mp->sw_if_index);
2607 vam->result_ready = 1;
2609 vam->regenerate_interface_table = 1;
2612 static void vl_api_create_vhost_user_if_reply_t_handler_json
2613 (vl_api_create_vhost_user_if_reply_t * mp)
2615 vat_main_t *vam = &vat_main;
2616 vat_json_node_t node;
2618 vat_json_init_object (&node);
2619 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2620 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2622 vat_json_print (vam->ofp, &node);
2623 vat_json_free (&node);
2625 vam->retval = ntohl (mp->retval);
2626 vam->result_ready = 1;
2629 static void vl_api_ip_address_details_t_handler
2630 (vl_api_ip_address_details_t * mp)
2632 vat_main_t *vam = &vat_main;
2633 static ip_address_details_t empty_ip_address_details = { {0} };
2634 ip_address_details_t *address = NULL;
2635 ip_details_t *current_ip_details = NULL;
2636 ip_details_t *details = NULL;
2638 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2640 if (!details || vam->current_sw_if_index >= vec_len (details)
2641 || !details[vam->current_sw_if_index].present)
2643 errmsg ("ip address details arrived but not stored");
2644 errmsg ("ip_dump should be called first");
2648 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2650 #define addresses (current_ip_details->addr)
2652 vec_validate_init_empty (addresses, vec_len (addresses),
2653 empty_ip_address_details);
2655 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2657 clib_memcpy (&address->ip, &mp->prefix.address.un, sizeof (address->ip));
2658 address->prefix_length = mp->prefix.len;
2662 static void vl_api_ip_address_details_t_handler_json
2663 (vl_api_ip_address_details_t * mp)
2665 vat_main_t *vam = &vat_main;
2666 vat_json_node_t *node = NULL;
2668 if (VAT_JSON_ARRAY != vam->json_tree.type)
2670 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2671 vat_json_init_array (&vam->json_tree);
2673 node = vat_json_array_add (&vam->json_tree);
2675 vat_json_init_object (node);
2676 vat_json_object_add_prefix (node, &mp->prefix);
2680 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2682 vat_main_t *vam = &vat_main;
2683 static ip_details_t empty_ip_details = { 0 };
2684 ip_details_t *ip = NULL;
2685 u32 sw_if_index = ~0;
2687 sw_if_index = ntohl (mp->sw_if_index);
2689 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2690 sw_if_index, empty_ip_details);
2692 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2699 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2701 vat_main_t *vam = &vat_main;
2703 if (VAT_JSON_ARRAY != vam->json_tree.type)
2705 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2706 vat_json_init_array (&vam->json_tree);
2708 vat_json_array_add_uint (&vam->json_tree,
2709 clib_net_to_host_u32 (mp->sw_if_index));
2712 static void vl_api_get_first_msg_id_reply_t_handler
2713 (vl_api_get_first_msg_id_reply_t * mp)
2715 vat_main_t *vam = &vat_main;
2716 i32 retval = ntohl (mp->retval);
2718 if (vam->async_mode)
2720 vam->async_errors += (retval < 0);
2724 vam->retval = retval;
2725 vam->result_ready = 1;
2729 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2733 static void vl_api_get_first_msg_id_reply_t_handler_json
2734 (vl_api_get_first_msg_id_reply_t * mp)
2736 vat_main_t *vam = &vat_main;
2737 vat_json_node_t node;
2739 vat_json_init_object (&node);
2740 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2741 vat_json_object_add_uint (&node, "first_msg_id",
2742 (uint) ntohs (mp->first_msg_id));
2744 vat_json_print (vam->ofp, &node);
2745 vat_json_free (&node);
2747 vam->retval = ntohl (mp->retval);
2748 vam->result_ready = 1;
2751 static void vl_api_get_node_graph_reply_t_handler
2752 (vl_api_get_node_graph_reply_t * mp)
2754 vat_main_t *vam = &vat_main;
2755 i32 retval = ntohl (mp->retval);
2756 u8 *pvt_copy, *reply;
2761 if (vam->async_mode)
2763 vam->async_errors += (retval < 0);
2767 vam->retval = retval;
2768 vam->result_ready = 1;
2771 /* "Should never happen..." */
2775 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2776 pvt_copy = vec_dup (reply);
2778 /* Toss the shared-memory original... */
2779 oldheap = vl_msg_push_heap ();
2783 vl_msg_pop_heap (oldheap);
2785 if (vam->graph_nodes)
2787 hash_free (vam->graph_node_index_by_name);
2789 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2791 node = vam->graph_nodes[0][i];
2792 vec_free (node->name);
2793 vec_free (node->next_nodes);
2796 vec_free (vam->graph_nodes[0]);
2797 vec_free (vam->graph_nodes);
2800 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2801 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2802 vec_free (pvt_copy);
2804 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2806 node = vam->graph_nodes[0][i];
2807 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2811 static void vl_api_get_node_graph_reply_t_handler_json
2812 (vl_api_get_node_graph_reply_t * mp)
2814 vat_main_t *vam = &vat_main;
2816 vat_json_node_t node;
2819 /* $$$$ make this real? */
2820 vat_json_init_object (&node);
2821 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2822 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2824 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2826 /* Toss the shared-memory original... */
2827 oldheap = vl_msg_push_heap ();
2831 vl_msg_pop_heap (oldheap);
2833 vat_json_print (vam->ofp, &node);
2834 vat_json_free (&node);
2836 vam->retval = ntohl (mp->retval);
2837 vam->result_ready = 1;
2841 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2843 vat_main_t *vam = &vat_main;
2848 s = format (s, "%=16d%=16d%=16d",
2849 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2853 s = format (s, "%=16U%=16d%=16d",
2854 format_ip46_address,
2855 mp->ip_address, mp->priority, mp->weight);
2858 print (vam->ofp, "%v", s);
2863 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2865 vat_main_t *vam = &vat_main;
2866 vat_json_node_t *node = NULL;
2867 struct in6_addr ip6;
2870 if (VAT_JSON_ARRAY != vam->json_tree.type)
2872 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2873 vat_json_init_array (&vam->json_tree);
2875 node = vat_json_array_add (&vam->json_tree);
2876 vat_json_init_object (node);
2878 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2879 vat_json_object_add_uint (node, "priority", mp->priority);
2880 vat_json_object_add_uint (node, "weight", mp->weight);
2883 vat_json_object_add_uint (node, "sw_if_index",
2884 clib_net_to_host_u32 (mp->sw_if_index));
2887 if (mp->ip_address.af)
2889 clib_memcpy (&ip6, mp->ip_address.un.ip6, sizeof (ip6));
2890 vat_json_object_add_ip6 (node, "address", ip6);
2894 clib_memcpy (&ip4, mp->ip_address.un.ip4, sizeof (ip4));
2895 vat_json_object_add_ip4 (node, "address", ip4);
2901 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2904 vat_main_t *vam = &vat_main;
2907 ls_name = format (0, "%s", mp->ls_name);
2909 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2915 vl_api_one_locator_set_details_t_handler_json
2916 (vl_api_one_locator_set_details_t * mp)
2918 vat_main_t *vam = &vat_main;
2919 vat_json_node_t *node = 0;
2922 ls_name = format (0, "%s", mp->ls_name);
2923 vec_add1 (ls_name, 0);
2925 if (VAT_JSON_ARRAY != vam->json_tree.type)
2927 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2928 vat_json_init_array (&vam->json_tree);
2930 node = vat_json_array_add (&vam->json_tree);
2932 vat_json_init_object (node);
2933 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2934 vat_json_object_add_uint (node, "ls_index",
2935 clib_net_to_host_u32 (mp->ls_index));
2943 } __attribute__ ((__packed__)) lisp_nsh_api_t;
2946 unformat_nsh_address (unformat_input_t * input, va_list * args)
2948 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
2949 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
2953 format_nsh_address_vat (u8 * s, va_list * args)
2955 nsh_t *a = va_arg (*args, nsh_t *);
2956 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
2960 format_lisp_flat_eid (u8 * s, va_list * args)
2962 vl_api_eid_t *eid = va_arg (*args, vl_api_eid_t *);
2966 case EID_TYPE_API_PREFIX:
2967 if (eid->address.prefix.address.af)
2968 return format (s, "%U/%d", format_ip6_address,
2969 eid->address.prefix.address.un.ip6,
2970 eid->address.prefix.len);
2971 return format (s, "%U/%d", format_ip4_address,
2972 eid->address.prefix.address.un.ip4,
2973 eid->address.prefix.len);
2974 case EID_TYPE_API_MAC:
2975 return format (s, "%U", format_ethernet_address, eid->address.mac);
2976 case EID_TYPE_API_NSH:
2977 return format (s, "%U", format_nsh_address_vat, eid->address.nsh);
2983 format_lisp_eid_vat (u8 * s, va_list * args)
2985 vl_api_eid_t *deid = va_arg (*args, vl_api_eid_t *);
2986 vl_api_eid_t *seid = va_arg (*args, vl_api_eid_t *);
2987 u8 is_src_dst = (u8) va_arg (*args, int);
2990 s = format (s, "%U|", format_lisp_flat_eid, seid);
2992 s = format (s, "%U", format_lisp_flat_eid, deid);
2998 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
3000 vat_main_t *vam = &vat_main;
3001 u8 *s = 0, *eid = 0;
3003 if (~0 == mp->locator_set_index)
3004 s = format (0, "action: %d", mp->action);
3006 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3008 eid = format (0, "%U", format_lisp_eid_vat,
3009 &mp->deid, &mp->seid, mp->is_src_dst);
3012 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3013 clib_net_to_host_u32 (mp->vni),
3015 mp->is_local ? "local" : "remote",
3016 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3017 clib_net_to_host_u16 (mp->key.id), mp->key.key);
3024 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3027 vat_main_t *vam = &vat_main;
3028 vat_json_node_t *node = 0;
3031 if (VAT_JSON_ARRAY != vam->json_tree.type)
3033 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3034 vat_json_init_array (&vam->json_tree);
3036 node = vat_json_array_add (&vam->json_tree);
3038 vat_json_init_object (node);
3039 if (~0 == mp->locator_set_index)
3040 vat_json_object_add_uint (node, "action", mp->action);
3042 vat_json_object_add_uint (node, "locator_set_index",
3043 clib_net_to_host_u32 (mp->locator_set_index));
3045 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3046 if (mp->deid.type == 3)
3048 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3049 vat_json_init_object (nsh_json);
3050 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) & mp->deid.address.nsh;
3051 vat_json_object_add_uint (nsh_json, "spi",
3052 clib_net_to_host_u32 (nsh->spi));
3053 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3057 eid = format (0, "%U", format_lisp_eid_vat,
3058 &mp->deid, &mp->seid, mp->is_src_dst);
3060 vat_json_object_add_string_copy (node, "eid", eid);
3063 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3064 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3065 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3069 vat_json_object_add_uint (node, "key_id",
3070 clib_net_to_host_u16 (mp->key.id));
3071 vat_json_object_add_string_copy (node, "key", mp->key.key);
3076 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3078 vat_main_t *vam = &vat_main;
3079 u8 *seid = 0, *deid = 0;
3080 ip46_address_t lloc, rloc;
3082 deid = format (0, "%U", format_lisp_eid_vat, &mp->deid, 0, 0);
3084 seid = format (0, "%U", format_lisp_eid_vat, &mp->seid, 0, 0);
3091 clib_memcpy (&lloc.ip6, mp->lloc.un.ip6, 16);
3092 clib_memcpy (&rloc.ip6, mp->rloc.un.ip6, 16);
3096 clib_memcpy (&lloc.ip4, mp->lloc.un.ip4, 4);
3097 clib_memcpy (&rloc.ip4, mp->rloc.un.ip4, 4);
3101 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3102 clib_net_to_host_u32 (mp->vni),
3104 format_ip46_address, lloc,
3105 format_ip46_address, rloc,
3106 clib_net_to_host_u32 (mp->pkt_count),
3107 clib_net_to_host_u32 (mp->bytes));
3114 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3116 struct in6_addr ip6;
3118 vat_main_t *vam = &vat_main;
3119 vat_json_node_t *node = 0;
3120 u8 *deid = 0, *seid = 0;
3122 if (VAT_JSON_ARRAY != vam->json_tree.type)
3124 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3125 vat_json_init_array (&vam->json_tree);
3127 node = vat_json_array_add (&vam->json_tree);
3129 vat_json_init_object (node);
3130 deid = format (0, "%U", format_lisp_eid_vat, &mp->deid, 0, 0);
3132 seid = format (0, "%U", format_lisp_eid_vat, &mp->seid, 0, 0);
3137 vat_json_object_add_string_copy (node, "seid", seid);
3138 vat_json_object_add_string_copy (node, "deid", deid);
3139 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3143 clib_memcpy (&ip6, mp->lloc.un.ip6, sizeof (ip6));
3144 vat_json_object_add_ip6 (node, "lloc", ip6);
3145 clib_memcpy (&ip6, mp->rloc.un.ip6, sizeof (ip6));
3146 vat_json_object_add_ip6 (node, "rloc", ip6);
3151 clib_memcpy (&ip4, mp->lloc.un.ip4, sizeof (ip4));
3152 vat_json_object_add_ip4 (node, "lloc", ip4);
3153 clib_memcpy (&ip4, mp->rloc.un.ip4, sizeof (ip4));
3154 vat_json_object_add_ip4 (node, "rloc", ip4);
3156 vat_json_object_add_uint (node, "pkt_count",
3157 clib_net_to_host_u32 (mp->pkt_count));
3158 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3165 vl_api_one_eid_table_map_details_t_handler
3166 (vl_api_one_eid_table_map_details_t * mp)
3168 vat_main_t *vam = &vat_main;
3170 u8 *line = format (0, "%=10d%=10d",
3171 clib_net_to_host_u32 (mp->vni),
3172 clib_net_to_host_u32 (mp->dp_table));
3173 print (vam->ofp, "%v", line);
3178 vl_api_one_eid_table_map_details_t_handler_json
3179 (vl_api_one_eid_table_map_details_t * mp)
3181 vat_main_t *vam = &vat_main;
3182 vat_json_node_t *node = NULL;
3184 if (VAT_JSON_ARRAY != vam->json_tree.type)
3186 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3187 vat_json_init_array (&vam->json_tree);
3189 node = vat_json_array_add (&vam->json_tree);
3190 vat_json_init_object (node);
3191 vat_json_object_add_uint (node, "dp_table",
3192 clib_net_to_host_u32 (mp->dp_table));
3193 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3197 vl_api_one_eid_table_vni_details_t_handler
3198 (vl_api_one_eid_table_vni_details_t * mp)
3200 vat_main_t *vam = &vat_main;
3202 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3203 print (vam->ofp, "%v", line);
3208 vl_api_one_eid_table_vni_details_t_handler_json
3209 (vl_api_one_eid_table_vni_details_t * mp)
3211 vat_main_t *vam = &vat_main;
3212 vat_json_node_t *node = NULL;
3214 if (VAT_JSON_ARRAY != vam->json_tree.type)
3216 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3217 vat_json_init_array (&vam->json_tree);
3219 node = vat_json_array_add (&vam->json_tree);
3220 vat_json_init_object (node);
3221 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3225 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3226 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3228 vat_main_t *vam = &vat_main;
3229 int retval = clib_net_to_host_u32 (mp->retval);
3231 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3232 print (vam->ofp, "fallback threshold value: %d", mp->value);
3234 vam->retval = retval;
3235 vam->result_ready = 1;
3239 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3240 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3242 vat_main_t *vam = &vat_main;
3243 vat_json_node_t _node, *node = &_node;
3244 int retval = clib_net_to_host_u32 (mp->retval);
3246 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3247 vat_json_init_object (node);
3248 vat_json_object_add_uint (node, "value", mp->value);
3250 vat_json_print (vam->ofp, node);
3251 vat_json_free (node);
3253 vam->retval = retval;
3254 vam->result_ready = 1;
3258 vl_api_show_one_map_register_state_reply_t_handler
3259 (vl_api_show_one_map_register_state_reply_t * mp)
3261 vat_main_t *vam = &vat_main;
3262 int retval = clib_net_to_host_u32 (mp->retval);
3264 print (vam->ofp, "%s", mp->is_enable ? "enabled" : "disabled");
3266 vam->retval = retval;
3267 vam->result_ready = 1;
3271 vl_api_show_one_map_register_state_reply_t_handler_json
3272 (vl_api_show_one_map_register_state_reply_t * mp)
3274 vat_main_t *vam = &vat_main;
3275 vat_json_node_t _node, *node = &_node;
3276 int retval = clib_net_to_host_u32 (mp->retval);
3278 u8 *s = format (0, "%s", mp->is_enable ? "enabled" : "disabled");
3280 vat_json_init_object (node);
3281 vat_json_object_add_string_copy (node, "state", s);
3283 vat_json_print (vam->ofp, node);
3284 vat_json_free (node);
3286 vam->retval = retval;
3287 vam->result_ready = 1;
3292 vl_api_show_one_rloc_probe_state_reply_t_handler
3293 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3295 vat_main_t *vam = &vat_main;
3296 int retval = clib_net_to_host_u32 (mp->retval);
3301 print (vam->ofp, "%s", mp->is_enable ? "enabled" : "disabled");
3303 vam->retval = retval;
3304 vam->result_ready = 1;
3308 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3309 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3311 vat_main_t *vam = &vat_main;
3312 vat_json_node_t _node, *node = &_node;
3313 int retval = clib_net_to_host_u32 (mp->retval);
3315 u8 *s = format (0, "%s", mp->is_enable ? "enabled" : "disabled");
3316 vat_json_init_object (node);
3317 vat_json_object_add_string_copy (node, "state", s);
3319 vat_json_print (vam->ofp, node);
3320 vat_json_free (node);
3322 vam->retval = retval;
3323 vam->result_ready = 1;
3328 vl_api_show_one_stats_enable_disable_reply_t_handler
3329 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3331 vat_main_t *vam = &vat_main;
3332 int retval = clib_net_to_host_u32 (mp->retval);
3337 print (vam->ofp, "%s", mp->is_enable ? "enabled" : "disabled");
3339 vam->retval = retval;
3340 vam->result_ready = 1;
3344 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3345 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3347 vat_main_t *vam = &vat_main;
3348 vat_json_node_t _node, *node = &_node;
3349 int retval = clib_net_to_host_u32 (mp->retval);
3351 u8 *s = format (0, "%s", mp->is_enable ? "enabled" : "disabled");
3352 vat_json_init_object (node);
3353 vat_json_object_add_string_copy (node, "state", s);
3355 vat_json_print (vam->ofp, node);
3356 vat_json_free (node);
3358 vam->retval = retval;
3359 vam->result_ready = 1;
3364 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3366 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3367 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3368 e->vni = clib_net_to_host_u32 (e->vni);
3372 gpe_fwd_entries_get_reply_t_net_to_host
3373 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3377 mp->count = clib_net_to_host_u32 (mp->count);
3378 for (i = 0; i < mp->count; i++)
3380 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3385 format_gpe_encap_mode (u8 * s, va_list * args)
3387 u32 mode = va_arg (*args, u32);
3392 return format (s, "lisp");
3394 return format (s, "vxlan");
3400 vl_api_gpe_get_encap_mode_reply_t_handler
3401 (vl_api_gpe_get_encap_mode_reply_t * mp)
3403 vat_main_t *vam = &vat_main;
3405 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3406 vam->retval = ntohl (mp->retval);
3407 vam->result_ready = 1;
3411 vl_api_gpe_get_encap_mode_reply_t_handler_json
3412 (vl_api_gpe_get_encap_mode_reply_t * mp)
3414 vat_main_t *vam = &vat_main;
3415 vat_json_node_t node;
3417 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3418 vec_add1 (encap_mode, 0);
3420 vat_json_init_object (&node);
3421 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3423 vec_free (encap_mode);
3424 vat_json_print (vam->ofp, &node);
3425 vat_json_free (&node);
3427 vam->retval = ntohl (mp->retval);
3428 vam->result_ready = 1;
3432 vl_api_gpe_fwd_entry_path_details_t_handler
3433 (vl_api_gpe_fwd_entry_path_details_t * mp)
3435 vat_main_t *vam = &vat_main;
3436 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3438 if (mp->lcl_loc.addr.af)
3439 format_ip_address_fcn = format_ip6_address;
3441 format_ip_address_fcn = format_ip4_address;
3443 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3444 format_ip_address_fcn, &mp->lcl_loc.addr.un,
3445 format_ip_address_fcn, &mp->rmt_loc.addr.un);
3449 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3451 struct in6_addr ip6;
3456 clib_memcpy (&ip6, loc->addr.un.ip6, sizeof (ip6));
3457 vat_json_object_add_ip6 (n, "address", ip6);
3461 clib_memcpy (&ip4, loc->addr.un.ip4, sizeof (ip4));
3462 vat_json_object_add_ip4 (n, "address", ip4);
3464 vat_json_object_add_uint (n, "weight", loc->weight);
3468 vl_api_gpe_fwd_entry_path_details_t_handler_json
3469 (vl_api_gpe_fwd_entry_path_details_t * mp)
3471 vat_main_t *vam = &vat_main;
3472 vat_json_node_t *node = NULL;
3473 vat_json_node_t *loc_node;
3475 if (VAT_JSON_ARRAY != vam->json_tree.type)
3477 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3478 vat_json_init_array (&vam->json_tree);
3480 node = vat_json_array_add (&vam->json_tree);
3481 vat_json_init_object (node);
3483 loc_node = vat_json_object_add (node, "local_locator");
3484 vat_json_init_object (loc_node);
3485 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3487 loc_node = vat_json_object_add (node, "remote_locator");
3488 vat_json_init_object (loc_node);
3489 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3493 vl_api_gpe_fwd_entries_get_reply_t_handler
3494 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3496 vat_main_t *vam = &vat_main;
3498 int retval = clib_net_to_host_u32 (mp->retval);
3499 vl_api_gpe_fwd_entry_t *e;
3504 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3506 for (i = 0; i < mp->count; i++)
3508 e = &mp->entries[i];
3509 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3510 format_lisp_flat_eid, e->leid, format_lisp_flat_eid, e->reid);
3514 vam->retval = retval;
3515 vam->result_ready = 1;
3519 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3520 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3523 vat_main_t *vam = &vat_main;
3524 vat_json_node_t *e = 0, root;
3526 int retval = clib_net_to_host_u32 (mp->retval);
3527 vl_api_gpe_fwd_entry_t *fwd;
3532 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3533 vat_json_init_array (&root);
3535 for (i = 0; i < mp->count; i++)
3537 e = vat_json_array_add (&root);
3538 fwd = &mp->entries[i];
3540 vat_json_init_object (e);
3541 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3542 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3543 vat_json_object_add_int (e, "vni", fwd->vni);
3544 vat_json_object_add_int (e, "action", fwd->action);
3546 s = format (0, "%U", format_lisp_flat_eid, fwd->leid);
3548 vat_json_object_add_string_copy (e, "leid", s);
3551 s = format (0, "%U", format_lisp_flat_eid, fwd->reid);
3553 vat_json_object_add_string_copy (e, "reid", s);
3557 vat_json_print (vam->ofp, &root);
3558 vat_json_free (&root);
3561 vam->retval = retval;
3562 vam->result_ready = 1;
3566 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3567 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3569 vat_main_t *vam = &vat_main;
3571 int retval = clib_net_to_host_u32 (mp->retval);
3572 vl_api_gpe_native_fwd_rpath_t *r;
3577 n = clib_net_to_host_u32 (mp->count);
3579 for (i = 0; i < n; i++)
3581 r = &mp->entries[i];
3582 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3583 clib_net_to_host_u32 (r->fib_index),
3584 clib_net_to_host_u32 (r->nh_sw_if_index),
3585 r->nh_addr.af ? format_ip6_address : format_ip4_address,
3590 vam->retval = retval;
3591 vam->result_ready = 1;
3595 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3596 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3598 vat_main_t *vam = &vat_main;
3599 vat_json_node_t root, *e;
3601 int retval = clib_net_to_host_u32 (mp->retval);
3602 vl_api_gpe_native_fwd_rpath_t *r;
3608 n = clib_net_to_host_u32 (mp->count);
3609 vat_json_init_array (&root);
3611 for (i = 0; i < n; i++)
3613 e = vat_json_array_add (&root);
3614 vat_json_init_object (e);
3615 r = &mp->entries[i];
3618 r->nh_addr.af ? format_ip6_address : format_ip4_address,
3621 vat_json_object_add_string_copy (e, "ip4", s);
3624 vat_json_object_add_uint (e, "fib_index",
3625 clib_net_to_host_u32 (r->fib_index));
3626 vat_json_object_add_uint (e, "nh_sw_if_index",
3627 clib_net_to_host_u32 (r->nh_sw_if_index));
3630 vat_json_print (vam->ofp, &root);
3631 vat_json_free (&root);
3634 vam->retval = retval;
3635 vam->result_ready = 1;
3639 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3640 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3642 vat_main_t *vam = &vat_main;
3644 int retval = clib_net_to_host_u32 (mp->retval);
3649 n = clib_net_to_host_u32 (mp->count);
3651 for (i = 0; i < n; i++)
3652 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3655 vam->retval = retval;
3656 vam->result_ready = 1;
3660 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3661 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3663 vat_main_t *vam = &vat_main;
3664 vat_json_node_t root;
3666 int retval = clib_net_to_host_u32 (mp->retval);
3671 n = clib_net_to_host_u32 (mp->count);
3672 vat_json_init_array (&root);
3674 for (i = 0; i < n; i++)
3675 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3677 vat_json_print (vam->ofp, &root);
3678 vat_json_free (&root);
3681 vam->retval = retval;
3682 vam->result_ready = 1;
3686 vl_api_one_ndp_entries_get_reply_t_handler
3687 (vl_api_one_ndp_entries_get_reply_t * mp)
3689 vat_main_t *vam = &vat_main;
3691 int retval = clib_net_to_host_u32 (mp->retval);
3696 n = clib_net_to_host_u32 (mp->count);
3698 for (i = 0; i < n; i++)
3699 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3700 format_ethernet_address, mp->entries[i].mac);
3703 vam->retval = retval;
3704 vam->result_ready = 1;
3708 vl_api_one_ndp_entries_get_reply_t_handler_json
3709 (vl_api_one_ndp_entries_get_reply_t * mp)
3712 vat_main_t *vam = &vat_main;
3713 vat_json_node_t *e = 0, root;
3715 int retval = clib_net_to_host_u32 (mp->retval);
3716 vl_api_one_ndp_entry_t *arp_entry;
3721 n = clib_net_to_host_u32 (mp->count);
3722 vat_json_init_array (&root);
3724 for (i = 0; i < n; i++)
3726 e = vat_json_array_add (&root);
3727 arp_entry = &mp->entries[i];
3729 vat_json_init_object (e);
3730 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3733 vat_json_object_add_string_copy (e, "mac", s);
3736 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3738 vat_json_object_add_string_copy (e, "ip6", s);
3742 vat_json_print (vam->ofp, &root);
3743 vat_json_free (&root);
3746 vam->retval = retval;
3747 vam->result_ready = 1;
3751 vl_api_one_l2_arp_entries_get_reply_t_handler
3752 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3754 vat_main_t *vam = &vat_main;
3756 int retval = clib_net_to_host_u32 (mp->retval);
3761 n = clib_net_to_host_u32 (mp->count);
3763 for (i = 0; i < n; i++)
3764 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3765 format_ethernet_address, mp->entries[i].mac);
3768 vam->retval = retval;
3769 vam->result_ready = 1;
3773 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3774 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3777 vat_main_t *vam = &vat_main;
3778 vat_json_node_t *e = 0, root;
3780 int retval = clib_net_to_host_u32 (mp->retval);
3781 vl_api_one_l2_arp_entry_t *arp_entry;
3786 n = clib_net_to_host_u32 (mp->count);
3787 vat_json_init_array (&root);
3789 for (i = 0; i < n; i++)
3791 e = vat_json_array_add (&root);
3792 arp_entry = &mp->entries[i];
3794 vat_json_init_object (e);
3795 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3798 vat_json_object_add_string_copy (e, "mac", s);
3801 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3803 vat_json_object_add_string_copy (e, "ip4", s);
3807 vat_json_print (vam->ofp, &root);
3808 vat_json_free (&root);
3811 vam->retval = retval;
3812 vam->result_ready = 1;
3816 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
3818 vat_main_t *vam = &vat_main;
3820 int retval = clib_net_to_host_u32 (mp->retval);
3825 n = clib_net_to_host_u32 (mp->count);
3827 for (i = 0; i < n; i++)
3829 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3833 vam->retval = retval;
3834 vam->result_ready = 1;
3838 vl_api_one_ndp_bd_get_reply_t_handler_json
3839 (vl_api_one_ndp_bd_get_reply_t * mp)
3841 vat_main_t *vam = &vat_main;
3842 vat_json_node_t root;
3844 int retval = clib_net_to_host_u32 (mp->retval);
3849 n = clib_net_to_host_u32 (mp->count);
3850 vat_json_init_array (&root);
3852 for (i = 0; i < n; i++)
3854 vat_json_array_add_uint (&root,
3855 clib_net_to_host_u32 (mp->bridge_domains[i]));
3858 vat_json_print (vam->ofp, &root);
3859 vat_json_free (&root);
3862 vam->retval = retval;
3863 vam->result_ready = 1;
3867 vl_api_one_l2_arp_bd_get_reply_t_handler
3868 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3870 vat_main_t *vam = &vat_main;
3872 int retval = clib_net_to_host_u32 (mp->retval);
3877 n = clib_net_to_host_u32 (mp->count);
3879 for (i = 0; i < n; i++)
3881 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3885 vam->retval = retval;
3886 vam->result_ready = 1;
3890 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3891 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3893 vat_main_t *vam = &vat_main;
3894 vat_json_node_t root;
3896 int retval = clib_net_to_host_u32 (mp->retval);
3901 n = clib_net_to_host_u32 (mp->count);
3902 vat_json_init_array (&root);
3904 for (i = 0; i < n; i++)
3906 vat_json_array_add_uint (&root,
3907 clib_net_to_host_u32 (mp->bridge_domains[i]));
3910 vat_json_print (vam->ofp, &root);
3911 vat_json_free (&root);
3914 vam->retval = retval;
3915 vam->result_ready = 1;
3919 vl_api_one_adjacencies_get_reply_t_handler
3920 (vl_api_one_adjacencies_get_reply_t * mp)
3922 vat_main_t *vam = &vat_main;
3924 int retval = clib_net_to_host_u32 (mp->retval);
3925 vl_api_one_adjacency_t *a;
3930 n = clib_net_to_host_u32 (mp->count);
3932 for (i = 0; i < n; i++)
3934 a = &mp->adjacencies[i];
3935 print (vam->ofp, "%U %40U",
3936 format_lisp_flat_eid, a->leid, format_lisp_flat_eid, a->reid);
3940 vam->retval = retval;
3941 vam->result_ready = 1;
3945 vl_api_one_adjacencies_get_reply_t_handler_json
3946 (vl_api_one_adjacencies_get_reply_t * mp)
3949 vat_main_t *vam = &vat_main;
3950 vat_json_node_t *e = 0, root;
3952 int retval = clib_net_to_host_u32 (mp->retval);
3953 vl_api_one_adjacency_t *a;
3958 n = clib_net_to_host_u32 (mp->count);
3959 vat_json_init_array (&root);
3961 for (i = 0; i < n; i++)
3963 e = vat_json_array_add (&root);
3964 a = &mp->adjacencies[i];
3966 vat_json_init_object (e);
3967 s = format (0, "%U", format_lisp_flat_eid, a->leid);
3969 vat_json_object_add_string_copy (e, "leid", s);
3972 s = format (0, "%U", format_lisp_flat_eid, a->reid);
3974 vat_json_object_add_string_copy (e, "reid", s);
3978 vat_json_print (vam->ofp, &root);
3979 vat_json_free (&root);
3982 vam->retval = retval;
3983 vam->result_ready = 1;
3987 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
3989 vat_main_t *vam = &vat_main;
3991 print (vam->ofp, "%=20U",
3992 mp->ip_address.af ? format_ip6_address : format_ip4_address,
3997 vl_api_one_map_server_details_t_handler_json
3998 (vl_api_one_map_server_details_t * mp)
4000 vat_main_t *vam = &vat_main;
4001 vat_json_node_t *node = NULL;
4002 struct in6_addr ip6;
4005 if (VAT_JSON_ARRAY != vam->json_tree.type)
4007 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4008 vat_json_init_array (&vam->json_tree);
4010 node = vat_json_array_add (&vam->json_tree);
4012 vat_json_init_object (node);
4013 if (mp->ip_address.af)
4015 clib_memcpy (&ip6, mp->ip_address.un.ip6, sizeof (ip6));
4016 vat_json_object_add_ip6 (node, "map-server", ip6);
4020 clib_memcpy (&ip4, mp->ip_address.un.ip4, sizeof (ip4));
4021 vat_json_object_add_ip4 (node, "map-server", ip4);
4026 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4029 vat_main_t *vam = &vat_main;
4031 print (vam->ofp, "%=20U",
4032 mp->ip_address.af ? format_ip6_address : format_ip4_address,
4037 vl_api_one_map_resolver_details_t_handler_json
4038 (vl_api_one_map_resolver_details_t * mp)
4040 vat_main_t *vam = &vat_main;
4041 vat_json_node_t *node = NULL;
4042 struct in6_addr ip6;
4045 if (VAT_JSON_ARRAY != vam->json_tree.type)
4047 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4048 vat_json_init_array (&vam->json_tree);
4050 node = vat_json_array_add (&vam->json_tree);
4052 vat_json_init_object (node);
4053 if (mp->ip_address.af)
4055 clib_memcpy (&ip6, mp->ip_address.un.ip6, sizeof (ip6));
4056 vat_json_object_add_ip6 (node, "map resolver", ip6);
4060 clib_memcpy (&ip4, mp->ip_address.un.ip4, sizeof (ip4));
4061 vat_json_object_add_ip4 (node, "map resolver", ip4);
4066 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4068 vat_main_t *vam = &vat_main;
4069 i32 retval = ntohl (mp->retval);
4073 print (vam->ofp, "feature: %s\ngpe: %s",
4074 mp->feature_status ? "enabled" : "disabled",
4075 mp->gpe_status ? "enabled" : "disabled");
4078 vam->retval = retval;
4079 vam->result_ready = 1;
4083 vl_api_show_one_status_reply_t_handler_json
4084 (vl_api_show_one_status_reply_t * mp)
4086 vat_main_t *vam = &vat_main;
4087 vat_json_node_t node;
4088 u8 *gpe_status = NULL;
4089 u8 *feature_status = NULL;
4091 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4092 feature_status = format (0, "%s",
4093 mp->feature_status ? "enabled" : "disabled");
4094 vec_add1 (gpe_status, 0);
4095 vec_add1 (feature_status, 0);
4097 vat_json_init_object (&node);
4098 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4099 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4101 vec_free (gpe_status);
4102 vec_free (feature_status);
4104 vat_json_print (vam->ofp, &node);
4105 vat_json_free (&node);
4107 vam->retval = ntohl (mp->retval);
4108 vam->result_ready = 1;
4112 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4113 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4115 vat_main_t *vam = &vat_main;
4116 i32 retval = ntohl (mp->retval);
4120 print (vam->ofp, "%=20s", mp->locator_set_name);
4123 vam->retval = retval;
4124 vam->result_ready = 1;
4128 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4129 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4131 vat_main_t *vam = &vat_main;
4132 vat_json_node_t *node = NULL;
4134 if (VAT_JSON_ARRAY != vam->json_tree.type)
4136 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4137 vat_json_init_array (&vam->json_tree);
4139 node = vat_json_array_add (&vam->json_tree);
4141 vat_json_init_object (node);
4142 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4144 vat_json_print (vam->ofp, node);
4145 vat_json_free (node);
4147 vam->retval = ntohl (mp->retval);
4148 vam->result_ready = 1;
4152 format_lisp_map_request_mode (u8 * s, va_list * args)
4154 u32 mode = va_arg (*args, u32);
4159 return format (0, "dst-only");
4161 return format (0, "src-dst");
4167 vl_api_show_one_map_request_mode_reply_t_handler
4168 (vl_api_show_one_map_request_mode_reply_t * mp)
4170 vat_main_t *vam = &vat_main;
4171 i32 retval = ntohl (mp->retval);
4175 u32 mode = mp->mode;
4176 print (vam->ofp, "map_request_mode: %U",
4177 format_lisp_map_request_mode, mode);
4180 vam->retval = retval;
4181 vam->result_ready = 1;
4185 vl_api_show_one_map_request_mode_reply_t_handler_json
4186 (vl_api_show_one_map_request_mode_reply_t * mp)
4188 vat_main_t *vam = &vat_main;
4189 vat_json_node_t node;
4194 s = format (0, "%U", format_lisp_map_request_mode, mode);
4197 vat_json_init_object (&node);
4198 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4199 vat_json_print (vam->ofp, &node);
4200 vat_json_free (&node);
4203 vam->retval = ntohl (mp->retval);
4204 vam->result_ready = 1;
4208 vl_api_one_show_xtr_mode_reply_t_handler
4209 (vl_api_one_show_xtr_mode_reply_t * mp)
4211 vat_main_t *vam = &vat_main;
4212 i32 retval = ntohl (mp->retval);
4216 print (vam->ofp, "%s\n", mp->is_enable ? "enabled" : "disabled");
4219 vam->retval = retval;
4220 vam->result_ready = 1;
4224 vl_api_one_show_xtr_mode_reply_t_handler_json
4225 (vl_api_one_show_xtr_mode_reply_t * mp)
4227 vat_main_t *vam = &vat_main;
4228 vat_json_node_t node;
4231 status = format (0, "%s", mp->is_enable ? "enabled" : "disabled");
4232 vec_add1 (status, 0);
4234 vat_json_init_object (&node);
4235 vat_json_object_add_string_copy (&node, "status", status);
4239 vat_json_print (vam->ofp, &node);
4240 vat_json_free (&node);
4242 vam->retval = ntohl (mp->retval);
4243 vam->result_ready = 1;
4247 vl_api_one_show_pitr_mode_reply_t_handler
4248 (vl_api_one_show_pitr_mode_reply_t * mp)
4250 vat_main_t *vam = &vat_main;
4251 i32 retval = ntohl (mp->retval);
4255 print (vam->ofp, "%s\n", mp->is_enable ? "enabled" : "disabled");
4258 vam->retval = retval;
4259 vam->result_ready = 1;
4263 vl_api_one_show_pitr_mode_reply_t_handler_json
4264 (vl_api_one_show_pitr_mode_reply_t * mp)
4266 vat_main_t *vam = &vat_main;
4267 vat_json_node_t node;
4270 status = format (0, "%s", mp->is_enable ? "enabled" : "disabled");
4271 vec_add1 (status, 0);
4273 vat_json_init_object (&node);
4274 vat_json_object_add_string_copy (&node, "status", status);
4278 vat_json_print (vam->ofp, &node);
4279 vat_json_free (&node);
4281 vam->retval = ntohl (mp->retval);
4282 vam->result_ready = 1;
4286 vl_api_one_show_petr_mode_reply_t_handler
4287 (vl_api_one_show_petr_mode_reply_t * mp)
4289 vat_main_t *vam = &vat_main;
4290 i32 retval = ntohl (mp->retval);
4294 print (vam->ofp, "%s\n", mp->is_enable ? "enabled" : "disabled");
4297 vam->retval = retval;
4298 vam->result_ready = 1;
4302 vl_api_one_show_petr_mode_reply_t_handler_json
4303 (vl_api_one_show_petr_mode_reply_t * mp)
4305 vat_main_t *vam = &vat_main;
4306 vat_json_node_t node;
4309 status = format (0, "%s", mp->is_enable ? "enabled" : "disabled");
4310 vec_add1 (status, 0);
4312 vat_json_init_object (&node);
4313 vat_json_object_add_string_copy (&node, "status", status);
4317 vat_json_print (vam->ofp, &node);
4318 vat_json_free (&node);
4320 vam->retval = ntohl (mp->retval);
4321 vam->result_ready = 1;
4325 vl_api_show_one_use_petr_reply_t_handler
4326 (vl_api_show_one_use_petr_reply_t * mp)
4328 vat_main_t *vam = &vat_main;
4329 i32 retval = ntohl (mp->retval);
4333 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4336 print (vam->ofp, "Proxy-ETR address; %U",
4337 mp->ip_address.af ? format_ip6_address : format_ip4_address,
4342 vam->retval = retval;
4343 vam->result_ready = 1;
4347 vl_api_show_one_use_petr_reply_t_handler_json
4348 (vl_api_show_one_use_petr_reply_t * mp)
4350 vat_main_t *vam = &vat_main;
4351 vat_json_node_t node;
4354 struct in6_addr ip6;
4356 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4357 vec_add1 (status, 0);
4359 vat_json_init_object (&node);
4360 vat_json_object_add_string_copy (&node, "status", status);
4363 if (mp->ip_address.af)
4365 clib_memcpy (&ip6, mp->ip_address.un.ip6, sizeof (ip6));
4366 vat_json_object_add_ip6 (&node, "address", ip6);
4370 clib_memcpy (&ip4, mp->ip_address.un.ip4, sizeof (ip4));
4371 vat_json_object_add_ip4 (&node, "address", ip4);
4377 vat_json_print (vam->ofp, &node);
4378 vat_json_free (&node);
4380 vam->retval = ntohl (mp->retval);
4381 vam->result_ready = 1;
4385 vl_api_show_one_nsh_mapping_reply_t_handler
4386 (vl_api_show_one_nsh_mapping_reply_t * mp)
4388 vat_main_t *vam = &vat_main;
4389 i32 retval = ntohl (mp->retval);
4393 print (vam->ofp, "%-20s%-16s",
4394 mp->is_set ? "set" : "not-set",
4395 mp->is_set ? (char *) mp->locator_set_name : "");
4398 vam->retval = retval;
4399 vam->result_ready = 1;
4403 vl_api_show_one_nsh_mapping_reply_t_handler_json
4404 (vl_api_show_one_nsh_mapping_reply_t * mp)
4406 vat_main_t *vam = &vat_main;
4407 vat_json_node_t node;
4410 status = format (0, "%s", mp->is_set ? "yes" : "no");
4411 vec_add1 (status, 0);
4413 vat_json_init_object (&node);
4414 vat_json_object_add_string_copy (&node, "is_set", status);
4417 vat_json_object_add_string_copy (&node, "locator_set",
4418 mp->locator_set_name);
4423 vat_json_print (vam->ofp, &node);
4424 vat_json_free (&node);
4426 vam->retval = ntohl (mp->retval);
4427 vam->result_ready = 1;
4431 vl_api_show_one_map_register_ttl_reply_t_handler
4432 (vl_api_show_one_map_register_ttl_reply_t * mp)
4434 vat_main_t *vam = &vat_main;
4435 i32 retval = ntohl (mp->retval);
4437 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4441 print (vam->ofp, "ttl: %u", mp->ttl);
4444 vam->retval = retval;
4445 vam->result_ready = 1;
4449 vl_api_show_one_map_register_ttl_reply_t_handler_json
4450 (vl_api_show_one_map_register_ttl_reply_t * mp)
4452 vat_main_t *vam = &vat_main;
4453 vat_json_node_t node;
4455 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4456 vat_json_init_object (&node);
4457 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4459 vat_json_print (vam->ofp, &node);
4460 vat_json_free (&node);
4462 vam->retval = ntohl (mp->retval);
4463 vam->result_ready = 1;
4467 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4469 vat_main_t *vam = &vat_main;
4470 i32 retval = ntohl (mp->retval);
4474 print (vam->ofp, "%-20s%-16s",
4475 mp->status ? "enabled" : "disabled",
4476 mp->status ? (char *) mp->locator_set_name : "");
4479 vam->retval = retval;
4480 vam->result_ready = 1;
4484 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4486 vat_main_t *vam = &vat_main;
4487 vat_json_node_t node;
4490 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4491 vec_add1 (status, 0);
4493 vat_json_init_object (&node);
4494 vat_json_object_add_string_copy (&node, "status", status);
4497 vat_json_object_add_string_copy (&node, "locator_set",
4498 mp->locator_set_name);
4503 vat_json_print (vam->ofp, &node);
4504 vat_json_free (&node);
4506 vam->retval = ntohl (mp->retval);
4507 vam->result_ready = 1;
4511 format_policer_type (u8 * s, va_list * va)
4513 u32 i = va_arg (*va, u32);
4515 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4516 s = format (s, "1r2c");
4517 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4518 s = format (s, "1r3c");
4519 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4520 s = format (s, "2r3c-2698");
4521 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4522 s = format (s, "2r3c-4115");
4523 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4524 s = format (s, "2r3c-mef5cf1");
4526 s = format (s, "ILLEGAL");
4531 format_policer_rate_type (u8 * s, va_list * va)
4533 u32 i = va_arg (*va, u32);
4535 if (i == SSE2_QOS_RATE_KBPS)
4536 s = format (s, "kbps");
4537 else if (i == SSE2_QOS_RATE_PPS)
4538 s = format (s, "pps");
4540 s = format (s, "ILLEGAL");
4545 format_policer_round_type (u8 * s, va_list * va)
4547 u32 i = va_arg (*va, u32);
4549 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4550 s = format (s, "closest");
4551 else if (i == SSE2_QOS_ROUND_TO_UP)
4552 s = format (s, "up");
4553 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4554 s = format (s, "down");
4556 s = format (s, "ILLEGAL");
4561 format_policer_action_type (u8 * s, va_list * va)
4563 u32 i = va_arg (*va, u32);
4565 if (i == SSE2_QOS_ACTION_DROP)
4566 s = format (s, "drop");
4567 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4568 s = format (s, "transmit");
4569 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4570 s = format (s, "mark-and-transmit");
4572 s = format (s, "ILLEGAL");
4577 format_dscp (u8 * s, va_list * va)
4579 u32 i = va_arg (*va, u32);
4584 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4588 return format (s, "ILLEGAL");
4590 s = format (s, "%s", t);
4595 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4597 vat_main_t *vam = &vat_main;
4598 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4600 if (mp->conform_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
4601 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_action.dscp);
4603 conform_dscp_str = format (0, "");
4605 if (mp->exceed_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
4606 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_action.dscp);
4608 exceed_dscp_str = format (0, "");
4610 if (mp->violate_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
4611 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_action.dscp);
4613 violate_dscp_str = format (0, "");
4615 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4616 "rate type %U, round type %U, %s rate, %s color-aware, "
4617 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4618 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4619 "conform action %U%s, exceed action %U%s, violate action %U%s",
4621 format_policer_type, mp->type,
4624 clib_net_to_host_u64 (mp->cb),
4625 clib_net_to_host_u64 (mp->eb),
4626 format_policer_rate_type, mp->rate_type,
4627 format_policer_round_type, mp->round_type,
4628 mp->single_rate ? "single" : "dual",
4629 mp->color_aware ? "is" : "not",
4630 ntohl (mp->cir_tokens_per_period),
4631 ntohl (mp->pir_tokens_per_period),
4633 ntohl (mp->current_limit),
4634 ntohl (mp->current_bucket),
4635 ntohl (mp->extended_limit),
4636 ntohl (mp->extended_bucket),
4637 clib_net_to_host_u64 (mp->last_update_time),
4638 format_policer_action_type, mp->conform_action.type,
4640 format_policer_action_type, mp->exceed_action.type,
4642 format_policer_action_type, mp->violate_action.type,
4645 vec_free (conform_dscp_str);
4646 vec_free (exceed_dscp_str);
4647 vec_free (violate_dscp_str);
4650 static void vl_api_policer_details_t_handler_json
4651 (vl_api_policer_details_t * mp)
4653 vat_main_t *vam = &vat_main;
4654 vat_json_node_t *node;
4655 u8 *rate_type_str, *round_type_str, *type_str;
4656 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4658 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4660 format (0, "%U", format_policer_round_type, mp->round_type);
4661 type_str = format (0, "%U", format_policer_type, mp->type);
4662 conform_action_str = format (0, "%U", format_policer_action_type,
4663 mp->conform_action.type);
4664 exceed_action_str = format (0, "%U", format_policer_action_type,
4665 mp->exceed_action.type);
4666 violate_action_str = format (0, "%U", format_policer_action_type,
4667 mp->violate_action.type);
4669 if (VAT_JSON_ARRAY != vam->json_tree.type)
4671 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4672 vat_json_init_array (&vam->json_tree);
4674 node = vat_json_array_add (&vam->json_tree);
4676 vat_json_init_object (node);
4677 vat_json_object_add_string_copy (node, "name", mp->name);
4678 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4679 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4680 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4681 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4682 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4683 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4684 vat_json_object_add_string_copy (node, "type", type_str);
4685 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4686 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4687 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4688 vat_json_object_add_uint (node, "cir_tokens_per_period",
4689 ntohl (mp->cir_tokens_per_period));
4690 vat_json_object_add_uint (node, "eir_tokens_per_period",
4691 ntohl (mp->pir_tokens_per_period));
4692 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4693 vat_json_object_add_uint (node, "current_bucket",
4694 ntohl (mp->current_bucket));
4695 vat_json_object_add_uint (node, "extended_limit",
4696 ntohl (mp->extended_limit));
4697 vat_json_object_add_uint (node, "extended_bucket",
4698 ntohl (mp->extended_bucket));
4699 vat_json_object_add_uint (node, "last_update_time",
4700 ntohl (mp->last_update_time));
4701 vat_json_object_add_string_copy (node, "conform_action",
4702 conform_action_str);
4703 if (mp->conform_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
4705 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_action.dscp);
4706 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4707 vec_free (dscp_str);
4709 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4710 if (mp->exceed_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
4712 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_action.dscp);
4713 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4714 vec_free (dscp_str);
4716 vat_json_object_add_string_copy (node, "violate_action",
4717 violate_action_str);
4718 if (mp->violate_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
4720 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_action.dscp);
4721 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4722 vec_free (dscp_str);
4725 vec_free (rate_type_str);
4726 vec_free (round_type_str);
4727 vec_free (type_str);
4728 vec_free (conform_action_str);
4729 vec_free (exceed_action_str);
4730 vec_free (violate_action_str);
4734 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4737 vat_main_t *vam = &vat_main;
4738 int i, count = ntohl (mp->count);
4741 print (vam->ofp, "classify table ids (%d) : ", count);
4742 for (i = 0; i < count; i++)
4744 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4745 print (vam->ofp, (i < count - 1) ? "," : "");
4747 vam->retval = ntohl (mp->retval);
4748 vam->result_ready = 1;
4752 vl_api_classify_table_ids_reply_t_handler_json
4753 (vl_api_classify_table_ids_reply_t * mp)
4755 vat_main_t *vam = &vat_main;
4756 int i, count = ntohl (mp->count);
4760 vat_json_node_t node;
4762 vat_json_init_object (&node);
4763 for (i = 0; i < count; i++)
4765 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4767 vat_json_print (vam->ofp, &node);
4768 vat_json_free (&node);
4770 vam->retval = ntohl (mp->retval);
4771 vam->result_ready = 1;
4775 vl_api_classify_table_by_interface_reply_t_handler
4776 (vl_api_classify_table_by_interface_reply_t * mp)
4778 vat_main_t *vam = &vat_main;
4781 table_id = ntohl (mp->l2_table_id);
4783 print (vam->ofp, "l2 table id : %d", table_id);
4785 print (vam->ofp, "l2 table id : No input ACL tables configured");
4786 table_id = ntohl (mp->ip4_table_id);
4788 print (vam->ofp, "ip4 table id : %d", table_id);
4790 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4791 table_id = ntohl (mp->ip6_table_id);
4793 print (vam->ofp, "ip6 table id : %d", table_id);
4795 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4796 vam->retval = ntohl (mp->retval);
4797 vam->result_ready = 1;
4801 vl_api_classify_table_by_interface_reply_t_handler_json
4802 (vl_api_classify_table_by_interface_reply_t * mp)
4804 vat_main_t *vam = &vat_main;
4805 vat_json_node_t node;
4807 vat_json_init_object (&node);
4809 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4810 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4811 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4813 vat_json_print (vam->ofp, &node);
4814 vat_json_free (&node);
4816 vam->retval = ntohl (mp->retval);
4817 vam->result_ready = 1;
4820 static void vl_api_policer_add_del_reply_t_handler
4821 (vl_api_policer_add_del_reply_t * mp)
4823 vat_main_t *vam = &vat_main;
4824 i32 retval = ntohl (mp->retval);
4825 if (vam->async_mode)
4827 vam->async_errors += (retval < 0);
4831 vam->retval = retval;
4832 vam->result_ready = 1;
4833 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4835 * Note: this is just barely thread-safe, depends on
4836 * the main thread spinning waiting for an answer...
4838 errmsg ("policer index %d", ntohl (mp->policer_index));
4842 static void vl_api_policer_add_del_reply_t_handler_json
4843 (vl_api_policer_add_del_reply_t * mp)
4845 vat_main_t *vam = &vat_main;
4846 vat_json_node_t node;
4848 vat_json_init_object (&node);
4849 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4850 vat_json_object_add_uint (&node, "policer_index",
4851 ntohl (mp->policer_index));
4853 vat_json_print (vam->ofp, &node);
4854 vat_json_free (&node);
4856 vam->retval = ntohl (mp->retval);
4857 vam->result_ready = 1;
4860 /* Format hex dump. */
4862 format_hex_bytes (u8 * s, va_list * va)
4864 u8 *bytes = va_arg (*va, u8 *);
4865 int n_bytes = va_arg (*va, int);
4868 /* Print short or long form depending on byte count. */
4869 uword short_form = n_bytes <= 32;
4870 u32 indent = format_get_indent (s);
4875 for (i = 0; i < n_bytes; i++)
4877 if (!short_form && (i % 32) == 0)
4878 s = format (s, "%08x: ", i);
4879 s = format (s, "%02x", bytes[i]);
4880 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4881 s = format (s, "\n%U", format_white_space, indent);
4888 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4891 vat_main_t *vam = &vat_main;
4892 i32 retval = ntohl (mp->retval);
4895 print (vam->ofp, "classify table info :");
4896 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4897 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4898 ntohl (mp->miss_next_index));
4899 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4900 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4901 ntohl (mp->match_n_vectors));
4902 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4903 ntohl (mp->mask_length));
4905 vam->retval = retval;
4906 vam->result_ready = 1;
4910 vl_api_classify_table_info_reply_t_handler_json
4911 (vl_api_classify_table_info_reply_t * mp)
4913 vat_main_t *vam = &vat_main;
4914 vat_json_node_t node;
4916 i32 retval = ntohl (mp->retval);
4919 vat_json_init_object (&node);
4921 vat_json_object_add_int (&node, "sessions",
4922 ntohl (mp->active_sessions));
4923 vat_json_object_add_int (&node, "nexttbl",
4924 ntohl (mp->next_table_index));
4925 vat_json_object_add_int (&node, "nextnode",
4926 ntohl (mp->miss_next_index));
4927 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4928 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4929 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4930 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4931 ntohl (mp->mask_length), 0);
4932 vat_json_object_add_string_copy (&node, "mask", s);
4934 vat_json_print (vam->ofp, &node);
4935 vat_json_free (&node);
4937 vam->retval = ntohl (mp->retval);
4938 vam->result_ready = 1;
4942 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4945 vat_main_t *vam = &vat_main;
4947 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4948 ntohl (mp->hit_next_index), ntohl (mp->advance),
4949 ntohl (mp->opaque_index));
4950 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4951 ntohl (mp->match_length));
4955 vl_api_classify_session_details_t_handler_json
4956 (vl_api_classify_session_details_t * mp)
4958 vat_main_t *vam = &vat_main;
4959 vat_json_node_t *node = NULL;
4961 if (VAT_JSON_ARRAY != vam->json_tree.type)
4963 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4964 vat_json_init_array (&vam->json_tree);
4966 node = vat_json_array_add (&vam->json_tree);
4968 vat_json_init_object (node);
4969 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
4970 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
4971 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
4973 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
4975 vat_json_object_add_string_copy (node, "match", s);
4978 static void vl_api_pg_create_interface_reply_t_handler
4979 (vl_api_pg_create_interface_reply_t * mp)
4981 vat_main_t *vam = &vat_main;
4983 vam->retval = ntohl (mp->retval);
4984 vam->result_ready = 1;
4987 static void vl_api_pg_create_interface_reply_t_handler_json
4988 (vl_api_pg_create_interface_reply_t * mp)
4990 vat_main_t *vam = &vat_main;
4991 vat_json_node_t node;
4993 i32 retval = ntohl (mp->retval);
4996 vat_json_init_object (&node);
4998 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
5000 vat_json_print (vam->ofp, &node);
5001 vat_json_free (&node);
5003 vam->retval = ntohl (mp->retval);
5004 vam->result_ready = 1;
5007 static void vl_api_policer_classify_details_t_handler
5008 (vl_api_policer_classify_details_t * mp)
5010 vat_main_t *vam = &vat_main;
5012 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5013 ntohl (mp->table_index));
5016 static void vl_api_policer_classify_details_t_handler_json
5017 (vl_api_policer_classify_details_t * mp)
5019 vat_main_t *vam = &vat_main;
5020 vat_json_node_t *node;
5022 if (VAT_JSON_ARRAY != vam->json_tree.type)
5024 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5025 vat_json_init_array (&vam->json_tree);
5027 node = vat_json_array_add (&vam->json_tree);
5029 vat_json_init_object (node);
5030 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5031 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5034 static void vl_api_flow_classify_details_t_handler
5035 (vl_api_flow_classify_details_t * mp)
5037 vat_main_t *vam = &vat_main;
5039 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5040 ntohl (mp->table_index));
5043 static void vl_api_flow_classify_details_t_handler_json
5044 (vl_api_flow_classify_details_t * mp)
5046 vat_main_t *vam = &vat_main;
5047 vat_json_node_t *node;
5049 if (VAT_JSON_ARRAY != vam->json_tree.type)
5051 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5052 vat_json_init_array (&vam->json_tree);
5054 node = vat_json_array_add (&vam->json_tree);
5056 vat_json_init_object (node);
5057 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5058 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5061 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5062 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5063 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5064 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5065 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5066 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5067 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5068 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5069 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5070 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5073 * Generate boilerplate reply handlers, which
5074 * dig the return value out of the xxx_reply_t API message,
5075 * stick it into vam->retval, and set vam->result_ready
5077 * Could also do this by pointing N message decode slots at
5078 * a single function, but that could break in subtle ways.
5081 #define foreach_standard_reply_retval_handler \
5082 _(sw_interface_set_flags_reply) \
5083 _(sw_interface_add_del_address_reply) \
5084 _(sw_interface_set_rx_mode_reply) \
5085 _(sw_interface_set_rx_placement_reply) \
5086 _(sw_interface_set_table_reply) \
5087 _(sw_interface_set_mpls_enable_reply) \
5088 _(sw_interface_set_vpath_reply) \
5089 _(sw_interface_set_vxlan_bypass_reply) \
5090 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5091 _(sw_interface_set_l2_bridge_reply) \
5092 _(sw_interface_set_bond_weight_reply) \
5093 _(bridge_domain_add_del_reply) \
5094 _(sw_interface_set_l2_xconnect_reply) \
5095 _(l2fib_add_del_reply) \
5096 _(l2fib_flush_int_reply) \
5097 _(l2fib_flush_bd_reply) \
5098 _(ip_route_add_del_reply) \
5099 _(ip_table_add_del_reply) \
5100 _(ip_table_replace_begin_reply) \
5101 _(ip_table_flush_reply) \
5102 _(ip_table_replace_end_reply) \
5103 _(ip_mroute_add_del_reply) \
5104 _(mpls_route_add_del_reply) \
5105 _(mpls_table_add_del_reply) \
5106 _(mpls_ip_bind_unbind_reply) \
5107 _(bier_route_add_del_reply) \
5108 _(bier_table_add_del_reply) \
5109 _(sw_interface_set_unnumbered_reply) \
5110 _(set_ip_flow_hash_reply) \
5111 _(sw_interface_ip6_enable_disable_reply) \
5112 _(l2_patch_add_del_reply) \
5113 _(sr_mpls_policy_add_reply) \
5114 _(sr_mpls_policy_mod_reply) \
5115 _(sr_mpls_policy_del_reply) \
5116 _(sr_policy_add_reply) \
5117 _(sr_policy_mod_reply) \
5118 _(sr_policy_del_reply) \
5119 _(sr_localsid_add_del_reply) \
5120 _(sr_steering_add_del_reply) \
5121 _(classify_add_del_session_reply) \
5122 _(classify_set_interface_ip_table_reply) \
5123 _(classify_set_interface_l2_tables_reply) \
5124 _(l2tpv3_set_tunnel_cookies_reply) \
5125 _(l2tpv3_interface_enable_disable_reply) \
5126 _(l2tpv3_set_lookup_key_reply) \
5127 _(l2_fib_clear_table_reply) \
5128 _(l2_interface_efp_filter_reply) \
5129 _(l2_interface_vlan_tag_rewrite_reply) \
5130 _(modify_vhost_user_if_reply) \
5131 _(delete_vhost_user_if_reply) \
5132 _(want_l2_macs_events_reply) \
5133 _(input_acl_set_interface_reply) \
5134 _(ipsec_spd_add_del_reply) \
5135 _(ipsec_interface_add_del_spd_reply) \
5136 _(ipsec_spd_entry_add_del_reply) \
5137 _(ipsec_sad_entry_add_del_reply) \
5138 _(ipsec_tunnel_if_add_del_reply) \
5139 _(ipsec_tunnel_if_set_sa_reply) \
5140 _(delete_loopback_reply) \
5141 _(bd_ip_mac_add_del_reply) \
5142 _(bd_ip_mac_flush_reply) \
5143 _(want_interface_events_reply) \
5144 _(cop_interface_enable_disable_reply) \
5145 _(cop_whitelist_enable_disable_reply) \
5146 _(sw_interface_clear_stats_reply) \
5147 _(ioam_enable_reply) \
5148 _(ioam_disable_reply) \
5149 _(one_add_del_locator_reply) \
5150 _(one_add_del_local_eid_reply) \
5151 _(one_add_del_remote_mapping_reply) \
5152 _(one_add_del_adjacency_reply) \
5153 _(one_add_del_map_resolver_reply) \
5154 _(one_add_del_map_server_reply) \
5155 _(one_enable_disable_reply) \
5156 _(one_rloc_probe_enable_disable_reply) \
5157 _(one_map_register_enable_disable_reply) \
5158 _(one_map_register_set_ttl_reply) \
5159 _(one_set_transport_protocol_reply) \
5160 _(one_map_register_fallback_threshold_reply) \
5161 _(one_pitr_set_locator_set_reply) \
5162 _(one_map_request_mode_reply) \
5163 _(one_add_del_map_request_itr_rlocs_reply) \
5164 _(one_eid_table_add_del_map_reply) \
5165 _(one_use_petr_reply) \
5166 _(one_stats_enable_disable_reply) \
5167 _(one_add_del_l2_arp_entry_reply) \
5168 _(one_add_del_ndp_entry_reply) \
5169 _(one_stats_flush_reply) \
5170 _(one_enable_disable_xtr_mode_reply) \
5171 _(one_enable_disable_pitr_mode_reply) \
5172 _(one_enable_disable_petr_mode_reply) \
5173 _(gpe_enable_disable_reply) \
5174 _(gpe_set_encap_mode_reply) \
5175 _(gpe_add_del_iface_reply) \
5176 _(gpe_add_del_native_fwd_rpath_reply) \
5177 _(af_packet_delete_reply) \
5178 _(policer_classify_set_interface_reply) \
5179 _(set_ipfix_exporter_reply) \
5180 _(set_ipfix_classify_stream_reply) \
5181 _(ipfix_classify_table_add_del_reply) \
5182 _(flow_classify_set_interface_reply) \
5183 _(sw_interface_span_enable_disable_reply) \
5184 _(pg_capture_reply) \
5185 _(pg_enable_disable_reply) \
5186 _(pg_interface_enable_disable_coalesce_reply) \
5187 _(ip_source_and_port_range_check_add_del_reply) \
5188 _(ip_source_and_port_range_check_interface_add_del_reply)\
5189 _(delete_subif_reply) \
5190 _(l2_interface_pbb_tag_rewrite_reply) \
5192 _(feature_enable_disable_reply) \
5193 _(feature_gso_enable_disable_reply) \
5194 _(sw_interface_tag_add_del_reply) \
5195 _(sw_interface_add_del_mac_address_reply) \
5196 _(hw_interface_set_mtu_reply) \
5197 _(p2p_ethernet_add_reply) \
5198 _(p2p_ethernet_del_reply) \
5199 _(tcp_configure_src_addresses_reply) \
5200 _(session_rule_add_del_reply) \
5201 _(ip_container_proxy_add_del_reply) \
5202 _(output_acl_set_interface_reply) \
5203 _(qos_record_enable_disable_reply) \
5207 static void vl_api_##n##_t_handler \
5208 (vl_api_##n##_t * mp) \
5210 vat_main_t * vam = &vat_main; \
5211 i32 retval = ntohl(mp->retval); \
5212 if (vam->async_mode) { \
5213 vam->async_errors += (retval < 0); \
5215 vam->retval = retval; \
5216 vam->result_ready = 1; \
5219 foreach_standard_reply_retval_handler;
5223 static void vl_api_##n##_t_handler_json \
5224 (vl_api_##n##_t * mp) \
5226 vat_main_t * vam = &vat_main; \
5227 vat_json_node_t node; \
5228 vat_json_init_object(&node); \
5229 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5230 vat_json_print(vam->ofp, &node); \
5231 vam->retval = ntohl(mp->retval); \
5232 vam->result_ready = 1; \
5234 foreach_standard_reply_retval_handler;
5238 * Table of message reply handlers, must include boilerplate handlers
5242 #define foreach_vpe_api_reply_msg \
5243 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5244 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5245 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5246 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5247 _(CONTROL_PING_REPLY, control_ping_reply) \
5248 _(CLI_REPLY, cli_reply) \
5249 _(CLI_INBAND_REPLY, cli_inband_reply) \
5250 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5251 sw_interface_add_del_address_reply) \
5252 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5253 _(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
5254 _(SW_INTERFACE_RX_PLACEMENT_DETAILS, sw_interface_rx_placement_details) \
5255 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5256 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5257 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5258 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5259 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5260 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5261 sw_interface_set_l2_xconnect_reply) \
5262 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5263 sw_interface_set_l2_bridge_reply) \
5264 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5265 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5266 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5267 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5268 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5269 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5270 _(L2_FLAGS_REPLY, l2_flags_reply) \
5271 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5272 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5273 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5274 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5275 _(VIRTIO_PCI_CREATE_REPLY, virtio_pci_create_reply) \
5276 _(VIRTIO_PCI_CREATE_V2_REPLY, virtio_pci_create_v2_reply) \
5277 _(VIRTIO_PCI_DELETE_REPLY, virtio_pci_delete_reply) \
5278 _(SW_INTERFACE_VIRTIO_PCI_DETAILS, sw_interface_virtio_pci_details) \
5279 _(BOND_CREATE_REPLY, bond_create_reply) \
5280 _(BOND_CREATE2_REPLY, bond_create2_reply) \
5281 _(BOND_DELETE_REPLY, bond_delete_reply) \
5282 _(BOND_ADD_MEMBER_REPLY, bond_add_member_reply) \
5283 _(BOND_DETACH_MEMBER_REPLY, bond_detach_member_reply) \
5284 _(SW_INTERFACE_SET_BOND_WEIGHT_REPLY, sw_interface_set_bond_weight_reply) \
5285 _(SW_BOND_INTERFACE_DETAILS, sw_bond_interface_details) \
5286 _(SW_MEMBER_INTERFACE_DETAILS, sw_member_interface_details) \
5287 _(IP_ROUTE_ADD_DEL_REPLY, ip_route_add_del_reply) \
5288 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5289 _(IP_TABLE_REPLACE_BEGIN_REPLY, ip_table_replace_begin_reply) \
5290 _(IP_TABLE_FLUSH_REPLY, ip_table_flush_reply) \
5291 _(IP_TABLE_REPLACE_END_REPLY, ip_table_replace_end_reply) \
5292 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5293 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5294 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5295 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5296 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5297 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5298 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5299 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5300 sw_interface_set_unnumbered_reply) \
5301 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5302 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5303 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5304 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5305 sw_interface_ip6_enable_disable_reply) \
5306 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5307 _(SR_MPLS_POLICY_ADD_REPLY, sr_mpls_policy_add_reply) \
5308 _(SR_MPLS_POLICY_MOD_REPLY, sr_mpls_policy_mod_reply) \
5309 _(SR_MPLS_POLICY_DEL_REPLY, sr_mpls_policy_del_reply) \
5310 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5311 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5312 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5313 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5314 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5315 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5316 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5317 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5318 classify_set_interface_ip_table_reply) \
5319 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5320 classify_set_interface_l2_tables_reply) \
5321 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5322 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5323 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5324 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5325 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5326 l2tpv3_interface_enable_disable_reply) \
5327 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5328 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5329 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5330 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5331 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5332 _(GRE_TUNNEL_ADD_DEL_REPLY, gre_tunnel_add_del_reply) \
5333 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5334 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5335 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5336 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5337 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5338 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5339 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5340 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5341 _(SHOW_VERSION_REPLY, show_version_reply) \
5342 _(SHOW_THREADS_REPLY, show_threads_reply) \
5343 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5344 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5345 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5346 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5347 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5348 _(L2_MACS_EVENT, l2_macs_event) \
5349 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5350 _(IP_ADDRESS_DETAILS, ip_address_details) \
5351 _(IP_DETAILS, ip_details) \
5352 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5353 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5354 _(IPSEC_SPD_ENTRY_ADD_DEL_REPLY, ipsec_spd_entry_add_del_reply) \
5355 _(IPSEC_SAD_ENTRY_ADD_DEL_REPLY, ipsec_sad_entry_add_del_reply) \
5356 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5357 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5358 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5359 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5360 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5361 _(BD_IP_MAC_FLUSH_REPLY, bd_ip_mac_flush_reply) \
5362 _(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
5363 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5364 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5365 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5366 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5367 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5368 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5369 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5370 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5371 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5372 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5373 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5374 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5375 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5376 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5377 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5378 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5379 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5380 one_map_register_enable_disable_reply) \
5381 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5382 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5383 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5384 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5385 one_map_register_fallback_threshold_reply) \
5386 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5387 one_rloc_probe_enable_disable_reply) \
5388 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5389 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5390 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5391 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5392 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5393 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5394 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5395 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5396 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5397 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5398 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5399 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5400 _(ONE_STATS_DETAILS, one_stats_details) \
5401 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5402 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5403 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5404 show_one_stats_enable_disable_reply) \
5405 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5406 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5407 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5408 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5409 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5410 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5411 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5412 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5413 one_enable_disable_pitr_mode_reply) \
5414 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5415 one_enable_disable_petr_mode_reply) \
5416 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5417 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5418 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5419 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5420 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5421 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5422 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5423 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5424 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5425 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5426 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5427 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5428 gpe_add_del_native_fwd_rpath_reply) \
5429 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5430 gpe_fwd_entry_path_details) \
5431 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5432 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5433 one_add_del_map_request_itr_rlocs_reply) \
5434 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5435 one_get_map_request_itr_rlocs_reply) \
5436 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5437 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5438 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5439 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5440 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5441 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5442 show_one_map_register_state_reply) \
5443 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5444 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5445 show_one_map_register_fallback_threshold_reply) \
5446 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5447 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5448 _(AF_PACKET_DETAILS, af_packet_details) \
5449 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5450 _(POLICER_DETAILS, policer_details) \
5451 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5452 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5453 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5454 _(MPLS_TABLE_DETAILS, mpls_table_details) \
5455 _(MPLS_ROUTE_DETAILS, mpls_route_details) \
5456 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5457 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5458 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5459 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5460 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5461 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5462 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5463 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5464 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5465 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5466 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5467 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5468 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5469 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5470 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5471 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5472 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5473 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5474 _(PG_INTERFACE_ENABLE_DISABLE_COALESCE_REPLY, pg_interface_enable_disable_coalesce_reply) \
5475 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5476 ip_source_and_port_range_check_add_del_reply) \
5477 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5478 ip_source_and_port_range_check_interface_add_del_reply) \
5479 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5480 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5481 _(SET_PUNT_REPLY, set_punt_reply) \
5482 _(IP_TABLE_DETAILS, ip_table_details) \
5483 _(IP_ROUTE_DETAILS, ip_route_details) \
5484 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5485 _(FEATURE_GSO_ENABLE_DISABLE_REPLY, feature_gso_enable_disable_reply) \
5486 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5487 _(SW_INTERFACE_ADD_DEL_MAC_ADDRESS_REPLY, sw_interface_add_del_mac_address_reply) \
5488 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5489 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5490 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5491 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5492 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5493 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5494 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5495 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5496 _(SESSION_RULES_DETAILS, session_rules_details) \
5497 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5498 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5499 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply) \
5500 _(FLOW_ADD_REPLY, flow_add_reply) \
5502 #define foreach_standalone_reply_msg \
5503 _(SW_INTERFACE_EVENT, sw_interface_event)
5511 #define STR_VTR_OP_CASE(op) \
5512 case L2_VTR_ ## op: \
5516 str_vtr_op (u32 vtr_op)
5520 STR_VTR_OP_CASE (DISABLED);
5521 STR_VTR_OP_CASE (PUSH_1);
5522 STR_VTR_OP_CASE (PUSH_2);
5523 STR_VTR_OP_CASE (POP_1);
5524 STR_VTR_OP_CASE (POP_2);
5525 STR_VTR_OP_CASE (TRANSLATE_1_1);
5526 STR_VTR_OP_CASE (TRANSLATE_1_2);
5527 STR_VTR_OP_CASE (TRANSLATE_2_1);
5528 STR_VTR_OP_CASE (TRANSLATE_2_2);
5535 dump_sub_interface_table (vat_main_t * vam)
5537 const sw_interface_subif_t *sub = NULL;
5539 if (vam->json_output)
5542 ("JSON output supported only for VPE API calls and dump_stats_table");
5547 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5548 "Interface", "sw_if_index",
5549 "sub id", "dot1ad", "tags", "outer id",
5550 "inner id", "exact", "default", "outer any", "inner any");
5552 vec_foreach (sub, vam->sw_if_subif_table)
5555 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5556 sub->interface_name,
5558 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5559 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5560 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5561 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5562 if (sub->vtr_op != L2_VTR_DISABLED)
5565 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5566 "tag1: %d tag2: %d ]",
5567 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5568 sub->vtr_tag1, sub->vtr_tag2);
5576 name_sort_cmp (void *a1, void *a2)
5578 name_sort_t *n1 = a1;
5579 name_sort_t *n2 = a2;
5581 return strcmp ((char *) n1->name, (char *) n2->name);
5585 dump_interface_table (vat_main_t * vam)
5588 name_sort_t *nses = 0, *ns;
5590 if (vam->json_output)
5593 ("JSON output supported only for VPE API calls and dump_stats_table");
5598 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5600 vec_add2 (nses, ns, 1);
5601 ns->name = (u8 *)(p->key);
5602 ns->value = (u32) p->value[0];
5606 vec_sort_with_function (nses, name_sort_cmp);
5608 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5609 vec_foreach (ns, nses)
5611 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5618 dump_ip_table (vat_main_t * vam, int is_ipv6)
5620 const ip_details_t *det = NULL;
5621 const ip_address_details_t *address = NULL;
5624 print (vam->ofp, "%-12s", "sw_if_index");
5626 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5633 print (vam->ofp, "%-12d", i);
5634 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5639 vec_foreach (address, det->addr)
5643 is_ipv6 ? format_ip6_address : format_ip4_address,
5644 address->ip, address->prefix_length);
5652 dump_ipv4_table (vat_main_t * vam)
5654 if (vam->json_output)
5657 ("JSON output supported only for VPE API calls and dump_stats_table");
5661 return dump_ip_table (vam, 0);
5665 dump_ipv6_table (vat_main_t * vam)
5667 if (vam->json_output)
5670 ("JSON output supported only for VPE API calls and dump_stats_table");
5674 return dump_ip_table (vam, 1);
5678 * Pass CLI buffers directly in the CLI_INBAND API message,
5679 * instead of an additional shared memory area.
5682 exec_inband (vat_main_t * vam)
5684 vl_api_cli_inband_t *mp;
5685 unformat_input_t *i = vam->input;
5688 if (vec_len (i->buffer) == 0)
5691 if (vam->exec_mode == 0 && unformat (i, "mode"))
5696 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5703 * In order for the CLI command to work, it
5704 * must be a vector ending in \n, not a C-string ending
5707 M2 (CLI_INBAND, mp, vec_len (vam->input->buffer));
5708 vl_api_vec_to_api_string (vam->input->buffer, &mp->cmd);
5712 /* json responses may or may not include a useful reply... */
5713 if (vec_len (vam->cmd_reply))
5714 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
5719 exec (vat_main_t * vam)
5721 return exec_inband (vam);
5725 api_create_loopback (vat_main_t * vam)
5727 unformat_input_t *i = vam->input;
5728 vl_api_create_loopback_t *mp;
5729 vl_api_create_loopback_instance_t *mp_lbi;
5732 u8 is_specified = 0;
5733 u32 user_instance = 0;
5736 clib_memset (mac_address, 0, sizeof (mac_address));
5738 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5740 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5742 if (unformat (i, "instance %d", &user_instance))
5750 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5751 mp_lbi->is_specified = is_specified;
5753 mp_lbi->user_instance = htonl (user_instance);
5755 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5760 /* Construct the API message */
5761 M (CREATE_LOOPBACK, mp);
5763 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5772 api_delete_loopback (vat_main_t * vam)
5774 unformat_input_t *i = vam->input;
5775 vl_api_delete_loopback_t *mp;
5776 u32 sw_if_index = ~0;
5779 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5781 if (unformat (i, "sw_if_index %d", &sw_if_index))
5787 if (sw_if_index == ~0)
5789 errmsg ("missing sw_if_index");
5793 /* Construct the API message */
5794 M (DELETE_LOOPBACK, mp);
5795 mp->sw_if_index = ntohl (sw_if_index);
5803 api_want_interface_events (vat_main_t * vam)
5805 unformat_input_t *i = vam->input;
5806 vl_api_want_interface_events_t *mp;
5810 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5812 if (unformat (i, "enable"))
5814 else if (unformat (i, "disable"))
5822 errmsg ("missing enable|disable");
5826 M (WANT_INTERFACE_EVENTS, mp);
5827 mp->enable_disable = enable;
5829 vam->interface_event_display = enable;
5837 /* Note: non-static, called once to set up the initial intfc table */
5839 api_sw_interface_dump (vat_main_t * vam)
5841 vl_api_sw_interface_dump_t *mp;
5842 vl_api_control_ping_t *mp_ping;
5844 name_sort_t *nses = 0, *ns;
5845 sw_interface_subif_t *sub = NULL;
5848 /* Toss the old name table */
5850 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5852 vec_add2 (nses, ns, 1);
5853 ns->name = (u8 *)(p->key);
5854 ns->value = (u32) p->value[0];
5858 hash_free (vam->sw_if_index_by_interface_name);
5860 vec_foreach (ns, nses) vec_free (ns->name);
5864 vec_foreach (sub, vam->sw_if_subif_table)
5866 vec_free (sub->interface_name);
5868 vec_free (vam->sw_if_subif_table);
5870 /* recreate the interface name hash table */
5871 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5874 * Ask for all interface names. Otherwise, the epic catalog of
5875 * name filters becomes ridiculously long, and vat ends up needing
5876 * to be taught about new interface types.
5878 M (SW_INTERFACE_DUMP, mp);
5881 /* Use a control ping for synchronization */
5882 MPING (CONTROL_PING, mp_ping);
5890 api_sw_interface_set_flags (vat_main_t * vam)
5892 unformat_input_t *i = vam->input;
5893 vl_api_sw_interface_set_flags_t *mp;
5895 u8 sw_if_index_set = 0;
5899 /* Parse args required to build the message */
5900 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5902 if (unformat (i, "admin-up"))
5904 else if (unformat (i, "admin-down"))
5907 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5908 sw_if_index_set = 1;
5909 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5910 sw_if_index_set = 1;
5915 if (sw_if_index_set == 0)
5917 errmsg ("missing interface name or sw_if_index");
5921 /* Construct the API message */
5922 M (SW_INTERFACE_SET_FLAGS, mp);
5923 mp->sw_if_index = ntohl (sw_if_index);
5924 mp->flags = ntohl ((admin_up) ? IF_STATUS_API_FLAG_ADMIN_UP : 0);
5929 /* Wait for a reply, return the good/bad news... */
5935 api_sw_interface_set_rx_mode (vat_main_t * vam)
5937 unformat_input_t *i = vam->input;
5938 vl_api_sw_interface_set_rx_mode_t *mp;
5940 u8 sw_if_index_set = 0;
5942 u8 queue_id_valid = 0;
5944 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
5946 /* Parse args required to build the message */
5947 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5949 if (unformat (i, "queue %d", &queue_id))
5951 else if (unformat (i, "polling"))
5952 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
5953 else if (unformat (i, "interrupt"))
5954 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
5955 else if (unformat (i, "adaptive"))
5956 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
5958 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5959 sw_if_index_set = 1;
5960 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5961 sw_if_index_set = 1;
5966 if (sw_if_index_set == 0)
5968 errmsg ("missing interface name or sw_if_index");
5971 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
5973 errmsg ("missing rx-mode");
5977 /* Construct the API message */
5978 M (SW_INTERFACE_SET_RX_MODE, mp);
5979 mp->sw_if_index = ntohl (sw_if_index);
5980 mp->mode = (vl_api_rx_mode_t) mode;
5981 mp->queue_id_valid = queue_id_valid;
5982 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
5987 /* Wait for a reply, return the good/bad news... */
5993 api_sw_interface_set_rx_placement (vat_main_t * vam)
5995 unformat_input_t *i = vam->input;
5996 vl_api_sw_interface_set_rx_placement_t *mp;
5998 u8 sw_if_index_set = 0;
6001 u32 queue_id, thread_index;
6003 /* Parse args required to build the message */
6004 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6006 if (unformat (i, "queue %d", &queue_id))
6008 else if (unformat (i, "main"))
6010 else if (unformat (i, "worker %d", &thread_index))
6013 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6014 sw_if_index_set = 1;
6015 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6016 sw_if_index_set = 1;
6021 if (sw_if_index_set == 0)
6023 errmsg ("missing interface name or sw_if_index");
6029 /* Construct the API message */
6030 M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
6031 mp->sw_if_index = ntohl (sw_if_index);
6032 mp->worker_id = ntohl (thread_index);
6033 mp->queue_id = ntohl (queue_id);
6034 mp->is_main = is_main;
6038 /* Wait for a reply, return the good/bad news... */
6043 static void vl_api_sw_interface_rx_placement_details_t_handler
6044 (vl_api_sw_interface_rx_placement_details_t * mp)
6046 vat_main_t *vam = &vat_main;
6047 u32 worker_id = ntohl (mp->worker_id);
6050 "\n%-11d %-11s %-6d %-5d %-9s",
6051 ntohl (mp->sw_if_index), (worker_id == 0) ? "main" : "worker",
6052 worker_id, ntohl (mp->queue_id),
6054 1) ? "polling" : ((mp->mode == 2) ? "interrupt" : "adaptive"));
6057 static void vl_api_sw_interface_rx_placement_details_t_handler_json
6058 (vl_api_sw_interface_rx_placement_details_t * mp)
6060 vat_main_t *vam = &vat_main;
6061 vat_json_node_t *node = NULL;
6063 if (VAT_JSON_ARRAY != vam->json_tree.type)
6065 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
6066 vat_json_init_array (&vam->json_tree);
6068 node = vat_json_array_add (&vam->json_tree);
6070 vat_json_init_object (node);
6071 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
6072 vat_json_object_add_uint (node, "worker_id", ntohl (mp->worker_id));
6073 vat_json_object_add_uint (node, "queue_id", ntohl (mp->queue_id));
6074 vat_json_object_add_uint (node, "mode", mp->mode);
6078 api_sw_interface_rx_placement_dump (vat_main_t * vam)
6080 unformat_input_t *i = vam->input;
6081 vl_api_sw_interface_rx_placement_dump_t *mp;
6082 vl_api_control_ping_t *mp_ping;
6085 u8 sw_if_index_set = 0;
6087 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6089 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6091 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6098 "\n%-11s %-11s %-6s %-5s %-4s",
6099 "sw_if_index", "main/worker", "thread", "queue", "mode");
6101 /* Dump Interface rx placement */
6102 M (SW_INTERFACE_RX_PLACEMENT_DUMP, mp);
6104 if (sw_if_index_set)
6105 mp->sw_if_index = htonl (sw_if_index);
6107 mp->sw_if_index = ~0;
6111 /* Use a control ping for synchronization */
6112 MPING (CONTROL_PING, mp_ping);
6120 api_sw_interface_clear_stats (vat_main_t * vam)
6122 unformat_input_t *i = vam->input;
6123 vl_api_sw_interface_clear_stats_t *mp;
6125 u8 sw_if_index_set = 0;
6128 /* Parse args required to build the message */
6129 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6131 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6132 sw_if_index_set = 1;
6133 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6134 sw_if_index_set = 1;
6139 /* Construct the API message */
6140 M (SW_INTERFACE_CLEAR_STATS, mp);
6142 if (sw_if_index_set == 1)
6143 mp->sw_if_index = ntohl (sw_if_index);
6145 mp->sw_if_index = ~0;
6150 /* Wait for a reply, return the good/bad news... */
6156 api_sw_interface_add_del_address (vat_main_t * vam)
6158 unformat_input_t *i = vam->input;
6159 vl_api_sw_interface_add_del_address_t *mp;
6161 u8 sw_if_index_set = 0;
6162 u8 is_add = 1, del_all = 0;
6163 u32 address_length = 0;
6164 u8 v4_address_set = 0;
6165 u8 v6_address_set = 0;
6166 ip4_address_t v4address;
6167 ip6_address_t v6address;
6170 /* Parse args required to build the message */
6171 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6173 if (unformat (i, "del-all"))
6175 else if (unformat (i, "del"))
6178 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6179 sw_if_index_set = 1;
6180 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6181 sw_if_index_set = 1;
6182 else if (unformat (i, "%U/%d",
6183 unformat_ip4_address, &v4address, &address_length))
6185 else if (unformat (i, "%U/%d",
6186 unformat_ip6_address, &v6address, &address_length))
6192 if (sw_if_index_set == 0)
6194 errmsg ("missing interface name or sw_if_index");
6197 if (v4_address_set && v6_address_set)
6199 errmsg ("both v4 and v6 addresses set");
6202 if (!v4_address_set && !v6_address_set && !del_all)
6204 errmsg ("no addresses set");
6208 /* Construct the API message */
6209 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6211 mp->sw_if_index = ntohl (sw_if_index);
6212 mp->is_add = is_add;
6213 mp->del_all = del_all;
6216 mp->prefix.address.af = ADDRESS_IP6;
6217 clib_memcpy (mp->prefix.address.un.ip6, &v6address, sizeof (v6address));
6221 mp->prefix.address.af = ADDRESS_IP4;
6222 clib_memcpy (mp->prefix.address.un.ip4, &v4address, sizeof (v4address));
6224 mp->prefix.len = address_length;
6229 /* Wait for a reply, return good/bad news */
6235 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6237 unformat_input_t *i = vam->input;
6238 vl_api_sw_interface_set_mpls_enable_t *mp;
6240 u8 sw_if_index_set = 0;
6244 /* Parse args required to build the message */
6245 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6247 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6248 sw_if_index_set = 1;
6249 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6250 sw_if_index_set = 1;
6251 else if (unformat (i, "disable"))
6253 else if (unformat (i, "dis"))
6259 if (sw_if_index_set == 0)
6261 errmsg ("missing interface name or sw_if_index");
6265 /* Construct the API message */
6266 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6268 mp->sw_if_index = ntohl (sw_if_index);
6269 mp->enable = enable;
6274 /* Wait for a reply... */
6280 api_sw_interface_set_table (vat_main_t * vam)
6282 unformat_input_t *i = vam->input;
6283 vl_api_sw_interface_set_table_t *mp;
6284 u32 sw_if_index, vrf_id = 0;
6285 u8 sw_if_index_set = 0;
6289 /* Parse args required to build the message */
6290 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6292 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6293 sw_if_index_set = 1;
6294 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6295 sw_if_index_set = 1;
6296 else if (unformat (i, "vrf %d", &vrf_id))
6298 else if (unformat (i, "ipv6"))
6304 if (sw_if_index_set == 0)
6306 errmsg ("missing interface name or sw_if_index");
6310 /* Construct the API message */
6311 M (SW_INTERFACE_SET_TABLE, mp);
6313 mp->sw_if_index = ntohl (sw_if_index);
6314 mp->is_ipv6 = is_ipv6;
6315 mp->vrf_id = ntohl (vrf_id);
6320 /* Wait for a reply... */
6325 static void vl_api_sw_interface_get_table_reply_t_handler
6326 (vl_api_sw_interface_get_table_reply_t * mp)
6328 vat_main_t *vam = &vat_main;
6330 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6332 vam->retval = ntohl (mp->retval);
6333 vam->result_ready = 1;
6337 static void vl_api_sw_interface_get_table_reply_t_handler_json
6338 (vl_api_sw_interface_get_table_reply_t * mp)
6340 vat_main_t *vam = &vat_main;
6341 vat_json_node_t node;
6343 vat_json_init_object (&node);
6344 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6345 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6347 vat_json_print (vam->ofp, &node);
6348 vat_json_free (&node);
6350 vam->retval = ntohl (mp->retval);
6351 vam->result_ready = 1;
6355 api_sw_interface_get_table (vat_main_t * vam)
6357 unformat_input_t *i = vam->input;
6358 vl_api_sw_interface_get_table_t *mp;
6360 u8 sw_if_index_set = 0;
6364 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6366 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6367 sw_if_index_set = 1;
6368 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6369 sw_if_index_set = 1;
6370 else if (unformat (i, "ipv6"))
6376 if (sw_if_index_set == 0)
6378 errmsg ("missing interface name or sw_if_index");
6382 M (SW_INTERFACE_GET_TABLE, mp);
6383 mp->sw_if_index = htonl (sw_if_index);
6384 mp->is_ipv6 = is_ipv6;
6392 api_sw_interface_set_vpath (vat_main_t * vam)
6394 unformat_input_t *i = vam->input;
6395 vl_api_sw_interface_set_vpath_t *mp;
6396 u32 sw_if_index = 0;
6397 u8 sw_if_index_set = 0;
6401 /* Parse args required to build the message */
6402 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6404 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6405 sw_if_index_set = 1;
6406 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6407 sw_if_index_set = 1;
6408 else if (unformat (i, "enable"))
6410 else if (unformat (i, "disable"))
6416 if (sw_if_index_set == 0)
6418 errmsg ("missing interface name or sw_if_index");
6422 /* Construct the API message */
6423 M (SW_INTERFACE_SET_VPATH, mp);
6425 mp->sw_if_index = ntohl (sw_if_index);
6426 mp->enable = is_enable;
6431 /* Wait for a reply... */
6437 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6439 unformat_input_t *i = vam->input;
6440 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6441 u32 sw_if_index = 0;
6442 u8 sw_if_index_set = 0;
6447 /* Parse args required to build the message */
6448 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6450 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6451 sw_if_index_set = 1;
6452 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6453 sw_if_index_set = 1;
6454 else if (unformat (i, "enable"))
6456 else if (unformat (i, "disable"))
6458 else if (unformat (i, "ip4"))
6460 else if (unformat (i, "ip6"))
6466 if (sw_if_index_set == 0)
6468 errmsg ("missing interface name or sw_if_index");
6472 /* Construct the API message */
6473 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6475 mp->sw_if_index = ntohl (sw_if_index);
6476 mp->enable = is_enable;
6477 mp->is_ipv6 = is_ipv6;
6482 /* Wait for a reply... */
6488 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6490 unformat_input_t *i = vam->input;
6491 vl_api_sw_interface_set_l2_xconnect_t *mp;
6493 u8 rx_sw_if_index_set = 0;
6495 u8 tx_sw_if_index_set = 0;
6499 /* Parse args required to build the message */
6500 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6502 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6503 rx_sw_if_index_set = 1;
6504 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6505 tx_sw_if_index_set = 1;
6506 else if (unformat (i, "rx"))
6508 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6510 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6512 rx_sw_if_index_set = 1;
6517 else if (unformat (i, "tx"))
6519 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6521 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6523 tx_sw_if_index_set = 1;
6528 else if (unformat (i, "enable"))
6530 else if (unformat (i, "disable"))
6536 if (rx_sw_if_index_set == 0)
6538 errmsg ("missing rx interface name or rx_sw_if_index");
6542 if (enable && (tx_sw_if_index_set == 0))
6544 errmsg ("missing tx interface name or tx_sw_if_index");
6548 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6550 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6551 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6552 mp->enable = enable;
6560 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6562 unformat_input_t *i = vam->input;
6563 vl_api_sw_interface_set_l2_bridge_t *mp;
6564 vl_api_l2_port_type_t port_type;
6566 u8 rx_sw_if_index_set = 0;
6573 port_type = L2_API_PORT_TYPE_NORMAL;
6575 /* Parse args required to build the message */
6576 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6578 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6579 rx_sw_if_index_set = 1;
6580 else if (unformat (i, "bd_id %d", &bd_id))
6584 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6585 rx_sw_if_index_set = 1;
6586 else if (unformat (i, "shg %d", &shg))
6588 else if (unformat (i, "bvi"))
6589 port_type = L2_API_PORT_TYPE_BVI;
6590 else if (unformat (i, "uu-fwd"))
6591 port_type = L2_API_PORT_TYPE_UU_FWD;
6592 else if (unformat (i, "enable"))
6594 else if (unformat (i, "disable"))
6600 if (rx_sw_if_index_set == 0)
6602 errmsg ("missing rx interface name or sw_if_index");
6606 if (enable && (bd_id_set == 0))
6608 errmsg ("missing bridge domain");
6612 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6614 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6615 mp->bd_id = ntohl (bd_id);
6617 mp->port_type = ntohl (port_type);
6618 mp->enable = enable;
6626 api_bridge_domain_dump (vat_main_t * vam)
6628 unformat_input_t *i = vam->input;
6629 vl_api_bridge_domain_dump_t *mp;
6630 vl_api_control_ping_t *mp_ping;
6634 /* Parse args required to build the message */
6635 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6637 if (unformat (i, "bd_id %d", &bd_id))
6643 M (BRIDGE_DOMAIN_DUMP, mp);
6644 mp->bd_id = ntohl (bd_id);
6647 /* Use a control ping for synchronization */
6648 MPING (CONTROL_PING, mp_ping);
6656 api_bridge_domain_add_del (vat_main_t * vam)
6658 unformat_input_t *i = vam->input;
6659 vl_api_bridge_domain_add_del_t *mp;
6662 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6667 /* Parse args required to build the message */
6668 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6670 if (unformat (i, "bd_id %d", &bd_id))
6672 else if (unformat (i, "flood %d", &flood))
6674 else if (unformat (i, "uu-flood %d", &uu_flood))
6676 else if (unformat (i, "forward %d", &forward))
6678 else if (unformat (i, "learn %d", &learn))
6680 else if (unformat (i, "arp-term %d", &arp_term))
6682 else if (unformat (i, "mac-age %d", &mac_age))
6684 else if (unformat (i, "bd-tag %s", &bd_tag))
6686 else if (unformat (i, "del"))
6689 flood = uu_flood = forward = learn = 0;
6697 errmsg ("missing bridge domain");
6704 errmsg ("mac age must be less than 256 ");
6709 if ((bd_tag) && (vec_len (bd_tag) > 63))
6711 errmsg ("bd-tag cannot be longer than 63");
6716 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6718 mp->bd_id = ntohl (bd_id);
6720 mp->uu_flood = uu_flood;
6721 mp->forward = forward;
6723 mp->arp_term = arp_term;
6724 mp->is_add = is_add;
6725 mp->mac_age = (u8) mac_age;
6728 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
6729 mp->bd_tag[vec_len (bd_tag)] = 0;
6740 api_l2fib_flush_bd (vat_main_t * vam)
6742 unformat_input_t *i = vam->input;
6743 vl_api_l2fib_flush_bd_t *mp;
6747 /* Parse args required to build the message */
6748 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6750 if (unformat (i, "bd_id %d", &bd_id));
6757 errmsg ("missing bridge domain");
6761 M (L2FIB_FLUSH_BD, mp);
6763 mp->bd_id = htonl (bd_id);
6771 api_l2fib_flush_int (vat_main_t * vam)
6773 unformat_input_t *i = vam->input;
6774 vl_api_l2fib_flush_int_t *mp;
6775 u32 sw_if_index = ~0;
6778 /* Parse args required to build the message */
6779 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6781 if (unformat (i, "sw_if_index %d", &sw_if_index));
6783 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6788 if (sw_if_index == ~0)
6790 errmsg ("missing interface name or sw_if_index");
6794 M (L2FIB_FLUSH_INT, mp);
6796 mp->sw_if_index = ntohl (sw_if_index);
6804 api_l2fib_add_del (vat_main_t * vam)
6806 unformat_input_t *i = vam->input;
6807 vl_api_l2fib_add_del_t *mp;
6813 u32 sw_if_index = 0;
6814 u8 sw_if_index_set = 0;
6823 /* Parse args required to build the message */
6824 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6826 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
6828 else if (unformat (i, "bd_id %d", &bd_id))
6830 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6831 sw_if_index_set = 1;
6832 else if (unformat (i, "sw_if"))
6834 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6837 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6838 sw_if_index_set = 1;
6843 else if (unformat (i, "static"))
6845 else if (unformat (i, "filter"))
6850 else if (unformat (i, "bvi"))
6855 else if (unformat (i, "del"))
6857 else if (unformat (i, "count %d", &count))
6865 errmsg ("missing mac address");
6871 errmsg ("missing bridge domain");
6875 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
6877 errmsg ("missing interface name or sw_if_index");
6883 /* Turn on async mode */
6884 vam->async_mode = 1;
6885 vam->async_errors = 0;
6886 before = vat_time_now (vam);
6889 for (j = 0; j < count; j++)
6891 M (L2FIB_ADD_DEL, mp);
6893 clib_memcpy (mp->mac, mac, 6);
6894 mp->bd_id = ntohl (bd_id);
6895 mp->is_add = is_add;
6896 mp->sw_if_index = ntohl (sw_if_index);
6900 mp->static_mac = static_mac;
6901 mp->filter_mac = filter_mac;
6902 mp->bvi_mac = bvi_mac;
6904 increment_mac_address (mac);
6911 vl_api_control_ping_t *mp_ping;
6914 /* Shut off async mode */
6915 vam->async_mode = 0;
6917 MPING (CONTROL_PING, mp_ping);
6920 timeout = vat_time_now (vam) + 1.0;
6921 while (vat_time_now (vam) < timeout)
6922 if (vam->result_ready == 1)
6927 if (vam->retval == -99)
6930 if (vam->async_errors > 0)
6932 errmsg ("%d asynchronous errors", vam->async_errors);
6935 vam->async_errors = 0;
6936 after = vat_time_now (vam);
6938 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6939 count, after - before, count / (after - before));
6945 /* Wait for a reply... */
6949 /* Return the good/bad news */
6950 return (vam->retval);
6954 api_bridge_domain_set_mac_age (vat_main_t * vam)
6956 unformat_input_t *i = vam->input;
6957 vl_api_bridge_domain_set_mac_age_t *mp;
6962 /* Parse args required to build the message */
6963 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6965 if (unformat (i, "bd_id %d", &bd_id));
6966 else if (unformat (i, "mac-age %d", &mac_age));
6973 errmsg ("missing bridge domain");
6979 errmsg ("mac age must be less than 256 ");
6983 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
6985 mp->bd_id = htonl (bd_id);
6986 mp->mac_age = (u8) mac_age;
6994 api_l2_flags (vat_main_t * vam)
6996 unformat_input_t *i = vam->input;
6997 vl_api_l2_flags_t *mp;
7000 u8 sw_if_index_set = 0;
7004 /* Parse args required to build the message */
7005 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7007 if (unformat (i, "sw_if_index %d", &sw_if_index))
7008 sw_if_index_set = 1;
7009 else if (unformat (i, "sw_if"))
7011 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7014 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7015 sw_if_index_set = 1;
7020 else if (unformat (i, "learn"))
7022 else if (unformat (i, "forward"))
7024 else if (unformat (i, "flood"))
7026 else if (unformat (i, "uu-flood"))
7027 flags |= L2_UU_FLOOD;
7028 else if (unformat (i, "arp-term"))
7029 flags |= L2_ARP_TERM;
7030 else if (unformat (i, "off"))
7032 else if (unformat (i, "disable"))
7038 if (sw_if_index_set == 0)
7040 errmsg ("missing interface name or sw_if_index");
7046 mp->sw_if_index = ntohl (sw_if_index);
7047 mp->feature_bitmap = ntohl (flags);
7048 mp->is_set = is_set;
7056 api_bridge_flags (vat_main_t * vam)
7058 unformat_input_t *i = vam->input;
7059 vl_api_bridge_flags_t *mp;
7063 bd_flags_t flags = 0;
7066 /* Parse args required to build the message */
7067 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7069 if (unformat (i, "bd_id %d", &bd_id))
7071 else if (unformat (i, "learn"))
7072 flags |= BRIDGE_API_FLAG_LEARN;
7073 else if (unformat (i, "forward"))
7074 flags |= BRIDGE_API_FLAG_FWD;
7075 else if (unformat (i, "flood"))
7076 flags |= BRIDGE_API_FLAG_FLOOD;
7077 else if (unformat (i, "uu-flood"))
7078 flags |= BRIDGE_API_FLAG_UU_FLOOD;
7079 else if (unformat (i, "arp-term"))
7080 flags |= BRIDGE_API_FLAG_ARP_TERM;
7081 else if (unformat (i, "off"))
7083 else if (unformat (i, "disable"))
7091 errmsg ("missing bridge domain");
7095 M (BRIDGE_FLAGS, mp);
7097 mp->bd_id = ntohl (bd_id);
7098 mp->flags = ntohl (flags);
7099 mp->is_set = is_set;
7107 api_bd_ip_mac_add_del (vat_main_t * vam)
7109 vl_api_address_t ip = VL_API_ZERO_ADDRESS;
7110 vl_api_mac_address_t mac = { 0 };
7111 unformat_input_t *i = vam->input;
7112 vl_api_bd_ip_mac_add_del_t *mp;
7121 /* Parse args required to build the message */
7122 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7124 if (unformat (i, "bd_id %d", &bd_id))
7128 else if (unformat (i, "%U", unformat_vl_api_address, &ip))
7132 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
7136 else if (unformat (i, "del"))
7144 errmsg ("missing bridge domain");
7147 else if (ip_set == 0)
7149 errmsg ("missing IP address");
7152 else if (mac_set == 0)
7154 errmsg ("missing MAC address");
7158 M (BD_IP_MAC_ADD_DEL, mp);
7160 mp->entry.bd_id = ntohl (bd_id);
7161 mp->is_add = is_add;
7163 clib_memcpy (&mp->entry.ip, &ip, sizeof (ip));
7164 clib_memcpy (&mp->entry.mac, &mac, sizeof (mac));
7172 api_bd_ip_mac_flush (vat_main_t * vam)
7174 unformat_input_t *i = vam->input;
7175 vl_api_bd_ip_mac_flush_t *mp;
7180 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7182 if (unformat (i, "bd_id %d", &bd_id))
7192 errmsg ("missing bridge domain");
7196 M (BD_IP_MAC_FLUSH, mp);
7198 mp->bd_id = ntohl (bd_id);
7205 static void vl_api_bd_ip_mac_details_t_handler
7206 (vl_api_bd_ip_mac_details_t * mp)
7208 vat_main_t *vam = &vat_main;
7212 ntohl (mp->entry.bd_id),
7213 format_vl_api_mac_address, mp->entry.mac,
7214 format_vl_api_address, &mp->entry.ip);
7217 static void vl_api_bd_ip_mac_details_t_handler_json
7218 (vl_api_bd_ip_mac_details_t * mp)
7220 vat_main_t *vam = &vat_main;
7221 vat_json_node_t *node = NULL;
7223 if (VAT_JSON_ARRAY != vam->json_tree.type)
7225 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7226 vat_json_init_array (&vam->json_tree);
7228 node = vat_json_array_add (&vam->json_tree);
7230 vat_json_init_object (node);
7231 vat_json_object_add_uint (node, "bd_id", ntohl (mp->entry.bd_id));
7232 vat_json_object_add_string_copy (node, "mac_address",
7233 format (0, "%U", format_vl_api_mac_address,
7237 ip = format (0, "%U", format_vl_api_address, &mp->entry.ip);
7238 vat_json_object_add_string_copy (node, "ip_address", ip);
7243 api_bd_ip_mac_dump (vat_main_t * vam)
7245 unformat_input_t *i = vam->input;
7246 vl_api_bd_ip_mac_dump_t *mp;
7247 vl_api_control_ping_t *mp_ping;
7252 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7254 if (unformat (i, "bd_id %d", &bd_id))
7263 "\n%-5s %-7s %-20s %-30s",
7264 "bd_id", "is_ipv6", "mac_address", "ip_address");
7266 /* Dump Bridge Domain Ip to Mac entries */
7267 M (BD_IP_MAC_DUMP, mp);
7270 mp->bd_id = htonl (bd_id);
7276 /* Use a control ping for synchronization */
7277 MPING (CONTROL_PING, mp_ping);
7285 api_tap_create_v2 (vat_main_t * vam)
7287 unformat_input_t *i = vam->input;
7288 vl_api_tap_create_v2_t *mp;
7292 u32 num_rx_queues = 0;
7293 u8 *host_if_name = 0;
7294 u8 host_if_name_set = 0;
7297 u8 host_mac_addr[6];
7298 u8 host_mac_addr_set = 0;
7299 u8 *host_bridge = 0;
7300 u8 host_bridge_set = 0;
7301 u8 host_ip4_prefix_set = 0;
7302 u8 host_ip6_prefix_set = 0;
7303 ip4_address_t host_ip4_addr;
7304 ip4_address_t host_ip4_gw;
7305 u8 host_ip4_gw_set = 0;
7306 u32 host_ip4_prefix_len = 0;
7307 ip6_address_t host_ip6_addr;
7308 ip6_address_t host_ip6_gw;
7309 u8 host_ip6_gw_set = 0;
7310 u32 host_ip6_prefix_len = 0;
7311 u32 host_mtu_size = 0;
7312 u8 host_mtu_set = 0;
7315 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7317 clib_memset (mac_address, 0, sizeof (mac_address));
7319 /* Parse args required to build the message */
7320 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7322 if (unformat (i, "id %u", &id))
7326 (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7328 else if (unformat (i, "host-if-name %s", &host_if_name))
7329 host_if_name_set = 1;
7330 else if (unformat (i, "num-rx-queues %u", &num_rx_queues))
7332 else if (unformat (i, "host-ns %s", &host_ns))
7334 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
7336 host_mac_addr_set = 1;
7337 else if (unformat (i, "host-bridge %s", &host_bridge))
7338 host_bridge_set = 1;
7339 else if (unformat (i, "host-ip4-addr %U/%u", unformat_ip4_address,
7340 &host_ip4_addr, &host_ip4_prefix_len))
7341 host_ip4_prefix_set = 1;
7342 else if (unformat (i, "host-ip6-addr %U/%u", unformat_ip6_address,
7343 &host_ip6_addr, &host_ip6_prefix_len))
7344 host_ip6_prefix_set = 1;
7345 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
7347 host_ip4_gw_set = 1;
7348 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
7350 host_ip6_gw_set = 1;
7351 else if (unformat (i, "rx-ring-size %u", &rx_ring_sz))
7353 else if (unformat (i, "tx-ring-size %u", &tx_ring_sz))
7355 else if (unformat (i, "host-mtu-size %u", &host_mtu_size))
7357 else if (unformat (i, "no-gso"))
7358 tap_flags &= ~TAP_API_FLAG_GSO;
7359 else if (unformat (i, "gso"))
7360 tap_flags |= TAP_API_FLAG_GSO;
7361 else if (unformat (i, "csum-offload"))
7362 tap_flags |= TAP_API_FLAG_CSUM_OFFLOAD;
7363 else if (unformat (i, "persist"))
7364 tap_flags |= TAP_API_FLAG_PERSIST;
7365 else if (unformat (i, "attach"))
7366 tap_flags |= TAP_API_FLAG_ATTACH;
7367 else if (unformat (i, "tun"))
7368 tap_flags |= TAP_API_FLAG_TUN;
7369 else if (unformat (i, "gro-coalesce"))
7370 tap_flags |= TAP_API_FLAG_GRO_COALESCE;
7371 else if (unformat (i, "packed"))
7372 tap_flags |= TAP_API_FLAG_PACKED;
7373 else if (unformat (i, "in-order"))
7374 tap_flags |= TAP_API_FLAG_IN_ORDER;
7379 if (vec_len (host_if_name) > 63)
7381 errmsg ("tap name too long. ");
7384 if (vec_len (host_ns) > 63)
7386 errmsg ("host name space too long. ");
7389 if (vec_len (host_bridge) > 63)
7391 errmsg ("host bridge name too long. ");
7394 if (host_ip4_prefix_len > 32)
7396 errmsg ("host ip4 prefix length not valid. ");
7399 if (host_ip6_prefix_len > 128)
7401 errmsg ("host ip6 prefix length not valid. ");
7404 if (!is_pow2 (rx_ring_sz))
7406 errmsg ("rx ring size must be power of 2. ");
7409 if (rx_ring_sz > 32768)
7411 errmsg ("rx ring size must be 32768 or lower. ");
7414 if (!is_pow2 (tx_ring_sz))
7416 errmsg ("tx ring size must be power of 2. ");
7419 if (tx_ring_sz > 32768)
7421 errmsg ("tx ring size must be 32768 or lower. ");
7424 if (host_mtu_set && (host_mtu_size < 64 || host_mtu_size > 65355))
7426 errmsg ("host MTU size must be in between 64 and 65355. ");
7430 /* Construct the API message */
7431 M (TAP_CREATE_V2, mp);
7433 mp->id = ntohl (id);
7434 mp->use_random_mac = random_mac;
7435 mp->num_rx_queues = (u8) num_rx_queues;
7436 mp->tx_ring_sz = ntohs (tx_ring_sz);
7437 mp->rx_ring_sz = ntohs (rx_ring_sz);
7438 mp->host_mtu_set = host_mtu_set;
7439 mp->host_mtu_size = ntohl (host_mtu_size);
7440 mp->host_mac_addr_set = host_mac_addr_set;
7441 mp->host_ip4_prefix_set = host_ip4_prefix_set;
7442 mp->host_ip6_prefix_set = host_ip6_prefix_set;
7443 mp->host_ip4_gw_set = host_ip4_gw_set;
7444 mp->host_ip6_gw_set = host_ip6_gw_set;
7445 mp->tap_flags = ntohl (tap_flags);
7446 mp->host_namespace_set = host_ns_set;
7447 mp->host_if_name_set = host_if_name_set;
7448 mp->host_bridge_set = host_bridge_set;
7450 if (random_mac == 0)
7451 clib_memcpy (mp->mac_address, mac_address, 6);
7452 if (host_mac_addr_set)
7453 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
7454 if (host_if_name_set)
7455 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
7457 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
7458 if (host_bridge_set)
7459 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
7460 if (host_ip4_prefix_set)
7462 clib_memcpy (mp->host_ip4_prefix.address, &host_ip4_addr, 4);
7463 mp->host_ip4_prefix.len = (u8) host_ip4_prefix_len;
7465 if (host_ip6_prefix_set)
7467 clib_memcpy (mp->host_ip6_prefix.address, &host_ip6_addr, 16);
7468 mp->host_ip6_prefix.len = (u8) host_ip6_prefix_len;
7470 if (host_ip4_gw_set)
7471 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
7472 if (host_ip6_gw_set)
7473 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
7476 vec_free (host_if_name);
7477 vec_free (host_bridge);
7482 /* Wait for a reply... */
7488 api_tap_delete_v2 (vat_main_t * vam)
7490 unformat_input_t *i = vam->input;
7491 vl_api_tap_delete_v2_t *mp;
7492 u32 sw_if_index = ~0;
7493 u8 sw_if_index_set = 0;
7496 /* Parse args required to build the message */
7497 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7499 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7500 sw_if_index_set = 1;
7501 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7502 sw_if_index_set = 1;
7507 if (sw_if_index_set == 0)
7509 errmsg ("missing vpp interface name. ");
7513 /* Construct the API message */
7514 M (TAP_DELETE_V2, mp);
7516 mp->sw_if_index = ntohl (sw_if_index);
7521 /* Wait for a reply... */
7527 unformat_vlib_pci_addr (unformat_input_t * input, va_list * args)
7529 vlib_pci_addr_t *addr = va_arg (*args, vlib_pci_addr_t *);
7532 if (!unformat (input, "%x:%x:%x.%x", &x[0], &x[1], &x[2], &x[3]))
7535 addr->domain = x[0];
7538 addr->function = x[3];
7544 api_virtio_pci_create_v2 (vat_main_t * vam)
7546 unformat_input_t *i = vam->input;
7547 vl_api_virtio_pci_create_v2_t *mp;
7551 u64 features = (u64) ~ (0ULL);
7552 u32 virtio_flags = 0;
7555 clib_memset (mac_address, 0, sizeof (mac_address));
7557 /* Parse args required to build the message */
7558 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7560 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7564 else if (unformat (i, "pci-addr %U", unformat_vlib_pci_addr, &pci_addr))
7566 else if (unformat (i, "features 0x%llx", &features))
7568 else if (unformat (i, "gso-enabled"))
7569 virtio_flags |= VIRTIO_API_FLAG_GSO;
7570 else if (unformat (i, "csum-offload-enabled"))
7571 virtio_flags |= VIRTIO_API_FLAG_CSUM_OFFLOAD;
7572 else if (unformat (i, "gro-coalesce"))
7573 virtio_flags |= VIRTIO_API_FLAG_GRO_COALESCE;
7574 else if (unformat (i, "packed"))
7575 virtio_flags |= VIRTIO_API_FLAG_PACKED;
7576 else if (unformat (i, "in-order"))
7577 virtio_flags |= VIRTIO_API_FLAG_IN_ORDER;
7584 errmsg ("pci address must be non zero. ");
7588 /* Construct the API message */
7589 M (VIRTIO_PCI_CREATE_V2, mp);
7591 mp->use_random_mac = random_mac;
7593 mp->pci_addr.domain = htons (((vlib_pci_addr_t) pci_addr).domain);
7594 mp->pci_addr.bus = ((vlib_pci_addr_t) pci_addr).bus;
7595 mp->pci_addr.slot = ((vlib_pci_addr_t) pci_addr).slot;
7596 mp->pci_addr.function = ((vlib_pci_addr_t) pci_addr).function;
7598 mp->features = clib_host_to_net_u64 (features);
7599 mp->virtio_flags = clib_host_to_net_u32 (virtio_flags);
7601 if (random_mac == 0)
7602 clib_memcpy (mp->mac_address, mac_address, 6);
7607 /* Wait for a reply... */
7613 api_virtio_pci_delete (vat_main_t * vam)
7615 unformat_input_t *i = vam->input;
7616 vl_api_virtio_pci_delete_t *mp;
7617 u32 sw_if_index = ~0;
7618 u8 sw_if_index_set = 0;
7621 /* Parse args required to build the message */
7622 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7624 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7625 sw_if_index_set = 1;
7626 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7627 sw_if_index_set = 1;
7632 if (sw_if_index_set == 0)
7634 errmsg ("missing vpp interface name. ");
7638 /* Construct the API message */
7639 M (VIRTIO_PCI_DELETE, mp);
7641 mp->sw_if_index = htonl (sw_if_index);
7646 /* Wait for a reply... */
7652 api_bond_create (vat_main_t * vam)
7654 unformat_input_t *i = vam->input;
7655 vl_api_bond_create_t *mp;
7665 clib_memset (mac_address, 0, sizeof (mac_address));
7668 /* Parse args required to build the message */
7669 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7671 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
7673 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
7674 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
7676 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
7679 else if (unformat (i, "numa-only"))
7681 else if (unformat (i, "id %u", &id))
7687 if (mode_is_set == 0)
7689 errmsg ("Missing bond mode. ");
7693 /* Construct the API message */
7694 M (BOND_CREATE, mp);
7696 mp->use_custom_mac = custom_mac;
7698 mp->mode = htonl (mode);
7699 mp->lb = htonl (lb);
7700 mp->id = htonl (id);
7701 mp->numa_only = numa_only;
7704 clib_memcpy (mp->mac_address, mac_address, 6);
7709 /* Wait for a reply... */
7715 api_bond_create2 (vat_main_t * vam)
7717 unformat_input_t *i = vam->input;
7718 vl_api_bond_create2_t *mp;
7729 clib_memset (mac_address, 0, sizeof (mac_address));
7732 /* Parse args required to build the message */
7733 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7735 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
7737 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
7738 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
7740 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
7743 else if (unformat (i, "numa-only"))
7745 else if (unformat (i, "gso"))
7747 else if (unformat (i, "id %u", &id))
7753 if (mode_is_set == 0)
7755 errmsg ("Missing bond mode. ");
7759 /* Construct the API message */
7760 M (BOND_CREATE2, mp);
7762 mp->use_custom_mac = custom_mac;
7764 mp->mode = htonl (mode);
7765 mp->lb = htonl (lb);
7766 mp->id = htonl (id);
7767 mp->numa_only = numa_only;
7768 mp->enable_gso = gso;
7771 clib_memcpy (mp->mac_address, mac_address, 6);
7776 /* Wait for a reply... */
7782 api_bond_delete (vat_main_t * vam)
7784 unformat_input_t *i = vam->input;
7785 vl_api_bond_delete_t *mp;
7786 u32 sw_if_index = ~0;
7787 u8 sw_if_index_set = 0;
7790 /* Parse args required to build the message */
7791 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7793 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7794 sw_if_index_set = 1;
7795 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7796 sw_if_index_set = 1;
7801 if (sw_if_index_set == 0)
7803 errmsg ("missing vpp interface name. ");
7807 /* Construct the API message */
7808 M (BOND_DELETE, mp);
7810 mp->sw_if_index = ntohl (sw_if_index);
7815 /* Wait for a reply... */
7821 api_bond_add_member (vat_main_t * vam)
7823 unformat_input_t *i = vam->input;
7824 vl_api_bond_add_member_t *mp;
7825 u32 bond_sw_if_index;
7829 u32 bond_sw_if_index_is_set = 0;
7831 u8 sw_if_index_is_set = 0;
7833 /* Parse args required to build the message */
7834 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7836 if (unformat (i, "sw_if_index %d", &sw_if_index))
7837 sw_if_index_is_set = 1;
7838 else if (unformat (i, "bond %u", &bond_sw_if_index))
7839 bond_sw_if_index_is_set = 1;
7840 else if (unformat (i, "passive %d", &is_passive))
7842 else if (unformat (i, "long-timeout %d", &is_long_timeout))
7848 if (bond_sw_if_index_is_set == 0)
7850 errmsg ("Missing bond sw_if_index. ");
7853 if (sw_if_index_is_set == 0)
7855 errmsg ("Missing member sw_if_index. ");
7859 /* Construct the API message */
7860 M (BOND_ADD_MEMBER, mp);
7862 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
7863 mp->sw_if_index = ntohl (sw_if_index);
7864 mp->is_long_timeout = is_long_timeout;
7865 mp->is_passive = is_passive;
7870 /* Wait for a reply... */
7876 api_bond_detach_member (vat_main_t * vam)
7878 unformat_input_t *i = vam->input;
7879 vl_api_bond_detach_member_t *mp;
7880 u32 sw_if_index = ~0;
7881 u8 sw_if_index_set = 0;
7884 /* Parse args required to build the message */
7885 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7887 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7888 sw_if_index_set = 1;
7889 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7890 sw_if_index_set = 1;
7895 if (sw_if_index_set == 0)
7897 errmsg ("missing vpp interface name. ");
7901 /* Construct the API message */
7902 M (BOND_DETACH_MEMBER, mp);
7904 mp->sw_if_index = ntohl (sw_if_index);
7909 /* Wait for a reply... */
7915 api_ip_table_add_del (vat_main_t * vam)
7917 unformat_input_t *i = vam->input;
7918 vl_api_ip_table_add_del_t *mp;
7924 /* Parse args required to build the message */
7925 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7927 if (unformat (i, "ipv6"))
7929 else if (unformat (i, "del"))
7931 else if (unformat (i, "add"))
7933 else if (unformat (i, "table %d", &table_id))
7937 clib_warning ("parse error '%U'", format_unformat_error, i);
7944 errmsg ("missing table-ID");
7948 /* Construct the API message */
7949 M (IP_TABLE_ADD_DEL, mp);
7951 mp->table.table_id = ntohl (table_id);
7952 mp->table.is_ip6 = is_ipv6;
7953 mp->is_add = is_add;
7958 /* Wait for a reply... */
7965 unformat_fib_path (unformat_input_t * input, va_list * args)
7967 vat_main_t *vam = va_arg (*args, vat_main_t *);
7968 vl_api_fib_path_t *path = va_arg (*args, vl_api_fib_path_t *);
7969 u32 weight, preference;
7970 mpls_label_t out_label;
7972 clib_memset (path, 0, sizeof (*path));
7974 path->sw_if_index = ~0;
7978 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7980 if (unformat (input, "%U %U",
7981 unformat_vl_api_ip4_address,
7982 &path->nh.address.ip4,
7983 api_unformat_sw_if_index, vam, &path->sw_if_index))
7985 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7987 else if (unformat (input, "%U %U",
7988 unformat_vl_api_ip6_address,
7989 &path->nh.address.ip6,
7990 api_unformat_sw_if_index, vam, &path->sw_if_index))
7992 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7994 else if (unformat (input, "weight %u", &weight))
7996 path->weight = weight;
7998 else if (unformat (input, "preference %u", &preference))
8000 path->preference = preference;
8002 else if (unformat (input, "%U next-hop-table %d",
8003 unformat_vl_api_ip4_address,
8004 &path->nh.address.ip4, &path->table_id))
8006 path->proto = FIB_API_PATH_NH_PROTO_IP4;
8008 else if (unformat (input, "%U next-hop-table %d",
8009 unformat_vl_api_ip6_address,
8010 &path->nh.address.ip6, &path->table_id))
8012 path->proto = FIB_API_PATH_NH_PROTO_IP6;
8014 else if (unformat (input, "%U",
8015 unformat_vl_api_ip4_address, &path->nh.address.ip4))
8018 * the recursive next-hops are by default in the default table
8021 path->sw_if_index = ~0;
8022 path->proto = FIB_API_PATH_NH_PROTO_IP4;
8024 else if (unformat (input, "%U",
8025 unformat_vl_api_ip6_address, &path->nh.address.ip6))
8028 * the recursive next-hops are by default in the default table
8031 path->sw_if_index = ~0;
8032 path->proto = FIB_API_PATH_NH_PROTO_IP6;
8034 else if (unformat (input, "resolve-via-host"))
8036 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_HOST;
8038 else if (unformat (input, "resolve-via-attached"))
8040 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED;
8042 else if (unformat (input, "ip4-lookup-in-table %d", &path->table_id))
8044 path->type = FIB_API_PATH_TYPE_LOCAL;
8045 path->sw_if_index = ~0;
8046 path->proto = FIB_API_PATH_NH_PROTO_IP4;
8048 else if (unformat (input, "ip6-lookup-in-table %d", &path->table_id))
8050 path->type = FIB_API_PATH_TYPE_LOCAL;
8051 path->sw_if_index = ~0;
8052 path->proto = FIB_API_PATH_NH_PROTO_IP6;
8054 else if (unformat (input, "sw_if_index %d", &path->sw_if_index))
8056 else if (unformat (input, "via-label %d", &path->nh.via_label))
8058 path->proto = FIB_API_PATH_NH_PROTO_MPLS;
8059 path->sw_if_index = ~0;
8061 else if (unformat (input, "l2-input-on %d", &path->sw_if_index))
8063 path->proto = FIB_API_PATH_NH_PROTO_ETHERNET;
8064 path->type = FIB_API_PATH_TYPE_INTERFACE_RX;
8066 else if (unformat (input, "local"))
8068 path->type = FIB_API_PATH_TYPE_LOCAL;
8070 else if (unformat (input, "out-labels"))
8072 while (unformat (input, "%d", &out_label))
8074 path->label_stack[path->n_labels].label = out_label;
8075 path->label_stack[path->n_labels].is_uniform = 0;
8076 path->label_stack[path->n_labels].ttl = 64;
8080 else if (unformat (input, "via"))
8082 /* new path, back up and return */
8083 unformat_put_input (input);
8084 unformat_put_input (input);
8085 unformat_put_input (input);
8086 unformat_put_input (input);
8095 path->proto = ntohl (path->proto);
8096 path->type = ntohl (path->type);
8097 path->flags = ntohl (path->flags);
8098 path->table_id = ntohl (path->table_id);
8099 path->sw_if_index = ntohl (path->sw_if_index);
8105 api_ip_route_add_del (vat_main_t * vam)
8107 unformat_input_t *i = vam->input;
8108 vl_api_ip_route_add_del_t *mp;
8111 u8 is_multipath = 0;
8114 vl_api_prefix_t pfx = { };
8115 vl_api_fib_path_t paths[8];
8119 u32 random_add_del = 0;
8120 u32 *random_vector = 0;
8121 u32 random_seed = 0xdeaddabe;
8123 /* Parse args required to build the message */
8124 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8126 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
8128 else if (unformat (i, "del"))
8130 else if (unformat (i, "add"))
8132 else if (unformat (i, "vrf %d", &vrf_id))
8134 else if (unformat (i, "count %d", &count))
8136 else if (unformat (i, "random"))
8138 else if (unformat (i, "multipath"))
8140 else if (unformat (i, "seed %d", &random_seed))
8144 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8147 if (8 == path_count)
8149 errmsg ("max 8 paths");
8155 clib_warning ("parse error '%U'", format_unformat_error, i);
8162 errmsg ("specify a path; via ...");
8165 if (prefix_set == 0)
8167 errmsg ("missing prefix");
8171 /* Generate a pile of unique, random routes */
8174 ip4_address_t *i = (ip4_address_t *) & paths[0].nh.address.ip4;
8175 u32 this_random_address;
8178 random_hash = hash_create (count, sizeof (uword));
8180 hash_set (random_hash, i->as_u32, 1);
8181 for (j = 0; j <= count; j++)
8185 this_random_address = random_u32 (&random_seed);
8186 this_random_address =
8187 clib_host_to_net_u32 (this_random_address);
8189 while (hash_get (random_hash, this_random_address));
8190 vec_add1 (random_vector, this_random_address);
8191 hash_set (random_hash, this_random_address, 1);
8193 hash_free (random_hash);
8194 set_ip4_address (&pfx.address, random_vector[0]);
8199 /* Turn on async mode */
8200 vam->async_mode = 1;
8201 vam->async_errors = 0;
8202 before = vat_time_now (vam);
8205 for (j = 0; j < count; j++)
8207 /* Construct the API message */
8208 M2 (IP_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8210 mp->is_add = is_add;
8211 mp->is_multipath = is_multipath;
8213 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
8214 mp->route.table_id = ntohl (vrf_id);
8215 mp->route.n_paths = path_count;
8217 clib_memcpy (&mp->route.paths, &paths, sizeof (paths[0]) * path_count);
8220 set_ip4_address (&pfx.address, random_vector[j + 1]);
8222 increment_address (&pfx.address);
8225 /* If we receive SIGTERM, stop now... */
8230 /* When testing multiple add/del ops, use a control-ping to sync */
8233 vl_api_control_ping_t *mp_ping;
8237 /* Shut off async mode */
8238 vam->async_mode = 0;
8240 MPING (CONTROL_PING, mp_ping);
8243 timeout = vat_time_now (vam) + 1.0;
8244 while (vat_time_now (vam) < timeout)
8245 if (vam->result_ready == 1)
8250 if (vam->retval == -99)
8253 if (vam->async_errors > 0)
8255 errmsg ("%d asynchronous errors", vam->async_errors);
8258 vam->async_errors = 0;
8259 after = vat_time_now (vam);
8261 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8265 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8266 count, after - before, count / (after - before));
8272 /* Wait for a reply... */
8277 /* Return the good/bad news */
8278 return (vam->retval);
8282 api_ip_mroute_add_del (vat_main_t * vam)
8284 unformat_input_t *i = vam->input;
8285 u8 path_set = 0, prefix_set = 0, is_add = 1;
8286 vl_api_ip_mroute_add_del_t *mp;
8287 mfib_entry_flags_t eflags = 0;
8288 vl_api_mfib_path_t path;
8289 vl_api_mprefix_t pfx = { };
8293 /* Parse args required to build the message */
8294 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8296 if (unformat (i, "%U", unformat_vl_api_mprefix, &pfx))
8299 pfx.grp_address_length = htons (pfx.grp_address_length);
8301 else if (unformat (i, "del"))
8303 else if (unformat (i, "add"))
8305 else if (unformat (i, "vrf %d", &vrf_id))
8307 else if (unformat (i, "%U", unformat_mfib_itf_flags, &path.itf_flags))
8308 path.itf_flags = htonl (path.itf_flags);
8309 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8311 else if (unformat (i, "via %U", unformat_fib_path, vam, &path.path))
8315 clib_warning ("parse error '%U'", format_unformat_error, i);
8320 if (prefix_set == 0)
8322 errmsg ("missing addresses\n");
8327 errmsg ("missing path\n");
8331 /* Construct the API message */
8332 M (IP_MROUTE_ADD_DEL, mp);
8334 mp->is_add = is_add;
8335 mp->is_multipath = 1;
8337 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
8338 mp->route.table_id = htonl (vrf_id);
8339 mp->route.n_paths = 1;
8340 mp->route.entry_flags = htonl (eflags);
8342 clib_memcpy (&mp->route.paths, &path, sizeof (path));
8346 /* Wait for a reply... */
8352 api_mpls_table_add_del (vat_main_t * vam)
8354 unformat_input_t *i = vam->input;
8355 vl_api_mpls_table_add_del_t *mp;
8360 /* Parse args required to build the message */
8361 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8363 if (unformat (i, "table %d", &table_id))
8365 else if (unformat (i, "del"))
8367 else if (unformat (i, "add"))
8371 clib_warning ("parse error '%U'", format_unformat_error, i);
8378 errmsg ("missing table-ID");
8382 /* Construct the API message */
8383 M (MPLS_TABLE_ADD_DEL, mp);
8385 mp->mt_table.mt_table_id = ntohl (table_id);
8386 mp->mt_is_add = is_add;
8391 /* Wait for a reply... */
8398 api_mpls_route_add_del (vat_main_t * vam)
8400 u8 is_add = 1, path_count = 0, is_multipath = 0, is_eos = 0;
8401 mpls_label_t local_label = MPLS_LABEL_INVALID;
8402 unformat_input_t *i = vam->input;
8403 vl_api_mpls_route_add_del_t *mp;
8404 vl_api_fib_path_t paths[8];
8408 /* Parse args required to build the message */
8409 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8411 if (unformat (i, "%d", &local_label))
8413 else if (unformat (i, "eos"))
8415 else if (unformat (i, "non-eos"))
8417 else if (unformat (i, "del"))
8419 else if (unformat (i, "add"))
8421 else if (unformat (i, "multipath"))
8423 else if (unformat (i, "count %d", &count))
8427 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8430 if (8 == path_count)
8432 errmsg ("max 8 paths");
8438 clib_warning ("parse error '%U'", format_unformat_error, i);
8445 errmsg ("specify a path; via ...");
8449 if (MPLS_LABEL_INVALID == local_label)
8451 errmsg ("missing label");
8457 /* Turn on async mode */
8458 vam->async_mode = 1;
8459 vam->async_errors = 0;
8460 before = vat_time_now (vam);
8463 for (j = 0; j < count; j++)
8465 /* Construct the API message */
8466 M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8468 mp->mr_is_add = is_add;
8469 mp->mr_is_multipath = is_multipath;
8471 mp->mr_route.mr_label = local_label;
8472 mp->mr_route.mr_eos = is_eos;
8473 mp->mr_route.mr_table_id = 0;
8474 mp->mr_route.mr_n_paths = path_count;
8476 clib_memcpy (&mp->mr_route.mr_paths, paths,
8477 sizeof (paths[0]) * path_count);
8483 /* If we receive SIGTERM, stop now... */
8488 /* When testing multiple add/del ops, use a control-ping to sync */
8491 vl_api_control_ping_t *mp_ping;
8495 /* Shut off async mode */
8496 vam->async_mode = 0;
8498 MPING (CONTROL_PING, mp_ping);
8501 timeout = vat_time_now (vam) + 1.0;
8502 while (vat_time_now (vam) < timeout)
8503 if (vam->result_ready == 1)
8508 if (vam->retval == -99)
8511 if (vam->async_errors > 0)
8513 errmsg ("%d asynchronous errors", vam->async_errors);
8516 vam->async_errors = 0;
8517 after = vat_time_now (vam);
8519 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8523 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8524 count, after - before, count / (after - before));
8530 /* Wait for a reply... */
8535 /* Return the good/bad news */
8536 return (vam->retval);
8541 api_mpls_ip_bind_unbind (vat_main_t * vam)
8543 unformat_input_t *i = vam->input;
8544 vl_api_mpls_ip_bind_unbind_t *mp;
8545 u32 ip_table_id = 0;
8547 vl_api_prefix_t pfx;
8549 mpls_label_t local_label = MPLS_LABEL_INVALID;
8552 /* Parse args required to build the message */
8553 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8555 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
8557 else if (unformat (i, "%d", &local_label))
8559 else if (unformat (i, "table-id %d", &ip_table_id))
8561 else if (unformat (i, "unbind"))
8563 else if (unformat (i, "bind"))
8567 clib_warning ("parse error '%U'", format_unformat_error, i);
8574 errmsg ("IP prefix not set");
8578 if (MPLS_LABEL_INVALID == local_label)
8580 errmsg ("missing label");
8584 /* Construct the API message */
8585 M (MPLS_IP_BIND_UNBIND, mp);
8587 mp->mb_is_bind = is_bind;
8588 mp->mb_ip_table_id = ntohl (ip_table_id);
8589 mp->mb_mpls_table_id = 0;
8590 mp->mb_label = ntohl (local_label);
8591 clib_memcpy (&mp->mb_prefix, &pfx, sizeof (pfx));
8596 /* Wait for a reply... */
8603 api_sr_mpls_policy_add (vat_main_t * vam)
8605 unformat_input_t *i = vam->input;
8606 vl_api_sr_mpls_policy_add_t *mp;
8612 u32 *segments = NULL;
8615 /* Parse args required to build the message */
8616 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8618 if (unformat (i, "bsid %d", &bsid))
8620 else if (unformat (i, "weight %d", &weight))
8622 else if (unformat (i, "spray"))
8624 else if (unformat (i, "next %d", &sid))
8627 vec_add1 (segments, htonl (sid));
8631 clib_warning ("parse error '%U'", format_unformat_error, i);
8638 errmsg ("bsid not set");
8642 if (n_segments == 0)
8644 errmsg ("no sid in segment stack");
8648 /* Construct the API message */
8649 M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
8651 mp->bsid = htonl (bsid);
8652 mp->weight = htonl (weight);
8653 mp->is_spray = type;
8654 mp->n_segments = n_segments;
8655 memcpy (mp->segments, segments, sizeof (u32) * n_segments);
8656 vec_free (segments);
8661 /* Wait for a reply... */
8667 api_sr_mpls_policy_del (vat_main_t * vam)
8669 unformat_input_t *i = vam->input;
8670 vl_api_sr_mpls_policy_del_t *mp;
8674 /* Parse args required to build the message */
8675 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8677 if (unformat (i, "bsid %d", &bsid))
8681 clib_warning ("parse error '%U'", format_unformat_error, i);
8688 errmsg ("bsid not set");
8692 /* Construct the API message */
8693 M (SR_MPLS_POLICY_DEL, mp);
8695 mp->bsid = htonl (bsid);
8700 /* Wait for a reply... */
8706 api_bier_table_add_del (vat_main_t * vam)
8708 unformat_input_t *i = vam->input;
8709 vl_api_bier_table_add_del_t *mp;
8711 u32 set = 0, sub_domain = 0, hdr_len = 3;
8712 mpls_label_t local_label = MPLS_LABEL_INVALID;
8715 /* Parse args required to build the message */
8716 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8718 if (unformat (i, "sub-domain %d", &sub_domain))
8720 else if (unformat (i, "set %d", &set))
8722 else if (unformat (i, "label %d", &local_label))
8724 else if (unformat (i, "hdr-len %d", &hdr_len))
8726 else if (unformat (i, "add"))
8728 else if (unformat (i, "del"))
8732 clib_warning ("parse error '%U'", format_unformat_error, i);
8737 if (MPLS_LABEL_INVALID == local_label)
8739 errmsg ("missing label\n");
8743 /* Construct the API message */
8744 M (BIER_TABLE_ADD_DEL, mp);
8746 mp->bt_is_add = is_add;
8747 mp->bt_label = ntohl (local_label);
8748 mp->bt_tbl_id.bt_set = set;
8749 mp->bt_tbl_id.bt_sub_domain = sub_domain;
8750 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
8755 /* Wait for a reply... */
8762 api_bier_route_add_del (vat_main_t * vam)
8764 unformat_input_t *i = vam->input;
8765 vl_api_bier_route_add_del_t *mp;
8767 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
8768 ip4_address_t v4_next_hop_address;
8769 ip6_address_t v6_next_hop_address;
8770 u8 next_hop_set = 0;
8771 u8 next_hop_proto_is_ip4 = 1;
8772 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8775 /* Parse args required to build the message */
8776 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8778 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
8780 next_hop_proto_is_ip4 = 1;
8783 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
8785 next_hop_proto_is_ip4 = 0;
8788 if (unformat (i, "sub-domain %d", &sub_domain))
8790 else if (unformat (i, "set %d", &set))
8792 else if (unformat (i, "hdr-len %d", &hdr_len))
8794 else if (unformat (i, "bp %d", &bp))
8796 else if (unformat (i, "add"))
8798 else if (unformat (i, "del"))
8800 else if (unformat (i, "out-label %d", &next_hop_out_label))
8804 clib_warning ("parse error '%U'", format_unformat_error, i);
8809 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
8811 errmsg ("next hop / label set\n");
8816 errmsg ("bit=position not set\n");
8820 /* Construct the API message */
8821 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
8823 mp->br_is_add = is_add;
8824 mp->br_route.br_tbl_id.bt_set = set;
8825 mp->br_route.br_tbl_id.bt_sub_domain = sub_domain;
8826 mp->br_route.br_tbl_id.bt_hdr_len_id = hdr_len;
8827 mp->br_route.br_bp = ntohs (bp);
8828 mp->br_route.br_n_paths = 1;
8829 mp->br_route.br_paths[0].n_labels = 1;
8830 mp->br_route.br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
8831 mp->br_route.br_paths[0].proto = (next_hop_proto_is_ip4 ?
8832 FIB_API_PATH_NH_PROTO_IP4 :
8833 FIB_API_PATH_NH_PROTO_IP6);
8835 if (next_hop_proto_is_ip4)
8837 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip4,
8838 &v4_next_hop_address, sizeof (v4_next_hop_address));
8842 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip6,
8843 &v6_next_hop_address, sizeof (v6_next_hop_address));
8849 /* Wait for a reply... */
8856 api_mpls_tunnel_add_del (vat_main_t * vam)
8858 unformat_input_t *i = vam->input;
8859 vl_api_mpls_tunnel_add_del_t *mp;
8861 vl_api_fib_path_t paths[8];
8862 u32 sw_if_index = ~0;
8868 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8870 if (unformat (i, "add"))
8874 (i, "del %U", api_unformat_sw_if_index, vam, &sw_if_index))
8876 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
8878 else if (unformat (i, "l2-only"))
8882 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8885 if (8 == path_count)
8887 errmsg ("max 8 paths");
8893 clib_warning ("parse error '%U'", format_unformat_error, i);
8898 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8900 mp->mt_is_add = is_add;
8901 mp->mt_tunnel.mt_sw_if_index = ntohl (sw_if_index);
8902 mp->mt_tunnel.mt_l2_only = l2_only;
8903 mp->mt_tunnel.mt_is_multicast = 0;
8904 mp->mt_tunnel.mt_n_paths = path_count;
8906 clib_memcpy (&mp->mt_tunnel.mt_paths, &paths,
8907 sizeof (paths[0]) * path_count);
8915 api_sw_interface_set_unnumbered (vat_main_t * vam)
8917 unformat_input_t *i = vam->input;
8918 vl_api_sw_interface_set_unnumbered_t *mp;
8920 u32 unnum_sw_index = ~0;
8922 u8 sw_if_index_set = 0;
8925 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8927 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8928 sw_if_index_set = 1;
8929 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8930 sw_if_index_set = 1;
8931 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
8933 else if (unformat (i, "del"))
8937 clib_warning ("parse error '%U'", format_unformat_error, i);
8942 if (sw_if_index_set == 0)
8944 errmsg ("missing interface name or sw_if_index");
8948 M (SW_INTERFACE_SET_UNNUMBERED, mp);
8950 mp->sw_if_index = ntohl (sw_if_index);
8951 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
8952 mp->is_add = is_add;
8961 api_create_vlan_subif (vat_main_t * vam)
8963 unformat_input_t *i = vam->input;
8964 vl_api_create_vlan_subif_t *mp;
8966 u8 sw_if_index_set = 0;
8971 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8973 if (unformat (i, "sw_if_index %d", &sw_if_index))
8974 sw_if_index_set = 1;
8976 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8977 sw_if_index_set = 1;
8978 else if (unformat (i, "vlan %d", &vlan_id))
8982 clib_warning ("parse error '%U'", format_unformat_error, i);
8987 if (sw_if_index_set == 0)
8989 errmsg ("missing interface name or sw_if_index");
8993 if (vlan_id_set == 0)
8995 errmsg ("missing vlan_id");
8998 M (CREATE_VLAN_SUBIF, mp);
9000 mp->sw_if_index = ntohl (sw_if_index);
9001 mp->vlan_id = ntohl (vlan_id);
9008 #define foreach_create_subif_bit \
9015 _(outer_vlan_id_any) \
9016 _(inner_vlan_id_any)
9018 #define foreach_create_subif_flag \
9023 _(4, "exact_match") \
9024 _(5, "default_sub") \
9025 _(6, "outer_vlan_id_any") \
9026 _(7, "inner_vlan_id_any")
9029 api_create_subif (vat_main_t * vam)
9031 unformat_input_t *i = vam->input;
9032 vl_api_create_subif_t *mp;
9034 u8 sw_if_index_set = 0;
9037 u32 __attribute__ ((unused)) no_tags = 0;
9038 u32 __attribute__ ((unused)) one_tag = 0;
9039 u32 __attribute__ ((unused)) two_tags = 0;
9040 u32 __attribute__ ((unused)) dot1ad = 0;
9041 u32 __attribute__ ((unused)) exact_match = 0;
9042 u32 __attribute__ ((unused)) default_sub = 0;
9043 u32 __attribute__ ((unused)) outer_vlan_id_any = 0;
9044 u32 __attribute__ ((unused)) inner_vlan_id_any = 0;
9046 u16 outer_vlan_id = 0;
9047 u16 inner_vlan_id = 0;
9050 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9052 if (unformat (i, "sw_if_index %d", &sw_if_index))
9053 sw_if_index_set = 1;
9055 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9056 sw_if_index_set = 1;
9057 else if (unformat (i, "sub_id %d", &sub_id))
9059 else if (unformat (i, "outer_vlan_id %d", &tmp))
9060 outer_vlan_id = tmp;
9061 else if (unformat (i, "inner_vlan_id %d", &tmp))
9062 inner_vlan_id = tmp;
9064 #define _(a) else if (unformat (i, #a)) a = 1 ;
9065 foreach_create_subif_bit
9069 clib_warning ("parse error '%U'", format_unformat_error, i);
9074 if (sw_if_index_set == 0)
9076 errmsg ("missing interface name or sw_if_index");
9080 if (sub_id_set == 0)
9082 errmsg ("missing sub_id");
9085 M (CREATE_SUBIF, mp);
9087 mp->sw_if_index = ntohl (sw_if_index);
9088 mp->sub_id = ntohl (sub_id);
9090 #define _(a,b) mp->sub_if_flags |= (1 << a);
9091 foreach_create_subif_flag;
9094 mp->outer_vlan_id = ntohs (outer_vlan_id);
9095 mp->inner_vlan_id = ntohs (inner_vlan_id);
9103 api_ip_table_replace_begin (vat_main_t * vam)
9105 unformat_input_t *i = vam->input;
9106 vl_api_ip_table_replace_begin_t *mp;
9111 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9113 if (unformat (i, "table %d", &table_id))
9115 else if (unformat (i, "ipv6"))
9119 clib_warning ("parse error '%U'", format_unformat_error, i);
9124 M (IP_TABLE_REPLACE_BEGIN, mp);
9126 mp->table.table_id = ntohl (table_id);
9127 mp->table.is_ip6 = is_ipv6;
9135 api_ip_table_flush (vat_main_t * vam)
9137 unformat_input_t *i = vam->input;
9138 vl_api_ip_table_flush_t *mp;
9143 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9145 if (unformat (i, "table %d", &table_id))
9147 else if (unformat (i, "ipv6"))
9151 clib_warning ("parse error '%U'", format_unformat_error, i);
9156 M (IP_TABLE_FLUSH, mp);
9158 mp->table.table_id = ntohl (table_id);
9159 mp->table.is_ip6 = is_ipv6;
9167 api_ip_table_replace_end (vat_main_t * vam)
9169 unformat_input_t *i = vam->input;
9170 vl_api_ip_table_replace_end_t *mp;
9175 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9177 if (unformat (i, "table %d", &table_id))
9179 else if (unformat (i, "ipv6"))
9183 clib_warning ("parse error '%U'", format_unformat_error, i);
9188 M (IP_TABLE_REPLACE_END, mp);
9190 mp->table.table_id = ntohl (table_id);
9191 mp->table.is_ip6 = is_ipv6;
9199 api_set_ip_flow_hash (vat_main_t * vam)
9201 unformat_input_t *i = vam->input;
9202 vl_api_set_ip_flow_hash_t *mp;
9214 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9216 if (unformat (i, "vrf %d", &vrf_id))
9218 else if (unformat (i, "ipv6"))
9220 else if (unformat (i, "src"))
9222 else if (unformat (i, "dst"))
9224 else if (unformat (i, "sport"))
9226 else if (unformat (i, "dport"))
9228 else if (unformat (i, "proto"))
9230 else if (unformat (i, "reverse"))
9235 clib_warning ("parse error '%U'", format_unformat_error, i);
9240 if (vrf_id_set == 0)
9242 errmsg ("missing vrf id");
9246 M (SET_IP_FLOW_HASH, mp);
9252 mp->reverse = reverse;
9253 mp->vrf_id = ntohl (vrf_id);
9254 mp->is_ipv6 = is_ipv6;
9262 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
9264 unformat_input_t *i = vam->input;
9265 vl_api_sw_interface_ip6_enable_disable_t *mp;
9267 u8 sw_if_index_set = 0;
9271 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9273 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9274 sw_if_index_set = 1;
9275 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9276 sw_if_index_set = 1;
9277 else if (unformat (i, "enable"))
9279 else if (unformat (i, "disable"))
9283 clib_warning ("parse error '%U'", format_unformat_error, i);
9288 if (sw_if_index_set == 0)
9290 errmsg ("missing interface name or sw_if_index");
9294 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
9296 mp->sw_if_index = ntohl (sw_if_index);
9297 mp->enable = enable;
9306 api_l2_patch_add_del (vat_main_t * vam)
9308 unformat_input_t *i = vam->input;
9309 vl_api_l2_patch_add_del_t *mp;
9311 u8 rx_sw_if_index_set = 0;
9313 u8 tx_sw_if_index_set = 0;
9317 /* Parse args required to build the message */
9318 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9320 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
9321 rx_sw_if_index_set = 1;
9322 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
9323 tx_sw_if_index_set = 1;
9324 else if (unformat (i, "rx"))
9326 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9328 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9330 rx_sw_if_index_set = 1;
9335 else if (unformat (i, "tx"))
9337 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9339 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9341 tx_sw_if_index_set = 1;
9346 else if (unformat (i, "del"))
9352 if (rx_sw_if_index_set == 0)
9354 errmsg ("missing rx interface name or rx_sw_if_index");
9358 if (tx_sw_if_index_set == 0)
9360 errmsg ("missing tx interface name or tx_sw_if_index");
9364 M (L2_PATCH_ADD_DEL, mp);
9366 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
9367 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
9368 mp->is_add = is_add;
9376 u8 localsid_addr[16];
9385 api_sr_localsid_add_del (vat_main_t * vam)
9387 unformat_input_t *i = vam->input;
9388 vl_api_sr_localsid_add_del_t *mp;
9391 ip6_address_t localsid;
9395 u32 fib_table = ~(u32) 0;
9396 ip46_address_t nh_addr;
9397 clib_memset (&nh_addr, 0, sizeof (ip46_address_t));
9399 bool nexthop_set = 0;
9403 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9405 if (unformat (i, "del"))
9407 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
9408 else if (unformat (i, "next-hop %U", unformat_ip46_address, &nh_addr))
9410 else if (unformat (i, "behavior %u", &behavior));
9411 else if (unformat (i, "sw_if_index %u", &sw_if_index));
9412 else if (unformat (i, "fib-table %u", &fib_table));
9413 else if (unformat (i, "end.psp %u", &behavior));
9418 M (SR_LOCALSID_ADD_DEL, mp);
9420 clib_memcpy (mp->localsid, &localsid, sizeof (mp->localsid));
9424 clib_memcpy (&mp->nh_addr.un, &nh_addr, sizeof (mp->nh_addr.un));
9426 mp->behavior = behavior;
9427 mp->sw_if_index = ntohl (sw_if_index);
9428 mp->fib_table = ntohl (fib_table);
9429 mp->end_psp = end_psp;
9430 mp->is_del = is_del;
9438 api_ioam_enable (vat_main_t * vam)
9440 unformat_input_t *input = vam->input;
9441 vl_api_ioam_enable_t *mp;
9443 int has_trace_option = 0;
9444 int has_pot_option = 0;
9445 int has_seqno_option = 0;
9446 int has_analyse_option = 0;
9449 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9451 if (unformat (input, "trace"))
9452 has_trace_option = 1;
9453 else if (unformat (input, "pot"))
9455 else if (unformat (input, "seqno"))
9456 has_seqno_option = 1;
9457 else if (unformat (input, "analyse"))
9458 has_analyse_option = 1;
9462 M (IOAM_ENABLE, mp);
9463 mp->id = htons (id);
9464 mp->seqno = has_seqno_option;
9465 mp->analyse = has_analyse_option;
9466 mp->pot_enable = has_pot_option;
9467 mp->trace_enable = has_trace_option;
9476 api_ioam_disable (vat_main_t * vam)
9478 vl_api_ioam_disable_t *mp;
9481 M (IOAM_DISABLE, mp);
9487 #define foreach_tcp_proto_field \
9491 #define foreach_udp_proto_field \
9495 #define foreach_ip4_proto_field \
9507 u16 src_port, dst_port;
9510 #if VPP_API_TEST_BUILTIN == 0
9512 unformat_tcp_mask (unformat_input_t * input, va_list * args)
9514 u8 **maskp = va_arg (*args, u8 **);
9516 u8 found_something = 0;
9519 #define _(a) u8 a=0;
9520 foreach_tcp_proto_field;
9523 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9526 #define _(a) else if (unformat (input, #a)) a=1;
9527 foreach_tcp_proto_field
9533 #define _(a) found_something += a;
9534 foreach_tcp_proto_field;
9537 if (found_something == 0)
9540 vec_validate (mask, sizeof (*tcp) - 1);
9542 tcp = (tcp_header_t *) mask;
9544 #define _(a) if (a) clib_memset (&tcp->a, 0xff, sizeof (tcp->a));
9545 foreach_tcp_proto_field;
9553 unformat_udp_mask (unformat_input_t * input, va_list * args)
9555 u8 **maskp = va_arg (*args, u8 **);
9557 u8 found_something = 0;
9560 #define _(a) u8 a=0;
9561 foreach_udp_proto_field;
9564 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9567 #define _(a) else if (unformat (input, #a)) a=1;
9568 foreach_udp_proto_field
9574 #define _(a) found_something += a;
9575 foreach_udp_proto_field;
9578 if (found_something == 0)
9581 vec_validate (mask, sizeof (*udp) - 1);
9583 udp = (udp_header_t *) mask;
9585 #define _(a) if (a) clib_memset (&udp->a, 0xff, sizeof (udp->a));
9586 foreach_udp_proto_field;
9594 unformat_l4_mask (unformat_input_t * input, va_list * args)
9596 u8 **maskp = va_arg (*args, u8 **);
9597 u16 src_port = 0, dst_port = 0;
9598 tcpudp_header_t *tcpudp;
9600 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9602 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
9604 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
9606 else if (unformat (input, "src_port"))
9608 else if (unformat (input, "dst_port"))
9614 if (!src_port && !dst_port)
9618 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
9620 tcpudp = (tcpudp_header_t *) mask;
9621 tcpudp->src_port = src_port;
9622 tcpudp->dst_port = dst_port;
9630 unformat_ip4_mask (unformat_input_t * input, va_list * args)
9632 u8 **maskp = va_arg (*args, u8 **);
9634 u8 found_something = 0;
9637 #define _(a) u8 a=0;
9638 foreach_ip4_proto_field;
9644 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9646 if (unformat (input, "version"))
9648 else if (unformat (input, "hdr_length"))
9650 else if (unformat (input, "src"))
9652 else if (unformat (input, "dst"))
9654 else if (unformat (input, "proto"))
9657 #define _(a) else if (unformat (input, #a)) a=1;
9658 foreach_ip4_proto_field
9664 #define _(a) found_something += a;
9665 foreach_ip4_proto_field;
9668 if (found_something == 0)
9671 vec_validate (mask, sizeof (*ip) - 1);
9673 ip = (ip4_header_t *) mask;
9675 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
9676 foreach_ip4_proto_field;
9679 ip->ip_version_and_header_length = 0;
9682 ip->ip_version_and_header_length |= 0xF0;
9685 ip->ip_version_and_header_length |= 0x0F;
9691 #define foreach_ip6_proto_field \
9699 unformat_ip6_mask (unformat_input_t * input, va_list * args)
9701 u8 **maskp = va_arg (*args, u8 **);
9703 u8 found_something = 0;
9705 u32 ip_version_traffic_class_and_flow_label;
9707 #define _(a) u8 a=0;
9708 foreach_ip6_proto_field;
9711 u8 traffic_class = 0;
9714 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9716 if (unformat (input, "version"))
9718 else if (unformat (input, "traffic-class"))
9720 else if (unformat (input, "flow-label"))
9722 else if (unformat (input, "src"))
9724 else if (unformat (input, "dst"))
9726 else if (unformat (input, "proto"))
9729 #define _(a) else if (unformat (input, #a)) a=1;
9730 foreach_ip6_proto_field
9736 #define _(a) found_something += a;
9737 foreach_ip6_proto_field;
9740 if (found_something == 0)
9743 vec_validate (mask, sizeof (*ip) - 1);
9745 ip = (ip6_header_t *) mask;
9747 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
9748 foreach_ip6_proto_field;
9751 ip_version_traffic_class_and_flow_label = 0;
9754 ip_version_traffic_class_and_flow_label |= 0xF0000000;
9757 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
9760 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
9762 ip->ip_version_traffic_class_and_flow_label =
9763 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9770 unformat_l3_mask (unformat_input_t * input, va_list * args)
9772 u8 **maskp = va_arg (*args, u8 **);
9774 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9776 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
9778 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
9787 unformat_l2_mask (unformat_input_t * input, va_list * args)
9789 u8 **maskp = va_arg (*args, u8 **);
9804 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9806 if (unformat (input, "src"))
9808 else if (unformat (input, "dst"))
9810 else if (unformat (input, "proto"))
9812 else if (unformat (input, "tag1"))
9814 else if (unformat (input, "tag2"))
9816 else if (unformat (input, "ignore-tag1"))
9818 else if (unformat (input, "ignore-tag2"))
9820 else if (unformat (input, "cos1"))
9822 else if (unformat (input, "cos2"))
9824 else if (unformat (input, "dot1q"))
9826 else if (unformat (input, "dot1ad"))
9831 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
9832 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9835 if (tag1 || ignore_tag1 || cos1 || dot1q)
9837 if (tag2 || ignore_tag2 || cos2 || dot1ad)
9840 vec_validate (mask, len - 1);
9843 clib_memset (mask, 0xff, 6);
9846 clib_memset (mask + 6, 0xff, 6);
9850 /* inner vlan tag */
9859 mask[21] = mask[20] = 0xff;
9880 mask[16] = mask[17] = 0xff;
9890 mask[12] = mask[13] = 0xff;
9897 unformat_classify_mask (unformat_input_t * input, va_list * args)
9899 u8 **maskp = va_arg (*args, u8 **);
9900 u32 *skipp = va_arg (*args, u32 *);
9901 u32 *matchp = va_arg (*args, u32 *);
9909 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9911 if (unformat (input, "hex %U", unformat_hex_string, &mask))
9913 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
9915 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
9917 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
9931 if (mask || l2 || l3 || l4)
9935 /* "With a free Ethernet header in every package" */
9937 vec_validate (l2, 13);
9941 vec_append (mask, l3);
9946 vec_append (mask, l4);
9951 /* Scan forward looking for the first significant mask octet */
9952 for (i = 0; i < vec_len (mask); i++)
9956 /* compute (skip, match) params */
9957 *skipp = i / sizeof (u32x4);
9958 vec_delete (mask, *skipp * sizeof (u32x4), 0);
9960 /* Pad mask to an even multiple of the vector size */
9961 while (vec_len (mask) % sizeof (u32x4))
9964 match = vec_len (mask) / sizeof (u32x4);
9966 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
9968 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
9969 if (*tmp || *(tmp + 1))
9974 clib_warning ("BUG: match 0");
9976 _vec_len (mask) = match * sizeof (u32x4);
9986 #endif /* VPP_API_TEST_BUILTIN */
9988 #define foreach_l2_next \
9990 _(ethernet, ETHERNET_INPUT) \
9995 unformat_l2_next_index (unformat_input_t * input, va_list * args)
9997 u32 *miss_next_indexp = va_arg (*args, u32 *);
10002 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
10006 if (unformat (input, "%d", &tmp))
10015 *miss_next_indexp = next_index;
10019 #define foreach_ip_next \
10022 _(rewrite, REWRITE)
10025 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
10027 u32 *miss_next_indexp = va_arg (*args, u32 *);
10028 u32 next_index = 0;
10032 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
10036 if (unformat (input, "%d", &tmp))
10045 *miss_next_indexp = next_index;
10049 #define foreach_acl_next \
10053 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
10055 u32 *miss_next_indexp = va_arg (*args, u32 *);
10056 u32 next_index = 0;
10060 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
10064 if (unformat (input, "permit"))
10069 else if (unformat (input, "%d", &tmp))
10078 *miss_next_indexp = next_index;
10083 unformat_policer_precolor (unformat_input_t * input, va_list * args)
10085 u32 *r = va_arg (*args, u32 *);
10087 if (unformat (input, "conform-color"))
10088 *r = POLICE_CONFORM;
10089 else if (unformat (input, "exceed-color"))
10090 *r = POLICE_EXCEED;
10098 api_classify_add_del_table (vat_main_t * vam)
10100 unformat_input_t *i = vam->input;
10101 vl_api_classify_add_del_table_t *mp;
10108 u32 table_index = ~0;
10109 u32 next_table_index = ~0;
10110 u32 miss_next_index = ~0;
10111 u32 memory_size = 32 << 20;
10113 u32 current_data_flag = 0;
10114 int current_data_offset = 0;
10117 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10119 if (unformat (i, "del"))
10121 else if (unformat (i, "del-chain"))
10126 else if (unformat (i, "buckets %d", &nbuckets))
10128 else if (unformat (i, "memory_size %d", &memory_size))
10130 else if (unformat (i, "skip %d", &skip))
10132 else if (unformat (i, "match %d", &match))
10134 else if (unformat (i, "table %d", &table_index))
10136 else if (unformat (i, "mask %U", unformat_classify_mask,
10137 &mask, &skip, &match))
10139 else if (unformat (i, "next-table %d", &next_table_index))
10141 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
10144 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
10147 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
10150 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
10152 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
10158 if (is_add && mask == 0)
10160 errmsg ("Mask required");
10164 if (is_add && skip == ~0)
10166 errmsg ("skip count required");
10170 if (is_add && match == ~0)
10172 errmsg ("match count required");
10176 if (!is_add && table_index == ~0)
10178 errmsg ("table index required for delete");
10182 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
10184 mp->is_add = is_add;
10185 mp->del_chain = del_chain;
10186 mp->table_index = ntohl (table_index);
10187 mp->nbuckets = ntohl (nbuckets);
10188 mp->memory_size = ntohl (memory_size);
10189 mp->skip_n_vectors = ntohl (skip);
10190 mp->match_n_vectors = ntohl (match);
10191 mp->next_table_index = ntohl (next_table_index);
10192 mp->miss_next_index = ntohl (miss_next_index);
10193 mp->current_data_flag = ntohl (current_data_flag);
10194 mp->current_data_offset = ntohl (current_data_offset);
10195 mp->mask_len = ntohl (vec_len (mask));
10196 clib_memcpy (mp->mask, mask, vec_len (mask));
10205 #if VPP_API_TEST_BUILTIN == 0
10207 unformat_l4_match (unformat_input_t * input, va_list * args)
10209 u8 **matchp = va_arg (*args, u8 **);
10211 u8 *proto_header = 0;
10217 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10219 if (unformat (input, "src_port %d", &src_port))
10221 else if (unformat (input, "dst_port %d", &dst_port))
10227 h.src_port = clib_host_to_net_u16 (src_port);
10228 h.dst_port = clib_host_to_net_u16 (dst_port);
10229 vec_validate (proto_header, sizeof (h) - 1);
10230 memcpy (proto_header, &h, sizeof (h));
10232 *matchp = proto_header;
10238 unformat_ip4_match (unformat_input_t * input, va_list * args)
10240 u8 **matchp = va_arg (*args, u8 **);
10245 int hdr_length = 0;
10246 u32 hdr_length_val;
10247 int src = 0, dst = 0;
10248 ip4_address_t src_val, dst_val;
10255 int fragment_id = 0;
10256 u32 fragment_id_val;
10262 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10264 if (unformat (input, "version %d", &version_val))
10266 else if (unformat (input, "hdr_length %d", &hdr_length_val))
10268 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
10270 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
10272 else if (unformat (input, "proto %d", &proto_val))
10274 else if (unformat (input, "tos %d", &tos_val))
10276 else if (unformat (input, "length %d", &length_val))
10278 else if (unformat (input, "fragment_id %d", &fragment_id_val))
10280 else if (unformat (input, "ttl %d", &ttl_val))
10282 else if (unformat (input, "checksum %d", &checksum_val))
10288 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
10289 + ttl + checksum == 0)
10293 * Aligned because we use the real comparison functions
10295 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10297 ip = (ip4_header_t *) match;
10299 /* These are realistically matched in practice */
10301 ip->src_address.as_u32 = src_val.as_u32;
10304 ip->dst_address.as_u32 = dst_val.as_u32;
10307 ip->protocol = proto_val;
10310 /* These are not, but they're included for completeness */
10312 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
10315 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
10321 ip->length = clib_host_to_net_u16 (length_val);
10327 ip->checksum = clib_host_to_net_u16 (checksum_val);
10334 unformat_ip6_match (unformat_input_t * input, va_list * args)
10336 u8 **matchp = va_arg (*args, u8 **);
10341 u8 traffic_class = 0;
10342 u32 traffic_class_val = 0;
10345 int src = 0, dst = 0;
10346 ip6_address_t src_val, dst_val;
10349 int payload_length = 0;
10350 u32 payload_length_val;
10353 u32 ip_version_traffic_class_and_flow_label;
10355 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10357 if (unformat (input, "version %d", &version_val))
10359 else if (unformat (input, "traffic_class %d", &traffic_class_val))
10361 else if (unformat (input, "flow_label %d", &flow_label_val))
10363 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
10365 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
10367 else if (unformat (input, "proto %d", &proto_val))
10369 else if (unformat (input, "payload_length %d", &payload_length_val))
10370 payload_length = 1;
10371 else if (unformat (input, "hop_limit %d", &hop_limit_val))
10377 if (version + traffic_class + flow_label + src + dst + proto +
10378 payload_length + hop_limit == 0)
10382 * Aligned because we use the real comparison functions
10384 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10386 ip = (ip6_header_t *) match;
10389 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
10392 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
10395 ip->protocol = proto_val;
10397 ip_version_traffic_class_and_flow_label = 0;
10400 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
10403 ip_version_traffic_class_and_flow_label |=
10404 (traffic_class_val & 0xFF) << 20;
10407 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
10409 ip->ip_version_traffic_class_and_flow_label =
10410 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10412 if (payload_length)
10413 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
10416 ip->hop_limit = hop_limit_val;
10423 unformat_l3_match (unformat_input_t * input, va_list * args)
10425 u8 **matchp = va_arg (*args, u8 **);
10427 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10429 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
10431 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
10440 unformat_vlan_tag (unformat_input_t * input, va_list * args)
10442 u8 *tagp = va_arg (*args, u8 *);
10445 if (unformat (input, "%d", &tag))
10447 tagp[0] = (tag >> 8) & 0x0F;
10448 tagp[1] = tag & 0xFF;
10456 unformat_l2_match (unformat_input_t * input, va_list * args)
10458 u8 **matchp = va_arg (*args, u8 **);
10471 u8 ignore_tag1 = 0;
10472 u8 ignore_tag2 = 0;
10478 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10480 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
10483 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
10485 else if (unformat (input, "proto %U",
10486 unformat_ethernet_type_host_byte_order, &proto_val))
10488 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
10490 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
10492 else if (unformat (input, "ignore-tag1"))
10494 else if (unformat (input, "ignore-tag2"))
10496 else if (unformat (input, "cos1 %d", &cos1_val))
10498 else if (unformat (input, "cos2 %d", &cos2_val))
10503 if ((src + dst + proto + tag1 + tag2 +
10504 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10507 if (tag1 || ignore_tag1 || cos1)
10509 if (tag2 || ignore_tag2 || cos2)
10512 vec_validate_aligned (match, len - 1, sizeof (u32x4));
10515 clib_memcpy (match, dst_val, 6);
10518 clib_memcpy (match + 6, src_val, 6);
10522 /* inner vlan tag */
10523 match[19] = tag2_val[1];
10524 match[18] = tag2_val[0];
10526 match[18] |= (cos2_val & 0x7) << 5;
10529 match[21] = proto_val & 0xff;
10530 match[20] = proto_val >> 8;
10534 match[15] = tag1_val[1];
10535 match[14] = tag1_val[0];
10538 match[14] |= (cos1_val & 0x7) << 5;
10544 match[15] = tag1_val[1];
10545 match[14] = tag1_val[0];
10548 match[17] = proto_val & 0xff;
10549 match[16] = proto_val >> 8;
10552 match[14] |= (cos1_val & 0x7) << 5;
10558 match[18] |= (cos2_val & 0x7) << 5;
10560 match[14] |= (cos1_val & 0x7) << 5;
10563 match[13] = proto_val & 0xff;
10564 match[12] = proto_val >> 8;
10572 unformat_qos_source (unformat_input_t * input, va_list * args)
10574 int *qs = va_arg (*args, int *);
10576 if (unformat (input, "ip"))
10577 *qs = QOS_SOURCE_IP;
10578 else if (unformat (input, "mpls"))
10579 *qs = QOS_SOURCE_MPLS;
10580 else if (unformat (input, "ext"))
10581 *qs = QOS_SOURCE_EXT;
10582 else if (unformat (input, "vlan"))
10583 *qs = QOS_SOURCE_VLAN;
10592 api_unformat_classify_match (unformat_input_t * input, va_list * args)
10594 u8 **matchp = va_arg (*args, u8 **);
10595 u32 skip_n_vectors = va_arg (*args, u32);
10596 u32 match_n_vectors = va_arg (*args, u32);
10603 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10605 if (unformat (input, "hex %U", unformat_hex_string, &match))
10607 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
10609 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
10611 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
10625 if (match || l2 || l3 || l4)
10627 if (l2 || l3 || l4)
10629 /* "Win a free Ethernet header in every packet" */
10631 vec_validate_aligned (l2, 13, sizeof (u32x4));
10635 vec_append_aligned (match, l3, sizeof (u32x4));
10640 vec_append_aligned (match, l4, sizeof (u32x4));
10645 /* Make sure the vector is big enough even if key is all 0's */
10646 vec_validate_aligned
10647 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
10650 /* Set size, include skipped vectors */
10651 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
10662 api_classify_add_del_session (vat_main_t * vam)
10664 unformat_input_t *i = vam->input;
10665 vl_api_classify_add_del_session_t *mp;
10667 u32 table_index = ~0;
10668 u32 hit_next_index = ~0;
10669 u32 opaque_index = ~0;
10672 u32 skip_n_vectors = 0;
10673 u32 match_n_vectors = 0;
10679 * Warning: you have to supply skip_n and match_n
10680 * because the API client cant simply look at the classify
10684 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10686 if (unformat (i, "del"))
10688 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
10691 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
10694 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
10697 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
10699 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
10701 else if (unformat (i, "opaque-index %d", &opaque_index))
10703 else if (unformat (i, "skip_n %d", &skip_n_vectors))
10705 else if (unformat (i, "match_n %d", &match_n_vectors))
10707 else if (unformat (i, "match %U", api_unformat_classify_match,
10708 &match, skip_n_vectors, match_n_vectors))
10710 else if (unformat (i, "advance %d", &advance))
10712 else if (unformat (i, "table-index %d", &table_index))
10714 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
10716 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
10718 else if (unformat (i, "action %d", &action))
10720 else if (unformat (i, "metadata %d", &metadata))
10726 if (table_index == ~0)
10728 errmsg ("Table index required");
10732 if (is_add && match == 0)
10734 errmsg ("Match value required");
10738 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
10740 mp->is_add = is_add;
10741 mp->table_index = ntohl (table_index);
10742 mp->hit_next_index = ntohl (hit_next_index);
10743 mp->opaque_index = ntohl (opaque_index);
10744 mp->advance = ntohl (advance);
10745 mp->action = action;
10746 mp->metadata = ntohl (metadata);
10747 mp->match_len = ntohl (vec_len (match));
10748 clib_memcpy (mp->match, match, vec_len (match));
10757 api_classify_set_interface_ip_table (vat_main_t * vam)
10759 unformat_input_t *i = vam->input;
10760 vl_api_classify_set_interface_ip_table_t *mp;
10762 int sw_if_index_set;
10763 u32 table_index = ~0;
10767 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10769 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10770 sw_if_index_set = 1;
10771 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10772 sw_if_index_set = 1;
10773 else if (unformat (i, "table %d", &table_index))
10777 clib_warning ("parse error '%U'", format_unformat_error, i);
10782 if (sw_if_index_set == 0)
10784 errmsg ("missing interface name or sw_if_index");
10789 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
10791 mp->sw_if_index = ntohl (sw_if_index);
10792 mp->table_index = ntohl (table_index);
10793 mp->is_ipv6 = is_ipv6;
10801 api_classify_set_interface_l2_tables (vat_main_t * vam)
10803 unformat_input_t *i = vam->input;
10804 vl_api_classify_set_interface_l2_tables_t *mp;
10806 int sw_if_index_set;
10807 u32 ip4_table_index = ~0;
10808 u32 ip6_table_index = ~0;
10809 u32 other_table_index = ~0;
10813 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10815 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10816 sw_if_index_set = 1;
10817 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10818 sw_if_index_set = 1;
10819 else if (unformat (i, "ip4-table %d", &ip4_table_index))
10821 else if (unformat (i, "ip6-table %d", &ip6_table_index))
10823 else if (unformat (i, "other-table %d", &other_table_index))
10825 else if (unformat (i, "is-input %d", &is_input))
10829 clib_warning ("parse error '%U'", format_unformat_error, i);
10834 if (sw_if_index_set == 0)
10836 errmsg ("missing interface name or sw_if_index");
10841 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
10843 mp->sw_if_index = ntohl (sw_if_index);
10844 mp->ip4_table_index = ntohl (ip4_table_index);
10845 mp->ip6_table_index = ntohl (ip6_table_index);
10846 mp->other_table_index = ntohl (other_table_index);
10847 mp->is_input = (u8) is_input;
10855 api_set_ipfix_exporter (vat_main_t * vam)
10857 unformat_input_t *i = vam->input;
10858 vl_api_set_ipfix_exporter_t *mp;
10859 ip4_address_t collector_address;
10860 u8 collector_address_set = 0;
10861 u32 collector_port = ~0;
10862 ip4_address_t src_address;
10863 u8 src_address_set = 0;
10866 u32 template_interval = ~0;
10867 u8 udp_checksum = 0;
10870 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10872 if (unformat (i, "collector_address %U", unformat_ip4_address,
10873 &collector_address))
10874 collector_address_set = 1;
10875 else if (unformat (i, "collector_port %d", &collector_port))
10877 else if (unformat (i, "src_address %U", unformat_ip4_address,
10879 src_address_set = 1;
10880 else if (unformat (i, "vrf_id %d", &vrf_id))
10882 else if (unformat (i, "path_mtu %d", &path_mtu))
10884 else if (unformat (i, "template_interval %d", &template_interval))
10886 else if (unformat (i, "udp_checksum"))
10892 if (collector_address_set == 0)
10894 errmsg ("collector_address required");
10898 if (src_address_set == 0)
10900 errmsg ("src_address required");
10904 M (SET_IPFIX_EXPORTER, mp);
10906 memcpy (mp->collector_address.un.ip4, collector_address.data,
10907 sizeof (collector_address.data));
10908 mp->collector_port = htons ((u16) collector_port);
10909 memcpy (mp->src_address.un.ip4, src_address.data,
10910 sizeof (src_address.data));
10911 mp->vrf_id = htonl (vrf_id);
10912 mp->path_mtu = htonl (path_mtu);
10913 mp->template_interval = htonl (template_interval);
10914 mp->udp_checksum = udp_checksum;
10922 api_set_ipfix_classify_stream (vat_main_t * vam)
10924 unformat_input_t *i = vam->input;
10925 vl_api_set_ipfix_classify_stream_t *mp;
10927 u32 src_port = UDP_DST_PORT_ipfix;
10930 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10932 if (unformat (i, "domain %d", &domain_id))
10934 else if (unformat (i, "src_port %d", &src_port))
10938 errmsg ("unknown input `%U'", format_unformat_error, i);
10943 M (SET_IPFIX_CLASSIFY_STREAM, mp);
10945 mp->domain_id = htonl (domain_id);
10946 mp->src_port = htons ((u16) src_port);
10954 api_ipfix_classify_table_add_del (vat_main_t * vam)
10956 unformat_input_t *i = vam->input;
10957 vl_api_ipfix_classify_table_add_del_t *mp;
10959 u32 classify_table_index = ~0;
10961 u8 transport_protocol = 255;
10964 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10966 if (unformat (i, "add"))
10968 else if (unformat (i, "del"))
10970 else if (unformat (i, "table %d", &classify_table_index))
10972 else if (unformat (i, "ip4"))
10974 else if (unformat (i, "ip6"))
10976 else if (unformat (i, "tcp"))
10977 transport_protocol = 6;
10978 else if (unformat (i, "udp"))
10979 transport_protocol = 17;
10982 errmsg ("unknown input `%U'", format_unformat_error, i);
10989 errmsg ("expecting: add|del");
10992 if (classify_table_index == ~0)
10994 errmsg ("classifier table not specified");
10997 if (ip_version == 0)
10999 errmsg ("IP version not specified");
11003 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
11005 mp->is_add = is_add;
11006 mp->table_id = htonl (classify_table_index);
11007 mp->ip_version = ip_version;
11008 mp->transport_protocol = transport_protocol;
11016 api_get_node_index (vat_main_t * vam)
11018 unformat_input_t *i = vam->input;
11019 vl_api_get_node_index_t *mp;
11023 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11025 if (unformat (i, "node %s", &name))
11032 errmsg ("node name required");
11035 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11037 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11041 M (GET_NODE_INDEX, mp);
11042 clib_memcpy (mp->node_name, name, vec_len (name));
11051 api_get_next_index (vat_main_t * vam)
11053 unformat_input_t *i = vam->input;
11054 vl_api_get_next_index_t *mp;
11055 u8 *node_name = 0, *next_node_name = 0;
11058 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11060 if (unformat (i, "node-name %s", &node_name))
11062 else if (unformat (i, "next-node-name %s", &next_node_name))
11066 if (node_name == 0)
11068 errmsg ("node name required");
11071 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
11073 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11077 if (next_node_name == 0)
11079 errmsg ("next node name required");
11082 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
11084 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
11088 M (GET_NEXT_INDEX, mp);
11089 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
11090 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
11091 vec_free (node_name);
11092 vec_free (next_node_name);
11100 api_add_node_next (vat_main_t * vam)
11102 unformat_input_t *i = vam->input;
11103 vl_api_add_node_next_t *mp;
11108 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11110 if (unformat (i, "node %s", &name))
11112 else if (unformat (i, "next %s", &next))
11119 errmsg ("node name required");
11122 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11124 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11129 errmsg ("next node required");
11132 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
11134 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
11138 M (ADD_NODE_NEXT, mp);
11139 clib_memcpy (mp->node_name, name, vec_len (name));
11140 clib_memcpy (mp->next_name, next, vec_len (next));
11150 api_l2tpv3_create_tunnel (vat_main_t * vam)
11152 unformat_input_t *i = vam->input;
11153 ip6_address_t client_address, our_address;
11154 int client_address_set = 0;
11155 int our_address_set = 0;
11156 u32 local_session_id = 0;
11157 u32 remote_session_id = 0;
11158 u64 local_cookie = 0;
11159 u64 remote_cookie = 0;
11160 u8 l2_sublayer_present = 0;
11161 vl_api_l2tpv3_create_tunnel_t *mp;
11164 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11166 if (unformat (i, "client_address %U", unformat_ip6_address,
11168 client_address_set = 1;
11169 else if (unformat (i, "our_address %U", unformat_ip6_address,
11171 our_address_set = 1;
11172 else if (unformat (i, "local_session_id %d", &local_session_id))
11174 else if (unformat (i, "remote_session_id %d", &remote_session_id))
11176 else if (unformat (i, "local_cookie %lld", &local_cookie))
11178 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
11180 else if (unformat (i, "l2-sublayer-present"))
11181 l2_sublayer_present = 1;
11186 if (client_address_set == 0)
11188 errmsg ("client_address required");
11192 if (our_address_set == 0)
11194 errmsg ("our_address required");
11198 M (L2TPV3_CREATE_TUNNEL, mp);
11200 clib_memcpy (mp->client_address.un.ip6, client_address.as_u8,
11201 sizeof (ip6_address_t));
11203 clib_memcpy (mp->our_address.un.ip6, our_address.as_u8,
11204 sizeof (ip6_address_t));
11206 mp->local_session_id = ntohl (local_session_id);
11207 mp->remote_session_id = ntohl (remote_session_id);
11208 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
11209 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
11210 mp->l2_sublayer_present = l2_sublayer_present;
11218 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
11220 unformat_input_t *i = vam->input;
11222 u8 sw_if_index_set = 0;
11223 u64 new_local_cookie = 0;
11224 u64 new_remote_cookie = 0;
11225 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
11228 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11230 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11231 sw_if_index_set = 1;
11232 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11233 sw_if_index_set = 1;
11234 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
11236 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
11242 if (sw_if_index_set == 0)
11244 errmsg ("missing interface name or sw_if_index");
11248 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
11250 mp->sw_if_index = ntohl (sw_if_index);
11251 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
11252 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
11260 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
11262 unformat_input_t *i = vam->input;
11263 vl_api_l2tpv3_interface_enable_disable_t *mp;
11265 u8 sw_if_index_set = 0;
11266 u8 enable_disable = 1;
11269 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11271 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11272 sw_if_index_set = 1;
11273 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11274 sw_if_index_set = 1;
11275 else if (unformat (i, "enable"))
11276 enable_disable = 1;
11277 else if (unformat (i, "disable"))
11278 enable_disable = 0;
11283 if (sw_if_index_set == 0)
11285 errmsg ("missing interface name or sw_if_index");
11289 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
11291 mp->sw_if_index = ntohl (sw_if_index);
11292 mp->enable_disable = enable_disable;
11300 api_l2tpv3_set_lookup_key (vat_main_t * vam)
11302 unformat_input_t *i = vam->input;
11303 vl_api_l2tpv3_set_lookup_key_t *mp;
11307 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11309 if (unformat (i, "lookup_v6_src"))
11310 key = L2T_LOOKUP_SRC_ADDRESS;
11311 else if (unformat (i, "lookup_v6_dst"))
11312 key = L2T_LOOKUP_DST_ADDRESS;
11313 else if (unformat (i, "lookup_session_id"))
11314 key = L2T_LOOKUP_SESSION_ID;
11319 if (key == (u8) ~ 0)
11321 errmsg ("l2tp session lookup key unset");
11325 M (L2TPV3_SET_LOOKUP_KEY, mp);
11334 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
11335 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11337 vat_main_t *vam = &vat_main;
11339 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
11340 format_ip6_address, mp->our_address,
11341 format_ip6_address, mp->client_address,
11342 clib_net_to_host_u32 (mp->sw_if_index));
11345 " local cookies %016llx %016llx remote cookie %016llx",
11346 clib_net_to_host_u64 (mp->local_cookie[0]),
11347 clib_net_to_host_u64 (mp->local_cookie[1]),
11348 clib_net_to_host_u64 (mp->remote_cookie));
11350 print (vam->ofp, " local session-id %d remote session-id %d",
11351 clib_net_to_host_u32 (mp->local_session_id),
11352 clib_net_to_host_u32 (mp->remote_session_id));
11354 print (vam->ofp, " l2 specific sublayer %s\n",
11355 mp->l2_sublayer_present ? "preset" : "absent");
11359 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
11360 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11362 vat_main_t *vam = &vat_main;
11363 vat_json_node_t *node = NULL;
11364 struct in6_addr addr;
11366 if (VAT_JSON_ARRAY != vam->json_tree.type)
11368 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11369 vat_json_init_array (&vam->json_tree);
11371 node = vat_json_array_add (&vam->json_tree);
11373 vat_json_init_object (node);
11375 clib_memcpy (&addr, mp->our_address.un.ip6, sizeof (addr));
11376 vat_json_object_add_ip6 (node, "our_address", addr);
11377 clib_memcpy (&addr, mp->client_address.un.ip6, sizeof (addr));
11378 vat_json_object_add_ip6 (node, "client_address", addr);
11380 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
11381 vat_json_init_array (lc);
11382 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
11383 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
11384 vat_json_object_add_uint (node, "remote_cookie",
11385 clib_net_to_host_u64 (mp->remote_cookie));
11387 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
11388 vat_json_object_add_uint (node, "local_session_id",
11389 clib_net_to_host_u32 (mp->local_session_id));
11390 vat_json_object_add_uint (node, "remote_session_id",
11391 clib_net_to_host_u32 (mp->remote_session_id));
11392 vat_json_object_add_string_copy (node, "l2_sublayer",
11393 mp->l2_sublayer_present ? (u8 *) "present"
11394 : (u8 *) "absent");
11398 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
11400 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
11401 vl_api_control_ping_t *mp_ping;
11404 /* Get list of l2tpv3-tunnel interfaces */
11405 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
11408 /* Use a control ping for synchronization */
11409 MPING (CONTROL_PING, mp_ping);
11417 static void vl_api_sw_interface_tap_v2_details_t_handler
11418 (vl_api_sw_interface_tap_v2_details_t * mp)
11420 vat_main_t *vam = &vat_main;
11423 format (0, "%U/%d", format_ip4_address, mp->host_ip4_prefix.address,
11424 mp->host_ip4_prefix.len);
11426 format (0, "%U/%d", format_ip6_address, mp->host_ip6_prefix.address,
11427 mp->host_ip6_prefix.len);
11430 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s 0x%-08x",
11431 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
11432 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
11433 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
11434 mp->host_bridge, ip4, ip6, ntohl (mp->tap_flags));
11440 static void vl_api_sw_interface_tap_v2_details_t_handler_json
11441 (vl_api_sw_interface_tap_v2_details_t * mp)
11443 vat_main_t *vam = &vat_main;
11444 vat_json_node_t *node = NULL;
11446 if (VAT_JSON_ARRAY != vam->json_tree.type)
11448 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11449 vat_json_init_array (&vam->json_tree);
11451 node = vat_json_array_add (&vam->json_tree);
11453 vat_json_init_object (node);
11454 vat_json_object_add_uint (node, "id", ntohl (mp->id));
11455 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11456 vat_json_object_add_uint (node, "tap_flags", ntohl (mp->tap_flags));
11457 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
11458 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
11459 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
11460 vat_json_object_add_string_copy (node, "host_mac_addr",
11461 format (0, "%U", format_ethernet_address,
11462 &mp->host_mac_addr));
11463 vat_json_object_add_string_copy (node, "host_namespace",
11464 mp->host_namespace);
11465 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
11466 vat_json_object_add_string_copy (node, "host_ip4_addr",
11467 format (0, "%U/%d", format_ip4_address,
11468 mp->host_ip4_prefix.address,
11469 mp->host_ip4_prefix.len));
11470 vat_json_object_add_string_copy (node, "host_ip6_prefix",
11471 format (0, "%U/%d", format_ip6_address,
11472 mp->host_ip6_prefix.address,
11473 mp->host_ip6_prefix.len));
11478 api_sw_interface_tap_v2_dump (vat_main_t * vam)
11480 vl_api_sw_interface_tap_v2_dump_t *mp;
11481 vl_api_control_ping_t *mp_ping;
11485 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
11486 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
11487 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
11490 /* Get list of tap interfaces */
11491 M (SW_INTERFACE_TAP_V2_DUMP, mp);
11494 /* Use a control ping for synchronization */
11495 MPING (CONTROL_PING, mp_ping);
11502 static void vl_api_sw_interface_virtio_pci_details_t_handler
11503 (vl_api_sw_interface_virtio_pci_details_t * mp)
11505 vat_main_t *vam = &vat_main;
11520 addr.domain = ntohs (mp->pci_addr.domain);
11521 addr.bus = mp->pci_addr.bus;
11522 addr.slot = mp->pci_addr.slot;
11523 addr.function = mp->pci_addr.function;
11525 u8 *pci_addr = format (0, "%04x:%02x:%02x.%x", addr.domain, addr.bus,
11526 addr.slot, addr.function);
11529 "\n%-12s %-12d %-12d %-12d %-17U 0x%-08llx",
11530 pci_addr, ntohl (mp->sw_if_index),
11531 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
11532 format_ethernet_address, mp->mac_addr,
11533 clib_net_to_host_u64 (mp->features));
11534 vec_free (pci_addr);
11537 static void vl_api_sw_interface_virtio_pci_details_t_handler_json
11538 (vl_api_sw_interface_virtio_pci_details_t * mp)
11540 vat_main_t *vam = &vat_main;
11541 vat_json_node_t *node = NULL;
11542 vlib_pci_addr_t pci_addr;
11544 if (VAT_JSON_ARRAY != vam->json_tree.type)
11546 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11547 vat_json_init_array (&vam->json_tree);
11549 node = vat_json_array_add (&vam->json_tree);
11551 pci_addr.domain = ntohs (mp->pci_addr.domain);
11552 pci_addr.bus = mp->pci_addr.bus;
11553 pci_addr.slot = mp->pci_addr.slot;
11554 pci_addr.function = mp->pci_addr.function;
11556 vat_json_init_object (node);
11557 vat_json_object_add_uint (node, "pci-addr", pci_addr.as_u32);
11558 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11559 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
11560 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
11561 vat_json_object_add_uint (node, "features",
11562 clib_net_to_host_u64 (mp->features));
11563 vat_json_object_add_string_copy (node, "mac_addr",
11564 format (0, "%U", format_ethernet_address,
11569 api_sw_interface_virtio_pci_dump (vat_main_t * vam)
11571 vl_api_sw_interface_virtio_pci_dump_t *mp;
11572 vl_api_control_ping_t *mp_ping;
11576 "\n%-12s %-12s %-12s %-12s %-17s %-08s",
11577 "pci_addr", "sw_if_index", "rx_ring_sz", "tx_ring_sz",
11578 "mac_addr", "features");
11580 /* Get list of tap interfaces */
11581 M (SW_INTERFACE_VIRTIO_PCI_DUMP, mp);
11584 /* Use a control ping for synchronization */
11585 MPING (CONTROL_PING, mp_ping);
11593 api_vxlan_offload_rx (vat_main_t * vam)
11595 unformat_input_t *line_input = vam->input;
11596 vl_api_vxlan_offload_rx_t *mp;
11597 u32 hw_if_index = ~0, rx_if_index = ~0;
11601 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11603 if (unformat (line_input, "del"))
11605 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
11608 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
11610 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
11613 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
11617 errmsg ("parse error '%U'", format_unformat_error, line_input);
11622 if (hw_if_index == ~0)
11624 errmsg ("no hw interface");
11628 if (rx_if_index == ~0)
11630 errmsg ("no rx tunnel");
11634 M (VXLAN_OFFLOAD_RX, mp);
11636 mp->hw_if_index = ntohl (hw_if_index);
11637 mp->sw_if_index = ntohl (rx_if_index);
11638 mp->enable = is_add;
11645 static uword unformat_vxlan_decap_next
11646 (unformat_input_t * input, va_list * args)
11648 u32 *result = va_arg (*args, u32 *);
11651 if (unformat (input, "l2"))
11652 *result = VXLAN_INPUT_NEXT_L2_INPUT;
11653 else if (unformat (input, "%d", &tmp))
11661 api_vxlan_add_del_tunnel (vat_main_t * vam)
11663 unformat_input_t *line_input = vam->input;
11664 vl_api_vxlan_add_del_tunnel_t *mp;
11665 ip46_address_t src, dst;
11667 u8 ipv4_set = 0, ipv6_set = 0;
11672 u32 mcast_sw_if_index = ~0;
11673 u32 encap_vrf_id = 0;
11674 u32 decap_next_index = ~0;
11678 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
11679 clib_memset (&src, 0, sizeof src);
11680 clib_memset (&dst, 0, sizeof dst);
11682 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11684 if (unformat (line_input, "del"))
11686 else if (unformat (line_input, "instance %d", &instance))
11689 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
11695 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
11701 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
11707 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
11712 else if (unformat (line_input, "group %U %U",
11713 unformat_ip4_address, &dst.ip4,
11714 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11716 grp_set = dst_set = 1;
11719 else if (unformat (line_input, "group %U",
11720 unformat_ip4_address, &dst.ip4))
11722 grp_set = dst_set = 1;
11725 else if (unformat (line_input, "group %U %U",
11726 unformat_ip6_address, &dst.ip6,
11727 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11729 grp_set = dst_set = 1;
11732 else if (unformat (line_input, "group %U",
11733 unformat_ip6_address, &dst.ip6))
11735 grp_set = dst_set = 1;
11739 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
11741 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11743 else if (unformat (line_input, "decap-next %U",
11744 unformat_vxlan_decap_next, &decap_next_index))
11746 else if (unformat (line_input, "vni %d", &vni))
11750 errmsg ("parse error '%U'", format_unformat_error, line_input);
11757 errmsg ("tunnel src address not specified");
11762 errmsg ("tunnel dst address not specified");
11766 if (grp_set && !ip46_address_is_multicast (&dst))
11768 errmsg ("tunnel group address not multicast");
11771 if (grp_set && mcast_sw_if_index == ~0)
11773 errmsg ("tunnel nonexistent multicast device");
11776 if (grp_set == 0 && ip46_address_is_multicast (&dst))
11778 errmsg ("tunnel dst address must be unicast");
11783 if (ipv4_set && ipv6_set)
11785 errmsg ("both IPv4 and IPv6 addresses specified");
11789 if ((vni == 0) || (vni >> 24))
11791 errmsg ("vni not specified or out of range");
11795 M (VXLAN_ADD_DEL_TUNNEL, mp);
11799 clib_memcpy (mp->src_address.un.ip6, &src.ip6, sizeof (src.ip6));
11800 clib_memcpy (mp->dst_address.un.ip6, &dst.ip6, sizeof (dst.ip6));
11804 clib_memcpy (mp->src_address.un.ip4, &src.ip4, sizeof (src.ip4));
11805 clib_memcpy (mp->dst_address.un.ip4, &dst.ip4, sizeof (dst.ip4));
11807 mp->src_address.af = ipv6_set;
11808 mp->dst_address.af = ipv6_set;
11810 mp->instance = htonl (instance);
11811 mp->encap_vrf_id = ntohl (encap_vrf_id);
11812 mp->decap_next_index = ntohl (decap_next_index);
11813 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
11814 mp->vni = ntohl (vni);
11815 mp->is_add = is_add;
11822 static void vl_api_vxlan_tunnel_details_t_handler
11823 (vl_api_vxlan_tunnel_details_t * mp)
11825 vat_main_t *vam = &vat_main;
11826 ip46_address_t src =
11827 to_ip46 (mp->dst_address.af, (u8 *) & mp->dst_address.un);
11828 ip46_address_t dst =
11829 to_ip46 (mp->dst_address.af, (u8 *) & mp->src_address.un);
11831 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
11832 ntohl (mp->sw_if_index),
11833 ntohl (mp->instance),
11834 format_ip46_address, &src, IP46_TYPE_ANY,
11835 format_ip46_address, &dst, IP46_TYPE_ANY,
11836 ntohl (mp->encap_vrf_id),
11837 ntohl (mp->decap_next_index), ntohl (mp->vni),
11838 ntohl (mp->mcast_sw_if_index));
11841 static void vl_api_vxlan_tunnel_details_t_handler_json
11842 (vl_api_vxlan_tunnel_details_t * mp)
11844 vat_main_t *vam = &vat_main;
11845 vat_json_node_t *node = NULL;
11847 if (VAT_JSON_ARRAY != vam->json_tree.type)
11849 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11850 vat_json_init_array (&vam->json_tree);
11852 node = vat_json_array_add (&vam->json_tree);
11854 vat_json_init_object (node);
11855 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11857 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
11859 if (mp->src_address.af)
11861 struct in6_addr ip6;
11863 clib_memcpy (&ip6, mp->src_address.un.ip6, sizeof (ip6));
11864 vat_json_object_add_ip6 (node, "src_address", ip6);
11865 clib_memcpy (&ip6, mp->dst_address.un.ip6, sizeof (ip6));
11866 vat_json_object_add_ip6 (node, "dst_address", ip6);
11870 struct in_addr ip4;
11872 clib_memcpy (&ip4, mp->src_address.un.ip4, sizeof (ip4));
11873 vat_json_object_add_ip4 (node, "src_address", ip4);
11874 clib_memcpy (&ip4, mp->dst_address.un.ip4, sizeof (ip4));
11875 vat_json_object_add_ip4 (node, "dst_address", ip4);
11877 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11878 vat_json_object_add_uint (node, "decap_next_index",
11879 ntohl (mp->decap_next_index));
11880 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11881 vat_json_object_add_uint (node, "mcast_sw_if_index",
11882 ntohl (mp->mcast_sw_if_index));
11886 api_vxlan_tunnel_dump (vat_main_t * vam)
11888 unformat_input_t *i = vam->input;
11889 vl_api_vxlan_tunnel_dump_t *mp;
11890 vl_api_control_ping_t *mp_ping;
11892 u8 sw_if_index_set = 0;
11895 /* Parse args required to build the message */
11896 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11898 if (unformat (i, "sw_if_index %d", &sw_if_index))
11899 sw_if_index_set = 1;
11904 if (sw_if_index_set == 0)
11909 if (!vam->json_output)
11911 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
11912 "sw_if_index", "instance", "src_address", "dst_address",
11913 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
11916 /* Get list of vxlan-tunnel interfaces */
11917 M (VXLAN_TUNNEL_DUMP, mp);
11919 mp->sw_if_index = htonl (sw_if_index);
11923 /* Use a control ping for synchronization */
11924 MPING (CONTROL_PING, mp_ping);
11932 api_gre_tunnel_add_del (vat_main_t * vam)
11934 unformat_input_t *line_input = vam->input;
11935 vl_api_address_t src = { }, dst =
11938 vl_api_gre_tunnel_add_del_t *mp;
11939 vl_api_gre_tunnel_type_t t_type;
11943 u32 outer_table_id = 0;
11944 u32 session_id = 0;
11948 t_type = GRE_API_TUNNEL_TYPE_L3;
11950 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11952 if (unformat (line_input, "del"))
11954 else if (unformat (line_input, "instance %d", &instance))
11956 else if (unformat (line_input, "src %U", unformat_vl_api_address, &src))
11960 else if (unformat (line_input, "dst %U", unformat_vl_api_address, &dst))
11964 else if (unformat (line_input, "outer-table-id %d", &outer_table_id))
11966 else if (unformat (line_input, "teb"))
11967 t_type = GRE_API_TUNNEL_TYPE_TEB;
11968 else if (unformat (line_input, "erspan %d", &session_id))
11969 t_type = GRE_API_TUNNEL_TYPE_ERSPAN;
11972 errmsg ("parse error '%U'", format_unformat_error, line_input);
11979 errmsg ("tunnel src address not specified");
11984 errmsg ("tunnel dst address not specified");
11988 M (GRE_TUNNEL_ADD_DEL, mp);
11990 clib_memcpy (&mp->tunnel.src, &src, sizeof (mp->tunnel.src));
11991 clib_memcpy (&mp->tunnel.dst, &dst, sizeof (mp->tunnel.dst));
11993 mp->tunnel.instance = htonl (instance);
11994 mp->tunnel.outer_table_id = htonl (outer_table_id);
11995 mp->is_add = is_add;
11996 mp->tunnel.session_id = htons ((u16) session_id);
11997 mp->tunnel.type = htonl (t_type);
12004 static void vl_api_gre_tunnel_details_t_handler
12005 (vl_api_gre_tunnel_details_t * mp)
12007 vat_main_t *vam = &vat_main;
12009 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
12010 ntohl (mp->tunnel.sw_if_index),
12011 ntohl (mp->tunnel.instance),
12012 format_vl_api_address, &mp->tunnel.src,
12013 format_vl_api_address, &mp->tunnel.dst,
12014 mp->tunnel.type, ntohl (mp->tunnel.outer_table_id),
12015 ntohl (mp->tunnel.session_id));
12018 static void vl_api_gre_tunnel_details_t_handler_json
12019 (vl_api_gre_tunnel_details_t * mp)
12021 vat_main_t *vam = &vat_main;
12022 vat_json_node_t *node = NULL;
12024 if (VAT_JSON_ARRAY != vam->json_tree.type)
12026 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12027 vat_json_init_array (&vam->json_tree);
12029 node = vat_json_array_add (&vam->json_tree);
12031 vat_json_init_object (node);
12032 vat_json_object_add_uint (node, "sw_if_index",
12033 ntohl (mp->tunnel.sw_if_index));
12034 vat_json_object_add_uint (node, "instance", ntohl (mp->tunnel.instance));
12036 vat_json_object_add_address (node, "src", &mp->tunnel.src);
12037 vat_json_object_add_address (node, "dst", &mp->tunnel.dst);
12038 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel.type);
12039 vat_json_object_add_uint (node, "outer_table_id",
12040 ntohl (mp->tunnel.outer_table_id));
12041 vat_json_object_add_uint (node, "session_id", mp->tunnel.session_id);
12045 api_gre_tunnel_dump (vat_main_t * vam)
12047 unformat_input_t *i = vam->input;
12048 vl_api_gre_tunnel_dump_t *mp;
12049 vl_api_control_ping_t *mp_ping;
12051 u8 sw_if_index_set = 0;
12054 /* Parse args required to build the message */
12055 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12057 if (unformat (i, "sw_if_index %d", &sw_if_index))
12058 sw_if_index_set = 1;
12063 if (sw_if_index_set == 0)
12068 if (!vam->json_output)
12070 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
12071 "sw_if_index", "instance", "src_address", "dst_address",
12072 "tunnel_type", "outer_fib_id", "session_id");
12075 /* Get list of gre-tunnel interfaces */
12076 M (GRE_TUNNEL_DUMP, mp);
12078 mp->sw_if_index = htonl (sw_if_index);
12082 /* Use a control ping for synchronization */
12083 MPING (CONTROL_PING, mp_ping);
12091 api_l2_fib_clear_table (vat_main_t * vam)
12093 // unformat_input_t * i = vam->input;
12094 vl_api_l2_fib_clear_table_t *mp;
12097 M (L2_FIB_CLEAR_TABLE, mp);
12105 api_l2_interface_efp_filter (vat_main_t * vam)
12107 unformat_input_t *i = vam->input;
12108 vl_api_l2_interface_efp_filter_t *mp;
12111 u8 sw_if_index_set = 0;
12114 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12116 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12117 sw_if_index_set = 1;
12118 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12119 sw_if_index_set = 1;
12120 else if (unformat (i, "enable"))
12122 else if (unformat (i, "disable"))
12126 clib_warning ("parse error '%U'", format_unformat_error, i);
12131 if (sw_if_index_set == 0)
12133 errmsg ("missing sw_if_index");
12137 M (L2_INTERFACE_EFP_FILTER, mp);
12139 mp->sw_if_index = ntohl (sw_if_index);
12140 mp->enable_disable = enable;
12147 #define foreach_vtr_op \
12148 _("disable", L2_VTR_DISABLED) \
12149 _("push-1", L2_VTR_PUSH_1) \
12150 _("push-2", L2_VTR_PUSH_2) \
12151 _("pop-1", L2_VTR_POP_1) \
12152 _("pop-2", L2_VTR_POP_2) \
12153 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
12154 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
12155 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
12156 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
12159 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
12161 unformat_input_t *i = vam->input;
12162 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
12164 u8 sw_if_index_set = 0;
12167 u32 push_dot1q = 1;
12172 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12174 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12175 sw_if_index_set = 1;
12176 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12177 sw_if_index_set = 1;
12178 else if (unformat (i, "vtr_op %d", &vtr_op))
12180 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
12183 else if (unformat (i, "push_dot1q %d", &push_dot1q))
12185 else if (unformat (i, "tag1 %d", &tag1))
12187 else if (unformat (i, "tag2 %d", &tag2))
12191 clib_warning ("parse error '%U'", format_unformat_error, i);
12196 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
12198 errmsg ("missing vtr operation or sw_if_index");
12202 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
12203 mp->sw_if_index = ntohl (sw_if_index);
12204 mp->vtr_op = ntohl (vtr_op);
12205 mp->push_dot1q = ntohl (push_dot1q);
12206 mp->tag1 = ntohl (tag1);
12207 mp->tag2 = ntohl (tag2);
12215 api_create_vhost_user_if (vat_main_t * vam)
12217 unformat_input_t *i = vam->input;
12218 vl_api_create_vhost_user_if_t *mp;
12221 u8 file_name_set = 0;
12222 u32 custom_dev_instance = ~0;
12224 u8 use_custom_mac = 0;
12225 u8 disable_mrg_rxbuf = 0;
12226 u8 disable_indirect_desc = 0;
12229 u8 enable_packed = 0;
12232 /* Shut up coverity */
12233 clib_memset (hwaddr, 0, sizeof (hwaddr));
12235 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12237 if (unformat (i, "socket %s", &file_name))
12241 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12243 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
12244 use_custom_mac = 1;
12245 else if (unformat (i, "server"))
12247 else if (unformat (i, "disable_mrg_rxbuf"))
12248 disable_mrg_rxbuf = 1;
12249 else if (unformat (i, "disable_indirect_desc"))
12250 disable_indirect_desc = 1;
12251 else if (unformat (i, "gso"))
12253 else if (unformat (i, "packed"))
12255 else if (unformat (i, "tag %s", &tag))
12261 if (file_name_set == 0)
12263 errmsg ("missing socket file name");
12267 if (vec_len (file_name) > 255)
12269 errmsg ("socket file name too long");
12272 vec_add1 (file_name, 0);
12274 M (CREATE_VHOST_USER_IF, mp);
12276 mp->is_server = is_server;
12277 mp->disable_mrg_rxbuf = disable_mrg_rxbuf;
12278 mp->disable_indirect_desc = disable_indirect_desc;
12279 mp->enable_gso = enable_gso;
12280 mp->enable_packed = enable_packed;
12281 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12282 vec_free (file_name);
12283 if (custom_dev_instance != ~0)
12286 mp->custom_dev_instance = ntohl (custom_dev_instance);
12289 mp->use_custom_mac = use_custom_mac;
12290 clib_memcpy (mp->mac_address, hwaddr, 6);
12292 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
12301 api_modify_vhost_user_if (vat_main_t * vam)
12303 unformat_input_t *i = vam->input;
12304 vl_api_modify_vhost_user_if_t *mp;
12307 u8 file_name_set = 0;
12308 u32 custom_dev_instance = ~0;
12309 u8 sw_if_index_set = 0;
12310 u32 sw_if_index = (u32) ~ 0;
12312 u8 enable_packed = 0;
12315 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12317 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12318 sw_if_index_set = 1;
12319 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12320 sw_if_index_set = 1;
12321 else if (unformat (i, "socket %s", &file_name))
12325 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12327 else if (unformat (i, "server"))
12329 else if (unformat (i, "gso"))
12331 else if (unformat (i, "packed"))
12337 if (sw_if_index_set == 0)
12339 errmsg ("missing sw_if_index or interface name");
12343 if (file_name_set == 0)
12345 errmsg ("missing socket file name");
12349 if (vec_len (file_name) > 255)
12351 errmsg ("socket file name too long");
12354 vec_add1 (file_name, 0);
12356 M (MODIFY_VHOST_USER_IF, mp);
12358 mp->sw_if_index = ntohl (sw_if_index);
12359 mp->is_server = is_server;
12360 mp->enable_gso = enable_gso;
12361 mp->enable_packed = enable_packed;
12362 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12363 vec_free (file_name);
12364 if (custom_dev_instance != ~0)
12367 mp->custom_dev_instance = ntohl (custom_dev_instance);
12376 api_delete_vhost_user_if (vat_main_t * vam)
12378 unformat_input_t *i = vam->input;
12379 vl_api_delete_vhost_user_if_t *mp;
12380 u32 sw_if_index = ~0;
12381 u8 sw_if_index_set = 0;
12384 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12386 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12387 sw_if_index_set = 1;
12388 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12389 sw_if_index_set = 1;
12394 if (sw_if_index_set == 0)
12396 errmsg ("missing sw_if_index or interface name");
12401 M (DELETE_VHOST_USER_IF, mp);
12403 mp->sw_if_index = ntohl (sw_if_index);
12410 static void vl_api_sw_interface_vhost_user_details_t_handler
12411 (vl_api_sw_interface_vhost_user_details_t * mp)
12413 vat_main_t *vam = &vat_main;
12417 clib_net_to_host_u32 (mp->features_first_32) | ((u64)
12418 clib_net_to_host_u32
12419 (mp->features_last_32) <<
12422 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
12423 (char *) mp->interface_name,
12424 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
12425 features, mp->is_server,
12426 ntohl (mp->num_regions), (char *) mp->sock_filename);
12427 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
12430 static void vl_api_sw_interface_vhost_user_details_t_handler_json
12431 (vl_api_sw_interface_vhost_user_details_t * mp)
12433 vat_main_t *vam = &vat_main;
12434 vat_json_node_t *node = NULL;
12436 if (VAT_JSON_ARRAY != vam->json_tree.type)
12438 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12439 vat_json_init_array (&vam->json_tree);
12441 node = vat_json_array_add (&vam->json_tree);
12443 vat_json_init_object (node);
12444 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12445 vat_json_object_add_string_copy (node, "interface_name",
12446 mp->interface_name);
12447 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
12448 ntohl (mp->virtio_net_hdr_sz));
12449 vat_json_object_add_uint (node, "features_first_32",
12450 clib_net_to_host_u32 (mp->features_first_32));
12451 vat_json_object_add_uint (node, "features_last_32",
12452 clib_net_to_host_u32 (mp->features_last_32));
12453 vat_json_object_add_uint (node, "is_server", mp->is_server);
12454 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
12455 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
12456 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
12460 api_sw_interface_vhost_user_dump (vat_main_t * vam)
12462 unformat_input_t *i = vam->input;
12463 vl_api_sw_interface_vhost_user_dump_t *mp;
12464 vl_api_control_ping_t *mp_ping;
12466 u32 sw_if_index = ~0;
12468 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12470 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12472 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12479 "Interface name idx hdr_sz features server regions filename");
12481 /* Get list of vhost-user interfaces */
12482 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
12483 mp->sw_if_index = ntohl (sw_if_index);
12486 /* Use a control ping for synchronization */
12487 MPING (CONTROL_PING, mp_ping);
12495 api_show_version (vat_main_t * vam)
12497 vl_api_show_version_t *mp;
12500 M (SHOW_VERSION, mp);
12509 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
12511 unformat_input_t *line_input = vam->input;
12512 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
12513 ip46_address_t local, remote;
12518 u32 mcast_sw_if_index = ~0;
12519 u32 encap_vrf_id = 0;
12520 u32 decap_vrf_id = 0;
12526 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12528 if (unformat (line_input, "del"))
12530 else if (unformat (line_input, "local %U",
12531 unformat_ip46_address, &local))
12535 else if (unformat (line_input, "remote %U",
12536 unformat_ip46_address, &remote))
12540 else if (unformat (line_input, "group %U %U",
12541 unformat_ip46_address, &remote,
12542 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12544 grp_set = remote_set = 1;
12546 else if (unformat (line_input, "group %U",
12547 unformat_ip46_address, &remote))
12549 grp_set = remote_set = 1;
12552 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12554 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12556 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
12558 else if (unformat (line_input, "vni %d", &vni))
12560 else if (unformat (line_input, "next-ip4"))
12562 else if (unformat (line_input, "next-ip6"))
12564 else if (unformat (line_input, "next-ethernet"))
12566 else if (unformat (line_input, "next-nsh"))
12570 errmsg ("parse error '%U'", format_unformat_error, line_input);
12575 if (local_set == 0)
12577 errmsg ("tunnel local address not specified");
12580 if (remote_set == 0)
12582 errmsg ("tunnel remote address not specified");
12585 if (grp_set && mcast_sw_if_index == ~0)
12587 errmsg ("tunnel nonexistent multicast device");
12590 if (ip46_address_is_ip4 (&local) != ip46_address_is_ip4 (&remote))
12592 errmsg ("both IPv4 and IPv6 addresses specified");
12598 errmsg ("vni not specified");
12602 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
12604 ip_address_encode (&local,
12605 ip46_address_is_ip4 (&local) ? IP46_TYPE_IP4 :
12606 IP46_TYPE_IP6, &mp->local);
12607 ip_address_encode (&remote,
12608 ip46_address_is_ip4 (&remote) ? IP46_TYPE_IP4 :
12609 IP46_TYPE_IP6, &mp->remote);
12611 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12612 mp->encap_vrf_id = ntohl (encap_vrf_id);
12613 mp->decap_vrf_id = ntohl (decap_vrf_id);
12614 mp->protocol = protocol;
12615 mp->vni = ntohl (vni);
12616 mp->is_add = is_add;
12623 static void vl_api_vxlan_gpe_tunnel_details_t_handler
12624 (vl_api_vxlan_gpe_tunnel_details_t * mp)
12626 vat_main_t *vam = &vat_main;
12627 ip46_address_t local, remote;
12629 ip_address_decode (&mp->local, &local);
12630 ip_address_decode (&mp->remote, &remote);
12632 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
12633 ntohl (mp->sw_if_index),
12634 format_ip46_address, &local, IP46_TYPE_ANY,
12635 format_ip46_address, &remote, IP46_TYPE_ANY,
12636 ntohl (mp->vni), mp->protocol,
12637 ntohl (mp->mcast_sw_if_index),
12638 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
12642 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
12643 (vl_api_vxlan_gpe_tunnel_details_t * mp)
12645 vat_main_t *vam = &vat_main;
12646 vat_json_node_t *node = NULL;
12647 struct in_addr ip4;
12648 struct in6_addr ip6;
12649 ip46_address_t local, remote;
12651 ip_address_decode (&mp->local, &local);
12652 ip_address_decode (&mp->remote, &remote);
12654 if (VAT_JSON_ARRAY != vam->json_tree.type)
12656 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12657 vat_json_init_array (&vam->json_tree);
12659 node = vat_json_array_add (&vam->json_tree);
12661 vat_json_init_object (node);
12662 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12663 if (ip46_address_is_ip4 (&local))
12665 clib_memcpy (&ip4, &local.ip4, sizeof (ip4));
12666 vat_json_object_add_ip4 (node, "local", ip4);
12667 clib_memcpy (&ip4, &remote.ip4, sizeof (ip4));
12668 vat_json_object_add_ip4 (node, "remote", ip4);
12672 clib_memcpy (&ip6, &local.ip6, sizeof (ip6));
12673 vat_json_object_add_ip6 (node, "local", ip6);
12674 clib_memcpy (&ip6, &remote.ip6, sizeof (ip6));
12675 vat_json_object_add_ip6 (node, "remote", ip6);
12677 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12678 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
12679 vat_json_object_add_uint (node, "mcast_sw_if_index",
12680 ntohl (mp->mcast_sw_if_index));
12681 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12682 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
12683 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12687 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
12689 unformat_input_t *i = vam->input;
12690 vl_api_vxlan_gpe_tunnel_dump_t *mp;
12691 vl_api_control_ping_t *mp_ping;
12693 u8 sw_if_index_set = 0;
12696 /* Parse args required to build the message */
12697 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12699 if (unformat (i, "sw_if_index %d", &sw_if_index))
12700 sw_if_index_set = 1;
12705 if (sw_if_index_set == 0)
12710 if (!vam->json_output)
12712 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
12713 "sw_if_index", "local", "remote", "vni",
12714 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
12717 /* Get list of vxlan-tunnel interfaces */
12718 M (VXLAN_GPE_TUNNEL_DUMP, mp);
12720 mp->sw_if_index = htonl (sw_if_index);
12724 /* Use a control ping for synchronization */
12725 MPING (CONTROL_PING, mp_ping);
12732 static void vl_api_l2_fib_table_details_t_handler
12733 (vl_api_l2_fib_table_details_t * mp)
12735 vat_main_t *vam = &vat_main;
12737 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
12739 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
12740 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
12744 static void vl_api_l2_fib_table_details_t_handler_json
12745 (vl_api_l2_fib_table_details_t * mp)
12747 vat_main_t *vam = &vat_main;
12748 vat_json_node_t *node = NULL;
12750 if (VAT_JSON_ARRAY != vam->json_tree.type)
12752 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12753 vat_json_init_array (&vam->json_tree);
12755 node = vat_json_array_add (&vam->json_tree);
12757 vat_json_init_object (node);
12758 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
12759 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
12760 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12761 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
12762 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
12763 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
12767 api_l2_fib_table_dump (vat_main_t * vam)
12769 unformat_input_t *i = vam->input;
12770 vl_api_l2_fib_table_dump_t *mp;
12771 vl_api_control_ping_t *mp_ping;
12776 /* Parse args required to build the message */
12777 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12779 if (unformat (i, "bd_id %d", &bd_id))
12785 if (bd_id_set == 0)
12787 errmsg ("missing bridge domain");
12791 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
12793 /* Get list of l2 fib entries */
12794 M (L2_FIB_TABLE_DUMP, mp);
12796 mp->bd_id = ntohl (bd_id);
12799 /* Use a control ping for synchronization */
12800 MPING (CONTROL_PING, mp_ping);
12809 api_interface_name_renumber (vat_main_t * vam)
12811 unformat_input_t *line_input = vam->input;
12812 vl_api_interface_name_renumber_t *mp;
12813 u32 sw_if_index = ~0;
12814 u32 new_show_dev_instance = ~0;
12817 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12819 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
12822 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12824 else if (unformat (line_input, "new_show_dev_instance %d",
12825 &new_show_dev_instance))
12831 if (sw_if_index == ~0)
12833 errmsg ("missing interface name or sw_if_index");
12837 if (new_show_dev_instance == ~0)
12839 errmsg ("missing new_show_dev_instance");
12843 M (INTERFACE_NAME_RENUMBER, mp);
12845 mp->sw_if_index = ntohl (sw_if_index);
12846 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
12854 api_want_l2_macs_events (vat_main_t * vam)
12856 unformat_input_t *line_input = vam->input;
12857 vl_api_want_l2_macs_events_t *mp;
12858 u8 enable_disable = 1;
12859 u32 scan_delay = 0;
12860 u32 max_macs_in_event = 0;
12861 u32 learn_limit = 0;
12864 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12866 if (unformat (line_input, "learn-limit %d", &learn_limit))
12868 else if (unformat (line_input, "scan-delay %d", &scan_delay))
12870 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
12872 else if (unformat (line_input, "disable"))
12873 enable_disable = 0;
12878 M (WANT_L2_MACS_EVENTS, mp);
12879 mp->enable_disable = enable_disable;
12880 mp->pid = htonl (getpid ());
12881 mp->learn_limit = htonl (learn_limit);
12882 mp->scan_delay = (u8) scan_delay;
12883 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
12890 api_input_acl_set_interface (vat_main_t * vam)
12892 unformat_input_t *i = vam->input;
12893 vl_api_input_acl_set_interface_t *mp;
12895 int sw_if_index_set;
12896 u32 ip4_table_index = ~0;
12897 u32 ip6_table_index = ~0;
12898 u32 l2_table_index = ~0;
12902 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12904 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12905 sw_if_index_set = 1;
12906 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12907 sw_if_index_set = 1;
12908 else if (unformat (i, "del"))
12910 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12912 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12914 else if (unformat (i, "l2-table %d", &l2_table_index))
12918 clib_warning ("parse error '%U'", format_unformat_error, i);
12923 if (sw_if_index_set == 0)
12925 errmsg ("missing interface name or sw_if_index");
12929 M (INPUT_ACL_SET_INTERFACE, mp);
12931 mp->sw_if_index = ntohl (sw_if_index);
12932 mp->ip4_table_index = ntohl (ip4_table_index);
12933 mp->ip6_table_index = ntohl (ip6_table_index);
12934 mp->l2_table_index = ntohl (l2_table_index);
12935 mp->is_add = is_add;
12943 api_output_acl_set_interface (vat_main_t * vam)
12945 unformat_input_t *i = vam->input;
12946 vl_api_output_acl_set_interface_t *mp;
12948 int sw_if_index_set;
12949 u32 ip4_table_index = ~0;
12950 u32 ip6_table_index = ~0;
12951 u32 l2_table_index = ~0;
12955 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12957 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12958 sw_if_index_set = 1;
12959 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12960 sw_if_index_set = 1;
12961 else if (unformat (i, "del"))
12963 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12965 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12967 else if (unformat (i, "l2-table %d", &l2_table_index))
12971 clib_warning ("parse error '%U'", format_unformat_error, i);
12976 if (sw_if_index_set == 0)
12978 errmsg ("missing interface name or sw_if_index");
12982 M (OUTPUT_ACL_SET_INTERFACE, mp);
12984 mp->sw_if_index = ntohl (sw_if_index);
12985 mp->ip4_table_index = ntohl (ip4_table_index);
12986 mp->ip6_table_index = ntohl (ip6_table_index);
12987 mp->l2_table_index = ntohl (l2_table_index);
12988 mp->is_add = is_add;
12996 api_ip_address_dump (vat_main_t * vam)
12998 unformat_input_t *i = vam->input;
12999 vl_api_ip_address_dump_t *mp;
13000 vl_api_control_ping_t *mp_ping;
13001 u32 sw_if_index = ~0;
13002 u8 sw_if_index_set = 0;
13007 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13009 if (unformat (i, "sw_if_index %d", &sw_if_index))
13010 sw_if_index_set = 1;
13012 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13013 sw_if_index_set = 1;
13014 else if (unformat (i, "ipv4"))
13016 else if (unformat (i, "ipv6"))
13022 if (ipv4_set && ipv6_set)
13024 errmsg ("ipv4 and ipv6 flags cannot be both set");
13028 if ((!ipv4_set) && (!ipv6_set))
13030 errmsg ("no ipv4 nor ipv6 flag set");
13034 if (sw_if_index_set == 0)
13036 errmsg ("missing interface name or sw_if_index");
13040 vam->current_sw_if_index = sw_if_index;
13041 vam->is_ipv6 = ipv6_set;
13043 M (IP_ADDRESS_DUMP, mp);
13044 mp->sw_if_index = ntohl (sw_if_index);
13045 mp->is_ipv6 = ipv6_set;
13048 /* Use a control ping for synchronization */
13049 MPING (CONTROL_PING, mp_ping);
13057 api_ip_dump (vat_main_t * vam)
13059 vl_api_ip_dump_t *mp;
13060 vl_api_control_ping_t *mp_ping;
13061 unformat_input_t *in = vam->input;
13068 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
13070 if (unformat (in, "ipv4"))
13072 else if (unformat (in, "ipv6"))
13078 if (ipv4_set && ipv6_set)
13080 errmsg ("ipv4 and ipv6 flags cannot be both set");
13084 if ((!ipv4_set) && (!ipv6_set))
13086 errmsg ("no ipv4 nor ipv6 flag set");
13090 is_ipv6 = ipv6_set;
13091 vam->is_ipv6 = is_ipv6;
13093 /* free old data */
13094 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
13096 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
13098 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
13101 mp->is_ipv6 = ipv6_set;
13104 /* Use a control ping for synchronization */
13105 MPING (CONTROL_PING, mp_ping);
13113 api_ipsec_spd_add_del (vat_main_t * vam)
13115 unformat_input_t *i = vam->input;
13116 vl_api_ipsec_spd_add_del_t *mp;
13121 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13123 if (unformat (i, "spd_id %d", &spd_id))
13125 else if (unformat (i, "del"))
13129 clib_warning ("parse error '%U'", format_unformat_error, i);
13135 errmsg ("spd_id must be set");
13139 M (IPSEC_SPD_ADD_DEL, mp);
13141 mp->spd_id = ntohl (spd_id);
13142 mp->is_add = is_add;
13150 api_ipsec_interface_add_del_spd (vat_main_t * vam)
13152 unformat_input_t *i = vam->input;
13153 vl_api_ipsec_interface_add_del_spd_t *mp;
13155 u8 sw_if_index_set = 0;
13156 u32 spd_id = (u32) ~ 0;
13160 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13162 if (unformat (i, "del"))
13164 else if (unformat (i, "spd_id %d", &spd_id))
13167 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13168 sw_if_index_set = 1;
13169 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13170 sw_if_index_set = 1;
13173 clib_warning ("parse error '%U'", format_unformat_error, i);
13179 if (spd_id == (u32) ~ 0)
13181 errmsg ("spd_id must be set");
13185 if (sw_if_index_set == 0)
13187 errmsg ("missing interface name or sw_if_index");
13191 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
13193 mp->spd_id = ntohl (spd_id);
13194 mp->sw_if_index = ntohl (sw_if_index);
13195 mp->is_add = is_add;
13203 api_ipsec_spd_entry_add_del (vat_main_t * vam)
13205 unformat_input_t *i = vam->input;
13206 vl_api_ipsec_spd_entry_add_del_t *mp;
13207 u8 is_add = 1, is_outbound = 0;
13208 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
13210 u32 rport_start = 0, rport_stop = (u32) ~ 0;
13211 u32 lport_start = 0, lport_stop = (u32) ~ 0;
13212 vl_api_address_t laddr_start = { }, laddr_stop =
13221 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13223 if (unformat (i, "del"))
13225 if (unformat (i, "outbound"))
13227 if (unformat (i, "inbound"))
13229 else if (unformat (i, "spd_id %d", &spd_id))
13231 else if (unformat (i, "sa_id %d", &sa_id))
13233 else if (unformat (i, "priority %d", &priority))
13235 else if (unformat (i, "protocol %d", &protocol))
13237 else if (unformat (i, "lport_start %d", &lport_start))
13239 else if (unformat (i, "lport_stop %d", &lport_stop))
13241 else if (unformat (i, "rport_start %d", &rport_start))
13243 else if (unformat (i, "rport_stop %d", &rport_stop))
13245 else if (unformat (i, "laddr_start %U",
13246 unformat_vl_api_address, &laddr_start))
13248 else if (unformat (i, "laddr_stop %U", unformat_vl_api_address,
13251 else if (unformat (i, "raddr_start %U", unformat_vl_api_address,
13254 else if (unformat (i, "raddr_stop %U", unformat_vl_api_address,
13258 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
13260 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
13262 clib_warning ("unsupported action: 'resolve'");
13268 clib_warning ("parse error '%U'", format_unformat_error, i);
13274 M (IPSEC_SPD_ENTRY_ADD_DEL, mp);
13276 mp->is_add = is_add;
13278 mp->entry.spd_id = ntohl (spd_id);
13279 mp->entry.priority = ntohl (priority);
13280 mp->entry.is_outbound = is_outbound;
13282 clib_memcpy (&mp->entry.remote_address_start, &raddr_start,
13283 sizeof (vl_api_address_t));
13284 clib_memcpy (&mp->entry.remote_address_stop, &raddr_stop,
13285 sizeof (vl_api_address_t));
13286 clib_memcpy (&mp->entry.local_address_start, &laddr_start,
13287 sizeof (vl_api_address_t));
13288 clib_memcpy (&mp->entry.local_address_stop, &laddr_stop,
13289 sizeof (vl_api_address_t));
13291 mp->entry.protocol = (u8) protocol;
13292 mp->entry.local_port_start = ntohs ((u16) lport_start);
13293 mp->entry.local_port_stop = ntohs ((u16) lport_stop);
13294 mp->entry.remote_port_start = ntohs ((u16) rport_start);
13295 mp->entry.remote_port_stop = ntohs ((u16) rport_stop);
13296 mp->entry.policy = (u8) policy;
13297 mp->entry.sa_id = ntohl (sa_id);
13305 api_ipsec_sad_entry_add_del (vat_main_t * vam)
13307 unformat_input_t *i = vam->input;
13308 vl_api_ipsec_sad_entry_add_del_t *mp;
13309 u32 sad_id = 0, spi = 0;
13310 u8 *ck = 0, *ik = 0;
13313 vl_api_ipsec_crypto_alg_t crypto_alg = IPSEC_API_CRYPTO_ALG_NONE;
13314 vl_api_ipsec_integ_alg_t integ_alg = IPSEC_API_INTEG_ALG_NONE;
13315 vl_api_ipsec_sad_flags_t flags = IPSEC_API_SAD_FLAG_NONE;
13316 vl_api_ipsec_proto_t protocol = IPSEC_API_PROTO_AH;
13317 vl_api_address_t tun_src, tun_dst;
13320 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13322 if (unformat (i, "del"))
13324 else if (unformat (i, "sad_id %d", &sad_id))
13326 else if (unformat (i, "spi %d", &spi))
13328 else if (unformat (i, "esp"))
13329 protocol = IPSEC_API_PROTO_ESP;
13331 if (unformat (i, "tunnel_src %U", unformat_vl_api_address, &tun_src))
13333 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
13334 if (ADDRESS_IP6 == tun_src.af)
13335 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
13338 if (unformat (i, "tunnel_dst %U", unformat_vl_api_address, &tun_dst))
13340 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
13341 if (ADDRESS_IP6 == tun_src.af)
13342 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
13345 if (unformat (i, "crypto_alg %U",
13346 unformat_ipsec_api_crypto_alg, &crypto_alg))
13348 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
13350 else if (unformat (i, "integ_alg %U",
13351 unformat_ipsec_api_integ_alg, &integ_alg))
13353 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
13357 clib_warning ("parse error '%U'", format_unformat_error, i);
13363 M (IPSEC_SAD_ENTRY_ADD_DEL, mp);
13365 mp->is_add = is_add;
13366 mp->entry.sad_id = ntohl (sad_id);
13367 mp->entry.protocol = protocol;
13368 mp->entry.spi = ntohl (spi);
13369 mp->entry.flags = flags;
13371 mp->entry.crypto_algorithm = crypto_alg;
13372 mp->entry.integrity_algorithm = integ_alg;
13373 mp->entry.crypto_key.length = vec_len (ck);
13374 mp->entry.integrity_key.length = vec_len (ik);
13376 if (mp->entry.crypto_key.length > sizeof (mp->entry.crypto_key.data))
13377 mp->entry.crypto_key.length = sizeof (mp->entry.crypto_key.data);
13379 if (mp->entry.integrity_key.length > sizeof (mp->entry.integrity_key.data))
13380 mp->entry.integrity_key.length = sizeof (mp->entry.integrity_key.data);
13383 clib_memcpy (mp->entry.crypto_key.data, ck, mp->entry.crypto_key.length);
13385 clib_memcpy (mp->entry.integrity_key.data, ik,
13386 mp->entry.integrity_key.length);
13388 if (flags & IPSEC_API_SAD_FLAG_IS_TUNNEL)
13390 clib_memcpy (&mp->entry.tunnel_src, &tun_src,
13391 sizeof (mp->entry.tunnel_src));
13392 clib_memcpy (&mp->entry.tunnel_dst, &tun_dst,
13393 sizeof (mp->entry.tunnel_dst));
13402 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
13404 unformat_input_t *i = vam->input;
13405 vl_api_ipsec_tunnel_if_add_del_t *mp;
13406 u32 local_spi = 0, remote_spi = 0;
13407 u32 crypto_alg = 0, integ_alg = 0;
13408 u8 *lck = NULL, *rck = NULL;
13409 u8 *lik = NULL, *rik = NULL;
13410 vl_api_address_t local_ip = { 0 };
13411 vl_api_address_t remote_ip = { 0 };
13415 u8 anti_replay = 0;
13421 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13423 if (unformat (i, "del"))
13425 else if (unformat (i, "esn"))
13427 else if (unformat (i, "anti-replay"))
13429 else if (unformat (i, "count %d", &count))
13431 else if (unformat (i, "local_spi %d", &local_spi))
13433 else if (unformat (i, "remote_spi %d", &remote_spi))
13436 if (unformat (i, "local_ip %U", unformat_vl_api_address, &local_ip))
13439 if (unformat (i, "remote_ip %U", unformat_vl_api_address, &remote_ip))
13441 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
13444 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
13446 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
13448 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
13452 (i, "crypto_alg %U", unformat_ipsec_api_crypto_alg, &crypto_alg))
13454 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
13456 errmsg ("unsupported crypto-alg: '%U'\n",
13457 format_ipsec_crypto_alg, crypto_alg);
13463 (i, "integ_alg %U", unformat_ipsec_api_integ_alg, &integ_alg))
13465 if (integ_alg >= IPSEC_INTEG_N_ALG)
13467 errmsg ("unsupported integ-alg: '%U'\n",
13468 format_ipsec_integ_alg, integ_alg);
13472 else if (unformat (i, "instance %u", &instance))
13476 errmsg ("parse error '%U'\n", format_unformat_error, i);
13483 /* Turn on async mode */
13484 vam->async_mode = 1;
13485 vam->async_errors = 0;
13486 before = vat_time_now (vam);
13489 for (jj = 0; jj < count; jj++)
13491 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
13493 mp->is_add = is_add;
13495 mp->anti_replay = anti_replay;
13498 increment_address (&remote_ip);
13500 clib_memcpy (&mp->local_ip, &local_ip, sizeof (local_ip));
13501 clib_memcpy (&mp->remote_ip, &remote_ip, sizeof (remote_ip));
13503 mp->local_spi = htonl (local_spi + jj);
13504 mp->remote_spi = htonl (remote_spi + jj);
13505 mp->crypto_alg = (u8) crypto_alg;
13507 mp->local_crypto_key_len = 0;
13510 mp->local_crypto_key_len = vec_len (lck);
13511 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
13512 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
13513 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
13516 mp->remote_crypto_key_len = 0;
13519 mp->remote_crypto_key_len = vec_len (rck);
13520 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
13521 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
13522 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
13525 mp->integ_alg = (u8) integ_alg;
13527 mp->local_integ_key_len = 0;
13530 mp->local_integ_key_len = vec_len (lik);
13531 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
13532 mp->local_integ_key_len = sizeof (mp->local_integ_key);
13533 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
13536 mp->remote_integ_key_len = 0;
13539 mp->remote_integ_key_len = vec_len (rik);
13540 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
13541 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
13542 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
13547 mp->renumber = renumber;
13548 mp->show_instance = ntohl (instance);
13553 /* When testing multiple add/del ops, use a control-ping to sync */
13556 vl_api_control_ping_t *mp_ping;
13560 /* Shut off async mode */
13561 vam->async_mode = 0;
13563 MPING (CONTROL_PING, mp_ping);
13566 timeout = vat_time_now (vam) + 1.0;
13567 while (vat_time_now (vam) < timeout)
13568 if (vam->result_ready == 1)
13573 if (vam->retval == -99)
13574 errmsg ("timeout");
13576 if (vam->async_errors > 0)
13578 errmsg ("%d asynchronous errors", vam->async_errors);
13581 vam->async_errors = 0;
13582 after = vat_time_now (vam);
13584 /* slim chance, but we might have eaten SIGTERM on the first iteration */
13588 print (vam->ofp, "%d tunnels in %.6f secs, %.2f tunnels/sec",
13589 count, after - before, count / (after - before));
13593 /* Wait for a reply... */
13602 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
13604 vat_main_t *vam = &vat_main;
13606 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
13607 "crypto_key %U integ_alg %u integ_key %U flags %x "
13608 "tunnel_src_addr %U tunnel_dst_addr %U "
13609 "salt %u seq_outbound %lu last_seq_inbound %lu "
13610 "replay_window %lu stat_index %u\n",
13611 ntohl (mp->entry.sad_id),
13612 ntohl (mp->sw_if_index),
13613 ntohl (mp->entry.spi),
13614 ntohl (mp->entry.protocol),
13615 ntohl (mp->entry.crypto_algorithm),
13616 format_hex_bytes, mp->entry.crypto_key.data,
13617 mp->entry.crypto_key.length, ntohl (mp->entry.integrity_algorithm),
13618 format_hex_bytes, mp->entry.integrity_key.data,
13619 mp->entry.integrity_key.length, ntohl (mp->entry.flags),
13620 format_vl_api_address, &mp->entry.tunnel_src, format_vl_api_address,
13621 &mp->entry.tunnel_dst, ntohl (mp->salt),
13622 clib_net_to_host_u64 (mp->seq_outbound),
13623 clib_net_to_host_u64 (mp->last_seq_inbound),
13624 clib_net_to_host_u64 (mp->replay_window), ntohl (mp->stat_index));
13627 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
13628 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
13630 static void vl_api_ipsec_sa_details_t_handler_json
13631 (vl_api_ipsec_sa_details_t * mp)
13633 vat_main_t *vam = &vat_main;
13634 vat_json_node_t *node = NULL;
13635 vl_api_ipsec_sad_flags_t flags;
13637 if (VAT_JSON_ARRAY != vam->json_tree.type)
13639 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13640 vat_json_init_array (&vam->json_tree);
13642 node = vat_json_array_add (&vam->json_tree);
13644 vat_json_init_object (node);
13645 vat_json_object_add_uint (node, "sa_id", ntohl (mp->entry.sad_id));
13646 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13647 vat_json_object_add_uint (node, "spi", ntohl (mp->entry.spi));
13648 vat_json_object_add_uint (node, "proto", ntohl (mp->entry.protocol));
13649 vat_json_object_add_uint (node, "crypto_alg",
13650 ntohl (mp->entry.crypto_algorithm));
13651 vat_json_object_add_uint (node, "integ_alg",
13652 ntohl (mp->entry.integrity_algorithm));
13653 flags = ntohl (mp->entry.flags);
13654 vat_json_object_add_uint (node, "use_esn",
13655 ! !(flags & IPSEC_API_SAD_FLAG_USE_ESN));
13656 vat_json_object_add_uint (node, "use_anti_replay",
13657 ! !(flags & IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY));
13658 vat_json_object_add_uint (node, "is_tunnel",
13659 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL));
13660 vat_json_object_add_uint (node, "is_tunnel_ip6",
13661 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL_V6));
13662 vat_json_object_add_uint (node, "udp_encap",
13663 ! !(flags & IPSEC_API_SAD_FLAG_UDP_ENCAP));
13664 vat_json_object_add_bytes (node, "crypto_key", mp->entry.crypto_key.data,
13665 mp->entry.crypto_key.length);
13666 vat_json_object_add_bytes (node, "integ_key", mp->entry.integrity_key.data,
13667 mp->entry.integrity_key.length);
13668 vat_json_object_add_address (node, "src", &mp->entry.tunnel_src);
13669 vat_json_object_add_address (node, "dst", &mp->entry.tunnel_dst);
13670 vat_json_object_add_uint (node, "replay_window",
13671 clib_net_to_host_u64 (mp->replay_window));
13672 vat_json_object_add_uint (node, "stat_index", ntohl (mp->stat_index));
13676 api_ipsec_sa_dump (vat_main_t * vam)
13678 unformat_input_t *i = vam->input;
13679 vl_api_ipsec_sa_dump_t *mp;
13680 vl_api_control_ping_t *mp_ping;
13684 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13686 if (unformat (i, "sa_id %d", &sa_id))
13690 clib_warning ("parse error '%U'", format_unformat_error, i);
13695 M (IPSEC_SA_DUMP, mp);
13697 mp->sa_id = ntohl (sa_id);
13701 /* Use a control ping for synchronization */
13702 M (CONTROL_PING, mp_ping);
13710 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
13712 unformat_input_t *i = vam->input;
13713 vl_api_ipsec_tunnel_if_set_sa_t *mp;
13714 u32 sw_if_index = ~0;
13716 u8 is_outbound = (u8) ~ 0;
13719 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13721 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13723 else if (unformat (i, "sa_id %d", &sa_id))
13725 else if (unformat (i, "outbound"))
13727 else if (unformat (i, "inbound"))
13731 clib_warning ("parse error '%U'", format_unformat_error, i);
13736 if (sw_if_index == ~0)
13738 errmsg ("interface must be specified");
13744 errmsg ("SA ID must be specified");
13748 M (IPSEC_TUNNEL_IF_SET_SA, mp);
13750 mp->sw_if_index = htonl (sw_if_index);
13751 mp->sa_id = htonl (sa_id);
13752 mp->is_outbound = is_outbound;
13761 api_get_first_msg_id (vat_main_t * vam)
13763 vl_api_get_first_msg_id_t *mp;
13764 unformat_input_t *i = vam->input;
13769 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13771 if (unformat (i, "client %s", &name))
13779 errmsg ("missing client name");
13782 vec_add1 (name, 0);
13784 if (vec_len (name) > 63)
13786 errmsg ("client name too long");
13790 M (GET_FIRST_MSG_ID, mp);
13791 clib_memcpy (mp->name, name, vec_len (name));
13798 api_cop_interface_enable_disable (vat_main_t * vam)
13800 unformat_input_t *line_input = vam->input;
13801 vl_api_cop_interface_enable_disable_t *mp;
13802 u32 sw_if_index = ~0;
13803 u8 enable_disable = 1;
13806 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13808 if (unformat (line_input, "disable"))
13809 enable_disable = 0;
13810 if (unformat (line_input, "enable"))
13811 enable_disable = 1;
13812 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13813 vam, &sw_if_index))
13815 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13821 if (sw_if_index == ~0)
13823 errmsg ("missing interface name or sw_if_index");
13827 /* Construct the API message */
13828 M (COP_INTERFACE_ENABLE_DISABLE, mp);
13829 mp->sw_if_index = ntohl (sw_if_index);
13830 mp->enable_disable = enable_disable;
13834 /* Wait for the reply */
13840 api_cop_whitelist_enable_disable (vat_main_t * vam)
13842 unformat_input_t *line_input = vam->input;
13843 vl_api_cop_whitelist_enable_disable_t *mp;
13844 u32 sw_if_index = ~0;
13845 u8 ip4 = 0, ip6 = 0, default_cop = 0;
13849 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13851 if (unformat (line_input, "ip4"))
13853 else if (unformat (line_input, "ip6"))
13855 else if (unformat (line_input, "default"))
13857 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13858 vam, &sw_if_index))
13860 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13862 else if (unformat (line_input, "fib-id %d", &fib_id))
13868 if (sw_if_index == ~0)
13870 errmsg ("missing interface name or sw_if_index");
13874 /* Construct the API message */
13875 M (COP_WHITELIST_ENABLE_DISABLE, mp);
13876 mp->sw_if_index = ntohl (sw_if_index);
13877 mp->fib_id = ntohl (fib_id);
13880 mp->default_cop = default_cop;
13884 /* Wait for the reply */
13890 api_get_node_graph (vat_main_t * vam)
13892 vl_api_get_node_graph_t *mp;
13895 M (GET_NODE_GRAPH, mp);
13899 /* Wait for the reply */
13905 /** Used for parsing LISP eids */
13906 typedef CLIB_PACKED(struct{
13910 lisp_nsh_api_t nsh;
13912 u32 len; /**< prefix length if IP */
13913 u8 type; /**< type of eid */
13918 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
13920 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
13922 clib_memset (a, 0, sizeof (a[0]));
13924 if (unformat (input, "%U/%d", unformat_ip46_address, a->addr.ip, &a->len))
13926 a->type = 0; /* ip prefix type */
13928 else if (unformat (input, "%U", unformat_ethernet_address, &a->addr.mac))
13930 a->type = 1; /* mac type */
13932 else if (unformat (input, "%U", unformat_nsh_address, a->addr.nsh))
13934 a->type = 2; /* NSH type */
13935 a->addr.nsh.spi = clib_host_to_net_u32 (a->addr.nsh.spi);
13944 if (ip46_address_is_ip4 (&a->addr.ip))
13945 return a->len > 32 ? 1 : 0;
13947 return a->len > 128 ? 1 : 0;
13954 lisp_eid_put_vat (vl_api_eid_t * eid, const lisp_eid_vat_t * vat_eid)
13956 eid->type = vat_eid->type;
13959 case EID_TYPE_API_PREFIX:
13960 if (ip46_address_is_ip4 (&vat_eid->addr.ip))
13962 clib_memcpy (&eid->address.prefix.address.un.ip4,
13963 &vat_eid->addr.ip.ip4, 4);
13964 eid->address.prefix.address.af = ADDRESS_IP4;
13965 eid->address.prefix.len = vat_eid->len;
13969 clib_memcpy (&eid->address.prefix.address.un.ip6,
13970 &vat_eid->addr.ip.ip6, 16);
13971 eid->address.prefix.address.af = ADDRESS_IP6;
13972 eid->address.prefix.len = vat_eid->len;
13975 case EID_TYPE_API_MAC:
13976 clib_memcpy (&eid->address.mac, &vat_eid->addr.mac,
13977 sizeof (eid->address.mac));
13979 case EID_TYPE_API_NSH:
13980 clib_memcpy (&eid->address.nsh, &vat_eid->addr.nsh,
13981 sizeof (eid->address.nsh));
13990 api_one_add_del_locator_set (vat_main_t * vam)
13992 unformat_input_t *input = vam->input;
13993 vl_api_one_add_del_locator_set_t *mp;
13995 u8 *locator_set_name = NULL;
13996 u8 locator_set_name_set = 0;
13997 vl_api_local_locator_t locator, *locators = 0;
13998 u32 sw_if_index, priority, weight;
14002 /* Parse args required to build the message */
14003 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14005 if (unformat (input, "del"))
14009 else if (unformat (input, "locator-set %s", &locator_set_name))
14011 locator_set_name_set = 1;
14013 else if (unformat (input, "sw_if_index %u p %u w %u",
14014 &sw_if_index, &priority, &weight))
14016 locator.sw_if_index = htonl (sw_if_index);
14017 locator.priority = priority;
14018 locator.weight = weight;
14019 vec_add1 (locators, locator);
14023 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
14024 &sw_if_index, &priority, &weight))
14026 locator.sw_if_index = htonl (sw_if_index);
14027 locator.priority = priority;
14028 locator.weight = weight;
14029 vec_add1 (locators, locator);
14035 if (locator_set_name_set == 0)
14037 errmsg ("missing locator-set name");
14038 vec_free (locators);
14042 if (vec_len (locator_set_name) > 64)
14044 errmsg ("locator-set name too long");
14045 vec_free (locator_set_name);
14046 vec_free (locators);
14049 vec_add1 (locator_set_name, 0);
14051 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
14053 /* Construct the API message */
14054 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
14056 mp->is_add = is_add;
14057 clib_memcpy (mp->locator_set_name, locator_set_name,
14058 vec_len (locator_set_name));
14059 vec_free (locator_set_name);
14061 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
14063 clib_memcpy (mp->locators, locators, data_len);
14064 vec_free (locators);
14069 /* Wait for a reply... */
14074 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
14077 api_one_add_del_locator (vat_main_t * vam)
14079 unformat_input_t *input = vam->input;
14080 vl_api_one_add_del_locator_t *mp;
14081 u32 tmp_if_index = ~0;
14082 u32 sw_if_index = ~0;
14083 u8 sw_if_index_set = 0;
14084 u8 sw_if_index_if_name_set = 0;
14086 u8 priority_set = 0;
14090 u8 *locator_set_name = NULL;
14091 u8 locator_set_name_set = 0;
14094 /* Parse args required to build the message */
14095 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14097 if (unformat (input, "del"))
14101 else if (unformat (input, "locator-set %s", &locator_set_name))
14103 locator_set_name_set = 1;
14105 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
14108 sw_if_index_if_name_set = 1;
14109 sw_if_index = tmp_if_index;
14111 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
14113 sw_if_index_set = 1;
14114 sw_if_index = tmp_if_index;
14116 else if (unformat (input, "p %d", &priority))
14120 else if (unformat (input, "w %d", &weight))
14128 if (locator_set_name_set == 0)
14130 errmsg ("missing locator-set name");
14134 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
14136 errmsg ("missing sw_if_index");
14137 vec_free (locator_set_name);
14141 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
14143 errmsg ("cannot use both params interface name and sw_if_index");
14144 vec_free (locator_set_name);
14148 if (priority_set == 0)
14150 errmsg ("missing locator-set priority");
14151 vec_free (locator_set_name);
14155 if (weight_set == 0)
14157 errmsg ("missing locator-set weight");
14158 vec_free (locator_set_name);
14162 if (vec_len (locator_set_name) > 64)
14164 errmsg ("locator-set name too long");
14165 vec_free (locator_set_name);
14168 vec_add1 (locator_set_name, 0);
14170 /* Construct the API message */
14171 M (ONE_ADD_DEL_LOCATOR, mp);
14173 mp->is_add = is_add;
14174 mp->sw_if_index = ntohl (sw_if_index);
14175 mp->priority = priority;
14176 mp->weight = weight;
14177 clib_memcpy (mp->locator_set_name, locator_set_name,
14178 vec_len (locator_set_name));
14179 vec_free (locator_set_name);
14184 /* Wait for a reply... */
14189 #define api_lisp_add_del_locator api_one_add_del_locator
14192 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
14194 u32 *key_id = va_arg (*args, u32 *);
14197 if (unformat (input, "%s", &s))
14199 if (!strcmp ((char *) s, "sha1"))
14200 key_id[0] = HMAC_SHA_1_96;
14201 else if (!strcmp ((char *) s, "sha256"))
14202 key_id[0] = HMAC_SHA_256_128;
14205 clib_warning ("invalid key_id: '%s'", s);
14206 key_id[0] = HMAC_NO_KEY;
14217 api_one_add_del_local_eid (vat_main_t * vam)
14219 unformat_input_t *input = vam->input;
14220 vl_api_one_add_del_local_eid_t *mp;
14223 lisp_eid_vat_t _eid, *eid = &_eid;
14224 u8 *locator_set_name = 0;
14225 u8 locator_set_name_set = 0;
14231 /* Parse args required to build the message */
14232 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14234 if (unformat (input, "del"))
14238 else if (unformat (input, "vni %d", &vni))
14242 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14246 else if (unformat (input, "locator-set %s", &locator_set_name))
14248 locator_set_name_set = 1;
14250 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
14252 else if (unformat (input, "secret-key %_%v%_", &key))
14258 if (locator_set_name_set == 0)
14260 errmsg ("missing locator-set name");
14266 errmsg ("EID address not set!");
14267 vec_free (locator_set_name);
14271 if (key && (0 == key_id))
14273 errmsg ("invalid key_id!");
14277 if (vec_len (key) > 64)
14279 errmsg ("key too long");
14284 if (vec_len (locator_set_name) > 64)
14286 errmsg ("locator-set name too long");
14287 vec_free (locator_set_name);
14290 vec_add1 (locator_set_name, 0);
14292 /* Construct the API message */
14293 M (ONE_ADD_DEL_LOCAL_EID, mp);
14295 mp->is_add = is_add;
14296 lisp_eid_put_vat (&mp->eid, eid);
14297 mp->vni = clib_host_to_net_u32 (vni);
14298 mp->key.id = key_id;
14299 clib_memcpy (mp->locator_set_name, locator_set_name,
14300 vec_len (locator_set_name));
14301 clib_memcpy (mp->key.key, key, vec_len (key));
14303 vec_free (locator_set_name);
14309 /* Wait for a reply... */
14314 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
14317 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
14319 u32 dp_table = 0, vni = 0;;
14320 unformat_input_t *input = vam->input;
14321 vl_api_gpe_add_del_fwd_entry_t *mp;
14323 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
14324 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
14325 u8 rmt_eid_set = 0, lcl_eid_set = 0;
14326 u32 action = ~0, w;
14327 ip4_address_t rmt_rloc4, lcl_rloc4;
14328 ip6_address_t rmt_rloc6, lcl_rloc6;
14329 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
14332 clib_memset (&rloc, 0, sizeof (rloc));
14334 /* Parse args required to build the message */
14335 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14337 if (unformat (input, "del"))
14339 else if (unformat (input, "add"))
14341 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
14345 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
14349 else if (unformat (input, "vrf %d", &dp_table))
14351 else if (unformat (input, "bd %d", &dp_table))
14353 else if (unformat (input, "vni %d", &vni))
14355 else if (unformat (input, "w %d", &w))
14359 errmsg ("No RLOC configured for setting priority/weight!");
14362 curr_rloc->weight = w;
14364 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
14365 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
14368 clib_memcpy (&rloc.addr.un.ip4, &lcl_rloc4, sizeof (lcl_rloc4));
14370 vec_add1 (lcl_locs, rloc);
14372 clib_memcpy (&rloc.addr.un.ip4, &rmt_rloc4, sizeof (rmt_rloc4));
14373 vec_add1 (rmt_locs, rloc);
14374 /* weight saved in rmt loc */
14375 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14377 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
14378 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
14381 clib_memcpy (&rloc.addr.un.ip6, &lcl_rloc6, sizeof (lcl_rloc6));
14383 vec_add1 (lcl_locs, rloc);
14385 clib_memcpy (&rloc.addr.un.ip6, &rmt_rloc6, sizeof (rmt_rloc6));
14386 vec_add1 (rmt_locs, rloc);
14387 /* weight saved in rmt loc */
14388 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14390 else if (unformat (input, "action %d", &action))
14396 clib_warning ("parse error '%U'", format_unformat_error, input);
14403 errmsg ("remote eid addresses not set");
14407 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
14409 errmsg ("eid types don't match");
14413 if (0 == rmt_locs && (u32) ~ 0 == action)
14415 errmsg ("action not set for negative mapping");
14419 /* Construct the API message */
14420 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
14421 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
14423 mp->is_add = is_add;
14424 lisp_eid_put_vat (&mp->rmt_eid, rmt_eid);
14425 lisp_eid_put_vat (&mp->lcl_eid, lcl_eid);
14426 mp->dp_table = clib_host_to_net_u32 (dp_table);
14427 mp->vni = clib_host_to_net_u32 (vni);
14428 mp->action = action;
14430 if (0 != rmt_locs && 0 != lcl_locs)
14432 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
14433 clib_memcpy (mp->locs, lcl_locs,
14434 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
14436 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
14437 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
14438 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
14440 vec_free (lcl_locs);
14441 vec_free (rmt_locs);
14446 /* Wait for a reply... */
14452 api_one_add_del_map_server (vat_main_t * vam)
14454 unformat_input_t *input = vam->input;
14455 vl_api_one_add_del_map_server_t *mp;
14459 ip4_address_t ipv4;
14460 ip6_address_t ipv6;
14463 /* Parse args required to build the message */
14464 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14466 if (unformat (input, "del"))
14470 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14474 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14482 if (ipv4_set && ipv6_set)
14484 errmsg ("both eid v4 and v6 addresses set");
14488 if (!ipv4_set && !ipv6_set)
14490 errmsg ("eid addresses not set");
14494 /* Construct the API message */
14495 M (ONE_ADD_DEL_MAP_SERVER, mp);
14497 mp->is_add = is_add;
14500 mp->ip_address.af = 1;
14501 clib_memcpy (mp->ip_address.un.ip6, &ipv6, sizeof (ipv6));
14505 mp->ip_address.af = 0;
14506 clib_memcpy (mp->ip_address.un.ip4, &ipv4, sizeof (ipv4));
14512 /* Wait for a reply... */
14517 #define api_lisp_add_del_map_server api_one_add_del_map_server
14520 api_one_add_del_map_resolver (vat_main_t * vam)
14522 unformat_input_t *input = vam->input;
14523 vl_api_one_add_del_map_resolver_t *mp;
14527 ip4_address_t ipv4;
14528 ip6_address_t ipv6;
14531 /* Parse args required to build the message */
14532 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14534 if (unformat (input, "del"))
14538 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14542 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14550 if (ipv4_set && ipv6_set)
14552 errmsg ("both eid v4 and v6 addresses set");
14556 if (!ipv4_set && !ipv6_set)
14558 errmsg ("eid addresses not set");
14562 /* Construct the API message */
14563 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
14565 mp->is_add = is_add;
14568 mp->ip_address.af = 1;
14569 clib_memcpy (mp->ip_address.un.ip6, &ipv6, sizeof (ipv6));
14573 mp->ip_address.af = 0;
14574 clib_memcpy (mp->ip_address.un.ip6, &ipv4, sizeof (ipv4));
14580 /* Wait for a reply... */
14585 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
14588 api_lisp_gpe_enable_disable (vat_main_t * vam)
14590 unformat_input_t *input = vam->input;
14591 vl_api_gpe_enable_disable_t *mp;
14596 /* Parse args required to build the message */
14597 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14599 if (unformat (input, "enable"))
14604 else if (unformat (input, "disable"))
14615 errmsg ("Value not set");
14619 /* Construct the API message */
14620 M (GPE_ENABLE_DISABLE, mp);
14622 mp->is_enable = is_enable;
14627 /* Wait for a reply... */
14633 api_one_rloc_probe_enable_disable (vat_main_t * vam)
14635 unformat_input_t *input = vam->input;
14636 vl_api_one_rloc_probe_enable_disable_t *mp;
14641 /* Parse args required to build the message */
14642 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14644 if (unformat (input, "enable"))
14649 else if (unformat (input, "disable"))
14657 errmsg ("Value not set");
14661 /* Construct the API message */
14662 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
14664 mp->is_enable = is_enable;
14669 /* Wait for a reply... */
14674 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
14677 api_one_map_register_enable_disable (vat_main_t * vam)
14679 unformat_input_t *input = vam->input;
14680 vl_api_one_map_register_enable_disable_t *mp;
14685 /* Parse args required to build the message */
14686 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14688 if (unformat (input, "enable"))
14693 else if (unformat (input, "disable"))
14701 errmsg ("Value not set");
14705 /* Construct the API message */
14706 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
14708 mp->is_enable = is_enable;
14713 /* Wait for a reply... */
14718 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
14721 api_one_enable_disable (vat_main_t * vam)
14723 unformat_input_t *input = vam->input;
14724 vl_api_one_enable_disable_t *mp;
14729 /* Parse args required to build the message */
14730 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14732 if (unformat (input, "enable"))
14737 else if (unformat (input, "disable"))
14747 errmsg ("Value not set");
14751 /* Construct the API message */
14752 M (ONE_ENABLE_DISABLE, mp);
14754 mp->is_enable = is_enable;
14759 /* Wait for a reply... */
14764 #define api_lisp_enable_disable api_one_enable_disable
14767 api_one_enable_disable_xtr_mode (vat_main_t * vam)
14769 unformat_input_t *input = vam->input;
14770 vl_api_one_enable_disable_xtr_mode_t *mp;
14775 /* Parse args required to build the message */
14776 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14778 if (unformat (input, "enable"))
14783 else if (unformat (input, "disable"))
14793 errmsg ("Value not set");
14797 /* Construct the API message */
14798 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
14800 mp->is_enable = is_enable;
14805 /* Wait for a reply... */
14811 api_one_show_xtr_mode (vat_main_t * vam)
14813 vl_api_one_show_xtr_mode_t *mp;
14816 /* Construct the API message */
14817 M (ONE_SHOW_XTR_MODE, mp);
14822 /* Wait for a reply... */
14828 api_one_enable_disable_pitr_mode (vat_main_t * vam)
14830 unformat_input_t *input = vam->input;
14831 vl_api_one_enable_disable_pitr_mode_t *mp;
14836 /* Parse args required to build the message */
14837 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14839 if (unformat (input, "enable"))
14844 else if (unformat (input, "disable"))
14854 errmsg ("Value not set");
14858 /* Construct the API message */
14859 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
14861 mp->is_enable = is_enable;
14866 /* Wait for a reply... */
14872 api_one_show_pitr_mode (vat_main_t * vam)
14874 vl_api_one_show_pitr_mode_t *mp;
14877 /* Construct the API message */
14878 M (ONE_SHOW_PITR_MODE, mp);
14883 /* Wait for a reply... */
14889 api_one_enable_disable_petr_mode (vat_main_t * vam)
14891 unformat_input_t *input = vam->input;
14892 vl_api_one_enable_disable_petr_mode_t *mp;
14897 /* Parse args required to build the message */
14898 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14900 if (unformat (input, "enable"))
14905 else if (unformat (input, "disable"))
14915 errmsg ("Value not set");
14919 /* Construct the API message */
14920 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
14922 mp->is_enable = is_enable;
14927 /* Wait for a reply... */
14933 api_one_show_petr_mode (vat_main_t * vam)
14935 vl_api_one_show_petr_mode_t *mp;
14938 /* Construct the API message */
14939 M (ONE_SHOW_PETR_MODE, mp);
14944 /* Wait for a reply... */
14950 api_show_one_map_register_state (vat_main_t * vam)
14952 vl_api_show_one_map_register_state_t *mp;
14955 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
14960 /* wait for reply */
14965 #define api_show_lisp_map_register_state api_show_one_map_register_state
14968 api_show_one_rloc_probe_state (vat_main_t * vam)
14970 vl_api_show_one_rloc_probe_state_t *mp;
14973 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
14978 /* wait for reply */
14983 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
14986 api_one_add_del_ndp_entry (vat_main_t * vam)
14988 vl_api_one_add_del_ndp_entry_t *mp;
14989 unformat_input_t *input = vam->input;
14994 u8 mac[6] = { 0, };
14995 u8 ip6[16] = { 0, };
14999 /* Parse args required to build the message */
15000 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15002 if (unformat (input, "del"))
15004 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
15006 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
15008 else if (unformat (input, "bd %d", &bd))
15012 errmsg ("parse error '%U'", format_unformat_error, input);
15017 if (!bd_set || !ip_set || (!mac_set && is_add))
15019 errmsg ("Missing BD, IP or MAC!");
15023 M (ONE_ADD_DEL_NDP_ENTRY, mp);
15024 mp->is_add = is_add;
15025 clib_memcpy (&mp->entry.mac, mac, 6);
15026 mp->bd = clib_host_to_net_u32 (bd);
15027 clib_memcpy (&mp->entry.ip6, ip6, sizeof (mp->entry.ip6));
15032 /* wait for reply */
15038 api_one_add_del_l2_arp_entry (vat_main_t * vam)
15040 vl_api_one_add_del_l2_arp_entry_t *mp;
15041 unformat_input_t *input = vam->input;
15046 u8 mac[6] = { 0, };
15047 u32 ip4 = 0, bd = ~0;
15050 /* Parse args required to build the message */
15051 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15053 if (unformat (input, "del"))
15055 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
15057 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
15059 else if (unformat (input, "bd %d", &bd))
15063 errmsg ("parse error '%U'", format_unformat_error, input);
15068 if (!bd_set || !ip_set || (!mac_set && is_add))
15070 errmsg ("Missing BD, IP or MAC!");
15074 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
15075 mp->is_add = is_add;
15076 clib_memcpy (&mp->entry.mac, mac, 6);
15077 mp->bd = clib_host_to_net_u32 (bd);
15078 clib_memcpy (mp->entry.ip4, &ip4, sizeof (mp->entry.ip4));
15083 /* wait for reply */
15089 api_one_ndp_bd_get (vat_main_t * vam)
15091 vl_api_one_ndp_bd_get_t *mp;
15094 M (ONE_NDP_BD_GET, mp);
15099 /* wait for reply */
15105 api_one_ndp_entries_get (vat_main_t * vam)
15107 vl_api_one_ndp_entries_get_t *mp;
15108 unformat_input_t *input = vam->input;
15113 /* Parse args required to build the message */
15114 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15116 if (unformat (input, "bd %d", &bd))
15120 errmsg ("parse error '%U'", format_unformat_error, input);
15127 errmsg ("Expected bridge domain!");
15131 M (ONE_NDP_ENTRIES_GET, mp);
15132 mp->bd = clib_host_to_net_u32 (bd);
15137 /* wait for reply */
15143 api_one_l2_arp_bd_get (vat_main_t * vam)
15145 vl_api_one_l2_arp_bd_get_t *mp;
15148 M (ONE_L2_ARP_BD_GET, mp);
15153 /* wait for reply */
15159 api_one_l2_arp_entries_get (vat_main_t * vam)
15161 vl_api_one_l2_arp_entries_get_t *mp;
15162 unformat_input_t *input = vam->input;
15167 /* Parse args required to build the message */
15168 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15170 if (unformat (input, "bd %d", &bd))
15174 errmsg ("parse error '%U'", format_unformat_error, input);
15181 errmsg ("Expected bridge domain!");
15185 M (ONE_L2_ARP_ENTRIES_GET, mp);
15186 mp->bd = clib_host_to_net_u32 (bd);
15191 /* wait for reply */
15197 api_one_stats_enable_disable (vat_main_t * vam)
15199 vl_api_one_stats_enable_disable_t *mp;
15200 unformat_input_t *input = vam->input;
15205 /* Parse args required to build the message */
15206 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15208 if (unformat (input, "enable"))
15213 else if (unformat (input, "disable"))
15223 errmsg ("Value not set");
15227 M (ONE_STATS_ENABLE_DISABLE, mp);
15228 mp->is_enable = is_enable;
15233 /* wait for reply */
15239 api_show_one_stats_enable_disable (vat_main_t * vam)
15241 vl_api_show_one_stats_enable_disable_t *mp;
15244 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
15249 /* wait for reply */
15255 api_show_one_map_request_mode (vat_main_t * vam)
15257 vl_api_show_one_map_request_mode_t *mp;
15260 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
15265 /* wait for reply */
15270 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
15273 api_one_map_request_mode (vat_main_t * vam)
15275 unformat_input_t *input = vam->input;
15276 vl_api_one_map_request_mode_t *mp;
15280 /* Parse args required to build the message */
15281 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15283 if (unformat (input, "dst-only"))
15285 else if (unformat (input, "src-dst"))
15289 errmsg ("parse error '%U'", format_unformat_error, input);
15294 M (ONE_MAP_REQUEST_MODE, mp);
15301 /* wait for reply */
15306 #define api_lisp_map_request_mode api_one_map_request_mode
15309 * Enable/disable ONE proxy ITR.
15311 * @param vam vpp API test context
15312 * @return return code
15315 api_one_pitr_set_locator_set (vat_main_t * vam)
15317 u8 ls_name_set = 0;
15318 unformat_input_t *input = vam->input;
15319 vl_api_one_pitr_set_locator_set_t *mp;
15324 /* Parse args required to build the message */
15325 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15327 if (unformat (input, "del"))
15329 else if (unformat (input, "locator-set %s", &ls_name))
15333 errmsg ("parse error '%U'", format_unformat_error, input);
15340 errmsg ("locator-set name not set!");
15344 M (ONE_PITR_SET_LOCATOR_SET, mp);
15346 mp->is_add = is_add;
15347 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
15348 vec_free (ls_name);
15353 /* wait for reply */
15358 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
15361 api_one_nsh_set_locator_set (vat_main_t * vam)
15363 u8 ls_name_set = 0;
15364 unformat_input_t *input = vam->input;
15365 vl_api_one_nsh_set_locator_set_t *mp;
15370 /* Parse args required to build the message */
15371 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15373 if (unformat (input, "del"))
15375 else if (unformat (input, "ls %s", &ls_name))
15379 errmsg ("parse error '%U'", format_unformat_error, input);
15384 if (!ls_name_set && is_add)
15386 errmsg ("locator-set name not set!");
15390 M (ONE_NSH_SET_LOCATOR_SET, mp);
15392 mp->is_add = is_add;
15393 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
15394 vec_free (ls_name);
15399 /* wait for reply */
15405 api_show_one_pitr (vat_main_t * vam)
15407 vl_api_show_one_pitr_t *mp;
15410 if (!vam->json_output)
15412 print (vam->ofp, "%=20s", "lisp status:");
15415 M (SHOW_ONE_PITR, mp);
15419 /* Wait for a reply... */
15424 #define api_show_lisp_pitr api_show_one_pitr
15427 api_one_use_petr (vat_main_t * vam)
15429 unformat_input_t *input = vam->input;
15430 vl_api_one_use_petr_t *mp;
15435 clib_memset (&ip, 0, sizeof (ip));
15437 /* Parse args required to build the message */
15438 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15440 if (unformat (input, "disable"))
15443 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
15446 ip_addr_version (&ip) = AF_IP4;
15449 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
15452 ip_addr_version (&ip) = AF_IP6;
15456 errmsg ("parse error '%U'", format_unformat_error, input);
15461 M (ONE_USE_PETR, mp);
15463 mp->is_add = is_add;
15466 mp->ip_address.af = ip_addr_version (&ip) == AF_IP4 ? 0 : 1;
15467 if (mp->ip_address.af)
15468 clib_memcpy (mp->ip_address.un.ip6, &ip, 16);
15470 clib_memcpy (mp->ip_address.un.ip4, &ip, 4);
15476 /* wait for reply */
15481 #define api_lisp_use_petr api_one_use_petr
15484 api_show_one_nsh_mapping (vat_main_t * vam)
15486 vl_api_show_one_use_petr_t *mp;
15489 if (!vam->json_output)
15491 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
15494 M (SHOW_ONE_NSH_MAPPING, mp);
15498 /* Wait for a reply... */
15504 api_show_one_use_petr (vat_main_t * vam)
15506 vl_api_show_one_use_petr_t *mp;
15509 if (!vam->json_output)
15511 print (vam->ofp, "%=20s", "Proxy-ETR status:");
15514 M (SHOW_ONE_USE_PETR, mp);
15518 /* Wait for a reply... */
15523 #define api_show_lisp_use_petr api_show_one_use_petr
15526 * Add/delete mapping between vni and vrf
15529 api_one_eid_table_add_del_map (vat_main_t * vam)
15531 unformat_input_t *input = vam->input;
15532 vl_api_one_eid_table_add_del_map_t *mp;
15533 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
15534 u32 vni, vrf, bd_index;
15537 /* Parse args required to build the message */
15538 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15540 if (unformat (input, "del"))
15542 else if (unformat (input, "vrf %d", &vrf))
15544 else if (unformat (input, "bd_index %d", &bd_index))
15546 else if (unformat (input, "vni %d", &vni))
15552 if (!vni_set || (!vrf_set && !bd_index_set))
15554 errmsg ("missing arguments!");
15558 if (vrf_set && bd_index_set)
15560 errmsg ("error: both vrf and bd entered!");
15564 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
15566 mp->is_add = is_add;
15567 mp->vni = htonl (vni);
15568 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
15569 mp->is_l2 = bd_index_set;
15574 /* wait for reply */
15579 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
15582 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
15584 u32 *action = va_arg (*args, u32 *);
15587 if (unformat (input, "%s", &s))
15589 if (!strcmp ((char *) s, "no-action"))
15591 else if (!strcmp ((char *) s, "natively-forward"))
15593 else if (!strcmp ((char *) s, "send-map-request"))
15595 else if (!strcmp ((char *) s, "drop"))
15599 clib_warning ("invalid action: '%s'", s);
15611 * Add/del remote mapping to/from ONE control plane
15613 * @param vam vpp API test context
15614 * @return return code
15617 api_one_add_del_remote_mapping (vat_main_t * vam)
15619 unformat_input_t *input = vam->input;
15620 vl_api_one_add_del_remote_mapping_t *mp;
15622 lisp_eid_vat_t _eid, *eid = &_eid;
15623 lisp_eid_vat_t _seid, *seid = &_seid;
15624 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
15625 u32 action = ~0, p, w, data_len;
15626 ip4_address_t rloc4;
15627 ip6_address_t rloc6;
15628 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
15631 clib_memset (&rloc, 0, sizeof (rloc));
15633 /* Parse args required to build the message */
15634 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15636 if (unformat (input, "del-all"))
15640 else if (unformat (input, "del"))
15644 else if (unformat (input, "add"))
15648 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15652 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
15656 else if (unformat (input, "vni %d", &vni))
15660 else if (unformat (input, "p %d w %d", &p, &w))
15664 errmsg ("No RLOC configured for setting priority/weight!");
15667 curr_rloc->priority = p;
15668 curr_rloc->weight = w;
15670 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
15672 rloc.ip_address.af = 0;
15673 clib_memcpy (&rloc.ip_address.un.ip6, &rloc6, sizeof (rloc6));
15674 vec_add1 (rlocs, rloc);
15675 curr_rloc = &rlocs[vec_len (rlocs) - 1];
15677 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
15679 rloc.ip_address.af = 1;
15680 clib_memcpy (&rloc.ip_address.un.ip4, &rloc4, sizeof (rloc4));
15681 vec_add1 (rlocs, rloc);
15682 curr_rloc = &rlocs[vec_len (rlocs) - 1];
15684 else if (unformat (input, "action %U",
15685 unformat_negative_mapping_action, &action))
15691 clib_warning ("parse error '%U'", format_unformat_error, input);
15698 errmsg ("missing params!");
15702 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
15704 errmsg ("no action set for negative map-reply!");
15708 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
15710 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
15711 mp->is_add = is_add;
15712 mp->vni = htonl (vni);
15713 mp->action = (u8) action;
15714 mp->is_src_dst = seid_set;
15715 mp->del_all = del_all;
15716 lisp_eid_put_vat (&mp->deid, eid);
15717 lisp_eid_put_vat (&mp->seid, seid);
15719 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
15720 clib_memcpy (mp->rlocs, rlocs, data_len);
15726 /* Wait for a reply... */
15731 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
15734 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
15735 * forwarding entries in data-plane accordingly.
15737 * @param vam vpp API test context
15738 * @return return code
15741 api_one_add_del_adjacency (vat_main_t * vam)
15743 unformat_input_t *input = vam->input;
15744 vl_api_one_add_del_adjacency_t *mp;
15748 lisp_eid_vat_t leid, reid;
15750 leid.type = reid.type = (u8) ~ 0;
15752 /* Parse args required to build the message */
15753 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15755 if (unformat (input, "del"))
15759 else if (unformat (input, "add"))
15763 else if (unformat (input, "reid %U/%d", unformat_ip46_address,
15764 &reid.addr.ip, &reid.len))
15766 reid.type = 0; /* ipv4 */
15768 else if (unformat (input, "reid %U", unformat_ethernet_address,
15771 reid.type = 1; /* mac */
15773 else if (unformat (input, "leid %U/%d", unformat_ip46_address,
15774 &leid.addr.ip, &leid.len))
15776 leid.type = 0; /* ipv4 */
15778 else if (unformat (input, "leid %U", unformat_ethernet_address,
15781 leid.type = 1; /* mac */
15783 else if (unformat (input, "vni %d", &vni))
15789 errmsg ("parse error '%U'", format_unformat_error, input);
15794 if ((u8) ~ 0 == reid.type)
15796 errmsg ("missing params!");
15800 if (leid.type != reid.type)
15802 errmsg ("remote and local EIDs are of different types!");
15806 M (ONE_ADD_DEL_ADJACENCY, mp);
15807 mp->is_add = is_add;
15808 mp->vni = htonl (vni);
15809 lisp_eid_put_vat (&mp->leid, &leid);
15810 lisp_eid_put_vat (&mp->reid, &reid);
15815 /* Wait for a reply... */
15820 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
15823 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
15825 u32 *mode = va_arg (*args, u32 *);
15827 if (unformat (input, "lisp"))
15829 else if (unformat (input, "vxlan"))
15838 api_gpe_get_encap_mode (vat_main_t * vam)
15840 vl_api_gpe_get_encap_mode_t *mp;
15843 /* Construct the API message */
15844 M (GPE_GET_ENCAP_MODE, mp);
15849 /* Wait for a reply... */
15855 api_gpe_set_encap_mode (vat_main_t * vam)
15857 unformat_input_t *input = vam->input;
15858 vl_api_gpe_set_encap_mode_t *mp;
15862 /* Parse args required to build the message */
15863 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15865 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
15871 /* Construct the API message */
15872 M (GPE_SET_ENCAP_MODE, mp);
15874 mp->is_vxlan = mode;
15879 /* Wait for a reply... */
15885 api_lisp_gpe_add_del_iface (vat_main_t * vam)
15887 unformat_input_t *input = vam->input;
15888 vl_api_gpe_add_del_iface_t *mp;
15889 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
15890 u32 dp_table = 0, vni = 0;
15893 /* Parse args required to build the message */
15894 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15896 if (unformat (input, "up"))
15901 else if (unformat (input, "down"))
15906 else if (unformat (input, "table_id %d", &dp_table))
15910 else if (unformat (input, "bd_id %d", &dp_table))
15915 else if (unformat (input, "vni %d", &vni))
15923 if (action_set == 0)
15925 errmsg ("Action not set");
15928 if (dp_table_set == 0 || vni_set == 0)
15930 errmsg ("vni and dp_table must be set");
15934 /* Construct the API message */
15935 M (GPE_ADD_DEL_IFACE, mp);
15937 mp->is_add = is_add;
15938 mp->dp_table = clib_host_to_net_u32 (dp_table);
15940 mp->vni = clib_host_to_net_u32 (vni);
15945 /* Wait for a reply... */
15951 api_one_map_register_fallback_threshold (vat_main_t * vam)
15953 unformat_input_t *input = vam->input;
15954 vl_api_one_map_register_fallback_threshold_t *mp;
15959 /* Parse args required to build the message */
15960 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15962 if (unformat (input, "%u", &value))
15966 clib_warning ("parse error '%U'", format_unformat_error, input);
15973 errmsg ("fallback threshold value is missing!");
15977 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
15978 mp->value = clib_host_to_net_u32 (value);
15983 /* Wait for a reply... */
15989 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
15991 vl_api_show_one_map_register_fallback_threshold_t *mp;
15994 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
15999 /* Wait for a reply... */
16005 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
16007 u32 *proto = va_arg (*args, u32 *);
16009 if (unformat (input, "udp"))
16011 else if (unformat (input, "api"))
16020 api_one_set_transport_protocol (vat_main_t * vam)
16022 unformat_input_t *input = vam->input;
16023 vl_api_one_set_transport_protocol_t *mp;
16028 /* Parse args required to build the message */
16029 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16031 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
16035 clib_warning ("parse error '%U'", format_unformat_error, input);
16042 errmsg ("Transport protocol missing!");
16046 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
16047 mp->protocol = (u8) protocol;
16052 /* Wait for a reply... */
16058 api_one_get_transport_protocol (vat_main_t * vam)
16060 vl_api_one_get_transport_protocol_t *mp;
16063 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
16068 /* Wait for a reply... */
16074 api_one_map_register_set_ttl (vat_main_t * vam)
16076 unformat_input_t *input = vam->input;
16077 vl_api_one_map_register_set_ttl_t *mp;
16082 /* Parse args required to build the message */
16083 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16085 if (unformat (input, "%u", &ttl))
16089 clib_warning ("parse error '%U'", format_unformat_error, input);
16096 errmsg ("TTL value missing!");
16100 M (ONE_MAP_REGISTER_SET_TTL, mp);
16101 mp->ttl = clib_host_to_net_u32 (ttl);
16106 /* Wait for a reply... */
16112 api_show_one_map_register_ttl (vat_main_t * vam)
16114 vl_api_show_one_map_register_ttl_t *mp;
16117 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
16122 /* Wait for a reply... */
16128 * Add/del map request itr rlocs from ONE control plane and updates
16130 * @param vam vpp API test context
16131 * @return return code
16134 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
16136 unformat_input_t *input = vam->input;
16137 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
16138 u8 *locator_set_name = 0;
16139 u8 locator_set_name_set = 0;
16143 /* Parse args required to build the message */
16144 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16146 if (unformat (input, "del"))
16150 else if (unformat (input, "%_%v%_", &locator_set_name))
16152 locator_set_name_set = 1;
16156 clib_warning ("parse error '%U'", format_unformat_error, input);
16161 if (is_add && !locator_set_name_set)
16163 errmsg ("itr-rloc is not set!");
16167 if (is_add && vec_len (locator_set_name) > 64)
16169 errmsg ("itr-rloc locator-set name too long");
16170 vec_free (locator_set_name);
16174 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
16175 mp->is_add = is_add;
16178 clib_memcpy (mp->locator_set_name, locator_set_name,
16179 vec_len (locator_set_name));
16183 clib_memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
16185 vec_free (locator_set_name);
16190 /* Wait for a reply... */
16195 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
16198 api_one_locator_dump (vat_main_t * vam)
16200 unformat_input_t *input = vam->input;
16201 vl_api_one_locator_dump_t *mp;
16202 vl_api_control_ping_t *mp_ping;
16203 u8 is_index_set = 0, is_name_set = 0;
16208 /* Parse args required to build the message */
16209 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16211 if (unformat (input, "ls_name %_%v%_", &ls_name))
16215 else if (unformat (input, "ls_index %d", &ls_index))
16221 errmsg ("parse error '%U'", format_unformat_error, input);
16226 if (!is_index_set && !is_name_set)
16228 errmsg ("error: expected one of index or name!");
16232 if (is_index_set && is_name_set)
16234 errmsg ("error: only one param expected!");
16238 if (vec_len (ls_name) > 62)
16240 errmsg ("error: locator set name too long!");
16244 if (!vam->json_output)
16246 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
16249 M (ONE_LOCATOR_DUMP, mp);
16250 mp->is_index_set = is_index_set;
16253 mp->ls_index = clib_host_to_net_u32 (ls_index);
16256 vec_add1 (ls_name, 0);
16257 strncpy ((char *) mp->ls_name, (char *) ls_name,
16258 sizeof (mp->ls_name) - 1);
16264 /* Use a control ping for synchronization */
16265 MPING (CONTROL_PING, mp_ping);
16268 /* Wait for a reply... */
16273 #define api_lisp_locator_dump api_one_locator_dump
16276 api_one_locator_set_dump (vat_main_t * vam)
16278 vl_api_one_locator_set_dump_t *mp;
16279 vl_api_control_ping_t *mp_ping;
16280 unformat_input_t *input = vam->input;
16284 /* Parse args required to build the message */
16285 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16287 if (unformat (input, "local"))
16291 else if (unformat (input, "remote"))
16297 errmsg ("parse error '%U'", format_unformat_error, input);
16302 if (!vam->json_output)
16304 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
16307 M (ONE_LOCATOR_SET_DUMP, mp);
16309 mp->filter = filter;
16314 /* Use a control ping for synchronization */
16315 MPING (CONTROL_PING, mp_ping);
16318 /* Wait for a reply... */
16323 #define api_lisp_locator_set_dump api_one_locator_set_dump
16326 api_one_eid_table_map_dump (vat_main_t * vam)
16330 unformat_input_t *input = vam->input;
16331 vl_api_one_eid_table_map_dump_t *mp;
16332 vl_api_control_ping_t *mp_ping;
16335 /* Parse args required to build the message */
16336 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16338 if (unformat (input, "l2"))
16343 else if (unformat (input, "l3"))
16350 errmsg ("parse error '%U'", format_unformat_error, input);
16357 errmsg ("expected one of 'l2' or 'l3' parameter!");
16361 if (!vam->json_output)
16363 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
16366 M (ONE_EID_TABLE_MAP_DUMP, mp);
16372 /* Use a control ping for synchronization */
16373 MPING (CONTROL_PING, mp_ping);
16376 /* Wait for a reply... */
16381 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
16384 api_one_eid_table_vni_dump (vat_main_t * vam)
16386 vl_api_one_eid_table_vni_dump_t *mp;
16387 vl_api_control_ping_t *mp_ping;
16390 if (!vam->json_output)
16392 print (vam->ofp, "VNI");
16395 M (ONE_EID_TABLE_VNI_DUMP, mp);
16400 /* Use a control ping for synchronization */
16401 MPING (CONTROL_PING, mp_ping);
16404 /* Wait for a reply... */
16409 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
16412 api_one_eid_table_dump (vat_main_t * vam)
16414 unformat_input_t *i = vam->input;
16415 vl_api_one_eid_table_dump_t *mp;
16416 vl_api_control_ping_t *mp_ping;
16420 lisp_eid_vat_t eid;
16423 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16426 (i, "eid %U/%d", unformat_ip46_address, &eid.addr.ip, &eid.len))
16432 if (unformat (i, "eid %U", unformat_ethernet_address, &eid.addr.mac))
16437 else if (unformat (i, "eid %U", unformat_nsh_address, &eid.addr.nsh))
16442 else if (unformat (i, "vni %d", &t))
16446 else if (unformat (i, "local"))
16450 else if (unformat (i, "remote"))
16456 errmsg ("parse error '%U'", format_unformat_error, i);
16461 if (!vam->json_output)
16463 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
16464 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
16467 M (ONE_EID_TABLE_DUMP, mp);
16469 mp->filter = filter;
16473 mp->vni = htonl (vni);
16474 lisp_eid_put_vat (&mp->eid, &eid);
16480 /* Use a control ping for synchronization */
16481 MPING (CONTROL_PING, mp_ping);
16484 /* Wait for a reply... */
16489 #define api_lisp_eid_table_dump api_one_eid_table_dump
16492 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
16494 unformat_input_t *i = vam->input;
16495 vl_api_gpe_fwd_entries_get_t *mp;
16500 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16502 if (unformat (i, "vni %d", &vni))
16508 errmsg ("parse error '%U'", format_unformat_error, i);
16515 errmsg ("vni not set!");
16519 if (!vam->json_output)
16521 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
16525 M (GPE_FWD_ENTRIES_GET, mp);
16526 mp->vni = clib_host_to_net_u32 (vni);
16531 /* Wait for a reply... */
16536 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
16537 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
16538 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
16539 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
16540 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
16541 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
16542 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
16543 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
16546 api_one_adjacencies_get (vat_main_t * vam)
16548 unformat_input_t *i = vam->input;
16549 vl_api_one_adjacencies_get_t *mp;
16554 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16556 if (unformat (i, "vni %d", &vni))
16562 errmsg ("parse error '%U'", format_unformat_error, i);
16569 errmsg ("vni not set!");
16573 if (!vam->json_output)
16575 print (vam->ofp, "%s %40s", "leid", "reid");
16578 M (ONE_ADJACENCIES_GET, mp);
16579 mp->vni = clib_host_to_net_u32 (vni);
16584 /* Wait for a reply... */
16589 #define api_lisp_adjacencies_get api_one_adjacencies_get
16592 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
16594 unformat_input_t *i = vam->input;
16595 vl_api_gpe_native_fwd_rpaths_get_t *mp;
16597 u8 ip_family_set = 0, is_ip4 = 1;
16599 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16601 if (unformat (i, "ip4"))
16606 else if (unformat (i, "ip6"))
16613 errmsg ("parse error '%U'", format_unformat_error, i);
16618 if (!ip_family_set)
16620 errmsg ("ip family not set!");
16624 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
16625 mp->is_ip4 = is_ip4;
16630 /* Wait for a reply... */
16636 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
16638 vl_api_gpe_fwd_entry_vnis_get_t *mp;
16641 if (!vam->json_output)
16643 print (vam->ofp, "VNIs");
16646 M (GPE_FWD_ENTRY_VNIS_GET, mp);
16651 /* Wait for a reply... */
16657 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
16659 unformat_input_t *i = vam->input;
16660 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
16662 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
16663 struct in_addr ip4;
16664 struct in6_addr ip6;
16665 u32 table_id = 0, nh_sw_if_index = ~0;
16667 clib_memset (&ip4, 0, sizeof (ip4));
16668 clib_memset (&ip6, 0, sizeof (ip6));
16670 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16672 if (unformat (i, "del"))
16674 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
16675 api_unformat_sw_if_index, vam, &nh_sw_if_index))
16680 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
16681 api_unformat_sw_if_index, vam, &nh_sw_if_index))
16686 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
16690 nh_sw_if_index = ~0;
16692 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
16696 nh_sw_if_index = ~0;
16698 else if (unformat (i, "table %d", &table_id))
16702 errmsg ("parse error '%U'", format_unformat_error, i);
16709 errmsg ("nh addr not set!");
16713 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
16714 mp->is_add = is_add;
16715 mp->table_id = clib_host_to_net_u32 (table_id);
16716 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
16717 mp->nh_addr.af = is_ip4 ? 0 : 1;
16719 clib_memcpy (mp->nh_addr.un.ip4, &ip4, sizeof (ip4));
16721 clib_memcpy (mp->nh_addr.un.ip6, &ip6, sizeof (ip6));
16726 /* Wait for a reply... */
16732 api_one_map_server_dump (vat_main_t * vam)
16734 vl_api_one_map_server_dump_t *mp;
16735 vl_api_control_ping_t *mp_ping;
16738 if (!vam->json_output)
16740 print (vam->ofp, "%=20s", "Map server");
16743 M (ONE_MAP_SERVER_DUMP, mp);
16747 /* Use a control ping for synchronization */
16748 MPING (CONTROL_PING, mp_ping);
16751 /* Wait for a reply... */
16756 #define api_lisp_map_server_dump api_one_map_server_dump
16759 api_one_map_resolver_dump (vat_main_t * vam)
16761 vl_api_one_map_resolver_dump_t *mp;
16762 vl_api_control_ping_t *mp_ping;
16765 if (!vam->json_output)
16767 print (vam->ofp, "%=20s", "Map resolver");
16770 M (ONE_MAP_RESOLVER_DUMP, mp);
16774 /* Use a control ping for synchronization */
16775 MPING (CONTROL_PING, mp_ping);
16778 /* Wait for a reply... */
16783 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
16786 api_one_stats_flush (vat_main_t * vam)
16788 vl_api_one_stats_flush_t *mp;
16791 M (ONE_STATS_FLUSH, mp);
16798 api_one_stats_dump (vat_main_t * vam)
16800 vl_api_one_stats_dump_t *mp;
16801 vl_api_control_ping_t *mp_ping;
16804 M (ONE_STATS_DUMP, mp);
16808 /* Use a control ping for synchronization */
16809 MPING (CONTROL_PING, mp_ping);
16812 /* Wait for a reply... */
16818 api_show_one_status (vat_main_t * vam)
16820 vl_api_show_one_status_t *mp;
16823 if (!vam->json_output)
16825 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
16828 M (SHOW_ONE_STATUS, mp);
16831 /* Wait for a reply... */
16836 #define api_show_lisp_status api_show_one_status
16839 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
16841 vl_api_gpe_fwd_entry_path_dump_t *mp;
16842 vl_api_control_ping_t *mp_ping;
16843 unformat_input_t *i = vam->input;
16844 u32 fwd_entry_index = ~0;
16847 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16849 if (unformat (i, "index %d", &fwd_entry_index))
16855 if (~0 == fwd_entry_index)
16857 errmsg ("no index specified!");
16861 if (!vam->json_output)
16863 print (vam->ofp, "first line");
16866 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
16870 /* Use a control ping for synchronization */
16871 MPING (CONTROL_PING, mp_ping);
16874 /* Wait for a reply... */
16880 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
16882 vl_api_one_get_map_request_itr_rlocs_t *mp;
16885 if (!vam->json_output)
16887 print (vam->ofp, "%=20s", "itr-rlocs:");
16890 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
16893 /* Wait for a reply... */
16898 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
16901 api_af_packet_create (vat_main_t * vam)
16903 unformat_input_t *i = vam->input;
16904 vl_api_af_packet_create_t *mp;
16905 u8 *host_if_name = 0;
16907 u8 random_hw_addr = 1;
16910 clib_memset (hw_addr, 0, sizeof (hw_addr));
16912 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16914 if (unformat (i, "name %s", &host_if_name))
16915 vec_add1 (host_if_name, 0);
16916 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
16917 random_hw_addr = 0;
16922 if (!vec_len (host_if_name))
16924 errmsg ("host-interface name must be specified");
16928 if (vec_len (host_if_name) > 64)
16930 errmsg ("host-interface name too long");
16934 M (AF_PACKET_CREATE, mp);
16936 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
16937 clib_memcpy (mp->hw_addr, hw_addr, 6);
16938 mp->use_random_hw_addr = random_hw_addr;
16939 vec_free (host_if_name);
16947 fprintf (vam->ofp ? vam->ofp : stderr,
16948 " new sw_if_index = %d\n", vam->sw_if_index);
16955 api_af_packet_delete (vat_main_t * vam)
16957 unformat_input_t *i = vam->input;
16958 vl_api_af_packet_delete_t *mp;
16959 u8 *host_if_name = 0;
16962 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16964 if (unformat (i, "name %s", &host_if_name))
16965 vec_add1 (host_if_name, 0);
16970 if (!vec_len (host_if_name))
16972 errmsg ("host-interface name must be specified");
16976 if (vec_len (host_if_name) > 64)
16978 errmsg ("host-interface name too long");
16982 M (AF_PACKET_DELETE, mp);
16984 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
16985 vec_free (host_if_name);
16992 static void vl_api_af_packet_details_t_handler
16993 (vl_api_af_packet_details_t * mp)
16995 vat_main_t *vam = &vat_main;
16997 print (vam->ofp, "%-16s %d",
16998 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
17001 static void vl_api_af_packet_details_t_handler_json
17002 (vl_api_af_packet_details_t * mp)
17004 vat_main_t *vam = &vat_main;
17005 vat_json_node_t *node = NULL;
17007 if (VAT_JSON_ARRAY != vam->json_tree.type)
17009 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17010 vat_json_init_array (&vam->json_tree);
17012 node = vat_json_array_add (&vam->json_tree);
17014 vat_json_init_object (node);
17015 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
17016 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
17020 api_af_packet_dump (vat_main_t * vam)
17022 vl_api_af_packet_dump_t *mp;
17023 vl_api_control_ping_t *mp_ping;
17026 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
17027 /* Get list of tap interfaces */
17028 M (AF_PACKET_DUMP, mp);
17031 /* Use a control ping for synchronization */
17032 MPING (CONTROL_PING, mp_ping);
17040 api_policer_add_del (vat_main_t * vam)
17042 unformat_input_t *i = vam->input;
17043 vl_api_policer_add_del_t *mp;
17053 u8 color_aware = 0;
17054 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
17057 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
17058 conform_action.dscp = 0;
17059 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
17060 exceed_action.dscp = 0;
17061 violate_action.action_type = SSE2_QOS_ACTION_DROP;
17062 violate_action.dscp = 0;
17064 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17066 if (unformat (i, "del"))
17068 else if (unformat (i, "name %s", &name))
17069 vec_add1 (name, 0);
17070 else if (unformat (i, "cir %u", &cir))
17072 else if (unformat (i, "eir %u", &eir))
17074 else if (unformat (i, "cb %u", &cb))
17076 else if (unformat (i, "eb %u", &eb))
17078 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
17081 else if (unformat (i, "round_type %U", unformat_policer_round_type,
17084 else if (unformat (i, "type %U", unformat_policer_type, &type))
17086 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
17089 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
17092 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
17095 else if (unformat (i, "color-aware"))
17101 if (!vec_len (name))
17103 errmsg ("policer name must be specified");
17107 if (vec_len (name) > 64)
17109 errmsg ("policer name too long");
17113 M (POLICER_ADD_DEL, mp);
17115 clib_memcpy (mp->name, name, vec_len (name));
17117 mp->is_add = is_add;
17118 mp->cir = ntohl (cir);
17119 mp->eir = ntohl (eir);
17120 mp->cb = clib_net_to_host_u64 (cb);
17121 mp->eb = clib_net_to_host_u64 (eb);
17122 mp->rate_type = rate_type;
17123 mp->round_type = round_type;
17125 mp->conform_action.type = conform_action.action_type;
17126 mp->conform_action.dscp = conform_action.dscp;
17127 mp->exceed_action.type = exceed_action.action_type;
17128 mp->exceed_action.dscp = exceed_action.dscp;
17129 mp->violate_action.type = violate_action.action_type;
17130 mp->violate_action.dscp = violate_action.dscp;
17131 mp->color_aware = color_aware;
17139 api_policer_dump (vat_main_t * vam)
17141 unformat_input_t *i = vam->input;
17142 vl_api_policer_dump_t *mp;
17143 vl_api_control_ping_t *mp_ping;
17144 u8 *match_name = 0;
17145 u8 match_name_valid = 0;
17148 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17150 if (unformat (i, "name %s", &match_name))
17152 vec_add1 (match_name, 0);
17153 match_name_valid = 1;
17159 M (POLICER_DUMP, mp);
17160 mp->match_name_valid = match_name_valid;
17161 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
17162 vec_free (match_name);
17166 /* Use a control ping for synchronization */
17167 MPING (CONTROL_PING, mp_ping);
17170 /* Wait for a reply... */
17176 api_policer_classify_set_interface (vat_main_t * vam)
17178 unformat_input_t *i = vam->input;
17179 vl_api_policer_classify_set_interface_t *mp;
17181 int sw_if_index_set;
17182 u32 ip4_table_index = ~0;
17183 u32 ip6_table_index = ~0;
17184 u32 l2_table_index = ~0;
17188 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17190 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17191 sw_if_index_set = 1;
17192 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17193 sw_if_index_set = 1;
17194 else if (unformat (i, "del"))
17196 else if (unformat (i, "ip4-table %d", &ip4_table_index))
17198 else if (unformat (i, "ip6-table %d", &ip6_table_index))
17200 else if (unformat (i, "l2-table %d", &l2_table_index))
17204 clib_warning ("parse error '%U'", format_unformat_error, i);
17209 if (sw_if_index_set == 0)
17211 errmsg ("missing interface name or sw_if_index");
17215 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
17217 mp->sw_if_index = ntohl (sw_if_index);
17218 mp->ip4_table_index = ntohl (ip4_table_index);
17219 mp->ip6_table_index = ntohl (ip6_table_index);
17220 mp->l2_table_index = ntohl (l2_table_index);
17221 mp->is_add = is_add;
17229 api_policer_classify_dump (vat_main_t * vam)
17231 unformat_input_t *i = vam->input;
17232 vl_api_policer_classify_dump_t *mp;
17233 vl_api_control_ping_t *mp_ping;
17234 u8 type = POLICER_CLASSIFY_N_TABLES;
17237 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
17241 errmsg ("classify table type must be specified");
17245 if (!vam->json_output)
17247 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
17250 M (POLICER_CLASSIFY_DUMP, mp);
17255 /* Use a control ping for synchronization */
17256 MPING (CONTROL_PING, mp_ping);
17259 /* Wait for a reply... */
17265 format_fib_api_path_nh_proto (u8 * s, va_list * args)
17267 vl_api_fib_path_nh_proto_t proto =
17268 va_arg (*args, vl_api_fib_path_nh_proto_t);
17272 case FIB_API_PATH_NH_PROTO_IP4:
17273 s = format (s, "ip4");
17275 case FIB_API_PATH_NH_PROTO_IP6:
17276 s = format (s, "ip6");
17278 case FIB_API_PATH_NH_PROTO_MPLS:
17279 s = format (s, "mpls");
17281 case FIB_API_PATH_NH_PROTO_BIER:
17282 s = format (s, "bier");
17284 case FIB_API_PATH_NH_PROTO_ETHERNET:
17285 s = format (s, "ethernet");
17293 format_vl_api_ip_address_union (u8 * s, va_list * args)
17295 vl_api_address_family_t af = va_arg (*args, int);
17296 const vl_api_address_union_t *u = va_arg (*args, vl_api_address_union_t *);
17301 s = format (s, "%U", format_ip4_address, u->ip4);
17304 s = format (s, "%U", format_ip6_address, u->ip6);
17311 format_vl_api_fib_path_type (u8 * s, va_list * args)
17313 vl_api_fib_path_type_t t = va_arg (*args, vl_api_fib_path_type_t);
17317 case FIB_API_PATH_TYPE_NORMAL:
17318 s = format (s, "normal");
17320 case FIB_API_PATH_TYPE_LOCAL:
17321 s = format (s, "local");
17323 case FIB_API_PATH_TYPE_DROP:
17324 s = format (s, "drop");
17326 case FIB_API_PATH_TYPE_UDP_ENCAP:
17327 s = format (s, "udp-encap");
17329 case FIB_API_PATH_TYPE_BIER_IMP:
17330 s = format (s, "bier-imp");
17332 case FIB_API_PATH_TYPE_ICMP_UNREACH:
17333 s = format (s, "unreach");
17335 case FIB_API_PATH_TYPE_ICMP_PROHIBIT:
17336 s = format (s, "prohibit");
17338 case FIB_API_PATH_TYPE_SOURCE_LOOKUP:
17339 s = format (s, "src-lookup");
17341 case FIB_API_PATH_TYPE_DVR:
17342 s = format (s, "dvr");
17344 case FIB_API_PATH_TYPE_INTERFACE_RX:
17345 s = format (s, "interface-rx");
17347 case FIB_API_PATH_TYPE_CLASSIFY:
17348 s = format (s, "classify");
17356 vl_api_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
17359 " weight %d, sw_if_index %d, type %U, afi %U, next_hop %U",
17360 ntohl (fp->weight), ntohl (fp->sw_if_index),
17361 format_vl_api_fib_path_type, fp->type,
17362 format_fib_api_path_nh_proto, fp->proto,
17363 format_vl_api_ip_address_union, &fp->nh.address);
17367 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
17368 vl_api_fib_path_t * fp)
17370 struct in_addr ip4;
17371 struct in6_addr ip6;
17373 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
17374 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
17375 vat_json_object_add_uint (node, "type", fp->type);
17376 vat_json_object_add_uint (node, "next_hop_proto", fp->proto);
17377 if (fp->proto == FIB_API_PATH_NH_PROTO_IP4)
17379 clib_memcpy (&ip4, &fp->nh.address.ip4, sizeof (ip4));
17380 vat_json_object_add_ip4 (node, "next_hop", ip4);
17382 else if (fp->proto == FIB_API_PATH_NH_PROTO_IP6)
17384 clib_memcpy (&ip6, &fp->nh.address.ip6, sizeof (ip6));
17385 vat_json_object_add_ip6 (node, "next_hop", ip6);
17390 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
17392 vat_main_t *vam = &vat_main;
17393 int count = ntohl (mp->mt_tunnel.mt_n_paths);
17394 vl_api_fib_path_t *fp;
17397 print (vam->ofp, "sw_if_index %d via:",
17398 ntohl (mp->mt_tunnel.mt_sw_if_index));
17399 fp = mp->mt_tunnel.mt_paths;
17400 for (i = 0; i < count; i++)
17402 vl_api_fib_path_print (vam, fp);
17406 print (vam->ofp, "");
17409 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
17410 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
17413 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
17415 vat_main_t *vam = &vat_main;
17416 vat_json_node_t *node = NULL;
17417 int count = ntohl (mp->mt_tunnel.mt_n_paths);
17418 vl_api_fib_path_t *fp;
17421 if (VAT_JSON_ARRAY != vam->json_tree.type)
17423 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17424 vat_json_init_array (&vam->json_tree);
17426 node = vat_json_array_add (&vam->json_tree);
17428 vat_json_init_object (node);
17429 vat_json_object_add_uint (node, "sw_if_index",
17430 ntohl (mp->mt_tunnel.mt_sw_if_index));
17432 vat_json_object_add_uint (node, "l2_only", mp->mt_tunnel.mt_l2_only);
17434 fp = mp->mt_tunnel.mt_paths;
17435 for (i = 0; i < count; i++)
17437 vl_api_mpls_fib_path_json_print (node, fp);
17443 api_mpls_tunnel_dump (vat_main_t * vam)
17445 vl_api_mpls_tunnel_dump_t *mp;
17446 vl_api_control_ping_t *mp_ping;
17449 M (MPLS_TUNNEL_DUMP, mp);
17453 /* Use a control ping for synchronization */
17454 MPING (CONTROL_PING, mp_ping);
17461 #define vl_api_mpls_table_details_t_endian vl_noop_handler
17462 #define vl_api_mpls_table_details_t_print vl_noop_handler
17466 vl_api_mpls_table_details_t_handler (vl_api_mpls_table_details_t * mp)
17468 vat_main_t *vam = &vat_main;
17470 print (vam->ofp, "table-id %d,", ntohl (mp->mt_table.mt_table_id));
17473 static void vl_api_mpls_table_details_t_handler_json
17474 (vl_api_mpls_table_details_t * mp)
17476 vat_main_t *vam = &vat_main;
17477 vat_json_node_t *node = NULL;
17479 if (VAT_JSON_ARRAY != vam->json_tree.type)
17481 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17482 vat_json_init_array (&vam->json_tree);
17484 node = vat_json_array_add (&vam->json_tree);
17486 vat_json_init_object (node);
17487 vat_json_object_add_uint (node, "table", ntohl (mp->mt_table.mt_table_id));
17491 api_mpls_table_dump (vat_main_t * vam)
17493 vl_api_mpls_table_dump_t *mp;
17494 vl_api_control_ping_t *mp_ping;
17497 M (MPLS_TABLE_DUMP, mp);
17500 /* Use a control ping for synchronization */
17501 MPING (CONTROL_PING, mp_ping);
17508 #define vl_api_mpls_route_details_t_endian vl_noop_handler
17509 #define vl_api_mpls_route_details_t_print vl_noop_handler
17512 vl_api_mpls_route_details_t_handler (vl_api_mpls_route_details_t * mp)
17514 vat_main_t *vam = &vat_main;
17515 int count = (int) clib_net_to_host_u32 (mp->mr_route.mr_n_paths);
17516 vl_api_fib_path_t *fp;
17520 "table-id %d, label %u, ess_bit %u",
17521 ntohl (mp->mr_route.mr_table_id),
17522 ntohl (mp->mr_route.mr_label), mp->mr_route.mr_eos);
17523 fp = mp->mr_route.mr_paths;
17524 for (i = 0; i < count; i++)
17526 vl_api_fib_path_print (vam, fp);
17531 static void vl_api_mpls_route_details_t_handler_json
17532 (vl_api_mpls_route_details_t * mp)
17534 vat_main_t *vam = &vat_main;
17535 int count = (int) clib_host_to_net_u32 (mp->mr_route.mr_n_paths);
17536 vat_json_node_t *node = NULL;
17537 vl_api_fib_path_t *fp;
17540 if (VAT_JSON_ARRAY != vam->json_tree.type)
17542 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17543 vat_json_init_array (&vam->json_tree);
17545 node = vat_json_array_add (&vam->json_tree);
17547 vat_json_init_object (node);
17548 vat_json_object_add_uint (node, "table", ntohl (mp->mr_route.mr_table_id));
17549 vat_json_object_add_uint (node, "s_bit", mp->mr_route.mr_eos);
17550 vat_json_object_add_uint (node, "label", ntohl (mp->mr_route.mr_label));
17551 vat_json_object_add_uint (node, "path_count", count);
17552 fp = mp->mr_route.mr_paths;
17553 for (i = 0; i < count; i++)
17555 vl_api_mpls_fib_path_json_print (node, fp);
17561 api_mpls_route_dump (vat_main_t * vam)
17563 unformat_input_t *input = vam->input;
17564 vl_api_mpls_route_dump_t *mp;
17565 vl_api_control_ping_t *mp_ping;
17569 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17571 if (unformat (input, "table_id %d", &table_id))
17576 if (table_id == ~0)
17578 errmsg ("missing table id");
17582 M (MPLS_ROUTE_DUMP, mp);
17584 mp->table.mt_table_id = ntohl (table_id);
17587 /* Use a control ping for synchronization */
17588 MPING (CONTROL_PING, mp_ping);
17595 #define vl_api_ip_table_details_t_endian vl_noop_handler
17596 #define vl_api_ip_table_details_t_print vl_noop_handler
17599 vl_api_ip_table_details_t_handler (vl_api_ip_table_details_t * mp)
17601 vat_main_t *vam = &vat_main;
17604 "%s; table-id %d, prefix %U/%d",
17605 mp->table.name, ntohl (mp->table.table_id));
17609 static void vl_api_ip_table_details_t_handler_json
17610 (vl_api_ip_table_details_t * mp)
17612 vat_main_t *vam = &vat_main;
17613 vat_json_node_t *node = NULL;
17615 if (VAT_JSON_ARRAY != vam->json_tree.type)
17617 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17618 vat_json_init_array (&vam->json_tree);
17620 node = vat_json_array_add (&vam->json_tree);
17622 vat_json_init_object (node);
17623 vat_json_object_add_uint (node, "table", ntohl (mp->table.table_id));
17627 api_ip_table_dump (vat_main_t * vam)
17629 vl_api_ip_table_dump_t *mp;
17630 vl_api_control_ping_t *mp_ping;
17633 M (IP_TABLE_DUMP, mp);
17636 /* Use a control ping for synchronization */
17637 MPING (CONTROL_PING, mp_ping);
17645 api_ip_mtable_dump (vat_main_t * vam)
17647 vl_api_ip_mtable_dump_t *mp;
17648 vl_api_control_ping_t *mp_ping;
17651 M (IP_MTABLE_DUMP, mp);
17654 /* Use a control ping for synchronization */
17655 MPING (CONTROL_PING, mp_ping);
17663 api_ip_mroute_dump (vat_main_t * vam)
17665 unformat_input_t *input = vam->input;
17666 vl_api_control_ping_t *mp_ping;
17667 vl_api_ip_mroute_dump_t *mp;
17672 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17674 if (unformat (input, "table_id %d", &table_id))
17676 else if (unformat (input, "ip6"))
17678 else if (unformat (input, "ip4"))
17683 if (table_id == ~0)
17685 errmsg ("missing table id");
17689 M (IP_MROUTE_DUMP, mp);
17690 mp->table.table_id = table_id;
17691 mp->table.is_ip6 = is_ip6;
17694 /* Use a control ping for synchronization */
17695 MPING (CONTROL_PING, mp_ping);
17702 #define vl_api_ip_route_details_t_endian vl_noop_handler
17703 #define vl_api_ip_route_details_t_print vl_noop_handler
17706 vl_api_ip_route_details_t_handler (vl_api_ip_route_details_t * mp)
17708 vat_main_t *vam = &vat_main;
17709 u8 count = mp->route.n_paths;
17710 vl_api_fib_path_t *fp;
17714 "table-id %d, prefix %U/%d",
17715 ntohl (mp->route.table_id),
17716 format_ip46_address, mp->route.prefix.address, mp->route.prefix.len);
17717 for (i = 0; i < count; i++)
17719 fp = &mp->route.paths[i];
17721 vl_api_fib_path_print (vam, fp);
17726 static void vl_api_ip_route_details_t_handler_json
17727 (vl_api_ip_route_details_t * mp)
17729 vat_main_t *vam = &vat_main;
17730 u8 count = mp->route.n_paths;
17731 vat_json_node_t *node = NULL;
17732 struct in_addr ip4;
17733 struct in6_addr ip6;
17734 vl_api_fib_path_t *fp;
17737 if (VAT_JSON_ARRAY != vam->json_tree.type)
17739 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17740 vat_json_init_array (&vam->json_tree);
17742 node = vat_json_array_add (&vam->json_tree);
17744 vat_json_init_object (node);
17745 vat_json_object_add_uint (node, "table", ntohl (mp->route.table_id));
17746 if (ADDRESS_IP6 == mp->route.prefix.address.af)
17748 clib_memcpy (&ip6, &mp->route.prefix.address.un.ip6, sizeof (ip6));
17749 vat_json_object_add_ip6 (node, "prefix", ip6);
17753 clib_memcpy (&ip4, &mp->route.prefix.address.un.ip4, sizeof (ip4));
17754 vat_json_object_add_ip4 (node, "prefix", ip4);
17756 vat_json_object_add_uint (node, "mask_length", mp->route.prefix.len);
17757 vat_json_object_add_uint (node, "path_count", count);
17758 for (i = 0; i < count; i++)
17760 fp = &mp->route.paths[i];
17761 vl_api_mpls_fib_path_json_print (node, fp);
17766 api_ip_route_dump (vat_main_t * vam)
17768 unformat_input_t *input = vam->input;
17769 vl_api_ip_route_dump_t *mp;
17770 vl_api_control_ping_t *mp_ping;
17776 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17778 if (unformat (input, "table_id %d", &table_id))
17780 else if (unformat (input, "ip6"))
17782 else if (unformat (input, "ip4"))
17787 if (table_id == ~0)
17789 errmsg ("missing table id");
17793 M (IP_ROUTE_DUMP, mp);
17795 mp->table.table_id = table_id;
17796 mp->table.is_ip6 = is_ip6;
17800 /* Use a control ping for synchronization */
17801 MPING (CONTROL_PING, mp_ping);
17809 api_classify_table_ids (vat_main_t * vam)
17811 vl_api_classify_table_ids_t *mp;
17814 /* Construct the API message */
17815 M (CLASSIFY_TABLE_IDS, mp);
17824 api_classify_table_by_interface (vat_main_t * vam)
17826 unformat_input_t *input = vam->input;
17827 vl_api_classify_table_by_interface_t *mp;
17829 u32 sw_if_index = ~0;
17831 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17833 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17835 else if (unformat (input, "sw_if_index %d", &sw_if_index))
17840 if (sw_if_index == ~0)
17842 errmsg ("missing interface name or sw_if_index");
17846 /* Construct the API message */
17847 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
17849 mp->sw_if_index = ntohl (sw_if_index);
17857 api_classify_table_info (vat_main_t * vam)
17859 unformat_input_t *input = vam->input;
17860 vl_api_classify_table_info_t *mp;
17864 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17866 if (unformat (input, "table_id %d", &table_id))
17871 if (table_id == ~0)
17873 errmsg ("missing table id");
17877 /* Construct the API message */
17878 M (CLASSIFY_TABLE_INFO, mp);
17880 mp->table_id = ntohl (table_id);
17888 api_classify_session_dump (vat_main_t * vam)
17890 unformat_input_t *input = vam->input;
17891 vl_api_classify_session_dump_t *mp;
17892 vl_api_control_ping_t *mp_ping;
17896 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17898 if (unformat (input, "table_id %d", &table_id))
17903 if (table_id == ~0)
17905 errmsg ("missing table id");
17909 /* Construct the API message */
17910 M (CLASSIFY_SESSION_DUMP, mp);
17912 mp->table_id = ntohl (table_id);
17915 /* Use a control ping for synchronization */
17916 MPING (CONTROL_PING, mp_ping);
17924 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
17926 vat_main_t *vam = &vat_main;
17928 print (vam->ofp, "collector_address %U, collector_port %d, "
17929 "src_address %U, vrf_id %d, path_mtu %u, "
17930 "template_interval %u, udp_checksum %d",
17931 format_ip4_address, mp->collector_address,
17932 ntohs (mp->collector_port),
17933 format_ip4_address, mp->src_address,
17934 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
17935 ntohl (mp->template_interval), mp->udp_checksum);
17938 vam->result_ready = 1;
17942 vl_api_ipfix_exporter_details_t_handler_json
17943 (vl_api_ipfix_exporter_details_t * mp)
17945 vat_main_t *vam = &vat_main;
17946 vat_json_node_t node;
17947 struct in_addr collector_address;
17948 struct in_addr src_address;
17950 vat_json_init_object (&node);
17951 clib_memcpy (&collector_address, &mp->collector_address,
17952 sizeof (collector_address));
17953 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
17954 vat_json_object_add_uint (&node, "collector_port",
17955 ntohs (mp->collector_port));
17956 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
17957 vat_json_object_add_ip4 (&node, "src_address", src_address);
17958 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
17959 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
17960 vat_json_object_add_uint (&node, "template_interval",
17961 ntohl (mp->template_interval));
17962 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
17964 vat_json_print (vam->ofp, &node);
17965 vat_json_free (&node);
17967 vam->result_ready = 1;
17971 api_ipfix_exporter_dump (vat_main_t * vam)
17973 vl_api_ipfix_exporter_dump_t *mp;
17976 /* Construct the API message */
17977 M (IPFIX_EXPORTER_DUMP, mp);
17986 api_ipfix_classify_stream_dump (vat_main_t * vam)
17988 vl_api_ipfix_classify_stream_dump_t *mp;
17991 /* Construct the API message */
17992 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
18003 vl_api_ipfix_classify_stream_details_t_handler
18004 (vl_api_ipfix_classify_stream_details_t * mp)
18006 vat_main_t *vam = &vat_main;
18007 print (vam->ofp, "domain_id %d, src_port %d",
18008 ntohl (mp->domain_id), ntohs (mp->src_port));
18010 vam->result_ready = 1;
18014 vl_api_ipfix_classify_stream_details_t_handler_json
18015 (vl_api_ipfix_classify_stream_details_t * mp)
18017 vat_main_t *vam = &vat_main;
18018 vat_json_node_t node;
18020 vat_json_init_object (&node);
18021 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
18022 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
18024 vat_json_print (vam->ofp, &node);
18025 vat_json_free (&node);
18027 vam->result_ready = 1;
18031 api_ipfix_classify_table_dump (vat_main_t * vam)
18033 vl_api_ipfix_classify_table_dump_t *mp;
18034 vl_api_control_ping_t *mp_ping;
18037 if (!vam->json_output)
18039 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
18040 "transport_protocol");
18043 /* Construct the API message */
18044 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
18049 /* Use a control ping for synchronization */
18050 MPING (CONTROL_PING, mp_ping);
18058 vl_api_ipfix_classify_table_details_t_handler
18059 (vl_api_ipfix_classify_table_details_t * mp)
18061 vat_main_t *vam = &vat_main;
18062 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
18063 mp->transport_protocol);
18067 vl_api_ipfix_classify_table_details_t_handler_json
18068 (vl_api_ipfix_classify_table_details_t * mp)
18070 vat_json_node_t *node = NULL;
18071 vat_main_t *vam = &vat_main;
18073 if (VAT_JSON_ARRAY != vam->json_tree.type)
18075 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18076 vat_json_init_array (&vam->json_tree);
18079 node = vat_json_array_add (&vam->json_tree);
18080 vat_json_init_object (node);
18082 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
18083 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
18084 vat_json_object_add_uint (node, "transport_protocol",
18085 mp->transport_protocol);
18089 api_sw_interface_span_enable_disable (vat_main_t * vam)
18091 unformat_input_t *i = vam->input;
18092 vl_api_sw_interface_span_enable_disable_t *mp;
18093 u32 src_sw_if_index = ~0;
18094 u32 dst_sw_if_index = ~0;
18099 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18102 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
18104 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
18108 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
18110 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
18112 else if (unformat (i, "disable"))
18114 else if (unformat (i, "rx"))
18116 else if (unformat (i, "tx"))
18118 else if (unformat (i, "both"))
18120 else if (unformat (i, "l2"))
18126 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
18128 mp->sw_if_index_from = htonl (src_sw_if_index);
18129 mp->sw_if_index_to = htonl (dst_sw_if_index);
18139 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
18142 vat_main_t *vam = &vat_main;
18143 u8 *sw_if_from_name = 0;
18144 u8 *sw_if_to_name = 0;
18145 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
18146 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
18147 char *states[] = { "none", "rx", "tx", "both" };
18151 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
18153 if ((u32) p->value[0] == sw_if_index_from)
18155 sw_if_from_name = (u8 *)(p->key);
18159 if ((u32) p->value[0] == sw_if_index_to)
18161 sw_if_to_name = (u8 *)(p->key);
18162 if (sw_if_from_name)
18167 print (vam->ofp, "%20s => %20s (%s) %s",
18168 sw_if_from_name, sw_if_to_name, states[mp->state],
18169 mp->is_l2 ? "l2" : "device");
18173 vl_api_sw_interface_span_details_t_handler_json
18174 (vl_api_sw_interface_span_details_t * mp)
18176 vat_main_t *vam = &vat_main;
18177 vat_json_node_t *node = NULL;
18178 u8 *sw_if_from_name = 0;
18179 u8 *sw_if_to_name = 0;
18180 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
18181 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
18185 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
18187 if ((u32) p->value[0] == sw_if_index_from)
18189 sw_if_from_name = (u8 *)(p->key);
18193 if ((u32) p->value[0] == sw_if_index_to)
18195 sw_if_to_name = (u8 *)(p->key);
18196 if (sw_if_from_name)
18202 if (VAT_JSON_ARRAY != vam->json_tree.type)
18204 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18205 vat_json_init_array (&vam->json_tree);
18207 node = vat_json_array_add (&vam->json_tree);
18209 vat_json_init_object (node);
18210 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
18211 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
18212 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
18213 if (0 != sw_if_to_name)
18215 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
18217 vat_json_object_add_uint (node, "state", mp->state);
18218 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
18222 api_sw_interface_span_dump (vat_main_t * vam)
18224 unformat_input_t *input = vam->input;
18225 vl_api_sw_interface_span_dump_t *mp;
18226 vl_api_control_ping_t *mp_ping;
18230 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18232 if (unformat (input, "l2"))
18238 M (SW_INTERFACE_SPAN_DUMP, mp);
18242 /* Use a control ping for synchronization */
18243 MPING (CONTROL_PING, mp_ping);
18251 api_pg_create_interface (vat_main_t * vam)
18253 unformat_input_t *input = vam->input;
18254 vl_api_pg_create_interface_t *mp;
18256 u32 if_id = ~0, gso_size = 0;
18257 u8 gso_enabled = 0;
18259 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18261 if (unformat (input, "if_id %d", &if_id))
18263 else if (unformat (input, "gso-enabled"))
18266 if (unformat (input, "gso-size %u", &gso_size))
18270 errmsg ("missing gso-size");
18279 errmsg ("missing pg interface index");
18283 /* Construct the API message */
18284 M (PG_CREATE_INTERFACE, mp);
18286 mp->interface_id = ntohl (if_id);
18287 mp->gso_enabled = gso_enabled;
18295 api_pg_capture (vat_main_t * vam)
18297 unformat_input_t *input = vam->input;
18298 vl_api_pg_capture_t *mp;
18303 u8 pcap_file_set = 0;
18306 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18308 if (unformat (input, "if_id %d", &if_id))
18310 else if (unformat (input, "pcap %s", &pcap_file))
18312 else if (unformat (input, "count %d", &count))
18314 else if (unformat (input, "disable"))
18321 errmsg ("missing pg interface index");
18324 if (pcap_file_set > 0)
18326 if (vec_len (pcap_file) > 255)
18328 errmsg ("pcap file name is too long");
18333 /* Construct the API message */
18334 M (PG_CAPTURE, mp);
18336 mp->interface_id = ntohl (if_id);
18337 mp->is_enabled = enable;
18338 mp->count = ntohl (count);
18339 if (pcap_file_set != 0)
18341 vl_api_vec_to_api_string (pcap_file, &mp->pcap_file_name);
18343 vec_free (pcap_file);
18351 api_pg_enable_disable (vat_main_t * vam)
18353 unformat_input_t *input = vam->input;
18354 vl_api_pg_enable_disable_t *mp;
18357 u8 stream_name_set = 0;
18358 u8 *stream_name = 0;
18360 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18362 if (unformat (input, "stream %s", &stream_name))
18363 stream_name_set = 1;
18364 else if (unformat (input, "disable"))
18370 if (stream_name_set > 0)
18372 if (vec_len (stream_name) > 255)
18374 errmsg ("stream name too long");
18379 /* Construct the API message */
18380 M (PG_ENABLE_DISABLE, mp);
18382 mp->is_enabled = enable;
18383 if (stream_name_set != 0)
18385 vl_api_vec_to_api_string (stream_name, &mp->stream_name);
18387 vec_free (stream_name);
18395 api_pg_interface_enable_disable_coalesce (vat_main_t * vam)
18397 unformat_input_t *input = vam->input;
18398 vl_api_pg_interface_enable_disable_coalesce_t *mp;
18400 u32 sw_if_index = ~0;
18403 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18405 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18407 else if (unformat (input, "sw_if_index %d", &sw_if_index))
18409 else if (unformat (input, "disable"))
18415 if (sw_if_index == ~0)
18417 errmsg ("Interface required but not specified");
18421 /* Construct the API message */
18422 M (PG_INTERFACE_ENABLE_DISABLE_COALESCE, mp);
18424 mp->coalesce_enabled = enable;
18425 mp->sw_if_index = htonl (sw_if_index);
18433 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
18435 unformat_input_t *input = vam->input;
18436 vl_api_ip_source_and_port_range_check_add_del_t *mp;
18438 u16 *low_ports = 0;
18439 u16 *high_ports = 0;
18442 vl_api_prefix_t prefix;
18449 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18451 if (unformat (input, "%U", unformat_vl_api_prefix, &prefix))
18453 else if (unformat (input, "vrf %d", &vrf_id))
18455 else if (unformat (input, "del"))
18457 else if (unformat (input, "port %d", &tmp))
18459 if (tmp == 0 || tmp > 65535)
18461 errmsg ("port %d out of range", tmp);
18465 this_hi = this_low + 1;
18466 vec_add1 (low_ports, this_low);
18467 vec_add1 (high_ports, this_hi);
18469 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
18471 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
18473 errmsg ("incorrect range parameters");
18477 /* Note: in debug CLI +1 is added to high before
18478 passing to real fn that does "the work"
18479 (ip_source_and_port_range_check_add_del).
18480 This fn is a wrapper around the binary API fn a
18481 control plane will call, which expects this increment
18482 to have occurred. Hence letting the binary API control
18483 plane fn do the increment for consistency between VAT
18484 and other control planes.
18487 vec_add1 (low_ports, this_low);
18488 vec_add1 (high_ports, this_hi);
18494 if (prefix_set == 0)
18496 errmsg ("<address>/<mask> not specified");
18502 errmsg ("VRF ID required, not specified");
18509 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
18513 if (vec_len (low_ports) == 0)
18515 errmsg ("At least one port or port range required");
18519 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
18521 mp->is_add = is_add;
18523 clib_memcpy (&mp->prefix, &prefix, sizeof (prefix));
18525 mp->number_of_ranges = vec_len (low_ports);
18527 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
18528 vec_free (low_ports);
18530 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
18531 vec_free (high_ports);
18533 mp->vrf_id = ntohl (vrf_id);
18541 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
18543 unformat_input_t *input = vam->input;
18544 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
18545 u32 sw_if_index = ~0;
18547 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
18548 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
18552 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18554 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18556 else if (unformat (input, "sw_if_index %d", &sw_if_index))
18558 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
18560 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
18562 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
18564 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
18566 else if (unformat (input, "del"))
18572 if (sw_if_index == ~0)
18574 errmsg ("Interface required but not specified");
18580 errmsg ("VRF ID required but not specified");
18584 if (tcp_out_vrf_id == 0
18585 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
18588 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
18592 /* Construct the API message */
18593 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
18595 mp->sw_if_index = ntohl (sw_if_index);
18596 mp->is_add = is_add;
18597 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
18598 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
18599 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
18600 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
18605 /* Wait for a reply... */
18611 api_set_punt (vat_main_t * vam)
18613 unformat_input_t *i = vam->input;
18614 vl_api_address_family_t af;
18615 vl_api_set_punt_t *mp;
18621 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18623 if (unformat (i, "%U", unformat_vl_api_address_family, &af))
18625 else if (unformat (i, "protocol %d", &protocol))
18627 else if (unformat (i, "port %d", &port))
18629 else if (unformat (i, "del"))
18633 clib_warning ("parse error '%U'", format_unformat_error, i);
18640 mp->is_add = (u8) is_add;
18641 mp->punt.type = PUNT_API_TYPE_L4;
18642 mp->punt.punt.l4.af = af;
18643 mp->punt.punt.l4.protocol = (u8) protocol;
18644 mp->punt.punt.l4.port = htons ((u16) port);
18652 api_delete_subif (vat_main_t * vam)
18654 unformat_input_t *i = vam->input;
18655 vl_api_delete_subif_t *mp;
18656 u32 sw_if_index = ~0;
18659 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18661 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18663 if (unformat (i, "sw_if_index %d", &sw_if_index))
18669 if (sw_if_index == ~0)
18671 errmsg ("missing sw_if_index");
18675 /* Construct the API message */
18676 M (DELETE_SUBIF, mp);
18677 mp->sw_if_index = ntohl (sw_if_index);
18684 #define foreach_pbb_vtr_op \
18685 _("disable", L2_VTR_DISABLED) \
18686 _("pop", L2_VTR_POP_2) \
18687 _("push", L2_VTR_PUSH_2)
18690 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
18692 unformat_input_t *i = vam->input;
18693 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
18694 u32 sw_if_index = ~0, vtr_op = ~0;
18695 u16 outer_tag = ~0;
18696 u8 dmac[6], smac[6];
18697 u8 dmac_set = 0, smac_set = 0;
18703 /* Shut up coverity */
18704 clib_memset (dmac, 0, sizeof (dmac));
18705 clib_memset (smac, 0, sizeof (smac));
18707 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18709 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18711 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18713 else if (unformat (i, "vtr_op %d", &vtr_op))
18715 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
18718 else if (unformat (i, "translate_pbb_stag"))
18720 if (unformat (i, "%d", &tmp))
18722 vtr_op = L2_VTR_TRANSLATE_2_1;
18728 ("translate_pbb_stag operation requires outer tag definition");
18732 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
18734 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
18736 else if (unformat (i, "sid %d", &sid))
18738 else if (unformat (i, "vlanid %d", &tmp))
18742 clib_warning ("parse error '%U'", format_unformat_error, i);
18747 if ((sw_if_index == ~0) || (vtr_op == ~0))
18749 errmsg ("missing sw_if_index or vtr operation");
18752 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
18753 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
18756 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
18760 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
18761 mp->sw_if_index = ntohl (sw_if_index);
18762 mp->vtr_op = ntohl (vtr_op);
18763 mp->outer_tag = ntohs (outer_tag);
18764 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
18765 clib_memcpy (mp->b_smac, smac, sizeof (smac));
18766 mp->b_vlanid = ntohs (vlanid);
18767 mp->i_sid = ntohl (sid);
18775 api_flow_classify_set_interface (vat_main_t * vam)
18777 unformat_input_t *i = vam->input;
18778 vl_api_flow_classify_set_interface_t *mp;
18780 int sw_if_index_set;
18781 u32 ip4_table_index = ~0;
18782 u32 ip6_table_index = ~0;
18786 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18788 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18789 sw_if_index_set = 1;
18790 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18791 sw_if_index_set = 1;
18792 else if (unformat (i, "del"))
18794 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18796 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18800 clib_warning ("parse error '%U'", format_unformat_error, i);
18805 if (sw_if_index_set == 0)
18807 errmsg ("missing interface name or sw_if_index");
18811 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
18813 mp->sw_if_index = ntohl (sw_if_index);
18814 mp->ip4_table_index = ntohl (ip4_table_index);
18815 mp->ip6_table_index = ntohl (ip6_table_index);
18816 mp->is_add = is_add;
18824 api_flow_classify_dump (vat_main_t * vam)
18826 unformat_input_t *i = vam->input;
18827 vl_api_flow_classify_dump_t *mp;
18828 vl_api_control_ping_t *mp_ping;
18829 u8 type = FLOW_CLASSIFY_N_TABLES;
18832 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
18836 errmsg ("classify table type must be specified");
18840 if (!vam->json_output)
18842 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
18845 M (FLOW_CLASSIFY_DUMP, mp);
18850 /* Use a control ping for synchronization */
18851 MPING (CONTROL_PING, mp_ping);
18854 /* Wait for a reply... */
18860 api_feature_enable_disable (vat_main_t * vam)
18862 unformat_input_t *i = vam->input;
18863 vl_api_feature_enable_disable_t *mp;
18865 u8 *feature_name = 0;
18866 u32 sw_if_index = ~0;
18870 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18872 if (unformat (i, "arc_name %s", &arc_name))
18874 else if (unformat (i, "feature_name %s", &feature_name))
18877 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18879 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18881 else if (unformat (i, "disable"))
18889 errmsg ("missing arc name");
18892 if (vec_len (arc_name) > 63)
18894 errmsg ("arc name too long");
18897 if (feature_name == 0)
18899 errmsg ("missing feature name");
18902 if (vec_len (feature_name) > 63)
18904 errmsg ("feature name too long");
18907 if (sw_if_index == ~0)
18909 errmsg ("missing interface name or sw_if_index");
18913 /* Construct the API message */
18914 M (FEATURE_ENABLE_DISABLE, mp);
18915 mp->sw_if_index = ntohl (sw_if_index);
18916 mp->enable = enable;
18917 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
18918 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
18919 vec_free (arc_name);
18920 vec_free (feature_name);
18928 api_feature_gso_enable_disable (vat_main_t * vam)
18930 unformat_input_t *i = vam->input;
18931 vl_api_feature_gso_enable_disable_t *mp;
18932 u32 sw_if_index = ~0;
18936 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18938 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18940 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18942 else if (unformat (i, "enable"))
18944 else if (unformat (i, "disable"))
18950 if (sw_if_index == ~0)
18952 errmsg ("missing interface name or sw_if_index");
18956 /* Construct the API message */
18957 M (FEATURE_GSO_ENABLE_DISABLE, mp);
18958 mp->sw_if_index = ntohl (sw_if_index);
18959 mp->enable_disable = enable;
18967 api_sw_interface_tag_add_del (vat_main_t * vam)
18969 unformat_input_t *i = vam->input;
18970 vl_api_sw_interface_tag_add_del_t *mp;
18971 u32 sw_if_index = ~0;
18976 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18978 if (unformat (i, "tag %s", &tag))
18980 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18982 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18984 else if (unformat (i, "del"))
18990 if (sw_if_index == ~0)
18992 errmsg ("missing interface name or sw_if_index");
18996 if (enable && (tag == 0))
18998 errmsg ("no tag specified");
19002 /* Construct the API message */
19003 M (SW_INTERFACE_TAG_ADD_DEL, mp);
19004 mp->sw_if_index = ntohl (sw_if_index);
19005 mp->is_add = enable;
19007 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
19016 api_sw_interface_add_del_mac_address (vat_main_t * vam)
19018 unformat_input_t *i = vam->input;
19019 vl_api_mac_address_t mac = { 0 };
19020 vl_api_sw_interface_add_del_mac_address_t *mp;
19021 u32 sw_if_index = ~0;
19026 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19028 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19030 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19032 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
19034 else if (unformat (i, "del"))
19040 if (sw_if_index == ~0)
19042 errmsg ("missing interface name or sw_if_index");
19048 errmsg ("missing MAC address");
19052 /* Construct the API message */
19053 M (SW_INTERFACE_ADD_DEL_MAC_ADDRESS, mp);
19054 mp->sw_if_index = ntohl (sw_if_index);
19055 mp->is_add = is_add;
19056 clib_memcpy (&mp->addr, &mac, sizeof (mac));
19063 static void vl_api_l2_xconnect_details_t_handler
19064 (vl_api_l2_xconnect_details_t * mp)
19066 vat_main_t *vam = &vat_main;
19068 print (vam->ofp, "%15d%15d",
19069 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
19072 static void vl_api_l2_xconnect_details_t_handler_json
19073 (vl_api_l2_xconnect_details_t * mp)
19075 vat_main_t *vam = &vat_main;
19076 vat_json_node_t *node = NULL;
19078 if (VAT_JSON_ARRAY != vam->json_tree.type)
19080 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19081 vat_json_init_array (&vam->json_tree);
19083 node = vat_json_array_add (&vam->json_tree);
19085 vat_json_init_object (node);
19086 vat_json_object_add_uint (node, "rx_sw_if_index",
19087 ntohl (mp->rx_sw_if_index));
19088 vat_json_object_add_uint (node, "tx_sw_if_index",
19089 ntohl (mp->tx_sw_if_index));
19093 api_l2_xconnect_dump (vat_main_t * vam)
19095 vl_api_l2_xconnect_dump_t *mp;
19096 vl_api_control_ping_t *mp_ping;
19099 if (!vam->json_output)
19101 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
19104 M (L2_XCONNECT_DUMP, mp);
19108 /* Use a control ping for synchronization */
19109 MPING (CONTROL_PING, mp_ping);
19117 api_hw_interface_set_mtu (vat_main_t * vam)
19119 unformat_input_t *i = vam->input;
19120 vl_api_hw_interface_set_mtu_t *mp;
19121 u32 sw_if_index = ~0;
19125 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19127 if (unformat (i, "mtu %d", &mtu))
19129 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19131 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19137 if (sw_if_index == ~0)
19139 errmsg ("missing interface name or sw_if_index");
19145 errmsg ("no mtu specified");
19149 /* Construct the API message */
19150 M (HW_INTERFACE_SET_MTU, mp);
19151 mp->sw_if_index = ntohl (sw_if_index);
19152 mp->mtu = ntohs ((u16) mtu);
19160 api_p2p_ethernet_add (vat_main_t * vam)
19162 unformat_input_t *i = vam->input;
19163 vl_api_p2p_ethernet_add_t *mp;
19164 u32 parent_if_index = ~0;
19170 clib_memset (remote_mac, 0, sizeof (remote_mac));
19171 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19173 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
19175 else if (unformat (i, "sw_if_index %d", &parent_if_index))
19179 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
19181 else if (unformat (i, "sub_id %d", &sub_id))
19185 clib_warning ("parse error '%U'", format_unformat_error, i);
19190 if (parent_if_index == ~0)
19192 errmsg ("missing interface name or sw_if_index");
19197 errmsg ("missing remote mac address");
19202 errmsg ("missing sub-interface id");
19206 M (P2P_ETHERNET_ADD, mp);
19207 mp->parent_if_index = ntohl (parent_if_index);
19208 mp->subif_id = ntohl (sub_id);
19209 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
19217 api_p2p_ethernet_del (vat_main_t * vam)
19219 unformat_input_t *i = vam->input;
19220 vl_api_p2p_ethernet_del_t *mp;
19221 u32 parent_if_index = ~0;
19226 clib_memset (remote_mac, 0, sizeof (remote_mac));
19227 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19229 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
19231 else if (unformat (i, "sw_if_index %d", &parent_if_index))
19235 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
19239 clib_warning ("parse error '%U'", format_unformat_error, i);
19244 if (parent_if_index == ~0)
19246 errmsg ("missing interface name or sw_if_index");
19251 errmsg ("missing remote mac address");
19255 M (P2P_ETHERNET_DEL, mp);
19256 mp->parent_if_index = ntohl (parent_if_index);
19257 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
19265 api_tcp_configure_src_addresses (vat_main_t * vam)
19267 vl_api_tcp_configure_src_addresses_t *mp;
19268 unformat_input_t *i = vam->input;
19269 vl_api_address_t first, last;
19274 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19276 if (unformat (i, "%U - %U",
19277 unformat_vl_api_address, &first,
19278 unformat_vl_api_address, &last))
19282 errmsg ("one range per message (range already set)");
19287 else if (unformat (i, "vrf %d", &vrf_id))
19293 if (range_set == 0)
19295 errmsg ("address range not set");
19299 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
19301 mp->vrf_id = ntohl (vrf_id);
19302 clib_memcpy (&mp->first_address, &first, sizeof (first));
19303 clib_memcpy (&mp->last_address, &last, sizeof (last));
19310 static void vl_api_app_namespace_add_del_reply_t_handler
19311 (vl_api_app_namespace_add_del_reply_t * mp)
19313 vat_main_t *vam = &vat_main;
19314 i32 retval = ntohl (mp->retval);
19315 if (vam->async_mode)
19317 vam->async_errors += (retval < 0);
19321 vam->retval = retval;
19323 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
19324 vam->result_ready = 1;
19328 static void vl_api_app_namespace_add_del_reply_t_handler_json
19329 (vl_api_app_namespace_add_del_reply_t * mp)
19331 vat_main_t *vam = &vat_main;
19332 vat_json_node_t node;
19334 vat_json_init_object (&node);
19335 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
19336 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
19338 vat_json_print (vam->ofp, &node);
19339 vat_json_free (&node);
19341 vam->retval = ntohl (mp->retval);
19342 vam->result_ready = 1;
19346 api_app_namespace_add_del (vat_main_t * vam)
19348 vl_api_app_namespace_add_del_t *mp;
19349 unformat_input_t *i = vam->input;
19350 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
19351 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
19355 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19357 if (unformat (i, "id %_%v%_", &ns_id))
19359 else if (unformat (i, "secret %lu", &secret))
19361 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19362 sw_if_index_set = 1;
19363 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
19365 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
19370 if (!ns_id || !secret_set || !sw_if_index_set)
19372 errmsg ("namespace id, secret and sw_if_index must be set");
19375 if (vec_len (ns_id) > 64)
19377 errmsg ("namespace id too long");
19380 M (APP_NAMESPACE_ADD_DEL, mp);
19382 vl_api_vec_to_api_string (ns_id, &mp->namespace_id);
19383 mp->secret = clib_host_to_net_u64 (secret);
19384 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
19385 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
19386 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
19394 api_sock_init_shm (vat_main_t * vam)
19396 #if VPP_API_TEST_BUILTIN == 0
19397 unformat_input_t *i = vam->input;
19398 vl_api_shm_elem_config_t *config = 0;
19399 u64 size = 64 << 20;
19402 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19404 if (unformat (i, "size %U", unformat_memory_size, &size))
19411 * Canned custom ring allocator config.
19412 * Should probably parse all of this
19414 vec_validate (config, 6);
19415 config[0].type = VL_API_VLIB_RING;
19416 config[0].size = 256;
19417 config[0].count = 32;
19419 config[1].type = VL_API_VLIB_RING;
19420 config[1].size = 1024;
19421 config[1].count = 16;
19423 config[2].type = VL_API_VLIB_RING;
19424 config[2].size = 4096;
19425 config[2].count = 2;
19427 config[3].type = VL_API_CLIENT_RING;
19428 config[3].size = 256;
19429 config[3].count = 32;
19431 config[4].type = VL_API_CLIENT_RING;
19432 config[4].size = 1024;
19433 config[4].count = 16;
19435 config[5].type = VL_API_CLIENT_RING;
19436 config[5].size = 4096;
19437 config[5].count = 2;
19439 config[6].type = VL_API_QUEUE;
19440 config[6].count = 128;
19441 config[6].size = sizeof (uword);
19443 rv = vl_socket_client_init_shm (config, 1 /* want_pthread */ );
19445 vam->client_index_invalid = 1;
19453 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
19455 vat_main_t *vam = &vat_main;
19456 fib_prefix_t lcl, rmt;
19458 ip_prefix_decode (&mp->lcl, &lcl);
19459 ip_prefix_decode (&mp->rmt, &rmt);
19461 if (lcl.fp_proto == FIB_PROTOCOL_IP4)
19464 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
19465 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
19466 mp->scope, format_ip4_address, &lcl.fp_addr.ip4, lcl.fp_len,
19467 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
19468 &rmt.fp_addr.ip4, rmt.fp_len,
19469 clib_net_to_host_u16 (mp->rmt_port),
19470 clib_net_to_host_u32 (mp->action_index), mp->tag);
19475 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
19476 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
19477 mp->scope, format_ip6_address, &lcl.fp_addr.ip6, lcl.fp_len,
19478 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
19479 &rmt.fp_addr.ip6, rmt.fp_len,
19480 clib_net_to_host_u16 (mp->rmt_port),
19481 clib_net_to_host_u32 (mp->action_index), mp->tag);
19486 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
19489 vat_main_t *vam = &vat_main;
19490 vat_json_node_t *node = NULL;
19491 struct in6_addr ip6;
19492 struct in_addr ip4;
19494 fib_prefix_t lcl, rmt;
19496 ip_prefix_decode (&mp->lcl, &lcl);
19497 ip_prefix_decode (&mp->rmt, &rmt);
19499 if (VAT_JSON_ARRAY != vam->json_tree.type)
19501 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19502 vat_json_init_array (&vam->json_tree);
19504 node = vat_json_array_add (&vam->json_tree);
19505 vat_json_init_object (node);
19507 vat_json_object_add_uint (node, "appns_index",
19508 clib_net_to_host_u32 (mp->appns_index));
19509 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
19510 vat_json_object_add_uint (node, "scope", mp->scope);
19511 vat_json_object_add_uint (node, "action_index",
19512 clib_net_to_host_u32 (mp->action_index));
19513 vat_json_object_add_uint (node, "lcl_port",
19514 clib_net_to_host_u16 (mp->lcl_port));
19515 vat_json_object_add_uint (node, "rmt_port",
19516 clib_net_to_host_u16 (mp->rmt_port));
19517 vat_json_object_add_uint (node, "lcl_plen", lcl.fp_len);
19518 vat_json_object_add_uint (node, "rmt_plen", rmt.fp_len);
19519 vat_json_object_add_string_copy (node, "tag", mp->tag);
19520 if (lcl.fp_proto == FIB_PROTOCOL_IP4)
19522 clib_memcpy (&ip4, &lcl.fp_addr.ip4, sizeof (ip4));
19523 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
19524 clib_memcpy (&ip4, &rmt.fp_addr.ip4, sizeof (ip4));
19525 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
19529 clib_memcpy (&ip6, &lcl.fp_addr.ip6, sizeof (ip6));
19530 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
19531 clib_memcpy (&ip6, &rmt.fp_addr.ip6, sizeof (ip6));
19532 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
19537 api_session_rule_add_del (vat_main_t * vam)
19539 vl_api_session_rule_add_del_t *mp;
19540 unformat_input_t *i = vam->input;
19541 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
19542 u32 appns_index = 0, scope = 0;
19543 ip4_address_t lcl_ip4, rmt_ip4;
19544 ip6_address_t lcl_ip6, rmt_ip6;
19545 u8 is_ip4 = 1, conn_set = 0;
19546 u8 is_add = 1, *tag = 0;
19548 fib_prefix_t lcl, rmt;
19550 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19552 if (unformat (i, "del"))
19554 else if (unformat (i, "add"))
19556 else if (unformat (i, "proto tcp"))
19558 else if (unformat (i, "proto udp"))
19560 else if (unformat (i, "appns %d", &appns_index))
19562 else if (unformat (i, "scope %d", &scope))
19564 else if (unformat (i, "tag %_%v%_", &tag))
19568 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
19569 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
19577 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
19578 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
19584 else if (unformat (i, "action %d", &action))
19589 if (proto == ~0 || !conn_set || action == ~0)
19591 errmsg ("transport proto, connection and action must be set");
19597 errmsg ("scope should be 0-3");
19601 M (SESSION_RULE_ADD_DEL, mp);
19603 clib_memset (&lcl, 0, sizeof (lcl));
19604 clib_memset (&rmt, 0, sizeof (rmt));
19607 ip_set (&lcl.fp_addr, &lcl_ip4, 1);
19608 ip_set (&rmt.fp_addr, &rmt_ip4, 1);
19609 lcl.fp_len = lcl_plen;
19610 rmt.fp_len = rmt_plen;
19614 ip_set (&lcl.fp_addr, &lcl_ip6, 0);
19615 ip_set (&rmt.fp_addr, &rmt_ip6, 0);
19616 lcl.fp_len = lcl_plen;
19617 rmt.fp_len = rmt_plen;
19621 ip_prefix_encode (&lcl, &mp->lcl);
19622 ip_prefix_encode (&rmt, &mp->rmt);
19623 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
19624 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
19625 mp->transport_proto =
19626 proto ? TRANSPORT_PROTO_API_UDP : TRANSPORT_PROTO_API_TCP;
19627 mp->action_index = clib_host_to_net_u32 (action);
19628 mp->appns_index = clib_host_to_net_u32 (appns_index);
19630 mp->is_add = is_add;
19633 clib_memcpy (mp->tag, tag, vec_len (tag));
19643 api_session_rules_dump (vat_main_t * vam)
19645 vl_api_session_rules_dump_t *mp;
19646 vl_api_control_ping_t *mp_ping;
19649 if (!vam->json_output)
19651 print (vam->ofp, "%=20s", "Session Rules");
19654 M (SESSION_RULES_DUMP, mp);
19658 /* Use a control ping for synchronization */
19659 MPING (CONTROL_PING, mp_ping);
19662 /* Wait for a reply... */
19668 api_ip_container_proxy_add_del (vat_main_t * vam)
19670 vl_api_ip_container_proxy_add_del_t *mp;
19671 unformat_input_t *i = vam->input;
19672 u32 sw_if_index = ~0;
19673 vl_api_prefix_t pfx = { };
19677 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19679 if (unformat (i, "del"))
19681 else if (unformat (i, "add"))
19683 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
19685 else if (unformat (i, "sw_if_index %u", &sw_if_index))
19690 if (sw_if_index == ~0 || pfx.len == 0)
19692 errmsg ("address and sw_if_index must be set");
19696 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
19698 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
19699 mp->is_add = is_add;
19700 clib_memcpy (&mp->pfx, &pfx, sizeof (pfx));
19708 api_qos_record_enable_disable (vat_main_t * vam)
19710 unformat_input_t *i = vam->input;
19711 vl_api_qos_record_enable_disable_t *mp;
19712 u32 sw_if_index, qs = 0xff;
19713 u8 sw_if_index_set = 0;
19717 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19719 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19720 sw_if_index_set = 1;
19721 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19722 sw_if_index_set = 1;
19723 else if (unformat (i, "%U", unformat_qos_source, &qs))
19725 else if (unformat (i, "disable"))
19729 clib_warning ("parse error '%U'", format_unformat_error, i);
19734 if (sw_if_index_set == 0)
19736 errmsg ("missing interface name or sw_if_index");
19741 errmsg ("input location must be specified");
19745 M (QOS_RECORD_ENABLE_DISABLE, mp);
19747 mp->record.sw_if_index = ntohl (sw_if_index);
19748 mp->record.input_source = qs;
19749 mp->enable = enable;
19758 q_or_quit (vat_main_t * vam)
19760 #if VPP_API_TEST_BUILTIN == 0
19761 longjmp (vam->jump_buf, 1);
19763 return 0; /* not so much */
19767 q (vat_main_t * vam)
19769 return q_or_quit (vam);
19773 quit (vat_main_t * vam)
19775 return q_or_quit (vam);
19779 comment (vat_main_t * vam)
19785 elog_save (vat_main_t * vam)
19787 #if VPP_API_TEST_BUILTIN == 0
19788 elog_main_t *em = &vam->elog_main;
19789 unformat_input_t *i = vam->input;
19790 char *file, *chroot_file;
19791 clib_error_t *error;
19793 if (!unformat (i, "%s", &file))
19795 errmsg ("expected file name, got `%U'", format_unformat_error, i);
19799 /* It's fairly hard to get "../oopsie" through unformat; just in case */
19800 if (strstr (file, "..") || index (file, '/'))
19802 errmsg ("illegal characters in filename '%s'", file);
19806 chroot_file = (char *) format (0, "/tmp/%s%c", file, 0);
19810 errmsg ("Saving %wd of %wd events to %s",
19811 elog_n_events_in_buffer (em),
19812 elog_buffer_capacity (em), chroot_file);
19814 error = elog_write_file (em, chroot_file, 1 /* flush ring */ );
19815 vec_free (chroot_file);
19818 clib_error_report (error);
19820 errmsg ("Use the vpp event loger...");
19827 elog_setup (vat_main_t * vam)
19829 #if VPP_API_TEST_BUILTIN == 0
19830 elog_main_t *em = &vam->elog_main;
19831 unformat_input_t *i = vam->input;
19832 u32 nevents = 128 << 10;
19834 (void) unformat (i, "nevents %d", &nevents);
19836 elog_init (em, nevents);
19837 vl_api_set_elog_main (em);
19838 vl_api_set_elog_trace_api_messages (1);
19839 errmsg ("Event logger initialized with %u events", nevents);
19841 errmsg ("Use the vpp event loger...");
19847 elog_enable (vat_main_t * vam)
19849 #if VPP_API_TEST_BUILTIN == 0
19850 elog_main_t *em = &vam->elog_main;
19852 elog_enable_disable (em, 1 /* enable */ );
19853 vl_api_set_elog_trace_api_messages (1);
19854 errmsg ("Event logger enabled...");
19856 errmsg ("Use the vpp event loger...");
19862 elog_disable (vat_main_t * vam)
19864 #if VPP_API_TEST_BUILTIN == 0
19865 elog_main_t *em = &vam->elog_main;
19867 elog_enable_disable (em, 0 /* enable */ );
19868 vl_api_set_elog_trace_api_messages (1);
19869 errmsg ("Event logger disabled...");
19871 errmsg ("Use the vpp event loger...");
19877 statseg (vat_main_t * vam)
19879 ssvm_private_t *ssvmp = &vam->stat_segment;
19880 ssvm_shared_header_t *shared_header = ssvmp->sh;
19881 vlib_counter_t **counters;
19882 u64 thread0_index1_packets;
19883 u64 thread0_index1_bytes;
19884 f64 vector_rate, input_rate;
19887 uword *counter_vector_by_name;
19888 if (vam->stat_segment_lockp == 0)
19890 errmsg ("Stat segment not mapped...");
19894 /* look up "/if/rx for sw_if_index 1 as a test */
19896 clib_spinlock_lock (vam->stat_segment_lockp);
19898 counter_vector_by_name = (uword *) shared_header->opaque[1];
19900 p = hash_get_mem (counter_vector_by_name, "/if/rx");
19903 clib_spinlock_unlock (vam->stat_segment_lockp);
19904 errmsg ("/if/tx not found?");
19908 /* Fish per-thread vector of combined counters from shared memory */
19909 counters = (vlib_counter_t **) p[0];
19911 if (vec_len (counters[0]) < 2)
19913 clib_spinlock_unlock (vam->stat_segment_lockp);
19914 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
19918 /* Read thread 0 sw_if_index 1 counter */
19919 thread0_index1_packets = counters[0][1].packets;
19920 thread0_index1_bytes = counters[0][1].bytes;
19922 p = hash_get_mem (counter_vector_by_name, "vector_rate");
19925 clib_spinlock_unlock (vam->stat_segment_lockp);
19926 errmsg ("vector_rate not found?");
19930 vector_rate = *(f64 *) (p[0]);
19931 p = hash_get_mem (counter_vector_by_name, "input_rate");
19934 clib_spinlock_unlock (vam->stat_segment_lockp);
19935 errmsg ("input_rate not found?");
19938 input_rate = *(f64 *) (p[0]);
19940 clib_spinlock_unlock (vam->stat_segment_lockp);
19942 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
19943 vector_rate, input_rate);
19944 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
19945 thread0_index1_packets, thread0_index1_bytes);
19951 cmd_cmp (void *a1, void *a2)
19956 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
19960 help (vat_main_t * vam)
19965 unformat_input_t *i = vam->input;
19968 if (unformat (i, "%s", &name))
19972 vec_add1 (name, 0);
19974 hs = hash_get_mem (vam->help_by_name, name);
19976 print (vam->ofp, "usage: %s %s", name, hs[0]);
19978 print (vam->ofp, "No such msg / command '%s'", name);
19983 print (vam->ofp, "Help is available for the following:");
19986 hash_foreach_pair (p, vam->function_by_name,
19988 vec_add1 (cmds, (u8 *)(p->key));
19992 vec_sort_with_function (cmds, cmd_cmp);
19994 for (j = 0; j < vec_len (cmds); j++)
19995 print (vam->ofp, "%s", cmds[j]);
20002 set (vat_main_t * vam)
20004 u8 *name = 0, *value = 0;
20005 unformat_input_t *i = vam->input;
20007 if (unformat (i, "%s", &name))
20009 /* The input buffer is a vector, not a string. */
20010 value = vec_dup (i->buffer);
20011 vec_delete (value, i->index, 0);
20012 /* Almost certainly has a trailing newline */
20013 if (value[vec_len (value) - 1] == '\n')
20014 value[vec_len (value) - 1] = 0;
20015 /* Make sure it's a proper string, one way or the other */
20016 vec_add1 (value, 0);
20017 (void) clib_macro_set_value (&vam->macro_main,
20018 (char *) name, (char *) value);
20021 errmsg ("usage: set <name> <value>");
20029 unset (vat_main_t * vam)
20033 if (unformat (vam->input, "%s", &name))
20034 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
20035 errmsg ("unset: %s wasn't set", name);
20048 macro_sort_cmp (void *a1, void *a2)
20050 macro_sort_t *s1 = a1;
20051 macro_sort_t *s2 = a2;
20053 return strcmp ((char *) (s1->name), (char *) (s2->name));
20057 dump_macro_table (vat_main_t * vam)
20059 macro_sort_t *sort_me = 0, *sm;
20064 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
20066 vec_add2 (sort_me, sm, 1);
20067 sm->name = (u8 *)(p->key);
20068 sm->value = (u8 *) (p->value[0]);
20072 vec_sort_with_function (sort_me, macro_sort_cmp);
20074 if (vec_len (sort_me))
20075 print (vam->ofp, "%-15s%s", "Name", "Value");
20077 print (vam->ofp, "The macro table is empty...");
20079 for (i = 0; i < vec_len (sort_me); i++)
20080 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
20085 dump_node_table (vat_main_t * vam)
20088 vlib_node_t *node, *next_node;
20090 if (vec_len (vam->graph_nodes) == 0)
20092 print (vam->ofp, "Node table empty, issue get_node_graph...");
20096 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
20098 node = vam->graph_nodes[0][i];
20099 print (vam->ofp, "[%d] %s", i, node->name);
20100 for (j = 0; j < vec_len (node->next_nodes); j++)
20102 if (node->next_nodes[j] != ~0)
20104 next_node = vam->graph_nodes[0][node->next_nodes[j]];
20105 print (vam->ofp, " [%d] %s", j, next_node->name);
20113 value_sort_cmp (void *a1, void *a2)
20115 name_sort_t *n1 = a1;
20116 name_sort_t *n2 = a2;
20118 if (n1->value < n2->value)
20120 if (n1->value > n2->value)
20127 dump_msg_api_table (vat_main_t * vam)
20129 api_main_t *am = vlibapi_get_main ();
20130 name_sort_t *nses = 0, *ns;
20135 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
20137 vec_add2 (nses, ns, 1);
20138 ns->name = (u8 *)(hp->key);
20139 ns->value = (u32) hp->value[0];
20143 vec_sort_with_function (nses, value_sort_cmp);
20145 for (i = 0; i < vec_len (nses); i++)
20146 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
20152 get_msg_id (vat_main_t * vam)
20157 if (unformat (vam->input, "%s", &name_and_crc))
20159 message_index = vl_msg_api_get_msg_index (name_and_crc);
20160 if (message_index == ~0)
20162 print (vam->ofp, " '%s' not found", name_and_crc);
20165 print (vam->ofp, " '%s' has message index %d",
20166 name_and_crc, message_index);
20169 errmsg ("name_and_crc required...");
20174 search_node_table (vat_main_t * vam)
20176 unformat_input_t *line_input = vam->input;
20179 vlib_node_t *node, *next_node;
20182 if (vam->graph_node_index_by_name == 0)
20184 print (vam->ofp, "Node table empty, issue get_node_graph...");
20188 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
20190 if (unformat (line_input, "%s", &node_to_find))
20192 vec_add1 (node_to_find, 0);
20193 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
20196 print (vam->ofp, "%s not found...", node_to_find);
20199 node = vam->graph_nodes[0][p[0]];
20200 print (vam->ofp, "[%d] %s", p[0], node->name);
20201 for (j = 0; j < vec_len (node->next_nodes); j++)
20203 if (node->next_nodes[j] != ~0)
20205 next_node = vam->graph_nodes[0][node->next_nodes[j]];
20206 print (vam->ofp, " [%d] %s", j, next_node->name);
20213 clib_warning ("parse error '%U'", format_unformat_error,
20219 vec_free (node_to_find);
20228 script (vat_main_t * vam)
20230 #if (VPP_API_TEST_BUILTIN==0)
20232 char *save_current_file;
20233 unformat_input_t save_input;
20234 jmp_buf save_jump_buf;
20235 u32 save_line_number;
20237 FILE *new_fp, *save_ifp;
20239 if (unformat (vam->input, "%s", &s))
20241 new_fp = fopen ((char *) s, "r");
20244 errmsg ("Couldn't open script file %s", s);
20251 errmsg ("Missing script name");
20255 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
20256 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
20257 save_ifp = vam->ifp;
20258 save_line_number = vam->input_line_number;
20259 save_current_file = (char *) vam->current_file;
20261 vam->input_line_number = 0;
20263 vam->current_file = s;
20266 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
20267 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
20268 vam->ifp = save_ifp;
20269 vam->input_line_number = save_line_number;
20270 vam->current_file = (u8 *) save_current_file;
20275 clib_warning ("use the exec command...");
20281 echo (vat_main_t * vam)
20283 print (vam->ofp, "%v", vam->input->buffer);
20287 /* List of API message constructors, CLI names map to api_xxx */
20288 #define foreach_vpe_api_msg \
20289 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
20290 _(sw_interface_dump,"") \
20291 _(sw_interface_set_flags, \
20292 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
20293 _(sw_interface_add_del_address, \
20294 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
20295 _(sw_interface_set_rx_mode, \
20296 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
20297 _(sw_interface_set_rx_placement, \
20298 "<intfc> | sw_if_index <id> [queue <id>] [worker <id> | main]") \
20299 _(sw_interface_rx_placement_dump, \
20300 "[<intfc> | sw_if_index <id>]") \
20301 _(sw_interface_set_table, \
20302 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
20303 _(sw_interface_set_mpls_enable, \
20304 "<intfc> | sw_if_index [disable | dis]") \
20305 _(sw_interface_set_vpath, \
20306 "<intfc> | sw_if_index <id> enable | disable") \
20307 _(sw_interface_set_vxlan_bypass, \
20308 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
20309 _(sw_interface_set_l2_xconnect, \
20310 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
20311 "enable | disable") \
20312 _(sw_interface_set_l2_bridge, \
20313 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
20314 "[shg <split-horizon-group>] [bvi]\n" \
20315 "enable | disable") \
20316 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
20317 _(bridge_domain_add_del, \
20318 "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") \
20319 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
20321 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
20322 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
20323 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
20325 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
20327 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
20329 "id <num> [hw-addr <mac-addr>] [host-if-name <name>] [host-ns <name>] [num-rx-queues <num>] [rx-ring-size <num>] [tx-ring-size <num>] [host-bridge <name>] [host-mac-addr <mac-addr>] [host-ip4-addr <ip4addr/mask>] [host-ip6-addr <ip6addr/mask>] [host-mtu-size <mtu>] [gso | no-gso | csum-offload | gro-coalesce] [persist] [attach] [tun] [packed] [in-order]") \
20331 "<vpp-if-name> | sw_if_index <id>") \
20332 _(sw_interface_tap_v2_dump, "") \
20333 _(virtio_pci_create_v2, \
20334 "pci-addr <pci-address> [use_random_mac | hw-addr <mac-addr>] [features <hex-value>] [gso-enabled [gro-coalesce] | csum-offload-enabled] [packed] [in-order]") \
20335 _(virtio_pci_delete, \
20336 "<vpp-if-name> | sw_if_index <id>") \
20337 _(sw_interface_virtio_pci_dump, "") \
20339 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
20340 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \
20343 "[hw-addr <mac-addr>] {mode round-robin | active-backup | " \
20344 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \
20345 "[id <if-id>] [gso]") \
20347 "<vpp-if-name> | sw_if_index <id>") \
20348 _(bond_add_member, \
20349 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
20350 _(bond_detach_member, \
20351 "sw_if_index <n>") \
20352 _(sw_interface_set_bond_weight, "<intfc> | sw_if_index <nn> weight <value>") \
20353 _(sw_bond_interface_dump, "<intfc> | sw_if_index <nn>") \
20354 _(sw_member_interface_dump, \
20355 "<vpp-if-name> | sw_if_index <id>") \
20356 _(ip_table_add_del, \
20357 "table <n> [ipv6] [add | del]\n") \
20358 _(ip_route_add_del, \
20359 "<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
20360 "[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
20361 "[weight <n>] [drop] [local] [classify <n>] [out-label <n>]\n" \
20362 "[multipath] [count <n>] [del]") \
20363 _(ip_mroute_add_del, \
20364 "<src> <grp>/<mask> [table-id <n>]\n" \
20365 "[<intfc> | sw_if_index <id>] [local] [del]") \
20366 _(mpls_table_add_del, \
20367 "table <n> [add | del]\n") \
20368 _(mpls_route_add_del, \
20369 "<label> <eos> via <addr | next-hop-table <n> | via-label <n> |\n" \
20370 "lookup-ip4-table <n> | lookup-in-ip6-table <n> |\n" \
20371 "l2-input-on <intfc> | l2-input-on sw_if_index <id>>\n" \
20372 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>] [weight <n>]\n" \
20373 "[drop] [local] [classify <n>] [out-label <n>] [multipath]\n" \
20374 "[count <n>] [del]") \
20375 _(mpls_ip_bind_unbind, \
20376 "<label> <addr/len>") \
20377 _(mpls_tunnel_add_del, \
20378 "[add | del <intfc | sw_if_index <id>>] via <addr | via-label <n>>\n" \
20379 "[<intfc> | sw_if_index <id> | next-hop-table <id>]\n" \
20380 "[l2-only] [out-label <n>]") \
20381 _(sr_mpls_policy_add, \
20382 "bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
20383 _(sr_mpls_policy_del, \
20385 _(bier_table_add_del, \
20386 "<label> <sub-domain> <set> <bsl> [del]") \
20387 _(bier_route_add_del, \
20388 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
20389 "[<intfc> | sw_if_index <id>]" \
20390 "[weight <n>] [del] [multipath]") \
20391 _(sw_interface_set_unnumbered, \
20392 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
20393 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
20394 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
20395 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
20396 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
20397 "[outer_vlan_id_any][inner_vlan_id_any]") \
20398 _(ip_table_replace_begin, "table <n> [ipv6]") \
20399 _(ip_table_flush, "table <n> [ipv6]") \
20400 _(ip_table_replace_end, "table <n> [ipv6]") \
20401 _(set_ip_flow_hash, \
20402 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
20403 _(sw_interface_ip6_enable_disable, \
20404 "<intfc> | sw_if_index <id> enable | disable") \
20405 _(l2_patch_add_del, \
20406 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
20407 "enable | disable") \
20408 _(sr_localsid_add_del, \
20409 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
20410 "fib-table <num> (end.psp) sw_if_index <num>") \
20411 _(classify_add_del_table, \
20412 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
20413 " [del] [del-chain] mask <mask-value>\n" \
20414 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
20415 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
20416 _(classify_add_del_session, \
20417 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
20418 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
20419 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
20420 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
20421 _(classify_set_interface_ip_table, \
20422 "<intfc> | sw_if_index <nn> table <nn>") \
20423 _(classify_set_interface_l2_tables, \
20424 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20425 " [other-table <nn>]") \
20426 _(get_node_index, "node <node-name") \
20427 _(add_node_next, "node <node-name> next <next-node-name>") \
20428 _(l2tpv3_create_tunnel, \
20429 "client_address <ip6-addr> our_address <ip6-addr>\n" \
20430 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
20431 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
20432 _(l2tpv3_set_tunnel_cookies, \
20433 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
20434 "[new_remote_cookie <nn>]\n") \
20435 _(l2tpv3_interface_enable_disable, \
20436 "<intfc> | sw_if_index <nn> enable | disable") \
20437 _(l2tpv3_set_lookup_key, \
20438 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
20439 _(sw_if_l2tpv3_tunnel_dump, "") \
20440 _(vxlan_offload_rx, \
20441 "hw { <interface name> | hw_if_index <nn>} " \
20442 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
20443 _(vxlan_add_del_tunnel, \
20444 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
20445 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
20446 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
20447 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20448 _(gre_tunnel_add_del, \
20449 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
20450 "[teb | erspan <session-id>] [del]") \
20451 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20452 _(l2_fib_clear_table, "") \
20453 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
20454 _(l2_interface_vlan_tag_rewrite, \
20455 "<intfc> | sw_if_index <nn> \n" \
20456 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
20457 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
20458 _(create_vhost_user_if, \
20459 "socket <filename> [server] [renumber <dev_instance>] " \
20460 "[disable_mrg_rxbuf] [disable_indirect_desc] [gso] " \
20461 "[mac <mac_address>] [packed]") \
20462 _(modify_vhost_user_if, \
20463 "<intfc> | sw_if_index <nn> socket <filename>\n" \
20464 "[server] [renumber <dev_instance>] [gso] [packed]") \
20465 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
20466 _(sw_interface_vhost_user_dump, "<intfc> | sw_if_index <nn>") \
20467 _(show_version, "") \
20468 _(show_threads, "") \
20469 _(vxlan_gpe_add_del_tunnel, \
20470 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
20471 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
20472 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
20473 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
20474 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20475 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
20476 _(interface_name_renumber, \
20477 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
20478 _(input_acl_set_interface, \
20479 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20480 " [l2-table <nn>] [del]") \
20481 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
20482 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
20483 _(ip_dump, "ipv4 | ipv6") \
20484 _(ipsec_spd_add_del, "spd_id <n> [del]") \
20485 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
20487 _(ipsec_sad_entry_add_del, "sad_id <n> spi <n> crypto_alg <alg>\n" \
20488 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
20489 " integ_alg <alg> integ_key <hex>") \
20490 _(ipsec_spd_entry_add_del, "spd_id <n> priority <n> action <action>\n" \
20491 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
20492 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
20493 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
20494 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
20495 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
20496 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
20497 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
20498 " [instance <n>]") \
20499 _(ipsec_sa_dump, "[sa_id <n>]") \
20500 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
20501 _(delete_loopback,"sw_if_index <nn>") \
20502 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
20503 _(bd_ip_mac_flush, "bd_id <bridge-domain-id>") \
20504 _(bd_ip_mac_dump, "[bd_id] <bridge-domain-id>") \
20505 _(want_interface_events, "enable|disable") \
20506 _(get_first_msg_id, "client <name>") \
20507 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
20508 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
20509 "fib-id <nn> [ip4][ip6][default]") \
20510 _(get_node_graph, " ") \
20511 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
20512 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
20513 _(ioam_disable, "") \
20514 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
20515 " sw_if_index <sw_if_index> p <priority> " \
20516 "w <weight>] [del]") \
20517 _(one_add_del_locator, "locator-set <locator_name> " \
20518 "iface <intf> | sw_if_index <sw_if_index> " \
20519 "p <priority> w <weight> [del]") \
20520 _(one_add_del_local_eid,"vni <vni> eid " \
20521 "<ipv4|ipv6>/<prefix> | <L2 address> " \
20522 "locator-set <locator_name> [del]" \
20523 "[key-id sha1|sha256 secret-key <secret-key>]")\
20524 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
20525 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
20526 _(one_enable_disable, "enable|disable") \
20527 _(one_map_register_enable_disable, "enable|disable") \
20528 _(one_map_register_fallback_threshold, "<value>") \
20529 _(one_rloc_probe_enable_disable, "enable|disable") \
20530 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
20532 "rloc <locator> p <prio> " \
20533 "w <weight> [rloc <loc> ... ] " \
20534 "action <action> [del-all]") \
20535 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
20537 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
20538 _(one_use_petr, "ip-address> | disable") \
20539 _(one_map_request_mode, "src-dst|dst-only") \
20540 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
20541 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
20542 _(one_locator_set_dump, "[local | remote]") \
20543 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
20544 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
20545 "[local] | [remote]") \
20546 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
20547 _(one_ndp_bd_get, "") \
20548 _(one_ndp_entries_get, "bd <bridge-domain>") \
20549 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip <ip4>") \
20550 _(one_l2_arp_bd_get, "") \
20551 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
20552 _(one_stats_enable_disable, "enable|disable") \
20553 _(show_one_stats_enable_disable, "") \
20554 _(one_eid_table_vni_dump, "") \
20555 _(one_eid_table_map_dump, "l2|l3") \
20556 _(one_map_resolver_dump, "") \
20557 _(one_map_server_dump, "") \
20558 _(one_adjacencies_get, "vni <vni>") \
20559 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
20560 _(show_one_rloc_probe_state, "") \
20561 _(show_one_map_register_state, "") \
20562 _(show_one_status, "") \
20563 _(one_stats_dump, "") \
20564 _(one_stats_flush, "") \
20565 _(one_get_map_request_itr_rlocs, "") \
20566 _(one_map_register_set_ttl, "<ttl>") \
20567 _(one_set_transport_protocol, "udp|api") \
20568 _(one_get_transport_protocol, "") \
20569 _(one_enable_disable_xtr_mode, "enable|disable") \
20570 _(one_show_xtr_mode, "") \
20571 _(one_enable_disable_pitr_mode, "enable|disable") \
20572 _(one_show_pitr_mode, "") \
20573 _(one_enable_disable_petr_mode, "enable|disable") \
20574 _(one_show_petr_mode, "") \
20575 _(show_one_nsh_mapping, "") \
20576 _(show_one_pitr, "") \
20577 _(show_one_use_petr, "") \
20578 _(show_one_map_request_mode, "") \
20579 _(show_one_map_register_ttl, "") \
20580 _(show_one_map_register_fallback_threshold, "") \
20581 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
20582 " sw_if_index <sw_if_index> p <priority> " \
20583 "w <weight>] [del]") \
20584 _(lisp_add_del_locator, "locator-set <locator_name> " \
20585 "iface <intf> | sw_if_index <sw_if_index> " \
20586 "p <priority> w <weight> [del]") \
20587 _(lisp_add_del_local_eid,"vni <vni> eid " \
20588 "<ipv4|ipv6>/<prefix> | <L2 address> " \
20589 "locator-set <locator_name> [del]" \
20590 "[key-id sha1|sha256 secret-key <secret-key>]") \
20591 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
20592 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
20593 _(lisp_enable_disable, "enable|disable") \
20594 _(lisp_map_register_enable_disable, "enable|disable") \
20595 _(lisp_rloc_probe_enable_disable, "enable|disable") \
20596 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
20598 "rloc <locator> p <prio> " \
20599 "w <weight> [rloc <loc> ... ] " \
20600 "action <action> [del-all]") \
20601 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
20603 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
20604 _(lisp_use_petr, "<ip-address> | disable") \
20605 _(lisp_map_request_mode, "src-dst|dst-only") \
20606 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
20607 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
20608 _(lisp_locator_set_dump, "[local | remote]") \
20609 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
20610 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
20611 "[local] | [remote]") \
20612 _(lisp_eid_table_vni_dump, "") \
20613 _(lisp_eid_table_map_dump, "l2|l3") \
20614 _(lisp_map_resolver_dump, "") \
20615 _(lisp_map_server_dump, "") \
20616 _(lisp_adjacencies_get, "vni <vni>") \
20617 _(gpe_fwd_entry_vnis_get, "") \
20618 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
20619 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
20620 "[table <table-id>]") \
20621 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
20622 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
20623 _(gpe_set_encap_mode, "lisp|vxlan") \
20624 _(gpe_get_encap_mode, "") \
20625 _(lisp_gpe_add_del_iface, "up|down") \
20626 _(lisp_gpe_enable_disable, "enable|disable") \
20627 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
20628 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
20629 _(show_lisp_rloc_probe_state, "") \
20630 _(show_lisp_map_register_state, "") \
20631 _(show_lisp_status, "") \
20632 _(lisp_get_map_request_itr_rlocs, "") \
20633 _(show_lisp_pitr, "") \
20634 _(show_lisp_use_petr, "") \
20635 _(show_lisp_map_request_mode, "") \
20636 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
20637 _(af_packet_delete, "name <host interface name>") \
20638 _(af_packet_dump, "") \
20639 _(policer_add_del, "name <policer name> <params> [del]") \
20640 _(policer_dump, "[name <policer name>]") \
20641 _(policer_classify_set_interface, \
20642 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20643 " [l2-table <nn>] [del]") \
20644 _(policer_classify_dump, "type [ip4|ip6|l2]") \
20645 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
20646 _(mpls_table_dump, "") \
20647 _(mpls_route_dump, "table-id <ID>") \
20648 _(classify_table_ids, "") \
20649 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
20650 _(classify_table_info, "table_id <nn>") \
20651 _(classify_session_dump, "table_id <nn>") \
20652 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
20653 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
20654 "[template_interval <nn>] [udp_checksum]") \
20655 _(ipfix_exporter_dump, "") \
20656 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
20657 _(ipfix_classify_stream_dump, "") \
20658 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
20659 _(ipfix_classify_table_dump, "") \
20660 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
20661 _(sw_interface_span_dump, "[l2]") \
20662 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
20663 _(pg_create_interface, "if_id <nn> [gso-enabled gso-size <size>]") \
20664 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
20665 _(pg_enable_disable, "[stream <id>] disable") \
20666 _(pg_interface_enable_disable_coalesce, "<intf> | sw_if_index <nn> enable | disable") \
20667 _(ip_source_and_port_range_check_add_del, \
20668 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
20669 _(ip_source_and_port_range_check_interface_add_del, \
20670 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
20671 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
20672 _(delete_subif,"<intfc> | sw_if_index <nn>") \
20673 _(l2_interface_pbb_tag_rewrite, \
20674 "<intfc> | sw_if_index <nn> \n" \
20675 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
20676 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
20677 _(set_punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
20678 _(flow_classify_set_interface, \
20679 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
20680 _(flow_classify_dump, "type [ip4|ip6]") \
20681 _(ip_table_dump, "") \
20682 _(ip_route_dump, "table-id [ip4|ip6]") \
20683 _(ip_mtable_dump, "") \
20684 _(ip_mroute_dump, "table-id [ip4|ip6]") \
20685 _(feature_enable_disable, "arc_name <arc_name> " \
20686 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
20687 _(feature_gso_enable_disable, "<intfc> | sw_if_index <nn> " \
20688 "[enable | disable] ") \
20689 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
20691 _(sw_interface_add_del_mac_address, "<intfc> | sw_if_index <nn> " \
20692 "mac <mac-address> [del]") \
20693 _(l2_xconnect_dump, "") \
20694 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
20695 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
20696 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
20697 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
20698 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
20699 _(sock_init_shm, "size <nnn>") \
20700 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
20701 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
20702 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
20703 _(session_rules_dump, "") \
20704 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
20705 _(output_acl_set_interface, \
20706 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20707 " [l2-table <nn>] [del]") \
20708 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
20710 /* List of command functions, CLI names map directly to functions */
20711 #define foreach_cli_function \
20712 _(comment, "usage: comment <ignore-rest-of-line>") \
20713 _(dump_interface_table, "usage: dump_interface_table") \
20714 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
20715 _(dump_ipv4_table, "usage: dump_ipv4_table") \
20716 _(dump_ipv6_table, "usage: dump_ipv6_table") \
20717 _(dump_macro_table, "usage: dump_macro_table ") \
20718 _(dump_node_table, "usage: dump_node_table") \
20719 _(dump_msg_api_table, "usage: dump_msg_api_table") \
20720 _(elog_setup, "usage: elog_setup [nevents, default 128K]") \
20721 _(elog_disable, "usage: elog_disable") \
20722 _(elog_enable, "usage: elog_enable") \
20723 _(elog_save, "usage: elog_save <filename>") \
20724 _(get_msg_id, "usage: get_msg_id name_and_crc") \
20725 _(echo, "usage: echo <message>") \
20726 _(exec, "usage: exec <vpe-debug-CLI-command>") \
20727 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
20728 _(help, "usage: help") \
20729 _(q, "usage: quit") \
20730 _(quit, "usage: quit") \
20731 _(search_node_table, "usage: search_node_table <name>...") \
20732 _(set, "usage: set <variable-name> <value>") \
20733 _(script, "usage: script <file-name>") \
20734 _(statseg, "usage: statseg") \
20735 _(unset, "usage: unset <variable-name>")
20738 static void vl_api_##n##_t_handler_uni \
20739 (vl_api_##n##_t * mp) \
20741 vat_main_t * vam = &vat_main; \
20742 if (vam->json_output) { \
20743 vl_api_##n##_t_handler_json(mp); \
20745 vl_api_##n##_t_handler(mp); \
20748 foreach_vpe_api_reply_msg;
20749 #if VPP_API_TEST_BUILTIN == 0
20750 foreach_standalone_reply_msg;
20755 vat_api_hookup (vat_main_t * vam)
20758 vl_msg_api_set_handlers(VL_API_##N, #n, \
20759 vl_api_##n##_t_handler_uni, \
20761 vl_api_##n##_t_endian, \
20762 vl_api_##n##_t_print, \
20763 sizeof(vl_api_##n##_t), 1);
20764 foreach_vpe_api_reply_msg;
20765 #if VPP_API_TEST_BUILTIN == 0
20766 foreach_standalone_reply_msg;
20770 #if (VPP_API_TEST_BUILTIN==0)
20771 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
20773 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
20775 vam->function_by_name = hash_create_string (0, sizeof (uword));
20777 vam->help_by_name = hash_create_string (0, sizeof (uword));
20780 /* API messages we can send */
20781 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
20782 foreach_vpe_api_msg;
20786 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
20787 foreach_vpe_api_msg;
20790 /* CLI functions */
20791 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
20792 foreach_cli_function;
20796 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
20797 foreach_cli_function;
20801 #if VPP_API_TEST_BUILTIN
20802 static clib_error_t *
20803 vat_api_hookup_shim (vlib_main_t * vm)
20805 vat_api_hookup (&vat_main);
20809 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
20813 * fd.io coding-style-patch-verification: ON
20816 * eval: (c-set-style "gnu")