2 *------------------------------------------------------------------
5 * Copyright (c) 2014-2016 Cisco and/or its affiliates.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *------------------------------------------------------------------
21 #include <vlib/pci/pci.h>
22 #include <vpp/api/types.h>
23 #include <vppinfra/socket.h>
24 #include <vlibapi/api.h>
25 #include <vlibmemory/api.h>
26 #include <vnet/ip/ip.h>
27 #include <vnet/ip-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/geneve/geneve.h>
33 #include <vnet/gre/gre.h>
34 #include <vnet/vxlan-gpe/vxlan_gpe.h>
35 #include <vnet/lisp-gpe/lisp_gpe.h>
37 #include <vpp/api/vpe_msg_enum.h>
38 #include <vnet/l2/l2_classify.h>
39 #include <vnet/l2/l2_vtr.h>
40 #include <vnet/classify/in_out_acl.h>
41 #include <vnet/classify/policer_classify.h>
42 #include <vnet/classify/flow_classify.h>
43 #include <vnet/mpls/mpls.h>
44 #include <vnet/ipsec/ipsec.h>
46 #include <vnet/cop/cop.h>
47 #include <vnet/ip/ip6_hop_by_hop.h>
48 #include <vnet/ip/ip_source_and_port_range_check.h>
49 #include <vnet/policer/xlate.h>
50 #include <vnet/span/span.h>
51 #include <vnet/policer/policer.h>
52 #include <vnet/policer/police.h>
53 #include <vnet/mfib/mfib_types.h>
54 #include <vnet/bonding/node.h>
55 #include <vnet/qos/qos_types.h>
56 #include <vnet/ethernet/ethernet_types_api.h>
57 #include <vnet/ip/ip_types_api.h>
58 #include "vat/json_format.h"
59 #include <vnet/ip/ip_types_api.h>
60 #include <vnet/ethernet/ethernet_types_api.h>
65 #define vl_typedefs /* define message structures */
66 #include <vpp/api/vpe_all_api_h.h>
69 /* declare message handlers for each api */
71 #define vl_endianfun /* define message structures */
72 #include <vpp/api/vpe_all_api_h.h>
75 /* instantiate all the print functions we know about */
76 #if VPP_API_TEST_BUILTIN == 0
77 #define vl_print(handle, ...)
79 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
82 #include <vpp/api/vpe_all_api_h.h>
85 #define __plugin_msg_base 0
86 #include <vlibapi/vat_helper_macros.h>
88 #include <vnet/format_fns.h>
90 void vl_api_set_elog_main (elog_main_t * m);
91 int vl_api_set_elog_trace_api_messages (int enable);
93 #if VPP_API_TEST_BUILTIN == 0
103 vat_socket_connect (vat_main_t * vam)
106 api_main_t *am = vlibapi_get_main ();
107 vam->socket_client_main = &socket_client_main;
108 if ((rv = vl_socket_client_connect ((char *) vam->socket_name,
110 0 /* default socket rx, tx buffer */ )))
113 /* vpp expects the client index in network order */
114 vam->my_client_index = htonl (socket_client_main.client_index);
115 am->my_client_index = vam->my_client_index;
118 #else /* vpp built-in case, we don't do sockets... */
120 vat_socket_connect (vat_main_t * vam)
126 vl_socket_client_read (int wait)
132 vl_socket_client_write ()
138 vl_socket_client_msg_alloc (int nbytes)
146 vat_time_now (vat_main_t * vam)
148 #if VPP_API_TEST_BUILTIN
149 return vlib_time_now (vam->vlib_main);
151 return clib_time_now (&vam->clib_time);
156 errmsg (char *fmt, ...)
158 vat_main_t *vam = &vat_main;
163 s = va_format (0, fmt, &va);
168 #if VPP_API_TEST_BUILTIN
169 vlib_cli_output (vam->vlib_main, (char *) s);
172 if (vam->ifp != stdin)
173 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
174 vam->input_line_number);
176 fformat (vam->ofp, "%s\n", (char *) s);
184 #if VPP_API_TEST_BUILTIN == 0
186 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
188 vat_main_t *vam = va_arg (*args, vat_main_t *);
189 u32 *result = va_arg (*args, u32 *);
193 if (!unformat (input, "%s", &if_name))
196 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
204 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
209 /* Parse an IP4 address %d.%d.%d.%d. */
211 unformat_ip4_address (unformat_input_t * input, va_list * args)
213 u8 *result = va_arg (*args, u8 *);
216 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
219 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
231 unformat_ethernet_address (unformat_input_t * input, va_list * args)
233 u8 *result = va_arg (*args, u8 *);
236 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
237 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
241 for (i = 0; i < 6; i++)
242 if (a[i] >= (1 << 8))
245 for (i = 0; i < 6; i++)
251 /* Returns ethernet type as an int in host byte order. */
253 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
256 u16 *result = va_arg (*args, u16 *);
260 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
262 if (type >= (1 << 16))
270 /* Parse an IP46 address. */
272 unformat_ip46_address (unformat_input_t * input, va_list * args)
274 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
275 ip46_type_t type = va_arg (*args, ip46_type_t);
276 if ((type != IP46_TYPE_IP6) &&
277 unformat (input, "%U", unformat_ip4_address, &ip46->ip4))
279 ip46_address_mask_ip4 (ip46);
282 else if ((type != IP46_TYPE_IP4) &&
283 unformat (input, "%U", unformat_ip6_address, &ip46->ip6))
290 /* Parse an IP6 address. */
292 unformat_ip6_address (unformat_input_t * input, va_list * args)
294 ip6_address_t *result = va_arg (*args, ip6_address_t *);
296 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
297 uword c, n_colon, double_colon_index;
299 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
300 double_colon_index = ARRAY_LEN (hex_quads);
301 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
304 if (c >= '0' && c <= '9')
306 else if (c >= 'a' && c <= 'f')
307 hex_digit = c + 10 - 'a';
308 else if (c >= 'A' && c <= 'F')
309 hex_digit = c + 10 - 'A';
310 else if (c == ':' && n_colon < 2)
314 unformat_put_input (input);
318 /* Too many hex quads. */
319 if (n_hex_quads >= ARRAY_LEN (hex_quads))
324 hex_quad = (hex_quad << 4) | hex_digit;
326 /* Hex quad must fit in 16 bits. */
327 if (n_hex_digits >= 4)
334 /* Save position of :: */
337 /* More than one :: ? */
338 if (double_colon_index < ARRAY_LEN (hex_quads))
340 double_colon_index = n_hex_quads;
343 if (n_colon > 0 && n_hex_digits > 0)
345 hex_quads[n_hex_quads++] = hex_quad;
351 if (n_hex_digits > 0)
352 hex_quads[n_hex_quads++] = hex_quad;
357 /* Expand :: to appropriate number of zero hex quads. */
358 if (double_colon_index < ARRAY_LEN (hex_quads))
360 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
362 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
363 hex_quads[n_zero + i] = hex_quads[i];
365 for (i = 0; i < n_zero; i++)
366 hex_quads[double_colon_index + i] = 0;
368 n_hex_quads = ARRAY_LEN (hex_quads);
371 /* Too few hex quads given. */
372 if (n_hex_quads < ARRAY_LEN (hex_quads))
375 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
376 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
383 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
385 u32 *r = va_arg (*args, u32 *);
388 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
389 foreach_ipsec_policy_action
397 format_ipsec_crypto_alg (u8 * s, va_list * args)
399 u32 i = va_arg (*args, u32);
404 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
405 foreach_ipsec_crypto_alg
408 return format (s, "unknown");
410 return format (s, "%s", t);
414 format_ipsec_integ_alg (u8 * s, va_list * args)
416 u32 i = va_arg (*args, u32);
421 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
422 foreach_ipsec_integ_alg
425 return format (s, "unknown");
427 return format (s, "%s", t);
430 #else /* VPP_API_TEST_BUILTIN == 1 */
432 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
434 vat_main_t *vam __clib_unused = va_arg (*args, vat_main_t *);
435 vnet_main_t *vnm = vnet_get_main ();
436 u32 *result = va_arg (*args, u32 *);
438 return unformat (input, "%U", unformat_vnet_sw_interface, vnm, result);
442 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
444 vat_main_t *vam __clib_unused = va_arg (*args, vat_main_t *);
445 vnet_main_t *vnm = vnet_get_main ();
446 u32 *result = va_arg (*args, u32 *);
448 return unformat (input, "%U", unformat_vnet_hw_interface, vnm, result);
451 #endif /* VPP_API_TEST_BUILTIN */
454 unformat_ipsec_api_crypto_alg (unformat_input_t * input, va_list * args)
456 u32 *r = va_arg (*args, u32 *);
459 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_API_CRYPTO_ALG_##f;
460 foreach_ipsec_crypto_alg
468 unformat_ipsec_api_integ_alg (unformat_input_t * input, va_list * args)
470 u32 *r = va_arg (*args, u32 *);
473 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_API_INTEG_ALG_##f;
474 foreach_ipsec_integ_alg
482 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
484 u8 *r = va_arg (*args, u8 *);
486 if (unformat (input, "kbps"))
487 *r = SSE2_QOS_RATE_KBPS;
488 else if (unformat (input, "pps"))
489 *r = SSE2_QOS_RATE_PPS;
496 unformat_policer_round_type (unformat_input_t * input, va_list * args)
498 u8 *r = va_arg (*args, u8 *);
500 if (unformat (input, "closest"))
501 *r = SSE2_QOS_ROUND_TO_CLOSEST;
502 else if (unformat (input, "up"))
503 *r = SSE2_QOS_ROUND_TO_UP;
504 else if (unformat (input, "down"))
505 *r = SSE2_QOS_ROUND_TO_DOWN;
512 unformat_policer_type (unformat_input_t * input, va_list * args)
514 u8 *r = va_arg (*args, u8 *);
516 if (unformat (input, "1r2c"))
517 *r = SSE2_QOS_POLICER_TYPE_1R2C;
518 else if (unformat (input, "1r3c"))
519 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
520 else if (unformat (input, "2r3c-2698"))
521 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
522 else if (unformat (input, "2r3c-4115"))
523 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
524 else if (unformat (input, "2r3c-mef5cf1"))
525 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
532 unformat_dscp (unformat_input_t * input, va_list * va)
534 u8 *r = va_arg (*va, u8 *);
537 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
546 unformat_policer_action_type (unformat_input_t * input, va_list * va)
548 sse2_qos_pol_action_params_st *a
549 = va_arg (*va, sse2_qos_pol_action_params_st *);
551 if (unformat (input, "drop"))
552 a->action_type = SSE2_QOS_ACTION_DROP;
553 else if (unformat (input, "transmit"))
554 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
555 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
556 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
563 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
565 u32 *r = va_arg (*va, u32 *);
568 if (unformat (input, "ip4"))
569 tid = POLICER_CLASSIFY_TABLE_IP4;
570 else if (unformat (input, "ip6"))
571 tid = POLICER_CLASSIFY_TABLE_IP6;
572 else if (unformat (input, "l2"))
573 tid = POLICER_CLASSIFY_TABLE_L2;
582 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
584 u32 *r = va_arg (*va, u32 *);
587 if (unformat (input, "ip4"))
588 tid = FLOW_CLASSIFY_TABLE_IP4;
589 else if (unformat (input, "ip6"))
590 tid = FLOW_CLASSIFY_TABLE_IP6;
598 #if (VPP_API_TEST_BUILTIN==0)
600 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
601 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
602 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
603 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
606 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
608 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
609 mfib_itf_attribute_t attr;
612 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
614 if (unformat (input, mfib_itf_flag_long_names[attr]))
615 *iflags |= (1 << attr);
617 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
619 if (unformat (input, mfib_itf_flag_names[attr]))
620 *iflags |= (1 << attr);
623 return (old == *iflags ? 0 : 1);
627 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
629 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
630 mfib_entry_attribute_t attr;
633 FOR_EACH_MFIB_ATTRIBUTE (attr)
635 if (unformat (input, mfib_flag_long_names[attr]))
636 *eflags |= (1 << attr);
638 FOR_EACH_MFIB_ATTRIBUTE (attr)
640 if (unformat (input, mfib_flag_names[attr]))
641 *eflags |= (1 << attr);
644 return (old == *eflags ? 0 : 1);
648 format_ip4_address (u8 * s, va_list * args)
650 u8 *a = va_arg (*args, u8 *);
651 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
655 format_ip6_address (u8 * s, va_list * args)
657 ip6_address_t *a = va_arg (*args, ip6_address_t *);
658 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
660 i_max_n_zero = ARRAY_LEN (a->as_u16);
662 i_first_zero = i_max_n_zero;
664 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
666 u32 is_zero = a->as_u16[i] == 0;
667 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
673 if ((!is_zero && n_zeros > max_n_zeros)
674 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
676 i_max_n_zero = i_first_zero;
677 max_n_zeros = n_zeros;
678 i_first_zero = ARRAY_LEN (a->as_u16);
683 last_double_colon = 0;
684 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
686 if (i == i_max_n_zero && max_n_zeros > 1)
688 s = format (s, "::");
689 i += max_n_zeros - 1;
690 last_double_colon = 1;
694 s = format (s, "%s%x",
695 (last_double_colon || i == 0) ? "" : ":",
696 clib_net_to_host_u16 (a->as_u16[i]));
697 last_double_colon = 0;
704 /* Format an IP46 address. */
706 format_ip46_address (u8 * s, va_list * args)
708 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
709 ip46_type_t type = va_arg (*args, ip46_type_t);
715 is_ip4 = ip46_address_is_ip4 (ip46);
726 format (s, "%U", format_ip4_address, &ip46->ip4) :
727 format (s, "%U", format_ip6_address, &ip46->ip6);
731 format_ethernet_address (u8 * s, va_list * args)
733 u8 *a = va_arg (*args, u8 *);
735 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
736 a[0], a[1], a[2], a[3], a[4], a[5]);
741 increment_v4_address (vl_api_ip4_address_t * i)
743 ip4_address_t *a = (ip4_address_t *) i;
746 v = ntohl (a->as_u32) + 1;
747 a->as_u32 = ntohl (v);
751 increment_v6_address (vl_api_ip6_address_t * i)
753 ip6_address_t *a = (ip6_address_t *) i;
756 v0 = clib_net_to_host_u64 (a->as_u64[0]);
757 v1 = clib_net_to_host_u64 (a->as_u64[1]);
762 a->as_u64[0] = clib_net_to_host_u64 (v0);
763 a->as_u64[1] = clib_net_to_host_u64 (v1);
767 increment_address (vl_api_address_t * a)
769 if (a->af == ADDRESS_IP4)
770 increment_v4_address (&a->un.ip4);
771 else if (a->af == ADDRESS_IP6)
772 increment_v6_address (&a->un.ip6);
776 set_ip4_address (vl_api_address_t * a, u32 v)
778 if (a->af == ADDRESS_IP4)
780 ip4_address_t *i = (ip4_address_t *) & a->un.ip4;
786 ip_set (ip46_address_t * dst, void *src, u8 is_ip4)
789 dst->ip4.as_u32 = ((ip4_address_t *) src)->as_u32;
791 clib_memcpy_fast (&dst->ip6, (ip6_address_t *) src,
792 sizeof (ip6_address_t));
796 increment_mac_address (u8 * mac)
798 u64 tmp = *((u64 *) mac);
799 tmp = clib_net_to_host_u64 (tmp);
800 tmp += 1 << 16; /* skip unused (least significant) octets */
801 tmp = clib_host_to_net_u64 (tmp);
803 clib_memcpy (mac, &tmp, 6);
807 vat_json_object_add_address (vat_json_node_t * node,
808 const char *str, const vl_api_address_t * addr)
810 if (ADDRESS_IP6 == addr->af)
814 clib_memcpy (&ip6, &addr->un.ip6, sizeof (ip6));
815 vat_json_object_add_ip6 (node, str, ip6);
821 clib_memcpy (&ip4, &addr->un.ip4, sizeof (ip4));
822 vat_json_object_add_ip4 (node, str, ip4);
827 vat_json_object_add_prefix (vat_json_node_t * node,
828 const vl_api_prefix_t * prefix)
830 vat_json_object_add_uint (node, "len", prefix->len);
831 vat_json_object_add_address (node, "address", &prefix->address);
834 static void vl_api_create_loopback_reply_t_handler
835 (vl_api_create_loopback_reply_t * mp)
837 vat_main_t *vam = &vat_main;
838 i32 retval = ntohl (mp->retval);
840 vam->retval = retval;
841 vam->regenerate_interface_table = 1;
842 vam->sw_if_index = ntohl (mp->sw_if_index);
843 vam->result_ready = 1;
846 static void vl_api_create_loopback_reply_t_handler_json
847 (vl_api_create_loopback_reply_t * mp)
849 vat_main_t *vam = &vat_main;
850 vat_json_node_t node;
852 vat_json_init_object (&node);
853 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
854 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
856 vat_json_print (vam->ofp, &node);
857 vat_json_free (&node);
858 vam->retval = ntohl (mp->retval);
859 vam->result_ready = 1;
862 static void vl_api_create_loopback_instance_reply_t_handler
863 (vl_api_create_loopback_instance_reply_t * mp)
865 vat_main_t *vam = &vat_main;
866 i32 retval = ntohl (mp->retval);
868 vam->retval = retval;
869 vam->regenerate_interface_table = 1;
870 vam->sw_if_index = ntohl (mp->sw_if_index);
871 vam->result_ready = 1;
874 static void vl_api_create_loopback_instance_reply_t_handler_json
875 (vl_api_create_loopback_instance_reply_t * mp)
877 vat_main_t *vam = &vat_main;
878 vat_json_node_t node;
880 vat_json_init_object (&node);
881 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
882 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
884 vat_json_print (vam->ofp, &node);
885 vat_json_free (&node);
886 vam->retval = ntohl (mp->retval);
887 vam->result_ready = 1;
890 static void vl_api_af_packet_create_reply_t_handler
891 (vl_api_af_packet_create_reply_t * mp)
893 vat_main_t *vam = &vat_main;
894 i32 retval = ntohl (mp->retval);
896 vam->retval = retval;
897 vam->regenerate_interface_table = 1;
898 vam->sw_if_index = ntohl (mp->sw_if_index);
899 vam->result_ready = 1;
902 static void vl_api_af_packet_create_reply_t_handler_json
903 (vl_api_af_packet_create_reply_t * mp)
905 vat_main_t *vam = &vat_main;
906 vat_json_node_t node;
908 vat_json_init_object (&node);
909 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
910 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
912 vat_json_print (vam->ofp, &node);
913 vat_json_free (&node);
915 vam->retval = ntohl (mp->retval);
916 vam->result_ready = 1;
919 static void vl_api_create_vlan_subif_reply_t_handler
920 (vl_api_create_vlan_subif_reply_t * mp)
922 vat_main_t *vam = &vat_main;
923 i32 retval = ntohl (mp->retval);
925 vam->retval = retval;
926 vam->regenerate_interface_table = 1;
927 vam->sw_if_index = ntohl (mp->sw_if_index);
928 vam->result_ready = 1;
931 static void vl_api_create_vlan_subif_reply_t_handler_json
932 (vl_api_create_vlan_subif_reply_t * mp)
934 vat_main_t *vam = &vat_main;
935 vat_json_node_t node;
937 vat_json_init_object (&node);
938 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
939 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
941 vat_json_print (vam->ofp, &node);
942 vat_json_free (&node);
944 vam->retval = ntohl (mp->retval);
945 vam->result_ready = 1;
948 static void vl_api_create_subif_reply_t_handler
949 (vl_api_create_subif_reply_t * mp)
951 vat_main_t *vam = &vat_main;
952 i32 retval = ntohl (mp->retval);
954 vam->retval = retval;
955 vam->regenerate_interface_table = 1;
956 vam->sw_if_index = ntohl (mp->sw_if_index);
957 vam->result_ready = 1;
960 static void vl_api_create_subif_reply_t_handler_json
961 (vl_api_create_subif_reply_t * mp)
963 vat_main_t *vam = &vat_main;
964 vat_json_node_t node;
966 vat_json_init_object (&node);
967 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
968 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
970 vat_json_print (vam->ofp, &node);
971 vat_json_free (&node);
973 vam->retval = ntohl (mp->retval);
974 vam->result_ready = 1;
977 static void vl_api_interface_name_renumber_reply_t_handler
978 (vl_api_interface_name_renumber_reply_t * mp)
980 vat_main_t *vam = &vat_main;
981 i32 retval = ntohl (mp->retval);
983 vam->retval = retval;
984 vam->regenerate_interface_table = 1;
985 vam->result_ready = 1;
988 static void vl_api_interface_name_renumber_reply_t_handler_json
989 (vl_api_interface_name_renumber_reply_t * mp)
991 vat_main_t *vam = &vat_main;
992 vat_json_node_t node;
994 vat_json_init_object (&node);
995 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
997 vat_json_print (vam->ofp, &node);
998 vat_json_free (&node);
1000 vam->retval = ntohl (mp->retval);
1001 vam->result_ready = 1;
1005 * Special-case: build the interface table, maintain
1006 * the next loopback sw_if_index vbl.
1008 static void vl_api_sw_interface_details_t_handler
1009 (vl_api_sw_interface_details_t * mp)
1011 vat_main_t *vam = &vat_main;
1012 u8 *s = format (0, "%s%c", mp->interface_name, 0);
1014 hash_set_mem (vam->sw_if_index_by_interface_name, s,
1015 ntohl (mp->sw_if_index));
1017 /* In sub interface case, fill the sub interface table entry */
1018 if (mp->sw_if_index != mp->sup_sw_if_index)
1020 sw_interface_subif_t *sub = NULL;
1022 vec_add2 (vam->sw_if_subif_table, sub, 1);
1024 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
1025 strncpy ((char *) sub->interface_name, (char *) s,
1026 vec_len (sub->interface_name));
1027 sub->sw_if_index = ntohl (mp->sw_if_index);
1028 sub->sub_id = ntohl (mp->sub_id);
1030 sub->raw_flags = ntohl (mp->sub_if_flags & SUB_IF_API_FLAG_MASK_VNET);
1032 sub->sub_number_of_tags = mp->sub_number_of_tags;
1033 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
1034 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
1036 /* vlan tag rewrite */
1037 sub->vtr_op = ntohl (mp->vtr_op);
1038 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
1039 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
1040 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
1044 static void vl_api_sw_interface_details_t_handler_json
1045 (vl_api_sw_interface_details_t * mp)
1047 vat_main_t *vam = &vat_main;
1048 vat_json_node_t *node = NULL;
1050 if (VAT_JSON_ARRAY != vam->json_tree.type)
1052 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1053 vat_json_init_array (&vam->json_tree);
1055 node = vat_json_array_add (&vam->json_tree);
1057 vat_json_init_object (node);
1058 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1059 vat_json_object_add_uint (node, "sup_sw_if_index",
1060 ntohl (mp->sup_sw_if_index));
1061 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
1062 sizeof (mp->l2_address));
1063 vat_json_object_add_string_copy (node, "interface_name",
1064 mp->interface_name);
1065 vat_json_object_add_string_copy (node, "interface_dev_type",
1066 mp->interface_dev_type);
1067 vat_json_object_add_uint (node, "flags", mp->flags);
1068 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
1069 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
1070 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
1071 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
1072 vat_json_object_add_uint (node, "sub_number_of_tags",
1073 mp->sub_number_of_tags);
1074 vat_json_object_add_uint (node, "sub_outer_vlan_id",
1075 ntohs (mp->sub_outer_vlan_id));
1076 vat_json_object_add_uint (node, "sub_inner_vlan_id",
1077 ntohs (mp->sub_inner_vlan_id));
1078 vat_json_object_add_uint (node, "sub_if_flags", ntohl (mp->sub_if_flags));
1079 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
1080 vat_json_object_add_uint (node, "vtr_push_dot1q",
1081 ntohl (mp->vtr_push_dot1q));
1082 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
1083 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
1084 if (ntohl (mp->sub_if_flags) & SUB_IF_API_FLAG_DOT1AH)
1086 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
1088 format_ethernet_address,
1090 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
1092 format_ethernet_address,
1094 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
1095 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
1099 #if VPP_API_TEST_BUILTIN == 0
1100 static void vl_api_sw_interface_event_t_handler
1101 (vl_api_sw_interface_event_t * mp)
1103 vat_main_t *vam = &vat_main;
1104 if (vam->interface_event_display)
1105 errmsg ("interface flags: sw_if_index %d %s %s",
1106 ntohl (mp->sw_if_index),
1107 ((ntohl (mp->flags)) & IF_STATUS_API_FLAG_ADMIN_UP) ?
1108 "admin-up" : "admin-down",
1109 ((ntohl (mp->flags)) & IF_STATUS_API_FLAG_LINK_UP) ?
1110 "link-up" : "link-down");
1114 __clib_unused static void
1115 vl_api_sw_interface_event_t_handler_json (vl_api_sw_interface_event_t * mp)
1117 /* JSON output not supported */
1121 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
1123 vat_main_t *vam = &vat_main;
1124 i32 retval = ntohl (mp->retval);
1126 vam->retval = retval;
1127 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1128 vam->result_ready = 1;
1132 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1134 vat_main_t *vam = &vat_main;
1135 vat_json_node_t node;
1139 vat_json_init_object (&node);
1140 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1141 vat_json_object_add_uint (&node, "reply_in_shmem",
1142 ntohl (mp->reply_in_shmem));
1143 /* Toss the shared-memory original... */
1144 oldheap = vl_msg_push_heap ();
1146 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1149 vl_msg_pop_heap (oldheap);
1151 vat_json_print (vam->ofp, &node);
1152 vat_json_free (&node);
1154 vam->retval = ntohl (mp->retval);
1155 vam->result_ready = 1;
1159 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1161 vat_main_t *vam = &vat_main;
1162 i32 retval = ntohl (mp->retval);
1164 vec_reset_length (vam->cmd_reply);
1166 vam->retval = retval;
1168 vam->cmd_reply = vl_api_from_api_to_new_vec (&mp->reply);
1169 vam->result_ready = 1;
1173 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1175 vat_main_t *vam = &vat_main;
1176 vat_json_node_t node;
1177 u8 *reply = 0; /* reply vector */
1179 reply = vl_api_from_api_to_new_vec (&mp->reply);
1180 vec_reset_length (vam->cmd_reply);
1182 vat_json_init_object (&node);
1183 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1184 vat_json_object_add_string_copy (&node, "reply", reply);
1186 vat_json_print (vam->ofp, &node);
1187 vat_json_free (&node);
1190 vam->retval = ntohl (mp->retval);
1191 vam->result_ready = 1;
1194 static void vl_api_classify_add_del_table_reply_t_handler
1195 (vl_api_classify_add_del_table_reply_t * mp)
1197 vat_main_t *vam = &vat_main;
1198 i32 retval = ntohl (mp->retval);
1199 if (vam->async_mode)
1201 vam->async_errors += (retval < 0);
1205 vam->retval = retval;
1207 ((mp->new_table_index != 0xFFFFFFFF) ||
1208 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1209 (mp->match_n_vectors != 0xFFFFFFFF)))
1211 * Note: this is just barely thread-safe, depends on
1212 * the main thread spinning waiting for an answer...
1214 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1215 ntohl (mp->new_table_index),
1216 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1217 vam->result_ready = 1;
1221 static void vl_api_classify_add_del_table_reply_t_handler_json
1222 (vl_api_classify_add_del_table_reply_t * mp)
1224 vat_main_t *vam = &vat_main;
1225 vat_json_node_t node;
1227 vat_json_init_object (&node);
1228 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1229 vat_json_object_add_uint (&node, "new_table_index",
1230 ntohl (mp->new_table_index));
1231 vat_json_object_add_uint (&node, "skip_n_vectors",
1232 ntohl (mp->skip_n_vectors));
1233 vat_json_object_add_uint (&node, "match_n_vectors",
1234 ntohl (mp->match_n_vectors));
1236 vat_json_print (vam->ofp, &node);
1237 vat_json_free (&node);
1239 vam->retval = ntohl (mp->retval);
1240 vam->result_ready = 1;
1243 static void vl_api_get_node_index_reply_t_handler
1244 (vl_api_get_node_index_reply_t * mp)
1246 vat_main_t *vam = &vat_main;
1247 i32 retval = ntohl (mp->retval);
1248 if (vam->async_mode)
1250 vam->async_errors += (retval < 0);
1254 vam->retval = retval;
1256 errmsg ("node index %d", ntohl (mp->node_index));
1257 vam->result_ready = 1;
1261 static void vl_api_get_node_index_reply_t_handler_json
1262 (vl_api_get_node_index_reply_t * mp)
1264 vat_main_t *vam = &vat_main;
1265 vat_json_node_t node;
1267 vat_json_init_object (&node);
1268 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1269 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1271 vat_json_print (vam->ofp, &node);
1272 vat_json_free (&node);
1274 vam->retval = ntohl (mp->retval);
1275 vam->result_ready = 1;
1278 static void vl_api_get_next_index_reply_t_handler
1279 (vl_api_get_next_index_reply_t * mp)
1281 vat_main_t *vam = &vat_main;
1282 i32 retval = ntohl (mp->retval);
1283 if (vam->async_mode)
1285 vam->async_errors += (retval < 0);
1289 vam->retval = retval;
1291 errmsg ("next node index %d", ntohl (mp->next_index));
1292 vam->result_ready = 1;
1296 static void vl_api_get_next_index_reply_t_handler_json
1297 (vl_api_get_next_index_reply_t * mp)
1299 vat_main_t *vam = &vat_main;
1300 vat_json_node_t node;
1302 vat_json_init_object (&node);
1303 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1304 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1306 vat_json_print (vam->ofp, &node);
1307 vat_json_free (&node);
1309 vam->retval = ntohl (mp->retval);
1310 vam->result_ready = 1;
1313 static void vl_api_add_node_next_reply_t_handler
1314 (vl_api_add_node_next_reply_t * mp)
1316 vat_main_t *vam = &vat_main;
1317 i32 retval = ntohl (mp->retval);
1318 if (vam->async_mode)
1320 vam->async_errors += (retval < 0);
1324 vam->retval = retval;
1326 errmsg ("next index %d", ntohl (mp->next_index));
1327 vam->result_ready = 1;
1331 static void vl_api_add_node_next_reply_t_handler_json
1332 (vl_api_add_node_next_reply_t * mp)
1334 vat_main_t *vam = &vat_main;
1335 vat_json_node_t node;
1337 vat_json_init_object (&node);
1338 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1339 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1341 vat_json_print (vam->ofp, &node);
1342 vat_json_free (&node);
1344 vam->retval = ntohl (mp->retval);
1345 vam->result_ready = 1;
1348 static void vl_api_show_version_reply_t_handler
1349 (vl_api_show_version_reply_t * mp)
1351 vat_main_t *vam = &vat_main;
1352 i32 retval = ntohl (mp->retval);
1356 errmsg (" program: %s", mp->program);
1357 errmsg (" version: %s", mp->version);
1358 errmsg (" build date: %s", mp->build_date);
1359 errmsg ("build directory: %s", mp->build_directory);
1361 vam->retval = retval;
1362 vam->result_ready = 1;
1365 static void vl_api_show_version_reply_t_handler_json
1366 (vl_api_show_version_reply_t * mp)
1368 vat_main_t *vam = &vat_main;
1369 vat_json_node_t node;
1371 vat_json_init_object (&node);
1372 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1373 vat_json_object_add_string_copy (&node, "program", mp->program);
1374 vat_json_object_add_string_copy (&node, "version", mp->version);
1375 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1376 vat_json_object_add_string_copy (&node, "build_directory",
1377 mp->build_directory);
1379 vat_json_print (vam->ofp, &node);
1380 vat_json_free (&node);
1382 vam->retval = ntohl (mp->retval);
1383 vam->result_ready = 1;
1386 static void vl_api_show_threads_reply_t_handler
1387 (vl_api_show_threads_reply_t * mp)
1389 vat_main_t *vam = &vat_main;
1390 i32 retval = ntohl (mp->retval);
1394 count = ntohl (mp->count);
1396 for (i = 0; i < count; i++)
1398 "\n%-2d %-11s %-11s %-5d %-6d %-4d %-6d",
1399 ntohl (mp->thread_data[i].id), mp->thread_data[i].name,
1400 mp->thread_data[i].type, ntohl (mp->thread_data[i].pid),
1401 ntohl (mp->thread_data[i].cpu_id), ntohl (mp->thread_data[i].core),
1402 ntohl (mp->thread_data[i].cpu_socket));
1404 vam->retval = retval;
1405 vam->result_ready = 1;
1408 static void vl_api_show_threads_reply_t_handler_json
1409 (vl_api_show_threads_reply_t * mp)
1411 vat_main_t *vam = &vat_main;
1412 vat_json_node_t node;
1413 vl_api_thread_data_t *td;
1414 i32 retval = ntohl (mp->retval);
1418 count = ntohl (mp->count);
1420 vat_json_init_object (&node);
1421 vat_json_object_add_int (&node, "retval", retval);
1422 vat_json_object_add_uint (&node, "count", count);
1424 for (i = 0; i < count; i++)
1426 td = &mp->thread_data[i];
1427 vat_json_object_add_uint (&node, "id", ntohl (td->id));
1428 vat_json_object_add_string_copy (&node, "name", td->name);
1429 vat_json_object_add_string_copy (&node, "type", td->type);
1430 vat_json_object_add_uint (&node, "pid", ntohl (td->pid));
1431 vat_json_object_add_int (&node, "cpu_id", ntohl (td->cpu_id));
1432 vat_json_object_add_int (&node, "core", ntohl (td->id));
1433 vat_json_object_add_int (&node, "cpu_socket", ntohl (td->cpu_socket));
1436 vat_json_print (vam->ofp, &node);
1437 vat_json_free (&node);
1439 vam->retval = retval;
1440 vam->result_ready = 1;
1444 api_show_threads (vat_main_t * vam)
1446 vl_api_show_threads_t *mp;
1450 "\n%-2s %-11s %-11s %-5s %-6s %-4s %-6s",
1451 "ID", "Name", "Type", "LWP", "cpu_id", "Core", "Socket");
1453 M (SHOW_THREADS, mp);
1461 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1463 u32 n_macs = ntohl (mp->n_macs);
1464 errmsg ("L2MAC event received with pid %d cl-idx %d for %d macs: \n",
1465 ntohl (mp->pid), mp->client_index, n_macs);
1467 for (i = 0; i < n_macs; i++)
1469 vl_api_mac_entry_t *mac = &mp->mac[i];
1470 errmsg (" [%d] sw_if_index %d mac_addr %U action %d \n",
1471 i + 1, ntohl (mac->sw_if_index),
1472 format_ethernet_address, mac->mac_addr, mac->action);
1479 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1481 /* JSON output not supported */
1484 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1485 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1488 * Special-case: build the bridge domain table, maintain
1489 * the next bd id vbl.
1491 static void vl_api_bridge_domain_details_t_handler
1492 (vl_api_bridge_domain_details_t * mp)
1494 vat_main_t *vam = &vat_main;
1495 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1498 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-6s %-3s",
1499 " ID", "LRN", "FWD", "FLD", "BVI", "UU-FWD", "#IF");
1501 print (vam->ofp, "%3d %3d %3d %3d %3d %6d %3d",
1502 ntohl (mp->bd_id), mp->learn, mp->forward,
1503 mp->flood, ntohl (mp->bvi_sw_if_index),
1504 ntohl (mp->uu_fwd_sw_if_index), n_sw_ifs);
1508 vl_api_bridge_domain_sw_if_t *sw_ifs;
1509 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1512 sw_ifs = mp->sw_if_details;
1513 for (i = 0; i < n_sw_ifs; i++)
1519 sw_if_index = ntohl (sw_ifs->sw_if_index);
1522 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1524 if ((u32) p->value[0] == sw_if_index)
1526 sw_if_name = (u8 *)(p->key);
1531 print (vam->ofp, "%7d %3d %s", sw_if_index,
1532 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1533 "sw_if_index not found!");
1540 static void vl_api_bridge_domain_details_t_handler_json
1541 (vl_api_bridge_domain_details_t * mp)
1543 vat_main_t *vam = &vat_main;
1544 vat_json_node_t *node, *array = NULL;
1545 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1547 if (VAT_JSON_ARRAY != vam->json_tree.type)
1549 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1550 vat_json_init_array (&vam->json_tree);
1552 node = vat_json_array_add (&vam->json_tree);
1554 vat_json_init_object (node);
1555 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1556 vat_json_object_add_uint (node, "flood", mp->flood);
1557 vat_json_object_add_uint (node, "forward", mp->forward);
1558 vat_json_object_add_uint (node, "learn", mp->learn);
1559 vat_json_object_add_uint (node, "bvi_sw_if_index",
1560 ntohl (mp->bvi_sw_if_index));
1561 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1562 array = vat_json_object_add (node, "sw_if");
1563 vat_json_init_array (array);
1569 vl_api_bridge_domain_sw_if_t *sw_ifs;
1572 sw_ifs = mp->sw_if_details;
1573 for (i = 0; i < n_sw_ifs; i++)
1575 node = vat_json_array_add (array);
1576 vat_json_init_object (node);
1577 vat_json_object_add_uint (node, "sw_if_index",
1578 ntohl (sw_ifs->sw_if_index));
1579 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1585 static void vl_api_control_ping_reply_t_handler
1586 (vl_api_control_ping_reply_t * mp)
1588 vat_main_t *vam = &vat_main;
1589 i32 retval = ntohl (mp->retval);
1590 if (vam->async_mode)
1592 vam->async_errors += (retval < 0);
1596 vam->retval = retval;
1597 vam->result_ready = 1;
1599 if (vam->socket_client_main)
1600 vam->socket_client_main->control_pings_outstanding--;
1603 static void vl_api_control_ping_reply_t_handler_json
1604 (vl_api_control_ping_reply_t * mp)
1606 vat_main_t *vam = &vat_main;
1607 i32 retval = ntohl (mp->retval);
1609 if (VAT_JSON_NONE != vam->json_tree.type)
1611 vat_json_print (vam->ofp, &vam->json_tree);
1612 vat_json_free (&vam->json_tree);
1613 vam->json_tree.type = VAT_JSON_NONE;
1618 vat_json_init_array (&vam->json_tree);
1619 vat_json_print (vam->ofp, &vam->json_tree);
1620 vam->json_tree.type = VAT_JSON_NONE;
1623 vam->retval = retval;
1624 vam->result_ready = 1;
1628 vl_api_bridge_domain_set_mac_age_reply_t_handler
1629 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1631 vat_main_t *vam = &vat_main;
1632 i32 retval = ntohl (mp->retval);
1633 if (vam->async_mode)
1635 vam->async_errors += (retval < 0);
1639 vam->retval = retval;
1640 vam->result_ready = 1;
1644 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1645 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1647 vat_main_t *vam = &vat_main;
1648 vat_json_node_t node;
1650 vat_json_init_object (&node);
1651 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1653 vat_json_print (vam->ofp, &node);
1654 vat_json_free (&node);
1656 vam->retval = ntohl (mp->retval);
1657 vam->result_ready = 1;
1661 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1663 vat_main_t *vam = &vat_main;
1664 i32 retval = ntohl (mp->retval);
1665 if (vam->async_mode)
1667 vam->async_errors += (retval < 0);
1671 vam->retval = retval;
1672 vam->result_ready = 1;
1676 static void vl_api_l2_flags_reply_t_handler_json
1677 (vl_api_l2_flags_reply_t * mp)
1679 vat_main_t *vam = &vat_main;
1680 vat_json_node_t node;
1682 vat_json_init_object (&node);
1683 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1684 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1685 ntohl (mp->resulting_feature_bitmap));
1687 vat_json_print (vam->ofp, &node);
1688 vat_json_free (&node);
1690 vam->retval = ntohl (mp->retval);
1691 vam->result_ready = 1;
1694 static void vl_api_bridge_flags_reply_t_handler
1695 (vl_api_bridge_flags_reply_t * mp)
1697 vat_main_t *vam = &vat_main;
1698 i32 retval = ntohl (mp->retval);
1699 if (vam->async_mode)
1701 vam->async_errors += (retval < 0);
1705 vam->retval = retval;
1706 vam->result_ready = 1;
1710 static void vl_api_bridge_flags_reply_t_handler_json
1711 (vl_api_bridge_flags_reply_t * mp)
1713 vat_main_t *vam = &vat_main;
1714 vat_json_node_t node;
1716 vat_json_init_object (&node);
1717 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1718 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1719 ntohl (mp->resulting_feature_bitmap));
1721 vat_json_print (vam->ofp, &node);
1722 vat_json_free (&node);
1724 vam->retval = ntohl (mp->retval);
1725 vam->result_ready = 1;
1729 vl_api_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_reply_t * mp)
1731 vat_main_t *vam = &vat_main;
1732 i32 retval = ntohl (mp->retval);
1733 if (vam->async_mode)
1735 vam->async_errors += (retval < 0);
1739 vam->retval = retval;
1740 vam->sw_if_index = ntohl (mp->sw_if_index);
1741 vam->result_ready = 1;
1746 static void vl_api_tap_create_v2_reply_t_handler_json
1747 (vl_api_tap_create_v2_reply_t * mp)
1749 vat_main_t *vam = &vat_main;
1750 vat_json_node_t node;
1752 vat_json_init_object (&node);
1753 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1754 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1756 vat_json_print (vam->ofp, &node);
1757 vat_json_free (&node);
1759 vam->retval = ntohl (mp->retval);
1760 vam->result_ready = 1;
1765 vl_api_tap_delete_v2_reply_t_handler (vl_api_tap_delete_v2_reply_t * mp)
1767 vat_main_t *vam = &vat_main;
1768 i32 retval = ntohl (mp->retval);
1769 if (vam->async_mode)
1771 vam->async_errors += (retval < 0);
1775 vam->retval = retval;
1776 vam->result_ready = 1;
1780 static void vl_api_tap_delete_v2_reply_t_handler_json
1781 (vl_api_tap_delete_v2_reply_t * mp)
1783 vat_main_t *vam = &vat_main;
1784 vat_json_node_t node;
1786 vat_json_init_object (&node);
1787 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1789 vat_json_print (vam->ofp, &node);
1790 vat_json_free (&node);
1792 vam->retval = ntohl (mp->retval);
1793 vam->result_ready = 1;
1797 vl_api_virtio_pci_create_reply_t_handler (vl_api_virtio_pci_create_reply_t *
1800 vat_main_t *vam = &vat_main;
1801 i32 retval = ntohl (mp->retval);
1802 if (vam->async_mode)
1804 vam->async_errors += (retval < 0);
1808 vam->retval = retval;
1809 vam->sw_if_index = ntohl (mp->sw_if_index);
1810 vam->result_ready = 1;
1814 static void vl_api_virtio_pci_create_reply_t_handler_json
1815 (vl_api_virtio_pci_create_reply_t * mp)
1817 vat_main_t *vam = &vat_main;
1818 vat_json_node_t node;
1820 vat_json_init_object (&node);
1821 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1822 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1824 vat_json_print (vam->ofp, &node);
1825 vat_json_free (&node);
1827 vam->retval = ntohl (mp->retval);
1828 vam->result_ready = 1;
1833 vl_api_virtio_pci_delete_reply_t_handler (vl_api_virtio_pci_delete_reply_t *
1836 vat_main_t *vam = &vat_main;
1837 i32 retval = ntohl (mp->retval);
1838 if (vam->async_mode)
1840 vam->async_errors += (retval < 0);
1844 vam->retval = retval;
1845 vam->result_ready = 1;
1849 static void vl_api_virtio_pci_delete_reply_t_handler_json
1850 (vl_api_virtio_pci_delete_reply_t * mp)
1852 vat_main_t *vam = &vat_main;
1853 vat_json_node_t node;
1855 vat_json_init_object (&node);
1856 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
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_bond_create_reply_t_handler (vl_api_bond_create_reply_t * mp)
1868 vat_main_t *vam = &vat_main;
1869 i32 retval = ntohl (mp->retval);
1871 if (vam->async_mode)
1873 vam->async_errors += (retval < 0);
1877 vam->retval = retval;
1878 vam->sw_if_index = ntohl (mp->sw_if_index);
1879 vam->result_ready = 1;
1883 static void vl_api_bond_create_reply_t_handler_json
1884 (vl_api_bond_create_reply_t * mp)
1886 vat_main_t *vam = &vat_main;
1887 vat_json_node_t node;
1889 vat_json_init_object (&node);
1890 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1891 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1893 vat_json_print (vam->ofp, &node);
1894 vat_json_free (&node);
1896 vam->retval = ntohl (mp->retval);
1897 vam->result_ready = 1;
1901 vl_api_bond_delete_reply_t_handler (vl_api_bond_delete_reply_t * mp)
1903 vat_main_t *vam = &vat_main;
1904 i32 retval = ntohl (mp->retval);
1906 if (vam->async_mode)
1908 vam->async_errors += (retval < 0);
1912 vam->retval = retval;
1913 vam->result_ready = 1;
1917 static void vl_api_bond_delete_reply_t_handler_json
1918 (vl_api_bond_delete_reply_t * mp)
1920 vat_main_t *vam = &vat_main;
1921 vat_json_node_t node;
1923 vat_json_init_object (&node);
1924 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
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_enslave_reply_t_handler (vl_api_bond_enslave_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->result_ready = 1;
1950 static void vl_api_bond_enslave_reply_t_handler_json
1951 (vl_api_bond_enslave_reply_t * mp)
1953 vat_main_t *vam = &vat_main;
1954 vat_json_node_t node;
1956 vat_json_init_object (&node);
1957 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1959 vat_json_print (vam->ofp, &node);
1960 vat_json_free (&node);
1962 vam->retval = ntohl (mp->retval);
1963 vam->result_ready = 1;
1967 vl_api_bond_detach_slave_reply_t_handler (vl_api_bond_detach_slave_reply_t *
1970 vat_main_t *vam = &vat_main;
1971 i32 retval = ntohl (mp->retval);
1973 if (vam->async_mode)
1975 vam->async_errors += (retval < 0);
1979 vam->retval = retval;
1980 vam->result_ready = 1;
1984 static void vl_api_bond_detach_slave_reply_t_handler_json
1985 (vl_api_bond_detach_slave_reply_t * mp)
1987 vat_main_t *vam = &vat_main;
1988 vat_json_node_t node;
1990 vat_json_init_object (&node);
1991 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1993 vat_json_print (vam->ofp, &node);
1994 vat_json_free (&node);
1996 vam->retval = ntohl (mp->retval);
1997 vam->result_ready = 1;
2001 api_sw_interface_set_bond_weight (vat_main_t * vam)
2003 unformat_input_t *i = vam->input;
2004 vl_api_sw_interface_set_bond_weight_t *mp;
2005 u32 sw_if_index = ~0;
2007 u8 weight_enter = 0;
2010 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2012 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2014 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2016 else if (unformat (i, "weight %u", &weight))
2022 if (sw_if_index == ~0)
2024 errmsg ("missing interface name or sw_if_index");
2027 if (weight_enter == 0)
2029 errmsg ("missing valid weight");
2033 /* Construct the API message */
2034 M (SW_INTERFACE_SET_BOND_WEIGHT, mp);
2035 mp->sw_if_index = ntohl (sw_if_index);
2036 mp->weight = ntohl (weight);
2043 static void vl_api_sw_interface_bond_details_t_handler
2044 (vl_api_sw_interface_bond_details_t * mp)
2046 vat_main_t *vam = &vat_main;
2049 "%-16s %-12d %-12U %-13U %-14u %-14u",
2050 mp->interface_name, ntohl (mp->sw_if_index),
2051 format_bond_mode, ntohl (mp->mode), format_bond_load_balance,
2052 ntohl (mp->lb), ntohl (mp->active_slaves), ntohl (mp->slaves));
2055 static void vl_api_sw_interface_bond_details_t_handler_json
2056 (vl_api_sw_interface_bond_details_t * mp)
2058 vat_main_t *vam = &vat_main;
2059 vat_json_node_t *node = NULL;
2061 if (VAT_JSON_ARRAY != vam->json_tree.type)
2063 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2064 vat_json_init_array (&vam->json_tree);
2066 node = vat_json_array_add (&vam->json_tree);
2068 vat_json_init_object (node);
2069 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2070 vat_json_object_add_string_copy (node, "interface_name",
2071 mp->interface_name);
2072 vat_json_object_add_uint (node, "mode", ntohl (mp->mode));
2073 vat_json_object_add_uint (node, "load_balance", ntohl (mp->lb));
2074 vat_json_object_add_uint (node, "active_slaves", ntohl (mp->active_slaves));
2075 vat_json_object_add_uint (node, "slaves", ntohl (mp->slaves));
2079 api_sw_interface_bond_dump (vat_main_t * vam)
2081 vl_api_sw_interface_bond_dump_t *mp;
2082 vl_api_control_ping_t *mp_ping;
2086 "\n%-16s %-12s %-12s %-13s %-14s %-14s",
2087 "interface name", "sw_if_index", "mode", "load balance",
2088 "active slaves", "slaves");
2090 /* Get list of bond interfaces */
2091 M (SW_INTERFACE_BOND_DUMP, mp);
2094 /* Use a control ping for synchronization */
2095 MPING (CONTROL_PING, mp_ping);
2102 static void vl_api_sw_interface_slave_details_t_handler
2103 (vl_api_sw_interface_slave_details_t * mp)
2105 vat_main_t *vam = &vat_main;
2108 "%-25s %-12d %-7d %-12d %-10d %-10d", mp->interface_name,
2109 ntohl (mp->sw_if_index), mp->is_passive, mp->is_long_timeout,
2110 ntohl (mp->weight), mp->is_local_numa);
2113 static void vl_api_sw_interface_slave_details_t_handler_json
2114 (vl_api_sw_interface_slave_details_t * mp)
2116 vat_main_t *vam = &vat_main;
2117 vat_json_node_t *node = NULL;
2119 if (VAT_JSON_ARRAY != vam->json_tree.type)
2121 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2122 vat_json_init_array (&vam->json_tree);
2124 node = vat_json_array_add (&vam->json_tree);
2126 vat_json_init_object (node);
2127 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2128 vat_json_object_add_string_copy (node, "interface_name",
2129 mp->interface_name);
2130 vat_json_object_add_uint (node, "passive", mp->is_passive);
2131 vat_json_object_add_uint (node, "long_timeout", mp->is_long_timeout);
2132 vat_json_object_add_uint (node, "weight", ntohl (mp->weight));
2133 vat_json_object_add_uint (node, "is_local_numa", mp->is_local_numa);
2137 api_sw_interface_slave_dump (vat_main_t * vam)
2139 unformat_input_t *i = vam->input;
2140 vl_api_sw_interface_slave_dump_t *mp;
2141 vl_api_control_ping_t *mp_ping;
2142 u32 sw_if_index = ~0;
2143 u8 sw_if_index_set = 0;
2146 /* Parse args required to build the message */
2147 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2149 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2150 sw_if_index_set = 1;
2151 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2152 sw_if_index_set = 1;
2157 if (sw_if_index_set == 0)
2159 errmsg ("missing vpp interface name. ");
2164 "\n%-25s %-12s %-7s %-12s %-10s %-10s",
2165 "slave interface name", "sw_if_index", "passive", "long_timeout",
2166 "weight", "local numa");
2168 /* Get list of bond interfaces */
2169 M (SW_INTERFACE_SLAVE_DUMP, mp);
2170 mp->sw_if_index = ntohl (sw_if_index);
2173 /* Use a control ping for synchronization */
2174 MPING (CONTROL_PING, mp_ping);
2181 static void vl_api_mpls_tunnel_add_del_reply_t_handler
2182 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2184 vat_main_t *vam = &vat_main;
2185 i32 retval = ntohl (mp->retval);
2186 if (vam->async_mode)
2188 vam->async_errors += (retval < 0);
2192 vam->retval = retval;
2193 vam->sw_if_index = ntohl (mp->sw_if_index);
2194 vam->result_ready = 1;
2196 vam->regenerate_interface_table = 1;
2199 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
2200 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2202 vat_main_t *vam = &vat_main;
2203 vat_json_node_t node;
2205 vat_json_init_object (&node);
2206 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2207 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
2208 ntohl (mp->sw_if_index));
2210 vat_json_print (vam->ofp, &node);
2211 vat_json_free (&node);
2213 vam->retval = ntohl (mp->retval);
2214 vam->result_ready = 1;
2217 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
2218 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2220 vat_main_t *vam = &vat_main;
2221 i32 retval = ntohl (mp->retval);
2222 if (vam->async_mode)
2224 vam->async_errors += (retval < 0);
2228 vam->retval = retval;
2229 vam->sw_if_index = ntohl (mp->sw_if_index);
2230 vam->result_ready = 1;
2234 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
2235 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2237 vat_main_t *vam = &vat_main;
2238 vat_json_node_t node;
2240 vat_json_init_object (&node);
2241 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2242 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2244 vat_json_print (vam->ofp, &node);
2245 vat_json_free (&node);
2247 vam->retval = ntohl (mp->retval);
2248 vam->result_ready = 1;
2251 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
2252 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2254 vat_main_t *vam = &vat_main;
2255 i32 retval = ntohl (mp->retval);
2256 if (vam->async_mode)
2258 vam->async_errors += (retval < 0);
2262 vam->retval = retval;
2263 vam->result_ready = 1;
2267 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
2268 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2270 vat_main_t *vam = &vat_main;
2271 vat_json_node_t node;
2273 vat_json_init_object (&node);
2274 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2275 vat_json_object_add_uint (&node, "fwd_entry_index",
2276 clib_net_to_host_u32 (mp->fwd_entry_index));
2278 vat_json_print (vam->ofp, &node);
2279 vat_json_free (&node);
2281 vam->retval = ntohl (mp->retval);
2282 vam->result_ready = 1;
2286 format_lisp_transport_protocol (u8 * s, va_list * args)
2288 u32 proto = va_arg (*args, u32);
2293 return format (s, "udp");
2295 return format (s, "api");
2302 static void vl_api_one_get_transport_protocol_reply_t_handler
2303 (vl_api_one_get_transport_protocol_reply_t * mp)
2305 vat_main_t *vam = &vat_main;
2306 i32 retval = ntohl (mp->retval);
2307 if (vam->async_mode)
2309 vam->async_errors += (retval < 0);
2313 u32 proto = mp->protocol;
2314 print (vam->ofp, "Transport protocol: %U",
2315 format_lisp_transport_protocol, proto);
2316 vam->retval = retval;
2317 vam->result_ready = 1;
2321 static void vl_api_one_get_transport_protocol_reply_t_handler_json
2322 (vl_api_one_get_transport_protocol_reply_t * mp)
2324 vat_main_t *vam = &vat_main;
2325 vat_json_node_t node;
2328 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
2331 vat_json_init_object (&node);
2332 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2333 vat_json_object_add_string_copy (&node, "transport-protocol", s);
2336 vat_json_print (vam->ofp, &node);
2337 vat_json_free (&node);
2339 vam->retval = ntohl (mp->retval);
2340 vam->result_ready = 1;
2343 static void vl_api_one_add_del_locator_set_reply_t_handler
2344 (vl_api_one_add_del_locator_set_reply_t * mp)
2346 vat_main_t *vam = &vat_main;
2347 i32 retval = ntohl (mp->retval);
2348 if (vam->async_mode)
2350 vam->async_errors += (retval < 0);
2354 vam->retval = retval;
2355 vam->result_ready = 1;
2359 static void vl_api_one_add_del_locator_set_reply_t_handler_json
2360 (vl_api_one_add_del_locator_set_reply_t * mp)
2362 vat_main_t *vam = &vat_main;
2363 vat_json_node_t node;
2365 vat_json_init_object (&node);
2366 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2367 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
2369 vat_json_print (vam->ofp, &node);
2370 vat_json_free (&node);
2372 vam->retval = ntohl (mp->retval);
2373 vam->result_ready = 1;
2376 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
2377 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2379 vat_main_t *vam = &vat_main;
2380 i32 retval = ntohl (mp->retval);
2381 if (vam->async_mode)
2383 vam->async_errors += (retval < 0);
2387 vam->retval = retval;
2388 vam->sw_if_index = ntohl (mp->sw_if_index);
2389 vam->result_ready = 1;
2391 vam->regenerate_interface_table = 1;
2394 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
2395 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2397 vat_main_t *vam = &vat_main;
2398 vat_json_node_t node;
2400 vat_json_init_object (&node);
2401 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2402 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2404 vat_json_print (vam->ofp, &node);
2405 vat_json_free (&node);
2407 vam->retval = ntohl (mp->retval);
2408 vam->result_ready = 1;
2411 static void vl_api_vxlan_offload_rx_reply_t_handler
2412 (vl_api_vxlan_offload_rx_reply_t * mp)
2414 vat_main_t *vam = &vat_main;
2415 i32 retval = ntohl (mp->retval);
2416 if (vam->async_mode)
2418 vam->async_errors += (retval < 0);
2422 vam->retval = retval;
2423 vam->result_ready = 1;
2427 static void vl_api_vxlan_offload_rx_reply_t_handler_json
2428 (vl_api_vxlan_offload_rx_reply_t * mp)
2430 vat_main_t *vam = &vat_main;
2431 vat_json_node_t node;
2433 vat_json_init_object (&node);
2434 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2436 vat_json_print (vam->ofp, &node);
2437 vat_json_free (&node);
2439 vam->retval = ntohl (mp->retval);
2440 vam->result_ready = 1;
2443 static void vl_api_geneve_add_del_tunnel_reply_t_handler
2444 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2446 vat_main_t *vam = &vat_main;
2447 i32 retval = ntohl (mp->retval);
2448 if (vam->async_mode)
2450 vam->async_errors += (retval < 0);
2454 vam->retval = retval;
2455 vam->sw_if_index = ntohl (mp->sw_if_index);
2456 vam->result_ready = 1;
2460 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
2461 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2463 vat_main_t *vam = &vat_main;
2464 vat_json_node_t node;
2466 vat_json_init_object (&node);
2467 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2468 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2470 vat_json_print (vam->ofp, &node);
2471 vat_json_free (&node);
2473 vam->retval = ntohl (mp->retval);
2474 vam->result_ready = 1;
2477 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
2478 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2480 vat_main_t *vam = &vat_main;
2481 i32 retval = ntohl (mp->retval);
2482 if (vam->async_mode)
2484 vam->async_errors += (retval < 0);
2488 vam->retval = retval;
2489 vam->sw_if_index = ntohl (mp->sw_if_index);
2490 vam->result_ready = 1;
2492 vam->regenerate_interface_table = 1;
2495 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
2496 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2498 vat_main_t *vam = &vat_main;
2499 vat_json_node_t node;
2501 vat_json_init_object (&node);
2502 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2503 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2505 vat_json_print (vam->ofp, &node);
2506 vat_json_free (&node);
2508 vam->retval = ntohl (mp->retval);
2509 vam->result_ready = 1;
2512 static void vl_api_gre_tunnel_add_del_reply_t_handler
2513 (vl_api_gre_tunnel_add_del_reply_t * mp)
2515 vat_main_t *vam = &vat_main;
2516 i32 retval = ntohl (mp->retval);
2517 if (vam->async_mode)
2519 vam->async_errors += (retval < 0);
2523 vam->retval = retval;
2524 vam->sw_if_index = ntohl (mp->sw_if_index);
2525 vam->result_ready = 1;
2529 static void vl_api_gre_tunnel_add_del_reply_t_handler_json
2530 (vl_api_gre_tunnel_add_del_reply_t * mp)
2532 vat_main_t *vam = &vat_main;
2533 vat_json_node_t node;
2535 vat_json_init_object (&node);
2536 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2537 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2539 vat_json_print (vam->ofp, &node);
2540 vat_json_free (&node);
2542 vam->retval = ntohl (mp->retval);
2543 vam->result_ready = 1;
2546 static void vl_api_create_vhost_user_if_reply_t_handler
2547 (vl_api_create_vhost_user_if_reply_t * mp)
2549 vat_main_t *vam = &vat_main;
2550 i32 retval = ntohl (mp->retval);
2551 if (vam->async_mode)
2553 vam->async_errors += (retval < 0);
2557 vam->retval = retval;
2558 vam->sw_if_index = ntohl (mp->sw_if_index);
2559 vam->result_ready = 1;
2561 vam->regenerate_interface_table = 1;
2564 static void vl_api_create_vhost_user_if_reply_t_handler_json
2565 (vl_api_create_vhost_user_if_reply_t * mp)
2567 vat_main_t *vam = &vat_main;
2568 vat_json_node_t node;
2570 vat_json_init_object (&node);
2571 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2572 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2574 vat_json_print (vam->ofp, &node);
2575 vat_json_free (&node);
2577 vam->retval = ntohl (mp->retval);
2578 vam->result_ready = 1;
2581 static void vl_api_ip_address_details_t_handler
2582 (vl_api_ip_address_details_t * mp)
2584 vat_main_t *vam = &vat_main;
2585 static ip_address_details_t empty_ip_address_details = { {0} };
2586 ip_address_details_t *address = NULL;
2587 ip_details_t *current_ip_details = NULL;
2588 ip_details_t *details = NULL;
2590 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2592 if (!details || vam->current_sw_if_index >= vec_len (details)
2593 || !details[vam->current_sw_if_index].present)
2595 errmsg ("ip address details arrived but not stored");
2596 errmsg ("ip_dump should be called first");
2600 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2602 #define addresses (current_ip_details->addr)
2604 vec_validate_init_empty (addresses, vec_len (addresses),
2605 empty_ip_address_details);
2607 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2609 clib_memcpy (&address->ip, &mp->prefix.address.un, sizeof (address->ip));
2610 address->prefix_length = mp->prefix.len;
2614 static void vl_api_ip_address_details_t_handler_json
2615 (vl_api_ip_address_details_t * mp)
2617 vat_main_t *vam = &vat_main;
2618 vat_json_node_t *node = NULL;
2620 if (VAT_JSON_ARRAY != vam->json_tree.type)
2622 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2623 vat_json_init_array (&vam->json_tree);
2625 node = vat_json_array_add (&vam->json_tree);
2627 vat_json_init_object (node);
2628 vat_json_object_add_prefix (node, &mp->prefix);
2632 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2634 vat_main_t *vam = &vat_main;
2635 static ip_details_t empty_ip_details = { 0 };
2636 ip_details_t *ip = NULL;
2637 u32 sw_if_index = ~0;
2639 sw_if_index = ntohl (mp->sw_if_index);
2641 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2642 sw_if_index, empty_ip_details);
2644 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2651 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2653 vat_main_t *vam = &vat_main;
2655 if (VAT_JSON_ARRAY != vam->json_tree.type)
2657 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2658 vat_json_init_array (&vam->json_tree);
2660 vat_json_array_add_uint (&vam->json_tree,
2661 clib_net_to_host_u32 (mp->sw_if_index));
2664 static void vl_api_get_first_msg_id_reply_t_handler
2665 (vl_api_get_first_msg_id_reply_t * mp)
2667 vat_main_t *vam = &vat_main;
2668 i32 retval = ntohl (mp->retval);
2670 if (vam->async_mode)
2672 vam->async_errors += (retval < 0);
2676 vam->retval = retval;
2677 vam->result_ready = 1;
2681 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2685 static void vl_api_get_first_msg_id_reply_t_handler_json
2686 (vl_api_get_first_msg_id_reply_t * mp)
2688 vat_main_t *vam = &vat_main;
2689 vat_json_node_t node;
2691 vat_json_init_object (&node);
2692 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2693 vat_json_object_add_uint (&node, "first_msg_id",
2694 (uint) ntohs (mp->first_msg_id));
2696 vat_json_print (vam->ofp, &node);
2697 vat_json_free (&node);
2699 vam->retval = ntohl (mp->retval);
2700 vam->result_ready = 1;
2703 static void vl_api_get_node_graph_reply_t_handler
2704 (vl_api_get_node_graph_reply_t * mp)
2706 vat_main_t *vam = &vat_main;
2707 i32 retval = ntohl (mp->retval);
2708 u8 *pvt_copy, *reply;
2713 if (vam->async_mode)
2715 vam->async_errors += (retval < 0);
2719 vam->retval = retval;
2720 vam->result_ready = 1;
2723 /* "Should never happen..." */
2727 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2728 pvt_copy = vec_dup (reply);
2730 /* Toss the shared-memory original... */
2731 oldheap = vl_msg_push_heap ();
2735 vl_msg_pop_heap (oldheap);
2737 if (vam->graph_nodes)
2739 hash_free (vam->graph_node_index_by_name);
2741 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2743 node = vam->graph_nodes[0][i];
2744 vec_free (node->name);
2745 vec_free (node->next_nodes);
2748 vec_free (vam->graph_nodes[0]);
2749 vec_free (vam->graph_nodes);
2752 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2753 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2754 vec_free (pvt_copy);
2756 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2758 node = vam->graph_nodes[0][i];
2759 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2763 static void vl_api_get_node_graph_reply_t_handler_json
2764 (vl_api_get_node_graph_reply_t * mp)
2766 vat_main_t *vam = &vat_main;
2768 vat_json_node_t node;
2771 /* $$$$ make this real? */
2772 vat_json_init_object (&node);
2773 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2774 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2776 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2778 /* Toss the shared-memory original... */
2779 oldheap = vl_msg_push_heap ();
2783 vl_msg_pop_heap (oldheap);
2785 vat_json_print (vam->ofp, &node);
2786 vat_json_free (&node);
2788 vam->retval = ntohl (mp->retval);
2789 vam->result_ready = 1;
2793 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2795 vat_main_t *vam = &vat_main;
2800 s = format (s, "%=16d%=16d%=16d",
2801 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2805 s = format (s, "%=16U%=16d%=16d",
2806 mp->is_ipv6 ? format_ip6_address :
2808 mp->ip_address, mp->priority, mp->weight);
2811 print (vam->ofp, "%v", s);
2816 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2818 vat_main_t *vam = &vat_main;
2819 vat_json_node_t *node = NULL;
2820 struct in6_addr ip6;
2823 if (VAT_JSON_ARRAY != vam->json_tree.type)
2825 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2826 vat_json_init_array (&vam->json_tree);
2828 node = vat_json_array_add (&vam->json_tree);
2829 vat_json_init_object (node);
2831 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2832 vat_json_object_add_uint (node, "priority", mp->priority);
2833 vat_json_object_add_uint (node, "weight", mp->weight);
2836 vat_json_object_add_uint (node, "sw_if_index",
2837 clib_net_to_host_u32 (mp->sw_if_index));
2842 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2843 vat_json_object_add_ip6 (node, "address", ip6);
2847 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2848 vat_json_object_add_ip4 (node, "address", ip4);
2854 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2857 vat_main_t *vam = &vat_main;
2860 ls_name = format (0, "%s", mp->ls_name);
2862 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2868 vl_api_one_locator_set_details_t_handler_json
2869 (vl_api_one_locator_set_details_t * mp)
2871 vat_main_t *vam = &vat_main;
2872 vat_json_node_t *node = 0;
2875 ls_name = format (0, "%s", mp->ls_name);
2876 vec_add1 (ls_name, 0);
2878 if (VAT_JSON_ARRAY != vam->json_tree.type)
2880 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2881 vat_json_init_array (&vam->json_tree);
2883 node = vat_json_array_add (&vam->json_tree);
2885 vat_json_init_object (node);
2886 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2887 vat_json_object_add_uint (node, "ls_index",
2888 clib_net_to_host_u32 (mp->ls_index));
2896 } __attribute__ ((__packed__)) lisp_nsh_api_t;
2899 unformat_nsh_address (unformat_input_t * input, va_list * args)
2901 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
2902 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
2906 format_nsh_address_vat (u8 * s, va_list * args)
2908 nsh_t *a = va_arg (*args, nsh_t *);
2909 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
2913 format_lisp_flat_eid (u8 * s, va_list * args)
2915 u32 type = va_arg (*args, u32);
2916 u8 *eid = va_arg (*args, u8 *);
2917 u32 eid_len = va_arg (*args, u32);
2922 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2924 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2926 return format (s, "%U", format_ethernet_address, eid);
2928 return format (s, "%U", format_nsh_address_vat, eid);
2934 format_lisp_eid_vat (u8 * s, va_list * args)
2936 u32 type = va_arg (*args, u32);
2937 u8 *eid = va_arg (*args, u8 *);
2938 u32 eid_len = va_arg (*args, u32);
2939 u8 *seid = va_arg (*args, u8 *);
2940 u32 seid_len = va_arg (*args, u32);
2941 u32 is_src_dst = va_arg (*args, u32);
2944 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2946 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2952 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
2954 vat_main_t *vam = &vat_main;
2955 u8 *s = 0, *eid = 0;
2957 if (~0 == mp->locator_set_index)
2958 s = format (0, "action: %d", mp->action);
2960 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2962 eid = format (0, "%U", format_lisp_eid_vat,
2966 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2969 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
2970 clib_net_to_host_u32 (mp->vni),
2972 mp->is_local ? "local" : "remote",
2973 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
2974 clib_net_to_host_u16 (mp->key_id), mp->key);
2981 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
2984 vat_main_t *vam = &vat_main;
2985 vat_json_node_t *node = 0;
2988 if (VAT_JSON_ARRAY != vam->json_tree.type)
2990 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2991 vat_json_init_array (&vam->json_tree);
2993 node = vat_json_array_add (&vam->json_tree);
2995 vat_json_init_object (node);
2996 if (~0 == mp->locator_set_index)
2997 vat_json_object_add_uint (node, "action", mp->action);
2999 vat_json_object_add_uint (node, "locator_set_index",
3000 clib_net_to_host_u32 (mp->locator_set_index));
3002 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3003 if (mp->eid_type == 3)
3005 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3006 vat_json_init_object (nsh_json);
3007 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3008 vat_json_object_add_uint (nsh_json, "spi",
3009 clib_net_to_host_u32 (nsh->spi));
3010 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3014 eid = format (0, "%U", format_lisp_eid_vat,
3018 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3020 vat_json_object_add_string_copy (node, "eid", eid);
3023 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3024 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3025 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3029 vat_json_object_add_uint (node, "key_id",
3030 clib_net_to_host_u16 (mp->key_id));
3031 vat_json_object_add_string_copy (node, "key", mp->key);
3036 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3038 vat_main_t *vam = &vat_main;
3039 u8 *seid = 0, *deid = 0;
3040 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3042 deid = format (0, "%U", format_lisp_eid_vat,
3043 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3045 seid = format (0, "%U", format_lisp_eid_vat,
3046 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3052 format_ip_address_fcn = format_ip4_address;
3054 format_ip_address_fcn = format_ip6_address;
3057 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3058 clib_net_to_host_u32 (mp->vni),
3060 format_ip_address_fcn, mp->lloc,
3061 format_ip_address_fcn, mp->rloc,
3062 clib_net_to_host_u32 (mp->pkt_count),
3063 clib_net_to_host_u32 (mp->bytes));
3070 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3072 struct in6_addr ip6;
3074 vat_main_t *vam = &vat_main;
3075 vat_json_node_t *node = 0;
3076 u8 *deid = 0, *seid = 0;
3078 if (VAT_JSON_ARRAY != vam->json_tree.type)
3080 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3081 vat_json_init_array (&vam->json_tree);
3083 node = vat_json_array_add (&vam->json_tree);
3085 vat_json_init_object (node);
3086 deid = format (0, "%U", format_lisp_eid_vat,
3087 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3089 seid = format (0, "%U", format_lisp_eid_vat,
3090 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3095 vat_json_object_add_string_copy (node, "seid", seid);
3096 vat_json_object_add_string_copy (node, "deid", deid);
3097 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3101 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3102 vat_json_object_add_ip4 (node, "lloc", ip4);
3103 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3104 vat_json_object_add_ip4 (node, "rloc", ip4);
3108 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3109 vat_json_object_add_ip6 (node, "lloc", ip6);
3110 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3111 vat_json_object_add_ip6 (node, "rloc", ip6);
3113 vat_json_object_add_uint (node, "pkt_count",
3114 clib_net_to_host_u32 (mp->pkt_count));
3115 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3122 vl_api_one_eid_table_map_details_t_handler
3123 (vl_api_one_eid_table_map_details_t * mp)
3125 vat_main_t *vam = &vat_main;
3127 u8 *line = format (0, "%=10d%=10d",
3128 clib_net_to_host_u32 (mp->vni),
3129 clib_net_to_host_u32 (mp->dp_table));
3130 print (vam->ofp, "%v", line);
3135 vl_api_one_eid_table_map_details_t_handler_json
3136 (vl_api_one_eid_table_map_details_t * mp)
3138 vat_main_t *vam = &vat_main;
3139 vat_json_node_t *node = NULL;
3141 if (VAT_JSON_ARRAY != vam->json_tree.type)
3143 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3144 vat_json_init_array (&vam->json_tree);
3146 node = vat_json_array_add (&vam->json_tree);
3147 vat_json_init_object (node);
3148 vat_json_object_add_uint (node, "dp_table",
3149 clib_net_to_host_u32 (mp->dp_table));
3150 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3154 vl_api_one_eid_table_vni_details_t_handler
3155 (vl_api_one_eid_table_vni_details_t * mp)
3157 vat_main_t *vam = &vat_main;
3159 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3160 print (vam->ofp, "%v", line);
3165 vl_api_one_eid_table_vni_details_t_handler_json
3166 (vl_api_one_eid_table_vni_details_t * mp)
3168 vat_main_t *vam = &vat_main;
3169 vat_json_node_t *node = NULL;
3171 if (VAT_JSON_ARRAY != vam->json_tree.type)
3173 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3174 vat_json_init_array (&vam->json_tree);
3176 node = vat_json_array_add (&vam->json_tree);
3177 vat_json_init_object (node);
3178 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3182 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3183 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3185 vat_main_t *vam = &vat_main;
3186 int retval = clib_net_to_host_u32 (mp->retval);
3188 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3189 print (vam->ofp, "fallback threshold value: %d", mp->value);
3191 vam->retval = retval;
3192 vam->result_ready = 1;
3196 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3197 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3199 vat_main_t *vam = &vat_main;
3200 vat_json_node_t _node, *node = &_node;
3201 int retval = clib_net_to_host_u32 (mp->retval);
3203 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3204 vat_json_init_object (node);
3205 vat_json_object_add_uint (node, "value", mp->value);
3207 vat_json_print (vam->ofp, node);
3208 vat_json_free (node);
3210 vam->retval = retval;
3211 vam->result_ready = 1;
3215 vl_api_show_one_map_register_state_reply_t_handler
3216 (vl_api_show_one_map_register_state_reply_t * mp)
3218 vat_main_t *vam = &vat_main;
3219 int retval = clib_net_to_host_u32 (mp->retval);
3221 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3223 vam->retval = retval;
3224 vam->result_ready = 1;
3228 vl_api_show_one_map_register_state_reply_t_handler_json
3229 (vl_api_show_one_map_register_state_reply_t * mp)
3231 vat_main_t *vam = &vat_main;
3232 vat_json_node_t _node, *node = &_node;
3233 int retval = clib_net_to_host_u32 (mp->retval);
3235 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3237 vat_json_init_object (node);
3238 vat_json_object_add_string_copy (node, "state", s);
3240 vat_json_print (vam->ofp, node);
3241 vat_json_free (node);
3243 vam->retval = retval;
3244 vam->result_ready = 1;
3249 vl_api_show_one_rloc_probe_state_reply_t_handler
3250 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3252 vat_main_t *vam = &vat_main;
3253 int retval = clib_net_to_host_u32 (mp->retval);
3258 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3260 vam->retval = retval;
3261 vam->result_ready = 1;
3265 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3266 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3268 vat_main_t *vam = &vat_main;
3269 vat_json_node_t _node, *node = &_node;
3270 int retval = clib_net_to_host_u32 (mp->retval);
3272 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3273 vat_json_init_object (node);
3274 vat_json_object_add_string_copy (node, "state", s);
3276 vat_json_print (vam->ofp, node);
3277 vat_json_free (node);
3279 vam->retval = retval;
3280 vam->result_ready = 1;
3285 vl_api_show_one_stats_enable_disable_reply_t_handler
3286 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3288 vat_main_t *vam = &vat_main;
3289 int retval = clib_net_to_host_u32 (mp->retval);
3294 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3296 vam->retval = retval;
3297 vam->result_ready = 1;
3301 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3302 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3304 vat_main_t *vam = &vat_main;
3305 vat_json_node_t _node, *node = &_node;
3306 int retval = clib_net_to_host_u32 (mp->retval);
3308 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3309 vat_json_init_object (node);
3310 vat_json_object_add_string_copy (node, "state", s);
3312 vat_json_print (vam->ofp, node);
3313 vat_json_free (node);
3315 vam->retval = retval;
3316 vam->result_ready = 1;
3321 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3323 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3324 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3325 e->vni = clib_net_to_host_u32 (e->vni);
3329 gpe_fwd_entries_get_reply_t_net_to_host
3330 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3334 mp->count = clib_net_to_host_u32 (mp->count);
3335 for (i = 0; i < mp->count; i++)
3337 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3342 format_gpe_encap_mode (u8 * s, va_list * args)
3344 u32 mode = va_arg (*args, u32);
3349 return format (s, "lisp");
3351 return format (s, "vxlan");
3357 vl_api_gpe_get_encap_mode_reply_t_handler
3358 (vl_api_gpe_get_encap_mode_reply_t * mp)
3360 vat_main_t *vam = &vat_main;
3362 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3363 vam->retval = ntohl (mp->retval);
3364 vam->result_ready = 1;
3368 vl_api_gpe_get_encap_mode_reply_t_handler_json
3369 (vl_api_gpe_get_encap_mode_reply_t * mp)
3371 vat_main_t *vam = &vat_main;
3372 vat_json_node_t node;
3374 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3375 vec_add1 (encap_mode, 0);
3377 vat_json_init_object (&node);
3378 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3380 vec_free (encap_mode);
3381 vat_json_print (vam->ofp, &node);
3382 vat_json_free (&node);
3384 vam->retval = ntohl (mp->retval);
3385 vam->result_ready = 1;
3389 vl_api_gpe_fwd_entry_path_details_t_handler
3390 (vl_api_gpe_fwd_entry_path_details_t * mp)
3392 vat_main_t *vam = &vat_main;
3393 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3395 if (mp->lcl_loc.is_ip4)
3396 format_ip_address_fcn = format_ip4_address;
3398 format_ip_address_fcn = format_ip6_address;
3400 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3401 format_ip_address_fcn, &mp->lcl_loc,
3402 format_ip_address_fcn, &mp->rmt_loc);
3406 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3408 struct in6_addr ip6;
3413 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3414 vat_json_object_add_ip4 (n, "address", ip4);
3418 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3419 vat_json_object_add_ip6 (n, "address", ip6);
3421 vat_json_object_add_uint (n, "weight", loc->weight);
3425 vl_api_gpe_fwd_entry_path_details_t_handler_json
3426 (vl_api_gpe_fwd_entry_path_details_t * mp)
3428 vat_main_t *vam = &vat_main;
3429 vat_json_node_t *node = NULL;
3430 vat_json_node_t *loc_node;
3432 if (VAT_JSON_ARRAY != vam->json_tree.type)
3434 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3435 vat_json_init_array (&vam->json_tree);
3437 node = vat_json_array_add (&vam->json_tree);
3438 vat_json_init_object (node);
3440 loc_node = vat_json_object_add (node, "local_locator");
3441 vat_json_init_object (loc_node);
3442 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3444 loc_node = vat_json_object_add (node, "remote_locator");
3445 vat_json_init_object (loc_node);
3446 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3450 vl_api_gpe_fwd_entries_get_reply_t_handler
3451 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3453 vat_main_t *vam = &vat_main;
3455 int retval = clib_net_to_host_u32 (mp->retval);
3456 vl_api_gpe_fwd_entry_t *e;
3461 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3463 for (i = 0; i < mp->count; i++)
3465 e = &mp->entries[i];
3466 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3467 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3468 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3472 vam->retval = retval;
3473 vam->result_ready = 1;
3477 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3478 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3481 vat_main_t *vam = &vat_main;
3482 vat_json_node_t *e = 0, root;
3484 int retval = clib_net_to_host_u32 (mp->retval);
3485 vl_api_gpe_fwd_entry_t *fwd;
3490 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3491 vat_json_init_array (&root);
3493 for (i = 0; i < mp->count; i++)
3495 e = vat_json_array_add (&root);
3496 fwd = &mp->entries[i];
3498 vat_json_init_object (e);
3499 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3500 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3501 vat_json_object_add_int (e, "vni", fwd->vni);
3502 vat_json_object_add_int (e, "action", fwd->action);
3504 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3505 fwd->leid_prefix_len);
3507 vat_json_object_add_string_copy (e, "leid", s);
3510 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3511 fwd->reid_prefix_len);
3513 vat_json_object_add_string_copy (e, "reid", s);
3517 vat_json_print (vam->ofp, &root);
3518 vat_json_free (&root);
3521 vam->retval = retval;
3522 vam->result_ready = 1;
3526 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3527 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3529 vat_main_t *vam = &vat_main;
3531 int retval = clib_net_to_host_u32 (mp->retval);
3532 vl_api_gpe_native_fwd_rpath_t *r;
3537 n = clib_net_to_host_u32 (mp->count);
3539 for (i = 0; i < n; i++)
3541 r = &mp->entries[i];
3542 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3543 clib_net_to_host_u32 (r->fib_index),
3544 clib_net_to_host_u32 (r->nh_sw_if_index),
3545 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3549 vam->retval = retval;
3550 vam->result_ready = 1;
3554 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3555 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3557 vat_main_t *vam = &vat_main;
3558 vat_json_node_t root, *e;
3560 int retval = clib_net_to_host_u32 (mp->retval);
3561 vl_api_gpe_native_fwd_rpath_t *r;
3567 n = clib_net_to_host_u32 (mp->count);
3568 vat_json_init_array (&root);
3570 for (i = 0; i < n; i++)
3572 e = vat_json_array_add (&root);
3573 vat_json_init_object (e);
3574 r = &mp->entries[i];
3576 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3579 vat_json_object_add_string_copy (e, "ip4", s);
3582 vat_json_object_add_uint (e, "fib_index",
3583 clib_net_to_host_u32 (r->fib_index));
3584 vat_json_object_add_uint (e, "nh_sw_if_index",
3585 clib_net_to_host_u32 (r->nh_sw_if_index));
3588 vat_json_print (vam->ofp, &root);
3589 vat_json_free (&root);
3592 vam->retval = retval;
3593 vam->result_ready = 1;
3597 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3598 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3600 vat_main_t *vam = &vat_main;
3602 int retval = clib_net_to_host_u32 (mp->retval);
3607 n = clib_net_to_host_u32 (mp->count);
3609 for (i = 0; i < n; i++)
3610 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3613 vam->retval = retval;
3614 vam->result_ready = 1;
3618 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3619 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3621 vat_main_t *vam = &vat_main;
3622 vat_json_node_t root;
3624 int retval = clib_net_to_host_u32 (mp->retval);
3629 n = clib_net_to_host_u32 (mp->count);
3630 vat_json_init_array (&root);
3632 for (i = 0; i < n; i++)
3633 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3635 vat_json_print (vam->ofp, &root);
3636 vat_json_free (&root);
3639 vam->retval = retval;
3640 vam->result_ready = 1;
3644 vl_api_one_ndp_entries_get_reply_t_handler
3645 (vl_api_one_ndp_entries_get_reply_t * mp)
3647 vat_main_t *vam = &vat_main;
3649 int retval = clib_net_to_host_u32 (mp->retval);
3654 n = clib_net_to_host_u32 (mp->count);
3656 for (i = 0; i < n; i++)
3657 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3658 format_ethernet_address, mp->entries[i].mac);
3661 vam->retval = retval;
3662 vam->result_ready = 1;
3666 vl_api_one_ndp_entries_get_reply_t_handler_json
3667 (vl_api_one_ndp_entries_get_reply_t * mp)
3670 vat_main_t *vam = &vat_main;
3671 vat_json_node_t *e = 0, root;
3673 int retval = clib_net_to_host_u32 (mp->retval);
3674 vl_api_one_ndp_entry_t *arp_entry;
3679 n = clib_net_to_host_u32 (mp->count);
3680 vat_json_init_array (&root);
3682 for (i = 0; i < n; i++)
3684 e = vat_json_array_add (&root);
3685 arp_entry = &mp->entries[i];
3687 vat_json_init_object (e);
3688 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3691 vat_json_object_add_string_copy (e, "mac", s);
3694 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3696 vat_json_object_add_string_copy (e, "ip6", s);
3700 vat_json_print (vam->ofp, &root);
3701 vat_json_free (&root);
3704 vam->retval = retval;
3705 vam->result_ready = 1;
3709 vl_api_one_l2_arp_entries_get_reply_t_handler
3710 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3712 vat_main_t *vam = &vat_main;
3714 int retval = clib_net_to_host_u32 (mp->retval);
3719 n = clib_net_to_host_u32 (mp->count);
3721 for (i = 0; i < n; i++)
3722 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3723 format_ethernet_address, mp->entries[i].mac);
3726 vam->retval = retval;
3727 vam->result_ready = 1;
3731 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3732 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3735 vat_main_t *vam = &vat_main;
3736 vat_json_node_t *e = 0, root;
3738 int retval = clib_net_to_host_u32 (mp->retval);
3739 vl_api_one_l2_arp_entry_t *arp_entry;
3744 n = clib_net_to_host_u32 (mp->count);
3745 vat_json_init_array (&root);
3747 for (i = 0; i < n; i++)
3749 e = vat_json_array_add (&root);
3750 arp_entry = &mp->entries[i];
3752 vat_json_init_object (e);
3753 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3756 vat_json_object_add_string_copy (e, "mac", s);
3759 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3761 vat_json_object_add_string_copy (e, "ip4", s);
3765 vat_json_print (vam->ofp, &root);
3766 vat_json_free (&root);
3769 vam->retval = retval;
3770 vam->result_ready = 1;
3774 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
3776 vat_main_t *vam = &vat_main;
3778 int retval = clib_net_to_host_u32 (mp->retval);
3783 n = clib_net_to_host_u32 (mp->count);
3785 for (i = 0; i < n; i++)
3787 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3791 vam->retval = retval;
3792 vam->result_ready = 1;
3796 vl_api_one_ndp_bd_get_reply_t_handler_json
3797 (vl_api_one_ndp_bd_get_reply_t * mp)
3799 vat_main_t *vam = &vat_main;
3800 vat_json_node_t root;
3802 int retval = clib_net_to_host_u32 (mp->retval);
3807 n = clib_net_to_host_u32 (mp->count);
3808 vat_json_init_array (&root);
3810 for (i = 0; i < n; i++)
3812 vat_json_array_add_uint (&root,
3813 clib_net_to_host_u32 (mp->bridge_domains[i]));
3816 vat_json_print (vam->ofp, &root);
3817 vat_json_free (&root);
3820 vam->retval = retval;
3821 vam->result_ready = 1;
3825 vl_api_one_l2_arp_bd_get_reply_t_handler
3826 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3828 vat_main_t *vam = &vat_main;
3830 int retval = clib_net_to_host_u32 (mp->retval);
3835 n = clib_net_to_host_u32 (mp->count);
3837 for (i = 0; i < n; i++)
3839 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3843 vam->retval = retval;
3844 vam->result_ready = 1;
3848 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3849 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3851 vat_main_t *vam = &vat_main;
3852 vat_json_node_t root;
3854 int retval = clib_net_to_host_u32 (mp->retval);
3859 n = clib_net_to_host_u32 (mp->count);
3860 vat_json_init_array (&root);
3862 for (i = 0; i < n; i++)
3864 vat_json_array_add_uint (&root,
3865 clib_net_to_host_u32 (mp->bridge_domains[i]));
3868 vat_json_print (vam->ofp, &root);
3869 vat_json_free (&root);
3872 vam->retval = retval;
3873 vam->result_ready = 1;
3877 vl_api_one_adjacencies_get_reply_t_handler
3878 (vl_api_one_adjacencies_get_reply_t * mp)
3880 vat_main_t *vam = &vat_main;
3882 int retval = clib_net_to_host_u32 (mp->retval);
3883 vl_api_one_adjacency_t *a;
3888 n = clib_net_to_host_u32 (mp->count);
3890 for (i = 0; i < n; i++)
3892 a = &mp->adjacencies[i];
3893 print (vam->ofp, "%U %40U",
3894 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3895 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3899 vam->retval = retval;
3900 vam->result_ready = 1;
3904 vl_api_one_adjacencies_get_reply_t_handler_json
3905 (vl_api_one_adjacencies_get_reply_t * mp)
3908 vat_main_t *vam = &vat_main;
3909 vat_json_node_t *e = 0, root;
3911 int retval = clib_net_to_host_u32 (mp->retval);
3912 vl_api_one_adjacency_t *a;
3917 n = clib_net_to_host_u32 (mp->count);
3918 vat_json_init_array (&root);
3920 for (i = 0; i < n; i++)
3922 e = vat_json_array_add (&root);
3923 a = &mp->adjacencies[i];
3925 vat_json_init_object (e);
3926 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
3927 a->leid_prefix_len);
3929 vat_json_object_add_string_copy (e, "leid", s);
3932 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
3933 a->reid_prefix_len);
3935 vat_json_object_add_string_copy (e, "reid", s);
3939 vat_json_print (vam->ofp, &root);
3940 vat_json_free (&root);
3943 vam->retval = retval;
3944 vam->result_ready = 1;
3948 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
3950 vat_main_t *vam = &vat_main;
3952 print (vam->ofp, "%=20U",
3953 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3958 vl_api_one_map_server_details_t_handler_json
3959 (vl_api_one_map_server_details_t * mp)
3961 vat_main_t *vam = &vat_main;
3962 vat_json_node_t *node = NULL;
3963 struct in6_addr ip6;
3966 if (VAT_JSON_ARRAY != vam->json_tree.type)
3968 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3969 vat_json_init_array (&vam->json_tree);
3971 node = vat_json_array_add (&vam->json_tree);
3973 vat_json_init_object (node);
3976 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3977 vat_json_object_add_ip6 (node, "map-server", ip6);
3981 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3982 vat_json_object_add_ip4 (node, "map-server", ip4);
3987 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
3990 vat_main_t *vam = &vat_main;
3992 print (vam->ofp, "%=20U",
3993 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3998 vl_api_one_map_resolver_details_t_handler_json
3999 (vl_api_one_map_resolver_details_t * mp)
4001 vat_main_t *vam = &vat_main;
4002 vat_json_node_t *node = NULL;
4003 struct in6_addr ip6;
4006 if (VAT_JSON_ARRAY != vam->json_tree.type)
4008 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4009 vat_json_init_array (&vam->json_tree);
4011 node = vat_json_array_add (&vam->json_tree);
4013 vat_json_init_object (node);
4016 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4017 vat_json_object_add_ip6 (node, "map resolver", ip6);
4021 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4022 vat_json_object_add_ip4 (node, "map resolver", ip4);
4027 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4029 vat_main_t *vam = &vat_main;
4030 i32 retval = ntohl (mp->retval);
4034 print (vam->ofp, "feature: %s\ngpe: %s",
4035 mp->feature_status ? "enabled" : "disabled",
4036 mp->gpe_status ? "enabled" : "disabled");
4039 vam->retval = retval;
4040 vam->result_ready = 1;
4044 vl_api_show_one_status_reply_t_handler_json
4045 (vl_api_show_one_status_reply_t * mp)
4047 vat_main_t *vam = &vat_main;
4048 vat_json_node_t node;
4049 u8 *gpe_status = NULL;
4050 u8 *feature_status = NULL;
4052 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4053 feature_status = format (0, "%s",
4054 mp->feature_status ? "enabled" : "disabled");
4055 vec_add1 (gpe_status, 0);
4056 vec_add1 (feature_status, 0);
4058 vat_json_init_object (&node);
4059 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4060 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4062 vec_free (gpe_status);
4063 vec_free (feature_status);
4065 vat_json_print (vam->ofp, &node);
4066 vat_json_free (&node);
4068 vam->retval = ntohl (mp->retval);
4069 vam->result_ready = 1;
4073 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4074 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4076 vat_main_t *vam = &vat_main;
4077 i32 retval = ntohl (mp->retval);
4081 print (vam->ofp, "%=20s", mp->locator_set_name);
4084 vam->retval = retval;
4085 vam->result_ready = 1;
4089 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4090 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4092 vat_main_t *vam = &vat_main;
4093 vat_json_node_t *node = NULL;
4095 if (VAT_JSON_ARRAY != vam->json_tree.type)
4097 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4098 vat_json_init_array (&vam->json_tree);
4100 node = vat_json_array_add (&vam->json_tree);
4102 vat_json_init_object (node);
4103 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4105 vat_json_print (vam->ofp, node);
4106 vat_json_free (node);
4108 vam->retval = ntohl (mp->retval);
4109 vam->result_ready = 1;
4113 format_lisp_map_request_mode (u8 * s, va_list * args)
4115 u32 mode = va_arg (*args, u32);
4120 return format (0, "dst-only");
4122 return format (0, "src-dst");
4128 vl_api_show_one_map_request_mode_reply_t_handler
4129 (vl_api_show_one_map_request_mode_reply_t * mp)
4131 vat_main_t *vam = &vat_main;
4132 i32 retval = ntohl (mp->retval);
4136 u32 mode = mp->mode;
4137 print (vam->ofp, "map_request_mode: %U",
4138 format_lisp_map_request_mode, mode);
4141 vam->retval = retval;
4142 vam->result_ready = 1;
4146 vl_api_show_one_map_request_mode_reply_t_handler_json
4147 (vl_api_show_one_map_request_mode_reply_t * mp)
4149 vat_main_t *vam = &vat_main;
4150 vat_json_node_t node;
4155 s = format (0, "%U", format_lisp_map_request_mode, mode);
4158 vat_json_init_object (&node);
4159 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4160 vat_json_print (vam->ofp, &node);
4161 vat_json_free (&node);
4164 vam->retval = ntohl (mp->retval);
4165 vam->result_ready = 1;
4169 vl_api_one_show_xtr_mode_reply_t_handler
4170 (vl_api_one_show_xtr_mode_reply_t * mp)
4172 vat_main_t *vam = &vat_main;
4173 i32 retval = ntohl (mp->retval);
4177 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4180 vam->retval = retval;
4181 vam->result_ready = 1;
4185 vl_api_one_show_xtr_mode_reply_t_handler_json
4186 (vl_api_one_show_xtr_mode_reply_t * mp)
4188 vat_main_t *vam = &vat_main;
4189 vat_json_node_t node;
4192 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4193 vec_add1 (status, 0);
4195 vat_json_init_object (&node);
4196 vat_json_object_add_string_copy (&node, "status", status);
4200 vat_json_print (vam->ofp, &node);
4201 vat_json_free (&node);
4203 vam->retval = ntohl (mp->retval);
4204 vam->result_ready = 1;
4208 vl_api_one_show_pitr_mode_reply_t_handler
4209 (vl_api_one_show_pitr_mode_reply_t * mp)
4211 vat_main_t *vam = &vat_main;
4212 i32 retval = ntohl (mp->retval);
4216 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4219 vam->retval = retval;
4220 vam->result_ready = 1;
4224 vl_api_one_show_pitr_mode_reply_t_handler_json
4225 (vl_api_one_show_pitr_mode_reply_t * mp)
4227 vat_main_t *vam = &vat_main;
4228 vat_json_node_t node;
4231 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4232 vec_add1 (status, 0);
4234 vat_json_init_object (&node);
4235 vat_json_object_add_string_copy (&node, "status", status);
4239 vat_json_print (vam->ofp, &node);
4240 vat_json_free (&node);
4242 vam->retval = ntohl (mp->retval);
4243 vam->result_ready = 1;
4247 vl_api_one_show_petr_mode_reply_t_handler
4248 (vl_api_one_show_petr_mode_reply_t * mp)
4250 vat_main_t *vam = &vat_main;
4251 i32 retval = ntohl (mp->retval);
4255 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4258 vam->retval = retval;
4259 vam->result_ready = 1;
4263 vl_api_one_show_petr_mode_reply_t_handler_json
4264 (vl_api_one_show_petr_mode_reply_t * mp)
4266 vat_main_t *vam = &vat_main;
4267 vat_json_node_t node;
4270 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4271 vec_add1 (status, 0);
4273 vat_json_init_object (&node);
4274 vat_json_object_add_string_copy (&node, "status", status);
4278 vat_json_print (vam->ofp, &node);
4279 vat_json_free (&node);
4281 vam->retval = ntohl (mp->retval);
4282 vam->result_ready = 1;
4286 vl_api_show_one_use_petr_reply_t_handler
4287 (vl_api_show_one_use_petr_reply_t * mp)
4289 vat_main_t *vam = &vat_main;
4290 i32 retval = ntohl (mp->retval);
4294 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4297 print (vam->ofp, "Proxy-ETR address; %U",
4298 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4303 vam->retval = retval;
4304 vam->result_ready = 1;
4308 vl_api_show_one_use_petr_reply_t_handler_json
4309 (vl_api_show_one_use_petr_reply_t * mp)
4311 vat_main_t *vam = &vat_main;
4312 vat_json_node_t node;
4315 struct in6_addr ip6;
4317 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4318 vec_add1 (status, 0);
4320 vat_json_init_object (&node);
4321 vat_json_object_add_string_copy (&node, "status", status);
4326 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4327 vat_json_object_add_ip6 (&node, "address", ip6);
4331 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4332 vat_json_object_add_ip4 (&node, "address", ip4);
4338 vat_json_print (vam->ofp, &node);
4339 vat_json_free (&node);
4341 vam->retval = ntohl (mp->retval);
4342 vam->result_ready = 1;
4346 vl_api_show_one_nsh_mapping_reply_t_handler
4347 (vl_api_show_one_nsh_mapping_reply_t * mp)
4349 vat_main_t *vam = &vat_main;
4350 i32 retval = ntohl (mp->retval);
4354 print (vam->ofp, "%-20s%-16s",
4355 mp->is_set ? "set" : "not-set",
4356 mp->is_set ? (char *) mp->locator_set_name : "");
4359 vam->retval = retval;
4360 vam->result_ready = 1;
4364 vl_api_show_one_nsh_mapping_reply_t_handler_json
4365 (vl_api_show_one_nsh_mapping_reply_t * mp)
4367 vat_main_t *vam = &vat_main;
4368 vat_json_node_t node;
4371 status = format (0, "%s", mp->is_set ? "yes" : "no");
4372 vec_add1 (status, 0);
4374 vat_json_init_object (&node);
4375 vat_json_object_add_string_copy (&node, "is_set", status);
4378 vat_json_object_add_string_copy (&node, "locator_set",
4379 mp->locator_set_name);
4384 vat_json_print (vam->ofp, &node);
4385 vat_json_free (&node);
4387 vam->retval = ntohl (mp->retval);
4388 vam->result_ready = 1;
4392 vl_api_show_one_map_register_ttl_reply_t_handler
4393 (vl_api_show_one_map_register_ttl_reply_t * mp)
4395 vat_main_t *vam = &vat_main;
4396 i32 retval = ntohl (mp->retval);
4398 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4402 print (vam->ofp, "ttl: %u", mp->ttl);
4405 vam->retval = retval;
4406 vam->result_ready = 1;
4410 vl_api_show_one_map_register_ttl_reply_t_handler_json
4411 (vl_api_show_one_map_register_ttl_reply_t * mp)
4413 vat_main_t *vam = &vat_main;
4414 vat_json_node_t node;
4416 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4417 vat_json_init_object (&node);
4418 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4420 vat_json_print (vam->ofp, &node);
4421 vat_json_free (&node);
4423 vam->retval = ntohl (mp->retval);
4424 vam->result_ready = 1;
4428 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4430 vat_main_t *vam = &vat_main;
4431 i32 retval = ntohl (mp->retval);
4435 print (vam->ofp, "%-20s%-16s",
4436 mp->status ? "enabled" : "disabled",
4437 mp->status ? (char *) mp->locator_set_name : "");
4440 vam->retval = retval;
4441 vam->result_ready = 1;
4445 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4447 vat_main_t *vam = &vat_main;
4448 vat_json_node_t node;
4451 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4452 vec_add1 (status, 0);
4454 vat_json_init_object (&node);
4455 vat_json_object_add_string_copy (&node, "status", status);
4458 vat_json_object_add_string_copy (&node, "locator_set",
4459 mp->locator_set_name);
4464 vat_json_print (vam->ofp, &node);
4465 vat_json_free (&node);
4467 vam->retval = ntohl (mp->retval);
4468 vam->result_ready = 1;
4472 format_policer_type (u8 * s, va_list * va)
4474 u32 i = va_arg (*va, u32);
4476 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4477 s = format (s, "1r2c");
4478 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4479 s = format (s, "1r3c");
4480 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4481 s = format (s, "2r3c-2698");
4482 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4483 s = format (s, "2r3c-4115");
4484 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4485 s = format (s, "2r3c-mef5cf1");
4487 s = format (s, "ILLEGAL");
4492 format_policer_rate_type (u8 * s, va_list * va)
4494 u32 i = va_arg (*va, u32);
4496 if (i == SSE2_QOS_RATE_KBPS)
4497 s = format (s, "kbps");
4498 else if (i == SSE2_QOS_RATE_PPS)
4499 s = format (s, "pps");
4501 s = format (s, "ILLEGAL");
4506 format_policer_round_type (u8 * s, va_list * va)
4508 u32 i = va_arg (*va, u32);
4510 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4511 s = format (s, "closest");
4512 else if (i == SSE2_QOS_ROUND_TO_UP)
4513 s = format (s, "up");
4514 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4515 s = format (s, "down");
4517 s = format (s, "ILLEGAL");
4522 format_policer_action_type (u8 * s, va_list * va)
4524 u32 i = va_arg (*va, u32);
4526 if (i == SSE2_QOS_ACTION_DROP)
4527 s = format (s, "drop");
4528 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4529 s = format (s, "transmit");
4530 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4531 s = format (s, "mark-and-transmit");
4533 s = format (s, "ILLEGAL");
4538 format_dscp (u8 * s, va_list * va)
4540 u32 i = va_arg (*va, u32);
4545 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4549 return format (s, "ILLEGAL");
4551 s = format (s, "%s", t);
4556 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4558 vat_main_t *vam = &vat_main;
4559 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4561 if (mp->conform_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
4562 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_action.dscp);
4564 conform_dscp_str = format (0, "");
4566 if (mp->exceed_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
4567 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_action.dscp);
4569 exceed_dscp_str = format (0, "");
4571 if (mp->violate_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
4572 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_action.dscp);
4574 violate_dscp_str = format (0, "");
4576 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4577 "rate type %U, round type %U, %s rate, %s color-aware, "
4578 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4579 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4580 "conform action %U%s, exceed action %U%s, violate action %U%s",
4582 format_policer_type, mp->type,
4585 clib_net_to_host_u64 (mp->cb),
4586 clib_net_to_host_u64 (mp->eb),
4587 format_policer_rate_type, mp->rate_type,
4588 format_policer_round_type, mp->round_type,
4589 mp->single_rate ? "single" : "dual",
4590 mp->color_aware ? "is" : "not",
4591 ntohl (mp->cir_tokens_per_period),
4592 ntohl (mp->pir_tokens_per_period),
4594 ntohl (mp->current_limit),
4595 ntohl (mp->current_bucket),
4596 ntohl (mp->extended_limit),
4597 ntohl (mp->extended_bucket),
4598 clib_net_to_host_u64 (mp->last_update_time),
4599 format_policer_action_type, mp->conform_action.type,
4601 format_policer_action_type, mp->exceed_action.type,
4603 format_policer_action_type, mp->violate_action.type,
4606 vec_free (conform_dscp_str);
4607 vec_free (exceed_dscp_str);
4608 vec_free (violate_dscp_str);
4611 static void vl_api_policer_details_t_handler_json
4612 (vl_api_policer_details_t * mp)
4614 vat_main_t *vam = &vat_main;
4615 vat_json_node_t *node;
4616 u8 *rate_type_str, *round_type_str, *type_str;
4617 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4619 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4621 format (0, "%U", format_policer_round_type, mp->round_type);
4622 type_str = format (0, "%U", format_policer_type, mp->type);
4623 conform_action_str = format (0, "%U", format_policer_action_type,
4624 mp->conform_action.type);
4625 exceed_action_str = format (0, "%U", format_policer_action_type,
4626 mp->exceed_action.type);
4627 violate_action_str = format (0, "%U", format_policer_action_type,
4628 mp->violate_action.type);
4630 if (VAT_JSON_ARRAY != vam->json_tree.type)
4632 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4633 vat_json_init_array (&vam->json_tree);
4635 node = vat_json_array_add (&vam->json_tree);
4637 vat_json_init_object (node);
4638 vat_json_object_add_string_copy (node, "name", mp->name);
4639 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4640 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4641 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4642 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4643 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4644 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4645 vat_json_object_add_string_copy (node, "type", type_str);
4646 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4647 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4648 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4649 vat_json_object_add_uint (node, "cir_tokens_per_period",
4650 ntohl (mp->cir_tokens_per_period));
4651 vat_json_object_add_uint (node, "eir_tokens_per_period",
4652 ntohl (mp->pir_tokens_per_period));
4653 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4654 vat_json_object_add_uint (node, "current_bucket",
4655 ntohl (mp->current_bucket));
4656 vat_json_object_add_uint (node, "extended_limit",
4657 ntohl (mp->extended_limit));
4658 vat_json_object_add_uint (node, "extended_bucket",
4659 ntohl (mp->extended_bucket));
4660 vat_json_object_add_uint (node, "last_update_time",
4661 ntohl (mp->last_update_time));
4662 vat_json_object_add_string_copy (node, "conform_action",
4663 conform_action_str);
4664 if (mp->conform_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
4666 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_action.dscp);
4667 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4668 vec_free (dscp_str);
4670 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4671 if (mp->exceed_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
4673 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_action.dscp);
4674 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4675 vec_free (dscp_str);
4677 vat_json_object_add_string_copy (node, "violate_action",
4678 violate_action_str);
4679 if (mp->violate_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
4681 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_action.dscp);
4682 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4683 vec_free (dscp_str);
4686 vec_free (rate_type_str);
4687 vec_free (round_type_str);
4688 vec_free (type_str);
4689 vec_free (conform_action_str);
4690 vec_free (exceed_action_str);
4691 vec_free (violate_action_str);
4695 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4698 vat_main_t *vam = &vat_main;
4699 int i, count = ntohl (mp->count);
4702 print (vam->ofp, "classify table ids (%d) : ", count);
4703 for (i = 0; i < count; i++)
4705 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4706 print (vam->ofp, (i < count - 1) ? "," : "");
4708 vam->retval = ntohl (mp->retval);
4709 vam->result_ready = 1;
4713 vl_api_classify_table_ids_reply_t_handler_json
4714 (vl_api_classify_table_ids_reply_t * mp)
4716 vat_main_t *vam = &vat_main;
4717 int i, count = ntohl (mp->count);
4721 vat_json_node_t node;
4723 vat_json_init_object (&node);
4724 for (i = 0; i < count; i++)
4726 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4728 vat_json_print (vam->ofp, &node);
4729 vat_json_free (&node);
4731 vam->retval = ntohl (mp->retval);
4732 vam->result_ready = 1;
4736 vl_api_classify_table_by_interface_reply_t_handler
4737 (vl_api_classify_table_by_interface_reply_t * mp)
4739 vat_main_t *vam = &vat_main;
4742 table_id = ntohl (mp->l2_table_id);
4744 print (vam->ofp, "l2 table id : %d", table_id);
4746 print (vam->ofp, "l2 table id : No input ACL tables configured");
4747 table_id = ntohl (mp->ip4_table_id);
4749 print (vam->ofp, "ip4 table id : %d", table_id);
4751 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4752 table_id = ntohl (mp->ip6_table_id);
4754 print (vam->ofp, "ip6 table id : %d", table_id);
4756 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4757 vam->retval = ntohl (mp->retval);
4758 vam->result_ready = 1;
4762 vl_api_classify_table_by_interface_reply_t_handler_json
4763 (vl_api_classify_table_by_interface_reply_t * mp)
4765 vat_main_t *vam = &vat_main;
4766 vat_json_node_t node;
4768 vat_json_init_object (&node);
4770 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4771 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4772 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4774 vat_json_print (vam->ofp, &node);
4775 vat_json_free (&node);
4777 vam->retval = ntohl (mp->retval);
4778 vam->result_ready = 1;
4781 static void vl_api_policer_add_del_reply_t_handler
4782 (vl_api_policer_add_del_reply_t * mp)
4784 vat_main_t *vam = &vat_main;
4785 i32 retval = ntohl (mp->retval);
4786 if (vam->async_mode)
4788 vam->async_errors += (retval < 0);
4792 vam->retval = retval;
4793 vam->result_ready = 1;
4794 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4796 * Note: this is just barely thread-safe, depends on
4797 * the main thread spinning waiting for an answer...
4799 errmsg ("policer index %d", ntohl (mp->policer_index));
4803 static void vl_api_policer_add_del_reply_t_handler_json
4804 (vl_api_policer_add_del_reply_t * mp)
4806 vat_main_t *vam = &vat_main;
4807 vat_json_node_t node;
4809 vat_json_init_object (&node);
4810 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4811 vat_json_object_add_uint (&node, "policer_index",
4812 ntohl (mp->policer_index));
4814 vat_json_print (vam->ofp, &node);
4815 vat_json_free (&node);
4817 vam->retval = ntohl (mp->retval);
4818 vam->result_ready = 1;
4821 /* Format hex dump. */
4823 format_hex_bytes (u8 * s, va_list * va)
4825 u8 *bytes = va_arg (*va, u8 *);
4826 int n_bytes = va_arg (*va, int);
4829 /* Print short or long form depending on byte count. */
4830 uword short_form = n_bytes <= 32;
4831 u32 indent = format_get_indent (s);
4836 for (i = 0; i < n_bytes; i++)
4838 if (!short_form && (i % 32) == 0)
4839 s = format (s, "%08x: ", i);
4840 s = format (s, "%02x", bytes[i]);
4841 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4842 s = format (s, "\n%U", format_white_space, indent);
4849 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4852 vat_main_t *vam = &vat_main;
4853 i32 retval = ntohl (mp->retval);
4856 print (vam->ofp, "classify table info :");
4857 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4858 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4859 ntohl (mp->miss_next_index));
4860 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4861 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4862 ntohl (mp->match_n_vectors));
4863 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4864 ntohl (mp->mask_length));
4866 vam->retval = retval;
4867 vam->result_ready = 1;
4871 vl_api_classify_table_info_reply_t_handler_json
4872 (vl_api_classify_table_info_reply_t * mp)
4874 vat_main_t *vam = &vat_main;
4875 vat_json_node_t node;
4877 i32 retval = ntohl (mp->retval);
4880 vat_json_init_object (&node);
4882 vat_json_object_add_int (&node, "sessions",
4883 ntohl (mp->active_sessions));
4884 vat_json_object_add_int (&node, "nexttbl",
4885 ntohl (mp->next_table_index));
4886 vat_json_object_add_int (&node, "nextnode",
4887 ntohl (mp->miss_next_index));
4888 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4889 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4890 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4891 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4892 ntohl (mp->mask_length), 0);
4893 vat_json_object_add_string_copy (&node, "mask", s);
4895 vat_json_print (vam->ofp, &node);
4896 vat_json_free (&node);
4898 vam->retval = ntohl (mp->retval);
4899 vam->result_ready = 1;
4903 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4906 vat_main_t *vam = &vat_main;
4908 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4909 ntohl (mp->hit_next_index), ntohl (mp->advance),
4910 ntohl (mp->opaque_index));
4911 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4912 ntohl (mp->match_length));
4916 vl_api_classify_session_details_t_handler_json
4917 (vl_api_classify_session_details_t * mp)
4919 vat_main_t *vam = &vat_main;
4920 vat_json_node_t *node = NULL;
4922 if (VAT_JSON_ARRAY != vam->json_tree.type)
4924 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4925 vat_json_init_array (&vam->json_tree);
4927 node = vat_json_array_add (&vam->json_tree);
4929 vat_json_init_object (node);
4930 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
4931 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
4932 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
4934 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
4936 vat_json_object_add_string_copy (node, "match", s);
4939 static void vl_api_pg_create_interface_reply_t_handler
4940 (vl_api_pg_create_interface_reply_t * mp)
4942 vat_main_t *vam = &vat_main;
4944 vam->retval = ntohl (mp->retval);
4945 vam->result_ready = 1;
4948 static void vl_api_pg_create_interface_reply_t_handler_json
4949 (vl_api_pg_create_interface_reply_t * mp)
4951 vat_main_t *vam = &vat_main;
4952 vat_json_node_t node;
4954 i32 retval = ntohl (mp->retval);
4957 vat_json_init_object (&node);
4959 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
4961 vat_json_print (vam->ofp, &node);
4962 vat_json_free (&node);
4964 vam->retval = ntohl (mp->retval);
4965 vam->result_ready = 1;
4968 static void vl_api_policer_classify_details_t_handler
4969 (vl_api_policer_classify_details_t * mp)
4971 vat_main_t *vam = &vat_main;
4973 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4974 ntohl (mp->table_index));
4977 static void vl_api_policer_classify_details_t_handler_json
4978 (vl_api_policer_classify_details_t * mp)
4980 vat_main_t *vam = &vat_main;
4981 vat_json_node_t *node;
4983 if (VAT_JSON_ARRAY != vam->json_tree.type)
4985 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4986 vat_json_init_array (&vam->json_tree);
4988 node = vat_json_array_add (&vam->json_tree);
4990 vat_json_init_object (node);
4991 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4992 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4995 static void vl_api_flow_classify_details_t_handler
4996 (vl_api_flow_classify_details_t * mp)
4998 vat_main_t *vam = &vat_main;
5000 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5001 ntohl (mp->table_index));
5004 static void vl_api_flow_classify_details_t_handler_json
5005 (vl_api_flow_classify_details_t * mp)
5007 vat_main_t *vam = &vat_main;
5008 vat_json_node_t *node;
5010 if (VAT_JSON_ARRAY != vam->json_tree.type)
5012 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5013 vat_json_init_array (&vam->json_tree);
5015 node = vat_json_array_add (&vam->json_tree);
5017 vat_json_init_object (node);
5018 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5019 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5022 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5023 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5024 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5025 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5026 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5027 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5028 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5029 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5030 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5031 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5034 * Generate boilerplate reply handlers, which
5035 * dig the return value out of the xxx_reply_t API message,
5036 * stick it into vam->retval, and set vam->result_ready
5038 * Could also do this by pointing N message decode slots at
5039 * a single function, but that could break in subtle ways.
5042 #define foreach_standard_reply_retval_handler \
5043 _(sw_interface_set_flags_reply) \
5044 _(sw_interface_add_del_address_reply) \
5045 _(sw_interface_set_rx_mode_reply) \
5046 _(sw_interface_set_rx_placement_reply) \
5047 _(sw_interface_set_table_reply) \
5048 _(sw_interface_set_mpls_enable_reply) \
5049 _(sw_interface_set_vpath_reply) \
5050 _(sw_interface_set_vxlan_bypass_reply) \
5051 _(sw_interface_set_geneve_bypass_reply) \
5052 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5053 _(sw_interface_set_l2_bridge_reply) \
5054 _(sw_interface_set_bond_weight_reply) \
5055 _(bridge_domain_add_del_reply) \
5056 _(sw_interface_set_l2_xconnect_reply) \
5057 _(l2fib_add_del_reply) \
5058 _(l2fib_flush_int_reply) \
5059 _(l2fib_flush_bd_reply) \
5060 _(ip_route_add_del_reply) \
5061 _(ip_table_add_del_reply) \
5062 _(ip_table_replace_begin_reply) \
5063 _(ip_table_flush_reply) \
5064 _(ip_table_replace_end_reply) \
5065 _(ip_mroute_add_del_reply) \
5066 _(mpls_route_add_del_reply) \
5067 _(mpls_table_add_del_reply) \
5068 _(mpls_ip_bind_unbind_reply) \
5069 _(bier_route_add_del_reply) \
5070 _(bier_table_add_del_reply) \
5071 _(sw_interface_set_unnumbered_reply) \
5072 _(set_ip_flow_hash_reply) \
5073 _(sw_interface_ip6_enable_disable_reply) \
5074 _(l2_patch_add_del_reply) \
5075 _(sr_mpls_policy_add_reply) \
5076 _(sr_mpls_policy_mod_reply) \
5077 _(sr_mpls_policy_del_reply) \
5078 _(sr_policy_add_reply) \
5079 _(sr_policy_mod_reply) \
5080 _(sr_policy_del_reply) \
5081 _(sr_localsid_add_del_reply) \
5082 _(sr_steering_add_del_reply) \
5083 _(classify_add_del_session_reply) \
5084 _(classify_set_interface_ip_table_reply) \
5085 _(classify_set_interface_l2_tables_reply) \
5086 _(l2tpv3_set_tunnel_cookies_reply) \
5087 _(l2tpv3_interface_enable_disable_reply) \
5088 _(l2tpv3_set_lookup_key_reply) \
5089 _(l2_fib_clear_table_reply) \
5090 _(l2_interface_efp_filter_reply) \
5091 _(l2_interface_vlan_tag_rewrite_reply) \
5092 _(modify_vhost_user_if_reply) \
5093 _(delete_vhost_user_if_reply) \
5094 _(want_l2_macs_events_reply) \
5095 _(input_acl_set_interface_reply) \
5096 _(ipsec_spd_add_del_reply) \
5097 _(ipsec_interface_add_del_spd_reply) \
5098 _(ipsec_spd_entry_add_del_reply) \
5099 _(ipsec_sad_entry_add_del_reply) \
5100 _(ipsec_tunnel_if_add_del_reply) \
5101 _(ipsec_tunnel_if_set_sa_reply) \
5102 _(delete_loopback_reply) \
5103 _(bd_ip_mac_add_del_reply) \
5104 _(bd_ip_mac_flush_reply) \
5105 _(want_interface_events_reply) \
5106 _(cop_interface_enable_disable_reply) \
5107 _(cop_whitelist_enable_disable_reply) \
5108 _(sw_interface_clear_stats_reply) \
5109 _(ioam_enable_reply) \
5110 _(ioam_disable_reply) \
5111 _(one_add_del_locator_reply) \
5112 _(one_add_del_local_eid_reply) \
5113 _(one_add_del_remote_mapping_reply) \
5114 _(one_add_del_adjacency_reply) \
5115 _(one_add_del_map_resolver_reply) \
5116 _(one_add_del_map_server_reply) \
5117 _(one_enable_disable_reply) \
5118 _(one_rloc_probe_enable_disable_reply) \
5119 _(one_map_register_enable_disable_reply) \
5120 _(one_map_register_set_ttl_reply) \
5121 _(one_set_transport_protocol_reply) \
5122 _(one_map_register_fallback_threshold_reply) \
5123 _(one_pitr_set_locator_set_reply) \
5124 _(one_map_request_mode_reply) \
5125 _(one_add_del_map_request_itr_rlocs_reply) \
5126 _(one_eid_table_add_del_map_reply) \
5127 _(one_use_petr_reply) \
5128 _(one_stats_enable_disable_reply) \
5129 _(one_add_del_l2_arp_entry_reply) \
5130 _(one_add_del_ndp_entry_reply) \
5131 _(one_stats_flush_reply) \
5132 _(one_enable_disable_xtr_mode_reply) \
5133 _(one_enable_disable_pitr_mode_reply) \
5134 _(one_enable_disable_petr_mode_reply) \
5135 _(gpe_enable_disable_reply) \
5136 _(gpe_set_encap_mode_reply) \
5137 _(gpe_add_del_iface_reply) \
5138 _(gpe_add_del_native_fwd_rpath_reply) \
5139 _(af_packet_delete_reply) \
5140 _(policer_classify_set_interface_reply) \
5141 _(set_ipfix_exporter_reply) \
5142 _(set_ipfix_classify_stream_reply) \
5143 _(ipfix_classify_table_add_del_reply) \
5144 _(flow_classify_set_interface_reply) \
5145 _(sw_interface_span_enable_disable_reply) \
5146 _(pg_capture_reply) \
5147 _(pg_enable_disable_reply) \
5148 _(ip_source_and_port_range_check_add_del_reply) \
5149 _(ip_source_and_port_range_check_interface_add_del_reply)\
5150 _(delete_subif_reply) \
5151 _(l2_interface_pbb_tag_rewrite_reply) \
5153 _(feature_enable_disable_reply) \
5154 _(feature_gso_enable_disable_reply) \
5155 _(sw_interface_tag_add_del_reply) \
5156 _(sw_interface_add_del_mac_address_reply) \
5157 _(hw_interface_set_mtu_reply) \
5158 _(p2p_ethernet_add_reply) \
5159 _(p2p_ethernet_del_reply) \
5160 _(lldp_config_reply) \
5161 _(sw_interface_set_lldp_reply) \
5162 _(tcp_configure_src_addresses_reply) \
5163 _(session_rule_add_del_reply) \
5164 _(ip_container_proxy_add_del_reply) \
5165 _(output_acl_set_interface_reply) \
5166 _(qos_record_enable_disable_reply)
5169 static void vl_api_##n##_t_handler \
5170 (vl_api_##n##_t * mp) \
5172 vat_main_t * vam = &vat_main; \
5173 i32 retval = ntohl(mp->retval); \
5174 if (vam->async_mode) { \
5175 vam->async_errors += (retval < 0); \
5177 vam->retval = retval; \
5178 vam->result_ready = 1; \
5181 foreach_standard_reply_retval_handler;
5185 static void vl_api_##n##_t_handler_json \
5186 (vl_api_##n##_t * mp) \
5188 vat_main_t * vam = &vat_main; \
5189 vat_json_node_t node; \
5190 vat_json_init_object(&node); \
5191 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5192 vat_json_print(vam->ofp, &node); \
5193 vam->retval = ntohl(mp->retval); \
5194 vam->result_ready = 1; \
5196 foreach_standard_reply_retval_handler;
5200 * Table of message reply handlers, must include boilerplate handlers
5204 #define foreach_vpe_api_reply_msg \
5205 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5206 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5207 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5208 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5209 _(CONTROL_PING_REPLY, control_ping_reply) \
5210 _(CLI_REPLY, cli_reply) \
5211 _(CLI_INBAND_REPLY, cli_inband_reply) \
5212 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5213 sw_interface_add_del_address_reply) \
5214 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5215 _(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
5216 _(SW_INTERFACE_RX_PLACEMENT_DETAILS, sw_interface_rx_placement_details) \
5217 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5218 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5219 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5220 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5221 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5222 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5223 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5224 sw_interface_set_l2_xconnect_reply) \
5225 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5226 sw_interface_set_l2_bridge_reply) \
5227 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5228 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5229 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5230 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5231 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5232 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5233 _(L2_FLAGS_REPLY, l2_flags_reply) \
5234 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5235 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5236 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5237 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5238 _(VIRTIO_PCI_CREATE_REPLY, virtio_pci_create_reply) \
5239 _(VIRTIO_PCI_DELETE_REPLY, virtio_pci_delete_reply) \
5240 _(SW_INTERFACE_VIRTIO_PCI_DETAILS, sw_interface_virtio_pci_details) \
5241 _(BOND_CREATE_REPLY, bond_create_reply) \
5242 _(BOND_DELETE_REPLY, bond_delete_reply) \
5243 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5244 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5245 _(SW_INTERFACE_SET_BOND_WEIGHT_REPLY, sw_interface_set_bond_weight_reply) \
5246 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5247 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5248 _(IP_ROUTE_ADD_DEL_REPLY, ip_route_add_del_reply) \
5249 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5250 _(IP_TABLE_REPLACE_BEGIN_REPLY, ip_table_replace_begin_reply) \
5251 _(IP_TABLE_FLUSH_REPLY, ip_table_flush_reply) \
5252 _(IP_TABLE_REPLACE_END_REPLY, ip_table_replace_end_reply) \
5253 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5254 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5255 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5256 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5257 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5258 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5259 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5260 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5261 sw_interface_set_unnumbered_reply) \
5262 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5263 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5264 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5265 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5266 sw_interface_ip6_enable_disable_reply) \
5267 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5268 _(SR_MPLS_POLICY_ADD_REPLY, sr_mpls_policy_add_reply) \
5269 _(SR_MPLS_POLICY_MOD_REPLY, sr_mpls_policy_mod_reply) \
5270 _(SR_MPLS_POLICY_DEL_REPLY, sr_mpls_policy_del_reply) \
5271 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5272 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5273 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5274 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5275 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5276 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5277 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5278 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5279 classify_set_interface_ip_table_reply) \
5280 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5281 classify_set_interface_l2_tables_reply) \
5282 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5283 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5284 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5285 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5286 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5287 l2tpv3_interface_enable_disable_reply) \
5288 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5289 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5290 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5291 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5292 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5293 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5294 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5295 _(GRE_TUNNEL_ADD_DEL_REPLY, gre_tunnel_add_del_reply) \
5296 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5297 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5298 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5299 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5300 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5301 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5302 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5303 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5304 _(SHOW_VERSION_REPLY, show_version_reply) \
5305 _(SHOW_THREADS_REPLY, show_threads_reply) \
5306 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5307 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5308 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5309 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5310 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5311 _(L2_MACS_EVENT, l2_macs_event) \
5312 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5313 _(IP_ADDRESS_DETAILS, ip_address_details) \
5314 _(IP_DETAILS, ip_details) \
5315 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5316 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5317 _(IPSEC_SPD_ENTRY_ADD_DEL_REPLY, ipsec_spd_entry_add_del_reply) \
5318 _(IPSEC_SAD_ENTRY_ADD_DEL_REPLY, ipsec_sad_entry_add_del_reply) \
5319 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5320 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5321 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5322 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5323 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5324 _(BD_IP_MAC_FLUSH_REPLY, bd_ip_mac_flush_reply) \
5325 _(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
5326 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5327 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5328 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5329 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5330 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5331 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5332 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5333 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5334 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5335 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5336 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5337 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5338 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5339 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5340 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5341 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5342 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5343 one_map_register_enable_disable_reply) \
5344 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5345 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5346 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5347 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5348 one_map_register_fallback_threshold_reply) \
5349 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5350 one_rloc_probe_enable_disable_reply) \
5351 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5352 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5353 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5354 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5355 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5356 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5357 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5358 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5359 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5360 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5361 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5362 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5363 _(ONE_STATS_DETAILS, one_stats_details) \
5364 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5365 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5366 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5367 show_one_stats_enable_disable_reply) \
5368 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5369 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5370 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5371 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5372 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5373 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5374 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5375 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5376 one_enable_disable_pitr_mode_reply) \
5377 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5378 one_enable_disable_petr_mode_reply) \
5379 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5380 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5381 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5382 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5383 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5384 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5385 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5386 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5387 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5388 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5389 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5390 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5391 gpe_add_del_native_fwd_rpath_reply) \
5392 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5393 gpe_fwd_entry_path_details) \
5394 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5395 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5396 one_add_del_map_request_itr_rlocs_reply) \
5397 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5398 one_get_map_request_itr_rlocs_reply) \
5399 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5400 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5401 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5402 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5403 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5404 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5405 show_one_map_register_state_reply) \
5406 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5407 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5408 show_one_map_register_fallback_threshold_reply) \
5409 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5410 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5411 _(AF_PACKET_DETAILS, af_packet_details) \
5412 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5413 _(POLICER_DETAILS, policer_details) \
5414 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5415 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5416 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5417 _(MPLS_TABLE_DETAILS, mpls_table_details) \
5418 _(MPLS_ROUTE_DETAILS, mpls_route_details) \
5419 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5420 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5421 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5422 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5423 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5424 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5425 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5426 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5427 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5428 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5429 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5430 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5431 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5432 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5433 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5434 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5435 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5436 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5437 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5438 ip_source_and_port_range_check_add_del_reply) \
5439 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5440 ip_source_and_port_range_check_interface_add_del_reply) \
5441 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5442 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5443 _(SET_PUNT_REPLY, set_punt_reply) \
5444 _(IP_TABLE_DETAILS, ip_table_details) \
5445 _(IP_ROUTE_DETAILS, ip_route_details) \
5446 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5447 _(FEATURE_GSO_ENABLE_DISABLE_REPLY, feature_gso_enable_disable_reply) \
5448 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5449 _(SW_INTERFACE_ADD_DEL_MAC_ADDRESS_REPLY, sw_interface_add_del_mac_address_reply) \
5450 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5451 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5452 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5453 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5454 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5455 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5456 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5457 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5458 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5459 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5460 _(SESSION_RULES_DETAILS, session_rules_details) \
5461 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5462 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5463 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply)
5465 #define foreach_standalone_reply_msg \
5466 _(SW_INTERFACE_EVENT, sw_interface_event)
5474 #define STR_VTR_OP_CASE(op) \
5475 case L2_VTR_ ## op: \
5479 str_vtr_op (u32 vtr_op)
5483 STR_VTR_OP_CASE (DISABLED);
5484 STR_VTR_OP_CASE (PUSH_1);
5485 STR_VTR_OP_CASE (PUSH_2);
5486 STR_VTR_OP_CASE (POP_1);
5487 STR_VTR_OP_CASE (POP_2);
5488 STR_VTR_OP_CASE (TRANSLATE_1_1);
5489 STR_VTR_OP_CASE (TRANSLATE_1_2);
5490 STR_VTR_OP_CASE (TRANSLATE_2_1);
5491 STR_VTR_OP_CASE (TRANSLATE_2_2);
5498 dump_sub_interface_table (vat_main_t * vam)
5500 const sw_interface_subif_t *sub = NULL;
5502 if (vam->json_output)
5505 ("JSON output supported only for VPE API calls and dump_stats_table");
5510 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5511 "Interface", "sw_if_index",
5512 "sub id", "dot1ad", "tags", "outer id",
5513 "inner id", "exact", "default", "outer any", "inner any");
5515 vec_foreach (sub, vam->sw_if_subif_table)
5518 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5519 sub->interface_name,
5521 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5522 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5523 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5524 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5525 if (sub->vtr_op != L2_VTR_DISABLED)
5528 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5529 "tag1: %d tag2: %d ]",
5530 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5531 sub->vtr_tag1, sub->vtr_tag2);
5539 name_sort_cmp (void *a1, void *a2)
5541 name_sort_t *n1 = a1;
5542 name_sort_t *n2 = a2;
5544 return strcmp ((char *) n1->name, (char *) n2->name);
5548 dump_interface_table (vat_main_t * vam)
5551 name_sort_t *nses = 0, *ns;
5553 if (vam->json_output)
5556 ("JSON output supported only for VPE API calls and dump_stats_table");
5561 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5563 vec_add2 (nses, ns, 1);
5564 ns->name = (u8 *)(p->key);
5565 ns->value = (u32) p->value[0];
5569 vec_sort_with_function (nses, name_sort_cmp);
5571 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5572 vec_foreach (ns, nses)
5574 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5581 dump_ip_table (vat_main_t * vam, int is_ipv6)
5583 const ip_details_t *det = NULL;
5584 const ip_address_details_t *address = NULL;
5587 print (vam->ofp, "%-12s", "sw_if_index");
5589 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5596 print (vam->ofp, "%-12d", i);
5597 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5602 vec_foreach (address, det->addr)
5606 is_ipv6 ? format_ip6_address : format_ip4_address,
5607 address->ip, address->prefix_length);
5615 dump_ipv4_table (vat_main_t * vam)
5617 if (vam->json_output)
5620 ("JSON output supported only for VPE API calls and dump_stats_table");
5624 return dump_ip_table (vam, 0);
5628 dump_ipv6_table (vat_main_t * vam)
5630 if (vam->json_output)
5633 ("JSON output supported only for VPE API calls and dump_stats_table");
5637 return dump_ip_table (vam, 1);
5641 * Pass CLI buffers directly in the CLI_INBAND API message,
5642 * instead of an additional shared memory area.
5645 exec_inband (vat_main_t * vam)
5647 vl_api_cli_inband_t *mp;
5648 unformat_input_t *i = vam->input;
5651 if (vec_len (i->buffer) == 0)
5654 if (vam->exec_mode == 0 && unformat (i, "mode"))
5659 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5666 * In order for the CLI command to work, it
5667 * must be a vector ending in \n, not a C-string ending
5670 M2 (CLI_INBAND, mp, vec_len (vam->input->buffer));
5671 vl_api_vec_to_api_string (vam->input->buffer, &mp->cmd);
5675 /* json responses may or may not include a useful reply... */
5676 if (vec_len (vam->cmd_reply))
5677 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
5682 exec (vat_main_t * vam)
5684 return exec_inband (vam);
5688 api_create_loopback (vat_main_t * vam)
5690 unformat_input_t *i = vam->input;
5691 vl_api_create_loopback_t *mp;
5692 vl_api_create_loopback_instance_t *mp_lbi;
5695 u8 is_specified = 0;
5696 u32 user_instance = 0;
5699 clib_memset (mac_address, 0, sizeof (mac_address));
5701 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5703 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5705 if (unformat (i, "instance %d", &user_instance))
5713 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5714 mp_lbi->is_specified = is_specified;
5716 mp_lbi->user_instance = htonl (user_instance);
5718 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5723 /* Construct the API message */
5724 M (CREATE_LOOPBACK, mp);
5726 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5735 api_delete_loopback (vat_main_t * vam)
5737 unformat_input_t *i = vam->input;
5738 vl_api_delete_loopback_t *mp;
5739 u32 sw_if_index = ~0;
5742 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5744 if (unformat (i, "sw_if_index %d", &sw_if_index))
5750 if (sw_if_index == ~0)
5752 errmsg ("missing sw_if_index");
5756 /* Construct the API message */
5757 M (DELETE_LOOPBACK, mp);
5758 mp->sw_if_index = ntohl (sw_if_index);
5766 api_want_interface_events (vat_main_t * vam)
5768 unformat_input_t *i = vam->input;
5769 vl_api_want_interface_events_t *mp;
5773 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5775 if (unformat (i, "enable"))
5777 else if (unformat (i, "disable"))
5785 errmsg ("missing enable|disable");
5789 M (WANT_INTERFACE_EVENTS, mp);
5790 mp->enable_disable = enable;
5792 vam->interface_event_display = enable;
5800 /* Note: non-static, called once to set up the initial intfc table */
5802 api_sw_interface_dump (vat_main_t * vam)
5804 vl_api_sw_interface_dump_t *mp;
5805 vl_api_control_ping_t *mp_ping;
5807 name_sort_t *nses = 0, *ns;
5808 sw_interface_subif_t *sub = NULL;
5811 /* Toss the old name table */
5813 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5815 vec_add2 (nses, ns, 1);
5816 ns->name = (u8 *)(p->key);
5817 ns->value = (u32) p->value[0];
5821 hash_free (vam->sw_if_index_by_interface_name);
5823 vec_foreach (ns, nses) vec_free (ns->name);
5827 vec_foreach (sub, vam->sw_if_subif_table)
5829 vec_free (sub->interface_name);
5831 vec_free (vam->sw_if_subif_table);
5833 /* recreate the interface name hash table */
5834 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5837 * Ask for all interface names. Otherwise, the epic catalog of
5838 * name filters becomes ridiculously long, and vat ends up needing
5839 * to be taught about new interface types.
5841 M (SW_INTERFACE_DUMP, mp);
5844 /* Use a control ping for synchronization */
5845 MPING (CONTROL_PING, mp_ping);
5853 api_sw_interface_set_flags (vat_main_t * vam)
5855 unformat_input_t *i = vam->input;
5856 vl_api_sw_interface_set_flags_t *mp;
5858 u8 sw_if_index_set = 0;
5862 /* Parse args required to build the message */
5863 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5865 if (unformat (i, "admin-up"))
5867 else if (unformat (i, "admin-down"))
5870 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5871 sw_if_index_set = 1;
5872 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5873 sw_if_index_set = 1;
5878 if (sw_if_index_set == 0)
5880 errmsg ("missing interface name or sw_if_index");
5884 /* Construct the API message */
5885 M (SW_INTERFACE_SET_FLAGS, mp);
5886 mp->sw_if_index = ntohl (sw_if_index);
5887 mp->flags = ntohl ((admin_up) ? IF_STATUS_API_FLAG_ADMIN_UP : 0);
5892 /* Wait for a reply, return the good/bad news... */
5898 api_sw_interface_set_rx_mode (vat_main_t * vam)
5900 unformat_input_t *i = vam->input;
5901 vl_api_sw_interface_set_rx_mode_t *mp;
5903 u8 sw_if_index_set = 0;
5905 u8 queue_id_valid = 0;
5907 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
5909 /* Parse args required to build the message */
5910 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5912 if (unformat (i, "queue %d", &queue_id))
5914 else if (unformat (i, "polling"))
5915 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
5916 else if (unformat (i, "interrupt"))
5917 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
5918 else if (unformat (i, "adaptive"))
5919 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
5921 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5922 sw_if_index_set = 1;
5923 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5924 sw_if_index_set = 1;
5929 if (sw_if_index_set == 0)
5931 errmsg ("missing interface name or sw_if_index");
5934 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
5936 errmsg ("missing rx-mode");
5940 /* Construct the API message */
5941 M (SW_INTERFACE_SET_RX_MODE, mp);
5942 mp->sw_if_index = ntohl (sw_if_index);
5943 mp->mode = (vl_api_rx_mode_t) mode;
5944 mp->queue_id_valid = queue_id_valid;
5945 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
5950 /* Wait for a reply, return the good/bad news... */
5956 api_sw_interface_set_rx_placement (vat_main_t * vam)
5958 unformat_input_t *i = vam->input;
5959 vl_api_sw_interface_set_rx_placement_t *mp;
5961 u8 sw_if_index_set = 0;
5964 u32 queue_id, thread_index;
5966 /* Parse args required to build the message */
5967 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5969 if (unformat (i, "queue %d", &queue_id))
5971 else if (unformat (i, "main"))
5973 else if (unformat (i, "worker %d", &thread_index))
5976 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5977 sw_if_index_set = 1;
5978 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5979 sw_if_index_set = 1;
5984 if (sw_if_index_set == 0)
5986 errmsg ("missing interface name or sw_if_index");
5992 /* Construct the API message */
5993 M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
5994 mp->sw_if_index = ntohl (sw_if_index);
5995 mp->worker_id = ntohl (thread_index);
5996 mp->queue_id = ntohl (queue_id);
5997 mp->is_main = is_main;
6001 /* Wait for a reply, return the good/bad news... */
6006 static void vl_api_sw_interface_rx_placement_details_t_handler
6007 (vl_api_sw_interface_rx_placement_details_t * mp)
6009 vat_main_t *vam = &vat_main;
6010 u32 worker_id = ntohl (mp->worker_id);
6013 "\n%-11d %-11s %-6d %-5d %-9s",
6014 ntohl (mp->sw_if_index), (worker_id == 0) ? "main" : "worker",
6015 worker_id, ntohl (mp->queue_id),
6017 1) ? "polling" : ((mp->mode == 2) ? "interrupt" : "adaptive"));
6020 static void vl_api_sw_interface_rx_placement_details_t_handler_json
6021 (vl_api_sw_interface_rx_placement_details_t * mp)
6023 vat_main_t *vam = &vat_main;
6024 vat_json_node_t *node = NULL;
6026 if (VAT_JSON_ARRAY != vam->json_tree.type)
6028 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
6029 vat_json_init_array (&vam->json_tree);
6031 node = vat_json_array_add (&vam->json_tree);
6033 vat_json_init_object (node);
6034 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
6035 vat_json_object_add_uint (node, "worker_id", ntohl (mp->worker_id));
6036 vat_json_object_add_uint (node, "queue_id", ntohl (mp->queue_id));
6037 vat_json_object_add_uint (node, "mode", mp->mode);
6041 api_sw_interface_rx_placement_dump (vat_main_t * vam)
6043 unformat_input_t *i = vam->input;
6044 vl_api_sw_interface_rx_placement_dump_t *mp;
6045 vl_api_control_ping_t *mp_ping;
6048 u8 sw_if_index_set = 0;
6050 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6052 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6054 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6061 "\n%-11s %-11s %-6s %-5s %-4s",
6062 "sw_if_index", "main/worker", "thread", "queue", "mode");
6064 /* Dump Interface rx placement */
6065 M (SW_INTERFACE_RX_PLACEMENT_DUMP, mp);
6067 if (sw_if_index_set)
6068 mp->sw_if_index = htonl (sw_if_index);
6070 mp->sw_if_index = ~0;
6074 /* Use a control ping for synchronization */
6075 MPING (CONTROL_PING, mp_ping);
6083 api_sw_interface_clear_stats (vat_main_t * vam)
6085 unformat_input_t *i = vam->input;
6086 vl_api_sw_interface_clear_stats_t *mp;
6088 u8 sw_if_index_set = 0;
6091 /* Parse args required to build the message */
6092 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6094 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6095 sw_if_index_set = 1;
6096 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6097 sw_if_index_set = 1;
6102 /* Construct the API message */
6103 M (SW_INTERFACE_CLEAR_STATS, mp);
6105 if (sw_if_index_set == 1)
6106 mp->sw_if_index = ntohl (sw_if_index);
6108 mp->sw_if_index = ~0;
6113 /* Wait for a reply, return the good/bad news... */
6119 api_sw_interface_add_del_address (vat_main_t * vam)
6121 unformat_input_t *i = vam->input;
6122 vl_api_sw_interface_add_del_address_t *mp;
6124 u8 sw_if_index_set = 0;
6125 u8 is_add = 1, del_all = 0;
6126 u32 address_length = 0;
6127 u8 v4_address_set = 0;
6128 u8 v6_address_set = 0;
6129 ip4_address_t v4address;
6130 ip6_address_t v6address;
6133 /* Parse args required to build the message */
6134 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6136 if (unformat (i, "del-all"))
6138 else if (unformat (i, "del"))
6141 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6142 sw_if_index_set = 1;
6143 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6144 sw_if_index_set = 1;
6145 else if (unformat (i, "%U/%d",
6146 unformat_ip4_address, &v4address, &address_length))
6148 else if (unformat (i, "%U/%d",
6149 unformat_ip6_address, &v6address, &address_length))
6155 if (sw_if_index_set == 0)
6157 errmsg ("missing interface name or sw_if_index");
6160 if (v4_address_set && v6_address_set)
6162 errmsg ("both v4 and v6 addresses set");
6165 if (!v4_address_set && !v6_address_set && !del_all)
6167 errmsg ("no addresses set");
6171 /* Construct the API message */
6172 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6174 mp->sw_if_index = ntohl (sw_if_index);
6175 mp->is_add = is_add;
6176 mp->del_all = del_all;
6179 mp->prefix.address.af = ADDRESS_IP6;
6180 clib_memcpy (mp->prefix.address.un.ip6, &v6address, sizeof (v6address));
6184 mp->prefix.address.af = ADDRESS_IP4;
6185 clib_memcpy (mp->prefix.address.un.ip4, &v4address, sizeof (v4address));
6187 mp->prefix.len = address_length;
6192 /* Wait for a reply, return good/bad news */
6198 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6200 unformat_input_t *i = vam->input;
6201 vl_api_sw_interface_set_mpls_enable_t *mp;
6203 u8 sw_if_index_set = 0;
6207 /* Parse args required to build the message */
6208 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6210 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6211 sw_if_index_set = 1;
6212 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6213 sw_if_index_set = 1;
6214 else if (unformat (i, "disable"))
6216 else if (unformat (i, "dis"))
6222 if (sw_if_index_set == 0)
6224 errmsg ("missing interface name or sw_if_index");
6228 /* Construct the API message */
6229 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6231 mp->sw_if_index = ntohl (sw_if_index);
6232 mp->enable = enable;
6237 /* Wait for a reply... */
6243 api_sw_interface_set_table (vat_main_t * vam)
6245 unformat_input_t *i = vam->input;
6246 vl_api_sw_interface_set_table_t *mp;
6247 u32 sw_if_index, vrf_id = 0;
6248 u8 sw_if_index_set = 0;
6252 /* Parse args required to build the message */
6253 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6255 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6256 sw_if_index_set = 1;
6257 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6258 sw_if_index_set = 1;
6259 else if (unformat (i, "vrf %d", &vrf_id))
6261 else if (unformat (i, "ipv6"))
6267 if (sw_if_index_set == 0)
6269 errmsg ("missing interface name or sw_if_index");
6273 /* Construct the API message */
6274 M (SW_INTERFACE_SET_TABLE, mp);
6276 mp->sw_if_index = ntohl (sw_if_index);
6277 mp->is_ipv6 = is_ipv6;
6278 mp->vrf_id = ntohl (vrf_id);
6283 /* Wait for a reply... */
6288 static void vl_api_sw_interface_get_table_reply_t_handler
6289 (vl_api_sw_interface_get_table_reply_t * mp)
6291 vat_main_t *vam = &vat_main;
6293 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6295 vam->retval = ntohl (mp->retval);
6296 vam->result_ready = 1;
6300 static void vl_api_sw_interface_get_table_reply_t_handler_json
6301 (vl_api_sw_interface_get_table_reply_t * mp)
6303 vat_main_t *vam = &vat_main;
6304 vat_json_node_t node;
6306 vat_json_init_object (&node);
6307 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6308 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6310 vat_json_print (vam->ofp, &node);
6311 vat_json_free (&node);
6313 vam->retval = ntohl (mp->retval);
6314 vam->result_ready = 1;
6318 api_sw_interface_get_table (vat_main_t * vam)
6320 unformat_input_t *i = vam->input;
6321 vl_api_sw_interface_get_table_t *mp;
6323 u8 sw_if_index_set = 0;
6327 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6329 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6330 sw_if_index_set = 1;
6331 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6332 sw_if_index_set = 1;
6333 else if (unformat (i, "ipv6"))
6339 if (sw_if_index_set == 0)
6341 errmsg ("missing interface name or sw_if_index");
6345 M (SW_INTERFACE_GET_TABLE, mp);
6346 mp->sw_if_index = htonl (sw_if_index);
6347 mp->is_ipv6 = is_ipv6;
6355 api_sw_interface_set_vpath (vat_main_t * vam)
6357 unformat_input_t *i = vam->input;
6358 vl_api_sw_interface_set_vpath_t *mp;
6359 u32 sw_if_index = 0;
6360 u8 sw_if_index_set = 0;
6364 /* Parse args required to build the message */
6365 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6367 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6368 sw_if_index_set = 1;
6369 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6370 sw_if_index_set = 1;
6371 else if (unformat (i, "enable"))
6373 else if (unformat (i, "disable"))
6379 if (sw_if_index_set == 0)
6381 errmsg ("missing interface name or sw_if_index");
6385 /* Construct the API message */
6386 M (SW_INTERFACE_SET_VPATH, mp);
6388 mp->sw_if_index = ntohl (sw_if_index);
6389 mp->enable = is_enable;
6394 /* Wait for a reply... */
6400 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6402 unformat_input_t *i = vam->input;
6403 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6404 u32 sw_if_index = 0;
6405 u8 sw_if_index_set = 0;
6410 /* Parse args required to build the message */
6411 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6413 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6414 sw_if_index_set = 1;
6415 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6416 sw_if_index_set = 1;
6417 else if (unformat (i, "enable"))
6419 else if (unformat (i, "disable"))
6421 else if (unformat (i, "ip4"))
6423 else if (unformat (i, "ip6"))
6429 if (sw_if_index_set == 0)
6431 errmsg ("missing interface name or sw_if_index");
6435 /* Construct the API message */
6436 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6438 mp->sw_if_index = ntohl (sw_if_index);
6439 mp->enable = is_enable;
6440 mp->is_ipv6 = is_ipv6;
6445 /* Wait for a reply... */
6451 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6453 unformat_input_t *i = vam->input;
6454 vl_api_sw_interface_set_geneve_bypass_t *mp;
6455 u32 sw_if_index = 0;
6456 u8 sw_if_index_set = 0;
6461 /* Parse args required to build the message */
6462 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6464 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6465 sw_if_index_set = 1;
6466 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6467 sw_if_index_set = 1;
6468 else if (unformat (i, "enable"))
6470 else if (unformat (i, "disable"))
6472 else if (unformat (i, "ip4"))
6474 else if (unformat (i, "ip6"))
6480 if (sw_if_index_set == 0)
6482 errmsg ("missing interface name or sw_if_index");
6486 /* Construct the API message */
6487 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6489 mp->sw_if_index = ntohl (sw_if_index);
6490 mp->enable = is_enable;
6491 mp->is_ipv6 = is_ipv6;
6496 /* Wait for a reply... */
6502 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6504 unformat_input_t *i = vam->input;
6505 vl_api_sw_interface_set_l2_xconnect_t *mp;
6507 u8 rx_sw_if_index_set = 0;
6509 u8 tx_sw_if_index_set = 0;
6513 /* Parse args required to build the message */
6514 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6516 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6517 rx_sw_if_index_set = 1;
6518 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6519 tx_sw_if_index_set = 1;
6520 else if (unformat (i, "rx"))
6522 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6524 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6526 rx_sw_if_index_set = 1;
6531 else if (unformat (i, "tx"))
6533 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6535 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6537 tx_sw_if_index_set = 1;
6542 else if (unformat (i, "enable"))
6544 else if (unformat (i, "disable"))
6550 if (rx_sw_if_index_set == 0)
6552 errmsg ("missing rx interface name or rx_sw_if_index");
6556 if (enable && (tx_sw_if_index_set == 0))
6558 errmsg ("missing tx interface name or tx_sw_if_index");
6562 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6564 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6565 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6566 mp->enable = enable;
6574 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6576 unformat_input_t *i = vam->input;
6577 vl_api_sw_interface_set_l2_bridge_t *mp;
6578 vl_api_l2_port_type_t port_type;
6580 u8 rx_sw_if_index_set = 0;
6587 port_type = L2_API_PORT_TYPE_NORMAL;
6589 /* Parse args required to build the message */
6590 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6592 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6593 rx_sw_if_index_set = 1;
6594 else if (unformat (i, "bd_id %d", &bd_id))
6598 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6599 rx_sw_if_index_set = 1;
6600 else if (unformat (i, "shg %d", &shg))
6602 else if (unformat (i, "bvi"))
6603 port_type = L2_API_PORT_TYPE_BVI;
6604 else if (unformat (i, "uu-fwd"))
6605 port_type = L2_API_PORT_TYPE_UU_FWD;
6606 else if (unformat (i, "enable"))
6608 else if (unformat (i, "disable"))
6614 if (rx_sw_if_index_set == 0)
6616 errmsg ("missing rx interface name or sw_if_index");
6620 if (enable && (bd_id_set == 0))
6622 errmsg ("missing bridge domain");
6626 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6628 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6629 mp->bd_id = ntohl (bd_id);
6631 mp->port_type = ntohl (port_type);
6632 mp->enable = enable;
6640 api_bridge_domain_dump (vat_main_t * vam)
6642 unformat_input_t *i = vam->input;
6643 vl_api_bridge_domain_dump_t *mp;
6644 vl_api_control_ping_t *mp_ping;
6648 /* Parse args required to build the message */
6649 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6651 if (unformat (i, "bd_id %d", &bd_id))
6657 M (BRIDGE_DOMAIN_DUMP, mp);
6658 mp->bd_id = ntohl (bd_id);
6661 /* Use a control ping for synchronization */
6662 MPING (CONTROL_PING, mp_ping);
6670 api_bridge_domain_add_del (vat_main_t * vam)
6672 unformat_input_t *i = vam->input;
6673 vl_api_bridge_domain_add_del_t *mp;
6676 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6681 /* Parse args required to build the message */
6682 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6684 if (unformat (i, "bd_id %d", &bd_id))
6686 else if (unformat (i, "flood %d", &flood))
6688 else if (unformat (i, "uu-flood %d", &uu_flood))
6690 else if (unformat (i, "forward %d", &forward))
6692 else if (unformat (i, "learn %d", &learn))
6694 else if (unformat (i, "arp-term %d", &arp_term))
6696 else if (unformat (i, "mac-age %d", &mac_age))
6698 else if (unformat (i, "bd-tag %s", &bd_tag))
6700 else if (unformat (i, "del"))
6703 flood = uu_flood = forward = learn = 0;
6711 errmsg ("missing bridge domain");
6718 errmsg ("mac age must be less than 256 ");
6723 if ((bd_tag) && (vec_len (bd_tag) > 63))
6725 errmsg ("bd-tag cannot be longer than 63");
6730 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6732 mp->bd_id = ntohl (bd_id);
6734 mp->uu_flood = uu_flood;
6735 mp->forward = forward;
6737 mp->arp_term = arp_term;
6738 mp->is_add = is_add;
6739 mp->mac_age = (u8) mac_age;
6742 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
6743 mp->bd_tag[vec_len (bd_tag)] = 0;
6754 api_l2fib_flush_bd (vat_main_t * vam)
6756 unformat_input_t *i = vam->input;
6757 vl_api_l2fib_flush_bd_t *mp;
6761 /* Parse args required to build the message */
6762 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6764 if (unformat (i, "bd_id %d", &bd_id));
6771 errmsg ("missing bridge domain");
6775 M (L2FIB_FLUSH_BD, mp);
6777 mp->bd_id = htonl (bd_id);
6785 api_l2fib_flush_int (vat_main_t * vam)
6787 unformat_input_t *i = vam->input;
6788 vl_api_l2fib_flush_int_t *mp;
6789 u32 sw_if_index = ~0;
6792 /* Parse args required to build the message */
6793 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6795 if (unformat (i, "sw_if_index %d", &sw_if_index));
6797 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6802 if (sw_if_index == ~0)
6804 errmsg ("missing interface name or sw_if_index");
6808 M (L2FIB_FLUSH_INT, mp);
6810 mp->sw_if_index = ntohl (sw_if_index);
6818 api_l2fib_add_del (vat_main_t * vam)
6820 unformat_input_t *i = vam->input;
6821 vl_api_l2fib_add_del_t *mp;
6827 u32 sw_if_index = 0;
6828 u8 sw_if_index_set = 0;
6837 /* Parse args required to build the message */
6838 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6840 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
6842 else if (unformat (i, "bd_id %d", &bd_id))
6844 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6845 sw_if_index_set = 1;
6846 else if (unformat (i, "sw_if"))
6848 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6851 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6852 sw_if_index_set = 1;
6857 else if (unformat (i, "static"))
6859 else if (unformat (i, "filter"))
6864 else if (unformat (i, "bvi"))
6869 else if (unformat (i, "del"))
6871 else if (unformat (i, "count %d", &count))
6879 errmsg ("missing mac address");
6885 errmsg ("missing bridge domain");
6889 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
6891 errmsg ("missing interface name or sw_if_index");
6897 /* Turn on async mode */
6898 vam->async_mode = 1;
6899 vam->async_errors = 0;
6900 before = vat_time_now (vam);
6903 for (j = 0; j < count; j++)
6905 M (L2FIB_ADD_DEL, mp);
6907 clib_memcpy (mp->mac, mac, 6);
6908 mp->bd_id = ntohl (bd_id);
6909 mp->is_add = is_add;
6910 mp->sw_if_index = ntohl (sw_if_index);
6914 mp->static_mac = static_mac;
6915 mp->filter_mac = filter_mac;
6916 mp->bvi_mac = bvi_mac;
6918 increment_mac_address (mac);
6925 vl_api_control_ping_t *mp_ping;
6928 /* Shut off async mode */
6929 vam->async_mode = 0;
6931 MPING (CONTROL_PING, mp_ping);
6934 timeout = vat_time_now (vam) + 1.0;
6935 while (vat_time_now (vam) < timeout)
6936 if (vam->result_ready == 1)
6941 if (vam->retval == -99)
6944 if (vam->async_errors > 0)
6946 errmsg ("%d asynchronous errors", vam->async_errors);
6949 vam->async_errors = 0;
6950 after = vat_time_now (vam);
6952 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6953 count, after - before, count / (after - before));
6959 /* Wait for a reply... */
6963 /* Return the good/bad news */
6964 return (vam->retval);
6968 api_bridge_domain_set_mac_age (vat_main_t * vam)
6970 unformat_input_t *i = vam->input;
6971 vl_api_bridge_domain_set_mac_age_t *mp;
6976 /* Parse args required to build the message */
6977 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6979 if (unformat (i, "bd_id %d", &bd_id));
6980 else if (unformat (i, "mac-age %d", &mac_age));
6987 errmsg ("missing bridge domain");
6993 errmsg ("mac age must be less than 256 ");
6997 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
6999 mp->bd_id = htonl (bd_id);
7000 mp->mac_age = (u8) mac_age;
7008 api_l2_flags (vat_main_t * vam)
7010 unformat_input_t *i = vam->input;
7011 vl_api_l2_flags_t *mp;
7014 u8 sw_if_index_set = 0;
7018 /* Parse args required to build the message */
7019 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7021 if (unformat (i, "sw_if_index %d", &sw_if_index))
7022 sw_if_index_set = 1;
7023 else if (unformat (i, "sw_if"))
7025 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7028 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7029 sw_if_index_set = 1;
7034 else if (unformat (i, "learn"))
7036 else if (unformat (i, "forward"))
7038 else if (unformat (i, "flood"))
7040 else if (unformat (i, "uu-flood"))
7041 flags |= L2_UU_FLOOD;
7042 else if (unformat (i, "arp-term"))
7043 flags |= L2_ARP_TERM;
7044 else if (unformat (i, "off"))
7046 else if (unformat (i, "disable"))
7052 if (sw_if_index_set == 0)
7054 errmsg ("missing interface name or sw_if_index");
7060 mp->sw_if_index = ntohl (sw_if_index);
7061 mp->feature_bitmap = ntohl (flags);
7062 mp->is_set = is_set;
7070 api_bridge_flags (vat_main_t * vam)
7072 unformat_input_t *i = vam->input;
7073 vl_api_bridge_flags_t *mp;
7077 bd_flags_t flags = 0;
7080 /* Parse args required to build the message */
7081 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7083 if (unformat (i, "bd_id %d", &bd_id))
7085 else if (unformat (i, "learn"))
7086 flags |= BRIDGE_API_FLAG_LEARN;
7087 else if (unformat (i, "forward"))
7088 flags |= BRIDGE_API_FLAG_FWD;
7089 else if (unformat (i, "flood"))
7090 flags |= BRIDGE_API_FLAG_FLOOD;
7091 else if (unformat (i, "uu-flood"))
7092 flags |= BRIDGE_API_FLAG_UU_FLOOD;
7093 else if (unformat (i, "arp-term"))
7094 flags |= BRIDGE_API_FLAG_ARP_TERM;
7095 else if (unformat (i, "off"))
7097 else if (unformat (i, "disable"))
7105 errmsg ("missing bridge domain");
7109 M (BRIDGE_FLAGS, mp);
7111 mp->bd_id = ntohl (bd_id);
7112 mp->flags = ntohl (flags);
7113 mp->is_set = is_set;
7121 api_bd_ip_mac_add_del (vat_main_t * vam)
7123 vl_api_address_t ip = VL_API_ZERO_ADDRESS;
7124 vl_api_mac_address_t mac = { 0 };
7125 unformat_input_t *i = vam->input;
7126 vl_api_bd_ip_mac_add_del_t *mp;
7135 /* Parse args required to build the message */
7136 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7138 if (unformat (i, "bd_id %d", &bd_id))
7142 else if (unformat (i, "%U", unformat_vl_api_address, &ip))
7146 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
7150 else if (unformat (i, "del"))
7158 errmsg ("missing bridge domain");
7161 else if (ip_set == 0)
7163 errmsg ("missing IP address");
7166 else if (mac_set == 0)
7168 errmsg ("missing MAC address");
7172 M (BD_IP_MAC_ADD_DEL, mp);
7174 mp->entry.bd_id = ntohl (bd_id);
7175 mp->is_add = is_add;
7177 clib_memcpy (&mp->entry.ip, &ip, sizeof (ip));
7178 clib_memcpy (&mp->entry.mac, &mac, sizeof (mac));
7186 api_bd_ip_mac_flush (vat_main_t * vam)
7188 unformat_input_t *i = vam->input;
7189 vl_api_bd_ip_mac_flush_t *mp;
7194 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7196 if (unformat (i, "bd_id %d", &bd_id))
7206 errmsg ("missing bridge domain");
7210 M (BD_IP_MAC_FLUSH, mp);
7212 mp->bd_id = ntohl (bd_id);
7219 static void vl_api_bd_ip_mac_details_t_handler
7220 (vl_api_bd_ip_mac_details_t * mp)
7222 vat_main_t *vam = &vat_main;
7226 ntohl (mp->entry.bd_id),
7227 format_vl_api_mac_address, mp->entry.mac,
7228 format_vl_api_address, &mp->entry.ip);
7231 static void vl_api_bd_ip_mac_details_t_handler_json
7232 (vl_api_bd_ip_mac_details_t * mp)
7234 vat_main_t *vam = &vat_main;
7235 vat_json_node_t *node = NULL;
7237 if (VAT_JSON_ARRAY != vam->json_tree.type)
7239 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7240 vat_json_init_array (&vam->json_tree);
7242 node = vat_json_array_add (&vam->json_tree);
7244 vat_json_init_object (node);
7245 vat_json_object_add_uint (node, "bd_id", ntohl (mp->entry.bd_id));
7246 vat_json_object_add_string_copy (node, "mac_address",
7247 format (0, "%U", format_vl_api_mac_address,
7251 ip = format (0, "%U", format_vl_api_address, &mp->entry.ip);
7252 vat_json_object_add_string_copy (node, "ip_address", ip);
7257 api_bd_ip_mac_dump (vat_main_t * vam)
7259 unformat_input_t *i = vam->input;
7260 vl_api_bd_ip_mac_dump_t *mp;
7261 vl_api_control_ping_t *mp_ping;
7266 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7268 if (unformat (i, "bd_id %d", &bd_id))
7277 "\n%-5s %-7s %-20s %-30s",
7278 "bd_id", "is_ipv6", "mac_address", "ip_address");
7280 /* Dump Bridge Domain Ip to Mac entries */
7281 M (BD_IP_MAC_DUMP, mp);
7284 mp->bd_id = htonl (bd_id);
7290 /* Use a control ping for synchronization */
7291 MPING (CONTROL_PING, mp_ping);
7299 api_tap_create_v2 (vat_main_t * vam)
7301 unformat_input_t *i = vam->input;
7302 vl_api_tap_create_v2_t *mp;
7306 u32 num_rx_queues = 0;
7307 u8 *host_if_name = 0;
7308 u8 host_if_name_set = 0;
7311 u8 host_mac_addr[6];
7312 u8 host_mac_addr_set = 0;
7313 u8 *host_bridge = 0;
7314 u8 host_bridge_set = 0;
7315 u8 host_ip4_prefix_set = 0;
7316 u8 host_ip6_prefix_set = 0;
7317 ip4_address_t host_ip4_addr;
7318 ip4_address_t host_ip4_gw;
7319 u8 host_ip4_gw_set = 0;
7320 u32 host_ip4_prefix_len = 0;
7321 ip6_address_t host_ip6_addr;
7322 ip6_address_t host_ip6_gw;
7323 u8 host_ip6_gw_set = 0;
7324 u32 host_ip6_prefix_len = 0;
7325 u32 host_mtu_size = 0;
7326 u8 host_mtu_set = 0;
7329 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7331 clib_memset (mac_address, 0, sizeof (mac_address));
7333 /* Parse args required to build the message */
7334 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7336 if (unformat (i, "id %u", &id))
7340 (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7342 else if (unformat (i, "host-if-name %s", &host_if_name))
7343 host_if_name_set = 1;
7344 else if (unformat (i, "num-rx-queues %u", &num_rx_queues))
7346 else if (unformat (i, "host-ns %s", &host_ns))
7348 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
7350 host_mac_addr_set = 1;
7351 else if (unformat (i, "host-bridge %s", &host_bridge))
7352 host_bridge_set = 1;
7353 else if (unformat (i, "host-ip4-addr %U/%u", unformat_ip4_address,
7354 &host_ip4_addr, &host_ip4_prefix_len))
7355 host_ip4_prefix_set = 1;
7356 else if (unformat (i, "host-ip6-addr %U/%u", unformat_ip6_address,
7357 &host_ip6_addr, &host_ip6_prefix_len))
7358 host_ip6_prefix_set = 1;
7359 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
7361 host_ip4_gw_set = 1;
7362 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
7364 host_ip6_gw_set = 1;
7365 else if (unformat (i, "rx-ring-size %u", &rx_ring_sz))
7367 else if (unformat (i, "tx-ring-size %u", &tx_ring_sz))
7369 else if (unformat (i, "host-mtu-size %u", &host_mtu_size))
7371 else if (unformat (i, "no-gso"))
7372 tap_flags &= ~TAP_FLAG_GSO;
7373 else if (unformat (i, "gso"))
7374 tap_flags |= TAP_FLAG_GSO;
7375 else if (unformat (i, "csum-offload"))
7376 tap_flags |= TAP_FLAG_CSUM_OFFLOAD;
7377 else if (unformat (i, "persist"))
7378 tap_flags |= TAP_FLAG_PERSIST;
7379 else if (unformat (i, "attach"))
7380 tap_flags |= TAP_FLAG_ATTACH;
7385 if (vec_len (host_if_name) > 63)
7387 errmsg ("tap name too long. ");
7390 if (vec_len (host_ns) > 63)
7392 errmsg ("host name space too long. ");
7395 if (vec_len (host_bridge) > 63)
7397 errmsg ("host bridge name too long. ");
7400 if (host_ip4_prefix_len > 32)
7402 errmsg ("host ip4 prefix length not valid. ");
7405 if (host_ip6_prefix_len > 128)
7407 errmsg ("host ip6 prefix length not valid. ");
7410 if (!is_pow2 (rx_ring_sz))
7412 errmsg ("rx ring size must be power of 2. ");
7415 if (rx_ring_sz > 32768)
7417 errmsg ("rx ring size must be 32768 or lower. ");
7420 if (!is_pow2 (tx_ring_sz))
7422 errmsg ("tx ring size must be power of 2. ");
7425 if (tx_ring_sz > 32768)
7427 errmsg ("tx ring size must be 32768 or lower. ");
7430 if (host_mtu_set && (host_mtu_size < 64 || host_mtu_size > 65355))
7432 errmsg ("host MTU size must be in between 64 and 65355. ");
7436 /* Construct the API message */
7437 M (TAP_CREATE_V2, mp);
7439 mp->id = ntohl (id);
7440 mp->use_random_mac = random_mac;
7441 mp->num_rx_queues = (u8) num_rx_queues;
7442 mp->tx_ring_sz = ntohs (tx_ring_sz);
7443 mp->rx_ring_sz = ntohs (rx_ring_sz);
7444 mp->host_mtu_set = host_mtu_set;
7445 mp->host_mtu_size = ntohl (host_mtu_size);
7446 mp->host_mac_addr_set = host_mac_addr_set;
7447 mp->host_ip4_prefix_set = host_ip4_prefix_set;
7448 mp->host_ip6_prefix_set = host_ip6_prefix_set;
7449 mp->host_ip4_gw_set = host_ip4_gw_set;
7450 mp->host_ip6_gw_set = host_ip6_gw_set;
7451 mp->tap_flags = ntohl (tap_flags);
7452 mp->host_namespace_set = host_ns_set;
7453 mp->host_if_name_set = host_if_name_set;
7454 mp->host_bridge_set = host_bridge_set;
7456 if (random_mac == 0)
7457 clib_memcpy (mp->mac_address, mac_address, 6);
7458 if (host_mac_addr_set)
7459 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
7460 if (host_if_name_set)
7461 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
7463 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
7464 if (host_bridge_set)
7465 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
7466 if (host_ip4_prefix_set)
7468 clib_memcpy (mp->host_ip4_prefix.address, &host_ip4_addr, 4);
7469 mp->host_ip4_prefix.len = (u8) host_ip4_prefix_len;
7471 if (host_ip6_prefix_set)
7473 clib_memcpy (mp->host_ip6_prefix.address, &host_ip6_addr, 16);
7474 mp->host_ip6_prefix.len = (u8) host_ip6_prefix_len;
7476 if (host_ip4_gw_set)
7477 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
7478 if (host_ip6_gw_set)
7479 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
7482 vec_free (host_if_name);
7483 vec_free (host_bridge);
7488 /* Wait for a reply... */
7494 api_tap_delete_v2 (vat_main_t * vam)
7496 unformat_input_t *i = vam->input;
7497 vl_api_tap_delete_v2_t *mp;
7498 u32 sw_if_index = ~0;
7499 u8 sw_if_index_set = 0;
7502 /* Parse args required to build the message */
7503 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7505 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7506 sw_if_index_set = 1;
7507 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7508 sw_if_index_set = 1;
7513 if (sw_if_index_set == 0)
7515 errmsg ("missing vpp interface name. ");
7519 /* Construct the API message */
7520 M (TAP_DELETE_V2, mp);
7522 mp->sw_if_index = ntohl (sw_if_index);
7527 /* Wait for a reply... */
7533 unformat_vlib_pci_addr (unformat_input_t * input, va_list * args)
7535 vlib_pci_addr_t *addr = va_arg (*args, vlib_pci_addr_t *);
7538 if (!unformat (input, "%x:%x:%x.%x", &x[0], &x[1], &x[2], &x[3]))
7541 addr->domain = x[0];
7544 addr->function = x[3];
7550 api_virtio_pci_create (vat_main_t * vam)
7552 unformat_input_t *i = vam->input;
7553 vl_api_virtio_pci_create_t *mp;
7557 u8 checksum_offload_enabled = 0;
7559 u64 features = (u64) ~ (0ULL);
7562 clib_memset (mac_address, 0, sizeof (mac_address));
7564 /* Parse args required to build the message */
7565 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7567 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7571 else if (unformat (i, "pci-addr %U", unformat_vlib_pci_addr, &pci_addr))
7573 else if (unformat (i, "features 0x%llx", &features))
7575 else if (unformat (i, "gso-enabled"))
7577 else if (unformat (i, "csum-offload-enabled"))
7578 checksum_offload_enabled = 1;
7585 errmsg ("pci address must be non zero. ");
7589 /* Construct the API message */
7590 M (VIRTIO_PCI_CREATE, mp);
7592 mp->use_random_mac = random_mac;
7594 mp->pci_addr.domain = htons (((vlib_pci_addr_t) pci_addr).domain);
7595 mp->pci_addr.bus = ((vlib_pci_addr_t) pci_addr).bus;
7596 mp->pci_addr.slot = ((vlib_pci_addr_t) pci_addr).slot;
7597 mp->pci_addr.function = ((vlib_pci_addr_t) pci_addr).function;
7599 mp->features = clib_host_to_net_u64 (features);
7600 mp->gso_enabled = gso_enabled;
7601 mp->checksum_offload_enabled = checksum_offload_enabled;
7603 if (random_mac == 0)
7604 clib_memcpy (mp->mac_address, mac_address, 6);
7609 /* Wait for a reply... */
7615 api_virtio_pci_delete (vat_main_t * vam)
7617 unformat_input_t *i = vam->input;
7618 vl_api_virtio_pci_delete_t *mp;
7619 u32 sw_if_index = ~0;
7620 u8 sw_if_index_set = 0;
7623 /* Parse args required to build the message */
7624 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7626 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7627 sw_if_index_set = 1;
7628 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7629 sw_if_index_set = 1;
7634 if (sw_if_index_set == 0)
7636 errmsg ("missing vpp interface name. ");
7640 /* Construct the API message */
7641 M (VIRTIO_PCI_DELETE, mp);
7643 mp->sw_if_index = htonl (sw_if_index);
7648 /* Wait for a reply... */
7654 api_bond_create (vat_main_t * vam)
7656 unformat_input_t *i = vam->input;
7657 vl_api_bond_create_t *mp;
7667 clib_memset (mac_address, 0, sizeof (mac_address));
7670 /* Parse args required to build the message */
7671 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7673 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
7675 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
7676 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
7678 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
7681 else if (unformat (i, "numa-only"))
7683 else if (unformat (i, "id %u", &id))
7689 if (mode_is_set == 0)
7691 errmsg ("Missing bond mode. ");
7695 /* Construct the API message */
7696 M (BOND_CREATE, mp);
7698 mp->use_custom_mac = custom_mac;
7700 mp->mode = htonl (mode);
7701 mp->lb = htonl (lb);
7702 mp->id = htonl (id);
7703 mp->numa_only = numa_only;
7706 clib_memcpy (mp->mac_address, mac_address, 6);
7711 /* Wait for a reply... */
7717 api_bond_delete (vat_main_t * vam)
7719 unformat_input_t *i = vam->input;
7720 vl_api_bond_delete_t *mp;
7721 u32 sw_if_index = ~0;
7722 u8 sw_if_index_set = 0;
7725 /* Parse args required to build the message */
7726 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7728 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7729 sw_if_index_set = 1;
7730 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7731 sw_if_index_set = 1;
7736 if (sw_if_index_set == 0)
7738 errmsg ("missing vpp interface name. ");
7742 /* Construct the API message */
7743 M (BOND_DELETE, mp);
7745 mp->sw_if_index = ntohl (sw_if_index);
7750 /* Wait for a reply... */
7756 api_bond_enslave (vat_main_t * vam)
7758 unformat_input_t *i = vam->input;
7759 vl_api_bond_enslave_t *mp;
7760 u32 bond_sw_if_index;
7764 u32 bond_sw_if_index_is_set = 0;
7766 u8 sw_if_index_is_set = 0;
7768 /* Parse args required to build the message */
7769 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7771 if (unformat (i, "sw_if_index %d", &sw_if_index))
7772 sw_if_index_is_set = 1;
7773 else if (unformat (i, "bond %u", &bond_sw_if_index))
7774 bond_sw_if_index_is_set = 1;
7775 else if (unformat (i, "passive %d", &is_passive))
7777 else if (unformat (i, "long-timeout %d", &is_long_timeout))
7783 if (bond_sw_if_index_is_set == 0)
7785 errmsg ("Missing bond sw_if_index. ");
7788 if (sw_if_index_is_set == 0)
7790 errmsg ("Missing slave sw_if_index. ");
7794 /* Construct the API message */
7795 M (BOND_ENSLAVE, mp);
7797 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
7798 mp->sw_if_index = ntohl (sw_if_index);
7799 mp->is_long_timeout = is_long_timeout;
7800 mp->is_passive = is_passive;
7805 /* Wait for a reply... */
7811 api_bond_detach_slave (vat_main_t * vam)
7813 unformat_input_t *i = vam->input;
7814 vl_api_bond_detach_slave_t *mp;
7815 u32 sw_if_index = ~0;
7816 u8 sw_if_index_set = 0;
7819 /* Parse args required to build the message */
7820 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7822 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7823 sw_if_index_set = 1;
7824 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7825 sw_if_index_set = 1;
7830 if (sw_if_index_set == 0)
7832 errmsg ("missing vpp interface name. ");
7836 /* Construct the API message */
7837 M (BOND_DETACH_SLAVE, mp);
7839 mp->sw_if_index = ntohl (sw_if_index);
7844 /* Wait for a reply... */
7850 api_ip_table_add_del (vat_main_t * vam)
7852 unformat_input_t *i = vam->input;
7853 vl_api_ip_table_add_del_t *mp;
7859 /* Parse args required to build the message */
7860 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7862 if (unformat (i, "ipv6"))
7864 else if (unformat (i, "del"))
7866 else if (unformat (i, "add"))
7868 else if (unformat (i, "table %d", &table_id))
7872 clib_warning ("parse error '%U'", format_unformat_error, i);
7879 errmsg ("missing table-ID");
7883 /* Construct the API message */
7884 M (IP_TABLE_ADD_DEL, mp);
7886 mp->table.table_id = ntohl (table_id);
7887 mp->table.is_ip6 = is_ipv6;
7888 mp->is_add = is_add;
7893 /* Wait for a reply... */
7900 unformat_fib_path (unformat_input_t * input, va_list * args)
7902 vat_main_t *vam = va_arg (*args, vat_main_t *);
7903 vl_api_fib_path_t *path = va_arg (*args, vl_api_fib_path_t *);
7904 u32 weight, preference;
7905 mpls_label_t out_label;
7907 clib_memset (path, 0, sizeof (*path));
7909 path->sw_if_index = ~0;
7913 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7915 if (unformat (input, "%U %U",
7916 unformat_vl_api_ip4_address,
7917 &path->nh.address.ip4,
7918 api_unformat_sw_if_index, vam, &path->sw_if_index))
7920 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7922 else if (unformat (input, "%U %U",
7923 unformat_vl_api_ip6_address,
7924 &path->nh.address.ip6,
7925 api_unformat_sw_if_index, vam, &path->sw_if_index))
7927 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7929 else if (unformat (input, "weight %u", &weight))
7931 path->weight = weight;
7933 else if (unformat (input, "preference %u", &preference))
7935 path->preference = preference;
7937 else if (unformat (input, "%U next-hop-table %d",
7938 unformat_vl_api_ip4_address,
7939 &path->nh.address.ip4, &path->table_id))
7941 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7943 else if (unformat (input, "%U next-hop-table %d",
7944 unformat_vl_api_ip6_address,
7945 &path->nh.address.ip6, &path->table_id))
7947 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7949 else if (unformat (input, "%U",
7950 unformat_vl_api_ip4_address, &path->nh.address.ip4))
7953 * the recursive next-hops are by default in the default table
7956 path->sw_if_index = ~0;
7957 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7959 else if (unformat (input, "%U",
7960 unformat_vl_api_ip6_address, &path->nh.address.ip6))
7963 * the recursive next-hops are by default in the default table
7966 path->sw_if_index = ~0;
7967 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7969 else if (unformat (input, "resolve-via-host"))
7971 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_HOST;
7973 else if (unformat (input, "resolve-via-attached"))
7975 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED;
7977 else if (unformat (input, "ip4-lookup-in-table %d", &path->table_id))
7979 path->type = FIB_API_PATH_TYPE_LOCAL;
7980 path->sw_if_index = ~0;
7981 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7983 else if (unformat (input, "ip6-lookup-in-table %d", &path->table_id))
7985 path->type = FIB_API_PATH_TYPE_LOCAL;
7986 path->sw_if_index = ~0;
7987 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7989 else if (unformat (input, "sw_if_index %d", &path->sw_if_index))
7991 else if (unformat (input, "via-label %d", &path->nh.via_label))
7993 path->proto = FIB_API_PATH_NH_PROTO_MPLS;
7994 path->sw_if_index = ~0;
7996 else if (unformat (input, "l2-input-on %d", &path->sw_if_index))
7998 path->proto = FIB_API_PATH_NH_PROTO_ETHERNET;
7999 path->type = FIB_API_PATH_TYPE_INTERFACE_RX;
8001 else if (unformat (input, "local"))
8003 path->type = FIB_API_PATH_TYPE_LOCAL;
8005 else if (unformat (input, "out-labels"))
8007 while (unformat (input, "%d", &out_label))
8009 path->label_stack[path->n_labels].label = out_label;
8010 path->label_stack[path->n_labels].is_uniform = 0;
8011 path->label_stack[path->n_labels].ttl = 64;
8015 else if (unformat (input, "via"))
8017 /* new path, back up and return */
8018 unformat_put_input (input);
8019 unformat_put_input (input);
8020 unformat_put_input (input);
8021 unformat_put_input (input);
8030 path->proto = ntohl (path->proto);
8031 path->type = ntohl (path->type);
8032 path->flags = ntohl (path->flags);
8033 path->table_id = ntohl (path->table_id);
8034 path->sw_if_index = ntohl (path->sw_if_index);
8040 api_ip_route_add_del (vat_main_t * vam)
8042 unformat_input_t *i = vam->input;
8043 vl_api_ip_route_add_del_t *mp;
8046 u8 is_multipath = 0;
8049 vl_api_prefix_t pfx = { };
8050 vl_api_fib_path_t paths[8];
8054 u32 random_add_del = 0;
8055 u32 *random_vector = 0;
8056 u32 random_seed = 0xdeaddabe;
8058 /* Parse args required to build the message */
8059 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8061 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
8063 else if (unformat (i, "del"))
8065 else if (unformat (i, "add"))
8067 else if (unformat (i, "vrf %d", &vrf_id))
8069 else if (unformat (i, "count %d", &count))
8071 else if (unformat (i, "random"))
8073 else if (unformat (i, "multipath"))
8075 else if (unformat (i, "seed %d", &random_seed))
8079 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8082 if (8 == path_count)
8084 errmsg ("max 8 paths");
8090 clib_warning ("parse error '%U'", format_unformat_error, i);
8097 errmsg ("specify a path; via ...");
8100 if (prefix_set == 0)
8102 errmsg ("missing prefix");
8106 /* Generate a pile of unique, random routes */
8109 ip4_address_t *i = (ip4_address_t *) & paths[0].nh.address.ip4;
8110 u32 this_random_address;
8113 random_hash = hash_create (count, sizeof (uword));
8115 hash_set (random_hash, i->as_u32, 1);
8116 for (j = 0; j <= count; j++)
8120 this_random_address = random_u32 (&random_seed);
8121 this_random_address =
8122 clib_host_to_net_u32 (this_random_address);
8124 while (hash_get (random_hash, this_random_address));
8125 vec_add1 (random_vector, this_random_address);
8126 hash_set (random_hash, this_random_address, 1);
8128 hash_free (random_hash);
8129 set_ip4_address (&pfx.address, random_vector[0]);
8134 /* Turn on async mode */
8135 vam->async_mode = 1;
8136 vam->async_errors = 0;
8137 before = vat_time_now (vam);
8140 for (j = 0; j < count; j++)
8142 /* Construct the API message */
8143 M2 (IP_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8145 mp->is_add = is_add;
8146 mp->is_multipath = is_multipath;
8148 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
8149 mp->route.table_id = ntohl (vrf_id);
8150 mp->route.n_paths = path_count;
8152 clib_memcpy (&mp->route.paths, &paths, sizeof (paths[0]) * path_count);
8155 set_ip4_address (&pfx.address, random_vector[j + 1]);
8157 increment_address (&pfx.address);
8160 /* If we receive SIGTERM, stop now... */
8165 /* When testing multiple add/del ops, use a control-ping to sync */
8168 vl_api_control_ping_t *mp_ping;
8172 /* Shut off async mode */
8173 vam->async_mode = 0;
8175 MPING (CONTROL_PING, mp_ping);
8178 timeout = vat_time_now (vam) + 1.0;
8179 while (vat_time_now (vam) < timeout)
8180 if (vam->result_ready == 1)
8185 if (vam->retval == -99)
8188 if (vam->async_errors > 0)
8190 errmsg ("%d asynchronous errors", vam->async_errors);
8193 vam->async_errors = 0;
8194 after = vat_time_now (vam);
8196 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8200 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8201 count, after - before, count / (after - before));
8207 /* Wait for a reply... */
8212 /* Return the good/bad news */
8213 return (vam->retval);
8217 api_ip_mroute_add_del (vat_main_t * vam)
8219 unformat_input_t *i = vam->input;
8220 u8 path_set = 0, prefix_set = 0, is_add = 1;
8221 vl_api_ip_mroute_add_del_t *mp;
8222 mfib_entry_flags_t eflags = 0;
8223 vl_api_mfib_path_t path;
8224 vl_api_mprefix_t pfx = { };
8228 /* Parse args required to build the message */
8229 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8231 if (unformat (i, "%U", unformat_vl_api_mprefix, &pfx))
8234 pfx.grp_address_length = htons (pfx.grp_address_length);
8236 else if (unformat (i, "del"))
8238 else if (unformat (i, "add"))
8240 else if (unformat (i, "vrf %d", &vrf_id))
8242 else if (unformat (i, "%U", unformat_mfib_itf_flags, &path.itf_flags))
8243 path.itf_flags = htonl (path.itf_flags);
8244 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8246 else if (unformat (i, "via %U", unformat_fib_path, vam, &path.path))
8250 clib_warning ("parse error '%U'", format_unformat_error, i);
8255 if (prefix_set == 0)
8257 errmsg ("missing addresses\n");
8262 errmsg ("missing path\n");
8266 /* Construct the API message */
8267 M (IP_MROUTE_ADD_DEL, mp);
8269 mp->is_add = is_add;
8270 mp->is_multipath = 1;
8272 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
8273 mp->route.table_id = htonl (vrf_id);
8274 mp->route.n_paths = 1;
8275 mp->route.entry_flags = htonl (eflags);
8277 clib_memcpy (&mp->route.paths, &path, sizeof (path));
8281 /* Wait for a reply... */
8287 api_mpls_table_add_del (vat_main_t * vam)
8289 unformat_input_t *i = vam->input;
8290 vl_api_mpls_table_add_del_t *mp;
8295 /* Parse args required to build the message */
8296 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8298 if (unformat (i, "table %d", &table_id))
8300 else if (unformat (i, "del"))
8302 else if (unformat (i, "add"))
8306 clib_warning ("parse error '%U'", format_unformat_error, i);
8313 errmsg ("missing table-ID");
8317 /* Construct the API message */
8318 M (MPLS_TABLE_ADD_DEL, mp);
8320 mp->mt_table.mt_table_id = ntohl (table_id);
8321 mp->mt_is_add = is_add;
8326 /* Wait for a reply... */
8333 api_mpls_route_add_del (vat_main_t * vam)
8335 u8 is_add = 1, path_count = 0, is_multipath = 0, is_eos = 0;
8336 mpls_label_t local_label = MPLS_LABEL_INVALID;
8337 unformat_input_t *i = vam->input;
8338 vl_api_mpls_route_add_del_t *mp;
8339 vl_api_fib_path_t paths[8];
8343 /* Parse args required to build the message */
8344 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8346 if (unformat (i, "%d", &local_label))
8348 else if (unformat (i, "eos"))
8350 else if (unformat (i, "non-eos"))
8352 else if (unformat (i, "del"))
8354 else if (unformat (i, "add"))
8356 else if (unformat (i, "multipath"))
8358 else if (unformat (i, "count %d", &count))
8362 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8365 if (8 == path_count)
8367 errmsg ("max 8 paths");
8373 clib_warning ("parse error '%U'", format_unformat_error, i);
8380 errmsg ("specify a path; via ...");
8384 if (MPLS_LABEL_INVALID == local_label)
8386 errmsg ("missing label");
8392 /* Turn on async mode */
8393 vam->async_mode = 1;
8394 vam->async_errors = 0;
8395 before = vat_time_now (vam);
8398 for (j = 0; j < count; j++)
8400 /* Construct the API message */
8401 M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8403 mp->mr_is_add = is_add;
8404 mp->mr_is_multipath = is_multipath;
8406 mp->mr_route.mr_label = local_label;
8407 mp->mr_route.mr_eos = is_eos;
8408 mp->mr_route.mr_table_id = 0;
8409 mp->mr_route.mr_n_paths = path_count;
8411 clib_memcpy (&mp->mr_route.mr_paths, paths,
8412 sizeof (paths[0]) * path_count);
8418 /* If we receive SIGTERM, stop now... */
8423 /* When testing multiple add/del ops, use a control-ping to sync */
8426 vl_api_control_ping_t *mp_ping;
8430 /* Shut off async mode */
8431 vam->async_mode = 0;
8433 MPING (CONTROL_PING, mp_ping);
8436 timeout = vat_time_now (vam) + 1.0;
8437 while (vat_time_now (vam) < timeout)
8438 if (vam->result_ready == 1)
8443 if (vam->retval == -99)
8446 if (vam->async_errors > 0)
8448 errmsg ("%d asynchronous errors", vam->async_errors);
8451 vam->async_errors = 0;
8452 after = vat_time_now (vam);
8454 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8458 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8459 count, after - before, count / (after - before));
8465 /* Wait for a reply... */
8470 /* Return the good/bad news */
8471 return (vam->retval);
8476 api_mpls_ip_bind_unbind (vat_main_t * vam)
8478 unformat_input_t *i = vam->input;
8479 vl_api_mpls_ip_bind_unbind_t *mp;
8480 u32 ip_table_id = 0;
8482 vl_api_prefix_t pfx;
8484 mpls_label_t local_label = MPLS_LABEL_INVALID;
8487 /* Parse args required to build the message */
8488 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8490 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
8492 else if (unformat (i, "%d", &local_label))
8494 else if (unformat (i, "table-id %d", &ip_table_id))
8496 else if (unformat (i, "unbind"))
8498 else if (unformat (i, "bind"))
8502 clib_warning ("parse error '%U'", format_unformat_error, i);
8509 errmsg ("IP prefix not set");
8513 if (MPLS_LABEL_INVALID == local_label)
8515 errmsg ("missing label");
8519 /* Construct the API message */
8520 M (MPLS_IP_BIND_UNBIND, mp);
8522 mp->mb_is_bind = is_bind;
8523 mp->mb_ip_table_id = ntohl (ip_table_id);
8524 mp->mb_mpls_table_id = 0;
8525 mp->mb_label = ntohl (local_label);
8526 clib_memcpy (&mp->mb_prefix, &pfx, sizeof (pfx));
8531 /* Wait for a reply... */
8538 api_sr_mpls_policy_add (vat_main_t * vam)
8540 unformat_input_t *i = vam->input;
8541 vl_api_sr_mpls_policy_add_t *mp;
8547 u32 *segments = NULL;
8550 /* Parse args required to build the message */
8551 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8553 if (unformat (i, "bsid %d", &bsid))
8555 else if (unformat (i, "weight %d", &weight))
8557 else if (unformat (i, "spray"))
8559 else if (unformat (i, "next %d", &sid))
8562 vec_add1 (segments, htonl (sid));
8566 clib_warning ("parse error '%U'", format_unformat_error, i);
8573 errmsg ("bsid not set");
8577 if (n_segments == 0)
8579 errmsg ("no sid in segment stack");
8583 /* Construct the API message */
8584 M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
8586 mp->bsid = htonl (bsid);
8587 mp->weight = htonl (weight);
8588 mp->is_spray = type;
8589 mp->n_segments = n_segments;
8590 memcpy (mp->segments, segments, sizeof (u32) * n_segments);
8591 vec_free (segments);
8596 /* Wait for a reply... */
8602 api_sr_mpls_policy_del (vat_main_t * vam)
8604 unformat_input_t *i = vam->input;
8605 vl_api_sr_mpls_policy_del_t *mp;
8609 /* Parse args required to build the message */
8610 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8612 if (unformat (i, "bsid %d", &bsid))
8616 clib_warning ("parse error '%U'", format_unformat_error, i);
8623 errmsg ("bsid not set");
8627 /* Construct the API message */
8628 M (SR_MPLS_POLICY_DEL, mp);
8630 mp->bsid = htonl (bsid);
8635 /* Wait for a reply... */
8641 api_bier_table_add_del (vat_main_t * vam)
8643 unformat_input_t *i = vam->input;
8644 vl_api_bier_table_add_del_t *mp;
8646 u32 set = 0, sub_domain = 0, hdr_len = 3;
8647 mpls_label_t local_label = MPLS_LABEL_INVALID;
8650 /* Parse args required to build the message */
8651 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8653 if (unformat (i, "sub-domain %d", &sub_domain))
8655 else if (unformat (i, "set %d", &set))
8657 else if (unformat (i, "label %d", &local_label))
8659 else if (unformat (i, "hdr-len %d", &hdr_len))
8661 else if (unformat (i, "add"))
8663 else if (unformat (i, "del"))
8667 clib_warning ("parse error '%U'", format_unformat_error, i);
8672 if (MPLS_LABEL_INVALID == local_label)
8674 errmsg ("missing label\n");
8678 /* Construct the API message */
8679 M (BIER_TABLE_ADD_DEL, mp);
8681 mp->bt_is_add = is_add;
8682 mp->bt_label = ntohl (local_label);
8683 mp->bt_tbl_id.bt_set = set;
8684 mp->bt_tbl_id.bt_sub_domain = sub_domain;
8685 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
8690 /* Wait for a reply... */
8697 api_bier_route_add_del (vat_main_t * vam)
8699 unformat_input_t *i = vam->input;
8700 vl_api_bier_route_add_del_t *mp;
8702 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
8703 ip4_address_t v4_next_hop_address;
8704 ip6_address_t v6_next_hop_address;
8705 u8 next_hop_set = 0;
8706 u8 next_hop_proto_is_ip4 = 1;
8707 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8710 /* Parse args required to build the message */
8711 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8713 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
8715 next_hop_proto_is_ip4 = 1;
8718 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
8720 next_hop_proto_is_ip4 = 0;
8723 if (unformat (i, "sub-domain %d", &sub_domain))
8725 else if (unformat (i, "set %d", &set))
8727 else if (unformat (i, "hdr-len %d", &hdr_len))
8729 else if (unformat (i, "bp %d", &bp))
8731 else if (unformat (i, "add"))
8733 else if (unformat (i, "del"))
8735 else if (unformat (i, "out-label %d", &next_hop_out_label))
8739 clib_warning ("parse error '%U'", format_unformat_error, i);
8744 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
8746 errmsg ("next hop / label set\n");
8751 errmsg ("bit=position not set\n");
8755 /* Construct the API message */
8756 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
8758 mp->br_is_add = is_add;
8759 mp->br_route.br_tbl_id.bt_set = set;
8760 mp->br_route.br_tbl_id.bt_sub_domain = sub_domain;
8761 mp->br_route.br_tbl_id.bt_hdr_len_id = hdr_len;
8762 mp->br_route.br_bp = ntohs (bp);
8763 mp->br_route.br_n_paths = 1;
8764 mp->br_route.br_paths[0].n_labels = 1;
8765 mp->br_route.br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
8766 mp->br_route.br_paths[0].proto = (next_hop_proto_is_ip4 ?
8767 FIB_API_PATH_NH_PROTO_IP4 :
8768 FIB_API_PATH_NH_PROTO_IP6);
8770 if (next_hop_proto_is_ip4)
8772 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip4,
8773 &v4_next_hop_address, sizeof (v4_next_hop_address));
8777 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip6,
8778 &v6_next_hop_address, sizeof (v6_next_hop_address));
8784 /* Wait for a reply... */
8791 api_mpls_tunnel_add_del (vat_main_t * vam)
8793 unformat_input_t *i = vam->input;
8794 vl_api_mpls_tunnel_add_del_t *mp;
8796 vl_api_fib_path_t paths[8];
8797 u32 sw_if_index = ~0;
8803 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8805 if (unformat (i, "add"))
8809 (i, "del %U", api_unformat_sw_if_index, vam, &sw_if_index))
8811 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
8813 else if (unformat (i, "l2-only"))
8817 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8820 if (8 == path_count)
8822 errmsg ("max 8 paths");
8828 clib_warning ("parse error '%U'", format_unformat_error, i);
8833 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8835 mp->mt_is_add = is_add;
8836 mp->mt_tunnel.mt_sw_if_index = ntohl (sw_if_index);
8837 mp->mt_tunnel.mt_l2_only = l2_only;
8838 mp->mt_tunnel.mt_is_multicast = 0;
8839 mp->mt_tunnel.mt_n_paths = path_count;
8841 clib_memcpy (&mp->mt_tunnel.mt_paths, &paths,
8842 sizeof (paths[0]) * path_count);
8850 api_sw_interface_set_unnumbered (vat_main_t * vam)
8852 unformat_input_t *i = vam->input;
8853 vl_api_sw_interface_set_unnumbered_t *mp;
8855 u32 unnum_sw_index = ~0;
8857 u8 sw_if_index_set = 0;
8860 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8862 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8863 sw_if_index_set = 1;
8864 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8865 sw_if_index_set = 1;
8866 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
8868 else if (unformat (i, "del"))
8872 clib_warning ("parse error '%U'", format_unformat_error, i);
8877 if (sw_if_index_set == 0)
8879 errmsg ("missing interface name or sw_if_index");
8883 M (SW_INTERFACE_SET_UNNUMBERED, mp);
8885 mp->sw_if_index = ntohl (sw_if_index);
8886 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
8887 mp->is_add = is_add;
8896 api_create_vlan_subif (vat_main_t * vam)
8898 unformat_input_t *i = vam->input;
8899 vl_api_create_vlan_subif_t *mp;
8901 u8 sw_if_index_set = 0;
8906 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8908 if (unformat (i, "sw_if_index %d", &sw_if_index))
8909 sw_if_index_set = 1;
8911 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8912 sw_if_index_set = 1;
8913 else if (unformat (i, "vlan %d", &vlan_id))
8917 clib_warning ("parse error '%U'", format_unformat_error, i);
8922 if (sw_if_index_set == 0)
8924 errmsg ("missing interface name or sw_if_index");
8928 if (vlan_id_set == 0)
8930 errmsg ("missing vlan_id");
8933 M (CREATE_VLAN_SUBIF, mp);
8935 mp->sw_if_index = ntohl (sw_if_index);
8936 mp->vlan_id = ntohl (vlan_id);
8943 #define foreach_create_subif_bit \
8950 _(outer_vlan_id_any) \
8951 _(inner_vlan_id_any)
8953 #define foreach_create_subif_flag \
8958 _(4, "exact_match") \
8959 _(5, "default_sub") \
8960 _(6, "outer_vlan_id_any") \
8961 _(7, "inner_vlan_id_any")
8964 api_create_subif (vat_main_t * vam)
8966 unformat_input_t *i = vam->input;
8967 vl_api_create_subif_t *mp;
8969 u8 sw_if_index_set = 0;
8972 u32 __attribute__ ((unused)) no_tags = 0;
8973 u32 __attribute__ ((unused)) one_tag = 0;
8974 u32 __attribute__ ((unused)) two_tags = 0;
8975 u32 __attribute__ ((unused)) dot1ad = 0;
8976 u32 __attribute__ ((unused)) exact_match = 0;
8977 u32 __attribute__ ((unused)) default_sub = 0;
8978 u32 __attribute__ ((unused)) outer_vlan_id_any = 0;
8979 u32 __attribute__ ((unused)) inner_vlan_id_any = 0;
8981 u16 outer_vlan_id = 0;
8982 u16 inner_vlan_id = 0;
8985 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8987 if (unformat (i, "sw_if_index %d", &sw_if_index))
8988 sw_if_index_set = 1;
8990 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8991 sw_if_index_set = 1;
8992 else if (unformat (i, "sub_id %d", &sub_id))
8994 else if (unformat (i, "outer_vlan_id %d", &tmp))
8995 outer_vlan_id = tmp;
8996 else if (unformat (i, "inner_vlan_id %d", &tmp))
8997 inner_vlan_id = tmp;
8999 #define _(a) else if (unformat (i, #a)) a = 1 ;
9000 foreach_create_subif_bit
9004 clib_warning ("parse error '%U'", format_unformat_error, i);
9009 if (sw_if_index_set == 0)
9011 errmsg ("missing interface name or sw_if_index");
9015 if (sub_id_set == 0)
9017 errmsg ("missing sub_id");
9020 M (CREATE_SUBIF, mp);
9022 mp->sw_if_index = ntohl (sw_if_index);
9023 mp->sub_id = ntohl (sub_id);
9025 #define _(a,b) mp->sub_if_flags |= (1 << a);
9026 foreach_create_subif_flag;
9029 mp->outer_vlan_id = ntohs (outer_vlan_id);
9030 mp->inner_vlan_id = ntohs (inner_vlan_id);
9038 api_ip_table_replace_begin (vat_main_t * vam)
9040 unformat_input_t *i = vam->input;
9041 vl_api_ip_table_replace_begin_t *mp;
9046 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9048 if (unformat (i, "table %d", &table_id))
9050 else if (unformat (i, "ipv6"))
9054 clib_warning ("parse error '%U'", format_unformat_error, i);
9059 M (IP_TABLE_REPLACE_BEGIN, mp);
9061 mp->table.table_id = ntohl (table_id);
9062 mp->table.is_ip6 = is_ipv6;
9070 api_ip_table_flush (vat_main_t * vam)
9072 unformat_input_t *i = vam->input;
9073 vl_api_ip_table_flush_t *mp;
9078 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9080 if (unformat (i, "table %d", &table_id))
9082 else if (unformat (i, "ipv6"))
9086 clib_warning ("parse error '%U'", format_unformat_error, i);
9091 M (IP_TABLE_FLUSH, mp);
9093 mp->table.table_id = ntohl (table_id);
9094 mp->table.is_ip6 = is_ipv6;
9102 api_ip_table_replace_end (vat_main_t * vam)
9104 unformat_input_t *i = vam->input;
9105 vl_api_ip_table_replace_end_t *mp;
9110 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9112 if (unformat (i, "table %d", &table_id))
9114 else if (unformat (i, "ipv6"))
9118 clib_warning ("parse error '%U'", format_unformat_error, i);
9123 M (IP_TABLE_REPLACE_END, mp);
9125 mp->table.table_id = ntohl (table_id);
9126 mp->table.is_ip6 = is_ipv6;
9134 api_set_ip_flow_hash (vat_main_t * vam)
9136 unformat_input_t *i = vam->input;
9137 vl_api_set_ip_flow_hash_t *mp;
9149 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9151 if (unformat (i, "vrf %d", &vrf_id))
9153 else if (unformat (i, "ipv6"))
9155 else if (unformat (i, "src"))
9157 else if (unformat (i, "dst"))
9159 else if (unformat (i, "sport"))
9161 else if (unformat (i, "dport"))
9163 else if (unformat (i, "proto"))
9165 else if (unformat (i, "reverse"))
9170 clib_warning ("parse error '%U'", format_unformat_error, i);
9175 if (vrf_id_set == 0)
9177 errmsg ("missing vrf id");
9181 M (SET_IP_FLOW_HASH, mp);
9187 mp->reverse = reverse;
9188 mp->vrf_id = ntohl (vrf_id);
9189 mp->is_ipv6 = is_ipv6;
9197 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
9199 unformat_input_t *i = vam->input;
9200 vl_api_sw_interface_ip6_enable_disable_t *mp;
9202 u8 sw_if_index_set = 0;
9206 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9208 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9209 sw_if_index_set = 1;
9210 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9211 sw_if_index_set = 1;
9212 else if (unformat (i, "enable"))
9214 else if (unformat (i, "disable"))
9218 clib_warning ("parse error '%U'", format_unformat_error, i);
9223 if (sw_if_index_set == 0)
9225 errmsg ("missing interface name or sw_if_index");
9229 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
9231 mp->sw_if_index = ntohl (sw_if_index);
9232 mp->enable = enable;
9241 api_l2_patch_add_del (vat_main_t * vam)
9243 unformat_input_t *i = vam->input;
9244 vl_api_l2_patch_add_del_t *mp;
9246 u8 rx_sw_if_index_set = 0;
9248 u8 tx_sw_if_index_set = 0;
9252 /* Parse args required to build the message */
9253 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9255 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
9256 rx_sw_if_index_set = 1;
9257 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
9258 tx_sw_if_index_set = 1;
9259 else if (unformat (i, "rx"))
9261 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9263 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9265 rx_sw_if_index_set = 1;
9270 else if (unformat (i, "tx"))
9272 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9274 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9276 tx_sw_if_index_set = 1;
9281 else if (unformat (i, "del"))
9287 if (rx_sw_if_index_set == 0)
9289 errmsg ("missing rx interface name or rx_sw_if_index");
9293 if (tx_sw_if_index_set == 0)
9295 errmsg ("missing tx interface name or tx_sw_if_index");
9299 M (L2_PATCH_ADD_DEL, mp);
9301 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
9302 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
9303 mp->is_add = is_add;
9311 u8 localsid_addr[16];
9320 api_sr_localsid_add_del (vat_main_t * vam)
9322 unformat_input_t *i = vam->input;
9323 vl_api_sr_localsid_add_del_t *mp;
9326 ip6_address_t localsid;
9330 u32 fib_table = ~(u32) 0;
9331 ip46_address_t nh_addr;
9332 clib_memset (&nh_addr, 0, sizeof (ip46_address_t));
9334 bool nexthop_set = 0;
9338 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9340 if (unformat (i, "del"))
9342 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
9343 else if (unformat (i, "next-hop %U", unformat_ip46_address, &nh_addr))
9345 else if (unformat (i, "behavior %u", &behavior));
9346 else if (unformat (i, "sw_if_index %u", &sw_if_index));
9347 else if (unformat (i, "fib-table %u", &fib_table));
9348 else if (unformat (i, "end.psp %u", &behavior));
9353 M (SR_LOCALSID_ADD_DEL, mp);
9355 clib_memcpy (mp->localsid, &localsid, sizeof (mp->localsid));
9359 clib_memcpy (&mp->nh_addr.un, &nh_addr, sizeof (mp->nh_addr.un));
9361 mp->behavior = behavior;
9362 mp->sw_if_index = ntohl (sw_if_index);
9363 mp->fib_table = ntohl (fib_table);
9364 mp->end_psp = end_psp;
9365 mp->is_del = is_del;
9373 api_ioam_enable (vat_main_t * vam)
9375 unformat_input_t *input = vam->input;
9376 vl_api_ioam_enable_t *mp;
9378 int has_trace_option = 0;
9379 int has_pot_option = 0;
9380 int has_seqno_option = 0;
9381 int has_analyse_option = 0;
9384 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9386 if (unformat (input, "trace"))
9387 has_trace_option = 1;
9388 else if (unformat (input, "pot"))
9390 else if (unformat (input, "seqno"))
9391 has_seqno_option = 1;
9392 else if (unformat (input, "analyse"))
9393 has_analyse_option = 1;
9397 M (IOAM_ENABLE, mp);
9398 mp->id = htons (id);
9399 mp->seqno = has_seqno_option;
9400 mp->analyse = has_analyse_option;
9401 mp->pot_enable = has_pot_option;
9402 mp->trace_enable = has_trace_option;
9411 api_ioam_disable (vat_main_t * vam)
9413 vl_api_ioam_disable_t *mp;
9416 M (IOAM_DISABLE, mp);
9422 #define foreach_tcp_proto_field \
9426 #define foreach_udp_proto_field \
9430 #define foreach_ip4_proto_field \
9442 u16 src_port, dst_port;
9445 #if VPP_API_TEST_BUILTIN == 0
9447 unformat_tcp_mask (unformat_input_t * input, va_list * args)
9449 u8 **maskp = va_arg (*args, u8 **);
9451 u8 found_something = 0;
9454 #define _(a) u8 a=0;
9455 foreach_tcp_proto_field;
9458 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9461 #define _(a) else if (unformat (input, #a)) a=1;
9462 foreach_tcp_proto_field
9468 #define _(a) found_something += a;
9469 foreach_tcp_proto_field;
9472 if (found_something == 0)
9475 vec_validate (mask, sizeof (*tcp) - 1);
9477 tcp = (tcp_header_t *) mask;
9479 #define _(a) if (a) clib_memset (&tcp->a, 0xff, sizeof (tcp->a));
9480 foreach_tcp_proto_field;
9488 unformat_udp_mask (unformat_input_t * input, va_list * args)
9490 u8 **maskp = va_arg (*args, u8 **);
9492 u8 found_something = 0;
9495 #define _(a) u8 a=0;
9496 foreach_udp_proto_field;
9499 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9502 #define _(a) else if (unformat (input, #a)) a=1;
9503 foreach_udp_proto_field
9509 #define _(a) found_something += a;
9510 foreach_udp_proto_field;
9513 if (found_something == 0)
9516 vec_validate (mask, sizeof (*udp) - 1);
9518 udp = (udp_header_t *) mask;
9520 #define _(a) if (a) clib_memset (&udp->a, 0xff, sizeof (udp->a));
9521 foreach_udp_proto_field;
9529 unformat_l4_mask (unformat_input_t * input, va_list * args)
9531 u8 **maskp = va_arg (*args, u8 **);
9532 u16 src_port = 0, dst_port = 0;
9533 tcpudp_header_t *tcpudp;
9535 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9537 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
9539 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
9541 else if (unformat (input, "src_port"))
9543 else if (unformat (input, "dst_port"))
9549 if (!src_port && !dst_port)
9553 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
9555 tcpudp = (tcpudp_header_t *) mask;
9556 tcpudp->src_port = src_port;
9557 tcpudp->dst_port = dst_port;
9565 unformat_ip4_mask (unformat_input_t * input, va_list * args)
9567 u8 **maskp = va_arg (*args, u8 **);
9569 u8 found_something = 0;
9572 #define _(a) u8 a=0;
9573 foreach_ip4_proto_field;
9579 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9581 if (unformat (input, "version"))
9583 else if (unformat (input, "hdr_length"))
9585 else if (unformat (input, "src"))
9587 else if (unformat (input, "dst"))
9589 else if (unformat (input, "proto"))
9592 #define _(a) else if (unformat (input, #a)) a=1;
9593 foreach_ip4_proto_field
9599 #define _(a) found_something += a;
9600 foreach_ip4_proto_field;
9603 if (found_something == 0)
9606 vec_validate (mask, sizeof (*ip) - 1);
9608 ip = (ip4_header_t *) mask;
9610 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
9611 foreach_ip4_proto_field;
9614 ip->ip_version_and_header_length = 0;
9617 ip->ip_version_and_header_length |= 0xF0;
9620 ip->ip_version_and_header_length |= 0x0F;
9626 #define foreach_ip6_proto_field \
9634 unformat_ip6_mask (unformat_input_t * input, va_list * args)
9636 u8 **maskp = va_arg (*args, u8 **);
9638 u8 found_something = 0;
9640 u32 ip_version_traffic_class_and_flow_label;
9642 #define _(a) u8 a=0;
9643 foreach_ip6_proto_field;
9646 u8 traffic_class = 0;
9649 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9651 if (unformat (input, "version"))
9653 else if (unformat (input, "traffic-class"))
9655 else if (unformat (input, "flow-label"))
9657 else if (unformat (input, "src"))
9659 else if (unformat (input, "dst"))
9661 else if (unformat (input, "proto"))
9664 #define _(a) else if (unformat (input, #a)) a=1;
9665 foreach_ip6_proto_field
9671 #define _(a) found_something += a;
9672 foreach_ip6_proto_field;
9675 if (found_something == 0)
9678 vec_validate (mask, sizeof (*ip) - 1);
9680 ip = (ip6_header_t *) mask;
9682 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
9683 foreach_ip6_proto_field;
9686 ip_version_traffic_class_and_flow_label = 0;
9689 ip_version_traffic_class_and_flow_label |= 0xF0000000;
9692 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
9695 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
9697 ip->ip_version_traffic_class_and_flow_label =
9698 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9705 unformat_l3_mask (unformat_input_t * input, va_list * args)
9707 u8 **maskp = va_arg (*args, u8 **);
9709 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9711 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
9713 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
9722 unformat_l2_mask (unformat_input_t * input, va_list * args)
9724 u8 **maskp = va_arg (*args, u8 **);
9739 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9741 if (unformat (input, "src"))
9743 else if (unformat (input, "dst"))
9745 else if (unformat (input, "proto"))
9747 else if (unformat (input, "tag1"))
9749 else if (unformat (input, "tag2"))
9751 else if (unformat (input, "ignore-tag1"))
9753 else if (unformat (input, "ignore-tag2"))
9755 else if (unformat (input, "cos1"))
9757 else if (unformat (input, "cos2"))
9759 else if (unformat (input, "dot1q"))
9761 else if (unformat (input, "dot1ad"))
9766 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
9767 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9770 if (tag1 || ignore_tag1 || cos1 || dot1q)
9772 if (tag2 || ignore_tag2 || cos2 || dot1ad)
9775 vec_validate (mask, len - 1);
9778 clib_memset (mask, 0xff, 6);
9781 clib_memset (mask + 6, 0xff, 6);
9785 /* inner vlan tag */
9794 mask[21] = mask[20] = 0xff;
9815 mask[16] = mask[17] = 0xff;
9825 mask[12] = mask[13] = 0xff;
9832 unformat_classify_mask (unformat_input_t * input, va_list * args)
9834 u8 **maskp = va_arg (*args, u8 **);
9835 u32 *skipp = va_arg (*args, u32 *);
9836 u32 *matchp = va_arg (*args, u32 *);
9844 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9846 if (unformat (input, "hex %U", unformat_hex_string, &mask))
9848 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
9850 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
9852 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
9866 if (mask || l2 || l3 || l4)
9870 /* "With a free Ethernet header in every package" */
9872 vec_validate (l2, 13);
9876 vec_append (mask, l3);
9881 vec_append (mask, l4);
9886 /* Scan forward looking for the first significant mask octet */
9887 for (i = 0; i < vec_len (mask); i++)
9891 /* compute (skip, match) params */
9892 *skipp = i / sizeof (u32x4);
9893 vec_delete (mask, *skipp * sizeof (u32x4), 0);
9895 /* Pad mask to an even multiple of the vector size */
9896 while (vec_len (mask) % sizeof (u32x4))
9899 match = vec_len (mask) / sizeof (u32x4);
9901 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
9903 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
9904 if (*tmp || *(tmp + 1))
9909 clib_warning ("BUG: match 0");
9911 _vec_len (mask) = match * sizeof (u32x4);
9921 #endif /* VPP_API_TEST_BUILTIN */
9923 #define foreach_l2_next \
9925 _(ethernet, ETHERNET_INPUT) \
9930 unformat_l2_next_index (unformat_input_t * input, va_list * args)
9932 u32 *miss_next_indexp = va_arg (*args, u32 *);
9937 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
9941 if (unformat (input, "%d", &tmp))
9950 *miss_next_indexp = next_index;
9954 #define foreach_ip_next \
9960 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
9962 u32 *miss_next_indexp = va_arg (*args, u32 *);
9967 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
9971 if (unformat (input, "%d", &tmp))
9980 *miss_next_indexp = next_index;
9984 #define foreach_acl_next \
9988 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
9990 u32 *miss_next_indexp = va_arg (*args, u32 *);
9995 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
9999 if (unformat (input, "permit"))
10004 else if (unformat (input, "%d", &tmp))
10013 *miss_next_indexp = next_index;
10018 unformat_policer_precolor (unformat_input_t * input, va_list * args)
10020 u32 *r = va_arg (*args, u32 *);
10022 if (unformat (input, "conform-color"))
10023 *r = POLICE_CONFORM;
10024 else if (unformat (input, "exceed-color"))
10025 *r = POLICE_EXCEED;
10033 api_classify_add_del_table (vat_main_t * vam)
10035 unformat_input_t *i = vam->input;
10036 vl_api_classify_add_del_table_t *mp;
10043 u32 table_index = ~0;
10044 u32 next_table_index = ~0;
10045 u32 miss_next_index = ~0;
10046 u32 memory_size = 32 << 20;
10048 u32 current_data_flag = 0;
10049 int current_data_offset = 0;
10052 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10054 if (unformat (i, "del"))
10056 else if (unformat (i, "del-chain"))
10061 else if (unformat (i, "buckets %d", &nbuckets))
10063 else if (unformat (i, "memory_size %d", &memory_size))
10065 else if (unformat (i, "skip %d", &skip))
10067 else if (unformat (i, "match %d", &match))
10069 else if (unformat (i, "table %d", &table_index))
10071 else if (unformat (i, "mask %U", unformat_classify_mask,
10072 &mask, &skip, &match))
10074 else if (unformat (i, "next-table %d", &next_table_index))
10076 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
10079 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
10082 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
10085 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
10087 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
10093 if (is_add && mask == 0)
10095 errmsg ("Mask required");
10099 if (is_add && skip == ~0)
10101 errmsg ("skip count required");
10105 if (is_add && match == ~0)
10107 errmsg ("match count required");
10111 if (!is_add && table_index == ~0)
10113 errmsg ("table index required for delete");
10117 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
10119 mp->is_add = is_add;
10120 mp->del_chain = del_chain;
10121 mp->table_index = ntohl (table_index);
10122 mp->nbuckets = ntohl (nbuckets);
10123 mp->memory_size = ntohl (memory_size);
10124 mp->skip_n_vectors = ntohl (skip);
10125 mp->match_n_vectors = ntohl (match);
10126 mp->next_table_index = ntohl (next_table_index);
10127 mp->miss_next_index = ntohl (miss_next_index);
10128 mp->current_data_flag = ntohl (current_data_flag);
10129 mp->current_data_offset = ntohl (current_data_offset);
10130 mp->mask_len = ntohl (vec_len (mask));
10131 clib_memcpy (mp->mask, mask, vec_len (mask));
10140 #if VPP_API_TEST_BUILTIN == 0
10142 unformat_l4_match (unformat_input_t * input, va_list * args)
10144 u8 **matchp = va_arg (*args, u8 **);
10146 u8 *proto_header = 0;
10152 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10154 if (unformat (input, "src_port %d", &src_port))
10156 else if (unformat (input, "dst_port %d", &dst_port))
10162 h.src_port = clib_host_to_net_u16 (src_port);
10163 h.dst_port = clib_host_to_net_u16 (dst_port);
10164 vec_validate (proto_header, sizeof (h) - 1);
10165 memcpy (proto_header, &h, sizeof (h));
10167 *matchp = proto_header;
10173 unformat_ip4_match (unformat_input_t * input, va_list * args)
10175 u8 **matchp = va_arg (*args, u8 **);
10180 int hdr_length = 0;
10181 u32 hdr_length_val;
10182 int src = 0, dst = 0;
10183 ip4_address_t src_val, dst_val;
10190 int fragment_id = 0;
10191 u32 fragment_id_val;
10197 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10199 if (unformat (input, "version %d", &version_val))
10201 else if (unformat (input, "hdr_length %d", &hdr_length_val))
10203 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
10205 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
10207 else if (unformat (input, "proto %d", &proto_val))
10209 else if (unformat (input, "tos %d", &tos_val))
10211 else if (unformat (input, "length %d", &length_val))
10213 else if (unformat (input, "fragment_id %d", &fragment_id_val))
10215 else if (unformat (input, "ttl %d", &ttl_val))
10217 else if (unformat (input, "checksum %d", &checksum_val))
10223 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
10224 + ttl + checksum == 0)
10228 * Aligned because we use the real comparison functions
10230 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10232 ip = (ip4_header_t *) match;
10234 /* These are realistically matched in practice */
10236 ip->src_address.as_u32 = src_val.as_u32;
10239 ip->dst_address.as_u32 = dst_val.as_u32;
10242 ip->protocol = proto_val;
10245 /* These are not, but they're included for completeness */
10247 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
10250 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
10256 ip->length = clib_host_to_net_u16 (length_val);
10262 ip->checksum = clib_host_to_net_u16 (checksum_val);
10269 unformat_ip6_match (unformat_input_t * input, va_list * args)
10271 u8 **matchp = va_arg (*args, u8 **);
10276 u8 traffic_class = 0;
10277 u32 traffic_class_val = 0;
10280 int src = 0, dst = 0;
10281 ip6_address_t src_val, dst_val;
10284 int payload_length = 0;
10285 u32 payload_length_val;
10288 u32 ip_version_traffic_class_and_flow_label;
10290 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10292 if (unformat (input, "version %d", &version_val))
10294 else if (unformat (input, "traffic_class %d", &traffic_class_val))
10296 else if (unformat (input, "flow_label %d", &flow_label_val))
10298 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
10300 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
10302 else if (unformat (input, "proto %d", &proto_val))
10304 else if (unformat (input, "payload_length %d", &payload_length_val))
10305 payload_length = 1;
10306 else if (unformat (input, "hop_limit %d", &hop_limit_val))
10312 if (version + traffic_class + flow_label + src + dst + proto +
10313 payload_length + hop_limit == 0)
10317 * Aligned because we use the real comparison functions
10319 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10321 ip = (ip6_header_t *) match;
10324 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
10327 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
10330 ip->protocol = proto_val;
10332 ip_version_traffic_class_and_flow_label = 0;
10335 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
10338 ip_version_traffic_class_and_flow_label |=
10339 (traffic_class_val & 0xFF) << 20;
10342 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
10344 ip->ip_version_traffic_class_and_flow_label =
10345 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10347 if (payload_length)
10348 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
10351 ip->hop_limit = hop_limit_val;
10358 unformat_l3_match (unformat_input_t * input, va_list * args)
10360 u8 **matchp = va_arg (*args, u8 **);
10362 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10364 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
10366 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
10375 unformat_vlan_tag (unformat_input_t * input, va_list * args)
10377 u8 *tagp = va_arg (*args, u8 *);
10380 if (unformat (input, "%d", &tag))
10382 tagp[0] = (tag >> 8) & 0x0F;
10383 tagp[1] = tag & 0xFF;
10391 unformat_l2_match (unformat_input_t * input, va_list * args)
10393 u8 **matchp = va_arg (*args, u8 **);
10406 u8 ignore_tag1 = 0;
10407 u8 ignore_tag2 = 0;
10413 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10415 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
10418 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
10420 else if (unformat (input, "proto %U",
10421 unformat_ethernet_type_host_byte_order, &proto_val))
10423 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
10425 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
10427 else if (unformat (input, "ignore-tag1"))
10429 else if (unformat (input, "ignore-tag2"))
10431 else if (unformat (input, "cos1 %d", &cos1_val))
10433 else if (unformat (input, "cos2 %d", &cos2_val))
10438 if ((src + dst + proto + tag1 + tag2 +
10439 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10442 if (tag1 || ignore_tag1 || cos1)
10444 if (tag2 || ignore_tag2 || cos2)
10447 vec_validate_aligned (match, len - 1, sizeof (u32x4));
10450 clib_memcpy (match, dst_val, 6);
10453 clib_memcpy (match + 6, src_val, 6);
10457 /* inner vlan tag */
10458 match[19] = tag2_val[1];
10459 match[18] = tag2_val[0];
10461 match[18] |= (cos2_val & 0x7) << 5;
10464 match[21] = proto_val & 0xff;
10465 match[20] = proto_val >> 8;
10469 match[15] = tag1_val[1];
10470 match[14] = tag1_val[0];
10473 match[14] |= (cos1_val & 0x7) << 5;
10479 match[15] = tag1_val[1];
10480 match[14] = tag1_val[0];
10483 match[17] = proto_val & 0xff;
10484 match[16] = proto_val >> 8;
10487 match[14] |= (cos1_val & 0x7) << 5;
10493 match[18] |= (cos2_val & 0x7) << 5;
10495 match[14] |= (cos1_val & 0x7) << 5;
10498 match[13] = proto_val & 0xff;
10499 match[12] = proto_val >> 8;
10507 unformat_qos_source (unformat_input_t * input, va_list * args)
10509 int *qs = va_arg (*args, int *);
10511 if (unformat (input, "ip"))
10512 *qs = QOS_SOURCE_IP;
10513 else if (unformat (input, "mpls"))
10514 *qs = QOS_SOURCE_MPLS;
10515 else if (unformat (input, "ext"))
10516 *qs = QOS_SOURCE_EXT;
10517 else if (unformat (input, "vlan"))
10518 *qs = QOS_SOURCE_VLAN;
10527 api_unformat_classify_match (unformat_input_t * input, va_list * args)
10529 u8 **matchp = va_arg (*args, u8 **);
10530 u32 skip_n_vectors = va_arg (*args, u32);
10531 u32 match_n_vectors = va_arg (*args, u32);
10538 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10540 if (unformat (input, "hex %U", unformat_hex_string, &match))
10542 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
10544 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
10546 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
10560 if (match || l2 || l3 || l4)
10562 if (l2 || l3 || l4)
10564 /* "Win a free Ethernet header in every packet" */
10566 vec_validate_aligned (l2, 13, sizeof (u32x4));
10570 vec_append_aligned (match, l3, sizeof (u32x4));
10575 vec_append_aligned (match, l4, sizeof (u32x4));
10580 /* Make sure the vector is big enough even if key is all 0's */
10581 vec_validate_aligned
10582 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
10585 /* Set size, include skipped vectors */
10586 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
10597 api_classify_add_del_session (vat_main_t * vam)
10599 unformat_input_t *i = vam->input;
10600 vl_api_classify_add_del_session_t *mp;
10602 u32 table_index = ~0;
10603 u32 hit_next_index = ~0;
10604 u32 opaque_index = ~0;
10607 u32 skip_n_vectors = 0;
10608 u32 match_n_vectors = 0;
10614 * Warning: you have to supply skip_n and match_n
10615 * because the API client cant simply look at the classify
10619 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10621 if (unformat (i, "del"))
10623 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
10626 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
10629 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
10632 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
10634 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
10636 else if (unformat (i, "opaque-index %d", &opaque_index))
10638 else if (unformat (i, "skip_n %d", &skip_n_vectors))
10640 else if (unformat (i, "match_n %d", &match_n_vectors))
10642 else if (unformat (i, "match %U", api_unformat_classify_match,
10643 &match, skip_n_vectors, match_n_vectors))
10645 else if (unformat (i, "advance %d", &advance))
10647 else if (unformat (i, "table-index %d", &table_index))
10649 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
10651 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
10653 else if (unformat (i, "action %d", &action))
10655 else if (unformat (i, "metadata %d", &metadata))
10661 if (table_index == ~0)
10663 errmsg ("Table index required");
10667 if (is_add && match == 0)
10669 errmsg ("Match value required");
10673 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
10675 mp->is_add = is_add;
10676 mp->table_index = ntohl (table_index);
10677 mp->hit_next_index = ntohl (hit_next_index);
10678 mp->opaque_index = ntohl (opaque_index);
10679 mp->advance = ntohl (advance);
10680 mp->action = action;
10681 mp->metadata = ntohl (metadata);
10682 mp->match_len = ntohl (vec_len (match));
10683 clib_memcpy (mp->match, match, vec_len (match));
10692 api_classify_set_interface_ip_table (vat_main_t * vam)
10694 unformat_input_t *i = vam->input;
10695 vl_api_classify_set_interface_ip_table_t *mp;
10697 int sw_if_index_set;
10698 u32 table_index = ~0;
10702 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10704 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10705 sw_if_index_set = 1;
10706 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10707 sw_if_index_set = 1;
10708 else if (unformat (i, "table %d", &table_index))
10712 clib_warning ("parse error '%U'", format_unformat_error, i);
10717 if (sw_if_index_set == 0)
10719 errmsg ("missing interface name or sw_if_index");
10724 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
10726 mp->sw_if_index = ntohl (sw_if_index);
10727 mp->table_index = ntohl (table_index);
10728 mp->is_ipv6 = is_ipv6;
10736 api_classify_set_interface_l2_tables (vat_main_t * vam)
10738 unformat_input_t *i = vam->input;
10739 vl_api_classify_set_interface_l2_tables_t *mp;
10741 int sw_if_index_set;
10742 u32 ip4_table_index = ~0;
10743 u32 ip6_table_index = ~0;
10744 u32 other_table_index = ~0;
10748 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10750 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10751 sw_if_index_set = 1;
10752 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10753 sw_if_index_set = 1;
10754 else if (unformat (i, "ip4-table %d", &ip4_table_index))
10756 else if (unformat (i, "ip6-table %d", &ip6_table_index))
10758 else if (unformat (i, "other-table %d", &other_table_index))
10760 else if (unformat (i, "is-input %d", &is_input))
10764 clib_warning ("parse error '%U'", format_unformat_error, i);
10769 if (sw_if_index_set == 0)
10771 errmsg ("missing interface name or sw_if_index");
10776 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
10778 mp->sw_if_index = ntohl (sw_if_index);
10779 mp->ip4_table_index = ntohl (ip4_table_index);
10780 mp->ip6_table_index = ntohl (ip6_table_index);
10781 mp->other_table_index = ntohl (other_table_index);
10782 mp->is_input = (u8) is_input;
10790 api_set_ipfix_exporter (vat_main_t * vam)
10792 unformat_input_t *i = vam->input;
10793 vl_api_set_ipfix_exporter_t *mp;
10794 ip4_address_t collector_address;
10795 u8 collector_address_set = 0;
10796 u32 collector_port = ~0;
10797 ip4_address_t src_address;
10798 u8 src_address_set = 0;
10801 u32 template_interval = ~0;
10802 u8 udp_checksum = 0;
10805 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10807 if (unformat (i, "collector_address %U", unformat_ip4_address,
10808 &collector_address))
10809 collector_address_set = 1;
10810 else if (unformat (i, "collector_port %d", &collector_port))
10812 else if (unformat (i, "src_address %U", unformat_ip4_address,
10814 src_address_set = 1;
10815 else if (unformat (i, "vrf_id %d", &vrf_id))
10817 else if (unformat (i, "path_mtu %d", &path_mtu))
10819 else if (unformat (i, "template_interval %d", &template_interval))
10821 else if (unformat (i, "udp_checksum"))
10827 if (collector_address_set == 0)
10829 errmsg ("collector_address required");
10833 if (src_address_set == 0)
10835 errmsg ("src_address required");
10839 M (SET_IPFIX_EXPORTER, mp);
10841 memcpy (mp->collector_address.un.ip4, collector_address.data,
10842 sizeof (collector_address.data));
10843 mp->collector_port = htons ((u16) collector_port);
10844 memcpy (mp->src_address.un.ip4, src_address.data,
10845 sizeof (src_address.data));
10846 mp->vrf_id = htonl (vrf_id);
10847 mp->path_mtu = htonl (path_mtu);
10848 mp->template_interval = htonl (template_interval);
10849 mp->udp_checksum = udp_checksum;
10857 api_set_ipfix_classify_stream (vat_main_t * vam)
10859 unformat_input_t *i = vam->input;
10860 vl_api_set_ipfix_classify_stream_t *mp;
10862 u32 src_port = UDP_DST_PORT_ipfix;
10865 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10867 if (unformat (i, "domain %d", &domain_id))
10869 else if (unformat (i, "src_port %d", &src_port))
10873 errmsg ("unknown input `%U'", format_unformat_error, i);
10878 M (SET_IPFIX_CLASSIFY_STREAM, mp);
10880 mp->domain_id = htonl (domain_id);
10881 mp->src_port = htons ((u16) src_port);
10889 api_ipfix_classify_table_add_del (vat_main_t * vam)
10891 unformat_input_t *i = vam->input;
10892 vl_api_ipfix_classify_table_add_del_t *mp;
10894 u32 classify_table_index = ~0;
10896 u8 transport_protocol = 255;
10899 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10901 if (unformat (i, "add"))
10903 else if (unformat (i, "del"))
10905 else if (unformat (i, "table %d", &classify_table_index))
10907 else if (unformat (i, "ip4"))
10909 else if (unformat (i, "ip6"))
10911 else if (unformat (i, "tcp"))
10912 transport_protocol = 6;
10913 else if (unformat (i, "udp"))
10914 transport_protocol = 17;
10917 errmsg ("unknown input `%U'", format_unformat_error, i);
10924 errmsg ("expecting: add|del");
10927 if (classify_table_index == ~0)
10929 errmsg ("classifier table not specified");
10932 if (ip_version == 0)
10934 errmsg ("IP version not specified");
10938 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
10940 mp->is_add = is_add;
10941 mp->table_id = htonl (classify_table_index);
10942 mp->ip_version = ip_version;
10943 mp->transport_protocol = transport_protocol;
10951 api_get_node_index (vat_main_t * vam)
10953 unformat_input_t *i = vam->input;
10954 vl_api_get_node_index_t *mp;
10958 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10960 if (unformat (i, "node %s", &name))
10967 errmsg ("node name required");
10970 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10972 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10976 M (GET_NODE_INDEX, mp);
10977 clib_memcpy (mp->node_name, name, vec_len (name));
10986 api_get_next_index (vat_main_t * vam)
10988 unformat_input_t *i = vam->input;
10989 vl_api_get_next_index_t *mp;
10990 u8 *node_name = 0, *next_node_name = 0;
10993 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10995 if (unformat (i, "node-name %s", &node_name))
10997 else if (unformat (i, "next-node-name %s", &next_node_name))
11001 if (node_name == 0)
11003 errmsg ("node name required");
11006 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
11008 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11012 if (next_node_name == 0)
11014 errmsg ("next node name required");
11017 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
11019 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
11023 M (GET_NEXT_INDEX, mp);
11024 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
11025 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
11026 vec_free (node_name);
11027 vec_free (next_node_name);
11035 api_add_node_next (vat_main_t * vam)
11037 unformat_input_t *i = vam->input;
11038 vl_api_add_node_next_t *mp;
11043 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11045 if (unformat (i, "node %s", &name))
11047 else if (unformat (i, "next %s", &next))
11054 errmsg ("node name required");
11057 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11059 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11064 errmsg ("next node required");
11067 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
11069 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
11073 M (ADD_NODE_NEXT, mp);
11074 clib_memcpy (mp->node_name, name, vec_len (name));
11075 clib_memcpy (mp->next_name, next, vec_len (next));
11085 api_l2tpv3_create_tunnel (vat_main_t * vam)
11087 unformat_input_t *i = vam->input;
11088 ip6_address_t client_address, our_address;
11089 int client_address_set = 0;
11090 int our_address_set = 0;
11091 u32 local_session_id = 0;
11092 u32 remote_session_id = 0;
11093 u64 local_cookie = 0;
11094 u64 remote_cookie = 0;
11095 u8 l2_sublayer_present = 0;
11096 vl_api_l2tpv3_create_tunnel_t *mp;
11099 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11101 if (unformat (i, "client_address %U", unformat_ip6_address,
11103 client_address_set = 1;
11104 else if (unformat (i, "our_address %U", unformat_ip6_address,
11106 our_address_set = 1;
11107 else if (unformat (i, "local_session_id %d", &local_session_id))
11109 else if (unformat (i, "remote_session_id %d", &remote_session_id))
11111 else if (unformat (i, "local_cookie %lld", &local_cookie))
11113 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
11115 else if (unformat (i, "l2-sublayer-present"))
11116 l2_sublayer_present = 1;
11121 if (client_address_set == 0)
11123 errmsg ("client_address required");
11127 if (our_address_set == 0)
11129 errmsg ("our_address required");
11133 M (L2TPV3_CREATE_TUNNEL, mp);
11135 clib_memcpy (mp->client_address.un.ip6, client_address.as_u8,
11136 sizeof (ip6_address_t));
11138 clib_memcpy (mp->our_address.un.ip6, our_address.as_u8,
11139 sizeof (ip6_address_t));
11141 mp->local_session_id = ntohl (local_session_id);
11142 mp->remote_session_id = ntohl (remote_session_id);
11143 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
11144 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
11145 mp->l2_sublayer_present = l2_sublayer_present;
11153 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
11155 unformat_input_t *i = vam->input;
11157 u8 sw_if_index_set = 0;
11158 u64 new_local_cookie = 0;
11159 u64 new_remote_cookie = 0;
11160 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
11163 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11165 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11166 sw_if_index_set = 1;
11167 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11168 sw_if_index_set = 1;
11169 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
11171 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
11177 if (sw_if_index_set == 0)
11179 errmsg ("missing interface name or sw_if_index");
11183 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
11185 mp->sw_if_index = ntohl (sw_if_index);
11186 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
11187 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
11195 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
11197 unformat_input_t *i = vam->input;
11198 vl_api_l2tpv3_interface_enable_disable_t *mp;
11200 u8 sw_if_index_set = 0;
11201 u8 enable_disable = 1;
11204 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11206 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11207 sw_if_index_set = 1;
11208 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11209 sw_if_index_set = 1;
11210 else if (unformat (i, "enable"))
11211 enable_disable = 1;
11212 else if (unformat (i, "disable"))
11213 enable_disable = 0;
11218 if (sw_if_index_set == 0)
11220 errmsg ("missing interface name or sw_if_index");
11224 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
11226 mp->sw_if_index = ntohl (sw_if_index);
11227 mp->enable_disable = enable_disable;
11235 api_l2tpv3_set_lookup_key (vat_main_t * vam)
11237 unformat_input_t *i = vam->input;
11238 vl_api_l2tpv3_set_lookup_key_t *mp;
11242 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11244 if (unformat (i, "lookup_v6_src"))
11245 key = L2T_LOOKUP_SRC_ADDRESS;
11246 else if (unformat (i, "lookup_v6_dst"))
11247 key = L2T_LOOKUP_DST_ADDRESS;
11248 else if (unformat (i, "lookup_session_id"))
11249 key = L2T_LOOKUP_SESSION_ID;
11254 if (key == (u8) ~ 0)
11256 errmsg ("l2tp session lookup key unset");
11260 M (L2TPV3_SET_LOOKUP_KEY, mp);
11269 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
11270 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11272 vat_main_t *vam = &vat_main;
11274 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
11275 format_ip6_address, mp->our_address,
11276 format_ip6_address, mp->client_address,
11277 clib_net_to_host_u32 (mp->sw_if_index));
11280 " local cookies %016llx %016llx remote cookie %016llx",
11281 clib_net_to_host_u64 (mp->local_cookie[0]),
11282 clib_net_to_host_u64 (mp->local_cookie[1]),
11283 clib_net_to_host_u64 (mp->remote_cookie));
11285 print (vam->ofp, " local session-id %d remote session-id %d",
11286 clib_net_to_host_u32 (mp->local_session_id),
11287 clib_net_to_host_u32 (mp->remote_session_id));
11289 print (vam->ofp, " l2 specific sublayer %s\n",
11290 mp->l2_sublayer_present ? "preset" : "absent");
11294 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
11295 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11297 vat_main_t *vam = &vat_main;
11298 vat_json_node_t *node = NULL;
11299 struct in6_addr addr;
11301 if (VAT_JSON_ARRAY != vam->json_tree.type)
11303 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11304 vat_json_init_array (&vam->json_tree);
11306 node = vat_json_array_add (&vam->json_tree);
11308 vat_json_init_object (node);
11310 clib_memcpy (&addr, mp->our_address.un.ip6, sizeof (addr));
11311 vat_json_object_add_ip6 (node, "our_address", addr);
11312 clib_memcpy (&addr, mp->client_address.un.ip6, sizeof (addr));
11313 vat_json_object_add_ip6 (node, "client_address", addr);
11315 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
11316 vat_json_init_array (lc);
11317 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
11318 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
11319 vat_json_object_add_uint (node, "remote_cookie",
11320 clib_net_to_host_u64 (mp->remote_cookie));
11322 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
11323 vat_json_object_add_uint (node, "local_session_id",
11324 clib_net_to_host_u32 (mp->local_session_id));
11325 vat_json_object_add_uint (node, "remote_session_id",
11326 clib_net_to_host_u32 (mp->remote_session_id));
11327 vat_json_object_add_string_copy (node, "l2_sublayer",
11328 mp->l2_sublayer_present ? (u8 *) "present"
11329 : (u8 *) "absent");
11333 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
11335 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
11336 vl_api_control_ping_t *mp_ping;
11339 /* Get list of l2tpv3-tunnel interfaces */
11340 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
11343 /* Use a control ping for synchronization */
11344 MPING (CONTROL_PING, mp_ping);
11352 static void vl_api_sw_interface_tap_v2_details_t_handler
11353 (vl_api_sw_interface_tap_v2_details_t * mp)
11355 vat_main_t *vam = &vat_main;
11358 format (0, "%U/%d", format_ip4_address, mp->host_ip4_prefix.address,
11359 mp->host_ip4_prefix.len);
11361 format (0, "%U/%d", format_ip6_address, mp->host_ip6_prefix.address,
11362 mp->host_ip6_prefix.len);
11365 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s 0x%-08x",
11366 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
11367 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
11368 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
11369 mp->host_bridge, ip4, ip6, ntohl (mp->tap_flags));
11375 static void vl_api_sw_interface_tap_v2_details_t_handler_json
11376 (vl_api_sw_interface_tap_v2_details_t * mp)
11378 vat_main_t *vam = &vat_main;
11379 vat_json_node_t *node = NULL;
11381 if (VAT_JSON_ARRAY != vam->json_tree.type)
11383 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11384 vat_json_init_array (&vam->json_tree);
11386 node = vat_json_array_add (&vam->json_tree);
11388 vat_json_init_object (node);
11389 vat_json_object_add_uint (node, "id", ntohl (mp->id));
11390 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11391 vat_json_object_add_uint (node, "tap_flags", ntohl (mp->tap_flags));
11392 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
11393 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
11394 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
11395 vat_json_object_add_string_copy (node, "host_mac_addr",
11396 format (0, "%U", format_ethernet_address,
11397 &mp->host_mac_addr));
11398 vat_json_object_add_string_copy (node, "host_namespace",
11399 mp->host_namespace);
11400 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
11401 vat_json_object_add_string_copy (node, "host_ip4_addr",
11402 format (0, "%U/%d", format_ip4_address,
11403 mp->host_ip4_prefix.address,
11404 mp->host_ip4_prefix.len));
11405 vat_json_object_add_string_copy (node, "host_ip6_prefix",
11406 format (0, "%U/%d", format_ip6_address,
11407 mp->host_ip6_prefix.address,
11408 mp->host_ip6_prefix.len));
11413 api_sw_interface_tap_v2_dump (vat_main_t * vam)
11415 vl_api_sw_interface_tap_v2_dump_t *mp;
11416 vl_api_control_ping_t *mp_ping;
11420 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
11421 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
11422 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
11425 /* Get list of tap interfaces */
11426 M (SW_INTERFACE_TAP_V2_DUMP, mp);
11429 /* Use a control ping for synchronization */
11430 MPING (CONTROL_PING, mp_ping);
11437 static void vl_api_sw_interface_virtio_pci_details_t_handler
11438 (vl_api_sw_interface_virtio_pci_details_t * mp)
11440 vat_main_t *vam = &vat_main;
11455 addr.domain = ntohs (mp->pci_addr.domain);
11456 addr.bus = mp->pci_addr.bus;
11457 addr.slot = mp->pci_addr.slot;
11458 addr.function = mp->pci_addr.function;
11460 u8 *pci_addr = format (0, "%04x:%02x:%02x.%x", addr.domain, addr.bus,
11461 addr.slot, addr.function);
11464 "\n%-12s %-12d %-12d %-12d %-17U 0x%-08llx",
11465 pci_addr, ntohl (mp->sw_if_index),
11466 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
11467 format_ethernet_address, mp->mac_addr,
11468 clib_net_to_host_u64 (mp->features));
11469 vec_free (pci_addr);
11472 static void vl_api_sw_interface_virtio_pci_details_t_handler_json
11473 (vl_api_sw_interface_virtio_pci_details_t * mp)
11475 vat_main_t *vam = &vat_main;
11476 vat_json_node_t *node = NULL;
11477 vlib_pci_addr_t pci_addr;
11479 if (VAT_JSON_ARRAY != vam->json_tree.type)
11481 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11482 vat_json_init_array (&vam->json_tree);
11484 node = vat_json_array_add (&vam->json_tree);
11486 pci_addr.domain = ntohs (mp->pci_addr.domain);
11487 pci_addr.bus = mp->pci_addr.bus;
11488 pci_addr.slot = mp->pci_addr.slot;
11489 pci_addr.function = mp->pci_addr.function;
11491 vat_json_init_object (node);
11492 vat_json_object_add_uint (node, "pci-addr", pci_addr.as_u32);
11493 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11494 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
11495 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
11496 vat_json_object_add_uint (node, "features",
11497 clib_net_to_host_u64 (mp->features));
11498 vat_json_object_add_string_copy (node, "mac_addr",
11499 format (0, "%U", format_ethernet_address,
11504 api_sw_interface_virtio_pci_dump (vat_main_t * vam)
11506 vl_api_sw_interface_virtio_pci_dump_t *mp;
11507 vl_api_control_ping_t *mp_ping;
11511 "\n%-12s %-12s %-12s %-12s %-17s %-08s",
11512 "pci_addr", "sw_if_index", "rx_ring_sz", "tx_ring_sz",
11513 "mac_addr", "features");
11515 /* Get list of tap interfaces */
11516 M (SW_INTERFACE_VIRTIO_PCI_DUMP, mp);
11519 /* Use a control ping for synchronization */
11520 MPING (CONTROL_PING, mp_ping);
11528 api_vxlan_offload_rx (vat_main_t * vam)
11530 unformat_input_t *line_input = vam->input;
11531 vl_api_vxlan_offload_rx_t *mp;
11532 u32 hw_if_index = ~0, rx_if_index = ~0;
11536 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11538 if (unformat (line_input, "del"))
11540 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
11543 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
11545 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
11548 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
11552 errmsg ("parse error '%U'", format_unformat_error, line_input);
11557 if (hw_if_index == ~0)
11559 errmsg ("no hw interface");
11563 if (rx_if_index == ~0)
11565 errmsg ("no rx tunnel");
11569 M (VXLAN_OFFLOAD_RX, mp);
11571 mp->hw_if_index = ntohl (hw_if_index);
11572 mp->sw_if_index = ntohl (rx_if_index);
11573 mp->enable = is_add;
11580 static uword unformat_vxlan_decap_next
11581 (unformat_input_t * input, va_list * args)
11583 u32 *result = va_arg (*args, u32 *);
11586 if (unformat (input, "l2"))
11587 *result = VXLAN_INPUT_NEXT_L2_INPUT;
11588 else if (unformat (input, "%d", &tmp))
11596 api_vxlan_add_del_tunnel (vat_main_t * vam)
11598 unformat_input_t *line_input = vam->input;
11599 vl_api_vxlan_add_del_tunnel_t *mp;
11600 ip46_address_t src, dst;
11602 u8 ipv4_set = 0, ipv6_set = 0;
11607 u32 mcast_sw_if_index = ~0;
11608 u32 encap_vrf_id = 0;
11609 u32 decap_next_index = ~0;
11613 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
11614 clib_memset (&src, 0, sizeof src);
11615 clib_memset (&dst, 0, sizeof dst);
11617 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11619 if (unformat (line_input, "del"))
11621 else if (unformat (line_input, "instance %d", &instance))
11624 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
11630 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
11636 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
11642 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
11647 else if (unformat (line_input, "group %U %U",
11648 unformat_ip4_address, &dst.ip4,
11649 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11651 grp_set = dst_set = 1;
11654 else if (unformat (line_input, "group %U",
11655 unformat_ip4_address, &dst.ip4))
11657 grp_set = dst_set = 1;
11660 else if (unformat (line_input, "group %U %U",
11661 unformat_ip6_address, &dst.ip6,
11662 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11664 grp_set = dst_set = 1;
11667 else if (unformat (line_input, "group %U",
11668 unformat_ip6_address, &dst.ip6))
11670 grp_set = dst_set = 1;
11674 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
11676 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11678 else if (unformat (line_input, "decap-next %U",
11679 unformat_vxlan_decap_next, &decap_next_index))
11681 else if (unformat (line_input, "vni %d", &vni))
11685 errmsg ("parse error '%U'", format_unformat_error, line_input);
11692 errmsg ("tunnel src address not specified");
11697 errmsg ("tunnel dst address not specified");
11701 if (grp_set && !ip46_address_is_multicast (&dst))
11703 errmsg ("tunnel group address not multicast");
11706 if (grp_set && mcast_sw_if_index == ~0)
11708 errmsg ("tunnel nonexistent multicast device");
11711 if (grp_set == 0 && ip46_address_is_multicast (&dst))
11713 errmsg ("tunnel dst address must be unicast");
11718 if (ipv4_set && ipv6_set)
11720 errmsg ("both IPv4 and IPv6 addresses specified");
11724 if ((vni == 0) || (vni >> 24))
11726 errmsg ("vni not specified or out of range");
11730 M (VXLAN_ADD_DEL_TUNNEL, mp);
11734 clib_memcpy (mp->src_address.un.ip6, &src.ip6, sizeof (src.ip6));
11735 clib_memcpy (mp->dst_address.un.ip6, &dst.ip6, sizeof (dst.ip6));
11739 clib_memcpy (mp->src_address.un.ip4, &src.ip4, sizeof (src.ip4));
11740 clib_memcpy (mp->dst_address.un.ip4, &dst.ip4, sizeof (dst.ip4));
11742 mp->src_address.af = ipv6_set;
11743 mp->dst_address.af = ipv6_set;
11745 mp->instance = htonl (instance);
11746 mp->encap_vrf_id = ntohl (encap_vrf_id);
11747 mp->decap_next_index = ntohl (decap_next_index);
11748 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
11749 mp->vni = ntohl (vni);
11750 mp->is_add = is_add;
11757 static void vl_api_vxlan_tunnel_details_t_handler
11758 (vl_api_vxlan_tunnel_details_t * mp)
11760 vat_main_t *vam = &vat_main;
11761 ip46_address_t src =
11762 to_ip46 (mp->dst_address.af, (u8 *) & mp->dst_address.un);
11763 ip46_address_t dst =
11764 to_ip46 (mp->dst_address.af, (u8 *) & mp->src_address.un);
11766 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
11767 ntohl (mp->sw_if_index),
11768 ntohl (mp->instance),
11769 format_ip46_address, &src, IP46_TYPE_ANY,
11770 format_ip46_address, &dst, IP46_TYPE_ANY,
11771 ntohl (mp->encap_vrf_id),
11772 ntohl (mp->decap_next_index), ntohl (mp->vni),
11773 ntohl (mp->mcast_sw_if_index));
11776 static void vl_api_vxlan_tunnel_details_t_handler_json
11777 (vl_api_vxlan_tunnel_details_t * mp)
11779 vat_main_t *vam = &vat_main;
11780 vat_json_node_t *node = NULL;
11782 if (VAT_JSON_ARRAY != vam->json_tree.type)
11784 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11785 vat_json_init_array (&vam->json_tree);
11787 node = vat_json_array_add (&vam->json_tree);
11789 vat_json_init_object (node);
11790 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11792 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
11794 if (mp->src_address.af)
11796 struct in6_addr ip6;
11798 clib_memcpy (&ip6, mp->src_address.un.ip6, sizeof (ip6));
11799 vat_json_object_add_ip6 (node, "src_address", ip6);
11800 clib_memcpy (&ip6, mp->dst_address.un.ip6, sizeof (ip6));
11801 vat_json_object_add_ip6 (node, "dst_address", ip6);
11805 struct in_addr ip4;
11807 clib_memcpy (&ip4, mp->src_address.un.ip4, sizeof (ip4));
11808 vat_json_object_add_ip4 (node, "src_address", ip4);
11809 clib_memcpy (&ip4, mp->dst_address.un.ip4, sizeof (ip4));
11810 vat_json_object_add_ip4 (node, "dst_address", ip4);
11812 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11813 vat_json_object_add_uint (node, "decap_next_index",
11814 ntohl (mp->decap_next_index));
11815 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11816 vat_json_object_add_uint (node, "mcast_sw_if_index",
11817 ntohl (mp->mcast_sw_if_index));
11821 api_vxlan_tunnel_dump (vat_main_t * vam)
11823 unformat_input_t *i = vam->input;
11824 vl_api_vxlan_tunnel_dump_t *mp;
11825 vl_api_control_ping_t *mp_ping;
11827 u8 sw_if_index_set = 0;
11830 /* Parse args required to build the message */
11831 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11833 if (unformat (i, "sw_if_index %d", &sw_if_index))
11834 sw_if_index_set = 1;
11839 if (sw_if_index_set == 0)
11844 if (!vam->json_output)
11846 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
11847 "sw_if_index", "instance", "src_address", "dst_address",
11848 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
11851 /* Get list of vxlan-tunnel interfaces */
11852 M (VXLAN_TUNNEL_DUMP, mp);
11854 mp->sw_if_index = htonl (sw_if_index);
11858 /* Use a control ping for synchronization */
11859 MPING (CONTROL_PING, mp_ping);
11866 static uword unformat_geneve_decap_next
11867 (unformat_input_t * input, va_list * args)
11869 u32 *result = va_arg (*args, u32 *);
11872 if (unformat (input, "l2"))
11873 *result = GENEVE_INPUT_NEXT_L2_INPUT;
11874 else if (unformat (input, "%d", &tmp))
11882 api_geneve_add_del_tunnel (vat_main_t * vam)
11884 unformat_input_t *line_input = vam->input;
11885 vl_api_geneve_add_del_tunnel_t *mp;
11886 ip46_address_t src, dst;
11888 u8 ipv4_set = 0, ipv6_set = 0;
11892 u32 mcast_sw_if_index = ~0;
11893 u32 encap_vrf_id = 0;
11894 u32 decap_next_index = ~0;
11898 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
11899 clib_memset (&src, 0, sizeof src);
11900 clib_memset (&dst, 0, sizeof dst);
11902 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11904 if (unformat (line_input, "del"))
11907 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
11913 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
11919 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
11925 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
11930 else if (unformat (line_input, "group %U %U",
11931 unformat_ip4_address, &dst.ip4,
11932 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11934 grp_set = dst_set = 1;
11937 else if (unformat (line_input, "group %U",
11938 unformat_ip4_address, &dst.ip4))
11940 grp_set = dst_set = 1;
11943 else if (unformat (line_input, "group %U %U",
11944 unformat_ip6_address, &dst.ip6,
11945 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11947 grp_set = dst_set = 1;
11950 else if (unformat (line_input, "group %U",
11951 unformat_ip6_address, &dst.ip6))
11953 grp_set = dst_set = 1;
11957 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
11959 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11961 else if (unformat (line_input, "decap-next %U",
11962 unformat_geneve_decap_next, &decap_next_index))
11964 else if (unformat (line_input, "vni %d", &vni))
11968 errmsg ("parse error '%U'", format_unformat_error, line_input);
11975 errmsg ("tunnel src address not specified");
11980 errmsg ("tunnel dst address not specified");
11984 if (grp_set && !ip46_address_is_multicast (&dst))
11986 errmsg ("tunnel group address not multicast");
11989 if (grp_set && mcast_sw_if_index == ~0)
11991 errmsg ("tunnel nonexistent multicast device");
11994 if (grp_set == 0 && ip46_address_is_multicast (&dst))
11996 errmsg ("tunnel dst address must be unicast");
12001 if (ipv4_set && ipv6_set)
12003 errmsg ("both IPv4 and IPv6 addresses specified");
12007 if ((vni == 0) || (vni >> 24))
12009 errmsg ("vni not specified or out of range");
12013 M (GENEVE_ADD_DEL_TUNNEL, mp);
12017 clib_memcpy (&mp->local_address.un.ip6, &src.ip6, sizeof (src.ip6));
12018 clib_memcpy (&mp->remote_address.un.ip6, &dst.ip6, sizeof (dst.ip6));
12022 clib_memcpy (&mp->local_address.un.ip4, &src.ip4, sizeof (src.ip4));
12023 clib_memcpy (&mp->remote_address.un.ip4, &dst.ip4, sizeof (dst.ip4));
12025 mp->encap_vrf_id = ntohl (encap_vrf_id);
12026 mp->decap_next_index = ntohl (decap_next_index);
12027 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12028 mp->vni = ntohl (vni);
12029 mp->is_add = is_add;
12036 static void vl_api_geneve_tunnel_details_t_handler
12037 (vl_api_geneve_tunnel_details_t * mp)
12039 vat_main_t *vam = &vat_main;
12040 ip46_address_t src = {.as_u64[0] = 0,.as_u64[1] = 0 };
12041 ip46_address_t dst = {.as_u64[0] = 0,.as_u64[1] = 0 };
12043 if (mp->src_address.af == ADDRESS_IP6)
12045 clib_memcpy (&src.ip6, &mp->src_address.un.ip6, sizeof (ip6_address_t));
12046 clib_memcpy (&dst.ip6, &mp->dst_address.un.ip6, sizeof (ip6_address_t));
12050 clib_memcpy (&src.ip4, &mp->src_address.un.ip4, sizeof (ip4_address_t));
12051 clib_memcpy (&dst.ip4, &mp->dst_address.un.ip4, sizeof (ip4_address_t));
12054 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12055 ntohl (mp->sw_if_index),
12056 format_ip46_address, &src, IP46_TYPE_ANY,
12057 format_ip46_address, &dst, IP46_TYPE_ANY,
12058 ntohl (mp->encap_vrf_id),
12059 ntohl (mp->decap_next_index), ntohl (mp->vni),
12060 ntohl (mp->mcast_sw_if_index));
12063 static void vl_api_geneve_tunnel_details_t_handler_json
12064 (vl_api_geneve_tunnel_details_t * mp)
12066 vat_main_t *vam = &vat_main;
12067 vat_json_node_t *node = NULL;
12070 if (VAT_JSON_ARRAY != vam->json_tree.type)
12072 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12073 vat_json_init_array (&vam->json_tree);
12075 node = vat_json_array_add (&vam->json_tree);
12077 vat_json_init_object (node);
12078 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12079 is_ipv6 = mp->src_address.af == ADDRESS_IP6;
12082 struct in6_addr ip6;
12084 clib_memcpy (&ip6, &mp->src_address.un.ip6, sizeof (ip6));
12085 vat_json_object_add_ip6 (node, "src_address", ip6);
12086 clib_memcpy (&ip6, &mp->dst_address.un.ip6, sizeof (ip6));
12087 vat_json_object_add_ip6 (node, "dst_address", ip6);
12091 struct in_addr ip4;
12093 clib_memcpy (&ip4, &mp->src_address.un.ip4, sizeof (ip4));
12094 vat_json_object_add_ip4 (node, "src_address", ip4);
12095 clib_memcpy (&ip4, &mp->dst_address.un.ip4, sizeof (ip4));
12096 vat_json_object_add_ip4 (node, "dst_address", ip4);
12098 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12099 vat_json_object_add_uint (node, "decap_next_index",
12100 ntohl (mp->decap_next_index));
12101 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12102 vat_json_object_add_uint (node, "mcast_sw_if_index",
12103 ntohl (mp->mcast_sw_if_index));
12107 api_geneve_tunnel_dump (vat_main_t * vam)
12109 unformat_input_t *i = vam->input;
12110 vl_api_geneve_tunnel_dump_t *mp;
12111 vl_api_control_ping_t *mp_ping;
12113 u8 sw_if_index_set = 0;
12116 /* Parse args required to build the message */
12117 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12119 if (unformat (i, "sw_if_index %d", &sw_if_index))
12120 sw_if_index_set = 1;
12125 if (sw_if_index_set == 0)
12130 if (!vam->json_output)
12132 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12133 "sw_if_index", "local_address", "remote_address",
12134 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12137 /* Get list of geneve-tunnel interfaces */
12138 M (GENEVE_TUNNEL_DUMP, mp);
12140 mp->sw_if_index = htonl (sw_if_index);
12144 /* Use a control ping for synchronization */
12145 M (CONTROL_PING, mp_ping);
12153 api_gre_tunnel_add_del (vat_main_t * vam)
12155 unformat_input_t *line_input = vam->input;
12156 vl_api_address_t src = { }, dst =
12159 vl_api_gre_tunnel_add_del_t *mp;
12160 vl_api_gre_tunnel_type_t t_type;
12164 u32 outer_table_id = 0;
12165 u32 session_id = 0;
12169 t_type = GRE_API_TUNNEL_TYPE_L3;
12171 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12173 if (unformat (line_input, "del"))
12175 else if (unformat (line_input, "instance %d", &instance))
12177 else if (unformat (line_input, "src %U", unformat_vl_api_address, &src))
12181 else if (unformat (line_input, "dst %U", unformat_vl_api_address, &dst))
12185 else if (unformat (line_input, "outer-table-id %d", &outer_table_id))
12187 else if (unformat (line_input, "teb"))
12188 t_type = GRE_API_TUNNEL_TYPE_TEB;
12189 else if (unformat (line_input, "erspan %d", &session_id))
12190 t_type = GRE_API_TUNNEL_TYPE_ERSPAN;
12193 errmsg ("parse error '%U'", format_unformat_error, line_input);
12200 errmsg ("tunnel src address not specified");
12205 errmsg ("tunnel dst address not specified");
12209 M (GRE_TUNNEL_ADD_DEL, mp);
12211 clib_memcpy (&mp->tunnel.src, &src, sizeof (mp->tunnel.src));
12212 clib_memcpy (&mp->tunnel.dst, &dst, sizeof (mp->tunnel.dst));
12214 mp->tunnel.instance = htonl (instance);
12215 mp->tunnel.outer_table_id = htonl (outer_table_id);
12216 mp->is_add = is_add;
12217 mp->tunnel.session_id = htons ((u16) session_id);
12218 mp->tunnel.type = htonl (t_type);
12225 static void vl_api_gre_tunnel_details_t_handler
12226 (vl_api_gre_tunnel_details_t * mp)
12228 vat_main_t *vam = &vat_main;
12230 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
12231 ntohl (mp->tunnel.sw_if_index),
12232 ntohl (mp->tunnel.instance),
12233 format_vl_api_address, &mp->tunnel.src,
12234 format_vl_api_address, &mp->tunnel.dst,
12235 mp->tunnel.type, ntohl (mp->tunnel.outer_table_id),
12236 ntohl (mp->tunnel.session_id));
12239 static void vl_api_gre_tunnel_details_t_handler_json
12240 (vl_api_gre_tunnel_details_t * mp)
12242 vat_main_t *vam = &vat_main;
12243 vat_json_node_t *node = NULL;
12245 if (VAT_JSON_ARRAY != vam->json_tree.type)
12247 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12248 vat_json_init_array (&vam->json_tree);
12250 node = vat_json_array_add (&vam->json_tree);
12252 vat_json_init_object (node);
12253 vat_json_object_add_uint (node, "sw_if_index",
12254 ntohl (mp->tunnel.sw_if_index));
12255 vat_json_object_add_uint (node, "instance", ntohl (mp->tunnel.instance));
12257 vat_json_object_add_address (node, "src", &mp->tunnel.src);
12258 vat_json_object_add_address (node, "dst", &mp->tunnel.dst);
12259 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel.type);
12260 vat_json_object_add_uint (node, "outer_table_id",
12261 ntohl (mp->tunnel.outer_table_id));
12262 vat_json_object_add_uint (node, "session_id", mp->tunnel.session_id);
12266 api_gre_tunnel_dump (vat_main_t * vam)
12268 unformat_input_t *i = vam->input;
12269 vl_api_gre_tunnel_dump_t *mp;
12270 vl_api_control_ping_t *mp_ping;
12272 u8 sw_if_index_set = 0;
12275 /* Parse args required to build the message */
12276 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12278 if (unformat (i, "sw_if_index %d", &sw_if_index))
12279 sw_if_index_set = 1;
12284 if (sw_if_index_set == 0)
12289 if (!vam->json_output)
12291 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
12292 "sw_if_index", "instance", "src_address", "dst_address",
12293 "tunnel_type", "outer_fib_id", "session_id");
12296 /* Get list of gre-tunnel interfaces */
12297 M (GRE_TUNNEL_DUMP, mp);
12299 mp->sw_if_index = htonl (sw_if_index);
12303 /* Use a control ping for synchronization */
12304 MPING (CONTROL_PING, mp_ping);
12312 api_l2_fib_clear_table (vat_main_t * vam)
12314 // unformat_input_t * i = vam->input;
12315 vl_api_l2_fib_clear_table_t *mp;
12318 M (L2_FIB_CLEAR_TABLE, mp);
12326 api_l2_interface_efp_filter (vat_main_t * vam)
12328 unformat_input_t *i = vam->input;
12329 vl_api_l2_interface_efp_filter_t *mp;
12332 u8 sw_if_index_set = 0;
12335 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12337 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12338 sw_if_index_set = 1;
12339 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12340 sw_if_index_set = 1;
12341 else if (unformat (i, "enable"))
12343 else if (unformat (i, "disable"))
12347 clib_warning ("parse error '%U'", format_unformat_error, i);
12352 if (sw_if_index_set == 0)
12354 errmsg ("missing sw_if_index");
12358 M (L2_INTERFACE_EFP_FILTER, mp);
12360 mp->sw_if_index = ntohl (sw_if_index);
12361 mp->enable_disable = enable;
12368 #define foreach_vtr_op \
12369 _("disable", L2_VTR_DISABLED) \
12370 _("push-1", L2_VTR_PUSH_1) \
12371 _("push-2", L2_VTR_PUSH_2) \
12372 _("pop-1", L2_VTR_POP_1) \
12373 _("pop-2", L2_VTR_POP_2) \
12374 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
12375 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
12376 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
12377 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
12380 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
12382 unformat_input_t *i = vam->input;
12383 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
12385 u8 sw_if_index_set = 0;
12388 u32 push_dot1q = 1;
12393 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12395 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12396 sw_if_index_set = 1;
12397 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12398 sw_if_index_set = 1;
12399 else if (unformat (i, "vtr_op %d", &vtr_op))
12401 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
12404 else if (unformat (i, "push_dot1q %d", &push_dot1q))
12406 else if (unformat (i, "tag1 %d", &tag1))
12408 else if (unformat (i, "tag2 %d", &tag2))
12412 clib_warning ("parse error '%U'", format_unformat_error, i);
12417 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
12419 errmsg ("missing vtr operation or sw_if_index");
12423 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
12424 mp->sw_if_index = ntohl (sw_if_index);
12425 mp->vtr_op = ntohl (vtr_op);
12426 mp->push_dot1q = ntohl (push_dot1q);
12427 mp->tag1 = ntohl (tag1);
12428 mp->tag2 = ntohl (tag2);
12436 api_create_vhost_user_if (vat_main_t * vam)
12438 unformat_input_t *i = vam->input;
12439 vl_api_create_vhost_user_if_t *mp;
12442 u8 file_name_set = 0;
12443 u32 custom_dev_instance = ~0;
12445 u8 use_custom_mac = 0;
12446 u8 disable_mrg_rxbuf = 0;
12447 u8 disable_indirect_desc = 0;
12450 u8 enable_packed = 0;
12453 /* Shut up coverity */
12454 clib_memset (hwaddr, 0, sizeof (hwaddr));
12456 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12458 if (unformat (i, "socket %s", &file_name))
12462 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12464 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
12465 use_custom_mac = 1;
12466 else if (unformat (i, "server"))
12468 else if (unformat (i, "disable_mrg_rxbuf"))
12469 disable_mrg_rxbuf = 1;
12470 else if (unformat (i, "disable_indirect_desc"))
12471 disable_indirect_desc = 1;
12472 else if (unformat (i, "gso"))
12474 else if (unformat (i, "packed"))
12476 else if (unformat (i, "tag %s", &tag))
12482 if (file_name_set == 0)
12484 errmsg ("missing socket file name");
12488 if (vec_len (file_name) > 255)
12490 errmsg ("socket file name too long");
12493 vec_add1 (file_name, 0);
12495 M (CREATE_VHOST_USER_IF, mp);
12497 mp->is_server = is_server;
12498 mp->disable_mrg_rxbuf = disable_mrg_rxbuf;
12499 mp->disable_indirect_desc = disable_indirect_desc;
12500 mp->enable_gso = enable_gso;
12501 mp->enable_packed = enable_packed;
12502 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12503 vec_free (file_name);
12504 if (custom_dev_instance != ~0)
12507 mp->custom_dev_instance = ntohl (custom_dev_instance);
12510 mp->use_custom_mac = use_custom_mac;
12511 clib_memcpy (mp->mac_address, hwaddr, 6);
12513 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
12522 api_modify_vhost_user_if (vat_main_t * vam)
12524 unformat_input_t *i = vam->input;
12525 vl_api_modify_vhost_user_if_t *mp;
12528 u8 file_name_set = 0;
12529 u32 custom_dev_instance = ~0;
12530 u8 sw_if_index_set = 0;
12531 u32 sw_if_index = (u32) ~ 0;
12533 u8 enable_packed = 0;
12536 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12538 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12539 sw_if_index_set = 1;
12540 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12541 sw_if_index_set = 1;
12542 else if (unformat (i, "socket %s", &file_name))
12546 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12548 else if (unformat (i, "server"))
12550 else if (unformat (i, "gso"))
12552 else if (unformat (i, "packed"))
12558 if (sw_if_index_set == 0)
12560 errmsg ("missing sw_if_index or interface name");
12564 if (file_name_set == 0)
12566 errmsg ("missing socket file name");
12570 if (vec_len (file_name) > 255)
12572 errmsg ("socket file name too long");
12575 vec_add1 (file_name, 0);
12577 M (MODIFY_VHOST_USER_IF, mp);
12579 mp->sw_if_index = ntohl (sw_if_index);
12580 mp->is_server = is_server;
12581 mp->enable_gso = enable_gso;
12582 mp->enable_packed = enable_packed;
12583 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12584 vec_free (file_name);
12585 if (custom_dev_instance != ~0)
12588 mp->custom_dev_instance = ntohl (custom_dev_instance);
12597 api_delete_vhost_user_if (vat_main_t * vam)
12599 unformat_input_t *i = vam->input;
12600 vl_api_delete_vhost_user_if_t *mp;
12601 u32 sw_if_index = ~0;
12602 u8 sw_if_index_set = 0;
12605 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12607 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12608 sw_if_index_set = 1;
12609 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12610 sw_if_index_set = 1;
12615 if (sw_if_index_set == 0)
12617 errmsg ("missing sw_if_index or interface name");
12622 M (DELETE_VHOST_USER_IF, mp);
12624 mp->sw_if_index = ntohl (sw_if_index);
12631 static void vl_api_sw_interface_vhost_user_details_t_handler
12632 (vl_api_sw_interface_vhost_user_details_t * mp)
12634 vat_main_t *vam = &vat_main;
12638 clib_net_to_host_u32 (mp->features_first_32) | ((u64)
12639 clib_net_to_host_u32
12640 (mp->features_last_32) <<
12643 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
12644 (char *) mp->interface_name,
12645 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
12646 features, mp->is_server,
12647 ntohl (mp->num_regions), (char *) mp->sock_filename);
12648 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
12651 static void vl_api_sw_interface_vhost_user_details_t_handler_json
12652 (vl_api_sw_interface_vhost_user_details_t * mp)
12654 vat_main_t *vam = &vat_main;
12655 vat_json_node_t *node = NULL;
12657 if (VAT_JSON_ARRAY != vam->json_tree.type)
12659 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12660 vat_json_init_array (&vam->json_tree);
12662 node = vat_json_array_add (&vam->json_tree);
12664 vat_json_init_object (node);
12665 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12666 vat_json_object_add_string_copy (node, "interface_name",
12667 mp->interface_name);
12668 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
12669 ntohl (mp->virtio_net_hdr_sz));
12670 vat_json_object_add_uint (node, "features_first_32",
12671 clib_net_to_host_u32 (mp->features_first_32));
12672 vat_json_object_add_uint (node, "features_last_32",
12673 clib_net_to_host_u32 (mp->features_last_32));
12674 vat_json_object_add_uint (node, "is_server", mp->is_server);
12675 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
12676 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
12677 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
12681 api_sw_interface_vhost_user_dump (vat_main_t * vam)
12683 vl_api_sw_interface_vhost_user_dump_t *mp;
12684 vl_api_control_ping_t *mp_ping;
12687 "Interface name idx hdr_sz features server regions filename");
12689 /* Get list of vhost-user interfaces */
12690 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
12691 mp->sw_if_index = ntohl (~0);
12694 /* Use a control ping for synchronization */
12695 MPING (CONTROL_PING, mp_ping);
12703 api_show_version (vat_main_t * vam)
12705 vl_api_show_version_t *mp;
12708 M (SHOW_VERSION, mp);
12717 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
12719 unformat_input_t *line_input = vam->input;
12720 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
12721 ip46_address_t local, remote;
12726 u32 mcast_sw_if_index = ~0;
12727 u32 encap_vrf_id = 0;
12728 u32 decap_vrf_id = 0;
12734 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12736 if (unformat (line_input, "del"))
12738 else if (unformat (line_input, "local %U",
12739 unformat_ip46_address, &local))
12743 else if (unformat (line_input, "remote %U",
12744 unformat_ip46_address, &remote))
12748 else if (unformat (line_input, "group %U %U",
12749 unformat_ip46_address, &remote,
12750 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12752 grp_set = remote_set = 1;
12754 else if (unformat (line_input, "group %U",
12755 unformat_ip46_address, &remote))
12757 grp_set = remote_set = 1;
12760 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12762 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12764 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
12766 else if (unformat (line_input, "vni %d", &vni))
12768 else if (unformat (line_input, "next-ip4"))
12770 else if (unformat (line_input, "next-ip6"))
12772 else if (unformat (line_input, "next-ethernet"))
12774 else if (unformat (line_input, "next-nsh"))
12778 errmsg ("parse error '%U'", format_unformat_error, line_input);
12783 if (local_set == 0)
12785 errmsg ("tunnel local address not specified");
12788 if (remote_set == 0)
12790 errmsg ("tunnel remote address not specified");
12793 if (grp_set && mcast_sw_if_index == ~0)
12795 errmsg ("tunnel nonexistent multicast device");
12798 if (ip46_address_is_ip4 (&local) != ip46_address_is_ip4 (&remote))
12800 errmsg ("both IPv4 and IPv6 addresses specified");
12806 errmsg ("vni not specified");
12810 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
12812 ip_address_encode (&local,
12813 ip46_address_is_ip4 (&local) ? IP46_TYPE_IP4 :
12814 IP46_TYPE_IP6, &mp->local);
12815 ip_address_encode (&remote,
12816 ip46_address_is_ip4 (&remote) ? IP46_TYPE_IP4 :
12817 IP46_TYPE_IP6, &mp->remote);
12819 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12820 mp->encap_vrf_id = ntohl (encap_vrf_id);
12821 mp->decap_vrf_id = ntohl (decap_vrf_id);
12822 mp->protocol = protocol;
12823 mp->vni = ntohl (vni);
12824 mp->is_add = is_add;
12831 static void vl_api_vxlan_gpe_tunnel_details_t_handler
12832 (vl_api_vxlan_gpe_tunnel_details_t * mp)
12834 vat_main_t *vam = &vat_main;
12835 ip46_address_t local, remote;
12837 ip_address_decode (&mp->local, &local);
12838 ip_address_decode (&mp->remote, &remote);
12840 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
12841 ntohl (mp->sw_if_index),
12842 format_ip46_address, &local, IP46_TYPE_ANY,
12843 format_ip46_address, &remote, IP46_TYPE_ANY,
12844 ntohl (mp->vni), mp->protocol,
12845 ntohl (mp->mcast_sw_if_index),
12846 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
12850 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
12851 (vl_api_vxlan_gpe_tunnel_details_t * mp)
12853 vat_main_t *vam = &vat_main;
12854 vat_json_node_t *node = NULL;
12855 struct in_addr ip4;
12856 struct in6_addr ip6;
12857 ip46_address_t local, remote;
12859 ip_address_decode (&mp->local, &local);
12860 ip_address_decode (&mp->remote, &remote);
12862 if (VAT_JSON_ARRAY != vam->json_tree.type)
12864 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12865 vat_json_init_array (&vam->json_tree);
12867 node = vat_json_array_add (&vam->json_tree);
12869 vat_json_init_object (node);
12870 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12871 if (ip46_address_is_ip4 (&local))
12873 clib_memcpy (&ip4, &local.ip4, sizeof (ip4));
12874 vat_json_object_add_ip4 (node, "local", ip4);
12875 clib_memcpy (&ip4, &remote.ip4, sizeof (ip4));
12876 vat_json_object_add_ip4 (node, "remote", ip4);
12880 clib_memcpy (&ip6, &local.ip6, sizeof (ip6));
12881 vat_json_object_add_ip6 (node, "local", ip6);
12882 clib_memcpy (&ip6, &remote.ip6, sizeof (ip6));
12883 vat_json_object_add_ip6 (node, "remote", ip6);
12885 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12886 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
12887 vat_json_object_add_uint (node, "mcast_sw_if_index",
12888 ntohl (mp->mcast_sw_if_index));
12889 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12890 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
12891 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12895 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
12897 unformat_input_t *i = vam->input;
12898 vl_api_vxlan_gpe_tunnel_dump_t *mp;
12899 vl_api_control_ping_t *mp_ping;
12901 u8 sw_if_index_set = 0;
12904 /* Parse args required to build the message */
12905 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12907 if (unformat (i, "sw_if_index %d", &sw_if_index))
12908 sw_if_index_set = 1;
12913 if (sw_if_index_set == 0)
12918 if (!vam->json_output)
12920 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
12921 "sw_if_index", "local", "remote", "vni",
12922 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
12925 /* Get list of vxlan-tunnel interfaces */
12926 M (VXLAN_GPE_TUNNEL_DUMP, mp);
12928 mp->sw_if_index = htonl (sw_if_index);
12932 /* Use a control ping for synchronization */
12933 MPING (CONTROL_PING, mp_ping);
12940 static void vl_api_l2_fib_table_details_t_handler
12941 (vl_api_l2_fib_table_details_t * mp)
12943 vat_main_t *vam = &vat_main;
12945 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
12947 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
12948 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
12952 static void vl_api_l2_fib_table_details_t_handler_json
12953 (vl_api_l2_fib_table_details_t * mp)
12955 vat_main_t *vam = &vat_main;
12956 vat_json_node_t *node = NULL;
12958 if (VAT_JSON_ARRAY != vam->json_tree.type)
12960 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12961 vat_json_init_array (&vam->json_tree);
12963 node = vat_json_array_add (&vam->json_tree);
12965 vat_json_init_object (node);
12966 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
12967 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
12968 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12969 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
12970 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
12971 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
12975 api_l2_fib_table_dump (vat_main_t * vam)
12977 unformat_input_t *i = vam->input;
12978 vl_api_l2_fib_table_dump_t *mp;
12979 vl_api_control_ping_t *mp_ping;
12984 /* Parse args required to build the message */
12985 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12987 if (unformat (i, "bd_id %d", &bd_id))
12993 if (bd_id_set == 0)
12995 errmsg ("missing bridge domain");
12999 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
13001 /* Get list of l2 fib entries */
13002 M (L2_FIB_TABLE_DUMP, mp);
13004 mp->bd_id = ntohl (bd_id);
13007 /* Use a control ping for synchronization */
13008 MPING (CONTROL_PING, mp_ping);
13017 api_interface_name_renumber (vat_main_t * vam)
13019 unformat_input_t *line_input = vam->input;
13020 vl_api_interface_name_renumber_t *mp;
13021 u32 sw_if_index = ~0;
13022 u32 new_show_dev_instance = ~0;
13025 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13027 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
13030 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13032 else if (unformat (line_input, "new_show_dev_instance %d",
13033 &new_show_dev_instance))
13039 if (sw_if_index == ~0)
13041 errmsg ("missing interface name or sw_if_index");
13045 if (new_show_dev_instance == ~0)
13047 errmsg ("missing new_show_dev_instance");
13051 M (INTERFACE_NAME_RENUMBER, mp);
13053 mp->sw_if_index = ntohl (sw_if_index);
13054 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
13062 api_want_l2_macs_events (vat_main_t * vam)
13064 unformat_input_t *line_input = vam->input;
13065 vl_api_want_l2_macs_events_t *mp;
13066 u8 enable_disable = 1;
13067 u32 scan_delay = 0;
13068 u32 max_macs_in_event = 0;
13069 u32 learn_limit = 0;
13072 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13074 if (unformat (line_input, "learn-limit %d", &learn_limit))
13076 else if (unformat (line_input, "scan-delay %d", &scan_delay))
13078 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
13080 else if (unformat (line_input, "disable"))
13081 enable_disable = 0;
13086 M (WANT_L2_MACS_EVENTS, mp);
13087 mp->enable_disable = enable_disable;
13088 mp->pid = htonl (getpid ());
13089 mp->learn_limit = htonl (learn_limit);
13090 mp->scan_delay = (u8) scan_delay;
13091 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
13098 api_input_acl_set_interface (vat_main_t * vam)
13100 unformat_input_t *i = vam->input;
13101 vl_api_input_acl_set_interface_t *mp;
13103 int sw_if_index_set;
13104 u32 ip4_table_index = ~0;
13105 u32 ip6_table_index = ~0;
13106 u32 l2_table_index = ~0;
13110 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13112 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13113 sw_if_index_set = 1;
13114 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13115 sw_if_index_set = 1;
13116 else if (unformat (i, "del"))
13118 else if (unformat (i, "ip4-table %d", &ip4_table_index))
13120 else if (unformat (i, "ip6-table %d", &ip6_table_index))
13122 else if (unformat (i, "l2-table %d", &l2_table_index))
13126 clib_warning ("parse error '%U'", format_unformat_error, i);
13131 if (sw_if_index_set == 0)
13133 errmsg ("missing interface name or sw_if_index");
13137 M (INPUT_ACL_SET_INTERFACE, mp);
13139 mp->sw_if_index = ntohl (sw_if_index);
13140 mp->ip4_table_index = ntohl (ip4_table_index);
13141 mp->ip6_table_index = ntohl (ip6_table_index);
13142 mp->l2_table_index = ntohl (l2_table_index);
13143 mp->is_add = is_add;
13151 api_output_acl_set_interface (vat_main_t * vam)
13153 unformat_input_t *i = vam->input;
13154 vl_api_output_acl_set_interface_t *mp;
13156 int sw_if_index_set;
13157 u32 ip4_table_index = ~0;
13158 u32 ip6_table_index = ~0;
13159 u32 l2_table_index = ~0;
13163 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13165 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13166 sw_if_index_set = 1;
13167 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13168 sw_if_index_set = 1;
13169 else if (unformat (i, "del"))
13171 else if (unformat (i, "ip4-table %d", &ip4_table_index))
13173 else if (unformat (i, "ip6-table %d", &ip6_table_index))
13175 else if (unformat (i, "l2-table %d", &l2_table_index))
13179 clib_warning ("parse error '%U'", format_unformat_error, i);
13184 if (sw_if_index_set == 0)
13186 errmsg ("missing interface name or sw_if_index");
13190 M (OUTPUT_ACL_SET_INTERFACE, mp);
13192 mp->sw_if_index = ntohl (sw_if_index);
13193 mp->ip4_table_index = ntohl (ip4_table_index);
13194 mp->ip6_table_index = ntohl (ip6_table_index);
13195 mp->l2_table_index = ntohl (l2_table_index);
13196 mp->is_add = is_add;
13204 api_ip_address_dump (vat_main_t * vam)
13206 unformat_input_t *i = vam->input;
13207 vl_api_ip_address_dump_t *mp;
13208 vl_api_control_ping_t *mp_ping;
13209 u32 sw_if_index = ~0;
13210 u8 sw_if_index_set = 0;
13215 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13217 if (unformat (i, "sw_if_index %d", &sw_if_index))
13218 sw_if_index_set = 1;
13220 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13221 sw_if_index_set = 1;
13222 else if (unformat (i, "ipv4"))
13224 else if (unformat (i, "ipv6"))
13230 if (ipv4_set && ipv6_set)
13232 errmsg ("ipv4 and ipv6 flags cannot be both set");
13236 if ((!ipv4_set) && (!ipv6_set))
13238 errmsg ("no ipv4 nor ipv6 flag set");
13242 if (sw_if_index_set == 0)
13244 errmsg ("missing interface name or sw_if_index");
13248 vam->current_sw_if_index = sw_if_index;
13249 vam->is_ipv6 = ipv6_set;
13251 M (IP_ADDRESS_DUMP, mp);
13252 mp->sw_if_index = ntohl (sw_if_index);
13253 mp->is_ipv6 = ipv6_set;
13256 /* Use a control ping for synchronization */
13257 MPING (CONTROL_PING, mp_ping);
13265 api_ip_dump (vat_main_t * vam)
13267 vl_api_ip_dump_t *mp;
13268 vl_api_control_ping_t *mp_ping;
13269 unformat_input_t *in = vam->input;
13276 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
13278 if (unformat (in, "ipv4"))
13280 else if (unformat (in, "ipv6"))
13286 if (ipv4_set && ipv6_set)
13288 errmsg ("ipv4 and ipv6 flags cannot be both set");
13292 if ((!ipv4_set) && (!ipv6_set))
13294 errmsg ("no ipv4 nor ipv6 flag set");
13298 is_ipv6 = ipv6_set;
13299 vam->is_ipv6 = is_ipv6;
13301 /* free old data */
13302 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
13304 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
13306 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
13309 mp->is_ipv6 = ipv6_set;
13312 /* Use a control ping for synchronization */
13313 MPING (CONTROL_PING, mp_ping);
13321 api_ipsec_spd_add_del (vat_main_t * vam)
13323 unformat_input_t *i = vam->input;
13324 vl_api_ipsec_spd_add_del_t *mp;
13329 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13331 if (unformat (i, "spd_id %d", &spd_id))
13333 else if (unformat (i, "del"))
13337 clib_warning ("parse error '%U'", format_unformat_error, i);
13343 errmsg ("spd_id must be set");
13347 M (IPSEC_SPD_ADD_DEL, mp);
13349 mp->spd_id = ntohl (spd_id);
13350 mp->is_add = is_add;
13358 api_ipsec_interface_add_del_spd (vat_main_t * vam)
13360 unformat_input_t *i = vam->input;
13361 vl_api_ipsec_interface_add_del_spd_t *mp;
13363 u8 sw_if_index_set = 0;
13364 u32 spd_id = (u32) ~ 0;
13368 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13370 if (unformat (i, "del"))
13372 else if (unformat (i, "spd_id %d", &spd_id))
13375 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13376 sw_if_index_set = 1;
13377 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13378 sw_if_index_set = 1;
13381 clib_warning ("parse error '%U'", format_unformat_error, i);
13387 if (spd_id == (u32) ~ 0)
13389 errmsg ("spd_id must be set");
13393 if (sw_if_index_set == 0)
13395 errmsg ("missing interface name or sw_if_index");
13399 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
13401 mp->spd_id = ntohl (spd_id);
13402 mp->sw_if_index = ntohl (sw_if_index);
13403 mp->is_add = is_add;
13411 api_ipsec_spd_entry_add_del (vat_main_t * vam)
13413 unformat_input_t *i = vam->input;
13414 vl_api_ipsec_spd_entry_add_del_t *mp;
13415 u8 is_add = 1, is_outbound = 0;
13416 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
13418 u32 rport_start = 0, rport_stop = (u32) ~ 0;
13419 u32 lport_start = 0, lport_stop = (u32) ~ 0;
13420 vl_api_address_t laddr_start = { }, laddr_stop =
13429 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13431 if (unformat (i, "del"))
13433 if (unformat (i, "outbound"))
13435 if (unformat (i, "inbound"))
13437 else if (unformat (i, "spd_id %d", &spd_id))
13439 else if (unformat (i, "sa_id %d", &sa_id))
13441 else if (unformat (i, "priority %d", &priority))
13443 else if (unformat (i, "protocol %d", &protocol))
13445 else if (unformat (i, "lport_start %d", &lport_start))
13447 else if (unformat (i, "lport_stop %d", &lport_stop))
13449 else if (unformat (i, "rport_start %d", &rport_start))
13451 else if (unformat (i, "rport_stop %d", &rport_stop))
13453 else if (unformat (i, "laddr_start %U",
13454 unformat_vl_api_address, &laddr_start))
13456 else if (unformat (i, "laddr_stop %U", unformat_vl_api_address,
13459 else if (unformat (i, "raddr_start %U", unformat_vl_api_address,
13462 else if (unformat (i, "raddr_stop %U", unformat_vl_api_address,
13466 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
13468 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
13470 clib_warning ("unsupported action: 'resolve'");
13476 clib_warning ("parse error '%U'", format_unformat_error, i);
13482 M (IPSEC_SPD_ENTRY_ADD_DEL, mp);
13484 mp->is_add = is_add;
13486 mp->entry.spd_id = ntohl (spd_id);
13487 mp->entry.priority = ntohl (priority);
13488 mp->entry.is_outbound = is_outbound;
13490 clib_memcpy (&mp->entry.remote_address_start, &raddr_start,
13491 sizeof (vl_api_address_t));
13492 clib_memcpy (&mp->entry.remote_address_stop, &raddr_stop,
13493 sizeof (vl_api_address_t));
13494 clib_memcpy (&mp->entry.local_address_start, &laddr_start,
13495 sizeof (vl_api_address_t));
13496 clib_memcpy (&mp->entry.local_address_stop, &laddr_stop,
13497 sizeof (vl_api_address_t));
13499 mp->entry.protocol = (u8) protocol;
13500 mp->entry.local_port_start = ntohs ((u16) lport_start);
13501 mp->entry.local_port_stop = ntohs ((u16) lport_stop);
13502 mp->entry.remote_port_start = ntohs ((u16) rport_start);
13503 mp->entry.remote_port_stop = ntohs ((u16) rport_stop);
13504 mp->entry.policy = (u8) policy;
13505 mp->entry.sa_id = ntohl (sa_id);
13513 api_ipsec_sad_entry_add_del (vat_main_t * vam)
13515 unformat_input_t *i = vam->input;
13516 vl_api_ipsec_sad_entry_add_del_t *mp;
13517 u32 sad_id = 0, spi = 0;
13518 u8 *ck = 0, *ik = 0;
13521 vl_api_ipsec_crypto_alg_t crypto_alg = IPSEC_API_CRYPTO_ALG_NONE;
13522 vl_api_ipsec_integ_alg_t integ_alg = IPSEC_API_INTEG_ALG_NONE;
13523 vl_api_ipsec_sad_flags_t flags = IPSEC_API_SAD_FLAG_NONE;
13524 vl_api_ipsec_proto_t protocol = IPSEC_API_PROTO_AH;
13525 vl_api_address_t tun_src, tun_dst;
13528 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13530 if (unformat (i, "del"))
13532 else if (unformat (i, "sad_id %d", &sad_id))
13534 else if (unformat (i, "spi %d", &spi))
13536 else if (unformat (i, "esp"))
13537 protocol = IPSEC_API_PROTO_ESP;
13539 if (unformat (i, "tunnel_src %U", unformat_vl_api_address, &tun_src))
13541 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
13542 if (ADDRESS_IP6 == tun_src.af)
13543 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
13546 if (unformat (i, "tunnel_dst %U", unformat_vl_api_address, &tun_dst))
13548 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
13549 if (ADDRESS_IP6 == tun_src.af)
13550 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
13553 if (unformat (i, "crypto_alg %U",
13554 unformat_ipsec_api_crypto_alg, &crypto_alg))
13556 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
13558 else if (unformat (i, "integ_alg %U",
13559 unformat_ipsec_api_integ_alg, &integ_alg))
13561 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
13565 clib_warning ("parse error '%U'", format_unformat_error, i);
13571 M (IPSEC_SAD_ENTRY_ADD_DEL, mp);
13573 mp->is_add = is_add;
13574 mp->entry.sad_id = ntohl (sad_id);
13575 mp->entry.protocol = protocol;
13576 mp->entry.spi = ntohl (spi);
13577 mp->entry.flags = flags;
13579 mp->entry.crypto_algorithm = crypto_alg;
13580 mp->entry.integrity_algorithm = integ_alg;
13581 mp->entry.crypto_key.length = vec_len (ck);
13582 mp->entry.integrity_key.length = vec_len (ik);
13584 if (mp->entry.crypto_key.length > sizeof (mp->entry.crypto_key.data))
13585 mp->entry.crypto_key.length = sizeof (mp->entry.crypto_key.data);
13587 if (mp->entry.integrity_key.length > sizeof (mp->entry.integrity_key.data))
13588 mp->entry.integrity_key.length = sizeof (mp->entry.integrity_key.data);
13591 clib_memcpy (mp->entry.crypto_key.data, ck, mp->entry.crypto_key.length);
13593 clib_memcpy (mp->entry.integrity_key.data, ik,
13594 mp->entry.integrity_key.length);
13596 if (flags & IPSEC_API_SAD_FLAG_IS_TUNNEL)
13598 clib_memcpy (&mp->entry.tunnel_src, &tun_src,
13599 sizeof (mp->entry.tunnel_src));
13600 clib_memcpy (&mp->entry.tunnel_dst, &tun_dst,
13601 sizeof (mp->entry.tunnel_dst));
13610 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
13612 unformat_input_t *i = vam->input;
13613 vl_api_ipsec_tunnel_if_add_del_t *mp;
13614 u32 local_spi = 0, remote_spi = 0;
13615 u32 crypto_alg = 0, integ_alg = 0;
13616 u8 *lck = NULL, *rck = NULL;
13617 u8 *lik = NULL, *rik = NULL;
13618 vl_api_address_t local_ip = { 0 };
13619 vl_api_address_t remote_ip = { 0 };
13623 u8 anti_replay = 0;
13629 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13631 if (unformat (i, "del"))
13633 else if (unformat (i, "esn"))
13635 else if (unformat (i, "anti-replay"))
13637 else if (unformat (i, "count %d", &count))
13639 else if (unformat (i, "local_spi %d", &local_spi))
13641 else if (unformat (i, "remote_spi %d", &remote_spi))
13644 if (unformat (i, "local_ip %U", unformat_vl_api_address, &local_ip))
13647 if (unformat (i, "remote_ip %U", unformat_vl_api_address, &remote_ip))
13649 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
13652 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
13654 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
13656 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
13660 (i, "crypto_alg %U", unformat_ipsec_api_crypto_alg, &crypto_alg))
13662 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
13664 errmsg ("unsupported crypto-alg: '%U'\n",
13665 format_ipsec_crypto_alg, crypto_alg);
13671 (i, "integ_alg %U", unformat_ipsec_api_integ_alg, &integ_alg))
13673 if (integ_alg >= IPSEC_INTEG_N_ALG)
13675 errmsg ("unsupported integ-alg: '%U'\n",
13676 format_ipsec_integ_alg, integ_alg);
13680 else if (unformat (i, "instance %u", &instance))
13684 errmsg ("parse error '%U'\n", format_unformat_error, i);
13691 /* Turn on async mode */
13692 vam->async_mode = 1;
13693 vam->async_errors = 0;
13694 before = vat_time_now (vam);
13697 for (jj = 0; jj < count; jj++)
13699 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
13701 mp->is_add = is_add;
13703 mp->anti_replay = anti_replay;
13706 increment_address (&remote_ip);
13708 clib_memcpy (&mp->local_ip, &local_ip, sizeof (local_ip));
13709 clib_memcpy (&mp->remote_ip, &remote_ip, sizeof (remote_ip));
13711 mp->local_spi = htonl (local_spi + jj);
13712 mp->remote_spi = htonl (remote_spi + jj);
13713 mp->crypto_alg = (u8) crypto_alg;
13715 mp->local_crypto_key_len = 0;
13718 mp->local_crypto_key_len = vec_len (lck);
13719 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
13720 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
13721 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
13724 mp->remote_crypto_key_len = 0;
13727 mp->remote_crypto_key_len = vec_len (rck);
13728 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
13729 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
13730 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
13733 mp->integ_alg = (u8) integ_alg;
13735 mp->local_integ_key_len = 0;
13738 mp->local_integ_key_len = vec_len (lik);
13739 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
13740 mp->local_integ_key_len = sizeof (mp->local_integ_key);
13741 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
13744 mp->remote_integ_key_len = 0;
13747 mp->remote_integ_key_len = vec_len (rik);
13748 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
13749 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
13750 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
13755 mp->renumber = renumber;
13756 mp->show_instance = ntohl (instance);
13761 /* When testing multiple add/del ops, use a control-ping to sync */
13764 vl_api_control_ping_t *mp_ping;
13768 /* Shut off async mode */
13769 vam->async_mode = 0;
13771 MPING (CONTROL_PING, mp_ping);
13774 timeout = vat_time_now (vam) + 1.0;
13775 while (vat_time_now (vam) < timeout)
13776 if (vam->result_ready == 1)
13781 if (vam->retval == -99)
13782 errmsg ("timeout");
13784 if (vam->async_errors > 0)
13786 errmsg ("%d asynchronous errors", vam->async_errors);
13789 vam->async_errors = 0;
13790 after = vat_time_now (vam);
13792 /* slim chance, but we might have eaten SIGTERM on the first iteration */
13796 print (vam->ofp, "%d tunnels in %.6f secs, %.2f tunnels/sec",
13797 count, after - before, count / (after - before));
13801 /* Wait for a reply... */
13810 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
13812 vat_main_t *vam = &vat_main;
13814 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
13815 "crypto_key %U integ_alg %u integ_key %U flags %x "
13816 "tunnel_src_addr %U tunnel_dst_addr %U "
13817 "salt %u seq_outbound %lu last_seq_inbound %lu "
13818 "replay_window %lu stat_index %u\n",
13819 ntohl (mp->entry.sad_id),
13820 ntohl (mp->sw_if_index),
13821 ntohl (mp->entry.spi),
13822 ntohl (mp->entry.protocol),
13823 ntohl (mp->entry.crypto_algorithm),
13824 format_hex_bytes, mp->entry.crypto_key.data,
13825 mp->entry.crypto_key.length, ntohl (mp->entry.integrity_algorithm),
13826 format_hex_bytes, mp->entry.integrity_key.data,
13827 mp->entry.integrity_key.length, ntohl (mp->entry.flags),
13828 format_vl_api_address, &mp->entry.tunnel_src, format_vl_api_address,
13829 &mp->entry.tunnel_dst, ntohl (mp->salt),
13830 clib_net_to_host_u64 (mp->seq_outbound),
13831 clib_net_to_host_u64 (mp->last_seq_inbound),
13832 clib_net_to_host_u64 (mp->replay_window), ntohl (mp->stat_index));
13835 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
13836 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
13838 static void vl_api_ipsec_sa_details_t_handler_json
13839 (vl_api_ipsec_sa_details_t * mp)
13841 vat_main_t *vam = &vat_main;
13842 vat_json_node_t *node = NULL;
13843 vl_api_ipsec_sad_flags_t flags;
13845 if (VAT_JSON_ARRAY != vam->json_tree.type)
13847 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13848 vat_json_init_array (&vam->json_tree);
13850 node = vat_json_array_add (&vam->json_tree);
13852 vat_json_init_object (node);
13853 vat_json_object_add_uint (node, "sa_id", ntohl (mp->entry.sad_id));
13854 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13855 vat_json_object_add_uint (node, "spi", ntohl (mp->entry.spi));
13856 vat_json_object_add_uint (node, "proto", ntohl (mp->entry.protocol));
13857 vat_json_object_add_uint (node, "crypto_alg",
13858 ntohl (mp->entry.crypto_algorithm));
13859 vat_json_object_add_uint (node, "integ_alg",
13860 ntohl (mp->entry.integrity_algorithm));
13861 flags = ntohl (mp->entry.flags);
13862 vat_json_object_add_uint (node, "use_esn",
13863 ! !(flags & IPSEC_API_SAD_FLAG_USE_ESN));
13864 vat_json_object_add_uint (node, "use_anti_replay",
13865 ! !(flags & IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY));
13866 vat_json_object_add_uint (node, "is_tunnel",
13867 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL));
13868 vat_json_object_add_uint (node, "is_tunnel_ip6",
13869 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL_V6));
13870 vat_json_object_add_uint (node, "udp_encap",
13871 ! !(flags & IPSEC_API_SAD_FLAG_UDP_ENCAP));
13872 vat_json_object_add_bytes (node, "crypto_key", mp->entry.crypto_key.data,
13873 mp->entry.crypto_key.length);
13874 vat_json_object_add_bytes (node, "integ_key", mp->entry.integrity_key.data,
13875 mp->entry.integrity_key.length);
13876 vat_json_object_add_address (node, "src", &mp->entry.tunnel_src);
13877 vat_json_object_add_address (node, "dst", &mp->entry.tunnel_dst);
13878 vat_json_object_add_uint (node, "replay_window",
13879 clib_net_to_host_u64 (mp->replay_window));
13880 vat_json_object_add_uint (node, "stat_index", ntohl (mp->stat_index));
13884 api_ipsec_sa_dump (vat_main_t * vam)
13886 unformat_input_t *i = vam->input;
13887 vl_api_ipsec_sa_dump_t *mp;
13888 vl_api_control_ping_t *mp_ping;
13892 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13894 if (unformat (i, "sa_id %d", &sa_id))
13898 clib_warning ("parse error '%U'", format_unformat_error, i);
13903 M (IPSEC_SA_DUMP, mp);
13905 mp->sa_id = ntohl (sa_id);
13909 /* Use a control ping for synchronization */
13910 M (CONTROL_PING, mp_ping);
13918 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
13920 unformat_input_t *i = vam->input;
13921 vl_api_ipsec_tunnel_if_set_sa_t *mp;
13922 u32 sw_if_index = ~0;
13924 u8 is_outbound = (u8) ~ 0;
13927 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13929 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13931 else if (unformat (i, "sa_id %d", &sa_id))
13933 else if (unformat (i, "outbound"))
13935 else if (unformat (i, "inbound"))
13939 clib_warning ("parse error '%U'", format_unformat_error, i);
13944 if (sw_if_index == ~0)
13946 errmsg ("interface must be specified");
13952 errmsg ("SA ID must be specified");
13956 M (IPSEC_TUNNEL_IF_SET_SA, mp);
13958 mp->sw_if_index = htonl (sw_if_index);
13959 mp->sa_id = htonl (sa_id);
13960 mp->is_outbound = is_outbound;
13969 api_get_first_msg_id (vat_main_t * vam)
13971 vl_api_get_first_msg_id_t *mp;
13972 unformat_input_t *i = vam->input;
13977 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13979 if (unformat (i, "client %s", &name))
13987 errmsg ("missing client name");
13990 vec_add1 (name, 0);
13992 if (vec_len (name) > 63)
13994 errmsg ("client name too long");
13998 M (GET_FIRST_MSG_ID, mp);
13999 clib_memcpy (mp->name, name, vec_len (name));
14006 api_cop_interface_enable_disable (vat_main_t * vam)
14008 unformat_input_t *line_input = vam->input;
14009 vl_api_cop_interface_enable_disable_t *mp;
14010 u32 sw_if_index = ~0;
14011 u8 enable_disable = 1;
14014 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14016 if (unformat (line_input, "disable"))
14017 enable_disable = 0;
14018 if (unformat (line_input, "enable"))
14019 enable_disable = 1;
14020 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
14021 vam, &sw_if_index))
14023 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14029 if (sw_if_index == ~0)
14031 errmsg ("missing interface name or sw_if_index");
14035 /* Construct the API message */
14036 M (COP_INTERFACE_ENABLE_DISABLE, mp);
14037 mp->sw_if_index = ntohl (sw_if_index);
14038 mp->enable_disable = enable_disable;
14042 /* Wait for the reply */
14048 api_cop_whitelist_enable_disable (vat_main_t * vam)
14050 unformat_input_t *line_input = vam->input;
14051 vl_api_cop_whitelist_enable_disable_t *mp;
14052 u32 sw_if_index = ~0;
14053 u8 ip4 = 0, ip6 = 0, default_cop = 0;
14057 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14059 if (unformat (line_input, "ip4"))
14061 else if (unformat (line_input, "ip6"))
14063 else if (unformat (line_input, "default"))
14065 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
14066 vam, &sw_if_index))
14068 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14070 else if (unformat (line_input, "fib-id %d", &fib_id))
14076 if (sw_if_index == ~0)
14078 errmsg ("missing interface name or sw_if_index");
14082 /* Construct the API message */
14083 M (COP_WHITELIST_ENABLE_DISABLE, mp);
14084 mp->sw_if_index = ntohl (sw_if_index);
14085 mp->fib_id = ntohl (fib_id);
14088 mp->default_cop = default_cop;
14092 /* Wait for the reply */
14098 api_get_node_graph (vat_main_t * vam)
14100 vl_api_get_node_graph_t *mp;
14103 M (GET_NODE_GRAPH, mp);
14107 /* Wait for the reply */
14113 /** Used for parsing LISP eids */
14114 typedef CLIB_PACKED(struct{
14115 u8 addr[16]; /**< eid address */
14116 u32 len; /**< prefix length if IP */
14117 u8 type; /**< type of eid */
14122 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
14124 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
14126 clib_memset (a, 0, sizeof (a[0]));
14128 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
14130 a->type = 0; /* ipv4 type */
14132 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
14134 a->type = 1; /* ipv6 type */
14136 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
14138 a->type = 2; /* mac type */
14140 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
14142 a->type = 3; /* NSH type */
14143 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
14144 nsh->spi = clib_host_to_net_u32 (nsh->spi);
14151 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
14160 lisp_eid_size_vat (u8 type)
14177 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
14179 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
14183 api_one_add_del_locator_set (vat_main_t * vam)
14185 unformat_input_t *input = vam->input;
14186 vl_api_one_add_del_locator_set_t *mp;
14188 u8 *locator_set_name = NULL;
14189 u8 locator_set_name_set = 0;
14190 vl_api_local_locator_t locator, *locators = 0;
14191 u32 sw_if_index, priority, weight;
14195 /* Parse args required to build the message */
14196 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14198 if (unformat (input, "del"))
14202 else if (unformat (input, "locator-set %s", &locator_set_name))
14204 locator_set_name_set = 1;
14206 else if (unformat (input, "sw_if_index %u p %u w %u",
14207 &sw_if_index, &priority, &weight))
14209 locator.sw_if_index = htonl (sw_if_index);
14210 locator.priority = priority;
14211 locator.weight = weight;
14212 vec_add1 (locators, locator);
14216 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
14217 &sw_if_index, &priority, &weight))
14219 locator.sw_if_index = htonl (sw_if_index);
14220 locator.priority = priority;
14221 locator.weight = weight;
14222 vec_add1 (locators, locator);
14228 if (locator_set_name_set == 0)
14230 errmsg ("missing locator-set name");
14231 vec_free (locators);
14235 if (vec_len (locator_set_name) > 64)
14237 errmsg ("locator-set name too long");
14238 vec_free (locator_set_name);
14239 vec_free (locators);
14242 vec_add1 (locator_set_name, 0);
14244 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
14246 /* Construct the API message */
14247 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
14249 mp->is_add = is_add;
14250 clib_memcpy (mp->locator_set_name, locator_set_name,
14251 vec_len (locator_set_name));
14252 vec_free (locator_set_name);
14254 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
14256 clib_memcpy (mp->locators, locators, data_len);
14257 vec_free (locators);
14262 /* Wait for a reply... */
14267 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
14270 api_one_add_del_locator (vat_main_t * vam)
14272 unformat_input_t *input = vam->input;
14273 vl_api_one_add_del_locator_t *mp;
14274 u32 tmp_if_index = ~0;
14275 u32 sw_if_index = ~0;
14276 u8 sw_if_index_set = 0;
14277 u8 sw_if_index_if_name_set = 0;
14279 u8 priority_set = 0;
14283 u8 *locator_set_name = NULL;
14284 u8 locator_set_name_set = 0;
14287 /* Parse args required to build the message */
14288 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14290 if (unformat (input, "del"))
14294 else if (unformat (input, "locator-set %s", &locator_set_name))
14296 locator_set_name_set = 1;
14298 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
14301 sw_if_index_if_name_set = 1;
14302 sw_if_index = tmp_if_index;
14304 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
14306 sw_if_index_set = 1;
14307 sw_if_index = tmp_if_index;
14309 else if (unformat (input, "p %d", &priority))
14313 else if (unformat (input, "w %d", &weight))
14321 if (locator_set_name_set == 0)
14323 errmsg ("missing locator-set name");
14327 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
14329 errmsg ("missing sw_if_index");
14330 vec_free (locator_set_name);
14334 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
14336 errmsg ("cannot use both params interface name and sw_if_index");
14337 vec_free (locator_set_name);
14341 if (priority_set == 0)
14343 errmsg ("missing locator-set priority");
14344 vec_free (locator_set_name);
14348 if (weight_set == 0)
14350 errmsg ("missing locator-set weight");
14351 vec_free (locator_set_name);
14355 if (vec_len (locator_set_name) > 64)
14357 errmsg ("locator-set name too long");
14358 vec_free (locator_set_name);
14361 vec_add1 (locator_set_name, 0);
14363 /* Construct the API message */
14364 M (ONE_ADD_DEL_LOCATOR, mp);
14366 mp->is_add = is_add;
14367 mp->sw_if_index = ntohl (sw_if_index);
14368 mp->priority = priority;
14369 mp->weight = weight;
14370 clib_memcpy (mp->locator_set_name, locator_set_name,
14371 vec_len (locator_set_name));
14372 vec_free (locator_set_name);
14377 /* Wait for a reply... */
14382 #define api_lisp_add_del_locator api_one_add_del_locator
14385 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
14387 u32 *key_id = va_arg (*args, u32 *);
14390 if (unformat (input, "%s", &s))
14392 if (!strcmp ((char *) s, "sha1"))
14393 key_id[0] = HMAC_SHA_1_96;
14394 else if (!strcmp ((char *) s, "sha256"))
14395 key_id[0] = HMAC_SHA_256_128;
14398 clib_warning ("invalid key_id: '%s'", s);
14399 key_id[0] = HMAC_NO_KEY;
14410 api_one_add_del_local_eid (vat_main_t * vam)
14412 unformat_input_t *input = vam->input;
14413 vl_api_one_add_del_local_eid_t *mp;
14416 lisp_eid_vat_t _eid, *eid = &_eid;
14417 u8 *locator_set_name = 0;
14418 u8 locator_set_name_set = 0;
14424 /* Parse args required to build the message */
14425 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14427 if (unformat (input, "del"))
14431 else if (unformat (input, "vni %d", &vni))
14435 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14439 else if (unformat (input, "locator-set %s", &locator_set_name))
14441 locator_set_name_set = 1;
14443 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
14445 else if (unformat (input, "secret-key %_%v%_", &key))
14451 if (locator_set_name_set == 0)
14453 errmsg ("missing locator-set name");
14459 errmsg ("EID address not set!");
14460 vec_free (locator_set_name);
14464 if (key && (0 == key_id))
14466 errmsg ("invalid key_id!");
14470 if (vec_len (key) > 64)
14472 errmsg ("key too long");
14477 if (vec_len (locator_set_name) > 64)
14479 errmsg ("locator-set name too long");
14480 vec_free (locator_set_name);
14483 vec_add1 (locator_set_name, 0);
14485 /* Construct the API message */
14486 M (ONE_ADD_DEL_LOCAL_EID, mp);
14488 mp->is_add = is_add;
14489 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
14490 mp->eid_type = eid->type;
14491 mp->prefix_len = eid->len;
14492 mp->vni = clib_host_to_net_u32 (vni);
14493 mp->key_id = clib_host_to_net_u16 (key_id);
14494 clib_memcpy (mp->locator_set_name, locator_set_name,
14495 vec_len (locator_set_name));
14496 clib_memcpy (mp->key, key, vec_len (key));
14498 vec_free (locator_set_name);
14504 /* Wait for a reply... */
14509 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
14512 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
14514 u32 dp_table = 0, vni = 0;;
14515 unformat_input_t *input = vam->input;
14516 vl_api_gpe_add_del_fwd_entry_t *mp;
14518 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
14519 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
14520 u8 rmt_eid_set = 0, lcl_eid_set = 0;
14521 u32 action = ~0, w;
14522 ip4_address_t rmt_rloc4, lcl_rloc4;
14523 ip6_address_t rmt_rloc6, lcl_rloc6;
14524 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
14527 clib_memset (&rloc, 0, sizeof (rloc));
14529 /* Parse args required to build the message */
14530 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14532 if (unformat (input, "del"))
14534 else if (unformat (input, "add"))
14536 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
14540 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
14544 else if (unformat (input, "vrf %d", &dp_table))
14546 else if (unformat (input, "bd %d", &dp_table))
14548 else if (unformat (input, "vni %d", &vni))
14550 else if (unformat (input, "w %d", &w))
14554 errmsg ("No RLOC configured for setting priority/weight!");
14557 curr_rloc->weight = w;
14559 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
14560 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
14564 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
14566 vec_add1 (lcl_locs, rloc);
14568 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
14569 vec_add1 (rmt_locs, rloc);
14570 /* weight saved in rmt loc */
14571 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14573 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
14574 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
14577 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
14579 vec_add1 (lcl_locs, rloc);
14581 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
14582 vec_add1 (rmt_locs, rloc);
14583 /* weight saved in rmt loc */
14584 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14586 else if (unformat (input, "action %d", &action))
14592 clib_warning ("parse error '%U'", format_unformat_error, input);
14599 errmsg ("remote eid addresses not set");
14603 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
14605 errmsg ("eid types don't match");
14609 if (0 == rmt_locs && (u32) ~ 0 == action)
14611 errmsg ("action not set for negative mapping");
14615 /* Construct the API message */
14616 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
14617 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
14619 mp->is_add = is_add;
14620 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
14621 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
14622 mp->eid_type = rmt_eid->type;
14623 mp->dp_table = clib_host_to_net_u32 (dp_table);
14624 mp->vni = clib_host_to_net_u32 (vni);
14625 mp->rmt_len = rmt_eid->len;
14626 mp->lcl_len = lcl_eid->len;
14627 mp->action = action;
14629 if (0 != rmt_locs && 0 != lcl_locs)
14631 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
14632 clib_memcpy (mp->locs, lcl_locs,
14633 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
14635 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
14636 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
14637 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
14639 vec_free (lcl_locs);
14640 vec_free (rmt_locs);
14645 /* Wait for a reply... */
14651 api_one_add_del_map_server (vat_main_t * vam)
14653 unformat_input_t *input = vam->input;
14654 vl_api_one_add_del_map_server_t *mp;
14658 ip4_address_t ipv4;
14659 ip6_address_t ipv6;
14662 /* Parse args required to build the message */
14663 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14665 if (unformat (input, "del"))
14669 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14673 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14681 if (ipv4_set && ipv6_set)
14683 errmsg ("both eid v4 and v6 addresses set");
14687 if (!ipv4_set && !ipv6_set)
14689 errmsg ("eid addresses not set");
14693 /* Construct the API message */
14694 M (ONE_ADD_DEL_MAP_SERVER, mp);
14696 mp->is_add = is_add;
14700 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14705 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14711 /* Wait for a reply... */
14716 #define api_lisp_add_del_map_server api_one_add_del_map_server
14719 api_one_add_del_map_resolver (vat_main_t * vam)
14721 unformat_input_t *input = vam->input;
14722 vl_api_one_add_del_map_resolver_t *mp;
14726 ip4_address_t ipv4;
14727 ip6_address_t ipv6;
14730 /* Parse args required to build the message */
14731 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14733 if (unformat (input, "del"))
14737 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14741 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14749 if (ipv4_set && ipv6_set)
14751 errmsg ("both eid v4 and v6 addresses set");
14755 if (!ipv4_set && !ipv6_set)
14757 errmsg ("eid addresses not set");
14761 /* Construct the API message */
14762 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
14764 mp->is_add = is_add;
14768 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14773 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14779 /* Wait for a reply... */
14784 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
14787 api_lisp_gpe_enable_disable (vat_main_t * vam)
14789 unformat_input_t *input = vam->input;
14790 vl_api_gpe_enable_disable_t *mp;
14795 /* Parse args required to build the message */
14796 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14798 if (unformat (input, "enable"))
14803 else if (unformat (input, "disable"))
14814 errmsg ("Value not set");
14818 /* Construct the API message */
14819 M (GPE_ENABLE_DISABLE, mp);
14826 /* Wait for a reply... */
14832 api_one_rloc_probe_enable_disable (vat_main_t * vam)
14834 unformat_input_t *input = vam->input;
14835 vl_api_one_rloc_probe_enable_disable_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"))
14856 errmsg ("Value not set");
14860 /* Construct the API message */
14861 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
14863 mp->is_enabled = is_en;
14868 /* Wait for a reply... */
14873 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
14876 api_one_map_register_enable_disable (vat_main_t * vam)
14878 unformat_input_t *input = vam->input;
14879 vl_api_one_map_register_enable_disable_t *mp;
14884 /* Parse args required to build the message */
14885 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14887 if (unformat (input, "enable"))
14892 else if (unformat (input, "disable"))
14900 errmsg ("Value not set");
14904 /* Construct the API message */
14905 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
14907 mp->is_enabled = is_en;
14912 /* Wait for a reply... */
14917 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
14920 api_one_enable_disable (vat_main_t * vam)
14922 unformat_input_t *input = vam->input;
14923 vl_api_one_enable_disable_t *mp;
14928 /* Parse args required to build the message */
14929 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14931 if (unformat (input, "enable"))
14936 else if (unformat (input, "disable"))
14946 errmsg ("Value not set");
14950 /* Construct the API message */
14951 M (ONE_ENABLE_DISABLE, mp);
14958 /* Wait for a reply... */
14963 #define api_lisp_enable_disable api_one_enable_disable
14966 api_one_enable_disable_xtr_mode (vat_main_t * vam)
14968 unformat_input_t *input = vam->input;
14969 vl_api_one_enable_disable_xtr_mode_t *mp;
14974 /* Parse args required to build the message */
14975 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14977 if (unformat (input, "enable"))
14982 else if (unformat (input, "disable"))
14992 errmsg ("Value not set");
14996 /* Construct the API message */
14997 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
15004 /* Wait for a reply... */
15010 api_one_show_xtr_mode (vat_main_t * vam)
15012 vl_api_one_show_xtr_mode_t *mp;
15015 /* Construct the API message */
15016 M (ONE_SHOW_XTR_MODE, mp);
15021 /* Wait for a reply... */
15027 api_one_enable_disable_pitr_mode (vat_main_t * vam)
15029 unformat_input_t *input = vam->input;
15030 vl_api_one_enable_disable_pitr_mode_t *mp;
15035 /* Parse args required to build the message */
15036 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15038 if (unformat (input, "enable"))
15043 else if (unformat (input, "disable"))
15053 errmsg ("Value not set");
15057 /* Construct the API message */
15058 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
15065 /* Wait for a reply... */
15071 api_one_show_pitr_mode (vat_main_t * vam)
15073 vl_api_one_show_pitr_mode_t *mp;
15076 /* Construct the API message */
15077 M (ONE_SHOW_PITR_MODE, mp);
15082 /* Wait for a reply... */
15088 api_one_enable_disable_petr_mode (vat_main_t * vam)
15090 unformat_input_t *input = vam->input;
15091 vl_api_one_enable_disable_petr_mode_t *mp;
15096 /* Parse args required to build the message */
15097 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15099 if (unformat (input, "enable"))
15104 else if (unformat (input, "disable"))
15114 errmsg ("Value not set");
15118 /* Construct the API message */
15119 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
15126 /* Wait for a reply... */
15132 api_one_show_petr_mode (vat_main_t * vam)
15134 vl_api_one_show_petr_mode_t *mp;
15137 /* Construct the API message */
15138 M (ONE_SHOW_PETR_MODE, mp);
15143 /* Wait for a reply... */
15149 api_show_one_map_register_state (vat_main_t * vam)
15151 vl_api_show_one_map_register_state_t *mp;
15154 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
15159 /* wait for reply */
15164 #define api_show_lisp_map_register_state api_show_one_map_register_state
15167 api_show_one_rloc_probe_state (vat_main_t * vam)
15169 vl_api_show_one_rloc_probe_state_t *mp;
15172 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
15177 /* wait for reply */
15182 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
15185 api_one_add_del_ndp_entry (vat_main_t * vam)
15187 vl_api_one_add_del_ndp_entry_t *mp;
15188 unformat_input_t *input = vam->input;
15193 u8 mac[6] = { 0, };
15194 u8 ip6[16] = { 0, };
15198 /* Parse args required to build the message */
15199 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15201 if (unformat (input, "del"))
15203 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
15205 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
15207 else if (unformat (input, "bd %d", &bd))
15211 errmsg ("parse error '%U'", format_unformat_error, input);
15216 if (!bd_set || !ip_set || (!mac_set && is_add))
15218 errmsg ("Missing BD, IP or MAC!");
15222 M (ONE_ADD_DEL_NDP_ENTRY, mp);
15223 mp->is_add = is_add;
15224 clib_memcpy (mp->mac, mac, 6);
15225 mp->bd = clib_host_to_net_u32 (bd);
15226 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
15231 /* wait for reply */
15237 api_one_add_del_l2_arp_entry (vat_main_t * vam)
15239 vl_api_one_add_del_l2_arp_entry_t *mp;
15240 unformat_input_t *input = vam->input;
15245 u8 mac[6] = { 0, };
15246 u32 ip4 = 0, bd = ~0;
15249 /* Parse args required to build the message */
15250 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15252 if (unformat (input, "del"))
15254 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
15256 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
15258 else if (unformat (input, "bd %d", &bd))
15262 errmsg ("parse error '%U'", format_unformat_error, input);
15267 if (!bd_set || !ip_set || (!mac_set && is_add))
15269 errmsg ("Missing BD, IP or MAC!");
15273 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
15274 mp->is_add = is_add;
15275 clib_memcpy (mp->mac, mac, 6);
15276 mp->bd = clib_host_to_net_u32 (bd);
15282 /* wait for reply */
15288 api_one_ndp_bd_get (vat_main_t * vam)
15290 vl_api_one_ndp_bd_get_t *mp;
15293 M (ONE_NDP_BD_GET, mp);
15298 /* wait for reply */
15304 api_one_ndp_entries_get (vat_main_t * vam)
15306 vl_api_one_ndp_entries_get_t *mp;
15307 unformat_input_t *input = vam->input;
15312 /* Parse args required to build the message */
15313 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15315 if (unformat (input, "bd %d", &bd))
15319 errmsg ("parse error '%U'", format_unformat_error, input);
15326 errmsg ("Expected bridge domain!");
15330 M (ONE_NDP_ENTRIES_GET, mp);
15331 mp->bd = clib_host_to_net_u32 (bd);
15336 /* wait for reply */
15342 api_one_l2_arp_bd_get (vat_main_t * vam)
15344 vl_api_one_l2_arp_bd_get_t *mp;
15347 M (ONE_L2_ARP_BD_GET, mp);
15352 /* wait for reply */
15358 api_one_l2_arp_entries_get (vat_main_t * vam)
15360 vl_api_one_l2_arp_entries_get_t *mp;
15361 unformat_input_t *input = vam->input;
15366 /* Parse args required to build the message */
15367 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15369 if (unformat (input, "bd %d", &bd))
15373 errmsg ("parse error '%U'", format_unformat_error, input);
15380 errmsg ("Expected bridge domain!");
15384 M (ONE_L2_ARP_ENTRIES_GET, mp);
15385 mp->bd = clib_host_to_net_u32 (bd);
15390 /* wait for reply */
15396 api_one_stats_enable_disable (vat_main_t * vam)
15398 vl_api_one_stats_enable_disable_t *mp;
15399 unformat_input_t *input = vam->input;
15404 /* Parse args required to build the message */
15405 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15407 if (unformat (input, "enable"))
15412 else if (unformat (input, "disable"))
15422 errmsg ("Value not set");
15426 M (ONE_STATS_ENABLE_DISABLE, mp);
15432 /* wait for reply */
15438 api_show_one_stats_enable_disable (vat_main_t * vam)
15440 vl_api_show_one_stats_enable_disable_t *mp;
15443 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
15448 /* wait for reply */
15454 api_show_one_map_request_mode (vat_main_t * vam)
15456 vl_api_show_one_map_request_mode_t *mp;
15459 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
15464 /* wait for reply */
15469 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
15472 api_one_map_request_mode (vat_main_t * vam)
15474 unformat_input_t *input = vam->input;
15475 vl_api_one_map_request_mode_t *mp;
15479 /* Parse args required to build the message */
15480 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15482 if (unformat (input, "dst-only"))
15484 else if (unformat (input, "src-dst"))
15488 errmsg ("parse error '%U'", format_unformat_error, input);
15493 M (ONE_MAP_REQUEST_MODE, mp);
15500 /* wait for reply */
15505 #define api_lisp_map_request_mode api_one_map_request_mode
15508 * Enable/disable ONE proxy ITR.
15510 * @param vam vpp API test context
15511 * @return return code
15514 api_one_pitr_set_locator_set (vat_main_t * vam)
15516 u8 ls_name_set = 0;
15517 unformat_input_t *input = vam->input;
15518 vl_api_one_pitr_set_locator_set_t *mp;
15523 /* Parse args required to build the message */
15524 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15526 if (unformat (input, "del"))
15528 else if (unformat (input, "locator-set %s", &ls_name))
15532 errmsg ("parse error '%U'", format_unformat_error, input);
15539 errmsg ("locator-set name not set!");
15543 M (ONE_PITR_SET_LOCATOR_SET, mp);
15545 mp->is_add = is_add;
15546 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
15547 vec_free (ls_name);
15552 /* wait for reply */
15557 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
15560 api_one_nsh_set_locator_set (vat_main_t * vam)
15562 u8 ls_name_set = 0;
15563 unformat_input_t *input = vam->input;
15564 vl_api_one_nsh_set_locator_set_t *mp;
15569 /* Parse args required to build the message */
15570 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15572 if (unformat (input, "del"))
15574 else if (unformat (input, "ls %s", &ls_name))
15578 errmsg ("parse error '%U'", format_unformat_error, input);
15583 if (!ls_name_set && is_add)
15585 errmsg ("locator-set name not set!");
15589 M (ONE_NSH_SET_LOCATOR_SET, mp);
15591 mp->is_add = is_add;
15592 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
15593 vec_free (ls_name);
15598 /* wait for reply */
15604 api_show_one_pitr (vat_main_t * vam)
15606 vl_api_show_one_pitr_t *mp;
15609 if (!vam->json_output)
15611 print (vam->ofp, "%=20s", "lisp status:");
15614 M (SHOW_ONE_PITR, mp);
15618 /* Wait for a reply... */
15623 #define api_show_lisp_pitr api_show_one_pitr
15626 api_one_use_petr (vat_main_t * vam)
15628 unformat_input_t *input = vam->input;
15629 vl_api_one_use_petr_t *mp;
15634 clib_memset (&ip, 0, sizeof (ip));
15636 /* Parse args required to build the message */
15637 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15639 if (unformat (input, "disable"))
15642 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
15645 ip_addr_version (&ip) = AF_IP4;
15648 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
15651 ip_addr_version (&ip) = AF_IP6;
15655 errmsg ("parse error '%U'", format_unformat_error, input);
15660 M (ONE_USE_PETR, mp);
15662 mp->is_add = is_add;
15665 mp->is_ip4 = ip_addr_version (&ip) == AF_IP4 ? 1 : 0;
15667 clib_memcpy (mp->address, &ip, 4);
15669 clib_memcpy (mp->address, &ip, 16);
15675 /* wait for reply */
15680 #define api_lisp_use_petr api_one_use_petr
15683 api_show_one_nsh_mapping (vat_main_t * vam)
15685 vl_api_show_one_use_petr_t *mp;
15688 if (!vam->json_output)
15690 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
15693 M (SHOW_ONE_NSH_MAPPING, mp);
15697 /* Wait for a reply... */
15703 api_show_one_use_petr (vat_main_t * vam)
15705 vl_api_show_one_use_petr_t *mp;
15708 if (!vam->json_output)
15710 print (vam->ofp, "%=20s", "Proxy-ETR status:");
15713 M (SHOW_ONE_USE_PETR, mp);
15717 /* Wait for a reply... */
15722 #define api_show_lisp_use_petr api_show_one_use_petr
15725 * Add/delete mapping between vni and vrf
15728 api_one_eid_table_add_del_map (vat_main_t * vam)
15730 unformat_input_t *input = vam->input;
15731 vl_api_one_eid_table_add_del_map_t *mp;
15732 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
15733 u32 vni, vrf, bd_index;
15736 /* Parse args required to build the message */
15737 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15739 if (unformat (input, "del"))
15741 else if (unformat (input, "vrf %d", &vrf))
15743 else if (unformat (input, "bd_index %d", &bd_index))
15745 else if (unformat (input, "vni %d", &vni))
15751 if (!vni_set || (!vrf_set && !bd_index_set))
15753 errmsg ("missing arguments!");
15757 if (vrf_set && bd_index_set)
15759 errmsg ("error: both vrf and bd entered!");
15763 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
15765 mp->is_add = is_add;
15766 mp->vni = htonl (vni);
15767 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
15768 mp->is_l2 = bd_index_set;
15773 /* wait for reply */
15778 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
15781 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
15783 u32 *action = va_arg (*args, u32 *);
15786 if (unformat (input, "%s", &s))
15788 if (!strcmp ((char *) s, "no-action"))
15790 else if (!strcmp ((char *) s, "natively-forward"))
15792 else if (!strcmp ((char *) s, "send-map-request"))
15794 else if (!strcmp ((char *) s, "drop"))
15798 clib_warning ("invalid action: '%s'", s);
15810 * Add/del remote mapping to/from ONE control plane
15812 * @param vam vpp API test context
15813 * @return return code
15816 api_one_add_del_remote_mapping (vat_main_t * vam)
15818 unformat_input_t *input = vam->input;
15819 vl_api_one_add_del_remote_mapping_t *mp;
15821 lisp_eid_vat_t _eid, *eid = &_eid;
15822 lisp_eid_vat_t _seid, *seid = &_seid;
15823 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
15824 u32 action = ~0, p, w, data_len;
15825 ip4_address_t rloc4;
15826 ip6_address_t rloc6;
15827 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
15830 clib_memset (&rloc, 0, sizeof (rloc));
15832 /* Parse args required to build the message */
15833 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15835 if (unformat (input, "del-all"))
15839 else if (unformat (input, "del"))
15843 else if (unformat (input, "add"))
15847 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15851 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
15855 else if (unformat (input, "vni %d", &vni))
15859 else if (unformat (input, "p %d w %d", &p, &w))
15863 errmsg ("No RLOC configured for setting priority/weight!");
15866 curr_rloc->priority = p;
15867 curr_rloc->weight = w;
15869 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
15872 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
15873 vec_add1 (rlocs, rloc);
15874 curr_rloc = &rlocs[vec_len (rlocs) - 1];
15876 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
15879 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
15880 vec_add1 (rlocs, rloc);
15881 curr_rloc = &rlocs[vec_len (rlocs) - 1];
15883 else if (unformat (input, "action %U",
15884 unformat_negative_mapping_action, &action))
15890 clib_warning ("parse error '%U'", format_unformat_error, input);
15897 errmsg ("missing params!");
15901 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
15903 errmsg ("no action set for negative map-reply!");
15907 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
15909 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
15910 mp->is_add = is_add;
15911 mp->vni = htonl (vni);
15912 mp->action = (u8) action;
15913 mp->is_src_dst = seid_set;
15914 mp->eid_len = eid->len;
15915 mp->seid_len = seid->len;
15916 mp->del_all = del_all;
15917 mp->eid_type = eid->type;
15918 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15919 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
15921 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
15922 clib_memcpy (mp->rlocs, rlocs, data_len);
15928 /* Wait for a reply... */
15933 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
15936 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
15937 * forwarding entries in data-plane accordingly.
15939 * @param vam vpp API test context
15940 * @return return code
15943 api_one_add_del_adjacency (vat_main_t * vam)
15945 unformat_input_t *input = vam->input;
15946 vl_api_one_add_del_adjacency_t *mp;
15948 ip4_address_t leid4, reid4;
15949 ip6_address_t leid6, reid6;
15950 u8 reid_mac[6] = { 0 };
15951 u8 leid_mac[6] = { 0 };
15952 u8 reid_type, leid_type;
15953 u32 leid_len = 0, reid_len = 0, len;
15957 leid_type = reid_type = (u8) ~ 0;
15959 /* Parse args required to build the message */
15960 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15962 if (unformat (input, "del"))
15966 else if (unformat (input, "add"))
15970 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
15973 reid_type = 0; /* ipv4 */
15976 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
15979 reid_type = 1; /* ipv6 */
15982 else if (unformat (input, "reid %U", unformat_ethernet_address,
15985 reid_type = 2; /* mac */
15987 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
15990 leid_type = 0; /* ipv4 */
15993 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
15996 leid_type = 1; /* ipv6 */
15999 else if (unformat (input, "leid %U", unformat_ethernet_address,
16002 leid_type = 2; /* mac */
16004 else if (unformat (input, "vni %d", &vni))
16010 errmsg ("parse error '%U'", format_unformat_error, input);
16015 if ((u8) ~ 0 == reid_type)
16017 errmsg ("missing params!");
16021 if (leid_type != reid_type)
16023 errmsg ("remote and local EIDs are of different types!");
16027 M (ONE_ADD_DEL_ADJACENCY, mp);
16028 mp->is_add = is_add;
16029 mp->vni = htonl (vni);
16030 mp->leid_len = leid_len;
16031 mp->reid_len = reid_len;
16032 mp->eid_type = reid_type;
16034 switch (mp->eid_type)
16037 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
16038 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
16041 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
16042 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
16045 clib_memcpy (mp->leid, leid_mac, 6);
16046 clib_memcpy (mp->reid, reid_mac, 6);
16049 errmsg ("unknown EID type %d!", mp->eid_type);
16056 /* Wait for a reply... */
16061 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
16064 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
16066 u32 *mode = va_arg (*args, u32 *);
16068 if (unformat (input, "lisp"))
16070 else if (unformat (input, "vxlan"))
16079 api_gpe_get_encap_mode (vat_main_t * vam)
16081 vl_api_gpe_get_encap_mode_t *mp;
16084 /* Construct the API message */
16085 M (GPE_GET_ENCAP_MODE, mp);
16090 /* Wait for a reply... */
16096 api_gpe_set_encap_mode (vat_main_t * vam)
16098 unformat_input_t *input = vam->input;
16099 vl_api_gpe_set_encap_mode_t *mp;
16103 /* Parse args required to build the message */
16104 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16106 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
16112 /* Construct the API message */
16113 M (GPE_SET_ENCAP_MODE, mp);
16120 /* Wait for a reply... */
16126 api_lisp_gpe_add_del_iface (vat_main_t * vam)
16128 unformat_input_t *input = vam->input;
16129 vl_api_gpe_add_del_iface_t *mp;
16130 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
16131 u32 dp_table = 0, vni = 0;
16134 /* Parse args required to build the message */
16135 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16137 if (unformat (input, "up"))
16142 else if (unformat (input, "down"))
16147 else if (unformat (input, "table_id %d", &dp_table))
16151 else if (unformat (input, "bd_id %d", &dp_table))
16156 else if (unformat (input, "vni %d", &vni))
16164 if (action_set == 0)
16166 errmsg ("Action not set");
16169 if (dp_table_set == 0 || vni_set == 0)
16171 errmsg ("vni and dp_table must be set");
16175 /* Construct the API message */
16176 M (GPE_ADD_DEL_IFACE, mp);
16178 mp->is_add = is_add;
16179 mp->dp_table = clib_host_to_net_u32 (dp_table);
16181 mp->vni = clib_host_to_net_u32 (vni);
16186 /* Wait for a reply... */
16192 api_one_map_register_fallback_threshold (vat_main_t * vam)
16194 unformat_input_t *input = vam->input;
16195 vl_api_one_map_register_fallback_threshold_t *mp;
16200 /* Parse args required to build the message */
16201 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16203 if (unformat (input, "%u", &value))
16207 clib_warning ("parse error '%U'", format_unformat_error, input);
16214 errmsg ("fallback threshold value is missing!");
16218 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
16219 mp->value = clib_host_to_net_u32 (value);
16224 /* Wait for a reply... */
16230 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
16232 vl_api_show_one_map_register_fallback_threshold_t *mp;
16235 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
16240 /* Wait for a reply... */
16246 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
16248 u32 *proto = va_arg (*args, u32 *);
16250 if (unformat (input, "udp"))
16252 else if (unformat (input, "api"))
16261 api_one_set_transport_protocol (vat_main_t * vam)
16263 unformat_input_t *input = vam->input;
16264 vl_api_one_set_transport_protocol_t *mp;
16269 /* Parse args required to build the message */
16270 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16272 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
16276 clib_warning ("parse error '%U'", format_unformat_error, input);
16283 errmsg ("Transport protocol missing!");
16287 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
16288 mp->protocol = (u8) protocol;
16293 /* Wait for a reply... */
16299 api_one_get_transport_protocol (vat_main_t * vam)
16301 vl_api_one_get_transport_protocol_t *mp;
16304 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
16309 /* Wait for a reply... */
16315 api_one_map_register_set_ttl (vat_main_t * vam)
16317 unformat_input_t *input = vam->input;
16318 vl_api_one_map_register_set_ttl_t *mp;
16323 /* Parse args required to build the message */
16324 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16326 if (unformat (input, "%u", &ttl))
16330 clib_warning ("parse error '%U'", format_unformat_error, input);
16337 errmsg ("TTL value missing!");
16341 M (ONE_MAP_REGISTER_SET_TTL, mp);
16342 mp->ttl = clib_host_to_net_u32 (ttl);
16347 /* Wait for a reply... */
16353 api_show_one_map_register_ttl (vat_main_t * vam)
16355 vl_api_show_one_map_register_ttl_t *mp;
16358 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
16363 /* Wait for a reply... */
16369 * Add/del map request itr rlocs from ONE control plane and updates
16371 * @param vam vpp API test context
16372 * @return return code
16375 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
16377 unformat_input_t *input = vam->input;
16378 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
16379 u8 *locator_set_name = 0;
16380 u8 locator_set_name_set = 0;
16384 /* Parse args required to build the message */
16385 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16387 if (unformat (input, "del"))
16391 else if (unformat (input, "%_%v%_", &locator_set_name))
16393 locator_set_name_set = 1;
16397 clib_warning ("parse error '%U'", format_unformat_error, input);
16402 if (is_add && !locator_set_name_set)
16404 errmsg ("itr-rloc is not set!");
16408 if (is_add && vec_len (locator_set_name) > 64)
16410 errmsg ("itr-rloc locator-set name too long");
16411 vec_free (locator_set_name);
16415 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
16416 mp->is_add = is_add;
16419 clib_memcpy (mp->locator_set_name, locator_set_name,
16420 vec_len (locator_set_name));
16424 clib_memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
16426 vec_free (locator_set_name);
16431 /* Wait for a reply... */
16436 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
16439 api_one_locator_dump (vat_main_t * vam)
16441 unformat_input_t *input = vam->input;
16442 vl_api_one_locator_dump_t *mp;
16443 vl_api_control_ping_t *mp_ping;
16444 u8 is_index_set = 0, is_name_set = 0;
16449 /* Parse args required to build the message */
16450 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16452 if (unformat (input, "ls_name %_%v%_", &ls_name))
16456 else if (unformat (input, "ls_index %d", &ls_index))
16462 errmsg ("parse error '%U'", format_unformat_error, input);
16467 if (!is_index_set && !is_name_set)
16469 errmsg ("error: expected one of index or name!");
16473 if (is_index_set && is_name_set)
16475 errmsg ("error: only one param expected!");
16479 if (vec_len (ls_name) > 62)
16481 errmsg ("error: locator set name too long!");
16485 if (!vam->json_output)
16487 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
16490 M (ONE_LOCATOR_DUMP, mp);
16491 mp->is_index_set = is_index_set;
16494 mp->ls_index = clib_host_to_net_u32 (ls_index);
16497 vec_add1 (ls_name, 0);
16498 strncpy ((char *) mp->ls_name, (char *) ls_name,
16499 sizeof (mp->ls_name) - 1);
16505 /* Use a control ping for synchronization */
16506 MPING (CONTROL_PING, mp_ping);
16509 /* Wait for a reply... */
16514 #define api_lisp_locator_dump api_one_locator_dump
16517 api_one_locator_set_dump (vat_main_t * vam)
16519 vl_api_one_locator_set_dump_t *mp;
16520 vl_api_control_ping_t *mp_ping;
16521 unformat_input_t *input = vam->input;
16525 /* Parse args required to build the message */
16526 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16528 if (unformat (input, "local"))
16532 else if (unformat (input, "remote"))
16538 errmsg ("parse error '%U'", format_unformat_error, input);
16543 if (!vam->json_output)
16545 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
16548 M (ONE_LOCATOR_SET_DUMP, mp);
16550 mp->filter = filter;
16555 /* Use a control ping for synchronization */
16556 MPING (CONTROL_PING, mp_ping);
16559 /* Wait for a reply... */
16564 #define api_lisp_locator_set_dump api_one_locator_set_dump
16567 api_one_eid_table_map_dump (vat_main_t * vam)
16571 unformat_input_t *input = vam->input;
16572 vl_api_one_eid_table_map_dump_t *mp;
16573 vl_api_control_ping_t *mp_ping;
16576 /* Parse args required to build the message */
16577 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16579 if (unformat (input, "l2"))
16584 else if (unformat (input, "l3"))
16591 errmsg ("parse error '%U'", format_unformat_error, input);
16598 errmsg ("expected one of 'l2' or 'l3' parameter!");
16602 if (!vam->json_output)
16604 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
16607 M (ONE_EID_TABLE_MAP_DUMP, mp);
16613 /* Use a control ping for synchronization */
16614 MPING (CONTROL_PING, mp_ping);
16617 /* Wait for a reply... */
16622 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
16625 api_one_eid_table_vni_dump (vat_main_t * vam)
16627 vl_api_one_eid_table_vni_dump_t *mp;
16628 vl_api_control_ping_t *mp_ping;
16631 if (!vam->json_output)
16633 print (vam->ofp, "VNI");
16636 M (ONE_EID_TABLE_VNI_DUMP, mp);
16641 /* Use a control ping for synchronization */
16642 MPING (CONTROL_PING, mp_ping);
16645 /* Wait for a reply... */
16650 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
16653 api_one_eid_table_dump (vat_main_t * vam)
16655 unformat_input_t *i = vam->input;
16656 vl_api_one_eid_table_dump_t *mp;
16657 vl_api_control_ping_t *mp_ping;
16658 struct in_addr ip4;
16659 struct in6_addr ip6;
16661 u8 eid_type = ~0, eid_set = 0;
16662 u32 prefix_length = ~0, t, vni = 0;
16665 lisp_nsh_api_t nsh;
16667 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16669 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
16675 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
16681 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
16686 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
16691 else if (unformat (i, "vni %d", &t))
16695 else if (unformat (i, "local"))
16699 else if (unformat (i, "remote"))
16705 errmsg ("parse error '%U'", format_unformat_error, i);
16710 if (!vam->json_output)
16712 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
16713 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
16716 M (ONE_EID_TABLE_DUMP, mp);
16718 mp->filter = filter;
16722 mp->vni = htonl (vni);
16723 mp->eid_type = eid_type;
16727 mp->prefix_length = prefix_length;
16728 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
16731 mp->prefix_length = prefix_length;
16732 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
16735 clib_memcpy (mp->eid, mac, sizeof (mac));
16738 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
16741 errmsg ("unknown EID type %d!", eid_type);
16749 /* Use a control ping for synchronization */
16750 MPING (CONTROL_PING, mp_ping);
16753 /* Wait for a reply... */
16758 #define api_lisp_eid_table_dump api_one_eid_table_dump
16761 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
16763 unformat_input_t *i = vam->input;
16764 vl_api_gpe_fwd_entries_get_t *mp;
16769 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16771 if (unformat (i, "vni %d", &vni))
16777 errmsg ("parse error '%U'", format_unformat_error, i);
16784 errmsg ("vni not set!");
16788 if (!vam->json_output)
16790 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
16794 M (GPE_FWD_ENTRIES_GET, mp);
16795 mp->vni = clib_host_to_net_u32 (vni);
16800 /* Wait for a reply... */
16805 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
16806 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
16807 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
16808 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
16809 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
16810 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
16811 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
16812 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
16815 api_one_adjacencies_get (vat_main_t * vam)
16817 unformat_input_t *i = vam->input;
16818 vl_api_one_adjacencies_get_t *mp;
16823 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16825 if (unformat (i, "vni %d", &vni))
16831 errmsg ("parse error '%U'", format_unformat_error, i);
16838 errmsg ("vni not set!");
16842 if (!vam->json_output)
16844 print (vam->ofp, "%s %40s", "leid", "reid");
16847 M (ONE_ADJACENCIES_GET, mp);
16848 mp->vni = clib_host_to_net_u32 (vni);
16853 /* Wait for a reply... */
16858 #define api_lisp_adjacencies_get api_one_adjacencies_get
16861 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
16863 unformat_input_t *i = vam->input;
16864 vl_api_gpe_native_fwd_rpaths_get_t *mp;
16866 u8 ip_family_set = 0, is_ip4 = 1;
16868 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16870 if (unformat (i, "ip4"))
16875 else if (unformat (i, "ip6"))
16882 errmsg ("parse error '%U'", format_unformat_error, i);
16887 if (!ip_family_set)
16889 errmsg ("ip family not set!");
16893 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
16894 mp->is_ip4 = is_ip4;
16899 /* Wait for a reply... */
16905 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
16907 vl_api_gpe_fwd_entry_vnis_get_t *mp;
16910 if (!vam->json_output)
16912 print (vam->ofp, "VNIs");
16915 M (GPE_FWD_ENTRY_VNIS_GET, mp);
16920 /* Wait for a reply... */
16926 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
16928 unformat_input_t *i = vam->input;
16929 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
16931 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
16932 struct in_addr ip4;
16933 struct in6_addr ip6;
16934 u32 table_id = 0, nh_sw_if_index = ~0;
16936 clib_memset (&ip4, 0, sizeof (ip4));
16937 clib_memset (&ip6, 0, sizeof (ip6));
16939 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16941 if (unformat (i, "del"))
16943 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
16944 api_unformat_sw_if_index, vam, &nh_sw_if_index))
16949 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
16950 api_unformat_sw_if_index, vam, &nh_sw_if_index))
16955 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
16959 nh_sw_if_index = ~0;
16961 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
16965 nh_sw_if_index = ~0;
16967 else if (unformat (i, "table %d", &table_id))
16971 errmsg ("parse error '%U'", format_unformat_error, i);
16978 errmsg ("nh addr not set!");
16982 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
16983 mp->is_add = is_add;
16984 mp->table_id = clib_host_to_net_u32 (table_id);
16985 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
16986 mp->is_ip4 = is_ip4;
16988 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
16990 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
16995 /* Wait for a reply... */
17001 api_one_map_server_dump (vat_main_t * vam)
17003 vl_api_one_map_server_dump_t *mp;
17004 vl_api_control_ping_t *mp_ping;
17007 if (!vam->json_output)
17009 print (vam->ofp, "%=20s", "Map server");
17012 M (ONE_MAP_SERVER_DUMP, mp);
17016 /* Use a control ping for synchronization */
17017 MPING (CONTROL_PING, mp_ping);
17020 /* Wait for a reply... */
17025 #define api_lisp_map_server_dump api_one_map_server_dump
17028 api_one_map_resolver_dump (vat_main_t * vam)
17030 vl_api_one_map_resolver_dump_t *mp;
17031 vl_api_control_ping_t *mp_ping;
17034 if (!vam->json_output)
17036 print (vam->ofp, "%=20s", "Map resolver");
17039 M (ONE_MAP_RESOLVER_DUMP, mp);
17043 /* Use a control ping for synchronization */
17044 MPING (CONTROL_PING, mp_ping);
17047 /* Wait for a reply... */
17052 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
17055 api_one_stats_flush (vat_main_t * vam)
17057 vl_api_one_stats_flush_t *mp;
17060 M (ONE_STATS_FLUSH, mp);
17067 api_one_stats_dump (vat_main_t * vam)
17069 vl_api_one_stats_dump_t *mp;
17070 vl_api_control_ping_t *mp_ping;
17073 M (ONE_STATS_DUMP, mp);
17077 /* Use a control ping for synchronization */
17078 MPING (CONTROL_PING, mp_ping);
17081 /* Wait for a reply... */
17087 api_show_one_status (vat_main_t * vam)
17089 vl_api_show_one_status_t *mp;
17092 if (!vam->json_output)
17094 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
17097 M (SHOW_ONE_STATUS, mp);
17100 /* Wait for a reply... */
17105 #define api_show_lisp_status api_show_one_status
17108 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
17110 vl_api_gpe_fwd_entry_path_dump_t *mp;
17111 vl_api_control_ping_t *mp_ping;
17112 unformat_input_t *i = vam->input;
17113 u32 fwd_entry_index = ~0;
17116 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17118 if (unformat (i, "index %d", &fwd_entry_index))
17124 if (~0 == fwd_entry_index)
17126 errmsg ("no index specified!");
17130 if (!vam->json_output)
17132 print (vam->ofp, "first line");
17135 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
17139 /* Use a control ping for synchronization */
17140 MPING (CONTROL_PING, mp_ping);
17143 /* Wait for a reply... */
17149 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
17151 vl_api_one_get_map_request_itr_rlocs_t *mp;
17154 if (!vam->json_output)
17156 print (vam->ofp, "%=20s", "itr-rlocs:");
17159 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
17162 /* Wait for a reply... */
17167 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
17170 api_af_packet_create (vat_main_t * vam)
17172 unformat_input_t *i = vam->input;
17173 vl_api_af_packet_create_t *mp;
17174 u8 *host_if_name = 0;
17176 u8 random_hw_addr = 1;
17179 clib_memset (hw_addr, 0, sizeof (hw_addr));
17181 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17183 if (unformat (i, "name %s", &host_if_name))
17184 vec_add1 (host_if_name, 0);
17185 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
17186 random_hw_addr = 0;
17191 if (!vec_len (host_if_name))
17193 errmsg ("host-interface name must be specified");
17197 if (vec_len (host_if_name) > 64)
17199 errmsg ("host-interface name too long");
17203 M (AF_PACKET_CREATE, mp);
17205 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
17206 clib_memcpy (mp->hw_addr, hw_addr, 6);
17207 mp->use_random_hw_addr = random_hw_addr;
17208 vec_free (host_if_name);
17216 fprintf (vam->ofp ? vam->ofp : stderr,
17217 " new sw_if_index = %d\n", vam->sw_if_index);
17224 api_af_packet_delete (vat_main_t * vam)
17226 unformat_input_t *i = vam->input;
17227 vl_api_af_packet_delete_t *mp;
17228 u8 *host_if_name = 0;
17231 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17233 if (unformat (i, "name %s", &host_if_name))
17234 vec_add1 (host_if_name, 0);
17239 if (!vec_len (host_if_name))
17241 errmsg ("host-interface name must be specified");
17245 if (vec_len (host_if_name) > 64)
17247 errmsg ("host-interface name too long");
17251 M (AF_PACKET_DELETE, mp);
17253 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
17254 vec_free (host_if_name);
17261 static void vl_api_af_packet_details_t_handler
17262 (vl_api_af_packet_details_t * mp)
17264 vat_main_t *vam = &vat_main;
17266 print (vam->ofp, "%-16s %d",
17267 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
17270 static void vl_api_af_packet_details_t_handler_json
17271 (vl_api_af_packet_details_t * mp)
17273 vat_main_t *vam = &vat_main;
17274 vat_json_node_t *node = NULL;
17276 if (VAT_JSON_ARRAY != vam->json_tree.type)
17278 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17279 vat_json_init_array (&vam->json_tree);
17281 node = vat_json_array_add (&vam->json_tree);
17283 vat_json_init_object (node);
17284 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
17285 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
17289 api_af_packet_dump (vat_main_t * vam)
17291 vl_api_af_packet_dump_t *mp;
17292 vl_api_control_ping_t *mp_ping;
17295 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
17296 /* Get list of tap interfaces */
17297 M (AF_PACKET_DUMP, mp);
17300 /* Use a control ping for synchronization */
17301 MPING (CONTROL_PING, mp_ping);
17309 api_policer_add_del (vat_main_t * vam)
17311 unformat_input_t *i = vam->input;
17312 vl_api_policer_add_del_t *mp;
17322 u8 color_aware = 0;
17323 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
17326 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
17327 conform_action.dscp = 0;
17328 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
17329 exceed_action.dscp = 0;
17330 violate_action.action_type = SSE2_QOS_ACTION_DROP;
17331 violate_action.dscp = 0;
17333 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17335 if (unformat (i, "del"))
17337 else if (unformat (i, "name %s", &name))
17338 vec_add1 (name, 0);
17339 else if (unformat (i, "cir %u", &cir))
17341 else if (unformat (i, "eir %u", &eir))
17343 else if (unformat (i, "cb %u", &cb))
17345 else if (unformat (i, "eb %u", &eb))
17347 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
17350 else if (unformat (i, "round_type %U", unformat_policer_round_type,
17353 else if (unformat (i, "type %U", unformat_policer_type, &type))
17355 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
17358 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
17361 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
17364 else if (unformat (i, "color-aware"))
17370 if (!vec_len (name))
17372 errmsg ("policer name must be specified");
17376 if (vec_len (name) > 64)
17378 errmsg ("policer name too long");
17382 M (POLICER_ADD_DEL, mp);
17384 clib_memcpy (mp->name, name, vec_len (name));
17386 mp->is_add = is_add;
17387 mp->cir = ntohl (cir);
17388 mp->eir = ntohl (eir);
17389 mp->cb = clib_net_to_host_u64 (cb);
17390 mp->eb = clib_net_to_host_u64 (eb);
17391 mp->rate_type = rate_type;
17392 mp->round_type = round_type;
17394 mp->conform_action.type = conform_action.action_type;
17395 mp->conform_action.dscp = conform_action.dscp;
17396 mp->exceed_action.type = exceed_action.action_type;
17397 mp->exceed_action.dscp = exceed_action.dscp;
17398 mp->violate_action.type = violate_action.action_type;
17399 mp->violate_action.dscp = violate_action.dscp;
17400 mp->color_aware = color_aware;
17408 api_policer_dump (vat_main_t * vam)
17410 unformat_input_t *i = vam->input;
17411 vl_api_policer_dump_t *mp;
17412 vl_api_control_ping_t *mp_ping;
17413 u8 *match_name = 0;
17414 u8 match_name_valid = 0;
17417 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17419 if (unformat (i, "name %s", &match_name))
17421 vec_add1 (match_name, 0);
17422 match_name_valid = 1;
17428 M (POLICER_DUMP, mp);
17429 mp->match_name_valid = match_name_valid;
17430 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
17431 vec_free (match_name);
17435 /* Use a control ping for synchronization */
17436 MPING (CONTROL_PING, mp_ping);
17439 /* Wait for a reply... */
17445 api_policer_classify_set_interface (vat_main_t * vam)
17447 unformat_input_t *i = vam->input;
17448 vl_api_policer_classify_set_interface_t *mp;
17450 int sw_if_index_set;
17451 u32 ip4_table_index = ~0;
17452 u32 ip6_table_index = ~0;
17453 u32 l2_table_index = ~0;
17457 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17459 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17460 sw_if_index_set = 1;
17461 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17462 sw_if_index_set = 1;
17463 else if (unformat (i, "del"))
17465 else if (unformat (i, "ip4-table %d", &ip4_table_index))
17467 else if (unformat (i, "ip6-table %d", &ip6_table_index))
17469 else if (unformat (i, "l2-table %d", &l2_table_index))
17473 clib_warning ("parse error '%U'", format_unformat_error, i);
17478 if (sw_if_index_set == 0)
17480 errmsg ("missing interface name or sw_if_index");
17484 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
17486 mp->sw_if_index = ntohl (sw_if_index);
17487 mp->ip4_table_index = ntohl (ip4_table_index);
17488 mp->ip6_table_index = ntohl (ip6_table_index);
17489 mp->l2_table_index = ntohl (l2_table_index);
17490 mp->is_add = is_add;
17498 api_policer_classify_dump (vat_main_t * vam)
17500 unformat_input_t *i = vam->input;
17501 vl_api_policer_classify_dump_t *mp;
17502 vl_api_control_ping_t *mp_ping;
17503 u8 type = POLICER_CLASSIFY_N_TABLES;
17506 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
17510 errmsg ("classify table type must be specified");
17514 if (!vam->json_output)
17516 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
17519 M (POLICER_CLASSIFY_DUMP, mp);
17524 /* Use a control ping for synchronization */
17525 MPING (CONTROL_PING, mp_ping);
17528 /* Wait for a reply... */
17534 format_fib_api_path_nh_proto (u8 * s, va_list * args)
17536 vl_api_fib_path_nh_proto_t proto =
17537 va_arg (*args, vl_api_fib_path_nh_proto_t);
17541 case FIB_API_PATH_NH_PROTO_IP4:
17542 s = format (s, "ip4");
17544 case FIB_API_PATH_NH_PROTO_IP6:
17545 s = format (s, "ip6");
17547 case FIB_API_PATH_NH_PROTO_MPLS:
17548 s = format (s, "mpls");
17550 case FIB_API_PATH_NH_PROTO_BIER:
17551 s = format (s, "bier");
17553 case FIB_API_PATH_NH_PROTO_ETHERNET:
17554 s = format (s, "ethernet");
17562 format_vl_api_ip_address_union (u8 * s, va_list * args)
17564 vl_api_address_family_t af = va_arg (*args, int);
17565 const vl_api_address_union_t *u = va_arg (*args, vl_api_address_union_t *);
17570 s = format (s, "%U", format_ip4_address, u->ip4);
17573 s = format (s, "%U", format_ip6_address, u->ip6);
17580 format_vl_api_fib_path_type (u8 * s, va_list * args)
17582 vl_api_fib_path_type_t t = va_arg (*args, vl_api_fib_path_type_t);
17586 case FIB_API_PATH_TYPE_NORMAL:
17587 s = format (s, "normal");
17589 case FIB_API_PATH_TYPE_LOCAL:
17590 s = format (s, "local");
17592 case FIB_API_PATH_TYPE_DROP:
17593 s = format (s, "drop");
17595 case FIB_API_PATH_TYPE_UDP_ENCAP:
17596 s = format (s, "udp-encap");
17598 case FIB_API_PATH_TYPE_BIER_IMP:
17599 s = format (s, "bier-imp");
17601 case FIB_API_PATH_TYPE_ICMP_UNREACH:
17602 s = format (s, "unreach");
17604 case FIB_API_PATH_TYPE_ICMP_PROHIBIT:
17605 s = format (s, "prohibit");
17607 case FIB_API_PATH_TYPE_SOURCE_LOOKUP:
17608 s = format (s, "src-lookup");
17610 case FIB_API_PATH_TYPE_DVR:
17611 s = format (s, "dvr");
17613 case FIB_API_PATH_TYPE_INTERFACE_RX:
17614 s = format (s, "interface-rx");
17616 case FIB_API_PATH_TYPE_CLASSIFY:
17617 s = format (s, "classify");
17625 vl_api_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
17628 " weight %d, sw_if_index %d, type %U, afi %U, next_hop %U",
17629 ntohl (fp->weight), ntohl (fp->sw_if_index),
17630 format_vl_api_fib_path_type, fp->type,
17631 format_fib_api_path_nh_proto, fp->proto,
17632 format_vl_api_ip_address_union, &fp->nh.address);
17636 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
17637 vl_api_fib_path_t * fp)
17639 struct in_addr ip4;
17640 struct in6_addr ip6;
17642 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
17643 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
17644 vat_json_object_add_uint (node, "type", fp->type);
17645 vat_json_object_add_uint (node, "next_hop_proto", fp->proto);
17646 if (fp->proto == FIB_API_PATH_NH_PROTO_IP4)
17648 clib_memcpy (&ip4, &fp->nh.address.ip4, sizeof (ip4));
17649 vat_json_object_add_ip4 (node, "next_hop", ip4);
17651 else if (fp->proto == FIB_API_PATH_NH_PROTO_IP6)
17653 clib_memcpy (&ip6, &fp->nh.address.ip6, sizeof (ip6));
17654 vat_json_object_add_ip6 (node, "next_hop", ip6);
17659 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
17661 vat_main_t *vam = &vat_main;
17662 int count = ntohl (mp->mt_tunnel.mt_n_paths);
17663 vl_api_fib_path_t *fp;
17666 print (vam->ofp, "sw_if_index %d via:",
17667 ntohl (mp->mt_tunnel.mt_sw_if_index));
17668 fp = mp->mt_tunnel.mt_paths;
17669 for (i = 0; i < count; i++)
17671 vl_api_fib_path_print (vam, fp);
17675 print (vam->ofp, "");
17678 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
17679 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
17682 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
17684 vat_main_t *vam = &vat_main;
17685 vat_json_node_t *node = NULL;
17686 int count = ntohl (mp->mt_tunnel.mt_n_paths);
17687 vl_api_fib_path_t *fp;
17690 if (VAT_JSON_ARRAY != vam->json_tree.type)
17692 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17693 vat_json_init_array (&vam->json_tree);
17695 node = vat_json_array_add (&vam->json_tree);
17697 vat_json_init_object (node);
17698 vat_json_object_add_uint (node, "sw_if_index",
17699 ntohl (mp->mt_tunnel.mt_sw_if_index));
17701 vat_json_object_add_uint (node, "l2_only", mp->mt_tunnel.mt_l2_only);
17703 fp = mp->mt_tunnel.mt_paths;
17704 for (i = 0; i < count; i++)
17706 vl_api_mpls_fib_path_json_print (node, fp);
17712 api_mpls_tunnel_dump (vat_main_t * vam)
17714 vl_api_mpls_tunnel_dump_t *mp;
17715 vl_api_control_ping_t *mp_ping;
17718 M (MPLS_TUNNEL_DUMP, mp);
17722 /* Use a control ping for synchronization */
17723 MPING (CONTROL_PING, mp_ping);
17730 #define vl_api_mpls_table_details_t_endian vl_noop_handler
17731 #define vl_api_mpls_table_details_t_print vl_noop_handler
17735 vl_api_mpls_table_details_t_handler (vl_api_mpls_table_details_t * mp)
17737 vat_main_t *vam = &vat_main;
17739 print (vam->ofp, "table-id %d,", ntohl (mp->mt_table.mt_table_id));
17742 static void vl_api_mpls_table_details_t_handler_json
17743 (vl_api_mpls_table_details_t * mp)
17745 vat_main_t *vam = &vat_main;
17746 vat_json_node_t *node = NULL;
17748 if (VAT_JSON_ARRAY != vam->json_tree.type)
17750 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17751 vat_json_init_array (&vam->json_tree);
17753 node = vat_json_array_add (&vam->json_tree);
17755 vat_json_init_object (node);
17756 vat_json_object_add_uint (node, "table", ntohl (mp->mt_table.mt_table_id));
17760 api_mpls_table_dump (vat_main_t * vam)
17762 vl_api_mpls_table_dump_t *mp;
17763 vl_api_control_ping_t *mp_ping;
17766 M (MPLS_TABLE_DUMP, mp);
17769 /* Use a control ping for synchronization */
17770 MPING (CONTROL_PING, mp_ping);
17777 #define vl_api_mpls_route_details_t_endian vl_noop_handler
17778 #define vl_api_mpls_route_details_t_print vl_noop_handler
17781 vl_api_mpls_route_details_t_handler (vl_api_mpls_route_details_t * mp)
17783 vat_main_t *vam = &vat_main;
17784 int count = (int) clib_net_to_host_u32 (mp->mr_route.mr_n_paths);
17785 vl_api_fib_path_t *fp;
17789 "table-id %d, label %u, ess_bit %u",
17790 ntohl (mp->mr_route.mr_table_id),
17791 ntohl (mp->mr_route.mr_label), mp->mr_route.mr_eos);
17792 fp = mp->mr_route.mr_paths;
17793 for (i = 0; i < count; i++)
17795 vl_api_fib_path_print (vam, fp);
17800 static void vl_api_mpls_route_details_t_handler_json
17801 (vl_api_mpls_route_details_t * mp)
17803 vat_main_t *vam = &vat_main;
17804 int count = (int) clib_host_to_net_u32 (mp->mr_route.mr_n_paths);
17805 vat_json_node_t *node = NULL;
17806 vl_api_fib_path_t *fp;
17809 if (VAT_JSON_ARRAY != vam->json_tree.type)
17811 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17812 vat_json_init_array (&vam->json_tree);
17814 node = vat_json_array_add (&vam->json_tree);
17816 vat_json_init_object (node);
17817 vat_json_object_add_uint (node, "table", ntohl (mp->mr_route.mr_table_id));
17818 vat_json_object_add_uint (node, "s_bit", mp->mr_route.mr_eos);
17819 vat_json_object_add_uint (node, "label", ntohl (mp->mr_route.mr_label));
17820 vat_json_object_add_uint (node, "path_count", count);
17821 fp = mp->mr_route.mr_paths;
17822 for (i = 0; i < count; i++)
17824 vl_api_mpls_fib_path_json_print (node, fp);
17830 api_mpls_route_dump (vat_main_t * vam)
17832 unformat_input_t *input = vam->input;
17833 vl_api_mpls_route_dump_t *mp;
17834 vl_api_control_ping_t *mp_ping;
17838 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17840 if (unformat (input, "table_id %d", &table_id))
17845 if (table_id == ~0)
17847 errmsg ("missing table id");
17851 M (MPLS_ROUTE_DUMP, mp);
17853 mp->table.mt_table_id = ntohl (table_id);
17856 /* Use a control ping for synchronization */
17857 MPING (CONTROL_PING, mp_ping);
17864 #define vl_api_ip_table_details_t_endian vl_noop_handler
17865 #define vl_api_ip_table_details_t_print vl_noop_handler
17868 vl_api_ip_table_details_t_handler (vl_api_ip_table_details_t * mp)
17870 vat_main_t *vam = &vat_main;
17873 "%s; table-id %d, prefix %U/%d",
17874 mp->table.name, ntohl (mp->table.table_id));
17878 static void vl_api_ip_table_details_t_handler_json
17879 (vl_api_ip_table_details_t * mp)
17881 vat_main_t *vam = &vat_main;
17882 vat_json_node_t *node = NULL;
17884 if (VAT_JSON_ARRAY != vam->json_tree.type)
17886 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17887 vat_json_init_array (&vam->json_tree);
17889 node = vat_json_array_add (&vam->json_tree);
17891 vat_json_init_object (node);
17892 vat_json_object_add_uint (node, "table", ntohl (mp->table.table_id));
17896 api_ip_table_dump (vat_main_t * vam)
17898 vl_api_ip_table_dump_t *mp;
17899 vl_api_control_ping_t *mp_ping;
17902 M (IP_TABLE_DUMP, mp);
17905 /* Use a control ping for synchronization */
17906 MPING (CONTROL_PING, mp_ping);
17914 api_ip_mtable_dump (vat_main_t * vam)
17916 vl_api_ip_mtable_dump_t *mp;
17917 vl_api_control_ping_t *mp_ping;
17920 M (IP_MTABLE_DUMP, mp);
17923 /* Use a control ping for synchronization */
17924 MPING (CONTROL_PING, mp_ping);
17932 api_ip_mroute_dump (vat_main_t * vam)
17934 unformat_input_t *input = vam->input;
17935 vl_api_control_ping_t *mp_ping;
17936 vl_api_ip_mroute_dump_t *mp;
17941 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17943 if (unformat (input, "table_id %d", &table_id))
17945 else if (unformat (input, "ip6"))
17947 else if (unformat (input, "ip4"))
17952 if (table_id == ~0)
17954 errmsg ("missing table id");
17958 M (IP_MROUTE_DUMP, mp);
17959 mp->table.table_id = table_id;
17960 mp->table.is_ip6 = is_ip6;
17963 /* Use a control ping for synchronization */
17964 MPING (CONTROL_PING, mp_ping);
17971 #define vl_api_ip_route_details_t_endian vl_noop_handler
17972 #define vl_api_ip_route_details_t_print vl_noop_handler
17975 vl_api_ip_route_details_t_handler (vl_api_ip_route_details_t * mp)
17977 vat_main_t *vam = &vat_main;
17978 u8 count = mp->route.n_paths;
17979 vl_api_fib_path_t *fp;
17983 "table-id %d, prefix %U/%d",
17984 ntohl (mp->route.table_id),
17985 format_ip46_address, mp->route.prefix.address, mp->route.prefix.len);
17986 for (i = 0; i < count; i++)
17988 fp = &mp->route.paths[i];
17990 vl_api_fib_path_print (vam, fp);
17995 static void vl_api_ip_route_details_t_handler_json
17996 (vl_api_ip_route_details_t * mp)
17998 vat_main_t *vam = &vat_main;
17999 u8 count = mp->route.n_paths;
18000 vat_json_node_t *node = NULL;
18001 struct in_addr ip4;
18002 struct in6_addr ip6;
18003 vl_api_fib_path_t *fp;
18006 if (VAT_JSON_ARRAY != vam->json_tree.type)
18008 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18009 vat_json_init_array (&vam->json_tree);
18011 node = vat_json_array_add (&vam->json_tree);
18013 vat_json_init_object (node);
18014 vat_json_object_add_uint (node, "table", ntohl (mp->route.table_id));
18015 if (ADDRESS_IP6 == mp->route.prefix.address.af)
18017 clib_memcpy (&ip6, &mp->route.prefix.address.un.ip6, sizeof (ip6));
18018 vat_json_object_add_ip6 (node, "prefix", ip6);
18022 clib_memcpy (&ip4, &mp->route.prefix.address.un.ip4, sizeof (ip4));
18023 vat_json_object_add_ip4 (node, "prefix", ip4);
18025 vat_json_object_add_uint (node, "mask_length", mp->route.prefix.len);
18026 vat_json_object_add_uint (node, "path_count", count);
18027 for (i = 0; i < count; i++)
18029 fp = &mp->route.paths[i];
18030 vl_api_mpls_fib_path_json_print (node, fp);
18035 api_ip_route_dump (vat_main_t * vam)
18037 unformat_input_t *input = vam->input;
18038 vl_api_ip_route_dump_t *mp;
18039 vl_api_control_ping_t *mp_ping;
18045 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18047 if (unformat (input, "table_id %d", &table_id))
18049 else if (unformat (input, "ip6"))
18051 else if (unformat (input, "ip4"))
18056 if (table_id == ~0)
18058 errmsg ("missing table id");
18062 M (IP_ROUTE_DUMP, mp);
18064 mp->table.table_id = table_id;
18065 mp->table.is_ip6 = is_ip6;
18069 /* Use a control ping for synchronization */
18070 MPING (CONTROL_PING, mp_ping);
18078 api_classify_table_ids (vat_main_t * vam)
18080 vl_api_classify_table_ids_t *mp;
18083 /* Construct the API message */
18084 M (CLASSIFY_TABLE_IDS, mp);
18093 api_classify_table_by_interface (vat_main_t * vam)
18095 unformat_input_t *input = vam->input;
18096 vl_api_classify_table_by_interface_t *mp;
18098 u32 sw_if_index = ~0;
18100 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18102 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18104 else if (unformat (input, "sw_if_index %d", &sw_if_index))
18109 if (sw_if_index == ~0)
18111 errmsg ("missing interface name or sw_if_index");
18115 /* Construct the API message */
18116 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
18118 mp->sw_if_index = ntohl (sw_if_index);
18126 api_classify_table_info (vat_main_t * vam)
18128 unformat_input_t *input = vam->input;
18129 vl_api_classify_table_info_t *mp;
18133 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18135 if (unformat (input, "table_id %d", &table_id))
18140 if (table_id == ~0)
18142 errmsg ("missing table id");
18146 /* Construct the API message */
18147 M (CLASSIFY_TABLE_INFO, mp);
18149 mp->table_id = ntohl (table_id);
18157 api_classify_session_dump (vat_main_t * vam)
18159 unformat_input_t *input = vam->input;
18160 vl_api_classify_session_dump_t *mp;
18161 vl_api_control_ping_t *mp_ping;
18165 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18167 if (unformat (input, "table_id %d", &table_id))
18172 if (table_id == ~0)
18174 errmsg ("missing table id");
18178 /* Construct the API message */
18179 M (CLASSIFY_SESSION_DUMP, mp);
18181 mp->table_id = ntohl (table_id);
18184 /* Use a control ping for synchronization */
18185 MPING (CONTROL_PING, mp_ping);
18193 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
18195 vat_main_t *vam = &vat_main;
18197 print (vam->ofp, "collector_address %U, collector_port %d, "
18198 "src_address %U, vrf_id %d, path_mtu %u, "
18199 "template_interval %u, udp_checksum %d",
18200 format_ip4_address, mp->collector_address,
18201 ntohs (mp->collector_port),
18202 format_ip4_address, mp->src_address,
18203 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
18204 ntohl (mp->template_interval), mp->udp_checksum);
18207 vam->result_ready = 1;
18211 vl_api_ipfix_exporter_details_t_handler_json
18212 (vl_api_ipfix_exporter_details_t * mp)
18214 vat_main_t *vam = &vat_main;
18215 vat_json_node_t node;
18216 struct in_addr collector_address;
18217 struct in_addr src_address;
18219 vat_json_init_object (&node);
18220 clib_memcpy (&collector_address, &mp->collector_address,
18221 sizeof (collector_address));
18222 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
18223 vat_json_object_add_uint (&node, "collector_port",
18224 ntohs (mp->collector_port));
18225 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
18226 vat_json_object_add_ip4 (&node, "src_address", src_address);
18227 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
18228 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
18229 vat_json_object_add_uint (&node, "template_interval",
18230 ntohl (mp->template_interval));
18231 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
18233 vat_json_print (vam->ofp, &node);
18234 vat_json_free (&node);
18236 vam->result_ready = 1;
18240 api_ipfix_exporter_dump (vat_main_t * vam)
18242 vl_api_ipfix_exporter_dump_t *mp;
18245 /* Construct the API message */
18246 M (IPFIX_EXPORTER_DUMP, mp);
18255 api_ipfix_classify_stream_dump (vat_main_t * vam)
18257 vl_api_ipfix_classify_stream_dump_t *mp;
18260 /* Construct the API message */
18261 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
18272 vl_api_ipfix_classify_stream_details_t_handler
18273 (vl_api_ipfix_classify_stream_details_t * mp)
18275 vat_main_t *vam = &vat_main;
18276 print (vam->ofp, "domain_id %d, src_port %d",
18277 ntohl (mp->domain_id), ntohs (mp->src_port));
18279 vam->result_ready = 1;
18283 vl_api_ipfix_classify_stream_details_t_handler_json
18284 (vl_api_ipfix_classify_stream_details_t * mp)
18286 vat_main_t *vam = &vat_main;
18287 vat_json_node_t node;
18289 vat_json_init_object (&node);
18290 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
18291 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
18293 vat_json_print (vam->ofp, &node);
18294 vat_json_free (&node);
18296 vam->result_ready = 1;
18300 api_ipfix_classify_table_dump (vat_main_t * vam)
18302 vl_api_ipfix_classify_table_dump_t *mp;
18303 vl_api_control_ping_t *mp_ping;
18306 if (!vam->json_output)
18308 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
18309 "transport_protocol");
18312 /* Construct the API message */
18313 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
18318 /* Use a control ping for synchronization */
18319 MPING (CONTROL_PING, mp_ping);
18327 vl_api_ipfix_classify_table_details_t_handler
18328 (vl_api_ipfix_classify_table_details_t * mp)
18330 vat_main_t *vam = &vat_main;
18331 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
18332 mp->transport_protocol);
18336 vl_api_ipfix_classify_table_details_t_handler_json
18337 (vl_api_ipfix_classify_table_details_t * mp)
18339 vat_json_node_t *node = NULL;
18340 vat_main_t *vam = &vat_main;
18342 if (VAT_JSON_ARRAY != vam->json_tree.type)
18344 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18345 vat_json_init_array (&vam->json_tree);
18348 node = vat_json_array_add (&vam->json_tree);
18349 vat_json_init_object (node);
18351 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
18352 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
18353 vat_json_object_add_uint (node, "transport_protocol",
18354 mp->transport_protocol);
18358 api_sw_interface_span_enable_disable (vat_main_t * vam)
18360 unformat_input_t *i = vam->input;
18361 vl_api_sw_interface_span_enable_disable_t *mp;
18362 u32 src_sw_if_index = ~0;
18363 u32 dst_sw_if_index = ~0;
18368 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18371 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
18373 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
18377 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
18379 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
18381 else if (unformat (i, "disable"))
18383 else if (unformat (i, "rx"))
18385 else if (unformat (i, "tx"))
18387 else if (unformat (i, "both"))
18389 else if (unformat (i, "l2"))
18395 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
18397 mp->sw_if_index_from = htonl (src_sw_if_index);
18398 mp->sw_if_index_to = htonl (dst_sw_if_index);
18408 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
18411 vat_main_t *vam = &vat_main;
18412 u8 *sw_if_from_name = 0;
18413 u8 *sw_if_to_name = 0;
18414 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
18415 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
18416 char *states[] = { "none", "rx", "tx", "both" };
18420 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
18422 if ((u32) p->value[0] == sw_if_index_from)
18424 sw_if_from_name = (u8 *)(p->key);
18428 if ((u32) p->value[0] == sw_if_index_to)
18430 sw_if_to_name = (u8 *)(p->key);
18431 if (sw_if_from_name)
18436 print (vam->ofp, "%20s => %20s (%s) %s",
18437 sw_if_from_name, sw_if_to_name, states[mp->state],
18438 mp->is_l2 ? "l2" : "device");
18442 vl_api_sw_interface_span_details_t_handler_json
18443 (vl_api_sw_interface_span_details_t * mp)
18445 vat_main_t *vam = &vat_main;
18446 vat_json_node_t *node = NULL;
18447 u8 *sw_if_from_name = 0;
18448 u8 *sw_if_to_name = 0;
18449 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
18450 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
18454 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
18456 if ((u32) p->value[0] == sw_if_index_from)
18458 sw_if_from_name = (u8 *)(p->key);
18462 if ((u32) p->value[0] == sw_if_index_to)
18464 sw_if_to_name = (u8 *)(p->key);
18465 if (sw_if_from_name)
18471 if (VAT_JSON_ARRAY != vam->json_tree.type)
18473 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18474 vat_json_init_array (&vam->json_tree);
18476 node = vat_json_array_add (&vam->json_tree);
18478 vat_json_init_object (node);
18479 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
18480 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
18481 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
18482 if (0 != sw_if_to_name)
18484 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
18486 vat_json_object_add_uint (node, "state", mp->state);
18487 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
18491 api_sw_interface_span_dump (vat_main_t * vam)
18493 unformat_input_t *input = vam->input;
18494 vl_api_sw_interface_span_dump_t *mp;
18495 vl_api_control_ping_t *mp_ping;
18499 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18501 if (unformat (input, "l2"))
18507 M (SW_INTERFACE_SPAN_DUMP, mp);
18511 /* Use a control ping for synchronization */
18512 MPING (CONTROL_PING, mp_ping);
18520 api_pg_create_interface (vat_main_t * vam)
18522 unformat_input_t *input = vam->input;
18523 vl_api_pg_create_interface_t *mp;
18525 u32 if_id = ~0, gso_size = 0;
18526 u8 gso_enabled = 0;
18528 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18530 if (unformat (input, "if_id %d", &if_id))
18532 else if (unformat (input, "gso-enabled"))
18535 if (unformat (input, "gso-size %u", &gso_size))
18539 errmsg ("missing gso-size");
18548 errmsg ("missing pg interface index");
18552 /* Construct the API message */
18553 M (PG_CREATE_INTERFACE, mp);
18555 mp->interface_id = ntohl (if_id);
18556 mp->gso_enabled = gso_enabled;
18564 api_pg_capture (vat_main_t * vam)
18566 unformat_input_t *input = vam->input;
18567 vl_api_pg_capture_t *mp;
18572 u8 pcap_file_set = 0;
18575 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18577 if (unformat (input, "if_id %d", &if_id))
18579 else if (unformat (input, "pcap %s", &pcap_file))
18581 else if (unformat (input, "count %d", &count))
18583 else if (unformat (input, "disable"))
18590 errmsg ("missing pg interface index");
18593 if (pcap_file_set > 0)
18595 if (vec_len (pcap_file) > 255)
18597 errmsg ("pcap file name is too long");
18602 /* Construct the API message */
18603 M (PG_CAPTURE, mp);
18605 mp->interface_id = ntohl (if_id);
18606 mp->is_enabled = enable;
18607 mp->count = ntohl (count);
18608 if (pcap_file_set != 0)
18610 vl_api_vec_to_api_string (pcap_file, &mp->pcap_file_name);
18612 vec_free (pcap_file);
18620 api_pg_enable_disable (vat_main_t * vam)
18622 unformat_input_t *input = vam->input;
18623 vl_api_pg_enable_disable_t *mp;
18626 u8 stream_name_set = 0;
18627 u8 *stream_name = 0;
18629 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18631 if (unformat (input, "stream %s", &stream_name))
18632 stream_name_set = 1;
18633 else if (unformat (input, "disable"))
18639 if (stream_name_set > 0)
18641 if (vec_len (stream_name) > 255)
18643 errmsg ("stream name too long");
18648 /* Construct the API message */
18649 M (PG_ENABLE_DISABLE, mp);
18651 mp->is_enabled = enable;
18652 if (stream_name_set != 0)
18654 vl_api_vec_to_api_string (stream_name, &mp->stream_name);
18656 vec_free (stream_name);
18664 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
18666 unformat_input_t *input = vam->input;
18667 vl_api_ip_source_and_port_range_check_add_del_t *mp;
18669 u16 *low_ports = 0;
18670 u16 *high_ports = 0;
18673 vl_api_prefix_t prefix;
18680 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18682 if (unformat (input, "%U", unformat_vl_api_prefix, &prefix))
18684 else if (unformat (input, "vrf %d", &vrf_id))
18686 else if (unformat (input, "del"))
18688 else if (unformat (input, "port %d", &tmp))
18690 if (tmp == 0 || tmp > 65535)
18692 errmsg ("port %d out of range", tmp);
18696 this_hi = this_low + 1;
18697 vec_add1 (low_ports, this_low);
18698 vec_add1 (high_ports, this_hi);
18700 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
18702 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
18704 errmsg ("incorrect range parameters");
18708 /* Note: in debug CLI +1 is added to high before
18709 passing to real fn that does "the work"
18710 (ip_source_and_port_range_check_add_del).
18711 This fn is a wrapper around the binary API fn a
18712 control plane will call, which expects this increment
18713 to have occurred. Hence letting the binary API control
18714 plane fn do the increment for consistency between VAT
18715 and other control planes.
18718 vec_add1 (low_ports, this_low);
18719 vec_add1 (high_ports, this_hi);
18725 if (prefix_set == 0)
18727 errmsg ("<address>/<mask> not specified");
18733 errmsg ("VRF ID required, not specified");
18740 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
18744 if (vec_len (low_ports) == 0)
18746 errmsg ("At least one port or port range required");
18750 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
18752 mp->is_add = is_add;
18754 clib_memcpy (&mp->prefix, &prefix, sizeof (prefix));
18756 mp->number_of_ranges = vec_len (low_ports);
18758 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
18759 vec_free (low_ports);
18761 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
18762 vec_free (high_ports);
18764 mp->vrf_id = ntohl (vrf_id);
18772 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
18774 unformat_input_t *input = vam->input;
18775 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
18776 u32 sw_if_index = ~0;
18778 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
18779 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
18783 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18785 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18787 else if (unformat (input, "sw_if_index %d", &sw_if_index))
18789 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
18791 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
18793 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
18795 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
18797 else if (unformat (input, "del"))
18803 if (sw_if_index == ~0)
18805 errmsg ("Interface required but not specified");
18811 errmsg ("VRF ID required but not specified");
18815 if (tcp_out_vrf_id == 0
18816 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
18819 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
18823 /* Construct the API message */
18824 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
18826 mp->sw_if_index = ntohl (sw_if_index);
18827 mp->is_add = is_add;
18828 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
18829 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
18830 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
18831 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
18836 /* Wait for a reply... */
18842 api_set_punt (vat_main_t * vam)
18844 unformat_input_t *i = vam->input;
18845 vl_api_address_family_t af;
18846 vl_api_set_punt_t *mp;
18852 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18854 if (unformat (i, "%U", unformat_vl_api_address_family, &af))
18856 else if (unformat (i, "protocol %d", &protocol))
18858 else if (unformat (i, "port %d", &port))
18860 else if (unformat (i, "del"))
18864 clib_warning ("parse error '%U'", format_unformat_error, i);
18871 mp->is_add = (u8) is_add;
18872 mp->punt.type = PUNT_API_TYPE_L4;
18873 mp->punt.punt.l4.af = af;
18874 mp->punt.punt.l4.protocol = (u8) protocol;
18875 mp->punt.punt.l4.port = htons ((u16) port);
18883 api_delete_subif (vat_main_t * vam)
18885 unformat_input_t *i = vam->input;
18886 vl_api_delete_subif_t *mp;
18887 u32 sw_if_index = ~0;
18890 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18892 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18894 if (unformat (i, "sw_if_index %d", &sw_if_index))
18900 if (sw_if_index == ~0)
18902 errmsg ("missing sw_if_index");
18906 /* Construct the API message */
18907 M (DELETE_SUBIF, mp);
18908 mp->sw_if_index = ntohl (sw_if_index);
18915 #define foreach_pbb_vtr_op \
18916 _("disable", L2_VTR_DISABLED) \
18917 _("pop", L2_VTR_POP_2) \
18918 _("push", L2_VTR_PUSH_2)
18921 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
18923 unformat_input_t *i = vam->input;
18924 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
18925 u32 sw_if_index = ~0, vtr_op = ~0;
18926 u16 outer_tag = ~0;
18927 u8 dmac[6], smac[6];
18928 u8 dmac_set = 0, smac_set = 0;
18934 /* Shut up coverity */
18935 clib_memset (dmac, 0, sizeof (dmac));
18936 clib_memset (smac, 0, sizeof (smac));
18938 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18940 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18942 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18944 else if (unformat (i, "vtr_op %d", &vtr_op))
18946 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
18949 else if (unformat (i, "translate_pbb_stag"))
18951 if (unformat (i, "%d", &tmp))
18953 vtr_op = L2_VTR_TRANSLATE_2_1;
18959 ("translate_pbb_stag operation requires outer tag definition");
18963 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
18965 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
18967 else if (unformat (i, "sid %d", &sid))
18969 else if (unformat (i, "vlanid %d", &tmp))
18973 clib_warning ("parse error '%U'", format_unformat_error, i);
18978 if ((sw_if_index == ~0) || (vtr_op == ~0))
18980 errmsg ("missing sw_if_index or vtr operation");
18983 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
18984 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
18987 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
18991 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
18992 mp->sw_if_index = ntohl (sw_if_index);
18993 mp->vtr_op = ntohl (vtr_op);
18994 mp->outer_tag = ntohs (outer_tag);
18995 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
18996 clib_memcpy (mp->b_smac, smac, sizeof (smac));
18997 mp->b_vlanid = ntohs (vlanid);
18998 mp->i_sid = ntohl (sid);
19006 api_flow_classify_set_interface (vat_main_t * vam)
19008 unformat_input_t *i = vam->input;
19009 vl_api_flow_classify_set_interface_t *mp;
19011 int sw_if_index_set;
19012 u32 ip4_table_index = ~0;
19013 u32 ip6_table_index = ~0;
19017 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19019 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19020 sw_if_index_set = 1;
19021 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19022 sw_if_index_set = 1;
19023 else if (unformat (i, "del"))
19025 else if (unformat (i, "ip4-table %d", &ip4_table_index))
19027 else if (unformat (i, "ip6-table %d", &ip6_table_index))
19031 clib_warning ("parse error '%U'", format_unformat_error, i);
19036 if (sw_if_index_set == 0)
19038 errmsg ("missing interface name or sw_if_index");
19042 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
19044 mp->sw_if_index = ntohl (sw_if_index);
19045 mp->ip4_table_index = ntohl (ip4_table_index);
19046 mp->ip6_table_index = ntohl (ip6_table_index);
19047 mp->is_add = is_add;
19055 api_flow_classify_dump (vat_main_t * vam)
19057 unformat_input_t *i = vam->input;
19058 vl_api_flow_classify_dump_t *mp;
19059 vl_api_control_ping_t *mp_ping;
19060 u8 type = FLOW_CLASSIFY_N_TABLES;
19063 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
19067 errmsg ("classify table type must be specified");
19071 if (!vam->json_output)
19073 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
19076 M (FLOW_CLASSIFY_DUMP, mp);
19081 /* Use a control ping for synchronization */
19082 MPING (CONTROL_PING, mp_ping);
19085 /* Wait for a reply... */
19091 api_feature_enable_disable (vat_main_t * vam)
19093 unformat_input_t *i = vam->input;
19094 vl_api_feature_enable_disable_t *mp;
19096 u8 *feature_name = 0;
19097 u32 sw_if_index = ~0;
19101 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19103 if (unformat (i, "arc_name %s", &arc_name))
19105 else if (unformat (i, "feature_name %s", &feature_name))
19108 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19110 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19112 else if (unformat (i, "disable"))
19120 errmsg ("missing arc name");
19123 if (vec_len (arc_name) > 63)
19125 errmsg ("arc name too long");
19128 if (feature_name == 0)
19130 errmsg ("missing feature name");
19133 if (vec_len (feature_name) > 63)
19135 errmsg ("feature name too long");
19138 if (sw_if_index == ~0)
19140 errmsg ("missing interface name or sw_if_index");
19144 /* Construct the API message */
19145 M (FEATURE_ENABLE_DISABLE, mp);
19146 mp->sw_if_index = ntohl (sw_if_index);
19147 mp->enable = enable;
19148 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
19149 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
19150 vec_free (arc_name);
19151 vec_free (feature_name);
19159 api_feature_gso_enable_disable (vat_main_t * vam)
19161 unformat_input_t *i = vam->input;
19162 vl_api_feature_gso_enable_disable_t *mp;
19163 u32 sw_if_index = ~0;
19167 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19169 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19171 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19173 else if (unformat (i, "enable"))
19175 else if (unformat (i, "disable"))
19181 if (sw_if_index == ~0)
19183 errmsg ("missing interface name or sw_if_index");
19187 /* Construct the API message */
19188 M (FEATURE_GSO_ENABLE_DISABLE, mp);
19189 mp->sw_if_index = ntohl (sw_if_index);
19190 mp->enable_disable = enable;
19198 api_sw_interface_tag_add_del (vat_main_t * vam)
19200 unformat_input_t *i = vam->input;
19201 vl_api_sw_interface_tag_add_del_t *mp;
19202 u32 sw_if_index = ~0;
19207 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19209 if (unformat (i, "tag %s", &tag))
19211 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19213 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19215 else if (unformat (i, "del"))
19221 if (sw_if_index == ~0)
19223 errmsg ("missing interface name or sw_if_index");
19227 if (enable && (tag == 0))
19229 errmsg ("no tag specified");
19233 /* Construct the API message */
19234 M (SW_INTERFACE_TAG_ADD_DEL, mp);
19235 mp->sw_if_index = ntohl (sw_if_index);
19236 mp->is_add = enable;
19238 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
19247 api_sw_interface_add_del_mac_address (vat_main_t * vam)
19249 unformat_input_t *i = vam->input;
19250 vl_api_mac_address_t mac = { 0 };
19251 vl_api_sw_interface_add_del_mac_address_t *mp;
19252 u32 sw_if_index = ~0;
19257 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19259 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19261 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19263 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
19265 else if (unformat (i, "del"))
19271 if (sw_if_index == ~0)
19273 errmsg ("missing interface name or sw_if_index");
19279 errmsg ("missing MAC address");
19283 /* Construct the API message */
19284 M (SW_INTERFACE_ADD_DEL_MAC_ADDRESS, mp);
19285 mp->sw_if_index = ntohl (sw_if_index);
19286 mp->is_add = is_add;
19287 clib_memcpy (&mp->addr, &mac, sizeof (mac));
19294 static void vl_api_l2_xconnect_details_t_handler
19295 (vl_api_l2_xconnect_details_t * mp)
19297 vat_main_t *vam = &vat_main;
19299 print (vam->ofp, "%15d%15d",
19300 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
19303 static void vl_api_l2_xconnect_details_t_handler_json
19304 (vl_api_l2_xconnect_details_t * mp)
19306 vat_main_t *vam = &vat_main;
19307 vat_json_node_t *node = NULL;
19309 if (VAT_JSON_ARRAY != vam->json_tree.type)
19311 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19312 vat_json_init_array (&vam->json_tree);
19314 node = vat_json_array_add (&vam->json_tree);
19316 vat_json_init_object (node);
19317 vat_json_object_add_uint (node, "rx_sw_if_index",
19318 ntohl (mp->rx_sw_if_index));
19319 vat_json_object_add_uint (node, "tx_sw_if_index",
19320 ntohl (mp->tx_sw_if_index));
19324 api_l2_xconnect_dump (vat_main_t * vam)
19326 vl_api_l2_xconnect_dump_t *mp;
19327 vl_api_control_ping_t *mp_ping;
19330 if (!vam->json_output)
19332 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
19335 M (L2_XCONNECT_DUMP, mp);
19339 /* Use a control ping for synchronization */
19340 MPING (CONTROL_PING, mp_ping);
19348 api_hw_interface_set_mtu (vat_main_t * vam)
19350 unformat_input_t *i = vam->input;
19351 vl_api_hw_interface_set_mtu_t *mp;
19352 u32 sw_if_index = ~0;
19356 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19358 if (unformat (i, "mtu %d", &mtu))
19360 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19362 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19368 if (sw_if_index == ~0)
19370 errmsg ("missing interface name or sw_if_index");
19376 errmsg ("no mtu specified");
19380 /* Construct the API message */
19381 M (HW_INTERFACE_SET_MTU, mp);
19382 mp->sw_if_index = ntohl (sw_if_index);
19383 mp->mtu = ntohs ((u16) mtu);
19391 api_p2p_ethernet_add (vat_main_t * vam)
19393 unformat_input_t *i = vam->input;
19394 vl_api_p2p_ethernet_add_t *mp;
19395 u32 parent_if_index = ~0;
19401 clib_memset (remote_mac, 0, sizeof (remote_mac));
19402 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19404 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
19406 else if (unformat (i, "sw_if_index %d", &parent_if_index))
19410 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
19412 else if (unformat (i, "sub_id %d", &sub_id))
19416 clib_warning ("parse error '%U'", format_unformat_error, i);
19421 if (parent_if_index == ~0)
19423 errmsg ("missing interface name or sw_if_index");
19428 errmsg ("missing remote mac address");
19433 errmsg ("missing sub-interface id");
19437 M (P2P_ETHERNET_ADD, mp);
19438 mp->parent_if_index = ntohl (parent_if_index);
19439 mp->subif_id = ntohl (sub_id);
19440 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
19448 api_p2p_ethernet_del (vat_main_t * vam)
19450 unformat_input_t *i = vam->input;
19451 vl_api_p2p_ethernet_del_t *mp;
19452 u32 parent_if_index = ~0;
19457 clib_memset (remote_mac, 0, sizeof (remote_mac));
19458 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19460 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
19462 else if (unformat (i, "sw_if_index %d", &parent_if_index))
19466 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
19470 clib_warning ("parse error '%U'", format_unformat_error, i);
19475 if (parent_if_index == ~0)
19477 errmsg ("missing interface name or sw_if_index");
19482 errmsg ("missing remote mac address");
19486 M (P2P_ETHERNET_DEL, mp);
19487 mp->parent_if_index = ntohl (parent_if_index);
19488 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
19496 api_lldp_config (vat_main_t * vam)
19498 unformat_input_t *i = vam->input;
19499 vl_api_lldp_config_t *mp;
19501 int tx_interval = 0;
19502 u8 *sys_name = NULL;
19505 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19507 if (unformat (i, "system-name %s", &sys_name))
19509 else if (unformat (i, "tx-hold %d", &tx_hold))
19511 else if (unformat (i, "tx-interval %d", &tx_interval))
19515 clib_warning ("parse error '%U'", format_unformat_error, i);
19520 vec_add1 (sys_name, 0);
19522 M (LLDP_CONFIG, mp);
19523 mp->tx_hold = htonl (tx_hold);
19524 mp->tx_interval = htonl (tx_interval);
19525 vl_api_vec_to_api_string (sys_name, &mp->system_name);
19526 vec_free (sys_name);
19534 api_sw_interface_set_lldp (vat_main_t * vam)
19536 unformat_input_t *i = vam->input;
19537 vl_api_sw_interface_set_lldp_t *mp;
19538 u32 sw_if_index = ~0;
19540 u8 *port_desc = NULL, *mgmt_oid = NULL;
19541 ip4_address_t ip4_addr;
19542 ip6_address_t ip6_addr;
19545 clib_memset (&ip4_addr, 0, sizeof (ip4_addr));
19546 clib_memset (&ip6_addr, 0, sizeof (ip6_addr));
19548 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19550 if (unformat (i, "disable"))
19553 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19555 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19557 else if (unformat (i, "port-desc %s", &port_desc))
19559 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
19561 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
19563 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
19569 if (sw_if_index == ~0)
19571 errmsg ("missing interface name or sw_if_index");
19575 /* Construct the API message */
19576 vec_add1 (port_desc, 0);
19577 vec_add1 (mgmt_oid, 0);
19578 M (SW_INTERFACE_SET_LLDP, mp);
19579 mp->sw_if_index = ntohl (sw_if_index);
19580 mp->enable = enable;
19581 vl_api_vec_to_api_string (port_desc, &mp->port_desc);
19582 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
19583 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
19584 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
19585 vec_free (port_desc);
19586 vec_free (mgmt_oid);
19594 api_tcp_configure_src_addresses (vat_main_t * vam)
19596 vl_api_tcp_configure_src_addresses_t *mp;
19597 unformat_input_t *i = vam->input;
19598 vl_api_address_t first, last;
19603 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19605 if (unformat (i, "%U - %U",
19606 unformat_vl_api_address, &first,
19607 unformat_vl_api_address, &last))
19611 errmsg ("one range per message (range already set)");
19616 else if (unformat (i, "vrf %d", &vrf_id))
19622 if (range_set == 0)
19624 errmsg ("address range not set");
19628 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
19630 mp->vrf_id = ntohl (vrf_id);
19631 clib_memcpy (&mp->first_address, &first, sizeof (first));
19632 clib_memcpy (&mp->last_address, &last, sizeof (last));
19639 static void vl_api_app_namespace_add_del_reply_t_handler
19640 (vl_api_app_namespace_add_del_reply_t * mp)
19642 vat_main_t *vam = &vat_main;
19643 i32 retval = ntohl (mp->retval);
19644 if (vam->async_mode)
19646 vam->async_errors += (retval < 0);
19650 vam->retval = retval;
19652 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
19653 vam->result_ready = 1;
19657 static void vl_api_app_namespace_add_del_reply_t_handler_json
19658 (vl_api_app_namespace_add_del_reply_t * mp)
19660 vat_main_t *vam = &vat_main;
19661 vat_json_node_t node;
19663 vat_json_init_object (&node);
19664 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
19665 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
19667 vat_json_print (vam->ofp, &node);
19668 vat_json_free (&node);
19670 vam->retval = ntohl (mp->retval);
19671 vam->result_ready = 1;
19675 api_app_namespace_add_del (vat_main_t * vam)
19677 vl_api_app_namespace_add_del_t *mp;
19678 unformat_input_t *i = vam->input;
19679 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
19680 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
19684 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19686 if (unformat (i, "id %_%v%_", &ns_id))
19688 else if (unformat (i, "secret %lu", &secret))
19690 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19691 sw_if_index_set = 1;
19692 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
19694 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
19699 if (!ns_id || !secret_set || !sw_if_index_set)
19701 errmsg ("namespace id, secret and sw_if_index must be set");
19704 if (vec_len (ns_id) > 64)
19706 errmsg ("namespace id too long");
19709 M (APP_NAMESPACE_ADD_DEL, mp);
19711 vl_api_vec_to_api_string (ns_id, &mp->namespace_id);
19712 mp->secret = clib_host_to_net_u64 (secret);
19713 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
19714 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
19715 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
19723 api_sock_init_shm (vat_main_t * vam)
19725 #if VPP_API_TEST_BUILTIN == 0
19726 unformat_input_t *i = vam->input;
19727 vl_api_shm_elem_config_t *config = 0;
19728 u64 size = 64 << 20;
19731 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19733 if (unformat (i, "size %U", unformat_memory_size, &size))
19740 * Canned custom ring allocator config.
19741 * Should probably parse all of this
19743 vec_validate (config, 6);
19744 config[0].type = VL_API_VLIB_RING;
19745 config[0].size = 256;
19746 config[0].count = 32;
19748 config[1].type = VL_API_VLIB_RING;
19749 config[1].size = 1024;
19750 config[1].count = 16;
19752 config[2].type = VL_API_VLIB_RING;
19753 config[2].size = 4096;
19754 config[2].count = 2;
19756 config[3].type = VL_API_CLIENT_RING;
19757 config[3].size = 256;
19758 config[3].count = 32;
19760 config[4].type = VL_API_CLIENT_RING;
19761 config[4].size = 1024;
19762 config[4].count = 16;
19764 config[5].type = VL_API_CLIENT_RING;
19765 config[5].size = 4096;
19766 config[5].count = 2;
19768 config[6].type = VL_API_QUEUE;
19769 config[6].count = 128;
19770 config[6].size = sizeof (uword);
19772 rv = vl_socket_client_init_shm (config, 1 /* want_pthread */ );
19774 vam->client_index_invalid = 1;
19782 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
19784 vat_main_t *vam = &vat_main;
19785 fib_prefix_t lcl, rmt;
19787 ip_prefix_decode (&mp->lcl, &lcl);
19788 ip_prefix_decode (&mp->rmt, &rmt);
19790 if (lcl.fp_proto == FIB_PROTOCOL_IP4)
19793 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
19794 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
19795 mp->scope, format_ip4_address, &lcl.fp_addr.ip4, lcl.fp_len,
19796 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
19797 &rmt.fp_addr.ip4, rmt.fp_len,
19798 clib_net_to_host_u16 (mp->rmt_port),
19799 clib_net_to_host_u32 (mp->action_index), mp->tag);
19804 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
19805 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
19806 mp->scope, format_ip6_address, &lcl.fp_addr.ip6, lcl.fp_len,
19807 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
19808 &rmt.fp_addr.ip6, rmt.fp_len,
19809 clib_net_to_host_u16 (mp->rmt_port),
19810 clib_net_to_host_u32 (mp->action_index), mp->tag);
19815 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
19818 vat_main_t *vam = &vat_main;
19819 vat_json_node_t *node = NULL;
19820 struct in6_addr ip6;
19821 struct in_addr ip4;
19823 fib_prefix_t lcl, rmt;
19825 ip_prefix_decode (&mp->lcl, &lcl);
19826 ip_prefix_decode (&mp->rmt, &rmt);
19828 if (VAT_JSON_ARRAY != vam->json_tree.type)
19830 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19831 vat_json_init_array (&vam->json_tree);
19833 node = vat_json_array_add (&vam->json_tree);
19834 vat_json_init_object (node);
19836 vat_json_object_add_uint (node, "appns_index",
19837 clib_net_to_host_u32 (mp->appns_index));
19838 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
19839 vat_json_object_add_uint (node, "scope", mp->scope);
19840 vat_json_object_add_uint (node, "action_index",
19841 clib_net_to_host_u32 (mp->action_index));
19842 vat_json_object_add_uint (node, "lcl_port",
19843 clib_net_to_host_u16 (mp->lcl_port));
19844 vat_json_object_add_uint (node, "rmt_port",
19845 clib_net_to_host_u16 (mp->rmt_port));
19846 vat_json_object_add_uint (node, "lcl_plen", lcl.fp_len);
19847 vat_json_object_add_uint (node, "rmt_plen", rmt.fp_len);
19848 vat_json_object_add_string_copy (node, "tag", mp->tag);
19849 if (lcl.fp_proto == FIB_PROTOCOL_IP4)
19851 clib_memcpy (&ip4, &lcl.fp_addr.ip4, sizeof (ip4));
19852 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
19853 clib_memcpy (&ip4, &rmt.fp_addr.ip4, sizeof (ip4));
19854 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
19858 clib_memcpy (&ip6, &lcl.fp_addr.ip6, sizeof (ip6));
19859 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
19860 clib_memcpy (&ip6, &rmt.fp_addr.ip6, sizeof (ip6));
19861 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
19866 api_session_rule_add_del (vat_main_t * vam)
19868 vl_api_session_rule_add_del_t *mp;
19869 unformat_input_t *i = vam->input;
19870 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
19871 u32 appns_index = 0, scope = 0;
19872 ip4_address_t lcl_ip4, rmt_ip4;
19873 ip6_address_t lcl_ip6, rmt_ip6;
19874 u8 is_ip4 = 1, conn_set = 0;
19875 u8 is_add = 1, *tag = 0;
19877 fib_prefix_t lcl, rmt;
19879 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19881 if (unformat (i, "del"))
19883 else if (unformat (i, "add"))
19885 else if (unformat (i, "proto tcp"))
19887 else if (unformat (i, "proto udp"))
19889 else if (unformat (i, "appns %d", &appns_index))
19891 else if (unformat (i, "scope %d", &scope))
19893 else if (unformat (i, "tag %_%v%_", &tag))
19897 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
19898 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
19906 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
19907 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
19913 else if (unformat (i, "action %d", &action))
19918 if (proto == ~0 || !conn_set || action == ~0)
19920 errmsg ("transport proto, connection and action must be set");
19926 errmsg ("scope should be 0-3");
19930 M (SESSION_RULE_ADD_DEL, mp);
19932 clib_memset (&lcl, 0, sizeof (lcl));
19933 clib_memset (&rmt, 0, sizeof (rmt));
19936 ip_set (&lcl.fp_addr, &lcl_ip4, 1);
19937 ip_set (&rmt.fp_addr, &rmt_ip4, 1);
19938 lcl.fp_len = lcl_plen;
19939 rmt.fp_len = rmt_plen;
19943 ip_set (&lcl.fp_addr, &lcl_ip6, 0);
19944 ip_set (&rmt.fp_addr, &rmt_ip6, 0);
19945 lcl.fp_len = lcl_plen;
19946 rmt.fp_len = rmt_plen;
19950 ip_prefix_encode (&lcl, &mp->lcl);
19951 ip_prefix_encode (&rmt, &mp->rmt);
19952 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
19953 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
19954 mp->transport_proto =
19955 proto ? TRANSPORT_PROTO_API_UDP : TRANSPORT_PROTO_API_TCP;
19956 mp->action_index = clib_host_to_net_u32 (action);
19957 mp->appns_index = clib_host_to_net_u32 (appns_index);
19959 mp->is_add = is_add;
19962 clib_memcpy (mp->tag, tag, vec_len (tag));
19972 api_session_rules_dump (vat_main_t * vam)
19974 vl_api_session_rules_dump_t *mp;
19975 vl_api_control_ping_t *mp_ping;
19978 if (!vam->json_output)
19980 print (vam->ofp, "%=20s", "Session Rules");
19983 M (SESSION_RULES_DUMP, mp);
19987 /* Use a control ping for synchronization */
19988 MPING (CONTROL_PING, mp_ping);
19991 /* Wait for a reply... */
19997 api_ip_container_proxy_add_del (vat_main_t * vam)
19999 vl_api_ip_container_proxy_add_del_t *mp;
20000 unformat_input_t *i = vam->input;
20001 u32 sw_if_index = ~0;
20002 vl_api_prefix_t pfx = { };
20006 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20008 if (unformat (i, "del"))
20010 else if (unformat (i, "add"))
20012 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
20014 else if (unformat (i, "sw_if_index %u", &sw_if_index))
20019 if (sw_if_index == ~0 || pfx.len == 0)
20021 errmsg ("address and sw_if_index must be set");
20025 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
20027 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
20028 mp->is_add = is_add;
20029 clib_memcpy (&mp->pfx, &pfx, sizeof (pfx));
20037 api_qos_record_enable_disable (vat_main_t * vam)
20039 unformat_input_t *i = vam->input;
20040 vl_api_qos_record_enable_disable_t *mp;
20041 u32 sw_if_index, qs = 0xff;
20042 u8 sw_if_index_set = 0;
20046 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20048 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20049 sw_if_index_set = 1;
20050 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20051 sw_if_index_set = 1;
20052 else if (unformat (i, "%U", unformat_qos_source, &qs))
20054 else if (unformat (i, "disable"))
20058 clib_warning ("parse error '%U'", format_unformat_error, i);
20063 if (sw_if_index_set == 0)
20065 errmsg ("missing interface name or sw_if_index");
20070 errmsg ("input location must be specified");
20074 M (QOS_RECORD_ENABLE_DISABLE, mp);
20076 mp->record.sw_if_index = ntohl (sw_if_index);
20077 mp->record.input_source = qs;
20078 mp->enable = enable;
20087 q_or_quit (vat_main_t * vam)
20089 #if VPP_API_TEST_BUILTIN == 0
20090 longjmp (vam->jump_buf, 1);
20092 return 0; /* not so much */
20096 q (vat_main_t * vam)
20098 return q_or_quit (vam);
20102 quit (vat_main_t * vam)
20104 return q_or_quit (vam);
20108 comment (vat_main_t * vam)
20114 elog_save (vat_main_t * vam)
20116 #if VPP_API_TEST_BUILTIN == 0
20117 elog_main_t *em = &vam->elog_main;
20118 unformat_input_t *i = vam->input;
20119 char *file, *chroot_file;
20120 clib_error_t *error;
20122 if (!unformat (i, "%s", &file))
20124 errmsg ("expected file name, got `%U'", format_unformat_error, i);
20128 /* It's fairly hard to get "../oopsie" through unformat; just in case */
20129 if (strstr (file, "..") || index (file, '/'))
20131 errmsg ("illegal characters in filename '%s'", file);
20135 chroot_file = (char *) format (0, "/tmp/%s%c", file, 0);
20139 errmsg ("Saving %wd of %wd events to %s",
20140 elog_n_events_in_buffer (em),
20141 elog_buffer_capacity (em), chroot_file);
20143 error = elog_write_file (em, chroot_file, 1 /* flush ring */ );
20144 vec_free (chroot_file);
20147 clib_error_report (error);
20149 errmsg ("Use the vpp event loger...");
20156 elog_setup (vat_main_t * vam)
20158 #if VPP_API_TEST_BUILTIN == 0
20159 elog_main_t *em = &vam->elog_main;
20160 unformat_input_t *i = vam->input;
20161 u32 nevents = 128 << 10;
20163 (void) unformat (i, "nevents %d", &nevents);
20165 elog_init (em, nevents);
20166 vl_api_set_elog_main (em);
20167 vl_api_set_elog_trace_api_messages (1);
20168 errmsg ("Event logger initialized with %u events", nevents);
20170 errmsg ("Use the vpp event loger...");
20176 elog_enable (vat_main_t * vam)
20178 #if VPP_API_TEST_BUILTIN == 0
20179 elog_main_t *em = &vam->elog_main;
20181 elog_enable_disable (em, 1 /* enable */ );
20182 vl_api_set_elog_trace_api_messages (1);
20183 errmsg ("Event logger enabled...");
20185 errmsg ("Use the vpp event loger...");
20191 elog_disable (vat_main_t * vam)
20193 #if VPP_API_TEST_BUILTIN == 0
20194 elog_main_t *em = &vam->elog_main;
20196 elog_enable_disable (em, 0 /* enable */ );
20197 vl_api_set_elog_trace_api_messages (1);
20198 errmsg ("Event logger disabled...");
20200 errmsg ("Use the vpp event loger...");
20206 statseg (vat_main_t * vam)
20208 ssvm_private_t *ssvmp = &vam->stat_segment;
20209 ssvm_shared_header_t *shared_header = ssvmp->sh;
20210 vlib_counter_t **counters;
20211 u64 thread0_index1_packets;
20212 u64 thread0_index1_bytes;
20213 f64 vector_rate, input_rate;
20216 uword *counter_vector_by_name;
20217 if (vam->stat_segment_lockp == 0)
20219 errmsg ("Stat segment not mapped...");
20223 /* look up "/if/rx for sw_if_index 1 as a test */
20225 clib_spinlock_lock (vam->stat_segment_lockp);
20227 counter_vector_by_name = (uword *) shared_header->opaque[1];
20229 p = hash_get_mem (counter_vector_by_name, "/if/rx");
20232 clib_spinlock_unlock (vam->stat_segment_lockp);
20233 errmsg ("/if/tx not found?");
20237 /* Fish per-thread vector of combined counters from shared memory */
20238 counters = (vlib_counter_t **) p[0];
20240 if (vec_len (counters[0]) < 2)
20242 clib_spinlock_unlock (vam->stat_segment_lockp);
20243 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
20247 /* Read thread 0 sw_if_index 1 counter */
20248 thread0_index1_packets = counters[0][1].packets;
20249 thread0_index1_bytes = counters[0][1].bytes;
20251 p = hash_get_mem (counter_vector_by_name, "vector_rate");
20254 clib_spinlock_unlock (vam->stat_segment_lockp);
20255 errmsg ("vector_rate not found?");
20259 vector_rate = *(f64 *) (p[0]);
20260 p = hash_get_mem (counter_vector_by_name, "input_rate");
20263 clib_spinlock_unlock (vam->stat_segment_lockp);
20264 errmsg ("input_rate not found?");
20267 input_rate = *(f64 *) (p[0]);
20269 clib_spinlock_unlock (vam->stat_segment_lockp);
20271 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
20272 vector_rate, input_rate);
20273 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
20274 thread0_index1_packets, thread0_index1_bytes);
20280 cmd_cmp (void *a1, void *a2)
20285 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
20289 help (vat_main_t * vam)
20294 unformat_input_t *i = vam->input;
20297 if (unformat (i, "%s", &name))
20301 vec_add1 (name, 0);
20303 hs = hash_get_mem (vam->help_by_name, name);
20305 print (vam->ofp, "usage: %s %s", name, hs[0]);
20307 print (vam->ofp, "No such msg / command '%s'", name);
20312 print (vam->ofp, "Help is available for the following:");
20315 hash_foreach_pair (p, vam->function_by_name,
20317 vec_add1 (cmds, (u8 *)(p->key));
20321 vec_sort_with_function (cmds, cmd_cmp);
20323 for (j = 0; j < vec_len (cmds); j++)
20324 print (vam->ofp, "%s", cmds[j]);
20331 set (vat_main_t * vam)
20333 u8 *name = 0, *value = 0;
20334 unformat_input_t *i = vam->input;
20336 if (unformat (i, "%s", &name))
20338 /* The input buffer is a vector, not a string. */
20339 value = vec_dup (i->buffer);
20340 vec_delete (value, i->index, 0);
20341 /* Almost certainly has a trailing newline */
20342 if (value[vec_len (value) - 1] == '\n')
20343 value[vec_len (value) - 1] = 0;
20344 /* Make sure it's a proper string, one way or the other */
20345 vec_add1 (value, 0);
20346 (void) clib_macro_set_value (&vam->macro_main,
20347 (char *) name, (char *) value);
20350 errmsg ("usage: set <name> <value>");
20358 unset (vat_main_t * vam)
20362 if (unformat (vam->input, "%s", &name))
20363 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
20364 errmsg ("unset: %s wasn't set", name);
20377 macro_sort_cmp (void *a1, void *a2)
20379 macro_sort_t *s1 = a1;
20380 macro_sort_t *s2 = a2;
20382 return strcmp ((char *) (s1->name), (char *) (s2->name));
20386 dump_macro_table (vat_main_t * vam)
20388 macro_sort_t *sort_me = 0, *sm;
20393 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
20395 vec_add2 (sort_me, sm, 1);
20396 sm->name = (u8 *)(p->key);
20397 sm->value = (u8 *) (p->value[0]);
20401 vec_sort_with_function (sort_me, macro_sort_cmp);
20403 if (vec_len (sort_me))
20404 print (vam->ofp, "%-15s%s", "Name", "Value");
20406 print (vam->ofp, "The macro table is empty...");
20408 for (i = 0; i < vec_len (sort_me); i++)
20409 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
20414 dump_node_table (vat_main_t * vam)
20417 vlib_node_t *node, *next_node;
20419 if (vec_len (vam->graph_nodes) == 0)
20421 print (vam->ofp, "Node table empty, issue get_node_graph...");
20425 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
20427 node = vam->graph_nodes[0][i];
20428 print (vam->ofp, "[%d] %s", i, node->name);
20429 for (j = 0; j < vec_len (node->next_nodes); j++)
20431 if (node->next_nodes[j] != ~0)
20433 next_node = vam->graph_nodes[0][node->next_nodes[j]];
20434 print (vam->ofp, " [%d] %s", j, next_node->name);
20442 value_sort_cmp (void *a1, void *a2)
20444 name_sort_t *n1 = a1;
20445 name_sort_t *n2 = a2;
20447 if (n1->value < n2->value)
20449 if (n1->value > n2->value)
20456 dump_msg_api_table (vat_main_t * vam)
20458 api_main_t *am = vlibapi_get_main ();
20459 name_sort_t *nses = 0, *ns;
20464 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
20466 vec_add2 (nses, ns, 1);
20467 ns->name = (u8 *)(hp->key);
20468 ns->value = (u32) hp->value[0];
20472 vec_sort_with_function (nses, value_sort_cmp);
20474 for (i = 0; i < vec_len (nses); i++)
20475 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
20481 get_msg_id (vat_main_t * vam)
20486 if (unformat (vam->input, "%s", &name_and_crc))
20488 message_index = vl_msg_api_get_msg_index (name_and_crc);
20489 if (message_index == ~0)
20491 print (vam->ofp, " '%s' not found", name_and_crc);
20494 print (vam->ofp, " '%s' has message index %d",
20495 name_and_crc, message_index);
20498 errmsg ("name_and_crc required...");
20503 search_node_table (vat_main_t * vam)
20505 unformat_input_t *line_input = vam->input;
20508 vlib_node_t *node, *next_node;
20511 if (vam->graph_node_index_by_name == 0)
20513 print (vam->ofp, "Node table empty, issue get_node_graph...");
20517 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
20519 if (unformat (line_input, "%s", &node_to_find))
20521 vec_add1 (node_to_find, 0);
20522 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
20525 print (vam->ofp, "%s not found...", node_to_find);
20528 node = vam->graph_nodes[0][p[0]];
20529 print (vam->ofp, "[%d] %s", p[0], node->name);
20530 for (j = 0; j < vec_len (node->next_nodes); j++)
20532 if (node->next_nodes[j] != ~0)
20534 next_node = vam->graph_nodes[0][node->next_nodes[j]];
20535 print (vam->ofp, " [%d] %s", j, next_node->name);
20542 clib_warning ("parse error '%U'", format_unformat_error,
20548 vec_free (node_to_find);
20557 script (vat_main_t * vam)
20559 #if (VPP_API_TEST_BUILTIN==0)
20561 char *save_current_file;
20562 unformat_input_t save_input;
20563 jmp_buf save_jump_buf;
20564 u32 save_line_number;
20566 FILE *new_fp, *save_ifp;
20568 if (unformat (vam->input, "%s", &s))
20570 new_fp = fopen ((char *) s, "r");
20573 errmsg ("Couldn't open script file %s", s);
20580 errmsg ("Missing script name");
20584 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
20585 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
20586 save_ifp = vam->ifp;
20587 save_line_number = vam->input_line_number;
20588 save_current_file = (char *) vam->current_file;
20590 vam->input_line_number = 0;
20592 vam->current_file = s;
20595 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
20596 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
20597 vam->ifp = save_ifp;
20598 vam->input_line_number = save_line_number;
20599 vam->current_file = (u8 *) save_current_file;
20604 clib_warning ("use the exec command...");
20610 echo (vat_main_t * vam)
20612 print (vam->ofp, "%v", vam->input->buffer);
20616 /* List of API message constructors, CLI names map to api_xxx */
20617 #define foreach_vpe_api_msg \
20618 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
20619 _(sw_interface_dump,"") \
20620 _(sw_interface_set_flags, \
20621 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
20622 _(sw_interface_add_del_address, \
20623 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
20624 _(sw_interface_set_rx_mode, \
20625 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
20626 _(sw_interface_set_rx_placement, \
20627 "<intfc> | sw_if_index <id> [queue <id>] [worker <id> | main]") \
20628 _(sw_interface_rx_placement_dump, \
20629 "[<intfc> | sw_if_index <id>]") \
20630 _(sw_interface_set_table, \
20631 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
20632 _(sw_interface_set_mpls_enable, \
20633 "<intfc> | sw_if_index [disable | dis]") \
20634 _(sw_interface_set_vpath, \
20635 "<intfc> | sw_if_index <id> enable | disable") \
20636 _(sw_interface_set_vxlan_bypass, \
20637 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
20638 _(sw_interface_set_geneve_bypass, \
20639 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
20640 _(sw_interface_set_l2_xconnect, \
20641 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
20642 "enable | disable") \
20643 _(sw_interface_set_l2_bridge, \
20644 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
20645 "[shg <split-horizon-group>] [bvi]\n" \
20646 "enable | disable") \
20647 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
20648 _(bridge_domain_add_del, \
20649 "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") \
20650 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
20652 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
20653 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
20654 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
20656 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
20658 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
20660 "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] [persist] [attach]") \
20662 "<vpp-if-name> | sw_if_index <id>") \
20663 _(sw_interface_tap_v2_dump, "") \
20664 _(virtio_pci_create, \
20665 "pci-addr <pci-address> [use_random_mac | hw-addr <mac-addr>] [features <hex-value>] [gso-enabled | csum-offload-enabled]") \
20666 _(virtio_pci_delete, \
20667 "<vpp-if-name> | sw_if_index <id>") \
20668 _(sw_interface_virtio_pci_dump, "") \
20670 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
20671 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \
20674 "<vpp-if-name> | sw_if_index <id>") \
20676 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
20677 _(bond_detach_slave, \
20678 "sw_if_index <n>") \
20679 _(sw_interface_set_bond_weight, "<intfc> | sw_if_index <nn> weight <value>") \
20680 _(sw_interface_bond_dump, "") \
20681 _(sw_interface_slave_dump, \
20682 "<vpp-if-name> | sw_if_index <id>") \
20683 _(ip_table_add_del, \
20684 "table <n> [ipv6] [add | del]\n") \
20685 _(ip_route_add_del, \
20686 "<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
20687 "[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
20688 "[weight <n>] [drop] [local] [classify <n>] [out-label <n>]\n" \
20689 "[multipath] [count <n>] [del]") \
20690 _(ip_mroute_add_del, \
20691 "<src> <grp>/<mask> [table-id <n>]\n" \
20692 "[<intfc> | sw_if_index <id>] [local] [del]") \
20693 _(mpls_table_add_del, \
20694 "table <n> [add | del]\n") \
20695 _(mpls_route_add_del, \
20696 "<label> <eos> via <addr | next-hop-table <n> | via-label <n> |\n" \
20697 "lookup-ip4-table <n> | lookup-in-ip6-table <n> |\n" \
20698 "l2-input-on <intfc> | l2-input-on sw_if_index <id>>\n" \
20699 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>] [weight <n>]\n" \
20700 "[drop] [local] [classify <n>] [out-label <n>] [multipath]\n" \
20701 "[count <n>] [del]") \
20702 _(mpls_ip_bind_unbind, \
20703 "<label> <addr/len>") \
20704 _(mpls_tunnel_add_del, \
20705 "[add | del <intfc | sw_if_index <id>>] via <addr | via-label <n>>\n" \
20706 "[<intfc> | sw_if_index <id> | next-hop-table <id>]\n" \
20707 "[l2-only] [out-label <n>]") \
20708 _(sr_mpls_policy_add, \
20709 "bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
20710 _(sr_mpls_policy_del, \
20712 _(bier_table_add_del, \
20713 "<label> <sub-domain> <set> <bsl> [del]") \
20714 _(bier_route_add_del, \
20715 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
20716 "[<intfc> | sw_if_index <id>]" \
20717 "[weight <n>] [del] [multipath]") \
20718 _(sw_interface_set_unnumbered, \
20719 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
20720 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
20721 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
20722 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
20723 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
20724 "[outer_vlan_id_any][inner_vlan_id_any]") \
20725 _(ip_table_replace_begin, "table <n> [ipv6]") \
20726 _(ip_table_flush, "table <n> [ipv6]") \
20727 _(ip_table_replace_end, "table <n> [ipv6]") \
20728 _(set_ip_flow_hash, \
20729 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
20730 _(sw_interface_ip6_enable_disable, \
20731 "<intfc> | sw_if_index <id> enable | disable") \
20732 _(l2_patch_add_del, \
20733 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
20734 "enable | disable") \
20735 _(sr_localsid_add_del, \
20736 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
20737 "fib-table <num> (end.psp) sw_if_index <num>") \
20738 _(classify_add_del_table, \
20739 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
20740 " [del] [del-chain] mask <mask-value>\n" \
20741 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
20742 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
20743 _(classify_add_del_session, \
20744 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
20745 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
20746 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
20747 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
20748 _(classify_set_interface_ip_table, \
20749 "<intfc> | sw_if_index <nn> table <nn>") \
20750 _(classify_set_interface_l2_tables, \
20751 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20752 " [other-table <nn>]") \
20753 _(get_node_index, "node <node-name") \
20754 _(add_node_next, "node <node-name> next <next-node-name>") \
20755 _(l2tpv3_create_tunnel, \
20756 "client_address <ip6-addr> our_address <ip6-addr>\n" \
20757 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
20758 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
20759 _(l2tpv3_set_tunnel_cookies, \
20760 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
20761 "[new_remote_cookie <nn>]\n") \
20762 _(l2tpv3_interface_enable_disable, \
20763 "<intfc> | sw_if_index <nn> enable | disable") \
20764 _(l2tpv3_set_lookup_key, \
20765 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
20766 _(sw_if_l2tpv3_tunnel_dump, "") \
20767 _(vxlan_offload_rx, \
20768 "hw { <interface name> | hw_if_index <nn>} " \
20769 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
20770 _(vxlan_add_del_tunnel, \
20771 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
20772 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
20773 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
20774 _(geneve_add_del_tunnel, \
20775 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
20776 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
20777 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
20778 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20779 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20780 _(gre_tunnel_add_del, \
20781 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
20782 "[teb | erspan <session-id>] [del]") \
20783 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20784 _(l2_fib_clear_table, "") \
20785 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
20786 _(l2_interface_vlan_tag_rewrite, \
20787 "<intfc> | sw_if_index <nn> \n" \
20788 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
20789 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
20790 _(create_vhost_user_if, \
20791 "socket <filename> [server] [renumber <dev_instance>] " \
20792 "[disable_mrg_rxbuf] [disable_indirect_desc] [gso] " \
20793 "[mac <mac_address>] [packed]") \
20794 _(modify_vhost_user_if, \
20795 "<intfc> | sw_if_index <nn> socket <filename>\n" \
20796 "[server] [renumber <dev_instance>] [gso] [packed]") \
20797 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
20798 _(sw_interface_vhost_user_dump, "") \
20799 _(show_version, "") \
20800 _(show_threads, "") \
20801 _(vxlan_gpe_add_del_tunnel, \
20802 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
20803 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
20804 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
20805 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
20806 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20807 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
20808 _(interface_name_renumber, \
20809 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
20810 _(input_acl_set_interface, \
20811 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20812 " [l2-table <nn>] [del]") \
20813 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
20814 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
20815 _(ip_dump, "ipv4 | ipv6") \
20816 _(ipsec_spd_add_del, "spd_id <n> [del]") \
20817 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
20819 _(ipsec_sad_entry_add_del, "sad_id <n> spi <n> crypto_alg <alg>\n" \
20820 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
20821 " integ_alg <alg> integ_key <hex>") \
20822 _(ipsec_spd_entry_add_del, "spd_id <n> priority <n> action <action>\n" \
20823 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
20824 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
20825 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
20826 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
20827 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
20828 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
20829 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
20830 " [instance <n>]") \
20831 _(ipsec_sa_dump, "[sa_id <n>]") \
20832 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
20833 _(delete_loopback,"sw_if_index <nn>") \
20834 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
20835 _(bd_ip_mac_flush, "bd_id <bridge-domain-id>") \
20836 _(bd_ip_mac_dump, "[bd_id] <bridge-domain-id>") \
20837 _(want_interface_events, "enable|disable") \
20838 _(get_first_msg_id, "client <name>") \
20839 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
20840 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
20841 "fib-id <nn> [ip4][ip6][default]") \
20842 _(get_node_graph, " ") \
20843 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
20844 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
20845 _(ioam_disable, "") \
20846 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
20847 " sw_if_index <sw_if_index> p <priority> " \
20848 "w <weight>] [del]") \
20849 _(one_add_del_locator, "locator-set <locator_name> " \
20850 "iface <intf> | sw_if_index <sw_if_index> " \
20851 "p <priority> w <weight> [del]") \
20852 _(one_add_del_local_eid,"vni <vni> eid " \
20853 "<ipv4|ipv6>/<prefix> | <L2 address> " \
20854 "locator-set <locator_name> [del]" \
20855 "[key-id sha1|sha256 secret-key <secret-key>]")\
20856 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
20857 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
20858 _(one_enable_disable, "enable|disable") \
20859 _(one_map_register_enable_disable, "enable|disable") \
20860 _(one_map_register_fallback_threshold, "<value>") \
20861 _(one_rloc_probe_enable_disable, "enable|disable") \
20862 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
20864 "rloc <locator> p <prio> " \
20865 "w <weight> [rloc <loc> ... ] " \
20866 "action <action> [del-all]") \
20867 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
20869 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
20870 _(one_use_petr, "ip-address> | disable") \
20871 _(one_map_request_mode, "src-dst|dst-only") \
20872 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
20873 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
20874 _(one_locator_set_dump, "[local | remote]") \
20875 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
20876 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
20877 "[local] | [remote]") \
20878 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
20879 _(one_ndp_bd_get, "") \
20880 _(one_ndp_entries_get, "bd <bridge-domain>") \
20881 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
20882 _(one_l2_arp_bd_get, "") \
20883 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
20884 _(one_stats_enable_disable, "enable|disable") \
20885 _(show_one_stats_enable_disable, "") \
20886 _(one_eid_table_vni_dump, "") \
20887 _(one_eid_table_map_dump, "l2|l3") \
20888 _(one_map_resolver_dump, "") \
20889 _(one_map_server_dump, "") \
20890 _(one_adjacencies_get, "vni <vni>") \
20891 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
20892 _(show_one_rloc_probe_state, "") \
20893 _(show_one_map_register_state, "") \
20894 _(show_one_status, "") \
20895 _(one_stats_dump, "") \
20896 _(one_stats_flush, "") \
20897 _(one_get_map_request_itr_rlocs, "") \
20898 _(one_map_register_set_ttl, "<ttl>") \
20899 _(one_set_transport_protocol, "udp|api") \
20900 _(one_get_transport_protocol, "") \
20901 _(one_enable_disable_xtr_mode, "enable|disable") \
20902 _(one_show_xtr_mode, "") \
20903 _(one_enable_disable_pitr_mode, "enable|disable") \
20904 _(one_show_pitr_mode, "") \
20905 _(one_enable_disable_petr_mode, "enable|disable") \
20906 _(one_show_petr_mode, "") \
20907 _(show_one_nsh_mapping, "") \
20908 _(show_one_pitr, "") \
20909 _(show_one_use_petr, "") \
20910 _(show_one_map_request_mode, "") \
20911 _(show_one_map_register_ttl, "") \
20912 _(show_one_map_register_fallback_threshold, "") \
20913 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
20914 " sw_if_index <sw_if_index> p <priority> " \
20915 "w <weight>] [del]") \
20916 _(lisp_add_del_locator, "locator-set <locator_name> " \
20917 "iface <intf> | sw_if_index <sw_if_index> " \
20918 "p <priority> w <weight> [del]") \
20919 _(lisp_add_del_local_eid,"vni <vni> eid " \
20920 "<ipv4|ipv6>/<prefix> | <L2 address> " \
20921 "locator-set <locator_name> [del]" \
20922 "[key-id sha1|sha256 secret-key <secret-key>]") \
20923 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
20924 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
20925 _(lisp_enable_disable, "enable|disable") \
20926 _(lisp_map_register_enable_disable, "enable|disable") \
20927 _(lisp_rloc_probe_enable_disable, "enable|disable") \
20928 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
20930 "rloc <locator> p <prio> " \
20931 "w <weight> [rloc <loc> ... ] " \
20932 "action <action> [del-all]") \
20933 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
20935 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
20936 _(lisp_use_petr, "<ip-address> | disable") \
20937 _(lisp_map_request_mode, "src-dst|dst-only") \
20938 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
20939 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
20940 _(lisp_locator_set_dump, "[local | remote]") \
20941 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
20942 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
20943 "[local] | [remote]") \
20944 _(lisp_eid_table_vni_dump, "") \
20945 _(lisp_eid_table_map_dump, "l2|l3") \
20946 _(lisp_map_resolver_dump, "") \
20947 _(lisp_map_server_dump, "") \
20948 _(lisp_adjacencies_get, "vni <vni>") \
20949 _(gpe_fwd_entry_vnis_get, "") \
20950 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
20951 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
20952 "[table <table-id>]") \
20953 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
20954 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
20955 _(gpe_set_encap_mode, "lisp|vxlan") \
20956 _(gpe_get_encap_mode, "") \
20957 _(lisp_gpe_add_del_iface, "up|down") \
20958 _(lisp_gpe_enable_disable, "enable|disable") \
20959 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
20960 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
20961 _(show_lisp_rloc_probe_state, "") \
20962 _(show_lisp_map_register_state, "") \
20963 _(show_lisp_status, "") \
20964 _(lisp_get_map_request_itr_rlocs, "") \
20965 _(show_lisp_pitr, "") \
20966 _(show_lisp_use_petr, "") \
20967 _(show_lisp_map_request_mode, "") \
20968 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
20969 _(af_packet_delete, "name <host interface name>") \
20970 _(af_packet_dump, "") \
20971 _(policer_add_del, "name <policer name> <params> [del]") \
20972 _(policer_dump, "[name <policer name>]") \
20973 _(policer_classify_set_interface, \
20974 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20975 " [l2-table <nn>] [del]") \
20976 _(policer_classify_dump, "type [ip4|ip6|l2]") \
20977 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
20978 _(mpls_table_dump, "") \
20979 _(mpls_route_dump, "table-id <ID>") \
20980 _(classify_table_ids, "") \
20981 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
20982 _(classify_table_info, "table_id <nn>") \
20983 _(classify_session_dump, "table_id <nn>") \
20984 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
20985 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
20986 "[template_interval <nn>] [udp_checksum]") \
20987 _(ipfix_exporter_dump, "") \
20988 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
20989 _(ipfix_classify_stream_dump, "") \
20990 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
20991 _(ipfix_classify_table_dump, "") \
20992 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
20993 _(sw_interface_span_dump, "[l2]") \
20994 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
20995 _(pg_create_interface, "if_id <nn> [gso-enabled gso-size <size>]") \
20996 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
20997 _(pg_enable_disable, "[stream <id>] disable") \
20998 _(ip_source_and_port_range_check_add_del, \
20999 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
21000 _(ip_source_and_port_range_check_interface_add_del, \
21001 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
21002 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
21003 _(delete_subif,"<intfc> | sw_if_index <nn>") \
21004 _(l2_interface_pbb_tag_rewrite, \
21005 "<intfc> | sw_if_index <nn> \n" \
21006 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
21007 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
21008 _(set_punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
21009 _(flow_classify_set_interface, \
21010 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
21011 _(flow_classify_dump, "type [ip4|ip6]") \
21012 _(ip_table_dump, "") \
21013 _(ip_route_dump, "table-id [ip4|ip6]") \
21014 _(ip_mtable_dump, "") \
21015 _(ip_mroute_dump, "table-id [ip4|ip6]") \
21016 _(feature_enable_disable, "arc_name <arc_name> " \
21017 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
21018 _(feature_gso_enable_disable, "<intfc> | sw_if_index <nn> " \
21019 "[enable | disable] ") \
21020 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
21022 _(sw_interface_add_del_mac_address, "<intfc> | sw_if_index <nn> " \
21023 "mac <mac-address> [del]") \
21024 _(l2_xconnect_dump, "") \
21025 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
21026 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
21027 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
21028 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
21029 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
21030 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
21031 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
21032 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
21033 _(sock_init_shm, "size <nnn>") \
21034 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
21035 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
21036 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
21037 _(session_rules_dump, "") \
21038 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
21039 _(output_acl_set_interface, \
21040 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21041 " [l2-table <nn>] [del]") \
21042 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
21044 /* List of command functions, CLI names map directly to functions */
21045 #define foreach_cli_function \
21046 _(comment, "usage: comment <ignore-rest-of-line>") \
21047 _(dump_interface_table, "usage: dump_interface_table") \
21048 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
21049 _(dump_ipv4_table, "usage: dump_ipv4_table") \
21050 _(dump_ipv6_table, "usage: dump_ipv6_table") \
21051 _(dump_macro_table, "usage: dump_macro_table ") \
21052 _(dump_node_table, "usage: dump_node_table") \
21053 _(dump_msg_api_table, "usage: dump_msg_api_table") \
21054 _(elog_setup, "usage: elog_setup [nevents, default 128K]") \
21055 _(elog_disable, "usage: elog_disable") \
21056 _(elog_enable, "usage: elog_enable") \
21057 _(elog_save, "usage: elog_save <filename>") \
21058 _(get_msg_id, "usage: get_msg_id name_and_crc") \
21059 _(echo, "usage: echo <message>") \
21060 _(exec, "usage: exec <vpe-debug-CLI-command>") \
21061 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
21062 _(help, "usage: help") \
21063 _(q, "usage: quit") \
21064 _(quit, "usage: quit") \
21065 _(search_node_table, "usage: search_node_table <name>...") \
21066 _(set, "usage: set <variable-name> <value>") \
21067 _(script, "usage: script <file-name>") \
21068 _(statseg, "usage: statseg") \
21069 _(unset, "usage: unset <variable-name>")
21072 static void vl_api_##n##_t_handler_uni \
21073 (vl_api_##n##_t * mp) \
21075 vat_main_t * vam = &vat_main; \
21076 if (vam->json_output) { \
21077 vl_api_##n##_t_handler_json(mp); \
21079 vl_api_##n##_t_handler(mp); \
21082 foreach_vpe_api_reply_msg;
21083 #if VPP_API_TEST_BUILTIN == 0
21084 foreach_standalone_reply_msg;
21089 vat_api_hookup (vat_main_t * vam)
21092 vl_msg_api_set_handlers(VL_API_##N, #n, \
21093 vl_api_##n##_t_handler_uni, \
21095 vl_api_##n##_t_endian, \
21096 vl_api_##n##_t_print, \
21097 sizeof(vl_api_##n##_t), 1);
21098 foreach_vpe_api_reply_msg;
21099 #if VPP_API_TEST_BUILTIN == 0
21100 foreach_standalone_reply_msg;
21104 #if (VPP_API_TEST_BUILTIN==0)
21105 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
21107 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
21109 vam->function_by_name = hash_create_string (0, sizeof (uword));
21111 vam->help_by_name = hash_create_string (0, sizeof (uword));
21114 /* API messages we can send */
21115 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
21116 foreach_vpe_api_msg;
21120 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
21121 foreach_vpe_api_msg;
21124 /* CLI functions */
21125 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
21126 foreach_cli_function;
21130 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
21131 foreach_cli_function;
21135 #if VPP_API_TEST_BUILTIN
21136 static clib_error_t *
21137 vat_api_hookup_shim (vlib_main_t * vm)
21139 vat_api_hookup (&vat_main);
21143 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
21147 * fd.io coding-style-patch-verification: ON
21150 * eval: (c-set-style "gnu")