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;
7773 clib_memset (mac_address, 0, sizeof (mac_address));
7776 /* Parse args required to build the message */
7777 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7779 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
7781 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
7782 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
7784 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
7787 else if (unformat (i, "id %u", &id))
7793 if (mode_is_set == 0)
7795 errmsg ("Missing bond mode. ");
7799 /* Construct the API message */
7800 M (BOND_CREATE, mp);
7802 mp->use_custom_mac = custom_mac;
7806 mp->id = htonl (id);
7809 clib_memcpy (mp->mac_address, mac_address, 6);
7814 /* Wait for a reply... */
7820 api_bond_delete (vat_main_t * vam)
7822 unformat_input_t *i = vam->input;
7823 vl_api_bond_delete_t *mp;
7824 u32 sw_if_index = ~0;
7825 u8 sw_if_index_set = 0;
7828 /* Parse args required to build the message */
7829 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7831 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7832 sw_if_index_set = 1;
7833 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7834 sw_if_index_set = 1;
7839 if (sw_if_index_set == 0)
7841 errmsg ("missing vpp interface name. ");
7845 /* Construct the API message */
7846 M (BOND_DELETE, mp);
7848 mp->sw_if_index = ntohl (sw_if_index);
7853 /* Wait for a reply... */
7859 api_bond_enslave (vat_main_t * vam)
7861 unformat_input_t *i = vam->input;
7862 vl_api_bond_enslave_t *mp;
7863 u32 bond_sw_if_index;
7867 u32 bond_sw_if_index_is_set = 0;
7869 u8 sw_if_index_is_set = 0;
7871 /* Parse args required to build the message */
7872 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7874 if (unformat (i, "sw_if_index %d", &sw_if_index))
7875 sw_if_index_is_set = 1;
7876 else if (unformat (i, "bond %u", &bond_sw_if_index))
7877 bond_sw_if_index_is_set = 1;
7878 else if (unformat (i, "passive %d", &is_passive))
7880 else if (unformat (i, "long-timeout %d", &is_long_timeout))
7886 if (bond_sw_if_index_is_set == 0)
7888 errmsg ("Missing bond sw_if_index. ");
7891 if (sw_if_index_is_set == 0)
7893 errmsg ("Missing slave sw_if_index. ");
7897 /* Construct the API message */
7898 M (BOND_ENSLAVE, mp);
7900 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
7901 mp->sw_if_index = ntohl (sw_if_index);
7902 mp->is_long_timeout = is_long_timeout;
7903 mp->is_passive = is_passive;
7908 /* Wait for a reply... */
7914 api_bond_detach_slave (vat_main_t * vam)
7916 unformat_input_t *i = vam->input;
7917 vl_api_bond_detach_slave_t *mp;
7918 u32 sw_if_index = ~0;
7919 u8 sw_if_index_set = 0;
7922 /* Parse args required to build the message */
7923 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7925 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7926 sw_if_index_set = 1;
7927 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7928 sw_if_index_set = 1;
7933 if (sw_if_index_set == 0)
7935 errmsg ("missing vpp interface name. ");
7939 /* Construct the API message */
7940 M (BOND_DETACH_SLAVE, mp);
7942 mp->sw_if_index = ntohl (sw_if_index);
7947 /* Wait for a reply... */
7953 api_ip_table_add_del (vat_main_t * vam)
7955 unformat_input_t *i = vam->input;
7956 vl_api_ip_table_add_del_t *mp;
7962 /* Parse args required to build the message */
7963 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7965 if (unformat (i, "ipv6"))
7967 else if (unformat (i, "del"))
7969 else if (unformat (i, "add"))
7971 else if (unformat (i, "table %d", &table_id))
7975 clib_warning ("parse error '%U'", format_unformat_error, i);
7982 errmsg ("missing table-ID");
7986 /* Construct the API message */
7987 M (IP_TABLE_ADD_DEL, mp);
7989 mp->table.table_id = ntohl (table_id);
7990 mp->table.is_ip6 = is_ipv6;
7991 mp->is_add = is_add;
7996 /* Wait for a reply... */
8003 unformat_fib_path (unformat_input_t * input, va_list * args)
8005 vat_main_t *vam = va_arg (*args, vat_main_t *);
8006 vl_api_fib_path_t *path = va_arg (*args, vl_api_fib_path_t *);
8007 u32 weight, preference;
8008 mpls_label_t out_label;
8010 clib_memset (path, 0, sizeof (*path));
8012 path->sw_if_index = ~0;
8016 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8018 if (unformat (input, "%U %U",
8019 unformat_vl_api_ip4_address,
8020 &path->nh.address.ip4,
8021 api_unformat_sw_if_index, vam, &path->sw_if_index))
8023 path->proto = FIB_API_PATH_NH_PROTO_IP4;
8025 else if (unformat (input, "%U %U",
8026 unformat_vl_api_ip6_address,
8027 &path->nh.address.ip6,
8028 api_unformat_sw_if_index, vam, &path->sw_if_index))
8030 path->proto = FIB_API_PATH_NH_PROTO_IP6;
8032 else if (unformat (input, "weight %u", &weight))
8034 path->weight = weight;
8036 else if (unformat (input, "preference %u", &preference))
8038 path->preference = preference;
8040 else if (unformat (input, "%U next-hop-table %d",
8041 unformat_vl_api_ip4_address,
8042 &path->nh.address.ip4, &path->table_id))
8044 path->proto = FIB_API_PATH_NH_PROTO_IP4;
8046 else if (unformat (input, "%U next-hop-table %d",
8047 unformat_vl_api_ip6_address,
8048 &path->nh.address.ip6, &path->table_id))
8050 path->proto = FIB_API_PATH_NH_PROTO_IP6;
8052 else if (unformat (input, "%U",
8053 unformat_vl_api_ip4_address, &path->nh.address.ip4))
8056 * the recursive next-hops are by default in the default table
8059 path->sw_if_index = ~0;
8060 path->proto = FIB_API_PATH_NH_PROTO_IP4;
8062 else if (unformat (input, "%U",
8063 unformat_vl_api_ip6_address, &path->nh.address.ip6))
8066 * the recursive next-hops are by default in the default table
8069 path->sw_if_index = ~0;
8070 path->proto = FIB_API_PATH_NH_PROTO_IP6;
8072 else if (unformat (input, "resolve-via-host"))
8074 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_HOST;
8076 else if (unformat (input, "resolve-via-attached"))
8078 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED;
8080 else if (unformat (input, "ip4-lookup-in-table %d", &path->table_id))
8082 path->type = FIB_API_PATH_TYPE_LOCAL;
8083 path->sw_if_index = ~0;
8084 path->proto = FIB_API_PATH_NH_PROTO_IP4;
8086 else if (unformat (input, "ip6-lookup-in-table %d", &path->table_id))
8088 path->type = FIB_API_PATH_TYPE_LOCAL;
8089 path->sw_if_index = ~0;
8090 path->proto = FIB_API_PATH_NH_PROTO_IP6;
8092 else if (unformat (input, "sw_if_index %d", &path->sw_if_index))
8094 else if (unformat (input, "via-label %d", &path->nh.via_label))
8096 path->proto = FIB_API_PATH_NH_PROTO_MPLS;
8097 path->sw_if_index = ~0;
8099 else if (unformat (input, "l2-input-on %d", &path->sw_if_index))
8101 path->proto = FIB_API_PATH_NH_PROTO_ETHERNET;
8102 path->type = FIB_API_PATH_TYPE_INTERFACE_RX;
8104 else if (unformat (input, "local"))
8106 path->type = FIB_API_PATH_TYPE_LOCAL;
8108 else if (unformat (input, "out-labels"))
8110 while (unformat (input, "%d", &out_label))
8112 path->label_stack[path->n_labels].label = out_label;
8113 path->label_stack[path->n_labels].is_uniform = 0;
8114 path->label_stack[path->n_labels].ttl = 64;
8118 else if (unformat (input, "via"))
8120 /* new path, back up and return */
8121 unformat_put_input (input);
8122 unformat_put_input (input);
8123 unformat_put_input (input);
8124 unformat_put_input (input);
8133 path->proto = ntohl (path->proto);
8134 path->type = ntohl (path->type);
8135 path->flags = ntohl (path->flags);
8136 path->table_id = ntohl (path->table_id);
8137 path->sw_if_index = ntohl (path->sw_if_index);
8143 api_ip_route_add_del (vat_main_t * vam)
8145 unformat_input_t *i = vam->input;
8146 vl_api_ip_route_add_del_t *mp;
8149 u8 is_multipath = 0;
8152 vl_api_prefix_t pfx = { };
8153 vl_api_fib_path_t paths[8];
8157 u32 random_add_del = 0;
8158 u32 *random_vector = 0;
8159 u32 random_seed = 0xdeaddabe;
8161 /* Parse args required to build the message */
8162 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8164 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
8166 else if (unformat (i, "del"))
8168 else if (unformat (i, "add"))
8170 else if (unformat (i, "vrf %d", &vrf_id))
8172 else if (unformat (i, "count %d", &count))
8174 else if (unformat (i, "random"))
8176 else if (unformat (i, "multipath"))
8178 else if (unformat (i, "seed %d", &random_seed))
8182 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8185 if (8 == path_count)
8187 errmsg ("max 8 paths");
8193 clib_warning ("parse error '%U'", format_unformat_error, i);
8200 errmsg ("specify a path; via ...");
8203 if (prefix_set == 0)
8205 errmsg ("missing prefix");
8209 /* Generate a pile of unique, random routes */
8212 ip4_address_t *i = (ip4_address_t *) & paths[0].nh.address.ip4;
8213 u32 this_random_address;
8216 random_hash = hash_create (count, sizeof (uword));
8218 hash_set (random_hash, i->as_u32, 1);
8219 for (j = 0; j <= count; j++)
8223 this_random_address = random_u32 (&random_seed);
8224 this_random_address =
8225 clib_host_to_net_u32 (this_random_address);
8227 while (hash_get (random_hash, this_random_address));
8228 vec_add1 (random_vector, this_random_address);
8229 hash_set (random_hash, this_random_address, 1);
8231 hash_free (random_hash);
8232 set_ip4_address (&pfx.address, random_vector[0]);
8237 /* Turn on async mode */
8238 vam->async_mode = 1;
8239 vam->async_errors = 0;
8240 before = vat_time_now (vam);
8243 for (j = 0; j < count; j++)
8245 /* Construct the API message */
8246 M2 (IP_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8248 mp->is_add = is_add;
8249 mp->is_multipath = is_multipath;
8251 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
8252 mp->route.table_id = ntohl (vrf_id);
8253 mp->route.n_paths = path_count;
8255 clib_memcpy (&mp->route.paths, &paths, sizeof (paths[0]) * path_count);
8258 set_ip4_address (&pfx.address, random_vector[j + 1]);
8260 increment_address (&pfx.address);
8263 /* If we receive SIGTERM, stop now... */
8268 /* When testing multiple add/del ops, use a control-ping to sync */
8271 vl_api_control_ping_t *mp_ping;
8275 /* Shut off async mode */
8276 vam->async_mode = 0;
8278 MPING (CONTROL_PING, mp_ping);
8281 timeout = vat_time_now (vam) + 1.0;
8282 while (vat_time_now (vam) < timeout)
8283 if (vam->result_ready == 1)
8288 if (vam->retval == -99)
8291 if (vam->async_errors > 0)
8293 errmsg ("%d asynchronous errors", vam->async_errors);
8296 vam->async_errors = 0;
8297 after = vat_time_now (vam);
8299 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8303 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8304 count, after - before, count / (after - before));
8310 /* Wait for a reply... */
8315 /* Return the good/bad news */
8316 return (vam->retval);
8320 api_ip_mroute_add_del (vat_main_t * vam)
8322 unformat_input_t *i = vam->input;
8323 u8 path_set = 0, prefix_set = 0, is_add = 1;
8324 vl_api_ip_mroute_add_del_t *mp;
8325 mfib_entry_flags_t eflags = 0;
8326 vl_api_mfib_path_t path;
8327 vl_api_mprefix_t pfx = { };
8331 /* Parse args required to build the message */
8332 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8334 if (unformat (i, "%U", unformat_vl_api_mprefix, &pfx))
8337 pfx.grp_address_length = htons (pfx.grp_address_length);
8339 else if (unformat (i, "del"))
8341 else if (unformat (i, "add"))
8343 else if (unformat (i, "vrf %d", &vrf_id))
8345 else if (unformat (i, "%U", unformat_mfib_itf_flags, &path.itf_flags))
8346 path.itf_flags = htonl (path.itf_flags);
8347 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8349 else if (unformat (i, "via %U", unformat_fib_path, vam, &path.path))
8353 clib_warning ("parse error '%U'", format_unformat_error, i);
8358 if (prefix_set == 0)
8360 errmsg ("missing addresses\n");
8365 errmsg ("missing path\n");
8369 /* Construct the API message */
8370 M (IP_MROUTE_ADD_DEL, mp);
8372 mp->is_add = is_add;
8373 mp->is_multipath = 1;
8375 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
8376 mp->route.table_id = htonl (vrf_id);
8377 mp->route.n_paths = 1;
8378 mp->route.entry_flags = htonl (eflags);
8380 clib_memcpy (&mp->route.paths, &path, sizeof (path));
8384 /* Wait for a reply... */
8390 api_mpls_table_add_del (vat_main_t * vam)
8392 unformat_input_t *i = vam->input;
8393 vl_api_mpls_table_add_del_t *mp;
8398 /* Parse args required to build the message */
8399 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8401 if (unformat (i, "table %d", &table_id))
8403 else if (unformat (i, "del"))
8405 else if (unformat (i, "add"))
8409 clib_warning ("parse error '%U'", format_unformat_error, i);
8416 errmsg ("missing table-ID");
8420 /* Construct the API message */
8421 M (MPLS_TABLE_ADD_DEL, mp);
8423 mp->mt_table.mt_table_id = ntohl (table_id);
8424 mp->mt_is_add = is_add;
8429 /* Wait for a reply... */
8436 api_mpls_route_add_del (vat_main_t * vam)
8438 u8 is_add = 1, path_count = 0, is_multipath = 0, is_eos = 0;
8439 mpls_label_t local_label = MPLS_LABEL_INVALID;
8440 unformat_input_t *i = vam->input;
8441 vl_api_mpls_route_add_del_t *mp;
8442 vl_api_fib_path_t paths[8];
8446 /* Parse args required to build the message */
8447 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8449 if (unformat (i, "%d", &local_label))
8451 else if (unformat (i, "eos"))
8453 else if (unformat (i, "non-eos"))
8455 else if (unformat (i, "del"))
8457 else if (unformat (i, "add"))
8459 else if (unformat (i, "multipath"))
8461 else if (unformat (i, "count %d", &count))
8465 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8468 if (8 == path_count)
8470 errmsg ("max 8 paths");
8476 clib_warning ("parse error '%U'", format_unformat_error, i);
8483 errmsg ("specify a path; via ...");
8487 if (MPLS_LABEL_INVALID == local_label)
8489 errmsg ("missing label");
8495 /* Turn on async mode */
8496 vam->async_mode = 1;
8497 vam->async_errors = 0;
8498 before = vat_time_now (vam);
8501 for (j = 0; j < count; j++)
8503 /* Construct the API message */
8504 M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8506 mp->mr_is_add = is_add;
8507 mp->mr_is_multipath = is_multipath;
8509 mp->mr_route.mr_label = local_label;
8510 mp->mr_route.mr_eos = is_eos;
8511 mp->mr_route.mr_table_id = 0;
8512 mp->mr_route.mr_n_paths = path_count;
8514 clib_memcpy (&mp->mr_route.mr_paths, paths,
8515 sizeof (paths[0]) * path_count);
8521 /* If we receive SIGTERM, stop now... */
8526 /* When testing multiple add/del ops, use a control-ping to sync */
8529 vl_api_control_ping_t *mp_ping;
8533 /* Shut off async mode */
8534 vam->async_mode = 0;
8536 MPING (CONTROL_PING, mp_ping);
8539 timeout = vat_time_now (vam) + 1.0;
8540 while (vat_time_now (vam) < timeout)
8541 if (vam->result_ready == 1)
8546 if (vam->retval == -99)
8549 if (vam->async_errors > 0)
8551 errmsg ("%d asynchronous errors", vam->async_errors);
8554 vam->async_errors = 0;
8555 after = vat_time_now (vam);
8557 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8561 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8562 count, after - before, count / (after - before));
8568 /* Wait for a reply... */
8573 /* Return the good/bad news */
8574 return (vam->retval);
8579 api_mpls_ip_bind_unbind (vat_main_t * vam)
8581 unformat_input_t *i = vam->input;
8582 vl_api_mpls_ip_bind_unbind_t *mp;
8583 u32 ip_table_id = 0;
8585 vl_api_prefix_t pfx;
8587 mpls_label_t local_label = MPLS_LABEL_INVALID;
8590 /* Parse args required to build the message */
8591 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8593 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
8595 else if (unformat (i, "%d", &local_label))
8597 else if (unformat (i, "table-id %d", &ip_table_id))
8599 else if (unformat (i, "unbind"))
8601 else if (unformat (i, "bind"))
8605 clib_warning ("parse error '%U'", format_unformat_error, i);
8612 errmsg ("IP prefix not set");
8616 if (MPLS_LABEL_INVALID == local_label)
8618 errmsg ("missing label");
8622 /* Construct the API message */
8623 M (MPLS_IP_BIND_UNBIND, mp);
8625 mp->mb_is_bind = is_bind;
8626 mp->mb_ip_table_id = ntohl (ip_table_id);
8627 mp->mb_mpls_table_id = 0;
8628 mp->mb_label = ntohl (local_label);
8629 clib_memcpy (&mp->mb_prefix, &pfx, sizeof (pfx));
8634 /* Wait for a reply... */
8641 api_sr_mpls_policy_add (vat_main_t * vam)
8643 unformat_input_t *i = vam->input;
8644 vl_api_sr_mpls_policy_add_t *mp;
8650 u32 *segments = NULL;
8653 /* Parse args required to build the message */
8654 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8656 if (unformat (i, "bsid %d", &bsid))
8658 else if (unformat (i, "weight %d", &weight))
8660 else if (unformat (i, "spray"))
8662 else if (unformat (i, "next %d", &sid))
8665 vec_add1 (segments, htonl (sid));
8669 clib_warning ("parse error '%U'", format_unformat_error, i);
8676 errmsg ("bsid not set");
8680 if (n_segments == 0)
8682 errmsg ("no sid in segment stack");
8686 /* Construct the API message */
8687 M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
8689 mp->bsid = htonl (bsid);
8690 mp->weight = htonl (weight);
8692 mp->n_segments = n_segments;
8693 memcpy (mp->segments, segments, sizeof (u32) * n_segments);
8694 vec_free (segments);
8699 /* Wait for a reply... */
8705 api_sr_mpls_policy_del (vat_main_t * vam)
8707 unformat_input_t *i = vam->input;
8708 vl_api_sr_mpls_policy_del_t *mp;
8712 /* Parse args required to build the message */
8713 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8715 if (unformat (i, "bsid %d", &bsid))
8719 clib_warning ("parse error '%U'", format_unformat_error, i);
8726 errmsg ("bsid not set");
8730 /* Construct the API message */
8731 M (SR_MPLS_POLICY_DEL, mp);
8733 mp->bsid = htonl (bsid);
8738 /* Wait for a reply... */
8744 api_bier_table_add_del (vat_main_t * vam)
8746 unformat_input_t *i = vam->input;
8747 vl_api_bier_table_add_del_t *mp;
8749 u32 set = 0, sub_domain = 0, hdr_len = 3;
8750 mpls_label_t local_label = MPLS_LABEL_INVALID;
8753 /* Parse args required to build the message */
8754 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8756 if (unformat (i, "sub-domain %d", &sub_domain))
8758 else if (unformat (i, "set %d", &set))
8760 else if (unformat (i, "label %d", &local_label))
8762 else if (unformat (i, "hdr-len %d", &hdr_len))
8764 else if (unformat (i, "add"))
8766 else if (unformat (i, "del"))
8770 clib_warning ("parse error '%U'", format_unformat_error, i);
8775 if (MPLS_LABEL_INVALID == local_label)
8777 errmsg ("missing label\n");
8781 /* Construct the API message */
8782 M (BIER_TABLE_ADD_DEL, mp);
8784 mp->bt_is_add = is_add;
8785 mp->bt_label = ntohl (local_label);
8786 mp->bt_tbl_id.bt_set = set;
8787 mp->bt_tbl_id.bt_sub_domain = sub_domain;
8788 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
8793 /* Wait for a reply... */
8800 api_bier_route_add_del (vat_main_t * vam)
8802 unformat_input_t *i = vam->input;
8803 vl_api_bier_route_add_del_t *mp;
8805 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
8806 ip4_address_t v4_next_hop_address;
8807 ip6_address_t v6_next_hop_address;
8808 u8 next_hop_set = 0;
8809 u8 next_hop_proto_is_ip4 = 1;
8810 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8813 /* Parse args required to build the message */
8814 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8816 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
8818 next_hop_proto_is_ip4 = 1;
8821 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
8823 next_hop_proto_is_ip4 = 0;
8826 if (unformat (i, "sub-domain %d", &sub_domain))
8828 else if (unformat (i, "set %d", &set))
8830 else if (unformat (i, "hdr-len %d", &hdr_len))
8832 else if (unformat (i, "bp %d", &bp))
8834 else if (unformat (i, "add"))
8836 else if (unformat (i, "del"))
8838 else if (unformat (i, "out-label %d", &next_hop_out_label))
8842 clib_warning ("parse error '%U'", format_unformat_error, i);
8847 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
8849 errmsg ("next hop / label set\n");
8854 errmsg ("bit=position not set\n");
8858 /* Construct the API message */
8859 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
8861 mp->br_is_add = is_add;
8862 mp->br_route.br_tbl_id.bt_set = set;
8863 mp->br_route.br_tbl_id.bt_sub_domain = sub_domain;
8864 mp->br_route.br_tbl_id.bt_hdr_len_id = hdr_len;
8865 mp->br_route.br_bp = ntohs (bp);
8866 mp->br_route.br_n_paths = 1;
8867 mp->br_route.br_paths[0].n_labels = 1;
8868 mp->br_route.br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
8869 mp->br_route.br_paths[0].proto = (next_hop_proto_is_ip4 ?
8870 FIB_API_PATH_NH_PROTO_IP4 :
8871 FIB_API_PATH_NH_PROTO_IP6);
8873 if (next_hop_proto_is_ip4)
8875 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip4,
8876 &v4_next_hop_address, sizeof (v4_next_hop_address));
8880 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip6,
8881 &v6_next_hop_address, sizeof (v6_next_hop_address));
8887 /* Wait for a reply... */
8894 api_proxy_arp_add_del (vat_main_t * vam)
8896 unformat_input_t *i = vam->input;
8897 vl_api_proxy_arp_add_del_t *mp;
8900 vl_api_ip4_address_t lo, hi;
8904 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8906 if (unformat (i, "vrf %d", &vrf_id))
8908 else if (unformat (i, "%U - %U", unformat_vl_api_ip4_address, &lo,
8909 unformat_vl_api_ip4_address, &hi))
8911 else if (unformat (i, "del"))
8915 clib_warning ("parse error '%U'", format_unformat_error, i);
8922 errmsg ("address range not set");
8926 M (PROXY_ARP_ADD_DEL, mp);
8928 mp->proxy.table_id = ntohl (vrf_id);
8929 mp->is_add = is_add;
8930 clib_memcpy (mp->proxy.low, &lo, sizeof (lo));
8931 clib_memcpy (mp->proxy.hi, &hi, sizeof (hi));
8939 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
8941 unformat_input_t *i = vam->input;
8942 vl_api_proxy_arp_intfc_enable_disable_t *mp;
8945 u8 sw_if_index_set = 0;
8948 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8950 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8951 sw_if_index_set = 1;
8952 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8953 sw_if_index_set = 1;
8954 else if (unformat (i, "enable"))
8956 else if (unformat (i, "disable"))
8960 clib_warning ("parse error '%U'", format_unformat_error, i);
8965 if (sw_if_index_set == 0)
8967 errmsg ("missing interface name or sw_if_index");
8971 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
8973 mp->sw_if_index = ntohl (sw_if_index);
8974 mp->enable_disable = enable;
8982 api_mpls_tunnel_add_del (vat_main_t * vam)
8984 unformat_input_t *i = vam->input;
8985 vl_api_mpls_tunnel_add_del_t *mp;
8987 vl_api_fib_path_t paths[8];
8988 u32 sw_if_index = ~0;
8994 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8996 if (unformat (i, "add"))
9000 (i, "del %U", api_unformat_sw_if_index, vam, &sw_if_index))
9002 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
9004 else if (unformat (i, "l2-only"))
9008 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
9011 if (8 == path_count)
9013 errmsg ("max 8 paths");
9019 clib_warning ("parse error '%U'", format_unformat_error, i);
9024 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
9026 mp->mt_is_add = is_add;
9027 mp->mt_tunnel.mt_sw_if_index = ntohl (sw_if_index);
9028 mp->mt_tunnel.mt_l2_only = l2_only;
9029 mp->mt_tunnel.mt_is_multicast = 0;
9030 mp->mt_tunnel.mt_n_paths = path_count;
9032 clib_memcpy (&mp->mt_tunnel.mt_paths, &paths,
9033 sizeof (paths[0]) * path_count);
9041 api_sw_interface_set_unnumbered (vat_main_t * vam)
9043 unformat_input_t *i = vam->input;
9044 vl_api_sw_interface_set_unnumbered_t *mp;
9046 u32 unnum_sw_index = ~0;
9048 u8 sw_if_index_set = 0;
9051 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9053 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9054 sw_if_index_set = 1;
9055 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9056 sw_if_index_set = 1;
9057 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
9059 else if (unformat (i, "del"))
9063 clib_warning ("parse error '%U'", format_unformat_error, i);
9068 if (sw_if_index_set == 0)
9070 errmsg ("missing interface name or sw_if_index");
9074 M (SW_INTERFACE_SET_UNNUMBERED, mp);
9076 mp->sw_if_index = ntohl (sw_if_index);
9077 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
9078 mp->is_add = is_add;
9086 api_ip_neighbor_add_del (vat_main_t * vam)
9088 vl_api_mac_address_t mac_address;
9089 unformat_input_t *i = vam->input;
9090 vl_api_ip_neighbor_add_del_t *mp;
9091 vl_api_address_t ip_address;
9093 u8 sw_if_index_set = 0;
9098 ip_neighbor_flags_t flags;
9100 flags = IP_NEIGHBOR_FLAG_NONE;
9101 clib_memset (&ip_address, 0, sizeof (ip_address));
9102 clib_memset (&mac_address, 0, sizeof (mac_address));
9104 /* Parse args required to build the message */
9105 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9107 if (unformat (i, "mac %U", unformat_vl_api_mac_address, &mac_address))
9111 else if (unformat (i, "del"))
9114 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9115 sw_if_index_set = 1;
9116 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9117 sw_if_index_set = 1;
9118 else if (unformat (i, "static"))
9119 flags |= IP_NEIGHBOR_FLAG_STATIC;
9120 else if (unformat (i, "no-fib-entry"))
9121 flags |= IP_NEIGHBOR_FLAG_NO_FIB_ENTRY;
9122 else if (unformat (i, "dst %U", unformat_vl_api_address, &ip_address))
9126 clib_warning ("parse error '%U'", format_unformat_error, i);
9131 if (sw_if_index_set == 0)
9133 errmsg ("missing interface name or sw_if_index");
9138 errmsg ("no address set");
9142 /* Construct the API message */
9143 M (IP_NEIGHBOR_ADD_DEL, mp);
9145 mp->neighbor.sw_if_index = ntohl (sw_if_index);
9146 mp->is_add = is_add;
9147 mp->neighbor.flags = htonl (flags);
9149 clib_memcpy (&mp->neighbor.mac_address, &mac_address,
9150 sizeof (mac_address));
9152 clib_memcpy (&mp->neighbor.ip_address, &ip_address, sizeof (ip_address));
9157 /* Wait for a reply, return good/bad news */
9163 api_create_vlan_subif (vat_main_t * vam)
9165 unformat_input_t *i = vam->input;
9166 vl_api_create_vlan_subif_t *mp;
9168 u8 sw_if_index_set = 0;
9173 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9175 if (unformat (i, "sw_if_index %d", &sw_if_index))
9176 sw_if_index_set = 1;
9178 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9179 sw_if_index_set = 1;
9180 else if (unformat (i, "vlan %d", &vlan_id))
9184 clib_warning ("parse error '%U'", format_unformat_error, i);
9189 if (sw_if_index_set == 0)
9191 errmsg ("missing interface name or sw_if_index");
9195 if (vlan_id_set == 0)
9197 errmsg ("missing vlan_id");
9200 M (CREATE_VLAN_SUBIF, mp);
9202 mp->sw_if_index = ntohl (sw_if_index);
9203 mp->vlan_id = ntohl (vlan_id);
9210 #define foreach_create_subif_bit \
9217 _(outer_vlan_id_any) \
9218 _(inner_vlan_id_any)
9221 api_create_subif (vat_main_t * vam)
9223 unformat_input_t *i = vam->input;
9224 vl_api_create_subif_t *mp;
9226 u8 sw_if_index_set = 0;
9233 u32 exact_match = 0;
9234 u32 default_sub = 0;
9235 u32 outer_vlan_id_any = 0;
9236 u32 inner_vlan_id_any = 0;
9238 u16 outer_vlan_id = 0;
9239 u16 inner_vlan_id = 0;
9242 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9244 if (unformat (i, "sw_if_index %d", &sw_if_index))
9245 sw_if_index_set = 1;
9247 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9248 sw_if_index_set = 1;
9249 else if (unformat (i, "sub_id %d", &sub_id))
9251 else if (unformat (i, "outer_vlan_id %d", &tmp))
9252 outer_vlan_id = tmp;
9253 else if (unformat (i, "inner_vlan_id %d", &tmp))
9254 inner_vlan_id = tmp;
9256 #define _(a) else if (unformat (i, #a)) a = 1 ;
9257 foreach_create_subif_bit
9261 clib_warning ("parse error '%U'", format_unformat_error, i);
9266 if (sw_if_index_set == 0)
9268 errmsg ("missing interface name or sw_if_index");
9272 if (sub_id_set == 0)
9274 errmsg ("missing sub_id");
9277 M (CREATE_SUBIF, mp);
9279 mp->sw_if_index = ntohl (sw_if_index);
9280 mp->sub_id = ntohl (sub_id);
9282 #define _(a) mp->a = a;
9283 foreach_create_subif_bit;
9286 mp->outer_vlan_id = ntohs (outer_vlan_id);
9287 mp->inner_vlan_id = ntohs (inner_vlan_id);
9295 api_reset_fib (vat_main_t * vam)
9297 unformat_input_t *i = vam->input;
9298 vl_api_reset_fib_t *mp;
9304 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9306 if (unformat (i, "vrf %d", &vrf_id))
9308 else if (unformat (i, "ipv6"))
9312 clib_warning ("parse error '%U'", format_unformat_error, i);
9317 if (vrf_id_set == 0)
9319 errmsg ("missing vrf id");
9325 mp->vrf_id = ntohl (vrf_id);
9326 mp->is_ipv6 = is_ipv6;
9334 api_dhcp_proxy_config (vat_main_t * vam)
9336 unformat_input_t *i = vam->input;
9337 vl_api_dhcp_proxy_config_t *mp;
9339 u32 server_vrf_id = 0;
9341 u8 v4_address_set = 0;
9342 u8 v6_address_set = 0;
9343 ip4_address_t v4address;
9344 ip6_address_t v6address;
9345 u8 v4_src_address_set = 0;
9346 u8 v6_src_address_set = 0;
9347 ip4_address_t v4srcaddress;
9348 ip6_address_t v6srcaddress;
9351 /* Parse args required to build the message */
9352 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9354 if (unformat (i, "del"))
9356 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
9358 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
9360 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
9362 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
9364 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
9365 v4_src_address_set = 1;
9366 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
9367 v6_src_address_set = 1;
9372 if (v4_address_set && v6_address_set)
9374 errmsg ("both v4 and v6 server addresses set");
9377 if (!v4_address_set && !v6_address_set)
9379 errmsg ("no server addresses set");
9383 if (v4_src_address_set && v6_src_address_set)
9385 errmsg ("both v4 and v6 src addresses set");
9388 if (!v4_src_address_set && !v6_src_address_set)
9390 errmsg ("no src addresses set");
9394 if (!(v4_src_address_set && v4_address_set) &&
9395 !(v6_src_address_set && v6_address_set))
9397 errmsg ("no matching server and src addresses set");
9401 /* Construct the API message */
9402 M (DHCP_PROXY_CONFIG, mp);
9404 mp->is_add = is_add;
9405 mp->rx_vrf_id = ntohl (rx_vrf_id);
9406 mp->server_vrf_id = ntohl (server_vrf_id);
9410 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
9411 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
9415 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
9416 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
9422 /* Wait for a reply, return good/bad news */
9427 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
9428 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
9431 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
9433 vat_main_t *vam = &vat_main;
9434 u32 i, count = mp->count;
9435 vl_api_dhcp_server_t *s;
9439 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9440 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9441 ntohl (mp->rx_vrf_id),
9442 format_ip6_address, mp->dhcp_src_address,
9443 mp->vss_type, mp->vss_vpn_ascii_id,
9444 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9447 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9448 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9449 ntohl (mp->rx_vrf_id),
9450 format_ip4_address, mp->dhcp_src_address,
9451 mp->vss_type, mp->vss_vpn_ascii_id,
9452 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9454 for (i = 0; i < count; i++)
9456 s = &mp->servers[i];
9460 " Server Table-ID %d, Server Address %U",
9461 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
9464 " Server Table-ID %d, Server Address %U",
9465 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
9469 static void vl_api_dhcp_proxy_details_t_handler_json
9470 (vl_api_dhcp_proxy_details_t * mp)
9472 vat_main_t *vam = &vat_main;
9473 vat_json_node_t *node = NULL;
9474 u32 i, count = mp->count;
9476 struct in6_addr ip6;
9477 vl_api_dhcp_server_t *s;
9479 if (VAT_JSON_ARRAY != vam->json_tree.type)
9481 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9482 vat_json_init_array (&vam->json_tree);
9484 node = vat_json_array_add (&vam->json_tree);
9486 vat_json_init_object (node);
9487 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
9488 vat_json_object_add_bytes (node, "vss-type", &mp->vss_type,
9489 sizeof (mp->vss_type));
9490 vat_json_object_add_string_copy (node, "vss-vpn-ascii-id",
9491 mp->vss_vpn_ascii_id);
9492 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
9493 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
9497 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
9498 vat_json_object_add_ip6 (node, "src_address", ip6);
9502 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
9503 vat_json_object_add_ip4 (node, "src_address", ip4);
9506 for (i = 0; i < count; i++)
9508 s = &mp->servers[i];
9510 vat_json_object_add_uint (node, "server-table-id",
9511 ntohl (s->server_vrf_id));
9515 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
9516 vat_json_object_add_ip4 (node, "src_address", ip4);
9520 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
9521 vat_json_object_add_ip6 (node, "server_address", ip6);
9527 api_dhcp_proxy_dump (vat_main_t * vam)
9529 unformat_input_t *i = vam->input;
9530 vl_api_control_ping_t *mp_ping;
9531 vl_api_dhcp_proxy_dump_t *mp;
9535 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9537 if (unformat (i, "ipv6"))
9541 clib_warning ("parse error '%U'", format_unformat_error, i);
9546 M (DHCP_PROXY_DUMP, mp);
9548 mp->is_ip6 = is_ipv6;
9551 /* Use a control ping for synchronization */
9552 MPING (CONTROL_PING, mp_ping);
9560 api_dhcp_proxy_set_vss (vat_main_t * vam)
9562 unformat_input_t *i = vam->input;
9563 vl_api_dhcp_proxy_set_vss_t *mp;
9567 u8 vss_type = VSS_TYPE_DEFAULT;
9568 u8 *vpn_ascii_id = 0;
9573 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9575 if (unformat (i, "tbl_id %d", &tbl_id))
9577 else if (unformat (i, "vpn_ascii_id %s", &vpn_ascii_id))
9578 vss_type = VSS_TYPE_ASCII;
9579 else if (unformat (i, "fib_id %d", &fib_id))
9580 vss_type = VSS_TYPE_VPN_ID;
9581 else if (unformat (i, "oui %d", &oui))
9582 vss_type = VSS_TYPE_VPN_ID;
9583 else if (unformat (i, "ipv6"))
9585 else if (unformat (i, "del"))
9593 errmsg ("missing tbl_id ");
9594 vec_free (vpn_ascii_id);
9598 if ((vpn_ascii_id) && (vec_len (vpn_ascii_id) > 128))
9600 errmsg ("vpn_ascii_id cannot be longer than 128 ");
9601 vec_free (vpn_ascii_id);
9605 M (DHCP_PROXY_SET_VSS, mp);
9606 mp->tbl_id = ntohl (tbl_id);
9607 mp->vss_type = vss_type;
9610 clib_memcpy (mp->vpn_ascii_id, vpn_ascii_id, vec_len (vpn_ascii_id));
9611 mp->vpn_ascii_id[vec_len (vpn_ascii_id)] = 0;
9613 mp->vpn_index = ntohl (fib_id);
9614 mp->oui = ntohl (oui);
9615 mp->is_ipv6 = is_ipv6;
9616 mp->is_add = is_add;
9621 vec_free (vpn_ascii_id);
9626 api_dhcp_client_config (vat_main_t * vam)
9628 unformat_input_t *i = vam->input;
9629 vl_api_dhcp_client_config_t *mp;
9631 u8 sw_if_index_set = 0;
9634 u8 disable_event = 0;
9637 /* Parse args required to build the message */
9638 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9640 if (unformat (i, "del"))
9643 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9644 sw_if_index_set = 1;
9645 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9646 sw_if_index_set = 1;
9647 else if (unformat (i, "hostname %s", &hostname))
9649 else if (unformat (i, "disable_event"))
9655 if (sw_if_index_set == 0)
9657 errmsg ("missing interface name or sw_if_index");
9661 if (vec_len (hostname) > 63)
9663 errmsg ("hostname too long");
9665 vec_add1 (hostname, 0);
9667 /* Construct the API message */
9668 M (DHCP_CLIENT_CONFIG, mp);
9670 mp->is_add = is_add;
9671 mp->client.sw_if_index = htonl (sw_if_index);
9672 clib_memcpy (mp->client.hostname, hostname, vec_len (hostname));
9673 vec_free (hostname);
9674 mp->client.want_dhcp_event = disable_event ? 0 : 1;
9675 mp->client.pid = htonl (getpid ());
9680 /* Wait for a reply, return good/bad news */
9686 api_set_ip_flow_hash (vat_main_t * vam)
9688 unformat_input_t *i = vam->input;
9689 vl_api_set_ip_flow_hash_t *mp;
9701 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9703 if (unformat (i, "vrf %d", &vrf_id))
9705 else if (unformat (i, "ipv6"))
9707 else if (unformat (i, "src"))
9709 else if (unformat (i, "dst"))
9711 else if (unformat (i, "sport"))
9713 else if (unformat (i, "dport"))
9715 else if (unformat (i, "proto"))
9717 else if (unformat (i, "reverse"))
9722 clib_warning ("parse error '%U'", format_unformat_error, i);
9727 if (vrf_id_set == 0)
9729 errmsg ("missing vrf id");
9733 M (SET_IP_FLOW_HASH, mp);
9739 mp->reverse = reverse;
9740 mp->vrf_id = ntohl (vrf_id);
9741 mp->is_ipv6 = is_ipv6;
9749 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
9751 unformat_input_t *i = vam->input;
9752 vl_api_sw_interface_ip6_enable_disable_t *mp;
9754 u8 sw_if_index_set = 0;
9758 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9760 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9761 sw_if_index_set = 1;
9762 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9763 sw_if_index_set = 1;
9764 else if (unformat (i, "enable"))
9766 else if (unformat (i, "disable"))
9770 clib_warning ("parse error '%U'", format_unformat_error, i);
9775 if (sw_if_index_set == 0)
9777 errmsg ("missing interface name or sw_if_index");
9781 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
9783 mp->sw_if_index = ntohl (sw_if_index);
9784 mp->enable = enable;
9792 api_ip6nd_proxy_add_del (vat_main_t * vam)
9794 unformat_input_t *i = vam->input;
9795 vl_api_ip6nd_proxy_add_del_t *mp;
9796 u32 sw_if_index = ~0;
9797 u8 v6_address_set = 0;
9798 vl_api_ip6_address_t v6address;
9802 /* Parse args required to build the message */
9803 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9805 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9807 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9809 else if (unformat (i, "%U", unformat_vl_api_ip6_address, &v6address))
9811 if (unformat (i, "del"))
9815 clib_warning ("parse error '%U'", format_unformat_error, i);
9820 if (sw_if_index == ~0)
9822 errmsg ("missing interface name or sw_if_index");
9825 if (!v6_address_set)
9827 errmsg ("no address set");
9831 /* Construct the API message */
9832 M (IP6ND_PROXY_ADD_DEL, mp);
9834 mp->is_del = is_del;
9835 mp->sw_if_index = ntohl (sw_if_index);
9836 clib_memcpy (mp->ip, v6address, sizeof (v6address));
9841 /* Wait for a reply, return good/bad news */
9847 api_ip6nd_proxy_dump (vat_main_t * vam)
9849 vl_api_ip6nd_proxy_dump_t *mp;
9850 vl_api_control_ping_t *mp_ping;
9853 M (IP6ND_PROXY_DUMP, mp);
9857 /* Use a control ping for synchronization */
9858 MPING (CONTROL_PING, mp_ping);
9865 static void vl_api_ip6nd_proxy_details_t_handler
9866 (vl_api_ip6nd_proxy_details_t * mp)
9868 vat_main_t *vam = &vat_main;
9870 print (vam->ofp, "host %U sw_if_index %d",
9871 format_vl_api_ip6_address, mp->ip, ntohl (mp->sw_if_index));
9874 static void vl_api_ip6nd_proxy_details_t_handler_json
9875 (vl_api_ip6nd_proxy_details_t * mp)
9877 vat_main_t *vam = &vat_main;
9878 struct in6_addr ip6;
9879 vat_json_node_t *node = NULL;
9881 if (VAT_JSON_ARRAY != vam->json_tree.type)
9883 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9884 vat_json_init_array (&vam->json_tree);
9886 node = vat_json_array_add (&vam->json_tree);
9888 vat_json_init_object (node);
9889 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9891 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
9892 vat_json_object_add_ip6 (node, "host", ip6);
9896 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
9898 unformat_input_t *i = vam->input;
9899 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
9901 u8 sw_if_index_set = 0;
9902 u8 v6_address_set = 0;
9903 vl_api_prefix_t pfx;
9905 u8 no_advertise = 0;
9907 u8 no_autoconfig = 0;
9910 u32 val_lifetime = 0;
9911 u32 pref_lifetime = 0;
9914 /* Parse args required to build the message */
9915 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9917 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9918 sw_if_index_set = 1;
9919 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9920 sw_if_index_set = 1;
9921 else if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
9923 else if (unformat (i, "val_life %d", &val_lifetime))
9925 else if (unformat (i, "pref_life %d", &pref_lifetime))
9927 else if (unformat (i, "def"))
9929 else if (unformat (i, "noadv"))
9931 else if (unformat (i, "offl"))
9933 else if (unformat (i, "noauto"))
9935 else if (unformat (i, "nolink"))
9937 else if (unformat (i, "isno"))
9941 clib_warning ("parse error '%U'", format_unformat_error, i);
9946 if (sw_if_index_set == 0)
9948 errmsg ("missing interface name or sw_if_index");
9951 if (!v6_address_set)
9953 errmsg ("no address set");
9957 /* Construct the API message */
9958 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
9960 mp->sw_if_index = ntohl (sw_if_index);
9961 clib_memcpy (&mp->prefix, &pfx, sizeof (pfx));
9962 mp->use_default = use_default;
9963 mp->no_advertise = no_advertise;
9964 mp->off_link = off_link;
9965 mp->no_autoconfig = no_autoconfig;
9966 mp->no_onlink = no_onlink;
9968 mp->val_lifetime = ntohl (val_lifetime);
9969 mp->pref_lifetime = ntohl (pref_lifetime);
9974 /* Wait for a reply, return good/bad news */
9980 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
9982 unformat_input_t *i = vam->input;
9983 vl_api_sw_interface_ip6nd_ra_config_t *mp;
9985 u8 sw_if_index_set = 0;
9990 u8 send_unicast = 0;
9993 u8 default_router = 0;
9994 u32 max_interval = 0;
9995 u32 min_interval = 0;
9997 u32 initial_count = 0;
9998 u32 initial_interval = 0;
10002 /* Parse args required to build the message */
10003 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10005 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10006 sw_if_index_set = 1;
10007 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10008 sw_if_index_set = 1;
10009 else if (unformat (i, "maxint %d", &max_interval))
10011 else if (unformat (i, "minint %d", &min_interval))
10013 else if (unformat (i, "life %d", &lifetime))
10015 else if (unformat (i, "count %d", &initial_count))
10017 else if (unformat (i, "interval %d", &initial_interval))
10019 else if (unformat (i, "suppress") || unformat (i, "surpress"))
10021 else if (unformat (i, "managed"))
10023 else if (unformat (i, "other"))
10025 else if (unformat (i, "ll"))
10027 else if (unformat (i, "send"))
10029 else if (unformat (i, "cease"))
10031 else if (unformat (i, "isno"))
10033 else if (unformat (i, "def"))
10034 default_router = 1;
10037 clib_warning ("parse error '%U'", format_unformat_error, i);
10042 if (sw_if_index_set == 0)
10044 errmsg ("missing interface name or sw_if_index");
10048 /* Construct the API message */
10049 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
10051 mp->sw_if_index = ntohl (sw_if_index);
10052 mp->max_interval = ntohl (max_interval);
10053 mp->min_interval = ntohl (min_interval);
10054 mp->lifetime = ntohl (lifetime);
10055 mp->initial_count = ntohl (initial_count);
10056 mp->initial_interval = ntohl (initial_interval);
10057 mp->suppress = suppress;
10058 mp->managed = managed;
10060 mp->ll_option = ll_option;
10061 mp->send_unicast = send_unicast;
10064 mp->default_router = default_router;
10069 /* Wait for a reply, return good/bad news */
10075 api_set_arp_neighbor_limit (vat_main_t * vam)
10077 unformat_input_t *i = vam->input;
10078 vl_api_set_arp_neighbor_limit_t *mp;
10084 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10086 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
10088 else if (unformat (i, "ipv6"))
10092 clib_warning ("parse error '%U'", format_unformat_error, i);
10097 if (limit_set == 0)
10099 errmsg ("missing limit value");
10103 M (SET_ARP_NEIGHBOR_LIMIT, mp);
10105 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
10106 mp->is_ipv6 = is_ipv6;
10114 api_l2_patch_add_del (vat_main_t * vam)
10116 unformat_input_t *i = vam->input;
10117 vl_api_l2_patch_add_del_t *mp;
10118 u32 rx_sw_if_index;
10119 u8 rx_sw_if_index_set = 0;
10120 u32 tx_sw_if_index;
10121 u8 tx_sw_if_index_set = 0;
10125 /* Parse args required to build the message */
10126 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10128 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
10129 rx_sw_if_index_set = 1;
10130 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
10131 tx_sw_if_index_set = 1;
10132 else if (unformat (i, "rx"))
10134 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10136 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10138 rx_sw_if_index_set = 1;
10143 else if (unformat (i, "tx"))
10145 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10147 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10149 tx_sw_if_index_set = 1;
10154 else if (unformat (i, "del"))
10160 if (rx_sw_if_index_set == 0)
10162 errmsg ("missing rx interface name or rx_sw_if_index");
10166 if (tx_sw_if_index_set == 0)
10168 errmsg ("missing tx interface name or tx_sw_if_index");
10172 M (L2_PATCH_ADD_DEL, mp);
10174 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
10175 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
10176 mp->is_add = is_add;
10184 u8 localsid_addr[16];
10193 api_sr_localsid_add_del (vat_main_t * vam)
10195 unformat_input_t *i = vam->input;
10196 vl_api_sr_localsid_add_del_t *mp;
10199 ip6_address_t localsid;
10203 u32 fib_table = ~(u32) 0;
10204 ip6_address_t nh_addr6;
10205 ip4_address_t nh_addr4;
10206 clib_memset (&nh_addr6, 0, sizeof (ip6_address_t));
10207 clib_memset (&nh_addr4, 0, sizeof (ip4_address_t));
10209 bool nexthop_set = 0;
10213 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10215 if (unformat (i, "del"))
10217 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
10218 else if (unformat (i, "next-hop %U", unformat_ip4_address, &nh_addr4))
10220 else if (unformat (i, "next-hop %U", unformat_ip6_address, &nh_addr6))
10222 else if (unformat (i, "behavior %u", &behavior));
10223 else if (unformat (i, "sw_if_index %u", &sw_if_index));
10224 else if (unformat (i, "fib-table %u", &fib_table));
10225 else if (unformat (i, "end.psp %u", &behavior));
10230 M (SR_LOCALSID_ADD_DEL, mp);
10232 clib_memcpy (mp->localsid.addr, &localsid, sizeof (mp->localsid));
10235 clib_memcpy (mp->nh_addr6, &nh_addr6, sizeof (mp->nh_addr6));
10236 clib_memcpy (mp->nh_addr4, &nh_addr4, sizeof (mp->nh_addr4));
10238 mp->behavior = behavior;
10239 mp->sw_if_index = ntohl (sw_if_index);
10240 mp->fib_table = ntohl (fib_table);
10241 mp->end_psp = end_psp;
10242 mp->is_del = is_del;
10250 api_ioam_enable (vat_main_t * vam)
10252 unformat_input_t *input = vam->input;
10253 vl_api_ioam_enable_t *mp;
10255 int has_trace_option = 0;
10256 int has_pot_option = 0;
10257 int has_seqno_option = 0;
10258 int has_analyse_option = 0;
10261 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10263 if (unformat (input, "trace"))
10264 has_trace_option = 1;
10265 else if (unformat (input, "pot"))
10266 has_pot_option = 1;
10267 else if (unformat (input, "seqno"))
10268 has_seqno_option = 1;
10269 else if (unformat (input, "analyse"))
10270 has_analyse_option = 1;
10274 M (IOAM_ENABLE, mp);
10275 mp->id = htons (id);
10276 mp->seqno = has_seqno_option;
10277 mp->analyse = has_analyse_option;
10278 mp->pot_enable = has_pot_option;
10279 mp->trace_enable = has_trace_option;
10288 api_ioam_disable (vat_main_t * vam)
10290 vl_api_ioam_disable_t *mp;
10293 M (IOAM_DISABLE, mp);
10299 #define foreach_tcp_proto_field \
10303 #define foreach_udp_proto_field \
10307 #define foreach_ip4_proto_field \
10319 u16 src_port, dst_port;
10322 #if VPP_API_TEST_BUILTIN == 0
10324 unformat_tcp_mask (unformat_input_t * input, va_list * args)
10326 u8 **maskp = va_arg (*args, u8 **);
10328 u8 found_something = 0;
10331 #define _(a) u8 a=0;
10332 foreach_tcp_proto_field;
10335 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10338 #define _(a) else if (unformat (input, #a)) a=1;
10339 foreach_tcp_proto_field
10345 #define _(a) found_something += a;
10346 foreach_tcp_proto_field;
10349 if (found_something == 0)
10352 vec_validate (mask, sizeof (*tcp) - 1);
10354 tcp = (tcp_header_t *) mask;
10356 #define _(a) if (a) clib_memset (&tcp->a, 0xff, sizeof (tcp->a));
10357 foreach_tcp_proto_field;
10365 unformat_udp_mask (unformat_input_t * input, va_list * args)
10367 u8 **maskp = va_arg (*args, u8 **);
10369 u8 found_something = 0;
10372 #define _(a) u8 a=0;
10373 foreach_udp_proto_field;
10376 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10379 #define _(a) else if (unformat (input, #a)) a=1;
10380 foreach_udp_proto_field
10386 #define _(a) found_something += a;
10387 foreach_udp_proto_field;
10390 if (found_something == 0)
10393 vec_validate (mask, sizeof (*udp) - 1);
10395 udp = (udp_header_t *) mask;
10397 #define _(a) if (a) clib_memset (&udp->a, 0xff, sizeof (udp->a));
10398 foreach_udp_proto_field;
10406 unformat_l4_mask (unformat_input_t * input, va_list * args)
10408 u8 **maskp = va_arg (*args, u8 **);
10409 u16 src_port = 0, dst_port = 0;
10410 tcpudp_header_t *tcpudp;
10412 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10414 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
10416 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
10418 else if (unformat (input, "src_port"))
10420 else if (unformat (input, "dst_port"))
10426 if (!src_port && !dst_port)
10430 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
10432 tcpudp = (tcpudp_header_t *) mask;
10433 tcpudp->src_port = src_port;
10434 tcpudp->dst_port = dst_port;
10442 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10444 u8 **maskp = va_arg (*args, u8 **);
10446 u8 found_something = 0;
10449 #define _(a) u8 a=0;
10450 foreach_ip4_proto_field;
10456 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10458 if (unformat (input, "version"))
10460 else if (unformat (input, "hdr_length"))
10462 else if (unformat (input, "src"))
10464 else if (unformat (input, "dst"))
10466 else if (unformat (input, "proto"))
10469 #define _(a) else if (unformat (input, #a)) a=1;
10470 foreach_ip4_proto_field
10476 #define _(a) found_something += a;
10477 foreach_ip4_proto_field;
10480 if (found_something == 0)
10483 vec_validate (mask, sizeof (*ip) - 1);
10485 ip = (ip4_header_t *) mask;
10487 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
10488 foreach_ip4_proto_field;
10491 ip->ip_version_and_header_length = 0;
10494 ip->ip_version_and_header_length |= 0xF0;
10497 ip->ip_version_and_header_length |= 0x0F;
10503 #define foreach_ip6_proto_field \
10506 _(payload_length) \
10511 unformat_ip6_mask (unformat_input_t * input, va_list * args)
10513 u8 **maskp = va_arg (*args, u8 **);
10515 u8 found_something = 0;
10517 u32 ip_version_traffic_class_and_flow_label;
10519 #define _(a) u8 a=0;
10520 foreach_ip6_proto_field;
10523 u8 traffic_class = 0;
10526 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10528 if (unformat (input, "version"))
10530 else if (unformat (input, "traffic-class"))
10532 else if (unformat (input, "flow-label"))
10534 else if (unformat (input, "src"))
10536 else if (unformat (input, "dst"))
10538 else if (unformat (input, "proto"))
10541 #define _(a) else if (unformat (input, #a)) a=1;
10542 foreach_ip6_proto_field
10548 #define _(a) found_something += a;
10549 foreach_ip6_proto_field;
10552 if (found_something == 0)
10555 vec_validate (mask, sizeof (*ip) - 1);
10557 ip = (ip6_header_t *) mask;
10559 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
10560 foreach_ip6_proto_field;
10563 ip_version_traffic_class_and_flow_label = 0;
10566 ip_version_traffic_class_and_flow_label |= 0xF0000000;
10569 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
10572 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
10574 ip->ip_version_traffic_class_and_flow_label =
10575 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10582 unformat_l3_mask (unformat_input_t * input, va_list * args)
10584 u8 **maskp = va_arg (*args, u8 **);
10586 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10588 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
10590 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
10599 unformat_l2_mask (unformat_input_t * input, va_list * args)
10601 u8 **maskp = va_arg (*args, u8 **);
10608 u8 ignore_tag1 = 0;
10609 u8 ignore_tag2 = 0;
10616 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10618 if (unformat (input, "src"))
10620 else if (unformat (input, "dst"))
10622 else if (unformat (input, "proto"))
10624 else if (unformat (input, "tag1"))
10626 else if (unformat (input, "tag2"))
10628 else if (unformat (input, "ignore-tag1"))
10630 else if (unformat (input, "ignore-tag2"))
10632 else if (unformat (input, "cos1"))
10634 else if (unformat (input, "cos2"))
10636 else if (unformat (input, "dot1q"))
10638 else if (unformat (input, "dot1ad"))
10643 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
10644 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10647 if (tag1 || ignore_tag1 || cos1 || dot1q)
10649 if (tag2 || ignore_tag2 || cos2 || dot1ad)
10652 vec_validate (mask, len - 1);
10655 clib_memset (mask, 0xff, 6);
10658 clib_memset (mask + 6, 0xff, 6);
10660 if (tag2 || dot1ad)
10662 /* inner vlan tag */
10671 mask[21] = mask[20] = 0xff;
10692 mask[16] = mask[17] = 0xff;
10702 mask[12] = mask[13] = 0xff;
10709 unformat_classify_mask (unformat_input_t * input, va_list * args)
10711 u8 **maskp = va_arg (*args, u8 **);
10712 u32 *skipp = va_arg (*args, u32 *);
10713 u32 *matchp = va_arg (*args, u32 *);
10721 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10723 if (unformat (input, "hex %U", unformat_hex_string, &mask))
10725 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
10727 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
10729 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
10743 if (mask || l2 || l3 || l4)
10745 if (l2 || l3 || l4)
10747 /* "With a free Ethernet header in every package" */
10749 vec_validate (l2, 13);
10753 vec_append (mask, l3);
10758 vec_append (mask, l4);
10763 /* Scan forward looking for the first significant mask octet */
10764 for (i = 0; i < vec_len (mask); i++)
10768 /* compute (skip, match) params */
10769 *skipp = i / sizeof (u32x4);
10770 vec_delete (mask, *skipp * sizeof (u32x4), 0);
10772 /* Pad mask to an even multiple of the vector size */
10773 while (vec_len (mask) % sizeof (u32x4))
10774 vec_add1 (mask, 0);
10776 match = vec_len (mask) / sizeof (u32x4);
10778 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
10780 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
10781 if (*tmp || *(tmp + 1))
10786 clib_warning ("BUG: match 0");
10788 _vec_len (mask) = match * sizeof (u32x4);
10798 #endif /* VPP_API_TEST_BUILTIN */
10800 #define foreach_l2_next \
10802 _(ethernet, ETHERNET_INPUT) \
10803 _(ip4, IP4_INPUT) \
10807 unformat_l2_next_index (unformat_input_t * input, va_list * args)
10809 u32 *miss_next_indexp = va_arg (*args, u32 *);
10810 u32 next_index = 0;
10814 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
10818 if (unformat (input, "%d", &tmp))
10827 *miss_next_indexp = next_index;
10831 #define foreach_ip_next \
10834 _(rewrite, REWRITE)
10837 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
10839 u32 *miss_next_indexp = va_arg (*args, u32 *);
10840 u32 next_index = 0;
10844 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
10848 if (unformat (input, "%d", &tmp))
10857 *miss_next_indexp = next_index;
10861 #define foreach_acl_next \
10865 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
10867 u32 *miss_next_indexp = va_arg (*args, u32 *);
10868 u32 next_index = 0;
10872 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
10876 if (unformat (input, "permit"))
10881 else if (unformat (input, "%d", &tmp))
10890 *miss_next_indexp = next_index;
10895 unformat_policer_precolor (unformat_input_t * input, va_list * args)
10897 u32 *r = va_arg (*args, u32 *);
10899 if (unformat (input, "conform-color"))
10900 *r = POLICE_CONFORM;
10901 else if (unformat (input, "exceed-color"))
10902 *r = POLICE_EXCEED;
10910 api_classify_add_del_table (vat_main_t * vam)
10912 unformat_input_t *i = vam->input;
10913 vl_api_classify_add_del_table_t *mp;
10920 u32 table_index = ~0;
10921 u32 next_table_index = ~0;
10922 u32 miss_next_index = ~0;
10923 u32 memory_size = 32 << 20;
10925 u32 current_data_flag = 0;
10926 int current_data_offset = 0;
10929 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10931 if (unformat (i, "del"))
10933 else if (unformat (i, "del-chain"))
10938 else if (unformat (i, "buckets %d", &nbuckets))
10940 else if (unformat (i, "memory_size %d", &memory_size))
10942 else if (unformat (i, "skip %d", &skip))
10944 else if (unformat (i, "match %d", &match))
10946 else if (unformat (i, "table %d", &table_index))
10948 else if (unformat (i, "mask %U", unformat_classify_mask,
10949 &mask, &skip, &match))
10951 else if (unformat (i, "next-table %d", &next_table_index))
10953 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
10956 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
10959 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
10962 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
10964 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
10970 if (is_add && mask == 0)
10972 errmsg ("Mask required");
10976 if (is_add && skip == ~0)
10978 errmsg ("skip count required");
10982 if (is_add && match == ~0)
10984 errmsg ("match count required");
10988 if (!is_add && table_index == ~0)
10990 errmsg ("table index required for delete");
10994 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
10996 mp->is_add = is_add;
10997 mp->del_chain = del_chain;
10998 mp->table_index = ntohl (table_index);
10999 mp->nbuckets = ntohl (nbuckets);
11000 mp->memory_size = ntohl (memory_size);
11001 mp->skip_n_vectors = ntohl (skip);
11002 mp->match_n_vectors = ntohl (match);
11003 mp->next_table_index = ntohl (next_table_index);
11004 mp->miss_next_index = ntohl (miss_next_index);
11005 mp->current_data_flag = ntohl (current_data_flag);
11006 mp->current_data_offset = ntohl (current_data_offset);
11007 mp->mask_len = ntohl (vec_len (mask));
11008 clib_memcpy (mp->mask, mask, vec_len (mask));
11017 #if VPP_API_TEST_BUILTIN == 0
11019 unformat_l4_match (unformat_input_t * input, va_list * args)
11021 u8 **matchp = va_arg (*args, u8 **);
11023 u8 *proto_header = 0;
11029 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11031 if (unformat (input, "src_port %d", &src_port))
11033 else if (unformat (input, "dst_port %d", &dst_port))
11039 h.src_port = clib_host_to_net_u16 (src_port);
11040 h.dst_port = clib_host_to_net_u16 (dst_port);
11041 vec_validate (proto_header, sizeof (h) - 1);
11042 memcpy (proto_header, &h, sizeof (h));
11044 *matchp = proto_header;
11050 unformat_ip4_match (unformat_input_t * input, va_list * args)
11052 u8 **matchp = va_arg (*args, u8 **);
11057 int hdr_length = 0;
11058 u32 hdr_length_val;
11059 int src = 0, dst = 0;
11060 ip4_address_t src_val, dst_val;
11067 int fragment_id = 0;
11068 u32 fragment_id_val;
11074 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11076 if (unformat (input, "version %d", &version_val))
11078 else if (unformat (input, "hdr_length %d", &hdr_length_val))
11080 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
11082 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
11084 else if (unformat (input, "proto %d", &proto_val))
11086 else if (unformat (input, "tos %d", &tos_val))
11088 else if (unformat (input, "length %d", &length_val))
11090 else if (unformat (input, "fragment_id %d", &fragment_id_val))
11092 else if (unformat (input, "ttl %d", &ttl_val))
11094 else if (unformat (input, "checksum %d", &checksum_val))
11100 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
11101 + ttl + checksum == 0)
11105 * Aligned because we use the real comparison functions
11107 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11109 ip = (ip4_header_t *) match;
11111 /* These are realistically matched in practice */
11113 ip->src_address.as_u32 = src_val.as_u32;
11116 ip->dst_address.as_u32 = dst_val.as_u32;
11119 ip->protocol = proto_val;
11122 /* These are not, but they're included for completeness */
11124 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
11127 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
11133 ip->length = clib_host_to_net_u16 (length_val);
11139 ip->checksum = clib_host_to_net_u16 (checksum_val);
11146 unformat_ip6_match (unformat_input_t * input, va_list * args)
11148 u8 **matchp = va_arg (*args, u8 **);
11153 u8 traffic_class = 0;
11154 u32 traffic_class_val = 0;
11157 int src = 0, dst = 0;
11158 ip6_address_t src_val, dst_val;
11161 int payload_length = 0;
11162 u32 payload_length_val;
11165 u32 ip_version_traffic_class_and_flow_label;
11167 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11169 if (unformat (input, "version %d", &version_val))
11171 else if (unformat (input, "traffic_class %d", &traffic_class_val))
11173 else if (unformat (input, "flow_label %d", &flow_label_val))
11175 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
11177 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
11179 else if (unformat (input, "proto %d", &proto_val))
11181 else if (unformat (input, "payload_length %d", &payload_length_val))
11182 payload_length = 1;
11183 else if (unformat (input, "hop_limit %d", &hop_limit_val))
11189 if (version + traffic_class + flow_label + src + dst + proto +
11190 payload_length + hop_limit == 0)
11194 * Aligned because we use the real comparison functions
11196 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11198 ip = (ip6_header_t *) match;
11201 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
11204 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
11207 ip->protocol = proto_val;
11209 ip_version_traffic_class_and_flow_label = 0;
11212 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
11215 ip_version_traffic_class_and_flow_label |=
11216 (traffic_class_val & 0xFF) << 20;
11219 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
11221 ip->ip_version_traffic_class_and_flow_label =
11222 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11224 if (payload_length)
11225 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
11228 ip->hop_limit = hop_limit_val;
11235 unformat_l3_match (unformat_input_t * input, va_list * args)
11237 u8 **matchp = va_arg (*args, u8 **);
11239 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11241 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
11243 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
11252 unformat_vlan_tag (unformat_input_t * input, va_list * args)
11254 u8 *tagp = va_arg (*args, u8 *);
11257 if (unformat (input, "%d", &tag))
11259 tagp[0] = (tag >> 8) & 0x0F;
11260 tagp[1] = tag & 0xFF;
11268 unformat_l2_match (unformat_input_t * input, va_list * args)
11270 u8 **matchp = va_arg (*args, u8 **);
11283 u8 ignore_tag1 = 0;
11284 u8 ignore_tag2 = 0;
11290 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11292 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
11295 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
11297 else if (unformat (input, "proto %U",
11298 unformat_ethernet_type_host_byte_order, &proto_val))
11300 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
11302 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
11304 else if (unformat (input, "ignore-tag1"))
11306 else if (unformat (input, "ignore-tag2"))
11308 else if (unformat (input, "cos1 %d", &cos1_val))
11310 else if (unformat (input, "cos2 %d", &cos2_val))
11315 if ((src + dst + proto + tag1 + tag2 +
11316 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11319 if (tag1 || ignore_tag1 || cos1)
11321 if (tag2 || ignore_tag2 || cos2)
11324 vec_validate_aligned (match, len - 1, sizeof (u32x4));
11327 clib_memcpy (match, dst_val, 6);
11330 clib_memcpy (match + 6, src_val, 6);
11334 /* inner vlan tag */
11335 match[19] = tag2_val[1];
11336 match[18] = tag2_val[0];
11338 match[18] |= (cos2_val & 0x7) << 5;
11341 match[21] = proto_val & 0xff;
11342 match[20] = proto_val >> 8;
11346 match[15] = tag1_val[1];
11347 match[14] = tag1_val[0];
11350 match[14] |= (cos1_val & 0x7) << 5;
11356 match[15] = tag1_val[1];
11357 match[14] = tag1_val[0];
11360 match[17] = proto_val & 0xff;
11361 match[16] = proto_val >> 8;
11364 match[14] |= (cos1_val & 0x7) << 5;
11370 match[18] |= (cos2_val & 0x7) << 5;
11372 match[14] |= (cos1_val & 0x7) << 5;
11375 match[13] = proto_val & 0xff;
11376 match[12] = proto_val >> 8;
11384 unformat_qos_source (unformat_input_t * input, va_list * args)
11386 int *qs = va_arg (*args, int *);
11388 if (unformat (input, "ip"))
11389 *qs = QOS_SOURCE_IP;
11390 else if (unformat (input, "mpls"))
11391 *qs = QOS_SOURCE_MPLS;
11392 else if (unformat (input, "ext"))
11393 *qs = QOS_SOURCE_EXT;
11394 else if (unformat (input, "vlan"))
11395 *qs = QOS_SOURCE_VLAN;
11404 api_unformat_classify_match (unformat_input_t * input, va_list * args)
11406 u8 **matchp = va_arg (*args, u8 **);
11407 u32 skip_n_vectors = va_arg (*args, u32);
11408 u32 match_n_vectors = va_arg (*args, u32);
11415 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11417 if (unformat (input, "hex %U", unformat_hex_string, &match))
11419 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
11421 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
11423 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11437 if (match || l2 || l3 || l4)
11439 if (l2 || l3 || l4)
11441 /* "Win a free Ethernet header in every packet" */
11443 vec_validate_aligned (l2, 13, sizeof (u32x4));
11447 vec_append_aligned (match, l3, sizeof (u32x4));
11452 vec_append_aligned (match, l4, sizeof (u32x4));
11457 /* Make sure the vector is big enough even if key is all 0's */
11458 vec_validate_aligned
11459 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11462 /* Set size, include skipped vectors */
11463 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11474 api_classify_add_del_session (vat_main_t * vam)
11476 unformat_input_t *i = vam->input;
11477 vl_api_classify_add_del_session_t *mp;
11479 u32 table_index = ~0;
11480 u32 hit_next_index = ~0;
11481 u32 opaque_index = ~0;
11484 u32 skip_n_vectors = 0;
11485 u32 match_n_vectors = 0;
11491 * Warning: you have to supply skip_n and match_n
11492 * because the API client cant simply look at the classify
11496 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11498 if (unformat (i, "del"))
11500 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
11503 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
11506 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
11509 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
11511 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
11513 else if (unformat (i, "opaque-index %d", &opaque_index))
11515 else if (unformat (i, "skip_n %d", &skip_n_vectors))
11517 else if (unformat (i, "match_n %d", &match_n_vectors))
11519 else if (unformat (i, "match %U", api_unformat_classify_match,
11520 &match, skip_n_vectors, match_n_vectors))
11522 else if (unformat (i, "advance %d", &advance))
11524 else if (unformat (i, "table-index %d", &table_index))
11526 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
11528 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
11530 else if (unformat (i, "action %d", &action))
11532 else if (unformat (i, "metadata %d", &metadata))
11538 if (table_index == ~0)
11540 errmsg ("Table index required");
11544 if (is_add && match == 0)
11546 errmsg ("Match value required");
11550 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
11552 mp->is_add = is_add;
11553 mp->table_index = ntohl (table_index);
11554 mp->hit_next_index = ntohl (hit_next_index);
11555 mp->opaque_index = ntohl (opaque_index);
11556 mp->advance = ntohl (advance);
11557 mp->action = action;
11558 mp->metadata = ntohl (metadata);
11559 mp->match_len = ntohl (vec_len (match));
11560 clib_memcpy (mp->match, match, vec_len (match));
11569 api_classify_set_interface_ip_table (vat_main_t * vam)
11571 unformat_input_t *i = vam->input;
11572 vl_api_classify_set_interface_ip_table_t *mp;
11574 int sw_if_index_set;
11575 u32 table_index = ~0;
11579 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11581 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11582 sw_if_index_set = 1;
11583 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11584 sw_if_index_set = 1;
11585 else if (unformat (i, "table %d", &table_index))
11589 clib_warning ("parse error '%U'", format_unformat_error, i);
11594 if (sw_if_index_set == 0)
11596 errmsg ("missing interface name or sw_if_index");
11601 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
11603 mp->sw_if_index = ntohl (sw_if_index);
11604 mp->table_index = ntohl (table_index);
11605 mp->is_ipv6 = is_ipv6;
11613 api_classify_set_interface_l2_tables (vat_main_t * vam)
11615 unformat_input_t *i = vam->input;
11616 vl_api_classify_set_interface_l2_tables_t *mp;
11618 int sw_if_index_set;
11619 u32 ip4_table_index = ~0;
11620 u32 ip6_table_index = ~0;
11621 u32 other_table_index = ~0;
11625 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11627 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11628 sw_if_index_set = 1;
11629 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11630 sw_if_index_set = 1;
11631 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11633 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11635 else if (unformat (i, "other-table %d", &other_table_index))
11637 else if (unformat (i, "is-input %d", &is_input))
11641 clib_warning ("parse error '%U'", format_unformat_error, i);
11646 if (sw_if_index_set == 0)
11648 errmsg ("missing interface name or sw_if_index");
11653 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
11655 mp->sw_if_index = ntohl (sw_if_index);
11656 mp->ip4_table_index = ntohl (ip4_table_index);
11657 mp->ip6_table_index = ntohl (ip6_table_index);
11658 mp->other_table_index = ntohl (other_table_index);
11659 mp->is_input = (u8) is_input;
11667 api_set_ipfix_exporter (vat_main_t * vam)
11669 unformat_input_t *i = vam->input;
11670 vl_api_set_ipfix_exporter_t *mp;
11671 ip4_address_t collector_address;
11672 u8 collector_address_set = 0;
11673 u32 collector_port = ~0;
11674 ip4_address_t src_address;
11675 u8 src_address_set = 0;
11678 u32 template_interval = ~0;
11679 u8 udp_checksum = 0;
11682 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11684 if (unformat (i, "collector_address %U", unformat_ip4_address,
11685 &collector_address))
11686 collector_address_set = 1;
11687 else if (unformat (i, "collector_port %d", &collector_port))
11689 else if (unformat (i, "src_address %U", unformat_ip4_address,
11691 src_address_set = 1;
11692 else if (unformat (i, "vrf_id %d", &vrf_id))
11694 else if (unformat (i, "path_mtu %d", &path_mtu))
11696 else if (unformat (i, "template_interval %d", &template_interval))
11698 else if (unformat (i, "udp_checksum"))
11704 if (collector_address_set == 0)
11706 errmsg ("collector_address required");
11710 if (src_address_set == 0)
11712 errmsg ("src_address required");
11716 M (SET_IPFIX_EXPORTER, mp);
11718 memcpy (mp->collector_address, collector_address.data,
11719 sizeof (collector_address.data));
11720 mp->collector_port = htons ((u16) collector_port);
11721 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
11722 mp->vrf_id = htonl (vrf_id);
11723 mp->path_mtu = htonl (path_mtu);
11724 mp->template_interval = htonl (template_interval);
11725 mp->udp_checksum = udp_checksum;
11733 api_set_ipfix_classify_stream (vat_main_t * vam)
11735 unformat_input_t *i = vam->input;
11736 vl_api_set_ipfix_classify_stream_t *mp;
11738 u32 src_port = UDP_DST_PORT_ipfix;
11741 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11743 if (unformat (i, "domain %d", &domain_id))
11745 else if (unformat (i, "src_port %d", &src_port))
11749 errmsg ("unknown input `%U'", format_unformat_error, i);
11754 M (SET_IPFIX_CLASSIFY_STREAM, mp);
11756 mp->domain_id = htonl (domain_id);
11757 mp->src_port = htons ((u16) src_port);
11765 api_ipfix_classify_table_add_del (vat_main_t * vam)
11767 unformat_input_t *i = vam->input;
11768 vl_api_ipfix_classify_table_add_del_t *mp;
11770 u32 classify_table_index = ~0;
11772 u8 transport_protocol = 255;
11775 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11777 if (unformat (i, "add"))
11779 else if (unformat (i, "del"))
11781 else if (unformat (i, "table %d", &classify_table_index))
11783 else if (unformat (i, "ip4"))
11785 else if (unformat (i, "ip6"))
11787 else if (unformat (i, "tcp"))
11788 transport_protocol = 6;
11789 else if (unformat (i, "udp"))
11790 transport_protocol = 17;
11793 errmsg ("unknown input `%U'", format_unformat_error, i);
11800 errmsg ("expecting: add|del");
11803 if (classify_table_index == ~0)
11805 errmsg ("classifier table not specified");
11808 if (ip_version == 0)
11810 errmsg ("IP version not specified");
11814 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
11816 mp->is_add = is_add;
11817 mp->table_id = htonl (classify_table_index);
11818 mp->ip_version = ip_version;
11819 mp->transport_protocol = transport_protocol;
11827 api_get_node_index (vat_main_t * vam)
11829 unformat_input_t *i = vam->input;
11830 vl_api_get_node_index_t *mp;
11834 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11836 if (unformat (i, "node %s", &name))
11843 errmsg ("node name required");
11846 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11848 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11852 M (GET_NODE_INDEX, mp);
11853 clib_memcpy (mp->node_name, name, vec_len (name));
11862 api_get_next_index (vat_main_t * vam)
11864 unformat_input_t *i = vam->input;
11865 vl_api_get_next_index_t *mp;
11866 u8 *node_name = 0, *next_node_name = 0;
11869 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11871 if (unformat (i, "node-name %s", &node_name))
11873 else if (unformat (i, "next-node-name %s", &next_node_name))
11877 if (node_name == 0)
11879 errmsg ("node name required");
11882 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
11884 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11888 if (next_node_name == 0)
11890 errmsg ("next node name required");
11893 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
11895 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
11899 M (GET_NEXT_INDEX, mp);
11900 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
11901 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
11902 vec_free (node_name);
11903 vec_free (next_node_name);
11911 api_add_node_next (vat_main_t * vam)
11913 unformat_input_t *i = vam->input;
11914 vl_api_add_node_next_t *mp;
11919 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11921 if (unformat (i, "node %s", &name))
11923 else if (unformat (i, "next %s", &next))
11930 errmsg ("node name required");
11933 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11935 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11940 errmsg ("next node required");
11943 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
11945 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
11949 M (ADD_NODE_NEXT, mp);
11950 clib_memcpy (mp->node_name, name, vec_len (name));
11951 clib_memcpy (mp->next_name, next, vec_len (next));
11961 api_l2tpv3_create_tunnel (vat_main_t * vam)
11963 unformat_input_t *i = vam->input;
11964 ip6_address_t client_address, our_address;
11965 int client_address_set = 0;
11966 int our_address_set = 0;
11967 u32 local_session_id = 0;
11968 u32 remote_session_id = 0;
11969 u64 local_cookie = 0;
11970 u64 remote_cookie = 0;
11971 u8 l2_sublayer_present = 0;
11972 vl_api_l2tpv3_create_tunnel_t *mp;
11975 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11977 if (unformat (i, "client_address %U", unformat_ip6_address,
11979 client_address_set = 1;
11980 else if (unformat (i, "our_address %U", unformat_ip6_address,
11982 our_address_set = 1;
11983 else if (unformat (i, "local_session_id %d", &local_session_id))
11985 else if (unformat (i, "remote_session_id %d", &remote_session_id))
11987 else if (unformat (i, "local_cookie %lld", &local_cookie))
11989 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
11991 else if (unformat (i, "l2-sublayer-present"))
11992 l2_sublayer_present = 1;
11997 if (client_address_set == 0)
11999 errmsg ("client_address required");
12003 if (our_address_set == 0)
12005 errmsg ("our_address required");
12009 M (L2TPV3_CREATE_TUNNEL, mp);
12011 clib_memcpy (mp->client_address, client_address.as_u8,
12012 sizeof (mp->client_address));
12014 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
12016 mp->local_session_id = ntohl (local_session_id);
12017 mp->remote_session_id = ntohl (remote_session_id);
12018 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
12019 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
12020 mp->l2_sublayer_present = l2_sublayer_present;
12029 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
12031 unformat_input_t *i = vam->input;
12033 u8 sw_if_index_set = 0;
12034 u64 new_local_cookie = 0;
12035 u64 new_remote_cookie = 0;
12036 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
12039 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12041 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12042 sw_if_index_set = 1;
12043 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12044 sw_if_index_set = 1;
12045 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
12047 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
12053 if (sw_if_index_set == 0)
12055 errmsg ("missing interface name or sw_if_index");
12059 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
12061 mp->sw_if_index = ntohl (sw_if_index);
12062 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
12063 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
12071 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
12073 unformat_input_t *i = vam->input;
12074 vl_api_l2tpv3_interface_enable_disable_t *mp;
12076 u8 sw_if_index_set = 0;
12077 u8 enable_disable = 1;
12080 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12082 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12083 sw_if_index_set = 1;
12084 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12085 sw_if_index_set = 1;
12086 else if (unformat (i, "enable"))
12087 enable_disable = 1;
12088 else if (unformat (i, "disable"))
12089 enable_disable = 0;
12094 if (sw_if_index_set == 0)
12096 errmsg ("missing interface name or sw_if_index");
12100 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
12102 mp->sw_if_index = ntohl (sw_if_index);
12103 mp->enable_disable = enable_disable;
12111 api_l2tpv3_set_lookup_key (vat_main_t * vam)
12113 unformat_input_t *i = vam->input;
12114 vl_api_l2tpv3_set_lookup_key_t *mp;
12118 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12120 if (unformat (i, "lookup_v6_src"))
12121 key = L2T_LOOKUP_SRC_ADDRESS;
12122 else if (unformat (i, "lookup_v6_dst"))
12123 key = L2T_LOOKUP_DST_ADDRESS;
12124 else if (unformat (i, "lookup_session_id"))
12125 key = L2T_LOOKUP_SESSION_ID;
12130 if (key == (u8) ~ 0)
12132 errmsg ("l2tp session lookup key unset");
12136 M (L2TPV3_SET_LOOKUP_KEY, mp);
12145 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
12146 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12148 vat_main_t *vam = &vat_main;
12150 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
12151 format_ip6_address, mp->our_address,
12152 format_ip6_address, mp->client_address,
12153 clib_net_to_host_u32 (mp->sw_if_index));
12156 " local cookies %016llx %016llx remote cookie %016llx",
12157 clib_net_to_host_u64 (mp->local_cookie[0]),
12158 clib_net_to_host_u64 (mp->local_cookie[1]),
12159 clib_net_to_host_u64 (mp->remote_cookie));
12161 print (vam->ofp, " local session-id %d remote session-id %d",
12162 clib_net_to_host_u32 (mp->local_session_id),
12163 clib_net_to_host_u32 (mp->remote_session_id));
12165 print (vam->ofp, " l2 specific sublayer %s\n",
12166 mp->l2_sublayer_present ? "preset" : "absent");
12170 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
12171 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12173 vat_main_t *vam = &vat_main;
12174 vat_json_node_t *node = NULL;
12175 struct in6_addr addr;
12177 if (VAT_JSON_ARRAY != vam->json_tree.type)
12179 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12180 vat_json_init_array (&vam->json_tree);
12182 node = vat_json_array_add (&vam->json_tree);
12184 vat_json_init_object (node);
12186 clib_memcpy (&addr, mp->our_address, sizeof (addr));
12187 vat_json_object_add_ip6 (node, "our_address", addr);
12188 clib_memcpy (&addr, mp->client_address, sizeof (addr));
12189 vat_json_object_add_ip6 (node, "client_address", addr);
12191 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
12192 vat_json_init_array (lc);
12193 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
12194 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
12195 vat_json_object_add_uint (node, "remote_cookie",
12196 clib_net_to_host_u64 (mp->remote_cookie));
12198 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
12199 vat_json_object_add_uint (node, "local_session_id",
12200 clib_net_to_host_u32 (mp->local_session_id));
12201 vat_json_object_add_uint (node, "remote_session_id",
12202 clib_net_to_host_u32 (mp->remote_session_id));
12203 vat_json_object_add_string_copy (node, "l2_sublayer",
12204 mp->l2_sublayer_present ? (u8 *) "present"
12205 : (u8 *) "absent");
12209 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
12211 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
12212 vl_api_control_ping_t *mp_ping;
12215 /* Get list of l2tpv3-tunnel interfaces */
12216 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
12219 /* Use a control ping for synchronization */
12220 MPING (CONTROL_PING, mp_ping);
12228 static void vl_api_sw_interface_tap_v2_details_t_handler
12229 (vl_api_sw_interface_tap_v2_details_t * mp)
12231 vat_main_t *vam = &vat_main;
12233 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
12234 mp->host_ip4_prefix_len);
12235 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
12236 mp->host_ip6_prefix_len);
12239 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s 0x%-08x",
12240 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
12241 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12242 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
12243 mp->host_bridge, ip4, ip6, ntohl (mp->tap_flags));
12249 static void vl_api_sw_interface_tap_v2_details_t_handler_json
12250 (vl_api_sw_interface_tap_v2_details_t * mp)
12252 vat_main_t *vam = &vat_main;
12253 vat_json_node_t *node = NULL;
12255 if (VAT_JSON_ARRAY != vam->json_tree.type)
12257 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12258 vat_json_init_array (&vam->json_tree);
12260 node = vat_json_array_add (&vam->json_tree);
12262 vat_json_init_object (node);
12263 vat_json_object_add_uint (node, "id", ntohl (mp->id));
12264 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12265 vat_json_object_add_uint (node, "tap_flags", ntohl (mp->tap_flags));
12266 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12267 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12268 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12269 vat_json_object_add_string_copy (node, "host_mac_addr",
12270 format (0, "%U", format_ethernet_address,
12271 &mp->host_mac_addr));
12272 vat_json_object_add_string_copy (node, "host_namespace",
12273 mp->host_namespace);
12274 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
12275 vat_json_object_add_string_copy (node, "host_ip4_addr",
12276 format (0, "%U/%d", format_ip4_address,
12278 mp->host_ip4_prefix_len));
12279 vat_json_object_add_string_copy (node, "host_ip6_addr",
12280 format (0, "%U/%d", format_ip6_address,
12282 mp->host_ip6_prefix_len));
12287 api_sw_interface_tap_v2_dump (vat_main_t * vam)
12289 vl_api_sw_interface_tap_v2_dump_t *mp;
12290 vl_api_control_ping_t *mp_ping;
12294 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
12295 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
12296 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
12299 /* Get list of tap interfaces */
12300 M (SW_INTERFACE_TAP_V2_DUMP, mp);
12303 /* Use a control ping for synchronization */
12304 MPING (CONTROL_PING, mp_ping);
12311 static void vl_api_sw_interface_virtio_pci_details_t_handler
12312 (vl_api_sw_interface_virtio_pci_details_t * mp)
12314 vat_main_t *vam = &vat_main;
12328 addr.as_u32 = ntohl (mp->pci_addr);
12329 u8 *pci_addr = format (0, "%04x:%02x:%02x.%x", addr.domain, addr.bus,
12330 addr.slot, addr.function);
12333 "\n%-12s %-12d %-12d %-12d %-17U 0x%-08llx",
12334 pci_addr, ntohl (mp->sw_if_index),
12335 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12336 format_ethernet_address, mp->mac_addr,
12337 clib_net_to_host_u64 (mp->features));
12338 vec_free (pci_addr);
12341 static void vl_api_sw_interface_virtio_pci_details_t_handler_json
12342 (vl_api_sw_interface_virtio_pci_details_t * mp)
12344 vat_main_t *vam = &vat_main;
12345 vat_json_node_t *node = NULL;
12347 if (VAT_JSON_ARRAY != vam->json_tree.type)
12349 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12350 vat_json_init_array (&vam->json_tree);
12352 node = vat_json_array_add (&vam->json_tree);
12354 vat_json_init_object (node);
12355 vat_json_object_add_uint (node, "pci-addr", ntohl (mp->pci_addr));
12356 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12357 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12358 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12359 vat_json_object_add_uint (node, "features",
12360 clib_net_to_host_u64 (mp->features));
12361 vat_json_object_add_string_copy (node, "mac_addr",
12362 format (0, "%U", format_ethernet_address,
12367 api_sw_interface_virtio_pci_dump (vat_main_t * vam)
12369 vl_api_sw_interface_virtio_pci_dump_t *mp;
12370 vl_api_control_ping_t *mp_ping;
12374 "\n%-12s %-12s %-12s %-12s %-17s %-08s",
12375 "pci_addr", "sw_if_index", "rx_ring_sz", "tx_ring_sz",
12376 "mac_addr", "features");
12378 /* Get list of tap interfaces */
12379 M (SW_INTERFACE_VIRTIO_PCI_DUMP, mp);
12382 /* Use a control ping for synchronization */
12383 MPING (CONTROL_PING, mp_ping);
12391 api_vxlan_offload_rx (vat_main_t * vam)
12393 unformat_input_t *line_input = vam->input;
12394 vl_api_vxlan_offload_rx_t *mp;
12395 u32 hw_if_index = ~0, rx_if_index = ~0;
12399 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12401 if (unformat (line_input, "del"))
12403 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
12406 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
12408 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
12411 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
12415 errmsg ("parse error '%U'", format_unformat_error, line_input);
12420 if (hw_if_index == ~0)
12422 errmsg ("no hw interface");
12426 if (rx_if_index == ~0)
12428 errmsg ("no rx tunnel");
12432 M (VXLAN_OFFLOAD_RX, mp);
12434 mp->hw_if_index = ntohl (hw_if_index);
12435 mp->sw_if_index = ntohl (rx_if_index);
12436 mp->enable = is_add;
12443 static uword unformat_vxlan_decap_next
12444 (unformat_input_t * input, va_list * args)
12446 u32 *result = va_arg (*args, u32 *);
12449 if (unformat (input, "l2"))
12450 *result = VXLAN_INPUT_NEXT_L2_INPUT;
12451 else if (unformat (input, "%d", &tmp))
12459 api_vxlan_add_del_tunnel (vat_main_t * vam)
12461 unformat_input_t *line_input = vam->input;
12462 vl_api_vxlan_add_del_tunnel_t *mp;
12463 ip46_address_t src, dst;
12465 u8 ipv4_set = 0, ipv6_set = 0;
12470 u32 mcast_sw_if_index = ~0;
12471 u32 encap_vrf_id = 0;
12472 u32 decap_next_index = ~0;
12476 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12477 clib_memset (&src, 0, sizeof src);
12478 clib_memset (&dst, 0, sizeof dst);
12480 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12482 if (unformat (line_input, "del"))
12484 else if (unformat (line_input, "instance %d", &instance))
12487 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12493 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12499 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12505 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12510 else if (unformat (line_input, "group %U %U",
12511 unformat_ip4_address, &dst.ip4,
12512 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12514 grp_set = dst_set = 1;
12517 else if (unformat (line_input, "group %U",
12518 unformat_ip4_address, &dst.ip4))
12520 grp_set = dst_set = 1;
12523 else if (unformat (line_input, "group %U %U",
12524 unformat_ip6_address, &dst.ip6,
12525 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12527 grp_set = dst_set = 1;
12530 else if (unformat (line_input, "group %U",
12531 unformat_ip6_address, &dst.ip6))
12533 grp_set = dst_set = 1;
12537 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12539 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12541 else if (unformat (line_input, "decap-next %U",
12542 unformat_vxlan_decap_next, &decap_next_index))
12544 else if (unformat (line_input, "vni %d", &vni))
12548 errmsg ("parse error '%U'", format_unformat_error, line_input);
12555 errmsg ("tunnel src address not specified");
12560 errmsg ("tunnel dst address not specified");
12564 if (grp_set && !ip46_address_is_multicast (&dst))
12566 errmsg ("tunnel group address not multicast");
12569 if (grp_set && mcast_sw_if_index == ~0)
12571 errmsg ("tunnel nonexistent multicast device");
12574 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12576 errmsg ("tunnel dst address must be unicast");
12581 if (ipv4_set && ipv6_set)
12583 errmsg ("both IPv4 and IPv6 addresses specified");
12587 if ((vni == 0) || (vni >> 24))
12589 errmsg ("vni not specified or out of range");
12593 M (VXLAN_ADD_DEL_TUNNEL, mp);
12597 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
12598 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
12602 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
12603 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
12606 mp->instance = htonl (instance);
12607 mp->encap_vrf_id = ntohl (encap_vrf_id);
12608 mp->decap_next_index = ntohl (decap_next_index);
12609 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12610 mp->vni = ntohl (vni);
12611 mp->is_add = is_add;
12612 mp->is_ipv6 = ipv6_set;
12619 static void vl_api_vxlan_tunnel_details_t_handler
12620 (vl_api_vxlan_tunnel_details_t * mp)
12622 vat_main_t *vam = &vat_main;
12623 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12624 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12626 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
12627 ntohl (mp->sw_if_index),
12628 ntohl (mp->instance),
12629 format_ip46_address, &src, IP46_TYPE_ANY,
12630 format_ip46_address, &dst, IP46_TYPE_ANY,
12631 ntohl (mp->encap_vrf_id),
12632 ntohl (mp->decap_next_index), ntohl (mp->vni),
12633 ntohl (mp->mcast_sw_if_index));
12636 static void vl_api_vxlan_tunnel_details_t_handler_json
12637 (vl_api_vxlan_tunnel_details_t * mp)
12639 vat_main_t *vam = &vat_main;
12640 vat_json_node_t *node = NULL;
12642 if (VAT_JSON_ARRAY != vam->json_tree.type)
12644 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12645 vat_json_init_array (&vam->json_tree);
12647 node = vat_json_array_add (&vam->json_tree);
12649 vat_json_init_object (node);
12650 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12652 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
12656 struct in6_addr ip6;
12658 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12659 vat_json_object_add_ip6 (node, "src_address", ip6);
12660 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12661 vat_json_object_add_ip6 (node, "dst_address", ip6);
12665 struct in_addr ip4;
12667 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12668 vat_json_object_add_ip4 (node, "src_address", ip4);
12669 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12670 vat_json_object_add_ip4 (node, "dst_address", ip4);
12672 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12673 vat_json_object_add_uint (node, "decap_next_index",
12674 ntohl (mp->decap_next_index));
12675 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12676 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12677 vat_json_object_add_uint (node, "mcast_sw_if_index",
12678 ntohl (mp->mcast_sw_if_index));
12682 api_vxlan_tunnel_dump (vat_main_t * vam)
12684 unformat_input_t *i = vam->input;
12685 vl_api_vxlan_tunnel_dump_t *mp;
12686 vl_api_control_ping_t *mp_ping;
12688 u8 sw_if_index_set = 0;
12691 /* Parse args required to build the message */
12692 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12694 if (unformat (i, "sw_if_index %d", &sw_if_index))
12695 sw_if_index_set = 1;
12700 if (sw_if_index_set == 0)
12705 if (!vam->json_output)
12707 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
12708 "sw_if_index", "instance", "src_address", "dst_address",
12709 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12712 /* Get list of vxlan-tunnel interfaces */
12713 M (VXLAN_TUNNEL_DUMP, mp);
12715 mp->sw_if_index = htonl (sw_if_index);
12719 /* Use a control ping for synchronization */
12720 MPING (CONTROL_PING, mp_ping);
12727 static uword unformat_geneve_decap_next
12728 (unformat_input_t * input, va_list * args)
12730 u32 *result = va_arg (*args, u32 *);
12733 if (unformat (input, "l2"))
12734 *result = GENEVE_INPUT_NEXT_L2_INPUT;
12735 else if (unformat (input, "%d", &tmp))
12743 api_geneve_add_del_tunnel (vat_main_t * vam)
12745 unformat_input_t *line_input = vam->input;
12746 vl_api_geneve_add_del_tunnel_t *mp;
12747 ip46_address_t src, dst;
12749 u8 ipv4_set = 0, ipv6_set = 0;
12753 u32 mcast_sw_if_index = ~0;
12754 u32 encap_vrf_id = 0;
12755 u32 decap_next_index = ~0;
12759 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12760 clib_memset (&src, 0, sizeof src);
12761 clib_memset (&dst, 0, sizeof dst);
12763 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12765 if (unformat (line_input, "del"))
12768 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12774 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12780 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12786 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12791 else if (unformat (line_input, "group %U %U",
12792 unformat_ip4_address, &dst.ip4,
12793 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12795 grp_set = dst_set = 1;
12798 else if (unformat (line_input, "group %U",
12799 unformat_ip4_address, &dst.ip4))
12801 grp_set = dst_set = 1;
12804 else if (unformat (line_input, "group %U %U",
12805 unformat_ip6_address, &dst.ip6,
12806 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12808 grp_set = dst_set = 1;
12811 else if (unformat (line_input, "group %U",
12812 unformat_ip6_address, &dst.ip6))
12814 grp_set = dst_set = 1;
12818 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12820 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12822 else if (unformat (line_input, "decap-next %U",
12823 unformat_geneve_decap_next, &decap_next_index))
12825 else if (unformat (line_input, "vni %d", &vni))
12829 errmsg ("parse error '%U'", format_unformat_error, line_input);
12836 errmsg ("tunnel src address not specified");
12841 errmsg ("tunnel dst address not specified");
12845 if (grp_set && !ip46_address_is_multicast (&dst))
12847 errmsg ("tunnel group address not multicast");
12850 if (grp_set && mcast_sw_if_index == ~0)
12852 errmsg ("tunnel nonexistent multicast device");
12855 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12857 errmsg ("tunnel dst address must be unicast");
12862 if (ipv4_set && ipv6_set)
12864 errmsg ("both IPv4 and IPv6 addresses specified");
12868 if ((vni == 0) || (vni >> 24))
12870 errmsg ("vni not specified or out of range");
12874 M (GENEVE_ADD_DEL_TUNNEL, mp);
12878 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
12879 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
12883 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
12884 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
12886 mp->encap_vrf_id = ntohl (encap_vrf_id);
12887 mp->decap_next_index = ntohl (decap_next_index);
12888 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12889 mp->vni = ntohl (vni);
12890 mp->is_add = is_add;
12891 mp->is_ipv6 = ipv6_set;
12898 static void vl_api_geneve_tunnel_details_t_handler
12899 (vl_api_geneve_tunnel_details_t * mp)
12901 vat_main_t *vam = &vat_main;
12902 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12903 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12905 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12906 ntohl (mp->sw_if_index),
12907 format_ip46_address, &src, IP46_TYPE_ANY,
12908 format_ip46_address, &dst, IP46_TYPE_ANY,
12909 ntohl (mp->encap_vrf_id),
12910 ntohl (mp->decap_next_index), ntohl (mp->vni),
12911 ntohl (mp->mcast_sw_if_index));
12914 static void vl_api_geneve_tunnel_details_t_handler_json
12915 (vl_api_geneve_tunnel_details_t * mp)
12917 vat_main_t *vam = &vat_main;
12918 vat_json_node_t *node = NULL;
12920 if (VAT_JSON_ARRAY != vam->json_tree.type)
12922 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12923 vat_json_init_array (&vam->json_tree);
12925 node = vat_json_array_add (&vam->json_tree);
12927 vat_json_init_object (node);
12928 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12931 struct in6_addr ip6;
12933 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12934 vat_json_object_add_ip6 (node, "src_address", ip6);
12935 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12936 vat_json_object_add_ip6 (node, "dst_address", ip6);
12940 struct in_addr ip4;
12942 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12943 vat_json_object_add_ip4 (node, "src_address", ip4);
12944 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12945 vat_json_object_add_ip4 (node, "dst_address", ip4);
12947 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12948 vat_json_object_add_uint (node, "decap_next_index",
12949 ntohl (mp->decap_next_index));
12950 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12951 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12952 vat_json_object_add_uint (node, "mcast_sw_if_index",
12953 ntohl (mp->mcast_sw_if_index));
12957 api_geneve_tunnel_dump (vat_main_t * vam)
12959 unformat_input_t *i = vam->input;
12960 vl_api_geneve_tunnel_dump_t *mp;
12961 vl_api_control_ping_t *mp_ping;
12963 u8 sw_if_index_set = 0;
12966 /* Parse args required to build the message */
12967 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12969 if (unformat (i, "sw_if_index %d", &sw_if_index))
12970 sw_if_index_set = 1;
12975 if (sw_if_index_set == 0)
12980 if (!vam->json_output)
12982 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12983 "sw_if_index", "local_address", "remote_address",
12984 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12987 /* Get list of geneve-tunnel interfaces */
12988 M (GENEVE_TUNNEL_DUMP, mp);
12990 mp->sw_if_index = htonl (sw_if_index);
12994 /* Use a control ping for synchronization */
12995 M (CONTROL_PING, mp_ping);
13003 api_gre_tunnel_add_del (vat_main_t * vam)
13005 unformat_input_t *line_input = vam->input;
13006 vl_api_address_t src = { }, dst =
13009 vl_api_gre_tunnel_add_del_t *mp;
13010 vl_api_gre_tunnel_type_t t_type;
13014 u32 outer_fib_id = 0;
13015 u32 session_id = 0;
13019 t_type = GRE_API_TUNNEL_TYPE_L3;
13021 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13023 if (unformat (line_input, "del"))
13025 else if (unformat (line_input, "instance %d", &instance))
13027 else if (unformat (line_input, "src %U", unformat_vl_api_address, &src))
13031 else if (unformat (line_input, "dst %U", unformat_vl_api_address, &dst))
13035 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
13037 else if (unformat (line_input, "teb"))
13038 t_type = GRE_API_TUNNEL_TYPE_TEB;
13039 else if (unformat (line_input, "erspan %d", &session_id))
13040 t_type = GRE_API_TUNNEL_TYPE_ERSPAN;
13043 errmsg ("parse error '%U'", format_unformat_error, line_input);
13050 errmsg ("tunnel src address not specified");
13055 errmsg ("tunnel dst address not specified");
13059 M (GRE_TUNNEL_ADD_DEL, mp);
13061 clib_memcpy (&mp->tunnel.src, &src, sizeof (mp->tunnel.src));
13062 clib_memcpy (&mp->tunnel.dst, &dst, sizeof (mp->tunnel.dst));
13064 mp->tunnel.instance = htonl (instance);
13065 mp->tunnel.outer_fib_id = htonl (outer_fib_id);
13066 mp->is_add = is_add;
13067 mp->tunnel.session_id = htons ((u16) session_id);
13068 mp->tunnel.type = htonl (t_type);
13075 static void vl_api_gre_tunnel_details_t_handler
13076 (vl_api_gre_tunnel_details_t * mp)
13078 vat_main_t *vam = &vat_main;
13080 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
13081 ntohl (mp->tunnel.sw_if_index),
13082 ntohl (mp->tunnel.instance),
13083 format_vl_api_address, &mp->tunnel.src,
13084 format_vl_api_address, &mp->tunnel.dst,
13085 mp->tunnel.type, ntohl (mp->tunnel.outer_fib_id),
13086 ntohl (mp->tunnel.session_id));
13089 static void vl_api_gre_tunnel_details_t_handler_json
13090 (vl_api_gre_tunnel_details_t * mp)
13092 vat_main_t *vam = &vat_main;
13093 vat_json_node_t *node = NULL;
13095 if (VAT_JSON_ARRAY != vam->json_tree.type)
13097 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13098 vat_json_init_array (&vam->json_tree);
13100 node = vat_json_array_add (&vam->json_tree);
13102 vat_json_init_object (node);
13103 vat_json_object_add_uint (node, "sw_if_index",
13104 ntohl (mp->tunnel.sw_if_index));
13105 vat_json_object_add_uint (node, "instance", ntohl (mp->tunnel.instance));
13107 vat_json_object_add_address (node, "src", &mp->tunnel.src);
13108 vat_json_object_add_address (node, "dst", &mp->tunnel.dst);
13109 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel.type);
13110 vat_json_object_add_uint (node, "outer_fib_id",
13111 ntohl (mp->tunnel.outer_fib_id));
13112 vat_json_object_add_uint (node, "session_id", mp->tunnel.session_id);
13116 api_gre_tunnel_dump (vat_main_t * vam)
13118 unformat_input_t *i = vam->input;
13119 vl_api_gre_tunnel_dump_t *mp;
13120 vl_api_control_ping_t *mp_ping;
13122 u8 sw_if_index_set = 0;
13125 /* Parse args required to build the message */
13126 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13128 if (unformat (i, "sw_if_index %d", &sw_if_index))
13129 sw_if_index_set = 1;
13134 if (sw_if_index_set == 0)
13139 if (!vam->json_output)
13141 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
13142 "sw_if_index", "instance", "src_address", "dst_address",
13143 "tunnel_type", "outer_fib_id", "session_id");
13146 /* Get list of gre-tunnel interfaces */
13147 M (GRE_TUNNEL_DUMP, mp);
13149 mp->sw_if_index = htonl (sw_if_index);
13153 /* Use a control ping for synchronization */
13154 MPING (CONTROL_PING, mp_ping);
13162 api_l2_fib_clear_table (vat_main_t * vam)
13164 // unformat_input_t * i = vam->input;
13165 vl_api_l2_fib_clear_table_t *mp;
13168 M (L2_FIB_CLEAR_TABLE, mp);
13176 api_l2_interface_efp_filter (vat_main_t * vam)
13178 unformat_input_t *i = vam->input;
13179 vl_api_l2_interface_efp_filter_t *mp;
13182 u8 sw_if_index_set = 0;
13185 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13187 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13188 sw_if_index_set = 1;
13189 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13190 sw_if_index_set = 1;
13191 else if (unformat (i, "enable"))
13193 else if (unformat (i, "disable"))
13197 clib_warning ("parse error '%U'", format_unformat_error, i);
13202 if (sw_if_index_set == 0)
13204 errmsg ("missing sw_if_index");
13208 M (L2_INTERFACE_EFP_FILTER, mp);
13210 mp->sw_if_index = ntohl (sw_if_index);
13211 mp->enable_disable = enable;
13218 #define foreach_vtr_op \
13219 _("disable", L2_VTR_DISABLED) \
13220 _("push-1", L2_VTR_PUSH_1) \
13221 _("push-2", L2_VTR_PUSH_2) \
13222 _("pop-1", L2_VTR_POP_1) \
13223 _("pop-2", L2_VTR_POP_2) \
13224 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
13225 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
13226 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
13227 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
13230 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
13232 unformat_input_t *i = vam->input;
13233 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
13235 u8 sw_if_index_set = 0;
13238 u32 push_dot1q = 1;
13243 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13245 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13246 sw_if_index_set = 1;
13247 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13248 sw_if_index_set = 1;
13249 else if (unformat (i, "vtr_op %d", &vtr_op))
13251 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
13254 else if (unformat (i, "push_dot1q %d", &push_dot1q))
13256 else if (unformat (i, "tag1 %d", &tag1))
13258 else if (unformat (i, "tag2 %d", &tag2))
13262 clib_warning ("parse error '%U'", format_unformat_error, i);
13267 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
13269 errmsg ("missing vtr operation or sw_if_index");
13273 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
13274 mp->sw_if_index = ntohl (sw_if_index);
13275 mp->vtr_op = ntohl (vtr_op);
13276 mp->push_dot1q = ntohl (push_dot1q);
13277 mp->tag1 = ntohl (tag1);
13278 mp->tag2 = ntohl (tag2);
13286 api_create_vhost_user_if (vat_main_t * vam)
13288 unformat_input_t *i = vam->input;
13289 vl_api_create_vhost_user_if_t *mp;
13292 u8 file_name_set = 0;
13293 u32 custom_dev_instance = ~0;
13295 u8 use_custom_mac = 0;
13296 u8 disable_mrg_rxbuf = 0;
13297 u8 disable_indirect_desc = 0;
13301 /* Shut up coverity */
13302 clib_memset (hwaddr, 0, sizeof (hwaddr));
13304 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13306 if (unformat (i, "socket %s", &file_name))
13310 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13312 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
13313 use_custom_mac = 1;
13314 else if (unformat (i, "server"))
13316 else if (unformat (i, "disable_mrg_rxbuf"))
13317 disable_mrg_rxbuf = 1;
13318 else if (unformat (i, "disable_indirect_desc"))
13319 disable_indirect_desc = 1;
13320 else if (unformat (i, "tag %s", &tag))
13326 if (file_name_set == 0)
13328 errmsg ("missing socket file name");
13332 if (vec_len (file_name) > 255)
13334 errmsg ("socket file name too long");
13337 vec_add1 (file_name, 0);
13339 M (CREATE_VHOST_USER_IF, mp);
13341 mp->is_server = is_server;
13342 mp->disable_mrg_rxbuf = disable_mrg_rxbuf;
13343 mp->disable_indirect_desc = disable_indirect_desc;
13344 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13345 vec_free (file_name);
13346 if (custom_dev_instance != ~0)
13349 mp->custom_dev_instance = ntohl (custom_dev_instance);
13352 mp->use_custom_mac = use_custom_mac;
13353 clib_memcpy (mp->mac_address, hwaddr, 6);
13355 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
13364 api_modify_vhost_user_if (vat_main_t * vam)
13366 unformat_input_t *i = vam->input;
13367 vl_api_modify_vhost_user_if_t *mp;
13370 u8 file_name_set = 0;
13371 u32 custom_dev_instance = ~0;
13372 u8 sw_if_index_set = 0;
13373 u32 sw_if_index = (u32) ~ 0;
13376 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13378 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13379 sw_if_index_set = 1;
13380 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13381 sw_if_index_set = 1;
13382 else if (unformat (i, "socket %s", &file_name))
13386 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13388 else if (unformat (i, "server"))
13394 if (sw_if_index_set == 0)
13396 errmsg ("missing sw_if_index or interface name");
13400 if (file_name_set == 0)
13402 errmsg ("missing socket file name");
13406 if (vec_len (file_name) > 255)
13408 errmsg ("socket file name too long");
13411 vec_add1 (file_name, 0);
13413 M (MODIFY_VHOST_USER_IF, mp);
13415 mp->sw_if_index = ntohl (sw_if_index);
13416 mp->is_server = is_server;
13417 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13418 vec_free (file_name);
13419 if (custom_dev_instance != ~0)
13422 mp->custom_dev_instance = ntohl (custom_dev_instance);
13431 api_delete_vhost_user_if (vat_main_t * vam)
13433 unformat_input_t *i = vam->input;
13434 vl_api_delete_vhost_user_if_t *mp;
13435 u32 sw_if_index = ~0;
13436 u8 sw_if_index_set = 0;
13439 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13441 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13442 sw_if_index_set = 1;
13443 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13444 sw_if_index_set = 1;
13449 if (sw_if_index_set == 0)
13451 errmsg ("missing sw_if_index or interface name");
13456 M (DELETE_VHOST_USER_IF, mp);
13458 mp->sw_if_index = ntohl (sw_if_index);
13465 static void vl_api_sw_interface_vhost_user_details_t_handler
13466 (vl_api_sw_interface_vhost_user_details_t * mp)
13468 vat_main_t *vam = &vat_main;
13470 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
13471 (char *) mp->interface_name,
13472 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
13473 clib_net_to_host_u64 (mp->features), mp->is_server,
13474 ntohl (mp->num_regions), (char *) mp->sock_filename);
13475 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
13478 static void vl_api_sw_interface_vhost_user_details_t_handler_json
13479 (vl_api_sw_interface_vhost_user_details_t * mp)
13481 vat_main_t *vam = &vat_main;
13482 vat_json_node_t *node = NULL;
13484 if (VAT_JSON_ARRAY != vam->json_tree.type)
13486 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13487 vat_json_init_array (&vam->json_tree);
13489 node = vat_json_array_add (&vam->json_tree);
13491 vat_json_init_object (node);
13492 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13493 vat_json_object_add_string_copy (node, "interface_name",
13494 mp->interface_name);
13495 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
13496 ntohl (mp->virtio_net_hdr_sz));
13497 vat_json_object_add_uint (node, "features",
13498 clib_net_to_host_u64 (mp->features));
13499 vat_json_object_add_uint (node, "is_server", mp->is_server);
13500 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
13501 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
13502 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
13506 api_sw_interface_vhost_user_dump (vat_main_t * vam)
13508 vl_api_sw_interface_vhost_user_dump_t *mp;
13509 vl_api_control_ping_t *mp_ping;
13512 "Interface name idx hdr_sz features server regions filename");
13514 /* Get list of vhost-user interfaces */
13515 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
13518 /* Use a control ping for synchronization */
13519 MPING (CONTROL_PING, mp_ping);
13527 api_show_version (vat_main_t * vam)
13529 vl_api_show_version_t *mp;
13532 M (SHOW_VERSION, mp);
13541 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
13543 unformat_input_t *line_input = vam->input;
13544 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
13545 ip4_address_t local4, remote4;
13546 ip6_address_t local6, remote6;
13548 u8 ipv4_set = 0, ipv6_set = 0;
13552 u32 mcast_sw_if_index = ~0;
13553 u32 encap_vrf_id = 0;
13554 u32 decap_vrf_id = 0;
13560 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13561 clib_memset (&local4, 0, sizeof local4);
13562 clib_memset (&remote4, 0, sizeof remote4);
13563 clib_memset (&local6, 0, sizeof local6);
13564 clib_memset (&remote6, 0, sizeof remote6);
13566 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13568 if (unformat (line_input, "del"))
13570 else if (unformat (line_input, "local %U",
13571 unformat_ip4_address, &local4))
13576 else if (unformat (line_input, "remote %U",
13577 unformat_ip4_address, &remote4))
13582 else if (unformat (line_input, "local %U",
13583 unformat_ip6_address, &local6))
13588 else if (unformat (line_input, "remote %U",
13589 unformat_ip6_address, &remote6))
13594 else if (unformat (line_input, "group %U %U",
13595 unformat_ip4_address, &remote4,
13596 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13598 grp_set = remote_set = 1;
13601 else if (unformat (line_input, "group %U",
13602 unformat_ip4_address, &remote4))
13604 grp_set = remote_set = 1;
13607 else if (unformat (line_input, "group %U %U",
13608 unformat_ip6_address, &remote6,
13609 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13611 grp_set = remote_set = 1;
13614 else if (unformat (line_input, "group %U",
13615 unformat_ip6_address, &remote6))
13617 grp_set = remote_set = 1;
13621 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13623 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13625 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
13627 else if (unformat (line_input, "vni %d", &vni))
13629 else if (unformat (line_input, "next-ip4"))
13631 else if (unformat (line_input, "next-ip6"))
13633 else if (unformat (line_input, "next-ethernet"))
13635 else if (unformat (line_input, "next-nsh"))
13639 errmsg ("parse error '%U'", format_unformat_error, line_input);
13644 if (local_set == 0)
13646 errmsg ("tunnel local address not specified");
13649 if (remote_set == 0)
13651 errmsg ("tunnel remote address not specified");
13654 if (grp_set && mcast_sw_if_index == ~0)
13656 errmsg ("tunnel nonexistent multicast device");
13659 if (ipv4_set && ipv6_set)
13661 errmsg ("both IPv4 and IPv6 addresses specified");
13667 errmsg ("vni not specified");
13671 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
13676 clib_memcpy (&mp->local, &local6, sizeof (local6));
13677 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
13681 clib_memcpy (&mp->local, &local4, sizeof (local4));
13682 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
13685 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13686 mp->encap_vrf_id = ntohl (encap_vrf_id);
13687 mp->decap_vrf_id = ntohl (decap_vrf_id);
13688 mp->protocol = protocol;
13689 mp->vni = ntohl (vni);
13690 mp->is_add = is_add;
13691 mp->is_ipv6 = ipv6_set;
13698 static void vl_api_vxlan_gpe_tunnel_details_t_handler
13699 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13701 vat_main_t *vam = &vat_main;
13702 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
13703 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
13705 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
13706 ntohl (mp->sw_if_index),
13707 format_ip46_address, &local, IP46_TYPE_ANY,
13708 format_ip46_address, &remote, IP46_TYPE_ANY,
13709 ntohl (mp->vni), mp->protocol,
13710 ntohl (mp->mcast_sw_if_index),
13711 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
13715 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
13716 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13718 vat_main_t *vam = &vat_main;
13719 vat_json_node_t *node = NULL;
13720 struct in_addr ip4;
13721 struct in6_addr ip6;
13723 if (VAT_JSON_ARRAY != vam->json_tree.type)
13725 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13726 vat_json_init_array (&vam->json_tree);
13728 node = vat_json_array_add (&vam->json_tree);
13730 vat_json_init_object (node);
13731 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13734 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
13735 vat_json_object_add_ip6 (node, "local", ip6);
13736 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
13737 vat_json_object_add_ip6 (node, "remote", ip6);
13741 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
13742 vat_json_object_add_ip4 (node, "local", ip4);
13743 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
13744 vat_json_object_add_ip4 (node, "remote", ip4);
13746 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13747 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
13748 vat_json_object_add_uint (node, "mcast_sw_if_index",
13749 ntohl (mp->mcast_sw_if_index));
13750 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13751 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
13752 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13756 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
13758 unformat_input_t *i = vam->input;
13759 vl_api_vxlan_gpe_tunnel_dump_t *mp;
13760 vl_api_control_ping_t *mp_ping;
13762 u8 sw_if_index_set = 0;
13765 /* Parse args required to build the message */
13766 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13768 if (unformat (i, "sw_if_index %d", &sw_if_index))
13769 sw_if_index_set = 1;
13774 if (sw_if_index_set == 0)
13779 if (!vam->json_output)
13781 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
13782 "sw_if_index", "local", "remote", "vni",
13783 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
13786 /* Get list of vxlan-tunnel interfaces */
13787 M (VXLAN_GPE_TUNNEL_DUMP, mp);
13789 mp->sw_if_index = htonl (sw_if_index);
13793 /* Use a control ping for synchronization */
13794 MPING (CONTROL_PING, mp_ping);
13801 static void vl_api_l2_fib_table_details_t_handler
13802 (vl_api_l2_fib_table_details_t * mp)
13804 vat_main_t *vam = &vat_main;
13806 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
13808 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
13809 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
13813 static void vl_api_l2_fib_table_details_t_handler_json
13814 (vl_api_l2_fib_table_details_t * mp)
13816 vat_main_t *vam = &vat_main;
13817 vat_json_node_t *node = NULL;
13819 if (VAT_JSON_ARRAY != vam->json_tree.type)
13821 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13822 vat_json_init_array (&vam->json_tree);
13824 node = vat_json_array_add (&vam->json_tree);
13826 vat_json_init_object (node);
13827 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
13828 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
13829 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13830 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
13831 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
13832 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
13836 api_l2_fib_table_dump (vat_main_t * vam)
13838 unformat_input_t *i = vam->input;
13839 vl_api_l2_fib_table_dump_t *mp;
13840 vl_api_control_ping_t *mp_ping;
13845 /* Parse args required to build the message */
13846 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13848 if (unformat (i, "bd_id %d", &bd_id))
13854 if (bd_id_set == 0)
13856 errmsg ("missing bridge domain");
13860 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
13862 /* Get list of l2 fib entries */
13863 M (L2_FIB_TABLE_DUMP, mp);
13865 mp->bd_id = ntohl (bd_id);
13868 /* Use a control ping for synchronization */
13869 MPING (CONTROL_PING, mp_ping);
13878 api_interface_name_renumber (vat_main_t * vam)
13880 unformat_input_t *line_input = vam->input;
13881 vl_api_interface_name_renumber_t *mp;
13882 u32 sw_if_index = ~0;
13883 u32 new_show_dev_instance = ~0;
13886 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13888 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
13891 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13893 else if (unformat (line_input, "new_show_dev_instance %d",
13894 &new_show_dev_instance))
13900 if (sw_if_index == ~0)
13902 errmsg ("missing interface name or sw_if_index");
13906 if (new_show_dev_instance == ~0)
13908 errmsg ("missing new_show_dev_instance");
13912 M (INTERFACE_NAME_RENUMBER, mp);
13914 mp->sw_if_index = ntohl (sw_if_index);
13915 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
13923 api_ip_probe_neighbor (vat_main_t * vam)
13925 unformat_input_t *i = vam->input;
13926 vl_api_ip_probe_neighbor_t *mp;
13927 vl_api_address_t dst_adr = { };
13933 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13935 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13937 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13939 else if (unformat (i, "address %U", unformat_vl_api_address, &dst_adr))
13947 errmsg ("missing interface");
13953 errmsg ("missing addresses");
13957 M (IP_PROBE_NEIGHBOR, mp);
13959 mp->sw_if_index = ntohl (sw_if_index);
13960 clib_memcpy (&mp->dst, &dst_adr, sizeof (dst_adr));
13968 api_ip_scan_neighbor_enable_disable (vat_main_t * vam)
13970 unformat_input_t *i = vam->input;
13971 vl_api_ip_scan_neighbor_enable_disable_t *mp;
13972 u8 mode = IP_SCAN_V46_NEIGHBORS;
13973 u32 interval = 0, time = 0, update = 0, delay = 0, stale = 0;
13976 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13978 if (unformat (i, "ip4"))
13979 mode = IP_SCAN_V4_NEIGHBORS;
13980 else if (unformat (i, "ip6"))
13981 mode = IP_SCAN_V6_NEIGHBORS;
13982 if (unformat (i, "both"))
13983 mode = IP_SCAN_V46_NEIGHBORS;
13984 else if (unformat (i, "disable"))
13985 mode = IP_SCAN_DISABLED;
13986 else if (unformat (i, "interval %d", &interval))
13988 else if (unformat (i, "max-time %d", &time))
13990 else if (unformat (i, "max-update %d", &update))
13992 else if (unformat (i, "delay %d", &delay))
13994 else if (unformat (i, "stale %d", &stale))
14000 if (interval > 255)
14002 errmsg ("interval cannot exceed 255 minutes.");
14007 errmsg ("max-time cannot exceed 255 usec.");
14012 errmsg ("max-update cannot exceed 255.");
14017 errmsg ("delay cannot exceed 255 msec.");
14022 errmsg ("stale cannot exceed 255 minutes.");
14026 M (IP_SCAN_NEIGHBOR_ENABLE_DISABLE, mp);
14028 mp->scan_interval = interval;
14029 mp->max_proc_time = time;
14030 mp->max_update = update;
14031 mp->scan_int_delay = delay;
14032 mp->stale_threshold = stale;
14040 api_want_ip4_arp_events (vat_main_t * vam)
14042 unformat_input_t *line_input = vam->input;
14043 vl_api_want_ip4_arp_events_t *mp;
14044 ip4_address_t address;
14045 int address_set = 0;
14046 u32 enable_disable = 1;
14049 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14051 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
14053 else if (unformat (line_input, "del"))
14054 enable_disable = 0;
14059 if (address_set == 0)
14061 errmsg ("missing addresses");
14065 M (WANT_IP4_ARP_EVENTS, mp);
14066 mp->enable_disable = enable_disable;
14067 mp->pid = htonl (getpid ());
14068 clib_memcpy (mp->ip, &address, sizeof (address));
14076 api_want_ip6_nd_events (vat_main_t * vam)
14078 unformat_input_t *line_input = vam->input;
14079 vl_api_want_ip6_nd_events_t *mp;
14080 vl_api_ip6_address_t address;
14081 int address_set = 0;
14082 u32 enable_disable = 1;
14085 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14088 (line_input, "address %U", unformat_vl_api_ip6_address, &address))
14090 else if (unformat (line_input, "del"))
14091 enable_disable = 0;
14096 if (address_set == 0)
14098 errmsg ("missing addresses");
14102 M (WANT_IP6_ND_EVENTS, mp);
14103 mp->enable_disable = enable_disable;
14104 mp->pid = htonl (getpid ());
14105 clib_memcpy (&mp->ip, &address, sizeof (address));
14113 api_want_l2_macs_events (vat_main_t * vam)
14115 unformat_input_t *line_input = vam->input;
14116 vl_api_want_l2_macs_events_t *mp;
14117 u8 enable_disable = 1;
14118 u32 scan_delay = 0;
14119 u32 max_macs_in_event = 0;
14120 u32 learn_limit = 0;
14123 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14125 if (unformat (line_input, "learn-limit %d", &learn_limit))
14127 else if (unformat (line_input, "scan-delay %d", &scan_delay))
14129 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
14131 else if (unformat (line_input, "disable"))
14132 enable_disable = 0;
14137 M (WANT_L2_MACS_EVENTS, mp);
14138 mp->enable_disable = enable_disable;
14139 mp->pid = htonl (getpid ());
14140 mp->learn_limit = htonl (learn_limit);
14141 mp->scan_delay = (u8) scan_delay;
14142 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
14149 api_input_acl_set_interface (vat_main_t * vam)
14151 unformat_input_t *i = vam->input;
14152 vl_api_input_acl_set_interface_t *mp;
14154 int sw_if_index_set;
14155 u32 ip4_table_index = ~0;
14156 u32 ip6_table_index = ~0;
14157 u32 l2_table_index = ~0;
14161 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14163 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14164 sw_if_index_set = 1;
14165 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14166 sw_if_index_set = 1;
14167 else if (unformat (i, "del"))
14169 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14171 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14173 else if (unformat (i, "l2-table %d", &l2_table_index))
14177 clib_warning ("parse error '%U'", format_unformat_error, i);
14182 if (sw_if_index_set == 0)
14184 errmsg ("missing interface name or sw_if_index");
14188 M (INPUT_ACL_SET_INTERFACE, mp);
14190 mp->sw_if_index = ntohl (sw_if_index);
14191 mp->ip4_table_index = ntohl (ip4_table_index);
14192 mp->ip6_table_index = ntohl (ip6_table_index);
14193 mp->l2_table_index = ntohl (l2_table_index);
14194 mp->is_add = is_add;
14202 api_output_acl_set_interface (vat_main_t * vam)
14204 unformat_input_t *i = vam->input;
14205 vl_api_output_acl_set_interface_t *mp;
14207 int sw_if_index_set;
14208 u32 ip4_table_index = ~0;
14209 u32 ip6_table_index = ~0;
14210 u32 l2_table_index = ~0;
14214 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14216 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14217 sw_if_index_set = 1;
14218 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14219 sw_if_index_set = 1;
14220 else if (unformat (i, "del"))
14222 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14224 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14226 else if (unformat (i, "l2-table %d", &l2_table_index))
14230 clib_warning ("parse error '%U'", format_unformat_error, i);
14235 if (sw_if_index_set == 0)
14237 errmsg ("missing interface name or sw_if_index");
14241 M (OUTPUT_ACL_SET_INTERFACE, mp);
14243 mp->sw_if_index = ntohl (sw_if_index);
14244 mp->ip4_table_index = ntohl (ip4_table_index);
14245 mp->ip6_table_index = ntohl (ip6_table_index);
14246 mp->l2_table_index = ntohl (l2_table_index);
14247 mp->is_add = is_add;
14255 api_ip_address_dump (vat_main_t * vam)
14257 unformat_input_t *i = vam->input;
14258 vl_api_ip_address_dump_t *mp;
14259 vl_api_control_ping_t *mp_ping;
14260 u32 sw_if_index = ~0;
14261 u8 sw_if_index_set = 0;
14266 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14268 if (unformat (i, "sw_if_index %d", &sw_if_index))
14269 sw_if_index_set = 1;
14271 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14272 sw_if_index_set = 1;
14273 else if (unformat (i, "ipv4"))
14275 else if (unformat (i, "ipv6"))
14281 if (ipv4_set && ipv6_set)
14283 errmsg ("ipv4 and ipv6 flags cannot be both set");
14287 if ((!ipv4_set) && (!ipv6_set))
14289 errmsg ("no ipv4 nor ipv6 flag set");
14293 if (sw_if_index_set == 0)
14295 errmsg ("missing interface name or sw_if_index");
14299 vam->current_sw_if_index = sw_if_index;
14300 vam->is_ipv6 = ipv6_set;
14302 M (IP_ADDRESS_DUMP, mp);
14303 mp->sw_if_index = ntohl (sw_if_index);
14304 mp->is_ipv6 = ipv6_set;
14307 /* Use a control ping for synchronization */
14308 MPING (CONTROL_PING, mp_ping);
14316 api_ip_dump (vat_main_t * vam)
14318 vl_api_ip_dump_t *mp;
14319 vl_api_control_ping_t *mp_ping;
14320 unformat_input_t *in = vam->input;
14327 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
14329 if (unformat (in, "ipv4"))
14331 else if (unformat (in, "ipv6"))
14337 if (ipv4_set && ipv6_set)
14339 errmsg ("ipv4 and ipv6 flags cannot be both set");
14343 if ((!ipv4_set) && (!ipv6_set))
14345 errmsg ("no ipv4 nor ipv6 flag set");
14349 is_ipv6 = ipv6_set;
14350 vam->is_ipv6 = is_ipv6;
14352 /* free old data */
14353 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
14355 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
14357 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
14360 mp->is_ipv6 = ipv6_set;
14363 /* Use a control ping for synchronization */
14364 MPING (CONTROL_PING, mp_ping);
14372 api_ipsec_spd_add_del (vat_main_t * vam)
14374 unformat_input_t *i = vam->input;
14375 vl_api_ipsec_spd_add_del_t *mp;
14380 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14382 if (unformat (i, "spd_id %d", &spd_id))
14384 else if (unformat (i, "del"))
14388 clib_warning ("parse error '%U'", format_unformat_error, i);
14394 errmsg ("spd_id must be set");
14398 M (IPSEC_SPD_ADD_DEL, mp);
14400 mp->spd_id = ntohl (spd_id);
14401 mp->is_add = is_add;
14409 api_ipsec_interface_add_del_spd (vat_main_t * vam)
14411 unformat_input_t *i = vam->input;
14412 vl_api_ipsec_interface_add_del_spd_t *mp;
14414 u8 sw_if_index_set = 0;
14415 u32 spd_id = (u32) ~ 0;
14419 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14421 if (unformat (i, "del"))
14423 else if (unformat (i, "spd_id %d", &spd_id))
14426 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14427 sw_if_index_set = 1;
14428 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14429 sw_if_index_set = 1;
14432 clib_warning ("parse error '%U'", format_unformat_error, i);
14438 if (spd_id == (u32) ~ 0)
14440 errmsg ("spd_id must be set");
14444 if (sw_if_index_set == 0)
14446 errmsg ("missing interface name or sw_if_index");
14450 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
14452 mp->spd_id = ntohl (spd_id);
14453 mp->sw_if_index = ntohl (sw_if_index);
14454 mp->is_add = is_add;
14462 api_ipsec_spd_entry_add_del (vat_main_t * vam)
14464 unformat_input_t *i = vam->input;
14465 vl_api_ipsec_spd_entry_add_del_t *mp;
14466 u8 is_add = 1, is_outbound = 0;
14467 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
14469 u32 rport_start = 0, rport_stop = (u32) ~ 0;
14470 u32 lport_start = 0, lport_stop = (u32) ~ 0;
14471 vl_api_address_t laddr_start = { }, laddr_stop =
14480 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14482 if (unformat (i, "del"))
14484 if (unformat (i, "outbound"))
14486 if (unformat (i, "inbound"))
14488 else if (unformat (i, "spd_id %d", &spd_id))
14490 else if (unformat (i, "sa_id %d", &sa_id))
14492 else if (unformat (i, "priority %d", &priority))
14494 else if (unformat (i, "protocol %d", &protocol))
14496 else if (unformat (i, "lport_start %d", &lport_start))
14498 else if (unformat (i, "lport_stop %d", &lport_stop))
14500 else if (unformat (i, "rport_start %d", &rport_start))
14502 else if (unformat (i, "rport_stop %d", &rport_stop))
14504 else if (unformat (i, "laddr_start %U",
14505 unformat_vl_api_address, &laddr_start))
14507 else if (unformat (i, "laddr_stop %U", unformat_vl_api_address,
14510 else if (unformat (i, "raddr_start %U", unformat_vl_api_address,
14513 else if (unformat (i, "raddr_stop %U", unformat_vl_api_address,
14517 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
14519 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
14521 clib_warning ("unsupported action: 'resolve'");
14527 clib_warning ("parse error '%U'", format_unformat_error, i);
14533 M (IPSEC_SPD_ENTRY_ADD_DEL, mp);
14535 mp->is_add = is_add;
14537 mp->entry.spd_id = ntohl (spd_id);
14538 mp->entry.priority = ntohl (priority);
14539 mp->entry.is_outbound = is_outbound;
14541 clib_memcpy (&mp->entry.remote_address_start, &raddr_start,
14542 sizeof (vl_api_address_t));
14543 clib_memcpy (&mp->entry.remote_address_stop, &raddr_stop,
14544 sizeof (vl_api_address_t));
14545 clib_memcpy (&mp->entry.local_address_start, &laddr_start,
14546 sizeof (vl_api_address_t));
14547 clib_memcpy (&mp->entry.local_address_stop, &laddr_stop,
14548 sizeof (vl_api_address_t));
14550 mp->entry.protocol = (u8) protocol;
14551 mp->entry.local_port_start = ntohs ((u16) lport_start);
14552 mp->entry.local_port_stop = ntohs ((u16) lport_stop);
14553 mp->entry.remote_port_start = ntohs ((u16) rport_start);
14554 mp->entry.remote_port_stop = ntohs ((u16) rport_stop);
14555 mp->entry.policy = (u8) policy;
14556 mp->entry.sa_id = ntohl (sa_id);
14564 api_ipsec_sad_entry_add_del (vat_main_t * vam)
14566 unformat_input_t *i = vam->input;
14567 vl_api_ipsec_sad_entry_add_del_t *mp;
14568 u32 sad_id = 0, spi = 0;
14569 u8 *ck = 0, *ik = 0;
14572 vl_api_ipsec_crypto_alg_t crypto_alg = IPSEC_API_CRYPTO_ALG_NONE;
14573 vl_api_ipsec_integ_alg_t integ_alg = IPSEC_API_INTEG_ALG_NONE;
14574 vl_api_ipsec_sad_flags_t flags = IPSEC_API_SAD_FLAG_NONE;
14575 vl_api_ipsec_proto_t protocol = IPSEC_API_PROTO_AH;
14576 vl_api_address_t tun_src, tun_dst;
14579 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14581 if (unformat (i, "del"))
14583 else if (unformat (i, "sad_id %d", &sad_id))
14585 else if (unformat (i, "spi %d", &spi))
14587 else if (unformat (i, "esp"))
14588 protocol = IPSEC_API_PROTO_ESP;
14590 if (unformat (i, "tunnel_src %U", unformat_vl_api_address, &tun_src))
14592 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
14593 if (ADDRESS_IP6 == tun_src.af)
14594 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
14597 if (unformat (i, "tunnel_dst %U", unformat_vl_api_address, &tun_dst))
14599 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
14600 if (ADDRESS_IP6 == tun_src.af)
14601 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
14604 if (unformat (i, "crypto_alg %U",
14605 unformat_ipsec_api_crypto_alg, &crypto_alg))
14607 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14609 else if (unformat (i, "integ_alg %U",
14610 unformat_ipsec_api_integ_alg, &integ_alg))
14612 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14616 clib_warning ("parse error '%U'", format_unformat_error, i);
14622 M (IPSEC_SAD_ENTRY_ADD_DEL, mp);
14624 mp->is_add = is_add;
14625 mp->entry.sad_id = ntohl (sad_id);
14626 mp->entry.protocol = protocol;
14627 mp->entry.spi = ntohl (spi);
14628 mp->entry.flags = flags;
14630 mp->entry.crypto_algorithm = crypto_alg;
14631 mp->entry.integrity_algorithm = integ_alg;
14632 mp->entry.crypto_key.length = vec_len (ck);
14633 mp->entry.integrity_key.length = vec_len (ik);
14635 if (mp->entry.crypto_key.length > sizeof (mp->entry.crypto_key.data))
14636 mp->entry.crypto_key.length = sizeof (mp->entry.crypto_key.data);
14638 if (mp->entry.integrity_key.length > sizeof (mp->entry.integrity_key.data))
14639 mp->entry.integrity_key.length = sizeof (mp->entry.integrity_key.data);
14642 clib_memcpy (mp->entry.crypto_key.data, ck, mp->entry.crypto_key.length);
14644 clib_memcpy (mp->entry.integrity_key.data, ik,
14645 mp->entry.integrity_key.length);
14647 if (flags & IPSEC_API_SAD_FLAG_IS_TUNNEL)
14649 clib_memcpy (&mp->entry.tunnel_src, &tun_src,
14650 sizeof (mp->entry.tunnel_src));
14651 clib_memcpy (&mp->entry.tunnel_dst, &tun_dst,
14652 sizeof (mp->entry.tunnel_dst));
14661 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
14663 unformat_input_t *i = vam->input;
14664 vl_api_ipsec_tunnel_if_add_del_t *mp;
14665 u32 local_spi = 0, remote_spi = 0;
14666 u32 crypto_alg = 0, integ_alg = 0;
14667 u8 *lck = NULL, *rck = NULL;
14668 u8 *lik = NULL, *rik = NULL;
14669 vl_api_address_t local_ip = { 0 };
14670 vl_api_address_t remote_ip = { 0 };
14674 u8 anti_replay = 0;
14680 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14682 if (unformat (i, "del"))
14684 else if (unformat (i, "esn"))
14686 else if (unformat (i, "anti-replay"))
14688 else if (unformat (i, "count %d", &count))
14690 else if (unformat (i, "local_spi %d", &local_spi))
14692 else if (unformat (i, "remote_spi %d", &remote_spi))
14695 if (unformat (i, "local_ip %U", unformat_vl_api_address, &local_ip))
14698 if (unformat (i, "remote_ip %U", unformat_vl_api_address, &remote_ip))
14700 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
14703 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
14705 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
14707 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
14711 (i, "crypto_alg %U", unformat_ipsec_api_crypto_alg, &crypto_alg))
14713 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
14715 errmsg ("unsupported crypto-alg: '%U'\n",
14716 format_ipsec_crypto_alg, crypto_alg);
14722 (i, "integ_alg %U", unformat_ipsec_api_integ_alg, &integ_alg))
14724 if (integ_alg >= IPSEC_INTEG_N_ALG)
14726 errmsg ("unsupported integ-alg: '%U'\n",
14727 format_ipsec_integ_alg, integ_alg);
14731 else if (unformat (i, "instance %u", &instance))
14735 errmsg ("parse error '%U'\n", format_unformat_error, i);
14742 /* Turn on async mode */
14743 vam->async_mode = 1;
14744 vam->async_errors = 0;
14745 before = vat_time_now (vam);
14748 for (jj = 0; jj < count; jj++)
14750 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
14752 mp->is_add = is_add;
14754 mp->anti_replay = anti_replay;
14757 increment_address (&remote_ip);
14759 clib_memcpy (&mp->local_ip, &local_ip, sizeof (local_ip));
14760 clib_memcpy (&mp->remote_ip, &remote_ip, sizeof (remote_ip));
14762 mp->local_spi = htonl (local_spi + jj);
14763 mp->remote_spi = htonl (remote_spi + jj);
14764 mp->crypto_alg = (u8) crypto_alg;
14766 mp->local_crypto_key_len = 0;
14769 mp->local_crypto_key_len = vec_len (lck);
14770 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
14771 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
14772 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
14775 mp->remote_crypto_key_len = 0;
14778 mp->remote_crypto_key_len = vec_len (rck);
14779 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
14780 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
14781 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
14784 mp->integ_alg = (u8) integ_alg;
14786 mp->local_integ_key_len = 0;
14789 mp->local_integ_key_len = vec_len (lik);
14790 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
14791 mp->local_integ_key_len = sizeof (mp->local_integ_key);
14792 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
14795 mp->remote_integ_key_len = 0;
14798 mp->remote_integ_key_len = vec_len (rik);
14799 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
14800 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
14801 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
14806 mp->renumber = renumber;
14807 mp->show_instance = ntohl (instance);
14812 /* When testing multiple add/del ops, use a control-ping to sync */
14815 vl_api_control_ping_t *mp_ping;
14819 /* Shut off async mode */
14820 vam->async_mode = 0;
14822 MPING (CONTROL_PING, mp_ping);
14825 timeout = vat_time_now (vam) + 1.0;
14826 while (vat_time_now (vam) < timeout)
14827 if (vam->result_ready == 1)
14832 if (vam->retval == -99)
14833 errmsg ("timeout");
14835 if (vam->async_errors > 0)
14837 errmsg ("%d asynchronous errors", vam->async_errors);
14840 vam->async_errors = 0;
14841 after = vat_time_now (vam);
14843 /* slim chance, but we might have eaten SIGTERM on the first iteration */
14847 print (vam->ofp, "%d tunnels in %.6f secs, %.2f tunnels/sec",
14848 count, after - before, count / (after - before));
14852 /* Wait for a reply... */
14861 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
14863 vat_main_t *vam = &vat_main;
14865 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
14866 "crypto_key %U integ_alg %u integ_key %U flags %x "
14867 "tunnel_src_addr %U tunnel_dst_addr %U "
14868 "salt %u seq_outbound %lu last_seq_inbound %lu "
14869 "replay_window %lu\n",
14870 ntohl (mp->entry.sad_id),
14871 ntohl (mp->sw_if_index),
14872 ntohl (mp->entry.spi),
14873 ntohl (mp->entry.protocol),
14874 ntohl (mp->entry.crypto_algorithm),
14875 format_hex_bytes, mp->entry.crypto_key.data,
14876 mp->entry.crypto_key.length, ntohl (mp->entry.integrity_algorithm),
14877 format_hex_bytes, mp->entry.integrity_key.data,
14878 mp->entry.integrity_key.length, ntohl (mp->entry.flags),
14879 format_vl_api_address, &mp->entry.tunnel_src, format_vl_api_address,
14880 &mp->entry.tunnel_dst, ntohl (mp->salt),
14881 clib_net_to_host_u64 (mp->seq_outbound),
14882 clib_net_to_host_u64 (mp->last_seq_inbound),
14883 clib_net_to_host_u64 (mp->replay_window));
14886 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
14887 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
14889 static void vl_api_ipsec_sa_details_t_handler_json
14890 (vl_api_ipsec_sa_details_t * mp)
14892 vat_main_t *vam = &vat_main;
14893 vat_json_node_t *node = NULL;
14894 vl_api_ipsec_sad_flags_t flags;
14896 if (VAT_JSON_ARRAY != vam->json_tree.type)
14898 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14899 vat_json_init_array (&vam->json_tree);
14901 node = vat_json_array_add (&vam->json_tree);
14903 vat_json_init_object (node);
14904 vat_json_object_add_uint (node, "sa_id", ntohl (mp->entry.sad_id));
14905 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14906 vat_json_object_add_uint (node, "spi", ntohl (mp->entry.spi));
14907 vat_json_object_add_uint (node, "proto", ntohl (mp->entry.protocol));
14908 vat_json_object_add_uint (node, "crypto_alg",
14909 ntohl (mp->entry.crypto_algorithm));
14910 vat_json_object_add_uint (node, "integ_alg",
14911 ntohl (mp->entry.integrity_algorithm));
14912 flags = ntohl (mp->entry.flags);
14913 vat_json_object_add_uint (node, "use_esn",
14914 ! !(flags & IPSEC_API_SAD_FLAG_USE_ESN));
14915 vat_json_object_add_uint (node, "use_anti_replay",
14916 ! !(flags & IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY));
14917 vat_json_object_add_uint (node, "is_tunnel",
14918 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL));
14919 vat_json_object_add_uint (node, "is_tunnel_ip6",
14920 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL_V6));
14921 vat_json_object_add_uint (node, "udp_encap",
14922 ! !(flags & IPSEC_API_SAD_FLAG_UDP_ENCAP));
14923 vat_json_object_add_bytes (node, "crypto_key", mp->entry.crypto_key.data,
14924 mp->entry.crypto_key.length);
14925 vat_json_object_add_bytes (node, "integ_key", mp->entry.integrity_key.data,
14926 mp->entry.integrity_key.length);
14927 vat_json_object_add_address (node, "src", &mp->entry.tunnel_src);
14928 vat_json_object_add_address (node, "dst", &mp->entry.tunnel_dst);
14929 vat_json_object_add_uint (node, "replay_window",
14930 clib_net_to_host_u64 (mp->replay_window));
14934 api_ipsec_sa_dump (vat_main_t * vam)
14936 unformat_input_t *i = vam->input;
14937 vl_api_ipsec_sa_dump_t *mp;
14938 vl_api_control_ping_t *mp_ping;
14942 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14944 if (unformat (i, "sa_id %d", &sa_id))
14948 clib_warning ("parse error '%U'", format_unformat_error, i);
14953 M (IPSEC_SA_DUMP, mp);
14955 mp->sa_id = ntohl (sa_id);
14959 /* Use a control ping for synchronization */
14960 M (CONTROL_PING, mp_ping);
14968 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
14970 unformat_input_t *i = vam->input;
14971 vl_api_ipsec_tunnel_if_set_sa_t *mp;
14972 u32 sw_if_index = ~0;
14974 u8 is_outbound = (u8) ~ 0;
14977 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14979 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14981 else if (unformat (i, "sa_id %d", &sa_id))
14983 else if (unformat (i, "outbound"))
14985 else if (unformat (i, "inbound"))
14989 clib_warning ("parse error '%U'", format_unformat_error, i);
14994 if (sw_if_index == ~0)
14996 errmsg ("interface must be specified");
15002 errmsg ("SA ID must be specified");
15006 M (IPSEC_TUNNEL_IF_SET_SA, mp);
15008 mp->sw_if_index = htonl (sw_if_index);
15009 mp->sa_id = htonl (sa_id);
15010 mp->is_outbound = is_outbound;
15019 api_get_first_msg_id (vat_main_t * vam)
15021 vl_api_get_first_msg_id_t *mp;
15022 unformat_input_t *i = vam->input;
15027 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15029 if (unformat (i, "client %s", &name))
15037 errmsg ("missing client name");
15040 vec_add1 (name, 0);
15042 if (vec_len (name) > 63)
15044 errmsg ("client name too long");
15048 M (GET_FIRST_MSG_ID, mp);
15049 clib_memcpy (mp->name, name, vec_len (name));
15056 api_cop_interface_enable_disable (vat_main_t * vam)
15058 unformat_input_t *line_input = vam->input;
15059 vl_api_cop_interface_enable_disable_t *mp;
15060 u32 sw_if_index = ~0;
15061 u8 enable_disable = 1;
15064 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15066 if (unformat (line_input, "disable"))
15067 enable_disable = 0;
15068 if (unformat (line_input, "enable"))
15069 enable_disable = 1;
15070 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15071 vam, &sw_if_index))
15073 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15079 if (sw_if_index == ~0)
15081 errmsg ("missing interface name or sw_if_index");
15085 /* Construct the API message */
15086 M (COP_INTERFACE_ENABLE_DISABLE, mp);
15087 mp->sw_if_index = ntohl (sw_if_index);
15088 mp->enable_disable = enable_disable;
15092 /* Wait for the reply */
15098 api_cop_whitelist_enable_disable (vat_main_t * vam)
15100 unformat_input_t *line_input = vam->input;
15101 vl_api_cop_whitelist_enable_disable_t *mp;
15102 u32 sw_if_index = ~0;
15103 u8 ip4 = 0, ip6 = 0, default_cop = 0;
15107 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15109 if (unformat (line_input, "ip4"))
15111 else if (unformat (line_input, "ip6"))
15113 else if (unformat (line_input, "default"))
15115 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15116 vam, &sw_if_index))
15118 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15120 else if (unformat (line_input, "fib-id %d", &fib_id))
15126 if (sw_if_index == ~0)
15128 errmsg ("missing interface name or sw_if_index");
15132 /* Construct the API message */
15133 M (COP_WHITELIST_ENABLE_DISABLE, mp);
15134 mp->sw_if_index = ntohl (sw_if_index);
15135 mp->fib_id = ntohl (fib_id);
15138 mp->default_cop = default_cop;
15142 /* Wait for the reply */
15148 api_get_node_graph (vat_main_t * vam)
15150 vl_api_get_node_graph_t *mp;
15153 M (GET_NODE_GRAPH, mp);
15157 /* Wait for the reply */
15163 /** Used for parsing LISP eids */
15164 typedef CLIB_PACKED(struct{
15165 u8 addr[16]; /**< eid address */
15166 u32 len; /**< prefix length if IP */
15167 u8 type; /**< type of eid */
15172 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
15174 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
15176 clib_memset (a, 0, sizeof (a[0]));
15178 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
15180 a->type = 0; /* ipv4 type */
15182 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
15184 a->type = 1; /* ipv6 type */
15186 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
15188 a->type = 2; /* mac type */
15190 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
15192 a->type = 3; /* NSH type */
15193 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
15194 nsh->spi = clib_host_to_net_u32 (nsh->spi);
15201 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
15210 lisp_eid_size_vat (u8 type)
15227 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
15229 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
15233 api_one_add_del_locator_set (vat_main_t * vam)
15235 unformat_input_t *input = vam->input;
15236 vl_api_one_add_del_locator_set_t *mp;
15238 u8 *locator_set_name = NULL;
15239 u8 locator_set_name_set = 0;
15240 vl_api_local_locator_t locator, *locators = 0;
15241 u32 sw_if_index, priority, weight;
15245 /* Parse args required to build the message */
15246 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15248 if (unformat (input, "del"))
15252 else if (unformat (input, "locator-set %s", &locator_set_name))
15254 locator_set_name_set = 1;
15256 else if (unformat (input, "sw_if_index %u p %u w %u",
15257 &sw_if_index, &priority, &weight))
15259 locator.sw_if_index = htonl (sw_if_index);
15260 locator.priority = priority;
15261 locator.weight = weight;
15262 vec_add1 (locators, locator);
15266 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
15267 &sw_if_index, &priority, &weight))
15269 locator.sw_if_index = htonl (sw_if_index);
15270 locator.priority = priority;
15271 locator.weight = weight;
15272 vec_add1 (locators, locator);
15278 if (locator_set_name_set == 0)
15280 errmsg ("missing locator-set name");
15281 vec_free (locators);
15285 if (vec_len (locator_set_name) > 64)
15287 errmsg ("locator-set name too long");
15288 vec_free (locator_set_name);
15289 vec_free (locators);
15292 vec_add1 (locator_set_name, 0);
15294 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
15296 /* Construct the API message */
15297 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
15299 mp->is_add = is_add;
15300 clib_memcpy (mp->locator_set_name, locator_set_name,
15301 vec_len (locator_set_name));
15302 vec_free (locator_set_name);
15304 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
15306 clib_memcpy (mp->locators, locators, data_len);
15307 vec_free (locators);
15312 /* Wait for a reply... */
15317 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
15320 api_one_add_del_locator (vat_main_t * vam)
15322 unformat_input_t *input = vam->input;
15323 vl_api_one_add_del_locator_t *mp;
15324 u32 tmp_if_index = ~0;
15325 u32 sw_if_index = ~0;
15326 u8 sw_if_index_set = 0;
15327 u8 sw_if_index_if_name_set = 0;
15329 u8 priority_set = 0;
15333 u8 *locator_set_name = NULL;
15334 u8 locator_set_name_set = 0;
15337 /* Parse args required to build the message */
15338 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15340 if (unformat (input, "del"))
15344 else if (unformat (input, "locator-set %s", &locator_set_name))
15346 locator_set_name_set = 1;
15348 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
15351 sw_if_index_if_name_set = 1;
15352 sw_if_index = tmp_if_index;
15354 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
15356 sw_if_index_set = 1;
15357 sw_if_index = tmp_if_index;
15359 else if (unformat (input, "p %d", &priority))
15363 else if (unformat (input, "w %d", &weight))
15371 if (locator_set_name_set == 0)
15373 errmsg ("missing locator-set name");
15377 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
15379 errmsg ("missing sw_if_index");
15380 vec_free (locator_set_name);
15384 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
15386 errmsg ("cannot use both params interface name and sw_if_index");
15387 vec_free (locator_set_name);
15391 if (priority_set == 0)
15393 errmsg ("missing locator-set priority");
15394 vec_free (locator_set_name);
15398 if (weight_set == 0)
15400 errmsg ("missing locator-set weight");
15401 vec_free (locator_set_name);
15405 if (vec_len (locator_set_name) > 64)
15407 errmsg ("locator-set name too long");
15408 vec_free (locator_set_name);
15411 vec_add1 (locator_set_name, 0);
15413 /* Construct the API message */
15414 M (ONE_ADD_DEL_LOCATOR, mp);
15416 mp->is_add = is_add;
15417 mp->sw_if_index = ntohl (sw_if_index);
15418 mp->priority = priority;
15419 mp->weight = weight;
15420 clib_memcpy (mp->locator_set_name, locator_set_name,
15421 vec_len (locator_set_name));
15422 vec_free (locator_set_name);
15427 /* Wait for a reply... */
15432 #define api_lisp_add_del_locator api_one_add_del_locator
15435 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
15437 u32 *key_id = va_arg (*args, u32 *);
15440 if (unformat (input, "%s", &s))
15442 if (!strcmp ((char *) s, "sha1"))
15443 key_id[0] = HMAC_SHA_1_96;
15444 else if (!strcmp ((char *) s, "sha256"))
15445 key_id[0] = HMAC_SHA_256_128;
15448 clib_warning ("invalid key_id: '%s'", s);
15449 key_id[0] = HMAC_NO_KEY;
15460 api_one_add_del_local_eid (vat_main_t * vam)
15462 unformat_input_t *input = vam->input;
15463 vl_api_one_add_del_local_eid_t *mp;
15466 lisp_eid_vat_t _eid, *eid = &_eid;
15467 u8 *locator_set_name = 0;
15468 u8 locator_set_name_set = 0;
15474 /* Parse args required to build the message */
15475 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15477 if (unformat (input, "del"))
15481 else if (unformat (input, "vni %d", &vni))
15485 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15489 else if (unformat (input, "locator-set %s", &locator_set_name))
15491 locator_set_name_set = 1;
15493 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
15495 else if (unformat (input, "secret-key %_%v%_", &key))
15501 if (locator_set_name_set == 0)
15503 errmsg ("missing locator-set name");
15509 errmsg ("EID address not set!");
15510 vec_free (locator_set_name);
15514 if (key && (0 == key_id))
15516 errmsg ("invalid key_id!");
15520 if (vec_len (key) > 64)
15522 errmsg ("key too long");
15527 if (vec_len (locator_set_name) > 64)
15529 errmsg ("locator-set name too long");
15530 vec_free (locator_set_name);
15533 vec_add1 (locator_set_name, 0);
15535 /* Construct the API message */
15536 M (ONE_ADD_DEL_LOCAL_EID, mp);
15538 mp->is_add = is_add;
15539 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15540 mp->eid_type = eid->type;
15541 mp->prefix_len = eid->len;
15542 mp->vni = clib_host_to_net_u32 (vni);
15543 mp->key_id = clib_host_to_net_u16 (key_id);
15544 clib_memcpy (mp->locator_set_name, locator_set_name,
15545 vec_len (locator_set_name));
15546 clib_memcpy (mp->key, key, vec_len (key));
15548 vec_free (locator_set_name);
15554 /* Wait for a reply... */
15559 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
15562 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
15564 u32 dp_table = 0, vni = 0;;
15565 unformat_input_t *input = vam->input;
15566 vl_api_gpe_add_del_fwd_entry_t *mp;
15568 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
15569 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
15570 u8 rmt_eid_set = 0, lcl_eid_set = 0;
15571 u32 action = ~0, w;
15572 ip4_address_t rmt_rloc4, lcl_rloc4;
15573 ip6_address_t rmt_rloc6, lcl_rloc6;
15574 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
15577 clib_memset (&rloc, 0, sizeof (rloc));
15579 /* Parse args required to build the message */
15580 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15582 if (unformat (input, "del"))
15584 else if (unformat (input, "add"))
15586 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
15590 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
15594 else if (unformat (input, "vrf %d", &dp_table))
15596 else if (unformat (input, "bd %d", &dp_table))
15598 else if (unformat (input, "vni %d", &vni))
15600 else if (unformat (input, "w %d", &w))
15604 errmsg ("No RLOC configured for setting priority/weight!");
15607 curr_rloc->weight = w;
15609 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
15610 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
15614 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
15616 vec_add1 (lcl_locs, rloc);
15618 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
15619 vec_add1 (rmt_locs, rloc);
15620 /* weight saved in rmt loc */
15621 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15623 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
15624 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
15627 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
15629 vec_add1 (lcl_locs, rloc);
15631 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
15632 vec_add1 (rmt_locs, rloc);
15633 /* weight saved in rmt loc */
15634 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15636 else if (unformat (input, "action %d", &action))
15642 clib_warning ("parse error '%U'", format_unformat_error, input);
15649 errmsg ("remote eid addresses not set");
15653 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
15655 errmsg ("eid types don't match");
15659 if (0 == rmt_locs && (u32) ~ 0 == action)
15661 errmsg ("action not set for negative mapping");
15665 /* Construct the API message */
15666 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
15667 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
15669 mp->is_add = is_add;
15670 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
15671 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
15672 mp->eid_type = rmt_eid->type;
15673 mp->dp_table = clib_host_to_net_u32 (dp_table);
15674 mp->vni = clib_host_to_net_u32 (vni);
15675 mp->rmt_len = rmt_eid->len;
15676 mp->lcl_len = lcl_eid->len;
15677 mp->action = action;
15679 if (0 != rmt_locs && 0 != lcl_locs)
15681 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
15682 clib_memcpy (mp->locs, lcl_locs,
15683 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
15685 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
15686 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
15687 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
15689 vec_free (lcl_locs);
15690 vec_free (rmt_locs);
15695 /* Wait for a reply... */
15701 api_one_add_del_map_server (vat_main_t * vam)
15703 unformat_input_t *input = vam->input;
15704 vl_api_one_add_del_map_server_t *mp;
15708 ip4_address_t ipv4;
15709 ip6_address_t ipv6;
15712 /* Parse args required to build the message */
15713 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15715 if (unformat (input, "del"))
15719 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15723 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15731 if (ipv4_set && ipv6_set)
15733 errmsg ("both eid v4 and v6 addresses set");
15737 if (!ipv4_set && !ipv6_set)
15739 errmsg ("eid addresses not set");
15743 /* Construct the API message */
15744 M (ONE_ADD_DEL_MAP_SERVER, mp);
15746 mp->is_add = is_add;
15750 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
15755 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
15761 /* Wait for a reply... */
15766 #define api_lisp_add_del_map_server api_one_add_del_map_server
15769 api_one_add_del_map_resolver (vat_main_t * vam)
15771 unformat_input_t *input = vam->input;
15772 vl_api_one_add_del_map_resolver_t *mp;
15776 ip4_address_t ipv4;
15777 ip6_address_t ipv6;
15780 /* Parse args required to build the message */
15781 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15783 if (unformat (input, "del"))
15787 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15791 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15799 if (ipv4_set && ipv6_set)
15801 errmsg ("both eid v4 and v6 addresses set");
15805 if (!ipv4_set && !ipv6_set)
15807 errmsg ("eid addresses not set");
15811 /* Construct the API message */
15812 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
15814 mp->is_add = is_add;
15818 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
15823 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
15829 /* Wait for a reply... */
15834 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
15837 api_lisp_gpe_enable_disable (vat_main_t * vam)
15839 unformat_input_t *input = vam->input;
15840 vl_api_gpe_enable_disable_t *mp;
15845 /* Parse args required to build the message */
15846 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15848 if (unformat (input, "enable"))
15853 else if (unformat (input, "disable"))
15864 errmsg ("Value not set");
15868 /* Construct the API message */
15869 M (GPE_ENABLE_DISABLE, mp);
15876 /* Wait for a reply... */
15882 api_one_rloc_probe_enable_disable (vat_main_t * vam)
15884 unformat_input_t *input = vam->input;
15885 vl_api_one_rloc_probe_enable_disable_t *mp;
15890 /* Parse args required to build the message */
15891 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15893 if (unformat (input, "enable"))
15898 else if (unformat (input, "disable"))
15906 errmsg ("Value not set");
15910 /* Construct the API message */
15911 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
15913 mp->is_enabled = is_en;
15918 /* Wait for a reply... */
15923 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
15926 api_one_map_register_enable_disable (vat_main_t * vam)
15928 unformat_input_t *input = vam->input;
15929 vl_api_one_map_register_enable_disable_t *mp;
15934 /* Parse args required to build the message */
15935 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15937 if (unformat (input, "enable"))
15942 else if (unformat (input, "disable"))
15950 errmsg ("Value not set");
15954 /* Construct the API message */
15955 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
15957 mp->is_enabled = is_en;
15962 /* Wait for a reply... */
15967 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
15970 api_one_enable_disable (vat_main_t * vam)
15972 unformat_input_t *input = vam->input;
15973 vl_api_one_enable_disable_t *mp;
15978 /* Parse args required to build the message */
15979 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15981 if (unformat (input, "enable"))
15986 else if (unformat (input, "disable"))
15996 errmsg ("Value not set");
16000 /* Construct the API message */
16001 M (ONE_ENABLE_DISABLE, mp);
16008 /* Wait for a reply... */
16013 #define api_lisp_enable_disable api_one_enable_disable
16016 api_one_enable_disable_xtr_mode (vat_main_t * vam)
16018 unformat_input_t *input = vam->input;
16019 vl_api_one_enable_disable_xtr_mode_t *mp;
16024 /* Parse args required to build the message */
16025 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16027 if (unformat (input, "enable"))
16032 else if (unformat (input, "disable"))
16042 errmsg ("Value not set");
16046 /* Construct the API message */
16047 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
16054 /* Wait for a reply... */
16060 api_one_show_xtr_mode (vat_main_t * vam)
16062 vl_api_one_show_xtr_mode_t *mp;
16065 /* Construct the API message */
16066 M (ONE_SHOW_XTR_MODE, mp);
16071 /* Wait for a reply... */
16077 api_one_enable_disable_pitr_mode (vat_main_t * vam)
16079 unformat_input_t *input = vam->input;
16080 vl_api_one_enable_disable_pitr_mode_t *mp;
16085 /* Parse args required to build the message */
16086 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16088 if (unformat (input, "enable"))
16093 else if (unformat (input, "disable"))
16103 errmsg ("Value not set");
16107 /* Construct the API message */
16108 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
16115 /* Wait for a reply... */
16121 api_one_show_pitr_mode (vat_main_t * vam)
16123 vl_api_one_show_pitr_mode_t *mp;
16126 /* Construct the API message */
16127 M (ONE_SHOW_PITR_MODE, mp);
16132 /* Wait for a reply... */
16138 api_one_enable_disable_petr_mode (vat_main_t * vam)
16140 unformat_input_t *input = vam->input;
16141 vl_api_one_enable_disable_petr_mode_t *mp;
16146 /* Parse args required to build the message */
16147 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16149 if (unformat (input, "enable"))
16154 else if (unformat (input, "disable"))
16164 errmsg ("Value not set");
16168 /* Construct the API message */
16169 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
16176 /* Wait for a reply... */
16182 api_one_show_petr_mode (vat_main_t * vam)
16184 vl_api_one_show_petr_mode_t *mp;
16187 /* Construct the API message */
16188 M (ONE_SHOW_PETR_MODE, mp);
16193 /* Wait for a reply... */
16199 api_show_one_map_register_state (vat_main_t * vam)
16201 vl_api_show_one_map_register_state_t *mp;
16204 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
16209 /* wait for reply */
16214 #define api_show_lisp_map_register_state api_show_one_map_register_state
16217 api_show_one_rloc_probe_state (vat_main_t * vam)
16219 vl_api_show_one_rloc_probe_state_t *mp;
16222 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
16227 /* wait for reply */
16232 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
16235 api_one_add_del_ndp_entry (vat_main_t * vam)
16237 vl_api_one_add_del_ndp_entry_t *mp;
16238 unformat_input_t *input = vam->input;
16243 u8 mac[6] = { 0, };
16244 u8 ip6[16] = { 0, };
16248 /* Parse args required to build the message */
16249 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16251 if (unformat (input, "del"))
16253 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16255 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
16257 else if (unformat (input, "bd %d", &bd))
16261 errmsg ("parse error '%U'", format_unformat_error, input);
16266 if (!bd_set || !ip_set || (!mac_set && is_add))
16268 errmsg ("Missing BD, IP or MAC!");
16272 M (ONE_ADD_DEL_NDP_ENTRY, mp);
16273 mp->is_add = is_add;
16274 clib_memcpy (mp->mac, mac, 6);
16275 mp->bd = clib_host_to_net_u32 (bd);
16276 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
16281 /* wait for reply */
16287 api_one_add_del_l2_arp_entry (vat_main_t * vam)
16289 vl_api_one_add_del_l2_arp_entry_t *mp;
16290 unformat_input_t *input = vam->input;
16295 u8 mac[6] = { 0, };
16296 u32 ip4 = 0, bd = ~0;
16299 /* Parse args required to build the message */
16300 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16302 if (unformat (input, "del"))
16304 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16306 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
16308 else if (unformat (input, "bd %d", &bd))
16312 errmsg ("parse error '%U'", format_unformat_error, input);
16317 if (!bd_set || !ip_set || (!mac_set && is_add))
16319 errmsg ("Missing BD, IP or MAC!");
16323 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
16324 mp->is_add = is_add;
16325 clib_memcpy (mp->mac, mac, 6);
16326 mp->bd = clib_host_to_net_u32 (bd);
16332 /* wait for reply */
16338 api_one_ndp_bd_get (vat_main_t * vam)
16340 vl_api_one_ndp_bd_get_t *mp;
16343 M (ONE_NDP_BD_GET, mp);
16348 /* wait for reply */
16354 api_one_ndp_entries_get (vat_main_t * vam)
16356 vl_api_one_ndp_entries_get_t *mp;
16357 unformat_input_t *input = vam->input;
16362 /* Parse args required to build the message */
16363 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16365 if (unformat (input, "bd %d", &bd))
16369 errmsg ("parse error '%U'", format_unformat_error, input);
16376 errmsg ("Expected bridge domain!");
16380 M (ONE_NDP_ENTRIES_GET, mp);
16381 mp->bd = clib_host_to_net_u32 (bd);
16386 /* wait for reply */
16392 api_one_l2_arp_bd_get (vat_main_t * vam)
16394 vl_api_one_l2_arp_bd_get_t *mp;
16397 M (ONE_L2_ARP_BD_GET, mp);
16402 /* wait for reply */
16408 api_one_l2_arp_entries_get (vat_main_t * vam)
16410 vl_api_one_l2_arp_entries_get_t *mp;
16411 unformat_input_t *input = vam->input;
16416 /* Parse args required to build the message */
16417 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16419 if (unformat (input, "bd %d", &bd))
16423 errmsg ("parse error '%U'", format_unformat_error, input);
16430 errmsg ("Expected bridge domain!");
16434 M (ONE_L2_ARP_ENTRIES_GET, mp);
16435 mp->bd = clib_host_to_net_u32 (bd);
16440 /* wait for reply */
16446 api_one_stats_enable_disable (vat_main_t * vam)
16448 vl_api_one_stats_enable_disable_t *mp;
16449 unformat_input_t *input = vam->input;
16454 /* Parse args required to build the message */
16455 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16457 if (unformat (input, "enable"))
16462 else if (unformat (input, "disable"))
16472 errmsg ("Value not set");
16476 M (ONE_STATS_ENABLE_DISABLE, mp);
16482 /* wait for reply */
16488 api_show_one_stats_enable_disable (vat_main_t * vam)
16490 vl_api_show_one_stats_enable_disable_t *mp;
16493 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
16498 /* wait for reply */
16504 api_show_one_map_request_mode (vat_main_t * vam)
16506 vl_api_show_one_map_request_mode_t *mp;
16509 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
16514 /* wait for reply */
16519 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
16522 api_one_map_request_mode (vat_main_t * vam)
16524 unformat_input_t *input = vam->input;
16525 vl_api_one_map_request_mode_t *mp;
16529 /* Parse args required to build the message */
16530 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16532 if (unformat (input, "dst-only"))
16534 else if (unformat (input, "src-dst"))
16538 errmsg ("parse error '%U'", format_unformat_error, input);
16543 M (ONE_MAP_REQUEST_MODE, mp);
16550 /* wait for reply */
16555 #define api_lisp_map_request_mode api_one_map_request_mode
16558 * Enable/disable ONE proxy ITR.
16560 * @param vam vpp API test context
16561 * @return return code
16564 api_one_pitr_set_locator_set (vat_main_t * vam)
16566 u8 ls_name_set = 0;
16567 unformat_input_t *input = vam->input;
16568 vl_api_one_pitr_set_locator_set_t *mp;
16573 /* Parse args required to build the message */
16574 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16576 if (unformat (input, "del"))
16578 else if (unformat (input, "locator-set %s", &ls_name))
16582 errmsg ("parse error '%U'", format_unformat_error, input);
16589 errmsg ("locator-set name not set!");
16593 M (ONE_PITR_SET_LOCATOR_SET, mp);
16595 mp->is_add = is_add;
16596 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16597 vec_free (ls_name);
16602 /* wait for reply */
16607 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
16610 api_one_nsh_set_locator_set (vat_main_t * vam)
16612 u8 ls_name_set = 0;
16613 unformat_input_t *input = vam->input;
16614 vl_api_one_nsh_set_locator_set_t *mp;
16619 /* Parse args required to build the message */
16620 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16622 if (unformat (input, "del"))
16624 else if (unformat (input, "ls %s", &ls_name))
16628 errmsg ("parse error '%U'", format_unformat_error, input);
16633 if (!ls_name_set && is_add)
16635 errmsg ("locator-set name not set!");
16639 M (ONE_NSH_SET_LOCATOR_SET, mp);
16641 mp->is_add = is_add;
16642 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16643 vec_free (ls_name);
16648 /* wait for reply */
16654 api_show_one_pitr (vat_main_t * vam)
16656 vl_api_show_one_pitr_t *mp;
16659 if (!vam->json_output)
16661 print (vam->ofp, "%=20s", "lisp status:");
16664 M (SHOW_ONE_PITR, mp);
16668 /* Wait for a reply... */
16673 #define api_show_lisp_pitr api_show_one_pitr
16676 api_one_use_petr (vat_main_t * vam)
16678 unformat_input_t *input = vam->input;
16679 vl_api_one_use_petr_t *mp;
16684 clib_memset (&ip, 0, sizeof (ip));
16686 /* Parse args required to build the message */
16687 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16689 if (unformat (input, "disable"))
16692 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
16695 ip_addr_version (&ip) = IP4;
16698 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
16701 ip_addr_version (&ip) = IP6;
16705 errmsg ("parse error '%U'", format_unformat_error, input);
16710 M (ONE_USE_PETR, mp);
16712 mp->is_add = is_add;
16715 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
16717 clib_memcpy (mp->address, &ip, 4);
16719 clib_memcpy (mp->address, &ip, 16);
16725 /* wait for reply */
16730 #define api_lisp_use_petr api_one_use_petr
16733 api_show_one_nsh_mapping (vat_main_t * vam)
16735 vl_api_show_one_use_petr_t *mp;
16738 if (!vam->json_output)
16740 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
16743 M (SHOW_ONE_NSH_MAPPING, mp);
16747 /* Wait for a reply... */
16753 api_show_one_use_petr (vat_main_t * vam)
16755 vl_api_show_one_use_petr_t *mp;
16758 if (!vam->json_output)
16760 print (vam->ofp, "%=20s", "Proxy-ETR status:");
16763 M (SHOW_ONE_USE_PETR, mp);
16767 /* Wait for a reply... */
16772 #define api_show_lisp_use_petr api_show_one_use_petr
16775 * Add/delete mapping between vni and vrf
16778 api_one_eid_table_add_del_map (vat_main_t * vam)
16780 unformat_input_t *input = vam->input;
16781 vl_api_one_eid_table_add_del_map_t *mp;
16782 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
16783 u32 vni, vrf, bd_index;
16786 /* Parse args required to build the message */
16787 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16789 if (unformat (input, "del"))
16791 else if (unformat (input, "vrf %d", &vrf))
16793 else if (unformat (input, "bd_index %d", &bd_index))
16795 else if (unformat (input, "vni %d", &vni))
16801 if (!vni_set || (!vrf_set && !bd_index_set))
16803 errmsg ("missing arguments!");
16807 if (vrf_set && bd_index_set)
16809 errmsg ("error: both vrf and bd entered!");
16813 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
16815 mp->is_add = is_add;
16816 mp->vni = htonl (vni);
16817 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
16818 mp->is_l2 = bd_index_set;
16823 /* wait for reply */
16828 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
16831 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
16833 u32 *action = va_arg (*args, u32 *);
16836 if (unformat (input, "%s", &s))
16838 if (!strcmp ((char *) s, "no-action"))
16840 else if (!strcmp ((char *) s, "natively-forward"))
16842 else if (!strcmp ((char *) s, "send-map-request"))
16844 else if (!strcmp ((char *) s, "drop"))
16848 clib_warning ("invalid action: '%s'", s);
16860 * Add/del remote mapping to/from ONE control plane
16862 * @param vam vpp API test context
16863 * @return return code
16866 api_one_add_del_remote_mapping (vat_main_t * vam)
16868 unformat_input_t *input = vam->input;
16869 vl_api_one_add_del_remote_mapping_t *mp;
16871 lisp_eid_vat_t _eid, *eid = &_eid;
16872 lisp_eid_vat_t _seid, *seid = &_seid;
16873 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
16874 u32 action = ~0, p, w, data_len;
16875 ip4_address_t rloc4;
16876 ip6_address_t rloc6;
16877 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
16880 clib_memset (&rloc, 0, sizeof (rloc));
16882 /* Parse args required to build the message */
16883 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16885 if (unformat (input, "del-all"))
16889 else if (unformat (input, "del"))
16893 else if (unformat (input, "add"))
16897 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
16901 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
16905 else if (unformat (input, "vni %d", &vni))
16909 else if (unformat (input, "p %d w %d", &p, &w))
16913 errmsg ("No RLOC configured for setting priority/weight!");
16916 curr_rloc->priority = p;
16917 curr_rloc->weight = w;
16919 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
16922 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
16923 vec_add1 (rlocs, rloc);
16924 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16926 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
16929 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
16930 vec_add1 (rlocs, rloc);
16931 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16933 else if (unformat (input, "action %U",
16934 unformat_negative_mapping_action, &action))
16940 clib_warning ("parse error '%U'", format_unformat_error, input);
16947 errmsg ("missing params!");
16951 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
16953 errmsg ("no action set for negative map-reply!");
16957 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
16959 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
16960 mp->is_add = is_add;
16961 mp->vni = htonl (vni);
16962 mp->action = (u8) action;
16963 mp->is_src_dst = seid_set;
16964 mp->eid_len = eid->len;
16965 mp->seid_len = seid->len;
16966 mp->del_all = del_all;
16967 mp->eid_type = eid->type;
16968 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
16969 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
16971 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
16972 clib_memcpy (mp->rlocs, rlocs, data_len);
16978 /* Wait for a reply... */
16983 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
16986 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
16987 * forwarding entries in data-plane accordingly.
16989 * @param vam vpp API test context
16990 * @return return code
16993 api_one_add_del_adjacency (vat_main_t * vam)
16995 unformat_input_t *input = vam->input;
16996 vl_api_one_add_del_adjacency_t *mp;
16998 ip4_address_t leid4, reid4;
16999 ip6_address_t leid6, reid6;
17000 u8 reid_mac[6] = { 0 };
17001 u8 leid_mac[6] = { 0 };
17002 u8 reid_type, leid_type;
17003 u32 leid_len = 0, reid_len = 0, len;
17007 leid_type = reid_type = (u8) ~ 0;
17009 /* Parse args required to build the message */
17010 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17012 if (unformat (input, "del"))
17016 else if (unformat (input, "add"))
17020 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
17023 reid_type = 0; /* ipv4 */
17026 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
17029 reid_type = 1; /* ipv6 */
17032 else if (unformat (input, "reid %U", unformat_ethernet_address,
17035 reid_type = 2; /* mac */
17037 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
17040 leid_type = 0; /* ipv4 */
17043 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
17046 leid_type = 1; /* ipv6 */
17049 else if (unformat (input, "leid %U", unformat_ethernet_address,
17052 leid_type = 2; /* mac */
17054 else if (unformat (input, "vni %d", &vni))
17060 errmsg ("parse error '%U'", format_unformat_error, input);
17065 if ((u8) ~ 0 == reid_type)
17067 errmsg ("missing params!");
17071 if (leid_type != reid_type)
17073 errmsg ("remote and local EIDs are of different types!");
17077 M (ONE_ADD_DEL_ADJACENCY, mp);
17078 mp->is_add = is_add;
17079 mp->vni = htonl (vni);
17080 mp->leid_len = leid_len;
17081 mp->reid_len = reid_len;
17082 mp->eid_type = reid_type;
17084 switch (mp->eid_type)
17087 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
17088 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
17091 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
17092 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
17095 clib_memcpy (mp->leid, leid_mac, 6);
17096 clib_memcpy (mp->reid, reid_mac, 6);
17099 errmsg ("unknown EID type %d!", mp->eid_type);
17106 /* Wait for a reply... */
17111 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
17114 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
17116 u32 *mode = va_arg (*args, u32 *);
17118 if (unformat (input, "lisp"))
17120 else if (unformat (input, "vxlan"))
17129 api_gpe_get_encap_mode (vat_main_t * vam)
17131 vl_api_gpe_get_encap_mode_t *mp;
17134 /* Construct the API message */
17135 M (GPE_GET_ENCAP_MODE, mp);
17140 /* Wait for a reply... */
17146 api_gpe_set_encap_mode (vat_main_t * vam)
17148 unformat_input_t *input = vam->input;
17149 vl_api_gpe_set_encap_mode_t *mp;
17153 /* Parse args required to build the message */
17154 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17156 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
17162 /* Construct the API message */
17163 M (GPE_SET_ENCAP_MODE, mp);
17170 /* Wait for a reply... */
17176 api_lisp_gpe_add_del_iface (vat_main_t * vam)
17178 unformat_input_t *input = vam->input;
17179 vl_api_gpe_add_del_iface_t *mp;
17180 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
17181 u32 dp_table = 0, vni = 0;
17184 /* Parse args required to build the message */
17185 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17187 if (unformat (input, "up"))
17192 else if (unformat (input, "down"))
17197 else if (unformat (input, "table_id %d", &dp_table))
17201 else if (unformat (input, "bd_id %d", &dp_table))
17206 else if (unformat (input, "vni %d", &vni))
17214 if (action_set == 0)
17216 errmsg ("Action not set");
17219 if (dp_table_set == 0 || vni_set == 0)
17221 errmsg ("vni and dp_table must be set");
17225 /* Construct the API message */
17226 M (GPE_ADD_DEL_IFACE, mp);
17228 mp->is_add = is_add;
17229 mp->dp_table = clib_host_to_net_u32 (dp_table);
17231 mp->vni = clib_host_to_net_u32 (vni);
17236 /* Wait for a reply... */
17242 api_one_map_register_fallback_threshold (vat_main_t * vam)
17244 unformat_input_t *input = vam->input;
17245 vl_api_one_map_register_fallback_threshold_t *mp;
17250 /* Parse args required to build the message */
17251 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17253 if (unformat (input, "%u", &value))
17257 clib_warning ("parse error '%U'", format_unformat_error, input);
17264 errmsg ("fallback threshold value is missing!");
17268 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17269 mp->value = clib_host_to_net_u32 (value);
17274 /* Wait for a reply... */
17280 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
17282 vl_api_show_one_map_register_fallback_threshold_t *mp;
17285 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17290 /* Wait for a reply... */
17296 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
17298 u32 *proto = va_arg (*args, u32 *);
17300 if (unformat (input, "udp"))
17302 else if (unformat (input, "api"))
17311 api_one_set_transport_protocol (vat_main_t * vam)
17313 unformat_input_t *input = vam->input;
17314 vl_api_one_set_transport_protocol_t *mp;
17319 /* Parse args required to build the message */
17320 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17322 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
17326 clib_warning ("parse error '%U'", format_unformat_error, input);
17333 errmsg ("Transport protocol missing!");
17337 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
17338 mp->protocol = (u8) protocol;
17343 /* Wait for a reply... */
17349 api_one_get_transport_protocol (vat_main_t * vam)
17351 vl_api_one_get_transport_protocol_t *mp;
17354 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
17359 /* Wait for a reply... */
17365 api_one_map_register_set_ttl (vat_main_t * vam)
17367 unformat_input_t *input = vam->input;
17368 vl_api_one_map_register_set_ttl_t *mp;
17373 /* Parse args required to build the message */
17374 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17376 if (unformat (input, "%u", &ttl))
17380 clib_warning ("parse error '%U'", format_unformat_error, input);
17387 errmsg ("TTL value missing!");
17391 M (ONE_MAP_REGISTER_SET_TTL, mp);
17392 mp->ttl = clib_host_to_net_u32 (ttl);
17397 /* Wait for a reply... */
17403 api_show_one_map_register_ttl (vat_main_t * vam)
17405 vl_api_show_one_map_register_ttl_t *mp;
17408 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
17413 /* Wait for a reply... */
17419 * Add/del map request itr rlocs from ONE control plane and updates
17421 * @param vam vpp API test context
17422 * @return return code
17425 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
17427 unformat_input_t *input = vam->input;
17428 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
17429 u8 *locator_set_name = 0;
17430 u8 locator_set_name_set = 0;
17434 /* Parse args required to build the message */
17435 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17437 if (unformat (input, "del"))
17441 else if (unformat (input, "%_%v%_", &locator_set_name))
17443 locator_set_name_set = 1;
17447 clib_warning ("parse error '%U'", format_unformat_error, input);
17452 if (is_add && !locator_set_name_set)
17454 errmsg ("itr-rloc is not set!");
17458 if (is_add && vec_len (locator_set_name) > 64)
17460 errmsg ("itr-rloc locator-set name too long");
17461 vec_free (locator_set_name);
17465 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
17466 mp->is_add = is_add;
17469 clib_memcpy (mp->locator_set_name, locator_set_name,
17470 vec_len (locator_set_name));
17474 clib_memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
17476 vec_free (locator_set_name);
17481 /* Wait for a reply... */
17486 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
17489 api_one_locator_dump (vat_main_t * vam)
17491 unformat_input_t *input = vam->input;
17492 vl_api_one_locator_dump_t *mp;
17493 vl_api_control_ping_t *mp_ping;
17494 u8 is_index_set = 0, is_name_set = 0;
17499 /* Parse args required to build the message */
17500 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17502 if (unformat (input, "ls_name %_%v%_", &ls_name))
17506 else if (unformat (input, "ls_index %d", &ls_index))
17512 errmsg ("parse error '%U'", format_unformat_error, input);
17517 if (!is_index_set && !is_name_set)
17519 errmsg ("error: expected one of index or name!");
17523 if (is_index_set && is_name_set)
17525 errmsg ("error: only one param expected!");
17529 if (vec_len (ls_name) > 62)
17531 errmsg ("error: locator set name too long!");
17535 if (!vam->json_output)
17537 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
17540 M (ONE_LOCATOR_DUMP, mp);
17541 mp->is_index_set = is_index_set;
17544 mp->ls_index = clib_host_to_net_u32 (ls_index);
17547 vec_add1 (ls_name, 0);
17548 strncpy ((char *) mp->ls_name, (char *) ls_name,
17549 sizeof (mp->ls_name) - 1);
17555 /* Use a control ping for synchronization */
17556 MPING (CONTROL_PING, mp_ping);
17559 /* Wait for a reply... */
17564 #define api_lisp_locator_dump api_one_locator_dump
17567 api_one_locator_set_dump (vat_main_t * vam)
17569 vl_api_one_locator_set_dump_t *mp;
17570 vl_api_control_ping_t *mp_ping;
17571 unformat_input_t *input = vam->input;
17575 /* Parse args required to build the message */
17576 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17578 if (unformat (input, "local"))
17582 else if (unformat (input, "remote"))
17588 errmsg ("parse error '%U'", format_unformat_error, input);
17593 if (!vam->json_output)
17595 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
17598 M (ONE_LOCATOR_SET_DUMP, mp);
17600 mp->filter = filter;
17605 /* Use a control ping for synchronization */
17606 MPING (CONTROL_PING, mp_ping);
17609 /* Wait for a reply... */
17614 #define api_lisp_locator_set_dump api_one_locator_set_dump
17617 api_one_eid_table_map_dump (vat_main_t * vam)
17621 unformat_input_t *input = vam->input;
17622 vl_api_one_eid_table_map_dump_t *mp;
17623 vl_api_control_ping_t *mp_ping;
17626 /* Parse args required to build the message */
17627 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17629 if (unformat (input, "l2"))
17634 else if (unformat (input, "l3"))
17641 errmsg ("parse error '%U'", format_unformat_error, input);
17648 errmsg ("expected one of 'l2' or 'l3' parameter!");
17652 if (!vam->json_output)
17654 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
17657 M (ONE_EID_TABLE_MAP_DUMP, mp);
17663 /* Use a control ping for synchronization */
17664 MPING (CONTROL_PING, mp_ping);
17667 /* Wait for a reply... */
17672 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
17675 api_one_eid_table_vni_dump (vat_main_t * vam)
17677 vl_api_one_eid_table_vni_dump_t *mp;
17678 vl_api_control_ping_t *mp_ping;
17681 if (!vam->json_output)
17683 print (vam->ofp, "VNI");
17686 M (ONE_EID_TABLE_VNI_DUMP, mp);
17691 /* Use a control ping for synchronization */
17692 MPING (CONTROL_PING, mp_ping);
17695 /* Wait for a reply... */
17700 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
17703 api_one_eid_table_dump (vat_main_t * vam)
17705 unformat_input_t *i = vam->input;
17706 vl_api_one_eid_table_dump_t *mp;
17707 vl_api_control_ping_t *mp_ping;
17708 struct in_addr ip4;
17709 struct in6_addr ip6;
17711 u8 eid_type = ~0, eid_set = 0;
17712 u32 prefix_length = ~0, t, vni = 0;
17715 lisp_nsh_api_t nsh;
17717 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17719 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
17725 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
17731 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
17736 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
17741 else if (unformat (i, "vni %d", &t))
17745 else if (unformat (i, "local"))
17749 else if (unformat (i, "remote"))
17755 errmsg ("parse error '%U'", format_unformat_error, i);
17760 if (!vam->json_output)
17762 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
17763 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
17766 M (ONE_EID_TABLE_DUMP, mp);
17768 mp->filter = filter;
17772 mp->vni = htonl (vni);
17773 mp->eid_type = eid_type;
17777 mp->prefix_length = prefix_length;
17778 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
17781 mp->prefix_length = prefix_length;
17782 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
17785 clib_memcpy (mp->eid, mac, sizeof (mac));
17788 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
17791 errmsg ("unknown EID type %d!", eid_type);
17799 /* Use a control ping for synchronization */
17800 MPING (CONTROL_PING, mp_ping);
17803 /* Wait for a reply... */
17808 #define api_lisp_eid_table_dump api_one_eid_table_dump
17811 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
17813 unformat_input_t *i = vam->input;
17814 vl_api_gpe_fwd_entries_get_t *mp;
17819 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17821 if (unformat (i, "vni %d", &vni))
17827 errmsg ("parse error '%U'", format_unformat_error, i);
17834 errmsg ("vni not set!");
17838 if (!vam->json_output)
17840 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
17844 M (GPE_FWD_ENTRIES_GET, mp);
17845 mp->vni = clib_host_to_net_u32 (vni);
17850 /* Wait for a reply... */
17855 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
17856 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
17857 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
17858 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
17859 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
17860 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
17861 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
17862 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
17865 api_one_adjacencies_get (vat_main_t * vam)
17867 unformat_input_t *i = vam->input;
17868 vl_api_one_adjacencies_get_t *mp;
17873 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17875 if (unformat (i, "vni %d", &vni))
17881 errmsg ("parse error '%U'", format_unformat_error, i);
17888 errmsg ("vni not set!");
17892 if (!vam->json_output)
17894 print (vam->ofp, "%s %40s", "leid", "reid");
17897 M (ONE_ADJACENCIES_GET, mp);
17898 mp->vni = clib_host_to_net_u32 (vni);
17903 /* Wait for a reply... */
17908 #define api_lisp_adjacencies_get api_one_adjacencies_get
17911 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
17913 unformat_input_t *i = vam->input;
17914 vl_api_gpe_native_fwd_rpaths_get_t *mp;
17916 u8 ip_family_set = 0, is_ip4 = 1;
17918 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17920 if (unformat (i, "ip4"))
17925 else if (unformat (i, "ip6"))
17932 errmsg ("parse error '%U'", format_unformat_error, i);
17937 if (!ip_family_set)
17939 errmsg ("ip family not set!");
17943 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
17944 mp->is_ip4 = is_ip4;
17949 /* Wait for a reply... */
17955 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
17957 vl_api_gpe_fwd_entry_vnis_get_t *mp;
17960 if (!vam->json_output)
17962 print (vam->ofp, "VNIs");
17965 M (GPE_FWD_ENTRY_VNIS_GET, mp);
17970 /* Wait for a reply... */
17976 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
17978 unformat_input_t *i = vam->input;
17979 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
17981 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
17982 struct in_addr ip4;
17983 struct in6_addr ip6;
17984 u32 table_id = 0, nh_sw_if_index = ~0;
17986 clib_memset (&ip4, 0, sizeof (ip4));
17987 clib_memset (&ip6, 0, sizeof (ip6));
17989 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17991 if (unformat (i, "del"))
17993 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
17994 api_unformat_sw_if_index, vam, &nh_sw_if_index))
17999 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
18000 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18005 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
18009 nh_sw_if_index = ~0;
18011 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
18015 nh_sw_if_index = ~0;
18017 else if (unformat (i, "table %d", &table_id))
18021 errmsg ("parse error '%U'", format_unformat_error, i);
18028 errmsg ("nh addr not set!");
18032 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
18033 mp->is_add = is_add;
18034 mp->table_id = clib_host_to_net_u32 (table_id);
18035 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
18036 mp->is_ip4 = is_ip4;
18038 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
18040 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
18045 /* Wait for a reply... */
18051 api_one_map_server_dump (vat_main_t * vam)
18053 vl_api_one_map_server_dump_t *mp;
18054 vl_api_control_ping_t *mp_ping;
18057 if (!vam->json_output)
18059 print (vam->ofp, "%=20s", "Map server");
18062 M (ONE_MAP_SERVER_DUMP, mp);
18066 /* Use a control ping for synchronization */
18067 MPING (CONTROL_PING, mp_ping);
18070 /* Wait for a reply... */
18075 #define api_lisp_map_server_dump api_one_map_server_dump
18078 api_one_map_resolver_dump (vat_main_t * vam)
18080 vl_api_one_map_resolver_dump_t *mp;
18081 vl_api_control_ping_t *mp_ping;
18084 if (!vam->json_output)
18086 print (vam->ofp, "%=20s", "Map resolver");
18089 M (ONE_MAP_RESOLVER_DUMP, mp);
18093 /* Use a control ping for synchronization */
18094 MPING (CONTROL_PING, mp_ping);
18097 /* Wait for a reply... */
18102 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
18105 api_one_stats_flush (vat_main_t * vam)
18107 vl_api_one_stats_flush_t *mp;
18110 M (ONE_STATS_FLUSH, mp);
18117 api_one_stats_dump (vat_main_t * vam)
18119 vl_api_one_stats_dump_t *mp;
18120 vl_api_control_ping_t *mp_ping;
18123 M (ONE_STATS_DUMP, mp);
18127 /* Use a control ping for synchronization */
18128 MPING (CONTROL_PING, mp_ping);
18131 /* Wait for a reply... */
18137 api_show_one_status (vat_main_t * vam)
18139 vl_api_show_one_status_t *mp;
18142 if (!vam->json_output)
18144 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
18147 M (SHOW_ONE_STATUS, mp);
18150 /* Wait for a reply... */
18155 #define api_show_lisp_status api_show_one_status
18158 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
18160 vl_api_gpe_fwd_entry_path_dump_t *mp;
18161 vl_api_control_ping_t *mp_ping;
18162 unformat_input_t *i = vam->input;
18163 u32 fwd_entry_index = ~0;
18166 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18168 if (unformat (i, "index %d", &fwd_entry_index))
18174 if (~0 == fwd_entry_index)
18176 errmsg ("no index specified!");
18180 if (!vam->json_output)
18182 print (vam->ofp, "first line");
18185 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
18189 /* Use a control ping for synchronization */
18190 MPING (CONTROL_PING, mp_ping);
18193 /* Wait for a reply... */
18199 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
18201 vl_api_one_get_map_request_itr_rlocs_t *mp;
18204 if (!vam->json_output)
18206 print (vam->ofp, "%=20s", "itr-rlocs:");
18209 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
18212 /* Wait for a reply... */
18217 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
18220 api_af_packet_create (vat_main_t * vam)
18222 unformat_input_t *i = vam->input;
18223 vl_api_af_packet_create_t *mp;
18224 u8 *host_if_name = 0;
18226 u8 random_hw_addr = 1;
18229 clib_memset (hw_addr, 0, sizeof (hw_addr));
18231 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18233 if (unformat (i, "name %s", &host_if_name))
18234 vec_add1 (host_if_name, 0);
18235 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18236 random_hw_addr = 0;
18241 if (!vec_len (host_if_name))
18243 errmsg ("host-interface name must be specified");
18247 if (vec_len (host_if_name) > 64)
18249 errmsg ("host-interface name too long");
18253 M (AF_PACKET_CREATE, mp);
18255 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18256 clib_memcpy (mp->hw_addr, hw_addr, 6);
18257 mp->use_random_hw_addr = random_hw_addr;
18258 vec_free (host_if_name);
18266 fprintf (vam->ofp ? vam->ofp : stderr,
18267 " new sw_if_index = %d\n", vam->sw_if_index);
18274 api_af_packet_delete (vat_main_t * vam)
18276 unformat_input_t *i = vam->input;
18277 vl_api_af_packet_delete_t *mp;
18278 u8 *host_if_name = 0;
18281 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18283 if (unformat (i, "name %s", &host_if_name))
18284 vec_add1 (host_if_name, 0);
18289 if (!vec_len (host_if_name))
18291 errmsg ("host-interface name must be specified");
18295 if (vec_len (host_if_name) > 64)
18297 errmsg ("host-interface name too long");
18301 M (AF_PACKET_DELETE, mp);
18303 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18304 vec_free (host_if_name);
18311 static void vl_api_af_packet_details_t_handler
18312 (vl_api_af_packet_details_t * mp)
18314 vat_main_t *vam = &vat_main;
18316 print (vam->ofp, "%-16s %d",
18317 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
18320 static void vl_api_af_packet_details_t_handler_json
18321 (vl_api_af_packet_details_t * mp)
18323 vat_main_t *vam = &vat_main;
18324 vat_json_node_t *node = NULL;
18326 if (VAT_JSON_ARRAY != vam->json_tree.type)
18328 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18329 vat_json_init_array (&vam->json_tree);
18331 node = vat_json_array_add (&vam->json_tree);
18333 vat_json_init_object (node);
18334 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
18335 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
18339 api_af_packet_dump (vat_main_t * vam)
18341 vl_api_af_packet_dump_t *mp;
18342 vl_api_control_ping_t *mp_ping;
18345 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
18346 /* Get list of tap interfaces */
18347 M (AF_PACKET_DUMP, mp);
18350 /* Use a control ping for synchronization */
18351 MPING (CONTROL_PING, mp_ping);
18359 api_policer_add_del (vat_main_t * vam)
18361 unformat_input_t *i = vam->input;
18362 vl_api_policer_add_del_t *mp;
18372 u8 color_aware = 0;
18373 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
18376 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
18377 conform_action.dscp = 0;
18378 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
18379 exceed_action.dscp = 0;
18380 violate_action.action_type = SSE2_QOS_ACTION_DROP;
18381 violate_action.dscp = 0;
18383 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18385 if (unformat (i, "del"))
18387 else if (unformat (i, "name %s", &name))
18388 vec_add1 (name, 0);
18389 else if (unformat (i, "cir %u", &cir))
18391 else if (unformat (i, "eir %u", &eir))
18393 else if (unformat (i, "cb %u", &cb))
18395 else if (unformat (i, "eb %u", &eb))
18397 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
18400 else if (unformat (i, "round_type %U", unformat_policer_round_type,
18403 else if (unformat (i, "type %U", unformat_policer_type, &type))
18405 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
18408 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
18411 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
18414 else if (unformat (i, "color-aware"))
18420 if (!vec_len (name))
18422 errmsg ("policer name must be specified");
18426 if (vec_len (name) > 64)
18428 errmsg ("policer name too long");
18432 M (POLICER_ADD_DEL, mp);
18434 clib_memcpy (mp->name, name, vec_len (name));
18436 mp->is_add = is_add;
18437 mp->cir = ntohl (cir);
18438 mp->eir = ntohl (eir);
18439 mp->cb = clib_net_to_host_u64 (cb);
18440 mp->eb = clib_net_to_host_u64 (eb);
18441 mp->rate_type = rate_type;
18442 mp->round_type = round_type;
18444 mp->conform_action_type = conform_action.action_type;
18445 mp->conform_dscp = conform_action.dscp;
18446 mp->exceed_action_type = exceed_action.action_type;
18447 mp->exceed_dscp = exceed_action.dscp;
18448 mp->violate_action_type = violate_action.action_type;
18449 mp->violate_dscp = violate_action.dscp;
18450 mp->color_aware = color_aware;
18458 api_policer_dump (vat_main_t * vam)
18460 unformat_input_t *i = vam->input;
18461 vl_api_policer_dump_t *mp;
18462 vl_api_control_ping_t *mp_ping;
18463 u8 *match_name = 0;
18464 u8 match_name_valid = 0;
18467 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18469 if (unformat (i, "name %s", &match_name))
18471 vec_add1 (match_name, 0);
18472 match_name_valid = 1;
18478 M (POLICER_DUMP, mp);
18479 mp->match_name_valid = match_name_valid;
18480 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
18481 vec_free (match_name);
18485 /* Use a control ping for synchronization */
18486 MPING (CONTROL_PING, mp_ping);
18489 /* Wait for a reply... */
18495 api_policer_classify_set_interface (vat_main_t * vam)
18497 unformat_input_t *i = vam->input;
18498 vl_api_policer_classify_set_interface_t *mp;
18500 int sw_if_index_set;
18501 u32 ip4_table_index = ~0;
18502 u32 ip6_table_index = ~0;
18503 u32 l2_table_index = ~0;
18507 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18509 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18510 sw_if_index_set = 1;
18511 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18512 sw_if_index_set = 1;
18513 else if (unformat (i, "del"))
18515 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18517 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18519 else if (unformat (i, "l2-table %d", &l2_table_index))
18523 clib_warning ("parse error '%U'", format_unformat_error, i);
18528 if (sw_if_index_set == 0)
18530 errmsg ("missing interface name or sw_if_index");
18534 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
18536 mp->sw_if_index = ntohl (sw_if_index);
18537 mp->ip4_table_index = ntohl (ip4_table_index);
18538 mp->ip6_table_index = ntohl (ip6_table_index);
18539 mp->l2_table_index = ntohl (l2_table_index);
18540 mp->is_add = is_add;
18548 api_policer_classify_dump (vat_main_t * vam)
18550 unformat_input_t *i = vam->input;
18551 vl_api_policer_classify_dump_t *mp;
18552 vl_api_control_ping_t *mp_ping;
18553 u8 type = POLICER_CLASSIFY_N_TABLES;
18556 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
18560 errmsg ("classify table type must be specified");
18564 if (!vam->json_output)
18566 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
18569 M (POLICER_CLASSIFY_DUMP, mp);
18574 /* Use a control ping for synchronization */
18575 MPING (CONTROL_PING, mp_ping);
18578 /* Wait for a reply... */
18584 api_netmap_create (vat_main_t * vam)
18586 unformat_input_t *i = vam->input;
18587 vl_api_netmap_create_t *mp;
18590 u8 random_hw_addr = 1;
18595 clib_memset (hw_addr, 0, sizeof (hw_addr));
18597 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18599 if (unformat (i, "name %s", &if_name))
18600 vec_add1 (if_name, 0);
18601 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18602 random_hw_addr = 0;
18603 else if (unformat (i, "pipe"))
18605 else if (unformat (i, "master"))
18607 else if (unformat (i, "slave"))
18613 if (!vec_len (if_name))
18615 errmsg ("interface name must be specified");
18619 if (vec_len (if_name) > 64)
18621 errmsg ("interface name too long");
18625 M (NETMAP_CREATE, mp);
18627 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18628 clib_memcpy (mp->hw_addr, hw_addr, 6);
18629 mp->use_random_hw_addr = random_hw_addr;
18630 mp->is_pipe = is_pipe;
18631 mp->is_master = is_master;
18632 vec_free (if_name);
18640 api_netmap_delete (vat_main_t * vam)
18642 unformat_input_t *i = vam->input;
18643 vl_api_netmap_delete_t *mp;
18647 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18649 if (unformat (i, "name %s", &if_name))
18650 vec_add1 (if_name, 0);
18655 if (!vec_len (if_name))
18657 errmsg ("interface name must be specified");
18661 if (vec_len (if_name) > 64)
18663 errmsg ("interface name too long");
18667 M (NETMAP_DELETE, mp);
18669 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18670 vec_free (if_name);
18678 format_fib_api_path_nh_proto (u8 * s, va_list * args)
18680 vl_api_fib_path_nh_proto_t proto =
18681 va_arg (*args, vl_api_fib_path_nh_proto_t);
18685 case FIB_API_PATH_NH_PROTO_IP4:
18686 s = format (s, "ip4");
18688 case FIB_API_PATH_NH_PROTO_IP6:
18689 s = format (s, "ip6");
18691 case FIB_API_PATH_NH_PROTO_MPLS:
18692 s = format (s, "mpls");
18694 case FIB_API_PATH_NH_PROTO_BIER:
18695 s = format (s, "bier");
18697 case FIB_API_PATH_NH_PROTO_ETHERNET:
18698 s = format (s, "ethernet");
18706 format_vl_api_ip_address_union (u8 * s, va_list * args)
18708 vl_api_address_family_t af = va_arg (*args, vl_api_address_family_t);
18709 const vl_api_address_union_t *u = va_arg (*args, vl_api_address_union_t *);
18714 s = format (s, "%U", format_ip4_address, u->ip4);
18717 s = format (s, "%U", format_ip6_address, u->ip6);
18724 format_vl_api_fib_path_type (u8 * s, va_list * args)
18726 vl_api_fib_path_type_t t = va_arg (*args, vl_api_fib_path_type_t);
18730 case FIB_API_PATH_TYPE_NORMAL:
18731 s = format (s, "normal");
18733 case FIB_API_PATH_TYPE_LOCAL:
18734 s = format (s, "local");
18736 case FIB_API_PATH_TYPE_DROP:
18737 s = format (s, "drop");
18739 case FIB_API_PATH_TYPE_UDP_ENCAP:
18740 s = format (s, "udp-encap");
18742 case FIB_API_PATH_TYPE_BIER_IMP:
18743 s = format (s, "bier-imp");
18745 case FIB_API_PATH_TYPE_ICMP_UNREACH:
18746 s = format (s, "unreach");
18748 case FIB_API_PATH_TYPE_ICMP_PROHIBIT:
18749 s = format (s, "prohibit");
18751 case FIB_API_PATH_TYPE_SOURCE_LOOKUP:
18752 s = format (s, "src-lookup");
18754 case FIB_API_PATH_TYPE_DVR:
18755 s = format (s, "dvr");
18757 case FIB_API_PATH_TYPE_INTERFACE_RX:
18758 s = format (s, "interface-rx");
18760 case FIB_API_PATH_TYPE_CLASSIFY:
18761 s = format (s, "classify");
18769 vl_api_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
18772 " weight %d, sw_if_index %d, type %U, afi %U, next_hop %U",
18773 ntohl (fp->weight), ntohl (fp->sw_if_index),
18774 format_vl_api_fib_path_type, fp->type,
18775 format_fib_api_path_nh_proto, fp->proto,
18776 format_vl_api_ip_address_union, &fp->nh.address);
18780 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
18781 vl_api_fib_path_t * fp)
18783 struct in_addr ip4;
18784 struct in6_addr ip6;
18786 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
18787 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
18788 vat_json_object_add_uint (node, "type", fp->type);
18789 vat_json_object_add_uint (node, "next_hop_proto", fp->proto);
18790 if (fp->proto == FIB_API_PATH_NH_PROTO_IP4)
18792 clib_memcpy (&ip4, &fp->nh.address.ip4, sizeof (ip4));
18793 vat_json_object_add_ip4 (node, "next_hop", ip4);
18795 else if (fp->proto == FIB_API_PATH_NH_PROTO_IP4)
18797 clib_memcpy (&ip6, &fp->nh.address.ip6, sizeof (ip6));
18798 vat_json_object_add_ip6 (node, "next_hop", ip6);
18803 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
18805 vat_main_t *vam = &vat_main;
18806 int count = ntohl (mp->mt_tunnel.mt_n_paths);
18807 vl_api_fib_path_t *fp;
18810 print (vam->ofp, "sw_if_index %d via:",
18811 ntohl (mp->mt_tunnel.mt_sw_if_index));
18812 fp = mp->mt_tunnel.mt_paths;
18813 for (i = 0; i < count; i++)
18815 vl_api_fib_path_print (vam, fp);
18819 print (vam->ofp, "");
18822 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
18823 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
18826 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
18828 vat_main_t *vam = &vat_main;
18829 vat_json_node_t *node = NULL;
18830 int count = ntohl (mp->mt_tunnel.mt_n_paths);
18831 vl_api_fib_path_t *fp;
18834 if (VAT_JSON_ARRAY != vam->json_tree.type)
18836 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18837 vat_json_init_array (&vam->json_tree);
18839 node = vat_json_array_add (&vam->json_tree);
18841 vat_json_init_object (node);
18842 vat_json_object_add_uint (node, "sw_if_index",
18843 ntohl (mp->mt_tunnel.mt_sw_if_index));
18845 vat_json_object_add_uint (node, "l2_only", mp->mt_tunnel.mt_l2_only);
18847 fp = mp->mt_tunnel.mt_paths;
18848 for (i = 0; i < count; i++)
18850 vl_api_mpls_fib_path_json_print (node, fp);
18856 api_mpls_tunnel_dump (vat_main_t * vam)
18858 vl_api_mpls_tunnel_dump_t *mp;
18859 vl_api_control_ping_t *mp_ping;
18862 M (MPLS_TUNNEL_DUMP, mp);
18866 /* Use a control ping for synchronization */
18867 MPING (CONTROL_PING, mp_ping);
18874 #define vl_api_mpls_table_details_t_endian vl_noop_handler
18875 #define vl_api_mpls_table_details_t_print vl_noop_handler
18879 vl_api_mpls_table_details_t_handler (vl_api_mpls_table_details_t * mp)
18881 vat_main_t *vam = &vat_main;
18883 print (vam->ofp, "table-id %d,", ntohl (mp->mt_table.mt_table_id));
18886 static void vl_api_mpls_table_details_t_handler_json
18887 (vl_api_mpls_table_details_t * mp)
18889 vat_main_t *vam = &vat_main;
18890 vat_json_node_t *node = NULL;
18892 if (VAT_JSON_ARRAY != vam->json_tree.type)
18894 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18895 vat_json_init_array (&vam->json_tree);
18897 node = vat_json_array_add (&vam->json_tree);
18899 vat_json_init_object (node);
18900 vat_json_object_add_uint (node, "table", ntohl (mp->mt_table.mt_table_id));
18904 api_mpls_table_dump (vat_main_t * vam)
18906 vl_api_mpls_table_dump_t *mp;
18907 vl_api_control_ping_t *mp_ping;
18910 M (MPLS_TABLE_DUMP, mp);
18913 /* Use a control ping for synchronization */
18914 MPING (CONTROL_PING, mp_ping);
18921 #define vl_api_mpls_route_details_t_endian vl_noop_handler
18922 #define vl_api_mpls_route_details_t_print vl_noop_handler
18925 vl_api_mpls_route_details_t_handler (vl_api_mpls_route_details_t * mp)
18927 vat_main_t *vam = &vat_main;
18928 int count = (int) clib_net_to_host_u32 (mp->mr_route.mr_n_paths);
18929 vl_api_fib_path_t *fp;
18933 "table-id %d, label %u, ess_bit %u",
18934 ntohl (mp->mr_route.mr_table_id),
18935 ntohl (mp->mr_route.mr_label), mp->mr_route.mr_eos);
18936 fp = mp->mr_route.mr_paths;
18937 for (i = 0; i < count; i++)
18939 vl_api_fib_path_print (vam, fp);
18944 static void vl_api_mpls_route_details_t_handler_json
18945 (vl_api_mpls_route_details_t * mp)
18947 vat_main_t *vam = &vat_main;
18948 int count = (int) clib_host_to_net_u32 (mp->mr_route.mr_n_paths);
18949 vat_json_node_t *node = NULL;
18950 vl_api_fib_path_t *fp;
18953 if (VAT_JSON_ARRAY != vam->json_tree.type)
18955 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18956 vat_json_init_array (&vam->json_tree);
18958 node = vat_json_array_add (&vam->json_tree);
18960 vat_json_init_object (node);
18961 vat_json_object_add_uint (node, "table", ntohl (mp->mr_route.mr_table_id));
18962 vat_json_object_add_uint (node, "s_bit", mp->mr_route.mr_eos);
18963 vat_json_object_add_uint (node, "label", ntohl (mp->mr_route.mr_label));
18964 vat_json_object_add_uint (node, "path_count", count);
18965 fp = mp->mr_route.mr_paths;
18966 for (i = 0; i < count; i++)
18968 vl_api_mpls_fib_path_json_print (node, fp);
18974 api_mpls_route_dump (vat_main_t * vam)
18976 unformat_input_t *input = vam->input;
18977 vl_api_mpls_route_dump_t *mp;
18978 vl_api_control_ping_t *mp_ping;
18982 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18984 if (unformat (input, "table_id %d", &table_id))
18989 if (table_id == ~0)
18991 errmsg ("missing table id");
18995 M (MPLS_ROUTE_DUMP, mp);
18997 mp->table.mt_table_id = ntohl (table_id);
19000 /* Use a control ping for synchronization */
19001 MPING (CONTROL_PING, mp_ping);
19008 #define vl_api_ip_table_details_t_endian vl_noop_handler
19009 #define vl_api_ip_table_details_t_print vl_noop_handler
19012 vl_api_ip_table_details_t_handler (vl_api_ip_table_details_t * mp)
19014 vat_main_t *vam = &vat_main;
19017 "%s; table-id %d, prefix %U/%d",
19018 mp->table.name, ntohl (mp->table.table_id));
19022 static void vl_api_ip_table_details_t_handler_json
19023 (vl_api_ip_table_details_t * mp)
19025 vat_main_t *vam = &vat_main;
19026 vat_json_node_t *node = NULL;
19028 if (VAT_JSON_ARRAY != vam->json_tree.type)
19030 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19031 vat_json_init_array (&vam->json_tree);
19033 node = vat_json_array_add (&vam->json_tree);
19035 vat_json_init_object (node);
19036 vat_json_object_add_uint (node, "table", ntohl (mp->table.table_id));
19040 api_ip_table_dump (vat_main_t * vam)
19042 vl_api_ip_table_dump_t *mp;
19043 vl_api_control_ping_t *mp_ping;
19046 M (IP_TABLE_DUMP, mp);
19049 /* Use a control ping for synchronization */
19050 MPING (CONTROL_PING, mp_ping);
19058 api_ip_mtable_dump (vat_main_t * vam)
19060 vl_api_ip_mtable_dump_t *mp;
19061 vl_api_control_ping_t *mp_ping;
19064 M (IP_MTABLE_DUMP, mp);
19067 /* Use a control ping for synchronization */
19068 MPING (CONTROL_PING, mp_ping);
19076 api_ip_mroute_dump (vat_main_t * vam)
19078 unformat_input_t *input = vam->input;
19079 vl_api_control_ping_t *mp_ping;
19080 vl_api_ip_mroute_dump_t *mp;
19085 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19087 if (unformat (input, "table_id %d", &table_id))
19089 else if (unformat (input, "ip6"))
19091 else if (unformat (input, "ip4"))
19096 if (table_id == ~0)
19098 errmsg ("missing table id");
19102 M (IP_MROUTE_DUMP, mp);
19103 mp->table.table_id = table_id;
19104 mp->table.is_ip6 = is_ip6;
19107 /* Use a control ping for synchronization */
19108 MPING (CONTROL_PING, mp_ping);
19115 static void vl_api_ip_neighbor_details_t_handler
19116 (vl_api_ip_neighbor_details_t * mp)
19118 vat_main_t *vam = &vat_main;
19120 print (vam->ofp, "%c %U %U",
19121 (ntohl (mp->neighbor.flags) & IP_NEIGHBOR_FLAG_STATIC) ? 'S' : 'D',
19122 format_vl_api_mac_address, &mp->neighbor.mac_address,
19123 format_vl_api_address, &mp->neighbor.ip_address);
19126 static void vl_api_ip_neighbor_details_t_handler_json
19127 (vl_api_ip_neighbor_details_t * mp)
19130 vat_main_t *vam = &vat_main;
19131 vat_json_node_t *node;
19133 if (VAT_JSON_ARRAY != vam->json_tree.type)
19135 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19136 vat_json_init_array (&vam->json_tree);
19138 node = vat_json_array_add (&vam->json_tree);
19140 vat_json_init_object (node);
19141 vat_json_object_add_string_copy
19143 ((ntohl (mp->neighbor.flags) & IP_NEIGHBOR_FLAG_STATIC) ?
19144 (u8 *) "static" : (u8 *) "dynamic"));
19146 vat_json_object_add_string_copy (node, "link_layer",
19147 format (0, "%U", format_vl_api_mac_address,
19148 &mp->neighbor.mac_address));
19149 vat_json_object_add_address (node, "ip", &mp->neighbor.ip_address);
19153 api_ip_neighbor_dump (vat_main_t * vam)
19155 unformat_input_t *i = vam->input;
19156 vl_api_ip_neighbor_dump_t *mp;
19157 vl_api_control_ping_t *mp_ping;
19159 u32 sw_if_index = ~0;
19162 /* Parse args required to build the message */
19163 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19165 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19167 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19169 else if (unformat (i, "ip6"))
19175 if (sw_if_index == ~0)
19177 errmsg ("missing interface name or sw_if_index");
19181 M (IP_NEIGHBOR_DUMP, mp);
19182 mp->is_ipv6 = (u8) is_ipv6;
19183 mp->sw_if_index = ntohl (sw_if_index);
19186 /* Use a control ping for synchronization */
19187 MPING (CONTROL_PING, mp_ping);
19194 #define vl_api_ip_route_details_t_endian vl_noop_handler
19195 #define vl_api_ip_route_details_t_print vl_noop_handler
19198 vl_api_ip_route_details_t_handler (vl_api_ip_route_details_t * mp)
19200 vat_main_t *vam = &vat_main;
19201 u8 count = mp->route.n_paths;
19202 vl_api_fib_path_t *fp;
19206 "table-id %d, prefix %U/%d",
19207 ntohl (mp->route.table_id),
19208 format_ip46_address, mp->route.prefix.address, mp->route.prefix.len);
19209 for (i = 0; i < count; i++)
19211 fp = &mp->route.paths[i];
19213 vl_api_fib_path_print (vam, fp);
19218 static void vl_api_ip_route_details_t_handler_json
19219 (vl_api_ip_route_details_t * mp)
19221 vat_main_t *vam = &vat_main;
19222 u8 count = mp->route.n_paths;
19223 vat_json_node_t *node = NULL;
19224 struct in_addr ip4;
19225 struct in6_addr ip6;
19226 vl_api_fib_path_t *fp;
19229 if (VAT_JSON_ARRAY != vam->json_tree.type)
19231 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19232 vat_json_init_array (&vam->json_tree);
19234 node = vat_json_array_add (&vam->json_tree);
19236 vat_json_init_object (node);
19237 vat_json_object_add_uint (node, "table", ntohl (mp->route.table_id));
19238 if (ADDRESS_IP6 == mp->route.prefix.address.af)
19240 clib_memcpy (&ip6, &mp->route.prefix.address.un.ip6, sizeof (ip6));
19241 vat_json_object_add_ip6 (node, "prefix", ip6);
19245 clib_memcpy (&ip4, &mp->route.prefix.address.un.ip4, sizeof (ip4));
19246 vat_json_object_add_ip4 (node, "prefix", ip4);
19248 vat_json_object_add_uint (node, "mask_length", mp->route.prefix.len);
19249 vat_json_object_add_uint (node, "path_count", count);
19250 for (i = 0; i < count; i++)
19252 fp = &mp->route.paths[i];
19253 vl_api_mpls_fib_path_json_print (node, fp);
19258 api_ip_route_dump (vat_main_t * vam)
19260 unformat_input_t *input = vam->input;
19261 vl_api_ip_route_dump_t *mp;
19262 vl_api_control_ping_t *mp_ping;
19268 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19270 if (unformat (input, "table_id %d", &table_id))
19272 else if (unformat (input, "ip6"))
19274 else if (unformat (input, "ip4"))
19279 if (table_id == ~0)
19281 errmsg ("missing table id");
19285 M (IP_ROUTE_DUMP, mp);
19287 mp->table.table_id = table_id;
19288 mp->table.is_ip6 = is_ip6;
19292 /* Use a control ping for synchronization */
19293 MPING (CONTROL_PING, mp_ping);
19301 api_classify_table_ids (vat_main_t * vam)
19303 vl_api_classify_table_ids_t *mp;
19306 /* Construct the API message */
19307 M (CLASSIFY_TABLE_IDS, mp);
19316 api_classify_table_by_interface (vat_main_t * vam)
19318 unformat_input_t *input = vam->input;
19319 vl_api_classify_table_by_interface_t *mp;
19321 u32 sw_if_index = ~0;
19323 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19325 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19327 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19332 if (sw_if_index == ~0)
19334 errmsg ("missing interface name or sw_if_index");
19338 /* Construct the API message */
19339 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
19341 mp->sw_if_index = ntohl (sw_if_index);
19349 api_classify_table_info (vat_main_t * vam)
19351 unformat_input_t *input = vam->input;
19352 vl_api_classify_table_info_t *mp;
19356 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19358 if (unformat (input, "table_id %d", &table_id))
19363 if (table_id == ~0)
19365 errmsg ("missing table id");
19369 /* Construct the API message */
19370 M (CLASSIFY_TABLE_INFO, mp);
19372 mp->table_id = ntohl (table_id);
19380 api_classify_session_dump (vat_main_t * vam)
19382 unformat_input_t *input = vam->input;
19383 vl_api_classify_session_dump_t *mp;
19384 vl_api_control_ping_t *mp_ping;
19388 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19390 if (unformat (input, "table_id %d", &table_id))
19395 if (table_id == ~0)
19397 errmsg ("missing table id");
19401 /* Construct the API message */
19402 M (CLASSIFY_SESSION_DUMP, mp);
19404 mp->table_id = ntohl (table_id);
19407 /* Use a control ping for synchronization */
19408 MPING (CONTROL_PING, mp_ping);
19416 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
19418 vat_main_t *vam = &vat_main;
19420 print (vam->ofp, "collector_address %U, collector_port %d, "
19421 "src_address %U, vrf_id %d, path_mtu %u, "
19422 "template_interval %u, udp_checksum %d",
19423 format_ip4_address, mp->collector_address,
19424 ntohs (mp->collector_port),
19425 format_ip4_address, mp->src_address,
19426 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
19427 ntohl (mp->template_interval), mp->udp_checksum);
19430 vam->result_ready = 1;
19434 vl_api_ipfix_exporter_details_t_handler_json
19435 (vl_api_ipfix_exporter_details_t * mp)
19437 vat_main_t *vam = &vat_main;
19438 vat_json_node_t node;
19439 struct in_addr collector_address;
19440 struct in_addr src_address;
19442 vat_json_init_object (&node);
19443 clib_memcpy (&collector_address, &mp->collector_address,
19444 sizeof (collector_address));
19445 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
19446 vat_json_object_add_uint (&node, "collector_port",
19447 ntohs (mp->collector_port));
19448 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
19449 vat_json_object_add_ip4 (&node, "src_address", src_address);
19450 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
19451 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
19452 vat_json_object_add_uint (&node, "template_interval",
19453 ntohl (mp->template_interval));
19454 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
19456 vat_json_print (vam->ofp, &node);
19457 vat_json_free (&node);
19459 vam->result_ready = 1;
19463 api_ipfix_exporter_dump (vat_main_t * vam)
19465 vl_api_ipfix_exporter_dump_t *mp;
19468 /* Construct the API message */
19469 M (IPFIX_EXPORTER_DUMP, mp);
19478 api_ipfix_classify_stream_dump (vat_main_t * vam)
19480 vl_api_ipfix_classify_stream_dump_t *mp;
19483 /* Construct the API message */
19484 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
19495 vl_api_ipfix_classify_stream_details_t_handler
19496 (vl_api_ipfix_classify_stream_details_t * mp)
19498 vat_main_t *vam = &vat_main;
19499 print (vam->ofp, "domain_id %d, src_port %d",
19500 ntohl (mp->domain_id), ntohs (mp->src_port));
19502 vam->result_ready = 1;
19506 vl_api_ipfix_classify_stream_details_t_handler_json
19507 (vl_api_ipfix_classify_stream_details_t * mp)
19509 vat_main_t *vam = &vat_main;
19510 vat_json_node_t node;
19512 vat_json_init_object (&node);
19513 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
19514 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
19516 vat_json_print (vam->ofp, &node);
19517 vat_json_free (&node);
19519 vam->result_ready = 1;
19523 api_ipfix_classify_table_dump (vat_main_t * vam)
19525 vl_api_ipfix_classify_table_dump_t *mp;
19526 vl_api_control_ping_t *mp_ping;
19529 if (!vam->json_output)
19531 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
19532 "transport_protocol");
19535 /* Construct the API message */
19536 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
19541 /* Use a control ping for synchronization */
19542 MPING (CONTROL_PING, mp_ping);
19550 vl_api_ipfix_classify_table_details_t_handler
19551 (vl_api_ipfix_classify_table_details_t * mp)
19553 vat_main_t *vam = &vat_main;
19554 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
19555 mp->transport_protocol);
19559 vl_api_ipfix_classify_table_details_t_handler_json
19560 (vl_api_ipfix_classify_table_details_t * mp)
19562 vat_json_node_t *node = NULL;
19563 vat_main_t *vam = &vat_main;
19565 if (VAT_JSON_ARRAY != vam->json_tree.type)
19567 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19568 vat_json_init_array (&vam->json_tree);
19571 node = vat_json_array_add (&vam->json_tree);
19572 vat_json_init_object (node);
19574 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
19575 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
19576 vat_json_object_add_uint (node, "transport_protocol",
19577 mp->transport_protocol);
19581 api_sw_interface_span_enable_disable (vat_main_t * vam)
19583 unformat_input_t *i = vam->input;
19584 vl_api_sw_interface_span_enable_disable_t *mp;
19585 u32 src_sw_if_index = ~0;
19586 u32 dst_sw_if_index = ~0;
19591 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19594 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
19596 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
19600 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
19602 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
19604 else if (unformat (i, "disable"))
19606 else if (unformat (i, "rx"))
19608 else if (unformat (i, "tx"))
19610 else if (unformat (i, "both"))
19612 else if (unformat (i, "l2"))
19618 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
19620 mp->sw_if_index_from = htonl (src_sw_if_index);
19621 mp->sw_if_index_to = htonl (dst_sw_if_index);
19631 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
19634 vat_main_t *vam = &vat_main;
19635 u8 *sw_if_from_name = 0;
19636 u8 *sw_if_to_name = 0;
19637 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19638 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19639 char *states[] = { "none", "rx", "tx", "both" };
19643 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19645 if ((u32) p->value[0] == sw_if_index_from)
19647 sw_if_from_name = (u8 *)(p->key);
19651 if ((u32) p->value[0] == sw_if_index_to)
19653 sw_if_to_name = (u8 *)(p->key);
19654 if (sw_if_from_name)
19659 print (vam->ofp, "%20s => %20s (%s) %s",
19660 sw_if_from_name, sw_if_to_name, states[mp->state],
19661 mp->is_l2 ? "l2" : "device");
19665 vl_api_sw_interface_span_details_t_handler_json
19666 (vl_api_sw_interface_span_details_t * mp)
19668 vat_main_t *vam = &vat_main;
19669 vat_json_node_t *node = NULL;
19670 u8 *sw_if_from_name = 0;
19671 u8 *sw_if_to_name = 0;
19672 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19673 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19677 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19679 if ((u32) p->value[0] == sw_if_index_from)
19681 sw_if_from_name = (u8 *)(p->key);
19685 if ((u32) p->value[0] == sw_if_index_to)
19687 sw_if_to_name = (u8 *)(p->key);
19688 if (sw_if_from_name)
19694 if (VAT_JSON_ARRAY != vam->json_tree.type)
19696 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19697 vat_json_init_array (&vam->json_tree);
19699 node = vat_json_array_add (&vam->json_tree);
19701 vat_json_init_object (node);
19702 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
19703 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
19704 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
19705 if (0 != sw_if_to_name)
19707 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
19709 vat_json_object_add_uint (node, "state", mp->state);
19710 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
19714 api_sw_interface_span_dump (vat_main_t * vam)
19716 unformat_input_t *input = vam->input;
19717 vl_api_sw_interface_span_dump_t *mp;
19718 vl_api_control_ping_t *mp_ping;
19722 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19724 if (unformat (input, "l2"))
19730 M (SW_INTERFACE_SPAN_DUMP, mp);
19734 /* Use a control ping for synchronization */
19735 MPING (CONTROL_PING, mp_ping);
19743 api_pg_create_interface (vat_main_t * vam)
19745 unformat_input_t *input = vam->input;
19746 vl_api_pg_create_interface_t *mp;
19750 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19752 if (unformat (input, "if_id %d", &if_id))
19759 errmsg ("missing pg interface index");
19763 /* Construct the API message */
19764 M (PG_CREATE_INTERFACE, mp);
19766 mp->interface_id = ntohl (if_id);
19774 api_pg_capture (vat_main_t * vam)
19776 unformat_input_t *input = vam->input;
19777 vl_api_pg_capture_t *mp;
19782 u8 pcap_file_set = 0;
19785 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19787 if (unformat (input, "if_id %d", &if_id))
19789 else if (unformat (input, "pcap %s", &pcap_file))
19791 else if (unformat (input, "count %d", &count))
19793 else if (unformat (input, "disable"))
19800 errmsg ("missing pg interface index");
19803 if (pcap_file_set > 0)
19805 if (vec_len (pcap_file) > 255)
19807 errmsg ("pcap file name is too long");
19812 u32 name_len = vec_len (pcap_file);
19813 /* Construct the API message */
19814 M (PG_CAPTURE, mp);
19816 mp->interface_id = ntohl (if_id);
19817 mp->is_enabled = enable;
19818 mp->count = ntohl (count);
19819 mp->pcap_name_length = ntohl (name_len);
19820 if (pcap_file_set != 0)
19822 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
19824 vec_free (pcap_file);
19832 api_pg_enable_disable (vat_main_t * vam)
19834 unformat_input_t *input = vam->input;
19835 vl_api_pg_enable_disable_t *mp;
19838 u8 stream_name_set = 0;
19839 u8 *stream_name = 0;
19841 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19843 if (unformat (input, "stream %s", &stream_name))
19844 stream_name_set = 1;
19845 else if (unformat (input, "disable"))
19851 if (stream_name_set > 0)
19853 if (vec_len (stream_name) > 255)
19855 errmsg ("stream name too long");
19860 u32 name_len = vec_len (stream_name);
19861 /* Construct the API message */
19862 M (PG_ENABLE_DISABLE, mp);
19864 mp->is_enabled = enable;
19865 if (stream_name_set != 0)
19867 mp->stream_name_length = ntohl (name_len);
19868 clib_memcpy (mp->stream_name, stream_name, name_len);
19870 vec_free (stream_name);
19878 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
19880 unformat_input_t *input = vam->input;
19881 vl_api_ip_source_and_port_range_check_add_del_t *mp;
19883 u16 *low_ports = 0;
19884 u16 *high_ports = 0;
19887 vl_api_prefix_t prefix;
19894 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19896 if (unformat (input, "%U", unformat_vl_api_prefix, &prefix))
19898 else if (unformat (input, "vrf %d", &vrf_id))
19900 else if (unformat (input, "del"))
19902 else if (unformat (input, "port %d", &tmp))
19904 if (tmp == 0 || tmp > 65535)
19906 errmsg ("port %d out of range", tmp);
19910 this_hi = this_low + 1;
19911 vec_add1 (low_ports, this_low);
19912 vec_add1 (high_ports, this_hi);
19914 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
19916 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
19918 errmsg ("incorrect range parameters");
19922 /* Note: in debug CLI +1 is added to high before
19923 passing to real fn that does "the work"
19924 (ip_source_and_port_range_check_add_del).
19925 This fn is a wrapper around the binary API fn a
19926 control plane will call, which expects this increment
19927 to have occurred. Hence letting the binary API control
19928 plane fn do the increment for consistency between VAT
19929 and other control planes.
19932 vec_add1 (low_ports, this_low);
19933 vec_add1 (high_ports, this_hi);
19939 if (prefix_set == 0)
19941 errmsg ("<address>/<mask> not specified");
19947 errmsg ("VRF ID required, not specified");
19954 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
19958 if (vec_len (low_ports) == 0)
19960 errmsg ("At least one port or port range required");
19964 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
19966 mp->is_add = is_add;
19968 clib_memcpy (&mp->prefix, &prefix, sizeof (prefix));
19970 mp->number_of_ranges = vec_len (low_ports);
19972 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
19973 vec_free (low_ports);
19975 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
19976 vec_free (high_ports);
19978 mp->vrf_id = ntohl (vrf_id);
19986 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
19988 unformat_input_t *input = vam->input;
19989 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
19990 u32 sw_if_index = ~0;
19992 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
19993 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
19997 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19999 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20001 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20003 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
20005 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
20007 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
20009 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
20011 else if (unformat (input, "del"))
20017 if (sw_if_index == ~0)
20019 errmsg ("Interface required but not specified");
20025 errmsg ("VRF ID required but not specified");
20029 if (tcp_out_vrf_id == 0
20030 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
20033 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
20037 /* Construct the API message */
20038 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
20040 mp->sw_if_index = ntohl (sw_if_index);
20041 mp->is_add = is_add;
20042 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
20043 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
20044 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
20045 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
20050 /* Wait for a reply... */
20056 api_set_punt (vat_main_t * vam)
20058 unformat_input_t *i = vam->input;
20059 vl_api_address_family_t af;
20060 vl_api_set_punt_t *mp;
20066 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20068 if (unformat (i, "%U", unformat_vl_api_address_family, &af))
20070 else if (unformat (i, "protocol %d", &protocol))
20072 else if (unformat (i, "port %d", &port))
20074 else if (unformat (i, "del"))
20078 clib_warning ("parse error '%U'", format_unformat_error, i);
20085 mp->is_add = (u8) is_add;
20086 mp->punt.type = PUNT_API_TYPE_L4;
20087 mp->punt.punt.l4.af = af;
20088 mp->punt.punt.l4.protocol = (u8) protocol;
20089 mp->punt.punt.l4.port = htons ((u16) port);
20097 api_delete_subif (vat_main_t * vam)
20099 unformat_input_t *i = vam->input;
20100 vl_api_delete_subif_t *mp;
20101 u32 sw_if_index = ~0;
20104 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20106 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20108 if (unformat (i, "sw_if_index %d", &sw_if_index))
20114 if (sw_if_index == ~0)
20116 errmsg ("missing sw_if_index");
20120 /* Construct the API message */
20121 M (DELETE_SUBIF, mp);
20122 mp->sw_if_index = ntohl (sw_if_index);
20129 #define foreach_pbb_vtr_op \
20130 _("disable", L2_VTR_DISABLED) \
20131 _("pop", L2_VTR_POP_2) \
20132 _("push", L2_VTR_PUSH_2)
20135 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
20137 unformat_input_t *i = vam->input;
20138 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
20139 u32 sw_if_index = ~0, vtr_op = ~0;
20140 u16 outer_tag = ~0;
20141 u8 dmac[6], smac[6];
20142 u8 dmac_set = 0, smac_set = 0;
20148 /* Shut up coverity */
20149 clib_memset (dmac, 0, sizeof (dmac));
20150 clib_memset (smac, 0, sizeof (smac));
20152 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20154 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20156 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20158 else if (unformat (i, "vtr_op %d", &vtr_op))
20160 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
20163 else if (unformat (i, "translate_pbb_stag"))
20165 if (unformat (i, "%d", &tmp))
20167 vtr_op = L2_VTR_TRANSLATE_2_1;
20173 ("translate_pbb_stag operation requires outer tag definition");
20177 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
20179 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
20181 else if (unformat (i, "sid %d", &sid))
20183 else if (unformat (i, "vlanid %d", &tmp))
20187 clib_warning ("parse error '%U'", format_unformat_error, i);
20192 if ((sw_if_index == ~0) || (vtr_op == ~0))
20194 errmsg ("missing sw_if_index or vtr operation");
20197 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
20198 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
20201 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
20205 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
20206 mp->sw_if_index = ntohl (sw_if_index);
20207 mp->vtr_op = ntohl (vtr_op);
20208 mp->outer_tag = ntohs (outer_tag);
20209 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
20210 clib_memcpy (mp->b_smac, smac, sizeof (smac));
20211 mp->b_vlanid = ntohs (vlanid);
20212 mp->i_sid = ntohl (sid);
20220 api_flow_classify_set_interface (vat_main_t * vam)
20222 unformat_input_t *i = vam->input;
20223 vl_api_flow_classify_set_interface_t *mp;
20225 int sw_if_index_set;
20226 u32 ip4_table_index = ~0;
20227 u32 ip6_table_index = ~0;
20231 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20233 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20234 sw_if_index_set = 1;
20235 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20236 sw_if_index_set = 1;
20237 else if (unformat (i, "del"))
20239 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20241 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20245 clib_warning ("parse error '%U'", format_unformat_error, i);
20250 if (sw_if_index_set == 0)
20252 errmsg ("missing interface name or sw_if_index");
20256 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
20258 mp->sw_if_index = ntohl (sw_if_index);
20259 mp->ip4_table_index = ntohl (ip4_table_index);
20260 mp->ip6_table_index = ntohl (ip6_table_index);
20261 mp->is_add = is_add;
20269 api_flow_classify_dump (vat_main_t * vam)
20271 unformat_input_t *i = vam->input;
20272 vl_api_flow_classify_dump_t *mp;
20273 vl_api_control_ping_t *mp_ping;
20274 u8 type = FLOW_CLASSIFY_N_TABLES;
20277 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
20281 errmsg ("classify table type must be specified");
20285 if (!vam->json_output)
20287 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20290 M (FLOW_CLASSIFY_DUMP, mp);
20295 /* Use a control ping for synchronization */
20296 MPING (CONTROL_PING, mp_ping);
20299 /* Wait for a reply... */
20305 api_feature_enable_disable (vat_main_t * vam)
20307 unformat_input_t *i = vam->input;
20308 vl_api_feature_enable_disable_t *mp;
20310 u8 *feature_name = 0;
20311 u32 sw_if_index = ~0;
20315 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20317 if (unformat (i, "arc_name %s", &arc_name))
20319 else if (unformat (i, "feature_name %s", &feature_name))
20322 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20324 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20326 else if (unformat (i, "disable"))
20334 errmsg ("missing arc name");
20337 if (vec_len (arc_name) > 63)
20339 errmsg ("arc name too long");
20342 if (feature_name == 0)
20344 errmsg ("missing feature name");
20347 if (vec_len (feature_name) > 63)
20349 errmsg ("feature name too long");
20352 if (sw_if_index == ~0)
20354 errmsg ("missing interface name or sw_if_index");
20358 /* Construct the API message */
20359 M (FEATURE_ENABLE_DISABLE, mp);
20360 mp->sw_if_index = ntohl (sw_if_index);
20361 mp->enable = enable;
20362 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
20363 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
20364 vec_free (arc_name);
20365 vec_free (feature_name);
20373 api_sw_interface_tag_add_del (vat_main_t * vam)
20375 unformat_input_t *i = vam->input;
20376 vl_api_sw_interface_tag_add_del_t *mp;
20377 u32 sw_if_index = ~0;
20382 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20384 if (unformat (i, "tag %s", &tag))
20386 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20388 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20390 else if (unformat (i, "del"))
20396 if (sw_if_index == ~0)
20398 errmsg ("missing interface name or sw_if_index");
20402 if (enable && (tag == 0))
20404 errmsg ("no tag specified");
20408 /* Construct the API message */
20409 M (SW_INTERFACE_TAG_ADD_DEL, mp);
20410 mp->sw_if_index = ntohl (sw_if_index);
20411 mp->is_add = enable;
20413 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
20421 static void vl_api_l2_xconnect_details_t_handler
20422 (vl_api_l2_xconnect_details_t * mp)
20424 vat_main_t *vam = &vat_main;
20426 print (vam->ofp, "%15d%15d",
20427 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
20430 static void vl_api_l2_xconnect_details_t_handler_json
20431 (vl_api_l2_xconnect_details_t * mp)
20433 vat_main_t *vam = &vat_main;
20434 vat_json_node_t *node = NULL;
20436 if (VAT_JSON_ARRAY != vam->json_tree.type)
20438 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20439 vat_json_init_array (&vam->json_tree);
20441 node = vat_json_array_add (&vam->json_tree);
20443 vat_json_init_object (node);
20444 vat_json_object_add_uint (node, "rx_sw_if_index",
20445 ntohl (mp->rx_sw_if_index));
20446 vat_json_object_add_uint (node, "tx_sw_if_index",
20447 ntohl (mp->tx_sw_if_index));
20451 api_l2_xconnect_dump (vat_main_t * vam)
20453 vl_api_l2_xconnect_dump_t *mp;
20454 vl_api_control_ping_t *mp_ping;
20457 if (!vam->json_output)
20459 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
20462 M (L2_XCONNECT_DUMP, mp);
20466 /* Use a control ping for synchronization */
20467 MPING (CONTROL_PING, mp_ping);
20475 api_hw_interface_set_mtu (vat_main_t * vam)
20477 unformat_input_t *i = vam->input;
20478 vl_api_hw_interface_set_mtu_t *mp;
20479 u32 sw_if_index = ~0;
20483 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20485 if (unformat (i, "mtu %d", &mtu))
20487 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20489 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20495 if (sw_if_index == ~0)
20497 errmsg ("missing interface name or sw_if_index");
20503 errmsg ("no mtu specified");
20507 /* Construct the API message */
20508 M (HW_INTERFACE_SET_MTU, mp);
20509 mp->sw_if_index = ntohl (sw_if_index);
20510 mp->mtu = ntohs ((u16) mtu);
20518 api_p2p_ethernet_add (vat_main_t * vam)
20520 unformat_input_t *i = vam->input;
20521 vl_api_p2p_ethernet_add_t *mp;
20522 u32 parent_if_index = ~0;
20528 clib_memset (remote_mac, 0, sizeof (remote_mac));
20529 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20531 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20533 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20537 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20539 else if (unformat (i, "sub_id %d", &sub_id))
20543 clib_warning ("parse error '%U'", format_unformat_error, i);
20548 if (parent_if_index == ~0)
20550 errmsg ("missing interface name or sw_if_index");
20555 errmsg ("missing remote mac address");
20560 errmsg ("missing sub-interface id");
20564 M (P2P_ETHERNET_ADD, mp);
20565 mp->parent_if_index = ntohl (parent_if_index);
20566 mp->subif_id = ntohl (sub_id);
20567 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20575 api_p2p_ethernet_del (vat_main_t * vam)
20577 unformat_input_t *i = vam->input;
20578 vl_api_p2p_ethernet_del_t *mp;
20579 u32 parent_if_index = ~0;
20584 clib_memset (remote_mac, 0, sizeof (remote_mac));
20585 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20587 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20589 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20593 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20597 clib_warning ("parse error '%U'", format_unformat_error, i);
20602 if (parent_if_index == ~0)
20604 errmsg ("missing interface name or sw_if_index");
20609 errmsg ("missing remote mac address");
20613 M (P2P_ETHERNET_DEL, mp);
20614 mp->parent_if_index = ntohl (parent_if_index);
20615 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20623 api_lldp_config (vat_main_t * vam)
20625 unformat_input_t *i = vam->input;
20626 vl_api_lldp_config_t *mp;
20628 int tx_interval = 0;
20629 u8 *sys_name = NULL;
20632 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20634 if (unformat (i, "system-name %s", &sys_name))
20636 else if (unformat (i, "tx-hold %d", &tx_hold))
20638 else if (unformat (i, "tx-interval %d", &tx_interval))
20642 clib_warning ("parse error '%U'", format_unformat_error, i);
20647 vec_add1 (sys_name, 0);
20649 M (LLDP_CONFIG, mp);
20650 mp->tx_hold = htonl (tx_hold);
20651 mp->tx_interval = htonl (tx_interval);
20652 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
20653 vec_free (sys_name);
20661 api_sw_interface_set_lldp (vat_main_t * vam)
20663 unformat_input_t *i = vam->input;
20664 vl_api_sw_interface_set_lldp_t *mp;
20665 u32 sw_if_index = ~0;
20667 u8 *port_desc = NULL, *mgmt_oid = NULL;
20668 ip4_address_t ip4_addr;
20669 ip6_address_t ip6_addr;
20672 clib_memset (&ip4_addr, 0, sizeof (ip4_addr));
20673 clib_memset (&ip6_addr, 0, sizeof (ip6_addr));
20675 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20677 if (unformat (i, "disable"))
20680 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20682 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20684 else if (unformat (i, "port-desc %s", &port_desc))
20686 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
20688 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
20690 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
20696 if (sw_if_index == ~0)
20698 errmsg ("missing interface name or sw_if_index");
20702 /* Construct the API message */
20703 vec_add1 (port_desc, 0);
20704 vec_add1 (mgmt_oid, 0);
20705 M (SW_INTERFACE_SET_LLDP, mp);
20706 mp->sw_if_index = ntohl (sw_if_index);
20707 mp->enable = enable;
20708 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
20709 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
20710 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
20711 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
20712 vec_free (port_desc);
20713 vec_free (mgmt_oid);
20721 api_tcp_configure_src_addresses (vat_main_t * vam)
20723 vl_api_tcp_configure_src_addresses_t *mp;
20724 unformat_input_t *i = vam->input;
20725 ip4_address_t v4first, v4last;
20726 ip6_address_t v6first, v6last;
20731 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20733 if (unformat (i, "%U - %U",
20734 unformat_ip4_address, &v4first,
20735 unformat_ip4_address, &v4last))
20739 errmsg ("one range per message (range already set)");
20744 else if (unformat (i, "%U - %U",
20745 unformat_ip6_address, &v6first,
20746 unformat_ip6_address, &v6last))
20750 errmsg ("one range per message (range already set)");
20755 else if (unformat (i, "vrf %d", &vrf_id))
20761 if (range_set == 0)
20763 errmsg ("address range not set");
20767 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
20768 mp->vrf_id = ntohl (vrf_id);
20770 if (range_set == 2)
20773 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
20774 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
20779 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
20780 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
20787 static void vl_api_app_namespace_add_del_reply_t_handler
20788 (vl_api_app_namespace_add_del_reply_t * mp)
20790 vat_main_t *vam = &vat_main;
20791 i32 retval = ntohl (mp->retval);
20792 if (vam->async_mode)
20794 vam->async_errors += (retval < 0);
20798 vam->retval = retval;
20800 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
20801 vam->result_ready = 1;
20805 static void vl_api_app_namespace_add_del_reply_t_handler_json
20806 (vl_api_app_namespace_add_del_reply_t * mp)
20808 vat_main_t *vam = &vat_main;
20809 vat_json_node_t node;
20811 vat_json_init_object (&node);
20812 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
20813 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
20815 vat_json_print (vam->ofp, &node);
20816 vat_json_free (&node);
20818 vam->retval = ntohl (mp->retval);
20819 vam->result_ready = 1;
20823 api_app_namespace_add_del (vat_main_t * vam)
20825 vl_api_app_namespace_add_del_t *mp;
20826 unformat_input_t *i = vam->input;
20827 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
20828 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
20832 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20834 if (unformat (i, "id %_%v%_", &ns_id))
20836 else if (unformat (i, "secret %lu", &secret))
20838 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20839 sw_if_index_set = 1;
20840 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
20842 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
20847 if (!ns_id || !secret_set || !sw_if_index_set)
20849 errmsg ("namespace id, secret and sw_if_index must be set");
20852 if (vec_len (ns_id) > 64)
20854 errmsg ("namespace id too long");
20857 M (APP_NAMESPACE_ADD_DEL, mp);
20859 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
20860 mp->namespace_id_len = vec_len (ns_id);
20861 mp->secret = clib_host_to_net_u64 (secret);
20862 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
20863 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
20864 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
20872 api_sock_init_shm (vat_main_t * vam)
20874 #if VPP_API_TEST_BUILTIN == 0
20875 unformat_input_t *i = vam->input;
20876 vl_api_shm_elem_config_t *config = 0;
20877 u64 size = 64 << 20;
20880 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20882 if (unformat (i, "size %U", unformat_memory_size, &size))
20889 * Canned custom ring allocator config.
20890 * Should probably parse all of this
20892 vec_validate (config, 6);
20893 config[0].type = VL_API_VLIB_RING;
20894 config[0].size = 256;
20895 config[0].count = 32;
20897 config[1].type = VL_API_VLIB_RING;
20898 config[1].size = 1024;
20899 config[1].count = 16;
20901 config[2].type = VL_API_VLIB_RING;
20902 config[2].size = 4096;
20903 config[2].count = 2;
20905 config[3].type = VL_API_CLIENT_RING;
20906 config[3].size = 256;
20907 config[3].count = 32;
20909 config[4].type = VL_API_CLIENT_RING;
20910 config[4].size = 1024;
20911 config[4].count = 16;
20913 config[5].type = VL_API_CLIENT_RING;
20914 config[5].size = 4096;
20915 config[5].count = 2;
20917 config[6].type = VL_API_QUEUE;
20918 config[6].count = 128;
20919 config[6].size = sizeof (uword);
20921 rv = vl_socket_client_init_shm (config, 1 /* want_pthread */ );
20923 vam->client_index_invalid = 1;
20931 api_dns_enable_disable (vat_main_t * vam)
20933 unformat_input_t *line_input = vam->input;
20934 vl_api_dns_enable_disable_t *mp;
20935 u8 enable_disable = 1;
20938 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
20940 if (unformat (line_input, "disable"))
20941 enable_disable = 0;
20942 if (unformat (line_input, "enable"))
20943 enable_disable = 1;
20948 /* Construct the API message */
20949 M (DNS_ENABLE_DISABLE, mp);
20950 mp->enable = enable_disable;
20954 /* Wait for the reply */
20960 api_dns_resolve_name (vat_main_t * vam)
20962 unformat_input_t *line_input = vam->input;
20963 vl_api_dns_resolve_name_t *mp;
20967 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
20969 if (unformat (line_input, "%s", &name))
20975 if (vec_len (name) > 127)
20977 errmsg ("name too long");
20981 /* Construct the API message */
20982 M (DNS_RESOLVE_NAME, mp);
20983 memcpy (mp->name, name, vec_len (name));
20988 /* Wait for the reply */
20994 api_dns_resolve_ip (vat_main_t * vam)
20996 unformat_input_t *line_input = vam->input;
20997 vl_api_dns_resolve_ip_t *mp;
20999 ip4_address_t addr4;
21000 ip6_address_t addr6;
21003 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21005 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
21007 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
21015 errmsg ("missing address");
21019 /* Construct the API message */
21020 M (DNS_RESOLVE_IP, mp);
21021 mp->is_ip6 = is_ip6;
21023 memcpy (mp->address, &addr6, sizeof (addr6));
21025 memcpy (mp->address, &addr4, sizeof (addr4));
21029 /* Wait for the reply */
21035 api_dns_name_server_add_del (vat_main_t * vam)
21037 unformat_input_t *i = vam->input;
21038 vl_api_dns_name_server_add_del_t *mp;
21040 ip6_address_t ip6_server;
21041 ip4_address_t ip4_server;
21046 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21048 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
21050 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
21052 else if (unformat (i, "del"))
21056 clib_warning ("parse error '%U'", format_unformat_error, i);
21061 if (ip4_set && ip6_set)
21063 errmsg ("Only one server address allowed per message");
21066 if ((ip4_set + ip6_set) == 0)
21068 errmsg ("Server address required");
21072 /* Construct the API message */
21073 M (DNS_NAME_SERVER_ADD_DEL, mp);
21077 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
21082 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
21086 mp->is_add = is_add;
21091 /* Wait for a reply, return good/bad news */
21097 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
21099 vat_main_t *vam = &vat_main;
21104 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
21105 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
21106 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
21107 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
21108 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
21109 clib_net_to_host_u32 (mp->action_index), mp->tag);
21114 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
21115 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
21116 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
21117 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
21118 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
21119 clib_net_to_host_u32 (mp->action_index), mp->tag);
21124 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
21127 vat_main_t *vam = &vat_main;
21128 vat_json_node_t *node = NULL;
21129 struct in6_addr ip6;
21130 struct in_addr ip4;
21132 if (VAT_JSON_ARRAY != vam->json_tree.type)
21134 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21135 vat_json_init_array (&vam->json_tree);
21137 node = vat_json_array_add (&vam->json_tree);
21138 vat_json_init_object (node);
21140 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
21141 vat_json_object_add_uint (node, "appns_index",
21142 clib_net_to_host_u32 (mp->appns_index));
21143 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
21144 vat_json_object_add_uint (node, "scope", mp->scope);
21145 vat_json_object_add_uint (node, "action_index",
21146 clib_net_to_host_u32 (mp->action_index));
21147 vat_json_object_add_uint (node, "lcl_port",
21148 clib_net_to_host_u16 (mp->lcl_port));
21149 vat_json_object_add_uint (node, "rmt_port",
21150 clib_net_to_host_u16 (mp->rmt_port));
21151 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
21152 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
21153 vat_json_object_add_string_copy (node, "tag", mp->tag);
21156 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
21157 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
21158 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
21159 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
21163 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
21164 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
21165 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
21166 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
21171 api_session_rule_add_del (vat_main_t * vam)
21173 vl_api_session_rule_add_del_t *mp;
21174 unformat_input_t *i = vam->input;
21175 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
21176 u32 appns_index = 0, scope = 0;
21177 ip4_address_t lcl_ip4, rmt_ip4;
21178 ip6_address_t lcl_ip6, rmt_ip6;
21179 u8 is_ip4 = 1, conn_set = 0;
21180 u8 is_add = 1, *tag = 0;
21183 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21185 if (unformat (i, "del"))
21187 else if (unformat (i, "add"))
21189 else if (unformat (i, "proto tcp"))
21191 else if (unformat (i, "proto udp"))
21193 else if (unformat (i, "appns %d", &appns_index))
21195 else if (unformat (i, "scope %d", &scope))
21197 else if (unformat (i, "tag %_%v%_", &tag))
21201 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
21202 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
21210 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
21211 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
21217 else if (unformat (i, "action %d", &action))
21222 if (proto == ~0 || !conn_set || action == ~0)
21224 errmsg ("transport proto, connection and action must be set");
21230 errmsg ("scope should be 0-3");
21234 M (SESSION_RULE_ADD_DEL, mp);
21236 mp->is_ip4 = is_ip4;
21237 mp->transport_proto = proto;
21238 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
21239 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
21240 mp->lcl_plen = lcl_plen;
21241 mp->rmt_plen = rmt_plen;
21242 mp->action_index = clib_host_to_net_u32 (action);
21243 mp->appns_index = clib_host_to_net_u32 (appns_index);
21245 mp->is_add = is_add;
21248 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
21249 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
21253 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
21254 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
21258 clib_memcpy (mp->tag, tag, vec_len (tag));
21268 api_session_rules_dump (vat_main_t * vam)
21270 vl_api_session_rules_dump_t *mp;
21271 vl_api_control_ping_t *mp_ping;
21274 if (!vam->json_output)
21276 print (vam->ofp, "%=20s", "Session Rules");
21279 M (SESSION_RULES_DUMP, mp);
21283 /* Use a control ping for synchronization */
21284 MPING (CONTROL_PING, mp_ping);
21287 /* Wait for a reply... */
21293 api_ip_container_proxy_add_del (vat_main_t * vam)
21295 vl_api_ip_container_proxy_add_del_t *mp;
21296 unformat_input_t *i = vam->input;
21297 u32 sw_if_index = ~0;
21298 vl_api_prefix_t pfx = { };
21302 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21304 if (unformat (i, "del"))
21306 else if (unformat (i, "add"))
21308 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
21310 else if (unformat (i, "sw_if_index %u", &sw_if_index))
21315 if (sw_if_index == ~0 || pfx.len == 0)
21317 errmsg ("address and sw_if_index must be set");
21321 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
21323 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
21324 mp->is_add = is_add;
21325 clib_memcpy (&mp->pfx, &pfx, sizeof (pfx));
21333 api_qos_record_enable_disable (vat_main_t * vam)
21335 unformat_input_t *i = vam->input;
21336 vl_api_qos_record_enable_disable_t *mp;
21337 u32 sw_if_index, qs = 0xff;
21338 u8 sw_if_index_set = 0;
21342 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21344 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21345 sw_if_index_set = 1;
21346 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21347 sw_if_index_set = 1;
21348 else if (unformat (i, "%U", unformat_qos_source, &qs))
21350 else if (unformat (i, "disable"))
21354 clib_warning ("parse error '%U'", format_unformat_error, i);
21359 if (sw_if_index_set == 0)
21361 errmsg ("missing interface name or sw_if_index");
21366 errmsg ("input location must be specified");
21370 M (QOS_RECORD_ENABLE_DISABLE, mp);
21372 mp->sw_if_index = ntohl (sw_if_index);
21373 mp->input_source = qs;
21374 mp->enable = enable;
21383 q_or_quit (vat_main_t * vam)
21385 #if VPP_API_TEST_BUILTIN == 0
21386 longjmp (vam->jump_buf, 1);
21388 return 0; /* not so much */
21392 q (vat_main_t * vam)
21394 return q_or_quit (vam);
21398 quit (vat_main_t * vam)
21400 return q_or_quit (vam);
21404 comment (vat_main_t * vam)
21410 elog_save (vat_main_t * vam)
21412 #if VPP_API_TEST_BUILTIN == 0
21413 elog_main_t *em = &vam->elog_main;
21414 unformat_input_t *i = vam->input;
21415 char *file, *chroot_file;
21416 clib_error_t *error;
21418 if (!unformat (i, "%s", &file))
21420 errmsg ("expected file name, got `%U'", format_unformat_error, i);
21424 /* It's fairly hard to get "../oopsie" through unformat; just in case */
21425 if (strstr (file, "..") || index (file, '/'))
21427 errmsg ("illegal characters in filename '%s'", file);
21431 chroot_file = (char *) format (0, "/tmp/%s%c", file, 0);
21435 errmsg ("Saving %wd of %wd events to %s",
21436 elog_n_events_in_buffer (em),
21437 elog_buffer_capacity (em), chroot_file);
21439 error = elog_write_file (em, chroot_file, 1 /* flush ring */ );
21440 vec_free (chroot_file);
21443 clib_error_report (error);
21445 errmsg ("Use the vpp event loger...");
21452 elog_setup (vat_main_t * vam)
21454 #if VPP_API_TEST_BUILTIN == 0
21455 elog_main_t *em = &vam->elog_main;
21456 unformat_input_t *i = vam->input;
21457 u32 nevents = 128 << 10;
21459 (void) unformat (i, "nevents %d", &nevents);
21461 elog_init (em, nevents);
21462 vl_api_set_elog_main (em);
21463 vl_api_set_elog_trace_api_messages (1);
21464 errmsg ("Event logger initialized with %u events", nevents);
21466 errmsg ("Use the vpp event loger...");
21472 elog_enable (vat_main_t * vam)
21474 #if VPP_API_TEST_BUILTIN == 0
21475 elog_main_t *em = &vam->elog_main;
21477 elog_enable_disable (em, 1 /* enable */ );
21478 vl_api_set_elog_trace_api_messages (1);
21479 errmsg ("Event logger enabled...");
21481 errmsg ("Use the vpp event loger...");
21487 elog_disable (vat_main_t * vam)
21489 #if VPP_API_TEST_BUILTIN == 0
21490 elog_main_t *em = &vam->elog_main;
21492 elog_enable_disable (em, 0 /* enable */ );
21493 vl_api_set_elog_trace_api_messages (1);
21494 errmsg ("Event logger disabled...");
21496 errmsg ("Use the vpp event loger...");
21502 statseg (vat_main_t * vam)
21504 ssvm_private_t *ssvmp = &vam->stat_segment;
21505 ssvm_shared_header_t *shared_header = ssvmp->sh;
21506 vlib_counter_t **counters;
21507 u64 thread0_index1_packets;
21508 u64 thread0_index1_bytes;
21509 f64 vector_rate, input_rate;
21512 uword *counter_vector_by_name;
21513 if (vam->stat_segment_lockp == 0)
21515 errmsg ("Stat segment not mapped...");
21519 /* look up "/if/rx for sw_if_index 1 as a test */
21521 clib_spinlock_lock (vam->stat_segment_lockp);
21523 counter_vector_by_name = (uword *) shared_header->opaque[1];
21525 p = hash_get_mem (counter_vector_by_name, "/if/rx");
21528 clib_spinlock_unlock (vam->stat_segment_lockp);
21529 errmsg ("/if/tx not found?");
21533 /* Fish per-thread vector of combined counters from shared memory */
21534 counters = (vlib_counter_t **) p[0];
21536 if (vec_len (counters[0]) < 2)
21538 clib_spinlock_unlock (vam->stat_segment_lockp);
21539 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
21543 /* Read thread 0 sw_if_index 1 counter */
21544 thread0_index1_packets = counters[0][1].packets;
21545 thread0_index1_bytes = counters[0][1].bytes;
21547 p = hash_get_mem (counter_vector_by_name, "vector_rate");
21550 clib_spinlock_unlock (vam->stat_segment_lockp);
21551 errmsg ("vector_rate not found?");
21555 vector_rate = *(f64 *) (p[0]);
21556 p = hash_get_mem (counter_vector_by_name, "input_rate");
21559 clib_spinlock_unlock (vam->stat_segment_lockp);
21560 errmsg ("input_rate not found?");
21563 input_rate = *(f64 *) (p[0]);
21565 clib_spinlock_unlock (vam->stat_segment_lockp);
21567 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
21568 vector_rate, input_rate);
21569 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
21570 thread0_index1_packets, thread0_index1_bytes);
21576 cmd_cmp (void *a1, void *a2)
21581 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
21585 help (vat_main_t * vam)
21590 unformat_input_t *i = vam->input;
21593 if (unformat (i, "%s", &name))
21597 vec_add1 (name, 0);
21599 hs = hash_get_mem (vam->help_by_name, name);
21601 print (vam->ofp, "usage: %s %s", name, hs[0]);
21603 print (vam->ofp, "No such msg / command '%s'", name);
21608 print (vam->ofp, "Help is available for the following:");
21611 hash_foreach_pair (p, vam->function_by_name,
21613 vec_add1 (cmds, (u8 *)(p->key));
21617 vec_sort_with_function (cmds, cmd_cmp);
21619 for (j = 0; j < vec_len (cmds); j++)
21620 print (vam->ofp, "%s", cmds[j]);
21627 set (vat_main_t * vam)
21629 u8 *name = 0, *value = 0;
21630 unformat_input_t *i = vam->input;
21632 if (unformat (i, "%s", &name))
21634 /* The input buffer is a vector, not a string. */
21635 value = vec_dup (i->buffer);
21636 vec_delete (value, i->index, 0);
21637 /* Almost certainly has a trailing newline */
21638 if (value[vec_len (value) - 1] == '\n')
21639 value[vec_len (value) - 1] = 0;
21640 /* Make sure it's a proper string, one way or the other */
21641 vec_add1 (value, 0);
21642 (void) clib_macro_set_value (&vam->macro_main,
21643 (char *) name, (char *) value);
21646 errmsg ("usage: set <name> <value>");
21654 unset (vat_main_t * vam)
21658 if (unformat (vam->input, "%s", &name))
21659 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
21660 errmsg ("unset: %s wasn't set", name);
21673 macro_sort_cmp (void *a1, void *a2)
21675 macro_sort_t *s1 = a1;
21676 macro_sort_t *s2 = a2;
21678 return strcmp ((char *) (s1->name), (char *) (s2->name));
21682 dump_macro_table (vat_main_t * vam)
21684 macro_sort_t *sort_me = 0, *sm;
21689 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
21691 vec_add2 (sort_me, sm, 1);
21692 sm->name = (u8 *)(p->key);
21693 sm->value = (u8 *) (p->value[0]);
21697 vec_sort_with_function (sort_me, macro_sort_cmp);
21699 if (vec_len (sort_me))
21700 print (vam->ofp, "%-15s%s", "Name", "Value");
21702 print (vam->ofp, "The macro table is empty...");
21704 for (i = 0; i < vec_len (sort_me); i++)
21705 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
21710 dump_node_table (vat_main_t * vam)
21713 vlib_node_t *node, *next_node;
21715 if (vec_len (vam->graph_nodes) == 0)
21717 print (vam->ofp, "Node table empty, issue get_node_graph...");
21721 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
21723 node = vam->graph_nodes[0][i];
21724 print (vam->ofp, "[%d] %s", i, node->name);
21725 for (j = 0; j < vec_len (node->next_nodes); j++)
21727 if (node->next_nodes[j] != ~0)
21729 next_node = vam->graph_nodes[0][node->next_nodes[j]];
21730 print (vam->ofp, " [%d] %s", j, next_node->name);
21738 value_sort_cmp (void *a1, void *a2)
21740 name_sort_t *n1 = a1;
21741 name_sort_t *n2 = a2;
21743 if (n1->value < n2->value)
21745 if (n1->value > n2->value)
21752 dump_msg_api_table (vat_main_t * vam)
21754 api_main_t *am = &api_main;
21755 name_sort_t *nses = 0, *ns;
21760 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
21762 vec_add2 (nses, ns, 1);
21763 ns->name = (u8 *)(hp->key);
21764 ns->value = (u32) hp->value[0];
21768 vec_sort_with_function (nses, value_sort_cmp);
21770 for (i = 0; i < vec_len (nses); i++)
21771 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
21777 get_msg_id (vat_main_t * vam)
21782 if (unformat (vam->input, "%s", &name_and_crc))
21784 message_index = vl_msg_api_get_msg_index (name_and_crc);
21785 if (message_index == ~0)
21787 print (vam->ofp, " '%s' not found", name_and_crc);
21790 print (vam->ofp, " '%s' has message index %d",
21791 name_and_crc, message_index);
21794 errmsg ("name_and_crc required...");
21799 search_node_table (vat_main_t * vam)
21801 unformat_input_t *line_input = vam->input;
21804 vlib_node_t *node, *next_node;
21807 if (vam->graph_node_index_by_name == 0)
21809 print (vam->ofp, "Node table empty, issue get_node_graph...");
21813 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21815 if (unformat (line_input, "%s", &node_to_find))
21817 vec_add1 (node_to_find, 0);
21818 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
21821 print (vam->ofp, "%s not found...", node_to_find);
21824 node = vam->graph_nodes[0][p[0]];
21825 print (vam->ofp, "[%d] %s", p[0], node->name);
21826 for (j = 0; j < vec_len (node->next_nodes); j++)
21828 if (node->next_nodes[j] != ~0)
21830 next_node = vam->graph_nodes[0][node->next_nodes[j]];
21831 print (vam->ofp, " [%d] %s", j, next_node->name);
21838 clib_warning ("parse error '%U'", format_unformat_error,
21844 vec_free (node_to_find);
21853 script (vat_main_t * vam)
21855 #if (VPP_API_TEST_BUILTIN==0)
21857 char *save_current_file;
21858 unformat_input_t save_input;
21859 jmp_buf save_jump_buf;
21860 u32 save_line_number;
21862 FILE *new_fp, *save_ifp;
21864 if (unformat (vam->input, "%s", &s))
21866 new_fp = fopen ((char *) s, "r");
21869 errmsg ("Couldn't open script file %s", s);
21876 errmsg ("Missing script name");
21880 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
21881 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
21882 save_ifp = vam->ifp;
21883 save_line_number = vam->input_line_number;
21884 save_current_file = (char *) vam->current_file;
21886 vam->input_line_number = 0;
21888 vam->current_file = s;
21891 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
21892 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
21893 vam->ifp = save_ifp;
21894 vam->input_line_number = save_line_number;
21895 vam->current_file = (u8 *) save_current_file;
21900 clib_warning ("use the exec command...");
21906 echo (vat_main_t * vam)
21908 print (vam->ofp, "%v", vam->input->buffer);
21912 /* List of API message constructors, CLI names map to api_xxx */
21913 #define foreach_vpe_api_msg \
21914 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
21915 _(sw_interface_dump,"") \
21916 _(sw_interface_set_flags, \
21917 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
21918 _(sw_interface_add_del_address, \
21919 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
21920 _(sw_interface_set_rx_mode, \
21921 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
21922 _(sw_interface_set_rx_placement, \
21923 "<intfc> | sw_if_index <id> [queue <id>] [worker <id> | main]") \
21924 _(sw_interface_rx_placement_dump, \
21925 "[<intfc> | sw_if_index <id>]") \
21926 _(sw_interface_set_table, \
21927 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
21928 _(sw_interface_set_mpls_enable, \
21929 "<intfc> | sw_if_index [disable | dis]") \
21930 _(sw_interface_set_vpath, \
21931 "<intfc> | sw_if_index <id> enable | disable") \
21932 _(sw_interface_set_vxlan_bypass, \
21933 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21934 _(sw_interface_set_geneve_bypass, \
21935 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21936 _(sw_interface_set_l2_xconnect, \
21937 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
21938 "enable | disable") \
21939 _(sw_interface_set_l2_bridge, \
21940 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
21941 "[shg <split-horizon-group>] [bvi]\n" \
21942 "enable | disable") \
21943 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
21944 _(bridge_domain_add_del, \
21945 "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") \
21946 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
21948 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
21949 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
21950 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
21952 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21954 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21956 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>] [host-mtu-size <mtu>] [gso | no-gso]") \
21958 "<vpp-if-name> | sw_if_index <id>") \
21959 _(sw_interface_tap_v2_dump, "") \
21960 _(virtio_pci_create, \
21961 "pci-addr <pci-address> [use_random_mac | hw-addr <mac-addr>] [features <hex-value>] [gso-enabled]") \
21962 _(virtio_pci_delete, \
21963 "<vpp-if-name> | sw_if_index <id>") \
21964 _(sw_interface_virtio_pci_dump, "") \
21966 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
21967 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \
21970 "<vpp-if-name> | sw_if_index <id>") \
21972 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
21973 _(bond_detach_slave, \
21974 "sw_if_index <n>") \
21975 _(sw_interface_bond_dump, "") \
21976 _(sw_interface_slave_dump, \
21977 "<vpp-if-name> | sw_if_index <id>") \
21978 _(ip_table_add_del, \
21979 "table <n> [ipv6] [add | del]\n") \
21980 _(ip_route_add_del, \
21981 "<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
21982 "[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
21983 "[weight <n>] [drop] [local] [classify <n>] [out-label <n>]\n" \
21984 "[multipath] [count <n>] [del]") \
21985 _(ip_mroute_add_del, \
21986 "<src> <grp>/<mask> [table-id <n>]\n" \
21987 "[<intfc> | sw_if_index <id>] [local] [del]") \
21988 _(mpls_table_add_del, \
21989 "table <n> [add | del]\n") \
21990 _(mpls_route_add_del, \
21991 "<label> <eos> via <addr | next-hop-table <n> | via-label <n> |\n" \
21992 "lookup-ip4-table <n> | lookup-in-ip6-table <n> |\n" \
21993 "l2-input-on <intfc> | l2-input-on sw_if_index <id>>\n" \
21994 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>] [weight <n>]\n" \
21995 "[drop] [local] [classify <n>] [out-label <n>] [multipath]\n" \
21996 "[count <n>] [del]") \
21997 _(mpls_ip_bind_unbind, \
21998 "<label> <addr/len>") \
21999 _(mpls_tunnel_add_del, \
22000 "[add | del <intfc | sw_if_index <id>>] via <addr | via-label <n>>\n" \
22001 "[<intfc> | sw_if_index <id> | next-hop-table <id>]\n" \
22002 "[l2-only] [out-label <n>]") \
22003 _(sr_mpls_policy_add, \
22004 "bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
22005 _(sr_mpls_policy_del, \
22007 _(bier_table_add_del, \
22008 "<label> <sub-domain> <set> <bsl> [del]") \
22009 _(bier_route_add_del, \
22010 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
22011 "[<intfc> | sw_if_index <id>]" \
22012 "[weight <n>] [del] [multipath]") \
22013 _(proxy_arp_add_del, \
22014 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
22015 _(proxy_arp_intfc_enable_disable, \
22016 "<intfc> | sw_if_index <id> enable | disable") \
22017 _(sw_interface_set_unnumbered, \
22018 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
22019 _(ip_neighbor_add_del, \
22020 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
22021 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
22022 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
22023 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
22024 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
22025 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
22026 "[outer_vlan_id_any][inner_vlan_id_any]") \
22027 _(reset_fib, "vrf <n> [ipv6]") \
22028 _(dhcp_proxy_config, \
22029 "svr <v46-address> src <v46-address>\n" \
22030 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
22031 _(dhcp_proxy_set_vss, \
22032 "tbl_id <n> [fib_id <n> oui <n> | vpn_ascii_id <text>] [ipv6] [del]") \
22033 _(dhcp_proxy_dump, "ip6") \
22034 _(dhcp_client_config, \
22035 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
22036 _(set_ip_flow_hash, \
22037 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
22038 _(sw_interface_ip6_enable_disable, \
22039 "<intfc> | sw_if_index <id> enable | disable") \
22040 _(ip6nd_proxy_add_del, \
22041 "<intfc> | sw_if_index <id> <ip6-address>") \
22042 _(ip6nd_proxy_dump, "") \
22043 _(sw_interface_ip6nd_ra_prefix, \
22044 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
22045 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
22046 "[nolink] [isno]") \
22047 _(sw_interface_ip6nd_ra_config, \
22048 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
22049 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
22050 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
22051 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
22052 _(l2_patch_add_del, \
22053 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
22054 "enable | disable") \
22055 _(sr_localsid_add_del, \
22056 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
22057 "fib-table <num> (end.psp) sw_if_index <num>") \
22058 _(classify_add_del_table, \
22059 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
22060 " [del] [del-chain] mask <mask-value>\n" \
22061 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
22062 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
22063 _(classify_add_del_session, \
22064 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
22065 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
22066 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
22067 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
22068 _(classify_set_interface_ip_table, \
22069 "<intfc> | sw_if_index <nn> table <nn>") \
22070 _(classify_set_interface_l2_tables, \
22071 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22072 " [other-table <nn>]") \
22073 _(get_node_index, "node <node-name") \
22074 _(add_node_next, "node <node-name> next <next-node-name>") \
22075 _(l2tpv3_create_tunnel, \
22076 "client_address <ip6-addr> our_address <ip6-addr>\n" \
22077 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
22078 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
22079 _(l2tpv3_set_tunnel_cookies, \
22080 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
22081 "[new_remote_cookie <nn>]\n") \
22082 _(l2tpv3_interface_enable_disable, \
22083 "<intfc> | sw_if_index <nn> enable | disable") \
22084 _(l2tpv3_set_lookup_key, \
22085 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
22086 _(sw_if_l2tpv3_tunnel_dump, "") \
22087 _(vxlan_offload_rx, \
22088 "hw { <interface name> | hw_if_index <nn>} " \
22089 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
22090 _(vxlan_add_del_tunnel, \
22091 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
22092 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
22093 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
22094 _(geneve_add_del_tunnel, \
22095 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
22096 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
22097 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
22098 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22099 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22100 _(gre_tunnel_add_del, \
22101 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
22102 "[teb | erspan <session-id>] [del]") \
22103 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22104 _(l2_fib_clear_table, "") \
22105 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
22106 _(l2_interface_vlan_tag_rewrite, \
22107 "<intfc> | sw_if_index <nn> \n" \
22108 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
22109 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
22110 _(create_vhost_user_if, \
22111 "socket <filename> [server] [renumber <dev_instance>] " \
22112 "[disable_mrg_rxbuf] [disable_indirect_desc] " \
22113 "[mac <mac_address>]") \
22114 _(modify_vhost_user_if, \
22115 "<intfc> | sw_if_index <nn> socket <filename>\n" \
22116 "[server] [renumber <dev_instance>]") \
22117 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
22118 _(sw_interface_vhost_user_dump, "") \
22119 _(show_version, "") \
22120 _(show_threads, "") \
22121 _(vxlan_gpe_add_del_tunnel, \
22122 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
22123 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
22124 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
22125 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
22126 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22127 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
22128 _(interface_name_renumber, \
22129 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
22130 _(input_acl_set_interface, \
22131 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22132 " [l2-table <nn>] [del]") \
22133 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
22134 _(ip_scan_neighbor_enable_disable, "[ip4|ip6|both|disable] [interval <n-min>]\n" \
22135 " [max-time <n-usec>] [max-update <n>] [delay <n-msec>] [stale <n-min>]") \
22136 _(want_ip4_arp_events, "address <ip4-address> [del]") \
22137 _(want_ip6_nd_events, "address <ip6-address> [del]") \
22138 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
22139 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
22140 _(ip_dump, "ipv4 | ipv6") \
22141 _(ipsec_spd_add_del, "spd_id <n> [del]") \
22142 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
22144 _(ipsec_sad_entry_add_del, "sad_id <n> spi <n> crypto_alg <alg>\n" \
22145 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
22146 " integ_alg <alg> integ_key <hex>") \
22147 _(ipsec_spd_entry_add_del, "spd_id <n> priority <n> action <action>\n" \
22148 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
22149 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
22150 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
22151 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
22152 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
22153 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
22154 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
22155 " [instance <n>]") \
22156 _(ipsec_sa_dump, "[sa_id <n>]") \
22157 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
22158 _(delete_loopback,"sw_if_index <nn>") \
22159 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
22160 _(bd_ip_mac_flush, "bd_id <bridge-domain-id>") \
22161 _(bd_ip_mac_dump, "[bd_id] <bridge-domain-id>") \
22162 _(want_interface_events, "enable|disable") \
22163 _(get_first_msg_id, "client <name>") \
22164 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
22165 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
22166 "fib-id <nn> [ip4][ip6][default]") \
22167 _(get_node_graph, " ") \
22168 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
22169 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
22170 _(ioam_disable, "") \
22171 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
22172 " sw_if_index <sw_if_index> p <priority> " \
22173 "w <weight>] [del]") \
22174 _(one_add_del_locator, "locator-set <locator_name> " \
22175 "iface <intf> | sw_if_index <sw_if_index> " \
22176 "p <priority> w <weight> [del]") \
22177 _(one_add_del_local_eid,"vni <vni> eid " \
22178 "<ipv4|ipv6>/<prefix> | <L2 address> " \
22179 "locator-set <locator_name> [del]" \
22180 "[key-id sha1|sha256 secret-key <secret-key>]")\
22181 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
22182 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
22183 _(one_enable_disable, "enable|disable") \
22184 _(one_map_register_enable_disable, "enable|disable") \
22185 _(one_map_register_fallback_threshold, "<value>") \
22186 _(one_rloc_probe_enable_disable, "enable|disable") \
22187 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
22189 "rloc <locator> p <prio> " \
22190 "w <weight> [rloc <loc> ... ] " \
22191 "action <action> [del-all]") \
22192 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
22194 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
22195 _(one_use_petr, "ip-address> | disable") \
22196 _(one_map_request_mode, "src-dst|dst-only") \
22197 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
22198 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
22199 _(one_locator_set_dump, "[local | remote]") \
22200 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
22201 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
22202 "[local] | [remote]") \
22203 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
22204 _(one_ndp_bd_get, "") \
22205 _(one_ndp_entries_get, "bd <bridge-domain>") \
22206 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
22207 _(one_l2_arp_bd_get, "") \
22208 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
22209 _(one_stats_enable_disable, "enable|disable") \
22210 _(show_one_stats_enable_disable, "") \
22211 _(one_eid_table_vni_dump, "") \
22212 _(one_eid_table_map_dump, "l2|l3") \
22213 _(one_map_resolver_dump, "") \
22214 _(one_map_server_dump, "") \
22215 _(one_adjacencies_get, "vni <vni>") \
22216 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
22217 _(show_one_rloc_probe_state, "") \
22218 _(show_one_map_register_state, "") \
22219 _(show_one_status, "") \
22220 _(one_stats_dump, "") \
22221 _(one_stats_flush, "") \
22222 _(one_get_map_request_itr_rlocs, "") \
22223 _(one_map_register_set_ttl, "<ttl>") \
22224 _(one_set_transport_protocol, "udp|api") \
22225 _(one_get_transport_protocol, "") \
22226 _(one_enable_disable_xtr_mode, "enable|disable") \
22227 _(one_show_xtr_mode, "") \
22228 _(one_enable_disable_pitr_mode, "enable|disable") \
22229 _(one_show_pitr_mode, "") \
22230 _(one_enable_disable_petr_mode, "enable|disable") \
22231 _(one_show_petr_mode, "") \
22232 _(show_one_nsh_mapping, "") \
22233 _(show_one_pitr, "") \
22234 _(show_one_use_petr, "") \
22235 _(show_one_map_request_mode, "") \
22236 _(show_one_map_register_ttl, "") \
22237 _(show_one_map_register_fallback_threshold, "") \
22238 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
22239 " sw_if_index <sw_if_index> p <priority> " \
22240 "w <weight>] [del]") \
22241 _(lisp_add_del_locator, "locator-set <locator_name> " \
22242 "iface <intf> | sw_if_index <sw_if_index> " \
22243 "p <priority> w <weight> [del]") \
22244 _(lisp_add_del_local_eid,"vni <vni> eid " \
22245 "<ipv4|ipv6>/<prefix> | <L2 address> " \
22246 "locator-set <locator_name> [del]" \
22247 "[key-id sha1|sha256 secret-key <secret-key>]") \
22248 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
22249 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
22250 _(lisp_enable_disable, "enable|disable") \
22251 _(lisp_map_register_enable_disable, "enable|disable") \
22252 _(lisp_rloc_probe_enable_disable, "enable|disable") \
22253 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
22255 "rloc <locator> p <prio> " \
22256 "w <weight> [rloc <loc> ... ] " \
22257 "action <action> [del-all]") \
22258 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
22260 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
22261 _(lisp_use_petr, "<ip-address> | disable") \
22262 _(lisp_map_request_mode, "src-dst|dst-only") \
22263 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
22264 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
22265 _(lisp_locator_set_dump, "[local | remote]") \
22266 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
22267 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
22268 "[local] | [remote]") \
22269 _(lisp_eid_table_vni_dump, "") \
22270 _(lisp_eid_table_map_dump, "l2|l3") \
22271 _(lisp_map_resolver_dump, "") \
22272 _(lisp_map_server_dump, "") \
22273 _(lisp_adjacencies_get, "vni <vni>") \
22274 _(gpe_fwd_entry_vnis_get, "") \
22275 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
22276 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
22277 "[table <table-id>]") \
22278 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
22279 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
22280 _(gpe_set_encap_mode, "lisp|vxlan") \
22281 _(gpe_get_encap_mode, "") \
22282 _(lisp_gpe_add_del_iface, "up|down") \
22283 _(lisp_gpe_enable_disable, "enable|disable") \
22284 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
22285 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
22286 _(show_lisp_rloc_probe_state, "") \
22287 _(show_lisp_map_register_state, "") \
22288 _(show_lisp_status, "") \
22289 _(lisp_get_map_request_itr_rlocs, "") \
22290 _(show_lisp_pitr, "") \
22291 _(show_lisp_use_petr, "") \
22292 _(show_lisp_map_request_mode, "") \
22293 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
22294 _(af_packet_delete, "name <host interface name>") \
22295 _(af_packet_dump, "") \
22296 _(policer_add_del, "name <policer name> <params> [del]") \
22297 _(policer_dump, "[name <policer name>]") \
22298 _(policer_classify_set_interface, \
22299 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22300 " [l2-table <nn>] [del]") \
22301 _(policer_classify_dump, "type [ip4|ip6|l2]") \
22302 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
22303 "[master|slave]") \
22304 _(netmap_delete, "name <interface name>") \
22305 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
22306 _(mpls_table_dump, "") \
22307 _(mpls_route_dump, "table-id <ID>") \
22308 _(classify_table_ids, "") \
22309 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
22310 _(classify_table_info, "table_id <nn>") \
22311 _(classify_session_dump, "table_id <nn>") \
22312 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
22313 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
22314 "[template_interval <nn>] [udp_checksum]") \
22315 _(ipfix_exporter_dump, "") \
22316 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
22317 _(ipfix_classify_stream_dump, "") \
22318 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
22319 _(ipfix_classify_table_dump, "") \
22320 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
22321 _(sw_interface_span_dump, "[l2]") \
22322 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
22323 _(pg_create_interface, "if_id <nn>") \
22324 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
22325 _(pg_enable_disable, "[stream <id>] disable") \
22326 _(ip_source_and_port_range_check_add_del, \
22327 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
22328 _(ip_source_and_port_range_check_interface_add_del, \
22329 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
22330 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
22331 _(delete_subif,"<intfc> | sw_if_index <nn>") \
22332 _(l2_interface_pbb_tag_rewrite, \
22333 "<intfc> | sw_if_index <nn> \n" \
22334 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
22335 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
22336 _(set_punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
22337 _(flow_classify_set_interface, \
22338 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
22339 _(flow_classify_dump, "type [ip4|ip6]") \
22340 _(ip_table_dump, "") \
22341 _(ip_route_dump, "table-id [ip4|ip6]") \
22342 _(ip_mtable_dump, "") \
22343 _(ip_mroute_dump, "table-id [ip4|ip6]") \
22344 _(feature_enable_disable, "arc_name <arc_name> " \
22345 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
22346 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
22348 _(l2_xconnect_dump, "") \
22349 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
22350 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
22351 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
22352 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
22353 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
22354 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
22355 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
22356 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
22357 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
22358 _(sock_init_shm, "size <nnn>") \
22359 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
22360 _(dns_enable_disable, "[enable][disable]") \
22361 _(dns_name_server_add_del, "<ip-address> [del]") \
22362 _(dns_resolve_name, "<hostname>") \
22363 _(dns_resolve_ip, "<ip4|ip6>") \
22364 _(dns_name_server_add_del, "<ip-address> [del]") \
22365 _(dns_resolve_name, "<hostname>") \
22366 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
22367 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
22368 _(session_rules_dump, "") \
22369 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
22370 _(output_acl_set_interface, \
22371 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22372 " [l2-table <nn>] [del]") \
22373 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
22375 /* List of command functions, CLI names map directly to functions */
22376 #define foreach_cli_function \
22377 _(comment, "usage: comment <ignore-rest-of-line>") \
22378 _(dump_interface_table, "usage: dump_interface_table") \
22379 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
22380 _(dump_ipv4_table, "usage: dump_ipv4_table") \
22381 _(dump_ipv6_table, "usage: dump_ipv6_table") \
22382 _(dump_macro_table, "usage: dump_macro_table ") \
22383 _(dump_node_table, "usage: dump_node_table") \
22384 _(dump_msg_api_table, "usage: dump_msg_api_table") \
22385 _(elog_setup, "usage: elog_setup [nevents, default 128K]") \
22386 _(elog_disable, "usage: elog_disable") \
22387 _(elog_enable, "usage: elog_enable") \
22388 _(elog_save, "usage: elog_save <filename>") \
22389 _(get_msg_id, "usage: get_msg_id name_and_crc") \
22390 _(echo, "usage: echo <message>") \
22391 _(exec, "usage: exec <vpe-debug-CLI-command>") \
22392 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
22393 _(help, "usage: help") \
22394 _(q, "usage: quit") \
22395 _(quit, "usage: quit") \
22396 _(search_node_table, "usage: search_node_table <name>...") \
22397 _(set, "usage: set <variable-name> <value>") \
22398 _(script, "usage: script <file-name>") \
22399 _(statseg, "usage: statseg") \
22400 _(unset, "usage: unset <variable-name>")
22403 static void vl_api_##n##_t_handler_uni \
22404 (vl_api_##n##_t * mp) \
22406 vat_main_t * vam = &vat_main; \
22407 if (vam->json_output) { \
22408 vl_api_##n##_t_handler_json(mp); \
22410 vl_api_##n##_t_handler(mp); \
22413 foreach_vpe_api_reply_msg;
22414 #if VPP_API_TEST_BUILTIN == 0
22415 foreach_standalone_reply_msg;
22420 vat_api_hookup (vat_main_t * vam)
22423 vl_msg_api_set_handlers(VL_API_##N, #n, \
22424 vl_api_##n##_t_handler_uni, \
22426 vl_api_##n##_t_endian, \
22427 vl_api_##n##_t_print, \
22428 sizeof(vl_api_##n##_t), 1);
22429 foreach_vpe_api_reply_msg;
22430 #if VPP_API_TEST_BUILTIN == 0
22431 foreach_standalone_reply_msg;
22435 #if (VPP_API_TEST_BUILTIN==0)
22436 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
22438 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
22440 vam->function_by_name = hash_create_string (0, sizeof (uword));
22442 vam->help_by_name = hash_create_string (0, sizeof (uword));
22445 /* API messages we can send */
22446 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
22447 foreach_vpe_api_msg;
22451 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
22452 foreach_vpe_api_msg;
22455 /* CLI functions */
22456 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
22457 foreach_cli_function;
22461 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
22462 foreach_cli_function;
22466 #if VPP_API_TEST_BUILTIN
22467 static clib_error_t *
22468 vat_api_hookup_shim (vlib_main_t * vm)
22470 vat_api_hookup (&vat_main);
22474 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
22478 * fd.io coding-style-patch-verification: ON
22481 * eval: (c-set-style "gnu")