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 #if VPP_API_TEST_BUILTIN == 0
77 #define vl_print(handle, ...)
79 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
82 #include <vpp/api/vpe_all_api_h.h>
85 #define __plugin_msg_base 0
86 #include <vlibapi/vat_helper_macros.h>
88 void vl_api_set_elog_main (elog_main_t * m);
89 int vl_api_set_elog_trace_api_messages (int enable);
91 #if VPP_API_TEST_BUILTIN == 0
101 vat_socket_connect (vat_main_t * vam)
104 vam->socket_client_main = &socket_client_main;
105 if ((rv = vl_socket_client_connect ((char *) vam->socket_name,
107 0 /* default socket rx, tx buffer */ )))
109 /* vpp expects the client index in network order */
110 vam->my_client_index = htonl (socket_client_main.client_index);
113 #else /* vpp built-in case, we don't do sockets... */
115 vat_socket_connect (vat_main_t * vam)
121 vl_socket_client_read (int wait)
127 vl_socket_client_write ()
133 vl_socket_client_msg_alloc (int nbytes)
141 vat_time_now (vat_main_t * vam)
143 #if VPP_API_TEST_BUILTIN
144 return vlib_time_now (vam->vlib_main);
146 return clib_time_now (&vam->clib_time);
151 errmsg (char *fmt, ...)
153 vat_main_t *vam = &vat_main;
158 s = va_format (0, fmt, &va);
163 #if VPP_API_TEST_BUILTIN
164 vlib_cli_output (vam->vlib_main, (char *) s);
167 if (vam->ifp != stdin)
168 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
169 vam->input_line_number);
171 fformat (vam->ofp, "%s\n", (char *) s);
179 #if VPP_API_TEST_BUILTIN == 0
181 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
183 vat_main_t *vam = va_arg (*args, vat_main_t *);
184 u32 *result = va_arg (*args, u32 *);
188 if (!unformat (input, "%s", &if_name))
191 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
199 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
204 /* Parse an IP4 address %d.%d.%d.%d. */
206 unformat_ip4_address (unformat_input_t * input, va_list * args)
208 u8 *result = va_arg (*args, u8 *);
211 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
214 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
226 unformat_ethernet_address (unformat_input_t * input, va_list * args)
228 u8 *result = va_arg (*args, u8 *);
231 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
232 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
236 for (i = 0; i < 6; i++)
237 if (a[i] >= (1 << 8))
240 for (i = 0; i < 6; i++)
246 /* Returns ethernet type as an int in host byte order. */
248 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
251 u16 *result = va_arg (*args, u16 *);
255 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
257 if (type >= (1 << 16))
265 /* Parse an IP6 address. */
267 unformat_ip6_address (unformat_input_t * input, va_list * args)
269 ip6_address_t *result = va_arg (*args, ip6_address_t *);
271 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
272 uword c, n_colon, double_colon_index;
274 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
275 double_colon_index = ARRAY_LEN (hex_quads);
276 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
279 if (c >= '0' && c <= '9')
281 else if (c >= 'a' && c <= 'f')
282 hex_digit = c + 10 - 'a';
283 else if (c >= 'A' && c <= 'F')
284 hex_digit = c + 10 - 'A';
285 else if (c == ':' && n_colon < 2)
289 unformat_put_input (input);
293 /* Too many hex quads. */
294 if (n_hex_quads >= ARRAY_LEN (hex_quads))
299 hex_quad = (hex_quad << 4) | hex_digit;
301 /* Hex quad must fit in 16 bits. */
302 if (n_hex_digits >= 4)
309 /* Save position of :: */
312 /* More than one :: ? */
313 if (double_colon_index < ARRAY_LEN (hex_quads))
315 double_colon_index = n_hex_quads;
318 if (n_colon > 0 && n_hex_digits > 0)
320 hex_quads[n_hex_quads++] = hex_quad;
326 if (n_hex_digits > 0)
327 hex_quads[n_hex_quads++] = hex_quad;
332 /* Expand :: to appropriate number of zero hex quads. */
333 if (double_colon_index < ARRAY_LEN (hex_quads))
335 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
337 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
338 hex_quads[n_zero + i] = hex_quads[i];
340 for (i = 0; i < n_zero; i++)
341 hex_quads[double_colon_index + i] = 0;
343 n_hex_quads = ARRAY_LEN (hex_quads);
346 /* Too few hex quads given. */
347 if (n_hex_quads < ARRAY_LEN (hex_quads))
350 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
351 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
358 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
360 u32 *r = va_arg (*args, u32 *);
363 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
364 foreach_ipsec_policy_action
372 format_ipsec_crypto_alg (u8 * s, va_list * args)
374 u32 i = va_arg (*args, u32);
379 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
380 foreach_ipsec_crypto_alg
383 return format (s, "unknown");
385 return format (s, "%s", t);
389 format_ipsec_integ_alg (u8 * s, va_list * args)
391 u32 i = va_arg (*args, u32);
396 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
397 foreach_ipsec_integ_alg
400 return format (s, "unknown");
402 return format (s, "%s", t);
405 #else /* VPP_API_TEST_BUILTIN == 1 */
407 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
409 vat_main_t *vam __clib_unused = va_arg (*args, vat_main_t *);
410 vnet_main_t *vnm = vnet_get_main ();
411 u32 *result = va_arg (*args, u32 *);
413 return unformat (input, "%U", unformat_vnet_sw_interface, vnm, result);
417 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
419 vat_main_t *vam __clib_unused = va_arg (*args, vat_main_t *);
420 vnet_main_t *vnm = vnet_get_main ();
421 u32 *result = va_arg (*args, u32 *);
423 return unformat (input, "%U", unformat_vnet_hw_interface, vnm, result);
426 #endif /* VPP_API_TEST_BUILTIN */
429 unformat_ipsec_api_crypto_alg (unformat_input_t * input, va_list * args)
431 u32 *r = va_arg (*args, u32 *);
434 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_API_CRYPTO_ALG_##f;
435 foreach_ipsec_crypto_alg
443 unformat_ipsec_api_integ_alg (unformat_input_t * input, va_list * args)
445 u32 *r = va_arg (*args, u32 *);
448 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_API_INTEG_ALG_##f;
449 foreach_ipsec_integ_alg
457 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
459 u8 *r = va_arg (*args, u8 *);
461 if (unformat (input, "kbps"))
462 *r = SSE2_QOS_RATE_KBPS;
463 else if (unformat (input, "pps"))
464 *r = SSE2_QOS_RATE_PPS;
471 unformat_policer_round_type (unformat_input_t * input, va_list * args)
473 u8 *r = va_arg (*args, u8 *);
475 if (unformat (input, "closest"))
476 *r = SSE2_QOS_ROUND_TO_CLOSEST;
477 else if (unformat (input, "up"))
478 *r = SSE2_QOS_ROUND_TO_UP;
479 else if (unformat (input, "down"))
480 *r = SSE2_QOS_ROUND_TO_DOWN;
487 unformat_policer_type (unformat_input_t * input, va_list * args)
489 u8 *r = va_arg (*args, u8 *);
491 if (unformat (input, "1r2c"))
492 *r = SSE2_QOS_POLICER_TYPE_1R2C;
493 else if (unformat (input, "1r3c"))
494 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
495 else if (unformat (input, "2r3c-2698"))
496 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
497 else if (unformat (input, "2r3c-4115"))
498 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
499 else if (unformat (input, "2r3c-mef5cf1"))
500 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
507 unformat_dscp (unformat_input_t * input, va_list * va)
509 u8 *r = va_arg (*va, u8 *);
512 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
521 unformat_policer_action_type (unformat_input_t * input, va_list * va)
523 sse2_qos_pol_action_params_st *a
524 = va_arg (*va, sse2_qos_pol_action_params_st *);
526 if (unformat (input, "drop"))
527 a->action_type = SSE2_QOS_ACTION_DROP;
528 else if (unformat (input, "transmit"))
529 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
530 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
531 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
538 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
540 u32 *r = va_arg (*va, u32 *);
543 if (unformat (input, "ip4"))
544 tid = POLICER_CLASSIFY_TABLE_IP4;
545 else if (unformat (input, "ip6"))
546 tid = POLICER_CLASSIFY_TABLE_IP6;
547 else if (unformat (input, "l2"))
548 tid = POLICER_CLASSIFY_TABLE_L2;
557 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
559 u32 *r = va_arg (*va, u32 *);
562 if (unformat (input, "ip4"))
563 tid = FLOW_CLASSIFY_TABLE_IP4;
564 else if (unformat (input, "ip6"))
565 tid = FLOW_CLASSIFY_TABLE_IP6;
573 #if (VPP_API_TEST_BUILTIN==0)
575 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
576 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
577 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
578 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
581 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
583 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
584 mfib_itf_attribute_t attr;
587 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
589 if (unformat (input, mfib_itf_flag_long_names[attr]))
590 *iflags |= (1 << attr);
592 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
594 if (unformat (input, mfib_itf_flag_names[attr]))
595 *iflags |= (1 << attr);
598 return (old == *iflags ? 0 : 1);
602 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
604 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
605 mfib_entry_attribute_t attr;
608 FOR_EACH_MFIB_ATTRIBUTE (attr)
610 if (unformat (input, mfib_flag_long_names[attr]))
611 *eflags |= (1 << attr);
613 FOR_EACH_MFIB_ATTRIBUTE (attr)
615 if (unformat (input, mfib_flag_names[attr]))
616 *eflags |= (1 << attr);
619 return (old == *eflags ? 0 : 1);
623 format_ip4_address (u8 * s, va_list * args)
625 u8 *a = va_arg (*args, u8 *);
626 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
630 format_ip6_address (u8 * s, va_list * args)
632 ip6_address_t *a = va_arg (*args, ip6_address_t *);
633 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
635 i_max_n_zero = ARRAY_LEN (a->as_u16);
637 i_first_zero = i_max_n_zero;
639 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
641 u32 is_zero = a->as_u16[i] == 0;
642 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
648 if ((!is_zero && n_zeros > max_n_zeros)
649 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
651 i_max_n_zero = i_first_zero;
652 max_n_zeros = n_zeros;
653 i_first_zero = ARRAY_LEN (a->as_u16);
658 last_double_colon = 0;
659 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
661 if (i == i_max_n_zero && max_n_zeros > 1)
663 s = format (s, "::");
664 i += max_n_zeros - 1;
665 last_double_colon = 1;
669 s = format (s, "%s%x",
670 (last_double_colon || i == 0) ? "" : ":",
671 clib_net_to_host_u16 (a->as_u16[i]));
672 last_double_colon = 0;
679 /* Format an IP46 address. */
681 format_ip46_address (u8 * s, va_list * args)
683 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
684 ip46_type_t type = va_arg (*args, ip46_type_t);
690 is_ip4 = ip46_address_is_ip4 (ip46);
701 format (s, "%U", format_ip4_address, &ip46->ip4) :
702 format (s, "%U", format_ip6_address, &ip46->ip6);
706 format_ethernet_address (u8 * s, va_list * args)
708 u8 *a = va_arg (*args, u8 *);
710 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
711 a[0], a[1], a[2], a[3], a[4], a[5]);
716 increment_v4_address (vl_api_ip4_address_t * i)
718 ip4_address_t *a = (ip4_address_t *) i;
721 v = ntohl (a->as_u32) + 1;
722 a->as_u32 = ntohl (v);
726 increment_v6_address (vl_api_ip6_address_t * i)
728 ip6_address_t *a = (ip6_address_t *) i;
731 v0 = clib_net_to_host_u64 (a->as_u64[0]);
732 v1 = clib_net_to_host_u64 (a->as_u64[1]);
737 a->as_u64[0] = clib_net_to_host_u64 (v0);
738 a->as_u64[1] = clib_net_to_host_u64 (v1);
742 increment_address (vl_api_address_t * a)
744 if (clib_net_to_host_u32 (a->af) == ADDRESS_IP4)
745 increment_v4_address (&a->un.ip4);
746 else if (clib_net_to_host_u32 (a->af) == ADDRESS_IP6)
747 increment_v6_address (&a->un.ip6);
751 set_ip4_address (vl_api_address_t * a, u32 v)
753 if (a->af == ADDRESS_IP4)
755 ip4_address_t *i = (ip4_address_t *) & a->un.ip4;
761 increment_mac_address (u8 * mac)
763 u64 tmp = *((u64 *) mac);
764 tmp = clib_net_to_host_u64 (tmp);
765 tmp += 1 << 16; /* skip unused (least significant) octets */
766 tmp = clib_host_to_net_u64 (tmp);
768 clib_memcpy (mac, &tmp, 6);
772 vat_json_object_add_address (vat_json_node_t * node,
773 const char *str, const vl_api_address_t * addr)
775 if (ADDRESS_IP6 == addr->af)
779 clib_memcpy (&ip6, &addr->un.ip6, sizeof (ip6));
780 vat_json_object_add_ip6 (node, str, ip6);
786 clib_memcpy (&ip4, &addr->un.ip4, sizeof (ip4));
787 vat_json_object_add_ip4 (node, str, ip4);
792 vat_json_object_add_prefix (vat_json_node_t * node,
793 const vl_api_prefix_t * prefix)
795 vat_json_object_add_uint (node, "len", prefix->len);
796 vat_json_object_add_address (node, "address", &prefix->address);
799 static void vl_api_create_loopback_reply_t_handler
800 (vl_api_create_loopback_reply_t * mp)
802 vat_main_t *vam = &vat_main;
803 i32 retval = ntohl (mp->retval);
805 vam->retval = retval;
806 vam->regenerate_interface_table = 1;
807 vam->sw_if_index = ntohl (mp->sw_if_index);
808 vam->result_ready = 1;
811 static void vl_api_create_loopback_reply_t_handler_json
812 (vl_api_create_loopback_reply_t * mp)
814 vat_main_t *vam = &vat_main;
815 vat_json_node_t node;
817 vat_json_init_object (&node);
818 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
819 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
821 vat_json_print (vam->ofp, &node);
822 vat_json_free (&node);
823 vam->retval = ntohl (mp->retval);
824 vam->result_ready = 1;
827 static void vl_api_create_loopback_instance_reply_t_handler
828 (vl_api_create_loopback_instance_reply_t * mp)
830 vat_main_t *vam = &vat_main;
831 i32 retval = ntohl (mp->retval);
833 vam->retval = retval;
834 vam->regenerate_interface_table = 1;
835 vam->sw_if_index = ntohl (mp->sw_if_index);
836 vam->result_ready = 1;
839 static void vl_api_create_loopback_instance_reply_t_handler_json
840 (vl_api_create_loopback_instance_reply_t * mp)
842 vat_main_t *vam = &vat_main;
843 vat_json_node_t node;
845 vat_json_init_object (&node);
846 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
847 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
849 vat_json_print (vam->ofp, &node);
850 vat_json_free (&node);
851 vam->retval = ntohl (mp->retval);
852 vam->result_ready = 1;
855 static void vl_api_af_packet_create_reply_t_handler
856 (vl_api_af_packet_create_reply_t * mp)
858 vat_main_t *vam = &vat_main;
859 i32 retval = ntohl (mp->retval);
861 vam->retval = retval;
862 vam->regenerate_interface_table = 1;
863 vam->sw_if_index = ntohl (mp->sw_if_index);
864 vam->result_ready = 1;
867 static void vl_api_af_packet_create_reply_t_handler_json
868 (vl_api_af_packet_create_reply_t * mp)
870 vat_main_t *vam = &vat_main;
871 vat_json_node_t node;
873 vat_json_init_object (&node);
874 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
875 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
877 vat_json_print (vam->ofp, &node);
878 vat_json_free (&node);
880 vam->retval = ntohl (mp->retval);
881 vam->result_ready = 1;
884 static void vl_api_create_vlan_subif_reply_t_handler
885 (vl_api_create_vlan_subif_reply_t * mp)
887 vat_main_t *vam = &vat_main;
888 i32 retval = ntohl (mp->retval);
890 vam->retval = retval;
891 vam->regenerate_interface_table = 1;
892 vam->sw_if_index = ntohl (mp->sw_if_index);
893 vam->result_ready = 1;
896 static void vl_api_create_vlan_subif_reply_t_handler_json
897 (vl_api_create_vlan_subif_reply_t * mp)
899 vat_main_t *vam = &vat_main;
900 vat_json_node_t node;
902 vat_json_init_object (&node);
903 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
904 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
906 vat_json_print (vam->ofp, &node);
907 vat_json_free (&node);
909 vam->retval = ntohl (mp->retval);
910 vam->result_ready = 1;
913 static void vl_api_create_subif_reply_t_handler
914 (vl_api_create_subif_reply_t * mp)
916 vat_main_t *vam = &vat_main;
917 i32 retval = ntohl (mp->retval);
919 vam->retval = retval;
920 vam->regenerate_interface_table = 1;
921 vam->sw_if_index = ntohl (mp->sw_if_index);
922 vam->result_ready = 1;
925 static void vl_api_create_subif_reply_t_handler_json
926 (vl_api_create_subif_reply_t * mp)
928 vat_main_t *vam = &vat_main;
929 vat_json_node_t node;
931 vat_json_init_object (&node);
932 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
933 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
935 vat_json_print (vam->ofp, &node);
936 vat_json_free (&node);
938 vam->retval = ntohl (mp->retval);
939 vam->result_ready = 1;
942 static void vl_api_interface_name_renumber_reply_t_handler
943 (vl_api_interface_name_renumber_reply_t * mp)
945 vat_main_t *vam = &vat_main;
946 i32 retval = ntohl (mp->retval);
948 vam->retval = retval;
949 vam->regenerate_interface_table = 1;
950 vam->result_ready = 1;
953 static void vl_api_interface_name_renumber_reply_t_handler_json
954 (vl_api_interface_name_renumber_reply_t * mp)
956 vat_main_t *vam = &vat_main;
957 vat_json_node_t node;
959 vat_json_init_object (&node);
960 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
962 vat_json_print (vam->ofp, &node);
963 vat_json_free (&node);
965 vam->retval = ntohl (mp->retval);
966 vam->result_ready = 1;
970 * Special-case: build the interface table, maintain
971 * the next loopback sw_if_index vbl.
973 static void vl_api_sw_interface_details_t_handler
974 (vl_api_sw_interface_details_t * mp)
976 vat_main_t *vam = &vat_main;
977 u8 *s = format (0, "%s%c", mp->interface_name, 0);
979 hash_set_mem (vam->sw_if_index_by_interface_name, s,
980 ntohl (mp->sw_if_index));
982 /* In sub interface case, fill the sub interface table entry */
983 if (mp->sw_if_index != mp->sup_sw_if_index)
985 sw_interface_subif_t *sub = NULL;
987 vec_add2 (vam->sw_if_subif_table, sub, 1);
989 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
990 strncpy ((char *) sub->interface_name, (char *) s,
991 vec_len (sub->interface_name));
992 sub->sw_if_index = ntohl (mp->sw_if_index);
993 sub->sub_id = ntohl (mp->sub_id);
995 sub->sub_dot1ad = mp->sub_dot1ad;
996 sub->sub_number_of_tags = mp->sub_number_of_tags;
997 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
998 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
999 sub->sub_exact_match = mp->sub_exact_match;
1000 sub->sub_default = mp->sub_default;
1001 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
1002 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
1004 /* vlan tag rewrite */
1005 sub->vtr_op = ntohl (mp->vtr_op);
1006 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
1007 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
1008 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
1012 static void vl_api_sw_interface_details_t_handler_json
1013 (vl_api_sw_interface_details_t * mp)
1015 vat_main_t *vam = &vat_main;
1016 vat_json_node_t *node = NULL;
1018 if (VAT_JSON_ARRAY != vam->json_tree.type)
1020 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1021 vat_json_init_array (&vam->json_tree);
1023 node = vat_json_array_add (&vam->json_tree);
1025 vat_json_init_object (node);
1026 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1027 vat_json_object_add_uint (node, "sup_sw_if_index",
1028 ntohl (mp->sup_sw_if_index));
1029 vat_json_object_add_uint (node, "l2_address_length",
1030 ntohl (mp->l2_address_length));
1031 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
1032 sizeof (mp->l2_address));
1033 vat_json_object_add_string_copy (node, "interface_name",
1034 mp->interface_name);
1035 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
1036 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
1037 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
1038 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
1039 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
1040 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
1041 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
1042 vat_json_object_add_uint (node, "sub_number_of_tags",
1043 mp->sub_number_of_tags);
1044 vat_json_object_add_uint (node, "sub_outer_vlan_id",
1045 ntohs (mp->sub_outer_vlan_id));
1046 vat_json_object_add_uint (node, "sub_inner_vlan_id",
1047 ntohs (mp->sub_inner_vlan_id));
1048 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
1049 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
1050 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
1051 mp->sub_outer_vlan_id_any);
1052 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
1053 mp->sub_inner_vlan_id_any);
1054 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
1055 vat_json_object_add_uint (node, "vtr_push_dot1q",
1056 ntohl (mp->vtr_push_dot1q));
1057 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
1058 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
1061 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
1063 format_ethernet_address,
1065 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
1067 format_ethernet_address,
1069 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
1070 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
1074 #if VPP_API_TEST_BUILTIN == 0
1075 static void vl_api_sw_interface_event_t_handler
1076 (vl_api_sw_interface_event_t * mp)
1078 vat_main_t *vam = &vat_main;
1079 if (vam->interface_event_display)
1080 errmsg ("interface flags: sw_if_index %d %s %s",
1081 ntohl (mp->sw_if_index),
1082 mp->admin_up_down ? "admin-up" : "admin-down",
1083 mp->link_up_down ? "link-up" : "link-down");
1087 __clib_unused static void
1088 vl_api_sw_interface_event_t_handler_json (vl_api_sw_interface_event_t * mp)
1090 /* JSON output not supported */
1094 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
1096 vat_main_t *vam = &vat_main;
1097 i32 retval = ntohl (mp->retval);
1099 vam->retval = retval;
1100 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1101 vam->result_ready = 1;
1105 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1107 vat_main_t *vam = &vat_main;
1108 vat_json_node_t node;
1109 api_main_t *am = &api_main;
1113 vat_json_init_object (&node);
1114 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1115 vat_json_object_add_uint (&node, "reply_in_shmem",
1116 ntohl (mp->reply_in_shmem));
1117 /* Toss the shared-memory original... */
1118 pthread_mutex_lock (&am->vlib_rp->mutex);
1119 oldheap = svm_push_data_heap (am->vlib_rp);
1121 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1124 svm_pop_heap (oldheap);
1125 pthread_mutex_unlock (&am->vlib_rp->mutex);
1127 vat_json_print (vam->ofp, &node);
1128 vat_json_free (&node);
1130 vam->retval = ntohl (mp->retval);
1131 vam->result_ready = 1;
1135 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1137 vat_main_t *vam = &vat_main;
1138 i32 retval = ntohl (mp->retval);
1139 u32 length = vl_api_string_len (&mp->reply);
1141 vec_reset_length (vam->cmd_reply);
1143 vam->retval = retval;
1146 vec_validate (vam->cmd_reply, length);
1147 clib_memcpy ((char *) (vam->cmd_reply),
1148 vl_api_from_api_string (&mp->reply), length);
1149 vam->cmd_reply[length] = 0;
1151 vam->result_ready = 1;
1155 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1157 vat_main_t *vam = &vat_main;
1158 vat_json_node_t node;
1160 vec_reset_length (vam->cmd_reply);
1162 vat_json_init_object (&node);
1163 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1164 vat_json_object_add_string_copy (&node, "reply",
1165 vl_api_from_api_string (&mp->reply));
1167 vat_json_print (vam->ofp, &node);
1168 vat_json_free (&node);
1170 vam->retval = ntohl (mp->retval);
1171 vam->result_ready = 1;
1174 static void vl_api_classify_add_del_table_reply_t_handler
1175 (vl_api_classify_add_del_table_reply_t * mp)
1177 vat_main_t *vam = &vat_main;
1178 i32 retval = ntohl (mp->retval);
1179 if (vam->async_mode)
1181 vam->async_errors += (retval < 0);
1185 vam->retval = retval;
1187 ((mp->new_table_index != 0xFFFFFFFF) ||
1188 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1189 (mp->match_n_vectors != 0xFFFFFFFF)))
1191 * Note: this is just barely thread-safe, depends on
1192 * the main thread spinning waiting for an answer...
1194 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1195 ntohl (mp->new_table_index),
1196 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1197 vam->result_ready = 1;
1201 static void vl_api_classify_add_del_table_reply_t_handler_json
1202 (vl_api_classify_add_del_table_reply_t * mp)
1204 vat_main_t *vam = &vat_main;
1205 vat_json_node_t node;
1207 vat_json_init_object (&node);
1208 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1209 vat_json_object_add_uint (&node, "new_table_index",
1210 ntohl (mp->new_table_index));
1211 vat_json_object_add_uint (&node, "skip_n_vectors",
1212 ntohl (mp->skip_n_vectors));
1213 vat_json_object_add_uint (&node, "match_n_vectors",
1214 ntohl (mp->match_n_vectors));
1216 vat_json_print (vam->ofp, &node);
1217 vat_json_free (&node);
1219 vam->retval = ntohl (mp->retval);
1220 vam->result_ready = 1;
1223 static void vl_api_get_node_index_reply_t_handler
1224 (vl_api_get_node_index_reply_t * mp)
1226 vat_main_t *vam = &vat_main;
1227 i32 retval = ntohl (mp->retval);
1228 if (vam->async_mode)
1230 vam->async_errors += (retval < 0);
1234 vam->retval = retval;
1236 errmsg ("node index %d", ntohl (mp->node_index));
1237 vam->result_ready = 1;
1241 static void vl_api_get_node_index_reply_t_handler_json
1242 (vl_api_get_node_index_reply_t * mp)
1244 vat_main_t *vam = &vat_main;
1245 vat_json_node_t node;
1247 vat_json_init_object (&node);
1248 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1249 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1251 vat_json_print (vam->ofp, &node);
1252 vat_json_free (&node);
1254 vam->retval = ntohl (mp->retval);
1255 vam->result_ready = 1;
1258 static void vl_api_get_next_index_reply_t_handler
1259 (vl_api_get_next_index_reply_t * mp)
1261 vat_main_t *vam = &vat_main;
1262 i32 retval = ntohl (mp->retval);
1263 if (vam->async_mode)
1265 vam->async_errors += (retval < 0);
1269 vam->retval = retval;
1271 errmsg ("next node index %d", ntohl (mp->next_index));
1272 vam->result_ready = 1;
1276 static void vl_api_get_next_index_reply_t_handler_json
1277 (vl_api_get_next_index_reply_t * mp)
1279 vat_main_t *vam = &vat_main;
1280 vat_json_node_t node;
1282 vat_json_init_object (&node);
1283 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1284 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1286 vat_json_print (vam->ofp, &node);
1287 vat_json_free (&node);
1289 vam->retval = ntohl (mp->retval);
1290 vam->result_ready = 1;
1293 static void vl_api_add_node_next_reply_t_handler
1294 (vl_api_add_node_next_reply_t * mp)
1296 vat_main_t *vam = &vat_main;
1297 i32 retval = ntohl (mp->retval);
1298 if (vam->async_mode)
1300 vam->async_errors += (retval < 0);
1304 vam->retval = retval;
1306 errmsg ("next index %d", ntohl (mp->next_index));
1307 vam->result_ready = 1;
1311 static void vl_api_add_node_next_reply_t_handler_json
1312 (vl_api_add_node_next_reply_t * mp)
1314 vat_main_t *vam = &vat_main;
1315 vat_json_node_t node;
1317 vat_json_init_object (&node);
1318 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1319 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1321 vat_json_print (vam->ofp, &node);
1322 vat_json_free (&node);
1324 vam->retval = ntohl (mp->retval);
1325 vam->result_ready = 1;
1328 static void vl_api_show_version_reply_t_handler
1329 (vl_api_show_version_reply_t * mp)
1331 vat_main_t *vam = &vat_main;
1332 i32 retval = ntohl (mp->retval);
1337 char *p = (char *) &mp->program;
1339 s = vl_api_from_api_to_vec ((vl_api_string_t *) p);
1340 errmsg (" program: %v\n", s);
1344 vl_api_string_len ((vl_api_string_t *) p) + sizeof (vl_api_string_t);
1345 s = vl_api_from_api_to_vec ((vl_api_string_t *) p);
1346 errmsg (" version: %v\n", s);
1350 vl_api_string_len ((vl_api_string_t *) p) + sizeof (vl_api_string_t);
1351 s = vl_api_from_api_to_vec ((vl_api_string_t *) p);
1352 errmsg (" build date: %v\n", s);
1356 vl_api_string_len ((vl_api_string_t *) p) + sizeof (vl_api_string_t);
1357 s = vl_api_from_api_to_vec ((vl_api_string_t *) p);
1358 errmsg ("build directory: %v\n", s);
1361 vam->retval = retval;
1362 vam->result_ready = 1;
1365 static void vl_api_show_version_reply_t_handler_json
1366 (vl_api_show_version_reply_t * mp)
1368 vat_main_t *vam = &vat_main;
1369 vat_json_node_t node;
1371 vat_json_init_object (&node);
1372 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1373 char *p = (char *) &mp->program;
1374 vat_json_object_add_string_copy (&node, "program",
1375 vl_api_from_api_string ((vl_api_string_t *)
1377 p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (u32);
1378 vat_json_object_add_string_copy (&node, "version",
1379 vl_api_from_api_string ((vl_api_string_t *)
1381 p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (u32);
1382 vat_json_object_add_string_copy (&node, "build_date",
1383 vl_api_from_api_string ((vl_api_string_t *)
1385 p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (u32);
1386 vat_json_object_add_string_copy (&node, "build_directory",
1387 vl_api_from_api_string ((vl_api_string_t *)
1390 vat_json_print (vam->ofp, &node);
1391 vat_json_free (&node);
1393 vam->retval = ntohl (mp->retval);
1394 vam->result_ready = 1;
1397 static void vl_api_show_threads_reply_t_handler
1398 (vl_api_show_threads_reply_t * mp)
1400 vat_main_t *vam = &vat_main;
1401 i32 retval = ntohl (mp->retval);
1405 count = ntohl (mp->count);
1407 for (i = 0; i < count; i++)
1409 "\n%-2d %-11s %-11s %-5d %-6d %-4d %-6d",
1410 ntohl (mp->thread_data[i].id), mp->thread_data[i].name,
1411 mp->thread_data[i].type, ntohl (mp->thread_data[i].pid),
1412 ntohl (mp->thread_data[i].cpu_id), ntohl (mp->thread_data[i].core),
1413 ntohl (mp->thread_data[i].cpu_socket));
1415 vam->retval = retval;
1416 vam->result_ready = 1;
1419 static void vl_api_show_threads_reply_t_handler_json
1420 (vl_api_show_threads_reply_t * mp)
1422 vat_main_t *vam = &vat_main;
1423 vat_json_node_t node;
1424 vl_api_thread_data_t *td;
1425 i32 retval = ntohl (mp->retval);
1429 count = ntohl (mp->count);
1431 vat_json_init_object (&node);
1432 vat_json_object_add_int (&node, "retval", retval);
1433 vat_json_object_add_uint (&node, "count", count);
1435 for (i = 0; i < count; i++)
1437 td = &mp->thread_data[i];
1438 vat_json_object_add_uint (&node, "id", ntohl (td->id));
1439 vat_json_object_add_string_copy (&node, "name", td->name);
1440 vat_json_object_add_string_copy (&node, "type", td->type);
1441 vat_json_object_add_uint (&node, "pid", ntohl (td->pid));
1442 vat_json_object_add_int (&node, "cpu_id", ntohl (td->cpu_id));
1443 vat_json_object_add_int (&node, "core", ntohl (td->id));
1444 vat_json_object_add_int (&node, "cpu_socket", ntohl (td->cpu_socket));
1447 vat_json_print (vam->ofp, &node);
1448 vat_json_free (&node);
1450 vam->retval = retval;
1451 vam->result_ready = 1;
1455 api_show_threads (vat_main_t * vam)
1457 vl_api_show_threads_t *mp;
1461 "\n%-2s %-11s %-11s %-5s %-6s %-4s %-6s",
1462 "ID", "Name", "Type", "LWP", "cpu_id", "Core", "Socket");
1464 M (SHOW_THREADS, mp);
1472 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1474 u32 sw_if_index = ntohl (mp->sw_if_index);
1475 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1476 mp->mac_ip ? "mac/ip binding" : "address resolution",
1477 ntohl (mp->pid), format_ip4_address, mp->ip,
1478 format_vl_api_mac_address, &mp->mac, sw_if_index);
1482 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1484 /* JSON output not supported */
1488 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1490 u32 sw_if_index = ntohl (mp->sw_if_index);
1491 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1492 mp->mac_ip ? "mac/ip binding" : "address resolution",
1493 ntohl (mp->pid), format_vl_api_ip6_address, mp->ip,
1494 format_vl_api_mac_address, mp->mac, sw_if_index);
1498 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1500 /* JSON output not supported */
1504 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1506 u32 n_macs = ntohl (mp->n_macs);
1507 errmsg ("L2MAC event received with pid %d cl-idx %d for %d macs: \n",
1508 ntohl (mp->pid), mp->client_index, n_macs);
1510 for (i = 0; i < n_macs; i++)
1512 vl_api_mac_entry_t *mac = &mp->mac[i];
1513 errmsg (" [%d] sw_if_index %d mac_addr %U action %d \n",
1514 i + 1, ntohl (mac->sw_if_index),
1515 format_ethernet_address, mac->mac_addr, mac->action);
1522 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1524 /* JSON output not supported */
1527 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1528 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1531 * Special-case: build the bridge domain table, maintain
1532 * the next bd id vbl.
1534 static void vl_api_bridge_domain_details_t_handler
1535 (vl_api_bridge_domain_details_t * mp)
1537 vat_main_t *vam = &vat_main;
1538 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1541 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-6s %-3s",
1542 " ID", "LRN", "FWD", "FLD", "BVI", "UU-FWD", "#IF");
1544 print (vam->ofp, "%3d %3d %3d %3d %3d %6d %3d",
1545 ntohl (mp->bd_id), mp->learn, mp->forward,
1546 mp->flood, ntohl (mp->bvi_sw_if_index),
1547 ntohl (mp->uu_fwd_sw_if_index), n_sw_ifs);
1551 vl_api_bridge_domain_sw_if_t *sw_ifs;
1552 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1555 sw_ifs = mp->sw_if_details;
1556 for (i = 0; i < n_sw_ifs; i++)
1562 sw_if_index = ntohl (sw_ifs->sw_if_index);
1565 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1567 if ((u32) p->value[0] == sw_if_index)
1569 sw_if_name = (u8 *)(p->key);
1574 print (vam->ofp, "%7d %3d %s", sw_if_index,
1575 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1576 "sw_if_index not found!");
1583 static void vl_api_bridge_domain_details_t_handler_json
1584 (vl_api_bridge_domain_details_t * mp)
1586 vat_main_t *vam = &vat_main;
1587 vat_json_node_t *node, *array = NULL;
1588 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1590 if (VAT_JSON_ARRAY != vam->json_tree.type)
1592 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1593 vat_json_init_array (&vam->json_tree);
1595 node = vat_json_array_add (&vam->json_tree);
1597 vat_json_init_object (node);
1598 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1599 vat_json_object_add_uint (node, "flood", mp->flood);
1600 vat_json_object_add_uint (node, "forward", mp->forward);
1601 vat_json_object_add_uint (node, "learn", mp->learn);
1602 vat_json_object_add_uint (node, "bvi_sw_if_index",
1603 ntohl (mp->bvi_sw_if_index));
1604 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1605 array = vat_json_object_add (node, "sw_if");
1606 vat_json_init_array (array);
1612 vl_api_bridge_domain_sw_if_t *sw_ifs;
1615 sw_ifs = mp->sw_if_details;
1616 for (i = 0; i < n_sw_ifs; i++)
1618 node = vat_json_array_add (array);
1619 vat_json_init_object (node);
1620 vat_json_object_add_uint (node, "sw_if_index",
1621 ntohl (sw_ifs->sw_if_index));
1622 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1628 static void vl_api_control_ping_reply_t_handler
1629 (vl_api_control_ping_reply_t * mp)
1631 vat_main_t *vam = &vat_main;
1632 i32 retval = ntohl (mp->retval);
1633 if (vam->async_mode)
1635 vam->async_errors += (retval < 0);
1639 vam->retval = retval;
1640 vam->result_ready = 1;
1642 if (vam->socket_client_main)
1643 vam->socket_client_main->control_pings_outstanding--;
1646 static void vl_api_control_ping_reply_t_handler_json
1647 (vl_api_control_ping_reply_t * mp)
1649 vat_main_t *vam = &vat_main;
1650 i32 retval = ntohl (mp->retval);
1652 if (VAT_JSON_NONE != vam->json_tree.type)
1654 vat_json_print (vam->ofp, &vam->json_tree);
1655 vat_json_free (&vam->json_tree);
1656 vam->json_tree.type = VAT_JSON_NONE;
1661 vat_json_init_array (&vam->json_tree);
1662 vat_json_print (vam->ofp, &vam->json_tree);
1663 vam->json_tree.type = VAT_JSON_NONE;
1666 vam->retval = retval;
1667 vam->result_ready = 1;
1671 vl_api_bridge_domain_set_mac_age_reply_t_handler
1672 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1674 vat_main_t *vam = &vat_main;
1675 i32 retval = ntohl (mp->retval);
1676 if (vam->async_mode)
1678 vam->async_errors += (retval < 0);
1682 vam->retval = retval;
1683 vam->result_ready = 1;
1687 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1688 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1690 vat_main_t *vam = &vat_main;
1691 vat_json_node_t node;
1693 vat_json_init_object (&node);
1694 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1696 vat_json_print (vam->ofp, &node);
1697 vat_json_free (&node);
1699 vam->retval = ntohl (mp->retval);
1700 vam->result_ready = 1;
1704 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1706 vat_main_t *vam = &vat_main;
1707 i32 retval = ntohl (mp->retval);
1708 if (vam->async_mode)
1710 vam->async_errors += (retval < 0);
1714 vam->retval = retval;
1715 vam->result_ready = 1;
1719 static void vl_api_l2_flags_reply_t_handler_json
1720 (vl_api_l2_flags_reply_t * mp)
1722 vat_main_t *vam = &vat_main;
1723 vat_json_node_t node;
1725 vat_json_init_object (&node);
1726 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1727 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1728 ntohl (mp->resulting_feature_bitmap));
1730 vat_json_print (vam->ofp, &node);
1731 vat_json_free (&node);
1733 vam->retval = ntohl (mp->retval);
1734 vam->result_ready = 1;
1737 static void vl_api_bridge_flags_reply_t_handler
1738 (vl_api_bridge_flags_reply_t * mp)
1740 vat_main_t *vam = &vat_main;
1741 i32 retval = ntohl (mp->retval);
1742 if (vam->async_mode)
1744 vam->async_errors += (retval < 0);
1748 vam->retval = retval;
1749 vam->result_ready = 1;
1753 static void vl_api_bridge_flags_reply_t_handler_json
1754 (vl_api_bridge_flags_reply_t * mp)
1756 vat_main_t *vam = &vat_main;
1757 vat_json_node_t node;
1759 vat_json_init_object (&node);
1760 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1761 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1762 ntohl (mp->resulting_feature_bitmap));
1764 vat_json_print (vam->ofp, &node);
1765 vat_json_free (&node);
1767 vam->retval = ntohl (mp->retval);
1768 vam->result_ready = 1;
1772 vl_api_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_reply_t * mp)
1774 vat_main_t *vam = &vat_main;
1775 i32 retval = ntohl (mp->retval);
1776 if (vam->async_mode)
1778 vam->async_errors += (retval < 0);
1782 vam->retval = retval;
1783 vam->sw_if_index = ntohl (mp->sw_if_index);
1784 vam->result_ready = 1;
1789 static void vl_api_tap_create_v2_reply_t_handler_json
1790 (vl_api_tap_create_v2_reply_t * mp)
1792 vat_main_t *vam = &vat_main;
1793 vat_json_node_t node;
1795 vat_json_init_object (&node);
1796 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1797 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1799 vat_json_print (vam->ofp, &node);
1800 vat_json_free (&node);
1802 vam->retval = ntohl (mp->retval);
1803 vam->result_ready = 1;
1808 vl_api_tap_delete_v2_reply_t_handler (vl_api_tap_delete_v2_reply_t * mp)
1810 vat_main_t *vam = &vat_main;
1811 i32 retval = ntohl (mp->retval);
1812 if (vam->async_mode)
1814 vam->async_errors += (retval < 0);
1818 vam->retval = retval;
1819 vam->result_ready = 1;
1823 static void vl_api_tap_delete_v2_reply_t_handler_json
1824 (vl_api_tap_delete_v2_reply_t * mp)
1826 vat_main_t *vam = &vat_main;
1827 vat_json_node_t node;
1829 vat_json_init_object (&node);
1830 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1832 vat_json_print (vam->ofp, &node);
1833 vat_json_free (&node);
1835 vam->retval = ntohl (mp->retval);
1836 vam->result_ready = 1;
1840 vl_api_virtio_pci_create_reply_t_handler (vl_api_virtio_pci_create_reply_t *
1843 vat_main_t *vam = &vat_main;
1844 i32 retval = ntohl (mp->retval);
1845 if (vam->async_mode)
1847 vam->async_errors += (retval < 0);
1851 vam->retval = retval;
1852 vam->sw_if_index = ntohl (mp->sw_if_index);
1853 vam->result_ready = 1;
1857 static void vl_api_virtio_pci_create_reply_t_handler_json
1858 (vl_api_virtio_pci_create_reply_t * mp)
1860 vat_main_t *vam = &vat_main;
1861 vat_json_node_t node;
1863 vat_json_init_object (&node);
1864 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1865 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1867 vat_json_print (vam->ofp, &node);
1868 vat_json_free (&node);
1870 vam->retval = ntohl (mp->retval);
1871 vam->result_ready = 1;
1876 vl_api_virtio_pci_delete_reply_t_handler (vl_api_virtio_pci_delete_reply_t *
1879 vat_main_t *vam = &vat_main;
1880 i32 retval = ntohl (mp->retval);
1881 if (vam->async_mode)
1883 vam->async_errors += (retval < 0);
1887 vam->retval = retval;
1888 vam->result_ready = 1;
1892 static void vl_api_virtio_pci_delete_reply_t_handler_json
1893 (vl_api_virtio_pci_delete_reply_t * mp)
1895 vat_main_t *vam = &vat_main;
1896 vat_json_node_t node;
1898 vat_json_init_object (&node);
1899 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1901 vat_json_print (vam->ofp, &node);
1902 vat_json_free (&node);
1904 vam->retval = ntohl (mp->retval);
1905 vam->result_ready = 1;
1909 vl_api_bond_create_reply_t_handler (vl_api_bond_create_reply_t * mp)
1911 vat_main_t *vam = &vat_main;
1912 i32 retval = ntohl (mp->retval);
1914 if (vam->async_mode)
1916 vam->async_errors += (retval < 0);
1920 vam->retval = retval;
1921 vam->sw_if_index = ntohl (mp->sw_if_index);
1922 vam->result_ready = 1;
1926 static void vl_api_bond_create_reply_t_handler_json
1927 (vl_api_bond_create_reply_t * mp)
1929 vat_main_t *vam = &vat_main;
1930 vat_json_node_t node;
1932 vat_json_init_object (&node);
1933 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1934 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1936 vat_json_print (vam->ofp, &node);
1937 vat_json_free (&node);
1939 vam->retval = ntohl (mp->retval);
1940 vam->result_ready = 1;
1944 vl_api_bond_delete_reply_t_handler (vl_api_bond_delete_reply_t * mp)
1946 vat_main_t *vam = &vat_main;
1947 i32 retval = ntohl (mp->retval);
1949 if (vam->async_mode)
1951 vam->async_errors += (retval < 0);
1955 vam->retval = retval;
1956 vam->result_ready = 1;
1960 static void vl_api_bond_delete_reply_t_handler_json
1961 (vl_api_bond_delete_reply_t * mp)
1963 vat_main_t *vam = &vat_main;
1964 vat_json_node_t node;
1966 vat_json_init_object (&node);
1967 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1969 vat_json_print (vam->ofp, &node);
1970 vat_json_free (&node);
1972 vam->retval = ntohl (mp->retval);
1973 vam->result_ready = 1;
1977 vl_api_bond_enslave_reply_t_handler (vl_api_bond_enslave_reply_t * mp)
1979 vat_main_t *vam = &vat_main;
1980 i32 retval = ntohl (mp->retval);
1982 if (vam->async_mode)
1984 vam->async_errors += (retval < 0);
1988 vam->retval = retval;
1989 vam->result_ready = 1;
1993 static void vl_api_bond_enslave_reply_t_handler_json
1994 (vl_api_bond_enslave_reply_t * mp)
1996 vat_main_t *vam = &vat_main;
1997 vat_json_node_t node;
1999 vat_json_init_object (&node);
2000 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2002 vat_json_print (vam->ofp, &node);
2003 vat_json_free (&node);
2005 vam->retval = ntohl (mp->retval);
2006 vam->result_ready = 1;
2010 vl_api_bond_detach_slave_reply_t_handler (vl_api_bond_detach_slave_reply_t *
2013 vat_main_t *vam = &vat_main;
2014 i32 retval = ntohl (mp->retval);
2016 if (vam->async_mode)
2018 vam->async_errors += (retval < 0);
2022 vam->retval = retval;
2023 vam->result_ready = 1;
2027 static void vl_api_bond_detach_slave_reply_t_handler_json
2028 (vl_api_bond_detach_slave_reply_t * mp)
2030 vat_main_t *vam = &vat_main;
2031 vat_json_node_t node;
2033 vat_json_init_object (&node);
2034 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2036 vat_json_print (vam->ofp, &node);
2037 vat_json_free (&node);
2039 vam->retval = ntohl (mp->retval);
2040 vam->result_ready = 1;
2043 static void vl_api_sw_interface_bond_details_t_handler
2044 (vl_api_sw_interface_bond_details_t * mp)
2046 vat_main_t *vam = &vat_main;
2049 "%-16s %-12d %-12U %-13U %-14u %-14u",
2050 mp->interface_name, ntohl (mp->sw_if_index),
2051 format_bond_mode, mp->mode, format_bond_load_balance, mp->lb,
2052 ntohl (mp->active_slaves), ntohl (mp->slaves));
2055 static void vl_api_sw_interface_bond_details_t_handler_json
2056 (vl_api_sw_interface_bond_details_t * mp)
2058 vat_main_t *vam = &vat_main;
2059 vat_json_node_t *node = NULL;
2061 if (VAT_JSON_ARRAY != vam->json_tree.type)
2063 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2064 vat_json_init_array (&vam->json_tree);
2066 node = vat_json_array_add (&vam->json_tree);
2068 vat_json_init_object (node);
2069 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2070 vat_json_object_add_string_copy (node, "interface_name",
2071 mp->interface_name);
2072 vat_json_object_add_uint (node, "mode", mp->mode);
2073 vat_json_object_add_uint (node, "load_balance", mp->lb);
2074 vat_json_object_add_uint (node, "active_slaves", ntohl (mp->active_slaves));
2075 vat_json_object_add_uint (node, "slaves", ntohl (mp->slaves));
2079 api_sw_interface_bond_dump (vat_main_t * vam)
2081 vl_api_sw_interface_bond_dump_t *mp;
2082 vl_api_control_ping_t *mp_ping;
2086 "\n%-16s %-12s %-12s %-13s %-14s %-14s",
2087 "interface name", "sw_if_index", "mode", "load balance",
2088 "active slaves", "slaves");
2090 /* Get list of bond interfaces */
2091 M (SW_INTERFACE_BOND_DUMP, mp);
2094 /* Use a control ping for synchronization */
2095 MPING (CONTROL_PING, mp_ping);
2102 static void vl_api_sw_interface_slave_details_t_handler
2103 (vl_api_sw_interface_slave_details_t * mp)
2105 vat_main_t *vam = &vat_main;
2108 "%-25s %-12d %-12d %d", mp->interface_name,
2109 ntohl (mp->sw_if_index), mp->is_passive, mp->is_long_timeout);
2112 static void vl_api_sw_interface_slave_details_t_handler_json
2113 (vl_api_sw_interface_slave_details_t * mp)
2115 vat_main_t *vam = &vat_main;
2116 vat_json_node_t *node = NULL;
2118 if (VAT_JSON_ARRAY != vam->json_tree.type)
2120 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2121 vat_json_init_array (&vam->json_tree);
2123 node = vat_json_array_add (&vam->json_tree);
2125 vat_json_init_object (node);
2126 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2127 vat_json_object_add_string_copy (node, "interface_name",
2128 mp->interface_name);
2129 vat_json_object_add_uint (node, "passive", mp->is_passive);
2130 vat_json_object_add_uint (node, "long_timeout", mp->is_long_timeout);
2134 api_sw_interface_slave_dump (vat_main_t * vam)
2136 unformat_input_t *i = vam->input;
2137 vl_api_sw_interface_slave_dump_t *mp;
2138 vl_api_control_ping_t *mp_ping;
2139 u32 sw_if_index = ~0;
2140 u8 sw_if_index_set = 0;
2143 /* Parse args required to build the message */
2144 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2146 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2147 sw_if_index_set = 1;
2148 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2149 sw_if_index_set = 1;
2154 if (sw_if_index_set == 0)
2156 errmsg ("missing vpp interface name. ");
2161 "\n%-25s %-12s %-12s %s",
2162 "slave interface name", "sw_if_index", "passive", "long_timeout");
2164 /* Get list of bond interfaces */
2165 M (SW_INTERFACE_SLAVE_DUMP, mp);
2166 mp->sw_if_index = ntohl (sw_if_index);
2169 /* Use a control ping for synchronization */
2170 MPING (CONTROL_PING, mp_ping);
2177 static void vl_api_mpls_tunnel_add_del_reply_t_handler
2178 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2180 vat_main_t *vam = &vat_main;
2181 i32 retval = ntohl (mp->retval);
2182 if (vam->async_mode)
2184 vam->async_errors += (retval < 0);
2188 vam->retval = retval;
2189 vam->sw_if_index = ntohl (mp->sw_if_index);
2190 vam->result_ready = 1;
2192 vam->regenerate_interface_table = 1;
2195 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
2196 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2198 vat_main_t *vam = &vat_main;
2199 vat_json_node_t node;
2201 vat_json_init_object (&node);
2202 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2203 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
2204 ntohl (mp->sw_if_index));
2206 vat_json_print (vam->ofp, &node);
2207 vat_json_free (&node);
2209 vam->retval = ntohl (mp->retval);
2210 vam->result_ready = 1;
2213 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
2214 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2216 vat_main_t *vam = &vat_main;
2217 i32 retval = ntohl (mp->retval);
2218 if (vam->async_mode)
2220 vam->async_errors += (retval < 0);
2224 vam->retval = retval;
2225 vam->sw_if_index = ntohl (mp->sw_if_index);
2226 vam->result_ready = 1;
2230 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
2231 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2233 vat_main_t *vam = &vat_main;
2234 vat_json_node_t node;
2236 vat_json_init_object (&node);
2237 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2238 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2240 vat_json_print (vam->ofp, &node);
2241 vat_json_free (&node);
2243 vam->retval = ntohl (mp->retval);
2244 vam->result_ready = 1;
2247 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
2248 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2250 vat_main_t *vam = &vat_main;
2251 i32 retval = ntohl (mp->retval);
2252 if (vam->async_mode)
2254 vam->async_errors += (retval < 0);
2258 vam->retval = retval;
2259 vam->result_ready = 1;
2263 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
2264 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2266 vat_main_t *vam = &vat_main;
2267 vat_json_node_t node;
2269 vat_json_init_object (&node);
2270 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2271 vat_json_object_add_uint (&node, "fwd_entry_index",
2272 clib_net_to_host_u32 (mp->fwd_entry_index));
2274 vat_json_print (vam->ofp, &node);
2275 vat_json_free (&node);
2277 vam->retval = ntohl (mp->retval);
2278 vam->result_ready = 1;
2282 format_lisp_transport_protocol (u8 * s, va_list * args)
2284 u32 proto = va_arg (*args, u32);
2289 return format (s, "udp");
2291 return format (s, "api");
2298 static void vl_api_one_get_transport_protocol_reply_t_handler
2299 (vl_api_one_get_transport_protocol_reply_t * mp)
2301 vat_main_t *vam = &vat_main;
2302 i32 retval = ntohl (mp->retval);
2303 if (vam->async_mode)
2305 vam->async_errors += (retval < 0);
2309 u32 proto = mp->protocol;
2310 print (vam->ofp, "Transport protocol: %U",
2311 format_lisp_transport_protocol, proto);
2312 vam->retval = retval;
2313 vam->result_ready = 1;
2317 static void vl_api_one_get_transport_protocol_reply_t_handler_json
2318 (vl_api_one_get_transport_protocol_reply_t * mp)
2320 vat_main_t *vam = &vat_main;
2321 vat_json_node_t node;
2324 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
2327 vat_json_init_object (&node);
2328 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2329 vat_json_object_add_string_copy (&node, "transport-protocol", s);
2332 vat_json_print (vam->ofp, &node);
2333 vat_json_free (&node);
2335 vam->retval = ntohl (mp->retval);
2336 vam->result_ready = 1;
2339 static void vl_api_one_add_del_locator_set_reply_t_handler
2340 (vl_api_one_add_del_locator_set_reply_t * mp)
2342 vat_main_t *vam = &vat_main;
2343 i32 retval = ntohl (mp->retval);
2344 if (vam->async_mode)
2346 vam->async_errors += (retval < 0);
2350 vam->retval = retval;
2351 vam->result_ready = 1;
2355 static void vl_api_one_add_del_locator_set_reply_t_handler_json
2356 (vl_api_one_add_del_locator_set_reply_t * mp)
2358 vat_main_t *vam = &vat_main;
2359 vat_json_node_t node;
2361 vat_json_init_object (&node);
2362 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2363 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
2365 vat_json_print (vam->ofp, &node);
2366 vat_json_free (&node);
2368 vam->retval = ntohl (mp->retval);
2369 vam->result_ready = 1;
2372 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
2373 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2375 vat_main_t *vam = &vat_main;
2376 i32 retval = ntohl (mp->retval);
2377 if (vam->async_mode)
2379 vam->async_errors += (retval < 0);
2383 vam->retval = retval;
2384 vam->sw_if_index = ntohl (mp->sw_if_index);
2385 vam->result_ready = 1;
2387 vam->regenerate_interface_table = 1;
2390 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
2391 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2393 vat_main_t *vam = &vat_main;
2394 vat_json_node_t node;
2396 vat_json_init_object (&node);
2397 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2398 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2400 vat_json_print (vam->ofp, &node);
2401 vat_json_free (&node);
2403 vam->retval = ntohl (mp->retval);
2404 vam->result_ready = 1;
2407 static void vl_api_vxlan_offload_rx_reply_t_handler
2408 (vl_api_vxlan_offload_rx_reply_t * mp)
2410 vat_main_t *vam = &vat_main;
2411 i32 retval = ntohl (mp->retval);
2412 if (vam->async_mode)
2414 vam->async_errors += (retval < 0);
2418 vam->retval = retval;
2419 vam->result_ready = 1;
2423 static void vl_api_vxlan_offload_rx_reply_t_handler_json
2424 (vl_api_vxlan_offload_rx_reply_t * mp)
2426 vat_main_t *vam = &vat_main;
2427 vat_json_node_t node;
2429 vat_json_init_object (&node);
2430 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2432 vat_json_print (vam->ofp, &node);
2433 vat_json_free (&node);
2435 vam->retval = ntohl (mp->retval);
2436 vam->result_ready = 1;
2439 static void vl_api_geneve_add_del_tunnel_reply_t_handler
2440 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2442 vat_main_t *vam = &vat_main;
2443 i32 retval = ntohl (mp->retval);
2444 if (vam->async_mode)
2446 vam->async_errors += (retval < 0);
2450 vam->retval = retval;
2451 vam->sw_if_index = ntohl (mp->sw_if_index);
2452 vam->result_ready = 1;
2456 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
2457 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2459 vat_main_t *vam = &vat_main;
2460 vat_json_node_t node;
2462 vat_json_init_object (&node);
2463 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2464 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2466 vat_json_print (vam->ofp, &node);
2467 vat_json_free (&node);
2469 vam->retval = ntohl (mp->retval);
2470 vam->result_ready = 1;
2473 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
2474 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2476 vat_main_t *vam = &vat_main;
2477 i32 retval = ntohl (mp->retval);
2478 if (vam->async_mode)
2480 vam->async_errors += (retval < 0);
2484 vam->retval = retval;
2485 vam->sw_if_index = ntohl (mp->sw_if_index);
2486 vam->result_ready = 1;
2488 vam->regenerate_interface_table = 1;
2491 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
2492 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2494 vat_main_t *vam = &vat_main;
2495 vat_json_node_t node;
2497 vat_json_init_object (&node);
2498 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2499 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2501 vat_json_print (vam->ofp, &node);
2502 vat_json_free (&node);
2504 vam->retval = ntohl (mp->retval);
2505 vam->result_ready = 1;
2508 static void vl_api_gre_tunnel_add_del_reply_t_handler
2509 (vl_api_gre_tunnel_add_del_reply_t * mp)
2511 vat_main_t *vam = &vat_main;
2512 i32 retval = ntohl (mp->retval);
2513 if (vam->async_mode)
2515 vam->async_errors += (retval < 0);
2519 vam->retval = retval;
2520 vam->sw_if_index = ntohl (mp->sw_if_index);
2521 vam->result_ready = 1;
2525 static void vl_api_gre_tunnel_add_del_reply_t_handler_json
2526 (vl_api_gre_tunnel_add_del_reply_t * mp)
2528 vat_main_t *vam = &vat_main;
2529 vat_json_node_t node;
2531 vat_json_init_object (&node);
2532 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2533 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2535 vat_json_print (vam->ofp, &node);
2536 vat_json_free (&node);
2538 vam->retval = ntohl (mp->retval);
2539 vam->result_ready = 1;
2542 static void vl_api_create_vhost_user_if_reply_t_handler
2543 (vl_api_create_vhost_user_if_reply_t * mp)
2545 vat_main_t *vam = &vat_main;
2546 i32 retval = ntohl (mp->retval);
2547 if (vam->async_mode)
2549 vam->async_errors += (retval < 0);
2553 vam->retval = retval;
2554 vam->sw_if_index = ntohl (mp->sw_if_index);
2555 vam->result_ready = 1;
2557 vam->regenerate_interface_table = 1;
2560 static void vl_api_create_vhost_user_if_reply_t_handler_json
2561 (vl_api_create_vhost_user_if_reply_t * mp)
2563 vat_main_t *vam = &vat_main;
2564 vat_json_node_t node;
2566 vat_json_init_object (&node);
2567 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2568 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2570 vat_json_print (vam->ofp, &node);
2571 vat_json_free (&node);
2573 vam->retval = ntohl (mp->retval);
2574 vam->result_ready = 1;
2577 static void vl_api_dns_resolve_name_reply_t_handler
2578 (vl_api_dns_resolve_name_reply_t * mp)
2580 vat_main_t *vam = &vat_main;
2581 i32 retval = ntohl (mp->retval);
2582 if (vam->async_mode)
2584 vam->async_errors += (retval < 0);
2588 vam->retval = retval;
2589 vam->result_ready = 1;
2594 clib_warning ("ip4 address %U", format_ip4_address,
2595 (ip4_address_t *) mp->ip4_address);
2597 clib_warning ("ip6 address %U", format_ip6_address,
2598 (ip6_address_t *) mp->ip6_address);
2601 clib_warning ("retval %d", retval);
2605 static void vl_api_dns_resolve_name_reply_t_handler_json
2606 (vl_api_dns_resolve_name_reply_t * mp)
2608 clib_warning ("not implemented");
2611 static void vl_api_dns_resolve_ip_reply_t_handler
2612 (vl_api_dns_resolve_ip_reply_t * mp)
2614 vat_main_t *vam = &vat_main;
2615 i32 retval = ntohl (mp->retval);
2616 if (vam->async_mode)
2618 vam->async_errors += (retval < 0);
2622 vam->retval = retval;
2623 vam->result_ready = 1;
2627 clib_warning ("canonical name %s", mp->name);
2630 clib_warning ("retval %d", retval);
2634 static void vl_api_dns_resolve_ip_reply_t_handler_json
2635 (vl_api_dns_resolve_ip_reply_t * mp)
2637 clib_warning ("not implemented");
2641 static void vl_api_ip_address_details_t_handler
2642 (vl_api_ip_address_details_t * mp)
2644 vat_main_t *vam = &vat_main;
2645 static ip_address_details_t empty_ip_address_details = { {0} };
2646 ip_address_details_t *address = NULL;
2647 ip_details_t *current_ip_details = NULL;
2648 ip_details_t *details = NULL;
2650 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2652 if (!details || vam->current_sw_if_index >= vec_len (details)
2653 || !details[vam->current_sw_if_index].present)
2655 errmsg ("ip address details arrived but not stored");
2656 errmsg ("ip_dump should be called first");
2660 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2662 #define addresses (current_ip_details->addr)
2664 vec_validate_init_empty (addresses, vec_len (addresses),
2665 empty_ip_address_details);
2667 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2669 clib_memcpy (&address->ip, &mp->prefix.address.un, sizeof (address->ip));
2670 address->prefix_length = mp->prefix.len;
2674 static void vl_api_ip_address_details_t_handler_json
2675 (vl_api_ip_address_details_t * mp)
2677 vat_main_t *vam = &vat_main;
2678 vat_json_node_t *node = NULL;
2680 if (VAT_JSON_ARRAY != vam->json_tree.type)
2682 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2683 vat_json_init_array (&vam->json_tree);
2685 node = vat_json_array_add (&vam->json_tree);
2687 vat_json_init_object (node);
2688 vat_json_object_add_prefix (node, &mp->prefix);
2692 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2694 vat_main_t *vam = &vat_main;
2695 static ip_details_t empty_ip_details = { 0 };
2696 ip_details_t *ip = NULL;
2697 u32 sw_if_index = ~0;
2699 sw_if_index = ntohl (mp->sw_if_index);
2701 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2702 sw_if_index, empty_ip_details);
2704 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2711 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2713 vat_main_t *vam = &vat_main;
2715 if (VAT_JSON_ARRAY != vam->json_tree.type)
2717 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2718 vat_json_init_array (&vam->json_tree);
2720 vat_json_array_add_uint (&vam->json_tree,
2721 clib_net_to_host_u32 (mp->sw_if_index));
2725 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2729 s = format (0, "DHCP compl event: pid %d %s hostname %s host_addr %U "
2730 "host_mac %U router_addr %U",
2731 ntohl (mp->pid), mp->lease.is_ipv6 ? "ipv6" : "ipv4",
2733 format_ip4_address, mp->lease.host_address,
2734 format_ethernet_address, mp->lease.host_mac,
2735 format_ip4_address, mp->lease.router_address);
2737 for (i = 0; i < mp->lease.count; i++)
2739 format (s, " domain_server_addr %U", format_ip4_address,
2740 mp->lease.domain_server[i].address);
2742 errmsg ((char *) s);
2746 static void vl_api_dhcp_compl_event_t_handler_json
2747 (vl_api_dhcp_compl_event_t * mp)
2749 /* JSON output not supported */
2752 static void vl_api_get_first_msg_id_reply_t_handler
2753 (vl_api_get_first_msg_id_reply_t * mp)
2755 vat_main_t *vam = &vat_main;
2756 i32 retval = ntohl (mp->retval);
2758 if (vam->async_mode)
2760 vam->async_errors += (retval < 0);
2764 vam->retval = retval;
2765 vam->result_ready = 1;
2769 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2773 static void vl_api_get_first_msg_id_reply_t_handler_json
2774 (vl_api_get_first_msg_id_reply_t * mp)
2776 vat_main_t *vam = &vat_main;
2777 vat_json_node_t node;
2779 vat_json_init_object (&node);
2780 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2781 vat_json_object_add_uint (&node, "first_msg_id",
2782 (uint) ntohs (mp->first_msg_id));
2784 vat_json_print (vam->ofp, &node);
2785 vat_json_free (&node);
2787 vam->retval = ntohl (mp->retval);
2788 vam->result_ready = 1;
2791 static void vl_api_get_node_graph_reply_t_handler
2792 (vl_api_get_node_graph_reply_t * mp)
2794 vat_main_t *vam = &vat_main;
2795 api_main_t *am = &api_main;
2796 i32 retval = ntohl (mp->retval);
2797 u8 *pvt_copy, *reply;
2802 if (vam->async_mode)
2804 vam->async_errors += (retval < 0);
2808 vam->retval = retval;
2809 vam->result_ready = 1;
2812 /* "Should never happen..." */
2816 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2817 pvt_copy = vec_dup (reply);
2819 /* Toss the shared-memory original... */
2820 pthread_mutex_lock (&am->vlib_rp->mutex);
2821 oldheap = svm_push_data_heap (am->vlib_rp);
2825 svm_pop_heap (oldheap);
2826 pthread_mutex_unlock (&am->vlib_rp->mutex);
2828 if (vam->graph_nodes)
2830 hash_free (vam->graph_node_index_by_name);
2832 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2834 node = vam->graph_nodes[0][i];
2835 vec_free (node->name);
2836 vec_free (node->next_nodes);
2839 vec_free (vam->graph_nodes[0]);
2840 vec_free (vam->graph_nodes);
2843 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2844 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2845 vec_free (pvt_copy);
2847 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2849 node = vam->graph_nodes[0][i];
2850 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2854 static void vl_api_get_node_graph_reply_t_handler_json
2855 (vl_api_get_node_graph_reply_t * mp)
2857 vat_main_t *vam = &vat_main;
2858 api_main_t *am = &api_main;
2860 vat_json_node_t node;
2863 /* $$$$ make this real? */
2864 vat_json_init_object (&node);
2865 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2866 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2868 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2870 /* Toss the shared-memory original... */
2871 pthread_mutex_lock (&am->vlib_rp->mutex);
2872 oldheap = svm_push_data_heap (am->vlib_rp);
2876 svm_pop_heap (oldheap);
2877 pthread_mutex_unlock (&am->vlib_rp->mutex);
2879 vat_json_print (vam->ofp, &node);
2880 vat_json_free (&node);
2882 vam->retval = ntohl (mp->retval);
2883 vam->result_ready = 1;
2887 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2889 vat_main_t *vam = &vat_main;
2894 s = format (s, "%=16d%=16d%=16d",
2895 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2899 s = format (s, "%=16U%=16d%=16d",
2900 mp->is_ipv6 ? format_ip6_address :
2902 mp->ip_address, mp->priority, mp->weight);
2905 print (vam->ofp, "%v", s);
2910 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2912 vat_main_t *vam = &vat_main;
2913 vat_json_node_t *node = NULL;
2914 struct in6_addr ip6;
2917 if (VAT_JSON_ARRAY != vam->json_tree.type)
2919 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2920 vat_json_init_array (&vam->json_tree);
2922 node = vat_json_array_add (&vam->json_tree);
2923 vat_json_init_object (node);
2925 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2926 vat_json_object_add_uint (node, "priority", mp->priority);
2927 vat_json_object_add_uint (node, "weight", mp->weight);
2930 vat_json_object_add_uint (node, "sw_if_index",
2931 clib_net_to_host_u32 (mp->sw_if_index));
2936 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2937 vat_json_object_add_ip6 (node, "address", ip6);
2941 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2942 vat_json_object_add_ip4 (node, "address", ip4);
2948 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2951 vat_main_t *vam = &vat_main;
2954 ls_name = format (0, "%s", mp->ls_name);
2956 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2962 vl_api_one_locator_set_details_t_handler_json
2963 (vl_api_one_locator_set_details_t * mp)
2965 vat_main_t *vam = &vat_main;
2966 vat_json_node_t *node = 0;
2969 ls_name = format (0, "%s", mp->ls_name);
2970 vec_add1 (ls_name, 0);
2972 if (VAT_JSON_ARRAY != vam->json_tree.type)
2974 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2975 vat_json_init_array (&vam->json_tree);
2977 node = vat_json_array_add (&vam->json_tree);
2979 vat_json_init_object (node);
2980 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2981 vat_json_object_add_uint (node, "ls_index",
2982 clib_net_to_host_u32 (mp->ls_index));
2990 } __attribute__ ((__packed__)) lisp_nsh_api_t;
2993 unformat_nsh_address (unformat_input_t * input, va_list * args)
2995 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
2996 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
3000 format_nsh_address_vat (u8 * s, va_list * args)
3002 nsh_t *a = va_arg (*args, nsh_t *);
3003 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
3007 format_lisp_flat_eid (u8 * s, va_list * args)
3009 u32 type = va_arg (*args, u32);
3010 u8 *eid = va_arg (*args, u8 *);
3011 u32 eid_len = va_arg (*args, u32);
3016 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
3018 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
3020 return format (s, "%U", format_ethernet_address, eid);
3022 return format (s, "%U", format_nsh_address_vat, eid);
3028 format_lisp_eid_vat (u8 * s, va_list * args)
3030 u32 type = va_arg (*args, u32);
3031 u8 *eid = va_arg (*args, u8 *);
3032 u32 eid_len = va_arg (*args, u32);
3033 u8 *seid = va_arg (*args, u8 *);
3034 u32 seid_len = va_arg (*args, u32);
3035 u32 is_src_dst = va_arg (*args, u32);
3038 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
3040 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
3046 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
3048 vat_main_t *vam = &vat_main;
3049 u8 *s = 0, *eid = 0;
3051 if (~0 == mp->locator_set_index)
3052 s = format (0, "action: %d", mp->action);
3054 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3056 eid = format (0, "%U", format_lisp_eid_vat,
3060 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3063 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3064 clib_net_to_host_u32 (mp->vni),
3066 mp->is_local ? "local" : "remote",
3067 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3068 clib_net_to_host_u16 (mp->key_id), mp->key);
3075 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3078 vat_main_t *vam = &vat_main;
3079 vat_json_node_t *node = 0;
3082 if (VAT_JSON_ARRAY != vam->json_tree.type)
3084 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3085 vat_json_init_array (&vam->json_tree);
3087 node = vat_json_array_add (&vam->json_tree);
3089 vat_json_init_object (node);
3090 if (~0 == mp->locator_set_index)
3091 vat_json_object_add_uint (node, "action", mp->action);
3093 vat_json_object_add_uint (node, "locator_set_index",
3094 clib_net_to_host_u32 (mp->locator_set_index));
3096 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3097 if (mp->eid_type == 3)
3099 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3100 vat_json_init_object (nsh_json);
3101 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3102 vat_json_object_add_uint (nsh_json, "spi",
3103 clib_net_to_host_u32 (nsh->spi));
3104 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3108 eid = format (0, "%U", format_lisp_eid_vat,
3112 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3114 vat_json_object_add_string_copy (node, "eid", eid);
3117 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3118 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3119 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3123 vat_json_object_add_uint (node, "key_id",
3124 clib_net_to_host_u16 (mp->key_id));
3125 vat_json_object_add_string_copy (node, "key", mp->key);
3130 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3132 vat_main_t *vam = &vat_main;
3133 u8 *seid = 0, *deid = 0;
3134 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3136 deid = format (0, "%U", format_lisp_eid_vat,
3137 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3139 seid = format (0, "%U", format_lisp_eid_vat,
3140 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3146 format_ip_address_fcn = format_ip4_address;
3148 format_ip_address_fcn = format_ip6_address;
3151 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3152 clib_net_to_host_u32 (mp->vni),
3154 format_ip_address_fcn, mp->lloc,
3155 format_ip_address_fcn, mp->rloc,
3156 clib_net_to_host_u32 (mp->pkt_count),
3157 clib_net_to_host_u32 (mp->bytes));
3164 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3166 struct in6_addr ip6;
3168 vat_main_t *vam = &vat_main;
3169 vat_json_node_t *node = 0;
3170 u8 *deid = 0, *seid = 0;
3172 if (VAT_JSON_ARRAY != vam->json_tree.type)
3174 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3175 vat_json_init_array (&vam->json_tree);
3177 node = vat_json_array_add (&vam->json_tree);
3179 vat_json_init_object (node);
3180 deid = format (0, "%U", format_lisp_eid_vat,
3181 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3183 seid = format (0, "%U", format_lisp_eid_vat,
3184 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3189 vat_json_object_add_string_copy (node, "seid", seid);
3190 vat_json_object_add_string_copy (node, "deid", deid);
3191 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3195 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3196 vat_json_object_add_ip4 (node, "lloc", ip4);
3197 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3198 vat_json_object_add_ip4 (node, "rloc", ip4);
3202 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3203 vat_json_object_add_ip6 (node, "lloc", ip6);
3204 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3205 vat_json_object_add_ip6 (node, "rloc", ip6);
3207 vat_json_object_add_uint (node, "pkt_count",
3208 clib_net_to_host_u32 (mp->pkt_count));
3209 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3216 vl_api_one_eid_table_map_details_t_handler
3217 (vl_api_one_eid_table_map_details_t * mp)
3219 vat_main_t *vam = &vat_main;
3221 u8 *line = format (0, "%=10d%=10d",
3222 clib_net_to_host_u32 (mp->vni),
3223 clib_net_to_host_u32 (mp->dp_table));
3224 print (vam->ofp, "%v", line);
3229 vl_api_one_eid_table_map_details_t_handler_json
3230 (vl_api_one_eid_table_map_details_t * mp)
3232 vat_main_t *vam = &vat_main;
3233 vat_json_node_t *node = NULL;
3235 if (VAT_JSON_ARRAY != vam->json_tree.type)
3237 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3238 vat_json_init_array (&vam->json_tree);
3240 node = vat_json_array_add (&vam->json_tree);
3241 vat_json_init_object (node);
3242 vat_json_object_add_uint (node, "dp_table",
3243 clib_net_to_host_u32 (mp->dp_table));
3244 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3248 vl_api_one_eid_table_vni_details_t_handler
3249 (vl_api_one_eid_table_vni_details_t * mp)
3251 vat_main_t *vam = &vat_main;
3253 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3254 print (vam->ofp, "%v", line);
3259 vl_api_one_eid_table_vni_details_t_handler_json
3260 (vl_api_one_eid_table_vni_details_t * mp)
3262 vat_main_t *vam = &vat_main;
3263 vat_json_node_t *node = NULL;
3265 if (VAT_JSON_ARRAY != vam->json_tree.type)
3267 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3268 vat_json_init_array (&vam->json_tree);
3270 node = vat_json_array_add (&vam->json_tree);
3271 vat_json_init_object (node);
3272 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3276 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3277 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3279 vat_main_t *vam = &vat_main;
3280 int retval = clib_net_to_host_u32 (mp->retval);
3282 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3283 print (vam->ofp, "fallback threshold value: %d", mp->value);
3285 vam->retval = retval;
3286 vam->result_ready = 1;
3290 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3291 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3293 vat_main_t *vam = &vat_main;
3294 vat_json_node_t _node, *node = &_node;
3295 int retval = clib_net_to_host_u32 (mp->retval);
3297 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3298 vat_json_init_object (node);
3299 vat_json_object_add_uint (node, "value", mp->value);
3301 vat_json_print (vam->ofp, node);
3302 vat_json_free (node);
3304 vam->retval = retval;
3305 vam->result_ready = 1;
3309 vl_api_show_one_map_register_state_reply_t_handler
3310 (vl_api_show_one_map_register_state_reply_t * mp)
3312 vat_main_t *vam = &vat_main;
3313 int retval = clib_net_to_host_u32 (mp->retval);
3315 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3317 vam->retval = retval;
3318 vam->result_ready = 1;
3322 vl_api_show_one_map_register_state_reply_t_handler_json
3323 (vl_api_show_one_map_register_state_reply_t * mp)
3325 vat_main_t *vam = &vat_main;
3326 vat_json_node_t _node, *node = &_node;
3327 int retval = clib_net_to_host_u32 (mp->retval);
3329 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3331 vat_json_init_object (node);
3332 vat_json_object_add_string_copy (node, "state", s);
3334 vat_json_print (vam->ofp, node);
3335 vat_json_free (node);
3337 vam->retval = retval;
3338 vam->result_ready = 1;
3343 vl_api_show_one_rloc_probe_state_reply_t_handler
3344 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3346 vat_main_t *vam = &vat_main;
3347 int retval = clib_net_to_host_u32 (mp->retval);
3352 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3354 vam->retval = retval;
3355 vam->result_ready = 1;
3359 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3360 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3362 vat_main_t *vam = &vat_main;
3363 vat_json_node_t _node, *node = &_node;
3364 int retval = clib_net_to_host_u32 (mp->retval);
3366 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3367 vat_json_init_object (node);
3368 vat_json_object_add_string_copy (node, "state", s);
3370 vat_json_print (vam->ofp, node);
3371 vat_json_free (node);
3373 vam->retval = retval;
3374 vam->result_ready = 1;
3379 vl_api_show_one_stats_enable_disable_reply_t_handler
3380 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3382 vat_main_t *vam = &vat_main;
3383 int retval = clib_net_to_host_u32 (mp->retval);
3388 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3390 vam->retval = retval;
3391 vam->result_ready = 1;
3395 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3396 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3398 vat_main_t *vam = &vat_main;
3399 vat_json_node_t _node, *node = &_node;
3400 int retval = clib_net_to_host_u32 (mp->retval);
3402 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3403 vat_json_init_object (node);
3404 vat_json_object_add_string_copy (node, "state", s);
3406 vat_json_print (vam->ofp, node);
3407 vat_json_free (node);
3409 vam->retval = retval;
3410 vam->result_ready = 1;
3415 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3417 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3418 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3419 e->vni = clib_net_to_host_u32 (e->vni);
3423 gpe_fwd_entries_get_reply_t_net_to_host
3424 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3428 mp->count = clib_net_to_host_u32 (mp->count);
3429 for (i = 0; i < mp->count; i++)
3431 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3436 format_gpe_encap_mode (u8 * s, va_list * args)
3438 u32 mode = va_arg (*args, u32);
3443 return format (s, "lisp");
3445 return format (s, "vxlan");
3451 vl_api_gpe_get_encap_mode_reply_t_handler
3452 (vl_api_gpe_get_encap_mode_reply_t * mp)
3454 vat_main_t *vam = &vat_main;
3456 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3457 vam->retval = ntohl (mp->retval);
3458 vam->result_ready = 1;
3462 vl_api_gpe_get_encap_mode_reply_t_handler_json
3463 (vl_api_gpe_get_encap_mode_reply_t * mp)
3465 vat_main_t *vam = &vat_main;
3466 vat_json_node_t node;
3468 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3469 vec_add1 (encap_mode, 0);
3471 vat_json_init_object (&node);
3472 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3474 vec_free (encap_mode);
3475 vat_json_print (vam->ofp, &node);
3476 vat_json_free (&node);
3478 vam->retval = ntohl (mp->retval);
3479 vam->result_ready = 1;
3483 vl_api_gpe_fwd_entry_path_details_t_handler
3484 (vl_api_gpe_fwd_entry_path_details_t * mp)
3486 vat_main_t *vam = &vat_main;
3487 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3489 if (mp->lcl_loc.is_ip4)
3490 format_ip_address_fcn = format_ip4_address;
3492 format_ip_address_fcn = format_ip6_address;
3494 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3495 format_ip_address_fcn, &mp->lcl_loc,
3496 format_ip_address_fcn, &mp->rmt_loc);
3500 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3502 struct in6_addr ip6;
3507 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3508 vat_json_object_add_ip4 (n, "address", ip4);
3512 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3513 vat_json_object_add_ip6 (n, "address", ip6);
3515 vat_json_object_add_uint (n, "weight", loc->weight);
3519 vl_api_gpe_fwd_entry_path_details_t_handler_json
3520 (vl_api_gpe_fwd_entry_path_details_t * mp)
3522 vat_main_t *vam = &vat_main;
3523 vat_json_node_t *node = NULL;
3524 vat_json_node_t *loc_node;
3526 if (VAT_JSON_ARRAY != vam->json_tree.type)
3528 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3529 vat_json_init_array (&vam->json_tree);
3531 node = vat_json_array_add (&vam->json_tree);
3532 vat_json_init_object (node);
3534 loc_node = vat_json_object_add (node, "local_locator");
3535 vat_json_init_object (loc_node);
3536 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3538 loc_node = vat_json_object_add (node, "remote_locator");
3539 vat_json_init_object (loc_node);
3540 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3544 vl_api_gpe_fwd_entries_get_reply_t_handler
3545 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3547 vat_main_t *vam = &vat_main;
3549 int retval = clib_net_to_host_u32 (mp->retval);
3550 vl_api_gpe_fwd_entry_t *e;
3555 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3557 for (i = 0; i < mp->count; i++)
3559 e = &mp->entries[i];
3560 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3561 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3562 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3566 vam->retval = retval;
3567 vam->result_ready = 1;
3571 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3572 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3575 vat_main_t *vam = &vat_main;
3576 vat_json_node_t *e = 0, root;
3578 int retval = clib_net_to_host_u32 (mp->retval);
3579 vl_api_gpe_fwd_entry_t *fwd;
3584 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3585 vat_json_init_array (&root);
3587 for (i = 0; i < mp->count; i++)
3589 e = vat_json_array_add (&root);
3590 fwd = &mp->entries[i];
3592 vat_json_init_object (e);
3593 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3594 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3595 vat_json_object_add_int (e, "vni", fwd->vni);
3596 vat_json_object_add_int (e, "action", fwd->action);
3598 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3599 fwd->leid_prefix_len);
3601 vat_json_object_add_string_copy (e, "leid", s);
3604 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3605 fwd->reid_prefix_len);
3607 vat_json_object_add_string_copy (e, "reid", s);
3611 vat_json_print (vam->ofp, &root);
3612 vat_json_free (&root);
3615 vam->retval = retval;
3616 vam->result_ready = 1;
3620 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3621 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3623 vat_main_t *vam = &vat_main;
3625 int retval = clib_net_to_host_u32 (mp->retval);
3626 vl_api_gpe_native_fwd_rpath_t *r;
3631 n = clib_net_to_host_u32 (mp->count);
3633 for (i = 0; i < n; i++)
3635 r = &mp->entries[i];
3636 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3637 clib_net_to_host_u32 (r->fib_index),
3638 clib_net_to_host_u32 (r->nh_sw_if_index),
3639 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3643 vam->retval = retval;
3644 vam->result_ready = 1;
3648 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3649 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3651 vat_main_t *vam = &vat_main;
3652 vat_json_node_t root, *e;
3654 int retval = clib_net_to_host_u32 (mp->retval);
3655 vl_api_gpe_native_fwd_rpath_t *r;
3661 n = clib_net_to_host_u32 (mp->count);
3662 vat_json_init_array (&root);
3664 for (i = 0; i < n; i++)
3666 e = vat_json_array_add (&root);
3667 vat_json_init_object (e);
3668 r = &mp->entries[i];
3670 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3673 vat_json_object_add_string_copy (e, "ip4", s);
3676 vat_json_object_add_uint (e, "fib_index",
3677 clib_net_to_host_u32 (r->fib_index));
3678 vat_json_object_add_uint (e, "nh_sw_if_index",
3679 clib_net_to_host_u32 (r->nh_sw_if_index));
3682 vat_json_print (vam->ofp, &root);
3683 vat_json_free (&root);
3686 vam->retval = retval;
3687 vam->result_ready = 1;
3691 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3692 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3694 vat_main_t *vam = &vat_main;
3696 int retval = clib_net_to_host_u32 (mp->retval);
3701 n = clib_net_to_host_u32 (mp->count);
3703 for (i = 0; i < n; i++)
3704 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3707 vam->retval = retval;
3708 vam->result_ready = 1;
3712 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3713 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3715 vat_main_t *vam = &vat_main;
3716 vat_json_node_t root;
3718 int retval = clib_net_to_host_u32 (mp->retval);
3723 n = clib_net_to_host_u32 (mp->count);
3724 vat_json_init_array (&root);
3726 for (i = 0; i < n; i++)
3727 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3729 vat_json_print (vam->ofp, &root);
3730 vat_json_free (&root);
3733 vam->retval = retval;
3734 vam->result_ready = 1;
3738 vl_api_one_ndp_entries_get_reply_t_handler
3739 (vl_api_one_ndp_entries_get_reply_t * mp)
3741 vat_main_t *vam = &vat_main;
3743 int retval = clib_net_to_host_u32 (mp->retval);
3748 n = clib_net_to_host_u32 (mp->count);
3750 for (i = 0; i < n; i++)
3751 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3752 format_ethernet_address, mp->entries[i].mac);
3755 vam->retval = retval;
3756 vam->result_ready = 1;
3760 vl_api_one_ndp_entries_get_reply_t_handler_json
3761 (vl_api_one_ndp_entries_get_reply_t * mp)
3764 vat_main_t *vam = &vat_main;
3765 vat_json_node_t *e = 0, root;
3767 int retval = clib_net_to_host_u32 (mp->retval);
3768 vl_api_one_ndp_entry_t *arp_entry;
3773 n = clib_net_to_host_u32 (mp->count);
3774 vat_json_init_array (&root);
3776 for (i = 0; i < n; i++)
3778 e = vat_json_array_add (&root);
3779 arp_entry = &mp->entries[i];
3781 vat_json_init_object (e);
3782 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3785 vat_json_object_add_string_copy (e, "mac", s);
3788 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3790 vat_json_object_add_string_copy (e, "ip6", s);
3794 vat_json_print (vam->ofp, &root);
3795 vat_json_free (&root);
3798 vam->retval = retval;
3799 vam->result_ready = 1;
3803 vl_api_one_l2_arp_entries_get_reply_t_handler
3804 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3806 vat_main_t *vam = &vat_main;
3808 int retval = clib_net_to_host_u32 (mp->retval);
3813 n = clib_net_to_host_u32 (mp->count);
3815 for (i = 0; i < n; i++)
3816 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3817 format_ethernet_address, mp->entries[i].mac);
3820 vam->retval = retval;
3821 vam->result_ready = 1;
3825 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3826 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3829 vat_main_t *vam = &vat_main;
3830 vat_json_node_t *e = 0, root;
3832 int retval = clib_net_to_host_u32 (mp->retval);
3833 vl_api_one_l2_arp_entry_t *arp_entry;
3838 n = clib_net_to_host_u32 (mp->count);
3839 vat_json_init_array (&root);
3841 for (i = 0; i < n; i++)
3843 e = vat_json_array_add (&root);
3844 arp_entry = &mp->entries[i];
3846 vat_json_init_object (e);
3847 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3850 vat_json_object_add_string_copy (e, "mac", s);
3853 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3855 vat_json_object_add_string_copy (e, "ip4", s);
3859 vat_json_print (vam->ofp, &root);
3860 vat_json_free (&root);
3863 vam->retval = retval;
3864 vam->result_ready = 1;
3868 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
3870 vat_main_t *vam = &vat_main;
3872 int retval = clib_net_to_host_u32 (mp->retval);
3877 n = clib_net_to_host_u32 (mp->count);
3879 for (i = 0; i < n; i++)
3881 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3885 vam->retval = retval;
3886 vam->result_ready = 1;
3890 vl_api_one_ndp_bd_get_reply_t_handler_json
3891 (vl_api_one_ndp_bd_get_reply_t * mp)
3893 vat_main_t *vam = &vat_main;
3894 vat_json_node_t root;
3896 int retval = clib_net_to_host_u32 (mp->retval);
3901 n = clib_net_to_host_u32 (mp->count);
3902 vat_json_init_array (&root);
3904 for (i = 0; i < n; i++)
3906 vat_json_array_add_uint (&root,
3907 clib_net_to_host_u32 (mp->bridge_domains[i]));
3910 vat_json_print (vam->ofp, &root);
3911 vat_json_free (&root);
3914 vam->retval = retval;
3915 vam->result_ready = 1;
3919 vl_api_one_l2_arp_bd_get_reply_t_handler
3920 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3922 vat_main_t *vam = &vat_main;
3924 int retval = clib_net_to_host_u32 (mp->retval);
3929 n = clib_net_to_host_u32 (mp->count);
3931 for (i = 0; i < n; i++)
3933 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3937 vam->retval = retval;
3938 vam->result_ready = 1;
3942 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3943 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3945 vat_main_t *vam = &vat_main;
3946 vat_json_node_t root;
3948 int retval = clib_net_to_host_u32 (mp->retval);
3953 n = clib_net_to_host_u32 (mp->count);
3954 vat_json_init_array (&root);
3956 for (i = 0; i < n; i++)
3958 vat_json_array_add_uint (&root,
3959 clib_net_to_host_u32 (mp->bridge_domains[i]));
3962 vat_json_print (vam->ofp, &root);
3963 vat_json_free (&root);
3966 vam->retval = retval;
3967 vam->result_ready = 1;
3971 vl_api_one_adjacencies_get_reply_t_handler
3972 (vl_api_one_adjacencies_get_reply_t * mp)
3974 vat_main_t *vam = &vat_main;
3976 int retval = clib_net_to_host_u32 (mp->retval);
3977 vl_api_one_adjacency_t *a;
3982 n = clib_net_to_host_u32 (mp->count);
3984 for (i = 0; i < n; i++)
3986 a = &mp->adjacencies[i];
3987 print (vam->ofp, "%U %40U",
3988 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3989 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3993 vam->retval = retval;
3994 vam->result_ready = 1;
3998 vl_api_one_adjacencies_get_reply_t_handler_json
3999 (vl_api_one_adjacencies_get_reply_t * mp)
4002 vat_main_t *vam = &vat_main;
4003 vat_json_node_t *e = 0, root;
4005 int retval = clib_net_to_host_u32 (mp->retval);
4006 vl_api_one_adjacency_t *a;
4011 n = clib_net_to_host_u32 (mp->count);
4012 vat_json_init_array (&root);
4014 for (i = 0; i < n; i++)
4016 e = vat_json_array_add (&root);
4017 a = &mp->adjacencies[i];
4019 vat_json_init_object (e);
4020 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
4021 a->leid_prefix_len);
4023 vat_json_object_add_string_copy (e, "leid", s);
4026 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
4027 a->reid_prefix_len);
4029 vat_json_object_add_string_copy (e, "reid", s);
4033 vat_json_print (vam->ofp, &root);
4034 vat_json_free (&root);
4037 vam->retval = retval;
4038 vam->result_ready = 1;
4042 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
4044 vat_main_t *vam = &vat_main;
4046 print (vam->ofp, "%=20U",
4047 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4052 vl_api_one_map_server_details_t_handler_json
4053 (vl_api_one_map_server_details_t * mp)
4055 vat_main_t *vam = &vat_main;
4056 vat_json_node_t *node = NULL;
4057 struct in6_addr ip6;
4060 if (VAT_JSON_ARRAY != vam->json_tree.type)
4062 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4063 vat_json_init_array (&vam->json_tree);
4065 node = vat_json_array_add (&vam->json_tree);
4067 vat_json_init_object (node);
4070 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4071 vat_json_object_add_ip6 (node, "map-server", ip6);
4075 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4076 vat_json_object_add_ip4 (node, "map-server", ip4);
4081 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4084 vat_main_t *vam = &vat_main;
4086 print (vam->ofp, "%=20U",
4087 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4092 vl_api_one_map_resolver_details_t_handler_json
4093 (vl_api_one_map_resolver_details_t * mp)
4095 vat_main_t *vam = &vat_main;
4096 vat_json_node_t *node = NULL;
4097 struct in6_addr ip6;
4100 if (VAT_JSON_ARRAY != vam->json_tree.type)
4102 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4103 vat_json_init_array (&vam->json_tree);
4105 node = vat_json_array_add (&vam->json_tree);
4107 vat_json_init_object (node);
4110 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4111 vat_json_object_add_ip6 (node, "map resolver", ip6);
4115 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4116 vat_json_object_add_ip4 (node, "map resolver", ip4);
4121 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4123 vat_main_t *vam = &vat_main;
4124 i32 retval = ntohl (mp->retval);
4128 print (vam->ofp, "feature: %s\ngpe: %s",
4129 mp->feature_status ? "enabled" : "disabled",
4130 mp->gpe_status ? "enabled" : "disabled");
4133 vam->retval = retval;
4134 vam->result_ready = 1;
4138 vl_api_show_one_status_reply_t_handler_json
4139 (vl_api_show_one_status_reply_t * mp)
4141 vat_main_t *vam = &vat_main;
4142 vat_json_node_t node;
4143 u8 *gpe_status = NULL;
4144 u8 *feature_status = NULL;
4146 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4147 feature_status = format (0, "%s",
4148 mp->feature_status ? "enabled" : "disabled");
4149 vec_add1 (gpe_status, 0);
4150 vec_add1 (feature_status, 0);
4152 vat_json_init_object (&node);
4153 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4154 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4156 vec_free (gpe_status);
4157 vec_free (feature_status);
4159 vat_json_print (vam->ofp, &node);
4160 vat_json_free (&node);
4162 vam->retval = ntohl (mp->retval);
4163 vam->result_ready = 1;
4167 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4168 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4170 vat_main_t *vam = &vat_main;
4171 i32 retval = ntohl (mp->retval);
4175 print (vam->ofp, "%=20s", mp->locator_set_name);
4178 vam->retval = retval;
4179 vam->result_ready = 1;
4183 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4184 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4186 vat_main_t *vam = &vat_main;
4187 vat_json_node_t *node = NULL;
4189 if (VAT_JSON_ARRAY != vam->json_tree.type)
4191 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4192 vat_json_init_array (&vam->json_tree);
4194 node = vat_json_array_add (&vam->json_tree);
4196 vat_json_init_object (node);
4197 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4199 vat_json_print (vam->ofp, node);
4200 vat_json_free (node);
4202 vam->retval = ntohl (mp->retval);
4203 vam->result_ready = 1;
4207 format_lisp_map_request_mode (u8 * s, va_list * args)
4209 u32 mode = va_arg (*args, u32);
4214 return format (0, "dst-only");
4216 return format (0, "src-dst");
4222 vl_api_show_one_map_request_mode_reply_t_handler
4223 (vl_api_show_one_map_request_mode_reply_t * mp)
4225 vat_main_t *vam = &vat_main;
4226 i32 retval = ntohl (mp->retval);
4230 u32 mode = mp->mode;
4231 print (vam->ofp, "map_request_mode: %U",
4232 format_lisp_map_request_mode, mode);
4235 vam->retval = retval;
4236 vam->result_ready = 1;
4240 vl_api_show_one_map_request_mode_reply_t_handler_json
4241 (vl_api_show_one_map_request_mode_reply_t * mp)
4243 vat_main_t *vam = &vat_main;
4244 vat_json_node_t node;
4249 s = format (0, "%U", format_lisp_map_request_mode, mode);
4252 vat_json_init_object (&node);
4253 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4254 vat_json_print (vam->ofp, &node);
4255 vat_json_free (&node);
4258 vam->retval = ntohl (mp->retval);
4259 vam->result_ready = 1;
4263 vl_api_one_show_xtr_mode_reply_t_handler
4264 (vl_api_one_show_xtr_mode_reply_t * mp)
4266 vat_main_t *vam = &vat_main;
4267 i32 retval = ntohl (mp->retval);
4271 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4274 vam->retval = retval;
4275 vam->result_ready = 1;
4279 vl_api_one_show_xtr_mode_reply_t_handler_json
4280 (vl_api_one_show_xtr_mode_reply_t * mp)
4282 vat_main_t *vam = &vat_main;
4283 vat_json_node_t node;
4286 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4287 vec_add1 (status, 0);
4289 vat_json_init_object (&node);
4290 vat_json_object_add_string_copy (&node, "status", status);
4294 vat_json_print (vam->ofp, &node);
4295 vat_json_free (&node);
4297 vam->retval = ntohl (mp->retval);
4298 vam->result_ready = 1;
4302 vl_api_one_show_pitr_mode_reply_t_handler
4303 (vl_api_one_show_pitr_mode_reply_t * mp)
4305 vat_main_t *vam = &vat_main;
4306 i32 retval = ntohl (mp->retval);
4310 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4313 vam->retval = retval;
4314 vam->result_ready = 1;
4318 vl_api_one_show_pitr_mode_reply_t_handler_json
4319 (vl_api_one_show_pitr_mode_reply_t * mp)
4321 vat_main_t *vam = &vat_main;
4322 vat_json_node_t node;
4325 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4326 vec_add1 (status, 0);
4328 vat_json_init_object (&node);
4329 vat_json_object_add_string_copy (&node, "status", status);
4333 vat_json_print (vam->ofp, &node);
4334 vat_json_free (&node);
4336 vam->retval = ntohl (mp->retval);
4337 vam->result_ready = 1;
4341 vl_api_one_show_petr_mode_reply_t_handler
4342 (vl_api_one_show_petr_mode_reply_t * mp)
4344 vat_main_t *vam = &vat_main;
4345 i32 retval = ntohl (mp->retval);
4349 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4352 vam->retval = retval;
4353 vam->result_ready = 1;
4357 vl_api_one_show_petr_mode_reply_t_handler_json
4358 (vl_api_one_show_petr_mode_reply_t * mp)
4360 vat_main_t *vam = &vat_main;
4361 vat_json_node_t node;
4364 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4365 vec_add1 (status, 0);
4367 vat_json_init_object (&node);
4368 vat_json_object_add_string_copy (&node, "status", status);
4372 vat_json_print (vam->ofp, &node);
4373 vat_json_free (&node);
4375 vam->retval = ntohl (mp->retval);
4376 vam->result_ready = 1;
4380 vl_api_show_one_use_petr_reply_t_handler
4381 (vl_api_show_one_use_petr_reply_t * mp)
4383 vat_main_t *vam = &vat_main;
4384 i32 retval = ntohl (mp->retval);
4388 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4391 print (vam->ofp, "Proxy-ETR address; %U",
4392 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4397 vam->retval = retval;
4398 vam->result_ready = 1;
4402 vl_api_show_one_use_petr_reply_t_handler_json
4403 (vl_api_show_one_use_petr_reply_t * mp)
4405 vat_main_t *vam = &vat_main;
4406 vat_json_node_t node;
4409 struct in6_addr ip6;
4411 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4412 vec_add1 (status, 0);
4414 vat_json_init_object (&node);
4415 vat_json_object_add_string_copy (&node, "status", status);
4420 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4421 vat_json_object_add_ip6 (&node, "address", ip6);
4425 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4426 vat_json_object_add_ip4 (&node, "address", ip4);
4432 vat_json_print (vam->ofp, &node);
4433 vat_json_free (&node);
4435 vam->retval = ntohl (mp->retval);
4436 vam->result_ready = 1;
4440 vl_api_show_one_nsh_mapping_reply_t_handler
4441 (vl_api_show_one_nsh_mapping_reply_t * mp)
4443 vat_main_t *vam = &vat_main;
4444 i32 retval = ntohl (mp->retval);
4448 print (vam->ofp, "%-20s%-16s",
4449 mp->is_set ? "set" : "not-set",
4450 mp->is_set ? (char *) mp->locator_set_name : "");
4453 vam->retval = retval;
4454 vam->result_ready = 1;
4458 vl_api_show_one_nsh_mapping_reply_t_handler_json
4459 (vl_api_show_one_nsh_mapping_reply_t * mp)
4461 vat_main_t *vam = &vat_main;
4462 vat_json_node_t node;
4465 status = format (0, "%s", mp->is_set ? "yes" : "no");
4466 vec_add1 (status, 0);
4468 vat_json_init_object (&node);
4469 vat_json_object_add_string_copy (&node, "is_set", status);
4472 vat_json_object_add_string_copy (&node, "locator_set",
4473 mp->locator_set_name);
4478 vat_json_print (vam->ofp, &node);
4479 vat_json_free (&node);
4481 vam->retval = ntohl (mp->retval);
4482 vam->result_ready = 1;
4486 vl_api_show_one_map_register_ttl_reply_t_handler
4487 (vl_api_show_one_map_register_ttl_reply_t * mp)
4489 vat_main_t *vam = &vat_main;
4490 i32 retval = ntohl (mp->retval);
4492 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4496 print (vam->ofp, "ttl: %u", mp->ttl);
4499 vam->retval = retval;
4500 vam->result_ready = 1;
4504 vl_api_show_one_map_register_ttl_reply_t_handler_json
4505 (vl_api_show_one_map_register_ttl_reply_t * mp)
4507 vat_main_t *vam = &vat_main;
4508 vat_json_node_t node;
4510 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4511 vat_json_init_object (&node);
4512 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4514 vat_json_print (vam->ofp, &node);
4515 vat_json_free (&node);
4517 vam->retval = ntohl (mp->retval);
4518 vam->result_ready = 1;
4522 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4524 vat_main_t *vam = &vat_main;
4525 i32 retval = ntohl (mp->retval);
4529 print (vam->ofp, "%-20s%-16s",
4530 mp->status ? "enabled" : "disabled",
4531 mp->status ? (char *) mp->locator_set_name : "");
4534 vam->retval = retval;
4535 vam->result_ready = 1;
4539 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4541 vat_main_t *vam = &vat_main;
4542 vat_json_node_t node;
4545 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4546 vec_add1 (status, 0);
4548 vat_json_init_object (&node);
4549 vat_json_object_add_string_copy (&node, "status", status);
4552 vat_json_object_add_string_copy (&node, "locator_set",
4553 mp->locator_set_name);
4558 vat_json_print (vam->ofp, &node);
4559 vat_json_free (&node);
4561 vam->retval = ntohl (mp->retval);
4562 vam->result_ready = 1;
4566 format_policer_type (u8 * s, va_list * va)
4568 u32 i = va_arg (*va, u32);
4570 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4571 s = format (s, "1r2c");
4572 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4573 s = format (s, "1r3c");
4574 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4575 s = format (s, "2r3c-2698");
4576 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4577 s = format (s, "2r3c-4115");
4578 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4579 s = format (s, "2r3c-mef5cf1");
4581 s = format (s, "ILLEGAL");
4586 format_policer_rate_type (u8 * s, va_list * va)
4588 u32 i = va_arg (*va, u32);
4590 if (i == SSE2_QOS_RATE_KBPS)
4591 s = format (s, "kbps");
4592 else if (i == SSE2_QOS_RATE_PPS)
4593 s = format (s, "pps");
4595 s = format (s, "ILLEGAL");
4600 format_policer_round_type (u8 * s, va_list * va)
4602 u32 i = va_arg (*va, u32);
4604 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4605 s = format (s, "closest");
4606 else if (i == SSE2_QOS_ROUND_TO_UP)
4607 s = format (s, "up");
4608 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4609 s = format (s, "down");
4611 s = format (s, "ILLEGAL");
4616 format_policer_action_type (u8 * s, va_list * va)
4618 u32 i = va_arg (*va, u32);
4620 if (i == SSE2_QOS_ACTION_DROP)
4621 s = format (s, "drop");
4622 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4623 s = format (s, "transmit");
4624 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4625 s = format (s, "mark-and-transmit");
4627 s = format (s, "ILLEGAL");
4632 format_dscp (u8 * s, va_list * va)
4634 u32 i = va_arg (*va, u32);
4639 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4643 return format (s, "ILLEGAL");
4645 s = format (s, "%s", t);
4650 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4652 vat_main_t *vam = &vat_main;
4653 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4655 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4656 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4658 conform_dscp_str = format (0, "");
4660 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4661 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4663 exceed_dscp_str = format (0, "");
4665 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4666 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4668 violate_dscp_str = format (0, "");
4670 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4671 "rate type %U, round type %U, %s rate, %s color-aware, "
4672 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4673 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4674 "conform action %U%s, exceed action %U%s, violate action %U%s",
4676 format_policer_type, mp->type,
4679 clib_net_to_host_u64 (mp->cb),
4680 clib_net_to_host_u64 (mp->eb),
4681 format_policer_rate_type, mp->rate_type,
4682 format_policer_round_type, mp->round_type,
4683 mp->single_rate ? "single" : "dual",
4684 mp->color_aware ? "is" : "not",
4685 ntohl (mp->cir_tokens_per_period),
4686 ntohl (mp->pir_tokens_per_period),
4688 ntohl (mp->current_limit),
4689 ntohl (mp->current_bucket),
4690 ntohl (mp->extended_limit),
4691 ntohl (mp->extended_bucket),
4692 clib_net_to_host_u64 (mp->last_update_time),
4693 format_policer_action_type, mp->conform_action_type,
4695 format_policer_action_type, mp->exceed_action_type,
4697 format_policer_action_type, mp->violate_action_type,
4700 vec_free (conform_dscp_str);
4701 vec_free (exceed_dscp_str);
4702 vec_free (violate_dscp_str);
4705 static void vl_api_policer_details_t_handler_json
4706 (vl_api_policer_details_t * mp)
4708 vat_main_t *vam = &vat_main;
4709 vat_json_node_t *node;
4710 u8 *rate_type_str, *round_type_str, *type_str;
4711 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4713 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4715 format (0, "%U", format_policer_round_type, mp->round_type);
4716 type_str = format (0, "%U", format_policer_type, mp->type);
4717 conform_action_str = format (0, "%U", format_policer_action_type,
4718 mp->conform_action_type);
4719 exceed_action_str = format (0, "%U", format_policer_action_type,
4720 mp->exceed_action_type);
4721 violate_action_str = format (0, "%U", format_policer_action_type,
4722 mp->violate_action_type);
4724 if (VAT_JSON_ARRAY != vam->json_tree.type)
4726 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4727 vat_json_init_array (&vam->json_tree);
4729 node = vat_json_array_add (&vam->json_tree);
4731 vat_json_init_object (node);
4732 vat_json_object_add_string_copy (node, "name", mp->name);
4733 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4734 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4735 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4736 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4737 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4738 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4739 vat_json_object_add_string_copy (node, "type", type_str);
4740 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4741 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4742 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4743 vat_json_object_add_uint (node, "cir_tokens_per_period",
4744 ntohl (mp->cir_tokens_per_period));
4745 vat_json_object_add_uint (node, "eir_tokens_per_period",
4746 ntohl (mp->pir_tokens_per_period));
4747 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4748 vat_json_object_add_uint (node, "current_bucket",
4749 ntohl (mp->current_bucket));
4750 vat_json_object_add_uint (node, "extended_limit",
4751 ntohl (mp->extended_limit));
4752 vat_json_object_add_uint (node, "extended_bucket",
4753 ntohl (mp->extended_bucket));
4754 vat_json_object_add_uint (node, "last_update_time",
4755 ntohl (mp->last_update_time));
4756 vat_json_object_add_string_copy (node, "conform_action",
4757 conform_action_str);
4758 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4760 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4761 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4762 vec_free (dscp_str);
4764 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4765 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4767 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4768 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4769 vec_free (dscp_str);
4771 vat_json_object_add_string_copy (node, "violate_action",
4772 violate_action_str);
4773 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4775 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4776 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4777 vec_free (dscp_str);
4780 vec_free (rate_type_str);
4781 vec_free (round_type_str);
4782 vec_free (type_str);
4783 vec_free (conform_action_str);
4784 vec_free (exceed_action_str);
4785 vec_free (violate_action_str);
4789 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4792 vat_main_t *vam = &vat_main;
4793 int i, count = ntohl (mp->count);
4796 print (vam->ofp, "classify table ids (%d) : ", count);
4797 for (i = 0; i < count; i++)
4799 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4800 print (vam->ofp, (i < count - 1) ? "," : "");
4802 vam->retval = ntohl (mp->retval);
4803 vam->result_ready = 1;
4807 vl_api_classify_table_ids_reply_t_handler_json
4808 (vl_api_classify_table_ids_reply_t * mp)
4810 vat_main_t *vam = &vat_main;
4811 int i, count = ntohl (mp->count);
4815 vat_json_node_t node;
4817 vat_json_init_object (&node);
4818 for (i = 0; i < count; i++)
4820 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4822 vat_json_print (vam->ofp, &node);
4823 vat_json_free (&node);
4825 vam->retval = ntohl (mp->retval);
4826 vam->result_ready = 1;
4830 vl_api_classify_table_by_interface_reply_t_handler
4831 (vl_api_classify_table_by_interface_reply_t * mp)
4833 vat_main_t *vam = &vat_main;
4836 table_id = ntohl (mp->l2_table_id);
4838 print (vam->ofp, "l2 table id : %d", table_id);
4840 print (vam->ofp, "l2 table id : No input ACL tables configured");
4841 table_id = ntohl (mp->ip4_table_id);
4843 print (vam->ofp, "ip4 table id : %d", table_id);
4845 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4846 table_id = ntohl (mp->ip6_table_id);
4848 print (vam->ofp, "ip6 table id : %d", table_id);
4850 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4851 vam->retval = ntohl (mp->retval);
4852 vam->result_ready = 1;
4856 vl_api_classify_table_by_interface_reply_t_handler_json
4857 (vl_api_classify_table_by_interface_reply_t * mp)
4859 vat_main_t *vam = &vat_main;
4860 vat_json_node_t node;
4862 vat_json_init_object (&node);
4864 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4865 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4866 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4868 vat_json_print (vam->ofp, &node);
4869 vat_json_free (&node);
4871 vam->retval = ntohl (mp->retval);
4872 vam->result_ready = 1;
4875 static void vl_api_policer_add_del_reply_t_handler
4876 (vl_api_policer_add_del_reply_t * mp)
4878 vat_main_t *vam = &vat_main;
4879 i32 retval = ntohl (mp->retval);
4880 if (vam->async_mode)
4882 vam->async_errors += (retval < 0);
4886 vam->retval = retval;
4887 vam->result_ready = 1;
4888 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4890 * Note: this is just barely thread-safe, depends on
4891 * the main thread spinning waiting for an answer...
4893 errmsg ("policer index %d", ntohl (mp->policer_index));
4897 static void vl_api_policer_add_del_reply_t_handler_json
4898 (vl_api_policer_add_del_reply_t * mp)
4900 vat_main_t *vam = &vat_main;
4901 vat_json_node_t node;
4903 vat_json_init_object (&node);
4904 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4905 vat_json_object_add_uint (&node, "policer_index",
4906 ntohl (mp->policer_index));
4908 vat_json_print (vam->ofp, &node);
4909 vat_json_free (&node);
4911 vam->retval = ntohl (mp->retval);
4912 vam->result_ready = 1;
4915 /* Format hex dump. */
4917 format_hex_bytes (u8 * s, va_list * va)
4919 u8 *bytes = va_arg (*va, u8 *);
4920 int n_bytes = va_arg (*va, int);
4923 /* Print short or long form depending on byte count. */
4924 uword short_form = n_bytes <= 32;
4925 u32 indent = format_get_indent (s);
4930 for (i = 0; i < n_bytes; i++)
4932 if (!short_form && (i % 32) == 0)
4933 s = format (s, "%08x: ", i);
4934 s = format (s, "%02x", bytes[i]);
4935 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4936 s = format (s, "\n%U", format_white_space, indent);
4943 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4946 vat_main_t *vam = &vat_main;
4947 i32 retval = ntohl (mp->retval);
4950 print (vam->ofp, "classify table info :");
4951 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4952 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4953 ntohl (mp->miss_next_index));
4954 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4955 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4956 ntohl (mp->match_n_vectors));
4957 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4958 ntohl (mp->mask_length));
4960 vam->retval = retval;
4961 vam->result_ready = 1;
4965 vl_api_classify_table_info_reply_t_handler_json
4966 (vl_api_classify_table_info_reply_t * mp)
4968 vat_main_t *vam = &vat_main;
4969 vat_json_node_t node;
4971 i32 retval = ntohl (mp->retval);
4974 vat_json_init_object (&node);
4976 vat_json_object_add_int (&node, "sessions",
4977 ntohl (mp->active_sessions));
4978 vat_json_object_add_int (&node, "nexttbl",
4979 ntohl (mp->next_table_index));
4980 vat_json_object_add_int (&node, "nextnode",
4981 ntohl (mp->miss_next_index));
4982 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4983 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4984 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4985 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4986 ntohl (mp->mask_length), 0);
4987 vat_json_object_add_string_copy (&node, "mask", s);
4989 vat_json_print (vam->ofp, &node);
4990 vat_json_free (&node);
4992 vam->retval = ntohl (mp->retval);
4993 vam->result_ready = 1;
4997 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
5000 vat_main_t *vam = &vat_main;
5002 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
5003 ntohl (mp->hit_next_index), ntohl (mp->advance),
5004 ntohl (mp->opaque_index));
5005 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
5006 ntohl (mp->match_length));
5010 vl_api_classify_session_details_t_handler_json
5011 (vl_api_classify_session_details_t * mp)
5013 vat_main_t *vam = &vat_main;
5014 vat_json_node_t *node = NULL;
5016 if (VAT_JSON_ARRAY != vam->json_tree.type)
5018 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5019 vat_json_init_array (&vam->json_tree);
5021 node = vat_json_array_add (&vam->json_tree);
5023 vat_json_init_object (node);
5024 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
5025 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
5026 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
5028 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
5030 vat_json_object_add_string_copy (node, "match", s);
5033 static void vl_api_pg_create_interface_reply_t_handler
5034 (vl_api_pg_create_interface_reply_t * mp)
5036 vat_main_t *vam = &vat_main;
5038 vam->retval = ntohl (mp->retval);
5039 vam->result_ready = 1;
5042 static void vl_api_pg_create_interface_reply_t_handler_json
5043 (vl_api_pg_create_interface_reply_t * mp)
5045 vat_main_t *vam = &vat_main;
5046 vat_json_node_t node;
5048 i32 retval = ntohl (mp->retval);
5051 vat_json_init_object (&node);
5053 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
5055 vat_json_print (vam->ofp, &node);
5056 vat_json_free (&node);
5058 vam->retval = ntohl (mp->retval);
5059 vam->result_ready = 1;
5062 static void vl_api_policer_classify_details_t_handler
5063 (vl_api_policer_classify_details_t * mp)
5065 vat_main_t *vam = &vat_main;
5067 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5068 ntohl (mp->table_index));
5071 static void vl_api_policer_classify_details_t_handler_json
5072 (vl_api_policer_classify_details_t * mp)
5074 vat_main_t *vam = &vat_main;
5075 vat_json_node_t *node;
5077 if (VAT_JSON_ARRAY != vam->json_tree.type)
5079 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5080 vat_json_init_array (&vam->json_tree);
5082 node = vat_json_array_add (&vam->json_tree);
5084 vat_json_init_object (node);
5085 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5086 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5089 static void vl_api_flow_classify_details_t_handler
5090 (vl_api_flow_classify_details_t * mp)
5092 vat_main_t *vam = &vat_main;
5094 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5095 ntohl (mp->table_index));
5098 static void vl_api_flow_classify_details_t_handler_json
5099 (vl_api_flow_classify_details_t * mp)
5101 vat_main_t *vam = &vat_main;
5102 vat_json_node_t *node;
5104 if (VAT_JSON_ARRAY != vam->json_tree.type)
5106 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5107 vat_json_init_array (&vam->json_tree);
5109 node = vat_json_array_add (&vam->json_tree);
5111 vat_json_init_object (node);
5112 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5113 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5116 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5117 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5118 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5119 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5120 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5121 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5122 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5123 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5124 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5125 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5128 * Generate boilerplate reply handlers, which
5129 * dig the return value out of the xxx_reply_t API message,
5130 * stick it into vam->retval, and set vam->result_ready
5132 * Could also do this by pointing N message decode slots at
5133 * a single function, but that could break in subtle ways.
5136 #define foreach_standard_reply_retval_handler \
5137 _(sw_interface_set_flags_reply) \
5138 _(sw_interface_add_del_address_reply) \
5139 _(sw_interface_set_rx_mode_reply) \
5140 _(sw_interface_set_rx_placement_reply) \
5141 _(sw_interface_set_table_reply) \
5142 _(sw_interface_set_mpls_enable_reply) \
5143 _(sw_interface_set_vpath_reply) \
5144 _(sw_interface_set_vxlan_bypass_reply) \
5145 _(sw_interface_set_geneve_bypass_reply) \
5146 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5147 _(sw_interface_set_l2_bridge_reply) \
5148 _(bridge_domain_add_del_reply) \
5149 _(sw_interface_set_l2_xconnect_reply) \
5150 _(l2fib_add_del_reply) \
5151 _(l2fib_flush_int_reply) \
5152 _(l2fib_flush_bd_reply) \
5153 _(ip_route_add_del_reply) \
5154 _(ip_table_add_del_reply) \
5155 _(ip_mroute_add_del_reply) \
5156 _(mpls_route_add_del_reply) \
5157 _(mpls_table_add_del_reply) \
5158 _(mpls_ip_bind_unbind_reply) \
5159 _(bier_route_add_del_reply) \
5160 _(bier_table_add_del_reply) \
5161 _(proxy_arp_add_del_reply) \
5162 _(proxy_arp_intfc_enable_disable_reply) \
5163 _(sw_interface_set_unnumbered_reply) \
5164 _(ip_neighbor_add_del_reply) \
5165 _(reset_fib_reply) \
5166 _(dhcp_proxy_config_reply) \
5167 _(dhcp_proxy_set_vss_reply) \
5168 _(dhcp_client_config_reply) \
5169 _(set_ip_flow_hash_reply) \
5170 _(sw_interface_ip6_enable_disable_reply) \
5171 _(ip6nd_proxy_add_del_reply) \
5172 _(sw_interface_ip6nd_ra_prefix_reply) \
5173 _(sw_interface_ip6nd_ra_config_reply) \
5174 _(set_arp_neighbor_limit_reply) \
5175 _(l2_patch_add_del_reply) \
5176 _(sr_mpls_policy_add_reply) \
5177 _(sr_mpls_policy_mod_reply) \
5178 _(sr_mpls_policy_del_reply) \
5179 _(sr_policy_add_reply) \
5180 _(sr_policy_mod_reply) \
5181 _(sr_policy_del_reply) \
5182 _(sr_localsid_add_del_reply) \
5183 _(sr_steering_add_del_reply) \
5184 _(classify_add_del_session_reply) \
5185 _(classify_set_interface_ip_table_reply) \
5186 _(classify_set_interface_l2_tables_reply) \
5187 _(l2tpv3_set_tunnel_cookies_reply) \
5188 _(l2tpv3_interface_enable_disable_reply) \
5189 _(l2tpv3_set_lookup_key_reply) \
5190 _(l2_fib_clear_table_reply) \
5191 _(l2_interface_efp_filter_reply) \
5192 _(l2_interface_vlan_tag_rewrite_reply) \
5193 _(modify_vhost_user_if_reply) \
5194 _(delete_vhost_user_if_reply) \
5195 _(ip_probe_neighbor_reply) \
5196 _(ip_scan_neighbor_enable_disable_reply) \
5197 _(want_ip4_arp_events_reply) \
5198 _(want_ip6_nd_events_reply) \
5199 _(want_l2_macs_events_reply) \
5200 _(input_acl_set_interface_reply) \
5201 _(ipsec_spd_add_del_reply) \
5202 _(ipsec_interface_add_del_spd_reply) \
5203 _(ipsec_spd_entry_add_del_reply) \
5204 _(ipsec_sad_entry_add_del_reply) \
5205 _(ipsec_tunnel_if_add_del_reply) \
5206 _(ipsec_tunnel_if_set_sa_reply) \
5207 _(delete_loopback_reply) \
5208 _(bd_ip_mac_add_del_reply) \
5209 _(bd_ip_mac_flush_reply) \
5210 _(want_interface_events_reply) \
5211 _(cop_interface_enable_disable_reply) \
5212 _(cop_whitelist_enable_disable_reply) \
5213 _(sw_interface_clear_stats_reply) \
5214 _(ioam_enable_reply) \
5215 _(ioam_disable_reply) \
5216 _(one_add_del_locator_reply) \
5217 _(one_add_del_local_eid_reply) \
5218 _(one_add_del_remote_mapping_reply) \
5219 _(one_add_del_adjacency_reply) \
5220 _(one_add_del_map_resolver_reply) \
5221 _(one_add_del_map_server_reply) \
5222 _(one_enable_disable_reply) \
5223 _(one_rloc_probe_enable_disable_reply) \
5224 _(one_map_register_enable_disable_reply) \
5225 _(one_map_register_set_ttl_reply) \
5226 _(one_set_transport_protocol_reply) \
5227 _(one_map_register_fallback_threshold_reply) \
5228 _(one_pitr_set_locator_set_reply) \
5229 _(one_map_request_mode_reply) \
5230 _(one_add_del_map_request_itr_rlocs_reply) \
5231 _(one_eid_table_add_del_map_reply) \
5232 _(one_use_petr_reply) \
5233 _(one_stats_enable_disable_reply) \
5234 _(one_add_del_l2_arp_entry_reply) \
5235 _(one_add_del_ndp_entry_reply) \
5236 _(one_stats_flush_reply) \
5237 _(one_enable_disable_xtr_mode_reply) \
5238 _(one_enable_disable_pitr_mode_reply) \
5239 _(one_enable_disable_petr_mode_reply) \
5240 _(gpe_enable_disable_reply) \
5241 _(gpe_set_encap_mode_reply) \
5242 _(gpe_add_del_iface_reply) \
5243 _(gpe_add_del_native_fwd_rpath_reply) \
5244 _(af_packet_delete_reply) \
5245 _(policer_classify_set_interface_reply) \
5246 _(netmap_create_reply) \
5247 _(netmap_delete_reply) \
5248 _(set_ipfix_exporter_reply) \
5249 _(set_ipfix_classify_stream_reply) \
5250 _(ipfix_classify_table_add_del_reply) \
5251 _(flow_classify_set_interface_reply) \
5252 _(sw_interface_span_enable_disable_reply) \
5253 _(pg_capture_reply) \
5254 _(pg_enable_disable_reply) \
5255 _(ip_source_and_port_range_check_add_del_reply) \
5256 _(ip_source_and_port_range_check_interface_add_del_reply)\
5257 _(delete_subif_reply) \
5258 _(l2_interface_pbb_tag_rewrite_reply) \
5260 _(feature_enable_disable_reply) \
5261 _(sw_interface_tag_add_del_reply) \
5262 _(hw_interface_set_mtu_reply) \
5263 _(p2p_ethernet_add_reply) \
5264 _(p2p_ethernet_del_reply) \
5265 _(lldp_config_reply) \
5266 _(sw_interface_set_lldp_reply) \
5267 _(tcp_configure_src_addresses_reply) \
5268 _(dns_enable_disable_reply) \
5269 _(dns_name_server_add_del_reply) \
5270 _(session_rule_add_del_reply) \
5271 _(ip_container_proxy_add_del_reply) \
5272 _(output_acl_set_interface_reply) \
5273 _(qos_record_enable_disable_reply)
5276 static void vl_api_##n##_t_handler \
5277 (vl_api_##n##_t * mp) \
5279 vat_main_t * vam = &vat_main; \
5280 i32 retval = ntohl(mp->retval); \
5281 if (vam->async_mode) { \
5282 vam->async_errors += (retval < 0); \
5284 vam->retval = retval; \
5285 vam->result_ready = 1; \
5288 foreach_standard_reply_retval_handler;
5292 static void vl_api_##n##_t_handler_json \
5293 (vl_api_##n##_t * mp) \
5295 vat_main_t * vam = &vat_main; \
5296 vat_json_node_t node; \
5297 vat_json_init_object(&node); \
5298 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5299 vat_json_print(vam->ofp, &node); \
5300 vam->retval = ntohl(mp->retval); \
5301 vam->result_ready = 1; \
5303 foreach_standard_reply_retval_handler;
5307 * Table of message reply handlers, must include boilerplate handlers
5311 #define foreach_vpe_api_reply_msg \
5312 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5313 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5314 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5315 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5316 _(CONTROL_PING_REPLY, control_ping_reply) \
5317 _(CLI_REPLY, cli_reply) \
5318 _(CLI_INBAND_REPLY, cli_inband_reply) \
5319 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5320 sw_interface_add_del_address_reply) \
5321 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5322 _(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
5323 _(SW_INTERFACE_RX_PLACEMENT_DETAILS, sw_interface_rx_placement_details) \
5324 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5325 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5326 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5327 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5328 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5329 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5330 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5331 sw_interface_set_l2_xconnect_reply) \
5332 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5333 sw_interface_set_l2_bridge_reply) \
5334 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5335 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5336 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5337 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5338 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5339 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5340 _(L2_FLAGS_REPLY, l2_flags_reply) \
5341 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5342 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5343 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5344 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5345 _(VIRTIO_PCI_CREATE_REPLY, virtio_pci_create_reply) \
5346 _(VIRTIO_PCI_DELETE_REPLY, virtio_pci_delete_reply) \
5347 _(SW_INTERFACE_VIRTIO_PCI_DETAILS, sw_interface_virtio_pci_details) \
5348 _(BOND_CREATE_REPLY, bond_create_reply) \
5349 _(BOND_DELETE_REPLY, bond_delete_reply) \
5350 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5351 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5352 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5353 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5354 _(IP_ROUTE_ADD_DEL_REPLY, ip_route_add_del_reply) \
5355 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5356 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5357 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5358 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5359 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5360 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5361 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5362 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5363 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5364 proxy_arp_intfc_enable_disable_reply) \
5365 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5366 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5367 sw_interface_set_unnumbered_reply) \
5368 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5369 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5370 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5371 _(RESET_FIB_REPLY, reset_fib_reply) \
5372 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5373 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5374 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5375 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5376 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5377 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5378 sw_interface_ip6_enable_disable_reply) \
5379 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5380 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5381 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5382 sw_interface_ip6nd_ra_prefix_reply) \
5383 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5384 sw_interface_ip6nd_ra_config_reply) \
5385 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5386 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5387 _(SR_MPLS_POLICY_ADD_REPLY, sr_mpls_policy_add_reply) \
5388 _(SR_MPLS_POLICY_MOD_REPLY, sr_mpls_policy_mod_reply) \
5389 _(SR_MPLS_POLICY_DEL_REPLY, sr_mpls_policy_del_reply) \
5390 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5391 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5392 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5393 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5394 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5395 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5396 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5397 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5398 classify_set_interface_ip_table_reply) \
5399 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5400 classify_set_interface_l2_tables_reply) \
5401 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5402 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5403 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5404 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5405 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5406 l2tpv3_interface_enable_disable_reply) \
5407 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5408 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5409 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5410 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5411 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5412 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5413 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5414 _(GRE_TUNNEL_ADD_DEL_REPLY, gre_tunnel_add_del_reply) \
5415 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5416 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5417 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5418 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5419 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5420 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5421 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5422 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5423 _(SHOW_VERSION_REPLY, show_version_reply) \
5424 _(SHOW_THREADS_REPLY, show_threads_reply) \
5425 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5426 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5427 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5428 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5429 _(IP_PROBE_NEIGHBOR_REPLY, ip_probe_neighbor_reply) \
5430 _(IP_SCAN_NEIGHBOR_ENABLE_DISABLE_REPLY, ip_scan_neighbor_enable_disable_reply) \
5431 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5432 _(IP4_ARP_EVENT, ip4_arp_event) \
5433 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5434 _(IP6_ND_EVENT, ip6_nd_event) \
5435 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5436 _(L2_MACS_EVENT, l2_macs_event) \
5437 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5438 _(IP_ADDRESS_DETAILS, ip_address_details) \
5439 _(IP_DETAILS, ip_details) \
5440 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5441 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5442 _(IPSEC_SPD_ENTRY_ADD_DEL_REPLY, ipsec_spd_entry_add_del_reply) \
5443 _(IPSEC_SAD_ENTRY_ADD_DEL_REPLY, ipsec_sad_entry_add_del_reply) \
5444 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5445 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5446 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5447 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5448 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5449 _(BD_IP_MAC_FLUSH_REPLY, bd_ip_mac_flush_reply) \
5450 _(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
5451 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5452 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5453 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5454 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5455 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5456 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5457 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5458 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5459 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5460 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5461 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5462 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5463 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5464 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5465 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5466 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5467 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5468 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5469 one_map_register_enable_disable_reply) \
5470 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5471 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5472 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5473 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5474 one_map_register_fallback_threshold_reply) \
5475 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5476 one_rloc_probe_enable_disable_reply) \
5477 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5478 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5479 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5480 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5481 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5482 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5483 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5484 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5485 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5486 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5487 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5488 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5489 _(ONE_STATS_DETAILS, one_stats_details) \
5490 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5491 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5492 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5493 show_one_stats_enable_disable_reply) \
5494 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5495 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5496 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5497 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5498 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5499 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5500 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5501 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5502 one_enable_disable_pitr_mode_reply) \
5503 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5504 one_enable_disable_petr_mode_reply) \
5505 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5506 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5507 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5508 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5509 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5510 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5511 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5512 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5513 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5514 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5515 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5516 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5517 gpe_add_del_native_fwd_rpath_reply) \
5518 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5519 gpe_fwd_entry_path_details) \
5520 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5521 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5522 one_add_del_map_request_itr_rlocs_reply) \
5523 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5524 one_get_map_request_itr_rlocs_reply) \
5525 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5526 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5527 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5528 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5529 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5530 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5531 show_one_map_register_state_reply) \
5532 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5533 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5534 show_one_map_register_fallback_threshold_reply) \
5535 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5536 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5537 _(AF_PACKET_DETAILS, af_packet_details) \
5538 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5539 _(POLICER_DETAILS, policer_details) \
5540 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5541 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5542 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5543 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5544 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5545 _(MPLS_TABLE_DETAILS, mpls_table_details) \
5546 _(MPLS_ROUTE_DETAILS, mpls_route_details) \
5547 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5548 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5549 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5550 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5551 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5552 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5553 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5554 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5555 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5556 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5557 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5558 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5559 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5560 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5561 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5562 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5563 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5564 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5565 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5566 ip_source_and_port_range_check_add_del_reply) \
5567 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5568 ip_source_and_port_range_check_interface_add_del_reply) \
5569 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5570 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5571 _(SET_PUNT_REPLY, set_punt_reply) \
5572 _(IP_TABLE_DETAILS, ip_table_details) \
5573 _(IP_ROUTE_DETAILS, ip_route_details) \
5574 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5575 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5576 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5577 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5578 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5579 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5580 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5581 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5582 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5583 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5584 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5585 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5586 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5587 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5588 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
5589 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \
5590 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5591 _(SESSION_RULES_DETAILS, session_rules_details) \
5592 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5593 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5594 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply)
5596 #define foreach_standalone_reply_msg \
5597 _(SW_INTERFACE_EVENT, sw_interface_event)
5605 #define STR_VTR_OP_CASE(op) \
5606 case L2_VTR_ ## op: \
5610 str_vtr_op (u32 vtr_op)
5614 STR_VTR_OP_CASE (DISABLED);
5615 STR_VTR_OP_CASE (PUSH_1);
5616 STR_VTR_OP_CASE (PUSH_2);
5617 STR_VTR_OP_CASE (POP_1);
5618 STR_VTR_OP_CASE (POP_2);
5619 STR_VTR_OP_CASE (TRANSLATE_1_1);
5620 STR_VTR_OP_CASE (TRANSLATE_1_2);
5621 STR_VTR_OP_CASE (TRANSLATE_2_1);
5622 STR_VTR_OP_CASE (TRANSLATE_2_2);
5629 dump_sub_interface_table (vat_main_t * vam)
5631 const sw_interface_subif_t *sub = NULL;
5633 if (vam->json_output)
5636 ("JSON output supported only for VPE API calls and dump_stats_table");
5641 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5642 "Interface", "sw_if_index",
5643 "sub id", "dot1ad", "tags", "outer id",
5644 "inner id", "exact", "default", "outer any", "inner any");
5646 vec_foreach (sub, vam->sw_if_subif_table)
5649 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5650 sub->interface_name,
5652 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5653 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5654 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5655 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5656 if (sub->vtr_op != L2_VTR_DISABLED)
5659 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5660 "tag1: %d tag2: %d ]",
5661 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5662 sub->vtr_tag1, sub->vtr_tag2);
5670 name_sort_cmp (void *a1, void *a2)
5672 name_sort_t *n1 = a1;
5673 name_sort_t *n2 = a2;
5675 return strcmp ((char *) n1->name, (char *) n2->name);
5679 dump_interface_table (vat_main_t * vam)
5682 name_sort_t *nses = 0, *ns;
5684 if (vam->json_output)
5687 ("JSON output supported only for VPE API calls and dump_stats_table");
5692 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5694 vec_add2 (nses, ns, 1);
5695 ns->name = (u8 *)(p->key);
5696 ns->value = (u32) p->value[0];
5700 vec_sort_with_function (nses, name_sort_cmp);
5702 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5703 vec_foreach (ns, nses)
5705 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5712 dump_ip_table (vat_main_t * vam, int is_ipv6)
5714 const ip_details_t *det = NULL;
5715 const ip_address_details_t *address = NULL;
5718 print (vam->ofp, "%-12s", "sw_if_index");
5720 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5727 print (vam->ofp, "%-12d", i);
5728 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5733 vec_foreach (address, det->addr)
5737 is_ipv6 ? format_ip6_address : format_ip4_address,
5738 address->ip, address->prefix_length);
5746 dump_ipv4_table (vat_main_t * vam)
5748 if (vam->json_output)
5751 ("JSON output supported only for VPE API calls and dump_stats_table");
5755 return dump_ip_table (vam, 0);
5759 dump_ipv6_table (vat_main_t * vam)
5761 if (vam->json_output)
5764 ("JSON output supported only for VPE API calls and dump_stats_table");
5768 return dump_ip_table (vam, 1);
5772 * Pass CLI buffers directly in the CLI_INBAND API message,
5773 * instead of an additional shared memory area.
5776 exec_inband (vat_main_t * vam)
5778 vl_api_cli_inband_t *mp;
5779 unformat_input_t *i = vam->input;
5782 if (vec_len (i->buffer) == 0)
5785 if (vam->exec_mode == 0 && unformat (i, "mode"))
5790 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5797 * In order for the CLI command to work, it
5798 * must be a vector ending in \n, not a C-string ending
5801 u32 len = vec_len (vam->input->buffer);
5802 M2 (CLI_INBAND, mp, len);
5803 vl_api_to_api_string (len - 1, (const char *) vam->input->buffer, &mp->cmd);
5807 /* json responses may or may not include a useful reply... */
5808 if (vec_len (vam->cmd_reply))
5809 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
5814 exec (vat_main_t * vam)
5816 return exec_inband (vam);
5820 api_create_loopback (vat_main_t * vam)
5822 unformat_input_t *i = vam->input;
5823 vl_api_create_loopback_t *mp;
5824 vl_api_create_loopback_instance_t *mp_lbi;
5827 u8 is_specified = 0;
5828 u32 user_instance = 0;
5831 clib_memset (mac_address, 0, sizeof (mac_address));
5833 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5835 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5837 if (unformat (i, "instance %d", &user_instance))
5845 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5846 mp_lbi->is_specified = is_specified;
5848 mp_lbi->user_instance = htonl (user_instance);
5850 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5855 /* Construct the API message */
5856 M (CREATE_LOOPBACK, mp);
5858 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5867 api_delete_loopback (vat_main_t * vam)
5869 unformat_input_t *i = vam->input;
5870 vl_api_delete_loopback_t *mp;
5871 u32 sw_if_index = ~0;
5874 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5876 if (unformat (i, "sw_if_index %d", &sw_if_index))
5882 if (sw_if_index == ~0)
5884 errmsg ("missing sw_if_index");
5888 /* Construct the API message */
5889 M (DELETE_LOOPBACK, mp);
5890 mp->sw_if_index = ntohl (sw_if_index);
5898 api_want_interface_events (vat_main_t * vam)
5900 unformat_input_t *i = vam->input;
5901 vl_api_want_interface_events_t *mp;
5905 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5907 if (unformat (i, "enable"))
5909 else if (unformat (i, "disable"))
5917 errmsg ("missing enable|disable");
5921 M (WANT_INTERFACE_EVENTS, mp);
5922 mp->enable_disable = enable;
5924 vam->interface_event_display = enable;
5932 /* Note: non-static, called once to set up the initial intfc table */
5934 api_sw_interface_dump (vat_main_t * vam)
5936 vl_api_sw_interface_dump_t *mp;
5937 vl_api_control_ping_t *mp_ping;
5939 name_sort_t *nses = 0, *ns;
5940 sw_interface_subif_t *sub = NULL;
5943 /* Toss the old name table */
5945 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5947 vec_add2 (nses, ns, 1);
5948 ns->name = (u8 *)(p->key);
5949 ns->value = (u32) p->value[0];
5953 hash_free (vam->sw_if_index_by_interface_name);
5955 vec_foreach (ns, nses) vec_free (ns->name);
5959 vec_foreach (sub, vam->sw_if_subif_table)
5961 vec_free (sub->interface_name);
5963 vec_free (vam->sw_if_subif_table);
5965 /* recreate the interface name hash table */
5966 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5969 * Ask for all interface names. Otherwise, the epic catalog of
5970 * name filters becomes ridiculously long, and vat ends up needing
5971 * to be taught about new interface types.
5973 M (SW_INTERFACE_DUMP, mp);
5976 /* Use a control ping for synchronization */
5977 MPING (CONTROL_PING, mp_ping);
5985 api_sw_interface_set_flags (vat_main_t * vam)
5987 unformat_input_t *i = vam->input;
5988 vl_api_sw_interface_set_flags_t *mp;
5990 u8 sw_if_index_set = 0;
5994 /* Parse args required to build the message */
5995 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5997 if (unformat (i, "admin-up"))
5999 else if (unformat (i, "admin-down"))
6002 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6003 sw_if_index_set = 1;
6004 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6005 sw_if_index_set = 1;
6010 if (sw_if_index_set == 0)
6012 errmsg ("missing interface name or sw_if_index");
6016 /* Construct the API message */
6017 M (SW_INTERFACE_SET_FLAGS, mp);
6018 mp->sw_if_index = ntohl (sw_if_index);
6019 mp->admin_up_down = admin_up;
6024 /* Wait for a reply, return the good/bad news... */
6030 api_sw_interface_set_rx_mode (vat_main_t * vam)
6032 unformat_input_t *i = vam->input;
6033 vl_api_sw_interface_set_rx_mode_t *mp;
6035 u8 sw_if_index_set = 0;
6037 u8 queue_id_valid = 0;
6039 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
6041 /* Parse args required to build the message */
6042 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6044 if (unformat (i, "queue %d", &queue_id))
6046 else if (unformat (i, "polling"))
6047 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
6048 else if (unformat (i, "interrupt"))
6049 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
6050 else if (unformat (i, "adaptive"))
6051 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
6053 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6054 sw_if_index_set = 1;
6055 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6056 sw_if_index_set = 1;
6061 if (sw_if_index_set == 0)
6063 errmsg ("missing interface name or sw_if_index");
6066 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6068 errmsg ("missing rx-mode");
6072 /* Construct the API message */
6073 M (SW_INTERFACE_SET_RX_MODE, mp);
6074 mp->sw_if_index = ntohl (sw_if_index);
6076 mp->queue_id_valid = queue_id_valid;
6077 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6082 /* Wait for a reply, return the good/bad news... */
6088 api_sw_interface_set_rx_placement (vat_main_t * vam)
6090 unformat_input_t *i = vam->input;
6091 vl_api_sw_interface_set_rx_placement_t *mp;
6093 u8 sw_if_index_set = 0;
6096 u32 queue_id, thread_index;
6098 /* Parse args required to build the message */
6099 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6101 if (unformat (i, "queue %d", &queue_id))
6103 else if (unformat (i, "main"))
6105 else if (unformat (i, "worker %d", &thread_index))
6108 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6109 sw_if_index_set = 1;
6110 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6111 sw_if_index_set = 1;
6116 if (sw_if_index_set == 0)
6118 errmsg ("missing interface name or sw_if_index");
6124 /* Construct the API message */
6125 M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
6126 mp->sw_if_index = ntohl (sw_if_index);
6127 mp->worker_id = ntohl (thread_index);
6128 mp->queue_id = ntohl (queue_id);
6129 mp->is_main = is_main;
6133 /* Wait for a reply, return the good/bad news... */
6138 static void vl_api_sw_interface_rx_placement_details_t_handler
6139 (vl_api_sw_interface_rx_placement_details_t * mp)
6141 vat_main_t *vam = &vat_main;
6142 u32 worker_id = ntohl (mp->worker_id);
6145 "\n%-11d %-11s %-6d %-5d %-9s",
6146 ntohl (mp->sw_if_index), (worker_id == 0) ? "main" : "worker",
6147 worker_id, ntohl (mp->queue_id),
6149 1) ? "polling" : ((mp->mode == 2) ? "interrupt" : "adaptive"));
6152 static void vl_api_sw_interface_rx_placement_details_t_handler_json
6153 (vl_api_sw_interface_rx_placement_details_t * mp)
6155 vat_main_t *vam = &vat_main;
6156 vat_json_node_t *node = NULL;
6158 if (VAT_JSON_ARRAY != vam->json_tree.type)
6160 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
6161 vat_json_init_array (&vam->json_tree);
6163 node = vat_json_array_add (&vam->json_tree);
6165 vat_json_init_object (node);
6166 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
6167 vat_json_object_add_uint (node, "worker_id", ntohl (mp->worker_id));
6168 vat_json_object_add_uint (node, "queue_id", ntohl (mp->queue_id));
6169 vat_json_object_add_uint (node, "mode", mp->mode);
6173 api_sw_interface_rx_placement_dump (vat_main_t * vam)
6175 unformat_input_t *i = vam->input;
6176 vl_api_sw_interface_rx_placement_dump_t *mp;
6177 vl_api_control_ping_t *mp_ping;
6180 u8 sw_if_index_set = 0;
6182 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6184 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6186 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6193 "\n%-11s %-11s %-6s %-5s %-4s",
6194 "sw_if_index", "main/worker", "thread", "queue", "mode");
6196 /* Dump Interface rx placement */
6197 M (SW_INTERFACE_RX_PLACEMENT_DUMP, mp);
6199 if (sw_if_index_set)
6200 mp->sw_if_index = htonl (sw_if_index);
6202 mp->sw_if_index = ~0;
6206 /* Use a control ping for synchronization */
6207 MPING (CONTROL_PING, mp_ping);
6215 api_sw_interface_clear_stats (vat_main_t * vam)
6217 unformat_input_t *i = vam->input;
6218 vl_api_sw_interface_clear_stats_t *mp;
6220 u8 sw_if_index_set = 0;
6223 /* Parse args required to build the message */
6224 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6226 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6227 sw_if_index_set = 1;
6228 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6229 sw_if_index_set = 1;
6234 /* Construct the API message */
6235 M (SW_INTERFACE_CLEAR_STATS, mp);
6237 if (sw_if_index_set == 1)
6238 mp->sw_if_index = ntohl (sw_if_index);
6240 mp->sw_if_index = ~0;
6245 /* Wait for a reply, return the good/bad news... */
6251 api_sw_interface_add_del_address (vat_main_t * vam)
6253 unformat_input_t *i = vam->input;
6254 vl_api_sw_interface_add_del_address_t *mp;
6256 u8 sw_if_index_set = 0;
6257 u8 is_add = 1, del_all = 0;
6258 u32 address_length = 0;
6259 u8 v4_address_set = 0;
6260 u8 v6_address_set = 0;
6261 ip4_address_t v4address;
6262 ip6_address_t v6address;
6265 /* Parse args required to build the message */
6266 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6268 if (unformat (i, "del-all"))
6270 else if (unformat (i, "del"))
6273 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6274 sw_if_index_set = 1;
6275 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6276 sw_if_index_set = 1;
6277 else if (unformat (i, "%U/%d",
6278 unformat_ip4_address, &v4address, &address_length))
6280 else if (unformat (i, "%U/%d",
6281 unformat_ip6_address, &v6address, &address_length))
6287 if (sw_if_index_set == 0)
6289 errmsg ("missing interface name or sw_if_index");
6292 if (v4_address_set && v6_address_set)
6294 errmsg ("both v4 and v6 addresses set");
6297 if (!v4_address_set && !v6_address_set && !del_all)
6299 errmsg ("no addresses set");
6303 /* Construct the API message */
6304 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6306 mp->sw_if_index = ntohl (sw_if_index);
6307 mp->is_add = is_add;
6308 mp->del_all = del_all;
6312 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6316 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6318 mp->address_length = address_length;
6323 /* Wait for a reply, return good/bad news */
6329 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6331 unformat_input_t *i = vam->input;
6332 vl_api_sw_interface_set_mpls_enable_t *mp;
6334 u8 sw_if_index_set = 0;
6338 /* Parse args required to build the message */
6339 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6341 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6342 sw_if_index_set = 1;
6343 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6344 sw_if_index_set = 1;
6345 else if (unformat (i, "disable"))
6347 else if (unformat (i, "dis"))
6353 if (sw_if_index_set == 0)
6355 errmsg ("missing interface name or sw_if_index");
6359 /* Construct the API message */
6360 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6362 mp->sw_if_index = ntohl (sw_if_index);
6363 mp->enable = enable;
6368 /* Wait for a reply... */
6374 api_sw_interface_set_table (vat_main_t * vam)
6376 unformat_input_t *i = vam->input;
6377 vl_api_sw_interface_set_table_t *mp;
6378 u32 sw_if_index, vrf_id = 0;
6379 u8 sw_if_index_set = 0;
6383 /* Parse args required to build the message */
6384 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6386 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6387 sw_if_index_set = 1;
6388 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6389 sw_if_index_set = 1;
6390 else if (unformat (i, "vrf %d", &vrf_id))
6392 else if (unformat (i, "ipv6"))
6398 if (sw_if_index_set == 0)
6400 errmsg ("missing interface name or sw_if_index");
6404 /* Construct the API message */
6405 M (SW_INTERFACE_SET_TABLE, mp);
6407 mp->sw_if_index = ntohl (sw_if_index);
6408 mp->is_ipv6 = is_ipv6;
6409 mp->vrf_id = ntohl (vrf_id);
6414 /* Wait for a reply... */
6419 static void vl_api_sw_interface_get_table_reply_t_handler
6420 (vl_api_sw_interface_get_table_reply_t * mp)
6422 vat_main_t *vam = &vat_main;
6424 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6426 vam->retval = ntohl (mp->retval);
6427 vam->result_ready = 1;
6431 static void vl_api_sw_interface_get_table_reply_t_handler_json
6432 (vl_api_sw_interface_get_table_reply_t * mp)
6434 vat_main_t *vam = &vat_main;
6435 vat_json_node_t node;
6437 vat_json_init_object (&node);
6438 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6439 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6441 vat_json_print (vam->ofp, &node);
6442 vat_json_free (&node);
6444 vam->retval = ntohl (mp->retval);
6445 vam->result_ready = 1;
6449 api_sw_interface_get_table (vat_main_t * vam)
6451 unformat_input_t *i = vam->input;
6452 vl_api_sw_interface_get_table_t *mp;
6454 u8 sw_if_index_set = 0;
6458 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6460 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6461 sw_if_index_set = 1;
6462 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6463 sw_if_index_set = 1;
6464 else if (unformat (i, "ipv6"))
6470 if (sw_if_index_set == 0)
6472 errmsg ("missing interface name or sw_if_index");
6476 M (SW_INTERFACE_GET_TABLE, mp);
6477 mp->sw_if_index = htonl (sw_if_index);
6478 mp->is_ipv6 = is_ipv6;
6486 api_sw_interface_set_vpath (vat_main_t * vam)
6488 unformat_input_t *i = vam->input;
6489 vl_api_sw_interface_set_vpath_t *mp;
6490 u32 sw_if_index = 0;
6491 u8 sw_if_index_set = 0;
6495 /* Parse args required to build the message */
6496 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6498 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6499 sw_if_index_set = 1;
6500 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6501 sw_if_index_set = 1;
6502 else if (unformat (i, "enable"))
6504 else if (unformat (i, "disable"))
6510 if (sw_if_index_set == 0)
6512 errmsg ("missing interface name or sw_if_index");
6516 /* Construct the API message */
6517 M (SW_INTERFACE_SET_VPATH, mp);
6519 mp->sw_if_index = ntohl (sw_if_index);
6520 mp->enable = is_enable;
6525 /* Wait for a reply... */
6531 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6533 unformat_input_t *i = vam->input;
6534 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6535 u32 sw_if_index = 0;
6536 u8 sw_if_index_set = 0;
6541 /* Parse args required to build the message */
6542 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6544 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6545 sw_if_index_set = 1;
6546 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6547 sw_if_index_set = 1;
6548 else if (unformat (i, "enable"))
6550 else if (unformat (i, "disable"))
6552 else if (unformat (i, "ip4"))
6554 else if (unformat (i, "ip6"))
6560 if (sw_if_index_set == 0)
6562 errmsg ("missing interface name or sw_if_index");
6566 /* Construct the API message */
6567 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6569 mp->sw_if_index = ntohl (sw_if_index);
6570 mp->enable = is_enable;
6571 mp->is_ipv6 = is_ipv6;
6576 /* Wait for a reply... */
6582 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6584 unformat_input_t *i = vam->input;
6585 vl_api_sw_interface_set_geneve_bypass_t *mp;
6586 u32 sw_if_index = 0;
6587 u8 sw_if_index_set = 0;
6592 /* Parse args required to build the message */
6593 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6595 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6596 sw_if_index_set = 1;
6597 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6598 sw_if_index_set = 1;
6599 else if (unformat (i, "enable"))
6601 else if (unformat (i, "disable"))
6603 else if (unformat (i, "ip4"))
6605 else if (unformat (i, "ip6"))
6611 if (sw_if_index_set == 0)
6613 errmsg ("missing interface name or sw_if_index");
6617 /* Construct the API message */
6618 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6620 mp->sw_if_index = ntohl (sw_if_index);
6621 mp->enable = is_enable;
6622 mp->is_ipv6 = is_ipv6;
6627 /* Wait for a reply... */
6633 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6635 unformat_input_t *i = vam->input;
6636 vl_api_sw_interface_set_l2_xconnect_t *mp;
6638 u8 rx_sw_if_index_set = 0;
6640 u8 tx_sw_if_index_set = 0;
6644 /* Parse args required to build the message */
6645 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6647 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6648 rx_sw_if_index_set = 1;
6649 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6650 tx_sw_if_index_set = 1;
6651 else if (unformat (i, "rx"))
6653 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6655 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6657 rx_sw_if_index_set = 1;
6662 else if (unformat (i, "tx"))
6664 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6666 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6668 tx_sw_if_index_set = 1;
6673 else if (unformat (i, "enable"))
6675 else if (unformat (i, "disable"))
6681 if (rx_sw_if_index_set == 0)
6683 errmsg ("missing rx interface name or rx_sw_if_index");
6687 if (enable && (tx_sw_if_index_set == 0))
6689 errmsg ("missing tx interface name or tx_sw_if_index");
6693 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6695 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6696 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6697 mp->enable = enable;
6705 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6707 unformat_input_t *i = vam->input;
6708 vl_api_sw_interface_set_l2_bridge_t *mp;
6709 vl_api_l2_port_type_t port_type;
6711 u8 rx_sw_if_index_set = 0;
6718 port_type = L2_API_PORT_TYPE_NORMAL;
6720 /* Parse args required to build the message */
6721 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6723 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6724 rx_sw_if_index_set = 1;
6725 else if (unformat (i, "bd_id %d", &bd_id))
6729 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6730 rx_sw_if_index_set = 1;
6731 else if (unformat (i, "shg %d", &shg))
6733 else if (unformat (i, "bvi"))
6734 port_type = L2_API_PORT_TYPE_BVI;
6735 else if (unformat (i, "uu-fwd"))
6736 port_type = L2_API_PORT_TYPE_UU_FWD;
6737 else if (unformat (i, "enable"))
6739 else if (unformat (i, "disable"))
6745 if (rx_sw_if_index_set == 0)
6747 errmsg ("missing rx interface name or sw_if_index");
6751 if (enable && (bd_id_set == 0))
6753 errmsg ("missing bridge domain");
6757 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6759 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6760 mp->bd_id = ntohl (bd_id);
6762 mp->port_type = ntohl (port_type);
6763 mp->enable = enable;
6771 api_bridge_domain_dump (vat_main_t * vam)
6773 unformat_input_t *i = vam->input;
6774 vl_api_bridge_domain_dump_t *mp;
6775 vl_api_control_ping_t *mp_ping;
6779 /* Parse args required to build the message */
6780 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6782 if (unformat (i, "bd_id %d", &bd_id))
6788 M (BRIDGE_DOMAIN_DUMP, mp);
6789 mp->bd_id = ntohl (bd_id);
6792 /* Use a control ping for synchronization */
6793 MPING (CONTROL_PING, mp_ping);
6801 api_bridge_domain_add_del (vat_main_t * vam)
6803 unformat_input_t *i = vam->input;
6804 vl_api_bridge_domain_add_del_t *mp;
6807 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6812 /* Parse args required to build the message */
6813 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6815 if (unformat (i, "bd_id %d", &bd_id))
6817 else if (unformat (i, "flood %d", &flood))
6819 else if (unformat (i, "uu-flood %d", &uu_flood))
6821 else if (unformat (i, "forward %d", &forward))
6823 else if (unformat (i, "learn %d", &learn))
6825 else if (unformat (i, "arp-term %d", &arp_term))
6827 else if (unformat (i, "mac-age %d", &mac_age))
6829 else if (unformat (i, "bd-tag %s", &bd_tag))
6831 else if (unformat (i, "del"))
6834 flood = uu_flood = forward = learn = 0;
6842 errmsg ("missing bridge domain");
6849 errmsg ("mac age must be less than 256 ");
6854 if ((bd_tag) && (vec_len (bd_tag) > 63))
6856 errmsg ("bd-tag cannot be longer than 63");
6861 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6863 mp->bd_id = ntohl (bd_id);
6865 mp->uu_flood = uu_flood;
6866 mp->forward = forward;
6868 mp->arp_term = arp_term;
6869 mp->is_add = is_add;
6870 mp->mac_age = (u8) mac_age;
6873 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
6874 mp->bd_tag[vec_len (bd_tag)] = 0;
6885 api_l2fib_flush_bd (vat_main_t * vam)
6887 unformat_input_t *i = vam->input;
6888 vl_api_l2fib_flush_bd_t *mp;
6892 /* Parse args required to build the message */
6893 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6895 if (unformat (i, "bd_id %d", &bd_id));
6902 errmsg ("missing bridge domain");
6906 M (L2FIB_FLUSH_BD, mp);
6908 mp->bd_id = htonl (bd_id);
6916 api_l2fib_flush_int (vat_main_t * vam)
6918 unformat_input_t *i = vam->input;
6919 vl_api_l2fib_flush_int_t *mp;
6920 u32 sw_if_index = ~0;
6923 /* Parse args required to build the message */
6924 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6926 if (unformat (i, "sw_if_index %d", &sw_if_index));
6928 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6933 if (sw_if_index == ~0)
6935 errmsg ("missing interface name or sw_if_index");
6939 M (L2FIB_FLUSH_INT, mp);
6941 mp->sw_if_index = ntohl (sw_if_index);
6949 api_l2fib_add_del (vat_main_t * vam)
6951 unformat_input_t *i = vam->input;
6952 vl_api_l2fib_add_del_t *mp;
6958 u32 sw_if_index = 0;
6959 u8 sw_if_index_set = 0;
6968 /* Parse args required to build the message */
6969 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6971 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
6973 else if (unformat (i, "bd_id %d", &bd_id))
6975 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6976 sw_if_index_set = 1;
6977 else if (unformat (i, "sw_if"))
6979 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6982 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6983 sw_if_index_set = 1;
6988 else if (unformat (i, "static"))
6990 else if (unformat (i, "filter"))
6995 else if (unformat (i, "bvi"))
7000 else if (unformat (i, "del"))
7002 else if (unformat (i, "count %d", &count))
7010 errmsg ("missing mac address");
7016 errmsg ("missing bridge domain");
7020 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7022 errmsg ("missing interface name or sw_if_index");
7028 /* Turn on async mode */
7029 vam->async_mode = 1;
7030 vam->async_errors = 0;
7031 before = vat_time_now (vam);
7034 for (j = 0; j < count; j++)
7036 M (L2FIB_ADD_DEL, mp);
7038 clib_memcpy (mp->mac, mac, 6);
7039 mp->bd_id = ntohl (bd_id);
7040 mp->is_add = is_add;
7041 mp->sw_if_index = ntohl (sw_if_index);
7045 mp->static_mac = static_mac;
7046 mp->filter_mac = filter_mac;
7047 mp->bvi_mac = bvi_mac;
7049 increment_mac_address (mac);
7056 vl_api_control_ping_t *mp_ping;
7059 /* Shut off async mode */
7060 vam->async_mode = 0;
7062 MPING (CONTROL_PING, mp_ping);
7065 timeout = vat_time_now (vam) + 1.0;
7066 while (vat_time_now (vam) < timeout)
7067 if (vam->result_ready == 1)
7072 if (vam->retval == -99)
7075 if (vam->async_errors > 0)
7077 errmsg ("%d asynchronous errors", vam->async_errors);
7080 vam->async_errors = 0;
7081 after = vat_time_now (vam);
7083 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7084 count, after - before, count / (after - before));
7090 /* Wait for a reply... */
7094 /* Return the good/bad news */
7095 return (vam->retval);
7099 api_bridge_domain_set_mac_age (vat_main_t * vam)
7101 unformat_input_t *i = vam->input;
7102 vl_api_bridge_domain_set_mac_age_t *mp;
7107 /* Parse args required to build the message */
7108 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7110 if (unformat (i, "bd_id %d", &bd_id));
7111 else if (unformat (i, "mac-age %d", &mac_age));
7118 errmsg ("missing bridge domain");
7124 errmsg ("mac age must be less than 256 ");
7128 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7130 mp->bd_id = htonl (bd_id);
7131 mp->mac_age = (u8) mac_age;
7139 api_l2_flags (vat_main_t * vam)
7141 unformat_input_t *i = vam->input;
7142 vl_api_l2_flags_t *mp;
7145 u8 sw_if_index_set = 0;
7149 /* Parse args required to build the message */
7150 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7152 if (unformat (i, "sw_if_index %d", &sw_if_index))
7153 sw_if_index_set = 1;
7154 else if (unformat (i, "sw_if"))
7156 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7159 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7160 sw_if_index_set = 1;
7165 else if (unformat (i, "learn"))
7167 else if (unformat (i, "forward"))
7169 else if (unformat (i, "flood"))
7171 else if (unformat (i, "uu-flood"))
7172 flags |= L2_UU_FLOOD;
7173 else if (unformat (i, "arp-term"))
7174 flags |= L2_ARP_TERM;
7175 else if (unformat (i, "off"))
7177 else if (unformat (i, "disable"))
7183 if (sw_if_index_set == 0)
7185 errmsg ("missing interface name or sw_if_index");
7191 mp->sw_if_index = ntohl (sw_if_index);
7192 mp->feature_bitmap = ntohl (flags);
7193 mp->is_set = is_set;
7201 api_bridge_flags (vat_main_t * vam)
7203 unformat_input_t *i = vam->input;
7204 vl_api_bridge_flags_t *mp;
7208 bd_flags_t flags = 0;
7211 /* Parse args required to build the message */
7212 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7214 if (unformat (i, "bd_id %d", &bd_id))
7216 else if (unformat (i, "learn"))
7217 flags |= BRIDGE_API_FLAG_LEARN;
7218 else if (unformat (i, "forward"))
7219 flags |= BRIDGE_API_FLAG_FWD;
7220 else if (unformat (i, "flood"))
7221 flags |= BRIDGE_API_FLAG_FLOOD;
7222 else if (unformat (i, "uu-flood"))
7223 flags |= BRIDGE_API_FLAG_UU_FLOOD;
7224 else if (unformat (i, "arp-term"))
7225 flags |= BRIDGE_API_FLAG_ARP_TERM;
7226 else if (unformat (i, "off"))
7228 else if (unformat (i, "disable"))
7236 errmsg ("missing bridge domain");
7240 M (BRIDGE_FLAGS, mp);
7242 mp->bd_id = ntohl (bd_id);
7243 mp->flags = ntohl (flags);
7244 mp->is_set = is_set;
7252 api_bd_ip_mac_add_del (vat_main_t * vam)
7254 vl_api_address_t ip = VL_API_ZERO_ADDRESS;
7255 vl_api_mac_address_t mac = { 0 };
7256 unformat_input_t *i = vam->input;
7257 vl_api_bd_ip_mac_add_del_t *mp;
7266 /* Parse args required to build the message */
7267 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7269 if (unformat (i, "bd_id %d", &bd_id))
7273 else if (unformat (i, "%U", unformat_vl_api_address, &ip))
7277 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
7281 else if (unformat (i, "del"))
7289 errmsg ("missing bridge domain");
7292 else if (ip_set == 0)
7294 errmsg ("missing IP address");
7297 else if (mac_set == 0)
7299 errmsg ("missing MAC address");
7303 M (BD_IP_MAC_ADD_DEL, mp);
7305 mp->entry.bd_id = ntohl (bd_id);
7306 mp->is_add = is_add;
7308 clib_memcpy (&mp->entry.ip, &ip, sizeof (ip));
7309 clib_memcpy (&mp->entry.mac, &mac, sizeof (mac));
7317 api_bd_ip_mac_flush (vat_main_t * vam)
7319 unformat_input_t *i = vam->input;
7320 vl_api_bd_ip_mac_flush_t *mp;
7325 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7327 if (unformat (i, "bd_id %d", &bd_id))
7337 errmsg ("missing bridge domain");
7341 M (BD_IP_MAC_FLUSH, mp);
7343 mp->bd_id = ntohl (bd_id);
7350 static void vl_api_bd_ip_mac_details_t_handler
7351 (vl_api_bd_ip_mac_details_t * mp)
7353 vat_main_t *vam = &vat_main;
7357 ntohl (mp->entry.bd_id),
7358 format_vl_api_mac_address, mp->entry.mac,
7359 format_vl_api_address, &mp->entry.ip);
7362 static void vl_api_bd_ip_mac_details_t_handler_json
7363 (vl_api_bd_ip_mac_details_t * mp)
7365 vat_main_t *vam = &vat_main;
7366 vat_json_node_t *node = NULL;
7368 if (VAT_JSON_ARRAY != vam->json_tree.type)
7370 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7371 vat_json_init_array (&vam->json_tree);
7373 node = vat_json_array_add (&vam->json_tree);
7375 vat_json_init_object (node);
7376 vat_json_object_add_uint (node, "bd_id", ntohl (mp->entry.bd_id));
7377 vat_json_object_add_string_copy (node, "mac_address",
7378 format (0, "%U", format_vl_api_mac_address,
7382 ip = format (0, "%U", format_vl_api_address, &mp->entry.ip);
7383 vat_json_object_add_string_copy (node, "ip_address", ip);
7388 api_bd_ip_mac_dump (vat_main_t * vam)
7390 unformat_input_t *i = vam->input;
7391 vl_api_bd_ip_mac_dump_t *mp;
7392 vl_api_control_ping_t *mp_ping;
7397 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7399 if (unformat (i, "bd_id %d", &bd_id))
7408 "\n%-5s %-7s %-20s %-30s",
7409 "bd_id", "is_ipv6", "mac_address", "ip_address");
7411 /* Dump Bridge Domain Ip to Mac entries */
7412 M (BD_IP_MAC_DUMP, mp);
7415 mp->bd_id = htonl (bd_id);
7421 /* Use a control ping for synchronization */
7422 MPING (CONTROL_PING, mp_ping);
7430 api_tap_create_v2 (vat_main_t * vam)
7432 unformat_input_t *i = vam->input;
7433 vl_api_tap_create_v2_t *mp;
7434 #define TAP_FLAG_GSO (1 << 0)
7438 u8 *host_if_name = 0;
7440 u8 host_mac_addr[6];
7441 u8 host_mac_addr_set = 0;
7442 u8 *host_bridge = 0;
7443 ip4_address_t host_ip4_addr;
7444 ip4_address_t host_ip4_gw;
7445 u8 host_ip4_gw_set = 0;
7446 u32 host_ip4_prefix_len = 0;
7447 ip6_address_t host_ip6_addr;
7448 ip6_address_t host_ip6_gw;
7449 u8 host_ip6_gw_set = 0;
7450 u32 host_ip6_prefix_len = 0;
7451 u8 host_mtu_set = 0;
7452 u32 host_mtu_size = 0;
7455 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7457 clib_memset (mac_address, 0, sizeof (mac_address));
7459 /* Parse args required to build the message */
7460 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7462 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7466 else if (unformat (i, "id %u", &id))
7468 else if (unformat (i, "host-if-name %s", &host_if_name))
7470 else if (unformat (i, "host-ns %s", &host_ns))
7472 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
7474 host_mac_addr_set = 1;
7475 else if (unformat (i, "host-bridge %s", &host_bridge))
7477 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
7478 &host_ip4_addr, &host_ip4_prefix_len))
7480 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
7481 &host_ip6_addr, &host_ip6_prefix_len))
7483 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
7485 host_ip4_gw_set = 1;
7486 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
7488 host_ip6_gw_set = 1;
7489 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
7491 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
7493 else if (unformat (i, "host-mtu-size %d", &host_mtu_size))
7495 else if (unformat (i, "no-gso"))
7496 tap_flags &= ~TAP_FLAG_GSO;
7497 else if (unformat (i, "gso"))
7498 tap_flags |= TAP_FLAG_GSO;
7503 if (vec_len (host_if_name) > 63)
7505 errmsg ("tap name too long. ");
7508 if (vec_len (host_ns) > 63)
7510 errmsg ("host name space too long. ");
7513 if (vec_len (host_bridge) > 63)
7515 errmsg ("host bridge name too long. ");
7518 if (host_ip4_prefix_len > 32)
7520 errmsg ("host ip4 prefix length not valid. ");
7523 if (host_ip6_prefix_len > 128)
7525 errmsg ("host ip6 prefix length not valid. ");
7528 if (!is_pow2 (rx_ring_sz))
7530 errmsg ("rx ring size must be power of 2. ");
7533 if (rx_ring_sz > 32768)
7535 errmsg ("rx ring size must be 32768 or lower. ");
7538 if (!is_pow2 (tx_ring_sz))
7540 errmsg ("tx ring size must be power of 2. ");
7543 if (tx_ring_sz > 32768)
7545 errmsg ("tx ring size must be 32768 or lower. ");
7548 if (host_mtu_set && (host_mtu_size < 64 || host_mtu_size > 65355))
7550 errmsg ("host MTU size must be in between 64 and 65355. ");
7554 /* Construct the API message */
7555 M (TAP_CREATE_V2, mp);
7557 mp->use_random_mac = random_mac;
7559 mp->id = ntohl (id);
7560 mp->host_namespace_set = host_ns != 0;
7561 mp->host_bridge_set = host_bridge != 0;
7562 mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
7563 mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
7564 mp->rx_ring_sz = ntohs (rx_ring_sz);
7565 mp->tx_ring_sz = ntohs (tx_ring_sz);
7566 mp->host_mtu_set = host_mtu_set;
7567 mp->host_mtu_size = ntohl (host_mtu_size);
7568 mp->tap_flags = ntohl (tap_flags);
7570 if (random_mac == 0)
7571 clib_memcpy (mp->mac_address, mac_address, 6);
7572 if (host_mac_addr_set)
7573 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
7575 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
7577 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
7579 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
7580 if (host_ip4_prefix_len)
7581 clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
7582 if (host_ip6_prefix_len)
7583 clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
7584 if (host_ip4_gw_set)
7585 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
7586 if (host_ip6_gw_set)
7587 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
7590 vec_free (host_if_name);
7591 vec_free (host_bridge);
7596 /* Wait for a reply... */
7602 api_tap_delete_v2 (vat_main_t * vam)
7604 unformat_input_t *i = vam->input;
7605 vl_api_tap_delete_v2_t *mp;
7606 u32 sw_if_index = ~0;
7607 u8 sw_if_index_set = 0;
7610 /* Parse args required to build the message */
7611 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7613 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7614 sw_if_index_set = 1;
7615 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7616 sw_if_index_set = 1;
7621 if (sw_if_index_set == 0)
7623 errmsg ("missing vpp interface name. ");
7627 /* Construct the API message */
7628 M (TAP_DELETE_V2, mp);
7630 mp->sw_if_index = ntohl (sw_if_index);
7635 /* Wait for a reply... */
7641 unformat_pci_addr (unformat_input_t * input, va_list * args)
7650 addr = va_arg (*args, struct pci_addr_t *);
7653 if (!unformat (input, "%x:%x:%x.%x", &x[0], &x[1], &x[2], &x[3]))
7656 addr->domain = x[0];
7659 addr->function = x[3];
7665 api_virtio_pci_create (vat_main_t * vam)
7667 unformat_input_t *i = vam->input;
7668 vl_api_virtio_pci_create_t *mp;
7673 u64 features = (u64) ~ (0ULL);
7676 clib_memset (mac_address, 0, sizeof (mac_address));
7678 /* Parse args required to build the message */
7679 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7681 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7685 else if (unformat (i, "pci-addr %U", unformat_pci_addr, &pci_addr))
7687 else if (unformat (i, "features 0x%llx", &features))
7689 else if (unformat (i, "gso-enabled"))
7697 errmsg ("pci address must be non zero. ");
7701 /* Construct the API message */
7702 M (VIRTIO_PCI_CREATE, mp);
7704 mp->use_random_mac = random_mac;
7706 mp->pci_addr = htonl (pci_addr);
7707 mp->features = clib_host_to_net_u64 (features);
7708 mp->gso_enabled = gso_enabled;
7710 if (random_mac == 0)
7711 clib_memcpy (mp->mac_address, mac_address, 6);
7716 /* Wait for a reply... */
7722 api_virtio_pci_delete (vat_main_t * vam)
7724 unformat_input_t *i = vam->input;
7725 vl_api_virtio_pci_delete_t *mp;
7726 u32 sw_if_index = ~0;
7727 u8 sw_if_index_set = 0;
7730 /* Parse args required to build the message */
7731 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7733 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7734 sw_if_index_set = 1;
7735 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7736 sw_if_index_set = 1;
7741 if (sw_if_index_set == 0)
7743 errmsg ("missing vpp interface name. ");
7747 /* Construct the API message */
7748 M (VIRTIO_PCI_DELETE, mp);
7750 mp->sw_if_index = htonl (sw_if_index);
7755 /* Wait for a reply... */
7761 api_bond_create (vat_main_t * vam)
7763 unformat_input_t *i = vam->input;
7764 vl_api_bond_create_t *mp;
7774 clib_memset (mac_address, 0, sizeof (mac_address));
7777 /* Parse args required to build the message */
7778 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7780 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
7782 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
7783 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
7785 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
7788 else if (unformat (i, "numa-only"))
7790 else if (unformat (i, "id %u", &id))
7796 if (mode_is_set == 0)
7798 errmsg ("Missing bond mode. ");
7802 /* Construct the API message */
7803 M (BOND_CREATE, mp);
7805 mp->use_custom_mac = custom_mac;
7809 mp->id = htonl (id);
7810 mp->numa_only = numa_only;
7813 clib_memcpy (mp->mac_address, mac_address, 6);
7818 /* Wait for a reply... */
7824 api_bond_delete (vat_main_t * vam)
7826 unformat_input_t *i = vam->input;
7827 vl_api_bond_delete_t *mp;
7828 u32 sw_if_index = ~0;
7829 u8 sw_if_index_set = 0;
7832 /* Parse args required to build the message */
7833 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7835 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7836 sw_if_index_set = 1;
7837 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7838 sw_if_index_set = 1;
7843 if (sw_if_index_set == 0)
7845 errmsg ("missing vpp interface name. ");
7849 /* Construct the API message */
7850 M (BOND_DELETE, mp);
7852 mp->sw_if_index = ntohl (sw_if_index);
7857 /* Wait for a reply... */
7863 api_bond_enslave (vat_main_t * vam)
7865 unformat_input_t *i = vam->input;
7866 vl_api_bond_enslave_t *mp;
7867 u32 bond_sw_if_index;
7871 u32 bond_sw_if_index_is_set = 0;
7873 u8 sw_if_index_is_set = 0;
7875 /* Parse args required to build the message */
7876 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7878 if (unformat (i, "sw_if_index %d", &sw_if_index))
7879 sw_if_index_is_set = 1;
7880 else if (unformat (i, "bond %u", &bond_sw_if_index))
7881 bond_sw_if_index_is_set = 1;
7882 else if (unformat (i, "passive %d", &is_passive))
7884 else if (unformat (i, "long-timeout %d", &is_long_timeout))
7890 if (bond_sw_if_index_is_set == 0)
7892 errmsg ("Missing bond sw_if_index. ");
7895 if (sw_if_index_is_set == 0)
7897 errmsg ("Missing slave sw_if_index. ");
7901 /* Construct the API message */
7902 M (BOND_ENSLAVE, mp);
7904 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
7905 mp->sw_if_index = ntohl (sw_if_index);
7906 mp->is_long_timeout = is_long_timeout;
7907 mp->is_passive = is_passive;
7912 /* Wait for a reply... */
7918 api_bond_detach_slave (vat_main_t * vam)
7920 unformat_input_t *i = vam->input;
7921 vl_api_bond_detach_slave_t *mp;
7922 u32 sw_if_index = ~0;
7923 u8 sw_if_index_set = 0;
7926 /* Parse args required to build the message */
7927 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7929 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7930 sw_if_index_set = 1;
7931 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7932 sw_if_index_set = 1;
7937 if (sw_if_index_set == 0)
7939 errmsg ("missing vpp interface name. ");
7943 /* Construct the API message */
7944 M (BOND_DETACH_SLAVE, mp);
7946 mp->sw_if_index = ntohl (sw_if_index);
7951 /* Wait for a reply... */
7957 api_ip_table_add_del (vat_main_t * vam)
7959 unformat_input_t *i = vam->input;
7960 vl_api_ip_table_add_del_t *mp;
7966 /* Parse args required to build the message */
7967 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7969 if (unformat (i, "ipv6"))
7971 else if (unformat (i, "del"))
7973 else if (unformat (i, "add"))
7975 else if (unformat (i, "table %d", &table_id))
7979 clib_warning ("parse error '%U'", format_unformat_error, i);
7986 errmsg ("missing table-ID");
7990 /* Construct the API message */
7991 M (IP_TABLE_ADD_DEL, mp);
7993 mp->table.table_id = ntohl (table_id);
7994 mp->table.is_ip6 = is_ipv6;
7995 mp->is_add = is_add;
8000 /* Wait for a reply... */
8007 unformat_fib_path (unformat_input_t * input, va_list * args)
8009 vat_main_t *vam = va_arg (*args, vat_main_t *);
8010 vl_api_fib_path_t *path = va_arg (*args, vl_api_fib_path_t *);
8011 u32 weight, preference;
8012 mpls_label_t out_label;
8014 clib_memset (path, 0, sizeof (*path));
8016 path->sw_if_index = ~0;
8020 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8022 if (unformat (input, "%U %U",
8023 unformat_vl_api_ip4_address,
8024 &path->nh.address.ip4,
8025 api_unformat_sw_if_index, vam, &path->sw_if_index))
8027 path->proto = FIB_API_PATH_NH_PROTO_IP4;
8029 else if (unformat (input, "%U %U",
8030 unformat_vl_api_ip6_address,
8031 &path->nh.address.ip6,
8032 api_unformat_sw_if_index, vam, &path->sw_if_index))
8034 path->proto = FIB_API_PATH_NH_PROTO_IP6;
8036 else if (unformat (input, "weight %u", &weight))
8038 path->weight = weight;
8040 else if (unformat (input, "preference %u", &preference))
8042 path->preference = preference;
8044 else if (unformat (input, "%U next-hop-table %d",
8045 unformat_vl_api_ip4_address,
8046 &path->nh.address.ip4, &path->table_id))
8048 path->proto = FIB_API_PATH_NH_PROTO_IP4;
8050 else if (unformat (input, "%U next-hop-table %d",
8051 unformat_vl_api_ip6_address,
8052 &path->nh.address.ip6, &path->table_id))
8054 path->proto = FIB_API_PATH_NH_PROTO_IP6;
8056 else if (unformat (input, "%U",
8057 unformat_vl_api_ip4_address, &path->nh.address.ip4))
8060 * the recursive next-hops are by default in the default table
8063 path->sw_if_index = ~0;
8064 path->proto = FIB_API_PATH_NH_PROTO_IP4;
8066 else if (unformat (input, "%U",
8067 unformat_vl_api_ip6_address, &path->nh.address.ip6))
8070 * the recursive next-hops are by default in the default table
8073 path->sw_if_index = ~0;
8074 path->proto = FIB_API_PATH_NH_PROTO_IP6;
8076 else if (unformat (input, "resolve-via-host"))
8078 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_HOST;
8080 else if (unformat (input, "resolve-via-attached"))
8082 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED;
8084 else if (unformat (input, "ip4-lookup-in-table %d", &path->table_id))
8086 path->type = FIB_API_PATH_TYPE_LOCAL;
8087 path->sw_if_index = ~0;
8088 path->proto = FIB_API_PATH_NH_PROTO_IP4;
8090 else if (unformat (input, "ip6-lookup-in-table %d", &path->table_id))
8092 path->type = FIB_API_PATH_TYPE_LOCAL;
8093 path->sw_if_index = ~0;
8094 path->proto = FIB_API_PATH_NH_PROTO_IP6;
8096 else if (unformat (input, "sw_if_index %d", &path->sw_if_index))
8098 else if (unformat (input, "via-label %d", &path->nh.via_label))
8100 path->proto = FIB_API_PATH_NH_PROTO_MPLS;
8101 path->sw_if_index = ~0;
8103 else if (unformat (input, "l2-input-on %d", &path->sw_if_index))
8105 path->proto = FIB_API_PATH_NH_PROTO_ETHERNET;
8106 path->type = FIB_API_PATH_TYPE_INTERFACE_RX;
8108 else if (unformat (input, "local"))
8110 path->type = FIB_API_PATH_TYPE_LOCAL;
8112 else if (unformat (input, "out-labels"))
8114 while (unformat (input, "%d", &out_label))
8116 path->label_stack[path->n_labels].label = out_label;
8117 path->label_stack[path->n_labels].is_uniform = 0;
8118 path->label_stack[path->n_labels].ttl = 64;
8122 else if (unformat (input, "via"))
8124 /* new path, back up and return */
8125 unformat_put_input (input);
8126 unformat_put_input (input);
8127 unformat_put_input (input);
8128 unformat_put_input (input);
8137 path->proto = ntohl (path->proto);
8138 path->type = ntohl (path->type);
8139 path->flags = ntohl (path->flags);
8140 path->table_id = ntohl (path->table_id);
8141 path->sw_if_index = ntohl (path->sw_if_index);
8147 api_ip_route_add_del (vat_main_t * vam)
8149 unformat_input_t *i = vam->input;
8150 vl_api_ip_route_add_del_t *mp;
8153 u8 is_multipath = 0;
8156 vl_api_prefix_t pfx = { };
8157 vl_api_fib_path_t paths[8];
8161 u32 random_add_del = 0;
8162 u32 *random_vector = 0;
8163 u32 random_seed = 0xdeaddabe;
8165 /* Parse args required to build the message */
8166 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8168 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
8170 else if (unformat (i, "del"))
8172 else if (unformat (i, "add"))
8174 else if (unformat (i, "vrf %d", &vrf_id))
8176 else if (unformat (i, "count %d", &count))
8178 else if (unformat (i, "random"))
8180 else if (unformat (i, "multipath"))
8182 else if (unformat (i, "seed %d", &random_seed))
8186 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8189 if (8 == path_count)
8191 errmsg ("max 8 paths");
8197 clib_warning ("parse error '%U'", format_unformat_error, i);
8204 errmsg ("specify a path; via ...");
8207 if (prefix_set == 0)
8209 errmsg ("missing prefix");
8213 /* Generate a pile of unique, random routes */
8216 ip4_address_t *i = (ip4_address_t *) & paths[0].nh.address.ip4;
8217 u32 this_random_address;
8220 random_hash = hash_create (count, sizeof (uword));
8222 hash_set (random_hash, i->as_u32, 1);
8223 for (j = 0; j <= count; j++)
8227 this_random_address = random_u32 (&random_seed);
8228 this_random_address =
8229 clib_host_to_net_u32 (this_random_address);
8231 while (hash_get (random_hash, this_random_address));
8232 vec_add1 (random_vector, this_random_address);
8233 hash_set (random_hash, this_random_address, 1);
8235 hash_free (random_hash);
8236 set_ip4_address (&pfx.address, random_vector[0]);
8241 /* Turn on async mode */
8242 vam->async_mode = 1;
8243 vam->async_errors = 0;
8244 before = vat_time_now (vam);
8247 for (j = 0; j < count; j++)
8249 /* Construct the API message */
8250 M2 (IP_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8252 mp->is_add = is_add;
8253 mp->is_multipath = is_multipath;
8255 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
8256 mp->route.table_id = ntohl (vrf_id);
8257 mp->route.n_paths = path_count;
8259 clib_memcpy (&mp->route.paths, &paths, sizeof (paths[0]) * path_count);
8262 set_ip4_address (&pfx.address, random_vector[j + 1]);
8264 increment_address (&pfx.address);
8267 /* If we receive SIGTERM, stop now... */
8272 /* When testing multiple add/del ops, use a control-ping to sync */
8275 vl_api_control_ping_t *mp_ping;
8279 /* Shut off async mode */
8280 vam->async_mode = 0;
8282 MPING (CONTROL_PING, mp_ping);
8285 timeout = vat_time_now (vam) + 1.0;
8286 while (vat_time_now (vam) < timeout)
8287 if (vam->result_ready == 1)
8292 if (vam->retval == -99)
8295 if (vam->async_errors > 0)
8297 errmsg ("%d asynchronous errors", vam->async_errors);
8300 vam->async_errors = 0;
8301 after = vat_time_now (vam);
8303 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8307 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8308 count, after - before, count / (after - before));
8314 /* Wait for a reply... */
8319 /* Return the good/bad news */
8320 return (vam->retval);
8324 api_ip_mroute_add_del (vat_main_t * vam)
8326 unformat_input_t *i = vam->input;
8327 u8 path_set = 0, prefix_set = 0, is_add = 1;
8328 vl_api_ip_mroute_add_del_t *mp;
8329 mfib_entry_flags_t eflags = 0;
8330 vl_api_mfib_path_t path;
8331 vl_api_mprefix_t pfx = { };
8335 /* Parse args required to build the message */
8336 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8338 if (unformat (i, "%U", unformat_vl_api_mprefix, &pfx))
8341 pfx.grp_address_length = htons (pfx.grp_address_length);
8343 else if (unformat (i, "del"))
8345 else if (unformat (i, "add"))
8347 else if (unformat (i, "vrf %d", &vrf_id))
8349 else if (unformat (i, "%U", unformat_mfib_itf_flags, &path.itf_flags))
8350 path.itf_flags = htonl (path.itf_flags);
8351 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8353 else if (unformat (i, "via %U", unformat_fib_path, vam, &path.path))
8357 clib_warning ("parse error '%U'", format_unformat_error, i);
8362 if (prefix_set == 0)
8364 errmsg ("missing addresses\n");
8369 errmsg ("missing path\n");
8373 /* Construct the API message */
8374 M (IP_MROUTE_ADD_DEL, mp);
8376 mp->is_add = is_add;
8377 mp->is_multipath = 1;
8379 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
8380 mp->route.table_id = htonl (vrf_id);
8381 mp->route.n_paths = 1;
8382 mp->route.entry_flags = htonl (eflags);
8384 clib_memcpy (&mp->route.paths, &path, sizeof (path));
8388 /* Wait for a reply... */
8394 api_mpls_table_add_del (vat_main_t * vam)
8396 unformat_input_t *i = vam->input;
8397 vl_api_mpls_table_add_del_t *mp;
8402 /* Parse args required to build the message */
8403 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8405 if (unformat (i, "table %d", &table_id))
8407 else if (unformat (i, "del"))
8409 else if (unformat (i, "add"))
8413 clib_warning ("parse error '%U'", format_unformat_error, i);
8420 errmsg ("missing table-ID");
8424 /* Construct the API message */
8425 M (MPLS_TABLE_ADD_DEL, mp);
8427 mp->mt_table.mt_table_id = ntohl (table_id);
8428 mp->mt_is_add = is_add;
8433 /* Wait for a reply... */
8440 api_mpls_route_add_del (vat_main_t * vam)
8442 u8 is_add = 1, path_count = 0, is_multipath = 0, is_eos = 0;
8443 mpls_label_t local_label = MPLS_LABEL_INVALID;
8444 unformat_input_t *i = vam->input;
8445 vl_api_mpls_route_add_del_t *mp;
8446 vl_api_fib_path_t paths[8];
8450 /* Parse args required to build the message */
8451 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8453 if (unformat (i, "%d", &local_label))
8455 else if (unformat (i, "eos"))
8457 else if (unformat (i, "non-eos"))
8459 else if (unformat (i, "del"))
8461 else if (unformat (i, "add"))
8463 else if (unformat (i, "multipath"))
8465 else if (unformat (i, "count %d", &count))
8469 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8472 if (8 == path_count)
8474 errmsg ("max 8 paths");
8480 clib_warning ("parse error '%U'", format_unformat_error, i);
8487 errmsg ("specify a path; via ...");
8491 if (MPLS_LABEL_INVALID == local_label)
8493 errmsg ("missing label");
8499 /* Turn on async mode */
8500 vam->async_mode = 1;
8501 vam->async_errors = 0;
8502 before = vat_time_now (vam);
8505 for (j = 0; j < count; j++)
8507 /* Construct the API message */
8508 M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8510 mp->mr_is_add = is_add;
8511 mp->mr_is_multipath = is_multipath;
8513 mp->mr_route.mr_label = local_label;
8514 mp->mr_route.mr_eos = is_eos;
8515 mp->mr_route.mr_table_id = 0;
8516 mp->mr_route.mr_n_paths = path_count;
8518 clib_memcpy (&mp->mr_route.mr_paths, paths,
8519 sizeof (paths[0]) * path_count);
8525 /* If we receive SIGTERM, stop now... */
8530 /* When testing multiple add/del ops, use a control-ping to sync */
8533 vl_api_control_ping_t *mp_ping;
8537 /* Shut off async mode */
8538 vam->async_mode = 0;
8540 MPING (CONTROL_PING, mp_ping);
8543 timeout = vat_time_now (vam) + 1.0;
8544 while (vat_time_now (vam) < timeout)
8545 if (vam->result_ready == 1)
8550 if (vam->retval == -99)
8553 if (vam->async_errors > 0)
8555 errmsg ("%d asynchronous errors", vam->async_errors);
8558 vam->async_errors = 0;
8559 after = vat_time_now (vam);
8561 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8565 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8566 count, after - before, count / (after - before));
8572 /* Wait for a reply... */
8577 /* Return the good/bad news */
8578 return (vam->retval);
8583 api_mpls_ip_bind_unbind (vat_main_t * vam)
8585 unformat_input_t *i = vam->input;
8586 vl_api_mpls_ip_bind_unbind_t *mp;
8587 u32 ip_table_id = 0;
8589 vl_api_prefix_t pfx;
8591 mpls_label_t local_label = MPLS_LABEL_INVALID;
8594 /* Parse args required to build the message */
8595 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8597 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
8599 else if (unformat (i, "%d", &local_label))
8601 else if (unformat (i, "table-id %d", &ip_table_id))
8603 else if (unformat (i, "unbind"))
8605 else if (unformat (i, "bind"))
8609 clib_warning ("parse error '%U'", format_unformat_error, i);
8616 errmsg ("IP prefix not set");
8620 if (MPLS_LABEL_INVALID == local_label)
8622 errmsg ("missing label");
8626 /* Construct the API message */
8627 M (MPLS_IP_BIND_UNBIND, mp);
8629 mp->mb_is_bind = is_bind;
8630 mp->mb_ip_table_id = ntohl (ip_table_id);
8631 mp->mb_mpls_table_id = 0;
8632 mp->mb_label = ntohl (local_label);
8633 clib_memcpy (&mp->mb_prefix, &pfx, sizeof (pfx));
8638 /* Wait for a reply... */
8645 api_sr_mpls_policy_add (vat_main_t * vam)
8647 unformat_input_t *i = vam->input;
8648 vl_api_sr_mpls_policy_add_t *mp;
8654 u32 *segments = NULL;
8657 /* Parse args required to build the message */
8658 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8660 if (unformat (i, "bsid %d", &bsid))
8662 else if (unformat (i, "weight %d", &weight))
8664 else if (unformat (i, "spray"))
8666 else if (unformat (i, "next %d", &sid))
8669 vec_add1 (segments, htonl (sid));
8673 clib_warning ("parse error '%U'", format_unformat_error, i);
8680 errmsg ("bsid not set");
8684 if (n_segments == 0)
8686 errmsg ("no sid in segment stack");
8690 /* Construct the API message */
8691 M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
8693 mp->bsid = htonl (bsid);
8694 mp->weight = htonl (weight);
8696 mp->n_segments = n_segments;
8697 memcpy (mp->segments, segments, sizeof (u32) * n_segments);
8698 vec_free (segments);
8703 /* Wait for a reply... */
8709 api_sr_mpls_policy_del (vat_main_t * vam)
8711 unformat_input_t *i = vam->input;
8712 vl_api_sr_mpls_policy_del_t *mp;
8716 /* Parse args required to build the message */
8717 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8719 if (unformat (i, "bsid %d", &bsid))
8723 clib_warning ("parse error '%U'", format_unformat_error, i);
8730 errmsg ("bsid not set");
8734 /* Construct the API message */
8735 M (SR_MPLS_POLICY_DEL, mp);
8737 mp->bsid = htonl (bsid);
8742 /* Wait for a reply... */
8748 api_bier_table_add_del (vat_main_t * vam)
8750 unformat_input_t *i = vam->input;
8751 vl_api_bier_table_add_del_t *mp;
8753 u32 set = 0, sub_domain = 0, hdr_len = 3;
8754 mpls_label_t local_label = MPLS_LABEL_INVALID;
8757 /* Parse args required to build the message */
8758 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8760 if (unformat (i, "sub-domain %d", &sub_domain))
8762 else if (unformat (i, "set %d", &set))
8764 else if (unformat (i, "label %d", &local_label))
8766 else if (unformat (i, "hdr-len %d", &hdr_len))
8768 else if (unformat (i, "add"))
8770 else if (unformat (i, "del"))
8774 clib_warning ("parse error '%U'", format_unformat_error, i);
8779 if (MPLS_LABEL_INVALID == local_label)
8781 errmsg ("missing label\n");
8785 /* Construct the API message */
8786 M (BIER_TABLE_ADD_DEL, mp);
8788 mp->bt_is_add = is_add;
8789 mp->bt_label = ntohl (local_label);
8790 mp->bt_tbl_id.bt_set = set;
8791 mp->bt_tbl_id.bt_sub_domain = sub_domain;
8792 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
8797 /* Wait for a reply... */
8804 api_bier_route_add_del (vat_main_t * vam)
8806 unformat_input_t *i = vam->input;
8807 vl_api_bier_route_add_del_t *mp;
8809 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
8810 ip4_address_t v4_next_hop_address;
8811 ip6_address_t v6_next_hop_address;
8812 u8 next_hop_set = 0;
8813 u8 next_hop_proto_is_ip4 = 1;
8814 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8817 /* Parse args required to build the message */
8818 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8820 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
8822 next_hop_proto_is_ip4 = 1;
8825 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
8827 next_hop_proto_is_ip4 = 0;
8830 if (unformat (i, "sub-domain %d", &sub_domain))
8832 else if (unformat (i, "set %d", &set))
8834 else if (unformat (i, "hdr-len %d", &hdr_len))
8836 else if (unformat (i, "bp %d", &bp))
8838 else if (unformat (i, "add"))
8840 else if (unformat (i, "del"))
8842 else if (unformat (i, "out-label %d", &next_hop_out_label))
8846 clib_warning ("parse error '%U'", format_unformat_error, i);
8851 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
8853 errmsg ("next hop / label set\n");
8858 errmsg ("bit=position not set\n");
8862 /* Construct the API message */
8863 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
8865 mp->br_is_add = is_add;
8866 mp->br_route.br_tbl_id.bt_set = set;
8867 mp->br_route.br_tbl_id.bt_sub_domain = sub_domain;
8868 mp->br_route.br_tbl_id.bt_hdr_len_id = hdr_len;
8869 mp->br_route.br_bp = ntohs (bp);
8870 mp->br_route.br_n_paths = 1;
8871 mp->br_route.br_paths[0].n_labels = 1;
8872 mp->br_route.br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
8873 mp->br_route.br_paths[0].proto = (next_hop_proto_is_ip4 ?
8874 FIB_API_PATH_NH_PROTO_IP4 :
8875 FIB_API_PATH_NH_PROTO_IP6);
8877 if (next_hop_proto_is_ip4)
8879 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip4,
8880 &v4_next_hop_address, sizeof (v4_next_hop_address));
8884 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip6,
8885 &v6_next_hop_address, sizeof (v6_next_hop_address));
8891 /* Wait for a reply... */
8898 api_proxy_arp_add_del (vat_main_t * vam)
8900 unformat_input_t *i = vam->input;
8901 vl_api_proxy_arp_add_del_t *mp;
8904 vl_api_ip4_address_t lo, hi;
8908 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8910 if (unformat (i, "vrf %d", &vrf_id))
8912 else if (unformat (i, "%U - %U", unformat_vl_api_ip4_address, &lo,
8913 unformat_vl_api_ip4_address, &hi))
8915 else if (unformat (i, "del"))
8919 clib_warning ("parse error '%U'", format_unformat_error, i);
8926 errmsg ("address range not set");
8930 M (PROXY_ARP_ADD_DEL, mp);
8932 mp->proxy.table_id = ntohl (vrf_id);
8933 mp->is_add = is_add;
8934 clib_memcpy (mp->proxy.low, &lo, sizeof (lo));
8935 clib_memcpy (mp->proxy.hi, &hi, sizeof (hi));
8943 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
8945 unformat_input_t *i = vam->input;
8946 vl_api_proxy_arp_intfc_enable_disable_t *mp;
8949 u8 sw_if_index_set = 0;
8952 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8954 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8955 sw_if_index_set = 1;
8956 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8957 sw_if_index_set = 1;
8958 else if (unformat (i, "enable"))
8960 else if (unformat (i, "disable"))
8964 clib_warning ("parse error '%U'", format_unformat_error, i);
8969 if (sw_if_index_set == 0)
8971 errmsg ("missing interface name or sw_if_index");
8975 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
8977 mp->sw_if_index = ntohl (sw_if_index);
8978 mp->enable_disable = enable;
8986 api_mpls_tunnel_add_del (vat_main_t * vam)
8988 unformat_input_t *i = vam->input;
8989 vl_api_mpls_tunnel_add_del_t *mp;
8991 vl_api_fib_path_t paths[8];
8992 u32 sw_if_index = ~0;
8998 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9000 if (unformat (i, "add"))
9004 (i, "del %U", api_unformat_sw_if_index, vam, &sw_if_index))
9006 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
9008 else if (unformat (i, "l2-only"))
9012 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
9015 if (8 == path_count)
9017 errmsg ("max 8 paths");
9023 clib_warning ("parse error '%U'", format_unformat_error, i);
9028 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
9030 mp->mt_is_add = is_add;
9031 mp->mt_tunnel.mt_sw_if_index = ntohl (sw_if_index);
9032 mp->mt_tunnel.mt_l2_only = l2_only;
9033 mp->mt_tunnel.mt_is_multicast = 0;
9034 mp->mt_tunnel.mt_n_paths = path_count;
9036 clib_memcpy (&mp->mt_tunnel.mt_paths, &paths,
9037 sizeof (paths[0]) * path_count);
9045 api_sw_interface_set_unnumbered (vat_main_t * vam)
9047 unformat_input_t *i = vam->input;
9048 vl_api_sw_interface_set_unnumbered_t *mp;
9050 u32 unnum_sw_index = ~0;
9052 u8 sw_if_index_set = 0;
9055 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9057 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9058 sw_if_index_set = 1;
9059 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9060 sw_if_index_set = 1;
9061 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
9063 else if (unformat (i, "del"))
9067 clib_warning ("parse error '%U'", format_unformat_error, i);
9072 if (sw_if_index_set == 0)
9074 errmsg ("missing interface name or sw_if_index");
9078 M (SW_INTERFACE_SET_UNNUMBERED, mp);
9080 mp->sw_if_index = ntohl (sw_if_index);
9081 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
9082 mp->is_add = is_add;
9090 api_ip_neighbor_add_del (vat_main_t * vam)
9092 vl_api_mac_address_t mac_address;
9093 unformat_input_t *i = vam->input;
9094 vl_api_ip_neighbor_add_del_t *mp;
9095 vl_api_address_t ip_address;
9097 u8 sw_if_index_set = 0;
9102 ip_neighbor_flags_t flags;
9104 flags = IP_NEIGHBOR_FLAG_NONE;
9105 clib_memset (&ip_address, 0, sizeof (ip_address));
9106 clib_memset (&mac_address, 0, sizeof (mac_address));
9108 /* Parse args required to build the message */
9109 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9111 if (unformat (i, "mac %U", unformat_vl_api_mac_address, &mac_address))
9115 else if (unformat (i, "del"))
9118 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9119 sw_if_index_set = 1;
9120 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9121 sw_if_index_set = 1;
9122 else if (unformat (i, "static"))
9123 flags |= IP_NEIGHBOR_FLAG_STATIC;
9124 else if (unformat (i, "no-fib-entry"))
9125 flags |= IP_NEIGHBOR_FLAG_NO_FIB_ENTRY;
9126 else if (unformat (i, "dst %U", unformat_vl_api_address, &ip_address))
9130 clib_warning ("parse error '%U'", format_unformat_error, i);
9135 if (sw_if_index_set == 0)
9137 errmsg ("missing interface name or sw_if_index");
9142 errmsg ("no address set");
9146 /* Construct the API message */
9147 M (IP_NEIGHBOR_ADD_DEL, mp);
9149 mp->neighbor.sw_if_index = ntohl (sw_if_index);
9150 mp->is_add = is_add;
9151 mp->neighbor.flags = htonl (flags);
9153 clib_memcpy (&mp->neighbor.mac_address, &mac_address,
9154 sizeof (mac_address));
9156 clib_memcpy (&mp->neighbor.ip_address, &ip_address, sizeof (ip_address));
9161 /* Wait for a reply, return good/bad news */
9167 api_create_vlan_subif (vat_main_t * vam)
9169 unformat_input_t *i = vam->input;
9170 vl_api_create_vlan_subif_t *mp;
9172 u8 sw_if_index_set = 0;
9177 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9179 if (unformat (i, "sw_if_index %d", &sw_if_index))
9180 sw_if_index_set = 1;
9182 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9183 sw_if_index_set = 1;
9184 else if (unformat (i, "vlan %d", &vlan_id))
9188 clib_warning ("parse error '%U'", format_unformat_error, i);
9193 if (sw_if_index_set == 0)
9195 errmsg ("missing interface name or sw_if_index");
9199 if (vlan_id_set == 0)
9201 errmsg ("missing vlan_id");
9204 M (CREATE_VLAN_SUBIF, mp);
9206 mp->sw_if_index = ntohl (sw_if_index);
9207 mp->vlan_id = ntohl (vlan_id);
9214 #define foreach_create_subif_bit \
9221 _(outer_vlan_id_any) \
9222 _(inner_vlan_id_any)
9225 api_create_subif (vat_main_t * vam)
9227 unformat_input_t *i = vam->input;
9228 vl_api_create_subif_t *mp;
9230 u8 sw_if_index_set = 0;
9237 u32 exact_match = 0;
9238 u32 default_sub = 0;
9239 u32 outer_vlan_id_any = 0;
9240 u32 inner_vlan_id_any = 0;
9242 u16 outer_vlan_id = 0;
9243 u16 inner_vlan_id = 0;
9246 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9248 if (unformat (i, "sw_if_index %d", &sw_if_index))
9249 sw_if_index_set = 1;
9251 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9252 sw_if_index_set = 1;
9253 else if (unformat (i, "sub_id %d", &sub_id))
9255 else if (unformat (i, "outer_vlan_id %d", &tmp))
9256 outer_vlan_id = tmp;
9257 else if (unformat (i, "inner_vlan_id %d", &tmp))
9258 inner_vlan_id = tmp;
9260 #define _(a) else if (unformat (i, #a)) a = 1 ;
9261 foreach_create_subif_bit
9265 clib_warning ("parse error '%U'", format_unformat_error, i);
9270 if (sw_if_index_set == 0)
9272 errmsg ("missing interface name or sw_if_index");
9276 if (sub_id_set == 0)
9278 errmsg ("missing sub_id");
9281 M (CREATE_SUBIF, mp);
9283 mp->sw_if_index = ntohl (sw_if_index);
9284 mp->sub_id = ntohl (sub_id);
9286 #define _(a) mp->a = a;
9287 foreach_create_subif_bit;
9290 mp->outer_vlan_id = ntohs (outer_vlan_id);
9291 mp->inner_vlan_id = ntohs (inner_vlan_id);
9299 api_reset_fib (vat_main_t * vam)
9301 unformat_input_t *i = vam->input;
9302 vl_api_reset_fib_t *mp;
9308 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9310 if (unformat (i, "vrf %d", &vrf_id))
9312 else if (unformat (i, "ipv6"))
9316 clib_warning ("parse error '%U'", format_unformat_error, i);
9321 if (vrf_id_set == 0)
9323 errmsg ("missing vrf id");
9329 mp->vrf_id = ntohl (vrf_id);
9330 mp->is_ipv6 = is_ipv6;
9338 api_dhcp_proxy_config (vat_main_t * vam)
9340 unformat_input_t *i = vam->input;
9341 vl_api_dhcp_proxy_config_t *mp;
9343 u32 server_vrf_id = 0;
9345 u8 v4_address_set = 0;
9346 u8 v6_address_set = 0;
9347 ip4_address_t v4address;
9348 ip6_address_t v6address;
9349 u8 v4_src_address_set = 0;
9350 u8 v6_src_address_set = 0;
9351 ip4_address_t v4srcaddress;
9352 ip6_address_t v6srcaddress;
9355 /* Parse args required to build the message */
9356 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9358 if (unformat (i, "del"))
9360 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
9362 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
9364 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
9366 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
9368 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
9369 v4_src_address_set = 1;
9370 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
9371 v6_src_address_set = 1;
9376 if (v4_address_set && v6_address_set)
9378 errmsg ("both v4 and v6 server addresses set");
9381 if (!v4_address_set && !v6_address_set)
9383 errmsg ("no server addresses set");
9387 if (v4_src_address_set && v6_src_address_set)
9389 errmsg ("both v4 and v6 src addresses set");
9392 if (!v4_src_address_set && !v6_src_address_set)
9394 errmsg ("no src addresses set");
9398 if (!(v4_src_address_set && v4_address_set) &&
9399 !(v6_src_address_set && v6_address_set))
9401 errmsg ("no matching server and src addresses set");
9405 /* Construct the API message */
9406 M (DHCP_PROXY_CONFIG, mp);
9408 mp->is_add = is_add;
9409 mp->rx_vrf_id = ntohl (rx_vrf_id);
9410 mp->server_vrf_id = ntohl (server_vrf_id);
9414 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
9415 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
9419 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
9420 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
9426 /* Wait for a reply, return good/bad news */
9431 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
9432 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
9435 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
9437 vat_main_t *vam = &vat_main;
9438 u32 i, count = mp->count;
9439 vl_api_dhcp_server_t *s;
9443 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9444 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9445 ntohl (mp->rx_vrf_id),
9446 format_ip6_address, mp->dhcp_src_address,
9447 mp->vss_type, mp->vss_vpn_ascii_id,
9448 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9451 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9452 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9453 ntohl (mp->rx_vrf_id),
9454 format_ip4_address, mp->dhcp_src_address,
9455 mp->vss_type, mp->vss_vpn_ascii_id,
9456 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9458 for (i = 0; i < count; i++)
9460 s = &mp->servers[i];
9464 " Server Table-ID %d, Server Address %U",
9465 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
9468 " Server Table-ID %d, Server Address %U",
9469 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
9473 static void vl_api_dhcp_proxy_details_t_handler_json
9474 (vl_api_dhcp_proxy_details_t * mp)
9476 vat_main_t *vam = &vat_main;
9477 vat_json_node_t *node = NULL;
9478 u32 i, count = mp->count;
9480 struct in6_addr ip6;
9481 vl_api_dhcp_server_t *s;
9483 if (VAT_JSON_ARRAY != vam->json_tree.type)
9485 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9486 vat_json_init_array (&vam->json_tree);
9488 node = vat_json_array_add (&vam->json_tree);
9490 vat_json_init_object (node);
9491 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
9492 vat_json_object_add_bytes (node, "vss-type", &mp->vss_type,
9493 sizeof (mp->vss_type));
9494 vat_json_object_add_string_copy (node, "vss-vpn-ascii-id",
9495 mp->vss_vpn_ascii_id);
9496 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
9497 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
9501 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
9502 vat_json_object_add_ip6 (node, "src_address", ip6);
9506 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
9507 vat_json_object_add_ip4 (node, "src_address", ip4);
9510 for (i = 0; i < count; i++)
9512 s = &mp->servers[i];
9514 vat_json_object_add_uint (node, "server-table-id",
9515 ntohl (s->server_vrf_id));
9519 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
9520 vat_json_object_add_ip4 (node, "src_address", ip4);
9524 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
9525 vat_json_object_add_ip6 (node, "server_address", ip6);
9531 api_dhcp_proxy_dump (vat_main_t * vam)
9533 unformat_input_t *i = vam->input;
9534 vl_api_control_ping_t *mp_ping;
9535 vl_api_dhcp_proxy_dump_t *mp;
9539 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9541 if (unformat (i, "ipv6"))
9545 clib_warning ("parse error '%U'", format_unformat_error, i);
9550 M (DHCP_PROXY_DUMP, mp);
9552 mp->is_ip6 = is_ipv6;
9555 /* Use a control ping for synchronization */
9556 MPING (CONTROL_PING, mp_ping);
9564 api_dhcp_proxy_set_vss (vat_main_t * vam)
9566 unformat_input_t *i = vam->input;
9567 vl_api_dhcp_proxy_set_vss_t *mp;
9571 u8 vss_type = VSS_TYPE_DEFAULT;
9572 u8 *vpn_ascii_id = 0;
9577 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9579 if (unformat (i, "tbl_id %d", &tbl_id))
9581 else if (unformat (i, "vpn_ascii_id %s", &vpn_ascii_id))
9582 vss_type = VSS_TYPE_ASCII;
9583 else if (unformat (i, "fib_id %d", &fib_id))
9584 vss_type = VSS_TYPE_VPN_ID;
9585 else if (unformat (i, "oui %d", &oui))
9586 vss_type = VSS_TYPE_VPN_ID;
9587 else if (unformat (i, "ipv6"))
9589 else if (unformat (i, "del"))
9597 errmsg ("missing tbl_id ");
9598 vec_free (vpn_ascii_id);
9602 if ((vpn_ascii_id) && (vec_len (vpn_ascii_id) > 128))
9604 errmsg ("vpn_ascii_id cannot be longer than 128 ");
9605 vec_free (vpn_ascii_id);
9609 M (DHCP_PROXY_SET_VSS, mp);
9610 mp->tbl_id = ntohl (tbl_id);
9611 mp->vss_type = vss_type;
9614 clib_memcpy (mp->vpn_ascii_id, vpn_ascii_id, vec_len (vpn_ascii_id));
9615 mp->vpn_ascii_id[vec_len (vpn_ascii_id)] = 0;
9617 mp->vpn_index = ntohl (fib_id);
9618 mp->oui = ntohl (oui);
9619 mp->is_ipv6 = is_ipv6;
9620 mp->is_add = is_add;
9625 vec_free (vpn_ascii_id);
9630 api_dhcp_client_config (vat_main_t * vam)
9632 unformat_input_t *i = vam->input;
9633 vl_api_dhcp_client_config_t *mp;
9635 u8 sw_if_index_set = 0;
9638 u8 disable_event = 0;
9641 /* Parse args required to build the message */
9642 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9644 if (unformat (i, "del"))
9647 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9648 sw_if_index_set = 1;
9649 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9650 sw_if_index_set = 1;
9651 else if (unformat (i, "hostname %s", &hostname))
9653 else if (unformat (i, "disable_event"))
9659 if (sw_if_index_set == 0)
9661 errmsg ("missing interface name or sw_if_index");
9665 if (vec_len (hostname) > 63)
9667 errmsg ("hostname too long");
9669 vec_add1 (hostname, 0);
9671 /* Construct the API message */
9672 M (DHCP_CLIENT_CONFIG, mp);
9674 mp->is_add = is_add;
9675 mp->client.sw_if_index = htonl (sw_if_index);
9676 clib_memcpy (mp->client.hostname, hostname, vec_len (hostname));
9677 vec_free (hostname);
9678 mp->client.want_dhcp_event = disable_event ? 0 : 1;
9679 mp->client.pid = htonl (getpid ());
9684 /* Wait for a reply, return good/bad news */
9690 api_set_ip_flow_hash (vat_main_t * vam)
9692 unformat_input_t *i = vam->input;
9693 vl_api_set_ip_flow_hash_t *mp;
9705 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9707 if (unformat (i, "vrf %d", &vrf_id))
9709 else if (unformat (i, "ipv6"))
9711 else if (unformat (i, "src"))
9713 else if (unformat (i, "dst"))
9715 else if (unformat (i, "sport"))
9717 else if (unformat (i, "dport"))
9719 else if (unformat (i, "proto"))
9721 else if (unformat (i, "reverse"))
9726 clib_warning ("parse error '%U'", format_unformat_error, i);
9731 if (vrf_id_set == 0)
9733 errmsg ("missing vrf id");
9737 M (SET_IP_FLOW_HASH, mp);
9743 mp->reverse = reverse;
9744 mp->vrf_id = ntohl (vrf_id);
9745 mp->is_ipv6 = is_ipv6;
9753 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
9755 unformat_input_t *i = vam->input;
9756 vl_api_sw_interface_ip6_enable_disable_t *mp;
9758 u8 sw_if_index_set = 0;
9762 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9764 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9765 sw_if_index_set = 1;
9766 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9767 sw_if_index_set = 1;
9768 else if (unformat (i, "enable"))
9770 else if (unformat (i, "disable"))
9774 clib_warning ("parse error '%U'", format_unformat_error, i);
9779 if (sw_if_index_set == 0)
9781 errmsg ("missing interface name or sw_if_index");
9785 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
9787 mp->sw_if_index = ntohl (sw_if_index);
9788 mp->enable = enable;
9796 api_ip6nd_proxy_add_del (vat_main_t * vam)
9798 unformat_input_t *i = vam->input;
9799 vl_api_ip6nd_proxy_add_del_t *mp;
9800 u32 sw_if_index = ~0;
9801 u8 v6_address_set = 0;
9802 vl_api_ip6_address_t v6address;
9806 /* Parse args required to build the message */
9807 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9809 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9811 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9813 else if (unformat (i, "%U", unformat_vl_api_ip6_address, &v6address))
9815 if (unformat (i, "del"))
9819 clib_warning ("parse error '%U'", format_unformat_error, i);
9824 if (sw_if_index == ~0)
9826 errmsg ("missing interface name or sw_if_index");
9829 if (!v6_address_set)
9831 errmsg ("no address set");
9835 /* Construct the API message */
9836 M (IP6ND_PROXY_ADD_DEL, mp);
9838 mp->is_del = is_del;
9839 mp->sw_if_index = ntohl (sw_if_index);
9840 clib_memcpy (mp->ip, v6address, sizeof (v6address));
9845 /* Wait for a reply, return good/bad news */
9851 api_ip6nd_proxy_dump (vat_main_t * vam)
9853 vl_api_ip6nd_proxy_dump_t *mp;
9854 vl_api_control_ping_t *mp_ping;
9857 M (IP6ND_PROXY_DUMP, mp);
9861 /* Use a control ping for synchronization */
9862 MPING (CONTROL_PING, mp_ping);
9869 static void vl_api_ip6nd_proxy_details_t_handler
9870 (vl_api_ip6nd_proxy_details_t * mp)
9872 vat_main_t *vam = &vat_main;
9874 print (vam->ofp, "host %U sw_if_index %d",
9875 format_vl_api_ip6_address, mp->ip, ntohl (mp->sw_if_index));
9878 static void vl_api_ip6nd_proxy_details_t_handler_json
9879 (vl_api_ip6nd_proxy_details_t * mp)
9881 vat_main_t *vam = &vat_main;
9882 struct in6_addr ip6;
9883 vat_json_node_t *node = NULL;
9885 if (VAT_JSON_ARRAY != vam->json_tree.type)
9887 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9888 vat_json_init_array (&vam->json_tree);
9890 node = vat_json_array_add (&vam->json_tree);
9892 vat_json_init_object (node);
9893 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9895 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
9896 vat_json_object_add_ip6 (node, "host", ip6);
9900 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
9902 unformat_input_t *i = vam->input;
9903 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
9905 u8 sw_if_index_set = 0;
9906 u8 v6_address_set = 0;
9907 vl_api_prefix_t pfx;
9909 u8 no_advertise = 0;
9911 u8 no_autoconfig = 0;
9914 u32 val_lifetime = 0;
9915 u32 pref_lifetime = 0;
9918 /* Parse args required to build the message */
9919 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9921 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9922 sw_if_index_set = 1;
9923 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9924 sw_if_index_set = 1;
9925 else if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
9927 else if (unformat (i, "val_life %d", &val_lifetime))
9929 else if (unformat (i, "pref_life %d", &pref_lifetime))
9931 else if (unformat (i, "def"))
9933 else if (unformat (i, "noadv"))
9935 else if (unformat (i, "offl"))
9937 else if (unformat (i, "noauto"))
9939 else if (unformat (i, "nolink"))
9941 else if (unformat (i, "isno"))
9945 clib_warning ("parse error '%U'", format_unformat_error, i);
9950 if (sw_if_index_set == 0)
9952 errmsg ("missing interface name or sw_if_index");
9955 if (!v6_address_set)
9957 errmsg ("no address set");
9961 /* Construct the API message */
9962 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
9964 mp->sw_if_index = ntohl (sw_if_index);
9965 clib_memcpy (&mp->prefix, &pfx, sizeof (pfx));
9966 mp->use_default = use_default;
9967 mp->no_advertise = no_advertise;
9968 mp->off_link = off_link;
9969 mp->no_autoconfig = no_autoconfig;
9970 mp->no_onlink = no_onlink;
9972 mp->val_lifetime = ntohl (val_lifetime);
9973 mp->pref_lifetime = ntohl (pref_lifetime);
9978 /* Wait for a reply, return good/bad news */
9984 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
9986 unformat_input_t *i = vam->input;
9987 vl_api_sw_interface_ip6nd_ra_config_t *mp;
9989 u8 sw_if_index_set = 0;
9994 u8 send_unicast = 0;
9997 u8 default_router = 0;
9998 u32 max_interval = 0;
9999 u32 min_interval = 0;
10001 u32 initial_count = 0;
10002 u32 initial_interval = 0;
10006 /* Parse args required to build the message */
10007 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10009 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10010 sw_if_index_set = 1;
10011 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10012 sw_if_index_set = 1;
10013 else if (unformat (i, "maxint %d", &max_interval))
10015 else if (unformat (i, "minint %d", &min_interval))
10017 else if (unformat (i, "life %d", &lifetime))
10019 else if (unformat (i, "count %d", &initial_count))
10021 else if (unformat (i, "interval %d", &initial_interval))
10023 else if (unformat (i, "suppress") || unformat (i, "surpress"))
10025 else if (unformat (i, "managed"))
10027 else if (unformat (i, "other"))
10029 else if (unformat (i, "ll"))
10031 else if (unformat (i, "send"))
10033 else if (unformat (i, "cease"))
10035 else if (unformat (i, "isno"))
10037 else if (unformat (i, "def"))
10038 default_router = 1;
10041 clib_warning ("parse error '%U'", format_unformat_error, i);
10046 if (sw_if_index_set == 0)
10048 errmsg ("missing interface name or sw_if_index");
10052 /* Construct the API message */
10053 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
10055 mp->sw_if_index = ntohl (sw_if_index);
10056 mp->max_interval = ntohl (max_interval);
10057 mp->min_interval = ntohl (min_interval);
10058 mp->lifetime = ntohl (lifetime);
10059 mp->initial_count = ntohl (initial_count);
10060 mp->initial_interval = ntohl (initial_interval);
10061 mp->suppress = suppress;
10062 mp->managed = managed;
10064 mp->ll_option = ll_option;
10065 mp->send_unicast = send_unicast;
10068 mp->default_router = default_router;
10073 /* Wait for a reply, return good/bad news */
10079 api_set_arp_neighbor_limit (vat_main_t * vam)
10081 unformat_input_t *i = vam->input;
10082 vl_api_set_arp_neighbor_limit_t *mp;
10088 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10090 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
10092 else if (unformat (i, "ipv6"))
10096 clib_warning ("parse error '%U'", format_unformat_error, i);
10101 if (limit_set == 0)
10103 errmsg ("missing limit value");
10107 M (SET_ARP_NEIGHBOR_LIMIT, mp);
10109 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
10110 mp->is_ipv6 = is_ipv6;
10118 api_l2_patch_add_del (vat_main_t * vam)
10120 unformat_input_t *i = vam->input;
10121 vl_api_l2_patch_add_del_t *mp;
10122 u32 rx_sw_if_index;
10123 u8 rx_sw_if_index_set = 0;
10124 u32 tx_sw_if_index;
10125 u8 tx_sw_if_index_set = 0;
10129 /* Parse args required to build the message */
10130 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10132 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
10133 rx_sw_if_index_set = 1;
10134 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
10135 tx_sw_if_index_set = 1;
10136 else if (unformat (i, "rx"))
10138 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10140 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10142 rx_sw_if_index_set = 1;
10147 else if (unformat (i, "tx"))
10149 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10151 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10153 tx_sw_if_index_set = 1;
10158 else if (unformat (i, "del"))
10164 if (rx_sw_if_index_set == 0)
10166 errmsg ("missing rx interface name or rx_sw_if_index");
10170 if (tx_sw_if_index_set == 0)
10172 errmsg ("missing tx interface name or tx_sw_if_index");
10176 M (L2_PATCH_ADD_DEL, mp);
10178 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
10179 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
10180 mp->is_add = is_add;
10188 u8 localsid_addr[16];
10197 api_sr_localsid_add_del (vat_main_t * vam)
10199 unformat_input_t *i = vam->input;
10200 vl_api_sr_localsid_add_del_t *mp;
10203 ip6_address_t localsid;
10207 u32 fib_table = ~(u32) 0;
10208 ip6_address_t nh_addr6;
10209 ip4_address_t nh_addr4;
10210 clib_memset (&nh_addr6, 0, sizeof (ip6_address_t));
10211 clib_memset (&nh_addr4, 0, sizeof (ip4_address_t));
10213 bool nexthop_set = 0;
10217 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10219 if (unformat (i, "del"))
10221 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
10222 else if (unformat (i, "next-hop %U", unformat_ip4_address, &nh_addr4))
10224 else if (unformat (i, "next-hop %U", unformat_ip6_address, &nh_addr6))
10226 else if (unformat (i, "behavior %u", &behavior));
10227 else if (unformat (i, "sw_if_index %u", &sw_if_index));
10228 else if (unformat (i, "fib-table %u", &fib_table));
10229 else if (unformat (i, "end.psp %u", &behavior));
10234 M (SR_LOCALSID_ADD_DEL, mp);
10236 clib_memcpy (mp->localsid.addr, &localsid, sizeof (mp->localsid));
10239 clib_memcpy (mp->nh_addr6, &nh_addr6, sizeof (mp->nh_addr6));
10240 clib_memcpy (mp->nh_addr4, &nh_addr4, sizeof (mp->nh_addr4));
10242 mp->behavior = behavior;
10243 mp->sw_if_index = ntohl (sw_if_index);
10244 mp->fib_table = ntohl (fib_table);
10245 mp->end_psp = end_psp;
10246 mp->is_del = is_del;
10254 api_ioam_enable (vat_main_t * vam)
10256 unformat_input_t *input = vam->input;
10257 vl_api_ioam_enable_t *mp;
10259 int has_trace_option = 0;
10260 int has_pot_option = 0;
10261 int has_seqno_option = 0;
10262 int has_analyse_option = 0;
10265 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10267 if (unformat (input, "trace"))
10268 has_trace_option = 1;
10269 else if (unformat (input, "pot"))
10270 has_pot_option = 1;
10271 else if (unformat (input, "seqno"))
10272 has_seqno_option = 1;
10273 else if (unformat (input, "analyse"))
10274 has_analyse_option = 1;
10278 M (IOAM_ENABLE, mp);
10279 mp->id = htons (id);
10280 mp->seqno = has_seqno_option;
10281 mp->analyse = has_analyse_option;
10282 mp->pot_enable = has_pot_option;
10283 mp->trace_enable = has_trace_option;
10292 api_ioam_disable (vat_main_t * vam)
10294 vl_api_ioam_disable_t *mp;
10297 M (IOAM_DISABLE, mp);
10303 #define foreach_tcp_proto_field \
10307 #define foreach_udp_proto_field \
10311 #define foreach_ip4_proto_field \
10323 u16 src_port, dst_port;
10326 #if VPP_API_TEST_BUILTIN == 0
10328 unformat_tcp_mask (unformat_input_t * input, va_list * args)
10330 u8 **maskp = va_arg (*args, u8 **);
10332 u8 found_something = 0;
10335 #define _(a) u8 a=0;
10336 foreach_tcp_proto_field;
10339 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10342 #define _(a) else if (unformat (input, #a)) a=1;
10343 foreach_tcp_proto_field
10349 #define _(a) found_something += a;
10350 foreach_tcp_proto_field;
10353 if (found_something == 0)
10356 vec_validate (mask, sizeof (*tcp) - 1);
10358 tcp = (tcp_header_t *) mask;
10360 #define _(a) if (a) clib_memset (&tcp->a, 0xff, sizeof (tcp->a));
10361 foreach_tcp_proto_field;
10369 unformat_udp_mask (unformat_input_t * input, va_list * args)
10371 u8 **maskp = va_arg (*args, u8 **);
10373 u8 found_something = 0;
10376 #define _(a) u8 a=0;
10377 foreach_udp_proto_field;
10380 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10383 #define _(a) else if (unformat (input, #a)) a=1;
10384 foreach_udp_proto_field
10390 #define _(a) found_something += a;
10391 foreach_udp_proto_field;
10394 if (found_something == 0)
10397 vec_validate (mask, sizeof (*udp) - 1);
10399 udp = (udp_header_t *) mask;
10401 #define _(a) if (a) clib_memset (&udp->a, 0xff, sizeof (udp->a));
10402 foreach_udp_proto_field;
10410 unformat_l4_mask (unformat_input_t * input, va_list * args)
10412 u8 **maskp = va_arg (*args, u8 **);
10413 u16 src_port = 0, dst_port = 0;
10414 tcpudp_header_t *tcpudp;
10416 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10418 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
10420 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
10422 else if (unformat (input, "src_port"))
10424 else if (unformat (input, "dst_port"))
10430 if (!src_port && !dst_port)
10434 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
10436 tcpudp = (tcpudp_header_t *) mask;
10437 tcpudp->src_port = src_port;
10438 tcpudp->dst_port = dst_port;
10446 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10448 u8 **maskp = va_arg (*args, u8 **);
10450 u8 found_something = 0;
10453 #define _(a) u8 a=0;
10454 foreach_ip4_proto_field;
10460 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10462 if (unformat (input, "version"))
10464 else if (unformat (input, "hdr_length"))
10466 else if (unformat (input, "src"))
10468 else if (unformat (input, "dst"))
10470 else if (unformat (input, "proto"))
10473 #define _(a) else if (unformat (input, #a)) a=1;
10474 foreach_ip4_proto_field
10480 #define _(a) found_something += a;
10481 foreach_ip4_proto_field;
10484 if (found_something == 0)
10487 vec_validate (mask, sizeof (*ip) - 1);
10489 ip = (ip4_header_t *) mask;
10491 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
10492 foreach_ip4_proto_field;
10495 ip->ip_version_and_header_length = 0;
10498 ip->ip_version_and_header_length |= 0xF0;
10501 ip->ip_version_and_header_length |= 0x0F;
10507 #define foreach_ip6_proto_field \
10510 _(payload_length) \
10515 unformat_ip6_mask (unformat_input_t * input, va_list * args)
10517 u8 **maskp = va_arg (*args, u8 **);
10519 u8 found_something = 0;
10521 u32 ip_version_traffic_class_and_flow_label;
10523 #define _(a) u8 a=0;
10524 foreach_ip6_proto_field;
10527 u8 traffic_class = 0;
10530 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10532 if (unformat (input, "version"))
10534 else if (unformat (input, "traffic-class"))
10536 else if (unformat (input, "flow-label"))
10538 else if (unformat (input, "src"))
10540 else if (unformat (input, "dst"))
10542 else if (unformat (input, "proto"))
10545 #define _(a) else if (unformat (input, #a)) a=1;
10546 foreach_ip6_proto_field
10552 #define _(a) found_something += a;
10553 foreach_ip6_proto_field;
10556 if (found_something == 0)
10559 vec_validate (mask, sizeof (*ip) - 1);
10561 ip = (ip6_header_t *) mask;
10563 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
10564 foreach_ip6_proto_field;
10567 ip_version_traffic_class_and_flow_label = 0;
10570 ip_version_traffic_class_and_flow_label |= 0xF0000000;
10573 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
10576 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
10578 ip->ip_version_traffic_class_and_flow_label =
10579 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10586 unformat_l3_mask (unformat_input_t * input, va_list * args)
10588 u8 **maskp = va_arg (*args, u8 **);
10590 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10592 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
10594 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
10603 unformat_l2_mask (unformat_input_t * input, va_list * args)
10605 u8 **maskp = va_arg (*args, u8 **);
10612 u8 ignore_tag1 = 0;
10613 u8 ignore_tag2 = 0;
10620 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10622 if (unformat (input, "src"))
10624 else if (unformat (input, "dst"))
10626 else if (unformat (input, "proto"))
10628 else if (unformat (input, "tag1"))
10630 else if (unformat (input, "tag2"))
10632 else if (unformat (input, "ignore-tag1"))
10634 else if (unformat (input, "ignore-tag2"))
10636 else if (unformat (input, "cos1"))
10638 else if (unformat (input, "cos2"))
10640 else if (unformat (input, "dot1q"))
10642 else if (unformat (input, "dot1ad"))
10647 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
10648 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10651 if (tag1 || ignore_tag1 || cos1 || dot1q)
10653 if (tag2 || ignore_tag2 || cos2 || dot1ad)
10656 vec_validate (mask, len - 1);
10659 clib_memset (mask, 0xff, 6);
10662 clib_memset (mask + 6, 0xff, 6);
10664 if (tag2 || dot1ad)
10666 /* inner vlan tag */
10675 mask[21] = mask[20] = 0xff;
10696 mask[16] = mask[17] = 0xff;
10706 mask[12] = mask[13] = 0xff;
10713 unformat_classify_mask (unformat_input_t * input, va_list * args)
10715 u8 **maskp = va_arg (*args, u8 **);
10716 u32 *skipp = va_arg (*args, u32 *);
10717 u32 *matchp = va_arg (*args, u32 *);
10725 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10727 if (unformat (input, "hex %U", unformat_hex_string, &mask))
10729 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
10731 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
10733 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
10747 if (mask || l2 || l3 || l4)
10749 if (l2 || l3 || l4)
10751 /* "With a free Ethernet header in every package" */
10753 vec_validate (l2, 13);
10757 vec_append (mask, l3);
10762 vec_append (mask, l4);
10767 /* Scan forward looking for the first significant mask octet */
10768 for (i = 0; i < vec_len (mask); i++)
10772 /* compute (skip, match) params */
10773 *skipp = i / sizeof (u32x4);
10774 vec_delete (mask, *skipp * sizeof (u32x4), 0);
10776 /* Pad mask to an even multiple of the vector size */
10777 while (vec_len (mask) % sizeof (u32x4))
10778 vec_add1 (mask, 0);
10780 match = vec_len (mask) / sizeof (u32x4);
10782 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
10784 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
10785 if (*tmp || *(tmp + 1))
10790 clib_warning ("BUG: match 0");
10792 _vec_len (mask) = match * sizeof (u32x4);
10802 #endif /* VPP_API_TEST_BUILTIN */
10804 #define foreach_l2_next \
10806 _(ethernet, ETHERNET_INPUT) \
10807 _(ip4, IP4_INPUT) \
10811 unformat_l2_next_index (unformat_input_t * input, va_list * args)
10813 u32 *miss_next_indexp = va_arg (*args, u32 *);
10814 u32 next_index = 0;
10818 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
10822 if (unformat (input, "%d", &tmp))
10831 *miss_next_indexp = next_index;
10835 #define foreach_ip_next \
10838 _(rewrite, REWRITE)
10841 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
10843 u32 *miss_next_indexp = va_arg (*args, u32 *);
10844 u32 next_index = 0;
10848 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
10852 if (unformat (input, "%d", &tmp))
10861 *miss_next_indexp = next_index;
10865 #define foreach_acl_next \
10869 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
10871 u32 *miss_next_indexp = va_arg (*args, u32 *);
10872 u32 next_index = 0;
10876 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
10880 if (unformat (input, "permit"))
10885 else if (unformat (input, "%d", &tmp))
10894 *miss_next_indexp = next_index;
10899 unformat_policer_precolor (unformat_input_t * input, va_list * args)
10901 u32 *r = va_arg (*args, u32 *);
10903 if (unformat (input, "conform-color"))
10904 *r = POLICE_CONFORM;
10905 else if (unformat (input, "exceed-color"))
10906 *r = POLICE_EXCEED;
10914 api_classify_add_del_table (vat_main_t * vam)
10916 unformat_input_t *i = vam->input;
10917 vl_api_classify_add_del_table_t *mp;
10924 u32 table_index = ~0;
10925 u32 next_table_index = ~0;
10926 u32 miss_next_index = ~0;
10927 u32 memory_size = 32 << 20;
10929 u32 current_data_flag = 0;
10930 int current_data_offset = 0;
10933 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10935 if (unformat (i, "del"))
10937 else if (unformat (i, "del-chain"))
10942 else if (unformat (i, "buckets %d", &nbuckets))
10944 else if (unformat (i, "memory_size %d", &memory_size))
10946 else if (unformat (i, "skip %d", &skip))
10948 else if (unformat (i, "match %d", &match))
10950 else if (unformat (i, "table %d", &table_index))
10952 else if (unformat (i, "mask %U", unformat_classify_mask,
10953 &mask, &skip, &match))
10955 else if (unformat (i, "next-table %d", &next_table_index))
10957 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
10960 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
10963 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
10966 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
10968 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
10974 if (is_add && mask == 0)
10976 errmsg ("Mask required");
10980 if (is_add && skip == ~0)
10982 errmsg ("skip count required");
10986 if (is_add && match == ~0)
10988 errmsg ("match count required");
10992 if (!is_add && table_index == ~0)
10994 errmsg ("table index required for delete");
10998 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
11000 mp->is_add = is_add;
11001 mp->del_chain = del_chain;
11002 mp->table_index = ntohl (table_index);
11003 mp->nbuckets = ntohl (nbuckets);
11004 mp->memory_size = ntohl (memory_size);
11005 mp->skip_n_vectors = ntohl (skip);
11006 mp->match_n_vectors = ntohl (match);
11007 mp->next_table_index = ntohl (next_table_index);
11008 mp->miss_next_index = ntohl (miss_next_index);
11009 mp->current_data_flag = ntohl (current_data_flag);
11010 mp->current_data_offset = ntohl (current_data_offset);
11011 mp->mask_len = ntohl (vec_len (mask));
11012 clib_memcpy (mp->mask, mask, vec_len (mask));
11021 #if VPP_API_TEST_BUILTIN == 0
11023 unformat_l4_match (unformat_input_t * input, va_list * args)
11025 u8 **matchp = va_arg (*args, u8 **);
11027 u8 *proto_header = 0;
11033 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11035 if (unformat (input, "src_port %d", &src_port))
11037 else if (unformat (input, "dst_port %d", &dst_port))
11043 h.src_port = clib_host_to_net_u16 (src_port);
11044 h.dst_port = clib_host_to_net_u16 (dst_port);
11045 vec_validate (proto_header, sizeof (h) - 1);
11046 memcpy (proto_header, &h, sizeof (h));
11048 *matchp = proto_header;
11054 unformat_ip4_match (unformat_input_t * input, va_list * args)
11056 u8 **matchp = va_arg (*args, u8 **);
11061 int hdr_length = 0;
11062 u32 hdr_length_val;
11063 int src = 0, dst = 0;
11064 ip4_address_t src_val, dst_val;
11071 int fragment_id = 0;
11072 u32 fragment_id_val;
11078 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11080 if (unformat (input, "version %d", &version_val))
11082 else if (unformat (input, "hdr_length %d", &hdr_length_val))
11084 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
11086 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
11088 else if (unformat (input, "proto %d", &proto_val))
11090 else if (unformat (input, "tos %d", &tos_val))
11092 else if (unformat (input, "length %d", &length_val))
11094 else if (unformat (input, "fragment_id %d", &fragment_id_val))
11096 else if (unformat (input, "ttl %d", &ttl_val))
11098 else if (unformat (input, "checksum %d", &checksum_val))
11104 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
11105 + ttl + checksum == 0)
11109 * Aligned because we use the real comparison functions
11111 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11113 ip = (ip4_header_t *) match;
11115 /* These are realistically matched in practice */
11117 ip->src_address.as_u32 = src_val.as_u32;
11120 ip->dst_address.as_u32 = dst_val.as_u32;
11123 ip->protocol = proto_val;
11126 /* These are not, but they're included for completeness */
11128 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
11131 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
11137 ip->length = clib_host_to_net_u16 (length_val);
11143 ip->checksum = clib_host_to_net_u16 (checksum_val);
11150 unformat_ip6_match (unformat_input_t * input, va_list * args)
11152 u8 **matchp = va_arg (*args, u8 **);
11157 u8 traffic_class = 0;
11158 u32 traffic_class_val = 0;
11161 int src = 0, dst = 0;
11162 ip6_address_t src_val, dst_val;
11165 int payload_length = 0;
11166 u32 payload_length_val;
11169 u32 ip_version_traffic_class_and_flow_label;
11171 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11173 if (unformat (input, "version %d", &version_val))
11175 else if (unformat (input, "traffic_class %d", &traffic_class_val))
11177 else if (unformat (input, "flow_label %d", &flow_label_val))
11179 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
11181 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
11183 else if (unformat (input, "proto %d", &proto_val))
11185 else if (unformat (input, "payload_length %d", &payload_length_val))
11186 payload_length = 1;
11187 else if (unformat (input, "hop_limit %d", &hop_limit_val))
11193 if (version + traffic_class + flow_label + src + dst + proto +
11194 payload_length + hop_limit == 0)
11198 * Aligned because we use the real comparison functions
11200 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11202 ip = (ip6_header_t *) match;
11205 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
11208 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
11211 ip->protocol = proto_val;
11213 ip_version_traffic_class_and_flow_label = 0;
11216 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
11219 ip_version_traffic_class_and_flow_label |=
11220 (traffic_class_val & 0xFF) << 20;
11223 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
11225 ip->ip_version_traffic_class_and_flow_label =
11226 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11228 if (payload_length)
11229 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
11232 ip->hop_limit = hop_limit_val;
11239 unformat_l3_match (unformat_input_t * input, va_list * args)
11241 u8 **matchp = va_arg (*args, u8 **);
11243 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11245 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
11247 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
11256 unformat_vlan_tag (unformat_input_t * input, va_list * args)
11258 u8 *tagp = va_arg (*args, u8 *);
11261 if (unformat (input, "%d", &tag))
11263 tagp[0] = (tag >> 8) & 0x0F;
11264 tagp[1] = tag & 0xFF;
11272 unformat_l2_match (unformat_input_t * input, va_list * args)
11274 u8 **matchp = va_arg (*args, u8 **);
11287 u8 ignore_tag1 = 0;
11288 u8 ignore_tag2 = 0;
11294 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11296 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
11299 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
11301 else if (unformat (input, "proto %U",
11302 unformat_ethernet_type_host_byte_order, &proto_val))
11304 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
11306 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
11308 else if (unformat (input, "ignore-tag1"))
11310 else if (unformat (input, "ignore-tag2"))
11312 else if (unformat (input, "cos1 %d", &cos1_val))
11314 else if (unformat (input, "cos2 %d", &cos2_val))
11319 if ((src + dst + proto + tag1 + tag2 +
11320 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11323 if (tag1 || ignore_tag1 || cos1)
11325 if (tag2 || ignore_tag2 || cos2)
11328 vec_validate_aligned (match, len - 1, sizeof (u32x4));
11331 clib_memcpy (match, dst_val, 6);
11334 clib_memcpy (match + 6, src_val, 6);
11338 /* inner vlan tag */
11339 match[19] = tag2_val[1];
11340 match[18] = tag2_val[0];
11342 match[18] |= (cos2_val & 0x7) << 5;
11345 match[21] = proto_val & 0xff;
11346 match[20] = proto_val >> 8;
11350 match[15] = tag1_val[1];
11351 match[14] = tag1_val[0];
11354 match[14] |= (cos1_val & 0x7) << 5;
11360 match[15] = tag1_val[1];
11361 match[14] = tag1_val[0];
11364 match[17] = proto_val & 0xff;
11365 match[16] = proto_val >> 8;
11368 match[14] |= (cos1_val & 0x7) << 5;
11374 match[18] |= (cos2_val & 0x7) << 5;
11376 match[14] |= (cos1_val & 0x7) << 5;
11379 match[13] = proto_val & 0xff;
11380 match[12] = proto_val >> 8;
11388 unformat_qos_source (unformat_input_t * input, va_list * args)
11390 int *qs = va_arg (*args, int *);
11392 if (unformat (input, "ip"))
11393 *qs = QOS_SOURCE_IP;
11394 else if (unformat (input, "mpls"))
11395 *qs = QOS_SOURCE_MPLS;
11396 else if (unformat (input, "ext"))
11397 *qs = QOS_SOURCE_EXT;
11398 else if (unformat (input, "vlan"))
11399 *qs = QOS_SOURCE_VLAN;
11408 api_unformat_classify_match (unformat_input_t * input, va_list * args)
11410 u8 **matchp = va_arg (*args, u8 **);
11411 u32 skip_n_vectors = va_arg (*args, u32);
11412 u32 match_n_vectors = va_arg (*args, u32);
11419 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11421 if (unformat (input, "hex %U", unformat_hex_string, &match))
11423 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
11425 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
11427 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11441 if (match || l2 || l3 || l4)
11443 if (l2 || l3 || l4)
11445 /* "Win a free Ethernet header in every packet" */
11447 vec_validate_aligned (l2, 13, sizeof (u32x4));
11451 vec_append_aligned (match, l3, sizeof (u32x4));
11456 vec_append_aligned (match, l4, sizeof (u32x4));
11461 /* Make sure the vector is big enough even if key is all 0's */
11462 vec_validate_aligned
11463 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11466 /* Set size, include skipped vectors */
11467 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11478 api_classify_add_del_session (vat_main_t * vam)
11480 unformat_input_t *i = vam->input;
11481 vl_api_classify_add_del_session_t *mp;
11483 u32 table_index = ~0;
11484 u32 hit_next_index = ~0;
11485 u32 opaque_index = ~0;
11488 u32 skip_n_vectors = 0;
11489 u32 match_n_vectors = 0;
11495 * Warning: you have to supply skip_n and match_n
11496 * because the API client cant simply look at the classify
11500 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11502 if (unformat (i, "del"))
11504 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
11507 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
11510 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
11513 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
11515 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
11517 else if (unformat (i, "opaque-index %d", &opaque_index))
11519 else if (unformat (i, "skip_n %d", &skip_n_vectors))
11521 else if (unformat (i, "match_n %d", &match_n_vectors))
11523 else if (unformat (i, "match %U", api_unformat_classify_match,
11524 &match, skip_n_vectors, match_n_vectors))
11526 else if (unformat (i, "advance %d", &advance))
11528 else if (unformat (i, "table-index %d", &table_index))
11530 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
11532 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
11534 else if (unformat (i, "action %d", &action))
11536 else if (unformat (i, "metadata %d", &metadata))
11542 if (table_index == ~0)
11544 errmsg ("Table index required");
11548 if (is_add && match == 0)
11550 errmsg ("Match value required");
11554 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
11556 mp->is_add = is_add;
11557 mp->table_index = ntohl (table_index);
11558 mp->hit_next_index = ntohl (hit_next_index);
11559 mp->opaque_index = ntohl (opaque_index);
11560 mp->advance = ntohl (advance);
11561 mp->action = action;
11562 mp->metadata = ntohl (metadata);
11563 mp->match_len = ntohl (vec_len (match));
11564 clib_memcpy (mp->match, match, vec_len (match));
11573 api_classify_set_interface_ip_table (vat_main_t * vam)
11575 unformat_input_t *i = vam->input;
11576 vl_api_classify_set_interface_ip_table_t *mp;
11578 int sw_if_index_set;
11579 u32 table_index = ~0;
11583 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11585 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11586 sw_if_index_set = 1;
11587 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11588 sw_if_index_set = 1;
11589 else if (unformat (i, "table %d", &table_index))
11593 clib_warning ("parse error '%U'", format_unformat_error, i);
11598 if (sw_if_index_set == 0)
11600 errmsg ("missing interface name or sw_if_index");
11605 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
11607 mp->sw_if_index = ntohl (sw_if_index);
11608 mp->table_index = ntohl (table_index);
11609 mp->is_ipv6 = is_ipv6;
11617 api_classify_set_interface_l2_tables (vat_main_t * vam)
11619 unformat_input_t *i = vam->input;
11620 vl_api_classify_set_interface_l2_tables_t *mp;
11622 int sw_if_index_set;
11623 u32 ip4_table_index = ~0;
11624 u32 ip6_table_index = ~0;
11625 u32 other_table_index = ~0;
11629 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11631 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11632 sw_if_index_set = 1;
11633 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11634 sw_if_index_set = 1;
11635 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11637 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11639 else if (unformat (i, "other-table %d", &other_table_index))
11641 else if (unformat (i, "is-input %d", &is_input))
11645 clib_warning ("parse error '%U'", format_unformat_error, i);
11650 if (sw_if_index_set == 0)
11652 errmsg ("missing interface name or sw_if_index");
11657 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
11659 mp->sw_if_index = ntohl (sw_if_index);
11660 mp->ip4_table_index = ntohl (ip4_table_index);
11661 mp->ip6_table_index = ntohl (ip6_table_index);
11662 mp->other_table_index = ntohl (other_table_index);
11663 mp->is_input = (u8) is_input;
11671 api_set_ipfix_exporter (vat_main_t * vam)
11673 unformat_input_t *i = vam->input;
11674 vl_api_set_ipfix_exporter_t *mp;
11675 ip4_address_t collector_address;
11676 u8 collector_address_set = 0;
11677 u32 collector_port = ~0;
11678 ip4_address_t src_address;
11679 u8 src_address_set = 0;
11682 u32 template_interval = ~0;
11683 u8 udp_checksum = 0;
11686 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11688 if (unformat (i, "collector_address %U", unformat_ip4_address,
11689 &collector_address))
11690 collector_address_set = 1;
11691 else if (unformat (i, "collector_port %d", &collector_port))
11693 else if (unformat (i, "src_address %U", unformat_ip4_address,
11695 src_address_set = 1;
11696 else if (unformat (i, "vrf_id %d", &vrf_id))
11698 else if (unformat (i, "path_mtu %d", &path_mtu))
11700 else if (unformat (i, "template_interval %d", &template_interval))
11702 else if (unformat (i, "udp_checksum"))
11708 if (collector_address_set == 0)
11710 errmsg ("collector_address required");
11714 if (src_address_set == 0)
11716 errmsg ("src_address required");
11720 M (SET_IPFIX_EXPORTER, mp);
11722 memcpy (mp->collector_address, collector_address.data,
11723 sizeof (collector_address.data));
11724 mp->collector_port = htons ((u16) collector_port);
11725 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
11726 mp->vrf_id = htonl (vrf_id);
11727 mp->path_mtu = htonl (path_mtu);
11728 mp->template_interval = htonl (template_interval);
11729 mp->udp_checksum = udp_checksum;
11737 api_set_ipfix_classify_stream (vat_main_t * vam)
11739 unformat_input_t *i = vam->input;
11740 vl_api_set_ipfix_classify_stream_t *mp;
11742 u32 src_port = UDP_DST_PORT_ipfix;
11745 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11747 if (unformat (i, "domain %d", &domain_id))
11749 else if (unformat (i, "src_port %d", &src_port))
11753 errmsg ("unknown input `%U'", format_unformat_error, i);
11758 M (SET_IPFIX_CLASSIFY_STREAM, mp);
11760 mp->domain_id = htonl (domain_id);
11761 mp->src_port = htons ((u16) src_port);
11769 api_ipfix_classify_table_add_del (vat_main_t * vam)
11771 unformat_input_t *i = vam->input;
11772 vl_api_ipfix_classify_table_add_del_t *mp;
11774 u32 classify_table_index = ~0;
11776 u8 transport_protocol = 255;
11779 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11781 if (unformat (i, "add"))
11783 else if (unformat (i, "del"))
11785 else if (unformat (i, "table %d", &classify_table_index))
11787 else if (unformat (i, "ip4"))
11789 else if (unformat (i, "ip6"))
11791 else if (unformat (i, "tcp"))
11792 transport_protocol = 6;
11793 else if (unformat (i, "udp"))
11794 transport_protocol = 17;
11797 errmsg ("unknown input `%U'", format_unformat_error, i);
11804 errmsg ("expecting: add|del");
11807 if (classify_table_index == ~0)
11809 errmsg ("classifier table not specified");
11812 if (ip_version == 0)
11814 errmsg ("IP version not specified");
11818 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
11820 mp->is_add = is_add;
11821 mp->table_id = htonl (classify_table_index);
11822 mp->ip_version = ip_version;
11823 mp->transport_protocol = transport_protocol;
11831 api_get_node_index (vat_main_t * vam)
11833 unformat_input_t *i = vam->input;
11834 vl_api_get_node_index_t *mp;
11838 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11840 if (unformat (i, "node %s", &name))
11847 errmsg ("node name required");
11850 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11852 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11856 M (GET_NODE_INDEX, mp);
11857 clib_memcpy (mp->node_name, name, vec_len (name));
11866 api_get_next_index (vat_main_t * vam)
11868 unformat_input_t *i = vam->input;
11869 vl_api_get_next_index_t *mp;
11870 u8 *node_name = 0, *next_node_name = 0;
11873 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11875 if (unformat (i, "node-name %s", &node_name))
11877 else if (unformat (i, "next-node-name %s", &next_node_name))
11881 if (node_name == 0)
11883 errmsg ("node name required");
11886 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
11888 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11892 if (next_node_name == 0)
11894 errmsg ("next node name required");
11897 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
11899 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
11903 M (GET_NEXT_INDEX, mp);
11904 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
11905 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
11906 vec_free (node_name);
11907 vec_free (next_node_name);
11915 api_add_node_next (vat_main_t * vam)
11917 unformat_input_t *i = vam->input;
11918 vl_api_add_node_next_t *mp;
11923 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11925 if (unformat (i, "node %s", &name))
11927 else if (unformat (i, "next %s", &next))
11934 errmsg ("node name required");
11937 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11939 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11944 errmsg ("next node required");
11947 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
11949 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
11953 M (ADD_NODE_NEXT, mp);
11954 clib_memcpy (mp->node_name, name, vec_len (name));
11955 clib_memcpy (mp->next_name, next, vec_len (next));
11965 api_l2tpv3_create_tunnel (vat_main_t * vam)
11967 unformat_input_t *i = vam->input;
11968 ip6_address_t client_address, our_address;
11969 int client_address_set = 0;
11970 int our_address_set = 0;
11971 u32 local_session_id = 0;
11972 u32 remote_session_id = 0;
11973 u64 local_cookie = 0;
11974 u64 remote_cookie = 0;
11975 u8 l2_sublayer_present = 0;
11976 vl_api_l2tpv3_create_tunnel_t *mp;
11979 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11981 if (unformat (i, "client_address %U", unformat_ip6_address,
11983 client_address_set = 1;
11984 else if (unformat (i, "our_address %U", unformat_ip6_address,
11986 our_address_set = 1;
11987 else if (unformat (i, "local_session_id %d", &local_session_id))
11989 else if (unformat (i, "remote_session_id %d", &remote_session_id))
11991 else if (unformat (i, "local_cookie %lld", &local_cookie))
11993 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
11995 else if (unformat (i, "l2-sublayer-present"))
11996 l2_sublayer_present = 1;
12001 if (client_address_set == 0)
12003 errmsg ("client_address required");
12007 if (our_address_set == 0)
12009 errmsg ("our_address required");
12013 M (L2TPV3_CREATE_TUNNEL, mp);
12015 clib_memcpy (mp->client_address, client_address.as_u8,
12016 sizeof (mp->client_address));
12018 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
12020 mp->local_session_id = ntohl (local_session_id);
12021 mp->remote_session_id = ntohl (remote_session_id);
12022 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
12023 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
12024 mp->l2_sublayer_present = l2_sublayer_present;
12033 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
12035 unformat_input_t *i = vam->input;
12037 u8 sw_if_index_set = 0;
12038 u64 new_local_cookie = 0;
12039 u64 new_remote_cookie = 0;
12040 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
12043 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12045 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12046 sw_if_index_set = 1;
12047 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12048 sw_if_index_set = 1;
12049 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
12051 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
12057 if (sw_if_index_set == 0)
12059 errmsg ("missing interface name or sw_if_index");
12063 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
12065 mp->sw_if_index = ntohl (sw_if_index);
12066 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
12067 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
12075 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
12077 unformat_input_t *i = vam->input;
12078 vl_api_l2tpv3_interface_enable_disable_t *mp;
12080 u8 sw_if_index_set = 0;
12081 u8 enable_disable = 1;
12084 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12086 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12087 sw_if_index_set = 1;
12088 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12089 sw_if_index_set = 1;
12090 else if (unformat (i, "enable"))
12091 enable_disable = 1;
12092 else if (unformat (i, "disable"))
12093 enable_disable = 0;
12098 if (sw_if_index_set == 0)
12100 errmsg ("missing interface name or sw_if_index");
12104 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
12106 mp->sw_if_index = ntohl (sw_if_index);
12107 mp->enable_disable = enable_disable;
12115 api_l2tpv3_set_lookup_key (vat_main_t * vam)
12117 unformat_input_t *i = vam->input;
12118 vl_api_l2tpv3_set_lookup_key_t *mp;
12122 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12124 if (unformat (i, "lookup_v6_src"))
12125 key = L2T_LOOKUP_SRC_ADDRESS;
12126 else if (unformat (i, "lookup_v6_dst"))
12127 key = L2T_LOOKUP_DST_ADDRESS;
12128 else if (unformat (i, "lookup_session_id"))
12129 key = L2T_LOOKUP_SESSION_ID;
12134 if (key == (u8) ~ 0)
12136 errmsg ("l2tp session lookup key unset");
12140 M (L2TPV3_SET_LOOKUP_KEY, mp);
12149 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
12150 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12152 vat_main_t *vam = &vat_main;
12154 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
12155 format_ip6_address, mp->our_address,
12156 format_ip6_address, mp->client_address,
12157 clib_net_to_host_u32 (mp->sw_if_index));
12160 " local cookies %016llx %016llx remote cookie %016llx",
12161 clib_net_to_host_u64 (mp->local_cookie[0]),
12162 clib_net_to_host_u64 (mp->local_cookie[1]),
12163 clib_net_to_host_u64 (mp->remote_cookie));
12165 print (vam->ofp, " local session-id %d remote session-id %d",
12166 clib_net_to_host_u32 (mp->local_session_id),
12167 clib_net_to_host_u32 (mp->remote_session_id));
12169 print (vam->ofp, " l2 specific sublayer %s\n",
12170 mp->l2_sublayer_present ? "preset" : "absent");
12174 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
12175 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12177 vat_main_t *vam = &vat_main;
12178 vat_json_node_t *node = NULL;
12179 struct in6_addr addr;
12181 if (VAT_JSON_ARRAY != vam->json_tree.type)
12183 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12184 vat_json_init_array (&vam->json_tree);
12186 node = vat_json_array_add (&vam->json_tree);
12188 vat_json_init_object (node);
12190 clib_memcpy (&addr, mp->our_address, sizeof (addr));
12191 vat_json_object_add_ip6 (node, "our_address", addr);
12192 clib_memcpy (&addr, mp->client_address, sizeof (addr));
12193 vat_json_object_add_ip6 (node, "client_address", addr);
12195 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
12196 vat_json_init_array (lc);
12197 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
12198 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
12199 vat_json_object_add_uint (node, "remote_cookie",
12200 clib_net_to_host_u64 (mp->remote_cookie));
12202 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
12203 vat_json_object_add_uint (node, "local_session_id",
12204 clib_net_to_host_u32 (mp->local_session_id));
12205 vat_json_object_add_uint (node, "remote_session_id",
12206 clib_net_to_host_u32 (mp->remote_session_id));
12207 vat_json_object_add_string_copy (node, "l2_sublayer",
12208 mp->l2_sublayer_present ? (u8 *) "present"
12209 : (u8 *) "absent");
12213 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
12215 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
12216 vl_api_control_ping_t *mp_ping;
12219 /* Get list of l2tpv3-tunnel interfaces */
12220 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
12223 /* Use a control ping for synchronization */
12224 MPING (CONTROL_PING, mp_ping);
12232 static void vl_api_sw_interface_tap_v2_details_t_handler
12233 (vl_api_sw_interface_tap_v2_details_t * mp)
12235 vat_main_t *vam = &vat_main;
12237 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
12238 mp->host_ip4_prefix_len);
12239 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
12240 mp->host_ip6_prefix_len);
12243 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s 0x%-08x",
12244 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
12245 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12246 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
12247 mp->host_bridge, ip4, ip6, ntohl (mp->tap_flags));
12253 static void vl_api_sw_interface_tap_v2_details_t_handler_json
12254 (vl_api_sw_interface_tap_v2_details_t * mp)
12256 vat_main_t *vam = &vat_main;
12257 vat_json_node_t *node = NULL;
12259 if (VAT_JSON_ARRAY != vam->json_tree.type)
12261 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12262 vat_json_init_array (&vam->json_tree);
12264 node = vat_json_array_add (&vam->json_tree);
12266 vat_json_init_object (node);
12267 vat_json_object_add_uint (node, "id", ntohl (mp->id));
12268 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12269 vat_json_object_add_uint (node, "tap_flags", ntohl (mp->tap_flags));
12270 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12271 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12272 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12273 vat_json_object_add_string_copy (node, "host_mac_addr",
12274 format (0, "%U", format_ethernet_address,
12275 &mp->host_mac_addr));
12276 vat_json_object_add_string_copy (node, "host_namespace",
12277 mp->host_namespace);
12278 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
12279 vat_json_object_add_string_copy (node, "host_ip4_addr",
12280 format (0, "%U/%d", format_ip4_address,
12282 mp->host_ip4_prefix_len));
12283 vat_json_object_add_string_copy (node, "host_ip6_addr",
12284 format (0, "%U/%d", format_ip6_address,
12286 mp->host_ip6_prefix_len));
12291 api_sw_interface_tap_v2_dump (vat_main_t * vam)
12293 vl_api_sw_interface_tap_v2_dump_t *mp;
12294 vl_api_control_ping_t *mp_ping;
12298 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
12299 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
12300 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
12303 /* Get list of tap interfaces */
12304 M (SW_INTERFACE_TAP_V2_DUMP, mp);
12307 /* Use a control ping for synchronization */
12308 MPING (CONTROL_PING, mp_ping);
12315 static void vl_api_sw_interface_virtio_pci_details_t_handler
12316 (vl_api_sw_interface_virtio_pci_details_t * mp)
12318 vat_main_t *vam = &vat_main;
12332 addr.as_u32 = ntohl (mp->pci_addr);
12333 u8 *pci_addr = format (0, "%04x:%02x:%02x.%x", addr.domain, addr.bus,
12334 addr.slot, addr.function);
12337 "\n%-12s %-12d %-12d %-12d %-17U 0x%-08llx",
12338 pci_addr, ntohl (mp->sw_if_index),
12339 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12340 format_ethernet_address, mp->mac_addr,
12341 clib_net_to_host_u64 (mp->features));
12342 vec_free (pci_addr);
12345 static void vl_api_sw_interface_virtio_pci_details_t_handler_json
12346 (vl_api_sw_interface_virtio_pci_details_t * mp)
12348 vat_main_t *vam = &vat_main;
12349 vat_json_node_t *node = NULL;
12351 if (VAT_JSON_ARRAY != vam->json_tree.type)
12353 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12354 vat_json_init_array (&vam->json_tree);
12356 node = vat_json_array_add (&vam->json_tree);
12358 vat_json_init_object (node);
12359 vat_json_object_add_uint (node, "pci-addr", ntohl (mp->pci_addr));
12360 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12361 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12362 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12363 vat_json_object_add_uint (node, "features",
12364 clib_net_to_host_u64 (mp->features));
12365 vat_json_object_add_string_copy (node, "mac_addr",
12366 format (0, "%U", format_ethernet_address,
12371 api_sw_interface_virtio_pci_dump (vat_main_t * vam)
12373 vl_api_sw_interface_virtio_pci_dump_t *mp;
12374 vl_api_control_ping_t *mp_ping;
12378 "\n%-12s %-12s %-12s %-12s %-17s %-08s",
12379 "pci_addr", "sw_if_index", "rx_ring_sz", "tx_ring_sz",
12380 "mac_addr", "features");
12382 /* Get list of tap interfaces */
12383 M (SW_INTERFACE_VIRTIO_PCI_DUMP, mp);
12386 /* Use a control ping for synchronization */
12387 MPING (CONTROL_PING, mp_ping);
12395 api_vxlan_offload_rx (vat_main_t * vam)
12397 unformat_input_t *line_input = vam->input;
12398 vl_api_vxlan_offload_rx_t *mp;
12399 u32 hw_if_index = ~0, rx_if_index = ~0;
12403 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12405 if (unformat (line_input, "del"))
12407 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
12410 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
12412 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
12415 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
12419 errmsg ("parse error '%U'", format_unformat_error, line_input);
12424 if (hw_if_index == ~0)
12426 errmsg ("no hw interface");
12430 if (rx_if_index == ~0)
12432 errmsg ("no rx tunnel");
12436 M (VXLAN_OFFLOAD_RX, mp);
12438 mp->hw_if_index = ntohl (hw_if_index);
12439 mp->sw_if_index = ntohl (rx_if_index);
12440 mp->enable = is_add;
12447 static uword unformat_vxlan_decap_next
12448 (unformat_input_t * input, va_list * args)
12450 u32 *result = va_arg (*args, u32 *);
12453 if (unformat (input, "l2"))
12454 *result = VXLAN_INPUT_NEXT_L2_INPUT;
12455 else if (unformat (input, "%d", &tmp))
12463 api_vxlan_add_del_tunnel (vat_main_t * vam)
12465 unformat_input_t *line_input = vam->input;
12466 vl_api_vxlan_add_del_tunnel_t *mp;
12467 ip46_address_t src, dst;
12469 u8 ipv4_set = 0, ipv6_set = 0;
12474 u32 mcast_sw_if_index = ~0;
12475 u32 encap_vrf_id = 0;
12476 u32 decap_next_index = ~0;
12480 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12481 clib_memset (&src, 0, sizeof src);
12482 clib_memset (&dst, 0, sizeof dst);
12484 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12486 if (unformat (line_input, "del"))
12488 else if (unformat (line_input, "instance %d", &instance))
12491 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12497 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12503 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12509 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12514 else if (unformat (line_input, "group %U %U",
12515 unformat_ip4_address, &dst.ip4,
12516 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12518 grp_set = dst_set = 1;
12521 else if (unformat (line_input, "group %U",
12522 unformat_ip4_address, &dst.ip4))
12524 grp_set = dst_set = 1;
12527 else if (unformat (line_input, "group %U %U",
12528 unformat_ip6_address, &dst.ip6,
12529 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12531 grp_set = dst_set = 1;
12534 else if (unformat (line_input, "group %U",
12535 unformat_ip6_address, &dst.ip6))
12537 grp_set = dst_set = 1;
12541 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12543 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12545 else if (unformat (line_input, "decap-next %U",
12546 unformat_vxlan_decap_next, &decap_next_index))
12548 else if (unformat (line_input, "vni %d", &vni))
12552 errmsg ("parse error '%U'", format_unformat_error, line_input);
12559 errmsg ("tunnel src address not specified");
12564 errmsg ("tunnel dst address not specified");
12568 if (grp_set && !ip46_address_is_multicast (&dst))
12570 errmsg ("tunnel group address not multicast");
12573 if (grp_set && mcast_sw_if_index == ~0)
12575 errmsg ("tunnel nonexistent multicast device");
12578 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12580 errmsg ("tunnel dst address must be unicast");
12585 if (ipv4_set && ipv6_set)
12587 errmsg ("both IPv4 and IPv6 addresses specified");
12591 if ((vni == 0) || (vni >> 24))
12593 errmsg ("vni not specified or out of range");
12597 M (VXLAN_ADD_DEL_TUNNEL, mp);
12601 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
12602 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
12606 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
12607 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
12610 mp->instance = htonl (instance);
12611 mp->encap_vrf_id = ntohl (encap_vrf_id);
12612 mp->decap_next_index = ntohl (decap_next_index);
12613 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12614 mp->vni = ntohl (vni);
12615 mp->is_add = is_add;
12616 mp->is_ipv6 = ipv6_set;
12623 static void vl_api_vxlan_tunnel_details_t_handler
12624 (vl_api_vxlan_tunnel_details_t * mp)
12626 vat_main_t *vam = &vat_main;
12627 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12628 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12630 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
12631 ntohl (mp->sw_if_index),
12632 ntohl (mp->instance),
12633 format_ip46_address, &src, IP46_TYPE_ANY,
12634 format_ip46_address, &dst, IP46_TYPE_ANY,
12635 ntohl (mp->encap_vrf_id),
12636 ntohl (mp->decap_next_index), ntohl (mp->vni),
12637 ntohl (mp->mcast_sw_if_index));
12640 static void vl_api_vxlan_tunnel_details_t_handler_json
12641 (vl_api_vxlan_tunnel_details_t * mp)
12643 vat_main_t *vam = &vat_main;
12644 vat_json_node_t *node = NULL;
12646 if (VAT_JSON_ARRAY != vam->json_tree.type)
12648 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12649 vat_json_init_array (&vam->json_tree);
12651 node = vat_json_array_add (&vam->json_tree);
12653 vat_json_init_object (node);
12654 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12656 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
12660 struct in6_addr ip6;
12662 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12663 vat_json_object_add_ip6 (node, "src_address", ip6);
12664 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12665 vat_json_object_add_ip6 (node, "dst_address", ip6);
12669 struct in_addr ip4;
12671 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12672 vat_json_object_add_ip4 (node, "src_address", ip4);
12673 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12674 vat_json_object_add_ip4 (node, "dst_address", ip4);
12676 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12677 vat_json_object_add_uint (node, "decap_next_index",
12678 ntohl (mp->decap_next_index));
12679 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12680 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12681 vat_json_object_add_uint (node, "mcast_sw_if_index",
12682 ntohl (mp->mcast_sw_if_index));
12686 api_vxlan_tunnel_dump (vat_main_t * vam)
12688 unformat_input_t *i = vam->input;
12689 vl_api_vxlan_tunnel_dump_t *mp;
12690 vl_api_control_ping_t *mp_ping;
12692 u8 sw_if_index_set = 0;
12695 /* Parse args required to build the message */
12696 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12698 if (unformat (i, "sw_if_index %d", &sw_if_index))
12699 sw_if_index_set = 1;
12704 if (sw_if_index_set == 0)
12709 if (!vam->json_output)
12711 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
12712 "sw_if_index", "instance", "src_address", "dst_address",
12713 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12716 /* Get list of vxlan-tunnel interfaces */
12717 M (VXLAN_TUNNEL_DUMP, mp);
12719 mp->sw_if_index = htonl (sw_if_index);
12723 /* Use a control ping for synchronization */
12724 MPING (CONTROL_PING, mp_ping);
12731 static uword unformat_geneve_decap_next
12732 (unformat_input_t * input, va_list * args)
12734 u32 *result = va_arg (*args, u32 *);
12737 if (unformat (input, "l2"))
12738 *result = GENEVE_INPUT_NEXT_L2_INPUT;
12739 else if (unformat (input, "%d", &tmp))
12747 api_geneve_add_del_tunnel (vat_main_t * vam)
12749 unformat_input_t *line_input = vam->input;
12750 vl_api_geneve_add_del_tunnel_t *mp;
12751 ip46_address_t src, dst;
12753 u8 ipv4_set = 0, ipv6_set = 0;
12757 u32 mcast_sw_if_index = ~0;
12758 u32 encap_vrf_id = 0;
12759 u32 decap_next_index = ~0;
12763 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12764 clib_memset (&src, 0, sizeof src);
12765 clib_memset (&dst, 0, sizeof dst);
12767 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12769 if (unformat (line_input, "del"))
12772 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12778 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12784 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12790 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12795 else if (unformat (line_input, "group %U %U",
12796 unformat_ip4_address, &dst.ip4,
12797 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12799 grp_set = dst_set = 1;
12802 else if (unformat (line_input, "group %U",
12803 unformat_ip4_address, &dst.ip4))
12805 grp_set = dst_set = 1;
12808 else if (unformat (line_input, "group %U %U",
12809 unformat_ip6_address, &dst.ip6,
12810 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12812 grp_set = dst_set = 1;
12815 else if (unformat (line_input, "group %U",
12816 unformat_ip6_address, &dst.ip6))
12818 grp_set = dst_set = 1;
12822 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12824 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12826 else if (unformat (line_input, "decap-next %U",
12827 unformat_geneve_decap_next, &decap_next_index))
12829 else if (unformat (line_input, "vni %d", &vni))
12833 errmsg ("parse error '%U'", format_unformat_error, line_input);
12840 errmsg ("tunnel src address not specified");
12845 errmsg ("tunnel dst address not specified");
12849 if (grp_set && !ip46_address_is_multicast (&dst))
12851 errmsg ("tunnel group address not multicast");
12854 if (grp_set && mcast_sw_if_index == ~0)
12856 errmsg ("tunnel nonexistent multicast device");
12859 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12861 errmsg ("tunnel dst address must be unicast");
12866 if (ipv4_set && ipv6_set)
12868 errmsg ("both IPv4 and IPv6 addresses specified");
12872 if ((vni == 0) || (vni >> 24))
12874 errmsg ("vni not specified or out of range");
12878 M (GENEVE_ADD_DEL_TUNNEL, mp);
12882 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
12883 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
12887 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
12888 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
12890 mp->encap_vrf_id = ntohl (encap_vrf_id);
12891 mp->decap_next_index = ntohl (decap_next_index);
12892 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12893 mp->vni = ntohl (vni);
12894 mp->is_add = is_add;
12895 mp->is_ipv6 = ipv6_set;
12902 static void vl_api_geneve_tunnel_details_t_handler
12903 (vl_api_geneve_tunnel_details_t * mp)
12905 vat_main_t *vam = &vat_main;
12906 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12907 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12909 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12910 ntohl (mp->sw_if_index),
12911 format_ip46_address, &src, IP46_TYPE_ANY,
12912 format_ip46_address, &dst, IP46_TYPE_ANY,
12913 ntohl (mp->encap_vrf_id),
12914 ntohl (mp->decap_next_index), ntohl (mp->vni),
12915 ntohl (mp->mcast_sw_if_index));
12918 static void vl_api_geneve_tunnel_details_t_handler_json
12919 (vl_api_geneve_tunnel_details_t * mp)
12921 vat_main_t *vam = &vat_main;
12922 vat_json_node_t *node = NULL;
12924 if (VAT_JSON_ARRAY != vam->json_tree.type)
12926 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12927 vat_json_init_array (&vam->json_tree);
12929 node = vat_json_array_add (&vam->json_tree);
12931 vat_json_init_object (node);
12932 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12935 struct in6_addr ip6;
12937 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12938 vat_json_object_add_ip6 (node, "src_address", ip6);
12939 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12940 vat_json_object_add_ip6 (node, "dst_address", ip6);
12944 struct in_addr ip4;
12946 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12947 vat_json_object_add_ip4 (node, "src_address", ip4);
12948 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12949 vat_json_object_add_ip4 (node, "dst_address", ip4);
12951 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12952 vat_json_object_add_uint (node, "decap_next_index",
12953 ntohl (mp->decap_next_index));
12954 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12955 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12956 vat_json_object_add_uint (node, "mcast_sw_if_index",
12957 ntohl (mp->mcast_sw_if_index));
12961 api_geneve_tunnel_dump (vat_main_t * vam)
12963 unformat_input_t *i = vam->input;
12964 vl_api_geneve_tunnel_dump_t *mp;
12965 vl_api_control_ping_t *mp_ping;
12967 u8 sw_if_index_set = 0;
12970 /* Parse args required to build the message */
12971 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12973 if (unformat (i, "sw_if_index %d", &sw_if_index))
12974 sw_if_index_set = 1;
12979 if (sw_if_index_set == 0)
12984 if (!vam->json_output)
12986 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12987 "sw_if_index", "local_address", "remote_address",
12988 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12991 /* Get list of geneve-tunnel interfaces */
12992 M (GENEVE_TUNNEL_DUMP, mp);
12994 mp->sw_if_index = htonl (sw_if_index);
12998 /* Use a control ping for synchronization */
12999 M (CONTROL_PING, mp_ping);
13007 api_gre_tunnel_add_del (vat_main_t * vam)
13009 unformat_input_t *line_input = vam->input;
13010 vl_api_address_t src = { }, dst =
13013 vl_api_gre_tunnel_add_del_t *mp;
13014 vl_api_gre_tunnel_type_t t_type;
13018 u32 outer_fib_id = 0;
13019 u32 session_id = 0;
13023 t_type = GRE_API_TUNNEL_TYPE_L3;
13025 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13027 if (unformat (line_input, "del"))
13029 else if (unformat (line_input, "instance %d", &instance))
13031 else if (unformat (line_input, "src %U", unformat_vl_api_address, &src))
13035 else if (unformat (line_input, "dst %U", unformat_vl_api_address, &dst))
13039 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
13041 else if (unformat (line_input, "teb"))
13042 t_type = GRE_API_TUNNEL_TYPE_TEB;
13043 else if (unformat (line_input, "erspan %d", &session_id))
13044 t_type = GRE_API_TUNNEL_TYPE_ERSPAN;
13047 errmsg ("parse error '%U'", format_unformat_error, line_input);
13054 errmsg ("tunnel src address not specified");
13059 errmsg ("tunnel dst address not specified");
13063 M (GRE_TUNNEL_ADD_DEL, mp);
13065 clib_memcpy (&mp->tunnel.src, &src, sizeof (mp->tunnel.src));
13066 clib_memcpy (&mp->tunnel.dst, &dst, sizeof (mp->tunnel.dst));
13068 mp->tunnel.instance = htonl (instance);
13069 mp->tunnel.outer_fib_id = htonl (outer_fib_id);
13070 mp->is_add = is_add;
13071 mp->tunnel.session_id = htons ((u16) session_id);
13072 mp->tunnel.type = htonl (t_type);
13079 static void vl_api_gre_tunnel_details_t_handler
13080 (vl_api_gre_tunnel_details_t * mp)
13082 vat_main_t *vam = &vat_main;
13084 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
13085 ntohl (mp->tunnel.sw_if_index),
13086 ntohl (mp->tunnel.instance),
13087 format_vl_api_address, &mp->tunnel.src,
13088 format_vl_api_address, &mp->tunnel.dst,
13089 mp->tunnel.type, ntohl (mp->tunnel.outer_fib_id),
13090 ntohl (mp->tunnel.session_id));
13093 static void vl_api_gre_tunnel_details_t_handler_json
13094 (vl_api_gre_tunnel_details_t * mp)
13096 vat_main_t *vam = &vat_main;
13097 vat_json_node_t *node = NULL;
13099 if (VAT_JSON_ARRAY != vam->json_tree.type)
13101 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13102 vat_json_init_array (&vam->json_tree);
13104 node = vat_json_array_add (&vam->json_tree);
13106 vat_json_init_object (node);
13107 vat_json_object_add_uint (node, "sw_if_index",
13108 ntohl (mp->tunnel.sw_if_index));
13109 vat_json_object_add_uint (node, "instance", ntohl (mp->tunnel.instance));
13111 vat_json_object_add_address (node, "src", &mp->tunnel.src);
13112 vat_json_object_add_address (node, "dst", &mp->tunnel.dst);
13113 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel.type);
13114 vat_json_object_add_uint (node, "outer_fib_id",
13115 ntohl (mp->tunnel.outer_fib_id));
13116 vat_json_object_add_uint (node, "session_id", mp->tunnel.session_id);
13120 api_gre_tunnel_dump (vat_main_t * vam)
13122 unformat_input_t *i = vam->input;
13123 vl_api_gre_tunnel_dump_t *mp;
13124 vl_api_control_ping_t *mp_ping;
13126 u8 sw_if_index_set = 0;
13129 /* Parse args required to build the message */
13130 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13132 if (unformat (i, "sw_if_index %d", &sw_if_index))
13133 sw_if_index_set = 1;
13138 if (sw_if_index_set == 0)
13143 if (!vam->json_output)
13145 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
13146 "sw_if_index", "instance", "src_address", "dst_address",
13147 "tunnel_type", "outer_fib_id", "session_id");
13150 /* Get list of gre-tunnel interfaces */
13151 M (GRE_TUNNEL_DUMP, mp);
13153 mp->sw_if_index = htonl (sw_if_index);
13157 /* Use a control ping for synchronization */
13158 MPING (CONTROL_PING, mp_ping);
13166 api_l2_fib_clear_table (vat_main_t * vam)
13168 // unformat_input_t * i = vam->input;
13169 vl_api_l2_fib_clear_table_t *mp;
13172 M (L2_FIB_CLEAR_TABLE, mp);
13180 api_l2_interface_efp_filter (vat_main_t * vam)
13182 unformat_input_t *i = vam->input;
13183 vl_api_l2_interface_efp_filter_t *mp;
13186 u8 sw_if_index_set = 0;
13189 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13191 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13192 sw_if_index_set = 1;
13193 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13194 sw_if_index_set = 1;
13195 else if (unformat (i, "enable"))
13197 else if (unformat (i, "disable"))
13201 clib_warning ("parse error '%U'", format_unformat_error, i);
13206 if (sw_if_index_set == 0)
13208 errmsg ("missing sw_if_index");
13212 M (L2_INTERFACE_EFP_FILTER, mp);
13214 mp->sw_if_index = ntohl (sw_if_index);
13215 mp->enable_disable = enable;
13222 #define foreach_vtr_op \
13223 _("disable", L2_VTR_DISABLED) \
13224 _("push-1", L2_VTR_PUSH_1) \
13225 _("push-2", L2_VTR_PUSH_2) \
13226 _("pop-1", L2_VTR_POP_1) \
13227 _("pop-2", L2_VTR_POP_2) \
13228 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
13229 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
13230 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
13231 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
13234 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
13236 unformat_input_t *i = vam->input;
13237 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
13239 u8 sw_if_index_set = 0;
13242 u32 push_dot1q = 1;
13247 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13249 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13250 sw_if_index_set = 1;
13251 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13252 sw_if_index_set = 1;
13253 else if (unformat (i, "vtr_op %d", &vtr_op))
13255 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
13258 else if (unformat (i, "push_dot1q %d", &push_dot1q))
13260 else if (unformat (i, "tag1 %d", &tag1))
13262 else if (unformat (i, "tag2 %d", &tag2))
13266 clib_warning ("parse error '%U'", format_unformat_error, i);
13271 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
13273 errmsg ("missing vtr operation or sw_if_index");
13277 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
13278 mp->sw_if_index = ntohl (sw_if_index);
13279 mp->vtr_op = ntohl (vtr_op);
13280 mp->push_dot1q = ntohl (push_dot1q);
13281 mp->tag1 = ntohl (tag1);
13282 mp->tag2 = ntohl (tag2);
13290 api_create_vhost_user_if (vat_main_t * vam)
13292 unformat_input_t *i = vam->input;
13293 vl_api_create_vhost_user_if_t *mp;
13296 u8 file_name_set = 0;
13297 u32 custom_dev_instance = ~0;
13299 u8 use_custom_mac = 0;
13300 u8 disable_mrg_rxbuf = 0;
13301 u8 disable_indirect_desc = 0;
13306 /* Shut up coverity */
13307 clib_memset (hwaddr, 0, sizeof (hwaddr));
13309 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13311 if (unformat (i, "socket %s", &file_name))
13315 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13317 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
13318 use_custom_mac = 1;
13319 else if (unformat (i, "server"))
13321 else if (unformat (i, "disable_mrg_rxbuf"))
13322 disable_mrg_rxbuf = 1;
13323 else if (unformat (i, "disable_indirect_desc"))
13324 disable_indirect_desc = 1;
13325 else if (unformat (i, "gso"))
13327 else if (unformat (i, "tag %s", &tag))
13333 if (file_name_set == 0)
13335 errmsg ("missing socket file name");
13339 if (vec_len (file_name) > 255)
13341 errmsg ("socket file name too long");
13344 vec_add1 (file_name, 0);
13346 M (CREATE_VHOST_USER_IF, mp);
13348 mp->is_server = is_server;
13349 mp->disable_mrg_rxbuf = disable_mrg_rxbuf;
13350 mp->disable_indirect_desc = disable_indirect_desc;
13351 mp->enable_gso = enable_gso;
13352 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13353 vec_free (file_name);
13354 if (custom_dev_instance != ~0)
13357 mp->custom_dev_instance = ntohl (custom_dev_instance);
13360 mp->use_custom_mac = use_custom_mac;
13361 clib_memcpy (mp->mac_address, hwaddr, 6);
13363 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
13372 api_modify_vhost_user_if (vat_main_t * vam)
13374 unformat_input_t *i = vam->input;
13375 vl_api_modify_vhost_user_if_t *mp;
13378 u8 file_name_set = 0;
13379 u32 custom_dev_instance = ~0;
13380 u8 sw_if_index_set = 0;
13381 u32 sw_if_index = (u32) ~ 0;
13385 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13387 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13388 sw_if_index_set = 1;
13389 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13390 sw_if_index_set = 1;
13391 else if (unformat (i, "socket %s", &file_name))
13395 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13397 else if (unformat (i, "server"))
13399 else if (unformat (i, "gso"))
13405 if (sw_if_index_set == 0)
13407 errmsg ("missing sw_if_index or interface name");
13411 if (file_name_set == 0)
13413 errmsg ("missing socket file name");
13417 if (vec_len (file_name) > 255)
13419 errmsg ("socket file name too long");
13422 vec_add1 (file_name, 0);
13424 M (MODIFY_VHOST_USER_IF, mp);
13426 mp->sw_if_index = ntohl (sw_if_index);
13427 mp->is_server = is_server;
13428 mp->enable_gso = enable_gso;
13429 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13430 vec_free (file_name);
13431 if (custom_dev_instance != ~0)
13434 mp->custom_dev_instance = ntohl (custom_dev_instance);
13443 api_delete_vhost_user_if (vat_main_t * vam)
13445 unformat_input_t *i = vam->input;
13446 vl_api_delete_vhost_user_if_t *mp;
13447 u32 sw_if_index = ~0;
13448 u8 sw_if_index_set = 0;
13451 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13453 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13454 sw_if_index_set = 1;
13455 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13456 sw_if_index_set = 1;
13461 if (sw_if_index_set == 0)
13463 errmsg ("missing sw_if_index or interface name");
13468 M (DELETE_VHOST_USER_IF, mp);
13470 mp->sw_if_index = ntohl (sw_if_index);
13477 static void vl_api_sw_interface_vhost_user_details_t_handler
13478 (vl_api_sw_interface_vhost_user_details_t * mp)
13480 vat_main_t *vam = &vat_main;
13482 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
13483 (char *) mp->interface_name,
13484 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
13485 clib_net_to_host_u64 (mp->features), mp->is_server,
13486 ntohl (mp->num_regions), (char *) mp->sock_filename);
13487 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
13490 static void vl_api_sw_interface_vhost_user_details_t_handler_json
13491 (vl_api_sw_interface_vhost_user_details_t * mp)
13493 vat_main_t *vam = &vat_main;
13494 vat_json_node_t *node = NULL;
13496 if (VAT_JSON_ARRAY != vam->json_tree.type)
13498 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13499 vat_json_init_array (&vam->json_tree);
13501 node = vat_json_array_add (&vam->json_tree);
13503 vat_json_init_object (node);
13504 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13505 vat_json_object_add_string_copy (node, "interface_name",
13506 mp->interface_name);
13507 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
13508 ntohl (mp->virtio_net_hdr_sz));
13509 vat_json_object_add_uint (node, "features",
13510 clib_net_to_host_u64 (mp->features));
13511 vat_json_object_add_uint (node, "is_server", mp->is_server);
13512 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
13513 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
13514 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
13518 api_sw_interface_vhost_user_dump (vat_main_t * vam)
13520 vl_api_sw_interface_vhost_user_dump_t *mp;
13521 vl_api_control_ping_t *mp_ping;
13524 "Interface name idx hdr_sz features server regions filename");
13526 /* Get list of vhost-user interfaces */
13527 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
13530 /* Use a control ping for synchronization */
13531 MPING (CONTROL_PING, mp_ping);
13539 api_show_version (vat_main_t * vam)
13541 vl_api_show_version_t *mp;
13544 M (SHOW_VERSION, mp);
13553 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
13555 unformat_input_t *line_input = vam->input;
13556 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
13557 ip4_address_t local4, remote4;
13558 ip6_address_t local6, remote6;
13560 u8 ipv4_set = 0, ipv6_set = 0;
13564 u32 mcast_sw_if_index = ~0;
13565 u32 encap_vrf_id = 0;
13566 u32 decap_vrf_id = 0;
13572 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13573 clib_memset (&local4, 0, sizeof local4);
13574 clib_memset (&remote4, 0, sizeof remote4);
13575 clib_memset (&local6, 0, sizeof local6);
13576 clib_memset (&remote6, 0, sizeof remote6);
13578 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13580 if (unformat (line_input, "del"))
13582 else if (unformat (line_input, "local %U",
13583 unformat_ip4_address, &local4))
13588 else if (unformat (line_input, "remote %U",
13589 unformat_ip4_address, &remote4))
13594 else if (unformat (line_input, "local %U",
13595 unformat_ip6_address, &local6))
13600 else if (unformat (line_input, "remote %U",
13601 unformat_ip6_address, &remote6))
13606 else if (unformat (line_input, "group %U %U",
13607 unformat_ip4_address, &remote4,
13608 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13610 grp_set = remote_set = 1;
13613 else if (unformat (line_input, "group %U",
13614 unformat_ip4_address, &remote4))
13616 grp_set = remote_set = 1;
13619 else if (unformat (line_input, "group %U %U",
13620 unformat_ip6_address, &remote6,
13621 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13623 grp_set = remote_set = 1;
13626 else if (unformat (line_input, "group %U",
13627 unformat_ip6_address, &remote6))
13629 grp_set = remote_set = 1;
13633 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13635 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13637 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
13639 else if (unformat (line_input, "vni %d", &vni))
13641 else if (unformat (line_input, "next-ip4"))
13643 else if (unformat (line_input, "next-ip6"))
13645 else if (unformat (line_input, "next-ethernet"))
13647 else if (unformat (line_input, "next-nsh"))
13651 errmsg ("parse error '%U'", format_unformat_error, line_input);
13656 if (local_set == 0)
13658 errmsg ("tunnel local address not specified");
13661 if (remote_set == 0)
13663 errmsg ("tunnel remote address not specified");
13666 if (grp_set && mcast_sw_if_index == ~0)
13668 errmsg ("tunnel nonexistent multicast device");
13671 if (ipv4_set && ipv6_set)
13673 errmsg ("both IPv4 and IPv6 addresses specified");
13679 errmsg ("vni not specified");
13683 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
13688 clib_memcpy (&mp->local, &local6, sizeof (local6));
13689 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
13693 clib_memcpy (&mp->local, &local4, sizeof (local4));
13694 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
13697 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13698 mp->encap_vrf_id = ntohl (encap_vrf_id);
13699 mp->decap_vrf_id = ntohl (decap_vrf_id);
13700 mp->protocol = protocol;
13701 mp->vni = ntohl (vni);
13702 mp->is_add = is_add;
13703 mp->is_ipv6 = ipv6_set;
13710 static void vl_api_vxlan_gpe_tunnel_details_t_handler
13711 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13713 vat_main_t *vam = &vat_main;
13714 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
13715 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
13717 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
13718 ntohl (mp->sw_if_index),
13719 format_ip46_address, &local, IP46_TYPE_ANY,
13720 format_ip46_address, &remote, IP46_TYPE_ANY,
13721 ntohl (mp->vni), mp->protocol,
13722 ntohl (mp->mcast_sw_if_index),
13723 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
13727 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
13728 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13730 vat_main_t *vam = &vat_main;
13731 vat_json_node_t *node = NULL;
13732 struct in_addr ip4;
13733 struct in6_addr ip6;
13735 if (VAT_JSON_ARRAY != vam->json_tree.type)
13737 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13738 vat_json_init_array (&vam->json_tree);
13740 node = vat_json_array_add (&vam->json_tree);
13742 vat_json_init_object (node);
13743 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13746 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
13747 vat_json_object_add_ip6 (node, "local", ip6);
13748 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
13749 vat_json_object_add_ip6 (node, "remote", ip6);
13753 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
13754 vat_json_object_add_ip4 (node, "local", ip4);
13755 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
13756 vat_json_object_add_ip4 (node, "remote", ip4);
13758 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13759 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
13760 vat_json_object_add_uint (node, "mcast_sw_if_index",
13761 ntohl (mp->mcast_sw_if_index));
13762 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13763 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
13764 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13768 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
13770 unformat_input_t *i = vam->input;
13771 vl_api_vxlan_gpe_tunnel_dump_t *mp;
13772 vl_api_control_ping_t *mp_ping;
13774 u8 sw_if_index_set = 0;
13777 /* Parse args required to build the message */
13778 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13780 if (unformat (i, "sw_if_index %d", &sw_if_index))
13781 sw_if_index_set = 1;
13786 if (sw_if_index_set == 0)
13791 if (!vam->json_output)
13793 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
13794 "sw_if_index", "local", "remote", "vni",
13795 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
13798 /* Get list of vxlan-tunnel interfaces */
13799 M (VXLAN_GPE_TUNNEL_DUMP, mp);
13801 mp->sw_if_index = htonl (sw_if_index);
13805 /* Use a control ping for synchronization */
13806 MPING (CONTROL_PING, mp_ping);
13813 static void vl_api_l2_fib_table_details_t_handler
13814 (vl_api_l2_fib_table_details_t * mp)
13816 vat_main_t *vam = &vat_main;
13818 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
13820 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
13821 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
13825 static void vl_api_l2_fib_table_details_t_handler_json
13826 (vl_api_l2_fib_table_details_t * mp)
13828 vat_main_t *vam = &vat_main;
13829 vat_json_node_t *node = NULL;
13831 if (VAT_JSON_ARRAY != vam->json_tree.type)
13833 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13834 vat_json_init_array (&vam->json_tree);
13836 node = vat_json_array_add (&vam->json_tree);
13838 vat_json_init_object (node);
13839 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
13840 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
13841 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13842 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
13843 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
13844 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
13848 api_l2_fib_table_dump (vat_main_t * vam)
13850 unformat_input_t *i = vam->input;
13851 vl_api_l2_fib_table_dump_t *mp;
13852 vl_api_control_ping_t *mp_ping;
13857 /* Parse args required to build the message */
13858 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13860 if (unformat (i, "bd_id %d", &bd_id))
13866 if (bd_id_set == 0)
13868 errmsg ("missing bridge domain");
13872 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
13874 /* Get list of l2 fib entries */
13875 M (L2_FIB_TABLE_DUMP, mp);
13877 mp->bd_id = ntohl (bd_id);
13880 /* Use a control ping for synchronization */
13881 MPING (CONTROL_PING, mp_ping);
13890 api_interface_name_renumber (vat_main_t * vam)
13892 unformat_input_t *line_input = vam->input;
13893 vl_api_interface_name_renumber_t *mp;
13894 u32 sw_if_index = ~0;
13895 u32 new_show_dev_instance = ~0;
13898 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13900 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
13903 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13905 else if (unformat (line_input, "new_show_dev_instance %d",
13906 &new_show_dev_instance))
13912 if (sw_if_index == ~0)
13914 errmsg ("missing interface name or sw_if_index");
13918 if (new_show_dev_instance == ~0)
13920 errmsg ("missing new_show_dev_instance");
13924 M (INTERFACE_NAME_RENUMBER, mp);
13926 mp->sw_if_index = ntohl (sw_if_index);
13927 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
13935 api_ip_probe_neighbor (vat_main_t * vam)
13937 unformat_input_t *i = vam->input;
13938 vl_api_ip_probe_neighbor_t *mp;
13939 vl_api_address_t dst_adr = { };
13945 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13947 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13949 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13951 else if (unformat (i, "address %U", unformat_vl_api_address, &dst_adr))
13959 errmsg ("missing interface");
13965 errmsg ("missing addresses");
13969 M (IP_PROBE_NEIGHBOR, mp);
13971 mp->sw_if_index = ntohl (sw_if_index);
13972 clib_memcpy (&mp->dst, &dst_adr, sizeof (dst_adr));
13980 api_ip_scan_neighbor_enable_disable (vat_main_t * vam)
13982 unformat_input_t *i = vam->input;
13983 vl_api_ip_scan_neighbor_enable_disable_t *mp;
13984 u8 mode = IP_SCAN_V46_NEIGHBORS;
13985 u32 interval = 0, time = 0, update = 0, delay = 0, stale = 0;
13988 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13990 if (unformat (i, "ip4"))
13991 mode = IP_SCAN_V4_NEIGHBORS;
13992 else if (unformat (i, "ip6"))
13993 mode = IP_SCAN_V6_NEIGHBORS;
13994 if (unformat (i, "both"))
13995 mode = IP_SCAN_V46_NEIGHBORS;
13996 else if (unformat (i, "disable"))
13997 mode = IP_SCAN_DISABLED;
13998 else if (unformat (i, "interval %d", &interval))
14000 else if (unformat (i, "max-time %d", &time))
14002 else if (unformat (i, "max-update %d", &update))
14004 else if (unformat (i, "delay %d", &delay))
14006 else if (unformat (i, "stale %d", &stale))
14012 if (interval > 255)
14014 errmsg ("interval cannot exceed 255 minutes.");
14019 errmsg ("max-time cannot exceed 255 usec.");
14024 errmsg ("max-update cannot exceed 255.");
14029 errmsg ("delay cannot exceed 255 msec.");
14034 errmsg ("stale cannot exceed 255 minutes.");
14038 M (IP_SCAN_NEIGHBOR_ENABLE_DISABLE, mp);
14040 mp->scan_interval = interval;
14041 mp->max_proc_time = time;
14042 mp->max_update = update;
14043 mp->scan_int_delay = delay;
14044 mp->stale_threshold = stale;
14052 api_want_ip4_arp_events (vat_main_t * vam)
14054 unformat_input_t *line_input = vam->input;
14055 vl_api_want_ip4_arp_events_t *mp;
14056 ip4_address_t address;
14057 int address_set = 0;
14058 u32 enable_disable = 1;
14061 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14063 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
14065 else if (unformat (line_input, "del"))
14066 enable_disable = 0;
14071 if (address_set == 0)
14073 errmsg ("missing addresses");
14077 M (WANT_IP4_ARP_EVENTS, mp);
14078 mp->enable_disable = enable_disable;
14079 mp->pid = htonl (getpid ());
14080 clib_memcpy (mp->ip, &address, sizeof (address));
14088 api_want_ip6_nd_events (vat_main_t * vam)
14090 unformat_input_t *line_input = vam->input;
14091 vl_api_want_ip6_nd_events_t *mp;
14092 vl_api_ip6_address_t address;
14093 int address_set = 0;
14094 u32 enable_disable = 1;
14097 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14100 (line_input, "address %U", unformat_vl_api_ip6_address, &address))
14102 else if (unformat (line_input, "del"))
14103 enable_disable = 0;
14108 if (address_set == 0)
14110 errmsg ("missing addresses");
14114 M (WANT_IP6_ND_EVENTS, mp);
14115 mp->enable_disable = enable_disable;
14116 mp->pid = htonl (getpid ());
14117 clib_memcpy (&mp->ip, &address, sizeof (address));
14125 api_want_l2_macs_events (vat_main_t * vam)
14127 unformat_input_t *line_input = vam->input;
14128 vl_api_want_l2_macs_events_t *mp;
14129 u8 enable_disable = 1;
14130 u32 scan_delay = 0;
14131 u32 max_macs_in_event = 0;
14132 u32 learn_limit = 0;
14135 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14137 if (unformat (line_input, "learn-limit %d", &learn_limit))
14139 else if (unformat (line_input, "scan-delay %d", &scan_delay))
14141 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
14143 else if (unformat (line_input, "disable"))
14144 enable_disable = 0;
14149 M (WANT_L2_MACS_EVENTS, mp);
14150 mp->enable_disable = enable_disable;
14151 mp->pid = htonl (getpid ());
14152 mp->learn_limit = htonl (learn_limit);
14153 mp->scan_delay = (u8) scan_delay;
14154 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
14161 api_input_acl_set_interface (vat_main_t * vam)
14163 unformat_input_t *i = vam->input;
14164 vl_api_input_acl_set_interface_t *mp;
14166 int sw_if_index_set;
14167 u32 ip4_table_index = ~0;
14168 u32 ip6_table_index = ~0;
14169 u32 l2_table_index = ~0;
14173 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14175 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14176 sw_if_index_set = 1;
14177 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14178 sw_if_index_set = 1;
14179 else if (unformat (i, "del"))
14181 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14183 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14185 else if (unformat (i, "l2-table %d", &l2_table_index))
14189 clib_warning ("parse error '%U'", format_unformat_error, i);
14194 if (sw_if_index_set == 0)
14196 errmsg ("missing interface name or sw_if_index");
14200 M (INPUT_ACL_SET_INTERFACE, mp);
14202 mp->sw_if_index = ntohl (sw_if_index);
14203 mp->ip4_table_index = ntohl (ip4_table_index);
14204 mp->ip6_table_index = ntohl (ip6_table_index);
14205 mp->l2_table_index = ntohl (l2_table_index);
14206 mp->is_add = is_add;
14214 api_output_acl_set_interface (vat_main_t * vam)
14216 unformat_input_t *i = vam->input;
14217 vl_api_output_acl_set_interface_t *mp;
14219 int sw_if_index_set;
14220 u32 ip4_table_index = ~0;
14221 u32 ip6_table_index = ~0;
14222 u32 l2_table_index = ~0;
14226 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14228 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14229 sw_if_index_set = 1;
14230 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14231 sw_if_index_set = 1;
14232 else if (unformat (i, "del"))
14234 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14236 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14238 else if (unformat (i, "l2-table %d", &l2_table_index))
14242 clib_warning ("parse error '%U'", format_unformat_error, i);
14247 if (sw_if_index_set == 0)
14249 errmsg ("missing interface name or sw_if_index");
14253 M (OUTPUT_ACL_SET_INTERFACE, mp);
14255 mp->sw_if_index = ntohl (sw_if_index);
14256 mp->ip4_table_index = ntohl (ip4_table_index);
14257 mp->ip6_table_index = ntohl (ip6_table_index);
14258 mp->l2_table_index = ntohl (l2_table_index);
14259 mp->is_add = is_add;
14267 api_ip_address_dump (vat_main_t * vam)
14269 unformat_input_t *i = vam->input;
14270 vl_api_ip_address_dump_t *mp;
14271 vl_api_control_ping_t *mp_ping;
14272 u32 sw_if_index = ~0;
14273 u8 sw_if_index_set = 0;
14278 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14280 if (unformat (i, "sw_if_index %d", &sw_if_index))
14281 sw_if_index_set = 1;
14283 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14284 sw_if_index_set = 1;
14285 else if (unformat (i, "ipv4"))
14287 else if (unformat (i, "ipv6"))
14293 if (ipv4_set && ipv6_set)
14295 errmsg ("ipv4 and ipv6 flags cannot be both set");
14299 if ((!ipv4_set) && (!ipv6_set))
14301 errmsg ("no ipv4 nor ipv6 flag set");
14305 if (sw_if_index_set == 0)
14307 errmsg ("missing interface name or sw_if_index");
14311 vam->current_sw_if_index = sw_if_index;
14312 vam->is_ipv6 = ipv6_set;
14314 M (IP_ADDRESS_DUMP, mp);
14315 mp->sw_if_index = ntohl (sw_if_index);
14316 mp->is_ipv6 = ipv6_set;
14319 /* Use a control ping for synchronization */
14320 MPING (CONTROL_PING, mp_ping);
14328 api_ip_dump (vat_main_t * vam)
14330 vl_api_ip_dump_t *mp;
14331 vl_api_control_ping_t *mp_ping;
14332 unformat_input_t *in = vam->input;
14339 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
14341 if (unformat (in, "ipv4"))
14343 else if (unformat (in, "ipv6"))
14349 if (ipv4_set && ipv6_set)
14351 errmsg ("ipv4 and ipv6 flags cannot be both set");
14355 if ((!ipv4_set) && (!ipv6_set))
14357 errmsg ("no ipv4 nor ipv6 flag set");
14361 is_ipv6 = ipv6_set;
14362 vam->is_ipv6 = is_ipv6;
14364 /* free old data */
14365 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
14367 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
14369 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
14372 mp->is_ipv6 = ipv6_set;
14375 /* Use a control ping for synchronization */
14376 MPING (CONTROL_PING, mp_ping);
14384 api_ipsec_spd_add_del (vat_main_t * vam)
14386 unformat_input_t *i = vam->input;
14387 vl_api_ipsec_spd_add_del_t *mp;
14392 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14394 if (unformat (i, "spd_id %d", &spd_id))
14396 else if (unformat (i, "del"))
14400 clib_warning ("parse error '%U'", format_unformat_error, i);
14406 errmsg ("spd_id must be set");
14410 M (IPSEC_SPD_ADD_DEL, mp);
14412 mp->spd_id = ntohl (spd_id);
14413 mp->is_add = is_add;
14421 api_ipsec_interface_add_del_spd (vat_main_t * vam)
14423 unformat_input_t *i = vam->input;
14424 vl_api_ipsec_interface_add_del_spd_t *mp;
14426 u8 sw_if_index_set = 0;
14427 u32 spd_id = (u32) ~ 0;
14431 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14433 if (unformat (i, "del"))
14435 else if (unformat (i, "spd_id %d", &spd_id))
14438 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14439 sw_if_index_set = 1;
14440 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14441 sw_if_index_set = 1;
14444 clib_warning ("parse error '%U'", format_unformat_error, i);
14450 if (spd_id == (u32) ~ 0)
14452 errmsg ("spd_id must be set");
14456 if (sw_if_index_set == 0)
14458 errmsg ("missing interface name or sw_if_index");
14462 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
14464 mp->spd_id = ntohl (spd_id);
14465 mp->sw_if_index = ntohl (sw_if_index);
14466 mp->is_add = is_add;
14474 api_ipsec_spd_entry_add_del (vat_main_t * vam)
14476 unformat_input_t *i = vam->input;
14477 vl_api_ipsec_spd_entry_add_del_t *mp;
14478 u8 is_add = 1, is_outbound = 0;
14479 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
14481 u32 rport_start = 0, rport_stop = (u32) ~ 0;
14482 u32 lport_start = 0, lport_stop = (u32) ~ 0;
14483 vl_api_address_t laddr_start = { }, laddr_stop =
14492 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14494 if (unformat (i, "del"))
14496 if (unformat (i, "outbound"))
14498 if (unformat (i, "inbound"))
14500 else if (unformat (i, "spd_id %d", &spd_id))
14502 else if (unformat (i, "sa_id %d", &sa_id))
14504 else if (unformat (i, "priority %d", &priority))
14506 else if (unformat (i, "protocol %d", &protocol))
14508 else if (unformat (i, "lport_start %d", &lport_start))
14510 else if (unformat (i, "lport_stop %d", &lport_stop))
14512 else if (unformat (i, "rport_start %d", &rport_start))
14514 else if (unformat (i, "rport_stop %d", &rport_stop))
14516 else if (unformat (i, "laddr_start %U",
14517 unformat_vl_api_address, &laddr_start))
14519 else if (unformat (i, "laddr_stop %U", unformat_vl_api_address,
14522 else if (unformat (i, "raddr_start %U", unformat_vl_api_address,
14525 else if (unformat (i, "raddr_stop %U", unformat_vl_api_address,
14529 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
14531 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
14533 clib_warning ("unsupported action: 'resolve'");
14539 clib_warning ("parse error '%U'", format_unformat_error, i);
14545 M (IPSEC_SPD_ENTRY_ADD_DEL, mp);
14547 mp->is_add = is_add;
14549 mp->entry.spd_id = ntohl (spd_id);
14550 mp->entry.priority = ntohl (priority);
14551 mp->entry.is_outbound = is_outbound;
14553 clib_memcpy (&mp->entry.remote_address_start, &raddr_start,
14554 sizeof (vl_api_address_t));
14555 clib_memcpy (&mp->entry.remote_address_stop, &raddr_stop,
14556 sizeof (vl_api_address_t));
14557 clib_memcpy (&mp->entry.local_address_start, &laddr_start,
14558 sizeof (vl_api_address_t));
14559 clib_memcpy (&mp->entry.local_address_stop, &laddr_stop,
14560 sizeof (vl_api_address_t));
14562 mp->entry.protocol = (u8) protocol;
14563 mp->entry.local_port_start = ntohs ((u16) lport_start);
14564 mp->entry.local_port_stop = ntohs ((u16) lport_stop);
14565 mp->entry.remote_port_start = ntohs ((u16) rport_start);
14566 mp->entry.remote_port_stop = ntohs ((u16) rport_stop);
14567 mp->entry.policy = (u8) policy;
14568 mp->entry.sa_id = ntohl (sa_id);
14576 api_ipsec_sad_entry_add_del (vat_main_t * vam)
14578 unformat_input_t *i = vam->input;
14579 vl_api_ipsec_sad_entry_add_del_t *mp;
14580 u32 sad_id = 0, spi = 0;
14581 u8 *ck = 0, *ik = 0;
14584 vl_api_ipsec_crypto_alg_t crypto_alg = IPSEC_API_CRYPTO_ALG_NONE;
14585 vl_api_ipsec_integ_alg_t integ_alg = IPSEC_API_INTEG_ALG_NONE;
14586 vl_api_ipsec_sad_flags_t flags = IPSEC_API_SAD_FLAG_NONE;
14587 vl_api_ipsec_proto_t protocol = IPSEC_API_PROTO_AH;
14588 vl_api_address_t tun_src, tun_dst;
14591 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14593 if (unformat (i, "del"))
14595 else if (unformat (i, "sad_id %d", &sad_id))
14597 else if (unformat (i, "spi %d", &spi))
14599 else if (unformat (i, "esp"))
14600 protocol = IPSEC_API_PROTO_ESP;
14602 if (unformat (i, "tunnel_src %U", unformat_vl_api_address, &tun_src))
14604 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
14605 if (ADDRESS_IP6 == tun_src.af)
14606 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
14609 if (unformat (i, "tunnel_dst %U", unformat_vl_api_address, &tun_dst))
14611 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
14612 if (ADDRESS_IP6 == tun_src.af)
14613 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
14616 if (unformat (i, "crypto_alg %U",
14617 unformat_ipsec_api_crypto_alg, &crypto_alg))
14619 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14621 else if (unformat (i, "integ_alg %U",
14622 unformat_ipsec_api_integ_alg, &integ_alg))
14624 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14628 clib_warning ("parse error '%U'", format_unformat_error, i);
14634 M (IPSEC_SAD_ENTRY_ADD_DEL, mp);
14636 mp->is_add = is_add;
14637 mp->entry.sad_id = ntohl (sad_id);
14638 mp->entry.protocol = protocol;
14639 mp->entry.spi = ntohl (spi);
14640 mp->entry.flags = flags;
14642 mp->entry.crypto_algorithm = crypto_alg;
14643 mp->entry.integrity_algorithm = integ_alg;
14644 mp->entry.crypto_key.length = vec_len (ck);
14645 mp->entry.integrity_key.length = vec_len (ik);
14647 if (mp->entry.crypto_key.length > sizeof (mp->entry.crypto_key.data))
14648 mp->entry.crypto_key.length = sizeof (mp->entry.crypto_key.data);
14650 if (mp->entry.integrity_key.length > sizeof (mp->entry.integrity_key.data))
14651 mp->entry.integrity_key.length = sizeof (mp->entry.integrity_key.data);
14654 clib_memcpy (mp->entry.crypto_key.data, ck, mp->entry.crypto_key.length);
14656 clib_memcpy (mp->entry.integrity_key.data, ik,
14657 mp->entry.integrity_key.length);
14659 if (flags & IPSEC_API_SAD_FLAG_IS_TUNNEL)
14661 clib_memcpy (&mp->entry.tunnel_src, &tun_src,
14662 sizeof (mp->entry.tunnel_src));
14663 clib_memcpy (&mp->entry.tunnel_dst, &tun_dst,
14664 sizeof (mp->entry.tunnel_dst));
14673 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
14675 unformat_input_t *i = vam->input;
14676 vl_api_ipsec_tunnel_if_add_del_t *mp;
14677 u32 local_spi = 0, remote_spi = 0;
14678 u32 crypto_alg = 0, integ_alg = 0;
14679 u8 *lck = NULL, *rck = NULL;
14680 u8 *lik = NULL, *rik = NULL;
14681 vl_api_address_t local_ip = { 0 };
14682 vl_api_address_t remote_ip = { 0 };
14686 u8 anti_replay = 0;
14692 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14694 if (unformat (i, "del"))
14696 else if (unformat (i, "esn"))
14698 else if (unformat (i, "anti-replay"))
14700 else if (unformat (i, "count %d", &count))
14702 else if (unformat (i, "local_spi %d", &local_spi))
14704 else if (unformat (i, "remote_spi %d", &remote_spi))
14707 if (unformat (i, "local_ip %U", unformat_vl_api_address, &local_ip))
14710 if (unformat (i, "remote_ip %U", unformat_vl_api_address, &remote_ip))
14712 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
14715 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
14717 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
14719 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
14723 (i, "crypto_alg %U", unformat_ipsec_api_crypto_alg, &crypto_alg))
14725 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
14727 errmsg ("unsupported crypto-alg: '%U'\n",
14728 format_ipsec_crypto_alg, crypto_alg);
14734 (i, "integ_alg %U", unformat_ipsec_api_integ_alg, &integ_alg))
14736 if (integ_alg >= IPSEC_INTEG_N_ALG)
14738 errmsg ("unsupported integ-alg: '%U'\n",
14739 format_ipsec_integ_alg, integ_alg);
14743 else if (unformat (i, "instance %u", &instance))
14747 errmsg ("parse error '%U'\n", format_unformat_error, i);
14754 /* Turn on async mode */
14755 vam->async_mode = 1;
14756 vam->async_errors = 0;
14757 before = vat_time_now (vam);
14760 for (jj = 0; jj < count; jj++)
14762 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
14764 mp->is_add = is_add;
14766 mp->anti_replay = anti_replay;
14769 increment_address (&remote_ip);
14771 clib_memcpy (&mp->local_ip, &local_ip, sizeof (local_ip));
14772 clib_memcpy (&mp->remote_ip, &remote_ip, sizeof (remote_ip));
14774 mp->local_spi = htonl (local_spi + jj);
14775 mp->remote_spi = htonl (remote_spi + jj);
14776 mp->crypto_alg = (u8) crypto_alg;
14778 mp->local_crypto_key_len = 0;
14781 mp->local_crypto_key_len = vec_len (lck);
14782 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
14783 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
14784 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
14787 mp->remote_crypto_key_len = 0;
14790 mp->remote_crypto_key_len = vec_len (rck);
14791 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
14792 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
14793 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
14796 mp->integ_alg = (u8) integ_alg;
14798 mp->local_integ_key_len = 0;
14801 mp->local_integ_key_len = vec_len (lik);
14802 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
14803 mp->local_integ_key_len = sizeof (mp->local_integ_key);
14804 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
14807 mp->remote_integ_key_len = 0;
14810 mp->remote_integ_key_len = vec_len (rik);
14811 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
14812 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
14813 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
14818 mp->renumber = renumber;
14819 mp->show_instance = ntohl (instance);
14824 /* When testing multiple add/del ops, use a control-ping to sync */
14827 vl_api_control_ping_t *mp_ping;
14831 /* Shut off async mode */
14832 vam->async_mode = 0;
14834 MPING (CONTROL_PING, mp_ping);
14837 timeout = vat_time_now (vam) + 1.0;
14838 while (vat_time_now (vam) < timeout)
14839 if (vam->result_ready == 1)
14844 if (vam->retval == -99)
14845 errmsg ("timeout");
14847 if (vam->async_errors > 0)
14849 errmsg ("%d asynchronous errors", vam->async_errors);
14852 vam->async_errors = 0;
14853 after = vat_time_now (vam);
14855 /* slim chance, but we might have eaten SIGTERM on the first iteration */
14859 print (vam->ofp, "%d tunnels in %.6f secs, %.2f tunnels/sec",
14860 count, after - before, count / (after - before));
14864 /* Wait for a reply... */
14873 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
14875 vat_main_t *vam = &vat_main;
14877 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
14878 "crypto_key %U integ_alg %u integ_key %U flags %x "
14879 "tunnel_src_addr %U tunnel_dst_addr %U "
14880 "salt %u seq_outbound %lu last_seq_inbound %lu "
14881 "replay_window %lu\n",
14882 ntohl (mp->entry.sad_id),
14883 ntohl (mp->sw_if_index),
14884 ntohl (mp->entry.spi),
14885 ntohl (mp->entry.protocol),
14886 ntohl (mp->entry.crypto_algorithm),
14887 format_hex_bytes, mp->entry.crypto_key.data,
14888 mp->entry.crypto_key.length, ntohl (mp->entry.integrity_algorithm),
14889 format_hex_bytes, mp->entry.integrity_key.data,
14890 mp->entry.integrity_key.length, ntohl (mp->entry.flags),
14891 format_vl_api_address, &mp->entry.tunnel_src, format_vl_api_address,
14892 &mp->entry.tunnel_dst, ntohl (mp->salt),
14893 clib_net_to_host_u64 (mp->seq_outbound),
14894 clib_net_to_host_u64 (mp->last_seq_inbound),
14895 clib_net_to_host_u64 (mp->replay_window));
14898 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
14899 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
14901 static void vl_api_ipsec_sa_details_t_handler_json
14902 (vl_api_ipsec_sa_details_t * mp)
14904 vat_main_t *vam = &vat_main;
14905 vat_json_node_t *node = NULL;
14906 vl_api_ipsec_sad_flags_t flags;
14908 if (VAT_JSON_ARRAY != vam->json_tree.type)
14910 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14911 vat_json_init_array (&vam->json_tree);
14913 node = vat_json_array_add (&vam->json_tree);
14915 vat_json_init_object (node);
14916 vat_json_object_add_uint (node, "sa_id", ntohl (mp->entry.sad_id));
14917 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14918 vat_json_object_add_uint (node, "spi", ntohl (mp->entry.spi));
14919 vat_json_object_add_uint (node, "proto", ntohl (mp->entry.protocol));
14920 vat_json_object_add_uint (node, "crypto_alg",
14921 ntohl (mp->entry.crypto_algorithm));
14922 vat_json_object_add_uint (node, "integ_alg",
14923 ntohl (mp->entry.integrity_algorithm));
14924 flags = ntohl (mp->entry.flags);
14925 vat_json_object_add_uint (node, "use_esn",
14926 ! !(flags & IPSEC_API_SAD_FLAG_USE_ESN));
14927 vat_json_object_add_uint (node, "use_anti_replay",
14928 ! !(flags & IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY));
14929 vat_json_object_add_uint (node, "is_tunnel",
14930 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL));
14931 vat_json_object_add_uint (node, "is_tunnel_ip6",
14932 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL_V6));
14933 vat_json_object_add_uint (node, "udp_encap",
14934 ! !(flags & IPSEC_API_SAD_FLAG_UDP_ENCAP));
14935 vat_json_object_add_bytes (node, "crypto_key", mp->entry.crypto_key.data,
14936 mp->entry.crypto_key.length);
14937 vat_json_object_add_bytes (node, "integ_key", mp->entry.integrity_key.data,
14938 mp->entry.integrity_key.length);
14939 vat_json_object_add_address (node, "src", &mp->entry.tunnel_src);
14940 vat_json_object_add_address (node, "dst", &mp->entry.tunnel_dst);
14941 vat_json_object_add_uint (node, "replay_window",
14942 clib_net_to_host_u64 (mp->replay_window));
14946 api_ipsec_sa_dump (vat_main_t * vam)
14948 unformat_input_t *i = vam->input;
14949 vl_api_ipsec_sa_dump_t *mp;
14950 vl_api_control_ping_t *mp_ping;
14954 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14956 if (unformat (i, "sa_id %d", &sa_id))
14960 clib_warning ("parse error '%U'", format_unformat_error, i);
14965 M (IPSEC_SA_DUMP, mp);
14967 mp->sa_id = ntohl (sa_id);
14971 /* Use a control ping for synchronization */
14972 M (CONTROL_PING, mp_ping);
14980 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
14982 unformat_input_t *i = vam->input;
14983 vl_api_ipsec_tunnel_if_set_sa_t *mp;
14984 u32 sw_if_index = ~0;
14986 u8 is_outbound = (u8) ~ 0;
14989 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14991 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14993 else if (unformat (i, "sa_id %d", &sa_id))
14995 else if (unformat (i, "outbound"))
14997 else if (unformat (i, "inbound"))
15001 clib_warning ("parse error '%U'", format_unformat_error, i);
15006 if (sw_if_index == ~0)
15008 errmsg ("interface must be specified");
15014 errmsg ("SA ID must be specified");
15018 M (IPSEC_TUNNEL_IF_SET_SA, mp);
15020 mp->sw_if_index = htonl (sw_if_index);
15021 mp->sa_id = htonl (sa_id);
15022 mp->is_outbound = is_outbound;
15031 api_get_first_msg_id (vat_main_t * vam)
15033 vl_api_get_first_msg_id_t *mp;
15034 unformat_input_t *i = vam->input;
15039 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15041 if (unformat (i, "client %s", &name))
15049 errmsg ("missing client name");
15052 vec_add1 (name, 0);
15054 if (vec_len (name) > 63)
15056 errmsg ("client name too long");
15060 M (GET_FIRST_MSG_ID, mp);
15061 clib_memcpy (mp->name, name, vec_len (name));
15068 api_cop_interface_enable_disable (vat_main_t * vam)
15070 unformat_input_t *line_input = vam->input;
15071 vl_api_cop_interface_enable_disable_t *mp;
15072 u32 sw_if_index = ~0;
15073 u8 enable_disable = 1;
15076 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15078 if (unformat (line_input, "disable"))
15079 enable_disable = 0;
15080 if (unformat (line_input, "enable"))
15081 enable_disable = 1;
15082 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15083 vam, &sw_if_index))
15085 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15091 if (sw_if_index == ~0)
15093 errmsg ("missing interface name or sw_if_index");
15097 /* Construct the API message */
15098 M (COP_INTERFACE_ENABLE_DISABLE, mp);
15099 mp->sw_if_index = ntohl (sw_if_index);
15100 mp->enable_disable = enable_disable;
15104 /* Wait for the reply */
15110 api_cop_whitelist_enable_disable (vat_main_t * vam)
15112 unformat_input_t *line_input = vam->input;
15113 vl_api_cop_whitelist_enable_disable_t *mp;
15114 u32 sw_if_index = ~0;
15115 u8 ip4 = 0, ip6 = 0, default_cop = 0;
15119 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15121 if (unformat (line_input, "ip4"))
15123 else if (unformat (line_input, "ip6"))
15125 else if (unformat (line_input, "default"))
15127 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15128 vam, &sw_if_index))
15130 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15132 else if (unformat (line_input, "fib-id %d", &fib_id))
15138 if (sw_if_index == ~0)
15140 errmsg ("missing interface name or sw_if_index");
15144 /* Construct the API message */
15145 M (COP_WHITELIST_ENABLE_DISABLE, mp);
15146 mp->sw_if_index = ntohl (sw_if_index);
15147 mp->fib_id = ntohl (fib_id);
15150 mp->default_cop = default_cop;
15154 /* Wait for the reply */
15160 api_get_node_graph (vat_main_t * vam)
15162 vl_api_get_node_graph_t *mp;
15165 M (GET_NODE_GRAPH, mp);
15169 /* Wait for the reply */
15175 /** Used for parsing LISP eids */
15176 typedef CLIB_PACKED(struct{
15177 u8 addr[16]; /**< eid address */
15178 u32 len; /**< prefix length if IP */
15179 u8 type; /**< type of eid */
15184 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
15186 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
15188 clib_memset (a, 0, sizeof (a[0]));
15190 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
15192 a->type = 0; /* ipv4 type */
15194 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
15196 a->type = 1; /* ipv6 type */
15198 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
15200 a->type = 2; /* mac type */
15202 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
15204 a->type = 3; /* NSH type */
15205 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
15206 nsh->spi = clib_host_to_net_u32 (nsh->spi);
15213 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
15222 lisp_eid_size_vat (u8 type)
15239 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
15241 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
15245 api_one_add_del_locator_set (vat_main_t * vam)
15247 unformat_input_t *input = vam->input;
15248 vl_api_one_add_del_locator_set_t *mp;
15250 u8 *locator_set_name = NULL;
15251 u8 locator_set_name_set = 0;
15252 vl_api_local_locator_t locator, *locators = 0;
15253 u32 sw_if_index, priority, weight;
15257 /* Parse args required to build the message */
15258 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15260 if (unformat (input, "del"))
15264 else if (unformat (input, "locator-set %s", &locator_set_name))
15266 locator_set_name_set = 1;
15268 else if (unformat (input, "sw_if_index %u p %u w %u",
15269 &sw_if_index, &priority, &weight))
15271 locator.sw_if_index = htonl (sw_if_index);
15272 locator.priority = priority;
15273 locator.weight = weight;
15274 vec_add1 (locators, locator);
15278 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
15279 &sw_if_index, &priority, &weight))
15281 locator.sw_if_index = htonl (sw_if_index);
15282 locator.priority = priority;
15283 locator.weight = weight;
15284 vec_add1 (locators, locator);
15290 if (locator_set_name_set == 0)
15292 errmsg ("missing locator-set name");
15293 vec_free (locators);
15297 if (vec_len (locator_set_name) > 64)
15299 errmsg ("locator-set name too long");
15300 vec_free (locator_set_name);
15301 vec_free (locators);
15304 vec_add1 (locator_set_name, 0);
15306 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
15308 /* Construct the API message */
15309 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
15311 mp->is_add = is_add;
15312 clib_memcpy (mp->locator_set_name, locator_set_name,
15313 vec_len (locator_set_name));
15314 vec_free (locator_set_name);
15316 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
15318 clib_memcpy (mp->locators, locators, data_len);
15319 vec_free (locators);
15324 /* Wait for a reply... */
15329 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
15332 api_one_add_del_locator (vat_main_t * vam)
15334 unformat_input_t *input = vam->input;
15335 vl_api_one_add_del_locator_t *mp;
15336 u32 tmp_if_index = ~0;
15337 u32 sw_if_index = ~0;
15338 u8 sw_if_index_set = 0;
15339 u8 sw_if_index_if_name_set = 0;
15341 u8 priority_set = 0;
15345 u8 *locator_set_name = NULL;
15346 u8 locator_set_name_set = 0;
15349 /* Parse args required to build the message */
15350 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15352 if (unformat (input, "del"))
15356 else if (unformat (input, "locator-set %s", &locator_set_name))
15358 locator_set_name_set = 1;
15360 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
15363 sw_if_index_if_name_set = 1;
15364 sw_if_index = tmp_if_index;
15366 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
15368 sw_if_index_set = 1;
15369 sw_if_index = tmp_if_index;
15371 else if (unformat (input, "p %d", &priority))
15375 else if (unformat (input, "w %d", &weight))
15383 if (locator_set_name_set == 0)
15385 errmsg ("missing locator-set name");
15389 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
15391 errmsg ("missing sw_if_index");
15392 vec_free (locator_set_name);
15396 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
15398 errmsg ("cannot use both params interface name and sw_if_index");
15399 vec_free (locator_set_name);
15403 if (priority_set == 0)
15405 errmsg ("missing locator-set priority");
15406 vec_free (locator_set_name);
15410 if (weight_set == 0)
15412 errmsg ("missing locator-set weight");
15413 vec_free (locator_set_name);
15417 if (vec_len (locator_set_name) > 64)
15419 errmsg ("locator-set name too long");
15420 vec_free (locator_set_name);
15423 vec_add1 (locator_set_name, 0);
15425 /* Construct the API message */
15426 M (ONE_ADD_DEL_LOCATOR, mp);
15428 mp->is_add = is_add;
15429 mp->sw_if_index = ntohl (sw_if_index);
15430 mp->priority = priority;
15431 mp->weight = weight;
15432 clib_memcpy (mp->locator_set_name, locator_set_name,
15433 vec_len (locator_set_name));
15434 vec_free (locator_set_name);
15439 /* Wait for a reply... */
15444 #define api_lisp_add_del_locator api_one_add_del_locator
15447 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
15449 u32 *key_id = va_arg (*args, u32 *);
15452 if (unformat (input, "%s", &s))
15454 if (!strcmp ((char *) s, "sha1"))
15455 key_id[0] = HMAC_SHA_1_96;
15456 else if (!strcmp ((char *) s, "sha256"))
15457 key_id[0] = HMAC_SHA_256_128;
15460 clib_warning ("invalid key_id: '%s'", s);
15461 key_id[0] = HMAC_NO_KEY;
15472 api_one_add_del_local_eid (vat_main_t * vam)
15474 unformat_input_t *input = vam->input;
15475 vl_api_one_add_del_local_eid_t *mp;
15478 lisp_eid_vat_t _eid, *eid = &_eid;
15479 u8 *locator_set_name = 0;
15480 u8 locator_set_name_set = 0;
15486 /* Parse args required to build the message */
15487 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15489 if (unformat (input, "del"))
15493 else if (unformat (input, "vni %d", &vni))
15497 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15501 else if (unformat (input, "locator-set %s", &locator_set_name))
15503 locator_set_name_set = 1;
15505 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
15507 else if (unformat (input, "secret-key %_%v%_", &key))
15513 if (locator_set_name_set == 0)
15515 errmsg ("missing locator-set name");
15521 errmsg ("EID address not set!");
15522 vec_free (locator_set_name);
15526 if (key && (0 == key_id))
15528 errmsg ("invalid key_id!");
15532 if (vec_len (key) > 64)
15534 errmsg ("key too long");
15539 if (vec_len (locator_set_name) > 64)
15541 errmsg ("locator-set name too long");
15542 vec_free (locator_set_name);
15545 vec_add1 (locator_set_name, 0);
15547 /* Construct the API message */
15548 M (ONE_ADD_DEL_LOCAL_EID, mp);
15550 mp->is_add = is_add;
15551 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15552 mp->eid_type = eid->type;
15553 mp->prefix_len = eid->len;
15554 mp->vni = clib_host_to_net_u32 (vni);
15555 mp->key_id = clib_host_to_net_u16 (key_id);
15556 clib_memcpy (mp->locator_set_name, locator_set_name,
15557 vec_len (locator_set_name));
15558 clib_memcpy (mp->key, key, vec_len (key));
15560 vec_free (locator_set_name);
15566 /* Wait for a reply... */
15571 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
15574 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
15576 u32 dp_table = 0, vni = 0;;
15577 unformat_input_t *input = vam->input;
15578 vl_api_gpe_add_del_fwd_entry_t *mp;
15580 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
15581 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
15582 u8 rmt_eid_set = 0, lcl_eid_set = 0;
15583 u32 action = ~0, w;
15584 ip4_address_t rmt_rloc4, lcl_rloc4;
15585 ip6_address_t rmt_rloc6, lcl_rloc6;
15586 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
15589 clib_memset (&rloc, 0, sizeof (rloc));
15591 /* Parse args required to build the message */
15592 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15594 if (unformat (input, "del"))
15596 else if (unformat (input, "add"))
15598 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
15602 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
15606 else if (unformat (input, "vrf %d", &dp_table))
15608 else if (unformat (input, "bd %d", &dp_table))
15610 else if (unformat (input, "vni %d", &vni))
15612 else if (unformat (input, "w %d", &w))
15616 errmsg ("No RLOC configured for setting priority/weight!");
15619 curr_rloc->weight = w;
15621 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
15622 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
15626 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
15628 vec_add1 (lcl_locs, rloc);
15630 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
15631 vec_add1 (rmt_locs, rloc);
15632 /* weight saved in rmt loc */
15633 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15635 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
15636 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
15639 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
15641 vec_add1 (lcl_locs, rloc);
15643 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
15644 vec_add1 (rmt_locs, rloc);
15645 /* weight saved in rmt loc */
15646 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15648 else if (unformat (input, "action %d", &action))
15654 clib_warning ("parse error '%U'", format_unformat_error, input);
15661 errmsg ("remote eid addresses not set");
15665 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
15667 errmsg ("eid types don't match");
15671 if (0 == rmt_locs && (u32) ~ 0 == action)
15673 errmsg ("action not set for negative mapping");
15677 /* Construct the API message */
15678 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
15679 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
15681 mp->is_add = is_add;
15682 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
15683 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
15684 mp->eid_type = rmt_eid->type;
15685 mp->dp_table = clib_host_to_net_u32 (dp_table);
15686 mp->vni = clib_host_to_net_u32 (vni);
15687 mp->rmt_len = rmt_eid->len;
15688 mp->lcl_len = lcl_eid->len;
15689 mp->action = action;
15691 if (0 != rmt_locs && 0 != lcl_locs)
15693 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
15694 clib_memcpy (mp->locs, lcl_locs,
15695 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
15697 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
15698 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
15699 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
15701 vec_free (lcl_locs);
15702 vec_free (rmt_locs);
15707 /* Wait for a reply... */
15713 api_one_add_del_map_server (vat_main_t * vam)
15715 unformat_input_t *input = vam->input;
15716 vl_api_one_add_del_map_server_t *mp;
15720 ip4_address_t ipv4;
15721 ip6_address_t ipv6;
15724 /* Parse args required to build the message */
15725 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15727 if (unformat (input, "del"))
15731 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15735 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15743 if (ipv4_set && ipv6_set)
15745 errmsg ("both eid v4 and v6 addresses set");
15749 if (!ipv4_set && !ipv6_set)
15751 errmsg ("eid addresses not set");
15755 /* Construct the API message */
15756 M (ONE_ADD_DEL_MAP_SERVER, mp);
15758 mp->is_add = is_add;
15762 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
15767 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
15773 /* Wait for a reply... */
15778 #define api_lisp_add_del_map_server api_one_add_del_map_server
15781 api_one_add_del_map_resolver (vat_main_t * vam)
15783 unformat_input_t *input = vam->input;
15784 vl_api_one_add_del_map_resolver_t *mp;
15788 ip4_address_t ipv4;
15789 ip6_address_t ipv6;
15792 /* Parse args required to build the message */
15793 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15795 if (unformat (input, "del"))
15799 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15803 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15811 if (ipv4_set && ipv6_set)
15813 errmsg ("both eid v4 and v6 addresses set");
15817 if (!ipv4_set && !ipv6_set)
15819 errmsg ("eid addresses not set");
15823 /* Construct the API message */
15824 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
15826 mp->is_add = is_add;
15830 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
15835 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
15841 /* Wait for a reply... */
15846 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
15849 api_lisp_gpe_enable_disable (vat_main_t * vam)
15851 unformat_input_t *input = vam->input;
15852 vl_api_gpe_enable_disable_t *mp;
15857 /* Parse args required to build the message */
15858 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15860 if (unformat (input, "enable"))
15865 else if (unformat (input, "disable"))
15876 errmsg ("Value not set");
15880 /* Construct the API message */
15881 M (GPE_ENABLE_DISABLE, mp);
15888 /* Wait for a reply... */
15894 api_one_rloc_probe_enable_disable (vat_main_t * vam)
15896 unformat_input_t *input = vam->input;
15897 vl_api_one_rloc_probe_enable_disable_t *mp;
15902 /* Parse args required to build the message */
15903 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15905 if (unformat (input, "enable"))
15910 else if (unformat (input, "disable"))
15918 errmsg ("Value not set");
15922 /* Construct the API message */
15923 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
15925 mp->is_enabled = is_en;
15930 /* Wait for a reply... */
15935 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
15938 api_one_map_register_enable_disable (vat_main_t * vam)
15940 unformat_input_t *input = vam->input;
15941 vl_api_one_map_register_enable_disable_t *mp;
15946 /* Parse args required to build the message */
15947 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15949 if (unformat (input, "enable"))
15954 else if (unformat (input, "disable"))
15962 errmsg ("Value not set");
15966 /* Construct the API message */
15967 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
15969 mp->is_enabled = is_en;
15974 /* Wait for a reply... */
15979 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
15982 api_one_enable_disable (vat_main_t * vam)
15984 unformat_input_t *input = vam->input;
15985 vl_api_one_enable_disable_t *mp;
15990 /* Parse args required to build the message */
15991 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15993 if (unformat (input, "enable"))
15998 else if (unformat (input, "disable"))
16008 errmsg ("Value not set");
16012 /* Construct the API message */
16013 M (ONE_ENABLE_DISABLE, mp);
16020 /* Wait for a reply... */
16025 #define api_lisp_enable_disable api_one_enable_disable
16028 api_one_enable_disable_xtr_mode (vat_main_t * vam)
16030 unformat_input_t *input = vam->input;
16031 vl_api_one_enable_disable_xtr_mode_t *mp;
16036 /* Parse args required to build the message */
16037 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16039 if (unformat (input, "enable"))
16044 else if (unformat (input, "disable"))
16054 errmsg ("Value not set");
16058 /* Construct the API message */
16059 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
16066 /* Wait for a reply... */
16072 api_one_show_xtr_mode (vat_main_t * vam)
16074 vl_api_one_show_xtr_mode_t *mp;
16077 /* Construct the API message */
16078 M (ONE_SHOW_XTR_MODE, mp);
16083 /* Wait for a reply... */
16089 api_one_enable_disable_pitr_mode (vat_main_t * vam)
16091 unformat_input_t *input = vam->input;
16092 vl_api_one_enable_disable_pitr_mode_t *mp;
16097 /* Parse args required to build the message */
16098 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16100 if (unformat (input, "enable"))
16105 else if (unformat (input, "disable"))
16115 errmsg ("Value not set");
16119 /* Construct the API message */
16120 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
16127 /* Wait for a reply... */
16133 api_one_show_pitr_mode (vat_main_t * vam)
16135 vl_api_one_show_pitr_mode_t *mp;
16138 /* Construct the API message */
16139 M (ONE_SHOW_PITR_MODE, mp);
16144 /* Wait for a reply... */
16150 api_one_enable_disable_petr_mode (vat_main_t * vam)
16152 unformat_input_t *input = vam->input;
16153 vl_api_one_enable_disable_petr_mode_t *mp;
16158 /* Parse args required to build the message */
16159 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16161 if (unformat (input, "enable"))
16166 else if (unformat (input, "disable"))
16176 errmsg ("Value not set");
16180 /* Construct the API message */
16181 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
16188 /* Wait for a reply... */
16194 api_one_show_petr_mode (vat_main_t * vam)
16196 vl_api_one_show_petr_mode_t *mp;
16199 /* Construct the API message */
16200 M (ONE_SHOW_PETR_MODE, mp);
16205 /* Wait for a reply... */
16211 api_show_one_map_register_state (vat_main_t * vam)
16213 vl_api_show_one_map_register_state_t *mp;
16216 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
16221 /* wait for reply */
16226 #define api_show_lisp_map_register_state api_show_one_map_register_state
16229 api_show_one_rloc_probe_state (vat_main_t * vam)
16231 vl_api_show_one_rloc_probe_state_t *mp;
16234 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
16239 /* wait for reply */
16244 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
16247 api_one_add_del_ndp_entry (vat_main_t * vam)
16249 vl_api_one_add_del_ndp_entry_t *mp;
16250 unformat_input_t *input = vam->input;
16255 u8 mac[6] = { 0, };
16256 u8 ip6[16] = { 0, };
16260 /* Parse args required to build the message */
16261 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16263 if (unformat (input, "del"))
16265 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16267 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
16269 else if (unformat (input, "bd %d", &bd))
16273 errmsg ("parse error '%U'", format_unformat_error, input);
16278 if (!bd_set || !ip_set || (!mac_set && is_add))
16280 errmsg ("Missing BD, IP or MAC!");
16284 M (ONE_ADD_DEL_NDP_ENTRY, mp);
16285 mp->is_add = is_add;
16286 clib_memcpy (mp->mac, mac, 6);
16287 mp->bd = clib_host_to_net_u32 (bd);
16288 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
16293 /* wait for reply */
16299 api_one_add_del_l2_arp_entry (vat_main_t * vam)
16301 vl_api_one_add_del_l2_arp_entry_t *mp;
16302 unformat_input_t *input = vam->input;
16307 u8 mac[6] = { 0, };
16308 u32 ip4 = 0, bd = ~0;
16311 /* Parse args required to build the message */
16312 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16314 if (unformat (input, "del"))
16316 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16318 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
16320 else if (unformat (input, "bd %d", &bd))
16324 errmsg ("parse error '%U'", format_unformat_error, input);
16329 if (!bd_set || !ip_set || (!mac_set && is_add))
16331 errmsg ("Missing BD, IP or MAC!");
16335 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
16336 mp->is_add = is_add;
16337 clib_memcpy (mp->mac, mac, 6);
16338 mp->bd = clib_host_to_net_u32 (bd);
16344 /* wait for reply */
16350 api_one_ndp_bd_get (vat_main_t * vam)
16352 vl_api_one_ndp_bd_get_t *mp;
16355 M (ONE_NDP_BD_GET, mp);
16360 /* wait for reply */
16366 api_one_ndp_entries_get (vat_main_t * vam)
16368 vl_api_one_ndp_entries_get_t *mp;
16369 unformat_input_t *input = vam->input;
16374 /* Parse args required to build the message */
16375 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16377 if (unformat (input, "bd %d", &bd))
16381 errmsg ("parse error '%U'", format_unformat_error, input);
16388 errmsg ("Expected bridge domain!");
16392 M (ONE_NDP_ENTRIES_GET, mp);
16393 mp->bd = clib_host_to_net_u32 (bd);
16398 /* wait for reply */
16404 api_one_l2_arp_bd_get (vat_main_t * vam)
16406 vl_api_one_l2_arp_bd_get_t *mp;
16409 M (ONE_L2_ARP_BD_GET, mp);
16414 /* wait for reply */
16420 api_one_l2_arp_entries_get (vat_main_t * vam)
16422 vl_api_one_l2_arp_entries_get_t *mp;
16423 unformat_input_t *input = vam->input;
16428 /* Parse args required to build the message */
16429 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16431 if (unformat (input, "bd %d", &bd))
16435 errmsg ("parse error '%U'", format_unformat_error, input);
16442 errmsg ("Expected bridge domain!");
16446 M (ONE_L2_ARP_ENTRIES_GET, mp);
16447 mp->bd = clib_host_to_net_u32 (bd);
16452 /* wait for reply */
16458 api_one_stats_enable_disable (vat_main_t * vam)
16460 vl_api_one_stats_enable_disable_t *mp;
16461 unformat_input_t *input = vam->input;
16466 /* Parse args required to build the message */
16467 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16469 if (unformat (input, "enable"))
16474 else if (unformat (input, "disable"))
16484 errmsg ("Value not set");
16488 M (ONE_STATS_ENABLE_DISABLE, mp);
16494 /* wait for reply */
16500 api_show_one_stats_enable_disable (vat_main_t * vam)
16502 vl_api_show_one_stats_enable_disable_t *mp;
16505 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
16510 /* wait for reply */
16516 api_show_one_map_request_mode (vat_main_t * vam)
16518 vl_api_show_one_map_request_mode_t *mp;
16521 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
16526 /* wait for reply */
16531 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
16534 api_one_map_request_mode (vat_main_t * vam)
16536 unformat_input_t *input = vam->input;
16537 vl_api_one_map_request_mode_t *mp;
16541 /* Parse args required to build the message */
16542 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16544 if (unformat (input, "dst-only"))
16546 else if (unformat (input, "src-dst"))
16550 errmsg ("parse error '%U'", format_unformat_error, input);
16555 M (ONE_MAP_REQUEST_MODE, mp);
16562 /* wait for reply */
16567 #define api_lisp_map_request_mode api_one_map_request_mode
16570 * Enable/disable ONE proxy ITR.
16572 * @param vam vpp API test context
16573 * @return return code
16576 api_one_pitr_set_locator_set (vat_main_t * vam)
16578 u8 ls_name_set = 0;
16579 unformat_input_t *input = vam->input;
16580 vl_api_one_pitr_set_locator_set_t *mp;
16585 /* Parse args required to build the message */
16586 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16588 if (unformat (input, "del"))
16590 else if (unformat (input, "locator-set %s", &ls_name))
16594 errmsg ("parse error '%U'", format_unformat_error, input);
16601 errmsg ("locator-set name not set!");
16605 M (ONE_PITR_SET_LOCATOR_SET, mp);
16607 mp->is_add = is_add;
16608 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16609 vec_free (ls_name);
16614 /* wait for reply */
16619 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
16622 api_one_nsh_set_locator_set (vat_main_t * vam)
16624 u8 ls_name_set = 0;
16625 unformat_input_t *input = vam->input;
16626 vl_api_one_nsh_set_locator_set_t *mp;
16631 /* Parse args required to build the message */
16632 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16634 if (unformat (input, "del"))
16636 else if (unformat (input, "ls %s", &ls_name))
16640 errmsg ("parse error '%U'", format_unformat_error, input);
16645 if (!ls_name_set && is_add)
16647 errmsg ("locator-set name not set!");
16651 M (ONE_NSH_SET_LOCATOR_SET, mp);
16653 mp->is_add = is_add;
16654 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16655 vec_free (ls_name);
16660 /* wait for reply */
16666 api_show_one_pitr (vat_main_t * vam)
16668 vl_api_show_one_pitr_t *mp;
16671 if (!vam->json_output)
16673 print (vam->ofp, "%=20s", "lisp status:");
16676 M (SHOW_ONE_PITR, mp);
16680 /* Wait for a reply... */
16685 #define api_show_lisp_pitr api_show_one_pitr
16688 api_one_use_petr (vat_main_t * vam)
16690 unformat_input_t *input = vam->input;
16691 vl_api_one_use_petr_t *mp;
16696 clib_memset (&ip, 0, sizeof (ip));
16698 /* Parse args required to build the message */
16699 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16701 if (unformat (input, "disable"))
16704 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
16707 ip_addr_version (&ip) = IP4;
16710 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
16713 ip_addr_version (&ip) = IP6;
16717 errmsg ("parse error '%U'", format_unformat_error, input);
16722 M (ONE_USE_PETR, mp);
16724 mp->is_add = is_add;
16727 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
16729 clib_memcpy (mp->address, &ip, 4);
16731 clib_memcpy (mp->address, &ip, 16);
16737 /* wait for reply */
16742 #define api_lisp_use_petr api_one_use_petr
16745 api_show_one_nsh_mapping (vat_main_t * vam)
16747 vl_api_show_one_use_petr_t *mp;
16750 if (!vam->json_output)
16752 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
16755 M (SHOW_ONE_NSH_MAPPING, mp);
16759 /* Wait for a reply... */
16765 api_show_one_use_petr (vat_main_t * vam)
16767 vl_api_show_one_use_petr_t *mp;
16770 if (!vam->json_output)
16772 print (vam->ofp, "%=20s", "Proxy-ETR status:");
16775 M (SHOW_ONE_USE_PETR, mp);
16779 /* Wait for a reply... */
16784 #define api_show_lisp_use_petr api_show_one_use_petr
16787 * Add/delete mapping between vni and vrf
16790 api_one_eid_table_add_del_map (vat_main_t * vam)
16792 unformat_input_t *input = vam->input;
16793 vl_api_one_eid_table_add_del_map_t *mp;
16794 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
16795 u32 vni, vrf, bd_index;
16798 /* Parse args required to build the message */
16799 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16801 if (unformat (input, "del"))
16803 else if (unformat (input, "vrf %d", &vrf))
16805 else if (unformat (input, "bd_index %d", &bd_index))
16807 else if (unformat (input, "vni %d", &vni))
16813 if (!vni_set || (!vrf_set && !bd_index_set))
16815 errmsg ("missing arguments!");
16819 if (vrf_set && bd_index_set)
16821 errmsg ("error: both vrf and bd entered!");
16825 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
16827 mp->is_add = is_add;
16828 mp->vni = htonl (vni);
16829 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
16830 mp->is_l2 = bd_index_set;
16835 /* wait for reply */
16840 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
16843 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
16845 u32 *action = va_arg (*args, u32 *);
16848 if (unformat (input, "%s", &s))
16850 if (!strcmp ((char *) s, "no-action"))
16852 else if (!strcmp ((char *) s, "natively-forward"))
16854 else if (!strcmp ((char *) s, "send-map-request"))
16856 else if (!strcmp ((char *) s, "drop"))
16860 clib_warning ("invalid action: '%s'", s);
16872 * Add/del remote mapping to/from ONE control plane
16874 * @param vam vpp API test context
16875 * @return return code
16878 api_one_add_del_remote_mapping (vat_main_t * vam)
16880 unformat_input_t *input = vam->input;
16881 vl_api_one_add_del_remote_mapping_t *mp;
16883 lisp_eid_vat_t _eid, *eid = &_eid;
16884 lisp_eid_vat_t _seid, *seid = &_seid;
16885 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
16886 u32 action = ~0, p, w, data_len;
16887 ip4_address_t rloc4;
16888 ip6_address_t rloc6;
16889 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
16892 clib_memset (&rloc, 0, sizeof (rloc));
16894 /* Parse args required to build the message */
16895 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16897 if (unformat (input, "del-all"))
16901 else if (unformat (input, "del"))
16905 else if (unformat (input, "add"))
16909 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
16913 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
16917 else if (unformat (input, "vni %d", &vni))
16921 else if (unformat (input, "p %d w %d", &p, &w))
16925 errmsg ("No RLOC configured for setting priority/weight!");
16928 curr_rloc->priority = p;
16929 curr_rloc->weight = w;
16931 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
16934 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
16935 vec_add1 (rlocs, rloc);
16936 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16938 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
16941 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
16942 vec_add1 (rlocs, rloc);
16943 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16945 else if (unformat (input, "action %U",
16946 unformat_negative_mapping_action, &action))
16952 clib_warning ("parse error '%U'", format_unformat_error, input);
16959 errmsg ("missing params!");
16963 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
16965 errmsg ("no action set for negative map-reply!");
16969 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
16971 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
16972 mp->is_add = is_add;
16973 mp->vni = htonl (vni);
16974 mp->action = (u8) action;
16975 mp->is_src_dst = seid_set;
16976 mp->eid_len = eid->len;
16977 mp->seid_len = seid->len;
16978 mp->del_all = del_all;
16979 mp->eid_type = eid->type;
16980 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
16981 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
16983 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
16984 clib_memcpy (mp->rlocs, rlocs, data_len);
16990 /* Wait for a reply... */
16995 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
16998 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
16999 * forwarding entries in data-plane accordingly.
17001 * @param vam vpp API test context
17002 * @return return code
17005 api_one_add_del_adjacency (vat_main_t * vam)
17007 unformat_input_t *input = vam->input;
17008 vl_api_one_add_del_adjacency_t *mp;
17010 ip4_address_t leid4, reid4;
17011 ip6_address_t leid6, reid6;
17012 u8 reid_mac[6] = { 0 };
17013 u8 leid_mac[6] = { 0 };
17014 u8 reid_type, leid_type;
17015 u32 leid_len = 0, reid_len = 0, len;
17019 leid_type = reid_type = (u8) ~ 0;
17021 /* Parse args required to build the message */
17022 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17024 if (unformat (input, "del"))
17028 else if (unformat (input, "add"))
17032 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
17035 reid_type = 0; /* ipv4 */
17038 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
17041 reid_type = 1; /* ipv6 */
17044 else if (unformat (input, "reid %U", unformat_ethernet_address,
17047 reid_type = 2; /* mac */
17049 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
17052 leid_type = 0; /* ipv4 */
17055 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
17058 leid_type = 1; /* ipv6 */
17061 else if (unformat (input, "leid %U", unformat_ethernet_address,
17064 leid_type = 2; /* mac */
17066 else if (unformat (input, "vni %d", &vni))
17072 errmsg ("parse error '%U'", format_unformat_error, input);
17077 if ((u8) ~ 0 == reid_type)
17079 errmsg ("missing params!");
17083 if (leid_type != reid_type)
17085 errmsg ("remote and local EIDs are of different types!");
17089 M (ONE_ADD_DEL_ADJACENCY, mp);
17090 mp->is_add = is_add;
17091 mp->vni = htonl (vni);
17092 mp->leid_len = leid_len;
17093 mp->reid_len = reid_len;
17094 mp->eid_type = reid_type;
17096 switch (mp->eid_type)
17099 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
17100 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
17103 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
17104 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
17107 clib_memcpy (mp->leid, leid_mac, 6);
17108 clib_memcpy (mp->reid, reid_mac, 6);
17111 errmsg ("unknown EID type %d!", mp->eid_type);
17118 /* Wait for a reply... */
17123 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
17126 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
17128 u32 *mode = va_arg (*args, u32 *);
17130 if (unformat (input, "lisp"))
17132 else if (unformat (input, "vxlan"))
17141 api_gpe_get_encap_mode (vat_main_t * vam)
17143 vl_api_gpe_get_encap_mode_t *mp;
17146 /* Construct the API message */
17147 M (GPE_GET_ENCAP_MODE, mp);
17152 /* Wait for a reply... */
17158 api_gpe_set_encap_mode (vat_main_t * vam)
17160 unformat_input_t *input = vam->input;
17161 vl_api_gpe_set_encap_mode_t *mp;
17165 /* Parse args required to build the message */
17166 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17168 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
17174 /* Construct the API message */
17175 M (GPE_SET_ENCAP_MODE, mp);
17182 /* Wait for a reply... */
17188 api_lisp_gpe_add_del_iface (vat_main_t * vam)
17190 unformat_input_t *input = vam->input;
17191 vl_api_gpe_add_del_iface_t *mp;
17192 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
17193 u32 dp_table = 0, vni = 0;
17196 /* Parse args required to build the message */
17197 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17199 if (unformat (input, "up"))
17204 else if (unformat (input, "down"))
17209 else if (unformat (input, "table_id %d", &dp_table))
17213 else if (unformat (input, "bd_id %d", &dp_table))
17218 else if (unformat (input, "vni %d", &vni))
17226 if (action_set == 0)
17228 errmsg ("Action not set");
17231 if (dp_table_set == 0 || vni_set == 0)
17233 errmsg ("vni and dp_table must be set");
17237 /* Construct the API message */
17238 M (GPE_ADD_DEL_IFACE, mp);
17240 mp->is_add = is_add;
17241 mp->dp_table = clib_host_to_net_u32 (dp_table);
17243 mp->vni = clib_host_to_net_u32 (vni);
17248 /* Wait for a reply... */
17254 api_one_map_register_fallback_threshold (vat_main_t * vam)
17256 unformat_input_t *input = vam->input;
17257 vl_api_one_map_register_fallback_threshold_t *mp;
17262 /* Parse args required to build the message */
17263 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17265 if (unformat (input, "%u", &value))
17269 clib_warning ("parse error '%U'", format_unformat_error, input);
17276 errmsg ("fallback threshold value is missing!");
17280 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17281 mp->value = clib_host_to_net_u32 (value);
17286 /* Wait for a reply... */
17292 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
17294 vl_api_show_one_map_register_fallback_threshold_t *mp;
17297 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17302 /* Wait for a reply... */
17308 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
17310 u32 *proto = va_arg (*args, u32 *);
17312 if (unformat (input, "udp"))
17314 else if (unformat (input, "api"))
17323 api_one_set_transport_protocol (vat_main_t * vam)
17325 unformat_input_t *input = vam->input;
17326 vl_api_one_set_transport_protocol_t *mp;
17331 /* Parse args required to build the message */
17332 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17334 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
17338 clib_warning ("parse error '%U'", format_unformat_error, input);
17345 errmsg ("Transport protocol missing!");
17349 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
17350 mp->protocol = (u8) protocol;
17355 /* Wait for a reply... */
17361 api_one_get_transport_protocol (vat_main_t * vam)
17363 vl_api_one_get_transport_protocol_t *mp;
17366 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
17371 /* Wait for a reply... */
17377 api_one_map_register_set_ttl (vat_main_t * vam)
17379 unformat_input_t *input = vam->input;
17380 vl_api_one_map_register_set_ttl_t *mp;
17385 /* Parse args required to build the message */
17386 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17388 if (unformat (input, "%u", &ttl))
17392 clib_warning ("parse error '%U'", format_unformat_error, input);
17399 errmsg ("TTL value missing!");
17403 M (ONE_MAP_REGISTER_SET_TTL, mp);
17404 mp->ttl = clib_host_to_net_u32 (ttl);
17409 /* Wait for a reply... */
17415 api_show_one_map_register_ttl (vat_main_t * vam)
17417 vl_api_show_one_map_register_ttl_t *mp;
17420 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
17425 /* Wait for a reply... */
17431 * Add/del map request itr rlocs from ONE control plane and updates
17433 * @param vam vpp API test context
17434 * @return return code
17437 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
17439 unformat_input_t *input = vam->input;
17440 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
17441 u8 *locator_set_name = 0;
17442 u8 locator_set_name_set = 0;
17446 /* Parse args required to build the message */
17447 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17449 if (unformat (input, "del"))
17453 else if (unformat (input, "%_%v%_", &locator_set_name))
17455 locator_set_name_set = 1;
17459 clib_warning ("parse error '%U'", format_unformat_error, input);
17464 if (is_add && !locator_set_name_set)
17466 errmsg ("itr-rloc is not set!");
17470 if (is_add && vec_len (locator_set_name) > 64)
17472 errmsg ("itr-rloc locator-set name too long");
17473 vec_free (locator_set_name);
17477 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
17478 mp->is_add = is_add;
17481 clib_memcpy (mp->locator_set_name, locator_set_name,
17482 vec_len (locator_set_name));
17486 clib_memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
17488 vec_free (locator_set_name);
17493 /* Wait for a reply... */
17498 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
17501 api_one_locator_dump (vat_main_t * vam)
17503 unformat_input_t *input = vam->input;
17504 vl_api_one_locator_dump_t *mp;
17505 vl_api_control_ping_t *mp_ping;
17506 u8 is_index_set = 0, is_name_set = 0;
17511 /* Parse args required to build the message */
17512 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17514 if (unformat (input, "ls_name %_%v%_", &ls_name))
17518 else if (unformat (input, "ls_index %d", &ls_index))
17524 errmsg ("parse error '%U'", format_unformat_error, input);
17529 if (!is_index_set && !is_name_set)
17531 errmsg ("error: expected one of index or name!");
17535 if (is_index_set && is_name_set)
17537 errmsg ("error: only one param expected!");
17541 if (vec_len (ls_name) > 62)
17543 errmsg ("error: locator set name too long!");
17547 if (!vam->json_output)
17549 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
17552 M (ONE_LOCATOR_DUMP, mp);
17553 mp->is_index_set = is_index_set;
17556 mp->ls_index = clib_host_to_net_u32 (ls_index);
17559 vec_add1 (ls_name, 0);
17560 strncpy ((char *) mp->ls_name, (char *) ls_name,
17561 sizeof (mp->ls_name) - 1);
17567 /* Use a control ping for synchronization */
17568 MPING (CONTROL_PING, mp_ping);
17571 /* Wait for a reply... */
17576 #define api_lisp_locator_dump api_one_locator_dump
17579 api_one_locator_set_dump (vat_main_t * vam)
17581 vl_api_one_locator_set_dump_t *mp;
17582 vl_api_control_ping_t *mp_ping;
17583 unformat_input_t *input = vam->input;
17587 /* Parse args required to build the message */
17588 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17590 if (unformat (input, "local"))
17594 else if (unformat (input, "remote"))
17600 errmsg ("parse error '%U'", format_unformat_error, input);
17605 if (!vam->json_output)
17607 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
17610 M (ONE_LOCATOR_SET_DUMP, mp);
17612 mp->filter = filter;
17617 /* Use a control ping for synchronization */
17618 MPING (CONTROL_PING, mp_ping);
17621 /* Wait for a reply... */
17626 #define api_lisp_locator_set_dump api_one_locator_set_dump
17629 api_one_eid_table_map_dump (vat_main_t * vam)
17633 unformat_input_t *input = vam->input;
17634 vl_api_one_eid_table_map_dump_t *mp;
17635 vl_api_control_ping_t *mp_ping;
17638 /* Parse args required to build the message */
17639 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17641 if (unformat (input, "l2"))
17646 else if (unformat (input, "l3"))
17653 errmsg ("parse error '%U'", format_unformat_error, input);
17660 errmsg ("expected one of 'l2' or 'l3' parameter!");
17664 if (!vam->json_output)
17666 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
17669 M (ONE_EID_TABLE_MAP_DUMP, mp);
17675 /* Use a control ping for synchronization */
17676 MPING (CONTROL_PING, mp_ping);
17679 /* Wait for a reply... */
17684 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
17687 api_one_eid_table_vni_dump (vat_main_t * vam)
17689 vl_api_one_eid_table_vni_dump_t *mp;
17690 vl_api_control_ping_t *mp_ping;
17693 if (!vam->json_output)
17695 print (vam->ofp, "VNI");
17698 M (ONE_EID_TABLE_VNI_DUMP, mp);
17703 /* Use a control ping for synchronization */
17704 MPING (CONTROL_PING, mp_ping);
17707 /* Wait for a reply... */
17712 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
17715 api_one_eid_table_dump (vat_main_t * vam)
17717 unformat_input_t *i = vam->input;
17718 vl_api_one_eid_table_dump_t *mp;
17719 vl_api_control_ping_t *mp_ping;
17720 struct in_addr ip4;
17721 struct in6_addr ip6;
17723 u8 eid_type = ~0, eid_set = 0;
17724 u32 prefix_length = ~0, t, vni = 0;
17727 lisp_nsh_api_t nsh;
17729 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17731 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
17737 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
17743 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
17748 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
17753 else if (unformat (i, "vni %d", &t))
17757 else if (unformat (i, "local"))
17761 else if (unformat (i, "remote"))
17767 errmsg ("parse error '%U'", format_unformat_error, i);
17772 if (!vam->json_output)
17774 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
17775 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
17778 M (ONE_EID_TABLE_DUMP, mp);
17780 mp->filter = filter;
17784 mp->vni = htonl (vni);
17785 mp->eid_type = eid_type;
17789 mp->prefix_length = prefix_length;
17790 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
17793 mp->prefix_length = prefix_length;
17794 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
17797 clib_memcpy (mp->eid, mac, sizeof (mac));
17800 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
17803 errmsg ("unknown EID type %d!", eid_type);
17811 /* Use a control ping for synchronization */
17812 MPING (CONTROL_PING, mp_ping);
17815 /* Wait for a reply... */
17820 #define api_lisp_eid_table_dump api_one_eid_table_dump
17823 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
17825 unformat_input_t *i = vam->input;
17826 vl_api_gpe_fwd_entries_get_t *mp;
17831 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17833 if (unformat (i, "vni %d", &vni))
17839 errmsg ("parse error '%U'", format_unformat_error, i);
17846 errmsg ("vni not set!");
17850 if (!vam->json_output)
17852 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
17856 M (GPE_FWD_ENTRIES_GET, mp);
17857 mp->vni = clib_host_to_net_u32 (vni);
17862 /* Wait for a reply... */
17867 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
17868 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
17869 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
17870 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
17871 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
17872 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
17873 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
17874 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
17877 api_one_adjacencies_get (vat_main_t * vam)
17879 unformat_input_t *i = vam->input;
17880 vl_api_one_adjacencies_get_t *mp;
17885 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17887 if (unformat (i, "vni %d", &vni))
17893 errmsg ("parse error '%U'", format_unformat_error, i);
17900 errmsg ("vni not set!");
17904 if (!vam->json_output)
17906 print (vam->ofp, "%s %40s", "leid", "reid");
17909 M (ONE_ADJACENCIES_GET, mp);
17910 mp->vni = clib_host_to_net_u32 (vni);
17915 /* Wait for a reply... */
17920 #define api_lisp_adjacencies_get api_one_adjacencies_get
17923 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
17925 unformat_input_t *i = vam->input;
17926 vl_api_gpe_native_fwd_rpaths_get_t *mp;
17928 u8 ip_family_set = 0, is_ip4 = 1;
17930 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17932 if (unformat (i, "ip4"))
17937 else if (unformat (i, "ip6"))
17944 errmsg ("parse error '%U'", format_unformat_error, i);
17949 if (!ip_family_set)
17951 errmsg ("ip family not set!");
17955 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
17956 mp->is_ip4 = is_ip4;
17961 /* Wait for a reply... */
17967 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
17969 vl_api_gpe_fwd_entry_vnis_get_t *mp;
17972 if (!vam->json_output)
17974 print (vam->ofp, "VNIs");
17977 M (GPE_FWD_ENTRY_VNIS_GET, mp);
17982 /* Wait for a reply... */
17988 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
17990 unformat_input_t *i = vam->input;
17991 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
17993 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
17994 struct in_addr ip4;
17995 struct in6_addr ip6;
17996 u32 table_id = 0, nh_sw_if_index = ~0;
17998 clib_memset (&ip4, 0, sizeof (ip4));
17999 clib_memset (&ip6, 0, sizeof (ip6));
18001 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18003 if (unformat (i, "del"))
18005 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
18006 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18011 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
18012 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18017 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
18021 nh_sw_if_index = ~0;
18023 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
18027 nh_sw_if_index = ~0;
18029 else if (unformat (i, "table %d", &table_id))
18033 errmsg ("parse error '%U'", format_unformat_error, i);
18040 errmsg ("nh addr not set!");
18044 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
18045 mp->is_add = is_add;
18046 mp->table_id = clib_host_to_net_u32 (table_id);
18047 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
18048 mp->is_ip4 = is_ip4;
18050 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
18052 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
18057 /* Wait for a reply... */
18063 api_one_map_server_dump (vat_main_t * vam)
18065 vl_api_one_map_server_dump_t *mp;
18066 vl_api_control_ping_t *mp_ping;
18069 if (!vam->json_output)
18071 print (vam->ofp, "%=20s", "Map server");
18074 M (ONE_MAP_SERVER_DUMP, mp);
18078 /* Use a control ping for synchronization */
18079 MPING (CONTROL_PING, mp_ping);
18082 /* Wait for a reply... */
18087 #define api_lisp_map_server_dump api_one_map_server_dump
18090 api_one_map_resolver_dump (vat_main_t * vam)
18092 vl_api_one_map_resolver_dump_t *mp;
18093 vl_api_control_ping_t *mp_ping;
18096 if (!vam->json_output)
18098 print (vam->ofp, "%=20s", "Map resolver");
18101 M (ONE_MAP_RESOLVER_DUMP, mp);
18105 /* Use a control ping for synchronization */
18106 MPING (CONTROL_PING, mp_ping);
18109 /* Wait for a reply... */
18114 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
18117 api_one_stats_flush (vat_main_t * vam)
18119 vl_api_one_stats_flush_t *mp;
18122 M (ONE_STATS_FLUSH, mp);
18129 api_one_stats_dump (vat_main_t * vam)
18131 vl_api_one_stats_dump_t *mp;
18132 vl_api_control_ping_t *mp_ping;
18135 M (ONE_STATS_DUMP, mp);
18139 /* Use a control ping for synchronization */
18140 MPING (CONTROL_PING, mp_ping);
18143 /* Wait for a reply... */
18149 api_show_one_status (vat_main_t * vam)
18151 vl_api_show_one_status_t *mp;
18154 if (!vam->json_output)
18156 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
18159 M (SHOW_ONE_STATUS, mp);
18162 /* Wait for a reply... */
18167 #define api_show_lisp_status api_show_one_status
18170 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
18172 vl_api_gpe_fwd_entry_path_dump_t *mp;
18173 vl_api_control_ping_t *mp_ping;
18174 unformat_input_t *i = vam->input;
18175 u32 fwd_entry_index = ~0;
18178 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18180 if (unformat (i, "index %d", &fwd_entry_index))
18186 if (~0 == fwd_entry_index)
18188 errmsg ("no index specified!");
18192 if (!vam->json_output)
18194 print (vam->ofp, "first line");
18197 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
18201 /* Use a control ping for synchronization */
18202 MPING (CONTROL_PING, mp_ping);
18205 /* Wait for a reply... */
18211 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
18213 vl_api_one_get_map_request_itr_rlocs_t *mp;
18216 if (!vam->json_output)
18218 print (vam->ofp, "%=20s", "itr-rlocs:");
18221 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
18224 /* Wait for a reply... */
18229 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
18232 api_af_packet_create (vat_main_t * vam)
18234 unformat_input_t *i = vam->input;
18235 vl_api_af_packet_create_t *mp;
18236 u8 *host_if_name = 0;
18238 u8 random_hw_addr = 1;
18241 clib_memset (hw_addr, 0, sizeof (hw_addr));
18243 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18245 if (unformat (i, "name %s", &host_if_name))
18246 vec_add1 (host_if_name, 0);
18247 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18248 random_hw_addr = 0;
18253 if (!vec_len (host_if_name))
18255 errmsg ("host-interface name must be specified");
18259 if (vec_len (host_if_name) > 64)
18261 errmsg ("host-interface name too long");
18265 M (AF_PACKET_CREATE, mp);
18267 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18268 clib_memcpy (mp->hw_addr, hw_addr, 6);
18269 mp->use_random_hw_addr = random_hw_addr;
18270 vec_free (host_if_name);
18278 fprintf (vam->ofp ? vam->ofp : stderr,
18279 " new sw_if_index = %d\n", vam->sw_if_index);
18286 api_af_packet_delete (vat_main_t * vam)
18288 unformat_input_t *i = vam->input;
18289 vl_api_af_packet_delete_t *mp;
18290 u8 *host_if_name = 0;
18293 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18295 if (unformat (i, "name %s", &host_if_name))
18296 vec_add1 (host_if_name, 0);
18301 if (!vec_len (host_if_name))
18303 errmsg ("host-interface name must be specified");
18307 if (vec_len (host_if_name) > 64)
18309 errmsg ("host-interface name too long");
18313 M (AF_PACKET_DELETE, mp);
18315 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18316 vec_free (host_if_name);
18323 static void vl_api_af_packet_details_t_handler
18324 (vl_api_af_packet_details_t * mp)
18326 vat_main_t *vam = &vat_main;
18328 print (vam->ofp, "%-16s %d",
18329 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
18332 static void vl_api_af_packet_details_t_handler_json
18333 (vl_api_af_packet_details_t * mp)
18335 vat_main_t *vam = &vat_main;
18336 vat_json_node_t *node = NULL;
18338 if (VAT_JSON_ARRAY != vam->json_tree.type)
18340 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18341 vat_json_init_array (&vam->json_tree);
18343 node = vat_json_array_add (&vam->json_tree);
18345 vat_json_init_object (node);
18346 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
18347 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
18351 api_af_packet_dump (vat_main_t * vam)
18353 vl_api_af_packet_dump_t *mp;
18354 vl_api_control_ping_t *mp_ping;
18357 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
18358 /* Get list of tap interfaces */
18359 M (AF_PACKET_DUMP, mp);
18362 /* Use a control ping for synchronization */
18363 MPING (CONTROL_PING, mp_ping);
18371 api_policer_add_del (vat_main_t * vam)
18373 unformat_input_t *i = vam->input;
18374 vl_api_policer_add_del_t *mp;
18384 u8 color_aware = 0;
18385 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
18388 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
18389 conform_action.dscp = 0;
18390 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
18391 exceed_action.dscp = 0;
18392 violate_action.action_type = SSE2_QOS_ACTION_DROP;
18393 violate_action.dscp = 0;
18395 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18397 if (unformat (i, "del"))
18399 else if (unformat (i, "name %s", &name))
18400 vec_add1 (name, 0);
18401 else if (unformat (i, "cir %u", &cir))
18403 else if (unformat (i, "eir %u", &eir))
18405 else if (unformat (i, "cb %u", &cb))
18407 else if (unformat (i, "eb %u", &eb))
18409 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
18412 else if (unformat (i, "round_type %U", unformat_policer_round_type,
18415 else if (unformat (i, "type %U", unformat_policer_type, &type))
18417 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
18420 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
18423 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
18426 else if (unformat (i, "color-aware"))
18432 if (!vec_len (name))
18434 errmsg ("policer name must be specified");
18438 if (vec_len (name) > 64)
18440 errmsg ("policer name too long");
18444 M (POLICER_ADD_DEL, mp);
18446 clib_memcpy (mp->name, name, vec_len (name));
18448 mp->is_add = is_add;
18449 mp->cir = ntohl (cir);
18450 mp->eir = ntohl (eir);
18451 mp->cb = clib_net_to_host_u64 (cb);
18452 mp->eb = clib_net_to_host_u64 (eb);
18453 mp->rate_type = rate_type;
18454 mp->round_type = round_type;
18456 mp->conform_action_type = conform_action.action_type;
18457 mp->conform_dscp = conform_action.dscp;
18458 mp->exceed_action_type = exceed_action.action_type;
18459 mp->exceed_dscp = exceed_action.dscp;
18460 mp->violate_action_type = violate_action.action_type;
18461 mp->violate_dscp = violate_action.dscp;
18462 mp->color_aware = color_aware;
18470 api_policer_dump (vat_main_t * vam)
18472 unformat_input_t *i = vam->input;
18473 vl_api_policer_dump_t *mp;
18474 vl_api_control_ping_t *mp_ping;
18475 u8 *match_name = 0;
18476 u8 match_name_valid = 0;
18479 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18481 if (unformat (i, "name %s", &match_name))
18483 vec_add1 (match_name, 0);
18484 match_name_valid = 1;
18490 M (POLICER_DUMP, mp);
18491 mp->match_name_valid = match_name_valid;
18492 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
18493 vec_free (match_name);
18497 /* Use a control ping for synchronization */
18498 MPING (CONTROL_PING, mp_ping);
18501 /* Wait for a reply... */
18507 api_policer_classify_set_interface (vat_main_t * vam)
18509 unformat_input_t *i = vam->input;
18510 vl_api_policer_classify_set_interface_t *mp;
18512 int sw_if_index_set;
18513 u32 ip4_table_index = ~0;
18514 u32 ip6_table_index = ~0;
18515 u32 l2_table_index = ~0;
18519 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18521 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18522 sw_if_index_set = 1;
18523 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18524 sw_if_index_set = 1;
18525 else if (unformat (i, "del"))
18527 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18529 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18531 else if (unformat (i, "l2-table %d", &l2_table_index))
18535 clib_warning ("parse error '%U'", format_unformat_error, i);
18540 if (sw_if_index_set == 0)
18542 errmsg ("missing interface name or sw_if_index");
18546 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
18548 mp->sw_if_index = ntohl (sw_if_index);
18549 mp->ip4_table_index = ntohl (ip4_table_index);
18550 mp->ip6_table_index = ntohl (ip6_table_index);
18551 mp->l2_table_index = ntohl (l2_table_index);
18552 mp->is_add = is_add;
18560 api_policer_classify_dump (vat_main_t * vam)
18562 unformat_input_t *i = vam->input;
18563 vl_api_policer_classify_dump_t *mp;
18564 vl_api_control_ping_t *mp_ping;
18565 u8 type = POLICER_CLASSIFY_N_TABLES;
18568 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
18572 errmsg ("classify table type must be specified");
18576 if (!vam->json_output)
18578 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
18581 M (POLICER_CLASSIFY_DUMP, mp);
18586 /* Use a control ping for synchronization */
18587 MPING (CONTROL_PING, mp_ping);
18590 /* Wait for a reply... */
18596 api_netmap_create (vat_main_t * vam)
18598 unformat_input_t *i = vam->input;
18599 vl_api_netmap_create_t *mp;
18602 u8 random_hw_addr = 1;
18607 clib_memset (hw_addr, 0, sizeof (hw_addr));
18609 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18611 if (unformat (i, "name %s", &if_name))
18612 vec_add1 (if_name, 0);
18613 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18614 random_hw_addr = 0;
18615 else if (unformat (i, "pipe"))
18617 else if (unformat (i, "master"))
18619 else if (unformat (i, "slave"))
18625 if (!vec_len (if_name))
18627 errmsg ("interface name must be specified");
18631 if (vec_len (if_name) > 64)
18633 errmsg ("interface name too long");
18637 M (NETMAP_CREATE, mp);
18639 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18640 clib_memcpy (mp->hw_addr, hw_addr, 6);
18641 mp->use_random_hw_addr = random_hw_addr;
18642 mp->is_pipe = is_pipe;
18643 mp->is_master = is_master;
18644 vec_free (if_name);
18652 api_netmap_delete (vat_main_t * vam)
18654 unformat_input_t *i = vam->input;
18655 vl_api_netmap_delete_t *mp;
18659 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18661 if (unformat (i, "name %s", &if_name))
18662 vec_add1 (if_name, 0);
18667 if (!vec_len (if_name))
18669 errmsg ("interface name must be specified");
18673 if (vec_len (if_name) > 64)
18675 errmsg ("interface name too long");
18679 M (NETMAP_DELETE, mp);
18681 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18682 vec_free (if_name);
18690 format_fib_api_path_nh_proto (u8 * s, va_list * args)
18692 vl_api_fib_path_nh_proto_t proto =
18693 va_arg (*args, vl_api_fib_path_nh_proto_t);
18697 case FIB_API_PATH_NH_PROTO_IP4:
18698 s = format (s, "ip4");
18700 case FIB_API_PATH_NH_PROTO_IP6:
18701 s = format (s, "ip6");
18703 case FIB_API_PATH_NH_PROTO_MPLS:
18704 s = format (s, "mpls");
18706 case FIB_API_PATH_NH_PROTO_BIER:
18707 s = format (s, "bier");
18709 case FIB_API_PATH_NH_PROTO_ETHERNET:
18710 s = format (s, "ethernet");
18718 format_vl_api_ip_address_union (u8 * s, va_list * args)
18720 vl_api_address_family_t af = va_arg (*args, vl_api_address_family_t);
18721 const vl_api_address_union_t *u = va_arg (*args, vl_api_address_union_t *);
18726 s = format (s, "%U", format_ip4_address, u->ip4);
18729 s = format (s, "%U", format_ip6_address, u->ip6);
18736 format_vl_api_fib_path_type (u8 * s, va_list * args)
18738 vl_api_fib_path_type_t t = va_arg (*args, vl_api_fib_path_type_t);
18742 case FIB_API_PATH_TYPE_NORMAL:
18743 s = format (s, "normal");
18745 case FIB_API_PATH_TYPE_LOCAL:
18746 s = format (s, "local");
18748 case FIB_API_PATH_TYPE_DROP:
18749 s = format (s, "drop");
18751 case FIB_API_PATH_TYPE_UDP_ENCAP:
18752 s = format (s, "udp-encap");
18754 case FIB_API_PATH_TYPE_BIER_IMP:
18755 s = format (s, "bier-imp");
18757 case FIB_API_PATH_TYPE_ICMP_UNREACH:
18758 s = format (s, "unreach");
18760 case FIB_API_PATH_TYPE_ICMP_PROHIBIT:
18761 s = format (s, "prohibit");
18763 case FIB_API_PATH_TYPE_SOURCE_LOOKUP:
18764 s = format (s, "src-lookup");
18766 case FIB_API_PATH_TYPE_DVR:
18767 s = format (s, "dvr");
18769 case FIB_API_PATH_TYPE_INTERFACE_RX:
18770 s = format (s, "interface-rx");
18772 case FIB_API_PATH_TYPE_CLASSIFY:
18773 s = format (s, "classify");
18781 vl_api_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
18784 " weight %d, sw_if_index %d, type %U, afi %U, next_hop %U",
18785 ntohl (fp->weight), ntohl (fp->sw_if_index),
18786 format_vl_api_fib_path_type, fp->type,
18787 format_fib_api_path_nh_proto, fp->proto,
18788 format_vl_api_ip_address_union, &fp->nh.address);
18792 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
18793 vl_api_fib_path_t * fp)
18795 struct in_addr ip4;
18796 struct in6_addr ip6;
18798 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
18799 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
18800 vat_json_object_add_uint (node, "type", fp->type);
18801 vat_json_object_add_uint (node, "next_hop_proto", fp->proto);
18802 if (fp->proto == FIB_API_PATH_NH_PROTO_IP4)
18804 clib_memcpy (&ip4, &fp->nh.address.ip4, sizeof (ip4));
18805 vat_json_object_add_ip4 (node, "next_hop", ip4);
18807 else if (fp->proto == FIB_API_PATH_NH_PROTO_IP4)
18809 clib_memcpy (&ip6, &fp->nh.address.ip6, sizeof (ip6));
18810 vat_json_object_add_ip6 (node, "next_hop", ip6);
18815 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
18817 vat_main_t *vam = &vat_main;
18818 int count = ntohl (mp->mt_tunnel.mt_n_paths);
18819 vl_api_fib_path_t *fp;
18822 print (vam->ofp, "sw_if_index %d via:",
18823 ntohl (mp->mt_tunnel.mt_sw_if_index));
18824 fp = mp->mt_tunnel.mt_paths;
18825 for (i = 0; i < count; i++)
18827 vl_api_fib_path_print (vam, fp);
18831 print (vam->ofp, "");
18834 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
18835 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
18838 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
18840 vat_main_t *vam = &vat_main;
18841 vat_json_node_t *node = NULL;
18842 int count = ntohl (mp->mt_tunnel.mt_n_paths);
18843 vl_api_fib_path_t *fp;
18846 if (VAT_JSON_ARRAY != vam->json_tree.type)
18848 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18849 vat_json_init_array (&vam->json_tree);
18851 node = vat_json_array_add (&vam->json_tree);
18853 vat_json_init_object (node);
18854 vat_json_object_add_uint (node, "sw_if_index",
18855 ntohl (mp->mt_tunnel.mt_sw_if_index));
18857 vat_json_object_add_uint (node, "l2_only", mp->mt_tunnel.mt_l2_only);
18859 fp = mp->mt_tunnel.mt_paths;
18860 for (i = 0; i < count; i++)
18862 vl_api_mpls_fib_path_json_print (node, fp);
18868 api_mpls_tunnel_dump (vat_main_t * vam)
18870 vl_api_mpls_tunnel_dump_t *mp;
18871 vl_api_control_ping_t *mp_ping;
18874 M (MPLS_TUNNEL_DUMP, mp);
18878 /* Use a control ping for synchronization */
18879 MPING (CONTROL_PING, mp_ping);
18886 #define vl_api_mpls_table_details_t_endian vl_noop_handler
18887 #define vl_api_mpls_table_details_t_print vl_noop_handler
18891 vl_api_mpls_table_details_t_handler (vl_api_mpls_table_details_t * mp)
18893 vat_main_t *vam = &vat_main;
18895 print (vam->ofp, "table-id %d,", ntohl (mp->mt_table.mt_table_id));
18898 static void vl_api_mpls_table_details_t_handler_json
18899 (vl_api_mpls_table_details_t * mp)
18901 vat_main_t *vam = &vat_main;
18902 vat_json_node_t *node = NULL;
18904 if (VAT_JSON_ARRAY != vam->json_tree.type)
18906 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18907 vat_json_init_array (&vam->json_tree);
18909 node = vat_json_array_add (&vam->json_tree);
18911 vat_json_init_object (node);
18912 vat_json_object_add_uint (node, "table", ntohl (mp->mt_table.mt_table_id));
18916 api_mpls_table_dump (vat_main_t * vam)
18918 vl_api_mpls_table_dump_t *mp;
18919 vl_api_control_ping_t *mp_ping;
18922 M (MPLS_TABLE_DUMP, mp);
18925 /* Use a control ping for synchronization */
18926 MPING (CONTROL_PING, mp_ping);
18933 #define vl_api_mpls_route_details_t_endian vl_noop_handler
18934 #define vl_api_mpls_route_details_t_print vl_noop_handler
18937 vl_api_mpls_route_details_t_handler (vl_api_mpls_route_details_t * mp)
18939 vat_main_t *vam = &vat_main;
18940 int count = (int) clib_net_to_host_u32 (mp->mr_route.mr_n_paths);
18941 vl_api_fib_path_t *fp;
18945 "table-id %d, label %u, ess_bit %u",
18946 ntohl (mp->mr_route.mr_table_id),
18947 ntohl (mp->mr_route.mr_label), mp->mr_route.mr_eos);
18948 fp = mp->mr_route.mr_paths;
18949 for (i = 0; i < count; i++)
18951 vl_api_fib_path_print (vam, fp);
18956 static void vl_api_mpls_route_details_t_handler_json
18957 (vl_api_mpls_route_details_t * mp)
18959 vat_main_t *vam = &vat_main;
18960 int count = (int) clib_host_to_net_u32 (mp->mr_route.mr_n_paths);
18961 vat_json_node_t *node = NULL;
18962 vl_api_fib_path_t *fp;
18965 if (VAT_JSON_ARRAY != vam->json_tree.type)
18967 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18968 vat_json_init_array (&vam->json_tree);
18970 node = vat_json_array_add (&vam->json_tree);
18972 vat_json_init_object (node);
18973 vat_json_object_add_uint (node, "table", ntohl (mp->mr_route.mr_table_id));
18974 vat_json_object_add_uint (node, "s_bit", mp->mr_route.mr_eos);
18975 vat_json_object_add_uint (node, "label", ntohl (mp->mr_route.mr_label));
18976 vat_json_object_add_uint (node, "path_count", count);
18977 fp = mp->mr_route.mr_paths;
18978 for (i = 0; i < count; i++)
18980 vl_api_mpls_fib_path_json_print (node, fp);
18986 api_mpls_route_dump (vat_main_t * vam)
18988 unformat_input_t *input = vam->input;
18989 vl_api_mpls_route_dump_t *mp;
18990 vl_api_control_ping_t *mp_ping;
18994 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18996 if (unformat (input, "table_id %d", &table_id))
19001 if (table_id == ~0)
19003 errmsg ("missing table id");
19007 M (MPLS_ROUTE_DUMP, mp);
19009 mp->table.mt_table_id = ntohl (table_id);
19012 /* Use a control ping for synchronization */
19013 MPING (CONTROL_PING, mp_ping);
19020 #define vl_api_ip_table_details_t_endian vl_noop_handler
19021 #define vl_api_ip_table_details_t_print vl_noop_handler
19024 vl_api_ip_table_details_t_handler (vl_api_ip_table_details_t * mp)
19026 vat_main_t *vam = &vat_main;
19029 "%s; table-id %d, prefix %U/%d",
19030 mp->table.name, ntohl (mp->table.table_id));
19034 static void vl_api_ip_table_details_t_handler_json
19035 (vl_api_ip_table_details_t * mp)
19037 vat_main_t *vam = &vat_main;
19038 vat_json_node_t *node = NULL;
19040 if (VAT_JSON_ARRAY != vam->json_tree.type)
19042 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19043 vat_json_init_array (&vam->json_tree);
19045 node = vat_json_array_add (&vam->json_tree);
19047 vat_json_init_object (node);
19048 vat_json_object_add_uint (node, "table", ntohl (mp->table.table_id));
19052 api_ip_table_dump (vat_main_t * vam)
19054 vl_api_ip_table_dump_t *mp;
19055 vl_api_control_ping_t *mp_ping;
19058 M (IP_TABLE_DUMP, mp);
19061 /* Use a control ping for synchronization */
19062 MPING (CONTROL_PING, mp_ping);
19070 api_ip_mtable_dump (vat_main_t * vam)
19072 vl_api_ip_mtable_dump_t *mp;
19073 vl_api_control_ping_t *mp_ping;
19076 M (IP_MTABLE_DUMP, mp);
19079 /* Use a control ping for synchronization */
19080 MPING (CONTROL_PING, mp_ping);
19088 api_ip_mroute_dump (vat_main_t * vam)
19090 unformat_input_t *input = vam->input;
19091 vl_api_control_ping_t *mp_ping;
19092 vl_api_ip_mroute_dump_t *mp;
19097 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19099 if (unformat (input, "table_id %d", &table_id))
19101 else if (unformat (input, "ip6"))
19103 else if (unformat (input, "ip4"))
19108 if (table_id == ~0)
19110 errmsg ("missing table id");
19114 M (IP_MROUTE_DUMP, mp);
19115 mp->table.table_id = table_id;
19116 mp->table.is_ip6 = is_ip6;
19119 /* Use a control ping for synchronization */
19120 MPING (CONTROL_PING, mp_ping);
19127 static void vl_api_ip_neighbor_details_t_handler
19128 (vl_api_ip_neighbor_details_t * mp)
19130 vat_main_t *vam = &vat_main;
19132 print (vam->ofp, "%c %U %U",
19133 (ntohl (mp->neighbor.flags) & IP_NEIGHBOR_FLAG_STATIC) ? 'S' : 'D',
19134 format_vl_api_mac_address, &mp->neighbor.mac_address,
19135 format_vl_api_address, &mp->neighbor.ip_address);
19138 static void vl_api_ip_neighbor_details_t_handler_json
19139 (vl_api_ip_neighbor_details_t * mp)
19142 vat_main_t *vam = &vat_main;
19143 vat_json_node_t *node;
19145 if (VAT_JSON_ARRAY != vam->json_tree.type)
19147 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19148 vat_json_init_array (&vam->json_tree);
19150 node = vat_json_array_add (&vam->json_tree);
19152 vat_json_init_object (node);
19153 vat_json_object_add_string_copy
19155 ((ntohl (mp->neighbor.flags) & IP_NEIGHBOR_FLAG_STATIC) ?
19156 (u8 *) "static" : (u8 *) "dynamic"));
19158 vat_json_object_add_string_copy (node, "link_layer",
19159 format (0, "%U", format_vl_api_mac_address,
19160 &mp->neighbor.mac_address));
19161 vat_json_object_add_address (node, "ip", &mp->neighbor.ip_address);
19165 api_ip_neighbor_dump (vat_main_t * vam)
19167 unformat_input_t *i = vam->input;
19168 vl_api_ip_neighbor_dump_t *mp;
19169 vl_api_control_ping_t *mp_ping;
19171 u32 sw_if_index = ~0;
19174 /* Parse args required to build the message */
19175 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19177 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19179 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19181 else if (unformat (i, "ip6"))
19187 if (sw_if_index == ~0)
19189 errmsg ("missing interface name or sw_if_index");
19193 M (IP_NEIGHBOR_DUMP, mp);
19194 mp->is_ipv6 = (u8) is_ipv6;
19195 mp->sw_if_index = ntohl (sw_if_index);
19198 /* Use a control ping for synchronization */
19199 MPING (CONTROL_PING, mp_ping);
19206 #define vl_api_ip_route_details_t_endian vl_noop_handler
19207 #define vl_api_ip_route_details_t_print vl_noop_handler
19210 vl_api_ip_route_details_t_handler (vl_api_ip_route_details_t * mp)
19212 vat_main_t *vam = &vat_main;
19213 u8 count = mp->route.n_paths;
19214 vl_api_fib_path_t *fp;
19218 "table-id %d, prefix %U/%d",
19219 ntohl (mp->route.table_id),
19220 format_ip46_address, mp->route.prefix.address, mp->route.prefix.len);
19221 for (i = 0; i < count; i++)
19223 fp = &mp->route.paths[i];
19225 vl_api_fib_path_print (vam, fp);
19230 static void vl_api_ip_route_details_t_handler_json
19231 (vl_api_ip_route_details_t * mp)
19233 vat_main_t *vam = &vat_main;
19234 u8 count = mp->route.n_paths;
19235 vat_json_node_t *node = NULL;
19236 struct in_addr ip4;
19237 struct in6_addr ip6;
19238 vl_api_fib_path_t *fp;
19241 if (VAT_JSON_ARRAY != vam->json_tree.type)
19243 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19244 vat_json_init_array (&vam->json_tree);
19246 node = vat_json_array_add (&vam->json_tree);
19248 vat_json_init_object (node);
19249 vat_json_object_add_uint (node, "table", ntohl (mp->route.table_id));
19250 if (ADDRESS_IP6 == mp->route.prefix.address.af)
19252 clib_memcpy (&ip6, &mp->route.prefix.address.un.ip6, sizeof (ip6));
19253 vat_json_object_add_ip6 (node, "prefix", ip6);
19257 clib_memcpy (&ip4, &mp->route.prefix.address.un.ip4, sizeof (ip4));
19258 vat_json_object_add_ip4 (node, "prefix", ip4);
19260 vat_json_object_add_uint (node, "mask_length", mp->route.prefix.len);
19261 vat_json_object_add_uint (node, "path_count", count);
19262 for (i = 0; i < count; i++)
19264 fp = &mp->route.paths[i];
19265 vl_api_mpls_fib_path_json_print (node, fp);
19270 api_ip_route_dump (vat_main_t * vam)
19272 unformat_input_t *input = vam->input;
19273 vl_api_ip_route_dump_t *mp;
19274 vl_api_control_ping_t *mp_ping;
19280 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19282 if (unformat (input, "table_id %d", &table_id))
19284 else if (unformat (input, "ip6"))
19286 else if (unformat (input, "ip4"))
19291 if (table_id == ~0)
19293 errmsg ("missing table id");
19297 M (IP_ROUTE_DUMP, mp);
19299 mp->table.table_id = table_id;
19300 mp->table.is_ip6 = is_ip6;
19304 /* Use a control ping for synchronization */
19305 MPING (CONTROL_PING, mp_ping);
19313 api_classify_table_ids (vat_main_t * vam)
19315 vl_api_classify_table_ids_t *mp;
19318 /* Construct the API message */
19319 M (CLASSIFY_TABLE_IDS, mp);
19328 api_classify_table_by_interface (vat_main_t * vam)
19330 unformat_input_t *input = vam->input;
19331 vl_api_classify_table_by_interface_t *mp;
19333 u32 sw_if_index = ~0;
19335 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19337 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19339 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19344 if (sw_if_index == ~0)
19346 errmsg ("missing interface name or sw_if_index");
19350 /* Construct the API message */
19351 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
19353 mp->sw_if_index = ntohl (sw_if_index);
19361 api_classify_table_info (vat_main_t * vam)
19363 unformat_input_t *input = vam->input;
19364 vl_api_classify_table_info_t *mp;
19368 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19370 if (unformat (input, "table_id %d", &table_id))
19375 if (table_id == ~0)
19377 errmsg ("missing table id");
19381 /* Construct the API message */
19382 M (CLASSIFY_TABLE_INFO, mp);
19384 mp->table_id = ntohl (table_id);
19392 api_classify_session_dump (vat_main_t * vam)
19394 unformat_input_t *input = vam->input;
19395 vl_api_classify_session_dump_t *mp;
19396 vl_api_control_ping_t *mp_ping;
19400 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19402 if (unformat (input, "table_id %d", &table_id))
19407 if (table_id == ~0)
19409 errmsg ("missing table id");
19413 /* Construct the API message */
19414 M (CLASSIFY_SESSION_DUMP, mp);
19416 mp->table_id = ntohl (table_id);
19419 /* Use a control ping for synchronization */
19420 MPING (CONTROL_PING, mp_ping);
19428 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
19430 vat_main_t *vam = &vat_main;
19432 print (vam->ofp, "collector_address %U, collector_port %d, "
19433 "src_address %U, vrf_id %d, path_mtu %u, "
19434 "template_interval %u, udp_checksum %d",
19435 format_ip4_address, mp->collector_address,
19436 ntohs (mp->collector_port),
19437 format_ip4_address, mp->src_address,
19438 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
19439 ntohl (mp->template_interval), mp->udp_checksum);
19442 vam->result_ready = 1;
19446 vl_api_ipfix_exporter_details_t_handler_json
19447 (vl_api_ipfix_exporter_details_t * mp)
19449 vat_main_t *vam = &vat_main;
19450 vat_json_node_t node;
19451 struct in_addr collector_address;
19452 struct in_addr src_address;
19454 vat_json_init_object (&node);
19455 clib_memcpy (&collector_address, &mp->collector_address,
19456 sizeof (collector_address));
19457 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
19458 vat_json_object_add_uint (&node, "collector_port",
19459 ntohs (mp->collector_port));
19460 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
19461 vat_json_object_add_ip4 (&node, "src_address", src_address);
19462 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
19463 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
19464 vat_json_object_add_uint (&node, "template_interval",
19465 ntohl (mp->template_interval));
19466 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
19468 vat_json_print (vam->ofp, &node);
19469 vat_json_free (&node);
19471 vam->result_ready = 1;
19475 api_ipfix_exporter_dump (vat_main_t * vam)
19477 vl_api_ipfix_exporter_dump_t *mp;
19480 /* Construct the API message */
19481 M (IPFIX_EXPORTER_DUMP, mp);
19490 api_ipfix_classify_stream_dump (vat_main_t * vam)
19492 vl_api_ipfix_classify_stream_dump_t *mp;
19495 /* Construct the API message */
19496 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
19507 vl_api_ipfix_classify_stream_details_t_handler
19508 (vl_api_ipfix_classify_stream_details_t * mp)
19510 vat_main_t *vam = &vat_main;
19511 print (vam->ofp, "domain_id %d, src_port %d",
19512 ntohl (mp->domain_id), ntohs (mp->src_port));
19514 vam->result_ready = 1;
19518 vl_api_ipfix_classify_stream_details_t_handler_json
19519 (vl_api_ipfix_classify_stream_details_t * mp)
19521 vat_main_t *vam = &vat_main;
19522 vat_json_node_t node;
19524 vat_json_init_object (&node);
19525 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
19526 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
19528 vat_json_print (vam->ofp, &node);
19529 vat_json_free (&node);
19531 vam->result_ready = 1;
19535 api_ipfix_classify_table_dump (vat_main_t * vam)
19537 vl_api_ipfix_classify_table_dump_t *mp;
19538 vl_api_control_ping_t *mp_ping;
19541 if (!vam->json_output)
19543 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
19544 "transport_protocol");
19547 /* Construct the API message */
19548 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
19553 /* Use a control ping for synchronization */
19554 MPING (CONTROL_PING, mp_ping);
19562 vl_api_ipfix_classify_table_details_t_handler
19563 (vl_api_ipfix_classify_table_details_t * mp)
19565 vat_main_t *vam = &vat_main;
19566 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
19567 mp->transport_protocol);
19571 vl_api_ipfix_classify_table_details_t_handler_json
19572 (vl_api_ipfix_classify_table_details_t * mp)
19574 vat_json_node_t *node = NULL;
19575 vat_main_t *vam = &vat_main;
19577 if (VAT_JSON_ARRAY != vam->json_tree.type)
19579 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19580 vat_json_init_array (&vam->json_tree);
19583 node = vat_json_array_add (&vam->json_tree);
19584 vat_json_init_object (node);
19586 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
19587 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
19588 vat_json_object_add_uint (node, "transport_protocol",
19589 mp->transport_protocol);
19593 api_sw_interface_span_enable_disable (vat_main_t * vam)
19595 unformat_input_t *i = vam->input;
19596 vl_api_sw_interface_span_enable_disable_t *mp;
19597 u32 src_sw_if_index = ~0;
19598 u32 dst_sw_if_index = ~0;
19603 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19606 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
19608 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
19612 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
19614 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
19616 else if (unformat (i, "disable"))
19618 else if (unformat (i, "rx"))
19620 else if (unformat (i, "tx"))
19622 else if (unformat (i, "both"))
19624 else if (unformat (i, "l2"))
19630 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
19632 mp->sw_if_index_from = htonl (src_sw_if_index);
19633 mp->sw_if_index_to = htonl (dst_sw_if_index);
19643 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
19646 vat_main_t *vam = &vat_main;
19647 u8 *sw_if_from_name = 0;
19648 u8 *sw_if_to_name = 0;
19649 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19650 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19651 char *states[] = { "none", "rx", "tx", "both" };
19655 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19657 if ((u32) p->value[0] == sw_if_index_from)
19659 sw_if_from_name = (u8 *)(p->key);
19663 if ((u32) p->value[0] == sw_if_index_to)
19665 sw_if_to_name = (u8 *)(p->key);
19666 if (sw_if_from_name)
19671 print (vam->ofp, "%20s => %20s (%s) %s",
19672 sw_if_from_name, sw_if_to_name, states[mp->state],
19673 mp->is_l2 ? "l2" : "device");
19677 vl_api_sw_interface_span_details_t_handler_json
19678 (vl_api_sw_interface_span_details_t * mp)
19680 vat_main_t *vam = &vat_main;
19681 vat_json_node_t *node = NULL;
19682 u8 *sw_if_from_name = 0;
19683 u8 *sw_if_to_name = 0;
19684 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19685 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19689 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19691 if ((u32) p->value[0] == sw_if_index_from)
19693 sw_if_from_name = (u8 *)(p->key);
19697 if ((u32) p->value[0] == sw_if_index_to)
19699 sw_if_to_name = (u8 *)(p->key);
19700 if (sw_if_from_name)
19706 if (VAT_JSON_ARRAY != vam->json_tree.type)
19708 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19709 vat_json_init_array (&vam->json_tree);
19711 node = vat_json_array_add (&vam->json_tree);
19713 vat_json_init_object (node);
19714 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
19715 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
19716 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
19717 if (0 != sw_if_to_name)
19719 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
19721 vat_json_object_add_uint (node, "state", mp->state);
19722 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
19726 api_sw_interface_span_dump (vat_main_t * vam)
19728 unformat_input_t *input = vam->input;
19729 vl_api_sw_interface_span_dump_t *mp;
19730 vl_api_control_ping_t *mp_ping;
19734 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19736 if (unformat (input, "l2"))
19742 M (SW_INTERFACE_SPAN_DUMP, mp);
19746 /* Use a control ping for synchronization */
19747 MPING (CONTROL_PING, mp_ping);
19755 api_pg_create_interface (vat_main_t * vam)
19757 unformat_input_t *input = vam->input;
19758 vl_api_pg_create_interface_t *mp;
19760 u32 if_id = ~0, gso_size = 0;
19761 u8 gso_enabled = 0;
19763 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19765 if (unformat (input, "if_id %d", &if_id))
19767 else if (unformat (input, "gso-enabled"))
19770 if (unformat (input, "gso-size %u", &gso_size))
19774 errmsg ("missing gso-size");
19783 errmsg ("missing pg interface index");
19787 /* Construct the API message */
19788 M (PG_CREATE_INTERFACE, mp);
19790 mp->interface_id = ntohl (if_id);
19791 mp->gso_enabled = gso_enabled;
19799 api_pg_capture (vat_main_t * vam)
19801 unformat_input_t *input = vam->input;
19802 vl_api_pg_capture_t *mp;
19807 u8 pcap_file_set = 0;
19810 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19812 if (unformat (input, "if_id %d", &if_id))
19814 else if (unformat (input, "pcap %s", &pcap_file))
19816 else if (unformat (input, "count %d", &count))
19818 else if (unformat (input, "disable"))
19825 errmsg ("missing pg interface index");
19828 if (pcap_file_set > 0)
19830 if (vec_len (pcap_file) > 255)
19832 errmsg ("pcap file name is too long");
19837 u32 name_len = vec_len (pcap_file);
19838 /* Construct the API message */
19839 M (PG_CAPTURE, mp);
19841 mp->interface_id = ntohl (if_id);
19842 mp->is_enabled = enable;
19843 mp->count = ntohl (count);
19844 mp->pcap_name_length = ntohl (name_len);
19845 if (pcap_file_set != 0)
19847 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
19849 vec_free (pcap_file);
19857 api_pg_enable_disable (vat_main_t * vam)
19859 unformat_input_t *input = vam->input;
19860 vl_api_pg_enable_disable_t *mp;
19863 u8 stream_name_set = 0;
19864 u8 *stream_name = 0;
19866 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19868 if (unformat (input, "stream %s", &stream_name))
19869 stream_name_set = 1;
19870 else if (unformat (input, "disable"))
19876 if (stream_name_set > 0)
19878 if (vec_len (stream_name) > 255)
19880 errmsg ("stream name too long");
19885 u32 name_len = vec_len (stream_name);
19886 /* Construct the API message */
19887 M (PG_ENABLE_DISABLE, mp);
19889 mp->is_enabled = enable;
19890 if (stream_name_set != 0)
19892 mp->stream_name_length = ntohl (name_len);
19893 clib_memcpy (mp->stream_name, stream_name, name_len);
19895 vec_free (stream_name);
19903 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
19905 unformat_input_t *input = vam->input;
19906 vl_api_ip_source_and_port_range_check_add_del_t *mp;
19908 u16 *low_ports = 0;
19909 u16 *high_ports = 0;
19912 vl_api_prefix_t prefix;
19919 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19921 if (unformat (input, "%U", unformat_vl_api_prefix, &prefix))
19923 else if (unformat (input, "vrf %d", &vrf_id))
19925 else if (unformat (input, "del"))
19927 else if (unformat (input, "port %d", &tmp))
19929 if (tmp == 0 || tmp > 65535)
19931 errmsg ("port %d out of range", tmp);
19935 this_hi = this_low + 1;
19936 vec_add1 (low_ports, this_low);
19937 vec_add1 (high_ports, this_hi);
19939 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
19941 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
19943 errmsg ("incorrect range parameters");
19947 /* Note: in debug CLI +1 is added to high before
19948 passing to real fn that does "the work"
19949 (ip_source_and_port_range_check_add_del).
19950 This fn is a wrapper around the binary API fn a
19951 control plane will call, which expects this increment
19952 to have occurred. Hence letting the binary API control
19953 plane fn do the increment for consistency between VAT
19954 and other control planes.
19957 vec_add1 (low_ports, this_low);
19958 vec_add1 (high_ports, this_hi);
19964 if (prefix_set == 0)
19966 errmsg ("<address>/<mask> not specified");
19972 errmsg ("VRF ID required, not specified");
19979 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
19983 if (vec_len (low_ports) == 0)
19985 errmsg ("At least one port or port range required");
19989 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
19991 mp->is_add = is_add;
19993 clib_memcpy (&mp->prefix, &prefix, sizeof (prefix));
19995 mp->number_of_ranges = vec_len (low_ports);
19997 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
19998 vec_free (low_ports);
20000 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
20001 vec_free (high_ports);
20003 mp->vrf_id = ntohl (vrf_id);
20011 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
20013 unformat_input_t *input = vam->input;
20014 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
20015 u32 sw_if_index = ~0;
20017 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
20018 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
20022 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20024 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20026 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20028 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
20030 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
20032 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
20034 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
20036 else if (unformat (input, "del"))
20042 if (sw_if_index == ~0)
20044 errmsg ("Interface required but not specified");
20050 errmsg ("VRF ID required but not specified");
20054 if (tcp_out_vrf_id == 0
20055 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
20058 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
20062 /* Construct the API message */
20063 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
20065 mp->sw_if_index = ntohl (sw_if_index);
20066 mp->is_add = is_add;
20067 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
20068 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
20069 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
20070 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
20075 /* Wait for a reply... */
20081 api_set_punt (vat_main_t * vam)
20083 unformat_input_t *i = vam->input;
20084 vl_api_address_family_t af;
20085 vl_api_set_punt_t *mp;
20091 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20093 if (unformat (i, "%U", unformat_vl_api_address_family, &af))
20095 else if (unformat (i, "protocol %d", &protocol))
20097 else if (unformat (i, "port %d", &port))
20099 else if (unformat (i, "del"))
20103 clib_warning ("parse error '%U'", format_unformat_error, i);
20110 mp->is_add = (u8) is_add;
20111 mp->punt.type = PUNT_API_TYPE_L4;
20112 mp->punt.punt.l4.af = af;
20113 mp->punt.punt.l4.protocol = (u8) protocol;
20114 mp->punt.punt.l4.port = htons ((u16) port);
20122 api_delete_subif (vat_main_t * vam)
20124 unformat_input_t *i = vam->input;
20125 vl_api_delete_subif_t *mp;
20126 u32 sw_if_index = ~0;
20129 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20131 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20133 if (unformat (i, "sw_if_index %d", &sw_if_index))
20139 if (sw_if_index == ~0)
20141 errmsg ("missing sw_if_index");
20145 /* Construct the API message */
20146 M (DELETE_SUBIF, mp);
20147 mp->sw_if_index = ntohl (sw_if_index);
20154 #define foreach_pbb_vtr_op \
20155 _("disable", L2_VTR_DISABLED) \
20156 _("pop", L2_VTR_POP_2) \
20157 _("push", L2_VTR_PUSH_2)
20160 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
20162 unformat_input_t *i = vam->input;
20163 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
20164 u32 sw_if_index = ~0, vtr_op = ~0;
20165 u16 outer_tag = ~0;
20166 u8 dmac[6], smac[6];
20167 u8 dmac_set = 0, smac_set = 0;
20173 /* Shut up coverity */
20174 clib_memset (dmac, 0, sizeof (dmac));
20175 clib_memset (smac, 0, sizeof (smac));
20177 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20179 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20181 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20183 else if (unformat (i, "vtr_op %d", &vtr_op))
20185 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
20188 else if (unformat (i, "translate_pbb_stag"))
20190 if (unformat (i, "%d", &tmp))
20192 vtr_op = L2_VTR_TRANSLATE_2_1;
20198 ("translate_pbb_stag operation requires outer tag definition");
20202 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
20204 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
20206 else if (unformat (i, "sid %d", &sid))
20208 else if (unformat (i, "vlanid %d", &tmp))
20212 clib_warning ("parse error '%U'", format_unformat_error, i);
20217 if ((sw_if_index == ~0) || (vtr_op == ~0))
20219 errmsg ("missing sw_if_index or vtr operation");
20222 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
20223 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
20226 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
20230 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
20231 mp->sw_if_index = ntohl (sw_if_index);
20232 mp->vtr_op = ntohl (vtr_op);
20233 mp->outer_tag = ntohs (outer_tag);
20234 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
20235 clib_memcpy (mp->b_smac, smac, sizeof (smac));
20236 mp->b_vlanid = ntohs (vlanid);
20237 mp->i_sid = ntohl (sid);
20245 api_flow_classify_set_interface (vat_main_t * vam)
20247 unformat_input_t *i = vam->input;
20248 vl_api_flow_classify_set_interface_t *mp;
20250 int sw_if_index_set;
20251 u32 ip4_table_index = ~0;
20252 u32 ip6_table_index = ~0;
20256 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20258 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20259 sw_if_index_set = 1;
20260 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20261 sw_if_index_set = 1;
20262 else if (unformat (i, "del"))
20264 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20266 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20270 clib_warning ("parse error '%U'", format_unformat_error, i);
20275 if (sw_if_index_set == 0)
20277 errmsg ("missing interface name or sw_if_index");
20281 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
20283 mp->sw_if_index = ntohl (sw_if_index);
20284 mp->ip4_table_index = ntohl (ip4_table_index);
20285 mp->ip6_table_index = ntohl (ip6_table_index);
20286 mp->is_add = is_add;
20294 api_flow_classify_dump (vat_main_t * vam)
20296 unformat_input_t *i = vam->input;
20297 vl_api_flow_classify_dump_t *mp;
20298 vl_api_control_ping_t *mp_ping;
20299 u8 type = FLOW_CLASSIFY_N_TABLES;
20302 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
20306 errmsg ("classify table type must be specified");
20310 if (!vam->json_output)
20312 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20315 M (FLOW_CLASSIFY_DUMP, mp);
20320 /* Use a control ping for synchronization */
20321 MPING (CONTROL_PING, mp_ping);
20324 /* Wait for a reply... */
20330 api_feature_enable_disable (vat_main_t * vam)
20332 unformat_input_t *i = vam->input;
20333 vl_api_feature_enable_disable_t *mp;
20335 u8 *feature_name = 0;
20336 u32 sw_if_index = ~0;
20340 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20342 if (unformat (i, "arc_name %s", &arc_name))
20344 else if (unformat (i, "feature_name %s", &feature_name))
20347 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20349 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20351 else if (unformat (i, "disable"))
20359 errmsg ("missing arc name");
20362 if (vec_len (arc_name) > 63)
20364 errmsg ("arc name too long");
20367 if (feature_name == 0)
20369 errmsg ("missing feature name");
20372 if (vec_len (feature_name) > 63)
20374 errmsg ("feature name too long");
20377 if (sw_if_index == ~0)
20379 errmsg ("missing interface name or sw_if_index");
20383 /* Construct the API message */
20384 M (FEATURE_ENABLE_DISABLE, mp);
20385 mp->sw_if_index = ntohl (sw_if_index);
20386 mp->enable = enable;
20387 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
20388 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
20389 vec_free (arc_name);
20390 vec_free (feature_name);
20398 api_sw_interface_tag_add_del (vat_main_t * vam)
20400 unformat_input_t *i = vam->input;
20401 vl_api_sw_interface_tag_add_del_t *mp;
20402 u32 sw_if_index = ~0;
20407 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20409 if (unformat (i, "tag %s", &tag))
20411 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20413 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20415 else if (unformat (i, "del"))
20421 if (sw_if_index == ~0)
20423 errmsg ("missing interface name or sw_if_index");
20427 if (enable && (tag == 0))
20429 errmsg ("no tag specified");
20433 /* Construct the API message */
20434 M (SW_INTERFACE_TAG_ADD_DEL, mp);
20435 mp->sw_if_index = ntohl (sw_if_index);
20436 mp->is_add = enable;
20438 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
20446 static void vl_api_l2_xconnect_details_t_handler
20447 (vl_api_l2_xconnect_details_t * mp)
20449 vat_main_t *vam = &vat_main;
20451 print (vam->ofp, "%15d%15d",
20452 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
20455 static void vl_api_l2_xconnect_details_t_handler_json
20456 (vl_api_l2_xconnect_details_t * mp)
20458 vat_main_t *vam = &vat_main;
20459 vat_json_node_t *node = NULL;
20461 if (VAT_JSON_ARRAY != vam->json_tree.type)
20463 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20464 vat_json_init_array (&vam->json_tree);
20466 node = vat_json_array_add (&vam->json_tree);
20468 vat_json_init_object (node);
20469 vat_json_object_add_uint (node, "rx_sw_if_index",
20470 ntohl (mp->rx_sw_if_index));
20471 vat_json_object_add_uint (node, "tx_sw_if_index",
20472 ntohl (mp->tx_sw_if_index));
20476 api_l2_xconnect_dump (vat_main_t * vam)
20478 vl_api_l2_xconnect_dump_t *mp;
20479 vl_api_control_ping_t *mp_ping;
20482 if (!vam->json_output)
20484 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
20487 M (L2_XCONNECT_DUMP, mp);
20491 /* Use a control ping for synchronization */
20492 MPING (CONTROL_PING, mp_ping);
20500 api_hw_interface_set_mtu (vat_main_t * vam)
20502 unformat_input_t *i = vam->input;
20503 vl_api_hw_interface_set_mtu_t *mp;
20504 u32 sw_if_index = ~0;
20508 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20510 if (unformat (i, "mtu %d", &mtu))
20512 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20514 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20520 if (sw_if_index == ~0)
20522 errmsg ("missing interface name or sw_if_index");
20528 errmsg ("no mtu specified");
20532 /* Construct the API message */
20533 M (HW_INTERFACE_SET_MTU, mp);
20534 mp->sw_if_index = ntohl (sw_if_index);
20535 mp->mtu = ntohs ((u16) mtu);
20543 api_p2p_ethernet_add (vat_main_t * vam)
20545 unformat_input_t *i = vam->input;
20546 vl_api_p2p_ethernet_add_t *mp;
20547 u32 parent_if_index = ~0;
20553 clib_memset (remote_mac, 0, sizeof (remote_mac));
20554 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20556 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20558 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20562 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20564 else if (unformat (i, "sub_id %d", &sub_id))
20568 clib_warning ("parse error '%U'", format_unformat_error, i);
20573 if (parent_if_index == ~0)
20575 errmsg ("missing interface name or sw_if_index");
20580 errmsg ("missing remote mac address");
20585 errmsg ("missing sub-interface id");
20589 M (P2P_ETHERNET_ADD, mp);
20590 mp->parent_if_index = ntohl (parent_if_index);
20591 mp->subif_id = ntohl (sub_id);
20592 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20600 api_p2p_ethernet_del (vat_main_t * vam)
20602 unformat_input_t *i = vam->input;
20603 vl_api_p2p_ethernet_del_t *mp;
20604 u32 parent_if_index = ~0;
20609 clib_memset (remote_mac, 0, sizeof (remote_mac));
20610 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20612 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20614 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20618 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20622 clib_warning ("parse error '%U'", format_unformat_error, i);
20627 if (parent_if_index == ~0)
20629 errmsg ("missing interface name or sw_if_index");
20634 errmsg ("missing remote mac address");
20638 M (P2P_ETHERNET_DEL, mp);
20639 mp->parent_if_index = ntohl (parent_if_index);
20640 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20648 api_lldp_config (vat_main_t * vam)
20650 unformat_input_t *i = vam->input;
20651 vl_api_lldp_config_t *mp;
20653 int tx_interval = 0;
20654 u8 *sys_name = NULL;
20657 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20659 if (unformat (i, "system-name %s", &sys_name))
20661 else if (unformat (i, "tx-hold %d", &tx_hold))
20663 else if (unformat (i, "tx-interval %d", &tx_interval))
20667 clib_warning ("parse error '%U'", format_unformat_error, i);
20672 vec_add1 (sys_name, 0);
20674 M (LLDP_CONFIG, mp);
20675 mp->tx_hold = htonl (tx_hold);
20676 mp->tx_interval = htonl (tx_interval);
20677 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
20678 vec_free (sys_name);
20686 api_sw_interface_set_lldp (vat_main_t * vam)
20688 unformat_input_t *i = vam->input;
20689 vl_api_sw_interface_set_lldp_t *mp;
20690 u32 sw_if_index = ~0;
20692 u8 *port_desc = NULL, *mgmt_oid = NULL;
20693 ip4_address_t ip4_addr;
20694 ip6_address_t ip6_addr;
20697 clib_memset (&ip4_addr, 0, sizeof (ip4_addr));
20698 clib_memset (&ip6_addr, 0, sizeof (ip6_addr));
20700 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20702 if (unformat (i, "disable"))
20705 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20707 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20709 else if (unformat (i, "port-desc %s", &port_desc))
20711 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
20713 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
20715 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
20721 if (sw_if_index == ~0)
20723 errmsg ("missing interface name or sw_if_index");
20727 /* Construct the API message */
20728 vec_add1 (port_desc, 0);
20729 vec_add1 (mgmt_oid, 0);
20730 M (SW_INTERFACE_SET_LLDP, mp);
20731 mp->sw_if_index = ntohl (sw_if_index);
20732 mp->enable = enable;
20733 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
20734 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
20735 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
20736 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
20737 vec_free (port_desc);
20738 vec_free (mgmt_oid);
20746 api_tcp_configure_src_addresses (vat_main_t * vam)
20748 vl_api_tcp_configure_src_addresses_t *mp;
20749 unformat_input_t *i = vam->input;
20750 ip4_address_t v4first, v4last;
20751 ip6_address_t v6first, v6last;
20756 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20758 if (unformat (i, "%U - %U",
20759 unformat_ip4_address, &v4first,
20760 unformat_ip4_address, &v4last))
20764 errmsg ("one range per message (range already set)");
20769 else if (unformat (i, "%U - %U",
20770 unformat_ip6_address, &v6first,
20771 unformat_ip6_address, &v6last))
20775 errmsg ("one range per message (range already set)");
20780 else if (unformat (i, "vrf %d", &vrf_id))
20786 if (range_set == 0)
20788 errmsg ("address range not set");
20792 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
20793 mp->vrf_id = ntohl (vrf_id);
20795 if (range_set == 2)
20798 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
20799 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
20804 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
20805 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
20812 static void vl_api_app_namespace_add_del_reply_t_handler
20813 (vl_api_app_namespace_add_del_reply_t * mp)
20815 vat_main_t *vam = &vat_main;
20816 i32 retval = ntohl (mp->retval);
20817 if (vam->async_mode)
20819 vam->async_errors += (retval < 0);
20823 vam->retval = retval;
20825 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
20826 vam->result_ready = 1;
20830 static void vl_api_app_namespace_add_del_reply_t_handler_json
20831 (vl_api_app_namespace_add_del_reply_t * mp)
20833 vat_main_t *vam = &vat_main;
20834 vat_json_node_t node;
20836 vat_json_init_object (&node);
20837 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
20838 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
20840 vat_json_print (vam->ofp, &node);
20841 vat_json_free (&node);
20843 vam->retval = ntohl (mp->retval);
20844 vam->result_ready = 1;
20848 api_app_namespace_add_del (vat_main_t * vam)
20850 vl_api_app_namespace_add_del_t *mp;
20851 unformat_input_t *i = vam->input;
20852 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
20853 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
20857 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20859 if (unformat (i, "id %_%v%_", &ns_id))
20861 else if (unformat (i, "secret %lu", &secret))
20863 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20864 sw_if_index_set = 1;
20865 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
20867 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
20872 if (!ns_id || !secret_set || !sw_if_index_set)
20874 errmsg ("namespace id, secret and sw_if_index must be set");
20877 if (vec_len (ns_id) > 64)
20879 errmsg ("namespace id too long");
20882 M (APP_NAMESPACE_ADD_DEL, mp);
20884 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
20885 mp->namespace_id_len = vec_len (ns_id);
20886 mp->secret = clib_host_to_net_u64 (secret);
20887 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
20888 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
20889 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
20897 api_sock_init_shm (vat_main_t * vam)
20899 #if VPP_API_TEST_BUILTIN == 0
20900 unformat_input_t *i = vam->input;
20901 vl_api_shm_elem_config_t *config = 0;
20902 u64 size = 64 << 20;
20905 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20907 if (unformat (i, "size %U", unformat_memory_size, &size))
20914 * Canned custom ring allocator config.
20915 * Should probably parse all of this
20917 vec_validate (config, 6);
20918 config[0].type = VL_API_VLIB_RING;
20919 config[0].size = 256;
20920 config[0].count = 32;
20922 config[1].type = VL_API_VLIB_RING;
20923 config[1].size = 1024;
20924 config[1].count = 16;
20926 config[2].type = VL_API_VLIB_RING;
20927 config[2].size = 4096;
20928 config[2].count = 2;
20930 config[3].type = VL_API_CLIENT_RING;
20931 config[3].size = 256;
20932 config[3].count = 32;
20934 config[4].type = VL_API_CLIENT_RING;
20935 config[4].size = 1024;
20936 config[4].count = 16;
20938 config[5].type = VL_API_CLIENT_RING;
20939 config[5].size = 4096;
20940 config[5].count = 2;
20942 config[6].type = VL_API_QUEUE;
20943 config[6].count = 128;
20944 config[6].size = sizeof (uword);
20946 rv = vl_socket_client_init_shm (config, 1 /* want_pthread */ );
20948 vam->client_index_invalid = 1;
20956 api_dns_enable_disable (vat_main_t * vam)
20958 unformat_input_t *line_input = vam->input;
20959 vl_api_dns_enable_disable_t *mp;
20960 u8 enable_disable = 1;
20963 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
20965 if (unformat (line_input, "disable"))
20966 enable_disable = 0;
20967 if (unformat (line_input, "enable"))
20968 enable_disable = 1;
20973 /* Construct the API message */
20974 M (DNS_ENABLE_DISABLE, mp);
20975 mp->enable = enable_disable;
20979 /* Wait for the reply */
20985 api_dns_resolve_name (vat_main_t * vam)
20987 unformat_input_t *line_input = vam->input;
20988 vl_api_dns_resolve_name_t *mp;
20992 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
20994 if (unformat (line_input, "%s", &name))
21000 if (vec_len (name) > 127)
21002 errmsg ("name too long");
21006 /* Construct the API message */
21007 M (DNS_RESOLVE_NAME, mp);
21008 memcpy (mp->name, name, vec_len (name));
21013 /* Wait for the reply */
21019 api_dns_resolve_ip (vat_main_t * vam)
21021 unformat_input_t *line_input = vam->input;
21022 vl_api_dns_resolve_ip_t *mp;
21024 ip4_address_t addr4;
21025 ip6_address_t addr6;
21028 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21030 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
21032 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
21040 errmsg ("missing address");
21044 /* Construct the API message */
21045 M (DNS_RESOLVE_IP, mp);
21046 mp->is_ip6 = is_ip6;
21048 memcpy (mp->address, &addr6, sizeof (addr6));
21050 memcpy (mp->address, &addr4, sizeof (addr4));
21054 /* Wait for the reply */
21060 api_dns_name_server_add_del (vat_main_t * vam)
21062 unformat_input_t *i = vam->input;
21063 vl_api_dns_name_server_add_del_t *mp;
21065 ip6_address_t ip6_server;
21066 ip4_address_t ip4_server;
21071 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21073 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
21075 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
21077 else if (unformat (i, "del"))
21081 clib_warning ("parse error '%U'", format_unformat_error, i);
21086 if (ip4_set && ip6_set)
21088 errmsg ("Only one server address allowed per message");
21091 if ((ip4_set + ip6_set) == 0)
21093 errmsg ("Server address required");
21097 /* Construct the API message */
21098 M (DNS_NAME_SERVER_ADD_DEL, mp);
21102 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
21107 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
21111 mp->is_add = is_add;
21116 /* Wait for a reply, return good/bad news */
21122 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
21124 vat_main_t *vam = &vat_main;
21129 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
21130 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
21131 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
21132 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
21133 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
21134 clib_net_to_host_u32 (mp->action_index), mp->tag);
21139 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
21140 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
21141 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
21142 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
21143 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
21144 clib_net_to_host_u32 (mp->action_index), mp->tag);
21149 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
21152 vat_main_t *vam = &vat_main;
21153 vat_json_node_t *node = NULL;
21154 struct in6_addr ip6;
21155 struct in_addr ip4;
21157 if (VAT_JSON_ARRAY != vam->json_tree.type)
21159 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21160 vat_json_init_array (&vam->json_tree);
21162 node = vat_json_array_add (&vam->json_tree);
21163 vat_json_init_object (node);
21165 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
21166 vat_json_object_add_uint (node, "appns_index",
21167 clib_net_to_host_u32 (mp->appns_index));
21168 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
21169 vat_json_object_add_uint (node, "scope", mp->scope);
21170 vat_json_object_add_uint (node, "action_index",
21171 clib_net_to_host_u32 (mp->action_index));
21172 vat_json_object_add_uint (node, "lcl_port",
21173 clib_net_to_host_u16 (mp->lcl_port));
21174 vat_json_object_add_uint (node, "rmt_port",
21175 clib_net_to_host_u16 (mp->rmt_port));
21176 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
21177 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
21178 vat_json_object_add_string_copy (node, "tag", mp->tag);
21181 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
21182 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
21183 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
21184 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
21188 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
21189 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
21190 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
21191 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
21196 api_session_rule_add_del (vat_main_t * vam)
21198 vl_api_session_rule_add_del_t *mp;
21199 unformat_input_t *i = vam->input;
21200 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
21201 u32 appns_index = 0, scope = 0;
21202 ip4_address_t lcl_ip4, rmt_ip4;
21203 ip6_address_t lcl_ip6, rmt_ip6;
21204 u8 is_ip4 = 1, conn_set = 0;
21205 u8 is_add = 1, *tag = 0;
21208 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21210 if (unformat (i, "del"))
21212 else if (unformat (i, "add"))
21214 else if (unformat (i, "proto tcp"))
21216 else if (unformat (i, "proto udp"))
21218 else if (unformat (i, "appns %d", &appns_index))
21220 else if (unformat (i, "scope %d", &scope))
21222 else if (unformat (i, "tag %_%v%_", &tag))
21226 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
21227 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
21235 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
21236 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
21242 else if (unformat (i, "action %d", &action))
21247 if (proto == ~0 || !conn_set || action == ~0)
21249 errmsg ("transport proto, connection and action must be set");
21255 errmsg ("scope should be 0-3");
21259 M (SESSION_RULE_ADD_DEL, mp);
21261 mp->is_ip4 = is_ip4;
21262 mp->transport_proto = proto;
21263 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
21264 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
21265 mp->lcl_plen = lcl_plen;
21266 mp->rmt_plen = rmt_plen;
21267 mp->action_index = clib_host_to_net_u32 (action);
21268 mp->appns_index = clib_host_to_net_u32 (appns_index);
21270 mp->is_add = is_add;
21273 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
21274 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
21278 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
21279 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
21283 clib_memcpy (mp->tag, tag, vec_len (tag));
21293 api_session_rules_dump (vat_main_t * vam)
21295 vl_api_session_rules_dump_t *mp;
21296 vl_api_control_ping_t *mp_ping;
21299 if (!vam->json_output)
21301 print (vam->ofp, "%=20s", "Session Rules");
21304 M (SESSION_RULES_DUMP, mp);
21308 /* Use a control ping for synchronization */
21309 MPING (CONTROL_PING, mp_ping);
21312 /* Wait for a reply... */
21318 api_ip_container_proxy_add_del (vat_main_t * vam)
21320 vl_api_ip_container_proxy_add_del_t *mp;
21321 unformat_input_t *i = vam->input;
21322 u32 sw_if_index = ~0;
21323 vl_api_prefix_t pfx = { };
21327 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21329 if (unformat (i, "del"))
21331 else if (unformat (i, "add"))
21333 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
21335 else if (unformat (i, "sw_if_index %u", &sw_if_index))
21340 if (sw_if_index == ~0 || pfx.len == 0)
21342 errmsg ("address and sw_if_index must be set");
21346 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
21348 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
21349 mp->is_add = is_add;
21350 clib_memcpy (&mp->pfx, &pfx, sizeof (pfx));
21358 api_qos_record_enable_disable (vat_main_t * vam)
21360 unformat_input_t *i = vam->input;
21361 vl_api_qos_record_enable_disable_t *mp;
21362 u32 sw_if_index, qs = 0xff;
21363 u8 sw_if_index_set = 0;
21367 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21369 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21370 sw_if_index_set = 1;
21371 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21372 sw_if_index_set = 1;
21373 else if (unformat (i, "%U", unformat_qos_source, &qs))
21375 else if (unformat (i, "disable"))
21379 clib_warning ("parse error '%U'", format_unformat_error, i);
21384 if (sw_if_index_set == 0)
21386 errmsg ("missing interface name or sw_if_index");
21391 errmsg ("input location must be specified");
21395 M (QOS_RECORD_ENABLE_DISABLE, mp);
21397 mp->record.sw_if_index = ntohl (sw_if_index);
21398 mp->record.input_source = qs;
21399 mp->enable = enable;
21408 q_or_quit (vat_main_t * vam)
21410 #if VPP_API_TEST_BUILTIN == 0
21411 longjmp (vam->jump_buf, 1);
21413 return 0; /* not so much */
21417 q (vat_main_t * vam)
21419 return q_or_quit (vam);
21423 quit (vat_main_t * vam)
21425 return q_or_quit (vam);
21429 comment (vat_main_t * vam)
21435 elog_save (vat_main_t * vam)
21437 #if VPP_API_TEST_BUILTIN == 0
21438 elog_main_t *em = &vam->elog_main;
21439 unformat_input_t *i = vam->input;
21440 char *file, *chroot_file;
21441 clib_error_t *error;
21443 if (!unformat (i, "%s", &file))
21445 errmsg ("expected file name, got `%U'", format_unformat_error, i);
21449 /* It's fairly hard to get "../oopsie" through unformat; just in case */
21450 if (strstr (file, "..") || index (file, '/'))
21452 errmsg ("illegal characters in filename '%s'", file);
21456 chroot_file = (char *) format (0, "/tmp/%s%c", file, 0);
21460 errmsg ("Saving %wd of %wd events to %s",
21461 elog_n_events_in_buffer (em),
21462 elog_buffer_capacity (em), chroot_file);
21464 error = elog_write_file (em, chroot_file, 1 /* flush ring */ );
21465 vec_free (chroot_file);
21468 clib_error_report (error);
21470 errmsg ("Use the vpp event loger...");
21477 elog_setup (vat_main_t * vam)
21479 #if VPP_API_TEST_BUILTIN == 0
21480 elog_main_t *em = &vam->elog_main;
21481 unformat_input_t *i = vam->input;
21482 u32 nevents = 128 << 10;
21484 (void) unformat (i, "nevents %d", &nevents);
21486 elog_init (em, nevents);
21487 vl_api_set_elog_main (em);
21488 vl_api_set_elog_trace_api_messages (1);
21489 errmsg ("Event logger initialized with %u events", nevents);
21491 errmsg ("Use the vpp event loger...");
21497 elog_enable (vat_main_t * vam)
21499 #if VPP_API_TEST_BUILTIN == 0
21500 elog_main_t *em = &vam->elog_main;
21502 elog_enable_disable (em, 1 /* enable */ );
21503 vl_api_set_elog_trace_api_messages (1);
21504 errmsg ("Event logger enabled...");
21506 errmsg ("Use the vpp event loger...");
21512 elog_disable (vat_main_t * vam)
21514 #if VPP_API_TEST_BUILTIN == 0
21515 elog_main_t *em = &vam->elog_main;
21517 elog_enable_disable (em, 0 /* enable */ );
21518 vl_api_set_elog_trace_api_messages (1);
21519 errmsg ("Event logger disabled...");
21521 errmsg ("Use the vpp event loger...");
21527 statseg (vat_main_t * vam)
21529 ssvm_private_t *ssvmp = &vam->stat_segment;
21530 ssvm_shared_header_t *shared_header = ssvmp->sh;
21531 vlib_counter_t **counters;
21532 u64 thread0_index1_packets;
21533 u64 thread0_index1_bytes;
21534 f64 vector_rate, input_rate;
21537 uword *counter_vector_by_name;
21538 if (vam->stat_segment_lockp == 0)
21540 errmsg ("Stat segment not mapped...");
21544 /* look up "/if/rx for sw_if_index 1 as a test */
21546 clib_spinlock_lock (vam->stat_segment_lockp);
21548 counter_vector_by_name = (uword *) shared_header->opaque[1];
21550 p = hash_get_mem (counter_vector_by_name, "/if/rx");
21553 clib_spinlock_unlock (vam->stat_segment_lockp);
21554 errmsg ("/if/tx not found?");
21558 /* Fish per-thread vector of combined counters from shared memory */
21559 counters = (vlib_counter_t **) p[0];
21561 if (vec_len (counters[0]) < 2)
21563 clib_spinlock_unlock (vam->stat_segment_lockp);
21564 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
21568 /* Read thread 0 sw_if_index 1 counter */
21569 thread0_index1_packets = counters[0][1].packets;
21570 thread0_index1_bytes = counters[0][1].bytes;
21572 p = hash_get_mem (counter_vector_by_name, "vector_rate");
21575 clib_spinlock_unlock (vam->stat_segment_lockp);
21576 errmsg ("vector_rate not found?");
21580 vector_rate = *(f64 *) (p[0]);
21581 p = hash_get_mem (counter_vector_by_name, "input_rate");
21584 clib_spinlock_unlock (vam->stat_segment_lockp);
21585 errmsg ("input_rate not found?");
21588 input_rate = *(f64 *) (p[0]);
21590 clib_spinlock_unlock (vam->stat_segment_lockp);
21592 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
21593 vector_rate, input_rate);
21594 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
21595 thread0_index1_packets, thread0_index1_bytes);
21601 cmd_cmp (void *a1, void *a2)
21606 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
21610 help (vat_main_t * vam)
21615 unformat_input_t *i = vam->input;
21618 if (unformat (i, "%s", &name))
21622 vec_add1 (name, 0);
21624 hs = hash_get_mem (vam->help_by_name, name);
21626 print (vam->ofp, "usage: %s %s", name, hs[0]);
21628 print (vam->ofp, "No such msg / command '%s'", name);
21633 print (vam->ofp, "Help is available for the following:");
21636 hash_foreach_pair (p, vam->function_by_name,
21638 vec_add1 (cmds, (u8 *)(p->key));
21642 vec_sort_with_function (cmds, cmd_cmp);
21644 for (j = 0; j < vec_len (cmds); j++)
21645 print (vam->ofp, "%s", cmds[j]);
21652 set (vat_main_t * vam)
21654 u8 *name = 0, *value = 0;
21655 unformat_input_t *i = vam->input;
21657 if (unformat (i, "%s", &name))
21659 /* The input buffer is a vector, not a string. */
21660 value = vec_dup (i->buffer);
21661 vec_delete (value, i->index, 0);
21662 /* Almost certainly has a trailing newline */
21663 if (value[vec_len (value) - 1] == '\n')
21664 value[vec_len (value) - 1] = 0;
21665 /* Make sure it's a proper string, one way or the other */
21666 vec_add1 (value, 0);
21667 (void) clib_macro_set_value (&vam->macro_main,
21668 (char *) name, (char *) value);
21671 errmsg ("usage: set <name> <value>");
21679 unset (vat_main_t * vam)
21683 if (unformat (vam->input, "%s", &name))
21684 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
21685 errmsg ("unset: %s wasn't set", name);
21698 macro_sort_cmp (void *a1, void *a2)
21700 macro_sort_t *s1 = a1;
21701 macro_sort_t *s2 = a2;
21703 return strcmp ((char *) (s1->name), (char *) (s2->name));
21707 dump_macro_table (vat_main_t * vam)
21709 macro_sort_t *sort_me = 0, *sm;
21714 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
21716 vec_add2 (sort_me, sm, 1);
21717 sm->name = (u8 *)(p->key);
21718 sm->value = (u8 *) (p->value[0]);
21722 vec_sort_with_function (sort_me, macro_sort_cmp);
21724 if (vec_len (sort_me))
21725 print (vam->ofp, "%-15s%s", "Name", "Value");
21727 print (vam->ofp, "The macro table is empty...");
21729 for (i = 0; i < vec_len (sort_me); i++)
21730 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
21735 dump_node_table (vat_main_t * vam)
21738 vlib_node_t *node, *next_node;
21740 if (vec_len (vam->graph_nodes) == 0)
21742 print (vam->ofp, "Node table empty, issue get_node_graph...");
21746 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
21748 node = vam->graph_nodes[0][i];
21749 print (vam->ofp, "[%d] %s", i, node->name);
21750 for (j = 0; j < vec_len (node->next_nodes); j++)
21752 if (node->next_nodes[j] != ~0)
21754 next_node = vam->graph_nodes[0][node->next_nodes[j]];
21755 print (vam->ofp, " [%d] %s", j, next_node->name);
21763 value_sort_cmp (void *a1, void *a2)
21765 name_sort_t *n1 = a1;
21766 name_sort_t *n2 = a2;
21768 if (n1->value < n2->value)
21770 if (n1->value > n2->value)
21777 dump_msg_api_table (vat_main_t * vam)
21779 api_main_t *am = &api_main;
21780 name_sort_t *nses = 0, *ns;
21785 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
21787 vec_add2 (nses, ns, 1);
21788 ns->name = (u8 *)(hp->key);
21789 ns->value = (u32) hp->value[0];
21793 vec_sort_with_function (nses, value_sort_cmp);
21795 for (i = 0; i < vec_len (nses); i++)
21796 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
21802 get_msg_id (vat_main_t * vam)
21807 if (unformat (vam->input, "%s", &name_and_crc))
21809 message_index = vl_msg_api_get_msg_index (name_and_crc);
21810 if (message_index == ~0)
21812 print (vam->ofp, " '%s' not found", name_and_crc);
21815 print (vam->ofp, " '%s' has message index %d",
21816 name_and_crc, message_index);
21819 errmsg ("name_and_crc required...");
21824 search_node_table (vat_main_t * vam)
21826 unformat_input_t *line_input = vam->input;
21829 vlib_node_t *node, *next_node;
21832 if (vam->graph_node_index_by_name == 0)
21834 print (vam->ofp, "Node table empty, issue get_node_graph...");
21838 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21840 if (unformat (line_input, "%s", &node_to_find))
21842 vec_add1 (node_to_find, 0);
21843 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
21846 print (vam->ofp, "%s not found...", node_to_find);
21849 node = vam->graph_nodes[0][p[0]];
21850 print (vam->ofp, "[%d] %s", p[0], node->name);
21851 for (j = 0; j < vec_len (node->next_nodes); j++)
21853 if (node->next_nodes[j] != ~0)
21855 next_node = vam->graph_nodes[0][node->next_nodes[j]];
21856 print (vam->ofp, " [%d] %s", j, next_node->name);
21863 clib_warning ("parse error '%U'", format_unformat_error,
21869 vec_free (node_to_find);
21878 script (vat_main_t * vam)
21880 #if (VPP_API_TEST_BUILTIN==0)
21882 char *save_current_file;
21883 unformat_input_t save_input;
21884 jmp_buf save_jump_buf;
21885 u32 save_line_number;
21887 FILE *new_fp, *save_ifp;
21889 if (unformat (vam->input, "%s", &s))
21891 new_fp = fopen ((char *) s, "r");
21894 errmsg ("Couldn't open script file %s", s);
21901 errmsg ("Missing script name");
21905 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
21906 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
21907 save_ifp = vam->ifp;
21908 save_line_number = vam->input_line_number;
21909 save_current_file = (char *) vam->current_file;
21911 vam->input_line_number = 0;
21913 vam->current_file = s;
21916 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
21917 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
21918 vam->ifp = save_ifp;
21919 vam->input_line_number = save_line_number;
21920 vam->current_file = (u8 *) save_current_file;
21925 clib_warning ("use the exec command...");
21931 echo (vat_main_t * vam)
21933 print (vam->ofp, "%v", vam->input->buffer);
21937 /* List of API message constructors, CLI names map to api_xxx */
21938 #define foreach_vpe_api_msg \
21939 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
21940 _(sw_interface_dump,"") \
21941 _(sw_interface_set_flags, \
21942 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
21943 _(sw_interface_add_del_address, \
21944 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
21945 _(sw_interface_set_rx_mode, \
21946 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
21947 _(sw_interface_set_rx_placement, \
21948 "<intfc> | sw_if_index <id> [queue <id>] [worker <id> | main]") \
21949 _(sw_interface_rx_placement_dump, \
21950 "[<intfc> | sw_if_index <id>]") \
21951 _(sw_interface_set_table, \
21952 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
21953 _(sw_interface_set_mpls_enable, \
21954 "<intfc> | sw_if_index [disable | dis]") \
21955 _(sw_interface_set_vpath, \
21956 "<intfc> | sw_if_index <id> enable | disable") \
21957 _(sw_interface_set_vxlan_bypass, \
21958 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21959 _(sw_interface_set_geneve_bypass, \
21960 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21961 _(sw_interface_set_l2_xconnect, \
21962 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
21963 "enable | disable") \
21964 _(sw_interface_set_l2_bridge, \
21965 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
21966 "[shg <split-horizon-group>] [bvi]\n" \
21967 "enable | disable") \
21968 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
21969 _(bridge_domain_add_del, \
21970 "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") \
21971 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
21973 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
21974 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
21975 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
21977 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21979 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21981 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>] [host-mtu-size <mtu>] [gso | no-gso]") \
21983 "<vpp-if-name> | sw_if_index <id>") \
21984 _(sw_interface_tap_v2_dump, "") \
21985 _(virtio_pci_create, \
21986 "pci-addr <pci-address> [use_random_mac | hw-addr <mac-addr>] [features <hex-value>] [gso-enabled]") \
21987 _(virtio_pci_delete, \
21988 "<vpp-if-name> | sw_if_index <id>") \
21989 _(sw_interface_virtio_pci_dump, "") \
21991 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
21992 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \
21995 "<vpp-if-name> | sw_if_index <id>") \
21997 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
21998 _(bond_detach_slave, \
21999 "sw_if_index <n>") \
22000 _(sw_interface_bond_dump, "") \
22001 _(sw_interface_slave_dump, \
22002 "<vpp-if-name> | sw_if_index <id>") \
22003 _(ip_table_add_del, \
22004 "table <n> [ipv6] [add | del]\n") \
22005 _(ip_route_add_del, \
22006 "<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
22007 "[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
22008 "[weight <n>] [drop] [local] [classify <n>] [out-label <n>]\n" \
22009 "[multipath] [count <n>] [del]") \
22010 _(ip_mroute_add_del, \
22011 "<src> <grp>/<mask> [table-id <n>]\n" \
22012 "[<intfc> | sw_if_index <id>] [local] [del]") \
22013 _(mpls_table_add_del, \
22014 "table <n> [add | del]\n") \
22015 _(mpls_route_add_del, \
22016 "<label> <eos> via <addr | next-hop-table <n> | via-label <n> |\n" \
22017 "lookup-ip4-table <n> | lookup-in-ip6-table <n> |\n" \
22018 "l2-input-on <intfc> | l2-input-on sw_if_index <id>>\n" \
22019 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>] [weight <n>]\n" \
22020 "[drop] [local] [classify <n>] [out-label <n>] [multipath]\n" \
22021 "[count <n>] [del]") \
22022 _(mpls_ip_bind_unbind, \
22023 "<label> <addr/len>") \
22024 _(mpls_tunnel_add_del, \
22025 "[add | del <intfc | sw_if_index <id>>] via <addr | via-label <n>>\n" \
22026 "[<intfc> | sw_if_index <id> | next-hop-table <id>]\n" \
22027 "[l2-only] [out-label <n>]") \
22028 _(sr_mpls_policy_add, \
22029 "bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
22030 _(sr_mpls_policy_del, \
22032 _(bier_table_add_del, \
22033 "<label> <sub-domain> <set> <bsl> [del]") \
22034 _(bier_route_add_del, \
22035 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
22036 "[<intfc> | sw_if_index <id>]" \
22037 "[weight <n>] [del] [multipath]") \
22038 _(proxy_arp_add_del, \
22039 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
22040 _(proxy_arp_intfc_enable_disable, \
22041 "<intfc> | sw_if_index <id> enable | disable") \
22042 _(sw_interface_set_unnumbered, \
22043 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
22044 _(ip_neighbor_add_del, \
22045 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
22046 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
22047 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
22048 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
22049 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
22050 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
22051 "[outer_vlan_id_any][inner_vlan_id_any]") \
22052 _(reset_fib, "vrf <n> [ipv6]") \
22053 _(dhcp_proxy_config, \
22054 "svr <v46-address> src <v46-address>\n" \
22055 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
22056 _(dhcp_proxy_set_vss, \
22057 "tbl_id <n> [fib_id <n> oui <n> | vpn_ascii_id <text>] [ipv6] [del]") \
22058 _(dhcp_proxy_dump, "ip6") \
22059 _(dhcp_client_config, \
22060 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
22061 _(set_ip_flow_hash, \
22062 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
22063 _(sw_interface_ip6_enable_disable, \
22064 "<intfc> | sw_if_index <id> enable | disable") \
22065 _(ip6nd_proxy_add_del, \
22066 "<intfc> | sw_if_index <id> <ip6-address>") \
22067 _(ip6nd_proxy_dump, "") \
22068 _(sw_interface_ip6nd_ra_prefix, \
22069 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
22070 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
22071 "[nolink] [isno]") \
22072 _(sw_interface_ip6nd_ra_config, \
22073 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
22074 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
22075 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
22076 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
22077 _(l2_patch_add_del, \
22078 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
22079 "enable | disable") \
22080 _(sr_localsid_add_del, \
22081 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
22082 "fib-table <num> (end.psp) sw_if_index <num>") \
22083 _(classify_add_del_table, \
22084 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
22085 " [del] [del-chain] mask <mask-value>\n" \
22086 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
22087 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
22088 _(classify_add_del_session, \
22089 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
22090 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
22091 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
22092 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
22093 _(classify_set_interface_ip_table, \
22094 "<intfc> | sw_if_index <nn> table <nn>") \
22095 _(classify_set_interface_l2_tables, \
22096 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22097 " [other-table <nn>]") \
22098 _(get_node_index, "node <node-name") \
22099 _(add_node_next, "node <node-name> next <next-node-name>") \
22100 _(l2tpv3_create_tunnel, \
22101 "client_address <ip6-addr> our_address <ip6-addr>\n" \
22102 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
22103 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
22104 _(l2tpv3_set_tunnel_cookies, \
22105 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
22106 "[new_remote_cookie <nn>]\n") \
22107 _(l2tpv3_interface_enable_disable, \
22108 "<intfc> | sw_if_index <nn> enable | disable") \
22109 _(l2tpv3_set_lookup_key, \
22110 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
22111 _(sw_if_l2tpv3_tunnel_dump, "") \
22112 _(vxlan_offload_rx, \
22113 "hw { <interface name> | hw_if_index <nn>} " \
22114 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
22115 _(vxlan_add_del_tunnel, \
22116 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
22117 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
22118 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
22119 _(geneve_add_del_tunnel, \
22120 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
22121 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
22122 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
22123 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22124 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22125 _(gre_tunnel_add_del, \
22126 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
22127 "[teb | erspan <session-id>] [del]") \
22128 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22129 _(l2_fib_clear_table, "") \
22130 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
22131 _(l2_interface_vlan_tag_rewrite, \
22132 "<intfc> | sw_if_index <nn> \n" \
22133 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
22134 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
22135 _(create_vhost_user_if, \
22136 "socket <filename> [server] [renumber <dev_instance>] " \
22137 "[disable_mrg_rxbuf] [disable_indirect_desc] [gso] " \
22138 "[mac <mac_address>]") \
22139 _(modify_vhost_user_if, \
22140 "<intfc> | sw_if_index <nn> socket <filename>\n" \
22141 "[server] [renumber <dev_instance>] [gso]") \
22142 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
22143 _(sw_interface_vhost_user_dump, "") \
22144 _(show_version, "") \
22145 _(show_threads, "") \
22146 _(vxlan_gpe_add_del_tunnel, \
22147 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
22148 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
22149 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
22150 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
22151 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22152 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
22153 _(interface_name_renumber, \
22154 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
22155 _(input_acl_set_interface, \
22156 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22157 " [l2-table <nn>] [del]") \
22158 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
22159 _(ip_scan_neighbor_enable_disable, "[ip4|ip6|both|disable] [interval <n-min>]\n" \
22160 " [max-time <n-usec>] [max-update <n>] [delay <n-msec>] [stale <n-min>]") \
22161 _(want_ip4_arp_events, "address <ip4-address> [del]") \
22162 _(want_ip6_nd_events, "address <ip6-address> [del]") \
22163 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
22164 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
22165 _(ip_dump, "ipv4 | ipv6") \
22166 _(ipsec_spd_add_del, "spd_id <n> [del]") \
22167 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
22169 _(ipsec_sad_entry_add_del, "sad_id <n> spi <n> crypto_alg <alg>\n" \
22170 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
22171 " integ_alg <alg> integ_key <hex>") \
22172 _(ipsec_spd_entry_add_del, "spd_id <n> priority <n> action <action>\n" \
22173 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
22174 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
22175 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
22176 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
22177 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
22178 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
22179 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
22180 " [instance <n>]") \
22181 _(ipsec_sa_dump, "[sa_id <n>]") \
22182 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
22183 _(delete_loopback,"sw_if_index <nn>") \
22184 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
22185 _(bd_ip_mac_flush, "bd_id <bridge-domain-id>") \
22186 _(bd_ip_mac_dump, "[bd_id] <bridge-domain-id>") \
22187 _(want_interface_events, "enable|disable") \
22188 _(get_first_msg_id, "client <name>") \
22189 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
22190 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
22191 "fib-id <nn> [ip4][ip6][default]") \
22192 _(get_node_graph, " ") \
22193 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
22194 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
22195 _(ioam_disable, "") \
22196 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
22197 " sw_if_index <sw_if_index> p <priority> " \
22198 "w <weight>] [del]") \
22199 _(one_add_del_locator, "locator-set <locator_name> " \
22200 "iface <intf> | sw_if_index <sw_if_index> " \
22201 "p <priority> w <weight> [del]") \
22202 _(one_add_del_local_eid,"vni <vni> eid " \
22203 "<ipv4|ipv6>/<prefix> | <L2 address> " \
22204 "locator-set <locator_name> [del]" \
22205 "[key-id sha1|sha256 secret-key <secret-key>]")\
22206 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
22207 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
22208 _(one_enable_disable, "enable|disable") \
22209 _(one_map_register_enable_disable, "enable|disable") \
22210 _(one_map_register_fallback_threshold, "<value>") \
22211 _(one_rloc_probe_enable_disable, "enable|disable") \
22212 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
22214 "rloc <locator> p <prio> " \
22215 "w <weight> [rloc <loc> ... ] " \
22216 "action <action> [del-all]") \
22217 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
22219 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
22220 _(one_use_petr, "ip-address> | disable") \
22221 _(one_map_request_mode, "src-dst|dst-only") \
22222 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
22223 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
22224 _(one_locator_set_dump, "[local | remote]") \
22225 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
22226 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
22227 "[local] | [remote]") \
22228 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
22229 _(one_ndp_bd_get, "") \
22230 _(one_ndp_entries_get, "bd <bridge-domain>") \
22231 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
22232 _(one_l2_arp_bd_get, "") \
22233 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
22234 _(one_stats_enable_disable, "enable|disable") \
22235 _(show_one_stats_enable_disable, "") \
22236 _(one_eid_table_vni_dump, "") \
22237 _(one_eid_table_map_dump, "l2|l3") \
22238 _(one_map_resolver_dump, "") \
22239 _(one_map_server_dump, "") \
22240 _(one_adjacencies_get, "vni <vni>") \
22241 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
22242 _(show_one_rloc_probe_state, "") \
22243 _(show_one_map_register_state, "") \
22244 _(show_one_status, "") \
22245 _(one_stats_dump, "") \
22246 _(one_stats_flush, "") \
22247 _(one_get_map_request_itr_rlocs, "") \
22248 _(one_map_register_set_ttl, "<ttl>") \
22249 _(one_set_transport_protocol, "udp|api") \
22250 _(one_get_transport_protocol, "") \
22251 _(one_enable_disable_xtr_mode, "enable|disable") \
22252 _(one_show_xtr_mode, "") \
22253 _(one_enable_disable_pitr_mode, "enable|disable") \
22254 _(one_show_pitr_mode, "") \
22255 _(one_enable_disable_petr_mode, "enable|disable") \
22256 _(one_show_petr_mode, "") \
22257 _(show_one_nsh_mapping, "") \
22258 _(show_one_pitr, "") \
22259 _(show_one_use_petr, "") \
22260 _(show_one_map_request_mode, "") \
22261 _(show_one_map_register_ttl, "") \
22262 _(show_one_map_register_fallback_threshold, "") \
22263 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
22264 " sw_if_index <sw_if_index> p <priority> " \
22265 "w <weight>] [del]") \
22266 _(lisp_add_del_locator, "locator-set <locator_name> " \
22267 "iface <intf> | sw_if_index <sw_if_index> " \
22268 "p <priority> w <weight> [del]") \
22269 _(lisp_add_del_local_eid,"vni <vni> eid " \
22270 "<ipv4|ipv6>/<prefix> | <L2 address> " \
22271 "locator-set <locator_name> [del]" \
22272 "[key-id sha1|sha256 secret-key <secret-key>]") \
22273 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
22274 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
22275 _(lisp_enable_disable, "enable|disable") \
22276 _(lisp_map_register_enable_disable, "enable|disable") \
22277 _(lisp_rloc_probe_enable_disable, "enable|disable") \
22278 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
22280 "rloc <locator> p <prio> " \
22281 "w <weight> [rloc <loc> ... ] " \
22282 "action <action> [del-all]") \
22283 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
22285 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
22286 _(lisp_use_petr, "<ip-address> | disable") \
22287 _(lisp_map_request_mode, "src-dst|dst-only") \
22288 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
22289 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
22290 _(lisp_locator_set_dump, "[local | remote]") \
22291 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
22292 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
22293 "[local] | [remote]") \
22294 _(lisp_eid_table_vni_dump, "") \
22295 _(lisp_eid_table_map_dump, "l2|l3") \
22296 _(lisp_map_resolver_dump, "") \
22297 _(lisp_map_server_dump, "") \
22298 _(lisp_adjacencies_get, "vni <vni>") \
22299 _(gpe_fwd_entry_vnis_get, "") \
22300 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
22301 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
22302 "[table <table-id>]") \
22303 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
22304 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
22305 _(gpe_set_encap_mode, "lisp|vxlan") \
22306 _(gpe_get_encap_mode, "") \
22307 _(lisp_gpe_add_del_iface, "up|down") \
22308 _(lisp_gpe_enable_disable, "enable|disable") \
22309 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
22310 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
22311 _(show_lisp_rloc_probe_state, "") \
22312 _(show_lisp_map_register_state, "") \
22313 _(show_lisp_status, "") \
22314 _(lisp_get_map_request_itr_rlocs, "") \
22315 _(show_lisp_pitr, "") \
22316 _(show_lisp_use_petr, "") \
22317 _(show_lisp_map_request_mode, "") \
22318 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
22319 _(af_packet_delete, "name <host interface name>") \
22320 _(af_packet_dump, "") \
22321 _(policer_add_del, "name <policer name> <params> [del]") \
22322 _(policer_dump, "[name <policer name>]") \
22323 _(policer_classify_set_interface, \
22324 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22325 " [l2-table <nn>] [del]") \
22326 _(policer_classify_dump, "type [ip4|ip6|l2]") \
22327 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
22328 "[master|slave]") \
22329 _(netmap_delete, "name <interface name>") \
22330 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
22331 _(mpls_table_dump, "") \
22332 _(mpls_route_dump, "table-id <ID>") \
22333 _(classify_table_ids, "") \
22334 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
22335 _(classify_table_info, "table_id <nn>") \
22336 _(classify_session_dump, "table_id <nn>") \
22337 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
22338 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
22339 "[template_interval <nn>] [udp_checksum]") \
22340 _(ipfix_exporter_dump, "") \
22341 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
22342 _(ipfix_classify_stream_dump, "") \
22343 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
22344 _(ipfix_classify_table_dump, "") \
22345 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
22346 _(sw_interface_span_dump, "[l2]") \
22347 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
22348 _(pg_create_interface, "if_id <nn> [gso-enabled gso-size <size>]") \
22349 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
22350 _(pg_enable_disable, "[stream <id>] disable") \
22351 _(ip_source_and_port_range_check_add_del, \
22352 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
22353 _(ip_source_and_port_range_check_interface_add_del, \
22354 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
22355 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
22356 _(delete_subif,"<intfc> | sw_if_index <nn>") \
22357 _(l2_interface_pbb_tag_rewrite, \
22358 "<intfc> | sw_if_index <nn> \n" \
22359 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
22360 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
22361 _(set_punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
22362 _(flow_classify_set_interface, \
22363 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
22364 _(flow_classify_dump, "type [ip4|ip6]") \
22365 _(ip_table_dump, "") \
22366 _(ip_route_dump, "table-id [ip4|ip6]") \
22367 _(ip_mtable_dump, "") \
22368 _(ip_mroute_dump, "table-id [ip4|ip6]") \
22369 _(feature_enable_disable, "arc_name <arc_name> " \
22370 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
22371 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
22373 _(l2_xconnect_dump, "") \
22374 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
22375 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
22376 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
22377 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
22378 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
22379 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
22380 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
22381 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
22382 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
22383 _(sock_init_shm, "size <nnn>") \
22384 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
22385 _(dns_enable_disable, "[enable][disable]") \
22386 _(dns_name_server_add_del, "<ip-address> [del]") \
22387 _(dns_resolve_name, "<hostname>") \
22388 _(dns_resolve_ip, "<ip4|ip6>") \
22389 _(dns_name_server_add_del, "<ip-address> [del]") \
22390 _(dns_resolve_name, "<hostname>") \
22391 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
22392 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
22393 _(session_rules_dump, "") \
22394 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
22395 _(output_acl_set_interface, \
22396 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22397 " [l2-table <nn>] [del]") \
22398 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
22400 /* List of command functions, CLI names map directly to functions */
22401 #define foreach_cli_function \
22402 _(comment, "usage: comment <ignore-rest-of-line>") \
22403 _(dump_interface_table, "usage: dump_interface_table") \
22404 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
22405 _(dump_ipv4_table, "usage: dump_ipv4_table") \
22406 _(dump_ipv6_table, "usage: dump_ipv6_table") \
22407 _(dump_macro_table, "usage: dump_macro_table ") \
22408 _(dump_node_table, "usage: dump_node_table") \
22409 _(dump_msg_api_table, "usage: dump_msg_api_table") \
22410 _(elog_setup, "usage: elog_setup [nevents, default 128K]") \
22411 _(elog_disable, "usage: elog_disable") \
22412 _(elog_enable, "usage: elog_enable") \
22413 _(elog_save, "usage: elog_save <filename>") \
22414 _(get_msg_id, "usage: get_msg_id name_and_crc") \
22415 _(echo, "usage: echo <message>") \
22416 _(exec, "usage: exec <vpe-debug-CLI-command>") \
22417 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
22418 _(help, "usage: help") \
22419 _(q, "usage: quit") \
22420 _(quit, "usage: quit") \
22421 _(search_node_table, "usage: search_node_table <name>...") \
22422 _(set, "usage: set <variable-name> <value>") \
22423 _(script, "usage: script <file-name>") \
22424 _(statseg, "usage: statseg") \
22425 _(unset, "usage: unset <variable-name>")
22428 static void vl_api_##n##_t_handler_uni \
22429 (vl_api_##n##_t * mp) \
22431 vat_main_t * vam = &vat_main; \
22432 if (vam->json_output) { \
22433 vl_api_##n##_t_handler_json(mp); \
22435 vl_api_##n##_t_handler(mp); \
22438 foreach_vpe_api_reply_msg;
22439 #if VPP_API_TEST_BUILTIN == 0
22440 foreach_standalone_reply_msg;
22445 vat_api_hookup (vat_main_t * vam)
22448 vl_msg_api_set_handlers(VL_API_##N, #n, \
22449 vl_api_##n##_t_handler_uni, \
22451 vl_api_##n##_t_endian, \
22452 vl_api_##n##_t_print, \
22453 sizeof(vl_api_##n##_t), 1);
22454 foreach_vpe_api_reply_msg;
22455 #if VPP_API_TEST_BUILTIN == 0
22456 foreach_standalone_reply_msg;
22460 #if (VPP_API_TEST_BUILTIN==0)
22461 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
22463 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
22465 vam->function_by_name = hash_create_string (0, sizeof (uword));
22467 vam->help_by_name = hash_create_string (0, sizeof (uword));
22470 /* API messages we can send */
22471 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
22472 foreach_vpe_api_msg;
22476 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
22477 foreach_vpe_api_msg;
22480 /* CLI functions */
22481 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
22482 foreach_cli_function;
22486 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
22487 foreach_cli_function;
22491 #if VPP_API_TEST_BUILTIN
22492 static clib_error_t *
22493 vat_api_hookup_shim (vlib_main_t * vm)
22495 vat_api_hookup (&vat_main);
22499 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
22503 * fd.io coding-style-patch-verification: ON
22506 * eval: (c-set-style "gnu")