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 _(lldp_config_reply) \
5200 _(sw_interface_set_lldp_reply) \
5201 _(tcp_configure_src_addresses_reply) \
5202 _(session_rule_add_del_reply) \
5203 _(ip_container_proxy_add_del_reply) \
5204 _(output_acl_set_interface_reply) \
5205 _(qos_record_enable_disable_reply) \
5209 static void vl_api_##n##_t_handler \
5210 (vl_api_##n##_t * mp) \
5212 vat_main_t * vam = &vat_main; \
5213 i32 retval = ntohl(mp->retval); \
5214 if (vam->async_mode) { \
5215 vam->async_errors += (retval < 0); \
5217 vam->retval = retval; \
5218 vam->result_ready = 1; \
5221 foreach_standard_reply_retval_handler;
5225 static void vl_api_##n##_t_handler_json \
5226 (vl_api_##n##_t * mp) \
5228 vat_main_t * vam = &vat_main; \
5229 vat_json_node_t node; \
5230 vat_json_init_object(&node); \
5231 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5232 vat_json_print(vam->ofp, &node); \
5233 vam->retval = ntohl(mp->retval); \
5234 vam->result_ready = 1; \
5236 foreach_standard_reply_retval_handler;
5240 * Table of message reply handlers, must include boilerplate handlers
5244 #define foreach_vpe_api_reply_msg \
5245 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5246 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5247 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5248 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5249 _(CONTROL_PING_REPLY, control_ping_reply) \
5250 _(CLI_REPLY, cli_reply) \
5251 _(CLI_INBAND_REPLY, cli_inband_reply) \
5252 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5253 sw_interface_add_del_address_reply) \
5254 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5255 _(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
5256 _(SW_INTERFACE_RX_PLACEMENT_DETAILS, sw_interface_rx_placement_details) \
5257 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5258 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5259 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5260 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5261 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5262 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5263 sw_interface_set_l2_xconnect_reply) \
5264 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5265 sw_interface_set_l2_bridge_reply) \
5266 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5267 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5268 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5269 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5270 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5271 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5272 _(L2_FLAGS_REPLY, l2_flags_reply) \
5273 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5274 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5275 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5276 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5277 _(VIRTIO_PCI_CREATE_REPLY, virtio_pci_create_reply) \
5278 _(VIRTIO_PCI_CREATE_V2_REPLY, virtio_pci_create_v2_reply) \
5279 _(VIRTIO_PCI_DELETE_REPLY, virtio_pci_delete_reply) \
5280 _(SW_INTERFACE_VIRTIO_PCI_DETAILS, sw_interface_virtio_pci_details) \
5281 _(BOND_CREATE_REPLY, bond_create_reply) \
5282 _(BOND_CREATE2_REPLY, bond_create2_reply) \
5283 _(BOND_DELETE_REPLY, bond_delete_reply) \
5284 _(BOND_ADD_MEMBER_REPLY, bond_add_member_reply) \
5285 _(BOND_DETACH_MEMBER_REPLY, bond_detach_member_reply) \
5286 _(SW_INTERFACE_SET_BOND_WEIGHT_REPLY, sw_interface_set_bond_weight_reply) \
5287 _(SW_BOND_INTERFACE_DETAILS, sw_bond_interface_details) \
5288 _(SW_MEMBER_INTERFACE_DETAILS, sw_member_interface_details) \
5289 _(IP_ROUTE_ADD_DEL_REPLY, ip_route_add_del_reply) \
5290 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5291 _(IP_TABLE_REPLACE_BEGIN_REPLY, ip_table_replace_begin_reply) \
5292 _(IP_TABLE_FLUSH_REPLY, ip_table_flush_reply) \
5293 _(IP_TABLE_REPLACE_END_REPLY, ip_table_replace_end_reply) \
5294 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5295 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5296 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5297 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5298 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5299 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5300 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5301 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5302 sw_interface_set_unnumbered_reply) \
5303 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5304 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5305 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5306 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5307 sw_interface_ip6_enable_disable_reply) \
5308 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5309 _(SR_MPLS_POLICY_ADD_REPLY, sr_mpls_policy_add_reply) \
5310 _(SR_MPLS_POLICY_MOD_REPLY, sr_mpls_policy_mod_reply) \
5311 _(SR_MPLS_POLICY_DEL_REPLY, sr_mpls_policy_del_reply) \
5312 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5313 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5314 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5315 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5316 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5317 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5318 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5319 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5320 classify_set_interface_ip_table_reply) \
5321 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5322 classify_set_interface_l2_tables_reply) \
5323 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5324 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5325 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5326 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5327 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5328 l2tpv3_interface_enable_disable_reply) \
5329 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5330 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5331 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5332 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5333 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5334 _(GRE_TUNNEL_ADD_DEL_REPLY, gre_tunnel_add_del_reply) \
5335 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5336 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5337 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5338 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5339 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5340 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5341 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5342 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5343 _(SHOW_VERSION_REPLY, show_version_reply) \
5344 _(SHOW_THREADS_REPLY, show_threads_reply) \
5345 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5346 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5347 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5348 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5349 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5350 _(L2_MACS_EVENT, l2_macs_event) \
5351 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5352 _(IP_ADDRESS_DETAILS, ip_address_details) \
5353 _(IP_DETAILS, ip_details) \
5354 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5355 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5356 _(IPSEC_SPD_ENTRY_ADD_DEL_REPLY, ipsec_spd_entry_add_del_reply) \
5357 _(IPSEC_SAD_ENTRY_ADD_DEL_REPLY, ipsec_sad_entry_add_del_reply) \
5358 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5359 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5360 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5361 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5362 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5363 _(BD_IP_MAC_FLUSH_REPLY, bd_ip_mac_flush_reply) \
5364 _(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
5365 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5366 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5367 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5368 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5369 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5370 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5371 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5372 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5373 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5374 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5375 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5376 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5377 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5378 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5379 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5380 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5381 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5382 one_map_register_enable_disable_reply) \
5383 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5384 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5385 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5386 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5387 one_map_register_fallback_threshold_reply) \
5388 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5389 one_rloc_probe_enable_disable_reply) \
5390 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5391 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5392 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5393 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5394 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5395 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5396 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5397 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5398 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5399 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5400 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5401 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5402 _(ONE_STATS_DETAILS, one_stats_details) \
5403 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5404 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5405 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5406 show_one_stats_enable_disable_reply) \
5407 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5408 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5409 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5410 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5411 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5412 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5413 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5414 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5415 one_enable_disable_pitr_mode_reply) \
5416 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5417 one_enable_disable_petr_mode_reply) \
5418 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5419 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5420 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5421 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5422 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5423 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5424 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5425 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5426 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5427 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5428 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5429 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5430 gpe_add_del_native_fwd_rpath_reply) \
5431 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5432 gpe_fwd_entry_path_details) \
5433 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5434 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5435 one_add_del_map_request_itr_rlocs_reply) \
5436 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5437 one_get_map_request_itr_rlocs_reply) \
5438 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5439 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5440 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5441 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5442 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5443 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5444 show_one_map_register_state_reply) \
5445 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5446 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5447 show_one_map_register_fallback_threshold_reply) \
5448 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5449 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5450 _(AF_PACKET_DETAILS, af_packet_details) \
5451 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5452 _(POLICER_DETAILS, policer_details) \
5453 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5454 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5455 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5456 _(MPLS_TABLE_DETAILS, mpls_table_details) \
5457 _(MPLS_ROUTE_DETAILS, mpls_route_details) \
5458 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5459 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5460 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5461 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5462 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5463 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5464 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5465 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5466 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5467 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5468 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5469 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5470 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5471 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5472 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5473 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5474 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5475 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5476 _(PG_INTERFACE_ENABLE_DISABLE_COALESCE_REPLY, pg_interface_enable_disable_coalesce_reply) \
5477 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5478 ip_source_and_port_range_check_add_del_reply) \
5479 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5480 ip_source_and_port_range_check_interface_add_del_reply) \
5481 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5482 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5483 _(SET_PUNT_REPLY, set_punt_reply) \
5484 _(IP_TABLE_DETAILS, ip_table_details) \
5485 _(IP_ROUTE_DETAILS, ip_route_details) \
5486 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5487 _(FEATURE_GSO_ENABLE_DISABLE_REPLY, feature_gso_enable_disable_reply) \
5488 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5489 _(SW_INTERFACE_ADD_DEL_MAC_ADDRESS_REPLY, sw_interface_add_del_mac_address_reply) \
5490 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5491 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5492 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5493 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5494 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5495 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5496 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5497 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5498 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5499 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5500 _(SESSION_RULES_DETAILS, session_rules_details) \
5501 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5502 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5503 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply) \
5504 _(FLOW_ADD_REPLY, flow_add_reply) \
5506 #define foreach_standalone_reply_msg \
5507 _(SW_INTERFACE_EVENT, sw_interface_event)
5515 #define STR_VTR_OP_CASE(op) \
5516 case L2_VTR_ ## op: \
5520 str_vtr_op (u32 vtr_op)
5524 STR_VTR_OP_CASE (DISABLED);
5525 STR_VTR_OP_CASE (PUSH_1);
5526 STR_VTR_OP_CASE (PUSH_2);
5527 STR_VTR_OP_CASE (POP_1);
5528 STR_VTR_OP_CASE (POP_2);
5529 STR_VTR_OP_CASE (TRANSLATE_1_1);
5530 STR_VTR_OP_CASE (TRANSLATE_1_2);
5531 STR_VTR_OP_CASE (TRANSLATE_2_1);
5532 STR_VTR_OP_CASE (TRANSLATE_2_2);
5539 dump_sub_interface_table (vat_main_t * vam)
5541 const sw_interface_subif_t *sub = NULL;
5543 if (vam->json_output)
5546 ("JSON output supported only for VPE API calls and dump_stats_table");
5551 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5552 "Interface", "sw_if_index",
5553 "sub id", "dot1ad", "tags", "outer id",
5554 "inner id", "exact", "default", "outer any", "inner any");
5556 vec_foreach (sub, vam->sw_if_subif_table)
5559 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5560 sub->interface_name,
5562 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5563 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5564 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5565 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5566 if (sub->vtr_op != L2_VTR_DISABLED)
5569 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5570 "tag1: %d tag2: %d ]",
5571 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5572 sub->vtr_tag1, sub->vtr_tag2);
5580 name_sort_cmp (void *a1, void *a2)
5582 name_sort_t *n1 = a1;
5583 name_sort_t *n2 = a2;
5585 return strcmp ((char *) n1->name, (char *) n2->name);
5589 dump_interface_table (vat_main_t * vam)
5592 name_sort_t *nses = 0, *ns;
5594 if (vam->json_output)
5597 ("JSON output supported only for VPE API calls and dump_stats_table");
5602 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5604 vec_add2 (nses, ns, 1);
5605 ns->name = (u8 *)(p->key);
5606 ns->value = (u32) p->value[0];
5610 vec_sort_with_function (nses, name_sort_cmp);
5612 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5613 vec_foreach (ns, nses)
5615 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5622 dump_ip_table (vat_main_t * vam, int is_ipv6)
5624 const ip_details_t *det = NULL;
5625 const ip_address_details_t *address = NULL;
5628 print (vam->ofp, "%-12s", "sw_if_index");
5630 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5637 print (vam->ofp, "%-12d", i);
5638 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5643 vec_foreach (address, det->addr)
5647 is_ipv6 ? format_ip6_address : format_ip4_address,
5648 address->ip, address->prefix_length);
5656 dump_ipv4_table (vat_main_t * vam)
5658 if (vam->json_output)
5661 ("JSON output supported only for VPE API calls and dump_stats_table");
5665 return dump_ip_table (vam, 0);
5669 dump_ipv6_table (vat_main_t * vam)
5671 if (vam->json_output)
5674 ("JSON output supported only for VPE API calls and dump_stats_table");
5678 return dump_ip_table (vam, 1);
5682 * Pass CLI buffers directly in the CLI_INBAND API message,
5683 * instead of an additional shared memory area.
5686 exec_inband (vat_main_t * vam)
5688 vl_api_cli_inband_t *mp;
5689 unformat_input_t *i = vam->input;
5692 if (vec_len (i->buffer) == 0)
5695 if (vam->exec_mode == 0 && unformat (i, "mode"))
5700 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5707 * In order for the CLI command to work, it
5708 * must be a vector ending in \n, not a C-string ending
5711 M2 (CLI_INBAND, mp, vec_len (vam->input->buffer));
5712 vl_api_vec_to_api_string (vam->input->buffer, &mp->cmd);
5716 /* json responses may or may not include a useful reply... */
5717 if (vec_len (vam->cmd_reply))
5718 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
5723 exec (vat_main_t * vam)
5725 return exec_inband (vam);
5729 api_create_loopback (vat_main_t * vam)
5731 unformat_input_t *i = vam->input;
5732 vl_api_create_loopback_t *mp;
5733 vl_api_create_loopback_instance_t *mp_lbi;
5736 u8 is_specified = 0;
5737 u32 user_instance = 0;
5740 clib_memset (mac_address, 0, sizeof (mac_address));
5742 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5744 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5746 if (unformat (i, "instance %d", &user_instance))
5754 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5755 mp_lbi->is_specified = is_specified;
5757 mp_lbi->user_instance = htonl (user_instance);
5759 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5764 /* Construct the API message */
5765 M (CREATE_LOOPBACK, mp);
5767 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5776 api_delete_loopback (vat_main_t * vam)
5778 unformat_input_t *i = vam->input;
5779 vl_api_delete_loopback_t *mp;
5780 u32 sw_if_index = ~0;
5783 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5785 if (unformat (i, "sw_if_index %d", &sw_if_index))
5791 if (sw_if_index == ~0)
5793 errmsg ("missing sw_if_index");
5797 /* Construct the API message */
5798 M (DELETE_LOOPBACK, mp);
5799 mp->sw_if_index = ntohl (sw_if_index);
5807 api_want_interface_events (vat_main_t * vam)
5809 unformat_input_t *i = vam->input;
5810 vl_api_want_interface_events_t *mp;
5814 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5816 if (unformat (i, "enable"))
5818 else if (unformat (i, "disable"))
5826 errmsg ("missing enable|disable");
5830 M (WANT_INTERFACE_EVENTS, mp);
5831 mp->enable_disable = enable;
5833 vam->interface_event_display = enable;
5841 /* Note: non-static, called once to set up the initial intfc table */
5843 api_sw_interface_dump (vat_main_t * vam)
5845 vl_api_sw_interface_dump_t *mp;
5846 vl_api_control_ping_t *mp_ping;
5848 name_sort_t *nses = 0, *ns;
5849 sw_interface_subif_t *sub = NULL;
5852 /* Toss the old name table */
5854 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5856 vec_add2 (nses, ns, 1);
5857 ns->name = (u8 *)(p->key);
5858 ns->value = (u32) p->value[0];
5862 hash_free (vam->sw_if_index_by_interface_name);
5864 vec_foreach (ns, nses) vec_free (ns->name);
5868 vec_foreach (sub, vam->sw_if_subif_table)
5870 vec_free (sub->interface_name);
5872 vec_free (vam->sw_if_subif_table);
5874 /* recreate the interface name hash table */
5875 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5878 * Ask for all interface names. Otherwise, the epic catalog of
5879 * name filters becomes ridiculously long, and vat ends up needing
5880 * to be taught about new interface types.
5882 M (SW_INTERFACE_DUMP, mp);
5885 /* Use a control ping for synchronization */
5886 MPING (CONTROL_PING, mp_ping);
5894 api_sw_interface_set_flags (vat_main_t * vam)
5896 unformat_input_t *i = vam->input;
5897 vl_api_sw_interface_set_flags_t *mp;
5899 u8 sw_if_index_set = 0;
5903 /* Parse args required to build the message */
5904 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5906 if (unformat (i, "admin-up"))
5908 else if (unformat (i, "admin-down"))
5911 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5912 sw_if_index_set = 1;
5913 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5914 sw_if_index_set = 1;
5919 if (sw_if_index_set == 0)
5921 errmsg ("missing interface name or sw_if_index");
5925 /* Construct the API message */
5926 M (SW_INTERFACE_SET_FLAGS, mp);
5927 mp->sw_if_index = ntohl (sw_if_index);
5928 mp->flags = ntohl ((admin_up) ? IF_STATUS_API_FLAG_ADMIN_UP : 0);
5933 /* Wait for a reply, return the good/bad news... */
5939 api_sw_interface_set_rx_mode (vat_main_t * vam)
5941 unformat_input_t *i = vam->input;
5942 vl_api_sw_interface_set_rx_mode_t *mp;
5944 u8 sw_if_index_set = 0;
5946 u8 queue_id_valid = 0;
5948 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
5950 /* Parse args required to build the message */
5951 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5953 if (unformat (i, "queue %d", &queue_id))
5955 else if (unformat (i, "polling"))
5956 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
5957 else if (unformat (i, "interrupt"))
5958 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
5959 else if (unformat (i, "adaptive"))
5960 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
5962 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5963 sw_if_index_set = 1;
5964 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5965 sw_if_index_set = 1;
5970 if (sw_if_index_set == 0)
5972 errmsg ("missing interface name or sw_if_index");
5975 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
5977 errmsg ("missing rx-mode");
5981 /* Construct the API message */
5982 M (SW_INTERFACE_SET_RX_MODE, mp);
5983 mp->sw_if_index = ntohl (sw_if_index);
5984 mp->mode = (vl_api_rx_mode_t) mode;
5985 mp->queue_id_valid = queue_id_valid;
5986 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
5991 /* Wait for a reply, return the good/bad news... */
5997 api_sw_interface_set_rx_placement (vat_main_t * vam)
5999 unformat_input_t *i = vam->input;
6000 vl_api_sw_interface_set_rx_placement_t *mp;
6002 u8 sw_if_index_set = 0;
6005 u32 queue_id, thread_index;
6007 /* Parse args required to build the message */
6008 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6010 if (unformat (i, "queue %d", &queue_id))
6012 else if (unformat (i, "main"))
6014 else if (unformat (i, "worker %d", &thread_index))
6017 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6018 sw_if_index_set = 1;
6019 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6020 sw_if_index_set = 1;
6025 if (sw_if_index_set == 0)
6027 errmsg ("missing interface name or sw_if_index");
6033 /* Construct the API message */
6034 M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
6035 mp->sw_if_index = ntohl (sw_if_index);
6036 mp->worker_id = ntohl (thread_index);
6037 mp->queue_id = ntohl (queue_id);
6038 mp->is_main = is_main;
6042 /* Wait for a reply, return the good/bad news... */
6047 static void vl_api_sw_interface_rx_placement_details_t_handler
6048 (vl_api_sw_interface_rx_placement_details_t * mp)
6050 vat_main_t *vam = &vat_main;
6051 u32 worker_id = ntohl (mp->worker_id);
6054 "\n%-11d %-11s %-6d %-5d %-9s",
6055 ntohl (mp->sw_if_index), (worker_id == 0) ? "main" : "worker",
6056 worker_id, ntohl (mp->queue_id),
6058 1) ? "polling" : ((mp->mode == 2) ? "interrupt" : "adaptive"));
6061 static void vl_api_sw_interface_rx_placement_details_t_handler_json
6062 (vl_api_sw_interface_rx_placement_details_t * mp)
6064 vat_main_t *vam = &vat_main;
6065 vat_json_node_t *node = NULL;
6067 if (VAT_JSON_ARRAY != vam->json_tree.type)
6069 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
6070 vat_json_init_array (&vam->json_tree);
6072 node = vat_json_array_add (&vam->json_tree);
6074 vat_json_init_object (node);
6075 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
6076 vat_json_object_add_uint (node, "worker_id", ntohl (mp->worker_id));
6077 vat_json_object_add_uint (node, "queue_id", ntohl (mp->queue_id));
6078 vat_json_object_add_uint (node, "mode", mp->mode);
6082 api_sw_interface_rx_placement_dump (vat_main_t * vam)
6084 unformat_input_t *i = vam->input;
6085 vl_api_sw_interface_rx_placement_dump_t *mp;
6086 vl_api_control_ping_t *mp_ping;
6089 u8 sw_if_index_set = 0;
6091 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6093 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6095 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6102 "\n%-11s %-11s %-6s %-5s %-4s",
6103 "sw_if_index", "main/worker", "thread", "queue", "mode");
6105 /* Dump Interface rx placement */
6106 M (SW_INTERFACE_RX_PLACEMENT_DUMP, mp);
6108 if (sw_if_index_set)
6109 mp->sw_if_index = htonl (sw_if_index);
6111 mp->sw_if_index = ~0;
6115 /* Use a control ping for synchronization */
6116 MPING (CONTROL_PING, mp_ping);
6124 api_sw_interface_clear_stats (vat_main_t * vam)
6126 unformat_input_t *i = vam->input;
6127 vl_api_sw_interface_clear_stats_t *mp;
6129 u8 sw_if_index_set = 0;
6132 /* Parse args required to build the message */
6133 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6135 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6136 sw_if_index_set = 1;
6137 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6138 sw_if_index_set = 1;
6143 /* Construct the API message */
6144 M (SW_INTERFACE_CLEAR_STATS, mp);
6146 if (sw_if_index_set == 1)
6147 mp->sw_if_index = ntohl (sw_if_index);
6149 mp->sw_if_index = ~0;
6154 /* Wait for a reply, return the good/bad news... */
6160 api_sw_interface_add_del_address (vat_main_t * vam)
6162 unformat_input_t *i = vam->input;
6163 vl_api_sw_interface_add_del_address_t *mp;
6165 u8 sw_if_index_set = 0;
6166 u8 is_add = 1, del_all = 0;
6167 u32 address_length = 0;
6168 u8 v4_address_set = 0;
6169 u8 v6_address_set = 0;
6170 ip4_address_t v4address;
6171 ip6_address_t v6address;
6174 /* Parse args required to build the message */
6175 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6177 if (unformat (i, "del-all"))
6179 else if (unformat (i, "del"))
6182 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6183 sw_if_index_set = 1;
6184 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6185 sw_if_index_set = 1;
6186 else if (unformat (i, "%U/%d",
6187 unformat_ip4_address, &v4address, &address_length))
6189 else if (unformat (i, "%U/%d",
6190 unformat_ip6_address, &v6address, &address_length))
6196 if (sw_if_index_set == 0)
6198 errmsg ("missing interface name or sw_if_index");
6201 if (v4_address_set && v6_address_set)
6203 errmsg ("both v4 and v6 addresses set");
6206 if (!v4_address_set && !v6_address_set && !del_all)
6208 errmsg ("no addresses set");
6212 /* Construct the API message */
6213 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6215 mp->sw_if_index = ntohl (sw_if_index);
6216 mp->is_add = is_add;
6217 mp->del_all = del_all;
6220 mp->prefix.address.af = ADDRESS_IP6;
6221 clib_memcpy (mp->prefix.address.un.ip6, &v6address, sizeof (v6address));
6225 mp->prefix.address.af = ADDRESS_IP4;
6226 clib_memcpy (mp->prefix.address.un.ip4, &v4address, sizeof (v4address));
6228 mp->prefix.len = address_length;
6233 /* Wait for a reply, return good/bad news */
6239 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6241 unformat_input_t *i = vam->input;
6242 vl_api_sw_interface_set_mpls_enable_t *mp;
6244 u8 sw_if_index_set = 0;
6248 /* Parse args required to build the message */
6249 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6251 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6252 sw_if_index_set = 1;
6253 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6254 sw_if_index_set = 1;
6255 else if (unformat (i, "disable"))
6257 else if (unformat (i, "dis"))
6263 if (sw_if_index_set == 0)
6265 errmsg ("missing interface name or sw_if_index");
6269 /* Construct the API message */
6270 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6272 mp->sw_if_index = ntohl (sw_if_index);
6273 mp->enable = enable;
6278 /* Wait for a reply... */
6284 api_sw_interface_set_table (vat_main_t * vam)
6286 unformat_input_t *i = vam->input;
6287 vl_api_sw_interface_set_table_t *mp;
6288 u32 sw_if_index, vrf_id = 0;
6289 u8 sw_if_index_set = 0;
6293 /* Parse args required to build the message */
6294 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6296 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6297 sw_if_index_set = 1;
6298 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6299 sw_if_index_set = 1;
6300 else if (unformat (i, "vrf %d", &vrf_id))
6302 else if (unformat (i, "ipv6"))
6308 if (sw_if_index_set == 0)
6310 errmsg ("missing interface name or sw_if_index");
6314 /* Construct the API message */
6315 M (SW_INTERFACE_SET_TABLE, mp);
6317 mp->sw_if_index = ntohl (sw_if_index);
6318 mp->is_ipv6 = is_ipv6;
6319 mp->vrf_id = ntohl (vrf_id);
6324 /* Wait for a reply... */
6329 static void vl_api_sw_interface_get_table_reply_t_handler
6330 (vl_api_sw_interface_get_table_reply_t * mp)
6332 vat_main_t *vam = &vat_main;
6334 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6336 vam->retval = ntohl (mp->retval);
6337 vam->result_ready = 1;
6341 static void vl_api_sw_interface_get_table_reply_t_handler_json
6342 (vl_api_sw_interface_get_table_reply_t * mp)
6344 vat_main_t *vam = &vat_main;
6345 vat_json_node_t node;
6347 vat_json_init_object (&node);
6348 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6349 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6351 vat_json_print (vam->ofp, &node);
6352 vat_json_free (&node);
6354 vam->retval = ntohl (mp->retval);
6355 vam->result_ready = 1;
6359 api_sw_interface_get_table (vat_main_t * vam)
6361 unformat_input_t *i = vam->input;
6362 vl_api_sw_interface_get_table_t *mp;
6364 u8 sw_if_index_set = 0;
6368 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6370 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6371 sw_if_index_set = 1;
6372 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6373 sw_if_index_set = 1;
6374 else if (unformat (i, "ipv6"))
6380 if (sw_if_index_set == 0)
6382 errmsg ("missing interface name or sw_if_index");
6386 M (SW_INTERFACE_GET_TABLE, mp);
6387 mp->sw_if_index = htonl (sw_if_index);
6388 mp->is_ipv6 = is_ipv6;
6396 api_sw_interface_set_vpath (vat_main_t * vam)
6398 unformat_input_t *i = vam->input;
6399 vl_api_sw_interface_set_vpath_t *mp;
6400 u32 sw_if_index = 0;
6401 u8 sw_if_index_set = 0;
6405 /* Parse args required to build the message */
6406 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6408 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6409 sw_if_index_set = 1;
6410 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6411 sw_if_index_set = 1;
6412 else if (unformat (i, "enable"))
6414 else if (unformat (i, "disable"))
6420 if (sw_if_index_set == 0)
6422 errmsg ("missing interface name or sw_if_index");
6426 /* Construct the API message */
6427 M (SW_INTERFACE_SET_VPATH, mp);
6429 mp->sw_if_index = ntohl (sw_if_index);
6430 mp->enable = is_enable;
6435 /* Wait for a reply... */
6441 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6443 unformat_input_t *i = vam->input;
6444 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6445 u32 sw_if_index = 0;
6446 u8 sw_if_index_set = 0;
6451 /* Parse args required to build the message */
6452 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6454 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6455 sw_if_index_set = 1;
6456 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6457 sw_if_index_set = 1;
6458 else if (unformat (i, "enable"))
6460 else if (unformat (i, "disable"))
6462 else if (unformat (i, "ip4"))
6464 else if (unformat (i, "ip6"))
6470 if (sw_if_index_set == 0)
6472 errmsg ("missing interface name or sw_if_index");
6476 /* Construct the API message */
6477 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6479 mp->sw_if_index = ntohl (sw_if_index);
6480 mp->enable = is_enable;
6481 mp->is_ipv6 = is_ipv6;
6486 /* Wait for a reply... */
6492 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6494 unformat_input_t *i = vam->input;
6495 vl_api_sw_interface_set_l2_xconnect_t *mp;
6497 u8 rx_sw_if_index_set = 0;
6499 u8 tx_sw_if_index_set = 0;
6503 /* Parse args required to build the message */
6504 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6506 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6507 rx_sw_if_index_set = 1;
6508 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6509 tx_sw_if_index_set = 1;
6510 else if (unformat (i, "rx"))
6512 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6514 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6516 rx_sw_if_index_set = 1;
6521 else if (unformat (i, "tx"))
6523 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6525 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6527 tx_sw_if_index_set = 1;
6532 else if (unformat (i, "enable"))
6534 else if (unformat (i, "disable"))
6540 if (rx_sw_if_index_set == 0)
6542 errmsg ("missing rx interface name or rx_sw_if_index");
6546 if (enable && (tx_sw_if_index_set == 0))
6548 errmsg ("missing tx interface name or tx_sw_if_index");
6552 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6554 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6555 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6556 mp->enable = enable;
6564 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6566 unformat_input_t *i = vam->input;
6567 vl_api_sw_interface_set_l2_bridge_t *mp;
6568 vl_api_l2_port_type_t port_type;
6570 u8 rx_sw_if_index_set = 0;
6577 port_type = L2_API_PORT_TYPE_NORMAL;
6579 /* Parse args required to build the message */
6580 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6582 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6583 rx_sw_if_index_set = 1;
6584 else if (unformat (i, "bd_id %d", &bd_id))
6588 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6589 rx_sw_if_index_set = 1;
6590 else if (unformat (i, "shg %d", &shg))
6592 else if (unformat (i, "bvi"))
6593 port_type = L2_API_PORT_TYPE_BVI;
6594 else if (unformat (i, "uu-fwd"))
6595 port_type = L2_API_PORT_TYPE_UU_FWD;
6596 else if (unformat (i, "enable"))
6598 else if (unformat (i, "disable"))
6604 if (rx_sw_if_index_set == 0)
6606 errmsg ("missing rx interface name or sw_if_index");
6610 if (enable && (bd_id_set == 0))
6612 errmsg ("missing bridge domain");
6616 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6618 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6619 mp->bd_id = ntohl (bd_id);
6621 mp->port_type = ntohl (port_type);
6622 mp->enable = enable;
6630 api_bridge_domain_dump (vat_main_t * vam)
6632 unformat_input_t *i = vam->input;
6633 vl_api_bridge_domain_dump_t *mp;
6634 vl_api_control_ping_t *mp_ping;
6638 /* Parse args required to build the message */
6639 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6641 if (unformat (i, "bd_id %d", &bd_id))
6647 M (BRIDGE_DOMAIN_DUMP, mp);
6648 mp->bd_id = ntohl (bd_id);
6651 /* Use a control ping for synchronization */
6652 MPING (CONTROL_PING, mp_ping);
6660 api_bridge_domain_add_del (vat_main_t * vam)
6662 unformat_input_t *i = vam->input;
6663 vl_api_bridge_domain_add_del_t *mp;
6666 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6671 /* Parse args required to build the message */
6672 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6674 if (unformat (i, "bd_id %d", &bd_id))
6676 else if (unformat (i, "flood %d", &flood))
6678 else if (unformat (i, "uu-flood %d", &uu_flood))
6680 else if (unformat (i, "forward %d", &forward))
6682 else if (unformat (i, "learn %d", &learn))
6684 else if (unformat (i, "arp-term %d", &arp_term))
6686 else if (unformat (i, "mac-age %d", &mac_age))
6688 else if (unformat (i, "bd-tag %s", &bd_tag))
6690 else if (unformat (i, "del"))
6693 flood = uu_flood = forward = learn = 0;
6701 errmsg ("missing bridge domain");
6708 errmsg ("mac age must be less than 256 ");
6713 if ((bd_tag) && (vec_len (bd_tag) > 63))
6715 errmsg ("bd-tag cannot be longer than 63");
6720 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6722 mp->bd_id = ntohl (bd_id);
6724 mp->uu_flood = uu_flood;
6725 mp->forward = forward;
6727 mp->arp_term = arp_term;
6728 mp->is_add = is_add;
6729 mp->mac_age = (u8) mac_age;
6732 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
6733 mp->bd_tag[vec_len (bd_tag)] = 0;
6744 api_l2fib_flush_bd (vat_main_t * vam)
6746 unformat_input_t *i = vam->input;
6747 vl_api_l2fib_flush_bd_t *mp;
6751 /* Parse args required to build the message */
6752 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6754 if (unformat (i, "bd_id %d", &bd_id));
6761 errmsg ("missing bridge domain");
6765 M (L2FIB_FLUSH_BD, mp);
6767 mp->bd_id = htonl (bd_id);
6775 api_l2fib_flush_int (vat_main_t * vam)
6777 unformat_input_t *i = vam->input;
6778 vl_api_l2fib_flush_int_t *mp;
6779 u32 sw_if_index = ~0;
6782 /* Parse args required to build the message */
6783 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6785 if (unformat (i, "sw_if_index %d", &sw_if_index));
6787 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6792 if (sw_if_index == ~0)
6794 errmsg ("missing interface name or sw_if_index");
6798 M (L2FIB_FLUSH_INT, mp);
6800 mp->sw_if_index = ntohl (sw_if_index);
6808 api_l2fib_add_del (vat_main_t * vam)
6810 unformat_input_t *i = vam->input;
6811 vl_api_l2fib_add_del_t *mp;
6817 u32 sw_if_index = 0;
6818 u8 sw_if_index_set = 0;
6827 /* Parse args required to build the message */
6828 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6830 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
6832 else if (unformat (i, "bd_id %d", &bd_id))
6834 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6835 sw_if_index_set = 1;
6836 else if (unformat (i, "sw_if"))
6838 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6841 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6842 sw_if_index_set = 1;
6847 else if (unformat (i, "static"))
6849 else if (unformat (i, "filter"))
6854 else if (unformat (i, "bvi"))
6859 else if (unformat (i, "del"))
6861 else if (unformat (i, "count %d", &count))
6869 errmsg ("missing mac address");
6875 errmsg ("missing bridge domain");
6879 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
6881 errmsg ("missing interface name or sw_if_index");
6887 /* Turn on async mode */
6888 vam->async_mode = 1;
6889 vam->async_errors = 0;
6890 before = vat_time_now (vam);
6893 for (j = 0; j < count; j++)
6895 M (L2FIB_ADD_DEL, mp);
6897 clib_memcpy (mp->mac, mac, 6);
6898 mp->bd_id = ntohl (bd_id);
6899 mp->is_add = is_add;
6900 mp->sw_if_index = ntohl (sw_if_index);
6904 mp->static_mac = static_mac;
6905 mp->filter_mac = filter_mac;
6906 mp->bvi_mac = bvi_mac;
6908 increment_mac_address (mac);
6915 vl_api_control_ping_t *mp_ping;
6918 /* Shut off async mode */
6919 vam->async_mode = 0;
6921 MPING (CONTROL_PING, mp_ping);
6924 timeout = vat_time_now (vam) + 1.0;
6925 while (vat_time_now (vam) < timeout)
6926 if (vam->result_ready == 1)
6931 if (vam->retval == -99)
6934 if (vam->async_errors > 0)
6936 errmsg ("%d asynchronous errors", vam->async_errors);
6939 vam->async_errors = 0;
6940 after = vat_time_now (vam);
6942 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6943 count, after - before, count / (after - before));
6949 /* Wait for a reply... */
6953 /* Return the good/bad news */
6954 return (vam->retval);
6958 api_bridge_domain_set_mac_age (vat_main_t * vam)
6960 unformat_input_t *i = vam->input;
6961 vl_api_bridge_domain_set_mac_age_t *mp;
6966 /* Parse args required to build the message */
6967 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6969 if (unformat (i, "bd_id %d", &bd_id));
6970 else if (unformat (i, "mac-age %d", &mac_age));
6977 errmsg ("missing bridge domain");
6983 errmsg ("mac age must be less than 256 ");
6987 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
6989 mp->bd_id = htonl (bd_id);
6990 mp->mac_age = (u8) mac_age;
6998 api_l2_flags (vat_main_t * vam)
7000 unformat_input_t *i = vam->input;
7001 vl_api_l2_flags_t *mp;
7004 u8 sw_if_index_set = 0;
7008 /* Parse args required to build the message */
7009 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7011 if (unformat (i, "sw_if_index %d", &sw_if_index))
7012 sw_if_index_set = 1;
7013 else if (unformat (i, "sw_if"))
7015 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7018 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7019 sw_if_index_set = 1;
7024 else if (unformat (i, "learn"))
7026 else if (unformat (i, "forward"))
7028 else if (unformat (i, "flood"))
7030 else if (unformat (i, "uu-flood"))
7031 flags |= L2_UU_FLOOD;
7032 else if (unformat (i, "arp-term"))
7033 flags |= L2_ARP_TERM;
7034 else if (unformat (i, "off"))
7036 else if (unformat (i, "disable"))
7042 if (sw_if_index_set == 0)
7044 errmsg ("missing interface name or sw_if_index");
7050 mp->sw_if_index = ntohl (sw_if_index);
7051 mp->feature_bitmap = ntohl (flags);
7052 mp->is_set = is_set;
7060 api_bridge_flags (vat_main_t * vam)
7062 unformat_input_t *i = vam->input;
7063 vl_api_bridge_flags_t *mp;
7067 bd_flags_t flags = 0;
7070 /* Parse args required to build the message */
7071 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7073 if (unformat (i, "bd_id %d", &bd_id))
7075 else if (unformat (i, "learn"))
7076 flags |= BRIDGE_API_FLAG_LEARN;
7077 else if (unformat (i, "forward"))
7078 flags |= BRIDGE_API_FLAG_FWD;
7079 else if (unformat (i, "flood"))
7080 flags |= BRIDGE_API_FLAG_FLOOD;
7081 else if (unformat (i, "uu-flood"))
7082 flags |= BRIDGE_API_FLAG_UU_FLOOD;
7083 else if (unformat (i, "arp-term"))
7084 flags |= BRIDGE_API_FLAG_ARP_TERM;
7085 else if (unformat (i, "off"))
7087 else if (unformat (i, "disable"))
7095 errmsg ("missing bridge domain");
7099 M (BRIDGE_FLAGS, mp);
7101 mp->bd_id = ntohl (bd_id);
7102 mp->flags = ntohl (flags);
7103 mp->is_set = is_set;
7111 api_bd_ip_mac_add_del (vat_main_t * vam)
7113 vl_api_address_t ip = VL_API_ZERO_ADDRESS;
7114 vl_api_mac_address_t mac = { 0 };
7115 unformat_input_t *i = vam->input;
7116 vl_api_bd_ip_mac_add_del_t *mp;
7125 /* Parse args required to build the message */
7126 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7128 if (unformat (i, "bd_id %d", &bd_id))
7132 else if (unformat (i, "%U", unformat_vl_api_address, &ip))
7136 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
7140 else if (unformat (i, "del"))
7148 errmsg ("missing bridge domain");
7151 else if (ip_set == 0)
7153 errmsg ("missing IP address");
7156 else if (mac_set == 0)
7158 errmsg ("missing MAC address");
7162 M (BD_IP_MAC_ADD_DEL, mp);
7164 mp->entry.bd_id = ntohl (bd_id);
7165 mp->is_add = is_add;
7167 clib_memcpy (&mp->entry.ip, &ip, sizeof (ip));
7168 clib_memcpy (&mp->entry.mac, &mac, sizeof (mac));
7176 api_bd_ip_mac_flush (vat_main_t * vam)
7178 unformat_input_t *i = vam->input;
7179 vl_api_bd_ip_mac_flush_t *mp;
7184 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7186 if (unformat (i, "bd_id %d", &bd_id))
7196 errmsg ("missing bridge domain");
7200 M (BD_IP_MAC_FLUSH, mp);
7202 mp->bd_id = ntohl (bd_id);
7209 static void vl_api_bd_ip_mac_details_t_handler
7210 (vl_api_bd_ip_mac_details_t * mp)
7212 vat_main_t *vam = &vat_main;
7216 ntohl (mp->entry.bd_id),
7217 format_vl_api_mac_address, mp->entry.mac,
7218 format_vl_api_address, &mp->entry.ip);
7221 static void vl_api_bd_ip_mac_details_t_handler_json
7222 (vl_api_bd_ip_mac_details_t * mp)
7224 vat_main_t *vam = &vat_main;
7225 vat_json_node_t *node = NULL;
7227 if (VAT_JSON_ARRAY != vam->json_tree.type)
7229 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7230 vat_json_init_array (&vam->json_tree);
7232 node = vat_json_array_add (&vam->json_tree);
7234 vat_json_init_object (node);
7235 vat_json_object_add_uint (node, "bd_id", ntohl (mp->entry.bd_id));
7236 vat_json_object_add_string_copy (node, "mac_address",
7237 format (0, "%U", format_vl_api_mac_address,
7241 ip = format (0, "%U", format_vl_api_address, &mp->entry.ip);
7242 vat_json_object_add_string_copy (node, "ip_address", ip);
7247 api_bd_ip_mac_dump (vat_main_t * vam)
7249 unformat_input_t *i = vam->input;
7250 vl_api_bd_ip_mac_dump_t *mp;
7251 vl_api_control_ping_t *mp_ping;
7256 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7258 if (unformat (i, "bd_id %d", &bd_id))
7267 "\n%-5s %-7s %-20s %-30s",
7268 "bd_id", "is_ipv6", "mac_address", "ip_address");
7270 /* Dump Bridge Domain Ip to Mac entries */
7271 M (BD_IP_MAC_DUMP, mp);
7274 mp->bd_id = htonl (bd_id);
7280 /* Use a control ping for synchronization */
7281 MPING (CONTROL_PING, mp_ping);
7289 api_tap_create_v2 (vat_main_t * vam)
7291 unformat_input_t *i = vam->input;
7292 vl_api_tap_create_v2_t *mp;
7296 u32 num_rx_queues = 0;
7297 u8 *host_if_name = 0;
7298 u8 host_if_name_set = 0;
7301 u8 host_mac_addr[6];
7302 u8 host_mac_addr_set = 0;
7303 u8 *host_bridge = 0;
7304 u8 host_bridge_set = 0;
7305 u8 host_ip4_prefix_set = 0;
7306 u8 host_ip6_prefix_set = 0;
7307 ip4_address_t host_ip4_addr;
7308 ip4_address_t host_ip4_gw;
7309 u8 host_ip4_gw_set = 0;
7310 u32 host_ip4_prefix_len = 0;
7311 ip6_address_t host_ip6_addr;
7312 ip6_address_t host_ip6_gw;
7313 u8 host_ip6_gw_set = 0;
7314 u32 host_ip6_prefix_len = 0;
7315 u32 host_mtu_size = 0;
7316 u8 host_mtu_set = 0;
7319 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7321 clib_memset (mac_address, 0, sizeof (mac_address));
7323 /* Parse args required to build the message */
7324 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7326 if (unformat (i, "id %u", &id))
7330 (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7332 else if (unformat (i, "host-if-name %s", &host_if_name))
7333 host_if_name_set = 1;
7334 else if (unformat (i, "num-rx-queues %u", &num_rx_queues))
7336 else if (unformat (i, "host-ns %s", &host_ns))
7338 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
7340 host_mac_addr_set = 1;
7341 else if (unformat (i, "host-bridge %s", &host_bridge))
7342 host_bridge_set = 1;
7343 else if (unformat (i, "host-ip4-addr %U/%u", unformat_ip4_address,
7344 &host_ip4_addr, &host_ip4_prefix_len))
7345 host_ip4_prefix_set = 1;
7346 else if (unformat (i, "host-ip6-addr %U/%u", unformat_ip6_address,
7347 &host_ip6_addr, &host_ip6_prefix_len))
7348 host_ip6_prefix_set = 1;
7349 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
7351 host_ip4_gw_set = 1;
7352 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
7354 host_ip6_gw_set = 1;
7355 else if (unformat (i, "rx-ring-size %u", &rx_ring_sz))
7357 else if (unformat (i, "tx-ring-size %u", &tx_ring_sz))
7359 else if (unformat (i, "host-mtu-size %u", &host_mtu_size))
7361 else if (unformat (i, "no-gso"))
7362 tap_flags &= ~TAP_API_FLAG_GSO;
7363 else if (unformat (i, "gso"))
7364 tap_flags |= TAP_API_FLAG_GSO;
7365 else if (unformat (i, "csum-offload"))
7366 tap_flags |= TAP_API_FLAG_CSUM_OFFLOAD;
7367 else if (unformat (i, "persist"))
7368 tap_flags |= TAP_API_FLAG_PERSIST;
7369 else if (unformat (i, "attach"))
7370 tap_flags |= TAP_API_FLAG_ATTACH;
7371 else if (unformat (i, "tun"))
7372 tap_flags |= TAP_API_FLAG_TUN;
7373 else if (unformat (i, "gro-coalesce"))
7374 tap_flags |= TAP_API_FLAG_GRO_COALESCE;
7375 else if (unformat (i, "packed"))
7376 tap_flags |= TAP_API_FLAG_PACKED;
7377 else if (unformat (i, "in-order"))
7378 tap_flags |= TAP_API_FLAG_IN_ORDER;
7383 if (vec_len (host_if_name) > 63)
7385 errmsg ("tap name too long. ");
7388 if (vec_len (host_ns) > 63)
7390 errmsg ("host name space too long. ");
7393 if (vec_len (host_bridge) > 63)
7395 errmsg ("host bridge name too long. ");
7398 if (host_ip4_prefix_len > 32)
7400 errmsg ("host ip4 prefix length not valid. ");
7403 if (host_ip6_prefix_len > 128)
7405 errmsg ("host ip6 prefix length not valid. ");
7408 if (!is_pow2 (rx_ring_sz))
7410 errmsg ("rx ring size must be power of 2. ");
7413 if (rx_ring_sz > 32768)
7415 errmsg ("rx ring size must be 32768 or lower. ");
7418 if (!is_pow2 (tx_ring_sz))
7420 errmsg ("tx ring size must be power of 2. ");
7423 if (tx_ring_sz > 32768)
7425 errmsg ("tx ring size must be 32768 or lower. ");
7428 if (host_mtu_set && (host_mtu_size < 64 || host_mtu_size > 65355))
7430 errmsg ("host MTU size must be in between 64 and 65355. ");
7434 /* Construct the API message */
7435 M (TAP_CREATE_V2, mp);
7437 mp->id = ntohl (id);
7438 mp->use_random_mac = random_mac;
7439 mp->num_rx_queues = (u8) num_rx_queues;
7440 mp->tx_ring_sz = ntohs (tx_ring_sz);
7441 mp->rx_ring_sz = ntohs (rx_ring_sz);
7442 mp->host_mtu_set = host_mtu_set;
7443 mp->host_mtu_size = ntohl (host_mtu_size);
7444 mp->host_mac_addr_set = host_mac_addr_set;
7445 mp->host_ip4_prefix_set = host_ip4_prefix_set;
7446 mp->host_ip6_prefix_set = host_ip6_prefix_set;
7447 mp->host_ip4_gw_set = host_ip4_gw_set;
7448 mp->host_ip6_gw_set = host_ip6_gw_set;
7449 mp->tap_flags = ntohl (tap_flags);
7450 mp->host_namespace_set = host_ns_set;
7451 mp->host_if_name_set = host_if_name_set;
7452 mp->host_bridge_set = host_bridge_set;
7454 if (random_mac == 0)
7455 clib_memcpy (mp->mac_address, mac_address, 6);
7456 if (host_mac_addr_set)
7457 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
7458 if (host_if_name_set)
7459 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
7461 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
7462 if (host_bridge_set)
7463 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
7464 if (host_ip4_prefix_set)
7466 clib_memcpy (mp->host_ip4_prefix.address, &host_ip4_addr, 4);
7467 mp->host_ip4_prefix.len = (u8) host_ip4_prefix_len;
7469 if (host_ip6_prefix_set)
7471 clib_memcpy (mp->host_ip6_prefix.address, &host_ip6_addr, 16);
7472 mp->host_ip6_prefix.len = (u8) host_ip6_prefix_len;
7474 if (host_ip4_gw_set)
7475 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
7476 if (host_ip6_gw_set)
7477 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
7480 vec_free (host_if_name);
7481 vec_free (host_bridge);
7486 /* Wait for a reply... */
7492 api_tap_delete_v2 (vat_main_t * vam)
7494 unformat_input_t *i = vam->input;
7495 vl_api_tap_delete_v2_t *mp;
7496 u32 sw_if_index = ~0;
7497 u8 sw_if_index_set = 0;
7500 /* Parse args required to build the message */
7501 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7503 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7504 sw_if_index_set = 1;
7505 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7506 sw_if_index_set = 1;
7511 if (sw_if_index_set == 0)
7513 errmsg ("missing vpp interface name. ");
7517 /* Construct the API message */
7518 M (TAP_DELETE_V2, mp);
7520 mp->sw_if_index = ntohl (sw_if_index);
7525 /* Wait for a reply... */
7531 unformat_vlib_pci_addr (unformat_input_t * input, va_list * args)
7533 vlib_pci_addr_t *addr = va_arg (*args, vlib_pci_addr_t *);
7536 if (!unformat (input, "%x:%x:%x.%x", &x[0], &x[1], &x[2], &x[3]))
7539 addr->domain = x[0];
7542 addr->function = x[3];
7548 api_virtio_pci_create_v2 (vat_main_t * vam)
7550 unformat_input_t *i = vam->input;
7551 vl_api_virtio_pci_create_v2_t *mp;
7555 u64 features = (u64) ~ (0ULL);
7556 u32 virtio_flags = 0;
7559 clib_memset (mac_address, 0, sizeof (mac_address));
7561 /* Parse args required to build the message */
7562 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7564 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7568 else if (unformat (i, "pci-addr %U", unformat_vlib_pci_addr, &pci_addr))
7570 else if (unformat (i, "features 0x%llx", &features))
7572 else if (unformat (i, "gso-enabled"))
7573 virtio_flags |= VIRTIO_API_FLAG_GSO;
7574 else if (unformat (i, "csum-offload-enabled"))
7575 virtio_flags |= VIRTIO_API_FLAG_CSUM_OFFLOAD;
7576 else if (unformat (i, "gro-coalesce"))
7577 virtio_flags |= VIRTIO_API_FLAG_GRO_COALESCE;
7578 else if (unformat (i, "packed"))
7579 virtio_flags |= VIRTIO_API_FLAG_PACKED;
7580 else if (unformat (i, "in-order"))
7581 virtio_flags |= VIRTIO_API_FLAG_IN_ORDER;
7588 errmsg ("pci address must be non zero. ");
7592 /* Construct the API message */
7593 M (VIRTIO_PCI_CREATE_V2, mp);
7595 mp->use_random_mac = random_mac;
7597 mp->pci_addr.domain = htons (((vlib_pci_addr_t) pci_addr).domain);
7598 mp->pci_addr.bus = ((vlib_pci_addr_t) pci_addr).bus;
7599 mp->pci_addr.slot = ((vlib_pci_addr_t) pci_addr).slot;
7600 mp->pci_addr.function = ((vlib_pci_addr_t) pci_addr).function;
7602 mp->features = clib_host_to_net_u64 (features);
7603 mp->virtio_flags = clib_host_to_net_u32 (virtio_flags);
7605 if (random_mac == 0)
7606 clib_memcpy (mp->mac_address, mac_address, 6);
7611 /* Wait for a reply... */
7617 api_virtio_pci_delete (vat_main_t * vam)
7619 unformat_input_t *i = vam->input;
7620 vl_api_virtio_pci_delete_t *mp;
7621 u32 sw_if_index = ~0;
7622 u8 sw_if_index_set = 0;
7625 /* Parse args required to build the message */
7626 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7628 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7629 sw_if_index_set = 1;
7630 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7631 sw_if_index_set = 1;
7636 if (sw_if_index_set == 0)
7638 errmsg ("missing vpp interface name. ");
7642 /* Construct the API message */
7643 M (VIRTIO_PCI_DELETE, mp);
7645 mp->sw_if_index = htonl (sw_if_index);
7650 /* Wait for a reply... */
7656 api_bond_create (vat_main_t * vam)
7658 unformat_input_t *i = vam->input;
7659 vl_api_bond_create_t *mp;
7669 clib_memset (mac_address, 0, sizeof (mac_address));
7672 /* Parse args required to build the message */
7673 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7675 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
7677 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
7678 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
7680 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
7683 else if (unformat (i, "numa-only"))
7685 else if (unformat (i, "id %u", &id))
7691 if (mode_is_set == 0)
7693 errmsg ("Missing bond mode. ");
7697 /* Construct the API message */
7698 M (BOND_CREATE, mp);
7700 mp->use_custom_mac = custom_mac;
7702 mp->mode = htonl (mode);
7703 mp->lb = htonl (lb);
7704 mp->id = htonl (id);
7705 mp->numa_only = numa_only;
7708 clib_memcpy (mp->mac_address, mac_address, 6);
7713 /* Wait for a reply... */
7719 api_bond_create2 (vat_main_t * vam)
7721 unformat_input_t *i = vam->input;
7722 vl_api_bond_create2_t *mp;
7733 clib_memset (mac_address, 0, sizeof (mac_address));
7736 /* Parse args required to build the message */
7737 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7739 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
7741 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
7742 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
7744 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
7747 else if (unformat (i, "numa-only"))
7749 else if (unformat (i, "gso"))
7751 else if (unformat (i, "id %u", &id))
7757 if (mode_is_set == 0)
7759 errmsg ("Missing bond mode. ");
7763 /* Construct the API message */
7764 M (BOND_CREATE2, mp);
7766 mp->use_custom_mac = custom_mac;
7768 mp->mode = htonl (mode);
7769 mp->lb = htonl (lb);
7770 mp->id = htonl (id);
7771 mp->numa_only = numa_only;
7772 mp->enable_gso = gso;
7775 clib_memcpy (mp->mac_address, mac_address, 6);
7780 /* Wait for a reply... */
7786 api_bond_delete (vat_main_t * vam)
7788 unformat_input_t *i = vam->input;
7789 vl_api_bond_delete_t *mp;
7790 u32 sw_if_index = ~0;
7791 u8 sw_if_index_set = 0;
7794 /* Parse args required to build the message */
7795 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7797 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7798 sw_if_index_set = 1;
7799 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7800 sw_if_index_set = 1;
7805 if (sw_if_index_set == 0)
7807 errmsg ("missing vpp interface name. ");
7811 /* Construct the API message */
7812 M (BOND_DELETE, mp);
7814 mp->sw_if_index = ntohl (sw_if_index);
7819 /* Wait for a reply... */
7825 api_bond_add_member (vat_main_t * vam)
7827 unformat_input_t *i = vam->input;
7828 vl_api_bond_add_member_t *mp;
7829 u32 bond_sw_if_index;
7833 u32 bond_sw_if_index_is_set = 0;
7835 u8 sw_if_index_is_set = 0;
7837 /* Parse args required to build the message */
7838 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7840 if (unformat (i, "sw_if_index %d", &sw_if_index))
7841 sw_if_index_is_set = 1;
7842 else if (unformat (i, "bond %u", &bond_sw_if_index))
7843 bond_sw_if_index_is_set = 1;
7844 else if (unformat (i, "passive %d", &is_passive))
7846 else if (unformat (i, "long-timeout %d", &is_long_timeout))
7852 if (bond_sw_if_index_is_set == 0)
7854 errmsg ("Missing bond sw_if_index. ");
7857 if (sw_if_index_is_set == 0)
7859 errmsg ("Missing member sw_if_index. ");
7863 /* Construct the API message */
7864 M (BOND_ADD_MEMBER, mp);
7866 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
7867 mp->sw_if_index = ntohl (sw_if_index);
7868 mp->is_long_timeout = is_long_timeout;
7869 mp->is_passive = is_passive;
7874 /* Wait for a reply... */
7880 api_bond_detach_member (vat_main_t * vam)
7882 unformat_input_t *i = vam->input;
7883 vl_api_bond_detach_member_t *mp;
7884 u32 sw_if_index = ~0;
7885 u8 sw_if_index_set = 0;
7888 /* Parse args required to build the message */
7889 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7891 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7892 sw_if_index_set = 1;
7893 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7894 sw_if_index_set = 1;
7899 if (sw_if_index_set == 0)
7901 errmsg ("missing vpp interface name. ");
7905 /* Construct the API message */
7906 M (BOND_DETACH_MEMBER, mp);
7908 mp->sw_if_index = ntohl (sw_if_index);
7913 /* Wait for a reply... */
7919 api_ip_table_add_del (vat_main_t * vam)
7921 unformat_input_t *i = vam->input;
7922 vl_api_ip_table_add_del_t *mp;
7928 /* Parse args required to build the message */
7929 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7931 if (unformat (i, "ipv6"))
7933 else if (unformat (i, "del"))
7935 else if (unformat (i, "add"))
7937 else if (unformat (i, "table %d", &table_id))
7941 clib_warning ("parse error '%U'", format_unformat_error, i);
7948 errmsg ("missing table-ID");
7952 /* Construct the API message */
7953 M (IP_TABLE_ADD_DEL, mp);
7955 mp->table.table_id = ntohl (table_id);
7956 mp->table.is_ip6 = is_ipv6;
7957 mp->is_add = is_add;
7962 /* Wait for a reply... */
7969 unformat_fib_path (unformat_input_t * input, va_list * args)
7971 vat_main_t *vam = va_arg (*args, vat_main_t *);
7972 vl_api_fib_path_t *path = va_arg (*args, vl_api_fib_path_t *);
7973 u32 weight, preference;
7974 mpls_label_t out_label;
7976 clib_memset (path, 0, sizeof (*path));
7978 path->sw_if_index = ~0;
7982 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7984 if (unformat (input, "%U %U",
7985 unformat_vl_api_ip4_address,
7986 &path->nh.address.ip4,
7987 api_unformat_sw_if_index, vam, &path->sw_if_index))
7989 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7991 else if (unformat (input, "%U %U",
7992 unformat_vl_api_ip6_address,
7993 &path->nh.address.ip6,
7994 api_unformat_sw_if_index, vam, &path->sw_if_index))
7996 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7998 else if (unformat (input, "weight %u", &weight))
8000 path->weight = weight;
8002 else if (unformat (input, "preference %u", &preference))
8004 path->preference = preference;
8006 else if (unformat (input, "%U next-hop-table %d",
8007 unformat_vl_api_ip4_address,
8008 &path->nh.address.ip4, &path->table_id))
8010 path->proto = FIB_API_PATH_NH_PROTO_IP4;
8012 else if (unformat (input, "%U next-hop-table %d",
8013 unformat_vl_api_ip6_address,
8014 &path->nh.address.ip6, &path->table_id))
8016 path->proto = FIB_API_PATH_NH_PROTO_IP6;
8018 else if (unformat (input, "%U",
8019 unformat_vl_api_ip4_address, &path->nh.address.ip4))
8022 * the recursive next-hops are by default in the default table
8025 path->sw_if_index = ~0;
8026 path->proto = FIB_API_PATH_NH_PROTO_IP4;
8028 else if (unformat (input, "%U",
8029 unformat_vl_api_ip6_address, &path->nh.address.ip6))
8032 * the recursive next-hops are by default in the default table
8035 path->sw_if_index = ~0;
8036 path->proto = FIB_API_PATH_NH_PROTO_IP6;
8038 else if (unformat (input, "resolve-via-host"))
8040 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_HOST;
8042 else if (unformat (input, "resolve-via-attached"))
8044 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED;
8046 else if (unformat (input, "ip4-lookup-in-table %d", &path->table_id))
8048 path->type = FIB_API_PATH_TYPE_LOCAL;
8049 path->sw_if_index = ~0;
8050 path->proto = FIB_API_PATH_NH_PROTO_IP4;
8052 else if (unformat (input, "ip6-lookup-in-table %d", &path->table_id))
8054 path->type = FIB_API_PATH_TYPE_LOCAL;
8055 path->sw_if_index = ~0;
8056 path->proto = FIB_API_PATH_NH_PROTO_IP6;
8058 else if (unformat (input, "sw_if_index %d", &path->sw_if_index))
8060 else if (unformat (input, "via-label %d", &path->nh.via_label))
8062 path->proto = FIB_API_PATH_NH_PROTO_MPLS;
8063 path->sw_if_index = ~0;
8065 else if (unformat (input, "l2-input-on %d", &path->sw_if_index))
8067 path->proto = FIB_API_PATH_NH_PROTO_ETHERNET;
8068 path->type = FIB_API_PATH_TYPE_INTERFACE_RX;
8070 else if (unformat (input, "local"))
8072 path->type = FIB_API_PATH_TYPE_LOCAL;
8074 else if (unformat (input, "out-labels"))
8076 while (unformat (input, "%d", &out_label))
8078 path->label_stack[path->n_labels].label = out_label;
8079 path->label_stack[path->n_labels].is_uniform = 0;
8080 path->label_stack[path->n_labels].ttl = 64;
8084 else if (unformat (input, "via"))
8086 /* new path, back up and return */
8087 unformat_put_input (input);
8088 unformat_put_input (input);
8089 unformat_put_input (input);
8090 unformat_put_input (input);
8099 path->proto = ntohl (path->proto);
8100 path->type = ntohl (path->type);
8101 path->flags = ntohl (path->flags);
8102 path->table_id = ntohl (path->table_id);
8103 path->sw_if_index = ntohl (path->sw_if_index);
8109 api_ip_route_add_del (vat_main_t * vam)
8111 unformat_input_t *i = vam->input;
8112 vl_api_ip_route_add_del_t *mp;
8115 u8 is_multipath = 0;
8118 vl_api_prefix_t pfx = { };
8119 vl_api_fib_path_t paths[8];
8123 u32 random_add_del = 0;
8124 u32 *random_vector = 0;
8125 u32 random_seed = 0xdeaddabe;
8127 /* Parse args required to build the message */
8128 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8130 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
8132 else if (unformat (i, "del"))
8134 else if (unformat (i, "add"))
8136 else if (unformat (i, "vrf %d", &vrf_id))
8138 else if (unformat (i, "count %d", &count))
8140 else if (unformat (i, "random"))
8142 else if (unformat (i, "multipath"))
8144 else if (unformat (i, "seed %d", &random_seed))
8148 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8151 if (8 == path_count)
8153 errmsg ("max 8 paths");
8159 clib_warning ("parse error '%U'", format_unformat_error, i);
8166 errmsg ("specify a path; via ...");
8169 if (prefix_set == 0)
8171 errmsg ("missing prefix");
8175 /* Generate a pile of unique, random routes */
8178 ip4_address_t *i = (ip4_address_t *) & paths[0].nh.address.ip4;
8179 u32 this_random_address;
8182 random_hash = hash_create (count, sizeof (uword));
8184 hash_set (random_hash, i->as_u32, 1);
8185 for (j = 0; j <= count; j++)
8189 this_random_address = random_u32 (&random_seed);
8190 this_random_address =
8191 clib_host_to_net_u32 (this_random_address);
8193 while (hash_get (random_hash, this_random_address));
8194 vec_add1 (random_vector, this_random_address);
8195 hash_set (random_hash, this_random_address, 1);
8197 hash_free (random_hash);
8198 set_ip4_address (&pfx.address, random_vector[0]);
8203 /* Turn on async mode */
8204 vam->async_mode = 1;
8205 vam->async_errors = 0;
8206 before = vat_time_now (vam);
8209 for (j = 0; j < count; j++)
8211 /* Construct the API message */
8212 M2 (IP_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8214 mp->is_add = is_add;
8215 mp->is_multipath = is_multipath;
8217 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
8218 mp->route.table_id = ntohl (vrf_id);
8219 mp->route.n_paths = path_count;
8221 clib_memcpy (&mp->route.paths, &paths, sizeof (paths[0]) * path_count);
8224 set_ip4_address (&pfx.address, random_vector[j + 1]);
8226 increment_address (&pfx.address);
8229 /* If we receive SIGTERM, stop now... */
8234 /* When testing multiple add/del ops, use a control-ping to sync */
8237 vl_api_control_ping_t *mp_ping;
8241 /* Shut off async mode */
8242 vam->async_mode = 0;
8244 MPING (CONTROL_PING, mp_ping);
8247 timeout = vat_time_now (vam) + 1.0;
8248 while (vat_time_now (vam) < timeout)
8249 if (vam->result_ready == 1)
8254 if (vam->retval == -99)
8257 if (vam->async_errors > 0)
8259 errmsg ("%d asynchronous errors", vam->async_errors);
8262 vam->async_errors = 0;
8263 after = vat_time_now (vam);
8265 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8269 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8270 count, after - before, count / (after - before));
8276 /* Wait for a reply... */
8281 /* Return the good/bad news */
8282 return (vam->retval);
8286 api_ip_mroute_add_del (vat_main_t * vam)
8288 unformat_input_t *i = vam->input;
8289 u8 path_set = 0, prefix_set = 0, is_add = 1;
8290 vl_api_ip_mroute_add_del_t *mp;
8291 mfib_entry_flags_t eflags = 0;
8292 vl_api_mfib_path_t path;
8293 vl_api_mprefix_t pfx = { };
8297 /* Parse args required to build the message */
8298 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8300 if (unformat (i, "%U", unformat_vl_api_mprefix, &pfx))
8303 pfx.grp_address_length = htons (pfx.grp_address_length);
8305 else if (unformat (i, "del"))
8307 else if (unformat (i, "add"))
8309 else if (unformat (i, "vrf %d", &vrf_id))
8311 else if (unformat (i, "%U", unformat_mfib_itf_flags, &path.itf_flags))
8312 path.itf_flags = htonl (path.itf_flags);
8313 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8315 else if (unformat (i, "via %U", unformat_fib_path, vam, &path.path))
8319 clib_warning ("parse error '%U'", format_unformat_error, i);
8324 if (prefix_set == 0)
8326 errmsg ("missing addresses\n");
8331 errmsg ("missing path\n");
8335 /* Construct the API message */
8336 M (IP_MROUTE_ADD_DEL, mp);
8338 mp->is_add = is_add;
8339 mp->is_multipath = 1;
8341 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
8342 mp->route.table_id = htonl (vrf_id);
8343 mp->route.n_paths = 1;
8344 mp->route.entry_flags = htonl (eflags);
8346 clib_memcpy (&mp->route.paths, &path, sizeof (path));
8350 /* Wait for a reply... */
8356 api_mpls_table_add_del (vat_main_t * vam)
8358 unformat_input_t *i = vam->input;
8359 vl_api_mpls_table_add_del_t *mp;
8364 /* Parse args required to build the message */
8365 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8367 if (unformat (i, "table %d", &table_id))
8369 else if (unformat (i, "del"))
8371 else if (unformat (i, "add"))
8375 clib_warning ("parse error '%U'", format_unformat_error, i);
8382 errmsg ("missing table-ID");
8386 /* Construct the API message */
8387 M (MPLS_TABLE_ADD_DEL, mp);
8389 mp->mt_table.mt_table_id = ntohl (table_id);
8390 mp->mt_is_add = is_add;
8395 /* Wait for a reply... */
8402 api_mpls_route_add_del (vat_main_t * vam)
8404 u8 is_add = 1, path_count = 0, is_multipath = 0, is_eos = 0;
8405 mpls_label_t local_label = MPLS_LABEL_INVALID;
8406 unformat_input_t *i = vam->input;
8407 vl_api_mpls_route_add_del_t *mp;
8408 vl_api_fib_path_t paths[8];
8412 /* Parse args required to build the message */
8413 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8415 if (unformat (i, "%d", &local_label))
8417 else if (unformat (i, "eos"))
8419 else if (unformat (i, "non-eos"))
8421 else if (unformat (i, "del"))
8423 else if (unformat (i, "add"))
8425 else if (unformat (i, "multipath"))
8427 else if (unformat (i, "count %d", &count))
8431 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8434 if (8 == path_count)
8436 errmsg ("max 8 paths");
8442 clib_warning ("parse error '%U'", format_unformat_error, i);
8449 errmsg ("specify a path; via ...");
8453 if (MPLS_LABEL_INVALID == local_label)
8455 errmsg ("missing label");
8461 /* Turn on async mode */
8462 vam->async_mode = 1;
8463 vam->async_errors = 0;
8464 before = vat_time_now (vam);
8467 for (j = 0; j < count; j++)
8469 /* Construct the API message */
8470 M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8472 mp->mr_is_add = is_add;
8473 mp->mr_is_multipath = is_multipath;
8475 mp->mr_route.mr_label = local_label;
8476 mp->mr_route.mr_eos = is_eos;
8477 mp->mr_route.mr_table_id = 0;
8478 mp->mr_route.mr_n_paths = path_count;
8480 clib_memcpy (&mp->mr_route.mr_paths, paths,
8481 sizeof (paths[0]) * path_count);
8487 /* If we receive SIGTERM, stop now... */
8492 /* When testing multiple add/del ops, use a control-ping to sync */
8495 vl_api_control_ping_t *mp_ping;
8499 /* Shut off async mode */
8500 vam->async_mode = 0;
8502 MPING (CONTROL_PING, mp_ping);
8505 timeout = vat_time_now (vam) + 1.0;
8506 while (vat_time_now (vam) < timeout)
8507 if (vam->result_ready == 1)
8512 if (vam->retval == -99)
8515 if (vam->async_errors > 0)
8517 errmsg ("%d asynchronous errors", vam->async_errors);
8520 vam->async_errors = 0;
8521 after = vat_time_now (vam);
8523 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8527 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8528 count, after - before, count / (after - before));
8534 /* Wait for a reply... */
8539 /* Return the good/bad news */
8540 return (vam->retval);
8545 api_mpls_ip_bind_unbind (vat_main_t * vam)
8547 unformat_input_t *i = vam->input;
8548 vl_api_mpls_ip_bind_unbind_t *mp;
8549 u32 ip_table_id = 0;
8551 vl_api_prefix_t pfx;
8553 mpls_label_t local_label = MPLS_LABEL_INVALID;
8556 /* Parse args required to build the message */
8557 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8559 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
8561 else if (unformat (i, "%d", &local_label))
8563 else if (unformat (i, "table-id %d", &ip_table_id))
8565 else if (unformat (i, "unbind"))
8567 else if (unformat (i, "bind"))
8571 clib_warning ("parse error '%U'", format_unformat_error, i);
8578 errmsg ("IP prefix not set");
8582 if (MPLS_LABEL_INVALID == local_label)
8584 errmsg ("missing label");
8588 /* Construct the API message */
8589 M (MPLS_IP_BIND_UNBIND, mp);
8591 mp->mb_is_bind = is_bind;
8592 mp->mb_ip_table_id = ntohl (ip_table_id);
8593 mp->mb_mpls_table_id = 0;
8594 mp->mb_label = ntohl (local_label);
8595 clib_memcpy (&mp->mb_prefix, &pfx, sizeof (pfx));
8600 /* Wait for a reply... */
8607 api_sr_mpls_policy_add (vat_main_t * vam)
8609 unformat_input_t *i = vam->input;
8610 vl_api_sr_mpls_policy_add_t *mp;
8616 u32 *segments = NULL;
8619 /* Parse args required to build the message */
8620 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8622 if (unformat (i, "bsid %d", &bsid))
8624 else if (unformat (i, "weight %d", &weight))
8626 else if (unformat (i, "spray"))
8628 else if (unformat (i, "next %d", &sid))
8631 vec_add1 (segments, htonl (sid));
8635 clib_warning ("parse error '%U'", format_unformat_error, i);
8642 errmsg ("bsid not set");
8646 if (n_segments == 0)
8648 errmsg ("no sid in segment stack");
8652 /* Construct the API message */
8653 M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
8655 mp->bsid = htonl (bsid);
8656 mp->weight = htonl (weight);
8657 mp->is_spray = type;
8658 mp->n_segments = n_segments;
8659 memcpy (mp->segments, segments, sizeof (u32) * n_segments);
8660 vec_free (segments);
8665 /* Wait for a reply... */
8671 api_sr_mpls_policy_del (vat_main_t * vam)
8673 unformat_input_t *i = vam->input;
8674 vl_api_sr_mpls_policy_del_t *mp;
8678 /* Parse args required to build the message */
8679 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8681 if (unformat (i, "bsid %d", &bsid))
8685 clib_warning ("parse error '%U'", format_unformat_error, i);
8692 errmsg ("bsid not set");
8696 /* Construct the API message */
8697 M (SR_MPLS_POLICY_DEL, mp);
8699 mp->bsid = htonl (bsid);
8704 /* Wait for a reply... */
8710 api_bier_table_add_del (vat_main_t * vam)
8712 unformat_input_t *i = vam->input;
8713 vl_api_bier_table_add_del_t *mp;
8715 u32 set = 0, sub_domain = 0, hdr_len = 3;
8716 mpls_label_t local_label = MPLS_LABEL_INVALID;
8719 /* Parse args required to build the message */
8720 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8722 if (unformat (i, "sub-domain %d", &sub_domain))
8724 else if (unformat (i, "set %d", &set))
8726 else if (unformat (i, "label %d", &local_label))
8728 else if (unformat (i, "hdr-len %d", &hdr_len))
8730 else if (unformat (i, "add"))
8732 else if (unformat (i, "del"))
8736 clib_warning ("parse error '%U'", format_unformat_error, i);
8741 if (MPLS_LABEL_INVALID == local_label)
8743 errmsg ("missing label\n");
8747 /* Construct the API message */
8748 M (BIER_TABLE_ADD_DEL, mp);
8750 mp->bt_is_add = is_add;
8751 mp->bt_label = ntohl (local_label);
8752 mp->bt_tbl_id.bt_set = set;
8753 mp->bt_tbl_id.bt_sub_domain = sub_domain;
8754 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
8759 /* Wait for a reply... */
8766 api_bier_route_add_del (vat_main_t * vam)
8768 unformat_input_t *i = vam->input;
8769 vl_api_bier_route_add_del_t *mp;
8771 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
8772 ip4_address_t v4_next_hop_address;
8773 ip6_address_t v6_next_hop_address;
8774 u8 next_hop_set = 0;
8775 u8 next_hop_proto_is_ip4 = 1;
8776 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8779 /* Parse args required to build the message */
8780 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8782 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
8784 next_hop_proto_is_ip4 = 1;
8787 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
8789 next_hop_proto_is_ip4 = 0;
8792 if (unformat (i, "sub-domain %d", &sub_domain))
8794 else if (unformat (i, "set %d", &set))
8796 else if (unformat (i, "hdr-len %d", &hdr_len))
8798 else if (unformat (i, "bp %d", &bp))
8800 else if (unformat (i, "add"))
8802 else if (unformat (i, "del"))
8804 else if (unformat (i, "out-label %d", &next_hop_out_label))
8808 clib_warning ("parse error '%U'", format_unformat_error, i);
8813 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
8815 errmsg ("next hop / label set\n");
8820 errmsg ("bit=position not set\n");
8824 /* Construct the API message */
8825 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
8827 mp->br_is_add = is_add;
8828 mp->br_route.br_tbl_id.bt_set = set;
8829 mp->br_route.br_tbl_id.bt_sub_domain = sub_domain;
8830 mp->br_route.br_tbl_id.bt_hdr_len_id = hdr_len;
8831 mp->br_route.br_bp = ntohs (bp);
8832 mp->br_route.br_n_paths = 1;
8833 mp->br_route.br_paths[0].n_labels = 1;
8834 mp->br_route.br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
8835 mp->br_route.br_paths[0].proto = (next_hop_proto_is_ip4 ?
8836 FIB_API_PATH_NH_PROTO_IP4 :
8837 FIB_API_PATH_NH_PROTO_IP6);
8839 if (next_hop_proto_is_ip4)
8841 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip4,
8842 &v4_next_hop_address, sizeof (v4_next_hop_address));
8846 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip6,
8847 &v6_next_hop_address, sizeof (v6_next_hop_address));
8853 /* Wait for a reply... */
8860 api_mpls_tunnel_add_del (vat_main_t * vam)
8862 unformat_input_t *i = vam->input;
8863 vl_api_mpls_tunnel_add_del_t *mp;
8865 vl_api_fib_path_t paths[8];
8866 u32 sw_if_index = ~0;
8872 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8874 if (unformat (i, "add"))
8878 (i, "del %U", api_unformat_sw_if_index, vam, &sw_if_index))
8880 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
8882 else if (unformat (i, "l2-only"))
8886 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8889 if (8 == path_count)
8891 errmsg ("max 8 paths");
8897 clib_warning ("parse error '%U'", format_unformat_error, i);
8902 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8904 mp->mt_is_add = is_add;
8905 mp->mt_tunnel.mt_sw_if_index = ntohl (sw_if_index);
8906 mp->mt_tunnel.mt_l2_only = l2_only;
8907 mp->mt_tunnel.mt_is_multicast = 0;
8908 mp->mt_tunnel.mt_n_paths = path_count;
8910 clib_memcpy (&mp->mt_tunnel.mt_paths, &paths,
8911 sizeof (paths[0]) * path_count);
8919 api_sw_interface_set_unnumbered (vat_main_t * vam)
8921 unformat_input_t *i = vam->input;
8922 vl_api_sw_interface_set_unnumbered_t *mp;
8924 u32 unnum_sw_index = ~0;
8926 u8 sw_if_index_set = 0;
8929 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8931 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8932 sw_if_index_set = 1;
8933 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8934 sw_if_index_set = 1;
8935 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
8937 else if (unformat (i, "del"))
8941 clib_warning ("parse error '%U'", format_unformat_error, i);
8946 if (sw_if_index_set == 0)
8948 errmsg ("missing interface name or sw_if_index");
8952 M (SW_INTERFACE_SET_UNNUMBERED, mp);
8954 mp->sw_if_index = ntohl (sw_if_index);
8955 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
8956 mp->is_add = is_add;
8965 api_create_vlan_subif (vat_main_t * vam)
8967 unformat_input_t *i = vam->input;
8968 vl_api_create_vlan_subif_t *mp;
8970 u8 sw_if_index_set = 0;
8975 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8977 if (unformat (i, "sw_if_index %d", &sw_if_index))
8978 sw_if_index_set = 1;
8980 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8981 sw_if_index_set = 1;
8982 else if (unformat (i, "vlan %d", &vlan_id))
8986 clib_warning ("parse error '%U'", format_unformat_error, i);
8991 if (sw_if_index_set == 0)
8993 errmsg ("missing interface name or sw_if_index");
8997 if (vlan_id_set == 0)
8999 errmsg ("missing vlan_id");
9002 M (CREATE_VLAN_SUBIF, mp);
9004 mp->sw_if_index = ntohl (sw_if_index);
9005 mp->vlan_id = ntohl (vlan_id);
9012 #define foreach_create_subif_bit \
9019 _(outer_vlan_id_any) \
9020 _(inner_vlan_id_any)
9022 #define foreach_create_subif_flag \
9027 _(4, "exact_match") \
9028 _(5, "default_sub") \
9029 _(6, "outer_vlan_id_any") \
9030 _(7, "inner_vlan_id_any")
9033 api_create_subif (vat_main_t * vam)
9035 unformat_input_t *i = vam->input;
9036 vl_api_create_subif_t *mp;
9038 u8 sw_if_index_set = 0;
9041 u32 __attribute__ ((unused)) no_tags = 0;
9042 u32 __attribute__ ((unused)) one_tag = 0;
9043 u32 __attribute__ ((unused)) two_tags = 0;
9044 u32 __attribute__ ((unused)) dot1ad = 0;
9045 u32 __attribute__ ((unused)) exact_match = 0;
9046 u32 __attribute__ ((unused)) default_sub = 0;
9047 u32 __attribute__ ((unused)) outer_vlan_id_any = 0;
9048 u32 __attribute__ ((unused)) inner_vlan_id_any = 0;
9050 u16 outer_vlan_id = 0;
9051 u16 inner_vlan_id = 0;
9054 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9056 if (unformat (i, "sw_if_index %d", &sw_if_index))
9057 sw_if_index_set = 1;
9059 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9060 sw_if_index_set = 1;
9061 else if (unformat (i, "sub_id %d", &sub_id))
9063 else if (unformat (i, "outer_vlan_id %d", &tmp))
9064 outer_vlan_id = tmp;
9065 else if (unformat (i, "inner_vlan_id %d", &tmp))
9066 inner_vlan_id = tmp;
9068 #define _(a) else if (unformat (i, #a)) a = 1 ;
9069 foreach_create_subif_bit
9073 clib_warning ("parse error '%U'", format_unformat_error, i);
9078 if (sw_if_index_set == 0)
9080 errmsg ("missing interface name or sw_if_index");
9084 if (sub_id_set == 0)
9086 errmsg ("missing sub_id");
9089 M (CREATE_SUBIF, mp);
9091 mp->sw_if_index = ntohl (sw_if_index);
9092 mp->sub_id = ntohl (sub_id);
9094 #define _(a,b) mp->sub_if_flags |= (1 << a);
9095 foreach_create_subif_flag;
9098 mp->outer_vlan_id = ntohs (outer_vlan_id);
9099 mp->inner_vlan_id = ntohs (inner_vlan_id);
9107 api_ip_table_replace_begin (vat_main_t * vam)
9109 unformat_input_t *i = vam->input;
9110 vl_api_ip_table_replace_begin_t *mp;
9115 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9117 if (unformat (i, "table %d", &table_id))
9119 else if (unformat (i, "ipv6"))
9123 clib_warning ("parse error '%U'", format_unformat_error, i);
9128 M (IP_TABLE_REPLACE_BEGIN, mp);
9130 mp->table.table_id = ntohl (table_id);
9131 mp->table.is_ip6 = is_ipv6;
9139 api_ip_table_flush (vat_main_t * vam)
9141 unformat_input_t *i = vam->input;
9142 vl_api_ip_table_flush_t *mp;
9147 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9149 if (unformat (i, "table %d", &table_id))
9151 else if (unformat (i, "ipv6"))
9155 clib_warning ("parse error '%U'", format_unformat_error, i);
9160 M (IP_TABLE_FLUSH, mp);
9162 mp->table.table_id = ntohl (table_id);
9163 mp->table.is_ip6 = is_ipv6;
9171 api_ip_table_replace_end (vat_main_t * vam)
9173 unformat_input_t *i = vam->input;
9174 vl_api_ip_table_replace_end_t *mp;
9179 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9181 if (unformat (i, "table %d", &table_id))
9183 else if (unformat (i, "ipv6"))
9187 clib_warning ("parse error '%U'", format_unformat_error, i);
9192 M (IP_TABLE_REPLACE_END, mp);
9194 mp->table.table_id = ntohl (table_id);
9195 mp->table.is_ip6 = is_ipv6;
9203 api_set_ip_flow_hash (vat_main_t * vam)
9205 unformat_input_t *i = vam->input;
9206 vl_api_set_ip_flow_hash_t *mp;
9218 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9220 if (unformat (i, "vrf %d", &vrf_id))
9222 else if (unformat (i, "ipv6"))
9224 else if (unformat (i, "src"))
9226 else if (unformat (i, "dst"))
9228 else if (unformat (i, "sport"))
9230 else if (unformat (i, "dport"))
9232 else if (unformat (i, "proto"))
9234 else if (unformat (i, "reverse"))
9239 clib_warning ("parse error '%U'", format_unformat_error, i);
9244 if (vrf_id_set == 0)
9246 errmsg ("missing vrf id");
9250 M (SET_IP_FLOW_HASH, mp);
9256 mp->reverse = reverse;
9257 mp->vrf_id = ntohl (vrf_id);
9258 mp->is_ipv6 = is_ipv6;
9266 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
9268 unformat_input_t *i = vam->input;
9269 vl_api_sw_interface_ip6_enable_disable_t *mp;
9271 u8 sw_if_index_set = 0;
9275 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9277 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9278 sw_if_index_set = 1;
9279 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9280 sw_if_index_set = 1;
9281 else if (unformat (i, "enable"))
9283 else if (unformat (i, "disable"))
9287 clib_warning ("parse error '%U'", format_unformat_error, i);
9292 if (sw_if_index_set == 0)
9294 errmsg ("missing interface name or sw_if_index");
9298 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
9300 mp->sw_if_index = ntohl (sw_if_index);
9301 mp->enable = enable;
9310 api_l2_patch_add_del (vat_main_t * vam)
9312 unformat_input_t *i = vam->input;
9313 vl_api_l2_patch_add_del_t *mp;
9315 u8 rx_sw_if_index_set = 0;
9317 u8 tx_sw_if_index_set = 0;
9321 /* Parse args required to build the message */
9322 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9324 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
9325 rx_sw_if_index_set = 1;
9326 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
9327 tx_sw_if_index_set = 1;
9328 else if (unformat (i, "rx"))
9330 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9332 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9334 rx_sw_if_index_set = 1;
9339 else if (unformat (i, "tx"))
9341 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9343 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9345 tx_sw_if_index_set = 1;
9350 else if (unformat (i, "del"))
9356 if (rx_sw_if_index_set == 0)
9358 errmsg ("missing rx interface name or rx_sw_if_index");
9362 if (tx_sw_if_index_set == 0)
9364 errmsg ("missing tx interface name or tx_sw_if_index");
9368 M (L2_PATCH_ADD_DEL, mp);
9370 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
9371 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
9372 mp->is_add = is_add;
9380 u8 localsid_addr[16];
9389 api_sr_localsid_add_del (vat_main_t * vam)
9391 unformat_input_t *i = vam->input;
9392 vl_api_sr_localsid_add_del_t *mp;
9395 ip6_address_t localsid;
9399 u32 fib_table = ~(u32) 0;
9400 ip46_address_t nh_addr;
9401 clib_memset (&nh_addr, 0, sizeof (ip46_address_t));
9403 bool nexthop_set = 0;
9407 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9409 if (unformat (i, "del"))
9411 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
9412 else if (unformat (i, "next-hop %U", unformat_ip46_address, &nh_addr))
9414 else if (unformat (i, "behavior %u", &behavior));
9415 else if (unformat (i, "sw_if_index %u", &sw_if_index));
9416 else if (unformat (i, "fib-table %u", &fib_table));
9417 else if (unformat (i, "end.psp %u", &behavior));
9422 M (SR_LOCALSID_ADD_DEL, mp);
9424 clib_memcpy (mp->localsid, &localsid, sizeof (mp->localsid));
9428 clib_memcpy (&mp->nh_addr.un, &nh_addr, sizeof (mp->nh_addr.un));
9430 mp->behavior = behavior;
9431 mp->sw_if_index = ntohl (sw_if_index);
9432 mp->fib_table = ntohl (fib_table);
9433 mp->end_psp = end_psp;
9434 mp->is_del = is_del;
9442 api_ioam_enable (vat_main_t * vam)
9444 unformat_input_t *input = vam->input;
9445 vl_api_ioam_enable_t *mp;
9447 int has_trace_option = 0;
9448 int has_pot_option = 0;
9449 int has_seqno_option = 0;
9450 int has_analyse_option = 0;
9453 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9455 if (unformat (input, "trace"))
9456 has_trace_option = 1;
9457 else if (unformat (input, "pot"))
9459 else if (unformat (input, "seqno"))
9460 has_seqno_option = 1;
9461 else if (unformat (input, "analyse"))
9462 has_analyse_option = 1;
9466 M (IOAM_ENABLE, mp);
9467 mp->id = htons (id);
9468 mp->seqno = has_seqno_option;
9469 mp->analyse = has_analyse_option;
9470 mp->pot_enable = has_pot_option;
9471 mp->trace_enable = has_trace_option;
9480 api_ioam_disable (vat_main_t * vam)
9482 vl_api_ioam_disable_t *mp;
9485 M (IOAM_DISABLE, mp);
9491 #define foreach_tcp_proto_field \
9495 #define foreach_udp_proto_field \
9499 #define foreach_ip4_proto_field \
9511 u16 src_port, dst_port;
9514 #if VPP_API_TEST_BUILTIN == 0
9516 unformat_tcp_mask (unformat_input_t * input, va_list * args)
9518 u8 **maskp = va_arg (*args, u8 **);
9520 u8 found_something = 0;
9523 #define _(a) u8 a=0;
9524 foreach_tcp_proto_field;
9527 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9530 #define _(a) else if (unformat (input, #a)) a=1;
9531 foreach_tcp_proto_field
9537 #define _(a) found_something += a;
9538 foreach_tcp_proto_field;
9541 if (found_something == 0)
9544 vec_validate (mask, sizeof (*tcp) - 1);
9546 tcp = (tcp_header_t *) mask;
9548 #define _(a) if (a) clib_memset (&tcp->a, 0xff, sizeof (tcp->a));
9549 foreach_tcp_proto_field;
9557 unformat_udp_mask (unformat_input_t * input, va_list * args)
9559 u8 **maskp = va_arg (*args, u8 **);
9561 u8 found_something = 0;
9564 #define _(a) u8 a=0;
9565 foreach_udp_proto_field;
9568 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9571 #define _(a) else if (unformat (input, #a)) a=1;
9572 foreach_udp_proto_field
9578 #define _(a) found_something += a;
9579 foreach_udp_proto_field;
9582 if (found_something == 0)
9585 vec_validate (mask, sizeof (*udp) - 1);
9587 udp = (udp_header_t *) mask;
9589 #define _(a) if (a) clib_memset (&udp->a, 0xff, sizeof (udp->a));
9590 foreach_udp_proto_field;
9598 unformat_l4_mask (unformat_input_t * input, va_list * args)
9600 u8 **maskp = va_arg (*args, u8 **);
9601 u16 src_port = 0, dst_port = 0;
9602 tcpudp_header_t *tcpudp;
9604 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9606 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
9608 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
9610 else if (unformat (input, "src_port"))
9612 else if (unformat (input, "dst_port"))
9618 if (!src_port && !dst_port)
9622 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
9624 tcpudp = (tcpudp_header_t *) mask;
9625 tcpudp->src_port = src_port;
9626 tcpudp->dst_port = dst_port;
9634 unformat_ip4_mask (unformat_input_t * input, va_list * args)
9636 u8 **maskp = va_arg (*args, u8 **);
9638 u8 found_something = 0;
9641 #define _(a) u8 a=0;
9642 foreach_ip4_proto_field;
9648 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9650 if (unformat (input, "version"))
9652 else if (unformat (input, "hdr_length"))
9654 else if (unformat (input, "src"))
9656 else if (unformat (input, "dst"))
9658 else if (unformat (input, "proto"))
9661 #define _(a) else if (unformat (input, #a)) a=1;
9662 foreach_ip4_proto_field
9668 #define _(a) found_something += a;
9669 foreach_ip4_proto_field;
9672 if (found_something == 0)
9675 vec_validate (mask, sizeof (*ip) - 1);
9677 ip = (ip4_header_t *) mask;
9679 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
9680 foreach_ip4_proto_field;
9683 ip->ip_version_and_header_length = 0;
9686 ip->ip_version_and_header_length |= 0xF0;
9689 ip->ip_version_and_header_length |= 0x0F;
9695 #define foreach_ip6_proto_field \
9703 unformat_ip6_mask (unformat_input_t * input, va_list * args)
9705 u8 **maskp = va_arg (*args, u8 **);
9707 u8 found_something = 0;
9709 u32 ip_version_traffic_class_and_flow_label;
9711 #define _(a) u8 a=0;
9712 foreach_ip6_proto_field;
9715 u8 traffic_class = 0;
9718 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9720 if (unformat (input, "version"))
9722 else if (unformat (input, "traffic-class"))
9724 else if (unformat (input, "flow-label"))
9726 else if (unformat (input, "src"))
9728 else if (unformat (input, "dst"))
9730 else if (unformat (input, "proto"))
9733 #define _(a) else if (unformat (input, #a)) a=1;
9734 foreach_ip6_proto_field
9740 #define _(a) found_something += a;
9741 foreach_ip6_proto_field;
9744 if (found_something == 0)
9747 vec_validate (mask, sizeof (*ip) - 1);
9749 ip = (ip6_header_t *) mask;
9751 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
9752 foreach_ip6_proto_field;
9755 ip_version_traffic_class_and_flow_label = 0;
9758 ip_version_traffic_class_and_flow_label |= 0xF0000000;
9761 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
9764 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
9766 ip->ip_version_traffic_class_and_flow_label =
9767 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9774 unformat_l3_mask (unformat_input_t * input, va_list * args)
9776 u8 **maskp = va_arg (*args, u8 **);
9778 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9780 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
9782 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
9791 unformat_l2_mask (unformat_input_t * input, va_list * args)
9793 u8 **maskp = va_arg (*args, u8 **);
9808 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9810 if (unformat (input, "src"))
9812 else if (unformat (input, "dst"))
9814 else if (unformat (input, "proto"))
9816 else if (unformat (input, "tag1"))
9818 else if (unformat (input, "tag2"))
9820 else if (unformat (input, "ignore-tag1"))
9822 else if (unformat (input, "ignore-tag2"))
9824 else if (unformat (input, "cos1"))
9826 else if (unformat (input, "cos2"))
9828 else if (unformat (input, "dot1q"))
9830 else if (unformat (input, "dot1ad"))
9835 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
9836 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9839 if (tag1 || ignore_tag1 || cos1 || dot1q)
9841 if (tag2 || ignore_tag2 || cos2 || dot1ad)
9844 vec_validate (mask, len - 1);
9847 clib_memset (mask, 0xff, 6);
9850 clib_memset (mask + 6, 0xff, 6);
9854 /* inner vlan tag */
9863 mask[21] = mask[20] = 0xff;
9884 mask[16] = mask[17] = 0xff;
9894 mask[12] = mask[13] = 0xff;
9901 unformat_classify_mask (unformat_input_t * input, va_list * args)
9903 u8 **maskp = va_arg (*args, u8 **);
9904 u32 *skipp = va_arg (*args, u32 *);
9905 u32 *matchp = va_arg (*args, u32 *);
9913 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9915 if (unformat (input, "hex %U", unformat_hex_string, &mask))
9917 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
9919 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
9921 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
9935 if (mask || l2 || l3 || l4)
9939 /* "With a free Ethernet header in every package" */
9941 vec_validate (l2, 13);
9945 vec_append (mask, l3);
9950 vec_append (mask, l4);
9955 /* Scan forward looking for the first significant mask octet */
9956 for (i = 0; i < vec_len (mask); i++)
9960 /* compute (skip, match) params */
9961 *skipp = i / sizeof (u32x4);
9962 vec_delete (mask, *skipp * sizeof (u32x4), 0);
9964 /* Pad mask to an even multiple of the vector size */
9965 while (vec_len (mask) % sizeof (u32x4))
9968 match = vec_len (mask) / sizeof (u32x4);
9970 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
9972 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
9973 if (*tmp || *(tmp + 1))
9978 clib_warning ("BUG: match 0");
9980 _vec_len (mask) = match * sizeof (u32x4);
9990 #endif /* VPP_API_TEST_BUILTIN */
9992 #define foreach_l2_next \
9994 _(ethernet, ETHERNET_INPUT) \
9999 unformat_l2_next_index (unformat_input_t * input, va_list * args)
10001 u32 *miss_next_indexp = va_arg (*args, u32 *);
10002 u32 next_index = 0;
10006 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
10010 if (unformat (input, "%d", &tmp))
10019 *miss_next_indexp = next_index;
10023 #define foreach_ip_next \
10026 _(rewrite, REWRITE)
10029 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
10031 u32 *miss_next_indexp = va_arg (*args, u32 *);
10032 u32 next_index = 0;
10036 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
10040 if (unformat (input, "%d", &tmp))
10049 *miss_next_indexp = next_index;
10053 #define foreach_acl_next \
10057 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
10059 u32 *miss_next_indexp = va_arg (*args, u32 *);
10060 u32 next_index = 0;
10064 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
10068 if (unformat (input, "permit"))
10073 else if (unformat (input, "%d", &tmp))
10082 *miss_next_indexp = next_index;
10087 unformat_policer_precolor (unformat_input_t * input, va_list * args)
10089 u32 *r = va_arg (*args, u32 *);
10091 if (unformat (input, "conform-color"))
10092 *r = POLICE_CONFORM;
10093 else if (unformat (input, "exceed-color"))
10094 *r = POLICE_EXCEED;
10102 api_classify_add_del_table (vat_main_t * vam)
10104 unformat_input_t *i = vam->input;
10105 vl_api_classify_add_del_table_t *mp;
10112 u32 table_index = ~0;
10113 u32 next_table_index = ~0;
10114 u32 miss_next_index = ~0;
10115 u32 memory_size = 32 << 20;
10117 u32 current_data_flag = 0;
10118 int current_data_offset = 0;
10121 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10123 if (unformat (i, "del"))
10125 else if (unformat (i, "del-chain"))
10130 else if (unformat (i, "buckets %d", &nbuckets))
10132 else if (unformat (i, "memory_size %d", &memory_size))
10134 else if (unformat (i, "skip %d", &skip))
10136 else if (unformat (i, "match %d", &match))
10138 else if (unformat (i, "table %d", &table_index))
10140 else if (unformat (i, "mask %U", unformat_classify_mask,
10141 &mask, &skip, &match))
10143 else if (unformat (i, "next-table %d", &next_table_index))
10145 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
10148 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
10151 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
10154 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
10156 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
10162 if (is_add && mask == 0)
10164 errmsg ("Mask required");
10168 if (is_add && skip == ~0)
10170 errmsg ("skip count required");
10174 if (is_add && match == ~0)
10176 errmsg ("match count required");
10180 if (!is_add && table_index == ~0)
10182 errmsg ("table index required for delete");
10186 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
10188 mp->is_add = is_add;
10189 mp->del_chain = del_chain;
10190 mp->table_index = ntohl (table_index);
10191 mp->nbuckets = ntohl (nbuckets);
10192 mp->memory_size = ntohl (memory_size);
10193 mp->skip_n_vectors = ntohl (skip);
10194 mp->match_n_vectors = ntohl (match);
10195 mp->next_table_index = ntohl (next_table_index);
10196 mp->miss_next_index = ntohl (miss_next_index);
10197 mp->current_data_flag = ntohl (current_data_flag);
10198 mp->current_data_offset = ntohl (current_data_offset);
10199 mp->mask_len = ntohl (vec_len (mask));
10200 clib_memcpy (mp->mask, mask, vec_len (mask));
10209 #if VPP_API_TEST_BUILTIN == 0
10211 unformat_l4_match (unformat_input_t * input, va_list * args)
10213 u8 **matchp = va_arg (*args, u8 **);
10215 u8 *proto_header = 0;
10221 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10223 if (unformat (input, "src_port %d", &src_port))
10225 else if (unformat (input, "dst_port %d", &dst_port))
10231 h.src_port = clib_host_to_net_u16 (src_port);
10232 h.dst_port = clib_host_to_net_u16 (dst_port);
10233 vec_validate (proto_header, sizeof (h) - 1);
10234 memcpy (proto_header, &h, sizeof (h));
10236 *matchp = proto_header;
10242 unformat_ip4_match (unformat_input_t * input, va_list * args)
10244 u8 **matchp = va_arg (*args, u8 **);
10249 int hdr_length = 0;
10250 u32 hdr_length_val;
10251 int src = 0, dst = 0;
10252 ip4_address_t src_val, dst_val;
10259 int fragment_id = 0;
10260 u32 fragment_id_val;
10266 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10268 if (unformat (input, "version %d", &version_val))
10270 else if (unformat (input, "hdr_length %d", &hdr_length_val))
10272 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
10274 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
10276 else if (unformat (input, "proto %d", &proto_val))
10278 else if (unformat (input, "tos %d", &tos_val))
10280 else if (unformat (input, "length %d", &length_val))
10282 else if (unformat (input, "fragment_id %d", &fragment_id_val))
10284 else if (unformat (input, "ttl %d", &ttl_val))
10286 else if (unformat (input, "checksum %d", &checksum_val))
10292 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
10293 + ttl + checksum == 0)
10297 * Aligned because we use the real comparison functions
10299 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10301 ip = (ip4_header_t *) match;
10303 /* These are realistically matched in practice */
10305 ip->src_address.as_u32 = src_val.as_u32;
10308 ip->dst_address.as_u32 = dst_val.as_u32;
10311 ip->protocol = proto_val;
10314 /* These are not, but they're included for completeness */
10316 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
10319 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
10325 ip->length = clib_host_to_net_u16 (length_val);
10331 ip->checksum = clib_host_to_net_u16 (checksum_val);
10338 unformat_ip6_match (unformat_input_t * input, va_list * args)
10340 u8 **matchp = va_arg (*args, u8 **);
10345 u8 traffic_class = 0;
10346 u32 traffic_class_val = 0;
10349 int src = 0, dst = 0;
10350 ip6_address_t src_val, dst_val;
10353 int payload_length = 0;
10354 u32 payload_length_val;
10357 u32 ip_version_traffic_class_and_flow_label;
10359 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10361 if (unformat (input, "version %d", &version_val))
10363 else if (unformat (input, "traffic_class %d", &traffic_class_val))
10365 else if (unformat (input, "flow_label %d", &flow_label_val))
10367 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
10369 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
10371 else if (unformat (input, "proto %d", &proto_val))
10373 else if (unformat (input, "payload_length %d", &payload_length_val))
10374 payload_length = 1;
10375 else if (unformat (input, "hop_limit %d", &hop_limit_val))
10381 if (version + traffic_class + flow_label + src + dst + proto +
10382 payload_length + hop_limit == 0)
10386 * Aligned because we use the real comparison functions
10388 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10390 ip = (ip6_header_t *) match;
10393 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
10396 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
10399 ip->protocol = proto_val;
10401 ip_version_traffic_class_and_flow_label = 0;
10404 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
10407 ip_version_traffic_class_and_flow_label |=
10408 (traffic_class_val & 0xFF) << 20;
10411 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
10413 ip->ip_version_traffic_class_and_flow_label =
10414 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10416 if (payload_length)
10417 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
10420 ip->hop_limit = hop_limit_val;
10427 unformat_l3_match (unformat_input_t * input, va_list * args)
10429 u8 **matchp = va_arg (*args, u8 **);
10431 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10433 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
10435 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
10444 unformat_vlan_tag (unformat_input_t * input, va_list * args)
10446 u8 *tagp = va_arg (*args, u8 *);
10449 if (unformat (input, "%d", &tag))
10451 tagp[0] = (tag >> 8) & 0x0F;
10452 tagp[1] = tag & 0xFF;
10460 unformat_l2_match (unformat_input_t * input, va_list * args)
10462 u8 **matchp = va_arg (*args, u8 **);
10475 u8 ignore_tag1 = 0;
10476 u8 ignore_tag2 = 0;
10482 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10484 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
10487 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
10489 else if (unformat (input, "proto %U",
10490 unformat_ethernet_type_host_byte_order, &proto_val))
10492 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
10494 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
10496 else if (unformat (input, "ignore-tag1"))
10498 else if (unformat (input, "ignore-tag2"))
10500 else if (unformat (input, "cos1 %d", &cos1_val))
10502 else if (unformat (input, "cos2 %d", &cos2_val))
10507 if ((src + dst + proto + tag1 + tag2 +
10508 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10511 if (tag1 || ignore_tag1 || cos1)
10513 if (tag2 || ignore_tag2 || cos2)
10516 vec_validate_aligned (match, len - 1, sizeof (u32x4));
10519 clib_memcpy (match, dst_val, 6);
10522 clib_memcpy (match + 6, src_val, 6);
10526 /* inner vlan tag */
10527 match[19] = tag2_val[1];
10528 match[18] = tag2_val[0];
10530 match[18] |= (cos2_val & 0x7) << 5;
10533 match[21] = proto_val & 0xff;
10534 match[20] = proto_val >> 8;
10538 match[15] = tag1_val[1];
10539 match[14] = tag1_val[0];
10542 match[14] |= (cos1_val & 0x7) << 5;
10548 match[15] = tag1_val[1];
10549 match[14] = tag1_val[0];
10552 match[17] = proto_val & 0xff;
10553 match[16] = proto_val >> 8;
10556 match[14] |= (cos1_val & 0x7) << 5;
10562 match[18] |= (cos2_val & 0x7) << 5;
10564 match[14] |= (cos1_val & 0x7) << 5;
10567 match[13] = proto_val & 0xff;
10568 match[12] = proto_val >> 8;
10576 unformat_qos_source (unformat_input_t * input, va_list * args)
10578 int *qs = va_arg (*args, int *);
10580 if (unformat (input, "ip"))
10581 *qs = QOS_SOURCE_IP;
10582 else if (unformat (input, "mpls"))
10583 *qs = QOS_SOURCE_MPLS;
10584 else if (unformat (input, "ext"))
10585 *qs = QOS_SOURCE_EXT;
10586 else if (unformat (input, "vlan"))
10587 *qs = QOS_SOURCE_VLAN;
10596 api_unformat_classify_match (unformat_input_t * input, va_list * args)
10598 u8 **matchp = va_arg (*args, u8 **);
10599 u32 skip_n_vectors = va_arg (*args, u32);
10600 u32 match_n_vectors = va_arg (*args, u32);
10607 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10609 if (unformat (input, "hex %U", unformat_hex_string, &match))
10611 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
10613 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
10615 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
10629 if (match || l2 || l3 || l4)
10631 if (l2 || l3 || l4)
10633 /* "Win a free Ethernet header in every packet" */
10635 vec_validate_aligned (l2, 13, sizeof (u32x4));
10639 vec_append_aligned (match, l3, sizeof (u32x4));
10644 vec_append_aligned (match, l4, sizeof (u32x4));
10649 /* Make sure the vector is big enough even if key is all 0's */
10650 vec_validate_aligned
10651 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
10654 /* Set size, include skipped vectors */
10655 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
10666 api_classify_add_del_session (vat_main_t * vam)
10668 unformat_input_t *i = vam->input;
10669 vl_api_classify_add_del_session_t *mp;
10671 u32 table_index = ~0;
10672 u32 hit_next_index = ~0;
10673 u32 opaque_index = ~0;
10676 u32 skip_n_vectors = 0;
10677 u32 match_n_vectors = 0;
10683 * Warning: you have to supply skip_n and match_n
10684 * because the API client cant simply look at the classify
10688 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10690 if (unformat (i, "del"))
10692 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
10695 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
10698 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
10701 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
10703 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
10705 else if (unformat (i, "opaque-index %d", &opaque_index))
10707 else if (unformat (i, "skip_n %d", &skip_n_vectors))
10709 else if (unformat (i, "match_n %d", &match_n_vectors))
10711 else if (unformat (i, "match %U", api_unformat_classify_match,
10712 &match, skip_n_vectors, match_n_vectors))
10714 else if (unformat (i, "advance %d", &advance))
10716 else if (unformat (i, "table-index %d", &table_index))
10718 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
10720 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
10722 else if (unformat (i, "action %d", &action))
10724 else if (unformat (i, "metadata %d", &metadata))
10730 if (table_index == ~0)
10732 errmsg ("Table index required");
10736 if (is_add && match == 0)
10738 errmsg ("Match value required");
10742 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
10744 mp->is_add = is_add;
10745 mp->table_index = ntohl (table_index);
10746 mp->hit_next_index = ntohl (hit_next_index);
10747 mp->opaque_index = ntohl (opaque_index);
10748 mp->advance = ntohl (advance);
10749 mp->action = action;
10750 mp->metadata = ntohl (metadata);
10751 mp->match_len = ntohl (vec_len (match));
10752 clib_memcpy (mp->match, match, vec_len (match));
10761 api_classify_set_interface_ip_table (vat_main_t * vam)
10763 unformat_input_t *i = vam->input;
10764 vl_api_classify_set_interface_ip_table_t *mp;
10766 int sw_if_index_set;
10767 u32 table_index = ~0;
10771 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10773 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10774 sw_if_index_set = 1;
10775 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10776 sw_if_index_set = 1;
10777 else if (unformat (i, "table %d", &table_index))
10781 clib_warning ("parse error '%U'", format_unformat_error, i);
10786 if (sw_if_index_set == 0)
10788 errmsg ("missing interface name or sw_if_index");
10793 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
10795 mp->sw_if_index = ntohl (sw_if_index);
10796 mp->table_index = ntohl (table_index);
10797 mp->is_ipv6 = is_ipv6;
10805 api_classify_set_interface_l2_tables (vat_main_t * vam)
10807 unformat_input_t *i = vam->input;
10808 vl_api_classify_set_interface_l2_tables_t *mp;
10810 int sw_if_index_set;
10811 u32 ip4_table_index = ~0;
10812 u32 ip6_table_index = ~0;
10813 u32 other_table_index = ~0;
10817 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10819 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10820 sw_if_index_set = 1;
10821 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10822 sw_if_index_set = 1;
10823 else if (unformat (i, "ip4-table %d", &ip4_table_index))
10825 else if (unformat (i, "ip6-table %d", &ip6_table_index))
10827 else if (unformat (i, "other-table %d", &other_table_index))
10829 else if (unformat (i, "is-input %d", &is_input))
10833 clib_warning ("parse error '%U'", format_unformat_error, i);
10838 if (sw_if_index_set == 0)
10840 errmsg ("missing interface name or sw_if_index");
10845 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
10847 mp->sw_if_index = ntohl (sw_if_index);
10848 mp->ip4_table_index = ntohl (ip4_table_index);
10849 mp->ip6_table_index = ntohl (ip6_table_index);
10850 mp->other_table_index = ntohl (other_table_index);
10851 mp->is_input = (u8) is_input;
10859 api_set_ipfix_exporter (vat_main_t * vam)
10861 unformat_input_t *i = vam->input;
10862 vl_api_set_ipfix_exporter_t *mp;
10863 ip4_address_t collector_address;
10864 u8 collector_address_set = 0;
10865 u32 collector_port = ~0;
10866 ip4_address_t src_address;
10867 u8 src_address_set = 0;
10870 u32 template_interval = ~0;
10871 u8 udp_checksum = 0;
10874 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10876 if (unformat (i, "collector_address %U", unformat_ip4_address,
10877 &collector_address))
10878 collector_address_set = 1;
10879 else if (unformat (i, "collector_port %d", &collector_port))
10881 else if (unformat (i, "src_address %U", unformat_ip4_address,
10883 src_address_set = 1;
10884 else if (unformat (i, "vrf_id %d", &vrf_id))
10886 else if (unformat (i, "path_mtu %d", &path_mtu))
10888 else if (unformat (i, "template_interval %d", &template_interval))
10890 else if (unformat (i, "udp_checksum"))
10896 if (collector_address_set == 0)
10898 errmsg ("collector_address required");
10902 if (src_address_set == 0)
10904 errmsg ("src_address required");
10908 M (SET_IPFIX_EXPORTER, mp);
10910 memcpy (mp->collector_address.un.ip4, collector_address.data,
10911 sizeof (collector_address.data));
10912 mp->collector_port = htons ((u16) collector_port);
10913 memcpy (mp->src_address.un.ip4, src_address.data,
10914 sizeof (src_address.data));
10915 mp->vrf_id = htonl (vrf_id);
10916 mp->path_mtu = htonl (path_mtu);
10917 mp->template_interval = htonl (template_interval);
10918 mp->udp_checksum = udp_checksum;
10926 api_set_ipfix_classify_stream (vat_main_t * vam)
10928 unformat_input_t *i = vam->input;
10929 vl_api_set_ipfix_classify_stream_t *mp;
10931 u32 src_port = UDP_DST_PORT_ipfix;
10934 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10936 if (unformat (i, "domain %d", &domain_id))
10938 else if (unformat (i, "src_port %d", &src_port))
10942 errmsg ("unknown input `%U'", format_unformat_error, i);
10947 M (SET_IPFIX_CLASSIFY_STREAM, mp);
10949 mp->domain_id = htonl (domain_id);
10950 mp->src_port = htons ((u16) src_port);
10958 api_ipfix_classify_table_add_del (vat_main_t * vam)
10960 unformat_input_t *i = vam->input;
10961 vl_api_ipfix_classify_table_add_del_t *mp;
10963 u32 classify_table_index = ~0;
10965 u8 transport_protocol = 255;
10968 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10970 if (unformat (i, "add"))
10972 else if (unformat (i, "del"))
10974 else if (unformat (i, "table %d", &classify_table_index))
10976 else if (unformat (i, "ip4"))
10978 else if (unformat (i, "ip6"))
10980 else if (unformat (i, "tcp"))
10981 transport_protocol = 6;
10982 else if (unformat (i, "udp"))
10983 transport_protocol = 17;
10986 errmsg ("unknown input `%U'", format_unformat_error, i);
10993 errmsg ("expecting: add|del");
10996 if (classify_table_index == ~0)
10998 errmsg ("classifier table not specified");
11001 if (ip_version == 0)
11003 errmsg ("IP version not specified");
11007 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
11009 mp->is_add = is_add;
11010 mp->table_id = htonl (classify_table_index);
11011 mp->ip_version = ip_version;
11012 mp->transport_protocol = transport_protocol;
11020 api_get_node_index (vat_main_t * vam)
11022 unformat_input_t *i = vam->input;
11023 vl_api_get_node_index_t *mp;
11027 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11029 if (unformat (i, "node %s", &name))
11036 errmsg ("node name required");
11039 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11041 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11045 M (GET_NODE_INDEX, mp);
11046 clib_memcpy (mp->node_name, name, vec_len (name));
11055 api_get_next_index (vat_main_t * vam)
11057 unformat_input_t *i = vam->input;
11058 vl_api_get_next_index_t *mp;
11059 u8 *node_name = 0, *next_node_name = 0;
11062 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11064 if (unformat (i, "node-name %s", &node_name))
11066 else if (unformat (i, "next-node-name %s", &next_node_name))
11070 if (node_name == 0)
11072 errmsg ("node name required");
11075 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
11077 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11081 if (next_node_name == 0)
11083 errmsg ("next node name required");
11086 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
11088 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
11092 M (GET_NEXT_INDEX, mp);
11093 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
11094 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
11095 vec_free (node_name);
11096 vec_free (next_node_name);
11104 api_add_node_next (vat_main_t * vam)
11106 unformat_input_t *i = vam->input;
11107 vl_api_add_node_next_t *mp;
11112 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11114 if (unformat (i, "node %s", &name))
11116 else if (unformat (i, "next %s", &next))
11123 errmsg ("node name required");
11126 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11128 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11133 errmsg ("next node required");
11136 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
11138 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
11142 M (ADD_NODE_NEXT, mp);
11143 clib_memcpy (mp->node_name, name, vec_len (name));
11144 clib_memcpy (mp->next_name, next, vec_len (next));
11154 api_l2tpv3_create_tunnel (vat_main_t * vam)
11156 unformat_input_t *i = vam->input;
11157 ip6_address_t client_address, our_address;
11158 int client_address_set = 0;
11159 int our_address_set = 0;
11160 u32 local_session_id = 0;
11161 u32 remote_session_id = 0;
11162 u64 local_cookie = 0;
11163 u64 remote_cookie = 0;
11164 u8 l2_sublayer_present = 0;
11165 vl_api_l2tpv3_create_tunnel_t *mp;
11168 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11170 if (unformat (i, "client_address %U", unformat_ip6_address,
11172 client_address_set = 1;
11173 else if (unformat (i, "our_address %U", unformat_ip6_address,
11175 our_address_set = 1;
11176 else if (unformat (i, "local_session_id %d", &local_session_id))
11178 else if (unformat (i, "remote_session_id %d", &remote_session_id))
11180 else if (unformat (i, "local_cookie %lld", &local_cookie))
11182 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
11184 else if (unformat (i, "l2-sublayer-present"))
11185 l2_sublayer_present = 1;
11190 if (client_address_set == 0)
11192 errmsg ("client_address required");
11196 if (our_address_set == 0)
11198 errmsg ("our_address required");
11202 M (L2TPV3_CREATE_TUNNEL, mp);
11204 clib_memcpy (mp->client_address.un.ip6, client_address.as_u8,
11205 sizeof (ip6_address_t));
11207 clib_memcpy (mp->our_address.un.ip6, our_address.as_u8,
11208 sizeof (ip6_address_t));
11210 mp->local_session_id = ntohl (local_session_id);
11211 mp->remote_session_id = ntohl (remote_session_id);
11212 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
11213 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
11214 mp->l2_sublayer_present = l2_sublayer_present;
11222 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
11224 unformat_input_t *i = vam->input;
11226 u8 sw_if_index_set = 0;
11227 u64 new_local_cookie = 0;
11228 u64 new_remote_cookie = 0;
11229 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
11232 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11234 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11235 sw_if_index_set = 1;
11236 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11237 sw_if_index_set = 1;
11238 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
11240 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
11246 if (sw_if_index_set == 0)
11248 errmsg ("missing interface name or sw_if_index");
11252 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
11254 mp->sw_if_index = ntohl (sw_if_index);
11255 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
11256 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
11264 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
11266 unformat_input_t *i = vam->input;
11267 vl_api_l2tpv3_interface_enable_disable_t *mp;
11269 u8 sw_if_index_set = 0;
11270 u8 enable_disable = 1;
11273 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11275 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11276 sw_if_index_set = 1;
11277 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11278 sw_if_index_set = 1;
11279 else if (unformat (i, "enable"))
11280 enable_disable = 1;
11281 else if (unformat (i, "disable"))
11282 enable_disable = 0;
11287 if (sw_if_index_set == 0)
11289 errmsg ("missing interface name or sw_if_index");
11293 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
11295 mp->sw_if_index = ntohl (sw_if_index);
11296 mp->enable_disable = enable_disable;
11304 api_l2tpv3_set_lookup_key (vat_main_t * vam)
11306 unformat_input_t *i = vam->input;
11307 vl_api_l2tpv3_set_lookup_key_t *mp;
11311 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11313 if (unformat (i, "lookup_v6_src"))
11314 key = L2T_LOOKUP_SRC_ADDRESS;
11315 else if (unformat (i, "lookup_v6_dst"))
11316 key = L2T_LOOKUP_DST_ADDRESS;
11317 else if (unformat (i, "lookup_session_id"))
11318 key = L2T_LOOKUP_SESSION_ID;
11323 if (key == (u8) ~ 0)
11325 errmsg ("l2tp session lookup key unset");
11329 M (L2TPV3_SET_LOOKUP_KEY, mp);
11338 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
11339 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11341 vat_main_t *vam = &vat_main;
11343 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
11344 format_ip6_address, mp->our_address,
11345 format_ip6_address, mp->client_address,
11346 clib_net_to_host_u32 (mp->sw_if_index));
11349 " local cookies %016llx %016llx remote cookie %016llx",
11350 clib_net_to_host_u64 (mp->local_cookie[0]),
11351 clib_net_to_host_u64 (mp->local_cookie[1]),
11352 clib_net_to_host_u64 (mp->remote_cookie));
11354 print (vam->ofp, " local session-id %d remote session-id %d",
11355 clib_net_to_host_u32 (mp->local_session_id),
11356 clib_net_to_host_u32 (mp->remote_session_id));
11358 print (vam->ofp, " l2 specific sublayer %s\n",
11359 mp->l2_sublayer_present ? "preset" : "absent");
11363 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
11364 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11366 vat_main_t *vam = &vat_main;
11367 vat_json_node_t *node = NULL;
11368 struct in6_addr addr;
11370 if (VAT_JSON_ARRAY != vam->json_tree.type)
11372 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11373 vat_json_init_array (&vam->json_tree);
11375 node = vat_json_array_add (&vam->json_tree);
11377 vat_json_init_object (node);
11379 clib_memcpy (&addr, mp->our_address.un.ip6, sizeof (addr));
11380 vat_json_object_add_ip6 (node, "our_address", addr);
11381 clib_memcpy (&addr, mp->client_address.un.ip6, sizeof (addr));
11382 vat_json_object_add_ip6 (node, "client_address", addr);
11384 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
11385 vat_json_init_array (lc);
11386 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
11387 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
11388 vat_json_object_add_uint (node, "remote_cookie",
11389 clib_net_to_host_u64 (mp->remote_cookie));
11391 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
11392 vat_json_object_add_uint (node, "local_session_id",
11393 clib_net_to_host_u32 (mp->local_session_id));
11394 vat_json_object_add_uint (node, "remote_session_id",
11395 clib_net_to_host_u32 (mp->remote_session_id));
11396 vat_json_object_add_string_copy (node, "l2_sublayer",
11397 mp->l2_sublayer_present ? (u8 *) "present"
11398 : (u8 *) "absent");
11402 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
11404 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
11405 vl_api_control_ping_t *mp_ping;
11408 /* Get list of l2tpv3-tunnel interfaces */
11409 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
11412 /* Use a control ping for synchronization */
11413 MPING (CONTROL_PING, mp_ping);
11421 static void vl_api_sw_interface_tap_v2_details_t_handler
11422 (vl_api_sw_interface_tap_v2_details_t * mp)
11424 vat_main_t *vam = &vat_main;
11427 format (0, "%U/%d", format_ip4_address, mp->host_ip4_prefix.address,
11428 mp->host_ip4_prefix.len);
11430 format (0, "%U/%d", format_ip6_address, mp->host_ip6_prefix.address,
11431 mp->host_ip6_prefix.len);
11434 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s 0x%-08x",
11435 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
11436 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
11437 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
11438 mp->host_bridge, ip4, ip6, ntohl (mp->tap_flags));
11444 static void vl_api_sw_interface_tap_v2_details_t_handler_json
11445 (vl_api_sw_interface_tap_v2_details_t * mp)
11447 vat_main_t *vam = &vat_main;
11448 vat_json_node_t *node = NULL;
11450 if (VAT_JSON_ARRAY != vam->json_tree.type)
11452 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11453 vat_json_init_array (&vam->json_tree);
11455 node = vat_json_array_add (&vam->json_tree);
11457 vat_json_init_object (node);
11458 vat_json_object_add_uint (node, "id", ntohl (mp->id));
11459 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11460 vat_json_object_add_uint (node, "tap_flags", ntohl (mp->tap_flags));
11461 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
11462 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
11463 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
11464 vat_json_object_add_string_copy (node, "host_mac_addr",
11465 format (0, "%U", format_ethernet_address,
11466 &mp->host_mac_addr));
11467 vat_json_object_add_string_copy (node, "host_namespace",
11468 mp->host_namespace);
11469 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
11470 vat_json_object_add_string_copy (node, "host_ip4_addr",
11471 format (0, "%U/%d", format_ip4_address,
11472 mp->host_ip4_prefix.address,
11473 mp->host_ip4_prefix.len));
11474 vat_json_object_add_string_copy (node, "host_ip6_prefix",
11475 format (0, "%U/%d", format_ip6_address,
11476 mp->host_ip6_prefix.address,
11477 mp->host_ip6_prefix.len));
11482 api_sw_interface_tap_v2_dump (vat_main_t * vam)
11484 vl_api_sw_interface_tap_v2_dump_t *mp;
11485 vl_api_control_ping_t *mp_ping;
11489 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
11490 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
11491 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
11494 /* Get list of tap interfaces */
11495 M (SW_INTERFACE_TAP_V2_DUMP, mp);
11498 /* Use a control ping for synchronization */
11499 MPING (CONTROL_PING, mp_ping);
11506 static void vl_api_sw_interface_virtio_pci_details_t_handler
11507 (vl_api_sw_interface_virtio_pci_details_t * mp)
11509 vat_main_t *vam = &vat_main;
11524 addr.domain = ntohs (mp->pci_addr.domain);
11525 addr.bus = mp->pci_addr.bus;
11526 addr.slot = mp->pci_addr.slot;
11527 addr.function = mp->pci_addr.function;
11529 u8 *pci_addr = format (0, "%04x:%02x:%02x.%x", addr.domain, addr.bus,
11530 addr.slot, addr.function);
11533 "\n%-12s %-12d %-12d %-12d %-17U 0x%-08llx",
11534 pci_addr, ntohl (mp->sw_if_index),
11535 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
11536 format_ethernet_address, mp->mac_addr,
11537 clib_net_to_host_u64 (mp->features));
11538 vec_free (pci_addr);
11541 static void vl_api_sw_interface_virtio_pci_details_t_handler_json
11542 (vl_api_sw_interface_virtio_pci_details_t * mp)
11544 vat_main_t *vam = &vat_main;
11545 vat_json_node_t *node = NULL;
11546 vlib_pci_addr_t pci_addr;
11548 if (VAT_JSON_ARRAY != vam->json_tree.type)
11550 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11551 vat_json_init_array (&vam->json_tree);
11553 node = vat_json_array_add (&vam->json_tree);
11555 pci_addr.domain = ntohs (mp->pci_addr.domain);
11556 pci_addr.bus = mp->pci_addr.bus;
11557 pci_addr.slot = mp->pci_addr.slot;
11558 pci_addr.function = mp->pci_addr.function;
11560 vat_json_init_object (node);
11561 vat_json_object_add_uint (node, "pci-addr", pci_addr.as_u32);
11562 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11563 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
11564 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
11565 vat_json_object_add_uint (node, "features",
11566 clib_net_to_host_u64 (mp->features));
11567 vat_json_object_add_string_copy (node, "mac_addr",
11568 format (0, "%U", format_ethernet_address,
11573 api_sw_interface_virtio_pci_dump (vat_main_t * vam)
11575 vl_api_sw_interface_virtio_pci_dump_t *mp;
11576 vl_api_control_ping_t *mp_ping;
11580 "\n%-12s %-12s %-12s %-12s %-17s %-08s",
11581 "pci_addr", "sw_if_index", "rx_ring_sz", "tx_ring_sz",
11582 "mac_addr", "features");
11584 /* Get list of tap interfaces */
11585 M (SW_INTERFACE_VIRTIO_PCI_DUMP, mp);
11588 /* Use a control ping for synchronization */
11589 MPING (CONTROL_PING, mp_ping);
11597 api_vxlan_offload_rx (vat_main_t * vam)
11599 unformat_input_t *line_input = vam->input;
11600 vl_api_vxlan_offload_rx_t *mp;
11601 u32 hw_if_index = ~0, rx_if_index = ~0;
11605 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11607 if (unformat (line_input, "del"))
11609 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
11612 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
11614 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
11617 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
11621 errmsg ("parse error '%U'", format_unformat_error, line_input);
11626 if (hw_if_index == ~0)
11628 errmsg ("no hw interface");
11632 if (rx_if_index == ~0)
11634 errmsg ("no rx tunnel");
11638 M (VXLAN_OFFLOAD_RX, mp);
11640 mp->hw_if_index = ntohl (hw_if_index);
11641 mp->sw_if_index = ntohl (rx_if_index);
11642 mp->enable = is_add;
11649 static uword unformat_vxlan_decap_next
11650 (unformat_input_t * input, va_list * args)
11652 u32 *result = va_arg (*args, u32 *);
11655 if (unformat (input, "l2"))
11656 *result = VXLAN_INPUT_NEXT_L2_INPUT;
11657 else if (unformat (input, "%d", &tmp))
11665 api_vxlan_add_del_tunnel (vat_main_t * vam)
11667 unformat_input_t *line_input = vam->input;
11668 vl_api_vxlan_add_del_tunnel_t *mp;
11669 ip46_address_t src, dst;
11671 u8 ipv4_set = 0, ipv6_set = 0;
11676 u32 mcast_sw_if_index = ~0;
11677 u32 encap_vrf_id = 0;
11678 u32 decap_next_index = ~0;
11682 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
11683 clib_memset (&src, 0, sizeof src);
11684 clib_memset (&dst, 0, sizeof dst);
11686 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11688 if (unformat (line_input, "del"))
11690 else if (unformat (line_input, "instance %d", &instance))
11693 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
11699 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
11705 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
11711 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
11716 else if (unformat (line_input, "group %U %U",
11717 unformat_ip4_address, &dst.ip4,
11718 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11720 grp_set = dst_set = 1;
11723 else if (unformat (line_input, "group %U",
11724 unformat_ip4_address, &dst.ip4))
11726 grp_set = dst_set = 1;
11729 else if (unformat (line_input, "group %U %U",
11730 unformat_ip6_address, &dst.ip6,
11731 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11733 grp_set = dst_set = 1;
11736 else if (unformat (line_input, "group %U",
11737 unformat_ip6_address, &dst.ip6))
11739 grp_set = dst_set = 1;
11743 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
11745 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11747 else if (unformat (line_input, "decap-next %U",
11748 unformat_vxlan_decap_next, &decap_next_index))
11750 else if (unformat (line_input, "vni %d", &vni))
11754 errmsg ("parse error '%U'", format_unformat_error, line_input);
11761 errmsg ("tunnel src address not specified");
11766 errmsg ("tunnel dst address not specified");
11770 if (grp_set && !ip46_address_is_multicast (&dst))
11772 errmsg ("tunnel group address not multicast");
11775 if (grp_set && mcast_sw_if_index == ~0)
11777 errmsg ("tunnel nonexistent multicast device");
11780 if (grp_set == 0 && ip46_address_is_multicast (&dst))
11782 errmsg ("tunnel dst address must be unicast");
11787 if (ipv4_set && ipv6_set)
11789 errmsg ("both IPv4 and IPv6 addresses specified");
11793 if ((vni == 0) || (vni >> 24))
11795 errmsg ("vni not specified or out of range");
11799 M (VXLAN_ADD_DEL_TUNNEL, mp);
11803 clib_memcpy (mp->src_address.un.ip6, &src.ip6, sizeof (src.ip6));
11804 clib_memcpy (mp->dst_address.un.ip6, &dst.ip6, sizeof (dst.ip6));
11808 clib_memcpy (mp->src_address.un.ip4, &src.ip4, sizeof (src.ip4));
11809 clib_memcpy (mp->dst_address.un.ip4, &dst.ip4, sizeof (dst.ip4));
11811 mp->src_address.af = ipv6_set;
11812 mp->dst_address.af = ipv6_set;
11814 mp->instance = htonl (instance);
11815 mp->encap_vrf_id = ntohl (encap_vrf_id);
11816 mp->decap_next_index = ntohl (decap_next_index);
11817 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
11818 mp->vni = ntohl (vni);
11819 mp->is_add = is_add;
11826 static void vl_api_vxlan_tunnel_details_t_handler
11827 (vl_api_vxlan_tunnel_details_t * mp)
11829 vat_main_t *vam = &vat_main;
11830 ip46_address_t src =
11831 to_ip46 (mp->dst_address.af, (u8 *) & mp->dst_address.un);
11832 ip46_address_t dst =
11833 to_ip46 (mp->dst_address.af, (u8 *) & mp->src_address.un);
11835 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
11836 ntohl (mp->sw_if_index),
11837 ntohl (mp->instance),
11838 format_ip46_address, &src, IP46_TYPE_ANY,
11839 format_ip46_address, &dst, IP46_TYPE_ANY,
11840 ntohl (mp->encap_vrf_id),
11841 ntohl (mp->decap_next_index), ntohl (mp->vni),
11842 ntohl (mp->mcast_sw_if_index));
11845 static void vl_api_vxlan_tunnel_details_t_handler_json
11846 (vl_api_vxlan_tunnel_details_t * mp)
11848 vat_main_t *vam = &vat_main;
11849 vat_json_node_t *node = NULL;
11851 if (VAT_JSON_ARRAY != vam->json_tree.type)
11853 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11854 vat_json_init_array (&vam->json_tree);
11856 node = vat_json_array_add (&vam->json_tree);
11858 vat_json_init_object (node);
11859 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11861 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
11863 if (mp->src_address.af)
11865 struct in6_addr ip6;
11867 clib_memcpy (&ip6, mp->src_address.un.ip6, sizeof (ip6));
11868 vat_json_object_add_ip6 (node, "src_address", ip6);
11869 clib_memcpy (&ip6, mp->dst_address.un.ip6, sizeof (ip6));
11870 vat_json_object_add_ip6 (node, "dst_address", ip6);
11874 struct in_addr ip4;
11876 clib_memcpy (&ip4, mp->src_address.un.ip4, sizeof (ip4));
11877 vat_json_object_add_ip4 (node, "src_address", ip4);
11878 clib_memcpy (&ip4, mp->dst_address.un.ip4, sizeof (ip4));
11879 vat_json_object_add_ip4 (node, "dst_address", ip4);
11881 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11882 vat_json_object_add_uint (node, "decap_next_index",
11883 ntohl (mp->decap_next_index));
11884 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11885 vat_json_object_add_uint (node, "mcast_sw_if_index",
11886 ntohl (mp->mcast_sw_if_index));
11890 api_vxlan_tunnel_dump (vat_main_t * vam)
11892 unformat_input_t *i = vam->input;
11893 vl_api_vxlan_tunnel_dump_t *mp;
11894 vl_api_control_ping_t *mp_ping;
11896 u8 sw_if_index_set = 0;
11899 /* Parse args required to build the message */
11900 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11902 if (unformat (i, "sw_if_index %d", &sw_if_index))
11903 sw_if_index_set = 1;
11908 if (sw_if_index_set == 0)
11913 if (!vam->json_output)
11915 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
11916 "sw_if_index", "instance", "src_address", "dst_address",
11917 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
11920 /* Get list of vxlan-tunnel interfaces */
11921 M (VXLAN_TUNNEL_DUMP, mp);
11923 mp->sw_if_index = htonl (sw_if_index);
11927 /* Use a control ping for synchronization */
11928 MPING (CONTROL_PING, mp_ping);
11936 api_gre_tunnel_add_del (vat_main_t * vam)
11938 unformat_input_t *line_input = vam->input;
11939 vl_api_address_t src = { }, dst =
11942 vl_api_gre_tunnel_add_del_t *mp;
11943 vl_api_gre_tunnel_type_t t_type;
11947 u32 outer_table_id = 0;
11948 u32 session_id = 0;
11952 t_type = GRE_API_TUNNEL_TYPE_L3;
11954 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11956 if (unformat (line_input, "del"))
11958 else if (unformat (line_input, "instance %d", &instance))
11960 else if (unformat (line_input, "src %U", unformat_vl_api_address, &src))
11964 else if (unformat (line_input, "dst %U", unformat_vl_api_address, &dst))
11968 else if (unformat (line_input, "outer-table-id %d", &outer_table_id))
11970 else if (unformat (line_input, "teb"))
11971 t_type = GRE_API_TUNNEL_TYPE_TEB;
11972 else if (unformat (line_input, "erspan %d", &session_id))
11973 t_type = GRE_API_TUNNEL_TYPE_ERSPAN;
11976 errmsg ("parse error '%U'", format_unformat_error, line_input);
11983 errmsg ("tunnel src address not specified");
11988 errmsg ("tunnel dst address not specified");
11992 M (GRE_TUNNEL_ADD_DEL, mp);
11994 clib_memcpy (&mp->tunnel.src, &src, sizeof (mp->tunnel.src));
11995 clib_memcpy (&mp->tunnel.dst, &dst, sizeof (mp->tunnel.dst));
11997 mp->tunnel.instance = htonl (instance);
11998 mp->tunnel.outer_table_id = htonl (outer_table_id);
11999 mp->is_add = is_add;
12000 mp->tunnel.session_id = htons ((u16) session_id);
12001 mp->tunnel.type = htonl (t_type);
12008 static void vl_api_gre_tunnel_details_t_handler
12009 (vl_api_gre_tunnel_details_t * mp)
12011 vat_main_t *vam = &vat_main;
12013 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
12014 ntohl (mp->tunnel.sw_if_index),
12015 ntohl (mp->tunnel.instance),
12016 format_vl_api_address, &mp->tunnel.src,
12017 format_vl_api_address, &mp->tunnel.dst,
12018 mp->tunnel.type, ntohl (mp->tunnel.outer_table_id),
12019 ntohl (mp->tunnel.session_id));
12022 static void vl_api_gre_tunnel_details_t_handler_json
12023 (vl_api_gre_tunnel_details_t * mp)
12025 vat_main_t *vam = &vat_main;
12026 vat_json_node_t *node = NULL;
12028 if (VAT_JSON_ARRAY != vam->json_tree.type)
12030 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12031 vat_json_init_array (&vam->json_tree);
12033 node = vat_json_array_add (&vam->json_tree);
12035 vat_json_init_object (node);
12036 vat_json_object_add_uint (node, "sw_if_index",
12037 ntohl (mp->tunnel.sw_if_index));
12038 vat_json_object_add_uint (node, "instance", ntohl (mp->tunnel.instance));
12040 vat_json_object_add_address (node, "src", &mp->tunnel.src);
12041 vat_json_object_add_address (node, "dst", &mp->tunnel.dst);
12042 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel.type);
12043 vat_json_object_add_uint (node, "outer_table_id",
12044 ntohl (mp->tunnel.outer_table_id));
12045 vat_json_object_add_uint (node, "session_id", mp->tunnel.session_id);
12049 api_gre_tunnel_dump (vat_main_t * vam)
12051 unformat_input_t *i = vam->input;
12052 vl_api_gre_tunnel_dump_t *mp;
12053 vl_api_control_ping_t *mp_ping;
12055 u8 sw_if_index_set = 0;
12058 /* Parse args required to build the message */
12059 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12061 if (unformat (i, "sw_if_index %d", &sw_if_index))
12062 sw_if_index_set = 1;
12067 if (sw_if_index_set == 0)
12072 if (!vam->json_output)
12074 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
12075 "sw_if_index", "instance", "src_address", "dst_address",
12076 "tunnel_type", "outer_fib_id", "session_id");
12079 /* Get list of gre-tunnel interfaces */
12080 M (GRE_TUNNEL_DUMP, mp);
12082 mp->sw_if_index = htonl (sw_if_index);
12086 /* Use a control ping for synchronization */
12087 MPING (CONTROL_PING, mp_ping);
12095 api_l2_fib_clear_table (vat_main_t * vam)
12097 // unformat_input_t * i = vam->input;
12098 vl_api_l2_fib_clear_table_t *mp;
12101 M (L2_FIB_CLEAR_TABLE, mp);
12109 api_l2_interface_efp_filter (vat_main_t * vam)
12111 unformat_input_t *i = vam->input;
12112 vl_api_l2_interface_efp_filter_t *mp;
12115 u8 sw_if_index_set = 0;
12118 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12120 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12121 sw_if_index_set = 1;
12122 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12123 sw_if_index_set = 1;
12124 else if (unformat (i, "enable"))
12126 else if (unformat (i, "disable"))
12130 clib_warning ("parse error '%U'", format_unformat_error, i);
12135 if (sw_if_index_set == 0)
12137 errmsg ("missing sw_if_index");
12141 M (L2_INTERFACE_EFP_FILTER, mp);
12143 mp->sw_if_index = ntohl (sw_if_index);
12144 mp->enable_disable = enable;
12151 #define foreach_vtr_op \
12152 _("disable", L2_VTR_DISABLED) \
12153 _("push-1", L2_VTR_PUSH_1) \
12154 _("push-2", L2_VTR_PUSH_2) \
12155 _("pop-1", L2_VTR_POP_1) \
12156 _("pop-2", L2_VTR_POP_2) \
12157 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
12158 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
12159 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
12160 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
12163 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
12165 unformat_input_t *i = vam->input;
12166 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
12168 u8 sw_if_index_set = 0;
12171 u32 push_dot1q = 1;
12176 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12178 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12179 sw_if_index_set = 1;
12180 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12181 sw_if_index_set = 1;
12182 else if (unformat (i, "vtr_op %d", &vtr_op))
12184 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
12187 else if (unformat (i, "push_dot1q %d", &push_dot1q))
12189 else if (unformat (i, "tag1 %d", &tag1))
12191 else if (unformat (i, "tag2 %d", &tag2))
12195 clib_warning ("parse error '%U'", format_unformat_error, i);
12200 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
12202 errmsg ("missing vtr operation or sw_if_index");
12206 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
12207 mp->sw_if_index = ntohl (sw_if_index);
12208 mp->vtr_op = ntohl (vtr_op);
12209 mp->push_dot1q = ntohl (push_dot1q);
12210 mp->tag1 = ntohl (tag1);
12211 mp->tag2 = ntohl (tag2);
12219 api_create_vhost_user_if (vat_main_t * vam)
12221 unformat_input_t *i = vam->input;
12222 vl_api_create_vhost_user_if_t *mp;
12225 u8 file_name_set = 0;
12226 u32 custom_dev_instance = ~0;
12228 u8 use_custom_mac = 0;
12229 u8 disable_mrg_rxbuf = 0;
12230 u8 disable_indirect_desc = 0;
12233 u8 enable_packed = 0;
12236 /* Shut up coverity */
12237 clib_memset (hwaddr, 0, sizeof (hwaddr));
12239 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12241 if (unformat (i, "socket %s", &file_name))
12245 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12247 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
12248 use_custom_mac = 1;
12249 else if (unformat (i, "server"))
12251 else if (unformat (i, "disable_mrg_rxbuf"))
12252 disable_mrg_rxbuf = 1;
12253 else if (unformat (i, "disable_indirect_desc"))
12254 disable_indirect_desc = 1;
12255 else if (unformat (i, "gso"))
12257 else if (unformat (i, "packed"))
12259 else if (unformat (i, "tag %s", &tag))
12265 if (file_name_set == 0)
12267 errmsg ("missing socket file name");
12271 if (vec_len (file_name) > 255)
12273 errmsg ("socket file name too long");
12276 vec_add1 (file_name, 0);
12278 M (CREATE_VHOST_USER_IF, mp);
12280 mp->is_server = is_server;
12281 mp->disable_mrg_rxbuf = disable_mrg_rxbuf;
12282 mp->disable_indirect_desc = disable_indirect_desc;
12283 mp->enable_gso = enable_gso;
12284 mp->enable_packed = enable_packed;
12285 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12286 vec_free (file_name);
12287 if (custom_dev_instance != ~0)
12290 mp->custom_dev_instance = ntohl (custom_dev_instance);
12293 mp->use_custom_mac = use_custom_mac;
12294 clib_memcpy (mp->mac_address, hwaddr, 6);
12296 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
12305 api_modify_vhost_user_if (vat_main_t * vam)
12307 unformat_input_t *i = vam->input;
12308 vl_api_modify_vhost_user_if_t *mp;
12311 u8 file_name_set = 0;
12312 u32 custom_dev_instance = ~0;
12313 u8 sw_if_index_set = 0;
12314 u32 sw_if_index = (u32) ~ 0;
12316 u8 enable_packed = 0;
12319 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12321 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12322 sw_if_index_set = 1;
12323 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12324 sw_if_index_set = 1;
12325 else if (unformat (i, "socket %s", &file_name))
12329 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12331 else if (unformat (i, "server"))
12333 else if (unformat (i, "gso"))
12335 else if (unformat (i, "packed"))
12341 if (sw_if_index_set == 0)
12343 errmsg ("missing sw_if_index or interface name");
12347 if (file_name_set == 0)
12349 errmsg ("missing socket file name");
12353 if (vec_len (file_name) > 255)
12355 errmsg ("socket file name too long");
12358 vec_add1 (file_name, 0);
12360 M (MODIFY_VHOST_USER_IF, mp);
12362 mp->sw_if_index = ntohl (sw_if_index);
12363 mp->is_server = is_server;
12364 mp->enable_gso = enable_gso;
12365 mp->enable_packed = enable_packed;
12366 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12367 vec_free (file_name);
12368 if (custom_dev_instance != ~0)
12371 mp->custom_dev_instance = ntohl (custom_dev_instance);
12380 api_delete_vhost_user_if (vat_main_t * vam)
12382 unformat_input_t *i = vam->input;
12383 vl_api_delete_vhost_user_if_t *mp;
12384 u32 sw_if_index = ~0;
12385 u8 sw_if_index_set = 0;
12388 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12390 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12391 sw_if_index_set = 1;
12392 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12393 sw_if_index_set = 1;
12398 if (sw_if_index_set == 0)
12400 errmsg ("missing sw_if_index or interface name");
12405 M (DELETE_VHOST_USER_IF, mp);
12407 mp->sw_if_index = ntohl (sw_if_index);
12414 static void vl_api_sw_interface_vhost_user_details_t_handler
12415 (vl_api_sw_interface_vhost_user_details_t * mp)
12417 vat_main_t *vam = &vat_main;
12421 clib_net_to_host_u32 (mp->features_first_32) | ((u64)
12422 clib_net_to_host_u32
12423 (mp->features_last_32) <<
12426 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
12427 (char *) mp->interface_name,
12428 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
12429 features, mp->is_server,
12430 ntohl (mp->num_regions), (char *) mp->sock_filename);
12431 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
12434 static void vl_api_sw_interface_vhost_user_details_t_handler_json
12435 (vl_api_sw_interface_vhost_user_details_t * mp)
12437 vat_main_t *vam = &vat_main;
12438 vat_json_node_t *node = NULL;
12440 if (VAT_JSON_ARRAY != vam->json_tree.type)
12442 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12443 vat_json_init_array (&vam->json_tree);
12445 node = vat_json_array_add (&vam->json_tree);
12447 vat_json_init_object (node);
12448 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12449 vat_json_object_add_string_copy (node, "interface_name",
12450 mp->interface_name);
12451 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
12452 ntohl (mp->virtio_net_hdr_sz));
12453 vat_json_object_add_uint (node, "features_first_32",
12454 clib_net_to_host_u32 (mp->features_first_32));
12455 vat_json_object_add_uint (node, "features_last_32",
12456 clib_net_to_host_u32 (mp->features_last_32));
12457 vat_json_object_add_uint (node, "is_server", mp->is_server);
12458 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
12459 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
12460 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
12464 api_sw_interface_vhost_user_dump (vat_main_t * vam)
12466 unformat_input_t *i = vam->input;
12467 vl_api_sw_interface_vhost_user_dump_t *mp;
12468 vl_api_control_ping_t *mp_ping;
12470 u32 sw_if_index = ~0;
12472 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12474 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12476 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12483 "Interface name idx hdr_sz features server regions filename");
12485 /* Get list of vhost-user interfaces */
12486 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
12487 mp->sw_if_index = ntohl (sw_if_index);
12490 /* Use a control ping for synchronization */
12491 MPING (CONTROL_PING, mp_ping);
12499 api_show_version (vat_main_t * vam)
12501 vl_api_show_version_t *mp;
12504 M (SHOW_VERSION, mp);
12513 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
12515 unformat_input_t *line_input = vam->input;
12516 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
12517 ip46_address_t local, remote;
12522 u32 mcast_sw_if_index = ~0;
12523 u32 encap_vrf_id = 0;
12524 u32 decap_vrf_id = 0;
12530 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12532 if (unformat (line_input, "del"))
12534 else if (unformat (line_input, "local %U",
12535 unformat_ip46_address, &local))
12539 else if (unformat (line_input, "remote %U",
12540 unformat_ip46_address, &remote))
12544 else if (unformat (line_input, "group %U %U",
12545 unformat_ip46_address, &remote,
12546 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12548 grp_set = remote_set = 1;
12550 else if (unformat (line_input, "group %U",
12551 unformat_ip46_address, &remote))
12553 grp_set = remote_set = 1;
12556 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12558 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12560 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
12562 else if (unformat (line_input, "vni %d", &vni))
12564 else if (unformat (line_input, "next-ip4"))
12566 else if (unformat (line_input, "next-ip6"))
12568 else if (unformat (line_input, "next-ethernet"))
12570 else if (unformat (line_input, "next-nsh"))
12574 errmsg ("parse error '%U'", format_unformat_error, line_input);
12579 if (local_set == 0)
12581 errmsg ("tunnel local address not specified");
12584 if (remote_set == 0)
12586 errmsg ("tunnel remote address not specified");
12589 if (grp_set && mcast_sw_if_index == ~0)
12591 errmsg ("tunnel nonexistent multicast device");
12594 if (ip46_address_is_ip4 (&local) != ip46_address_is_ip4 (&remote))
12596 errmsg ("both IPv4 and IPv6 addresses specified");
12602 errmsg ("vni not specified");
12606 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
12608 ip_address_encode (&local,
12609 ip46_address_is_ip4 (&local) ? IP46_TYPE_IP4 :
12610 IP46_TYPE_IP6, &mp->local);
12611 ip_address_encode (&remote,
12612 ip46_address_is_ip4 (&remote) ? IP46_TYPE_IP4 :
12613 IP46_TYPE_IP6, &mp->remote);
12615 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12616 mp->encap_vrf_id = ntohl (encap_vrf_id);
12617 mp->decap_vrf_id = ntohl (decap_vrf_id);
12618 mp->protocol = protocol;
12619 mp->vni = ntohl (vni);
12620 mp->is_add = is_add;
12627 static void vl_api_vxlan_gpe_tunnel_details_t_handler
12628 (vl_api_vxlan_gpe_tunnel_details_t * mp)
12630 vat_main_t *vam = &vat_main;
12631 ip46_address_t local, remote;
12633 ip_address_decode (&mp->local, &local);
12634 ip_address_decode (&mp->remote, &remote);
12636 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
12637 ntohl (mp->sw_if_index),
12638 format_ip46_address, &local, IP46_TYPE_ANY,
12639 format_ip46_address, &remote, IP46_TYPE_ANY,
12640 ntohl (mp->vni), mp->protocol,
12641 ntohl (mp->mcast_sw_if_index),
12642 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
12646 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
12647 (vl_api_vxlan_gpe_tunnel_details_t * mp)
12649 vat_main_t *vam = &vat_main;
12650 vat_json_node_t *node = NULL;
12651 struct in_addr ip4;
12652 struct in6_addr ip6;
12653 ip46_address_t local, remote;
12655 ip_address_decode (&mp->local, &local);
12656 ip_address_decode (&mp->remote, &remote);
12658 if (VAT_JSON_ARRAY != vam->json_tree.type)
12660 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12661 vat_json_init_array (&vam->json_tree);
12663 node = vat_json_array_add (&vam->json_tree);
12665 vat_json_init_object (node);
12666 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12667 if (ip46_address_is_ip4 (&local))
12669 clib_memcpy (&ip4, &local.ip4, sizeof (ip4));
12670 vat_json_object_add_ip4 (node, "local", ip4);
12671 clib_memcpy (&ip4, &remote.ip4, sizeof (ip4));
12672 vat_json_object_add_ip4 (node, "remote", ip4);
12676 clib_memcpy (&ip6, &local.ip6, sizeof (ip6));
12677 vat_json_object_add_ip6 (node, "local", ip6);
12678 clib_memcpy (&ip6, &remote.ip6, sizeof (ip6));
12679 vat_json_object_add_ip6 (node, "remote", ip6);
12681 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12682 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
12683 vat_json_object_add_uint (node, "mcast_sw_if_index",
12684 ntohl (mp->mcast_sw_if_index));
12685 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12686 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
12687 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12691 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
12693 unformat_input_t *i = vam->input;
12694 vl_api_vxlan_gpe_tunnel_dump_t *mp;
12695 vl_api_control_ping_t *mp_ping;
12697 u8 sw_if_index_set = 0;
12700 /* Parse args required to build the message */
12701 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12703 if (unformat (i, "sw_if_index %d", &sw_if_index))
12704 sw_if_index_set = 1;
12709 if (sw_if_index_set == 0)
12714 if (!vam->json_output)
12716 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
12717 "sw_if_index", "local", "remote", "vni",
12718 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
12721 /* Get list of vxlan-tunnel interfaces */
12722 M (VXLAN_GPE_TUNNEL_DUMP, mp);
12724 mp->sw_if_index = htonl (sw_if_index);
12728 /* Use a control ping for synchronization */
12729 MPING (CONTROL_PING, mp_ping);
12736 static void vl_api_l2_fib_table_details_t_handler
12737 (vl_api_l2_fib_table_details_t * mp)
12739 vat_main_t *vam = &vat_main;
12741 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
12743 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
12744 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
12748 static void vl_api_l2_fib_table_details_t_handler_json
12749 (vl_api_l2_fib_table_details_t * mp)
12751 vat_main_t *vam = &vat_main;
12752 vat_json_node_t *node = NULL;
12754 if (VAT_JSON_ARRAY != vam->json_tree.type)
12756 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12757 vat_json_init_array (&vam->json_tree);
12759 node = vat_json_array_add (&vam->json_tree);
12761 vat_json_init_object (node);
12762 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
12763 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
12764 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12765 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
12766 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
12767 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
12771 api_l2_fib_table_dump (vat_main_t * vam)
12773 unformat_input_t *i = vam->input;
12774 vl_api_l2_fib_table_dump_t *mp;
12775 vl_api_control_ping_t *mp_ping;
12780 /* Parse args required to build the message */
12781 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12783 if (unformat (i, "bd_id %d", &bd_id))
12789 if (bd_id_set == 0)
12791 errmsg ("missing bridge domain");
12795 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
12797 /* Get list of l2 fib entries */
12798 M (L2_FIB_TABLE_DUMP, mp);
12800 mp->bd_id = ntohl (bd_id);
12803 /* Use a control ping for synchronization */
12804 MPING (CONTROL_PING, mp_ping);
12813 api_interface_name_renumber (vat_main_t * vam)
12815 unformat_input_t *line_input = vam->input;
12816 vl_api_interface_name_renumber_t *mp;
12817 u32 sw_if_index = ~0;
12818 u32 new_show_dev_instance = ~0;
12821 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12823 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
12826 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12828 else if (unformat (line_input, "new_show_dev_instance %d",
12829 &new_show_dev_instance))
12835 if (sw_if_index == ~0)
12837 errmsg ("missing interface name or sw_if_index");
12841 if (new_show_dev_instance == ~0)
12843 errmsg ("missing new_show_dev_instance");
12847 M (INTERFACE_NAME_RENUMBER, mp);
12849 mp->sw_if_index = ntohl (sw_if_index);
12850 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
12858 api_want_l2_macs_events (vat_main_t * vam)
12860 unformat_input_t *line_input = vam->input;
12861 vl_api_want_l2_macs_events_t *mp;
12862 u8 enable_disable = 1;
12863 u32 scan_delay = 0;
12864 u32 max_macs_in_event = 0;
12865 u32 learn_limit = 0;
12868 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12870 if (unformat (line_input, "learn-limit %d", &learn_limit))
12872 else if (unformat (line_input, "scan-delay %d", &scan_delay))
12874 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
12876 else if (unformat (line_input, "disable"))
12877 enable_disable = 0;
12882 M (WANT_L2_MACS_EVENTS, mp);
12883 mp->enable_disable = enable_disable;
12884 mp->pid = htonl (getpid ());
12885 mp->learn_limit = htonl (learn_limit);
12886 mp->scan_delay = (u8) scan_delay;
12887 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
12894 api_input_acl_set_interface (vat_main_t * vam)
12896 unformat_input_t *i = vam->input;
12897 vl_api_input_acl_set_interface_t *mp;
12899 int sw_if_index_set;
12900 u32 ip4_table_index = ~0;
12901 u32 ip6_table_index = ~0;
12902 u32 l2_table_index = ~0;
12906 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12908 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12909 sw_if_index_set = 1;
12910 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12911 sw_if_index_set = 1;
12912 else if (unformat (i, "del"))
12914 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12916 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12918 else if (unformat (i, "l2-table %d", &l2_table_index))
12922 clib_warning ("parse error '%U'", format_unformat_error, i);
12927 if (sw_if_index_set == 0)
12929 errmsg ("missing interface name or sw_if_index");
12933 M (INPUT_ACL_SET_INTERFACE, mp);
12935 mp->sw_if_index = ntohl (sw_if_index);
12936 mp->ip4_table_index = ntohl (ip4_table_index);
12937 mp->ip6_table_index = ntohl (ip6_table_index);
12938 mp->l2_table_index = ntohl (l2_table_index);
12939 mp->is_add = is_add;
12947 api_output_acl_set_interface (vat_main_t * vam)
12949 unformat_input_t *i = vam->input;
12950 vl_api_output_acl_set_interface_t *mp;
12952 int sw_if_index_set;
12953 u32 ip4_table_index = ~0;
12954 u32 ip6_table_index = ~0;
12955 u32 l2_table_index = ~0;
12959 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12961 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12962 sw_if_index_set = 1;
12963 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12964 sw_if_index_set = 1;
12965 else if (unformat (i, "del"))
12967 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12969 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12971 else if (unformat (i, "l2-table %d", &l2_table_index))
12975 clib_warning ("parse error '%U'", format_unformat_error, i);
12980 if (sw_if_index_set == 0)
12982 errmsg ("missing interface name or sw_if_index");
12986 M (OUTPUT_ACL_SET_INTERFACE, mp);
12988 mp->sw_if_index = ntohl (sw_if_index);
12989 mp->ip4_table_index = ntohl (ip4_table_index);
12990 mp->ip6_table_index = ntohl (ip6_table_index);
12991 mp->l2_table_index = ntohl (l2_table_index);
12992 mp->is_add = is_add;
13000 api_ip_address_dump (vat_main_t * vam)
13002 unformat_input_t *i = vam->input;
13003 vl_api_ip_address_dump_t *mp;
13004 vl_api_control_ping_t *mp_ping;
13005 u32 sw_if_index = ~0;
13006 u8 sw_if_index_set = 0;
13011 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13013 if (unformat (i, "sw_if_index %d", &sw_if_index))
13014 sw_if_index_set = 1;
13016 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13017 sw_if_index_set = 1;
13018 else if (unformat (i, "ipv4"))
13020 else if (unformat (i, "ipv6"))
13026 if (ipv4_set && ipv6_set)
13028 errmsg ("ipv4 and ipv6 flags cannot be both set");
13032 if ((!ipv4_set) && (!ipv6_set))
13034 errmsg ("no ipv4 nor ipv6 flag set");
13038 if (sw_if_index_set == 0)
13040 errmsg ("missing interface name or sw_if_index");
13044 vam->current_sw_if_index = sw_if_index;
13045 vam->is_ipv6 = ipv6_set;
13047 M (IP_ADDRESS_DUMP, mp);
13048 mp->sw_if_index = ntohl (sw_if_index);
13049 mp->is_ipv6 = ipv6_set;
13052 /* Use a control ping for synchronization */
13053 MPING (CONTROL_PING, mp_ping);
13061 api_ip_dump (vat_main_t * vam)
13063 vl_api_ip_dump_t *mp;
13064 vl_api_control_ping_t *mp_ping;
13065 unformat_input_t *in = vam->input;
13072 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
13074 if (unformat (in, "ipv4"))
13076 else if (unformat (in, "ipv6"))
13082 if (ipv4_set && ipv6_set)
13084 errmsg ("ipv4 and ipv6 flags cannot be both set");
13088 if ((!ipv4_set) && (!ipv6_set))
13090 errmsg ("no ipv4 nor ipv6 flag set");
13094 is_ipv6 = ipv6_set;
13095 vam->is_ipv6 = is_ipv6;
13097 /* free old data */
13098 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
13100 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
13102 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
13105 mp->is_ipv6 = ipv6_set;
13108 /* Use a control ping for synchronization */
13109 MPING (CONTROL_PING, mp_ping);
13117 api_ipsec_spd_add_del (vat_main_t * vam)
13119 unformat_input_t *i = vam->input;
13120 vl_api_ipsec_spd_add_del_t *mp;
13125 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13127 if (unformat (i, "spd_id %d", &spd_id))
13129 else if (unformat (i, "del"))
13133 clib_warning ("parse error '%U'", format_unformat_error, i);
13139 errmsg ("spd_id must be set");
13143 M (IPSEC_SPD_ADD_DEL, mp);
13145 mp->spd_id = ntohl (spd_id);
13146 mp->is_add = is_add;
13154 api_ipsec_interface_add_del_spd (vat_main_t * vam)
13156 unformat_input_t *i = vam->input;
13157 vl_api_ipsec_interface_add_del_spd_t *mp;
13159 u8 sw_if_index_set = 0;
13160 u32 spd_id = (u32) ~ 0;
13164 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13166 if (unformat (i, "del"))
13168 else if (unformat (i, "spd_id %d", &spd_id))
13171 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13172 sw_if_index_set = 1;
13173 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13174 sw_if_index_set = 1;
13177 clib_warning ("parse error '%U'", format_unformat_error, i);
13183 if (spd_id == (u32) ~ 0)
13185 errmsg ("spd_id must be set");
13189 if (sw_if_index_set == 0)
13191 errmsg ("missing interface name or sw_if_index");
13195 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
13197 mp->spd_id = ntohl (spd_id);
13198 mp->sw_if_index = ntohl (sw_if_index);
13199 mp->is_add = is_add;
13207 api_ipsec_spd_entry_add_del (vat_main_t * vam)
13209 unformat_input_t *i = vam->input;
13210 vl_api_ipsec_spd_entry_add_del_t *mp;
13211 u8 is_add = 1, is_outbound = 0;
13212 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
13214 u32 rport_start = 0, rport_stop = (u32) ~ 0;
13215 u32 lport_start = 0, lport_stop = (u32) ~ 0;
13216 vl_api_address_t laddr_start = { }, laddr_stop =
13225 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13227 if (unformat (i, "del"))
13229 if (unformat (i, "outbound"))
13231 if (unformat (i, "inbound"))
13233 else if (unformat (i, "spd_id %d", &spd_id))
13235 else if (unformat (i, "sa_id %d", &sa_id))
13237 else if (unformat (i, "priority %d", &priority))
13239 else if (unformat (i, "protocol %d", &protocol))
13241 else if (unformat (i, "lport_start %d", &lport_start))
13243 else if (unformat (i, "lport_stop %d", &lport_stop))
13245 else if (unformat (i, "rport_start %d", &rport_start))
13247 else if (unformat (i, "rport_stop %d", &rport_stop))
13249 else if (unformat (i, "laddr_start %U",
13250 unformat_vl_api_address, &laddr_start))
13252 else if (unformat (i, "laddr_stop %U", unformat_vl_api_address,
13255 else if (unformat (i, "raddr_start %U", unformat_vl_api_address,
13258 else if (unformat (i, "raddr_stop %U", unformat_vl_api_address,
13262 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
13264 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
13266 clib_warning ("unsupported action: 'resolve'");
13272 clib_warning ("parse error '%U'", format_unformat_error, i);
13278 M (IPSEC_SPD_ENTRY_ADD_DEL, mp);
13280 mp->is_add = is_add;
13282 mp->entry.spd_id = ntohl (spd_id);
13283 mp->entry.priority = ntohl (priority);
13284 mp->entry.is_outbound = is_outbound;
13286 clib_memcpy (&mp->entry.remote_address_start, &raddr_start,
13287 sizeof (vl_api_address_t));
13288 clib_memcpy (&mp->entry.remote_address_stop, &raddr_stop,
13289 sizeof (vl_api_address_t));
13290 clib_memcpy (&mp->entry.local_address_start, &laddr_start,
13291 sizeof (vl_api_address_t));
13292 clib_memcpy (&mp->entry.local_address_stop, &laddr_stop,
13293 sizeof (vl_api_address_t));
13295 mp->entry.protocol = (u8) protocol;
13296 mp->entry.local_port_start = ntohs ((u16) lport_start);
13297 mp->entry.local_port_stop = ntohs ((u16) lport_stop);
13298 mp->entry.remote_port_start = ntohs ((u16) rport_start);
13299 mp->entry.remote_port_stop = ntohs ((u16) rport_stop);
13300 mp->entry.policy = (u8) policy;
13301 mp->entry.sa_id = ntohl (sa_id);
13309 api_ipsec_sad_entry_add_del (vat_main_t * vam)
13311 unformat_input_t *i = vam->input;
13312 vl_api_ipsec_sad_entry_add_del_t *mp;
13313 u32 sad_id = 0, spi = 0;
13314 u8 *ck = 0, *ik = 0;
13317 vl_api_ipsec_crypto_alg_t crypto_alg = IPSEC_API_CRYPTO_ALG_NONE;
13318 vl_api_ipsec_integ_alg_t integ_alg = IPSEC_API_INTEG_ALG_NONE;
13319 vl_api_ipsec_sad_flags_t flags = IPSEC_API_SAD_FLAG_NONE;
13320 vl_api_ipsec_proto_t protocol = IPSEC_API_PROTO_AH;
13321 vl_api_address_t tun_src, tun_dst;
13324 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13326 if (unformat (i, "del"))
13328 else if (unformat (i, "sad_id %d", &sad_id))
13330 else if (unformat (i, "spi %d", &spi))
13332 else if (unformat (i, "esp"))
13333 protocol = IPSEC_API_PROTO_ESP;
13335 if (unformat (i, "tunnel_src %U", unformat_vl_api_address, &tun_src))
13337 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
13338 if (ADDRESS_IP6 == tun_src.af)
13339 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
13342 if (unformat (i, "tunnel_dst %U", unformat_vl_api_address, &tun_dst))
13344 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
13345 if (ADDRESS_IP6 == tun_src.af)
13346 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
13349 if (unformat (i, "crypto_alg %U",
13350 unformat_ipsec_api_crypto_alg, &crypto_alg))
13352 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
13354 else if (unformat (i, "integ_alg %U",
13355 unformat_ipsec_api_integ_alg, &integ_alg))
13357 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
13361 clib_warning ("parse error '%U'", format_unformat_error, i);
13367 M (IPSEC_SAD_ENTRY_ADD_DEL, mp);
13369 mp->is_add = is_add;
13370 mp->entry.sad_id = ntohl (sad_id);
13371 mp->entry.protocol = protocol;
13372 mp->entry.spi = ntohl (spi);
13373 mp->entry.flags = flags;
13375 mp->entry.crypto_algorithm = crypto_alg;
13376 mp->entry.integrity_algorithm = integ_alg;
13377 mp->entry.crypto_key.length = vec_len (ck);
13378 mp->entry.integrity_key.length = vec_len (ik);
13380 if (mp->entry.crypto_key.length > sizeof (mp->entry.crypto_key.data))
13381 mp->entry.crypto_key.length = sizeof (mp->entry.crypto_key.data);
13383 if (mp->entry.integrity_key.length > sizeof (mp->entry.integrity_key.data))
13384 mp->entry.integrity_key.length = sizeof (mp->entry.integrity_key.data);
13387 clib_memcpy (mp->entry.crypto_key.data, ck, mp->entry.crypto_key.length);
13389 clib_memcpy (mp->entry.integrity_key.data, ik,
13390 mp->entry.integrity_key.length);
13392 if (flags & IPSEC_API_SAD_FLAG_IS_TUNNEL)
13394 clib_memcpy (&mp->entry.tunnel_src, &tun_src,
13395 sizeof (mp->entry.tunnel_src));
13396 clib_memcpy (&mp->entry.tunnel_dst, &tun_dst,
13397 sizeof (mp->entry.tunnel_dst));
13406 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
13408 unformat_input_t *i = vam->input;
13409 vl_api_ipsec_tunnel_if_add_del_t *mp;
13410 u32 local_spi = 0, remote_spi = 0;
13411 u32 crypto_alg = 0, integ_alg = 0;
13412 u8 *lck = NULL, *rck = NULL;
13413 u8 *lik = NULL, *rik = NULL;
13414 vl_api_address_t local_ip = { 0 };
13415 vl_api_address_t remote_ip = { 0 };
13419 u8 anti_replay = 0;
13425 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13427 if (unformat (i, "del"))
13429 else if (unformat (i, "esn"))
13431 else if (unformat (i, "anti-replay"))
13433 else if (unformat (i, "count %d", &count))
13435 else if (unformat (i, "local_spi %d", &local_spi))
13437 else if (unformat (i, "remote_spi %d", &remote_spi))
13440 if (unformat (i, "local_ip %U", unformat_vl_api_address, &local_ip))
13443 if (unformat (i, "remote_ip %U", unformat_vl_api_address, &remote_ip))
13445 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
13448 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
13450 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
13452 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
13456 (i, "crypto_alg %U", unformat_ipsec_api_crypto_alg, &crypto_alg))
13458 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
13460 errmsg ("unsupported crypto-alg: '%U'\n",
13461 format_ipsec_crypto_alg, crypto_alg);
13467 (i, "integ_alg %U", unformat_ipsec_api_integ_alg, &integ_alg))
13469 if (integ_alg >= IPSEC_INTEG_N_ALG)
13471 errmsg ("unsupported integ-alg: '%U'\n",
13472 format_ipsec_integ_alg, integ_alg);
13476 else if (unformat (i, "instance %u", &instance))
13480 errmsg ("parse error '%U'\n", format_unformat_error, i);
13487 /* Turn on async mode */
13488 vam->async_mode = 1;
13489 vam->async_errors = 0;
13490 before = vat_time_now (vam);
13493 for (jj = 0; jj < count; jj++)
13495 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
13497 mp->is_add = is_add;
13499 mp->anti_replay = anti_replay;
13502 increment_address (&remote_ip);
13504 clib_memcpy (&mp->local_ip, &local_ip, sizeof (local_ip));
13505 clib_memcpy (&mp->remote_ip, &remote_ip, sizeof (remote_ip));
13507 mp->local_spi = htonl (local_spi + jj);
13508 mp->remote_spi = htonl (remote_spi + jj);
13509 mp->crypto_alg = (u8) crypto_alg;
13511 mp->local_crypto_key_len = 0;
13514 mp->local_crypto_key_len = vec_len (lck);
13515 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
13516 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
13517 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
13520 mp->remote_crypto_key_len = 0;
13523 mp->remote_crypto_key_len = vec_len (rck);
13524 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
13525 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
13526 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
13529 mp->integ_alg = (u8) integ_alg;
13531 mp->local_integ_key_len = 0;
13534 mp->local_integ_key_len = vec_len (lik);
13535 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
13536 mp->local_integ_key_len = sizeof (mp->local_integ_key);
13537 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
13540 mp->remote_integ_key_len = 0;
13543 mp->remote_integ_key_len = vec_len (rik);
13544 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
13545 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
13546 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
13551 mp->renumber = renumber;
13552 mp->show_instance = ntohl (instance);
13557 /* When testing multiple add/del ops, use a control-ping to sync */
13560 vl_api_control_ping_t *mp_ping;
13564 /* Shut off async mode */
13565 vam->async_mode = 0;
13567 MPING (CONTROL_PING, mp_ping);
13570 timeout = vat_time_now (vam) + 1.0;
13571 while (vat_time_now (vam) < timeout)
13572 if (vam->result_ready == 1)
13577 if (vam->retval == -99)
13578 errmsg ("timeout");
13580 if (vam->async_errors > 0)
13582 errmsg ("%d asynchronous errors", vam->async_errors);
13585 vam->async_errors = 0;
13586 after = vat_time_now (vam);
13588 /* slim chance, but we might have eaten SIGTERM on the first iteration */
13592 print (vam->ofp, "%d tunnels in %.6f secs, %.2f tunnels/sec",
13593 count, after - before, count / (after - before));
13597 /* Wait for a reply... */
13606 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
13608 vat_main_t *vam = &vat_main;
13610 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
13611 "crypto_key %U integ_alg %u integ_key %U flags %x "
13612 "tunnel_src_addr %U tunnel_dst_addr %U "
13613 "salt %u seq_outbound %lu last_seq_inbound %lu "
13614 "replay_window %lu stat_index %u\n",
13615 ntohl (mp->entry.sad_id),
13616 ntohl (mp->sw_if_index),
13617 ntohl (mp->entry.spi),
13618 ntohl (mp->entry.protocol),
13619 ntohl (mp->entry.crypto_algorithm),
13620 format_hex_bytes, mp->entry.crypto_key.data,
13621 mp->entry.crypto_key.length, ntohl (mp->entry.integrity_algorithm),
13622 format_hex_bytes, mp->entry.integrity_key.data,
13623 mp->entry.integrity_key.length, ntohl (mp->entry.flags),
13624 format_vl_api_address, &mp->entry.tunnel_src, format_vl_api_address,
13625 &mp->entry.tunnel_dst, ntohl (mp->salt),
13626 clib_net_to_host_u64 (mp->seq_outbound),
13627 clib_net_to_host_u64 (mp->last_seq_inbound),
13628 clib_net_to_host_u64 (mp->replay_window), ntohl (mp->stat_index));
13631 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
13632 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
13634 static void vl_api_ipsec_sa_details_t_handler_json
13635 (vl_api_ipsec_sa_details_t * mp)
13637 vat_main_t *vam = &vat_main;
13638 vat_json_node_t *node = NULL;
13639 vl_api_ipsec_sad_flags_t flags;
13641 if (VAT_JSON_ARRAY != vam->json_tree.type)
13643 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13644 vat_json_init_array (&vam->json_tree);
13646 node = vat_json_array_add (&vam->json_tree);
13648 vat_json_init_object (node);
13649 vat_json_object_add_uint (node, "sa_id", ntohl (mp->entry.sad_id));
13650 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13651 vat_json_object_add_uint (node, "spi", ntohl (mp->entry.spi));
13652 vat_json_object_add_uint (node, "proto", ntohl (mp->entry.protocol));
13653 vat_json_object_add_uint (node, "crypto_alg",
13654 ntohl (mp->entry.crypto_algorithm));
13655 vat_json_object_add_uint (node, "integ_alg",
13656 ntohl (mp->entry.integrity_algorithm));
13657 flags = ntohl (mp->entry.flags);
13658 vat_json_object_add_uint (node, "use_esn",
13659 ! !(flags & IPSEC_API_SAD_FLAG_USE_ESN));
13660 vat_json_object_add_uint (node, "use_anti_replay",
13661 ! !(flags & IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY));
13662 vat_json_object_add_uint (node, "is_tunnel",
13663 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL));
13664 vat_json_object_add_uint (node, "is_tunnel_ip6",
13665 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL_V6));
13666 vat_json_object_add_uint (node, "udp_encap",
13667 ! !(flags & IPSEC_API_SAD_FLAG_UDP_ENCAP));
13668 vat_json_object_add_bytes (node, "crypto_key", mp->entry.crypto_key.data,
13669 mp->entry.crypto_key.length);
13670 vat_json_object_add_bytes (node, "integ_key", mp->entry.integrity_key.data,
13671 mp->entry.integrity_key.length);
13672 vat_json_object_add_address (node, "src", &mp->entry.tunnel_src);
13673 vat_json_object_add_address (node, "dst", &mp->entry.tunnel_dst);
13674 vat_json_object_add_uint (node, "replay_window",
13675 clib_net_to_host_u64 (mp->replay_window));
13676 vat_json_object_add_uint (node, "stat_index", ntohl (mp->stat_index));
13680 api_ipsec_sa_dump (vat_main_t * vam)
13682 unformat_input_t *i = vam->input;
13683 vl_api_ipsec_sa_dump_t *mp;
13684 vl_api_control_ping_t *mp_ping;
13688 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13690 if (unformat (i, "sa_id %d", &sa_id))
13694 clib_warning ("parse error '%U'", format_unformat_error, i);
13699 M (IPSEC_SA_DUMP, mp);
13701 mp->sa_id = ntohl (sa_id);
13705 /* Use a control ping for synchronization */
13706 M (CONTROL_PING, mp_ping);
13714 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
13716 unformat_input_t *i = vam->input;
13717 vl_api_ipsec_tunnel_if_set_sa_t *mp;
13718 u32 sw_if_index = ~0;
13720 u8 is_outbound = (u8) ~ 0;
13723 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13725 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13727 else if (unformat (i, "sa_id %d", &sa_id))
13729 else if (unformat (i, "outbound"))
13731 else if (unformat (i, "inbound"))
13735 clib_warning ("parse error '%U'", format_unformat_error, i);
13740 if (sw_if_index == ~0)
13742 errmsg ("interface must be specified");
13748 errmsg ("SA ID must be specified");
13752 M (IPSEC_TUNNEL_IF_SET_SA, mp);
13754 mp->sw_if_index = htonl (sw_if_index);
13755 mp->sa_id = htonl (sa_id);
13756 mp->is_outbound = is_outbound;
13765 api_get_first_msg_id (vat_main_t * vam)
13767 vl_api_get_first_msg_id_t *mp;
13768 unformat_input_t *i = vam->input;
13773 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13775 if (unformat (i, "client %s", &name))
13783 errmsg ("missing client name");
13786 vec_add1 (name, 0);
13788 if (vec_len (name) > 63)
13790 errmsg ("client name too long");
13794 M (GET_FIRST_MSG_ID, mp);
13795 clib_memcpy (mp->name, name, vec_len (name));
13802 api_cop_interface_enable_disable (vat_main_t * vam)
13804 unformat_input_t *line_input = vam->input;
13805 vl_api_cop_interface_enable_disable_t *mp;
13806 u32 sw_if_index = ~0;
13807 u8 enable_disable = 1;
13810 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13812 if (unformat (line_input, "disable"))
13813 enable_disable = 0;
13814 if (unformat (line_input, "enable"))
13815 enable_disable = 1;
13816 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13817 vam, &sw_if_index))
13819 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13825 if (sw_if_index == ~0)
13827 errmsg ("missing interface name or sw_if_index");
13831 /* Construct the API message */
13832 M (COP_INTERFACE_ENABLE_DISABLE, mp);
13833 mp->sw_if_index = ntohl (sw_if_index);
13834 mp->enable_disable = enable_disable;
13838 /* Wait for the reply */
13844 api_cop_whitelist_enable_disable (vat_main_t * vam)
13846 unformat_input_t *line_input = vam->input;
13847 vl_api_cop_whitelist_enable_disable_t *mp;
13848 u32 sw_if_index = ~0;
13849 u8 ip4 = 0, ip6 = 0, default_cop = 0;
13853 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13855 if (unformat (line_input, "ip4"))
13857 else if (unformat (line_input, "ip6"))
13859 else if (unformat (line_input, "default"))
13861 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13862 vam, &sw_if_index))
13864 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13866 else if (unformat (line_input, "fib-id %d", &fib_id))
13872 if (sw_if_index == ~0)
13874 errmsg ("missing interface name or sw_if_index");
13878 /* Construct the API message */
13879 M (COP_WHITELIST_ENABLE_DISABLE, mp);
13880 mp->sw_if_index = ntohl (sw_if_index);
13881 mp->fib_id = ntohl (fib_id);
13884 mp->default_cop = default_cop;
13888 /* Wait for the reply */
13894 api_get_node_graph (vat_main_t * vam)
13896 vl_api_get_node_graph_t *mp;
13899 M (GET_NODE_GRAPH, mp);
13903 /* Wait for the reply */
13909 /** Used for parsing LISP eids */
13910 typedef CLIB_PACKED(struct{
13914 lisp_nsh_api_t nsh;
13916 u32 len; /**< prefix length if IP */
13917 u8 type; /**< type of eid */
13922 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
13924 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
13926 clib_memset (a, 0, sizeof (a[0]));
13928 if (unformat (input, "%U/%d", unformat_ip46_address, a->addr.ip, &a->len))
13930 a->type = 0; /* ip prefix type */
13932 else if (unformat (input, "%U", unformat_ethernet_address, &a->addr.mac))
13934 a->type = 1; /* mac type */
13936 else if (unformat (input, "%U", unformat_nsh_address, a->addr.nsh))
13938 a->type = 2; /* NSH type */
13939 a->addr.nsh.spi = clib_host_to_net_u32 (a->addr.nsh.spi);
13948 if (ip46_address_is_ip4 (&a->addr.ip))
13949 return a->len > 32 ? 1 : 0;
13951 return a->len > 128 ? 1 : 0;
13958 lisp_eid_put_vat (vl_api_eid_t * eid, const lisp_eid_vat_t * vat_eid)
13960 eid->type = vat_eid->type;
13963 case EID_TYPE_API_PREFIX:
13964 if (ip46_address_is_ip4 (&vat_eid->addr.ip))
13966 clib_memcpy (&eid->address.prefix.address.un.ip4,
13967 &vat_eid->addr.ip.ip4, 4);
13968 eid->address.prefix.address.af = ADDRESS_IP4;
13969 eid->address.prefix.len = vat_eid->len;
13973 clib_memcpy (&eid->address.prefix.address.un.ip6,
13974 &vat_eid->addr.ip.ip6, 16);
13975 eid->address.prefix.address.af = ADDRESS_IP6;
13976 eid->address.prefix.len = vat_eid->len;
13979 case EID_TYPE_API_MAC:
13980 clib_memcpy (&eid->address.mac, &vat_eid->addr.mac,
13981 sizeof (eid->address.mac));
13983 case EID_TYPE_API_NSH:
13984 clib_memcpy (&eid->address.nsh, &vat_eid->addr.nsh,
13985 sizeof (eid->address.nsh));
13994 api_one_add_del_locator_set (vat_main_t * vam)
13996 unformat_input_t *input = vam->input;
13997 vl_api_one_add_del_locator_set_t *mp;
13999 u8 *locator_set_name = NULL;
14000 u8 locator_set_name_set = 0;
14001 vl_api_local_locator_t locator, *locators = 0;
14002 u32 sw_if_index, priority, weight;
14006 /* Parse args required to build the message */
14007 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14009 if (unformat (input, "del"))
14013 else if (unformat (input, "locator-set %s", &locator_set_name))
14015 locator_set_name_set = 1;
14017 else if (unformat (input, "sw_if_index %u p %u w %u",
14018 &sw_if_index, &priority, &weight))
14020 locator.sw_if_index = htonl (sw_if_index);
14021 locator.priority = priority;
14022 locator.weight = weight;
14023 vec_add1 (locators, locator);
14027 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
14028 &sw_if_index, &priority, &weight))
14030 locator.sw_if_index = htonl (sw_if_index);
14031 locator.priority = priority;
14032 locator.weight = weight;
14033 vec_add1 (locators, locator);
14039 if (locator_set_name_set == 0)
14041 errmsg ("missing locator-set name");
14042 vec_free (locators);
14046 if (vec_len (locator_set_name) > 64)
14048 errmsg ("locator-set name too long");
14049 vec_free (locator_set_name);
14050 vec_free (locators);
14053 vec_add1 (locator_set_name, 0);
14055 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
14057 /* Construct the API message */
14058 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
14060 mp->is_add = is_add;
14061 clib_memcpy (mp->locator_set_name, locator_set_name,
14062 vec_len (locator_set_name));
14063 vec_free (locator_set_name);
14065 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
14067 clib_memcpy (mp->locators, locators, data_len);
14068 vec_free (locators);
14073 /* Wait for a reply... */
14078 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
14081 api_one_add_del_locator (vat_main_t * vam)
14083 unformat_input_t *input = vam->input;
14084 vl_api_one_add_del_locator_t *mp;
14085 u32 tmp_if_index = ~0;
14086 u32 sw_if_index = ~0;
14087 u8 sw_if_index_set = 0;
14088 u8 sw_if_index_if_name_set = 0;
14090 u8 priority_set = 0;
14094 u8 *locator_set_name = NULL;
14095 u8 locator_set_name_set = 0;
14098 /* Parse args required to build the message */
14099 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14101 if (unformat (input, "del"))
14105 else if (unformat (input, "locator-set %s", &locator_set_name))
14107 locator_set_name_set = 1;
14109 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
14112 sw_if_index_if_name_set = 1;
14113 sw_if_index = tmp_if_index;
14115 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
14117 sw_if_index_set = 1;
14118 sw_if_index = tmp_if_index;
14120 else if (unformat (input, "p %d", &priority))
14124 else if (unformat (input, "w %d", &weight))
14132 if (locator_set_name_set == 0)
14134 errmsg ("missing locator-set name");
14138 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
14140 errmsg ("missing sw_if_index");
14141 vec_free (locator_set_name);
14145 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
14147 errmsg ("cannot use both params interface name and sw_if_index");
14148 vec_free (locator_set_name);
14152 if (priority_set == 0)
14154 errmsg ("missing locator-set priority");
14155 vec_free (locator_set_name);
14159 if (weight_set == 0)
14161 errmsg ("missing locator-set weight");
14162 vec_free (locator_set_name);
14166 if (vec_len (locator_set_name) > 64)
14168 errmsg ("locator-set name too long");
14169 vec_free (locator_set_name);
14172 vec_add1 (locator_set_name, 0);
14174 /* Construct the API message */
14175 M (ONE_ADD_DEL_LOCATOR, mp);
14177 mp->is_add = is_add;
14178 mp->sw_if_index = ntohl (sw_if_index);
14179 mp->priority = priority;
14180 mp->weight = weight;
14181 clib_memcpy (mp->locator_set_name, locator_set_name,
14182 vec_len (locator_set_name));
14183 vec_free (locator_set_name);
14188 /* Wait for a reply... */
14193 #define api_lisp_add_del_locator api_one_add_del_locator
14196 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
14198 u32 *key_id = va_arg (*args, u32 *);
14201 if (unformat (input, "%s", &s))
14203 if (!strcmp ((char *) s, "sha1"))
14204 key_id[0] = HMAC_SHA_1_96;
14205 else if (!strcmp ((char *) s, "sha256"))
14206 key_id[0] = HMAC_SHA_256_128;
14209 clib_warning ("invalid key_id: '%s'", s);
14210 key_id[0] = HMAC_NO_KEY;
14221 api_one_add_del_local_eid (vat_main_t * vam)
14223 unformat_input_t *input = vam->input;
14224 vl_api_one_add_del_local_eid_t *mp;
14227 lisp_eid_vat_t _eid, *eid = &_eid;
14228 u8 *locator_set_name = 0;
14229 u8 locator_set_name_set = 0;
14235 /* Parse args required to build the message */
14236 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14238 if (unformat (input, "del"))
14242 else if (unformat (input, "vni %d", &vni))
14246 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14250 else if (unformat (input, "locator-set %s", &locator_set_name))
14252 locator_set_name_set = 1;
14254 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
14256 else if (unformat (input, "secret-key %_%v%_", &key))
14262 if (locator_set_name_set == 0)
14264 errmsg ("missing locator-set name");
14270 errmsg ("EID address not set!");
14271 vec_free (locator_set_name);
14275 if (key && (0 == key_id))
14277 errmsg ("invalid key_id!");
14281 if (vec_len (key) > 64)
14283 errmsg ("key too long");
14288 if (vec_len (locator_set_name) > 64)
14290 errmsg ("locator-set name too long");
14291 vec_free (locator_set_name);
14294 vec_add1 (locator_set_name, 0);
14296 /* Construct the API message */
14297 M (ONE_ADD_DEL_LOCAL_EID, mp);
14299 mp->is_add = is_add;
14300 lisp_eid_put_vat (&mp->eid, eid);
14301 mp->vni = clib_host_to_net_u32 (vni);
14302 mp->key.id = key_id;
14303 clib_memcpy (mp->locator_set_name, locator_set_name,
14304 vec_len (locator_set_name));
14305 clib_memcpy (mp->key.key, key, vec_len (key));
14307 vec_free (locator_set_name);
14313 /* Wait for a reply... */
14318 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
14321 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
14323 u32 dp_table = 0, vni = 0;;
14324 unformat_input_t *input = vam->input;
14325 vl_api_gpe_add_del_fwd_entry_t *mp;
14327 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
14328 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
14329 u8 rmt_eid_set = 0, lcl_eid_set = 0;
14330 u32 action = ~0, w;
14331 ip4_address_t rmt_rloc4, lcl_rloc4;
14332 ip6_address_t rmt_rloc6, lcl_rloc6;
14333 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
14336 clib_memset (&rloc, 0, sizeof (rloc));
14338 /* Parse args required to build the message */
14339 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14341 if (unformat (input, "del"))
14343 else if (unformat (input, "add"))
14345 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
14349 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
14353 else if (unformat (input, "vrf %d", &dp_table))
14355 else if (unformat (input, "bd %d", &dp_table))
14357 else if (unformat (input, "vni %d", &vni))
14359 else if (unformat (input, "w %d", &w))
14363 errmsg ("No RLOC configured for setting priority/weight!");
14366 curr_rloc->weight = w;
14368 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
14369 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
14372 clib_memcpy (&rloc.addr.un.ip4, &lcl_rloc4, sizeof (lcl_rloc4));
14374 vec_add1 (lcl_locs, rloc);
14376 clib_memcpy (&rloc.addr.un.ip4, &rmt_rloc4, sizeof (rmt_rloc4));
14377 vec_add1 (rmt_locs, rloc);
14378 /* weight saved in rmt loc */
14379 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14381 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
14382 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
14385 clib_memcpy (&rloc.addr.un.ip6, &lcl_rloc6, sizeof (lcl_rloc6));
14387 vec_add1 (lcl_locs, rloc);
14389 clib_memcpy (&rloc.addr.un.ip6, &rmt_rloc6, sizeof (rmt_rloc6));
14390 vec_add1 (rmt_locs, rloc);
14391 /* weight saved in rmt loc */
14392 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14394 else if (unformat (input, "action %d", &action))
14400 clib_warning ("parse error '%U'", format_unformat_error, input);
14407 errmsg ("remote eid addresses not set");
14411 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
14413 errmsg ("eid types don't match");
14417 if (0 == rmt_locs && (u32) ~ 0 == action)
14419 errmsg ("action not set for negative mapping");
14423 /* Construct the API message */
14424 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
14425 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
14427 mp->is_add = is_add;
14428 lisp_eid_put_vat (&mp->rmt_eid, rmt_eid);
14429 lisp_eid_put_vat (&mp->lcl_eid, lcl_eid);
14430 mp->dp_table = clib_host_to_net_u32 (dp_table);
14431 mp->vni = clib_host_to_net_u32 (vni);
14432 mp->action = action;
14434 if (0 != rmt_locs && 0 != lcl_locs)
14436 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
14437 clib_memcpy (mp->locs, lcl_locs,
14438 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
14440 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
14441 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
14442 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
14444 vec_free (lcl_locs);
14445 vec_free (rmt_locs);
14450 /* Wait for a reply... */
14456 api_one_add_del_map_server (vat_main_t * vam)
14458 unformat_input_t *input = vam->input;
14459 vl_api_one_add_del_map_server_t *mp;
14463 ip4_address_t ipv4;
14464 ip6_address_t ipv6;
14467 /* Parse args required to build the message */
14468 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14470 if (unformat (input, "del"))
14474 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14478 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14486 if (ipv4_set && ipv6_set)
14488 errmsg ("both eid v4 and v6 addresses set");
14492 if (!ipv4_set && !ipv6_set)
14494 errmsg ("eid addresses not set");
14498 /* Construct the API message */
14499 M (ONE_ADD_DEL_MAP_SERVER, mp);
14501 mp->is_add = is_add;
14504 mp->ip_address.af = 1;
14505 clib_memcpy (mp->ip_address.un.ip6, &ipv6, sizeof (ipv6));
14509 mp->ip_address.af = 0;
14510 clib_memcpy (mp->ip_address.un.ip4, &ipv4, sizeof (ipv4));
14516 /* Wait for a reply... */
14521 #define api_lisp_add_del_map_server api_one_add_del_map_server
14524 api_one_add_del_map_resolver (vat_main_t * vam)
14526 unformat_input_t *input = vam->input;
14527 vl_api_one_add_del_map_resolver_t *mp;
14531 ip4_address_t ipv4;
14532 ip6_address_t ipv6;
14535 /* Parse args required to build the message */
14536 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14538 if (unformat (input, "del"))
14542 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14546 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14554 if (ipv4_set && ipv6_set)
14556 errmsg ("both eid v4 and v6 addresses set");
14560 if (!ipv4_set && !ipv6_set)
14562 errmsg ("eid addresses not set");
14566 /* Construct the API message */
14567 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
14569 mp->is_add = is_add;
14572 mp->ip_address.af = 1;
14573 clib_memcpy (mp->ip_address.un.ip6, &ipv6, sizeof (ipv6));
14577 mp->ip_address.af = 0;
14578 clib_memcpy (mp->ip_address.un.ip6, &ipv4, sizeof (ipv4));
14584 /* Wait for a reply... */
14589 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
14592 api_lisp_gpe_enable_disable (vat_main_t * vam)
14594 unformat_input_t *input = vam->input;
14595 vl_api_gpe_enable_disable_t *mp;
14600 /* Parse args required to build the message */
14601 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14603 if (unformat (input, "enable"))
14608 else if (unformat (input, "disable"))
14619 errmsg ("Value not set");
14623 /* Construct the API message */
14624 M (GPE_ENABLE_DISABLE, mp);
14626 mp->is_enable = is_enable;
14631 /* Wait for a reply... */
14637 api_one_rloc_probe_enable_disable (vat_main_t * vam)
14639 unformat_input_t *input = vam->input;
14640 vl_api_one_rloc_probe_enable_disable_t *mp;
14645 /* Parse args required to build the message */
14646 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14648 if (unformat (input, "enable"))
14653 else if (unformat (input, "disable"))
14661 errmsg ("Value not set");
14665 /* Construct the API message */
14666 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
14668 mp->is_enable = is_enable;
14673 /* Wait for a reply... */
14678 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
14681 api_one_map_register_enable_disable (vat_main_t * vam)
14683 unformat_input_t *input = vam->input;
14684 vl_api_one_map_register_enable_disable_t *mp;
14689 /* Parse args required to build the message */
14690 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14692 if (unformat (input, "enable"))
14697 else if (unformat (input, "disable"))
14705 errmsg ("Value not set");
14709 /* Construct the API message */
14710 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
14712 mp->is_enable = is_enable;
14717 /* Wait for a reply... */
14722 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
14725 api_one_enable_disable (vat_main_t * vam)
14727 unformat_input_t *input = vam->input;
14728 vl_api_one_enable_disable_t *mp;
14733 /* Parse args required to build the message */
14734 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14736 if (unformat (input, "enable"))
14741 else if (unformat (input, "disable"))
14751 errmsg ("Value not set");
14755 /* Construct the API message */
14756 M (ONE_ENABLE_DISABLE, mp);
14758 mp->is_enable = is_enable;
14763 /* Wait for a reply... */
14768 #define api_lisp_enable_disable api_one_enable_disable
14771 api_one_enable_disable_xtr_mode (vat_main_t * vam)
14773 unformat_input_t *input = vam->input;
14774 vl_api_one_enable_disable_xtr_mode_t *mp;
14779 /* Parse args required to build the message */
14780 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14782 if (unformat (input, "enable"))
14787 else if (unformat (input, "disable"))
14797 errmsg ("Value not set");
14801 /* Construct the API message */
14802 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
14804 mp->is_enable = is_enable;
14809 /* Wait for a reply... */
14815 api_one_show_xtr_mode (vat_main_t * vam)
14817 vl_api_one_show_xtr_mode_t *mp;
14820 /* Construct the API message */
14821 M (ONE_SHOW_XTR_MODE, mp);
14826 /* Wait for a reply... */
14832 api_one_enable_disable_pitr_mode (vat_main_t * vam)
14834 unformat_input_t *input = vam->input;
14835 vl_api_one_enable_disable_pitr_mode_t *mp;
14840 /* Parse args required to build the message */
14841 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14843 if (unformat (input, "enable"))
14848 else if (unformat (input, "disable"))
14858 errmsg ("Value not set");
14862 /* Construct the API message */
14863 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
14865 mp->is_enable = is_enable;
14870 /* Wait for a reply... */
14876 api_one_show_pitr_mode (vat_main_t * vam)
14878 vl_api_one_show_pitr_mode_t *mp;
14881 /* Construct the API message */
14882 M (ONE_SHOW_PITR_MODE, mp);
14887 /* Wait for a reply... */
14893 api_one_enable_disable_petr_mode (vat_main_t * vam)
14895 unformat_input_t *input = vam->input;
14896 vl_api_one_enable_disable_petr_mode_t *mp;
14901 /* Parse args required to build the message */
14902 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14904 if (unformat (input, "enable"))
14909 else if (unformat (input, "disable"))
14919 errmsg ("Value not set");
14923 /* Construct the API message */
14924 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
14926 mp->is_enable = is_enable;
14931 /* Wait for a reply... */
14937 api_one_show_petr_mode (vat_main_t * vam)
14939 vl_api_one_show_petr_mode_t *mp;
14942 /* Construct the API message */
14943 M (ONE_SHOW_PETR_MODE, mp);
14948 /* Wait for a reply... */
14954 api_show_one_map_register_state (vat_main_t * vam)
14956 vl_api_show_one_map_register_state_t *mp;
14959 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
14964 /* wait for reply */
14969 #define api_show_lisp_map_register_state api_show_one_map_register_state
14972 api_show_one_rloc_probe_state (vat_main_t * vam)
14974 vl_api_show_one_rloc_probe_state_t *mp;
14977 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
14982 /* wait for reply */
14987 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
14990 api_one_add_del_ndp_entry (vat_main_t * vam)
14992 vl_api_one_add_del_ndp_entry_t *mp;
14993 unformat_input_t *input = vam->input;
14998 u8 mac[6] = { 0, };
14999 u8 ip6[16] = { 0, };
15003 /* Parse args required to build the message */
15004 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15006 if (unformat (input, "del"))
15008 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
15010 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
15012 else if (unformat (input, "bd %d", &bd))
15016 errmsg ("parse error '%U'", format_unformat_error, input);
15021 if (!bd_set || !ip_set || (!mac_set && is_add))
15023 errmsg ("Missing BD, IP or MAC!");
15027 M (ONE_ADD_DEL_NDP_ENTRY, mp);
15028 mp->is_add = is_add;
15029 clib_memcpy (&mp->entry.mac, mac, 6);
15030 mp->bd = clib_host_to_net_u32 (bd);
15031 clib_memcpy (&mp->entry.ip6, ip6, sizeof (mp->entry.ip6));
15036 /* wait for reply */
15042 api_one_add_del_l2_arp_entry (vat_main_t * vam)
15044 vl_api_one_add_del_l2_arp_entry_t *mp;
15045 unformat_input_t *input = vam->input;
15050 u8 mac[6] = { 0, };
15051 u32 ip4 = 0, bd = ~0;
15054 /* Parse args required to build the message */
15055 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15057 if (unformat (input, "del"))
15059 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
15061 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
15063 else if (unformat (input, "bd %d", &bd))
15067 errmsg ("parse error '%U'", format_unformat_error, input);
15072 if (!bd_set || !ip_set || (!mac_set && is_add))
15074 errmsg ("Missing BD, IP or MAC!");
15078 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
15079 mp->is_add = is_add;
15080 clib_memcpy (&mp->entry.mac, mac, 6);
15081 mp->bd = clib_host_to_net_u32 (bd);
15082 clib_memcpy (mp->entry.ip4, &ip4, sizeof (mp->entry.ip4));
15087 /* wait for reply */
15093 api_one_ndp_bd_get (vat_main_t * vam)
15095 vl_api_one_ndp_bd_get_t *mp;
15098 M (ONE_NDP_BD_GET, mp);
15103 /* wait for reply */
15109 api_one_ndp_entries_get (vat_main_t * vam)
15111 vl_api_one_ndp_entries_get_t *mp;
15112 unformat_input_t *input = vam->input;
15117 /* Parse args required to build the message */
15118 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15120 if (unformat (input, "bd %d", &bd))
15124 errmsg ("parse error '%U'", format_unformat_error, input);
15131 errmsg ("Expected bridge domain!");
15135 M (ONE_NDP_ENTRIES_GET, mp);
15136 mp->bd = clib_host_to_net_u32 (bd);
15141 /* wait for reply */
15147 api_one_l2_arp_bd_get (vat_main_t * vam)
15149 vl_api_one_l2_arp_bd_get_t *mp;
15152 M (ONE_L2_ARP_BD_GET, mp);
15157 /* wait for reply */
15163 api_one_l2_arp_entries_get (vat_main_t * vam)
15165 vl_api_one_l2_arp_entries_get_t *mp;
15166 unformat_input_t *input = vam->input;
15171 /* Parse args required to build the message */
15172 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15174 if (unformat (input, "bd %d", &bd))
15178 errmsg ("parse error '%U'", format_unformat_error, input);
15185 errmsg ("Expected bridge domain!");
15189 M (ONE_L2_ARP_ENTRIES_GET, mp);
15190 mp->bd = clib_host_to_net_u32 (bd);
15195 /* wait for reply */
15201 api_one_stats_enable_disable (vat_main_t * vam)
15203 vl_api_one_stats_enable_disable_t *mp;
15204 unformat_input_t *input = vam->input;
15209 /* Parse args required to build the message */
15210 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15212 if (unformat (input, "enable"))
15217 else if (unformat (input, "disable"))
15227 errmsg ("Value not set");
15231 M (ONE_STATS_ENABLE_DISABLE, mp);
15232 mp->is_enable = is_enable;
15237 /* wait for reply */
15243 api_show_one_stats_enable_disable (vat_main_t * vam)
15245 vl_api_show_one_stats_enable_disable_t *mp;
15248 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
15253 /* wait for reply */
15259 api_show_one_map_request_mode (vat_main_t * vam)
15261 vl_api_show_one_map_request_mode_t *mp;
15264 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
15269 /* wait for reply */
15274 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
15277 api_one_map_request_mode (vat_main_t * vam)
15279 unformat_input_t *input = vam->input;
15280 vl_api_one_map_request_mode_t *mp;
15284 /* Parse args required to build the message */
15285 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15287 if (unformat (input, "dst-only"))
15289 else if (unformat (input, "src-dst"))
15293 errmsg ("parse error '%U'", format_unformat_error, input);
15298 M (ONE_MAP_REQUEST_MODE, mp);
15305 /* wait for reply */
15310 #define api_lisp_map_request_mode api_one_map_request_mode
15313 * Enable/disable ONE proxy ITR.
15315 * @param vam vpp API test context
15316 * @return return code
15319 api_one_pitr_set_locator_set (vat_main_t * vam)
15321 u8 ls_name_set = 0;
15322 unformat_input_t *input = vam->input;
15323 vl_api_one_pitr_set_locator_set_t *mp;
15328 /* Parse args required to build the message */
15329 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15331 if (unformat (input, "del"))
15333 else if (unformat (input, "locator-set %s", &ls_name))
15337 errmsg ("parse error '%U'", format_unformat_error, input);
15344 errmsg ("locator-set name not set!");
15348 M (ONE_PITR_SET_LOCATOR_SET, mp);
15350 mp->is_add = is_add;
15351 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
15352 vec_free (ls_name);
15357 /* wait for reply */
15362 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
15365 api_one_nsh_set_locator_set (vat_main_t * vam)
15367 u8 ls_name_set = 0;
15368 unformat_input_t *input = vam->input;
15369 vl_api_one_nsh_set_locator_set_t *mp;
15374 /* Parse args required to build the message */
15375 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15377 if (unformat (input, "del"))
15379 else if (unformat (input, "ls %s", &ls_name))
15383 errmsg ("parse error '%U'", format_unformat_error, input);
15388 if (!ls_name_set && is_add)
15390 errmsg ("locator-set name not set!");
15394 M (ONE_NSH_SET_LOCATOR_SET, mp);
15396 mp->is_add = is_add;
15397 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
15398 vec_free (ls_name);
15403 /* wait for reply */
15409 api_show_one_pitr (vat_main_t * vam)
15411 vl_api_show_one_pitr_t *mp;
15414 if (!vam->json_output)
15416 print (vam->ofp, "%=20s", "lisp status:");
15419 M (SHOW_ONE_PITR, mp);
15423 /* Wait for a reply... */
15428 #define api_show_lisp_pitr api_show_one_pitr
15431 api_one_use_petr (vat_main_t * vam)
15433 unformat_input_t *input = vam->input;
15434 vl_api_one_use_petr_t *mp;
15439 clib_memset (&ip, 0, sizeof (ip));
15441 /* Parse args required to build the message */
15442 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15444 if (unformat (input, "disable"))
15447 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
15450 ip_addr_version (&ip) = AF_IP4;
15453 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
15456 ip_addr_version (&ip) = AF_IP6;
15460 errmsg ("parse error '%U'", format_unformat_error, input);
15465 M (ONE_USE_PETR, mp);
15467 mp->is_add = is_add;
15470 mp->ip_address.af = ip_addr_version (&ip) == AF_IP4 ? 0 : 1;
15471 if (mp->ip_address.af)
15472 clib_memcpy (mp->ip_address.un.ip6, &ip, 16);
15474 clib_memcpy (mp->ip_address.un.ip4, &ip, 4);
15480 /* wait for reply */
15485 #define api_lisp_use_petr api_one_use_petr
15488 api_show_one_nsh_mapping (vat_main_t * vam)
15490 vl_api_show_one_use_petr_t *mp;
15493 if (!vam->json_output)
15495 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
15498 M (SHOW_ONE_NSH_MAPPING, mp);
15502 /* Wait for a reply... */
15508 api_show_one_use_petr (vat_main_t * vam)
15510 vl_api_show_one_use_petr_t *mp;
15513 if (!vam->json_output)
15515 print (vam->ofp, "%=20s", "Proxy-ETR status:");
15518 M (SHOW_ONE_USE_PETR, mp);
15522 /* Wait for a reply... */
15527 #define api_show_lisp_use_petr api_show_one_use_petr
15530 * Add/delete mapping between vni and vrf
15533 api_one_eid_table_add_del_map (vat_main_t * vam)
15535 unformat_input_t *input = vam->input;
15536 vl_api_one_eid_table_add_del_map_t *mp;
15537 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
15538 u32 vni, vrf, bd_index;
15541 /* Parse args required to build the message */
15542 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15544 if (unformat (input, "del"))
15546 else if (unformat (input, "vrf %d", &vrf))
15548 else if (unformat (input, "bd_index %d", &bd_index))
15550 else if (unformat (input, "vni %d", &vni))
15556 if (!vni_set || (!vrf_set && !bd_index_set))
15558 errmsg ("missing arguments!");
15562 if (vrf_set && bd_index_set)
15564 errmsg ("error: both vrf and bd entered!");
15568 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
15570 mp->is_add = is_add;
15571 mp->vni = htonl (vni);
15572 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
15573 mp->is_l2 = bd_index_set;
15578 /* wait for reply */
15583 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
15586 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
15588 u32 *action = va_arg (*args, u32 *);
15591 if (unformat (input, "%s", &s))
15593 if (!strcmp ((char *) s, "no-action"))
15595 else if (!strcmp ((char *) s, "natively-forward"))
15597 else if (!strcmp ((char *) s, "send-map-request"))
15599 else if (!strcmp ((char *) s, "drop"))
15603 clib_warning ("invalid action: '%s'", s);
15615 * Add/del remote mapping to/from ONE control plane
15617 * @param vam vpp API test context
15618 * @return return code
15621 api_one_add_del_remote_mapping (vat_main_t * vam)
15623 unformat_input_t *input = vam->input;
15624 vl_api_one_add_del_remote_mapping_t *mp;
15626 lisp_eid_vat_t _eid, *eid = &_eid;
15627 lisp_eid_vat_t _seid, *seid = &_seid;
15628 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
15629 u32 action = ~0, p, w, data_len;
15630 ip4_address_t rloc4;
15631 ip6_address_t rloc6;
15632 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
15635 clib_memset (&rloc, 0, sizeof (rloc));
15637 /* Parse args required to build the message */
15638 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15640 if (unformat (input, "del-all"))
15644 else if (unformat (input, "del"))
15648 else if (unformat (input, "add"))
15652 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15656 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
15660 else if (unformat (input, "vni %d", &vni))
15664 else if (unformat (input, "p %d w %d", &p, &w))
15668 errmsg ("No RLOC configured for setting priority/weight!");
15671 curr_rloc->priority = p;
15672 curr_rloc->weight = w;
15674 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
15676 rloc.ip_address.af = 0;
15677 clib_memcpy (&rloc.ip_address.un.ip6, &rloc6, sizeof (rloc6));
15678 vec_add1 (rlocs, rloc);
15679 curr_rloc = &rlocs[vec_len (rlocs) - 1];
15681 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
15683 rloc.ip_address.af = 1;
15684 clib_memcpy (&rloc.ip_address.un.ip4, &rloc4, sizeof (rloc4));
15685 vec_add1 (rlocs, rloc);
15686 curr_rloc = &rlocs[vec_len (rlocs) - 1];
15688 else if (unformat (input, "action %U",
15689 unformat_negative_mapping_action, &action))
15695 clib_warning ("parse error '%U'", format_unformat_error, input);
15702 errmsg ("missing params!");
15706 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
15708 errmsg ("no action set for negative map-reply!");
15712 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
15714 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
15715 mp->is_add = is_add;
15716 mp->vni = htonl (vni);
15717 mp->action = (u8) action;
15718 mp->is_src_dst = seid_set;
15719 mp->del_all = del_all;
15720 lisp_eid_put_vat (&mp->deid, eid);
15721 lisp_eid_put_vat (&mp->seid, seid);
15723 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
15724 clib_memcpy (mp->rlocs, rlocs, data_len);
15730 /* Wait for a reply... */
15735 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
15738 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
15739 * forwarding entries in data-plane accordingly.
15741 * @param vam vpp API test context
15742 * @return return code
15745 api_one_add_del_adjacency (vat_main_t * vam)
15747 unformat_input_t *input = vam->input;
15748 vl_api_one_add_del_adjacency_t *mp;
15752 lisp_eid_vat_t leid, reid;
15754 leid.type = reid.type = (u8) ~ 0;
15756 /* Parse args required to build the message */
15757 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15759 if (unformat (input, "del"))
15763 else if (unformat (input, "add"))
15767 else if (unformat (input, "reid %U/%d", unformat_ip46_address,
15768 &reid.addr.ip, &reid.len))
15770 reid.type = 0; /* ipv4 */
15772 else if (unformat (input, "reid %U", unformat_ethernet_address,
15775 reid.type = 1; /* mac */
15777 else if (unformat (input, "leid %U/%d", unformat_ip46_address,
15778 &leid.addr.ip, &leid.len))
15780 leid.type = 0; /* ipv4 */
15782 else if (unformat (input, "leid %U", unformat_ethernet_address,
15785 leid.type = 1; /* mac */
15787 else if (unformat (input, "vni %d", &vni))
15793 errmsg ("parse error '%U'", format_unformat_error, input);
15798 if ((u8) ~ 0 == reid.type)
15800 errmsg ("missing params!");
15804 if (leid.type != reid.type)
15806 errmsg ("remote and local EIDs are of different types!");
15810 M (ONE_ADD_DEL_ADJACENCY, mp);
15811 mp->is_add = is_add;
15812 mp->vni = htonl (vni);
15813 lisp_eid_put_vat (&mp->leid, &leid);
15814 lisp_eid_put_vat (&mp->reid, &reid);
15819 /* Wait for a reply... */
15824 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
15827 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
15829 u32 *mode = va_arg (*args, u32 *);
15831 if (unformat (input, "lisp"))
15833 else if (unformat (input, "vxlan"))
15842 api_gpe_get_encap_mode (vat_main_t * vam)
15844 vl_api_gpe_get_encap_mode_t *mp;
15847 /* Construct the API message */
15848 M (GPE_GET_ENCAP_MODE, mp);
15853 /* Wait for a reply... */
15859 api_gpe_set_encap_mode (vat_main_t * vam)
15861 unformat_input_t *input = vam->input;
15862 vl_api_gpe_set_encap_mode_t *mp;
15866 /* Parse args required to build the message */
15867 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15869 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
15875 /* Construct the API message */
15876 M (GPE_SET_ENCAP_MODE, mp);
15878 mp->is_vxlan = mode;
15883 /* Wait for a reply... */
15889 api_lisp_gpe_add_del_iface (vat_main_t * vam)
15891 unformat_input_t *input = vam->input;
15892 vl_api_gpe_add_del_iface_t *mp;
15893 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
15894 u32 dp_table = 0, vni = 0;
15897 /* Parse args required to build the message */
15898 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15900 if (unformat (input, "up"))
15905 else if (unformat (input, "down"))
15910 else if (unformat (input, "table_id %d", &dp_table))
15914 else if (unformat (input, "bd_id %d", &dp_table))
15919 else if (unformat (input, "vni %d", &vni))
15927 if (action_set == 0)
15929 errmsg ("Action not set");
15932 if (dp_table_set == 0 || vni_set == 0)
15934 errmsg ("vni and dp_table must be set");
15938 /* Construct the API message */
15939 M (GPE_ADD_DEL_IFACE, mp);
15941 mp->is_add = is_add;
15942 mp->dp_table = clib_host_to_net_u32 (dp_table);
15944 mp->vni = clib_host_to_net_u32 (vni);
15949 /* Wait for a reply... */
15955 api_one_map_register_fallback_threshold (vat_main_t * vam)
15957 unformat_input_t *input = vam->input;
15958 vl_api_one_map_register_fallback_threshold_t *mp;
15963 /* Parse args required to build the message */
15964 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15966 if (unformat (input, "%u", &value))
15970 clib_warning ("parse error '%U'", format_unformat_error, input);
15977 errmsg ("fallback threshold value is missing!");
15981 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
15982 mp->value = clib_host_to_net_u32 (value);
15987 /* Wait for a reply... */
15993 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
15995 vl_api_show_one_map_register_fallback_threshold_t *mp;
15998 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
16003 /* Wait for a reply... */
16009 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
16011 u32 *proto = va_arg (*args, u32 *);
16013 if (unformat (input, "udp"))
16015 else if (unformat (input, "api"))
16024 api_one_set_transport_protocol (vat_main_t * vam)
16026 unformat_input_t *input = vam->input;
16027 vl_api_one_set_transport_protocol_t *mp;
16032 /* Parse args required to build the message */
16033 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16035 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
16039 clib_warning ("parse error '%U'", format_unformat_error, input);
16046 errmsg ("Transport protocol missing!");
16050 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
16051 mp->protocol = (u8) protocol;
16056 /* Wait for a reply... */
16062 api_one_get_transport_protocol (vat_main_t * vam)
16064 vl_api_one_get_transport_protocol_t *mp;
16067 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
16072 /* Wait for a reply... */
16078 api_one_map_register_set_ttl (vat_main_t * vam)
16080 unformat_input_t *input = vam->input;
16081 vl_api_one_map_register_set_ttl_t *mp;
16086 /* Parse args required to build the message */
16087 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16089 if (unformat (input, "%u", &ttl))
16093 clib_warning ("parse error '%U'", format_unformat_error, input);
16100 errmsg ("TTL value missing!");
16104 M (ONE_MAP_REGISTER_SET_TTL, mp);
16105 mp->ttl = clib_host_to_net_u32 (ttl);
16110 /* Wait for a reply... */
16116 api_show_one_map_register_ttl (vat_main_t * vam)
16118 vl_api_show_one_map_register_ttl_t *mp;
16121 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
16126 /* Wait for a reply... */
16132 * Add/del map request itr rlocs from ONE control plane and updates
16134 * @param vam vpp API test context
16135 * @return return code
16138 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
16140 unformat_input_t *input = vam->input;
16141 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
16142 u8 *locator_set_name = 0;
16143 u8 locator_set_name_set = 0;
16147 /* Parse args required to build the message */
16148 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16150 if (unformat (input, "del"))
16154 else if (unformat (input, "%_%v%_", &locator_set_name))
16156 locator_set_name_set = 1;
16160 clib_warning ("parse error '%U'", format_unformat_error, input);
16165 if (is_add && !locator_set_name_set)
16167 errmsg ("itr-rloc is not set!");
16171 if (is_add && vec_len (locator_set_name) > 64)
16173 errmsg ("itr-rloc locator-set name too long");
16174 vec_free (locator_set_name);
16178 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
16179 mp->is_add = is_add;
16182 clib_memcpy (mp->locator_set_name, locator_set_name,
16183 vec_len (locator_set_name));
16187 clib_memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
16189 vec_free (locator_set_name);
16194 /* Wait for a reply... */
16199 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
16202 api_one_locator_dump (vat_main_t * vam)
16204 unformat_input_t *input = vam->input;
16205 vl_api_one_locator_dump_t *mp;
16206 vl_api_control_ping_t *mp_ping;
16207 u8 is_index_set = 0, is_name_set = 0;
16212 /* Parse args required to build the message */
16213 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16215 if (unformat (input, "ls_name %_%v%_", &ls_name))
16219 else if (unformat (input, "ls_index %d", &ls_index))
16225 errmsg ("parse error '%U'", format_unformat_error, input);
16230 if (!is_index_set && !is_name_set)
16232 errmsg ("error: expected one of index or name!");
16236 if (is_index_set && is_name_set)
16238 errmsg ("error: only one param expected!");
16242 if (vec_len (ls_name) > 62)
16244 errmsg ("error: locator set name too long!");
16248 if (!vam->json_output)
16250 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
16253 M (ONE_LOCATOR_DUMP, mp);
16254 mp->is_index_set = is_index_set;
16257 mp->ls_index = clib_host_to_net_u32 (ls_index);
16260 vec_add1 (ls_name, 0);
16261 strncpy ((char *) mp->ls_name, (char *) ls_name,
16262 sizeof (mp->ls_name) - 1);
16268 /* Use a control ping for synchronization */
16269 MPING (CONTROL_PING, mp_ping);
16272 /* Wait for a reply... */
16277 #define api_lisp_locator_dump api_one_locator_dump
16280 api_one_locator_set_dump (vat_main_t * vam)
16282 vl_api_one_locator_set_dump_t *mp;
16283 vl_api_control_ping_t *mp_ping;
16284 unformat_input_t *input = vam->input;
16288 /* Parse args required to build the message */
16289 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16291 if (unformat (input, "local"))
16295 else if (unformat (input, "remote"))
16301 errmsg ("parse error '%U'", format_unformat_error, input);
16306 if (!vam->json_output)
16308 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
16311 M (ONE_LOCATOR_SET_DUMP, mp);
16313 mp->filter = filter;
16318 /* Use a control ping for synchronization */
16319 MPING (CONTROL_PING, mp_ping);
16322 /* Wait for a reply... */
16327 #define api_lisp_locator_set_dump api_one_locator_set_dump
16330 api_one_eid_table_map_dump (vat_main_t * vam)
16334 unformat_input_t *input = vam->input;
16335 vl_api_one_eid_table_map_dump_t *mp;
16336 vl_api_control_ping_t *mp_ping;
16339 /* Parse args required to build the message */
16340 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16342 if (unformat (input, "l2"))
16347 else if (unformat (input, "l3"))
16354 errmsg ("parse error '%U'", format_unformat_error, input);
16361 errmsg ("expected one of 'l2' or 'l3' parameter!");
16365 if (!vam->json_output)
16367 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
16370 M (ONE_EID_TABLE_MAP_DUMP, mp);
16376 /* Use a control ping for synchronization */
16377 MPING (CONTROL_PING, mp_ping);
16380 /* Wait for a reply... */
16385 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
16388 api_one_eid_table_vni_dump (vat_main_t * vam)
16390 vl_api_one_eid_table_vni_dump_t *mp;
16391 vl_api_control_ping_t *mp_ping;
16394 if (!vam->json_output)
16396 print (vam->ofp, "VNI");
16399 M (ONE_EID_TABLE_VNI_DUMP, mp);
16404 /* Use a control ping for synchronization */
16405 MPING (CONTROL_PING, mp_ping);
16408 /* Wait for a reply... */
16413 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
16416 api_one_eid_table_dump (vat_main_t * vam)
16418 unformat_input_t *i = vam->input;
16419 vl_api_one_eid_table_dump_t *mp;
16420 vl_api_control_ping_t *mp_ping;
16424 lisp_eid_vat_t eid;
16427 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16430 (i, "eid %U/%d", unformat_ip46_address, &eid.addr.ip, &eid.len))
16436 if (unformat (i, "eid %U", unformat_ethernet_address, &eid.addr.mac))
16441 else if (unformat (i, "eid %U", unformat_nsh_address, &eid.addr.nsh))
16446 else if (unformat (i, "vni %d", &t))
16450 else if (unformat (i, "local"))
16454 else if (unformat (i, "remote"))
16460 errmsg ("parse error '%U'", format_unformat_error, i);
16465 if (!vam->json_output)
16467 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
16468 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
16471 M (ONE_EID_TABLE_DUMP, mp);
16473 mp->filter = filter;
16477 mp->vni = htonl (vni);
16478 lisp_eid_put_vat (&mp->eid, &eid);
16484 /* Use a control ping for synchronization */
16485 MPING (CONTROL_PING, mp_ping);
16488 /* Wait for a reply... */
16493 #define api_lisp_eid_table_dump api_one_eid_table_dump
16496 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
16498 unformat_input_t *i = vam->input;
16499 vl_api_gpe_fwd_entries_get_t *mp;
16504 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16506 if (unformat (i, "vni %d", &vni))
16512 errmsg ("parse error '%U'", format_unformat_error, i);
16519 errmsg ("vni not set!");
16523 if (!vam->json_output)
16525 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
16529 M (GPE_FWD_ENTRIES_GET, mp);
16530 mp->vni = clib_host_to_net_u32 (vni);
16535 /* Wait for a reply... */
16540 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
16541 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
16542 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
16543 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
16544 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
16545 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
16546 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
16547 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
16550 api_one_adjacencies_get (vat_main_t * vam)
16552 unformat_input_t *i = vam->input;
16553 vl_api_one_adjacencies_get_t *mp;
16558 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16560 if (unformat (i, "vni %d", &vni))
16566 errmsg ("parse error '%U'", format_unformat_error, i);
16573 errmsg ("vni not set!");
16577 if (!vam->json_output)
16579 print (vam->ofp, "%s %40s", "leid", "reid");
16582 M (ONE_ADJACENCIES_GET, mp);
16583 mp->vni = clib_host_to_net_u32 (vni);
16588 /* Wait for a reply... */
16593 #define api_lisp_adjacencies_get api_one_adjacencies_get
16596 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
16598 unformat_input_t *i = vam->input;
16599 vl_api_gpe_native_fwd_rpaths_get_t *mp;
16601 u8 ip_family_set = 0, is_ip4 = 1;
16603 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16605 if (unformat (i, "ip4"))
16610 else if (unformat (i, "ip6"))
16617 errmsg ("parse error '%U'", format_unformat_error, i);
16622 if (!ip_family_set)
16624 errmsg ("ip family not set!");
16628 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
16629 mp->is_ip4 = is_ip4;
16634 /* Wait for a reply... */
16640 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
16642 vl_api_gpe_fwd_entry_vnis_get_t *mp;
16645 if (!vam->json_output)
16647 print (vam->ofp, "VNIs");
16650 M (GPE_FWD_ENTRY_VNIS_GET, mp);
16655 /* Wait for a reply... */
16661 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
16663 unformat_input_t *i = vam->input;
16664 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
16666 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
16667 struct in_addr ip4;
16668 struct in6_addr ip6;
16669 u32 table_id = 0, nh_sw_if_index = ~0;
16671 clib_memset (&ip4, 0, sizeof (ip4));
16672 clib_memset (&ip6, 0, sizeof (ip6));
16674 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16676 if (unformat (i, "del"))
16678 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
16679 api_unformat_sw_if_index, vam, &nh_sw_if_index))
16684 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
16685 api_unformat_sw_if_index, vam, &nh_sw_if_index))
16690 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
16694 nh_sw_if_index = ~0;
16696 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
16700 nh_sw_if_index = ~0;
16702 else if (unformat (i, "table %d", &table_id))
16706 errmsg ("parse error '%U'", format_unformat_error, i);
16713 errmsg ("nh addr not set!");
16717 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
16718 mp->is_add = is_add;
16719 mp->table_id = clib_host_to_net_u32 (table_id);
16720 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
16721 mp->nh_addr.af = is_ip4 ? 0 : 1;
16723 clib_memcpy (mp->nh_addr.un.ip4, &ip4, sizeof (ip4));
16725 clib_memcpy (mp->nh_addr.un.ip6, &ip6, sizeof (ip6));
16730 /* Wait for a reply... */
16736 api_one_map_server_dump (vat_main_t * vam)
16738 vl_api_one_map_server_dump_t *mp;
16739 vl_api_control_ping_t *mp_ping;
16742 if (!vam->json_output)
16744 print (vam->ofp, "%=20s", "Map server");
16747 M (ONE_MAP_SERVER_DUMP, mp);
16751 /* Use a control ping for synchronization */
16752 MPING (CONTROL_PING, mp_ping);
16755 /* Wait for a reply... */
16760 #define api_lisp_map_server_dump api_one_map_server_dump
16763 api_one_map_resolver_dump (vat_main_t * vam)
16765 vl_api_one_map_resolver_dump_t *mp;
16766 vl_api_control_ping_t *mp_ping;
16769 if (!vam->json_output)
16771 print (vam->ofp, "%=20s", "Map resolver");
16774 M (ONE_MAP_RESOLVER_DUMP, mp);
16778 /* Use a control ping for synchronization */
16779 MPING (CONTROL_PING, mp_ping);
16782 /* Wait for a reply... */
16787 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
16790 api_one_stats_flush (vat_main_t * vam)
16792 vl_api_one_stats_flush_t *mp;
16795 M (ONE_STATS_FLUSH, mp);
16802 api_one_stats_dump (vat_main_t * vam)
16804 vl_api_one_stats_dump_t *mp;
16805 vl_api_control_ping_t *mp_ping;
16808 M (ONE_STATS_DUMP, mp);
16812 /* Use a control ping for synchronization */
16813 MPING (CONTROL_PING, mp_ping);
16816 /* Wait for a reply... */
16822 api_show_one_status (vat_main_t * vam)
16824 vl_api_show_one_status_t *mp;
16827 if (!vam->json_output)
16829 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
16832 M (SHOW_ONE_STATUS, mp);
16835 /* Wait for a reply... */
16840 #define api_show_lisp_status api_show_one_status
16843 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
16845 vl_api_gpe_fwd_entry_path_dump_t *mp;
16846 vl_api_control_ping_t *mp_ping;
16847 unformat_input_t *i = vam->input;
16848 u32 fwd_entry_index = ~0;
16851 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16853 if (unformat (i, "index %d", &fwd_entry_index))
16859 if (~0 == fwd_entry_index)
16861 errmsg ("no index specified!");
16865 if (!vam->json_output)
16867 print (vam->ofp, "first line");
16870 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
16874 /* Use a control ping for synchronization */
16875 MPING (CONTROL_PING, mp_ping);
16878 /* Wait for a reply... */
16884 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
16886 vl_api_one_get_map_request_itr_rlocs_t *mp;
16889 if (!vam->json_output)
16891 print (vam->ofp, "%=20s", "itr-rlocs:");
16894 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
16897 /* Wait for a reply... */
16902 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
16905 api_af_packet_create (vat_main_t * vam)
16907 unformat_input_t *i = vam->input;
16908 vl_api_af_packet_create_t *mp;
16909 u8 *host_if_name = 0;
16911 u8 random_hw_addr = 1;
16914 clib_memset (hw_addr, 0, sizeof (hw_addr));
16916 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16918 if (unformat (i, "name %s", &host_if_name))
16919 vec_add1 (host_if_name, 0);
16920 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
16921 random_hw_addr = 0;
16926 if (!vec_len (host_if_name))
16928 errmsg ("host-interface name must be specified");
16932 if (vec_len (host_if_name) > 64)
16934 errmsg ("host-interface name too long");
16938 M (AF_PACKET_CREATE, mp);
16940 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
16941 clib_memcpy (mp->hw_addr, hw_addr, 6);
16942 mp->use_random_hw_addr = random_hw_addr;
16943 vec_free (host_if_name);
16951 fprintf (vam->ofp ? vam->ofp : stderr,
16952 " new sw_if_index = %d\n", vam->sw_if_index);
16959 api_af_packet_delete (vat_main_t * vam)
16961 unformat_input_t *i = vam->input;
16962 vl_api_af_packet_delete_t *mp;
16963 u8 *host_if_name = 0;
16966 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16968 if (unformat (i, "name %s", &host_if_name))
16969 vec_add1 (host_if_name, 0);
16974 if (!vec_len (host_if_name))
16976 errmsg ("host-interface name must be specified");
16980 if (vec_len (host_if_name) > 64)
16982 errmsg ("host-interface name too long");
16986 M (AF_PACKET_DELETE, mp);
16988 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
16989 vec_free (host_if_name);
16996 static void vl_api_af_packet_details_t_handler
16997 (vl_api_af_packet_details_t * mp)
16999 vat_main_t *vam = &vat_main;
17001 print (vam->ofp, "%-16s %d",
17002 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
17005 static void vl_api_af_packet_details_t_handler_json
17006 (vl_api_af_packet_details_t * mp)
17008 vat_main_t *vam = &vat_main;
17009 vat_json_node_t *node = NULL;
17011 if (VAT_JSON_ARRAY != vam->json_tree.type)
17013 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17014 vat_json_init_array (&vam->json_tree);
17016 node = vat_json_array_add (&vam->json_tree);
17018 vat_json_init_object (node);
17019 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
17020 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
17024 api_af_packet_dump (vat_main_t * vam)
17026 vl_api_af_packet_dump_t *mp;
17027 vl_api_control_ping_t *mp_ping;
17030 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
17031 /* Get list of tap interfaces */
17032 M (AF_PACKET_DUMP, mp);
17035 /* Use a control ping for synchronization */
17036 MPING (CONTROL_PING, mp_ping);
17044 api_policer_add_del (vat_main_t * vam)
17046 unformat_input_t *i = vam->input;
17047 vl_api_policer_add_del_t *mp;
17057 u8 color_aware = 0;
17058 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
17061 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
17062 conform_action.dscp = 0;
17063 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
17064 exceed_action.dscp = 0;
17065 violate_action.action_type = SSE2_QOS_ACTION_DROP;
17066 violate_action.dscp = 0;
17068 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17070 if (unformat (i, "del"))
17072 else if (unformat (i, "name %s", &name))
17073 vec_add1 (name, 0);
17074 else if (unformat (i, "cir %u", &cir))
17076 else if (unformat (i, "eir %u", &eir))
17078 else if (unformat (i, "cb %u", &cb))
17080 else if (unformat (i, "eb %u", &eb))
17082 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
17085 else if (unformat (i, "round_type %U", unformat_policer_round_type,
17088 else if (unformat (i, "type %U", unformat_policer_type, &type))
17090 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
17093 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
17096 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
17099 else if (unformat (i, "color-aware"))
17105 if (!vec_len (name))
17107 errmsg ("policer name must be specified");
17111 if (vec_len (name) > 64)
17113 errmsg ("policer name too long");
17117 M (POLICER_ADD_DEL, mp);
17119 clib_memcpy (mp->name, name, vec_len (name));
17121 mp->is_add = is_add;
17122 mp->cir = ntohl (cir);
17123 mp->eir = ntohl (eir);
17124 mp->cb = clib_net_to_host_u64 (cb);
17125 mp->eb = clib_net_to_host_u64 (eb);
17126 mp->rate_type = rate_type;
17127 mp->round_type = round_type;
17129 mp->conform_action.type = conform_action.action_type;
17130 mp->conform_action.dscp = conform_action.dscp;
17131 mp->exceed_action.type = exceed_action.action_type;
17132 mp->exceed_action.dscp = exceed_action.dscp;
17133 mp->violate_action.type = violate_action.action_type;
17134 mp->violate_action.dscp = violate_action.dscp;
17135 mp->color_aware = color_aware;
17143 api_policer_dump (vat_main_t * vam)
17145 unformat_input_t *i = vam->input;
17146 vl_api_policer_dump_t *mp;
17147 vl_api_control_ping_t *mp_ping;
17148 u8 *match_name = 0;
17149 u8 match_name_valid = 0;
17152 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17154 if (unformat (i, "name %s", &match_name))
17156 vec_add1 (match_name, 0);
17157 match_name_valid = 1;
17163 M (POLICER_DUMP, mp);
17164 mp->match_name_valid = match_name_valid;
17165 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
17166 vec_free (match_name);
17170 /* Use a control ping for synchronization */
17171 MPING (CONTROL_PING, mp_ping);
17174 /* Wait for a reply... */
17180 api_policer_classify_set_interface (vat_main_t * vam)
17182 unformat_input_t *i = vam->input;
17183 vl_api_policer_classify_set_interface_t *mp;
17185 int sw_if_index_set;
17186 u32 ip4_table_index = ~0;
17187 u32 ip6_table_index = ~0;
17188 u32 l2_table_index = ~0;
17192 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17194 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17195 sw_if_index_set = 1;
17196 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17197 sw_if_index_set = 1;
17198 else if (unformat (i, "del"))
17200 else if (unformat (i, "ip4-table %d", &ip4_table_index))
17202 else if (unformat (i, "ip6-table %d", &ip6_table_index))
17204 else if (unformat (i, "l2-table %d", &l2_table_index))
17208 clib_warning ("parse error '%U'", format_unformat_error, i);
17213 if (sw_if_index_set == 0)
17215 errmsg ("missing interface name or sw_if_index");
17219 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
17221 mp->sw_if_index = ntohl (sw_if_index);
17222 mp->ip4_table_index = ntohl (ip4_table_index);
17223 mp->ip6_table_index = ntohl (ip6_table_index);
17224 mp->l2_table_index = ntohl (l2_table_index);
17225 mp->is_add = is_add;
17233 api_policer_classify_dump (vat_main_t * vam)
17235 unformat_input_t *i = vam->input;
17236 vl_api_policer_classify_dump_t *mp;
17237 vl_api_control_ping_t *mp_ping;
17238 u8 type = POLICER_CLASSIFY_N_TABLES;
17241 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
17245 errmsg ("classify table type must be specified");
17249 if (!vam->json_output)
17251 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
17254 M (POLICER_CLASSIFY_DUMP, mp);
17259 /* Use a control ping for synchronization */
17260 MPING (CONTROL_PING, mp_ping);
17263 /* Wait for a reply... */
17269 format_fib_api_path_nh_proto (u8 * s, va_list * args)
17271 vl_api_fib_path_nh_proto_t proto =
17272 va_arg (*args, vl_api_fib_path_nh_proto_t);
17276 case FIB_API_PATH_NH_PROTO_IP4:
17277 s = format (s, "ip4");
17279 case FIB_API_PATH_NH_PROTO_IP6:
17280 s = format (s, "ip6");
17282 case FIB_API_PATH_NH_PROTO_MPLS:
17283 s = format (s, "mpls");
17285 case FIB_API_PATH_NH_PROTO_BIER:
17286 s = format (s, "bier");
17288 case FIB_API_PATH_NH_PROTO_ETHERNET:
17289 s = format (s, "ethernet");
17297 format_vl_api_ip_address_union (u8 * s, va_list * args)
17299 vl_api_address_family_t af = va_arg (*args, int);
17300 const vl_api_address_union_t *u = va_arg (*args, vl_api_address_union_t *);
17305 s = format (s, "%U", format_ip4_address, u->ip4);
17308 s = format (s, "%U", format_ip6_address, u->ip6);
17315 format_vl_api_fib_path_type (u8 * s, va_list * args)
17317 vl_api_fib_path_type_t t = va_arg (*args, vl_api_fib_path_type_t);
17321 case FIB_API_PATH_TYPE_NORMAL:
17322 s = format (s, "normal");
17324 case FIB_API_PATH_TYPE_LOCAL:
17325 s = format (s, "local");
17327 case FIB_API_PATH_TYPE_DROP:
17328 s = format (s, "drop");
17330 case FIB_API_PATH_TYPE_UDP_ENCAP:
17331 s = format (s, "udp-encap");
17333 case FIB_API_PATH_TYPE_BIER_IMP:
17334 s = format (s, "bier-imp");
17336 case FIB_API_PATH_TYPE_ICMP_UNREACH:
17337 s = format (s, "unreach");
17339 case FIB_API_PATH_TYPE_ICMP_PROHIBIT:
17340 s = format (s, "prohibit");
17342 case FIB_API_PATH_TYPE_SOURCE_LOOKUP:
17343 s = format (s, "src-lookup");
17345 case FIB_API_PATH_TYPE_DVR:
17346 s = format (s, "dvr");
17348 case FIB_API_PATH_TYPE_INTERFACE_RX:
17349 s = format (s, "interface-rx");
17351 case FIB_API_PATH_TYPE_CLASSIFY:
17352 s = format (s, "classify");
17360 vl_api_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
17363 " weight %d, sw_if_index %d, type %U, afi %U, next_hop %U",
17364 ntohl (fp->weight), ntohl (fp->sw_if_index),
17365 format_vl_api_fib_path_type, fp->type,
17366 format_fib_api_path_nh_proto, fp->proto,
17367 format_vl_api_ip_address_union, &fp->nh.address);
17371 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
17372 vl_api_fib_path_t * fp)
17374 struct in_addr ip4;
17375 struct in6_addr ip6;
17377 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
17378 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
17379 vat_json_object_add_uint (node, "type", fp->type);
17380 vat_json_object_add_uint (node, "next_hop_proto", fp->proto);
17381 if (fp->proto == FIB_API_PATH_NH_PROTO_IP4)
17383 clib_memcpy (&ip4, &fp->nh.address.ip4, sizeof (ip4));
17384 vat_json_object_add_ip4 (node, "next_hop", ip4);
17386 else if (fp->proto == FIB_API_PATH_NH_PROTO_IP6)
17388 clib_memcpy (&ip6, &fp->nh.address.ip6, sizeof (ip6));
17389 vat_json_object_add_ip6 (node, "next_hop", ip6);
17394 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
17396 vat_main_t *vam = &vat_main;
17397 int count = ntohl (mp->mt_tunnel.mt_n_paths);
17398 vl_api_fib_path_t *fp;
17401 print (vam->ofp, "sw_if_index %d via:",
17402 ntohl (mp->mt_tunnel.mt_sw_if_index));
17403 fp = mp->mt_tunnel.mt_paths;
17404 for (i = 0; i < count; i++)
17406 vl_api_fib_path_print (vam, fp);
17410 print (vam->ofp, "");
17413 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
17414 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
17417 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
17419 vat_main_t *vam = &vat_main;
17420 vat_json_node_t *node = NULL;
17421 int count = ntohl (mp->mt_tunnel.mt_n_paths);
17422 vl_api_fib_path_t *fp;
17425 if (VAT_JSON_ARRAY != vam->json_tree.type)
17427 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17428 vat_json_init_array (&vam->json_tree);
17430 node = vat_json_array_add (&vam->json_tree);
17432 vat_json_init_object (node);
17433 vat_json_object_add_uint (node, "sw_if_index",
17434 ntohl (mp->mt_tunnel.mt_sw_if_index));
17436 vat_json_object_add_uint (node, "l2_only", mp->mt_tunnel.mt_l2_only);
17438 fp = mp->mt_tunnel.mt_paths;
17439 for (i = 0; i < count; i++)
17441 vl_api_mpls_fib_path_json_print (node, fp);
17447 api_mpls_tunnel_dump (vat_main_t * vam)
17449 vl_api_mpls_tunnel_dump_t *mp;
17450 vl_api_control_ping_t *mp_ping;
17453 M (MPLS_TUNNEL_DUMP, mp);
17457 /* Use a control ping for synchronization */
17458 MPING (CONTROL_PING, mp_ping);
17465 #define vl_api_mpls_table_details_t_endian vl_noop_handler
17466 #define vl_api_mpls_table_details_t_print vl_noop_handler
17470 vl_api_mpls_table_details_t_handler (vl_api_mpls_table_details_t * mp)
17472 vat_main_t *vam = &vat_main;
17474 print (vam->ofp, "table-id %d,", ntohl (mp->mt_table.mt_table_id));
17477 static void vl_api_mpls_table_details_t_handler_json
17478 (vl_api_mpls_table_details_t * mp)
17480 vat_main_t *vam = &vat_main;
17481 vat_json_node_t *node = NULL;
17483 if (VAT_JSON_ARRAY != vam->json_tree.type)
17485 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17486 vat_json_init_array (&vam->json_tree);
17488 node = vat_json_array_add (&vam->json_tree);
17490 vat_json_init_object (node);
17491 vat_json_object_add_uint (node, "table", ntohl (mp->mt_table.mt_table_id));
17495 api_mpls_table_dump (vat_main_t * vam)
17497 vl_api_mpls_table_dump_t *mp;
17498 vl_api_control_ping_t *mp_ping;
17501 M (MPLS_TABLE_DUMP, mp);
17504 /* Use a control ping for synchronization */
17505 MPING (CONTROL_PING, mp_ping);
17512 #define vl_api_mpls_route_details_t_endian vl_noop_handler
17513 #define vl_api_mpls_route_details_t_print vl_noop_handler
17516 vl_api_mpls_route_details_t_handler (vl_api_mpls_route_details_t * mp)
17518 vat_main_t *vam = &vat_main;
17519 int count = (int) clib_net_to_host_u32 (mp->mr_route.mr_n_paths);
17520 vl_api_fib_path_t *fp;
17524 "table-id %d, label %u, ess_bit %u",
17525 ntohl (mp->mr_route.mr_table_id),
17526 ntohl (mp->mr_route.mr_label), mp->mr_route.mr_eos);
17527 fp = mp->mr_route.mr_paths;
17528 for (i = 0; i < count; i++)
17530 vl_api_fib_path_print (vam, fp);
17535 static void vl_api_mpls_route_details_t_handler_json
17536 (vl_api_mpls_route_details_t * mp)
17538 vat_main_t *vam = &vat_main;
17539 int count = (int) clib_host_to_net_u32 (mp->mr_route.mr_n_paths);
17540 vat_json_node_t *node = NULL;
17541 vl_api_fib_path_t *fp;
17544 if (VAT_JSON_ARRAY != vam->json_tree.type)
17546 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17547 vat_json_init_array (&vam->json_tree);
17549 node = vat_json_array_add (&vam->json_tree);
17551 vat_json_init_object (node);
17552 vat_json_object_add_uint (node, "table", ntohl (mp->mr_route.mr_table_id));
17553 vat_json_object_add_uint (node, "s_bit", mp->mr_route.mr_eos);
17554 vat_json_object_add_uint (node, "label", ntohl (mp->mr_route.mr_label));
17555 vat_json_object_add_uint (node, "path_count", count);
17556 fp = mp->mr_route.mr_paths;
17557 for (i = 0; i < count; i++)
17559 vl_api_mpls_fib_path_json_print (node, fp);
17565 api_mpls_route_dump (vat_main_t * vam)
17567 unformat_input_t *input = vam->input;
17568 vl_api_mpls_route_dump_t *mp;
17569 vl_api_control_ping_t *mp_ping;
17573 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17575 if (unformat (input, "table_id %d", &table_id))
17580 if (table_id == ~0)
17582 errmsg ("missing table id");
17586 M (MPLS_ROUTE_DUMP, mp);
17588 mp->table.mt_table_id = ntohl (table_id);
17591 /* Use a control ping for synchronization */
17592 MPING (CONTROL_PING, mp_ping);
17599 #define vl_api_ip_table_details_t_endian vl_noop_handler
17600 #define vl_api_ip_table_details_t_print vl_noop_handler
17603 vl_api_ip_table_details_t_handler (vl_api_ip_table_details_t * mp)
17605 vat_main_t *vam = &vat_main;
17608 "%s; table-id %d, prefix %U/%d",
17609 mp->table.name, ntohl (mp->table.table_id));
17613 static void vl_api_ip_table_details_t_handler_json
17614 (vl_api_ip_table_details_t * mp)
17616 vat_main_t *vam = &vat_main;
17617 vat_json_node_t *node = NULL;
17619 if (VAT_JSON_ARRAY != vam->json_tree.type)
17621 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17622 vat_json_init_array (&vam->json_tree);
17624 node = vat_json_array_add (&vam->json_tree);
17626 vat_json_init_object (node);
17627 vat_json_object_add_uint (node, "table", ntohl (mp->table.table_id));
17631 api_ip_table_dump (vat_main_t * vam)
17633 vl_api_ip_table_dump_t *mp;
17634 vl_api_control_ping_t *mp_ping;
17637 M (IP_TABLE_DUMP, mp);
17640 /* Use a control ping for synchronization */
17641 MPING (CONTROL_PING, mp_ping);
17649 api_ip_mtable_dump (vat_main_t * vam)
17651 vl_api_ip_mtable_dump_t *mp;
17652 vl_api_control_ping_t *mp_ping;
17655 M (IP_MTABLE_DUMP, mp);
17658 /* Use a control ping for synchronization */
17659 MPING (CONTROL_PING, mp_ping);
17667 api_ip_mroute_dump (vat_main_t * vam)
17669 unformat_input_t *input = vam->input;
17670 vl_api_control_ping_t *mp_ping;
17671 vl_api_ip_mroute_dump_t *mp;
17676 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17678 if (unformat (input, "table_id %d", &table_id))
17680 else if (unformat (input, "ip6"))
17682 else if (unformat (input, "ip4"))
17687 if (table_id == ~0)
17689 errmsg ("missing table id");
17693 M (IP_MROUTE_DUMP, mp);
17694 mp->table.table_id = table_id;
17695 mp->table.is_ip6 = is_ip6;
17698 /* Use a control ping for synchronization */
17699 MPING (CONTROL_PING, mp_ping);
17706 #define vl_api_ip_route_details_t_endian vl_noop_handler
17707 #define vl_api_ip_route_details_t_print vl_noop_handler
17710 vl_api_ip_route_details_t_handler (vl_api_ip_route_details_t * mp)
17712 vat_main_t *vam = &vat_main;
17713 u8 count = mp->route.n_paths;
17714 vl_api_fib_path_t *fp;
17718 "table-id %d, prefix %U/%d",
17719 ntohl (mp->route.table_id),
17720 format_ip46_address, mp->route.prefix.address, mp->route.prefix.len);
17721 for (i = 0; i < count; i++)
17723 fp = &mp->route.paths[i];
17725 vl_api_fib_path_print (vam, fp);
17730 static void vl_api_ip_route_details_t_handler_json
17731 (vl_api_ip_route_details_t * mp)
17733 vat_main_t *vam = &vat_main;
17734 u8 count = mp->route.n_paths;
17735 vat_json_node_t *node = NULL;
17736 struct in_addr ip4;
17737 struct in6_addr ip6;
17738 vl_api_fib_path_t *fp;
17741 if (VAT_JSON_ARRAY != vam->json_tree.type)
17743 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17744 vat_json_init_array (&vam->json_tree);
17746 node = vat_json_array_add (&vam->json_tree);
17748 vat_json_init_object (node);
17749 vat_json_object_add_uint (node, "table", ntohl (mp->route.table_id));
17750 if (ADDRESS_IP6 == mp->route.prefix.address.af)
17752 clib_memcpy (&ip6, &mp->route.prefix.address.un.ip6, sizeof (ip6));
17753 vat_json_object_add_ip6 (node, "prefix", ip6);
17757 clib_memcpy (&ip4, &mp->route.prefix.address.un.ip4, sizeof (ip4));
17758 vat_json_object_add_ip4 (node, "prefix", ip4);
17760 vat_json_object_add_uint (node, "mask_length", mp->route.prefix.len);
17761 vat_json_object_add_uint (node, "path_count", count);
17762 for (i = 0; i < count; i++)
17764 fp = &mp->route.paths[i];
17765 vl_api_mpls_fib_path_json_print (node, fp);
17770 api_ip_route_dump (vat_main_t * vam)
17772 unformat_input_t *input = vam->input;
17773 vl_api_ip_route_dump_t *mp;
17774 vl_api_control_ping_t *mp_ping;
17780 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17782 if (unformat (input, "table_id %d", &table_id))
17784 else if (unformat (input, "ip6"))
17786 else if (unformat (input, "ip4"))
17791 if (table_id == ~0)
17793 errmsg ("missing table id");
17797 M (IP_ROUTE_DUMP, mp);
17799 mp->table.table_id = table_id;
17800 mp->table.is_ip6 = is_ip6;
17804 /* Use a control ping for synchronization */
17805 MPING (CONTROL_PING, mp_ping);
17813 api_classify_table_ids (vat_main_t * vam)
17815 vl_api_classify_table_ids_t *mp;
17818 /* Construct the API message */
17819 M (CLASSIFY_TABLE_IDS, mp);
17828 api_classify_table_by_interface (vat_main_t * vam)
17830 unformat_input_t *input = vam->input;
17831 vl_api_classify_table_by_interface_t *mp;
17833 u32 sw_if_index = ~0;
17835 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17837 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17839 else if (unformat (input, "sw_if_index %d", &sw_if_index))
17844 if (sw_if_index == ~0)
17846 errmsg ("missing interface name or sw_if_index");
17850 /* Construct the API message */
17851 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
17853 mp->sw_if_index = ntohl (sw_if_index);
17861 api_classify_table_info (vat_main_t * vam)
17863 unformat_input_t *input = vam->input;
17864 vl_api_classify_table_info_t *mp;
17868 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17870 if (unformat (input, "table_id %d", &table_id))
17875 if (table_id == ~0)
17877 errmsg ("missing table id");
17881 /* Construct the API message */
17882 M (CLASSIFY_TABLE_INFO, mp);
17884 mp->table_id = ntohl (table_id);
17892 api_classify_session_dump (vat_main_t * vam)
17894 unformat_input_t *input = vam->input;
17895 vl_api_classify_session_dump_t *mp;
17896 vl_api_control_ping_t *mp_ping;
17900 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17902 if (unformat (input, "table_id %d", &table_id))
17907 if (table_id == ~0)
17909 errmsg ("missing table id");
17913 /* Construct the API message */
17914 M (CLASSIFY_SESSION_DUMP, mp);
17916 mp->table_id = ntohl (table_id);
17919 /* Use a control ping for synchronization */
17920 MPING (CONTROL_PING, mp_ping);
17928 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
17930 vat_main_t *vam = &vat_main;
17932 print (vam->ofp, "collector_address %U, collector_port %d, "
17933 "src_address %U, vrf_id %d, path_mtu %u, "
17934 "template_interval %u, udp_checksum %d",
17935 format_ip4_address, mp->collector_address,
17936 ntohs (mp->collector_port),
17937 format_ip4_address, mp->src_address,
17938 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
17939 ntohl (mp->template_interval), mp->udp_checksum);
17942 vam->result_ready = 1;
17946 vl_api_ipfix_exporter_details_t_handler_json
17947 (vl_api_ipfix_exporter_details_t * mp)
17949 vat_main_t *vam = &vat_main;
17950 vat_json_node_t node;
17951 struct in_addr collector_address;
17952 struct in_addr src_address;
17954 vat_json_init_object (&node);
17955 clib_memcpy (&collector_address, &mp->collector_address,
17956 sizeof (collector_address));
17957 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
17958 vat_json_object_add_uint (&node, "collector_port",
17959 ntohs (mp->collector_port));
17960 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
17961 vat_json_object_add_ip4 (&node, "src_address", src_address);
17962 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
17963 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
17964 vat_json_object_add_uint (&node, "template_interval",
17965 ntohl (mp->template_interval));
17966 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
17968 vat_json_print (vam->ofp, &node);
17969 vat_json_free (&node);
17971 vam->result_ready = 1;
17975 api_ipfix_exporter_dump (vat_main_t * vam)
17977 vl_api_ipfix_exporter_dump_t *mp;
17980 /* Construct the API message */
17981 M (IPFIX_EXPORTER_DUMP, mp);
17990 api_ipfix_classify_stream_dump (vat_main_t * vam)
17992 vl_api_ipfix_classify_stream_dump_t *mp;
17995 /* Construct the API message */
17996 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
18007 vl_api_ipfix_classify_stream_details_t_handler
18008 (vl_api_ipfix_classify_stream_details_t * mp)
18010 vat_main_t *vam = &vat_main;
18011 print (vam->ofp, "domain_id %d, src_port %d",
18012 ntohl (mp->domain_id), ntohs (mp->src_port));
18014 vam->result_ready = 1;
18018 vl_api_ipfix_classify_stream_details_t_handler_json
18019 (vl_api_ipfix_classify_stream_details_t * mp)
18021 vat_main_t *vam = &vat_main;
18022 vat_json_node_t node;
18024 vat_json_init_object (&node);
18025 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
18026 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
18028 vat_json_print (vam->ofp, &node);
18029 vat_json_free (&node);
18031 vam->result_ready = 1;
18035 api_ipfix_classify_table_dump (vat_main_t * vam)
18037 vl_api_ipfix_classify_table_dump_t *mp;
18038 vl_api_control_ping_t *mp_ping;
18041 if (!vam->json_output)
18043 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
18044 "transport_protocol");
18047 /* Construct the API message */
18048 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
18053 /* Use a control ping for synchronization */
18054 MPING (CONTROL_PING, mp_ping);
18062 vl_api_ipfix_classify_table_details_t_handler
18063 (vl_api_ipfix_classify_table_details_t * mp)
18065 vat_main_t *vam = &vat_main;
18066 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
18067 mp->transport_protocol);
18071 vl_api_ipfix_classify_table_details_t_handler_json
18072 (vl_api_ipfix_classify_table_details_t * mp)
18074 vat_json_node_t *node = NULL;
18075 vat_main_t *vam = &vat_main;
18077 if (VAT_JSON_ARRAY != vam->json_tree.type)
18079 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18080 vat_json_init_array (&vam->json_tree);
18083 node = vat_json_array_add (&vam->json_tree);
18084 vat_json_init_object (node);
18086 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
18087 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
18088 vat_json_object_add_uint (node, "transport_protocol",
18089 mp->transport_protocol);
18093 api_sw_interface_span_enable_disable (vat_main_t * vam)
18095 unformat_input_t *i = vam->input;
18096 vl_api_sw_interface_span_enable_disable_t *mp;
18097 u32 src_sw_if_index = ~0;
18098 u32 dst_sw_if_index = ~0;
18103 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18106 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
18108 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
18112 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
18114 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
18116 else if (unformat (i, "disable"))
18118 else if (unformat (i, "rx"))
18120 else if (unformat (i, "tx"))
18122 else if (unformat (i, "both"))
18124 else if (unformat (i, "l2"))
18130 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
18132 mp->sw_if_index_from = htonl (src_sw_if_index);
18133 mp->sw_if_index_to = htonl (dst_sw_if_index);
18143 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
18146 vat_main_t *vam = &vat_main;
18147 u8 *sw_if_from_name = 0;
18148 u8 *sw_if_to_name = 0;
18149 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
18150 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
18151 char *states[] = { "none", "rx", "tx", "both" };
18155 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
18157 if ((u32) p->value[0] == sw_if_index_from)
18159 sw_if_from_name = (u8 *)(p->key);
18163 if ((u32) p->value[0] == sw_if_index_to)
18165 sw_if_to_name = (u8 *)(p->key);
18166 if (sw_if_from_name)
18171 print (vam->ofp, "%20s => %20s (%s) %s",
18172 sw_if_from_name, sw_if_to_name, states[mp->state],
18173 mp->is_l2 ? "l2" : "device");
18177 vl_api_sw_interface_span_details_t_handler_json
18178 (vl_api_sw_interface_span_details_t * mp)
18180 vat_main_t *vam = &vat_main;
18181 vat_json_node_t *node = NULL;
18182 u8 *sw_if_from_name = 0;
18183 u8 *sw_if_to_name = 0;
18184 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
18185 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
18189 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
18191 if ((u32) p->value[0] == sw_if_index_from)
18193 sw_if_from_name = (u8 *)(p->key);
18197 if ((u32) p->value[0] == sw_if_index_to)
18199 sw_if_to_name = (u8 *)(p->key);
18200 if (sw_if_from_name)
18206 if (VAT_JSON_ARRAY != vam->json_tree.type)
18208 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18209 vat_json_init_array (&vam->json_tree);
18211 node = vat_json_array_add (&vam->json_tree);
18213 vat_json_init_object (node);
18214 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
18215 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
18216 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
18217 if (0 != sw_if_to_name)
18219 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
18221 vat_json_object_add_uint (node, "state", mp->state);
18222 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
18226 api_sw_interface_span_dump (vat_main_t * vam)
18228 unformat_input_t *input = vam->input;
18229 vl_api_sw_interface_span_dump_t *mp;
18230 vl_api_control_ping_t *mp_ping;
18234 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18236 if (unformat (input, "l2"))
18242 M (SW_INTERFACE_SPAN_DUMP, mp);
18246 /* Use a control ping for synchronization */
18247 MPING (CONTROL_PING, mp_ping);
18255 api_pg_create_interface (vat_main_t * vam)
18257 unformat_input_t *input = vam->input;
18258 vl_api_pg_create_interface_t *mp;
18260 u32 if_id = ~0, gso_size = 0;
18261 u8 gso_enabled = 0;
18263 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18265 if (unformat (input, "if_id %d", &if_id))
18267 else if (unformat (input, "gso-enabled"))
18270 if (unformat (input, "gso-size %u", &gso_size))
18274 errmsg ("missing gso-size");
18283 errmsg ("missing pg interface index");
18287 /* Construct the API message */
18288 M (PG_CREATE_INTERFACE, mp);
18290 mp->interface_id = ntohl (if_id);
18291 mp->gso_enabled = gso_enabled;
18299 api_pg_capture (vat_main_t * vam)
18301 unformat_input_t *input = vam->input;
18302 vl_api_pg_capture_t *mp;
18307 u8 pcap_file_set = 0;
18310 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18312 if (unformat (input, "if_id %d", &if_id))
18314 else if (unformat (input, "pcap %s", &pcap_file))
18316 else if (unformat (input, "count %d", &count))
18318 else if (unformat (input, "disable"))
18325 errmsg ("missing pg interface index");
18328 if (pcap_file_set > 0)
18330 if (vec_len (pcap_file) > 255)
18332 errmsg ("pcap file name is too long");
18337 /* Construct the API message */
18338 M (PG_CAPTURE, mp);
18340 mp->interface_id = ntohl (if_id);
18341 mp->is_enabled = enable;
18342 mp->count = ntohl (count);
18343 if (pcap_file_set != 0)
18345 vl_api_vec_to_api_string (pcap_file, &mp->pcap_file_name);
18347 vec_free (pcap_file);
18355 api_pg_enable_disable (vat_main_t * vam)
18357 unformat_input_t *input = vam->input;
18358 vl_api_pg_enable_disable_t *mp;
18361 u8 stream_name_set = 0;
18362 u8 *stream_name = 0;
18364 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18366 if (unformat (input, "stream %s", &stream_name))
18367 stream_name_set = 1;
18368 else if (unformat (input, "disable"))
18374 if (stream_name_set > 0)
18376 if (vec_len (stream_name) > 255)
18378 errmsg ("stream name too long");
18383 /* Construct the API message */
18384 M (PG_ENABLE_DISABLE, mp);
18386 mp->is_enabled = enable;
18387 if (stream_name_set != 0)
18389 vl_api_vec_to_api_string (stream_name, &mp->stream_name);
18391 vec_free (stream_name);
18399 api_pg_interface_enable_disable_coalesce (vat_main_t * vam)
18401 unformat_input_t *input = vam->input;
18402 vl_api_pg_interface_enable_disable_coalesce_t *mp;
18404 u32 sw_if_index = ~0;
18407 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18409 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18411 else if (unformat (input, "sw_if_index %d", &sw_if_index))
18413 else if (unformat (input, "disable"))
18419 if (sw_if_index == ~0)
18421 errmsg ("Interface required but not specified");
18425 /* Construct the API message */
18426 M (PG_INTERFACE_ENABLE_DISABLE_COALESCE, mp);
18428 mp->coalesce_enabled = enable;
18429 mp->sw_if_index = htonl (sw_if_index);
18437 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
18439 unformat_input_t *input = vam->input;
18440 vl_api_ip_source_and_port_range_check_add_del_t *mp;
18442 u16 *low_ports = 0;
18443 u16 *high_ports = 0;
18446 vl_api_prefix_t prefix;
18453 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18455 if (unformat (input, "%U", unformat_vl_api_prefix, &prefix))
18457 else if (unformat (input, "vrf %d", &vrf_id))
18459 else if (unformat (input, "del"))
18461 else if (unformat (input, "port %d", &tmp))
18463 if (tmp == 0 || tmp > 65535)
18465 errmsg ("port %d out of range", tmp);
18469 this_hi = this_low + 1;
18470 vec_add1 (low_ports, this_low);
18471 vec_add1 (high_ports, this_hi);
18473 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
18475 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
18477 errmsg ("incorrect range parameters");
18481 /* Note: in debug CLI +1 is added to high before
18482 passing to real fn that does "the work"
18483 (ip_source_and_port_range_check_add_del).
18484 This fn is a wrapper around the binary API fn a
18485 control plane will call, which expects this increment
18486 to have occurred. Hence letting the binary API control
18487 plane fn do the increment for consistency between VAT
18488 and other control planes.
18491 vec_add1 (low_ports, this_low);
18492 vec_add1 (high_ports, this_hi);
18498 if (prefix_set == 0)
18500 errmsg ("<address>/<mask> not specified");
18506 errmsg ("VRF ID required, not specified");
18513 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
18517 if (vec_len (low_ports) == 0)
18519 errmsg ("At least one port or port range required");
18523 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
18525 mp->is_add = is_add;
18527 clib_memcpy (&mp->prefix, &prefix, sizeof (prefix));
18529 mp->number_of_ranges = vec_len (low_ports);
18531 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
18532 vec_free (low_ports);
18534 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
18535 vec_free (high_ports);
18537 mp->vrf_id = ntohl (vrf_id);
18545 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
18547 unformat_input_t *input = vam->input;
18548 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
18549 u32 sw_if_index = ~0;
18551 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
18552 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
18556 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18558 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18560 else if (unformat (input, "sw_if_index %d", &sw_if_index))
18562 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
18564 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
18566 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
18568 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
18570 else if (unformat (input, "del"))
18576 if (sw_if_index == ~0)
18578 errmsg ("Interface required but not specified");
18584 errmsg ("VRF ID required but not specified");
18588 if (tcp_out_vrf_id == 0
18589 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
18592 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
18596 /* Construct the API message */
18597 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
18599 mp->sw_if_index = ntohl (sw_if_index);
18600 mp->is_add = is_add;
18601 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
18602 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
18603 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
18604 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
18609 /* Wait for a reply... */
18615 api_set_punt (vat_main_t * vam)
18617 unformat_input_t *i = vam->input;
18618 vl_api_address_family_t af;
18619 vl_api_set_punt_t *mp;
18625 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18627 if (unformat (i, "%U", unformat_vl_api_address_family, &af))
18629 else if (unformat (i, "protocol %d", &protocol))
18631 else if (unformat (i, "port %d", &port))
18633 else if (unformat (i, "del"))
18637 clib_warning ("parse error '%U'", format_unformat_error, i);
18644 mp->is_add = (u8) is_add;
18645 mp->punt.type = PUNT_API_TYPE_L4;
18646 mp->punt.punt.l4.af = af;
18647 mp->punt.punt.l4.protocol = (u8) protocol;
18648 mp->punt.punt.l4.port = htons ((u16) port);
18656 api_delete_subif (vat_main_t * vam)
18658 unformat_input_t *i = vam->input;
18659 vl_api_delete_subif_t *mp;
18660 u32 sw_if_index = ~0;
18663 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18665 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18667 if (unformat (i, "sw_if_index %d", &sw_if_index))
18673 if (sw_if_index == ~0)
18675 errmsg ("missing sw_if_index");
18679 /* Construct the API message */
18680 M (DELETE_SUBIF, mp);
18681 mp->sw_if_index = ntohl (sw_if_index);
18688 #define foreach_pbb_vtr_op \
18689 _("disable", L2_VTR_DISABLED) \
18690 _("pop", L2_VTR_POP_2) \
18691 _("push", L2_VTR_PUSH_2)
18694 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
18696 unformat_input_t *i = vam->input;
18697 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
18698 u32 sw_if_index = ~0, vtr_op = ~0;
18699 u16 outer_tag = ~0;
18700 u8 dmac[6], smac[6];
18701 u8 dmac_set = 0, smac_set = 0;
18707 /* Shut up coverity */
18708 clib_memset (dmac, 0, sizeof (dmac));
18709 clib_memset (smac, 0, sizeof (smac));
18711 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18713 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18715 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18717 else if (unformat (i, "vtr_op %d", &vtr_op))
18719 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
18722 else if (unformat (i, "translate_pbb_stag"))
18724 if (unformat (i, "%d", &tmp))
18726 vtr_op = L2_VTR_TRANSLATE_2_1;
18732 ("translate_pbb_stag operation requires outer tag definition");
18736 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
18738 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
18740 else if (unformat (i, "sid %d", &sid))
18742 else if (unformat (i, "vlanid %d", &tmp))
18746 clib_warning ("parse error '%U'", format_unformat_error, i);
18751 if ((sw_if_index == ~0) || (vtr_op == ~0))
18753 errmsg ("missing sw_if_index or vtr operation");
18756 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
18757 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
18760 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
18764 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
18765 mp->sw_if_index = ntohl (sw_if_index);
18766 mp->vtr_op = ntohl (vtr_op);
18767 mp->outer_tag = ntohs (outer_tag);
18768 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
18769 clib_memcpy (mp->b_smac, smac, sizeof (smac));
18770 mp->b_vlanid = ntohs (vlanid);
18771 mp->i_sid = ntohl (sid);
18779 api_flow_classify_set_interface (vat_main_t * vam)
18781 unformat_input_t *i = vam->input;
18782 vl_api_flow_classify_set_interface_t *mp;
18784 int sw_if_index_set;
18785 u32 ip4_table_index = ~0;
18786 u32 ip6_table_index = ~0;
18790 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18792 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18793 sw_if_index_set = 1;
18794 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18795 sw_if_index_set = 1;
18796 else if (unformat (i, "del"))
18798 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18800 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18804 clib_warning ("parse error '%U'", format_unformat_error, i);
18809 if (sw_if_index_set == 0)
18811 errmsg ("missing interface name or sw_if_index");
18815 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
18817 mp->sw_if_index = ntohl (sw_if_index);
18818 mp->ip4_table_index = ntohl (ip4_table_index);
18819 mp->ip6_table_index = ntohl (ip6_table_index);
18820 mp->is_add = is_add;
18828 api_flow_classify_dump (vat_main_t * vam)
18830 unformat_input_t *i = vam->input;
18831 vl_api_flow_classify_dump_t *mp;
18832 vl_api_control_ping_t *mp_ping;
18833 u8 type = FLOW_CLASSIFY_N_TABLES;
18836 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
18840 errmsg ("classify table type must be specified");
18844 if (!vam->json_output)
18846 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
18849 M (FLOW_CLASSIFY_DUMP, mp);
18854 /* Use a control ping for synchronization */
18855 MPING (CONTROL_PING, mp_ping);
18858 /* Wait for a reply... */
18864 api_feature_enable_disable (vat_main_t * vam)
18866 unformat_input_t *i = vam->input;
18867 vl_api_feature_enable_disable_t *mp;
18869 u8 *feature_name = 0;
18870 u32 sw_if_index = ~0;
18874 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18876 if (unformat (i, "arc_name %s", &arc_name))
18878 else if (unformat (i, "feature_name %s", &feature_name))
18881 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18883 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18885 else if (unformat (i, "disable"))
18893 errmsg ("missing arc name");
18896 if (vec_len (arc_name) > 63)
18898 errmsg ("arc name too long");
18901 if (feature_name == 0)
18903 errmsg ("missing feature name");
18906 if (vec_len (feature_name) > 63)
18908 errmsg ("feature name too long");
18911 if (sw_if_index == ~0)
18913 errmsg ("missing interface name or sw_if_index");
18917 /* Construct the API message */
18918 M (FEATURE_ENABLE_DISABLE, mp);
18919 mp->sw_if_index = ntohl (sw_if_index);
18920 mp->enable = enable;
18921 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
18922 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
18923 vec_free (arc_name);
18924 vec_free (feature_name);
18932 api_feature_gso_enable_disable (vat_main_t * vam)
18934 unformat_input_t *i = vam->input;
18935 vl_api_feature_gso_enable_disable_t *mp;
18936 u32 sw_if_index = ~0;
18940 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18942 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18944 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18946 else if (unformat (i, "enable"))
18948 else if (unformat (i, "disable"))
18954 if (sw_if_index == ~0)
18956 errmsg ("missing interface name or sw_if_index");
18960 /* Construct the API message */
18961 M (FEATURE_GSO_ENABLE_DISABLE, mp);
18962 mp->sw_if_index = ntohl (sw_if_index);
18963 mp->enable_disable = enable;
18971 api_sw_interface_tag_add_del (vat_main_t * vam)
18973 unformat_input_t *i = vam->input;
18974 vl_api_sw_interface_tag_add_del_t *mp;
18975 u32 sw_if_index = ~0;
18980 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18982 if (unformat (i, "tag %s", &tag))
18984 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18986 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18988 else if (unformat (i, "del"))
18994 if (sw_if_index == ~0)
18996 errmsg ("missing interface name or sw_if_index");
19000 if (enable && (tag == 0))
19002 errmsg ("no tag specified");
19006 /* Construct the API message */
19007 M (SW_INTERFACE_TAG_ADD_DEL, mp);
19008 mp->sw_if_index = ntohl (sw_if_index);
19009 mp->is_add = enable;
19011 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
19020 api_sw_interface_add_del_mac_address (vat_main_t * vam)
19022 unformat_input_t *i = vam->input;
19023 vl_api_mac_address_t mac = { 0 };
19024 vl_api_sw_interface_add_del_mac_address_t *mp;
19025 u32 sw_if_index = ~0;
19030 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19032 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19034 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19036 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
19038 else if (unformat (i, "del"))
19044 if (sw_if_index == ~0)
19046 errmsg ("missing interface name or sw_if_index");
19052 errmsg ("missing MAC address");
19056 /* Construct the API message */
19057 M (SW_INTERFACE_ADD_DEL_MAC_ADDRESS, mp);
19058 mp->sw_if_index = ntohl (sw_if_index);
19059 mp->is_add = is_add;
19060 clib_memcpy (&mp->addr, &mac, sizeof (mac));
19067 static void vl_api_l2_xconnect_details_t_handler
19068 (vl_api_l2_xconnect_details_t * mp)
19070 vat_main_t *vam = &vat_main;
19072 print (vam->ofp, "%15d%15d",
19073 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
19076 static void vl_api_l2_xconnect_details_t_handler_json
19077 (vl_api_l2_xconnect_details_t * mp)
19079 vat_main_t *vam = &vat_main;
19080 vat_json_node_t *node = NULL;
19082 if (VAT_JSON_ARRAY != vam->json_tree.type)
19084 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19085 vat_json_init_array (&vam->json_tree);
19087 node = vat_json_array_add (&vam->json_tree);
19089 vat_json_init_object (node);
19090 vat_json_object_add_uint (node, "rx_sw_if_index",
19091 ntohl (mp->rx_sw_if_index));
19092 vat_json_object_add_uint (node, "tx_sw_if_index",
19093 ntohl (mp->tx_sw_if_index));
19097 api_l2_xconnect_dump (vat_main_t * vam)
19099 vl_api_l2_xconnect_dump_t *mp;
19100 vl_api_control_ping_t *mp_ping;
19103 if (!vam->json_output)
19105 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
19108 M (L2_XCONNECT_DUMP, mp);
19112 /* Use a control ping for synchronization */
19113 MPING (CONTROL_PING, mp_ping);
19121 api_hw_interface_set_mtu (vat_main_t * vam)
19123 unformat_input_t *i = vam->input;
19124 vl_api_hw_interface_set_mtu_t *mp;
19125 u32 sw_if_index = ~0;
19129 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19131 if (unformat (i, "mtu %d", &mtu))
19133 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19135 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19141 if (sw_if_index == ~0)
19143 errmsg ("missing interface name or sw_if_index");
19149 errmsg ("no mtu specified");
19153 /* Construct the API message */
19154 M (HW_INTERFACE_SET_MTU, mp);
19155 mp->sw_if_index = ntohl (sw_if_index);
19156 mp->mtu = ntohs ((u16) mtu);
19164 api_p2p_ethernet_add (vat_main_t * vam)
19166 unformat_input_t *i = vam->input;
19167 vl_api_p2p_ethernet_add_t *mp;
19168 u32 parent_if_index = ~0;
19174 clib_memset (remote_mac, 0, sizeof (remote_mac));
19175 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19177 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
19179 else if (unformat (i, "sw_if_index %d", &parent_if_index))
19183 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
19185 else if (unformat (i, "sub_id %d", &sub_id))
19189 clib_warning ("parse error '%U'", format_unformat_error, i);
19194 if (parent_if_index == ~0)
19196 errmsg ("missing interface name or sw_if_index");
19201 errmsg ("missing remote mac address");
19206 errmsg ("missing sub-interface id");
19210 M (P2P_ETHERNET_ADD, mp);
19211 mp->parent_if_index = ntohl (parent_if_index);
19212 mp->subif_id = ntohl (sub_id);
19213 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
19221 api_p2p_ethernet_del (vat_main_t * vam)
19223 unformat_input_t *i = vam->input;
19224 vl_api_p2p_ethernet_del_t *mp;
19225 u32 parent_if_index = ~0;
19230 clib_memset (remote_mac, 0, sizeof (remote_mac));
19231 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19233 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
19235 else if (unformat (i, "sw_if_index %d", &parent_if_index))
19239 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
19243 clib_warning ("parse error '%U'", format_unformat_error, i);
19248 if (parent_if_index == ~0)
19250 errmsg ("missing interface name or sw_if_index");
19255 errmsg ("missing remote mac address");
19259 M (P2P_ETHERNET_DEL, mp);
19260 mp->parent_if_index = ntohl (parent_if_index);
19261 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
19269 api_lldp_config (vat_main_t * vam)
19271 unformat_input_t *i = vam->input;
19272 vl_api_lldp_config_t *mp;
19274 int tx_interval = 0;
19275 u8 *sys_name = NULL;
19278 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19280 if (unformat (i, "system-name %s", &sys_name))
19282 else if (unformat (i, "tx-hold %d", &tx_hold))
19284 else if (unformat (i, "tx-interval %d", &tx_interval))
19288 clib_warning ("parse error '%U'", format_unformat_error, i);
19293 vec_add1 (sys_name, 0);
19295 M (LLDP_CONFIG, mp);
19296 mp->tx_hold = htonl (tx_hold);
19297 mp->tx_interval = htonl (tx_interval);
19298 vl_api_vec_to_api_string (sys_name, &mp->system_name);
19299 vec_free (sys_name);
19307 api_sw_interface_set_lldp (vat_main_t * vam)
19309 unformat_input_t *i = vam->input;
19310 vl_api_sw_interface_set_lldp_t *mp;
19311 u32 sw_if_index = ~0;
19313 u8 *port_desc = NULL, *mgmt_oid = NULL;
19314 ip4_address_t ip4_addr;
19315 ip6_address_t ip6_addr;
19318 clib_memset (&ip4_addr, 0, sizeof (ip4_addr));
19319 clib_memset (&ip6_addr, 0, sizeof (ip6_addr));
19321 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19323 if (unformat (i, "disable"))
19326 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19328 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19330 else if (unformat (i, "port-desc %s", &port_desc))
19332 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
19334 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
19336 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
19342 if (sw_if_index == ~0)
19344 errmsg ("missing interface name or sw_if_index");
19348 /* Construct the API message */
19349 vec_add1 (port_desc, 0);
19350 vec_add1 (mgmt_oid, 0);
19351 M (SW_INTERFACE_SET_LLDP, mp);
19352 mp->sw_if_index = ntohl (sw_if_index);
19353 mp->enable = enable;
19354 vl_api_vec_to_api_string (port_desc, &mp->port_desc);
19355 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
19356 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
19357 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
19358 vec_free (port_desc);
19359 vec_free (mgmt_oid);
19367 api_tcp_configure_src_addresses (vat_main_t * vam)
19369 vl_api_tcp_configure_src_addresses_t *mp;
19370 unformat_input_t *i = vam->input;
19371 vl_api_address_t first, last;
19376 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19378 if (unformat (i, "%U - %U",
19379 unformat_vl_api_address, &first,
19380 unformat_vl_api_address, &last))
19384 errmsg ("one range per message (range already set)");
19389 else if (unformat (i, "vrf %d", &vrf_id))
19395 if (range_set == 0)
19397 errmsg ("address range not set");
19401 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
19403 mp->vrf_id = ntohl (vrf_id);
19404 clib_memcpy (&mp->first_address, &first, sizeof (first));
19405 clib_memcpy (&mp->last_address, &last, sizeof (last));
19412 static void vl_api_app_namespace_add_del_reply_t_handler
19413 (vl_api_app_namespace_add_del_reply_t * mp)
19415 vat_main_t *vam = &vat_main;
19416 i32 retval = ntohl (mp->retval);
19417 if (vam->async_mode)
19419 vam->async_errors += (retval < 0);
19423 vam->retval = retval;
19425 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
19426 vam->result_ready = 1;
19430 static void vl_api_app_namespace_add_del_reply_t_handler_json
19431 (vl_api_app_namespace_add_del_reply_t * mp)
19433 vat_main_t *vam = &vat_main;
19434 vat_json_node_t node;
19436 vat_json_init_object (&node);
19437 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
19438 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
19440 vat_json_print (vam->ofp, &node);
19441 vat_json_free (&node);
19443 vam->retval = ntohl (mp->retval);
19444 vam->result_ready = 1;
19448 api_app_namespace_add_del (vat_main_t * vam)
19450 vl_api_app_namespace_add_del_t *mp;
19451 unformat_input_t *i = vam->input;
19452 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
19453 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
19457 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19459 if (unformat (i, "id %_%v%_", &ns_id))
19461 else if (unformat (i, "secret %lu", &secret))
19463 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19464 sw_if_index_set = 1;
19465 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
19467 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
19472 if (!ns_id || !secret_set || !sw_if_index_set)
19474 errmsg ("namespace id, secret and sw_if_index must be set");
19477 if (vec_len (ns_id) > 64)
19479 errmsg ("namespace id too long");
19482 M (APP_NAMESPACE_ADD_DEL, mp);
19484 vl_api_vec_to_api_string (ns_id, &mp->namespace_id);
19485 mp->secret = clib_host_to_net_u64 (secret);
19486 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
19487 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
19488 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
19496 api_sock_init_shm (vat_main_t * vam)
19498 #if VPP_API_TEST_BUILTIN == 0
19499 unformat_input_t *i = vam->input;
19500 vl_api_shm_elem_config_t *config = 0;
19501 u64 size = 64 << 20;
19504 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19506 if (unformat (i, "size %U", unformat_memory_size, &size))
19513 * Canned custom ring allocator config.
19514 * Should probably parse all of this
19516 vec_validate (config, 6);
19517 config[0].type = VL_API_VLIB_RING;
19518 config[0].size = 256;
19519 config[0].count = 32;
19521 config[1].type = VL_API_VLIB_RING;
19522 config[1].size = 1024;
19523 config[1].count = 16;
19525 config[2].type = VL_API_VLIB_RING;
19526 config[2].size = 4096;
19527 config[2].count = 2;
19529 config[3].type = VL_API_CLIENT_RING;
19530 config[3].size = 256;
19531 config[3].count = 32;
19533 config[4].type = VL_API_CLIENT_RING;
19534 config[4].size = 1024;
19535 config[4].count = 16;
19537 config[5].type = VL_API_CLIENT_RING;
19538 config[5].size = 4096;
19539 config[5].count = 2;
19541 config[6].type = VL_API_QUEUE;
19542 config[6].count = 128;
19543 config[6].size = sizeof (uword);
19545 rv = vl_socket_client_init_shm (config, 1 /* want_pthread */ );
19547 vam->client_index_invalid = 1;
19555 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
19557 vat_main_t *vam = &vat_main;
19558 fib_prefix_t lcl, rmt;
19560 ip_prefix_decode (&mp->lcl, &lcl);
19561 ip_prefix_decode (&mp->rmt, &rmt);
19563 if (lcl.fp_proto == FIB_PROTOCOL_IP4)
19566 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
19567 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
19568 mp->scope, format_ip4_address, &lcl.fp_addr.ip4, lcl.fp_len,
19569 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
19570 &rmt.fp_addr.ip4, rmt.fp_len,
19571 clib_net_to_host_u16 (mp->rmt_port),
19572 clib_net_to_host_u32 (mp->action_index), mp->tag);
19577 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
19578 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
19579 mp->scope, format_ip6_address, &lcl.fp_addr.ip6, lcl.fp_len,
19580 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
19581 &rmt.fp_addr.ip6, rmt.fp_len,
19582 clib_net_to_host_u16 (mp->rmt_port),
19583 clib_net_to_host_u32 (mp->action_index), mp->tag);
19588 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
19591 vat_main_t *vam = &vat_main;
19592 vat_json_node_t *node = NULL;
19593 struct in6_addr ip6;
19594 struct in_addr ip4;
19596 fib_prefix_t lcl, rmt;
19598 ip_prefix_decode (&mp->lcl, &lcl);
19599 ip_prefix_decode (&mp->rmt, &rmt);
19601 if (VAT_JSON_ARRAY != vam->json_tree.type)
19603 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19604 vat_json_init_array (&vam->json_tree);
19606 node = vat_json_array_add (&vam->json_tree);
19607 vat_json_init_object (node);
19609 vat_json_object_add_uint (node, "appns_index",
19610 clib_net_to_host_u32 (mp->appns_index));
19611 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
19612 vat_json_object_add_uint (node, "scope", mp->scope);
19613 vat_json_object_add_uint (node, "action_index",
19614 clib_net_to_host_u32 (mp->action_index));
19615 vat_json_object_add_uint (node, "lcl_port",
19616 clib_net_to_host_u16 (mp->lcl_port));
19617 vat_json_object_add_uint (node, "rmt_port",
19618 clib_net_to_host_u16 (mp->rmt_port));
19619 vat_json_object_add_uint (node, "lcl_plen", lcl.fp_len);
19620 vat_json_object_add_uint (node, "rmt_plen", rmt.fp_len);
19621 vat_json_object_add_string_copy (node, "tag", mp->tag);
19622 if (lcl.fp_proto == FIB_PROTOCOL_IP4)
19624 clib_memcpy (&ip4, &lcl.fp_addr.ip4, sizeof (ip4));
19625 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
19626 clib_memcpy (&ip4, &rmt.fp_addr.ip4, sizeof (ip4));
19627 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
19631 clib_memcpy (&ip6, &lcl.fp_addr.ip6, sizeof (ip6));
19632 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
19633 clib_memcpy (&ip6, &rmt.fp_addr.ip6, sizeof (ip6));
19634 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
19639 api_session_rule_add_del (vat_main_t * vam)
19641 vl_api_session_rule_add_del_t *mp;
19642 unformat_input_t *i = vam->input;
19643 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
19644 u32 appns_index = 0, scope = 0;
19645 ip4_address_t lcl_ip4, rmt_ip4;
19646 ip6_address_t lcl_ip6, rmt_ip6;
19647 u8 is_ip4 = 1, conn_set = 0;
19648 u8 is_add = 1, *tag = 0;
19650 fib_prefix_t lcl, rmt;
19652 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19654 if (unformat (i, "del"))
19656 else if (unformat (i, "add"))
19658 else if (unformat (i, "proto tcp"))
19660 else if (unformat (i, "proto udp"))
19662 else if (unformat (i, "appns %d", &appns_index))
19664 else if (unformat (i, "scope %d", &scope))
19666 else if (unformat (i, "tag %_%v%_", &tag))
19670 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
19671 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
19679 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
19680 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
19686 else if (unformat (i, "action %d", &action))
19691 if (proto == ~0 || !conn_set || action == ~0)
19693 errmsg ("transport proto, connection and action must be set");
19699 errmsg ("scope should be 0-3");
19703 M (SESSION_RULE_ADD_DEL, mp);
19705 clib_memset (&lcl, 0, sizeof (lcl));
19706 clib_memset (&rmt, 0, sizeof (rmt));
19709 ip_set (&lcl.fp_addr, &lcl_ip4, 1);
19710 ip_set (&rmt.fp_addr, &rmt_ip4, 1);
19711 lcl.fp_len = lcl_plen;
19712 rmt.fp_len = rmt_plen;
19716 ip_set (&lcl.fp_addr, &lcl_ip6, 0);
19717 ip_set (&rmt.fp_addr, &rmt_ip6, 0);
19718 lcl.fp_len = lcl_plen;
19719 rmt.fp_len = rmt_plen;
19723 ip_prefix_encode (&lcl, &mp->lcl);
19724 ip_prefix_encode (&rmt, &mp->rmt);
19725 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
19726 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
19727 mp->transport_proto =
19728 proto ? TRANSPORT_PROTO_API_UDP : TRANSPORT_PROTO_API_TCP;
19729 mp->action_index = clib_host_to_net_u32 (action);
19730 mp->appns_index = clib_host_to_net_u32 (appns_index);
19732 mp->is_add = is_add;
19735 clib_memcpy (mp->tag, tag, vec_len (tag));
19745 api_session_rules_dump (vat_main_t * vam)
19747 vl_api_session_rules_dump_t *mp;
19748 vl_api_control_ping_t *mp_ping;
19751 if (!vam->json_output)
19753 print (vam->ofp, "%=20s", "Session Rules");
19756 M (SESSION_RULES_DUMP, mp);
19760 /* Use a control ping for synchronization */
19761 MPING (CONTROL_PING, mp_ping);
19764 /* Wait for a reply... */
19770 api_ip_container_proxy_add_del (vat_main_t * vam)
19772 vl_api_ip_container_proxy_add_del_t *mp;
19773 unformat_input_t *i = vam->input;
19774 u32 sw_if_index = ~0;
19775 vl_api_prefix_t pfx = { };
19779 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19781 if (unformat (i, "del"))
19783 else if (unformat (i, "add"))
19785 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
19787 else if (unformat (i, "sw_if_index %u", &sw_if_index))
19792 if (sw_if_index == ~0 || pfx.len == 0)
19794 errmsg ("address and sw_if_index must be set");
19798 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
19800 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
19801 mp->is_add = is_add;
19802 clib_memcpy (&mp->pfx, &pfx, sizeof (pfx));
19810 api_qos_record_enable_disable (vat_main_t * vam)
19812 unformat_input_t *i = vam->input;
19813 vl_api_qos_record_enable_disable_t *mp;
19814 u32 sw_if_index, qs = 0xff;
19815 u8 sw_if_index_set = 0;
19819 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19821 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19822 sw_if_index_set = 1;
19823 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19824 sw_if_index_set = 1;
19825 else if (unformat (i, "%U", unformat_qos_source, &qs))
19827 else if (unformat (i, "disable"))
19831 clib_warning ("parse error '%U'", format_unformat_error, i);
19836 if (sw_if_index_set == 0)
19838 errmsg ("missing interface name or sw_if_index");
19843 errmsg ("input location must be specified");
19847 M (QOS_RECORD_ENABLE_DISABLE, mp);
19849 mp->record.sw_if_index = ntohl (sw_if_index);
19850 mp->record.input_source = qs;
19851 mp->enable = enable;
19860 q_or_quit (vat_main_t * vam)
19862 #if VPP_API_TEST_BUILTIN == 0
19863 longjmp (vam->jump_buf, 1);
19865 return 0; /* not so much */
19869 q (vat_main_t * vam)
19871 return q_or_quit (vam);
19875 quit (vat_main_t * vam)
19877 return q_or_quit (vam);
19881 comment (vat_main_t * vam)
19887 elog_save (vat_main_t * vam)
19889 #if VPP_API_TEST_BUILTIN == 0
19890 elog_main_t *em = &vam->elog_main;
19891 unformat_input_t *i = vam->input;
19892 char *file, *chroot_file;
19893 clib_error_t *error;
19895 if (!unformat (i, "%s", &file))
19897 errmsg ("expected file name, got `%U'", format_unformat_error, i);
19901 /* It's fairly hard to get "../oopsie" through unformat; just in case */
19902 if (strstr (file, "..") || index (file, '/'))
19904 errmsg ("illegal characters in filename '%s'", file);
19908 chroot_file = (char *) format (0, "/tmp/%s%c", file, 0);
19912 errmsg ("Saving %wd of %wd events to %s",
19913 elog_n_events_in_buffer (em),
19914 elog_buffer_capacity (em), chroot_file);
19916 error = elog_write_file (em, chroot_file, 1 /* flush ring */ );
19917 vec_free (chroot_file);
19920 clib_error_report (error);
19922 errmsg ("Use the vpp event loger...");
19929 elog_setup (vat_main_t * vam)
19931 #if VPP_API_TEST_BUILTIN == 0
19932 elog_main_t *em = &vam->elog_main;
19933 unformat_input_t *i = vam->input;
19934 u32 nevents = 128 << 10;
19936 (void) unformat (i, "nevents %d", &nevents);
19938 elog_init (em, nevents);
19939 vl_api_set_elog_main (em);
19940 vl_api_set_elog_trace_api_messages (1);
19941 errmsg ("Event logger initialized with %u events", nevents);
19943 errmsg ("Use the vpp event loger...");
19949 elog_enable (vat_main_t * vam)
19951 #if VPP_API_TEST_BUILTIN == 0
19952 elog_main_t *em = &vam->elog_main;
19954 elog_enable_disable (em, 1 /* enable */ );
19955 vl_api_set_elog_trace_api_messages (1);
19956 errmsg ("Event logger enabled...");
19958 errmsg ("Use the vpp event loger...");
19964 elog_disable (vat_main_t * vam)
19966 #if VPP_API_TEST_BUILTIN == 0
19967 elog_main_t *em = &vam->elog_main;
19969 elog_enable_disable (em, 0 /* enable */ );
19970 vl_api_set_elog_trace_api_messages (1);
19971 errmsg ("Event logger disabled...");
19973 errmsg ("Use the vpp event loger...");
19979 statseg (vat_main_t * vam)
19981 ssvm_private_t *ssvmp = &vam->stat_segment;
19982 ssvm_shared_header_t *shared_header = ssvmp->sh;
19983 vlib_counter_t **counters;
19984 u64 thread0_index1_packets;
19985 u64 thread0_index1_bytes;
19986 f64 vector_rate, input_rate;
19989 uword *counter_vector_by_name;
19990 if (vam->stat_segment_lockp == 0)
19992 errmsg ("Stat segment not mapped...");
19996 /* look up "/if/rx for sw_if_index 1 as a test */
19998 clib_spinlock_lock (vam->stat_segment_lockp);
20000 counter_vector_by_name = (uword *) shared_header->opaque[1];
20002 p = hash_get_mem (counter_vector_by_name, "/if/rx");
20005 clib_spinlock_unlock (vam->stat_segment_lockp);
20006 errmsg ("/if/tx not found?");
20010 /* Fish per-thread vector of combined counters from shared memory */
20011 counters = (vlib_counter_t **) p[0];
20013 if (vec_len (counters[0]) < 2)
20015 clib_spinlock_unlock (vam->stat_segment_lockp);
20016 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
20020 /* Read thread 0 sw_if_index 1 counter */
20021 thread0_index1_packets = counters[0][1].packets;
20022 thread0_index1_bytes = counters[0][1].bytes;
20024 p = hash_get_mem (counter_vector_by_name, "vector_rate");
20027 clib_spinlock_unlock (vam->stat_segment_lockp);
20028 errmsg ("vector_rate not found?");
20032 vector_rate = *(f64 *) (p[0]);
20033 p = hash_get_mem (counter_vector_by_name, "input_rate");
20036 clib_spinlock_unlock (vam->stat_segment_lockp);
20037 errmsg ("input_rate not found?");
20040 input_rate = *(f64 *) (p[0]);
20042 clib_spinlock_unlock (vam->stat_segment_lockp);
20044 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
20045 vector_rate, input_rate);
20046 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
20047 thread0_index1_packets, thread0_index1_bytes);
20053 cmd_cmp (void *a1, void *a2)
20058 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
20062 help (vat_main_t * vam)
20067 unformat_input_t *i = vam->input;
20070 if (unformat (i, "%s", &name))
20074 vec_add1 (name, 0);
20076 hs = hash_get_mem (vam->help_by_name, name);
20078 print (vam->ofp, "usage: %s %s", name, hs[0]);
20080 print (vam->ofp, "No such msg / command '%s'", name);
20085 print (vam->ofp, "Help is available for the following:");
20088 hash_foreach_pair (p, vam->function_by_name,
20090 vec_add1 (cmds, (u8 *)(p->key));
20094 vec_sort_with_function (cmds, cmd_cmp);
20096 for (j = 0; j < vec_len (cmds); j++)
20097 print (vam->ofp, "%s", cmds[j]);
20104 set (vat_main_t * vam)
20106 u8 *name = 0, *value = 0;
20107 unformat_input_t *i = vam->input;
20109 if (unformat (i, "%s", &name))
20111 /* The input buffer is a vector, not a string. */
20112 value = vec_dup (i->buffer);
20113 vec_delete (value, i->index, 0);
20114 /* Almost certainly has a trailing newline */
20115 if (value[vec_len (value) - 1] == '\n')
20116 value[vec_len (value) - 1] = 0;
20117 /* Make sure it's a proper string, one way or the other */
20118 vec_add1 (value, 0);
20119 (void) clib_macro_set_value (&vam->macro_main,
20120 (char *) name, (char *) value);
20123 errmsg ("usage: set <name> <value>");
20131 unset (vat_main_t * vam)
20135 if (unformat (vam->input, "%s", &name))
20136 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
20137 errmsg ("unset: %s wasn't set", name);
20150 macro_sort_cmp (void *a1, void *a2)
20152 macro_sort_t *s1 = a1;
20153 macro_sort_t *s2 = a2;
20155 return strcmp ((char *) (s1->name), (char *) (s2->name));
20159 dump_macro_table (vat_main_t * vam)
20161 macro_sort_t *sort_me = 0, *sm;
20166 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
20168 vec_add2 (sort_me, sm, 1);
20169 sm->name = (u8 *)(p->key);
20170 sm->value = (u8 *) (p->value[0]);
20174 vec_sort_with_function (sort_me, macro_sort_cmp);
20176 if (vec_len (sort_me))
20177 print (vam->ofp, "%-15s%s", "Name", "Value");
20179 print (vam->ofp, "The macro table is empty...");
20181 for (i = 0; i < vec_len (sort_me); i++)
20182 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
20187 dump_node_table (vat_main_t * vam)
20190 vlib_node_t *node, *next_node;
20192 if (vec_len (vam->graph_nodes) == 0)
20194 print (vam->ofp, "Node table empty, issue get_node_graph...");
20198 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
20200 node = vam->graph_nodes[0][i];
20201 print (vam->ofp, "[%d] %s", i, node->name);
20202 for (j = 0; j < vec_len (node->next_nodes); j++)
20204 if (node->next_nodes[j] != ~0)
20206 next_node = vam->graph_nodes[0][node->next_nodes[j]];
20207 print (vam->ofp, " [%d] %s", j, next_node->name);
20215 value_sort_cmp (void *a1, void *a2)
20217 name_sort_t *n1 = a1;
20218 name_sort_t *n2 = a2;
20220 if (n1->value < n2->value)
20222 if (n1->value > n2->value)
20229 dump_msg_api_table (vat_main_t * vam)
20231 api_main_t *am = vlibapi_get_main ();
20232 name_sort_t *nses = 0, *ns;
20237 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
20239 vec_add2 (nses, ns, 1);
20240 ns->name = (u8 *)(hp->key);
20241 ns->value = (u32) hp->value[0];
20245 vec_sort_with_function (nses, value_sort_cmp);
20247 for (i = 0; i < vec_len (nses); i++)
20248 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
20254 get_msg_id (vat_main_t * vam)
20259 if (unformat (vam->input, "%s", &name_and_crc))
20261 message_index = vl_msg_api_get_msg_index (name_and_crc);
20262 if (message_index == ~0)
20264 print (vam->ofp, " '%s' not found", name_and_crc);
20267 print (vam->ofp, " '%s' has message index %d",
20268 name_and_crc, message_index);
20271 errmsg ("name_and_crc required...");
20276 search_node_table (vat_main_t * vam)
20278 unformat_input_t *line_input = vam->input;
20281 vlib_node_t *node, *next_node;
20284 if (vam->graph_node_index_by_name == 0)
20286 print (vam->ofp, "Node table empty, issue get_node_graph...");
20290 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
20292 if (unformat (line_input, "%s", &node_to_find))
20294 vec_add1 (node_to_find, 0);
20295 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
20298 print (vam->ofp, "%s not found...", node_to_find);
20301 node = vam->graph_nodes[0][p[0]];
20302 print (vam->ofp, "[%d] %s", p[0], node->name);
20303 for (j = 0; j < vec_len (node->next_nodes); j++)
20305 if (node->next_nodes[j] != ~0)
20307 next_node = vam->graph_nodes[0][node->next_nodes[j]];
20308 print (vam->ofp, " [%d] %s", j, next_node->name);
20315 clib_warning ("parse error '%U'", format_unformat_error,
20321 vec_free (node_to_find);
20330 script (vat_main_t * vam)
20332 #if (VPP_API_TEST_BUILTIN==0)
20334 char *save_current_file;
20335 unformat_input_t save_input;
20336 jmp_buf save_jump_buf;
20337 u32 save_line_number;
20339 FILE *new_fp, *save_ifp;
20341 if (unformat (vam->input, "%s", &s))
20343 new_fp = fopen ((char *) s, "r");
20346 errmsg ("Couldn't open script file %s", s);
20353 errmsg ("Missing script name");
20357 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
20358 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
20359 save_ifp = vam->ifp;
20360 save_line_number = vam->input_line_number;
20361 save_current_file = (char *) vam->current_file;
20363 vam->input_line_number = 0;
20365 vam->current_file = s;
20368 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
20369 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
20370 vam->ifp = save_ifp;
20371 vam->input_line_number = save_line_number;
20372 vam->current_file = (u8 *) save_current_file;
20377 clib_warning ("use the exec command...");
20383 echo (vat_main_t * vam)
20385 print (vam->ofp, "%v", vam->input->buffer);
20389 /* List of API message constructors, CLI names map to api_xxx */
20390 #define foreach_vpe_api_msg \
20391 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
20392 _(sw_interface_dump,"") \
20393 _(sw_interface_set_flags, \
20394 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
20395 _(sw_interface_add_del_address, \
20396 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
20397 _(sw_interface_set_rx_mode, \
20398 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
20399 _(sw_interface_set_rx_placement, \
20400 "<intfc> | sw_if_index <id> [queue <id>] [worker <id> | main]") \
20401 _(sw_interface_rx_placement_dump, \
20402 "[<intfc> | sw_if_index <id>]") \
20403 _(sw_interface_set_table, \
20404 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
20405 _(sw_interface_set_mpls_enable, \
20406 "<intfc> | sw_if_index [disable | dis]") \
20407 _(sw_interface_set_vpath, \
20408 "<intfc> | sw_if_index <id> enable | disable") \
20409 _(sw_interface_set_vxlan_bypass, \
20410 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
20411 _(sw_interface_set_l2_xconnect, \
20412 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
20413 "enable | disable") \
20414 _(sw_interface_set_l2_bridge, \
20415 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
20416 "[shg <split-horizon-group>] [bvi]\n" \
20417 "enable | disable") \
20418 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
20419 _(bridge_domain_add_del, \
20420 "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") \
20421 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
20423 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
20424 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
20425 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
20427 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
20429 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
20431 "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]") \
20433 "<vpp-if-name> | sw_if_index <id>") \
20434 _(sw_interface_tap_v2_dump, "") \
20435 _(virtio_pci_create_v2, \
20436 "pci-addr <pci-address> [use_random_mac | hw-addr <mac-addr>] [features <hex-value>] [gso-enabled [gro-coalesce] | csum-offload-enabled] [packed] [in-order]") \
20437 _(virtio_pci_delete, \
20438 "<vpp-if-name> | sw_if_index <id>") \
20439 _(sw_interface_virtio_pci_dump, "") \
20441 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
20442 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \
20445 "[hw-addr <mac-addr>] {mode round-robin | active-backup | " \
20446 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \
20447 "[id <if-id>] [gso]") \
20449 "<vpp-if-name> | sw_if_index <id>") \
20450 _(bond_add_member, \
20451 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
20452 _(bond_detach_member, \
20453 "sw_if_index <n>") \
20454 _(sw_interface_set_bond_weight, "<intfc> | sw_if_index <nn> weight <value>") \
20455 _(sw_bond_interface_dump, "<intfc> | sw_if_index <nn>") \
20456 _(sw_member_interface_dump, \
20457 "<vpp-if-name> | sw_if_index <id>") \
20458 _(ip_table_add_del, \
20459 "table <n> [ipv6] [add | del]\n") \
20460 _(ip_route_add_del, \
20461 "<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
20462 "[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
20463 "[weight <n>] [drop] [local] [classify <n>] [out-label <n>]\n" \
20464 "[multipath] [count <n>] [del]") \
20465 _(ip_mroute_add_del, \
20466 "<src> <grp>/<mask> [table-id <n>]\n" \
20467 "[<intfc> | sw_if_index <id>] [local] [del]") \
20468 _(mpls_table_add_del, \
20469 "table <n> [add | del]\n") \
20470 _(mpls_route_add_del, \
20471 "<label> <eos> via <addr | next-hop-table <n> | via-label <n> |\n" \
20472 "lookup-ip4-table <n> | lookup-in-ip6-table <n> |\n" \
20473 "l2-input-on <intfc> | l2-input-on sw_if_index <id>>\n" \
20474 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>] [weight <n>]\n" \
20475 "[drop] [local] [classify <n>] [out-label <n>] [multipath]\n" \
20476 "[count <n>] [del]") \
20477 _(mpls_ip_bind_unbind, \
20478 "<label> <addr/len>") \
20479 _(mpls_tunnel_add_del, \
20480 "[add | del <intfc | sw_if_index <id>>] via <addr | via-label <n>>\n" \
20481 "[<intfc> | sw_if_index <id> | next-hop-table <id>]\n" \
20482 "[l2-only] [out-label <n>]") \
20483 _(sr_mpls_policy_add, \
20484 "bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
20485 _(sr_mpls_policy_del, \
20487 _(bier_table_add_del, \
20488 "<label> <sub-domain> <set> <bsl> [del]") \
20489 _(bier_route_add_del, \
20490 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
20491 "[<intfc> | sw_if_index <id>]" \
20492 "[weight <n>] [del] [multipath]") \
20493 _(sw_interface_set_unnumbered, \
20494 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
20495 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
20496 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
20497 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
20498 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
20499 "[outer_vlan_id_any][inner_vlan_id_any]") \
20500 _(ip_table_replace_begin, "table <n> [ipv6]") \
20501 _(ip_table_flush, "table <n> [ipv6]") \
20502 _(ip_table_replace_end, "table <n> [ipv6]") \
20503 _(set_ip_flow_hash, \
20504 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
20505 _(sw_interface_ip6_enable_disable, \
20506 "<intfc> | sw_if_index <id> enable | disable") \
20507 _(l2_patch_add_del, \
20508 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
20509 "enable | disable") \
20510 _(sr_localsid_add_del, \
20511 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
20512 "fib-table <num> (end.psp) sw_if_index <num>") \
20513 _(classify_add_del_table, \
20514 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
20515 " [del] [del-chain] mask <mask-value>\n" \
20516 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
20517 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
20518 _(classify_add_del_session, \
20519 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
20520 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
20521 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
20522 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
20523 _(classify_set_interface_ip_table, \
20524 "<intfc> | sw_if_index <nn> table <nn>") \
20525 _(classify_set_interface_l2_tables, \
20526 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20527 " [other-table <nn>]") \
20528 _(get_node_index, "node <node-name") \
20529 _(add_node_next, "node <node-name> next <next-node-name>") \
20530 _(l2tpv3_create_tunnel, \
20531 "client_address <ip6-addr> our_address <ip6-addr>\n" \
20532 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
20533 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
20534 _(l2tpv3_set_tunnel_cookies, \
20535 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
20536 "[new_remote_cookie <nn>]\n") \
20537 _(l2tpv3_interface_enable_disable, \
20538 "<intfc> | sw_if_index <nn> enable | disable") \
20539 _(l2tpv3_set_lookup_key, \
20540 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
20541 _(sw_if_l2tpv3_tunnel_dump, "") \
20542 _(vxlan_offload_rx, \
20543 "hw { <interface name> | hw_if_index <nn>} " \
20544 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
20545 _(vxlan_add_del_tunnel, \
20546 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
20547 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
20548 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
20549 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20550 _(gre_tunnel_add_del, \
20551 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
20552 "[teb | erspan <session-id>] [del]") \
20553 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20554 _(l2_fib_clear_table, "") \
20555 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
20556 _(l2_interface_vlan_tag_rewrite, \
20557 "<intfc> | sw_if_index <nn> \n" \
20558 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
20559 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
20560 _(create_vhost_user_if, \
20561 "socket <filename> [server] [renumber <dev_instance>] " \
20562 "[disable_mrg_rxbuf] [disable_indirect_desc] [gso] " \
20563 "[mac <mac_address>] [packed]") \
20564 _(modify_vhost_user_if, \
20565 "<intfc> | sw_if_index <nn> socket <filename>\n" \
20566 "[server] [renumber <dev_instance>] [gso] [packed]") \
20567 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
20568 _(sw_interface_vhost_user_dump, "<intfc> | sw_if_index <nn>") \
20569 _(show_version, "") \
20570 _(show_threads, "") \
20571 _(vxlan_gpe_add_del_tunnel, \
20572 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
20573 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
20574 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
20575 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
20576 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20577 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
20578 _(interface_name_renumber, \
20579 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
20580 _(input_acl_set_interface, \
20581 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20582 " [l2-table <nn>] [del]") \
20583 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
20584 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
20585 _(ip_dump, "ipv4 | ipv6") \
20586 _(ipsec_spd_add_del, "spd_id <n> [del]") \
20587 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
20589 _(ipsec_sad_entry_add_del, "sad_id <n> spi <n> crypto_alg <alg>\n" \
20590 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
20591 " integ_alg <alg> integ_key <hex>") \
20592 _(ipsec_spd_entry_add_del, "spd_id <n> priority <n> action <action>\n" \
20593 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
20594 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
20595 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
20596 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
20597 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
20598 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
20599 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
20600 " [instance <n>]") \
20601 _(ipsec_sa_dump, "[sa_id <n>]") \
20602 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
20603 _(delete_loopback,"sw_if_index <nn>") \
20604 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
20605 _(bd_ip_mac_flush, "bd_id <bridge-domain-id>") \
20606 _(bd_ip_mac_dump, "[bd_id] <bridge-domain-id>") \
20607 _(want_interface_events, "enable|disable") \
20608 _(get_first_msg_id, "client <name>") \
20609 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
20610 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
20611 "fib-id <nn> [ip4][ip6][default]") \
20612 _(get_node_graph, " ") \
20613 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
20614 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
20615 _(ioam_disable, "") \
20616 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
20617 " sw_if_index <sw_if_index> p <priority> " \
20618 "w <weight>] [del]") \
20619 _(one_add_del_locator, "locator-set <locator_name> " \
20620 "iface <intf> | sw_if_index <sw_if_index> " \
20621 "p <priority> w <weight> [del]") \
20622 _(one_add_del_local_eid,"vni <vni> eid " \
20623 "<ipv4|ipv6>/<prefix> | <L2 address> " \
20624 "locator-set <locator_name> [del]" \
20625 "[key-id sha1|sha256 secret-key <secret-key>]")\
20626 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
20627 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
20628 _(one_enable_disable, "enable|disable") \
20629 _(one_map_register_enable_disable, "enable|disable") \
20630 _(one_map_register_fallback_threshold, "<value>") \
20631 _(one_rloc_probe_enable_disable, "enable|disable") \
20632 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
20634 "rloc <locator> p <prio> " \
20635 "w <weight> [rloc <loc> ... ] " \
20636 "action <action> [del-all]") \
20637 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
20639 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
20640 _(one_use_petr, "ip-address> | disable") \
20641 _(one_map_request_mode, "src-dst|dst-only") \
20642 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
20643 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
20644 _(one_locator_set_dump, "[local | remote]") \
20645 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
20646 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
20647 "[local] | [remote]") \
20648 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
20649 _(one_ndp_bd_get, "") \
20650 _(one_ndp_entries_get, "bd <bridge-domain>") \
20651 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip <ip4>") \
20652 _(one_l2_arp_bd_get, "") \
20653 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
20654 _(one_stats_enable_disable, "enable|disable") \
20655 _(show_one_stats_enable_disable, "") \
20656 _(one_eid_table_vni_dump, "") \
20657 _(one_eid_table_map_dump, "l2|l3") \
20658 _(one_map_resolver_dump, "") \
20659 _(one_map_server_dump, "") \
20660 _(one_adjacencies_get, "vni <vni>") \
20661 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
20662 _(show_one_rloc_probe_state, "") \
20663 _(show_one_map_register_state, "") \
20664 _(show_one_status, "") \
20665 _(one_stats_dump, "") \
20666 _(one_stats_flush, "") \
20667 _(one_get_map_request_itr_rlocs, "") \
20668 _(one_map_register_set_ttl, "<ttl>") \
20669 _(one_set_transport_protocol, "udp|api") \
20670 _(one_get_transport_protocol, "") \
20671 _(one_enable_disable_xtr_mode, "enable|disable") \
20672 _(one_show_xtr_mode, "") \
20673 _(one_enable_disable_pitr_mode, "enable|disable") \
20674 _(one_show_pitr_mode, "") \
20675 _(one_enable_disable_petr_mode, "enable|disable") \
20676 _(one_show_petr_mode, "") \
20677 _(show_one_nsh_mapping, "") \
20678 _(show_one_pitr, "") \
20679 _(show_one_use_petr, "") \
20680 _(show_one_map_request_mode, "") \
20681 _(show_one_map_register_ttl, "") \
20682 _(show_one_map_register_fallback_threshold, "") \
20683 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
20684 " sw_if_index <sw_if_index> p <priority> " \
20685 "w <weight>] [del]") \
20686 _(lisp_add_del_locator, "locator-set <locator_name> " \
20687 "iface <intf> | sw_if_index <sw_if_index> " \
20688 "p <priority> w <weight> [del]") \
20689 _(lisp_add_del_local_eid,"vni <vni> eid " \
20690 "<ipv4|ipv6>/<prefix> | <L2 address> " \
20691 "locator-set <locator_name> [del]" \
20692 "[key-id sha1|sha256 secret-key <secret-key>]") \
20693 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
20694 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
20695 _(lisp_enable_disable, "enable|disable") \
20696 _(lisp_map_register_enable_disable, "enable|disable") \
20697 _(lisp_rloc_probe_enable_disable, "enable|disable") \
20698 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
20700 "rloc <locator> p <prio> " \
20701 "w <weight> [rloc <loc> ... ] " \
20702 "action <action> [del-all]") \
20703 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
20705 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
20706 _(lisp_use_petr, "<ip-address> | disable") \
20707 _(lisp_map_request_mode, "src-dst|dst-only") \
20708 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
20709 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
20710 _(lisp_locator_set_dump, "[local | remote]") \
20711 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
20712 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
20713 "[local] | [remote]") \
20714 _(lisp_eid_table_vni_dump, "") \
20715 _(lisp_eid_table_map_dump, "l2|l3") \
20716 _(lisp_map_resolver_dump, "") \
20717 _(lisp_map_server_dump, "") \
20718 _(lisp_adjacencies_get, "vni <vni>") \
20719 _(gpe_fwd_entry_vnis_get, "") \
20720 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
20721 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
20722 "[table <table-id>]") \
20723 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
20724 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
20725 _(gpe_set_encap_mode, "lisp|vxlan") \
20726 _(gpe_get_encap_mode, "") \
20727 _(lisp_gpe_add_del_iface, "up|down") \
20728 _(lisp_gpe_enable_disable, "enable|disable") \
20729 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
20730 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
20731 _(show_lisp_rloc_probe_state, "") \
20732 _(show_lisp_map_register_state, "") \
20733 _(show_lisp_status, "") \
20734 _(lisp_get_map_request_itr_rlocs, "") \
20735 _(show_lisp_pitr, "") \
20736 _(show_lisp_use_petr, "") \
20737 _(show_lisp_map_request_mode, "") \
20738 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
20739 _(af_packet_delete, "name <host interface name>") \
20740 _(af_packet_dump, "") \
20741 _(policer_add_del, "name <policer name> <params> [del]") \
20742 _(policer_dump, "[name <policer name>]") \
20743 _(policer_classify_set_interface, \
20744 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20745 " [l2-table <nn>] [del]") \
20746 _(policer_classify_dump, "type [ip4|ip6|l2]") \
20747 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
20748 _(mpls_table_dump, "") \
20749 _(mpls_route_dump, "table-id <ID>") \
20750 _(classify_table_ids, "") \
20751 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
20752 _(classify_table_info, "table_id <nn>") \
20753 _(classify_session_dump, "table_id <nn>") \
20754 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
20755 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
20756 "[template_interval <nn>] [udp_checksum]") \
20757 _(ipfix_exporter_dump, "") \
20758 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
20759 _(ipfix_classify_stream_dump, "") \
20760 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
20761 _(ipfix_classify_table_dump, "") \
20762 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
20763 _(sw_interface_span_dump, "[l2]") \
20764 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
20765 _(pg_create_interface, "if_id <nn> [gso-enabled gso-size <size>]") \
20766 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
20767 _(pg_enable_disable, "[stream <id>] disable") \
20768 _(pg_interface_enable_disable_coalesce, "<intf> | sw_if_index <nn> enable | disable") \
20769 _(ip_source_and_port_range_check_add_del, \
20770 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
20771 _(ip_source_and_port_range_check_interface_add_del, \
20772 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
20773 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
20774 _(delete_subif,"<intfc> | sw_if_index <nn>") \
20775 _(l2_interface_pbb_tag_rewrite, \
20776 "<intfc> | sw_if_index <nn> \n" \
20777 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
20778 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
20779 _(set_punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
20780 _(flow_classify_set_interface, \
20781 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
20782 _(flow_classify_dump, "type [ip4|ip6]") \
20783 _(ip_table_dump, "") \
20784 _(ip_route_dump, "table-id [ip4|ip6]") \
20785 _(ip_mtable_dump, "") \
20786 _(ip_mroute_dump, "table-id [ip4|ip6]") \
20787 _(feature_enable_disable, "arc_name <arc_name> " \
20788 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
20789 _(feature_gso_enable_disable, "<intfc> | sw_if_index <nn> " \
20790 "[enable | disable] ") \
20791 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
20793 _(sw_interface_add_del_mac_address, "<intfc> | sw_if_index <nn> " \
20794 "mac <mac-address> [del]") \
20795 _(l2_xconnect_dump, "") \
20796 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
20797 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
20798 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
20799 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
20800 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
20801 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
20802 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
20803 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
20804 _(sock_init_shm, "size <nnn>") \
20805 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
20806 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
20807 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
20808 _(session_rules_dump, "") \
20809 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
20810 _(output_acl_set_interface, \
20811 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20812 " [l2-table <nn>] [del]") \
20813 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
20815 /* List of command functions, CLI names map directly to functions */
20816 #define foreach_cli_function \
20817 _(comment, "usage: comment <ignore-rest-of-line>") \
20818 _(dump_interface_table, "usage: dump_interface_table") \
20819 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
20820 _(dump_ipv4_table, "usage: dump_ipv4_table") \
20821 _(dump_ipv6_table, "usage: dump_ipv6_table") \
20822 _(dump_macro_table, "usage: dump_macro_table ") \
20823 _(dump_node_table, "usage: dump_node_table") \
20824 _(dump_msg_api_table, "usage: dump_msg_api_table") \
20825 _(elog_setup, "usage: elog_setup [nevents, default 128K]") \
20826 _(elog_disable, "usage: elog_disable") \
20827 _(elog_enable, "usage: elog_enable") \
20828 _(elog_save, "usage: elog_save <filename>") \
20829 _(get_msg_id, "usage: get_msg_id name_and_crc") \
20830 _(echo, "usage: echo <message>") \
20831 _(exec, "usage: exec <vpe-debug-CLI-command>") \
20832 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
20833 _(help, "usage: help") \
20834 _(q, "usage: quit") \
20835 _(quit, "usage: quit") \
20836 _(search_node_table, "usage: search_node_table <name>...") \
20837 _(set, "usage: set <variable-name> <value>") \
20838 _(script, "usage: script <file-name>") \
20839 _(statseg, "usage: statseg") \
20840 _(unset, "usage: unset <variable-name>")
20843 static void vl_api_##n##_t_handler_uni \
20844 (vl_api_##n##_t * mp) \
20846 vat_main_t * vam = &vat_main; \
20847 if (vam->json_output) { \
20848 vl_api_##n##_t_handler_json(mp); \
20850 vl_api_##n##_t_handler(mp); \
20853 foreach_vpe_api_reply_msg;
20854 #if VPP_API_TEST_BUILTIN == 0
20855 foreach_standalone_reply_msg;
20860 vat_api_hookup (vat_main_t * vam)
20863 vl_msg_api_set_handlers(VL_API_##N, #n, \
20864 vl_api_##n##_t_handler_uni, \
20866 vl_api_##n##_t_endian, \
20867 vl_api_##n##_t_print, \
20868 sizeof(vl_api_##n##_t), 1);
20869 foreach_vpe_api_reply_msg;
20870 #if VPP_API_TEST_BUILTIN == 0
20871 foreach_standalone_reply_msg;
20875 #if (VPP_API_TEST_BUILTIN==0)
20876 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
20878 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
20880 vam->function_by_name = hash_create_string (0, sizeof (uword));
20882 vam->help_by_name = hash_create_string (0, sizeof (uword));
20885 /* API messages we can send */
20886 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
20887 foreach_vpe_api_msg;
20891 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
20892 foreach_vpe_api_msg;
20895 /* CLI functions */
20896 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
20897 foreach_cli_function;
20901 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
20902 foreach_cli_function;
20906 #if VPP_API_TEST_BUILTIN
20907 static clib_error_t *
20908 vat_api_hookup_shim (vlib_main_t * vm)
20910 vat_api_hookup (&vat_main);
20914 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
20918 * fd.io coding-style-patch-verification: ON
20921 * eval: (c-set-style "gnu")