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 <vpp/api/types.h>
22 #include <vppinfra/socket.h>
23 #include <vlibapi/api.h>
24 #include <vlibmemory/api.h>
25 #include <vnet/ip/ip.h>
26 #include <vnet/ip/ip_neighbor.h>
27 #include <vnet/ip/ip_types_api.h>
28 #include <vnet/l2/l2_input.h>
29 #include <vnet/l2tp/l2tp.h>
30 #include <vnet/vxlan/vxlan.h>
31 #include <vnet/geneve/geneve.h>
32 #include <vnet/gre/gre.h>
33 #include <vnet/vxlan-gpe/vxlan_gpe.h>
34 #include <vnet/lisp-gpe/lisp_gpe.h>
36 #include <vpp/api/vpe_msg_enum.h>
37 #include <vnet/l2/l2_classify.h>
38 #include <vnet/l2/l2_vtr.h>
39 #include <vnet/classify/in_out_acl.h>
40 #include <vnet/classify/policer_classify.h>
41 #include <vnet/classify/flow_classify.h>
42 #include <vnet/mpls/mpls.h>
43 #include <vnet/ipsec/ipsec.h>
45 #include <vnet/cop/cop.h>
46 #include <vnet/ip/ip6_hop_by_hop.h>
47 #include <vnet/ip/ip_source_and_port_range_check.h>
48 #include <vnet/policer/xlate.h>
49 #include <vnet/span/span.h>
50 #include <vnet/policer/policer.h>
51 #include <vnet/policer/police.h>
52 #include <vnet/mfib/mfib_types.h>
53 #include <vnet/dhcp/dhcp_proxy.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 #define vl_print(handle, ...)
78 #include <vpp/api/vpe_all_api_h.h>
81 #define __plugin_msg_base 0
82 #include <vlibapi/vat_helper_macros.h>
84 #if VPP_API_TEST_BUILTIN == 0
94 vat_socket_connect (vat_main_t * vam)
97 vam->socket_client_main = &socket_client_main;
98 if ((rv = vl_socket_client_connect ((char *) vam->socket_name,
100 0 /* default socket rx, tx buffer */ )))
102 /* vpp expects the client index in network order */
103 vam->my_client_index = htonl (socket_client_main.client_index);
106 #else /* vpp built-in case, we don't do sockets... */
108 vat_socket_connect (vat_main_t * vam)
114 vl_socket_client_read (int wait)
120 vl_socket_client_write ()
126 vl_socket_client_msg_alloc (int nbytes)
134 vat_time_now (vat_main_t * vam)
136 #if VPP_API_TEST_BUILTIN
137 return vlib_time_now (vam->vlib_main);
139 return clib_time_now (&vam->clib_time);
144 errmsg (char *fmt, ...)
146 vat_main_t *vam = &vat_main;
151 s = va_format (0, fmt, &va);
156 #if VPP_API_TEST_BUILTIN
157 vlib_cli_output (vam->vlib_main, (char *) s);
160 if (vam->ifp != stdin)
161 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
162 vam->input_line_number);
163 fformat (vam->ofp, (char *) s);
171 #if VPP_API_TEST_BUILTIN == 0
173 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
175 vat_main_t *vam = va_arg (*args, vat_main_t *);
176 u32 *result = va_arg (*args, u32 *);
180 if (!unformat (input, "%s", &if_name))
183 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
191 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
196 /* Parse an IP4 address %d.%d.%d.%d. */
198 unformat_ip4_address (unformat_input_t * input, va_list * args)
200 u8 *result = va_arg (*args, u8 *);
203 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
206 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
218 unformat_ethernet_address (unformat_input_t * input, va_list * args)
220 u8 *result = va_arg (*args, u8 *);
223 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
224 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
228 for (i = 0; i < 6; i++)
229 if (a[i] >= (1 << 8))
232 for (i = 0; i < 6; i++)
238 /* Returns ethernet type as an int in host byte order. */
240 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
243 u16 *result = va_arg (*args, u16 *);
247 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
249 if (type >= (1 << 16))
257 /* Parse an IP6 address. */
259 unformat_ip6_address (unformat_input_t * input, va_list * args)
261 ip6_address_t *result = va_arg (*args, ip6_address_t *);
263 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
264 uword c, n_colon, double_colon_index;
266 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
267 double_colon_index = ARRAY_LEN (hex_quads);
268 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
271 if (c >= '0' && c <= '9')
273 else if (c >= 'a' && c <= 'f')
274 hex_digit = c + 10 - 'a';
275 else if (c >= 'A' && c <= 'F')
276 hex_digit = c + 10 - 'A';
277 else if (c == ':' && n_colon < 2)
281 unformat_put_input (input);
285 /* Too many hex quads. */
286 if (n_hex_quads >= ARRAY_LEN (hex_quads))
291 hex_quad = (hex_quad << 4) | hex_digit;
293 /* Hex quad must fit in 16 bits. */
294 if (n_hex_digits >= 4)
301 /* Save position of :: */
304 /* More than one :: ? */
305 if (double_colon_index < ARRAY_LEN (hex_quads))
307 double_colon_index = n_hex_quads;
310 if (n_colon > 0 && n_hex_digits > 0)
312 hex_quads[n_hex_quads++] = hex_quad;
318 if (n_hex_digits > 0)
319 hex_quads[n_hex_quads++] = hex_quad;
324 /* Expand :: to appropriate number of zero hex quads. */
325 if (double_colon_index < ARRAY_LEN (hex_quads))
327 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
329 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
330 hex_quads[n_zero + i] = hex_quads[i];
332 for (i = 0; i < n_zero; i++)
333 hex_quads[double_colon_index + i] = 0;
335 n_hex_quads = ARRAY_LEN (hex_quads);
338 /* Too few hex quads given. */
339 if (n_hex_quads < ARRAY_LEN (hex_quads))
342 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
343 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
350 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
352 u32 *r = va_arg (*args, u32 *);
355 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
356 foreach_ipsec_policy_action
364 format_ipsec_crypto_alg (u8 * s, va_list * args)
366 u32 i = va_arg (*args, u32);
371 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
372 foreach_ipsec_crypto_alg
375 return format (s, "unknown");
377 return format (s, "%s", t);
381 format_ipsec_integ_alg (u8 * s, va_list * args)
383 u32 i = va_arg (*args, u32);
388 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
389 foreach_ipsec_integ_alg
392 return format (s, "unknown");
394 return format (s, "%s", t);
397 #else /* VPP_API_TEST_BUILTIN == 1 */
399 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
401 vat_main_t *vam __clib_unused = va_arg (*args, vat_main_t *);
402 vnet_main_t *vnm = vnet_get_main ();
403 u32 *result = va_arg (*args, u32 *);
405 return unformat (input, "%U", unformat_vnet_sw_interface, vnm, result);
409 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
411 vat_main_t *vam __clib_unused = va_arg (*args, vat_main_t *);
412 vnet_main_t *vnm = vnet_get_main ();
413 u32 *result = va_arg (*args, u32 *);
415 return unformat (input, "%U", unformat_vnet_hw_interface, vnm, result);
418 #endif /* VPP_API_TEST_BUILTIN */
421 unformat_ipsec_api_crypto_alg (unformat_input_t * input, va_list * args)
423 u32 *r = va_arg (*args, u32 *);
426 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_API_CRYPTO_ALG_##f;
427 foreach_ipsec_crypto_alg
435 unformat_ipsec_api_integ_alg (unformat_input_t * input, va_list * args)
437 u32 *r = va_arg (*args, u32 *);
440 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_API_INTEG_ALG_##f;
441 foreach_ipsec_integ_alg
449 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
451 u8 *r = va_arg (*args, u8 *);
453 if (unformat (input, "kbps"))
454 *r = SSE2_QOS_RATE_KBPS;
455 else if (unformat (input, "pps"))
456 *r = SSE2_QOS_RATE_PPS;
463 unformat_policer_round_type (unformat_input_t * input, va_list * args)
465 u8 *r = va_arg (*args, u8 *);
467 if (unformat (input, "closest"))
468 *r = SSE2_QOS_ROUND_TO_CLOSEST;
469 else if (unformat (input, "up"))
470 *r = SSE2_QOS_ROUND_TO_UP;
471 else if (unformat (input, "down"))
472 *r = SSE2_QOS_ROUND_TO_DOWN;
479 unformat_policer_type (unformat_input_t * input, va_list * args)
481 u8 *r = va_arg (*args, u8 *);
483 if (unformat (input, "1r2c"))
484 *r = SSE2_QOS_POLICER_TYPE_1R2C;
485 else if (unformat (input, "1r3c"))
486 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
487 else if (unformat (input, "2r3c-2698"))
488 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
489 else if (unformat (input, "2r3c-4115"))
490 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
491 else if (unformat (input, "2r3c-mef5cf1"))
492 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
499 unformat_dscp (unformat_input_t * input, va_list * va)
501 u8 *r = va_arg (*va, u8 *);
504 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
513 unformat_policer_action_type (unformat_input_t * input, va_list * va)
515 sse2_qos_pol_action_params_st *a
516 = va_arg (*va, sse2_qos_pol_action_params_st *);
518 if (unformat (input, "drop"))
519 a->action_type = SSE2_QOS_ACTION_DROP;
520 else if (unformat (input, "transmit"))
521 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
522 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
523 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
530 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
532 u32 *r = va_arg (*va, u32 *);
535 if (unformat (input, "ip4"))
536 tid = POLICER_CLASSIFY_TABLE_IP4;
537 else if (unformat (input, "ip6"))
538 tid = POLICER_CLASSIFY_TABLE_IP6;
539 else if (unformat (input, "l2"))
540 tid = POLICER_CLASSIFY_TABLE_L2;
549 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
551 u32 *r = va_arg (*va, u32 *);
554 if (unformat (input, "ip4"))
555 tid = FLOW_CLASSIFY_TABLE_IP4;
556 else if (unformat (input, "ip6"))
557 tid = FLOW_CLASSIFY_TABLE_IP6;
565 #if (VPP_API_TEST_BUILTIN==0)
567 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
568 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
569 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
570 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
573 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
575 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
576 mfib_itf_attribute_t attr;
579 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
581 if (unformat (input, mfib_itf_flag_long_names[attr]))
582 *iflags |= (1 << attr);
584 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
586 if (unformat (input, mfib_itf_flag_names[attr]))
587 *iflags |= (1 << attr);
590 return (old == *iflags ? 0 : 1);
594 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
596 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
597 mfib_entry_attribute_t attr;
600 FOR_EACH_MFIB_ATTRIBUTE (attr)
602 if (unformat (input, mfib_flag_long_names[attr]))
603 *eflags |= (1 << attr);
605 FOR_EACH_MFIB_ATTRIBUTE (attr)
607 if (unformat (input, mfib_flag_names[attr]))
608 *eflags |= (1 << attr);
611 return (old == *eflags ? 0 : 1);
615 format_ip4_address (u8 * s, va_list * args)
617 u8 *a = va_arg (*args, u8 *);
618 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
622 format_ip6_address (u8 * s, va_list * args)
624 ip6_address_t *a = va_arg (*args, ip6_address_t *);
625 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
627 i_max_n_zero = ARRAY_LEN (a->as_u16);
629 i_first_zero = i_max_n_zero;
631 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
633 u32 is_zero = a->as_u16[i] == 0;
634 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
640 if ((!is_zero && n_zeros > max_n_zeros)
641 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
643 i_max_n_zero = i_first_zero;
644 max_n_zeros = n_zeros;
645 i_first_zero = ARRAY_LEN (a->as_u16);
650 last_double_colon = 0;
651 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
653 if (i == i_max_n_zero && max_n_zeros > 1)
655 s = format (s, "::");
656 i += max_n_zeros - 1;
657 last_double_colon = 1;
661 s = format (s, "%s%x",
662 (last_double_colon || i == 0) ? "" : ":",
663 clib_net_to_host_u16 (a->as_u16[i]));
664 last_double_colon = 0;
671 /* Format an IP46 address. */
673 format_ip46_address (u8 * s, va_list * args)
675 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
676 ip46_type_t type = va_arg (*args, ip46_type_t);
682 is_ip4 = ip46_address_is_ip4 (ip46);
693 format (s, "%U", format_ip4_address, &ip46->ip4) :
694 format (s, "%U", format_ip6_address, &ip46->ip6);
698 format_ethernet_address (u8 * s, va_list * args)
700 u8 *a = va_arg (*args, u8 *);
702 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
703 a[0], a[1], a[2], a[3], a[4], a[5]);
708 increment_v4_address (ip4_address_t * a)
712 v = ntohl (a->as_u32) + 1;
713 a->as_u32 = ntohl (v);
717 increment_vl_v4_address (vl_api_ip4_address_t * a)
725 clib_memcpy (a, &v, sizeof (v));
729 increment_vl_address (vl_api_address_t * a)
731 if (ADDRESS_IP4 == a->af)
732 increment_vl_v4_address (&a->un.ip4);
736 increment_v6_address (ip6_address_t * a)
740 v0 = clib_net_to_host_u64 (a->as_u64[0]);
741 v1 = clib_net_to_host_u64 (a->as_u64[1]);
746 a->as_u64[0] = clib_net_to_host_u64 (v0);
747 a->as_u64[1] = clib_net_to_host_u64 (v1);
751 increment_mac_address (u8 * mac)
753 u64 tmp = *((u64 *) mac);
754 tmp = clib_net_to_host_u64 (tmp);
755 tmp += 1 << 16; /* skip unused (least significant) octets */
756 tmp = clib_host_to_net_u64 (tmp);
758 clib_memcpy (mac, &tmp, 6);
761 static void vl_api_create_loopback_reply_t_handler
762 (vl_api_create_loopback_reply_t * mp)
764 vat_main_t *vam = &vat_main;
765 i32 retval = ntohl (mp->retval);
767 vam->retval = retval;
768 vam->regenerate_interface_table = 1;
769 vam->sw_if_index = ntohl (mp->sw_if_index);
770 vam->result_ready = 1;
773 static void vl_api_create_loopback_reply_t_handler_json
774 (vl_api_create_loopback_reply_t * mp)
776 vat_main_t *vam = &vat_main;
777 vat_json_node_t node;
779 vat_json_init_object (&node);
780 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
781 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
783 vat_json_print (vam->ofp, &node);
784 vat_json_free (&node);
785 vam->retval = ntohl (mp->retval);
786 vam->result_ready = 1;
789 static void vl_api_create_loopback_instance_reply_t_handler
790 (vl_api_create_loopback_instance_reply_t * mp)
792 vat_main_t *vam = &vat_main;
793 i32 retval = ntohl (mp->retval);
795 vam->retval = retval;
796 vam->regenerate_interface_table = 1;
797 vam->sw_if_index = ntohl (mp->sw_if_index);
798 vam->result_ready = 1;
801 static void vl_api_create_loopback_instance_reply_t_handler_json
802 (vl_api_create_loopback_instance_reply_t * mp)
804 vat_main_t *vam = &vat_main;
805 vat_json_node_t node;
807 vat_json_init_object (&node);
808 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
809 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
811 vat_json_print (vam->ofp, &node);
812 vat_json_free (&node);
813 vam->retval = ntohl (mp->retval);
814 vam->result_ready = 1;
817 static void vl_api_af_packet_create_reply_t_handler
818 (vl_api_af_packet_create_reply_t * mp)
820 vat_main_t *vam = &vat_main;
821 i32 retval = ntohl (mp->retval);
823 vam->retval = retval;
824 vam->regenerate_interface_table = 1;
825 vam->sw_if_index = ntohl (mp->sw_if_index);
826 vam->result_ready = 1;
829 static void vl_api_af_packet_create_reply_t_handler_json
830 (vl_api_af_packet_create_reply_t * mp)
832 vat_main_t *vam = &vat_main;
833 vat_json_node_t node;
835 vat_json_init_object (&node);
836 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
837 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
839 vat_json_print (vam->ofp, &node);
840 vat_json_free (&node);
842 vam->retval = ntohl (mp->retval);
843 vam->result_ready = 1;
846 static void vl_api_create_vlan_subif_reply_t_handler
847 (vl_api_create_vlan_subif_reply_t * mp)
849 vat_main_t *vam = &vat_main;
850 i32 retval = ntohl (mp->retval);
852 vam->retval = retval;
853 vam->regenerate_interface_table = 1;
854 vam->sw_if_index = ntohl (mp->sw_if_index);
855 vam->result_ready = 1;
858 static void vl_api_create_vlan_subif_reply_t_handler_json
859 (vl_api_create_vlan_subif_reply_t * mp)
861 vat_main_t *vam = &vat_main;
862 vat_json_node_t node;
864 vat_json_init_object (&node);
865 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
866 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
868 vat_json_print (vam->ofp, &node);
869 vat_json_free (&node);
871 vam->retval = ntohl (mp->retval);
872 vam->result_ready = 1;
875 static void vl_api_create_subif_reply_t_handler
876 (vl_api_create_subif_reply_t * mp)
878 vat_main_t *vam = &vat_main;
879 i32 retval = ntohl (mp->retval);
881 vam->retval = retval;
882 vam->regenerate_interface_table = 1;
883 vam->sw_if_index = ntohl (mp->sw_if_index);
884 vam->result_ready = 1;
887 static void vl_api_create_subif_reply_t_handler_json
888 (vl_api_create_subif_reply_t * mp)
890 vat_main_t *vam = &vat_main;
891 vat_json_node_t node;
893 vat_json_init_object (&node);
894 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
895 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
897 vat_json_print (vam->ofp, &node);
898 vat_json_free (&node);
900 vam->retval = ntohl (mp->retval);
901 vam->result_ready = 1;
904 static void vl_api_interface_name_renumber_reply_t_handler
905 (vl_api_interface_name_renumber_reply_t * mp)
907 vat_main_t *vam = &vat_main;
908 i32 retval = ntohl (mp->retval);
910 vam->retval = retval;
911 vam->regenerate_interface_table = 1;
912 vam->result_ready = 1;
915 static void vl_api_interface_name_renumber_reply_t_handler_json
916 (vl_api_interface_name_renumber_reply_t * mp)
918 vat_main_t *vam = &vat_main;
919 vat_json_node_t node;
921 vat_json_init_object (&node);
922 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
924 vat_json_print (vam->ofp, &node);
925 vat_json_free (&node);
927 vam->retval = ntohl (mp->retval);
928 vam->result_ready = 1;
932 * Special-case: build the interface table, maintain
933 * the next loopback sw_if_index vbl.
935 static void vl_api_sw_interface_details_t_handler
936 (vl_api_sw_interface_details_t * mp)
938 vat_main_t *vam = &vat_main;
939 u8 *s = format (0, "%s%c", mp->interface_name, 0);
941 hash_set_mem (vam->sw_if_index_by_interface_name, s,
942 ntohl (mp->sw_if_index));
944 /* In sub interface case, fill the sub interface table entry */
945 if (mp->sw_if_index != mp->sup_sw_if_index)
947 sw_interface_subif_t *sub = NULL;
949 vec_add2 (vam->sw_if_subif_table, sub, 1);
951 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
952 strncpy ((char *) sub->interface_name, (char *) s,
953 vec_len (sub->interface_name));
954 sub->sw_if_index = ntohl (mp->sw_if_index);
955 sub->sub_id = ntohl (mp->sub_id);
957 sub->sub_dot1ad = mp->sub_dot1ad;
958 sub->sub_number_of_tags = mp->sub_number_of_tags;
959 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
960 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
961 sub->sub_exact_match = mp->sub_exact_match;
962 sub->sub_default = mp->sub_default;
963 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
964 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
966 /* vlan tag rewrite */
967 sub->vtr_op = ntohl (mp->vtr_op);
968 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
969 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
970 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
974 static void vl_api_sw_interface_details_t_handler_json
975 (vl_api_sw_interface_details_t * mp)
977 vat_main_t *vam = &vat_main;
978 vat_json_node_t *node = NULL;
980 if (VAT_JSON_ARRAY != vam->json_tree.type)
982 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
983 vat_json_init_array (&vam->json_tree);
985 node = vat_json_array_add (&vam->json_tree);
987 vat_json_init_object (node);
988 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
989 vat_json_object_add_uint (node, "sup_sw_if_index",
990 ntohl (mp->sup_sw_if_index));
991 vat_json_object_add_uint (node, "l2_address_length",
992 ntohl (mp->l2_address_length));
993 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
994 sizeof (mp->l2_address));
995 vat_json_object_add_string_copy (node, "interface_name",
997 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
998 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
999 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
1000 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
1001 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
1002 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
1003 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
1004 vat_json_object_add_uint (node, "sub_number_of_tags",
1005 mp->sub_number_of_tags);
1006 vat_json_object_add_uint (node, "sub_outer_vlan_id",
1007 ntohs (mp->sub_outer_vlan_id));
1008 vat_json_object_add_uint (node, "sub_inner_vlan_id",
1009 ntohs (mp->sub_inner_vlan_id));
1010 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
1011 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
1012 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
1013 mp->sub_outer_vlan_id_any);
1014 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
1015 mp->sub_inner_vlan_id_any);
1016 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
1017 vat_json_object_add_uint (node, "vtr_push_dot1q",
1018 ntohl (mp->vtr_push_dot1q));
1019 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
1020 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
1023 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
1025 format_ethernet_address,
1027 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
1029 format_ethernet_address,
1031 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
1032 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
1036 #if VPP_API_TEST_BUILTIN == 0
1037 static void vl_api_sw_interface_event_t_handler
1038 (vl_api_sw_interface_event_t * mp)
1040 vat_main_t *vam = &vat_main;
1041 if (vam->interface_event_display)
1042 errmsg ("interface flags: sw_if_index %d %s %s",
1043 ntohl (mp->sw_if_index),
1044 mp->admin_up_down ? "admin-up" : "admin-down",
1045 mp->link_up_down ? "link-up" : "link-down");
1049 __clib_unused static void
1050 vl_api_sw_interface_event_t_handler_json (vl_api_sw_interface_event_t * mp)
1052 /* JSON output not supported */
1056 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
1058 vat_main_t *vam = &vat_main;
1059 i32 retval = ntohl (mp->retval);
1061 vam->retval = retval;
1062 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1063 vam->result_ready = 1;
1067 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1069 vat_main_t *vam = &vat_main;
1070 vat_json_node_t node;
1071 api_main_t *am = &api_main;
1075 vat_json_init_object (&node);
1076 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1077 vat_json_object_add_uint (&node, "reply_in_shmem",
1078 ntohl (mp->reply_in_shmem));
1079 /* Toss the shared-memory original... */
1080 pthread_mutex_lock (&am->vlib_rp->mutex);
1081 oldheap = svm_push_data_heap (am->vlib_rp);
1083 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1086 svm_pop_heap (oldheap);
1087 pthread_mutex_unlock (&am->vlib_rp->mutex);
1089 vat_json_print (vam->ofp, &node);
1090 vat_json_free (&node);
1092 vam->retval = ntohl (mp->retval);
1093 vam->result_ready = 1;
1097 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1099 vat_main_t *vam = &vat_main;
1100 i32 retval = ntohl (mp->retval);
1101 u32 length = vl_api_string_len (&mp->reply);
1103 vec_reset_length (vam->cmd_reply);
1105 vam->retval = retval;
1108 vec_validate (vam->cmd_reply, length);
1109 clib_memcpy ((char *) (vam->cmd_reply),
1110 vl_api_from_api_string (&mp->reply), length);
1111 vam->cmd_reply[length] = 0;
1113 vam->result_ready = 1;
1117 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1119 vat_main_t *vam = &vat_main;
1120 vat_json_node_t node;
1122 vec_reset_length (vam->cmd_reply);
1124 vat_json_init_object (&node);
1125 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1126 vat_json_object_add_string_copy (&node, "reply",
1127 vl_api_from_api_string (&mp->reply));
1129 vat_json_print (vam->ofp, &node);
1130 vat_json_free (&node);
1132 vam->retval = ntohl (mp->retval);
1133 vam->result_ready = 1;
1136 static void vl_api_classify_add_del_table_reply_t_handler
1137 (vl_api_classify_add_del_table_reply_t * mp)
1139 vat_main_t *vam = &vat_main;
1140 i32 retval = ntohl (mp->retval);
1141 if (vam->async_mode)
1143 vam->async_errors += (retval < 0);
1147 vam->retval = retval;
1149 ((mp->new_table_index != 0xFFFFFFFF) ||
1150 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1151 (mp->match_n_vectors != 0xFFFFFFFF)))
1153 * Note: this is just barely thread-safe, depends on
1154 * the main thread spinning waiting for an answer...
1156 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1157 ntohl (mp->new_table_index),
1158 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1159 vam->result_ready = 1;
1163 static void vl_api_classify_add_del_table_reply_t_handler_json
1164 (vl_api_classify_add_del_table_reply_t * mp)
1166 vat_main_t *vam = &vat_main;
1167 vat_json_node_t node;
1169 vat_json_init_object (&node);
1170 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1171 vat_json_object_add_uint (&node, "new_table_index",
1172 ntohl (mp->new_table_index));
1173 vat_json_object_add_uint (&node, "skip_n_vectors",
1174 ntohl (mp->skip_n_vectors));
1175 vat_json_object_add_uint (&node, "match_n_vectors",
1176 ntohl (mp->match_n_vectors));
1178 vat_json_print (vam->ofp, &node);
1179 vat_json_free (&node);
1181 vam->retval = ntohl (mp->retval);
1182 vam->result_ready = 1;
1185 static void vl_api_get_node_index_reply_t_handler
1186 (vl_api_get_node_index_reply_t * mp)
1188 vat_main_t *vam = &vat_main;
1189 i32 retval = ntohl (mp->retval);
1190 if (vam->async_mode)
1192 vam->async_errors += (retval < 0);
1196 vam->retval = retval;
1198 errmsg ("node index %d", ntohl (mp->node_index));
1199 vam->result_ready = 1;
1203 static void vl_api_get_node_index_reply_t_handler_json
1204 (vl_api_get_node_index_reply_t * mp)
1206 vat_main_t *vam = &vat_main;
1207 vat_json_node_t node;
1209 vat_json_init_object (&node);
1210 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1211 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1213 vat_json_print (vam->ofp, &node);
1214 vat_json_free (&node);
1216 vam->retval = ntohl (mp->retval);
1217 vam->result_ready = 1;
1220 static void vl_api_get_next_index_reply_t_handler
1221 (vl_api_get_next_index_reply_t * mp)
1223 vat_main_t *vam = &vat_main;
1224 i32 retval = ntohl (mp->retval);
1225 if (vam->async_mode)
1227 vam->async_errors += (retval < 0);
1231 vam->retval = retval;
1233 errmsg ("next node index %d", ntohl (mp->next_index));
1234 vam->result_ready = 1;
1238 static void vl_api_get_next_index_reply_t_handler_json
1239 (vl_api_get_next_index_reply_t * mp)
1241 vat_main_t *vam = &vat_main;
1242 vat_json_node_t node;
1244 vat_json_init_object (&node);
1245 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1246 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1248 vat_json_print (vam->ofp, &node);
1249 vat_json_free (&node);
1251 vam->retval = ntohl (mp->retval);
1252 vam->result_ready = 1;
1255 static void vl_api_add_node_next_reply_t_handler
1256 (vl_api_add_node_next_reply_t * mp)
1258 vat_main_t *vam = &vat_main;
1259 i32 retval = ntohl (mp->retval);
1260 if (vam->async_mode)
1262 vam->async_errors += (retval < 0);
1266 vam->retval = retval;
1268 errmsg ("next index %d", ntohl (mp->next_index));
1269 vam->result_ready = 1;
1273 static void vl_api_add_node_next_reply_t_handler_json
1274 (vl_api_add_node_next_reply_t * mp)
1276 vat_main_t *vam = &vat_main;
1277 vat_json_node_t node;
1279 vat_json_init_object (&node);
1280 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1281 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1283 vat_json_print (vam->ofp, &node);
1284 vat_json_free (&node);
1286 vam->retval = ntohl (mp->retval);
1287 vam->result_ready = 1;
1290 static void vl_api_show_version_reply_t_handler
1291 (vl_api_show_version_reply_t * mp)
1293 vat_main_t *vam = &vat_main;
1294 i32 retval = ntohl (mp->retval);
1299 char *p = (char *) &mp->program;
1301 s = vl_api_from_api_string_c ((vl_api_string_t *) p);
1302 errmsg (" program: %s\n", s);
1306 vl_api_string_len ((vl_api_string_t *) p) + sizeof (vl_api_string_t);
1307 s = vl_api_from_api_string_c ((vl_api_string_t *) p);
1308 errmsg (" version: %s\n", s);
1312 vl_api_string_len ((vl_api_string_t *) p) + sizeof (vl_api_string_t);
1313 s = vl_api_from_api_string_c ((vl_api_string_t *) p);
1314 errmsg (" build date: %s\n", s);
1318 vl_api_string_len ((vl_api_string_t *) p) + sizeof (vl_api_string_t);
1319 s = vl_api_from_api_string_c ((vl_api_string_t *) p);
1320 errmsg ("build directory: %s\n", s);
1323 vam->retval = retval;
1324 vam->result_ready = 1;
1327 static void vl_api_show_version_reply_t_handler_json
1328 (vl_api_show_version_reply_t * mp)
1330 vat_main_t *vam = &vat_main;
1331 vat_json_node_t node;
1333 vat_json_init_object (&node);
1334 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1335 char *p = (char *) &mp->program;
1336 vat_json_object_add_string_copy (&node, "program",
1337 vl_api_from_api_string ((vl_api_string_t *)
1339 p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (u32);
1340 vat_json_object_add_string_copy (&node, "version",
1341 vl_api_from_api_string ((vl_api_string_t *)
1343 p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (u32);
1344 vat_json_object_add_string_copy (&node, "build_date",
1345 vl_api_from_api_string ((vl_api_string_t *)
1347 p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (u32);
1348 vat_json_object_add_string_copy (&node, "build_directory",
1349 vl_api_from_api_string ((vl_api_string_t *)
1352 vat_json_print (vam->ofp, &node);
1353 vat_json_free (&node);
1355 vam->retval = ntohl (mp->retval);
1356 vam->result_ready = 1;
1359 static void vl_api_show_threads_reply_t_handler
1360 (vl_api_show_threads_reply_t * mp)
1362 vat_main_t *vam = &vat_main;
1363 i32 retval = ntohl (mp->retval);
1367 count = ntohl (mp->count);
1369 for (i = 0; i < count; i++)
1371 "\n%-2d %-11s %-11s %-5d %-6d %-4d %-6d",
1372 ntohl (mp->thread_data[i].id), mp->thread_data[i].name,
1373 mp->thread_data[i].type, ntohl (mp->thread_data[i].pid),
1374 ntohl (mp->thread_data[i].cpu_id), ntohl (mp->thread_data[i].core),
1375 ntohl (mp->thread_data[i].cpu_socket));
1377 vam->retval = retval;
1378 vam->result_ready = 1;
1381 static void vl_api_show_threads_reply_t_handler_json
1382 (vl_api_show_threads_reply_t * mp)
1384 vat_main_t *vam = &vat_main;
1385 vat_json_node_t node;
1386 vl_api_thread_data_t *td;
1387 i32 retval = ntohl (mp->retval);
1391 count = ntohl (mp->count);
1393 vat_json_init_object (&node);
1394 vat_json_object_add_int (&node, "retval", retval);
1395 vat_json_object_add_uint (&node, "count", count);
1397 for (i = 0; i < count; i++)
1399 td = &mp->thread_data[i];
1400 vat_json_object_add_uint (&node, "id", ntohl (td->id));
1401 vat_json_object_add_string_copy (&node, "name", td->name);
1402 vat_json_object_add_string_copy (&node, "type", td->type);
1403 vat_json_object_add_uint (&node, "pid", ntohl (td->pid));
1404 vat_json_object_add_int (&node, "cpu_id", ntohl (td->cpu_id));
1405 vat_json_object_add_int (&node, "core", ntohl (td->id));
1406 vat_json_object_add_int (&node, "cpu_socket", ntohl (td->cpu_socket));
1409 vat_json_print (vam->ofp, &node);
1410 vat_json_free (&node);
1412 vam->retval = retval;
1413 vam->result_ready = 1;
1417 api_show_threads (vat_main_t * vam)
1419 vl_api_show_threads_t *mp;
1423 "\n%-2s %-11s %-11s %-5s %-6s %-4s %-6s",
1424 "ID", "Name", "Type", "LWP", "cpu_id", "Core", "Socket");
1426 M (SHOW_THREADS, mp);
1434 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1436 u32 sw_if_index = ntohl (mp->sw_if_index);
1437 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1438 mp->mac_ip ? "mac/ip binding" : "address resolution",
1439 ntohl (mp->pid), format_ip4_address, mp->ip,
1440 format_vl_api_mac_address, &mp->mac, sw_if_index);
1444 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1446 /* JSON output not supported */
1450 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1452 u32 sw_if_index = ntohl (mp->sw_if_index);
1453 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1454 mp->mac_ip ? "mac/ip binding" : "address resolution",
1455 ntohl (mp->pid), format_vl_api_ip6_address, mp->ip,
1456 format_vl_api_mac_address, mp->mac, sw_if_index);
1460 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1462 /* JSON output not supported */
1466 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1468 u32 n_macs = ntohl (mp->n_macs);
1469 errmsg ("L2MAC event received with pid %d cl-idx %d for %d macs: \n",
1470 ntohl (mp->pid), mp->client_index, n_macs);
1472 for (i = 0; i < n_macs; i++)
1474 vl_api_mac_entry_t *mac = &mp->mac[i];
1475 errmsg (" [%d] sw_if_index %d mac_addr %U action %d \n",
1476 i + 1, ntohl (mac->sw_if_index),
1477 format_ethernet_address, mac->mac_addr, mac->action);
1484 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1486 /* JSON output not supported */
1489 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1490 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1493 * Special-case: build the bridge domain table, maintain
1494 * the next bd id vbl.
1496 static void vl_api_bridge_domain_details_t_handler
1497 (vl_api_bridge_domain_details_t * mp)
1499 vat_main_t *vam = &vat_main;
1500 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1503 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-6s %-3s",
1504 " ID", "LRN", "FWD", "FLD", "BVI", "UU-FWD", "#IF");
1506 print (vam->ofp, "%3d %3d %3d %3d %3d %6d %3d",
1507 ntohl (mp->bd_id), mp->learn, mp->forward,
1508 mp->flood, ntohl (mp->bvi_sw_if_index),
1509 ntohl (mp->uu_fwd_sw_if_index), n_sw_ifs);
1513 vl_api_bridge_domain_sw_if_t *sw_ifs;
1514 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1517 sw_ifs = mp->sw_if_details;
1518 for (i = 0; i < n_sw_ifs; i++)
1524 sw_if_index = ntohl (sw_ifs->sw_if_index);
1527 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1529 if ((u32) p->value[0] == sw_if_index)
1531 sw_if_name = (u8 *)(p->key);
1536 print (vam->ofp, "%7d %3d %s", sw_if_index,
1537 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1538 "sw_if_index not found!");
1545 static void vl_api_bridge_domain_details_t_handler_json
1546 (vl_api_bridge_domain_details_t * mp)
1548 vat_main_t *vam = &vat_main;
1549 vat_json_node_t *node, *array = NULL;
1550 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1552 if (VAT_JSON_ARRAY != vam->json_tree.type)
1554 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1555 vat_json_init_array (&vam->json_tree);
1557 node = vat_json_array_add (&vam->json_tree);
1559 vat_json_init_object (node);
1560 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1561 vat_json_object_add_uint (node, "flood", mp->flood);
1562 vat_json_object_add_uint (node, "forward", mp->forward);
1563 vat_json_object_add_uint (node, "learn", mp->learn);
1564 vat_json_object_add_uint (node, "bvi_sw_if_index",
1565 ntohl (mp->bvi_sw_if_index));
1566 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1567 array = vat_json_object_add (node, "sw_if");
1568 vat_json_init_array (array);
1574 vl_api_bridge_domain_sw_if_t *sw_ifs;
1577 sw_ifs = mp->sw_if_details;
1578 for (i = 0; i < n_sw_ifs; i++)
1580 node = vat_json_array_add (array);
1581 vat_json_init_object (node);
1582 vat_json_object_add_uint (node, "sw_if_index",
1583 ntohl (sw_ifs->sw_if_index));
1584 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1590 static void vl_api_control_ping_reply_t_handler
1591 (vl_api_control_ping_reply_t * mp)
1593 vat_main_t *vam = &vat_main;
1594 i32 retval = ntohl (mp->retval);
1595 if (vam->async_mode)
1597 vam->async_errors += (retval < 0);
1601 vam->retval = retval;
1602 vam->result_ready = 1;
1604 if (vam->socket_client_main)
1605 vam->socket_client_main->control_pings_outstanding--;
1608 static void vl_api_control_ping_reply_t_handler_json
1609 (vl_api_control_ping_reply_t * mp)
1611 vat_main_t *vam = &vat_main;
1612 i32 retval = ntohl (mp->retval);
1614 if (VAT_JSON_NONE != vam->json_tree.type)
1616 vat_json_print (vam->ofp, &vam->json_tree);
1617 vat_json_free (&vam->json_tree);
1618 vam->json_tree.type = VAT_JSON_NONE;
1623 vat_json_init_array (&vam->json_tree);
1624 vat_json_print (vam->ofp, &vam->json_tree);
1625 vam->json_tree.type = VAT_JSON_NONE;
1628 vam->retval = retval;
1629 vam->result_ready = 1;
1633 vl_api_bridge_domain_set_mac_age_reply_t_handler
1634 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1636 vat_main_t *vam = &vat_main;
1637 i32 retval = ntohl (mp->retval);
1638 if (vam->async_mode)
1640 vam->async_errors += (retval < 0);
1644 vam->retval = retval;
1645 vam->result_ready = 1;
1649 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1650 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1652 vat_main_t *vam = &vat_main;
1653 vat_json_node_t node;
1655 vat_json_init_object (&node);
1656 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1658 vat_json_print (vam->ofp, &node);
1659 vat_json_free (&node);
1661 vam->retval = ntohl (mp->retval);
1662 vam->result_ready = 1;
1666 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1668 vat_main_t *vam = &vat_main;
1669 i32 retval = ntohl (mp->retval);
1670 if (vam->async_mode)
1672 vam->async_errors += (retval < 0);
1676 vam->retval = retval;
1677 vam->result_ready = 1;
1681 static void vl_api_l2_flags_reply_t_handler_json
1682 (vl_api_l2_flags_reply_t * mp)
1684 vat_main_t *vam = &vat_main;
1685 vat_json_node_t node;
1687 vat_json_init_object (&node);
1688 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1689 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1690 ntohl (mp->resulting_feature_bitmap));
1692 vat_json_print (vam->ofp, &node);
1693 vat_json_free (&node);
1695 vam->retval = ntohl (mp->retval);
1696 vam->result_ready = 1;
1699 static void vl_api_bridge_flags_reply_t_handler
1700 (vl_api_bridge_flags_reply_t * mp)
1702 vat_main_t *vam = &vat_main;
1703 i32 retval = ntohl (mp->retval);
1704 if (vam->async_mode)
1706 vam->async_errors += (retval < 0);
1710 vam->retval = retval;
1711 vam->result_ready = 1;
1715 static void vl_api_bridge_flags_reply_t_handler_json
1716 (vl_api_bridge_flags_reply_t * mp)
1718 vat_main_t *vam = &vat_main;
1719 vat_json_node_t node;
1721 vat_json_init_object (&node);
1722 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1723 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1724 ntohl (mp->resulting_feature_bitmap));
1726 vat_json_print (vam->ofp, &node);
1727 vat_json_free (&node);
1729 vam->retval = ntohl (mp->retval);
1730 vam->result_ready = 1;
1734 vl_api_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_reply_t * mp)
1736 vat_main_t *vam = &vat_main;
1737 i32 retval = ntohl (mp->retval);
1738 if (vam->async_mode)
1740 vam->async_errors += (retval < 0);
1744 vam->retval = retval;
1745 vam->sw_if_index = ntohl (mp->sw_if_index);
1746 vam->result_ready = 1;
1751 static void vl_api_tap_create_v2_reply_t_handler_json
1752 (vl_api_tap_create_v2_reply_t * mp)
1754 vat_main_t *vam = &vat_main;
1755 vat_json_node_t node;
1757 vat_json_init_object (&node);
1758 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1759 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1761 vat_json_print (vam->ofp, &node);
1762 vat_json_free (&node);
1764 vam->retval = ntohl (mp->retval);
1765 vam->result_ready = 1;
1770 vl_api_tap_delete_v2_reply_t_handler (vl_api_tap_delete_v2_reply_t * mp)
1772 vat_main_t *vam = &vat_main;
1773 i32 retval = ntohl (mp->retval);
1774 if (vam->async_mode)
1776 vam->async_errors += (retval < 0);
1780 vam->retval = retval;
1781 vam->result_ready = 1;
1785 static void vl_api_tap_delete_v2_reply_t_handler_json
1786 (vl_api_tap_delete_v2_reply_t * mp)
1788 vat_main_t *vam = &vat_main;
1789 vat_json_node_t node;
1791 vat_json_init_object (&node);
1792 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1794 vat_json_print (vam->ofp, &node);
1795 vat_json_free (&node);
1797 vam->retval = ntohl (mp->retval);
1798 vam->result_ready = 1;
1802 vl_api_virtio_pci_create_reply_t_handler (vl_api_virtio_pci_create_reply_t *
1805 vat_main_t *vam = &vat_main;
1806 i32 retval = ntohl (mp->retval);
1807 if (vam->async_mode)
1809 vam->async_errors += (retval < 0);
1813 vam->retval = retval;
1814 vam->sw_if_index = ntohl (mp->sw_if_index);
1815 vam->result_ready = 1;
1819 static void vl_api_virtio_pci_create_reply_t_handler_json
1820 (vl_api_virtio_pci_create_reply_t * mp)
1822 vat_main_t *vam = &vat_main;
1823 vat_json_node_t node;
1825 vat_json_init_object (&node);
1826 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1827 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1829 vat_json_print (vam->ofp, &node);
1830 vat_json_free (&node);
1832 vam->retval = ntohl (mp->retval);
1833 vam->result_ready = 1;
1838 vl_api_virtio_pci_delete_reply_t_handler (vl_api_virtio_pci_delete_reply_t *
1841 vat_main_t *vam = &vat_main;
1842 i32 retval = ntohl (mp->retval);
1843 if (vam->async_mode)
1845 vam->async_errors += (retval < 0);
1849 vam->retval = retval;
1850 vam->result_ready = 1;
1854 static void vl_api_virtio_pci_delete_reply_t_handler_json
1855 (vl_api_virtio_pci_delete_reply_t * mp)
1857 vat_main_t *vam = &vat_main;
1858 vat_json_node_t node;
1860 vat_json_init_object (&node);
1861 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1863 vat_json_print (vam->ofp, &node);
1864 vat_json_free (&node);
1866 vam->retval = ntohl (mp->retval);
1867 vam->result_ready = 1;
1871 vl_api_bond_create_reply_t_handler (vl_api_bond_create_reply_t * mp)
1873 vat_main_t *vam = &vat_main;
1874 i32 retval = ntohl (mp->retval);
1876 if (vam->async_mode)
1878 vam->async_errors += (retval < 0);
1882 vam->retval = retval;
1883 vam->sw_if_index = ntohl (mp->sw_if_index);
1884 vam->result_ready = 1;
1888 static void vl_api_bond_create_reply_t_handler_json
1889 (vl_api_bond_create_reply_t * mp)
1891 vat_main_t *vam = &vat_main;
1892 vat_json_node_t node;
1894 vat_json_init_object (&node);
1895 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1896 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1898 vat_json_print (vam->ofp, &node);
1899 vat_json_free (&node);
1901 vam->retval = ntohl (mp->retval);
1902 vam->result_ready = 1;
1906 vl_api_bond_delete_reply_t_handler (vl_api_bond_delete_reply_t * mp)
1908 vat_main_t *vam = &vat_main;
1909 i32 retval = ntohl (mp->retval);
1911 if (vam->async_mode)
1913 vam->async_errors += (retval < 0);
1917 vam->retval = retval;
1918 vam->result_ready = 1;
1922 static void vl_api_bond_delete_reply_t_handler_json
1923 (vl_api_bond_delete_reply_t * mp)
1925 vat_main_t *vam = &vat_main;
1926 vat_json_node_t node;
1928 vat_json_init_object (&node);
1929 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1931 vat_json_print (vam->ofp, &node);
1932 vat_json_free (&node);
1934 vam->retval = ntohl (mp->retval);
1935 vam->result_ready = 1;
1939 vl_api_bond_enslave_reply_t_handler (vl_api_bond_enslave_reply_t * mp)
1941 vat_main_t *vam = &vat_main;
1942 i32 retval = ntohl (mp->retval);
1944 if (vam->async_mode)
1946 vam->async_errors += (retval < 0);
1950 vam->retval = retval;
1951 vam->result_ready = 1;
1955 static void vl_api_bond_enslave_reply_t_handler_json
1956 (vl_api_bond_enslave_reply_t * mp)
1958 vat_main_t *vam = &vat_main;
1959 vat_json_node_t node;
1961 vat_json_init_object (&node);
1962 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1964 vat_json_print (vam->ofp, &node);
1965 vat_json_free (&node);
1967 vam->retval = ntohl (mp->retval);
1968 vam->result_ready = 1;
1972 vl_api_bond_detach_slave_reply_t_handler (vl_api_bond_detach_slave_reply_t *
1975 vat_main_t *vam = &vat_main;
1976 i32 retval = ntohl (mp->retval);
1978 if (vam->async_mode)
1980 vam->async_errors += (retval < 0);
1984 vam->retval = retval;
1985 vam->result_ready = 1;
1989 static void vl_api_bond_detach_slave_reply_t_handler_json
1990 (vl_api_bond_detach_slave_reply_t * mp)
1992 vat_main_t *vam = &vat_main;
1993 vat_json_node_t node;
1995 vat_json_init_object (&node);
1996 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1998 vat_json_print (vam->ofp, &node);
1999 vat_json_free (&node);
2001 vam->retval = ntohl (mp->retval);
2002 vam->result_ready = 1;
2005 static void vl_api_sw_interface_bond_details_t_handler
2006 (vl_api_sw_interface_bond_details_t * mp)
2008 vat_main_t *vam = &vat_main;
2011 "%-16s %-12d %-12U %-13U %-14u %-14u",
2012 mp->interface_name, ntohl (mp->sw_if_index),
2013 format_bond_mode, mp->mode, format_bond_load_balance, mp->lb,
2014 ntohl (mp->active_slaves), ntohl (mp->slaves));
2017 static void vl_api_sw_interface_bond_details_t_handler_json
2018 (vl_api_sw_interface_bond_details_t * mp)
2020 vat_main_t *vam = &vat_main;
2021 vat_json_node_t *node = NULL;
2023 if (VAT_JSON_ARRAY != vam->json_tree.type)
2025 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2026 vat_json_init_array (&vam->json_tree);
2028 node = vat_json_array_add (&vam->json_tree);
2030 vat_json_init_object (node);
2031 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2032 vat_json_object_add_string_copy (node, "interface_name",
2033 mp->interface_name);
2034 vat_json_object_add_uint (node, "mode", mp->mode);
2035 vat_json_object_add_uint (node, "load_balance", mp->lb);
2036 vat_json_object_add_uint (node, "active_slaves", ntohl (mp->active_slaves));
2037 vat_json_object_add_uint (node, "slaves", ntohl (mp->slaves));
2041 api_sw_interface_bond_dump (vat_main_t * vam)
2043 vl_api_sw_interface_bond_dump_t *mp;
2044 vl_api_control_ping_t *mp_ping;
2048 "\n%-16s %-12s %-12s %-13s %-14s %-14s",
2049 "interface name", "sw_if_index", "mode", "load balance",
2050 "active slaves", "slaves");
2052 /* Get list of bond interfaces */
2053 M (SW_INTERFACE_BOND_DUMP, mp);
2056 /* Use a control ping for synchronization */
2057 MPING (CONTROL_PING, mp_ping);
2064 static void vl_api_sw_interface_slave_details_t_handler
2065 (vl_api_sw_interface_slave_details_t * mp)
2067 vat_main_t *vam = &vat_main;
2070 "%-25s %-12d %-12d %d", mp->interface_name,
2071 ntohl (mp->sw_if_index), mp->is_passive, mp->is_long_timeout);
2074 static void vl_api_sw_interface_slave_details_t_handler_json
2075 (vl_api_sw_interface_slave_details_t * mp)
2077 vat_main_t *vam = &vat_main;
2078 vat_json_node_t *node = NULL;
2080 if (VAT_JSON_ARRAY != vam->json_tree.type)
2082 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2083 vat_json_init_array (&vam->json_tree);
2085 node = vat_json_array_add (&vam->json_tree);
2087 vat_json_init_object (node);
2088 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2089 vat_json_object_add_string_copy (node, "interface_name",
2090 mp->interface_name);
2091 vat_json_object_add_uint (node, "passive", mp->is_passive);
2092 vat_json_object_add_uint (node, "long_timeout", mp->is_long_timeout);
2096 api_sw_interface_slave_dump (vat_main_t * vam)
2098 unformat_input_t *i = vam->input;
2099 vl_api_sw_interface_slave_dump_t *mp;
2100 vl_api_control_ping_t *mp_ping;
2101 u32 sw_if_index = ~0;
2102 u8 sw_if_index_set = 0;
2105 /* Parse args required to build the message */
2106 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2108 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2109 sw_if_index_set = 1;
2110 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2111 sw_if_index_set = 1;
2116 if (sw_if_index_set == 0)
2118 errmsg ("missing vpp interface name. ");
2123 "\n%-25s %-12s %-12s %s",
2124 "slave interface name", "sw_if_index", "passive", "long_timeout");
2126 /* Get list of bond interfaces */
2127 M (SW_INTERFACE_SLAVE_DUMP, mp);
2128 mp->sw_if_index = ntohl (sw_if_index);
2131 /* Use a control ping for synchronization */
2132 MPING (CONTROL_PING, mp_ping);
2139 static void vl_api_mpls_tunnel_add_del_reply_t_handler
2140 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2142 vat_main_t *vam = &vat_main;
2143 i32 retval = ntohl (mp->retval);
2144 if (vam->async_mode)
2146 vam->async_errors += (retval < 0);
2150 vam->retval = retval;
2151 vam->sw_if_index = ntohl (mp->sw_if_index);
2152 vam->result_ready = 1;
2154 vam->regenerate_interface_table = 1;
2157 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
2158 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2160 vat_main_t *vam = &vat_main;
2161 vat_json_node_t node;
2163 vat_json_init_object (&node);
2164 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2165 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
2166 ntohl (mp->sw_if_index));
2168 vat_json_print (vam->ofp, &node);
2169 vat_json_free (&node);
2171 vam->retval = ntohl (mp->retval);
2172 vam->result_ready = 1;
2175 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
2176 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2178 vat_main_t *vam = &vat_main;
2179 i32 retval = ntohl (mp->retval);
2180 if (vam->async_mode)
2182 vam->async_errors += (retval < 0);
2186 vam->retval = retval;
2187 vam->sw_if_index = ntohl (mp->sw_if_index);
2188 vam->result_ready = 1;
2192 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
2193 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2195 vat_main_t *vam = &vat_main;
2196 vat_json_node_t node;
2198 vat_json_init_object (&node);
2199 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2200 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2202 vat_json_print (vam->ofp, &node);
2203 vat_json_free (&node);
2205 vam->retval = ntohl (mp->retval);
2206 vam->result_ready = 1;
2209 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
2210 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2212 vat_main_t *vam = &vat_main;
2213 i32 retval = ntohl (mp->retval);
2214 if (vam->async_mode)
2216 vam->async_errors += (retval < 0);
2220 vam->retval = retval;
2221 vam->result_ready = 1;
2225 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
2226 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2228 vat_main_t *vam = &vat_main;
2229 vat_json_node_t node;
2231 vat_json_init_object (&node);
2232 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2233 vat_json_object_add_uint (&node, "fwd_entry_index",
2234 clib_net_to_host_u32 (mp->fwd_entry_index));
2236 vat_json_print (vam->ofp, &node);
2237 vat_json_free (&node);
2239 vam->retval = ntohl (mp->retval);
2240 vam->result_ready = 1;
2244 format_lisp_transport_protocol (u8 * s, va_list * args)
2246 u32 proto = va_arg (*args, u32);
2251 return format (s, "udp");
2253 return format (s, "api");
2260 static void vl_api_one_get_transport_protocol_reply_t_handler
2261 (vl_api_one_get_transport_protocol_reply_t * mp)
2263 vat_main_t *vam = &vat_main;
2264 i32 retval = ntohl (mp->retval);
2265 if (vam->async_mode)
2267 vam->async_errors += (retval < 0);
2271 u32 proto = mp->protocol;
2272 print (vam->ofp, "Transport protocol: %U",
2273 format_lisp_transport_protocol, proto);
2274 vam->retval = retval;
2275 vam->result_ready = 1;
2279 static void vl_api_one_get_transport_protocol_reply_t_handler_json
2280 (vl_api_one_get_transport_protocol_reply_t * mp)
2282 vat_main_t *vam = &vat_main;
2283 vat_json_node_t node;
2286 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
2289 vat_json_init_object (&node);
2290 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2291 vat_json_object_add_string_copy (&node, "transport-protocol", s);
2294 vat_json_print (vam->ofp, &node);
2295 vat_json_free (&node);
2297 vam->retval = ntohl (mp->retval);
2298 vam->result_ready = 1;
2301 static void vl_api_one_add_del_locator_set_reply_t_handler
2302 (vl_api_one_add_del_locator_set_reply_t * mp)
2304 vat_main_t *vam = &vat_main;
2305 i32 retval = ntohl (mp->retval);
2306 if (vam->async_mode)
2308 vam->async_errors += (retval < 0);
2312 vam->retval = retval;
2313 vam->result_ready = 1;
2317 static void vl_api_one_add_del_locator_set_reply_t_handler_json
2318 (vl_api_one_add_del_locator_set_reply_t * mp)
2320 vat_main_t *vam = &vat_main;
2321 vat_json_node_t node;
2323 vat_json_init_object (&node);
2324 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2325 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
2327 vat_json_print (vam->ofp, &node);
2328 vat_json_free (&node);
2330 vam->retval = ntohl (mp->retval);
2331 vam->result_ready = 1;
2334 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
2335 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2337 vat_main_t *vam = &vat_main;
2338 i32 retval = ntohl (mp->retval);
2339 if (vam->async_mode)
2341 vam->async_errors += (retval < 0);
2345 vam->retval = retval;
2346 vam->sw_if_index = ntohl (mp->sw_if_index);
2347 vam->result_ready = 1;
2349 vam->regenerate_interface_table = 1;
2352 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
2353 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2355 vat_main_t *vam = &vat_main;
2356 vat_json_node_t node;
2358 vat_json_init_object (&node);
2359 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2360 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2362 vat_json_print (vam->ofp, &node);
2363 vat_json_free (&node);
2365 vam->retval = ntohl (mp->retval);
2366 vam->result_ready = 1;
2369 static void vl_api_vxlan_offload_rx_reply_t_handler
2370 (vl_api_vxlan_offload_rx_reply_t * mp)
2372 vat_main_t *vam = &vat_main;
2373 i32 retval = ntohl (mp->retval);
2374 if (vam->async_mode)
2376 vam->async_errors += (retval < 0);
2380 vam->retval = retval;
2381 vam->result_ready = 1;
2385 static void vl_api_vxlan_offload_rx_reply_t_handler_json
2386 (vl_api_vxlan_offload_rx_reply_t * mp)
2388 vat_main_t *vam = &vat_main;
2389 vat_json_node_t node;
2391 vat_json_init_object (&node);
2392 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2394 vat_json_print (vam->ofp, &node);
2395 vat_json_free (&node);
2397 vam->retval = ntohl (mp->retval);
2398 vam->result_ready = 1;
2401 static void vl_api_geneve_add_del_tunnel_reply_t_handler
2402 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2404 vat_main_t *vam = &vat_main;
2405 i32 retval = ntohl (mp->retval);
2406 if (vam->async_mode)
2408 vam->async_errors += (retval < 0);
2412 vam->retval = retval;
2413 vam->sw_if_index = ntohl (mp->sw_if_index);
2414 vam->result_ready = 1;
2418 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
2419 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2421 vat_main_t *vam = &vat_main;
2422 vat_json_node_t node;
2424 vat_json_init_object (&node);
2425 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2426 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2428 vat_json_print (vam->ofp, &node);
2429 vat_json_free (&node);
2431 vam->retval = ntohl (mp->retval);
2432 vam->result_ready = 1;
2435 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
2436 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2438 vat_main_t *vam = &vat_main;
2439 i32 retval = ntohl (mp->retval);
2440 if (vam->async_mode)
2442 vam->async_errors += (retval < 0);
2446 vam->retval = retval;
2447 vam->sw_if_index = ntohl (mp->sw_if_index);
2448 vam->result_ready = 1;
2450 vam->regenerate_interface_table = 1;
2453 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
2454 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2456 vat_main_t *vam = &vat_main;
2457 vat_json_node_t node;
2459 vat_json_init_object (&node);
2460 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2461 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2463 vat_json_print (vam->ofp, &node);
2464 vat_json_free (&node);
2466 vam->retval = ntohl (mp->retval);
2467 vam->result_ready = 1;
2470 static void vl_api_gre_tunnel_add_del_reply_t_handler
2471 (vl_api_gre_tunnel_add_del_reply_t * mp)
2473 vat_main_t *vam = &vat_main;
2474 i32 retval = ntohl (mp->retval);
2475 if (vam->async_mode)
2477 vam->async_errors += (retval < 0);
2481 vam->retval = retval;
2482 vam->sw_if_index = ntohl (mp->sw_if_index);
2483 vam->result_ready = 1;
2487 static void vl_api_gre_tunnel_add_del_reply_t_handler_json
2488 (vl_api_gre_tunnel_add_del_reply_t * mp)
2490 vat_main_t *vam = &vat_main;
2491 vat_json_node_t node;
2493 vat_json_init_object (&node);
2494 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2495 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2497 vat_json_print (vam->ofp, &node);
2498 vat_json_free (&node);
2500 vam->retval = ntohl (mp->retval);
2501 vam->result_ready = 1;
2504 static void vl_api_create_vhost_user_if_reply_t_handler
2505 (vl_api_create_vhost_user_if_reply_t * mp)
2507 vat_main_t *vam = &vat_main;
2508 i32 retval = ntohl (mp->retval);
2509 if (vam->async_mode)
2511 vam->async_errors += (retval < 0);
2515 vam->retval = retval;
2516 vam->sw_if_index = ntohl (mp->sw_if_index);
2517 vam->result_ready = 1;
2519 vam->regenerate_interface_table = 1;
2522 static void vl_api_create_vhost_user_if_reply_t_handler_json
2523 (vl_api_create_vhost_user_if_reply_t * mp)
2525 vat_main_t *vam = &vat_main;
2526 vat_json_node_t node;
2528 vat_json_init_object (&node);
2529 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2530 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2532 vat_json_print (vam->ofp, &node);
2533 vat_json_free (&node);
2535 vam->retval = ntohl (mp->retval);
2536 vam->result_ready = 1;
2539 static void vl_api_dns_resolve_name_reply_t_handler
2540 (vl_api_dns_resolve_name_reply_t * mp)
2542 vat_main_t *vam = &vat_main;
2543 i32 retval = ntohl (mp->retval);
2544 if (vam->async_mode)
2546 vam->async_errors += (retval < 0);
2550 vam->retval = retval;
2551 vam->result_ready = 1;
2556 clib_warning ("ip4 address %U", format_ip4_address,
2557 (ip4_address_t *) mp->ip4_address);
2559 clib_warning ("ip6 address %U", format_ip6_address,
2560 (ip6_address_t *) mp->ip6_address);
2563 clib_warning ("retval %d", retval);
2567 static void vl_api_dns_resolve_name_reply_t_handler_json
2568 (vl_api_dns_resolve_name_reply_t * mp)
2570 clib_warning ("not implemented");
2573 static void vl_api_dns_resolve_ip_reply_t_handler
2574 (vl_api_dns_resolve_ip_reply_t * mp)
2576 vat_main_t *vam = &vat_main;
2577 i32 retval = ntohl (mp->retval);
2578 if (vam->async_mode)
2580 vam->async_errors += (retval < 0);
2584 vam->retval = retval;
2585 vam->result_ready = 1;
2589 clib_warning ("canonical name %s", mp->name);
2592 clib_warning ("retval %d", retval);
2596 static void vl_api_dns_resolve_ip_reply_t_handler_json
2597 (vl_api_dns_resolve_ip_reply_t * mp)
2599 clib_warning ("not implemented");
2603 static void vl_api_ip_address_details_t_handler
2604 (vl_api_ip_address_details_t * mp)
2606 vat_main_t *vam = &vat_main;
2607 static ip_address_details_t empty_ip_address_details = { {0} };
2608 ip_address_details_t *address = NULL;
2609 ip_details_t *current_ip_details = NULL;
2610 ip_details_t *details = NULL;
2612 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2614 if (!details || vam->current_sw_if_index >= vec_len (details)
2615 || !details[vam->current_sw_if_index].present)
2617 errmsg ("ip address details arrived but not stored");
2618 errmsg ("ip_dump should be called first");
2622 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2624 #define addresses (current_ip_details->addr)
2626 vec_validate_init_empty (addresses, vec_len (addresses),
2627 empty_ip_address_details);
2629 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2631 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
2632 address->prefix_length = mp->prefix_length;
2636 static void vl_api_ip_address_details_t_handler_json
2637 (vl_api_ip_address_details_t * mp)
2639 vat_main_t *vam = &vat_main;
2640 vat_json_node_t *node = NULL;
2641 struct in6_addr ip6;
2644 if (VAT_JSON_ARRAY != vam->json_tree.type)
2646 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2647 vat_json_init_array (&vam->json_tree);
2649 node = vat_json_array_add (&vam->json_tree);
2651 vat_json_init_object (node);
2654 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
2655 vat_json_object_add_ip6 (node, "ip", ip6);
2659 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
2660 vat_json_object_add_ip4 (node, "ip", ip4);
2662 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
2666 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2668 vat_main_t *vam = &vat_main;
2669 static ip_details_t empty_ip_details = { 0 };
2670 ip_details_t *ip = NULL;
2671 u32 sw_if_index = ~0;
2673 sw_if_index = ntohl (mp->sw_if_index);
2675 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2676 sw_if_index, empty_ip_details);
2678 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2685 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2687 vat_main_t *vam = &vat_main;
2689 if (VAT_JSON_ARRAY != vam->json_tree.type)
2691 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2692 vat_json_init_array (&vam->json_tree);
2694 vat_json_array_add_uint (&vam->json_tree,
2695 clib_net_to_host_u32 (mp->sw_if_index));
2699 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2703 s = format (0, "DHCP compl event: pid %d %s hostname %s host_addr %U "
2704 "host_mac %U router_addr %U",
2705 ntohl (mp->pid), mp->lease.is_ipv6 ? "ipv6" : "ipv4",
2707 format_ip4_address, mp->lease.host_address,
2708 format_ethernet_address, mp->lease.host_mac,
2709 format_ip4_address, mp->lease.router_address);
2711 for (i = 0; i < mp->lease.count; i++)
2713 format (s, " domain_server_addr %U", format_ip4_address,
2714 mp->lease.domain_server[i].address);
2716 errmsg ((char *) s);
2720 static void vl_api_dhcp_compl_event_t_handler_json
2721 (vl_api_dhcp_compl_event_t * mp)
2723 /* JSON output not supported */
2726 static void vl_api_get_first_msg_id_reply_t_handler
2727 (vl_api_get_first_msg_id_reply_t * mp)
2729 vat_main_t *vam = &vat_main;
2730 i32 retval = ntohl (mp->retval);
2732 if (vam->async_mode)
2734 vam->async_errors += (retval < 0);
2738 vam->retval = retval;
2739 vam->result_ready = 1;
2743 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2747 static void vl_api_get_first_msg_id_reply_t_handler_json
2748 (vl_api_get_first_msg_id_reply_t * mp)
2750 vat_main_t *vam = &vat_main;
2751 vat_json_node_t node;
2753 vat_json_init_object (&node);
2754 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2755 vat_json_object_add_uint (&node, "first_msg_id",
2756 (uint) ntohs (mp->first_msg_id));
2758 vat_json_print (vam->ofp, &node);
2759 vat_json_free (&node);
2761 vam->retval = ntohl (mp->retval);
2762 vam->result_ready = 1;
2765 static void vl_api_get_node_graph_reply_t_handler
2766 (vl_api_get_node_graph_reply_t * mp)
2768 vat_main_t *vam = &vat_main;
2769 api_main_t *am = &api_main;
2770 i32 retval = ntohl (mp->retval);
2771 u8 *pvt_copy, *reply;
2776 if (vam->async_mode)
2778 vam->async_errors += (retval < 0);
2782 vam->retval = retval;
2783 vam->result_ready = 1;
2786 /* "Should never happen..." */
2790 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2791 pvt_copy = vec_dup (reply);
2793 /* Toss the shared-memory original... */
2794 pthread_mutex_lock (&am->vlib_rp->mutex);
2795 oldheap = svm_push_data_heap (am->vlib_rp);
2799 svm_pop_heap (oldheap);
2800 pthread_mutex_unlock (&am->vlib_rp->mutex);
2802 if (vam->graph_nodes)
2804 hash_free (vam->graph_node_index_by_name);
2806 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2808 node = vam->graph_nodes[0][i];
2809 vec_free (node->name);
2810 vec_free (node->next_nodes);
2813 vec_free (vam->graph_nodes[0]);
2814 vec_free (vam->graph_nodes);
2817 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2818 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2819 vec_free (pvt_copy);
2821 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2823 node = vam->graph_nodes[0][i];
2824 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2828 static void vl_api_get_node_graph_reply_t_handler_json
2829 (vl_api_get_node_graph_reply_t * mp)
2831 vat_main_t *vam = &vat_main;
2832 api_main_t *am = &api_main;
2834 vat_json_node_t node;
2837 /* $$$$ make this real? */
2838 vat_json_init_object (&node);
2839 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2840 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2842 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2844 /* Toss the shared-memory original... */
2845 pthread_mutex_lock (&am->vlib_rp->mutex);
2846 oldheap = svm_push_data_heap (am->vlib_rp);
2850 svm_pop_heap (oldheap);
2851 pthread_mutex_unlock (&am->vlib_rp->mutex);
2853 vat_json_print (vam->ofp, &node);
2854 vat_json_free (&node);
2856 vam->retval = ntohl (mp->retval);
2857 vam->result_ready = 1;
2861 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2863 vat_main_t *vam = &vat_main;
2868 s = format (s, "%=16d%=16d%=16d",
2869 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2873 s = format (s, "%=16U%=16d%=16d",
2874 mp->is_ipv6 ? format_ip6_address :
2876 mp->ip_address, mp->priority, mp->weight);
2879 print (vam->ofp, "%v", s);
2884 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2886 vat_main_t *vam = &vat_main;
2887 vat_json_node_t *node = NULL;
2888 struct in6_addr ip6;
2891 if (VAT_JSON_ARRAY != vam->json_tree.type)
2893 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2894 vat_json_init_array (&vam->json_tree);
2896 node = vat_json_array_add (&vam->json_tree);
2897 vat_json_init_object (node);
2899 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2900 vat_json_object_add_uint (node, "priority", mp->priority);
2901 vat_json_object_add_uint (node, "weight", mp->weight);
2904 vat_json_object_add_uint (node, "sw_if_index",
2905 clib_net_to_host_u32 (mp->sw_if_index));
2910 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2911 vat_json_object_add_ip6 (node, "address", ip6);
2915 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2916 vat_json_object_add_ip4 (node, "address", ip4);
2922 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2925 vat_main_t *vam = &vat_main;
2928 ls_name = format (0, "%s", mp->ls_name);
2930 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2936 vl_api_one_locator_set_details_t_handler_json
2937 (vl_api_one_locator_set_details_t * mp)
2939 vat_main_t *vam = &vat_main;
2940 vat_json_node_t *node = 0;
2943 ls_name = format (0, "%s", mp->ls_name);
2944 vec_add1 (ls_name, 0);
2946 if (VAT_JSON_ARRAY != vam->json_tree.type)
2948 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2949 vat_json_init_array (&vam->json_tree);
2951 node = vat_json_array_add (&vam->json_tree);
2953 vat_json_init_object (node);
2954 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2955 vat_json_object_add_uint (node, "ls_index",
2956 clib_net_to_host_u32 (mp->ls_index));
2964 } __attribute__ ((__packed__)) lisp_nsh_api_t;
2967 unformat_nsh_address (unformat_input_t * input, va_list * args)
2969 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
2970 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
2974 format_nsh_address_vat (u8 * s, va_list * args)
2976 nsh_t *a = va_arg (*args, nsh_t *);
2977 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
2981 format_lisp_flat_eid (u8 * s, va_list * args)
2983 u32 type = va_arg (*args, u32);
2984 u8 *eid = va_arg (*args, u8 *);
2985 u32 eid_len = va_arg (*args, u32);
2990 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2992 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2994 return format (s, "%U", format_ethernet_address, eid);
2996 return format (s, "%U", format_nsh_address_vat, eid);
3002 format_lisp_eid_vat (u8 * s, va_list * args)
3004 u32 type = va_arg (*args, u32);
3005 u8 *eid = va_arg (*args, u8 *);
3006 u32 eid_len = va_arg (*args, u32);
3007 u8 *seid = va_arg (*args, u8 *);
3008 u32 seid_len = va_arg (*args, u32);
3009 u32 is_src_dst = va_arg (*args, u32);
3012 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
3014 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
3020 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
3022 vat_main_t *vam = &vat_main;
3023 u8 *s = 0, *eid = 0;
3025 if (~0 == mp->locator_set_index)
3026 s = format (0, "action: %d", mp->action);
3028 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3030 eid = format (0, "%U", format_lisp_eid_vat,
3034 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3037 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3038 clib_net_to_host_u32 (mp->vni),
3040 mp->is_local ? "local" : "remote",
3041 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3042 clib_net_to_host_u16 (mp->key_id), mp->key);
3049 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3052 vat_main_t *vam = &vat_main;
3053 vat_json_node_t *node = 0;
3056 if (VAT_JSON_ARRAY != vam->json_tree.type)
3058 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3059 vat_json_init_array (&vam->json_tree);
3061 node = vat_json_array_add (&vam->json_tree);
3063 vat_json_init_object (node);
3064 if (~0 == mp->locator_set_index)
3065 vat_json_object_add_uint (node, "action", mp->action);
3067 vat_json_object_add_uint (node, "locator_set_index",
3068 clib_net_to_host_u32 (mp->locator_set_index));
3070 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3071 if (mp->eid_type == 3)
3073 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3074 vat_json_init_object (nsh_json);
3075 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3076 vat_json_object_add_uint (nsh_json, "spi",
3077 clib_net_to_host_u32 (nsh->spi));
3078 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3082 eid = format (0, "%U", format_lisp_eid_vat,
3086 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3088 vat_json_object_add_string_copy (node, "eid", eid);
3091 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3092 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3093 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3097 vat_json_object_add_uint (node, "key_id",
3098 clib_net_to_host_u16 (mp->key_id));
3099 vat_json_object_add_string_copy (node, "key", mp->key);
3104 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3106 vat_main_t *vam = &vat_main;
3107 u8 *seid = 0, *deid = 0;
3108 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3110 deid = format (0, "%U", format_lisp_eid_vat,
3111 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3113 seid = format (0, "%U", format_lisp_eid_vat,
3114 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3120 format_ip_address_fcn = format_ip4_address;
3122 format_ip_address_fcn = format_ip6_address;
3125 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3126 clib_net_to_host_u32 (mp->vni),
3128 format_ip_address_fcn, mp->lloc,
3129 format_ip_address_fcn, mp->rloc,
3130 clib_net_to_host_u32 (mp->pkt_count),
3131 clib_net_to_host_u32 (mp->bytes));
3138 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3140 struct in6_addr ip6;
3142 vat_main_t *vam = &vat_main;
3143 vat_json_node_t *node = 0;
3144 u8 *deid = 0, *seid = 0;
3146 if (VAT_JSON_ARRAY != vam->json_tree.type)
3148 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3149 vat_json_init_array (&vam->json_tree);
3151 node = vat_json_array_add (&vam->json_tree);
3153 vat_json_init_object (node);
3154 deid = format (0, "%U", format_lisp_eid_vat,
3155 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3157 seid = format (0, "%U", format_lisp_eid_vat,
3158 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3163 vat_json_object_add_string_copy (node, "seid", seid);
3164 vat_json_object_add_string_copy (node, "deid", deid);
3165 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3169 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3170 vat_json_object_add_ip4 (node, "lloc", ip4);
3171 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3172 vat_json_object_add_ip4 (node, "rloc", ip4);
3176 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3177 vat_json_object_add_ip6 (node, "lloc", ip6);
3178 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3179 vat_json_object_add_ip6 (node, "rloc", ip6);
3181 vat_json_object_add_uint (node, "pkt_count",
3182 clib_net_to_host_u32 (mp->pkt_count));
3183 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3190 vl_api_one_eid_table_map_details_t_handler
3191 (vl_api_one_eid_table_map_details_t * mp)
3193 vat_main_t *vam = &vat_main;
3195 u8 *line = format (0, "%=10d%=10d",
3196 clib_net_to_host_u32 (mp->vni),
3197 clib_net_to_host_u32 (mp->dp_table));
3198 print (vam->ofp, "%v", line);
3203 vl_api_one_eid_table_map_details_t_handler_json
3204 (vl_api_one_eid_table_map_details_t * mp)
3206 vat_main_t *vam = &vat_main;
3207 vat_json_node_t *node = NULL;
3209 if (VAT_JSON_ARRAY != vam->json_tree.type)
3211 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3212 vat_json_init_array (&vam->json_tree);
3214 node = vat_json_array_add (&vam->json_tree);
3215 vat_json_init_object (node);
3216 vat_json_object_add_uint (node, "dp_table",
3217 clib_net_to_host_u32 (mp->dp_table));
3218 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3222 vl_api_one_eid_table_vni_details_t_handler
3223 (vl_api_one_eid_table_vni_details_t * mp)
3225 vat_main_t *vam = &vat_main;
3227 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3228 print (vam->ofp, "%v", line);
3233 vl_api_one_eid_table_vni_details_t_handler_json
3234 (vl_api_one_eid_table_vni_details_t * mp)
3236 vat_main_t *vam = &vat_main;
3237 vat_json_node_t *node = NULL;
3239 if (VAT_JSON_ARRAY != vam->json_tree.type)
3241 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3242 vat_json_init_array (&vam->json_tree);
3244 node = vat_json_array_add (&vam->json_tree);
3245 vat_json_init_object (node);
3246 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3250 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3251 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3253 vat_main_t *vam = &vat_main;
3254 int retval = clib_net_to_host_u32 (mp->retval);
3256 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3257 print (vam->ofp, "fallback threshold value: %d", mp->value);
3259 vam->retval = retval;
3260 vam->result_ready = 1;
3264 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3265 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3267 vat_main_t *vam = &vat_main;
3268 vat_json_node_t _node, *node = &_node;
3269 int retval = clib_net_to_host_u32 (mp->retval);
3271 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3272 vat_json_init_object (node);
3273 vat_json_object_add_uint (node, "value", mp->value);
3275 vat_json_print (vam->ofp, node);
3276 vat_json_free (node);
3278 vam->retval = retval;
3279 vam->result_ready = 1;
3283 vl_api_show_one_map_register_state_reply_t_handler
3284 (vl_api_show_one_map_register_state_reply_t * mp)
3286 vat_main_t *vam = &vat_main;
3287 int retval = clib_net_to_host_u32 (mp->retval);
3289 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3291 vam->retval = retval;
3292 vam->result_ready = 1;
3296 vl_api_show_one_map_register_state_reply_t_handler_json
3297 (vl_api_show_one_map_register_state_reply_t * mp)
3299 vat_main_t *vam = &vat_main;
3300 vat_json_node_t _node, *node = &_node;
3301 int retval = clib_net_to_host_u32 (mp->retval);
3303 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3305 vat_json_init_object (node);
3306 vat_json_object_add_string_copy (node, "state", s);
3308 vat_json_print (vam->ofp, node);
3309 vat_json_free (node);
3311 vam->retval = retval;
3312 vam->result_ready = 1;
3317 vl_api_show_one_rloc_probe_state_reply_t_handler
3318 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3320 vat_main_t *vam = &vat_main;
3321 int retval = clib_net_to_host_u32 (mp->retval);
3326 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3328 vam->retval = retval;
3329 vam->result_ready = 1;
3333 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3334 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3336 vat_main_t *vam = &vat_main;
3337 vat_json_node_t _node, *node = &_node;
3338 int retval = clib_net_to_host_u32 (mp->retval);
3340 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3341 vat_json_init_object (node);
3342 vat_json_object_add_string_copy (node, "state", s);
3344 vat_json_print (vam->ofp, node);
3345 vat_json_free (node);
3347 vam->retval = retval;
3348 vam->result_ready = 1;
3353 vl_api_show_one_stats_enable_disable_reply_t_handler
3354 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3356 vat_main_t *vam = &vat_main;
3357 int retval = clib_net_to_host_u32 (mp->retval);
3362 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3364 vam->retval = retval;
3365 vam->result_ready = 1;
3369 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3370 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3372 vat_main_t *vam = &vat_main;
3373 vat_json_node_t _node, *node = &_node;
3374 int retval = clib_net_to_host_u32 (mp->retval);
3376 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3377 vat_json_init_object (node);
3378 vat_json_object_add_string_copy (node, "state", s);
3380 vat_json_print (vam->ofp, node);
3381 vat_json_free (node);
3383 vam->retval = retval;
3384 vam->result_ready = 1;
3389 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3391 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3392 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3393 e->vni = clib_net_to_host_u32 (e->vni);
3397 gpe_fwd_entries_get_reply_t_net_to_host
3398 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3402 mp->count = clib_net_to_host_u32 (mp->count);
3403 for (i = 0; i < mp->count; i++)
3405 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3410 format_gpe_encap_mode (u8 * s, va_list * args)
3412 u32 mode = va_arg (*args, u32);
3417 return format (s, "lisp");
3419 return format (s, "vxlan");
3425 vl_api_gpe_get_encap_mode_reply_t_handler
3426 (vl_api_gpe_get_encap_mode_reply_t * mp)
3428 vat_main_t *vam = &vat_main;
3430 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3431 vam->retval = ntohl (mp->retval);
3432 vam->result_ready = 1;
3436 vl_api_gpe_get_encap_mode_reply_t_handler_json
3437 (vl_api_gpe_get_encap_mode_reply_t * mp)
3439 vat_main_t *vam = &vat_main;
3440 vat_json_node_t node;
3442 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3443 vec_add1 (encap_mode, 0);
3445 vat_json_init_object (&node);
3446 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3448 vec_free (encap_mode);
3449 vat_json_print (vam->ofp, &node);
3450 vat_json_free (&node);
3452 vam->retval = ntohl (mp->retval);
3453 vam->result_ready = 1;
3457 vl_api_gpe_fwd_entry_path_details_t_handler
3458 (vl_api_gpe_fwd_entry_path_details_t * mp)
3460 vat_main_t *vam = &vat_main;
3461 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3463 if (mp->lcl_loc.is_ip4)
3464 format_ip_address_fcn = format_ip4_address;
3466 format_ip_address_fcn = format_ip6_address;
3468 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3469 format_ip_address_fcn, &mp->lcl_loc,
3470 format_ip_address_fcn, &mp->rmt_loc);
3474 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3476 struct in6_addr ip6;
3481 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3482 vat_json_object_add_ip4 (n, "address", ip4);
3486 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3487 vat_json_object_add_ip6 (n, "address", ip6);
3489 vat_json_object_add_uint (n, "weight", loc->weight);
3493 vl_api_gpe_fwd_entry_path_details_t_handler_json
3494 (vl_api_gpe_fwd_entry_path_details_t * mp)
3496 vat_main_t *vam = &vat_main;
3497 vat_json_node_t *node = NULL;
3498 vat_json_node_t *loc_node;
3500 if (VAT_JSON_ARRAY != vam->json_tree.type)
3502 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3503 vat_json_init_array (&vam->json_tree);
3505 node = vat_json_array_add (&vam->json_tree);
3506 vat_json_init_object (node);
3508 loc_node = vat_json_object_add (node, "local_locator");
3509 vat_json_init_object (loc_node);
3510 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3512 loc_node = vat_json_object_add (node, "remote_locator");
3513 vat_json_init_object (loc_node);
3514 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3518 vl_api_gpe_fwd_entries_get_reply_t_handler
3519 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3521 vat_main_t *vam = &vat_main;
3523 int retval = clib_net_to_host_u32 (mp->retval);
3524 vl_api_gpe_fwd_entry_t *e;
3529 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3531 for (i = 0; i < mp->count; i++)
3533 e = &mp->entries[i];
3534 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3535 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3536 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3540 vam->retval = retval;
3541 vam->result_ready = 1;
3545 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3546 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3549 vat_main_t *vam = &vat_main;
3550 vat_json_node_t *e = 0, root;
3552 int retval = clib_net_to_host_u32 (mp->retval);
3553 vl_api_gpe_fwd_entry_t *fwd;
3558 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3559 vat_json_init_array (&root);
3561 for (i = 0; i < mp->count; i++)
3563 e = vat_json_array_add (&root);
3564 fwd = &mp->entries[i];
3566 vat_json_init_object (e);
3567 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3568 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3569 vat_json_object_add_int (e, "vni", fwd->vni);
3570 vat_json_object_add_int (e, "action", fwd->action);
3572 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3573 fwd->leid_prefix_len);
3575 vat_json_object_add_string_copy (e, "leid", s);
3578 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3579 fwd->reid_prefix_len);
3581 vat_json_object_add_string_copy (e, "reid", s);
3585 vat_json_print (vam->ofp, &root);
3586 vat_json_free (&root);
3589 vam->retval = retval;
3590 vam->result_ready = 1;
3594 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3595 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3597 vat_main_t *vam = &vat_main;
3599 int retval = clib_net_to_host_u32 (mp->retval);
3600 vl_api_gpe_native_fwd_rpath_t *r;
3605 n = clib_net_to_host_u32 (mp->count);
3607 for (i = 0; i < n; i++)
3609 r = &mp->entries[i];
3610 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3611 clib_net_to_host_u32 (r->fib_index),
3612 clib_net_to_host_u32 (r->nh_sw_if_index),
3613 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3617 vam->retval = retval;
3618 vam->result_ready = 1;
3622 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3623 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3625 vat_main_t *vam = &vat_main;
3626 vat_json_node_t root, *e;
3628 int retval = clib_net_to_host_u32 (mp->retval);
3629 vl_api_gpe_native_fwd_rpath_t *r;
3635 n = clib_net_to_host_u32 (mp->count);
3636 vat_json_init_array (&root);
3638 for (i = 0; i < n; i++)
3640 e = vat_json_array_add (&root);
3641 vat_json_init_object (e);
3642 r = &mp->entries[i];
3644 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3647 vat_json_object_add_string_copy (e, "ip4", s);
3650 vat_json_object_add_uint (e, "fib_index",
3651 clib_net_to_host_u32 (r->fib_index));
3652 vat_json_object_add_uint (e, "nh_sw_if_index",
3653 clib_net_to_host_u32 (r->nh_sw_if_index));
3656 vat_json_print (vam->ofp, &root);
3657 vat_json_free (&root);
3660 vam->retval = retval;
3661 vam->result_ready = 1;
3665 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3666 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3668 vat_main_t *vam = &vat_main;
3670 int retval = clib_net_to_host_u32 (mp->retval);
3675 n = clib_net_to_host_u32 (mp->count);
3677 for (i = 0; i < n; i++)
3678 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3681 vam->retval = retval;
3682 vam->result_ready = 1;
3686 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3687 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3689 vat_main_t *vam = &vat_main;
3690 vat_json_node_t root;
3692 int retval = clib_net_to_host_u32 (mp->retval);
3697 n = clib_net_to_host_u32 (mp->count);
3698 vat_json_init_array (&root);
3700 for (i = 0; i < n; i++)
3701 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3703 vat_json_print (vam->ofp, &root);
3704 vat_json_free (&root);
3707 vam->retval = retval;
3708 vam->result_ready = 1;
3712 vl_api_one_ndp_entries_get_reply_t_handler
3713 (vl_api_one_ndp_entries_get_reply_t * mp)
3715 vat_main_t *vam = &vat_main;
3717 int retval = clib_net_to_host_u32 (mp->retval);
3722 n = clib_net_to_host_u32 (mp->count);
3724 for (i = 0; i < n; i++)
3725 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3726 format_ethernet_address, mp->entries[i].mac);
3729 vam->retval = retval;
3730 vam->result_ready = 1;
3734 vl_api_one_ndp_entries_get_reply_t_handler_json
3735 (vl_api_one_ndp_entries_get_reply_t * mp)
3738 vat_main_t *vam = &vat_main;
3739 vat_json_node_t *e = 0, root;
3741 int retval = clib_net_to_host_u32 (mp->retval);
3742 vl_api_one_ndp_entry_t *arp_entry;
3747 n = clib_net_to_host_u32 (mp->count);
3748 vat_json_init_array (&root);
3750 for (i = 0; i < n; i++)
3752 e = vat_json_array_add (&root);
3753 arp_entry = &mp->entries[i];
3755 vat_json_init_object (e);
3756 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3759 vat_json_object_add_string_copy (e, "mac", s);
3762 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3764 vat_json_object_add_string_copy (e, "ip6", s);
3768 vat_json_print (vam->ofp, &root);
3769 vat_json_free (&root);
3772 vam->retval = retval;
3773 vam->result_ready = 1;
3777 vl_api_one_l2_arp_entries_get_reply_t_handler
3778 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3780 vat_main_t *vam = &vat_main;
3782 int retval = clib_net_to_host_u32 (mp->retval);
3787 n = clib_net_to_host_u32 (mp->count);
3789 for (i = 0; i < n; i++)
3790 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3791 format_ethernet_address, mp->entries[i].mac);
3794 vam->retval = retval;
3795 vam->result_ready = 1;
3799 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3800 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3803 vat_main_t *vam = &vat_main;
3804 vat_json_node_t *e = 0, root;
3806 int retval = clib_net_to_host_u32 (mp->retval);
3807 vl_api_one_l2_arp_entry_t *arp_entry;
3812 n = clib_net_to_host_u32 (mp->count);
3813 vat_json_init_array (&root);
3815 for (i = 0; i < n; i++)
3817 e = vat_json_array_add (&root);
3818 arp_entry = &mp->entries[i];
3820 vat_json_init_object (e);
3821 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3824 vat_json_object_add_string_copy (e, "mac", s);
3827 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3829 vat_json_object_add_string_copy (e, "ip4", s);
3833 vat_json_print (vam->ofp, &root);
3834 vat_json_free (&root);
3837 vam->retval = retval;
3838 vam->result_ready = 1;
3842 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
3844 vat_main_t *vam = &vat_main;
3846 int retval = clib_net_to_host_u32 (mp->retval);
3851 n = clib_net_to_host_u32 (mp->count);
3853 for (i = 0; i < n; i++)
3855 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3859 vam->retval = retval;
3860 vam->result_ready = 1;
3864 vl_api_one_ndp_bd_get_reply_t_handler_json
3865 (vl_api_one_ndp_bd_get_reply_t * mp)
3867 vat_main_t *vam = &vat_main;
3868 vat_json_node_t root;
3870 int retval = clib_net_to_host_u32 (mp->retval);
3875 n = clib_net_to_host_u32 (mp->count);
3876 vat_json_init_array (&root);
3878 for (i = 0; i < n; i++)
3880 vat_json_array_add_uint (&root,
3881 clib_net_to_host_u32 (mp->bridge_domains[i]));
3884 vat_json_print (vam->ofp, &root);
3885 vat_json_free (&root);
3888 vam->retval = retval;
3889 vam->result_ready = 1;
3893 vl_api_one_l2_arp_bd_get_reply_t_handler
3894 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3896 vat_main_t *vam = &vat_main;
3898 int retval = clib_net_to_host_u32 (mp->retval);
3903 n = clib_net_to_host_u32 (mp->count);
3905 for (i = 0; i < n; i++)
3907 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3911 vam->retval = retval;
3912 vam->result_ready = 1;
3916 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3917 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3919 vat_main_t *vam = &vat_main;
3920 vat_json_node_t root;
3922 int retval = clib_net_to_host_u32 (mp->retval);
3927 n = clib_net_to_host_u32 (mp->count);
3928 vat_json_init_array (&root);
3930 for (i = 0; i < n; i++)
3932 vat_json_array_add_uint (&root,
3933 clib_net_to_host_u32 (mp->bridge_domains[i]));
3936 vat_json_print (vam->ofp, &root);
3937 vat_json_free (&root);
3940 vam->retval = retval;
3941 vam->result_ready = 1;
3945 vl_api_one_adjacencies_get_reply_t_handler
3946 (vl_api_one_adjacencies_get_reply_t * mp)
3948 vat_main_t *vam = &vat_main;
3950 int retval = clib_net_to_host_u32 (mp->retval);
3951 vl_api_one_adjacency_t *a;
3956 n = clib_net_to_host_u32 (mp->count);
3958 for (i = 0; i < n; i++)
3960 a = &mp->adjacencies[i];
3961 print (vam->ofp, "%U %40U",
3962 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3963 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3967 vam->retval = retval;
3968 vam->result_ready = 1;
3972 vl_api_one_adjacencies_get_reply_t_handler_json
3973 (vl_api_one_adjacencies_get_reply_t * mp)
3976 vat_main_t *vam = &vat_main;
3977 vat_json_node_t *e = 0, root;
3979 int retval = clib_net_to_host_u32 (mp->retval);
3980 vl_api_one_adjacency_t *a;
3985 n = clib_net_to_host_u32 (mp->count);
3986 vat_json_init_array (&root);
3988 for (i = 0; i < n; i++)
3990 e = vat_json_array_add (&root);
3991 a = &mp->adjacencies[i];
3993 vat_json_init_object (e);
3994 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
3995 a->leid_prefix_len);
3997 vat_json_object_add_string_copy (e, "leid", s);
4000 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
4001 a->reid_prefix_len);
4003 vat_json_object_add_string_copy (e, "reid", s);
4007 vat_json_print (vam->ofp, &root);
4008 vat_json_free (&root);
4011 vam->retval = retval;
4012 vam->result_ready = 1;
4016 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
4018 vat_main_t *vam = &vat_main;
4020 print (vam->ofp, "%=20U",
4021 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4026 vl_api_one_map_server_details_t_handler_json
4027 (vl_api_one_map_server_details_t * mp)
4029 vat_main_t *vam = &vat_main;
4030 vat_json_node_t *node = NULL;
4031 struct in6_addr ip6;
4034 if (VAT_JSON_ARRAY != vam->json_tree.type)
4036 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4037 vat_json_init_array (&vam->json_tree);
4039 node = vat_json_array_add (&vam->json_tree);
4041 vat_json_init_object (node);
4044 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4045 vat_json_object_add_ip6 (node, "map-server", ip6);
4049 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4050 vat_json_object_add_ip4 (node, "map-server", ip4);
4055 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4058 vat_main_t *vam = &vat_main;
4060 print (vam->ofp, "%=20U",
4061 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4066 vl_api_one_map_resolver_details_t_handler_json
4067 (vl_api_one_map_resolver_details_t * mp)
4069 vat_main_t *vam = &vat_main;
4070 vat_json_node_t *node = NULL;
4071 struct in6_addr ip6;
4074 if (VAT_JSON_ARRAY != vam->json_tree.type)
4076 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4077 vat_json_init_array (&vam->json_tree);
4079 node = vat_json_array_add (&vam->json_tree);
4081 vat_json_init_object (node);
4084 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4085 vat_json_object_add_ip6 (node, "map resolver", ip6);
4089 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4090 vat_json_object_add_ip4 (node, "map resolver", ip4);
4095 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4097 vat_main_t *vam = &vat_main;
4098 i32 retval = ntohl (mp->retval);
4102 print (vam->ofp, "feature: %s\ngpe: %s",
4103 mp->feature_status ? "enabled" : "disabled",
4104 mp->gpe_status ? "enabled" : "disabled");
4107 vam->retval = retval;
4108 vam->result_ready = 1;
4112 vl_api_show_one_status_reply_t_handler_json
4113 (vl_api_show_one_status_reply_t * mp)
4115 vat_main_t *vam = &vat_main;
4116 vat_json_node_t node;
4117 u8 *gpe_status = NULL;
4118 u8 *feature_status = NULL;
4120 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4121 feature_status = format (0, "%s",
4122 mp->feature_status ? "enabled" : "disabled");
4123 vec_add1 (gpe_status, 0);
4124 vec_add1 (feature_status, 0);
4126 vat_json_init_object (&node);
4127 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4128 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4130 vec_free (gpe_status);
4131 vec_free (feature_status);
4133 vat_json_print (vam->ofp, &node);
4134 vat_json_free (&node);
4136 vam->retval = ntohl (mp->retval);
4137 vam->result_ready = 1;
4141 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4142 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4144 vat_main_t *vam = &vat_main;
4145 i32 retval = ntohl (mp->retval);
4149 print (vam->ofp, "%=20s", mp->locator_set_name);
4152 vam->retval = retval;
4153 vam->result_ready = 1;
4157 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4158 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4160 vat_main_t *vam = &vat_main;
4161 vat_json_node_t *node = NULL;
4163 if (VAT_JSON_ARRAY != vam->json_tree.type)
4165 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4166 vat_json_init_array (&vam->json_tree);
4168 node = vat_json_array_add (&vam->json_tree);
4170 vat_json_init_object (node);
4171 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4173 vat_json_print (vam->ofp, node);
4174 vat_json_free (node);
4176 vam->retval = ntohl (mp->retval);
4177 vam->result_ready = 1;
4181 format_lisp_map_request_mode (u8 * s, va_list * args)
4183 u32 mode = va_arg (*args, u32);
4188 return format (0, "dst-only");
4190 return format (0, "src-dst");
4196 vl_api_show_one_map_request_mode_reply_t_handler
4197 (vl_api_show_one_map_request_mode_reply_t * mp)
4199 vat_main_t *vam = &vat_main;
4200 i32 retval = ntohl (mp->retval);
4204 u32 mode = mp->mode;
4205 print (vam->ofp, "map_request_mode: %U",
4206 format_lisp_map_request_mode, mode);
4209 vam->retval = retval;
4210 vam->result_ready = 1;
4214 vl_api_show_one_map_request_mode_reply_t_handler_json
4215 (vl_api_show_one_map_request_mode_reply_t * mp)
4217 vat_main_t *vam = &vat_main;
4218 vat_json_node_t node;
4223 s = format (0, "%U", format_lisp_map_request_mode, mode);
4226 vat_json_init_object (&node);
4227 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4228 vat_json_print (vam->ofp, &node);
4229 vat_json_free (&node);
4232 vam->retval = ntohl (mp->retval);
4233 vam->result_ready = 1;
4237 vl_api_one_show_xtr_mode_reply_t_handler
4238 (vl_api_one_show_xtr_mode_reply_t * mp)
4240 vat_main_t *vam = &vat_main;
4241 i32 retval = ntohl (mp->retval);
4245 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4248 vam->retval = retval;
4249 vam->result_ready = 1;
4253 vl_api_one_show_xtr_mode_reply_t_handler_json
4254 (vl_api_one_show_xtr_mode_reply_t * mp)
4256 vat_main_t *vam = &vat_main;
4257 vat_json_node_t node;
4260 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4261 vec_add1 (status, 0);
4263 vat_json_init_object (&node);
4264 vat_json_object_add_string_copy (&node, "status", status);
4268 vat_json_print (vam->ofp, &node);
4269 vat_json_free (&node);
4271 vam->retval = ntohl (mp->retval);
4272 vam->result_ready = 1;
4276 vl_api_one_show_pitr_mode_reply_t_handler
4277 (vl_api_one_show_pitr_mode_reply_t * mp)
4279 vat_main_t *vam = &vat_main;
4280 i32 retval = ntohl (mp->retval);
4284 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4287 vam->retval = retval;
4288 vam->result_ready = 1;
4292 vl_api_one_show_pitr_mode_reply_t_handler_json
4293 (vl_api_one_show_pitr_mode_reply_t * mp)
4295 vat_main_t *vam = &vat_main;
4296 vat_json_node_t node;
4299 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4300 vec_add1 (status, 0);
4302 vat_json_init_object (&node);
4303 vat_json_object_add_string_copy (&node, "status", status);
4307 vat_json_print (vam->ofp, &node);
4308 vat_json_free (&node);
4310 vam->retval = ntohl (mp->retval);
4311 vam->result_ready = 1;
4315 vl_api_one_show_petr_mode_reply_t_handler
4316 (vl_api_one_show_petr_mode_reply_t * mp)
4318 vat_main_t *vam = &vat_main;
4319 i32 retval = ntohl (mp->retval);
4323 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4326 vam->retval = retval;
4327 vam->result_ready = 1;
4331 vl_api_one_show_petr_mode_reply_t_handler_json
4332 (vl_api_one_show_petr_mode_reply_t * mp)
4334 vat_main_t *vam = &vat_main;
4335 vat_json_node_t node;
4338 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4339 vec_add1 (status, 0);
4341 vat_json_init_object (&node);
4342 vat_json_object_add_string_copy (&node, "status", status);
4346 vat_json_print (vam->ofp, &node);
4347 vat_json_free (&node);
4349 vam->retval = ntohl (mp->retval);
4350 vam->result_ready = 1;
4354 vl_api_show_one_use_petr_reply_t_handler
4355 (vl_api_show_one_use_petr_reply_t * mp)
4357 vat_main_t *vam = &vat_main;
4358 i32 retval = ntohl (mp->retval);
4362 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4365 print (vam->ofp, "Proxy-ETR address; %U",
4366 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4371 vam->retval = retval;
4372 vam->result_ready = 1;
4376 vl_api_show_one_use_petr_reply_t_handler_json
4377 (vl_api_show_one_use_petr_reply_t * mp)
4379 vat_main_t *vam = &vat_main;
4380 vat_json_node_t node;
4383 struct in6_addr ip6;
4385 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4386 vec_add1 (status, 0);
4388 vat_json_init_object (&node);
4389 vat_json_object_add_string_copy (&node, "status", status);
4394 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4395 vat_json_object_add_ip6 (&node, "address", ip6);
4399 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4400 vat_json_object_add_ip4 (&node, "address", ip4);
4406 vat_json_print (vam->ofp, &node);
4407 vat_json_free (&node);
4409 vam->retval = ntohl (mp->retval);
4410 vam->result_ready = 1;
4414 vl_api_show_one_nsh_mapping_reply_t_handler
4415 (vl_api_show_one_nsh_mapping_reply_t * mp)
4417 vat_main_t *vam = &vat_main;
4418 i32 retval = ntohl (mp->retval);
4422 print (vam->ofp, "%-20s%-16s",
4423 mp->is_set ? "set" : "not-set",
4424 mp->is_set ? (char *) mp->locator_set_name : "");
4427 vam->retval = retval;
4428 vam->result_ready = 1;
4432 vl_api_show_one_nsh_mapping_reply_t_handler_json
4433 (vl_api_show_one_nsh_mapping_reply_t * mp)
4435 vat_main_t *vam = &vat_main;
4436 vat_json_node_t node;
4439 status = format (0, "%s", mp->is_set ? "yes" : "no");
4440 vec_add1 (status, 0);
4442 vat_json_init_object (&node);
4443 vat_json_object_add_string_copy (&node, "is_set", status);
4446 vat_json_object_add_string_copy (&node, "locator_set",
4447 mp->locator_set_name);
4452 vat_json_print (vam->ofp, &node);
4453 vat_json_free (&node);
4455 vam->retval = ntohl (mp->retval);
4456 vam->result_ready = 1;
4460 vl_api_show_one_map_register_ttl_reply_t_handler
4461 (vl_api_show_one_map_register_ttl_reply_t * mp)
4463 vat_main_t *vam = &vat_main;
4464 i32 retval = ntohl (mp->retval);
4466 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4470 print (vam->ofp, "ttl: %u", mp->ttl);
4473 vam->retval = retval;
4474 vam->result_ready = 1;
4478 vl_api_show_one_map_register_ttl_reply_t_handler_json
4479 (vl_api_show_one_map_register_ttl_reply_t * mp)
4481 vat_main_t *vam = &vat_main;
4482 vat_json_node_t node;
4484 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4485 vat_json_init_object (&node);
4486 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4488 vat_json_print (vam->ofp, &node);
4489 vat_json_free (&node);
4491 vam->retval = ntohl (mp->retval);
4492 vam->result_ready = 1;
4496 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4498 vat_main_t *vam = &vat_main;
4499 i32 retval = ntohl (mp->retval);
4503 print (vam->ofp, "%-20s%-16s",
4504 mp->status ? "enabled" : "disabled",
4505 mp->status ? (char *) mp->locator_set_name : "");
4508 vam->retval = retval;
4509 vam->result_ready = 1;
4513 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4515 vat_main_t *vam = &vat_main;
4516 vat_json_node_t node;
4519 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4520 vec_add1 (status, 0);
4522 vat_json_init_object (&node);
4523 vat_json_object_add_string_copy (&node, "status", status);
4526 vat_json_object_add_string_copy (&node, "locator_set",
4527 mp->locator_set_name);
4532 vat_json_print (vam->ofp, &node);
4533 vat_json_free (&node);
4535 vam->retval = ntohl (mp->retval);
4536 vam->result_ready = 1;
4540 format_policer_type (u8 * s, va_list * va)
4542 u32 i = va_arg (*va, u32);
4544 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4545 s = format (s, "1r2c");
4546 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4547 s = format (s, "1r3c");
4548 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4549 s = format (s, "2r3c-2698");
4550 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4551 s = format (s, "2r3c-4115");
4552 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4553 s = format (s, "2r3c-mef5cf1");
4555 s = format (s, "ILLEGAL");
4560 format_policer_rate_type (u8 * s, va_list * va)
4562 u32 i = va_arg (*va, u32);
4564 if (i == SSE2_QOS_RATE_KBPS)
4565 s = format (s, "kbps");
4566 else if (i == SSE2_QOS_RATE_PPS)
4567 s = format (s, "pps");
4569 s = format (s, "ILLEGAL");
4574 format_policer_round_type (u8 * s, va_list * va)
4576 u32 i = va_arg (*va, u32);
4578 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4579 s = format (s, "closest");
4580 else if (i == SSE2_QOS_ROUND_TO_UP)
4581 s = format (s, "up");
4582 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4583 s = format (s, "down");
4585 s = format (s, "ILLEGAL");
4590 format_policer_action_type (u8 * s, va_list * va)
4592 u32 i = va_arg (*va, u32);
4594 if (i == SSE2_QOS_ACTION_DROP)
4595 s = format (s, "drop");
4596 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4597 s = format (s, "transmit");
4598 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4599 s = format (s, "mark-and-transmit");
4601 s = format (s, "ILLEGAL");
4606 format_dscp (u8 * s, va_list * va)
4608 u32 i = va_arg (*va, u32);
4613 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4617 return format (s, "ILLEGAL");
4619 s = format (s, "%s", t);
4624 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4626 vat_main_t *vam = &vat_main;
4627 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4629 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4630 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4632 conform_dscp_str = format (0, "");
4634 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4635 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4637 exceed_dscp_str = format (0, "");
4639 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4640 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4642 violate_dscp_str = format (0, "");
4644 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4645 "rate type %U, round type %U, %s rate, %s color-aware, "
4646 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4647 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4648 "conform action %U%s, exceed action %U%s, violate action %U%s",
4650 format_policer_type, mp->type,
4653 clib_net_to_host_u64 (mp->cb),
4654 clib_net_to_host_u64 (mp->eb),
4655 format_policer_rate_type, mp->rate_type,
4656 format_policer_round_type, mp->round_type,
4657 mp->single_rate ? "single" : "dual",
4658 mp->color_aware ? "is" : "not",
4659 ntohl (mp->cir_tokens_per_period),
4660 ntohl (mp->pir_tokens_per_period),
4662 ntohl (mp->current_limit),
4663 ntohl (mp->current_bucket),
4664 ntohl (mp->extended_limit),
4665 ntohl (mp->extended_bucket),
4666 clib_net_to_host_u64 (mp->last_update_time),
4667 format_policer_action_type, mp->conform_action_type,
4669 format_policer_action_type, mp->exceed_action_type,
4671 format_policer_action_type, mp->violate_action_type,
4674 vec_free (conform_dscp_str);
4675 vec_free (exceed_dscp_str);
4676 vec_free (violate_dscp_str);
4679 static void vl_api_policer_details_t_handler_json
4680 (vl_api_policer_details_t * mp)
4682 vat_main_t *vam = &vat_main;
4683 vat_json_node_t *node;
4684 u8 *rate_type_str, *round_type_str, *type_str;
4685 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4687 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4689 format (0, "%U", format_policer_round_type, mp->round_type);
4690 type_str = format (0, "%U", format_policer_type, mp->type);
4691 conform_action_str = format (0, "%U", format_policer_action_type,
4692 mp->conform_action_type);
4693 exceed_action_str = format (0, "%U", format_policer_action_type,
4694 mp->exceed_action_type);
4695 violate_action_str = format (0, "%U", format_policer_action_type,
4696 mp->violate_action_type);
4698 if (VAT_JSON_ARRAY != vam->json_tree.type)
4700 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4701 vat_json_init_array (&vam->json_tree);
4703 node = vat_json_array_add (&vam->json_tree);
4705 vat_json_init_object (node);
4706 vat_json_object_add_string_copy (node, "name", mp->name);
4707 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4708 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4709 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4710 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4711 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4712 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4713 vat_json_object_add_string_copy (node, "type", type_str);
4714 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4715 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4716 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4717 vat_json_object_add_uint (node, "cir_tokens_per_period",
4718 ntohl (mp->cir_tokens_per_period));
4719 vat_json_object_add_uint (node, "eir_tokens_per_period",
4720 ntohl (mp->pir_tokens_per_period));
4721 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4722 vat_json_object_add_uint (node, "current_bucket",
4723 ntohl (mp->current_bucket));
4724 vat_json_object_add_uint (node, "extended_limit",
4725 ntohl (mp->extended_limit));
4726 vat_json_object_add_uint (node, "extended_bucket",
4727 ntohl (mp->extended_bucket));
4728 vat_json_object_add_uint (node, "last_update_time",
4729 ntohl (mp->last_update_time));
4730 vat_json_object_add_string_copy (node, "conform_action",
4731 conform_action_str);
4732 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4734 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4735 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4736 vec_free (dscp_str);
4738 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4739 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4741 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4742 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4743 vec_free (dscp_str);
4745 vat_json_object_add_string_copy (node, "violate_action",
4746 violate_action_str);
4747 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4749 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4750 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4751 vec_free (dscp_str);
4754 vec_free (rate_type_str);
4755 vec_free (round_type_str);
4756 vec_free (type_str);
4757 vec_free (conform_action_str);
4758 vec_free (exceed_action_str);
4759 vec_free (violate_action_str);
4763 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4766 vat_main_t *vam = &vat_main;
4767 int i, count = ntohl (mp->count);
4770 print (vam->ofp, "classify table ids (%d) : ", count);
4771 for (i = 0; i < count; i++)
4773 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4774 print (vam->ofp, (i < count - 1) ? "," : "");
4776 vam->retval = ntohl (mp->retval);
4777 vam->result_ready = 1;
4781 vl_api_classify_table_ids_reply_t_handler_json
4782 (vl_api_classify_table_ids_reply_t * mp)
4784 vat_main_t *vam = &vat_main;
4785 int i, count = ntohl (mp->count);
4789 vat_json_node_t node;
4791 vat_json_init_object (&node);
4792 for (i = 0; i < count; i++)
4794 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4796 vat_json_print (vam->ofp, &node);
4797 vat_json_free (&node);
4799 vam->retval = ntohl (mp->retval);
4800 vam->result_ready = 1;
4804 vl_api_classify_table_by_interface_reply_t_handler
4805 (vl_api_classify_table_by_interface_reply_t * mp)
4807 vat_main_t *vam = &vat_main;
4810 table_id = ntohl (mp->l2_table_id);
4812 print (vam->ofp, "l2 table id : %d", table_id);
4814 print (vam->ofp, "l2 table id : No input ACL tables configured");
4815 table_id = ntohl (mp->ip4_table_id);
4817 print (vam->ofp, "ip4 table id : %d", table_id);
4819 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4820 table_id = ntohl (mp->ip6_table_id);
4822 print (vam->ofp, "ip6 table id : %d", table_id);
4824 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4825 vam->retval = ntohl (mp->retval);
4826 vam->result_ready = 1;
4830 vl_api_classify_table_by_interface_reply_t_handler_json
4831 (vl_api_classify_table_by_interface_reply_t * mp)
4833 vat_main_t *vam = &vat_main;
4834 vat_json_node_t node;
4836 vat_json_init_object (&node);
4838 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4839 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4840 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4842 vat_json_print (vam->ofp, &node);
4843 vat_json_free (&node);
4845 vam->retval = ntohl (mp->retval);
4846 vam->result_ready = 1;
4849 static void vl_api_policer_add_del_reply_t_handler
4850 (vl_api_policer_add_del_reply_t * mp)
4852 vat_main_t *vam = &vat_main;
4853 i32 retval = ntohl (mp->retval);
4854 if (vam->async_mode)
4856 vam->async_errors += (retval < 0);
4860 vam->retval = retval;
4861 vam->result_ready = 1;
4862 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4864 * Note: this is just barely thread-safe, depends on
4865 * the main thread spinning waiting for an answer...
4867 errmsg ("policer index %d", ntohl (mp->policer_index));
4871 static void vl_api_policer_add_del_reply_t_handler_json
4872 (vl_api_policer_add_del_reply_t * mp)
4874 vat_main_t *vam = &vat_main;
4875 vat_json_node_t node;
4877 vat_json_init_object (&node);
4878 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4879 vat_json_object_add_uint (&node, "policer_index",
4880 ntohl (mp->policer_index));
4882 vat_json_print (vam->ofp, &node);
4883 vat_json_free (&node);
4885 vam->retval = ntohl (mp->retval);
4886 vam->result_ready = 1;
4889 /* Format hex dump. */
4891 format_hex_bytes (u8 * s, va_list * va)
4893 u8 *bytes = va_arg (*va, u8 *);
4894 int n_bytes = va_arg (*va, int);
4897 /* Print short or long form depending on byte count. */
4898 uword short_form = n_bytes <= 32;
4899 u32 indent = format_get_indent (s);
4904 for (i = 0; i < n_bytes; i++)
4906 if (!short_form && (i % 32) == 0)
4907 s = format (s, "%08x: ", i);
4908 s = format (s, "%02x", bytes[i]);
4909 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4910 s = format (s, "\n%U", format_white_space, indent);
4917 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4920 vat_main_t *vam = &vat_main;
4921 i32 retval = ntohl (mp->retval);
4924 print (vam->ofp, "classify table info :");
4925 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4926 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4927 ntohl (mp->miss_next_index));
4928 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4929 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4930 ntohl (mp->match_n_vectors));
4931 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4932 ntohl (mp->mask_length));
4934 vam->retval = retval;
4935 vam->result_ready = 1;
4939 vl_api_classify_table_info_reply_t_handler_json
4940 (vl_api_classify_table_info_reply_t * mp)
4942 vat_main_t *vam = &vat_main;
4943 vat_json_node_t node;
4945 i32 retval = ntohl (mp->retval);
4948 vat_json_init_object (&node);
4950 vat_json_object_add_int (&node, "sessions",
4951 ntohl (mp->active_sessions));
4952 vat_json_object_add_int (&node, "nexttbl",
4953 ntohl (mp->next_table_index));
4954 vat_json_object_add_int (&node, "nextnode",
4955 ntohl (mp->miss_next_index));
4956 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4957 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4958 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4959 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4960 ntohl (mp->mask_length), 0);
4961 vat_json_object_add_string_copy (&node, "mask", s);
4963 vat_json_print (vam->ofp, &node);
4964 vat_json_free (&node);
4966 vam->retval = ntohl (mp->retval);
4967 vam->result_ready = 1;
4971 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4974 vat_main_t *vam = &vat_main;
4976 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4977 ntohl (mp->hit_next_index), ntohl (mp->advance),
4978 ntohl (mp->opaque_index));
4979 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4980 ntohl (mp->match_length));
4984 vl_api_classify_session_details_t_handler_json
4985 (vl_api_classify_session_details_t * mp)
4987 vat_main_t *vam = &vat_main;
4988 vat_json_node_t *node = NULL;
4990 if (VAT_JSON_ARRAY != vam->json_tree.type)
4992 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4993 vat_json_init_array (&vam->json_tree);
4995 node = vat_json_array_add (&vam->json_tree);
4997 vat_json_init_object (node);
4998 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
4999 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
5000 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
5002 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
5004 vat_json_object_add_string_copy (node, "match", s);
5007 static void vl_api_pg_create_interface_reply_t_handler
5008 (vl_api_pg_create_interface_reply_t * mp)
5010 vat_main_t *vam = &vat_main;
5012 vam->retval = ntohl (mp->retval);
5013 vam->result_ready = 1;
5016 static void vl_api_pg_create_interface_reply_t_handler_json
5017 (vl_api_pg_create_interface_reply_t * mp)
5019 vat_main_t *vam = &vat_main;
5020 vat_json_node_t node;
5022 i32 retval = ntohl (mp->retval);
5025 vat_json_init_object (&node);
5027 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
5029 vat_json_print (vam->ofp, &node);
5030 vat_json_free (&node);
5032 vam->retval = ntohl (mp->retval);
5033 vam->result_ready = 1;
5036 static void vl_api_policer_classify_details_t_handler
5037 (vl_api_policer_classify_details_t * mp)
5039 vat_main_t *vam = &vat_main;
5041 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5042 ntohl (mp->table_index));
5045 static void vl_api_policer_classify_details_t_handler_json
5046 (vl_api_policer_classify_details_t * mp)
5048 vat_main_t *vam = &vat_main;
5049 vat_json_node_t *node;
5051 if (VAT_JSON_ARRAY != vam->json_tree.type)
5053 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5054 vat_json_init_array (&vam->json_tree);
5056 node = vat_json_array_add (&vam->json_tree);
5058 vat_json_init_object (node);
5059 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5060 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5063 static void vl_api_ipsec_gre_tunnel_add_del_reply_t_handler
5064 (vl_api_ipsec_gre_tunnel_add_del_reply_t * mp)
5066 vat_main_t *vam = &vat_main;
5067 i32 retval = ntohl (mp->retval);
5068 if (vam->async_mode)
5070 vam->async_errors += (retval < 0);
5074 vam->retval = retval;
5075 vam->sw_if_index = ntohl (mp->sw_if_index);
5076 vam->result_ready = 1;
5078 vam->regenerate_interface_table = 1;
5081 static void vl_api_ipsec_gre_tunnel_add_del_reply_t_handler_json
5082 (vl_api_ipsec_gre_tunnel_add_del_reply_t * mp)
5084 vat_main_t *vam = &vat_main;
5085 vat_json_node_t node;
5087 vat_json_init_object (&node);
5088 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5089 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
5091 vat_json_print (vam->ofp, &node);
5092 vat_json_free (&node);
5094 vam->retval = ntohl (mp->retval);
5095 vam->result_ready = 1;
5098 static void vl_api_flow_classify_details_t_handler
5099 (vl_api_flow_classify_details_t * mp)
5101 vat_main_t *vam = &vat_main;
5103 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5104 ntohl (mp->table_index));
5107 static void vl_api_flow_classify_details_t_handler_json
5108 (vl_api_flow_classify_details_t * mp)
5110 vat_main_t *vam = &vat_main;
5111 vat_json_node_t *node;
5113 if (VAT_JSON_ARRAY != vam->json_tree.type)
5115 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5116 vat_json_init_array (&vam->json_tree);
5118 node = vat_json_array_add (&vam->json_tree);
5120 vat_json_init_object (node);
5121 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5122 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5125 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5126 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5127 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5128 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5129 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5130 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5131 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5132 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5133 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5134 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5137 * Generate boilerplate reply handlers, which
5138 * dig the return value out of the xxx_reply_t API message,
5139 * stick it into vam->retval, and set vam->result_ready
5141 * Could also do this by pointing N message decode slots at
5142 * a single function, but that could break in subtle ways.
5145 #define foreach_standard_reply_retval_handler \
5146 _(sw_interface_set_flags_reply) \
5147 _(sw_interface_add_del_address_reply) \
5148 _(sw_interface_set_rx_mode_reply) \
5149 _(sw_interface_set_rx_placement_reply) \
5150 _(sw_interface_set_table_reply) \
5151 _(sw_interface_set_mpls_enable_reply) \
5152 _(sw_interface_set_vpath_reply) \
5153 _(sw_interface_set_vxlan_bypass_reply) \
5154 _(sw_interface_set_geneve_bypass_reply) \
5155 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5156 _(sw_interface_set_l2_bridge_reply) \
5157 _(bridge_domain_add_del_reply) \
5158 _(sw_interface_set_l2_xconnect_reply) \
5159 _(l2fib_add_del_reply) \
5160 _(l2fib_flush_int_reply) \
5161 _(l2fib_flush_bd_reply) \
5162 _(ip_add_del_route_reply) \
5163 _(ip_table_add_del_reply) \
5164 _(ip_mroute_add_del_reply) \
5165 _(mpls_route_add_del_reply) \
5166 _(mpls_table_add_del_reply) \
5167 _(mpls_ip_bind_unbind_reply) \
5168 _(bier_route_add_del_reply) \
5169 _(bier_table_add_del_reply) \
5170 _(proxy_arp_add_del_reply) \
5171 _(proxy_arp_intfc_enable_disable_reply) \
5172 _(sw_interface_set_unnumbered_reply) \
5173 _(ip_neighbor_add_del_reply) \
5174 _(reset_fib_reply) \
5175 _(dhcp_proxy_config_reply) \
5176 _(dhcp_proxy_set_vss_reply) \
5177 _(dhcp_client_config_reply) \
5178 _(set_ip_flow_hash_reply) \
5179 _(sw_interface_ip6_enable_disable_reply) \
5180 _(ip6nd_proxy_add_del_reply) \
5181 _(sw_interface_ip6nd_ra_prefix_reply) \
5182 _(sw_interface_ip6nd_ra_config_reply) \
5183 _(set_arp_neighbor_limit_reply) \
5184 _(l2_patch_add_del_reply) \
5185 _(sr_mpls_policy_add_reply) \
5186 _(sr_mpls_policy_mod_reply) \
5187 _(sr_mpls_policy_del_reply) \
5188 _(sr_policy_add_reply) \
5189 _(sr_policy_mod_reply) \
5190 _(sr_policy_del_reply) \
5191 _(sr_localsid_add_del_reply) \
5192 _(sr_steering_add_del_reply) \
5193 _(classify_add_del_session_reply) \
5194 _(classify_set_interface_ip_table_reply) \
5195 _(classify_set_interface_l2_tables_reply) \
5196 _(l2tpv3_set_tunnel_cookies_reply) \
5197 _(l2tpv3_interface_enable_disable_reply) \
5198 _(l2tpv3_set_lookup_key_reply) \
5199 _(l2_fib_clear_table_reply) \
5200 _(l2_interface_efp_filter_reply) \
5201 _(l2_interface_vlan_tag_rewrite_reply) \
5202 _(modify_vhost_user_if_reply) \
5203 _(delete_vhost_user_if_reply) \
5204 _(ip_probe_neighbor_reply) \
5205 _(ip_scan_neighbor_enable_disable_reply) \
5206 _(want_ip4_arp_events_reply) \
5207 _(want_ip6_nd_events_reply) \
5208 _(want_l2_macs_events_reply) \
5209 _(input_acl_set_interface_reply) \
5210 _(ipsec_spd_add_del_reply) \
5211 _(ipsec_interface_add_del_spd_reply) \
5212 _(ipsec_spd_entry_add_del_reply) \
5213 _(ipsec_sad_entry_add_del_reply) \
5214 _(ipsec_tunnel_if_add_del_reply) \
5215 _(ipsec_tunnel_if_set_sa_reply) \
5216 _(delete_loopback_reply) \
5217 _(bd_ip_mac_add_del_reply) \
5218 _(bd_ip_mac_flush_reply) \
5219 _(want_interface_events_reply) \
5220 _(cop_interface_enable_disable_reply) \
5221 _(cop_whitelist_enable_disable_reply) \
5222 _(sw_interface_clear_stats_reply) \
5223 _(ioam_enable_reply) \
5224 _(ioam_disable_reply) \
5225 _(one_add_del_locator_reply) \
5226 _(one_add_del_local_eid_reply) \
5227 _(one_add_del_remote_mapping_reply) \
5228 _(one_add_del_adjacency_reply) \
5229 _(one_add_del_map_resolver_reply) \
5230 _(one_add_del_map_server_reply) \
5231 _(one_enable_disable_reply) \
5232 _(one_rloc_probe_enable_disable_reply) \
5233 _(one_map_register_enable_disable_reply) \
5234 _(one_map_register_set_ttl_reply) \
5235 _(one_set_transport_protocol_reply) \
5236 _(one_map_register_fallback_threshold_reply) \
5237 _(one_pitr_set_locator_set_reply) \
5238 _(one_map_request_mode_reply) \
5239 _(one_add_del_map_request_itr_rlocs_reply) \
5240 _(one_eid_table_add_del_map_reply) \
5241 _(one_use_petr_reply) \
5242 _(one_stats_enable_disable_reply) \
5243 _(one_add_del_l2_arp_entry_reply) \
5244 _(one_add_del_ndp_entry_reply) \
5245 _(one_stats_flush_reply) \
5246 _(one_enable_disable_xtr_mode_reply) \
5247 _(one_enable_disable_pitr_mode_reply) \
5248 _(one_enable_disable_petr_mode_reply) \
5249 _(gpe_enable_disable_reply) \
5250 _(gpe_set_encap_mode_reply) \
5251 _(gpe_add_del_iface_reply) \
5252 _(gpe_add_del_native_fwd_rpath_reply) \
5253 _(af_packet_delete_reply) \
5254 _(policer_classify_set_interface_reply) \
5255 _(netmap_create_reply) \
5256 _(netmap_delete_reply) \
5257 _(set_ipfix_exporter_reply) \
5258 _(set_ipfix_classify_stream_reply) \
5259 _(ipfix_classify_table_add_del_reply) \
5260 _(flow_classify_set_interface_reply) \
5261 _(sw_interface_span_enable_disable_reply) \
5262 _(pg_capture_reply) \
5263 _(pg_enable_disable_reply) \
5264 _(ip_source_and_port_range_check_add_del_reply) \
5265 _(ip_source_and_port_range_check_interface_add_del_reply)\
5266 _(delete_subif_reply) \
5267 _(l2_interface_pbb_tag_rewrite_reply) \
5269 _(feature_enable_disable_reply) \
5270 _(sw_interface_tag_add_del_reply) \
5271 _(hw_interface_set_mtu_reply) \
5272 _(p2p_ethernet_add_reply) \
5273 _(p2p_ethernet_del_reply) \
5274 _(lldp_config_reply) \
5275 _(sw_interface_set_lldp_reply) \
5276 _(tcp_configure_src_addresses_reply) \
5277 _(dns_enable_disable_reply) \
5278 _(dns_name_server_add_del_reply) \
5279 _(session_rule_add_del_reply) \
5280 _(ip_container_proxy_add_del_reply) \
5281 _(output_acl_set_interface_reply) \
5282 _(qos_record_enable_disable_reply)
5285 static void vl_api_##n##_t_handler \
5286 (vl_api_##n##_t * mp) \
5288 vat_main_t * vam = &vat_main; \
5289 i32 retval = ntohl(mp->retval); \
5290 if (vam->async_mode) { \
5291 vam->async_errors += (retval < 0); \
5293 vam->retval = retval; \
5294 vam->result_ready = 1; \
5297 foreach_standard_reply_retval_handler;
5301 static void vl_api_##n##_t_handler_json \
5302 (vl_api_##n##_t * mp) \
5304 vat_main_t * vam = &vat_main; \
5305 vat_json_node_t node; \
5306 vat_json_init_object(&node); \
5307 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5308 vat_json_print(vam->ofp, &node); \
5309 vam->retval = ntohl(mp->retval); \
5310 vam->result_ready = 1; \
5312 foreach_standard_reply_retval_handler;
5316 * Table of message reply handlers, must include boilerplate handlers
5320 #define foreach_vpe_api_reply_msg \
5321 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5322 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5323 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5324 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5325 _(CONTROL_PING_REPLY, control_ping_reply) \
5326 _(CLI_REPLY, cli_reply) \
5327 _(CLI_INBAND_REPLY, cli_inband_reply) \
5328 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5329 sw_interface_add_del_address_reply) \
5330 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5331 _(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
5332 _(SW_INTERFACE_RX_PLACEMENT_DETAILS, sw_interface_rx_placement_details) \
5333 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5334 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5335 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5336 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5337 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5338 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5339 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5340 sw_interface_set_l2_xconnect_reply) \
5341 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5342 sw_interface_set_l2_bridge_reply) \
5343 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5344 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5345 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5346 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5347 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5348 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5349 _(L2_FLAGS_REPLY, l2_flags_reply) \
5350 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5351 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5352 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5353 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5354 _(VIRTIO_PCI_CREATE_REPLY, virtio_pci_create_reply) \
5355 _(VIRTIO_PCI_DELETE_REPLY, virtio_pci_delete_reply) \
5356 _(SW_INTERFACE_VIRTIO_PCI_DETAILS, sw_interface_virtio_pci_details) \
5357 _(BOND_CREATE_REPLY, bond_create_reply) \
5358 _(BOND_DELETE_REPLY, bond_delete_reply) \
5359 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5360 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5361 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5362 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5363 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5364 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5365 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5366 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5367 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5368 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5369 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5370 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5371 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5372 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5373 proxy_arp_intfc_enable_disable_reply) \
5374 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5375 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5376 sw_interface_set_unnumbered_reply) \
5377 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5378 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5379 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5380 _(RESET_FIB_REPLY, reset_fib_reply) \
5381 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5382 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5383 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5384 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5385 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5386 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5387 sw_interface_ip6_enable_disable_reply) \
5388 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5389 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5390 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5391 sw_interface_ip6nd_ra_prefix_reply) \
5392 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5393 sw_interface_ip6nd_ra_config_reply) \
5394 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5395 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5396 _(SR_MPLS_POLICY_ADD_REPLY, sr_mpls_policy_add_reply) \
5397 _(SR_MPLS_POLICY_MOD_REPLY, sr_mpls_policy_mod_reply) \
5398 _(SR_MPLS_POLICY_DEL_REPLY, sr_mpls_policy_del_reply) \
5399 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5400 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5401 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5402 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5403 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5404 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5405 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5406 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5407 classify_set_interface_ip_table_reply) \
5408 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5409 classify_set_interface_l2_tables_reply) \
5410 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5411 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5412 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5413 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5414 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5415 l2tpv3_interface_enable_disable_reply) \
5416 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5417 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5418 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5419 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5420 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5421 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5422 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5423 _(GRE_TUNNEL_ADD_DEL_REPLY, gre_tunnel_add_del_reply) \
5424 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5425 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5426 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5427 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5428 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5429 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5430 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5431 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5432 _(SHOW_VERSION_REPLY, show_version_reply) \
5433 _(SHOW_THREADS_REPLY, show_threads_reply) \
5434 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5435 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5436 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5437 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5438 _(IP_PROBE_NEIGHBOR_REPLY, ip_probe_neighbor_reply) \
5439 _(IP_SCAN_NEIGHBOR_ENABLE_DISABLE_REPLY, ip_scan_neighbor_enable_disable_reply) \
5440 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5441 _(IP4_ARP_EVENT, ip4_arp_event) \
5442 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5443 _(IP6_ND_EVENT, ip6_nd_event) \
5444 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5445 _(L2_MACS_EVENT, l2_macs_event) \
5446 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5447 _(IP_ADDRESS_DETAILS, ip_address_details) \
5448 _(IP_DETAILS, ip_details) \
5449 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5450 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5451 _(IPSEC_SPD_ENTRY_ADD_DEL_REPLY, ipsec_spd_entry_add_del_reply) \
5452 _(IPSEC_SAD_ENTRY_ADD_DEL_REPLY, ipsec_sad_entry_add_del_reply) \
5453 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5454 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5455 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5456 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5457 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5458 _(BD_IP_MAC_FLUSH_REPLY, bd_ip_mac_flush_reply) \
5459 _(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
5460 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5461 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5462 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5463 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5464 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5465 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5466 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5467 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5468 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5469 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5470 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5471 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5472 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5473 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5474 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5475 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5476 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5477 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5478 one_map_register_enable_disable_reply) \
5479 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5480 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5481 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5482 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5483 one_map_register_fallback_threshold_reply) \
5484 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5485 one_rloc_probe_enable_disable_reply) \
5486 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5487 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5488 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5489 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5490 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5491 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5492 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5493 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5494 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5495 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5496 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5497 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5498 _(ONE_STATS_DETAILS, one_stats_details) \
5499 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5500 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5501 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5502 show_one_stats_enable_disable_reply) \
5503 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5504 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5505 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5506 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5507 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5508 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5509 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5510 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5511 one_enable_disable_pitr_mode_reply) \
5512 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5513 one_enable_disable_petr_mode_reply) \
5514 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5515 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5516 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5517 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5518 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5519 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5520 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5521 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5522 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5523 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5524 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5525 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5526 gpe_add_del_native_fwd_rpath_reply) \
5527 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5528 gpe_fwd_entry_path_details) \
5529 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5530 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5531 one_add_del_map_request_itr_rlocs_reply) \
5532 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5533 one_get_map_request_itr_rlocs_reply) \
5534 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5535 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5536 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5537 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5538 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5539 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5540 show_one_map_register_state_reply) \
5541 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5542 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5543 show_one_map_register_fallback_threshold_reply) \
5544 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5545 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5546 _(AF_PACKET_DETAILS, af_packet_details) \
5547 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5548 _(POLICER_DETAILS, policer_details) \
5549 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5550 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5551 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5552 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5553 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5554 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5555 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5556 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5557 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5558 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5559 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5560 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5561 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5562 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5563 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5564 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5565 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5566 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5567 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5568 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5569 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5570 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5571 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5572 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5573 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5574 ip_source_and_port_range_check_add_del_reply) \
5575 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5576 ip_source_and_port_range_check_interface_add_del_reply) \
5577 _(IPSEC_GRE_TUNNEL_ADD_DEL_REPLY, ipsec_gre_tunnel_add_del_reply) \
5578 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5579 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5580 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5581 _(SET_PUNT_REPLY, set_punt_reply) \
5582 _(IP_FIB_DETAILS, ip_fib_details) \
5583 _(IP6_FIB_DETAILS, ip6_fib_details) \
5584 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5585 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5586 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5587 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5588 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5589 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5590 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5591 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5592 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5593 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5594 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5595 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5596 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5597 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5598 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
5599 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \
5600 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5601 _(SESSION_RULES_DETAILS, session_rules_details) \
5602 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5603 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5604 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply)
5606 #define foreach_standalone_reply_msg \
5607 _(SW_INTERFACE_EVENT, sw_interface_event)
5615 #define STR_VTR_OP_CASE(op) \
5616 case L2_VTR_ ## op: \
5620 str_vtr_op (u32 vtr_op)
5624 STR_VTR_OP_CASE (DISABLED);
5625 STR_VTR_OP_CASE (PUSH_1);
5626 STR_VTR_OP_CASE (PUSH_2);
5627 STR_VTR_OP_CASE (POP_1);
5628 STR_VTR_OP_CASE (POP_2);
5629 STR_VTR_OP_CASE (TRANSLATE_1_1);
5630 STR_VTR_OP_CASE (TRANSLATE_1_2);
5631 STR_VTR_OP_CASE (TRANSLATE_2_1);
5632 STR_VTR_OP_CASE (TRANSLATE_2_2);
5639 dump_sub_interface_table (vat_main_t * vam)
5641 const sw_interface_subif_t *sub = NULL;
5643 if (vam->json_output)
5646 ("JSON output supported only for VPE API calls and dump_stats_table");
5651 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5652 "Interface", "sw_if_index",
5653 "sub id", "dot1ad", "tags", "outer id",
5654 "inner id", "exact", "default", "outer any", "inner any");
5656 vec_foreach (sub, vam->sw_if_subif_table)
5659 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5660 sub->interface_name,
5662 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5663 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5664 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5665 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5666 if (sub->vtr_op != L2_VTR_DISABLED)
5669 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5670 "tag1: %d tag2: %d ]",
5671 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5672 sub->vtr_tag1, sub->vtr_tag2);
5680 name_sort_cmp (void *a1, void *a2)
5682 name_sort_t *n1 = a1;
5683 name_sort_t *n2 = a2;
5685 return strcmp ((char *) n1->name, (char *) n2->name);
5689 dump_interface_table (vat_main_t * vam)
5692 name_sort_t *nses = 0, *ns;
5694 if (vam->json_output)
5697 ("JSON output supported only for VPE API calls and dump_stats_table");
5702 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5704 vec_add2 (nses, ns, 1);
5705 ns->name = (u8 *)(p->key);
5706 ns->value = (u32) p->value[0];
5710 vec_sort_with_function (nses, name_sort_cmp);
5712 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5713 vec_foreach (ns, nses)
5715 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5722 dump_ip_table (vat_main_t * vam, int is_ipv6)
5724 const ip_details_t *det = NULL;
5725 const ip_address_details_t *address = NULL;
5728 print (vam->ofp, "%-12s", "sw_if_index");
5730 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5737 print (vam->ofp, "%-12d", i);
5738 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5743 vec_foreach (address, det->addr)
5747 is_ipv6 ? format_ip6_address : format_ip4_address,
5748 address->ip, address->prefix_length);
5756 dump_ipv4_table (vat_main_t * vam)
5758 if (vam->json_output)
5761 ("JSON output supported only for VPE API calls and dump_stats_table");
5765 return dump_ip_table (vam, 0);
5769 dump_ipv6_table (vat_main_t * vam)
5771 if (vam->json_output)
5774 ("JSON output supported only for VPE API calls and dump_stats_table");
5778 return dump_ip_table (vam, 1);
5782 * Pass CLI buffers directly in the CLI_INBAND API message,
5783 * instead of an additional shared memory area.
5786 exec_inband (vat_main_t * vam)
5788 vl_api_cli_inband_t *mp;
5789 unformat_input_t *i = vam->input;
5792 if (vec_len (i->buffer) == 0)
5795 if (vam->exec_mode == 0 && unformat (i, "mode"))
5800 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5807 * In order for the CLI command to work, it
5808 * must be a vector ending in \n, not a C-string ending
5811 u32 len = vec_len (vam->input->buffer);
5812 M2 (CLI_INBAND, mp, len);
5813 vl_api_to_api_string (len - 1, (const char *) vam->input->buffer, &mp->cmd);
5817 /* json responses may or may not include a useful reply... */
5818 if (vec_len (vam->cmd_reply))
5819 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
5824 exec (vat_main_t * vam)
5826 return exec_inband (vam);
5830 api_create_loopback (vat_main_t * vam)
5832 unformat_input_t *i = vam->input;
5833 vl_api_create_loopback_t *mp;
5834 vl_api_create_loopback_instance_t *mp_lbi;
5837 u8 is_specified = 0;
5838 u32 user_instance = 0;
5841 clib_memset (mac_address, 0, sizeof (mac_address));
5843 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5845 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5847 if (unformat (i, "instance %d", &user_instance))
5855 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5856 mp_lbi->is_specified = is_specified;
5858 mp_lbi->user_instance = htonl (user_instance);
5860 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5865 /* Construct the API message */
5866 M (CREATE_LOOPBACK, mp);
5868 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5877 api_delete_loopback (vat_main_t * vam)
5879 unformat_input_t *i = vam->input;
5880 vl_api_delete_loopback_t *mp;
5881 u32 sw_if_index = ~0;
5884 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5886 if (unformat (i, "sw_if_index %d", &sw_if_index))
5892 if (sw_if_index == ~0)
5894 errmsg ("missing sw_if_index");
5898 /* Construct the API message */
5899 M (DELETE_LOOPBACK, mp);
5900 mp->sw_if_index = ntohl (sw_if_index);
5908 api_want_interface_events (vat_main_t * vam)
5910 unformat_input_t *i = vam->input;
5911 vl_api_want_interface_events_t *mp;
5915 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5917 if (unformat (i, "enable"))
5919 else if (unformat (i, "disable"))
5927 errmsg ("missing enable|disable");
5931 M (WANT_INTERFACE_EVENTS, mp);
5932 mp->enable_disable = enable;
5934 vam->interface_event_display = enable;
5942 /* Note: non-static, called once to set up the initial intfc table */
5944 api_sw_interface_dump (vat_main_t * vam)
5946 vl_api_sw_interface_dump_t *mp;
5947 vl_api_control_ping_t *mp_ping;
5949 name_sort_t *nses = 0, *ns;
5950 sw_interface_subif_t *sub = NULL;
5953 /* Toss the old name table */
5955 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5957 vec_add2 (nses, ns, 1);
5958 ns->name = (u8 *)(p->key);
5959 ns->value = (u32) p->value[0];
5963 hash_free (vam->sw_if_index_by_interface_name);
5965 vec_foreach (ns, nses) vec_free (ns->name);
5969 vec_foreach (sub, vam->sw_if_subif_table)
5971 vec_free (sub->interface_name);
5973 vec_free (vam->sw_if_subif_table);
5975 /* recreate the interface name hash table */
5976 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5979 * Ask for all interface names. Otherwise, the epic catalog of
5980 * name filters becomes ridiculously long, and vat ends up needing
5981 * to be taught about new interface types.
5983 M (SW_INTERFACE_DUMP, mp);
5986 /* Use a control ping for synchronization */
5987 MPING (CONTROL_PING, mp_ping);
5995 api_sw_interface_set_flags (vat_main_t * vam)
5997 unformat_input_t *i = vam->input;
5998 vl_api_sw_interface_set_flags_t *mp;
6000 u8 sw_if_index_set = 0;
6004 /* Parse args required to build the message */
6005 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6007 if (unformat (i, "admin-up"))
6009 else if (unformat (i, "admin-down"))
6012 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6013 sw_if_index_set = 1;
6014 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6015 sw_if_index_set = 1;
6020 if (sw_if_index_set == 0)
6022 errmsg ("missing interface name or sw_if_index");
6026 /* Construct the API message */
6027 M (SW_INTERFACE_SET_FLAGS, mp);
6028 mp->sw_if_index = ntohl (sw_if_index);
6029 mp->admin_up_down = admin_up;
6034 /* Wait for a reply, return the good/bad news... */
6040 api_sw_interface_set_rx_mode (vat_main_t * vam)
6042 unformat_input_t *i = vam->input;
6043 vl_api_sw_interface_set_rx_mode_t *mp;
6045 u8 sw_if_index_set = 0;
6047 u8 queue_id_valid = 0;
6049 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
6051 /* Parse args required to build the message */
6052 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6054 if (unformat (i, "queue %d", &queue_id))
6056 else if (unformat (i, "polling"))
6057 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
6058 else if (unformat (i, "interrupt"))
6059 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
6060 else if (unformat (i, "adaptive"))
6061 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
6063 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6064 sw_if_index_set = 1;
6065 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6066 sw_if_index_set = 1;
6071 if (sw_if_index_set == 0)
6073 errmsg ("missing interface name or sw_if_index");
6076 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6078 errmsg ("missing rx-mode");
6082 /* Construct the API message */
6083 M (SW_INTERFACE_SET_RX_MODE, mp);
6084 mp->sw_if_index = ntohl (sw_if_index);
6086 mp->queue_id_valid = queue_id_valid;
6087 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6092 /* Wait for a reply, return the good/bad news... */
6098 api_sw_interface_set_rx_placement (vat_main_t * vam)
6100 unformat_input_t *i = vam->input;
6101 vl_api_sw_interface_set_rx_placement_t *mp;
6103 u8 sw_if_index_set = 0;
6106 u32 queue_id, thread_index;
6108 /* Parse args required to build the message */
6109 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6111 if (unformat (i, "queue %d", &queue_id))
6113 else if (unformat (i, "main"))
6115 else if (unformat (i, "worker %d", &thread_index))
6118 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6119 sw_if_index_set = 1;
6120 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6121 sw_if_index_set = 1;
6126 if (sw_if_index_set == 0)
6128 errmsg ("missing interface name or sw_if_index");
6134 /* Construct the API message */
6135 M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
6136 mp->sw_if_index = ntohl (sw_if_index);
6137 mp->worker_id = ntohl (thread_index);
6138 mp->queue_id = ntohl (queue_id);
6139 mp->is_main = is_main;
6143 /* Wait for a reply, return the good/bad news... */
6148 static void vl_api_sw_interface_rx_placement_details_t_handler
6149 (vl_api_sw_interface_rx_placement_details_t * mp)
6151 vat_main_t *vam = &vat_main;
6152 u32 worker_id = ntohl (mp->worker_id);
6155 "\n%-11d %-11s %-6d %-5d %-9s",
6156 ntohl (mp->sw_if_index), (worker_id == 0) ? "main" : "worker",
6157 worker_id, ntohl (mp->queue_id),
6159 1) ? "polling" : ((mp->mode == 2) ? "interrupt" : "adaptive"));
6162 static void vl_api_sw_interface_rx_placement_details_t_handler_json
6163 (vl_api_sw_interface_rx_placement_details_t * mp)
6165 vat_main_t *vam = &vat_main;
6166 vat_json_node_t *node = NULL;
6168 if (VAT_JSON_ARRAY != vam->json_tree.type)
6170 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
6171 vat_json_init_array (&vam->json_tree);
6173 node = vat_json_array_add (&vam->json_tree);
6175 vat_json_init_object (node);
6176 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
6177 vat_json_object_add_uint (node, "worker_id", ntohl (mp->worker_id));
6178 vat_json_object_add_uint (node, "queue_id", ntohl (mp->queue_id));
6179 vat_json_object_add_uint (node, "mode", mp->mode);
6183 api_sw_interface_rx_placement_dump (vat_main_t * vam)
6185 unformat_input_t *i = vam->input;
6186 vl_api_sw_interface_rx_placement_dump_t *mp;
6187 vl_api_control_ping_t *mp_ping;
6190 u8 sw_if_index_set = 0;
6192 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6194 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6196 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6203 "\n%-11s %-11s %-6s %-5s %-4s",
6204 "sw_if_index", "main/worker", "thread", "queue", "mode");
6206 /* Dump Interface rx placement */
6207 M (SW_INTERFACE_RX_PLACEMENT_DUMP, mp);
6209 if (sw_if_index_set)
6210 mp->sw_if_index = htonl (sw_if_index);
6212 mp->sw_if_index = ~0;
6216 /* Use a control ping for synchronization */
6217 MPING (CONTROL_PING, mp_ping);
6225 api_sw_interface_clear_stats (vat_main_t * vam)
6227 unformat_input_t *i = vam->input;
6228 vl_api_sw_interface_clear_stats_t *mp;
6230 u8 sw_if_index_set = 0;
6233 /* Parse args required to build the message */
6234 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6236 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6237 sw_if_index_set = 1;
6238 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6239 sw_if_index_set = 1;
6244 /* Construct the API message */
6245 M (SW_INTERFACE_CLEAR_STATS, mp);
6247 if (sw_if_index_set == 1)
6248 mp->sw_if_index = ntohl (sw_if_index);
6250 mp->sw_if_index = ~0;
6255 /* Wait for a reply, return the good/bad news... */
6261 api_sw_interface_add_del_address (vat_main_t * vam)
6263 unformat_input_t *i = vam->input;
6264 vl_api_sw_interface_add_del_address_t *mp;
6266 u8 sw_if_index_set = 0;
6267 u8 is_add = 1, del_all = 0;
6268 u32 address_length = 0;
6269 u8 v4_address_set = 0;
6270 u8 v6_address_set = 0;
6271 ip4_address_t v4address;
6272 ip6_address_t v6address;
6275 /* Parse args required to build the message */
6276 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6278 if (unformat (i, "del-all"))
6280 else if (unformat (i, "del"))
6283 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6284 sw_if_index_set = 1;
6285 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6286 sw_if_index_set = 1;
6287 else if (unformat (i, "%U/%d",
6288 unformat_ip4_address, &v4address, &address_length))
6290 else if (unformat (i, "%U/%d",
6291 unformat_ip6_address, &v6address, &address_length))
6297 if (sw_if_index_set == 0)
6299 errmsg ("missing interface name or sw_if_index");
6302 if (v4_address_set && v6_address_set)
6304 errmsg ("both v4 and v6 addresses set");
6307 if (!v4_address_set && !v6_address_set && !del_all)
6309 errmsg ("no addresses set");
6313 /* Construct the API message */
6314 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6316 mp->sw_if_index = ntohl (sw_if_index);
6317 mp->is_add = is_add;
6318 mp->del_all = del_all;
6322 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6326 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6328 mp->address_length = address_length;
6333 /* Wait for a reply, return good/bad news */
6339 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6341 unformat_input_t *i = vam->input;
6342 vl_api_sw_interface_set_mpls_enable_t *mp;
6344 u8 sw_if_index_set = 0;
6348 /* Parse args required to build the message */
6349 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6351 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6352 sw_if_index_set = 1;
6353 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6354 sw_if_index_set = 1;
6355 else if (unformat (i, "disable"))
6357 else if (unformat (i, "dis"))
6363 if (sw_if_index_set == 0)
6365 errmsg ("missing interface name or sw_if_index");
6369 /* Construct the API message */
6370 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6372 mp->sw_if_index = ntohl (sw_if_index);
6373 mp->enable = enable;
6378 /* Wait for a reply... */
6384 api_sw_interface_set_table (vat_main_t * vam)
6386 unformat_input_t *i = vam->input;
6387 vl_api_sw_interface_set_table_t *mp;
6388 u32 sw_if_index, vrf_id = 0;
6389 u8 sw_if_index_set = 0;
6393 /* Parse args required to build the message */
6394 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6396 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6397 sw_if_index_set = 1;
6398 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6399 sw_if_index_set = 1;
6400 else if (unformat (i, "vrf %d", &vrf_id))
6402 else if (unformat (i, "ipv6"))
6408 if (sw_if_index_set == 0)
6410 errmsg ("missing interface name or sw_if_index");
6414 /* Construct the API message */
6415 M (SW_INTERFACE_SET_TABLE, mp);
6417 mp->sw_if_index = ntohl (sw_if_index);
6418 mp->is_ipv6 = is_ipv6;
6419 mp->vrf_id = ntohl (vrf_id);
6424 /* Wait for a reply... */
6429 static void vl_api_sw_interface_get_table_reply_t_handler
6430 (vl_api_sw_interface_get_table_reply_t * mp)
6432 vat_main_t *vam = &vat_main;
6434 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6436 vam->retval = ntohl (mp->retval);
6437 vam->result_ready = 1;
6441 static void vl_api_sw_interface_get_table_reply_t_handler_json
6442 (vl_api_sw_interface_get_table_reply_t * mp)
6444 vat_main_t *vam = &vat_main;
6445 vat_json_node_t node;
6447 vat_json_init_object (&node);
6448 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6449 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6451 vat_json_print (vam->ofp, &node);
6452 vat_json_free (&node);
6454 vam->retval = ntohl (mp->retval);
6455 vam->result_ready = 1;
6459 api_sw_interface_get_table (vat_main_t * vam)
6461 unformat_input_t *i = vam->input;
6462 vl_api_sw_interface_get_table_t *mp;
6464 u8 sw_if_index_set = 0;
6468 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6470 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6471 sw_if_index_set = 1;
6472 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6473 sw_if_index_set = 1;
6474 else if (unformat (i, "ipv6"))
6480 if (sw_if_index_set == 0)
6482 errmsg ("missing interface name or sw_if_index");
6486 M (SW_INTERFACE_GET_TABLE, mp);
6487 mp->sw_if_index = htonl (sw_if_index);
6488 mp->is_ipv6 = is_ipv6;
6496 api_sw_interface_set_vpath (vat_main_t * vam)
6498 unformat_input_t *i = vam->input;
6499 vl_api_sw_interface_set_vpath_t *mp;
6500 u32 sw_if_index = 0;
6501 u8 sw_if_index_set = 0;
6505 /* Parse args required to build the message */
6506 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6508 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6509 sw_if_index_set = 1;
6510 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6511 sw_if_index_set = 1;
6512 else if (unformat (i, "enable"))
6514 else if (unformat (i, "disable"))
6520 if (sw_if_index_set == 0)
6522 errmsg ("missing interface name or sw_if_index");
6526 /* Construct the API message */
6527 M (SW_INTERFACE_SET_VPATH, mp);
6529 mp->sw_if_index = ntohl (sw_if_index);
6530 mp->enable = is_enable;
6535 /* Wait for a reply... */
6541 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6543 unformat_input_t *i = vam->input;
6544 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6545 u32 sw_if_index = 0;
6546 u8 sw_if_index_set = 0;
6551 /* Parse args required to build the message */
6552 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6554 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6555 sw_if_index_set = 1;
6556 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6557 sw_if_index_set = 1;
6558 else if (unformat (i, "enable"))
6560 else if (unformat (i, "disable"))
6562 else if (unformat (i, "ip4"))
6564 else if (unformat (i, "ip6"))
6570 if (sw_if_index_set == 0)
6572 errmsg ("missing interface name or sw_if_index");
6576 /* Construct the API message */
6577 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6579 mp->sw_if_index = ntohl (sw_if_index);
6580 mp->enable = is_enable;
6581 mp->is_ipv6 = is_ipv6;
6586 /* Wait for a reply... */
6592 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6594 unformat_input_t *i = vam->input;
6595 vl_api_sw_interface_set_geneve_bypass_t *mp;
6596 u32 sw_if_index = 0;
6597 u8 sw_if_index_set = 0;
6602 /* Parse args required to build the message */
6603 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6605 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6606 sw_if_index_set = 1;
6607 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6608 sw_if_index_set = 1;
6609 else if (unformat (i, "enable"))
6611 else if (unformat (i, "disable"))
6613 else if (unformat (i, "ip4"))
6615 else if (unformat (i, "ip6"))
6621 if (sw_if_index_set == 0)
6623 errmsg ("missing interface name or sw_if_index");
6627 /* Construct the API message */
6628 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6630 mp->sw_if_index = ntohl (sw_if_index);
6631 mp->enable = is_enable;
6632 mp->is_ipv6 = is_ipv6;
6637 /* Wait for a reply... */
6643 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6645 unformat_input_t *i = vam->input;
6646 vl_api_sw_interface_set_l2_xconnect_t *mp;
6648 u8 rx_sw_if_index_set = 0;
6650 u8 tx_sw_if_index_set = 0;
6654 /* Parse args required to build the message */
6655 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6657 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6658 rx_sw_if_index_set = 1;
6659 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6660 tx_sw_if_index_set = 1;
6661 else if (unformat (i, "rx"))
6663 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6665 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6667 rx_sw_if_index_set = 1;
6672 else if (unformat (i, "tx"))
6674 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6676 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6678 tx_sw_if_index_set = 1;
6683 else if (unformat (i, "enable"))
6685 else if (unformat (i, "disable"))
6691 if (rx_sw_if_index_set == 0)
6693 errmsg ("missing rx interface name or rx_sw_if_index");
6697 if (enable && (tx_sw_if_index_set == 0))
6699 errmsg ("missing tx interface name or tx_sw_if_index");
6703 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6705 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6706 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6707 mp->enable = enable;
6715 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6717 unformat_input_t *i = vam->input;
6718 vl_api_sw_interface_set_l2_bridge_t *mp;
6719 vl_api_l2_port_type_t port_type;
6721 u8 rx_sw_if_index_set = 0;
6728 port_type = L2_API_PORT_TYPE_NORMAL;
6730 /* Parse args required to build the message */
6731 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6733 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6734 rx_sw_if_index_set = 1;
6735 else if (unformat (i, "bd_id %d", &bd_id))
6739 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6740 rx_sw_if_index_set = 1;
6741 else if (unformat (i, "shg %d", &shg))
6743 else if (unformat (i, "bvi"))
6744 port_type = L2_API_PORT_TYPE_BVI;
6745 else if (unformat (i, "uu-fwd"))
6746 port_type = L2_API_PORT_TYPE_UU_FWD;
6747 else if (unformat (i, "enable"))
6749 else if (unformat (i, "disable"))
6755 if (rx_sw_if_index_set == 0)
6757 errmsg ("missing rx interface name or sw_if_index");
6761 if (enable && (bd_id_set == 0))
6763 errmsg ("missing bridge domain");
6767 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6769 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6770 mp->bd_id = ntohl (bd_id);
6772 mp->port_type = ntohl (port_type);
6773 mp->enable = enable;
6781 api_bridge_domain_dump (vat_main_t * vam)
6783 unformat_input_t *i = vam->input;
6784 vl_api_bridge_domain_dump_t *mp;
6785 vl_api_control_ping_t *mp_ping;
6789 /* Parse args required to build the message */
6790 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6792 if (unformat (i, "bd_id %d", &bd_id))
6798 M (BRIDGE_DOMAIN_DUMP, mp);
6799 mp->bd_id = ntohl (bd_id);
6802 /* Use a control ping for synchronization */
6803 MPING (CONTROL_PING, mp_ping);
6811 api_bridge_domain_add_del (vat_main_t * vam)
6813 unformat_input_t *i = vam->input;
6814 vl_api_bridge_domain_add_del_t *mp;
6817 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6822 /* Parse args required to build the message */
6823 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6825 if (unformat (i, "bd_id %d", &bd_id))
6827 else if (unformat (i, "flood %d", &flood))
6829 else if (unformat (i, "uu-flood %d", &uu_flood))
6831 else if (unformat (i, "forward %d", &forward))
6833 else if (unformat (i, "learn %d", &learn))
6835 else if (unformat (i, "arp-term %d", &arp_term))
6837 else if (unformat (i, "mac-age %d", &mac_age))
6839 else if (unformat (i, "bd-tag %s", &bd_tag))
6841 else if (unformat (i, "del"))
6844 flood = uu_flood = forward = learn = 0;
6852 errmsg ("missing bridge domain");
6859 errmsg ("mac age must be less than 256 ");
6864 if ((bd_tag) && (vec_len (bd_tag) > 63))
6866 errmsg ("bd-tag cannot be longer than 63");
6871 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6873 mp->bd_id = ntohl (bd_id);
6875 mp->uu_flood = uu_flood;
6876 mp->forward = forward;
6878 mp->arp_term = arp_term;
6879 mp->is_add = is_add;
6880 mp->mac_age = (u8) mac_age;
6883 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
6884 mp->bd_tag[vec_len (bd_tag)] = 0;
6895 api_l2fib_flush_bd (vat_main_t * vam)
6897 unformat_input_t *i = vam->input;
6898 vl_api_l2fib_flush_bd_t *mp;
6902 /* Parse args required to build the message */
6903 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6905 if (unformat (i, "bd_id %d", &bd_id));
6912 errmsg ("missing bridge domain");
6916 M (L2FIB_FLUSH_BD, mp);
6918 mp->bd_id = htonl (bd_id);
6926 api_l2fib_flush_int (vat_main_t * vam)
6928 unformat_input_t *i = vam->input;
6929 vl_api_l2fib_flush_int_t *mp;
6930 u32 sw_if_index = ~0;
6933 /* Parse args required to build the message */
6934 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6936 if (unformat (i, "sw_if_index %d", &sw_if_index));
6938 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6943 if (sw_if_index == ~0)
6945 errmsg ("missing interface name or sw_if_index");
6949 M (L2FIB_FLUSH_INT, mp);
6951 mp->sw_if_index = ntohl (sw_if_index);
6959 api_l2fib_add_del (vat_main_t * vam)
6961 unformat_input_t *i = vam->input;
6962 vl_api_l2fib_add_del_t *mp;
6968 u32 sw_if_index = 0;
6969 u8 sw_if_index_set = 0;
6978 /* Parse args required to build the message */
6979 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6981 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
6983 else if (unformat (i, "bd_id %d", &bd_id))
6985 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6986 sw_if_index_set = 1;
6987 else if (unformat (i, "sw_if"))
6989 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6992 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6993 sw_if_index_set = 1;
6998 else if (unformat (i, "static"))
7000 else if (unformat (i, "filter"))
7005 else if (unformat (i, "bvi"))
7010 else if (unformat (i, "del"))
7012 else if (unformat (i, "count %d", &count))
7020 errmsg ("missing mac address");
7026 errmsg ("missing bridge domain");
7030 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7032 errmsg ("missing interface name or sw_if_index");
7038 /* Turn on async mode */
7039 vam->async_mode = 1;
7040 vam->async_errors = 0;
7041 before = vat_time_now (vam);
7044 for (j = 0; j < count; j++)
7046 M (L2FIB_ADD_DEL, mp);
7048 clib_memcpy (mp->mac, mac, 6);
7049 mp->bd_id = ntohl (bd_id);
7050 mp->is_add = is_add;
7051 mp->sw_if_index = ntohl (sw_if_index);
7055 mp->static_mac = static_mac;
7056 mp->filter_mac = filter_mac;
7057 mp->bvi_mac = bvi_mac;
7059 increment_mac_address (mac);
7066 vl_api_control_ping_t *mp_ping;
7069 /* Shut off async mode */
7070 vam->async_mode = 0;
7072 MPING (CONTROL_PING, mp_ping);
7075 timeout = vat_time_now (vam) + 1.0;
7076 while (vat_time_now (vam) < timeout)
7077 if (vam->result_ready == 1)
7082 if (vam->retval == -99)
7085 if (vam->async_errors > 0)
7087 errmsg ("%d asynchronous errors", vam->async_errors);
7090 vam->async_errors = 0;
7091 after = vat_time_now (vam);
7093 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7094 count, after - before, count / (after - before));
7100 /* Wait for a reply... */
7104 /* Return the good/bad news */
7105 return (vam->retval);
7109 api_bridge_domain_set_mac_age (vat_main_t * vam)
7111 unformat_input_t *i = vam->input;
7112 vl_api_bridge_domain_set_mac_age_t *mp;
7117 /* Parse args required to build the message */
7118 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7120 if (unformat (i, "bd_id %d", &bd_id));
7121 else if (unformat (i, "mac-age %d", &mac_age));
7128 errmsg ("missing bridge domain");
7134 errmsg ("mac age must be less than 256 ");
7138 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7140 mp->bd_id = htonl (bd_id);
7141 mp->mac_age = (u8) mac_age;
7149 api_l2_flags (vat_main_t * vam)
7151 unformat_input_t *i = vam->input;
7152 vl_api_l2_flags_t *mp;
7155 u8 sw_if_index_set = 0;
7159 /* Parse args required to build the message */
7160 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7162 if (unformat (i, "sw_if_index %d", &sw_if_index))
7163 sw_if_index_set = 1;
7164 else if (unformat (i, "sw_if"))
7166 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7169 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7170 sw_if_index_set = 1;
7175 else if (unformat (i, "learn"))
7177 else if (unformat (i, "forward"))
7179 else if (unformat (i, "flood"))
7181 else if (unformat (i, "uu-flood"))
7182 flags |= L2_UU_FLOOD;
7183 else if (unformat (i, "arp-term"))
7184 flags |= L2_ARP_TERM;
7185 else if (unformat (i, "off"))
7187 else if (unformat (i, "disable"))
7193 if (sw_if_index_set == 0)
7195 errmsg ("missing interface name or sw_if_index");
7201 mp->sw_if_index = ntohl (sw_if_index);
7202 mp->feature_bitmap = ntohl (flags);
7203 mp->is_set = is_set;
7211 api_bridge_flags (vat_main_t * vam)
7213 unformat_input_t *i = vam->input;
7214 vl_api_bridge_flags_t *mp;
7218 bd_flags_t flags = 0;
7221 /* Parse args required to build the message */
7222 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7224 if (unformat (i, "bd_id %d", &bd_id))
7226 else if (unformat (i, "learn"))
7227 flags |= BRIDGE_API_FLAG_LEARN;
7228 else if (unformat (i, "forward"))
7229 flags |= BRIDGE_API_FLAG_FWD;
7230 else if (unformat (i, "flood"))
7231 flags |= BRIDGE_API_FLAG_FLOOD;
7232 else if (unformat (i, "uu-flood"))
7233 flags |= BRIDGE_API_FLAG_UU_FLOOD;
7234 else if (unformat (i, "arp-term"))
7235 flags |= BRIDGE_API_FLAG_ARP_TERM;
7236 else if (unformat (i, "off"))
7238 else if (unformat (i, "disable"))
7246 errmsg ("missing bridge domain");
7250 M (BRIDGE_FLAGS, mp);
7252 mp->bd_id = ntohl (bd_id);
7253 mp->flags = ntohl (flags);
7254 mp->is_set = is_set;
7262 api_bd_ip_mac_add_del (vat_main_t * vam)
7264 vl_api_address_t ip = VL_API_ZERO_ADDRESS;
7265 vl_api_mac_address_t mac = { 0 };
7266 unformat_input_t *i = vam->input;
7267 vl_api_bd_ip_mac_add_del_t *mp;
7276 /* Parse args required to build the message */
7277 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7279 if (unformat (i, "bd_id %d", &bd_id))
7283 else if (unformat (i, "%U", unformat_vl_api_address, &ip))
7287 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
7291 else if (unformat (i, "del"))
7299 errmsg ("missing bridge domain");
7302 else if (ip_set == 0)
7304 errmsg ("missing IP address");
7307 else if (mac_set == 0)
7309 errmsg ("missing MAC address");
7313 M (BD_IP_MAC_ADD_DEL, mp);
7315 mp->bd_id = ntohl (bd_id);
7316 mp->is_add = is_add;
7318 clib_memcpy (&mp->ip, &ip, sizeof (ip));
7319 clib_memcpy (&mp->mac, &mac, sizeof (mac));
7327 api_bd_ip_mac_flush (vat_main_t * vam)
7329 unformat_input_t *i = vam->input;
7330 vl_api_bd_ip_mac_flush_t *mp;
7335 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7337 if (unformat (i, "bd_id %d", &bd_id))
7347 errmsg ("missing bridge domain");
7351 M (BD_IP_MAC_FLUSH, mp);
7353 mp->bd_id = ntohl (bd_id);
7360 static void vl_api_bd_ip_mac_details_t_handler
7361 (vl_api_bd_ip_mac_details_t * mp)
7363 vat_main_t *vam = &vat_main;
7368 format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
7371 format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
7374 "\n%-5d %-7s %-20U %-30s",
7375 ntohl (mp->bd_id), mp->is_ipv6 ? "ip6" : "ip4",
7376 format_ethernet_address, mp->mac_address, ip);
7381 static void vl_api_bd_ip_mac_details_t_handler_json
7382 (vl_api_bd_ip_mac_details_t * mp)
7384 vat_main_t *vam = &vat_main;
7385 vat_json_node_t *node = NULL;
7387 if (VAT_JSON_ARRAY != vam->json_tree.type)
7389 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7390 vat_json_init_array (&vam->json_tree);
7392 node = vat_json_array_add (&vam->json_tree);
7394 vat_json_init_object (node);
7395 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
7396 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
7397 vat_json_object_add_string_copy (node, "mac_address",
7398 format (0, "%U", format_ethernet_address,
7404 format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
7407 format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
7408 vat_json_object_add_string_copy (node, "ip_address", ip);
7413 api_bd_ip_mac_dump (vat_main_t * vam)
7415 unformat_input_t *i = vam->input;
7416 vl_api_bd_ip_mac_dump_t *mp;
7417 vl_api_control_ping_t *mp_ping;
7422 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7424 if (unformat (i, "bd_id %d", &bd_id))
7433 "\n%-5s %-7s %-20s %-30s",
7434 "bd_id", "is_ipv6", "mac_address", "ip_address");
7436 /* Dump Bridge Domain Ip to Mac entries */
7437 M (BD_IP_MAC_DUMP, mp);
7440 mp->bd_id = htonl (bd_id);
7446 /* Use a control ping for synchronization */
7447 MPING (CONTROL_PING, mp_ping);
7455 api_tap_create_v2 (vat_main_t * vam)
7457 unformat_input_t *i = vam->input;
7458 vl_api_tap_create_v2_t *mp;
7462 u8 *host_if_name = 0;
7464 u8 host_mac_addr[6];
7465 u8 host_mac_addr_set = 0;
7466 u8 *host_bridge = 0;
7467 ip4_address_t host_ip4_addr;
7468 ip4_address_t host_ip4_gw;
7469 u8 host_ip4_gw_set = 0;
7470 u32 host_ip4_prefix_len = 0;
7471 ip6_address_t host_ip6_addr;
7472 ip6_address_t host_ip6_gw;
7473 u8 host_ip6_gw_set = 0;
7474 u32 host_ip6_prefix_len = 0;
7476 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7478 clib_memset (mac_address, 0, sizeof (mac_address));
7480 /* Parse args required to build the message */
7481 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7483 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7487 else if (unformat (i, "id %u", &id))
7489 else if (unformat (i, "host-if-name %s", &host_if_name))
7491 else if (unformat (i, "host-ns %s", &host_ns))
7493 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
7495 host_mac_addr_set = 1;
7496 else if (unformat (i, "host-bridge %s", &host_bridge))
7498 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
7499 &host_ip4_addr, &host_ip4_prefix_len))
7501 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
7502 &host_ip6_addr, &host_ip6_prefix_len))
7504 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
7506 host_ip4_gw_set = 1;
7507 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
7509 host_ip6_gw_set = 1;
7510 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
7512 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
7518 if (vec_len (host_if_name) > 63)
7520 errmsg ("tap name too long. ");
7523 if (vec_len (host_ns) > 63)
7525 errmsg ("host name space too long. ");
7528 if (vec_len (host_bridge) > 63)
7530 errmsg ("host bridge name too long. ");
7533 if (host_ip4_prefix_len > 32)
7535 errmsg ("host ip4 prefix length not valid. ");
7538 if (host_ip6_prefix_len > 128)
7540 errmsg ("host ip6 prefix length not valid. ");
7543 if (!is_pow2 (rx_ring_sz))
7545 errmsg ("rx ring size must be power of 2. ");
7548 if (rx_ring_sz > 32768)
7550 errmsg ("rx ring size must be 32768 or lower. ");
7553 if (!is_pow2 (tx_ring_sz))
7555 errmsg ("tx ring size must be power of 2. ");
7558 if (tx_ring_sz > 32768)
7560 errmsg ("tx ring size must be 32768 or lower. ");
7564 /* Construct the API message */
7565 M (TAP_CREATE_V2, mp);
7567 mp->use_random_mac = random_mac;
7569 mp->id = ntohl (id);
7570 mp->host_namespace_set = host_ns != 0;
7571 mp->host_bridge_set = host_bridge != 0;
7572 mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
7573 mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
7574 mp->rx_ring_sz = ntohs (rx_ring_sz);
7575 mp->tx_ring_sz = ntohs (tx_ring_sz);
7577 if (random_mac == 0)
7578 clib_memcpy (mp->mac_address, mac_address, 6);
7579 if (host_mac_addr_set)
7580 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
7582 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
7584 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
7586 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
7587 if (host_ip4_prefix_len)
7588 clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
7589 if (host_ip6_prefix_len)
7590 clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
7591 if (host_ip4_gw_set)
7592 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
7593 if (host_ip6_gw_set)
7594 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
7597 vec_free (host_if_name);
7598 vec_free (host_bridge);
7603 /* Wait for a reply... */
7609 api_tap_delete_v2 (vat_main_t * vam)
7611 unformat_input_t *i = vam->input;
7612 vl_api_tap_delete_v2_t *mp;
7613 u32 sw_if_index = ~0;
7614 u8 sw_if_index_set = 0;
7617 /* Parse args required to build the message */
7618 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7620 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7621 sw_if_index_set = 1;
7622 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7623 sw_if_index_set = 1;
7628 if (sw_if_index_set == 0)
7630 errmsg ("missing vpp interface name. ");
7634 /* Construct the API message */
7635 M (TAP_DELETE_V2, mp);
7637 mp->sw_if_index = ntohl (sw_if_index);
7642 /* Wait for a reply... */
7648 unformat_pci_addr (unformat_input_t * input, va_list * args)
7657 addr = va_arg (*args, struct pci_addr_t *);
7660 if (!unformat (input, "%x:%x:%x.%x", &x[0], &x[1], &x[2], &x[3]))
7663 addr->domain = x[0];
7666 addr->function = x[3];
7672 api_virtio_pci_create (vat_main_t * vam)
7674 unformat_input_t *i = vam->input;
7675 vl_api_virtio_pci_create_t *mp;
7680 u64 features = (u64) ~ (0ULL);
7683 clib_memset (mac_address, 0, sizeof (mac_address));
7685 /* Parse args required to build the message */
7686 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7688 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7692 else if (unformat (i, "pci-addr %U", unformat_pci_addr, &pci_addr))
7694 else if (unformat (i, "features 0x%llx", &features))
7696 else if (unformat (i, "gso-enabled"))
7704 errmsg ("pci address must be non zero. ");
7708 /* Construct the API message */
7709 M (VIRTIO_PCI_CREATE, mp);
7711 mp->use_random_mac = random_mac;
7713 mp->pci_addr = htonl (pci_addr);
7714 mp->features = clib_host_to_net_u64 (features);
7715 mp->gso_enabled = gso_enabled;
7717 if (random_mac == 0)
7718 clib_memcpy (mp->mac_address, mac_address, 6);
7723 /* Wait for a reply... */
7729 api_virtio_pci_delete (vat_main_t * vam)
7731 unformat_input_t *i = vam->input;
7732 vl_api_virtio_pci_delete_t *mp;
7733 u32 sw_if_index = ~0;
7734 u8 sw_if_index_set = 0;
7737 /* Parse args required to build the message */
7738 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7740 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7741 sw_if_index_set = 1;
7742 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7743 sw_if_index_set = 1;
7748 if (sw_if_index_set == 0)
7750 errmsg ("missing vpp interface name. ");
7754 /* Construct the API message */
7755 M (VIRTIO_PCI_DELETE, mp);
7757 mp->sw_if_index = htonl (sw_if_index);
7762 /* Wait for a reply... */
7768 api_bond_create (vat_main_t * vam)
7770 unformat_input_t *i = vam->input;
7771 vl_api_bond_create_t *mp;
7780 clib_memset (mac_address, 0, sizeof (mac_address));
7783 /* Parse args required to build the message */
7784 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7786 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
7788 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
7789 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
7791 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
7794 else if (unformat (i, "id %u", &id))
7800 if (mode_is_set == 0)
7802 errmsg ("Missing bond mode. ");
7806 /* Construct the API message */
7807 M (BOND_CREATE, mp);
7809 mp->use_custom_mac = custom_mac;
7813 mp->id = htonl (id);
7816 clib_memcpy (mp->mac_address, mac_address, 6);
7821 /* Wait for a reply... */
7827 api_bond_delete (vat_main_t * vam)
7829 unformat_input_t *i = vam->input;
7830 vl_api_bond_delete_t *mp;
7831 u32 sw_if_index = ~0;
7832 u8 sw_if_index_set = 0;
7835 /* Parse args required to build the message */
7836 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7838 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7839 sw_if_index_set = 1;
7840 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7841 sw_if_index_set = 1;
7846 if (sw_if_index_set == 0)
7848 errmsg ("missing vpp interface name. ");
7852 /* Construct the API message */
7853 M (BOND_DELETE, mp);
7855 mp->sw_if_index = ntohl (sw_if_index);
7860 /* Wait for a reply... */
7866 api_bond_enslave (vat_main_t * vam)
7868 unformat_input_t *i = vam->input;
7869 vl_api_bond_enslave_t *mp;
7870 u32 bond_sw_if_index;
7874 u32 bond_sw_if_index_is_set = 0;
7876 u8 sw_if_index_is_set = 0;
7878 /* Parse args required to build the message */
7879 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7881 if (unformat (i, "sw_if_index %d", &sw_if_index))
7882 sw_if_index_is_set = 1;
7883 else if (unformat (i, "bond %u", &bond_sw_if_index))
7884 bond_sw_if_index_is_set = 1;
7885 else if (unformat (i, "passive %d", &is_passive))
7887 else if (unformat (i, "long-timeout %d", &is_long_timeout))
7893 if (bond_sw_if_index_is_set == 0)
7895 errmsg ("Missing bond sw_if_index. ");
7898 if (sw_if_index_is_set == 0)
7900 errmsg ("Missing slave sw_if_index. ");
7904 /* Construct the API message */
7905 M (BOND_ENSLAVE, mp);
7907 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
7908 mp->sw_if_index = ntohl (sw_if_index);
7909 mp->is_long_timeout = is_long_timeout;
7910 mp->is_passive = is_passive;
7915 /* Wait for a reply... */
7921 api_bond_detach_slave (vat_main_t * vam)
7923 unformat_input_t *i = vam->input;
7924 vl_api_bond_detach_slave_t *mp;
7925 u32 sw_if_index = ~0;
7926 u8 sw_if_index_set = 0;
7929 /* Parse args required to build the message */
7930 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7932 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7933 sw_if_index_set = 1;
7934 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7935 sw_if_index_set = 1;
7940 if (sw_if_index_set == 0)
7942 errmsg ("missing vpp interface name. ");
7946 /* Construct the API message */
7947 M (BOND_DETACH_SLAVE, mp);
7949 mp->sw_if_index = ntohl (sw_if_index);
7954 /* Wait for a reply... */
7960 api_ip_table_add_del (vat_main_t * vam)
7962 unformat_input_t *i = vam->input;
7963 vl_api_ip_table_add_del_t *mp;
7969 /* Parse args required to build the message */
7970 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7972 if (unformat (i, "ipv6"))
7974 else if (unformat (i, "del"))
7976 else if (unformat (i, "add"))
7978 else if (unformat (i, "table %d", &table_id))
7982 clib_warning ("parse error '%U'", format_unformat_error, i);
7989 errmsg ("missing table-ID");
7993 /* Construct the API message */
7994 M (IP_TABLE_ADD_DEL, mp);
7996 mp->table_id = ntohl (table_id);
7997 mp->is_ipv6 = is_ipv6;
7998 mp->is_add = is_add;
8003 /* Wait for a reply... */
8010 api_ip_add_del_route (vat_main_t * vam)
8012 unformat_input_t *i = vam->input;
8013 vl_api_ip_add_del_route_t *mp;
8014 u32 sw_if_index = ~0, vrf_id = 0;
8016 u8 is_local = 0, is_drop = 0;
8017 u8 is_unreach = 0, is_prohibit = 0;
8019 u32 next_hop_weight = 1;
8020 u8 is_multipath = 0;
8022 u8 address_length_set = 0;
8023 u32 next_hop_table_id = 0;
8024 u32 resolve_attempts = 0;
8025 u32 dst_address_length = 0;
8026 u8 next_hop_set = 0;
8027 ip4_address_t v4_dst_address, v4_next_hop_address;
8028 ip6_address_t v6_dst_address, v6_next_hop_address;
8032 u32 random_add_del = 0;
8033 u32 *random_vector = 0;
8035 u32 random_seed = 0xdeaddabe;
8036 u32 classify_table_index = ~0;
8038 u8 resolve_host = 0, resolve_attached = 0;
8039 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
8040 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8041 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8043 clib_memset (&v4_next_hop_address, 0, sizeof (ip4_address_t));
8044 clib_memset (&v6_next_hop_address, 0, sizeof (ip6_address_t));
8045 /* Parse args required to build the message */
8046 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8048 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8050 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8052 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
8057 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
8062 else if (unformat (i, "/%d", &dst_address_length))
8064 address_length_set = 1;
8067 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
8068 &v4_next_hop_address))
8072 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
8073 &v6_next_hop_address))
8079 (i, "via %U", api_unformat_sw_if_index, vam, &sw_if_index))
8083 else if (unformat (i, "via sw_if_index %d", &sw_if_index))
8087 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
8089 else if (unformat (i, "weight %d", &next_hop_weight))
8091 else if (unformat (i, "drop"))
8095 else if (unformat (i, "null-send-unreach"))
8099 else if (unformat (i, "null-send-prohibit"))
8103 else if (unformat (i, "local"))
8107 else if (unformat (i, "classify %d", &classify_table_index))
8111 else if (unformat (i, "del"))
8113 else if (unformat (i, "add"))
8115 else if (unformat (i, "resolve-via-host"))
8117 else if (unformat (i, "resolve-via-attached"))
8118 resolve_attached = 1;
8119 else if (unformat (i, "multipath"))
8121 else if (unformat (i, "vrf %d", &vrf_id))
8123 else if (unformat (i, "count %d", &count))
8125 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
8127 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8129 else if (unformat (i, "out-label %d", &next_hop_out_label))
8131 vl_api_fib_mpls_label_t fib_label = {
8132 .label = ntohl (next_hop_out_label),
8136 vec_add1 (next_hop_out_label_stack, fib_label);
8138 else if (unformat (i, "via via-label %d", &next_hop_via_label))
8140 else if (unformat (i, "random"))
8142 else if (unformat (i, "seed %d", &random_seed))
8146 clib_warning ("parse error '%U'", format_unformat_error, i);
8151 if (!next_hop_set && !is_drop && !is_local &&
8152 !is_classify && !is_unreach && !is_prohibit &&
8153 MPLS_LABEL_INVALID == next_hop_via_label)
8156 ("next hop / local / drop / unreach / prohibit / classify not set");
8160 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
8162 errmsg ("next hop and next-hop via label set");
8165 if (address_set == 0)
8167 errmsg ("missing addresses");
8171 if (address_length_set == 0)
8173 errmsg ("missing address length");
8177 /* Generate a pile of unique, random routes */
8180 u32 this_random_address;
8181 random_hash = hash_create (count, sizeof (uword));
8183 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
8184 for (j = 0; j <= count; j++)
8188 this_random_address = random_u32 (&random_seed);
8189 this_random_address =
8190 clib_host_to_net_u32 (this_random_address);
8192 while (hash_get (random_hash, this_random_address));
8193 vec_add1 (random_vector, this_random_address);
8194 hash_set (random_hash, this_random_address, 1);
8196 hash_free (random_hash);
8197 v4_dst_address.as_u32 = random_vector[0];
8202 /* Turn on async mode */
8203 vam->async_mode = 1;
8204 vam->async_errors = 0;
8205 before = vat_time_now (vam);
8208 for (j = 0; j < count; j++)
8210 /* Construct the API message */
8211 M2 (IP_ADD_DEL_ROUTE, mp, sizeof (vl_api_fib_mpls_label_t) *
8212 vec_len (next_hop_out_label_stack));
8214 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8215 mp->table_id = ntohl (vrf_id);
8217 mp->is_add = is_add;
8218 mp->is_drop = is_drop;
8219 mp->is_unreach = is_unreach;
8220 mp->is_prohibit = is_prohibit;
8221 mp->is_ipv6 = is_ipv6;
8222 mp->is_local = is_local;
8223 mp->is_classify = is_classify;
8224 mp->is_multipath = is_multipath;
8225 mp->is_resolve_host = resolve_host;
8226 mp->is_resolve_attached = resolve_attached;
8227 mp->next_hop_weight = next_hop_weight;
8228 mp->next_hop_preference = 0;
8229 mp->dst_address_length = dst_address_length;
8230 mp->next_hop_table_id = ntohl (next_hop_table_id);
8231 mp->classify_table_index = ntohl (classify_table_index);
8232 mp->next_hop_via_label = ntohl (next_hop_via_label);
8233 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8234 if (0 != mp->next_hop_n_out_labels)
8236 memcpy (mp->next_hop_out_label_stack,
8237 next_hop_out_label_stack,
8238 (vec_len (next_hop_out_label_stack) *
8239 sizeof (vl_api_fib_mpls_label_t)));
8240 vec_free (next_hop_out_label_stack);
8245 clib_memcpy (mp->dst_address, &v6_dst_address,
8246 sizeof (v6_dst_address));
8248 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
8249 sizeof (v6_next_hop_address));
8250 increment_v6_address (&v6_dst_address);
8254 clib_memcpy (mp->dst_address, &v4_dst_address,
8255 sizeof (v4_dst_address));
8257 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
8258 sizeof (v4_next_hop_address));
8260 v4_dst_address.as_u32 = random_vector[j + 1];
8262 increment_v4_address (&v4_dst_address);
8266 /* If we receive SIGTERM, stop now... */
8271 /* When testing multiple add/del ops, use a control-ping to sync */
8274 vl_api_control_ping_t *mp_ping;
8278 /* Shut off async mode */
8279 vam->async_mode = 0;
8281 MPING (CONTROL_PING, mp_ping);
8284 timeout = vat_time_now (vam) + 1.0;
8285 while (vat_time_now (vam) < timeout)
8286 if (vam->result_ready == 1)
8291 if (vam->retval == -99)
8294 if (vam->async_errors > 0)
8296 errmsg ("%d asynchronous errors", vam->async_errors);
8299 vam->async_errors = 0;
8300 after = vat_time_now (vam);
8302 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8306 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8307 count, after - before, count / (after - before));
8313 /* Wait for a reply... */
8318 /* Return the good/bad news */
8319 return (vam->retval);
8323 api_ip_mroute_add_del (vat_main_t * vam)
8325 unformat_input_t *i = vam->input;
8326 vl_api_ip_mroute_add_del_t *mp;
8327 u32 sw_if_index = ~0, vrf_id = 0;
8332 u32 grp_address_length = 0;
8333 ip4_address_t v4_grp_address, v4_src_address;
8334 ip6_address_t v6_grp_address, v6_src_address;
8335 mfib_itf_flags_t iflags = 0;
8336 mfib_entry_flags_t eflags = 0;
8339 /* Parse args required to build the message */
8340 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8342 if (unformat (i, "sw_if_index %d", &sw_if_index))
8344 else if (unformat (i, "%U %U",
8345 unformat_ip4_address, &v4_src_address,
8346 unformat_ip4_address, &v4_grp_address))
8348 grp_address_length = 64;
8352 else if (unformat (i, "%U %U",
8353 unformat_ip6_address, &v6_src_address,
8354 unformat_ip6_address, &v6_grp_address))
8356 grp_address_length = 256;
8360 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
8362 clib_memset (&v4_src_address, 0, sizeof (v4_src_address));
8363 grp_address_length = 32;
8367 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
8369 clib_memset (&v6_src_address, 0, sizeof (v6_src_address));
8370 grp_address_length = 128;
8374 else if (unformat (i, "/%d", &grp_address_length))
8376 else if (unformat (i, "local"))
8380 else if (unformat (i, "del"))
8382 else if (unformat (i, "add"))
8384 else if (unformat (i, "vrf %d", &vrf_id))
8386 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
8388 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8392 clib_warning ("parse error '%U'", format_unformat_error, i);
8397 if (address_set == 0)
8399 errmsg ("missing addresses\n");
8403 /* Construct the API message */
8404 M (IP_MROUTE_ADD_DEL, mp);
8406 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8407 mp->table_id = ntohl (vrf_id);
8409 mp->is_add = is_add;
8410 mp->is_ipv6 = is_ipv6;
8411 mp->is_local = is_local;
8412 mp->itf_flags = ntohl (iflags);
8413 mp->entry_flags = ntohl (eflags);
8414 mp->grp_address_length = grp_address_length;
8415 mp->grp_address_length = ntohs (mp->grp_address_length);
8419 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
8420 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
8424 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
8425 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
8431 /* Wait for a reply... */
8437 api_mpls_table_add_del (vat_main_t * vam)
8439 unformat_input_t *i = vam->input;
8440 vl_api_mpls_table_add_del_t *mp;
8445 /* Parse args required to build the message */
8446 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8448 if (unformat (i, "table %d", &table_id))
8450 else if (unformat (i, "del"))
8452 else if (unformat (i, "add"))
8456 clib_warning ("parse error '%U'", format_unformat_error, i);
8463 errmsg ("missing table-ID");
8467 /* Construct the API message */
8468 M (MPLS_TABLE_ADD_DEL, mp);
8470 mp->mt_table_id = ntohl (table_id);
8471 mp->mt_is_add = is_add;
8476 /* Wait for a reply... */
8483 api_mpls_route_add_del (vat_main_t * vam)
8485 unformat_input_t *i = vam->input;
8486 vl_api_mpls_route_add_del_t *mp;
8487 u32 sw_if_index = ~0, table_id = 0;
8489 u32 next_hop_weight = 1;
8490 u8 is_multipath = 0;
8491 u32 next_hop_table_id = 0;
8492 u8 next_hop_set = 0;
8493 ip4_address_t v4_next_hop_address = {
8496 ip6_address_t v6_next_hop_address = { {0} };
8500 u32 classify_table_index = ~0;
8502 u8 resolve_host = 0, resolve_attached = 0;
8503 u8 is_interface_rx = 0;
8504 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8505 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8506 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
8507 mpls_label_t local_label = MPLS_LABEL_INVALID;
8509 dpo_proto_t next_hop_proto = DPO_PROTO_MPLS;
8511 /* Parse args required to build the message */
8512 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8514 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8516 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8518 else if (unformat (i, "%d", &local_label))
8520 else if (unformat (i, "eos"))
8522 else if (unformat (i, "non-eos"))
8524 else if (unformat (i, "via %U", unformat_ip4_address,
8525 &v4_next_hop_address))
8528 next_hop_proto = DPO_PROTO_IP4;
8530 else if (unformat (i, "via %U", unformat_ip6_address,
8531 &v6_next_hop_address))
8534 next_hop_proto = DPO_PROTO_IP6;
8536 else if (unformat (i, "weight %d", &next_hop_weight))
8538 else if (unformat (i, "classify %d", &classify_table_index))
8542 else if (unformat (i, "del"))
8544 else if (unformat (i, "add"))
8546 else if (unformat (i, "resolve-via-host"))
8548 else if (unformat (i, "resolve-via-attached"))
8549 resolve_attached = 1;
8550 else if (unformat (i, "multipath"))
8552 else if (unformat (i, "count %d", &count))
8554 else if (unformat (i, "via lookup-in-ip4-table %d", &next_hop_table_id))
8557 next_hop_proto = DPO_PROTO_IP4;
8559 else if (unformat (i, "via lookup-in-ip6-table %d", &next_hop_table_id))
8562 next_hop_proto = DPO_PROTO_IP6;
8566 (i, "via l2-input-on %U", api_unformat_sw_if_index, vam,
8570 next_hop_proto = DPO_PROTO_ETHERNET;
8571 is_interface_rx = 1;
8573 else if (unformat (i, "via l2-input-on sw_if_index %d", &sw_if_index))
8576 next_hop_proto = DPO_PROTO_ETHERNET;
8577 is_interface_rx = 1;
8579 else if (unformat (i, "via next-hop-table %d", &next_hop_table_id))
8581 else if (unformat (i, "via via-label %d", &next_hop_via_label))
8583 else if (unformat (i, "out-label %d", &next_hop_out_label))
8585 vl_api_fib_mpls_label_t fib_label = {
8586 .label = ntohl (next_hop_out_label),
8590 vec_add1 (next_hop_out_label_stack, fib_label);
8594 clib_warning ("parse error '%U'", format_unformat_error, i);
8599 if (!next_hop_set && !is_classify)
8601 errmsg ("next hop / classify not set");
8605 if (MPLS_LABEL_INVALID == local_label)
8607 errmsg ("missing label");
8613 /* Turn on async mode */
8614 vam->async_mode = 1;
8615 vam->async_errors = 0;
8616 before = vat_time_now (vam);
8619 for (j = 0; j < count; j++)
8621 /* Construct the API message */
8622 M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_mpls_label_t) *
8623 vec_len (next_hop_out_label_stack));
8625 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
8626 mp->mr_table_id = ntohl (table_id);
8628 mp->mr_is_add = is_add;
8629 mp->mr_next_hop_proto = next_hop_proto;
8630 mp->mr_is_classify = is_classify;
8631 mp->mr_is_multipath = is_multipath;
8632 mp->mr_is_resolve_host = resolve_host;
8633 mp->mr_is_resolve_attached = resolve_attached;
8634 mp->mr_is_interface_rx = is_interface_rx;
8635 mp->mr_next_hop_weight = next_hop_weight;
8636 mp->mr_next_hop_preference = 0;
8637 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
8638 mp->mr_classify_table_index = ntohl (classify_table_index);
8639 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
8640 mp->mr_label = ntohl (local_label);
8641 mp->mr_eos = is_eos;
8643 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8644 if (0 != mp->mr_next_hop_n_out_labels)
8646 memcpy (mp->mr_next_hop_out_label_stack,
8647 next_hop_out_label_stack,
8648 vec_len (next_hop_out_label_stack) *
8649 sizeof (vl_api_fib_mpls_label_t));
8650 vec_free (next_hop_out_label_stack);
8655 if (DPO_PROTO_IP4 == next_hop_proto)
8657 clib_memcpy (mp->mr_next_hop,
8658 &v4_next_hop_address,
8659 sizeof (v4_next_hop_address));
8661 else if (DPO_PROTO_IP6 == next_hop_proto)
8664 clib_memcpy (mp->mr_next_hop,
8665 &v6_next_hop_address,
8666 sizeof (v6_next_hop_address));
8673 /* If we receive SIGTERM, stop now... */
8678 /* When testing multiple add/del ops, use a control-ping to sync */
8681 vl_api_control_ping_t *mp_ping;
8685 /* Shut off async mode */
8686 vam->async_mode = 0;
8688 MPING (CONTROL_PING, mp_ping);
8691 timeout = vat_time_now (vam) + 1.0;
8692 while (vat_time_now (vam) < timeout)
8693 if (vam->result_ready == 1)
8698 if (vam->retval == -99)
8701 if (vam->async_errors > 0)
8703 errmsg ("%d asynchronous errors", vam->async_errors);
8706 vam->async_errors = 0;
8707 after = vat_time_now (vam);
8709 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8713 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8714 count, after - before, count / (after - before));
8720 /* Wait for a reply... */
8725 /* Return the good/bad news */
8726 return (vam->retval);
8730 api_mpls_ip_bind_unbind (vat_main_t * vam)
8732 unformat_input_t *i = vam->input;
8733 vl_api_mpls_ip_bind_unbind_t *mp;
8734 u32 ip_table_id = 0;
8737 ip4_address_t v4_address;
8738 ip6_address_t v6_address;
8741 mpls_label_t local_label = MPLS_LABEL_INVALID;
8744 /* Parse args required to build the message */
8745 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8747 if (unformat (i, "%U/%d", unformat_ip4_address,
8748 &v4_address, &address_length))
8753 else if (unformat (i, "%U/%d", unformat_ip6_address,
8754 &v6_address, &address_length))
8759 else if (unformat (i, "%d", &local_label))
8761 else if (unformat (i, "table-id %d", &ip_table_id))
8763 else if (unformat (i, "unbind"))
8765 else if (unformat (i, "bind"))
8769 clib_warning ("parse error '%U'", format_unformat_error, i);
8776 errmsg ("IP address not set");
8780 if (MPLS_LABEL_INVALID == local_label)
8782 errmsg ("missing label");
8786 /* Construct the API message */
8787 M (MPLS_IP_BIND_UNBIND, mp);
8789 mp->mb_is_bind = is_bind;
8790 mp->mb_is_ip4 = is_ip4;
8791 mp->mb_ip_table_id = ntohl (ip_table_id);
8792 mp->mb_mpls_table_id = 0;
8793 mp->mb_label = ntohl (local_label);
8794 mp->mb_address_length = address_length;
8797 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
8799 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
8804 /* Wait for a reply... */
8810 api_sr_mpls_policy_add (vat_main_t * vam)
8812 unformat_input_t *i = vam->input;
8813 vl_api_sr_mpls_policy_add_t *mp;
8819 u32 *segments = NULL;
8822 /* Parse args required to build the message */
8823 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8825 if (unformat (i, "bsid %d", &bsid))
8827 else if (unformat (i, "weight %d", &weight))
8829 else if (unformat (i, "spray"))
8831 else if (unformat (i, "next %d", &sid))
8834 vec_add1 (segments, htonl (sid));
8838 clib_warning ("parse error '%U'", format_unformat_error, i);
8845 errmsg ("bsid not set");
8849 if (n_segments == 0)
8851 errmsg ("no sid in segment stack");
8855 /* Construct the API message */
8856 M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
8858 mp->bsid = htonl (bsid);
8859 mp->weight = htonl (weight);
8861 mp->n_segments = n_segments;
8862 memcpy (mp->segments, segments, sizeof (u32) * n_segments);
8863 vec_free (segments);
8868 /* Wait for a reply... */
8874 api_sr_mpls_policy_del (vat_main_t * vam)
8876 unformat_input_t *i = vam->input;
8877 vl_api_sr_mpls_policy_del_t *mp;
8881 /* Parse args required to build the message */
8882 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8884 if (unformat (i, "bsid %d", &bsid))
8888 clib_warning ("parse error '%U'", format_unformat_error, i);
8895 errmsg ("bsid not set");
8899 /* Construct the API message */
8900 M (SR_MPLS_POLICY_DEL, mp);
8902 mp->bsid = htonl (bsid);
8907 /* Wait for a reply... */
8913 api_bier_table_add_del (vat_main_t * vam)
8915 unformat_input_t *i = vam->input;
8916 vl_api_bier_table_add_del_t *mp;
8918 u32 set = 0, sub_domain = 0, hdr_len = 3;
8919 mpls_label_t local_label = MPLS_LABEL_INVALID;
8922 /* Parse args required to build the message */
8923 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8925 if (unformat (i, "sub-domain %d", &sub_domain))
8927 else if (unformat (i, "set %d", &set))
8929 else if (unformat (i, "label %d", &local_label))
8931 else if (unformat (i, "hdr-len %d", &hdr_len))
8933 else if (unformat (i, "add"))
8935 else if (unformat (i, "del"))
8939 clib_warning ("parse error '%U'", format_unformat_error, i);
8944 if (MPLS_LABEL_INVALID == local_label)
8946 errmsg ("missing label\n");
8950 /* Construct the API message */
8951 M (BIER_TABLE_ADD_DEL, mp);
8953 mp->bt_is_add = is_add;
8954 mp->bt_label = ntohl (local_label);
8955 mp->bt_tbl_id.bt_set = set;
8956 mp->bt_tbl_id.bt_sub_domain = sub_domain;
8957 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
8962 /* Wait for a reply... */
8969 api_bier_route_add_del (vat_main_t * vam)
8971 unformat_input_t *i = vam->input;
8972 vl_api_bier_route_add_del_t *mp;
8974 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
8975 ip4_address_t v4_next_hop_address;
8976 ip6_address_t v6_next_hop_address;
8977 u8 next_hop_set = 0;
8978 u8 next_hop_proto_is_ip4 = 1;
8979 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8982 /* Parse args required to build the message */
8983 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8985 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
8987 next_hop_proto_is_ip4 = 1;
8990 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
8992 next_hop_proto_is_ip4 = 0;
8995 if (unformat (i, "sub-domain %d", &sub_domain))
8997 else if (unformat (i, "set %d", &set))
8999 else if (unformat (i, "hdr-len %d", &hdr_len))
9001 else if (unformat (i, "bp %d", &bp))
9003 else if (unformat (i, "add"))
9005 else if (unformat (i, "del"))
9007 else if (unformat (i, "out-label %d", &next_hop_out_label))
9011 clib_warning ("parse error '%U'", format_unformat_error, i);
9016 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
9018 errmsg ("next hop / label set\n");
9023 errmsg ("bit=position not set\n");
9027 /* Construct the API message */
9028 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
9030 mp->br_is_add = is_add;
9031 mp->br_tbl_id.bt_set = set;
9032 mp->br_tbl_id.bt_sub_domain = sub_domain;
9033 mp->br_tbl_id.bt_hdr_len_id = hdr_len;
9034 mp->br_bp = ntohs (bp);
9036 mp->br_paths[0].n_labels = 1;
9037 mp->br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
9038 mp->br_paths[0].afi = (next_hop_proto_is_ip4 ? 0 : 1);
9040 if (next_hop_proto_is_ip4)
9042 clib_memcpy (mp->br_paths[0].next_hop,
9043 &v4_next_hop_address, sizeof (v4_next_hop_address));
9047 clib_memcpy (mp->br_paths[0].next_hop,
9048 &v6_next_hop_address, sizeof (v6_next_hop_address));
9054 /* Wait for a reply... */
9061 api_proxy_arp_add_del (vat_main_t * vam)
9063 unformat_input_t *i = vam->input;
9064 vl_api_proxy_arp_add_del_t *mp;
9067 vl_api_ip4_address_t lo, hi;
9071 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9073 if (unformat (i, "vrf %d", &vrf_id))
9075 else if (unformat (i, "%U - %U", unformat_vl_api_ip4_address, &lo,
9076 unformat_vl_api_ip4_address, &hi))
9078 else if (unformat (i, "del"))
9082 clib_warning ("parse error '%U'", format_unformat_error, i);
9089 errmsg ("address range not set");
9093 M (PROXY_ARP_ADD_DEL, mp);
9095 mp->proxy.table_id = ntohl (vrf_id);
9096 mp->is_add = is_add;
9097 clib_memcpy (mp->proxy.low, &lo, sizeof (lo));
9098 clib_memcpy (mp->proxy.hi, &hi, sizeof (hi));
9106 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
9108 unformat_input_t *i = vam->input;
9109 vl_api_proxy_arp_intfc_enable_disable_t *mp;
9112 u8 sw_if_index_set = 0;
9115 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9117 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9118 sw_if_index_set = 1;
9119 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9120 sw_if_index_set = 1;
9121 else if (unformat (i, "enable"))
9123 else if (unformat (i, "disable"))
9127 clib_warning ("parse error '%U'", format_unformat_error, i);
9132 if (sw_if_index_set == 0)
9134 errmsg ("missing interface name or sw_if_index");
9138 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
9140 mp->sw_if_index = ntohl (sw_if_index);
9141 mp->enable_disable = enable;
9149 api_mpls_tunnel_add_del (vat_main_t * vam)
9151 unformat_input_t *i = vam->input;
9152 vl_api_mpls_tunnel_add_del_t *mp;
9156 u32 sw_if_index = ~0;
9157 u32 next_hop_sw_if_index = ~0;
9158 u32 next_hop_proto_is_ip4 = 1;
9160 u32 next_hop_table_id = 0;
9161 ip4_address_t v4_next_hop_address = {
9164 ip6_address_t v6_next_hop_address = { {0} };
9165 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
9166 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
9167 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9170 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9172 if (unformat (i, "add"))
9176 (i, "del %U", api_unformat_sw_if_index, vam, &sw_if_index))
9178 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
9180 else if (unformat (i, "via %U",
9181 unformat_ip4_address, &v4_next_hop_address))
9183 next_hop_proto_is_ip4 = 1;
9185 else if (unformat (i, "via %U",
9186 unformat_ip6_address, &v6_next_hop_address))
9188 next_hop_proto_is_ip4 = 0;
9190 else if (unformat (i, "via-label %d", &next_hop_via_label))
9194 (i, "%U", api_unformat_sw_if_index, vam, &next_hop_sw_if_index))
9196 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
9198 else if (unformat (i, "l2-only"))
9200 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
9202 else if (unformat (i, "out-label %d", &next_hop_out_label))
9204 vl_api_fib_mpls_label_t fib_label = {
9205 .label = ntohl (next_hop_out_label),
9209 vec_add1 (next_hop_out_label_stack, fib_label);
9213 clib_warning ("parse error '%U'", format_unformat_error, i);
9218 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (vl_api_fib_mpls_label_t) *
9219 vec_len (next_hop_out_label_stack));
9221 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
9222 mp->mt_sw_if_index = ntohl (sw_if_index);
9223 mp->mt_is_add = is_add;
9224 mp->mt_l2_only = l2_only;
9225 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
9226 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
9227 mp->mt_next_hop_via_label = ntohl (next_hop_via_label);
9228 mp->mt_next_hop_weight = 1;
9229 mp->mt_next_hop_preference = 0;
9231 mp->mt_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
9233 if (0 != mp->mt_next_hop_n_out_labels)
9235 clib_memcpy (mp->mt_next_hop_out_label_stack,
9236 next_hop_out_label_stack,
9237 (vec_len (next_hop_out_label_stack) *
9238 sizeof (vl_api_fib_mpls_label_t)));
9239 vec_free (next_hop_out_label_stack);
9242 if (next_hop_proto_is_ip4)
9244 clib_memcpy (mp->mt_next_hop,
9245 &v4_next_hop_address, sizeof (v4_next_hop_address));
9249 clib_memcpy (mp->mt_next_hop,
9250 &v6_next_hop_address, sizeof (v6_next_hop_address));
9259 api_sw_interface_set_unnumbered (vat_main_t * vam)
9261 unformat_input_t *i = vam->input;
9262 vl_api_sw_interface_set_unnumbered_t *mp;
9264 u32 unnum_sw_index = ~0;
9266 u8 sw_if_index_set = 0;
9269 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9271 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9272 sw_if_index_set = 1;
9273 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9274 sw_if_index_set = 1;
9275 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
9277 else if (unformat (i, "del"))
9281 clib_warning ("parse error '%U'", format_unformat_error, i);
9286 if (sw_if_index_set == 0)
9288 errmsg ("missing interface name or sw_if_index");
9292 M (SW_INTERFACE_SET_UNNUMBERED, mp);
9294 mp->sw_if_index = ntohl (sw_if_index);
9295 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
9296 mp->is_add = is_add;
9304 api_ip_neighbor_add_del (vat_main_t * vam)
9306 vl_api_mac_address_t mac_address;
9307 unformat_input_t *i = vam->input;
9308 vl_api_ip_neighbor_add_del_t *mp;
9309 vl_api_address_t ip_address;
9311 u8 sw_if_index_set = 0;
9316 ip_neighbor_flags_t flags;
9318 flags = IP_NEIGHBOR_FLAG_NONE;
9319 clib_memset (&ip_address, 0, sizeof (ip_address));
9320 clib_memset (&mac_address, 0, sizeof (mac_address));
9321 /* Parse args required to build the message */
9322 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9324 if (unformat (i, "mac %U", unformat_vl_api_mac_address, &mac_address))
9328 else if (unformat (i, "del"))
9331 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9332 sw_if_index_set = 1;
9333 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9334 sw_if_index_set = 1;
9335 else if (unformat (i, "static"))
9336 flags |= IP_NEIGHBOR_FLAG_STATIC;
9337 else if (unformat (i, "no-fib-entry"))
9338 flags |= IP_NEIGHBOR_FLAG_NO_FIB_ENTRY;
9339 else if (unformat (i, "dst %U", unformat_vl_api_address, &ip_address))
9343 clib_warning ("parse error '%U'", format_unformat_error, i);
9348 if (sw_if_index_set == 0)
9350 errmsg ("missing interface name or sw_if_index");
9355 errmsg ("no address set");
9359 /* Construct the API message */
9360 M (IP_NEIGHBOR_ADD_DEL, mp);
9362 mp->neighbor.sw_if_index = ntohl (sw_if_index);
9363 mp->is_add = is_add;
9364 mp->neighbor.flags = htonl (flags);
9366 clib_memcpy (&mp->neighbor.mac_address, &mac_address,
9367 sizeof (mac_address));
9369 clib_memcpy (&mp->neighbor.ip_address, &ip_address, sizeof (ip_address));
9374 /* Wait for a reply, return good/bad news */
9380 api_create_vlan_subif (vat_main_t * vam)
9382 unformat_input_t *i = vam->input;
9383 vl_api_create_vlan_subif_t *mp;
9385 u8 sw_if_index_set = 0;
9390 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9392 if (unformat (i, "sw_if_index %d", &sw_if_index))
9393 sw_if_index_set = 1;
9395 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9396 sw_if_index_set = 1;
9397 else if (unformat (i, "vlan %d", &vlan_id))
9401 clib_warning ("parse error '%U'", format_unformat_error, i);
9406 if (sw_if_index_set == 0)
9408 errmsg ("missing interface name or sw_if_index");
9412 if (vlan_id_set == 0)
9414 errmsg ("missing vlan_id");
9417 M (CREATE_VLAN_SUBIF, mp);
9419 mp->sw_if_index = ntohl (sw_if_index);
9420 mp->vlan_id = ntohl (vlan_id);
9427 #define foreach_create_subif_bit \
9434 _(outer_vlan_id_any) \
9435 _(inner_vlan_id_any)
9438 api_create_subif (vat_main_t * vam)
9440 unformat_input_t *i = vam->input;
9441 vl_api_create_subif_t *mp;
9443 u8 sw_if_index_set = 0;
9450 u32 exact_match = 0;
9451 u32 default_sub = 0;
9452 u32 outer_vlan_id_any = 0;
9453 u32 inner_vlan_id_any = 0;
9455 u16 outer_vlan_id = 0;
9456 u16 inner_vlan_id = 0;
9459 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9461 if (unformat (i, "sw_if_index %d", &sw_if_index))
9462 sw_if_index_set = 1;
9464 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9465 sw_if_index_set = 1;
9466 else if (unformat (i, "sub_id %d", &sub_id))
9468 else if (unformat (i, "outer_vlan_id %d", &tmp))
9469 outer_vlan_id = tmp;
9470 else if (unformat (i, "inner_vlan_id %d", &tmp))
9471 inner_vlan_id = tmp;
9473 #define _(a) else if (unformat (i, #a)) a = 1 ;
9474 foreach_create_subif_bit
9478 clib_warning ("parse error '%U'", format_unformat_error, i);
9483 if (sw_if_index_set == 0)
9485 errmsg ("missing interface name or sw_if_index");
9489 if (sub_id_set == 0)
9491 errmsg ("missing sub_id");
9494 M (CREATE_SUBIF, mp);
9496 mp->sw_if_index = ntohl (sw_if_index);
9497 mp->sub_id = ntohl (sub_id);
9499 #define _(a) mp->a = a;
9500 foreach_create_subif_bit;
9503 mp->outer_vlan_id = ntohs (outer_vlan_id);
9504 mp->inner_vlan_id = ntohs (inner_vlan_id);
9512 api_reset_fib (vat_main_t * vam)
9514 unformat_input_t *i = vam->input;
9515 vl_api_reset_fib_t *mp;
9521 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9523 if (unformat (i, "vrf %d", &vrf_id))
9525 else if (unformat (i, "ipv6"))
9529 clib_warning ("parse error '%U'", format_unformat_error, i);
9534 if (vrf_id_set == 0)
9536 errmsg ("missing vrf id");
9542 mp->vrf_id = ntohl (vrf_id);
9543 mp->is_ipv6 = is_ipv6;
9551 api_dhcp_proxy_config (vat_main_t * vam)
9553 unformat_input_t *i = vam->input;
9554 vl_api_dhcp_proxy_config_t *mp;
9556 u32 server_vrf_id = 0;
9558 u8 v4_address_set = 0;
9559 u8 v6_address_set = 0;
9560 ip4_address_t v4address;
9561 ip6_address_t v6address;
9562 u8 v4_src_address_set = 0;
9563 u8 v6_src_address_set = 0;
9564 ip4_address_t v4srcaddress;
9565 ip6_address_t v6srcaddress;
9568 /* Parse args required to build the message */
9569 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9571 if (unformat (i, "del"))
9573 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
9575 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
9577 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
9579 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
9581 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
9582 v4_src_address_set = 1;
9583 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
9584 v6_src_address_set = 1;
9589 if (v4_address_set && v6_address_set)
9591 errmsg ("both v4 and v6 server addresses set");
9594 if (!v4_address_set && !v6_address_set)
9596 errmsg ("no server addresses set");
9600 if (v4_src_address_set && v6_src_address_set)
9602 errmsg ("both v4 and v6 src addresses set");
9605 if (!v4_src_address_set && !v6_src_address_set)
9607 errmsg ("no src addresses set");
9611 if (!(v4_src_address_set && v4_address_set) &&
9612 !(v6_src_address_set && v6_address_set))
9614 errmsg ("no matching server and src addresses set");
9618 /* Construct the API message */
9619 M (DHCP_PROXY_CONFIG, mp);
9621 mp->is_add = is_add;
9622 mp->rx_vrf_id = ntohl (rx_vrf_id);
9623 mp->server_vrf_id = ntohl (server_vrf_id);
9627 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
9628 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
9632 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
9633 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
9639 /* Wait for a reply, return good/bad news */
9644 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
9645 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
9648 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
9650 vat_main_t *vam = &vat_main;
9651 u32 i, count = mp->count;
9652 vl_api_dhcp_server_t *s;
9656 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9657 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9658 ntohl (mp->rx_vrf_id),
9659 format_ip6_address, mp->dhcp_src_address,
9660 mp->vss_type, mp->vss_vpn_ascii_id,
9661 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9664 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9665 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9666 ntohl (mp->rx_vrf_id),
9667 format_ip4_address, mp->dhcp_src_address,
9668 mp->vss_type, mp->vss_vpn_ascii_id,
9669 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9671 for (i = 0; i < count; i++)
9673 s = &mp->servers[i];
9677 " Server Table-ID %d, Server Address %U",
9678 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
9681 " Server Table-ID %d, Server Address %U",
9682 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
9686 static void vl_api_dhcp_proxy_details_t_handler_json
9687 (vl_api_dhcp_proxy_details_t * mp)
9689 vat_main_t *vam = &vat_main;
9690 vat_json_node_t *node = NULL;
9691 u32 i, count = mp->count;
9693 struct in6_addr ip6;
9694 vl_api_dhcp_server_t *s;
9696 if (VAT_JSON_ARRAY != vam->json_tree.type)
9698 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9699 vat_json_init_array (&vam->json_tree);
9701 node = vat_json_array_add (&vam->json_tree);
9703 vat_json_init_object (node);
9704 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
9705 vat_json_object_add_bytes (node, "vss-type", &mp->vss_type,
9706 sizeof (mp->vss_type));
9707 vat_json_object_add_string_copy (node, "vss-vpn-ascii-id",
9708 mp->vss_vpn_ascii_id);
9709 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
9710 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
9714 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
9715 vat_json_object_add_ip6 (node, "src_address", ip6);
9719 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
9720 vat_json_object_add_ip4 (node, "src_address", ip4);
9723 for (i = 0; i < count; i++)
9725 s = &mp->servers[i];
9727 vat_json_object_add_uint (node, "server-table-id",
9728 ntohl (s->server_vrf_id));
9732 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
9733 vat_json_object_add_ip4 (node, "src_address", ip4);
9737 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
9738 vat_json_object_add_ip6 (node, "server_address", ip6);
9744 api_dhcp_proxy_dump (vat_main_t * vam)
9746 unformat_input_t *i = vam->input;
9747 vl_api_control_ping_t *mp_ping;
9748 vl_api_dhcp_proxy_dump_t *mp;
9752 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9754 if (unformat (i, "ipv6"))
9758 clib_warning ("parse error '%U'", format_unformat_error, i);
9763 M (DHCP_PROXY_DUMP, mp);
9765 mp->is_ip6 = is_ipv6;
9768 /* Use a control ping for synchronization */
9769 MPING (CONTROL_PING, mp_ping);
9777 api_dhcp_proxy_set_vss (vat_main_t * vam)
9779 unformat_input_t *i = vam->input;
9780 vl_api_dhcp_proxy_set_vss_t *mp;
9784 u8 vss_type = VSS_TYPE_DEFAULT;
9785 u8 *vpn_ascii_id = 0;
9790 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9792 if (unformat (i, "tbl_id %d", &tbl_id))
9794 else if (unformat (i, "vpn_ascii_id %s", &vpn_ascii_id))
9795 vss_type = VSS_TYPE_ASCII;
9796 else if (unformat (i, "fib_id %d", &fib_id))
9797 vss_type = VSS_TYPE_VPN_ID;
9798 else if (unformat (i, "oui %d", &oui))
9799 vss_type = VSS_TYPE_VPN_ID;
9800 else if (unformat (i, "ipv6"))
9802 else if (unformat (i, "del"))
9810 errmsg ("missing tbl_id ");
9811 vec_free (vpn_ascii_id);
9815 if ((vpn_ascii_id) && (vec_len (vpn_ascii_id) > 128))
9817 errmsg ("vpn_ascii_id cannot be longer than 128 ");
9818 vec_free (vpn_ascii_id);
9822 M (DHCP_PROXY_SET_VSS, mp);
9823 mp->tbl_id = ntohl (tbl_id);
9824 mp->vss_type = vss_type;
9827 clib_memcpy (mp->vpn_ascii_id, vpn_ascii_id, vec_len (vpn_ascii_id));
9828 mp->vpn_ascii_id[vec_len (vpn_ascii_id)] = 0;
9830 mp->vpn_index = ntohl (fib_id);
9831 mp->oui = ntohl (oui);
9832 mp->is_ipv6 = is_ipv6;
9833 mp->is_add = is_add;
9838 vec_free (vpn_ascii_id);
9843 api_dhcp_client_config (vat_main_t * vam)
9845 unformat_input_t *i = vam->input;
9846 vl_api_dhcp_client_config_t *mp;
9848 u8 sw_if_index_set = 0;
9851 u8 disable_event = 0;
9854 /* Parse args required to build the message */
9855 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9857 if (unformat (i, "del"))
9860 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9861 sw_if_index_set = 1;
9862 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9863 sw_if_index_set = 1;
9864 else if (unformat (i, "hostname %s", &hostname))
9866 else if (unformat (i, "disable_event"))
9872 if (sw_if_index_set == 0)
9874 errmsg ("missing interface name or sw_if_index");
9878 if (vec_len (hostname) > 63)
9880 errmsg ("hostname too long");
9882 vec_add1 (hostname, 0);
9884 /* Construct the API message */
9885 M (DHCP_CLIENT_CONFIG, mp);
9887 mp->is_add = is_add;
9888 mp->client.sw_if_index = htonl (sw_if_index);
9889 clib_memcpy (mp->client.hostname, hostname, vec_len (hostname));
9890 vec_free (hostname);
9891 mp->client.want_dhcp_event = disable_event ? 0 : 1;
9892 mp->client.pid = htonl (getpid ());
9897 /* Wait for a reply, return good/bad news */
9903 api_set_ip_flow_hash (vat_main_t * vam)
9905 unformat_input_t *i = vam->input;
9906 vl_api_set_ip_flow_hash_t *mp;
9918 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9920 if (unformat (i, "vrf %d", &vrf_id))
9922 else if (unformat (i, "ipv6"))
9924 else if (unformat (i, "src"))
9926 else if (unformat (i, "dst"))
9928 else if (unformat (i, "sport"))
9930 else if (unformat (i, "dport"))
9932 else if (unformat (i, "proto"))
9934 else if (unformat (i, "reverse"))
9939 clib_warning ("parse error '%U'", format_unformat_error, i);
9944 if (vrf_id_set == 0)
9946 errmsg ("missing vrf id");
9950 M (SET_IP_FLOW_HASH, mp);
9956 mp->reverse = reverse;
9957 mp->vrf_id = ntohl (vrf_id);
9958 mp->is_ipv6 = is_ipv6;
9966 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
9968 unformat_input_t *i = vam->input;
9969 vl_api_sw_interface_ip6_enable_disable_t *mp;
9971 u8 sw_if_index_set = 0;
9975 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9977 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9978 sw_if_index_set = 1;
9979 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9980 sw_if_index_set = 1;
9981 else if (unformat (i, "enable"))
9983 else if (unformat (i, "disable"))
9987 clib_warning ("parse error '%U'", format_unformat_error, i);
9992 if (sw_if_index_set == 0)
9994 errmsg ("missing interface name or sw_if_index");
9998 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
10000 mp->sw_if_index = ntohl (sw_if_index);
10001 mp->enable = enable;
10009 api_ip6nd_proxy_add_del (vat_main_t * vam)
10011 unformat_input_t *i = vam->input;
10012 vl_api_ip6nd_proxy_add_del_t *mp;
10013 u32 sw_if_index = ~0;
10014 u8 v6_address_set = 0;
10015 vl_api_ip6_address_t v6address;
10019 /* Parse args required to build the message */
10020 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10022 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10024 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10026 else if (unformat (i, "%U", unformat_vl_api_ip6_address, &v6address))
10027 v6_address_set = 1;
10028 if (unformat (i, "del"))
10032 clib_warning ("parse error '%U'", format_unformat_error, i);
10037 if (sw_if_index == ~0)
10039 errmsg ("missing interface name or sw_if_index");
10042 if (!v6_address_set)
10044 errmsg ("no address set");
10048 /* Construct the API message */
10049 M (IP6ND_PROXY_ADD_DEL, mp);
10051 mp->is_del = is_del;
10052 mp->sw_if_index = ntohl (sw_if_index);
10053 clib_memcpy (mp->ip, v6address, sizeof (v6address));
10058 /* Wait for a reply, return good/bad news */
10064 api_ip6nd_proxy_dump (vat_main_t * vam)
10066 vl_api_ip6nd_proxy_dump_t *mp;
10067 vl_api_control_ping_t *mp_ping;
10070 M (IP6ND_PROXY_DUMP, mp);
10074 /* Use a control ping for synchronization */
10075 MPING (CONTROL_PING, mp_ping);
10082 static void vl_api_ip6nd_proxy_details_t_handler
10083 (vl_api_ip6nd_proxy_details_t * mp)
10085 vat_main_t *vam = &vat_main;
10087 print (vam->ofp, "host %U sw_if_index %d",
10088 format_vl_api_ip6_address, mp->ip, ntohl (mp->sw_if_index));
10091 static void vl_api_ip6nd_proxy_details_t_handler_json
10092 (vl_api_ip6nd_proxy_details_t * mp)
10094 vat_main_t *vam = &vat_main;
10095 struct in6_addr ip6;
10096 vat_json_node_t *node = NULL;
10098 if (VAT_JSON_ARRAY != vam->json_tree.type)
10100 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10101 vat_json_init_array (&vam->json_tree);
10103 node = vat_json_array_add (&vam->json_tree);
10105 vat_json_init_object (node);
10106 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10108 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
10109 vat_json_object_add_ip6 (node, "host", ip6);
10113 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
10115 unformat_input_t *i = vam->input;
10116 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
10118 u8 sw_if_index_set = 0;
10119 u8 v6_address_set = 0;
10120 vl_api_prefix_t pfx;
10121 u8 use_default = 0;
10122 u8 no_advertise = 0;
10124 u8 no_autoconfig = 0;
10127 u32 val_lifetime = 0;
10128 u32 pref_lifetime = 0;
10131 /* Parse args required to build the message */
10132 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10134 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10135 sw_if_index_set = 1;
10136 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10137 sw_if_index_set = 1;
10138 else if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
10139 v6_address_set = 1;
10140 else if (unformat (i, "val_life %d", &val_lifetime))
10142 else if (unformat (i, "pref_life %d", &pref_lifetime))
10144 else if (unformat (i, "def"))
10146 else if (unformat (i, "noadv"))
10148 else if (unformat (i, "offl"))
10150 else if (unformat (i, "noauto"))
10152 else if (unformat (i, "nolink"))
10154 else if (unformat (i, "isno"))
10158 clib_warning ("parse error '%U'", format_unformat_error, i);
10163 if (sw_if_index_set == 0)
10165 errmsg ("missing interface name or sw_if_index");
10168 if (!v6_address_set)
10170 errmsg ("no address set");
10174 /* Construct the API message */
10175 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
10177 mp->sw_if_index = ntohl (sw_if_index);
10178 clib_memcpy (&mp->prefix, &pfx, sizeof (pfx));
10179 mp->use_default = use_default;
10180 mp->no_advertise = no_advertise;
10181 mp->off_link = off_link;
10182 mp->no_autoconfig = no_autoconfig;
10183 mp->no_onlink = no_onlink;
10185 mp->val_lifetime = ntohl (val_lifetime);
10186 mp->pref_lifetime = ntohl (pref_lifetime);
10191 /* Wait for a reply, return good/bad news */
10197 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
10199 unformat_input_t *i = vam->input;
10200 vl_api_sw_interface_ip6nd_ra_config_t *mp;
10202 u8 sw_if_index_set = 0;
10207 u8 send_unicast = 0;
10210 u8 default_router = 0;
10211 u32 max_interval = 0;
10212 u32 min_interval = 0;
10214 u32 initial_count = 0;
10215 u32 initial_interval = 0;
10219 /* Parse args required to build the message */
10220 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10222 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10223 sw_if_index_set = 1;
10224 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10225 sw_if_index_set = 1;
10226 else if (unformat (i, "maxint %d", &max_interval))
10228 else if (unformat (i, "minint %d", &min_interval))
10230 else if (unformat (i, "life %d", &lifetime))
10232 else if (unformat (i, "count %d", &initial_count))
10234 else if (unformat (i, "interval %d", &initial_interval))
10236 else if (unformat (i, "suppress") || unformat (i, "surpress"))
10238 else if (unformat (i, "managed"))
10240 else if (unformat (i, "other"))
10242 else if (unformat (i, "ll"))
10244 else if (unformat (i, "send"))
10246 else if (unformat (i, "cease"))
10248 else if (unformat (i, "isno"))
10250 else if (unformat (i, "def"))
10251 default_router = 1;
10254 clib_warning ("parse error '%U'", format_unformat_error, i);
10259 if (sw_if_index_set == 0)
10261 errmsg ("missing interface name or sw_if_index");
10265 /* Construct the API message */
10266 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
10268 mp->sw_if_index = ntohl (sw_if_index);
10269 mp->max_interval = ntohl (max_interval);
10270 mp->min_interval = ntohl (min_interval);
10271 mp->lifetime = ntohl (lifetime);
10272 mp->initial_count = ntohl (initial_count);
10273 mp->initial_interval = ntohl (initial_interval);
10274 mp->suppress = suppress;
10275 mp->managed = managed;
10277 mp->ll_option = ll_option;
10278 mp->send_unicast = send_unicast;
10281 mp->default_router = default_router;
10286 /* Wait for a reply, return good/bad news */
10292 api_set_arp_neighbor_limit (vat_main_t * vam)
10294 unformat_input_t *i = vam->input;
10295 vl_api_set_arp_neighbor_limit_t *mp;
10301 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10303 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
10305 else if (unformat (i, "ipv6"))
10309 clib_warning ("parse error '%U'", format_unformat_error, i);
10314 if (limit_set == 0)
10316 errmsg ("missing limit value");
10320 M (SET_ARP_NEIGHBOR_LIMIT, mp);
10322 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
10323 mp->is_ipv6 = is_ipv6;
10331 api_l2_patch_add_del (vat_main_t * vam)
10333 unformat_input_t *i = vam->input;
10334 vl_api_l2_patch_add_del_t *mp;
10335 u32 rx_sw_if_index;
10336 u8 rx_sw_if_index_set = 0;
10337 u32 tx_sw_if_index;
10338 u8 tx_sw_if_index_set = 0;
10342 /* Parse args required to build the message */
10343 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10345 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
10346 rx_sw_if_index_set = 1;
10347 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
10348 tx_sw_if_index_set = 1;
10349 else if (unformat (i, "rx"))
10351 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10353 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10355 rx_sw_if_index_set = 1;
10360 else if (unformat (i, "tx"))
10362 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10364 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10366 tx_sw_if_index_set = 1;
10371 else if (unformat (i, "del"))
10377 if (rx_sw_if_index_set == 0)
10379 errmsg ("missing rx interface name or rx_sw_if_index");
10383 if (tx_sw_if_index_set == 0)
10385 errmsg ("missing tx interface name or tx_sw_if_index");
10389 M (L2_PATCH_ADD_DEL, mp);
10391 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
10392 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
10393 mp->is_add = is_add;
10401 u8 localsid_addr[16];
10410 api_sr_localsid_add_del (vat_main_t * vam)
10412 unformat_input_t *i = vam->input;
10413 vl_api_sr_localsid_add_del_t *mp;
10416 ip6_address_t localsid;
10420 u32 fib_table = ~(u32) 0;
10421 ip6_address_t nh_addr6;
10422 ip4_address_t nh_addr4;
10423 clib_memset (&nh_addr6, 0, sizeof (ip6_address_t));
10424 clib_memset (&nh_addr4, 0, sizeof (ip4_address_t));
10426 bool nexthop_set = 0;
10430 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10432 if (unformat (i, "del"))
10434 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
10435 else if (unformat (i, "next-hop %U", unformat_ip4_address, &nh_addr4))
10437 else if (unformat (i, "next-hop %U", unformat_ip6_address, &nh_addr6))
10439 else if (unformat (i, "behavior %u", &behavior));
10440 else if (unformat (i, "sw_if_index %u", &sw_if_index));
10441 else if (unformat (i, "fib-table %u", &fib_table));
10442 else if (unformat (i, "end.psp %u", &behavior));
10447 M (SR_LOCALSID_ADD_DEL, mp);
10449 clib_memcpy (mp->localsid.addr, &localsid, sizeof (mp->localsid));
10452 clib_memcpy (mp->nh_addr6, &nh_addr6, sizeof (mp->nh_addr6));
10453 clib_memcpy (mp->nh_addr4, &nh_addr4, sizeof (mp->nh_addr4));
10455 mp->behavior = behavior;
10456 mp->sw_if_index = ntohl (sw_if_index);
10457 mp->fib_table = ntohl (fib_table);
10458 mp->end_psp = end_psp;
10459 mp->is_del = is_del;
10467 api_ioam_enable (vat_main_t * vam)
10469 unformat_input_t *input = vam->input;
10470 vl_api_ioam_enable_t *mp;
10472 int has_trace_option = 0;
10473 int has_pot_option = 0;
10474 int has_seqno_option = 0;
10475 int has_analyse_option = 0;
10478 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10480 if (unformat (input, "trace"))
10481 has_trace_option = 1;
10482 else if (unformat (input, "pot"))
10483 has_pot_option = 1;
10484 else if (unformat (input, "seqno"))
10485 has_seqno_option = 1;
10486 else if (unformat (input, "analyse"))
10487 has_analyse_option = 1;
10491 M (IOAM_ENABLE, mp);
10492 mp->id = htons (id);
10493 mp->seqno = has_seqno_option;
10494 mp->analyse = has_analyse_option;
10495 mp->pot_enable = has_pot_option;
10496 mp->trace_enable = has_trace_option;
10505 api_ioam_disable (vat_main_t * vam)
10507 vl_api_ioam_disable_t *mp;
10510 M (IOAM_DISABLE, mp);
10516 #define foreach_tcp_proto_field \
10520 #define foreach_udp_proto_field \
10524 #define foreach_ip4_proto_field \
10536 u16 src_port, dst_port;
10539 #if VPP_API_TEST_BUILTIN == 0
10541 unformat_tcp_mask (unformat_input_t * input, va_list * args)
10543 u8 **maskp = va_arg (*args, u8 **);
10545 u8 found_something = 0;
10548 #define _(a) u8 a=0;
10549 foreach_tcp_proto_field;
10552 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10555 #define _(a) else if (unformat (input, #a)) a=1;
10556 foreach_tcp_proto_field
10562 #define _(a) found_something += a;
10563 foreach_tcp_proto_field;
10566 if (found_something == 0)
10569 vec_validate (mask, sizeof (*tcp) - 1);
10571 tcp = (tcp_header_t *) mask;
10573 #define _(a) if (a) clib_memset (&tcp->a, 0xff, sizeof (tcp->a));
10574 foreach_tcp_proto_field;
10582 unformat_udp_mask (unformat_input_t * input, va_list * args)
10584 u8 **maskp = va_arg (*args, u8 **);
10586 u8 found_something = 0;
10589 #define _(a) u8 a=0;
10590 foreach_udp_proto_field;
10593 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10596 #define _(a) else if (unformat (input, #a)) a=1;
10597 foreach_udp_proto_field
10603 #define _(a) found_something += a;
10604 foreach_udp_proto_field;
10607 if (found_something == 0)
10610 vec_validate (mask, sizeof (*udp) - 1);
10612 udp = (udp_header_t *) mask;
10614 #define _(a) if (a) clib_memset (&udp->a, 0xff, sizeof (udp->a));
10615 foreach_udp_proto_field;
10623 unformat_l4_mask (unformat_input_t * input, va_list * args)
10625 u8 **maskp = va_arg (*args, u8 **);
10626 u16 src_port = 0, dst_port = 0;
10627 tcpudp_header_t *tcpudp;
10629 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10631 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
10633 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
10635 else if (unformat (input, "src_port"))
10637 else if (unformat (input, "dst_port"))
10643 if (!src_port && !dst_port)
10647 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
10649 tcpudp = (tcpudp_header_t *) mask;
10650 tcpudp->src_port = src_port;
10651 tcpudp->dst_port = dst_port;
10659 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10661 u8 **maskp = va_arg (*args, u8 **);
10663 u8 found_something = 0;
10666 #define _(a) u8 a=0;
10667 foreach_ip4_proto_field;
10673 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10675 if (unformat (input, "version"))
10677 else if (unformat (input, "hdr_length"))
10679 else if (unformat (input, "src"))
10681 else if (unformat (input, "dst"))
10683 else if (unformat (input, "proto"))
10686 #define _(a) else if (unformat (input, #a)) a=1;
10687 foreach_ip4_proto_field
10693 #define _(a) found_something += a;
10694 foreach_ip4_proto_field;
10697 if (found_something == 0)
10700 vec_validate (mask, sizeof (*ip) - 1);
10702 ip = (ip4_header_t *) mask;
10704 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
10705 foreach_ip4_proto_field;
10708 ip->ip_version_and_header_length = 0;
10711 ip->ip_version_and_header_length |= 0xF0;
10714 ip->ip_version_and_header_length |= 0x0F;
10720 #define foreach_ip6_proto_field \
10723 _(payload_length) \
10728 unformat_ip6_mask (unformat_input_t * input, va_list * args)
10730 u8 **maskp = va_arg (*args, u8 **);
10732 u8 found_something = 0;
10734 u32 ip_version_traffic_class_and_flow_label;
10736 #define _(a) u8 a=0;
10737 foreach_ip6_proto_field;
10740 u8 traffic_class = 0;
10743 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10745 if (unformat (input, "version"))
10747 else if (unformat (input, "traffic-class"))
10749 else if (unformat (input, "flow-label"))
10751 else if (unformat (input, "src"))
10753 else if (unformat (input, "dst"))
10755 else if (unformat (input, "proto"))
10758 #define _(a) else if (unformat (input, #a)) a=1;
10759 foreach_ip6_proto_field
10765 #define _(a) found_something += a;
10766 foreach_ip6_proto_field;
10769 if (found_something == 0)
10772 vec_validate (mask, sizeof (*ip) - 1);
10774 ip = (ip6_header_t *) mask;
10776 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
10777 foreach_ip6_proto_field;
10780 ip_version_traffic_class_and_flow_label = 0;
10783 ip_version_traffic_class_and_flow_label |= 0xF0000000;
10786 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
10789 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
10791 ip->ip_version_traffic_class_and_flow_label =
10792 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10799 unformat_l3_mask (unformat_input_t * input, va_list * args)
10801 u8 **maskp = va_arg (*args, u8 **);
10803 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10805 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
10807 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
10816 unformat_l2_mask (unformat_input_t * input, va_list * args)
10818 u8 **maskp = va_arg (*args, u8 **);
10825 u8 ignore_tag1 = 0;
10826 u8 ignore_tag2 = 0;
10833 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10835 if (unformat (input, "src"))
10837 else if (unformat (input, "dst"))
10839 else if (unformat (input, "proto"))
10841 else if (unformat (input, "tag1"))
10843 else if (unformat (input, "tag2"))
10845 else if (unformat (input, "ignore-tag1"))
10847 else if (unformat (input, "ignore-tag2"))
10849 else if (unformat (input, "cos1"))
10851 else if (unformat (input, "cos2"))
10853 else if (unformat (input, "dot1q"))
10855 else if (unformat (input, "dot1ad"))
10860 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
10861 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10864 if (tag1 || ignore_tag1 || cos1 || dot1q)
10866 if (tag2 || ignore_tag2 || cos2 || dot1ad)
10869 vec_validate (mask, len - 1);
10872 clib_memset (mask, 0xff, 6);
10875 clib_memset (mask + 6, 0xff, 6);
10877 if (tag2 || dot1ad)
10879 /* inner vlan tag */
10888 mask[21] = mask[20] = 0xff;
10909 mask[16] = mask[17] = 0xff;
10919 mask[12] = mask[13] = 0xff;
10926 unformat_classify_mask (unformat_input_t * input, va_list * args)
10928 u8 **maskp = va_arg (*args, u8 **);
10929 u32 *skipp = va_arg (*args, u32 *);
10930 u32 *matchp = va_arg (*args, u32 *);
10938 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10940 if (unformat (input, "hex %U", unformat_hex_string, &mask))
10942 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
10944 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
10946 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
10960 if (mask || l2 || l3 || l4)
10962 if (l2 || l3 || l4)
10964 /* "With a free Ethernet header in every package" */
10966 vec_validate (l2, 13);
10970 vec_append (mask, l3);
10975 vec_append (mask, l4);
10980 /* Scan forward looking for the first significant mask octet */
10981 for (i = 0; i < vec_len (mask); i++)
10985 /* compute (skip, match) params */
10986 *skipp = i / sizeof (u32x4);
10987 vec_delete (mask, *skipp * sizeof (u32x4), 0);
10989 /* Pad mask to an even multiple of the vector size */
10990 while (vec_len (mask) % sizeof (u32x4))
10991 vec_add1 (mask, 0);
10993 match = vec_len (mask) / sizeof (u32x4);
10995 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
10997 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
10998 if (*tmp || *(tmp + 1))
11003 clib_warning ("BUG: match 0");
11005 _vec_len (mask) = match * sizeof (u32x4);
11015 #endif /* VPP_API_TEST_BUILTIN */
11017 #define foreach_l2_next \
11019 _(ethernet, ETHERNET_INPUT) \
11020 _(ip4, IP4_INPUT) \
11024 unformat_l2_next_index (unformat_input_t * input, va_list * args)
11026 u32 *miss_next_indexp = va_arg (*args, u32 *);
11027 u32 next_index = 0;
11031 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
11035 if (unformat (input, "%d", &tmp))
11044 *miss_next_indexp = next_index;
11048 #define foreach_ip_next \
11051 _(rewrite, REWRITE)
11054 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
11056 u32 *miss_next_indexp = va_arg (*args, u32 *);
11057 u32 next_index = 0;
11061 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
11065 if (unformat (input, "%d", &tmp))
11074 *miss_next_indexp = next_index;
11078 #define foreach_acl_next \
11082 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
11084 u32 *miss_next_indexp = va_arg (*args, u32 *);
11085 u32 next_index = 0;
11089 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
11093 if (unformat (input, "permit"))
11098 else if (unformat (input, "%d", &tmp))
11107 *miss_next_indexp = next_index;
11112 unformat_policer_precolor (unformat_input_t * input, va_list * args)
11114 u32 *r = va_arg (*args, u32 *);
11116 if (unformat (input, "conform-color"))
11117 *r = POLICE_CONFORM;
11118 else if (unformat (input, "exceed-color"))
11119 *r = POLICE_EXCEED;
11127 api_classify_add_del_table (vat_main_t * vam)
11129 unformat_input_t *i = vam->input;
11130 vl_api_classify_add_del_table_t *mp;
11137 u32 table_index = ~0;
11138 u32 next_table_index = ~0;
11139 u32 miss_next_index = ~0;
11140 u32 memory_size = 32 << 20;
11142 u32 current_data_flag = 0;
11143 int current_data_offset = 0;
11146 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11148 if (unformat (i, "del"))
11150 else if (unformat (i, "del-chain"))
11155 else if (unformat (i, "buckets %d", &nbuckets))
11157 else if (unformat (i, "memory_size %d", &memory_size))
11159 else if (unformat (i, "skip %d", &skip))
11161 else if (unformat (i, "match %d", &match))
11163 else if (unformat (i, "table %d", &table_index))
11165 else if (unformat (i, "mask %U", unformat_classify_mask,
11166 &mask, &skip, &match))
11168 else if (unformat (i, "next-table %d", &next_table_index))
11170 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
11173 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
11176 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
11179 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
11181 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
11187 if (is_add && mask == 0)
11189 errmsg ("Mask required");
11193 if (is_add && skip == ~0)
11195 errmsg ("skip count required");
11199 if (is_add && match == ~0)
11201 errmsg ("match count required");
11205 if (!is_add && table_index == ~0)
11207 errmsg ("table index required for delete");
11211 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
11213 mp->is_add = is_add;
11214 mp->del_chain = del_chain;
11215 mp->table_index = ntohl (table_index);
11216 mp->nbuckets = ntohl (nbuckets);
11217 mp->memory_size = ntohl (memory_size);
11218 mp->skip_n_vectors = ntohl (skip);
11219 mp->match_n_vectors = ntohl (match);
11220 mp->next_table_index = ntohl (next_table_index);
11221 mp->miss_next_index = ntohl (miss_next_index);
11222 mp->current_data_flag = ntohl (current_data_flag);
11223 mp->current_data_offset = ntohl (current_data_offset);
11224 mp->mask_len = ntohl (vec_len (mask));
11225 clib_memcpy (mp->mask, mask, vec_len (mask));
11234 #if VPP_API_TEST_BUILTIN == 0
11236 unformat_l4_match (unformat_input_t * input, va_list * args)
11238 u8 **matchp = va_arg (*args, u8 **);
11240 u8 *proto_header = 0;
11246 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11248 if (unformat (input, "src_port %d", &src_port))
11250 else if (unformat (input, "dst_port %d", &dst_port))
11256 h.src_port = clib_host_to_net_u16 (src_port);
11257 h.dst_port = clib_host_to_net_u16 (dst_port);
11258 vec_validate (proto_header, sizeof (h) - 1);
11259 memcpy (proto_header, &h, sizeof (h));
11261 *matchp = proto_header;
11267 unformat_ip4_match (unformat_input_t * input, va_list * args)
11269 u8 **matchp = va_arg (*args, u8 **);
11274 int hdr_length = 0;
11275 u32 hdr_length_val;
11276 int src = 0, dst = 0;
11277 ip4_address_t src_val, dst_val;
11284 int fragment_id = 0;
11285 u32 fragment_id_val;
11291 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11293 if (unformat (input, "version %d", &version_val))
11295 else if (unformat (input, "hdr_length %d", &hdr_length_val))
11297 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
11299 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
11301 else if (unformat (input, "proto %d", &proto_val))
11303 else if (unformat (input, "tos %d", &tos_val))
11305 else if (unformat (input, "length %d", &length_val))
11307 else if (unformat (input, "fragment_id %d", &fragment_id_val))
11309 else if (unformat (input, "ttl %d", &ttl_val))
11311 else if (unformat (input, "checksum %d", &checksum_val))
11317 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
11318 + ttl + checksum == 0)
11322 * Aligned because we use the real comparison functions
11324 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11326 ip = (ip4_header_t *) match;
11328 /* These are realistically matched in practice */
11330 ip->src_address.as_u32 = src_val.as_u32;
11333 ip->dst_address.as_u32 = dst_val.as_u32;
11336 ip->protocol = proto_val;
11339 /* These are not, but they're included for completeness */
11341 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
11344 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
11350 ip->length = clib_host_to_net_u16 (length_val);
11356 ip->checksum = clib_host_to_net_u16 (checksum_val);
11363 unformat_ip6_match (unformat_input_t * input, va_list * args)
11365 u8 **matchp = va_arg (*args, u8 **);
11370 u8 traffic_class = 0;
11371 u32 traffic_class_val = 0;
11374 int src = 0, dst = 0;
11375 ip6_address_t src_val, dst_val;
11378 int payload_length = 0;
11379 u32 payload_length_val;
11382 u32 ip_version_traffic_class_and_flow_label;
11384 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11386 if (unformat (input, "version %d", &version_val))
11388 else if (unformat (input, "traffic_class %d", &traffic_class_val))
11390 else if (unformat (input, "flow_label %d", &flow_label_val))
11392 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
11394 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
11396 else if (unformat (input, "proto %d", &proto_val))
11398 else if (unformat (input, "payload_length %d", &payload_length_val))
11399 payload_length = 1;
11400 else if (unformat (input, "hop_limit %d", &hop_limit_val))
11406 if (version + traffic_class + flow_label + src + dst + proto +
11407 payload_length + hop_limit == 0)
11411 * Aligned because we use the real comparison functions
11413 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11415 ip = (ip6_header_t *) match;
11418 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
11421 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
11424 ip->protocol = proto_val;
11426 ip_version_traffic_class_and_flow_label = 0;
11429 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
11432 ip_version_traffic_class_and_flow_label |=
11433 (traffic_class_val & 0xFF) << 20;
11436 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
11438 ip->ip_version_traffic_class_and_flow_label =
11439 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11441 if (payload_length)
11442 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
11445 ip->hop_limit = hop_limit_val;
11452 unformat_l3_match (unformat_input_t * input, va_list * args)
11454 u8 **matchp = va_arg (*args, u8 **);
11456 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11458 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
11460 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
11469 unformat_vlan_tag (unformat_input_t * input, va_list * args)
11471 u8 *tagp = va_arg (*args, u8 *);
11474 if (unformat (input, "%d", &tag))
11476 tagp[0] = (tag >> 8) & 0x0F;
11477 tagp[1] = tag & 0xFF;
11485 unformat_l2_match (unformat_input_t * input, va_list * args)
11487 u8 **matchp = va_arg (*args, u8 **);
11500 u8 ignore_tag1 = 0;
11501 u8 ignore_tag2 = 0;
11507 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11509 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
11512 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
11514 else if (unformat (input, "proto %U",
11515 unformat_ethernet_type_host_byte_order, &proto_val))
11517 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
11519 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
11521 else if (unformat (input, "ignore-tag1"))
11523 else if (unformat (input, "ignore-tag2"))
11525 else if (unformat (input, "cos1 %d", &cos1_val))
11527 else if (unformat (input, "cos2 %d", &cos2_val))
11532 if ((src + dst + proto + tag1 + tag2 +
11533 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11536 if (tag1 || ignore_tag1 || cos1)
11538 if (tag2 || ignore_tag2 || cos2)
11541 vec_validate_aligned (match, len - 1, sizeof (u32x4));
11544 clib_memcpy (match, dst_val, 6);
11547 clib_memcpy (match + 6, src_val, 6);
11551 /* inner vlan tag */
11552 match[19] = tag2_val[1];
11553 match[18] = tag2_val[0];
11555 match[18] |= (cos2_val & 0x7) << 5;
11558 match[21] = proto_val & 0xff;
11559 match[20] = proto_val >> 8;
11563 match[15] = tag1_val[1];
11564 match[14] = tag1_val[0];
11567 match[14] |= (cos1_val & 0x7) << 5;
11573 match[15] = tag1_val[1];
11574 match[14] = tag1_val[0];
11577 match[17] = proto_val & 0xff;
11578 match[16] = proto_val >> 8;
11581 match[14] |= (cos1_val & 0x7) << 5;
11587 match[18] |= (cos2_val & 0x7) << 5;
11589 match[14] |= (cos1_val & 0x7) << 5;
11592 match[13] = proto_val & 0xff;
11593 match[12] = proto_val >> 8;
11601 unformat_qos_source (unformat_input_t * input, va_list * args)
11603 int *qs = va_arg (*args, int *);
11605 if (unformat (input, "ip"))
11606 *qs = QOS_SOURCE_IP;
11607 else if (unformat (input, "mpls"))
11608 *qs = QOS_SOURCE_MPLS;
11609 else if (unformat (input, "ext"))
11610 *qs = QOS_SOURCE_EXT;
11611 else if (unformat (input, "vlan"))
11612 *qs = QOS_SOURCE_VLAN;
11621 api_unformat_classify_match (unformat_input_t * input, va_list * args)
11623 u8 **matchp = va_arg (*args, u8 **);
11624 u32 skip_n_vectors = va_arg (*args, u32);
11625 u32 match_n_vectors = va_arg (*args, u32);
11632 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11634 if (unformat (input, "hex %U", unformat_hex_string, &match))
11636 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
11638 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
11640 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11654 if (match || l2 || l3 || l4)
11656 if (l2 || l3 || l4)
11658 /* "Win a free Ethernet header in every packet" */
11660 vec_validate_aligned (l2, 13, sizeof (u32x4));
11664 vec_append_aligned (match, l3, sizeof (u32x4));
11669 vec_append_aligned (match, l4, sizeof (u32x4));
11674 /* Make sure the vector is big enough even if key is all 0's */
11675 vec_validate_aligned
11676 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11679 /* Set size, include skipped vectors */
11680 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11691 api_classify_add_del_session (vat_main_t * vam)
11693 unformat_input_t *i = vam->input;
11694 vl_api_classify_add_del_session_t *mp;
11696 u32 table_index = ~0;
11697 u32 hit_next_index = ~0;
11698 u32 opaque_index = ~0;
11701 u32 skip_n_vectors = 0;
11702 u32 match_n_vectors = 0;
11708 * Warning: you have to supply skip_n and match_n
11709 * because the API client cant simply look at the classify
11713 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11715 if (unformat (i, "del"))
11717 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
11720 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
11723 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
11726 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
11728 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
11730 else if (unformat (i, "opaque-index %d", &opaque_index))
11732 else if (unformat (i, "skip_n %d", &skip_n_vectors))
11734 else if (unformat (i, "match_n %d", &match_n_vectors))
11736 else if (unformat (i, "match %U", api_unformat_classify_match,
11737 &match, skip_n_vectors, match_n_vectors))
11739 else if (unformat (i, "advance %d", &advance))
11741 else if (unformat (i, "table-index %d", &table_index))
11743 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
11745 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
11747 else if (unformat (i, "action %d", &action))
11749 else if (unformat (i, "metadata %d", &metadata))
11755 if (table_index == ~0)
11757 errmsg ("Table index required");
11761 if (is_add && match == 0)
11763 errmsg ("Match value required");
11767 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
11769 mp->is_add = is_add;
11770 mp->table_index = ntohl (table_index);
11771 mp->hit_next_index = ntohl (hit_next_index);
11772 mp->opaque_index = ntohl (opaque_index);
11773 mp->advance = ntohl (advance);
11774 mp->action = action;
11775 mp->metadata = ntohl (metadata);
11776 mp->match_len = ntohl (vec_len (match));
11777 clib_memcpy (mp->match, match, vec_len (match));
11786 api_classify_set_interface_ip_table (vat_main_t * vam)
11788 unformat_input_t *i = vam->input;
11789 vl_api_classify_set_interface_ip_table_t *mp;
11791 int sw_if_index_set;
11792 u32 table_index = ~0;
11796 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11798 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11799 sw_if_index_set = 1;
11800 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11801 sw_if_index_set = 1;
11802 else if (unformat (i, "table %d", &table_index))
11806 clib_warning ("parse error '%U'", format_unformat_error, i);
11811 if (sw_if_index_set == 0)
11813 errmsg ("missing interface name or sw_if_index");
11818 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
11820 mp->sw_if_index = ntohl (sw_if_index);
11821 mp->table_index = ntohl (table_index);
11822 mp->is_ipv6 = is_ipv6;
11830 api_classify_set_interface_l2_tables (vat_main_t * vam)
11832 unformat_input_t *i = vam->input;
11833 vl_api_classify_set_interface_l2_tables_t *mp;
11835 int sw_if_index_set;
11836 u32 ip4_table_index = ~0;
11837 u32 ip6_table_index = ~0;
11838 u32 other_table_index = ~0;
11842 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11844 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11845 sw_if_index_set = 1;
11846 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11847 sw_if_index_set = 1;
11848 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11850 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11852 else if (unformat (i, "other-table %d", &other_table_index))
11854 else if (unformat (i, "is-input %d", &is_input))
11858 clib_warning ("parse error '%U'", format_unformat_error, i);
11863 if (sw_if_index_set == 0)
11865 errmsg ("missing interface name or sw_if_index");
11870 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
11872 mp->sw_if_index = ntohl (sw_if_index);
11873 mp->ip4_table_index = ntohl (ip4_table_index);
11874 mp->ip6_table_index = ntohl (ip6_table_index);
11875 mp->other_table_index = ntohl (other_table_index);
11876 mp->is_input = (u8) is_input;
11884 api_set_ipfix_exporter (vat_main_t * vam)
11886 unformat_input_t *i = vam->input;
11887 vl_api_set_ipfix_exporter_t *mp;
11888 ip4_address_t collector_address;
11889 u8 collector_address_set = 0;
11890 u32 collector_port = ~0;
11891 ip4_address_t src_address;
11892 u8 src_address_set = 0;
11895 u32 template_interval = ~0;
11896 u8 udp_checksum = 0;
11899 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11901 if (unformat (i, "collector_address %U", unformat_ip4_address,
11902 &collector_address))
11903 collector_address_set = 1;
11904 else if (unformat (i, "collector_port %d", &collector_port))
11906 else if (unformat (i, "src_address %U", unformat_ip4_address,
11908 src_address_set = 1;
11909 else if (unformat (i, "vrf_id %d", &vrf_id))
11911 else if (unformat (i, "path_mtu %d", &path_mtu))
11913 else if (unformat (i, "template_interval %d", &template_interval))
11915 else if (unformat (i, "udp_checksum"))
11921 if (collector_address_set == 0)
11923 errmsg ("collector_address required");
11927 if (src_address_set == 0)
11929 errmsg ("src_address required");
11933 M (SET_IPFIX_EXPORTER, mp);
11935 memcpy (mp->collector_address, collector_address.data,
11936 sizeof (collector_address.data));
11937 mp->collector_port = htons ((u16) collector_port);
11938 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
11939 mp->vrf_id = htonl (vrf_id);
11940 mp->path_mtu = htonl (path_mtu);
11941 mp->template_interval = htonl (template_interval);
11942 mp->udp_checksum = udp_checksum;
11950 api_set_ipfix_classify_stream (vat_main_t * vam)
11952 unformat_input_t *i = vam->input;
11953 vl_api_set_ipfix_classify_stream_t *mp;
11955 u32 src_port = UDP_DST_PORT_ipfix;
11958 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11960 if (unformat (i, "domain %d", &domain_id))
11962 else if (unformat (i, "src_port %d", &src_port))
11966 errmsg ("unknown input `%U'", format_unformat_error, i);
11971 M (SET_IPFIX_CLASSIFY_STREAM, mp);
11973 mp->domain_id = htonl (domain_id);
11974 mp->src_port = htons ((u16) src_port);
11982 api_ipfix_classify_table_add_del (vat_main_t * vam)
11984 unformat_input_t *i = vam->input;
11985 vl_api_ipfix_classify_table_add_del_t *mp;
11987 u32 classify_table_index = ~0;
11989 u8 transport_protocol = 255;
11992 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11994 if (unformat (i, "add"))
11996 else if (unformat (i, "del"))
11998 else if (unformat (i, "table %d", &classify_table_index))
12000 else if (unformat (i, "ip4"))
12002 else if (unformat (i, "ip6"))
12004 else if (unformat (i, "tcp"))
12005 transport_protocol = 6;
12006 else if (unformat (i, "udp"))
12007 transport_protocol = 17;
12010 errmsg ("unknown input `%U'", format_unformat_error, i);
12017 errmsg ("expecting: add|del");
12020 if (classify_table_index == ~0)
12022 errmsg ("classifier table not specified");
12025 if (ip_version == 0)
12027 errmsg ("IP version not specified");
12031 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
12033 mp->is_add = is_add;
12034 mp->table_id = htonl (classify_table_index);
12035 mp->ip_version = ip_version;
12036 mp->transport_protocol = transport_protocol;
12044 api_get_node_index (vat_main_t * vam)
12046 unformat_input_t *i = vam->input;
12047 vl_api_get_node_index_t *mp;
12051 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12053 if (unformat (i, "node %s", &name))
12060 errmsg ("node name required");
12063 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12065 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12069 M (GET_NODE_INDEX, mp);
12070 clib_memcpy (mp->node_name, name, vec_len (name));
12079 api_get_next_index (vat_main_t * vam)
12081 unformat_input_t *i = vam->input;
12082 vl_api_get_next_index_t *mp;
12083 u8 *node_name = 0, *next_node_name = 0;
12086 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12088 if (unformat (i, "node-name %s", &node_name))
12090 else if (unformat (i, "next-node-name %s", &next_node_name))
12094 if (node_name == 0)
12096 errmsg ("node name required");
12099 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
12101 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12105 if (next_node_name == 0)
12107 errmsg ("next node name required");
12110 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
12112 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
12116 M (GET_NEXT_INDEX, mp);
12117 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
12118 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
12119 vec_free (node_name);
12120 vec_free (next_node_name);
12128 api_add_node_next (vat_main_t * vam)
12130 unformat_input_t *i = vam->input;
12131 vl_api_add_node_next_t *mp;
12136 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12138 if (unformat (i, "node %s", &name))
12140 else if (unformat (i, "next %s", &next))
12147 errmsg ("node name required");
12150 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12152 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12157 errmsg ("next node required");
12160 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
12162 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
12166 M (ADD_NODE_NEXT, mp);
12167 clib_memcpy (mp->node_name, name, vec_len (name));
12168 clib_memcpy (mp->next_name, next, vec_len (next));
12178 api_l2tpv3_create_tunnel (vat_main_t * vam)
12180 unformat_input_t *i = vam->input;
12181 ip6_address_t client_address, our_address;
12182 int client_address_set = 0;
12183 int our_address_set = 0;
12184 u32 local_session_id = 0;
12185 u32 remote_session_id = 0;
12186 u64 local_cookie = 0;
12187 u64 remote_cookie = 0;
12188 u8 l2_sublayer_present = 0;
12189 vl_api_l2tpv3_create_tunnel_t *mp;
12192 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12194 if (unformat (i, "client_address %U", unformat_ip6_address,
12196 client_address_set = 1;
12197 else if (unformat (i, "our_address %U", unformat_ip6_address,
12199 our_address_set = 1;
12200 else if (unformat (i, "local_session_id %d", &local_session_id))
12202 else if (unformat (i, "remote_session_id %d", &remote_session_id))
12204 else if (unformat (i, "local_cookie %lld", &local_cookie))
12206 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
12208 else if (unformat (i, "l2-sublayer-present"))
12209 l2_sublayer_present = 1;
12214 if (client_address_set == 0)
12216 errmsg ("client_address required");
12220 if (our_address_set == 0)
12222 errmsg ("our_address required");
12226 M (L2TPV3_CREATE_TUNNEL, mp);
12228 clib_memcpy (mp->client_address, client_address.as_u8,
12229 sizeof (mp->client_address));
12231 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
12233 mp->local_session_id = ntohl (local_session_id);
12234 mp->remote_session_id = ntohl (remote_session_id);
12235 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
12236 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
12237 mp->l2_sublayer_present = l2_sublayer_present;
12246 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
12248 unformat_input_t *i = vam->input;
12250 u8 sw_if_index_set = 0;
12251 u64 new_local_cookie = 0;
12252 u64 new_remote_cookie = 0;
12253 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
12256 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12258 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12259 sw_if_index_set = 1;
12260 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12261 sw_if_index_set = 1;
12262 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
12264 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
12270 if (sw_if_index_set == 0)
12272 errmsg ("missing interface name or sw_if_index");
12276 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
12278 mp->sw_if_index = ntohl (sw_if_index);
12279 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
12280 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
12288 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
12290 unformat_input_t *i = vam->input;
12291 vl_api_l2tpv3_interface_enable_disable_t *mp;
12293 u8 sw_if_index_set = 0;
12294 u8 enable_disable = 1;
12297 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12299 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12300 sw_if_index_set = 1;
12301 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12302 sw_if_index_set = 1;
12303 else if (unformat (i, "enable"))
12304 enable_disable = 1;
12305 else if (unformat (i, "disable"))
12306 enable_disable = 0;
12311 if (sw_if_index_set == 0)
12313 errmsg ("missing interface name or sw_if_index");
12317 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
12319 mp->sw_if_index = ntohl (sw_if_index);
12320 mp->enable_disable = enable_disable;
12328 api_l2tpv3_set_lookup_key (vat_main_t * vam)
12330 unformat_input_t *i = vam->input;
12331 vl_api_l2tpv3_set_lookup_key_t *mp;
12335 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12337 if (unformat (i, "lookup_v6_src"))
12338 key = L2T_LOOKUP_SRC_ADDRESS;
12339 else if (unformat (i, "lookup_v6_dst"))
12340 key = L2T_LOOKUP_DST_ADDRESS;
12341 else if (unformat (i, "lookup_session_id"))
12342 key = L2T_LOOKUP_SESSION_ID;
12347 if (key == (u8) ~ 0)
12349 errmsg ("l2tp session lookup key unset");
12353 M (L2TPV3_SET_LOOKUP_KEY, mp);
12362 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
12363 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12365 vat_main_t *vam = &vat_main;
12367 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
12368 format_ip6_address, mp->our_address,
12369 format_ip6_address, mp->client_address,
12370 clib_net_to_host_u32 (mp->sw_if_index));
12373 " local cookies %016llx %016llx remote cookie %016llx",
12374 clib_net_to_host_u64 (mp->local_cookie[0]),
12375 clib_net_to_host_u64 (mp->local_cookie[1]),
12376 clib_net_to_host_u64 (mp->remote_cookie));
12378 print (vam->ofp, " local session-id %d remote session-id %d",
12379 clib_net_to_host_u32 (mp->local_session_id),
12380 clib_net_to_host_u32 (mp->remote_session_id));
12382 print (vam->ofp, " l2 specific sublayer %s\n",
12383 mp->l2_sublayer_present ? "preset" : "absent");
12387 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
12388 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12390 vat_main_t *vam = &vat_main;
12391 vat_json_node_t *node = NULL;
12392 struct in6_addr addr;
12394 if (VAT_JSON_ARRAY != vam->json_tree.type)
12396 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12397 vat_json_init_array (&vam->json_tree);
12399 node = vat_json_array_add (&vam->json_tree);
12401 vat_json_init_object (node);
12403 clib_memcpy (&addr, mp->our_address, sizeof (addr));
12404 vat_json_object_add_ip6 (node, "our_address", addr);
12405 clib_memcpy (&addr, mp->client_address, sizeof (addr));
12406 vat_json_object_add_ip6 (node, "client_address", addr);
12408 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
12409 vat_json_init_array (lc);
12410 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
12411 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
12412 vat_json_object_add_uint (node, "remote_cookie",
12413 clib_net_to_host_u64 (mp->remote_cookie));
12415 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
12416 vat_json_object_add_uint (node, "local_session_id",
12417 clib_net_to_host_u32 (mp->local_session_id));
12418 vat_json_object_add_uint (node, "remote_session_id",
12419 clib_net_to_host_u32 (mp->remote_session_id));
12420 vat_json_object_add_string_copy (node, "l2_sublayer",
12421 mp->l2_sublayer_present ? (u8 *) "present"
12422 : (u8 *) "absent");
12426 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
12428 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
12429 vl_api_control_ping_t *mp_ping;
12432 /* Get list of l2tpv3-tunnel interfaces */
12433 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
12436 /* Use a control ping for synchronization */
12437 MPING (CONTROL_PING, mp_ping);
12445 static void vl_api_sw_interface_tap_v2_details_t_handler
12446 (vl_api_sw_interface_tap_v2_details_t * mp)
12448 vat_main_t *vam = &vat_main;
12450 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
12451 mp->host_ip4_prefix_len);
12452 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
12453 mp->host_ip6_prefix_len);
12456 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s 0x%-08x",
12457 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
12458 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12459 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
12460 mp->host_bridge, ip4, ip6, ntohl (mp->tap_flags));
12466 static void vl_api_sw_interface_tap_v2_details_t_handler_json
12467 (vl_api_sw_interface_tap_v2_details_t * mp)
12469 vat_main_t *vam = &vat_main;
12470 vat_json_node_t *node = NULL;
12472 if (VAT_JSON_ARRAY != vam->json_tree.type)
12474 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12475 vat_json_init_array (&vam->json_tree);
12477 node = vat_json_array_add (&vam->json_tree);
12479 vat_json_init_object (node);
12480 vat_json_object_add_uint (node, "id", ntohl (mp->id));
12481 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12482 vat_json_object_add_uint (node, "tap_flags", ntohl (mp->tap_flags));
12483 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12484 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12485 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12486 vat_json_object_add_string_copy (node, "host_mac_addr",
12487 format (0, "%U", format_ethernet_address,
12488 &mp->host_mac_addr));
12489 vat_json_object_add_string_copy (node, "host_namespace",
12490 mp->host_namespace);
12491 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
12492 vat_json_object_add_string_copy (node, "host_ip4_addr",
12493 format (0, "%U/%d", format_ip4_address,
12495 mp->host_ip4_prefix_len));
12496 vat_json_object_add_string_copy (node, "host_ip6_addr",
12497 format (0, "%U/%d", format_ip6_address,
12499 mp->host_ip6_prefix_len));
12504 api_sw_interface_tap_v2_dump (vat_main_t * vam)
12506 vl_api_sw_interface_tap_v2_dump_t *mp;
12507 vl_api_control_ping_t *mp_ping;
12511 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
12512 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
12513 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
12516 /* Get list of tap interfaces */
12517 M (SW_INTERFACE_TAP_V2_DUMP, mp);
12520 /* Use a control ping for synchronization */
12521 MPING (CONTROL_PING, mp_ping);
12528 static void vl_api_sw_interface_virtio_pci_details_t_handler
12529 (vl_api_sw_interface_virtio_pci_details_t * mp)
12531 vat_main_t *vam = &vat_main;
12545 addr.as_u32 = ntohl (mp->pci_addr);
12546 u8 *pci_addr = format (0, "%04x:%02x:%02x.%x", addr.domain, addr.bus,
12547 addr.slot, addr.function);
12550 "\n%-12s %-12d %-12d %-12d %-17U 0x%-08llx",
12551 pci_addr, ntohl (mp->sw_if_index),
12552 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12553 format_ethernet_address, mp->mac_addr,
12554 clib_net_to_host_u64 (mp->features));
12555 vec_free (pci_addr);
12558 static void vl_api_sw_interface_virtio_pci_details_t_handler_json
12559 (vl_api_sw_interface_virtio_pci_details_t * mp)
12561 vat_main_t *vam = &vat_main;
12562 vat_json_node_t *node = NULL;
12564 if (VAT_JSON_ARRAY != vam->json_tree.type)
12566 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12567 vat_json_init_array (&vam->json_tree);
12569 node = vat_json_array_add (&vam->json_tree);
12571 vat_json_init_object (node);
12572 vat_json_object_add_uint (node, "pci-addr", ntohl (mp->pci_addr));
12573 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12574 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12575 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12576 vat_json_object_add_uint (node, "features",
12577 clib_net_to_host_u64 (mp->features));
12578 vat_json_object_add_string_copy (node, "mac_addr",
12579 format (0, "%U", format_ethernet_address,
12584 api_sw_interface_virtio_pci_dump (vat_main_t * vam)
12586 vl_api_sw_interface_virtio_pci_dump_t *mp;
12587 vl_api_control_ping_t *mp_ping;
12591 "\n%-12s %-12s %-12s %-12s %-17s %-08s",
12592 "pci_addr", "sw_if_index", "rx_ring_sz", "tx_ring_sz",
12593 "mac_addr", "features");
12595 /* Get list of tap interfaces */
12596 M (SW_INTERFACE_VIRTIO_PCI_DUMP, mp);
12599 /* Use a control ping for synchronization */
12600 MPING (CONTROL_PING, mp_ping);
12608 api_vxlan_offload_rx (vat_main_t * vam)
12610 unformat_input_t *line_input = vam->input;
12611 vl_api_vxlan_offload_rx_t *mp;
12612 u32 hw_if_index = ~0, rx_if_index = ~0;
12616 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12618 if (unformat (line_input, "del"))
12620 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
12623 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
12625 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
12628 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
12632 errmsg ("parse error '%U'", format_unformat_error, line_input);
12637 if (hw_if_index == ~0)
12639 errmsg ("no hw interface");
12643 if (rx_if_index == ~0)
12645 errmsg ("no rx tunnel");
12649 M (VXLAN_OFFLOAD_RX, mp);
12651 mp->hw_if_index = ntohl (hw_if_index);
12652 mp->sw_if_index = ntohl (rx_if_index);
12653 mp->enable = is_add;
12660 static uword unformat_vxlan_decap_next
12661 (unformat_input_t * input, va_list * args)
12663 u32 *result = va_arg (*args, u32 *);
12666 if (unformat (input, "l2"))
12667 *result = VXLAN_INPUT_NEXT_L2_INPUT;
12668 else if (unformat (input, "%d", &tmp))
12676 api_vxlan_add_del_tunnel (vat_main_t * vam)
12678 unformat_input_t *line_input = vam->input;
12679 vl_api_vxlan_add_del_tunnel_t *mp;
12680 ip46_address_t src, dst;
12682 u8 ipv4_set = 0, ipv6_set = 0;
12687 u32 mcast_sw_if_index = ~0;
12688 u32 encap_vrf_id = 0;
12689 u32 decap_next_index = ~0;
12693 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12694 clib_memset (&src, 0, sizeof src);
12695 clib_memset (&dst, 0, sizeof dst);
12697 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12699 if (unformat (line_input, "del"))
12701 else if (unformat (line_input, "instance %d", &instance))
12704 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12710 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12716 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12722 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12727 else if (unformat (line_input, "group %U %U",
12728 unformat_ip4_address, &dst.ip4,
12729 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12731 grp_set = dst_set = 1;
12734 else if (unformat (line_input, "group %U",
12735 unformat_ip4_address, &dst.ip4))
12737 grp_set = dst_set = 1;
12740 else if (unformat (line_input, "group %U %U",
12741 unformat_ip6_address, &dst.ip6,
12742 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12744 grp_set = dst_set = 1;
12747 else if (unformat (line_input, "group %U",
12748 unformat_ip6_address, &dst.ip6))
12750 grp_set = dst_set = 1;
12754 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12756 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12758 else if (unformat (line_input, "decap-next %U",
12759 unformat_vxlan_decap_next, &decap_next_index))
12761 else if (unformat (line_input, "vni %d", &vni))
12765 errmsg ("parse error '%U'", format_unformat_error, line_input);
12772 errmsg ("tunnel src address not specified");
12777 errmsg ("tunnel dst address not specified");
12781 if (grp_set && !ip46_address_is_multicast (&dst))
12783 errmsg ("tunnel group address not multicast");
12786 if (grp_set && mcast_sw_if_index == ~0)
12788 errmsg ("tunnel nonexistent multicast device");
12791 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12793 errmsg ("tunnel dst address must be unicast");
12798 if (ipv4_set && ipv6_set)
12800 errmsg ("both IPv4 and IPv6 addresses specified");
12804 if ((vni == 0) || (vni >> 24))
12806 errmsg ("vni not specified or out of range");
12810 M (VXLAN_ADD_DEL_TUNNEL, mp);
12814 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
12815 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
12819 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
12820 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
12823 mp->instance = htonl (instance);
12824 mp->encap_vrf_id = ntohl (encap_vrf_id);
12825 mp->decap_next_index = ntohl (decap_next_index);
12826 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12827 mp->vni = ntohl (vni);
12828 mp->is_add = is_add;
12829 mp->is_ipv6 = ipv6_set;
12836 static void vl_api_vxlan_tunnel_details_t_handler
12837 (vl_api_vxlan_tunnel_details_t * mp)
12839 vat_main_t *vam = &vat_main;
12840 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12841 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12843 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
12844 ntohl (mp->sw_if_index),
12845 ntohl (mp->instance),
12846 format_ip46_address, &src, IP46_TYPE_ANY,
12847 format_ip46_address, &dst, IP46_TYPE_ANY,
12848 ntohl (mp->encap_vrf_id),
12849 ntohl (mp->decap_next_index), ntohl (mp->vni),
12850 ntohl (mp->mcast_sw_if_index));
12853 static void vl_api_vxlan_tunnel_details_t_handler_json
12854 (vl_api_vxlan_tunnel_details_t * mp)
12856 vat_main_t *vam = &vat_main;
12857 vat_json_node_t *node = NULL;
12859 if (VAT_JSON_ARRAY != vam->json_tree.type)
12861 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12862 vat_json_init_array (&vam->json_tree);
12864 node = vat_json_array_add (&vam->json_tree);
12866 vat_json_init_object (node);
12867 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12869 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
12873 struct in6_addr ip6;
12875 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12876 vat_json_object_add_ip6 (node, "src_address", ip6);
12877 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12878 vat_json_object_add_ip6 (node, "dst_address", ip6);
12882 struct in_addr ip4;
12884 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12885 vat_json_object_add_ip4 (node, "src_address", ip4);
12886 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12887 vat_json_object_add_ip4 (node, "dst_address", ip4);
12889 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12890 vat_json_object_add_uint (node, "decap_next_index",
12891 ntohl (mp->decap_next_index));
12892 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12893 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12894 vat_json_object_add_uint (node, "mcast_sw_if_index",
12895 ntohl (mp->mcast_sw_if_index));
12899 api_vxlan_tunnel_dump (vat_main_t * vam)
12901 unformat_input_t *i = vam->input;
12902 vl_api_vxlan_tunnel_dump_t *mp;
12903 vl_api_control_ping_t *mp_ping;
12905 u8 sw_if_index_set = 0;
12908 /* Parse args required to build the message */
12909 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12911 if (unformat (i, "sw_if_index %d", &sw_if_index))
12912 sw_if_index_set = 1;
12917 if (sw_if_index_set == 0)
12922 if (!vam->json_output)
12924 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
12925 "sw_if_index", "instance", "src_address", "dst_address",
12926 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12929 /* Get list of vxlan-tunnel interfaces */
12930 M (VXLAN_TUNNEL_DUMP, mp);
12932 mp->sw_if_index = htonl (sw_if_index);
12936 /* Use a control ping for synchronization */
12937 MPING (CONTROL_PING, mp_ping);
12944 static uword unformat_geneve_decap_next
12945 (unformat_input_t * input, va_list * args)
12947 u32 *result = va_arg (*args, u32 *);
12950 if (unformat (input, "l2"))
12951 *result = GENEVE_INPUT_NEXT_L2_INPUT;
12952 else if (unformat (input, "%d", &tmp))
12960 api_geneve_add_del_tunnel (vat_main_t * vam)
12962 unformat_input_t *line_input = vam->input;
12963 vl_api_geneve_add_del_tunnel_t *mp;
12964 ip46_address_t src, dst;
12966 u8 ipv4_set = 0, ipv6_set = 0;
12970 u32 mcast_sw_if_index = ~0;
12971 u32 encap_vrf_id = 0;
12972 u32 decap_next_index = ~0;
12976 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12977 clib_memset (&src, 0, sizeof src);
12978 clib_memset (&dst, 0, sizeof dst);
12980 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12982 if (unformat (line_input, "del"))
12985 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12991 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12997 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13003 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13008 else if (unformat (line_input, "group %U %U",
13009 unformat_ip4_address, &dst.ip4,
13010 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13012 grp_set = dst_set = 1;
13015 else if (unformat (line_input, "group %U",
13016 unformat_ip4_address, &dst.ip4))
13018 grp_set = dst_set = 1;
13021 else if (unformat (line_input, "group %U %U",
13022 unformat_ip6_address, &dst.ip6,
13023 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13025 grp_set = dst_set = 1;
13028 else if (unformat (line_input, "group %U",
13029 unformat_ip6_address, &dst.ip6))
13031 grp_set = dst_set = 1;
13035 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13037 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13039 else if (unformat (line_input, "decap-next %U",
13040 unformat_geneve_decap_next, &decap_next_index))
13042 else if (unformat (line_input, "vni %d", &vni))
13046 errmsg ("parse error '%U'", format_unformat_error, line_input);
13053 errmsg ("tunnel src address not specified");
13058 errmsg ("tunnel dst address not specified");
13062 if (grp_set && !ip46_address_is_multicast (&dst))
13064 errmsg ("tunnel group address not multicast");
13067 if (grp_set && mcast_sw_if_index == ~0)
13069 errmsg ("tunnel nonexistent multicast device");
13072 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13074 errmsg ("tunnel dst address must be unicast");
13079 if (ipv4_set && ipv6_set)
13081 errmsg ("both IPv4 and IPv6 addresses specified");
13085 if ((vni == 0) || (vni >> 24))
13087 errmsg ("vni not specified or out of range");
13091 M (GENEVE_ADD_DEL_TUNNEL, mp);
13095 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
13096 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
13100 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
13101 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
13103 mp->encap_vrf_id = ntohl (encap_vrf_id);
13104 mp->decap_next_index = ntohl (decap_next_index);
13105 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13106 mp->vni = ntohl (vni);
13107 mp->is_add = is_add;
13108 mp->is_ipv6 = ipv6_set;
13115 static void vl_api_geneve_tunnel_details_t_handler
13116 (vl_api_geneve_tunnel_details_t * mp)
13118 vat_main_t *vam = &vat_main;
13119 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13120 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13122 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
13123 ntohl (mp->sw_if_index),
13124 format_ip46_address, &src, IP46_TYPE_ANY,
13125 format_ip46_address, &dst, IP46_TYPE_ANY,
13126 ntohl (mp->encap_vrf_id),
13127 ntohl (mp->decap_next_index), ntohl (mp->vni),
13128 ntohl (mp->mcast_sw_if_index));
13131 static void vl_api_geneve_tunnel_details_t_handler_json
13132 (vl_api_geneve_tunnel_details_t * mp)
13134 vat_main_t *vam = &vat_main;
13135 vat_json_node_t *node = NULL;
13137 if (VAT_JSON_ARRAY != vam->json_tree.type)
13139 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13140 vat_json_init_array (&vam->json_tree);
13142 node = vat_json_array_add (&vam->json_tree);
13144 vat_json_init_object (node);
13145 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13148 struct in6_addr ip6;
13150 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13151 vat_json_object_add_ip6 (node, "src_address", ip6);
13152 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13153 vat_json_object_add_ip6 (node, "dst_address", ip6);
13157 struct in_addr ip4;
13159 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13160 vat_json_object_add_ip4 (node, "src_address", ip4);
13161 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13162 vat_json_object_add_ip4 (node, "dst_address", ip4);
13164 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13165 vat_json_object_add_uint (node, "decap_next_index",
13166 ntohl (mp->decap_next_index));
13167 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13168 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13169 vat_json_object_add_uint (node, "mcast_sw_if_index",
13170 ntohl (mp->mcast_sw_if_index));
13174 api_geneve_tunnel_dump (vat_main_t * vam)
13176 unformat_input_t *i = vam->input;
13177 vl_api_geneve_tunnel_dump_t *mp;
13178 vl_api_control_ping_t *mp_ping;
13180 u8 sw_if_index_set = 0;
13183 /* Parse args required to build the message */
13184 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13186 if (unformat (i, "sw_if_index %d", &sw_if_index))
13187 sw_if_index_set = 1;
13192 if (sw_if_index_set == 0)
13197 if (!vam->json_output)
13199 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
13200 "sw_if_index", "local_address", "remote_address",
13201 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13204 /* Get list of geneve-tunnel interfaces */
13205 M (GENEVE_TUNNEL_DUMP, mp);
13207 mp->sw_if_index = htonl (sw_if_index);
13211 /* Use a control ping for synchronization */
13212 M (CONTROL_PING, mp_ping);
13220 api_gre_tunnel_add_del (vat_main_t * vam)
13222 unformat_input_t *line_input = vam->input;
13223 vl_api_address_t src = { }, dst =
13226 vl_api_gre_tunnel_add_del_t *mp;
13227 vl_api_gre_tunnel_type_t t_type;
13231 u32 outer_fib_id = 0;
13232 u32 session_id = 0;
13236 t_type = GRE_API_TUNNEL_TYPE_L3;
13238 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13240 if (unformat (line_input, "del"))
13242 else if (unformat (line_input, "instance %d", &instance))
13244 else if (unformat (line_input, "src %U", unformat_vl_api_address, &src))
13248 else if (unformat (line_input, "dst %U", unformat_vl_api_address, &dst))
13252 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
13254 else if (unformat (line_input, "teb"))
13255 t_type = GRE_API_TUNNEL_TYPE_TEB;
13256 else if (unformat (line_input, "erspan %d", &session_id))
13257 t_type = GRE_API_TUNNEL_TYPE_ERSPAN;
13260 errmsg ("parse error '%U'", format_unformat_error, line_input);
13267 errmsg ("tunnel src address not specified");
13272 errmsg ("tunnel dst address not specified");
13276 M (GRE_TUNNEL_ADD_DEL, mp);
13278 clib_memcpy (&mp->tunnel.src, &src, sizeof (mp->tunnel.src));
13279 clib_memcpy (&mp->tunnel.dst, &dst, sizeof (mp->tunnel.dst));
13281 mp->tunnel.instance = htonl (instance);
13282 mp->tunnel.outer_fib_id = htonl (outer_fib_id);
13283 mp->is_add = is_add;
13284 mp->tunnel.session_id = htons ((u16) session_id);
13285 mp->tunnel.type = htonl (t_type);
13292 static void vl_api_gre_tunnel_details_t_handler
13293 (vl_api_gre_tunnel_details_t * mp)
13295 vat_main_t *vam = &vat_main;
13297 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
13298 ntohl (mp->tunnel.sw_if_index),
13299 ntohl (mp->tunnel.instance),
13300 format_vl_api_address, &mp->tunnel.src,
13301 format_vl_api_address, &mp->tunnel.dst,
13302 mp->tunnel.type, ntohl (mp->tunnel.outer_fib_id),
13303 ntohl (mp->tunnel.session_id));
13307 vat_json_object_add_address (vat_json_node_t * node,
13308 const char *str, const vl_api_address_t * addr)
13310 if (ADDRESS_IP6 == addr->af)
13312 struct in6_addr ip6;
13314 clib_memcpy (&ip6, &addr->un.ip6, sizeof (ip6));
13315 vat_json_object_add_ip6 (node, str, ip6);
13319 struct in_addr ip4;
13321 clib_memcpy (&ip4, &addr->un.ip4, sizeof (ip4));
13322 vat_json_object_add_ip4 (node, str, ip4);
13326 static void vl_api_gre_tunnel_details_t_handler_json
13327 (vl_api_gre_tunnel_details_t * mp)
13329 vat_main_t *vam = &vat_main;
13330 vat_json_node_t *node = NULL;
13332 if (VAT_JSON_ARRAY != vam->json_tree.type)
13334 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13335 vat_json_init_array (&vam->json_tree);
13337 node = vat_json_array_add (&vam->json_tree);
13339 vat_json_init_object (node);
13340 vat_json_object_add_uint (node, "sw_if_index",
13341 ntohl (mp->tunnel.sw_if_index));
13342 vat_json_object_add_uint (node, "instance", ntohl (mp->tunnel.instance));
13344 vat_json_object_add_address (node, "src", &mp->tunnel.src);
13345 vat_json_object_add_address (node, "dst", &mp->tunnel.dst);
13346 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel.type);
13347 vat_json_object_add_uint (node, "outer_fib_id",
13348 ntohl (mp->tunnel.outer_fib_id));
13349 vat_json_object_add_uint (node, "session_id", mp->tunnel.session_id);
13353 api_gre_tunnel_dump (vat_main_t * vam)
13355 unformat_input_t *i = vam->input;
13356 vl_api_gre_tunnel_dump_t *mp;
13357 vl_api_control_ping_t *mp_ping;
13359 u8 sw_if_index_set = 0;
13362 /* Parse args required to build the message */
13363 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13365 if (unformat (i, "sw_if_index %d", &sw_if_index))
13366 sw_if_index_set = 1;
13371 if (sw_if_index_set == 0)
13376 if (!vam->json_output)
13378 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
13379 "sw_if_index", "instance", "src_address", "dst_address",
13380 "tunnel_type", "outer_fib_id", "session_id");
13383 /* Get list of gre-tunnel interfaces */
13384 M (GRE_TUNNEL_DUMP, mp);
13386 mp->sw_if_index = htonl (sw_if_index);
13390 /* Use a control ping for synchronization */
13391 MPING (CONTROL_PING, mp_ping);
13399 api_l2_fib_clear_table (vat_main_t * vam)
13401 // unformat_input_t * i = vam->input;
13402 vl_api_l2_fib_clear_table_t *mp;
13405 M (L2_FIB_CLEAR_TABLE, mp);
13413 api_l2_interface_efp_filter (vat_main_t * vam)
13415 unformat_input_t *i = vam->input;
13416 vl_api_l2_interface_efp_filter_t *mp;
13419 u8 sw_if_index_set = 0;
13422 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13424 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13425 sw_if_index_set = 1;
13426 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13427 sw_if_index_set = 1;
13428 else if (unformat (i, "enable"))
13430 else if (unformat (i, "disable"))
13434 clib_warning ("parse error '%U'", format_unformat_error, i);
13439 if (sw_if_index_set == 0)
13441 errmsg ("missing sw_if_index");
13445 M (L2_INTERFACE_EFP_FILTER, mp);
13447 mp->sw_if_index = ntohl (sw_if_index);
13448 mp->enable_disable = enable;
13455 #define foreach_vtr_op \
13456 _("disable", L2_VTR_DISABLED) \
13457 _("push-1", L2_VTR_PUSH_1) \
13458 _("push-2", L2_VTR_PUSH_2) \
13459 _("pop-1", L2_VTR_POP_1) \
13460 _("pop-2", L2_VTR_POP_2) \
13461 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
13462 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
13463 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
13464 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
13467 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
13469 unformat_input_t *i = vam->input;
13470 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
13472 u8 sw_if_index_set = 0;
13475 u32 push_dot1q = 1;
13480 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13482 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13483 sw_if_index_set = 1;
13484 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13485 sw_if_index_set = 1;
13486 else if (unformat (i, "vtr_op %d", &vtr_op))
13488 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
13491 else if (unformat (i, "push_dot1q %d", &push_dot1q))
13493 else if (unformat (i, "tag1 %d", &tag1))
13495 else if (unformat (i, "tag2 %d", &tag2))
13499 clib_warning ("parse error '%U'", format_unformat_error, i);
13504 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
13506 errmsg ("missing vtr operation or sw_if_index");
13510 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
13511 mp->sw_if_index = ntohl (sw_if_index);
13512 mp->vtr_op = ntohl (vtr_op);
13513 mp->push_dot1q = ntohl (push_dot1q);
13514 mp->tag1 = ntohl (tag1);
13515 mp->tag2 = ntohl (tag2);
13523 api_create_vhost_user_if (vat_main_t * vam)
13525 unformat_input_t *i = vam->input;
13526 vl_api_create_vhost_user_if_t *mp;
13529 u8 file_name_set = 0;
13530 u32 custom_dev_instance = ~0;
13532 u8 use_custom_mac = 0;
13533 u8 disable_mrg_rxbuf = 0;
13534 u8 disable_indirect_desc = 0;
13538 /* Shut up coverity */
13539 clib_memset (hwaddr, 0, sizeof (hwaddr));
13541 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13543 if (unformat (i, "socket %s", &file_name))
13547 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13549 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
13550 use_custom_mac = 1;
13551 else if (unformat (i, "server"))
13553 else if (unformat (i, "disable_mrg_rxbuf"))
13554 disable_mrg_rxbuf = 1;
13555 else if (unformat (i, "disable_indirect_desc"))
13556 disable_indirect_desc = 1;
13557 else if (unformat (i, "tag %s", &tag))
13563 if (file_name_set == 0)
13565 errmsg ("missing socket file name");
13569 if (vec_len (file_name) > 255)
13571 errmsg ("socket file name too long");
13574 vec_add1 (file_name, 0);
13576 M (CREATE_VHOST_USER_IF, mp);
13578 mp->is_server = is_server;
13579 mp->disable_mrg_rxbuf = disable_mrg_rxbuf;
13580 mp->disable_indirect_desc = disable_indirect_desc;
13581 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13582 vec_free (file_name);
13583 if (custom_dev_instance != ~0)
13586 mp->custom_dev_instance = ntohl (custom_dev_instance);
13589 mp->use_custom_mac = use_custom_mac;
13590 clib_memcpy (mp->mac_address, hwaddr, 6);
13592 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
13601 api_modify_vhost_user_if (vat_main_t * vam)
13603 unformat_input_t *i = vam->input;
13604 vl_api_modify_vhost_user_if_t *mp;
13607 u8 file_name_set = 0;
13608 u32 custom_dev_instance = ~0;
13609 u8 sw_if_index_set = 0;
13610 u32 sw_if_index = (u32) ~ 0;
13613 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13615 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13616 sw_if_index_set = 1;
13617 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13618 sw_if_index_set = 1;
13619 else if (unformat (i, "socket %s", &file_name))
13623 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13625 else if (unformat (i, "server"))
13631 if (sw_if_index_set == 0)
13633 errmsg ("missing sw_if_index or interface name");
13637 if (file_name_set == 0)
13639 errmsg ("missing socket file name");
13643 if (vec_len (file_name) > 255)
13645 errmsg ("socket file name too long");
13648 vec_add1 (file_name, 0);
13650 M (MODIFY_VHOST_USER_IF, mp);
13652 mp->sw_if_index = ntohl (sw_if_index);
13653 mp->is_server = is_server;
13654 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13655 vec_free (file_name);
13656 if (custom_dev_instance != ~0)
13659 mp->custom_dev_instance = ntohl (custom_dev_instance);
13668 api_delete_vhost_user_if (vat_main_t * vam)
13670 unformat_input_t *i = vam->input;
13671 vl_api_delete_vhost_user_if_t *mp;
13672 u32 sw_if_index = ~0;
13673 u8 sw_if_index_set = 0;
13676 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13678 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13679 sw_if_index_set = 1;
13680 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13681 sw_if_index_set = 1;
13686 if (sw_if_index_set == 0)
13688 errmsg ("missing sw_if_index or interface name");
13693 M (DELETE_VHOST_USER_IF, mp);
13695 mp->sw_if_index = ntohl (sw_if_index);
13702 static void vl_api_sw_interface_vhost_user_details_t_handler
13703 (vl_api_sw_interface_vhost_user_details_t * mp)
13705 vat_main_t *vam = &vat_main;
13707 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
13708 (char *) mp->interface_name,
13709 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
13710 clib_net_to_host_u64 (mp->features), mp->is_server,
13711 ntohl (mp->num_regions), (char *) mp->sock_filename);
13712 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
13715 static void vl_api_sw_interface_vhost_user_details_t_handler_json
13716 (vl_api_sw_interface_vhost_user_details_t * mp)
13718 vat_main_t *vam = &vat_main;
13719 vat_json_node_t *node = NULL;
13721 if (VAT_JSON_ARRAY != vam->json_tree.type)
13723 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13724 vat_json_init_array (&vam->json_tree);
13726 node = vat_json_array_add (&vam->json_tree);
13728 vat_json_init_object (node);
13729 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13730 vat_json_object_add_string_copy (node, "interface_name",
13731 mp->interface_name);
13732 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
13733 ntohl (mp->virtio_net_hdr_sz));
13734 vat_json_object_add_uint (node, "features",
13735 clib_net_to_host_u64 (mp->features));
13736 vat_json_object_add_uint (node, "is_server", mp->is_server);
13737 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
13738 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
13739 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
13743 api_sw_interface_vhost_user_dump (vat_main_t * vam)
13745 vl_api_sw_interface_vhost_user_dump_t *mp;
13746 vl_api_control_ping_t *mp_ping;
13749 "Interface name idx hdr_sz features server regions filename");
13751 /* Get list of vhost-user interfaces */
13752 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
13755 /* Use a control ping for synchronization */
13756 MPING (CONTROL_PING, mp_ping);
13764 api_show_version (vat_main_t * vam)
13766 vl_api_show_version_t *mp;
13769 M (SHOW_VERSION, mp);
13778 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
13780 unformat_input_t *line_input = vam->input;
13781 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
13782 ip4_address_t local4, remote4;
13783 ip6_address_t local6, remote6;
13785 u8 ipv4_set = 0, ipv6_set = 0;
13789 u32 mcast_sw_if_index = ~0;
13790 u32 encap_vrf_id = 0;
13791 u32 decap_vrf_id = 0;
13797 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13798 clib_memset (&local4, 0, sizeof local4);
13799 clib_memset (&remote4, 0, sizeof remote4);
13800 clib_memset (&local6, 0, sizeof local6);
13801 clib_memset (&remote6, 0, sizeof remote6);
13803 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13805 if (unformat (line_input, "del"))
13807 else if (unformat (line_input, "local %U",
13808 unformat_ip4_address, &local4))
13813 else if (unformat (line_input, "remote %U",
13814 unformat_ip4_address, &remote4))
13819 else if (unformat (line_input, "local %U",
13820 unformat_ip6_address, &local6))
13825 else if (unformat (line_input, "remote %U",
13826 unformat_ip6_address, &remote6))
13831 else if (unformat (line_input, "group %U %U",
13832 unformat_ip4_address, &remote4,
13833 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13835 grp_set = remote_set = 1;
13838 else if (unformat (line_input, "group %U",
13839 unformat_ip4_address, &remote4))
13841 grp_set = remote_set = 1;
13844 else if (unformat (line_input, "group %U %U",
13845 unformat_ip6_address, &remote6,
13846 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13848 grp_set = remote_set = 1;
13851 else if (unformat (line_input, "group %U",
13852 unformat_ip6_address, &remote6))
13854 grp_set = remote_set = 1;
13858 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13860 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13862 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
13864 else if (unformat (line_input, "vni %d", &vni))
13866 else if (unformat (line_input, "next-ip4"))
13868 else if (unformat (line_input, "next-ip6"))
13870 else if (unformat (line_input, "next-ethernet"))
13872 else if (unformat (line_input, "next-nsh"))
13876 errmsg ("parse error '%U'", format_unformat_error, line_input);
13881 if (local_set == 0)
13883 errmsg ("tunnel local address not specified");
13886 if (remote_set == 0)
13888 errmsg ("tunnel remote address not specified");
13891 if (grp_set && mcast_sw_if_index == ~0)
13893 errmsg ("tunnel nonexistent multicast device");
13896 if (ipv4_set && ipv6_set)
13898 errmsg ("both IPv4 and IPv6 addresses specified");
13904 errmsg ("vni not specified");
13908 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
13913 clib_memcpy (&mp->local, &local6, sizeof (local6));
13914 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
13918 clib_memcpy (&mp->local, &local4, sizeof (local4));
13919 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
13922 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13923 mp->encap_vrf_id = ntohl (encap_vrf_id);
13924 mp->decap_vrf_id = ntohl (decap_vrf_id);
13925 mp->protocol = protocol;
13926 mp->vni = ntohl (vni);
13927 mp->is_add = is_add;
13928 mp->is_ipv6 = ipv6_set;
13935 static void vl_api_vxlan_gpe_tunnel_details_t_handler
13936 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13938 vat_main_t *vam = &vat_main;
13939 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
13940 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
13942 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
13943 ntohl (mp->sw_if_index),
13944 format_ip46_address, &local, IP46_TYPE_ANY,
13945 format_ip46_address, &remote, IP46_TYPE_ANY,
13946 ntohl (mp->vni), mp->protocol,
13947 ntohl (mp->mcast_sw_if_index),
13948 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
13952 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
13953 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13955 vat_main_t *vam = &vat_main;
13956 vat_json_node_t *node = NULL;
13957 struct in_addr ip4;
13958 struct in6_addr ip6;
13960 if (VAT_JSON_ARRAY != vam->json_tree.type)
13962 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13963 vat_json_init_array (&vam->json_tree);
13965 node = vat_json_array_add (&vam->json_tree);
13967 vat_json_init_object (node);
13968 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13971 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
13972 vat_json_object_add_ip6 (node, "local", ip6);
13973 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
13974 vat_json_object_add_ip6 (node, "remote", ip6);
13978 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
13979 vat_json_object_add_ip4 (node, "local", ip4);
13980 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
13981 vat_json_object_add_ip4 (node, "remote", ip4);
13983 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13984 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
13985 vat_json_object_add_uint (node, "mcast_sw_if_index",
13986 ntohl (mp->mcast_sw_if_index));
13987 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13988 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
13989 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13993 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
13995 unformat_input_t *i = vam->input;
13996 vl_api_vxlan_gpe_tunnel_dump_t *mp;
13997 vl_api_control_ping_t *mp_ping;
13999 u8 sw_if_index_set = 0;
14002 /* Parse args required to build the message */
14003 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14005 if (unformat (i, "sw_if_index %d", &sw_if_index))
14006 sw_if_index_set = 1;
14011 if (sw_if_index_set == 0)
14016 if (!vam->json_output)
14018 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
14019 "sw_if_index", "local", "remote", "vni",
14020 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
14023 /* Get list of vxlan-tunnel interfaces */
14024 M (VXLAN_GPE_TUNNEL_DUMP, mp);
14026 mp->sw_if_index = htonl (sw_if_index);
14030 /* Use a control ping for synchronization */
14031 MPING (CONTROL_PING, mp_ping);
14038 static void vl_api_l2_fib_table_details_t_handler
14039 (vl_api_l2_fib_table_details_t * mp)
14041 vat_main_t *vam = &vat_main;
14043 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
14045 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
14046 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
14050 static void vl_api_l2_fib_table_details_t_handler_json
14051 (vl_api_l2_fib_table_details_t * mp)
14053 vat_main_t *vam = &vat_main;
14054 vat_json_node_t *node = NULL;
14056 if (VAT_JSON_ARRAY != vam->json_tree.type)
14058 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14059 vat_json_init_array (&vam->json_tree);
14061 node = vat_json_array_add (&vam->json_tree);
14063 vat_json_init_object (node);
14064 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
14065 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
14066 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14067 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
14068 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
14069 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
14073 api_l2_fib_table_dump (vat_main_t * vam)
14075 unformat_input_t *i = vam->input;
14076 vl_api_l2_fib_table_dump_t *mp;
14077 vl_api_control_ping_t *mp_ping;
14082 /* Parse args required to build the message */
14083 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14085 if (unformat (i, "bd_id %d", &bd_id))
14091 if (bd_id_set == 0)
14093 errmsg ("missing bridge domain");
14097 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
14099 /* Get list of l2 fib entries */
14100 M (L2_FIB_TABLE_DUMP, mp);
14102 mp->bd_id = ntohl (bd_id);
14105 /* Use a control ping for synchronization */
14106 MPING (CONTROL_PING, mp_ping);
14115 api_interface_name_renumber (vat_main_t * vam)
14117 unformat_input_t *line_input = vam->input;
14118 vl_api_interface_name_renumber_t *mp;
14119 u32 sw_if_index = ~0;
14120 u32 new_show_dev_instance = ~0;
14123 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14125 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
14128 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14130 else if (unformat (line_input, "new_show_dev_instance %d",
14131 &new_show_dev_instance))
14137 if (sw_if_index == ~0)
14139 errmsg ("missing interface name or sw_if_index");
14143 if (new_show_dev_instance == ~0)
14145 errmsg ("missing new_show_dev_instance");
14149 M (INTERFACE_NAME_RENUMBER, mp);
14151 mp->sw_if_index = ntohl (sw_if_index);
14152 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
14160 api_ip_probe_neighbor (vat_main_t * vam)
14162 unformat_input_t *i = vam->input;
14163 vl_api_ip_probe_neighbor_t *mp;
14164 vl_api_address_t dst_adr = { };
14170 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14172 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14174 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14176 else if (unformat (i, "address %U", unformat_vl_api_address, &dst_adr))
14184 errmsg ("missing interface");
14190 errmsg ("missing addresses");
14194 M (IP_PROBE_NEIGHBOR, mp);
14196 mp->sw_if_index = ntohl (sw_if_index);
14197 clib_memcpy (&mp->dst, &dst_adr, sizeof (dst_adr));
14205 api_ip_scan_neighbor_enable_disable (vat_main_t * vam)
14207 unformat_input_t *i = vam->input;
14208 vl_api_ip_scan_neighbor_enable_disable_t *mp;
14209 u8 mode = IP_SCAN_V46_NEIGHBORS;
14210 u32 interval = 0, time = 0, update = 0, delay = 0, stale = 0;
14213 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14215 if (unformat (i, "ip4"))
14216 mode = IP_SCAN_V4_NEIGHBORS;
14217 else if (unformat (i, "ip6"))
14218 mode = IP_SCAN_V6_NEIGHBORS;
14219 if (unformat (i, "both"))
14220 mode = IP_SCAN_V46_NEIGHBORS;
14221 else if (unformat (i, "disable"))
14222 mode = IP_SCAN_DISABLED;
14223 else if (unformat (i, "interval %d", &interval))
14225 else if (unformat (i, "max-time %d", &time))
14227 else if (unformat (i, "max-update %d", &update))
14229 else if (unformat (i, "delay %d", &delay))
14231 else if (unformat (i, "stale %d", &stale))
14237 if (interval > 255)
14239 errmsg ("interval cannot exceed 255 minutes.");
14244 errmsg ("max-time cannot exceed 255 usec.");
14249 errmsg ("max-update cannot exceed 255.");
14254 errmsg ("delay cannot exceed 255 msec.");
14259 errmsg ("stale cannot exceed 255 minutes.");
14263 M (IP_SCAN_NEIGHBOR_ENABLE_DISABLE, mp);
14265 mp->scan_interval = interval;
14266 mp->max_proc_time = time;
14267 mp->max_update = update;
14268 mp->scan_int_delay = delay;
14269 mp->stale_threshold = stale;
14277 api_want_ip4_arp_events (vat_main_t * vam)
14279 unformat_input_t *line_input = vam->input;
14280 vl_api_want_ip4_arp_events_t *mp;
14281 ip4_address_t address;
14282 int address_set = 0;
14283 u32 enable_disable = 1;
14286 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14288 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
14290 else if (unformat (line_input, "del"))
14291 enable_disable = 0;
14296 if (address_set == 0)
14298 errmsg ("missing addresses");
14302 M (WANT_IP4_ARP_EVENTS, mp);
14303 mp->enable_disable = enable_disable;
14304 mp->pid = htonl (getpid ());
14305 clib_memcpy (mp->ip, &address, sizeof (address));
14313 api_want_ip6_nd_events (vat_main_t * vam)
14315 unformat_input_t *line_input = vam->input;
14316 vl_api_want_ip6_nd_events_t *mp;
14317 vl_api_ip6_address_t address;
14318 int address_set = 0;
14319 u32 enable_disable = 1;
14322 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14325 (line_input, "address %U", unformat_vl_api_ip6_address, &address))
14327 else if (unformat (line_input, "del"))
14328 enable_disable = 0;
14333 if (address_set == 0)
14335 errmsg ("missing addresses");
14339 M (WANT_IP6_ND_EVENTS, mp);
14340 mp->enable_disable = enable_disable;
14341 mp->pid = htonl (getpid ());
14342 clib_memcpy (&mp->ip, &address, sizeof (address));
14350 api_want_l2_macs_events (vat_main_t * vam)
14352 unformat_input_t *line_input = vam->input;
14353 vl_api_want_l2_macs_events_t *mp;
14354 u8 enable_disable = 1;
14355 u32 scan_delay = 0;
14356 u32 max_macs_in_event = 0;
14357 u32 learn_limit = 0;
14360 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14362 if (unformat (line_input, "learn-limit %d", &learn_limit))
14364 else if (unformat (line_input, "scan-delay %d", &scan_delay))
14366 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
14368 else if (unformat (line_input, "disable"))
14369 enable_disable = 0;
14374 M (WANT_L2_MACS_EVENTS, mp);
14375 mp->enable_disable = enable_disable;
14376 mp->pid = htonl (getpid ());
14377 mp->learn_limit = htonl (learn_limit);
14378 mp->scan_delay = (u8) scan_delay;
14379 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
14386 api_input_acl_set_interface (vat_main_t * vam)
14388 unformat_input_t *i = vam->input;
14389 vl_api_input_acl_set_interface_t *mp;
14391 int sw_if_index_set;
14392 u32 ip4_table_index = ~0;
14393 u32 ip6_table_index = ~0;
14394 u32 l2_table_index = ~0;
14398 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14400 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14401 sw_if_index_set = 1;
14402 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14403 sw_if_index_set = 1;
14404 else if (unformat (i, "del"))
14406 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14408 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14410 else if (unformat (i, "l2-table %d", &l2_table_index))
14414 clib_warning ("parse error '%U'", format_unformat_error, i);
14419 if (sw_if_index_set == 0)
14421 errmsg ("missing interface name or sw_if_index");
14425 M (INPUT_ACL_SET_INTERFACE, mp);
14427 mp->sw_if_index = ntohl (sw_if_index);
14428 mp->ip4_table_index = ntohl (ip4_table_index);
14429 mp->ip6_table_index = ntohl (ip6_table_index);
14430 mp->l2_table_index = ntohl (l2_table_index);
14431 mp->is_add = is_add;
14439 api_output_acl_set_interface (vat_main_t * vam)
14441 unformat_input_t *i = vam->input;
14442 vl_api_output_acl_set_interface_t *mp;
14444 int sw_if_index_set;
14445 u32 ip4_table_index = ~0;
14446 u32 ip6_table_index = ~0;
14447 u32 l2_table_index = ~0;
14451 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14453 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14454 sw_if_index_set = 1;
14455 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14456 sw_if_index_set = 1;
14457 else if (unformat (i, "del"))
14459 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14461 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14463 else if (unformat (i, "l2-table %d", &l2_table_index))
14467 clib_warning ("parse error '%U'", format_unformat_error, i);
14472 if (sw_if_index_set == 0)
14474 errmsg ("missing interface name or sw_if_index");
14478 M (OUTPUT_ACL_SET_INTERFACE, mp);
14480 mp->sw_if_index = ntohl (sw_if_index);
14481 mp->ip4_table_index = ntohl (ip4_table_index);
14482 mp->ip6_table_index = ntohl (ip6_table_index);
14483 mp->l2_table_index = ntohl (l2_table_index);
14484 mp->is_add = is_add;
14492 api_ip_address_dump (vat_main_t * vam)
14494 unformat_input_t *i = vam->input;
14495 vl_api_ip_address_dump_t *mp;
14496 vl_api_control_ping_t *mp_ping;
14497 u32 sw_if_index = ~0;
14498 u8 sw_if_index_set = 0;
14503 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14505 if (unformat (i, "sw_if_index %d", &sw_if_index))
14506 sw_if_index_set = 1;
14508 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14509 sw_if_index_set = 1;
14510 else if (unformat (i, "ipv4"))
14512 else if (unformat (i, "ipv6"))
14518 if (ipv4_set && ipv6_set)
14520 errmsg ("ipv4 and ipv6 flags cannot be both set");
14524 if ((!ipv4_set) && (!ipv6_set))
14526 errmsg ("no ipv4 nor ipv6 flag set");
14530 if (sw_if_index_set == 0)
14532 errmsg ("missing interface name or sw_if_index");
14536 vam->current_sw_if_index = sw_if_index;
14537 vam->is_ipv6 = ipv6_set;
14539 M (IP_ADDRESS_DUMP, mp);
14540 mp->sw_if_index = ntohl (sw_if_index);
14541 mp->is_ipv6 = ipv6_set;
14544 /* Use a control ping for synchronization */
14545 MPING (CONTROL_PING, mp_ping);
14553 api_ip_dump (vat_main_t * vam)
14555 vl_api_ip_dump_t *mp;
14556 vl_api_control_ping_t *mp_ping;
14557 unformat_input_t *in = vam->input;
14564 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
14566 if (unformat (in, "ipv4"))
14568 else if (unformat (in, "ipv6"))
14574 if (ipv4_set && ipv6_set)
14576 errmsg ("ipv4 and ipv6 flags cannot be both set");
14580 if ((!ipv4_set) && (!ipv6_set))
14582 errmsg ("no ipv4 nor ipv6 flag set");
14586 is_ipv6 = ipv6_set;
14587 vam->is_ipv6 = is_ipv6;
14589 /* free old data */
14590 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
14592 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
14594 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
14597 mp->is_ipv6 = ipv6_set;
14600 /* Use a control ping for synchronization */
14601 MPING (CONTROL_PING, mp_ping);
14609 api_ipsec_spd_add_del (vat_main_t * vam)
14611 unformat_input_t *i = vam->input;
14612 vl_api_ipsec_spd_add_del_t *mp;
14617 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14619 if (unformat (i, "spd_id %d", &spd_id))
14621 else if (unformat (i, "del"))
14625 clib_warning ("parse error '%U'", format_unformat_error, i);
14631 errmsg ("spd_id must be set");
14635 M (IPSEC_SPD_ADD_DEL, mp);
14637 mp->spd_id = ntohl (spd_id);
14638 mp->is_add = is_add;
14646 api_ipsec_interface_add_del_spd (vat_main_t * vam)
14648 unformat_input_t *i = vam->input;
14649 vl_api_ipsec_interface_add_del_spd_t *mp;
14651 u8 sw_if_index_set = 0;
14652 u32 spd_id = (u32) ~ 0;
14656 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14658 if (unformat (i, "del"))
14660 else if (unformat (i, "spd_id %d", &spd_id))
14663 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14664 sw_if_index_set = 1;
14665 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14666 sw_if_index_set = 1;
14669 clib_warning ("parse error '%U'", format_unformat_error, i);
14675 if (spd_id == (u32) ~ 0)
14677 errmsg ("spd_id must be set");
14681 if (sw_if_index_set == 0)
14683 errmsg ("missing interface name or sw_if_index");
14687 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
14689 mp->spd_id = ntohl (spd_id);
14690 mp->sw_if_index = ntohl (sw_if_index);
14691 mp->is_add = is_add;
14699 api_ipsec_spd_entry_add_del (vat_main_t * vam)
14701 unformat_input_t *i = vam->input;
14702 vl_api_ipsec_spd_entry_add_del_t *mp;
14703 u8 is_add = 1, is_outbound = 0;
14704 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
14706 u32 rport_start = 0, rport_stop = (u32) ~ 0;
14707 u32 lport_start = 0, lport_stop = (u32) ~ 0;
14708 vl_api_address_t laddr_start = { }, laddr_stop =
14717 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14719 if (unformat (i, "del"))
14721 if (unformat (i, "outbound"))
14723 if (unformat (i, "inbound"))
14725 else if (unformat (i, "spd_id %d", &spd_id))
14727 else if (unformat (i, "sa_id %d", &sa_id))
14729 else if (unformat (i, "priority %d", &priority))
14731 else if (unformat (i, "protocol %d", &protocol))
14733 else if (unformat (i, "lport_start %d", &lport_start))
14735 else if (unformat (i, "lport_stop %d", &lport_stop))
14737 else if (unformat (i, "rport_start %d", &rport_start))
14739 else if (unformat (i, "rport_stop %d", &rport_stop))
14741 else if (unformat (i, "laddr_start %U",
14742 unformat_vl_api_address, &laddr_start))
14744 else if (unformat (i, "laddr_stop %U", unformat_vl_api_address,
14747 else if (unformat (i, "raddr_start %U", unformat_vl_api_address,
14750 else if (unformat (i, "raddr_stop %U", unformat_vl_api_address,
14754 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
14756 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
14758 clib_warning ("unsupported action: 'resolve'");
14764 clib_warning ("parse error '%U'", format_unformat_error, i);
14770 M (IPSEC_SPD_ENTRY_ADD_DEL, mp);
14772 mp->is_add = is_add;
14774 mp->entry.spd_id = ntohl (spd_id);
14775 mp->entry.priority = ntohl (priority);
14776 mp->entry.is_outbound = is_outbound;
14778 clib_memcpy (&mp->entry.remote_address_start, &raddr_start,
14779 sizeof (vl_api_address_t));
14780 clib_memcpy (&mp->entry.remote_address_stop, &raddr_stop,
14781 sizeof (vl_api_address_t));
14782 clib_memcpy (&mp->entry.local_address_start, &laddr_start,
14783 sizeof (vl_api_address_t));
14784 clib_memcpy (&mp->entry.local_address_stop, &laddr_stop,
14785 sizeof (vl_api_address_t));
14787 mp->entry.protocol = (u8) protocol;
14788 mp->entry.local_port_start = ntohs ((u16) lport_start);
14789 mp->entry.local_port_stop = ntohs ((u16) lport_stop);
14790 mp->entry.remote_port_start = ntohs ((u16) rport_start);
14791 mp->entry.remote_port_stop = ntohs ((u16) rport_stop);
14792 mp->entry.policy = (u8) policy;
14793 mp->entry.sa_id = ntohl (sa_id);
14801 api_ipsec_sad_entry_add_del (vat_main_t * vam)
14803 unformat_input_t *i = vam->input;
14804 vl_api_ipsec_sad_entry_add_del_t *mp;
14805 u32 sad_id = 0, spi = 0;
14806 u8 *ck = 0, *ik = 0;
14809 vl_api_ipsec_crypto_alg_t crypto_alg = IPSEC_API_CRYPTO_ALG_NONE;
14810 vl_api_ipsec_integ_alg_t integ_alg = IPSEC_API_INTEG_ALG_NONE;
14811 vl_api_ipsec_sad_flags_t flags = IPSEC_API_SAD_FLAG_NONE;
14812 vl_api_ipsec_proto_t protocol = IPSEC_API_PROTO_AH;
14813 vl_api_address_t tun_src, tun_dst;
14816 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14818 if (unformat (i, "del"))
14820 else if (unformat (i, "sad_id %d", &sad_id))
14822 else if (unformat (i, "spi %d", &spi))
14824 else if (unformat (i, "esp"))
14825 protocol = IPSEC_API_PROTO_ESP;
14827 if (unformat (i, "tunnel_src %U", unformat_vl_api_address, &tun_src))
14829 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
14830 if (ADDRESS_IP6 == tun_src.af)
14831 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
14834 if (unformat (i, "tunnel_dst %U", unformat_vl_api_address, &tun_dst))
14836 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
14837 if (ADDRESS_IP6 == tun_src.af)
14838 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
14841 if (unformat (i, "crypto_alg %U",
14842 unformat_ipsec_api_crypto_alg, &crypto_alg))
14844 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14846 else if (unformat (i, "integ_alg %U",
14847 unformat_ipsec_api_integ_alg, &integ_alg))
14849 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14853 clib_warning ("parse error '%U'", format_unformat_error, i);
14859 M (IPSEC_SAD_ENTRY_ADD_DEL, mp);
14861 mp->is_add = is_add;
14862 mp->entry.sad_id = ntohl (sad_id);
14863 mp->entry.protocol = protocol;
14864 mp->entry.spi = ntohl (spi);
14865 mp->entry.flags = flags;
14867 mp->entry.crypto_algorithm = crypto_alg;
14868 mp->entry.integrity_algorithm = integ_alg;
14869 mp->entry.crypto_key.length = vec_len (ck);
14870 mp->entry.integrity_key.length = vec_len (ik);
14872 if (mp->entry.crypto_key.length > sizeof (mp->entry.crypto_key.data))
14873 mp->entry.crypto_key.length = sizeof (mp->entry.crypto_key.data);
14875 if (mp->entry.integrity_key.length > sizeof (mp->entry.integrity_key.data))
14876 mp->entry.integrity_key.length = sizeof (mp->entry.integrity_key.data);
14879 clib_memcpy (mp->entry.crypto_key.data, ck, mp->entry.crypto_key.length);
14881 clib_memcpy (mp->entry.integrity_key.data, ik,
14882 mp->entry.integrity_key.length);
14884 if (flags & IPSEC_API_SAD_FLAG_IS_TUNNEL)
14886 clib_memcpy (&mp->entry.tunnel_src, &tun_src,
14887 sizeof (mp->entry.tunnel_src));
14888 clib_memcpy (&mp->entry.tunnel_dst, &tun_dst,
14889 sizeof (mp->entry.tunnel_dst));
14898 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
14900 unformat_input_t *i = vam->input;
14901 vl_api_ipsec_tunnel_if_add_del_t *mp;
14902 u32 local_spi = 0, remote_spi = 0;
14903 u32 crypto_alg = 0, integ_alg = 0;
14904 u8 *lck = NULL, *rck = NULL;
14905 u8 *lik = NULL, *rik = NULL;
14906 vl_api_address_t local_ip = { 0 };
14907 vl_api_address_t remote_ip = { 0 };
14911 u8 anti_replay = 0;
14917 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14919 if (unformat (i, "del"))
14921 else if (unformat (i, "esn"))
14923 else if (unformat (i, "anti-replay"))
14925 else if (unformat (i, "count %d", &count))
14927 else if (unformat (i, "local_spi %d", &local_spi))
14929 else if (unformat (i, "remote_spi %d", &remote_spi))
14932 if (unformat (i, "local_ip %U", unformat_vl_api_address, &local_ip))
14935 if (unformat (i, "remote_ip %U", unformat_vl_api_address, &remote_ip))
14937 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
14940 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
14942 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
14944 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
14948 (i, "crypto_alg %U", unformat_ipsec_api_crypto_alg, &crypto_alg))
14950 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
14952 errmsg ("unsupported crypto-alg: '%U'\n",
14953 format_ipsec_crypto_alg, crypto_alg);
14959 (i, "integ_alg %U", unformat_ipsec_api_integ_alg, &integ_alg))
14961 if (integ_alg >= IPSEC_INTEG_N_ALG)
14963 errmsg ("unsupported integ-alg: '%U'\n",
14964 format_ipsec_integ_alg, integ_alg);
14968 else if (unformat (i, "instance %u", &instance))
14972 errmsg ("parse error '%U'\n", format_unformat_error, i);
14979 /* Turn on async mode */
14980 vam->async_mode = 1;
14981 vam->async_errors = 0;
14982 before = vat_time_now (vam);
14985 for (jj = 0; jj < count; jj++)
14987 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
14989 mp->is_add = is_add;
14991 mp->anti_replay = anti_replay;
14994 increment_vl_address (&remote_ip);
14996 clib_memcpy (&mp->local_ip, &local_ip, sizeof (local_ip));
14997 clib_memcpy (&mp->remote_ip, &remote_ip, sizeof (remote_ip));
14999 mp->local_spi = htonl (local_spi + jj);
15000 mp->remote_spi = htonl (remote_spi + jj);
15001 mp->crypto_alg = (u8) crypto_alg;
15003 mp->local_crypto_key_len = 0;
15006 mp->local_crypto_key_len = vec_len (lck);
15007 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
15008 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
15009 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
15012 mp->remote_crypto_key_len = 0;
15015 mp->remote_crypto_key_len = vec_len (rck);
15016 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
15017 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
15018 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
15021 mp->integ_alg = (u8) integ_alg;
15023 mp->local_integ_key_len = 0;
15026 mp->local_integ_key_len = vec_len (lik);
15027 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
15028 mp->local_integ_key_len = sizeof (mp->local_integ_key);
15029 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
15032 mp->remote_integ_key_len = 0;
15035 mp->remote_integ_key_len = vec_len (rik);
15036 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
15037 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
15038 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
15043 mp->renumber = renumber;
15044 mp->show_instance = ntohl (instance);
15049 /* When testing multiple add/del ops, use a control-ping to sync */
15052 vl_api_control_ping_t *mp_ping;
15056 /* Shut off async mode */
15057 vam->async_mode = 0;
15059 MPING (CONTROL_PING, mp_ping);
15062 timeout = vat_time_now (vam) + 1.0;
15063 while (vat_time_now (vam) < timeout)
15064 if (vam->result_ready == 1)
15069 if (vam->retval == -99)
15070 errmsg ("timeout");
15072 if (vam->async_errors > 0)
15074 errmsg ("%d asynchronous errors", vam->async_errors);
15077 vam->async_errors = 0;
15078 after = vat_time_now (vam);
15080 /* slim chance, but we might have eaten SIGTERM on the first iteration */
15084 print (vam->ofp, "%d tunnels in %.6f secs, %.2f tunnels/sec",
15085 count, after - before, count / (after - before));
15089 /* Wait for a reply... */
15098 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
15100 vat_main_t *vam = &vat_main;
15102 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
15103 "crypto_key %U integ_alg %u integ_key %U flags %x "
15104 "tunnel_src_addr %U tunnel_dst_addr %U "
15105 "salt %u seq_outbound %lu last_seq_inbound %lu "
15106 "replay_window %lu\n",
15107 ntohl (mp->entry.sad_id),
15108 ntohl (mp->sw_if_index),
15109 ntohl (mp->entry.spi),
15110 ntohl (mp->entry.protocol),
15111 ntohl (mp->entry.crypto_algorithm),
15112 format_hex_bytes, mp->entry.crypto_key.data,
15113 mp->entry.crypto_key.length, ntohl (mp->entry.integrity_algorithm),
15114 format_hex_bytes, mp->entry.integrity_key.data,
15115 mp->entry.integrity_key.length, ntohl (mp->entry.flags),
15116 format_vl_api_address, &mp->entry.tunnel_src, format_vl_api_address,
15117 &mp->entry.tunnel_dst, ntohl (mp->salt),
15118 clib_net_to_host_u64 (mp->seq_outbound),
15119 clib_net_to_host_u64 (mp->last_seq_inbound),
15120 clib_net_to_host_u64 (mp->replay_window));
15123 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
15124 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
15126 static void vl_api_ipsec_sa_details_t_handler_json
15127 (vl_api_ipsec_sa_details_t * mp)
15129 vat_main_t *vam = &vat_main;
15130 vat_json_node_t *node = NULL;
15131 vl_api_ipsec_sad_flags_t flags;
15133 if (VAT_JSON_ARRAY != vam->json_tree.type)
15135 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15136 vat_json_init_array (&vam->json_tree);
15138 node = vat_json_array_add (&vam->json_tree);
15140 vat_json_init_object (node);
15141 vat_json_object_add_uint (node, "sa_id", ntohl (mp->entry.sad_id));
15142 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
15143 vat_json_object_add_uint (node, "spi", ntohl (mp->entry.spi));
15144 vat_json_object_add_uint (node, "proto", ntohl (mp->entry.protocol));
15145 vat_json_object_add_uint (node, "crypto_alg",
15146 ntohl (mp->entry.crypto_algorithm));
15147 vat_json_object_add_uint (node, "integ_alg",
15148 ntohl (mp->entry.integrity_algorithm));
15149 flags = ntohl (mp->entry.flags);
15150 vat_json_object_add_uint (node, "use_esn",
15151 ! !(flags & IPSEC_API_SAD_FLAG_USE_ESN));
15152 vat_json_object_add_uint (node, "use_anti_replay",
15153 ! !(flags & IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY));
15154 vat_json_object_add_uint (node, "is_tunnel",
15155 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL));
15156 vat_json_object_add_uint (node, "is_tunnel_ip6",
15157 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL_V6));
15158 vat_json_object_add_uint (node, "udp_encap",
15159 ! !(flags & IPSEC_API_SAD_FLAG_UDP_ENCAP));
15160 vat_json_object_add_bytes (node, "crypto_key", mp->entry.crypto_key.data,
15161 mp->entry.crypto_key.length);
15162 vat_json_object_add_bytes (node, "integ_key", mp->entry.integrity_key.data,
15163 mp->entry.integrity_key.length);
15164 vat_json_object_add_address (node, "src", &mp->entry.tunnel_src);
15165 vat_json_object_add_address (node, "dst", &mp->entry.tunnel_dst);
15166 vat_json_object_add_uint (node, "replay_window",
15167 clib_net_to_host_u64 (mp->replay_window));
15171 api_ipsec_sa_dump (vat_main_t * vam)
15173 unformat_input_t *i = vam->input;
15174 vl_api_ipsec_sa_dump_t *mp;
15175 vl_api_control_ping_t *mp_ping;
15179 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15181 if (unformat (i, "sa_id %d", &sa_id))
15185 clib_warning ("parse error '%U'", format_unformat_error, i);
15190 M (IPSEC_SA_DUMP, mp);
15192 mp->sa_id = ntohl (sa_id);
15196 /* Use a control ping for synchronization */
15197 M (CONTROL_PING, mp_ping);
15205 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
15207 unformat_input_t *i = vam->input;
15208 vl_api_ipsec_tunnel_if_set_sa_t *mp;
15209 u32 sw_if_index = ~0;
15211 u8 is_outbound = (u8) ~ 0;
15214 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15216 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15218 else if (unformat (i, "sa_id %d", &sa_id))
15220 else if (unformat (i, "outbound"))
15222 else if (unformat (i, "inbound"))
15226 clib_warning ("parse error '%U'", format_unformat_error, i);
15231 if (sw_if_index == ~0)
15233 errmsg ("interface must be specified");
15239 errmsg ("SA ID must be specified");
15243 M (IPSEC_TUNNEL_IF_SET_SA, mp);
15245 mp->sw_if_index = htonl (sw_if_index);
15246 mp->sa_id = htonl (sa_id);
15247 mp->is_outbound = is_outbound;
15256 api_get_first_msg_id (vat_main_t * vam)
15258 vl_api_get_first_msg_id_t *mp;
15259 unformat_input_t *i = vam->input;
15264 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15266 if (unformat (i, "client %s", &name))
15274 errmsg ("missing client name");
15277 vec_add1 (name, 0);
15279 if (vec_len (name) > 63)
15281 errmsg ("client name too long");
15285 M (GET_FIRST_MSG_ID, mp);
15286 clib_memcpy (mp->name, name, vec_len (name));
15293 api_cop_interface_enable_disable (vat_main_t * vam)
15295 unformat_input_t *line_input = vam->input;
15296 vl_api_cop_interface_enable_disable_t *mp;
15297 u32 sw_if_index = ~0;
15298 u8 enable_disable = 1;
15301 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15303 if (unformat (line_input, "disable"))
15304 enable_disable = 0;
15305 if (unformat (line_input, "enable"))
15306 enable_disable = 1;
15307 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15308 vam, &sw_if_index))
15310 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15316 if (sw_if_index == ~0)
15318 errmsg ("missing interface name or sw_if_index");
15322 /* Construct the API message */
15323 M (COP_INTERFACE_ENABLE_DISABLE, mp);
15324 mp->sw_if_index = ntohl (sw_if_index);
15325 mp->enable_disable = enable_disable;
15329 /* Wait for the reply */
15335 api_cop_whitelist_enable_disable (vat_main_t * vam)
15337 unformat_input_t *line_input = vam->input;
15338 vl_api_cop_whitelist_enable_disable_t *mp;
15339 u32 sw_if_index = ~0;
15340 u8 ip4 = 0, ip6 = 0, default_cop = 0;
15344 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15346 if (unformat (line_input, "ip4"))
15348 else if (unformat (line_input, "ip6"))
15350 else if (unformat (line_input, "default"))
15352 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15353 vam, &sw_if_index))
15355 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15357 else if (unformat (line_input, "fib-id %d", &fib_id))
15363 if (sw_if_index == ~0)
15365 errmsg ("missing interface name or sw_if_index");
15369 /* Construct the API message */
15370 M (COP_WHITELIST_ENABLE_DISABLE, mp);
15371 mp->sw_if_index = ntohl (sw_if_index);
15372 mp->fib_id = ntohl (fib_id);
15375 mp->default_cop = default_cop;
15379 /* Wait for the reply */
15385 api_get_node_graph (vat_main_t * vam)
15387 vl_api_get_node_graph_t *mp;
15390 M (GET_NODE_GRAPH, mp);
15394 /* Wait for the reply */
15400 /** Used for parsing LISP eids */
15401 typedef CLIB_PACKED(struct{
15402 u8 addr[16]; /**< eid address */
15403 u32 len; /**< prefix length if IP */
15404 u8 type; /**< type of eid */
15409 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
15411 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
15413 clib_memset (a, 0, sizeof (a[0]));
15415 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
15417 a->type = 0; /* ipv4 type */
15419 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
15421 a->type = 1; /* ipv6 type */
15423 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
15425 a->type = 2; /* mac type */
15427 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
15429 a->type = 3; /* NSH type */
15430 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
15431 nsh->spi = clib_host_to_net_u32 (nsh->spi);
15438 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
15447 lisp_eid_size_vat (u8 type)
15464 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
15466 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
15470 api_one_add_del_locator_set (vat_main_t * vam)
15472 unformat_input_t *input = vam->input;
15473 vl_api_one_add_del_locator_set_t *mp;
15475 u8 *locator_set_name = NULL;
15476 u8 locator_set_name_set = 0;
15477 vl_api_local_locator_t locator, *locators = 0;
15478 u32 sw_if_index, priority, weight;
15482 /* Parse args required to build the message */
15483 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15485 if (unformat (input, "del"))
15489 else if (unformat (input, "locator-set %s", &locator_set_name))
15491 locator_set_name_set = 1;
15493 else if (unformat (input, "sw_if_index %u p %u w %u",
15494 &sw_if_index, &priority, &weight))
15496 locator.sw_if_index = htonl (sw_if_index);
15497 locator.priority = priority;
15498 locator.weight = weight;
15499 vec_add1 (locators, locator);
15503 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
15504 &sw_if_index, &priority, &weight))
15506 locator.sw_if_index = htonl (sw_if_index);
15507 locator.priority = priority;
15508 locator.weight = weight;
15509 vec_add1 (locators, locator);
15515 if (locator_set_name_set == 0)
15517 errmsg ("missing locator-set name");
15518 vec_free (locators);
15522 if (vec_len (locator_set_name) > 64)
15524 errmsg ("locator-set name too long");
15525 vec_free (locator_set_name);
15526 vec_free (locators);
15529 vec_add1 (locator_set_name, 0);
15531 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
15533 /* Construct the API message */
15534 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
15536 mp->is_add = is_add;
15537 clib_memcpy (mp->locator_set_name, locator_set_name,
15538 vec_len (locator_set_name));
15539 vec_free (locator_set_name);
15541 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
15543 clib_memcpy (mp->locators, locators, data_len);
15544 vec_free (locators);
15549 /* Wait for a reply... */
15554 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
15557 api_one_add_del_locator (vat_main_t * vam)
15559 unformat_input_t *input = vam->input;
15560 vl_api_one_add_del_locator_t *mp;
15561 u32 tmp_if_index = ~0;
15562 u32 sw_if_index = ~0;
15563 u8 sw_if_index_set = 0;
15564 u8 sw_if_index_if_name_set = 0;
15566 u8 priority_set = 0;
15570 u8 *locator_set_name = NULL;
15571 u8 locator_set_name_set = 0;
15574 /* Parse args required to build the message */
15575 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15577 if (unformat (input, "del"))
15581 else if (unformat (input, "locator-set %s", &locator_set_name))
15583 locator_set_name_set = 1;
15585 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
15588 sw_if_index_if_name_set = 1;
15589 sw_if_index = tmp_if_index;
15591 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
15593 sw_if_index_set = 1;
15594 sw_if_index = tmp_if_index;
15596 else if (unformat (input, "p %d", &priority))
15600 else if (unformat (input, "w %d", &weight))
15608 if (locator_set_name_set == 0)
15610 errmsg ("missing locator-set name");
15614 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
15616 errmsg ("missing sw_if_index");
15617 vec_free (locator_set_name);
15621 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
15623 errmsg ("cannot use both params interface name and sw_if_index");
15624 vec_free (locator_set_name);
15628 if (priority_set == 0)
15630 errmsg ("missing locator-set priority");
15631 vec_free (locator_set_name);
15635 if (weight_set == 0)
15637 errmsg ("missing locator-set weight");
15638 vec_free (locator_set_name);
15642 if (vec_len (locator_set_name) > 64)
15644 errmsg ("locator-set name too long");
15645 vec_free (locator_set_name);
15648 vec_add1 (locator_set_name, 0);
15650 /* Construct the API message */
15651 M (ONE_ADD_DEL_LOCATOR, mp);
15653 mp->is_add = is_add;
15654 mp->sw_if_index = ntohl (sw_if_index);
15655 mp->priority = priority;
15656 mp->weight = weight;
15657 clib_memcpy (mp->locator_set_name, locator_set_name,
15658 vec_len (locator_set_name));
15659 vec_free (locator_set_name);
15664 /* Wait for a reply... */
15669 #define api_lisp_add_del_locator api_one_add_del_locator
15672 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
15674 u32 *key_id = va_arg (*args, u32 *);
15677 if (unformat (input, "%s", &s))
15679 if (!strcmp ((char *) s, "sha1"))
15680 key_id[0] = HMAC_SHA_1_96;
15681 else if (!strcmp ((char *) s, "sha256"))
15682 key_id[0] = HMAC_SHA_256_128;
15685 clib_warning ("invalid key_id: '%s'", s);
15686 key_id[0] = HMAC_NO_KEY;
15697 api_one_add_del_local_eid (vat_main_t * vam)
15699 unformat_input_t *input = vam->input;
15700 vl_api_one_add_del_local_eid_t *mp;
15703 lisp_eid_vat_t _eid, *eid = &_eid;
15704 u8 *locator_set_name = 0;
15705 u8 locator_set_name_set = 0;
15711 /* Parse args required to build the message */
15712 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15714 if (unformat (input, "del"))
15718 else if (unformat (input, "vni %d", &vni))
15722 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15726 else if (unformat (input, "locator-set %s", &locator_set_name))
15728 locator_set_name_set = 1;
15730 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
15732 else if (unformat (input, "secret-key %_%v%_", &key))
15738 if (locator_set_name_set == 0)
15740 errmsg ("missing locator-set name");
15746 errmsg ("EID address not set!");
15747 vec_free (locator_set_name);
15751 if (key && (0 == key_id))
15753 errmsg ("invalid key_id!");
15757 if (vec_len (key) > 64)
15759 errmsg ("key too long");
15764 if (vec_len (locator_set_name) > 64)
15766 errmsg ("locator-set name too long");
15767 vec_free (locator_set_name);
15770 vec_add1 (locator_set_name, 0);
15772 /* Construct the API message */
15773 M (ONE_ADD_DEL_LOCAL_EID, mp);
15775 mp->is_add = is_add;
15776 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15777 mp->eid_type = eid->type;
15778 mp->prefix_len = eid->len;
15779 mp->vni = clib_host_to_net_u32 (vni);
15780 mp->key_id = clib_host_to_net_u16 (key_id);
15781 clib_memcpy (mp->locator_set_name, locator_set_name,
15782 vec_len (locator_set_name));
15783 clib_memcpy (mp->key, key, vec_len (key));
15785 vec_free (locator_set_name);
15791 /* Wait for a reply... */
15796 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
15799 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
15801 u32 dp_table = 0, vni = 0;;
15802 unformat_input_t *input = vam->input;
15803 vl_api_gpe_add_del_fwd_entry_t *mp;
15805 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
15806 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
15807 u8 rmt_eid_set = 0, lcl_eid_set = 0;
15808 u32 action = ~0, w;
15809 ip4_address_t rmt_rloc4, lcl_rloc4;
15810 ip6_address_t rmt_rloc6, lcl_rloc6;
15811 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
15814 clib_memset (&rloc, 0, sizeof (rloc));
15816 /* Parse args required to build the message */
15817 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15819 if (unformat (input, "del"))
15821 else if (unformat (input, "add"))
15823 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
15827 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
15831 else if (unformat (input, "vrf %d", &dp_table))
15833 else if (unformat (input, "bd %d", &dp_table))
15835 else if (unformat (input, "vni %d", &vni))
15837 else if (unformat (input, "w %d", &w))
15841 errmsg ("No RLOC configured for setting priority/weight!");
15844 curr_rloc->weight = w;
15846 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
15847 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
15851 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
15853 vec_add1 (lcl_locs, rloc);
15855 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
15856 vec_add1 (rmt_locs, rloc);
15857 /* weight saved in rmt loc */
15858 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15860 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
15861 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
15864 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
15866 vec_add1 (lcl_locs, rloc);
15868 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
15869 vec_add1 (rmt_locs, rloc);
15870 /* weight saved in rmt loc */
15871 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15873 else if (unformat (input, "action %d", &action))
15879 clib_warning ("parse error '%U'", format_unformat_error, input);
15886 errmsg ("remote eid addresses not set");
15890 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
15892 errmsg ("eid types don't match");
15896 if (0 == rmt_locs && (u32) ~ 0 == action)
15898 errmsg ("action not set for negative mapping");
15902 /* Construct the API message */
15903 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
15904 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
15906 mp->is_add = is_add;
15907 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
15908 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
15909 mp->eid_type = rmt_eid->type;
15910 mp->dp_table = clib_host_to_net_u32 (dp_table);
15911 mp->vni = clib_host_to_net_u32 (vni);
15912 mp->rmt_len = rmt_eid->len;
15913 mp->lcl_len = lcl_eid->len;
15914 mp->action = action;
15916 if (0 != rmt_locs && 0 != lcl_locs)
15918 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
15919 clib_memcpy (mp->locs, lcl_locs,
15920 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
15922 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
15923 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
15924 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
15926 vec_free (lcl_locs);
15927 vec_free (rmt_locs);
15932 /* Wait for a reply... */
15938 api_one_add_del_map_server (vat_main_t * vam)
15940 unformat_input_t *input = vam->input;
15941 vl_api_one_add_del_map_server_t *mp;
15945 ip4_address_t ipv4;
15946 ip6_address_t ipv6;
15949 /* Parse args required to build the message */
15950 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15952 if (unformat (input, "del"))
15956 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15960 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15968 if (ipv4_set && ipv6_set)
15970 errmsg ("both eid v4 and v6 addresses set");
15974 if (!ipv4_set && !ipv6_set)
15976 errmsg ("eid addresses not set");
15980 /* Construct the API message */
15981 M (ONE_ADD_DEL_MAP_SERVER, mp);
15983 mp->is_add = is_add;
15987 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
15992 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
15998 /* Wait for a reply... */
16003 #define api_lisp_add_del_map_server api_one_add_del_map_server
16006 api_one_add_del_map_resolver (vat_main_t * vam)
16008 unformat_input_t *input = vam->input;
16009 vl_api_one_add_del_map_resolver_t *mp;
16013 ip4_address_t ipv4;
16014 ip6_address_t ipv6;
16017 /* Parse args required to build the message */
16018 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16020 if (unformat (input, "del"))
16024 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
16028 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
16036 if (ipv4_set && ipv6_set)
16038 errmsg ("both eid v4 and v6 addresses set");
16042 if (!ipv4_set && !ipv6_set)
16044 errmsg ("eid addresses not set");
16048 /* Construct the API message */
16049 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
16051 mp->is_add = is_add;
16055 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
16060 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
16066 /* Wait for a reply... */
16071 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
16074 api_lisp_gpe_enable_disable (vat_main_t * vam)
16076 unformat_input_t *input = vam->input;
16077 vl_api_gpe_enable_disable_t *mp;
16082 /* Parse args required to build the message */
16083 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16085 if (unformat (input, "enable"))
16090 else if (unformat (input, "disable"))
16101 errmsg ("Value not set");
16105 /* Construct the API message */
16106 M (GPE_ENABLE_DISABLE, mp);
16113 /* Wait for a reply... */
16119 api_one_rloc_probe_enable_disable (vat_main_t * vam)
16121 unformat_input_t *input = vam->input;
16122 vl_api_one_rloc_probe_enable_disable_t *mp;
16127 /* Parse args required to build the message */
16128 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16130 if (unformat (input, "enable"))
16135 else if (unformat (input, "disable"))
16143 errmsg ("Value not set");
16147 /* Construct the API message */
16148 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
16150 mp->is_enabled = is_en;
16155 /* Wait for a reply... */
16160 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
16163 api_one_map_register_enable_disable (vat_main_t * vam)
16165 unformat_input_t *input = vam->input;
16166 vl_api_one_map_register_enable_disable_t *mp;
16171 /* Parse args required to build the message */
16172 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16174 if (unformat (input, "enable"))
16179 else if (unformat (input, "disable"))
16187 errmsg ("Value not set");
16191 /* Construct the API message */
16192 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
16194 mp->is_enabled = is_en;
16199 /* Wait for a reply... */
16204 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
16207 api_one_enable_disable (vat_main_t * vam)
16209 unformat_input_t *input = vam->input;
16210 vl_api_one_enable_disable_t *mp;
16215 /* Parse args required to build the message */
16216 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16218 if (unformat (input, "enable"))
16223 else if (unformat (input, "disable"))
16233 errmsg ("Value not set");
16237 /* Construct the API message */
16238 M (ONE_ENABLE_DISABLE, mp);
16245 /* Wait for a reply... */
16250 #define api_lisp_enable_disable api_one_enable_disable
16253 api_one_enable_disable_xtr_mode (vat_main_t * vam)
16255 unformat_input_t *input = vam->input;
16256 vl_api_one_enable_disable_xtr_mode_t *mp;
16261 /* Parse args required to build the message */
16262 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16264 if (unformat (input, "enable"))
16269 else if (unformat (input, "disable"))
16279 errmsg ("Value not set");
16283 /* Construct the API message */
16284 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
16291 /* Wait for a reply... */
16297 api_one_show_xtr_mode (vat_main_t * vam)
16299 vl_api_one_show_xtr_mode_t *mp;
16302 /* Construct the API message */
16303 M (ONE_SHOW_XTR_MODE, mp);
16308 /* Wait for a reply... */
16314 api_one_enable_disable_pitr_mode (vat_main_t * vam)
16316 unformat_input_t *input = vam->input;
16317 vl_api_one_enable_disable_pitr_mode_t *mp;
16322 /* Parse args required to build the message */
16323 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16325 if (unformat (input, "enable"))
16330 else if (unformat (input, "disable"))
16340 errmsg ("Value not set");
16344 /* Construct the API message */
16345 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
16352 /* Wait for a reply... */
16358 api_one_show_pitr_mode (vat_main_t * vam)
16360 vl_api_one_show_pitr_mode_t *mp;
16363 /* Construct the API message */
16364 M (ONE_SHOW_PITR_MODE, mp);
16369 /* Wait for a reply... */
16375 api_one_enable_disable_petr_mode (vat_main_t * vam)
16377 unformat_input_t *input = vam->input;
16378 vl_api_one_enable_disable_petr_mode_t *mp;
16383 /* Parse args required to build the message */
16384 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16386 if (unformat (input, "enable"))
16391 else if (unformat (input, "disable"))
16401 errmsg ("Value not set");
16405 /* Construct the API message */
16406 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
16413 /* Wait for a reply... */
16419 api_one_show_petr_mode (vat_main_t * vam)
16421 vl_api_one_show_petr_mode_t *mp;
16424 /* Construct the API message */
16425 M (ONE_SHOW_PETR_MODE, mp);
16430 /* Wait for a reply... */
16436 api_show_one_map_register_state (vat_main_t * vam)
16438 vl_api_show_one_map_register_state_t *mp;
16441 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
16446 /* wait for reply */
16451 #define api_show_lisp_map_register_state api_show_one_map_register_state
16454 api_show_one_rloc_probe_state (vat_main_t * vam)
16456 vl_api_show_one_rloc_probe_state_t *mp;
16459 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
16464 /* wait for reply */
16469 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
16472 api_one_add_del_ndp_entry (vat_main_t * vam)
16474 vl_api_one_add_del_ndp_entry_t *mp;
16475 unformat_input_t *input = vam->input;
16480 u8 mac[6] = { 0, };
16481 u8 ip6[16] = { 0, };
16485 /* Parse args required to build the message */
16486 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16488 if (unformat (input, "del"))
16490 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16492 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
16494 else if (unformat (input, "bd %d", &bd))
16498 errmsg ("parse error '%U'", format_unformat_error, input);
16503 if (!bd_set || !ip_set || (!mac_set && is_add))
16505 errmsg ("Missing BD, IP or MAC!");
16509 M (ONE_ADD_DEL_NDP_ENTRY, mp);
16510 mp->is_add = is_add;
16511 clib_memcpy (mp->mac, mac, 6);
16512 mp->bd = clib_host_to_net_u32 (bd);
16513 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
16518 /* wait for reply */
16524 api_one_add_del_l2_arp_entry (vat_main_t * vam)
16526 vl_api_one_add_del_l2_arp_entry_t *mp;
16527 unformat_input_t *input = vam->input;
16532 u8 mac[6] = { 0, };
16533 u32 ip4 = 0, bd = ~0;
16536 /* Parse args required to build the message */
16537 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16539 if (unformat (input, "del"))
16541 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16543 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
16545 else if (unformat (input, "bd %d", &bd))
16549 errmsg ("parse error '%U'", format_unformat_error, input);
16554 if (!bd_set || !ip_set || (!mac_set && is_add))
16556 errmsg ("Missing BD, IP or MAC!");
16560 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
16561 mp->is_add = is_add;
16562 clib_memcpy (mp->mac, mac, 6);
16563 mp->bd = clib_host_to_net_u32 (bd);
16569 /* wait for reply */
16575 api_one_ndp_bd_get (vat_main_t * vam)
16577 vl_api_one_ndp_bd_get_t *mp;
16580 M (ONE_NDP_BD_GET, mp);
16585 /* wait for reply */
16591 api_one_ndp_entries_get (vat_main_t * vam)
16593 vl_api_one_ndp_entries_get_t *mp;
16594 unformat_input_t *input = vam->input;
16599 /* Parse args required to build the message */
16600 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16602 if (unformat (input, "bd %d", &bd))
16606 errmsg ("parse error '%U'", format_unformat_error, input);
16613 errmsg ("Expected bridge domain!");
16617 M (ONE_NDP_ENTRIES_GET, mp);
16618 mp->bd = clib_host_to_net_u32 (bd);
16623 /* wait for reply */
16629 api_one_l2_arp_bd_get (vat_main_t * vam)
16631 vl_api_one_l2_arp_bd_get_t *mp;
16634 M (ONE_L2_ARP_BD_GET, mp);
16639 /* wait for reply */
16645 api_one_l2_arp_entries_get (vat_main_t * vam)
16647 vl_api_one_l2_arp_entries_get_t *mp;
16648 unformat_input_t *input = vam->input;
16653 /* Parse args required to build the message */
16654 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16656 if (unformat (input, "bd %d", &bd))
16660 errmsg ("parse error '%U'", format_unformat_error, input);
16667 errmsg ("Expected bridge domain!");
16671 M (ONE_L2_ARP_ENTRIES_GET, mp);
16672 mp->bd = clib_host_to_net_u32 (bd);
16677 /* wait for reply */
16683 api_one_stats_enable_disable (vat_main_t * vam)
16685 vl_api_one_stats_enable_disable_t *mp;
16686 unformat_input_t *input = vam->input;
16691 /* Parse args required to build the message */
16692 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16694 if (unformat (input, "enable"))
16699 else if (unformat (input, "disable"))
16709 errmsg ("Value not set");
16713 M (ONE_STATS_ENABLE_DISABLE, mp);
16719 /* wait for reply */
16725 api_show_one_stats_enable_disable (vat_main_t * vam)
16727 vl_api_show_one_stats_enable_disable_t *mp;
16730 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
16735 /* wait for reply */
16741 api_show_one_map_request_mode (vat_main_t * vam)
16743 vl_api_show_one_map_request_mode_t *mp;
16746 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
16751 /* wait for reply */
16756 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
16759 api_one_map_request_mode (vat_main_t * vam)
16761 unformat_input_t *input = vam->input;
16762 vl_api_one_map_request_mode_t *mp;
16766 /* Parse args required to build the message */
16767 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16769 if (unformat (input, "dst-only"))
16771 else if (unformat (input, "src-dst"))
16775 errmsg ("parse error '%U'", format_unformat_error, input);
16780 M (ONE_MAP_REQUEST_MODE, mp);
16787 /* wait for reply */
16792 #define api_lisp_map_request_mode api_one_map_request_mode
16795 * Enable/disable ONE proxy ITR.
16797 * @param vam vpp API test context
16798 * @return return code
16801 api_one_pitr_set_locator_set (vat_main_t * vam)
16803 u8 ls_name_set = 0;
16804 unformat_input_t *input = vam->input;
16805 vl_api_one_pitr_set_locator_set_t *mp;
16810 /* Parse args required to build the message */
16811 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16813 if (unformat (input, "del"))
16815 else if (unformat (input, "locator-set %s", &ls_name))
16819 errmsg ("parse error '%U'", format_unformat_error, input);
16826 errmsg ("locator-set name not set!");
16830 M (ONE_PITR_SET_LOCATOR_SET, mp);
16832 mp->is_add = is_add;
16833 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16834 vec_free (ls_name);
16839 /* wait for reply */
16844 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
16847 api_one_nsh_set_locator_set (vat_main_t * vam)
16849 u8 ls_name_set = 0;
16850 unformat_input_t *input = vam->input;
16851 vl_api_one_nsh_set_locator_set_t *mp;
16856 /* Parse args required to build the message */
16857 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16859 if (unformat (input, "del"))
16861 else if (unformat (input, "ls %s", &ls_name))
16865 errmsg ("parse error '%U'", format_unformat_error, input);
16870 if (!ls_name_set && is_add)
16872 errmsg ("locator-set name not set!");
16876 M (ONE_NSH_SET_LOCATOR_SET, mp);
16878 mp->is_add = is_add;
16879 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16880 vec_free (ls_name);
16885 /* wait for reply */
16891 api_show_one_pitr (vat_main_t * vam)
16893 vl_api_show_one_pitr_t *mp;
16896 if (!vam->json_output)
16898 print (vam->ofp, "%=20s", "lisp status:");
16901 M (SHOW_ONE_PITR, mp);
16905 /* Wait for a reply... */
16910 #define api_show_lisp_pitr api_show_one_pitr
16913 api_one_use_petr (vat_main_t * vam)
16915 unformat_input_t *input = vam->input;
16916 vl_api_one_use_petr_t *mp;
16921 clib_memset (&ip, 0, sizeof (ip));
16923 /* Parse args required to build the message */
16924 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16926 if (unformat (input, "disable"))
16929 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
16932 ip_addr_version (&ip) = IP4;
16935 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
16938 ip_addr_version (&ip) = IP6;
16942 errmsg ("parse error '%U'", format_unformat_error, input);
16947 M (ONE_USE_PETR, mp);
16949 mp->is_add = is_add;
16952 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
16954 clib_memcpy (mp->address, &ip, 4);
16956 clib_memcpy (mp->address, &ip, 16);
16962 /* wait for reply */
16967 #define api_lisp_use_petr api_one_use_petr
16970 api_show_one_nsh_mapping (vat_main_t * vam)
16972 vl_api_show_one_use_petr_t *mp;
16975 if (!vam->json_output)
16977 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
16980 M (SHOW_ONE_NSH_MAPPING, mp);
16984 /* Wait for a reply... */
16990 api_show_one_use_petr (vat_main_t * vam)
16992 vl_api_show_one_use_petr_t *mp;
16995 if (!vam->json_output)
16997 print (vam->ofp, "%=20s", "Proxy-ETR status:");
17000 M (SHOW_ONE_USE_PETR, mp);
17004 /* Wait for a reply... */
17009 #define api_show_lisp_use_petr api_show_one_use_petr
17012 * Add/delete mapping between vni and vrf
17015 api_one_eid_table_add_del_map (vat_main_t * vam)
17017 unformat_input_t *input = vam->input;
17018 vl_api_one_eid_table_add_del_map_t *mp;
17019 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
17020 u32 vni, vrf, bd_index;
17023 /* Parse args required to build the message */
17024 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17026 if (unformat (input, "del"))
17028 else if (unformat (input, "vrf %d", &vrf))
17030 else if (unformat (input, "bd_index %d", &bd_index))
17032 else if (unformat (input, "vni %d", &vni))
17038 if (!vni_set || (!vrf_set && !bd_index_set))
17040 errmsg ("missing arguments!");
17044 if (vrf_set && bd_index_set)
17046 errmsg ("error: both vrf and bd entered!");
17050 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
17052 mp->is_add = is_add;
17053 mp->vni = htonl (vni);
17054 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
17055 mp->is_l2 = bd_index_set;
17060 /* wait for reply */
17065 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
17068 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
17070 u32 *action = va_arg (*args, u32 *);
17073 if (unformat (input, "%s", &s))
17075 if (!strcmp ((char *) s, "no-action"))
17077 else if (!strcmp ((char *) s, "natively-forward"))
17079 else if (!strcmp ((char *) s, "send-map-request"))
17081 else if (!strcmp ((char *) s, "drop"))
17085 clib_warning ("invalid action: '%s'", s);
17097 * Add/del remote mapping to/from ONE control plane
17099 * @param vam vpp API test context
17100 * @return return code
17103 api_one_add_del_remote_mapping (vat_main_t * vam)
17105 unformat_input_t *input = vam->input;
17106 vl_api_one_add_del_remote_mapping_t *mp;
17108 lisp_eid_vat_t _eid, *eid = &_eid;
17109 lisp_eid_vat_t _seid, *seid = &_seid;
17110 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
17111 u32 action = ~0, p, w, data_len;
17112 ip4_address_t rloc4;
17113 ip6_address_t rloc6;
17114 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
17117 clib_memset (&rloc, 0, sizeof (rloc));
17119 /* Parse args required to build the message */
17120 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17122 if (unformat (input, "del-all"))
17126 else if (unformat (input, "del"))
17130 else if (unformat (input, "add"))
17134 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
17138 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
17142 else if (unformat (input, "vni %d", &vni))
17146 else if (unformat (input, "p %d w %d", &p, &w))
17150 errmsg ("No RLOC configured for setting priority/weight!");
17153 curr_rloc->priority = p;
17154 curr_rloc->weight = w;
17156 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
17159 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
17160 vec_add1 (rlocs, rloc);
17161 curr_rloc = &rlocs[vec_len (rlocs) - 1];
17163 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
17166 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
17167 vec_add1 (rlocs, rloc);
17168 curr_rloc = &rlocs[vec_len (rlocs) - 1];
17170 else if (unformat (input, "action %U",
17171 unformat_negative_mapping_action, &action))
17177 clib_warning ("parse error '%U'", format_unformat_error, input);
17184 errmsg ("missing params!");
17188 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
17190 errmsg ("no action set for negative map-reply!");
17194 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
17196 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
17197 mp->is_add = is_add;
17198 mp->vni = htonl (vni);
17199 mp->action = (u8) action;
17200 mp->is_src_dst = seid_set;
17201 mp->eid_len = eid->len;
17202 mp->seid_len = seid->len;
17203 mp->del_all = del_all;
17204 mp->eid_type = eid->type;
17205 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
17206 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
17208 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
17209 clib_memcpy (mp->rlocs, rlocs, data_len);
17215 /* Wait for a reply... */
17220 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
17223 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
17224 * forwarding entries in data-plane accordingly.
17226 * @param vam vpp API test context
17227 * @return return code
17230 api_one_add_del_adjacency (vat_main_t * vam)
17232 unformat_input_t *input = vam->input;
17233 vl_api_one_add_del_adjacency_t *mp;
17235 ip4_address_t leid4, reid4;
17236 ip6_address_t leid6, reid6;
17237 u8 reid_mac[6] = { 0 };
17238 u8 leid_mac[6] = { 0 };
17239 u8 reid_type, leid_type;
17240 u32 leid_len = 0, reid_len = 0, len;
17244 leid_type = reid_type = (u8) ~ 0;
17246 /* Parse args required to build the message */
17247 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17249 if (unformat (input, "del"))
17253 else if (unformat (input, "add"))
17257 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
17260 reid_type = 0; /* ipv4 */
17263 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
17266 reid_type = 1; /* ipv6 */
17269 else if (unformat (input, "reid %U", unformat_ethernet_address,
17272 reid_type = 2; /* mac */
17274 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
17277 leid_type = 0; /* ipv4 */
17280 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
17283 leid_type = 1; /* ipv6 */
17286 else if (unformat (input, "leid %U", unformat_ethernet_address,
17289 leid_type = 2; /* mac */
17291 else if (unformat (input, "vni %d", &vni))
17297 errmsg ("parse error '%U'", format_unformat_error, input);
17302 if ((u8) ~ 0 == reid_type)
17304 errmsg ("missing params!");
17308 if (leid_type != reid_type)
17310 errmsg ("remote and local EIDs are of different types!");
17314 M (ONE_ADD_DEL_ADJACENCY, mp);
17315 mp->is_add = is_add;
17316 mp->vni = htonl (vni);
17317 mp->leid_len = leid_len;
17318 mp->reid_len = reid_len;
17319 mp->eid_type = reid_type;
17321 switch (mp->eid_type)
17324 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
17325 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
17328 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
17329 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
17332 clib_memcpy (mp->leid, leid_mac, 6);
17333 clib_memcpy (mp->reid, reid_mac, 6);
17336 errmsg ("unknown EID type %d!", mp->eid_type);
17343 /* Wait for a reply... */
17348 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
17351 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
17353 u32 *mode = va_arg (*args, u32 *);
17355 if (unformat (input, "lisp"))
17357 else if (unformat (input, "vxlan"))
17366 api_gpe_get_encap_mode (vat_main_t * vam)
17368 vl_api_gpe_get_encap_mode_t *mp;
17371 /* Construct the API message */
17372 M (GPE_GET_ENCAP_MODE, mp);
17377 /* Wait for a reply... */
17383 api_gpe_set_encap_mode (vat_main_t * vam)
17385 unformat_input_t *input = vam->input;
17386 vl_api_gpe_set_encap_mode_t *mp;
17390 /* Parse args required to build the message */
17391 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17393 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
17399 /* Construct the API message */
17400 M (GPE_SET_ENCAP_MODE, mp);
17407 /* Wait for a reply... */
17413 api_lisp_gpe_add_del_iface (vat_main_t * vam)
17415 unformat_input_t *input = vam->input;
17416 vl_api_gpe_add_del_iface_t *mp;
17417 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
17418 u32 dp_table = 0, vni = 0;
17421 /* Parse args required to build the message */
17422 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17424 if (unformat (input, "up"))
17429 else if (unformat (input, "down"))
17434 else if (unformat (input, "table_id %d", &dp_table))
17438 else if (unformat (input, "bd_id %d", &dp_table))
17443 else if (unformat (input, "vni %d", &vni))
17451 if (action_set == 0)
17453 errmsg ("Action not set");
17456 if (dp_table_set == 0 || vni_set == 0)
17458 errmsg ("vni and dp_table must be set");
17462 /* Construct the API message */
17463 M (GPE_ADD_DEL_IFACE, mp);
17465 mp->is_add = is_add;
17466 mp->dp_table = clib_host_to_net_u32 (dp_table);
17468 mp->vni = clib_host_to_net_u32 (vni);
17473 /* Wait for a reply... */
17479 api_one_map_register_fallback_threshold (vat_main_t * vam)
17481 unformat_input_t *input = vam->input;
17482 vl_api_one_map_register_fallback_threshold_t *mp;
17487 /* Parse args required to build the message */
17488 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17490 if (unformat (input, "%u", &value))
17494 clib_warning ("parse error '%U'", format_unformat_error, input);
17501 errmsg ("fallback threshold value is missing!");
17505 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17506 mp->value = clib_host_to_net_u32 (value);
17511 /* Wait for a reply... */
17517 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
17519 vl_api_show_one_map_register_fallback_threshold_t *mp;
17522 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17527 /* Wait for a reply... */
17533 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
17535 u32 *proto = va_arg (*args, u32 *);
17537 if (unformat (input, "udp"))
17539 else if (unformat (input, "api"))
17548 api_one_set_transport_protocol (vat_main_t * vam)
17550 unformat_input_t *input = vam->input;
17551 vl_api_one_set_transport_protocol_t *mp;
17556 /* Parse args required to build the message */
17557 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17559 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
17563 clib_warning ("parse error '%U'", format_unformat_error, input);
17570 errmsg ("Transport protocol missing!");
17574 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
17575 mp->protocol = (u8) protocol;
17580 /* Wait for a reply... */
17586 api_one_get_transport_protocol (vat_main_t * vam)
17588 vl_api_one_get_transport_protocol_t *mp;
17591 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
17596 /* Wait for a reply... */
17602 api_one_map_register_set_ttl (vat_main_t * vam)
17604 unformat_input_t *input = vam->input;
17605 vl_api_one_map_register_set_ttl_t *mp;
17610 /* Parse args required to build the message */
17611 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17613 if (unformat (input, "%u", &ttl))
17617 clib_warning ("parse error '%U'", format_unformat_error, input);
17624 errmsg ("TTL value missing!");
17628 M (ONE_MAP_REGISTER_SET_TTL, mp);
17629 mp->ttl = clib_host_to_net_u32 (ttl);
17634 /* Wait for a reply... */
17640 api_show_one_map_register_ttl (vat_main_t * vam)
17642 vl_api_show_one_map_register_ttl_t *mp;
17645 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
17650 /* Wait for a reply... */
17656 * Add/del map request itr rlocs from ONE control plane and updates
17658 * @param vam vpp API test context
17659 * @return return code
17662 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
17664 unformat_input_t *input = vam->input;
17665 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
17666 u8 *locator_set_name = 0;
17667 u8 locator_set_name_set = 0;
17671 /* Parse args required to build the message */
17672 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17674 if (unformat (input, "del"))
17678 else if (unformat (input, "%_%v%_", &locator_set_name))
17680 locator_set_name_set = 1;
17684 clib_warning ("parse error '%U'", format_unformat_error, input);
17689 if (is_add && !locator_set_name_set)
17691 errmsg ("itr-rloc is not set!");
17695 if (is_add && vec_len (locator_set_name) > 64)
17697 errmsg ("itr-rloc locator-set name too long");
17698 vec_free (locator_set_name);
17702 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
17703 mp->is_add = is_add;
17706 clib_memcpy (mp->locator_set_name, locator_set_name,
17707 vec_len (locator_set_name));
17711 clib_memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
17713 vec_free (locator_set_name);
17718 /* Wait for a reply... */
17723 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
17726 api_one_locator_dump (vat_main_t * vam)
17728 unformat_input_t *input = vam->input;
17729 vl_api_one_locator_dump_t *mp;
17730 vl_api_control_ping_t *mp_ping;
17731 u8 is_index_set = 0, is_name_set = 0;
17736 /* Parse args required to build the message */
17737 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17739 if (unformat (input, "ls_name %_%v%_", &ls_name))
17743 else if (unformat (input, "ls_index %d", &ls_index))
17749 errmsg ("parse error '%U'", format_unformat_error, input);
17754 if (!is_index_set && !is_name_set)
17756 errmsg ("error: expected one of index or name!");
17760 if (is_index_set && is_name_set)
17762 errmsg ("error: only one param expected!");
17766 if (vec_len (ls_name) > 62)
17768 errmsg ("error: locator set name too long!");
17772 if (!vam->json_output)
17774 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
17777 M (ONE_LOCATOR_DUMP, mp);
17778 mp->is_index_set = is_index_set;
17781 mp->ls_index = clib_host_to_net_u32 (ls_index);
17784 vec_add1 (ls_name, 0);
17785 strncpy ((char *) mp->ls_name, (char *) ls_name,
17786 sizeof (mp->ls_name) - 1);
17792 /* Use a control ping for synchronization */
17793 MPING (CONTROL_PING, mp_ping);
17796 /* Wait for a reply... */
17801 #define api_lisp_locator_dump api_one_locator_dump
17804 api_one_locator_set_dump (vat_main_t * vam)
17806 vl_api_one_locator_set_dump_t *mp;
17807 vl_api_control_ping_t *mp_ping;
17808 unformat_input_t *input = vam->input;
17812 /* Parse args required to build the message */
17813 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17815 if (unformat (input, "local"))
17819 else if (unformat (input, "remote"))
17825 errmsg ("parse error '%U'", format_unformat_error, input);
17830 if (!vam->json_output)
17832 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
17835 M (ONE_LOCATOR_SET_DUMP, mp);
17837 mp->filter = filter;
17842 /* Use a control ping for synchronization */
17843 MPING (CONTROL_PING, mp_ping);
17846 /* Wait for a reply... */
17851 #define api_lisp_locator_set_dump api_one_locator_set_dump
17854 api_one_eid_table_map_dump (vat_main_t * vam)
17858 unformat_input_t *input = vam->input;
17859 vl_api_one_eid_table_map_dump_t *mp;
17860 vl_api_control_ping_t *mp_ping;
17863 /* Parse args required to build the message */
17864 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17866 if (unformat (input, "l2"))
17871 else if (unformat (input, "l3"))
17878 errmsg ("parse error '%U'", format_unformat_error, input);
17885 errmsg ("expected one of 'l2' or 'l3' parameter!");
17889 if (!vam->json_output)
17891 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
17894 M (ONE_EID_TABLE_MAP_DUMP, mp);
17900 /* Use a control ping for synchronization */
17901 MPING (CONTROL_PING, mp_ping);
17904 /* Wait for a reply... */
17909 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
17912 api_one_eid_table_vni_dump (vat_main_t * vam)
17914 vl_api_one_eid_table_vni_dump_t *mp;
17915 vl_api_control_ping_t *mp_ping;
17918 if (!vam->json_output)
17920 print (vam->ofp, "VNI");
17923 M (ONE_EID_TABLE_VNI_DUMP, mp);
17928 /* Use a control ping for synchronization */
17929 MPING (CONTROL_PING, mp_ping);
17932 /* Wait for a reply... */
17937 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
17940 api_one_eid_table_dump (vat_main_t * vam)
17942 unformat_input_t *i = vam->input;
17943 vl_api_one_eid_table_dump_t *mp;
17944 vl_api_control_ping_t *mp_ping;
17945 struct in_addr ip4;
17946 struct in6_addr ip6;
17948 u8 eid_type = ~0, eid_set = 0;
17949 u32 prefix_length = ~0, t, vni = 0;
17952 lisp_nsh_api_t nsh;
17954 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17956 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
17962 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
17968 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
17973 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
17978 else if (unformat (i, "vni %d", &t))
17982 else if (unformat (i, "local"))
17986 else if (unformat (i, "remote"))
17992 errmsg ("parse error '%U'", format_unformat_error, i);
17997 if (!vam->json_output)
17999 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
18000 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
18003 M (ONE_EID_TABLE_DUMP, mp);
18005 mp->filter = filter;
18009 mp->vni = htonl (vni);
18010 mp->eid_type = eid_type;
18014 mp->prefix_length = prefix_length;
18015 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
18018 mp->prefix_length = prefix_length;
18019 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
18022 clib_memcpy (mp->eid, mac, sizeof (mac));
18025 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
18028 errmsg ("unknown EID type %d!", eid_type);
18036 /* Use a control ping for synchronization */
18037 MPING (CONTROL_PING, mp_ping);
18040 /* Wait for a reply... */
18045 #define api_lisp_eid_table_dump api_one_eid_table_dump
18048 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
18050 unformat_input_t *i = vam->input;
18051 vl_api_gpe_fwd_entries_get_t *mp;
18056 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18058 if (unformat (i, "vni %d", &vni))
18064 errmsg ("parse error '%U'", format_unformat_error, i);
18071 errmsg ("vni not set!");
18075 if (!vam->json_output)
18077 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
18081 M (GPE_FWD_ENTRIES_GET, mp);
18082 mp->vni = clib_host_to_net_u32 (vni);
18087 /* Wait for a reply... */
18092 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
18093 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
18094 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
18095 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
18096 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
18097 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
18098 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
18099 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
18102 api_one_adjacencies_get (vat_main_t * vam)
18104 unformat_input_t *i = vam->input;
18105 vl_api_one_adjacencies_get_t *mp;
18110 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18112 if (unformat (i, "vni %d", &vni))
18118 errmsg ("parse error '%U'", format_unformat_error, i);
18125 errmsg ("vni not set!");
18129 if (!vam->json_output)
18131 print (vam->ofp, "%s %40s", "leid", "reid");
18134 M (ONE_ADJACENCIES_GET, mp);
18135 mp->vni = clib_host_to_net_u32 (vni);
18140 /* Wait for a reply... */
18145 #define api_lisp_adjacencies_get api_one_adjacencies_get
18148 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
18150 unformat_input_t *i = vam->input;
18151 vl_api_gpe_native_fwd_rpaths_get_t *mp;
18153 u8 ip_family_set = 0, is_ip4 = 1;
18155 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18157 if (unformat (i, "ip4"))
18162 else if (unformat (i, "ip6"))
18169 errmsg ("parse error '%U'", format_unformat_error, i);
18174 if (!ip_family_set)
18176 errmsg ("ip family not set!");
18180 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
18181 mp->is_ip4 = is_ip4;
18186 /* Wait for a reply... */
18192 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
18194 vl_api_gpe_fwd_entry_vnis_get_t *mp;
18197 if (!vam->json_output)
18199 print (vam->ofp, "VNIs");
18202 M (GPE_FWD_ENTRY_VNIS_GET, mp);
18207 /* Wait for a reply... */
18213 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
18215 unformat_input_t *i = vam->input;
18216 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
18218 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
18219 struct in_addr ip4;
18220 struct in6_addr ip6;
18221 u32 table_id = 0, nh_sw_if_index = ~0;
18223 clib_memset (&ip4, 0, sizeof (ip4));
18224 clib_memset (&ip6, 0, sizeof (ip6));
18226 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18228 if (unformat (i, "del"))
18230 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
18231 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18236 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
18237 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18242 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
18246 nh_sw_if_index = ~0;
18248 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
18252 nh_sw_if_index = ~0;
18254 else if (unformat (i, "table %d", &table_id))
18258 errmsg ("parse error '%U'", format_unformat_error, i);
18265 errmsg ("nh addr not set!");
18269 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
18270 mp->is_add = is_add;
18271 mp->table_id = clib_host_to_net_u32 (table_id);
18272 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
18273 mp->is_ip4 = is_ip4;
18275 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
18277 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
18282 /* Wait for a reply... */
18288 api_one_map_server_dump (vat_main_t * vam)
18290 vl_api_one_map_server_dump_t *mp;
18291 vl_api_control_ping_t *mp_ping;
18294 if (!vam->json_output)
18296 print (vam->ofp, "%=20s", "Map server");
18299 M (ONE_MAP_SERVER_DUMP, mp);
18303 /* Use a control ping for synchronization */
18304 MPING (CONTROL_PING, mp_ping);
18307 /* Wait for a reply... */
18312 #define api_lisp_map_server_dump api_one_map_server_dump
18315 api_one_map_resolver_dump (vat_main_t * vam)
18317 vl_api_one_map_resolver_dump_t *mp;
18318 vl_api_control_ping_t *mp_ping;
18321 if (!vam->json_output)
18323 print (vam->ofp, "%=20s", "Map resolver");
18326 M (ONE_MAP_RESOLVER_DUMP, mp);
18330 /* Use a control ping for synchronization */
18331 MPING (CONTROL_PING, mp_ping);
18334 /* Wait for a reply... */
18339 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
18342 api_one_stats_flush (vat_main_t * vam)
18344 vl_api_one_stats_flush_t *mp;
18347 M (ONE_STATS_FLUSH, mp);
18354 api_one_stats_dump (vat_main_t * vam)
18356 vl_api_one_stats_dump_t *mp;
18357 vl_api_control_ping_t *mp_ping;
18360 M (ONE_STATS_DUMP, mp);
18364 /* Use a control ping for synchronization */
18365 MPING (CONTROL_PING, mp_ping);
18368 /* Wait for a reply... */
18374 api_show_one_status (vat_main_t * vam)
18376 vl_api_show_one_status_t *mp;
18379 if (!vam->json_output)
18381 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
18384 M (SHOW_ONE_STATUS, mp);
18387 /* Wait for a reply... */
18392 #define api_show_lisp_status api_show_one_status
18395 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
18397 vl_api_gpe_fwd_entry_path_dump_t *mp;
18398 vl_api_control_ping_t *mp_ping;
18399 unformat_input_t *i = vam->input;
18400 u32 fwd_entry_index = ~0;
18403 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18405 if (unformat (i, "index %d", &fwd_entry_index))
18411 if (~0 == fwd_entry_index)
18413 errmsg ("no index specified!");
18417 if (!vam->json_output)
18419 print (vam->ofp, "first line");
18422 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
18426 /* Use a control ping for synchronization */
18427 MPING (CONTROL_PING, mp_ping);
18430 /* Wait for a reply... */
18436 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
18438 vl_api_one_get_map_request_itr_rlocs_t *mp;
18441 if (!vam->json_output)
18443 print (vam->ofp, "%=20s", "itr-rlocs:");
18446 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
18449 /* Wait for a reply... */
18454 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
18457 api_af_packet_create (vat_main_t * vam)
18459 unformat_input_t *i = vam->input;
18460 vl_api_af_packet_create_t *mp;
18461 u8 *host_if_name = 0;
18463 u8 random_hw_addr = 1;
18466 clib_memset (hw_addr, 0, sizeof (hw_addr));
18468 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18470 if (unformat (i, "name %s", &host_if_name))
18471 vec_add1 (host_if_name, 0);
18472 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18473 random_hw_addr = 0;
18478 if (!vec_len (host_if_name))
18480 errmsg ("host-interface name must be specified");
18484 if (vec_len (host_if_name) > 64)
18486 errmsg ("host-interface name too long");
18490 M (AF_PACKET_CREATE, mp);
18492 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18493 clib_memcpy (mp->hw_addr, hw_addr, 6);
18494 mp->use_random_hw_addr = random_hw_addr;
18495 vec_free (host_if_name);
18503 fprintf (vam->ofp ? vam->ofp : stderr,
18504 " new sw_if_index = %d\n", vam->sw_if_index);
18511 api_af_packet_delete (vat_main_t * vam)
18513 unformat_input_t *i = vam->input;
18514 vl_api_af_packet_delete_t *mp;
18515 u8 *host_if_name = 0;
18518 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18520 if (unformat (i, "name %s", &host_if_name))
18521 vec_add1 (host_if_name, 0);
18526 if (!vec_len (host_if_name))
18528 errmsg ("host-interface name must be specified");
18532 if (vec_len (host_if_name) > 64)
18534 errmsg ("host-interface name too long");
18538 M (AF_PACKET_DELETE, mp);
18540 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18541 vec_free (host_if_name);
18548 static void vl_api_af_packet_details_t_handler
18549 (vl_api_af_packet_details_t * mp)
18551 vat_main_t *vam = &vat_main;
18553 print (vam->ofp, "%-16s %d",
18554 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
18557 static void vl_api_af_packet_details_t_handler_json
18558 (vl_api_af_packet_details_t * mp)
18560 vat_main_t *vam = &vat_main;
18561 vat_json_node_t *node = NULL;
18563 if (VAT_JSON_ARRAY != vam->json_tree.type)
18565 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18566 vat_json_init_array (&vam->json_tree);
18568 node = vat_json_array_add (&vam->json_tree);
18570 vat_json_init_object (node);
18571 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
18572 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
18576 api_af_packet_dump (vat_main_t * vam)
18578 vl_api_af_packet_dump_t *mp;
18579 vl_api_control_ping_t *mp_ping;
18582 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
18583 /* Get list of tap interfaces */
18584 M (AF_PACKET_DUMP, mp);
18587 /* Use a control ping for synchronization */
18588 MPING (CONTROL_PING, mp_ping);
18596 api_policer_add_del (vat_main_t * vam)
18598 unformat_input_t *i = vam->input;
18599 vl_api_policer_add_del_t *mp;
18609 u8 color_aware = 0;
18610 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
18613 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
18614 conform_action.dscp = 0;
18615 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
18616 exceed_action.dscp = 0;
18617 violate_action.action_type = SSE2_QOS_ACTION_DROP;
18618 violate_action.dscp = 0;
18620 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18622 if (unformat (i, "del"))
18624 else if (unformat (i, "name %s", &name))
18625 vec_add1 (name, 0);
18626 else if (unformat (i, "cir %u", &cir))
18628 else if (unformat (i, "eir %u", &eir))
18630 else if (unformat (i, "cb %u", &cb))
18632 else if (unformat (i, "eb %u", &eb))
18634 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
18637 else if (unformat (i, "round_type %U", unformat_policer_round_type,
18640 else if (unformat (i, "type %U", unformat_policer_type, &type))
18642 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
18645 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
18648 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
18651 else if (unformat (i, "color-aware"))
18657 if (!vec_len (name))
18659 errmsg ("policer name must be specified");
18663 if (vec_len (name) > 64)
18665 errmsg ("policer name too long");
18669 M (POLICER_ADD_DEL, mp);
18671 clib_memcpy (mp->name, name, vec_len (name));
18673 mp->is_add = is_add;
18674 mp->cir = ntohl (cir);
18675 mp->eir = ntohl (eir);
18676 mp->cb = clib_net_to_host_u64 (cb);
18677 mp->eb = clib_net_to_host_u64 (eb);
18678 mp->rate_type = rate_type;
18679 mp->round_type = round_type;
18681 mp->conform_action_type = conform_action.action_type;
18682 mp->conform_dscp = conform_action.dscp;
18683 mp->exceed_action_type = exceed_action.action_type;
18684 mp->exceed_dscp = exceed_action.dscp;
18685 mp->violate_action_type = violate_action.action_type;
18686 mp->violate_dscp = violate_action.dscp;
18687 mp->color_aware = color_aware;
18695 api_policer_dump (vat_main_t * vam)
18697 unformat_input_t *i = vam->input;
18698 vl_api_policer_dump_t *mp;
18699 vl_api_control_ping_t *mp_ping;
18700 u8 *match_name = 0;
18701 u8 match_name_valid = 0;
18704 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18706 if (unformat (i, "name %s", &match_name))
18708 vec_add1 (match_name, 0);
18709 match_name_valid = 1;
18715 M (POLICER_DUMP, mp);
18716 mp->match_name_valid = match_name_valid;
18717 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
18718 vec_free (match_name);
18722 /* Use a control ping for synchronization */
18723 MPING (CONTROL_PING, mp_ping);
18726 /* Wait for a reply... */
18732 api_policer_classify_set_interface (vat_main_t * vam)
18734 unformat_input_t *i = vam->input;
18735 vl_api_policer_classify_set_interface_t *mp;
18737 int sw_if_index_set;
18738 u32 ip4_table_index = ~0;
18739 u32 ip6_table_index = ~0;
18740 u32 l2_table_index = ~0;
18744 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18746 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18747 sw_if_index_set = 1;
18748 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18749 sw_if_index_set = 1;
18750 else if (unformat (i, "del"))
18752 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18754 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18756 else if (unformat (i, "l2-table %d", &l2_table_index))
18760 clib_warning ("parse error '%U'", format_unformat_error, i);
18765 if (sw_if_index_set == 0)
18767 errmsg ("missing interface name or sw_if_index");
18771 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
18773 mp->sw_if_index = ntohl (sw_if_index);
18774 mp->ip4_table_index = ntohl (ip4_table_index);
18775 mp->ip6_table_index = ntohl (ip6_table_index);
18776 mp->l2_table_index = ntohl (l2_table_index);
18777 mp->is_add = is_add;
18785 api_policer_classify_dump (vat_main_t * vam)
18787 unformat_input_t *i = vam->input;
18788 vl_api_policer_classify_dump_t *mp;
18789 vl_api_control_ping_t *mp_ping;
18790 u8 type = POLICER_CLASSIFY_N_TABLES;
18793 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
18797 errmsg ("classify table type must be specified");
18801 if (!vam->json_output)
18803 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
18806 M (POLICER_CLASSIFY_DUMP, mp);
18811 /* Use a control ping for synchronization */
18812 MPING (CONTROL_PING, mp_ping);
18815 /* Wait for a reply... */
18821 api_netmap_create (vat_main_t * vam)
18823 unformat_input_t *i = vam->input;
18824 vl_api_netmap_create_t *mp;
18827 u8 random_hw_addr = 1;
18832 clib_memset (hw_addr, 0, sizeof (hw_addr));
18834 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18836 if (unformat (i, "name %s", &if_name))
18837 vec_add1 (if_name, 0);
18838 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18839 random_hw_addr = 0;
18840 else if (unformat (i, "pipe"))
18842 else if (unformat (i, "master"))
18844 else if (unformat (i, "slave"))
18850 if (!vec_len (if_name))
18852 errmsg ("interface name must be specified");
18856 if (vec_len (if_name) > 64)
18858 errmsg ("interface name too long");
18862 M (NETMAP_CREATE, mp);
18864 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18865 clib_memcpy (mp->hw_addr, hw_addr, 6);
18866 mp->use_random_hw_addr = random_hw_addr;
18867 mp->is_pipe = is_pipe;
18868 mp->is_master = is_master;
18869 vec_free (if_name);
18877 api_netmap_delete (vat_main_t * vam)
18879 unformat_input_t *i = vam->input;
18880 vl_api_netmap_delete_t *mp;
18884 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18886 if (unformat (i, "name %s", &if_name))
18887 vec_add1 (if_name, 0);
18892 if (!vec_len (if_name))
18894 errmsg ("interface name must be specified");
18898 if (vec_len (if_name) > 64)
18900 errmsg ("interface name too long");
18904 M (NETMAP_DELETE, mp);
18906 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18907 vec_free (if_name);
18915 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
18917 if (fp->afi == IP46_TYPE_IP6)
18919 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18920 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18921 fp->weight, ntohl (fp->sw_if_index), fp->is_local,
18922 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18923 format_ip6_address, fp->next_hop);
18924 else if (fp->afi == IP46_TYPE_IP4)
18926 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18927 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18928 fp->weight, ntohl (fp->sw_if_index), fp->is_local,
18929 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18930 format_ip4_address, fp->next_hop);
18934 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
18935 vl_api_fib_path_t * fp)
18937 struct in_addr ip4;
18938 struct in6_addr ip6;
18940 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
18941 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
18942 vat_json_object_add_uint (node, "is_local", fp->is_local);
18943 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
18944 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
18945 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
18946 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
18947 if (fp->afi == IP46_TYPE_IP4)
18949 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
18950 vat_json_object_add_ip4 (node, "next_hop", ip4);
18952 else if (fp->afi == IP46_TYPE_IP6)
18954 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
18955 vat_json_object_add_ip6 (node, "next_hop", ip6);
18960 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
18962 vat_main_t *vam = &vat_main;
18963 int count = ntohl (mp->mt_count);
18964 vl_api_fib_path_t *fp;
18967 print (vam->ofp, "[%d]: sw_if_index %d via:",
18968 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
18970 for (i = 0; i < count; i++)
18972 vl_api_mpls_fib_path_print (vam, fp);
18976 print (vam->ofp, "");
18979 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
18980 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
18983 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
18985 vat_main_t *vam = &vat_main;
18986 vat_json_node_t *node = NULL;
18987 int count = ntohl (mp->mt_count);
18988 vl_api_fib_path_t *fp;
18991 if (VAT_JSON_ARRAY != vam->json_tree.type)
18993 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18994 vat_json_init_array (&vam->json_tree);
18996 node = vat_json_array_add (&vam->json_tree);
18998 vat_json_init_object (node);
18999 vat_json_object_add_uint (node, "tunnel_index",
19000 ntohl (mp->mt_tunnel_index));
19001 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
19003 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
19006 for (i = 0; i < count; i++)
19008 vl_api_mpls_fib_path_json_print (node, fp);
19014 api_mpls_tunnel_dump (vat_main_t * vam)
19016 vl_api_mpls_tunnel_dump_t *mp;
19017 vl_api_control_ping_t *mp_ping;
19018 u32 sw_if_index = ~0;
19021 /* Parse args required to build the message */
19022 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
19024 if (unformat (vam->input, "sw_if_index %d", &sw_if_index))
19028 print (vam->ofp, " sw_if_index %d", sw_if_index);
19030 M (MPLS_TUNNEL_DUMP, mp);
19031 mp->sw_if_index = htonl (sw_if_index);
19034 /* Use a control ping for synchronization */
19035 MPING (CONTROL_PING, mp_ping);
19042 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
19043 #define vl_api_mpls_fib_details_t_print vl_noop_handler
19047 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
19049 vat_main_t *vam = &vat_main;
19050 int count = ntohl (mp->count);
19051 vl_api_fib_path_t *fp;
19055 "table-id %d, label %u, ess_bit %u",
19056 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
19058 for (i = 0; i < count; i++)
19060 vl_api_mpls_fib_path_print (vam, fp);
19065 static void vl_api_mpls_fib_details_t_handler_json
19066 (vl_api_mpls_fib_details_t * mp)
19068 vat_main_t *vam = &vat_main;
19069 int count = ntohl (mp->count);
19070 vat_json_node_t *node = NULL;
19071 vl_api_fib_path_t *fp;
19074 if (VAT_JSON_ARRAY != vam->json_tree.type)
19076 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19077 vat_json_init_array (&vam->json_tree);
19079 node = vat_json_array_add (&vam->json_tree);
19081 vat_json_init_object (node);
19082 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19083 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
19084 vat_json_object_add_uint (node, "label", ntohl (mp->label));
19085 vat_json_object_add_uint (node, "path_count", count);
19087 for (i = 0; i < count; i++)
19089 vl_api_mpls_fib_path_json_print (node, fp);
19095 api_mpls_fib_dump (vat_main_t * vam)
19097 vl_api_mpls_fib_dump_t *mp;
19098 vl_api_control_ping_t *mp_ping;
19101 M (MPLS_FIB_DUMP, mp);
19104 /* Use a control ping for synchronization */
19105 MPING (CONTROL_PING, mp_ping);
19112 #define vl_api_ip_fib_details_t_endian vl_noop_handler
19113 #define vl_api_ip_fib_details_t_print vl_noop_handler
19116 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
19118 vat_main_t *vam = &vat_main;
19119 int count = ntohl (mp->count);
19120 vl_api_fib_path_t *fp;
19124 "table-id %d, prefix %U/%d stats-index %d",
19125 ntohl (mp->table_id), format_ip4_address, mp->address,
19126 mp->address_length, ntohl (mp->stats_index));
19128 for (i = 0; i < count; i++)
19130 if (fp->afi == IP46_TYPE_IP6)
19132 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19133 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U, "
19134 "next_hop_table %d",
19135 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19136 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19137 format_ip6_address, fp->next_hop, ntohl (fp->table_id));
19138 else if (fp->afi == IP46_TYPE_IP4)
19140 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19141 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U, "
19142 "next_hop_table %d",
19143 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19144 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19145 format_ip4_address, fp->next_hop, ntohl (fp->table_id));
19150 static void vl_api_ip_fib_details_t_handler_json
19151 (vl_api_ip_fib_details_t * mp)
19153 vat_main_t *vam = &vat_main;
19154 int count = ntohl (mp->count);
19155 vat_json_node_t *node = NULL;
19156 struct in_addr ip4;
19157 struct in6_addr ip6;
19158 vl_api_fib_path_t *fp;
19161 if (VAT_JSON_ARRAY != vam->json_tree.type)
19163 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19164 vat_json_init_array (&vam->json_tree);
19166 node = vat_json_array_add (&vam->json_tree);
19168 vat_json_init_object (node);
19169 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19170 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
19171 vat_json_object_add_ip4 (node, "prefix", ip4);
19172 vat_json_object_add_uint (node, "mask_length", mp->address_length);
19173 vat_json_object_add_uint (node, "path_count", count);
19175 for (i = 0; i < count; i++)
19177 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19178 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19179 vat_json_object_add_uint (node, "is_local", fp->is_local);
19180 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19181 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19182 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19183 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19184 if (fp->afi == IP46_TYPE_IP4)
19186 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19187 vat_json_object_add_ip4 (node, "next_hop", ip4);
19189 else if (fp->afi == IP46_TYPE_IP6)
19191 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19192 vat_json_object_add_ip6 (node, "next_hop", ip6);
19198 api_ip_fib_dump (vat_main_t * vam)
19200 vl_api_ip_fib_dump_t *mp;
19201 vl_api_control_ping_t *mp_ping;
19204 M (IP_FIB_DUMP, mp);
19207 /* Use a control ping for synchronization */
19208 MPING (CONTROL_PING, mp_ping);
19216 api_ip_mfib_dump (vat_main_t * vam)
19218 vl_api_ip_mfib_dump_t *mp;
19219 vl_api_control_ping_t *mp_ping;
19222 M (IP_MFIB_DUMP, mp);
19225 /* Use a control ping for synchronization */
19226 MPING (CONTROL_PING, mp_ping);
19233 static void vl_api_ip_neighbor_details_t_handler
19234 (vl_api_ip_neighbor_details_t * mp)
19236 vat_main_t *vam = &vat_main;
19238 print (vam->ofp, "%c %U %U",
19239 (ntohl (mp->neighbor.flags) & IP_NEIGHBOR_FLAG_STATIC) ? 'S' : 'D',
19240 format_vl_api_mac_address, &mp->neighbor.mac_address,
19241 format_vl_api_address, &mp->neighbor.ip_address);
19244 static void vl_api_ip_neighbor_details_t_handler_json
19245 (vl_api_ip_neighbor_details_t * mp)
19248 vat_main_t *vam = &vat_main;
19249 vat_json_node_t *node;
19251 if (VAT_JSON_ARRAY != vam->json_tree.type)
19253 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19254 vat_json_init_array (&vam->json_tree);
19256 node = vat_json_array_add (&vam->json_tree);
19258 vat_json_init_object (node);
19259 vat_json_object_add_string_copy
19261 ((ntohl (mp->neighbor.flags) & IP_NEIGHBOR_FLAG_STATIC) ?
19262 (u8 *) "static" : (u8 *) "dynamic"));
19264 vat_json_object_add_string_copy (node, "link_layer",
19265 format (0, "%U", format_vl_api_mac_address,
19266 &mp->neighbor.mac_address));
19267 vat_json_object_add_address (node, "ip", &mp->neighbor.ip_address);
19271 api_ip_neighbor_dump (vat_main_t * vam)
19273 unformat_input_t *i = vam->input;
19274 vl_api_ip_neighbor_dump_t *mp;
19275 vl_api_control_ping_t *mp_ping;
19277 u32 sw_if_index = ~0;
19280 /* Parse args required to build the message */
19281 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19283 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19285 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19287 else if (unformat (i, "ip6"))
19293 if (sw_if_index == ~0)
19295 errmsg ("missing interface name or sw_if_index");
19299 M (IP_NEIGHBOR_DUMP, mp);
19300 mp->is_ipv6 = (u8) is_ipv6;
19301 mp->sw_if_index = ntohl (sw_if_index);
19304 /* Use a control ping for synchronization */
19305 MPING (CONTROL_PING, mp_ping);
19312 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
19313 #define vl_api_ip6_fib_details_t_print vl_noop_handler
19316 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
19318 vat_main_t *vam = &vat_main;
19319 int count = ntohl (mp->count);
19320 vl_api_fib_path_t *fp;
19324 "table-id %d, prefix %U/%d stats-index %d",
19325 ntohl (mp->table_id), format_ip6_address, mp->address,
19326 mp->address_length, ntohl (mp->stats_index));
19328 for (i = 0; i < count; i++)
19330 if (fp->afi == IP46_TYPE_IP6)
19332 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19333 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19334 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19335 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19336 format_ip6_address, fp->next_hop);
19337 else if (fp->afi == IP46_TYPE_IP4)
19339 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19340 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19341 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19342 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19343 format_ip4_address, fp->next_hop);
19348 static void vl_api_ip6_fib_details_t_handler_json
19349 (vl_api_ip6_fib_details_t * mp)
19351 vat_main_t *vam = &vat_main;
19352 int count = ntohl (mp->count);
19353 vat_json_node_t *node = NULL;
19354 struct in_addr ip4;
19355 struct in6_addr ip6;
19356 vl_api_fib_path_t *fp;
19359 if (VAT_JSON_ARRAY != vam->json_tree.type)
19361 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19362 vat_json_init_array (&vam->json_tree);
19364 node = vat_json_array_add (&vam->json_tree);
19366 vat_json_init_object (node);
19367 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19368 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
19369 vat_json_object_add_ip6 (node, "prefix", ip6);
19370 vat_json_object_add_uint (node, "mask_length", mp->address_length);
19371 vat_json_object_add_uint (node, "path_count", count);
19373 for (i = 0; i < count; i++)
19375 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19376 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19377 vat_json_object_add_uint (node, "is_local", fp->is_local);
19378 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19379 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19380 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19381 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19382 if (fp->afi == IP46_TYPE_IP4)
19384 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19385 vat_json_object_add_ip4 (node, "next_hop", ip4);
19387 else if (fp->afi == IP46_TYPE_IP6)
19389 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19390 vat_json_object_add_ip6 (node, "next_hop", ip6);
19396 api_ip6_fib_dump (vat_main_t * vam)
19398 vl_api_ip6_fib_dump_t *mp;
19399 vl_api_control_ping_t *mp_ping;
19402 M (IP6_FIB_DUMP, mp);
19405 /* Use a control ping for synchronization */
19406 MPING (CONTROL_PING, mp_ping);
19414 api_ip6_mfib_dump (vat_main_t * vam)
19416 vl_api_ip6_mfib_dump_t *mp;
19417 vl_api_control_ping_t *mp_ping;
19420 M (IP6_MFIB_DUMP, mp);
19423 /* Use a control ping for synchronization */
19424 MPING (CONTROL_PING, mp_ping);
19432 api_classify_table_ids (vat_main_t * vam)
19434 vl_api_classify_table_ids_t *mp;
19437 /* Construct the API message */
19438 M (CLASSIFY_TABLE_IDS, mp);
19447 api_classify_table_by_interface (vat_main_t * vam)
19449 unformat_input_t *input = vam->input;
19450 vl_api_classify_table_by_interface_t *mp;
19452 u32 sw_if_index = ~0;
19454 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19456 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19458 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19463 if (sw_if_index == ~0)
19465 errmsg ("missing interface name or sw_if_index");
19469 /* Construct the API message */
19470 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
19472 mp->sw_if_index = ntohl (sw_if_index);
19480 api_classify_table_info (vat_main_t * vam)
19482 unformat_input_t *input = vam->input;
19483 vl_api_classify_table_info_t *mp;
19487 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19489 if (unformat (input, "table_id %d", &table_id))
19494 if (table_id == ~0)
19496 errmsg ("missing table id");
19500 /* Construct the API message */
19501 M (CLASSIFY_TABLE_INFO, mp);
19503 mp->table_id = ntohl (table_id);
19511 api_classify_session_dump (vat_main_t * vam)
19513 unformat_input_t *input = vam->input;
19514 vl_api_classify_session_dump_t *mp;
19515 vl_api_control_ping_t *mp_ping;
19519 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19521 if (unformat (input, "table_id %d", &table_id))
19526 if (table_id == ~0)
19528 errmsg ("missing table id");
19532 /* Construct the API message */
19533 M (CLASSIFY_SESSION_DUMP, mp);
19535 mp->table_id = ntohl (table_id);
19538 /* Use a control ping for synchronization */
19539 MPING (CONTROL_PING, mp_ping);
19547 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
19549 vat_main_t *vam = &vat_main;
19551 print (vam->ofp, "collector_address %U, collector_port %d, "
19552 "src_address %U, vrf_id %d, path_mtu %u, "
19553 "template_interval %u, udp_checksum %d",
19554 format_ip4_address, mp->collector_address,
19555 ntohs (mp->collector_port),
19556 format_ip4_address, mp->src_address,
19557 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
19558 ntohl (mp->template_interval), mp->udp_checksum);
19561 vam->result_ready = 1;
19565 vl_api_ipfix_exporter_details_t_handler_json
19566 (vl_api_ipfix_exporter_details_t * mp)
19568 vat_main_t *vam = &vat_main;
19569 vat_json_node_t node;
19570 struct in_addr collector_address;
19571 struct in_addr src_address;
19573 vat_json_init_object (&node);
19574 clib_memcpy (&collector_address, &mp->collector_address,
19575 sizeof (collector_address));
19576 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
19577 vat_json_object_add_uint (&node, "collector_port",
19578 ntohs (mp->collector_port));
19579 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
19580 vat_json_object_add_ip4 (&node, "src_address", src_address);
19581 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
19582 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
19583 vat_json_object_add_uint (&node, "template_interval",
19584 ntohl (mp->template_interval));
19585 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
19587 vat_json_print (vam->ofp, &node);
19588 vat_json_free (&node);
19590 vam->result_ready = 1;
19594 api_ipfix_exporter_dump (vat_main_t * vam)
19596 vl_api_ipfix_exporter_dump_t *mp;
19599 /* Construct the API message */
19600 M (IPFIX_EXPORTER_DUMP, mp);
19609 api_ipfix_classify_stream_dump (vat_main_t * vam)
19611 vl_api_ipfix_classify_stream_dump_t *mp;
19614 /* Construct the API message */
19615 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
19626 vl_api_ipfix_classify_stream_details_t_handler
19627 (vl_api_ipfix_classify_stream_details_t * mp)
19629 vat_main_t *vam = &vat_main;
19630 print (vam->ofp, "domain_id %d, src_port %d",
19631 ntohl (mp->domain_id), ntohs (mp->src_port));
19633 vam->result_ready = 1;
19637 vl_api_ipfix_classify_stream_details_t_handler_json
19638 (vl_api_ipfix_classify_stream_details_t * mp)
19640 vat_main_t *vam = &vat_main;
19641 vat_json_node_t node;
19643 vat_json_init_object (&node);
19644 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
19645 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
19647 vat_json_print (vam->ofp, &node);
19648 vat_json_free (&node);
19650 vam->result_ready = 1;
19654 api_ipfix_classify_table_dump (vat_main_t * vam)
19656 vl_api_ipfix_classify_table_dump_t *mp;
19657 vl_api_control_ping_t *mp_ping;
19660 if (!vam->json_output)
19662 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
19663 "transport_protocol");
19666 /* Construct the API message */
19667 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
19672 /* Use a control ping for synchronization */
19673 MPING (CONTROL_PING, mp_ping);
19681 vl_api_ipfix_classify_table_details_t_handler
19682 (vl_api_ipfix_classify_table_details_t * mp)
19684 vat_main_t *vam = &vat_main;
19685 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
19686 mp->transport_protocol);
19690 vl_api_ipfix_classify_table_details_t_handler_json
19691 (vl_api_ipfix_classify_table_details_t * mp)
19693 vat_json_node_t *node = NULL;
19694 vat_main_t *vam = &vat_main;
19696 if (VAT_JSON_ARRAY != vam->json_tree.type)
19698 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19699 vat_json_init_array (&vam->json_tree);
19702 node = vat_json_array_add (&vam->json_tree);
19703 vat_json_init_object (node);
19705 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
19706 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
19707 vat_json_object_add_uint (node, "transport_protocol",
19708 mp->transport_protocol);
19712 api_sw_interface_span_enable_disable (vat_main_t * vam)
19714 unformat_input_t *i = vam->input;
19715 vl_api_sw_interface_span_enable_disable_t *mp;
19716 u32 src_sw_if_index = ~0;
19717 u32 dst_sw_if_index = ~0;
19722 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19725 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
19727 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
19731 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
19733 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
19735 else if (unformat (i, "disable"))
19737 else if (unformat (i, "rx"))
19739 else if (unformat (i, "tx"))
19741 else if (unformat (i, "both"))
19743 else if (unformat (i, "l2"))
19749 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
19751 mp->sw_if_index_from = htonl (src_sw_if_index);
19752 mp->sw_if_index_to = htonl (dst_sw_if_index);
19762 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
19765 vat_main_t *vam = &vat_main;
19766 u8 *sw_if_from_name = 0;
19767 u8 *sw_if_to_name = 0;
19768 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19769 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19770 char *states[] = { "none", "rx", "tx", "both" };
19774 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19776 if ((u32) p->value[0] == sw_if_index_from)
19778 sw_if_from_name = (u8 *)(p->key);
19782 if ((u32) p->value[0] == sw_if_index_to)
19784 sw_if_to_name = (u8 *)(p->key);
19785 if (sw_if_from_name)
19790 print (vam->ofp, "%20s => %20s (%s) %s",
19791 sw_if_from_name, sw_if_to_name, states[mp->state],
19792 mp->is_l2 ? "l2" : "device");
19796 vl_api_sw_interface_span_details_t_handler_json
19797 (vl_api_sw_interface_span_details_t * mp)
19799 vat_main_t *vam = &vat_main;
19800 vat_json_node_t *node = NULL;
19801 u8 *sw_if_from_name = 0;
19802 u8 *sw_if_to_name = 0;
19803 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19804 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19808 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19810 if ((u32) p->value[0] == sw_if_index_from)
19812 sw_if_from_name = (u8 *)(p->key);
19816 if ((u32) p->value[0] == sw_if_index_to)
19818 sw_if_to_name = (u8 *)(p->key);
19819 if (sw_if_from_name)
19825 if (VAT_JSON_ARRAY != vam->json_tree.type)
19827 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19828 vat_json_init_array (&vam->json_tree);
19830 node = vat_json_array_add (&vam->json_tree);
19832 vat_json_init_object (node);
19833 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
19834 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
19835 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
19836 if (0 != sw_if_to_name)
19838 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
19840 vat_json_object_add_uint (node, "state", mp->state);
19841 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
19845 api_sw_interface_span_dump (vat_main_t * vam)
19847 unformat_input_t *input = vam->input;
19848 vl_api_sw_interface_span_dump_t *mp;
19849 vl_api_control_ping_t *mp_ping;
19853 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19855 if (unformat (input, "l2"))
19861 M (SW_INTERFACE_SPAN_DUMP, mp);
19865 /* Use a control ping for synchronization */
19866 MPING (CONTROL_PING, mp_ping);
19874 api_pg_create_interface (vat_main_t * vam)
19876 unformat_input_t *input = vam->input;
19877 vl_api_pg_create_interface_t *mp;
19881 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19883 if (unformat (input, "if_id %d", &if_id))
19890 errmsg ("missing pg interface index");
19894 /* Construct the API message */
19895 M (PG_CREATE_INTERFACE, mp);
19897 mp->interface_id = ntohl (if_id);
19905 api_pg_capture (vat_main_t * vam)
19907 unformat_input_t *input = vam->input;
19908 vl_api_pg_capture_t *mp;
19913 u8 pcap_file_set = 0;
19916 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19918 if (unformat (input, "if_id %d", &if_id))
19920 else if (unformat (input, "pcap %s", &pcap_file))
19922 else if (unformat (input, "count %d", &count))
19924 else if (unformat (input, "disable"))
19931 errmsg ("missing pg interface index");
19934 if (pcap_file_set > 0)
19936 if (vec_len (pcap_file) > 255)
19938 errmsg ("pcap file name is too long");
19943 u32 name_len = vec_len (pcap_file);
19944 /* Construct the API message */
19945 M (PG_CAPTURE, mp);
19947 mp->interface_id = ntohl (if_id);
19948 mp->is_enabled = enable;
19949 mp->count = ntohl (count);
19950 mp->pcap_name_length = ntohl (name_len);
19951 if (pcap_file_set != 0)
19953 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
19955 vec_free (pcap_file);
19963 api_pg_enable_disable (vat_main_t * vam)
19965 unformat_input_t *input = vam->input;
19966 vl_api_pg_enable_disable_t *mp;
19969 u8 stream_name_set = 0;
19970 u8 *stream_name = 0;
19972 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19974 if (unformat (input, "stream %s", &stream_name))
19975 stream_name_set = 1;
19976 else if (unformat (input, "disable"))
19982 if (stream_name_set > 0)
19984 if (vec_len (stream_name) > 255)
19986 errmsg ("stream name too long");
19991 u32 name_len = vec_len (stream_name);
19992 /* Construct the API message */
19993 M (PG_ENABLE_DISABLE, mp);
19995 mp->is_enabled = enable;
19996 if (stream_name_set != 0)
19998 mp->stream_name_length = ntohl (name_len);
19999 clib_memcpy (mp->stream_name, stream_name, name_len);
20001 vec_free (stream_name);
20009 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
20011 unformat_input_t *input = vam->input;
20012 vl_api_ip_source_and_port_range_check_add_del_t *mp;
20014 u16 *low_ports = 0;
20015 u16 *high_ports = 0;
20018 vl_api_prefix_t prefix;
20025 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20027 if (unformat (input, "%U", unformat_vl_api_prefix, &prefix))
20029 else if (unformat (input, "vrf %d", &vrf_id))
20031 else if (unformat (input, "del"))
20033 else if (unformat (input, "port %d", &tmp))
20035 if (tmp == 0 || tmp > 65535)
20037 errmsg ("port %d out of range", tmp);
20041 this_hi = this_low + 1;
20042 vec_add1 (low_ports, this_low);
20043 vec_add1 (high_ports, this_hi);
20045 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
20047 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
20049 errmsg ("incorrect range parameters");
20053 /* Note: in debug CLI +1 is added to high before
20054 passing to real fn that does "the work"
20055 (ip_source_and_port_range_check_add_del).
20056 This fn is a wrapper around the binary API fn a
20057 control plane will call, which expects this increment
20058 to have occurred. Hence letting the binary API control
20059 plane fn do the increment for consistency between VAT
20060 and other control planes.
20063 vec_add1 (low_ports, this_low);
20064 vec_add1 (high_ports, this_hi);
20070 if (prefix_set == 0)
20072 errmsg ("<address>/<mask> not specified");
20078 errmsg ("VRF ID required, not specified");
20085 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
20089 if (vec_len (low_ports) == 0)
20091 errmsg ("At least one port or port range required");
20095 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
20097 mp->is_add = is_add;
20099 clib_memcpy (&mp->prefix, &prefix, sizeof (prefix));
20101 mp->number_of_ranges = vec_len (low_ports);
20103 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
20104 vec_free (low_ports);
20106 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
20107 vec_free (high_ports);
20109 mp->vrf_id = ntohl (vrf_id);
20117 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
20119 unformat_input_t *input = vam->input;
20120 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
20121 u32 sw_if_index = ~0;
20123 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
20124 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
20128 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20130 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20132 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20134 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
20136 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
20138 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
20140 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
20142 else if (unformat (input, "del"))
20148 if (sw_if_index == ~0)
20150 errmsg ("Interface required but not specified");
20156 errmsg ("VRF ID required but not specified");
20160 if (tcp_out_vrf_id == 0
20161 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
20164 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
20168 /* Construct the API message */
20169 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
20171 mp->sw_if_index = ntohl (sw_if_index);
20172 mp->is_add = is_add;
20173 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
20174 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
20175 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
20176 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
20181 /* Wait for a reply... */
20187 api_ipsec_gre_tunnel_add_del (vat_main_t * vam)
20189 unformat_input_t *i = vam->input;
20190 vl_api_ipsec_gre_tunnel_add_del_t *mp;
20191 u32 local_sa_id = 0;
20192 u32 remote_sa_id = 0;
20193 vl_api_ip4_address_t src_address;
20194 vl_api_ip4_address_t dst_address;
20198 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20200 if (unformat (i, "local_sa %d", &local_sa_id))
20202 else if (unformat (i, "remote_sa %d", &remote_sa_id))
20205 if (unformat (i, "src %U", unformat_vl_api_ip4_address, &src_address))
20208 if (unformat (i, "dst %U", unformat_vl_api_ip4_address, &dst_address))
20210 else if (unformat (i, "del"))
20214 clib_warning ("parse error '%U'", format_unformat_error, i);
20219 M (IPSEC_GRE_TUNNEL_ADD_DEL, mp);
20221 mp->tunnel.local_sa_id = ntohl (local_sa_id);
20222 mp->tunnel.remote_sa_id = ntohl (remote_sa_id);
20223 clib_memcpy (mp->tunnel.src, &src_address, sizeof (src_address));
20224 clib_memcpy (mp->tunnel.dst, &dst_address, sizeof (dst_address));
20225 mp->is_add = is_add;
20233 api_set_punt (vat_main_t * vam)
20235 unformat_input_t *i = vam->input;
20236 vl_api_address_family_t af;
20237 vl_api_set_punt_t *mp;
20243 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20245 if (unformat (i, "%U", unformat_vl_api_address_family, &af))
20247 else if (unformat (i, "protocol %d", &protocol))
20249 else if (unformat (i, "port %d", &port))
20251 else if (unformat (i, "del"))
20255 clib_warning ("parse error '%U'", format_unformat_error, i);
20262 mp->is_add = (u8) is_add;
20263 mp->punt.type = PUNT_API_TYPE_L4;
20264 mp->punt.punt.l4.af = af;
20265 mp->punt.punt.l4.protocol = (u8) protocol;
20266 mp->punt.punt.l4.port = htons ((u16) port);
20273 static void vl_api_ipsec_gre_tunnel_details_t_handler
20274 (vl_api_ipsec_gre_tunnel_details_t * mp)
20276 vat_main_t *vam = &vat_main;
20278 print (vam->ofp, "%11d%15U%15U%14d%14d",
20279 ntohl (mp->tunnel.sw_if_index),
20280 format_vl_api_ip4_address, mp->tunnel.src,
20281 format_vl_api_ip4_address, mp->tunnel.dst,
20282 ntohl (mp->tunnel.local_sa_id), ntohl (mp->tunnel.remote_sa_id));
20286 vat_json_object_add_vl_api_ip4 (vat_json_node_t * node,
20288 const vl_api_ip4_address_t addr)
20290 struct in_addr ip4;
20292 clib_memcpy (&ip4, addr, sizeof (ip4));
20293 vat_json_object_add_ip4 (node, name, ip4);
20296 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
20297 (vl_api_ipsec_gre_tunnel_details_t * mp)
20299 vat_main_t *vam = &vat_main;
20300 vat_json_node_t *node = NULL;
20302 if (VAT_JSON_ARRAY != vam->json_tree.type)
20304 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20305 vat_json_init_array (&vam->json_tree);
20307 node = vat_json_array_add (&vam->json_tree);
20309 vat_json_init_object (node);
20310 vat_json_object_add_uint (node, "sw_if_index",
20311 ntohl (mp->tunnel.sw_if_index));
20312 vat_json_object_add_vl_api_ip4 (node, "src", mp->tunnel.src);
20313 vat_json_object_add_vl_api_ip4 (node, "src", mp->tunnel.dst);
20314 vat_json_object_add_uint (node, "local_sa_id",
20315 ntohl (mp->tunnel.local_sa_id));
20316 vat_json_object_add_uint (node, "remote_sa_id",
20317 ntohl (mp->tunnel.remote_sa_id));
20321 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
20323 unformat_input_t *i = vam->input;
20324 vl_api_ipsec_gre_tunnel_dump_t *mp;
20325 vl_api_control_ping_t *mp_ping;
20327 u8 sw_if_index_set = 0;
20330 /* Parse args required to build the message */
20331 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20333 if (unformat (i, "sw_if_index %d", &sw_if_index))
20334 sw_if_index_set = 1;
20339 if (sw_if_index_set == 0)
20344 if (!vam->json_output)
20346 print (vam->ofp, "%11s%15s%15s%14s%14s",
20347 "sw_if_index", "src_address", "dst_address",
20348 "local_sa_id", "remote_sa_id");
20351 /* Get list of gre-tunnel interfaces */
20352 M (IPSEC_GRE_TUNNEL_DUMP, mp);
20354 mp->sw_if_index = htonl (sw_if_index);
20358 /* Use a control ping for synchronization */
20359 MPING (CONTROL_PING, mp_ping);
20367 api_delete_subif (vat_main_t * vam)
20369 unformat_input_t *i = vam->input;
20370 vl_api_delete_subif_t *mp;
20371 u32 sw_if_index = ~0;
20374 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20376 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20378 if (unformat (i, "sw_if_index %d", &sw_if_index))
20384 if (sw_if_index == ~0)
20386 errmsg ("missing sw_if_index");
20390 /* Construct the API message */
20391 M (DELETE_SUBIF, mp);
20392 mp->sw_if_index = ntohl (sw_if_index);
20399 #define foreach_pbb_vtr_op \
20400 _("disable", L2_VTR_DISABLED) \
20401 _("pop", L2_VTR_POP_2) \
20402 _("push", L2_VTR_PUSH_2)
20405 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
20407 unformat_input_t *i = vam->input;
20408 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
20409 u32 sw_if_index = ~0, vtr_op = ~0;
20410 u16 outer_tag = ~0;
20411 u8 dmac[6], smac[6];
20412 u8 dmac_set = 0, smac_set = 0;
20418 /* Shut up coverity */
20419 clib_memset (dmac, 0, sizeof (dmac));
20420 clib_memset (smac, 0, sizeof (smac));
20422 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20424 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20426 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20428 else if (unformat (i, "vtr_op %d", &vtr_op))
20430 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
20433 else if (unformat (i, "translate_pbb_stag"))
20435 if (unformat (i, "%d", &tmp))
20437 vtr_op = L2_VTR_TRANSLATE_2_1;
20443 ("translate_pbb_stag operation requires outer tag definition");
20447 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
20449 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
20451 else if (unformat (i, "sid %d", &sid))
20453 else if (unformat (i, "vlanid %d", &tmp))
20457 clib_warning ("parse error '%U'", format_unformat_error, i);
20462 if ((sw_if_index == ~0) || (vtr_op == ~0))
20464 errmsg ("missing sw_if_index or vtr operation");
20467 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
20468 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
20471 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
20475 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
20476 mp->sw_if_index = ntohl (sw_if_index);
20477 mp->vtr_op = ntohl (vtr_op);
20478 mp->outer_tag = ntohs (outer_tag);
20479 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
20480 clib_memcpy (mp->b_smac, smac, sizeof (smac));
20481 mp->b_vlanid = ntohs (vlanid);
20482 mp->i_sid = ntohl (sid);
20490 api_flow_classify_set_interface (vat_main_t * vam)
20492 unformat_input_t *i = vam->input;
20493 vl_api_flow_classify_set_interface_t *mp;
20495 int sw_if_index_set;
20496 u32 ip4_table_index = ~0;
20497 u32 ip6_table_index = ~0;
20501 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20503 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20504 sw_if_index_set = 1;
20505 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20506 sw_if_index_set = 1;
20507 else if (unformat (i, "del"))
20509 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20511 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20515 clib_warning ("parse error '%U'", format_unformat_error, i);
20520 if (sw_if_index_set == 0)
20522 errmsg ("missing interface name or sw_if_index");
20526 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
20528 mp->sw_if_index = ntohl (sw_if_index);
20529 mp->ip4_table_index = ntohl (ip4_table_index);
20530 mp->ip6_table_index = ntohl (ip6_table_index);
20531 mp->is_add = is_add;
20539 api_flow_classify_dump (vat_main_t * vam)
20541 unformat_input_t *i = vam->input;
20542 vl_api_flow_classify_dump_t *mp;
20543 vl_api_control_ping_t *mp_ping;
20544 u8 type = FLOW_CLASSIFY_N_TABLES;
20547 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
20551 errmsg ("classify table type must be specified");
20555 if (!vam->json_output)
20557 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20560 M (FLOW_CLASSIFY_DUMP, mp);
20565 /* Use a control ping for synchronization */
20566 MPING (CONTROL_PING, mp_ping);
20569 /* Wait for a reply... */
20575 api_feature_enable_disable (vat_main_t * vam)
20577 unformat_input_t *i = vam->input;
20578 vl_api_feature_enable_disable_t *mp;
20580 u8 *feature_name = 0;
20581 u32 sw_if_index = ~0;
20585 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20587 if (unformat (i, "arc_name %s", &arc_name))
20589 else if (unformat (i, "feature_name %s", &feature_name))
20592 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20594 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20596 else if (unformat (i, "disable"))
20604 errmsg ("missing arc name");
20607 if (vec_len (arc_name) > 63)
20609 errmsg ("arc name too long");
20612 if (feature_name == 0)
20614 errmsg ("missing feature name");
20617 if (vec_len (feature_name) > 63)
20619 errmsg ("feature name too long");
20622 if (sw_if_index == ~0)
20624 errmsg ("missing interface name or sw_if_index");
20628 /* Construct the API message */
20629 M (FEATURE_ENABLE_DISABLE, mp);
20630 mp->sw_if_index = ntohl (sw_if_index);
20631 mp->enable = enable;
20632 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
20633 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
20634 vec_free (arc_name);
20635 vec_free (feature_name);
20643 api_sw_interface_tag_add_del (vat_main_t * vam)
20645 unformat_input_t *i = vam->input;
20646 vl_api_sw_interface_tag_add_del_t *mp;
20647 u32 sw_if_index = ~0;
20652 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20654 if (unformat (i, "tag %s", &tag))
20656 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20658 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20660 else if (unformat (i, "del"))
20666 if (sw_if_index == ~0)
20668 errmsg ("missing interface name or sw_if_index");
20672 if (enable && (tag == 0))
20674 errmsg ("no tag specified");
20678 /* Construct the API message */
20679 M (SW_INTERFACE_TAG_ADD_DEL, mp);
20680 mp->sw_if_index = ntohl (sw_if_index);
20681 mp->is_add = enable;
20683 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
20691 static void vl_api_l2_xconnect_details_t_handler
20692 (vl_api_l2_xconnect_details_t * mp)
20694 vat_main_t *vam = &vat_main;
20696 print (vam->ofp, "%15d%15d",
20697 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
20700 static void vl_api_l2_xconnect_details_t_handler_json
20701 (vl_api_l2_xconnect_details_t * mp)
20703 vat_main_t *vam = &vat_main;
20704 vat_json_node_t *node = NULL;
20706 if (VAT_JSON_ARRAY != vam->json_tree.type)
20708 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20709 vat_json_init_array (&vam->json_tree);
20711 node = vat_json_array_add (&vam->json_tree);
20713 vat_json_init_object (node);
20714 vat_json_object_add_uint (node, "rx_sw_if_index",
20715 ntohl (mp->rx_sw_if_index));
20716 vat_json_object_add_uint (node, "tx_sw_if_index",
20717 ntohl (mp->tx_sw_if_index));
20721 api_l2_xconnect_dump (vat_main_t * vam)
20723 vl_api_l2_xconnect_dump_t *mp;
20724 vl_api_control_ping_t *mp_ping;
20727 if (!vam->json_output)
20729 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
20732 M (L2_XCONNECT_DUMP, mp);
20736 /* Use a control ping for synchronization */
20737 MPING (CONTROL_PING, mp_ping);
20745 api_hw_interface_set_mtu (vat_main_t * vam)
20747 unformat_input_t *i = vam->input;
20748 vl_api_hw_interface_set_mtu_t *mp;
20749 u32 sw_if_index = ~0;
20753 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20755 if (unformat (i, "mtu %d", &mtu))
20757 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20759 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20765 if (sw_if_index == ~0)
20767 errmsg ("missing interface name or sw_if_index");
20773 errmsg ("no mtu specified");
20777 /* Construct the API message */
20778 M (HW_INTERFACE_SET_MTU, mp);
20779 mp->sw_if_index = ntohl (sw_if_index);
20780 mp->mtu = ntohs ((u16) mtu);
20788 api_p2p_ethernet_add (vat_main_t * vam)
20790 unformat_input_t *i = vam->input;
20791 vl_api_p2p_ethernet_add_t *mp;
20792 u32 parent_if_index = ~0;
20798 clib_memset (remote_mac, 0, sizeof (remote_mac));
20799 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20801 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20803 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20807 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20809 else if (unformat (i, "sub_id %d", &sub_id))
20813 clib_warning ("parse error '%U'", format_unformat_error, i);
20818 if (parent_if_index == ~0)
20820 errmsg ("missing interface name or sw_if_index");
20825 errmsg ("missing remote mac address");
20830 errmsg ("missing sub-interface id");
20834 M (P2P_ETHERNET_ADD, mp);
20835 mp->parent_if_index = ntohl (parent_if_index);
20836 mp->subif_id = ntohl (sub_id);
20837 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20845 api_p2p_ethernet_del (vat_main_t * vam)
20847 unformat_input_t *i = vam->input;
20848 vl_api_p2p_ethernet_del_t *mp;
20849 u32 parent_if_index = ~0;
20854 clib_memset (remote_mac, 0, sizeof (remote_mac));
20855 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20857 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20859 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20863 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20867 clib_warning ("parse error '%U'", format_unformat_error, i);
20872 if (parent_if_index == ~0)
20874 errmsg ("missing interface name or sw_if_index");
20879 errmsg ("missing remote mac address");
20883 M (P2P_ETHERNET_DEL, mp);
20884 mp->parent_if_index = ntohl (parent_if_index);
20885 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20893 api_lldp_config (vat_main_t * vam)
20895 unformat_input_t *i = vam->input;
20896 vl_api_lldp_config_t *mp;
20898 int tx_interval = 0;
20899 u8 *sys_name = NULL;
20902 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20904 if (unformat (i, "system-name %s", &sys_name))
20906 else if (unformat (i, "tx-hold %d", &tx_hold))
20908 else if (unformat (i, "tx-interval %d", &tx_interval))
20912 clib_warning ("parse error '%U'", format_unformat_error, i);
20917 vec_add1 (sys_name, 0);
20919 M (LLDP_CONFIG, mp);
20920 mp->tx_hold = htonl (tx_hold);
20921 mp->tx_interval = htonl (tx_interval);
20922 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
20923 vec_free (sys_name);
20931 api_sw_interface_set_lldp (vat_main_t * vam)
20933 unformat_input_t *i = vam->input;
20934 vl_api_sw_interface_set_lldp_t *mp;
20935 u32 sw_if_index = ~0;
20937 u8 *port_desc = NULL, *mgmt_oid = NULL;
20938 ip4_address_t ip4_addr;
20939 ip6_address_t ip6_addr;
20942 clib_memset (&ip4_addr, 0, sizeof (ip4_addr));
20943 clib_memset (&ip6_addr, 0, sizeof (ip6_addr));
20945 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20947 if (unformat (i, "disable"))
20950 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20952 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20954 else if (unformat (i, "port-desc %s", &port_desc))
20956 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
20958 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
20960 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
20966 if (sw_if_index == ~0)
20968 errmsg ("missing interface name or sw_if_index");
20972 /* Construct the API message */
20973 vec_add1 (port_desc, 0);
20974 vec_add1 (mgmt_oid, 0);
20975 M (SW_INTERFACE_SET_LLDP, mp);
20976 mp->sw_if_index = ntohl (sw_if_index);
20977 mp->enable = enable;
20978 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
20979 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
20980 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
20981 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
20982 vec_free (port_desc);
20983 vec_free (mgmt_oid);
20991 api_tcp_configure_src_addresses (vat_main_t * vam)
20993 vl_api_tcp_configure_src_addresses_t *mp;
20994 unformat_input_t *i = vam->input;
20995 ip4_address_t v4first, v4last;
20996 ip6_address_t v6first, v6last;
21001 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21003 if (unformat (i, "%U - %U",
21004 unformat_ip4_address, &v4first,
21005 unformat_ip4_address, &v4last))
21009 errmsg ("one range per message (range already set)");
21014 else if (unformat (i, "%U - %U",
21015 unformat_ip6_address, &v6first,
21016 unformat_ip6_address, &v6last))
21020 errmsg ("one range per message (range already set)");
21025 else if (unformat (i, "vrf %d", &vrf_id))
21031 if (range_set == 0)
21033 errmsg ("address range not set");
21037 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
21038 mp->vrf_id = ntohl (vrf_id);
21040 if (range_set == 2)
21043 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
21044 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
21049 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
21050 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
21057 static void vl_api_app_namespace_add_del_reply_t_handler
21058 (vl_api_app_namespace_add_del_reply_t * mp)
21060 vat_main_t *vam = &vat_main;
21061 i32 retval = ntohl (mp->retval);
21062 if (vam->async_mode)
21064 vam->async_errors += (retval < 0);
21068 vam->retval = retval;
21070 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
21071 vam->result_ready = 1;
21075 static void vl_api_app_namespace_add_del_reply_t_handler_json
21076 (vl_api_app_namespace_add_del_reply_t * mp)
21078 vat_main_t *vam = &vat_main;
21079 vat_json_node_t node;
21081 vat_json_init_object (&node);
21082 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
21083 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
21085 vat_json_print (vam->ofp, &node);
21086 vat_json_free (&node);
21088 vam->retval = ntohl (mp->retval);
21089 vam->result_ready = 1;
21093 api_app_namespace_add_del (vat_main_t * vam)
21095 vl_api_app_namespace_add_del_t *mp;
21096 unformat_input_t *i = vam->input;
21097 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
21098 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
21102 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21104 if (unformat (i, "id %_%v%_", &ns_id))
21106 else if (unformat (i, "secret %lu", &secret))
21108 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21109 sw_if_index_set = 1;
21110 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
21112 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
21117 if (!ns_id || !secret_set || !sw_if_index_set)
21119 errmsg ("namespace id, secret and sw_if_index must be set");
21122 if (vec_len (ns_id) > 64)
21124 errmsg ("namespace id too long");
21127 M (APP_NAMESPACE_ADD_DEL, mp);
21129 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
21130 mp->namespace_id_len = vec_len (ns_id);
21131 mp->secret = clib_host_to_net_u64 (secret);
21132 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
21133 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
21134 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
21142 api_sock_init_shm (vat_main_t * vam)
21144 #if VPP_API_TEST_BUILTIN == 0
21145 unformat_input_t *i = vam->input;
21146 vl_api_shm_elem_config_t *config = 0;
21147 u64 size = 64 << 20;
21150 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21152 if (unformat (i, "size %U", unformat_memory_size, &size))
21159 * Canned custom ring allocator config.
21160 * Should probably parse all of this
21162 vec_validate (config, 6);
21163 config[0].type = VL_API_VLIB_RING;
21164 config[0].size = 256;
21165 config[0].count = 32;
21167 config[1].type = VL_API_VLIB_RING;
21168 config[1].size = 1024;
21169 config[1].count = 16;
21171 config[2].type = VL_API_VLIB_RING;
21172 config[2].size = 4096;
21173 config[2].count = 2;
21175 config[3].type = VL_API_CLIENT_RING;
21176 config[3].size = 256;
21177 config[3].count = 32;
21179 config[4].type = VL_API_CLIENT_RING;
21180 config[4].size = 1024;
21181 config[4].count = 16;
21183 config[5].type = VL_API_CLIENT_RING;
21184 config[5].size = 4096;
21185 config[5].count = 2;
21187 config[6].type = VL_API_QUEUE;
21188 config[6].count = 128;
21189 config[6].size = sizeof (uword);
21191 rv = vl_socket_client_init_shm (config, 1 /* want_pthread */ );
21193 vam->client_index_invalid = 1;
21201 api_dns_enable_disable (vat_main_t * vam)
21203 unformat_input_t *line_input = vam->input;
21204 vl_api_dns_enable_disable_t *mp;
21205 u8 enable_disable = 1;
21208 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21210 if (unformat (line_input, "disable"))
21211 enable_disable = 0;
21212 if (unformat (line_input, "enable"))
21213 enable_disable = 1;
21218 /* Construct the API message */
21219 M (DNS_ENABLE_DISABLE, mp);
21220 mp->enable = enable_disable;
21224 /* Wait for the reply */
21230 api_dns_resolve_name (vat_main_t * vam)
21232 unformat_input_t *line_input = vam->input;
21233 vl_api_dns_resolve_name_t *mp;
21237 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21239 if (unformat (line_input, "%s", &name))
21245 if (vec_len (name) > 127)
21247 errmsg ("name too long");
21251 /* Construct the API message */
21252 M (DNS_RESOLVE_NAME, mp);
21253 memcpy (mp->name, name, vec_len (name));
21258 /* Wait for the reply */
21264 api_dns_resolve_ip (vat_main_t * vam)
21266 unformat_input_t *line_input = vam->input;
21267 vl_api_dns_resolve_ip_t *mp;
21269 ip4_address_t addr4;
21270 ip6_address_t addr6;
21273 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21275 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
21277 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
21285 errmsg ("missing address");
21289 /* Construct the API message */
21290 M (DNS_RESOLVE_IP, mp);
21291 mp->is_ip6 = is_ip6;
21293 memcpy (mp->address, &addr6, sizeof (addr6));
21295 memcpy (mp->address, &addr4, sizeof (addr4));
21299 /* Wait for the reply */
21305 api_dns_name_server_add_del (vat_main_t * vam)
21307 unformat_input_t *i = vam->input;
21308 vl_api_dns_name_server_add_del_t *mp;
21310 ip6_address_t ip6_server;
21311 ip4_address_t ip4_server;
21316 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21318 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
21320 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
21322 else if (unformat (i, "del"))
21326 clib_warning ("parse error '%U'", format_unformat_error, i);
21331 if (ip4_set && ip6_set)
21333 errmsg ("Only one server address allowed per message");
21336 if ((ip4_set + ip6_set) == 0)
21338 errmsg ("Server address required");
21342 /* Construct the API message */
21343 M (DNS_NAME_SERVER_ADD_DEL, mp);
21347 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
21352 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
21356 mp->is_add = is_add;
21361 /* Wait for a reply, return good/bad news */
21367 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
21369 vat_main_t *vam = &vat_main;
21374 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
21375 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
21376 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
21377 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
21378 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
21379 clib_net_to_host_u32 (mp->action_index), mp->tag);
21384 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
21385 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
21386 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
21387 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
21388 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
21389 clib_net_to_host_u32 (mp->action_index), mp->tag);
21394 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
21397 vat_main_t *vam = &vat_main;
21398 vat_json_node_t *node = NULL;
21399 struct in6_addr ip6;
21400 struct in_addr ip4;
21402 if (VAT_JSON_ARRAY != vam->json_tree.type)
21404 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21405 vat_json_init_array (&vam->json_tree);
21407 node = vat_json_array_add (&vam->json_tree);
21408 vat_json_init_object (node);
21410 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
21411 vat_json_object_add_uint (node, "appns_index",
21412 clib_net_to_host_u32 (mp->appns_index));
21413 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
21414 vat_json_object_add_uint (node, "scope", mp->scope);
21415 vat_json_object_add_uint (node, "action_index",
21416 clib_net_to_host_u32 (mp->action_index));
21417 vat_json_object_add_uint (node, "lcl_port",
21418 clib_net_to_host_u16 (mp->lcl_port));
21419 vat_json_object_add_uint (node, "rmt_port",
21420 clib_net_to_host_u16 (mp->rmt_port));
21421 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
21422 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
21423 vat_json_object_add_string_copy (node, "tag", mp->tag);
21426 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
21427 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
21428 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
21429 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
21433 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
21434 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
21435 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
21436 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
21441 api_session_rule_add_del (vat_main_t * vam)
21443 vl_api_session_rule_add_del_t *mp;
21444 unformat_input_t *i = vam->input;
21445 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
21446 u32 appns_index = 0, scope = 0;
21447 ip4_address_t lcl_ip4, rmt_ip4;
21448 ip6_address_t lcl_ip6, rmt_ip6;
21449 u8 is_ip4 = 1, conn_set = 0;
21450 u8 is_add = 1, *tag = 0;
21453 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21455 if (unformat (i, "del"))
21457 else if (unformat (i, "add"))
21459 else if (unformat (i, "proto tcp"))
21461 else if (unformat (i, "proto udp"))
21463 else if (unformat (i, "appns %d", &appns_index))
21465 else if (unformat (i, "scope %d", &scope))
21467 else if (unformat (i, "tag %_%v%_", &tag))
21471 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
21472 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
21480 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
21481 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
21487 else if (unformat (i, "action %d", &action))
21492 if (proto == ~0 || !conn_set || action == ~0)
21494 errmsg ("transport proto, connection and action must be set");
21500 errmsg ("scope should be 0-3");
21504 M (SESSION_RULE_ADD_DEL, mp);
21506 mp->is_ip4 = is_ip4;
21507 mp->transport_proto = proto;
21508 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
21509 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
21510 mp->lcl_plen = lcl_plen;
21511 mp->rmt_plen = rmt_plen;
21512 mp->action_index = clib_host_to_net_u32 (action);
21513 mp->appns_index = clib_host_to_net_u32 (appns_index);
21515 mp->is_add = is_add;
21518 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
21519 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
21523 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
21524 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
21528 clib_memcpy (mp->tag, tag, vec_len (tag));
21538 api_session_rules_dump (vat_main_t * vam)
21540 vl_api_session_rules_dump_t *mp;
21541 vl_api_control_ping_t *mp_ping;
21544 if (!vam->json_output)
21546 print (vam->ofp, "%=20s", "Session Rules");
21549 M (SESSION_RULES_DUMP, mp);
21553 /* Use a control ping for synchronization */
21554 MPING (CONTROL_PING, mp_ping);
21557 /* Wait for a reply... */
21563 api_ip_container_proxy_add_del (vat_main_t * vam)
21565 vl_api_ip_container_proxy_add_del_t *mp;
21566 unformat_input_t *i = vam->input;
21567 u32 sw_if_index = ~0;
21568 vl_api_prefix_t pfx = { };
21572 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21574 if (unformat (i, "del"))
21576 else if (unformat (i, "add"))
21578 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
21580 else if (unformat (i, "sw_if_index %u", &sw_if_index))
21585 if (sw_if_index == ~0 || pfx.address_length == 0)
21587 errmsg ("address and sw_if_index must be set");
21591 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
21593 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
21594 mp->is_add = is_add;
21595 clib_memcpy (&mp->pfx, &pfx, sizeof (pfx));
21603 api_qos_record_enable_disable (vat_main_t * vam)
21605 unformat_input_t *i = vam->input;
21606 vl_api_qos_record_enable_disable_t *mp;
21607 u32 sw_if_index, qs = 0xff;
21608 u8 sw_if_index_set = 0;
21612 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21614 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21615 sw_if_index_set = 1;
21616 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21617 sw_if_index_set = 1;
21618 else if (unformat (i, "%U", unformat_qos_source, &qs))
21620 else if (unformat (i, "disable"))
21624 clib_warning ("parse error '%U'", format_unformat_error, i);
21629 if (sw_if_index_set == 0)
21631 errmsg ("missing interface name or sw_if_index");
21636 errmsg ("input location must be specified");
21640 M (QOS_RECORD_ENABLE_DISABLE, mp);
21642 mp->sw_if_index = ntohl (sw_if_index);
21643 mp->input_source = qs;
21644 mp->enable = enable;
21653 q_or_quit (vat_main_t * vam)
21655 #if VPP_API_TEST_BUILTIN == 0
21656 longjmp (vam->jump_buf, 1);
21658 return 0; /* not so much */
21662 q (vat_main_t * vam)
21664 return q_or_quit (vam);
21668 quit (vat_main_t * vam)
21670 return q_or_quit (vam);
21674 comment (vat_main_t * vam)
21680 statseg (vat_main_t * vam)
21682 ssvm_private_t *ssvmp = &vam->stat_segment;
21683 ssvm_shared_header_t *shared_header = ssvmp->sh;
21684 vlib_counter_t **counters;
21685 u64 thread0_index1_packets;
21686 u64 thread0_index1_bytes;
21687 f64 vector_rate, input_rate;
21690 uword *counter_vector_by_name;
21691 if (vam->stat_segment_lockp == 0)
21693 errmsg ("Stat segment not mapped...");
21697 /* look up "/if/rx for sw_if_index 1 as a test */
21699 clib_spinlock_lock (vam->stat_segment_lockp);
21701 counter_vector_by_name = (uword *) shared_header->opaque[1];
21703 p = hash_get_mem (counter_vector_by_name, "/if/rx");
21706 clib_spinlock_unlock (vam->stat_segment_lockp);
21707 errmsg ("/if/tx not found?");
21711 /* Fish per-thread vector of combined counters from shared memory */
21712 counters = (vlib_counter_t **) p[0];
21714 if (vec_len (counters[0]) < 2)
21716 clib_spinlock_unlock (vam->stat_segment_lockp);
21717 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
21721 /* Read thread 0 sw_if_index 1 counter */
21722 thread0_index1_packets = counters[0][1].packets;
21723 thread0_index1_bytes = counters[0][1].bytes;
21725 p = hash_get_mem (counter_vector_by_name, "vector_rate");
21728 clib_spinlock_unlock (vam->stat_segment_lockp);
21729 errmsg ("vector_rate not found?");
21733 vector_rate = *(f64 *) (p[0]);
21734 p = hash_get_mem (counter_vector_by_name, "input_rate");
21737 clib_spinlock_unlock (vam->stat_segment_lockp);
21738 errmsg ("input_rate not found?");
21741 input_rate = *(f64 *) (p[0]);
21743 clib_spinlock_unlock (vam->stat_segment_lockp);
21745 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
21746 vector_rate, input_rate);
21747 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
21748 thread0_index1_packets, thread0_index1_bytes);
21754 cmd_cmp (void *a1, void *a2)
21759 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
21763 help (vat_main_t * vam)
21768 unformat_input_t *i = vam->input;
21771 if (unformat (i, "%s", &name))
21775 vec_add1 (name, 0);
21777 hs = hash_get_mem (vam->help_by_name, name);
21779 print (vam->ofp, "usage: %s %s", name, hs[0]);
21781 print (vam->ofp, "No such msg / command '%s'", name);
21786 print (vam->ofp, "Help is available for the following:");
21789 hash_foreach_pair (p, vam->function_by_name,
21791 vec_add1 (cmds, (u8 *)(p->key));
21795 vec_sort_with_function (cmds, cmd_cmp);
21797 for (j = 0; j < vec_len (cmds); j++)
21798 print (vam->ofp, "%s", cmds[j]);
21805 set (vat_main_t * vam)
21807 u8 *name = 0, *value = 0;
21808 unformat_input_t *i = vam->input;
21810 if (unformat (i, "%s", &name))
21812 /* The input buffer is a vector, not a string. */
21813 value = vec_dup (i->buffer);
21814 vec_delete (value, i->index, 0);
21815 /* Almost certainly has a trailing newline */
21816 if (value[vec_len (value) - 1] == '\n')
21817 value[vec_len (value) - 1] = 0;
21818 /* Make sure it's a proper string, one way or the other */
21819 vec_add1 (value, 0);
21820 (void) clib_macro_set_value (&vam->macro_main,
21821 (char *) name, (char *) value);
21824 errmsg ("usage: set <name> <value>");
21832 unset (vat_main_t * vam)
21836 if (unformat (vam->input, "%s", &name))
21837 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
21838 errmsg ("unset: %s wasn't set", name);
21851 macro_sort_cmp (void *a1, void *a2)
21853 macro_sort_t *s1 = a1;
21854 macro_sort_t *s2 = a2;
21856 return strcmp ((char *) (s1->name), (char *) (s2->name));
21860 dump_macro_table (vat_main_t * vam)
21862 macro_sort_t *sort_me = 0, *sm;
21867 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
21869 vec_add2 (sort_me, sm, 1);
21870 sm->name = (u8 *)(p->key);
21871 sm->value = (u8 *) (p->value[0]);
21875 vec_sort_with_function (sort_me, macro_sort_cmp);
21877 if (vec_len (sort_me))
21878 print (vam->ofp, "%-15s%s", "Name", "Value");
21880 print (vam->ofp, "The macro table is empty...");
21882 for (i = 0; i < vec_len (sort_me); i++)
21883 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
21888 dump_node_table (vat_main_t * vam)
21891 vlib_node_t *node, *next_node;
21893 if (vec_len (vam->graph_nodes) == 0)
21895 print (vam->ofp, "Node table empty, issue get_node_graph...");
21899 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
21901 node = vam->graph_nodes[0][i];
21902 print (vam->ofp, "[%d] %s", i, node->name);
21903 for (j = 0; j < vec_len (node->next_nodes); j++)
21905 if (node->next_nodes[j] != ~0)
21907 next_node = vam->graph_nodes[0][node->next_nodes[j]];
21908 print (vam->ofp, " [%d] %s", j, next_node->name);
21916 value_sort_cmp (void *a1, void *a2)
21918 name_sort_t *n1 = a1;
21919 name_sort_t *n2 = a2;
21921 if (n1->value < n2->value)
21923 if (n1->value > n2->value)
21930 dump_msg_api_table (vat_main_t * vam)
21932 api_main_t *am = &api_main;
21933 name_sort_t *nses = 0, *ns;
21938 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
21940 vec_add2 (nses, ns, 1);
21941 ns->name = (u8 *)(hp->key);
21942 ns->value = (u32) hp->value[0];
21946 vec_sort_with_function (nses, value_sort_cmp);
21948 for (i = 0; i < vec_len (nses); i++)
21949 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
21955 get_msg_id (vat_main_t * vam)
21960 if (unformat (vam->input, "%s", &name_and_crc))
21962 message_index = vl_msg_api_get_msg_index (name_and_crc);
21963 if (message_index == ~0)
21965 print (vam->ofp, " '%s' not found", name_and_crc);
21968 print (vam->ofp, " '%s' has message index %d",
21969 name_and_crc, message_index);
21972 errmsg ("name_and_crc required...");
21977 search_node_table (vat_main_t * vam)
21979 unformat_input_t *line_input = vam->input;
21982 vlib_node_t *node, *next_node;
21985 if (vam->graph_node_index_by_name == 0)
21987 print (vam->ofp, "Node table empty, issue get_node_graph...");
21991 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21993 if (unformat (line_input, "%s", &node_to_find))
21995 vec_add1 (node_to_find, 0);
21996 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
21999 print (vam->ofp, "%s not found...", node_to_find);
22002 node = vam->graph_nodes[0][p[0]];
22003 print (vam->ofp, "[%d] %s", p[0], node->name);
22004 for (j = 0; j < vec_len (node->next_nodes); j++)
22006 if (node->next_nodes[j] != ~0)
22008 next_node = vam->graph_nodes[0][node->next_nodes[j]];
22009 print (vam->ofp, " [%d] %s", j, next_node->name);
22016 clib_warning ("parse error '%U'", format_unformat_error,
22022 vec_free (node_to_find);
22031 script (vat_main_t * vam)
22033 #if (VPP_API_TEST_BUILTIN==0)
22035 char *save_current_file;
22036 unformat_input_t save_input;
22037 jmp_buf save_jump_buf;
22038 u32 save_line_number;
22040 FILE *new_fp, *save_ifp;
22042 if (unformat (vam->input, "%s", &s))
22044 new_fp = fopen ((char *) s, "r");
22047 errmsg ("Couldn't open script file %s", s);
22054 errmsg ("Missing script name");
22058 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
22059 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
22060 save_ifp = vam->ifp;
22061 save_line_number = vam->input_line_number;
22062 save_current_file = (char *) vam->current_file;
22064 vam->input_line_number = 0;
22066 vam->current_file = s;
22069 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
22070 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
22071 vam->ifp = save_ifp;
22072 vam->input_line_number = save_line_number;
22073 vam->current_file = (u8 *) save_current_file;
22078 clib_warning ("use the exec command...");
22084 echo (vat_main_t * vam)
22086 print (vam->ofp, "%v", vam->input->buffer);
22090 /* List of API message constructors, CLI names map to api_xxx */
22091 #define foreach_vpe_api_msg \
22092 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
22093 _(sw_interface_dump,"") \
22094 _(sw_interface_set_flags, \
22095 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
22096 _(sw_interface_add_del_address, \
22097 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
22098 _(sw_interface_set_rx_mode, \
22099 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
22100 _(sw_interface_set_rx_placement, \
22101 "<intfc> | sw_if_index <id> [queue <id>] [worker <id> | main]") \
22102 _(sw_interface_rx_placement_dump, \
22103 "[<intfc> | sw_if_index <id>]") \
22104 _(sw_interface_set_table, \
22105 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
22106 _(sw_interface_set_mpls_enable, \
22107 "<intfc> | sw_if_index [disable | dis]") \
22108 _(sw_interface_set_vpath, \
22109 "<intfc> | sw_if_index <id> enable | disable") \
22110 _(sw_interface_set_vxlan_bypass, \
22111 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
22112 _(sw_interface_set_geneve_bypass, \
22113 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
22114 _(sw_interface_set_l2_xconnect, \
22115 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
22116 "enable | disable") \
22117 _(sw_interface_set_l2_bridge, \
22118 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
22119 "[shg <split-horizon-group>] [bvi]\n" \
22120 "enable | disable") \
22121 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
22122 _(bridge_domain_add_del, \
22123 "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") \
22124 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
22126 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
22127 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
22128 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
22130 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
22132 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
22134 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>]") \
22136 "<vpp-if-name> | sw_if_index <id>") \
22137 _(sw_interface_tap_v2_dump, "") \
22138 _(virtio_pci_create, \
22139 "pci-addr <pci-address> [use_random_mac | hw-addr <mac-addr>] [features <hex-value>] [gso-enabled]") \
22140 _(virtio_pci_delete, \
22141 "<vpp-if-name> | sw_if_index <id>") \
22142 _(sw_interface_virtio_pci_dump, "") \
22144 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
22145 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \
22148 "<vpp-if-name> | sw_if_index <id>") \
22150 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
22151 _(bond_detach_slave, \
22152 "sw_if_index <n>") \
22153 _(sw_interface_bond_dump, "") \
22154 _(sw_interface_slave_dump, \
22155 "<vpp-if-name> | sw_if_index <id>") \
22156 _(ip_table_add_del, \
22157 "table <n> [ipv6] [add | del]\n") \
22158 _(ip_add_del_route, \
22159 "<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
22160 "[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
22161 "[weight <n>] [drop] [local] [classify <n>] [out-label <n>]\n" \
22162 "[multipath] [count <n>] [del]") \
22163 _(ip_mroute_add_del, \
22164 "<src> <grp>/<mask> [table-id <n>]\n" \
22165 "[<intfc> | sw_if_index <id>] [local] [del]") \
22166 _(mpls_table_add_del, \
22167 "table <n> [add | del]\n") \
22168 _(mpls_route_add_del, \
22169 "<label> <eos> via <addr | next-hop-table <n> | via-label <n> |\n" \
22170 "lookup-ip4-table <n> | lookup-in-ip6-table <n> |\n" \
22171 "l2-input-on <intfc> | l2-input-on sw_if_index <id>>\n" \
22172 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>] [weight <n>]\n" \
22173 "[drop] [local] [classify <n>] [out-label <n>] [multipath]\n" \
22174 "[count <n>] [del]") \
22175 _(mpls_ip_bind_unbind, \
22176 "<label> <addr/len>") \
22177 _(mpls_tunnel_add_del, \
22178 "[add | del <intfc | sw_if_index <id>>] via <addr | via-label <n>>\n" \
22179 "[<intfc> | sw_if_index <id> | next-hop-table <id>]\n" \
22180 "[l2-only] [out-label <n>]") \
22181 _(sr_mpls_policy_add, \
22182 "bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
22183 _(sr_mpls_policy_del, \
22185 _(bier_table_add_del, \
22186 "<label> <sub-domain> <set> <bsl> [del]") \
22187 _(bier_route_add_del, \
22188 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
22189 "[<intfc> | sw_if_index <id>]" \
22190 "[weight <n>] [del] [multipath]") \
22191 _(proxy_arp_add_del, \
22192 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
22193 _(proxy_arp_intfc_enable_disable, \
22194 "<intfc> | sw_if_index <id> enable | disable") \
22195 _(sw_interface_set_unnumbered, \
22196 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
22197 _(ip_neighbor_add_del, \
22198 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
22199 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
22200 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
22201 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
22202 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
22203 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
22204 "[outer_vlan_id_any][inner_vlan_id_any]") \
22205 _(reset_fib, "vrf <n> [ipv6]") \
22206 _(dhcp_proxy_config, \
22207 "svr <v46-address> src <v46-address>\n" \
22208 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
22209 _(dhcp_proxy_set_vss, \
22210 "tbl_id <n> [fib_id <n> oui <n> | vpn_ascii_id <text>] [ipv6] [del]") \
22211 _(dhcp_proxy_dump, "ip6") \
22212 _(dhcp_client_config, \
22213 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
22214 _(set_ip_flow_hash, \
22215 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
22216 _(sw_interface_ip6_enable_disable, \
22217 "<intfc> | sw_if_index <id> enable | disable") \
22218 _(ip6nd_proxy_add_del, \
22219 "<intfc> | sw_if_index <id> <ip6-address>") \
22220 _(ip6nd_proxy_dump, "") \
22221 _(sw_interface_ip6nd_ra_prefix, \
22222 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
22223 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
22224 "[nolink] [isno]") \
22225 _(sw_interface_ip6nd_ra_config, \
22226 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
22227 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
22228 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
22229 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
22230 _(l2_patch_add_del, \
22231 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
22232 "enable | disable") \
22233 _(sr_localsid_add_del, \
22234 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
22235 "fib-table <num> (end.psp) sw_if_index <num>") \
22236 _(classify_add_del_table, \
22237 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
22238 " [del] [del-chain] mask <mask-value>\n" \
22239 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
22240 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
22241 _(classify_add_del_session, \
22242 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
22243 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
22244 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
22245 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
22246 _(classify_set_interface_ip_table, \
22247 "<intfc> | sw_if_index <nn> table <nn>") \
22248 _(classify_set_interface_l2_tables, \
22249 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22250 " [other-table <nn>]") \
22251 _(get_node_index, "node <node-name") \
22252 _(add_node_next, "node <node-name> next <next-node-name>") \
22253 _(l2tpv3_create_tunnel, \
22254 "client_address <ip6-addr> our_address <ip6-addr>\n" \
22255 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
22256 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
22257 _(l2tpv3_set_tunnel_cookies, \
22258 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
22259 "[new_remote_cookie <nn>]\n") \
22260 _(l2tpv3_interface_enable_disable, \
22261 "<intfc> | sw_if_index <nn> enable | disable") \
22262 _(l2tpv3_set_lookup_key, \
22263 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
22264 _(sw_if_l2tpv3_tunnel_dump, "") \
22265 _(vxlan_offload_rx, \
22266 "hw { <interface name> | hw_if_index <nn>} " \
22267 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
22268 _(vxlan_add_del_tunnel, \
22269 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
22270 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
22271 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
22272 _(geneve_add_del_tunnel, \
22273 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
22274 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
22275 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
22276 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22277 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22278 _(gre_tunnel_add_del, \
22279 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
22280 "[teb | erspan <session-id>] [del]") \
22281 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22282 _(l2_fib_clear_table, "") \
22283 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
22284 _(l2_interface_vlan_tag_rewrite, \
22285 "<intfc> | sw_if_index <nn> \n" \
22286 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
22287 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
22288 _(create_vhost_user_if, \
22289 "socket <filename> [server] [renumber <dev_instance>] " \
22290 "[disable_mrg_rxbuf] [disable_indirect_desc] " \
22291 "[mac <mac_address>]") \
22292 _(modify_vhost_user_if, \
22293 "<intfc> | sw_if_index <nn> socket <filename>\n" \
22294 "[server] [renumber <dev_instance>]") \
22295 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
22296 _(sw_interface_vhost_user_dump, "") \
22297 _(show_version, "") \
22298 _(show_threads, "") \
22299 _(vxlan_gpe_add_del_tunnel, \
22300 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
22301 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
22302 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
22303 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
22304 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22305 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
22306 _(interface_name_renumber, \
22307 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
22308 _(input_acl_set_interface, \
22309 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22310 " [l2-table <nn>] [del]") \
22311 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
22312 _(ip_scan_neighbor_enable_disable, "[ip4|ip6|both|disable] [interval <n-min>]\n" \
22313 " [max-time <n-usec>] [max-update <n>] [delay <n-msec>] [stale <n-min>]") \
22314 _(want_ip4_arp_events, "address <ip4-address> [del]") \
22315 _(want_ip6_nd_events, "address <ip6-address> [del]") \
22316 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
22317 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
22318 _(ip_dump, "ipv4 | ipv6") \
22319 _(ipsec_spd_add_del, "spd_id <n> [del]") \
22320 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
22322 _(ipsec_sad_entry_add_del, "sad_id <n> spi <n> crypto_alg <alg>\n" \
22323 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
22324 " integ_alg <alg> integ_key <hex>") \
22325 _(ipsec_spd_entry_add_del, "spd_id <n> priority <n> action <action>\n" \
22326 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
22327 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
22328 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
22329 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
22330 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
22331 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
22332 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
22333 " [instance <n>]") \
22334 _(ipsec_sa_dump, "[sa_id <n>]") \
22335 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
22336 _(delete_loopback,"sw_if_index <nn>") \
22337 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
22338 _(bd_ip_mac_flush, "bd_id <bridge-domain-id>") \
22339 _(bd_ip_mac_dump, "[bd_id] <bridge-domain-id>") \
22340 _(want_interface_events, "enable|disable") \
22341 _(get_first_msg_id, "client <name>") \
22342 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
22343 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
22344 "fib-id <nn> [ip4][ip6][default]") \
22345 _(get_node_graph, " ") \
22346 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
22347 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
22348 _(ioam_disable, "") \
22349 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
22350 " sw_if_index <sw_if_index> p <priority> " \
22351 "w <weight>] [del]") \
22352 _(one_add_del_locator, "locator-set <locator_name> " \
22353 "iface <intf> | sw_if_index <sw_if_index> " \
22354 "p <priority> w <weight> [del]") \
22355 _(one_add_del_local_eid,"vni <vni> eid " \
22356 "<ipv4|ipv6>/<prefix> | <L2 address> " \
22357 "locator-set <locator_name> [del]" \
22358 "[key-id sha1|sha256 secret-key <secret-key>]")\
22359 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
22360 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
22361 _(one_enable_disable, "enable|disable") \
22362 _(one_map_register_enable_disable, "enable|disable") \
22363 _(one_map_register_fallback_threshold, "<value>") \
22364 _(one_rloc_probe_enable_disable, "enable|disable") \
22365 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
22367 "rloc <locator> p <prio> " \
22368 "w <weight> [rloc <loc> ... ] " \
22369 "action <action> [del-all]") \
22370 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
22372 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
22373 _(one_use_petr, "ip-address> | disable") \
22374 _(one_map_request_mode, "src-dst|dst-only") \
22375 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
22376 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
22377 _(one_locator_set_dump, "[local | remote]") \
22378 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
22379 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
22380 "[local] | [remote]") \
22381 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
22382 _(one_ndp_bd_get, "") \
22383 _(one_ndp_entries_get, "bd <bridge-domain>") \
22384 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
22385 _(one_l2_arp_bd_get, "") \
22386 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
22387 _(one_stats_enable_disable, "enable|disable") \
22388 _(show_one_stats_enable_disable, "") \
22389 _(one_eid_table_vni_dump, "") \
22390 _(one_eid_table_map_dump, "l2|l3") \
22391 _(one_map_resolver_dump, "") \
22392 _(one_map_server_dump, "") \
22393 _(one_adjacencies_get, "vni <vni>") \
22394 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
22395 _(show_one_rloc_probe_state, "") \
22396 _(show_one_map_register_state, "") \
22397 _(show_one_status, "") \
22398 _(one_stats_dump, "") \
22399 _(one_stats_flush, "") \
22400 _(one_get_map_request_itr_rlocs, "") \
22401 _(one_map_register_set_ttl, "<ttl>") \
22402 _(one_set_transport_protocol, "udp|api") \
22403 _(one_get_transport_protocol, "") \
22404 _(one_enable_disable_xtr_mode, "enable|disable") \
22405 _(one_show_xtr_mode, "") \
22406 _(one_enable_disable_pitr_mode, "enable|disable") \
22407 _(one_show_pitr_mode, "") \
22408 _(one_enable_disable_petr_mode, "enable|disable") \
22409 _(one_show_petr_mode, "") \
22410 _(show_one_nsh_mapping, "") \
22411 _(show_one_pitr, "") \
22412 _(show_one_use_petr, "") \
22413 _(show_one_map_request_mode, "") \
22414 _(show_one_map_register_ttl, "") \
22415 _(show_one_map_register_fallback_threshold, "") \
22416 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
22417 " sw_if_index <sw_if_index> p <priority> " \
22418 "w <weight>] [del]") \
22419 _(lisp_add_del_locator, "locator-set <locator_name> " \
22420 "iface <intf> | sw_if_index <sw_if_index> " \
22421 "p <priority> w <weight> [del]") \
22422 _(lisp_add_del_local_eid,"vni <vni> eid " \
22423 "<ipv4|ipv6>/<prefix> | <L2 address> " \
22424 "locator-set <locator_name> [del]" \
22425 "[key-id sha1|sha256 secret-key <secret-key>]") \
22426 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
22427 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
22428 _(lisp_enable_disable, "enable|disable") \
22429 _(lisp_map_register_enable_disable, "enable|disable") \
22430 _(lisp_rloc_probe_enable_disable, "enable|disable") \
22431 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
22433 "rloc <locator> p <prio> " \
22434 "w <weight> [rloc <loc> ... ] " \
22435 "action <action> [del-all]") \
22436 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
22438 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
22439 _(lisp_use_petr, "<ip-address> | disable") \
22440 _(lisp_map_request_mode, "src-dst|dst-only") \
22441 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
22442 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
22443 _(lisp_locator_set_dump, "[local | remote]") \
22444 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
22445 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
22446 "[local] | [remote]") \
22447 _(lisp_eid_table_vni_dump, "") \
22448 _(lisp_eid_table_map_dump, "l2|l3") \
22449 _(lisp_map_resolver_dump, "") \
22450 _(lisp_map_server_dump, "") \
22451 _(lisp_adjacencies_get, "vni <vni>") \
22452 _(gpe_fwd_entry_vnis_get, "") \
22453 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
22454 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
22455 "[table <table-id>]") \
22456 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
22457 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
22458 _(gpe_set_encap_mode, "lisp|vxlan") \
22459 _(gpe_get_encap_mode, "") \
22460 _(lisp_gpe_add_del_iface, "up|down") \
22461 _(lisp_gpe_enable_disable, "enable|disable") \
22462 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
22463 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
22464 _(show_lisp_rloc_probe_state, "") \
22465 _(show_lisp_map_register_state, "") \
22466 _(show_lisp_status, "") \
22467 _(lisp_get_map_request_itr_rlocs, "") \
22468 _(show_lisp_pitr, "") \
22469 _(show_lisp_use_petr, "") \
22470 _(show_lisp_map_request_mode, "") \
22471 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
22472 _(af_packet_delete, "name <host interface name>") \
22473 _(af_packet_dump, "") \
22474 _(policer_add_del, "name <policer name> <params> [del]") \
22475 _(policer_dump, "[name <policer name>]") \
22476 _(policer_classify_set_interface, \
22477 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22478 " [l2-table <nn>] [del]") \
22479 _(policer_classify_dump, "type [ip4|ip6|l2]") \
22480 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
22481 "[master|slave]") \
22482 _(netmap_delete, "name <interface name>") \
22483 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
22484 _(mpls_fib_dump, "") \
22485 _(classify_table_ids, "") \
22486 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
22487 _(classify_table_info, "table_id <nn>") \
22488 _(classify_session_dump, "table_id <nn>") \
22489 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
22490 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
22491 "[template_interval <nn>] [udp_checksum]") \
22492 _(ipfix_exporter_dump, "") \
22493 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
22494 _(ipfix_classify_stream_dump, "") \
22495 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
22496 _(ipfix_classify_table_dump, "") \
22497 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
22498 _(sw_interface_span_dump, "[l2]") \
22499 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
22500 _(pg_create_interface, "if_id <nn>") \
22501 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
22502 _(pg_enable_disable, "[stream <id>] disable") \
22503 _(ip_source_and_port_range_check_add_del, \
22504 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
22505 _(ip_source_and_port_range_check_interface_add_del, \
22506 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
22507 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
22508 _(ipsec_gre_tunnel_add_del, \
22509 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
22510 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
22511 _(delete_subif,"<intfc> | sw_if_index <nn>") \
22512 _(l2_interface_pbb_tag_rewrite, \
22513 "<intfc> | sw_if_index <nn> \n" \
22514 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
22515 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
22516 _(set_punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
22517 _(flow_classify_set_interface, \
22518 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
22519 _(flow_classify_dump, "type [ip4|ip6]") \
22520 _(ip_fib_dump, "") \
22521 _(ip_mfib_dump, "") \
22522 _(ip6_fib_dump, "") \
22523 _(ip6_mfib_dump, "") \
22524 _(feature_enable_disable, "arc_name <arc_name> " \
22525 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
22526 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
22528 _(l2_xconnect_dump, "") \
22529 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
22530 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
22531 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
22532 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
22533 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
22534 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
22535 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
22536 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
22537 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
22538 _(sock_init_shm, "size <nnn>") \
22539 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
22540 _(dns_enable_disable, "[enable][disable]") \
22541 _(dns_name_server_add_del, "<ip-address> [del]") \
22542 _(dns_resolve_name, "<hostname>") \
22543 _(dns_resolve_ip, "<ip4|ip6>") \
22544 _(dns_name_server_add_del, "<ip-address> [del]") \
22545 _(dns_resolve_name, "<hostname>") \
22546 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
22547 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
22548 _(session_rules_dump, "") \
22549 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
22550 _(output_acl_set_interface, \
22551 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22552 " [l2-table <nn>] [del]") \
22553 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
22555 /* List of command functions, CLI names map directly to functions */
22556 #define foreach_cli_function \
22557 _(comment, "usage: comment <ignore-rest-of-line>") \
22558 _(dump_interface_table, "usage: dump_interface_table") \
22559 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
22560 _(dump_ipv4_table, "usage: dump_ipv4_table") \
22561 _(dump_ipv6_table, "usage: dump_ipv6_table") \
22562 _(dump_macro_table, "usage: dump_macro_table ") \
22563 _(dump_node_table, "usage: dump_node_table") \
22564 _(dump_msg_api_table, "usage: dump_msg_api_table") \
22565 _(get_msg_id, "usage: get_msg_id name_and_crc") \
22566 _(echo, "usage: echo <message>") \
22567 _(exec, "usage: exec <vpe-debug-CLI-command>") \
22568 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
22569 _(help, "usage: help") \
22570 _(q, "usage: quit") \
22571 _(quit, "usage: quit") \
22572 _(search_node_table, "usage: search_node_table <name>...") \
22573 _(set, "usage: set <variable-name> <value>") \
22574 _(script, "usage: script <file-name>") \
22575 _(statseg, "usage: statseg"); \
22576 _(unset, "usage: unset <variable-name>")
22579 static void vl_api_##n##_t_handler_uni \
22580 (vl_api_##n##_t * mp) \
22582 vat_main_t * vam = &vat_main; \
22583 if (vam->json_output) { \
22584 vl_api_##n##_t_handler_json(mp); \
22586 vl_api_##n##_t_handler(mp); \
22589 foreach_vpe_api_reply_msg;
22590 #if VPP_API_TEST_BUILTIN == 0
22591 foreach_standalone_reply_msg;
22596 vat_api_hookup (vat_main_t * vam)
22599 vl_msg_api_set_handlers(VL_API_##N, #n, \
22600 vl_api_##n##_t_handler_uni, \
22602 vl_api_##n##_t_endian, \
22603 vl_api_##n##_t_print, \
22604 sizeof(vl_api_##n##_t), 1);
22605 foreach_vpe_api_reply_msg;
22606 #if VPP_API_TEST_BUILTIN == 0
22607 foreach_standalone_reply_msg;
22611 #if (VPP_API_TEST_BUILTIN==0)
22612 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
22614 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
22616 vam->function_by_name = hash_create_string (0, sizeof (uword));
22618 vam->help_by_name = hash_create_string (0, sizeof (uword));
22621 /* API messages we can send */
22622 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
22623 foreach_vpe_api_msg;
22627 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
22628 foreach_vpe_api_msg;
22631 /* CLI functions */
22632 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
22633 foreach_cli_function;
22637 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
22638 foreach_cli_function;
22642 #if VPP_API_TEST_BUILTIN
22643 static clib_error_t *
22644 vat_api_hookup_shim (vlib_main_t * vm)
22646 vat_api_hookup (&vat_main);
22650 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
22654 * fd.io coding-style-patch-verification: ON
22657 * eval: (c-set-style "gnu")