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);
1355 errmsg ("build directory: %v\n", s);
1358 vam->retval = retval;
1359 vam->result_ready = 1;
1362 static void vl_api_show_version_reply_t_handler_json
1363 (vl_api_show_version_reply_t * mp)
1365 vat_main_t *vam = &vat_main;
1366 vat_json_node_t node;
1368 vat_json_init_object (&node);
1369 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1370 char *p = (char *) &mp->program;
1371 vat_json_object_add_string_copy (&node, "program",
1372 vl_api_from_api_string ((vl_api_string_t *)
1374 p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (u32);
1375 vat_json_object_add_string_copy (&node, "version",
1376 vl_api_from_api_string ((vl_api_string_t *)
1378 p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (u32);
1379 vat_json_object_add_string_copy (&node, "build_date",
1380 vl_api_from_api_string ((vl_api_string_t *)
1382 p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (u32);
1383 vat_json_object_add_string_copy (&node, "build_directory",
1384 vl_api_from_api_string ((vl_api_string_t *)
1387 vat_json_print (vam->ofp, &node);
1388 vat_json_free (&node);
1390 vam->retval = ntohl (mp->retval);
1391 vam->result_ready = 1;
1394 static void vl_api_show_threads_reply_t_handler
1395 (vl_api_show_threads_reply_t * mp)
1397 vat_main_t *vam = &vat_main;
1398 i32 retval = ntohl (mp->retval);
1402 count = ntohl (mp->count);
1404 for (i = 0; i < count; i++)
1406 "\n%-2d %-11s %-11s %-5d %-6d %-4d %-6d",
1407 ntohl (mp->thread_data[i].id), mp->thread_data[i].name,
1408 mp->thread_data[i].type, ntohl (mp->thread_data[i].pid),
1409 ntohl (mp->thread_data[i].cpu_id), ntohl (mp->thread_data[i].core),
1410 ntohl (mp->thread_data[i].cpu_socket));
1412 vam->retval = retval;
1413 vam->result_ready = 1;
1416 static void vl_api_show_threads_reply_t_handler_json
1417 (vl_api_show_threads_reply_t * mp)
1419 vat_main_t *vam = &vat_main;
1420 vat_json_node_t node;
1421 vl_api_thread_data_t *td;
1422 i32 retval = ntohl (mp->retval);
1426 count = ntohl (mp->count);
1428 vat_json_init_object (&node);
1429 vat_json_object_add_int (&node, "retval", retval);
1430 vat_json_object_add_uint (&node, "count", count);
1432 for (i = 0; i < count; i++)
1434 td = &mp->thread_data[i];
1435 vat_json_object_add_uint (&node, "id", ntohl (td->id));
1436 vat_json_object_add_string_copy (&node, "name", td->name);
1437 vat_json_object_add_string_copy (&node, "type", td->type);
1438 vat_json_object_add_uint (&node, "pid", ntohl (td->pid));
1439 vat_json_object_add_int (&node, "cpu_id", ntohl (td->cpu_id));
1440 vat_json_object_add_int (&node, "core", ntohl (td->id));
1441 vat_json_object_add_int (&node, "cpu_socket", ntohl (td->cpu_socket));
1444 vat_json_print (vam->ofp, &node);
1445 vat_json_free (&node);
1447 vam->retval = retval;
1448 vam->result_ready = 1;
1452 api_show_threads (vat_main_t * vam)
1454 vl_api_show_threads_t *mp;
1458 "\n%-2s %-11s %-11s %-5s %-6s %-4s %-6s",
1459 "ID", "Name", "Type", "LWP", "cpu_id", "Core", "Socket");
1461 M (SHOW_THREADS, mp);
1469 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1471 u32 sw_if_index = ntohl (mp->sw_if_index);
1472 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1473 mp->mac_ip ? "mac/ip binding" : "address resolution",
1474 ntohl (mp->pid), format_ip4_address, mp->ip,
1475 format_vl_api_mac_address, &mp->mac, sw_if_index);
1479 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1481 /* JSON output not supported */
1485 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1487 u32 sw_if_index = ntohl (mp->sw_if_index);
1488 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1489 mp->mac_ip ? "mac/ip binding" : "address resolution",
1490 ntohl (mp->pid), format_vl_api_ip6_address, mp->ip,
1491 format_vl_api_mac_address, mp->mac, sw_if_index);
1495 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1497 /* JSON output not supported */
1501 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1503 u32 n_macs = ntohl (mp->n_macs);
1504 errmsg ("L2MAC event received with pid %d cl-idx %d for %d macs: \n",
1505 ntohl (mp->pid), mp->client_index, n_macs);
1507 for (i = 0; i < n_macs; i++)
1509 vl_api_mac_entry_t *mac = &mp->mac[i];
1510 errmsg (" [%d] sw_if_index %d mac_addr %U action %d \n",
1511 i + 1, ntohl (mac->sw_if_index),
1512 format_ethernet_address, mac->mac_addr, mac->action);
1519 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1521 /* JSON output not supported */
1524 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1525 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1528 * Special-case: build the bridge domain table, maintain
1529 * the next bd id vbl.
1531 static void vl_api_bridge_domain_details_t_handler
1532 (vl_api_bridge_domain_details_t * mp)
1534 vat_main_t *vam = &vat_main;
1535 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1538 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-6s %-3s",
1539 " ID", "LRN", "FWD", "FLD", "BVI", "UU-FWD", "#IF");
1541 print (vam->ofp, "%3d %3d %3d %3d %3d %6d %3d",
1542 ntohl (mp->bd_id), mp->learn, mp->forward,
1543 mp->flood, ntohl (mp->bvi_sw_if_index),
1544 ntohl (mp->uu_fwd_sw_if_index), n_sw_ifs);
1548 vl_api_bridge_domain_sw_if_t *sw_ifs;
1549 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1552 sw_ifs = mp->sw_if_details;
1553 for (i = 0; i < n_sw_ifs; i++)
1559 sw_if_index = ntohl (sw_ifs->sw_if_index);
1562 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1564 if ((u32) p->value[0] == sw_if_index)
1566 sw_if_name = (u8 *)(p->key);
1571 print (vam->ofp, "%7d %3d %s", sw_if_index,
1572 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1573 "sw_if_index not found!");
1580 static void vl_api_bridge_domain_details_t_handler_json
1581 (vl_api_bridge_domain_details_t * mp)
1583 vat_main_t *vam = &vat_main;
1584 vat_json_node_t *node, *array = NULL;
1585 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1587 if (VAT_JSON_ARRAY != vam->json_tree.type)
1589 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1590 vat_json_init_array (&vam->json_tree);
1592 node = vat_json_array_add (&vam->json_tree);
1594 vat_json_init_object (node);
1595 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1596 vat_json_object_add_uint (node, "flood", mp->flood);
1597 vat_json_object_add_uint (node, "forward", mp->forward);
1598 vat_json_object_add_uint (node, "learn", mp->learn);
1599 vat_json_object_add_uint (node, "bvi_sw_if_index",
1600 ntohl (mp->bvi_sw_if_index));
1601 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1602 array = vat_json_object_add (node, "sw_if");
1603 vat_json_init_array (array);
1609 vl_api_bridge_domain_sw_if_t *sw_ifs;
1612 sw_ifs = mp->sw_if_details;
1613 for (i = 0; i < n_sw_ifs; i++)
1615 node = vat_json_array_add (array);
1616 vat_json_init_object (node);
1617 vat_json_object_add_uint (node, "sw_if_index",
1618 ntohl (sw_ifs->sw_if_index));
1619 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1625 static void vl_api_control_ping_reply_t_handler
1626 (vl_api_control_ping_reply_t * mp)
1628 vat_main_t *vam = &vat_main;
1629 i32 retval = ntohl (mp->retval);
1630 if (vam->async_mode)
1632 vam->async_errors += (retval < 0);
1636 vam->retval = retval;
1637 vam->result_ready = 1;
1639 if (vam->socket_client_main)
1640 vam->socket_client_main->control_pings_outstanding--;
1643 static void vl_api_control_ping_reply_t_handler_json
1644 (vl_api_control_ping_reply_t * mp)
1646 vat_main_t *vam = &vat_main;
1647 i32 retval = ntohl (mp->retval);
1649 if (VAT_JSON_NONE != vam->json_tree.type)
1651 vat_json_print (vam->ofp, &vam->json_tree);
1652 vat_json_free (&vam->json_tree);
1653 vam->json_tree.type = VAT_JSON_NONE;
1658 vat_json_init_array (&vam->json_tree);
1659 vat_json_print (vam->ofp, &vam->json_tree);
1660 vam->json_tree.type = VAT_JSON_NONE;
1663 vam->retval = retval;
1664 vam->result_ready = 1;
1668 vl_api_bridge_domain_set_mac_age_reply_t_handler
1669 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1671 vat_main_t *vam = &vat_main;
1672 i32 retval = ntohl (mp->retval);
1673 if (vam->async_mode)
1675 vam->async_errors += (retval < 0);
1679 vam->retval = retval;
1680 vam->result_ready = 1;
1684 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1685 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1687 vat_main_t *vam = &vat_main;
1688 vat_json_node_t node;
1690 vat_json_init_object (&node);
1691 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1693 vat_json_print (vam->ofp, &node);
1694 vat_json_free (&node);
1696 vam->retval = ntohl (mp->retval);
1697 vam->result_ready = 1;
1701 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1703 vat_main_t *vam = &vat_main;
1704 i32 retval = ntohl (mp->retval);
1705 if (vam->async_mode)
1707 vam->async_errors += (retval < 0);
1711 vam->retval = retval;
1712 vam->result_ready = 1;
1716 static void vl_api_l2_flags_reply_t_handler_json
1717 (vl_api_l2_flags_reply_t * mp)
1719 vat_main_t *vam = &vat_main;
1720 vat_json_node_t node;
1722 vat_json_init_object (&node);
1723 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1724 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1725 ntohl (mp->resulting_feature_bitmap));
1727 vat_json_print (vam->ofp, &node);
1728 vat_json_free (&node);
1730 vam->retval = ntohl (mp->retval);
1731 vam->result_ready = 1;
1734 static void vl_api_bridge_flags_reply_t_handler
1735 (vl_api_bridge_flags_reply_t * mp)
1737 vat_main_t *vam = &vat_main;
1738 i32 retval = ntohl (mp->retval);
1739 if (vam->async_mode)
1741 vam->async_errors += (retval < 0);
1745 vam->retval = retval;
1746 vam->result_ready = 1;
1750 static void vl_api_bridge_flags_reply_t_handler_json
1751 (vl_api_bridge_flags_reply_t * mp)
1753 vat_main_t *vam = &vat_main;
1754 vat_json_node_t node;
1756 vat_json_init_object (&node);
1757 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1758 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1759 ntohl (mp->resulting_feature_bitmap));
1761 vat_json_print (vam->ofp, &node);
1762 vat_json_free (&node);
1764 vam->retval = ntohl (mp->retval);
1765 vam->result_ready = 1;
1769 vl_api_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_reply_t * mp)
1771 vat_main_t *vam = &vat_main;
1772 i32 retval = ntohl (mp->retval);
1773 if (vam->async_mode)
1775 vam->async_errors += (retval < 0);
1779 vam->retval = retval;
1780 vam->sw_if_index = ntohl (mp->sw_if_index);
1781 vam->result_ready = 1;
1786 static void vl_api_tap_create_v2_reply_t_handler_json
1787 (vl_api_tap_create_v2_reply_t * mp)
1789 vat_main_t *vam = &vat_main;
1790 vat_json_node_t node;
1792 vat_json_init_object (&node);
1793 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1794 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1796 vat_json_print (vam->ofp, &node);
1797 vat_json_free (&node);
1799 vam->retval = ntohl (mp->retval);
1800 vam->result_ready = 1;
1805 vl_api_tap_delete_v2_reply_t_handler (vl_api_tap_delete_v2_reply_t * mp)
1807 vat_main_t *vam = &vat_main;
1808 i32 retval = ntohl (mp->retval);
1809 if (vam->async_mode)
1811 vam->async_errors += (retval < 0);
1815 vam->retval = retval;
1816 vam->result_ready = 1;
1820 static void vl_api_tap_delete_v2_reply_t_handler_json
1821 (vl_api_tap_delete_v2_reply_t * mp)
1823 vat_main_t *vam = &vat_main;
1824 vat_json_node_t node;
1826 vat_json_init_object (&node);
1827 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1829 vat_json_print (vam->ofp, &node);
1830 vat_json_free (&node);
1832 vam->retval = ntohl (mp->retval);
1833 vam->result_ready = 1;
1837 vl_api_virtio_pci_create_reply_t_handler (vl_api_virtio_pci_create_reply_t *
1840 vat_main_t *vam = &vat_main;
1841 i32 retval = ntohl (mp->retval);
1842 if (vam->async_mode)
1844 vam->async_errors += (retval < 0);
1848 vam->retval = retval;
1849 vam->sw_if_index = ntohl (mp->sw_if_index);
1850 vam->result_ready = 1;
1854 static void vl_api_virtio_pci_create_reply_t_handler_json
1855 (vl_api_virtio_pci_create_reply_t * mp)
1857 vat_main_t *vam = &vat_main;
1858 vat_json_node_t node;
1860 vat_json_init_object (&node);
1861 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1862 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1864 vat_json_print (vam->ofp, &node);
1865 vat_json_free (&node);
1867 vam->retval = ntohl (mp->retval);
1868 vam->result_ready = 1;
1873 vl_api_virtio_pci_delete_reply_t_handler (vl_api_virtio_pci_delete_reply_t *
1876 vat_main_t *vam = &vat_main;
1877 i32 retval = ntohl (mp->retval);
1878 if (vam->async_mode)
1880 vam->async_errors += (retval < 0);
1884 vam->retval = retval;
1885 vam->result_ready = 1;
1889 static void vl_api_virtio_pci_delete_reply_t_handler_json
1890 (vl_api_virtio_pci_delete_reply_t * mp)
1892 vat_main_t *vam = &vat_main;
1893 vat_json_node_t node;
1895 vat_json_init_object (&node);
1896 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1898 vat_json_print (vam->ofp, &node);
1899 vat_json_free (&node);
1901 vam->retval = ntohl (mp->retval);
1902 vam->result_ready = 1;
1906 vl_api_bond_create_reply_t_handler (vl_api_bond_create_reply_t * mp)
1908 vat_main_t *vam = &vat_main;
1909 i32 retval = ntohl (mp->retval);
1911 if (vam->async_mode)
1913 vam->async_errors += (retval < 0);
1917 vam->retval = retval;
1918 vam->sw_if_index = ntohl (mp->sw_if_index);
1919 vam->result_ready = 1;
1923 static void vl_api_bond_create_reply_t_handler_json
1924 (vl_api_bond_create_reply_t * mp)
1926 vat_main_t *vam = &vat_main;
1927 vat_json_node_t node;
1929 vat_json_init_object (&node);
1930 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1931 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1933 vat_json_print (vam->ofp, &node);
1934 vat_json_free (&node);
1936 vam->retval = ntohl (mp->retval);
1937 vam->result_ready = 1;
1941 vl_api_bond_delete_reply_t_handler (vl_api_bond_delete_reply_t * mp)
1943 vat_main_t *vam = &vat_main;
1944 i32 retval = ntohl (mp->retval);
1946 if (vam->async_mode)
1948 vam->async_errors += (retval < 0);
1952 vam->retval = retval;
1953 vam->result_ready = 1;
1957 static void vl_api_bond_delete_reply_t_handler_json
1958 (vl_api_bond_delete_reply_t * mp)
1960 vat_main_t *vam = &vat_main;
1961 vat_json_node_t node;
1963 vat_json_init_object (&node);
1964 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1966 vat_json_print (vam->ofp, &node);
1967 vat_json_free (&node);
1969 vam->retval = ntohl (mp->retval);
1970 vam->result_ready = 1;
1974 vl_api_bond_enslave_reply_t_handler (vl_api_bond_enslave_reply_t * mp)
1976 vat_main_t *vam = &vat_main;
1977 i32 retval = ntohl (mp->retval);
1979 if (vam->async_mode)
1981 vam->async_errors += (retval < 0);
1985 vam->retval = retval;
1986 vam->result_ready = 1;
1990 static void vl_api_bond_enslave_reply_t_handler_json
1991 (vl_api_bond_enslave_reply_t * mp)
1993 vat_main_t *vam = &vat_main;
1994 vat_json_node_t node;
1996 vat_json_init_object (&node);
1997 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1999 vat_json_print (vam->ofp, &node);
2000 vat_json_free (&node);
2002 vam->retval = ntohl (mp->retval);
2003 vam->result_ready = 1;
2007 vl_api_bond_detach_slave_reply_t_handler (vl_api_bond_detach_slave_reply_t *
2010 vat_main_t *vam = &vat_main;
2011 i32 retval = ntohl (mp->retval);
2013 if (vam->async_mode)
2015 vam->async_errors += (retval < 0);
2019 vam->retval = retval;
2020 vam->result_ready = 1;
2024 static void vl_api_bond_detach_slave_reply_t_handler_json
2025 (vl_api_bond_detach_slave_reply_t * mp)
2027 vat_main_t *vam = &vat_main;
2028 vat_json_node_t node;
2030 vat_json_init_object (&node);
2031 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2033 vat_json_print (vam->ofp, &node);
2034 vat_json_free (&node);
2036 vam->retval = ntohl (mp->retval);
2037 vam->result_ready = 1;
2040 static void vl_api_sw_interface_bond_details_t_handler
2041 (vl_api_sw_interface_bond_details_t * mp)
2043 vat_main_t *vam = &vat_main;
2046 "%-16s %-12d %-12U %-13U %-14u %-14u",
2047 mp->interface_name, ntohl (mp->sw_if_index),
2048 format_bond_mode, mp->mode, format_bond_load_balance, mp->lb,
2049 ntohl (mp->active_slaves), ntohl (mp->slaves));
2052 static void vl_api_sw_interface_bond_details_t_handler_json
2053 (vl_api_sw_interface_bond_details_t * mp)
2055 vat_main_t *vam = &vat_main;
2056 vat_json_node_t *node = NULL;
2058 if (VAT_JSON_ARRAY != vam->json_tree.type)
2060 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2061 vat_json_init_array (&vam->json_tree);
2063 node = vat_json_array_add (&vam->json_tree);
2065 vat_json_init_object (node);
2066 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2067 vat_json_object_add_string_copy (node, "interface_name",
2068 mp->interface_name);
2069 vat_json_object_add_uint (node, "mode", mp->mode);
2070 vat_json_object_add_uint (node, "load_balance", mp->lb);
2071 vat_json_object_add_uint (node, "active_slaves", ntohl (mp->active_slaves));
2072 vat_json_object_add_uint (node, "slaves", ntohl (mp->slaves));
2076 api_sw_interface_bond_dump (vat_main_t * vam)
2078 vl_api_sw_interface_bond_dump_t *mp;
2079 vl_api_control_ping_t *mp_ping;
2083 "\n%-16s %-12s %-12s %-13s %-14s %-14s",
2084 "interface name", "sw_if_index", "mode", "load balance",
2085 "active slaves", "slaves");
2087 /* Get list of bond interfaces */
2088 M (SW_INTERFACE_BOND_DUMP, mp);
2091 /* Use a control ping for synchronization */
2092 MPING (CONTROL_PING, mp_ping);
2099 static void vl_api_sw_interface_slave_details_t_handler
2100 (vl_api_sw_interface_slave_details_t * mp)
2102 vat_main_t *vam = &vat_main;
2105 "%-25s %-12d %-12d %d", mp->interface_name,
2106 ntohl (mp->sw_if_index), mp->is_passive, mp->is_long_timeout);
2109 static void vl_api_sw_interface_slave_details_t_handler_json
2110 (vl_api_sw_interface_slave_details_t * mp)
2112 vat_main_t *vam = &vat_main;
2113 vat_json_node_t *node = NULL;
2115 if (VAT_JSON_ARRAY != vam->json_tree.type)
2117 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2118 vat_json_init_array (&vam->json_tree);
2120 node = vat_json_array_add (&vam->json_tree);
2122 vat_json_init_object (node);
2123 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2124 vat_json_object_add_string_copy (node, "interface_name",
2125 mp->interface_name);
2126 vat_json_object_add_uint (node, "passive", mp->is_passive);
2127 vat_json_object_add_uint (node, "long_timeout", mp->is_long_timeout);
2131 api_sw_interface_slave_dump (vat_main_t * vam)
2133 unformat_input_t *i = vam->input;
2134 vl_api_sw_interface_slave_dump_t *mp;
2135 vl_api_control_ping_t *mp_ping;
2136 u32 sw_if_index = ~0;
2137 u8 sw_if_index_set = 0;
2140 /* Parse args required to build the message */
2141 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2143 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2144 sw_if_index_set = 1;
2145 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2146 sw_if_index_set = 1;
2151 if (sw_if_index_set == 0)
2153 errmsg ("missing vpp interface name. ");
2158 "\n%-25s %-12s %-12s %s",
2159 "slave interface name", "sw_if_index", "passive", "long_timeout");
2161 /* Get list of bond interfaces */
2162 M (SW_INTERFACE_SLAVE_DUMP, mp);
2163 mp->sw_if_index = ntohl (sw_if_index);
2166 /* Use a control ping for synchronization */
2167 MPING (CONTROL_PING, mp_ping);
2174 static void vl_api_mpls_tunnel_add_del_reply_t_handler
2175 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2177 vat_main_t *vam = &vat_main;
2178 i32 retval = ntohl (mp->retval);
2179 if (vam->async_mode)
2181 vam->async_errors += (retval < 0);
2185 vam->retval = retval;
2186 vam->sw_if_index = ntohl (mp->sw_if_index);
2187 vam->result_ready = 1;
2189 vam->regenerate_interface_table = 1;
2192 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
2193 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2195 vat_main_t *vam = &vat_main;
2196 vat_json_node_t node;
2198 vat_json_init_object (&node);
2199 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2200 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
2201 ntohl (mp->sw_if_index));
2203 vat_json_print (vam->ofp, &node);
2204 vat_json_free (&node);
2206 vam->retval = ntohl (mp->retval);
2207 vam->result_ready = 1;
2210 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
2211 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2213 vat_main_t *vam = &vat_main;
2214 i32 retval = ntohl (mp->retval);
2215 if (vam->async_mode)
2217 vam->async_errors += (retval < 0);
2221 vam->retval = retval;
2222 vam->sw_if_index = ntohl (mp->sw_if_index);
2223 vam->result_ready = 1;
2227 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
2228 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2230 vat_main_t *vam = &vat_main;
2231 vat_json_node_t node;
2233 vat_json_init_object (&node);
2234 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2235 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2237 vat_json_print (vam->ofp, &node);
2238 vat_json_free (&node);
2240 vam->retval = ntohl (mp->retval);
2241 vam->result_ready = 1;
2244 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
2245 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2247 vat_main_t *vam = &vat_main;
2248 i32 retval = ntohl (mp->retval);
2249 if (vam->async_mode)
2251 vam->async_errors += (retval < 0);
2255 vam->retval = retval;
2256 vam->result_ready = 1;
2260 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
2261 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2263 vat_main_t *vam = &vat_main;
2264 vat_json_node_t node;
2266 vat_json_init_object (&node);
2267 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2268 vat_json_object_add_uint (&node, "fwd_entry_index",
2269 clib_net_to_host_u32 (mp->fwd_entry_index));
2271 vat_json_print (vam->ofp, &node);
2272 vat_json_free (&node);
2274 vam->retval = ntohl (mp->retval);
2275 vam->result_ready = 1;
2279 format_lisp_transport_protocol (u8 * s, va_list * args)
2281 u32 proto = va_arg (*args, u32);
2286 return format (s, "udp");
2288 return format (s, "api");
2295 static void vl_api_one_get_transport_protocol_reply_t_handler
2296 (vl_api_one_get_transport_protocol_reply_t * mp)
2298 vat_main_t *vam = &vat_main;
2299 i32 retval = ntohl (mp->retval);
2300 if (vam->async_mode)
2302 vam->async_errors += (retval < 0);
2306 u32 proto = mp->protocol;
2307 print (vam->ofp, "Transport protocol: %U",
2308 format_lisp_transport_protocol, proto);
2309 vam->retval = retval;
2310 vam->result_ready = 1;
2314 static void vl_api_one_get_transport_protocol_reply_t_handler_json
2315 (vl_api_one_get_transport_protocol_reply_t * mp)
2317 vat_main_t *vam = &vat_main;
2318 vat_json_node_t node;
2321 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
2324 vat_json_init_object (&node);
2325 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2326 vat_json_object_add_string_copy (&node, "transport-protocol", s);
2329 vat_json_print (vam->ofp, &node);
2330 vat_json_free (&node);
2332 vam->retval = ntohl (mp->retval);
2333 vam->result_ready = 1;
2336 static void vl_api_one_add_del_locator_set_reply_t_handler
2337 (vl_api_one_add_del_locator_set_reply_t * mp)
2339 vat_main_t *vam = &vat_main;
2340 i32 retval = ntohl (mp->retval);
2341 if (vam->async_mode)
2343 vam->async_errors += (retval < 0);
2347 vam->retval = retval;
2348 vam->result_ready = 1;
2352 static void vl_api_one_add_del_locator_set_reply_t_handler_json
2353 (vl_api_one_add_del_locator_set_reply_t * mp)
2355 vat_main_t *vam = &vat_main;
2356 vat_json_node_t node;
2358 vat_json_init_object (&node);
2359 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2360 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
2362 vat_json_print (vam->ofp, &node);
2363 vat_json_free (&node);
2365 vam->retval = ntohl (mp->retval);
2366 vam->result_ready = 1;
2369 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
2370 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2372 vat_main_t *vam = &vat_main;
2373 i32 retval = ntohl (mp->retval);
2374 if (vam->async_mode)
2376 vam->async_errors += (retval < 0);
2380 vam->retval = retval;
2381 vam->sw_if_index = ntohl (mp->sw_if_index);
2382 vam->result_ready = 1;
2384 vam->regenerate_interface_table = 1;
2387 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
2388 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2390 vat_main_t *vam = &vat_main;
2391 vat_json_node_t node;
2393 vat_json_init_object (&node);
2394 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2395 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2397 vat_json_print (vam->ofp, &node);
2398 vat_json_free (&node);
2400 vam->retval = ntohl (mp->retval);
2401 vam->result_ready = 1;
2404 static void vl_api_vxlan_offload_rx_reply_t_handler
2405 (vl_api_vxlan_offload_rx_reply_t * mp)
2407 vat_main_t *vam = &vat_main;
2408 i32 retval = ntohl (mp->retval);
2409 if (vam->async_mode)
2411 vam->async_errors += (retval < 0);
2415 vam->retval = retval;
2416 vam->result_ready = 1;
2420 static void vl_api_vxlan_offload_rx_reply_t_handler_json
2421 (vl_api_vxlan_offload_rx_reply_t * mp)
2423 vat_main_t *vam = &vat_main;
2424 vat_json_node_t node;
2426 vat_json_init_object (&node);
2427 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2429 vat_json_print (vam->ofp, &node);
2430 vat_json_free (&node);
2432 vam->retval = ntohl (mp->retval);
2433 vam->result_ready = 1;
2436 static void vl_api_geneve_add_del_tunnel_reply_t_handler
2437 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2439 vat_main_t *vam = &vat_main;
2440 i32 retval = ntohl (mp->retval);
2441 if (vam->async_mode)
2443 vam->async_errors += (retval < 0);
2447 vam->retval = retval;
2448 vam->sw_if_index = ntohl (mp->sw_if_index);
2449 vam->result_ready = 1;
2453 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
2454 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2456 vat_main_t *vam = &vat_main;
2457 vat_json_node_t node;
2459 vat_json_init_object (&node);
2460 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2461 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2463 vat_json_print (vam->ofp, &node);
2464 vat_json_free (&node);
2466 vam->retval = ntohl (mp->retval);
2467 vam->result_ready = 1;
2470 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
2471 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2473 vat_main_t *vam = &vat_main;
2474 i32 retval = ntohl (mp->retval);
2475 if (vam->async_mode)
2477 vam->async_errors += (retval < 0);
2481 vam->retval = retval;
2482 vam->sw_if_index = ntohl (mp->sw_if_index);
2483 vam->result_ready = 1;
2485 vam->regenerate_interface_table = 1;
2488 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
2489 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2491 vat_main_t *vam = &vat_main;
2492 vat_json_node_t node;
2494 vat_json_init_object (&node);
2495 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2496 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2498 vat_json_print (vam->ofp, &node);
2499 vat_json_free (&node);
2501 vam->retval = ntohl (mp->retval);
2502 vam->result_ready = 1;
2505 static void vl_api_gre_tunnel_add_del_reply_t_handler
2506 (vl_api_gre_tunnel_add_del_reply_t * mp)
2508 vat_main_t *vam = &vat_main;
2509 i32 retval = ntohl (mp->retval);
2510 if (vam->async_mode)
2512 vam->async_errors += (retval < 0);
2516 vam->retval = retval;
2517 vam->sw_if_index = ntohl (mp->sw_if_index);
2518 vam->result_ready = 1;
2522 static void vl_api_gre_tunnel_add_del_reply_t_handler_json
2523 (vl_api_gre_tunnel_add_del_reply_t * mp)
2525 vat_main_t *vam = &vat_main;
2526 vat_json_node_t node;
2528 vat_json_init_object (&node);
2529 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2530 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2532 vat_json_print (vam->ofp, &node);
2533 vat_json_free (&node);
2535 vam->retval = ntohl (mp->retval);
2536 vam->result_ready = 1;
2539 static void vl_api_create_vhost_user_if_reply_t_handler
2540 (vl_api_create_vhost_user_if_reply_t * mp)
2542 vat_main_t *vam = &vat_main;
2543 i32 retval = ntohl (mp->retval);
2544 if (vam->async_mode)
2546 vam->async_errors += (retval < 0);
2550 vam->retval = retval;
2551 vam->sw_if_index = ntohl (mp->sw_if_index);
2552 vam->result_ready = 1;
2554 vam->regenerate_interface_table = 1;
2557 static void vl_api_create_vhost_user_if_reply_t_handler_json
2558 (vl_api_create_vhost_user_if_reply_t * mp)
2560 vat_main_t *vam = &vat_main;
2561 vat_json_node_t node;
2563 vat_json_init_object (&node);
2564 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2565 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2567 vat_json_print (vam->ofp, &node);
2568 vat_json_free (&node);
2570 vam->retval = ntohl (mp->retval);
2571 vam->result_ready = 1;
2574 static void vl_api_dns_resolve_name_reply_t_handler
2575 (vl_api_dns_resolve_name_reply_t * mp)
2577 vat_main_t *vam = &vat_main;
2578 i32 retval = ntohl (mp->retval);
2579 if (vam->async_mode)
2581 vam->async_errors += (retval < 0);
2585 vam->retval = retval;
2586 vam->result_ready = 1;
2591 clib_warning ("ip4 address %U", format_ip4_address,
2592 (ip4_address_t *) mp->ip4_address);
2594 clib_warning ("ip6 address %U", format_ip6_address,
2595 (ip6_address_t *) mp->ip6_address);
2598 clib_warning ("retval %d", retval);
2602 static void vl_api_dns_resolve_name_reply_t_handler_json
2603 (vl_api_dns_resolve_name_reply_t * mp)
2605 clib_warning ("not implemented");
2608 static void vl_api_dns_resolve_ip_reply_t_handler
2609 (vl_api_dns_resolve_ip_reply_t * mp)
2611 vat_main_t *vam = &vat_main;
2612 i32 retval = ntohl (mp->retval);
2613 if (vam->async_mode)
2615 vam->async_errors += (retval < 0);
2619 vam->retval = retval;
2620 vam->result_ready = 1;
2624 clib_warning ("canonical name %s", mp->name);
2627 clib_warning ("retval %d", retval);
2631 static void vl_api_dns_resolve_ip_reply_t_handler_json
2632 (vl_api_dns_resolve_ip_reply_t * mp)
2634 clib_warning ("not implemented");
2638 static void vl_api_ip_address_details_t_handler
2639 (vl_api_ip_address_details_t * mp)
2641 vat_main_t *vam = &vat_main;
2642 static ip_address_details_t empty_ip_address_details = { {0} };
2643 ip_address_details_t *address = NULL;
2644 ip_details_t *current_ip_details = NULL;
2645 ip_details_t *details = NULL;
2647 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2649 if (!details || vam->current_sw_if_index >= vec_len (details)
2650 || !details[vam->current_sw_if_index].present)
2652 errmsg ("ip address details arrived but not stored");
2653 errmsg ("ip_dump should be called first");
2657 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2659 #define addresses (current_ip_details->addr)
2661 vec_validate_init_empty (addresses, vec_len (addresses),
2662 empty_ip_address_details);
2664 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2666 clib_memcpy (&address->ip, &mp->prefix.address.un, sizeof (address->ip));
2667 address->prefix_length = mp->prefix.address_length;
2671 static void vl_api_ip_address_details_t_handler_json
2672 (vl_api_ip_address_details_t * mp)
2674 vat_main_t *vam = &vat_main;
2675 vat_json_node_t *node = NULL;
2677 if (VAT_JSON_ARRAY != vam->json_tree.type)
2679 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2680 vat_json_init_array (&vam->json_tree);
2682 node = vat_json_array_add (&vam->json_tree);
2684 vat_json_init_object (node);
2685 vat_json_object_add_prefix (node, &mp->prefix);
2689 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2691 vat_main_t *vam = &vat_main;
2692 static ip_details_t empty_ip_details = { 0 };
2693 ip_details_t *ip = NULL;
2694 u32 sw_if_index = ~0;
2696 sw_if_index = ntohl (mp->sw_if_index);
2698 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2699 sw_if_index, empty_ip_details);
2701 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2708 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2710 vat_main_t *vam = &vat_main;
2712 if (VAT_JSON_ARRAY != vam->json_tree.type)
2714 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2715 vat_json_init_array (&vam->json_tree);
2717 vat_json_array_add_uint (&vam->json_tree,
2718 clib_net_to_host_u32 (mp->sw_if_index));
2722 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2726 s = format (0, "DHCP compl event: pid %d %s hostname %s host_addr %U "
2727 "host_mac %U router_addr %U",
2728 ntohl (mp->pid), mp->lease.is_ipv6 ? "ipv6" : "ipv4",
2730 format_ip4_address, mp->lease.host_address,
2731 format_ethernet_address, mp->lease.host_mac,
2732 format_ip4_address, mp->lease.router_address);
2734 for (i = 0; i < mp->lease.count; i++)
2736 format (s, " domain_server_addr %U", format_ip4_address,
2737 mp->lease.domain_server[i].address);
2739 errmsg ((char *) s);
2743 static void vl_api_dhcp_compl_event_t_handler_json
2744 (vl_api_dhcp_compl_event_t * mp)
2746 /* JSON output not supported */
2749 static void vl_api_get_first_msg_id_reply_t_handler
2750 (vl_api_get_first_msg_id_reply_t * mp)
2752 vat_main_t *vam = &vat_main;
2753 i32 retval = ntohl (mp->retval);
2755 if (vam->async_mode)
2757 vam->async_errors += (retval < 0);
2761 vam->retval = retval;
2762 vam->result_ready = 1;
2766 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2770 static void vl_api_get_first_msg_id_reply_t_handler_json
2771 (vl_api_get_first_msg_id_reply_t * mp)
2773 vat_main_t *vam = &vat_main;
2774 vat_json_node_t node;
2776 vat_json_init_object (&node);
2777 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2778 vat_json_object_add_uint (&node, "first_msg_id",
2779 (uint) ntohs (mp->first_msg_id));
2781 vat_json_print (vam->ofp, &node);
2782 vat_json_free (&node);
2784 vam->retval = ntohl (mp->retval);
2785 vam->result_ready = 1;
2788 static void vl_api_get_node_graph_reply_t_handler
2789 (vl_api_get_node_graph_reply_t * mp)
2791 vat_main_t *vam = &vat_main;
2792 api_main_t *am = &api_main;
2793 i32 retval = ntohl (mp->retval);
2794 u8 *pvt_copy, *reply;
2799 if (vam->async_mode)
2801 vam->async_errors += (retval < 0);
2805 vam->retval = retval;
2806 vam->result_ready = 1;
2809 /* "Should never happen..." */
2813 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2814 pvt_copy = vec_dup (reply);
2816 /* Toss the shared-memory original... */
2817 pthread_mutex_lock (&am->vlib_rp->mutex);
2818 oldheap = svm_push_data_heap (am->vlib_rp);
2822 svm_pop_heap (oldheap);
2823 pthread_mutex_unlock (&am->vlib_rp->mutex);
2825 if (vam->graph_nodes)
2827 hash_free (vam->graph_node_index_by_name);
2829 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2831 node = vam->graph_nodes[0][i];
2832 vec_free (node->name);
2833 vec_free (node->next_nodes);
2836 vec_free (vam->graph_nodes[0]);
2837 vec_free (vam->graph_nodes);
2840 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2841 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2842 vec_free (pvt_copy);
2844 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2846 node = vam->graph_nodes[0][i];
2847 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2851 static void vl_api_get_node_graph_reply_t_handler_json
2852 (vl_api_get_node_graph_reply_t * mp)
2854 vat_main_t *vam = &vat_main;
2855 api_main_t *am = &api_main;
2857 vat_json_node_t node;
2860 /* $$$$ make this real? */
2861 vat_json_init_object (&node);
2862 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2863 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2865 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2867 /* Toss the shared-memory original... */
2868 pthread_mutex_lock (&am->vlib_rp->mutex);
2869 oldheap = svm_push_data_heap (am->vlib_rp);
2873 svm_pop_heap (oldheap);
2874 pthread_mutex_unlock (&am->vlib_rp->mutex);
2876 vat_json_print (vam->ofp, &node);
2877 vat_json_free (&node);
2879 vam->retval = ntohl (mp->retval);
2880 vam->result_ready = 1;
2884 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2886 vat_main_t *vam = &vat_main;
2891 s = format (s, "%=16d%=16d%=16d",
2892 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2896 s = format (s, "%=16U%=16d%=16d",
2897 mp->is_ipv6 ? format_ip6_address :
2899 mp->ip_address, mp->priority, mp->weight);
2902 print (vam->ofp, "%v", s);
2907 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2909 vat_main_t *vam = &vat_main;
2910 vat_json_node_t *node = NULL;
2911 struct in6_addr ip6;
2914 if (VAT_JSON_ARRAY != vam->json_tree.type)
2916 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2917 vat_json_init_array (&vam->json_tree);
2919 node = vat_json_array_add (&vam->json_tree);
2920 vat_json_init_object (node);
2922 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2923 vat_json_object_add_uint (node, "priority", mp->priority);
2924 vat_json_object_add_uint (node, "weight", mp->weight);
2927 vat_json_object_add_uint (node, "sw_if_index",
2928 clib_net_to_host_u32 (mp->sw_if_index));
2933 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2934 vat_json_object_add_ip6 (node, "address", ip6);
2938 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2939 vat_json_object_add_ip4 (node, "address", ip4);
2945 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2948 vat_main_t *vam = &vat_main;
2951 ls_name = format (0, "%s", mp->ls_name);
2953 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2959 vl_api_one_locator_set_details_t_handler_json
2960 (vl_api_one_locator_set_details_t * mp)
2962 vat_main_t *vam = &vat_main;
2963 vat_json_node_t *node = 0;
2966 ls_name = format (0, "%s", mp->ls_name);
2967 vec_add1 (ls_name, 0);
2969 if (VAT_JSON_ARRAY != vam->json_tree.type)
2971 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2972 vat_json_init_array (&vam->json_tree);
2974 node = vat_json_array_add (&vam->json_tree);
2976 vat_json_init_object (node);
2977 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2978 vat_json_object_add_uint (node, "ls_index",
2979 clib_net_to_host_u32 (mp->ls_index));
2987 } __attribute__ ((__packed__)) lisp_nsh_api_t;
2990 unformat_nsh_address (unformat_input_t * input, va_list * args)
2992 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
2993 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
2997 format_nsh_address_vat (u8 * s, va_list * args)
2999 nsh_t *a = va_arg (*args, nsh_t *);
3000 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
3004 format_lisp_flat_eid (u8 * s, va_list * args)
3006 u32 type = va_arg (*args, u32);
3007 u8 *eid = va_arg (*args, u8 *);
3008 u32 eid_len = va_arg (*args, u32);
3013 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
3015 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
3017 return format (s, "%U", format_ethernet_address, eid);
3019 return format (s, "%U", format_nsh_address_vat, eid);
3025 format_lisp_eid_vat (u8 * s, va_list * args)
3027 u32 type = va_arg (*args, u32);
3028 u8 *eid = va_arg (*args, u8 *);
3029 u32 eid_len = va_arg (*args, u32);
3030 u8 *seid = va_arg (*args, u8 *);
3031 u32 seid_len = va_arg (*args, u32);
3032 u32 is_src_dst = va_arg (*args, u32);
3035 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
3037 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
3043 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
3045 vat_main_t *vam = &vat_main;
3046 u8 *s = 0, *eid = 0;
3048 if (~0 == mp->locator_set_index)
3049 s = format (0, "action: %d", mp->action);
3051 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3053 eid = format (0, "%U", format_lisp_eid_vat,
3057 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3060 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3061 clib_net_to_host_u32 (mp->vni),
3063 mp->is_local ? "local" : "remote",
3064 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3065 clib_net_to_host_u16 (mp->key_id), mp->key);
3072 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3075 vat_main_t *vam = &vat_main;
3076 vat_json_node_t *node = 0;
3079 if (VAT_JSON_ARRAY != vam->json_tree.type)
3081 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3082 vat_json_init_array (&vam->json_tree);
3084 node = vat_json_array_add (&vam->json_tree);
3086 vat_json_init_object (node);
3087 if (~0 == mp->locator_set_index)
3088 vat_json_object_add_uint (node, "action", mp->action);
3090 vat_json_object_add_uint (node, "locator_set_index",
3091 clib_net_to_host_u32 (mp->locator_set_index));
3093 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3094 if (mp->eid_type == 3)
3096 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3097 vat_json_init_object (nsh_json);
3098 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3099 vat_json_object_add_uint (nsh_json, "spi",
3100 clib_net_to_host_u32 (nsh->spi));
3101 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3105 eid = format (0, "%U", format_lisp_eid_vat,
3109 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3111 vat_json_object_add_string_copy (node, "eid", eid);
3114 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3115 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3116 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3120 vat_json_object_add_uint (node, "key_id",
3121 clib_net_to_host_u16 (mp->key_id));
3122 vat_json_object_add_string_copy (node, "key", mp->key);
3127 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3129 vat_main_t *vam = &vat_main;
3130 u8 *seid = 0, *deid = 0;
3131 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3133 deid = format (0, "%U", format_lisp_eid_vat,
3134 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3136 seid = format (0, "%U", format_lisp_eid_vat,
3137 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3143 format_ip_address_fcn = format_ip4_address;
3145 format_ip_address_fcn = format_ip6_address;
3148 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3149 clib_net_to_host_u32 (mp->vni),
3151 format_ip_address_fcn, mp->lloc,
3152 format_ip_address_fcn, mp->rloc,
3153 clib_net_to_host_u32 (mp->pkt_count),
3154 clib_net_to_host_u32 (mp->bytes));
3161 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3163 struct in6_addr ip6;
3165 vat_main_t *vam = &vat_main;
3166 vat_json_node_t *node = 0;
3167 u8 *deid = 0, *seid = 0;
3169 if (VAT_JSON_ARRAY != vam->json_tree.type)
3171 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3172 vat_json_init_array (&vam->json_tree);
3174 node = vat_json_array_add (&vam->json_tree);
3176 vat_json_init_object (node);
3177 deid = format (0, "%U", format_lisp_eid_vat,
3178 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3180 seid = format (0, "%U", format_lisp_eid_vat,
3181 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3186 vat_json_object_add_string_copy (node, "seid", seid);
3187 vat_json_object_add_string_copy (node, "deid", deid);
3188 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3192 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3193 vat_json_object_add_ip4 (node, "lloc", ip4);
3194 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3195 vat_json_object_add_ip4 (node, "rloc", ip4);
3199 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3200 vat_json_object_add_ip6 (node, "lloc", ip6);
3201 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3202 vat_json_object_add_ip6 (node, "rloc", ip6);
3204 vat_json_object_add_uint (node, "pkt_count",
3205 clib_net_to_host_u32 (mp->pkt_count));
3206 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3213 vl_api_one_eid_table_map_details_t_handler
3214 (vl_api_one_eid_table_map_details_t * mp)
3216 vat_main_t *vam = &vat_main;
3218 u8 *line = format (0, "%=10d%=10d",
3219 clib_net_to_host_u32 (mp->vni),
3220 clib_net_to_host_u32 (mp->dp_table));
3221 print (vam->ofp, "%v", line);
3226 vl_api_one_eid_table_map_details_t_handler_json
3227 (vl_api_one_eid_table_map_details_t * mp)
3229 vat_main_t *vam = &vat_main;
3230 vat_json_node_t *node = NULL;
3232 if (VAT_JSON_ARRAY != vam->json_tree.type)
3234 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3235 vat_json_init_array (&vam->json_tree);
3237 node = vat_json_array_add (&vam->json_tree);
3238 vat_json_init_object (node);
3239 vat_json_object_add_uint (node, "dp_table",
3240 clib_net_to_host_u32 (mp->dp_table));
3241 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3245 vl_api_one_eid_table_vni_details_t_handler
3246 (vl_api_one_eid_table_vni_details_t * mp)
3248 vat_main_t *vam = &vat_main;
3250 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3251 print (vam->ofp, "%v", line);
3256 vl_api_one_eid_table_vni_details_t_handler_json
3257 (vl_api_one_eid_table_vni_details_t * mp)
3259 vat_main_t *vam = &vat_main;
3260 vat_json_node_t *node = NULL;
3262 if (VAT_JSON_ARRAY != vam->json_tree.type)
3264 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3265 vat_json_init_array (&vam->json_tree);
3267 node = vat_json_array_add (&vam->json_tree);
3268 vat_json_init_object (node);
3269 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3273 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3274 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3276 vat_main_t *vam = &vat_main;
3277 int retval = clib_net_to_host_u32 (mp->retval);
3279 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3280 print (vam->ofp, "fallback threshold value: %d", mp->value);
3282 vam->retval = retval;
3283 vam->result_ready = 1;
3287 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3288 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3290 vat_main_t *vam = &vat_main;
3291 vat_json_node_t _node, *node = &_node;
3292 int retval = clib_net_to_host_u32 (mp->retval);
3294 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3295 vat_json_init_object (node);
3296 vat_json_object_add_uint (node, "value", mp->value);
3298 vat_json_print (vam->ofp, node);
3299 vat_json_free (node);
3301 vam->retval = retval;
3302 vam->result_ready = 1;
3306 vl_api_show_one_map_register_state_reply_t_handler
3307 (vl_api_show_one_map_register_state_reply_t * mp)
3309 vat_main_t *vam = &vat_main;
3310 int retval = clib_net_to_host_u32 (mp->retval);
3312 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3314 vam->retval = retval;
3315 vam->result_ready = 1;
3319 vl_api_show_one_map_register_state_reply_t_handler_json
3320 (vl_api_show_one_map_register_state_reply_t * mp)
3322 vat_main_t *vam = &vat_main;
3323 vat_json_node_t _node, *node = &_node;
3324 int retval = clib_net_to_host_u32 (mp->retval);
3326 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3328 vat_json_init_object (node);
3329 vat_json_object_add_string_copy (node, "state", s);
3331 vat_json_print (vam->ofp, node);
3332 vat_json_free (node);
3334 vam->retval = retval;
3335 vam->result_ready = 1;
3340 vl_api_show_one_rloc_probe_state_reply_t_handler
3341 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3343 vat_main_t *vam = &vat_main;
3344 int retval = clib_net_to_host_u32 (mp->retval);
3349 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3351 vam->retval = retval;
3352 vam->result_ready = 1;
3356 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3357 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3359 vat_main_t *vam = &vat_main;
3360 vat_json_node_t _node, *node = &_node;
3361 int retval = clib_net_to_host_u32 (mp->retval);
3363 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3364 vat_json_init_object (node);
3365 vat_json_object_add_string_copy (node, "state", s);
3367 vat_json_print (vam->ofp, node);
3368 vat_json_free (node);
3370 vam->retval = retval;
3371 vam->result_ready = 1;
3376 vl_api_show_one_stats_enable_disable_reply_t_handler
3377 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3379 vat_main_t *vam = &vat_main;
3380 int retval = clib_net_to_host_u32 (mp->retval);
3385 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3387 vam->retval = retval;
3388 vam->result_ready = 1;
3392 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3393 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3395 vat_main_t *vam = &vat_main;
3396 vat_json_node_t _node, *node = &_node;
3397 int retval = clib_net_to_host_u32 (mp->retval);
3399 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3400 vat_json_init_object (node);
3401 vat_json_object_add_string_copy (node, "state", s);
3403 vat_json_print (vam->ofp, node);
3404 vat_json_free (node);
3406 vam->retval = retval;
3407 vam->result_ready = 1;
3412 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3414 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3415 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3416 e->vni = clib_net_to_host_u32 (e->vni);
3420 gpe_fwd_entries_get_reply_t_net_to_host
3421 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3425 mp->count = clib_net_to_host_u32 (mp->count);
3426 for (i = 0; i < mp->count; i++)
3428 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3433 format_gpe_encap_mode (u8 * s, va_list * args)
3435 u32 mode = va_arg (*args, u32);
3440 return format (s, "lisp");
3442 return format (s, "vxlan");
3448 vl_api_gpe_get_encap_mode_reply_t_handler
3449 (vl_api_gpe_get_encap_mode_reply_t * mp)
3451 vat_main_t *vam = &vat_main;
3453 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3454 vam->retval = ntohl (mp->retval);
3455 vam->result_ready = 1;
3459 vl_api_gpe_get_encap_mode_reply_t_handler_json
3460 (vl_api_gpe_get_encap_mode_reply_t * mp)
3462 vat_main_t *vam = &vat_main;
3463 vat_json_node_t node;
3465 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3466 vec_add1 (encap_mode, 0);
3468 vat_json_init_object (&node);
3469 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3471 vec_free (encap_mode);
3472 vat_json_print (vam->ofp, &node);
3473 vat_json_free (&node);
3475 vam->retval = ntohl (mp->retval);
3476 vam->result_ready = 1;
3480 vl_api_gpe_fwd_entry_path_details_t_handler
3481 (vl_api_gpe_fwd_entry_path_details_t * mp)
3483 vat_main_t *vam = &vat_main;
3484 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3486 if (mp->lcl_loc.is_ip4)
3487 format_ip_address_fcn = format_ip4_address;
3489 format_ip_address_fcn = format_ip6_address;
3491 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3492 format_ip_address_fcn, &mp->lcl_loc,
3493 format_ip_address_fcn, &mp->rmt_loc);
3497 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3499 struct in6_addr ip6;
3504 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3505 vat_json_object_add_ip4 (n, "address", ip4);
3509 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3510 vat_json_object_add_ip6 (n, "address", ip6);
3512 vat_json_object_add_uint (n, "weight", loc->weight);
3516 vl_api_gpe_fwd_entry_path_details_t_handler_json
3517 (vl_api_gpe_fwd_entry_path_details_t * mp)
3519 vat_main_t *vam = &vat_main;
3520 vat_json_node_t *node = NULL;
3521 vat_json_node_t *loc_node;
3523 if (VAT_JSON_ARRAY != vam->json_tree.type)
3525 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3526 vat_json_init_array (&vam->json_tree);
3528 node = vat_json_array_add (&vam->json_tree);
3529 vat_json_init_object (node);
3531 loc_node = vat_json_object_add (node, "local_locator");
3532 vat_json_init_object (loc_node);
3533 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3535 loc_node = vat_json_object_add (node, "remote_locator");
3536 vat_json_init_object (loc_node);
3537 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3541 vl_api_gpe_fwd_entries_get_reply_t_handler
3542 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3544 vat_main_t *vam = &vat_main;
3546 int retval = clib_net_to_host_u32 (mp->retval);
3547 vl_api_gpe_fwd_entry_t *e;
3552 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3554 for (i = 0; i < mp->count; i++)
3556 e = &mp->entries[i];
3557 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3558 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3559 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3563 vam->retval = retval;
3564 vam->result_ready = 1;
3568 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3569 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3572 vat_main_t *vam = &vat_main;
3573 vat_json_node_t *e = 0, root;
3575 int retval = clib_net_to_host_u32 (mp->retval);
3576 vl_api_gpe_fwd_entry_t *fwd;
3581 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3582 vat_json_init_array (&root);
3584 for (i = 0; i < mp->count; i++)
3586 e = vat_json_array_add (&root);
3587 fwd = &mp->entries[i];
3589 vat_json_init_object (e);
3590 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3591 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3592 vat_json_object_add_int (e, "vni", fwd->vni);
3593 vat_json_object_add_int (e, "action", fwd->action);
3595 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3596 fwd->leid_prefix_len);
3598 vat_json_object_add_string_copy (e, "leid", s);
3601 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3602 fwd->reid_prefix_len);
3604 vat_json_object_add_string_copy (e, "reid", s);
3608 vat_json_print (vam->ofp, &root);
3609 vat_json_free (&root);
3612 vam->retval = retval;
3613 vam->result_ready = 1;
3617 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3618 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3620 vat_main_t *vam = &vat_main;
3622 int retval = clib_net_to_host_u32 (mp->retval);
3623 vl_api_gpe_native_fwd_rpath_t *r;
3628 n = clib_net_to_host_u32 (mp->count);
3630 for (i = 0; i < n; i++)
3632 r = &mp->entries[i];
3633 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3634 clib_net_to_host_u32 (r->fib_index),
3635 clib_net_to_host_u32 (r->nh_sw_if_index),
3636 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3640 vam->retval = retval;
3641 vam->result_ready = 1;
3645 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3646 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3648 vat_main_t *vam = &vat_main;
3649 vat_json_node_t root, *e;
3651 int retval = clib_net_to_host_u32 (mp->retval);
3652 vl_api_gpe_native_fwd_rpath_t *r;
3658 n = clib_net_to_host_u32 (mp->count);
3659 vat_json_init_array (&root);
3661 for (i = 0; i < n; i++)
3663 e = vat_json_array_add (&root);
3664 vat_json_init_object (e);
3665 r = &mp->entries[i];
3667 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3670 vat_json_object_add_string_copy (e, "ip4", s);
3673 vat_json_object_add_uint (e, "fib_index",
3674 clib_net_to_host_u32 (r->fib_index));
3675 vat_json_object_add_uint (e, "nh_sw_if_index",
3676 clib_net_to_host_u32 (r->nh_sw_if_index));
3679 vat_json_print (vam->ofp, &root);
3680 vat_json_free (&root);
3683 vam->retval = retval;
3684 vam->result_ready = 1;
3688 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3689 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3691 vat_main_t *vam = &vat_main;
3693 int retval = clib_net_to_host_u32 (mp->retval);
3698 n = clib_net_to_host_u32 (mp->count);
3700 for (i = 0; i < n; i++)
3701 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3704 vam->retval = retval;
3705 vam->result_ready = 1;
3709 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3710 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3712 vat_main_t *vam = &vat_main;
3713 vat_json_node_t root;
3715 int retval = clib_net_to_host_u32 (mp->retval);
3720 n = clib_net_to_host_u32 (mp->count);
3721 vat_json_init_array (&root);
3723 for (i = 0; i < n; i++)
3724 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3726 vat_json_print (vam->ofp, &root);
3727 vat_json_free (&root);
3730 vam->retval = retval;
3731 vam->result_ready = 1;
3735 vl_api_one_ndp_entries_get_reply_t_handler
3736 (vl_api_one_ndp_entries_get_reply_t * mp)
3738 vat_main_t *vam = &vat_main;
3740 int retval = clib_net_to_host_u32 (mp->retval);
3745 n = clib_net_to_host_u32 (mp->count);
3747 for (i = 0; i < n; i++)
3748 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3749 format_ethernet_address, mp->entries[i].mac);
3752 vam->retval = retval;
3753 vam->result_ready = 1;
3757 vl_api_one_ndp_entries_get_reply_t_handler_json
3758 (vl_api_one_ndp_entries_get_reply_t * mp)
3761 vat_main_t *vam = &vat_main;
3762 vat_json_node_t *e = 0, root;
3764 int retval = clib_net_to_host_u32 (mp->retval);
3765 vl_api_one_ndp_entry_t *arp_entry;
3770 n = clib_net_to_host_u32 (mp->count);
3771 vat_json_init_array (&root);
3773 for (i = 0; i < n; i++)
3775 e = vat_json_array_add (&root);
3776 arp_entry = &mp->entries[i];
3778 vat_json_init_object (e);
3779 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3782 vat_json_object_add_string_copy (e, "mac", s);
3785 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3787 vat_json_object_add_string_copy (e, "ip6", s);
3791 vat_json_print (vam->ofp, &root);
3792 vat_json_free (&root);
3795 vam->retval = retval;
3796 vam->result_ready = 1;
3800 vl_api_one_l2_arp_entries_get_reply_t_handler
3801 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3803 vat_main_t *vam = &vat_main;
3805 int retval = clib_net_to_host_u32 (mp->retval);
3810 n = clib_net_to_host_u32 (mp->count);
3812 for (i = 0; i < n; i++)
3813 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3814 format_ethernet_address, mp->entries[i].mac);
3817 vam->retval = retval;
3818 vam->result_ready = 1;
3822 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3823 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3826 vat_main_t *vam = &vat_main;
3827 vat_json_node_t *e = 0, root;
3829 int retval = clib_net_to_host_u32 (mp->retval);
3830 vl_api_one_l2_arp_entry_t *arp_entry;
3835 n = clib_net_to_host_u32 (mp->count);
3836 vat_json_init_array (&root);
3838 for (i = 0; i < n; i++)
3840 e = vat_json_array_add (&root);
3841 arp_entry = &mp->entries[i];
3843 vat_json_init_object (e);
3844 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3847 vat_json_object_add_string_copy (e, "mac", s);
3850 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3852 vat_json_object_add_string_copy (e, "ip4", s);
3856 vat_json_print (vam->ofp, &root);
3857 vat_json_free (&root);
3860 vam->retval = retval;
3861 vam->result_ready = 1;
3865 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
3867 vat_main_t *vam = &vat_main;
3869 int retval = clib_net_to_host_u32 (mp->retval);
3874 n = clib_net_to_host_u32 (mp->count);
3876 for (i = 0; i < n; i++)
3878 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3882 vam->retval = retval;
3883 vam->result_ready = 1;
3887 vl_api_one_ndp_bd_get_reply_t_handler_json
3888 (vl_api_one_ndp_bd_get_reply_t * mp)
3890 vat_main_t *vam = &vat_main;
3891 vat_json_node_t root;
3893 int retval = clib_net_to_host_u32 (mp->retval);
3898 n = clib_net_to_host_u32 (mp->count);
3899 vat_json_init_array (&root);
3901 for (i = 0; i < n; i++)
3903 vat_json_array_add_uint (&root,
3904 clib_net_to_host_u32 (mp->bridge_domains[i]));
3907 vat_json_print (vam->ofp, &root);
3908 vat_json_free (&root);
3911 vam->retval = retval;
3912 vam->result_ready = 1;
3916 vl_api_one_l2_arp_bd_get_reply_t_handler
3917 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3919 vat_main_t *vam = &vat_main;
3921 int retval = clib_net_to_host_u32 (mp->retval);
3926 n = clib_net_to_host_u32 (mp->count);
3928 for (i = 0; i < n; i++)
3930 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3934 vam->retval = retval;
3935 vam->result_ready = 1;
3939 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3940 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3942 vat_main_t *vam = &vat_main;
3943 vat_json_node_t root;
3945 int retval = clib_net_to_host_u32 (mp->retval);
3950 n = clib_net_to_host_u32 (mp->count);
3951 vat_json_init_array (&root);
3953 for (i = 0; i < n; i++)
3955 vat_json_array_add_uint (&root,
3956 clib_net_to_host_u32 (mp->bridge_domains[i]));
3959 vat_json_print (vam->ofp, &root);
3960 vat_json_free (&root);
3963 vam->retval = retval;
3964 vam->result_ready = 1;
3968 vl_api_one_adjacencies_get_reply_t_handler
3969 (vl_api_one_adjacencies_get_reply_t * mp)
3971 vat_main_t *vam = &vat_main;
3973 int retval = clib_net_to_host_u32 (mp->retval);
3974 vl_api_one_adjacency_t *a;
3979 n = clib_net_to_host_u32 (mp->count);
3981 for (i = 0; i < n; i++)
3983 a = &mp->adjacencies[i];
3984 print (vam->ofp, "%U %40U",
3985 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3986 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3990 vam->retval = retval;
3991 vam->result_ready = 1;
3995 vl_api_one_adjacencies_get_reply_t_handler_json
3996 (vl_api_one_adjacencies_get_reply_t * mp)
3999 vat_main_t *vam = &vat_main;
4000 vat_json_node_t *e = 0, root;
4002 int retval = clib_net_to_host_u32 (mp->retval);
4003 vl_api_one_adjacency_t *a;
4008 n = clib_net_to_host_u32 (mp->count);
4009 vat_json_init_array (&root);
4011 for (i = 0; i < n; i++)
4013 e = vat_json_array_add (&root);
4014 a = &mp->adjacencies[i];
4016 vat_json_init_object (e);
4017 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
4018 a->leid_prefix_len);
4020 vat_json_object_add_string_copy (e, "leid", s);
4023 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
4024 a->reid_prefix_len);
4026 vat_json_object_add_string_copy (e, "reid", s);
4030 vat_json_print (vam->ofp, &root);
4031 vat_json_free (&root);
4034 vam->retval = retval;
4035 vam->result_ready = 1;
4039 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
4041 vat_main_t *vam = &vat_main;
4043 print (vam->ofp, "%=20U",
4044 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4049 vl_api_one_map_server_details_t_handler_json
4050 (vl_api_one_map_server_details_t * mp)
4052 vat_main_t *vam = &vat_main;
4053 vat_json_node_t *node = NULL;
4054 struct in6_addr ip6;
4057 if (VAT_JSON_ARRAY != vam->json_tree.type)
4059 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4060 vat_json_init_array (&vam->json_tree);
4062 node = vat_json_array_add (&vam->json_tree);
4064 vat_json_init_object (node);
4067 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4068 vat_json_object_add_ip6 (node, "map-server", ip6);
4072 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4073 vat_json_object_add_ip4 (node, "map-server", ip4);
4078 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4081 vat_main_t *vam = &vat_main;
4083 print (vam->ofp, "%=20U",
4084 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4089 vl_api_one_map_resolver_details_t_handler_json
4090 (vl_api_one_map_resolver_details_t * mp)
4092 vat_main_t *vam = &vat_main;
4093 vat_json_node_t *node = NULL;
4094 struct in6_addr ip6;
4097 if (VAT_JSON_ARRAY != vam->json_tree.type)
4099 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4100 vat_json_init_array (&vam->json_tree);
4102 node = vat_json_array_add (&vam->json_tree);
4104 vat_json_init_object (node);
4107 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4108 vat_json_object_add_ip6 (node, "map resolver", ip6);
4112 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4113 vat_json_object_add_ip4 (node, "map resolver", ip4);
4118 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4120 vat_main_t *vam = &vat_main;
4121 i32 retval = ntohl (mp->retval);
4125 print (vam->ofp, "feature: %s\ngpe: %s",
4126 mp->feature_status ? "enabled" : "disabled",
4127 mp->gpe_status ? "enabled" : "disabled");
4130 vam->retval = retval;
4131 vam->result_ready = 1;
4135 vl_api_show_one_status_reply_t_handler_json
4136 (vl_api_show_one_status_reply_t * mp)
4138 vat_main_t *vam = &vat_main;
4139 vat_json_node_t node;
4140 u8 *gpe_status = NULL;
4141 u8 *feature_status = NULL;
4143 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4144 feature_status = format (0, "%s",
4145 mp->feature_status ? "enabled" : "disabled");
4146 vec_add1 (gpe_status, 0);
4147 vec_add1 (feature_status, 0);
4149 vat_json_init_object (&node);
4150 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4151 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4153 vec_free (gpe_status);
4154 vec_free (feature_status);
4156 vat_json_print (vam->ofp, &node);
4157 vat_json_free (&node);
4159 vam->retval = ntohl (mp->retval);
4160 vam->result_ready = 1;
4164 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4165 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4167 vat_main_t *vam = &vat_main;
4168 i32 retval = ntohl (mp->retval);
4172 print (vam->ofp, "%=20s", mp->locator_set_name);
4175 vam->retval = retval;
4176 vam->result_ready = 1;
4180 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4181 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4183 vat_main_t *vam = &vat_main;
4184 vat_json_node_t *node = NULL;
4186 if (VAT_JSON_ARRAY != vam->json_tree.type)
4188 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4189 vat_json_init_array (&vam->json_tree);
4191 node = vat_json_array_add (&vam->json_tree);
4193 vat_json_init_object (node);
4194 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4196 vat_json_print (vam->ofp, node);
4197 vat_json_free (node);
4199 vam->retval = ntohl (mp->retval);
4200 vam->result_ready = 1;
4204 format_lisp_map_request_mode (u8 * s, va_list * args)
4206 u32 mode = va_arg (*args, u32);
4211 return format (0, "dst-only");
4213 return format (0, "src-dst");
4219 vl_api_show_one_map_request_mode_reply_t_handler
4220 (vl_api_show_one_map_request_mode_reply_t * mp)
4222 vat_main_t *vam = &vat_main;
4223 i32 retval = ntohl (mp->retval);
4227 u32 mode = mp->mode;
4228 print (vam->ofp, "map_request_mode: %U",
4229 format_lisp_map_request_mode, mode);
4232 vam->retval = retval;
4233 vam->result_ready = 1;
4237 vl_api_show_one_map_request_mode_reply_t_handler_json
4238 (vl_api_show_one_map_request_mode_reply_t * mp)
4240 vat_main_t *vam = &vat_main;
4241 vat_json_node_t node;
4246 s = format (0, "%U", format_lisp_map_request_mode, mode);
4249 vat_json_init_object (&node);
4250 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4251 vat_json_print (vam->ofp, &node);
4252 vat_json_free (&node);
4255 vam->retval = ntohl (mp->retval);
4256 vam->result_ready = 1;
4260 vl_api_one_show_xtr_mode_reply_t_handler
4261 (vl_api_one_show_xtr_mode_reply_t * mp)
4263 vat_main_t *vam = &vat_main;
4264 i32 retval = ntohl (mp->retval);
4268 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4271 vam->retval = retval;
4272 vam->result_ready = 1;
4276 vl_api_one_show_xtr_mode_reply_t_handler_json
4277 (vl_api_one_show_xtr_mode_reply_t * mp)
4279 vat_main_t *vam = &vat_main;
4280 vat_json_node_t node;
4283 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4284 vec_add1 (status, 0);
4286 vat_json_init_object (&node);
4287 vat_json_object_add_string_copy (&node, "status", status);
4291 vat_json_print (vam->ofp, &node);
4292 vat_json_free (&node);
4294 vam->retval = ntohl (mp->retval);
4295 vam->result_ready = 1;
4299 vl_api_one_show_pitr_mode_reply_t_handler
4300 (vl_api_one_show_pitr_mode_reply_t * mp)
4302 vat_main_t *vam = &vat_main;
4303 i32 retval = ntohl (mp->retval);
4307 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4310 vam->retval = retval;
4311 vam->result_ready = 1;
4315 vl_api_one_show_pitr_mode_reply_t_handler_json
4316 (vl_api_one_show_pitr_mode_reply_t * mp)
4318 vat_main_t *vam = &vat_main;
4319 vat_json_node_t node;
4322 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4323 vec_add1 (status, 0);
4325 vat_json_init_object (&node);
4326 vat_json_object_add_string_copy (&node, "status", status);
4330 vat_json_print (vam->ofp, &node);
4331 vat_json_free (&node);
4333 vam->retval = ntohl (mp->retval);
4334 vam->result_ready = 1;
4338 vl_api_one_show_petr_mode_reply_t_handler
4339 (vl_api_one_show_petr_mode_reply_t * mp)
4341 vat_main_t *vam = &vat_main;
4342 i32 retval = ntohl (mp->retval);
4346 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4349 vam->retval = retval;
4350 vam->result_ready = 1;
4354 vl_api_one_show_petr_mode_reply_t_handler_json
4355 (vl_api_one_show_petr_mode_reply_t * mp)
4357 vat_main_t *vam = &vat_main;
4358 vat_json_node_t node;
4361 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4362 vec_add1 (status, 0);
4364 vat_json_init_object (&node);
4365 vat_json_object_add_string_copy (&node, "status", status);
4369 vat_json_print (vam->ofp, &node);
4370 vat_json_free (&node);
4372 vam->retval = ntohl (mp->retval);
4373 vam->result_ready = 1;
4377 vl_api_show_one_use_petr_reply_t_handler
4378 (vl_api_show_one_use_petr_reply_t * mp)
4380 vat_main_t *vam = &vat_main;
4381 i32 retval = ntohl (mp->retval);
4385 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4388 print (vam->ofp, "Proxy-ETR address; %U",
4389 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4394 vam->retval = retval;
4395 vam->result_ready = 1;
4399 vl_api_show_one_use_petr_reply_t_handler_json
4400 (vl_api_show_one_use_petr_reply_t * mp)
4402 vat_main_t *vam = &vat_main;
4403 vat_json_node_t node;
4406 struct in6_addr ip6;
4408 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4409 vec_add1 (status, 0);
4411 vat_json_init_object (&node);
4412 vat_json_object_add_string_copy (&node, "status", status);
4417 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4418 vat_json_object_add_ip6 (&node, "address", ip6);
4422 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4423 vat_json_object_add_ip4 (&node, "address", ip4);
4429 vat_json_print (vam->ofp, &node);
4430 vat_json_free (&node);
4432 vam->retval = ntohl (mp->retval);
4433 vam->result_ready = 1;
4437 vl_api_show_one_nsh_mapping_reply_t_handler
4438 (vl_api_show_one_nsh_mapping_reply_t * mp)
4440 vat_main_t *vam = &vat_main;
4441 i32 retval = ntohl (mp->retval);
4445 print (vam->ofp, "%-20s%-16s",
4446 mp->is_set ? "set" : "not-set",
4447 mp->is_set ? (char *) mp->locator_set_name : "");
4450 vam->retval = retval;
4451 vam->result_ready = 1;
4455 vl_api_show_one_nsh_mapping_reply_t_handler_json
4456 (vl_api_show_one_nsh_mapping_reply_t * mp)
4458 vat_main_t *vam = &vat_main;
4459 vat_json_node_t node;
4462 status = format (0, "%s", mp->is_set ? "yes" : "no");
4463 vec_add1 (status, 0);
4465 vat_json_init_object (&node);
4466 vat_json_object_add_string_copy (&node, "is_set", status);
4469 vat_json_object_add_string_copy (&node, "locator_set",
4470 mp->locator_set_name);
4475 vat_json_print (vam->ofp, &node);
4476 vat_json_free (&node);
4478 vam->retval = ntohl (mp->retval);
4479 vam->result_ready = 1;
4483 vl_api_show_one_map_register_ttl_reply_t_handler
4484 (vl_api_show_one_map_register_ttl_reply_t * mp)
4486 vat_main_t *vam = &vat_main;
4487 i32 retval = ntohl (mp->retval);
4489 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4493 print (vam->ofp, "ttl: %u", mp->ttl);
4496 vam->retval = retval;
4497 vam->result_ready = 1;
4501 vl_api_show_one_map_register_ttl_reply_t_handler_json
4502 (vl_api_show_one_map_register_ttl_reply_t * mp)
4504 vat_main_t *vam = &vat_main;
4505 vat_json_node_t node;
4507 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4508 vat_json_init_object (&node);
4509 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4511 vat_json_print (vam->ofp, &node);
4512 vat_json_free (&node);
4514 vam->retval = ntohl (mp->retval);
4515 vam->result_ready = 1;
4519 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4521 vat_main_t *vam = &vat_main;
4522 i32 retval = ntohl (mp->retval);
4526 print (vam->ofp, "%-20s%-16s",
4527 mp->status ? "enabled" : "disabled",
4528 mp->status ? (char *) mp->locator_set_name : "");
4531 vam->retval = retval;
4532 vam->result_ready = 1;
4536 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4538 vat_main_t *vam = &vat_main;
4539 vat_json_node_t node;
4542 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4543 vec_add1 (status, 0);
4545 vat_json_init_object (&node);
4546 vat_json_object_add_string_copy (&node, "status", status);
4549 vat_json_object_add_string_copy (&node, "locator_set",
4550 mp->locator_set_name);
4555 vat_json_print (vam->ofp, &node);
4556 vat_json_free (&node);
4558 vam->retval = ntohl (mp->retval);
4559 vam->result_ready = 1;
4563 format_policer_type (u8 * s, va_list * va)
4565 u32 i = va_arg (*va, u32);
4567 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4568 s = format (s, "1r2c");
4569 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4570 s = format (s, "1r3c");
4571 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4572 s = format (s, "2r3c-2698");
4573 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4574 s = format (s, "2r3c-4115");
4575 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4576 s = format (s, "2r3c-mef5cf1");
4578 s = format (s, "ILLEGAL");
4583 format_policer_rate_type (u8 * s, va_list * va)
4585 u32 i = va_arg (*va, u32);
4587 if (i == SSE2_QOS_RATE_KBPS)
4588 s = format (s, "kbps");
4589 else if (i == SSE2_QOS_RATE_PPS)
4590 s = format (s, "pps");
4592 s = format (s, "ILLEGAL");
4597 format_policer_round_type (u8 * s, va_list * va)
4599 u32 i = va_arg (*va, u32);
4601 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4602 s = format (s, "closest");
4603 else if (i == SSE2_QOS_ROUND_TO_UP)
4604 s = format (s, "up");
4605 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4606 s = format (s, "down");
4608 s = format (s, "ILLEGAL");
4613 format_policer_action_type (u8 * s, va_list * va)
4615 u32 i = va_arg (*va, u32);
4617 if (i == SSE2_QOS_ACTION_DROP)
4618 s = format (s, "drop");
4619 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4620 s = format (s, "transmit");
4621 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4622 s = format (s, "mark-and-transmit");
4624 s = format (s, "ILLEGAL");
4629 format_dscp (u8 * s, va_list * va)
4631 u32 i = va_arg (*va, u32);
4636 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4640 return format (s, "ILLEGAL");
4642 s = format (s, "%s", t);
4647 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4649 vat_main_t *vam = &vat_main;
4650 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4652 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4653 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4655 conform_dscp_str = format (0, "");
4657 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4658 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4660 exceed_dscp_str = format (0, "");
4662 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4663 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4665 violate_dscp_str = format (0, "");
4667 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4668 "rate type %U, round type %U, %s rate, %s color-aware, "
4669 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4670 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4671 "conform action %U%s, exceed action %U%s, violate action %U%s",
4673 format_policer_type, mp->type,
4676 clib_net_to_host_u64 (mp->cb),
4677 clib_net_to_host_u64 (mp->eb),
4678 format_policer_rate_type, mp->rate_type,
4679 format_policer_round_type, mp->round_type,
4680 mp->single_rate ? "single" : "dual",
4681 mp->color_aware ? "is" : "not",
4682 ntohl (mp->cir_tokens_per_period),
4683 ntohl (mp->pir_tokens_per_period),
4685 ntohl (mp->current_limit),
4686 ntohl (mp->current_bucket),
4687 ntohl (mp->extended_limit),
4688 ntohl (mp->extended_bucket),
4689 clib_net_to_host_u64 (mp->last_update_time),
4690 format_policer_action_type, mp->conform_action_type,
4692 format_policer_action_type, mp->exceed_action_type,
4694 format_policer_action_type, mp->violate_action_type,
4697 vec_free (conform_dscp_str);
4698 vec_free (exceed_dscp_str);
4699 vec_free (violate_dscp_str);
4702 static void vl_api_policer_details_t_handler_json
4703 (vl_api_policer_details_t * mp)
4705 vat_main_t *vam = &vat_main;
4706 vat_json_node_t *node;
4707 u8 *rate_type_str, *round_type_str, *type_str;
4708 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4710 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4712 format (0, "%U", format_policer_round_type, mp->round_type);
4713 type_str = format (0, "%U", format_policer_type, mp->type);
4714 conform_action_str = format (0, "%U", format_policer_action_type,
4715 mp->conform_action_type);
4716 exceed_action_str = format (0, "%U", format_policer_action_type,
4717 mp->exceed_action_type);
4718 violate_action_str = format (0, "%U", format_policer_action_type,
4719 mp->violate_action_type);
4721 if (VAT_JSON_ARRAY != vam->json_tree.type)
4723 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4724 vat_json_init_array (&vam->json_tree);
4726 node = vat_json_array_add (&vam->json_tree);
4728 vat_json_init_object (node);
4729 vat_json_object_add_string_copy (node, "name", mp->name);
4730 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4731 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4732 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4733 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4734 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4735 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4736 vat_json_object_add_string_copy (node, "type", type_str);
4737 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4738 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4739 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4740 vat_json_object_add_uint (node, "cir_tokens_per_period",
4741 ntohl (mp->cir_tokens_per_period));
4742 vat_json_object_add_uint (node, "eir_tokens_per_period",
4743 ntohl (mp->pir_tokens_per_period));
4744 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4745 vat_json_object_add_uint (node, "current_bucket",
4746 ntohl (mp->current_bucket));
4747 vat_json_object_add_uint (node, "extended_limit",
4748 ntohl (mp->extended_limit));
4749 vat_json_object_add_uint (node, "extended_bucket",
4750 ntohl (mp->extended_bucket));
4751 vat_json_object_add_uint (node, "last_update_time",
4752 ntohl (mp->last_update_time));
4753 vat_json_object_add_string_copy (node, "conform_action",
4754 conform_action_str);
4755 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4757 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4758 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4759 vec_free (dscp_str);
4761 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4762 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4764 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4765 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4766 vec_free (dscp_str);
4768 vat_json_object_add_string_copy (node, "violate_action",
4769 violate_action_str);
4770 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4772 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4773 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4774 vec_free (dscp_str);
4777 vec_free (rate_type_str);
4778 vec_free (round_type_str);
4779 vec_free (type_str);
4780 vec_free (conform_action_str);
4781 vec_free (exceed_action_str);
4782 vec_free (violate_action_str);
4786 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4789 vat_main_t *vam = &vat_main;
4790 int i, count = ntohl (mp->count);
4793 print (vam->ofp, "classify table ids (%d) : ", count);
4794 for (i = 0; i < count; i++)
4796 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4797 print (vam->ofp, (i < count - 1) ? "," : "");
4799 vam->retval = ntohl (mp->retval);
4800 vam->result_ready = 1;
4804 vl_api_classify_table_ids_reply_t_handler_json
4805 (vl_api_classify_table_ids_reply_t * mp)
4807 vat_main_t *vam = &vat_main;
4808 int i, count = ntohl (mp->count);
4812 vat_json_node_t node;
4814 vat_json_init_object (&node);
4815 for (i = 0; i < count; i++)
4817 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4819 vat_json_print (vam->ofp, &node);
4820 vat_json_free (&node);
4822 vam->retval = ntohl (mp->retval);
4823 vam->result_ready = 1;
4827 vl_api_classify_table_by_interface_reply_t_handler
4828 (vl_api_classify_table_by_interface_reply_t * mp)
4830 vat_main_t *vam = &vat_main;
4833 table_id = ntohl (mp->l2_table_id);
4835 print (vam->ofp, "l2 table id : %d", table_id);
4837 print (vam->ofp, "l2 table id : No input ACL tables configured");
4838 table_id = ntohl (mp->ip4_table_id);
4840 print (vam->ofp, "ip4 table id : %d", table_id);
4842 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4843 table_id = ntohl (mp->ip6_table_id);
4845 print (vam->ofp, "ip6 table id : %d", table_id);
4847 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4848 vam->retval = ntohl (mp->retval);
4849 vam->result_ready = 1;
4853 vl_api_classify_table_by_interface_reply_t_handler_json
4854 (vl_api_classify_table_by_interface_reply_t * mp)
4856 vat_main_t *vam = &vat_main;
4857 vat_json_node_t node;
4859 vat_json_init_object (&node);
4861 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4862 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4863 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4865 vat_json_print (vam->ofp, &node);
4866 vat_json_free (&node);
4868 vam->retval = ntohl (mp->retval);
4869 vam->result_ready = 1;
4872 static void vl_api_policer_add_del_reply_t_handler
4873 (vl_api_policer_add_del_reply_t * mp)
4875 vat_main_t *vam = &vat_main;
4876 i32 retval = ntohl (mp->retval);
4877 if (vam->async_mode)
4879 vam->async_errors += (retval < 0);
4883 vam->retval = retval;
4884 vam->result_ready = 1;
4885 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4887 * Note: this is just barely thread-safe, depends on
4888 * the main thread spinning waiting for an answer...
4890 errmsg ("policer index %d", ntohl (mp->policer_index));
4894 static void vl_api_policer_add_del_reply_t_handler_json
4895 (vl_api_policer_add_del_reply_t * mp)
4897 vat_main_t *vam = &vat_main;
4898 vat_json_node_t node;
4900 vat_json_init_object (&node);
4901 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4902 vat_json_object_add_uint (&node, "policer_index",
4903 ntohl (mp->policer_index));
4905 vat_json_print (vam->ofp, &node);
4906 vat_json_free (&node);
4908 vam->retval = ntohl (mp->retval);
4909 vam->result_ready = 1;
4912 /* Format hex dump. */
4914 format_hex_bytes (u8 * s, va_list * va)
4916 u8 *bytes = va_arg (*va, u8 *);
4917 int n_bytes = va_arg (*va, int);
4920 /* Print short or long form depending on byte count. */
4921 uword short_form = n_bytes <= 32;
4922 u32 indent = format_get_indent (s);
4927 for (i = 0; i < n_bytes; i++)
4929 if (!short_form && (i % 32) == 0)
4930 s = format (s, "%08x: ", i);
4931 s = format (s, "%02x", bytes[i]);
4932 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4933 s = format (s, "\n%U", format_white_space, indent);
4940 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4943 vat_main_t *vam = &vat_main;
4944 i32 retval = ntohl (mp->retval);
4947 print (vam->ofp, "classify table info :");
4948 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4949 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4950 ntohl (mp->miss_next_index));
4951 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4952 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4953 ntohl (mp->match_n_vectors));
4954 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4955 ntohl (mp->mask_length));
4957 vam->retval = retval;
4958 vam->result_ready = 1;
4962 vl_api_classify_table_info_reply_t_handler_json
4963 (vl_api_classify_table_info_reply_t * mp)
4965 vat_main_t *vam = &vat_main;
4966 vat_json_node_t node;
4968 i32 retval = ntohl (mp->retval);
4971 vat_json_init_object (&node);
4973 vat_json_object_add_int (&node, "sessions",
4974 ntohl (mp->active_sessions));
4975 vat_json_object_add_int (&node, "nexttbl",
4976 ntohl (mp->next_table_index));
4977 vat_json_object_add_int (&node, "nextnode",
4978 ntohl (mp->miss_next_index));
4979 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4980 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4981 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4982 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4983 ntohl (mp->mask_length), 0);
4984 vat_json_object_add_string_copy (&node, "mask", s);
4986 vat_json_print (vam->ofp, &node);
4987 vat_json_free (&node);
4989 vam->retval = ntohl (mp->retval);
4990 vam->result_ready = 1;
4994 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4997 vat_main_t *vam = &vat_main;
4999 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
5000 ntohl (mp->hit_next_index), ntohl (mp->advance),
5001 ntohl (mp->opaque_index));
5002 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
5003 ntohl (mp->match_length));
5007 vl_api_classify_session_details_t_handler_json
5008 (vl_api_classify_session_details_t * mp)
5010 vat_main_t *vam = &vat_main;
5011 vat_json_node_t *node = NULL;
5013 if (VAT_JSON_ARRAY != vam->json_tree.type)
5015 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5016 vat_json_init_array (&vam->json_tree);
5018 node = vat_json_array_add (&vam->json_tree);
5020 vat_json_init_object (node);
5021 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
5022 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
5023 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
5025 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
5027 vat_json_object_add_string_copy (node, "match", s);
5030 static void vl_api_pg_create_interface_reply_t_handler
5031 (vl_api_pg_create_interface_reply_t * mp)
5033 vat_main_t *vam = &vat_main;
5035 vam->retval = ntohl (mp->retval);
5036 vam->result_ready = 1;
5039 static void vl_api_pg_create_interface_reply_t_handler_json
5040 (vl_api_pg_create_interface_reply_t * mp)
5042 vat_main_t *vam = &vat_main;
5043 vat_json_node_t node;
5045 i32 retval = ntohl (mp->retval);
5048 vat_json_init_object (&node);
5050 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
5052 vat_json_print (vam->ofp, &node);
5053 vat_json_free (&node);
5055 vam->retval = ntohl (mp->retval);
5056 vam->result_ready = 1;
5059 static void vl_api_policer_classify_details_t_handler
5060 (vl_api_policer_classify_details_t * mp)
5062 vat_main_t *vam = &vat_main;
5064 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5065 ntohl (mp->table_index));
5068 static void vl_api_policer_classify_details_t_handler_json
5069 (vl_api_policer_classify_details_t * mp)
5071 vat_main_t *vam = &vat_main;
5072 vat_json_node_t *node;
5074 if (VAT_JSON_ARRAY != vam->json_tree.type)
5076 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5077 vat_json_init_array (&vam->json_tree);
5079 node = vat_json_array_add (&vam->json_tree);
5081 vat_json_init_object (node);
5082 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5083 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5086 static void vl_api_flow_classify_details_t_handler
5087 (vl_api_flow_classify_details_t * mp)
5089 vat_main_t *vam = &vat_main;
5091 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5092 ntohl (mp->table_index));
5095 static void vl_api_flow_classify_details_t_handler_json
5096 (vl_api_flow_classify_details_t * mp)
5098 vat_main_t *vam = &vat_main;
5099 vat_json_node_t *node;
5101 if (VAT_JSON_ARRAY != vam->json_tree.type)
5103 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5104 vat_json_init_array (&vam->json_tree);
5106 node = vat_json_array_add (&vam->json_tree);
5108 vat_json_init_object (node);
5109 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5110 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5113 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5114 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5115 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5116 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5117 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5118 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5119 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5120 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5121 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5122 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5125 * Generate boilerplate reply handlers, which
5126 * dig the return value out of the xxx_reply_t API message,
5127 * stick it into vam->retval, and set vam->result_ready
5129 * Could also do this by pointing N message decode slots at
5130 * a single function, but that could break in subtle ways.
5133 #define foreach_standard_reply_retval_handler \
5134 _(sw_interface_set_flags_reply) \
5135 _(sw_interface_add_del_address_reply) \
5136 _(sw_interface_set_rx_mode_reply) \
5137 _(sw_interface_set_rx_placement_reply) \
5138 _(sw_interface_set_table_reply) \
5139 _(sw_interface_set_mpls_enable_reply) \
5140 _(sw_interface_set_vpath_reply) \
5141 _(sw_interface_set_vxlan_bypass_reply) \
5142 _(sw_interface_set_geneve_bypass_reply) \
5143 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5144 _(sw_interface_set_l2_bridge_reply) \
5145 _(bridge_domain_add_del_reply) \
5146 _(sw_interface_set_l2_xconnect_reply) \
5147 _(l2fib_add_del_reply) \
5148 _(l2fib_flush_int_reply) \
5149 _(l2fib_flush_bd_reply) \
5150 _(ip_route_add_del_reply) \
5151 _(ip_table_add_del_reply) \
5152 _(ip_mroute_add_del_reply) \
5153 _(mpls_route_add_del_reply) \
5154 _(mpls_table_add_del_reply) \
5155 _(mpls_ip_bind_unbind_reply) \
5156 _(bier_route_add_del_reply) \
5157 _(bier_table_add_del_reply) \
5158 _(proxy_arp_add_del_reply) \
5159 _(proxy_arp_intfc_enable_disable_reply) \
5160 _(sw_interface_set_unnumbered_reply) \
5161 _(ip_neighbor_add_del_reply) \
5162 _(reset_fib_reply) \
5163 _(dhcp_proxy_config_reply) \
5164 _(dhcp_proxy_set_vss_reply) \
5165 _(dhcp_client_config_reply) \
5166 _(set_ip_flow_hash_reply) \
5167 _(sw_interface_ip6_enable_disable_reply) \
5168 _(ip6nd_proxy_add_del_reply) \
5169 _(sw_interface_ip6nd_ra_prefix_reply) \
5170 _(sw_interface_ip6nd_ra_config_reply) \
5171 _(set_arp_neighbor_limit_reply) \
5172 _(l2_patch_add_del_reply) \
5173 _(sr_mpls_policy_add_reply) \
5174 _(sr_mpls_policy_mod_reply) \
5175 _(sr_mpls_policy_del_reply) \
5176 _(sr_policy_add_reply) \
5177 _(sr_policy_mod_reply) \
5178 _(sr_policy_del_reply) \
5179 _(sr_localsid_add_del_reply) \
5180 _(sr_steering_add_del_reply) \
5181 _(classify_add_del_session_reply) \
5182 _(classify_set_interface_ip_table_reply) \
5183 _(classify_set_interface_l2_tables_reply) \
5184 _(l2tpv3_set_tunnel_cookies_reply) \
5185 _(l2tpv3_interface_enable_disable_reply) \
5186 _(l2tpv3_set_lookup_key_reply) \
5187 _(l2_fib_clear_table_reply) \
5188 _(l2_interface_efp_filter_reply) \
5189 _(l2_interface_vlan_tag_rewrite_reply) \
5190 _(modify_vhost_user_if_reply) \
5191 _(delete_vhost_user_if_reply) \
5192 _(ip_probe_neighbor_reply) \
5193 _(ip_scan_neighbor_enable_disable_reply) \
5194 _(want_ip4_arp_events_reply) \
5195 _(want_ip6_nd_events_reply) \
5196 _(want_l2_macs_events_reply) \
5197 _(input_acl_set_interface_reply) \
5198 _(ipsec_spd_add_del_reply) \
5199 _(ipsec_interface_add_del_spd_reply) \
5200 _(ipsec_spd_entry_add_del_reply) \
5201 _(ipsec_sad_entry_add_del_reply) \
5202 _(ipsec_tunnel_if_add_del_reply) \
5203 _(ipsec_tunnel_if_set_sa_reply) \
5204 _(delete_loopback_reply) \
5205 _(bd_ip_mac_add_del_reply) \
5206 _(bd_ip_mac_flush_reply) \
5207 _(want_interface_events_reply) \
5208 _(cop_interface_enable_disable_reply) \
5209 _(cop_whitelist_enable_disable_reply) \
5210 _(sw_interface_clear_stats_reply) \
5211 _(ioam_enable_reply) \
5212 _(ioam_disable_reply) \
5213 _(one_add_del_locator_reply) \
5214 _(one_add_del_local_eid_reply) \
5215 _(one_add_del_remote_mapping_reply) \
5216 _(one_add_del_adjacency_reply) \
5217 _(one_add_del_map_resolver_reply) \
5218 _(one_add_del_map_server_reply) \
5219 _(one_enable_disable_reply) \
5220 _(one_rloc_probe_enable_disable_reply) \
5221 _(one_map_register_enable_disable_reply) \
5222 _(one_map_register_set_ttl_reply) \
5223 _(one_set_transport_protocol_reply) \
5224 _(one_map_register_fallback_threshold_reply) \
5225 _(one_pitr_set_locator_set_reply) \
5226 _(one_map_request_mode_reply) \
5227 _(one_add_del_map_request_itr_rlocs_reply) \
5228 _(one_eid_table_add_del_map_reply) \
5229 _(one_use_petr_reply) \
5230 _(one_stats_enable_disable_reply) \
5231 _(one_add_del_l2_arp_entry_reply) \
5232 _(one_add_del_ndp_entry_reply) \
5233 _(one_stats_flush_reply) \
5234 _(one_enable_disable_xtr_mode_reply) \
5235 _(one_enable_disable_pitr_mode_reply) \
5236 _(one_enable_disable_petr_mode_reply) \
5237 _(gpe_enable_disable_reply) \
5238 _(gpe_set_encap_mode_reply) \
5239 _(gpe_add_del_iface_reply) \
5240 _(gpe_add_del_native_fwd_rpath_reply) \
5241 _(af_packet_delete_reply) \
5242 _(policer_classify_set_interface_reply) \
5243 _(netmap_create_reply) \
5244 _(netmap_delete_reply) \
5245 _(set_ipfix_exporter_reply) \
5246 _(set_ipfix_classify_stream_reply) \
5247 _(ipfix_classify_table_add_del_reply) \
5248 _(flow_classify_set_interface_reply) \
5249 _(sw_interface_span_enable_disable_reply) \
5250 _(pg_capture_reply) \
5251 _(pg_enable_disable_reply) \
5252 _(ip_source_and_port_range_check_add_del_reply) \
5253 _(ip_source_and_port_range_check_interface_add_del_reply)\
5254 _(delete_subif_reply) \
5255 _(l2_interface_pbb_tag_rewrite_reply) \
5257 _(feature_enable_disable_reply) \
5258 _(sw_interface_tag_add_del_reply) \
5259 _(hw_interface_set_mtu_reply) \
5260 _(p2p_ethernet_add_reply) \
5261 _(p2p_ethernet_del_reply) \
5262 _(lldp_config_reply) \
5263 _(sw_interface_set_lldp_reply) \
5264 _(tcp_configure_src_addresses_reply) \
5265 _(dns_enable_disable_reply) \
5266 _(dns_name_server_add_del_reply) \
5267 _(session_rule_add_del_reply) \
5268 _(ip_container_proxy_add_del_reply) \
5269 _(output_acl_set_interface_reply) \
5270 _(qos_record_enable_disable_reply)
5273 static void vl_api_##n##_t_handler \
5274 (vl_api_##n##_t * mp) \
5276 vat_main_t * vam = &vat_main; \
5277 i32 retval = ntohl(mp->retval); \
5278 if (vam->async_mode) { \
5279 vam->async_errors += (retval < 0); \
5281 vam->retval = retval; \
5282 vam->result_ready = 1; \
5285 foreach_standard_reply_retval_handler;
5289 static void vl_api_##n##_t_handler_json \
5290 (vl_api_##n##_t * mp) \
5292 vat_main_t * vam = &vat_main; \
5293 vat_json_node_t node; \
5294 vat_json_init_object(&node); \
5295 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5296 vat_json_print(vam->ofp, &node); \
5297 vam->retval = ntohl(mp->retval); \
5298 vam->result_ready = 1; \
5300 foreach_standard_reply_retval_handler;
5304 * Table of message reply handlers, must include boilerplate handlers
5308 #define foreach_vpe_api_reply_msg \
5309 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5310 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5311 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5312 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5313 _(CONTROL_PING_REPLY, control_ping_reply) \
5314 _(CLI_REPLY, cli_reply) \
5315 _(CLI_INBAND_REPLY, cli_inband_reply) \
5316 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5317 sw_interface_add_del_address_reply) \
5318 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5319 _(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
5320 _(SW_INTERFACE_RX_PLACEMENT_DETAILS, sw_interface_rx_placement_details) \
5321 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5322 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5323 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5324 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5325 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5326 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5327 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5328 sw_interface_set_l2_xconnect_reply) \
5329 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5330 sw_interface_set_l2_bridge_reply) \
5331 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5332 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5333 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5334 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5335 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5336 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5337 _(L2_FLAGS_REPLY, l2_flags_reply) \
5338 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5339 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5340 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5341 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5342 _(VIRTIO_PCI_CREATE_REPLY, virtio_pci_create_reply) \
5343 _(VIRTIO_PCI_DELETE_REPLY, virtio_pci_delete_reply) \
5344 _(SW_INTERFACE_VIRTIO_PCI_DETAILS, sw_interface_virtio_pci_details) \
5345 _(BOND_CREATE_REPLY, bond_create_reply) \
5346 _(BOND_DELETE_REPLY, bond_delete_reply) \
5347 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5348 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5349 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5350 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5351 _(IP_ROUTE_ADD_DEL_REPLY, ip_route_add_del_reply) \
5352 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5353 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5354 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5355 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5356 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5357 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5358 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5359 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5360 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5361 proxy_arp_intfc_enable_disable_reply) \
5362 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5363 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5364 sw_interface_set_unnumbered_reply) \
5365 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5366 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5367 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5368 _(RESET_FIB_REPLY, reset_fib_reply) \
5369 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5370 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5371 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5372 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5373 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5374 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5375 sw_interface_ip6_enable_disable_reply) \
5376 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5377 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5378 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5379 sw_interface_ip6nd_ra_prefix_reply) \
5380 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5381 sw_interface_ip6nd_ra_config_reply) \
5382 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5383 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5384 _(SR_MPLS_POLICY_ADD_REPLY, sr_mpls_policy_add_reply) \
5385 _(SR_MPLS_POLICY_MOD_REPLY, sr_mpls_policy_mod_reply) \
5386 _(SR_MPLS_POLICY_DEL_REPLY, sr_mpls_policy_del_reply) \
5387 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5388 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5389 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5390 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5391 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5392 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5393 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5394 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5395 classify_set_interface_ip_table_reply) \
5396 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5397 classify_set_interface_l2_tables_reply) \
5398 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5399 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5400 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5401 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5402 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5403 l2tpv3_interface_enable_disable_reply) \
5404 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5405 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5406 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5407 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5408 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5409 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5410 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5411 _(GRE_TUNNEL_ADD_DEL_REPLY, gre_tunnel_add_del_reply) \
5412 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5413 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5414 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5415 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5416 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5417 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5418 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5419 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5420 _(SHOW_VERSION_REPLY, show_version_reply) \
5421 _(SHOW_THREADS_REPLY, show_threads_reply) \
5422 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5423 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5424 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5425 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5426 _(IP_PROBE_NEIGHBOR_REPLY, ip_probe_neighbor_reply) \
5427 _(IP_SCAN_NEIGHBOR_ENABLE_DISABLE_REPLY, ip_scan_neighbor_enable_disable_reply) \
5428 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5429 _(IP4_ARP_EVENT, ip4_arp_event) \
5430 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5431 _(IP6_ND_EVENT, ip6_nd_event) \
5432 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5433 _(L2_MACS_EVENT, l2_macs_event) \
5434 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5435 _(IP_ADDRESS_DETAILS, ip_address_details) \
5436 _(IP_DETAILS, ip_details) \
5437 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5438 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5439 _(IPSEC_SPD_ENTRY_ADD_DEL_REPLY, ipsec_spd_entry_add_del_reply) \
5440 _(IPSEC_SAD_ENTRY_ADD_DEL_REPLY, ipsec_sad_entry_add_del_reply) \
5441 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5442 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5443 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5444 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5445 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5446 _(BD_IP_MAC_FLUSH_REPLY, bd_ip_mac_flush_reply) \
5447 _(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
5448 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5449 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5450 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5451 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5452 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5453 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5454 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5455 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5456 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5457 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5458 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5459 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5460 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5461 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5462 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5463 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5464 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5465 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5466 one_map_register_enable_disable_reply) \
5467 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5468 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5469 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5470 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5471 one_map_register_fallback_threshold_reply) \
5472 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5473 one_rloc_probe_enable_disable_reply) \
5474 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5475 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5476 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5477 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5478 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5479 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5480 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5481 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5482 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5483 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5484 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5485 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5486 _(ONE_STATS_DETAILS, one_stats_details) \
5487 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5488 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5489 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5490 show_one_stats_enable_disable_reply) \
5491 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5492 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5493 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5494 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5495 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5496 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5497 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5498 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5499 one_enable_disable_pitr_mode_reply) \
5500 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5501 one_enable_disable_petr_mode_reply) \
5502 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5503 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5504 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5505 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5506 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5507 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5508 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5509 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5510 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5511 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5512 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5513 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5514 gpe_add_del_native_fwd_rpath_reply) \
5515 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5516 gpe_fwd_entry_path_details) \
5517 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5518 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5519 one_add_del_map_request_itr_rlocs_reply) \
5520 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5521 one_get_map_request_itr_rlocs_reply) \
5522 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5523 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5524 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5525 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5526 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5527 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5528 show_one_map_register_state_reply) \
5529 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5530 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5531 show_one_map_register_fallback_threshold_reply) \
5532 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5533 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5534 _(AF_PACKET_DETAILS, af_packet_details) \
5535 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5536 _(POLICER_DETAILS, policer_details) \
5537 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5538 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5539 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5540 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5541 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5542 _(MPLS_TABLE_DETAILS, mpls_table_details) \
5543 _(MPLS_ROUTE_DETAILS, mpls_route_details) \
5544 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5545 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5546 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5547 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5548 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5549 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5550 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5551 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5552 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5553 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5554 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5555 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5556 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5557 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5558 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5559 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5560 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5561 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5562 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5563 ip_source_and_port_range_check_add_del_reply) \
5564 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5565 ip_source_and_port_range_check_interface_add_del_reply) \
5566 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5567 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5568 _(SET_PUNT_REPLY, set_punt_reply) \
5569 _(IP_TABLE_DETAILS, ip_table_details) \
5570 _(IP_ROUTE_DETAILS, ip_route_details) \
5571 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5572 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5573 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5574 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5575 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5576 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5577 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5578 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5579 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5580 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5581 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5582 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5583 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5584 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5585 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
5586 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \
5587 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5588 _(SESSION_RULES_DETAILS, session_rules_details) \
5589 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5590 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5591 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply)
5593 #define foreach_standalone_reply_msg \
5594 _(SW_INTERFACE_EVENT, sw_interface_event)
5602 #define STR_VTR_OP_CASE(op) \
5603 case L2_VTR_ ## op: \
5607 str_vtr_op (u32 vtr_op)
5611 STR_VTR_OP_CASE (DISABLED);
5612 STR_VTR_OP_CASE (PUSH_1);
5613 STR_VTR_OP_CASE (PUSH_2);
5614 STR_VTR_OP_CASE (POP_1);
5615 STR_VTR_OP_CASE (POP_2);
5616 STR_VTR_OP_CASE (TRANSLATE_1_1);
5617 STR_VTR_OP_CASE (TRANSLATE_1_2);
5618 STR_VTR_OP_CASE (TRANSLATE_2_1);
5619 STR_VTR_OP_CASE (TRANSLATE_2_2);
5626 dump_sub_interface_table (vat_main_t * vam)
5628 const sw_interface_subif_t *sub = NULL;
5630 if (vam->json_output)
5633 ("JSON output supported only for VPE API calls and dump_stats_table");
5638 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5639 "Interface", "sw_if_index",
5640 "sub id", "dot1ad", "tags", "outer id",
5641 "inner id", "exact", "default", "outer any", "inner any");
5643 vec_foreach (sub, vam->sw_if_subif_table)
5646 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5647 sub->interface_name,
5649 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5650 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5651 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5652 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5653 if (sub->vtr_op != L2_VTR_DISABLED)
5656 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5657 "tag1: %d tag2: %d ]",
5658 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5659 sub->vtr_tag1, sub->vtr_tag2);
5667 name_sort_cmp (void *a1, void *a2)
5669 name_sort_t *n1 = a1;
5670 name_sort_t *n2 = a2;
5672 return strcmp ((char *) n1->name, (char *) n2->name);
5676 dump_interface_table (vat_main_t * vam)
5679 name_sort_t *nses = 0, *ns;
5681 if (vam->json_output)
5684 ("JSON output supported only for VPE API calls and dump_stats_table");
5689 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5691 vec_add2 (nses, ns, 1);
5692 ns->name = (u8 *)(p->key);
5693 ns->value = (u32) p->value[0];
5697 vec_sort_with_function (nses, name_sort_cmp);
5699 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5700 vec_foreach (ns, nses)
5702 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5709 dump_ip_table (vat_main_t * vam, int is_ipv6)
5711 const ip_details_t *det = NULL;
5712 const ip_address_details_t *address = NULL;
5715 print (vam->ofp, "%-12s", "sw_if_index");
5717 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5724 print (vam->ofp, "%-12d", i);
5725 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5730 vec_foreach (address, det->addr)
5734 is_ipv6 ? format_ip6_address : format_ip4_address,
5735 address->ip, address->prefix_length);
5743 dump_ipv4_table (vat_main_t * vam)
5745 if (vam->json_output)
5748 ("JSON output supported only for VPE API calls and dump_stats_table");
5752 return dump_ip_table (vam, 0);
5756 dump_ipv6_table (vat_main_t * vam)
5758 if (vam->json_output)
5761 ("JSON output supported only for VPE API calls and dump_stats_table");
5765 return dump_ip_table (vam, 1);
5769 * Pass CLI buffers directly in the CLI_INBAND API message,
5770 * instead of an additional shared memory area.
5773 exec_inband (vat_main_t * vam)
5775 vl_api_cli_inband_t *mp;
5776 unformat_input_t *i = vam->input;
5779 if (vec_len (i->buffer) == 0)
5782 if (vam->exec_mode == 0 && unformat (i, "mode"))
5787 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5794 * In order for the CLI command to work, it
5795 * must be a vector ending in \n, not a C-string ending
5798 u32 len = vec_len (vam->input->buffer);
5799 M2 (CLI_INBAND, mp, len);
5800 vl_api_to_api_string (len - 1, (const char *) vam->input->buffer, &mp->cmd);
5804 /* json responses may or may not include a useful reply... */
5805 if (vec_len (vam->cmd_reply))
5806 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
5811 exec (vat_main_t * vam)
5813 return exec_inband (vam);
5817 api_create_loopback (vat_main_t * vam)
5819 unformat_input_t *i = vam->input;
5820 vl_api_create_loopback_t *mp;
5821 vl_api_create_loopback_instance_t *mp_lbi;
5824 u8 is_specified = 0;
5825 u32 user_instance = 0;
5828 clib_memset (mac_address, 0, sizeof (mac_address));
5830 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5832 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5834 if (unformat (i, "instance %d", &user_instance))
5842 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5843 mp_lbi->is_specified = is_specified;
5845 mp_lbi->user_instance = htonl (user_instance);
5847 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5852 /* Construct the API message */
5853 M (CREATE_LOOPBACK, mp);
5855 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5864 api_delete_loopback (vat_main_t * vam)
5866 unformat_input_t *i = vam->input;
5867 vl_api_delete_loopback_t *mp;
5868 u32 sw_if_index = ~0;
5871 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5873 if (unformat (i, "sw_if_index %d", &sw_if_index))
5879 if (sw_if_index == ~0)
5881 errmsg ("missing sw_if_index");
5885 /* Construct the API message */
5886 M (DELETE_LOOPBACK, mp);
5887 mp->sw_if_index = ntohl (sw_if_index);
5895 api_want_interface_events (vat_main_t * vam)
5897 unformat_input_t *i = vam->input;
5898 vl_api_want_interface_events_t *mp;
5902 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5904 if (unformat (i, "enable"))
5906 else if (unformat (i, "disable"))
5914 errmsg ("missing enable|disable");
5918 M (WANT_INTERFACE_EVENTS, mp);
5919 mp->enable_disable = enable;
5921 vam->interface_event_display = enable;
5929 /* Note: non-static, called once to set up the initial intfc table */
5931 api_sw_interface_dump (vat_main_t * vam)
5933 vl_api_sw_interface_dump_t *mp;
5934 vl_api_control_ping_t *mp_ping;
5936 name_sort_t *nses = 0, *ns;
5937 sw_interface_subif_t *sub = NULL;
5940 /* Toss the old name table */
5942 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5944 vec_add2 (nses, ns, 1);
5945 ns->name = (u8 *)(p->key);
5946 ns->value = (u32) p->value[0];
5950 hash_free (vam->sw_if_index_by_interface_name);
5952 vec_foreach (ns, nses) vec_free (ns->name);
5956 vec_foreach (sub, vam->sw_if_subif_table)
5958 vec_free (sub->interface_name);
5960 vec_free (vam->sw_if_subif_table);
5962 /* recreate the interface name hash table */
5963 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5966 * Ask for all interface names. Otherwise, the epic catalog of
5967 * name filters becomes ridiculously long, and vat ends up needing
5968 * to be taught about new interface types.
5970 M (SW_INTERFACE_DUMP, mp);
5973 /* Use a control ping for synchronization */
5974 MPING (CONTROL_PING, mp_ping);
5982 api_sw_interface_set_flags (vat_main_t * vam)
5984 unformat_input_t *i = vam->input;
5985 vl_api_sw_interface_set_flags_t *mp;
5987 u8 sw_if_index_set = 0;
5991 /* Parse args required to build the message */
5992 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5994 if (unformat (i, "admin-up"))
5996 else if (unformat (i, "admin-down"))
5999 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6000 sw_if_index_set = 1;
6001 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6002 sw_if_index_set = 1;
6007 if (sw_if_index_set == 0)
6009 errmsg ("missing interface name or sw_if_index");
6013 /* Construct the API message */
6014 M (SW_INTERFACE_SET_FLAGS, mp);
6015 mp->sw_if_index = ntohl (sw_if_index);
6016 mp->admin_up_down = admin_up;
6021 /* Wait for a reply, return the good/bad news... */
6027 api_sw_interface_set_rx_mode (vat_main_t * vam)
6029 unformat_input_t *i = vam->input;
6030 vl_api_sw_interface_set_rx_mode_t *mp;
6032 u8 sw_if_index_set = 0;
6034 u8 queue_id_valid = 0;
6036 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
6038 /* Parse args required to build the message */
6039 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6041 if (unformat (i, "queue %d", &queue_id))
6043 else if (unformat (i, "polling"))
6044 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
6045 else if (unformat (i, "interrupt"))
6046 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
6047 else if (unformat (i, "adaptive"))
6048 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
6050 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6051 sw_if_index_set = 1;
6052 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6053 sw_if_index_set = 1;
6058 if (sw_if_index_set == 0)
6060 errmsg ("missing interface name or sw_if_index");
6063 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6065 errmsg ("missing rx-mode");
6069 /* Construct the API message */
6070 M (SW_INTERFACE_SET_RX_MODE, mp);
6071 mp->sw_if_index = ntohl (sw_if_index);
6073 mp->queue_id_valid = queue_id_valid;
6074 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6079 /* Wait for a reply, return the good/bad news... */
6085 api_sw_interface_set_rx_placement (vat_main_t * vam)
6087 unformat_input_t *i = vam->input;
6088 vl_api_sw_interface_set_rx_placement_t *mp;
6090 u8 sw_if_index_set = 0;
6093 u32 queue_id, thread_index;
6095 /* Parse args required to build the message */
6096 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6098 if (unformat (i, "queue %d", &queue_id))
6100 else if (unformat (i, "main"))
6102 else if (unformat (i, "worker %d", &thread_index))
6105 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6106 sw_if_index_set = 1;
6107 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6108 sw_if_index_set = 1;
6113 if (sw_if_index_set == 0)
6115 errmsg ("missing interface name or sw_if_index");
6121 /* Construct the API message */
6122 M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
6123 mp->sw_if_index = ntohl (sw_if_index);
6124 mp->worker_id = ntohl (thread_index);
6125 mp->queue_id = ntohl (queue_id);
6126 mp->is_main = is_main;
6130 /* Wait for a reply, return the good/bad news... */
6135 static void vl_api_sw_interface_rx_placement_details_t_handler
6136 (vl_api_sw_interface_rx_placement_details_t * mp)
6138 vat_main_t *vam = &vat_main;
6139 u32 worker_id = ntohl (mp->worker_id);
6142 "\n%-11d %-11s %-6d %-5d %-9s",
6143 ntohl (mp->sw_if_index), (worker_id == 0) ? "main" : "worker",
6144 worker_id, ntohl (mp->queue_id),
6146 1) ? "polling" : ((mp->mode == 2) ? "interrupt" : "adaptive"));
6149 static void vl_api_sw_interface_rx_placement_details_t_handler_json
6150 (vl_api_sw_interface_rx_placement_details_t * mp)
6152 vat_main_t *vam = &vat_main;
6153 vat_json_node_t *node = NULL;
6155 if (VAT_JSON_ARRAY != vam->json_tree.type)
6157 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
6158 vat_json_init_array (&vam->json_tree);
6160 node = vat_json_array_add (&vam->json_tree);
6162 vat_json_init_object (node);
6163 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
6164 vat_json_object_add_uint (node, "worker_id", ntohl (mp->worker_id));
6165 vat_json_object_add_uint (node, "queue_id", ntohl (mp->queue_id));
6166 vat_json_object_add_uint (node, "mode", mp->mode);
6170 api_sw_interface_rx_placement_dump (vat_main_t * vam)
6172 unformat_input_t *i = vam->input;
6173 vl_api_sw_interface_rx_placement_dump_t *mp;
6174 vl_api_control_ping_t *mp_ping;
6177 u8 sw_if_index_set = 0;
6179 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6181 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6183 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6190 "\n%-11s %-11s %-6s %-5s %-4s",
6191 "sw_if_index", "main/worker", "thread", "queue", "mode");
6193 /* Dump Interface rx placement */
6194 M (SW_INTERFACE_RX_PLACEMENT_DUMP, mp);
6196 if (sw_if_index_set)
6197 mp->sw_if_index = htonl (sw_if_index);
6199 mp->sw_if_index = ~0;
6203 /* Use a control ping for synchronization */
6204 MPING (CONTROL_PING, mp_ping);
6212 api_sw_interface_clear_stats (vat_main_t * vam)
6214 unformat_input_t *i = vam->input;
6215 vl_api_sw_interface_clear_stats_t *mp;
6217 u8 sw_if_index_set = 0;
6220 /* Parse args required to build the message */
6221 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6223 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6224 sw_if_index_set = 1;
6225 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6226 sw_if_index_set = 1;
6231 /* Construct the API message */
6232 M (SW_INTERFACE_CLEAR_STATS, mp);
6234 if (sw_if_index_set == 1)
6235 mp->sw_if_index = ntohl (sw_if_index);
6237 mp->sw_if_index = ~0;
6242 /* Wait for a reply, return the good/bad news... */
6248 api_sw_interface_add_del_address (vat_main_t * vam)
6250 unformat_input_t *i = vam->input;
6251 vl_api_sw_interface_add_del_address_t *mp;
6253 u8 sw_if_index_set = 0;
6254 u8 is_add = 1, del_all = 0;
6255 u32 address_length = 0;
6256 u8 v4_address_set = 0;
6257 u8 v6_address_set = 0;
6258 ip4_address_t v4address;
6259 ip6_address_t v6address;
6262 /* Parse args required to build the message */
6263 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6265 if (unformat (i, "del-all"))
6267 else if (unformat (i, "del"))
6270 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6271 sw_if_index_set = 1;
6272 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6273 sw_if_index_set = 1;
6274 else if (unformat (i, "%U/%d",
6275 unformat_ip4_address, &v4address, &address_length))
6277 else if (unformat (i, "%U/%d",
6278 unformat_ip6_address, &v6address, &address_length))
6284 if (sw_if_index_set == 0)
6286 errmsg ("missing interface name or sw_if_index");
6289 if (v4_address_set && v6_address_set)
6291 errmsg ("both v4 and v6 addresses set");
6294 if (!v4_address_set && !v6_address_set && !del_all)
6296 errmsg ("no addresses set");
6300 /* Construct the API message */
6301 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6303 mp->sw_if_index = ntohl (sw_if_index);
6304 mp->is_add = is_add;
6305 mp->del_all = del_all;
6309 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6313 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6315 mp->address_length = address_length;
6320 /* Wait for a reply, return good/bad news */
6326 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6328 unformat_input_t *i = vam->input;
6329 vl_api_sw_interface_set_mpls_enable_t *mp;
6331 u8 sw_if_index_set = 0;
6335 /* Parse args required to build the message */
6336 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6338 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6339 sw_if_index_set = 1;
6340 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6341 sw_if_index_set = 1;
6342 else if (unformat (i, "disable"))
6344 else if (unformat (i, "dis"))
6350 if (sw_if_index_set == 0)
6352 errmsg ("missing interface name or sw_if_index");
6356 /* Construct the API message */
6357 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6359 mp->sw_if_index = ntohl (sw_if_index);
6360 mp->enable = enable;
6365 /* Wait for a reply... */
6371 api_sw_interface_set_table (vat_main_t * vam)
6373 unformat_input_t *i = vam->input;
6374 vl_api_sw_interface_set_table_t *mp;
6375 u32 sw_if_index, vrf_id = 0;
6376 u8 sw_if_index_set = 0;
6380 /* Parse args required to build the message */
6381 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6383 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6384 sw_if_index_set = 1;
6385 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6386 sw_if_index_set = 1;
6387 else if (unformat (i, "vrf %d", &vrf_id))
6389 else if (unformat (i, "ipv6"))
6395 if (sw_if_index_set == 0)
6397 errmsg ("missing interface name or sw_if_index");
6401 /* Construct the API message */
6402 M (SW_INTERFACE_SET_TABLE, mp);
6404 mp->sw_if_index = ntohl (sw_if_index);
6405 mp->is_ipv6 = is_ipv6;
6406 mp->vrf_id = ntohl (vrf_id);
6411 /* Wait for a reply... */
6416 static void vl_api_sw_interface_get_table_reply_t_handler
6417 (vl_api_sw_interface_get_table_reply_t * mp)
6419 vat_main_t *vam = &vat_main;
6421 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6423 vam->retval = ntohl (mp->retval);
6424 vam->result_ready = 1;
6428 static void vl_api_sw_interface_get_table_reply_t_handler_json
6429 (vl_api_sw_interface_get_table_reply_t * mp)
6431 vat_main_t *vam = &vat_main;
6432 vat_json_node_t node;
6434 vat_json_init_object (&node);
6435 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6436 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6438 vat_json_print (vam->ofp, &node);
6439 vat_json_free (&node);
6441 vam->retval = ntohl (mp->retval);
6442 vam->result_ready = 1;
6446 api_sw_interface_get_table (vat_main_t * vam)
6448 unformat_input_t *i = vam->input;
6449 vl_api_sw_interface_get_table_t *mp;
6451 u8 sw_if_index_set = 0;
6455 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6457 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6458 sw_if_index_set = 1;
6459 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6460 sw_if_index_set = 1;
6461 else if (unformat (i, "ipv6"))
6467 if (sw_if_index_set == 0)
6469 errmsg ("missing interface name or sw_if_index");
6473 M (SW_INTERFACE_GET_TABLE, mp);
6474 mp->sw_if_index = htonl (sw_if_index);
6475 mp->is_ipv6 = is_ipv6;
6483 api_sw_interface_set_vpath (vat_main_t * vam)
6485 unformat_input_t *i = vam->input;
6486 vl_api_sw_interface_set_vpath_t *mp;
6487 u32 sw_if_index = 0;
6488 u8 sw_if_index_set = 0;
6492 /* Parse args required to build the message */
6493 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6495 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6496 sw_if_index_set = 1;
6497 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6498 sw_if_index_set = 1;
6499 else if (unformat (i, "enable"))
6501 else if (unformat (i, "disable"))
6507 if (sw_if_index_set == 0)
6509 errmsg ("missing interface name or sw_if_index");
6513 /* Construct the API message */
6514 M (SW_INTERFACE_SET_VPATH, mp);
6516 mp->sw_if_index = ntohl (sw_if_index);
6517 mp->enable = is_enable;
6522 /* Wait for a reply... */
6528 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6530 unformat_input_t *i = vam->input;
6531 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6532 u32 sw_if_index = 0;
6533 u8 sw_if_index_set = 0;
6538 /* Parse args required to build the message */
6539 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6541 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6542 sw_if_index_set = 1;
6543 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6544 sw_if_index_set = 1;
6545 else if (unformat (i, "enable"))
6547 else if (unformat (i, "disable"))
6549 else if (unformat (i, "ip4"))
6551 else if (unformat (i, "ip6"))
6557 if (sw_if_index_set == 0)
6559 errmsg ("missing interface name or sw_if_index");
6563 /* Construct the API message */
6564 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6566 mp->sw_if_index = ntohl (sw_if_index);
6567 mp->enable = is_enable;
6568 mp->is_ipv6 = is_ipv6;
6573 /* Wait for a reply... */
6579 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6581 unformat_input_t *i = vam->input;
6582 vl_api_sw_interface_set_geneve_bypass_t *mp;
6583 u32 sw_if_index = 0;
6584 u8 sw_if_index_set = 0;
6589 /* Parse args required to build the message */
6590 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6592 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6593 sw_if_index_set = 1;
6594 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6595 sw_if_index_set = 1;
6596 else if (unformat (i, "enable"))
6598 else if (unformat (i, "disable"))
6600 else if (unformat (i, "ip4"))
6602 else if (unformat (i, "ip6"))
6608 if (sw_if_index_set == 0)
6610 errmsg ("missing interface name or sw_if_index");
6614 /* Construct the API message */
6615 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6617 mp->sw_if_index = ntohl (sw_if_index);
6618 mp->enable = is_enable;
6619 mp->is_ipv6 = is_ipv6;
6624 /* Wait for a reply... */
6630 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6632 unformat_input_t *i = vam->input;
6633 vl_api_sw_interface_set_l2_xconnect_t *mp;
6635 u8 rx_sw_if_index_set = 0;
6637 u8 tx_sw_if_index_set = 0;
6641 /* Parse args required to build the message */
6642 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6644 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6645 rx_sw_if_index_set = 1;
6646 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6647 tx_sw_if_index_set = 1;
6648 else if (unformat (i, "rx"))
6650 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6652 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6654 rx_sw_if_index_set = 1;
6659 else if (unformat (i, "tx"))
6661 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6663 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6665 tx_sw_if_index_set = 1;
6670 else if (unformat (i, "enable"))
6672 else if (unformat (i, "disable"))
6678 if (rx_sw_if_index_set == 0)
6680 errmsg ("missing rx interface name or rx_sw_if_index");
6684 if (enable && (tx_sw_if_index_set == 0))
6686 errmsg ("missing tx interface name or tx_sw_if_index");
6690 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6692 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6693 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6694 mp->enable = enable;
6702 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6704 unformat_input_t *i = vam->input;
6705 vl_api_sw_interface_set_l2_bridge_t *mp;
6706 vl_api_l2_port_type_t port_type;
6708 u8 rx_sw_if_index_set = 0;
6715 port_type = L2_API_PORT_TYPE_NORMAL;
6717 /* Parse args required to build the message */
6718 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6720 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6721 rx_sw_if_index_set = 1;
6722 else if (unformat (i, "bd_id %d", &bd_id))
6726 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6727 rx_sw_if_index_set = 1;
6728 else if (unformat (i, "shg %d", &shg))
6730 else if (unformat (i, "bvi"))
6731 port_type = L2_API_PORT_TYPE_BVI;
6732 else if (unformat (i, "uu-fwd"))
6733 port_type = L2_API_PORT_TYPE_UU_FWD;
6734 else if (unformat (i, "enable"))
6736 else if (unformat (i, "disable"))
6742 if (rx_sw_if_index_set == 0)
6744 errmsg ("missing rx interface name or sw_if_index");
6748 if (enable && (bd_id_set == 0))
6750 errmsg ("missing bridge domain");
6754 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6756 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6757 mp->bd_id = ntohl (bd_id);
6759 mp->port_type = ntohl (port_type);
6760 mp->enable = enable;
6768 api_bridge_domain_dump (vat_main_t * vam)
6770 unformat_input_t *i = vam->input;
6771 vl_api_bridge_domain_dump_t *mp;
6772 vl_api_control_ping_t *mp_ping;
6776 /* Parse args required to build the message */
6777 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6779 if (unformat (i, "bd_id %d", &bd_id))
6785 M (BRIDGE_DOMAIN_DUMP, mp);
6786 mp->bd_id = ntohl (bd_id);
6789 /* Use a control ping for synchronization */
6790 MPING (CONTROL_PING, mp_ping);
6798 api_bridge_domain_add_del (vat_main_t * vam)
6800 unformat_input_t *i = vam->input;
6801 vl_api_bridge_domain_add_del_t *mp;
6804 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6809 /* Parse args required to build the message */
6810 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6812 if (unformat (i, "bd_id %d", &bd_id))
6814 else if (unformat (i, "flood %d", &flood))
6816 else if (unformat (i, "uu-flood %d", &uu_flood))
6818 else if (unformat (i, "forward %d", &forward))
6820 else if (unformat (i, "learn %d", &learn))
6822 else if (unformat (i, "arp-term %d", &arp_term))
6824 else if (unformat (i, "mac-age %d", &mac_age))
6826 else if (unformat (i, "bd-tag %s", &bd_tag))
6828 else if (unformat (i, "del"))
6831 flood = uu_flood = forward = learn = 0;
6839 errmsg ("missing bridge domain");
6846 errmsg ("mac age must be less than 256 ");
6851 if ((bd_tag) && (vec_len (bd_tag) > 63))
6853 errmsg ("bd-tag cannot be longer than 63");
6858 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6860 mp->bd_id = ntohl (bd_id);
6862 mp->uu_flood = uu_flood;
6863 mp->forward = forward;
6865 mp->arp_term = arp_term;
6866 mp->is_add = is_add;
6867 mp->mac_age = (u8) mac_age;
6870 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
6871 mp->bd_tag[vec_len (bd_tag)] = 0;
6882 api_l2fib_flush_bd (vat_main_t * vam)
6884 unformat_input_t *i = vam->input;
6885 vl_api_l2fib_flush_bd_t *mp;
6889 /* Parse args required to build the message */
6890 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6892 if (unformat (i, "bd_id %d", &bd_id));
6899 errmsg ("missing bridge domain");
6903 M (L2FIB_FLUSH_BD, mp);
6905 mp->bd_id = htonl (bd_id);
6913 api_l2fib_flush_int (vat_main_t * vam)
6915 unformat_input_t *i = vam->input;
6916 vl_api_l2fib_flush_int_t *mp;
6917 u32 sw_if_index = ~0;
6920 /* Parse args required to build the message */
6921 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6923 if (unformat (i, "sw_if_index %d", &sw_if_index));
6925 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6930 if (sw_if_index == ~0)
6932 errmsg ("missing interface name or sw_if_index");
6936 M (L2FIB_FLUSH_INT, mp);
6938 mp->sw_if_index = ntohl (sw_if_index);
6946 api_l2fib_add_del (vat_main_t * vam)
6948 unformat_input_t *i = vam->input;
6949 vl_api_l2fib_add_del_t *mp;
6955 u32 sw_if_index = 0;
6956 u8 sw_if_index_set = 0;
6965 /* Parse args required to build the message */
6966 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6968 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
6970 else if (unformat (i, "bd_id %d", &bd_id))
6972 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6973 sw_if_index_set = 1;
6974 else if (unformat (i, "sw_if"))
6976 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6979 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6980 sw_if_index_set = 1;
6985 else if (unformat (i, "static"))
6987 else if (unformat (i, "filter"))
6992 else if (unformat (i, "bvi"))
6997 else if (unformat (i, "del"))
6999 else if (unformat (i, "count %d", &count))
7007 errmsg ("missing mac address");
7013 errmsg ("missing bridge domain");
7017 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7019 errmsg ("missing interface name or sw_if_index");
7025 /* Turn on async mode */
7026 vam->async_mode = 1;
7027 vam->async_errors = 0;
7028 before = vat_time_now (vam);
7031 for (j = 0; j < count; j++)
7033 M (L2FIB_ADD_DEL, mp);
7035 clib_memcpy (mp->mac, mac, 6);
7036 mp->bd_id = ntohl (bd_id);
7037 mp->is_add = is_add;
7038 mp->sw_if_index = ntohl (sw_if_index);
7042 mp->static_mac = static_mac;
7043 mp->filter_mac = filter_mac;
7044 mp->bvi_mac = bvi_mac;
7046 increment_mac_address (mac);
7053 vl_api_control_ping_t *mp_ping;
7056 /* Shut off async mode */
7057 vam->async_mode = 0;
7059 MPING (CONTROL_PING, mp_ping);
7062 timeout = vat_time_now (vam) + 1.0;
7063 while (vat_time_now (vam) < timeout)
7064 if (vam->result_ready == 1)
7069 if (vam->retval == -99)
7072 if (vam->async_errors > 0)
7074 errmsg ("%d asynchronous errors", vam->async_errors);
7077 vam->async_errors = 0;
7078 after = vat_time_now (vam);
7080 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7081 count, after - before, count / (after - before));
7087 /* Wait for a reply... */
7091 /* Return the good/bad news */
7092 return (vam->retval);
7096 api_bridge_domain_set_mac_age (vat_main_t * vam)
7098 unformat_input_t *i = vam->input;
7099 vl_api_bridge_domain_set_mac_age_t *mp;
7104 /* Parse args required to build the message */
7105 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7107 if (unformat (i, "bd_id %d", &bd_id));
7108 else if (unformat (i, "mac-age %d", &mac_age));
7115 errmsg ("missing bridge domain");
7121 errmsg ("mac age must be less than 256 ");
7125 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7127 mp->bd_id = htonl (bd_id);
7128 mp->mac_age = (u8) mac_age;
7136 api_l2_flags (vat_main_t * vam)
7138 unformat_input_t *i = vam->input;
7139 vl_api_l2_flags_t *mp;
7142 u8 sw_if_index_set = 0;
7146 /* Parse args required to build the message */
7147 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7149 if (unformat (i, "sw_if_index %d", &sw_if_index))
7150 sw_if_index_set = 1;
7151 else if (unformat (i, "sw_if"))
7153 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7156 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7157 sw_if_index_set = 1;
7162 else if (unformat (i, "learn"))
7164 else if (unformat (i, "forward"))
7166 else if (unformat (i, "flood"))
7168 else if (unformat (i, "uu-flood"))
7169 flags |= L2_UU_FLOOD;
7170 else if (unformat (i, "arp-term"))
7171 flags |= L2_ARP_TERM;
7172 else if (unformat (i, "off"))
7174 else if (unformat (i, "disable"))
7180 if (sw_if_index_set == 0)
7182 errmsg ("missing interface name or sw_if_index");
7188 mp->sw_if_index = ntohl (sw_if_index);
7189 mp->feature_bitmap = ntohl (flags);
7190 mp->is_set = is_set;
7198 api_bridge_flags (vat_main_t * vam)
7200 unformat_input_t *i = vam->input;
7201 vl_api_bridge_flags_t *mp;
7205 bd_flags_t flags = 0;
7208 /* Parse args required to build the message */
7209 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7211 if (unformat (i, "bd_id %d", &bd_id))
7213 else if (unformat (i, "learn"))
7214 flags |= BRIDGE_API_FLAG_LEARN;
7215 else if (unformat (i, "forward"))
7216 flags |= BRIDGE_API_FLAG_FWD;
7217 else if (unformat (i, "flood"))
7218 flags |= BRIDGE_API_FLAG_FLOOD;
7219 else if (unformat (i, "uu-flood"))
7220 flags |= BRIDGE_API_FLAG_UU_FLOOD;
7221 else if (unformat (i, "arp-term"))
7222 flags |= BRIDGE_API_FLAG_ARP_TERM;
7223 else if (unformat (i, "off"))
7225 else if (unformat (i, "disable"))
7233 errmsg ("missing bridge domain");
7237 M (BRIDGE_FLAGS, mp);
7239 mp->bd_id = ntohl (bd_id);
7240 mp->flags = ntohl (flags);
7241 mp->is_set = is_set;
7249 api_bd_ip_mac_add_del (vat_main_t * vam)
7251 vl_api_address_t ip = VL_API_ZERO_ADDRESS;
7252 vl_api_mac_address_t mac = { 0 };
7253 unformat_input_t *i = vam->input;
7254 vl_api_bd_ip_mac_add_del_t *mp;
7263 /* Parse args required to build the message */
7264 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7266 if (unformat (i, "bd_id %d", &bd_id))
7270 else if (unformat (i, "%U", unformat_vl_api_address, &ip))
7274 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
7278 else if (unformat (i, "del"))
7286 errmsg ("missing bridge domain");
7289 else if (ip_set == 0)
7291 errmsg ("missing IP address");
7294 else if (mac_set == 0)
7296 errmsg ("missing MAC address");
7300 M (BD_IP_MAC_ADD_DEL, mp);
7302 mp->entry.bd_id = ntohl (bd_id);
7303 mp->is_add = is_add;
7305 clib_memcpy (&mp->entry.ip, &ip, sizeof (ip));
7306 clib_memcpy (&mp->entry.mac, &mac, sizeof (mac));
7314 api_bd_ip_mac_flush (vat_main_t * vam)
7316 unformat_input_t *i = vam->input;
7317 vl_api_bd_ip_mac_flush_t *mp;
7322 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7324 if (unformat (i, "bd_id %d", &bd_id))
7334 errmsg ("missing bridge domain");
7338 M (BD_IP_MAC_FLUSH, mp);
7340 mp->bd_id = ntohl (bd_id);
7347 static void vl_api_bd_ip_mac_details_t_handler
7348 (vl_api_bd_ip_mac_details_t * mp)
7350 vat_main_t *vam = &vat_main;
7354 ntohl (mp->entry.bd_id),
7355 format_vl_api_mac_address, mp->entry.mac,
7356 format_vl_api_address, &mp->entry.ip);
7359 static void vl_api_bd_ip_mac_details_t_handler_json
7360 (vl_api_bd_ip_mac_details_t * mp)
7362 vat_main_t *vam = &vat_main;
7363 vat_json_node_t *node = NULL;
7365 if (VAT_JSON_ARRAY != vam->json_tree.type)
7367 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7368 vat_json_init_array (&vam->json_tree);
7370 node = vat_json_array_add (&vam->json_tree);
7372 vat_json_init_object (node);
7373 vat_json_object_add_uint (node, "bd_id", ntohl (mp->entry.bd_id));
7374 vat_json_object_add_string_copy (node, "mac_address",
7375 format (0, "%U", format_vl_api_mac_address,
7379 ip = format (0, "%U", format_vl_api_address, &mp->entry.ip);
7380 vat_json_object_add_string_copy (node, "ip_address", ip);
7385 api_bd_ip_mac_dump (vat_main_t * vam)
7387 unformat_input_t *i = vam->input;
7388 vl_api_bd_ip_mac_dump_t *mp;
7389 vl_api_control_ping_t *mp_ping;
7394 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7396 if (unformat (i, "bd_id %d", &bd_id))
7405 "\n%-5s %-7s %-20s %-30s",
7406 "bd_id", "is_ipv6", "mac_address", "ip_address");
7408 /* Dump Bridge Domain Ip to Mac entries */
7409 M (BD_IP_MAC_DUMP, mp);
7412 mp->bd_id = htonl (bd_id);
7418 /* Use a control ping for synchronization */
7419 MPING (CONTROL_PING, mp_ping);
7427 api_tap_create_v2 (vat_main_t * vam)
7429 unformat_input_t *i = vam->input;
7430 vl_api_tap_create_v2_t *mp;
7431 #define TAP_FLAG_GSO (1 << 0)
7435 u8 *host_if_name = 0;
7437 u8 host_mac_addr[6];
7438 u8 host_mac_addr_set = 0;
7439 u8 *host_bridge = 0;
7440 ip4_address_t host_ip4_addr;
7441 ip4_address_t host_ip4_gw;
7442 u8 host_ip4_gw_set = 0;
7443 u32 host_ip4_prefix_len = 0;
7444 ip6_address_t host_ip6_addr;
7445 ip6_address_t host_ip6_gw;
7446 u8 host_ip6_gw_set = 0;
7447 u32 host_ip6_prefix_len = 0;
7448 u8 host_mtu_set = 0;
7449 u32 host_mtu_size = 0;
7452 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7454 clib_memset (mac_address, 0, sizeof (mac_address));
7456 /* Parse args required to build the message */
7457 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7459 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7463 else if (unformat (i, "id %u", &id))
7465 else if (unformat (i, "host-if-name %s", &host_if_name))
7467 else if (unformat (i, "host-ns %s", &host_ns))
7469 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
7471 host_mac_addr_set = 1;
7472 else if (unformat (i, "host-bridge %s", &host_bridge))
7474 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
7475 &host_ip4_addr, &host_ip4_prefix_len))
7477 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
7478 &host_ip6_addr, &host_ip6_prefix_len))
7480 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
7482 host_ip4_gw_set = 1;
7483 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
7485 host_ip6_gw_set = 1;
7486 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
7488 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
7490 else if (unformat (i, "host-mtu-size %d", &host_mtu_size))
7492 else if (unformat (i, "no-gso"))
7493 tap_flags &= ~TAP_FLAG_GSO;
7494 else if (unformat (i, "gso"))
7495 tap_flags |= TAP_FLAG_GSO;
7500 if (vec_len (host_if_name) > 63)
7502 errmsg ("tap name too long. ");
7505 if (vec_len (host_ns) > 63)
7507 errmsg ("host name space too long. ");
7510 if (vec_len (host_bridge) > 63)
7512 errmsg ("host bridge name too long. ");
7515 if (host_ip4_prefix_len > 32)
7517 errmsg ("host ip4 prefix length not valid. ");
7520 if (host_ip6_prefix_len > 128)
7522 errmsg ("host ip6 prefix length not valid. ");
7525 if (!is_pow2 (rx_ring_sz))
7527 errmsg ("rx ring size must be power of 2. ");
7530 if (rx_ring_sz > 32768)
7532 errmsg ("rx ring size must be 32768 or lower. ");
7535 if (!is_pow2 (tx_ring_sz))
7537 errmsg ("tx ring size must be power of 2. ");
7540 if (tx_ring_sz > 32768)
7542 errmsg ("tx ring size must be 32768 or lower. ");
7545 if (host_mtu_set && (host_mtu_size < 64 || host_mtu_size > 65355))
7547 errmsg ("host MTU size must be in between 64 and 65355. ");
7551 /* Construct the API message */
7552 M (TAP_CREATE_V2, mp);
7554 mp->use_random_mac = random_mac;
7556 mp->id = ntohl (id);
7557 mp->host_namespace_set = host_ns != 0;
7558 mp->host_bridge_set = host_bridge != 0;
7559 mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
7560 mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
7561 mp->rx_ring_sz = ntohs (rx_ring_sz);
7562 mp->tx_ring_sz = ntohs (tx_ring_sz);
7563 mp->host_mtu_set = host_mtu_set;
7564 mp->host_mtu_size = ntohl (host_mtu_size);
7565 mp->tap_flags = ntohl (tap_flags);
7567 if (random_mac == 0)
7568 clib_memcpy (mp->mac_address, mac_address, 6);
7569 if (host_mac_addr_set)
7570 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
7572 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
7574 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
7576 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
7577 if (host_ip4_prefix_len)
7578 clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
7579 if (host_ip6_prefix_len)
7580 clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
7581 if (host_ip4_gw_set)
7582 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
7583 if (host_ip6_gw_set)
7584 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
7587 vec_free (host_if_name);
7588 vec_free (host_bridge);
7593 /* Wait for a reply... */
7599 api_tap_delete_v2 (vat_main_t * vam)
7601 unformat_input_t *i = vam->input;
7602 vl_api_tap_delete_v2_t *mp;
7603 u32 sw_if_index = ~0;
7604 u8 sw_if_index_set = 0;
7607 /* Parse args required to build the message */
7608 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7610 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7611 sw_if_index_set = 1;
7612 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7613 sw_if_index_set = 1;
7618 if (sw_if_index_set == 0)
7620 errmsg ("missing vpp interface name. ");
7624 /* Construct the API message */
7625 M (TAP_DELETE_V2, mp);
7627 mp->sw_if_index = ntohl (sw_if_index);
7632 /* Wait for a reply... */
7638 unformat_pci_addr (unformat_input_t * input, va_list * args)
7647 addr = va_arg (*args, struct pci_addr_t *);
7650 if (!unformat (input, "%x:%x:%x.%x", &x[0], &x[1], &x[2], &x[3]))
7653 addr->domain = x[0];
7656 addr->function = x[3];
7662 api_virtio_pci_create (vat_main_t * vam)
7664 unformat_input_t *i = vam->input;
7665 vl_api_virtio_pci_create_t *mp;
7670 u64 features = (u64) ~ (0ULL);
7673 clib_memset (mac_address, 0, sizeof (mac_address));
7675 /* Parse args required to build the message */
7676 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7678 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7682 else if (unformat (i, "pci-addr %U", unformat_pci_addr, &pci_addr))
7684 else if (unformat (i, "features 0x%llx", &features))
7686 else if (unformat (i, "gso-enabled"))
7694 errmsg ("pci address must be non zero. ");
7698 /* Construct the API message */
7699 M (VIRTIO_PCI_CREATE, mp);
7701 mp->use_random_mac = random_mac;
7703 mp->pci_addr = htonl (pci_addr);
7704 mp->features = clib_host_to_net_u64 (features);
7705 mp->gso_enabled = gso_enabled;
7707 if (random_mac == 0)
7708 clib_memcpy (mp->mac_address, mac_address, 6);
7713 /* Wait for a reply... */
7719 api_virtio_pci_delete (vat_main_t * vam)
7721 unformat_input_t *i = vam->input;
7722 vl_api_virtio_pci_delete_t *mp;
7723 u32 sw_if_index = ~0;
7724 u8 sw_if_index_set = 0;
7727 /* Parse args required to build the message */
7728 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7730 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7731 sw_if_index_set = 1;
7732 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7733 sw_if_index_set = 1;
7738 if (sw_if_index_set == 0)
7740 errmsg ("missing vpp interface name. ");
7744 /* Construct the API message */
7745 M (VIRTIO_PCI_DELETE, mp);
7747 mp->sw_if_index = htonl (sw_if_index);
7752 /* Wait for a reply... */
7758 api_bond_create (vat_main_t * vam)
7760 unformat_input_t *i = vam->input;
7761 vl_api_bond_create_t *mp;
7770 clib_memset (mac_address, 0, sizeof (mac_address));
7773 /* Parse args required to build the message */
7774 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7776 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
7778 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
7779 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
7781 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
7784 else if (unformat (i, "id %u", &id))
7790 if (mode_is_set == 0)
7792 errmsg ("Missing bond mode. ");
7796 /* Construct the API message */
7797 M (BOND_CREATE, mp);
7799 mp->use_custom_mac = custom_mac;
7803 mp->id = htonl (id);
7806 clib_memcpy (mp->mac_address, mac_address, 6);
7811 /* Wait for a reply... */
7817 api_bond_delete (vat_main_t * vam)
7819 unformat_input_t *i = vam->input;
7820 vl_api_bond_delete_t *mp;
7821 u32 sw_if_index = ~0;
7822 u8 sw_if_index_set = 0;
7825 /* Parse args required to build the message */
7826 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7828 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7829 sw_if_index_set = 1;
7830 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7831 sw_if_index_set = 1;
7836 if (sw_if_index_set == 0)
7838 errmsg ("missing vpp interface name. ");
7842 /* Construct the API message */
7843 M (BOND_DELETE, mp);
7845 mp->sw_if_index = ntohl (sw_if_index);
7850 /* Wait for a reply... */
7856 api_bond_enslave (vat_main_t * vam)
7858 unformat_input_t *i = vam->input;
7859 vl_api_bond_enslave_t *mp;
7860 u32 bond_sw_if_index;
7864 u32 bond_sw_if_index_is_set = 0;
7866 u8 sw_if_index_is_set = 0;
7868 /* Parse args required to build the message */
7869 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7871 if (unformat (i, "sw_if_index %d", &sw_if_index))
7872 sw_if_index_is_set = 1;
7873 else if (unformat (i, "bond %u", &bond_sw_if_index))
7874 bond_sw_if_index_is_set = 1;
7875 else if (unformat (i, "passive %d", &is_passive))
7877 else if (unformat (i, "long-timeout %d", &is_long_timeout))
7883 if (bond_sw_if_index_is_set == 0)
7885 errmsg ("Missing bond sw_if_index. ");
7888 if (sw_if_index_is_set == 0)
7890 errmsg ("Missing slave sw_if_index. ");
7894 /* Construct the API message */
7895 M (BOND_ENSLAVE, mp);
7897 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
7898 mp->sw_if_index = ntohl (sw_if_index);
7899 mp->is_long_timeout = is_long_timeout;
7900 mp->is_passive = is_passive;
7905 /* Wait for a reply... */
7911 api_bond_detach_slave (vat_main_t * vam)
7913 unformat_input_t *i = vam->input;
7914 vl_api_bond_detach_slave_t *mp;
7915 u32 sw_if_index = ~0;
7916 u8 sw_if_index_set = 0;
7919 /* Parse args required to build the message */
7920 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7922 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7923 sw_if_index_set = 1;
7924 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7925 sw_if_index_set = 1;
7930 if (sw_if_index_set == 0)
7932 errmsg ("missing vpp interface name. ");
7936 /* Construct the API message */
7937 M (BOND_DETACH_SLAVE, mp);
7939 mp->sw_if_index = ntohl (sw_if_index);
7944 /* Wait for a reply... */
7950 api_ip_table_add_del (vat_main_t * vam)
7952 unformat_input_t *i = vam->input;
7953 vl_api_ip_table_add_del_t *mp;
7959 /* Parse args required to build the message */
7960 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7962 if (unformat (i, "ipv6"))
7964 else if (unformat (i, "del"))
7966 else if (unformat (i, "add"))
7968 else if (unformat (i, "table %d", &table_id))
7972 clib_warning ("parse error '%U'", format_unformat_error, i);
7979 errmsg ("missing table-ID");
7983 /* Construct the API message */
7984 M (IP_TABLE_ADD_DEL, mp);
7986 mp->table.table_id = ntohl (table_id);
7987 mp->table.is_ip6 = is_ipv6;
7988 mp->is_add = is_add;
7993 /* Wait for a reply... */
8000 unformat_fib_path (unformat_input_t * input, va_list * args)
8002 vat_main_t *vam = va_arg (*args, vat_main_t *);
8003 vl_api_fib_path_t *path = va_arg (*args, vl_api_fib_path_t *);
8004 u32 weight, preference;
8005 mpls_label_t out_label;
8007 clib_memset (path, 0, sizeof (*path));
8009 path->sw_if_index = ~0;
8013 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8015 if (unformat (input, "%U %U",
8016 unformat_vl_api_ip4_address,
8017 &path->nh.address.ip4,
8018 api_unformat_sw_if_index, vam, &path->sw_if_index))
8020 path->proto = FIB_API_PATH_NH_PROTO_IP4;
8022 else if (unformat (input, "%U %U",
8023 unformat_vl_api_ip6_address,
8024 &path->nh.address.ip6,
8025 api_unformat_sw_if_index, vam, &path->sw_if_index))
8027 path->proto = FIB_API_PATH_NH_PROTO_IP6;
8029 else if (unformat (input, "weight %u", &weight))
8031 path->weight = weight;
8033 else if (unformat (input, "preference %u", &preference))
8035 path->preference = preference;
8037 else if (unformat (input, "%U next-hop-table %d",
8038 unformat_vl_api_ip4_address,
8039 &path->nh.address.ip4, &path->table_id))
8041 path->proto = FIB_API_PATH_NH_PROTO_IP4;
8043 else if (unformat (input, "%U next-hop-table %d",
8044 unformat_vl_api_ip6_address,
8045 &path->nh.address.ip6, &path->table_id))
8047 path->proto = FIB_API_PATH_NH_PROTO_IP6;
8049 else if (unformat (input, "%U",
8050 unformat_vl_api_ip4_address, &path->nh.address.ip4))
8053 * the recursive next-hops are by default in the default table
8056 path->sw_if_index = ~0;
8057 path->proto = FIB_API_PATH_NH_PROTO_IP4;
8059 else if (unformat (input, "%U",
8060 unformat_vl_api_ip6_address, &path->nh.address.ip6))
8063 * the recursive next-hops are by default in the default table
8066 path->sw_if_index = ~0;
8067 path->proto = FIB_API_PATH_NH_PROTO_IP6;
8069 else if (unformat (input, "resolve-via-host"))
8071 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_HOST;
8073 else if (unformat (input, "resolve-via-attached"))
8075 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED;
8077 else if (unformat (input, "ip4-lookup-in-table %d", &path->table_id))
8079 path->type = FIB_API_PATH_TYPE_LOCAL;
8080 path->sw_if_index = ~0;
8081 path->proto = FIB_API_PATH_NH_PROTO_IP4;
8083 else if (unformat (input, "ip6-lookup-in-table %d", &path->table_id))
8085 path->type = FIB_API_PATH_TYPE_LOCAL;
8086 path->sw_if_index = ~0;
8087 path->proto = FIB_API_PATH_NH_PROTO_IP6;
8089 else if (unformat (input, "sw_if_index %d", &path->sw_if_index))
8091 else if (unformat (input, "via-label %d", &path->nh.via_label))
8093 path->proto = FIB_API_PATH_NH_PROTO_MPLS;
8094 path->sw_if_index = ~0;
8096 else if (unformat (input, "l2-input-on %d", &path->sw_if_index))
8098 path->proto = FIB_API_PATH_NH_PROTO_ETHERNET;
8099 path->type = FIB_API_PATH_TYPE_INTERFACE_RX;
8101 else if (unformat (input, "local"))
8103 path->type = FIB_API_PATH_TYPE_LOCAL;
8105 else if (unformat (input, "out-labels"))
8107 while (unformat (input, "%d", &out_label))
8109 path->label_stack[path->n_labels].label = out_label;
8110 path->label_stack[path->n_labels].is_uniform = 0;
8111 path->label_stack[path->n_labels].ttl = 64;
8115 else if (unformat (input, "via"))
8117 /* new path, back up and return */
8118 unformat_put_input (input);
8119 unformat_put_input (input);
8120 unformat_put_input (input);
8121 unformat_put_input (input);
8130 path->proto = ntohl (path->proto);
8131 path->type = ntohl (path->type);
8132 path->flags = ntohl (path->flags);
8133 path->table_id = ntohl (path->table_id);
8134 path->sw_if_index = ntohl (path->sw_if_index);
8140 api_ip_route_add_del (vat_main_t * vam)
8142 unformat_input_t *i = vam->input;
8143 vl_api_ip_route_add_del_t *mp;
8146 u8 is_multipath = 0;
8149 vl_api_prefix_t pfx = { };
8150 vl_api_fib_path_t paths[8];
8154 u32 random_add_del = 0;
8155 u32 *random_vector = 0;
8156 u32 random_seed = 0xdeaddabe;
8158 /* Parse args required to build the message */
8159 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8161 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
8163 else if (unformat (i, "del"))
8165 else if (unformat (i, "add"))
8167 else if (unformat (i, "vrf %d", &vrf_id))
8169 else if (unformat (i, "count %d", &count))
8171 else if (unformat (i, "random"))
8173 else if (unformat (i, "multipath"))
8175 else if (unformat (i, "seed %d", &random_seed))
8179 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8182 if (8 == path_count)
8184 errmsg ("max 8 paths");
8190 clib_warning ("parse error '%U'", format_unformat_error, i);
8197 errmsg ("specify a path; via ...");
8200 if (prefix_set == 0)
8202 errmsg ("missing prefix");
8206 /* Generate a pile of unique, random routes */
8209 ip4_address_t *i = (ip4_address_t *) & paths[0].nh.address.ip4;
8210 u32 this_random_address;
8213 random_hash = hash_create (count, sizeof (uword));
8215 hash_set (random_hash, i->as_u32, 1);
8216 for (j = 0; j <= count; j++)
8220 this_random_address = random_u32 (&random_seed);
8221 this_random_address =
8222 clib_host_to_net_u32 (this_random_address);
8224 while (hash_get (random_hash, this_random_address));
8225 vec_add1 (random_vector, this_random_address);
8226 hash_set (random_hash, this_random_address, 1);
8228 hash_free (random_hash);
8229 set_ip4_address (&pfx.address, random_vector[0]);
8234 /* Turn on async mode */
8235 vam->async_mode = 1;
8236 vam->async_errors = 0;
8237 before = vat_time_now (vam);
8240 for (j = 0; j < count; j++)
8242 /* Construct the API message */
8243 M2 (IP_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8245 mp->is_add = is_add;
8246 mp->is_multipath = is_multipath;
8248 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
8249 mp->route.table_id = ntohl (vrf_id);
8250 mp->route.n_paths = path_count;
8252 clib_memcpy (&mp->route.paths, &paths, sizeof (paths[0]) * path_count);
8255 set_ip4_address (&pfx.address, random_vector[j + 1]);
8257 increment_address (&pfx.address);
8260 /* If we receive SIGTERM, stop now... */
8265 /* When testing multiple add/del ops, use a control-ping to sync */
8268 vl_api_control_ping_t *mp_ping;
8272 /* Shut off async mode */
8273 vam->async_mode = 0;
8275 MPING (CONTROL_PING, mp_ping);
8278 timeout = vat_time_now (vam) + 1.0;
8279 while (vat_time_now (vam) < timeout)
8280 if (vam->result_ready == 1)
8285 if (vam->retval == -99)
8288 if (vam->async_errors > 0)
8290 errmsg ("%d asynchronous errors", vam->async_errors);
8293 vam->async_errors = 0;
8294 after = vat_time_now (vam);
8296 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8300 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8301 count, after - before, count / (after - before));
8307 /* Wait for a reply... */
8312 /* Return the good/bad news */
8313 return (vam->retval);
8317 api_ip_mroute_add_del (vat_main_t * vam)
8319 unformat_input_t *i = vam->input;
8320 u8 path_set = 0, prefix_set = 0, is_add = 1;
8321 vl_api_ip_mroute_add_del_t *mp;
8322 mfib_entry_flags_t eflags = 0;
8323 vl_api_mfib_path_t path;
8324 vl_api_mprefix_t pfx = { };
8328 /* Parse args required to build the message */
8329 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8331 if (unformat (i, "%U", unformat_vl_api_mprefix, &pfx))
8334 pfx.grp_address_length = htons (pfx.grp_address_length);
8336 else if (unformat (i, "del"))
8338 else if (unformat (i, "add"))
8340 else if (unformat (i, "vrf %d", &vrf_id))
8342 else if (unformat (i, "%U", unformat_mfib_itf_flags, &path.itf_flags))
8343 path.itf_flags = htonl (path.itf_flags);
8344 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8346 else if (unformat (i, "via %U", unformat_fib_path, vam, &path.path))
8350 clib_warning ("parse error '%U'", format_unformat_error, i);
8355 if (prefix_set == 0)
8357 errmsg ("missing addresses\n");
8362 errmsg ("missing path\n");
8366 /* Construct the API message */
8367 M (IP_MROUTE_ADD_DEL, mp);
8369 mp->is_add = is_add;
8370 mp->is_multipath = 1;
8372 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
8373 mp->route.table_id = htonl (vrf_id);
8374 mp->route.n_paths = 1;
8375 mp->route.entry_flags = htonl (eflags);
8377 clib_memcpy (&mp->route.paths, &path, sizeof (path));
8381 /* Wait for a reply... */
8387 api_mpls_table_add_del (vat_main_t * vam)
8389 unformat_input_t *i = vam->input;
8390 vl_api_mpls_table_add_del_t *mp;
8395 /* Parse args required to build the message */
8396 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8398 if (unformat (i, "table %d", &table_id))
8400 else if (unformat (i, "del"))
8402 else if (unformat (i, "add"))
8406 clib_warning ("parse error '%U'", format_unformat_error, i);
8413 errmsg ("missing table-ID");
8417 /* Construct the API message */
8418 M (MPLS_TABLE_ADD_DEL, mp);
8420 mp->mt_table.mt_table_id = ntohl (table_id);
8421 mp->mt_is_add = is_add;
8426 /* Wait for a reply... */
8433 api_mpls_route_add_del (vat_main_t * vam)
8435 u8 is_add = 1, path_count = 0, is_multipath = 0, is_eos = 0;
8436 mpls_label_t local_label = MPLS_LABEL_INVALID;
8437 unformat_input_t *i = vam->input;
8438 vl_api_mpls_route_add_del_t *mp;
8439 vl_api_fib_path_t paths[8];
8443 /* Parse args required to build the message */
8444 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8446 if (unformat (i, "%d", &local_label))
8448 else if (unformat (i, "eos"))
8450 else if (unformat (i, "non-eos"))
8452 else if (unformat (i, "del"))
8454 else if (unformat (i, "add"))
8456 else if (unformat (i, "multipath"))
8458 else if (unformat (i, "count %d", &count))
8462 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8465 if (8 == path_count)
8467 errmsg ("max 8 paths");
8473 clib_warning ("parse error '%U'", format_unformat_error, i);
8480 errmsg ("specify a path; via ...");
8484 if (MPLS_LABEL_INVALID == local_label)
8486 errmsg ("missing label");
8492 /* Turn on async mode */
8493 vam->async_mode = 1;
8494 vam->async_errors = 0;
8495 before = vat_time_now (vam);
8498 for (j = 0; j < count; j++)
8500 /* Construct the API message */
8501 M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8503 mp->mr_is_add = is_add;
8504 mp->mr_is_multipath = is_multipath;
8506 mp->mr_route.mr_label = local_label;
8507 mp->mr_route.mr_eos = is_eos;
8508 mp->mr_route.mr_table_id = 0;
8509 mp->mr_route.mr_n_paths = path_count;
8511 clib_memcpy (&mp->mr_route.mr_paths, paths,
8512 sizeof (paths[0]) * path_count);
8518 /* If we receive SIGTERM, stop now... */
8523 /* When testing multiple add/del ops, use a control-ping to sync */
8526 vl_api_control_ping_t *mp_ping;
8530 /* Shut off async mode */
8531 vam->async_mode = 0;
8533 MPING (CONTROL_PING, mp_ping);
8536 timeout = vat_time_now (vam) + 1.0;
8537 while (vat_time_now (vam) < timeout)
8538 if (vam->result_ready == 1)
8543 if (vam->retval == -99)
8546 if (vam->async_errors > 0)
8548 errmsg ("%d asynchronous errors", vam->async_errors);
8551 vam->async_errors = 0;
8552 after = vat_time_now (vam);
8554 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8558 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8559 count, after - before, count / (after - before));
8565 /* Wait for a reply... */
8570 /* Return the good/bad news */
8571 return (vam->retval);
8576 api_mpls_ip_bind_unbind (vat_main_t * vam)
8578 unformat_input_t *i = vam->input;
8579 vl_api_mpls_ip_bind_unbind_t *mp;
8580 u32 ip_table_id = 0;
8582 vl_api_prefix_t pfx;
8584 mpls_label_t local_label = MPLS_LABEL_INVALID;
8587 /* Parse args required to build the message */
8588 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8590 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
8592 else if (unformat (i, "%d", &local_label))
8594 else if (unformat (i, "table-id %d", &ip_table_id))
8596 else if (unformat (i, "unbind"))
8598 else if (unformat (i, "bind"))
8602 clib_warning ("parse error '%U'", format_unformat_error, i);
8609 errmsg ("IP prefix not set");
8613 if (MPLS_LABEL_INVALID == local_label)
8615 errmsg ("missing label");
8619 /* Construct the API message */
8620 M (MPLS_IP_BIND_UNBIND, mp);
8622 mp->mb_is_bind = is_bind;
8623 mp->mb_ip_table_id = ntohl (ip_table_id);
8624 mp->mb_mpls_table_id = 0;
8625 mp->mb_label = ntohl (local_label);
8626 clib_memcpy (&mp->mb_prefix, &pfx, sizeof (pfx));
8631 /* Wait for a reply... */
8638 api_sr_mpls_policy_add (vat_main_t * vam)
8640 unformat_input_t *i = vam->input;
8641 vl_api_sr_mpls_policy_add_t *mp;
8647 u32 *segments = NULL;
8650 /* Parse args required to build the message */
8651 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8653 if (unformat (i, "bsid %d", &bsid))
8655 else if (unformat (i, "weight %d", &weight))
8657 else if (unformat (i, "spray"))
8659 else if (unformat (i, "next %d", &sid))
8662 vec_add1 (segments, htonl (sid));
8666 clib_warning ("parse error '%U'", format_unformat_error, i);
8673 errmsg ("bsid not set");
8677 if (n_segments == 0)
8679 errmsg ("no sid in segment stack");
8683 /* Construct the API message */
8684 M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
8686 mp->bsid = htonl (bsid);
8687 mp->weight = htonl (weight);
8689 mp->n_segments = n_segments;
8690 memcpy (mp->segments, segments, sizeof (u32) * n_segments);
8691 vec_free (segments);
8696 /* Wait for a reply... */
8702 api_sr_mpls_policy_del (vat_main_t * vam)
8704 unformat_input_t *i = vam->input;
8705 vl_api_sr_mpls_policy_del_t *mp;
8709 /* Parse args required to build the message */
8710 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8712 if (unformat (i, "bsid %d", &bsid))
8716 clib_warning ("parse error '%U'", format_unformat_error, i);
8723 errmsg ("bsid not set");
8727 /* Construct the API message */
8728 M (SR_MPLS_POLICY_DEL, mp);
8730 mp->bsid = htonl (bsid);
8735 /* Wait for a reply... */
8741 api_bier_table_add_del (vat_main_t * vam)
8743 unformat_input_t *i = vam->input;
8744 vl_api_bier_table_add_del_t *mp;
8746 u32 set = 0, sub_domain = 0, hdr_len = 3;
8747 mpls_label_t local_label = MPLS_LABEL_INVALID;
8750 /* Parse args required to build the message */
8751 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8753 if (unformat (i, "sub-domain %d", &sub_domain))
8755 else if (unformat (i, "set %d", &set))
8757 else if (unformat (i, "label %d", &local_label))
8759 else if (unformat (i, "hdr-len %d", &hdr_len))
8761 else if (unformat (i, "add"))
8763 else if (unformat (i, "del"))
8767 clib_warning ("parse error '%U'", format_unformat_error, i);
8772 if (MPLS_LABEL_INVALID == local_label)
8774 errmsg ("missing label\n");
8778 /* Construct the API message */
8779 M (BIER_TABLE_ADD_DEL, mp);
8781 mp->bt_is_add = is_add;
8782 mp->bt_label = ntohl (local_label);
8783 mp->bt_tbl_id.bt_set = set;
8784 mp->bt_tbl_id.bt_sub_domain = sub_domain;
8785 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
8790 /* Wait for a reply... */
8797 api_bier_route_add_del (vat_main_t * vam)
8799 unformat_input_t *i = vam->input;
8800 vl_api_bier_route_add_del_t *mp;
8802 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
8803 ip4_address_t v4_next_hop_address;
8804 ip6_address_t v6_next_hop_address;
8805 u8 next_hop_set = 0;
8806 u8 next_hop_proto_is_ip4 = 1;
8807 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8810 /* Parse args required to build the message */
8811 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8813 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
8815 next_hop_proto_is_ip4 = 1;
8818 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
8820 next_hop_proto_is_ip4 = 0;
8823 if (unformat (i, "sub-domain %d", &sub_domain))
8825 else if (unformat (i, "set %d", &set))
8827 else if (unformat (i, "hdr-len %d", &hdr_len))
8829 else if (unformat (i, "bp %d", &bp))
8831 else if (unformat (i, "add"))
8833 else if (unformat (i, "del"))
8835 else if (unformat (i, "out-label %d", &next_hop_out_label))
8839 clib_warning ("parse error '%U'", format_unformat_error, i);
8844 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
8846 errmsg ("next hop / label set\n");
8851 errmsg ("bit=position not set\n");
8855 /* Construct the API message */
8856 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
8858 mp->br_is_add = is_add;
8859 mp->br_route.br_tbl_id.bt_set = set;
8860 mp->br_route.br_tbl_id.bt_sub_domain = sub_domain;
8861 mp->br_route.br_tbl_id.bt_hdr_len_id = hdr_len;
8862 mp->br_route.br_bp = ntohs (bp);
8863 mp->br_route.br_n_paths = 1;
8864 mp->br_route.br_paths[0].n_labels = 1;
8865 mp->br_route.br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
8866 mp->br_route.br_paths[0].proto = (next_hop_proto_is_ip4 ?
8867 FIB_API_PATH_NH_PROTO_IP4 :
8868 FIB_API_PATH_NH_PROTO_IP6);
8870 if (next_hop_proto_is_ip4)
8872 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip4,
8873 &v4_next_hop_address, sizeof (v4_next_hop_address));
8877 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip6,
8878 &v6_next_hop_address, sizeof (v6_next_hop_address));
8884 /* Wait for a reply... */
8891 api_proxy_arp_add_del (vat_main_t * vam)
8893 unformat_input_t *i = vam->input;
8894 vl_api_proxy_arp_add_del_t *mp;
8897 vl_api_ip4_address_t lo, hi;
8901 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8903 if (unformat (i, "vrf %d", &vrf_id))
8905 else if (unformat (i, "%U - %U", unformat_vl_api_ip4_address, &lo,
8906 unformat_vl_api_ip4_address, &hi))
8908 else if (unformat (i, "del"))
8912 clib_warning ("parse error '%U'", format_unformat_error, i);
8919 errmsg ("address range not set");
8923 M (PROXY_ARP_ADD_DEL, mp);
8925 mp->proxy.table_id = ntohl (vrf_id);
8926 mp->is_add = is_add;
8927 clib_memcpy (mp->proxy.low, &lo, sizeof (lo));
8928 clib_memcpy (mp->proxy.hi, &hi, sizeof (hi));
8936 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
8938 unformat_input_t *i = vam->input;
8939 vl_api_proxy_arp_intfc_enable_disable_t *mp;
8942 u8 sw_if_index_set = 0;
8945 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8947 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8948 sw_if_index_set = 1;
8949 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8950 sw_if_index_set = 1;
8951 else if (unformat (i, "enable"))
8953 else if (unformat (i, "disable"))
8957 clib_warning ("parse error '%U'", format_unformat_error, i);
8962 if (sw_if_index_set == 0)
8964 errmsg ("missing interface name or sw_if_index");
8968 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
8970 mp->sw_if_index = ntohl (sw_if_index);
8971 mp->enable_disable = enable;
8979 api_mpls_tunnel_add_del (vat_main_t * vam)
8981 unformat_input_t *i = vam->input;
8982 vl_api_mpls_tunnel_add_del_t *mp;
8984 vl_api_fib_path_t paths[8];
8985 u32 sw_if_index = ~0;
8991 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8993 if (unformat (i, "add"))
8997 (i, "del %U", api_unformat_sw_if_index, vam, &sw_if_index))
8999 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
9001 else if (unformat (i, "l2-only"))
9005 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
9008 if (8 == path_count)
9010 errmsg ("max 8 paths");
9016 clib_warning ("parse error '%U'", format_unformat_error, i);
9021 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
9023 mp->mt_is_add = is_add;
9024 mp->mt_tunnel.mt_sw_if_index = ntohl (sw_if_index);
9025 mp->mt_tunnel.mt_l2_only = l2_only;
9026 mp->mt_tunnel.mt_is_multicast = 0;
9027 mp->mt_tunnel.mt_n_paths = path_count;
9029 clib_memcpy (&mp->mt_tunnel.mt_paths, &paths,
9030 sizeof (paths[0]) * path_count);
9038 api_sw_interface_set_unnumbered (vat_main_t * vam)
9040 unformat_input_t *i = vam->input;
9041 vl_api_sw_interface_set_unnumbered_t *mp;
9043 u32 unnum_sw_index = ~0;
9045 u8 sw_if_index_set = 0;
9048 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9050 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9051 sw_if_index_set = 1;
9052 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9053 sw_if_index_set = 1;
9054 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
9056 else if (unformat (i, "del"))
9060 clib_warning ("parse error '%U'", format_unformat_error, i);
9065 if (sw_if_index_set == 0)
9067 errmsg ("missing interface name or sw_if_index");
9071 M (SW_INTERFACE_SET_UNNUMBERED, mp);
9073 mp->sw_if_index = ntohl (sw_if_index);
9074 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
9075 mp->is_add = is_add;
9083 api_ip_neighbor_add_del (vat_main_t * vam)
9085 vl_api_mac_address_t mac_address;
9086 unformat_input_t *i = vam->input;
9087 vl_api_ip_neighbor_add_del_t *mp;
9088 vl_api_address_t ip_address;
9090 u8 sw_if_index_set = 0;
9095 ip_neighbor_flags_t flags;
9097 flags = IP_NEIGHBOR_FLAG_NONE;
9098 clib_memset (&ip_address, 0, sizeof (ip_address));
9099 clib_memset (&mac_address, 0, sizeof (mac_address));
9101 /* Parse args required to build the message */
9102 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9104 if (unformat (i, "mac %U", unformat_vl_api_mac_address, &mac_address))
9108 else if (unformat (i, "del"))
9111 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9112 sw_if_index_set = 1;
9113 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9114 sw_if_index_set = 1;
9115 else if (unformat (i, "static"))
9116 flags |= IP_NEIGHBOR_FLAG_STATIC;
9117 else if (unformat (i, "no-fib-entry"))
9118 flags |= IP_NEIGHBOR_FLAG_NO_FIB_ENTRY;
9119 else if (unformat (i, "dst %U", unformat_vl_api_address, &ip_address))
9123 clib_warning ("parse error '%U'", format_unformat_error, i);
9128 if (sw_if_index_set == 0)
9130 errmsg ("missing interface name or sw_if_index");
9135 errmsg ("no address set");
9139 /* Construct the API message */
9140 M (IP_NEIGHBOR_ADD_DEL, mp);
9142 mp->neighbor.sw_if_index = ntohl (sw_if_index);
9143 mp->is_add = is_add;
9144 mp->neighbor.flags = htonl (flags);
9146 clib_memcpy (&mp->neighbor.mac_address, &mac_address,
9147 sizeof (mac_address));
9149 clib_memcpy (&mp->neighbor.ip_address, &ip_address, sizeof (ip_address));
9154 /* Wait for a reply, return good/bad news */
9160 api_create_vlan_subif (vat_main_t * vam)
9162 unformat_input_t *i = vam->input;
9163 vl_api_create_vlan_subif_t *mp;
9165 u8 sw_if_index_set = 0;
9170 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9172 if (unformat (i, "sw_if_index %d", &sw_if_index))
9173 sw_if_index_set = 1;
9175 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9176 sw_if_index_set = 1;
9177 else if (unformat (i, "vlan %d", &vlan_id))
9181 clib_warning ("parse error '%U'", format_unformat_error, i);
9186 if (sw_if_index_set == 0)
9188 errmsg ("missing interface name or sw_if_index");
9192 if (vlan_id_set == 0)
9194 errmsg ("missing vlan_id");
9197 M (CREATE_VLAN_SUBIF, mp);
9199 mp->sw_if_index = ntohl (sw_if_index);
9200 mp->vlan_id = ntohl (vlan_id);
9207 #define foreach_create_subif_bit \
9214 _(outer_vlan_id_any) \
9215 _(inner_vlan_id_any)
9218 api_create_subif (vat_main_t * vam)
9220 unformat_input_t *i = vam->input;
9221 vl_api_create_subif_t *mp;
9223 u8 sw_if_index_set = 0;
9230 u32 exact_match = 0;
9231 u32 default_sub = 0;
9232 u32 outer_vlan_id_any = 0;
9233 u32 inner_vlan_id_any = 0;
9235 u16 outer_vlan_id = 0;
9236 u16 inner_vlan_id = 0;
9239 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9241 if (unformat (i, "sw_if_index %d", &sw_if_index))
9242 sw_if_index_set = 1;
9244 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9245 sw_if_index_set = 1;
9246 else if (unformat (i, "sub_id %d", &sub_id))
9248 else if (unformat (i, "outer_vlan_id %d", &tmp))
9249 outer_vlan_id = tmp;
9250 else if (unformat (i, "inner_vlan_id %d", &tmp))
9251 inner_vlan_id = tmp;
9253 #define _(a) else if (unformat (i, #a)) a = 1 ;
9254 foreach_create_subif_bit
9258 clib_warning ("parse error '%U'", format_unformat_error, i);
9263 if (sw_if_index_set == 0)
9265 errmsg ("missing interface name or sw_if_index");
9269 if (sub_id_set == 0)
9271 errmsg ("missing sub_id");
9274 M (CREATE_SUBIF, mp);
9276 mp->sw_if_index = ntohl (sw_if_index);
9277 mp->sub_id = ntohl (sub_id);
9279 #define _(a) mp->a = a;
9280 foreach_create_subif_bit;
9283 mp->outer_vlan_id = ntohs (outer_vlan_id);
9284 mp->inner_vlan_id = ntohs (inner_vlan_id);
9292 api_reset_fib (vat_main_t * vam)
9294 unformat_input_t *i = vam->input;
9295 vl_api_reset_fib_t *mp;
9301 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9303 if (unformat (i, "vrf %d", &vrf_id))
9305 else if (unformat (i, "ipv6"))
9309 clib_warning ("parse error '%U'", format_unformat_error, i);
9314 if (vrf_id_set == 0)
9316 errmsg ("missing vrf id");
9322 mp->vrf_id = ntohl (vrf_id);
9323 mp->is_ipv6 = is_ipv6;
9331 api_dhcp_proxy_config (vat_main_t * vam)
9333 unformat_input_t *i = vam->input;
9334 vl_api_dhcp_proxy_config_t *mp;
9336 u32 server_vrf_id = 0;
9338 u8 v4_address_set = 0;
9339 u8 v6_address_set = 0;
9340 ip4_address_t v4address;
9341 ip6_address_t v6address;
9342 u8 v4_src_address_set = 0;
9343 u8 v6_src_address_set = 0;
9344 ip4_address_t v4srcaddress;
9345 ip6_address_t v6srcaddress;
9348 /* Parse args required to build the message */
9349 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9351 if (unformat (i, "del"))
9353 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
9355 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
9357 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
9359 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
9361 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
9362 v4_src_address_set = 1;
9363 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
9364 v6_src_address_set = 1;
9369 if (v4_address_set && v6_address_set)
9371 errmsg ("both v4 and v6 server addresses set");
9374 if (!v4_address_set && !v6_address_set)
9376 errmsg ("no server addresses set");
9380 if (v4_src_address_set && v6_src_address_set)
9382 errmsg ("both v4 and v6 src addresses set");
9385 if (!v4_src_address_set && !v6_src_address_set)
9387 errmsg ("no src addresses set");
9391 if (!(v4_src_address_set && v4_address_set) &&
9392 !(v6_src_address_set && v6_address_set))
9394 errmsg ("no matching server and src addresses set");
9398 /* Construct the API message */
9399 M (DHCP_PROXY_CONFIG, mp);
9401 mp->is_add = is_add;
9402 mp->rx_vrf_id = ntohl (rx_vrf_id);
9403 mp->server_vrf_id = ntohl (server_vrf_id);
9407 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
9408 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
9412 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
9413 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
9419 /* Wait for a reply, return good/bad news */
9424 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
9425 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
9428 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
9430 vat_main_t *vam = &vat_main;
9431 u32 i, count = mp->count;
9432 vl_api_dhcp_server_t *s;
9436 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9437 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9438 ntohl (mp->rx_vrf_id),
9439 format_ip6_address, mp->dhcp_src_address,
9440 mp->vss_type, mp->vss_vpn_ascii_id,
9441 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9444 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9445 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9446 ntohl (mp->rx_vrf_id),
9447 format_ip4_address, mp->dhcp_src_address,
9448 mp->vss_type, mp->vss_vpn_ascii_id,
9449 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9451 for (i = 0; i < count; i++)
9453 s = &mp->servers[i];
9457 " Server Table-ID %d, Server Address %U",
9458 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
9461 " Server Table-ID %d, Server Address %U",
9462 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
9466 static void vl_api_dhcp_proxy_details_t_handler_json
9467 (vl_api_dhcp_proxy_details_t * mp)
9469 vat_main_t *vam = &vat_main;
9470 vat_json_node_t *node = NULL;
9471 u32 i, count = mp->count;
9473 struct in6_addr ip6;
9474 vl_api_dhcp_server_t *s;
9476 if (VAT_JSON_ARRAY != vam->json_tree.type)
9478 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9479 vat_json_init_array (&vam->json_tree);
9481 node = vat_json_array_add (&vam->json_tree);
9483 vat_json_init_object (node);
9484 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
9485 vat_json_object_add_bytes (node, "vss-type", &mp->vss_type,
9486 sizeof (mp->vss_type));
9487 vat_json_object_add_string_copy (node, "vss-vpn-ascii-id",
9488 mp->vss_vpn_ascii_id);
9489 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
9490 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
9494 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
9495 vat_json_object_add_ip6 (node, "src_address", ip6);
9499 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
9500 vat_json_object_add_ip4 (node, "src_address", ip4);
9503 for (i = 0; i < count; i++)
9505 s = &mp->servers[i];
9507 vat_json_object_add_uint (node, "server-table-id",
9508 ntohl (s->server_vrf_id));
9512 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
9513 vat_json_object_add_ip4 (node, "src_address", ip4);
9517 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
9518 vat_json_object_add_ip6 (node, "server_address", ip6);
9524 api_dhcp_proxy_dump (vat_main_t * vam)
9526 unformat_input_t *i = vam->input;
9527 vl_api_control_ping_t *mp_ping;
9528 vl_api_dhcp_proxy_dump_t *mp;
9532 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9534 if (unformat (i, "ipv6"))
9538 clib_warning ("parse error '%U'", format_unformat_error, i);
9543 M (DHCP_PROXY_DUMP, mp);
9545 mp->is_ip6 = is_ipv6;
9548 /* Use a control ping for synchronization */
9549 MPING (CONTROL_PING, mp_ping);
9557 api_dhcp_proxy_set_vss (vat_main_t * vam)
9559 unformat_input_t *i = vam->input;
9560 vl_api_dhcp_proxy_set_vss_t *mp;
9564 u8 vss_type = VSS_TYPE_DEFAULT;
9565 u8 *vpn_ascii_id = 0;
9570 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9572 if (unformat (i, "tbl_id %d", &tbl_id))
9574 else if (unformat (i, "vpn_ascii_id %s", &vpn_ascii_id))
9575 vss_type = VSS_TYPE_ASCII;
9576 else if (unformat (i, "fib_id %d", &fib_id))
9577 vss_type = VSS_TYPE_VPN_ID;
9578 else if (unformat (i, "oui %d", &oui))
9579 vss_type = VSS_TYPE_VPN_ID;
9580 else if (unformat (i, "ipv6"))
9582 else if (unformat (i, "del"))
9590 errmsg ("missing tbl_id ");
9591 vec_free (vpn_ascii_id);
9595 if ((vpn_ascii_id) && (vec_len (vpn_ascii_id) > 128))
9597 errmsg ("vpn_ascii_id cannot be longer than 128 ");
9598 vec_free (vpn_ascii_id);
9602 M (DHCP_PROXY_SET_VSS, mp);
9603 mp->tbl_id = ntohl (tbl_id);
9604 mp->vss_type = vss_type;
9607 clib_memcpy (mp->vpn_ascii_id, vpn_ascii_id, vec_len (vpn_ascii_id));
9608 mp->vpn_ascii_id[vec_len (vpn_ascii_id)] = 0;
9610 mp->vpn_index = ntohl (fib_id);
9611 mp->oui = ntohl (oui);
9612 mp->is_ipv6 = is_ipv6;
9613 mp->is_add = is_add;
9618 vec_free (vpn_ascii_id);
9623 api_dhcp_client_config (vat_main_t * vam)
9625 unformat_input_t *i = vam->input;
9626 vl_api_dhcp_client_config_t *mp;
9628 u8 sw_if_index_set = 0;
9631 u8 disable_event = 0;
9634 /* Parse args required to build the message */
9635 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9637 if (unformat (i, "del"))
9640 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9641 sw_if_index_set = 1;
9642 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9643 sw_if_index_set = 1;
9644 else if (unformat (i, "hostname %s", &hostname))
9646 else if (unformat (i, "disable_event"))
9652 if (sw_if_index_set == 0)
9654 errmsg ("missing interface name or sw_if_index");
9658 if (vec_len (hostname) > 63)
9660 errmsg ("hostname too long");
9662 vec_add1 (hostname, 0);
9664 /* Construct the API message */
9665 M (DHCP_CLIENT_CONFIG, mp);
9667 mp->is_add = is_add;
9668 mp->client.sw_if_index = htonl (sw_if_index);
9669 clib_memcpy (mp->client.hostname, hostname, vec_len (hostname));
9670 vec_free (hostname);
9671 mp->client.want_dhcp_event = disable_event ? 0 : 1;
9672 mp->client.pid = htonl (getpid ());
9677 /* Wait for a reply, return good/bad news */
9683 api_set_ip_flow_hash (vat_main_t * vam)
9685 unformat_input_t *i = vam->input;
9686 vl_api_set_ip_flow_hash_t *mp;
9698 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9700 if (unformat (i, "vrf %d", &vrf_id))
9702 else if (unformat (i, "ipv6"))
9704 else if (unformat (i, "src"))
9706 else if (unformat (i, "dst"))
9708 else if (unformat (i, "sport"))
9710 else if (unformat (i, "dport"))
9712 else if (unformat (i, "proto"))
9714 else if (unformat (i, "reverse"))
9719 clib_warning ("parse error '%U'", format_unformat_error, i);
9724 if (vrf_id_set == 0)
9726 errmsg ("missing vrf id");
9730 M (SET_IP_FLOW_HASH, mp);
9736 mp->reverse = reverse;
9737 mp->vrf_id = ntohl (vrf_id);
9738 mp->is_ipv6 = is_ipv6;
9746 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
9748 unformat_input_t *i = vam->input;
9749 vl_api_sw_interface_ip6_enable_disable_t *mp;
9751 u8 sw_if_index_set = 0;
9755 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9757 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9758 sw_if_index_set = 1;
9759 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9760 sw_if_index_set = 1;
9761 else if (unformat (i, "enable"))
9763 else if (unformat (i, "disable"))
9767 clib_warning ("parse error '%U'", format_unformat_error, i);
9772 if (sw_if_index_set == 0)
9774 errmsg ("missing interface name or sw_if_index");
9778 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
9780 mp->sw_if_index = ntohl (sw_if_index);
9781 mp->enable = enable;
9789 api_ip6nd_proxy_add_del (vat_main_t * vam)
9791 unformat_input_t *i = vam->input;
9792 vl_api_ip6nd_proxy_add_del_t *mp;
9793 u32 sw_if_index = ~0;
9794 u8 v6_address_set = 0;
9795 vl_api_ip6_address_t v6address;
9799 /* Parse args required to build the message */
9800 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9802 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9804 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9806 else if (unformat (i, "%U", unformat_vl_api_ip6_address, &v6address))
9808 if (unformat (i, "del"))
9812 clib_warning ("parse error '%U'", format_unformat_error, i);
9817 if (sw_if_index == ~0)
9819 errmsg ("missing interface name or sw_if_index");
9822 if (!v6_address_set)
9824 errmsg ("no address set");
9828 /* Construct the API message */
9829 M (IP6ND_PROXY_ADD_DEL, mp);
9831 mp->is_del = is_del;
9832 mp->sw_if_index = ntohl (sw_if_index);
9833 clib_memcpy (mp->ip, v6address, sizeof (v6address));
9838 /* Wait for a reply, return good/bad news */
9844 api_ip6nd_proxy_dump (vat_main_t * vam)
9846 vl_api_ip6nd_proxy_dump_t *mp;
9847 vl_api_control_ping_t *mp_ping;
9850 M (IP6ND_PROXY_DUMP, mp);
9854 /* Use a control ping for synchronization */
9855 MPING (CONTROL_PING, mp_ping);
9862 static void vl_api_ip6nd_proxy_details_t_handler
9863 (vl_api_ip6nd_proxy_details_t * mp)
9865 vat_main_t *vam = &vat_main;
9867 print (vam->ofp, "host %U sw_if_index %d",
9868 format_vl_api_ip6_address, mp->ip, ntohl (mp->sw_if_index));
9871 static void vl_api_ip6nd_proxy_details_t_handler_json
9872 (vl_api_ip6nd_proxy_details_t * mp)
9874 vat_main_t *vam = &vat_main;
9875 struct in6_addr ip6;
9876 vat_json_node_t *node = NULL;
9878 if (VAT_JSON_ARRAY != vam->json_tree.type)
9880 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9881 vat_json_init_array (&vam->json_tree);
9883 node = vat_json_array_add (&vam->json_tree);
9885 vat_json_init_object (node);
9886 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9888 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
9889 vat_json_object_add_ip6 (node, "host", ip6);
9893 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
9895 unformat_input_t *i = vam->input;
9896 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
9898 u8 sw_if_index_set = 0;
9899 u8 v6_address_set = 0;
9900 vl_api_prefix_t pfx;
9902 u8 no_advertise = 0;
9904 u8 no_autoconfig = 0;
9907 u32 val_lifetime = 0;
9908 u32 pref_lifetime = 0;
9911 /* Parse args required to build the message */
9912 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9914 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9915 sw_if_index_set = 1;
9916 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9917 sw_if_index_set = 1;
9918 else if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
9920 else if (unformat (i, "val_life %d", &val_lifetime))
9922 else if (unformat (i, "pref_life %d", &pref_lifetime))
9924 else if (unformat (i, "def"))
9926 else if (unformat (i, "noadv"))
9928 else if (unformat (i, "offl"))
9930 else if (unformat (i, "noauto"))
9932 else if (unformat (i, "nolink"))
9934 else if (unformat (i, "isno"))
9938 clib_warning ("parse error '%U'", format_unformat_error, i);
9943 if (sw_if_index_set == 0)
9945 errmsg ("missing interface name or sw_if_index");
9948 if (!v6_address_set)
9950 errmsg ("no address set");
9954 /* Construct the API message */
9955 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
9957 mp->sw_if_index = ntohl (sw_if_index);
9958 clib_memcpy (&mp->prefix, &pfx, sizeof (pfx));
9959 mp->use_default = use_default;
9960 mp->no_advertise = no_advertise;
9961 mp->off_link = off_link;
9962 mp->no_autoconfig = no_autoconfig;
9963 mp->no_onlink = no_onlink;
9965 mp->val_lifetime = ntohl (val_lifetime);
9966 mp->pref_lifetime = ntohl (pref_lifetime);
9971 /* Wait for a reply, return good/bad news */
9977 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
9979 unformat_input_t *i = vam->input;
9980 vl_api_sw_interface_ip6nd_ra_config_t *mp;
9982 u8 sw_if_index_set = 0;
9987 u8 send_unicast = 0;
9990 u8 default_router = 0;
9991 u32 max_interval = 0;
9992 u32 min_interval = 0;
9994 u32 initial_count = 0;
9995 u32 initial_interval = 0;
9999 /* Parse args required to build the message */
10000 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10002 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10003 sw_if_index_set = 1;
10004 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10005 sw_if_index_set = 1;
10006 else if (unformat (i, "maxint %d", &max_interval))
10008 else if (unformat (i, "minint %d", &min_interval))
10010 else if (unformat (i, "life %d", &lifetime))
10012 else if (unformat (i, "count %d", &initial_count))
10014 else if (unformat (i, "interval %d", &initial_interval))
10016 else if (unformat (i, "suppress") || unformat (i, "surpress"))
10018 else if (unformat (i, "managed"))
10020 else if (unformat (i, "other"))
10022 else if (unformat (i, "ll"))
10024 else if (unformat (i, "send"))
10026 else if (unformat (i, "cease"))
10028 else if (unformat (i, "isno"))
10030 else if (unformat (i, "def"))
10031 default_router = 1;
10034 clib_warning ("parse error '%U'", format_unformat_error, i);
10039 if (sw_if_index_set == 0)
10041 errmsg ("missing interface name or sw_if_index");
10045 /* Construct the API message */
10046 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
10048 mp->sw_if_index = ntohl (sw_if_index);
10049 mp->max_interval = ntohl (max_interval);
10050 mp->min_interval = ntohl (min_interval);
10051 mp->lifetime = ntohl (lifetime);
10052 mp->initial_count = ntohl (initial_count);
10053 mp->initial_interval = ntohl (initial_interval);
10054 mp->suppress = suppress;
10055 mp->managed = managed;
10057 mp->ll_option = ll_option;
10058 mp->send_unicast = send_unicast;
10061 mp->default_router = default_router;
10066 /* Wait for a reply, return good/bad news */
10072 api_set_arp_neighbor_limit (vat_main_t * vam)
10074 unformat_input_t *i = vam->input;
10075 vl_api_set_arp_neighbor_limit_t *mp;
10081 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10083 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
10085 else if (unformat (i, "ipv6"))
10089 clib_warning ("parse error '%U'", format_unformat_error, i);
10094 if (limit_set == 0)
10096 errmsg ("missing limit value");
10100 M (SET_ARP_NEIGHBOR_LIMIT, mp);
10102 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
10103 mp->is_ipv6 = is_ipv6;
10111 api_l2_patch_add_del (vat_main_t * vam)
10113 unformat_input_t *i = vam->input;
10114 vl_api_l2_patch_add_del_t *mp;
10115 u32 rx_sw_if_index;
10116 u8 rx_sw_if_index_set = 0;
10117 u32 tx_sw_if_index;
10118 u8 tx_sw_if_index_set = 0;
10122 /* Parse args required to build the message */
10123 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10125 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
10126 rx_sw_if_index_set = 1;
10127 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
10128 tx_sw_if_index_set = 1;
10129 else if (unformat (i, "rx"))
10131 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10133 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10135 rx_sw_if_index_set = 1;
10140 else if (unformat (i, "tx"))
10142 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10144 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10146 tx_sw_if_index_set = 1;
10151 else if (unformat (i, "del"))
10157 if (rx_sw_if_index_set == 0)
10159 errmsg ("missing rx interface name or rx_sw_if_index");
10163 if (tx_sw_if_index_set == 0)
10165 errmsg ("missing tx interface name or tx_sw_if_index");
10169 M (L2_PATCH_ADD_DEL, mp);
10171 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
10172 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
10173 mp->is_add = is_add;
10181 u8 localsid_addr[16];
10190 api_sr_localsid_add_del (vat_main_t * vam)
10192 unformat_input_t *i = vam->input;
10193 vl_api_sr_localsid_add_del_t *mp;
10196 ip6_address_t localsid;
10200 u32 fib_table = ~(u32) 0;
10201 ip6_address_t nh_addr6;
10202 ip4_address_t nh_addr4;
10203 clib_memset (&nh_addr6, 0, sizeof (ip6_address_t));
10204 clib_memset (&nh_addr4, 0, sizeof (ip4_address_t));
10206 bool nexthop_set = 0;
10210 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10212 if (unformat (i, "del"))
10214 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
10215 else if (unformat (i, "next-hop %U", unformat_ip4_address, &nh_addr4))
10217 else if (unformat (i, "next-hop %U", unformat_ip6_address, &nh_addr6))
10219 else if (unformat (i, "behavior %u", &behavior));
10220 else if (unformat (i, "sw_if_index %u", &sw_if_index));
10221 else if (unformat (i, "fib-table %u", &fib_table));
10222 else if (unformat (i, "end.psp %u", &behavior));
10227 M (SR_LOCALSID_ADD_DEL, mp);
10229 clib_memcpy (mp->localsid.addr, &localsid, sizeof (mp->localsid));
10232 clib_memcpy (mp->nh_addr6, &nh_addr6, sizeof (mp->nh_addr6));
10233 clib_memcpy (mp->nh_addr4, &nh_addr4, sizeof (mp->nh_addr4));
10235 mp->behavior = behavior;
10236 mp->sw_if_index = ntohl (sw_if_index);
10237 mp->fib_table = ntohl (fib_table);
10238 mp->end_psp = end_psp;
10239 mp->is_del = is_del;
10247 api_ioam_enable (vat_main_t * vam)
10249 unformat_input_t *input = vam->input;
10250 vl_api_ioam_enable_t *mp;
10252 int has_trace_option = 0;
10253 int has_pot_option = 0;
10254 int has_seqno_option = 0;
10255 int has_analyse_option = 0;
10258 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10260 if (unformat (input, "trace"))
10261 has_trace_option = 1;
10262 else if (unformat (input, "pot"))
10263 has_pot_option = 1;
10264 else if (unformat (input, "seqno"))
10265 has_seqno_option = 1;
10266 else if (unformat (input, "analyse"))
10267 has_analyse_option = 1;
10271 M (IOAM_ENABLE, mp);
10272 mp->id = htons (id);
10273 mp->seqno = has_seqno_option;
10274 mp->analyse = has_analyse_option;
10275 mp->pot_enable = has_pot_option;
10276 mp->trace_enable = has_trace_option;
10285 api_ioam_disable (vat_main_t * vam)
10287 vl_api_ioam_disable_t *mp;
10290 M (IOAM_DISABLE, mp);
10296 #define foreach_tcp_proto_field \
10300 #define foreach_udp_proto_field \
10304 #define foreach_ip4_proto_field \
10316 u16 src_port, dst_port;
10319 #if VPP_API_TEST_BUILTIN == 0
10321 unformat_tcp_mask (unformat_input_t * input, va_list * args)
10323 u8 **maskp = va_arg (*args, u8 **);
10325 u8 found_something = 0;
10328 #define _(a) u8 a=0;
10329 foreach_tcp_proto_field;
10332 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10335 #define _(a) else if (unformat (input, #a)) a=1;
10336 foreach_tcp_proto_field
10342 #define _(a) found_something += a;
10343 foreach_tcp_proto_field;
10346 if (found_something == 0)
10349 vec_validate (mask, sizeof (*tcp) - 1);
10351 tcp = (tcp_header_t *) mask;
10353 #define _(a) if (a) clib_memset (&tcp->a, 0xff, sizeof (tcp->a));
10354 foreach_tcp_proto_field;
10362 unformat_udp_mask (unformat_input_t * input, va_list * args)
10364 u8 **maskp = va_arg (*args, u8 **);
10366 u8 found_something = 0;
10369 #define _(a) u8 a=0;
10370 foreach_udp_proto_field;
10373 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10376 #define _(a) else if (unformat (input, #a)) a=1;
10377 foreach_udp_proto_field
10383 #define _(a) found_something += a;
10384 foreach_udp_proto_field;
10387 if (found_something == 0)
10390 vec_validate (mask, sizeof (*udp) - 1);
10392 udp = (udp_header_t *) mask;
10394 #define _(a) if (a) clib_memset (&udp->a, 0xff, sizeof (udp->a));
10395 foreach_udp_proto_field;
10403 unformat_l4_mask (unformat_input_t * input, va_list * args)
10405 u8 **maskp = va_arg (*args, u8 **);
10406 u16 src_port = 0, dst_port = 0;
10407 tcpudp_header_t *tcpudp;
10409 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10411 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
10413 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
10415 else if (unformat (input, "src_port"))
10417 else if (unformat (input, "dst_port"))
10423 if (!src_port && !dst_port)
10427 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
10429 tcpudp = (tcpudp_header_t *) mask;
10430 tcpudp->src_port = src_port;
10431 tcpudp->dst_port = dst_port;
10439 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10441 u8 **maskp = va_arg (*args, u8 **);
10443 u8 found_something = 0;
10446 #define _(a) u8 a=0;
10447 foreach_ip4_proto_field;
10453 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10455 if (unformat (input, "version"))
10457 else if (unformat (input, "hdr_length"))
10459 else if (unformat (input, "src"))
10461 else if (unformat (input, "dst"))
10463 else if (unformat (input, "proto"))
10466 #define _(a) else if (unformat (input, #a)) a=1;
10467 foreach_ip4_proto_field
10473 #define _(a) found_something += a;
10474 foreach_ip4_proto_field;
10477 if (found_something == 0)
10480 vec_validate (mask, sizeof (*ip) - 1);
10482 ip = (ip4_header_t *) mask;
10484 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
10485 foreach_ip4_proto_field;
10488 ip->ip_version_and_header_length = 0;
10491 ip->ip_version_and_header_length |= 0xF0;
10494 ip->ip_version_and_header_length |= 0x0F;
10500 #define foreach_ip6_proto_field \
10503 _(payload_length) \
10508 unformat_ip6_mask (unformat_input_t * input, va_list * args)
10510 u8 **maskp = va_arg (*args, u8 **);
10512 u8 found_something = 0;
10514 u32 ip_version_traffic_class_and_flow_label;
10516 #define _(a) u8 a=0;
10517 foreach_ip6_proto_field;
10520 u8 traffic_class = 0;
10523 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10525 if (unformat (input, "version"))
10527 else if (unformat (input, "traffic-class"))
10529 else if (unformat (input, "flow-label"))
10531 else if (unformat (input, "src"))
10533 else if (unformat (input, "dst"))
10535 else if (unformat (input, "proto"))
10538 #define _(a) else if (unformat (input, #a)) a=1;
10539 foreach_ip6_proto_field
10545 #define _(a) found_something += a;
10546 foreach_ip6_proto_field;
10549 if (found_something == 0)
10552 vec_validate (mask, sizeof (*ip) - 1);
10554 ip = (ip6_header_t *) mask;
10556 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
10557 foreach_ip6_proto_field;
10560 ip_version_traffic_class_and_flow_label = 0;
10563 ip_version_traffic_class_and_flow_label |= 0xF0000000;
10566 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
10569 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
10571 ip->ip_version_traffic_class_and_flow_label =
10572 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10579 unformat_l3_mask (unformat_input_t * input, va_list * args)
10581 u8 **maskp = va_arg (*args, u8 **);
10583 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10585 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
10587 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
10596 unformat_l2_mask (unformat_input_t * input, va_list * args)
10598 u8 **maskp = va_arg (*args, u8 **);
10605 u8 ignore_tag1 = 0;
10606 u8 ignore_tag2 = 0;
10613 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10615 if (unformat (input, "src"))
10617 else if (unformat (input, "dst"))
10619 else if (unformat (input, "proto"))
10621 else if (unformat (input, "tag1"))
10623 else if (unformat (input, "tag2"))
10625 else if (unformat (input, "ignore-tag1"))
10627 else if (unformat (input, "ignore-tag2"))
10629 else if (unformat (input, "cos1"))
10631 else if (unformat (input, "cos2"))
10633 else if (unformat (input, "dot1q"))
10635 else if (unformat (input, "dot1ad"))
10640 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
10641 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10644 if (tag1 || ignore_tag1 || cos1 || dot1q)
10646 if (tag2 || ignore_tag2 || cos2 || dot1ad)
10649 vec_validate (mask, len - 1);
10652 clib_memset (mask, 0xff, 6);
10655 clib_memset (mask + 6, 0xff, 6);
10657 if (tag2 || dot1ad)
10659 /* inner vlan tag */
10668 mask[21] = mask[20] = 0xff;
10689 mask[16] = mask[17] = 0xff;
10699 mask[12] = mask[13] = 0xff;
10706 unformat_classify_mask (unformat_input_t * input, va_list * args)
10708 u8 **maskp = va_arg (*args, u8 **);
10709 u32 *skipp = va_arg (*args, u32 *);
10710 u32 *matchp = va_arg (*args, u32 *);
10718 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10720 if (unformat (input, "hex %U", unformat_hex_string, &mask))
10722 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
10724 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
10726 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
10740 if (mask || l2 || l3 || l4)
10742 if (l2 || l3 || l4)
10744 /* "With a free Ethernet header in every package" */
10746 vec_validate (l2, 13);
10750 vec_append (mask, l3);
10755 vec_append (mask, l4);
10760 /* Scan forward looking for the first significant mask octet */
10761 for (i = 0; i < vec_len (mask); i++)
10765 /* compute (skip, match) params */
10766 *skipp = i / sizeof (u32x4);
10767 vec_delete (mask, *skipp * sizeof (u32x4), 0);
10769 /* Pad mask to an even multiple of the vector size */
10770 while (vec_len (mask) % sizeof (u32x4))
10771 vec_add1 (mask, 0);
10773 match = vec_len (mask) / sizeof (u32x4);
10775 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
10777 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
10778 if (*tmp || *(tmp + 1))
10783 clib_warning ("BUG: match 0");
10785 _vec_len (mask) = match * sizeof (u32x4);
10795 #endif /* VPP_API_TEST_BUILTIN */
10797 #define foreach_l2_next \
10799 _(ethernet, ETHERNET_INPUT) \
10800 _(ip4, IP4_INPUT) \
10804 unformat_l2_next_index (unformat_input_t * input, va_list * args)
10806 u32 *miss_next_indexp = va_arg (*args, u32 *);
10807 u32 next_index = 0;
10811 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
10815 if (unformat (input, "%d", &tmp))
10824 *miss_next_indexp = next_index;
10828 #define foreach_ip_next \
10831 _(rewrite, REWRITE)
10834 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
10836 u32 *miss_next_indexp = va_arg (*args, u32 *);
10837 u32 next_index = 0;
10841 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
10845 if (unformat (input, "%d", &tmp))
10854 *miss_next_indexp = next_index;
10858 #define foreach_acl_next \
10862 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
10864 u32 *miss_next_indexp = va_arg (*args, u32 *);
10865 u32 next_index = 0;
10869 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
10873 if (unformat (input, "permit"))
10878 else if (unformat (input, "%d", &tmp))
10887 *miss_next_indexp = next_index;
10892 unformat_policer_precolor (unformat_input_t * input, va_list * args)
10894 u32 *r = va_arg (*args, u32 *);
10896 if (unformat (input, "conform-color"))
10897 *r = POLICE_CONFORM;
10898 else if (unformat (input, "exceed-color"))
10899 *r = POLICE_EXCEED;
10907 api_classify_add_del_table (vat_main_t * vam)
10909 unformat_input_t *i = vam->input;
10910 vl_api_classify_add_del_table_t *mp;
10917 u32 table_index = ~0;
10918 u32 next_table_index = ~0;
10919 u32 miss_next_index = ~0;
10920 u32 memory_size = 32 << 20;
10922 u32 current_data_flag = 0;
10923 int current_data_offset = 0;
10926 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10928 if (unformat (i, "del"))
10930 else if (unformat (i, "del-chain"))
10935 else if (unformat (i, "buckets %d", &nbuckets))
10937 else if (unformat (i, "memory_size %d", &memory_size))
10939 else if (unformat (i, "skip %d", &skip))
10941 else if (unformat (i, "match %d", &match))
10943 else if (unformat (i, "table %d", &table_index))
10945 else if (unformat (i, "mask %U", unformat_classify_mask,
10946 &mask, &skip, &match))
10948 else if (unformat (i, "next-table %d", &next_table_index))
10950 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
10953 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
10956 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
10959 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
10961 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
10967 if (is_add && mask == 0)
10969 errmsg ("Mask required");
10973 if (is_add && skip == ~0)
10975 errmsg ("skip count required");
10979 if (is_add && match == ~0)
10981 errmsg ("match count required");
10985 if (!is_add && table_index == ~0)
10987 errmsg ("table index required for delete");
10991 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
10993 mp->is_add = is_add;
10994 mp->del_chain = del_chain;
10995 mp->table_index = ntohl (table_index);
10996 mp->nbuckets = ntohl (nbuckets);
10997 mp->memory_size = ntohl (memory_size);
10998 mp->skip_n_vectors = ntohl (skip);
10999 mp->match_n_vectors = ntohl (match);
11000 mp->next_table_index = ntohl (next_table_index);
11001 mp->miss_next_index = ntohl (miss_next_index);
11002 mp->current_data_flag = ntohl (current_data_flag);
11003 mp->current_data_offset = ntohl (current_data_offset);
11004 mp->mask_len = ntohl (vec_len (mask));
11005 clib_memcpy (mp->mask, mask, vec_len (mask));
11014 #if VPP_API_TEST_BUILTIN == 0
11016 unformat_l4_match (unformat_input_t * input, va_list * args)
11018 u8 **matchp = va_arg (*args, u8 **);
11020 u8 *proto_header = 0;
11026 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11028 if (unformat (input, "src_port %d", &src_port))
11030 else if (unformat (input, "dst_port %d", &dst_port))
11036 h.src_port = clib_host_to_net_u16 (src_port);
11037 h.dst_port = clib_host_to_net_u16 (dst_port);
11038 vec_validate (proto_header, sizeof (h) - 1);
11039 memcpy (proto_header, &h, sizeof (h));
11041 *matchp = proto_header;
11047 unformat_ip4_match (unformat_input_t * input, va_list * args)
11049 u8 **matchp = va_arg (*args, u8 **);
11054 int hdr_length = 0;
11055 u32 hdr_length_val;
11056 int src = 0, dst = 0;
11057 ip4_address_t src_val, dst_val;
11064 int fragment_id = 0;
11065 u32 fragment_id_val;
11071 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11073 if (unformat (input, "version %d", &version_val))
11075 else if (unformat (input, "hdr_length %d", &hdr_length_val))
11077 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
11079 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
11081 else if (unformat (input, "proto %d", &proto_val))
11083 else if (unformat (input, "tos %d", &tos_val))
11085 else if (unformat (input, "length %d", &length_val))
11087 else if (unformat (input, "fragment_id %d", &fragment_id_val))
11089 else if (unformat (input, "ttl %d", &ttl_val))
11091 else if (unformat (input, "checksum %d", &checksum_val))
11097 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
11098 + ttl + checksum == 0)
11102 * Aligned because we use the real comparison functions
11104 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11106 ip = (ip4_header_t *) match;
11108 /* These are realistically matched in practice */
11110 ip->src_address.as_u32 = src_val.as_u32;
11113 ip->dst_address.as_u32 = dst_val.as_u32;
11116 ip->protocol = proto_val;
11119 /* These are not, but they're included for completeness */
11121 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
11124 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
11130 ip->length = clib_host_to_net_u16 (length_val);
11136 ip->checksum = clib_host_to_net_u16 (checksum_val);
11143 unformat_ip6_match (unformat_input_t * input, va_list * args)
11145 u8 **matchp = va_arg (*args, u8 **);
11150 u8 traffic_class = 0;
11151 u32 traffic_class_val = 0;
11154 int src = 0, dst = 0;
11155 ip6_address_t src_val, dst_val;
11158 int payload_length = 0;
11159 u32 payload_length_val;
11162 u32 ip_version_traffic_class_and_flow_label;
11164 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11166 if (unformat (input, "version %d", &version_val))
11168 else if (unformat (input, "traffic_class %d", &traffic_class_val))
11170 else if (unformat (input, "flow_label %d", &flow_label_val))
11172 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
11174 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
11176 else if (unformat (input, "proto %d", &proto_val))
11178 else if (unformat (input, "payload_length %d", &payload_length_val))
11179 payload_length = 1;
11180 else if (unformat (input, "hop_limit %d", &hop_limit_val))
11186 if (version + traffic_class + flow_label + src + dst + proto +
11187 payload_length + hop_limit == 0)
11191 * Aligned because we use the real comparison functions
11193 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11195 ip = (ip6_header_t *) match;
11198 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
11201 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
11204 ip->protocol = proto_val;
11206 ip_version_traffic_class_and_flow_label = 0;
11209 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
11212 ip_version_traffic_class_and_flow_label |=
11213 (traffic_class_val & 0xFF) << 20;
11216 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
11218 ip->ip_version_traffic_class_and_flow_label =
11219 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11221 if (payload_length)
11222 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
11225 ip->hop_limit = hop_limit_val;
11232 unformat_l3_match (unformat_input_t * input, va_list * args)
11234 u8 **matchp = va_arg (*args, u8 **);
11236 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11238 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
11240 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
11249 unformat_vlan_tag (unformat_input_t * input, va_list * args)
11251 u8 *tagp = va_arg (*args, u8 *);
11254 if (unformat (input, "%d", &tag))
11256 tagp[0] = (tag >> 8) & 0x0F;
11257 tagp[1] = tag & 0xFF;
11265 unformat_l2_match (unformat_input_t * input, va_list * args)
11267 u8 **matchp = va_arg (*args, u8 **);
11280 u8 ignore_tag1 = 0;
11281 u8 ignore_tag2 = 0;
11287 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11289 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
11292 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
11294 else if (unformat (input, "proto %U",
11295 unformat_ethernet_type_host_byte_order, &proto_val))
11297 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
11299 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
11301 else if (unformat (input, "ignore-tag1"))
11303 else if (unformat (input, "ignore-tag2"))
11305 else if (unformat (input, "cos1 %d", &cos1_val))
11307 else if (unformat (input, "cos2 %d", &cos2_val))
11312 if ((src + dst + proto + tag1 + tag2 +
11313 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11316 if (tag1 || ignore_tag1 || cos1)
11318 if (tag2 || ignore_tag2 || cos2)
11321 vec_validate_aligned (match, len - 1, sizeof (u32x4));
11324 clib_memcpy (match, dst_val, 6);
11327 clib_memcpy (match + 6, src_val, 6);
11331 /* inner vlan tag */
11332 match[19] = tag2_val[1];
11333 match[18] = tag2_val[0];
11335 match[18] |= (cos2_val & 0x7) << 5;
11338 match[21] = proto_val & 0xff;
11339 match[20] = proto_val >> 8;
11343 match[15] = tag1_val[1];
11344 match[14] = tag1_val[0];
11347 match[14] |= (cos1_val & 0x7) << 5;
11353 match[15] = tag1_val[1];
11354 match[14] = tag1_val[0];
11357 match[17] = proto_val & 0xff;
11358 match[16] = proto_val >> 8;
11361 match[14] |= (cos1_val & 0x7) << 5;
11367 match[18] |= (cos2_val & 0x7) << 5;
11369 match[14] |= (cos1_val & 0x7) << 5;
11372 match[13] = proto_val & 0xff;
11373 match[12] = proto_val >> 8;
11381 unformat_qos_source (unformat_input_t * input, va_list * args)
11383 int *qs = va_arg (*args, int *);
11385 if (unformat (input, "ip"))
11386 *qs = QOS_SOURCE_IP;
11387 else if (unformat (input, "mpls"))
11388 *qs = QOS_SOURCE_MPLS;
11389 else if (unformat (input, "ext"))
11390 *qs = QOS_SOURCE_EXT;
11391 else if (unformat (input, "vlan"))
11392 *qs = QOS_SOURCE_VLAN;
11401 api_unformat_classify_match (unformat_input_t * input, va_list * args)
11403 u8 **matchp = va_arg (*args, u8 **);
11404 u32 skip_n_vectors = va_arg (*args, u32);
11405 u32 match_n_vectors = va_arg (*args, u32);
11412 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11414 if (unformat (input, "hex %U", unformat_hex_string, &match))
11416 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
11418 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
11420 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11434 if (match || l2 || l3 || l4)
11436 if (l2 || l3 || l4)
11438 /* "Win a free Ethernet header in every packet" */
11440 vec_validate_aligned (l2, 13, sizeof (u32x4));
11444 vec_append_aligned (match, l3, sizeof (u32x4));
11449 vec_append_aligned (match, l4, sizeof (u32x4));
11454 /* Make sure the vector is big enough even if key is all 0's */
11455 vec_validate_aligned
11456 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11459 /* Set size, include skipped vectors */
11460 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11471 api_classify_add_del_session (vat_main_t * vam)
11473 unformat_input_t *i = vam->input;
11474 vl_api_classify_add_del_session_t *mp;
11476 u32 table_index = ~0;
11477 u32 hit_next_index = ~0;
11478 u32 opaque_index = ~0;
11481 u32 skip_n_vectors = 0;
11482 u32 match_n_vectors = 0;
11488 * Warning: you have to supply skip_n and match_n
11489 * because the API client cant simply look at the classify
11493 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11495 if (unformat (i, "del"))
11497 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
11500 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
11503 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
11506 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
11508 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
11510 else if (unformat (i, "opaque-index %d", &opaque_index))
11512 else if (unformat (i, "skip_n %d", &skip_n_vectors))
11514 else if (unformat (i, "match_n %d", &match_n_vectors))
11516 else if (unformat (i, "match %U", api_unformat_classify_match,
11517 &match, skip_n_vectors, match_n_vectors))
11519 else if (unformat (i, "advance %d", &advance))
11521 else if (unformat (i, "table-index %d", &table_index))
11523 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
11525 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
11527 else if (unformat (i, "action %d", &action))
11529 else if (unformat (i, "metadata %d", &metadata))
11535 if (table_index == ~0)
11537 errmsg ("Table index required");
11541 if (is_add && match == 0)
11543 errmsg ("Match value required");
11547 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
11549 mp->is_add = is_add;
11550 mp->table_index = ntohl (table_index);
11551 mp->hit_next_index = ntohl (hit_next_index);
11552 mp->opaque_index = ntohl (opaque_index);
11553 mp->advance = ntohl (advance);
11554 mp->action = action;
11555 mp->metadata = ntohl (metadata);
11556 mp->match_len = ntohl (vec_len (match));
11557 clib_memcpy (mp->match, match, vec_len (match));
11566 api_classify_set_interface_ip_table (vat_main_t * vam)
11568 unformat_input_t *i = vam->input;
11569 vl_api_classify_set_interface_ip_table_t *mp;
11571 int sw_if_index_set;
11572 u32 table_index = ~0;
11576 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11578 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11579 sw_if_index_set = 1;
11580 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11581 sw_if_index_set = 1;
11582 else if (unformat (i, "table %d", &table_index))
11586 clib_warning ("parse error '%U'", format_unformat_error, i);
11591 if (sw_if_index_set == 0)
11593 errmsg ("missing interface name or sw_if_index");
11598 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
11600 mp->sw_if_index = ntohl (sw_if_index);
11601 mp->table_index = ntohl (table_index);
11602 mp->is_ipv6 = is_ipv6;
11610 api_classify_set_interface_l2_tables (vat_main_t * vam)
11612 unformat_input_t *i = vam->input;
11613 vl_api_classify_set_interface_l2_tables_t *mp;
11615 int sw_if_index_set;
11616 u32 ip4_table_index = ~0;
11617 u32 ip6_table_index = ~0;
11618 u32 other_table_index = ~0;
11622 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11624 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11625 sw_if_index_set = 1;
11626 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11627 sw_if_index_set = 1;
11628 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11630 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11632 else if (unformat (i, "other-table %d", &other_table_index))
11634 else if (unformat (i, "is-input %d", &is_input))
11638 clib_warning ("parse error '%U'", format_unformat_error, i);
11643 if (sw_if_index_set == 0)
11645 errmsg ("missing interface name or sw_if_index");
11650 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
11652 mp->sw_if_index = ntohl (sw_if_index);
11653 mp->ip4_table_index = ntohl (ip4_table_index);
11654 mp->ip6_table_index = ntohl (ip6_table_index);
11655 mp->other_table_index = ntohl (other_table_index);
11656 mp->is_input = (u8) is_input;
11664 api_set_ipfix_exporter (vat_main_t * vam)
11666 unformat_input_t *i = vam->input;
11667 vl_api_set_ipfix_exporter_t *mp;
11668 ip4_address_t collector_address;
11669 u8 collector_address_set = 0;
11670 u32 collector_port = ~0;
11671 ip4_address_t src_address;
11672 u8 src_address_set = 0;
11675 u32 template_interval = ~0;
11676 u8 udp_checksum = 0;
11679 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11681 if (unformat (i, "collector_address %U", unformat_ip4_address,
11682 &collector_address))
11683 collector_address_set = 1;
11684 else if (unformat (i, "collector_port %d", &collector_port))
11686 else if (unformat (i, "src_address %U", unformat_ip4_address,
11688 src_address_set = 1;
11689 else if (unformat (i, "vrf_id %d", &vrf_id))
11691 else if (unformat (i, "path_mtu %d", &path_mtu))
11693 else if (unformat (i, "template_interval %d", &template_interval))
11695 else if (unformat (i, "udp_checksum"))
11701 if (collector_address_set == 0)
11703 errmsg ("collector_address required");
11707 if (src_address_set == 0)
11709 errmsg ("src_address required");
11713 M (SET_IPFIX_EXPORTER, mp);
11715 memcpy (mp->collector_address, collector_address.data,
11716 sizeof (collector_address.data));
11717 mp->collector_port = htons ((u16) collector_port);
11718 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
11719 mp->vrf_id = htonl (vrf_id);
11720 mp->path_mtu = htonl (path_mtu);
11721 mp->template_interval = htonl (template_interval);
11722 mp->udp_checksum = udp_checksum;
11730 api_set_ipfix_classify_stream (vat_main_t * vam)
11732 unformat_input_t *i = vam->input;
11733 vl_api_set_ipfix_classify_stream_t *mp;
11735 u32 src_port = UDP_DST_PORT_ipfix;
11738 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11740 if (unformat (i, "domain %d", &domain_id))
11742 else if (unformat (i, "src_port %d", &src_port))
11746 errmsg ("unknown input `%U'", format_unformat_error, i);
11751 M (SET_IPFIX_CLASSIFY_STREAM, mp);
11753 mp->domain_id = htonl (domain_id);
11754 mp->src_port = htons ((u16) src_port);
11762 api_ipfix_classify_table_add_del (vat_main_t * vam)
11764 unformat_input_t *i = vam->input;
11765 vl_api_ipfix_classify_table_add_del_t *mp;
11767 u32 classify_table_index = ~0;
11769 u8 transport_protocol = 255;
11772 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11774 if (unformat (i, "add"))
11776 else if (unformat (i, "del"))
11778 else if (unformat (i, "table %d", &classify_table_index))
11780 else if (unformat (i, "ip4"))
11782 else if (unformat (i, "ip6"))
11784 else if (unformat (i, "tcp"))
11785 transport_protocol = 6;
11786 else if (unformat (i, "udp"))
11787 transport_protocol = 17;
11790 errmsg ("unknown input `%U'", format_unformat_error, i);
11797 errmsg ("expecting: add|del");
11800 if (classify_table_index == ~0)
11802 errmsg ("classifier table not specified");
11805 if (ip_version == 0)
11807 errmsg ("IP version not specified");
11811 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
11813 mp->is_add = is_add;
11814 mp->table_id = htonl (classify_table_index);
11815 mp->ip_version = ip_version;
11816 mp->transport_protocol = transport_protocol;
11824 api_get_node_index (vat_main_t * vam)
11826 unformat_input_t *i = vam->input;
11827 vl_api_get_node_index_t *mp;
11831 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11833 if (unformat (i, "node %s", &name))
11840 errmsg ("node name required");
11843 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11845 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11849 M (GET_NODE_INDEX, mp);
11850 clib_memcpy (mp->node_name, name, vec_len (name));
11859 api_get_next_index (vat_main_t * vam)
11861 unformat_input_t *i = vam->input;
11862 vl_api_get_next_index_t *mp;
11863 u8 *node_name = 0, *next_node_name = 0;
11866 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11868 if (unformat (i, "node-name %s", &node_name))
11870 else if (unformat (i, "next-node-name %s", &next_node_name))
11874 if (node_name == 0)
11876 errmsg ("node name required");
11879 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
11881 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11885 if (next_node_name == 0)
11887 errmsg ("next node name required");
11890 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
11892 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
11896 M (GET_NEXT_INDEX, mp);
11897 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
11898 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
11899 vec_free (node_name);
11900 vec_free (next_node_name);
11908 api_add_node_next (vat_main_t * vam)
11910 unformat_input_t *i = vam->input;
11911 vl_api_add_node_next_t *mp;
11916 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11918 if (unformat (i, "node %s", &name))
11920 else if (unformat (i, "next %s", &next))
11927 errmsg ("node name required");
11930 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11932 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11937 errmsg ("next node required");
11940 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
11942 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
11946 M (ADD_NODE_NEXT, mp);
11947 clib_memcpy (mp->node_name, name, vec_len (name));
11948 clib_memcpy (mp->next_name, next, vec_len (next));
11958 api_l2tpv3_create_tunnel (vat_main_t * vam)
11960 unformat_input_t *i = vam->input;
11961 ip6_address_t client_address, our_address;
11962 int client_address_set = 0;
11963 int our_address_set = 0;
11964 u32 local_session_id = 0;
11965 u32 remote_session_id = 0;
11966 u64 local_cookie = 0;
11967 u64 remote_cookie = 0;
11968 u8 l2_sublayer_present = 0;
11969 vl_api_l2tpv3_create_tunnel_t *mp;
11972 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11974 if (unformat (i, "client_address %U", unformat_ip6_address,
11976 client_address_set = 1;
11977 else if (unformat (i, "our_address %U", unformat_ip6_address,
11979 our_address_set = 1;
11980 else if (unformat (i, "local_session_id %d", &local_session_id))
11982 else if (unformat (i, "remote_session_id %d", &remote_session_id))
11984 else if (unformat (i, "local_cookie %lld", &local_cookie))
11986 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
11988 else if (unformat (i, "l2-sublayer-present"))
11989 l2_sublayer_present = 1;
11994 if (client_address_set == 0)
11996 errmsg ("client_address required");
12000 if (our_address_set == 0)
12002 errmsg ("our_address required");
12006 M (L2TPV3_CREATE_TUNNEL, mp);
12008 clib_memcpy (mp->client_address, client_address.as_u8,
12009 sizeof (mp->client_address));
12011 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
12013 mp->local_session_id = ntohl (local_session_id);
12014 mp->remote_session_id = ntohl (remote_session_id);
12015 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
12016 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
12017 mp->l2_sublayer_present = l2_sublayer_present;
12026 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
12028 unformat_input_t *i = vam->input;
12030 u8 sw_if_index_set = 0;
12031 u64 new_local_cookie = 0;
12032 u64 new_remote_cookie = 0;
12033 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
12036 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12038 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12039 sw_if_index_set = 1;
12040 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12041 sw_if_index_set = 1;
12042 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
12044 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
12050 if (sw_if_index_set == 0)
12052 errmsg ("missing interface name or sw_if_index");
12056 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
12058 mp->sw_if_index = ntohl (sw_if_index);
12059 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
12060 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
12068 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
12070 unformat_input_t *i = vam->input;
12071 vl_api_l2tpv3_interface_enable_disable_t *mp;
12073 u8 sw_if_index_set = 0;
12074 u8 enable_disable = 1;
12077 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12079 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12080 sw_if_index_set = 1;
12081 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12082 sw_if_index_set = 1;
12083 else if (unformat (i, "enable"))
12084 enable_disable = 1;
12085 else if (unformat (i, "disable"))
12086 enable_disable = 0;
12091 if (sw_if_index_set == 0)
12093 errmsg ("missing interface name or sw_if_index");
12097 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
12099 mp->sw_if_index = ntohl (sw_if_index);
12100 mp->enable_disable = enable_disable;
12108 api_l2tpv3_set_lookup_key (vat_main_t * vam)
12110 unformat_input_t *i = vam->input;
12111 vl_api_l2tpv3_set_lookup_key_t *mp;
12115 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12117 if (unformat (i, "lookup_v6_src"))
12118 key = L2T_LOOKUP_SRC_ADDRESS;
12119 else if (unformat (i, "lookup_v6_dst"))
12120 key = L2T_LOOKUP_DST_ADDRESS;
12121 else if (unformat (i, "lookup_session_id"))
12122 key = L2T_LOOKUP_SESSION_ID;
12127 if (key == (u8) ~ 0)
12129 errmsg ("l2tp session lookup key unset");
12133 M (L2TPV3_SET_LOOKUP_KEY, mp);
12142 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
12143 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12145 vat_main_t *vam = &vat_main;
12147 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
12148 format_ip6_address, mp->our_address,
12149 format_ip6_address, mp->client_address,
12150 clib_net_to_host_u32 (mp->sw_if_index));
12153 " local cookies %016llx %016llx remote cookie %016llx",
12154 clib_net_to_host_u64 (mp->local_cookie[0]),
12155 clib_net_to_host_u64 (mp->local_cookie[1]),
12156 clib_net_to_host_u64 (mp->remote_cookie));
12158 print (vam->ofp, " local session-id %d remote session-id %d",
12159 clib_net_to_host_u32 (mp->local_session_id),
12160 clib_net_to_host_u32 (mp->remote_session_id));
12162 print (vam->ofp, " l2 specific sublayer %s\n",
12163 mp->l2_sublayer_present ? "preset" : "absent");
12167 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
12168 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12170 vat_main_t *vam = &vat_main;
12171 vat_json_node_t *node = NULL;
12172 struct in6_addr addr;
12174 if (VAT_JSON_ARRAY != vam->json_tree.type)
12176 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12177 vat_json_init_array (&vam->json_tree);
12179 node = vat_json_array_add (&vam->json_tree);
12181 vat_json_init_object (node);
12183 clib_memcpy (&addr, mp->our_address, sizeof (addr));
12184 vat_json_object_add_ip6 (node, "our_address", addr);
12185 clib_memcpy (&addr, mp->client_address, sizeof (addr));
12186 vat_json_object_add_ip6 (node, "client_address", addr);
12188 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
12189 vat_json_init_array (lc);
12190 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
12191 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
12192 vat_json_object_add_uint (node, "remote_cookie",
12193 clib_net_to_host_u64 (mp->remote_cookie));
12195 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
12196 vat_json_object_add_uint (node, "local_session_id",
12197 clib_net_to_host_u32 (mp->local_session_id));
12198 vat_json_object_add_uint (node, "remote_session_id",
12199 clib_net_to_host_u32 (mp->remote_session_id));
12200 vat_json_object_add_string_copy (node, "l2_sublayer",
12201 mp->l2_sublayer_present ? (u8 *) "present"
12202 : (u8 *) "absent");
12206 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
12208 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
12209 vl_api_control_ping_t *mp_ping;
12212 /* Get list of l2tpv3-tunnel interfaces */
12213 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
12216 /* Use a control ping for synchronization */
12217 MPING (CONTROL_PING, mp_ping);
12225 static void vl_api_sw_interface_tap_v2_details_t_handler
12226 (vl_api_sw_interface_tap_v2_details_t * mp)
12228 vat_main_t *vam = &vat_main;
12230 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
12231 mp->host_ip4_prefix_len);
12232 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
12233 mp->host_ip6_prefix_len);
12236 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s 0x%-08x",
12237 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
12238 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12239 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
12240 mp->host_bridge, ip4, ip6, ntohl (mp->tap_flags));
12246 static void vl_api_sw_interface_tap_v2_details_t_handler_json
12247 (vl_api_sw_interface_tap_v2_details_t * mp)
12249 vat_main_t *vam = &vat_main;
12250 vat_json_node_t *node = NULL;
12252 if (VAT_JSON_ARRAY != vam->json_tree.type)
12254 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12255 vat_json_init_array (&vam->json_tree);
12257 node = vat_json_array_add (&vam->json_tree);
12259 vat_json_init_object (node);
12260 vat_json_object_add_uint (node, "id", ntohl (mp->id));
12261 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12262 vat_json_object_add_uint (node, "tap_flags", ntohl (mp->tap_flags));
12263 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12264 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12265 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12266 vat_json_object_add_string_copy (node, "host_mac_addr",
12267 format (0, "%U", format_ethernet_address,
12268 &mp->host_mac_addr));
12269 vat_json_object_add_string_copy (node, "host_namespace",
12270 mp->host_namespace);
12271 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
12272 vat_json_object_add_string_copy (node, "host_ip4_addr",
12273 format (0, "%U/%d", format_ip4_address,
12275 mp->host_ip4_prefix_len));
12276 vat_json_object_add_string_copy (node, "host_ip6_addr",
12277 format (0, "%U/%d", format_ip6_address,
12279 mp->host_ip6_prefix_len));
12284 api_sw_interface_tap_v2_dump (vat_main_t * vam)
12286 vl_api_sw_interface_tap_v2_dump_t *mp;
12287 vl_api_control_ping_t *mp_ping;
12291 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
12292 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
12293 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
12296 /* Get list of tap interfaces */
12297 M (SW_INTERFACE_TAP_V2_DUMP, mp);
12300 /* Use a control ping for synchronization */
12301 MPING (CONTROL_PING, mp_ping);
12308 static void vl_api_sw_interface_virtio_pci_details_t_handler
12309 (vl_api_sw_interface_virtio_pci_details_t * mp)
12311 vat_main_t *vam = &vat_main;
12325 addr.as_u32 = ntohl (mp->pci_addr);
12326 u8 *pci_addr = format (0, "%04x:%02x:%02x.%x", addr.domain, addr.bus,
12327 addr.slot, addr.function);
12330 "\n%-12s %-12d %-12d %-12d %-17U 0x%-08llx",
12331 pci_addr, ntohl (mp->sw_if_index),
12332 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12333 format_ethernet_address, mp->mac_addr,
12334 clib_net_to_host_u64 (mp->features));
12335 vec_free (pci_addr);
12338 static void vl_api_sw_interface_virtio_pci_details_t_handler_json
12339 (vl_api_sw_interface_virtio_pci_details_t * mp)
12341 vat_main_t *vam = &vat_main;
12342 vat_json_node_t *node = NULL;
12344 if (VAT_JSON_ARRAY != vam->json_tree.type)
12346 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12347 vat_json_init_array (&vam->json_tree);
12349 node = vat_json_array_add (&vam->json_tree);
12351 vat_json_init_object (node);
12352 vat_json_object_add_uint (node, "pci-addr", ntohl (mp->pci_addr));
12353 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12354 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12355 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12356 vat_json_object_add_uint (node, "features",
12357 clib_net_to_host_u64 (mp->features));
12358 vat_json_object_add_string_copy (node, "mac_addr",
12359 format (0, "%U", format_ethernet_address,
12364 api_sw_interface_virtio_pci_dump (vat_main_t * vam)
12366 vl_api_sw_interface_virtio_pci_dump_t *mp;
12367 vl_api_control_ping_t *mp_ping;
12371 "\n%-12s %-12s %-12s %-12s %-17s %-08s",
12372 "pci_addr", "sw_if_index", "rx_ring_sz", "tx_ring_sz",
12373 "mac_addr", "features");
12375 /* Get list of tap interfaces */
12376 M (SW_INTERFACE_VIRTIO_PCI_DUMP, mp);
12379 /* Use a control ping for synchronization */
12380 MPING (CONTROL_PING, mp_ping);
12388 api_vxlan_offload_rx (vat_main_t * vam)
12390 unformat_input_t *line_input = vam->input;
12391 vl_api_vxlan_offload_rx_t *mp;
12392 u32 hw_if_index = ~0, rx_if_index = ~0;
12396 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12398 if (unformat (line_input, "del"))
12400 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
12403 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
12405 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
12408 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
12412 errmsg ("parse error '%U'", format_unformat_error, line_input);
12417 if (hw_if_index == ~0)
12419 errmsg ("no hw interface");
12423 if (rx_if_index == ~0)
12425 errmsg ("no rx tunnel");
12429 M (VXLAN_OFFLOAD_RX, mp);
12431 mp->hw_if_index = ntohl (hw_if_index);
12432 mp->sw_if_index = ntohl (rx_if_index);
12433 mp->enable = is_add;
12440 static uword unformat_vxlan_decap_next
12441 (unformat_input_t * input, va_list * args)
12443 u32 *result = va_arg (*args, u32 *);
12446 if (unformat (input, "l2"))
12447 *result = VXLAN_INPUT_NEXT_L2_INPUT;
12448 else if (unformat (input, "%d", &tmp))
12456 api_vxlan_add_del_tunnel (vat_main_t * vam)
12458 unformat_input_t *line_input = vam->input;
12459 vl_api_vxlan_add_del_tunnel_t *mp;
12460 ip46_address_t src, dst;
12462 u8 ipv4_set = 0, ipv6_set = 0;
12467 u32 mcast_sw_if_index = ~0;
12468 u32 encap_vrf_id = 0;
12469 u32 decap_next_index = ~0;
12473 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12474 clib_memset (&src, 0, sizeof src);
12475 clib_memset (&dst, 0, sizeof dst);
12477 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12479 if (unformat (line_input, "del"))
12481 else if (unformat (line_input, "instance %d", &instance))
12484 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12490 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12496 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12502 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12507 else if (unformat (line_input, "group %U %U",
12508 unformat_ip4_address, &dst.ip4,
12509 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12511 grp_set = dst_set = 1;
12514 else if (unformat (line_input, "group %U",
12515 unformat_ip4_address, &dst.ip4))
12517 grp_set = dst_set = 1;
12520 else if (unformat (line_input, "group %U %U",
12521 unformat_ip6_address, &dst.ip6,
12522 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12524 grp_set = dst_set = 1;
12527 else if (unformat (line_input, "group %U",
12528 unformat_ip6_address, &dst.ip6))
12530 grp_set = dst_set = 1;
12534 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12536 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12538 else if (unformat (line_input, "decap-next %U",
12539 unformat_vxlan_decap_next, &decap_next_index))
12541 else if (unformat (line_input, "vni %d", &vni))
12545 errmsg ("parse error '%U'", format_unformat_error, line_input);
12552 errmsg ("tunnel src address not specified");
12557 errmsg ("tunnel dst address not specified");
12561 if (grp_set && !ip46_address_is_multicast (&dst))
12563 errmsg ("tunnel group address not multicast");
12566 if (grp_set && mcast_sw_if_index == ~0)
12568 errmsg ("tunnel nonexistent multicast device");
12571 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12573 errmsg ("tunnel dst address must be unicast");
12578 if (ipv4_set && ipv6_set)
12580 errmsg ("both IPv4 and IPv6 addresses specified");
12584 if ((vni == 0) || (vni >> 24))
12586 errmsg ("vni not specified or out of range");
12590 M (VXLAN_ADD_DEL_TUNNEL, mp);
12594 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
12595 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
12599 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
12600 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
12603 mp->instance = htonl (instance);
12604 mp->encap_vrf_id = ntohl (encap_vrf_id);
12605 mp->decap_next_index = ntohl (decap_next_index);
12606 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12607 mp->vni = ntohl (vni);
12608 mp->is_add = is_add;
12609 mp->is_ipv6 = ipv6_set;
12616 static void vl_api_vxlan_tunnel_details_t_handler
12617 (vl_api_vxlan_tunnel_details_t * mp)
12619 vat_main_t *vam = &vat_main;
12620 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12621 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12623 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
12624 ntohl (mp->sw_if_index),
12625 ntohl (mp->instance),
12626 format_ip46_address, &src, IP46_TYPE_ANY,
12627 format_ip46_address, &dst, IP46_TYPE_ANY,
12628 ntohl (mp->encap_vrf_id),
12629 ntohl (mp->decap_next_index), ntohl (mp->vni),
12630 ntohl (mp->mcast_sw_if_index));
12633 static void vl_api_vxlan_tunnel_details_t_handler_json
12634 (vl_api_vxlan_tunnel_details_t * mp)
12636 vat_main_t *vam = &vat_main;
12637 vat_json_node_t *node = NULL;
12639 if (VAT_JSON_ARRAY != vam->json_tree.type)
12641 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12642 vat_json_init_array (&vam->json_tree);
12644 node = vat_json_array_add (&vam->json_tree);
12646 vat_json_init_object (node);
12647 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12649 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
12653 struct in6_addr ip6;
12655 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12656 vat_json_object_add_ip6 (node, "src_address", ip6);
12657 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12658 vat_json_object_add_ip6 (node, "dst_address", ip6);
12662 struct in_addr ip4;
12664 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12665 vat_json_object_add_ip4 (node, "src_address", ip4);
12666 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12667 vat_json_object_add_ip4 (node, "dst_address", ip4);
12669 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12670 vat_json_object_add_uint (node, "decap_next_index",
12671 ntohl (mp->decap_next_index));
12672 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12673 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12674 vat_json_object_add_uint (node, "mcast_sw_if_index",
12675 ntohl (mp->mcast_sw_if_index));
12679 api_vxlan_tunnel_dump (vat_main_t * vam)
12681 unformat_input_t *i = vam->input;
12682 vl_api_vxlan_tunnel_dump_t *mp;
12683 vl_api_control_ping_t *mp_ping;
12685 u8 sw_if_index_set = 0;
12688 /* Parse args required to build the message */
12689 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12691 if (unformat (i, "sw_if_index %d", &sw_if_index))
12692 sw_if_index_set = 1;
12697 if (sw_if_index_set == 0)
12702 if (!vam->json_output)
12704 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
12705 "sw_if_index", "instance", "src_address", "dst_address",
12706 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12709 /* Get list of vxlan-tunnel interfaces */
12710 M (VXLAN_TUNNEL_DUMP, mp);
12712 mp->sw_if_index = htonl (sw_if_index);
12716 /* Use a control ping for synchronization */
12717 MPING (CONTROL_PING, mp_ping);
12724 static uword unformat_geneve_decap_next
12725 (unformat_input_t * input, va_list * args)
12727 u32 *result = va_arg (*args, u32 *);
12730 if (unformat (input, "l2"))
12731 *result = GENEVE_INPUT_NEXT_L2_INPUT;
12732 else if (unformat (input, "%d", &tmp))
12740 api_geneve_add_del_tunnel (vat_main_t * vam)
12742 unformat_input_t *line_input = vam->input;
12743 vl_api_geneve_add_del_tunnel_t *mp;
12744 ip46_address_t src, dst;
12746 u8 ipv4_set = 0, ipv6_set = 0;
12750 u32 mcast_sw_if_index = ~0;
12751 u32 encap_vrf_id = 0;
12752 u32 decap_next_index = ~0;
12756 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12757 clib_memset (&src, 0, sizeof src);
12758 clib_memset (&dst, 0, sizeof dst);
12760 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12762 if (unformat (line_input, "del"))
12765 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12771 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12777 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12783 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12788 else if (unformat (line_input, "group %U %U",
12789 unformat_ip4_address, &dst.ip4,
12790 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12792 grp_set = dst_set = 1;
12795 else if (unformat (line_input, "group %U",
12796 unformat_ip4_address, &dst.ip4))
12798 grp_set = dst_set = 1;
12801 else if (unformat (line_input, "group %U %U",
12802 unformat_ip6_address, &dst.ip6,
12803 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12805 grp_set = dst_set = 1;
12808 else if (unformat (line_input, "group %U",
12809 unformat_ip6_address, &dst.ip6))
12811 grp_set = dst_set = 1;
12815 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12817 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12819 else if (unformat (line_input, "decap-next %U",
12820 unformat_geneve_decap_next, &decap_next_index))
12822 else if (unformat (line_input, "vni %d", &vni))
12826 errmsg ("parse error '%U'", format_unformat_error, line_input);
12833 errmsg ("tunnel src address not specified");
12838 errmsg ("tunnel dst address not specified");
12842 if (grp_set && !ip46_address_is_multicast (&dst))
12844 errmsg ("tunnel group address not multicast");
12847 if (grp_set && mcast_sw_if_index == ~0)
12849 errmsg ("tunnel nonexistent multicast device");
12852 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12854 errmsg ("tunnel dst address must be unicast");
12859 if (ipv4_set && ipv6_set)
12861 errmsg ("both IPv4 and IPv6 addresses specified");
12865 if ((vni == 0) || (vni >> 24))
12867 errmsg ("vni not specified or out of range");
12871 M (GENEVE_ADD_DEL_TUNNEL, mp);
12875 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
12876 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
12880 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
12881 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
12883 mp->encap_vrf_id = ntohl (encap_vrf_id);
12884 mp->decap_next_index = ntohl (decap_next_index);
12885 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12886 mp->vni = ntohl (vni);
12887 mp->is_add = is_add;
12888 mp->is_ipv6 = ipv6_set;
12895 static void vl_api_geneve_tunnel_details_t_handler
12896 (vl_api_geneve_tunnel_details_t * mp)
12898 vat_main_t *vam = &vat_main;
12899 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12900 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12902 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12903 ntohl (mp->sw_if_index),
12904 format_ip46_address, &src, IP46_TYPE_ANY,
12905 format_ip46_address, &dst, IP46_TYPE_ANY,
12906 ntohl (mp->encap_vrf_id),
12907 ntohl (mp->decap_next_index), ntohl (mp->vni),
12908 ntohl (mp->mcast_sw_if_index));
12911 static void vl_api_geneve_tunnel_details_t_handler_json
12912 (vl_api_geneve_tunnel_details_t * mp)
12914 vat_main_t *vam = &vat_main;
12915 vat_json_node_t *node = NULL;
12917 if (VAT_JSON_ARRAY != vam->json_tree.type)
12919 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12920 vat_json_init_array (&vam->json_tree);
12922 node = vat_json_array_add (&vam->json_tree);
12924 vat_json_init_object (node);
12925 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12928 struct in6_addr ip6;
12930 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12931 vat_json_object_add_ip6 (node, "src_address", ip6);
12932 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12933 vat_json_object_add_ip6 (node, "dst_address", ip6);
12937 struct in_addr ip4;
12939 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12940 vat_json_object_add_ip4 (node, "src_address", ip4);
12941 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12942 vat_json_object_add_ip4 (node, "dst_address", ip4);
12944 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12945 vat_json_object_add_uint (node, "decap_next_index",
12946 ntohl (mp->decap_next_index));
12947 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12948 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12949 vat_json_object_add_uint (node, "mcast_sw_if_index",
12950 ntohl (mp->mcast_sw_if_index));
12954 api_geneve_tunnel_dump (vat_main_t * vam)
12956 unformat_input_t *i = vam->input;
12957 vl_api_geneve_tunnel_dump_t *mp;
12958 vl_api_control_ping_t *mp_ping;
12960 u8 sw_if_index_set = 0;
12963 /* Parse args required to build the message */
12964 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12966 if (unformat (i, "sw_if_index %d", &sw_if_index))
12967 sw_if_index_set = 1;
12972 if (sw_if_index_set == 0)
12977 if (!vam->json_output)
12979 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12980 "sw_if_index", "local_address", "remote_address",
12981 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12984 /* Get list of geneve-tunnel interfaces */
12985 M (GENEVE_TUNNEL_DUMP, mp);
12987 mp->sw_if_index = htonl (sw_if_index);
12991 /* Use a control ping for synchronization */
12992 M (CONTROL_PING, mp_ping);
13000 api_gre_tunnel_add_del (vat_main_t * vam)
13002 unformat_input_t *line_input = vam->input;
13003 vl_api_address_t src = { }, dst =
13006 vl_api_gre_tunnel_add_del_t *mp;
13007 vl_api_gre_tunnel_type_t t_type;
13011 u32 outer_fib_id = 0;
13012 u32 session_id = 0;
13016 t_type = GRE_API_TUNNEL_TYPE_L3;
13018 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13020 if (unformat (line_input, "del"))
13022 else if (unformat (line_input, "instance %d", &instance))
13024 else if (unformat (line_input, "src %U", unformat_vl_api_address, &src))
13028 else if (unformat (line_input, "dst %U", unformat_vl_api_address, &dst))
13032 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
13034 else if (unformat (line_input, "teb"))
13035 t_type = GRE_API_TUNNEL_TYPE_TEB;
13036 else if (unformat (line_input, "erspan %d", &session_id))
13037 t_type = GRE_API_TUNNEL_TYPE_ERSPAN;
13040 errmsg ("parse error '%U'", format_unformat_error, line_input);
13047 errmsg ("tunnel src address not specified");
13052 errmsg ("tunnel dst address not specified");
13056 M (GRE_TUNNEL_ADD_DEL, mp);
13058 clib_memcpy (&mp->tunnel.src, &src, sizeof (mp->tunnel.src));
13059 clib_memcpy (&mp->tunnel.dst, &dst, sizeof (mp->tunnel.dst));
13061 mp->tunnel.instance = htonl (instance);
13062 mp->tunnel.outer_fib_id = htonl (outer_fib_id);
13063 mp->is_add = is_add;
13064 mp->tunnel.session_id = htons ((u16) session_id);
13065 mp->tunnel.type = htonl (t_type);
13072 static void vl_api_gre_tunnel_details_t_handler
13073 (vl_api_gre_tunnel_details_t * mp)
13075 vat_main_t *vam = &vat_main;
13077 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
13078 ntohl (mp->tunnel.sw_if_index),
13079 ntohl (mp->tunnel.instance),
13080 format_vl_api_address, &mp->tunnel.src,
13081 format_vl_api_address, &mp->tunnel.dst,
13082 mp->tunnel.type, ntohl (mp->tunnel.outer_fib_id),
13083 ntohl (mp->tunnel.session_id));
13086 static void vl_api_gre_tunnel_details_t_handler_json
13087 (vl_api_gre_tunnel_details_t * mp)
13089 vat_main_t *vam = &vat_main;
13090 vat_json_node_t *node = NULL;
13092 if (VAT_JSON_ARRAY != vam->json_tree.type)
13094 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13095 vat_json_init_array (&vam->json_tree);
13097 node = vat_json_array_add (&vam->json_tree);
13099 vat_json_init_object (node);
13100 vat_json_object_add_uint (node, "sw_if_index",
13101 ntohl (mp->tunnel.sw_if_index));
13102 vat_json_object_add_uint (node, "instance", ntohl (mp->tunnel.instance));
13104 vat_json_object_add_address (node, "src", &mp->tunnel.src);
13105 vat_json_object_add_address (node, "dst", &mp->tunnel.dst);
13106 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel.type);
13107 vat_json_object_add_uint (node, "outer_fib_id",
13108 ntohl (mp->tunnel.outer_fib_id));
13109 vat_json_object_add_uint (node, "session_id", mp->tunnel.session_id);
13113 api_gre_tunnel_dump (vat_main_t * vam)
13115 unformat_input_t *i = vam->input;
13116 vl_api_gre_tunnel_dump_t *mp;
13117 vl_api_control_ping_t *mp_ping;
13119 u8 sw_if_index_set = 0;
13122 /* Parse args required to build the message */
13123 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13125 if (unformat (i, "sw_if_index %d", &sw_if_index))
13126 sw_if_index_set = 1;
13131 if (sw_if_index_set == 0)
13136 if (!vam->json_output)
13138 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
13139 "sw_if_index", "instance", "src_address", "dst_address",
13140 "tunnel_type", "outer_fib_id", "session_id");
13143 /* Get list of gre-tunnel interfaces */
13144 M (GRE_TUNNEL_DUMP, mp);
13146 mp->sw_if_index = htonl (sw_if_index);
13150 /* Use a control ping for synchronization */
13151 MPING (CONTROL_PING, mp_ping);
13159 api_l2_fib_clear_table (vat_main_t * vam)
13161 // unformat_input_t * i = vam->input;
13162 vl_api_l2_fib_clear_table_t *mp;
13165 M (L2_FIB_CLEAR_TABLE, mp);
13173 api_l2_interface_efp_filter (vat_main_t * vam)
13175 unformat_input_t *i = vam->input;
13176 vl_api_l2_interface_efp_filter_t *mp;
13179 u8 sw_if_index_set = 0;
13182 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13184 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13185 sw_if_index_set = 1;
13186 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13187 sw_if_index_set = 1;
13188 else if (unformat (i, "enable"))
13190 else if (unformat (i, "disable"))
13194 clib_warning ("parse error '%U'", format_unformat_error, i);
13199 if (sw_if_index_set == 0)
13201 errmsg ("missing sw_if_index");
13205 M (L2_INTERFACE_EFP_FILTER, mp);
13207 mp->sw_if_index = ntohl (sw_if_index);
13208 mp->enable_disable = enable;
13215 #define foreach_vtr_op \
13216 _("disable", L2_VTR_DISABLED) \
13217 _("push-1", L2_VTR_PUSH_1) \
13218 _("push-2", L2_VTR_PUSH_2) \
13219 _("pop-1", L2_VTR_POP_1) \
13220 _("pop-2", L2_VTR_POP_2) \
13221 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
13222 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
13223 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
13224 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
13227 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
13229 unformat_input_t *i = vam->input;
13230 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
13232 u8 sw_if_index_set = 0;
13235 u32 push_dot1q = 1;
13240 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13242 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13243 sw_if_index_set = 1;
13244 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13245 sw_if_index_set = 1;
13246 else if (unformat (i, "vtr_op %d", &vtr_op))
13248 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
13251 else if (unformat (i, "push_dot1q %d", &push_dot1q))
13253 else if (unformat (i, "tag1 %d", &tag1))
13255 else if (unformat (i, "tag2 %d", &tag2))
13259 clib_warning ("parse error '%U'", format_unformat_error, i);
13264 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
13266 errmsg ("missing vtr operation or sw_if_index");
13270 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
13271 mp->sw_if_index = ntohl (sw_if_index);
13272 mp->vtr_op = ntohl (vtr_op);
13273 mp->push_dot1q = ntohl (push_dot1q);
13274 mp->tag1 = ntohl (tag1);
13275 mp->tag2 = ntohl (tag2);
13283 api_create_vhost_user_if (vat_main_t * vam)
13285 unformat_input_t *i = vam->input;
13286 vl_api_create_vhost_user_if_t *mp;
13289 u8 file_name_set = 0;
13290 u32 custom_dev_instance = ~0;
13292 u8 use_custom_mac = 0;
13293 u8 disable_mrg_rxbuf = 0;
13294 u8 disable_indirect_desc = 0;
13298 /* Shut up coverity */
13299 clib_memset (hwaddr, 0, sizeof (hwaddr));
13301 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13303 if (unformat (i, "socket %s", &file_name))
13307 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13309 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
13310 use_custom_mac = 1;
13311 else if (unformat (i, "server"))
13313 else if (unformat (i, "disable_mrg_rxbuf"))
13314 disable_mrg_rxbuf = 1;
13315 else if (unformat (i, "disable_indirect_desc"))
13316 disable_indirect_desc = 1;
13317 else if (unformat (i, "tag %s", &tag))
13323 if (file_name_set == 0)
13325 errmsg ("missing socket file name");
13329 if (vec_len (file_name) > 255)
13331 errmsg ("socket file name too long");
13334 vec_add1 (file_name, 0);
13336 M (CREATE_VHOST_USER_IF, mp);
13338 mp->is_server = is_server;
13339 mp->disable_mrg_rxbuf = disable_mrg_rxbuf;
13340 mp->disable_indirect_desc = disable_indirect_desc;
13341 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13342 vec_free (file_name);
13343 if (custom_dev_instance != ~0)
13346 mp->custom_dev_instance = ntohl (custom_dev_instance);
13349 mp->use_custom_mac = use_custom_mac;
13350 clib_memcpy (mp->mac_address, hwaddr, 6);
13352 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
13361 api_modify_vhost_user_if (vat_main_t * vam)
13363 unformat_input_t *i = vam->input;
13364 vl_api_modify_vhost_user_if_t *mp;
13367 u8 file_name_set = 0;
13368 u32 custom_dev_instance = ~0;
13369 u8 sw_if_index_set = 0;
13370 u32 sw_if_index = (u32) ~ 0;
13373 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13375 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13376 sw_if_index_set = 1;
13377 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13378 sw_if_index_set = 1;
13379 else if (unformat (i, "socket %s", &file_name))
13383 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13385 else if (unformat (i, "server"))
13391 if (sw_if_index_set == 0)
13393 errmsg ("missing sw_if_index or interface name");
13397 if (file_name_set == 0)
13399 errmsg ("missing socket file name");
13403 if (vec_len (file_name) > 255)
13405 errmsg ("socket file name too long");
13408 vec_add1 (file_name, 0);
13410 M (MODIFY_VHOST_USER_IF, mp);
13412 mp->sw_if_index = ntohl (sw_if_index);
13413 mp->is_server = is_server;
13414 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13415 vec_free (file_name);
13416 if (custom_dev_instance != ~0)
13419 mp->custom_dev_instance = ntohl (custom_dev_instance);
13428 api_delete_vhost_user_if (vat_main_t * vam)
13430 unformat_input_t *i = vam->input;
13431 vl_api_delete_vhost_user_if_t *mp;
13432 u32 sw_if_index = ~0;
13433 u8 sw_if_index_set = 0;
13436 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13438 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13439 sw_if_index_set = 1;
13440 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13441 sw_if_index_set = 1;
13446 if (sw_if_index_set == 0)
13448 errmsg ("missing sw_if_index or interface name");
13453 M (DELETE_VHOST_USER_IF, mp);
13455 mp->sw_if_index = ntohl (sw_if_index);
13462 static void vl_api_sw_interface_vhost_user_details_t_handler
13463 (vl_api_sw_interface_vhost_user_details_t * mp)
13465 vat_main_t *vam = &vat_main;
13467 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
13468 (char *) mp->interface_name,
13469 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
13470 clib_net_to_host_u64 (mp->features), mp->is_server,
13471 ntohl (mp->num_regions), (char *) mp->sock_filename);
13472 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
13475 static void vl_api_sw_interface_vhost_user_details_t_handler_json
13476 (vl_api_sw_interface_vhost_user_details_t * mp)
13478 vat_main_t *vam = &vat_main;
13479 vat_json_node_t *node = NULL;
13481 if (VAT_JSON_ARRAY != vam->json_tree.type)
13483 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13484 vat_json_init_array (&vam->json_tree);
13486 node = vat_json_array_add (&vam->json_tree);
13488 vat_json_init_object (node);
13489 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13490 vat_json_object_add_string_copy (node, "interface_name",
13491 mp->interface_name);
13492 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
13493 ntohl (mp->virtio_net_hdr_sz));
13494 vat_json_object_add_uint (node, "features",
13495 clib_net_to_host_u64 (mp->features));
13496 vat_json_object_add_uint (node, "is_server", mp->is_server);
13497 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
13498 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
13499 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
13503 api_sw_interface_vhost_user_dump (vat_main_t * vam)
13505 vl_api_sw_interface_vhost_user_dump_t *mp;
13506 vl_api_control_ping_t *mp_ping;
13509 "Interface name idx hdr_sz features server regions filename");
13511 /* Get list of vhost-user interfaces */
13512 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
13515 /* Use a control ping for synchronization */
13516 MPING (CONTROL_PING, mp_ping);
13524 api_show_version (vat_main_t * vam)
13526 vl_api_show_version_t *mp;
13529 M (SHOW_VERSION, mp);
13538 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
13540 unformat_input_t *line_input = vam->input;
13541 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
13542 ip4_address_t local4, remote4;
13543 ip6_address_t local6, remote6;
13545 u8 ipv4_set = 0, ipv6_set = 0;
13549 u32 mcast_sw_if_index = ~0;
13550 u32 encap_vrf_id = 0;
13551 u32 decap_vrf_id = 0;
13557 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13558 clib_memset (&local4, 0, sizeof local4);
13559 clib_memset (&remote4, 0, sizeof remote4);
13560 clib_memset (&local6, 0, sizeof local6);
13561 clib_memset (&remote6, 0, sizeof remote6);
13563 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13565 if (unformat (line_input, "del"))
13567 else if (unformat (line_input, "local %U",
13568 unformat_ip4_address, &local4))
13573 else if (unformat (line_input, "remote %U",
13574 unformat_ip4_address, &remote4))
13579 else if (unformat (line_input, "local %U",
13580 unformat_ip6_address, &local6))
13585 else if (unformat (line_input, "remote %U",
13586 unformat_ip6_address, &remote6))
13591 else if (unformat (line_input, "group %U %U",
13592 unformat_ip4_address, &remote4,
13593 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13595 grp_set = remote_set = 1;
13598 else if (unformat (line_input, "group %U",
13599 unformat_ip4_address, &remote4))
13601 grp_set = remote_set = 1;
13604 else if (unformat (line_input, "group %U %U",
13605 unformat_ip6_address, &remote6,
13606 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13608 grp_set = remote_set = 1;
13611 else if (unformat (line_input, "group %U",
13612 unformat_ip6_address, &remote6))
13614 grp_set = remote_set = 1;
13618 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13620 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13622 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
13624 else if (unformat (line_input, "vni %d", &vni))
13626 else if (unformat (line_input, "next-ip4"))
13628 else if (unformat (line_input, "next-ip6"))
13630 else if (unformat (line_input, "next-ethernet"))
13632 else if (unformat (line_input, "next-nsh"))
13636 errmsg ("parse error '%U'", format_unformat_error, line_input);
13641 if (local_set == 0)
13643 errmsg ("tunnel local address not specified");
13646 if (remote_set == 0)
13648 errmsg ("tunnel remote address not specified");
13651 if (grp_set && mcast_sw_if_index == ~0)
13653 errmsg ("tunnel nonexistent multicast device");
13656 if (ipv4_set && ipv6_set)
13658 errmsg ("both IPv4 and IPv6 addresses specified");
13664 errmsg ("vni not specified");
13668 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
13673 clib_memcpy (&mp->local, &local6, sizeof (local6));
13674 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
13678 clib_memcpy (&mp->local, &local4, sizeof (local4));
13679 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
13682 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13683 mp->encap_vrf_id = ntohl (encap_vrf_id);
13684 mp->decap_vrf_id = ntohl (decap_vrf_id);
13685 mp->protocol = protocol;
13686 mp->vni = ntohl (vni);
13687 mp->is_add = is_add;
13688 mp->is_ipv6 = ipv6_set;
13695 static void vl_api_vxlan_gpe_tunnel_details_t_handler
13696 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13698 vat_main_t *vam = &vat_main;
13699 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
13700 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
13702 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
13703 ntohl (mp->sw_if_index),
13704 format_ip46_address, &local, IP46_TYPE_ANY,
13705 format_ip46_address, &remote, IP46_TYPE_ANY,
13706 ntohl (mp->vni), mp->protocol,
13707 ntohl (mp->mcast_sw_if_index),
13708 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
13712 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
13713 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13715 vat_main_t *vam = &vat_main;
13716 vat_json_node_t *node = NULL;
13717 struct in_addr ip4;
13718 struct in6_addr ip6;
13720 if (VAT_JSON_ARRAY != vam->json_tree.type)
13722 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13723 vat_json_init_array (&vam->json_tree);
13725 node = vat_json_array_add (&vam->json_tree);
13727 vat_json_init_object (node);
13728 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13731 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
13732 vat_json_object_add_ip6 (node, "local", ip6);
13733 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
13734 vat_json_object_add_ip6 (node, "remote", ip6);
13738 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
13739 vat_json_object_add_ip4 (node, "local", ip4);
13740 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
13741 vat_json_object_add_ip4 (node, "remote", ip4);
13743 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13744 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
13745 vat_json_object_add_uint (node, "mcast_sw_if_index",
13746 ntohl (mp->mcast_sw_if_index));
13747 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13748 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
13749 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13753 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
13755 unformat_input_t *i = vam->input;
13756 vl_api_vxlan_gpe_tunnel_dump_t *mp;
13757 vl_api_control_ping_t *mp_ping;
13759 u8 sw_if_index_set = 0;
13762 /* Parse args required to build the message */
13763 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13765 if (unformat (i, "sw_if_index %d", &sw_if_index))
13766 sw_if_index_set = 1;
13771 if (sw_if_index_set == 0)
13776 if (!vam->json_output)
13778 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
13779 "sw_if_index", "local", "remote", "vni",
13780 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
13783 /* Get list of vxlan-tunnel interfaces */
13784 M (VXLAN_GPE_TUNNEL_DUMP, mp);
13786 mp->sw_if_index = htonl (sw_if_index);
13790 /* Use a control ping for synchronization */
13791 MPING (CONTROL_PING, mp_ping);
13798 static void vl_api_l2_fib_table_details_t_handler
13799 (vl_api_l2_fib_table_details_t * mp)
13801 vat_main_t *vam = &vat_main;
13803 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
13805 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
13806 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
13810 static void vl_api_l2_fib_table_details_t_handler_json
13811 (vl_api_l2_fib_table_details_t * mp)
13813 vat_main_t *vam = &vat_main;
13814 vat_json_node_t *node = NULL;
13816 if (VAT_JSON_ARRAY != vam->json_tree.type)
13818 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13819 vat_json_init_array (&vam->json_tree);
13821 node = vat_json_array_add (&vam->json_tree);
13823 vat_json_init_object (node);
13824 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
13825 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
13826 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13827 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
13828 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
13829 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
13833 api_l2_fib_table_dump (vat_main_t * vam)
13835 unformat_input_t *i = vam->input;
13836 vl_api_l2_fib_table_dump_t *mp;
13837 vl_api_control_ping_t *mp_ping;
13842 /* Parse args required to build the message */
13843 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13845 if (unformat (i, "bd_id %d", &bd_id))
13851 if (bd_id_set == 0)
13853 errmsg ("missing bridge domain");
13857 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
13859 /* Get list of l2 fib entries */
13860 M (L2_FIB_TABLE_DUMP, mp);
13862 mp->bd_id = ntohl (bd_id);
13865 /* Use a control ping for synchronization */
13866 MPING (CONTROL_PING, mp_ping);
13875 api_interface_name_renumber (vat_main_t * vam)
13877 unformat_input_t *line_input = vam->input;
13878 vl_api_interface_name_renumber_t *mp;
13879 u32 sw_if_index = ~0;
13880 u32 new_show_dev_instance = ~0;
13883 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13885 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
13888 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13890 else if (unformat (line_input, "new_show_dev_instance %d",
13891 &new_show_dev_instance))
13897 if (sw_if_index == ~0)
13899 errmsg ("missing interface name or sw_if_index");
13903 if (new_show_dev_instance == ~0)
13905 errmsg ("missing new_show_dev_instance");
13909 M (INTERFACE_NAME_RENUMBER, mp);
13911 mp->sw_if_index = ntohl (sw_if_index);
13912 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
13920 api_ip_probe_neighbor (vat_main_t * vam)
13922 unformat_input_t *i = vam->input;
13923 vl_api_ip_probe_neighbor_t *mp;
13924 vl_api_address_t dst_adr = { };
13930 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13932 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13934 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13936 else if (unformat (i, "address %U", unformat_vl_api_address, &dst_adr))
13944 errmsg ("missing interface");
13950 errmsg ("missing addresses");
13954 M (IP_PROBE_NEIGHBOR, mp);
13956 mp->sw_if_index = ntohl (sw_if_index);
13957 clib_memcpy (&mp->dst, &dst_adr, sizeof (dst_adr));
13965 api_ip_scan_neighbor_enable_disable (vat_main_t * vam)
13967 unformat_input_t *i = vam->input;
13968 vl_api_ip_scan_neighbor_enable_disable_t *mp;
13969 u8 mode = IP_SCAN_V46_NEIGHBORS;
13970 u32 interval = 0, time = 0, update = 0, delay = 0, stale = 0;
13973 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13975 if (unformat (i, "ip4"))
13976 mode = IP_SCAN_V4_NEIGHBORS;
13977 else if (unformat (i, "ip6"))
13978 mode = IP_SCAN_V6_NEIGHBORS;
13979 if (unformat (i, "both"))
13980 mode = IP_SCAN_V46_NEIGHBORS;
13981 else if (unformat (i, "disable"))
13982 mode = IP_SCAN_DISABLED;
13983 else if (unformat (i, "interval %d", &interval))
13985 else if (unformat (i, "max-time %d", &time))
13987 else if (unformat (i, "max-update %d", &update))
13989 else if (unformat (i, "delay %d", &delay))
13991 else if (unformat (i, "stale %d", &stale))
13997 if (interval > 255)
13999 errmsg ("interval cannot exceed 255 minutes.");
14004 errmsg ("max-time cannot exceed 255 usec.");
14009 errmsg ("max-update cannot exceed 255.");
14014 errmsg ("delay cannot exceed 255 msec.");
14019 errmsg ("stale cannot exceed 255 minutes.");
14023 M (IP_SCAN_NEIGHBOR_ENABLE_DISABLE, mp);
14025 mp->scan_interval = interval;
14026 mp->max_proc_time = time;
14027 mp->max_update = update;
14028 mp->scan_int_delay = delay;
14029 mp->stale_threshold = stale;
14037 api_want_ip4_arp_events (vat_main_t * vam)
14039 unformat_input_t *line_input = vam->input;
14040 vl_api_want_ip4_arp_events_t *mp;
14041 ip4_address_t address;
14042 int address_set = 0;
14043 u32 enable_disable = 1;
14046 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14048 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
14050 else if (unformat (line_input, "del"))
14051 enable_disable = 0;
14056 if (address_set == 0)
14058 errmsg ("missing addresses");
14062 M (WANT_IP4_ARP_EVENTS, mp);
14063 mp->enable_disable = enable_disable;
14064 mp->pid = htonl (getpid ());
14065 clib_memcpy (mp->ip, &address, sizeof (address));
14073 api_want_ip6_nd_events (vat_main_t * vam)
14075 unformat_input_t *line_input = vam->input;
14076 vl_api_want_ip6_nd_events_t *mp;
14077 vl_api_ip6_address_t address;
14078 int address_set = 0;
14079 u32 enable_disable = 1;
14082 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14085 (line_input, "address %U", unformat_vl_api_ip6_address, &address))
14087 else if (unformat (line_input, "del"))
14088 enable_disable = 0;
14093 if (address_set == 0)
14095 errmsg ("missing addresses");
14099 M (WANT_IP6_ND_EVENTS, mp);
14100 mp->enable_disable = enable_disable;
14101 mp->pid = htonl (getpid ());
14102 clib_memcpy (&mp->ip, &address, sizeof (address));
14110 api_want_l2_macs_events (vat_main_t * vam)
14112 unformat_input_t *line_input = vam->input;
14113 vl_api_want_l2_macs_events_t *mp;
14114 u8 enable_disable = 1;
14115 u32 scan_delay = 0;
14116 u32 max_macs_in_event = 0;
14117 u32 learn_limit = 0;
14120 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14122 if (unformat (line_input, "learn-limit %d", &learn_limit))
14124 else if (unformat (line_input, "scan-delay %d", &scan_delay))
14126 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
14128 else if (unformat (line_input, "disable"))
14129 enable_disable = 0;
14134 M (WANT_L2_MACS_EVENTS, mp);
14135 mp->enable_disable = enable_disable;
14136 mp->pid = htonl (getpid ());
14137 mp->learn_limit = htonl (learn_limit);
14138 mp->scan_delay = (u8) scan_delay;
14139 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
14146 api_input_acl_set_interface (vat_main_t * vam)
14148 unformat_input_t *i = vam->input;
14149 vl_api_input_acl_set_interface_t *mp;
14151 int sw_if_index_set;
14152 u32 ip4_table_index = ~0;
14153 u32 ip6_table_index = ~0;
14154 u32 l2_table_index = ~0;
14158 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14160 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14161 sw_if_index_set = 1;
14162 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14163 sw_if_index_set = 1;
14164 else if (unformat (i, "del"))
14166 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14168 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14170 else if (unformat (i, "l2-table %d", &l2_table_index))
14174 clib_warning ("parse error '%U'", format_unformat_error, i);
14179 if (sw_if_index_set == 0)
14181 errmsg ("missing interface name or sw_if_index");
14185 M (INPUT_ACL_SET_INTERFACE, mp);
14187 mp->sw_if_index = ntohl (sw_if_index);
14188 mp->ip4_table_index = ntohl (ip4_table_index);
14189 mp->ip6_table_index = ntohl (ip6_table_index);
14190 mp->l2_table_index = ntohl (l2_table_index);
14191 mp->is_add = is_add;
14199 api_output_acl_set_interface (vat_main_t * vam)
14201 unformat_input_t *i = vam->input;
14202 vl_api_output_acl_set_interface_t *mp;
14204 int sw_if_index_set;
14205 u32 ip4_table_index = ~0;
14206 u32 ip6_table_index = ~0;
14207 u32 l2_table_index = ~0;
14211 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14213 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14214 sw_if_index_set = 1;
14215 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14216 sw_if_index_set = 1;
14217 else if (unformat (i, "del"))
14219 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14221 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14223 else if (unformat (i, "l2-table %d", &l2_table_index))
14227 clib_warning ("parse error '%U'", format_unformat_error, i);
14232 if (sw_if_index_set == 0)
14234 errmsg ("missing interface name or sw_if_index");
14238 M (OUTPUT_ACL_SET_INTERFACE, mp);
14240 mp->sw_if_index = ntohl (sw_if_index);
14241 mp->ip4_table_index = ntohl (ip4_table_index);
14242 mp->ip6_table_index = ntohl (ip6_table_index);
14243 mp->l2_table_index = ntohl (l2_table_index);
14244 mp->is_add = is_add;
14252 api_ip_address_dump (vat_main_t * vam)
14254 unformat_input_t *i = vam->input;
14255 vl_api_ip_address_dump_t *mp;
14256 vl_api_control_ping_t *mp_ping;
14257 u32 sw_if_index = ~0;
14258 u8 sw_if_index_set = 0;
14263 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14265 if (unformat (i, "sw_if_index %d", &sw_if_index))
14266 sw_if_index_set = 1;
14268 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14269 sw_if_index_set = 1;
14270 else if (unformat (i, "ipv4"))
14272 else if (unformat (i, "ipv6"))
14278 if (ipv4_set && ipv6_set)
14280 errmsg ("ipv4 and ipv6 flags cannot be both set");
14284 if ((!ipv4_set) && (!ipv6_set))
14286 errmsg ("no ipv4 nor ipv6 flag set");
14290 if (sw_if_index_set == 0)
14292 errmsg ("missing interface name or sw_if_index");
14296 vam->current_sw_if_index = sw_if_index;
14297 vam->is_ipv6 = ipv6_set;
14299 M (IP_ADDRESS_DUMP, mp);
14300 mp->sw_if_index = ntohl (sw_if_index);
14301 mp->is_ipv6 = ipv6_set;
14304 /* Use a control ping for synchronization */
14305 MPING (CONTROL_PING, mp_ping);
14313 api_ip_dump (vat_main_t * vam)
14315 vl_api_ip_dump_t *mp;
14316 vl_api_control_ping_t *mp_ping;
14317 unformat_input_t *in = vam->input;
14324 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
14326 if (unformat (in, "ipv4"))
14328 else if (unformat (in, "ipv6"))
14334 if (ipv4_set && ipv6_set)
14336 errmsg ("ipv4 and ipv6 flags cannot be both set");
14340 if ((!ipv4_set) && (!ipv6_set))
14342 errmsg ("no ipv4 nor ipv6 flag set");
14346 is_ipv6 = ipv6_set;
14347 vam->is_ipv6 = is_ipv6;
14349 /* free old data */
14350 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
14352 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
14354 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
14357 mp->is_ipv6 = ipv6_set;
14360 /* Use a control ping for synchronization */
14361 MPING (CONTROL_PING, mp_ping);
14369 api_ipsec_spd_add_del (vat_main_t * vam)
14371 unformat_input_t *i = vam->input;
14372 vl_api_ipsec_spd_add_del_t *mp;
14377 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14379 if (unformat (i, "spd_id %d", &spd_id))
14381 else if (unformat (i, "del"))
14385 clib_warning ("parse error '%U'", format_unformat_error, i);
14391 errmsg ("spd_id must be set");
14395 M (IPSEC_SPD_ADD_DEL, mp);
14397 mp->spd_id = ntohl (spd_id);
14398 mp->is_add = is_add;
14406 api_ipsec_interface_add_del_spd (vat_main_t * vam)
14408 unformat_input_t *i = vam->input;
14409 vl_api_ipsec_interface_add_del_spd_t *mp;
14411 u8 sw_if_index_set = 0;
14412 u32 spd_id = (u32) ~ 0;
14416 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14418 if (unformat (i, "del"))
14420 else if (unformat (i, "spd_id %d", &spd_id))
14423 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14424 sw_if_index_set = 1;
14425 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14426 sw_if_index_set = 1;
14429 clib_warning ("parse error '%U'", format_unformat_error, i);
14435 if (spd_id == (u32) ~ 0)
14437 errmsg ("spd_id must be set");
14441 if (sw_if_index_set == 0)
14443 errmsg ("missing interface name or sw_if_index");
14447 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
14449 mp->spd_id = ntohl (spd_id);
14450 mp->sw_if_index = ntohl (sw_if_index);
14451 mp->is_add = is_add;
14459 api_ipsec_spd_entry_add_del (vat_main_t * vam)
14461 unformat_input_t *i = vam->input;
14462 vl_api_ipsec_spd_entry_add_del_t *mp;
14463 u8 is_add = 1, is_outbound = 0;
14464 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
14466 u32 rport_start = 0, rport_stop = (u32) ~ 0;
14467 u32 lport_start = 0, lport_stop = (u32) ~ 0;
14468 vl_api_address_t laddr_start = { }, laddr_stop =
14477 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14479 if (unformat (i, "del"))
14481 if (unformat (i, "outbound"))
14483 if (unformat (i, "inbound"))
14485 else if (unformat (i, "spd_id %d", &spd_id))
14487 else if (unformat (i, "sa_id %d", &sa_id))
14489 else if (unformat (i, "priority %d", &priority))
14491 else if (unformat (i, "protocol %d", &protocol))
14493 else if (unformat (i, "lport_start %d", &lport_start))
14495 else if (unformat (i, "lport_stop %d", &lport_stop))
14497 else if (unformat (i, "rport_start %d", &rport_start))
14499 else if (unformat (i, "rport_stop %d", &rport_stop))
14501 else if (unformat (i, "laddr_start %U",
14502 unformat_vl_api_address, &laddr_start))
14504 else if (unformat (i, "laddr_stop %U", unformat_vl_api_address,
14507 else if (unformat (i, "raddr_start %U", unformat_vl_api_address,
14510 else if (unformat (i, "raddr_stop %U", unformat_vl_api_address,
14514 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
14516 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
14518 clib_warning ("unsupported action: 'resolve'");
14524 clib_warning ("parse error '%U'", format_unformat_error, i);
14530 M (IPSEC_SPD_ENTRY_ADD_DEL, mp);
14532 mp->is_add = is_add;
14534 mp->entry.spd_id = ntohl (spd_id);
14535 mp->entry.priority = ntohl (priority);
14536 mp->entry.is_outbound = is_outbound;
14538 clib_memcpy (&mp->entry.remote_address_start, &raddr_start,
14539 sizeof (vl_api_address_t));
14540 clib_memcpy (&mp->entry.remote_address_stop, &raddr_stop,
14541 sizeof (vl_api_address_t));
14542 clib_memcpy (&mp->entry.local_address_start, &laddr_start,
14543 sizeof (vl_api_address_t));
14544 clib_memcpy (&mp->entry.local_address_stop, &laddr_stop,
14545 sizeof (vl_api_address_t));
14547 mp->entry.protocol = (u8) protocol;
14548 mp->entry.local_port_start = ntohs ((u16) lport_start);
14549 mp->entry.local_port_stop = ntohs ((u16) lport_stop);
14550 mp->entry.remote_port_start = ntohs ((u16) rport_start);
14551 mp->entry.remote_port_stop = ntohs ((u16) rport_stop);
14552 mp->entry.policy = (u8) policy;
14553 mp->entry.sa_id = ntohl (sa_id);
14561 api_ipsec_sad_entry_add_del (vat_main_t * vam)
14563 unformat_input_t *i = vam->input;
14564 vl_api_ipsec_sad_entry_add_del_t *mp;
14565 u32 sad_id = 0, spi = 0;
14566 u8 *ck = 0, *ik = 0;
14569 vl_api_ipsec_crypto_alg_t crypto_alg = IPSEC_API_CRYPTO_ALG_NONE;
14570 vl_api_ipsec_integ_alg_t integ_alg = IPSEC_API_INTEG_ALG_NONE;
14571 vl_api_ipsec_sad_flags_t flags = IPSEC_API_SAD_FLAG_NONE;
14572 vl_api_ipsec_proto_t protocol = IPSEC_API_PROTO_AH;
14573 vl_api_address_t tun_src, tun_dst;
14576 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14578 if (unformat (i, "del"))
14580 else if (unformat (i, "sad_id %d", &sad_id))
14582 else if (unformat (i, "spi %d", &spi))
14584 else if (unformat (i, "esp"))
14585 protocol = IPSEC_API_PROTO_ESP;
14587 if (unformat (i, "tunnel_src %U", unformat_vl_api_address, &tun_src))
14589 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
14590 if (ADDRESS_IP6 == tun_src.af)
14591 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
14594 if (unformat (i, "tunnel_dst %U", unformat_vl_api_address, &tun_dst))
14596 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
14597 if (ADDRESS_IP6 == tun_src.af)
14598 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
14601 if (unformat (i, "crypto_alg %U",
14602 unformat_ipsec_api_crypto_alg, &crypto_alg))
14604 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14606 else if (unformat (i, "integ_alg %U",
14607 unformat_ipsec_api_integ_alg, &integ_alg))
14609 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14613 clib_warning ("parse error '%U'", format_unformat_error, i);
14619 M (IPSEC_SAD_ENTRY_ADD_DEL, mp);
14621 mp->is_add = is_add;
14622 mp->entry.sad_id = ntohl (sad_id);
14623 mp->entry.protocol = protocol;
14624 mp->entry.spi = ntohl (spi);
14625 mp->entry.flags = flags;
14627 mp->entry.crypto_algorithm = crypto_alg;
14628 mp->entry.integrity_algorithm = integ_alg;
14629 mp->entry.crypto_key.length = vec_len (ck);
14630 mp->entry.integrity_key.length = vec_len (ik);
14632 if (mp->entry.crypto_key.length > sizeof (mp->entry.crypto_key.data))
14633 mp->entry.crypto_key.length = sizeof (mp->entry.crypto_key.data);
14635 if (mp->entry.integrity_key.length > sizeof (mp->entry.integrity_key.data))
14636 mp->entry.integrity_key.length = sizeof (mp->entry.integrity_key.data);
14639 clib_memcpy (mp->entry.crypto_key.data, ck, mp->entry.crypto_key.length);
14641 clib_memcpy (mp->entry.integrity_key.data, ik,
14642 mp->entry.integrity_key.length);
14644 if (flags & IPSEC_API_SAD_FLAG_IS_TUNNEL)
14646 clib_memcpy (&mp->entry.tunnel_src, &tun_src,
14647 sizeof (mp->entry.tunnel_src));
14648 clib_memcpy (&mp->entry.tunnel_dst, &tun_dst,
14649 sizeof (mp->entry.tunnel_dst));
14658 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
14660 unformat_input_t *i = vam->input;
14661 vl_api_ipsec_tunnel_if_add_del_t *mp;
14662 u32 local_spi = 0, remote_spi = 0;
14663 u32 crypto_alg = 0, integ_alg = 0;
14664 u8 *lck = NULL, *rck = NULL;
14665 u8 *lik = NULL, *rik = NULL;
14666 vl_api_address_t local_ip = { 0 };
14667 vl_api_address_t remote_ip = { 0 };
14671 u8 anti_replay = 0;
14677 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14679 if (unformat (i, "del"))
14681 else if (unformat (i, "esn"))
14683 else if (unformat (i, "anti-replay"))
14685 else if (unformat (i, "count %d", &count))
14687 else if (unformat (i, "local_spi %d", &local_spi))
14689 else if (unformat (i, "remote_spi %d", &remote_spi))
14692 if (unformat (i, "local_ip %U", unformat_vl_api_address, &local_ip))
14695 if (unformat (i, "remote_ip %U", unformat_vl_api_address, &remote_ip))
14697 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
14700 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
14702 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
14704 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
14708 (i, "crypto_alg %U", unformat_ipsec_api_crypto_alg, &crypto_alg))
14710 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
14712 errmsg ("unsupported crypto-alg: '%U'\n",
14713 format_ipsec_crypto_alg, crypto_alg);
14719 (i, "integ_alg %U", unformat_ipsec_api_integ_alg, &integ_alg))
14721 if (integ_alg >= IPSEC_INTEG_N_ALG)
14723 errmsg ("unsupported integ-alg: '%U'\n",
14724 format_ipsec_integ_alg, integ_alg);
14728 else if (unformat (i, "instance %u", &instance))
14732 errmsg ("parse error '%U'\n", format_unformat_error, i);
14739 /* Turn on async mode */
14740 vam->async_mode = 1;
14741 vam->async_errors = 0;
14742 before = vat_time_now (vam);
14745 for (jj = 0; jj < count; jj++)
14747 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
14749 mp->is_add = is_add;
14751 mp->anti_replay = anti_replay;
14754 increment_address (&remote_ip);
14756 clib_memcpy (&mp->local_ip, &local_ip, sizeof (local_ip));
14757 clib_memcpy (&mp->remote_ip, &remote_ip, sizeof (remote_ip));
14759 mp->local_spi = htonl (local_spi + jj);
14760 mp->remote_spi = htonl (remote_spi + jj);
14761 mp->crypto_alg = (u8) crypto_alg;
14763 mp->local_crypto_key_len = 0;
14766 mp->local_crypto_key_len = vec_len (lck);
14767 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
14768 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
14769 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
14772 mp->remote_crypto_key_len = 0;
14775 mp->remote_crypto_key_len = vec_len (rck);
14776 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
14777 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
14778 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
14781 mp->integ_alg = (u8) integ_alg;
14783 mp->local_integ_key_len = 0;
14786 mp->local_integ_key_len = vec_len (lik);
14787 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
14788 mp->local_integ_key_len = sizeof (mp->local_integ_key);
14789 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
14792 mp->remote_integ_key_len = 0;
14795 mp->remote_integ_key_len = vec_len (rik);
14796 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
14797 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
14798 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
14803 mp->renumber = renumber;
14804 mp->show_instance = ntohl (instance);
14809 /* When testing multiple add/del ops, use a control-ping to sync */
14812 vl_api_control_ping_t *mp_ping;
14816 /* Shut off async mode */
14817 vam->async_mode = 0;
14819 MPING (CONTROL_PING, mp_ping);
14822 timeout = vat_time_now (vam) + 1.0;
14823 while (vat_time_now (vam) < timeout)
14824 if (vam->result_ready == 1)
14829 if (vam->retval == -99)
14830 errmsg ("timeout");
14832 if (vam->async_errors > 0)
14834 errmsg ("%d asynchronous errors", vam->async_errors);
14837 vam->async_errors = 0;
14838 after = vat_time_now (vam);
14840 /* slim chance, but we might have eaten SIGTERM on the first iteration */
14844 print (vam->ofp, "%d tunnels in %.6f secs, %.2f tunnels/sec",
14845 count, after - before, count / (after - before));
14849 /* Wait for a reply... */
14858 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
14860 vat_main_t *vam = &vat_main;
14862 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
14863 "crypto_key %U integ_alg %u integ_key %U flags %x "
14864 "tunnel_src_addr %U tunnel_dst_addr %U "
14865 "salt %u seq_outbound %lu last_seq_inbound %lu "
14866 "replay_window %lu\n",
14867 ntohl (mp->entry.sad_id),
14868 ntohl (mp->sw_if_index),
14869 ntohl (mp->entry.spi),
14870 ntohl (mp->entry.protocol),
14871 ntohl (mp->entry.crypto_algorithm),
14872 format_hex_bytes, mp->entry.crypto_key.data,
14873 mp->entry.crypto_key.length, ntohl (mp->entry.integrity_algorithm),
14874 format_hex_bytes, mp->entry.integrity_key.data,
14875 mp->entry.integrity_key.length, ntohl (mp->entry.flags),
14876 format_vl_api_address, &mp->entry.tunnel_src, format_vl_api_address,
14877 &mp->entry.tunnel_dst, ntohl (mp->salt),
14878 clib_net_to_host_u64 (mp->seq_outbound),
14879 clib_net_to_host_u64 (mp->last_seq_inbound),
14880 clib_net_to_host_u64 (mp->replay_window));
14883 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
14884 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
14886 static void vl_api_ipsec_sa_details_t_handler_json
14887 (vl_api_ipsec_sa_details_t * mp)
14889 vat_main_t *vam = &vat_main;
14890 vat_json_node_t *node = NULL;
14891 vl_api_ipsec_sad_flags_t flags;
14893 if (VAT_JSON_ARRAY != vam->json_tree.type)
14895 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14896 vat_json_init_array (&vam->json_tree);
14898 node = vat_json_array_add (&vam->json_tree);
14900 vat_json_init_object (node);
14901 vat_json_object_add_uint (node, "sa_id", ntohl (mp->entry.sad_id));
14902 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14903 vat_json_object_add_uint (node, "spi", ntohl (mp->entry.spi));
14904 vat_json_object_add_uint (node, "proto", ntohl (mp->entry.protocol));
14905 vat_json_object_add_uint (node, "crypto_alg",
14906 ntohl (mp->entry.crypto_algorithm));
14907 vat_json_object_add_uint (node, "integ_alg",
14908 ntohl (mp->entry.integrity_algorithm));
14909 flags = ntohl (mp->entry.flags);
14910 vat_json_object_add_uint (node, "use_esn",
14911 ! !(flags & IPSEC_API_SAD_FLAG_USE_ESN));
14912 vat_json_object_add_uint (node, "use_anti_replay",
14913 ! !(flags & IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY));
14914 vat_json_object_add_uint (node, "is_tunnel",
14915 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL));
14916 vat_json_object_add_uint (node, "is_tunnel_ip6",
14917 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL_V6));
14918 vat_json_object_add_uint (node, "udp_encap",
14919 ! !(flags & IPSEC_API_SAD_FLAG_UDP_ENCAP));
14920 vat_json_object_add_bytes (node, "crypto_key", mp->entry.crypto_key.data,
14921 mp->entry.crypto_key.length);
14922 vat_json_object_add_bytes (node, "integ_key", mp->entry.integrity_key.data,
14923 mp->entry.integrity_key.length);
14924 vat_json_object_add_address (node, "src", &mp->entry.tunnel_src);
14925 vat_json_object_add_address (node, "dst", &mp->entry.tunnel_dst);
14926 vat_json_object_add_uint (node, "replay_window",
14927 clib_net_to_host_u64 (mp->replay_window));
14931 api_ipsec_sa_dump (vat_main_t * vam)
14933 unformat_input_t *i = vam->input;
14934 vl_api_ipsec_sa_dump_t *mp;
14935 vl_api_control_ping_t *mp_ping;
14939 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14941 if (unformat (i, "sa_id %d", &sa_id))
14945 clib_warning ("parse error '%U'", format_unformat_error, i);
14950 M (IPSEC_SA_DUMP, mp);
14952 mp->sa_id = ntohl (sa_id);
14956 /* Use a control ping for synchronization */
14957 M (CONTROL_PING, mp_ping);
14965 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
14967 unformat_input_t *i = vam->input;
14968 vl_api_ipsec_tunnel_if_set_sa_t *mp;
14969 u32 sw_if_index = ~0;
14971 u8 is_outbound = (u8) ~ 0;
14974 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14976 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14978 else if (unformat (i, "sa_id %d", &sa_id))
14980 else if (unformat (i, "outbound"))
14982 else if (unformat (i, "inbound"))
14986 clib_warning ("parse error '%U'", format_unformat_error, i);
14991 if (sw_if_index == ~0)
14993 errmsg ("interface must be specified");
14999 errmsg ("SA ID must be specified");
15003 M (IPSEC_TUNNEL_IF_SET_SA, mp);
15005 mp->sw_if_index = htonl (sw_if_index);
15006 mp->sa_id = htonl (sa_id);
15007 mp->is_outbound = is_outbound;
15016 api_get_first_msg_id (vat_main_t * vam)
15018 vl_api_get_first_msg_id_t *mp;
15019 unformat_input_t *i = vam->input;
15024 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15026 if (unformat (i, "client %s", &name))
15034 errmsg ("missing client name");
15037 vec_add1 (name, 0);
15039 if (vec_len (name) > 63)
15041 errmsg ("client name too long");
15045 M (GET_FIRST_MSG_ID, mp);
15046 clib_memcpy (mp->name, name, vec_len (name));
15053 api_cop_interface_enable_disable (vat_main_t * vam)
15055 unformat_input_t *line_input = vam->input;
15056 vl_api_cop_interface_enable_disable_t *mp;
15057 u32 sw_if_index = ~0;
15058 u8 enable_disable = 1;
15061 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15063 if (unformat (line_input, "disable"))
15064 enable_disable = 0;
15065 if (unformat (line_input, "enable"))
15066 enable_disable = 1;
15067 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15068 vam, &sw_if_index))
15070 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15076 if (sw_if_index == ~0)
15078 errmsg ("missing interface name or sw_if_index");
15082 /* Construct the API message */
15083 M (COP_INTERFACE_ENABLE_DISABLE, mp);
15084 mp->sw_if_index = ntohl (sw_if_index);
15085 mp->enable_disable = enable_disable;
15089 /* Wait for the reply */
15095 api_cop_whitelist_enable_disable (vat_main_t * vam)
15097 unformat_input_t *line_input = vam->input;
15098 vl_api_cop_whitelist_enable_disable_t *mp;
15099 u32 sw_if_index = ~0;
15100 u8 ip4 = 0, ip6 = 0, default_cop = 0;
15104 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15106 if (unformat (line_input, "ip4"))
15108 else if (unformat (line_input, "ip6"))
15110 else if (unformat (line_input, "default"))
15112 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15113 vam, &sw_if_index))
15115 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15117 else if (unformat (line_input, "fib-id %d", &fib_id))
15123 if (sw_if_index == ~0)
15125 errmsg ("missing interface name or sw_if_index");
15129 /* Construct the API message */
15130 M (COP_WHITELIST_ENABLE_DISABLE, mp);
15131 mp->sw_if_index = ntohl (sw_if_index);
15132 mp->fib_id = ntohl (fib_id);
15135 mp->default_cop = default_cop;
15139 /* Wait for the reply */
15145 api_get_node_graph (vat_main_t * vam)
15147 vl_api_get_node_graph_t *mp;
15150 M (GET_NODE_GRAPH, mp);
15154 /* Wait for the reply */
15160 /** Used for parsing LISP eids */
15161 typedef CLIB_PACKED(struct{
15162 u8 addr[16]; /**< eid address */
15163 u32 len; /**< prefix length if IP */
15164 u8 type; /**< type of eid */
15169 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
15171 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
15173 clib_memset (a, 0, sizeof (a[0]));
15175 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
15177 a->type = 0; /* ipv4 type */
15179 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
15181 a->type = 1; /* ipv6 type */
15183 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
15185 a->type = 2; /* mac type */
15187 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
15189 a->type = 3; /* NSH type */
15190 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
15191 nsh->spi = clib_host_to_net_u32 (nsh->spi);
15198 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
15207 lisp_eid_size_vat (u8 type)
15224 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
15226 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
15230 api_one_add_del_locator_set (vat_main_t * vam)
15232 unformat_input_t *input = vam->input;
15233 vl_api_one_add_del_locator_set_t *mp;
15235 u8 *locator_set_name = NULL;
15236 u8 locator_set_name_set = 0;
15237 vl_api_local_locator_t locator, *locators = 0;
15238 u32 sw_if_index, priority, weight;
15242 /* Parse args required to build the message */
15243 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15245 if (unformat (input, "del"))
15249 else if (unformat (input, "locator-set %s", &locator_set_name))
15251 locator_set_name_set = 1;
15253 else if (unformat (input, "sw_if_index %u p %u w %u",
15254 &sw_if_index, &priority, &weight))
15256 locator.sw_if_index = htonl (sw_if_index);
15257 locator.priority = priority;
15258 locator.weight = weight;
15259 vec_add1 (locators, locator);
15263 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
15264 &sw_if_index, &priority, &weight))
15266 locator.sw_if_index = htonl (sw_if_index);
15267 locator.priority = priority;
15268 locator.weight = weight;
15269 vec_add1 (locators, locator);
15275 if (locator_set_name_set == 0)
15277 errmsg ("missing locator-set name");
15278 vec_free (locators);
15282 if (vec_len (locator_set_name) > 64)
15284 errmsg ("locator-set name too long");
15285 vec_free (locator_set_name);
15286 vec_free (locators);
15289 vec_add1 (locator_set_name, 0);
15291 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
15293 /* Construct the API message */
15294 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
15296 mp->is_add = is_add;
15297 clib_memcpy (mp->locator_set_name, locator_set_name,
15298 vec_len (locator_set_name));
15299 vec_free (locator_set_name);
15301 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
15303 clib_memcpy (mp->locators, locators, data_len);
15304 vec_free (locators);
15309 /* Wait for a reply... */
15314 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
15317 api_one_add_del_locator (vat_main_t * vam)
15319 unformat_input_t *input = vam->input;
15320 vl_api_one_add_del_locator_t *mp;
15321 u32 tmp_if_index = ~0;
15322 u32 sw_if_index = ~0;
15323 u8 sw_if_index_set = 0;
15324 u8 sw_if_index_if_name_set = 0;
15326 u8 priority_set = 0;
15330 u8 *locator_set_name = NULL;
15331 u8 locator_set_name_set = 0;
15334 /* Parse args required to build the message */
15335 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15337 if (unformat (input, "del"))
15341 else if (unformat (input, "locator-set %s", &locator_set_name))
15343 locator_set_name_set = 1;
15345 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
15348 sw_if_index_if_name_set = 1;
15349 sw_if_index = tmp_if_index;
15351 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
15353 sw_if_index_set = 1;
15354 sw_if_index = tmp_if_index;
15356 else if (unformat (input, "p %d", &priority))
15360 else if (unformat (input, "w %d", &weight))
15368 if (locator_set_name_set == 0)
15370 errmsg ("missing locator-set name");
15374 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
15376 errmsg ("missing sw_if_index");
15377 vec_free (locator_set_name);
15381 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
15383 errmsg ("cannot use both params interface name and sw_if_index");
15384 vec_free (locator_set_name);
15388 if (priority_set == 0)
15390 errmsg ("missing locator-set priority");
15391 vec_free (locator_set_name);
15395 if (weight_set == 0)
15397 errmsg ("missing locator-set weight");
15398 vec_free (locator_set_name);
15402 if (vec_len (locator_set_name) > 64)
15404 errmsg ("locator-set name too long");
15405 vec_free (locator_set_name);
15408 vec_add1 (locator_set_name, 0);
15410 /* Construct the API message */
15411 M (ONE_ADD_DEL_LOCATOR, mp);
15413 mp->is_add = is_add;
15414 mp->sw_if_index = ntohl (sw_if_index);
15415 mp->priority = priority;
15416 mp->weight = weight;
15417 clib_memcpy (mp->locator_set_name, locator_set_name,
15418 vec_len (locator_set_name));
15419 vec_free (locator_set_name);
15424 /* Wait for a reply... */
15429 #define api_lisp_add_del_locator api_one_add_del_locator
15432 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
15434 u32 *key_id = va_arg (*args, u32 *);
15437 if (unformat (input, "%s", &s))
15439 if (!strcmp ((char *) s, "sha1"))
15440 key_id[0] = HMAC_SHA_1_96;
15441 else if (!strcmp ((char *) s, "sha256"))
15442 key_id[0] = HMAC_SHA_256_128;
15445 clib_warning ("invalid key_id: '%s'", s);
15446 key_id[0] = HMAC_NO_KEY;
15457 api_one_add_del_local_eid (vat_main_t * vam)
15459 unformat_input_t *input = vam->input;
15460 vl_api_one_add_del_local_eid_t *mp;
15463 lisp_eid_vat_t _eid, *eid = &_eid;
15464 u8 *locator_set_name = 0;
15465 u8 locator_set_name_set = 0;
15471 /* Parse args required to build the message */
15472 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15474 if (unformat (input, "del"))
15478 else if (unformat (input, "vni %d", &vni))
15482 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15486 else if (unformat (input, "locator-set %s", &locator_set_name))
15488 locator_set_name_set = 1;
15490 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
15492 else if (unformat (input, "secret-key %_%v%_", &key))
15498 if (locator_set_name_set == 0)
15500 errmsg ("missing locator-set name");
15506 errmsg ("EID address not set!");
15507 vec_free (locator_set_name);
15511 if (key && (0 == key_id))
15513 errmsg ("invalid key_id!");
15517 if (vec_len (key) > 64)
15519 errmsg ("key too long");
15524 if (vec_len (locator_set_name) > 64)
15526 errmsg ("locator-set name too long");
15527 vec_free (locator_set_name);
15530 vec_add1 (locator_set_name, 0);
15532 /* Construct the API message */
15533 M (ONE_ADD_DEL_LOCAL_EID, mp);
15535 mp->is_add = is_add;
15536 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15537 mp->eid_type = eid->type;
15538 mp->prefix_len = eid->len;
15539 mp->vni = clib_host_to_net_u32 (vni);
15540 mp->key_id = clib_host_to_net_u16 (key_id);
15541 clib_memcpy (mp->locator_set_name, locator_set_name,
15542 vec_len (locator_set_name));
15543 clib_memcpy (mp->key, key, vec_len (key));
15545 vec_free (locator_set_name);
15551 /* Wait for a reply... */
15556 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
15559 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
15561 u32 dp_table = 0, vni = 0;;
15562 unformat_input_t *input = vam->input;
15563 vl_api_gpe_add_del_fwd_entry_t *mp;
15565 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
15566 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
15567 u8 rmt_eid_set = 0, lcl_eid_set = 0;
15568 u32 action = ~0, w;
15569 ip4_address_t rmt_rloc4, lcl_rloc4;
15570 ip6_address_t rmt_rloc6, lcl_rloc6;
15571 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
15574 clib_memset (&rloc, 0, sizeof (rloc));
15576 /* Parse args required to build the message */
15577 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15579 if (unformat (input, "del"))
15581 else if (unformat (input, "add"))
15583 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
15587 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
15591 else if (unformat (input, "vrf %d", &dp_table))
15593 else if (unformat (input, "bd %d", &dp_table))
15595 else if (unformat (input, "vni %d", &vni))
15597 else if (unformat (input, "w %d", &w))
15601 errmsg ("No RLOC configured for setting priority/weight!");
15604 curr_rloc->weight = w;
15606 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
15607 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
15611 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
15613 vec_add1 (lcl_locs, rloc);
15615 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
15616 vec_add1 (rmt_locs, rloc);
15617 /* weight saved in rmt loc */
15618 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15620 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
15621 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
15624 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
15626 vec_add1 (lcl_locs, rloc);
15628 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
15629 vec_add1 (rmt_locs, rloc);
15630 /* weight saved in rmt loc */
15631 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15633 else if (unformat (input, "action %d", &action))
15639 clib_warning ("parse error '%U'", format_unformat_error, input);
15646 errmsg ("remote eid addresses not set");
15650 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
15652 errmsg ("eid types don't match");
15656 if (0 == rmt_locs && (u32) ~ 0 == action)
15658 errmsg ("action not set for negative mapping");
15662 /* Construct the API message */
15663 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
15664 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
15666 mp->is_add = is_add;
15667 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
15668 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
15669 mp->eid_type = rmt_eid->type;
15670 mp->dp_table = clib_host_to_net_u32 (dp_table);
15671 mp->vni = clib_host_to_net_u32 (vni);
15672 mp->rmt_len = rmt_eid->len;
15673 mp->lcl_len = lcl_eid->len;
15674 mp->action = action;
15676 if (0 != rmt_locs && 0 != lcl_locs)
15678 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
15679 clib_memcpy (mp->locs, lcl_locs,
15680 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
15682 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
15683 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
15684 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
15686 vec_free (lcl_locs);
15687 vec_free (rmt_locs);
15692 /* Wait for a reply... */
15698 api_one_add_del_map_server (vat_main_t * vam)
15700 unformat_input_t *input = vam->input;
15701 vl_api_one_add_del_map_server_t *mp;
15705 ip4_address_t ipv4;
15706 ip6_address_t ipv6;
15709 /* Parse args required to build the message */
15710 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15712 if (unformat (input, "del"))
15716 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15720 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15728 if (ipv4_set && ipv6_set)
15730 errmsg ("both eid v4 and v6 addresses set");
15734 if (!ipv4_set && !ipv6_set)
15736 errmsg ("eid addresses not set");
15740 /* Construct the API message */
15741 M (ONE_ADD_DEL_MAP_SERVER, mp);
15743 mp->is_add = is_add;
15747 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
15752 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
15758 /* Wait for a reply... */
15763 #define api_lisp_add_del_map_server api_one_add_del_map_server
15766 api_one_add_del_map_resolver (vat_main_t * vam)
15768 unformat_input_t *input = vam->input;
15769 vl_api_one_add_del_map_resolver_t *mp;
15773 ip4_address_t ipv4;
15774 ip6_address_t ipv6;
15777 /* Parse args required to build the message */
15778 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15780 if (unformat (input, "del"))
15784 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15788 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15796 if (ipv4_set && ipv6_set)
15798 errmsg ("both eid v4 and v6 addresses set");
15802 if (!ipv4_set && !ipv6_set)
15804 errmsg ("eid addresses not set");
15808 /* Construct the API message */
15809 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
15811 mp->is_add = is_add;
15815 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
15820 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
15826 /* Wait for a reply... */
15831 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
15834 api_lisp_gpe_enable_disable (vat_main_t * vam)
15836 unformat_input_t *input = vam->input;
15837 vl_api_gpe_enable_disable_t *mp;
15842 /* Parse args required to build the message */
15843 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15845 if (unformat (input, "enable"))
15850 else if (unformat (input, "disable"))
15861 errmsg ("Value not set");
15865 /* Construct the API message */
15866 M (GPE_ENABLE_DISABLE, mp);
15873 /* Wait for a reply... */
15879 api_one_rloc_probe_enable_disable (vat_main_t * vam)
15881 unformat_input_t *input = vam->input;
15882 vl_api_one_rloc_probe_enable_disable_t *mp;
15887 /* Parse args required to build the message */
15888 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15890 if (unformat (input, "enable"))
15895 else if (unformat (input, "disable"))
15903 errmsg ("Value not set");
15907 /* Construct the API message */
15908 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
15910 mp->is_enabled = is_en;
15915 /* Wait for a reply... */
15920 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
15923 api_one_map_register_enable_disable (vat_main_t * vam)
15925 unformat_input_t *input = vam->input;
15926 vl_api_one_map_register_enable_disable_t *mp;
15931 /* Parse args required to build the message */
15932 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15934 if (unformat (input, "enable"))
15939 else if (unformat (input, "disable"))
15947 errmsg ("Value not set");
15951 /* Construct the API message */
15952 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
15954 mp->is_enabled = is_en;
15959 /* Wait for a reply... */
15964 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
15967 api_one_enable_disable (vat_main_t * vam)
15969 unformat_input_t *input = vam->input;
15970 vl_api_one_enable_disable_t *mp;
15975 /* Parse args required to build the message */
15976 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15978 if (unformat (input, "enable"))
15983 else if (unformat (input, "disable"))
15993 errmsg ("Value not set");
15997 /* Construct the API message */
15998 M (ONE_ENABLE_DISABLE, mp);
16005 /* Wait for a reply... */
16010 #define api_lisp_enable_disable api_one_enable_disable
16013 api_one_enable_disable_xtr_mode (vat_main_t * vam)
16015 unformat_input_t *input = vam->input;
16016 vl_api_one_enable_disable_xtr_mode_t *mp;
16021 /* Parse args required to build the message */
16022 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16024 if (unformat (input, "enable"))
16029 else if (unformat (input, "disable"))
16039 errmsg ("Value not set");
16043 /* Construct the API message */
16044 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
16051 /* Wait for a reply... */
16057 api_one_show_xtr_mode (vat_main_t * vam)
16059 vl_api_one_show_xtr_mode_t *mp;
16062 /* Construct the API message */
16063 M (ONE_SHOW_XTR_MODE, mp);
16068 /* Wait for a reply... */
16074 api_one_enable_disable_pitr_mode (vat_main_t * vam)
16076 unformat_input_t *input = vam->input;
16077 vl_api_one_enable_disable_pitr_mode_t *mp;
16082 /* Parse args required to build the message */
16083 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16085 if (unformat (input, "enable"))
16090 else if (unformat (input, "disable"))
16100 errmsg ("Value not set");
16104 /* Construct the API message */
16105 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
16112 /* Wait for a reply... */
16118 api_one_show_pitr_mode (vat_main_t * vam)
16120 vl_api_one_show_pitr_mode_t *mp;
16123 /* Construct the API message */
16124 M (ONE_SHOW_PITR_MODE, mp);
16129 /* Wait for a reply... */
16135 api_one_enable_disable_petr_mode (vat_main_t * vam)
16137 unformat_input_t *input = vam->input;
16138 vl_api_one_enable_disable_petr_mode_t *mp;
16143 /* Parse args required to build the message */
16144 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16146 if (unformat (input, "enable"))
16151 else if (unformat (input, "disable"))
16161 errmsg ("Value not set");
16165 /* Construct the API message */
16166 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
16173 /* Wait for a reply... */
16179 api_one_show_petr_mode (vat_main_t * vam)
16181 vl_api_one_show_petr_mode_t *mp;
16184 /* Construct the API message */
16185 M (ONE_SHOW_PETR_MODE, mp);
16190 /* Wait for a reply... */
16196 api_show_one_map_register_state (vat_main_t * vam)
16198 vl_api_show_one_map_register_state_t *mp;
16201 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
16206 /* wait for reply */
16211 #define api_show_lisp_map_register_state api_show_one_map_register_state
16214 api_show_one_rloc_probe_state (vat_main_t * vam)
16216 vl_api_show_one_rloc_probe_state_t *mp;
16219 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
16224 /* wait for reply */
16229 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
16232 api_one_add_del_ndp_entry (vat_main_t * vam)
16234 vl_api_one_add_del_ndp_entry_t *mp;
16235 unformat_input_t *input = vam->input;
16240 u8 mac[6] = { 0, };
16241 u8 ip6[16] = { 0, };
16245 /* Parse args required to build the message */
16246 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16248 if (unformat (input, "del"))
16250 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16252 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
16254 else if (unformat (input, "bd %d", &bd))
16258 errmsg ("parse error '%U'", format_unformat_error, input);
16263 if (!bd_set || !ip_set || (!mac_set && is_add))
16265 errmsg ("Missing BD, IP or MAC!");
16269 M (ONE_ADD_DEL_NDP_ENTRY, mp);
16270 mp->is_add = is_add;
16271 clib_memcpy (mp->mac, mac, 6);
16272 mp->bd = clib_host_to_net_u32 (bd);
16273 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
16278 /* wait for reply */
16284 api_one_add_del_l2_arp_entry (vat_main_t * vam)
16286 vl_api_one_add_del_l2_arp_entry_t *mp;
16287 unformat_input_t *input = vam->input;
16292 u8 mac[6] = { 0, };
16293 u32 ip4 = 0, bd = ~0;
16296 /* Parse args required to build the message */
16297 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16299 if (unformat (input, "del"))
16301 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16303 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
16305 else if (unformat (input, "bd %d", &bd))
16309 errmsg ("parse error '%U'", format_unformat_error, input);
16314 if (!bd_set || !ip_set || (!mac_set && is_add))
16316 errmsg ("Missing BD, IP or MAC!");
16320 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
16321 mp->is_add = is_add;
16322 clib_memcpy (mp->mac, mac, 6);
16323 mp->bd = clib_host_to_net_u32 (bd);
16329 /* wait for reply */
16335 api_one_ndp_bd_get (vat_main_t * vam)
16337 vl_api_one_ndp_bd_get_t *mp;
16340 M (ONE_NDP_BD_GET, mp);
16345 /* wait for reply */
16351 api_one_ndp_entries_get (vat_main_t * vam)
16353 vl_api_one_ndp_entries_get_t *mp;
16354 unformat_input_t *input = vam->input;
16359 /* Parse args required to build the message */
16360 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16362 if (unformat (input, "bd %d", &bd))
16366 errmsg ("parse error '%U'", format_unformat_error, input);
16373 errmsg ("Expected bridge domain!");
16377 M (ONE_NDP_ENTRIES_GET, mp);
16378 mp->bd = clib_host_to_net_u32 (bd);
16383 /* wait for reply */
16389 api_one_l2_arp_bd_get (vat_main_t * vam)
16391 vl_api_one_l2_arp_bd_get_t *mp;
16394 M (ONE_L2_ARP_BD_GET, mp);
16399 /* wait for reply */
16405 api_one_l2_arp_entries_get (vat_main_t * vam)
16407 vl_api_one_l2_arp_entries_get_t *mp;
16408 unformat_input_t *input = vam->input;
16413 /* Parse args required to build the message */
16414 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16416 if (unformat (input, "bd %d", &bd))
16420 errmsg ("parse error '%U'", format_unformat_error, input);
16427 errmsg ("Expected bridge domain!");
16431 M (ONE_L2_ARP_ENTRIES_GET, mp);
16432 mp->bd = clib_host_to_net_u32 (bd);
16437 /* wait for reply */
16443 api_one_stats_enable_disable (vat_main_t * vam)
16445 vl_api_one_stats_enable_disable_t *mp;
16446 unformat_input_t *input = vam->input;
16451 /* Parse args required to build the message */
16452 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16454 if (unformat (input, "enable"))
16459 else if (unformat (input, "disable"))
16469 errmsg ("Value not set");
16473 M (ONE_STATS_ENABLE_DISABLE, mp);
16479 /* wait for reply */
16485 api_show_one_stats_enable_disable (vat_main_t * vam)
16487 vl_api_show_one_stats_enable_disable_t *mp;
16490 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
16495 /* wait for reply */
16501 api_show_one_map_request_mode (vat_main_t * vam)
16503 vl_api_show_one_map_request_mode_t *mp;
16506 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
16511 /* wait for reply */
16516 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
16519 api_one_map_request_mode (vat_main_t * vam)
16521 unformat_input_t *input = vam->input;
16522 vl_api_one_map_request_mode_t *mp;
16526 /* Parse args required to build the message */
16527 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16529 if (unformat (input, "dst-only"))
16531 else if (unformat (input, "src-dst"))
16535 errmsg ("parse error '%U'", format_unformat_error, input);
16540 M (ONE_MAP_REQUEST_MODE, mp);
16547 /* wait for reply */
16552 #define api_lisp_map_request_mode api_one_map_request_mode
16555 * Enable/disable ONE proxy ITR.
16557 * @param vam vpp API test context
16558 * @return return code
16561 api_one_pitr_set_locator_set (vat_main_t * vam)
16563 u8 ls_name_set = 0;
16564 unformat_input_t *input = vam->input;
16565 vl_api_one_pitr_set_locator_set_t *mp;
16570 /* Parse args required to build the message */
16571 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16573 if (unformat (input, "del"))
16575 else if (unformat (input, "locator-set %s", &ls_name))
16579 errmsg ("parse error '%U'", format_unformat_error, input);
16586 errmsg ("locator-set name not set!");
16590 M (ONE_PITR_SET_LOCATOR_SET, mp);
16592 mp->is_add = is_add;
16593 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16594 vec_free (ls_name);
16599 /* wait for reply */
16604 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
16607 api_one_nsh_set_locator_set (vat_main_t * vam)
16609 u8 ls_name_set = 0;
16610 unformat_input_t *input = vam->input;
16611 vl_api_one_nsh_set_locator_set_t *mp;
16616 /* Parse args required to build the message */
16617 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16619 if (unformat (input, "del"))
16621 else if (unformat (input, "ls %s", &ls_name))
16625 errmsg ("parse error '%U'", format_unformat_error, input);
16630 if (!ls_name_set && is_add)
16632 errmsg ("locator-set name not set!");
16636 M (ONE_NSH_SET_LOCATOR_SET, mp);
16638 mp->is_add = is_add;
16639 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16640 vec_free (ls_name);
16645 /* wait for reply */
16651 api_show_one_pitr (vat_main_t * vam)
16653 vl_api_show_one_pitr_t *mp;
16656 if (!vam->json_output)
16658 print (vam->ofp, "%=20s", "lisp status:");
16661 M (SHOW_ONE_PITR, mp);
16665 /* Wait for a reply... */
16670 #define api_show_lisp_pitr api_show_one_pitr
16673 api_one_use_petr (vat_main_t * vam)
16675 unformat_input_t *input = vam->input;
16676 vl_api_one_use_petr_t *mp;
16681 clib_memset (&ip, 0, sizeof (ip));
16683 /* Parse args required to build the message */
16684 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16686 if (unformat (input, "disable"))
16689 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
16692 ip_addr_version (&ip) = IP4;
16695 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
16698 ip_addr_version (&ip) = IP6;
16702 errmsg ("parse error '%U'", format_unformat_error, input);
16707 M (ONE_USE_PETR, mp);
16709 mp->is_add = is_add;
16712 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
16714 clib_memcpy (mp->address, &ip, 4);
16716 clib_memcpy (mp->address, &ip, 16);
16722 /* wait for reply */
16727 #define api_lisp_use_petr api_one_use_petr
16730 api_show_one_nsh_mapping (vat_main_t * vam)
16732 vl_api_show_one_use_petr_t *mp;
16735 if (!vam->json_output)
16737 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
16740 M (SHOW_ONE_NSH_MAPPING, mp);
16744 /* Wait for a reply... */
16750 api_show_one_use_petr (vat_main_t * vam)
16752 vl_api_show_one_use_petr_t *mp;
16755 if (!vam->json_output)
16757 print (vam->ofp, "%=20s", "Proxy-ETR status:");
16760 M (SHOW_ONE_USE_PETR, mp);
16764 /* Wait for a reply... */
16769 #define api_show_lisp_use_petr api_show_one_use_petr
16772 * Add/delete mapping between vni and vrf
16775 api_one_eid_table_add_del_map (vat_main_t * vam)
16777 unformat_input_t *input = vam->input;
16778 vl_api_one_eid_table_add_del_map_t *mp;
16779 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
16780 u32 vni, vrf, bd_index;
16783 /* Parse args required to build the message */
16784 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16786 if (unformat (input, "del"))
16788 else if (unformat (input, "vrf %d", &vrf))
16790 else if (unformat (input, "bd_index %d", &bd_index))
16792 else if (unformat (input, "vni %d", &vni))
16798 if (!vni_set || (!vrf_set && !bd_index_set))
16800 errmsg ("missing arguments!");
16804 if (vrf_set && bd_index_set)
16806 errmsg ("error: both vrf and bd entered!");
16810 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
16812 mp->is_add = is_add;
16813 mp->vni = htonl (vni);
16814 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
16815 mp->is_l2 = bd_index_set;
16820 /* wait for reply */
16825 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
16828 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
16830 u32 *action = va_arg (*args, u32 *);
16833 if (unformat (input, "%s", &s))
16835 if (!strcmp ((char *) s, "no-action"))
16837 else if (!strcmp ((char *) s, "natively-forward"))
16839 else if (!strcmp ((char *) s, "send-map-request"))
16841 else if (!strcmp ((char *) s, "drop"))
16845 clib_warning ("invalid action: '%s'", s);
16857 * Add/del remote mapping to/from ONE control plane
16859 * @param vam vpp API test context
16860 * @return return code
16863 api_one_add_del_remote_mapping (vat_main_t * vam)
16865 unformat_input_t *input = vam->input;
16866 vl_api_one_add_del_remote_mapping_t *mp;
16868 lisp_eid_vat_t _eid, *eid = &_eid;
16869 lisp_eid_vat_t _seid, *seid = &_seid;
16870 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
16871 u32 action = ~0, p, w, data_len;
16872 ip4_address_t rloc4;
16873 ip6_address_t rloc6;
16874 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
16877 clib_memset (&rloc, 0, sizeof (rloc));
16879 /* Parse args required to build the message */
16880 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16882 if (unformat (input, "del-all"))
16886 else if (unformat (input, "del"))
16890 else if (unformat (input, "add"))
16894 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
16898 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
16902 else if (unformat (input, "vni %d", &vni))
16906 else if (unformat (input, "p %d w %d", &p, &w))
16910 errmsg ("No RLOC configured for setting priority/weight!");
16913 curr_rloc->priority = p;
16914 curr_rloc->weight = w;
16916 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
16919 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
16920 vec_add1 (rlocs, rloc);
16921 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16923 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
16926 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
16927 vec_add1 (rlocs, rloc);
16928 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16930 else if (unformat (input, "action %U",
16931 unformat_negative_mapping_action, &action))
16937 clib_warning ("parse error '%U'", format_unformat_error, input);
16944 errmsg ("missing params!");
16948 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
16950 errmsg ("no action set for negative map-reply!");
16954 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
16956 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
16957 mp->is_add = is_add;
16958 mp->vni = htonl (vni);
16959 mp->action = (u8) action;
16960 mp->is_src_dst = seid_set;
16961 mp->eid_len = eid->len;
16962 mp->seid_len = seid->len;
16963 mp->del_all = del_all;
16964 mp->eid_type = eid->type;
16965 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
16966 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
16968 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
16969 clib_memcpy (mp->rlocs, rlocs, data_len);
16975 /* Wait for a reply... */
16980 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
16983 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
16984 * forwarding entries in data-plane accordingly.
16986 * @param vam vpp API test context
16987 * @return return code
16990 api_one_add_del_adjacency (vat_main_t * vam)
16992 unformat_input_t *input = vam->input;
16993 vl_api_one_add_del_adjacency_t *mp;
16995 ip4_address_t leid4, reid4;
16996 ip6_address_t leid6, reid6;
16997 u8 reid_mac[6] = { 0 };
16998 u8 leid_mac[6] = { 0 };
16999 u8 reid_type, leid_type;
17000 u32 leid_len = 0, reid_len = 0, len;
17004 leid_type = reid_type = (u8) ~ 0;
17006 /* Parse args required to build the message */
17007 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17009 if (unformat (input, "del"))
17013 else if (unformat (input, "add"))
17017 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
17020 reid_type = 0; /* ipv4 */
17023 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
17026 reid_type = 1; /* ipv6 */
17029 else if (unformat (input, "reid %U", unformat_ethernet_address,
17032 reid_type = 2; /* mac */
17034 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
17037 leid_type = 0; /* ipv4 */
17040 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
17043 leid_type = 1; /* ipv6 */
17046 else if (unformat (input, "leid %U", unformat_ethernet_address,
17049 leid_type = 2; /* mac */
17051 else if (unformat (input, "vni %d", &vni))
17057 errmsg ("parse error '%U'", format_unformat_error, input);
17062 if ((u8) ~ 0 == reid_type)
17064 errmsg ("missing params!");
17068 if (leid_type != reid_type)
17070 errmsg ("remote and local EIDs are of different types!");
17074 M (ONE_ADD_DEL_ADJACENCY, mp);
17075 mp->is_add = is_add;
17076 mp->vni = htonl (vni);
17077 mp->leid_len = leid_len;
17078 mp->reid_len = reid_len;
17079 mp->eid_type = reid_type;
17081 switch (mp->eid_type)
17084 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
17085 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
17088 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
17089 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
17092 clib_memcpy (mp->leid, leid_mac, 6);
17093 clib_memcpy (mp->reid, reid_mac, 6);
17096 errmsg ("unknown EID type %d!", mp->eid_type);
17103 /* Wait for a reply... */
17108 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
17111 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
17113 u32 *mode = va_arg (*args, u32 *);
17115 if (unformat (input, "lisp"))
17117 else if (unformat (input, "vxlan"))
17126 api_gpe_get_encap_mode (vat_main_t * vam)
17128 vl_api_gpe_get_encap_mode_t *mp;
17131 /* Construct the API message */
17132 M (GPE_GET_ENCAP_MODE, mp);
17137 /* Wait for a reply... */
17143 api_gpe_set_encap_mode (vat_main_t * vam)
17145 unformat_input_t *input = vam->input;
17146 vl_api_gpe_set_encap_mode_t *mp;
17150 /* Parse args required to build the message */
17151 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17153 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
17159 /* Construct the API message */
17160 M (GPE_SET_ENCAP_MODE, mp);
17167 /* Wait for a reply... */
17173 api_lisp_gpe_add_del_iface (vat_main_t * vam)
17175 unformat_input_t *input = vam->input;
17176 vl_api_gpe_add_del_iface_t *mp;
17177 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
17178 u32 dp_table = 0, vni = 0;
17181 /* Parse args required to build the message */
17182 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17184 if (unformat (input, "up"))
17189 else if (unformat (input, "down"))
17194 else if (unformat (input, "table_id %d", &dp_table))
17198 else if (unformat (input, "bd_id %d", &dp_table))
17203 else if (unformat (input, "vni %d", &vni))
17211 if (action_set == 0)
17213 errmsg ("Action not set");
17216 if (dp_table_set == 0 || vni_set == 0)
17218 errmsg ("vni and dp_table must be set");
17222 /* Construct the API message */
17223 M (GPE_ADD_DEL_IFACE, mp);
17225 mp->is_add = is_add;
17226 mp->dp_table = clib_host_to_net_u32 (dp_table);
17228 mp->vni = clib_host_to_net_u32 (vni);
17233 /* Wait for a reply... */
17239 api_one_map_register_fallback_threshold (vat_main_t * vam)
17241 unformat_input_t *input = vam->input;
17242 vl_api_one_map_register_fallback_threshold_t *mp;
17247 /* Parse args required to build the message */
17248 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17250 if (unformat (input, "%u", &value))
17254 clib_warning ("parse error '%U'", format_unformat_error, input);
17261 errmsg ("fallback threshold value is missing!");
17265 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17266 mp->value = clib_host_to_net_u32 (value);
17271 /* Wait for a reply... */
17277 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
17279 vl_api_show_one_map_register_fallback_threshold_t *mp;
17282 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17287 /* Wait for a reply... */
17293 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
17295 u32 *proto = va_arg (*args, u32 *);
17297 if (unformat (input, "udp"))
17299 else if (unformat (input, "api"))
17308 api_one_set_transport_protocol (vat_main_t * vam)
17310 unformat_input_t *input = vam->input;
17311 vl_api_one_set_transport_protocol_t *mp;
17316 /* Parse args required to build the message */
17317 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17319 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
17323 clib_warning ("parse error '%U'", format_unformat_error, input);
17330 errmsg ("Transport protocol missing!");
17334 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
17335 mp->protocol = (u8) protocol;
17340 /* Wait for a reply... */
17346 api_one_get_transport_protocol (vat_main_t * vam)
17348 vl_api_one_get_transport_protocol_t *mp;
17351 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
17356 /* Wait for a reply... */
17362 api_one_map_register_set_ttl (vat_main_t * vam)
17364 unformat_input_t *input = vam->input;
17365 vl_api_one_map_register_set_ttl_t *mp;
17370 /* Parse args required to build the message */
17371 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17373 if (unformat (input, "%u", &ttl))
17377 clib_warning ("parse error '%U'", format_unformat_error, input);
17384 errmsg ("TTL value missing!");
17388 M (ONE_MAP_REGISTER_SET_TTL, mp);
17389 mp->ttl = clib_host_to_net_u32 (ttl);
17394 /* Wait for a reply... */
17400 api_show_one_map_register_ttl (vat_main_t * vam)
17402 vl_api_show_one_map_register_ttl_t *mp;
17405 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
17410 /* Wait for a reply... */
17416 * Add/del map request itr rlocs from ONE control plane and updates
17418 * @param vam vpp API test context
17419 * @return return code
17422 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
17424 unformat_input_t *input = vam->input;
17425 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
17426 u8 *locator_set_name = 0;
17427 u8 locator_set_name_set = 0;
17431 /* Parse args required to build the message */
17432 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17434 if (unformat (input, "del"))
17438 else if (unformat (input, "%_%v%_", &locator_set_name))
17440 locator_set_name_set = 1;
17444 clib_warning ("parse error '%U'", format_unformat_error, input);
17449 if (is_add && !locator_set_name_set)
17451 errmsg ("itr-rloc is not set!");
17455 if (is_add && vec_len (locator_set_name) > 64)
17457 errmsg ("itr-rloc locator-set name too long");
17458 vec_free (locator_set_name);
17462 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
17463 mp->is_add = is_add;
17466 clib_memcpy (mp->locator_set_name, locator_set_name,
17467 vec_len (locator_set_name));
17471 clib_memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
17473 vec_free (locator_set_name);
17478 /* Wait for a reply... */
17483 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
17486 api_one_locator_dump (vat_main_t * vam)
17488 unformat_input_t *input = vam->input;
17489 vl_api_one_locator_dump_t *mp;
17490 vl_api_control_ping_t *mp_ping;
17491 u8 is_index_set = 0, is_name_set = 0;
17496 /* Parse args required to build the message */
17497 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17499 if (unformat (input, "ls_name %_%v%_", &ls_name))
17503 else if (unformat (input, "ls_index %d", &ls_index))
17509 errmsg ("parse error '%U'", format_unformat_error, input);
17514 if (!is_index_set && !is_name_set)
17516 errmsg ("error: expected one of index or name!");
17520 if (is_index_set && is_name_set)
17522 errmsg ("error: only one param expected!");
17526 if (vec_len (ls_name) > 62)
17528 errmsg ("error: locator set name too long!");
17532 if (!vam->json_output)
17534 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
17537 M (ONE_LOCATOR_DUMP, mp);
17538 mp->is_index_set = is_index_set;
17541 mp->ls_index = clib_host_to_net_u32 (ls_index);
17544 vec_add1 (ls_name, 0);
17545 strncpy ((char *) mp->ls_name, (char *) ls_name,
17546 sizeof (mp->ls_name) - 1);
17552 /* Use a control ping for synchronization */
17553 MPING (CONTROL_PING, mp_ping);
17556 /* Wait for a reply... */
17561 #define api_lisp_locator_dump api_one_locator_dump
17564 api_one_locator_set_dump (vat_main_t * vam)
17566 vl_api_one_locator_set_dump_t *mp;
17567 vl_api_control_ping_t *mp_ping;
17568 unformat_input_t *input = vam->input;
17572 /* Parse args required to build the message */
17573 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17575 if (unformat (input, "local"))
17579 else if (unformat (input, "remote"))
17585 errmsg ("parse error '%U'", format_unformat_error, input);
17590 if (!vam->json_output)
17592 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
17595 M (ONE_LOCATOR_SET_DUMP, mp);
17597 mp->filter = filter;
17602 /* Use a control ping for synchronization */
17603 MPING (CONTROL_PING, mp_ping);
17606 /* Wait for a reply... */
17611 #define api_lisp_locator_set_dump api_one_locator_set_dump
17614 api_one_eid_table_map_dump (vat_main_t * vam)
17618 unformat_input_t *input = vam->input;
17619 vl_api_one_eid_table_map_dump_t *mp;
17620 vl_api_control_ping_t *mp_ping;
17623 /* Parse args required to build the message */
17624 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17626 if (unformat (input, "l2"))
17631 else if (unformat (input, "l3"))
17638 errmsg ("parse error '%U'", format_unformat_error, input);
17645 errmsg ("expected one of 'l2' or 'l3' parameter!");
17649 if (!vam->json_output)
17651 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
17654 M (ONE_EID_TABLE_MAP_DUMP, mp);
17660 /* Use a control ping for synchronization */
17661 MPING (CONTROL_PING, mp_ping);
17664 /* Wait for a reply... */
17669 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
17672 api_one_eid_table_vni_dump (vat_main_t * vam)
17674 vl_api_one_eid_table_vni_dump_t *mp;
17675 vl_api_control_ping_t *mp_ping;
17678 if (!vam->json_output)
17680 print (vam->ofp, "VNI");
17683 M (ONE_EID_TABLE_VNI_DUMP, mp);
17688 /* Use a control ping for synchronization */
17689 MPING (CONTROL_PING, mp_ping);
17692 /* Wait for a reply... */
17697 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
17700 api_one_eid_table_dump (vat_main_t * vam)
17702 unformat_input_t *i = vam->input;
17703 vl_api_one_eid_table_dump_t *mp;
17704 vl_api_control_ping_t *mp_ping;
17705 struct in_addr ip4;
17706 struct in6_addr ip6;
17708 u8 eid_type = ~0, eid_set = 0;
17709 u32 prefix_length = ~0, t, vni = 0;
17712 lisp_nsh_api_t nsh;
17714 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17716 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
17722 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
17728 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
17733 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
17738 else if (unformat (i, "vni %d", &t))
17742 else if (unformat (i, "local"))
17746 else if (unformat (i, "remote"))
17752 errmsg ("parse error '%U'", format_unformat_error, i);
17757 if (!vam->json_output)
17759 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
17760 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
17763 M (ONE_EID_TABLE_DUMP, mp);
17765 mp->filter = filter;
17769 mp->vni = htonl (vni);
17770 mp->eid_type = eid_type;
17774 mp->prefix_length = prefix_length;
17775 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
17778 mp->prefix_length = prefix_length;
17779 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
17782 clib_memcpy (mp->eid, mac, sizeof (mac));
17785 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
17788 errmsg ("unknown EID type %d!", eid_type);
17796 /* Use a control ping for synchronization */
17797 MPING (CONTROL_PING, mp_ping);
17800 /* Wait for a reply... */
17805 #define api_lisp_eid_table_dump api_one_eid_table_dump
17808 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
17810 unformat_input_t *i = vam->input;
17811 vl_api_gpe_fwd_entries_get_t *mp;
17816 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17818 if (unformat (i, "vni %d", &vni))
17824 errmsg ("parse error '%U'", format_unformat_error, i);
17831 errmsg ("vni not set!");
17835 if (!vam->json_output)
17837 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
17841 M (GPE_FWD_ENTRIES_GET, mp);
17842 mp->vni = clib_host_to_net_u32 (vni);
17847 /* Wait for a reply... */
17852 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
17853 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
17854 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
17855 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
17856 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
17857 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
17858 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
17859 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
17862 api_one_adjacencies_get (vat_main_t * vam)
17864 unformat_input_t *i = vam->input;
17865 vl_api_one_adjacencies_get_t *mp;
17870 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17872 if (unformat (i, "vni %d", &vni))
17878 errmsg ("parse error '%U'", format_unformat_error, i);
17885 errmsg ("vni not set!");
17889 if (!vam->json_output)
17891 print (vam->ofp, "%s %40s", "leid", "reid");
17894 M (ONE_ADJACENCIES_GET, mp);
17895 mp->vni = clib_host_to_net_u32 (vni);
17900 /* Wait for a reply... */
17905 #define api_lisp_adjacencies_get api_one_adjacencies_get
17908 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
17910 unformat_input_t *i = vam->input;
17911 vl_api_gpe_native_fwd_rpaths_get_t *mp;
17913 u8 ip_family_set = 0, is_ip4 = 1;
17915 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17917 if (unformat (i, "ip4"))
17922 else if (unformat (i, "ip6"))
17929 errmsg ("parse error '%U'", format_unformat_error, i);
17934 if (!ip_family_set)
17936 errmsg ("ip family not set!");
17940 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
17941 mp->is_ip4 = is_ip4;
17946 /* Wait for a reply... */
17952 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
17954 vl_api_gpe_fwd_entry_vnis_get_t *mp;
17957 if (!vam->json_output)
17959 print (vam->ofp, "VNIs");
17962 M (GPE_FWD_ENTRY_VNIS_GET, mp);
17967 /* Wait for a reply... */
17973 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
17975 unformat_input_t *i = vam->input;
17976 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
17978 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
17979 struct in_addr ip4;
17980 struct in6_addr ip6;
17981 u32 table_id = 0, nh_sw_if_index = ~0;
17983 clib_memset (&ip4, 0, sizeof (ip4));
17984 clib_memset (&ip6, 0, sizeof (ip6));
17986 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17988 if (unformat (i, "del"))
17990 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
17991 api_unformat_sw_if_index, vam, &nh_sw_if_index))
17996 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
17997 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18002 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
18006 nh_sw_if_index = ~0;
18008 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
18012 nh_sw_if_index = ~0;
18014 else if (unformat (i, "table %d", &table_id))
18018 errmsg ("parse error '%U'", format_unformat_error, i);
18025 errmsg ("nh addr not set!");
18029 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
18030 mp->is_add = is_add;
18031 mp->table_id = clib_host_to_net_u32 (table_id);
18032 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
18033 mp->is_ip4 = is_ip4;
18035 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
18037 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
18042 /* Wait for a reply... */
18048 api_one_map_server_dump (vat_main_t * vam)
18050 vl_api_one_map_server_dump_t *mp;
18051 vl_api_control_ping_t *mp_ping;
18054 if (!vam->json_output)
18056 print (vam->ofp, "%=20s", "Map server");
18059 M (ONE_MAP_SERVER_DUMP, mp);
18063 /* Use a control ping for synchronization */
18064 MPING (CONTROL_PING, mp_ping);
18067 /* Wait for a reply... */
18072 #define api_lisp_map_server_dump api_one_map_server_dump
18075 api_one_map_resolver_dump (vat_main_t * vam)
18077 vl_api_one_map_resolver_dump_t *mp;
18078 vl_api_control_ping_t *mp_ping;
18081 if (!vam->json_output)
18083 print (vam->ofp, "%=20s", "Map resolver");
18086 M (ONE_MAP_RESOLVER_DUMP, mp);
18090 /* Use a control ping for synchronization */
18091 MPING (CONTROL_PING, mp_ping);
18094 /* Wait for a reply... */
18099 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
18102 api_one_stats_flush (vat_main_t * vam)
18104 vl_api_one_stats_flush_t *mp;
18107 M (ONE_STATS_FLUSH, mp);
18114 api_one_stats_dump (vat_main_t * vam)
18116 vl_api_one_stats_dump_t *mp;
18117 vl_api_control_ping_t *mp_ping;
18120 M (ONE_STATS_DUMP, mp);
18124 /* Use a control ping for synchronization */
18125 MPING (CONTROL_PING, mp_ping);
18128 /* Wait for a reply... */
18134 api_show_one_status (vat_main_t * vam)
18136 vl_api_show_one_status_t *mp;
18139 if (!vam->json_output)
18141 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
18144 M (SHOW_ONE_STATUS, mp);
18147 /* Wait for a reply... */
18152 #define api_show_lisp_status api_show_one_status
18155 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
18157 vl_api_gpe_fwd_entry_path_dump_t *mp;
18158 vl_api_control_ping_t *mp_ping;
18159 unformat_input_t *i = vam->input;
18160 u32 fwd_entry_index = ~0;
18163 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18165 if (unformat (i, "index %d", &fwd_entry_index))
18171 if (~0 == fwd_entry_index)
18173 errmsg ("no index specified!");
18177 if (!vam->json_output)
18179 print (vam->ofp, "first line");
18182 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
18186 /* Use a control ping for synchronization */
18187 MPING (CONTROL_PING, mp_ping);
18190 /* Wait for a reply... */
18196 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
18198 vl_api_one_get_map_request_itr_rlocs_t *mp;
18201 if (!vam->json_output)
18203 print (vam->ofp, "%=20s", "itr-rlocs:");
18206 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
18209 /* Wait for a reply... */
18214 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
18217 api_af_packet_create (vat_main_t * vam)
18219 unformat_input_t *i = vam->input;
18220 vl_api_af_packet_create_t *mp;
18221 u8 *host_if_name = 0;
18223 u8 random_hw_addr = 1;
18226 clib_memset (hw_addr, 0, sizeof (hw_addr));
18228 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18230 if (unformat (i, "name %s", &host_if_name))
18231 vec_add1 (host_if_name, 0);
18232 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18233 random_hw_addr = 0;
18238 if (!vec_len (host_if_name))
18240 errmsg ("host-interface name must be specified");
18244 if (vec_len (host_if_name) > 64)
18246 errmsg ("host-interface name too long");
18250 M (AF_PACKET_CREATE, mp);
18252 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18253 clib_memcpy (mp->hw_addr, hw_addr, 6);
18254 mp->use_random_hw_addr = random_hw_addr;
18255 vec_free (host_if_name);
18263 fprintf (vam->ofp ? vam->ofp : stderr,
18264 " new sw_if_index = %d\n", vam->sw_if_index);
18271 api_af_packet_delete (vat_main_t * vam)
18273 unformat_input_t *i = vam->input;
18274 vl_api_af_packet_delete_t *mp;
18275 u8 *host_if_name = 0;
18278 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18280 if (unformat (i, "name %s", &host_if_name))
18281 vec_add1 (host_if_name, 0);
18286 if (!vec_len (host_if_name))
18288 errmsg ("host-interface name must be specified");
18292 if (vec_len (host_if_name) > 64)
18294 errmsg ("host-interface name too long");
18298 M (AF_PACKET_DELETE, mp);
18300 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18301 vec_free (host_if_name);
18308 static void vl_api_af_packet_details_t_handler
18309 (vl_api_af_packet_details_t * mp)
18311 vat_main_t *vam = &vat_main;
18313 print (vam->ofp, "%-16s %d",
18314 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
18317 static void vl_api_af_packet_details_t_handler_json
18318 (vl_api_af_packet_details_t * mp)
18320 vat_main_t *vam = &vat_main;
18321 vat_json_node_t *node = NULL;
18323 if (VAT_JSON_ARRAY != vam->json_tree.type)
18325 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18326 vat_json_init_array (&vam->json_tree);
18328 node = vat_json_array_add (&vam->json_tree);
18330 vat_json_init_object (node);
18331 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
18332 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
18336 api_af_packet_dump (vat_main_t * vam)
18338 vl_api_af_packet_dump_t *mp;
18339 vl_api_control_ping_t *mp_ping;
18342 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
18343 /* Get list of tap interfaces */
18344 M (AF_PACKET_DUMP, mp);
18347 /* Use a control ping for synchronization */
18348 MPING (CONTROL_PING, mp_ping);
18356 api_policer_add_del (vat_main_t * vam)
18358 unformat_input_t *i = vam->input;
18359 vl_api_policer_add_del_t *mp;
18369 u8 color_aware = 0;
18370 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
18373 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
18374 conform_action.dscp = 0;
18375 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
18376 exceed_action.dscp = 0;
18377 violate_action.action_type = SSE2_QOS_ACTION_DROP;
18378 violate_action.dscp = 0;
18380 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18382 if (unformat (i, "del"))
18384 else if (unformat (i, "name %s", &name))
18385 vec_add1 (name, 0);
18386 else if (unformat (i, "cir %u", &cir))
18388 else if (unformat (i, "eir %u", &eir))
18390 else if (unformat (i, "cb %u", &cb))
18392 else if (unformat (i, "eb %u", &eb))
18394 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
18397 else if (unformat (i, "round_type %U", unformat_policer_round_type,
18400 else if (unformat (i, "type %U", unformat_policer_type, &type))
18402 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
18405 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
18408 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
18411 else if (unformat (i, "color-aware"))
18417 if (!vec_len (name))
18419 errmsg ("policer name must be specified");
18423 if (vec_len (name) > 64)
18425 errmsg ("policer name too long");
18429 M (POLICER_ADD_DEL, mp);
18431 clib_memcpy (mp->name, name, vec_len (name));
18433 mp->is_add = is_add;
18434 mp->cir = ntohl (cir);
18435 mp->eir = ntohl (eir);
18436 mp->cb = clib_net_to_host_u64 (cb);
18437 mp->eb = clib_net_to_host_u64 (eb);
18438 mp->rate_type = rate_type;
18439 mp->round_type = round_type;
18441 mp->conform_action_type = conform_action.action_type;
18442 mp->conform_dscp = conform_action.dscp;
18443 mp->exceed_action_type = exceed_action.action_type;
18444 mp->exceed_dscp = exceed_action.dscp;
18445 mp->violate_action_type = violate_action.action_type;
18446 mp->violate_dscp = violate_action.dscp;
18447 mp->color_aware = color_aware;
18455 api_policer_dump (vat_main_t * vam)
18457 unformat_input_t *i = vam->input;
18458 vl_api_policer_dump_t *mp;
18459 vl_api_control_ping_t *mp_ping;
18460 u8 *match_name = 0;
18461 u8 match_name_valid = 0;
18464 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18466 if (unformat (i, "name %s", &match_name))
18468 vec_add1 (match_name, 0);
18469 match_name_valid = 1;
18475 M (POLICER_DUMP, mp);
18476 mp->match_name_valid = match_name_valid;
18477 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
18478 vec_free (match_name);
18482 /* Use a control ping for synchronization */
18483 MPING (CONTROL_PING, mp_ping);
18486 /* Wait for a reply... */
18492 api_policer_classify_set_interface (vat_main_t * vam)
18494 unformat_input_t *i = vam->input;
18495 vl_api_policer_classify_set_interface_t *mp;
18497 int sw_if_index_set;
18498 u32 ip4_table_index = ~0;
18499 u32 ip6_table_index = ~0;
18500 u32 l2_table_index = ~0;
18504 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18506 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18507 sw_if_index_set = 1;
18508 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18509 sw_if_index_set = 1;
18510 else if (unformat (i, "del"))
18512 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18514 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18516 else if (unformat (i, "l2-table %d", &l2_table_index))
18520 clib_warning ("parse error '%U'", format_unformat_error, i);
18525 if (sw_if_index_set == 0)
18527 errmsg ("missing interface name or sw_if_index");
18531 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
18533 mp->sw_if_index = ntohl (sw_if_index);
18534 mp->ip4_table_index = ntohl (ip4_table_index);
18535 mp->ip6_table_index = ntohl (ip6_table_index);
18536 mp->l2_table_index = ntohl (l2_table_index);
18537 mp->is_add = is_add;
18545 api_policer_classify_dump (vat_main_t * vam)
18547 unformat_input_t *i = vam->input;
18548 vl_api_policer_classify_dump_t *mp;
18549 vl_api_control_ping_t *mp_ping;
18550 u8 type = POLICER_CLASSIFY_N_TABLES;
18553 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
18557 errmsg ("classify table type must be specified");
18561 if (!vam->json_output)
18563 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
18566 M (POLICER_CLASSIFY_DUMP, mp);
18571 /* Use a control ping for synchronization */
18572 MPING (CONTROL_PING, mp_ping);
18575 /* Wait for a reply... */
18581 api_netmap_create (vat_main_t * vam)
18583 unformat_input_t *i = vam->input;
18584 vl_api_netmap_create_t *mp;
18587 u8 random_hw_addr = 1;
18592 clib_memset (hw_addr, 0, sizeof (hw_addr));
18594 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18596 if (unformat (i, "name %s", &if_name))
18597 vec_add1 (if_name, 0);
18598 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18599 random_hw_addr = 0;
18600 else if (unformat (i, "pipe"))
18602 else if (unformat (i, "master"))
18604 else if (unformat (i, "slave"))
18610 if (!vec_len (if_name))
18612 errmsg ("interface name must be specified");
18616 if (vec_len (if_name) > 64)
18618 errmsg ("interface name too long");
18622 M (NETMAP_CREATE, mp);
18624 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18625 clib_memcpy (mp->hw_addr, hw_addr, 6);
18626 mp->use_random_hw_addr = random_hw_addr;
18627 mp->is_pipe = is_pipe;
18628 mp->is_master = is_master;
18629 vec_free (if_name);
18637 api_netmap_delete (vat_main_t * vam)
18639 unformat_input_t *i = vam->input;
18640 vl_api_netmap_delete_t *mp;
18644 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18646 if (unformat (i, "name %s", &if_name))
18647 vec_add1 (if_name, 0);
18652 if (!vec_len (if_name))
18654 errmsg ("interface name must be specified");
18658 if (vec_len (if_name) > 64)
18660 errmsg ("interface name too long");
18664 M (NETMAP_DELETE, mp);
18666 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18667 vec_free (if_name);
18675 format_fib_api_path_nh_proto (u8 * s, va_list * args)
18677 vl_api_fib_path_nh_proto_t proto =
18678 va_arg (*args, vl_api_fib_path_nh_proto_t);
18682 case FIB_API_PATH_NH_PROTO_IP4:
18683 s = format (s, "ip4");
18685 case FIB_API_PATH_NH_PROTO_IP6:
18686 s = format (s, "ip6");
18688 case FIB_API_PATH_NH_PROTO_MPLS:
18689 s = format (s, "mpls");
18691 case FIB_API_PATH_NH_PROTO_BIER:
18692 s = format (s, "bier");
18694 case FIB_API_PATH_NH_PROTO_ETHERNET:
18695 s = format (s, "ethernet");
18703 format_vl_api_ip_address_union (u8 * s, va_list * args)
18705 vl_api_address_family_t af = va_arg (*args, vl_api_address_family_t);
18706 const vl_api_address_union_t *u = va_arg (*args, vl_api_address_union_t *);
18711 s = format (s, "%U", format_ip4_address, u->ip4);
18714 s = format (s, "%U", format_ip6_address, u->ip6);
18721 format_vl_api_fib_path_type (u8 * s, va_list * args)
18723 vl_api_fib_path_type_t t = va_arg (*args, vl_api_fib_path_type_t);
18727 case FIB_API_PATH_TYPE_NORMAL:
18728 s = format (s, "normal");
18730 case FIB_API_PATH_TYPE_LOCAL:
18731 s = format (s, "local");
18733 case FIB_API_PATH_TYPE_DROP:
18734 s = format (s, "drop");
18736 case FIB_API_PATH_TYPE_UDP_ENCAP:
18737 s = format (s, "udp-encap");
18739 case FIB_API_PATH_TYPE_BIER_IMP:
18740 s = format (s, "bier-imp");
18742 case FIB_API_PATH_TYPE_ICMP_UNREACH:
18743 s = format (s, "unreach");
18745 case FIB_API_PATH_TYPE_ICMP_PROHIBIT:
18746 s = format (s, "prohibit");
18748 case FIB_API_PATH_TYPE_SOURCE_LOOKUP:
18749 s = format (s, "src-lookup");
18751 case FIB_API_PATH_TYPE_DVR:
18752 s = format (s, "dvr");
18754 case FIB_API_PATH_TYPE_INTERFACE_RX:
18755 s = format (s, "interface-rx");
18757 case FIB_API_PATH_TYPE_CLASSIFY:
18758 s = format (s, "classify");
18766 vl_api_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
18769 " weight %d, sw_if_index %d, type %U, afi %U, next_hop %U",
18770 ntohl (fp->weight), ntohl (fp->sw_if_index),
18771 format_vl_api_fib_path_type, fp->type,
18772 format_fib_api_path_nh_proto, fp->proto,
18773 format_vl_api_ip_address_union, &fp->nh.address);
18777 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
18778 vl_api_fib_path_t * fp)
18780 struct in_addr ip4;
18781 struct in6_addr ip6;
18783 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
18784 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
18785 vat_json_object_add_uint (node, "type", fp->type);
18786 vat_json_object_add_uint (node, "next_hop_proto", fp->proto);
18787 if (fp->proto == FIB_API_PATH_NH_PROTO_IP4)
18789 clib_memcpy (&ip4, &fp->nh.address.ip4, sizeof (ip4));
18790 vat_json_object_add_ip4 (node, "next_hop", ip4);
18792 else if (fp->proto == FIB_API_PATH_NH_PROTO_IP4)
18794 clib_memcpy (&ip6, &fp->nh.address.ip6, sizeof (ip6));
18795 vat_json_object_add_ip6 (node, "next_hop", ip6);
18800 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
18802 vat_main_t *vam = &vat_main;
18803 int count = ntohl (mp->mt_tunnel.mt_n_paths);
18804 vl_api_fib_path_t *fp;
18807 print (vam->ofp, "sw_if_index %d via:",
18808 ntohl (mp->mt_tunnel.mt_sw_if_index));
18809 fp = mp->mt_tunnel.mt_paths;
18810 for (i = 0; i < count; i++)
18812 vl_api_fib_path_print (vam, fp);
18816 print (vam->ofp, "");
18819 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
18820 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
18823 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
18825 vat_main_t *vam = &vat_main;
18826 vat_json_node_t *node = NULL;
18827 int count = ntohl (mp->mt_tunnel.mt_n_paths);
18828 vl_api_fib_path_t *fp;
18831 if (VAT_JSON_ARRAY != vam->json_tree.type)
18833 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18834 vat_json_init_array (&vam->json_tree);
18836 node = vat_json_array_add (&vam->json_tree);
18838 vat_json_init_object (node);
18839 vat_json_object_add_uint (node, "sw_if_index",
18840 ntohl (mp->mt_tunnel.mt_sw_if_index));
18842 vat_json_object_add_uint (node, "l2_only", mp->mt_tunnel.mt_l2_only);
18844 fp = mp->mt_tunnel.mt_paths;
18845 for (i = 0; i < count; i++)
18847 vl_api_mpls_fib_path_json_print (node, fp);
18853 api_mpls_tunnel_dump (vat_main_t * vam)
18855 vl_api_mpls_tunnel_dump_t *mp;
18856 vl_api_control_ping_t *mp_ping;
18859 M (MPLS_TUNNEL_DUMP, mp);
18863 /* Use a control ping for synchronization */
18864 MPING (CONTROL_PING, mp_ping);
18871 #define vl_api_mpls_table_details_t_endian vl_noop_handler
18872 #define vl_api_mpls_table_details_t_print vl_noop_handler
18876 vl_api_mpls_table_details_t_handler (vl_api_mpls_table_details_t * mp)
18878 vat_main_t *vam = &vat_main;
18880 print (vam->ofp, "table-id %d,", ntohl (mp->mt_table.mt_table_id));
18883 static void vl_api_mpls_table_details_t_handler_json
18884 (vl_api_mpls_table_details_t * mp)
18886 vat_main_t *vam = &vat_main;
18887 vat_json_node_t *node = NULL;
18889 if (VAT_JSON_ARRAY != vam->json_tree.type)
18891 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18892 vat_json_init_array (&vam->json_tree);
18894 node = vat_json_array_add (&vam->json_tree);
18896 vat_json_init_object (node);
18897 vat_json_object_add_uint (node, "table", ntohl (mp->mt_table.mt_table_id));
18901 api_mpls_table_dump (vat_main_t * vam)
18903 vl_api_mpls_table_dump_t *mp;
18904 vl_api_control_ping_t *mp_ping;
18907 M (MPLS_TABLE_DUMP, mp);
18910 /* Use a control ping for synchronization */
18911 MPING (CONTROL_PING, mp_ping);
18918 #define vl_api_mpls_route_details_t_endian vl_noop_handler
18919 #define vl_api_mpls_route_details_t_print vl_noop_handler
18922 vl_api_mpls_route_details_t_handler (vl_api_mpls_route_details_t * mp)
18924 vat_main_t *vam = &vat_main;
18925 int count = ntohl (mp->mr_route.mr_n_paths);
18926 vl_api_fib_path_t *fp;
18930 "table-id %d, label %u, ess_bit %u",
18931 ntohl (mp->mr_route.mr_table_id),
18932 ntohl (mp->mr_route.mr_label), mp->mr_route.mr_eos);
18933 fp = mp->mr_route.mr_paths;
18934 for (i = 0; i < count; i++)
18936 vl_api_fib_path_print (vam, fp);
18941 static void vl_api_mpls_route_details_t_handler_json
18942 (vl_api_mpls_route_details_t * mp)
18944 vat_main_t *vam = &vat_main;
18945 int count = ntohl (mp->mr_route.mr_n_paths);
18946 vat_json_node_t *node = NULL;
18947 vl_api_fib_path_t *fp;
18950 if (VAT_JSON_ARRAY != vam->json_tree.type)
18952 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18953 vat_json_init_array (&vam->json_tree);
18955 node = vat_json_array_add (&vam->json_tree);
18957 vat_json_init_object (node);
18958 vat_json_object_add_uint (node, "table", ntohl (mp->mr_route.mr_table_id));
18959 vat_json_object_add_uint (node, "s_bit", mp->mr_route.mr_eos);
18960 vat_json_object_add_uint (node, "label", ntohl (mp->mr_route.mr_label));
18961 vat_json_object_add_uint (node, "path_count", count);
18962 fp = mp->mr_route.mr_paths;
18963 for (i = 0; i < count; i++)
18965 vl_api_mpls_fib_path_json_print (node, fp);
18971 api_mpls_route_dump (vat_main_t * vam)
18973 unformat_input_t *input = vam->input;
18974 vl_api_mpls_route_dump_t *mp;
18975 vl_api_control_ping_t *mp_ping;
18979 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18981 if (unformat (input, "table_id %d", &table_id))
18986 if (table_id == ~0)
18988 errmsg ("missing table id");
18992 M (MPLS_ROUTE_DUMP, mp);
18994 mp->table.mt_table_id = ntohl (table_id);
18997 /* Use a control ping for synchronization */
18998 MPING (CONTROL_PING, mp_ping);
19005 #define vl_api_ip_table_details_t_endian vl_noop_handler
19006 #define vl_api_ip_table_details_t_print vl_noop_handler
19009 vl_api_ip_table_details_t_handler (vl_api_ip_table_details_t * mp)
19011 vat_main_t *vam = &vat_main;
19014 "%s; table-id %d, prefix %U/%d",
19015 mp->table.name, ntohl (mp->table.table_id));
19019 static void vl_api_ip_table_details_t_handler_json
19020 (vl_api_ip_table_details_t * mp)
19022 vat_main_t *vam = &vat_main;
19023 vat_json_node_t *node = NULL;
19025 if (VAT_JSON_ARRAY != vam->json_tree.type)
19027 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19028 vat_json_init_array (&vam->json_tree);
19030 node = vat_json_array_add (&vam->json_tree);
19032 vat_json_init_object (node);
19033 vat_json_object_add_uint (node, "table", ntohl (mp->table.table_id));
19037 api_ip_table_dump (vat_main_t * vam)
19039 vl_api_ip_table_dump_t *mp;
19040 vl_api_control_ping_t *mp_ping;
19043 M (IP_TABLE_DUMP, mp);
19046 /* Use a control ping for synchronization */
19047 MPING (CONTROL_PING, mp_ping);
19055 api_ip_mtable_dump (vat_main_t * vam)
19057 vl_api_ip_mtable_dump_t *mp;
19058 vl_api_control_ping_t *mp_ping;
19061 M (IP_MTABLE_DUMP, mp);
19064 /* Use a control ping for synchronization */
19065 MPING (CONTROL_PING, mp_ping);
19073 api_ip_mroute_dump (vat_main_t * vam)
19075 unformat_input_t *input = vam->input;
19076 vl_api_control_ping_t *mp_ping;
19077 vl_api_ip_mroute_dump_t *mp;
19082 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19084 if (unformat (input, "table_id %d", &table_id))
19086 else if (unformat (input, "ip6"))
19088 else if (unformat (input, "ip4"))
19093 if (table_id == ~0)
19095 errmsg ("missing table id");
19099 M (IP_MROUTE_DUMP, mp);
19100 mp->table.table_id = table_id;
19101 mp->table.is_ip6 = is_ip6;
19104 /* Use a control ping for synchronization */
19105 MPING (CONTROL_PING, mp_ping);
19112 static void vl_api_ip_neighbor_details_t_handler
19113 (vl_api_ip_neighbor_details_t * mp)
19115 vat_main_t *vam = &vat_main;
19117 print (vam->ofp, "%c %U %U",
19118 (ntohl (mp->neighbor.flags) & IP_NEIGHBOR_FLAG_STATIC) ? 'S' : 'D',
19119 format_vl_api_mac_address, &mp->neighbor.mac_address,
19120 format_vl_api_address, &mp->neighbor.ip_address);
19123 static void vl_api_ip_neighbor_details_t_handler_json
19124 (vl_api_ip_neighbor_details_t * mp)
19127 vat_main_t *vam = &vat_main;
19128 vat_json_node_t *node;
19130 if (VAT_JSON_ARRAY != vam->json_tree.type)
19132 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19133 vat_json_init_array (&vam->json_tree);
19135 node = vat_json_array_add (&vam->json_tree);
19137 vat_json_init_object (node);
19138 vat_json_object_add_string_copy
19140 ((ntohl (mp->neighbor.flags) & IP_NEIGHBOR_FLAG_STATIC) ?
19141 (u8 *) "static" : (u8 *) "dynamic"));
19143 vat_json_object_add_string_copy (node, "link_layer",
19144 format (0, "%U", format_vl_api_mac_address,
19145 &mp->neighbor.mac_address));
19146 vat_json_object_add_address (node, "ip", &mp->neighbor.ip_address);
19150 api_ip_neighbor_dump (vat_main_t * vam)
19152 unformat_input_t *i = vam->input;
19153 vl_api_ip_neighbor_dump_t *mp;
19154 vl_api_control_ping_t *mp_ping;
19156 u32 sw_if_index = ~0;
19159 /* Parse args required to build the message */
19160 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19162 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19164 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19166 else if (unformat (i, "ip6"))
19172 if (sw_if_index == ~0)
19174 errmsg ("missing interface name or sw_if_index");
19178 M (IP_NEIGHBOR_DUMP, mp);
19179 mp->is_ipv6 = (u8) is_ipv6;
19180 mp->sw_if_index = ntohl (sw_if_index);
19183 /* Use a control ping for synchronization */
19184 MPING (CONTROL_PING, mp_ping);
19191 #define vl_api_ip_route_details_t_endian vl_noop_handler
19192 #define vl_api_ip_route_details_t_print vl_noop_handler
19195 vl_api_ip_route_details_t_handler (vl_api_ip_route_details_t * mp)
19197 vat_main_t *vam = &vat_main;
19198 u8 count = mp->route.n_paths;
19199 vl_api_fib_path_t *fp;
19203 "table-id %d, prefix %U/%d",
19204 ntohl (mp->route.table_id),
19205 format_ip46_address,
19206 mp->route.prefix.address, mp->route.prefix.address_length);
19207 for (i = 0; i < count; i++)
19209 fp = &mp->route.paths[i];
19211 vl_api_fib_path_print (vam, fp);
19216 static void vl_api_ip_route_details_t_handler_json
19217 (vl_api_ip_route_details_t * mp)
19219 vat_main_t *vam = &vat_main;
19220 u8 count = mp->route.n_paths;
19221 vat_json_node_t *node = NULL;
19222 struct in_addr ip4;
19223 struct in6_addr ip6;
19224 vl_api_fib_path_t *fp;
19227 if (VAT_JSON_ARRAY != vam->json_tree.type)
19229 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19230 vat_json_init_array (&vam->json_tree);
19232 node = vat_json_array_add (&vam->json_tree);
19234 vat_json_init_object (node);
19235 vat_json_object_add_uint (node, "table", ntohl (mp->route.table_id));
19236 if (ADDRESS_IP6 == mp->route.prefix.address.af)
19238 clib_memcpy (&ip6, &mp->route.prefix.address.un.ip6, sizeof (ip6));
19239 vat_json_object_add_ip6 (node, "prefix", ip6);
19243 clib_memcpy (&ip4, &mp->route.prefix.address.un.ip4, sizeof (ip4));
19244 vat_json_object_add_ip4 (node, "prefix", ip4);
19246 vat_json_object_add_uint (node, "mask_length",
19247 mp->route.prefix.address_length);
19248 vat_json_object_add_uint (node, "path_count", count);
19249 for (i = 0; i < count; i++)
19251 fp = &mp->route.paths[i];
19252 vl_api_mpls_fib_path_json_print (node, fp);
19257 api_ip_route_dump (vat_main_t * vam)
19259 unformat_input_t *input = vam->input;
19260 vl_api_ip_route_dump_t *mp;
19261 vl_api_control_ping_t *mp_ping;
19267 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19269 if (unformat (input, "table_id %d", &table_id))
19271 else if (unformat (input, "ip6"))
19273 else if (unformat (input, "ip4"))
19278 if (table_id == ~0)
19280 errmsg ("missing table id");
19284 M (IP_ROUTE_DUMP, mp);
19286 mp->table.table_id = table_id;
19287 mp->table.is_ip6 = is_ip6;
19291 /* Use a control ping for synchronization */
19292 MPING (CONTROL_PING, mp_ping);
19300 api_classify_table_ids (vat_main_t * vam)
19302 vl_api_classify_table_ids_t *mp;
19305 /* Construct the API message */
19306 M (CLASSIFY_TABLE_IDS, mp);
19315 api_classify_table_by_interface (vat_main_t * vam)
19317 unformat_input_t *input = vam->input;
19318 vl_api_classify_table_by_interface_t *mp;
19320 u32 sw_if_index = ~0;
19322 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19324 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19326 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19331 if (sw_if_index == ~0)
19333 errmsg ("missing interface name or sw_if_index");
19337 /* Construct the API message */
19338 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
19340 mp->sw_if_index = ntohl (sw_if_index);
19348 api_classify_table_info (vat_main_t * vam)
19350 unformat_input_t *input = vam->input;
19351 vl_api_classify_table_info_t *mp;
19355 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19357 if (unformat (input, "table_id %d", &table_id))
19362 if (table_id == ~0)
19364 errmsg ("missing table id");
19368 /* Construct the API message */
19369 M (CLASSIFY_TABLE_INFO, mp);
19371 mp->table_id = ntohl (table_id);
19379 api_classify_session_dump (vat_main_t * vam)
19381 unformat_input_t *input = vam->input;
19382 vl_api_classify_session_dump_t *mp;
19383 vl_api_control_ping_t *mp_ping;
19387 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19389 if (unformat (input, "table_id %d", &table_id))
19394 if (table_id == ~0)
19396 errmsg ("missing table id");
19400 /* Construct the API message */
19401 M (CLASSIFY_SESSION_DUMP, mp);
19403 mp->table_id = ntohl (table_id);
19406 /* Use a control ping for synchronization */
19407 MPING (CONTROL_PING, mp_ping);
19415 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
19417 vat_main_t *vam = &vat_main;
19419 print (vam->ofp, "collector_address %U, collector_port %d, "
19420 "src_address %U, vrf_id %d, path_mtu %u, "
19421 "template_interval %u, udp_checksum %d",
19422 format_ip4_address, mp->collector_address,
19423 ntohs (mp->collector_port),
19424 format_ip4_address, mp->src_address,
19425 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
19426 ntohl (mp->template_interval), mp->udp_checksum);
19429 vam->result_ready = 1;
19433 vl_api_ipfix_exporter_details_t_handler_json
19434 (vl_api_ipfix_exporter_details_t * mp)
19436 vat_main_t *vam = &vat_main;
19437 vat_json_node_t node;
19438 struct in_addr collector_address;
19439 struct in_addr src_address;
19441 vat_json_init_object (&node);
19442 clib_memcpy (&collector_address, &mp->collector_address,
19443 sizeof (collector_address));
19444 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
19445 vat_json_object_add_uint (&node, "collector_port",
19446 ntohs (mp->collector_port));
19447 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
19448 vat_json_object_add_ip4 (&node, "src_address", src_address);
19449 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
19450 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
19451 vat_json_object_add_uint (&node, "template_interval",
19452 ntohl (mp->template_interval));
19453 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
19455 vat_json_print (vam->ofp, &node);
19456 vat_json_free (&node);
19458 vam->result_ready = 1;
19462 api_ipfix_exporter_dump (vat_main_t * vam)
19464 vl_api_ipfix_exporter_dump_t *mp;
19467 /* Construct the API message */
19468 M (IPFIX_EXPORTER_DUMP, mp);
19477 api_ipfix_classify_stream_dump (vat_main_t * vam)
19479 vl_api_ipfix_classify_stream_dump_t *mp;
19482 /* Construct the API message */
19483 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
19494 vl_api_ipfix_classify_stream_details_t_handler
19495 (vl_api_ipfix_classify_stream_details_t * mp)
19497 vat_main_t *vam = &vat_main;
19498 print (vam->ofp, "domain_id %d, src_port %d",
19499 ntohl (mp->domain_id), ntohs (mp->src_port));
19501 vam->result_ready = 1;
19505 vl_api_ipfix_classify_stream_details_t_handler_json
19506 (vl_api_ipfix_classify_stream_details_t * mp)
19508 vat_main_t *vam = &vat_main;
19509 vat_json_node_t node;
19511 vat_json_init_object (&node);
19512 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
19513 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
19515 vat_json_print (vam->ofp, &node);
19516 vat_json_free (&node);
19518 vam->result_ready = 1;
19522 api_ipfix_classify_table_dump (vat_main_t * vam)
19524 vl_api_ipfix_classify_table_dump_t *mp;
19525 vl_api_control_ping_t *mp_ping;
19528 if (!vam->json_output)
19530 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
19531 "transport_protocol");
19534 /* Construct the API message */
19535 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
19540 /* Use a control ping for synchronization */
19541 MPING (CONTROL_PING, mp_ping);
19549 vl_api_ipfix_classify_table_details_t_handler
19550 (vl_api_ipfix_classify_table_details_t * mp)
19552 vat_main_t *vam = &vat_main;
19553 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
19554 mp->transport_protocol);
19558 vl_api_ipfix_classify_table_details_t_handler_json
19559 (vl_api_ipfix_classify_table_details_t * mp)
19561 vat_json_node_t *node = NULL;
19562 vat_main_t *vam = &vat_main;
19564 if (VAT_JSON_ARRAY != vam->json_tree.type)
19566 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19567 vat_json_init_array (&vam->json_tree);
19570 node = vat_json_array_add (&vam->json_tree);
19571 vat_json_init_object (node);
19573 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
19574 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
19575 vat_json_object_add_uint (node, "transport_protocol",
19576 mp->transport_protocol);
19580 api_sw_interface_span_enable_disable (vat_main_t * vam)
19582 unformat_input_t *i = vam->input;
19583 vl_api_sw_interface_span_enable_disable_t *mp;
19584 u32 src_sw_if_index = ~0;
19585 u32 dst_sw_if_index = ~0;
19590 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19593 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
19595 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
19599 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
19601 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
19603 else if (unformat (i, "disable"))
19605 else if (unformat (i, "rx"))
19607 else if (unformat (i, "tx"))
19609 else if (unformat (i, "both"))
19611 else if (unformat (i, "l2"))
19617 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
19619 mp->sw_if_index_from = htonl (src_sw_if_index);
19620 mp->sw_if_index_to = htonl (dst_sw_if_index);
19630 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
19633 vat_main_t *vam = &vat_main;
19634 u8 *sw_if_from_name = 0;
19635 u8 *sw_if_to_name = 0;
19636 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19637 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19638 char *states[] = { "none", "rx", "tx", "both" };
19642 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19644 if ((u32) p->value[0] == sw_if_index_from)
19646 sw_if_from_name = (u8 *)(p->key);
19650 if ((u32) p->value[0] == sw_if_index_to)
19652 sw_if_to_name = (u8 *)(p->key);
19653 if (sw_if_from_name)
19658 print (vam->ofp, "%20s => %20s (%s) %s",
19659 sw_if_from_name, sw_if_to_name, states[mp->state],
19660 mp->is_l2 ? "l2" : "device");
19664 vl_api_sw_interface_span_details_t_handler_json
19665 (vl_api_sw_interface_span_details_t * mp)
19667 vat_main_t *vam = &vat_main;
19668 vat_json_node_t *node = NULL;
19669 u8 *sw_if_from_name = 0;
19670 u8 *sw_if_to_name = 0;
19671 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19672 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19676 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19678 if ((u32) p->value[0] == sw_if_index_from)
19680 sw_if_from_name = (u8 *)(p->key);
19684 if ((u32) p->value[0] == sw_if_index_to)
19686 sw_if_to_name = (u8 *)(p->key);
19687 if (sw_if_from_name)
19693 if (VAT_JSON_ARRAY != vam->json_tree.type)
19695 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19696 vat_json_init_array (&vam->json_tree);
19698 node = vat_json_array_add (&vam->json_tree);
19700 vat_json_init_object (node);
19701 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
19702 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
19703 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
19704 if (0 != sw_if_to_name)
19706 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
19708 vat_json_object_add_uint (node, "state", mp->state);
19709 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
19713 api_sw_interface_span_dump (vat_main_t * vam)
19715 unformat_input_t *input = vam->input;
19716 vl_api_sw_interface_span_dump_t *mp;
19717 vl_api_control_ping_t *mp_ping;
19721 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19723 if (unformat (input, "l2"))
19729 M (SW_INTERFACE_SPAN_DUMP, mp);
19733 /* Use a control ping for synchronization */
19734 MPING (CONTROL_PING, mp_ping);
19742 api_pg_create_interface (vat_main_t * vam)
19744 unformat_input_t *input = vam->input;
19745 vl_api_pg_create_interface_t *mp;
19749 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19751 if (unformat (input, "if_id %d", &if_id))
19758 errmsg ("missing pg interface index");
19762 /* Construct the API message */
19763 M (PG_CREATE_INTERFACE, mp);
19765 mp->interface_id = ntohl (if_id);
19773 api_pg_capture (vat_main_t * vam)
19775 unformat_input_t *input = vam->input;
19776 vl_api_pg_capture_t *mp;
19781 u8 pcap_file_set = 0;
19784 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19786 if (unformat (input, "if_id %d", &if_id))
19788 else if (unformat (input, "pcap %s", &pcap_file))
19790 else if (unformat (input, "count %d", &count))
19792 else if (unformat (input, "disable"))
19799 errmsg ("missing pg interface index");
19802 if (pcap_file_set > 0)
19804 if (vec_len (pcap_file) > 255)
19806 errmsg ("pcap file name is too long");
19811 u32 name_len = vec_len (pcap_file);
19812 /* Construct the API message */
19813 M (PG_CAPTURE, mp);
19815 mp->interface_id = ntohl (if_id);
19816 mp->is_enabled = enable;
19817 mp->count = ntohl (count);
19818 mp->pcap_name_length = ntohl (name_len);
19819 if (pcap_file_set != 0)
19821 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
19823 vec_free (pcap_file);
19831 api_pg_enable_disable (vat_main_t * vam)
19833 unformat_input_t *input = vam->input;
19834 vl_api_pg_enable_disable_t *mp;
19837 u8 stream_name_set = 0;
19838 u8 *stream_name = 0;
19840 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19842 if (unformat (input, "stream %s", &stream_name))
19843 stream_name_set = 1;
19844 else if (unformat (input, "disable"))
19850 if (stream_name_set > 0)
19852 if (vec_len (stream_name) > 255)
19854 errmsg ("stream name too long");
19859 u32 name_len = vec_len (stream_name);
19860 /* Construct the API message */
19861 M (PG_ENABLE_DISABLE, mp);
19863 mp->is_enabled = enable;
19864 if (stream_name_set != 0)
19866 mp->stream_name_length = ntohl (name_len);
19867 clib_memcpy (mp->stream_name, stream_name, name_len);
19869 vec_free (stream_name);
19877 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
19879 unformat_input_t *input = vam->input;
19880 vl_api_ip_source_and_port_range_check_add_del_t *mp;
19882 u16 *low_ports = 0;
19883 u16 *high_ports = 0;
19886 vl_api_prefix_t prefix;
19893 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19895 if (unformat (input, "%U", unformat_vl_api_prefix, &prefix))
19897 else if (unformat (input, "vrf %d", &vrf_id))
19899 else if (unformat (input, "del"))
19901 else if (unformat (input, "port %d", &tmp))
19903 if (tmp == 0 || tmp > 65535)
19905 errmsg ("port %d out of range", tmp);
19909 this_hi = this_low + 1;
19910 vec_add1 (low_ports, this_low);
19911 vec_add1 (high_ports, this_hi);
19913 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
19915 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
19917 errmsg ("incorrect range parameters");
19921 /* Note: in debug CLI +1 is added to high before
19922 passing to real fn that does "the work"
19923 (ip_source_and_port_range_check_add_del).
19924 This fn is a wrapper around the binary API fn a
19925 control plane will call, which expects this increment
19926 to have occurred. Hence letting the binary API control
19927 plane fn do the increment for consistency between VAT
19928 and other control planes.
19931 vec_add1 (low_ports, this_low);
19932 vec_add1 (high_ports, this_hi);
19938 if (prefix_set == 0)
19940 errmsg ("<address>/<mask> not specified");
19946 errmsg ("VRF ID required, not specified");
19953 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
19957 if (vec_len (low_ports) == 0)
19959 errmsg ("At least one port or port range required");
19963 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
19965 mp->is_add = is_add;
19967 clib_memcpy (&mp->prefix, &prefix, sizeof (prefix));
19969 mp->number_of_ranges = vec_len (low_ports);
19971 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
19972 vec_free (low_ports);
19974 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
19975 vec_free (high_ports);
19977 mp->vrf_id = ntohl (vrf_id);
19985 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
19987 unformat_input_t *input = vam->input;
19988 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
19989 u32 sw_if_index = ~0;
19991 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
19992 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
19996 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19998 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20000 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20002 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
20004 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
20006 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
20008 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
20010 else if (unformat (input, "del"))
20016 if (sw_if_index == ~0)
20018 errmsg ("Interface required but not specified");
20024 errmsg ("VRF ID required but not specified");
20028 if (tcp_out_vrf_id == 0
20029 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
20032 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
20036 /* Construct the API message */
20037 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
20039 mp->sw_if_index = ntohl (sw_if_index);
20040 mp->is_add = is_add;
20041 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
20042 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
20043 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
20044 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
20049 /* Wait for a reply... */
20055 api_set_punt (vat_main_t * vam)
20057 unformat_input_t *i = vam->input;
20058 vl_api_address_family_t af;
20059 vl_api_set_punt_t *mp;
20065 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20067 if (unformat (i, "%U", unformat_vl_api_address_family, &af))
20069 else if (unformat (i, "protocol %d", &protocol))
20071 else if (unformat (i, "port %d", &port))
20073 else if (unformat (i, "del"))
20077 clib_warning ("parse error '%U'", format_unformat_error, i);
20084 mp->is_add = (u8) is_add;
20085 mp->punt.type = PUNT_API_TYPE_L4;
20086 mp->punt.punt.l4.af = af;
20087 mp->punt.punt.l4.protocol = (u8) protocol;
20088 mp->punt.punt.l4.port = htons ((u16) port);
20096 api_delete_subif (vat_main_t * vam)
20098 unformat_input_t *i = vam->input;
20099 vl_api_delete_subif_t *mp;
20100 u32 sw_if_index = ~0;
20103 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20105 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20107 if (unformat (i, "sw_if_index %d", &sw_if_index))
20113 if (sw_if_index == ~0)
20115 errmsg ("missing sw_if_index");
20119 /* Construct the API message */
20120 M (DELETE_SUBIF, mp);
20121 mp->sw_if_index = ntohl (sw_if_index);
20128 #define foreach_pbb_vtr_op \
20129 _("disable", L2_VTR_DISABLED) \
20130 _("pop", L2_VTR_POP_2) \
20131 _("push", L2_VTR_PUSH_2)
20134 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
20136 unformat_input_t *i = vam->input;
20137 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
20138 u32 sw_if_index = ~0, vtr_op = ~0;
20139 u16 outer_tag = ~0;
20140 u8 dmac[6], smac[6];
20141 u8 dmac_set = 0, smac_set = 0;
20147 /* Shut up coverity */
20148 clib_memset (dmac, 0, sizeof (dmac));
20149 clib_memset (smac, 0, sizeof (smac));
20151 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20153 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20155 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20157 else if (unformat (i, "vtr_op %d", &vtr_op))
20159 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
20162 else if (unformat (i, "translate_pbb_stag"))
20164 if (unformat (i, "%d", &tmp))
20166 vtr_op = L2_VTR_TRANSLATE_2_1;
20172 ("translate_pbb_stag operation requires outer tag definition");
20176 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
20178 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
20180 else if (unformat (i, "sid %d", &sid))
20182 else if (unformat (i, "vlanid %d", &tmp))
20186 clib_warning ("parse error '%U'", format_unformat_error, i);
20191 if ((sw_if_index == ~0) || (vtr_op == ~0))
20193 errmsg ("missing sw_if_index or vtr operation");
20196 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
20197 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
20200 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
20204 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
20205 mp->sw_if_index = ntohl (sw_if_index);
20206 mp->vtr_op = ntohl (vtr_op);
20207 mp->outer_tag = ntohs (outer_tag);
20208 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
20209 clib_memcpy (mp->b_smac, smac, sizeof (smac));
20210 mp->b_vlanid = ntohs (vlanid);
20211 mp->i_sid = ntohl (sid);
20219 api_flow_classify_set_interface (vat_main_t * vam)
20221 unformat_input_t *i = vam->input;
20222 vl_api_flow_classify_set_interface_t *mp;
20224 int sw_if_index_set;
20225 u32 ip4_table_index = ~0;
20226 u32 ip6_table_index = ~0;
20230 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20232 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20233 sw_if_index_set = 1;
20234 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20235 sw_if_index_set = 1;
20236 else if (unformat (i, "del"))
20238 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20240 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20244 clib_warning ("parse error '%U'", format_unformat_error, i);
20249 if (sw_if_index_set == 0)
20251 errmsg ("missing interface name or sw_if_index");
20255 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
20257 mp->sw_if_index = ntohl (sw_if_index);
20258 mp->ip4_table_index = ntohl (ip4_table_index);
20259 mp->ip6_table_index = ntohl (ip6_table_index);
20260 mp->is_add = is_add;
20268 api_flow_classify_dump (vat_main_t * vam)
20270 unformat_input_t *i = vam->input;
20271 vl_api_flow_classify_dump_t *mp;
20272 vl_api_control_ping_t *mp_ping;
20273 u8 type = FLOW_CLASSIFY_N_TABLES;
20276 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
20280 errmsg ("classify table type must be specified");
20284 if (!vam->json_output)
20286 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20289 M (FLOW_CLASSIFY_DUMP, mp);
20294 /* Use a control ping for synchronization */
20295 MPING (CONTROL_PING, mp_ping);
20298 /* Wait for a reply... */
20304 api_feature_enable_disable (vat_main_t * vam)
20306 unformat_input_t *i = vam->input;
20307 vl_api_feature_enable_disable_t *mp;
20309 u8 *feature_name = 0;
20310 u32 sw_if_index = ~0;
20314 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20316 if (unformat (i, "arc_name %s", &arc_name))
20318 else if (unformat (i, "feature_name %s", &feature_name))
20321 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20323 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20325 else if (unformat (i, "disable"))
20333 errmsg ("missing arc name");
20336 if (vec_len (arc_name) > 63)
20338 errmsg ("arc name too long");
20341 if (feature_name == 0)
20343 errmsg ("missing feature name");
20346 if (vec_len (feature_name) > 63)
20348 errmsg ("feature name too long");
20351 if (sw_if_index == ~0)
20353 errmsg ("missing interface name or sw_if_index");
20357 /* Construct the API message */
20358 M (FEATURE_ENABLE_DISABLE, mp);
20359 mp->sw_if_index = ntohl (sw_if_index);
20360 mp->enable = enable;
20361 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
20362 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
20363 vec_free (arc_name);
20364 vec_free (feature_name);
20372 api_sw_interface_tag_add_del (vat_main_t * vam)
20374 unformat_input_t *i = vam->input;
20375 vl_api_sw_interface_tag_add_del_t *mp;
20376 u32 sw_if_index = ~0;
20381 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20383 if (unformat (i, "tag %s", &tag))
20385 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20387 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20389 else if (unformat (i, "del"))
20395 if (sw_if_index == ~0)
20397 errmsg ("missing interface name or sw_if_index");
20401 if (enable && (tag == 0))
20403 errmsg ("no tag specified");
20407 /* Construct the API message */
20408 M (SW_INTERFACE_TAG_ADD_DEL, mp);
20409 mp->sw_if_index = ntohl (sw_if_index);
20410 mp->is_add = enable;
20412 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
20420 static void vl_api_l2_xconnect_details_t_handler
20421 (vl_api_l2_xconnect_details_t * mp)
20423 vat_main_t *vam = &vat_main;
20425 print (vam->ofp, "%15d%15d",
20426 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
20429 static void vl_api_l2_xconnect_details_t_handler_json
20430 (vl_api_l2_xconnect_details_t * mp)
20432 vat_main_t *vam = &vat_main;
20433 vat_json_node_t *node = NULL;
20435 if (VAT_JSON_ARRAY != vam->json_tree.type)
20437 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20438 vat_json_init_array (&vam->json_tree);
20440 node = vat_json_array_add (&vam->json_tree);
20442 vat_json_init_object (node);
20443 vat_json_object_add_uint (node, "rx_sw_if_index",
20444 ntohl (mp->rx_sw_if_index));
20445 vat_json_object_add_uint (node, "tx_sw_if_index",
20446 ntohl (mp->tx_sw_if_index));
20450 api_l2_xconnect_dump (vat_main_t * vam)
20452 vl_api_l2_xconnect_dump_t *mp;
20453 vl_api_control_ping_t *mp_ping;
20456 if (!vam->json_output)
20458 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
20461 M (L2_XCONNECT_DUMP, mp);
20465 /* Use a control ping for synchronization */
20466 MPING (CONTROL_PING, mp_ping);
20474 api_hw_interface_set_mtu (vat_main_t * vam)
20476 unformat_input_t *i = vam->input;
20477 vl_api_hw_interface_set_mtu_t *mp;
20478 u32 sw_if_index = ~0;
20482 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20484 if (unformat (i, "mtu %d", &mtu))
20486 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20488 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20494 if (sw_if_index == ~0)
20496 errmsg ("missing interface name or sw_if_index");
20502 errmsg ("no mtu specified");
20506 /* Construct the API message */
20507 M (HW_INTERFACE_SET_MTU, mp);
20508 mp->sw_if_index = ntohl (sw_if_index);
20509 mp->mtu = ntohs ((u16) mtu);
20517 api_p2p_ethernet_add (vat_main_t * vam)
20519 unformat_input_t *i = vam->input;
20520 vl_api_p2p_ethernet_add_t *mp;
20521 u32 parent_if_index = ~0;
20527 clib_memset (remote_mac, 0, sizeof (remote_mac));
20528 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20530 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20532 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20536 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20538 else if (unformat (i, "sub_id %d", &sub_id))
20542 clib_warning ("parse error '%U'", format_unformat_error, i);
20547 if (parent_if_index == ~0)
20549 errmsg ("missing interface name or sw_if_index");
20554 errmsg ("missing remote mac address");
20559 errmsg ("missing sub-interface id");
20563 M (P2P_ETHERNET_ADD, mp);
20564 mp->parent_if_index = ntohl (parent_if_index);
20565 mp->subif_id = ntohl (sub_id);
20566 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20574 api_p2p_ethernet_del (vat_main_t * vam)
20576 unformat_input_t *i = vam->input;
20577 vl_api_p2p_ethernet_del_t *mp;
20578 u32 parent_if_index = ~0;
20583 clib_memset (remote_mac, 0, sizeof (remote_mac));
20584 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20586 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20588 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20592 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20596 clib_warning ("parse error '%U'", format_unformat_error, i);
20601 if (parent_if_index == ~0)
20603 errmsg ("missing interface name or sw_if_index");
20608 errmsg ("missing remote mac address");
20612 M (P2P_ETHERNET_DEL, mp);
20613 mp->parent_if_index = ntohl (parent_if_index);
20614 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20622 api_lldp_config (vat_main_t * vam)
20624 unformat_input_t *i = vam->input;
20625 vl_api_lldp_config_t *mp;
20627 int tx_interval = 0;
20628 u8 *sys_name = NULL;
20631 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20633 if (unformat (i, "system-name %s", &sys_name))
20635 else if (unformat (i, "tx-hold %d", &tx_hold))
20637 else if (unformat (i, "tx-interval %d", &tx_interval))
20641 clib_warning ("parse error '%U'", format_unformat_error, i);
20646 vec_add1 (sys_name, 0);
20648 M (LLDP_CONFIG, mp);
20649 mp->tx_hold = htonl (tx_hold);
20650 mp->tx_interval = htonl (tx_interval);
20651 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
20652 vec_free (sys_name);
20660 api_sw_interface_set_lldp (vat_main_t * vam)
20662 unformat_input_t *i = vam->input;
20663 vl_api_sw_interface_set_lldp_t *mp;
20664 u32 sw_if_index = ~0;
20666 u8 *port_desc = NULL, *mgmt_oid = NULL;
20667 ip4_address_t ip4_addr;
20668 ip6_address_t ip6_addr;
20671 clib_memset (&ip4_addr, 0, sizeof (ip4_addr));
20672 clib_memset (&ip6_addr, 0, sizeof (ip6_addr));
20674 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20676 if (unformat (i, "disable"))
20679 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20681 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20683 else if (unformat (i, "port-desc %s", &port_desc))
20685 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
20687 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
20689 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
20695 if (sw_if_index == ~0)
20697 errmsg ("missing interface name or sw_if_index");
20701 /* Construct the API message */
20702 vec_add1 (port_desc, 0);
20703 vec_add1 (mgmt_oid, 0);
20704 M (SW_INTERFACE_SET_LLDP, mp);
20705 mp->sw_if_index = ntohl (sw_if_index);
20706 mp->enable = enable;
20707 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
20708 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
20709 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
20710 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
20711 vec_free (port_desc);
20712 vec_free (mgmt_oid);
20720 api_tcp_configure_src_addresses (vat_main_t * vam)
20722 vl_api_tcp_configure_src_addresses_t *mp;
20723 unformat_input_t *i = vam->input;
20724 ip4_address_t v4first, v4last;
20725 ip6_address_t v6first, v6last;
20730 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20732 if (unformat (i, "%U - %U",
20733 unformat_ip4_address, &v4first,
20734 unformat_ip4_address, &v4last))
20738 errmsg ("one range per message (range already set)");
20743 else if (unformat (i, "%U - %U",
20744 unformat_ip6_address, &v6first,
20745 unformat_ip6_address, &v6last))
20749 errmsg ("one range per message (range already set)");
20754 else if (unformat (i, "vrf %d", &vrf_id))
20760 if (range_set == 0)
20762 errmsg ("address range not set");
20766 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
20767 mp->vrf_id = ntohl (vrf_id);
20769 if (range_set == 2)
20772 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
20773 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
20778 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
20779 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
20786 static void vl_api_app_namespace_add_del_reply_t_handler
20787 (vl_api_app_namespace_add_del_reply_t * mp)
20789 vat_main_t *vam = &vat_main;
20790 i32 retval = ntohl (mp->retval);
20791 if (vam->async_mode)
20793 vam->async_errors += (retval < 0);
20797 vam->retval = retval;
20799 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
20800 vam->result_ready = 1;
20804 static void vl_api_app_namespace_add_del_reply_t_handler_json
20805 (vl_api_app_namespace_add_del_reply_t * mp)
20807 vat_main_t *vam = &vat_main;
20808 vat_json_node_t node;
20810 vat_json_init_object (&node);
20811 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
20812 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
20814 vat_json_print (vam->ofp, &node);
20815 vat_json_free (&node);
20817 vam->retval = ntohl (mp->retval);
20818 vam->result_ready = 1;
20822 api_app_namespace_add_del (vat_main_t * vam)
20824 vl_api_app_namespace_add_del_t *mp;
20825 unformat_input_t *i = vam->input;
20826 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
20827 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
20831 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20833 if (unformat (i, "id %_%v%_", &ns_id))
20835 else if (unformat (i, "secret %lu", &secret))
20837 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20838 sw_if_index_set = 1;
20839 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
20841 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
20846 if (!ns_id || !secret_set || !sw_if_index_set)
20848 errmsg ("namespace id, secret and sw_if_index must be set");
20851 if (vec_len (ns_id) > 64)
20853 errmsg ("namespace id too long");
20856 M (APP_NAMESPACE_ADD_DEL, mp);
20858 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
20859 mp->namespace_id_len = vec_len (ns_id);
20860 mp->secret = clib_host_to_net_u64 (secret);
20861 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
20862 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
20863 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
20871 api_sock_init_shm (vat_main_t * vam)
20873 #if VPP_API_TEST_BUILTIN == 0
20874 unformat_input_t *i = vam->input;
20875 vl_api_shm_elem_config_t *config = 0;
20876 u64 size = 64 << 20;
20879 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20881 if (unformat (i, "size %U", unformat_memory_size, &size))
20888 * Canned custom ring allocator config.
20889 * Should probably parse all of this
20891 vec_validate (config, 6);
20892 config[0].type = VL_API_VLIB_RING;
20893 config[0].size = 256;
20894 config[0].count = 32;
20896 config[1].type = VL_API_VLIB_RING;
20897 config[1].size = 1024;
20898 config[1].count = 16;
20900 config[2].type = VL_API_VLIB_RING;
20901 config[2].size = 4096;
20902 config[2].count = 2;
20904 config[3].type = VL_API_CLIENT_RING;
20905 config[3].size = 256;
20906 config[3].count = 32;
20908 config[4].type = VL_API_CLIENT_RING;
20909 config[4].size = 1024;
20910 config[4].count = 16;
20912 config[5].type = VL_API_CLIENT_RING;
20913 config[5].size = 4096;
20914 config[5].count = 2;
20916 config[6].type = VL_API_QUEUE;
20917 config[6].count = 128;
20918 config[6].size = sizeof (uword);
20920 rv = vl_socket_client_init_shm (config, 1 /* want_pthread */ );
20922 vam->client_index_invalid = 1;
20930 api_dns_enable_disable (vat_main_t * vam)
20932 unformat_input_t *line_input = vam->input;
20933 vl_api_dns_enable_disable_t *mp;
20934 u8 enable_disable = 1;
20937 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
20939 if (unformat (line_input, "disable"))
20940 enable_disable = 0;
20941 if (unformat (line_input, "enable"))
20942 enable_disable = 1;
20947 /* Construct the API message */
20948 M (DNS_ENABLE_DISABLE, mp);
20949 mp->enable = enable_disable;
20953 /* Wait for the reply */
20959 api_dns_resolve_name (vat_main_t * vam)
20961 unformat_input_t *line_input = vam->input;
20962 vl_api_dns_resolve_name_t *mp;
20966 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
20968 if (unformat (line_input, "%s", &name))
20974 if (vec_len (name) > 127)
20976 errmsg ("name too long");
20980 /* Construct the API message */
20981 M (DNS_RESOLVE_NAME, mp);
20982 memcpy (mp->name, name, vec_len (name));
20987 /* Wait for the reply */
20993 api_dns_resolve_ip (vat_main_t * vam)
20995 unformat_input_t *line_input = vam->input;
20996 vl_api_dns_resolve_ip_t *mp;
20998 ip4_address_t addr4;
20999 ip6_address_t addr6;
21002 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21004 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
21006 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
21014 errmsg ("missing address");
21018 /* Construct the API message */
21019 M (DNS_RESOLVE_IP, mp);
21020 mp->is_ip6 = is_ip6;
21022 memcpy (mp->address, &addr6, sizeof (addr6));
21024 memcpy (mp->address, &addr4, sizeof (addr4));
21028 /* Wait for the reply */
21034 api_dns_name_server_add_del (vat_main_t * vam)
21036 unformat_input_t *i = vam->input;
21037 vl_api_dns_name_server_add_del_t *mp;
21039 ip6_address_t ip6_server;
21040 ip4_address_t ip4_server;
21045 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21047 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
21049 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
21051 else if (unformat (i, "del"))
21055 clib_warning ("parse error '%U'", format_unformat_error, i);
21060 if (ip4_set && ip6_set)
21062 errmsg ("Only one server address allowed per message");
21065 if ((ip4_set + ip6_set) == 0)
21067 errmsg ("Server address required");
21071 /* Construct the API message */
21072 M (DNS_NAME_SERVER_ADD_DEL, mp);
21076 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
21081 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
21085 mp->is_add = is_add;
21090 /* Wait for a reply, return good/bad news */
21096 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
21098 vat_main_t *vam = &vat_main;
21103 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
21104 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
21105 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
21106 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
21107 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
21108 clib_net_to_host_u32 (mp->action_index), mp->tag);
21113 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
21114 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
21115 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
21116 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
21117 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
21118 clib_net_to_host_u32 (mp->action_index), mp->tag);
21123 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
21126 vat_main_t *vam = &vat_main;
21127 vat_json_node_t *node = NULL;
21128 struct in6_addr ip6;
21129 struct in_addr ip4;
21131 if (VAT_JSON_ARRAY != vam->json_tree.type)
21133 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21134 vat_json_init_array (&vam->json_tree);
21136 node = vat_json_array_add (&vam->json_tree);
21137 vat_json_init_object (node);
21139 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
21140 vat_json_object_add_uint (node, "appns_index",
21141 clib_net_to_host_u32 (mp->appns_index));
21142 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
21143 vat_json_object_add_uint (node, "scope", mp->scope);
21144 vat_json_object_add_uint (node, "action_index",
21145 clib_net_to_host_u32 (mp->action_index));
21146 vat_json_object_add_uint (node, "lcl_port",
21147 clib_net_to_host_u16 (mp->lcl_port));
21148 vat_json_object_add_uint (node, "rmt_port",
21149 clib_net_to_host_u16 (mp->rmt_port));
21150 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
21151 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
21152 vat_json_object_add_string_copy (node, "tag", mp->tag);
21155 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
21156 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
21157 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
21158 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
21162 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
21163 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
21164 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
21165 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
21170 api_session_rule_add_del (vat_main_t * vam)
21172 vl_api_session_rule_add_del_t *mp;
21173 unformat_input_t *i = vam->input;
21174 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
21175 u32 appns_index = 0, scope = 0;
21176 ip4_address_t lcl_ip4, rmt_ip4;
21177 ip6_address_t lcl_ip6, rmt_ip6;
21178 u8 is_ip4 = 1, conn_set = 0;
21179 u8 is_add = 1, *tag = 0;
21182 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21184 if (unformat (i, "del"))
21186 else if (unformat (i, "add"))
21188 else if (unformat (i, "proto tcp"))
21190 else if (unformat (i, "proto udp"))
21192 else if (unformat (i, "appns %d", &appns_index))
21194 else if (unformat (i, "scope %d", &scope))
21196 else if (unformat (i, "tag %_%v%_", &tag))
21200 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
21201 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
21209 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
21210 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
21216 else if (unformat (i, "action %d", &action))
21221 if (proto == ~0 || !conn_set || action == ~0)
21223 errmsg ("transport proto, connection and action must be set");
21229 errmsg ("scope should be 0-3");
21233 M (SESSION_RULE_ADD_DEL, mp);
21235 mp->is_ip4 = is_ip4;
21236 mp->transport_proto = proto;
21237 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
21238 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
21239 mp->lcl_plen = lcl_plen;
21240 mp->rmt_plen = rmt_plen;
21241 mp->action_index = clib_host_to_net_u32 (action);
21242 mp->appns_index = clib_host_to_net_u32 (appns_index);
21244 mp->is_add = is_add;
21247 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
21248 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
21252 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
21253 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
21257 clib_memcpy (mp->tag, tag, vec_len (tag));
21267 api_session_rules_dump (vat_main_t * vam)
21269 vl_api_session_rules_dump_t *mp;
21270 vl_api_control_ping_t *mp_ping;
21273 if (!vam->json_output)
21275 print (vam->ofp, "%=20s", "Session Rules");
21278 M (SESSION_RULES_DUMP, mp);
21282 /* Use a control ping for synchronization */
21283 MPING (CONTROL_PING, mp_ping);
21286 /* Wait for a reply... */
21292 api_ip_container_proxy_add_del (vat_main_t * vam)
21294 vl_api_ip_container_proxy_add_del_t *mp;
21295 unformat_input_t *i = vam->input;
21296 u32 sw_if_index = ~0;
21297 vl_api_prefix_t pfx = { };
21301 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21303 if (unformat (i, "del"))
21305 else if (unformat (i, "add"))
21307 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
21309 else if (unformat (i, "sw_if_index %u", &sw_if_index))
21314 if (sw_if_index == ~0 || pfx.address_length == 0)
21316 errmsg ("address and sw_if_index must be set");
21320 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
21322 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
21323 mp->is_add = is_add;
21324 clib_memcpy (&mp->pfx, &pfx, sizeof (pfx));
21332 api_qos_record_enable_disable (vat_main_t * vam)
21334 unformat_input_t *i = vam->input;
21335 vl_api_qos_record_enable_disable_t *mp;
21336 u32 sw_if_index, qs = 0xff;
21337 u8 sw_if_index_set = 0;
21341 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21343 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21344 sw_if_index_set = 1;
21345 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21346 sw_if_index_set = 1;
21347 else if (unformat (i, "%U", unformat_qos_source, &qs))
21349 else if (unformat (i, "disable"))
21353 clib_warning ("parse error '%U'", format_unformat_error, i);
21358 if (sw_if_index_set == 0)
21360 errmsg ("missing interface name or sw_if_index");
21365 errmsg ("input location must be specified");
21369 M (QOS_RECORD_ENABLE_DISABLE, mp);
21371 mp->sw_if_index = ntohl (sw_if_index);
21372 mp->input_source = qs;
21373 mp->enable = enable;
21382 q_or_quit (vat_main_t * vam)
21384 #if VPP_API_TEST_BUILTIN == 0
21385 longjmp (vam->jump_buf, 1);
21387 return 0; /* not so much */
21391 q (vat_main_t * vam)
21393 return q_or_quit (vam);
21397 quit (vat_main_t * vam)
21399 return q_or_quit (vam);
21403 comment (vat_main_t * vam)
21409 statseg (vat_main_t * vam)
21411 ssvm_private_t *ssvmp = &vam->stat_segment;
21412 ssvm_shared_header_t *shared_header = ssvmp->sh;
21413 vlib_counter_t **counters;
21414 u64 thread0_index1_packets;
21415 u64 thread0_index1_bytes;
21416 f64 vector_rate, input_rate;
21419 uword *counter_vector_by_name;
21420 if (vam->stat_segment_lockp == 0)
21422 errmsg ("Stat segment not mapped...");
21426 /* look up "/if/rx for sw_if_index 1 as a test */
21428 clib_spinlock_lock (vam->stat_segment_lockp);
21430 counter_vector_by_name = (uword *) shared_header->opaque[1];
21432 p = hash_get_mem (counter_vector_by_name, "/if/rx");
21435 clib_spinlock_unlock (vam->stat_segment_lockp);
21436 errmsg ("/if/tx not found?");
21440 /* Fish per-thread vector of combined counters from shared memory */
21441 counters = (vlib_counter_t **) p[0];
21443 if (vec_len (counters[0]) < 2)
21445 clib_spinlock_unlock (vam->stat_segment_lockp);
21446 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
21450 /* Read thread 0 sw_if_index 1 counter */
21451 thread0_index1_packets = counters[0][1].packets;
21452 thread0_index1_bytes = counters[0][1].bytes;
21454 p = hash_get_mem (counter_vector_by_name, "vector_rate");
21457 clib_spinlock_unlock (vam->stat_segment_lockp);
21458 errmsg ("vector_rate not found?");
21462 vector_rate = *(f64 *) (p[0]);
21463 p = hash_get_mem (counter_vector_by_name, "input_rate");
21466 clib_spinlock_unlock (vam->stat_segment_lockp);
21467 errmsg ("input_rate not found?");
21470 input_rate = *(f64 *) (p[0]);
21472 clib_spinlock_unlock (vam->stat_segment_lockp);
21474 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
21475 vector_rate, input_rate);
21476 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
21477 thread0_index1_packets, thread0_index1_bytes);
21483 cmd_cmp (void *a1, void *a2)
21488 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
21492 help (vat_main_t * vam)
21497 unformat_input_t *i = vam->input;
21500 if (unformat (i, "%s", &name))
21504 vec_add1 (name, 0);
21506 hs = hash_get_mem (vam->help_by_name, name);
21508 print (vam->ofp, "usage: %s %s", name, hs[0]);
21510 print (vam->ofp, "No such msg / command '%s'", name);
21515 print (vam->ofp, "Help is available for the following:");
21518 hash_foreach_pair (p, vam->function_by_name,
21520 vec_add1 (cmds, (u8 *)(p->key));
21524 vec_sort_with_function (cmds, cmd_cmp);
21526 for (j = 0; j < vec_len (cmds); j++)
21527 print (vam->ofp, "%s", cmds[j]);
21534 set (vat_main_t * vam)
21536 u8 *name = 0, *value = 0;
21537 unformat_input_t *i = vam->input;
21539 if (unformat (i, "%s", &name))
21541 /* The input buffer is a vector, not a string. */
21542 value = vec_dup (i->buffer);
21543 vec_delete (value, i->index, 0);
21544 /* Almost certainly has a trailing newline */
21545 if (value[vec_len (value) - 1] == '\n')
21546 value[vec_len (value) - 1] = 0;
21547 /* Make sure it's a proper string, one way or the other */
21548 vec_add1 (value, 0);
21549 (void) clib_macro_set_value (&vam->macro_main,
21550 (char *) name, (char *) value);
21553 errmsg ("usage: set <name> <value>");
21561 unset (vat_main_t * vam)
21565 if (unformat (vam->input, "%s", &name))
21566 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
21567 errmsg ("unset: %s wasn't set", name);
21580 macro_sort_cmp (void *a1, void *a2)
21582 macro_sort_t *s1 = a1;
21583 macro_sort_t *s2 = a2;
21585 return strcmp ((char *) (s1->name), (char *) (s2->name));
21589 dump_macro_table (vat_main_t * vam)
21591 macro_sort_t *sort_me = 0, *sm;
21596 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
21598 vec_add2 (sort_me, sm, 1);
21599 sm->name = (u8 *)(p->key);
21600 sm->value = (u8 *) (p->value[0]);
21604 vec_sort_with_function (sort_me, macro_sort_cmp);
21606 if (vec_len (sort_me))
21607 print (vam->ofp, "%-15s%s", "Name", "Value");
21609 print (vam->ofp, "The macro table is empty...");
21611 for (i = 0; i < vec_len (sort_me); i++)
21612 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
21617 dump_node_table (vat_main_t * vam)
21620 vlib_node_t *node, *next_node;
21622 if (vec_len (vam->graph_nodes) == 0)
21624 print (vam->ofp, "Node table empty, issue get_node_graph...");
21628 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
21630 node = vam->graph_nodes[0][i];
21631 print (vam->ofp, "[%d] %s", i, node->name);
21632 for (j = 0; j < vec_len (node->next_nodes); j++)
21634 if (node->next_nodes[j] != ~0)
21636 next_node = vam->graph_nodes[0][node->next_nodes[j]];
21637 print (vam->ofp, " [%d] %s", j, next_node->name);
21645 value_sort_cmp (void *a1, void *a2)
21647 name_sort_t *n1 = a1;
21648 name_sort_t *n2 = a2;
21650 if (n1->value < n2->value)
21652 if (n1->value > n2->value)
21659 dump_msg_api_table (vat_main_t * vam)
21661 api_main_t *am = &api_main;
21662 name_sort_t *nses = 0, *ns;
21667 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
21669 vec_add2 (nses, ns, 1);
21670 ns->name = (u8 *)(hp->key);
21671 ns->value = (u32) hp->value[0];
21675 vec_sort_with_function (nses, value_sort_cmp);
21677 for (i = 0; i < vec_len (nses); i++)
21678 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
21684 get_msg_id (vat_main_t * vam)
21689 if (unformat (vam->input, "%s", &name_and_crc))
21691 message_index = vl_msg_api_get_msg_index (name_and_crc);
21692 if (message_index == ~0)
21694 print (vam->ofp, " '%s' not found", name_and_crc);
21697 print (vam->ofp, " '%s' has message index %d",
21698 name_and_crc, message_index);
21701 errmsg ("name_and_crc required...");
21706 search_node_table (vat_main_t * vam)
21708 unformat_input_t *line_input = vam->input;
21711 vlib_node_t *node, *next_node;
21714 if (vam->graph_node_index_by_name == 0)
21716 print (vam->ofp, "Node table empty, issue get_node_graph...");
21720 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21722 if (unformat (line_input, "%s", &node_to_find))
21724 vec_add1 (node_to_find, 0);
21725 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
21728 print (vam->ofp, "%s not found...", node_to_find);
21731 node = vam->graph_nodes[0][p[0]];
21732 print (vam->ofp, "[%d] %s", p[0], node->name);
21733 for (j = 0; j < vec_len (node->next_nodes); j++)
21735 if (node->next_nodes[j] != ~0)
21737 next_node = vam->graph_nodes[0][node->next_nodes[j]];
21738 print (vam->ofp, " [%d] %s", j, next_node->name);
21745 clib_warning ("parse error '%U'", format_unformat_error,
21751 vec_free (node_to_find);
21760 script (vat_main_t * vam)
21762 #if (VPP_API_TEST_BUILTIN==0)
21764 char *save_current_file;
21765 unformat_input_t save_input;
21766 jmp_buf save_jump_buf;
21767 u32 save_line_number;
21769 FILE *new_fp, *save_ifp;
21771 if (unformat (vam->input, "%s", &s))
21773 new_fp = fopen ((char *) s, "r");
21776 errmsg ("Couldn't open script file %s", s);
21783 errmsg ("Missing script name");
21787 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
21788 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
21789 save_ifp = vam->ifp;
21790 save_line_number = vam->input_line_number;
21791 save_current_file = (char *) vam->current_file;
21793 vam->input_line_number = 0;
21795 vam->current_file = s;
21798 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
21799 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
21800 vam->ifp = save_ifp;
21801 vam->input_line_number = save_line_number;
21802 vam->current_file = (u8 *) save_current_file;
21807 clib_warning ("use the exec command...");
21813 echo (vat_main_t * vam)
21815 print (vam->ofp, "%v", vam->input->buffer);
21819 /* List of API message constructors, CLI names map to api_xxx */
21820 #define foreach_vpe_api_msg \
21821 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
21822 _(sw_interface_dump,"") \
21823 _(sw_interface_set_flags, \
21824 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
21825 _(sw_interface_add_del_address, \
21826 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
21827 _(sw_interface_set_rx_mode, \
21828 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
21829 _(sw_interface_set_rx_placement, \
21830 "<intfc> | sw_if_index <id> [queue <id>] [worker <id> | main]") \
21831 _(sw_interface_rx_placement_dump, \
21832 "[<intfc> | sw_if_index <id>]") \
21833 _(sw_interface_set_table, \
21834 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
21835 _(sw_interface_set_mpls_enable, \
21836 "<intfc> | sw_if_index [disable | dis]") \
21837 _(sw_interface_set_vpath, \
21838 "<intfc> | sw_if_index <id> enable | disable") \
21839 _(sw_interface_set_vxlan_bypass, \
21840 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21841 _(sw_interface_set_geneve_bypass, \
21842 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21843 _(sw_interface_set_l2_xconnect, \
21844 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
21845 "enable | disable") \
21846 _(sw_interface_set_l2_bridge, \
21847 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
21848 "[shg <split-horizon-group>] [bvi]\n" \
21849 "enable | disable") \
21850 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
21851 _(bridge_domain_add_del, \
21852 "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") \
21853 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
21855 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
21856 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
21857 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
21859 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21861 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21863 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>] [host-mtu-size <mtu>] [gso | no-gso]") \
21865 "<vpp-if-name> | sw_if_index <id>") \
21866 _(sw_interface_tap_v2_dump, "") \
21867 _(virtio_pci_create, \
21868 "pci-addr <pci-address> [use_random_mac | hw-addr <mac-addr>] [features <hex-value>] [gso-enabled]") \
21869 _(virtio_pci_delete, \
21870 "<vpp-if-name> | sw_if_index <id>") \
21871 _(sw_interface_virtio_pci_dump, "") \
21873 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
21874 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \
21877 "<vpp-if-name> | sw_if_index <id>") \
21879 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
21880 _(bond_detach_slave, \
21881 "sw_if_index <n>") \
21882 _(sw_interface_bond_dump, "") \
21883 _(sw_interface_slave_dump, \
21884 "<vpp-if-name> | sw_if_index <id>") \
21885 _(ip_table_add_del, \
21886 "table <n> [ipv6] [add | del]\n") \
21887 _(ip_route_add_del, \
21888 "<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
21889 "[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
21890 "[weight <n>] [drop] [local] [classify <n>] [out-label <n>]\n" \
21891 "[multipath] [count <n>] [del]") \
21892 _(ip_mroute_add_del, \
21893 "<src> <grp>/<mask> [table-id <n>]\n" \
21894 "[<intfc> | sw_if_index <id>] [local] [del]") \
21895 _(mpls_table_add_del, \
21896 "table <n> [add | del]\n") \
21897 _(mpls_route_add_del, \
21898 "<label> <eos> via <addr | next-hop-table <n> | via-label <n> |\n" \
21899 "lookup-ip4-table <n> | lookup-in-ip6-table <n> |\n" \
21900 "l2-input-on <intfc> | l2-input-on sw_if_index <id>>\n" \
21901 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>] [weight <n>]\n" \
21902 "[drop] [local] [classify <n>] [out-label <n>] [multipath]\n" \
21903 "[count <n>] [del]") \
21904 _(mpls_ip_bind_unbind, \
21905 "<label> <addr/len>") \
21906 _(mpls_tunnel_add_del, \
21907 "[add | del <intfc | sw_if_index <id>>] via <addr | via-label <n>>\n" \
21908 "[<intfc> | sw_if_index <id> | next-hop-table <id>]\n" \
21909 "[l2-only] [out-label <n>]") \
21910 _(sr_mpls_policy_add, \
21911 "bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
21912 _(sr_mpls_policy_del, \
21914 _(bier_table_add_del, \
21915 "<label> <sub-domain> <set> <bsl> [del]") \
21916 _(bier_route_add_del, \
21917 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
21918 "[<intfc> | sw_if_index <id>]" \
21919 "[weight <n>] [del] [multipath]") \
21920 _(proxy_arp_add_del, \
21921 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
21922 _(proxy_arp_intfc_enable_disable, \
21923 "<intfc> | sw_if_index <id> enable | disable") \
21924 _(sw_interface_set_unnumbered, \
21925 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
21926 _(ip_neighbor_add_del, \
21927 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
21928 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
21929 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
21930 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
21931 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
21932 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
21933 "[outer_vlan_id_any][inner_vlan_id_any]") \
21934 _(reset_fib, "vrf <n> [ipv6]") \
21935 _(dhcp_proxy_config, \
21936 "svr <v46-address> src <v46-address>\n" \
21937 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
21938 _(dhcp_proxy_set_vss, \
21939 "tbl_id <n> [fib_id <n> oui <n> | vpn_ascii_id <text>] [ipv6] [del]") \
21940 _(dhcp_proxy_dump, "ip6") \
21941 _(dhcp_client_config, \
21942 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
21943 _(set_ip_flow_hash, \
21944 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
21945 _(sw_interface_ip6_enable_disable, \
21946 "<intfc> | sw_if_index <id> enable | disable") \
21947 _(ip6nd_proxy_add_del, \
21948 "<intfc> | sw_if_index <id> <ip6-address>") \
21949 _(ip6nd_proxy_dump, "") \
21950 _(sw_interface_ip6nd_ra_prefix, \
21951 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
21952 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
21953 "[nolink] [isno]") \
21954 _(sw_interface_ip6nd_ra_config, \
21955 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
21956 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
21957 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
21958 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
21959 _(l2_patch_add_del, \
21960 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
21961 "enable | disable") \
21962 _(sr_localsid_add_del, \
21963 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
21964 "fib-table <num> (end.psp) sw_if_index <num>") \
21965 _(classify_add_del_table, \
21966 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
21967 " [del] [del-chain] mask <mask-value>\n" \
21968 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
21969 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
21970 _(classify_add_del_session, \
21971 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
21972 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
21973 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
21974 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
21975 _(classify_set_interface_ip_table, \
21976 "<intfc> | sw_if_index <nn> table <nn>") \
21977 _(classify_set_interface_l2_tables, \
21978 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21979 " [other-table <nn>]") \
21980 _(get_node_index, "node <node-name") \
21981 _(add_node_next, "node <node-name> next <next-node-name>") \
21982 _(l2tpv3_create_tunnel, \
21983 "client_address <ip6-addr> our_address <ip6-addr>\n" \
21984 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
21985 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
21986 _(l2tpv3_set_tunnel_cookies, \
21987 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
21988 "[new_remote_cookie <nn>]\n") \
21989 _(l2tpv3_interface_enable_disable, \
21990 "<intfc> | sw_if_index <nn> enable | disable") \
21991 _(l2tpv3_set_lookup_key, \
21992 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
21993 _(sw_if_l2tpv3_tunnel_dump, "") \
21994 _(vxlan_offload_rx, \
21995 "hw { <interface name> | hw_if_index <nn>} " \
21996 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
21997 _(vxlan_add_del_tunnel, \
21998 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
21999 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
22000 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
22001 _(geneve_add_del_tunnel, \
22002 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
22003 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
22004 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
22005 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22006 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22007 _(gre_tunnel_add_del, \
22008 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
22009 "[teb | erspan <session-id>] [del]") \
22010 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22011 _(l2_fib_clear_table, "") \
22012 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
22013 _(l2_interface_vlan_tag_rewrite, \
22014 "<intfc> | sw_if_index <nn> \n" \
22015 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
22016 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
22017 _(create_vhost_user_if, \
22018 "socket <filename> [server] [renumber <dev_instance>] " \
22019 "[disable_mrg_rxbuf] [disable_indirect_desc] " \
22020 "[mac <mac_address>]") \
22021 _(modify_vhost_user_if, \
22022 "<intfc> | sw_if_index <nn> socket <filename>\n" \
22023 "[server] [renumber <dev_instance>]") \
22024 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
22025 _(sw_interface_vhost_user_dump, "") \
22026 _(show_version, "") \
22027 _(show_threads, "") \
22028 _(vxlan_gpe_add_del_tunnel, \
22029 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
22030 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
22031 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
22032 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
22033 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22034 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
22035 _(interface_name_renumber, \
22036 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
22037 _(input_acl_set_interface, \
22038 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22039 " [l2-table <nn>] [del]") \
22040 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
22041 _(ip_scan_neighbor_enable_disable, "[ip4|ip6|both|disable] [interval <n-min>]\n" \
22042 " [max-time <n-usec>] [max-update <n>] [delay <n-msec>] [stale <n-min>]") \
22043 _(want_ip4_arp_events, "address <ip4-address> [del]") \
22044 _(want_ip6_nd_events, "address <ip6-address> [del]") \
22045 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
22046 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
22047 _(ip_dump, "ipv4 | ipv6") \
22048 _(ipsec_spd_add_del, "spd_id <n> [del]") \
22049 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
22051 _(ipsec_sad_entry_add_del, "sad_id <n> spi <n> crypto_alg <alg>\n" \
22052 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
22053 " integ_alg <alg> integ_key <hex>") \
22054 _(ipsec_spd_entry_add_del, "spd_id <n> priority <n> action <action>\n" \
22055 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
22056 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
22057 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
22058 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
22059 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
22060 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
22061 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
22062 " [instance <n>]") \
22063 _(ipsec_sa_dump, "[sa_id <n>]") \
22064 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
22065 _(delete_loopback,"sw_if_index <nn>") \
22066 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
22067 _(bd_ip_mac_flush, "bd_id <bridge-domain-id>") \
22068 _(bd_ip_mac_dump, "[bd_id] <bridge-domain-id>") \
22069 _(want_interface_events, "enable|disable") \
22070 _(get_first_msg_id, "client <name>") \
22071 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
22072 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
22073 "fib-id <nn> [ip4][ip6][default]") \
22074 _(get_node_graph, " ") \
22075 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
22076 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
22077 _(ioam_disable, "") \
22078 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
22079 " sw_if_index <sw_if_index> p <priority> " \
22080 "w <weight>] [del]") \
22081 _(one_add_del_locator, "locator-set <locator_name> " \
22082 "iface <intf> | sw_if_index <sw_if_index> " \
22083 "p <priority> w <weight> [del]") \
22084 _(one_add_del_local_eid,"vni <vni> eid " \
22085 "<ipv4|ipv6>/<prefix> | <L2 address> " \
22086 "locator-set <locator_name> [del]" \
22087 "[key-id sha1|sha256 secret-key <secret-key>]")\
22088 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
22089 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
22090 _(one_enable_disable, "enable|disable") \
22091 _(one_map_register_enable_disable, "enable|disable") \
22092 _(one_map_register_fallback_threshold, "<value>") \
22093 _(one_rloc_probe_enable_disable, "enable|disable") \
22094 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
22096 "rloc <locator> p <prio> " \
22097 "w <weight> [rloc <loc> ... ] " \
22098 "action <action> [del-all]") \
22099 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
22101 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
22102 _(one_use_petr, "ip-address> | disable") \
22103 _(one_map_request_mode, "src-dst|dst-only") \
22104 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
22105 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
22106 _(one_locator_set_dump, "[local | remote]") \
22107 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
22108 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
22109 "[local] | [remote]") \
22110 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
22111 _(one_ndp_bd_get, "") \
22112 _(one_ndp_entries_get, "bd <bridge-domain>") \
22113 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
22114 _(one_l2_arp_bd_get, "") \
22115 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
22116 _(one_stats_enable_disable, "enable|disable") \
22117 _(show_one_stats_enable_disable, "") \
22118 _(one_eid_table_vni_dump, "") \
22119 _(one_eid_table_map_dump, "l2|l3") \
22120 _(one_map_resolver_dump, "") \
22121 _(one_map_server_dump, "") \
22122 _(one_adjacencies_get, "vni <vni>") \
22123 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
22124 _(show_one_rloc_probe_state, "") \
22125 _(show_one_map_register_state, "") \
22126 _(show_one_status, "") \
22127 _(one_stats_dump, "") \
22128 _(one_stats_flush, "") \
22129 _(one_get_map_request_itr_rlocs, "") \
22130 _(one_map_register_set_ttl, "<ttl>") \
22131 _(one_set_transport_protocol, "udp|api") \
22132 _(one_get_transport_protocol, "") \
22133 _(one_enable_disable_xtr_mode, "enable|disable") \
22134 _(one_show_xtr_mode, "") \
22135 _(one_enable_disable_pitr_mode, "enable|disable") \
22136 _(one_show_pitr_mode, "") \
22137 _(one_enable_disable_petr_mode, "enable|disable") \
22138 _(one_show_petr_mode, "") \
22139 _(show_one_nsh_mapping, "") \
22140 _(show_one_pitr, "") \
22141 _(show_one_use_petr, "") \
22142 _(show_one_map_request_mode, "") \
22143 _(show_one_map_register_ttl, "") \
22144 _(show_one_map_register_fallback_threshold, "") \
22145 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
22146 " sw_if_index <sw_if_index> p <priority> " \
22147 "w <weight>] [del]") \
22148 _(lisp_add_del_locator, "locator-set <locator_name> " \
22149 "iface <intf> | sw_if_index <sw_if_index> " \
22150 "p <priority> w <weight> [del]") \
22151 _(lisp_add_del_local_eid,"vni <vni> eid " \
22152 "<ipv4|ipv6>/<prefix> | <L2 address> " \
22153 "locator-set <locator_name> [del]" \
22154 "[key-id sha1|sha256 secret-key <secret-key>]") \
22155 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
22156 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
22157 _(lisp_enable_disable, "enable|disable") \
22158 _(lisp_map_register_enable_disable, "enable|disable") \
22159 _(lisp_rloc_probe_enable_disable, "enable|disable") \
22160 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
22162 "rloc <locator> p <prio> " \
22163 "w <weight> [rloc <loc> ... ] " \
22164 "action <action> [del-all]") \
22165 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
22167 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
22168 _(lisp_use_petr, "<ip-address> | disable") \
22169 _(lisp_map_request_mode, "src-dst|dst-only") \
22170 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
22171 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
22172 _(lisp_locator_set_dump, "[local | remote]") \
22173 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
22174 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
22175 "[local] | [remote]") \
22176 _(lisp_eid_table_vni_dump, "") \
22177 _(lisp_eid_table_map_dump, "l2|l3") \
22178 _(lisp_map_resolver_dump, "") \
22179 _(lisp_map_server_dump, "") \
22180 _(lisp_adjacencies_get, "vni <vni>") \
22181 _(gpe_fwd_entry_vnis_get, "") \
22182 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
22183 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
22184 "[table <table-id>]") \
22185 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
22186 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
22187 _(gpe_set_encap_mode, "lisp|vxlan") \
22188 _(gpe_get_encap_mode, "") \
22189 _(lisp_gpe_add_del_iface, "up|down") \
22190 _(lisp_gpe_enable_disable, "enable|disable") \
22191 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
22192 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
22193 _(show_lisp_rloc_probe_state, "") \
22194 _(show_lisp_map_register_state, "") \
22195 _(show_lisp_status, "") \
22196 _(lisp_get_map_request_itr_rlocs, "") \
22197 _(show_lisp_pitr, "") \
22198 _(show_lisp_use_petr, "") \
22199 _(show_lisp_map_request_mode, "") \
22200 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
22201 _(af_packet_delete, "name <host interface name>") \
22202 _(af_packet_dump, "") \
22203 _(policer_add_del, "name <policer name> <params> [del]") \
22204 _(policer_dump, "[name <policer name>]") \
22205 _(policer_classify_set_interface, \
22206 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22207 " [l2-table <nn>] [del]") \
22208 _(policer_classify_dump, "type [ip4|ip6|l2]") \
22209 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
22210 "[master|slave]") \
22211 _(netmap_delete, "name <interface name>") \
22212 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
22213 _(mpls_table_dump, "") \
22214 _(mpls_route_dump, "table-id <ID>") \
22215 _(classify_table_ids, "") \
22216 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
22217 _(classify_table_info, "table_id <nn>") \
22218 _(classify_session_dump, "table_id <nn>") \
22219 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
22220 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
22221 "[template_interval <nn>] [udp_checksum]") \
22222 _(ipfix_exporter_dump, "") \
22223 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
22224 _(ipfix_classify_stream_dump, "") \
22225 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
22226 _(ipfix_classify_table_dump, "") \
22227 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
22228 _(sw_interface_span_dump, "[l2]") \
22229 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
22230 _(pg_create_interface, "if_id <nn>") \
22231 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
22232 _(pg_enable_disable, "[stream <id>] disable") \
22233 _(ip_source_and_port_range_check_add_del, \
22234 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
22235 _(ip_source_and_port_range_check_interface_add_del, \
22236 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
22237 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
22238 _(delete_subif,"<intfc> | sw_if_index <nn>") \
22239 _(l2_interface_pbb_tag_rewrite, \
22240 "<intfc> | sw_if_index <nn> \n" \
22241 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
22242 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
22243 _(set_punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
22244 _(flow_classify_set_interface, \
22245 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
22246 _(flow_classify_dump, "type [ip4|ip6]") \
22247 _(ip_table_dump, "") \
22248 _(ip_route_dump, "table-id [ip4|ip6]") \
22249 _(ip_mtable_dump, "") \
22250 _(ip_mroute_dump, "table-id [ip4|ip6]") \
22251 _(feature_enable_disable, "arc_name <arc_name> " \
22252 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
22253 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
22255 _(l2_xconnect_dump, "") \
22256 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
22257 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
22258 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
22259 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
22260 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
22261 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
22262 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
22263 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
22264 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
22265 _(sock_init_shm, "size <nnn>") \
22266 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
22267 _(dns_enable_disable, "[enable][disable]") \
22268 _(dns_name_server_add_del, "<ip-address> [del]") \
22269 _(dns_resolve_name, "<hostname>") \
22270 _(dns_resolve_ip, "<ip4|ip6>") \
22271 _(dns_name_server_add_del, "<ip-address> [del]") \
22272 _(dns_resolve_name, "<hostname>") \
22273 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
22274 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
22275 _(session_rules_dump, "") \
22276 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
22277 _(output_acl_set_interface, \
22278 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22279 " [l2-table <nn>] [del]") \
22280 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
22282 /* List of command functions, CLI names map directly to functions */
22283 #define foreach_cli_function \
22284 _(comment, "usage: comment <ignore-rest-of-line>") \
22285 _(dump_interface_table, "usage: dump_interface_table") \
22286 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
22287 _(dump_ipv4_table, "usage: dump_ipv4_table") \
22288 _(dump_ipv6_table, "usage: dump_ipv6_table") \
22289 _(dump_macro_table, "usage: dump_macro_table ") \
22290 _(dump_node_table, "usage: dump_node_table") \
22291 _(dump_msg_api_table, "usage: dump_msg_api_table") \
22292 _(get_msg_id, "usage: get_msg_id name_and_crc") \
22293 _(echo, "usage: echo <message>") \
22294 _(exec, "usage: exec <vpe-debug-CLI-command>") \
22295 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
22296 _(help, "usage: help") \
22297 _(q, "usage: quit") \
22298 _(quit, "usage: quit") \
22299 _(search_node_table, "usage: search_node_table <name>...") \
22300 _(set, "usage: set <variable-name> <value>") \
22301 _(script, "usage: script <file-name>") \
22302 _(statseg, "usage: statseg") \
22303 _(unset, "usage: unset <variable-name>")
22306 static void vl_api_##n##_t_handler_uni \
22307 (vl_api_##n##_t * mp) \
22309 vat_main_t * vam = &vat_main; \
22310 if (vam->json_output) { \
22311 vl_api_##n##_t_handler_json(mp); \
22313 vl_api_##n##_t_handler(mp); \
22316 foreach_vpe_api_reply_msg;
22317 #if VPP_API_TEST_BUILTIN == 0
22318 foreach_standalone_reply_msg;
22323 vat_api_hookup (vat_main_t * vam)
22326 vl_msg_api_set_handlers(VL_API_##N, #n, \
22327 vl_api_##n##_t_handler_uni, \
22329 vl_api_##n##_t_endian, \
22330 vl_api_##n##_t_print, \
22331 sizeof(vl_api_##n##_t), 1);
22332 foreach_vpe_api_reply_msg;
22333 #if VPP_API_TEST_BUILTIN == 0
22334 foreach_standalone_reply_msg;
22338 #if (VPP_API_TEST_BUILTIN==0)
22339 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
22341 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
22343 vam->function_by_name = hash_create_string (0, sizeof (uword));
22345 vam->help_by_name = hash_create_string (0, sizeof (uword));
22348 /* API messages we can send */
22349 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
22350 foreach_vpe_api_msg;
22354 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
22355 foreach_vpe_api_msg;
22358 /* CLI functions */
22359 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
22360 foreach_cli_function;
22364 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
22365 foreach_cli_function;
22369 #if VPP_API_TEST_BUILTIN
22370 static clib_error_t *
22371 vat_api_hookup_shim (vlib_main_t * vm)
22373 vat_api_hookup (&vat_main);
22377 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
22381 * fd.io coding-style-patch-verification: ON
22384 * eval: (c-set-style "gnu")