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>
61 #include <vlibapi/api_types_inlines.h>
66 #define vl_typedefs /* define message structures */
67 #include <vpp/api/vpe_all_api_h.h>
70 /* declare message handlers for each api */
72 #define vl_endianfun /* define message structures */
73 #include <vpp/api/vpe_all_api_h.h>
76 /* instantiate all the print functions we know about */
77 #if VPP_API_TEST_BUILTIN == 0
78 #define vl_print(handle, ...)
80 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
83 #include <vpp/api/vpe_all_api_h.h>
86 #define __plugin_msg_base 0
87 #include <vlibapi/vat_helper_macros.h>
89 #if VPP_API_TEST_BUILTIN == 0
99 vat_socket_connect (vat_main_t * vam)
102 vam->socket_client_main = &socket_client_main;
103 if ((rv = vl_socket_client_connect ((char *) vam->socket_name,
105 0 /* default socket rx, tx buffer */ )))
107 /* vpp expects the client index in network order */
108 vam->my_client_index = htonl (socket_client_main.client_index);
111 #else /* vpp built-in case, we don't do sockets... */
113 vat_socket_connect (vat_main_t * vam)
119 vl_socket_client_read (int wait)
125 vl_socket_client_write ()
131 vl_socket_client_msg_alloc (int nbytes)
139 vat_time_now (vat_main_t * vam)
141 #if VPP_API_TEST_BUILTIN
142 return vlib_time_now (vam->vlib_main);
144 return clib_time_now (&vam->clib_time);
149 errmsg (char *fmt, ...)
151 vat_main_t *vam = &vat_main;
156 s = va_format (0, fmt, &va);
161 #if VPP_API_TEST_BUILTIN
162 vlib_cli_output (vam->vlib_main, (char *) s);
165 if (vam->ifp != stdin)
166 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
167 vam->input_line_number);
168 fformat (vam->ofp, (char *) s);
176 #if VPP_API_TEST_BUILTIN == 0
178 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
180 vat_main_t *vam = va_arg (*args, vat_main_t *);
181 u32 *result = va_arg (*args, u32 *);
185 if (!unformat (input, "%s", &if_name))
188 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
196 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
201 /* Parse an IP4 address %d.%d.%d.%d. */
203 unformat_ip4_address (unformat_input_t * input, va_list * args)
205 u8 *result = va_arg (*args, u8 *);
208 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
211 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
223 unformat_ethernet_address (unformat_input_t * input, va_list * args)
225 u8 *result = va_arg (*args, u8 *);
228 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
229 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
233 for (i = 0; i < 6; i++)
234 if (a[i] >= (1 << 8))
237 for (i = 0; i < 6; i++)
243 /* Returns ethernet type as an int in host byte order. */
245 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
248 u16 *result = va_arg (*args, u16 *);
252 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
254 if (type >= (1 << 16))
262 /* Parse an IP6 address. */
264 unformat_ip6_address (unformat_input_t * input, va_list * args)
266 ip6_address_t *result = va_arg (*args, ip6_address_t *);
268 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
269 uword c, n_colon, double_colon_index;
271 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
272 double_colon_index = ARRAY_LEN (hex_quads);
273 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
276 if (c >= '0' && c <= '9')
278 else if (c >= 'a' && c <= 'f')
279 hex_digit = c + 10 - 'a';
280 else if (c >= 'A' && c <= 'F')
281 hex_digit = c + 10 - 'A';
282 else if (c == ':' && n_colon < 2)
286 unformat_put_input (input);
290 /* Too many hex quads. */
291 if (n_hex_quads >= ARRAY_LEN (hex_quads))
296 hex_quad = (hex_quad << 4) | hex_digit;
298 /* Hex quad must fit in 16 bits. */
299 if (n_hex_digits >= 4)
306 /* Save position of :: */
309 /* More than one :: ? */
310 if (double_colon_index < ARRAY_LEN (hex_quads))
312 double_colon_index = n_hex_quads;
315 if (n_colon > 0 && n_hex_digits > 0)
317 hex_quads[n_hex_quads++] = hex_quad;
323 if (n_hex_digits > 0)
324 hex_quads[n_hex_quads++] = hex_quad;
329 /* Expand :: to appropriate number of zero hex quads. */
330 if (double_colon_index < ARRAY_LEN (hex_quads))
332 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
334 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
335 hex_quads[n_zero + i] = hex_quads[i];
337 for (i = 0; i < n_zero; i++)
338 hex_quads[double_colon_index + i] = 0;
340 n_hex_quads = ARRAY_LEN (hex_quads);
343 /* Too few hex quads given. */
344 if (n_hex_quads < ARRAY_LEN (hex_quads))
347 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
348 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
355 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
357 u32 *r = va_arg (*args, u32 *);
360 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
361 foreach_ipsec_policy_action
369 format_ipsec_crypto_alg (u8 * s, va_list * args)
371 u32 i = va_arg (*args, u32);
376 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
377 foreach_ipsec_crypto_alg
380 return format (s, "unknown");
382 return format (s, "%s", t);
386 format_ipsec_integ_alg (u8 * s, va_list * args)
388 u32 i = va_arg (*args, u32);
393 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
394 foreach_ipsec_integ_alg
397 return format (s, "unknown");
399 return format (s, "%s", t);
402 #else /* VPP_API_TEST_BUILTIN == 1 */
404 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
406 vat_main_t *vam __clib_unused = va_arg (*args, vat_main_t *);
407 vnet_main_t *vnm = vnet_get_main ();
408 u32 *result = va_arg (*args, u32 *);
410 return unformat (input, "%U", unformat_vnet_sw_interface, vnm, result);
414 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
416 vat_main_t *vam __clib_unused = va_arg (*args, vat_main_t *);
417 vnet_main_t *vnm = vnet_get_main ();
418 u32 *result = va_arg (*args, u32 *);
420 return unformat (input, "%U", unformat_vnet_hw_interface, vnm, result);
423 #endif /* VPP_API_TEST_BUILTIN */
426 unformat_ipsec_api_crypto_alg (unformat_input_t * input, va_list * args)
428 u32 *r = va_arg (*args, u32 *);
431 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_API_CRYPTO_ALG_##f;
432 foreach_ipsec_crypto_alg
440 unformat_ipsec_api_integ_alg (unformat_input_t * input, va_list * args)
442 u32 *r = va_arg (*args, u32 *);
445 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_API_INTEG_ALG_##f;
446 foreach_ipsec_integ_alg
454 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
456 u8 *r = va_arg (*args, u8 *);
458 if (unformat (input, "kbps"))
459 *r = SSE2_QOS_RATE_KBPS;
460 else if (unformat (input, "pps"))
461 *r = SSE2_QOS_RATE_PPS;
468 unformat_policer_round_type (unformat_input_t * input, va_list * args)
470 u8 *r = va_arg (*args, u8 *);
472 if (unformat (input, "closest"))
473 *r = SSE2_QOS_ROUND_TO_CLOSEST;
474 else if (unformat (input, "up"))
475 *r = SSE2_QOS_ROUND_TO_UP;
476 else if (unformat (input, "down"))
477 *r = SSE2_QOS_ROUND_TO_DOWN;
484 unformat_policer_type (unformat_input_t * input, va_list * args)
486 u8 *r = va_arg (*args, u8 *);
488 if (unformat (input, "1r2c"))
489 *r = SSE2_QOS_POLICER_TYPE_1R2C;
490 else if (unformat (input, "1r3c"))
491 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
492 else if (unformat (input, "2r3c-2698"))
493 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
494 else if (unformat (input, "2r3c-4115"))
495 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
496 else if (unformat (input, "2r3c-mef5cf1"))
497 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
504 unformat_dscp (unformat_input_t * input, va_list * va)
506 u8 *r = va_arg (*va, u8 *);
509 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
518 unformat_policer_action_type (unformat_input_t * input, va_list * va)
520 sse2_qos_pol_action_params_st *a
521 = va_arg (*va, sse2_qos_pol_action_params_st *);
523 if (unformat (input, "drop"))
524 a->action_type = SSE2_QOS_ACTION_DROP;
525 else if (unformat (input, "transmit"))
526 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
527 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
528 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
535 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
537 u32 *r = va_arg (*va, u32 *);
540 if (unformat (input, "ip4"))
541 tid = POLICER_CLASSIFY_TABLE_IP4;
542 else if (unformat (input, "ip6"))
543 tid = POLICER_CLASSIFY_TABLE_IP6;
544 else if (unformat (input, "l2"))
545 tid = POLICER_CLASSIFY_TABLE_L2;
554 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
556 u32 *r = va_arg (*va, u32 *);
559 if (unformat (input, "ip4"))
560 tid = FLOW_CLASSIFY_TABLE_IP4;
561 else if (unformat (input, "ip6"))
562 tid = FLOW_CLASSIFY_TABLE_IP6;
570 #if (VPP_API_TEST_BUILTIN==0)
572 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
573 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
574 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
575 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
578 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
580 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
581 mfib_itf_attribute_t attr;
584 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
586 if (unformat (input, mfib_itf_flag_long_names[attr]))
587 *iflags |= (1 << attr);
589 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
591 if (unformat (input, mfib_itf_flag_names[attr]))
592 *iflags |= (1 << attr);
595 return (old == *iflags ? 0 : 1);
599 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
601 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
602 mfib_entry_attribute_t attr;
605 FOR_EACH_MFIB_ATTRIBUTE (attr)
607 if (unformat (input, mfib_flag_long_names[attr]))
608 *eflags |= (1 << attr);
610 FOR_EACH_MFIB_ATTRIBUTE (attr)
612 if (unformat (input, mfib_flag_names[attr]))
613 *eflags |= (1 << attr);
616 return (old == *eflags ? 0 : 1);
620 format_ip4_address (u8 * s, va_list * args)
622 u8 *a = va_arg (*args, u8 *);
623 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
627 format_ip6_address (u8 * s, va_list * args)
629 ip6_address_t *a = va_arg (*args, ip6_address_t *);
630 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
632 i_max_n_zero = ARRAY_LEN (a->as_u16);
634 i_first_zero = i_max_n_zero;
636 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
638 u32 is_zero = a->as_u16[i] == 0;
639 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
645 if ((!is_zero && n_zeros > max_n_zeros)
646 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
648 i_max_n_zero = i_first_zero;
649 max_n_zeros = n_zeros;
650 i_first_zero = ARRAY_LEN (a->as_u16);
655 last_double_colon = 0;
656 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
658 if (i == i_max_n_zero && max_n_zeros > 1)
660 s = format (s, "::");
661 i += max_n_zeros - 1;
662 last_double_colon = 1;
666 s = format (s, "%s%x",
667 (last_double_colon || i == 0) ? "" : ":",
668 clib_net_to_host_u16 (a->as_u16[i]));
669 last_double_colon = 0;
676 /* Format an IP46 address. */
678 format_ip46_address (u8 * s, va_list * args)
680 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
681 ip46_type_t type = va_arg (*args, ip46_type_t);
687 is_ip4 = ip46_address_is_ip4 (ip46);
698 format (s, "%U", format_ip4_address, &ip46->ip4) :
699 format (s, "%U", format_ip6_address, &ip46->ip6);
703 format_ethernet_address (u8 * s, va_list * args)
705 u8 *a = va_arg (*args, u8 *);
707 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
708 a[0], a[1], a[2], a[3], a[4], a[5]);
713 increment_v4_address (vl_api_ip4_address_t * i)
715 ip4_address_t *a = (ip4_address_t *) i;
718 v = ntohl (a->as_u32) + 1;
719 a->as_u32 = ntohl (v);
723 increment_v6_address (vl_api_ip6_address_t * i)
725 ip6_address_t *a = (ip6_address_t *) i;
728 v0 = clib_net_to_host_u64 (a->as_u64[0]);
729 v1 = clib_net_to_host_u64 (a->as_u64[1]);
734 a->as_u64[0] = clib_net_to_host_u64 (v0);
735 a->as_u64[1] = clib_net_to_host_u64 (v1);
739 increment_address (vl_api_address_t * a)
741 if (a->af == ADDRESS_IP4)
742 increment_v4_address (&a->un.ip4);
743 else if (a->af == ADDRESS_IP6)
744 increment_v6_address (&a->un.ip6);
748 set_ip4_address (vl_api_address_t * a, u32 v)
750 if (a->af == ADDRESS_IP4)
752 ip4_address_t *i = (ip4_address_t *) & a->un.ip4;
758 increment_mac_address (u8 * mac)
760 u64 tmp = *((u64 *) mac);
761 tmp = clib_net_to_host_u64 (tmp);
762 tmp += 1 << 16; /* skip unused (least significant) octets */
763 tmp = clib_host_to_net_u64 (tmp);
765 clib_memcpy (mac, &tmp, 6);
769 vat_json_object_add_address (vat_json_node_t * node,
770 const char *str, const vl_api_address_t * addr)
772 if (ADDRESS_IP6 == addr->af)
776 clib_memcpy (&ip6, &addr->un.ip6, sizeof (ip6));
777 vat_json_object_add_ip6 (node, str, ip6);
783 clib_memcpy (&ip4, &addr->un.ip4, sizeof (ip4));
784 vat_json_object_add_ip4 (node, str, ip4);
789 vat_json_object_add_prefix (vat_json_node_t * node,
790 const vl_api_prefix_t * prefix)
792 vat_json_object_add_uint (node, "address_length", prefix->address_length);
793 vat_json_object_add_address (node, "prefix", &prefix->address);
796 static void vl_api_create_loopback_reply_t_handler
797 (vl_api_create_loopback_reply_t * mp)
799 vat_main_t *vam = &vat_main;
800 i32 retval = ntohl (mp->retval);
802 vam->retval = retval;
803 vam->regenerate_interface_table = 1;
804 vam->sw_if_index = ntohl (mp->sw_if_index);
805 vam->result_ready = 1;
808 static void vl_api_create_loopback_reply_t_handler_json
809 (vl_api_create_loopback_reply_t * mp)
811 vat_main_t *vam = &vat_main;
812 vat_json_node_t node;
814 vat_json_init_object (&node);
815 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
816 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
818 vat_json_print (vam->ofp, &node);
819 vat_json_free (&node);
820 vam->retval = ntohl (mp->retval);
821 vam->result_ready = 1;
824 static void vl_api_create_loopback_instance_reply_t_handler
825 (vl_api_create_loopback_instance_reply_t * mp)
827 vat_main_t *vam = &vat_main;
828 i32 retval = ntohl (mp->retval);
830 vam->retval = retval;
831 vam->regenerate_interface_table = 1;
832 vam->sw_if_index = ntohl (mp->sw_if_index);
833 vam->result_ready = 1;
836 static void vl_api_create_loopback_instance_reply_t_handler_json
837 (vl_api_create_loopback_instance_reply_t * mp)
839 vat_main_t *vam = &vat_main;
840 vat_json_node_t node;
842 vat_json_init_object (&node);
843 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
844 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
846 vat_json_print (vam->ofp, &node);
847 vat_json_free (&node);
848 vam->retval = ntohl (mp->retval);
849 vam->result_ready = 1;
852 static void vl_api_af_packet_create_reply_t_handler
853 (vl_api_af_packet_create_reply_t * mp)
855 vat_main_t *vam = &vat_main;
856 i32 retval = ntohl (mp->retval);
858 vam->retval = retval;
859 vam->regenerate_interface_table = 1;
860 vam->sw_if_index = ntohl (mp->sw_if_index);
861 vam->result_ready = 1;
864 static void vl_api_af_packet_create_reply_t_handler_json
865 (vl_api_af_packet_create_reply_t * mp)
867 vat_main_t *vam = &vat_main;
868 vat_json_node_t node;
870 vat_json_init_object (&node);
871 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
872 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
874 vat_json_print (vam->ofp, &node);
875 vat_json_free (&node);
877 vam->retval = ntohl (mp->retval);
878 vam->result_ready = 1;
881 static void vl_api_create_vlan_subif_reply_t_handler
882 (vl_api_create_vlan_subif_reply_t * mp)
884 vat_main_t *vam = &vat_main;
885 i32 retval = ntohl (mp->retval);
887 vam->retval = retval;
888 vam->regenerate_interface_table = 1;
889 vam->sw_if_index = ntohl (mp->sw_if_index);
890 vam->result_ready = 1;
893 static void vl_api_create_vlan_subif_reply_t_handler_json
894 (vl_api_create_vlan_subif_reply_t * mp)
896 vat_main_t *vam = &vat_main;
897 vat_json_node_t node;
899 vat_json_init_object (&node);
900 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
901 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
903 vat_json_print (vam->ofp, &node);
904 vat_json_free (&node);
906 vam->retval = ntohl (mp->retval);
907 vam->result_ready = 1;
910 static void vl_api_create_subif_reply_t_handler
911 (vl_api_create_subif_reply_t * mp)
913 vat_main_t *vam = &vat_main;
914 i32 retval = ntohl (mp->retval);
916 vam->retval = retval;
917 vam->regenerate_interface_table = 1;
918 vam->sw_if_index = ntohl (mp->sw_if_index);
919 vam->result_ready = 1;
922 static void vl_api_create_subif_reply_t_handler_json
923 (vl_api_create_subif_reply_t * mp)
925 vat_main_t *vam = &vat_main;
926 vat_json_node_t node;
928 vat_json_init_object (&node);
929 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
930 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
932 vat_json_print (vam->ofp, &node);
933 vat_json_free (&node);
935 vam->retval = ntohl (mp->retval);
936 vam->result_ready = 1;
939 static void vl_api_interface_name_renumber_reply_t_handler
940 (vl_api_interface_name_renumber_reply_t * mp)
942 vat_main_t *vam = &vat_main;
943 i32 retval = ntohl (mp->retval);
945 vam->retval = retval;
946 vam->regenerate_interface_table = 1;
947 vam->result_ready = 1;
950 static void vl_api_interface_name_renumber_reply_t_handler_json
951 (vl_api_interface_name_renumber_reply_t * mp)
953 vat_main_t *vam = &vat_main;
954 vat_json_node_t node;
956 vat_json_init_object (&node);
957 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
959 vat_json_print (vam->ofp, &node);
960 vat_json_free (&node);
962 vam->retval = ntohl (mp->retval);
963 vam->result_ready = 1;
967 * Special-case: build the interface table, maintain
968 * the next loopback sw_if_index vbl.
970 static void vl_api_sw_interface_details_t_handler
971 (vl_api_sw_interface_details_t * mp)
973 vat_main_t *vam = &vat_main;
974 u8 *s = format (0, "%s%c", mp->interface_name, 0);
976 hash_set_mem (vam->sw_if_index_by_interface_name, s,
977 ntohl (mp->sw_if_index));
979 /* In sub interface case, fill the sub interface table entry */
980 if (mp->sw_if_index != mp->sup_sw_if_index)
982 sw_interface_subif_t *sub = NULL;
984 vec_add2 (vam->sw_if_subif_table, sub, 1);
986 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
987 strncpy ((char *) sub->interface_name, (char *) s,
988 vec_len (sub->interface_name));
989 sub->sw_if_index = ntohl (mp->sw_if_index);
990 sub->sub_id = ntohl (mp->sub_id);
992 sub->sub_dot1ad = mp->sub_dot1ad;
993 sub->sub_number_of_tags = mp->sub_number_of_tags;
994 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
995 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
996 sub->sub_exact_match = mp->sub_exact_match;
997 sub->sub_default = mp->sub_default;
998 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
999 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
1001 /* vlan tag rewrite */
1002 sub->vtr_op = ntohl (mp->vtr_op);
1003 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
1004 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
1005 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
1009 static void vl_api_sw_interface_details_t_handler_json
1010 (vl_api_sw_interface_details_t * mp)
1012 vat_main_t *vam = &vat_main;
1013 vat_json_node_t *node = NULL;
1015 if (VAT_JSON_ARRAY != vam->json_tree.type)
1017 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1018 vat_json_init_array (&vam->json_tree);
1020 node = vat_json_array_add (&vam->json_tree);
1022 vat_json_init_object (node);
1023 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1024 vat_json_object_add_uint (node, "sup_sw_if_index",
1025 ntohl (mp->sup_sw_if_index));
1026 vat_json_object_add_uint (node, "l2_address_length",
1027 ntohl (mp->l2_address_length));
1028 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
1029 sizeof (mp->l2_address));
1030 vat_json_object_add_string_copy (node, "interface_name",
1031 mp->interface_name);
1032 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
1033 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
1034 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
1035 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
1036 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
1037 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
1038 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
1039 vat_json_object_add_uint (node, "sub_number_of_tags",
1040 mp->sub_number_of_tags);
1041 vat_json_object_add_uint (node, "sub_outer_vlan_id",
1042 ntohs (mp->sub_outer_vlan_id));
1043 vat_json_object_add_uint (node, "sub_inner_vlan_id",
1044 ntohs (mp->sub_inner_vlan_id));
1045 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
1046 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
1047 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
1048 mp->sub_outer_vlan_id_any);
1049 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
1050 mp->sub_inner_vlan_id_any);
1051 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
1052 vat_json_object_add_uint (node, "vtr_push_dot1q",
1053 ntohl (mp->vtr_push_dot1q));
1054 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
1055 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
1058 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
1060 format_ethernet_address,
1062 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
1064 format_ethernet_address,
1066 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
1067 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
1071 #if VPP_API_TEST_BUILTIN == 0
1072 static void vl_api_sw_interface_event_t_handler
1073 (vl_api_sw_interface_event_t * mp)
1075 vat_main_t *vam = &vat_main;
1076 if (vam->interface_event_display)
1077 errmsg ("interface flags: sw_if_index %d %s %s",
1078 ntohl (mp->sw_if_index),
1079 mp->admin_up_down ? "admin-up" : "admin-down",
1080 mp->link_up_down ? "link-up" : "link-down");
1084 __clib_unused static void
1085 vl_api_sw_interface_event_t_handler_json (vl_api_sw_interface_event_t * mp)
1087 /* JSON output not supported */
1091 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
1093 vat_main_t *vam = &vat_main;
1094 i32 retval = ntohl (mp->retval);
1096 vam->retval = retval;
1097 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1098 vam->result_ready = 1;
1102 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1104 vat_main_t *vam = &vat_main;
1105 vat_json_node_t node;
1106 api_main_t *am = &api_main;
1110 vat_json_init_object (&node);
1111 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1112 vat_json_object_add_uint (&node, "reply_in_shmem",
1113 ntohl (mp->reply_in_shmem));
1114 /* Toss the shared-memory original... */
1115 pthread_mutex_lock (&am->vlib_rp->mutex);
1116 oldheap = svm_push_data_heap (am->vlib_rp);
1118 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1121 svm_pop_heap (oldheap);
1122 pthread_mutex_unlock (&am->vlib_rp->mutex);
1124 vat_json_print (vam->ofp, &node);
1125 vat_json_free (&node);
1127 vam->retval = ntohl (mp->retval);
1128 vam->result_ready = 1;
1132 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1134 vat_main_t *vam = &vat_main;
1135 i32 retval = ntohl (mp->retval);
1136 u32 length = vl_api_string_len (&mp->reply);
1138 vec_reset_length (vam->cmd_reply);
1140 vam->retval = retval;
1143 vec_validate (vam->cmd_reply, length);
1144 clib_memcpy ((char *) (vam->cmd_reply),
1145 vl_api_from_api_string (&mp->reply), length);
1146 vam->cmd_reply[length] = 0;
1148 vam->result_ready = 1;
1152 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1154 vat_main_t *vam = &vat_main;
1155 vat_json_node_t node;
1157 vec_reset_length (vam->cmd_reply);
1159 vat_json_init_object (&node);
1160 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1161 vat_json_object_add_string_copy (&node, "reply",
1162 vl_api_from_api_string (&mp->reply));
1164 vat_json_print (vam->ofp, &node);
1165 vat_json_free (&node);
1167 vam->retval = ntohl (mp->retval);
1168 vam->result_ready = 1;
1171 static void vl_api_classify_add_del_table_reply_t_handler
1172 (vl_api_classify_add_del_table_reply_t * mp)
1174 vat_main_t *vam = &vat_main;
1175 i32 retval = ntohl (mp->retval);
1176 if (vam->async_mode)
1178 vam->async_errors += (retval < 0);
1182 vam->retval = retval;
1184 ((mp->new_table_index != 0xFFFFFFFF) ||
1185 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1186 (mp->match_n_vectors != 0xFFFFFFFF)))
1188 * Note: this is just barely thread-safe, depends on
1189 * the main thread spinning waiting for an answer...
1191 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1192 ntohl (mp->new_table_index),
1193 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1194 vam->result_ready = 1;
1198 static void vl_api_classify_add_del_table_reply_t_handler_json
1199 (vl_api_classify_add_del_table_reply_t * mp)
1201 vat_main_t *vam = &vat_main;
1202 vat_json_node_t node;
1204 vat_json_init_object (&node);
1205 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1206 vat_json_object_add_uint (&node, "new_table_index",
1207 ntohl (mp->new_table_index));
1208 vat_json_object_add_uint (&node, "skip_n_vectors",
1209 ntohl (mp->skip_n_vectors));
1210 vat_json_object_add_uint (&node, "match_n_vectors",
1211 ntohl (mp->match_n_vectors));
1213 vat_json_print (vam->ofp, &node);
1214 vat_json_free (&node);
1216 vam->retval = ntohl (mp->retval);
1217 vam->result_ready = 1;
1220 static void vl_api_get_node_index_reply_t_handler
1221 (vl_api_get_node_index_reply_t * mp)
1223 vat_main_t *vam = &vat_main;
1224 i32 retval = ntohl (mp->retval);
1225 if (vam->async_mode)
1227 vam->async_errors += (retval < 0);
1231 vam->retval = retval;
1233 errmsg ("node index %d", ntohl (mp->node_index));
1234 vam->result_ready = 1;
1238 static void vl_api_get_node_index_reply_t_handler_json
1239 (vl_api_get_node_index_reply_t * mp)
1241 vat_main_t *vam = &vat_main;
1242 vat_json_node_t node;
1244 vat_json_init_object (&node);
1245 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1246 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1248 vat_json_print (vam->ofp, &node);
1249 vat_json_free (&node);
1251 vam->retval = ntohl (mp->retval);
1252 vam->result_ready = 1;
1255 static void vl_api_get_next_index_reply_t_handler
1256 (vl_api_get_next_index_reply_t * mp)
1258 vat_main_t *vam = &vat_main;
1259 i32 retval = ntohl (mp->retval);
1260 if (vam->async_mode)
1262 vam->async_errors += (retval < 0);
1266 vam->retval = retval;
1268 errmsg ("next node index %d", ntohl (mp->next_index));
1269 vam->result_ready = 1;
1273 static void vl_api_get_next_index_reply_t_handler_json
1274 (vl_api_get_next_index_reply_t * mp)
1276 vat_main_t *vam = &vat_main;
1277 vat_json_node_t node;
1279 vat_json_init_object (&node);
1280 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1281 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1283 vat_json_print (vam->ofp, &node);
1284 vat_json_free (&node);
1286 vam->retval = ntohl (mp->retval);
1287 vam->result_ready = 1;
1290 static void vl_api_add_node_next_reply_t_handler
1291 (vl_api_add_node_next_reply_t * mp)
1293 vat_main_t *vam = &vat_main;
1294 i32 retval = ntohl (mp->retval);
1295 if (vam->async_mode)
1297 vam->async_errors += (retval < 0);
1301 vam->retval = retval;
1303 errmsg ("next index %d", ntohl (mp->next_index));
1304 vam->result_ready = 1;
1308 static void vl_api_add_node_next_reply_t_handler_json
1309 (vl_api_add_node_next_reply_t * mp)
1311 vat_main_t *vam = &vat_main;
1312 vat_json_node_t node;
1314 vat_json_init_object (&node);
1315 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1316 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1318 vat_json_print (vam->ofp, &node);
1319 vat_json_free (&node);
1321 vam->retval = ntohl (mp->retval);
1322 vam->result_ready = 1;
1325 static void vl_api_show_version_reply_t_handler
1326 (vl_api_show_version_reply_t * mp)
1328 vat_main_t *vam = &vat_main;
1329 i32 retval = ntohl (mp->retval);
1334 char *p = (char *) &mp->program;
1336 s = vl_api_from_api_to_vec ((vl_api_string_t *) p);
1337 errmsg (" program: %v\n", s);
1341 vl_api_string_len ((vl_api_string_t *) p) + sizeof (vl_api_string_t);
1342 s = vl_api_from_api_to_vec ((vl_api_string_t *) p);
1343 errmsg (" version: %v\n", s);
1347 vl_api_string_len ((vl_api_string_t *) p) + sizeof (vl_api_string_t);
1348 s = vl_api_from_api_to_vec ((vl_api_string_t *) p);
1349 errmsg (" build date: %v\n", s);
1353 vl_api_string_len ((vl_api_string_t *) p) + sizeof (vl_api_string_t);
1354 s = vl_api_from_api_to_vec ((vl_api_string_t *) p);
1357 errmsg ("build directory: %v\n", s);
1359 vam->retval = retval;
1360 vam->result_ready = 1;
1363 static void vl_api_show_version_reply_t_handler_json
1364 (vl_api_show_version_reply_t * mp)
1366 vat_main_t *vam = &vat_main;
1367 vat_json_node_t node;
1369 vat_json_init_object (&node);
1370 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1371 char *p = (char *) &mp->program;
1372 vat_json_object_add_string_copy (&node, "program",
1373 vl_api_from_api_string ((vl_api_string_t *)
1375 p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (u32);
1376 vat_json_object_add_string_copy (&node, "version",
1377 vl_api_from_api_string ((vl_api_string_t *)
1379 p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (u32);
1380 vat_json_object_add_string_copy (&node, "build_date",
1381 vl_api_from_api_string ((vl_api_string_t *)
1383 p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (u32);
1384 vat_json_object_add_string_copy (&node, "build_directory",
1385 vl_api_from_api_string ((vl_api_string_t *)
1388 vat_json_print (vam->ofp, &node);
1389 vat_json_free (&node);
1391 vam->retval = ntohl (mp->retval);
1392 vam->result_ready = 1;
1395 static void vl_api_show_threads_reply_t_handler
1396 (vl_api_show_threads_reply_t * mp)
1398 vat_main_t *vam = &vat_main;
1399 i32 retval = ntohl (mp->retval);
1403 count = ntohl (mp->count);
1405 for (i = 0; i < count; i++)
1407 "\n%-2d %-11s %-11s %-5d %-6d %-4d %-6d",
1408 ntohl (mp->thread_data[i].id), mp->thread_data[i].name,
1409 mp->thread_data[i].type, ntohl (mp->thread_data[i].pid),
1410 ntohl (mp->thread_data[i].cpu_id), ntohl (mp->thread_data[i].core),
1411 ntohl (mp->thread_data[i].cpu_socket));
1413 vam->retval = retval;
1414 vam->result_ready = 1;
1417 static void vl_api_show_threads_reply_t_handler_json
1418 (vl_api_show_threads_reply_t * mp)
1420 vat_main_t *vam = &vat_main;
1421 vat_json_node_t node;
1422 vl_api_thread_data_t *td;
1423 i32 retval = ntohl (mp->retval);
1427 count = ntohl (mp->count);
1429 vat_json_init_object (&node);
1430 vat_json_object_add_int (&node, "retval", retval);
1431 vat_json_object_add_uint (&node, "count", count);
1433 for (i = 0; i < count; i++)
1435 td = &mp->thread_data[i];
1436 vat_json_object_add_uint (&node, "id", ntohl (td->id));
1437 vat_json_object_add_string_copy (&node, "name", td->name);
1438 vat_json_object_add_string_copy (&node, "type", td->type);
1439 vat_json_object_add_uint (&node, "pid", ntohl (td->pid));
1440 vat_json_object_add_int (&node, "cpu_id", ntohl (td->cpu_id));
1441 vat_json_object_add_int (&node, "core", ntohl (td->id));
1442 vat_json_object_add_int (&node, "cpu_socket", ntohl (td->cpu_socket));
1445 vat_json_print (vam->ofp, &node);
1446 vat_json_free (&node);
1448 vam->retval = retval;
1449 vam->result_ready = 1;
1453 api_show_threads (vat_main_t * vam)
1455 vl_api_show_threads_t *mp;
1459 "\n%-2s %-11s %-11s %-5s %-6s %-4s %-6s",
1460 "ID", "Name", "Type", "LWP", "cpu_id", "Core", "Socket");
1462 M (SHOW_THREADS, mp);
1470 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1472 u32 sw_if_index = ntohl (mp->sw_if_index);
1473 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1474 mp->mac_ip ? "mac/ip binding" : "address resolution",
1475 ntohl (mp->pid), format_ip4_address, mp->ip,
1476 format_vl_api_mac_address, &mp->mac, sw_if_index);
1480 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1482 /* JSON output not supported */
1486 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1488 u32 sw_if_index = ntohl (mp->sw_if_index);
1489 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1490 mp->mac_ip ? "mac/ip binding" : "address resolution",
1491 ntohl (mp->pid), format_vl_api_ip6_address, mp->ip,
1492 format_vl_api_mac_address, mp->mac, sw_if_index);
1496 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1498 /* JSON output not supported */
1502 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1504 u32 n_macs = ntohl (mp->n_macs);
1505 errmsg ("L2MAC event received with pid %d cl-idx %d for %d macs: \n",
1506 ntohl (mp->pid), mp->client_index, n_macs);
1508 for (i = 0; i < n_macs; i++)
1510 vl_api_mac_entry_t *mac = &mp->mac[i];
1511 errmsg (" [%d] sw_if_index %d mac_addr %U action %d \n",
1512 i + 1, ntohl (mac->sw_if_index),
1513 format_ethernet_address, mac->mac_addr, mac->action);
1520 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1522 /* JSON output not supported */
1525 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1526 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1529 * Special-case: build the bridge domain table, maintain
1530 * the next bd id vbl.
1532 static void vl_api_bridge_domain_details_t_handler
1533 (vl_api_bridge_domain_details_t * mp)
1535 vat_main_t *vam = &vat_main;
1536 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1539 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-6s %-3s",
1540 " ID", "LRN", "FWD", "FLD", "BVI", "UU-FWD", "#IF");
1542 print (vam->ofp, "%3d %3d %3d %3d %3d %6d %3d",
1543 ntohl (mp->bd_id), mp->learn, mp->forward,
1544 mp->flood, ntohl (mp->bvi_sw_if_index),
1545 ntohl (mp->uu_fwd_sw_if_index), n_sw_ifs);
1549 vl_api_bridge_domain_sw_if_t *sw_ifs;
1550 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1553 sw_ifs = mp->sw_if_details;
1554 for (i = 0; i < n_sw_ifs; i++)
1560 sw_if_index = ntohl (sw_ifs->sw_if_index);
1563 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1565 if ((u32) p->value[0] == sw_if_index)
1567 sw_if_name = (u8 *)(p->key);
1572 print (vam->ofp, "%7d %3d %s", sw_if_index,
1573 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1574 "sw_if_index not found!");
1581 static void vl_api_bridge_domain_details_t_handler_json
1582 (vl_api_bridge_domain_details_t * mp)
1584 vat_main_t *vam = &vat_main;
1585 vat_json_node_t *node, *array = NULL;
1586 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1588 if (VAT_JSON_ARRAY != vam->json_tree.type)
1590 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1591 vat_json_init_array (&vam->json_tree);
1593 node = vat_json_array_add (&vam->json_tree);
1595 vat_json_init_object (node);
1596 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1597 vat_json_object_add_uint (node, "flood", mp->flood);
1598 vat_json_object_add_uint (node, "forward", mp->forward);
1599 vat_json_object_add_uint (node, "learn", mp->learn);
1600 vat_json_object_add_uint (node, "bvi_sw_if_index",
1601 ntohl (mp->bvi_sw_if_index));
1602 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1603 array = vat_json_object_add (node, "sw_if");
1604 vat_json_init_array (array);
1610 vl_api_bridge_domain_sw_if_t *sw_ifs;
1613 sw_ifs = mp->sw_if_details;
1614 for (i = 0; i < n_sw_ifs; i++)
1616 node = vat_json_array_add (array);
1617 vat_json_init_object (node);
1618 vat_json_object_add_uint (node, "sw_if_index",
1619 ntohl (sw_ifs->sw_if_index));
1620 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1626 static void vl_api_control_ping_reply_t_handler
1627 (vl_api_control_ping_reply_t * mp)
1629 vat_main_t *vam = &vat_main;
1630 i32 retval = ntohl (mp->retval);
1631 if (vam->async_mode)
1633 vam->async_errors += (retval < 0);
1637 vam->retval = retval;
1638 vam->result_ready = 1;
1640 if (vam->socket_client_main)
1641 vam->socket_client_main->control_pings_outstanding--;
1644 static void vl_api_control_ping_reply_t_handler_json
1645 (vl_api_control_ping_reply_t * mp)
1647 vat_main_t *vam = &vat_main;
1648 i32 retval = ntohl (mp->retval);
1650 if (VAT_JSON_NONE != vam->json_tree.type)
1652 vat_json_print (vam->ofp, &vam->json_tree);
1653 vat_json_free (&vam->json_tree);
1654 vam->json_tree.type = VAT_JSON_NONE;
1659 vat_json_init_array (&vam->json_tree);
1660 vat_json_print (vam->ofp, &vam->json_tree);
1661 vam->json_tree.type = VAT_JSON_NONE;
1664 vam->retval = retval;
1665 vam->result_ready = 1;
1669 vl_api_bridge_domain_set_mac_age_reply_t_handler
1670 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1672 vat_main_t *vam = &vat_main;
1673 i32 retval = ntohl (mp->retval);
1674 if (vam->async_mode)
1676 vam->async_errors += (retval < 0);
1680 vam->retval = retval;
1681 vam->result_ready = 1;
1685 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1686 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1688 vat_main_t *vam = &vat_main;
1689 vat_json_node_t node;
1691 vat_json_init_object (&node);
1692 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1694 vat_json_print (vam->ofp, &node);
1695 vat_json_free (&node);
1697 vam->retval = ntohl (mp->retval);
1698 vam->result_ready = 1;
1702 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1704 vat_main_t *vam = &vat_main;
1705 i32 retval = ntohl (mp->retval);
1706 if (vam->async_mode)
1708 vam->async_errors += (retval < 0);
1712 vam->retval = retval;
1713 vam->result_ready = 1;
1717 static void vl_api_l2_flags_reply_t_handler_json
1718 (vl_api_l2_flags_reply_t * mp)
1720 vat_main_t *vam = &vat_main;
1721 vat_json_node_t node;
1723 vat_json_init_object (&node);
1724 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1725 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1726 ntohl (mp->resulting_feature_bitmap));
1728 vat_json_print (vam->ofp, &node);
1729 vat_json_free (&node);
1731 vam->retval = ntohl (mp->retval);
1732 vam->result_ready = 1;
1735 static void vl_api_bridge_flags_reply_t_handler
1736 (vl_api_bridge_flags_reply_t * mp)
1738 vat_main_t *vam = &vat_main;
1739 i32 retval = ntohl (mp->retval);
1740 if (vam->async_mode)
1742 vam->async_errors += (retval < 0);
1746 vam->retval = retval;
1747 vam->result_ready = 1;
1751 static void vl_api_bridge_flags_reply_t_handler_json
1752 (vl_api_bridge_flags_reply_t * mp)
1754 vat_main_t *vam = &vat_main;
1755 vat_json_node_t node;
1757 vat_json_init_object (&node);
1758 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1759 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1760 ntohl (mp->resulting_feature_bitmap));
1762 vat_json_print (vam->ofp, &node);
1763 vat_json_free (&node);
1765 vam->retval = ntohl (mp->retval);
1766 vam->result_ready = 1;
1770 vl_api_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_reply_t * mp)
1772 vat_main_t *vam = &vat_main;
1773 i32 retval = ntohl (mp->retval);
1774 if (vam->async_mode)
1776 vam->async_errors += (retval < 0);
1780 vam->retval = retval;
1781 vam->sw_if_index = ntohl (mp->sw_if_index);
1782 vam->result_ready = 1;
1787 static void vl_api_tap_create_v2_reply_t_handler_json
1788 (vl_api_tap_create_v2_reply_t * mp)
1790 vat_main_t *vam = &vat_main;
1791 vat_json_node_t node;
1793 vat_json_init_object (&node);
1794 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1795 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1797 vat_json_print (vam->ofp, &node);
1798 vat_json_free (&node);
1800 vam->retval = ntohl (mp->retval);
1801 vam->result_ready = 1;
1806 vl_api_tap_delete_v2_reply_t_handler (vl_api_tap_delete_v2_reply_t * mp)
1808 vat_main_t *vam = &vat_main;
1809 i32 retval = ntohl (mp->retval);
1810 if (vam->async_mode)
1812 vam->async_errors += (retval < 0);
1816 vam->retval = retval;
1817 vam->result_ready = 1;
1821 static void vl_api_tap_delete_v2_reply_t_handler_json
1822 (vl_api_tap_delete_v2_reply_t * mp)
1824 vat_main_t *vam = &vat_main;
1825 vat_json_node_t node;
1827 vat_json_init_object (&node);
1828 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1830 vat_json_print (vam->ofp, &node);
1831 vat_json_free (&node);
1833 vam->retval = ntohl (mp->retval);
1834 vam->result_ready = 1;
1838 vl_api_virtio_pci_create_reply_t_handler (vl_api_virtio_pci_create_reply_t *
1841 vat_main_t *vam = &vat_main;
1842 i32 retval = ntohl (mp->retval);
1843 if (vam->async_mode)
1845 vam->async_errors += (retval < 0);
1849 vam->retval = retval;
1850 vam->sw_if_index = ntohl (mp->sw_if_index);
1851 vam->result_ready = 1;
1855 static void vl_api_virtio_pci_create_reply_t_handler_json
1856 (vl_api_virtio_pci_create_reply_t * mp)
1858 vat_main_t *vam = &vat_main;
1859 vat_json_node_t node;
1861 vat_json_init_object (&node);
1862 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1863 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1865 vat_json_print (vam->ofp, &node);
1866 vat_json_free (&node);
1868 vam->retval = ntohl (mp->retval);
1869 vam->result_ready = 1;
1874 vl_api_virtio_pci_delete_reply_t_handler (vl_api_virtio_pci_delete_reply_t *
1877 vat_main_t *vam = &vat_main;
1878 i32 retval = ntohl (mp->retval);
1879 if (vam->async_mode)
1881 vam->async_errors += (retval < 0);
1885 vam->retval = retval;
1886 vam->result_ready = 1;
1890 static void vl_api_virtio_pci_delete_reply_t_handler_json
1891 (vl_api_virtio_pci_delete_reply_t * mp)
1893 vat_main_t *vam = &vat_main;
1894 vat_json_node_t node;
1896 vat_json_init_object (&node);
1897 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1899 vat_json_print (vam->ofp, &node);
1900 vat_json_free (&node);
1902 vam->retval = ntohl (mp->retval);
1903 vam->result_ready = 1;
1907 vl_api_bond_create_reply_t_handler (vl_api_bond_create_reply_t * mp)
1909 vat_main_t *vam = &vat_main;
1910 i32 retval = ntohl (mp->retval);
1912 if (vam->async_mode)
1914 vam->async_errors += (retval < 0);
1918 vam->retval = retval;
1919 vam->sw_if_index = ntohl (mp->sw_if_index);
1920 vam->result_ready = 1;
1924 static void vl_api_bond_create_reply_t_handler_json
1925 (vl_api_bond_create_reply_t * mp)
1927 vat_main_t *vam = &vat_main;
1928 vat_json_node_t node;
1930 vat_json_init_object (&node);
1931 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1932 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1934 vat_json_print (vam->ofp, &node);
1935 vat_json_free (&node);
1937 vam->retval = ntohl (mp->retval);
1938 vam->result_ready = 1;
1942 vl_api_bond_delete_reply_t_handler (vl_api_bond_delete_reply_t * mp)
1944 vat_main_t *vam = &vat_main;
1945 i32 retval = ntohl (mp->retval);
1947 if (vam->async_mode)
1949 vam->async_errors += (retval < 0);
1953 vam->retval = retval;
1954 vam->result_ready = 1;
1958 static void vl_api_bond_delete_reply_t_handler_json
1959 (vl_api_bond_delete_reply_t * mp)
1961 vat_main_t *vam = &vat_main;
1962 vat_json_node_t node;
1964 vat_json_init_object (&node);
1965 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1967 vat_json_print (vam->ofp, &node);
1968 vat_json_free (&node);
1970 vam->retval = ntohl (mp->retval);
1971 vam->result_ready = 1;
1975 vl_api_bond_enslave_reply_t_handler (vl_api_bond_enslave_reply_t * mp)
1977 vat_main_t *vam = &vat_main;
1978 i32 retval = ntohl (mp->retval);
1980 if (vam->async_mode)
1982 vam->async_errors += (retval < 0);
1986 vam->retval = retval;
1987 vam->result_ready = 1;
1991 static void vl_api_bond_enslave_reply_t_handler_json
1992 (vl_api_bond_enslave_reply_t * mp)
1994 vat_main_t *vam = &vat_main;
1995 vat_json_node_t node;
1997 vat_json_init_object (&node);
1998 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2000 vat_json_print (vam->ofp, &node);
2001 vat_json_free (&node);
2003 vam->retval = ntohl (mp->retval);
2004 vam->result_ready = 1;
2008 vl_api_bond_detach_slave_reply_t_handler (vl_api_bond_detach_slave_reply_t *
2011 vat_main_t *vam = &vat_main;
2012 i32 retval = ntohl (mp->retval);
2014 if (vam->async_mode)
2016 vam->async_errors += (retval < 0);
2020 vam->retval = retval;
2021 vam->result_ready = 1;
2025 static void vl_api_bond_detach_slave_reply_t_handler_json
2026 (vl_api_bond_detach_slave_reply_t * mp)
2028 vat_main_t *vam = &vat_main;
2029 vat_json_node_t node;
2031 vat_json_init_object (&node);
2032 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2034 vat_json_print (vam->ofp, &node);
2035 vat_json_free (&node);
2037 vam->retval = ntohl (mp->retval);
2038 vam->result_ready = 1;
2041 static void vl_api_sw_interface_bond_details_t_handler
2042 (vl_api_sw_interface_bond_details_t * mp)
2044 vat_main_t *vam = &vat_main;
2047 "%-16s %-12d %-12U %-13U %-14u %-14u",
2048 mp->interface_name, ntohl (mp->sw_if_index),
2049 format_bond_mode, mp->mode, format_bond_load_balance, mp->lb,
2050 ntohl (mp->active_slaves), ntohl (mp->slaves));
2053 static void vl_api_sw_interface_bond_details_t_handler_json
2054 (vl_api_sw_interface_bond_details_t * mp)
2056 vat_main_t *vam = &vat_main;
2057 vat_json_node_t *node = NULL;
2059 if (VAT_JSON_ARRAY != vam->json_tree.type)
2061 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2062 vat_json_init_array (&vam->json_tree);
2064 node = vat_json_array_add (&vam->json_tree);
2066 vat_json_init_object (node);
2067 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2068 vat_json_object_add_string_copy (node, "interface_name",
2069 mp->interface_name);
2070 vat_json_object_add_uint (node, "mode", mp->mode);
2071 vat_json_object_add_uint (node, "load_balance", mp->lb);
2072 vat_json_object_add_uint (node, "active_slaves", ntohl (mp->active_slaves));
2073 vat_json_object_add_uint (node, "slaves", ntohl (mp->slaves));
2077 api_sw_interface_bond_dump (vat_main_t * vam)
2079 vl_api_sw_interface_bond_dump_t *mp;
2080 vl_api_control_ping_t *mp_ping;
2084 "\n%-16s %-12s %-12s %-13s %-14s %-14s",
2085 "interface name", "sw_if_index", "mode", "load balance",
2086 "active slaves", "slaves");
2088 /* Get list of bond interfaces */
2089 M (SW_INTERFACE_BOND_DUMP, mp);
2092 /* Use a control ping for synchronization */
2093 MPING (CONTROL_PING, mp_ping);
2100 static void vl_api_sw_interface_slave_details_t_handler
2101 (vl_api_sw_interface_slave_details_t * mp)
2103 vat_main_t *vam = &vat_main;
2106 "%-25s %-12d %-12d %d", mp->interface_name,
2107 ntohl (mp->sw_if_index), mp->is_passive, mp->is_long_timeout);
2110 static void vl_api_sw_interface_slave_details_t_handler_json
2111 (vl_api_sw_interface_slave_details_t * mp)
2113 vat_main_t *vam = &vat_main;
2114 vat_json_node_t *node = NULL;
2116 if (VAT_JSON_ARRAY != vam->json_tree.type)
2118 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2119 vat_json_init_array (&vam->json_tree);
2121 node = vat_json_array_add (&vam->json_tree);
2123 vat_json_init_object (node);
2124 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2125 vat_json_object_add_string_copy (node, "interface_name",
2126 mp->interface_name);
2127 vat_json_object_add_uint (node, "passive", mp->is_passive);
2128 vat_json_object_add_uint (node, "long_timeout", mp->is_long_timeout);
2132 api_sw_interface_slave_dump (vat_main_t * vam)
2134 unformat_input_t *i = vam->input;
2135 vl_api_sw_interface_slave_dump_t *mp;
2136 vl_api_control_ping_t *mp_ping;
2137 u32 sw_if_index = ~0;
2138 u8 sw_if_index_set = 0;
2141 /* Parse args required to build the message */
2142 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2144 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2145 sw_if_index_set = 1;
2146 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2147 sw_if_index_set = 1;
2152 if (sw_if_index_set == 0)
2154 errmsg ("missing vpp interface name. ");
2159 "\n%-25s %-12s %-12s %s",
2160 "slave interface name", "sw_if_index", "passive", "long_timeout");
2162 /* Get list of bond interfaces */
2163 M (SW_INTERFACE_SLAVE_DUMP, mp);
2164 mp->sw_if_index = ntohl (sw_if_index);
2167 /* Use a control ping for synchronization */
2168 MPING (CONTROL_PING, mp_ping);
2175 static void vl_api_mpls_tunnel_add_del_reply_t_handler
2176 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2178 vat_main_t *vam = &vat_main;
2179 i32 retval = ntohl (mp->retval);
2180 if (vam->async_mode)
2182 vam->async_errors += (retval < 0);
2186 vam->retval = retval;
2187 vam->sw_if_index = ntohl (mp->sw_if_index);
2188 vam->result_ready = 1;
2190 vam->regenerate_interface_table = 1;
2193 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
2194 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2196 vat_main_t *vam = &vat_main;
2197 vat_json_node_t node;
2199 vat_json_init_object (&node);
2200 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2201 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
2202 ntohl (mp->sw_if_index));
2204 vat_json_print (vam->ofp, &node);
2205 vat_json_free (&node);
2207 vam->retval = ntohl (mp->retval);
2208 vam->result_ready = 1;
2211 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
2212 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2214 vat_main_t *vam = &vat_main;
2215 i32 retval = ntohl (mp->retval);
2216 if (vam->async_mode)
2218 vam->async_errors += (retval < 0);
2222 vam->retval = retval;
2223 vam->sw_if_index = ntohl (mp->sw_if_index);
2224 vam->result_ready = 1;
2228 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
2229 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2231 vat_main_t *vam = &vat_main;
2232 vat_json_node_t node;
2234 vat_json_init_object (&node);
2235 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2236 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2238 vat_json_print (vam->ofp, &node);
2239 vat_json_free (&node);
2241 vam->retval = ntohl (mp->retval);
2242 vam->result_ready = 1;
2245 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
2246 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2248 vat_main_t *vam = &vat_main;
2249 i32 retval = ntohl (mp->retval);
2250 if (vam->async_mode)
2252 vam->async_errors += (retval < 0);
2256 vam->retval = retval;
2257 vam->result_ready = 1;
2261 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
2262 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2264 vat_main_t *vam = &vat_main;
2265 vat_json_node_t node;
2267 vat_json_init_object (&node);
2268 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2269 vat_json_object_add_uint (&node, "fwd_entry_index",
2270 clib_net_to_host_u32 (mp->fwd_entry_index));
2272 vat_json_print (vam->ofp, &node);
2273 vat_json_free (&node);
2275 vam->retval = ntohl (mp->retval);
2276 vam->result_ready = 1;
2280 format_lisp_transport_protocol (u8 * s, va_list * args)
2282 u32 proto = va_arg (*args, u32);
2287 return format (s, "udp");
2289 return format (s, "api");
2296 static void vl_api_one_get_transport_protocol_reply_t_handler
2297 (vl_api_one_get_transport_protocol_reply_t * mp)
2299 vat_main_t *vam = &vat_main;
2300 i32 retval = ntohl (mp->retval);
2301 if (vam->async_mode)
2303 vam->async_errors += (retval < 0);
2307 u32 proto = mp->protocol;
2308 print (vam->ofp, "Transport protocol: %U",
2309 format_lisp_transport_protocol, proto);
2310 vam->retval = retval;
2311 vam->result_ready = 1;
2315 static void vl_api_one_get_transport_protocol_reply_t_handler_json
2316 (vl_api_one_get_transport_protocol_reply_t * mp)
2318 vat_main_t *vam = &vat_main;
2319 vat_json_node_t node;
2322 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
2325 vat_json_init_object (&node);
2326 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2327 vat_json_object_add_string_copy (&node, "transport-protocol", s);
2330 vat_json_print (vam->ofp, &node);
2331 vat_json_free (&node);
2333 vam->retval = ntohl (mp->retval);
2334 vam->result_ready = 1;
2337 static void vl_api_one_add_del_locator_set_reply_t_handler
2338 (vl_api_one_add_del_locator_set_reply_t * mp)
2340 vat_main_t *vam = &vat_main;
2341 i32 retval = ntohl (mp->retval);
2342 if (vam->async_mode)
2344 vam->async_errors += (retval < 0);
2348 vam->retval = retval;
2349 vam->result_ready = 1;
2353 static void vl_api_one_add_del_locator_set_reply_t_handler_json
2354 (vl_api_one_add_del_locator_set_reply_t * mp)
2356 vat_main_t *vam = &vat_main;
2357 vat_json_node_t node;
2359 vat_json_init_object (&node);
2360 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2361 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
2363 vat_json_print (vam->ofp, &node);
2364 vat_json_free (&node);
2366 vam->retval = ntohl (mp->retval);
2367 vam->result_ready = 1;
2370 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
2371 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2373 vat_main_t *vam = &vat_main;
2374 i32 retval = ntohl (mp->retval);
2375 if (vam->async_mode)
2377 vam->async_errors += (retval < 0);
2381 vam->retval = retval;
2382 vam->sw_if_index = ntohl (mp->sw_if_index);
2383 vam->result_ready = 1;
2385 vam->regenerate_interface_table = 1;
2388 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
2389 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2391 vat_main_t *vam = &vat_main;
2392 vat_json_node_t node;
2394 vat_json_init_object (&node);
2395 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2396 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2398 vat_json_print (vam->ofp, &node);
2399 vat_json_free (&node);
2401 vam->retval = ntohl (mp->retval);
2402 vam->result_ready = 1;
2405 static void vl_api_vxlan_offload_rx_reply_t_handler
2406 (vl_api_vxlan_offload_rx_reply_t * mp)
2408 vat_main_t *vam = &vat_main;
2409 i32 retval = ntohl (mp->retval);
2410 if (vam->async_mode)
2412 vam->async_errors += (retval < 0);
2416 vam->retval = retval;
2417 vam->result_ready = 1;
2421 static void vl_api_vxlan_offload_rx_reply_t_handler_json
2422 (vl_api_vxlan_offload_rx_reply_t * mp)
2424 vat_main_t *vam = &vat_main;
2425 vat_json_node_t node;
2427 vat_json_init_object (&node);
2428 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2430 vat_json_print (vam->ofp, &node);
2431 vat_json_free (&node);
2433 vam->retval = ntohl (mp->retval);
2434 vam->result_ready = 1;
2437 static void vl_api_geneve_add_del_tunnel_reply_t_handler
2438 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2440 vat_main_t *vam = &vat_main;
2441 i32 retval = ntohl (mp->retval);
2442 if (vam->async_mode)
2444 vam->async_errors += (retval < 0);
2448 vam->retval = retval;
2449 vam->sw_if_index = ntohl (mp->sw_if_index);
2450 vam->result_ready = 1;
2454 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
2455 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2457 vat_main_t *vam = &vat_main;
2458 vat_json_node_t node;
2460 vat_json_init_object (&node);
2461 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2462 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2464 vat_json_print (vam->ofp, &node);
2465 vat_json_free (&node);
2467 vam->retval = ntohl (mp->retval);
2468 vam->result_ready = 1;
2471 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
2472 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2474 vat_main_t *vam = &vat_main;
2475 i32 retval = ntohl (mp->retval);
2476 if (vam->async_mode)
2478 vam->async_errors += (retval < 0);
2482 vam->retval = retval;
2483 vam->sw_if_index = ntohl (mp->sw_if_index);
2484 vam->result_ready = 1;
2486 vam->regenerate_interface_table = 1;
2489 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
2490 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2492 vat_main_t *vam = &vat_main;
2493 vat_json_node_t node;
2495 vat_json_init_object (&node);
2496 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2497 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2499 vat_json_print (vam->ofp, &node);
2500 vat_json_free (&node);
2502 vam->retval = ntohl (mp->retval);
2503 vam->result_ready = 1;
2506 static void vl_api_gre_tunnel_add_del_reply_t_handler
2507 (vl_api_gre_tunnel_add_del_reply_t * mp)
2509 vat_main_t *vam = &vat_main;
2510 i32 retval = ntohl (mp->retval);
2511 if (vam->async_mode)
2513 vam->async_errors += (retval < 0);
2517 vam->retval = retval;
2518 vam->sw_if_index = ntohl (mp->sw_if_index);
2519 vam->result_ready = 1;
2523 static void vl_api_gre_tunnel_add_del_reply_t_handler_json
2524 (vl_api_gre_tunnel_add_del_reply_t * mp)
2526 vat_main_t *vam = &vat_main;
2527 vat_json_node_t node;
2529 vat_json_init_object (&node);
2530 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2531 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2533 vat_json_print (vam->ofp, &node);
2534 vat_json_free (&node);
2536 vam->retval = ntohl (mp->retval);
2537 vam->result_ready = 1;
2540 static void vl_api_create_vhost_user_if_reply_t_handler
2541 (vl_api_create_vhost_user_if_reply_t * mp)
2543 vat_main_t *vam = &vat_main;
2544 i32 retval = ntohl (mp->retval);
2545 if (vam->async_mode)
2547 vam->async_errors += (retval < 0);
2551 vam->retval = retval;
2552 vam->sw_if_index = ntohl (mp->sw_if_index);
2553 vam->result_ready = 1;
2555 vam->regenerate_interface_table = 1;
2558 static void vl_api_create_vhost_user_if_reply_t_handler_json
2559 (vl_api_create_vhost_user_if_reply_t * mp)
2561 vat_main_t *vam = &vat_main;
2562 vat_json_node_t node;
2564 vat_json_init_object (&node);
2565 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2566 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2568 vat_json_print (vam->ofp, &node);
2569 vat_json_free (&node);
2571 vam->retval = ntohl (mp->retval);
2572 vam->result_ready = 1;
2575 static void vl_api_dns_resolve_name_reply_t_handler
2576 (vl_api_dns_resolve_name_reply_t * mp)
2578 vat_main_t *vam = &vat_main;
2579 i32 retval = ntohl (mp->retval);
2580 if (vam->async_mode)
2582 vam->async_errors += (retval < 0);
2586 vam->retval = retval;
2587 vam->result_ready = 1;
2592 clib_warning ("ip4 address %U", format_ip4_address,
2593 (ip4_address_t *) mp->ip4_address);
2595 clib_warning ("ip6 address %U", format_ip6_address,
2596 (ip6_address_t *) mp->ip6_address);
2599 clib_warning ("retval %d", retval);
2603 static void vl_api_dns_resolve_name_reply_t_handler_json
2604 (vl_api_dns_resolve_name_reply_t * mp)
2606 clib_warning ("not implemented");
2609 static void vl_api_dns_resolve_ip_reply_t_handler
2610 (vl_api_dns_resolve_ip_reply_t * mp)
2612 vat_main_t *vam = &vat_main;
2613 i32 retval = ntohl (mp->retval);
2614 if (vam->async_mode)
2616 vam->async_errors += (retval < 0);
2620 vam->retval = retval;
2621 vam->result_ready = 1;
2625 clib_warning ("canonical name %s", mp->name);
2628 clib_warning ("retval %d", retval);
2632 static void vl_api_dns_resolve_ip_reply_t_handler_json
2633 (vl_api_dns_resolve_ip_reply_t * mp)
2635 clib_warning ("not implemented");
2639 static void vl_api_ip_address_details_t_handler
2640 (vl_api_ip_address_details_t * mp)
2642 vat_main_t *vam = &vat_main;
2643 static ip_address_details_t empty_ip_address_details = { {0} };
2644 ip_address_details_t *address = NULL;
2645 ip_details_t *current_ip_details = NULL;
2646 ip_details_t *details = NULL;
2648 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2650 if (!details || vam->current_sw_if_index >= vec_len (details)
2651 || !details[vam->current_sw_if_index].present)
2653 errmsg ("ip address details arrived but not stored");
2654 errmsg ("ip_dump should be called first");
2658 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2660 #define addresses (current_ip_details->addr)
2662 vec_validate_init_empty (addresses, vec_len (addresses),
2663 empty_ip_address_details);
2665 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2667 clib_memcpy (&address->ip, &mp->prefix.address.un, sizeof (address->ip));
2668 address->prefix_length = mp->prefix.address_length;
2672 static void vl_api_ip_address_details_t_handler_json
2673 (vl_api_ip_address_details_t * mp)
2675 vat_main_t *vam = &vat_main;
2676 vat_json_node_t *node = NULL;
2678 if (VAT_JSON_ARRAY != vam->json_tree.type)
2680 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2681 vat_json_init_array (&vam->json_tree);
2683 node = vat_json_array_add (&vam->json_tree);
2685 vat_json_init_object (node);
2686 vat_json_object_add_prefix (node, &mp->prefix);
2690 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2692 vat_main_t *vam = &vat_main;
2693 static ip_details_t empty_ip_details = { 0 };
2694 ip_details_t *ip = NULL;
2695 u32 sw_if_index = ~0;
2697 sw_if_index = ntohl (mp->sw_if_index);
2699 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2700 sw_if_index, empty_ip_details);
2702 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2709 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2711 vat_main_t *vam = &vat_main;
2713 if (VAT_JSON_ARRAY != vam->json_tree.type)
2715 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2716 vat_json_init_array (&vam->json_tree);
2718 vat_json_array_add_uint (&vam->json_tree,
2719 clib_net_to_host_u32 (mp->sw_if_index));
2723 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2727 s = format (0, "DHCP compl event: pid %d %s hostname %s host_addr %U "
2728 "host_mac %U router_addr %U",
2729 ntohl (mp->pid), mp->lease.is_ipv6 ? "ipv6" : "ipv4",
2731 format_ip4_address, mp->lease.host_address,
2732 format_ethernet_address, mp->lease.host_mac,
2733 format_ip4_address, mp->lease.router_address);
2735 for (i = 0; i < mp->lease.count; i++)
2737 format (s, " domain_server_addr %U", format_ip4_address,
2738 mp->lease.domain_server[i].address);
2740 errmsg ((char *) s);
2744 static void vl_api_dhcp_compl_event_t_handler_json
2745 (vl_api_dhcp_compl_event_t * mp)
2747 /* JSON output not supported */
2750 static void vl_api_get_first_msg_id_reply_t_handler
2751 (vl_api_get_first_msg_id_reply_t * mp)
2753 vat_main_t *vam = &vat_main;
2754 i32 retval = ntohl (mp->retval);
2756 if (vam->async_mode)
2758 vam->async_errors += (retval < 0);
2762 vam->retval = retval;
2763 vam->result_ready = 1;
2767 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2771 static void vl_api_get_first_msg_id_reply_t_handler_json
2772 (vl_api_get_first_msg_id_reply_t * mp)
2774 vat_main_t *vam = &vat_main;
2775 vat_json_node_t node;
2777 vat_json_init_object (&node);
2778 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2779 vat_json_object_add_uint (&node, "first_msg_id",
2780 (uint) ntohs (mp->first_msg_id));
2782 vat_json_print (vam->ofp, &node);
2783 vat_json_free (&node);
2785 vam->retval = ntohl (mp->retval);
2786 vam->result_ready = 1;
2789 static void vl_api_get_node_graph_reply_t_handler
2790 (vl_api_get_node_graph_reply_t * mp)
2792 vat_main_t *vam = &vat_main;
2793 api_main_t *am = &api_main;
2794 i32 retval = ntohl (mp->retval);
2795 u8 *pvt_copy, *reply;
2800 if (vam->async_mode)
2802 vam->async_errors += (retval < 0);
2806 vam->retval = retval;
2807 vam->result_ready = 1;
2810 /* "Should never happen..." */
2814 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2815 pvt_copy = vec_dup (reply);
2817 /* Toss the shared-memory original... */
2818 pthread_mutex_lock (&am->vlib_rp->mutex);
2819 oldheap = svm_push_data_heap (am->vlib_rp);
2823 svm_pop_heap (oldheap);
2824 pthread_mutex_unlock (&am->vlib_rp->mutex);
2826 if (vam->graph_nodes)
2828 hash_free (vam->graph_node_index_by_name);
2830 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2832 node = vam->graph_nodes[0][i];
2833 vec_free (node->name);
2834 vec_free (node->next_nodes);
2837 vec_free (vam->graph_nodes[0]);
2838 vec_free (vam->graph_nodes);
2841 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2842 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2843 vec_free (pvt_copy);
2845 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2847 node = vam->graph_nodes[0][i];
2848 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2852 static void vl_api_get_node_graph_reply_t_handler_json
2853 (vl_api_get_node_graph_reply_t * mp)
2855 vat_main_t *vam = &vat_main;
2856 api_main_t *am = &api_main;
2858 vat_json_node_t node;
2861 /* $$$$ make this real? */
2862 vat_json_init_object (&node);
2863 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2864 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2866 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2868 /* Toss the shared-memory original... */
2869 pthread_mutex_lock (&am->vlib_rp->mutex);
2870 oldheap = svm_push_data_heap (am->vlib_rp);
2874 svm_pop_heap (oldheap);
2875 pthread_mutex_unlock (&am->vlib_rp->mutex);
2877 vat_json_print (vam->ofp, &node);
2878 vat_json_free (&node);
2880 vam->retval = ntohl (mp->retval);
2881 vam->result_ready = 1;
2885 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2887 vat_main_t *vam = &vat_main;
2892 s = format (s, "%=16d%=16d%=16d",
2893 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2897 s = format (s, "%=16U%=16d%=16d",
2898 mp->is_ipv6 ? format_ip6_address :
2900 mp->ip_address, mp->priority, mp->weight);
2903 print (vam->ofp, "%v", s);
2908 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2910 vat_main_t *vam = &vat_main;
2911 vat_json_node_t *node = NULL;
2912 struct in6_addr ip6;
2915 if (VAT_JSON_ARRAY != vam->json_tree.type)
2917 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2918 vat_json_init_array (&vam->json_tree);
2920 node = vat_json_array_add (&vam->json_tree);
2921 vat_json_init_object (node);
2923 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2924 vat_json_object_add_uint (node, "priority", mp->priority);
2925 vat_json_object_add_uint (node, "weight", mp->weight);
2928 vat_json_object_add_uint (node, "sw_if_index",
2929 clib_net_to_host_u32 (mp->sw_if_index));
2934 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2935 vat_json_object_add_ip6 (node, "address", ip6);
2939 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2940 vat_json_object_add_ip4 (node, "address", ip4);
2946 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2949 vat_main_t *vam = &vat_main;
2952 ls_name = format (0, "%s", mp->ls_name);
2954 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2960 vl_api_one_locator_set_details_t_handler_json
2961 (vl_api_one_locator_set_details_t * mp)
2963 vat_main_t *vam = &vat_main;
2964 vat_json_node_t *node = 0;
2967 ls_name = format (0, "%s", mp->ls_name);
2968 vec_add1 (ls_name, 0);
2970 if (VAT_JSON_ARRAY != vam->json_tree.type)
2972 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2973 vat_json_init_array (&vam->json_tree);
2975 node = vat_json_array_add (&vam->json_tree);
2977 vat_json_init_object (node);
2978 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2979 vat_json_object_add_uint (node, "ls_index",
2980 clib_net_to_host_u32 (mp->ls_index));
2988 } __attribute__ ((__packed__)) lisp_nsh_api_t;
2991 unformat_nsh_address (unformat_input_t * input, va_list * args)
2993 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
2994 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
2998 format_nsh_address_vat (u8 * s, va_list * args)
3000 nsh_t *a = va_arg (*args, nsh_t *);
3001 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
3005 format_lisp_flat_eid (u8 * s, va_list * args)
3007 u32 type = va_arg (*args, u32);
3008 u8 *eid = va_arg (*args, u8 *);
3009 u32 eid_len = va_arg (*args, u32);
3014 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
3016 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
3018 return format (s, "%U", format_ethernet_address, eid);
3020 return format (s, "%U", format_nsh_address_vat, eid);
3026 format_lisp_eid_vat (u8 * s, va_list * args)
3028 u32 type = va_arg (*args, u32);
3029 u8 *eid = va_arg (*args, u8 *);
3030 u32 eid_len = va_arg (*args, u32);
3031 u8 *seid = va_arg (*args, u8 *);
3032 u32 seid_len = va_arg (*args, u32);
3033 u32 is_src_dst = va_arg (*args, u32);
3036 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
3038 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
3044 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
3046 vat_main_t *vam = &vat_main;
3047 u8 *s = 0, *eid = 0;
3049 if (~0 == mp->locator_set_index)
3050 s = format (0, "action: %d", mp->action);
3052 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3054 eid = format (0, "%U", format_lisp_eid_vat,
3058 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3061 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3062 clib_net_to_host_u32 (mp->vni),
3064 mp->is_local ? "local" : "remote",
3065 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3066 clib_net_to_host_u16 (mp->key_id), mp->key);
3073 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3076 vat_main_t *vam = &vat_main;
3077 vat_json_node_t *node = 0;
3080 if (VAT_JSON_ARRAY != vam->json_tree.type)
3082 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3083 vat_json_init_array (&vam->json_tree);
3085 node = vat_json_array_add (&vam->json_tree);
3087 vat_json_init_object (node);
3088 if (~0 == mp->locator_set_index)
3089 vat_json_object_add_uint (node, "action", mp->action);
3091 vat_json_object_add_uint (node, "locator_set_index",
3092 clib_net_to_host_u32 (mp->locator_set_index));
3094 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3095 if (mp->eid_type == 3)
3097 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3098 vat_json_init_object (nsh_json);
3099 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3100 vat_json_object_add_uint (nsh_json, "spi",
3101 clib_net_to_host_u32 (nsh->spi));
3102 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3106 eid = format (0, "%U", format_lisp_eid_vat,
3110 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3112 vat_json_object_add_string_copy (node, "eid", eid);
3115 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3116 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3117 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3121 vat_json_object_add_uint (node, "key_id",
3122 clib_net_to_host_u16 (mp->key_id));
3123 vat_json_object_add_string_copy (node, "key", mp->key);
3128 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3130 vat_main_t *vam = &vat_main;
3131 u8 *seid = 0, *deid = 0;
3132 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3134 deid = format (0, "%U", format_lisp_eid_vat,
3135 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3137 seid = format (0, "%U", format_lisp_eid_vat,
3138 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3144 format_ip_address_fcn = format_ip4_address;
3146 format_ip_address_fcn = format_ip6_address;
3149 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3150 clib_net_to_host_u32 (mp->vni),
3152 format_ip_address_fcn, mp->lloc,
3153 format_ip_address_fcn, mp->rloc,
3154 clib_net_to_host_u32 (mp->pkt_count),
3155 clib_net_to_host_u32 (mp->bytes));
3162 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3164 struct in6_addr ip6;
3166 vat_main_t *vam = &vat_main;
3167 vat_json_node_t *node = 0;
3168 u8 *deid = 0, *seid = 0;
3170 if (VAT_JSON_ARRAY != vam->json_tree.type)
3172 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3173 vat_json_init_array (&vam->json_tree);
3175 node = vat_json_array_add (&vam->json_tree);
3177 vat_json_init_object (node);
3178 deid = format (0, "%U", format_lisp_eid_vat,
3179 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3181 seid = format (0, "%U", format_lisp_eid_vat,
3182 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3187 vat_json_object_add_string_copy (node, "seid", seid);
3188 vat_json_object_add_string_copy (node, "deid", deid);
3189 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3193 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3194 vat_json_object_add_ip4 (node, "lloc", ip4);
3195 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3196 vat_json_object_add_ip4 (node, "rloc", ip4);
3200 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3201 vat_json_object_add_ip6 (node, "lloc", ip6);
3202 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3203 vat_json_object_add_ip6 (node, "rloc", ip6);
3205 vat_json_object_add_uint (node, "pkt_count",
3206 clib_net_to_host_u32 (mp->pkt_count));
3207 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3214 vl_api_one_eid_table_map_details_t_handler
3215 (vl_api_one_eid_table_map_details_t * mp)
3217 vat_main_t *vam = &vat_main;
3219 u8 *line = format (0, "%=10d%=10d",
3220 clib_net_to_host_u32 (mp->vni),
3221 clib_net_to_host_u32 (mp->dp_table));
3222 print (vam->ofp, "%v", line);
3227 vl_api_one_eid_table_map_details_t_handler_json
3228 (vl_api_one_eid_table_map_details_t * mp)
3230 vat_main_t *vam = &vat_main;
3231 vat_json_node_t *node = NULL;
3233 if (VAT_JSON_ARRAY != vam->json_tree.type)
3235 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3236 vat_json_init_array (&vam->json_tree);
3238 node = vat_json_array_add (&vam->json_tree);
3239 vat_json_init_object (node);
3240 vat_json_object_add_uint (node, "dp_table",
3241 clib_net_to_host_u32 (mp->dp_table));
3242 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3246 vl_api_one_eid_table_vni_details_t_handler
3247 (vl_api_one_eid_table_vni_details_t * mp)
3249 vat_main_t *vam = &vat_main;
3251 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3252 print (vam->ofp, "%v", line);
3257 vl_api_one_eid_table_vni_details_t_handler_json
3258 (vl_api_one_eid_table_vni_details_t * mp)
3260 vat_main_t *vam = &vat_main;
3261 vat_json_node_t *node = NULL;
3263 if (VAT_JSON_ARRAY != vam->json_tree.type)
3265 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3266 vat_json_init_array (&vam->json_tree);
3268 node = vat_json_array_add (&vam->json_tree);
3269 vat_json_init_object (node);
3270 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3274 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3275 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3277 vat_main_t *vam = &vat_main;
3278 int retval = clib_net_to_host_u32 (mp->retval);
3280 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3281 print (vam->ofp, "fallback threshold value: %d", mp->value);
3283 vam->retval = retval;
3284 vam->result_ready = 1;
3288 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3289 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3291 vat_main_t *vam = &vat_main;
3292 vat_json_node_t _node, *node = &_node;
3293 int retval = clib_net_to_host_u32 (mp->retval);
3295 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3296 vat_json_init_object (node);
3297 vat_json_object_add_uint (node, "value", mp->value);
3299 vat_json_print (vam->ofp, node);
3300 vat_json_free (node);
3302 vam->retval = retval;
3303 vam->result_ready = 1;
3307 vl_api_show_one_map_register_state_reply_t_handler
3308 (vl_api_show_one_map_register_state_reply_t * mp)
3310 vat_main_t *vam = &vat_main;
3311 int retval = clib_net_to_host_u32 (mp->retval);
3313 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3315 vam->retval = retval;
3316 vam->result_ready = 1;
3320 vl_api_show_one_map_register_state_reply_t_handler_json
3321 (vl_api_show_one_map_register_state_reply_t * mp)
3323 vat_main_t *vam = &vat_main;
3324 vat_json_node_t _node, *node = &_node;
3325 int retval = clib_net_to_host_u32 (mp->retval);
3327 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3329 vat_json_init_object (node);
3330 vat_json_object_add_string_copy (node, "state", s);
3332 vat_json_print (vam->ofp, node);
3333 vat_json_free (node);
3335 vam->retval = retval;
3336 vam->result_ready = 1;
3341 vl_api_show_one_rloc_probe_state_reply_t_handler
3342 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3344 vat_main_t *vam = &vat_main;
3345 int retval = clib_net_to_host_u32 (mp->retval);
3350 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3352 vam->retval = retval;
3353 vam->result_ready = 1;
3357 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3358 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3360 vat_main_t *vam = &vat_main;
3361 vat_json_node_t _node, *node = &_node;
3362 int retval = clib_net_to_host_u32 (mp->retval);
3364 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3365 vat_json_init_object (node);
3366 vat_json_object_add_string_copy (node, "state", s);
3368 vat_json_print (vam->ofp, node);
3369 vat_json_free (node);
3371 vam->retval = retval;
3372 vam->result_ready = 1;
3377 vl_api_show_one_stats_enable_disable_reply_t_handler
3378 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3380 vat_main_t *vam = &vat_main;
3381 int retval = clib_net_to_host_u32 (mp->retval);
3386 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3388 vam->retval = retval;
3389 vam->result_ready = 1;
3393 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3394 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3396 vat_main_t *vam = &vat_main;
3397 vat_json_node_t _node, *node = &_node;
3398 int retval = clib_net_to_host_u32 (mp->retval);
3400 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3401 vat_json_init_object (node);
3402 vat_json_object_add_string_copy (node, "state", s);
3404 vat_json_print (vam->ofp, node);
3405 vat_json_free (node);
3407 vam->retval = retval;
3408 vam->result_ready = 1;
3413 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3415 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3416 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3417 e->vni = clib_net_to_host_u32 (e->vni);
3421 gpe_fwd_entries_get_reply_t_net_to_host
3422 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3426 mp->count = clib_net_to_host_u32 (mp->count);
3427 for (i = 0; i < mp->count; i++)
3429 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3434 format_gpe_encap_mode (u8 * s, va_list * args)
3436 u32 mode = va_arg (*args, u32);
3441 return format (s, "lisp");
3443 return format (s, "vxlan");
3449 vl_api_gpe_get_encap_mode_reply_t_handler
3450 (vl_api_gpe_get_encap_mode_reply_t * mp)
3452 vat_main_t *vam = &vat_main;
3454 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3455 vam->retval = ntohl (mp->retval);
3456 vam->result_ready = 1;
3460 vl_api_gpe_get_encap_mode_reply_t_handler_json
3461 (vl_api_gpe_get_encap_mode_reply_t * mp)
3463 vat_main_t *vam = &vat_main;
3464 vat_json_node_t node;
3466 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3467 vec_add1 (encap_mode, 0);
3469 vat_json_init_object (&node);
3470 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3472 vec_free (encap_mode);
3473 vat_json_print (vam->ofp, &node);
3474 vat_json_free (&node);
3476 vam->retval = ntohl (mp->retval);
3477 vam->result_ready = 1;
3481 vl_api_gpe_fwd_entry_path_details_t_handler
3482 (vl_api_gpe_fwd_entry_path_details_t * mp)
3484 vat_main_t *vam = &vat_main;
3485 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3487 if (mp->lcl_loc.is_ip4)
3488 format_ip_address_fcn = format_ip4_address;
3490 format_ip_address_fcn = format_ip6_address;
3492 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3493 format_ip_address_fcn, &mp->lcl_loc,
3494 format_ip_address_fcn, &mp->rmt_loc);
3498 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3500 struct in6_addr ip6;
3505 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3506 vat_json_object_add_ip4 (n, "address", ip4);
3510 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3511 vat_json_object_add_ip6 (n, "address", ip6);
3513 vat_json_object_add_uint (n, "weight", loc->weight);
3517 vl_api_gpe_fwd_entry_path_details_t_handler_json
3518 (vl_api_gpe_fwd_entry_path_details_t * mp)
3520 vat_main_t *vam = &vat_main;
3521 vat_json_node_t *node = NULL;
3522 vat_json_node_t *loc_node;
3524 if (VAT_JSON_ARRAY != vam->json_tree.type)
3526 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3527 vat_json_init_array (&vam->json_tree);
3529 node = vat_json_array_add (&vam->json_tree);
3530 vat_json_init_object (node);
3532 loc_node = vat_json_object_add (node, "local_locator");
3533 vat_json_init_object (loc_node);
3534 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3536 loc_node = vat_json_object_add (node, "remote_locator");
3537 vat_json_init_object (loc_node);
3538 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3542 vl_api_gpe_fwd_entries_get_reply_t_handler
3543 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3545 vat_main_t *vam = &vat_main;
3547 int retval = clib_net_to_host_u32 (mp->retval);
3548 vl_api_gpe_fwd_entry_t *e;
3553 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3555 for (i = 0; i < mp->count; i++)
3557 e = &mp->entries[i];
3558 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3559 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3560 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3564 vam->retval = retval;
3565 vam->result_ready = 1;
3569 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3570 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3573 vat_main_t *vam = &vat_main;
3574 vat_json_node_t *e = 0, root;
3576 int retval = clib_net_to_host_u32 (mp->retval);
3577 vl_api_gpe_fwd_entry_t *fwd;
3582 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3583 vat_json_init_array (&root);
3585 for (i = 0; i < mp->count; i++)
3587 e = vat_json_array_add (&root);
3588 fwd = &mp->entries[i];
3590 vat_json_init_object (e);
3591 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3592 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3593 vat_json_object_add_int (e, "vni", fwd->vni);
3594 vat_json_object_add_int (e, "action", fwd->action);
3596 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3597 fwd->leid_prefix_len);
3599 vat_json_object_add_string_copy (e, "leid", s);
3602 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3603 fwd->reid_prefix_len);
3605 vat_json_object_add_string_copy (e, "reid", s);
3609 vat_json_print (vam->ofp, &root);
3610 vat_json_free (&root);
3613 vam->retval = retval;
3614 vam->result_ready = 1;
3618 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3619 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3621 vat_main_t *vam = &vat_main;
3623 int retval = clib_net_to_host_u32 (mp->retval);
3624 vl_api_gpe_native_fwd_rpath_t *r;
3629 n = clib_net_to_host_u32 (mp->count);
3631 for (i = 0; i < n; i++)
3633 r = &mp->entries[i];
3634 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3635 clib_net_to_host_u32 (r->fib_index),
3636 clib_net_to_host_u32 (r->nh_sw_if_index),
3637 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3641 vam->retval = retval;
3642 vam->result_ready = 1;
3646 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3647 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3649 vat_main_t *vam = &vat_main;
3650 vat_json_node_t root, *e;
3652 int retval = clib_net_to_host_u32 (mp->retval);
3653 vl_api_gpe_native_fwd_rpath_t *r;
3659 n = clib_net_to_host_u32 (mp->count);
3660 vat_json_init_array (&root);
3662 for (i = 0; i < n; i++)
3664 e = vat_json_array_add (&root);
3665 vat_json_init_object (e);
3666 r = &mp->entries[i];
3668 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3671 vat_json_object_add_string_copy (e, "ip4", s);
3674 vat_json_object_add_uint (e, "fib_index",
3675 clib_net_to_host_u32 (r->fib_index));
3676 vat_json_object_add_uint (e, "nh_sw_if_index",
3677 clib_net_to_host_u32 (r->nh_sw_if_index));
3680 vat_json_print (vam->ofp, &root);
3681 vat_json_free (&root);
3684 vam->retval = retval;
3685 vam->result_ready = 1;
3689 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3690 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3692 vat_main_t *vam = &vat_main;
3694 int retval = clib_net_to_host_u32 (mp->retval);
3699 n = clib_net_to_host_u32 (mp->count);
3701 for (i = 0; i < n; i++)
3702 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3705 vam->retval = retval;
3706 vam->result_ready = 1;
3710 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3711 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3713 vat_main_t *vam = &vat_main;
3714 vat_json_node_t root;
3716 int retval = clib_net_to_host_u32 (mp->retval);
3721 n = clib_net_to_host_u32 (mp->count);
3722 vat_json_init_array (&root);
3724 for (i = 0; i < n; i++)
3725 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3727 vat_json_print (vam->ofp, &root);
3728 vat_json_free (&root);
3731 vam->retval = retval;
3732 vam->result_ready = 1;
3736 vl_api_one_ndp_entries_get_reply_t_handler
3737 (vl_api_one_ndp_entries_get_reply_t * mp)
3739 vat_main_t *vam = &vat_main;
3741 int retval = clib_net_to_host_u32 (mp->retval);
3746 n = clib_net_to_host_u32 (mp->count);
3748 for (i = 0; i < n; i++)
3749 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3750 format_ethernet_address, mp->entries[i].mac);
3753 vam->retval = retval;
3754 vam->result_ready = 1;
3758 vl_api_one_ndp_entries_get_reply_t_handler_json
3759 (vl_api_one_ndp_entries_get_reply_t * mp)
3762 vat_main_t *vam = &vat_main;
3763 vat_json_node_t *e = 0, root;
3765 int retval = clib_net_to_host_u32 (mp->retval);
3766 vl_api_one_ndp_entry_t *arp_entry;
3771 n = clib_net_to_host_u32 (mp->count);
3772 vat_json_init_array (&root);
3774 for (i = 0; i < n; i++)
3776 e = vat_json_array_add (&root);
3777 arp_entry = &mp->entries[i];
3779 vat_json_init_object (e);
3780 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3783 vat_json_object_add_string_copy (e, "mac", s);
3786 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3788 vat_json_object_add_string_copy (e, "ip6", s);
3792 vat_json_print (vam->ofp, &root);
3793 vat_json_free (&root);
3796 vam->retval = retval;
3797 vam->result_ready = 1;
3801 vl_api_one_l2_arp_entries_get_reply_t_handler
3802 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3804 vat_main_t *vam = &vat_main;
3806 int retval = clib_net_to_host_u32 (mp->retval);
3811 n = clib_net_to_host_u32 (mp->count);
3813 for (i = 0; i < n; i++)
3814 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3815 format_ethernet_address, mp->entries[i].mac);
3818 vam->retval = retval;
3819 vam->result_ready = 1;
3823 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3824 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3827 vat_main_t *vam = &vat_main;
3828 vat_json_node_t *e = 0, root;
3830 int retval = clib_net_to_host_u32 (mp->retval);
3831 vl_api_one_l2_arp_entry_t *arp_entry;
3836 n = clib_net_to_host_u32 (mp->count);
3837 vat_json_init_array (&root);
3839 for (i = 0; i < n; i++)
3841 e = vat_json_array_add (&root);
3842 arp_entry = &mp->entries[i];
3844 vat_json_init_object (e);
3845 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3848 vat_json_object_add_string_copy (e, "mac", s);
3851 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3853 vat_json_object_add_string_copy (e, "ip4", s);
3857 vat_json_print (vam->ofp, &root);
3858 vat_json_free (&root);
3861 vam->retval = retval;
3862 vam->result_ready = 1;
3866 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
3868 vat_main_t *vam = &vat_main;
3870 int retval = clib_net_to_host_u32 (mp->retval);
3875 n = clib_net_to_host_u32 (mp->count);
3877 for (i = 0; i < n; i++)
3879 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3883 vam->retval = retval;
3884 vam->result_ready = 1;
3888 vl_api_one_ndp_bd_get_reply_t_handler_json
3889 (vl_api_one_ndp_bd_get_reply_t * mp)
3891 vat_main_t *vam = &vat_main;
3892 vat_json_node_t root;
3894 int retval = clib_net_to_host_u32 (mp->retval);
3899 n = clib_net_to_host_u32 (mp->count);
3900 vat_json_init_array (&root);
3902 for (i = 0; i < n; i++)
3904 vat_json_array_add_uint (&root,
3905 clib_net_to_host_u32 (mp->bridge_domains[i]));
3908 vat_json_print (vam->ofp, &root);
3909 vat_json_free (&root);
3912 vam->retval = retval;
3913 vam->result_ready = 1;
3917 vl_api_one_l2_arp_bd_get_reply_t_handler
3918 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3920 vat_main_t *vam = &vat_main;
3922 int retval = clib_net_to_host_u32 (mp->retval);
3927 n = clib_net_to_host_u32 (mp->count);
3929 for (i = 0; i < n; i++)
3931 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3935 vam->retval = retval;
3936 vam->result_ready = 1;
3940 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3941 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3943 vat_main_t *vam = &vat_main;
3944 vat_json_node_t root;
3946 int retval = clib_net_to_host_u32 (mp->retval);
3951 n = clib_net_to_host_u32 (mp->count);
3952 vat_json_init_array (&root);
3954 for (i = 0; i < n; i++)
3956 vat_json_array_add_uint (&root,
3957 clib_net_to_host_u32 (mp->bridge_domains[i]));
3960 vat_json_print (vam->ofp, &root);
3961 vat_json_free (&root);
3964 vam->retval = retval;
3965 vam->result_ready = 1;
3969 vl_api_one_adjacencies_get_reply_t_handler
3970 (vl_api_one_adjacencies_get_reply_t * mp)
3972 vat_main_t *vam = &vat_main;
3974 int retval = clib_net_to_host_u32 (mp->retval);
3975 vl_api_one_adjacency_t *a;
3980 n = clib_net_to_host_u32 (mp->count);
3982 for (i = 0; i < n; i++)
3984 a = &mp->adjacencies[i];
3985 print (vam->ofp, "%U %40U",
3986 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3987 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3991 vam->retval = retval;
3992 vam->result_ready = 1;
3996 vl_api_one_adjacencies_get_reply_t_handler_json
3997 (vl_api_one_adjacencies_get_reply_t * mp)
4000 vat_main_t *vam = &vat_main;
4001 vat_json_node_t *e = 0, root;
4003 int retval = clib_net_to_host_u32 (mp->retval);
4004 vl_api_one_adjacency_t *a;
4009 n = clib_net_to_host_u32 (mp->count);
4010 vat_json_init_array (&root);
4012 for (i = 0; i < n; i++)
4014 e = vat_json_array_add (&root);
4015 a = &mp->adjacencies[i];
4017 vat_json_init_object (e);
4018 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
4019 a->leid_prefix_len);
4021 vat_json_object_add_string_copy (e, "leid", s);
4024 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
4025 a->reid_prefix_len);
4027 vat_json_object_add_string_copy (e, "reid", s);
4031 vat_json_print (vam->ofp, &root);
4032 vat_json_free (&root);
4035 vam->retval = retval;
4036 vam->result_ready = 1;
4040 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
4042 vat_main_t *vam = &vat_main;
4044 print (vam->ofp, "%=20U",
4045 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4050 vl_api_one_map_server_details_t_handler_json
4051 (vl_api_one_map_server_details_t * mp)
4053 vat_main_t *vam = &vat_main;
4054 vat_json_node_t *node = NULL;
4055 struct in6_addr ip6;
4058 if (VAT_JSON_ARRAY != vam->json_tree.type)
4060 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4061 vat_json_init_array (&vam->json_tree);
4063 node = vat_json_array_add (&vam->json_tree);
4065 vat_json_init_object (node);
4068 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4069 vat_json_object_add_ip6 (node, "map-server", ip6);
4073 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4074 vat_json_object_add_ip4 (node, "map-server", ip4);
4079 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4082 vat_main_t *vam = &vat_main;
4084 print (vam->ofp, "%=20U",
4085 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4090 vl_api_one_map_resolver_details_t_handler_json
4091 (vl_api_one_map_resolver_details_t * mp)
4093 vat_main_t *vam = &vat_main;
4094 vat_json_node_t *node = NULL;
4095 struct in6_addr ip6;
4098 if (VAT_JSON_ARRAY != vam->json_tree.type)
4100 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4101 vat_json_init_array (&vam->json_tree);
4103 node = vat_json_array_add (&vam->json_tree);
4105 vat_json_init_object (node);
4108 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4109 vat_json_object_add_ip6 (node, "map resolver", ip6);
4113 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4114 vat_json_object_add_ip4 (node, "map resolver", ip4);
4119 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4121 vat_main_t *vam = &vat_main;
4122 i32 retval = ntohl (mp->retval);
4126 print (vam->ofp, "feature: %s\ngpe: %s",
4127 mp->feature_status ? "enabled" : "disabled",
4128 mp->gpe_status ? "enabled" : "disabled");
4131 vam->retval = retval;
4132 vam->result_ready = 1;
4136 vl_api_show_one_status_reply_t_handler_json
4137 (vl_api_show_one_status_reply_t * mp)
4139 vat_main_t *vam = &vat_main;
4140 vat_json_node_t node;
4141 u8 *gpe_status = NULL;
4142 u8 *feature_status = NULL;
4144 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4145 feature_status = format (0, "%s",
4146 mp->feature_status ? "enabled" : "disabled");
4147 vec_add1 (gpe_status, 0);
4148 vec_add1 (feature_status, 0);
4150 vat_json_init_object (&node);
4151 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4152 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4154 vec_free (gpe_status);
4155 vec_free (feature_status);
4157 vat_json_print (vam->ofp, &node);
4158 vat_json_free (&node);
4160 vam->retval = ntohl (mp->retval);
4161 vam->result_ready = 1;
4165 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4166 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4168 vat_main_t *vam = &vat_main;
4169 i32 retval = ntohl (mp->retval);
4173 print (vam->ofp, "%=20s", mp->locator_set_name);
4176 vam->retval = retval;
4177 vam->result_ready = 1;
4181 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4182 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4184 vat_main_t *vam = &vat_main;
4185 vat_json_node_t *node = NULL;
4187 if (VAT_JSON_ARRAY != vam->json_tree.type)
4189 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4190 vat_json_init_array (&vam->json_tree);
4192 node = vat_json_array_add (&vam->json_tree);
4194 vat_json_init_object (node);
4195 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4197 vat_json_print (vam->ofp, node);
4198 vat_json_free (node);
4200 vam->retval = ntohl (mp->retval);
4201 vam->result_ready = 1;
4205 format_lisp_map_request_mode (u8 * s, va_list * args)
4207 u32 mode = va_arg (*args, u32);
4212 return format (0, "dst-only");
4214 return format (0, "src-dst");
4220 vl_api_show_one_map_request_mode_reply_t_handler
4221 (vl_api_show_one_map_request_mode_reply_t * mp)
4223 vat_main_t *vam = &vat_main;
4224 i32 retval = ntohl (mp->retval);
4228 u32 mode = mp->mode;
4229 print (vam->ofp, "map_request_mode: %U",
4230 format_lisp_map_request_mode, mode);
4233 vam->retval = retval;
4234 vam->result_ready = 1;
4238 vl_api_show_one_map_request_mode_reply_t_handler_json
4239 (vl_api_show_one_map_request_mode_reply_t * mp)
4241 vat_main_t *vam = &vat_main;
4242 vat_json_node_t node;
4247 s = format (0, "%U", format_lisp_map_request_mode, mode);
4250 vat_json_init_object (&node);
4251 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4252 vat_json_print (vam->ofp, &node);
4253 vat_json_free (&node);
4256 vam->retval = ntohl (mp->retval);
4257 vam->result_ready = 1;
4261 vl_api_one_show_xtr_mode_reply_t_handler
4262 (vl_api_one_show_xtr_mode_reply_t * mp)
4264 vat_main_t *vam = &vat_main;
4265 i32 retval = ntohl (mp->retval);
4269 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4272 vam->retval = retval;
4273 vam->result_ready = 1;
4277 vl_api_one_show_xtr_mode_reply_t_handler_json
4278 (vl_api_one_show_xtr_mode_reply_t * mp)
4280 vat_main_t *vam = &vat_main;
4281 vat_json_node_t node;
4284 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4285 vec_add1 (status, 0);
4287 vat_json_init_object (&node);
4288 vat_json_object_add_string_copy (&node, "status", status);
4292 vat_json_print (vam->ofp, &node);
4293 vat_json_free (&node);
4295 vam->retval = ntohl (mp->retval);
4296 vam->result_ready = 1;
4300 vl_api_one_show_pitr_mode_reply_t_handler
4301 (vl_api_one_show_pitr_mode_reply_t * mp)
4303 vat_main_t *vam = &vat_main;
4304 i32 retval = ntohl (mp->retval);
4308 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4311 vam->retval = retval;
4312 vam->result_ready = 1;
4316 vl_api_one_show_pitr_mode_reply_t_handler_json
4317 (vl_api_one_show_pitr_mode_reply_t * mp)
4319 vat_main_t *vam = &vat_main;
4320 vat_json_node_t node;
4323 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4324 vec_add1 (status, 0);
4326 vat_json_init_object (&node);
4327 vat_json_object_add_string_copy (&node, "status", status);
4331 vat_json_print (vam->ofp, &node);
4332 vat_json_free (&node);
4334 vam->retval = ntohl (mp->retval);
4335 vam->result_ready = 1;
4339 vl_api_one_show_petr_mode_reply_t_handler
4340 (vl_api_one_show_petr_mode_reply_t * mp)
4342 vat_main_t *vam = &vat_main;
4343 i32 retval = ntohl (mp->retval);
4347 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4350 vam->retval = retval;
4351 vam->result_ready = 1;
4355 vl_api_one_show_petr_mode_reply_t_handler_json
4356 (vl_api_one_show_petr_mode_reply_t * mp)
4358 vat_main_t *vam = &vat_main;
4359 vat_json_node_t node;
4362 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4363 vec_add1 (status, 0);
4365 vat_json_init_object (&node);
4366 vat_json_object_add_string_copy (&node, "status", status);
4370 vat_json_print (vam->ofp, &node);
4371 vat_json_free (&node);
4373 vam->retval = ntohl (mp->retval);
4374 vam->result_ready = 1;
4378 vl_api_show_one_use_petr_reply_t_handler
4379 (vl_api_show_one_use_petr_reply_t * mp)
4381 vat_main_t *vam = &vat_main;
4382 i32 retval = ntohl (mp->retval);
4386 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4389 print (vam->ofp, "Proxy-ETR address; %U",
4390 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4395 vam->retval = retval;
4396 vam->result_ready = 1;
4400 vl_api_show_one_use_petr_reply_t_handler_json
4401 (vl_api_show_one_use_petr_reply_t * mp)
4403 vat_main_t *vam = &vat_main;
4404 vat_json_node_t node;
4407 struct in6_addr ip6;
4409 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4410 vec_add1 (status, 0);
4412 vat_json_init_object (&node);
4413 vat_json_object_add_string_copy (&node, "status", status);
4418 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4419 vat_json_object_add_ip6 (&node, "address", ip6);
4423 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4424 vat_json_object_add_ip4 (&node, "address", ip4);
4430 vat_json_print (vam->ofp, &node);
4431 vat_json_free (&node);
4433 vam->retval = ntohl (mp->retval);
4434 vam->result_ready = 1;
4438 vl_api_show_one_nsh_mapping_reply_t_handler
4439 (vl_api_show_one_nsh_mapping_reply_t * mp)
4441 vat_main_t *vam = &vat_main;
4442 i32 retval = ntohl (mp->retval);
4446 print (vam->ofp, "%-20s%-16s",
4447 mp->is_set ? "set" : "not-set",
4448 mp->is_set ? (char *) mp->locator_set_name : "");
4451 vam->retval = retval;
4452 vam->result_ready = 1;
4456 vl_api_show_one_nsh_mapping_reply_t_handler_json
4457 (vl_api_show_one_nsh_mapping_reply_t * mp)
4459 vat_main_t *vam = &vat_main;
4460 vat_json_node_t node;
4463 status = format (0, "%s", mp->is_set ? "yes" : "no");
4464 vec_add1 (status, 0);
4466 vat_json_init_object (&node);
4467 vat_json_object_add_string_copy (&node, "is_set", status);
4470 vat_json_object_add_string_copy (&node, "locator_set",
4471 mp->locator_set_name);
4476 vat_json_print (vam->ofp, &node);
4477 vat_json_free (&node);
4479 vam->retval = ntohl (mp->retval);
4480 vam->result_ready = 1;
4484 vl_api_show_one_map_register_ttl_reply_t_handler
4485 (vl_api_show_one_map_register_ttl_reply_t * mp)
4487 vat_main_t *vam = &vat_main;
4488 i32 retval = ntohl (mp->retval);
4490 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4494 print (vam->ofp, "ttl: %u", mp->ttl);
4497 vam->retval = retval;
4498 vam->result_ready = 1;
4502 vl_api_show_one_map_register_ttl_reply_t_handler_json
4503 (vl_api_show_one_map_register_ttl_reply_t * mp)
4505 vat_main_t *vam = &vat_main;
4506 vat_json_node_t node;
4508 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4509 vat_json_init_object (&node);
4510 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4512 vat_json_print (vam->ofp, &node);
4513 vat_json_free (&node);
4515 vam->retval = ntohl (mp->retval);
4516 vam->result_ready = 1;
4520 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4522 vat_main_t *vam = &vat_main;
4523 i32 retval = ntohl (mp->retval);
4527 print (vam->ofp, "%-20s%-16s",
4528 mp->status ? "enabled" : "disabled",
4529 mp->status ? (char *) mp->locator_set_name : "");
4532 vam->retval = retval;
4533 vam->result_ready = 1;
4537 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4539 vat_main_t *vam = &vat_main;
4540 vat_json_node_t node;
4543 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4544 vec_add1 (status, 0);
4546 vat_json_init_object (&node);
4547 vat_json_object_add_string_copy (&node, "status", status);
4550 vat_json_object_add_string_copy (&node, "locator_set",
4551 mp->locator_set_name);
4556 vat_json_print (vam->ofp, &node);
4557 vat_json_free (&node);
4559 vam->retval = ntohl (mp->retval);
4560 vam->result_ready = 1;
4564 format_policer_type (u8 * s, va_list * va)
4566 u32 i = va_arg (*va, u32);
4568 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4569 s = format (s, "1r2c");
4570 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4571 s = format (s, "1r3c");
4572 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4573 s = format (s, "2r3c-2698");
4574 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4575 s = format (s, "2r3c-4115");
4576 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4577 s = format (s, "2r3c-mef5cf1");
4579 s = format (s, "ILLEGAL");
4584 format_policer_rate_type (u8 * s, va_list * va)
4586 u32 i = va_arg (*va, u32);
4588 if (i == SSE2_QOS_RATE_KBPS)
4589 s = format (s, "kbps");
4590 else if (i == SSE2_QOS_RATE_PPS)
4591 s = format (s, "pps");
4593 s = format (s, "ILLEGAL");
4598 format_policer_round_type (u8 * s, va_list * va)
4600 u32 i = va_arg (*va, u32);
4602 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4603 s = format (s, "closest");
4604 else if (i == SSE2_QOS_ROUND_TO_UP)
4605 s = format (s, "up");
4606 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4607 s = format (s, "down");
4609 s = format (s, "ILLEGAL");
4614 format_policer_action_type (u8 * s, va_list * va)
4616 u32 i = va_arg (*va, u32);
4618 if (i == SSE2_QOS_ACTION_DROP)
4619 s = format (s, "drop");
4620 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4621 s = format (s, "transmit");
4622 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4623 s = format (s, "mark-and-transmit");
4625 s = format (s, "ILLEGAL");
4630 format_dscp (u8 * s, va_list * va)
4632 u32 i = va_arg (*va, u32);
4637 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4641 return format (s, "ILLEGAL");
4643 s = format (s, "%s", t);
4648 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4650 vat_main_t *vam = &vat_main;
4651 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4653 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4654 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4656 conform_dscp_str = format (0, "");
4658 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4659 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4661 exceed_dscp_str = format (0, "");
4663 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4664 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4666 violate_dscp_str = format (0, "");
4668 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4669 "rate type %U, round type %U, %s rate, %s color-aware, "
4670 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4671 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4672 "conform action %U%s, exceed action %U%s, violate action %U%s",
4674 format_policer_type, mp->type,
4677 clib_net_to_host_u64 (mp->cb),
4678 clib_net_to_host_u64 (mp->eb),
4679 format_policer_rate_type, mp->rate_type,
4680 format_policer_round_type, mp->round_type,
4681 mp->single_rate ? "single" : "dual",
4682 mp->color_aware ? "is" : "not",
4683 ntohl (mp->cir_tokens_per_period),
4684 ntohl (mp->pir_tokens_per_period),
4686 ntohl (mp->current_limit),
4687 ntohl (mp->current_bucket),
4688 ntohl (mp->extended_limit),
4689 ntohl (mp->extended_bucket),
4690 clib_net_to_host_u64 (mp->last_update_time),
4691 format_policer_action_type, mp->conform_action_type,
4693 format_policer_action_type, mp->exceed_action_type,
4695 format_policer_action_type, mp->violate_action_type,
4698 vec_free (conform_dscp_str);
4699 vec_free (exceed_dscp_str);
4700 vec_free (violate_dscp_str);
4703 static void vl_api_policer_details_t_handler_json
4704 (vl_api_policer_details_t * mp)
4706 vat_main_t *vam = &vat_main;
4707 vat_json_node_t *node;
4708 u8 *rate_type_str, *round_type_str, *type_str;
4709 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4711 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4713 format (0, "%U", format_policer_round_type, mp->round_type);
4714 type_str = format (0, "%U", format_policer_type, mp->type);
4715 conform_action_str = format (0, "%U", format_policer_action_type,
4716 mp->conform_action_type);
4717 exceed_action_str = format (0, "%U", format_policer_action_type,
4718 mp->exceed_action_type);
4719 violate_action_str = format (0, "%U", format_policer_action_type,
4720 mp->violate_action_type);
4722 if (VAT_JSON_ARRAY != vam->json_tree.type)
4724 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4725 vat_json_init_array (&vam->json_tree);
4727 node = vat_json_array_add (&vam->json_tree);
4729 vat_json_init_object (node);
4730 vat_json_object_add_string_copy (node, "name", mp->name);
4731 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4732 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4733 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4734 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4735 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4736 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4737 vat_json_object_add_string_copy (node, "type", type_str);
4738 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4739 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4740 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4741 vat_json_object_add_uint (node, "cir_tokens_per_period",
4742 ntohl (mp->cir_tokens_per_period));
4743 vat_json_object_add_uint (node, "eir_tokens_per_period",
4744 ntohl (mp->pir_tokens_per_period));
4745 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4746 vat_json_object_add_uint (node, "current_bucket",
4747 ntohl (mp->current_bucket));
4748 vat_json_object_add_uint (node, "extended_limit",
4749 ntohl (mp->extended_limit));
4750 vat_json_object_add_uint (node, "extended_bucket",
4751 ntohl (mp->extended_bucket));
4752 vat_json_object_add_uint (node, "last_update_time",
4753 ntohl (mp->last_update_time));
4754 vat_json_object_add_string_copy (node, "conform_action",
4755 conform_action_str);
4756 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4758 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4759 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4760 vec_free (dscp_str);
4762 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4763 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4765 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4766 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4767 vec_free (dscp_str);
4769 vat_json_object_add_string_copy (node, "violate_action",
4770 violate_action_str);
4771 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4773 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4774 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4775 vec_free (dscp_str);
4778 vec_free (rate_type_str);
4779 vec_free (round_type_str);
4780 vec_free (type_str);
4781 vec_free (conform_action_str);
4782 vec_free (exceed_action_str);
4783 vec_free (violate_action_str);
4787 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4790 vat_main_t *vam = &vat_main;
4791 int i, count = ntohl (mp->count);
4794 print (vam->ofp, "classify table ids (%d) : ", count);
4795 for (i = 0; i < count; i++)
4797 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4798 print (vam->ofp, (i < count - 1) ? "," : "");
4800 vam->retval = ntohl (mp->retval);
4801 vam->result_ready = 1;
4805 vl_api_classify_table_ids_reply_t_handler_json
4806 (vl_api_classify_table_ids_reply_t * mp)
4808 vat_main_t *vam = &vat_main;
4809 int i, count = ntohl (mp->count);
4813 vat_json_node_t node;
4815 vat_json_init_object (&node);
4816 for (i = 0; i < count; i++)
4818 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4820 vat_json_print (vam->ofp, &node);
4821 vat_json_free (&node);
4823 vam->retval = ntohl (mp->retval);
4824 vam->result_ready = 1;
4828 vl_api_classify_table_by_interface_reply_t_handler
4829 (vl_api_classify_table_by_interface_reply_t * mp)
4831 vat_main_t *vam = &vat_main;
4834 table_id = ntohl (mp->l2_table_id);
4836 print (vam->ofp, "l2 table id : %d", table_id);
4838 print (vam->ofp, "l2 table id : No input ACL tables configured");
4839 table_id = ntohl (mp->ip4_table_id);
4841 print (vam->ofp, "ip4 table id : %d", table_id);
4843 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4844 table_id = ntohl (mp->ip6_table_id);
4846 print (vam->ofp, "ip6 table id : %d", table_id);
4848 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4849 vam->retval = ntohl (mp->retval);
4850 vam->result_ready = 1;
4854 vl_api_classify_table_by_interface_reply_t_handler_json
4855 (vl_api_classify_table_by_interface_reply_t * mp)
4857 vat_main_t *vam = &vat_main;
4858 vat_json_node_t node;
4860 vat_json_init_object (&node);
4862 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4863 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4864 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4866 vat_json_print (vam->ofp, &node);
4867 vat_json_free (&node);
4869 vam->retval = ntohl (mp->retval);
4870 vam->result_ready = 1;
4873 static void vl_api_policer_add_del_reply_t_handler
4874 (vl_api_policer_add_del_reply_t * mp)
4876 vat_main_t *vam = &vat_main;
4877 i32 retval = ntohl (mp->retval);
4878 if (vam->async_mode)
4880 vam->async_errors += (retval < 0);
4884 vam->retval = retval;
4885 vam->result_ready = 1;
4886 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4888 * Note: this is just barely thread-safe, depends on
4889 * the main thread spinning waiting for an answer...
4891 errmsg ("policer index %d", ntohl (mp->policer_index));
4895 static void vl_api_policer_add_del_reply_t_handler_json
4896 (vl_api_policer_add_del_reply_t * mp)
4898 vat_main_t *vam = &vat_main;
4899 vat_json_node_t node;
4901 vat_json_init_object (&node);
4902 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4903 vat_json_object_add_uint (&node, "policer_index",
4904 ntohl (mp->policer_index));
4906 vat_json_print (vam->ofp, &node);
4907 vat_json_free (&node);
4909 vam->retval = ntohl (mp->retval);
4910 vam->result_ready = 1;
4913 /* Format hex dump. */
4915 format_hex_bytes (u8 * s, va_list * va)
4917 u8 *bytes = va_arg (*va, u8 *);
4918 int n_bytes = va_arg (*va, int);
4921 /* Print short or long form depending on byte count. */
4922 uword short_form = n_bytes <= 32;
4923 u32 indent = format_get_indent (s);
4928 for (i = 0; i < n_bytes; i++)
4930 if (!short_form && (i % 32) == 0)
4931 s = format (s, "%08x: ", i);
4932 s = format (s, "%02x", bytes[i]);
4933 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4934 s = format (s, "\n%U", format_white_space, indent);
4941 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4944 vat_main_t *vam = &vat_main;
4945 i32 retval = ntohl (mp->retval);
4948 print (vam->ofp, "classify table info :");
4949 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4950 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4951 ntohl (mp->miss_next_index));
4952 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4953 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4954 ntohl (mp->match_n_vectors));
4955 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4956 ntohl (mp->mask_length));
4958 vam->retval = retval;
4959 vam->result_ready = 1;
4963 vl_api_classify_table_info_reply_t_handler_json
4964 (vl_api_classify_table_info_reply_t * mp)
4966 vat_main_t *vam = &vat_main;
4967 vat_json_node_t node;
4969 i32 retval = ntohl (mp->retval);
4972 vat_json_init_object (&node);
4974 vat_json_object_add_int (&node, "sessions",
4975 ntohl (mp->active_sessions));
4976 vat_json_object_add_int (&node, "nexttbl",
4977 ntohl (mp->next_table_index));
4978 vat_json_object_add_int (&node, "nextnode",
4979 ntohl (mp->miss_next_index));
4980 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4981 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4982 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4983 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4984 ntohl (mp->mask_length), 0);
4985 vat_json_object_add_string_copy (&node, "mask", s);
4987 vat_json_print (vam->ofp, &node);
4988 vat_json_free (&node);
4990 vam->retval = ntohl (mp->retval);
4991 vam->result_ready = 1;
4995 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4998 vat_main_t *vam = &vat_main;
5000 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
5001 ntohl (mp->hit_next_index), ntohl (mp->advance),
5002 ntohl (mp->opaque_index));
5003 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
5004 ntohl (mp->match_length));
5008 vl_api_classify_session_details_t_handler_json
5009 (vl_api_classify_session_details_t * mp)
5011 vat_main_t *vam = &vat_main;
5012 vat_json_node_t *node = NULL;
5014 if (VAT_JSON_ARRAY != vam->json_tree.type)
5016 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5017 vat_json_init_array (&vam->json_tree);
5019 node = vat_json_array_add (&vam->json_tree);
5021 vat_json_init_object (node);
5022 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
5023 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
5024 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
5026 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
5028 vat_json_object_add_string_copy (node, "match", s);
5031 static void vl_api_pg_create_interface_reply_t_handler
5032 (vl_api_pg_create_interface_reply_t * mp)
5034 vat_main_t *vam = &vat_main;
5036 vam->retval = ntohl (mp->retval);
5037 vam->result_ready = 1;
5040 static void vl_api_pg_create_interface_reply_t_handler_json
5041 (vl_api_pg_create_interface_reply_t * mp)
5043 vat_main_t *vam = &vat_main;
5044 vat_json_node_t node;
5046 i32 retval = ntohl (mp->retval);
5049 vat_json_init_object (&node);
5051 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
5053 vat_json_print (vam->ofp, &node);
5054 vat_json_free (&node);
5056 vam->retval = ntohl (mp->retval);
5057 vam->result_ready = 1;
5060 static void vl_api_policer_classify_details_t_handler
5061 (vl_api_policer_classify_details_t * mp)
5063 vat_main_t *vam = &vat_main;
5065 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5066 ntohl (mp->table_index));
5069 static void vl_api_policer_classify_details_t_handler_json
5070 (vl_api_policer_classify_details_t * mp)
5072 vat_main_t *vam = &vat_main;
5073 vat_json_node_t *node;
5075 if (VAT_JSON_ARRAY != vam->json_tree.type)
5077 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5078 vat_json_init_array (&vam->json_tree);
5080 node = vat_json_array_add (&vam->json_tree);
5082 vat_json_init_object (node);
5083 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5084 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5087 static void vl_api_flow_classify_details_t_handler
5088 (vl_api_flow_classify_details_t * mp)
5090 vat_main_t *vam = &vat_main;
5092 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5093 ntohl (mp->table_index));
5096 static void vl_api_flow_classify_details_t_handler_json
5097 (vl_api_flow_classify_details_t * mp)
5099 vat_main_t *vam = &vat_main;
5100 vat_json_node_t *node;
5102 if (VAT_JSON_ARRAY != vam->json_tree.type)
5104 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5105 vat_json_init_array (&vam->json_tree);
5107 node = vat_json_array_add (&vam->json_tree);
5109 vat_json_init_object (node);
5110 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5111 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5114 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5115 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5116 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5117 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5118 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5119 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5120 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5121 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5122 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5123 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5126 * Generate boilerplate reply handlers, which
5127 * dig the return value out of the xxx_reply_t API message,
5128 * stick it into vam->retval, and set vam->result_ready
5130 * Could also do this by pointing N message decode slots at
5131 * a single function, but that could break in subtle ways.
5134 #define foreach_standard_reply_retval_handler \
5135 _(sw_interface_set_flags_reply) \
5136 _(sw_interface_add_del_address_reply) \
5137 _(sw_interface_set_rx_mode_reply) \
5138 _(sw_interface_set_rx_placement_reply) \
5139 _(sw_interface_set_table_reply) \
5140 _(sw_interface_set_mpls_enable_reply) \
5141 _(sw_interface_set_vpath_reply) \
5142 _(sw_interface_set_vxlan_bypass_reply) \
5143 _(sw_interface_set_geneve_bypass_reply) \
5144 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5145 _(sw_interface_set_l2_bridge_reply) \
5146 _(bridge_domain_add_del_reply) \
5147 _(sw_interface_set_l2_xconnect_reply) \
5148 _(l2fib_add_del_reply) \
5149 _(l2fib_flush_int_reply) \
5150 _(l2fib_flush_bd_reply) \
5151 _(ip_route_add_del_reply) \
5152 _(ip_table_add_del_reply) \
5153 _(ip_mroute_add_del_reply) \
5154 _(mpls_route_add_del_reply) \
5155 _(mpls_table_add_del_reply) \
5156 _(mpls_ip_bind_unbind_reply) \
5157 _(bier_route_add_del_reply) \
5158 _(bier_table_add_del_reply) \
5159 _(proxy_arp_add_del_reply) \
5160 _(proxy_arp_intfc_enable_disable_reply) \
5161 _(sw_interface_set_unnumbered_reply) \
5162 _(ip_neighbor_add_del_reply) \
5163 _(reset_fib_reply) \
5164 _(dhcp_proxy_config_reply) \
5165 _(dhcp_proxy_set_vss_reply) \
5166 _(dhcp_client_config_reply) \
5167 _(set_ip_flow_hash_reply) \
5168 _(sw_interface_ip6_enable_disable_reply) \
5169 _(ip6nd_proxy_add_del_reply) \
5170 _(sw_interface_ip6nd_ra_prefix_reply) \
5171 _(sw_interface_ip6nd_ra_config_reply) \
5172 _(set_arp_neighbor_limit_reply) \
5173 _(l2_patch_add_del_reply) \
5174 _(sr_mpls_policy_add_reply) \
5175 _(sr_mpls_policy_mod_reply) \
5176 _(sr_mpls_policy_del_reply) \
5177 _(sr_policy_add_reply) \
5178 _(sr_policy_mod_reply) \
5179 _(sr_policy_del_reply) \
5180 _(sr_localsid_add_del_reply) \
5181 _(sr_steering_add_del_reply) \
5182 _(classify_add_del_session_reply) \
5183 _(classify_set_interface_ip_table_reply) \
5184 _(classify_set_interface_l2_tables_reply) \
5185 _(l2tpv3_set_tunnel_cookies_reply) \
5186 _(l2tpv3_interface_enable_disable_reply) \
5187 _(l2tpv3_set_lookup_key_reply) \
5188 _(l2_fib_clear_table_reply) \
5189 _(l2_interface_efp_filter_reply) \
5190 _(l2_interface_vlan_tag_rewrite_reply) \
5191 _(modify_vhost_user_if_reply) \
5192 _(delete_vhost_user_if_reply) \
5193 _(ip_probe_neighbor_reply) \
5194 _(ip_scan_neighbor_enable_disable_reply) \
5195 _(want_ip4_arp_events_reply) \
5196 _(want_ip6_nd_events_reply) \
5197 _(want_l2_macs_events_reply) \
5198 _(input_acl_set_interface_reply) \
5199 _(ipsec_spd_add_del_reply) \
5200 _(ipsec_interface_add_del_spd_reply) \
5201 _(ipsec_spd_entry_add_del_reply) \
5202 _(ipsec_sad_entry_add_del_reply) \
5203 _(ipsec_tunnel_if_add_del_reply) \
5204 _(ipsec_tunnel_if_set_sa_reply) \
5205 _(delete_loopback_reply) \
5206 _(bd_ip_mac_add_del_reply) \
5207 _(bd_ip_mac_flush_reply) \
5208 _(want_interface_events_reply) \
5209 _(cop_interface_enable_disable_reply) \
5210 _(cop_whitelist_enable_disable_reply) \
5211 _(sw_interface_clear_stats_reply) \
5212 _(ioam_enable_reply) \
5213 _(ioam_disable_reply) \
5214 _(one_add_del_locator_reply) \
5215 _(one_add_del_local_eid_reply) \
5216 _(one_add_del_remote_mapping_reply) \
5217 _(one_add_del_adjacency_reply) \
5218 _(one_add_del_map_resolver_reply) \
5219 _(one_add_del_map_server_reply) \
5220 _(one_enable_disable_reply) \
5221 _(one_rloc_probe_enable_disable_reply) \
5222 _(one_map_register_enable_disable_reply) \
5223 _(one_map_register_set_ttl_reply) \
5224 _(one_set_transport_protocol_reply) \
5225 _(one_map_register_fallback_threshold_reply) \
5226 _(one_pitr_set_locator_set_reply) \
5227 _(one_map_request_mode_reply) \
5228 _(one_add_del_map_request_itr_rlocs_reply) \
5229 _(one_eid_table_add_del_map_reply) \
5230 _(one_use_petr_reply) \
5231 _(one_stats_enable_disable_reply) \
5232 _(one_add_del_l2_arp_entry_reply) \
5233 _(one_add_del_ndp_entry_reply) \
5234 _(one_stats_flush_reply) \
5235 _(one_enable_disable_xtr_mode_reply) \
5236 _(one_enable_disable_pitr_mode_reply) \
5237 _(one_enable_disable_petr_mode_reply) \
5238 _(gpe_enable_disable_reply) \
5239 _(gpe_set_encap_mode_reply) \
5240 _(gpe_add_del_iface_reply) \
5241 _(gpe_add_del_native_fwd_rpath_reply) \
5242 _(af_packet_delete_reply) \
5243 _(policer_classify_set_interface_reply) \
5244 _(netmap_create_reply) \
5245 _(netmap_delete_reply) \
5246 _(set_ipfix_exporter_reply) \
5247 _(set_ipfix_classify_stream_reply) \
5248 _(ipfix_classify_table_add_del_reply) \
5249 _(flow_classify_set_interface_reply) \
5250 _(sw_interface_span_enable_disable_reply) \
5251 _(pg_capture_reply) \
5252 _(pg_enable_disable_reply) \
5253 _(ip_source_and_port_range_check_add_del_reply) \
5254 _(ip_source_and_port_range_check_interface_add_del_reply)\
5255 _(delete_subif_reply) \
5256 _(l2_interface_pbb_tag_rewrite_reply) \
5258 _(feature_enable_disable_reply) \
5259 _(sw_interface_tag_add_del_reply) \
5260 _(hw_interface_set_mtu_reply) \
5261 _(p2p_ethernet_add_reply) \
5262 _(p2p_ethernet_del_reply) \
5263 _(lldp_config_reply) \
5264 _(sw_interface_set_lldp_reply) \
5265 _(tcp_configure_src_addresses_reply) \
5266 _(dns_enable_disable_reply) \
5267 _(dns_name_server_add_del_reply) \
5268 _(session_rule_add_del_reply) \
5269 _(ip_container_proxy_add_del_reply) \
5270 _(output_acl_set_interface_reply) \
5271 _(qos_record_enable_disable_reply)
5274 static void vl_api_##n##_t_handler \
5275 (vl_api_##n##_t * mp) \
5277 vat_main_t * vam = &vat_main; \
5278 i32 retval = ntohl(mp->retval); \
5279 if (vam->async_mode) { \
5280 vam->async_errors += (retval < 0); \
5282 vam->retval = retval; \
5283 vam->result_ready = 1; \
5286 foreach_standard_reply_retval_handler;
5290 static void vl_api_##n##_t_handler_json \
5291 (vl_api_##n##_t * mp) \
5293 vat_main_t * vam = &vat_main; \
5294 vat_json_node_t node; \
5295 vat_json_init_object(&node); \
5296 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5297 vat_json_print(vam->ofp, &node); \
5298 vam->retval = ntohl(mp->retval); \
5299 vam->result_ready = 1; \
5301 foreach_standard_reply_retval_handler;
5305 * Table of message reply handlers, must include boilerplate handlers
5309 #define foreach_vpe_api_reply_msg \
5310 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5311 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5312 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5313 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5314 _(CONTROL_PING_REPLY, control_ping_reply) \
5315 _(CLI_REPLY, cli_reply) \
5316 _(CLI_INBAND_REPLY, cli_inband_reply) \
5317 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5318 sw_interface_add_del_address_reply) \
5319 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5320 _(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
5321 _(SW_INTERFACE_RX_PLACEMENT_DETAILS, sw_interface_rx_placement_details) \
5322 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5323 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5324 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5325 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5326 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5327 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5328 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5329 sw_interface_set_l2_xconnect_reply) \
5330 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5331 sw_interface_set_l2_bridge_reply) \
5332 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5333 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5334 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5335 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5336 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5337 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5338 _(L2_FLAGS_REPLY, l2_flags_reply) \
5339 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5340 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5341 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5342 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5343 _(VIRTIO_PCI_CREATE_REPLY, virtio_pci_create_reply) \
5344 _(VIRTIO_PCI_DELETE_REPLY, virtio_pci_delete_reply) \
5345 _(SW_INTERFACE_VIRTIO_PCI_DETAILS, sw_interface_virtio_pci_details) \
5346 _(BOND_CREATE_REPLY, bond_create_reply) \
5347 _(BOND_DELETE_REPLY, bond_delete_reply) \
5348 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5349 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5350 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5351 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5352 _(IP_ROUTE_ADD_DEL_REPLY, ip_route_add_del_reply) \
5353 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5354 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5355 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5356 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5357 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5358 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5359 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5360 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5361 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5362 proxy_arp_intfc_enable_disable_reply) \
5363 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5364 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5365 sw_interface_set_unnumbered_reply) \
5366 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5367 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5368 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5369 _(RESET_FIB_REPLY, reset_fib_reply) \
5370 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5371 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5372 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5373 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5374 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5375 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5376 sw_interface_ip6_enable_disable_reply) \
5377 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5378 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5379 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5380 sw_interface_ip6nd_ra_prefix_reply) \
5381 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5382 sw_interface_ip6nd_ra_config_reply) \
5383 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5384 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5385 _(SR_MPLS_POLICY_ADD_REPLY, sr_mpls_policy_add_reply) \
5386 _(SR_MPLS_POLICY_MOD_REPLY, sr_mpls_policy_mod_reply) \
5387 _(SR_MPLS_POLICY_DEL_REPLY, sr_mpls_policy_del_reply) \
5388 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5389 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5390 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5391 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5392 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5393 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5394 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5395 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5396 classify_set_interface_ip_table_reply) \
5397 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5398 classify_set_interface_l2_tables_reply) \
5399 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5400 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5401 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5402 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5403 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5404 l2tpv3_interface_enable_disable_reply) \
5405 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5406 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5407 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5408 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5409 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5410 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5411 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5412 _(GRE_TUNNEL_ADD_DEL_REPLY, gre_tunnel_add_del_reply) \
5413 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5414 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5415 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5416 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5417 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5418 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5419 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5420 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5421 _(SHOW_VERSION_REPLY, show_version_reply) \
5422 _(SHOW_THREADS_REPLY, show_threads_reply) \
5423 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5424 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5425 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5426 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5427 _(IP_PROBE_NEIGHBOR_REPLY, ip_probe_neighbor_reply) \
5428 _(IP_SCAN_NEIGHBOR_ENABLE_DISABLE_REPLY, ip_scan_neighbor_enable_disable_reply) \
5429 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5430 _(IP4_ARP_EVENT, ip4_arp_event) \
5431 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5432 _(IP6_ND_EVENT, ip6_nd_event) \
5433 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5434 _(L2_MACS_EVENT, l2_macs_event) \
5435 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5436 _(IP_ADDRESS_DETAILS, ip_address_details) \
5437 _(IP_DETAILS, ip_details) \
5438 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5439 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5440 _(IPSEC_SPD_ENTRY_ADD_DEL_REPLY, ipsec_spd_entry_add_del_reply) \
5441 _(IPSEC_SAD_ENTRY_ADD_DEL_REPLY, ipsec_sad_entry_add_del_reply) \
5442 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5443 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5444 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5445 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5446 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5447 _(BD_IP_MAC_FLUSH_REPLY, bd_ip_mac_flush_reply) \
5448 _(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
5449 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5450 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5451 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5452 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5453 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5454 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5455 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5456 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5457 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5458 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5459 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5460 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5461 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5462 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5463 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5464 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5465 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5466 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5467 one_map_register_enable_disable_reply) \
5468 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5469 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5470 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5471 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5472 one_map_register_fallback_threshold_reply) \
5473 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5474 one_rloc_probe_enable_disable_reply) \
5475 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5476 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5477 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5478 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5479 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5480 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5481 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5482 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5483 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5484 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5485 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5486 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5487 _(ONE_STATS_DETAILS, one_stats_details) \
5488 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5489 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5490 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5491 show_one_stats_enable_disable_reply) \
5492 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5493 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5494 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5495 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5496 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5497 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5498 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5499 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5500 one_enable_disable_pitr_mode_reply) \
5501 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5502 one_enable_disable_petr_mode_reply) \
5503 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5504 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5505 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5506 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5507 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5508 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5509 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5510 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5511 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5512 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5513 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5514 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5515 gpe_add_del_native_fwd_rpath_reply) \
5516 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5517 gpe_fwd_entry_path_details) \
5518 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5519 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5520 one_add_del_map_request_itr_rlocs_reply) \
5521 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5522 one_get_map_request_itr_rlocs_reply) \
5523 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5524 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5525 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5526 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5527 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5528 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5529 show_one_map_register_state_reply) \
5530 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5531 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5532 show_one_map_register_fallback_threshold_reply) \
5533 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5534 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5535 _(AF_PACKET_DETAILS, af_packet_details) \
5536 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5537 _(POLICER_DETAILS, policer_details) \
5538 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5539 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5540 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5541 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5542 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5543 _(MPLS_TABLE_DETAILS, mpls_table_details) \
5544 _(MPLS_ROUTE_DETAILS, mpls_route_details) \
5545 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5546 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5547 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5548 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5549 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5550 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5551 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5552 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5553 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5554 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5555 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5556 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5557 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5558 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5559 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5560 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5561 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5562 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5563 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5564 ip_source_and_port_range_check_add_del_reply) \
5565 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5566 ip_source_and_port_range_check_interface_add_del_reply) \
5567 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5568 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5569 _(SET_PUNT_REPLY, set_punt_reply) \
5570 _(IP_TABLE_DETAILS, ip_table_details) \
5571 _(IP_ROUTE_DETAILS, ip_route_details) \
5572 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5573 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5574 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5575 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5576 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5577 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5578 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5579 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5580 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5581 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5582 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5583 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5584 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5585 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5586 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
5587 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \
5588 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5589 _(SESSION_RULES_DETAILS, session_rules_details) \
5590 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5591 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5592 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply)
5594 #define foreach_standalone_reply_msg \
5595 _(SW_INTERFACE_EVENT, sw_interface_event)
5603 #define STR_VTR_OP_CASE(op) \
5604 case L2_VTR_ ## op: \
5608 str_vtr_op (u32 vtr_op)
5612 STR_VTR_OP_CASE (DISABLED);
5613 STR_VTR_OP_CASE (PUSH_1);
5614 STR_VTR_OP_CASE (PUSH_2);
5615 STR_VTR_OP_CASE (POP_1);
5616 STR_VTR_OP_CASE (POP_2);
5617 STR_VTR_OP_CASE (TRANSLATE_1_1);
5618 STR_VTR_OP_CASE (TRANSLATE_1_2);
5619 STR_VTR_OP_CASE (TRANSLATE_2_1);
5620 STR_VTR_OP_CASE (TRANSLATE_2_2);
5627 dump_sub_interface_table (vat_main_t * vam)
5629 const sw_interface_subif_t *sub = NULL;
5631 if (vam->json_output)
5634 ("JSON output supported only for VPE API calls and dump_stats_table");
5639 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5640 "Interface", "sw_if_index",
5641 "sub id", "dot1ad", "tags", "outer id",
5642 "inner id", "exact", "default", "outer any", "inner any");
5644 vec_foreach (sub, vam->sw_if_subif_table)
5647 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5648 sub->interface_name,
5650 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5651 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5652 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5653 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5654 if (sub->vtr_op != L2_VTR_DISABLED)
5657 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5658 "tag1: %d tag2: %d ]",
5659 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5660 sub->vtr_tag1, sub->vtr_tag2);
5668 name_sort_cmp (void *a1, void *a2)
5670 name_sort_t *n1 = a1;
5671 name_sort_t *n2 = a2;
5673 return strcmp ((char *) n1->name, (char *) n2->name);
5677 dump_interface_table (vat_main_t * vam)
5680 name_sort_t *nses = 0, *ns;
5682 if (vam->json_output)
5685 ("JSON output supported only for VPE API calls and dump_stats_table");
5690 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5692 vec_add2 (nses, ns, 1);
5693 ns->name = (u8 *)(p->key);
5694 ns->value = (u32) p->value[0];
5698 vec_sort_with_function (nses, name_sort_cmp);
5700 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5701 vec_foreach (ns, nses)
5703 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5710 dump_ip_table (vat_main_t * vam, int is_ipv6)
5712 const ip_details_t *det = NULL;
5713 const ip_address_details_t *address = NULL;
5716 print (vam->ofp, "%-12s", "sw_if_index");
5718 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5725 print (vam->ofp, "%-12d", i);
5726 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5731 vec_foreach (address, det->addr)
5735 is_ipv6 ? format_ip6_address : format_ip4_address,
5736 address->ip, address->prefix_length);
5744 dump_ipv4_table (vat_main_t * vam)
5746 if (vam->json_output)
5749 ("JSON output supported only for VPE API calls and dump_stats_table");
5753 return dump_ip_table (vam, 0);
5757 dump_ipv6_table (vat_main_t * vam)
5759 if (vam->json_output)
5762 ("JSON output supported only for VPE API calls and dump_stats_table");
5766 return dump_ip_table (vam, 1);
5770 * Pass CLI buffers directly in the CLI_INBAND API message,
5771 * instead of an additional shared memory area.
5774 exec_inband (vat_main_t * vam)
5776 vl_api_cli_inband_t *mp;
5777 unformat_input_t *i = vam->input;
5780 if (vec_len (i->buffer) == 0)
5783 if (vam->exec_mode == 0 && unformat (i, "mode"))
5788 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5795 * In order for the CLI command to work, it
5796 * must be a vector ending in \n, not a C-string ending
5799 u32 len = vec_len (vam->input->buffer);
5800 M2 (CLI_INBAND, mp, len);
5801 vl_api_to_api_string (len - 1, (const char *) vam->input->buffer, &mp->cmd);
5805 /* json responses may or may not include a useful reply... */
5806 if (vec_len (vam->cmd_reply))
5807 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
5812 exec (vat_main_t * vam)
5814 return exec_inband (vam);
5818 api_create_loopback (vat_main_t * vam)
5820 unformat_input_t *i = vam->input;
5821 vl_api_create_loopback_t *mp;
5822 vl_api_create_loopback_instance_t *mp_lbi;
5825 u8 is_specified = 0;
5826 u32 user_instance = 0;
5829 clib_memset (mac_address, 0, sizeof (mac_address));
5831 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5833 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5835 if (unformat (i, "instance %d", &user_instance))
5843 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5844 mp_lbi->is_specified = is_specified;
5846 mp_lbi->user_instance = htonl (user_instance);
5848 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5853 /* Construct the API message */
5854 M (CREATE_LOOPBACK, mp);
5856 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5865 api_delete_loopback (vat_main_t * vam)
5867 unformat_input_t *i = vam->input;
5868 vl_api_delete_loopback_t *mp;
5869 u32 sw_if_index = ~0;
5872 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5874 if (unformat (i, "sw_if_index %d", &sw_if_index))
5880 if (sw_if_index == ~0)
5882 errmsg ("missing sw_if_index");
5886 /* Construct the API message */
5887 M (DELETE_LOOPBACK, mp);
5888 mp->sw_if_index = ntohl (sw_if_index);
5896 api_want_interface_events (vat_main_t * vam)
5898 unformat_input_t *i = vam->input;
5899 vl_api_want_interface_events_t *mp;
5903 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5905 if (unformat (i, "enable"))
5907 else if (unformat (i, "disable"))
5915 errmsg ("missing enable|disable");
5919 M (WANT_INTERFACE_EVENTS, mp);
5920 mp->enable_disable = enable;
5922 vam->interface_event_display = enable;
5930 /* Note: non-static, called once to set up the initial intfc table */
5932 api_sw_interface_dump (vat_main_t * vam)
5934 vl_api_sw_interface_dump_t *mp;
5935 vl_api_control_ping_t *mp_ping;
5937 name_sort_t *nses = 0, *ns;
5938 sw_interface_subif_t *sub = NULL;
5941 /* Toss the old name table */
5943 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5945 vec_add2 (nses, ns, 1);
5946 ns->name = (u8 *)(p->key);
5947 ns->value = (u32) p->value[0];
5951 hash_free (vam->sw_if_index_by_interface_name);
5953 vec_foreach (ns, nses) vec_free (ns->name);
5957 vec_foreach (sub, vam->sw_if_subif_table)
5959 vec_free (sub->interface_name);
5961 vec_free (vam->sw_if_subif_table);
5963 /* recreate the interface name hash table */
5964 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5967 * Ask for all interface names. Otherwise, the epic catalog of
5968 * name filters becomes ridiculously long, and vat ends up needing
5969 * to be taught about new interface types.
5971 M (SW_INTERFACE_DUMP, mp);
5974 /* Use a control ping for synchronization */
5975 MPING (CONTROL_PING, mp_ping);
5983 api_sw_interface_set_flags (vat_main_t * vam)
5985 unformat_input_t *i = vam->input;
5986 vl_api_sw_interface_set_flags_t *mp;
5988 u8 sw_if_index_set = 0;
5992 /* Parse args required to build the message */
5993 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5995 if (unformat (i, "admin-up"))
5997 else if (unformat (i, "admin-down"))
6000 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6001 sw_if_index_set = 1;
6002 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6003 sw_if_index_set = 1;
6008 if (sw_if_index_set == 0)
6010 errmsg ("missing interface name or sw_if_index");
6014 /* Construct the API message */
6015 M (SW_INTERFACE_SET_FLAGS, mp);
6016 mp->sw_if_index = ntohl (sw_if_index);
6017 mp->admin_up_down = admin_up;
6022 /* Wait for a reply, return the good/bad news... */
6028 api_sw_interface_set_rx_mode (vat_main_t * vam)
6030 unformat_input_t *i = vam->input;
6031 vl_api_sw_interface_set_rx_mode_t *mp;
6033 u8 sw_if_index_set = 0;
6035 u8 queue_id_valid = 0;
6037 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
6039 /* Parse args required to build the message */
6040 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6042 if (unformat (i, "queue %d", &queue_id))
6044 else if (unformat (i, "polling"))
6045 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
6046 else if (unformat (i, "interrupt"))
6047 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
6048 else if (unformat (i, "adaptive"))
6049 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
6051 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6052 sw_if_index_set = 1;
6053 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6054 sw_if_index_set = 1;
6059 if (sw_if_index_set == 0)
6061 errmsg ("missing interface name or sw_if_index");
6064 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6066 errmsg ("missing rx-mode");
6070 /* Construct the API message */
6071 M (SW_INTERFACE_SET_RX_MODE, mp);
6072 mp->sw_if_index = ntohl (sw_if_index);
6074 mp->queue_id_valid = queue_id_valid;
6075 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6080 /* Wait for a reply, return the good/bad news... */
6086 api_sw_interface_set_rx_placement (vat_main_t * vam)
6088 unformat_input_t *i = vam->input;
6089 vl_api_sw_interface_set_rx_placement_t *mp;
6091 u8 sw_if_index_set = 0;
6094 u32 queue_id, thread_index;
6096 /* Parse args required to build the message */
6097 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6099 if (unformat (i, "queue %d", &queue_id))
6101 else if (unformat (i, "main"))
6103 else if (unformat (i, "worker %d", &thread_index))
6106 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6107 sw_if_index_set = 1;
6108 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6109 sw_if_index_set = 1;
6114 if (sw_if_index_set == 0)
6116 errmsg ("missing interface name or sw_if_index");
6122 /* Construct the API message */
6123 M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
6124 mp->sw_if_index = ntohl (sw_if_index);
6125 mp->worker_id = ntohl (thread_index);
6126 mp->queue_id = ntohl (queue_id);
6127 mp->is_main = is_main;
6131 /* Wait for a reply, return the good/bad news... */
6136 static void vl_api_sw_interface_rx_placement_details_t_handler
6137 (vl_api_sw_interface_rx_placement_details_t * mp)
6139 vat_main_t *vam = &vat_main;
6140 u32 worker_id = ntohl (mp->worker_id);
6143 "\n%-11d %-11s %-6d %-5d %-9s",
6144 ntohl (mp->sw_if_index), (worker_id == 0) ? "main" : "worker",
6145 worker_id, ntohl (mp->queue_id),
6147 1) ? "polling" : ((mp->mode == 2) ? "interrupt" : "adaptive"));
6150 static void vl_api_sw_interface_rx_placement_details_t_handler_json
6151 (vl_api_sw_interface_rx_placement_details_t * mp)
6153 vat_main_t *vam = &vat_main;
6154 vat_json_node_t *node = NULL;
6156 if (VAT_JSON_ARRAY != vam->json_tree.type)
6158 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
6159 vat_json_init_array (&vam->json_tree);
6161 node = vat_json_array_add (&vam->json_tree);
6163 vat_json_init_object (node);
6164 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
6165 vat_json_object_add_uint (node, "worker_id", ntohl (mp->worker_id));
6166 vat_json_object_add_uint (node, "queue_id", ntohl (mp->queue_id));
6167 vat_json_object_add_uint (node, "mode", mp->mode);
6171 api_sw_interface_rx_placement_dump (vat_main_t * vam)
6173 unformat_input_t *i = vam->input;
6174 vl_api_sw_interface_rx_placement_dump_t *mp;
6175 vl_api_control_ping_t *mp_ping;
6178 u8 sw_if_index_set = 0;
6180 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6182 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6184 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6191 "\n%-11s %-11s %-6s %-5s %-4s",
6192 "sw_if_index", "main/worker", "thread", "queue", "mode");
6194 /* Dump Interface rx placement */
6195 M (SW_INTERFACE_RX_PLACEMENT_DUMP, mp);
6197 if (sw_if_index_set)
6198 mp->sw_if_index = htonl (sw_if_index);
6200 mp->sw_if_index = ~0;
6204 /* Use a control ping for synchronization */
6205 MPING (CONTROL_PING, mp_ping);
6213 api_sw_interface_clear_stats (vat_main_t * vam)
6215 unformat_input_t *i = vam->input;
6216 vl_api_sw_interface_clear_stats_t *mp;
6218 u8 sw_if_index_set = 0;
6221 /* Parse args required to build the message */
6222 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6224 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6225 sw_if_index_set = 1;
6226 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6227 sw_if_index_set = 1;
6232 /* Construct the API message */
6233 M (SW_INTERFACE_CLEAR_STATS, mp);
6235 if (sw_if_index_set == 1)
6236 mp->sw_if_index = ntohl (sw_if_index);
6238 mp->sw_if_index = ~0;
6243 /* Wait for a reply, return the good/bad news... */
6249 api_sw_interface_add_del_address (vat_main_t * vam)
6251 unformat_input_t *i = vam->input;
6252 vl_api_sw_interface_add_del_address_t *mp;
6254 u8 sw_if_index_set = 0;
6255 u8 is_add = 1, del_all = 0;
6256 u32 address_length = 0;
6257 u8 v4_address_set = 0;
6258 u8 v6_address_set = 0;
6259 ip4_address_t v4address;
6260 ip6_address_t v6address;
6263 /* Parse args required to build the message */
6264 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6266 if (unformat (i, "del-all"))
6268 else if (unformat (i, "del"))
6271 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6272 sw_if_index_set = 1;
6273 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6274 sw_if_index_set = 1;
6275 else if (unformat (i, "%U/%d",
6276 unformat_ip4_address, &v4address, &address_length))
6278 else if (unformat (i, "%U/%d",
6279 unformat_ip6_address, &v6address, &address_length))
6285 if (sw_if_index_set == 0)
6287 errmsg ("missing interface name or sw_if_index");
6290 if (v4_address_set && v6_address_set)
6292 errmsg ("both v4 and v6 addresses set");
6295 if (!v4_address_set && !v6_address_set && !del_all)
6297 errmsg ("no addresses set");
6301 /* Construct the API message */
6302 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6304 mp->sw_if_index = ntohl (sw_if_index);
6305 mp->is_add = is_add;
6306 mp->del_all = del_all;
6310 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6314 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6316 mp->address_length = address_length;
6321 /* Wait for a reply, return good/bad news */
6327 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6329 unformat_input_t *i = vam->input;
6330 vl_api_sw_interface_set_mpls_enable_t *mp;
6332 u8 sw_if_index_set = 0;
6336 /* Parse args required to build the message */
6337 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6339 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6340 sw_if_index_set = 1;
6341 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6342 sw_if_index_set = 1;
6343 else if (unformat (i, "disable"))
6345 else if (unformat (i, "dis"))
6351 if (sw_if_index_set == 0)
6353 errmsg ("missing interface name or sw_if_index");
6357 /* Construct the API message */
6358 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6360 mp->sw_if_index = ntohl (sw_if_index);
6361 mp->enable = enable;
6366 /* Wait for a reply... */
6372 api_sw_interface_set_table (vat_main_t * vam)
6374 unformat_input_t *i = vam->input;
6375 vl_api_sw_interface_set_table_t *mp;
6376 u32 sw_if_index, vrf_id = 0;
6377 u8 sw_if_index_set = 0;
6381 /* Parse args required to build the message */
6382 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6384 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6385 sw_if_index_set = 1;
6386 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6387 sw_if_index_set = 1;
6388 else if (unformat (i, "vrf %d", &vrf_id))
6390 else if (unformat (i, "ipv6"))
6396 if (sw_if_index_set == 0)
6398 errmsg ("missing interface name or sw_if_index");
6402 /* Construct the API message */
6403 M (SW_INTERFACE_SET_TABLE, mp);
6405 mp->sw_if_index = ntohl (sw_if_index);
6406 mp->is_ipv6 = is_ipv6;
6407 mp->vrf_id = ntohl (vrf_id);
6412 /* Wait for a reply... */
6417 static void vl_api_sw_interface_get_table_reply_t_handler
6418 (vl_api_sw_interface_get_table_reply_t * mp)
6420 vat_main_t *vam = &vat_main;
6422 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6424 vam->retval = ntohl (mp->retval);
6425 vam->result_ready = 1;
6429 static void vl_api_sw_interface_get_table_reply_t_handler_json
6430 (vl_api_sw_interface_get_table_reply_t * mp)
6432 vat_main_t *vam = &vat_main;
6433 vat_json_node_t node;
6435 vat_json_init_object (&node);
6436 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6437 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6439 vat_json_print (vam->ofp, &node);
6440 vat_json_free (&node);
6442 vam->retval = ntohl (mp->retval);
6443 vam->result_ready = 1;
6447 api_sw_interface_get_table (vat_main_t * vam)
6449 unformat_input_t *i = vam->input;
6450 vl_api_sw_interface_get_table_t *mp;
6452 u8 sw_if_index_set = 0;
6456 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6458 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6459 sw_if_index_set = 1;
6460 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6461 sw_if_index_set = 1;
6462 else if (unformat (i, "ipv6"))
6468 if (sw_if_index_set == 0)
6470 errmsg ("missing interface name or sw_if_index");
6474 M (SW_INTERFACE_GET_TABLE, mp);
6475 mp->sw_if_index = htonl (sw_if_index);
6476 mp->is_ipv6 = is_ipv6;
6484 api_sw_interface_set_vpath (vat_main_t * vam)
6486 unformat_input_t *i = vam->input;
6487 vl_api_sw_interface_set_vpath_t *mp;
6488 u32 sw_if_index = 0;
6489 u8 sw_if_index_set = 0;
6493 /* Parse args required to build the message */
6494 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6496 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6497 sw_if_index_set = 1;
6498 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6499 sw_if_index_set = 1;
6500 else if (unformat (i, "enable"))
6502 else if (unformat (i, "disable"))
6508 if (sw_if_index_set == 0)
6510 errmsg ("missing interface name or sw_if_index");
6514 /* Construct the API message */
6515 M (SW_INTERFACE_SET_VPATH, mp);
6517 mp->sw_if_index = ntohl (sw_if_index);
6518 mp->enable = is_enable;
6523 /* Wait for a reply... */
6529 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6531 unformat_input_t *i = vam->input;
6532 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6533 u32 sw_if_index = 0;
6534 u8 sw_if_index_set = 0;
6539 /* Parse args required to build the message */
6540 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6542 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6543 sw_if_index_set = 1;
6544 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6545 sw_if_index_set = 1;
6546 else if (unformat (i, "enable"))
6548 else if (unformat (i, "disable"))
6550 else if (unformat (i, "ip4"))
6552 else if (unformat (i, "ip6"))
6558 if (sw_if_index_set == 0)
6560 errmsg ("missing interface name or sw_if_index");
6564 /* Construct the API message */
6565 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6567 mp->sw_if_index = ntohl (sw_if_index);
6568 mp->enable = is_enable;
6569 mp->is_ipv6 = is_ipv6;
6574 /* Wait for a reply... */
6580 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6582 unformat_input_t *i = vam->input;
6583 vl_api_sw_interface_set_geneve_bypass_t *mp;
6584 u32 sw_if_index = 0;
6585 u8 sw_if_index_set = 0;
6590 /* Parse args required to build the message */
6591 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6593 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6594 sw_if_index_set = 1;
6595 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6596 sw_if_index_set = 1;
6597 else if (unformat (i, "enable"))
6599 else if (unformat (i, "disable"))
6601 else if (unformat (i, "ip4"))
6603 else if (unformat (i, "ip6"))
6609 if (sw_if_index_set == 0)
6611 errmsg ("missing interface name or sw_if_index");
6615 /* Construct the API message */
6616 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6618 mp->sw_if_index = ntohl (sw_if_index);
6619 mp->enable = is_enable;
6620 mp->is_ipv6 = is_ipv6;
6625 /* Wait for a reply... */
6631 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6633 unformat_input_t *i = vam->input;
6634 vl_api_sw_interface_set_l2_xconnect_t *mp;
6636 u8 rx_sw_if_index_set = 0;
6638 u8 tx_sw_if_index_set = 0;
6642 /* Parse args required to build the message */
6643 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6645 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6646 rx_sw_if_index_set = 1;
6647 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6648 tx_sw_if_index_set = 1;
6649 else if (unformat (i, "rx"))
6651 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6653 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6655 rx_sw_if_index_set = 1;
6660 else if (unformat (i, "tx"))
6662 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6664 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6666 tx_sw_if_index_set = 1;
6671 else if (unformat (i, "enable"))
6673 else if (unformat (i, "disable"))
6679 if (rx_sw_if_index_set == 0)
6681 errmsg ("missing rx interface name or rx_sw_if_index");
6685 if (enable && (tx_sw_if_index_set == 0))
6687 errmsg ("missing tx interface name or tx_sw_if_index");
6691 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6693 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6694 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6695 mp->enable = enable;
6703 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6705 unformat_input_t *i = vam->input;
6706 vl_api_sw_interface_set_l2_bridge_t *mp;
6707 vl_api_l2_port_type_t port_type;
6709 u8 rx_sw_if_index_set = 0;
6716 port_type = L2_API_PORT_TYPE_NORMAL;
6718 /* Parse args required to build the message */
6719 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6721 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6722 rx_sw_if_index_set = 1;
6723 else if (unformat (i, "bd_id %d", &bd_id))
6727 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6728 rx_sw_if_index_set = 1;
6729 else if (unformat (i, "shg %d", &shg))
6731 else if (unformat (i, "bvi"))
6732 port_type = L2_API_PORT_TYPE_BVI;
6733 else if (unformat (i, "uu-fwd"))
6734 port_type = L2_API_PORT_TYPE_UU_FWD;
6735 else if (unformat (i, "enable"))
6737 else if (unformat (i, "disable"))
6743 if (rx_sw_if_index_set == 0)
6745 errmsg ("missing rx interface name or sw_if_index");
6749 if (enable && (bd_id_set == 0))
6751 errmsg ("missing bridge domain");
6755 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6757 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6758 mp->bd_id = ntohl (bd_id);
6760 mp->port_type = ntohl (port_type);
6761 mp->enable = enable;
6769 api_bridge_domain_dump (vat_main_t * vam)
6771 unformat_input_t *i = vam->input;
6772 vl_api_bridge_domain_dump_t *mp;
6773 vl_api_control_ping_t *mp_ping;
6777 /* Parse args required to build the message */
6778 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6780 if (unformat (i, "bd_id %d", &bd_id))
6786 M (BRIDGE_DOMAIN_DUMP, mp);
6787 mp->bd_id = ntohl (bd_id);
6790 /* Use a control ping for synchronization */
6791 MPING (CONTROL_PING, mp_ping);
6799 api_bridge_domain_add_del (vat_main_t * vam)
6801 unformat_input_t *i = vam->input;
6802 vl_api_bridge_domain_add_del_t *mp;
6805 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6810 /* Parse args required to build the message */
6811 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6813 if (unformat (i, "bd_id %d", &bd_id))
6815 else if (unformat (i, "flood %d", &flood))
6817 else if (unformat (i, "uu-flood %d", &uu_flood))
6819 else if (unformat (i, "forward %d", &forward))
6821 else if (unformat (i, "learn %d", &learn))
6823 else if (unformat (i, "arp-term %d", &arp_term))
6825 else if (unformat (i, "mac-age %d", &mac_age))
6827 else if (unformat (i, "bd-tag %s", &bd_tag))
6829 else if (unformat (i, "del"))
6832 flood = uu_flood = forward = learn = 0;
6840 errmsg ("missing bridge domain");
6847 errmsg ("mac age must be less than 256 ");
6852 if ((bd_tag) && (vec_len (bd_tag) > 63))
6854 errmsg ("bd-tag cannot be longer than 63");
6859 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6861 mp->bd_id = ntohl (bd_id);
6863 mp->uu_flood = uu_flood;
6864 mp->forward = forward;
6866 mp->arp_term = arp_term;
6867 mp->is_add = is_add;
6868 mp->mac_age = (u8) mac_age;
6871 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
6872 mp->bd_tag[vec_len (bd_tag)] = 0;
6883 api_l2fib_flush_bd (vat_main_t * vam)
6885 unformat_input_t *i = vam->input;
6886 vl_api_l2fib_flush_bd_t *mp;
6890 /* Parse args required to build the message */
6891 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6893 if (unformat (i, "bd_id %d", &bd_id));
6900 errmsg ("missing bridge domain");
6904 M (L2FIB_FLUSH_BD, mp);
6906 mp->bd_id = htonl (bd_id);
6914 api_l2fib_flush_int (vat_main_t * vam)
6916 unformat_input_t *i = vam->input;
6917 vl_api_l2fib_flush_int_t *mp;
6918 u32 sw_if_index = ~0;
6921 /* Parse args required to build the message */
6922 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6924 if (unformat (i, "sw_if_index %d", &sw_if_index));
6926 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6931 if (sw_if_index == ~0)
6933 errmsg ("missing interface name or sw_if_index");
6937 M (L2FIB_FLUSH_INT, mp);
6939 mp->sw_if_index = ntohl (sw_if_index);
6947 api_l2fib_add_del (vat_main_t * vam)
6949 unformat_input_t *i = vam->input;
6950 vl_api_l2fib_add_del_t *mp;
6956 u32 sw_if_index = 0;
6957 u8 sw_if_index_set = 0;
6966 /* Parse args required to build the message */
6967 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6969 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
6971 else if (unformat (i, "bd_id %d", &bd_id))
6973 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6974 sw_if_index_set = 1;
6975 else if (unformat (i, "sw_if"))
6977 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6980 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6981 sw_if_index_set = 1;
6986 else if (unformat (i, "static"))
6988 else if (unformat (i, "filter"))
6993 else if (unformat (i, "bvi"))
6998 else if (unformat (i, "del"))
7000 else if (unformat (i, "count %d", &count))
7008 errmsg ("missing mac address");
7014 errmsg ("missing bridge domain");
7018 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7020 errmsg ("missing interface name or sw_if_index");
7026 /* Turn on async mode */
7027 vam->async_mode = 1;
7028 vam->async_errors = 0;
7029 before = vat_time_now (vam);
7032 for (j = 0; j < count; j++)
7034 M (L2FIB_ADD_DEL, mp);
7036 clib_memcpy (mp->mac, mac, 6);
7037 mp->bd_id = ntohl (bd_id);
7038 mp->is_add = is_add;
7039 mp->sw_if_index = ntohl (sw_if_index);
7043 mp->static_mac = static_mac;
7044 mp->filter_mac = filter_mac;
7045 mp->bvi_mac = bvi_mac;
7047 increment_mac_address (mac);
7054 vl_api_control_ping_t *mp_ping;
7057 /* Shut off async mode */
7058 vam->async_mode = 0;
7060 MPING (CONTROL_PING, mp_ping);
7063 timeout = vat_time_now (vam) + 1.0;
7064 while (vat_time_now (vam) < timeout)
7065 if (vam->result_ready == 1)
7070 if (vam->retval == -99)
7073 if (vam->async_errors > 0)
7075 errmsg ("%d asynchronous errors", vam->async_errors);
7078 vam->async_errors = 0;
7079 after = vat_time_now (vam);
7081 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7082 count, after - before, count / (after - before));
7088 /* Wait for a reply... */
7092 /* Return the good/bad news */
7093 return (vam->retval);
7097 api_bridge_domain_set_mac_age (vat_main_t * vam)
7099 unformat_input_t *i = vam->input;
7100 vl_api_bridge_domain_set_mac_age_t *mp;
7105 /* Parse args required to build the message */
7106 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7108 if (unformat (i, "bd_id %d", &bd_id));
7109 else if (unformat (i, "mac-age %d", &mac_age));
7116 errmsg ("missing bridge domain");
7122 errmsg ("mac age must be less than 256 ");
7126 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7128 mp->bd_id = htonl (bd_id);
7129 mp->mac_age = (u8) mac_age;
7137 api_l2_flags (vat_main_t * vam)
7139 unformat_input_t *i = vam->input;
7140 vl_api_l2_flags_t *mp;
7143 u8 sw_if_index_set = 0;
7147 /* Parse args required to build the message */
7148 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7150 if (unformat (i, "sw_if_index %d", &sw_if_index))
7151 sw_if_index_set = 1;
7152 else if (unformat (i, "sw_if"))
7154 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7157 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7158 sw_if_index_set = 1;
7163 else if (unformat (i, "learn"))
7165 else if (unformat (i, "forward"))
7167 else if (unformat (i, "flood"))
7169 else if (unformat (i, "uu-flood"))
7170 flags |= L2_UU_FLOOD;
7171 else if (unformat (i, "arp-term"))
7172 flags |= L2_ARP_TERM;
7173 else if (unformat (i, "off"))
7175 else if (unformat (i, "disable"))
7181 if (sw_if_index_set == 0)
7183 errmsg ("missing interface name or sw_if_index");
7189 mp->sw_if_index = ntohl (sw_if_index);
7190 mp->feature_bitmap = ntohl (flags);
7191 mp->is_set = is_set;
7199 api_bridge_flags (vat_main_t * vam)
7201 unformat_input_t *i = vam->input;
7202 vl_api_bridge_flags_t *mp;
7206 bd_flags_t flags = 0;
7209 /* Parse args required to build the message */
7210 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7212 if (unformat (i, "bd_id %d", &bd_id))
7214 else if (unformat (i, "learn"))
7215 flags |= BRIDGE_API_FLAG_LEARN;
7216 else if (unformat (i, "forward"))
7217 flags |= BRIDGE_API_FLAG_FWD;
7218 else if (unformat (i, "flood"))
7219 flags |= BRIDGE_API_FLAG_FLOOD;
7220 else if (unformat (i, "uu-flood"))
7221 flags |= BRIDGE_API_FLAG_UU_FLOOD;
7222 else if (unformat (i, "arp-term"))
7223 flags |= BRIDGE_API_FLAG_ARP_TERM;
7224 else if (unformat (i, "off"))
7226 else if (unformat (i, "disable"))
7234 errmsg ("missing bridge domain");
7238 M (BRIDGE_FLAGS, mp);
7240 mp->bd_id = ntohl (bd_id);
7241 mp->flags = ntohl (flags);
7242 mp->is_set = is_set;
7250 api_bd_ip_mac_add_del (vat_main_t * vam)
7252 vl_api_address_t ip = VL_API_ZERO_ADDRESS;
7253 vl_api_mac_address_t mac = { 0 };
7254 unformat_input_t *i = vam->input;
7255 vl_api_bd_ip_mac_add_del_t *mp;
7264 /* Parse args required to build the message */
7265 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7267 if (unformat (i, "bd_id %d", &bd_id))
7271 else if (unformat (i, "%U", unformat_vl_api_address, &ip))
7275 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
7279 else if (unformat (i, "del"))
7287 errmsg ("missing bridge domain");
7290 else if (ip_set == 0)
7292 errmsg ("missing IP address");
7295 else if (mac_set == 0)
7297 errmsg ("missing MAC address");
7301 M (BD_IP_MAC_ADD_DEL, mp);
7303 mp->entry.bd_id = ntohl (bd_id);
7304 mp->is_add = is_add;
7306 clib_memcpy (&mp->entry.ip, &ip, sizeof (ip));
7307 clib_memcpy (&mp->entry.mac, &mac, sizeof (mac));
7315 api_bd_ip_mac_flush (vat_main_t * vam)
7317 unformat_input_t *i = vam->input;
7318 vl_api_bd_ip_mac_flush_t *mp;
7323 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7325 if (unformat (i, "bd_id %d", &bd_id))
7335 errmsg ("missing bridge domain");
7339 M (BD_IP_MAC_FLUSH, mp);
7341 mp->bd_id = ntohl (bd_id);
7348 static void vl_api_bd_ip_mac_details_t_handler
7349 (vl_api_bd_ip_mac_details_t * mp)
7351 vat_main_t *vam = &vat_main;
7355 ntohl (mp->entry.bd_id),
7356 format_vl_api_mac_address, mp->entry.mac,
7357 format_vl_api_address, &mp->entry.ip);
7360 static void vl_api_bd_ip_mac_details_t_handler_json
7361 (vl_api_bd_ip_mac_details_t * mp)
7363 vat_main_t *vam = &vat_main;
7364 vat_json_node_t *node = NULL;
7366 if (VAT_JSON_ARRAY != vam->json_tree.type)
7368 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7369 vat_json_init_array (&vam->json_tree);
7371 node = vat_json_array_add (&vam->json_tree);
7373 vat_json_init_object (node);
7374 vat_json_object_add_uint (node, "bd_id", ntohl (mp->entry.bd_id));
7375 vat_json_object_add_string_copy (node, "mac_address",
7376 format (0, "%U", format_vl_api_mac_address,
7380 ip = format (0, "%U", format_vl_api_address, &mp->entry.ip);
7381 vat_json_object_add_string_copy (node, "ip_address", ip);
7386 api_bd_ip_mac_dump (vat_main_t * vam)
7388 unformat_input_t *i = vam->input;
7389 vl_api_bd_ip_mac_dump_t *mp;
7390 vl_api_control_ping_t *mp_ping;
7395 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7397 if (unformat (i, "bd_id %d", &bd_id))
7406 "\n%-5s %-7s %-20s %-30s",
7407 "bd_id", "is_ipv6", "mac_address", "ip_address");
7409 /* Dump Bridge Domain Ip to Mac entries */
7410 M (BD_IP_MAC_DUMP, mp);
7413 mp->bd_id = htonl (bd_id);
7419 /* Use a control ping for synchronization */
7420 MPING (CONTROL_PING, mp_ping);
7428 api_tap_create_v2 (vat_main_t * vam)
7430 unformat_input_t *i = vam->input;
7431 vl_api_tap_create_v2_t *mp;
7432 #define TAP_FLAG_GSO (1 << 0)
7436 u8 *host_if_name = 0;
7438 u8 host_mac_addr[6];
7439 u8 host_mac_addr_set = 0;
7440 u8 *host_bridge = 0;
7441 ip4_address_t host_ip4_addr;
7442 ip4_address_t host_ip4_gw;
7443 u8 host_ip4_gw_set = 0;
7444 u32 host_ip4_prefix_len = 0;
7445 ip6_address_t host_ip6_addr;
7446 ip6_address_t host_ip6_gw;
7447 u8 host_ip6_gw_set = 0;
7448 u32 host_ip6_prefix_len = 0;
7449 u8 host_mtu_set = 0;
7450 u32 host_mtu_size = 0;
7453 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7455 clib_memset (mac_address, 0, sizeof (mac_address));
7457 /* Parse args required to build the message */
7458 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7460 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7464 else if (unformat (i, "id %u", &id))
7466 else if (unformat (i, "host-if-name %s", &host_if_name))
7468 else if (unformat (i, "host-ns %s", &host_ns))
7470 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
7472 host_mac_addr_set = 1;
7473 else if (unformat (i, "host-bridge %s", &host_bridge))
7475 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
7476 &host_ip4_addr, &host_ip4_prefix_len))
7478 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
7479 &host_ip6_addr, &host_ip6_prefix_len))
7481 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
7483 host_ip4_gw_set = 1;
7484 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
7486 host_ip6_gw_set = 1;
7487 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
7489 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
7491 else if (unformat (i, "host-mtu-size %d", &host_mtu_size))
7493 else if (unformat (i, "no-gso"))
7494 tap_flags &= ~TAP_FLAG_GSO;
7495 else if (unformat (i, "gso"))
7496 tap_flags |= TAP_FLAG_GSO;
7501 if (vec_len (host_if_name) > 63)
7503 errmsg ("tap name too long. ");
7506 if (vec_len (host_ns) > 63)
7508 errmsg ("host name space too long. ");
7511 if (vec_len (host_bridge) > 63)
7513 errmsg ("host bridge name too long. ");
7516 if (host_ip4_prefix_len > 32)
7518 errmsg ("host ip4 prefix length not valid. ");
7521 if (host_ip6_prefix_len > 128)
7523 errmsg ("host ip6 prefix length not valid. ");
7526 if (!is_pow2 (rx_ring_sz))
7528 errmsg ("rx ring size must be power of 2. ");
7531 if (rx_ring_sz > 32768)
7533 errmsg ("rx ring size must be 32768 or lower. ");
7536 if (!is_pow2 (tx_ring_sz))
7538 errmsg ("tx ring size must be power of 2. ");
7541 if (tx_ring_sz > 32768)
7543 errmsg ("tx ring size must be 32768 or lower. ");
7546 if (host_mtu_set && (host_mtu_size < 64 || host_mtu_size > 65355))
7548 errmsg ("host MTU size must be in between 64 and 65355. ");
7552 /* Construct the API message */
7553 M (TAP_CREATE_V2, mp);
7555 mp->use_random_mac = random_mac;
7557 mp->id = ntohl (id);
7558 mp->host_namespace_set = host_ns != 0;
7559 mp->host_bridge_set = host_bridge != 0;
7560 mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
7561 mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
7562 mp->rx_ring_sz = ntohs (rx_ring_sz);
7563 mp->tx_ring_sz = ntohs (tx_ring_sz);
7564 mp->host_mtu_set = host_mtu_set;
7565 mp->host_mtu_size = ntohl (host_mtu_size);
7566 mp->tap_flags = ntohl (tap_flags);
7568 if (random_mac == 0)
7569 clib_memcpy (mp->mac_address, mac_address, 6);
7570 if (host_mac_addr_set)
7571 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
7573 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
7575 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
7577 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
7578 if (host_ip4_prefix_len)
7579 clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
7580 if (host_ip6_prefix_len)
7581 clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
7582 if (host_ip4_gw_set)
7583 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
7584 if (host_ip6_gw_set)
7585 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
7588 vec_free (host_if_name);
7589 vec_free (host_bridge);
7594 /* Wait for a reply... */
7600 api_tap_delete_v2 (vat_main_t * vam)
7602 unformat_input_t *i = vam->input;
7603 vl_api_tap_delete_v2_t *mp;
7604 u32 sw_if_index = ~0;
7605 u8 sw_if_index_set = 0;
7608 /* Parse args required to build the message */
7609 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7611 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7612 sw_if_index_set = 1;
7613 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7614 sw_if_index_set = 1;
7619 if (sw_if_index_set == 0)
7621 errmsg ("missing vpp interface name. ");
7625 /* Construct the API message */
7626 M (TAP_DELETE_V2, mp);
7628 mp->sw_if_index = ntohl (sw_if_index);
7633 /* Wait for a reply... */
7639 unformat_pci_addr (unformat_input_t * input, va_list * args)
7648 addr = va_arg (*args, struct pci_addr_t *);
7651 if (!unformat (input, "%x:%x:%x.%x", &x[0], &x[1], &x[2], &x[3]))
7654 addr->domain = x[0];
7657 addr->function = x[3];
7663 api_virtio_pci_create (vat_main_t * vam)
7665 unformat_input_t *i = vam->input;
7666 vl_api_virtio_pci_create_t *mp;
7671 u64 features = (u64) ~ (0ULL);
7674 clib_memset (mac_address, 0, sizeof (mac_address));
7676 /* Parse args required to build the message */
7677 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7679 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7683 else if (unformat (i, "pci-addr %U", unformat_pci_addr, &pci_addr))
7685 else if (unformat (i, "features 0x%llx", &features))
7687 else if (unformat (i, "gso-enabled"))
7695 errmsg ("pci address must be non zero. ");
7699 /* Construct the API message */
7700 M (VIRTIO_PCI_CREATE, mp);
7702 mp->use_random_mac = random_mac;
7704 mp->pci_addr = htonl (pci_addr);
7705 mp->features = clib_host_to_net_u64 (features);
7706 mp->gso_enabled = gso_enabled;
7708 if (random_mac == 0)
7709 clib_memcpy (mp->mac_address, mac_address, 6);
7714 /* Wait for a reply... */
7720 api_virtio_pci_delete (vat_main_t * vam)
7722 unformat_input_t *i = vam->input;
7723 vl_api_virtio_pci_delete_t *mp;
7724 u32 sw_if_index = ~0;
7725 u8 sw_if_index_set = 0;
7728 /* Parse args required to build the message */
7729 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7731 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7732 sw_if_index_set = 1;
7733 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7734 sw_if_index_set = 1;
7739 if (sw_if_index_set == 0)
7741 errmsg ("missing vpp interface name. ");
7745 /* Construct the API message */
7746 M (VIRTIO_PCI_DELETE, mp);
7748 mp->sw_if_index = htonl (sw_if_index);
7753 /* Wait for a reply... */
7759 api_bond_create (vat_main_t * vam)
7761 unformat_input_t *i = vam->input;
7762 vl_api_bond_create_t *mp;
7771 clib_memset (mac_address, 0, sizeof (mac_address));
7774 /* Parse args required to build the message */
7775 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7777 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
7779 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
7780 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
7782 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
7785 else if (unformat (i, "id %u", &id))
7791 if (mode_is_set == 0)
7793 errmsg ("Missing bond mode. ");
7797 /* Construct the API message */
7798 M (BOND_CREATE, mp);
7800 mp->use_custom_mac = custom_mac;
7804 mp->id = htonl (id);
7807 clib_memcpy (mp->mac_address, mac_address, 6);
7812 /* Wait for a reply... */
7818 api_bond_delete (vat_main_t * vam)
7820 unformat_input_t *i = vam->input;
7821 vl_api_bond_delete_t *mp;
7822 u32 sw_if_index = ~0;
7823 u8 sw_if_index_set = 0;
7826 /* Parse args required to build the message */
7827 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7829 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7830 sw_if_index_set = 1;
7831 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7832 sw_if_index_set = 1;
7837 if (sw_if_index_set == 0)
7839 errmsg ("missing vpp interface name. ");
7843 /* Construct the API message */
7844 M (BOND_DELETE, mp);
7846 mp->sw_if_index = ntohl (sw_if_index);
7851 /* Wait for a reply... */
7857 api_bond_enslave (vat_main_t * vam)
7859 unformat_input_t *i = vam->input;
7860 vl_api_bond_enslave_t *mp;
7861 u32 bond_sw_if_index;
7865 u32 bond_sw_if_index_is_set = 0;
7867 u8 sw_if_index_is_set = 0;
7869 /* Parse args required to build the message */
7870 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7872 if (unformat (i, "sw_if_index %d", &sw_if_index))
7873 sw_if_index_is_set = 1;
7874 else if (unformat (i, "bond %u", &bond_sw_if_index))
7875 bond_sw_if_index_is_set = 1;
7876 else if (unformat (i, "passive %d", &is_passive))
7878 else if (unformat (i, "long-timeout %d", &is_long_timeout))
7884 if (bond_sw_if_index_is_set == 0)
7886 errmsg ("Missing bond sw_if_index. ");
7889 if (sw_if_index_is_set == 0)
7891 errmsg ("Missing slave sw_if_index. ");
7895 /* Construct the API message */
7896 M (BOND_ENSLAVE, mp);
7898 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
7899 mp->sw_if_index = ntohl (sw_if_index);
7900 mp->is_long_timeout = is_long_timeout;
7901 mp->is_passive = is_passive;
7906 /* Wait for a reply... */
7912 api_bond_detach_slave (vat_main_t * vam)
7914 unformat_input_t *i = vam->input;
7915 vl_api_bond_detach_slave_t *mp;
7916 u32 sw_if_index = ~0;
7917 u8 sw_if_index_set = 0;
7920 /* Parse args required to build the message */
7921 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7923 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7924 sw_if_index_set = 1;
7925 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7926 sw_if_index_set = 1;
7931 if (sw_if_index_set == 0)
7933 errmsg ("missing vpp interface name. ");
7937 /* Construct the API message */
7938 M (BOND_DETACH_SLAVE, mp);
7940 mp->sw_if_index = ntohl (sw_if_index);
7945 /* Wait for a reply... */
7951 api_ip_table_add_del (vat_main_t * vam)
7953 unformat_input_t *i = vam->input;
7954 vl_api_ip_table_add_del_t *mp;
7960 /* Parse args required to build the message */
7961 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7963 if (unformat (i, "ipv6"))
7965 else if (unformat (i, "del"))
7967 else if (unformat (i, "add"))
7969 else if (unformat (i, "table %d", &table_id))
7973 clib_warning ("parse error '%U'", format_unformat_error, i);
7980 errmsg ("missing table-ID");
7984 /* Construct the API message */
7985 M (IP_TABLE_ADD_DEL, mp);
7987 mp->table.table_id = ntohl (table_id);
7988 mp->table.is_ip6 = is_ipv6;
7989 mp->is_add = is_add;
7994 /* Wait for a reply... */
8001 unformat_fib_path (unformat_input_t * input, va_list * args)
8003 vat_main_t *vam = va_arg (*args, vat_main_t *);
8004 vl_api_fib_path_t *path = va_arg (*args, vl_api_fib_path_t *);
8005 u32 weight, preference;
8006 mpls_label_t out_label;
8008 clib_memset (path, 0, sizeof (*path));
8010 path->sw_if_index = ~0;
8014 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8016 if (unformat (input, "%U %U",
8017 unformat_vl_api_ip4_address,
8018 &path->nh.address.ip4,
8019 api_unformat_sw_if_index, vam, &path->sw_if_index))
8021 path->proto = FIB_API_PATH_NH_PROTO_IP4;
8023 else if (unformat (input, "%U %U",
8024 unformat_vl_api_ip6_address,
8025 &path->nh.address.ip6,
8026 api_unformat_sw_if_index, vam, &path->sw_if_index))
8028 path->proto = FIB_API_PATH_NH_PROTO_IP6;
8030 else if (unformat (input, "weight %u", &weight))
8032 path->weight = weight;
8034 else if (unformat (input, "preference %u", &preference))
8036 path->preference = preference;
8038 else if (unformat (input, "%U next-hop-table %d",
8039 unformat_vl_api_ip4_address,
8040 &path->nh.address.ip4, &path->table_id))
8042 path->proto = FIB_API_PATH_NH_PROTO_IP4;
8044 else if (unformat (input, "%U next-hop-table %d",
8045 unformat_vl_api_ip6_address,
8046 &path->nh.address.ip6, &path->table_id))
8048 path->proto = FIB_API_PATH_NH_PROTO_IP6;
8050 else if (unformat (input, "%U",
8051 unformat_vl_api_ip4_address, &path->nh.address.ip4))
8054 * the recursive next-hops are by default in the default table
8057 path->sw_if_index = ~0;
8058 path->proto = FIB_API_PATH_NH_PROTO_IP4;
8060 else if (unformat (input, "%U",
8061 unformat_vl_api_ip6_address, &path->nh.address.ip6))
8064 * the recursive next-hops are by default in the default table
8067 path->sw_if_index = ~0;
8068 path->proto = FIB_API_PATH_NH_PROTO_IP6;
8070 else if (unformat (input, "resolve-via-host"))
8072 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_HOST;
8074 else if (unformat (input, "resolve-via-attached"))
8076 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED;
8078 else if (unformat (input, "ip4-lookup-in-table %d", &path->table_id))
8080 path->type = FIB_API_PATH_TYPE_LOCAL;
8081 path->sw_if_index = ~0;
8082 path->proto = FIB_API_PATH_NH_PROTO_IP4;
8084 else if (unformat (input, "ip6-lookup-in-table %d", &path->table_id))
8086 path->type = FIB_API_PATH_TYPE_LOCAL;
8087 path->sw_if_index = ~0;
8088 path->proto = FIB_API_PATH_NH_PROTO_IP6;
8090 else if (unformat (input, "sw_if_index %d", &path->sw_if_index))
8092 else if (unformat (input, "via-label %d", &path->nh.via_label))
8094 path->proto = FIB_API_PATH_NH_PROTO_MPLS;
8095 path->sw_if_index = ~0;
8097 else if (unformat (input, "l2-input-on %d", &path->sw_if_index))
8099 path->proto = FIB_API_PATH_NH_PROTO_ETHERNET;
8100 path->type = FIB_API_PATH_TYPE_INTERFACE_RX;
8102 else if (unformat (input, "local"))
8104 path->type = FIB_API_PATH_TYPE_LOCAL;
8106 else if (unformat (input, "out-labels"))
8108 while (unformat (input, "%d", &out_label))
8110 path->label_stack[path->n_labels].label = out_label;
8111 path->label_stack[path->n_labels].is_uniform = 0;
8112 path->label_stack[path->n_labels].ttl = 64;
8116 else if (unformat (input, "via"))
8118 /* new path, back up and return */
8119 unformat_put_input (input);
8120 unformat_put_input (input);
8121 unformat_put_input (input);
8122 unformat_put_input (input);
8131 path->proto = ntohl (path->proto);
8132 path->type = ntohl (path->type);
8133 path->flags = ntohl (path->flags);
8134 path->table_id = ntohl (path->table_id);
8135 path->sw_if_index = ntohl (path->sw_if_index);
8141 api_ip_route_add_del (vat_main_t * vam)
8143 unformat_input_t *i = vam->input;
8144 vl_api_ip_route_add_del_t *mp;
8147 u8 is_multipath = 0;
8150 vl_api_prefix_t pfx = { };
8151 vl_api_fib_path_t paths[8];
8155 u32 random_add_del = 0;
8156 u32 *random_vector = 0;
8157 u32 random_seed = 0xdeaddabe;
8159 /* Parse args required to build the message */
8160 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8162 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
8164 else if (unformat (i, "del"))
8166 else if (unformat (i, "add"))
8168 else if (unformat (i, "vrf %d", &vrf_id))
8170 else if (unformat (i, "count %d", &count))
8172 else if (unformat (i, "random"))
8174 else if (unformat (i, "multipath"))
8176 else if (unformat (i, "seed %d", &random_seed))
8180 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8183 if (8 == path_count)
8185 errmsg ("max 8 paths");
8191 clib_warning ("parse error '%U'", format_unformat_error, i);
8198 errmsg ("specify a path; via ...");
8201 if (prefix_set == 0)
8203 errmsg ("missing prefix");
8207 /* Generate a pile of unique, random routes */
8210 ip4_address_t *i = (ip4_address_t *) & paths[0].nh.address.ip4;
8211 u32 this_random_address;
8214 random_hash = hash_create (count, sizeof (uword));
8216 hash_set (random_hash, i->as_u32, 1);
8217 for (j = 0; j <= count; j++)
8221 this_random_address = random_u32 (&random_seed);
8222 this_random_address =
8223 clib_host_to_net_u32 (this_random_address);
8225 while (hash_get (random_hash, this_random_address));
8226 vec_add1 (random_vector, this_random_address);
8227 hash_set (random_hash, this_random_address, 1);
8229 hash_free (random_hash);
8230 set_ip4_address (&pfx.address, random_vector[0]);
8235 /* Turn on async mode */
8236 vam->async_mode = 1;
8237 vam->async_errors = 0;
8238 before = vat_time_now (vam);
8241 for (j = 0; j < count; j++)
8243 /* Construct the API message */
8244 M2 (IP_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8246 mp->is_add = is_add;
8247 mp->is_multipath = is_multipath;
8249 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
8250 mp->route.table_id = ntohl (vrf_id);
8251 mp->route.n_paths = path_count;
8253 clib_memcpy (&mp->route.paths, &paths, sizeof (paths[0]) * path_count);
8256 set_ip4_address (&pfx.address, random_vector[j + 1]);
8258 increment_address (&pfx.address);
8261 /* If we receive SIGTERM, stop now... */
8266 /* When testing multiple add/del ops, use a control-ping to sync */
8269 vl_api_control_ping_t *mp_ping;
8273 /* Shut off async mode */
8274 vam->async_mode = 0;
8276 MPING (CONTROL_PING, mp_ping);
8279 timeout = vat_time_now (vam) + 1.0;
8280 while (vat_time_now (vam) < timeout)
8281 if (vam->result_ready == 1)
8286 if (vam->retval == -99)
8289 if (vam->async_errors > 0)
8291 errmsg ("%d asynchronous errors", vam->async_errors);
8294 vam->async_errors = 0;
8295 after = vat_time_now (vam);
8297 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8301 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8302 count, after - before, count / (after - before));
8308 /* Wait for a reply... */
8313 /* Return the good/bad news */
8314 return (vam->retval);
8318 api_ip_mroute_add_del (vat_main_t * vam)
8320 unformat_input_t *i = vam->input;
8321 u8 path_set = 0, prefix_set = 0, is_add = 1;
8322 vl_api_ip_mroute_add_del_t *mp;
8323 mfib_entry_flags_t eflags = 0;
8324 vl_api_mfib_path_t path;
8325 vl_api_mprefix_t pfx = { };
8329 /* Parse args required to build the message */
8330 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8332 if (unformat (i, "%U", unformat_vl_api_mprefix, &pfx))
8335 pfx.grp_address_length = htons (pfx.grp_address_length);
8337 else if (unformat (i, "del"))
8339 else if (unformat (i, "add"))
8341 else if (unformat (i, "vrf %d", &vrf_id))
8343 else if (unformat (i, "%U", unformat_mfib_itf_flags, &path.itf_flags))
8344 path.itf_flags = htonl (path.itf_flags);
8345 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8347 else if (unformat (i, "via %U", unformat_fib_path, vam, &path.path))
8351 clib_warning ("parse error '%U'", format_unformat_error, i);
8356 if (prefix_set == 0)
8358 errmsg ("missing addresses\n");
8363 errmsg ("missing path\n");
8367 /* Construct the API message */
8368 M (IP_MROUTE_ADD_DEL, mp);
8370 mp->is_add = is_add;
8371 mp->is_multipath = 1;
8373 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
8374 mp->route.table_id = htonl (vrf_id);
8375 mp->route.n_paths = 1;
8376 mp->route.entry_flags = htonl (eflags);
8378 clib_memcpy (&mp->route.paths, &path, sizeof (path));
8382 /* Wait for a reply... */
8388 api_mpls_table_add_del (vat_main_t * vam)
8390 unformat_input_t *i = vam->input;
8391 vl_api_mpls_table_add_del_t *mp;
8396 /* Parse args required to build the message */
8397 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8399 if (unformat (i, "table %d", &table_id))
8401 else if (unformat (i, "del"))
8403 else if (unformat (i, "add"))
8407 clib_warning ("parse error '%U'", format_unformat_error, i);
8414 errmsg ("missing table-ID");
8418 /* Construct the API message */
8419 M (MPLS_TABLE_ADD_DEL, mp);
8421 mp->mt_table.mt_table_id = ntohl (table_id);
8422 mp->mt_is_add = is_add;
8427 /* Wait for a reply... */
8434 api_mpls_route_add_del (vat_main_t * vam)
8436 u8 is_add = 1, path_count = 0, is_multipath = 0, is_eos = 0;
8437 mpls_label_t local_label = MPLS_LABEL_INVALID;
8438 unformat_input_t *i = vam->input;
8439 vl_api_mpls_route_add_del_t *mp;
8440 vl_api_fib_path_t paths[8];
8444 /* Parse args required to build the message */
8445 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8447 if (unformat (i, "%d", &local_label))
8449 else if (unformat (i, "eos"))
8451 else if (unformat (i, "non-eos"))
8453 else if (unformat (i, "del"))
8455 else if (unformat (i, "add"))
8457 else if (unformat (i, "multipath"))
8459 else if (unformat (i, "count %d", &count))
8463 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8466 if (8 == path_count)
8468 errmsg ("max 8 paths");
8474 clib_warning ("parse error '%U'", format_unformat_error, i);
8481 errmsg ("specify a path; via ...");
8485 if (MPLS_LABEL_INVALID == local_label)
8487 errmsg ("missing label");
8493 /* Turn on async mode */
8494 vam->async_mode = 1;
8495 vam->async_errors = 0;
8496 before = vat_time_now (vam);
8499 for (j = 0; j < count; j++)
8501 /* Construct the API message */
8502 M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8504 mp->mr_is_add = is_add;
8505 mp->mr_is_multipath = is_multipath;
8507 mp->mr_route.mr_label = local_label;
8508 mp->mr_route.mr_eos = is_eos;
8509 mp->mr_route.mr_table_id = 0;
8510 mp->mr_route.mr_n_paths = path_count;
8512 clib_memcpy (&mp->mr_route.mr_paths, paths,
8513 sizeof (paths[0]) * path_count);
8519 /* If we receive SIGTERM, stop now... */
8524 /* When testing multiple add/del ops, use a control-ping to sync */
8527 vl_api_control_ping_t *mp_ping;
8531 /* Shut off async mode */
8532 vam->async_mode = 0;
8534 MPING (CONTROL_PING, mp_ping);
8537 timeout = vat_time_now (vam) + 1.0;
8538 while (vat_time_now (vam) < timeout)
8539 if (vam->result_ready == 1)
8544 if (vam->retval == -99)
8547 if (vam->async_errors > 0)
8549 errmsg ("%d asynchronous errors", vam->async_errors);
8552 vam->async_errors = 0;
8553 after = vat_time_now (vam);
8555 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8559 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8560 count, after - before, count / (after - before));
8566 /* Wait for a reply... */
8571 /* Return the good/bad news */
8572 return (vam->retval);
8577 api_mpls_ip_bind_unbind (vat_main_t * vam)
8579 unformat_input_t *i = vam->input;
8580 vl_api_mpls_ip_bind_unbind_t *mp;
8581 u32 ip_table_id = 0;
8583 vl_api_prefix_t pfx;
8585 mpls_label_t local_label = MPLS_LABEL_INVALID;
8588 /* Parse args required to build the message */
8589 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8591 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
8593 else if (unformat (i, "%d", &local_label))
8595 else if (unformat (i, "table-id %d", &ip_table_id))
8597 else if (unformat (i, "unbind"))
8599 else if (unformat (i, "bind"))
8603 clib_warning ("parse error '%U'", format_unformat_error, i);
8610 errmsg ("IP prefix not set");
8614 if (MPLS_LABEL_INVALID == local_label)
8616 errmsg ("missing label");
8620 /* Construct the API message */
8621 M (MPLS_IP_BIND_UNBIND, mp);
8623 mp->mb_is_bind = is_bind;
8624 mp->mb_ip_table_id = ntohl (ip_table_id);
8625 mp->mb_mpls_table_id = 0;
8626 mp->mb_label = ntohl (local_label);
8627 clib_memcpy (&mp->mb_prefix, &pfx, sizeof (pfx));
8632 /* Wait for a reply... */
8639 api_sr_mpls_policy_add (vat_main_t * vam)
8641 unformat_input_t *i = vam->input;
8642 vl_api_sr_mpls_policy_add_t *mp;
8648 u32 *segments = NULL;
8651 /* Parse args required to build the message */
8652 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8654 if (unformat (i, "bsid %d", &bsid))
8656 else if (unformat (i, "weight %d", &weight))
8658 else if (unformat (i, "spray"))
8660 else if (unformat (i, "next %d", &sid))
8663 vec_add1 (segments, htonl (sid));
8667 clib_warning ("parse error '%U'", format_unformat_error, i);
8674 errmsg ("bsid not set");
8678 if (n_segments == 0)
8680 errmsg ("no sid in segment stack");
8684 /* Construct the API message */
8685 M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
8687 mp->bsid = htonl (bsid);
8688 mp->weight = htonl (weight);
8690 mp->n_segments = n_segments;
8691 memcpy (mp->segments, segments, sizeof (u32) * n_segments);
8692 vec_free (segments);
8697 /* Wait for a reply... */
8703 api_sr_mpls_policy_del (vat_main_t * vam)
8705 unformat_input_t *i = vam->input;
8706 vl_api_sr_mpls_policy_del_t *mp;
8710 /* Parse args required to build the message */
8711 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8713 if (unformat (i, "bsid %d", &bsid))
8717 clib_warning ("parse error '%U'", format_unformat_error, i);
8724 errmsg ("bsid not set");
8728 /* Construct the API message */
8729 M (SR_MPLS_POLICY_DEL, mp);
8731 mp->bsid = htonl (bsid);
8736 /* Wait for a reply... */
8742 api_bier_table_add_del (vat_main_t * vam)
8744 unformat_input_t *i = vam->input;
8745 vl_api_bier_table_add_del_t *mp;
8747 u32 set = 0, sub_domain = 0, hdr_len = 3;
8748 mpls_label_t local_label = MPLS_LABEL_INVALID;
8751 /* Parse args required to build the message */
8752 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8754 if (unformat (i, "sub-domain %d", &sub_domain))
8756 else if (unformat (i, "set %d", &set))
8758 else if (unformat (i, "label %d", &local_label))
8760 else if (unformat (i, "hdr-len %d", &hdr_len))
8762 else if (unformat (i, "add"))
8764 else if (unformat (i, "del"))
8768 clib_warning ("parse error '%U'", format_unformat_error, i);
8773 if (MPLS_LABEL_INVALID == local_label)
8775 errmsg ("missing label\n");
8779 /* Construct the API message */
8780 M (BIER_TABLE_ADD_DEL, mp);
8782 mp->bt_is_add = is_add;
8783 mp->bt_label = ntohl (local_label);
8784 mp->bt_tbl_id.bt_set = set;
8785 mp->bt_tbl_id.bt_sub_domain = sub_domain;
8786 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
8791 /* Wait for a reply... */
8798 api_bier_route_add_del (vat_main_t * vam)
8800 unformat_input_t *i = vam->input;
8801 vl_api_bier_route_add_del_t *mp;
8803 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
8804 ip4_address_t v4_next_hop_address;
8805 ip6_address_t v6_next_hop_address;
8806 u8 next_hop_set = 0;
8807 u8 next_hop_proto_is_ip4 = 1;
8808 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8811 /* Parse args required to build the message */
8812 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8814 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
8816 next_hop_proto_is_ip4 = 1;
8819 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
8821 next_hop_proto_is_ip4 = 0;
8824 if (unformat (i, "sub-domain %d", &sub_domain))
8826 else if (unformat (i, "set %d", &set))
8828 else if (unformat (i, "hdr-len %d", &hdr_len))
8830 else if (unformat (i, "bp %d", &bp))
8832 else if (unformat (i, "add"))
8834 else if (unformat (i, "del"))
8836 else if (unformat (i, "out-label %d", &next_hop_out_label))
8840 clib_warning ("parse error '%U'", format_unformat_error, i);
8845 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
8847 errmsg ("next hop / label set\n");
8852 errmsg ("bit=position not set\n");
8856 /* Construct the API message */
8857 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
8859 mp->br_is_add = is_add;
8860 mp->br_route.br_tbl_id.bt_set = set;
8861 mp->br_route.br_tbl_id.bt_sub_domain = sub_domain;
8862 mp->br_route.br_tbl_id.bt_hdr_len_id = hdr_len;
8863 mp->br_route.br_bp = ntohs (bp);
8864 mp->br_route.br_n_paths = 1;
8865 mp->br_route.br_paths[0].n_labels = 1;
8866 mp->br_route.br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
8867 mp->br_route.br_paths[0].proto = (next_hop_proto_is_ip4 ?
8868 FIB_API_PATH_NH_PROTO_IP4 :
8869 FIB_API_PATH_NH_PROTO_IP6);
8871 if (next_hop_proto_is_ip4)
8873 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip4,
8874 &v4_next_hop_address, sizeof (v4_next_hop_address));
8878 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip6,
8879 &v6_next_hop_address, sizeof (v6_next_hop_address));
8885 /* Wait for a reply... */
8892 api_proxy_arp_add_del (vat_main_t * vam)
8894 unformat_input_t *i = vam->input;
8895 vl_api_proxy_arp_add_del_t *mp;
8898 vl_api_ip4_address_t lo, hi;
8902 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8904 if (unformat (i, "vrf %d", &vrf_id))
8906 else if (unformat (i, "%U - %U", unformat_vl_api_ip4_address, &lo,
8907 unformat_vl_api_ip4_address, &hi))
8909 else if (unformat (i, "del"))
8913 clib_warning ("parse error '%U'", format_unformat_error, i);
8920 errmsg ("address range not set");
8924 M (PROXY_ARP_ADD_DEL, mp);
8926 mp->proxy.table_id = ntohl (vrf_id);
8927 mp->is_add = is_add;
8928 clib_memcpy (mp->proxy.low, &lo, sizeof (lo));
8929 clib_memcpy (mp->proxy.hi, &hi, sizeof (hi));
8937 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
8939 unformat_input_t *i = vam->input;
8940 vl_api_proxy_arp_intfc_enable_disable_t *mp;
8943 u8 sw_if_index_set = 0;
8946 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8948 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8949 sw_if_index_set = 1;
8950 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8951 sw_if_index_set = 1;
8952 else if (unformat (i, "enable"))
8954 else if (unformat (i, "disable"))
8958 clib_warning ("parse error '%U'", format_unformat_error, i);
8963 if (sw_if_index_set == 0)
8965 errmsg ("missing interface name or sw_if_index");
8969 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
8971 mp->sw_if_index = ntohl (sw_if_index);
8972 mp->enable_disable = enable;
8980 api_mpls_tunnel_add_del (vat_main_t * vam)
8982 unformat_input_t *i = vam->input;
8983 vl_api_mpls_tunnel_add_del_t *mp;
8985 vl_api_fib_path_t paths[8];
8986 u32 sw_if_index = ~0;
8992 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8994 if (unformat (i, "add"))
8998 (i, "del %U", api_unformat_sw_if_index, vam, &sw_if_index))
9000 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
9002 else if (unformat (i, "l2-only"))
9006 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
9009 if (8 == path_count)
9011 errmsg ("max 8 paths");
9017 clib_warning ("parse error '%U'", format_unformat_error, i);
9022 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
9024 mp->mt_is_add = is_add;
9025 mp->mt_tunnel.mt_sw_if_index = ntohl (sw_if_index);
9026 mp->mt_tunnel.mt_l2_only = l2_only;
9027 mp->mt_tunnel.mt_is_multicast = 0;
9028 mp->mt_tunnel.mt_n_paths = path_count;
9030 clib_memcpy (&mp->mt_tunnel.mt_paths, &paths,
9031 sizeof (paths[0]) * path_count);
9039 api_sw_interface_set_unnumbered (vat_main_t * vam)
9041 unformat_input_t *i = vam->input;
9042 vl_api_sw_interface_set_unnumbered_t *mp;
9044 u32 unnum_sw_index = ~0;
9046 u8 sw_if_index_set = 0;
9049 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9051 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9052 sw_if_index_set = 1;
9053 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9054 sw_if_index_set = 1;
9055 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
9057 else if (unformat (i, "del"))
9061 clib_warning ("parse error '%U'", format_unformat_error, i);
9066 if (sw_if_index_set == 0)
9068 errmsg ("missing interface name or sw_if_index");
9072 M (SW_INTERFACE_SET_UNNUMBERED, mp);
9074 mp->sw_if_index = ntohl (sw_if_index);
9075 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
9076 mp->is_add = is_add;
9084 api_ip_neighbor_add_del (vat_main_t * vam)
9086 vl_api_mac_address_t mac_address;
9087 unformat_input_t *i = vam->input;
9088 vl_api_ip_neighbor_add_del_t *mp;
9089 vl_api_address_t ip_address;
9091 u8 sw_if_index_set = 0;
9096 ip_neighbor_flags_t flags;
9098 flags = IP_NEIGHBOR_FLAG_NONE;
9099 clib_memset (&ip_address, 0, sizeof (ip_address));
9100 clib_memset (&mac_address, 0, sizeof (mac_address));
9102 /* Parse args required to build the message */
9103 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9105 if (unformat (i, "mac %U", unformat_vl_api_mac_address, &mac_address))
9109 else if (unformat (i, "del"))
9112 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9113 sw_if_index_set = 1;
9114 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9115 sw_if_index_set = 1;
9116 else if (unformat (i, "static"))
9117 flags |= IP_NEIGHBOR_FLAG_STATIC;
9118 else if (unformat (i, "no-fib-entry"))
9119 flags |= IP_NEIGHBOR_FLAG_NO_FIB_ENTRY;
9120 else if (unformat (i, "dst %U", unformat_vl_api_address, &ip_address))
9124 clib_warning ("parse error '%U'", format_unformat_error, i);
9129 if (sw_if_index_set == 0)
9131 errmsg ("missing interface name or sw_if_index");
9136 errmsg ("no address set");
9140 /* Construct the API message */
9141 M (IP_NEIGHBOR_ADD_DEL, mp);
9143 mp->neighbor.sw_if_index = ntohl (sw_if_index);
9144 mp->is_add = is_add;
9145 mp->neighbor.flags = htonl (flags);
9147 clib_memcpy (&mp->neighbor.mac_address, &mac_address,
9148 sizeof (mac_address));
9150 clib_memcpy (&mp->neighbor.ip_address, &ip_address, sizeof (ip_address));
9155 /* Wait for a reply, return good/bad news */
9161 api_create_vlan_subif (vat_main_t * vam)
9163 unformat_input_t *i = vam->input;
9164 vl_api_create_vlan_subif_t *mp;
9166 u8 sw_if_index_set = 0;
9171 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9173 if (unformat (i, "sw_if_index %d", &sw_if_index))
9174 sw_if_index_set = 1;
9176 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9177 sw_if_index_set = 1;
9178 else if (unformat (i, "vlan %d", &vlan_id))
9182 clib_warning ("parse error '%U'", format_unformat_error, i);
9187 if (sw_if_index_set == 0)
9189 errmsg ("missing interface name or sw_if_index");
9193 if (vlan_id_set == 0)
9195 errmsg ("missing vlan_id");
9198 M (CREATE_VLAN_SUBIF, mp);
9200 mp->sw_if_index = ntohl (sw_if_index);
9201 mp->vlan_id = ntohl (vlan_id);
9208 #define foreach_create_subif_bit \
9215 _(outer_vlan_id_any) \
9216 _(inner_vlan_id_any)
9219 api_create_subif (vat_main_t * vam)
9221 unformat_input_t *i = vam->input;
9222 vl_api_create_subif_t *mp;
9224 u8 sw_if_index_set = 0;
9231 u32 exact_match = 0;
9232 u32 default_sub = 0;
9233 u32 outer_vlan_id_any = 0;
9234 u32 inner_vlan_id_any = 0;
9236 u16 outer_vlan_id = 0;
9237 u16 inner_vlan_id = 0;
9240 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9242 if (unformat (i, "sw_if_index %d", &sw_if_index))
9243 sw_if_index_set = 1;
9245 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9246 sw_if_index_set = 1;
9247 else if (unformat (i, "sub_id %d", &sub_id))
9249 else if (unformat (i, "outer_vlan_id %d", &tmp))
9250 outer_vlan_id = tmp;
9251 else if (unformat (i, "inner_vlan_id %d", &tmp))
9252 inner_vlan_id = tmp;
9254 #define _(a) else if (unformat (i, #a)) a = 1 ;
9255 foreach_create_subif_bit
9259 clib_warning ("parse error '%U'", format_unformat_error, i);
9264 if (sw_if_index_set == 0)
9266 errmsg ("missing interface name or sw_if_index");
9270 if (sub_id_set == 0)
9272 errmsg ("missing sub_id");
9275 M (CREATE_SUBIF, mp);
9277 mp->sw_if_index = ntohl (sw_if_index);
9278 mp->sub_id = ntohl (sub_id);
9280 #define _(a) mp->a = a;
9281 foreach_create_subif_bit;
9284 mp->outer_vlan_id = ntohs (outer_vlan_id);
9285 mp->inner_vlan_id = ntohs (inner_vlan_id);
9293 api_reset_fib (vat_main_t * vam)
9295 unformat_input_t *i = vam->input;
9296 vl_api_reset_fib_t *mp;
9302 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9304 if (unformat (i, "vrf %d", &vrf_id))
9306 else if (unformat (i, "ipv6"))
9310 clib_warning ("parse error '%U'", format_unformat_error, i);
9315 if (vrf_id_set == 0)
9317 errmsg ("missing vrf id");
9323 mp->vrf_id = ntohl (vrf_id);
9324 mp->is_ipv6 = is_ipv6;
9332 api_dhcp_proxy_config (vat_main_t * vam)
9334 unformat_input_t *i = vam->input;
9335 vl_api_dhcp_proxy_config_t *mp;
9337 u32 server_vrf_id = 0;
9339 u8 v4_address_set = 0;
9340 u8 v6_address_set = 0;
9341 ip4_address_t v4address;
9342 ip6_address_t v6address;
9343 u8 v4_src_address_set = 0;
9344 u8 v6_src_address_set = 0;
9345 ip4_address_t v4srcaddress;
9346 ip6_address_t v6srcaddress;
9349 /* Parse args required to build the message */
9350 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9352 if (unformat (i, "del"))
9354 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
9356 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
9358 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
9360 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
9362 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
9363 v4_src_address_set = 1;
9364 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
9365 v6_src_address_set = 1;
9370 if (v4_address_set && v6_address_set)
9372 errmsg ("both v4 and v6 server addresses set");
9375 if (!v4_address_set && !v6_address_set)
9377 errmsg ("no server addresses set");
9381 if (v4_src_address_set && v6_src_address_set)
9383 errmsg ("both v4 and v6 src addresses set");
9386 if (!v4_src_address_set && !v6_src_address_set)
9388 errmsg ("no src addresses set");
9392 if (!(v4_src_address_set && v4_address_set) &&
9393 !(v6_src_address_set && v6_address_set))
9395 errmsg ("no matching server and src addresses set");
9399 /* Construct the API message */
9400 M (DHCP_PROXY_CONFIG, mp);
9402 mp->is_add = is_add;
9403 mp->rx_vrf_id = ntohl (rx_vrf_id);
9404 mp->server_vrf_id = ntohl (server_vrf_id);
9408 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
9409 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
9413 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
9414 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
9420 /* Wait for a reply, return good/bad news */
9425 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
9426 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
9429 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
9431 vat_main_t *vam = &vat_main;
9432 u32 i, count = mp->count;
9433 vl_api_dhcp_server_t *s;
9437 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9438 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9439 ntohl (mp->rx_vrf_id),
9440 format_ip6_address, mp->dhcp_src_address,
9441 mp->vss_type, mp->vss_vpn_ascii_id,
9442 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9445 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9446 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9447 ntohl (mp->rx_vrf_id),
9448 format_ip4_address, mp->dhcp_src_address,
9449 mp->vss_type, mp->vss_vpn_ascii_id,
9450 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9452 for (i = 0; i < count; i++)
9454 s = &mp->servers[i];
9458 " Server Table-ID %d, Server Address %U",
9459 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
9462 " Server Table-ID %d, Server Address %U",
9463 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
9467 static void vl_api_dhcp_proxy_details_t_handler_json
9468 (vl_api_dhcp_proxy_details_t * mp)
9470 vat_main_t *vam = &vat_main;
9471 vat_json_node_t *node = NULL;
9472 u32 i, count = mp->count;
9474 struct in6_addr ip6;
9475 vl_api_dhcp_server_t *s;
9477 if (VAT_JSON_ARRAY != vam->json_tree.type)
9479 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9480 vat_json_init_array (&vam->json_tree);
9482 node = vat_json_array_add (&vam->json_tree);
9484 vat_json_init_object (node);
9485 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
9486 vat_json_object_add_bytes (node, "vss-type", &mp->vss_type,
9487 sizeof (mp->vss_type));
9488 vat_json_object_add_string_copy (node, "vss-vpn-ascii-id",
9489 mp->vss_vpn_ascii_id);
9490 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
9491 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
9495 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
9496 vat_json_object_add_ip6 (node, "src_address", ip6);
9500 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
9501 vat_json_object_add_ip4 (node, "src_address", ip4);
9504 for (i = 0; i < count; i++)
9506 s = &mp->servers[i];
9508 vat_json_object_add_uint (node, "server-table-id",
9509 ntohl (s->server_vrf_id));
9513 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
9514 vat_json_object_add_ip4 (node, "src_address", ip4);
9518 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
9519 vat_json_object_add_ip6 (node, "server_address", ip6);
9525 api_dhcp_proxy_dump (vat_main_t * vam)
9527 unformat_input_t *i = vam->input;
9528 vl_api_control_ping_t *mp_ping;
9529 vl_api_dhcp_proxy_dump_t *mp;
9533 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9535 if (unformat (i, "ipv6"))
9539 clib_warning ("parse error '%U'", format_unformat_error, i);
9544 M (DHCP_PROXY_DUMP, mp);
9546 mp->is_ip6 = is_ipv6;
9549 /* Use a control ping for synchronization */
9550 MPING (CONTROL_PING, mp_ping);
9558 api_dhcp_proxy_set_vss (vat_main_t * vam)
9560 unformat_input_t *i = vam->input;
9561 vl_api_dhcp_proxy_set_vss_t *mp;
9565 u8 vss_type = VSS_TYPE_DEFAULT;
9566 u8 *vpn_ascii_id = 0;
9571 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9573 if (unformat (i, "tbl_id %d", &tbl_id))
9575 else if (unformat (i, "vpn_ascii_id %s", &vpn_ascii_id))
9576 vss_type = VSS_TYPE_ASCII;
9577 else if (unformat (i, "fib_id %d", &fib_id))
9578 vss_type = VSS_TYPE_VPN_ID;
9579 else if (unformat (i, "oui %d", &oui))
9580 vss_type = VSS_TYPE_VPN_ID;
9581 else if (unformat (i, "ipv6"))
9583 else if (unformat (i, "del"))
9591 errmsg ("missing tbl_id ");
9592 vec_free (vpn_ascii_id);
9596 if ((vpn_ascii_id) && (vec_len (vpn_ascii_id) > 128))
9598 errmsg ("vpn_ascii_id cannot be longer than 128 ");
9599 vec_free (vpn_ascii_id);
9603 M (DHCP_PROXY_SET_VSS, mp);
9604 mp->tbl_id = ntohl (tbl_id);
9605 mp->vss_type = vss_type;
9608 clib_memcpy (mp->vpn_ascii_id, vpn_ascii_id, vec_len (vpn_ascii_id));
9609 mp->vpn_ascii_id[vec_len (vpn_ascii_id)] = 0;
9611 mp->vpn_index = ntohl (fib_id);
9612 mp->oui = ntohl (oui);
9613 mp->is_ipv6 = is_ipv6;
9614 mp->is_add = is_add;
9619 vec_free (vpn_ascii_id);
9624 api_dhcp_client_config (vat_main_t * vam)
9626 unformat_input_t *i = vam->input;
9627 vl_api_dhcp_client_config_t *mp;
9629 u8 sw_if_index_set = 0;
9632 u8 disable_event = 0;
9635 /* Parse args required to build the message */
9636 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9638 if (unformat (i, "del"))
9641 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9642 sw_if_index_set = 1;
9643 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9644 sw_if_index_set = 1;
9645 else if (unformat (i, "hostname %s", &hostname))
9647 else if (unformat (i, "disable_event"))
9653 if (sw_if_index_set == 0)
9655 errmsg ("missing interface name or sw_if_index");
9659 if (vec_len (hostname) > 63)
9661 errmsg ("hostname too long");
9663 vec_add1 (hostname, 0);
9665 /* Construct the API message */
9666 M (DHCP_CLIENT_CONFIG, mp);
9668 mp->is_add = is_add;
9669 mp->client.sw_if_index = htonl (sw_if_index);
9670 clib_memcpy (mp->client.hostname, hostname, vec_len (hostname));
9671 vec_free (hostname);
9672 mp->client.want_dhcp_event = disable_event ? 0 : 1;
9673 mp->client.pid = htonl (getpid ());
9678 /* Wait for a reply, return good/bad news */
9684 api_set_ip_flow_hash (vat_main_t * vam)
9686 unformat_input_t *i = vam->input;
9687 vl_api_set_ip_flow_hash_t *mp;
9699 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9701 if (unformat (i, "vrf %d", &vrf_id))
9703 else if (unformat (i, "ipv6"))
9705 else if (unformat (i, "src"))
9707 else if (unformat (i, "dst"))
9709 else if (unformat (i, "sport"))
9711 else if (unformat (i, "dport"))
9713 else if (unformat (i, "proto"))
9715 else if (unformat (i, "reverse"))
9720 clib_warning ("parse error '%U'", format_unformat_error, i);
9725 if (vrf_id_set == 0)
9727 errmsg ("missing vrf id");
9731 M (SET_IP_FLOW_HASH, mp);
9737 mp->reverse = reverse;
9738 mp->vrf_id = ntohl (vrf_id);
9739 mp->is_ipv6 = is_ipv6;
9747 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
9749 unformat_input_t *i = vam->input;
9750 vl_api_sw_interface_ip6_enable_disable_t *mp;
9752 u8 sw_if_index_set = 0;
9756 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9758 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9759 sw_if_index_set = 1;
9760 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9761 sw_if_index_set = 1;
9762 else if (unformat (i, "enable"))
9764 else if (unformat (i, "disable"))
9768 clib_warning ("parse error '%U'", format_unformat_error, i);
9773 if (sw_if_index_set == 0)
9775 errmsg ("missing interface name or sw_if_index");
9779 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
9781 mp->sw_if_index = ntohl (sw_if_index);
9782 mp->enable = enable;
9790 api_ip6nd_proxy_add_del (vat_main_t * vam)
9792 unformat_input_t *i = vam->input;
9793 vl_api_ip6nd_proxy_add_del_t *mp;
9794 u32 sw_if_index = ~0;
9795 u8 v6_address_set = 0;
9796 vl_api_ip6_address_t v6address;
9800 /* Parse args required to build the message */
9801 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9803 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9805 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9807 else if (unformat (i, "%U", unformat_vl_api_ip6_address, &v6address))
9809 if (unformat (i, "del"))
9813 clib_warning ("parse error '%U'", format_unformat_error, i);
9818 if (sw_if_index == ~0)
9820 errmsg ("missing interface name or sw_if_index");
9823 if (!v6_address_set)
9825 errmsg ("no address set");
9829 /* Construct the API message */
9830 M (IP6ND_PROXY_ADD_DEL, mp);
9832 mp->is_del = is_del;
9833 mp->sw_if_index = ntohl (sw_if_index);
9834 clib_memcpy (mp->ip, v6address, sizeof (v6address));
9839 /* Wait for a reply, return good/bad news */
9845 api_ip6nd_proxy_dump (vat_main_t * vam)
9847 vl_api_ip6nd_proxy_dump_t *mp;
9848 vl_api_control_ping_t *mp_ping;
9851 M (IP6ND_PROXY_DUMP, mp);
9855 /* Use a control ping for synchronization */
9856 MPING (CONTROL_PING, mp_ping);
9863 static void vl_api_ip6nd_proxy_details_t_handler
9864 (vl_api_ip6nd_proxy_details_t * mp)
9866 vat_main_t *vam = &vat_main;
9868 print (vam->ofp, "host %U sw_if_index %d",
9869 format_vl_api_ip6_address, mp->ip, ntohl (mp->sw_if_index));
9872 static void vl_api_ip6nd_proxy_details_t_handler_json
9873 (vl_api_ip6nd_proxy_details_t * mp)
9875 vat_main_t *vam = &vat_main;
9876 struct in6_addr ip6;
9877 vat_json_node_t *node = NULL;
9879 if (VAT_JSON_ARRAY != vam->json_tree.type)
9881 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9882 vat_json_init_array (&vam->json_tree);
9884 node = vat_json_array_add (&vam->json_tree);
9886 vat_json_init_object (node);
9887 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9889 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
9890 vat_json_object_add_ip6 (node, "host", ip6);
9894 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
9896 unformat_input_t *i = vam->input;
9897 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
9899 u8 sw_if_index_set = 0;
9900 u8 v6_address_set = 0;
9901 vl_api_prefix_t pfx;
9903 u8 no_advertise = 0;
9905 u8 no_autoconfig = 0;
9908 u32 val_lifetime = 0;
9909 u32 pref_lifetime = 0;
9912 /* Parse args required to build the message */
9913 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9915 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9916 sw_if_index_set = 1;
9917 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9918 sw_if_index_set = 1;
9919 else if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
9921 else if (unformat (i, "val_life %d", &val_lifetime))
9923 else if (unformat (i, "pref_life %d", &pref_lifetime))
9925 else if (unformat (i, "def"))
9927 else if (unformat (i, "noadv"))
9929 else if (unformat (i, "offl"))
9931 else if (unformat (i, "noauto"))
9933 else if (unformat (i, "nolink"))
9935 else if (unformat (i, "isno"))
9939 clib_warning ("parse error '%U'", format_unformat_error, i);
9944 if (sw_if_index_set == 0)
9946 errmsg ("missing interface name or sw_if_index");
9949 if (!v6_address_set)
9951 errmsg ("no address set");
9955 /* Construct the API message */
9956 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
9958 mp->sw_if_index = ntohl (sw_if_index);
9959 clib_memcpy (&mp->prefix, &pfx, sizeof (pfx));
9960 mp->use_default = use_default;
9961 mp->no_advertise = no_advertise;
9962 mp->off_link = off_link;
9963 mp->no_autoconfig = no_autoconfig;
9964 mp->no_onlink = no_onlink;
9966 mp->val_lifetime = ntohl (val_lifetime);
9967 mp->pref_lifetime = ntohl (pref_lifetime);
9972 /* Wait for a reply, return good/bad news */
9978 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
9980 unformat_input_t *i = vam->input;
9981 vl_api_sw_interface_ip6nd_ra_config_t *mp;
9983 u8 sw_if_index_set = 0;
9988 u8 send_unicast = 0;
9991 u8 default_router = 0;
9992 u32 max_interval = 0;
9993 u32 min_interval = 0;
9995 u32 initial_count = 0;
9996 u32 initial_interval = 0;
10000 /* Parse args required to build the message */
10001 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10003 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10004 sw_if_index_set = 1;
10005 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10006 sw_if_index_set = 1;
10007 else if (unformat (i, "maxint %d", &max_interval))
10009 else if (unformat (i, "minint %d", &min_interval))
10011 else if (unformat (i, "life %d", &lifetime))
10013 else if (unformat (i, "count %d", &initial_count))
10015 else if (unformat (i, "interval %d", &initial_interval))
10017 else if (unformat (i, "suppress") || unformat (i, "surpress"))
10019 else if (unformat (i, "managed"))
10021 else if (unformat (i, "other"))
10023 else if (unformat (i, "ll"))
10025 else if (unformat (i, "send"))
10027 else if (unformat (i, "cease"))
10029 else if (unformat (i, "isno"))
10031 else if (unformat (i, "def"))
10032 default_router = 1;
10035 clib_warning ("parse error '%U'", format_unformat_error, i);
10040 if (sw_if_index_set == 0)
10042 errmsg ("missing interface name or sw_if_index");
10046 /* Construct the API message */
10047 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
10049 mp->sw_if_index = ntohl (sw_if_index);
10050 mp->max_interval = ntohl (max_interval);
10051 mp->min_interval = ntohl (min_interval);
10052 mp->lifetime = ntohl (lifetime);
10053 mp->initial_count = ntohl (initial_count);
10054 mp->initial_interval = ntohl (initial_interval);
10055 mp->suppress = suppress;
10056 mp->managed = managed;
10058 mp->ll_option = ll_option;
10059 mp->send_unicast = send_unicast;
10062 mp->default_router = default_router;
10067 /* Wait for a reply, return good/bad news */
10073 api_set_arp_neighbor_limit (vat_main_t * vam)
10075 unformat_input_t *i = vam->input;
10076 vl_api_set_arp_neighbor_limit_t *mp;
10082 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10084 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
10086 else if (unformat (i, "ipv6"))
10090 clib_warning ("parse error '%U'", format_unformat_error, i);
10095 if (limit_set == 0)
10097 errmsg ("missing limit value");
10101 M (SET_ARP_NEIGHBOR_LIMIT, mp);
10103 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
10104 mp->is_ipv6 = is_ipv6;
10112 api_l2_patch_add_del (vat_main_t * vam)
10114 unformat_input_t *i = vam->input;
10115 vl_api_l2_patch_add_del_t *mp;
10116 u32 rx_sw_if_index;
10117 u8 rx_sw_if_index_set = 0;
10118 u32 tx_sw_if_index;
10119 u8 tx_sw_if_index_set = 0;
10123 /* Parse args required to build the message */
10124 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10126 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
10127 rx_sw_if_index_set = 1;
10128 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
10129 tx_sw_if_index_set = 1;
10130 else if (unformat (i, "rx"))
10132 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10134 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10136 rx_sw_if_index_set = 1;
10141 else if (unformat (i, "tx"))
10143 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10145 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10147 tx_sw_if_index_set = 1;
10152 else if (unformat (i, "del"))
10158 if (rx_sw_if_index_set == 0)
10160 errmsg ("missing rx interface name or rx_sw_if_index");
10164 if (tx_sw_if_index_set == 0)
10166 errmsg ("missing tx interface name or tx_sw_if_index");
10170 M (L2_PATCH_ADD_DEL, mp);
10172 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
10173 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
10174 mp->is_add = is_add;
10182 u8 localsid_addr[16];
10191 api_sr_localsid_add_del (vat_main_t * vam)
10193 unformat_input_t *i = vam->input;
10194 vl_api_sr_localsid_add_del_t *mp;
10197 ip6_address_t localsid;
10201 u32 fib_table = ~(u32) 0;
10202 ip6_address_t nh_addr6;
10203 ip4_address_t nh_addr4;
10204 clib_memset (&nh_addr6, 0, sizeof (ip6_address_t));
10205 clib_memset (&nh_addr4, 0, sizeof (ip4_address_t));
10207 bool nexthop_set = 0;
10211 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10213 if (unformat (i, "del"))
10215 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
10216 else if (unformat (i, "next-hop %U", unformat_ip4_address, &nh_addr4))
10218 else if (unformat (i, "next-hop %U", unformat_ip6_address, &nh_addr6))
10220 else if (unformat (i, "behavior %u", &behavior));
10221 else if (unformat (i, "sw_if_index %u", &sw_if_index));
10222 else if (unformat (i, "fib-table %u", &fib_table));
10223 else if (unformat (i, "end.psp %u", &behavior));
10228 M (SR_LOCALSID_ADD_DEL, mp);
10230 clib_memcpy (mp->localsid.addr, &localsid, sizeof (mp->localsid));
10233 clib_memcpy (mp->nh_addr6, &nh_addr6, sizeof (mp->nh_addr6));
10234 clib_memcpy (mp->nh_addr4, &nh_addr4, sizeof (mp->nh_addr4));
10236 mp->behavior = behavior;
10237 mp->sw_if_index = ntohl (sw_if_index);
10238 mp->fib_table = ntohl (fib_table);
10239 mp->end_psp = end_psp;
10240 mp->is_del = is_del;
10248 api_ioam_enable (vat_main_t * vam)
10250 unformat_input_t *input = vam->input;
10251 vl_api_ioam_enable_t *mp;
10253 int has_trace_option = 0;
10254 int has_pot_option = 0;
10255 int has_seqno_option = 0;
10256 int has_analyse_option = 0;
10259 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10261 if (unformat (input, "trace"))
10262 has_trace_option = 1;
10263 else if (unformat (input, "pot"))
10264 has_pot_option = 1;
10265 else if (unformat (input, "seqno"))
10266 has_seqno_option = 1;
10267 else if (unformat (input, "analyse"))
10268 has_analyse_option = 1;
10272 M (IOAM_ENABLE, mp);
10273 mp->id = htons (id);
10274 mp->seqno = has_seqno_option;
10275 mp->analyse = has_analyse_option;
10276 mp->pot_enable = has_pot_option;
10277 mp->trace_enable = has_trace_option;
10286 api_ioam_disable (vat_main_t * vam)
10288 vl_api_ioam_disable_t *mp;
10291 M (IOAM_DISABLE, mp);
10297 #define foreach_tcp_proto_field \
10301 #define foreach_udp_proto_field \
10305 #define foreach_ip4_proto_field \
10317 u16 src_port, dst_port;
10320 #if VPP_API_TEST_BUILTIN == 0
10322 unformat_tcp_mask (unformat_input_t * input, va_list * args)
10324 u8 **maskp = va_arg (*args, u8 **);
10326 u8 found_something = 0;
10329 #define _(a) u8 a=0;
10330 foreach_tcp_proto_field;
10333 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10336 #define _(a) else if (unformat (input, #a)) a=1;
10337 foreach_tcp_proto_field
10343 #define _(a) found_something += a;
10344 foreach_tcp_proto_field;
10347 if (found_something == 0)
10350 vec_validate (mask, sizeof (*tcp) - 1);
10352 tcp = (tcp_header_t *) mask;
10354 #define _(a) if (a) clib_memset (&tcp->a, 0xff, sizeof (tcp->a));
10355 foreach_tcp_proto_field;
10363 unformat_udp_mask (unformat_input_t * input, va_list * args)
10365 u8 **maskp = va_arg (*args, u8 **);
10367 u8 found_something = 0;
10370 #define _(a) u8 a=0;
10371 foreach_udp_proto_field;
10374 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10377 #define _(a) else if (unformat (input, #a)) a=1;
10378 foreach_udp_proto_field
10384 #define _(a) found_something += a;
10385 foreach_udp_proto_field;
10388 if (found_something == 0)
10391 vec_validate (mask, sizeof (*udp) - 1);
10393 udp = (udp_header_t *) mask;
10395 #define _(a) if (a) clib_memset (&udp->a, 0xff, sizeof (udp->a));
10396 foreach_udp_proto_field;
10404 unformat_l4_mask (unformat_input_t * input, va_list * args)
10406 u8 **maskp = va_arg (*args, u8 **);
10407 u16 src_port = 0, dst_port = 0;
10408 tcpudp_header_t *tcpudp;
10410 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10412 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
10414 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
10416 else if (unformat (input, "src_port"))
10418 else if (unformat (input, "dst_port"))
10424 if (!src_port && !dst_port)
10428 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
10430 tcpudp = (tcpudp_header_t *) mask;
10431 tcpudp->src_port = src_port;
10432 tcpudp->dst_port = dst_port;
10440 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10442 u8 **maskp = va_arg (*args, u8 **);
10444 u8 found_something = 0;
10447 #define _(a) u8 a=0;
10448 foreach_ip4_proto_field;
10454 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10456 if (unformat (input, "version"))
10458 else if (unformat (input, "hdr_length"))
10460 else if (unformat (input, "src"))
10462 else if (unformat (input, "dst"))
10464 else if (unformat (input, "proto"))
10467 #define _(a) else if (unformat (input, #a)) a=1;
10468 foreach_ip4_proto_field
10474 #define _(a) found_something += a;
10475 foreach_ip4_proto_field;
10478 if (found_something == 0)
10481 vec_validate (mask, sizeof (*ip) - 1);
10483 ip = (ip4_header_t *) mask;
10485 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
10486 foreach_ip4_proto_field;
10489 ip->ip_version_and_header_length = 0;
10492 ip->ip_version_and_header_length |= 0xF0;
10495 ip->ip_version_and_header_length |= 0x0F;
10501 #define foreach_ip6_proto_field \
10504 _(payload_length) \
10509 unformat_ip6_mask (unformat_input_t * input, va_list * args)
10511 u8 **maskp = va_arg (*args, u8 **);
10513 u8 found_something = 0;
10515 u32 ip_version_traffic_class_and_flow_label;
10517 #define _(a) u8 a=0;
10518 foreach_ip6_proto_field;
10521 u8 traffic_class = 0;
10524 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10526 if (unformat (input, "version"))
10528 else if (unformat (input, "traffic-class"))
10530 else if (unformat (input, "flow-label"))
10532 else if (unformat (input, "src"))
10534 else if (unformat (input, "dst"))
10536 else if (unformat (input, "proto"))
10539 #define _(a) else if (unformat (input, #a)) a=1;
10540 foreach_ip6_proto_field
10546 #define _(a) found_something += a;
10547 foreach_ip6_proto_field;
10550 if (found_something == 0)
10553 vec_validate (mask, sizeof (*ip) - 1);
10555 ip = (ip6_header_t *) mask;
10557 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
10558 foreach_ip6_proto_field;
10561 ip_version_traffic_class_and_flow_label = 0;
10564 ip_version_traffic_class_and_flow_label |= 0xF0000000;
10567 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
10570 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
10572 ip->ip_version_traffic_class_and_flow_label =
10573 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10580 unformat_l3_mask (unformat_input_t * input, va_list * args)
10582 u8 **maskp = va_arg (*args, u8 **);
10584 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10586 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
10588 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
10597 unformat_l2_mask (unformat_input_t * input, va_list * args)
10599 u8 **maskp = va_arg (*args, u8 **);
10606 u8 ignore_tag1 = 0;
10607 u8 ignore_tag2 = 0;
10614 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10616 if (unformat (input, "src"))
10618 else if (unformat (input, "dst"))
10620 else if (unformat (input, "proto"))
10622 else if (unformat (input, "tag1"))
10624 else if (unformat (input, "tag2"))
10626 else if (unformat (input, "ignore-tag1"))
10628 else if (unformat (input, "ignore-tag2"))
10630 else if (unformat (input, "cos1"))
10632 else if (unformat (input, "cos2"))
10634 else if (unformat (input, "dot1q"))
10636 else if (unformat (input, "dot1ad"))
10641 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
10642 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10645 if (tag1 || ignore_tag1 || cos1 || dot1q)
10647 if (tag2 || ignore_tag2 || cos2 || dot1ad)
10650 vec_validate (mask, len - 1);
10653 clib_memset (mask, 0xff, 6);
10656 clib_memset (mask + 6, 0xff, 6);
10658 if (tag2 || dot1ad)
10660 /* inner vlan tag */
10669 mask[21] = mask[20] = 0xff;
10690 mask[16] = mask[17] = 0xff;
10700 mask[12] = mask[13] = 0xff;
10707 unformat_classify_mask (unformat_input_t * input, va_list * args)
10709 u8 **maskp = va_arg (*args, u8 **);
10710 u32 *skipp = va_arg (*args, u32 *);
10711 u32 *matchp = va_arg (*args, u32 *);
10719 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10721 if (unformat (input, "hex %U", unformat_hex_string, &mask))
10723 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
10725 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
10727 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
10741 if (mask || l2 || l3 || l4)
10743 if (l2 || l3 || l4)
10745 /* "With a free Ethernet header in every package" */
10747 vec_validate (l2, 13);
10751 vec_append (mask, l3);
10756 vec_append (mask, l4);
10761 /* Scan forward looking for the first significant mask octet */
10762 for (i = 0; i < vec_len (mask); i++)
10766 /* compute (skip, match) params */
10767 *skipp = i / sizeof (u32x4);
10768 vec_delete (mask, *skipp * sizeof (u32x4), 0);
10770 /* Pad mask to an even multiple of the vector size */
10771 while (vec_len (mask) % sizeof (u32x4))
10772 vec_add1 (mask, 0);
10774 match = vec_len (mask) / sizeof (u32x4);
10776 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
10778 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
10779 if (*tmp || *(tmp + 1))
10784 clib_warning ("BUG: match 0");
10786 _vec_len (mask) = match * sizeof (u32x4);
10796 #endif /* VPP_API_TEST_BUILTIN */
10798 #define foreach_l2_next \
10800 _(ethernet, ETHERNET_INPUT) \
10801 _(ip4, IP4_INPUT) \
10805 unformat_l2_next_index (unformat_input_t * input, va_list * args)
10807 u32 *miss_next_indexp = va_arg (*args, u32 *);
10808 u32 next_index = 0;
10812 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
10816 if (unformat (input, "%d", &tmp))
10825 *miss_next_indexp = next_index;
10829 #define foreach_ip_next \
10832 _(rewrite, REWRITE)
10835 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
10837 u32 *miss_next_indexp = va_arg (*args, u32 *);
10838 u32 next_index = 0;
10842 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
10846 if (unformat (input, "%d", &tmp))
10855 *miss_next_indexp = next_index;
10859 #define foreach_acl_next \
10863 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
10865 u32 *miss_next_indexp = va_arg (*args, u32 *);
10866 u32 next_index = 0;
10870 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
10874 if (unformat (input, "permit"))
10879 else if (unformat (input, "%d", &tmp))
10888 *miss_next_indexp = next_index;
10893 unformat_policer_precolor (unformat_input_t * input, va_list * args)
10895 u32 *r = va_arg (*args, u32 *);
10897 if (unformat (input, "conform-color"))
10898 *r = POLICE_CONFORM;
10899 else if (unformat (input, "exceed-color"))
10900 *r = POLICE_EXCEED;
10908 api_classify_add_del_table (vat_main_t * vam)
10910 unformat_input_t *i = vam->input;
10911 vl_api_classify_add_del_table_t *mp;
10918 u32 table_index = ~0;
10919 u32 next_table_index = ~0;
10920 u32 miss_next_index = ~0;
10921 u32 memory_size = 32 << 20;
10923 u32 current_data_flag = 0;
10924 int current_data_offset = 0;
10927 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10929 if (unformat (i, "del"))
10931 else if (unformat (i, "del-chain"))
10936 else if (unformat (i, "buckets %d", &nbuckets))
10938 else if (unformat (i, "memory_size %d", &memory_size))
10940 else if (unformat (i, "skip %d", &skip))
10942 else if (unformat (i, "match %d", &match))
10944 else if (unformat (i, "table %d", &table_index))
10946 else if (unformat (i, "mask %U", unformat_classify_mask,
10947 &mask, &skip, &match))
10949 else if (unformat (i, "next-table %d", &next_table_index))
10951 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
10954 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
10957 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
10960 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
10962 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
10968 if (is_add && mask == 0)
10970 errmsg ("Mask required");
10974 if (is_add && skip == ~0)
10976 errmsg ("skip count required");
10980 if (is_add && match == ~0)
10982 errmsg ("match count required");
10986 if (!is_add && table_index == ~0)
10988 errmsg ("table index required for delete");
10992 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
10994 mp->is_add = is_add;
10995 mp->del_chain = del_chain;
10996 mp->table_index = ntohl (table_index);
10997 mp->nbuckets = ntohl (nbuckets);
10998 mp->memory_size = ntohl (memory_size);
10999 mp->skip_n_vectors = ntohl (skip);
11000 mp->match_n_vectors = ntohl (match);
11001 mp->next_table_index = ntohl (next_table_index);
11002 mp->miss_next_index = ntohl (miss_next_index);
11003 mp->current_data_flag = ntohl (current_data_flag);
11004 mp->current_data_offset = ntohl (current_data_offset);
11005 mp->mask_len = ntohl (vec_len (mask));
11006 clib_memcpy (mp->mask, mask, vec_len (mask));
11015 #if VPP_API_TEST_BUILTIN == 0
11017 unformat_l4_match (unformat_input_t * input, va_list * args)
11019 u8 **matchp = va_arg (*args, u8 **);
11021 u8 *proto_header = 0;
11027 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11029 if (unformat (input, "src_port %d", &src_port))
11031 else if (unformat (input, "dst_port %d", &dst_port))
11037 h.src_port = clib_host_to_net_u16 (src_port);
11038 h.dst_port = clib_host_to_net_u16 (dst_port);
11039 vec_validate (proto_header, sizeof (h) - 1);
11040 memcpy (proto_header, &h, sizeof (h));
11042 *matchp = proto_header;
11048 unformat_ip4_match (unformat_input_t * input, va_list * args)
11050 u8 **matchp = va_arg (*args, u8 **);
11055 int hdr_length = 0;
11056 u32 hdr_length_val;
11057 int src = 0, dst = 0;
11058 ip4_address_t src_val, dst_val;
11065 int fragment_id = 0;
11066 u32 fragment_id_val;
11072 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11074 if (unformat (input, "version %d", &version_val))
11076 else if (unformat (input, "hdr_length %d", &hdr_length_val))
11078 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
11080 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
11082 else if (unformat (input, "proto %d", &proto_val))
11084 else if (unformat (input, "tos %d", &tos_val))
11086 else if (unformat (input, "length %d", &length_val))
11088 else if (unformat (input, "fragment_id %d", &fragment_id_val))
11090 else if (unformat (input, "ttl %d", &ttl_val))
11092 else if (unformat (input, "checksum %d", &checksum_val))
11098 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
11099 + ttl + checksum == 0)
11103 * Aligned because we use the real comparison functions
11105 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11107 ip = (ip4_header_t *) match;
11109 /* These are realistically matched in practice */
11111 ip->src_address.as_u32 = src_val.as_u32;
11114 ip->dst_address.as_u32 = dst_val.as_u32;
11117 ip->protocol = proto_val;
11120 /* These are not, but they're included for completeness */
11122 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
11125 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
11131 ip->length = clib_host_to_net_u16 (length_val);
11137 ip->checksum = clib_host_to_net_u16 (checksum_val);
11144 unformat_ip6_match (unformat_input_t * input, va_list * args)
11146 u8 **matchp = va_arg (*args, u8 **);
11151 u8 traffic_class = 0;
11152 u32 traffic_class_val = 0;
11155 int src = 0, dst = 0;
11156 ip6_address_t src_val, dst_val;
11159 int payload_length = 0;
11160 u32 payload_length_val;
11163 u32 ip_version_traffic_class_and_flow_label;
11165 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11167 if (unformat (input, "version %d", &version_val))
11169 else if (unformat (input, "traffic_class %d", &traffic_class_val))
11171 else if (unformat (input, "flow_label %d", &flow_label_val))
11173 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
11175 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
11177 else if (unformat (input, "proto %d", &proto_val))
11179 else if (unformat (input, "payload_length %d", &payload_length_val))
11180 payload_length = 1;
11181 else if (unformat (input, "hop_limit %d", &hop_limit_val))
11187 if (version + traffic_class + flow_label + src + dst + proto +
11188 payload_length + hop_limit == 0)
11192 * Aligned because we use the real comparison functions
11194 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11196 ip = (ip6_header_t *) match;
11199 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
11202 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
11205 ip->protocol = proto_val;
11207 ip_version_traffic_class_and_flow_label = 0;
11210 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
11213 ip_version_traffic_class_and_flow_label |=
11214 (traffic_class_val & 0xFF) << 20;
11217 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
11219 ip->ip_version_traffic_class_and_flow_label =
11220 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11222 if (payload_length)
11223 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
11226 ip->hop_limit = hop_limit_val;
11233 unformat_l3_match (unformat_input_t * input, va_list * args)
11235 u8 **matchp = va_arg (*args, u8 **);
11237 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11239 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
11241 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
11250 unformat_vlan_tag (unformat_input_t * input, va_list * args)
11252 u8 *tagp = va_arg (*args, u8 *);
11255 if (unformat (input, "%d", &tag))
11257 tagp[0] = (tag >> 8) & 0x0F;
11258 tagp[1] = tag & 0xFF;
11266 unformat_l2_match (unformat_input_t * input, va_list * args)
11268 u8 **matchp = va_arg (*args, u8 **);
11281 u8 ignore_tag1 = 0;
11282 u8 ignore_tag2 = 0;
11288 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11290 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
11293 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
11295 else if (unformat (input, "proto %U",
11296 unformat_ethernet_type_host_byte_order, &proto_val))
11298 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
11300 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
11302 else if (unformat (input, "ignore-tag1"))
11304 else if (unformat (input, "ignore-tag2"))
11306 else if (unformat (input, "cos1 %d", &cos1_val))
11308 else if (unformat (input, "cos2 %d", &cos2_val))
11313 if ((src + dst + proto + tag1 + tag2 +
11314 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11317 if (tag1 || ignore_tag1 || cos1)
11319 if (tag2 || ignore_tag2 || cos2)
11322 vec_validate_aligned (match, len - 1, sizeof (u32x4));
11325 clib_memcpy (match, dst_val, 6);
11328 clib_memcpy (match + 6, src_val, 6);
11332 /* inner vlan tag */
11333 match[19] = tag2_val[1];
11334 match[18] = tag2_val[0];
11336 match[18] |= (cos2_val & 0x7) << 5;
11339 match[21] = proto_val & 0xff;
11340 match[20] = proto_val >> 8;
11344 match[15] = tag1_val[1];
11345 match[14] = tag1_val[0];
11348 match[14] |= (cos1_val & 0x7) << 5;
11354 match[15] = tag1_val[1];
11355 match[14] = tag1_val[0];
11358 match[17] = proto_val & 0xff;
11359 match[16] = proto_val >> 8;
11362 match[14] |= (cos1_val & 0x7) << 5;
11368 match[18] |= (cos2_val & 0x7) << 5;
11370 match[14] |= (cos1_val & 0x7) << 5;
11373 match[13] = proto_val & 0xff;
11374 match[12] = proto_val >> 8;
11382 unformat_qos_source (unformat_input_t * input, va_list * args)
11384 int *qs = va_arg (*args, int *);
11386 if (unformat (input, "ip"))
11387 *qs = QOS_SOURCE_IP;
11388 else if (unformat (input, "mpls"))
11389 *qs = QOS_SOURCE_MPLS;
11390 else if (unformat (input, "ext"))
11391 *qs = QOS_SOURCE_EXT;
11392 else if (unformat (input, "vlan"))
11393 *qs = QOS_SOURCE_VLAN;
11402 api_unformat_classify_match (unformat_input_t * input, va_list * args)
11404 u8 **matchp = va_arg (*args, u8 **);
11405 u32 skip_n_vectors = va_arg (*args, u32);
11406 u32 match_n_vectors = va_arg (*args, u32);
11413 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11415 if (unformat (input, "hex %U", unformat_hex_string, &match))
11417 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
11419 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
11421 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11435 if (match || l2 || l3 || l4)
11437 if (l2 || l3 || l4)
11439 /* "Win a free Ethernet header in every packet" */
11441 vec_validate_aligned (l2, 13, sizeof (u32x4));
11445 vec_append_aligned (match, l3, sizeof (u32x4));
11450 vec_append_aligned (match, l4, sizeof (u32x4));
11455 /* Make sure the vector is big enough even if key is all 0's */
11456 vec_validate_aligned
11457 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11460 /* Set size, include skipped vectors */
11461 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11472 api_classify_add_del_session (vat_main_t * vam)
11474 unformat_input_t *i = vam->input;
11475 vl_api_classify_add_del_session_t *mp;
11477 u32 table_index = ~0;
11478 u32 hit_next_index = ~0;
11479 u32 opaque_index = ~0;
11482 u32 skip_n_vectors = 0;
11483 u32 match_n_vectors = 0;
11489 * Warning: you have to supply skip_n and match_n
11490 * because the API client cant simply look at the classify
11494 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11496 if (unformat (i, "del"))
11498 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
11501 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
11504 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
11507 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
11509 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
11511 else if (unformat (i, "opaque-index %d", &opaque_index))
11513 else if (unformat (i, "skip_n %d", &skip_n_vectors))
11515 else if (unformat (i, "match_n %d", &match_n_vectors))
11517 else if (unformat (i, "match %U", api_unformat_classify_match,
11518 &match, skip_n_vectors, match_n_vectors))
11520 else if (unformat (i, "advance %d", &advance))
11522 else if (unformat (i, "table-index %d", &table_index))
11524 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
11526 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
11528 else if (unformat (i, "action %d", &action))
11530 else if (unformat (i, "metadata %d", &metadata))
11536 if (table_index == ~0)
11538 errmsg ("Table index required");
11542 if (is_add && match == 0)
11544 errmsg ("Match value required");
11548 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
11550 mp->is_add = is_add;
11551 mp->table_index = ntohl (table_index);
11552 mp->hit_next_index = ntohl (hit_next_index);
11553 mp->opaque_index = ntohl (opaque_index);
11554 mp->advance = ntohl (advance);
11555 mp->action = action;
11556 mp->metadata = ntohl (metadata);
11557 mp->match_len = ntohl (vec_len (match));
11558 clib_memcpy (mp->match, match, vec_len (match));
11567 api_classify_set_interface_ip_table (vat_main_t * vam)
11569 unformat_input_t *i = vam->input;
11570 vl_api_classify_set_interface_ip_table_t *mp;
11572 int sw_if_index_set;
11573 u32 table_index = ~0;
11577 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11579 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11580 sw_if_index_set = 1;
11581 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11582 sw_if_index_set = 1;
11583 else if (unformat (i, "table %d", &table_index))
11587 clib_warning ("parse error '%U'", format_unformat_error, i);
11592 if (sw_if_index_set == 0)
11594 errmsg ("missing interface name or sw_if_index");
11599 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
11601 mp->sw_if_index = ntohl (sw_if_index);
11602 mp->table_index = ntohl (table_index);
11603 mp->is_ipv6 = is_ipv6;
11611 api_classify_set_interface_l2_tables (vat_main_t * vam)
11613 unformat_input_t *i = vam->input;
11614 vl_api_classify_set_interface_l2_tables_t *mp;
11616 int sw_if_index_set;
11617 u32 ip4_table_index = ~0;
11618 u32 ip6_table_index = ~0;
11619 u32 other_table_index = ~0;
11623 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11625 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11626 sw_if_index_set = 1;
11627 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11628 sw_if_index_set = 1;
11629 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11631 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11633 else if (unformat (i, "other-table %d", &other_table_index))
11635 else if (unformat (i, "is-input %d", &is_input))
11639 clib_warning ("parse error '%U'", format_unformat_error, i);
11644 if (sw_if_index_set == 0)
11646 errmsg ("missing interface name or sw_if_index");
11651 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
11653 mp->sw_if_index = ntohl (sw_if_index);
11654 mp->ip4_table_index = ntohl (ip4_table_index);
11655 mp->ip6_table_index = ntohl (ip6_table_index);
11656 mp->other_table_index = ntohl (other_table_index);
11657 mp->is_input = (u8) is_input;
11665 api_set_ipfix_exporter (vat_main_t * vam)
11667 unformat_input_t *i = vam->input;
11668 vl_api_set_ipfix_exporter_t *mp;
11669 ip4_address_t collector_address;
11670 u8 collector_address_set = 0;
11671 u32 collector_port = ~0;
11672 ip4_address_t src_address;
11673 u8 src_address_set = 0;
11676 u32 template_interval = ~0;
11677 u8 udp_checksum = 0;
11680 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11682 if (unformat (i, "collector_address %U", unformat_ip4_address,
11683 &collector_address))
11684 collector_address_set = 1;
11685 else if (unformat (i, "collector_port %d", &collector_port))
11687 else if (unformat (i, "src_address %U", unformat_ip4_address,
11689 src_address_set = 1;
11690 else if (unformat (i, "vrf_id %d", &vrf_id))
11692 else if (unformat (i, "path_mtu %d", &path_mtu))
11694 else if (unformat (i, "template_interval %d", &template_interval))
11696 else if (unformat (i, "udp_checksum"))
11702 if (collector_address_set == 0)
11704 errmsg ("collector_address required");
11708 if (src_address_set == 0)
11710 errmsg ("src_address required");
11714 M (SET_IPFIX_EXPORTER, mp);
11716 memcpy (mp->collector_address, collector_address.data,
11717 sizeof (collector_address.data));
11718 mp->collector_port = htons ((u16) collector_port);
11719 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
11720 mp->vrf_id = htonl (vrf_id);
11721 mp->path_mtu = htonl (path_mtu);
11722 mp->template_interval = htonl (template_interval);
11723 mp->udp_checksum = udp_checksum;
11731 api_set_ipfix_classify_stream (vat_main_t * vam)
11733 unformat_input_t *i = vam->input;
11734 vl_api_set_ipfix_classify_stream_t *mp;
11736 u32 src_port = UDP_DST_PORT_ipfix;
11739 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11741 if (unformat (i, "domain %d", &domain_id))
11743 else if (unformat (i, "src_port %d", &src_port))
11747 errmsg ("unknown input `%U'", format_unformat_error, i);
11752 M (SET_IPFIX_CLASSIFY_STREAM, mp);
11754 mp->domain_id = htonl (domain_id);
11755 mp->src_port = htons ((u16) src_port);
11763 api_ipfix_classify_table_add_del (vat_main_t * vam)
11765 unformat_input_t *i = vam->input;
11766 vl_api_ipfix_classify_table_add_del_t *mp;
11768 u32 classify_table_index = ~0;
11770 u8 transport_protocol = 255;
11773 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11775 if (unformat (i, "add"))
11777 else if (unformat (i, "del"))
11779 else if (unformat (i, "table %d", &classify_table_index))
11781 else if (unformat (i, "ip4"))
11783 else if (unformat (i, "ip6"))
11785 else if (unformat (i, "tcp"))
11786 transport_protocol = 6;
11787 else if (unformat (i, "udp"))
11788 transport_protocol = 17;
11791 errmsg ("unknown input `%U'", format_unformat_error, i);
11798 errmsg ("expecting: add|del");
11801 if (classify_table_index == ~0)
11803 errmsg ("classifier table not specified");
11806 if (ip_version == 0)
11808 errmsg ("IP version not specified");
11812 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
11814 mp->is_add = is_add;
11815 mp->table_id = htonl (classify_table_index);
11816 mp->ip_version = ip_version;
11817 mp->transport_protocol = transport_protocol;
11825 api_get_node_index (vat_main_t * vam)
11827 unformat_input_t *i = vam->input;
11828 vl_api_get_node_index_t *mp;
11832 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11834 if (unformat (i, "node %s", &name))
11841 errmsg ("node name required");
11844 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11846 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11850 M (GET_NODE_INDEX, mp);
11851 clib_memcpy (mp->node_name, name, vec_len (name));
11860 api_get_next_index (vat_main_t * vam)
11862 unformat_input_t *i = vam->input;
11863 vl_api_get_next_index_t *mp;
11864 u8 *node_name = 0, *next_node_name = 0;
11867 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11869 if (unformat (i, "node-name %s", &node_name))
11871 else if (unformat (i, "next-node-name %s", &next_node_name))
11875 if (node_name == 0)
11877 errmsg ("node name required");
11880 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
11882 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11886 if (next_node_name == 0)
11888 errmsg ("next node name required");
11891 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
11893 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
11897 M (GET_NEXT_INDEX, mp);
11898 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
11899 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
11900 vec_free (node_name);
11901 vec_free (next_node_name);
11909 api_add_node_next (vat_main_t * vam)
11911 unformat_input_t *i = vam->input;
11912 vl_api_add_node_next_t *mp;
11917 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11919 if (unformat (i, "node %s", &name))
11921 else if (unformat (i, "next %s", &next))
11928 errmsg ("node name required");
11931 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11933 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11938 errmsg ("next node required");
11941 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
11943 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
11947 M (ADD_NODE_NEXT, mp);
11948 clib_memcpy (mp->node_name, name, vec_len (name));
11949 clib_memcpy (mp->next_name, next, vec_len (next));
11959 api_l2tpv3_create_tunnel (vat_main_t * vam)
11961 unformat_input_t *i = vam->input;
11962 ip6_address_t client_address, our_address;
11963 int client_address_set = 0;
11964 int our_address_set = 0;
11965 u32 local_session_id = 0;
11966 u32 remote_session_id = 0;
11967 u64 local_cookie = 0;
11968 u64 remote_cookie = 0;
11969 u8 l2_sublayer_present = 0;
11970 vl_api_l2tpv3_create_tunnel_t *mp;
11973 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11975 if (unformat (i, "client_address %U", unformat_ip6_address,
11977 client_address_set = 1;
11978 else if (unformat (i, "our_address %U", unformat_ip6_address,
11980 our_address_set = 1;
11981 else if (unformat (i, "local_session_id %d", &local_session_id))
11983 else if (unformat (i, "remote_session_id %d", &remote_session_id))
11985 else if (unformat (i, "local_cookie %lld", &local_cookie))
11987 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
11989 else if (unformat (i, "l2-sublayer-present"))
11990 l2_sublayer_present = 1;
11995 if (client_address_set == 0)
11997 errmsg ("client_address required");
12001 if (our_address_set == 0)
12003 errmsg ("our_address required");
12007 M (L2TPV3_CREATE_TUNNEL, mp);
12009 clib_memcpy (mp->client_address, client_address.as_u8,
12010 sizeof (mp->client_address));
12012 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
12014 mp->local_session_id = ntohl (local_session_id);
12015 mp->remote_session_id = ntohl (remote_session_id);
12016 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
12017 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
12018 mp->l2_sublayer_present = l2_sublayer_present;
12027 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
12029 unformat_input_t *i = vam->input;
12031 u8 sw_if_index_set = 0;
12032 u64 new_local_cookie = 0;
12033 u64 new_remote_cookie = 0;
12034 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
12037 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12039 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12040 sw_if_index_set = 1;
12041 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12042 sw_if_index_set = 1;
12043 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
12045 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
12051 if (sw_if_index_set == 0)
12053 errmsg ("missing interface name or sw_if_index");
12057 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
12059 mp->sw_if_index = ntohl (sw_if_index);
12060 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
12061 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
12069 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
12071 unformat_input_t *i = vam->input;
12072 vl_api_l2tpv3_interface_enable_disable_t *mp;
12074 u8 sw_if_index_set = 0;
12075 u8 enable_disable = 1;
12078 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12080 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12081 sw_if_index_set = 1;
12082 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12083 sw_if_index_set = 1;
12084 else if (unformat (i, "enable"))
12085 enable_disable = 1;
12086 else if (unformat (i, "disable"))
12087 enable_disable = 0;
12092 if (sw_if_index_set == 0)
12094 errmsg ("missing interface name or sw_if_index");
12098 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
12100 mp->sw_if_index = ntohl (sw_if_index);
12101 mp->enable_disable = enable_disable;
12109 api_l2tpv3_set_lookup_key (vat_main_t * vam)
12111 unformat_input_t *i = vam->input;
12112 vl_api_l2tpv3_set_lookup_key_t *mp;
12116 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12118 if (unformat (i, "lookup_v6_src"))
12119 key = L2T_LOOKUP_SRC_ADDRESS;
12120 else if (unformat (i, "lookup_v6_dst"))
12121 key = L2T_LOOKUP_DST_ADDRESS;
12122 else if (unformat (i, "lookup_session_id"))
12123 key = L2T_LOOKUP_SESSION_ID;
12128 if (key == (u8) ~ 0)
12130 errmsg ("l2tp session lookup key unset");
12134 M (L2TPV3_SET_LOOKUP_KEY, mp);
12143 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
12144 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12146 vat_main_t *vam = &vat_main;
12148 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
12149 format_ip6_address, mp->our_address,
12150 format_ip6_address, mp->client_address,
12151 clib_net_to_host_u32 (mp->sw_if_index));
12154 " local cookies %016llx %016llx remote cookie %016llx",
12155 clib_net_to_host_u64 (mp->local_cookie[0]),
12156 clib_net_to_host_u64 (mp->local_cookie[1]),
12157 clib_net_to_host_u64 (mp->remote_cookie));
12159 print (vam->ofp, " local session-id %d remote session-id %d",
12160 clib_net_to_host_u32 (mp->local_session_id),
12161 clib_net_to_host_u32 (mp->remote_session_id));
12163 print (vam->ofp, " l2 specific sublayer %s\n",
12164 mp->l2_sublayer_present ? "preset" : "absent");
12168 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
12169 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12171 vat_main_t *vam = &vat_main;
12172 vat_json_node_t *node = NULL;
12173 struct in6_addr addr;
12175 if (VAT_JSON_ARRAY != vam->json_tree.type)
12177 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12178 vat_json_init_array (&vam->json_tree);
12180 node = vat_json_array_add (&vam->json_tree);
12182 vat_json_init_object (node);
12184 clib_memcpy (&addr, mp->our_address, sizeof (addr));
12185 vat_json_object_add_ip6 (node, "our_address", addr);
12186 clib_memcpy (&addr, mp->client_address, sizeof (addr));
12187 vat_json_object_add_ip6 (node, "client_address", addr);
12189 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
12190 vat_json_init_array (lc);
12191 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
12192 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
12193 vat_json_object_add_uint (node, "remote_cookie",
12194 clib_net_to_host_u64 (mp->remote_cookie));
12196 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
12197 vat_json_object_add_uint (node, "local_session_id",
12198 clib_net_to_host_u32 (mp->local_session_id));
12199 vat_json_object_add_uint (node, "remote_session_id",
12200 clib_net_to_host_u32 (mp->remote_session_id));
12201 vat_json_object_add_string_copy (node, "l2_sublayer",
12202 mp->l2_sublayer_present ? (u8 *) "present"
12203 : (u8 *) "absent");
12207 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
12209 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
12210 vl_api_control_ping_t *mp_ping;
12213 /* Get list of l2tpv3-tunnel interfaces */
12214 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
12217 /* Use a control ping for synchronization */
12218 MPING (CONTROL_PING, mp_ping);
12226 static void vl_api_sw_interface_tap_v2_details_t_handler
12227 (vl_api_sw_interface_tap_v2_details_t * mp)
12229 vat_main_t *vam = &vat_main;
12231 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
12232 mp->host_ip4_prefix_len);
12233 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
12234 mp->host_ip6_prefix_len);
12237 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s 0x%-08x",
12238 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
12239 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12240 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
12241 mp->host_bridge, ip4, ip6, ntohl (mp->tap_flags));
12247 static void vl_api_sw_interface_tap_v2_details_t_handler_json
12248 (vl_api_sw_interface_tap_v2_details_t * mp)
12250 vat_main_t *vam = &vat_main;
12251 vat_json_node_t *node = NULL;
12253 if (VAT_JSON_ARRAY != vam->json_tree.type)
12255 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12256 vat_json_init_array (&vam->json_tree);
12258 node = vat_json_array_add (&vam->json_tree);
12260 vat_json_init_object (node);
12261 vat_json_object_add_uint (node, "id", ntohl (mp->id));
12262 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12263 vat_json_object_add_uint (node, "tap_flags", ntohl (mp->tap_flags));
12264 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12265 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12266 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12267 vat_json_object_add_string_copy (node, "host_mac_addr",
12268 format (0, "%U", format_ethernet_address,
12269 &mp->host_mac_addr));
12270 vat_json_object_add_string_copy (node, "host_namespace",
12271 mp->host_namespace);
12272 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
12273 vat_json_object_add_string_copy (node, "host_ip4_addr",
12274 format (0, "%U/%d", format_ip4_address,
12276 mp->host_ip4_prefix_len));
12277 vat_json_object_add_string_copy (node, "host_ip6_addr",
12278 format (0, "%U/%d", format_ip6_address,
12280 mp->host_ip6_prefix_len));
12285 api_sw_interface_tap_v2_dump (vat_main_t * vam)
12287 vl_api_sw_interface_tap_v2_dump_t *mp;
12288 vl_api_control_ping_t *mp_ping;
12292 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
12293 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
12294 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
12297 /* Get list of tap interfaces */
12298 M (SW_INTERFACE_TAP_V2_DUMP, mp);
12301 /* Use a control ping for synchronization */
12302 MPING (CONTROL_PING, mp_ping);
12309 static void vl_api_sw_interface_virtio_pci_details_t_handler
12310 (vl_api_sw_interface_virtio_pci_details_t * mp)
12312 vat_main_t *vam = &vat_main;
12326 addr.as_u32 = ntohl (mp->pci_addr);
12327 u8 *pci_addr = format (0, "%04x:%02x:%02x.%x", addr.domain, addr.bus,
12328 addr.slot, addr.function);
12331 "\n%-12s %-12d %-12d %-12d %-17U 0x%-08llx",
12332 pci_addr, ntohl (mp->sw_if_index),
12333 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12334 format_ethernet_address, mp->mac_addr,
12335 clib_net_to_host_u64 (mp->features));
12336 vec_free (pci_addr);
12339 static void vl_api_sw_interface_virtio_pci_details_t_handler_json
12340 (vl_api_sw_interface_virtio_pci_details_t * mp)
12342 vat_main_t *vam = &vat_main;
12343 vat_json_node_t *node = NULL;
12345 if (VAT_JSON_ARRAY != vam->json_tree.type)
12347 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12348 vat_json_init_array (&vam->json_tree);
12350 node = vat_json_array_add (&vam->json_tree);
12352 vat_json_init_object (node);
12353 vat_json_object_add_uint (node, "pci-addr", ntohl (mp->pci_addr));
12354 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12355 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12356 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12357 vat_json_object_add_uint (node, "features",
12358 clib_net_to_host_u64 (mp->features));
12359 vat_json_object_add_string_copy (node, "mac_addr",
12360 format (0, "%U", format_ethernet_address,
12365 api_sw_interface_virtio_pci_dump (vat_main_t * vam)
12367 vl_api_sw_interface_virtio_pci_dump_t *mp;
12368 vl_api_control_ping_t *mp_ping;
12372 "\n%-12s %-12s %-12s %-12s %-17s %-08s",
12373 "pci_addr", "sw_if_index", "rx_ring_sz", "tx_ring_sz",
12374 "mac_addr", "features");
12376 /* Get list of tap interfaces */
12377 M (SW_INTERFACE_VIRTIO_PCI_DUMP, mp);
12380 /* Use a control ping for synchronization */
12381 MPING (CONTROL_PING, mp_ping);
12389 api_vxlan_offload_rx (vat_main_t * vam)
12391 unformat_input_t *line_input = vam->input;
12392 vl_api_vxlan_offload_rx_t *mp;
12393 u32 hw_if_index = ~0, rx_if_index = ~0;
12397 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12399 if (unformat (line_input, "del"))
12401 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
12404 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
12406 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
12409 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
12413 errmsg ("parse error '%U'", format_unformat_error, line_input);
12418 if (hw_if_index == ~0)
12420 errmsg ("no hw interface");
12424 if (rx_if_index == ~0)
12426 errmsg ("no rx tunnel");
12430 M (VXLAN_OFFLOAD_RX, mp);
12432 mp->hw_if_index = ntohl (hw_if_index);
12433 mp->sw_if_index = ntohl (rx_if_index);
12434 mp->enable = is_add;
12441 static uword unformat_vxlan_decap_next
12442 (unformat_input_t * input, va_list * args)
12444 u32 *result = va_arg (*args, u32 *);
12447 if (unformat (input, "l2"))
12448 *result = VXLAN_INPUT_NEXT_L2_INPUT;
12449 else if (unformat (input, "%d", &tmp))
12457 api_vxlan_add_del_tunnel (vat_main_t * vam)
12459 unformat_input_t *line_input = vam->input;
12460 vl_api_vxlan_add_del_tunnel_t *mp;
12461 ip46_address_t src, dst;
12463 u8 ipv4_set = 0, ipv6_set = 0;
12468 u32 mcast_sw_if_index = ~0;
12469 u32 encap_vrf_id = 0;
12470 u32 decap_next_index = ~0;
12474 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12475 clib_memset (&src, 0, sizeof src);
12476 clib_memset (&dst, 0, sizeof dst);
12478 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12480 if (unformat (line_input, "del"))
12482 else if (unformat (line_input, "instance %d", &instance))
12485 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12491 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12497 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12503 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12508 else if (unformat (line_input, "group %U %U",
12509 unformat_ip4_address, &dst.ip4,
12510 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12512 grp_set = dst_set = 1;
12515 else if (unformat (line_input, "group %U",
12516 unformat_ip4_address, &dst.ip4))
12518 grp_set = dst_set = 1;
12521 else if (unformat (line_input, "group %U %U",
12522 unformat_ip6_address, &dst.ip6,
12523 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12525 grp_set = dst_set = 1;
12528 else if (unformat (line_input, "group %U",
12529 unformat_ip6_address, &dst.ip6))
12531 grp_set = dst_set = 1;
12535 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12537 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12539 else if (unformat (line_input, "decap-next %U",
12540 unformat_vxlan_decap_next, &decap_next_index))
12542 else if (unformat (line_input, "vni %d", &vni))
12546 errmsg ("parse error '%U'", format_unformat_error, line_input);
12553 errmsg ("tunnel src address not specified");
12558 errmsg ("tunnel dst address not specified");
12562 if (grp_set && !ip46_address_is_multicast (&dst))
12564 errmsg ("tunnel group address not multicast");
12567 if (grp_set && mcast_sw_if_index == ~0)
12569 errmsg ("tunnel nonexistent multicast device");
12572 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12574 errmsg ("tunnel dst address must be unicast");
12579 if (ipv4_set && ipv6_set)
12581 errmsg ("both IPv4 and IPv6 addresses specified");
12585 if ((vni == 0) || (vni >> 24))
12587 errmsg ("vni not specified or out of range");
12591 M (VXLAN_ADD_DEL_TUNNEL, mp);
12595 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
12596 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
12600 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
12601 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
12604 mp->instance = htonl (instance);
12605 mp->encap_vrf_id = ntohl (encap_vrf_id);
12606 mp->decap_next_index = ntohl (decap_next_index);
12607 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12608 mp->vni = ntohl (vni);
12609 mp->is_add = is_add;
12610 mp->is_ipv6 = ipv6_set;
12617 static void vl_api_vxlan_tunnel_details_t_handler
12618 (vl_api_vxlan_tunnel_details_t * mp)
12620 vat_main_t *vam = &vat_main;
12621 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12622 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12624 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
12625 ntohl (mp->sw_if_index),
12626 ntohl (mp->instance),
12627 format_ip46_address, &src, IP46_TYPE_ANY,
12628 format_ip46_address, &dst, IP46_TYPE_ANY,
12629 ntohl (mp->encap_vrf_id),
12630 ntohl (mp->decap_next_index), ntohl (mp->vni),
12631 ntohl (mp->mcast_sw_if_index));
12634 static void vl_api_vxlan_tunnel_details_t_handler_json
12635 (vl_api_vxlan_tunnel_details_t * mp)
12637 vat_main_t *vam = &vat_main;
12638 vat_json_node_t *node = NULL;
12640 if (VAT_JSON_ARRAY != vam->json_tree.type)
12642 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12643 vat_json_init_array (&vam->json_tree);
12645 node = vat_json_array_add (&vam->json_tree);
12647 vat_json_init_object (node);
12648 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12650 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
12654 struct in6_addr ip6;
12656 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12657 vat_json_object_add_ip6 (node, "src_address", ip6);
12658 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12659 vat_json_object_add_ip6 (node, "dst_address", ip6);
12663 struct in_addr ip4;
12665 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12666 vat_json_object_add_ip4 (node, "src_address", ip4);
12667 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12668 vat_json_object_add_ip4 (node, "dst_address", ip4);
12670 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12671 vat_json_object_add_uint (node, "decap_next_index",
12672 ntohl (mp->decap_next_index));
12673 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12674 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12675 vat_json_object_add_uint (node, "mcast_sw_if_index",
12676 ntohl (mp->mcast_sw_if_index));
12680 api_vxlan_tunnel_dump (vat_main_t * vam)
12682 unformat_input_t *i = vam->input;
12683 vl_api_vxlan_tunnel_dump_t *mp;
12684 vl_api_control_ping_t *mp_ping;
12686 u8 sw_if_index_set = 0;
12689 /* Parse args required to build the message */
12690 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12692 if (unformat (i, "sw_if_index %d", &sw_if_index))
12693 sw_if_index_set = 1;
12698 if (sw_if_index_set == 0)
12703 if (!vam->json_output)
12705 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
12706 "sw_if_index", "instance", "src_address", "dst_address",
12707 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12710 /* Get list of vxlan-tunnel interfaces */
12711 M (VXLAN_TUNNEL_DUMP, mp);
12713 mp->sw_if_index = htonl (sw_if_index);
12717 /* Use a control ping for synchronization */
12718 MPING (CONTROL_PING, mp_ping);
12725 static uword unformat_geneve_decap_next
12726 (unformat_input_t * input, va_list * args)
12728 u32 *result = va_arg (*args, u32 *);
12731 if (unformat (input, "l2"))
12732 *result = GENEVE_INPUT_NEXT_L2_INPUT;
12733 else if (unformat (input, "%d", &tmp))
12741 api_geneve_add_del_tunnel (vat_main_t * vam)
12743 unformat_input_t *line_input = vam->input;
12744 vl_api_geneve_add_del_tunnel_t *mp;
12745 ip46_address_t src, dst;
12747 u8 ipv4_set = 0, ipv6_set = 0;
12751 u32 mcast_sw_if_index = ~0;
12752 u32 encap_vrf_id = 0;
12753 u32 decap_next_index = ~0;
12757 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12758 clib_memset (&src, 0, sizeof src);
12759 clib_memset (&dst, 0, sizeof dst);
12761 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12763 if (unformat (line_input, "del"))
12766 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12772 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12778 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12784 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12789 else if (unformat (line_input, "group %U %U",
12790 unformat_ip4_address, &dst.ip4,
12791 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12793 grp_set = dst_set = 1;
12796 else if (unformat (line_input, "group %U",
12797 unformat_ip4_address, &dst.ip4))
12799 grp_set = dst_set = 1;
12802 else if (unformat (line_input, "group %U %U",
12803 unformat_ip6_address, &dst.ip6,
12804 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12806 grp_set = dst_set = 1;
12809 else if (unformat (line_input, "group %U",
12810 unformat_ip6_address, &dst.ip6))
12812 grp_set = dst_set = 1;
12816 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12818 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12820 else if (unformat (line_input, "decap-next %U",
12821 unformat_geneve_decap_next, &decap_next_index))
12823 else if (unformat (line_input, "vni %d", &vni))
12827 errmsg ("parse error '%U'", format_unformat_error, line_input);
12834 errmsg ("tunnel src address not specified");
12839 errmsg ("tunnel dst address not specified");
12843 if (grp_set && !ip46_address_is_multicast (&dst))
12845 errmsg ("tunnel group address not multicast");
12848 if (grp_set && mcast_sw_if_index == ~0)
12850 errmsg ("tunnel nonexistent multicast device");
12853 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12855 errmsg ("tunnel dst address must be unicast");
12860 if (ipv4_set && ipv6_set)
12862 errmsg ("both IPv4 and IPv6 addresses specified");
12866 if ((vni == 0) || (vni >> 24))
12868 errmsg ("vni not specified or out of range");
12872 M (GENEVE_ADD_DEL_TUNNEL, mp);
12876 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
12877 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
12881 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
12882 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
12884 mp->encap_vrf_id = ntohl (encap_vrf_id);
12885 mp->decap_next_index = ntohl (decap_next_index);
12886 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12887 mp->vni = ntohl (vni);
12888 mp->is_add = is_add;
12889 mp->is_ipv6 = ipv6_set;
12896 static void vl_api_geneve_tunnel_details_t_handler
12897 (vl_api_geneve_tunnel_details_t * mp)
12899 vat_main_t *vam = &vat_main;
12900 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12901 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12903 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12904 ntohl (mp->sw_if_index),
12905 format_ip46_address, &src, IP46_TYPE_ANY,
12906 format_ip46_address, &dst, IP46_TYPE_ANY,
12907 ntohl (mp->encap_vrf_id),
12908 ntohl (mp->decap_next_index), ntohl (mp->vni),
12909 ntohl (mp->mcast_sw_if_index));
12912 static void vl_api_geneve_tunnel_details_t_handler_json
12913 (vl_api_geneve_tunnel_details_t * mp)
12915 vat_main_t *vam = &vat_main;
12916 vat_json_node_t *node = NULL;
12918 if (VAT_JSON_ARRAY != vam->json_tree.type)
12920 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12921 vat_json_init_array (&vam->json_tree);
12923 node = vat_json_array_add (&vam->json_tree);
12925 vat_json_init_object (node);
12926 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12929 struct in6_addr ip6;
12931 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12932 vat_json_object_add_ip6 (node, "src_address", ip6);
12933 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12934 vat_json_object_add_ip6 (node, "dst_address", ip6);
12938 struct in_addr ip4;
12940 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12941 vat_json_object_add_ip4 (node, "src_address", ip4);
12942 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12943 vat_json_object_add_ip4 (node, "dst_address", ip4);
12945 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12946 vat_json_object_add_uint (node, "decap_next_index",
12947 ntohl (mp->decap_next_index));
12948 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12949 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12950 vat_json_object_add_uint (node, "mcast_sw_if_index",
12951 ntohl (mp->mcast_sw_if_index));
12955 api_geneve_tunnel_dump (vat_main_t * vam)
12957 unformat_input_t *i = vam->input;
12958 vl_api_geneve_tunnel_dump_t *mp;
12959 vl_api_control_ping_t *mp_ping;
12961 u8 sw_if_index_set = 0;
12964 /* Parse args required to build the message */
12965 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12967 if (unformat (i, "sw_if_index %d", &sw_if_index))
12968 sw_if_index_set = 1;
12973 if (sw_if_index_set == 0)
12978 if (!vam->json_output)
12980 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12981 "sw_if_index", "local_address", "remote_address",
12982 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12985 /* Get list of geneve-tunnel interfaces */
12986 M (GENEVE_TUNNEL_DUMP, mp);
12988 mp->sw_if_index = htonl (sw_if_index);
12992 /* Use a control ping for synchronization */
12993 M (CONTROL_PING, mp_ping);
13001 api_gre_tunnel_add_del (vat_main_t * vam)
13003 unformat_input_t *line_input = vam->input;
13004 vl_api_address_t src = { }, dst =
13007 vl_api_gre_tunnel_add_del_t *mp;
13008 vl_api_gre_tunnel_type_t t_type;
13012 u32 outer_fib_id = 0;
13013 u32 session_id = 0;
13017 t_type = GRE_API_TUNNEL_TYPE_L3;
13019 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13021 if (unformat (line_input, "del"))
13023 else if (unformat (line_input, "instance %d", &instance))
13025 else if (unformat (line_input, "src %U", unformat_vl_api_address, &src))
13029 else if (unformat (line_input, "dst %U", unformat_vl_api_address, &dst))
13033 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
13035 else if (unformat (line_input, "teb"))
13036 t_type = GRE_API_TUNNEL_TYPE_TEB;
13037 else if (unformat (line_input, "erspan %d", &session_id))
13038 t_type = GRE_API_TUNNEL_TYPE_ERSPAN;
13041 errmsg ("parse error '%U'", format_unformat_error, line_input);
13048 errmsg ("tunnel src address not specified");
13053 errmsg ("tunnel dst address not specified");
13057 M (GRE_TUNNEL_ADD_DEL, mp);
13059 clib_memcpy (&mp->tunnel.src, &src, sizeof (mp->tunnel.src));
13060 clib_memcpy (&mp->tunnel.dst, &dst, sizeof (mp->tunnel.dst));
13062 mp->tunnel.instance = htonl (instance);
13063 mp->tunnel.outer_fib_id = htonl (outer_fib_id);
13064 mp->is_add = is_add;
13065 mp->tunnel.session_id = htons ((u16) session_id);
13066 mp->tunnel.type = htonl (t_type);
13073 static void vl_api_gre_tunnel_details_t_handler
13074 (vl_api_gre_tunnel_details_t * mp)
13076 vat_main_t *vam = &vat_main;
13078 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
13079 ntohl (mp->tunnel.sw_if_index),
13080 ntohl (mp->tunnel.instance),
13081 format_vl_api_address, &mp->tunnel.src,
13082 format_vl_api_address, &mp->tunnel.dst,
13083 mp->tunnel.type, ntohl (mp->tunnel.outer_fib_id),
13084 ntohl (mp->tunnel.session_id));
13087 static void vl_api_gre_tunnel_details_t_handler_json
13088 (vl_api_gre_tunnel_details_t * mp)
13090 vat_main_t *vam = &vat_main;
13091 vat_json_node_t *node = NULL;
13093 if (VAT_JSON_ARRAY != vam->json_tree.type)
13095 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13096 vat_json_init_array (&vam->json_tree);
13098 node = vat_json_array_add (&vam->json_tree);
13100 vat_json_init_object (node);
13101 vat_json_object_add_uint (node, "sw_if_index",
13102 ntohl (mp->tunnel.sw_if_index));
13103 vat_json_object_add_uint (node, "instance", ntohl (mp->tunnel.instance));
13105 vat_json_object_add_address (node, "src", &mp->tunnel.src);
13106 vat_json_object_add_address (node, "dst", &mp->tunnel.dst);
13107 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel.type);
13108 vat_json_object_add_uint (node, "outer_fib_id",
13109 ntohl (mp->tunnel.outer_fib_id));
13110 vat_json_object_add_uint (node, "session_id", mp->tunnel.session_id);
13114 api_gre_tunnel_dump (vat_main_t * vam)
13116 unformat_input_t *i = vam->input;
13117 vl_api_gre_tunnel_dump_t *mp;
13118 vl_api_control_ping_t *mp_ping;
13120 u8 sw_if_index_set = 0;
13123 /* Parse args required to build the message */
13124 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13126 if (unformat (i, "sw_if_index %d", &sw_if_index))
13127 sw_if_index_set = 1;
13132 if (sw_if_index_set == 0)
13137 if (!vam->json_output)
13139 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
13140 "sw_if_index", "instance", "src_address", "dst_address",
13141 "tunnel_type", "outer_fib_id", "session_id");
13144 /* Get list of gre-tunnel interfaces */
13145 M (GRE_TUNNEL_DUMP, mp);
13147 mp->sw_if_index = htonl (sw_if_index);
13151 /* Use a control ping for synchronization */
13152 MPING (CONTROL_PING, mp_ping);
13160 api_l2_fib_clear_table (vat_main_t * vam)
13162 // unformat_input_t * i = vam->input;
13163 vl_api_l2_fib_clear_table_t *mp;
13166 M (L2_FIB_CLEAR_TABLE, mp);
13174 api_l2_interface_efp_filter (vat_main_t * vam)
13176 unformat_input_t *i = vam->input;
13177 vl_api_l2_interface_efp_filter_t *mp;
13180 u8 sw_if_index_set = 0;
13183 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13185 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13186 sw_if_index_set = 1;
13187 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13188 sw_if_index_set = 1;
13189 else if (unformat (i, "enable"))
13191 else if (unformat (i, "disable"))
13195 clib_warning ("parse error '%U'", format_unformat_error, i);
13200 if (sw_if_index_set == 0)
13202 errmsg ("missing sw_if_index");
13206 M (L2_INTERFACE_EFP_FILTER, mp);
13208 mp->sw_if_index = ntohl (sw_if_index);
13209 mp->enable_disable = enable;
13216 #define foreach_vtr_op \
13217 _("disable", L2_VTR_DISABLED) \
13218 _("push-1", L2_VTR_PUSH_1) \
13219 _("push-2", L2_VTR_PUSH_2) \
13220 _("pop-1", L2_VTR_POP_1) \
13221 _("pop-2", L2_VTR_POP_2) \
13222 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
13223 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
13224 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
13225 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
13228 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
13230 unformat_input_t *i = vam->input;
13231 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
13233 u8 sw_if_index_set = 0;
13236 u32 push_dot1q = 1;
13241 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13243 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13244 sw_if_index_set = 1;
13245 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13246 sw_if_index_set = 1;
13247 else if (unformat (i, "vtr_op %d", &vtr_op))
13249 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
13252 else if (unformat (i, "push_dot1q %d", &push_dot1q))
13254 else if (unformat (i, "tag1 %d", &tag1))
13256 else if (unformat (i, "tag2 %d", &tag2))
13260 clib_warning ("parse error '%U'", format_unformat_error, i);
13265 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
13267 errmsg ("missing vtr operation or sw_if_index");
13271 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
13272 mp->sw_if_index = ntohl (sw_if_index);
13273 mp->vtr_op = ntohl (vtr_op);
13274 mp->push_dot1q = ntohl (push_dot1q);
13275 mp->tag1 = ntohl (tag1);
13276 mp->tag2 = ntohl (tag2);
13284 api_create_vhost_user_if (vat_main_t * vam)
13286 unformat_input_t *i = vam->input;
13287 vl_api_create_vhost_user_if_t *mp;
13290 u8 file_name_set = 0;
13291 u32 custom_dev_instance = ~0;
13293 u8 use_custom_mac = 0;
13294 u8 disable_mrg_rxbuf = 0;
13295 u8 disable_indirect_desc = 0;
13299 /* Shut up coverity */
13300 clib_memset (hwaddr, 0, sizeof (hwaddr));
13302 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13304 if (unformat (i, "socket %s", &file_name))
13308 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13310 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
13311 use_custom_mac = 1;
13312 else if (unformat (i, "server"))
13314 else if (unformat (i, "disable_mrg_rxbuf"))
13315 disable_mrg_rxbuf = 1;
13316 else if (unformat (i, "disable_indirect_desc"))
13317 disable_indirect_desc = 1;
13318 else if (unformat (i, "tag %s", &tag))
13324 if (file_name_set == 0)
13326 errmsg ("missing socket file name");
13330 if (vec_len (file_name) > 255)
13332 errmsg ("socket file name too long");
13335 vec_add1 (file_name, 0);
13337 M (CREATE_VHOST_USER_IF, mp);
13339 mp->is_server = is_server;
13340 mp->disable_mrg_rxbuf = disable_mrg_rxbuf;
13341 mp->disable_indirect_desc = disable_indirect_desc;
13342 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13343 vec_free (file_name);
13344 if (custom_dev_instance != ~0)
13347 mp->custom_dev_instance = ntohl (custom_dev_instance);
13350 mp->use_custom_mac = use_custom_mac;
13351 clib_memcpy (mp->mac_address, hwaddr, 6);
13353 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
13362 api_modify_vhost_user_if (vat_main_t * vam)
13364 unformat_input_t *i = vam->input;
13365 vl_api_modify_vhost_user_if_t *mp;
13368 u8 file_name_set = 0;
13369 u32 custom_dev_instance = ~0;
13370 u8 sw_if_index_set = 0;
13371 u32 sw_if_index = (u32) ~ 0;
13374 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13376 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13377 sw_if_index_set = 1;
13378 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13379 sw_if_index_set = 1;
13380 else if (unformat (i, "socket %s", &file_name))
13384 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13386 else if (unformat (i, "server"))
13392 if (sw_if_index_set == 0)
13394 errmsg ("missing sw_if_index or interface name");
13398 if (file_name_set == 0)
13400 errmsg ("missing socket file name");
13404 if (vec_len (file_name) > 255)
13406 errmsg ("socket file name too long");
13409 vec_add1 (file_name, 0);
13411 M (MODIFY_VHOST_USER_IF, mp);
13413 mp->sw_if_index = ntohl (sw_if_index);
13414 mp->is_server = is_server;
13415 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13416 vec_free (file_name);
13417 if (custom_dev_instance != ~0)
13420 mp->custom_dev_instance = ntohl (custom_dev_instance);
13429 api_delete_vhost_user_if (vat_main_t * vam)
13431 unformat_input_t *i = vam->input;
13432 vl_api_delete_vhost_user_if_t *mp;
13433 u32 sw_if_index = ~0;
13434 u8 sw_if_index_set = 0;
13437 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13439 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13440 sw_if_index_set = 1;
13441 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13442 sw_if_index_set = 1;
13447 if (sw_if_index_set == 0)
13449 errmsg ("missing sw_if_index or interface name");
13454 M (DELETE_VHOST_USER_IF, mp);
13456 mp->sw_if_index = ntohl (sw_if_index);
13463 static void vl_api_sw_interface_vhost_user_details_t_handler
13464 (vl_api_sw_interface_vhost_user_details_t * mp)
13466 vat_main_t *vam = &vat_main;
13468 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
13469 (char *) mp->interface_name,
13470 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
13471 clib_net_to_host_u64 (mp->features), mp->is_server,
13472 ntohl (mp->num_regions), (char *) mp->sock_filename);
13473 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
13476 static void vl_api_sw_interface_vhost_user_details_t_handler_json
13477 (vl_api_sw_interface_vhost_user_details_t * mp)
13479 vat_main_t *vam = &vat_main;
13480 vat_json_node_t *node = NULL;
13482 if (VAT_JSON_ARRAY != vam->json_tree.type)
13484 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13485 vat_json_init_array (&vam->json_tree);
13487 node = vat_json_array_add (&vam->json_tree);
13489 vat_json_init_object (node);
13490 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13491 vat_json_object_add_string_copy (node, "interface_name",
13492 mp->interface_name);
13493 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
13494 ntohl (mp->virtio_net_hdr_sz));
13495 vat_json_object_add_uint (node, "features",
13496 clib_net_to_host_u64 (mp->features));
13497 vat_json_object_add_uint (node, "is_server", mp->is_server);
13498 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
13499 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
13500 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
13504 api_sw_interface_vhost_user_dump (vat_main_t * vam)
13506 vl_api_sw_interface_vhost_user_dump_t *mp;
13507 vl_api_control_ping_t *mp_ping;
13510 "Interface name idx hdr_sz features server regions filename");
13512 /* Get list of vhost-user interfaces */
13513 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
13516 /* Use a control ping for synchronization */
13517 MPING (CONTROL_PING, mp_ping);
13525 api_show_version (vat_main_t * vam)
13527 vl_api_show_version_t *mp;
13530 M (SHOW_VERSION, mp);
13539 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
13541 unformat_input_t *line_input = vam->input;
13542 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
13543 ip4_address_t local4, remote4;
13544 ip6_address_t local6, remote6;
13546 u8 ipv4_set = 0, ipv6_set = 0;
13550 u32 mcast_sw_if_index = ~0;
13551 u32 encap_vrf_id = 0;
13552 u32 decap_vrf_id = 0;
13558 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13559 clib_memset (&local4, 0, sizeof local4);
13560 clib_memset (&remote4, 0, sizeof remote4);
13561 clib_memset (&local6, 0, sizeof local6);
13562 clib_memset (&remote6, 0, sizeof remote6);
13564 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13566 if (unformat (line_input, "del"))
13568 else if (unformat (line_input, "local %U",
13569 unformat_ip4_address, &local4))
13574 else if (unformat (line_input, "remote %U",
13575 unformat_ip4_address, &remote4))
13580 else if (unformat (line_input, "local %U",
13581 unformat_ip6_address, &local6))
13586 else if (unformat (line_input, "remote %U",
13587 unformat_ip6_address, &remote6))
13592 else if (unformat (line_input, "group %U %U",
13593 unformat_ip4_address, &remote4,
13594 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13596 grp_set = remote_set = 1;
13599 else if (unformat (line_input, "group %U",
13600 unformat_ip4_address, &remote4))
13602 grp_set = remote_set = 1;
13605 else if (unformat (line_input, "group %U %U",
13606 unformat_ip6_address, &remote6,
13607 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13609 grp_set = remote_set = 1;
13612 else if (unformat (line_input, "group %U",
13613 unformat_ip6_address, &remote6))
13615 grp_set = remote_set = 1;
13619 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13621 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13623 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
13625 else if (unformat (line_input, "vni %d", &vni))
13627 else if (unformat (line_input, "next-ip4"))
13629 else if (unformat (line_input, "next-ip6"))
13631 else if (unformat (line_input, "next-ethernet"))
13633 else if (unformat (line_input, "next-nsh"))
13637 errmsg ("parse error '%U'", format_unformat_error, line_input);
13642 if (local_set == 0)
13644 errmsg ("tunnel local address not specified");
13647 if (remote_set == 0)
13649 errmsg ("tunnel remote address not specified");
13652 if (grp_set && mcast_sw_if_index == ~0)
13654 errmsg ("tunnel nonexistent multicast device");
13657 if (ipv4_set && ipv6_set)
13659 errmsg ("both IPv4 and IPv6 addresses specified");
13665 errmsg ("vni not specified");
13669 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
13674 clib_memcpy (&mp->local, &local6, sizeof (local6));
13675 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
13679 clib_memcpy (&mp->local, &local4, sizeof (local4));
13680 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
13683 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13684 mp->encap_vrf_id = ntohl (encap_vrf_id);
13685 mp->decap_vrf_id = ntohl (decap_vrf_id);
13686 mp->protocol = protocol;
13687 mp->vni = ntohl (vni);
13688 mp->is_add = is_add;
13689 mp->is_ipv6 = ipv6_set;
13696 static void vl_api_vxlan_gpe_tunnel_details_t_handler
13697 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13699 vat_main_t *vam = &vat_main;
13700 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
13701 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
13703 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
13704 ntohl (mp->sw_if_index),
13705 format_ip46_address, &local, IP46_TYPE_ANY,
13706 format_ip46_address, &remote, IP46_TYPE_ANY,
13707 ntohl (mp->vni), mp->protocol,
13708 ntohl (mp->mcast_sw_if_index),
13709 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
13713 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
13714 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13716 vat_main_t *vam = &vat_main;
13717 vat_json_node_t *node = NULL;
13718 struct in_addr ip4;
13719 struct in6_addr ip6;
13721 if (VAT_JSON_ARRAY != vam->json_tree.type)
13723 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13724 vat_json_init_array (&vam->json_tree);
13726 node = vat_json_array_add (&vam->json_tree);
13728 vat_json_init_object (node);
13729 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13732 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
13733 vat_json_object_add_ip6 (node, "local", ip6);
13734 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
13735 vat_json_object_add_ip6 (node, "remote", ip6);
13739 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
13740 vat_json_object_add_ip4 (node, "local", ip4);
13741 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
13742 vat_json_object_add_ip4 (node, "remote", ip4);
13744 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13745 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
13746 vat_json_object_add_uint (node, "mcast_sw_if_index",
13747 ntohl (mp->mcast_sw_if_index));
13748 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13749 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
13750 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13754 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
13756 unformat_input_t *i = vam->input;
13757 vl_api_vxlan_gpe_tunnel_dump_t *mp;
13758 vl_api_control_ping_t *mp_ping;
13760 u8 sw_if_index_set = 0;
13763 /* Parse args required to build the message */
13764 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13766 if (unformat (i, "sw_if_index %d", &sw_if_index))
13767 sw_if_index_set = 1;
13772 if (sw_if_index_set == 0)
13777 if (!vam->json_output)
13779 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
13780 "sw_if_index", "local", "remote", "vni",
13781 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
13784 /* Get list of vxlan-tunnel interfaces */
13785 M (VXLAN_GPE_TUNNEL_DUMP, mp);
13787 mp->sw_if_index = htonl (sw_if_index);
13791 /* Use a control ping for synchronization */
13792 MPING (CONTROL_PING, mp_ping);
13799 static void vl_api_l2_fib_table_details_t_handler
13800 (vl_api_l2_fib_table_details_t * mp)
13802 vat_main_t *vam = &vat_main;
13804 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
13806 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
13807 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
13811 static void vl_api_l2_fib_table_details_t_handler_json
13812 (vl_api_l2_fib_table_details_t * mp)
13814 vat_main_t *vam = &vat_main;
13815 vat_json_node_t *node = NULL;
13817 if (VAT_JSON_ARRAY != vam->json_tree.type)
13819 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13820 vat_json_init_array (&vam->json_tree);
13822 node = vat_json_array_add (&vam->json_tree);
13824 vat_json_init_object (node);
13825 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
13826 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
13827 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13828 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
13829 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
13830 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
13834 api_l2_fib_table_dump (vat_main_t * vam)
13836 unformat_input_t *i = vam->input;
13837 vl_api_l2_fib_table_dump_t *mp;
13838 vl_api_control_ping_t *mp_ping;
13843 /* Parse args required to build the message */
13844 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13846 if (unformat (i, "bd_id %d", &bd_id))
13852 if (bd_id_set == 0)
13854 errmsg ("missing bridge domain");
13858 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
13860 /* Get list of l2 fib entries */
13861 M (L2_FIB_TABLE_DUMP, mp);
13863 mp->bd_id = ntohl (bd_id);
13866 /* Use a control ping for synchronization */
13867 MPING (CONTROL_PING, mp_ping);
13876 api_interface_name_renumber (vat_main_t * vam)
13878 unformat_input_t *line_input = vam->input;
13879 vl_api_interface_name_renumber_t *mp;
13880 u32 sw_if_index = ~0;
13881 u32 new_show_dev_instance = ~0;
13884 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13886 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
13889 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13891 else if (unformat (line_input, "new_show_dev_instance %d",
13892 &new_show_dev_instance))
13898 if (sw_if_index == ~0)
13900 errmsg ("missing interface name or sw_if_index");
13904 if (new_show_dev_instance == ~0)
13906 errmsg ("missing new_show_dev_instance");
13910 M (INTERFACE_NAME_RENUMBER, mp);
13912 mp->sw_if_index = ntohl (sw_if_index);
13913 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
13921 api_ip_probe_neighbor (vat_main_t * vam)
13923 unformat_input_t *i = vam->input;
13924 vl_api_ip_probe_neighbor_t *mp;
13925 vl_api_address_t dst_adr = { };
13931 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13933 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13935 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13937 else if (unformat (i, "address %U", unformat_vl_api_address, &dst_adr))
13945 errmsg ("missing interface");
13951 errmsg ("missing addresses");
13955 M (IP_PROBE_NEIGHBOR, mp);
13957 mp->sw_if_index = ntohl (sw_if_index);
13958 clib_memcpy (&mp->dst, &dst_adr, sizeof (dst_adr));
13966 api_ip_scan_neighbor_enable_disable (vat_main_t * vam)
13968 unformat_input_t *i = vam->input;
13969 vl_api_ip_scan_neighbor_enable_disable_t *mp;
13970 u8 mode = IP_SCAN_V46_NEIGHBORS;
13971 u32 interval = 0, time = 0, update = 0, delay = 0, stale = 0;
13974 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13976 if (unformat (i, "ip4"))
13977 mode = IP_SCAN_V4_NEIGHBORS;
13978 else if (unformat (i, "ip6"))
13979 mode = IP_SCAN_V6_NEIGHBORS;
13980 if (unformat (i, "both"))
13981 mode = IP_SCAN_V46_NEIGHBORS;
13982 else if (unformat (i, "disable"))
13983 mode = IP_SCAN_DISABLED;
13984 else if (unformat (i, "interval %d", &interval))
13986 else if (unformat (i, "max-time %d", &time))
13988 else if (unformat (i, "max-update %d", &update))
13990 else if (unformat (i, "delay %d", &delay))
13992 else if (unformat (i, "stale %d", &stale))
13998 if (interval > 255)
14000 errmsg ("interval cannot exceed 255 minutes.");
14005 errmsg ("max-time cannot exceed 255 usec.");
14010 errmsg ("max-update cannot exceed 255.");
14015 errmsg ("delay cannot exceed 255 msec.");
14020 errmsg ("stale cannot exceed 255 minutes.");
14024 M (IP_SCAN_NEIGHBOR_ENABLE_DISABLE, mp);
14026 mp->scan_interval = interval;
14027 mp->max_proc_time = time;
14028 mp->max_update = update;
14029 mp->scan_int_delay = delay;
14030 mp->stale_threshold = stale;
14038 api_want_ip4_arp_events (vat_main_t * vam)
14040 unformat_input_t *line_input = vam->input;
14041 vl_api_want_ip4_arp_events_t *mp;
14042 ip4_address_t address;
14043 int address_set = 0;
14044 u32 enable_disable = 1;
14047 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14049 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
14051 else if (unformat (line_input, "del"))
14052 enable_disable = 0;
14057 if (address_set == 0)
14059 errmsg ("missing addresses");
14063 M (WANT_IP4_ARP_EVENTS, mp);
14064 mp->enable_disable = enable_disable;
14065 mp->pid = htonl (getpid ());
14066 clib_memcpy (mp->ip, &address, sizeof (address));
14074 api_want_ip6_nd_events (vat_main_t * vam)
14076 unformat_input_t *line_input = vam->input;
14077 vl_api_want_ip6_nd_events_t *mp;
14078 vl_api_ip6_address_t address;
14079 int address_set = 0;
14080 u32 enable_disable = 1;
14083 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14086 (line_input, "address %U", unformat_vl_api_ip6_address, &address))
14088 else if (unformat (line_input, "del"))
14089 enable_disable = 0;
14094 if (address_set == 0)
14096 errmsg ("missing addresses");
14100 M (WANT_IP6_ND_EVENTS, mp);
14101 mp->enable_disable = enable_disable;
14102 mp->pid = htonl (getpid ());
14103 clib_memcpy (&mp->ip, &address, sizeof (address));
14111 api_want_l2_macs_events (vat_main_t * vam)
14113 unformat_input_t *line_input = vam->input;
14114 vl_api_want_l2_macs_events_t *mp;
14115 u8 enable_disable = 1;
14116 u32 scan_delay = 0;
14117 u32 max_macs_in_event = 0;
14118 u32 learn_limit = 0;
14121 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14123 if (unformat (line_input, "learn-limit %d", &learn_limit))
14125 else if (unformat (line_input, "scan-delay %d", &scan_delay))
14127 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
14129 else if (unformat (line_input, "disable"))
14130 enable_disable = 0;
14135 M (WANT_L2_MACS_EVENTS, mp);
14136 mp->enable_disable = enable_disable;
14137 mp->pid = htonl (getpid ());
14138 mp->learn_limit = htonl (learn_limit);
14139 mp->scan_delay = (u8) scan_delay;
14140 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
14147 api_input_acl_set_interface (vat_main_t * vam)
14149 unformat_input_t *i = vam->input;
14150 vl_api_input_acl_set_interface_t *mp;
14152 int sw_if_index_set;
14153 u32 ip4_table_index = ~0;
14154 u32 ip6_table_index = ~0;
14155 u32 l2_table_index = ~0;
14159 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14161 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14162 sw_if_index_set = 1;
14163 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14164 sw_if_index_set = 1;
14165 else if (unformat (i, "del"))
14167 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14169 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14171 else if (unformat (i, "l2-table %d", &l2_table_index))
14175 clib_warning ("parse error '%U'", format_unformat_error, i);
14180 if (sw_if_index_set == 0)
14182 errmsg ("missing interface name or sw_if_index");
14186 M (INPUT_ACL_SET_INTERFACE, mp);
14188 mp->sw_if_index = ntohl (sw_if_index);
14189 mp->ip4_table_index = ntohl (ip4_table_index);
14190 mp->ip6_table_index = ntohl (ip6_table_index);
14191 mp->l2_table_index = ntohl (l2_table_index);
14192 mp->is_add = is_add;
14200 api_output_acl_set_interface (vat_main_t * vam)
14202 unformat_input_t *i = vam->input;
14203 vl_api_output_acl_set_interface_t *mp;
14205 int sw_if_index_set;
14206 u32 ip4_table_index = ~0;
14207 u32 ip6_table_index = ~0;
14208 u32 l2_table_index = ~0;
14212 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14214 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14215 sw_if_index_set = 1;
14216 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14217 sw_if_index_set = 1;
14218 else if (unformat (i, "del"))
14220 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14222 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14224 else if (unformat (i, "l2-table %d", &l2_table_index))
14228 clib_warning ("parse error '%U'", format_unformat_error, i);
14233 if (sw_if_index_set == 0)
14235 errmsg ("missing interface name or sw_if_index");
14239 M (OUTPUT_ACL_SET_INTERFACE, mp);
14241 mp->sw_if_index = ntohl (sw_if_index);
14242 mp->ip4_table_index = ntohl (ip4_table_index);
14243 mp->ip6_table_index = ntohl (ip6_table_index);
14244 mp->l2_table_index = ntohl (l2_table_index);
14245 mp->is_add = is_add;
14253 api_ip_address_dump (vat_main_t * vam)
14255 unformat_input_t *i = vam->input;
14256 vl_api_ip_address_dump_t *mp;
14257 vl_api_control_ping_t *mp_ping;
14258 u32 sw_if_index = ~0;
14259 u8 sw_if_index_set = 0;
14264 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14266 if (unformat (i, "sw_if_index %d", &sw_if_index))
14267 sw_if_index_set = 1;
14269 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14270 sw_if_index_set = 1;
14271 else if (unformat (i, "ipv4"))
14273 else if (unformat (i, "ipv6"))
14279 if (ipv4_set && ipv6_set)
14281 errmsg ("ipv4 and ipv6 flags cannot be both set");
14285 if ((!ipv4_set) && (!ipv6_set))
14287 errmsg ("no ipv4 nor ipv6 flag set");
14291 if (sw_if_index_set == 0)
14293 errmsg ("missing interface name or sw_if_index");
14297 vam->current_sw_if_index = sw_if_index;
14298 vam->is_ipv6 = ipv6_set;
14300 M (IP_ADDRESS_DUMP, mp);
14301 mp->sw_if_index = ntohl (sw_if_index);
14302 mp->is_ipv6 = ipv6_set;
14305 /* Use a control ping for synchronization */
14306 MPING (CONTROL_PING, mp_ping);
14314 api_ip_dump (vat_main_t * vam)
14316 vl_api_ip_dump_t *mp;
14317 vl_api_control_ping_t *mp_ping;
14318 unformat_input_t *in = vam->input;
14325 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
14327 if (unformat (in, "ipv4"))
14329 else if (unformat (in, "ipv6"))
14335 if (ipv4_set && ipv6_set)
14337 errmsg ("ipv4 and ipv6 flags cannot be both set");
14341 if ((!ipv4_set) && (!ipv6_set))
14343 errmsg ("no ipv4 nor ipv6 flag set");
14347 is_ipv6 = ipv6_set;
14348 vam->is_ipv6 = is_ipv6;
14350 /* free old data */
14351 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
14353 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
14355 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
14358 mp->is_ipv6 = ipv6_set;
14361 /* Use a control ping for synchronization */
14362 MPING (CONTROL_PING, mp_ping);
14370 api_ipsec_spd_add_del (vat_main_t * vam)
14372 unformat_input_t *i = vam->input;
14373 vl_api_ipsec_spd_add_del_t *mp;
14378 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14380 if (unformat (i, "spd_id %d", &spd_id))
14382 else if (unformat (i, "del"))
14386 clib_warning ("parse error '%U'", format_unformat_error, i);
14392 errmsg ("spd_id must be set");
14396 M (IPSEC_SPD_ADD_DEL, mp);
14398 mp->spd_id = ntohl (spd_id);
14399 mp->is_add = is_add;
14407 api_ipsec_interface_add_del_spd (vat_main_t * vam)
14409 unformat_input_t *i = vam->input;
14410 vl_api_ipsec_interface_add_del_spd_t *mp;
14412 u8 sw_if_index_set = 0;
14413 u32 spd_id = (u32) ~ 0;
14417 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14419 if (unformat (i, "del"))
14421 else if (unformat (i, "spd_id %d", &spd_id))
14424 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14425 sw_if_index_set = 1;
14426 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14427 sw_if_index_set = 1;
14430 clib_warning ("parse error '%U'", format_unformat_error, i);
14436 if (spd_id == (u32) ~ 0)
14438 errmsg ("spd_id must be set");
14442 if (sw_if_index_set == 0)
14444 errmsg ("missing interface name or sw_if_index");
14448 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
14450 mp->spd_id = ntohl (spd_id);
14451 mp->sw_if_index = ntohl (sw_if_index);
14452 mp->is_add = is_add;
14460 api_ipsec_spd_entry_add_del (vat_main_t * vam)
14462 unformat_input_t *i = vam->input;
14463 vl_api_ipsec_spd_entry_add_del_t *mp;
14464 u8 is_add = 1, is_outbound = 0;
14465 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
14467 u32 rport_start = 0, rport_stop = (u32) ~ 0;
14468 u32 lport_start = 0, lport_stop = (u32) ~ 0;
14469 vl_api_address_t laddr_start = { }, laddr_stop =
14478 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14480 if (unformat (i, "del"))
14482 if (unformat (i, "outbound"))
14484 if (unformat (i, "inbound"))
14486 else if (unformat (i, "spd_id %d", &spd_id))
14488 else if (unformat (i, "sa_id %d", &sa_id))
14490 else if (unformat (i, "priority %d", &priority))
14492 else if (unformat (i, "protocol %d", &protocol))
14494 else if (unformat (i, "lport_start %d", &lport_start))
14496 else if (unformat (i, "lport_stop %d", &lport_stop))
14498 else if (unformat (i, "rport_start %d", &rport_start))
14500 else if (unformat (i, "rport_stop %d", &rport_stop))
14502 else if (unformat (i, "laddr_start %U",
14503 unformat_vl_api_address, &laddr_start))
14505 else if (unformat (i, "laddr_stop %U", unformat_vl_api_address,
14508 else if (unformat (i, "raddr_start %U", unformat_vl_api_address,
14511 else if (unformat (i, "raddr_stop %U", unformat_vl_api_address,
14515 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
14517 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
14519 clib_warning ("unsupported action: 'resolve'");
14525 clib_warning ("parse error '%U'", format_unformat_error, i);
14531 M (IPSEC_SPD_ENTRY_ADD_DEL, mp);
14533 mp->is_add = is_add;
14535 mp->entry.spd_id = ntohl (spd_id);
14536 mp->entry.priority = ntohl (priority);
14537 mp->entry.is_outbound = is_outbound;
14539 clib_memcpy (&mp->entry.remote_address_start, &raddr_start,
14540 sizeof (vl_api_address_t));
14541 clib_memcpy (&mp->entry.remote_address_stop, &raddr_stop,
14542 sizeof (vl_api_address_t));
14543 clib_memcpy (&mp->entry.local_address_start, &laddr_start,
14544 sizeof (vl_api_address_t));
14545 clib_memcpy (&mp->entry.local_address_stop, &laddr_stop,
14546 sizeof (vl_api_address_t));
14548 mp->entry.protocol = (u8) protocol;
14549 mp->entry.local_port_start = ntohs ((u16) lport_start);
14550 mp->entry.local_port_stop = ntohs ((u16) lport_stop);
14551 mp->entry.remote_port_start = ntohs ((u16) rport_start);
14552 mp->entry.remote_port_stop = ntohs ((u16) rport_stop);
14553 mp->entry.policy = (u8) policy;
14554 mp->entry.sa_id = ntohl (sa_id);
14562 api_ipsec_sad_entry_add_del (vat_main_t * vam)
14564 unformat_input_t *i = vam->input;
14565 vl_api_ipsec_sad_entry_add_del_t *mp;
14566 u32 sad_id = 0, spi = 0;
14567 u8 *ck = 0, *ik = 0;
14570 vl_api_ipsec_crypto_alg_t crypto_alg = IPSEC_API_CRYPTO_ALG_NONE;
14571 vl_api_ipsec_integ_alg_t integ_alg = IPSEC_API_INTEG_ALG_NONE;
14572 vl_api_ipsec_sad_flags_t flags = IPSEC_API_SAD_FLAG_NONE;
14573 vl_api_ipsec_proto_t protocol = IPSEC_API_PROTO_AH;
14574 vl_api_address_t tun_src, tun_dst;
14577 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14579 if (unformat (i, "del"))
14581 else if (unformat (i, "sad_id %d", &sad_id))
14583 else if (unformat (i, "spi %d", &spi))
14585 else if (unformat (i, "esp"))
14586 protocol = IPSEC_API_PROTO_ESP;
14588 if (unformat (i, "tunnel_src %U", unformat_vl_api_address, &tun_src))
14590 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
14591 if (ADDRESS_IP6 == tun_src.af)
14592 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
14595 if (unformat (i, "tunnel_dst %U", unformat_vl_api_address, &tun_dst))
14597 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
14598 if (ADDRESS_IP6 == tun_src.af)
14599 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
14602 if (unformat (i, "crypto_alg %U",
14603 unformat_ipsec_api_crypto_alg, &crypto_alg))
14605 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14607 else if (unformat (i, "integ_alg %U",
14608 unformat_ipsec_api_integ_alg, &integ_alg))
14610 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14614 clib_warning ("parse error '%U'", format_unformat_error, i);
14620 M (IPSEC_SAD_ENTRY_ADD_DEL, mp);
14622 mp->is_add = is_add;
14623 mp->entry.sad_id = ntohl (sad_id);
14624 mp->entry.protocol = protocol;
14625 mp->entry.spi = ntohl (spi);
14626 mp->entry.flags = flags;
14628 mp->entry.crypto_algorithm = crypto_alg;
14629 mp->entry.integrity_algorithm = integ_alg;
14630 mp->entry.crypto_key.length = vec_len (ck);
14631 mp->entry.integrity_key.length = vec_len (ik);
14633 if (mp->entry.crypto_key.length > sizeof (mp->entry.crypto_key.data))
14634 mp->entry.crypto_key.length = sizeof (mp->entry.crypto_key.data);
14636 if (mp->entry.integrity_key.length > sizeof (mp->entry.integrity_key.data))
14637 mp->entry.integrity_key.length = sizeof (mp->entry.integrity_key.data);
14640 clib_memcpy (mp->entry.crypto_key.data, ck, mp->entry.crypto_key.length);
14642 clib_memcpy (mp->entry.integrity_key.data, ik,
14643 mp->entry.integrity_key.length);
14645 if (flags & IPSEC_API_SAD_FLAG_IS_TUNNEL)
14647 clib_memcpy (&mp->entry.tunnel_src, &tun_src,
14648 sizeof (mp->entry.tunnel_src));
14649 clib_memcpy (&mp->entry.tunnel_dst, &tun_dst,
14650 sizeof (mp->entry.tunnel_dst));
14659 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
14661 unformat_input_t *i = vam->input;
14662 vl_api_ipsec_tunnel_if_add_del_t *mp;
14663 u32 local_spi = 0, remote_spi = 0;
14664 u32 crypto_alg = 0, integ_alg = 0;
14665 u8 *lck = NULL, *rck = NULL;
14666 u8 *lik = NULL, *rik = NULL;
14667 vl_api_address_t local_ip = { 0 };
14668 vl_api_address_t remote_ip = { 0 };
14672 u8 anti_replay = 0;
14678 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14680 if (unformat (i, "del"))
14682 else if (unformat (i, "esn"))
14684 else if (unformat (i, "anti-replay"))
14686 else if (unformat (i, "count %d", &count))
14688 else if (unformat (i, "local_spi %d", &local_spi))
14690 else if (unformat (i, "remote_spi %d", &remote_spi))
14693 if (unformat (i, "local_ip %U", unformat_vl_api_address, &local_ip))
14696 if (unformat (i, "remote_ip %U", unformat_vl_api_address, &remote_ip))
14698 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
14701 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
14703 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
14705 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
14709 (i, "crypto_alg %U", unformat_ipsec_api_crypto_alg, &crypto_alg))
14711 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
14713 errmsg ("unsupported crypto-alg: '%U'\n",
14714 format_ipsec_crypto_alg, crypto_alg);
14720 (i, "integ_alg %U", unformat_ipsec_api_integ_alg, &integ_alg))
14722 if (integ_alg >= IPSEC_INTEG_N_ALG)
14724 errmsg ("unsupported integ-alg: '%U'\n",
14725 format_ipsec_integ_alg, integ_alg);
14729 else if (unformat (i, "instance %u", &instance))
14733 errmsg ("parse error '%U'\n", format_unformat_error, i);
14740 /* Turn on async mode */
14741 vam->async_mode = 1;
14742 vam->async_errors = 0;
14743 before = vat_time_now (vam);
14746 for (jj = 0; jj < count; jj++)
14748 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
14750 mp->is_add = is_add;
14752 mp->anti_replay = anti_replay;
14755 increment_address (&remote_ip);
14757 clib_memcpy (&mp->local_ip, &local_ip, sizeof (local_ip));
14758 clib_memcpy (&mp->remote_ip, &remote_ip, sizeof (remote_ip));
14760 mp->local_spi = htonl (local_spi + jj);
14761 mp->remote_spi = htonl (remote_spi + jj);
14762 mp->crypto_alg = (u8) crypto_alg;
14764 mp->local_crypto_key_len = 0;
14767 mp->local_crypto_key_len = vec_len (lck);
14768 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
14769 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
14770 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
14773 mp->remote_crypto_key_len = 0;
14776 mp->remote_crypto_key_len = vec_len (rck);
14777 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
14778 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
14779 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
14782 mp->integ_alg = (u8) integ_alg;
14784 mp->local_integ_key_len = 0;
14787 mp->local_integ_key_len = vec_len (lik);
14788 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
14789 mp->local_integ_key_len = sizeof (mp->local_integ_key);
14790 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
14793 mp->remote_integ_key_len = 0;
14796 mp->remote_integ_key_len = vec_len (rik);
14797 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
14798 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
14799 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
14804 mp->renumber = renumber;
14805 mp->show_instance = ntohl (instance);
14810 /* When testing multiple add/del ops, use a control-ping to sync */
14813 vl_api_control_ping_t *mp_ping;
14817 /* Shut off async mode */
14818 vam->async_mode = 0;
14820 MPING (CONTROL_PING, mp_ping);
14823 timeout = vat_time_now (vam) + 1.0;
14824 while (vat_time_now (vam) < timeout)
14825 if (vam->result_ready == 1)
14830 if (vam->retval == -99)
14831 errmsg ("timeout");
14833 if (vam->async_errors > 0)
14835 errmsg ("%d asynchronous errors", vam->async_errors);
14838 vam->async_errors = 0;
14839 after = vat_time_now (vam);
14841 /* slim chance, but we might have eaten SIGTERM on the first iteration */
14845 print (vam->ofp, "%d tunnels in %.6f secs, %.2f tunnels/sec",
14846 count, after - before, count / (after - before));
14850 /* Wait for a reply... */
14859 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
14861 vat_main_t *vam = &vat_main;
14863 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
14864 "crypto_key %U integ_alg %u integ_key %U flags %x "
14865 "tunnel_src_addr %U tunnel_dst_addr %U "
14866 "salt %u seq_outbound %lu last_seq_inbound %lu "
14867 "replay_window %lu\n",
14868 ntohl (mp->entry.sad_id),
14869 ntohl (mp->sw_if_index),
14870 ntohl (mp->entry.spi),
14871 ntohl (mp->entry.protocol),
14872 ntohl (mp->entry.crypto_algorithm),
14873 format_hex_bytes, mp->entry.crypto_key.data,
14874 mp->entry.crypto_key.length, ntohl (mp->entry.integrity_algorithm),
14875 format_hex_bytes, mp->entry.integrity_key.data,
14876 mp->entry.integrity_key.length, ntohl (mp->entry.flags),
14877 format_vl_api_address, &mp->entry.tunnel_src, format_vl_api_address,
14878 &mp->entry.tunnel_dst, ntohl (mp->salt),
14879 clib_net_to_host_u64 (mp->seq_outbound),
14880 clib_net_to_host_u64 (mp->last_seq_inbound),
14881 clib_net_to_host_u64 (mp->replay_window));
14884 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
14885 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
14887 static void vl_api_ipsec_sa_details_t_handler_json
14888 (vl_api_ipsec_sa_details_t * mp)
14890 vat_main_t *vam = &vat_main;
14891 vat_json_node_t *node = NULL;
14892 vl_api_ipsec_sad_flags_t flags;
14894 if (VAT_JSON_ARRAY != vam->json_tree.type)
14896 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14897 vat_json_init_array (&vam->json_tree);
14899 node = vat_json_array_add (&vam->json_tree);
14901 vat_json_init_object (node);
14902 vat_json_object_add_uint (node, "sa_id", ntohl (mp->entry.sad_id));
14903 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14904 vat_json_object_add_uint (node, "spi", ntohl (mp->entry.spi));
14905 vat_json_object_add_uint (node, "proto", ntohl (mp->entry.protocol));
14906 vat_json_object_add_uint (node, "crypto_alg",
14907 ntohl (mp->entry.crypto_algorithm));
14908 vat_json_object_add_uint (node, "integ_alg",
14909 ntohl (mp->entry.integrity_algorithm));
14910 flags = ntohl (mp->entry.flags);
14911 vat_json_object_add_uint (node, "use_esn",
14912 ! !(flags & IPSEC_API_SAD_FLAG_USE_ESN));
14913 vat_json_object_add_uint (node, "use_anti_replay",
14914 ! !(flags & IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY));
14915 vat_json_object_add_uint (node, "is_tunnel",
14916 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL));
14917 vat_json_object_add_uint (node, "is_tunnel_ip6",
14918 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL_V6));
14919 vat_json_object_add_uint (node, "udp_encap",
14920 ! !(flags & IPSEC_API_SAD_FLAG_UDP_ENCAP));
14921 vat_json_object_add_bytes (node, "crypto_key", mp->entry.crypto_key.data,
14922 mp->entry.crypto_key.length);
14923 vat_json_object_add_bytes (node, "integ_key", mp->entry.integrity_key.data,
14924 mp->entry.integrity_key.length);
14925 vat_json_object_add_address (node, "src", &mp->entry.tunnel_src);
14926 vat_json_object_add_address (node, "dst", &mp->entry.tunnel_dst);
14927 vat_json_object_add_uint (node, "replay_window",
14928 clib_net_to_host_u64 (mp->replay_window));
14932 api_ipsec_sa_dump (vat_main_t * vam)
14934 unformat_input_t *i = vam->input;
14935 vl_api_ipsec_sa_dump_t *mp;
14936 vl_api_control_ping_t *mp_ping;
14940 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14942 if (unformat (i, "sa_id %d", &sa_id))
14946 clib_warning ("parse error '%U'", format_unformat_error, i);
14951 M (IPSEC_SA_DUMP, mp);
14953 mp->sa_id = ntohl (sa_id);
14957 /* Use a control ping for synchronization */
14958 M (CONTROL_PING, mp_ping);
14966 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
14968 unformat_input_t *i = vam->input;
14969 vl_api_ipsec_tunnel_if_set_sa_t *mp;
14970 u32 sw_if_index = ~0;
14972 u8 is_outbound = (u8) ~ 0;
14975 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14977 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14979 else if (unformat (i, "sa_id %d", &sa_id))
14981 else if (unformat (i, "outbound"))
14983 else if (unformat (i, "inbound"))
14987 clib_warning ("parse error '%U'", format_unformat_error, i);
14992 if (sw_if_index == ~0)
14994 errmsg ("interface must be specified");
15000 errmsg ("SA ID must be specified");
15004 M (IPSEC_TUNNEL_IF_SET_SA, mp);
15006 mp->sw_if_index = htonl (sw_if_index);
15007 mp->sa_id = htonl (sa_id);
15008 mp->is_outbound = is_outbound;
15017 api_get_first_msg_id (vat_main_t * vam)
15019 vl_api_get_first_msg_id_t *mp;
15020 unformat_input_t *i = vam->input;
15025 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15027 if (unformat (i, "client %s", &name))
15035 errmsg ("missing client name");
15038 vec_add1 (name, 0);
15040 if (vec_len (name) > 63)
15042 errmsg ("client name too long");
15046 M (GET_FIRST_MSG_ID, mp);
15047 clib_memcpy (mp->name, name, vec_len (name));
15054 api_cop_interface_enable_disable (vat_main_t * vam)
15056 unformat_input_t *line_input = vam->input;
15057 vl_api_cop_interface_enable_disable_t *mp;
15058 u32 sw_if_index = ~0;
15059 u8 enable_disable = 1;
15062 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15064 if (unformat (line_input, "disable"))
15065 enable_disable = 0;
15066 if (unformat (line_input, "enable"))
15067 enable_disable = 1;
15068 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15069 vam, &sw_if_index))
15071 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15077 if (sw_if_index == ~0)
15079 errmsg ("missing interface name or sw_if_index");
15083 /* Construct the API message */
15084 M (COP_INTERFACE_ENABLE_DISABLE, mp);
15085 mp->sw_if_index = ntohl (sw_if_index);
15086 mp->enable_disable = enable_disable;
15090 /* Wait for the reply */
15096 api_cop_whitelist_enable_disable (vat_main_t * vam)
15098 unformat_input_t *line_input = vam->input;
15099 vl_api_cop_whitelist_enable_disable_t *mp;
15100 u32 sw_if_index = ~0;
15101 u8 ip4 = 0, ip6 = 0, default_cop = 0;
15105 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15107 if (unformat (line_input, "ip4"))
15109 else if (unformat (line_input, "ip6"))
15111 else if (unformat (line_input, "default"))
15113 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15114 vam, &sw_if_index))
15116 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15118 else if (unformat (line_input, "fib-id %d", &fib_id))
15124 if (sw_if_index == ~0)
15126 errmsg ("missing interface name or sw_if_index");
15130 /* Construct the API message */
15131 M (COP_WHITELIST_ENABLE_DISABLE, mp);
15132 mp->sw_if_index = ntohl (sw_if_index);
15133 mp->fib_id = ntohl (fib_id);
15136 mp->default_cop = default_cop;
15140 /* Wait for the reply */
15146 api_get_node_graph (vat_main_t * vam)
15148 vl_api_get_node_graph_t *mp;
15151 M (GET_NODE_GRAPH, mp);
15155 /* Wait for the reply */
15161 /** Used for parsing LISP eids */
15162 typedef CLIB_PACKED(struct{
15163 u8 addr[16]; /**< eid address */
15164 u32 len; /**< prefix length if IP */
15165 u8 type; /**< type of eid */
15170 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
15172 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
15174 clib_memset (a, 0, sizeof (a[0]));
15176 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
15178 a->type = 0; /* ipv4 type */
15180 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
15182 a->type = 1; /* ipv6 type */
15184 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
15186 a->type = 2; /* mac type */
15188 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
15190 a->type = 3; /* NSH type */
15191 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
15192 nsh->spi = clib_host_to_net_u32 (nsh->spi);
15199 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
15208 lisp_eid_size_vat (u8 type)
15225 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
15227 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
15231 api_one_add_del_locator_set (vat_main_t * vam)
15233 unformat_input_t *input = vam->input;
15234 vl_api_one_add_del_locator_set_t *mp;
15236 u8 *locator_set_name = NULL;
15237 u8 locator_set_name_set = 0;
15238 vl_api_local_locator_t locator, *locators = 0;
15239 u32 sw_if_index, priority, weight;
15243 /* Parse args required to build the message */
15244 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15246 if (unformat (input, "del"))
15250 else if (unformat (input, "locator-set %s", &locator_set_name))
15252 locator_set_name_set = 1;
15254 else if (unformat (input, "sw_if_index %u p %u w %u",
15255 &sw_if_index, &priority, &weight))
15257 locator.sw_if_index = htonl (sw_if_index);
15258 locator.priority = priority;
15259 locator.weight = weight;
15260 vec_add1 (locators, locator);
15264 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
15265 &sw_if_index, &priority, &weight))
15267 locator.sw_if_index = htonl (sw_if_index);
15268 locator.priority = priority;
15269 locator.weight = weight;
15270 vec_add1 (locators, locator);
15276 if (locator_set_name_set == 0)
15278 errmsg ("missing locator-set name");
15279 vec_free (locators);
15283 if (vec_len (locator_set_name) > 64)
15285 errmsg ("locator-set name too long");
15286 vec_free (locator_set_name);
15287 vec_free (locators);
15290 vec_add1 (locator_set_name, 0);
15292 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
15294 /* Construct the API message */
15295 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
15297 mp->is_add = is_add;
15298 clib_memcpy (mp->locator_set_name, locator_set_name,
15299 vec_len (locator_set_name));
15300 vec_free (locator_set_name);
15302 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
15304 clib_memcpy (mp->locators, locators, data_len);
15305 vec_free (locators);
15310 /* Wait for a reply... */
15315 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
15318 api_one_add_del_locator (vat_main_t * vam)
15320 unformat_input_t *input = vam->input;
15321 vl_api_one_add_del_locator_t *mp;
15322 u32 tmp_if_index = ~0;
15323 u32 sw_if_index = ~0;
15324 u8 sw_if_index_set = 0;
15325 u8 sw_if_index_if_name_set = 0;
15327 u8 priority_set = 0;
15331 u8 *locator_set_name = NULL;
15332 u8 locator_set_name_set = 0;
15335 /* Parse args required to build the message */
15336 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15338 if (unformat (input, "del"))
15342 else if (unformat (input, "locator-set %s", &locator_set_name))
15344 locator_set_name_set = 1;
15346 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
15349 sw_if_index_if_name_set = 1;
15350 sw_if_index = tmp_if_index;
15352 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
15354 sw_if_index_set = 1;
15355 sw_if_index = tmp_if_index;
15357 else if (unformat (input, "p %d", &priority))
15361 else if (unformat (input, "w %d", &weight))
15369 if (locator_set_name_set == 0)
15371 errmsg ("missing locator-set name");
15375 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
15377 errmsg ("missing sw_if_index");
15378 vec_free (locator_set_name);
15382 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
15384 errmsg ("cannot use both params interface name and sw_if_index");
15385 vec_free (locator_set_name);
15389 if (priority_set == 0)
15391 errmsg ("missing locator-set priority");
15392 vec_free (locator_set_name);
15396 if (weight_set == 0)
15398 errmsg ("missing locator-set weight");
15399 vec_free (locator_set_name);
15403 if (vec_len (locator_set_name) > 64)
15405 errmsg ("locator-set name too long");
15406 vec_free (locator_set_name);
15409 vec_add1 (locator_set_name, 0);
15411 /* Construct the API message */
15412 M (ONE_ADD_DEL_LOCATOR, mp);
15414 mp->is_add = is_add;
15415 mp->sw_if_index = ntohl (sw_if_index);
15416 mp->priority = priority;
15417 mp->weight = weight;
15418 clib_memcpy (mp->locator_set_name, locator_set_name,
15419 vec_len (locator_set_name));
15420 vec_free (locator_set_name);
15425 /* Wait for a reply... */
15430 #define api_lisp_add_del_locator api_one_add_del_locator
15433 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
15435 u32 *key_id = va_arg (*args, u32 *);
15438 if (unformat (input, "%s", &s))
15440 if (!strcmp ((char *) s, "sha1"))
15441 key_id[0] = HMAC_SHA_1_96;
15442 else if (!strcmp ((char *) s, "sha256"))
15443 key_id[0] = HMAC_SHA_256_128;
15446 clib_warning ("invalid key_id: '%s'", s);
15447 key_id[0] = HMAC_NO_KEY;
15458 api_one_add_del_local_eid (vat_main_t * vam)
15460 unformat_input_t *input = vam->input;
15461 vl_api_one_add_del_local_eid_t *mp;
15464 lisp_eid_vat_t _eid, *eid = &_eid;
15465 u8 *locator_set_name = 0;
15466 u8 locator_set_name_set = 0;
15472 /* Parse args required to build the message */
15473 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15475 if (unformat (input, "del"))
15479 else if (unformat (input, "vni %d", &vni))
15483 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15487 else if (unformat (input, "locator-set %s", &locator_set_name))
15489 locator_set_name_set = 1;
15491 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
15493 else if (unformat (input, "secret-key %_%v%_", &key))
15499 if (locator_set_name_set == 0)
15501 errmsg ("missing locator-set name");
15507 errmsg ("EID address not set!");
15508 vec_free (locator_set_name);
15512 if (key && (0 == key_id))
15514 errmsg ("invalid key_id!");
15518 if (vec_len (key) > 64)
15520 errmsg ("key too long");
15525 if (vec_len (locator_set_name) > 64)
15527 errmsg ("locator-set name too long");
15528 vec_free (locator_set_name);
15531 vec_add1 (locator_set_name, 0);
15533 /* Construct the API message */
15534 M (ONE_ADD_DEL_LOCAL_EID, mp);
15536 mp->is_add = is_add;
15537 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15538 mp->eid_type = eid->type;
15539 mp->prefix_len = eid->len;
15540 mp->vni = clib_host_to_net_u32 (vni);
15541 mp->key_id = clib_host_to_net_u16 (key_id);
15542 clib_memcpy (mp->locator_set_name, locator_set_name,
15543 vec_len (locator_set_name));
15544 clib_memcpy (mp->key, key, vec_len (key));
15546 vec_free (locator_set_name);
15552 /* Wait for a reply... */
15557 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
15560 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
15562 u32 dp_table = 0, vni = 0;;
15563 unformat_input_t *input = vam->input;
15564 vl_api_gpe_add_del_fwd_entry_t *mp;
15566 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
15567 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
15568 u8 rmt_eid_set = 0, lcl_eid_set = 0;
15569 u32 action = ~0, w;
15570 ip4_address_t rmt_rloc4, lcl_rloc4;
15571 ip6_address_t rmt_rloc6, lcl_rloc6;
15572 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
15575 clib_memset (&rloc, 0, sizeof (rloc));
15577 /* Parse args required to build the message */
15578 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15580 if (unformat (input, "del"))
15582 else if (unformat (input, "add"))
15584 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
15588 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
15592 else if (unformat (input, "vrf %d", &dp_table))
15594 else if (unformat (input, "bd %d", &dp_table))
15596 else if (unformat (input, "vni %d", &vni))
15598 else if (unformat (input, "w %d", &w))
15602 errmsg ("No RLOC configured for setting priority/weight!");
15605 curr_rloc->weight = w;
15607 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
15608 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
15612 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
15614 vec_add1 (lcl_locs, rloc);
15616 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
15617 vec_add1 (rmt_locs, rloc);
15618 /* weight saved in rmt loc */
15619 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15621 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
15622 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
15625 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
15627 vec_add1 (lcl_locs, rloc);
15629 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
15630 vec_add1 (rmt_locs, rloc);
15631 /* weight saved in rmt loc */
15632 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15634 else if (unformat (input, "action %d", &action))
15640 clib_warning ("parse error '%U'", format_unformat_error, input);
15647 errmsg ("remote eid addresses not set");
15651 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
15653 errmsg ("eid types don't match");
15657 if (0 == rmt_locs && (u32) ~ 0 == action)
15659 errmsg ("action not set for negative mapping");
15663 /* Construct the API message */
15664 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
15665 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
15667 mp->is_add = is_add;
15668 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
15669 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
15670 mp->eid_type = rmt_eid->type;
15671 mp->dp_table = clib_host_to_net_u32 (dp_table);
15672 mp->vni = clib_host_to_net_u32 (vni);
15673 mp->rmt_len = rmt_eid->len;
15674 mp->lcl_len = lcl_eid->len;
15675 mp->action = action;
15677 if (0 != rmt_locs && 0 != lcl_locs)
15679 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
15680 clib_memcpy (mp->locs, lcl_locs,
15681 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
15683 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
15684 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
15685 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
15687 vec_free (lcl_locs);
15688 vec_free (rmt_locs);
15693 /* Wait for a reply... */
15699 api_one_add_del_map_server (vat_main_t * vam)
15701 unformat_input_t *input = vam->input;
15702 vl_api_one_add_del_map_server_t *mp;
15706 ip4_address_t ipv4;
15707 ip6_address_t ipv6;
15710 /* Parse args required to build the message */
15711 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15713 if (unformat (input, "del"))
15717 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15721 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15729 if (ipv4_set && ipv6_set)
15731 errmsg ("both eid v4 and v6 addresses set");
15735 if (!ipv4_set && !ipv6_set)
15737 errmsg ("eid addresses not set");
15741 /* Construct the API message */
15742 M (ONE_ADD_DEL_MAP_SERVER, mp);
15744 mp->is_add = is_add;
15748 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
15753 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
15759 /* Wait for a reply... */
15764 #define api_lisp_add_del_map_server api_one_add_del_map_server
15767 api_one_add_del_map_resolver (vat_main_t * vam)
15769 unformat_input_t *input = vam->input;
15770 vl_api_one_add_del_map_resolver_t *mp;
15774 ip4_address_t ipv4;
15775 ip6_address_t ipv6;
15778 /* Parse args required to build the message */
15779 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15781 if (unformat (input, "del"))
15785 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15789 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15797 if (ipv4_set && ipv6_set)
15799 errmsg ("both eid v4 and v6 addresses set");
15803 if (!ipv4_set && !ipv6_set)
15805 errmsg ("eid addresses not set");
15809 /* Construct the API message */
15810 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
15812 mp->is_add = is_add;
15816 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
15821 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
15827 /* Wait for a reply... */
15832 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
15835 api_lisp_gpe_enable_disable (vat_main_t * vam)
15837 unformat_input_t *input = vam->input;
15838 vl_api_gpe_enable_disable_t *mp;
15843 /* Parse args required to build the message */
15844 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15846 if (unformat (input, "enable"))
15851 else if (unformat (input, "disable"))
15862 errmsg ("Value not set");
15866 /* Construct the API message */
15867 M (GPE_ENABLE_DISABLE, mp);
15874 /* Wait for a reply... */
15880 api_one_rloc_probe_enable_disable (vat_main_t * vam)
15882 unformat_input_t *input = vam->input;
15883 vl_api_one_rloc_probe_enable_disable_t *mp;
15888 /* Parse args required to build the message */
15889 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15891 if (unformat (input, "enable"))
15896 else if (unformat (input, "disable"))
15904 errmsg ("Value not set");
15908 /* Construct the API message */
15909 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
15911 mp->is_enabled = is_en;
15916 /* Wait for a reply... */
15921 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
15924 api_one_map_register_enable_disable (vat_main_t * vam)
15926 unformat_input_t *input = vam->input;
15927 vl_api_one_map_register_enable_disable_t *mp;
15932 /* Parse args required to build the message */
15933 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15935 if (unformat (input, "enable"))
15940 else if (unformat (input, "disable"))
15948 errmsg ("Value not set");
15952 /* Construct the API message */
15953 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
15955 mp->is_enabled = is_en;
15960 /* Wait for a reply... */
15965 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
15968 api_one_enable_disable (vat_main_t * vam)
15970 unformat_input_t *input = vam->input;
15971 vl_api_one_enable_disable_t *mp;
15976 /* Parse args required to build the message */
15977 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15979 if (unformat (input, "enable"))
15984 else if (unformat (input, "disable"))
15994 errmsg ("Value not set");
15998 /* Construct the API message */
15999 M (ONE_ENABLE_DISABLE, mp);
16006 /* Wait for a reply... */
16011 #define api_lisp_enable_disable api_one_enable_disable
16014 api_one_enable_disable_xtr_mode (vat_main_t * vam)
16016 unformat_input_t *input = vam->input;
16017 vl_api_one_enable_disable_xtr_mode_t *mp;
16022 /* Parse args required to build the message */
16023 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16025 if (unformat (input, "enable"))
16030 else if (unformat (input, "disable"))
16040 errmsg ("Value not set");
16044 /* Construct the API message */
16045 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
16052 /* Wait for a reply... */
16058 api_one_show_xtr_mode (vat_main_t * vam)
16060 vl_api_one_show_xtr_mode_t *mp;
16063 /* Construct the API message */
16064 M (ONE_SHOW_XTR_MODE, mp);
16069 /* Wait for a reply... */
16075 api_one_enable_disable_pitr_mode (vat_main_t * vam)
16077 unformat_input_t *input = vam->input;
16078 vl_api_one_enable_disable_pitr_mode_t *mp;
16083 /* Parse args required to build the message */
16084 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16086 if (unformat (input, "enable"))
16091 else if (unformat (input, "disable"))
16101 errmsg ("Value not set");
16105 /* Construct the API message */
16106 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
16113 /* Wait for a reply... */
16119 api_one_show_pitr_mode (vat_main_t * vam)
16121 vl_api_one_show_pitr_mode_t *mp;
16124 /* Construct the API message */
16125 M (ONE_SHOW_PITR_MODE, mp);
16130 /* Wait for a reply... */
16136 api_one_enable_disable_petr_mode (vat_main_t * vam)
16138 unformat_input_t *input = vam->input;
16139 vl_api_one_enable_disable_petr_mode_t *mp;
16144 /* Parse args required to build the message */
16145 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16147 if (unformat (input, "enable"))
16152 else if (unformat (input, "disable"))
16162 errmsg ("Value not set");
16166 /* Construct the API message */
16167 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
16174 /* Wait for a reply... */
16180 api_one_show_petr_mode (vat_main_t * vam)
16182 vl_api_one_show_petr_mode_t *mp;
16185 /* Construct the API message */
16186 M (ONE_SHOW_PETR_MODE, mp);
16191 /* Wait for a reply... */
16197 api_show_one_map_register_state (vat_main_t * vam)
16199 vl_api_show_one_map_register_state_t *mp;
16202 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
16207 /* wait for reply */
16212 #define api_show_lisp_map_register_state api_show_one_map_register_state
16215 api_show_one_rloc_probe_state (vat_main_t * vam)
16217 vl_api_show_one_rloc_probe_state_t *mp;
16220 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
16225 /* wait for reply */
16230 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
16233 api_one_add_del_ndp_entry (vat_main_t * vam)
16235 vl_api_one_add_del_ndp_entry_t *mp;
16236 unformat_input_t *input = vam->input;
16241 u8 mac[6] = { 0, };
16242 u8 ip6[16] = { 0, };
16246 /* Parse args required to build the message */
16247 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16249 if (unformat (input, "del"))
16251 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16253 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
16255 else if (unformat (input, "bd %d", &bd))
16259 errmsg ("parse error '%U'", format_unformat_error, input);
16264 if (!bd_set || !ip_set || (!mac_set && is_add))
16266 errmsg ("Missing BD, IP or MAC!");
16270 M (ONE_ADD_DEL_NDP_ENTRY, mp);
16271 mp->is_add = is_add;
16272 clib_memcpy (mp->mac, mac, 6);
16273 mp->bd = clib_host_to_net_u32 (bd);
16274 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
16279 /* wait for reply */
16285 api_one_add_del_l2_arp_entry (vat_main_t * vam)
16287 vl_api_one_add_del_l2_arp_entry_t *mp;
16288 unformat_input_t *input = vam->input;
16293 u8 mac[6] = { 0, };
16294 u32 ip4 = 0, bd = ~0;
16297 /* Parse args required to build the message */
16298 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16300 if (unformat (input, "del"))
16302 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16304 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
16306 else if (unformat (input, "bd %d", &bd))
16310 errmsg ("parse error '%U'", format_unformat_error, input);
16315 if (!bd_set || !ip_set || (!mac_set && is_add))
16317 errmsg ("Missing BD, IP or MAC!");
16321 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
16322 mp->is_add = is_add;
16323 clib_memcpy (mp->mac, mac, 6);
16324 mp->bd = clib_host_to_net_u32 (bd);
16330 /* wait for reply */
16336 api_one_ndp_bd_get (vat_main_t * vam)
16338 vl_api_one_ndp_bd_get_t *mp;
16341 M (ONE_NDP_BD_GET, mp);
16346 /* wait for reply */
16352 api_one_ndp_entries_get (vat_main_t * vam)
16354 vl_api_one_ndp_entries_get_t *mp;
16355 unformat_input_t *input = vam->input;
16360 /* Parse args required to build the message */
16361 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16363 if (unformat (input, "bd %d", &bd))
16367 errmsg ("parse error '%U'", format_unformat_error, input);
16374 errmsg ("Expected bridge domain!");
16378 M (ONE_NDP_ENTRIES_GET, mp);
16379 mp->bd = clib_host_to_net_u32 (bd);
16384 /* wait for reply */
16390 api_one_l2_arp_bd_get (vat_main_t * vam)
16392 vl_api_one_l2_arp_bd_get_t *mp;
16395 M (ONE_L2_ARP_BD_GET, mp);
16400 /* wait for reply */
16406 api_one_l2_arp_entries_get (vat_main_t * vam)
16408 vl_api_one_l2_arp_entries_get_t *mp;
16409 unformat_input_t *input = vam->input;
16414 /* Parse args required to build the message */
16415 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16417 if (unformat (input, "bd %d", &bd))
16421 errmsg ("parse error '%U'", format_unformat_error, input);
16428 errmsg ("Expected bridge domain!");
16432 M (ONE_L2_ARP_ENTRIES_GET, mp);
16433 mp->bd = clib_host_to_net_u32 (bd);
16438 /* wait for reply */
16444 api_one_stats_enable_disable (vat_main_t * vam)
16446 vl_api_one_stats_enable_disable_t *mp;
16447 unformat_input_t *input = vam->input;
16452 /* Parse args required to build the message */
16453 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16455 if (unformat (input, "enable"))
16460 else if (unformat (input, "disable"))
16470 errmsg ("Value not set");
16474 M (ONE_STATS_ENABLE_DISABLE, mp);
16480 /* wait for reply */
16486 api_show_one_stats_enable_disable (vat_main_t * vam)
16488 vl_api_show_one_stats_enable_disable_t *mp;
16491 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
16496 /* wait for reply */
16502 api_show_one_map_request_mode (vat_main_t * vam)
16504 vl_api_show_one_map_request_mode_t *mp;
16507 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
16512 /* wait for reply */
16517 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
16520 api_one_map_request_mode (vat_main_t * vam)
16522 unformat_input_t *input = vam->input;
16523 vl_api_one_map_request_mode_t *mp;
16527 /* Parse args required to build the message */
16528 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16530 if (unformat (input, "dst-only"))
16532 else if (unformat (input, "src-dst"))
16536 errmsg ("parse error '%U'", format_unformat_error, input);
16541 M (ONE_MAP_REQUEST_MODE, mp);
16548 /* wait for reply */
16553 #define api_lisp_map_request_mode api_one_map_request_mode
16556 * Enable/disable ONE proxy ITR.
16558 * @param vam vpp API test context
16559 * @return return code
16562 api_one_pitr_set_locator_set (vat_main_t * vam)
16564 u8 ls_name_set = 0;
16565 unformat_input_t *input = vam->input;
16566 vl_api_one_pitr_set_locator_set_t *mp;
16571 /* Parse args required to build the message */
16572 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16574 if (unformat (input, "del"))
16576 else if (unformat (input, "locator-set %s", &ls_name))
16580 errmsg ("parse error '%U'", format_unformat_error, input);
16587 errmsg ("locator-set name not set!");
16591 M (ONE_PITR_SET_LOCATOR_SET, mp);
16593 mp->is_add = is_add;
16594 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16595 vec_free (ls_name);
16600 /* wait for reply */
16605 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
16608 api_one_nsh_set_locator_set (vat_main_t * vam)
16610 u8 ls_name_set = 0;
16611 unformat_input_t *input = vam->input;
16612 vl_api_one_nsh_set_locator_set_t *mp;
16617 /* Parse args required to build the message */
16618 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16620 if (unformat (input, "del"))
16622 else if (unformat (input, "ls %s", &ls_name))
16626 errmsg ("parse error '%U'", format_unformat_error, input);
16631 if (!ls_name_set && is_add)
16633 errmsg ("locator-set name not set!");
16637 M (ONE_NSH_SET_LOCATOR_SET, mp);
16639 mp->is_add = is_add;
16640 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16641 vec_free (ls_name);
16646 /* wait for reply */
16652 api_show_one_pitr (vat_main_t * vam)
16654 vl_api_show_one_pitr_t *mp;
16657 if (!vam->json_output)
16659 print (vam->ofp, "%=20s", "lisp status:");
16662 M (SHOW_ONE_PITR, mp);
16666 /* Wait for a reply... */
16671 #define api_show_lisp_pitr api_show_one_pitr
16674 api_one_use_petr (vat_main_t * vam)
16676 unformat_input_t *input = vam->input;
16677 vl_api_one_use_petr_t *mp;
16682 clib_memset (&ip, 0, sizeof (ip));
16684 /* Parse args required to build the message */
16685 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16687 if (unformat (input, "disable"))
16690 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
16693 ip_addr_version (&ip) = IP4;
16696 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
16699 ip_addr_version (&ip) = IP6;
16703 errmsg ("parse error '%U'", format_unformat_error, input);
16708 M (ONE_USE_PETR, mp);
16710 mp->is_add = is_add;
16713 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
16715 clib_memcpy (mp->address, &ip, 4);
16717 clib_memcpy (mp->address, &ip, 16);
16723 /* wait for reply */
16728 #define api_lisp_use_petr api_one_use_petr
16731 api_show_one_nsh_mapping (vat_main_t * vam)
16733 vl_api_show_one_use_petr_t *mp;
16736 if (!vam->json_output)
16738 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
16741 M (SHOW_ONE_NSH_MAPPING, mp);
16745 /* Wait for a reply... */
16751 api_show_one_use_petr (vat_main_t * vam)
16753 vl_api_show_one_use_petr_t *mp;
16756 if (!vam->json_output)
16758 print (vam->ofp, "%=20s", "Proxy-ETR status:");
16761 M (SHOW_ONE_USE_PETR, mp);
16765 /* Wait for a reply... */
16770 #define api_show_lisp_use_petr api_show_one_use_petr
16773 * Add/delete mapping between vni and vrf
16776 api_one_eid_table_add_del_map (vat_main_t * vam)
16778 unformat_input_t *input = vam->input;
16779 vl_api_one_eid_table_add_del_map_t *mp;
16780 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
16781 u32 vni, vrf, bd_index;
16784 /* Parse args required to build the message */
16785 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16787 if (unformat (input, "del"))
16789 else if (unformat (input, "vrf %d", &vrf))
16791 else if (unformat (input, "bd_index %d", &bd_index))
16793 else if (unformat (input, "vni %d", &vni))
16799 if (!vni_set || (!vrf_set && !bd_index_set))
16801 errmsg ("missing arguments!");
16805 if (vrf_set && bd_index_set)
16807 errmsg ("error: both vrf and bd entered!");
16811 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
16813 mp->is_add = is_add;
16814 mp->vni = htonl (vni);
16815 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
16816 mp->is_l2 = bd_index_set;
16821 /* wait for reply */
16826 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
16829 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
16831 u32 *action = va_arg (*args, u32 *);
16834 if (unformat (input, "%s", &s))
16836 if (!strcmp ((char *) s, "no-action"))
16838 else if (!strcmp ((char *) s, "natively-forward"))
16840 else if (!strcmp ((char *) s, "send-map-request"))
16842 else if (!strcmp ((char *) s, "drop"))
16846 clib_warning ("invalid action: '%s'", s);
16858 * Add/del remote mapping to/from ONE control plane
16860 * @param vam vpp API test context
16861 * @return return code
16864 api_one_add_del_remote_mapping (vat_main_t * vam)
16866 unformat_input_t *input = vam->input;
16867 vl_api_one_add_del_remote_mapping_t *mp;
16869 lisp_eid_vat_t _eid, *eid = &_eid;
16870 lisp_eid_vat_t _seid, *seid = &_seid;
16871 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
16872 u32 action = ~0, p, w, data_len;
16873 ip4_address_t rloc4;
16874 ip6_address_t rloc6;
16875 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
16878 clib_memset (&rloc, 0, sizeof (rloc));
16880 /* Parse args required to build the message */
16881 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16883 if (unformat (input, "del-all"))
16887 else if (unformat (input, "del"))
16891 else if (unformat (input, "add"))
16895 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
16899 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
16903 else if (unformat (input, "vni %d", &vni))
16907 else if (unformat (input, "p %d w %d", &p, &w))
16911 errmsg ("No RLOC configured for setting priority/weight!");
16914 curr_rloc->priority = p;
16915 curr_rloc->weight = w;
16917 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
16920 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
16921 vec_add1 (rlocs, rloc);
16922 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16924 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
16927 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
16928 vec_add1 (rlocs, rloc);
16929 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16931 else if (unformat (input, "action %U",
16932 unformat_negative_mapping_action, &action))
16938 clib_warning ("parse error '%U'", format_unformat_error, input);
16945 errmsg ("missing params!");
16949 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
16951 errmsg ("no action set for negative map-reply!");
16955 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
16957 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
16958 mp->is_add = is_add;
16959 mp->vni = htonl (vni);
16960 mp->action = (u8) action;
16961 mp->is_src_dst = seid_set;
16962 mp->eid_len = eid->len;
16963 mp->seid_len = seid->len;
16964 mp->del_all = del_all;
16965 mp->eid_type = eid->type;
16966 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
16967 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
16969 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
16970 clib_memcpy (mp->rlocs, rlocs, data_len);
16976 /* Wait for a reply... */
16981 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
16984 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
16985 * forwarding entries in data-plane accordingly.
16987 * @param vam vpp API test context
16988 * @return return code
16991 api_one_add_del_adjacency (vat_main_t * vam)
16993 unformat_input_t *input = vam->input;
16994 vl_api_one_add_del_adjacency_t *mp;
16996 ip4_address_t leid4, reid4;
16997 ip6_address_t leid6, reid6;
16998 u8 reid_mac[6] = { 0 };
16999 u8 leid_mac[6] = { 0 };
17000 u8 reid_type, leid_type;
17001 u32 leid_len = 0, reid_len = 0, len;
17005 leid_type = reid_type = (u8) ~ 0;
17007 /* Parse args required to build the message */
17008 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17010 if (unformat (input, "del"))
17014 else if (unformat (input, "add"))
17018 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
17021 reid_type = 0; /* ipv4 */
17024 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
17027 reid_type = 1; /* ipv6 */
17030 else if (unformat (input, "reid %U", unformat_ethernet_address,
17033 reid_type = 2; /* mac */
17035 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
17038 leid_type = 0; /* ipv4 */
17041 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
17044 leid_type = 1; /* ipv6 */
17047 else if (unformat (input, "leid %U", unformat_ethernet_address,
17050 leid_type = 2; /* mac */
17052 else if (unformat (input, "vni %d", &vni))
17058 errmsg ("parse error '%U'", format_unformat_error, input);
17063 if ((u8) ~ 0 == reid_type)
17065 errmsg ("missing params!");
17069 if (leid_type != reid_type)
17071 errmsg ("remote and local EIDs are of different types!");
17075 M (ONE_ADD_DEL_ADJACENCY, mp);
17076 mp->is_add = is_add;
17077 mp->vni = htonl (vni);
17078 mp->leid_len = leid_len;
17079 mp->reid_len = reid_len;
17080 mp->eid_type = reid_type;
17082 switch (mp->eid_type)
17085 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
17086 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
17089 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
17090 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
17093 clib_memcpy (mp->leid, leid_mac, 6);
17094 clib_memcpy (mp->reid, reid_mac, 6);
17097 errmsg ("unknown EID type %d!", mp->eid_type);
17104 /* Wait for a reply... */
17109 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
17112 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
17114 u32 *mode = va_arg (*args, u32 *);
17116 if (unformat (input, "lisp"))
17118 else if (unformat (input, "vxlan"))
17127 api_gpe_get_encap_mode (vat_main_t * vam)
17129 vl_api_gpe_get_encap_mode_t *mp;
17132 /* Construct the API message */
17133 M (GPE_GET_ENCAP_MODE, mp);
17138 /* Wait for a reply... */
17144 api_gpe_set_encap_mode (vat_main_t * vam)
17146 unformat_input_t *input = vam->input;
17147 vl_api_gpe_set_encap_mode_t *mp;
17151 /* Parse args required to build the message */
17152 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17154 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
17160 /* Construct the API message */
17161 M (GPE_SET_ENCAP_MODE, mp);
17168 /* Wait for a reply... */
17174 api_lisp_gpe_add_del_iface (vat_main_t * vam)
17176 unformat_input_t *input = vam->input;
17177 vl_api_gpe_add_del_iface_t *mp;
17178 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
17179 u32 dp_table = 0, vni = 0;
17182 /* Parse args required to build the message */
17183 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17185 if (unformat (input, "up"))
17190 else if (unformat (input, "down"))
17195 else if (unformat (input, "table_id %d", &dp_table))
17199 else if (unformat (input, "bd_id %d", &dp_table))
17204 else if (unformat (input, "vni %d", &vni))
17212 if (action_set == 0)
17214 errmsg ("Action not set");
17217 if (dp_table_set == 0 || vni_set == 0)
17219 errmsg ("vni and dp_table must be set");
17223 /* Construct the API message */
17224 M (GPE_ADD_DEL_IFACE, mp);
17226 mp->is_add = is_add;
17227 mp->dp_table = clib_host_to_net_u32 (dp_table);
17229 mp->vni = clib_host_to_net_u32 (vni);
17234 /* Wait for a reply... */
17240 api_one_map_register_fallback_threshold (vat_main_t * vam)
17242 unformat_input_t *input = vam->input;
17243 vl_api_one_map_register_fallback_threshold_t *mp;
17248 /* Parse args required to build the message */
17249 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17251 if (unformat (input, "%u", &value))
17255 clib_warning ("parse error '%U'", format_unformat_error, input);
17262 errmsg ("fallback threshold value is missing!");
17266 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17267 mp->value = clib_host_to_net_u32 (value);
17272 /* Wait for a reply... */
17278 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
17280 vl_api_show_one_map_register_fallback_threshold_t *mp;
17283 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17288 /* Wait for a reply... */
17294 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
17296 u32 *proto = va_arg (*args, u32 *);
17298 if (unformat (input, "udp"))
17300 else if (unformat (input, "api"))
17309 api_one_set_transport_protocol (vat_main_t * vam)
17311 unformat_input_t *input = vam->input;
17312 vl_api_one_set_transport_protocol_t *mp;
17317 /* Parse args required to build the message */
17318 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17320 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
17324 clib_warning ("parse error '%U'", format_unformat_error, input);
17331 errmsg ("Transport protocol missing!");
17335 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
17336 mp->protocol = (u8) protocol;
17341 /* Wait for a reply... */
17347 api_one_get_transport_protocol (vat_main_t * vam)
17349 vl_api_one_get_transport_protocol_t *mp;
17352 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
17357 /* Wait for a reply... */
17363 api_one_map_register_set_ttl (vat_main_t * vam)
17365 unformat_input_t *input = vam->input;
17366 vl_api_one_map_register_set_ttl_t *mp;
17371 /* Parse args required to build the message */
17372 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17374 if (unformat (input, "%u", &ttl))
17378 clib_warning ("parse error '%U'", format_unformat_error, input);
17385 errmsg ("TTL value missing!");
17389 M (ONE_MAP_REGISTER_SET_TTL, mp);
17390 mp->ttl = clib_host_to_net_u32 (ttl);
17395 /* Wait for a reply... */
17401 api_show_one_map_register_ttl (vat_main_t * vam)
17403 vl_api_show_one_map_register_ttl_t *mp;
17406 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
17411 /* Wait for a reply... */
17417 * Add/del map request itr rlocs from ONE control plane and updates
17419 * @param vam vpp API test context
17420 * @return return code
17423 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
17425 unformat_input_t *input = vam->input;
17426 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
17427 u8 *locator_set_name = 0;
17428 u8 locator_set_name_set = 0;
17432 /* Parse args required to build the message */
17433 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17435 if (unformat (input, "del"))
17439 else if (unformat (input, "%_%v%_", &locator_set_name))
17441 locator_set_name_set = 1;
17445 clib_warning ("parse error '%U'", format_unformat_error, input);
17450 if (is_add && !locator_set_name_set)
17452 errmsg ("itr-rloc is not set!");
17456 if (is_add && vec_len (locator_set_name) > 64)
17458 errmsg ("itr-rloc locator-set name too long");
17459 vec_free (locator_set_name);
17463 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
17464 mp->is_add = is_add;
17467 clib_memcpy (mp->locator_set_name, locator_set_name,
17468 vec_len (locator_set_name));
17472 clib_memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
17474 vec_free (locator_set_name);
17479 /* Wait for a reply... */
17484 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
17487 api_one_locator_dump (vat_main_t * vam)
17489 unformat_input_t *input = vam->input;
17490 vl_api_one_locator_dump_t *mp;
17491 vl_api_control_ping_t *mp_ping;
17492 u8 is_index_set = 0, is_name_set = 0;
17497 /* Parse args required to build the message */
17498 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17500 if (unformat (input, "ls_name %_%v%_", &ls_name))
17504 else if (unformat (input, "ls_index %d", &ls_index))
17510 errmsg ("parse error '%U'", format_unformat_error, input);
17515 if (!is_index_set && !is_name_set)
17517 errmsg ("error: expected one of index or name!");
17521 if (is_index_set && is_name_set)
17523 errmsg ("error: only one param expected!");
17527 if (vec_len (ls_name) > 62)
17529 errmsg ("error: locator set name too long!");
17533 if (!vam->json_output)
17535 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
17538 M (ONE_LOCATOR_DUMP, mp);
17539 mp->is_index_set = is_index_set;
17542 mp->ls_index = clib_host_to_net_u32 (ls_index);
17545 vec_add1 (ls_name, 0);
17546 strncpy ((char *) mp->ls_name, (char *) ls_name,
17547 sizeof (mp->ls_name) - 1);
17553 /* Use a control ping for synchronization */
17554 MPING (CONTROL_PING, mp_ping);
17557 /* Wait for a reply... */
17562 #define api_lisp_locator_dump api_one_locator_dump
17565 api_one_locator_set_dump (vat_main_t * vam)
17567 vl_api_one_locator_set_dump_t *mp;
17568 vl_api_control_ping_t *mp_ping;
17569 unformat_input_t *input = vam->input;
17573 /* Parse args required to build the message */
17574 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17576 if (unformat (input, "local"))
17580 else if (unformat (input, "remote"))
17586 errmsg ("parse error '%U'", format_unformat_error, input);
17591 if (!vam->json_output)
17593 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
17596 M (ONE_LOCATOR_SET_DUMP, mp);
17598 mp->filter = filter;
17603 /* Use a control ping for synchronization */
17604 MPING (CONTROL_PING, mp_ping);
17607 /* Wait for a reply... */
17612 #define api_lisp_locator_set_dump api_one_locator_set_dump
17615 api_one_eid_table_map_dump (vat_main_t * vam)
17619 unformat_input_t *input = vam->input;
17620 vl_api_one_eid_table_map_dump_t *mp;
17621 vl_api_control_ping_t *mp_ping;
17624 /* Parse args required to build the message */
17625 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17627 if (unformat (input, "l2"))
17632 else if (unformat (input, "l3"))
17639 errmsg ("parse error '%U'", format_unformat_error, input);
17646 errmsg ("expected one of 'l2' or 'l3' parameter!");
17650 if (!vam->json_output)
17652 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
17655 M (ONE_EID_TABLE_MAP_DUMP, mp);
17661 /* Use a control ping for synchronization */
17662 MPING (CONTROL_PING, mp_ping);
17665 /* Wait for a reply... */
17670 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
17673 api_one_eid_table_vni_dump (vat_main_t * vam)
17675 vl_api_one_eid_table_vni_dump_t *mp;
17676 vl_api_control_ping_t *mp_ping;
17679 if (!vam->json_output)
17681 print (vam->ofp, "VNI");
17684 M (ONE_EID_TABLE_VNI_DUMP, mp);
17689 /* Use a control ping for synchronization */
17690 MPING (CONTROL_PING, mp_ping);
17693 /* Wait for a reply... */
17698 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
17701 api_one_eid_table_dump (vat_main_t * vam)
17703 unformat_input_t *i = vam->input;
17704 vl_api_one_eid_table_dump_t *mp;
17705 vl_api_control_ping_t *mp_ping;
17706 struct in_addr ip4;
17707 struct in6_addr ip6;
17709 u8 eid_type = ~0, eid_set = 0;
17710 u32 prefix_length = ~0, t, vni = 0;
17713 lisp_nsh_api_t nsh;
17715 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17717 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
17723 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
17729 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
17734 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
17739 else if (unformat (i, "vni %d", &t))
17743 else if (unformat (i, "local"))
17747 else if (unformat (i, "remote"))
17753 errmsg ("parse error '%U'", format_unformat_error, i);
17758 if (!vam->json_output)
17760 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
17761 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
17764 M (ONE_EID_TABLE_DUMP, mp);
17766 mp->filter = filter;
17770 mp->vni = htonl (vni);
17771 mp->eid_type = eid_type;
17775 mp->prefix_length = prefix_length;
17776 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
17779 mp->prefix_length = prefix_length;
17780 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
17783 clib_memcpy (mp->eid, mac, sizeof (mac));
17786 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
17789 errmsg ("unknown EID type %d!", eid_type);
17797 /* Use a control ping for synchronization */
17798 MPING (CONTROL_PING, mp_ping);
17801 /* Wait for a reply... */
17806 #define api_lisp_eid_table_dump api_one_eid_table_dump
17809 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
17811 unformat_input_t *i = vam->input;
17812 vl_api_gpe_fwd_entries_get_t *mp;
17817 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17819 if (unformat (i, "vni %d", &vni))
17825 errmsg ("parse error '%U'", format_unformat_error, i);
17832 errmsg ("vni not set!");
17836 if (!vam->json_output)
17838 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
17842 M (GPE_FWD_ENTRIES_GET, mp);
17843 mp->vni = clib_host_to_net_u32 (vni);
17848 /* Wait for a reply... */
17853 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
17854 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
17855 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
17856 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
17857 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
17858 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
17859 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
17860 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
17863 api_one_adjacencies_get (vat_main_t * vam)
17865 unformat_input_t *i = vam->input;
17866 vl_api_one_adjacencies_get_t *mp;
17871 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17873 if (unformat (i, "vni %d", &vni))
17879 errmsg ("parse error '%U'", format_unformat_error, i);
17886 errmsg ("vni not set!");
17890 if (!vam->json_output)
17892 print (vam->ofp, "%s %40s", "leid", "reid");
17895 M (ONE_ADJACENCIES_GET, mp);
17896 mp->vni = clib_host_to_net_u32 (vni);
17901 /* Wait for a reply... */
17906 #define api_lisp_adjacencies_get api_one_adjacencies_get
17909 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
17911 unformat_input_t *i = vam->input;
17912 vl_api_gpe_native_fwd_rpaths_get_t *mp;
17914 u8 ip_family_set = 0, is_ip4 = 1;
17916 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17918 if (unformat (i, "ip4"))
17923 else if (unformat (i, "ip6"))
17930 errmsg ("parse error '%U'", format_unformat_error, i);
17935 if (!ip_family_set)
17937 errmsg ("ip family not set!");
17941 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
17942 mp->is_ip4 = is_ip4;
17947 /* Wait for a reply... */
17953 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
17955 vl_api_gpe_fwd_entry_vnis_get_t *mp;
17958 if (!vam->json_output)
17960 print (vam->ofp, "VNIs");
17963 M (GPE_FWD_ENTRY_VNIS_GET, mp);
17968 /* Wait for a reply... */
17974 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
17976 unformat_input_t *i = vam->input;
17977 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
17979 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
17980 struct in_addr ip4;
17981 struct in6_addr ip6;
17982 u32 table_id = 0, nh_sw_if_index = ~0;
17984 clib_memset (&ip4, 0, sizeof (ip4));
17985 clib_memset (&ip6, 0, sizeof (ip6));
17987 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17989 if (unformat (i, "del"))
17991 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
17992 api_unformat_sw_if_index, vam, &nh_sw_if_index))
17997 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
17998 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18003 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
18007 nh_sw_if_index = ~0;
18009 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
18013 nh_sw_if_index = ~0;
18015 else if (unformat (i, "table %d", &table_id))
18019 errmsg ("parse error '%U'", format_unformat_error, i);
18026 errmsg ("nh addr not set!");
18030 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
18031 mp->is_add = is_add;
18032 mp->table_id = clib_host_to_net_u32 (table_id);
18033 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
18034 mp->is_ip4 = is_ip4;
18036 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
18038 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
18043 /* Wait for a reply... */
18049 api_one_map_server_dump (vat_main_t * vam)
18051 vl_api_one_map_server_dump_t *mp;
18052 vl_api_control_ping_t *mp_ping;
18055 if (!vam->json_output)
18057 print (vam->ofp, "%=20s", "Map server");
18060 M (ONE_MAP_SERVER_DUMP, mp);
18064 /* Use a control ping for synchronization */
18065 MPING (CONTROL_PING, mp_ping);
18068 /* Wait for a reply... */
18073 #define api_lisp_map_server_dump api_one_map_server_dump
18076 api_one_map_resolver_dump (vat_main_t * vam)
18078 vl_api_one_map_resolver_dump_t *mp;
18079 vl_api_control_ping_t *mp_ping;
18082 if (!vam->json_output)
18084 print (vam->ofp, "%=20s", "Map resolver");
18087 M (ONE_MAP_RESOLVER_DUMP, mp);
18091 /* Use a control ping for synchronization */
18092 MPING (CONTROL_PING, mp_ping);
18095 /* Wait for a reply... */
18100 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
18103 api_one_stats_flush (vat_main_t * vam)
18105 vl_api_one_stats_flush_t *mp;
18108 M (ONE_STATS_FLUSH, mp);
18115 api_one_stats_dump (vat_main_t * vam)
18117 vl_api_one_stats_dump_t *mp;
18118 vl_api_control_ping_t *mp_ping;
18121 M (ONE_STATS_DUMP, mp);
18125 /* Use a control ping for synchronization */
18126 MPING (CONTROL_PING, mp_ping);
18129 /* Wait for a reply... */
18135 api_show_one_status (vat_main_t * vam)
18137 vl_api_show_one_status_t *mp;
18140 if (!vam->json_output)
18142 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
18145 M (SHOW_ONE_STATUS, mp);
18148 /* Wait for a reply... */
18153 #define api_show_lisp_status api_show_one_status
18156 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
18158 vl_api_gpe_fwd_entry_path_dump_t *mp;
18159 vl_api_control_ping_t *mp_ping;
18160 unformat_input_t *i = vam->input;
18161 u32 fwd_entry_index = ~0;
18164 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18166 if (unformat (i, "index %d", &fwd_entry_index))
18172 if (~0 == fwd_entry_index)
18174 errmsg ("no index specified!");
18178 if (!vam->json_output)
18180 print (vam->ofp, "first line");
18183 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
18187 /* Use a control ping for synchronization */
18188 MPING (CONTROL_PING, mp_ping);
18191 /* Wait for a reply... */
18197 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
18199 vl_api_one_get_map_request_itr_rlocs_t *mp;
18202 if (!vam->json_output)
18204 print (vam->ofp, "%=20s", "itr-rlocs:");
18207 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
18210 /* Wait for a reply... */
18215 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
18218 api_af_packet_create (vat_main_t * vam)
18220 unformat_input_t *i = vam->input;
18221 vl_api_af_packet_create_t *mp;
18222 u8 *host_if_name = 0;
18224 u8 random_hw_addr = 1;
18227 clib_memset (hw_addr, 0, sizeof (hw_addr));
18229 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18231 if (unformat (i, "name %s", &host_if_name))
18232 vec_add1 (host_if_name, 0);
18233 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18234 random_hw_addr = 0;
18239 if (!vec_len (host_if_name))
18241 errmsg ("host-interface name must be specified");
18245 if (vec_len (host_if_name) > 64)
18247 errmsg ("host-interface name too long");
18251 M (AF_PACKET_CREATE, mp);
18253 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18254 clib_memcpy (mp->hw_addr, hw_addr, 6);
18255 mp->use_random_hw_addr = random_hw_addr;
18256 vec_free (host_if_name);
18264 fprintf (vam->ofp ? vam->ofp : stderr,
18265 " new sw_if_index = %d\n", vam->sw_if_index);
18272 api_af_packet_delete (vat_main_t * vam)
18274 unformat_input_t *i = vam->input;
18275 vl_api_af_packet_delete_t *mp;
18276 u8 *host_if_name = 0;
18279 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18281 if (unformat (i, "name %s", &host_if_name))
18282 vec_add1 (host_if_name, 0);
18287 if (!vec_len (host_if_name))
18289 errmsg ("host-interface name must be specified");
18293 if (vec_len (host_if_name) > 64)
18295 errmsg ("host-interface name too long");
18299 M (AF_PACKET_DELETE, mp);
18301 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18302 vec_free (host_if_name);
18309 static void vl_api_af_packet_details_t_handler
18310 (vl_api_af_packet_details_t * mp)
18312 vat_main_t *vam = &vat_main;
18314 print (vam->ofp, "%-16s %d",
18315 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
18318 static void vl_api_af_packet_details_t_handler_json
18319 (vl_api_af_packet_details_t * mp)
18321 vat_main_t *vam = &vat_main;
18322 vat_json_node_t *node = NULL;
18324 if (VAT_JSON_ARRAY != vam->json_tree.type)
18326 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18327 vat_json_init_array (&vam->json_tree);
18329 node = vat_json_array_add (&vam->json_tree);
18331 vat_json_init_object (node);
18332 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
18333 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
18337 api_af_packet_dump (vat_main_t * vam)
18339 vl_api_af_packet_dump_t *mp;
18340 vl_api_control_ping_t *mp_ping;
18343 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
18344 /* Get list of tap interfaces */
18345 M (AF_PACKET_DUMP, mp);
18348 /* Use a control ping for synchronization */
18349 MPING (CONTROL_PING, mp_ping);
18357 api_policer_add_del (vat_main_t * vam)
18359 unformat_input_t *i = vam->input;
18360 vl_api_policer_add_del_t *mp;
18370 u8 color_aware = 0;
18371 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
18374 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
18375 conform_action.dscp = 0;
18376 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
18377 exceed_action.dscp = 0;
18378 violate_action.action_type = SSE2_QOS_ACTION_DROP;
18379 violate_action.dscp = 0;
18381 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18383 if (unformat (i, "del"))
18385 else if (unformat (i, "name %s", &name))
18386 vec_add1 (name, 0);
18387 else if (unformat (i, "cir %u", &cir))
18389 else if (unformat (i, "eir %u", &eir))
18391 else if (unformat (i, "cb %u", &cb))
18393 else if (unformat (i, "eb %u", &eb))
18395 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
18398 else if (unformat (i, "round_type %U", unformat_policer_round_type,
18401 else if (unformat (i, "type %U", unformat_policer_type, &type))
18403 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
18406 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
18409 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
18412 else if (unformat (i, "color-aware"))
18418 if (!vec_len (name))
18420 errmsg ("policer name must be specified");
18424 if (vec_len (name) > 64)
18426 errmsg ("policer name too long");
18430 M (POLICER_ADD_DEL, mp);
18432 clib_memcpy (mp->name, name, vec_len (name));
18434 mp->is_add = is_add;
18435 mp->cir = ntohl (cir);
18436 mp->eir = ntohl (eir);
18437 mp->cb = clib_net_to_host_u64 (cb);
18438 mp->eb = clib_net_to_host_u64 (eb);
18439 mp->rate_type = rate_type;
18440 mp->round_type = round_type;
18442 mp->conform_action_type = conform_action.action_type;
18443 mp->conform_dscp = conform_action.dscp;
18444 mp->exceed_action_type = exceed_action.action_type;
18445 mp->exceed_dscp = exceed_action.dscp;
18446 mp->violate_action_type = violate_action.action_type;
18447 mp->violate_dscp = violate_action.dscp;
18448 mp->color_aware = color_aware;
18456 api_policer_dump (vat_main_t * vam)
18458 unformat_input_t *i = vam->input;
18459 vl_api_policer_dump_t *mp;
18460 vl_api_control_ping_t *mp_ping;
18461 u8 *match_name = 0;
18462 u8 match_name_valid = 0;
18465 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18467 if (unformat (i, "name %s", &match_name))
18469 vec_add1 (match_name, 0);
18470 match_name_valid = 1;
18476 M (POLICER_DUMP, mp);
18477 mp->match_name_valid = match_name_valid;
18478 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
18479 vec_free (match_name);
18483 /* Use a control ping for synchronization */
18484 MPING (CONTROL_PING, mp_ping);
18487 /* Wait for a reply... */
18493 api_policer_classify_set_interface (vat_main_t * vam)
18495 unformat_input_t *i = vam->input;
18496 vl_api_policer_classify_set_interface_t *mp;
18498 int sw_if_index_set;
18499 u32 ip4_table_index = ~0;
18500 u32 ip6_table_index = ~0;
18501 u32 l2_table_index = ~0;
18505 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18507 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18508 sw_if_index_set = 1;
18509 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18510 sw_if_index_set = 1;
18511 else if (unformat (i, "del"))
18513 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18515 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18517 else if (unformat (i, "l2-table %d", &l2_table_index))
18521 clib_warning ("parse error '%U'", format_unformat_error, i);
18526 if (sw_if_index_set == 0)
18528 errmsg ("missing interface name or sw_if_index");
18532 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
18534 mp->sw_if_index = ntohl (sw_if_index);
18535 mp->ip4_table_index = ntohl (ip4_table_index);
18536 mp->ip6_table_index = ntohl (ip6_table_index);
18537 mp->l2_table_index = ntohl (l2_table_index);
18538 mp->is_add = is_add;
18546 api_policer_classify_dump (vat_main_t * vam)
18548 unformat_input_t *i = vam->input;
18549 vl_api_policer_classify_dump_t *mp;
18550 vl_api_control_ping_t *mp_ping;
18551 u8 type = POLICER_CLASSIFY_N_TABLES;
18554 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
18558 errmsg ("classify table type must be specified");
18562 if (!vam->json_output)
18564 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
18567 M (POLICER_CLASSIFY_DUMP, mp);
18572 /* Use a control ping for synchronization */
18573 MPING (CONTROL_PING, mp_ping);
18576 /* Wait for a reply... */
18582 api_netmap_create (vat_main_t * vam)
18584 unformat_input_t *i = vam->input;
18585 vl_api_netmap_create_t *mp;
18588 u8 random_hw_addr = 1;
18593 clib_memset (hw_addr, 0, sizeof (hw_addr));
18595 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18597 if (unformat (i, "name %s", &if_name))
18598 vec_add1 (if_name, 0);
18599 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18600 random_hw_addr = 0;
18601 else if (unformat (i, "pipe"))
18603 else if (unformat (i, "master"))
18605 else if (unformat (i, "slave"))
18611 if (!vec_len (if_name))
18613 errmsg ("interface name must be specified");
18617 if (vec_len (if_name) > 64)
18619 errmsg ("interface name too long");
18623 M (NETMAP_CREATE, mp);
18625 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18626 clib_memcpy (mp->hw_addr, hw_addr, 6);
18627 mp->use_random_hw_addr = random_hw_addr;
18628 mp->is_pipe = is_pipe;
18629 mp->is_master = is_master;
18630 vec_free (if_name);
18638 api_netmap_delete (vat_main_t * vam)
18640 unformat_input_t *i = vam->input;
18641 vl_api_netmap_delete_t *mp;
18645 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18647 if (unformat (i, "name %s", &if_name))
18648 vec_add1 (if_name, 0);
18653 if (!vec_len (if_name))
18655 errmsg ("interface name must be specified");
18659 if (vec_len (if_name) > 64)
18661 errmsg ("interface name too long");
18665 M (NETMAP_DELETE, mp);
18667 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18668 vec_free (if_name);
18676 format_fib_api_path_nh_proto (u8 * s, va_list * args)
18678 vl_api_fib_path_nh_proto_t proto =
18679 va_arg (*args, vl_api_fib_path_nh_proto_t);
18683 case FIB_API_PATH_NH_PROTO_IP4:
18684 s = format (s, "ip4");
18686 case FIB_API_PATH_NH_PROTO_IP6:
18687 s = format (s, "ip6");
18689 case FIB_API_PATH_NH_PROTO_MPLS:
18690 s = format (s, "mpls");
18692 case FIB_API_PATH_NH_PROTO_BIER:
18693 s = format (s, "bier");
18695 case FIB_API_PATH_NH_PROTO_ETHERNET:
18696 s = format (s, "ethernet");
18704 format_vl_api_ip_address_union (u8 * s, va_list * args)
18706 vl_api_address_family_t af = va_arg (*args, vl_api_address_family_t);
18707 const vl_api_address_union_t *u = va_arg (*args, vl_api_address_union_t *);
18712 s = format (s, "%U", format_ip4_address, u->ip4);
18715 s = format (s, "%U", format_ip6_address, u->ip6);
18722 format_vl_api_fib_path_type (u8 * s, va_list * args)
18724 vl_api_fib_path_type_t t = va_arg (*args, vl_api_fib_path_type_t);
18728 case FIB_API_PATH_TYPE_NORMAL:
18729 s = format (s, "normal");
18731 case FIB_API_PATH_TYPE_LOCAL:
18732 s = format (s, "local");
18734 case FIB_API_PATH_TYPE_DROP:
18735 s = format (s, "drop");
18737 case FIB_API_PATH_TYPE_UDP_ENCAP:
18738 s = format (s, "udp-encap");
18740 case FIB_API_PATH_TYPE_BIER_IMP:
18741 s = format (s, "bier-imp");
18743 case FIB_API_PATH_TYPE_ICMP_UNREACH:
18744 s = format (s, "unreach");
18746 case FIB_API_PATH_TYPE_ICMP_PROHIBIT:
18747 s = format (s, "prohibit");
18749 case FIB_API_PATH_TYPE_SOURCE_LOOKUP:
18750 s = format (s, "src-lookup");
18752 case FIB_API_PATH_TYPE_DVR:
18753 s = format (s, "dvr");
18755 case FIB_API_PATH_TYPE_INTERFACE_RX:
18756 s = format (s, "interface-rx");
18758 case FIB_API_PATH_TYPE_CLASSIFY:
18759 s = format (s, "classify");
18767 vl_api_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
18770 " weight %d, sw_if_index %d, type %U, afi %U, next_hop %U",
18771 ntohl (fp->weight), ntohl (fp->sw_if_index),
18772 format_vl_api_fib_path_type, fp->type,
18773 format_fib_api_path_nh_proto, fp->proto,
18774 format_vl_api_ip_address_union, &fp->nh.address);
18778 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
18779 vl_api_fib_path_t * fp)
18781 struct in_addr ip4;
18782 struct in6_addr ip6;
18784 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
18785 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
18786 vat_json_object_add_uint (node, "type", fp->type);
18787 vat_json_object_add_uint (node, "next_hop_proto", fp->proto);
18788 if (fp->proto == FIB_API_PATH_NH_PROTO_IP4)
18790 clib_memcpy (&ip4, &fp->nh.address.ip4, sizeof (ip4));
18791 vat_json_object_add_ip4 (node, "next_hop", ip4);
18793 else if (fp->proto == FIB_API_PATH_NH_PROTO_IP4)
18795 clib_memcpy (&ip6, &fp->nh.address.ip6, sizeof (ip6));
18796 vat_json_object_add_ip6 (node, "next_hop", ip6);
18801 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
18803 vat_main_t *vam = &vat_main;
18804 int count = ntohl (mp->mt_tunnel.mt_n_paths);
18805 vl_api_fib_path_t *fp;
18808 print (vam->ofp, "sw_if_index %d via:",
18809 ntohl (mp->mt_tunnel.mt_sw_if_index));
18810 fp = mp->mt_tunnel.mt_paths;
18811 for (i = 0; i < count; i++)
18813 vl_api_fib_path_print (vam, fp);
18817 print (vam->ofp, "");
18820 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
18821 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
18824 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
18826 vat_main_t *vam = &vat_main;
18827 vat_json_node_t *node = NULL;
18828 int count = ntohl (mp->mt_tunnel.mt_n_paths);
18829 vl_api_fib_path_t *fp;
18832 if (VAT_JSON_ARRAY != vam->json_tree.type)
18834 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18835 vat_json_init_array (&vam->json_tree);
18837 node = vat_json_array_add (&vam->json_tree);
18839 vat_json_init_object (node);
18840 vat_json_object_add_uint (node, "sw_if_index",
18841 ntohl (mp->mt_tunnel.mt_sw_if_index));
18843 vat_json_object_add_uint (node, "l2_only", mp->mt_tunnel.mt_l2_only);
18845 fp = mp->mt_tunnel.mt_paths;
18846 for (i = 0; i < count; i++)
18848 vl_api_mpls_fib_path_json_print (node, fp);
18854 api_mpls_tunnel_dump (vat_main_t * vam)
18856 vl_api_mpls_tunnel_dump_t *mp;
18857 vl_api_control_ping_t *mp_ping;
18860 M (MPLS_TUNNEL_DUMP, mp);
18864 /* Use a control ping for synchronization */
18865 MPING (CONTROL_PING, mp_ping);
18872 #define vl_api_mpls_table_details_t_endian vl_noop_handler
18873 #define vl_api_mpls_table_details_t_print vl_noop_handler
18877 vl_api_mpls_table_details_t_handler (vl_api_mpls_table_details_t * mp)
18879 vat_main_t *vam = &vat_main;
18881 print (vam->ofp, "table-id %d,", ntohl (mp->mt_table.mt_table_id));
18884 static void vl_api_mpls_table_details_t_handler_json
18885 (vl_api_mpls_table_details_t * mp)
18887 vat_main_t *vam = &vat_main;
18888 vat_json_node_t *node = NULL;
18890 if (VAT_JSON_ARRAY != vam->json_tree.type)
18892 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18893 vat_json_init_array (&vam->json_tree);
18895 node = vat_json_array_add (&vam->json_tree);
18897 vat_json_init_object (node);
18898 vat_json_object_add_uint (node, "table", ntohl (mp->mt_table.mt_table_id));
18902 api_mpls_table_dump (vat_main_t * vam)
18904 vl_api_mpls_table_dump_t *mp;
18905 vl_api_control_ping_t *mp_ping;
18908 M (MPLS_TABLE_DUMP, mp);
18911 /* Use a control ping for synchronization */
18912 MPING (CONTROL_PING, mp_ping);
18919 #define vl_api_mpls_route_details_t_endian vl_noop_handler
18920 #define vl_api_mpls_route_details_t_print vl_noop_handler
18923 vl_api_mpls_route_details_t_handler (vl_api_mpls_route_details_t * mp)
18925 vat_main_t *vam = &vat_main;
18926 int count = ntohl (mp->mr_route.mr_n_paths);
18927 vl_api_fib_path_t *fp;
18931 "table-id %d, label %u, ess_bit %u",
18932 ntohl (mp->mr_route.mr_table_id),
18933 ntohl (mp->mr_route.mr_label), mp->mr_route.mr_eos);
18934 fp = mp->mr_route.mr_paths;
18935 for (i = 0; i < count; i++)
18937 vl_api_fib_path_print (vam, fp);
18942 static void vl_api_mpls_route_details_t_handler_json
18943 (vl_api_mpls_route_details_t * mp)
18945 vat_main_t *vam = &vat_main;
18946 int count = ntohl (mp->mr_route.mr_n_paths);
18947 vat_json_node_t *node = NULL;
18948 vl_api_fib_path_t *fp;
18951 if (VAT_JSON_ARRAY != vam->json_tree.type)
18953 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18954 vat_json_init_array (&vam->json_tree);
18956 node = vat_json_array_add (&vam->json_tree);
18958 vat_json_init_object (node);
18959 vat_json_object_add_uint (node, "table", ntohl (mp->mr_route.mr_table_id));
18960 vat_json_object_add_uint (node, "s_bit", mp->mr_route.mr_eos);
18961 vat_json_object_add_uint (node, "label", ntohl (mp->mr_route.mr_label));
18962 vat_json_object_add_uint (node, "path_count", count);
18963 fp = mp->mr_route.mr_paths;
18964 for (i = 0; i < count; i++)
18966 vl_api_mpls_fib_path_json_print (node, fp);
18972 api_mpls_route_dump (vat_main_t * vam)
18974 unformat_input_t *input = vam->input;
18975 vl_api_mpls_route_dump_t *mp;
18976 vl_api_control_ping_t *mp_ping;
18980 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18982 if (unformat (input, "table_id %d", &table_id))
18987 if (table_id == ~0)
18989 errmsg ("missing table id");
18993 M (MPLS_ROUTE_DUMP, mp);
18995 mp->table.mt_table_id = ntohl (table_id);
18998 /* Use a control ping for synchronization */
18999 MPING (CONTROL_PING, mp_ping);
19006 #define vl_api_ip_table_details_t_endian vl_noop_handler
19007 #define vl_api_ip_table_details_t_print vl_noop_handler
19010 vl_api_ip_table_details_t_handler (vl_api_ip_table_details_t * mp)
19012 vat_main_t *vam = &vat_main;
19015 "%s; table-id %d, prefix %U/%d",
19016 mp->table.name, ntohl (mp->table.table_id));
19020 static void vl_api_ip_table_details_t_handler_json
19021 (vl_api_ip_table_details_t * mp)
19023 vat_main_t *vam = &vat_main;
19024 vat_json_node_t *node = NULL;
19026 if (VAT_JSON_ARRAY != vam->json_tree.type)
19028 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19029 vat_json_init_array (&vam->json_tree);
19031 node = vat_json_array_add (&vam->json_tree);
19033 vat_json_init_object (node);
19034 vat_json_object_add_uint (node, "table", ntohl (mp->table.table_id));
19038 api_ip_table_dump (vat_main_t * vam)
19040 vl_api_ip_table_dump_t *mp;
19041 vl_api_control_ping_t *mp_ping;
19044 M (IP_TABLE_DUMP, mp);
19047 /* Use a control ping for synchronization */
19048 MPING (CONTROL_PING, mp_ping);
19056 api_ip_mtable_dump (vat_main_t * vam)
19058 vl_api_ip_mtable_dump_t *mp;
19059 vl_api_control_ping_t *mp_ping;
19062 M (IP_MTABLE_DUMP, mp);
19065 /* Use a control ping for synchronization */
19066 MPING (CONTROL_PING, mp_ping);
19074 api_ip_mroute_dump (vat_main_t * vam)
19076 unformat_input_t *input = vam->input;
19077 vl_api_control_ping_t *mp_ping;
19078 vl_api_ip_mroute_dump_t *mp;
19083 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19085 if (unformat (input, "table_id %d", &table_id))
19087 else if (unformat (input, "ip6"))
19089 else if (unformat (input, "ip4"))
19094 if (table_id == ~0)
19096 errmsg ("missing table id");
19100 M (IP_MROUTE_DUMP, mp);
19101 mp->table.table_id = table_id;
19102 mp->table.is_ip6 = is_ip6;
19105 /* Use a control ping for synchronization */
19106 MPING (CONTROL_PING, mp_ping);
19113 static void vl_api_ip_neighbor_details_t_handler
19114 (vl_api_ip_neighbor_details_t * mp)
19116 vat_main_t *vam = &vat_main;
19118 print (vam->ofp, "%c %U %U",
19119 (ntohl (mp->neighbor.flags) & IP_NEIGHBOR_FLAG_STATIC) ? 'S' : 'D',
19120 format_vl_api_mac_address, &mp->neighbor.mac_address,
19121 format_vl_api_address, &mp->neighbor.ip_address);
19124 static void vl_api_ip_neighbor_details_t_handler_json
19125 (vl_api_ip_neighbor_details_t * mp)
19128 vat_main_t *vam = &vat_main;
19129 vat_json_node_t *node;
19131 if (VAT_JSON_ARRAY != vam->json_tree.type)
19133 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19134 vat_json_init_array (&vam->json_tree);
19136 node = vat_json_array_add (&vam->json_tree);
19138 vat_json_init_object (node);
19139 vat_json_object_add_string_copy
19141 ((ntohl (mp->neighbor.flags) & IP_NEIGHBOR_FLAG_STATIC) ?
19142 (u8 *) "static" : (u8 *) "dynamic"));
19144 vat_json_object_add_string_copy (node, "link_layer",
19145 format (0, "%U", format_vl_api_mac_address,
19146 &mp->neighbor.mac_address));
19147 vat_json_object_add_address (node, "ip", &mp->neighbor.ip_address);
19151 api_ip_neighbor_dump (vat_main_t * vam)
19153 unformat_input_t *i = vam->input;
19154 vl_api_ip_neighbor_dump_t *mp;
19155 vl_api_control_ping_t *mp_ping;
19157 u32 sw_if_index = ~0;
19160 /* Parse args required to build the message */
19161 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19163 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19165 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19167 else if (unformat (i, "ip6"))
19173 if (sw_if_index == ~0)
19175 errmsg ("missing interface name or sw_if_index");
19179 M (IP_NEIGHBOR_DUMP, mp);
19180 mp->is_ipv6 = (u8) is_ipv6;
19181 mp->sw_if_index = ntohl (sw_if_index);
19184 /* Use a control ping for synchronization */
19185 MPING (CONTROL_PING, mp_ping);
19192 #define vl_api_ip_route_details_t_endian vl_noop_handler
19193 #define vl_api_ip_route_details_t_print vl_noop_handler
19196 vl_api_ip_route_details_t_handler (vl_api_ip_route_details_t * mp)
19198 vat_main_t *vam = &vat_main;
19199 u8 count = mp->route.n_paths;
19200 vl_api_fib_path_t *fp;
19204 "table-id %d, prefix %U/%d",
19205 ntohl (mp->route.table_id),
19206 format_ip46_address,
19207 mp->route.prefix.address, mp->route.prefix.address_length);
19208 for (i = 0; i < count; i++)
19210 fp = &mp->route.paths[i];
19212 vl_api_fib_path_print (vam, fp);
19217 static void vl_api_ip_route_details_t_handler_json
19218 (vl_api_ip_route_details_t * mp)
19220 vat_main_t *vam = &vat_main;
19221 u8 count = mp->route.n_paths;
19222 vat_json_node_t *node = NULL;
19223 struct in_addr ip4;
19224 struct in6_addr ip6;
19225 vl_api_fib_path_t *fp;
19228 if (VAT_JSON_ARRAY != vam->json_tree.type)
19230 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19231 vat_json_init_array (&vam->json_tree);
19233 node = vat_json_array_add (&vam->json_tree);
19235 vat_json_init_object (node);
19236 vat_json_object_add_uint (node, "table", ntohl (mp->route.table_id));
19237 if (ADDRESS_IP6 == mp->route.prefix.address.af)
19239 clib_memcpy (&ip6, &mp->route.prefix.address.un.ip6, sizeof (ip6));
19240 vat_json_object_add_ip6 (node, "prefix", ip6);
19244 clib_memcpy (&ip4, &mp->route.prefix.address.un.ip4, sizeof (ip4));
19245 vat_json_object_add_ip4 (node, "prefix", ip4);
19247 vat_json_object_add_uint (node, "mask_length",
19248 mp->route.prefix.address_length);
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.address_length == 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 statseg (vat_main_t * vam)
21412 ssvm_private_t *ssvmp = &vam->stat_segment;
21413 ssvm_shared_header_t *shared_header = ssvmp->sh;
21414 vlib_counter_t **counters;
21415 u64 thread0_index1_packets;
21416 u64 thread0_index1_bytes;
21417 f64 vector_rate, input_rate;
21420 uword *counter_vector_by_name;
21421 if (vam->stat_segment_lockp == 0)
21423 errmsg ("Stat segment not mapped...");
21427 /* look up "/if/rx for sw_if_index 1 as a test */
21429 clib_spinlock_lock (vam->stat_segment_lockp);
21431 counter_vector_by_name = (uword *) shared_header->opaque[1];
21433 p = hash_get_mem (counter_vector_by_name, "/if/rx");
21436 clib_spinlock_unlock (vam->stat_segment_lockp);
21437 errmsg ("/if/tx not found?");
21441 /* Fish per-thread vector of combined counters from shared memory */
21442 counters = (vlib_counter_t **) p[0];
21444 if (vec_len (counters[0]) < 2)
21446 clib_spinlock_unlock (vam->stat_segment_lockp);
21447 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
21451 /* Read thread 0 sw_if_index 1 counter */
21452 thread0_index1_packets = counters[0][1].packets;
21453 thread0_index1_bytes = counters[0][1].bytes;
21455 p = hash_get_mem (counter_vector_by_name, "vector_rate");
21458 clib_spinlock_unlock (vam->stat_segment_lockp);
21459 errmsg ("vector_rate not found?");
21463 vector_rate = *(f64 *) (p[0]);
21464 p = hash_get_mem (counter_vector_by_name, "input_rate");
21467 clib_spinlock_unlock (vam->stat_segment_lockp);
21468 errmsg ("input_rate not found?");
21471 input_rate = *(f64 *) (p[0]);
21473 clib_spinlock_unlock (vam->stat_segment_lockp);
21475 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
21476 vector_rate, input_rate);
21477 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
21478 thread0_index1_packets, thread0_index1_bytes);
21484 cmd_cmp (void *a1, void *a2)
21489 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
21493 help (vat_main_t * vam)
21498 unformat_input_t *i = vam->input;
21501 if (unformat (i, "%s", &name))
21505 vec_add1 (name, 0);
21507 hs = hash_get_mem (vam->help_by_name, name);
21509 print (vam->ofp, "usage: %s %s", name, hs[0]);
21511 print (vam->ofp, "No such msg / command '%s'", name);
21516 print (vam->ofp, "Help is available for the following:");
21519 hash_foreach_pair (p, vam->function_by_name,
21521 vec_add1 (cmds, (u8 *)(p->key));
21525 vec_sort_with_function (cmds, cmd_cmp);
21527 for (j = 0; j < vec_len (cmds); j++)
21528 print (vam->ofp, "%s", cmds[j]);
21535 set (vat_main_t * vam)
21537 u8 *name = 0, *value = 0;
21538 unformat_input_t *i = vam->input;
21540 if (unformat (i, "%s", &name))
21542 /* The input buffer is a vector, not a string. */
21543 value = vec_dup (i->buffer);
21544 vec_delete (value, i->index, 0);
21545 /* Almost certainly has a trailing newline */
21546 if (value[vec_len (value) - 1] == '\n')
21547 value[vec_len (value) - 1] = 0;
21548 /* Make sure it's a proper string, one way or the other */
21549 vec_add1 (value, 0);
21550 (void) clib_macro_set_value (&vam->macro_main,
21551 (char *) name, (char *) value);
21554 errmsg ("usage: set <name> <value>");
21562 unset (vat_main_t * vam)
21566 if (unformat (vam->input, "%s", &name))
21567 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
21568 errmsg ("unset: %s wasn't set", name);
21581 macro_sort_cmp (void *a1, void *a2)
21583 macro_sort_t *s1 = a1;
21584 macro_sort_t *s2 = a2;
21586 return strcmp ((char *) (s1->name), (char *) (s2->name));
21590 dump_macro_table (vat_main_t * vam)
21592 macro_sort_t *sort_me = 0, *sm;
21597 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
21599 vec_add2 (sort_me, sm, 1);
21600 sm->name = (u8 *)(p->key);
21601 sm->value = (u8 *) (p->value[0]);
21605 vec_sort_with_function (sort_me, macro_sort_cmp);
21607 if (vec_len (sort_me))
21608 print (vam->ofp, "%-15s%s", "Name", "Value");
21610 print (vam->ofp, "The macro table is empty...");
21612 for (i = 0; i < vec_len (sort_me); i++)
21613 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
21618 dump_node_table (vat_main_t * vam)
21621 vlib_node_t *node, *next_node;
21623 if (vec_len (vam->graph_nodes) == 0)
21625 print (vam->ofp, "Node table empty, issue get_node_graph...");
21629 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
21631 node = vam->graph_nodes[0][i];
21632 print (vam->ofp, "[%d] %s", i, node->name);
21633 for (j = 0; j < vec_len (node->next_nodes); j++)
21635 if (node->next_nodes[j] != ~0)
21637 next_node = vam->graph_nodes[0][node->next_nodes[j]];
21638 print (vam->ofp, " [%d] %s", j, next_node->name);
21646 value_sort_cmp (void *a1, void *a2)
21648 name_sort_t *n1 = a1;
21649 name_sort_t *n2 = a2;
21651 if (n1->value < n2->value)
21653 if (n1->value > n2->value)
21660 dump_msg_api_table (vat_main_t * vam)
21662 api_main_t *am = &api_main;
21663 name_sort_t *nses = 0, *ns;
21668 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
21670 vec_add2 (nses, ns, 1);
21671 ns->name = (u8 *)(hp->key);
21672 ns->value = (u32) hp->value[0];
21676 vec_sort_with_function (nses, value_sort_cmp);
21678 for (i = 0; i < vec_len (nses); i++)
21679 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
21685 get_msg_id (vat_main_t * vam)
21690 if (unformat (vam->input, "%s", &name_and_crc))
21692 message_index = vl_msg_api_get_msg_index (name_and_crc);
21693 if (message_index == ~0)
21695 print (vam->ofp, " '%s' not found", name_and_crc);
21698 print (vam->ofp, " '%s' has message index %d",
21699 name_and_crc, message_index);
21702 errmsg ("name_and_crc required...");
21707 search_node_table (vat_main_t * vam)
21709 unformat_input_t *line_input = vam->input;
21712 vlib_node_t *node, *next_node;
21715 if (vam->graph_node_index_by_name == 0)
21717 print (vam->ofp, "Node table empty, issue get_node_graph...");
21721 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21723 if (unformat (line_input, "%s", &node_to_find))
21725 vec_add1 (node_to_find, 0);
21726 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
21729 print (vam->ofp, "%s not found...", node_to_find);
21732 node = vam->graph_nodes[0][p[0]];
21733 print (vam->ofp, "[%d] %s", p[0], node->name);
21734 for (j = 0; j < vec_len (node->next_nodes); j++)
21736 if (node->next_nodes[j] != ~0)
21738 next_node = vam->graph_nodes[0][node->next_nodes[j]];
21739 print (vam->ofp, " [%d] %s", j, next_node->name);
21746 clib_warning ("parse error '%U'", format_unformat_error,
21752 vec_free (node_to_find);
21761 script (vat_main_t * vam)
21763 #if (VPP_API_TEST_BUILTIN==0)
21765 char *save_current_file;
21766 unformat_input_t save_input;
21767 jmp_buf save_jump_buf;
21768 u32 save_line_number;
21770 FILE *new_fp, *save_ifp;
21772 if (unformat (vam->input, "%s", &s))
21774 new_fp = fopen ((char *) s, "r");
21777 errmsg ("Couldn't open script file %s", s);
21784 errmsg ("Missing script name");
21788 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
21789 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
21790 save_ifp = vam->ifp;
21791 save_line_number = vam->input_line_number;
21792 save_current_file = (char *) vam->current_file;
21794 vam->input_line_number = 0;
21796 vam->current_file = s;
21799 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
21800 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
21801 vam->ifp = save_ifp;
21802 vam->input_line_number = save_line_number;
21803 vam->current_file = (u8 *) save_current_file;
21808 clib_warning ("use the exec command...");
21814 echo (vat_main_t * vam)
21816 print (vam->ofp, "%v", vam->input->buffer);
21820 /* List of API message constructors, CLI names map to api_xxx */
21821 #define foreach_vpe_api_msg \
21822 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
21823 _(sw_interface_dump,"") \
21824 _(sw_interface_set_flags, \
21825 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
21826 _(sw_interface_add_del_address, \
21827 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
21828 _(sw_interface_set_rx_mode, \
21829 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
21830 _(sw_interface_set_rx_placement, \
21831 "<intfc> | sw_if_index <id> [queue <id>] [worker <id> | main]") \
21832 _(sw_interface_rx_placement_dump, \
21833 "[<intfc> | sw_if_index <id>]") \
21834 _(sw_interface_set_table, \
21835 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
21836 _(sw_interface_set_mpls_enable, \
21837 "<intfc> | sw_if_index [disable | dis]") \
21838 _(sw_interface_set_vpath, \
21839 "<intfc> | sw_if_index <id> enable | disable") \
21840 _(sw_interface_set_vxlan_bypass, \
21841 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21842 _(sw_interface_set_geneve_bypass, \
21843 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21844 _(sw_interface_set_l2_xconnect, \
21845 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
21846 "enable | disable") \
21847 _(sw_interface_set_l2_bridge, \
21848 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
21849 "[shg <split-horizon-group>] [bvi]\n" \
21850 "enable | disable") \
21851 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
21852 _(bridge_domain_add_del, \
21853 "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") \
21854 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
21856 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
21857 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
21858 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
21860 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21862 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21864 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>] [host-mtu-size <mtu>] [gso | no-gso]") \
21866 "<vpp-if-name> | sw_if_index <id>") \
21867 _(sw_interface_tap_v2_dump, "") \
21868 _(virtio_pci_create, \
21869 "pci-addr <pci-address> [use_random_mac | hw-addr <mac-addr>] [features <hex-value>] [gso-enabled]") \
21870 _(virtio_pci_delete, \
21871 "<vpp-if-name> | sw_if_index <id>") \
21872 _(sw_interface_virtio_pci_dump, "") \
21874 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
21875 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \
21878 "<vpp-if-name> | sw_if_index <id>") \
21880 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
21881 _(bond_detach_slave, \
21882 "sw_if_index <n>") \
21883 _(sw_interface_bond_dump, "") \
21884 _(sw_interface_slave_dump, \
21885 "<vpp-if-name> | sw_if_index <id>") \
21886 _(ip_table_add_del, \
21887 "table <n> [ipv6] [add | del]\n") \
21888 _(ip_route_add_del, \
21889 "<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
21890 "[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
21891 "[weight <n>] [drop] [local] [classify <n>] [out-label <n>]\n" \
21892 "[multipath] [count <n>] [del]") \
21893 _(ip_mroute_add_del, \
21894 "<src> <grp>/<mask> [table-id <n>]\n" \
21895 "[<intfc> | sw_if_index <id>] [local] [del]") \
21896 _(mpls_table_add_del, \
21897 "table <n> [add | del]\n") \
21898 _(mpls_route_add_del, \
21899 "<label> <eos> via <addr | next-hop-table <n> | via-label <n> |\n" \
21900 "lookup-ip4-table <n> | lookup-in-ip6-table <n> |\n" \
21901 "l2-input-on <intfc> | l2-input-on sw_if_index <id>>\n" \
21902 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>] [weight <n>]\n" \
21903 "[drop] [local] [classify <n>] [out-label <n>] [multipath]\n" \
21904 "[count <n>] [del]") \
21905 _(mpls_ip_bind_unbind, \
21906 "<label> <addr/len>") \
21907 _(mpls_tunnel_add_del, \
21908 "[add | del <intfc | sw_if_index <id>>] via <addr | via-label <n>>\n" \
21909 "[<intfc> | sw_if_index <id> | next-hop-table <id>]\n" \
21910 "[l2-only] [out-label <n>]") \
21911 _(sr_mpls_policy_add, \
21912 "bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
21913 _(sr_mpls_policy_del, \
21915 _(bier_table_add_del, \
21916 "<label> <sub-domain> <set> <bsl> [del]") \
21917 _(bier_route_add_del, \
21918 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
21919 "[<intfc> | sw_if_index <id>]" \
21920 "[weight <n>] [del] [multipath]") \
21921 _(proxy_arp_add_del, \
21922 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
21923 _(proxy_arp_intfc_enable_disable, \
21924 "<intfc> | sw_if_index <id> enable | disable") \
21925 _(sw_interface_set_unnumbered, \
21926 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
21927 _(ip_neighbor_add_del, \
21928 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
21929 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
21930 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
21931 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
21932 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
21933 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
21934 "[outer_vlan_id_any][inner_vlan_id_any]") \
21935 _(reset_fib, "vrf <n> [ipv6]") \
21936 _(dhcp_proxy_config, \
21937 "svr <v46-address> src <v46-address>\n" \
21938 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
21939 _(dhcp_proxy_set_vss, \
21940 "tbl_id <n> [fib_id <n> oui <n> | vpn_ascii_id <text>] [ipv6] [del]") \
21941 _(dhcp_proxy_dump, "ip6") \
21942 _(dhcp_client_config, \
21943 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
21944 _(set_ip_flow_hash, \
21945 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
21946 _(sw_interface_ip6_enable_disable, \
21947 "<intfc> | sw_if_index <id> enable | disable") \
21948 _(ip6nd_proxy_add_del, \
21949 "<intfc> | sw_if_index <id> <ip6-address>") \
21950 _(ip6nd_proxy_dump, "") \
21951 _(sw_interface_ip6nd_ra_prefix, \
21952 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
21953 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
21954 "[nolink] [isno]") \
21955 _(sw_interface_ip6nd_ra_config, \
21956 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
21957 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
21958 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
21959 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
21960 _(l2_patch_add_del, \
21961 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
21962 "enable | disable") \
21963 _(sr_localsid_add_del, \
21964 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
21965 "fib-table <num> (end.psp) sw_if_index <num>") \
21966 _(classify_add_del_table, \
21967 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
21968 " [del] [del-chain] mask <mask-value>\n" \
21969 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
21970 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
21971 _(classify_add_del_session, \
21972 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
21973 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
21974 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
21975 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
21976 _(classify_set_interface_ip_table, \
21977 "<intfc> | sw_if_index <nn> table <nn>") \
21978 _(classify_set_interface_l2_tables, \
21979 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21980 " [other-table <nn>]") \
21981 _(get_node_index, "node <node-name") \
21982 _(add_node_next, "node <node-name> next <next-node-name>") \
21983 _(l2tpv3_create_tunnel, \
21984 "client_address <ip6-addr> our_address <ip6-addr>\n" \
21985 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
21986 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
21987 _(l2tpv3_set_tunnel_cookies, \
21988 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
21989 "[new_remote_cookie <nn>]\n") \
21990 _(l2tpv3_interface_enable_disable, \
21991 "<intfc> | sw_if_index <nn> enable | disable") \
21992 _(l2tpv3_set_lookup_key, \
21993 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
21994 _(sw_if_l2tpv3_tunnel_dump, "") \
21995 _(vxlan_offload_rx, \
21996 "hw { <interface name> | hw_if_index <nn>} " \
21997 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
21998 _(vxlan_add_del_tunnel, \
21999 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
22000 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
22001 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
22002 _(geneve_add_del_tunnel, \
22003 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
22004 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
22005 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
22006 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22007 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22008 _(gre_tunnel_add_del, \
22009 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
22010 "[teb | erspan <session-id>] [del]") \
22011 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22012 _(l2_fib_clear_table, "") \
22013 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
22014 _(l2_interface_vlan_tag_rewrite, \
22015 "<intfc> | sw_if_index <nn> \n" \
22016 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
22017 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
22018 _(create_vhost_user_if, \
22019 "socket <filename> [server] [renumber <dev_instance>] " \
22020 "[disable_mrg_rxbuf] [disable_indirect_desc] " \
22021 "[mac <mac_address>]") \
22022 _(modify_vhost_user_if, \
22023 "<intfc> | sw_if_index <nn> socket <filename>\n" \
22024 "[server] [renumber <dev_instance>]") \
22025 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
22026 _(sw_interface_vhost_user_dump, "") \
22027 _(show_version, "") \
22028 _(show_threads, "") \
22029 _(vxlan_gpe_add_del_tunnel, \
22030 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
22031 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
22032 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
22033 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
22034 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22035 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
22036 _(interface_name_renumber, \
22037 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
22038 _(input_acl_set_interface, \
22039 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22040 " [l2-table <nn>] [del]") \
22041 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
22042 _(ip_scan_neighbor_enable_disable, "[ip4|ip6|both|disable] [interval <n-min>]\n" \
22043 " [max-time <n-usec>] [max-update <n>] [delay <n-msec>] [stale <n-min>]") \
22044 _(want_ip4_arp_events, "address <ip4-address> [del]") \
22045 _(want_ip6_nd_events, "address <ip6-address> [del]") \
22046 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
22047 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
22048 _(ip_dump, "ipv4 | ipv6") \
22049 _(ipsec_spd_add_del, "spd_id <n> [del]") \
22050 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
22052 _(ipsec_sad_entry_add_del, "sad_id <n> spi <n> crypto_alg <alg>\n" \
22053 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
22054 " integ_alg <alg> integ_key <hex>") \
22055 _(ipsec_spd_entry_add_del, "spd_id <n> priority <n> action <action>\n" \
22056 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
22057 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
22058 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
22059 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
22060 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
22061 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
22062 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
22063 " [instance <n>]") \
22064 _(ipsec_sa_dump, "[sa_id <n>]") \
22065 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
22066 _(delete_loopback,"sw_if_index <nn>") \
22067 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
22068 _(bd_ip_mac_flush, "bd_id <bridge-domain-id>") \
22069 _(bd_ip_mac_dump, "[bd_id] <bridge-domain-id>") \
22070 _(want_interface_events, "enable|disable") \
22071 _(get_first_msg_id, "client <name>") \
22072 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
22073 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
22074 "fib-id <nn> [ip4][ip6][default]") \
22075 _(get_node_graph, " ") \
22076 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
22077 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
22078 _(ioam_disable, "") \
22079 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
22080 " sw_if_index <sw_if_index> p <priority> " \
22081 "w <weight>] [del]") \
22082 _(one_add_del_locator, "locator-set <locator_name> " \
22083 "iface <intf> | sw_if_index <sw_if_index> " \
22084 "p <priority> w <weight> [del]") \
22085 _(one_add_del_local_eid,"vni <vni> eid " \
22086 "<ipv4|ipv6>/<prefix> | <L2 address> " \
22087 "locator-set <locator_name> [del]" \
22088 "[key-id sha1|sha256 secret-key <secret-key>]")\
22089 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
22090 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
22091 _(one_enable_disable, "enable|disable") \
22092 _(one_map_register_enable_disable, "enable|disable") \
22093 _(one_map_register_fallback_threshold, "<value>") \
22094 _(one_rloc_probe_enable_disable, "enable|disable") \
22095 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
22097 "rloc <locator> p <prio> " \
22098 "w <weight> [rloc <loc> ... ] " \
22099 "action <action> [del-all]") \
22100 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
22102 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
22103 _(one_use_petr, "ip-address> | disable") \
22104 _(one_map_request_mode, "src-dst|dst-only") \
22105 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
22106 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
22107 _(one_locator_set_dump, "[local | remote]") \
22108 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
22109 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
22110 "[local] | [remote]") \
22111 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
22112 _(one_ndp_bd_get, "") \
22113 _(one_ndp_entries_get, "bd <bridge-domain>") \
22114 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
22115 _(one_l2_arp_bd_get, "") \
22116 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
22117 _(one_stats_enable_disable, "enable|disable") \
22118 _(show_one_stats_enable_disable, "") \
22119 _(one_eid_table_vni_dump, "") \
22120 _(one_eid_table_map_dump, "l2|l3") \
22121 _(one_map_resolver_dump, "") \
22122 _(one_map_server_dump, "") \
22123 _(one_adjacencies_get, "vni <vni>") \
22124 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
22125 _(show_one_rloc_probe_state, "") \
22126 _(show_one_map_register_state, "") \
22127 _(show_one_status, "") \
22128 _(one_stats_dump, "") \
22129 _(one_stats_flush, "") \
22130 _(one_get_map_request_itr_rlocs, "") \
22131 _(one_map_register_set_ttl, "<ttl>") \
22132 _(one_set_transport_protocol, "udp|api") \
22133 _(one_get_transport_protocol, "") \
22134 _(one_enable_disable_xtr_mode, "enable|disable") \
22135 _(one_show_xtr_mode, "") \
22136 _(one_enable_disable_pitr_mode, "enable|disable") \
22137 _(one_show_pitr_mode, "") \
22138 _(one_enable_disable_petr_mode, "enable|disable") \
22139 _(one_show_petr_mode, "") \
22140 _(show_one_nsh_mapping, "") \
22141 _(show_one_pitr, "") \
22142 _(show_one_use_petr, "") \
22143 _(show_one_map_request_mode, "") \
22144 _(show_one_map_register_ttl, "") \
22145 _(show_one_map_register_fallback_threshold, "") \
22146 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
22147 " sw_if_index <sw_if_index> p <priority> " \
22148 "w <weight>] [del]") \
22149 _(lisp_add_del_locator, "locator-set <locator_name> " \
22150 "iface <intf> | sw_if_index <sw_if_index> " \
22151 "p <priority> w <weight> [del]") \
22152 _(lisp_add_del_local_eid,"vni <vni> eid " \
22153 "<ipv4|ipv6>/<prefix> | <L2 address> " \
22154 "locator-set <locator_name> [del]" \
22155 "[key-id sha1|sha256 secret-key <secret-key>]") \
22156 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
22157 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
22158 _(lisp_enable_disable, "enable|disable") \
22159 _(lisp_map_register_enable_disable, "enable|disable") \
22160 _(lisp_rloc_probe_enable_disable, "enable|disable") \
22161 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
22163 "rloc <locator> p <prio> " \
22164 "w <weight> [rloc <loc> ... ] " \
22165 "action <action> [del-all]") \
22166 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
22168 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
22169 _(lisp_use_petr, "<ip-address> | disable") \
22170 _(lisp_map_request_mode, "src-dst|dst-only") \
22171 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
22172 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
22173 _(lisp_locator_set_dump, "[local | remote]") \
22174 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
22175 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
22176 "[local] | [remote]") \
22177 _(lisp_eid_table_vni_dump, "") \
22178 _(lisp_eid_table_map_dump, "l2|l3") \
22179 _(lisp_map_resolver_dump, "") \
22180 _(lisp_map_server_dump, "") \
22181 _(lisp_adjacencies_get, "vni <vni>") \
22182 _(gpe_fwd_entry_vnis_get, "") \
22183 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
22184 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
22185 "[table <table-id>]") \
22186 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
22187 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
22188 _(gpe_set_encap_mode, "lisp|vxlan") \
22189 _(gpe_get_encap_mode, "") \
22190 _(lisp_gpe_add_del_iface, "up|down") \
22191 _(lisp_gpe_enable_disable, "enable|disable") \
22192 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
22193 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
22194 _(show_lisp_rloc_probe_state, "") \
22195 _(show_lisp_map_register_state, "") \
22196 _(show_lisp_status, "") \
22197 _(lisp_get_map_request_itr_rlocs, "") \
22198 _(show_lisp_pitr, "") \
22199 _(show_lisp_use_petr, "") \
22200 _(show_lisp_map_request_mode, "") \
22201 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
22202 _(af_packet_delete, "name <host interface name>") \
22203 _(af_packet_dump, "") \
22204 _(policer_add_del, "name <policer name> <params> [del]") \
22205 _(policer_dump, "[name <policer name>]") \
22206 _(policer_classify_set_interface, \
22207 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22208 " [l2-table <nn>] [del]") \
22209 _(policer_classify_dump, "type [ip4|ip6|l2]") \
22210 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
22211 "[master|slave]") \
22212 _(netmap_delete, "name <interface name>") \
22213 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
22214 _(mpls_table_dump, "") \
22215 _(mpls_route_dump, "table-id <ID>") \
22216 _(classify_table_ids, "") \
22217 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
22218 _(classify_table_info, "table_id <nn>") \
22219 _(classify_session_dump, "table_id <nn>") \
22220 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
22221 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
22222 "[template_interval <nn>] [udp_checksum]") \
22223 _(ipfix_exporter_dump, "") \
22224 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
22225 _(ipfix_classify_stream_dump, "") \
22226 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
22227 _(ipfix_classify_table_dump, "") \
22228 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
22229 _(sw_interface_span_dump, "[l2]") \
22230 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
22231 _(pg_create_interface, "if_id <nn>") \
22232 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
22233 _(pg_enable_disable, "[stream <id>] disable") \
22234 _(ip_source_and_port_range_check_add_del, \
22235 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
22236 _(ip_source_and_port_range_check_interface_add_del, \
22237 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
22238 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
22239 _(delete_subif,"<intfc> | sw_if_index <nn>") \
22240 _(l2_interface_pbb_tag_rewrite, \
22241 "<intfc> | sw_if_index <nn> \n" \
22242 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
22243 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
22244 _(set_punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
22245 _(flow_classify_set_interface, \
22246 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
22247 _(flow_classify_dump, "type [ip4|ip6]") \
22248 _(ip_table_dump, "") \
22249 _(ip_route_dump, "table-id [ip4|ip6]") \
22250 _(ip_mtable_dump, "") \
22251 _(ip_mroute_dump, "table-id [ip4|ip6]") \
22252 _(feature_enable_disable, "arc_name <arc_name> " \
22253 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
22254 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
22256 _(l2_xconnect_dump, "") \
22257 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
22258 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
22259 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
22260 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
22261 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
22262 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
22263 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
22264 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
22265 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
22266 _(sock_init_shm, "size <nnn>") \
22267 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
22268 _(dns_enable_disable, "[enable][disable]") \
22269 _(dns_name_server_add_del, "<ip-address> [del]") \
22270 _(dns_resolve_name, "<hostname>") \
22271 _(dns_resolve_ip, "<ip4|ip6>") \
22272 _(dns_name_server_add_del, "<ip-address> [del]") \
22273 _(dns_resolve_name, "<hostname>") \
22274 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
22275 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
22276 _(session_rules_dump, "") \
22277 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
22278 _(output_acl_set_interface, \
22279 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22280 " [l2-table <nn>] [del]") \
22281 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
22283 /* List of command functions, CLI names map directly to functions */
22284 #define foreach_cli_function \
22285 _(comment, "usage: comment <ignore-rest-of-line>") \
22286 _(dump_interface_table, "usage: dump_interface_table") \
22287 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
22288 _(dump_ipv4_table, "usage: dump_ipv4_table") \
22289 _(dump_ipv6_table, "usage: dump_ipv6_table") \
22290 _(dump_macro_table, "usage: dump_macro_table ") \
22291 _(dump_node_table, "usage: dump_node_table") \
22292 _(dump_msg_api_table, "usage: dump_msg_api_table") \
22293 _(get_msg_id, "usage: get_msg_id name_and_crc") \
22294 _(echo, "usage: echo <message>") \
22295 _(exec, "usage: exec <vpe-debug-CLI-command>") \
22296 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
22297 _(help, "usage: help") \
22298 _(q, "usage: quit") \
22299 _(quit, "usage: quit") \
22300 _(search_node_table, "usage: search_node_table <name>...") \
22301 _(set, "usage: set <variable-name> <value>") \
22302 _(script, "usage: script <file-name>") \
22303 _(statseg, "usage: statseg") \
22304 _(unset, "usage: unset <variable-name>")
22307 static void vl_api_##n##_t_handler_uni \
22308 (vl_api_##n##_t * mp) \
22310 vat_main_t * vam = &vat_main; \
22311 if (vam->json_output) { \
22312 vl_api_##n##_t_handler_json(mp); \
22314 vl_api_##n##_t_handler(mp); \
22317 foreach_vpe_api_reply_msg;
22318 #if VPP_API_TEST_BUILTIN == 0
22319 foreach_standalone_reply_msg;
22324 vat_api_hookup (vat_main_t * vam)
22327 vl_msg_api_set_handlers(VL_API_##N, #n, \
22328 vl_api_##n##_t_handler_uni, \
22330 vl_api_##n##_t_endian, \
22331 vl_api_##n##_t_print, \
22332 sizeof(vl_api_##n##_t), 1);
22333 foreach_vpe_api_reply_msg;
22334 #if VPP_API_TEST_BUILTIN == 0
22335 foreach_standalone_reply_msg;
22339 #if (VPP_API_TEST_BUILTIN==0)
22340 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
22342 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
22344 vam->function_by_name = hash_create_string (0, sizeof (uword));
22346 vam->help_by_name = hash_create_string (0, sizeof (uword));
22349 /* API messages we can send */
22350 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
22351 foreach_vpe_api_msg;
22355 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
22356 foreach_vpe_api_msg;
22359 /* CLI functions */
22360 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
22361 foreach_cli_function;
22365 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
22366 foreach_cli_function;
22370 #if VPP_API_TEST_BUILTIN
22371 static clib_error_t *
22372 vat_api_hookup_shim (vlib_main_t * vm)
22374 vat_api_hookup (&vat_main);
22378 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
22382 * fd.io coding-style-patch-verification: ON
22385 * eval: (c-set-style "gnu")