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 <vppinfra/socket.h>
22 #include <vlibapi/api.h>
23 #include <vlibmemory/api.h>
24 #include <vnet/ip/ip.h>
25 #include <vnet/ip/ip_neighbor.h>
26 #include <vnet/l2/l2_input.h>
27 #include <vnet/l2tp/l2tp.h>
28 #include <vnet/vxlan/vxlan.h>
29 #include <vnet/geneve/geneve.h>
30 #include <vnet/gre/gre.h>
31 #include <vnet/vxlan-gpe/vxlan_gpe.h>
32 #include <vnet/lisp-gpe/lisp_gpe.h>
34 #include <vpp/api/vpe_msg_enum.h>
35 #include <vnet/l2/l2_classify.h>
36 #include <vnet/l2/l2_vtr.h>
37 #include <vnet/classify/in_out_acl.h>
38 #include <vnet/classify/policer_classify.h>
39 #include <vnet/classify/flow_classify.h>
40 #include <vnet/mpls/mpls.h>
41 #include <vnet/ipsec/ipsec.h>
42 #include <vnet/ipsec/ikev2.h>
44 #include <vnet/cop/cop.h>
45 #include <vnet/ip/ip6_hop_by_hop.h>
46 #include <vnet/ip/ip_source_and_port_range_check.h>
47 #include <vnet/policer/xlate.h>
48 #include <vnet/span/span.h>
49 #include <vnet/policer/policer.h>
50 #include <vnet/policer/police.h>
51 #include <vnet/mfib/mfib_types.h>
52 #include <vnet/dhcp/dhcp_proxy.h>
53 #include <vnet/bonding/node.h>
54 #include <vnet/qos/qos_types.h>
55 #include "vat/json_format.h"
60 #define vl_typedefs /* define message structures */
61 #include <vpp/api/vpe_all_api_h.h>
64 /* declare message handlers for each api */
66 #define vl_endianfun /* define message structures */
67 #include <vpp/api/vpe_all_api_h.h>
70 /* instantiate all the print functions we know about */
71 #define vl_print(handle, ...)
73 #include <vpp/api/vpe_all_api_h.h>
76 #define __plugin_msg_base 0
77 #include <vlibapi/vat_helper_macros.h>
79 #if VPP_API_TEST_BUILTIN == 0
89 vat_socket_connect (vat_main_t * vam)
91 vam->socket_client_main = &socket_client_main;
92 return vl_socket_client_connect ((char *) vam->socket_name, "vpp_api_test",
93 0 /* default socket rx, tx buffer */ );
95 #else /* vpp built-in case, we don't do sockets... */
97 vat_socket_connect (vat_main_t * vam)
103 vl_socket_client_read (int wait)
109 vl_socket_client_write ()
115 vl_socket_client_msg_alloc (int nbytes)
123 vat_time_now (vat_main_t * vam)
125 #if VPP_API_TEST_BUILTIN
126 return vlib_time_now (vam->vlib_main);
128 return clib_time_now (&vam->clib_time);
133 errmsg (char *fmt, ...)
135 vat_main_t *vam = &vat_main;
140 s = va_format (0, fmt, &va);
145 #if VPP_API_TEST_BUILTIN
146 vlib_cli_output (vam->vlib_main, (char *) s);
149 if (vam->ifp != stdin)
150 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
151 vam->input_line_number);
152 fformat (vam->ofp, (char *) s);
160 #if VPP_API_TEST_BUILTIN == 0
162 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
164 vat_main_t *vam = va_arg (*args, vat_main_t *);
165 u32 *result = va_arg (*args, u32 *);
169 if (!unformat (input, "%s", &if_name))
172 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
180 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
185 /* Parse an IP4 address %d.%d.%d.%d. */
187 unformat_ip4_address (unformat_input_t * input, va_list * args)
189 u8 *result = va_arg (*args, u8 *);
192 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
195 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
207 unformat_ethernet_address (unformat_input_t * input, va_list * args)
209 u8 *result = va_arg (*args, u8 *);
212 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
213 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
217 for (i = 0; i < 6; i++)
218 if (a[i] >= (1 << 8))
221 for (i = 0; i < 6; i++)
227 /* Returns ethernet type as an int in host byte order. */
229 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
232 u16 *result = va_arg (*args, u16 *);
236 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
238 if (type >= (1 << 16))
246 /* Parse an IP6 address. */
248 unformat_ip6_address (unformat_input_t * input, va_list * args)
250 ip6_address_t *result = va_arg (*args, ip6_address_t *);
252 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
253 uword c, n_colon, double_colon_index;
255 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
256 double_colon_index = ARRAY_LEN (hex_quads);
257 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
260 if (c >= '0' && c <= '9')
262 else if (c >= 'a' && c <= 'f')
263 hex_digit = c + 10 - 'a';
264 else if (c >= 'A' && c <= 'F')
265 hex_digit = c + 10 - 'A';
266 else if (c == ':' && n_colon < 2)
270 unformat_put_input (input);
274 /* Too many hex quads. */
275 if (n_hex_quads >= ARRAY_LEN (hex_quads))
280 hex_quad = (hex_quad << 4) | hex_digit;
282 /* Hex quad must fit in 16 bits. */
283 if (n_hex_digits >= 4)
290 /* Save position of :: */
293 /* More than one :: ? */
294 if (double_colon_index < ARRAY_LEN (hex_quads))
296 double_colon_index = n_hex_quads;
299 if (n_colon > 0 && n_hex_digits > 0)
301 hex_quads[n_hex_quads++] = hex_quad;
307 if (n_hex_digits > 0)
308 hex_quads[n_hex_quads++] = hex_quad;
313 /* Expand :: to appropriate number of zero hex quads. */
314 if (double_colon_index < ARRAY_LEN (hex_quads))
316 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
318 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
319 hex_quads[n_zero + i] = hex_quads[i];
321 for (i = 0; i < n_zero; i++)
322 hex_quads[double_colon_index + i] = 0;
324 n_hex_quads = ARRAY_LEN (hex_quads);
327 /* Too few hex quads given. */
328 if (n_hex_quads < ARRAY_LEN (hex_quads))
331 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
332 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
339 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
341 u32 *r = va_arg (*args, u32 *);
344 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
345 foreach_ipsec_policy_action
353 unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args)
355 u32 *r = va_arg (*args, u32 *);
358 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
359 foreach_ipsec_crypto_alg
367 format_ipsec_crypto_alg (u8 * s, va_list * args)
369 u32 i = va_arg (*args, u32);
374 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
375 foreach_ipsec_crypto_alg
378 return format (s, "unknown");
380 return format (s, "%s", t);
384 unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args)
386 u32 *r = va_arg (*args, u32 *);
389 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f;
390 foreach_ipsec_integ_alg
398 format_ipsec_integ_alg (u8 * s, va_list * args)
400 u32 i = va_arg (*args, u32);
405 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
406 foreach_ipsec_integ_alg
409 return format (s, "unknown");
411 return format (s, "%s", t);
415 unformat_ikev2_auth_method (unformat_input_t * input, va_list * args)
417 u32 *r = va_arg (*args, u32 *);
420 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f;
421 foreach_ikev2_auth_method
429 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
431 u32 *r = va_arg (*args, u32 *);
434 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
435 foreach_ikev2_id_type
441 #else /* VPP_API_TEST_BUILTIN == 1 */
443 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
445 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
446 vnet_main_t *vnm = vnet_get_main ();
447 u32 *result = va_arg (*args, u32 *);
449 return unformat (input, "%U", unformat_vnet_sw_interface, vnm, result);
453 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
455 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
456 vnet_main_t *vnm = vnet_get_main ();
457 u32 *result = va_arg (*args, u32 *);
459 return unformat (input, "%U", unformat_vnet_hw_interface, vnm, result);
462 #endif /* VPP_API_TEST_BUILTIN */
465 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
467 u8 *r = va_arg (*args, u8 *);
469 if (unformat (input, "kbps"))
470 *r = SSE2_QOS_RATE_KBPS;
471 else if (unformat (input, "pps"))
472 *r = SSE2_QOS_RATE_PPS;
479 unformat_policer_round_type (unformat_input_t * input, va_list * args)
481 u8 *r = va_arg (*args, u8 *);
483 if (unformat (input, "closest"))
484 *r = SSE2_QOS_ROUND_TO_CLOSEST;
485 else if (unformat (input, "up"))
486 *r = SSE2_QOS_ROUND_TO_UP;
487 else if (unformat (input, "down"))
488 *r = SSE2_QOS_ROUND_TO_DOWN;
495 unformat_policer_type (unformat_input_t * input, va_list * args)
497 u8 *r = va_arg (*args, u8 *);
499 if (unformat (input, "1r2c"))
500 *r = SSE2_QOS_POLICER_TYPE_1R2C;
501 else if (unformat (input, "1r3c"))
502 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
503 else if (unformat (input, "2r3c-2698"))
504 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
505 else if (unformat (input, "2r3c-4115"))
506 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
507 else if (unformat (input, "2r3c-mef5cf1"))
508 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
515 unformat_dscp (unformat_input_t * input, va_list * va)
517 u8 *r = va_arg (*va, u8 *);
520 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
529 unformat_policer_action_type (unformat_input_t * input, va_list * va)
531 sse2_qos_pol_action_params_st *a
532 = va_arg (*va, sse2_qos_pol_action_params_st *);
534 if (unformat (input, "drop"))
535 a->action_type = SSE2_QOS_ACTION_DROP;
536 else if (unformat (input, "transmit"))
537 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
538 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
539 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
546 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
548 u32 *r = va_arg (*va, u32 *);
551 if (unformat (input, "ip4"))
552 tid = POLICER_CLASSIFY_TABLE_IP4;
553 else if (unformat (input, "ip6"))
554 tid = POLICER_CLASSIFY_TABLE_IP6;
555 else if (unformat (input, "l2"))
556 tid = POLICER_CLASSIFY_TABLE_L2;
565 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
567 u32 *r = va_arg (*va, u32 *);
570 if (unformat (input, "ip4"))
571 tid = FLOW_CLASSIFY_TABLE_IP4;
572 else if (unformat (input, "ip6"))
573 tid = FLOW_CLASSIFY_TABLE_IP6;
581 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
582 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
583 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
584 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
586 #if (VPP_API_TEST_BUILTIN==0)
588 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
590 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
591 mfib_itf_attribute_t attr;
594 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
596 if (unformat (input, mfib_itf_flag_long_names[attr]))
597 *iflags |= (1 << attr);
599 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
601 if (unformat (input, mfib_itf_flag_names[attr]))
602 *iflags |= (1 << attr);
605 return (old == *iflags ? 0 : 1);
609 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
611 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
612 mfib_entry_attribute_t attr;
615 FOR_EACH_MFIB_ATTRIBUTE (attr)
617 if (unformat (input, mfib_flag_long_names[attr]))
618 *eflags |= (1 << attr);
620 FOR_EACH_MFIB_ATTRIBUTE (attr)
622 if (unformat (input, mfib_flag_names[attr]))
623 *eflags |= (1 << attr);
626 return (old == *eflags ? 0 : 1);
630 format_ip4_address (u8 * s, va_list * args)
632 u8 *a = va_arg (*args, u8 *);
633 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
637 format_ip6_address (u8 * s, va_list * args)
639 ip6_address_t *a = va_arg (*args, ip6_address_t *);
640 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
642 i_max_n_zero = ARRAY_LEN (a->as_u16);
644 i_first_zero = i_max_n_zero;
646 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
648 u32 is_zero = a->as_u16[i] == 0;
649 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
655 if ((!is_zero && n_zeros > max_n_zeros)
656 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
658 i_max_n_zero = i_first_zero;
659 max_n_zeros = n_zeros;
660 i_first_zero = ARRAY_LEN (a->as_u16);
665 last_double_colon = 0;
666 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
668 if (i == i_max_n_zero && max_n_zeros > 1)
670 s = format (s, "::");
671 i += max_n_zeros - 1;
672 last_double_colon = 1;
676 s = format (s, "%s%x",
677 (last_double_colon || i == 0) ? "" : ":",
678 clib_net_to_host_u16 (a->as_u16[i]));
679 last_double_colon = 0;
686 /* Format an IP46 address. */
688 format_ip46_address (u8 * s, va_list * args)
690 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
691 ip46_type_t type = va_arg (*args, ip46_type_t);
697 is_ip4 = ip46_address_is_ip4 (ip46);
708 format (s, "%U", format_ip4_address, &ip46->ip4) :
709 format (s, "%U", format_ip6_address, &ip46->ip6);
713 format_ethernet_address (u8 * s, va_list * args)
715 u8 *a = va_arg (*args, u8 *);
717 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
718 a[0], a[1], a[2], a[3], a[4], a[5]);
723 increment_v4_address (ip4_address_t * a)
727 v = ntohl (a->as_u32) + 1;
728 a->as_u32 = ntohl (v);
732 increment_v6_address (ip6_address_t * a)
736 v0 = clib_net_to_host_u64 (a->as_u64[0]);
737 v1 = clib_net_to_host_u64 (a->as_u64[1]);
742 a->as_u64[0] = clib_net_to_host_u64 (v0);
743 a->as_u64[1] = clib_net_to_host_u64 (v1);
747 increment_mac_address (u8 * mac)
749 u64 tmp = *((u64 *) mac);
750 tmp = clib_net_to_host_u64 (tmp);
751 tmp += 1 << 16; /* skip unused (least significant) octets */
752 tmp = clib_host_to_net_u64 (tmp);
754 clib_memcpy (mac, &tmp, 6);
757 static void vl_api_create_loopback_reply_t_handler
758 (vl_api_create_loopback_reply_t * mp)
760 vat_main_t *vam = &vat_main;
761 i32 retval = ntohl (mp->retval);
763 vam->retval = retval;
764 vam->regenerate_interface_table = 1;
765 vam->sw_if_index = ntohl (mp->sw_if_index);
766 vam->result_ready = 1;
769 static void vl_api_create_loopback_reply_t_handler_json
770 (vl_api_create_loopback_reply_t * mp)
772 vat_main_t *vam = &vat_main;
773 vat_json_node_t node;
775 vat_json_init_object (&node);
776 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
777 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
779 vat_json_print (vam->ofp, &node);
780 vat_json_free (&node);
781 vam->retval = ntohl (mp->retval);
782 vam->result_ready = 1;
785 static void vl_api_create_loopback_instance_reply_t_handler
786 (vl_api_create_loopback_instance_reply_t * mp)
788 vat_main_t *vam = &vat_main;
789 i32 retval = ntohl (mp->retval);
791 vam->retval = retval;
792 vam->regenerate_interface_table = 1;
793 vam->sw_if_index = ntohl (mp->sw_if_index);
794 vam->result_ready = 1;
797 static void vl_api_create_loopback_instance_reply_t_handler_json
798 (vl_api_create_loopback_instance_reply_t * mp)
800 vat_main_t *vam = &vat_main;
801 vat_json_node_t node;
803 vat_json_init_object (&node);
804 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
805 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
807 vat_json_print (vam->ofp, &node);
808 vat_json_free (&node);
809 vam->retval = ntohl (mp->retval);
810 vam->result_ready = 1;
813 static void vl_api_af_packet_create_reply_t_handler
814 (vl_api_af_packet_create_reply_t * mp)
816 vat_main_t *vam = &vat_main;
817 i32 retval = ntohl (mp->retval);
819 vam->retval = retval;
820 vam->regenerate_interface_table = 1;
821 vam->sw_if_index = ntohl (mp->sw_if_index);
822 vam->result_ready = 1;
825 static void vl_api_af_packet_create_reply_t_handler_json
826 (vl_api_af_packet_create_reply_t * mp)
828 vat_main_t *vam = &vat_main;
829 vat_json_node_t node;
831 vat_json_init_object (&node);
832 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
833 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
835 vat_json_print (vam->ofp, &node);
836 vat_json_free (&node);
838 vam->retval = ntohl (mp->retval);
839 vam->result_ready = 1;
842 static void vl_api_create_vlan_subif_reply_t_handler
843 (vl_api_create_vlan_subif_reply_t * mp)
845 vat_main_t *vam = &vat_main;
846 i32 retval = ntohl (mp->retval);
848 vam->retval = retval;
849 vam->regenerate_interface_table = 1;
850 vam->sw_if_index = ntohl (mp->sw_if_index);
851 vam->result_ready = 1;
854 static void vl_api_create_vlan_subif_reply_t_handler_json
855 (vl_api_create_vlan_subif_reply_t * mp)
857 vat_main_t *vam = &vat_main;
858 vat_json_node_t node;
860 vat_json_init_object (&node);
861 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
862 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
864 vat_json_print (vam->ofp, &node);
865 vat_json_free (&node);
867 vam->retval = ntohl (mp->retval);
868 vam->result_ready = 1;
871 static void vl_api_create_subif_reply_t_handler
872 (vl_api_create_subif_reply_t * mp)
874 vat_main_t *vam = &vat_main;
875 i32 retval = ntohl (mp->retval);
877 vam->retval = retval;
878 vam->regenerate_interface_table = 1;
879 vam->sw_if_index = ntohl (mp->sw_if_index);
880 vam->result_ready = 1;
883 static void vl_api_create_subif_reply_t_handler_json
884 (vl_api_create_subif_reply_t * mp)
886 vat_main_t *vam = &vat_main;
887 vat_json_node_t node;
889 vat_json_init_object (&node);
890 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
891 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
893 vat_json_print (vam->ofp, &node);
894 vat_json_free (&node);
896 vam->retval = ntohl (mp->retval);
897 vam->result_ready = 1;
900 static void vl_api_interface_name_renumber_reply_t_handler
901 (vl_api_interface_name_renumber_reply_t * mp)
903 vat_main_t *vam = &vat_main;
904 i32 retval = ntohl (mp->retval);
906 vam->retval = retval;
907 vam->regenerate_interface_table = 1;
908 vam->result_ready = 1;
911 static void vl_api_interface_name_renumber_reply_t_handler_json
912 (vl_api_interface_name_renumber_reply_t * mp)
914 vat_main_t *vam = &vat_main;
915 vat_json_node_t node;
917 vat_json_init_object (&node);
918 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
920 vat_json_print (vam->ofp, &node);
921 vat_json_free (&node);
923 vam->retval = ntohl (mp->retval);
924 vam->result_ready = 1;
928 * Special-case: build the interface table, maintain
929 * the next loopback sw_if_index vbl.
931 static void vl_api_sw_interface_details_t_handler
932 (vl_api_sw_interface_details_t * mp)
934 vat_main_t *vam = &vat_main;
935 u8 *s = format (0, "%s%c", mp->interface_name, 0);
937 hash_set_mem (vam->sw_if_index_by_interface_name, s,
938 ntohl (mp->sw_if_index));
940 /* In sub interface case, fill the sub interface table entry */
941 if (mp->sw_if_index != mp->sup_sw_if_index)
943 sw_interface_subif_t *sub = NULL;
945 vec_add2 (vam->sw_if_subif_table, sub, 1);
947 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
948 strncpy ((char *) sub->interface_name, (char *) s,
949 vec_len (sub->interface_name));
950 sub->sw_if_index = ntohl (mp->sw_if_index);
951 sub->sub_id = ntohl (mp->sub_id);
953 sub->sub_dot1ad = mp->sub_dot1ad;
954 sub->sub_number_of_tags = mp->sub_number_of_tags;
955 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
956 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
957 sub->sub_exact_match = mp->sub_exact_match;
958 sub->sub_default = mp->sub_default;
959 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
960 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
962 /* vlan tag rewrite */
963 sub->vtr_op = ntohl (mp->vtr_op);
964 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
965 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
966 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
970 static void vl_api_sw_interface_details_t_handler_json
971 (vl_api_sw_interface_details_t * mp)
973 vat_main_t *vam = &vat_main;
974 vat_json_node_t *node = NULL;
976 if (VAT_JSON_ARRAY != vam->json_tree.type)
978 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
979 vat_json_init_array (&vam->json_tree);
981 node = vat_json_array_add (&vam->json_tree);
983 vat_json_init_object (node);
984 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
985 vat_json_object_add_uint (node, "sup_sw_if_index",
986 ntohl (mp->sup_sw_if_index));
987 vat_json_object_add_uint (node, "l2_address_length",
988 ntohl (mp->l2_address_length));
989 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
990 sizeof (mp->l2_address));
991 vat_json_object_add_string_copy (node, "interface_name",
993 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
994 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
995 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
996 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
997 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
998 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
999 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
1000 vat_json_object_add_uint (node, "sub_number_of_tags",
1001 mp->sub_number_of_tags);
1002 vat_json_object_add_uint (node, "sub_outer_vlan_id",
1003 ntohs (mp->sub_outer_vlan_id));
1004 vat_json_object_add_uint (node, "sub_inner_vlan_id",
1005 ntohs (mp->sub_inner_vlan_id));
1006 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
1007 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
1008 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
1009 mp->sub_outer_vlan_id_any);
1010 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
1011 mp->sub_inner_vlan_id_any);
1012 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
1013 vat_json_object_add_uint (node, "vtr_push_dot1q",
1014 ntohl (mp->vtr_push_dot1q));
1015 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
1016 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
1019 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
1021 format_ethernet_address,
1023 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
1025 format_ethernet_address,
1027 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
1028 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
1032 #if VPP_API_TEST_BUILTIN == 0
1033 static void vl_api_sw_interface_event_t_handler
1034 (vl_api_sw_interface_event_t * mp)
1036 vat_main_t *vam = &vat_main;
1037 if (vam->interface_event_display)
1038 errmsg ("interface flags: sw_if_index %d %s %s",
1039 ntohl (mp->sw_if_index),
1040 mp->admin_up_down ? "admin-up" : "admin-down",
1041 mp->link_up_down ? "link-up" : "link-down");
1045 static void vl_api_sw_interface_event_t_handler_json
1046 (vl_api_sw_interface_event_t * mp)
1048 /* JSON output not supported */
1052 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
1054 vat_main_t *vam = &vat_main;
1055 i32 retval = ntohl (mp->retval);
1057 vam->retval = retval;
1058 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1059 vam->result_ready = 1;
1063 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1065 vat_main_t *vam = &vat_main;
1066 vat_json_node_t node;
1067 api_main_t *am = &api_main;
1071 vat_json_init_object (&node);
1072 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1073 vat_json_object_add_uint (&node, "reply_in_shmem",
1074 ntohl (mp->reply_in_shmem));
1075 /* Toss the shared-memory original... */
1076 pthread_mutex_lock (&am->vlib_rp->mutex);
1077 oldheap = svm_push_data_heap (am->vlib_rp);
1079 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1082 svm_pop_heap (oldheap);
1083 pthread_mutex_unlock (&am->vlib_rp->mutex);
1085 vat_json_print (vam->ofp, &node);
1086 vat_json_free (&node);
1088 vam->retval = ntohl (mp->retval);
1089 vam->result_ready = 1;
1093 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1095 vat_main_t *vam = &vat_main;
1096 i32 retval = ntohl (mp->retval);
1097 u32 length = ntohl (mp->length);
1099 vec_reset_length (vam->cmd_reply);
1101 vam->retval = retval;
1104 vec_validate (vam->cmd_reply, length);
1105 clib_memcpy ((char *) (vam->cmd_reply), mp->reply, length);
1106 vam->cmd_reply[length] = 0;
1108 vam->result_ready = 1;
1112 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1114 vat_main_t *vam = &vat_main;
1115 vat_json_node_t node;
1117 vec_reset_length (vam->cmd_reply);
1119 vat_json_init_object (&node);
1120 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1121 vat_json_object_add_string_copy (&node, "reply", mp->reply);
1123 vat_json_print (vam->ofp, &node);
1124 vat_json_free (&node);
1126 vam->retval = ntohl (mp->retval);
1127 vam->result_ready = 1;
1130 static void vl_api_classify_add_del_table_reply_t_handler
1131 (vl_api_classify_add_del_table_reply_t * mp)
1133 vat_main_t *vam = &vat_main;
1134 i32 retval = ntohl (mp->retval);
1135 if (vam->async_mode)
1137 vam->async_errors += (retval < 0);
1141 vam->retval = retval;
1143 ((mp->new_table_index != 0xFFFFFFFF) ||
1144 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1145 (mp->match_n_vectors != 0xFFFFFFFF)))
1147 * Note: this is just barely thread-safe, depends on
1148 * the main thread spinning waiting for an answer...
1150 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1151 ntohl (mp->new_table_index),
1152 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1153 vam->result_ready = 1;
1157 static void vl_api_classify_add_del_table_reply_t_handler_json
1158 (vl_api_classify_add_del_table_reply_t * mp)
1160 vat_main_t *vam = &vat_main;
1161 vat_json_node_t node;
1163 vat_json_init_object (&node);
1164 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1165 vat_json_object_add_uint (&node, "new_table_index",
1166 ntohl (mp->new_table_index));
1167 vat_json_object_add_uint (&node, "skip_n_vectors",
1168 ntohl (mp->skip_n_vectors));
1169 vat_json_object_add_uint (&node, "match_n_vectors",
1170 ntohl (mp->match_n_vectors));
1172 vat_json_print (vam->ofp, &node);
1173 vat_json_free (&node);
1175 vam->retval = ntohl (mp->retval);
1176 vam->result_ready = 1;
1179 static void vl_api_get_node_index_reply_t_handler
1180 (vl_api_get_node_index_reply_t * mp)
1182 vat_main_t *vam = &vat_main;
1183 i32 retval = ntohl (mp->retval);
1184 if (vam->async_mode)
1186 vam->async_errors += (retval < 0);
1190 vam->retval = retval;
1192 errmsg ("node index %d", ntohl (mp->node_index));
1193 vam->result_ready = 1;
1197 static void vl_api_get_node_index_reply_t_handler_json
1198 (vl_api_get_node_index_reply_t * mp)
1200 vat_main_t *vam = &vat_main;
1201 vat_json_node_t node;
1203 vat_json_init_object (&node);
1204 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1205 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1207 vat_json_print (vam->ofp, &node);
1208 vat_json_free (&node);
1210 vam->retval = ntohl (mp->retval);
1211 vam->result_ready = 1;
1214 static void vl_api_get_next_index_reply_t_handler
1215 (vl_api_get_next_index_reply_t * mp)
1217 vat_main_t *vam = &vat_main;
1218 i32 retval = ntohl (mp->retval);
1219 if (vam->async_mode)
1221 vam->async_errors += (retval < 0);
1225 vam->retval = retval;
1227 errmsg ("next node index %d", ntohl (mp->next_index));
1228 vam->result_ready = 1;
1232 static void vl_api_get_next_index_reply_t_handler_json
1233 (vl_api_get_next_index_reply_t * mp)
1235 vat_main_t *vam = &vat_main;
1236 vat_json_node_t node;
1238 vat_json_init_object (&node);
1239 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1240 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1242 vat_json_print (vam->ofp, &node);
1243 vat_json_free (&node);
1245 vam->retval = ntohl (mp->retval);
1246 vam->result_ready = 1;
1249 static void vl_api_add_node_next_reply_t_handler
1250 (vl_api_add_node_next_reply_t * mp)
1252 vat_main_t *vam = &vat_main;
1253 i32 retval = ntohl (mp->retval);
1254 if (vam->async_mode)
1256 vam->async_errors += (retval < 0);
1260 vam->retval = retval;
1262 errmsg ("next index %d", ntohl (mp->next_index));
1263 vam->result_ready = 1;
1267 static void vl_api_add_node_next_reply_t_handler_json
1268 (vl_api_add_node_next_reply_t * mp)
1270 vat_main_t *vam = &vat_main;
1271 vat_json_node_t node;
1273 vat_json_init_object (&node);
1274 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1275 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1277 vat_json_print (vam->ofp, &node);
1278 vat_json_free (&node);
1280 vam->retval = ntohl (mp->retval);
1281 vam->result_ready = 1;
1284 static void vl_api_show_version_reply_t_handler
1285 (vl_api_show_version_reply_t * mp)
1287 vat_main_t *vam = &vat_main;
1288 i32 retval = ntohl (mp->retval);
1292 errmsg (" program: %s", mp->program);
1293 errmsg (" version: %s", mp->version);
1294 errmsg (" build date: %s", mp->build_date);
1295 errmsg ("build directory: %s", mp->build_directory);
1297 vam->retval = retval;
1298 vam->result_ready = 1;
1301 static void vl_api_show_version_reply_t_handler_json
1302 (vl_api_show_version_reply_t * mp)
1304 vat_main_t *vam = &vat_main;
1305 vat_json_node_t node;
1307 vat_json_init_object (&node);
1308 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1309 vat_json_object_add_string_copy (&node, "program", mp->program);
1310 vat_json_object_add_string_copy (&node, "version", mp->version);
1311 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1312 vat_json_object_add_string_copy (&node, "build_directory",
1313 mp->build_directory);
1315 vat_json_print (vam->ofp, &node);
1316 vat_json_free (&node);
1318 vam->retval = ntohl (mp->retval);
1319 vam->result_ready = 1;
1323 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1325 u32 sw_if_index = ntohl (mp->sw_if_index);
1326 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1327 mp->mac_ip ? "mac/ip binding" : "address resolution",
1328 ntohl (mp->pid), format_ip4_address, &mp->address,
1329 format_ethernet_address, mp->new_mac, sw_if_index);
1333 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1335 /* JSON output not supported */
1339 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1341 u32 sw_if_index = ntohl (mp->sw_if_index);
1342 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1343 mp->mac_ip ? "mac/ip binding" : "address resolution",
1344 ntohl (mp->pid), format_ip6_address, mp->address,
1345 format_ethernet_address, mp->new_mac, sw_if_index);
1349 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1351 /* JSON output not supported */
1355 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1357 u32 n_macs = ntohl (mp->n_macs);
1358 errmsg ("L2MAC event recived with pid %d cl-idx %d for %d macs: \n",
1359 ntohl (mp->pid), mp->client_index, n_macs);
1361 for (i = 0; i < n_macs; i++)
1363 vl_api_mac_entry_t *mac = &mp->mac[i];
1364 errmsg (" [%d] sw_if_index %d mac_addr %U action %d \n",
1365 i + 1, ntohl (mac->sw_if_index),
1366 format_ethernet_address, mac->mac_addr, mac->action);
1373 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1375 /* JSON output not supported */
1378 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1379 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1382 * Special-case: build the bridge domain table, maintain
1383 * the next bd id vbl.
1385 static void vl_api_bridge_domain_details_t_handler
1386 (vl_api_bridge_domain_details_t * mp)
1388 vat_main_t *vam = &vat_main;
1389 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1392 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1393 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1395 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1396 ntohl (mp->bd_id), mp->learn, mp->forward,
1397 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1401 vl_api_bridge_domain_sw_if_t *sw_ifs;
1402 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1405 sw_ifs = mp->sw_if_details;
1406 for (i = 0; i < n_sw_ifs; i++)
1412 sw_if_index = ntohl (sw_ifs->sw_if_index);
1415 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1417 if ((u32) p->value[0] == sw_if_index)
1419 sw_if_name = (u8 *)(p->key);
1424 print (vam->ofp, "%7d %3d %s", sw_if_index,
1425 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1426 "sw_if_index not found!");
1433 static void vl_api_bridge_domain_details_t_handler_json
1434 (vl_api_bridge_domain_details_t * mp)
1436 vat_main_t *vam = &vat_main;
1437 vat_json_node_t *node, *array = NULL;
1438 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1440 if (VAT_JSON_ARRAY != vam->json_tree.type)
1442 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1443 vat_json_init_array (&vam->json_tree);
1445 node = vat_json_array_add (&vam->json_tree);
1447 vat_json_init_object (node);
1448 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1449 vat_json_object_add_uint (node, "flood", mp->flood);
1450 vat_json_object_add_uint (node, "forward", mp->forward);
1451 vat_json_object_add_uint (node, "learn", mp->learn);
1452 vat_json_object_add_uint (node, "bvi_sw_if_index",
1453 ntohl (mp->bvi_sw_if_index));
1454 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1455 array = vat_json_object_add (node, "sw_if");
1456 vat_json_init_array (array);
1462 vl_api_bridge_domain_sw_if_t *sw_ifs;
1465 sw_ifs = mp->sw_if_details;
1466 for (i = 0; i < n_sw_ifs; i++)
1468 node = vat_json_array_add (array);
1469 vat_json_init_object (node);
1470 vat_json_object_add_uint (node, "sw_if_index",
1471 ntohl (sw_ifs->sw_if_index));
1472 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1478 static void vl_api_control_ping_reply_t_handler
1479 (vl_api_control_ping_reply_t * mp)
1481 vat_main_t *vam = &vat_main;
1482 i32 retval = ntohl (mp->retval);
1483 if (vam->async_mode)
1485 vam->async_errors += (retval < 0);
1489 vam->retval = retval;
1490 vam->result_ready = 1;
1492 if (vam->socket_client_main)
1493 vam->socket_client_main->control_pings_outstanding--;
1496 static void vl_api_control_ping_reply_t_handler_json
1497 (vl_api_control_ping_reply_t * mp)
1499 vat_main_t *vam = &vat_main;
1500 i32 retval = ntohl (mp->retval);
1502 if (VAT_JSON_NONE != vam->json_tree.type)
1504 vat_json_print (vam->ofp, &vam->json_tree);
1505 vat_json_free (&vam->json_tree);
1506 vam->json_tree.type = VAT_JSON_NONE;
1511 vat_json_init_array (&vam->json_tree);
1512 vat_json_print (vam->ofp, &vam->json_tree);
1513 vam->json_tree.type = VAT_JSON_NONE;
1516 vam->retval = retval;
1517 vam->result_ready = 1;
1521 vl_api_bridge_domain_set_mac_age_reply_t_handler
1522 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1524 vat_main_t *vam = &vat_main;
1525 i32 retval = ntohl (mp->retval);
1526 if (vam->async_mode)
1528 vam->async_errors += (retval < 0);
1532 vam->retval = retval;
1533 vam->result_ready = 1;
1537 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1538 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1540 vat_main_t *vam = &vat_main;
1541 vat_json_node_t node;
1543 vat_json_init_object (&node);
1544 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1546 vat_json_print (vam->ofp, &node);
1547 vat_json_free (&node);
1549 vam->retval = ntohl (mp->retval);
1550 vam->result_ready = 1;
1554 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1556 vat_main_t *vam = &vat_main;
1557 i32 retval = ntohl (mp->retval);
1558 if (vam->async_mode)
1560 vam->async_errors += (retval < 0);
1564 vam->retval = retval;
1565 vam->result_ready = 1;
1569 static void vl_api_l2_flags_reply_t_handler_json
1570 (vl_api_l2_flags_reply_t * mp)
1572 vat_main_t *vam = &vat_main;
1573 vat_json_node_t node;
1575 vat_json_init_object (&node);
1576 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1577 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1578 ntohl (mp->resulting_feature_bitmap));
1580 vat_json_print (vam->ofp, &node);
1581 vat_json_free (&node);
1583 vam->retval = ntohl (mp->retval);
1584 vam->result_ready = 1;
1587 static void vl_api_bridge_flags_reply_t_handler
1588 (vl_api_bridge_flags_reply_t * mp)
1590 vat_main_t *vam = &vat_main;
1591 i32 retval = ntohl (mp->retval);
1592 if (vam->async_mode)
1594 vam->async_errors += (retval < 0);
1598 vam->retval = retval;
1599 vam->result_ready = 1;
1603 static void vl_api_bridge_flags_reply_t_handler_json
1604 (vl_api_bridge_flags_reply_t * mp)
1606 vat_main_t *vam = &vat_main;
1607 vat_json_node_t node;
1609 vat_json_init_object (&node);
1610 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1611 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1612 ntohl (mp->resulting_feature_bitmap));
1614 vat_json_print (vam->ofp, &node);
1615 vat_json_free (&node);
1617 vam->retval = ntohl (mp->retval);
1618 vam->result_ready = 1;
1621 static void vl_api_tap_connect_reply_t_handler
1622 (vl_api_tap_connect_reply_t * mp)
1624 vat_main_t *vam = &vat_main;
1625 i32 retval = ntohl (mp->retval);
1626 if (vam->async_mode)
1628 vam->async_errors += (retval < 0);
1632 vam->retval = retval;
1633 vam->sw_if_index = ntohl (mp->sw_if_index);
1634 vam->result_ready = 1;
1639 static void vl_api_tap_connect_reply_t_handler_json
1640 (vl_api_tap_connect_reply_t * mp)
1642 vat_main_t *vam = &vat_main;
1643 vat_json_node_t node;
1645 vat_json_init_object (&node);
1646 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1647 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1649 vat_json_print (vam->ofp, &node);
1650 vat_json_free (&node);
1652 vam->retval = ntohl (mp->retval);
1653 vam->result_ready = 1;
1658 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1660 vat_main_t *vam = &vat_main;
1661 i32 retval = ntohl (mp->retval);
1662 if (vam->async_mode)
1664 vam->async_errors += (retval < 0);
1668 vam->retval = retval;
1669 vam->sw_if_index = ntohl (mp->sw_if_index);
1670 vam->result_ready = 1;
1674 static void vl_api_tap_modify_reply_t_handler_json
1675 (vl_api_tap_modify_reply_t * mp)
1677 vat_main_t *vam = &vat_main;
1678 vat_json_node_t node;
1680 vat_json_init_object (&node);
1681 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1682 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1684 vat_json_print (vam->ofp, &node);
1685 vat_json_free (&node);
1687 vam->retval = ntohl (mp->retval);
1688 vam->result_ready = 1;
1692 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1694 vat_main_t *vam = &vat_main;
1695 i32 retval = ntohl (mp->retval);
1696 if (vam->async_mode)
1698 vam->async_errors += (retval < 0);
1702 vam->retval = retval;
1703 vam->result_ready = 1;
1707 static void vl_api_tap_delete_reply_t_handler_json
1708 (vl_api_tap_delete_reply_t * mp)
1710 vat_main_t *vam = &vat_main;
1711 vat_json_node_t node;
1713 vat_json_init_object (&node);
1714 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1716 vat_json_print (vam->ofp, &node);
1717 vat_json_free (&node);
1719 vam->retval = ntohl (mp->retval);
1720 vam->result_ready = 1;
1724 vl_api_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_reply_t * mp)
1726 vat_main_t *vam = &vat_main;
1727 i32 retval = ntohl (mp->retval);
1728 if (vam->async_mode)
1730 vam->async_errors += (retval < 0);
1734 vam->retval = retval;
1735 vam->sw_if_index = ntohl (mp->sw_if_index);
1736 vam->result_ready = 1;
1741 static void vl_api_tap_create_v2_reply_t_handler_json
1742 (vl_api_tap_create_v2_reply_t * mp)
1744 vat_main_t *vam = &vat_main;
1745 vat_json_node_t node;
1747 vat_json_init_object (&node);
1748 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1749 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1751 vat_json_print (vam->ofp, &node);
1752 vat_json_free (&node);
1754 vam->retval = ntohl (mp->retval);
1755 vam->result_ready = 1;
1760 vl_api_tap_delete_v2_reply_t_handler (vl_api_tap_delete_v2_reply_t * mp)
1762 vat_main_t *vam = &vat_main;
1763 i32 retval = ntohl (mp->retval);
1764 if (vam->async_mode)
1766 vam->async_errors += (retval < 0);
1770 vam->retval = retval;
1771 vam->result_ready = 1;
1775 static void vl_api_tap_delete_v2_reply_t_handler_json
1776 (vl_api_tap_delete_v2_reply_t * mp)
1778 vat_main_t *vam = &vat_main;
1779 vat_json_node_t node;
1781 vat_json_init_object (&node);
1782 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1784 vat_json_print (vam->ofp, &node);
1785 vat_json_free (&node);
1787 vam->retval = ntohl (mp->retval);
1788 vam->result_ready = 1;
1792 vl_api_bond_create_reply_t_handler (vl_api_bond_create_reply_t * mp)
1794 vat_main_t *vam = &vat_main;
1795 i32 retval = ntohl (mp->retval);
1797 if (vam->async_mode)
1799 vam->async_errors += (retval < 0);
1803 vam->retval = retval;
1804 vam->sw_if_index = ntohl (mp->sw_if_index);
1805 vam->result_ready = 1;
1809 static void vl_api_bond_create_reply_t_handler_json
1810 (vl_api_bond_create_reply_t * mp)
1812 vat_main_t *vam = &vat_main;
1813 vat_json_node_t node;
1815 vat_json_init_object (&node);
1816 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1817 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1819 vat_json_print (vam->ofp, &node);
1820 vat_json_free (&node);
1822 vam->retval = ntohl (mp->retval);
1823 vam->result_ready = 1;
1827 vl_api_bond_delete_reply_t_handler (vl_api_bond_delete_reply_t * mp)
1829 vat_main_t *vam = &vat_main;
1830 i32 retval = ntohl (mp->retval);
1832 if (vam->async_mode)
1834 vam->async_errors += (retval < 0);
1838 vam->retval = retval;
1839 vam->result_ready = 1;
1843 static void vl_api_bond_delete_reply_t_handler_json
1844 (vl_api_bond_delete_reply_t * mp)
1846 vat_main_t *vam = &vat_main;
1847 vat_json_node_t node;
1849 vat_json_init_object (&node);
1850 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1852 vat_json_print (vam->ofp, &node);
1853 vat_json_free (&node);
1855 vam->retval = ntohl (mp->retval);
1856 vam->result_ready = 1;
1860 vl_api_bond_enslave_reply_t_handler (vl_api_bond_enslave_reply_t * mp)
1862 vat_main_t *vam = &vat_main;
1863 i32 retval = ntohl (mp->retval);
1865 if (vam->async_mode)
1867 vam->async_errors += (retval < 0);
1871 vam->retval = retval;
1872 vam->result_ready = 1;
1876 static void vl_api_bond_enslave_reply_t_handler_json
1877 (vl_api_bond_enslave_reply_t * mp)
1879 vat_main_t *vam = &vat_main;
1880 vat_json_node_t node;
1882 vat_json_init_object (&node);
1883 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1885 vat_json_print (vam->ofp, &node);
1886 vat_json_free (&node);
1888 vam->retval = ntohl (mp->retval);
1889 vam->result_ready = 1;
1893 vl_api_bond_detach_slave_reply_t_handler (vl_api_bond_detach_slave_reply_t *
1896 vat_main_t *vam = &vat_main;
1897 i32 retval = ntohl (mp->retval);
1899 if (vam->async_mode)
1901 vam->async_errors += (retval < 0);
1905 vam->retval = retval;
1906 vam->result_ready = 1;
1910 static void vl_api_bond_detach_slave_reply_t_handler_json
1911 (vl_api_bond_detach_slave_reply_t * mp)
1913 vat_main_t *vam = &vat_main;
1914 vat_json_node_t node;
1916 vat_json_init_object (&node);
1917 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1919 vat_json_print (vam->ofp, &node);
1920 vat_json_free (&node);
1922 vam->retval = ntohl (mp->retval);
1923 vam->result_ready = 1;
1926 static void vl_api_sw_interface_bond_details_t_handler
1927 (vl_api_sw_interface_bond_details_t * mp)
1929 vat_main_t *vam = &vat_main;
1932 "%-16s %-12d %-12U %-13U %-14u %-14u",
1933 mp->interface_name, ntohl (mp->sw_if_index),
1934 format_bond_mode, mp->mode, format_bond_load_balance, mp->lb,
1935 ntohl (mp->active_slaves), ntohl (mp->slaves));
1938 static void vl_api_sw_interface_bond_details_t_handler_json
1939 (vl_api_sw_interface_bond_details_t * mp)
1941 vat_main_t *vam = &vat_main;
1942 vat_json_node_t *node = NULL;
1944 if (VAT_JSON_ARRAY != vam->json_tree.type)
1946 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1947 vat_json_init_array (&vam->json_tree);
1949 node = vat_json_array_add (&vam->json_tree);
1951 vat_json_init_object (node);
1952 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1953 vat_json_object_add_string_copy (node, "interface_name",
1954 mp->interface_name);
1955 vat_json_object_add_uint (node, "mode", mp->mode);
1956 vat_json_object_add_uint (node, "load_balance", mp->lb);
1957 vat_json_object_add_uint (node, "active_slaves", ntohl (mp->active_slaves));
1958 vat_json_object_add_uint (node, "slaves", ntohl (mp->slaves));
1962 api_sw_interface_bond_dump (vat_main_t * vam)
1964 vl_api_sw_interface_bond_dump_t *mp;
1965 vl_api_control_ping_t *mp_ping;
1969 "\n%-16s %-12s %-12s %-13s %-14s %-14s",
1970 "interface name", "sw_if_index", "mode", "load balance",
1971 "active slaves", "slaves");
1973 /* Get list of bond interfaces */
1974 M (SW_INTERFACE_BOND_DUMP, mp);
1977 /* Use a control ping for synchronization */
1978 MPING (CONTROL_PING, mp_ping);
1985 static void vl_api_sw_interface_slave_details_t_handler
1986 (vl_api_sw_interface_slave_details_t * mp)
1988 vat_main_t *vam = &vat_main;
1991 "%-25s %-12d %-12d %d", mp->interface_name,
1992 ntohl (mp->sw_if_index), mp->is_passive, mp->is_long_timeout);
1995 static void vl_api_sw_interface_slave_details_t_handler_json
1996 (vl_api_sw_interface_slave_details_t * mp)
1998 vat_main_t *vam = &vat_main;
1999 vat_json_node_t *node = NULL;
2001 if (VAT_JSON_ARRAY != vam->json_tree.type)
2003 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2004 vat_json_init_array (&vam->json_tree);
2006 node = vat_json_array_add (&vam->json_tree);
2008 vat_json_init_object (node);
2009 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2010 vat_json_object_add_string_copy (node, "interface_name",
2011 mp->interface_name);
2012 vat_json_object_add_uint (node, "passive", mp->is_passive);
2013 vat_json_object_add_uint (node, "long_timeout", mp->is_long_timeout);
2017 api_sw_interface_slave_dump (vat_main_t * vam)
2019 unformat_input_t *i = vam->input;
2020 vl_api_sw_interface_slave_dump_t *mp;
2021 vl_api_control_ping_t *mp_ping;
2022 u32 sw_if_index = ~0;
2023 u8 sw_if_index_set = 0;
2026 /* Parse args required to build the message */
2027 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2029 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2030 sw_if_index_set = 1;
2031 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2032 sw_if_index_set = 1;
2037 if (sw_if_index_set == 0)
2039 errmsg ("missing vpp interface name. ");
2044 "\n%-25s %-12s %-12s %s",
2045 "slave interface name", "sw_if_index", "passive", "long_timeout");
2047 /* Get list of bond interfaces */
2048 M (SW_INTERFACE_SLAVE_DUMP, mp);
2049 mp->sw_if_index = ntohl (sw_if_index);
2052 /* Use a control ping for synchronization */
2053 MPING (CONTROL_PING, mp_ping);
2060 static void vl_api_mpls_tunnel_add_del_reply_t_handler
2061 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2063 vat_main_t *vam = &vat_main;
2064 i32 retval = ntohl (mp->retval);
2065 if (vam->async_mode)
2067 vam->async_errors += (retval < 0);
2071 vam->retval = retval;
2072 vam->result_ready = 1;
2076 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
2077 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2079 vat_main_t *vam = &vat_main;
2080 vat_json_node_t node;
2082 vat_json_init_object (&node);
2083 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2084 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
2085 ntohl (mp->sw_if_index));
2087 vat_json_print (vam->ofp, &node);
2088 vat_json_free (&node);
2090 vam->retval = ntohl (mp->retval);
2091 vam->result_ready = 1;
2094 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
2095 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2097 vat_main_t *vam = &vat_main;
2098 i32 retval = ntohl (mp->retval);
2099 if (vam->async_mode)
2101 vam->async_errors += (retval < 0);
2105 vam->retval = retval;
2106 vam->sw_if_index = ntohl (mp->sw_if_index);
2107 vam->result_ready = 1;
2111 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
2112 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2114 vat_main_t *vam = &vat_main;
2115 vat_json_node_t node;
2117 vat_json_init_object (&node);
2118 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2119 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2121 vat_json_print (vam->ofp, &node);
2122 vat_json_free (&node);
2124 vam->retval = ntohl (mp->retval);
2125 vam->result_ready = 1;
2128 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
2129 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2131 vat_main_t *vam = &vat_main;
2132 i32 retval = ntohl (mp->retval);
2133 if (vam->async_mode)
2135 vam->async_errors += (retval < 0);
2139 vam->retval = retval;
2140 vam->result_ready = 1;
2144 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
2145 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2147 vat_main_t *vam = &vat_main;
2148 vat_json_node_t node;
2150 vat_json_init_object (&node);
2151 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2152 vat_json_object_add_uint (&node, "fwd_entry_index",
2153 clib_net_to_host_u32 (mp->fwd_entry_index));
2155 vat_json_print (vam->ofp, &node);
2156 vat_json_free (&node);
2158 vam->retval = ntohl (mp->retval);
2159 vam->result_ready = 1;
2163 format_lisp_transport_protocol (u8 * s, va_list * args)
2165 u32 proto = va_arg (*args, u32);
2170 return format (s, "udp");
2172 return format (s, "api");
2179 static void vl_api_one_get_transport_protocol_reply_t_handler
2180 (vl_api_one_get_transport_protocol_reply_t * mp)
2182 vat_main_t *vam = &vat_main;
2183 i32 retval = ntohl (mp->retval);
2184 if (vam->async_mode)
2186 vam->async_errors += (retval < 0);
2190 u32 proto = mp->protocol;
2191 print (vam->ofp, "Transport protocol: %U",
2192 format_lisp_transport_protocol, proto);
2193 vam->retval = retval;
2194 vam->result_ready = 1;
2198 static void vl_api_one_get_transport_protocol_reply_t_handler_json
2199 (vl_api_one_get_transport_protocol_reply_t * mp)
2201 vat_main_t *vam = &vat_main;
2202 vat_json_node_t node;
2205 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
2208 vat_json_init_object (&node);
2209 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2210 vat_json_object_add_string_copy (&node, "transport-protocol", s);
2213 vat_json_print (vam->ofp, &node);
2214 vat_json_free (&node);
2216 vam->retval = ntohl (mp->retval);
2217 vam->result_ready = 1;
2220 static void vl_api_one_add_del_locator_set_reply_t_handler
2221 (vl_api_one_add_del_locator_set_reply_t * mp)
2223 vat_main_t *vam = &vat_main;
2224 i32 retval = ntohl (mp->retval);
2225 if (vam->async_mode)
2227 vam->async_errors += (retval < 0);
2231 vam->retval = retval;
2232 vam->result_ready = 1;
2236 static void vl_api_one_add_del_locator_set_reply_t_handler_json
2237 (vl_api_one_add_del_locator_set_reply_t * mp)
2239 vat_main_t *vam = &vat_main;
2240 vat_json_node_t node;
2242 vat_json_init_object (&node);
2243 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2244 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
2246 vat_json_print (vam->ofp, &node);
2247 vat_json_free (&node);
2249 vam->retval = ntohl (mp->retval);
2250 vam->result_ready = 1;
2253 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
2254 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2256 vat_main_t *vam = &vat_main;
2257 i32 retval = ntohl (mp->retval);
2258 if (vam->async_mode)
2260 vam->async_errors += (retval < 0);
2264 vam->retval = retval;
2265 vam->sw_if_index = ntohl (mp->sw_if_index);
2266 vam->result_ready = 1;
2268 vam->regenerate_interface_table = 1;
2271 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
2272 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2274 vat_main_t *vam = &vat_main;
2275 vat_json_node_t node;
2277 vat_json_init_object (&node);
2278 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2279 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2281 vat_json_print (vam->ofp, &node);
2282 vat_json_free (&node);
2284 vam->retval = ntohl (mp->retval);
2285 vam->result_ready = 1;
2288 static void vl_api_vxlan_offload_rx_reply_t_handler
2289 (vl_api_vxlan_offload_rx_reply_t * mp)
2291 vat_main_t *vam = &vat_main;
2292 i32 retval = ntohl (mp->retval);
2293 if (vam->async_mode)
2295 vam->async_errors += (retval < 0);
2299 vam->retval = retval;
2300 vam->result_ready = 1;
2304 static void vl_api_vxlan_offload_rx_reply_t_handler_json
2305 (vl_api_vxlan_offload_rx_reply_t * mp)
2307 vat_main_t *vam = &vat_main;
2308 vat_json_node_t node;
2310 vat_json_init_object (&node);
2311 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2313 vat_json_print (vam->ofp, &node);
2314 vat_json_free (&node);
2316 vam->retval = ntohl (mp->retval);
2317 vam->result_ready = 1;
2320 static void vl_api_geneve_add_del_tunnel_reply_t_handler
2321 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2323 vat_main_t *vam = &vat_main;
2324 i32 retval = ntohl (mp->retval);
2325 if (vam->async_mode)
2327 vam->async_errors += (retval < 0);
2331 vam->retval = retval;
2332 vam->sw_if_index = ntohl (mp->sw_if_index);
2333 vam->result_ready = 1;
2337 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
2338 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2340 vat_main_t *vam = &vat_main;
2341 vat_json_node_t node;
2343 vat_json_init_object (&node);
2344 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2345 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2347 vat_json_print (vam->ofp, &node);
2348 vat_json_free (&node);
2350 vam->retval = ntohl (mp->retval);
2351 vam->result_ready = 1;
2354 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
2355 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2357 vat_main_t *vam = &vat_main;
2358 i32 retval = ntohl (mp->retval);
2359 if (vam->async_mode)
2361 vam->async_errors += (retval < 0);
2365 vam->retval = retval;
2366 vam->sw_if_index = ntohl (mp->sw_if_index);
2367 vam->result_ready = 1;
2369 vam->regenerate_interface_table = 1;
2372 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
2373 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2375 vat_main_t *vam = &vat_main;
2376 vat_json_node_t node;
2378 vat_json_init_object (&node);
2379 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2380 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2382 vat_json_print (vam->ofp, &node);
2383 vat_json_free (&node);
2385 vam->retval = ntohl (mp->retval);
2386 vam->result_ready = 1;
2389 static void vl_api_gre_add_del_tunnel_reply_t_handler
2390 (vl_api_gre_add_del_tunnel_reply_t * mp)
2392 vat_main_t *vam = &vat_main;
2393 i32 retval = ntohl (mp->retval);
2394 if (vam->async_mode)
2396 vam->async_errors += (retval < 0);
2400 vam->retval = retval;
2401 vam->sw_if_index = ntohl (mp->sw_if_index);
2402 vam->result_ready = 1;
2406 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
2407 (vl_api_gre_add_del_tunnel_reply_t * mp)
2409 vat_main_t *vam = &vat_main;
2410 vat_json_node_t node;
2412 vat_json_init_object (&node);
2413 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2414 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2416 vat_json_print (vam->ofp, &node);
2417 vat_json_free (&node);
2419 vam->retval = ntohl (mp->retval);
2420 vam->result_ready = 1;
2423 static void vl_api_create_vhost_user_if_reply_t_handler
2424 (vl_api_create_vhost_user_if_reply_t * mp)
2426 vat_main_t *vam = &vat_main;
2427 i32 retval = ntohl (mp->retval);
2428 if (vam->async_mode)
2430 vam->async_errors += (retval < 0);
2434 vam->retval = retval;
2435 vam->sw_if_index = ntohl (mp->sw_if_index);
2436 vam->result_ready = 1;
2438 vam->regenerate_interface_table = 1;
2441 static void vl_api_create_vhost_user_if_reply_t_handler_json
2442 (vl_api_create_vhost_user_if_reply_t * mp)
2444 vat_main_t *vam = &vat_main;
2445 vat_json_node_t node;
2447 vat_json_init_object (&node);
2448 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2449 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2451 vat_json_print (vam->ofp, &node);
2452 vat_json_free (&node);
2454 vam->retval = ntohl (mp->retval);
2455 vam->result_ready = 1;
2458 static void vl_api_dns_resolve_name_reply_t_handler
2459 (vl_api_dns_resolve_name_reply_t * mp)
2461 vat_main_t *vam = &vat_main;
2462 i32 retval = ntohl (mp->retval);
2463 if (vam->async_mode)
2465 vam->async_errors += (retval < 0);
2469 vam->retval = retval;
2470 vam->result_ready = 1;
2475 clib_warning ("ip4 address %U", format_ip4_address,
2476 (ip4_address_t *) mp->ip4_address);
2478 clib_warning ("ip6 address %U", format_ip6_address,
2479 (ip6_address_t *) mp->ip6_address);
2482 clib_warning ("retval %d", retval);
2486 static void vl_api_dns_resolve_name_reply_t_handler_json
2487 (vl_api_dns_resolve_name_reply_t * mp)
2489 clib_warning ("not implemented");
2492 static void vl_api_dns_resolve_ip_reply_t_handler
2493 (vl_api_dns_resolve_ip_reply_t * mp)
2495 vat_main_t *vam = &vat_main;
2496 i32 retval = ntohl (mp->retval);
2497 if (vam->async_mode)
2499 vam->async_errors += (retval < 0);
2503 vam->retval = retval;
2504 vam->result_ready = 1;
2508 clib_warning ("canonical name %s", mp->name);
2511 clib_warning ("retval %d", retval);
2515 static void vl_api_dns_resolve_ip_reply_t_handler_json
2516 (vl_api_dns_resolve_ip_reply_t * mp)
2518 clib_warning ("not implemented");
2522 static void vl_api_ip_address_details_t_handler
2523 (vl_api_ip_address_details_t * mp)
2525 vat_main_t *vam = &vat_main;
2526 static ip_address_details_t empty_ip_address_details = { {0} };
2527 ip_address_details_t *address = NULL;
2528 ip_details_t *current_ip_details = NULL;
2529 ip_details_t *details = NULL;
2531 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2533 if (!details || vam->current_sw_if_index >= vec_len (details)
2534 || !details[vam->current_sw_if_index].present)
2536 errmsg ("ip address details arrived but not stored");
2537 errmsg ("ip_dump should be called first");
2541 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2543 #define addresses (current_ip_details->addr)
2545 vec_validate_init_empty (addresses, vec_len (addresses),
2546 empty_ip_address_details);
2548 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2550 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
2551 address->prefix_length = mp->prefix_length;
2555 static void vl_api_ip_address_details_t_handler_json
2556 (vl_api_ip_address_details_t * mp)
2558 vat_main_t *vam = &vat_main;
2559 vat_json_node_t *node = NULL;
2560 struct in6_addr ip6;
2563 if (VAT_JSON_ARRAY != vam->json_tree.type)
2565 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2566 vat_json_init_array (&vam->json_tree);
2568 node = vat_json_array_add (&vam->json_tree);
2570 vat_json_init_object (node);
2573 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
2574 vat_json_object_add_ip6 (node, "ip", ip6);
2578 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
2579 vat_json_object_add_ip4 (node, "ip", ip4);
2581 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
2585 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2587 vat_main_t *vam = &vat_main;
2588 static ip_details_t empty_ip_details = { 0 };
2589 ip_details_t *ip = NULL;
2590 u32 sw_if_index = ~0;
2592 sw_if_index = ntohl (mp->sw_if_index);
2594 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2595 sw_if_index, empty_ip_details);
2597 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2604 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2606 vat_main_t *vam = &vat_main;
2608 if (VAT_JSON_ARRAY != vam->json_tree.type)
2610 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2611 vat_json_init_array (&vam->json_tree);
2613 vat_json_array_add_uint (&vam->json_tree,
2614 clib_net_to_host_u32 (mp->sw_if_index));
2618 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2620 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2621 "router_addr %U host_mac %U",
2622 ntohl (mp->pid), mp->lease.is_ipv6 ? "ipv6" : "ipv4",
2624 format_ip4_address, &mp->lease.host_address,
2625 format_ip4_address, &mp->lease.router_address,
2626 format_ethernet_address, mp->lease.host_mac);
2629 static void vl_api_dhcp_compl_event_t_handler_json
2630 (vl_api_dhcp_compl_event_t * mp)
2632 /* JSON output not supported */
2636 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2639 vat_main_t *vam = &vat_main;
2640 static u64 default_counter = 0;
2642 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2644 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2645 sw_if_index, default_counter);
2646 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2650 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2651 interface_counter_t counter)
2653 vat_main_t *vam = &vat_main;
2654 static interface_counter_t default_counter = { 0, };
2656 vec_validate_init_empty (vam->combined_interface_counters,
2657 vnet_counter_type, NULL);
2658 vec_validate_init_empty (vam->combined_interface_counters
2659 [vnet_counter_type], sw_if_index, default_counter);
2660 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2663 static void vl_api_vnet_interface_simple_counters_t_handler
2664 (vl_api_vnet_interface_simple_counters_t * mp)
2669 static void vl_api_vnet_interface_combined_counters_t_handler
2670 (vl_api_vnet_interface_combined_counters_t * mp)
2675 static void vl_api_vnet_interface_simple_counters_t_handler_json
2676 (vl_api_vnet_interface_simple_counters_t * mp)
2681 u32 first_sw_if_index;
2684 count = ntohl (mp->count);
2685 first_sw_if_index = ntohl (mp->first_sw_if_index);
2687 v_packets = (u64 *) & mp->data;
2688 for (i = 0; i < count; i++)
2690 packets = clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2691 set_simple_interface_counter (mp->vnet_counter_type,
2692 first_sw_if_index + i, packets);
2697 static void vl_api_vnet_interface_combined_counters_t_handler_json
2698 (vl_api_vnet_interface_combined_counters_t * mp)
2700 interface_counter_t counter;
2702 u32 first_sw_if_index;
2706 count = ntohl (mp->count);
2707 first_sw_if_index = ntohl (mp->first_sw_if_index);
2709 v = (vlib_counter_t *) & mp->data;
2710 for (i = 0; i < count; i++)
2713 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2715 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2716 set_combined_interface_counter (mp->vnet_counter_type,
2717 first_sw_if_index + i, counter);
2723 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2725 vat_main_t *vam = &vat_main;
2728 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2730 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2739 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2741 vat_main_t *vam = &vat_main;
2744 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2746 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2754 static void vl_api_vnet_ip4_fib_counters_t_handler
2755 (vl_api_vnet_ip4_fib_counters_t * mp)
2760 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2761 (vl_api_vnet_ip4_fib_counters_t * mp)
2763 vat_main_t *vam = &vat_main;
2764 vl_api_ip4_fib_counter_t *v;
2765 ip4_fib_counter_t *counter;
2772 vrf_id = ntohl (mp->vrf_id);
2773 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2774 if (~0 == vrf_index)
2776 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2777 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2778 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2779 vec_validate (vam->ip4_fib_counters, vrf_index);
2780 vam->ip4_fib_counters[vrf_index] = NULL;
2783 vec_free (vam->ip4_fib_counters[vrf_index]);
2784 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2785 count = ntohl (mp->count);
2786 for (i = 0; i < count; i++)
2788 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2789 counter = &vam->ip4_fib_counters[vrf_index][i];
2790 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2791 counter->address = ip4;
2792 counter->address_length = v->address_length;
2793 counter->packets = clib_net_to_host_u64 (v->packets);
2794 counter->bytes = clib_net_to_host_u64 (v->bytes);
2799 static void vl_api_vnet_ip4_nbr_counters_t_handler
2800 (vl_api_vnet_ip4_nbr_counters_t * mp)
2805 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2806 (vl_api_vnet_ip4_nbr_counters_t * mp)
2808 vat_main_t *vam = &vat_main;
2809 vl_api_ip4_nbr_counter_t *v;
2810 ip4_nbr_counter_t *counter;
2815 sw_if_index = ntohl (mp->sw_if_index);
2816 count = ntohl (mp->count);
2817 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2820 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2822 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2823 for (i = 0; i < count; i++)
2825 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2826 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2827 counter->address.s_addr = v->address;
2828 counter->packets = clib_net_to_host_u64 (v->packets);
2829 counter->bytes = clib_net_to_host_u64 (v->bytes);
2830 counter->linkt = v->link_type;
2835 static void vl_api_vnet_ip6_fib_counters_t_handler
2836 (vl_api_vnet_ip6_fib_counters_t * mp)
2841 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2842 (vl_api_vnet_ip6_fib_counters_t * mp)
2844 vat_main_t *vam = &vat_main;
2845 vl_api_ip6_fib_counter_t *v;
2846 ip6_fib_counter_t *counter;
2847 struct in6_addr ip6;
2853 vrf_id = ntohl (mp->vrf_id);
2854 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2855 if (~0 == vrf_index)
2857 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2858 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2859 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2860 vec_validate (vam->ip6_fib_counters, vrf_index);
2861 vam->ip6_fib_counters[vrf_index] = NULL;
2864 vec_free (vam->ip6_fib_counters[vrf_index]);
2865 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2866 count = ntohl (mp->count);
2867 for (i = 0; i < count; i++)
2869 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2870 counter = &vam->ip6_fib_counters[vrf_index][i];
2871 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2872 counter->address = ip6;
2873 counter->address_length = v->address_length;
2874 counter->packets = clib_net_to_host_u64 (v->packets);
2875 counter->bytes = clib_net_to_host_u64 (v->bytes);
2880 static void vl_api_vnet_ip6_nbr_counters_t_handler
2881 (vl_api_vnet_ip6_nbr_counters_t * mp)
2886 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2887 (vl_api_vnet_ip6_nbr_counters_t * mp)
2889 vat_main_t *vam = &vat_main;
2890 vl_api_ip6_nbr_counter_t *v;
2891 ip6_nbr_counter_t *counter;
2892 struct in6_addr ip6;
2897 sw_if_index = ntohl (mp->sw_if_index);
2898 count = ntohl (mp->count);
2899 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2902 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2904 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2905 for (i = 0; i < count; i++)
2907 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2908 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2909 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2910 counter->address = ip6;
2911 counter->packets = clib_net_to_host_u64 (v->packets);
2912 counter->bytes = clib_net_to_host_u64 (v->bytes);
2917 static void vl_api_get_first_msg_id_reply_t_handler
2918 (vl_api_get_first_msg_id_reply_t * mp)
2920 vat_main_t *vam = &vat_main;
2921 i32 retval = ntohl (mp->retval);
2923 if (vam->async_mode)
2925 vam->async_errors += (retval < 0);
2929 vam->retval = retval;
2930 vam->result_ready = 1;
2934 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2938 static void vl_api_get_first_msg_id_reply_t_handler_json
2939 (vl_api_get_first_msg_id_reply_t * mp)
2941 vat_main_t *vam = &vat_main;
2942 vat_json_node_t node;
2944 vat_json_init_object (&node);
2945 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2946 vat_json_object_add_uint (&node, "first_msg_id",
2947 (uint) ntohs (mp->first_msg_id));
2949 vat_json_print (vam->ofp, &node);
2950 vat_json_free (&node);
2952 vam->retval = ntohl (mp->retval);
2953 vam->result_ready = 1;
2956 static void vl_api_get_node_graph_reply_t_handler
2957 (vl_api_get_node_graph_reply_t * mp)
2959 vat_main_t *vam = &vat_main;
2960 api_main_t *am = &api_main;
2961 i32 retval = ntohl (mp->retval);
2962 u8 *pvt_copy, *reply;
2967 if (vam->async_mode)
2969 vam->async_errors += (retval < 0);
2973 vam->retval = retval;
2974 vam->result_ready = 1;
2977 /* "Should never happen..." */
2981 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2982 pvt_copy = vec_dup (reply);
2984 /* Toss the shared-memory original... */
2985 pthread_mutex_lock (&am->vlib_rp->mutex);
2986 oldheap = svm_push_data_heap (am->vlib_rp);
2990 svm_pop_heap (oldheap);
2991 pthread_mutex_unlock (&am->vlib_rp->mutex);
2993 if (vam->graph_nodes)
2995 hash_free (vam->graph_node_index_by_name);
2997 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2999 node = vam->graph_nodes[0][i];
3000 vec_free (node->name);
3001 vec_free (node->next_nodes);
3004 vec_free (vam->graph_nodes[0]);
3005 vec_free (vam->graph_nodes);
3008 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
3009 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
3010 vec_free (pvt_copy);
3012 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
3014 node = vam->graph_nodes[0][i];
3015 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
3019 static void vl_api_get_node_graph_reply_t_handler_json
3020 (vl_api_get_node_graph_reply_t * mp)
3022 vat_main_t *vam = &vat_main;
3023 api_main_t *am = &api_main;
3025 vat_json_node_t node;
3028 /* $$$$ make this real? */
3029 vat_json_init_object (&node);
3030 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3031 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
3033 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
3035 /* Toss the shared-memory original... */
3036 pthread_mutex_lock (&am->vlib_rp->mutex);
3037 oldheap = svm_push_data_heap (am->vlib_rp);
3041 svm_pop_heap (oldheap);
3042 pthread_mutex_unlock (&am->vlib_rp->mutex);
3044 vat_json_print (vam->ofp, &node);
3045 vat_json_free (&node);
3047 vam->retval = ntohl (mp->retval);
3048 vam->result_ready = 1;
3052 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
3054 vat_main_t *vam = &vat_main;
3059 s = format (s, "%=16d%=16d%=16d",
3060 ntohl (mp->sw_if_index), mp->priority, mp->weight);
3064 s = format (s, "%=16U%=16d%=16d",
3065 mp->is_ipv6 ? format_ip6_address :
3067 mp->ip_address, mp->priority, mp->weight);
3070 print (vam->ofp, "%v", s);
3075 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
3077 vat_main_t *vam = &vat_main;
3078 vat_json_node_t *node = NULL;
3079 struct in6_addr ip6;
3082 if (VAT_JSON_ARRAY != vam->json_tree.type)
3084 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3085 vat_json_init_array (&vam->json_tree);
3087 node = vat_json_array_add (&vam->json_tree);
3088 vat_json_init_object (node);
3090 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
3091 vat_json_object_add_uint (node, "priority", mp->priority);
3092 vat_json_object_add_uint (node, "weight", mp->weight);
3095 vat_json_object_add_uint (node, "sw_if_index",
3096 clib_net_to_host_u32 (mp->sw_if_index));
3101 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3102 vat_json_object_add_ip6 (node, "address", ip6);
3106 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3107 vat_json_object_add_ip4 (node, "address", ip4);
3113 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
3116 vat_main_t *vam = &vat_main;
3119 ls_name = format (0, "%s", mp->ls_name);
3121 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
3127 vl_api_one_locator_set_details_t_handler_json
3128 (vl_api_one_locator_set_details_t * mp)
3130 vat_main_t *vam = &vat_main;
3131 vat_json_node_t *node = 0;
3134 ls_name = format (0, "%s", mp->ls_name);
3135 vec_add1 (ls_name, 0);
3137 if (VAT_JSON_ARRAY != vam->json_tree.type)
3139 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3140 vat_json_init_array (&vam->json_tree);
3142 node = vat_json_array_add (&vam->json_tree);
3144 vat_json_init_object (node);
3145 vat_json_object_add_string_copy (node, "ls_name", ls_name);
3146 vat_json_object_add_uint (node, "ls_index",
3147 clib_net_to_host_u32 (mp->ls_index));
3155 } __attribute__ ((__packed__)) lisp_nsh_api_t;
3158 unformat_nsh_address (unformat_input_t * input, va_list * args)
3160 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
3161 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
3165 format_nsh_address_vat (u8 * s, va_list * args)
3167 nsh_t *a = va_arg (*args, nsh_t *);
3168 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
3172 format_lisp_flat_eid (u8 * s, va_list * args)
3174 u32 type = va_arg (*args, u32);
3175 u8 *eid = va_arg (*args, u8 *);
3176 u32 eid_len = va_arg (*args, u32);
3181 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
3183 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
3185 return format (s, "%U", format_ethernet_address, eid);
3187 return format (s, "%U", format_nsh_address_vat, eid);
3193 format_lisp_eid_vat (u8 * s, va_list * args)
3195 u32 type = va_arg (*args, u32);
3196 u8 *eid = va_arg (*args, u8 *);
3197 u32 eid_len = va_arg (*args, u32);
3198 u8 *seid = va_arg (*args, u8 *);
3199 u32 seid_len = va_arg (*args, u32);
3200 u32 is_src_dst = va_arg (*args, u32);
3203 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
3205 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
3211 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
3213 vat_main_t *vam = &vat_main;
3214 u8 *s = 0, *eid = 0;
3216 if (~0 == mp->locator_set_index)
3217 s = format (0, "action: %d", mp->action);
3219 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3221 eid = format (0, "%U", format_lisp_eid_vat,
3225 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3228 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3229 clib_net_to_host_u32 (mp->vni),
3231 mp->is_local ? "local" : "remote",
3232 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3233 clib_net_to_host_u16 (mp->key_id), mp->key);
3240 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3243 vat_main_t *vam = &vat_main;
3244 vat_json_node_t *node = 0;
3247 if (VAT_JSON_ARRAY != vam->json_tree.type)
3249 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3250 vat_json_init_array (&vam->json_tree);
3252 node = vat_json_array_add (&vam->json_tree);
3254 vat_json_init_object (node);
3255 if (~0 == mp->locator_set_index)
3256 vat_json_object_add_uint (node, "action", mp->action);
3258 vat_json_object_add_uint (node, "locator_set_index",
3259 clib_net_to_host_u32 (mp->locator_set_index));
3261 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3262 if (mp->eid_type == 3)
3264 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3265 vat_json_init_object (nsh_json);
3266 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3267 vat_json_object_add_uint (nsh_json, "spi",
3268 clib_net_to_host_u32 (nsh->spi));
3269 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3273 eid = format (0, "%U", format_lisp_eid_vat,
3277 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3279 vat_json_object_add_string_copy (node, "eid", eid);
3282 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3283 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3284 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3288 vat_json_object_add_uint (node, "key_id",
3289 clib_net_to_host_u16 (mp->key_id));
3290 vat_json_object_add_string_copy (node, "key", mp->key);
3295 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3297 vat_main_t *vam = &vat_main;
3298 u8 *seid = 0, *deid = 0;
3299 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3301 deid = format (0, "%U", format_lisp_eid_vat,
3302 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3304 seid = format (0, "%U", format_lisp_eid_vat,
3305 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3311 format_ip_address_fcn = format_ip4_address;
3313 format_ip_address_fcn = format_ip6_address;
3316 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3317 clib_net_to_host_u32 (mp->vni),
3319 format_ip_address_fcn, mp->lloc,
3320 format_ip_address_fcn, mp->rloc,
3321 clib_net_to_host_u32 (mp->pkt_count),
3322 clib_net_to_host_u32 (mp->bytes));
3329 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3331 struct in6_addr ip6;
3333 vat_main_t *vam = &vat_main;
3334 vat_json_node_t *node = 0;
3335 u8 *deid = 0, *seid = 0;
3337 if (VAT_JSON_ARRAY != vam->json_tree.type)
3339 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3340 vat_json_init_array (&vam->json_tree);
3342 node = vat_json_array_add (&vam->json_tree);
3344 vat_json_init_object (node);
3345 deid = format (0, "%U", format_lisp_eid_vat,
3346 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3348 seid = format (0, "%U", format_lisp_eid_vat,
3349 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3354 vat_json_object_add_string_copy (node, "seid", seid);
3355 vat_json_object_add_string_copy (node, "deid", deid);
3356 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3360 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3361 vat_json_object_add_ip4 (node, "lloc", ip4);
3362 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3363 vat_json_object_add_ip4 (node, "rloc", ip4);
3367 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3368 vat_json_object_add_ip6 (node, "lloc", ip6);
3369 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3370 vat_json_object_add_ip6 (node, "rloc", ip6);
3372 vat_json_object_add_uint (node, "pkt_count",
3373 clib_net_to_host_u32 (mp->pkt_count));
3374 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3381 vl_api_one_eid_table_map_details_t_handler
3382 (vl_api_one_eid_table_map_details_t * mp)
3384 vat_main_t *vam = &vat_main;
3386 u8 *line = format (0, "%=10d%=10d",
3387 clib_net_to_host_u32 (mp->vni),
3388 clib_net_to_host_u32 (mp->dp_table));
3389 print (vam->ofp, "%v", line);
3394 vl_api_one_eid_table_map_details_t_handler_json
3395 (vl_api_one_eid_table_map_details_t * mp)
3397 vat_main_t *vam = &vat_main;
3398 vat_json_node_t *node = NULL;
3400 if (VAT_JSON_ARRAY != vam->json_tree.type)
3402 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3403 vat_json_init_array (&vam->json_tree);
3405 node = vat_json_array_add (&vam->json_tree);
3406 vat_json_init_object (node);
3407 vat_json_object_add_uint (node, "dp_table",
3408 clib_net_to_host_u32 (mp->dp_table));
3409 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3413 vl_api_one_eid_table_vni_details_t_handler
3414 (vl_api_one_eid_table_vni_details_t * mp)
3416 vat_main_t *vam = &vat_main;
3418 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3419 print (vam->ofp, "%v", line);
3424 vl_api_one_eid_table_vni_details_t_handler_json
3425 (vl_api_one_eid_table_vni_details_t * mp)
3427 vat_main_t *vam = &vat_main;
3428 vat_json_node_t *node = NULL;
3430 if (VAT_JSON_ARRAY != vam->json_tree.type)
3432 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3433 vat_json_init_array (&vam->json_tree);
3435 node = vat_json_array_add (&vam->json_tree);
3436 vat_json_init_object (node);
3437 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3441 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3442 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3444 vat_main_t *vam = &vat_main;
3445 int retval = clib_net_to_host_u32 (mp->retval);
3447 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3448 print (vam->ofp, "fallback threshold value: %d", mp->value);
3450 vam->retval = retval;
3451 vam->result_ready = 1;
3455 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3456 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3458 vat_main_t *vam = &vat_main;
3459 vat_json_node_t _node, *node = &_node;
3460 int retval = clib_net_to_host_u32 (mp->retval);
3462 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3463 vat_json_init_object (node);
3464 vat_json_object_add_uint (node, "value", mp->value);
3466 vat_json_print (vam->ofp, node);
3467 vat_json_free (node);
3469 vam->retval = retval;
3470 vam->result_ready = 1;
3474 vl_api_show_one_map_register_state_reply_t_handler
3475 (vl_api_show_one_map_register_state_reply_t * mp)
3477 vat_main_t *vam = &vat_main;
3478 int retval = clib_net_to_host_u32 (mp->retval);
3480 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3482 vam->retval = retval;
3483 vam->result_ready = 1;
3487 vl_api_show_one_map_register_state_reply_t_handler_json
3488 (vl_api_show_one_map_register_state_reply_t * mp)
3490 vat_main_t *vam = &vat_main;
3491 vat_json_node_t _node, *node = &_node;
3492 int retval = clib_net_to_host_u32 (mp->retval);
3494 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3496 vat_json_init_object (node);
3497 vat_json_object_add_string_copy (node, "state", s);
3499 vat_json_print (vam->ofp, node);
3500 vat_json_free (node);
3502 vam->retval = retval;
3503 vam->result_ready = 1;
3508 vl_api_show_one_rloc_probe_state_reply_t_handler
3509 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3511 vat_main_t *vam = &vat_main;
3512 int retval = clib_net_to_host_u32 (mp->retval);
3517 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3519 vam->retval = retval;
3520 vam->result_ready = 1;
3524 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3525 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3527 vat_main_t *vam = &vat_main;
3528 vat_json_node_t _node, *node = &_node;
3529 int retval = clib_net_to_host_u32 (mp->retval);
3531 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3532 vat_json_init_object (node);
3533 vat_json_object_add_string_copy (node, "state", s);
3535 vat_json_print (vam->ofp, node);
3536 vat_json_free (node);
3538 vam->retval = retval;
3539 vam->result_ready = 1;
3544 vl_api_show_one_stats_enable_disable_reply_t_handler
3545 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3547 vat_main_t *vam = &vat_main;
3548 int retval = clib_net_to_host_u32 (mp->retval);
3553 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3555 vam->retval = retval;
3556 vam->result_ready = 1;
3560 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3561 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3563 vat_main_t *vam = &vat_main;
3564 vat_json_node_t _node, *node = &_node;
3565 int retval = clib_net_to_host_u32 (mp->retval);
3567 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3568 vat_json_init_object (node);
3569 vat_json_object_add_string_copy (node, "state", s);
3571 vat_json_print (vam->ofp, node);
3572 vat_json_free (node);
3574 vam->retval = retval;
3575 vam->result_ready = 1;
3580 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3582 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3583 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3584 e->vni = clib_net_to_host_u32 (e->vni);
3588 gpe_fwd_entries_get_reply_t_net_to_host
3589 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3593 mp->count = clib_net_to_host_u32 (mp->count);
3594 for (i = 0; i < mp->count; i++)
3596 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3601 format_gpe_encap_mode (u8 * s, va_list * args)
3603 u32 mode = va_arg (*args, u32);
3608 return format (s, "lisp");
3610 return format (s, "vxlan");
3616 vl_api_gpe_get_encap_mode_reply_t_handler
3617 (vl_api_gpe_get_encap_mode_reply_t * mp)
3619 vat_main_t *vam = &vat_main;
3621 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3622 vam->retval = ntohl (mp->retval);
3623 vam->result_ready = 1;
3627 vl_api_gpe_get_encap_mode_reply_t_handler_json
3628 (vl_api_gpe_get_encap_mode_reply_t * mp)
3630 vat_main_t *vam = &vat_main;
3631 vat_json_node_t node;
3633 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3634 vec_add1 (encap_mode, 0);
3636 vat_json_init_object (&node);
3637 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3639 vec_free (encap_mode);
3640 vat_json_print (vam->ofp, &node);
3641 vat_json_free (&node);
3643 vam->retval = ntohl (mp->retval);
3644 vam->result_ready = 1;
3648 vl_api_gpe_fwd_entry_path_details_t_handler
3649 (vl_api_gpe_fwd_entry_path_details_t * mp)
3651 vat_main_t *vam = &vat_main;
3652 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3654 if (mp->lcl_loc.is_ip4)
3655 format_ip_address_fcn = format_ip4_address;
3657 format_ip_address_fcn = format_ip6_address;
3659 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3660 format_ip_address_fcn, &mp->lcl_loc,
3661 format_ip_address_fcn, &mp->rmt_loc);
3665 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3667 struct in6_addr ip6;
3672 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3673 vat_json_object_add_ip4 (n, "address", ip4);
3677 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3678 vat_json_object_add_ip6 (n, "address", ip6);
3680 vat_json_object_add_uint (n, "weight", loc->weight);
3684 vl_api_gpe_fwd_entry_path_details_t_handler_json
3685 (vl_api_gpe_fwd_entry_path_details_t * mp)
3687 vat_main_t *vam = &vat_main;
3688 vat_json_node_t *node = NULL;
3689 vat_json_node_t *loc_node;
3691 if (VAT_JSON_ARRAY != vam->json_tree.type)
3693 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3694 vat_json_init_array (&vam->json_tree);
3696 node = vat_json_array_add (&vam->json_tree);
3697 vat_json_init_object (node);
3699 loc_node = vat_json_object_add (node, "local_locator");
3700 vat_json_init_object (loc_node);
3701 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3703 loc_node = vat_json_object_add (node, "remote_locator");
3704 vat_json_init_object (loc_node);
3705 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3709 vl_api_gpe_fwd_entries_get_reply_t_handler
3710 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3712 vat_main_t *vam = &vat_main;
3714 int retval = clib_net_to_host_u32 (mp->retval);
3715 vl_api_gpe_fwd_entry_t *e;
3720 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3722 for (i = 0; i < mp->count; i++)
3724 e = &mp->entries[i];
3725 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3726 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3727 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3731 vam->retval = retval;
3732 vam->result_ready = 1;
3736 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3737 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3740 vat_main_t *vam = &vat_main;
3741 vat_json_node_t *e = 0, root;
3743 int retval = clib_net_to_host_u32 (mp->retval);
3744 vl_api_gpe_fwd_entry_t *fwd;
3749 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3750 vat_json_init_array (&root);
3752 for (i = 0; i < mp->count; i++)
3754 e = vat_json_array_add (&root);
3755 fwd = &mp->entries[i];
3757 vat_json_init_object (e);
3758 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3759 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3760 vat_json_object_add_int (e, "vni", fwd->vni);
3761 vat_json_object_add_int (e, "action", fwd->action);
3763 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3764 fwd->leid_prefix_len);
3766 vat_json_object_add_string_copy (e, "leid", s);
3769 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3770 fwd->reid_prefix_len);
3772 vat_json_object_add_string_copy (e, "reid", s);
3776 vat_json_print (vam->ofp, &root);
3777 vat_json_free (&root);
3780 vam->retval = retval;
3781 vam->result_ready = 1;
3785 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3786 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3788 vat_main_t *vam = &vat_main;
3790 int retval = clib_net_to_host_u32 (mp->retval);
3791 vl_api_gpe_native_fwd_rpath_t *r;
3796 n = clib_net_to_host_u32 (mp->count);
3798 for (i = 0; i < n; i++)
3800 r = &mp->entries[i];
3801 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3802 clib_net_to_host_u32 (r->fib_index),
3803 clib_net_to_host_u32 (r->nh_sw_if_index),
3804 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3808 vam->retval = retval;
3809 vam->result_ready = 1;
3813 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3814 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3816 vat_main_t *vam = &vat_main;
3817 vat_json_node_t root, *e;
3819 int retval = clib_net_to_host_u32 (mp->retval);
3820 vl_api_gpe_native_fwd_rpath_t *r;
3826 n = clib_net_to_host_u32 (mp->count);
3827 vat_json_init_array (&root);
3829 for (i = 0; i < n; i++)
3831 e = vat_json_array_add (&root);
3832 vat_json_init_object (e);
3833 r = &mp->entries[i];
3835 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3838 vat_json_object_add_string_copy (e, "ip4", s);
3841 vat_json_object_add_uint (e, "fib_index",
3842 clib_net_to_host_u32 (r->fib_index));
3843 vat_json_object_add_uint (e, "nh_sw_if_index",
3844 clib_net_to_host_u32 (r->nh_sw_if_index));
3847 vat_json_print (vam->ofp, &root);
3848 vat_json_free (&root);
3851 vam->retval = retval;
3852 vam->result_ready = 1;
3856 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3857 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3859 vat_main_t *vam = &vat_main;
3861 int retval = clib_net_to_host_u32 (mp->retval);
3866 n = clib_net_to_host_u32 (mp->count);
3868 for (i = 0; i < n; i++)
3869 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3872 vam->retval = retval;
3873 vam->result_ready = 1;
3877 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3878 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3880 vat_main_t *vam = &vat_main;
3881 vat_json_node_t root;
3883 int retval = clib_net_to_host_u32 (mp->retval);
3888 n = clib_net_to_host_u32 (mp->count);
3889 vat_json_init_array (&root);
3891 for (i = 0; i < n; i++)
3892 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3894 vat_json_print (vam->ofp, &root);
3895 vat_json_free (&root);
3898 vam->retval = retval;
3899 vam->result_ready = 1;
3903 vl_api_one_ndp_entries_get_reply_t_handler
3904 (vl_api_one_ndp_entries_get_reply_t * mp)
3906 vat_main_t *vam = &vat_main;
3908 int retval = clib_net_to_host_u32 (mp->retval);
3913 n = clib_net_to_host_u32 (mp->count);
3915 for (i = 0; i < n; i++)
3916 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3917 format_ethernet_address, mp->entries[i].mac);
3920 vam->retval = retval;
3921 vam->result_ready = 1;
3925 vl_api_one_ndp_entries_get_reply_t_handler_json
3926 (vl_api_one_ndp_entries_get_reply_t * mp)
3929 vat_main_t *vam = &vat_main;
3930 vat_json_node_t *e = 0, root;
3932 int retval = clib_net_to_host_u32 (mp->retval);
3933 vl_api_one_ndp_entry_t *arp_entry;
3938 n = clib_net_to_host_u32 (mp->count);
3939 vat_json_init_array (&root);
3941 for (i = 0; i < n; i++)
3943 e = vat_json_array_add (&root);
3944 arp_entry = &mp->entries[i];
3946 vat_json_init_object (e);
3947 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3950 vat_json_object_add_string_copy (e, "mac", s);
3953 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3955 vat_json_object_add_string_copy (e, "ip6", s);
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_l2_arp_entries_get_reply_t_handler
3969 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3971 vat_main_t *vam = &vat_main;
3973 int retval = clib_net_to_host_u32 (mp->retval);
3978 n = clib_net_to_host_u32 (mp->count);
3980 for (i = 0; i < n; i++)
3981 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3982 format_ethernet_address, mp->entries[i].mac);
3985 vam->retval = retval;
3986 vam->result_ready = 1;
3990 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3991 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3994 vat_main_t *vam = &vat_main;
3995 vat_json_node_t *e = 0, root;
3997 int retval = clib_net_to_host_u32 (mp->retval);
3998 vl_api_one_l2_arp_entry_t *arp_entry;
4003 n = clib_net_to_host_u32 (mp->count);
4004 vat_json_init_array (&root);
4006 for (i = 0; i < n; i++)
4008 e = vat_json_array_add (&root);
4009 arp_entry = &mp->entries[i];
4011 vat_json_init_object (e);
4012 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
4015 vat_json_object_add_string_copy (e, "mac", s);
4018 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
4020 vat_json_object_add_string_copy (e, "ip4", s);
4024 vat_json_print (vam->ofp, &root);
4025 vat_json_free (&root);
4028 vam->retval = retval;
4029 vam->result_ready = 1;
4033 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
4035 vat_main_t *vam = &vat_main;
4037 int retval = clib_net_to_host_u32 (mp->retval);
4042 n = clib_net_to_host_u32 (mp->count);
4044 for (i = 0; i < n; i++)
4046 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
4050 vam->retval = retval;
4051 vam->result_ready = 1;
4055 vl_api_one_ndp_bd_get_reply_t_handler_json
4056 (vl_api_one_ndp_bd_get_reply_t * mp)
4058 vat_main_t *vam = &vat_main;
4059 vat_json_node_t root;
4061 int retval = clib_net_to_host_u32 (mp->retval);
4066 n = clib_net_to_host_u32 (mp->count);
4067 vat_json_init_array (&root);
4069 for (i = 0; i < n; i++)
4071 vat_json_array_add_uint (&root,
4072 clib_net_to_host_u32 (mp->bridge_domains[i]));
4075 vat_json_print (vam->ofp, &root);
4076 vat_json_free (&root);
4079 vam->retval = retval;
4080 vam->result_ready = 1;
4084 vl_api_one_l2_arp_bd_get_reply_t_handler
4085 (vl_api_one_l2_arp_bd_get_reply_t * mp)
4087 vat_main_t *vam = &vat_main;
4089 int retval = clib_net_to_host_u32 (mp->retval);
4094 n = clib_net_to_host_u32 (mp->count);
4096 for (i = 0; i < n; i++)
4098 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
4102 vam->retval = retval;
4103 vam->result_ready = 1;
4107 vl_api_one_l2_arp_bd_get_reply_t_handler_json
4108 (vl_api_one_l2_arp_bd_get_reply_t * mp)
4110 vat_main_t *vam = &vat_main;
4111 vat_json_node_t root;
4113 int retval = clib_net_to_host_u32 (mp->retval);
4118 n = clib_net_to_host_u32 (mp->count);
4119 vat_json_init_array (&root);
4121 for (i = 0; i < n; i++)
4123 vat_json_array_add_uint (&root,
4124 clib_net_to_host_u32 (mp->bridge_domains[i]));
4127 vat_json_print (vam->ofp, &root);
4128 vat_json_free (&root);
4131 vam->retval = retval;
4132 vam->result_ready = 1;
4136 vl_api_one_adjacencies_get_reply_t_handler
4137 (vl_api_one_adjacencies_get_reply_t * mp)
4139 vat_main_t *vam = &vat_main;
4141 int retval = clib_net_to_host_u32 (mp->retval);
4142 vl_api_one_adjacency_t *a;
4147 n = clib_net_to_host_u32 (mp->count);
4149 for (i = 0; i < n; i++)
4151 a = &mp->adjacencies[i];
4152 print (vam->ofp, "%U %40U",
4153 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
4154 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
4158 vam->retval = retval;
4159 vam->result_ready = 1;
4163 vl_api_one_adjacencies_get_reply_t_handler_json
4164 (vl_api_one_adjacencies_get_reply_t * mp)
4167 vat_main_t *vam = &vat_main;
4168 vat_json_node_t *e = 0, root;
4170 int retval = clib_net_to_host_u32 (mp->retval);
4171 vl_api_one_adjacency_t *a;
4176 n = clib_net_to_host_u32 (mp->count);
4177 vat_json_init_array (&root);
4179 for (i = 0; i < n; i++)
4181 e = vat_json_array_add (&root);
4182 a = &mp->adjacencies[i];
4184 vat_json_init_object (e);
4185 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
4186 a->leid_prefix_len);
4188 vat_json_object_add_string_copy (e, "leid", s);
4191 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
4192 a->reid_prefix_len);
4194 vat_json_object_add_string_copy (e, "reid", s);
4198 vat_json_print (vam->ofp, &root);
4199 vat_json_free (&root);
4202 vam->retval = retval;
4203 vam->result_ready = 1;
4207 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
4209 vat_main_t *vam = &vat_main;
4211 print (vam->ofp, "%=20U",
4212 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4217 vl_api_one_map_server_details_t_handler_json
4218 (vl_api_one_map_server_details_t * mp)
4220 vat_main_t *vam = &vat_main;
4221 vat_json_node_t *node = NULL;
4222 struct in6_addr ip6;
4225 if (VAT_JSON_ARRAY != vam->json_tree.type)
4227 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4228 vat_json_init_array (&vam->json_tree);
4230 node = vat_json_array_add (&vam->json_tree);
4232 vat_json_init_object (node);
4235 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4236 vat_json_object_add_ip6 (node, "map-server", ip6);
4240 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4241 vat_json_object_add_ip4 (node, "map-server", ip4);
4246 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4249 vat_main_t *vam = &vat_main;
4251 print (vam->ofp, "%=20U",
4252 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4257 vl_api_one_map_resolver_details_t_handler_json
4258 (vl_api_one_map_resolver_details_t * mp)
4260 vat_main_t *vam = &vat_main;
4261 vat_json_node_t *node = NULL;
4262 struct in6_addr ip6;
4265 if (VAT_JSON_ARRAY != vam->json_tree.type)
4267 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4268 vat_json_init_array (&vam->json_tree);
4270 node = vat_json_array_add (&vam->json_tree);
4272 vat_json_init_object (node);
4275 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4276 vat_json_object_add_ip6 (node, "map resolver", ip6);
4280 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4281 vat_json_object_add_ip4 (node, "map resolver", ip4);
4286 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4288 vat_main_t *vam = &vat_main;
4289 i32 retval = ntohl (mp->retval);
4293 print (vam->ofp, "feature: %s\ngpe: %s",
4294 mp->feature_status ? "enabled" : "disabled",
4295 mp->gpe_status ? "enabled" : "disabled");
4298 vam->retval = retval;
4299 vam->result_ready = 1;
4303 vl_api_show_one_status_reply_t_handler_json
4304 (vl_api_show_one_status_reply_t * mp)
4306 vat_main_t *vam = &vat_main;
4307 vat_json_node_t node;
4308 u8 *gpe_status = NULL;
4309 u8 *feature_status = NULL;
4311 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4312 feature_status = format (0, "%s",
4313 mp->feature_status ? "enabled" : "disabled");
4314 vec_add1 (gpe_status, 0);
4315 vec_add1 (feature_status, 0);
4317 vat_json_init_object (&node);
4318 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4319 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4321 vec_free (gpe_status);
4322 vec_free (feature_status);
4324 vat_json_print (vam->ofp, &node);
4325 vat_json_free (&node);
4327 vam->retval = ntohl (mp->retval);
4328 vam->result_ready = 1;
4332 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4333 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4335 vat_main_t *vam = &vat_main;
4336 i32 retval = ntohl (mp->retval);
4340 print (vam->ofp, "%=20s", mp->locator_set_name);
4343 vam->retval = retval;
4344 vam->result_ready = 1;
4348 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4349 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4351 vat_main_t *vam = &vat_main;
4352 vat_json_node_t *node = NULL;
4354 if (VAT_JSON_ARRAY != vam->json_tree.type)
4356 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4357 vat_json_init_array (&vam->json_tree);
4359 node = vat_json_array_add (&vam->json_tree);
4361 vat_json_init_object (node);
4362 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4364 vat_json_print (vam->ofp, node);
4365 vat_json_free (node);
4367 vam->retval = ntohl (mp->retval);
4368 vam->result_ready = 1;
4372 format_lisp_map_request_mode (u8 * s, va_list * args)
4374 u32 mode = va_arg (*args, u32);
4379 return format (0, "dst-only");
4381 return format (0, "src-dst");
4387 vl_api_show_one_map_request_mode_reply_t_handler
4388 (vl_api_show_one_map_request_mode_reply_t * mp)
4390 vat_main_t *vam = &vat_main;
4391 i32 retval = ntohl (mp->retval);
4395 u32 mode = mp->mode;
4396 print (vam->ofp, "map_request_mode: %U",
4397 format_lisp_map_request_mode, mode);
4400 vam->retval = retval;
4401 vam->result_ready = 1;
4405 vl_api_show_one_map_request_mode_reply_t_handler_json
4406 (vl_api_show_one_map_request_mode_reply_t * mp)
4408 vat_main_t *vam = &vat_main;
4409 vat_json_node_t node;
4414 s = format (0, "%U", format_lisp_map_request_mode, mode);
4417 vat_json_init_object (&node);
4418 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4419 vat_json_print (vam->ofp, &node);
4420 vat_json_free (&node);
4423 vam->retval = ntohl (mp->retval);
4424 vam->result_ready = 1;
4428 vl_api_one_show_xtr_mode_reply_t_handler
4429 (vl_api_one_show_xtr_mode_reply_t * mp)
4431 vat_main_t *vam = &vat_main;
4432 i32 retval = ntohl (mp->retval);
4436 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4439 vam->retval = retval;
4440 vam->result_ready = 1;
4444 vl_api_one_show_xtr_mode_reply_t_handler_json
4445 (vl_api_one_show_xtr_mode_reply_t * mp)
4447 vat_main_t *vam = &vat_main;
4448 vat_json_node_t node;
4451 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4452 vec_add1 (status, 0);
4454 vat_json_init_object (&node);
4455 vat_json_object_add_string_copy (&node, "status", status);
4459 vat_json_print (vam->ofp, &node);
4460 vat_json_free (&node);
4462 vam->retval = ntohl (mp->retval);
4463 vam->result_ready = 1;
4467 vl_api_one_show_pitr_mode_reply_t_handler
4468 (vl_api_one_show_pitr_mode_reply_t * mp)
4470 vat_main_t *vam = &vat_main;
4471 i32 retval = ntohl (mp->retval);
4475 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4478 vam->retval = retval;
4479 vam->result_ready = 1;
4483 vl_api_one_show_pitr_mode_reply_t_handler_json
4484 (vl_api_one_show_pitr_mode_reply_t * mp)
4486 vat_main_t *vam = &vat_main;
4487 vat_json_node_t node;
4490 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4491 vec_add1 (status, 0);
4493 vat_json_init_object (&node);
4494 vat_json_object_add_string_copy (&node, "status", status);
4498 vat_json_print (vam->ofp, &node);
4499 vat_json_free (&node);
4501 vam->retval = ntohl (mp->retval);
4502 vam->result_ready = 1;
4506 vl_api_one_show_petr_mode_reply_t_handler
4507 (vl_api_one_show_petr_mode_reply_t * mp)
4509 vat_main_t *vam = &vat_main;
4510 i32 retval = ntohl (mp->retval);
4514 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4517 vam->retval = retval;
4518 vam->result_ready = 1;
4522 vl_api_one_show_petr_mode_reply_t_handler_json
4523 (vl_api_one_show_petr_mode_reply_t * mp)
4525 vat_main_t *vam = &vat_main;
4526 vat_json_node_t node;
4529 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4530 vec_add1 (status, 0);
4532 vat_json_init_object (&node);
4533 vat_json_object_add_string_copy (&node, "status", status);
4537 vat_json_print (vam->ofp, &node);
4538 vat_json_free (&node);
4540 vam->retval = ntohl (mp->retval);
4541 vam->result_ready = 1;
4545 vl_api_show_one_use_petr_reply_t_handler
4546 (vl_api_show_one_use_petr_reply_t * mp)
4548 vat_main_t *vam = &vat_main;
4549 i32 retval = ntohl (mp->retval);
4553 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4556 print (vam->ofp, "Proxy-ETR address; %U",
4557 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4562 vam->retval = retval;
4563 vam->result_ready = 1;
4567 vl_api_show_one_use_petr_reply_t_handler_json
4568 (vl_api_show_one_use_petr_reply_t * mp)
4570 vat_main_t *vam = &vat_main;
4571 vat_json_node_t node;
4574 struct in6_addr ip6;
4576 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4577 vec_add1 (status, 0);
4579 vat_json_init_object (&node);
4580 vat_json_object_add_string_copy (&node, "status", status);
4585 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4586 vat_json_object_add_ip6 (&node, "address", ip6);
4590 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4591 vat_json_object_add_ip4 (&node, "address", ip4);
4597 vat_json_print (vam->ofp, &node);
4598 vat_json_free (&node);
4600 vam->retval = ntohl (mp->retval);
4601 vam->result_ready = 1;
4605 vl_api_show_one_nsh_mapping_reply_t_handler
4606 (vl_api_show_one_nsh_mapping_reply_t * mp)
4608 vat_main_t *vam = &vat_main;
4609 i32 retval = ntohl (mp->retval);
4613 print (vam->ofp, "%-20s%-16s",
4614 mp->is_set ? "set" : "not-set",
4615 mp->is_set ? (char *) mp->locator_set_name : "");
4618 vam->retval = retval;
4619 vam->result_ready = 1;
4623 vl_api_show_one_nsh_mapping_reply_t_handler_json
4624 (vl_api_show_one_nsh_mapping_reply_t * mp)
4626 vat_main_t *vam = &vat_main;
4627 vat_json_node_t node;
4630 status = format (0, "%s", mp->is_set ? "yes" : "no");
4631 vec_add1 (status, 0);
4633 vat_json_init_object (&node);
4634 vat_json_object_add_string_copy (&node, "is_set", status);
4637 vat_json_object_add_string_copy (&node, "locator_set",
4638 mp->locator_set_name);
4643 vat_json_print (vam->ofp, &node);
4644 vat_json_free (&node);
4646 vam->retval = ntohl (mp->retval);
4647 vam->result_ready = 1;
4651 vl_api_show_one_map_register_ttl_reply_t_handler
4652 (vl_api_show_one_map_register_ttl_reply_t * mp)
4654 vat_main_t *vam = &vat_main;
4655 i32 retval = ntohl (mp->retval);
4657 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4661 print (vam->ofp, "ttl: %u", mp->ttl);
4664 vam->retval = retval;
4665 vam->result_ready = 1;
4669 vl_api_show_one_map_register_ttl_reply_t_handler_json
4670 (vl_api_show_one_map_register_ttl_reply_t * mp)
4672 vat_main_t *vam = &vat_main;
4673 vat_json_node_t node;
4675 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4676 vat_json_init_object (&node);
4677 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4679 vat_json_print (vam->ofp, &node);
4680 vat_json_free (&node);
4682 vam->retval = ntohl (mp->retval);
4683 vam->result_ready = 1;
4687 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4689 vat_main_t *vam = &vat_main;
4690 i32 retval = ntohl (mp->retval);
4694 print (vam->ofp, "%-20s%-16s",
4695 mp->status ? "enabled" : "disabled",
4696 mp->status ? (char *) mp->locator_set_name : "");
4699 vam->retval = retval;
4700 vam->result_ready = 1;
4704 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4706 vat_main_t *vam = &vat_main;
4707 vat_json_node_t node;
4710 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4711 vec_add1 (status, 0);
4713 vat_json_init_object (&node);
4714 vat_json_object_add_string_copy (&node, "status", status);
4717 vat_json_object_add_string_copy (&node, "locator_set",
4718 mp->locator_set_name);
4723 vat_json_print (vam->ofp, &node);
4724 vat_json_free (&node);
4726 vam->retval = ntohl (mp->retval);
4727 vam->result_ready = 1;
4731 format_policer_type (u8 * s, va_list * va)
4733 u32 i = va_arg (*va, u32);
4735 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4736 s = format (s, "1r2c");
4737 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4738 s = format (s, "1r3c");
4739 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4740 s = format (s, "2r3c-2698");
4741 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4742 s = format (s, "2r3c-4115");
4743 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4744 s = format (s, "2r3c-mef5cf1");
4746 s = format (s, "ILLEGAL");
4751 format_policer_rate_type (u8 * s, va_list * va)
4753 u32 i = va_arg (*va, u32);
4755 if (i == SSE2_QOS_RATE_KBPS)
4756 s = format (s, "kbps");
4757 else if (i == SSE2_QOS_RATE_PPS)
4758 s = format (s, "pps");
4760 s = format (s, "ILLEGAL");
4765 format_policer_round_type (u8 * s, va_list * va)
4767 u32 i = va_arg (*va, u32);
4769 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4770 s = format (s, "closest");
4771 else if (i == SSE2_QOS_ROUND_TO_UP)
4772 s = format (s, "up");
4773 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4774 s = format (s, "down");
4776 s = format (s, "ILLEGAL");
4781 format_policer_action_type (u8 * s, va_list * va)
4783 u32 i = va_arg (*va, u32);
4785 if (i == SSE2_QOS_ACTION_DROP)
4786 s = format (s, "drop");
4787 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4788 s = format (s, "transmit");
4789 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4790 s = format (s, "mark-and-transmit");
4792 s = format (s, "ILLEGAL");
4797 format_dscp (u8 * s, va_list * va)
4799 u32 i = va_arg (*va, u32);
4804 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4808 return format (s, "ILLEGAL");
4810 s = format (s, "%s", t);
4815 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4817 vat_main_t *vam = &vat_main;
4818 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4820 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4821 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4823 conform_dscp_str = format (0, "");
4825 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4826 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4828 exceed_dscp_str = format (0, "");
4830 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4831 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4833 violate_dscp_str = format (0, "");
4835 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4836 "rate type %U, round type %U, %s rate, %s color-aware, "
4837 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4838 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4839 "conform action %U%s, exceed action %U%s, violate action %U%s",
4841 format_policer_type, mp->type,
4844 clib_net_to_host_u64 (mp->cb),
4845 clib_net_to_host_u64 (mp->eb),
4846 format_policer_rate_type, mp->rate_type,
4847 format_policer_round_type, mp->round_type,
4848 mp->single_rate ? "single" : "dual",
4849 mp->color_aware ? "is" : "not",
4850 ntohl (mp->cir_tokens_per_period),
4851 ntohl (mp->pir_tokens_per_period),
4853 ntohl (mp->current_limit),
4854 ntohl (mp->current_bucket),
4855 ntohl (mp->extended_limit),
4856 ntohl (mp->extended_bucket),
4857 clib_net_to_host_u64 (mp->last_update_time),
4858 format_policer_action_type, mp->conform_action_type,
4860 format_policer_action_type, mp->exceed_action_type,
4862 format_policer_action_type, mp->violate_action_type,
4865 vec_free (conform_dscp_str);
4866 vec_free (exceed_dscp_str);
4867 vec_free (violate_dscp_str);
4870 static void vl_api_policer_details_t_handler_json
4871 (vl_api_policer_details_t * mp)
4873 vat_main_t *vam = &vat_main;
4874 vat_json_node_t *node;
4875 u8 *rate_type_str, *round_type_str, *type_str;
4876 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4878 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4880 format (0, "%U", format_policer_round_type, mp->round_type);
4881 type_str = format (0, "%U", format_policer_type, mp->type);
4882 conform_action_str = format (0, "%U", format_policer_action_type,
4883 mp->conform_action_type);
4884 exceed_action_str = format (0, "%U", format_policer_action_type,
4885 mp->exceed_action_type);
4886 violate_action_str = format (0, "%U", format_policer_action_type,
4887 mp->violate_action_type);
4889 if (VAT_JSON_ARRAY != vam->json_tree.type)
4891 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4892 vat_json_init_array (&vam->json_tree);
4894 node = vat_json_array_add (&vam->json_tree);
4896 vat_json_init_object (node);
4897 vat_json_object_add_string_copy (node, "name", mp->name);
4898 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4899 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4900 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4901 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4902 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4903 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4904 vat_json_object_add_string_copy (node, "type", type_str);
4905 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4906 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4907 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4908 vat_json_object_add_uint (node, "cir_tokens_per_period",
4909 ntohl (mp->cir_tokens_per_period));
4910 vat_json_object_add_uint (node, "eir_tokens_per_period",
4911 ntohl (mp->pir_tokens_per_period));
4912 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4913 vat_json_object_add_uint (node, "current_bucket",
4914 ntohl (mp->current_bucket));
4915 vat_json_object_add_uint (node, "extended_limit",
4916 ntohl (mp->extended_limit));
4917 vat_json_object_add_uint (node, "extended_bucket",
4918 ntohl (mp->extended_bucket));
4919 vat_json_object_add_uint (node, "last_update_time",
4920 ntohl (mp->last_update_time));
4921 vat_json_object_add_string_copy (node, "conform_action",
4922 conform_action_str);
4923 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4925 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4926 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4927 vec_free (dscp_str);
4929 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4930 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4932 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4933 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4934 vec_free (dscp_str);
4936 vat_json_object_add_string_copy (node, "violate_action",
4937 violate_action_str);
4938 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4940 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4941 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4942 vec_free (dscp_str);
4945 vec_free (rate_type_str);
4946 vec_free (round_type_str);
4947 vec_free (type_str);
4948 vec_free (conform_action_str);
4949 vec_free (exceed_action_str);
4950 vec_free (violate_action_str);
4954 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4957 vat_main_t *vam = &vat_main;
4958 int i, count = ntohl (mp->count);
4961 print (vam->ofp, "classify table ids (%d) : ", count);
4962 for (i = 0; i < count; i++)
4964 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4965 print (vam->ofp, (i < count - 1) ? "," : "");
4967 vam->retval = ntohl (mp->retval);
4968 vam->result_ready = 1;
4972 vl_api_classify_table_ids_reply_t_handler_json
4973 (vl_api_classify_table_ids_reply_t * mp)
4975 vat_main_t *vam = &vat_main;
4976 int i, count = ntohl (mp->count);
4980 vat_json_node_t node;
4982 vat_json_init_object (&node);
4983 for (i = 0; i < count; i++)
4985 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4987 vat_json_print (vam->ofp, &node);
4988 vat_json_free (&node);
4990 vam->retval = ntohl (mp->retval);
4991 vam->result_ready = 1;
4995 vl_api_classify_table_by_interface_reply_t_handler
4996 (vl_api_classify_table_by_interface_reply_t * mp)
4998 vat_main_t *vam = &vat_main;
5001 table_id = ntohl (mp->l2_table_id);
5003 print (vam->ofp, "l2 table id : %d", table_id);
5005 print (vam->ofp, "l2 table id : No input ACL tables configured");
5006 table_id = ntohl (mp->ip4_table_id);
5008 print (vam->ofp, "ip4 table id : %d", table_id);
5010 print (vam->ofp, "ip4 table id : No input ACL tables configured");
5011 table_id = ntohl (mp->ip6_table_id);
5013 print (vam->ofp, "ip6 table id : %d", table_id);
5015 print (vam->ofp, "ip6 table id : No input ACL tables configured");
5016 vam->retval = ntohl (mp->retval);
5017 vam->result_ready = 1;
5021 vl_api_classify_table_by_interface_reply_t_handler_json
5022 (vl_api_classify_table_by_interface_reply_t * mp)
5024 vat_main_t *vam = &vat_main;
5025 vat_json_node_t node;
5027 vat_json_init_object (&node);
5029 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
5030 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
5031 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
5033 vat_json_print (vam->ofp, &node);
5034 vat_json_free (&node);
5036 vam->retval = ntohl (mp->retval);
5037 vam->result_ready = 1;
5040 static void vl_api_policer_add_del_reply_t_handler
5041 (vl_api_policer_add_del_reply_t * mp)
5043 vat_main_t *vam = &vat_main;
5044 i32 retval = ntohl (mp->retval);
5045 if (vam->async_mode)
5047 vam->async_errors += (retval < 0);
5051 vam->retval = retval;
5052 vam->result_ready = 1;
5053 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
5055 * Note: this is just barely thread-safe, depends on
5056 * the main thread spinning waiting for an answer...
5058 errmsg ("policer index %d", ntohl (mp->policer_index));
5062 static void vl_api_policer_add_del_reply_t_handler_json
5063 (vl_api_policer_add_del_reply_t * mp)
5065 vat_main_t *vam = &vat_main;
5066 vat_json_node_t node;
5068 vat_json_init_object (&node);
5069 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5070 vat_json_object_add_uint (&node, "policer_index",
5071 ntohl (mp->policer_index));
5073 vat_json_print (vam->ofp, &node);
5074 vat_json_free (&node);
5076 vam->retval = ntohl (mp->retval);
5077 vam->result_ready = 1;
5080 /* Format hex dump. */
5082 format_hex_bytes (u8 * s, va_list * va)
5084 u8 *bytes = va_arg (*va, u8 *);
5085 int n_bytes = va_arg (*va, int);
5088 /* Print short or long form depending on byte count. */
5089 uword short_form = n_bytes <= 32;
5090 u32 indent = format_get_indent (s);
5095 for (i = 0; i < n_bytes; i++)
5097 if (!short_form && (i % 32) == 0)
5098 s = format (s, "%08x: ", i);
5099 s = format (s, "%02x", bytes[i]);
5100 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
5101 s = format (s, "\n%U", format_white_space, indent);
5108 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
5111 vat_main_t *vam = &vat_main;
5112 i32 retval = ntohl (mp->retval);
5115 print (vam->ofp, "classify table info :");
5116 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
5117 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
5118 ntohl (mp->miss_next_index));
5119 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
5120 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
5121 ntohl (mp->match_n_vectors));
5122 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
5123 ntohl (mp->mask_length));
5125 vam->retval = retval;
5126 vam->result_ready = 1;
5130 vl_api_classify_table_info_reply_t_handler_json
5131 (vl_api_classify_table_info_reply_t * mp)
5133 vat_main_t *vam = &vat_main;
5134 vat_json_node_t node;
5136 i32 retval = ntohl (mp->retval);
5139 vat_json_init_object (&node);
5141 vat_json_object_add_int (&node, "sessions",
5142 ntohl (mp->active_sessions));
5143 vat_json_object_add_int (&node, "nexttbl",
5144 ntohl (mp->next_table_index));
5145 vat_json_object_add_int (&node, "nextnode",
5146 ntohl (mp->miss_next_index));
5147 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
5148 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
5149 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
5150 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
5151 ntohl (mp->mask_length), 0);
5152 vat_json_object_add_string_copy (&node, "mask", s);
5154 vat_json_print (vam->ofp, &node);
5155 vat_json_free (&node);
5157 vam->retval = ntohl (mp->retval);
5158 vam->result_ready = 1;
5162 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
5165 vat_main_t *vam = &vat_main;
5167 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
5168 ntohl (mp->hit_next_index), ntohl (mp->advance),
5169 ntohl (mp->opaque_index));
5170 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
5171 ntohl (mp->match_length));
5175 vl_api_classify_session_details_t_handler_json
5176 (vl_api_classify_session_details_t * mp)
5178 vat_main_t *vam = &vat_main;
5179 vat_json_node_t *node = NULL;
5181 if (VAT_JSON_ARRAY != vam->json_tree.type)
5183 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5184 vat_json_init_array (&vam->json_tree);
5186 node = vat_json_array_add (&vam->json_tree);
5188 vat_json_init_object (node);
5189 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
5190 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
5191 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
5193 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
5195 vat_json_object_add_string_copy (node, "match", s);
5198 static void vl_api_pg_create_interface_reply_t_handler
5199 (vl_api_pg_create_interface_reply_t * mp)
5201 vat_main_t *vam = &vat_main;
5203 vam->retval = ntohl (mp->retval);
5204 vam->result_ready = 1;
5207 static void vl_api_pg_create_interface_reply_t_handler_json
5208 (vl_api_pg_create_interface_reply_t * mp)
5210 vat_main_t *vam = &vat_main;
5211 vat_json_node_t node;
5213 i32 retval = ntohl (mp->retval);
5216 vat_json_init_object (&node);
5218 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
5220 vat_json_print (vam->ofp, &node);
5221 vat_json_free (&node);
5223 vam->retval = ntohl (mp->retval);
5224 vam->result_ready = 1;
5227 static void vl_api_policer_classify_details_t_handler
5228 (vl_api_policer_classify_details_t * mp)
5230 vat_main_t *vam = &vat_main;
5232 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5233 ntohl (mp->table_index));
5236 static void vl_api_policer_classify_details_t_handler_json
5237 (vl_api_policer_classify_details_t * mp)
5239 vat_main_t *vam = &vat_main;
5240 vat_json_node_t *node;
5242 if (VAT_JSON_ARRAY != vam->json_tree.type)
5244 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5245 vat_json_init_array (&vam->json_tree);
5247 node = vat_json_array_add (&vam->json_tree);
5249 vat_json_init_object (node);
5250 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5251 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5254 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
5255 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5257 vat_main_t *vam = &vat_main;
5258 i32 retval = ntohl (mp->retval);
5259 if (vam->async_mode)
5261 vam->async_errors += (retval < 0);
5265 vam->retval = retval;
5266 vam->sw_if_index = ntohl (mp->sw_if_index);
5267 vam->result_ready = 1;
5269 vam->regenerate_interface_table = 1;
5272 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
5273 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5275 vat_main_t *vam = &vat_main;
5276 vat_json_node_t node;
5278 vat_json_init_object (&node);
5279 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5280 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
5282 vat_json_print (vam->ofp, &node);
5283 vat_json_free (&node);
5285 vam->retval = ntohl (mp->retval);
5286 vam->result_ready = 1;
5289 static void vl_api_flow_classify_details_t_handler
5290 (vl_api_flow_classify_details_t * mp)
5292 vat_main_t *vam = &vat_main;
5294 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5295 ntohl (mp->table_index));
5298 static void vl_api_flow_classify_details_t_handler_json
5299 (vl_api_flow_classify_details_t * mp)
5301 vat_main_t *vam = &vat_main;
5302 vat_json_node_t *node;
5304 if (VAT_JSON_ARRAY != vam->json_tree.type)
5306 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5307 vat_json_init_array (&vam->json_tree);
5309 node = vat_json_array_add (&vam->json_tree);
5311 vat_json_init_object (node);
5312 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5313 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5316 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
5317 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
5318 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
5319 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
5320 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
5321 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
5322 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
5323 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
5324 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
5325 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
5326 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
5327 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
5328 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5329 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5330 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5331 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5332 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5333 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5334 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5335 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5336 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5337 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5340 * Generate boilerplate reply handlers, which
5341 * dig the return value out of the xxx_reply_t API message,
5342 * stick it into vam->retval, and set vam->result_ready
5344 * Could also do this by pointing N message decode slots at
5345 * a single function, but that could break in subtle ways.
5348 #define foreach_standard_reply_retval_handler \
5349 _(sw_interface_set_flags_reply) \
5350 _(sw_interface_add_del_address_reply) \
5351 _(sw_interface_set_rx_mode_reply) \
5352 _(sw_interface_set_table_reply) \
5353 _(sw_interface_set_mpls_enable_reply) \
5354 _(sw_interface_set_vpath_reply) \
5355 _(sw_interface_set_vxlan_bypass_reply) \
5356 _(sw_interface_set_geneve_bypass_reply) \
5357 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5358 _(sw_interface_set_l2_bridge_reply) \
5359 _(bridge_domain_add_del_reply) \
5360 _(sw_interface_set_l2_xconnect_reply) \
5361 _(l2fib_add_del_reply) \
5362 _(l2fib_flush_int_reply) \
5363 _(l2fib_flush_bd_reply) \
5364 _(ip_add_del_route_reply) \
5365 _(ip_table_add_del_reply) \
5366 _(ip_mroute_add_del_reply) \
5367 _(mpls_route_add_del_reply) \
5368 _(mpls_table_add_del_reply) \
5369 _(mpls_ip_bind_unbind_reply) \
5370 _(bier_route_add_del_reply) \
5371 _(bier_table_add_del_reply) \
5372 _(proxy_arp_add_del_reply) \
5373 _(proxy_arp_intfc_enable_disable_reply) \
5374 _(sw_interface_set_unnumbered_reply) \
5375 _(ip_neighbor_add_del_reply) \
5376 _(oam_add_del_reply) \
5377 _(reset_fib_reply) \
5378 _(dhcp_proxy_config_reply) \
5379 _(dhcp_proxy_set_vss_reply) \
5380 _(dhcp_client_config_reply) \
5381 _(set_ip_flow_hash_reply) \
5382 _(sw_interface_ip6_enable_disable_reply) \
5383 _(sw_interface_ip6_set_link_local_address_reply) \
5384 _(ip6nd_proxy_add_del_reply) \
5385 _(sw_interface_ip6nd_ra_prefix_reply) \
5386 _(sw_interface_ip6nd_ra_config_reply) \
5387 _(set_arp_neighbor_limit_reply) \
5388 _(l2_patch_add_del_reply) \
5389 _(sr_policy_add_reply) \
5390 _(sr_policy_mod_reply) \
5391 _(sr_policy_del_reply) \
5392 _(sr_localsid_add_del_reply) \
5393 _(sr_steering_add_del_reply) \
5394 _(classify_add_del_session_reply) \
5395 _(classify_set_interface_ip_table_reply) \
5396 _(classify_set_interface_l2_tables_reply) \
5397 _(l2tpv3_set_tunnel_cookies_reply) \
5398 _(l2tpv3_interface_enable_disable_reply) \
5399 _(l2tpv3_set_lookup_key_reply) \
5400 _(l2_fib_clear_table_reply) \
5401 _(l2_interface_efp_filter_reply) \
5402 _(l2_interface_vlan_tag_rewrite_reply) \
5403 _(modify_vhost_user_if_reply) \
5404 _(delete_vhost_user_if_reply) \
5405 _(ip_probe_neighbor_reply) \
5406 _(ip_scan_neighbor_enable_disable_reply) \
5407 _(want_ip4_arp_events_reply) \
5408 _(want_ip6_nd_events_reply) \
5409 _(want_l2_macs_events_reply) \
5410 _(input_acl_set_interface_reply) \
5411 _(ipsec_spd_add_del_reply) \
5412 _(ipsec_interface_add_del_spd_reply) \
5413 _(ipsec_spd_add_del_entry_reply) \
5414 _(ipsec_sad_add_del_entry_reply) \
5415 _(ipsec_sa_set_key_reply) \
5416 _(ipsec_tunnel_if_add_del_reply) \
5417 _(ipsec_tunnel_if_set_key_reply) \
5418 _(ipsec_tunnel_if_set_sa_reply) \
5419 _(ikev2_profile_add_del_reply) \
5420 _(ikev2_profile_set_auth_reply) \
5421 _(ikev2_profile_set_id_reply) \
5422 _(ikev2_profile_set_ts_reply) \
5423 _(ikev2_set_local_key_reply) \
5424 _(ikev2_set_responder_reply) \
5425 _(ikev2_set_ike_transforms_reply) \
5426 _(ikev2_set_esp_transforms_reply) \
5427 _(ikev2_set_sa_lifetime_reply) \
5428 _(ikev2_initiate_sa_init_reply) \
5429 _(ikev2_initiate_del_ike_sa_reply) \
5430 _(ikev2_initiate_del_child_sa_reply) \
5431 _(ikev2_initiate_rekey_child_sa_reply) \
5432 _(delete_loopback_reply) \
5433 _(bd_ip_mac_add_del_reply) \
5434 _(want_interface_events_reply) \
5435 _(want_stats_reply) \
5436 _(cop_interface_enable_disable_reply) \
5437 _(cop_whitelist_enable_disable_reply) \
5438 _(sw_interface_clear_stats_reply) \
5439 _(ioam_enable_reply) \
5440 _(ioam_disable_reply) \
5441 _(one_add_del_locator_reply) \
5442 _(one_add_del_local_eid_reply) \
5443 _(one_add_del_remote_mapping_reply) \
5444 _(one_add_del_adjacency_reply) \
5445 _(one_add_del_map_resolver_reply) \
5446 _(one_add_del_map_server_reply) \
5447 _(one_enable_disable_reply) \
5448 _(one_rloc_probe_enable_disable_reply) \
5449 _(one_map_register_enable_disable_reply) \
5450 _(one_map_register_set_ttl_reply) \
5451 _(one_set_transport_protocol_reply) \
5452 _(one_map_register_fallback_threshold_reply) \
5453 _(one_pitr_set_locator_set_reply) \
5454 _(one_map_request_mode_reply) \
5455 _(one_add_del_map_request_itr_rlocs_reply) \
5456 _(one_eid_table_add_del_map_reply) \
5457 _(one_use_petr_reply) \
5458 _(one_stats_enable_disable_reply) \
5459 _(one_add_del_l2_arp_entry_reply) \
5460 _(one_add_del_ndp_entry_reply) \
5461 _(one_stats_flush_reply) \
5462 _(one_enable_disable_xtr_mode_reply) \
5463 _(one_enable_disable_pitr_mode_reply) \
5464 _(one_enable_disable_petr_mode_reply) \
5465 _(gpe_enable_disable_reply) \
5466 _(gpe_set_encap_mode_reply) \
5467 _(gpe_add_del_iface_reply) \
5468 _(gpe_add_del_native_fwd_rpath_reply) \
5469 _(af_packet_delete_reply) \
5470 _(policer_classify_set_interface_reply) \
5471 _(netmap_create_reply) \
5472 _(netmap_delete_reply) \
5473 _(set_ipfix_exporter_reply) \
5474 _(set_ipfix_classify_stream_reply) \
5475 _(ipfix_classify_table_add_del_reply) \
5476 _(flow_classify_set_interface_reply) \
5477 _(sw_interface_span_enable_disable_reply) \
5478 _(pg_capture_reply) \
5479 _(pg_enable_disable_reply) \
5480 _(ip_source_and_port_range_check_add_del_reply) \
5481 _(ip_source_and_port_range_check_interface_add_del_reply)\
5482 _(delete_subif_reply) \
5483 _(l2_interface_pbb_tag_rewrite_reply) \
5485 _(feature_enable_disable_reply) \
5486 _(sw_interface_tag_add_del_reply) \
5487 _(hw_interface_set_mtu_reply) \
5488 _(p2p_ethernet_add_reply) \
5489 _(p2p_ethernet_del_reply) \
5490 _(lldp_config_reply) \
5491 _(sw_interface_set_lldp_reply) \
5492 _(tcp_configure_src_addresses_reply) \
5493 _(dns_enable_disable_reply) \
5494 _(dns_name_server_add_del_reply) \
5495 _(session_rule_add_del_reply) \
5496 _(ip_container_proxy_add_del_reply) \
5497 _(output_acl_set_interface_reply) \
5498 _(qos_record_enable_disable_reply)
5501 static void vl_api_##n##_t_handler \
5502 (vl_api_##n##_t * mp) \
5504 vat_main_t * vam = &vat_main; \
5505 i32 retval = ntohl(mp->retval); \
5506 if (vam->async_mode) { \
5507 vam->async_errors += (retval < 0); \
5509 vam->retval = retval; \
5510 vam->result_ready = 1; \
5513 foreach_standard_reply_retval_handler;
5517 static void vl_api_##n##_t_handler_json \
5518 (vl_api_##n##_t * mp) \
5520 vat_main_t * vam = &vat_main; \
5521 vat_json_node_t node; \
5522 vat_json_init_object(&node); \
5523 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5524 vat_json_print(vam->ofp, &node); \
5525 vam->retval = ntohl(mp->retval); \
5526 vam->result_ready = 1; \
5528 foreach_standard_reply_retval_handler;
5532 * Table of message reply handlers, must include boilerplate handlers
5536 #define foreach_vpe_api_reply_msg \
5537 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5538 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5539 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5540 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5541 _(CONTROL_PING_REPLY, control_ping_reply) \
5542 _(CLI_REPLY, cli_reply) \
5543 _(CLI_INBAND_REPLY, cli_inband_reply) \
5544 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5545 sw_interface_add_del_address_reply) \
5546 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5547 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5548 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5549 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5550 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5551 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5552 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5553 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5554 sw_interface_set_l2_xconnect_reply) \
5555 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5556 sw_interface_set_l2_bridge_reply) \
5557 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5558 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5559 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5560 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5561 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5562 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5563 _(L2_FLAGS_REPLY, l2_flags_reply) \
5564 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5565 _(TAP_CONNECT_REPLY, tap_connect_reply) \
5566 _(TAP_MODIFY_REPLY, tap_modify_reply) \
5567 _(TAP_DELETE_REPLY, tap_delete_reply) \
5568 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
5569 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5570 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5571 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5572 _(BOND_CREATE_REPLY, bond_create_reply) \
5573 _(BOND_DELETE_REPLY, bond_delete_reply) \
5574 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5575 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5576 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5577 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5578 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5579 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5580 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5581 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5582 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5583 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5584 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5585 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5586 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5587 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5588 proxy_arp_intfc_enable_disable_reply) \
5589 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5590 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5591 sw_interface_set_unnumbered_reply) \
5592 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5593 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5594 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5595 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5596 _(RESET_FIB_REPLY, reset_fib_reply) \
5597 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5598 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5599 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5600 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5601 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5602 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5603 sw_interface_ip6_enable_disable_reply) \
5604 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
5605 sw_interface_ip6_set_link_local_address_reply) \
5606 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5607 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5608 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5609 sw_interface_ip6nd_ra_prefix_reply) \
5610 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5611 sw_interface_ip6nd_ra_config_reply) \
5612 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5613 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5614 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5615 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5616 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5617 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5618 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5619 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5620 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5621 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5622 classify_set_interface_ip_table_reply) \
5623 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5624 classify_set_interface_l2_tables_reply) \
5625 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5626 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5627 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5628 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5629 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5630 l2tpv3_interface_enable_disable_reply) \
5631 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5632 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5633 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5634 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5635 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5636 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5637 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5638 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5639 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5640 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5641 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5642 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5643 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5644 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5645 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5646 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5647 _(SHOW_VERSION_REPLY, show_version_reply) \
5648 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5649 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5650 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5651 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5652 _(IP_PROBE_NEIGHBOR_REPLY, ip_probe_neighbor_reply) \
5653 _(IP_SCAN_NEIGHBOR_ENABLE_DISABLE_REPLY, ip_scan_neighbor_enable_disable_reply) \
5654 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5655 _(IP4_ARP_EVENT, ip4_arp_event) \
5656 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5657 _(IP6_ND_EVENT, ip6_nd_event) \
5658 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5659 _(L2_MACS_EVENT, l2_macs_event) \
5660 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5661 _(IP_ADDRESS_DETAILS, ip_address_details) \
5662 _(IP_DETAILS, ip_details) \
5663 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5664 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5665 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
5666 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
5667 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5668 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5669 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5670 _(IPSEC_TUNNEL_IF_SET_KEY_REPLY, ipsec_tunnel_if_set_key_reply) \
5671 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5672 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
5673 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
5674 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
5675 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
5676 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
5677 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
5678 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
5679 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
5680 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
5681 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
5682 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
5683 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
5684 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
5685 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5686 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5687 _(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
5688 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5689 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5690 _(WANT_STATS_REPLY, want_stats_reply) \
5691 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5692 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5693 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5694 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5695 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5696 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5697 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5698 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5699 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5700 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5701 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5702 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5703 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5704 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5705 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5706 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5707 one_map_register_enable_disable_reply) \
5708 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5709 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5710 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5711 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5712 one_map_register_fallback_threshold_reply) \
5713 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5714 one_rloc_probe_enable_disable_reply) \
5715 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5716 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5717 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5718 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5719 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5720 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5721 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5722 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5723 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5724 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5725 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5726 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5727 _(ONE_STATS_DETAILS, one_stats_details) \
5728 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5729 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5730 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5731 show_one_stats_enable_disable_reply) \
5732 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5733 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5734 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5735 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5736 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5737 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5738 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5739 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5740 one_enable_disable_pitr_mode_reply) \
5741 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5742 one_enable_disable_petr_mode_reply) \
5743 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5744 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5745 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5746 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5747 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5748 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5749 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5750 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5751 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5752 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5753 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5754 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5755 gpe_add_del_native_fwd_rpath_reply) \
5756 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5757 gpe_fwd_entry_path_details) \
5758 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5759 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5760 one_add_del_map_request_itr_rlocs_reply) \
5761 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5762 one_get_map_request_itr_rlocs_reply) \
5763 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5764 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5765 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5766 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5767 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5768 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5769 show_one_map_register_state_reply) \
5770 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5771 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5772 show_one_map_register_fallback_threshold_reply) \
5773 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5774 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5775 _(AF_PACKET_DETAILS, af_packet_details) \
5776 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5777 _(POLICER_DETAILS, policer_details) \
5778 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5779 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5780 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5781 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5782 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5783 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5784 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5785 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5786 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5787 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5788 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5789 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5790 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5791 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5792 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5793 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5794 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5795 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5796 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5797 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5798 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5799 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5800 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5801 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5802 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5803 ip_source_and_port_range_check_add_del_reply) \
5804 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5805 ip_source_and_port_range_check_interface_add_del_reply) \
5806 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5807 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5808 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5809 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5810 _(PUNT_REPLY, punt_reply) \
5811 _(IP_FIB_DETAILS, ip_fib_details) \
5812 _(IP6_FIB_DETAILS, ip6_fib_details) \
5813 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5814 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5815 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5816 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5817 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5818 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5819 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5820 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5821 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5822 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5823 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5824 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5825 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5826 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5827 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
5828 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \
5829 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5830 _(SESSION_RULES_DETAILS, session_rules_details) \
5831 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5832 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5833 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply)
5835 #define foreach_standalone_reply_msg \
5836 _(SW_INTERFACE_EVENT, sw_interface_event) \
5837 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
5838 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
5839 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
5840 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
5841 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
5842 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters)
5850 #define STR_VTR_OP_CASE(op) \
5851 case L2_VTR_ ## op: \
5855 str_vtr_op (u32 vtr_op)
5859 STR_VTR_OP_CASE (DISABLED);
5860 STR_VTR_OP_CASE (PUSH_1);
5861 STR_VTR_OP_CASE (PUSH_2);
5862 STR_VTR_OP_CASE (POP_1);
5863 STR_VTR_OP_CASE (POP_2);
5864 STR_VTR_OP_CASE (TRANSLATE_1_1);
5865 STR_VTR_OP_CASE (TRANSLATE_1_2);
5866 STR_VTR_OP_CASE (TRANSLATE_2_1);
5867 STR_VTR_OP_CASE (TRANSLATE_2_2);
5874 dump_sub_interface_table (vat_main_t * vam)
5876 const sw_interface_subif_t *sub = NULL;
5878 if (vam->json_output)
5881 ("JSON output supported only for VPE API calls and dump_stats_table");
5886 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5887 "Interface", "sw_if_index",
5888 "sub id", "dot1ad", "tags", "outer id",
5889 "inner id", "exact", "default", "outer any", "inner any");
5891 vec_foreach (sub, vam->sw_if_subif_table)
5894 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5895 sub->interface_name,
5897 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5898 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5899 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5900 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5901 if (sub->vtr_op != L2_VTR_DISABLED)
5904 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5905 "tag1: %d tag2: %d ]",
5906 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5907 sub->vtr_tag1, sub->vtr_tag2);
5915 name_sort_cmp (void *a1, void *a2)
5917 name_sort_t *n1 = a1;
5918 name_sort_t *n2 = a2;
5920 return strcmp ((char *) n1->name, (char *) n2->name);
5924 dump_interface_table (vat_main_t * vam)
5927 name_sort_t *nses = 0, *ns;
5929 if (vam->json_output)
5932 ("JSON output supported only for VPE API calls and dump_stats_table");
5937 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5939 vec_add2 (nses, ns, 1);
5940 ns->name = (u8 *)(p->key);
5941 ns->value = (u32) p->value[0];
5945 vec_sort_with_function (nses, name_sort_cmp);
5947 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5948 vec_foreach (ns, nses)
5950 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5957 dump_ip_table (vat_main_t * vam, int is_ipv6)
5959 const ip_details_t *det = NULL;
5960 const ip_address_details_t *address = NULL;
5963 print (vam->ofp, "%-12s", "sw_if_index");
5965 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5972 print (vam->ofp, "%-12d", i);
5973 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5978 vec_foreach (address, det->addr)
5982 is_ipv6 ? format_ip6_address : format_ip4_address,
5983 address->ip, address->prefix_length);
5991 dump_ipv4_table (vat_main_t * vam)
5993 if (vam->json_output)
5996 ("JSON output supported only for VPE API calls and dump_stats_table");
6000 return dump_ip_table (vam, 0);
6004 dump_ipv6_table (vat_main_t * vam)
6006 if (vam->json_output)
6009 ("JSON output supported only for VPE API calls and dump_stats_table");
6013 return dump_ip_table (vam, 1);
6017 counter_type_to_str (u8 counter_type, u8 is_combined)
6021 switch (counter_type)
6023 case VNET_INTERFACE_COUNTER_DROP:
6025 case VNET_INTERFACE_COUNTER_PUNT:
6027 case VNET_INTERFACE_COUNTER_IP4:
6029 case VNET_INTERFACE_COUNTER_IP6:
6031 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
6033 case VNET_INTERFACE_COUNTER_RX_MISS:
6035 case VNET_INTERFACE_COUNTER_RX_ERROR:
6037 case VNET_INTERFACE_COUNTER_TX_ERROR:
6040 return "INVALID-COUNTER-TYPE";
6045 switch (counter_type)
6047 case VNET_INTERFACE_COUNTER_RX:
6049 case VNET_INTERFACE_COUNTER_TX:
6052 return "INVALID-COUNTER-TYPE";
6058 dump_stats_table (vat_main_t * vam)
6060 vat_json_node_t node;
6061 vat_json_node_t *msg_array;
6062 vat_json_node_t *msg;
6063 vat_json_node_t *counter_array;
6064 vat_json_node_t *counter;
6065 interface_counter_t c;
6067 ip4_fib_counter_t *c4;
6068 ip6_fib_counter_t *c6;
6069 ip4_nbr_counter_t *n4;
6070 ip6_nbr_counter_t *n6;
6073 if (!vam->json_output)
6075 clib_warning ("dump_stats_table supported only in JSON format");
6079 vat_json_init_object (&node);
6081 /* interface counters */
6082 msg_array = vat_json_object_add (&node, "interface_counters");
6083 vat_json_init_array (msg_array);
6084 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
6086 msg = vat_json_array_add (msg_array);
6087 vat_json_init_object (msg);
6088 vat_json_object_add_string_copy (msg, "vnet_counter_type",
6089 (u8 *) counter_type_to_str (i, 0));
6090 vat_json_object_add_int (msg, "is_combined", 0);
6091 counter_array = vat_json_object_add (msg, "data");
6092 vat_json_init_array (counter_array);
6093 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
6095 packets = vam->simple_interface_counters[i][j];
6096 vat_json_array_add_uint (counter_array, packets);
6099 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
6101 msg = vat_json_array_add (msg_array);
6102 vat_json_init_object (msg);
6103 vat_json_object_add_string_copy (msg, "vnet_counter_type",
6104 (u8 *) counter_type_to_str (i, 1));
6105 vat_json_object_add_int (msg, "is_combined", 1);
6106 counter_array = vat_json_object_add (msg, "data");
6107 vat_json_init_array (counter_array);
6108 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
6110 c = vam->combined_interface_counters[i][j];
6111 counter = vat_json_array_add (counter_array);
6112 vat_json_init_object (counter);
6113 vat_json_object_add_uint (counter, "packets", c.packets);
6114 vat_json_object_add_uint (counter, "bytes", c.bytes);
6118 /* ip4 fib counters */
6119 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
6120 vat_json_init_array (msg_array);
6121 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
6123 msg = vat_json_array_add (msg_array);
6124 vat_json_init_object (msg);
6125 vat_json_object_add_uint (msg, "vrf_id",
6126 vam->ip4_fib_counters_vrf_id_by_index[i]);
6127 counter_array = vat_json_object_add (msg, "c");
6128 vat_json_init_array (counter_array);
6129 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
6131 counter = vat_json_array_add (counter_array);
6132 vat_json_init_object (counter);
6133 c4 = &vam->ip4_fib_counters[i][j];
6134 vat_json_object_add_ip4 (counter, "address", c4->address);
6135 vat_json_object_add_uint (counter, "address_length",
6136 c4->address_length);
6137 vat_json_object_add_uint (counter, "packets", c4->packets);
6138 vat_json_object_add_uint (counter, "bytes", c4->bytes);
6142 /* ip6 fib counters */
6143 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
6144 vat_json_init_array (msg_array);
6145 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
6147 msg = vat_json_array_add (msg_array);
6148 vat_json_init_object (msg);
6149 vat_json_object_add_uint (msg, "vrf_id",
6150 vam->ip6_fib_counters_vrf_id_by_index[i]);
6151 counter_array = vat_json_object_add (msg, "c");
6152 vat_json_init_array (counter_array);
6153 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
6155 counter = vat_json_array_add (counter_array);
6156 vat_json_init_object (counter);
6157 c6 = &vam->ip6_fib_counters[i][j];
6158 vat_json_object_add_ip6 (counter, "address", c6->address);
6159 vat_json_object_add_uint (counter, "address_length",
6160 c6->address_length);
6161 vat_json_object_add_uint (counter, "packets", c6->packets);
6162 vat_json_object_add_uint (counter, "bytes", c6->bytes);
6166 /* ip4 nbr counters */
6167 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
6168 vat_json_init_array (msg_array);
6169 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
6171 msg = vat_json_array_add (msg_array);
6172 vat_json_init_object (msg);
6173 vat_json_object_add_uint (msg, "sw_if_index", i);
6174 counter_array = vat_json_object_add (msg, "c");
6175 vat_json_init_array (counter_array);
6176 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
6178 counter = vat_json_array_add (counter_array);
6179 vat_json_init_object (counter);
6180 n4 = &vam->ip4_nbr_counters[i][j];
6181 vat_json_object_add_ip4 (counter, "address", n4->address);
6182 vat_json_object_add_uint (counter, "link-type", n4->linkt);
6183 vat_json_object_add_uint (counter, "packets", n4->packets);
6184 vat_json_object_add_uint (counter, "bytes", n4->bytes);
6188 /* ip6 nbr counters */
6189 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
6190 vat_json_init_array (msg_array);
6191 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
6193 msg = vat_json_array_add (msg_array);
6194 vat_json_init_object (msg);
6195 vat_json_object_add_uint (msg, "sw_if_index", i);
6196 counter_array = vat_json_object_add (msg, "c");
6197 vat_json_init_array (counter_array);
6198 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
6200 counter = vat_json_array_add (counter_array);
6201 vat_json_init_object (counter);
6202 n6 = &vam->ip6_nbr_counters[i][j];
6203 vat_json_object_add_ip6 (counter, "address", n6->address);
6204 vat_json_object_add_uint (counter, "packets", n6->packets);
6205 vat_json_object_add_uint (counter, "bytes", n6->bytes);
6209 vat_json_print (vam->ofp, &node);
6210 vat_json_free (&node);
6216 * Pass CLI buffers directly in the CLI_INBAND API message,
6217 * instead of an additional shared memory area.
6220 exec_inband (vat_main_t * vam)
6222 vl_api_cli_inband_t *mp;
6223 unformat_input_t *i = vam->input;
6226 if (vec_len (i->buffer) == 0)
6229 if (vam->exec_mode == 0 && unformat (i, "mode"))
6234 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
6241 * In order for the CLI command to work, it
6242 * must be a vector ending in \n, not a C-string ending
6245 u32 len = vec_len (vam->input->buffer);
6246 M2 (CLI_INBAND, mp, len);
6247 clib_memcpy (mp->cmd, vam->input->buffer, len);
6248 mp->length = htonl (len);
6252 /* json responses may or may not include a useful reply... */
6253 if (vec_len (vam->cmd_reply))
6254 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
6259 exec (vat_main_t * vam)
6261 return exec_inband (vam);
6265 api_create_loopback (vat_main_t * vam)
6267 unformat_input_t *i = vam->input;
6268 vl_api_create_loopback_t *mp;
6269 vl_api_create_loopback_instance_t *mp_lbi;
6272 u8 is_specified = 0;
6273 u32 user_instance = 0;
6276 memset (mac_address, 0, sizeof (mac_address));
6278 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6280 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6282 if (unformat (i, "instance %d", &user_instance))
6290 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
6291 mp_lbi->is_specified = is_specified;
6293 mp_lbi->user_instance = htonl (user_instance);
6295 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
6300 /* Construct the API message */
6301 M (CREATE_LOOPBACK, mp);
6303 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
6312 api_delete_loopback (vat_main_t * vam)
6314 unformat_input_t *i = vam->input;
6315 vl_api_delete_loopback_t *mp;
6316 u32 sw_if_index = ~0;
6319 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6321 if (unformat (i, "sw_if_index %d", &sw_if_index))
6327 if (sw_if_index == ~0)
6329 errmsg ("missing sw_if_index");
6333 /* Construct the API message */
6334 M (DELETE_LOOPBACK, mp);
6335 mp->sw_if_index = ntohl (sw_if_index);
6343 api_want_stats (vat_main_t * vam)
6345 unformat_input_t *i = vam->input;
6346 vl_api_want_stats_t *mp;
6350 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6352 if (unformat (i, "enable"))
6354 else if (unformat (i, "disable"))
6362 errmsg ("missing enable|disable");
6367 mp->enable_disable = enable;
6375 api_want_interface_events (vat_main_t * vam)
6377 unformat_input_t *i = vam->input;
6378 vl_api_want_interface_events_t *mp;
6382 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6384 if (unformat (i, "enable"))
6386 else if (unformat (i, "disable"))
6394 errmsg ("missing enable|disable");
6398 M (WANT_INTERFACE_EVENTS, mp);
6399 mp->enable_disable = enable;
6401 vam->interface_event_display = enable;
6409 /* Note: non-static, called once to set up the initial intfc table */
6411 api_sw_interface_dump (vat_main_t * vam)
6413 vl_api_sw_interface_dump_t *mp;
6414 vl_api_control_ping_t *mp_ping;
6416 name_sort_t *nses = 0, *ns;
6417 sw_interface_subif_t *sub = NULL;
6420 /* Toss the old name table */
6422 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6424 vec_add2 (nses, ns, 1);
6425 ns->name = (u8 *)(p->key);
6426 ns->value = (u32) p->value[0];
6430 hash_free (vam->sw_if_index_by_interface_name);
6432 vec_foreach (ns, nses) vec_free (ns->name);
6436 vec_foreach (sub, vam->sw_if_subif_table)
6438 vec_free (sub->interface_name);
6440 vec_free (vam->sw_if_subif_table);
6442 /* recreate the interface name hash table */
6443 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
6446 * Ask for all interface names. Otherwise, the epic catalog of
6447 * name filters becomes ridiculously long, and vat ends up needing
6448 * to be taught about new interface types.
6450 M (SW_INTERFACE_DUMP, mp);
6453 /* Use a control ping for synchronization */
6454 MPING (CONTROL_PING, mp_ping);
6462 api_sw_interface_set_flags (vat_main_t * vam)
6464 unformat_input_t *i = vam->input;
6465 vl_api_sw_interface_set_flags_t *mp;
6467 u8 sw_if_index_set = 0;
6471 /* Parse args required to build the message */
6472 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6474 if (unformat (i, "admin-up"))
6476 else if (unformat (i, "admin-down"))
6479 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6480 sw_if_index_set = 1;
6481 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6482 sw_if_index_set = 1;
6487 if (sw_if_index_set == 0)
6489 errmsg ("missing interface name or sw_if_index");
6493 /* Construct the API message */
6494 M (SW_INTERFACE_SET_FLAGS, mp);
6495 mp->sw_if_index = ntohl (sw_if_index);
6496 mp->admin_up_down = admin_up;
6501 /* Wait for a reply, return the good/bad news... */
6507 api_sw_interface_set_rx_mode (vat_main_t * vam)
6509 unformat_input_t *i = vam->input;
6510 vl_api_sw_interface_set_rx_mode_t *mp;
6512 u8 sw_if_index_set = 0;
6514 u8 queue_id_valid = 0;
6516 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
6518 /* Parse args required to build the message */
6519 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6521 if (unformat (i, "queue %d", &queue_id))
6523 else if (unformat (i, "polling"))
6524 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
6525 else if (unformat (i, "interrupt"))
6526 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
6527 else if (unformat (i, "adaptive"))
6528 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
6530 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6531 sw_if_index_set = 1;
6532 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6533 sw_if_index_set = 1;
6538 if (sw_if_index_set == 0)
6540 errmsg ("missing interface name or sw_if_index");
6543 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6545 errmsg ("missing rx-mode");
6549 /* Construct the API message */
6550 M (SW_INTERFACE_SET_RX_MODE, mp);
6551 mp->sw_if_index = ntohl (sw_if_index);
6553 mp->queue_id_valid = queue_id_valid;
6554 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6559 /* Wait for a reply, return the good/bad news... */
6565 api_sw_interface_clear_stats (vat_main_t * vam)
6567 unformat_input_t *i = vam->input;
6568 vl_api_sw_interface_clear_stats_t *mp;
6570 u8 sw_if_index_set = 0;
6573 /* Parse args required to build the message */
6574 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6576 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6577 sw_if_index_set = 1;
6578 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6579 sw_if_index_set = 1;
6584 /* Construct the API message */
6585 M (SW_INTERFACE_CLEAR_STATS, mp);
6587 if (sw_if_index_set == 1)
6588 mp->sw_if_index = ntohl (sw_if_index);
6590 mp->sw_if_index = ~0;
6595 /* Wait for a reply, return the good/bad news... */
6601 api_sw_interface_add_del_address (vat_main_t * vam)
6603 unformat_input_t *i = vam->input;
6604 vl_api_sw_interface_add_del_address_t *mp;
6606 u8 sw_if_index_set = 0;
6607 u8 is_add = 1, del_all = 0;
6608 u32 address_length = 0;
6609 u8 v4_address_set = 0;
6610 u8 v6_address_set = 0;
6611 ip4_address_t v4address;
6612 ip6_address_t v6address;
6615 /* Parse args required to build the message */
6616 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6618 if (unformat (i, "del-all"))
6620 else if (unformat (i, "del"))
6623 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6624 sw_if_index_set = 1;
6625 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6626 sw_if_index_set = 1;
6627 else if (unformat (i, "%U/%d",
6628 unformat_ip4_address, &v4address, &address_length))
6630 else if (unformat (i, "%U/%d",
6631 unformat_ip6_address, &v6address, &address_length))
6637 if (sw_if_index_set == 0)
6639 errmsg ("missing interface name or sw_if_index");
6642 if (v4_address_set && v6_address_set)
6644 errmsg ("both v4 and v6 addresses set");
6647 if (!v4_address_set && !v6_address_set && !del_all)
6649 errmsg ("no addresses set");
6653 /* Construct the API message */
6654 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6656 mp->sw_if_index = ntohl (sw_if_index);
6657 mp->is_add = is_add;
6658 mp->del_all = del_all;
6662 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6666 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6668 mp->address_length = address_length;
6673 /* Wait for a reply, return good/bad news */
6679 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6681 unformat_input_t *i = vam->input;
6682 vl_api_sw_interface_set_mpls_enable_t *mp;
6684 u8 sw_if_index_set = 0;
6688 /* Parse args required to build the message */
6689 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6691 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6692 sw_if_index_set = 1;
6693 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6694 sw_if_index_set = 1;
6695 else if (unformat (i, "disable"))
6697 else if (unformat (i, "dis"))
6703 if (sw_if_index_set == 0)
6705 errmsg ("missing interface name or sw_if_index");
6709 /* Construct the API message */
6710 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6712 mp->sw_if_index = ntohl (sw_if_index);
6713 mp->enable = enable;
6718 /* Wait for a reply... */
6724 api_sw_interface_set_table (vat_main_t * vam)
6726 unformat_input_t *i = vam->input;
6727 vl_api_sw_interface_set_table_t *mp;
6728 u32 sw_if_index, vrf_id = 0;
6729 u8 sw_if_index_set = 0;
6733 /* Parse args required to build the message */
6734 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6736 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6737 sw_if_index_set = 1;
6738 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6739 sw_if_index_set = 1;
6740 else if (unformat (i, "vrf %d", &vrf_id))
6742 else if (unformat (i, "ipv6"))
6748 if (sw_if_index_set == 0)
6750 errmsg ("missing interface name or sw_if_index");
6754 /* Construct the API message */
6755 M (SW_INTERFACE_SET_TABLE, mp);
6757 mp->sw_if_index = ntohl (sw_if_index);
6758 mp->is_ipv6 = is_ipv6;
6759 mp->vrf_id = ntohl (vrf_id);
6764 /* Wait for a reply... */
6769 static void vl_api_sw_interface_get_table_reply_t_handler
6770 (vl_api_sw_interface_get_table_reply_t * mp)
6772 vat_main_t *vam = &vat_main;
6774 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6776 vam->retval = ntohl (mp->retval);
6777 vam->result_ready = 1;
6781 static void vl_api_sw_interface_get_table_reply_t_handler_json
6782 (vl_api_sw_interface_get_table_reply_t * mp)
6784 vat_main_t *vam = &vat_main;
6785 vat_json_node_t node;
6787 vat_json_init_object (&node);
6788 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6789 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6791 vat_json_print (vam->ofp, &node);
6792 vat_json_free (&node);
6794 vam->retval = ntohl (mp->retval);
6795 vam->result_ready = 1;
6799 api_sw_interface_get_table (vat_main_t * vam)
6801 unformat_input_t *i = vam->input;
6802 vl_api_sw_interface_get_table_t *mp;
6804 u8 sw_if_index_set = 0;
6808 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6810 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6811 sw_if_index_set = 1;
6812 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6813 sw_if_index_set = 1;
6814 else if (unformat (i, "ipv6"))
6820 if (sw_if_index_set == 0)
6822 errmsg ("missing interface name or sw_if_index");
6826 M (SW_INTERFACE_GET_TABLE, mp);
6827 mp->sw_if_index = htonl (sw_if_index);
6828 mp->is_ipv6 = is_ipv6;
6836 api_sw_interface_set_vpath (vat_main_t * vam)
6838 unformat_input_t *i = vam->input;
6839 vl_api_sw_interface_set_vpath_t *mp;
6840 u32 sw_if_index = 0;
6841 u8 sw_if_index_set = 0;
6845 /* Parse args required to build the message */
6846 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6848 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6849 sw_if_index_set = 1;
6850 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6851 sw_if_index_set = 1;
6852 else if (unformat (i, "enable"))
6854 else if (unformat (i, "disable"))
6860 if (sw_if_index_set == 0)
6862 errmsg ("missing interface name or sw_if_index");
6866 /* Construct the API message */
6867 M (SW_INTERFACE_SET_VPATH, mp);
6869 mp->sw_if_index = ntohl (sw_if_index);
6870 mp->enable = is_enable;
6875 /* Wait for a reply... */
6881 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6883 unformat_input_t *i = vam->input;
6884 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6885 u32 sw_if_index = 0;
6886 u8 sw_if_index_set = 0;
6891 /* Parse args required to build the message */
6892 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6894 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6895 sw_if_index_set = 1;
6896 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6897 sw_if_index_set = 1;
6898 else if (unformat (i, "enable"))
6900 else if (unformat (i, "disable"))
6902 else if (unformat (i, "ip4"))
6904 else if (unformat (i, "ip6"))
6910 if (sw_if_index_set == 0)
6912 errmsg ("missing interface name or sw_if_index");
6916 /* Construct the API message */
6917 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6919 mp->sw_if_index = ntohl (sw_if_index);
6920 mp->enable = is_enable;
6921 mp->is_ipv6 = is_ipv6;
6926 /* Wait for a reply... */
6932 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6934 unformat_input_t *i = vam->input;
6935 vl_api_sw_interface_set_geneve_bypass_t *mp;
6936 u32 sw_if_index = 0;
6937 u8 sw_if_index_set = 0;
6942 /* Parse args required to build the message */
6943 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6945 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6946 sw_if_index_set = 1;
6947 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6948 sw_if_index_set = 1;
6949 else if (unformat (i, "enable"))
6951 else if (unformat (i, "disable"))
6953 else if (unformat (i, "ip4"))
6955 else if (unformat (i, "ip6"))
6961 if (sw_if_index_set == 0)
6963 errmsg ("missing interface name or sw_if_index");
6967 /* Construct the API message */
6968 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6970 mp->sw_if_index = ntohl (sw_if_index);
6971 mp->enable = is_enable;
6972 mp->is_ipv6 = is_ipv6;
6977 /* Wait for a reply... */
6983 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6985 unformat_input_t *i = vam->input;
6986 vl_api_sw_interface_set_l2_xconnect_t *mp;
6988 u8 rx_sw_if_index_set = 0;
6990 u8 tx_sw_if_index_set = 0;
6994 /* Parse args required to build the message */
6995 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6997 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6998 rx_sw_if_index_set = 1;
6999 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
7000 tx_sw_if_index_set = 1;
7001 else if (unformat (i, "rx"))
7003 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7005 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7007 rx_sw_if_index_set = 1;
7012 else if (unformat (i, "tx"))
7014 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7016 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7018 tx_sw_if_index_set = 1;
7023 else if (unformat (i, "enable"))
7025 else if (unformat (i, "disable"))
7031 if (rx_sw_if_index_set == 0)
7033 errmsg ("missing rx interface name or rx_sw_if_index");
7037 if (enable && (tx_sw_if_index_set == 0))
7039 errmsg ("missing tx interface name or tx_sw_if_index");
7043 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
7045 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7046 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
7047 mp->enable = enable;
7055 api_sw_interface_set_l2_bridge (vat_main_t * vam)
7057 unformat_input_t *i = vam->input;
7058 vl_api_sw_interface_set_l2_bridge_t *mp;
7060 u8 rx_sw_if_index_set = 0;
7068 /* Parse args required to build the message */
7069 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7071 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
7072 rx_sw_if_index_set = 1;
7073 else if (unformat (i, "bd_id %d", &bd_id))
7077 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
7078 rx_sw_if_index_set = 1;
7079 else if (unformat (i, "shg %d", &shg))
7081 else if (unformat (i, "bvi"))
7083 else if (unformat (i, "enable"))
7085 else if (unformat (i, "disable"))
7091 if (rx_sw_if_index_set == 0)
7093 errmsg ("missing rx interface name or sw_if_index");
7097 if (enable && (bd_id_set == 0))
7099 errmsg ("missing bridge domain");
7103 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
7105 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7106 mp->bd_id = ntohl (bd_id);
7109 mp->enable = enable;
7117 api_bridge_domain_dump (vat_main_t * vam)
7119 unformat_input_t *i = vam->input;
7120 vl_api_bridge_domain_dump_t *mp;
7121 vl_api_control_ping_t *mp_ping;
7125 /* Parse args required to build the message */
7126 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7128 if (unformat (i, "bd_id %d", &bd_id))
7134 M (BRIDGE_DOMAIN_DUMP, mp);
7135 mp->bd_id = ntohl (bd_id);
7138 /* Use a control ping for synchronization */
7139 MPING (CONTROL_PING, mp_ping);
7147 api_bridge_domain_add_del (vat_main_t * vam)
7149 unformat_input_t *i = vam->input;
7150 vl_api_bridge_domain_add_del_t *mp;
7153 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
7158 /* Parse args required to build the message */
7159 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7161 if (unformat (i, "bd_id %d", &bd_id))
7163 else if (unformat (i, "flood %d", &flood))
7165 else if (unformat (i, "uu-flood %d", &uu_flood))
7167 else if (unformat (i, "forward %d", &forward))
7169 else if (unformat (i, "learn %d", &learn))
7171 else if (unformat (i, "arp-term %d", &arp_term))
7173 else if (unformat (i, "mac-age %d", &mac_age))
7175 else if (unformat (i, "bd-tag %s", &bd_tag))
7177 else if (unformat (i, "del"))
7180 flood = uu_flood = forward = learn = 0;
7188 errmsg ("missing bridge domain");
7195 errmsg ("mac age must be less than 256 ");
7200 if ((bd_tag) && (vec_len (bd_tag) > 63))
7202 errmsg ("bd-tag cannot be longer than 63");
7207 M (BRIDGE_DOMAIN_ADD_DEL, mp);
7209 mp->bd_id = ntohl (bd_id);
7211 mp->uu_flood = uu_flood;
7212 mp->forward = forward;
7214 mp->arp_term = arp_term;
7215 mp->is_add = is_add;
7216 mp->mac_age = (u8) mac_age;
7219 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
7220 mp->bd_tag[vec_len (bd_tag)] = 0;
7231 api_l2fib_flush_bd (vat_main_t * vam)
7233 unformat_input_t *i = vam->input;
7234 vl_api_l2fib_flush_bd_t *mp;
7238 /* Parse args required to build the message */
7239 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7241 if (unformat (i, "bd_id %d", &bd_id));
7248 errmsg ("missing bridge domain");
7252 M (L2FIB_FLUSH_BD, mp);
7254 mp->bd_id = htonl (bd_id);
7262 api_l2fib_flush_int (vat_main_t * vam)
7264 unformat_input_t *i = vam->input;
7265 vl_api_l2fib_flush_int_t *mp;
7266 u32 sw_if_index = ~0;
7269 /* Parse args required to build the message */
7270 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7272 if (unformat (i, "sw_if_index %d", &sw_if_index));
7274 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
7279 if (sw_if_index == ~0)
7281 errmsg ("missing interface name or sw_if_index");
7285 M (L2FIB_FLUSH_INT, mp);
7287 mp->sw_if_index = ntohl (sw_if_index);
7295 api_l2fib_add_del (vat_main_t * vam)
7297 unformat_input_t *i = vam->input;
7298 vl_api_l2fib_add_del_t *mp;
7304 u32 sw_if_index = 0;
7305 u8 sw_if_index_set = 0;
7314 /* Parse args required to build the message */
7315 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7317 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
7319 else if (unformat (i, "bd_id %d", &bd_id))
7321 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7322 sw_if_index_set = 1;
7323 else if (unformat (i, "sw_if"))
7325 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7328 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7329 sw_if_index_set = 1;
7334 else if (unformat (i, "static"))
7336 else if (unformat (i, "filter"))
7341 else if (unformat (i, "bvi"))
7346 else if (unformat (i, "del"))
7348 else if (unformat (i, "count %d", &count))
7356 errmsg ("missing mac address");
7362 errmsg ("missing bridge domain");
7366 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7368 errmsg ("missing interface name or sw_if_index");
7374 /* Turn on async mode */
7375 vam->async_mode = 1;
7376 vam->async_errors = 0;
7377 before = vat_time_now (vam);
7380 for (j = 0; j < count; j++)
7382 M (L2FIB_ADD_DEL, mp);
7384 clib_memcpy (mp->mac, mac, 6);
7385 mp->bd_id = ntohl (bd_id);
7386 mp->is_add = is_add;
7387 mp->sw_if_index = ntohl (sw_if_index);
7391 mp->static_mac = static_mac;
7392 mp->filter_mac = filter_mac;
7393 mp->bvi_mac = bvi_mac;
7395 increment_mac_address (mac);
7402 vl_api_control_ping_t *mp_ping;
7405 /* Shut off async mode */
7406 vam->async_mode = 0;
7408 MPING (CONTROL_PING, mp_ping);
7411 timeout = vat_time_now (vam) + 1.0;
7412 while (vat_time_now (vam) < timeout)
7413 if (vam->result_ready == 1)
7418 if (vam->retval == -99)
7421 if (vam->async_errors > 0)
7423 errmsg ("%d asynchronous errors", vam->async_errors);
7426 vam->async_errors = 0;
7427 after = vat_time_now (vam);
7429 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7430 count, after - before, count / (after - before));
7436 /* Wait for a reply... */
7440 /* Return the good/bad news */
7441 return (vam->retval);
7445 api_bridge_domain_set_mac_age (vat_main_t * vam)
7447 unformat_input_t *i = vam->input;
7448 vl_api_bridge_domain_set_mac_age_t *mp;
7453 /* Parse args required to build the message */
7454 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7456 if (unformat (i, "bd_id %d", &bd_id));
7457 else if (unformat (i, "mac-age %d", &mac_age));
7464 errmsg ("missing bridge domain");
7470 errmsg ("mac age must be less than 256 ");
7474 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7476 mp->bd_id = htonl (bd_id);
7477 mp->mac_age = (u8) mac_age;
7485 api_l2_flags (vat_main_t * vam)
7487 unformat_input_t *i = vam->input;
7488 vl_api_l2_flags_t *mp;
7491 u8 sw_if_index_set = 0;
7495 /* Parse args required to build the message */
7496 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7498 if (unformat (i, "sw_if_index %d", &sw_if_index))
7499 sw_if_index_set = 1;
7500 else if (unformat (i, "sw_if"))
7502 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7505 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7506 sw_if_index_set = 1;
7511 else if (unformat (i, "learn"))
7513 else if (unformat (i, "forward"))
7515 else if (unformat (i, "flood"))
7517 else if (unformat (i, "uu-flood"))
7518 flags |= L2_UU_FLOOD;
7519 else if (unformat (i, "arp-term"))
7520 flags |= L2_ARP_TERM;
7521 else if (unformat (i, "off"))
7523 else if (unformat (i, "disable"))
7529 if (sw_if_index_set == 0)
7531 errmsg ("missing interface name or sw_if_index");
7537 mp->sw_if_index = ntohl (sw_if_index);
7538 mp->feature_bitmap = ntohl (flags);
7539 mp->is_set = is_set;
7547 api_bridge_flags (vat_main_t * vam)
7549 unformat_input_t *i = vam->input;
7550 vl_api_bridge_flags_t *mp;
7557 /* Parse args required to build the message */
7558 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7560 if (unformat (i, "bd_id %d", &bd_id))
7562 else if (unformat (i, "learn"))
7564 else if (unformat (i, "forward"))
7566 else if (unformat (i, "flood"))
7568 else if (unformat (i, "uu-flood"))
7569 flags |= L2_UU_FLOOD;
7570 else if (unformat (i, "arp-term"))
7571 flags |= L2_ARP_TERM;
7572 else if (unformat (i, "off"))
7574 else if (unformat (i, "disable"))
7582 errmsg ("missing bridge domain");
7586 M (BRIDGE_FLAGS, mp);
7588 mp->bd_id = ntohl (bd_id);
7589 mp->feature_bitmap = ntohl (flags);
7590 mp->is_set = is_set;
7598 api_bd_ip_mac_add_del (vat_main_t * vam)
7600 unformat_input_t *i = vam->input;
7601 vl_api_bd_ip_mac_add_del_t *mp;
7608 ip4_address_t v4addr;
7609 ip6_address_t v6addr;
7614 /* Parse args required to build the message */
7615 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7617 if (unformat (i, "bd_id %d", &bd_id))
7621 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
7625 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
7630 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
7634 else if (unformat (i, "del"))
7642 errmsg ("missing bridge domain");
7645 else if (ip_set == 0)
7647 errmsg ("missing IP address");
7650 else if (mac_set == 0)
7652 errmsg ("missing MAC address");
7656 M (BD_IP_MAC_ADD_DEL, mp);
7658 mp->bd_id = ntohl (bd_id);
7659 mp->is_ipv6 = is_ipv6;
7660 mp->is_add = is_add;
7662 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
7664 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
7665 clib_memcpy (mp->mac_address, macaddr, 6);
7671 static void vl_api_bd_ip_mac_details_t_handler
7672 (vl_api_bd_ip_mac_details_t * mp)
7674 vat_main_t *vam = &vat_main;
7679 format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
7682 format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
7685 "\n%-5d %-7s %-20U %-30s",
7686 ntohl (mp->bd_id), mp->is_ipv6 ? "ip6" : "ip4",
7687 format_ethernet_address, mp->mac_address, ip);
7692 static void vl_api_bd_ip_mac_details_t_handler_json
7693 (vl_api_bd_ip_mac_details_t * mp)
7695 vat_main_t *vam = &vat_main;
7696 vat_json_node_t *node = NULL;
7698 if (VAT_JSON_ARRAY != vam->json_tree.type)
7700 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7701 vat_json_init_array (&vam->json_tree);
7703 node = vat_json_array_add (&vam->json_tree);
7705 vat_json_init_object (node);
7706 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
7707 vat_json_object_add_uint (node, "is_ipv6", ntohl (mp->is_ipv6));
7708 vat_json_object_add_string_copy (node, "mac_address",
7709 format (0, "%U", format_ethernet_address,
7715 format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
7718 format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
7719 vat_json_object_add_string_copy (node, "ip_address", ip);
7724 api_bd_ip_mac_dump (vat_main_t * vam)
7726 unformat_input_t *i = vam->input;
7727 vl_api_bd_ip_mac_dump_t *mp;
7728 vl_api_control_ping_t *mp_ping;
7733 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7735 if (unformat (i, "bd_id %d", &bd_id))
7744 "\n%-5s %-7s %-20s %-30s",
7745 "bd_id", "is_ipv6", "mac_address", "ip_address");
7747 /* Dump Bridge Domain Ip to Mac entries */
7748 M (BD_IP_MAC_DUMP, mp);
7751 mp->bd_id = htonl (bd_id);
7757 /* Use a control ping for synchronization */
7758 MPING (CONTROL_PING, mp_ping);
7766 api_tap_connect (vat_main_t * vam)
7768 unformat_input_t *i = vam->input;
7769 vl_api_tap_connect_t *mp;
7775 ip4_address_t ip4_address;
7777 int ip4_address_set = 0;
7778 ip6_address_t ip6_address;
7780 int ip6_address_set = 0;
7783 memset (mac_address, 0, sizeof (mac_address));
7785 /* Parse args required to build the message */
7786 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7788 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7792 else if (unformat (i, "random-mac"))
7794 else if (unformat (i, "tapname %s", &tap_name))
7796 else if (unformat (i, "tag %s", &tag))
7798 else if (unformat (i, "address %U/%d",
7799 unformat_ip4_address, &ip4_address, &ip4_mask_width))
7800 ip4_address_set = 1;
7801 else if (unformat (i, "address %U/%d",
7802 unformat_ip6_address, &ip6_address, &ip6_mask_width))
7803 ip6_address_set = 1;
7810 errmsg ("missing tap name");
7813 if (vec_len (tap_name) > 63)
7815 errmsg ("tap name too long");
7818 vec_add1 (tap_name, 0);
7820 if (vec_len (tag) > 63)
7822 errmsg ("tag too long");
7826 /* Construct the API message */
7827 M (TAP_CONNECT, mp);
7829 mp->use_random_mac = random_mac;
7830 clib_memcpy (mp->mac_address, mac_address, 6);
7831 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7833 clib_memcpy (mp->tag, tag, vec_len (tag));
7835 if (ip4_address_set)
7837 mp->ip4_address_set = 1;
7838 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
7839 mp->ip4_mask_width = ip4_mask_width;
7841 if (ip6_address_set)
7843 mp->ip6_address_set = 1;
7844 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
7845 mp->ip6_mask_width = ip6_mask_width;
7848 vec_free (tap_name);
7854 /* Wait for a reply... */
7860 api_tap_modify (vat_main_t * vam)
7862 unformat_input_t *i = vam->input;
7863 vl_api_tap_modify_t *mp;
7868 u32 sw_if_index = ~0;
7869 u8 sw_if_index_set = 0;
7872 memset (mac_address, 0, sizeof (mac_address));
7874 /* Parse args required to build the message */
7875 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7877 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7878 sw_if_index_set = 1;
7879 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7880 sw_if_index_set = 1;
7881 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7885 else if (unformat (i, "random-mac"))
7887 else if (unformat (i, "tapname %s", &tap_name))
7893 if (sw_if_index_set == 0)
7895 errmsg ("missing vpp interface name");
7900 errmsg ("missing tap name");
7903 if (vec_len (tap_name) > 63)
7905 errmsg ("tap name too long");
7907 vec_add1 (tap_name, 0);
7909 /* Construct the API message */
7912 mp->use_random_mac = random_mac;
7913 mp->sw_if_index = ntohl (sw_if_index);
7914 clib_memcpy (mp->mac_address, mac_address, 6);
7915 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7916 vec_free (tap_name);
7921 /* Wait for a reply... */
7927 api_tap_delete (vat_main_t * vam)
7929 unformat_input_t *i = vam->input;
7930 vl_api_tap_delete_t *mp;
7931 u32 sw_if_index = ~0;
7932 u8 sw_if_index_set = 0;
7935 /* Parse args required to build the message */
7936 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7938 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7939 sw_if_index_set = 1;
7940 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7941 sw_if_index_set = 1;
7946 if (sw_if_index_set == 0)
7948 errmsg ("missing vpp interface name");
7952 /* Construct the API message */
7955 mp->sw_if_index = ntohl (sw_if_index);
7960 /* Wait for a reply... */
7966 api_tap_create_v2 (vat_main_t * vam)
7968 unformat_input_t *i = vam->input;
7969 vl_api_tap_create_v2_t *mp;
7973 u8 *host_if_name = 0;
7975 u8 host_mac_addr[6];
7976 u8 host_mac_addr_set = 0;
7977 u8 *host_bridge = 0;
7978 ip4_address_t host_ip4_addr;
7979 ip4_address_t host_ip4_gw;
7980 u8 host_ip4_gw_set = 0;
7981 u32 host_ip4_prefix_len = 0;
7982 ip6_address_t host_ip6_addr;
7983 ip6_address_t host_ip6_gw;
7984 u8 host_ip6_gw_set = 0;
7985 u32 host_ip6_prefix_len = 0;
7987 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7989 memset (mac_address, 0, sizeof (mac_address));
7991 /* Parse args required to build the message */
7992 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7994 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7998 else if (unformat (i, "id %u", &id))
8000 else if (unformat (i, "host-if-name %s", &host_if_name))
8002 else if (unformat (i, "host-ns %s", &host_ns))
8004 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
8006 host_mac_addr_set = 1;
8007 else if (unformat (i, "host-bridge %s", &host_bridge))
8009 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
8010 &host_ip4_addr, &host_ip4_prefix_len))
8012 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
8013 &host_ip6_addr, &host_ip6_prefix_len))
8015 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
8017 host_ip4_gw_set = 1;
8018 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
8020 host_ip6_gw_set = 1;
8021 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
8023 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
8029 if (vec_len (host_if_name) > 63)
8031 errmsg ("tap name too long. ");
8034 if (vec_len (host_ns) > 63)
8036 errmsg ("host name space too long. ");
8039 if (vec_len (host_bridge) > 63)
8041 errmsg ("host bridge name too long. ");
8044 if (host_ip4_prefix_len > 32)
8046 errmsg ("host ip4 prefix length not valid. ");
8049 if (host_ip6_prefix_len > 128)
8051 errmsg ("host ip6 prefix length not valid. ");
8054 if (!is_pow2 (rx_ring_sz))
8056 errmsg ("rx ring size must be power of 2. ");
8059 if (rx_ring_sz > 32768)
8061 errmsg ("rx ring size must be 32768 or lower. ");
8064 if (!is_pow2 (tx_ring_sz))
8066 errmsg ("tx ring size must be power of 2. ");
8069 if (tx_ring_sz > 32768)
8071 errmsg ("tx ring size must be 32768 or lower. ");
8075 /* Construct the API message */
8076 M (TAP_CREATE_V2, mp);
8078 mp->use_random_mac = random_mac;
8080 mp->id = ntohl (id);
8081 mp->host_namespace_set = host_ns != 0;
8082 mp->host_bridge_set = host_bridge != 0;
8083 mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
8084 mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
8085 mp->rx_ring_sz = ntohs (rx_ring_sz);
8086 mp->tx_ring_sz = ntohs (tx_ring_sz);
8088 if (random_mac == 0)
8089 clib_memcpy (mp->mac_address, mac_address, 6);
8090 if (host_mac_addr_set)
8091 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
8093 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
8095 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
8097 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
8098 if (host_ip4_prefix_len)
8099 clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
8100 if (host_ip4_prefix_len)
8101 clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
8102 if (host_ip4_gw_set)
8103 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
8104 if (host_ip6_gw_set)
8105 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
8108 vec_free (host_if_name);
8109 vec_free (host_bridge);
8114 /* Wait for a reply... */
8120 api_tap_delete_v2 (vat_main_t * vam)
8122 unformat_input_t *i = vam->input;
8123 vl_api_tap_delete_v2_t *mp;
8124 u32 sw_if_index = ~0;
8125 u8 sw_if_index_set = 0;
8128 /* Parse args required to build the message */
8129 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8131 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8132 sw_if_index_set = 1;
8133 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8134 sw_if_index_set = 1;
8139 if (sw_if_index_set == 0)
8141 errmsg ("missing vpp interface name. ");
8145 /* Construct the API message */
8146 M (TAP_DELETE_V2, mp);
8148 mp->sw_if_index = ntohl (sw_if_index);
8153 /* Wait for a reply... */
8159 api_bond_create (vat_main_t * vam)
8161 unformat_input_t *i = vam->input;
8162 vl_api_bond_create_t *mp;
8170 memset (mac_address, 0, sizeof (mac_address));
8173 /* Parse args required to build the message */
8174 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8176 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
8178 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
8179 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
8181 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
8188 if (mode_is_set == 0)
8190 errmsg ("Missing bond mode. ");
8194 /* Construct the API message */
8195 M (BOND_CREATE, mp);
8197 mp->use_custom_mac = custom_mac;
8203 clib_memcpy (mp->mac_address, mac_address, 6);
8208 /* Wait for a reply... */
8214 api_bond_delete (vat_main_t * vam)
8216 unformat_input_t *i = vam->input;
8217 vl_api_bond_delete_t *mp;
8218 u32 sw_if_index = ~0;
8219 u8 sw_if_index_set = 0;
8222 /* Parse args required to build the message */
8223 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8225 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8226 sw_if_index_set = 1;
8227 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8228 sw_if_index_set = 1;
8233 if (sw_if_index_set == 0)
8235 errmsg ("missing vpp interface name. ");
8239 /* Construct the API message */
8240 M (BOND_DELETE, mp);
8242 mp->sw_if_index = ntohl (sw_if_index);
8247 /* Wait for a reply... */
8253 api_bond_enslave (vat_main_t * vam)
8255 unformat_input_t *i = vam->input;
8256 vl_api_bond_enslave_t *mp;
8257 u32 bond_sw_if_index;
8261 u32 bond_sw_if_index_is_set = 0;
8263 u8 sw_if_index_is_set = 0;
8265 /* Parse args required to build the message */
8266 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8268 if (unformat (i, "sw_if_index %d", &sw_if_index))
8269 sw_if_index_is_set = 1;
8270 else if (unformat (i, "bond %u", &bond_sw_if_index))
8271 bond_sw_if_index_is_set = 1;
8272 else if (unformat (i, "passive %d", &is_passive))
8274 else if (unformat (i, "long-timeout %d", &is_long_timeout))
8280 if (bond_sw_if_index_is_set == 0)
8282 errmsg ("Missing bond sw_if_index. ");
8285 if (sw_if_index_is_set == 0)
8287 errmsg ("Missing slave sw_if_index. ");
8291 /* Construct the API message */
8292 M (BOND_ENSLAVE, mp);
8294 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
8295 mp->sw_if_index = ntohl (sw_if_index);
8296 mp->is_long_timeout = is_long_timeout;
8297 mp->is_passive = is_passive;
8302 /* Wait for a reply... */
8308 api_bond_detach_slave (vat_main_t * vam)
8310 unformat_input_t *i = vam->input;
8311 vl_api_bond_detach_slave_t *mp;
8312 u32 sw_if_index = ~0;
8313 u8 sw_if_index_set = 0;
8316 /* Parse args required to build the message */
8317 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8319 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8320 sw_if_index_set = 1;
8321 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8322 sw_if_index_set = 1;
8327 if (sw_if_index_set == 0)
8329 errmsg ("missing vpp interface name. ");
8333 /* Construct the API message */
8334 M (BOND_DETACH_SLAVE, mp);
8336 mp->sw_if_index = ntohl (sw_if_index);
8341 /* Wait for a reply... */
8347 api_ip_table_add_del (vat_main_t * vam)
8349 unformat_input_t *i = vam->input;
8350 vl_api_ip_table_add_del_t *mp;
8356 /* Parse args required to build the message */
8357 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8359 if (unformat (i, "ipv6"))
8361 else if (unformat (i, "del"))
8363 else if (unformat (i, "add"))
8365 else if (unformat (i, "table %d", &table_id))
8369 clib_warning ("parse error '%U'", format_unformat_error, i);
8376 errmsg ("missing table-ID");
8380 /* Construct the API message */
8381 M (IP_TABLE_ADD_DEL, mp);
8383 mp->table_id = ntohl (table_id);
8384 mp->is_ipv6 = is_ipv6;
8385 mp->is_add = is_add;
8390 /* Wait for a reply... */
8397 api_ip_add_del_route (vat_main_t * vam)
8399 unformat_input_t *i = vam->input;
8400 vl_api_ip_add_del_route_t *mp;
8401 u32 sw_if_index = ~0, vrf_id = 0;
8403 u8 is_local = 0, is_drop = 0;
8404 u8 is_unreach = 0, is_prohibit = 0;
8406 u32 next_hop_weight = 1;
8407 u8 is_multipath = 0;
8409 u8 address_length_set = 0;
8410 u32 next_hop_table_id = 0;
8411 u32 resolve_attempts = 0;
8412 u32 dst_address_length = 0;
8413 u8 next_hop_set = 0;
8414 ip4_address_t v4_dst_address, v4_next_hop_address;
8415 ip6_address_t v6_dst_address, v6_next_hop_address;
8419 u32 random_add_del = 0;
8420 u32 *random_vector = 0;
8422 u32 random_seed = 0xdeaddabe;
8423 u32 classify_table_index = ~0;
8425 u8 resolve_host = 0, resolve_attached = 0;
8426 mpls_label_t *next_hop_out_label_stack = NULL;
8427 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8428 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8430 /* Parse args required to build the message */
8431 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8433 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8435 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8437 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
8442 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
8447 else if (unformat (i, "/%d", &dst_address_length))
8449 address_length_set = 1;
8452 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
8453 &v4_next_hop_address))
8457 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
8458 &v6_next_hop_address))
8462 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
8464 else if (unformat (i, "weight %d", &next_hop_weight))
8466 else if (unformat (i, "drop"))
8470 else if (unformat (i, "null-send-unreach"))
8474 else if (unformat (i, "null-send-prohibit"))
8478 else if (unformat (i, "local"))
8482 else if (unformat (i, "classify %d", &classify_table_index))
8486 else if (unformat (i, "del"))
8488 else if (unformat (i, "add"))
8490 else if (unformat (i, "resolve-via-host"))
8492 else if (unformat (i, "resolve-via-attached"))
8493 resolve_attached = 1;
8494 else if (unformat (i, "multipath"))
8496 else if (unformat (i, "vrf %d", &vrf_id))
8498 else if (unformat (i, "count %d", &count))
8500 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
8502 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8504 else if (unformat (i, "out-label %d", &next_hop_out_label))
8505 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
8506 else if (unformat (i, "via-label %d", &next_hop_via_label))
8508 else if (unformat (i, "random"))
8510 else if (unformat (i, "seed %d", &random_seed))
8514 clib_warning ("parse error '%U'", format_unformat_error, i);
8519 if (!next_hop_set && !is_drop && !is_local &&
8520 !is_classify && !is_unreach && !is_prohibit &&
8521 MPLS_LABEL_INVALID == next_hop_via_label)
8524 ("next hop / local / drop / unreach / prohibit / classify not set");
8528 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
8530 errmsg ("next hop and next-hop via label set");
8533 if (address_set == 0)
8535 errmsg ("missing addresses");
8539 if (address_length_set == 0)
8541 errmsg ("missing address length");
8545 /* Generate a pile of unique, random routes */
8548 u32 this_random_address;
8549 random_hash = hash_create (count, sizeof (uword));
8551 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
8552 for (j = 0; j <= count; j++)
8556 this_random_address = random_u32 (&random_seed);
8557 this_random_address =
8558 clib_host_to_net_u32 (this_random_address);
8560 while (hash_get (random_hash, this_random_address));
8561 vec_add1 (random_vector, this_random_address);
8562 hash_set (random_hash, this_random_address, 1);
8564 hash_free (random_hash);
8565 v4_dst_address.as_u32 = random_vector[0];
8570 /* Turn on async mode */
8571 vam->async_mode = 1;
8572 vam->async_errors = 0;
8573 before = vat_time_now (vam);
8576 for (j = 0; j < count; j++)
8578 /* Construct the API message */
8579 M2 (IP_ADD_DEL_ROUTE, mp,
8580 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
8582 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8583 mp->table_id = ntohl (vrf_id);
8585 mp->is_add = is_add;
8586 mp->is_drop = is_drop;
8587 mp->is_unreach = is_unreach;
8588 mp->is_prohibit = is_prohibit;
8589 mp->is_ipv6 = is_ipv6;
8590 mp->is_local = is_local;
8591 mp->is_classify = is_classify;
8592 mp->is_multipath = is_multipath;
8593 mp->is_resolve_host = resolve_host;
8594 mp->is_resolve_attached = resolve_attached;
8595 mp->next_hop_weight = next_hop_weight;
8596 mp->dst_address_length = dst_address_length;
8597 mp->next_hop_table_id = ntohl (next_hop_table_id);
8598 mp->classify_table_index = ntohl (classify_table_index);
8599 mp->next_hop_via_label = ntohl (next_hop_via_label);
8600 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8601 if (0 != mp->next_hop_n_out_labels)
8603 memcpy (mp->next_hop_out_label_stack,
8604 next_hop_out_label_stack,
8605 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
8606 vec_free (next_hop_out_label_stack);
8611 clib_memcpy (mp->dst_address, &v6_dst_address,
8612 sizeof (v6_dst_address));
8614 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
8615 sizeof (v6_next_hop_address));
8616 increment_v6_address (&v6_dst_address);
8620 clib_memcpy (mp->dst_address, &v4_dst_address,
8621 sizeof (v4_dst_address));
8623 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
8624 sizeof (v4_next_hop_address));
8626 v4_dst_address.as_u32 = random_vector[j + 1];
8628 increment_v4_address (&v4_dst_address);
8632 /* If we receive SIGTERM, stop now... */
8637 /* When testing multiple add/del ops, use a control-ping to sync */
8640 vl_api_control_ping_t *mp_ping;
8644 /* Shut off async mode */
8645 vam->async_mode = 0;
8647 MPING (CONTROL_PING, mp_ping);
8650 timeout = vat_time_now (vam) + 1.0;
8651 while (vat_time_now (vam) < timeout)
8652 if (vam->result_ready == 1)
8657 if (vam->retval == -99)
8660 if (vam->async_errors > 0)
8662 errmsg ("%d asynchronous errors", vam->async_errors);
8665 vam->async_errors = 0;
8666 after = vat_time_now (vam);
8668 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8672 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8673 count, after - before, count / (after - before));
8679 /* Wait for a reply... */
8684 /* Return the good/bad news */
8685 return (vam->retval);
8689 api_ip_mroute_add_del (vat_main_t * vam)
8691 unformat_input_t *i = vam->input;
8692 vl_api_ip_mroute_add_del_t *mp;
8693 u32 sw_if_index = ~0, vrf_id = 0;
8698 u32 grp_address_length = 0;
8699 ip4_address_t v4_grp_address, v4_src_address;
8700 ip6_address_t v6_grp_address, v6_src_address;
8701 mfib_itf_flags_t iflags = 0;
8702 mfib_entry_flags_t eflags = 0;
8705 /* Parse args required to build the message */
8706 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8708 if (unformat (i, "sw_if_index %d", &sw_if_index))
8710 else if (unformat (i, "%U %U",
8711 unformat_ip4_address, &v4_src_address,
8712 unformat_ip4_address, &v4_grp_address))
8714 grp_address_length = 64;
8718 else if (unformat (i, "%U %U",
8719 unformat_ip6_address, &v6_src_address,
8720 unformat_ip6_address, &v6_grp_address))
8722 grp_address_length = 256;
8726 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
8728 memset (&v4_src_address, 0, sizeof (v4_src_address));
8729 grp_address_length = 32;
8733 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
8735 memset (&v6_src_address, 0, sizeof (v6_src_address));
8736 grp_address_length = 128;
8740 else if (unformat (i, "/%d", &grp_address_length))
8742 else if (unformat (i, "local"))
8746 else if (unformat (i, "del"))
8748 else if (unformat (i, "add"))
8750 else if (unformat (i, "vrf %d", &vrf_id))
8752 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
8754 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8758 clib_warning ("parse error '%U'", format_unformat_error, i);
8763 if (address_set == 0)
8765 errmsg ("missing addresses\n");
8769 /* Construct the API message */
8770 M (IP_MROUTE_ADD_DEL, mp);
8772 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8773 mp->table_id = ntohl (vrf_id);
8775 mp->is_add = is_add;
8776 mp->is_ipv6 = is_ipv6;
8777 mp->is_local = is_local;
8778 mp->itf_flags = ntohl (iflags);
8779 mp->entry_flags = ntohl (eflags);
8780 mp->grp_address_length = grp_address_length;
8781 mp->grp_address_length = ntohs (mp->grp_address_length);
8785 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
8786 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
8790 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
8791 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
8797 /* Wait for a reply... */
8803 api_mpls_table_add_del (vat_main_t * vam)
8805 unformat_input_t *i = vam->input;
8806 vl_api_mpls_table_add_del_t *mp;
8811 /* Parse args required to build the message */
8812 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8814 if (unformat (i, "table %d", &table_id))
8816 else if (unformat (i, "del"))
8818 else if (unformat (i, "add"))
8822 clib_warning ("parse error '%U'", format_unformat_error, i);
8829 errmsg ("missing table-ID");
8833 /* Construct the API message */
8834 M (MPLS_TABLE_ADD_DEL, mp);
8836 mp->mt_table_id = ntohl (table_id);
8837 mp->mt_is_add = is_add;
8842 /* Wait for a reply... */
8849 api_mpls_route_add_del (vat_main_t * vam)
8851 unformat_input_t *i = vam->input;
8852 vl_api_mpls_route_add_del_t *mp;
8853 u32 sw_if_index = ~0, table_id = 0;
8855 u32 next_hop_weight = 1;
8856 u8 is_multipath = 0;
8857 u32 next_hop_table_id = 0;
8858 u8 next_hop_set = 0;
8859 ip4_address_t v4_next_hop_address = {
8862 ip6_address_t v6_next_hop_address = { {0} };
8866 u32 classify_table_index = ~0;
8868 u8 resolve_host = 0, resolve_attached = 0;
8869 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8870 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8871 mpls_label_t *next_hop_out_label_stack = NULL;
8872 mpls_label_t local_label = MPLS_LABEL_INVALID;
8874 dpo_proto_t next_hop_proto = DPO_PROTO_IP4;
8876 /* Parse args required to build the message */
8877 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8879 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8881 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8883 else if (unformat (i, "%d", &local_label))
8885 else if (unformat (i, "eos"))
8887 else if (unformat (i, "non-eos"))
8889 else if (unformat (i, "via %U", unformat_ip4_address,
8890 &v4_next_hop_address))
8893 next_hop_proto = DPO_PROTO_IP4;
8895 else if (unformat (i, "via %U", unformat_ip6_address,
8896 &v6_next_hop_address))
8899 next_hop_proto = DPO_PROTO_IP6;
8901 else if (unformat (i, "weight %d", &next_hop_weight))
8903 else if (unformat (i, "classify %d", &classify_table_index))
8907 else if (unformat (i, "del"))
8909 else if (unformat (i, "add"))
8911 else if (unformat (i, "resolve-via-host"))
8913 else if (unformat (i, "resolve-via-attached"))
8914 resolve_attached = 1;
8915 else if (unformat (i, "multipath"))
8917 else if (unformat (i, "count %d", &count))
8919 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
8922 next_hop_proto = DPO_PROTO_IP4;
8924 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
8927 next_hop_proto = DPO_PROTO_IP6;
8929 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8931 else if (unformat (i, "via-label %d", &next_hop_via_label))
8933 else if (unformat (i, "out-label %d", &next_hop_out_label))
8934 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
8937 clib_warning ("parse error '%U'", format_unformat_error, i);
8942 if (!next_hop_set && !is_classify)
8944 errmsg ("next hop / classify not set");
8948 if (MPLS_LABEL_INVALID == local_label)
8950 errmsg ("missing label");
8956 /* Turn on async mode */
8957 vam->async_mode = 1;
8958 vam->async_errors = 0;
8959 before = vat_time_now (vam);
8962 for (j = 0; j < count; j++)
8964 /* Construct the API message */
8965 M2 (MPLS_ROUTE_ADD_DEL, mp,
8966 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
8968 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
8969 mp->mr_table_id = ntohl (table_id);
8971 mp->mr_is_add = is_add;
8972 mp->mr_next_hop_proto = next_hop_proto;
8973 mp->mr_is_classify = is_classify;
8974 mp->mr_is_multipath = is_multipath;
8975 mp->mr_is_resolve_host = resolve_host;
8976 mp->mr_is_resolve_attached = resolve_attached;
8977 mp->mr_next_hop_weight = next_hop_weight;
8978 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
8979 mp->mr_classify_table_index = ntohl (classify_table_index);
8980 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
8981 mp->mr_label = ntohl (local_label);
8982 mp->mr_eos = is_eos;
8984 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8985 if (0 != mp->mr_next_hop_n_out_labels)
8987 memcpy (mp->mr_next_hop_out_label_stack,
8988 next_hop_out_label_stack,
8989 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
8990 vec_free (next_hop_out_label_stack);
8995 if (DPO_PROTO_IP4 == next_hop_proto)
8997 clib_memcpy (mp->mr_next_hop,
8998 &v4_next_hop_address,
8999 sizeof (v4_next_hop_address));
9001 else if (DPO_PROTO_IP6 == next_hop_proto)
9004 clib_memcpy (mp->mr_next_hop,
9005 &v6_next_hop_address,
9006 sizeof (v6_next_hop_address));
9013 /* If we receive SIGTERM, stop now... */
9018 /* When testing multiple add/del ops, use a control-ping to sync */
9021 vl_api_control_ping_t *mp_ping;
9025 /* Shut off async mode */
9026 vam->async_mode = 0;
9028 MPING (CONTROL_PING, mp_ping);
9031 timeout = vat_time_now (vam) + 1.0;
9032 while (vat_time_now (vam) < timeout)
9033 if (vam->result_ready == 1)
9038 if (vam->retval == -99)
9041 if (vam->async_errors > 0)
9043 errmsg ("%d asynchronous errors", vam->async_errors);
9046 vam->async_errors = 0;
9047 after = vat_time_now (vam);
9049 /* slim chance, but we might have eaten SIGTERM on the first iteration */
9053 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
9054 count, after - before, count / (after - before));
9060 /* Wait for a reply... */
9065 /* Return the good/bad news */
9066 return (vam->retval);
9070 api_mpls_ip_bind_unbind (vat_main_t * vam)
9072 unformat_input_t *i = vam->input;
9073 vl_api_mpls_ip_bind_unbind_t *mp;
9074 u32 ip_table_id = 0;
9077 ip4_address_t v4_address;
9078 ip6_address_t v6_address;
9081 mpls_label_t local_label = MPLS_LABEL_INVALID;
9084 /* Parse args required to build the message */
9085 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9087 if (unformat (i, "%U/%d", unformat_ip4_address,
9088 &v4_address, &address_length))
9093 else if (unformat (i, "%U/%d", unformat_ip6_address,
9094 &v6_address, &address_length))
9099 else if (unformat (i, "%d", &local_label))
9101 else if (unformat (i, "table-id %d", &ip_table_id))
9103 else if (unformat (i, "unbind"))
9105 else if (unformat (i, "bind"))
9109 clib_warning ("parse error '%U'", format_unformat_error, i);
9116 errmsg ("IP addres not set");
9120 if (MPLS_LABEL_INVALID == local_label)
9122 errmsg ("missing label");
9126 /* Construct the API message */
9127 M (MPLS_IP_BIND_UNBIND, mp);
9129 mp->mb_is_bind = is_bind;
9130 mp->mb_is_ip4 = is_ip4;
9131 mp->mb_ip_table_id = ntohl (ip_table_id);
9132 mp->mb_mpls_table_id = 0;
9133 mp->mb_label = ntohl (local_label);
9134 mp->mb_address_length = address_length;
9137 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
9139 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
9144 /* Wait for a reply... */
9150 api_bier_table_add_del (vat_main_t * vam)
9152 unformat_input_t *i = vam->input;
9153 vl_api_bier_table_add_del_t *mp;
9155 u32 set = 0, sub_domain = 0, hdr_len = 3;
9156 mpls_label_t local_label = MPLS_LABEL_INVALID;
9159 /* Parse args required to build the message */
9160 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9162 if (unformat (i, "sub-domain %d", &sub_domain))
9164 else if (unformat (i, "set %d", &set))
9166 else if (unformat (i, "label %d", &local_label))
9168 else if (unformat (i, "hdr-len %d", &hdr_len))
9170 else if (unformat (i, "add"))
9172 else if (unformat (i, "del"))
9176 clib_warning ("parse error '%U'", format_unformat_error, i);
9181 if (MPLS_LABEL_INVALID == local_label)
9183 errmsg ("missing label\n");
9187 /* Construct the API message */
9188 M (BIER_TABLE_ADD_DEL, mp);
9190 mp->bt_is_add = is_add;
9191 mp->bt_label = ntohl (local_label);
9192 mp->bt_tbl_id.bt_set = set;
9193 mp->bt_tbl_id.bt_sub_domain = sub_domain;
9194 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
9199 /* Wait for a reply... */
9206 api_bier_route_add_del (vat_main_t * vam)
9208 unformat_input_t *i = vam->input;
9209 vl_api_bier_route_add_del_t *mp;
9211 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
9212 ip4_address_t v4_next_hop_address;
9213 ip6_address_t v6_next_hop_address;
9214 u8 next_hop_set = 0;
9215 u8 next_hop_proto_is_ip4 = 1;
9216 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9219 /* Parse args required to build the message */
9220 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9222 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
9224 next_hop_proto_is_ip4 = 1;
9227 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
9229 next_hop_proto_is_ip4 = 0;
9232 if (unformat (i, "sub-domain %d", &sub_domain))
9234 else if (unformat (i, "set %d", &set))
9236 else if (unformat (i, "hdr-len %d", &hdr_len))
9238 else if (unformat (i, "bp %d", &bp))
9240 else if (unformat (i, "add"))
9242 else if (unformat (i, "del"))
9244 else if (unformat (i, "out-label %d", &next_hop_out_label))
9248 clib_warning ("parse error '%U'", format_unformat_error, i);
9253 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
9255 errmsg ("next hop / label set\n");
9260 errmsg ("bit=position not set\n");
9264 /* Construct the API message */
9265 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
9267 mp->br_is_add = is_add;
9268 mp->br_tbl_id.bt_set = set;
9269 mp->br_tbl_id.bt_sub_domain = sub_domain;
9270 mp->br_tbl_id.bt_hdr_len_id = hdr_len;
9271 mp->br_bp = ntohs (bp);
9273 mp->br_paths[0].n_labels = 1;
9274 mp->br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
9275 mp->br_paths[0].afi = (next_hop_proto_is_ip4 ? 0 : 1);
9277 if (next_hop_proto_is_ip4)
9279 clib_memcpy (mp->br_paths[0].next_hop,
9280 &v4_next_hop_address, sizeof (v4_next_hop_address));
9284 clib_memcpy (mp->br_paths[0].next_hop,
9285 &v6_next_hop_address, sizeof (v6_next_hop_address));
9291 /* Wait for a reply... */
9298 api_proxy_arp_add_del (vat_main_t * vam)
9300 unformat_input_t *i = vam->input;
9301 vl_api_proxy_arp_add_del_t *mp;
9304 ip4_address_t lo, hi;
9308 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9310 if (unformat (i, "vrf %d", &vrf_id))
9312 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
9313 unformat_ip4_address, &hi))
9315 else if (unformat (i, "del"))
9319 clib_warning ("parse error '%U'", format_unformat_error, i);
9326 errmsg ("address range not set");
9330 M (PROXY_ARP_ADD_DEL, mp);
9332 mp->proxy.vrf_id = ntohl (vrf_id);
9333 mp->is_add = is_add;
9334 clib_memcpy (mp->proxy.low_address, &lo, sizeof (mp->proxy.low_address));
9335 clib_memcpy (mp->proxy.hi_address, &hi, sizeof (mp->proxy.hi_address));
9343 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
9345 unformat_input_t *i = vam->input;
9346 vl_api_proxy_arp_intfc_enable_disable_t *mp;
9349 u8 sw_if_index_set = 0;
9352 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9354 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9355 sw_if_index_set = 1;
9356 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9357 sw_if_index_set = 1;
9358 else if (unformat (i, "enable"))
9360 else if (unformat (i, "disable"))
9364 clib_warning ("parse error '%U'", format_unformat_error, i);
9369 if (sw_if_index_set == 0)
9371 errmsg ("missing interface name or sw_if_index");
9375 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
9377 mp->sw_if_index = ntohl (sw_if_index);
9378 mp->enable_disable = enable;
9386 api_mpls_tunnel_add_del (vat_main_t * vam)
9388 unformat_input_t *i = vam->input;
9389 vl_api_mpls_tunnel_add_del_t *mp;
9393 u32 sw_if_index = ~0;
9394 u32 next_hop_sw_if_index = ~0;
9395 u32 next_hop_proto_is_ip4 = 1;
9397 u32 next_hop_table_id = 0;
9398 ip4_address_t v4_next_hop_address = {
9401 ip6_address_t v6_next_hop_address = { {0} };
9402 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
9405 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9407 if (unformat (i, "add"))
9409 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
9411 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
9413 else if (unformat (i, "via %U",
9414 unformat_ip4_address, &v4_next_hop_address))
9416 next_hop_proto_is_ip4 = 1;
9418 else if (unformat (i, "via %U",
9419 unformat_ip6_address, &v6_next_hop_address))
9421 next_hop_proto_is_ip4 = 0;
9423 else if (unformat (i, "l2-only"))
9425 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
9427 else if (unformat (i, "out-label %d", &next_hop_out_label))
9428 vec_add1 (labels, ntohl (next_hop_out_label));
9431 clib_warning ("parse error '%U'", format_unformat_error, i);
9436 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
9438 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
9439 mp->mt_sw_if_index = ntohl (sw_if_index);
9440 mp->mt_is_add = is_add;
9441 mp->mt_l2_only = l2_only;
9442 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
9443 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
9445 mp->mt_next_hop_n_out_labels = vec_len (labels);
9447 if (0 != mp->mt_next_hop_n_out_labels)
9449 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
9450 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
9454 if (next_hop_proto_is_ip4)
9456 clib_memcpy (mp->mt_next_hop,
9457 &v4_next_hop_address, sizeof (v4_next_hop_address));
9461 clib_memcpy (mp->mt_next_hop,
9462 &v6_next_hop_address, sizeof (v6_next_hop_address));
9471 api_sw_interface_set_unnumbered (vat_main_t * vam)
9473 unformat_input_t *i = vam->input;
9474 vl_api_sw_interface_set_unnumbered_t *mp;
9476 u32 unnum_sw_index = ~0;
9478 u8 sw_if_index_set = 0;
9481 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9483 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9484 sw_if_index_set = 1;
9485 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9486 sw_if_index_set = 1;
9487 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
9489 else if (unformat (i, "del"))
9493 clib_warning ("parse error '%U'", format_unformat_error, i);
9498 if (sw_if_index_set == 0)
9500 errmsg ("missing interface name or sw_if_index");
9504 M (SW_INTERFACE_SET_UNNUMBERED, mp);
9506 mp->sw_if_index = ntohl (sw_if_index);
9507 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
9508 mp->is_add = is_add;
9516 api_ip_neighbor_add_del (vat_main_t * vam)
9518 unformat_input_t *i = vam->input;
9519 vl_api_ip_neighbor_add_del_t *mp;
9521 u8 sw_if_index_set = 0;
9524 u8 is_no_fib_entry = 0;
9527 u8 v4_address_set = 0;
9528 u8 v6_address_set = 0;
9529 ip4_address_t v4address;
9530 ip6_address_t v6address;
9533 memset (mac_address, 0, sizeof (mac_address));
9535 /* Parse args required to build the message */
9536 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9538 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
9542 else if (unformat (i, "del"))
9545 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9546 sw_if_index_set = 1;
9547 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9548 sw_if_index_set = 1;
9549 else if (unformat (i, "is_static"))
9551 else if (unformat (i, "no-fib-entry"))
9552 is_no_fib_entry = 1;
9553 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
9555 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
9559 clib_warning ("parse error '%U'", format_unformat_error, i);
9564 if (sw_if_index_set == 0)
9566 errmsg ("missing interface name or sw_if_index");
9569 if (v4_address_set && v6_address_set)
9571 errmsg ("both v4 and v6 addresses set");
9574 if (!v4_address_set && !v6_address_set)
9576 errmsg ("no address set");
9580 /* Construct the API message */
9581 M (IP_NEIGHBOR_ADD_DEL, mp);
9583 mp->sw_if_index = ntohl (sw_if_index);
9584 mp->is_add = is_add;
9585 mp->is_static = is_static;
9586 mp->is_no_adj_fib = is_no_fib_entry;
9588 clib_memcpy (mp->mac_address, mac_address, 6);
9592 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
9596 /* mp->is_ipv6 = 0; via memset in M macro above */
9597 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
9603 /* Wait for a reply, return good/bad news */
9609 api_create_vlan_subif (vat_main_t * vam)
9611 unformat_input_t *i = vam->input;
9612 vl_api_create_vlan_subif_t *mp;
9614 u8 sw_if_index_set = 0;
9619 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9621 if (unformat (i, "sw_if_index %d", &sw_if_index))
9622 sw_if_index_set = 1;
9624 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9625 sw_if_index_set = 1;
9626 else if (unformat (i, "vlan %d", &vlan_id))
9630 clib_warning ("parse error '%U'", format_unformat_error, i);
9635 if (sw_if_index_set == 0)
9637 errmsg ("missing interface name or sw_if_index");
9641 if (vlan_id_set == 0)
9643 errmsg ("missing vlan_id");
9646 M (CREATE_VLAN_SUBIF, mp);
9648 mp->sw_if_index = ntohl (sw_if_index);
9649 mp->vlan_id = ntohl (vlan_id);
9656 #define foreach_create_subif_bit \
9663 _(outer_vlan_id_any) \
9664 _(inner_vlan_id_any)
9667 api_create_subif (vat_main_t * vam)
9669 unformat_input_t *i = vam->input;
9670 vl_api_create_subif_t *mp;
9672 u8 sw_if_index_set = 0;
9679 u32 exact_match = 0;
9680 u32 default_sub = 0;
9681 u32 outer_vlan_id_any = 0;
9682 u32 inner_vlan_id_any = 0;
9684 u16 outer_vlan_id = 0;
9685 u16 inner_vlan_id = 0;
9688 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9690 if (unformat (i, "sw_if_index %d", &sw_if_index))
9691 sw_if_index_set = 1;
9693 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9694 sw_if_index_set = 1;
9695 else if (unformat (i, "sub_id %d", &sub_id))
9697 else if (unformat (i, "outer_vlan_id %d", &tmp))
9698 outer_vlan_id = tmp;
9699 else if (unformat (i, "inner_vlan_id %d", &tmp))
9700 inner_vlan_id = tmp;
9702 #define _(a) else if (unformat (i, #a)) a = 1 ;
9703 foreach_create_subif_bit
9707 clib_warning ("parse error '%U'", format_unformat_error, i);
9712 if (sw_if_index_set == 0)
9714 errmsg ("missing interface name or sw_if_index");
9718 if (sub_id_set == 0)
9720 errmsg ("missing sub_id");
9723 M (CREATE_SUBIF, mp);
9725 mp->sw_if_index = ntohl (sw_if_index);
9726 mp->sub_id = ntohl (sub_id);
9728 #define _(a) mp->a = a;
9729 foreach_create_subif_bit;
9732 mp->outer_vlan_id = ntohs (outer_vlan_id);
9733 mp->inner_vlan_id = ntohs (inner_vlan_id);
9741 api_oam_add_del (vat_main_t * vam)
9743 unformat_input_t *i = vam->input;
9744 vl_api_oam_add_del_t *mp;
9747 ip4_address_t src, dst;
9752 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9754 if (unformat (i, "vrf %d", &vrf_id))
9756 else if (unformat (i, "src %U", unformat_ip4_address, &src))
9758 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
9760 else if (unformat (i, "del"))
9764 clib_warning ("parse error '%U'", format_unformat_error, i);
9771 errmsg ("missing src addr");
9777 errmsg ("missing dst addr");
9781 M (OAM_ADD_DEL, mp);
9783 mp->vrf_id = ntohl (vrf_id);
9784 mp->is_add = is_add;
9785 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
9786 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
9794 api_reset_fib (vat_main_t * vam)
9796 unformat_input_t *i = vam->input;
9797 vl_api_reset_fib_t *mp;
9803 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9805 if (unformat (i, "vrf %d", &vrf_id))
9807 else if (unformat (i, "ipv6"))
9811 clib_warning ("parse error '%U'", format_unformat_error, i);
9816 if (vrf_id_set == 0)
9818 errmsg ("missing vrf id");
9824 mp->vrf_id = ntohl (vrf_id);
9825 mp->is_ipv6 = is_ipv6;
9833 api_dhcp_proxy_config (vat_main_t * vam)
9835 unformat_input_t *i = vam->input;
9836 vl_api_dhcp_proxy_config_t *mp;
9838 u32 server_vrf_id = 0;
9840 u8 v4_address_set = 0;
9841 u8 v6_address_set = 0;
9842 ip4_address_t v4address;
9843 ip6_address_t v6address;
9844 u8 v4_src_address_set = 0;
9845 u8 v6_src_address_set = 0;
9846 ip4_address_t v4srcaddress;
9847 ip6_address_t v6srcaddress;
9850 /* Parse args required to build the message */
9851 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9853 if (unformat (i, "del"))
9855 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
9857 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
9859 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
9861 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
9863 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
9864 v4_src_address_set = 1;
9865 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
9866 v6_src_address_set = 1;
9871 if (v4_address_set && v6_address_set)
9873 errmsg ("both v4 and v6 server addresses set");
9876 if (!v4_address_set && !v6_address_set)
9878 errmsg ("no server addresses set");
9882 if (v4_src_address_set && v6_src_address_set)
9884 errmsg ("both v4 and v6 src addresses set");
9887 if (!v4_src_address_set && !v6_src_address_set)
9889 errmsg ("no src addresses set");
9893 if (!(v4_src_address_set && v4_address_set) &&
9894 !(v6_src_address_set && v6_address_set))
9896 errmsg ("no matching server and src addresses set");
9900 /* Construct the API message */
9901 M (DHCP_PROXY_CONFIG, mp);
9903 mp->is_add = is_add;
9904 mp->rx_vrf_id = ntohl (rx_vrf_id);
9905 mp->server_vrf_id = ntohl (server_vrf_id);
9909 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
9910 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
9914 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
9915 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
9921 /* Wait for a reply, return good/bad news */
9926 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
9927 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
9930 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
9932 vat_main_t *vam = &vat_main;
9933 u32 i, count = mp->count;
9934 vl_api_dhcp_server_t *s;
9938 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9939 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9940 ntohl (mp->rx_vrf_id),
9941 format_ip6_address, mp->dhcp_src_address,
9942 mp->vss_type, mp->vss_vpn_ascii_id,
9943 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9946 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9947 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9948 ntohl (mp->rx_vrf_id),
9949 format_ip4_address, mp->dhcp_src_address,
9950 mp->vss_type, mp->vss_vpn_ascii_id,
9951 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9953 for (i = 0; i < count; i++)
9955 s = &mp->servers[i];
9959 " Server Table-ID %d, Server Address %U",
9960 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
9963 " Server Table-ID %d, Server Address %U",
9964 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
9968 static void vl_api_dhcp_proxy_details_t_handler_json
9969 (vl_api_dhcp_proxy_details_t * mp)
9971 vat_main_t *vam = &vat_main;
9972 vat_json_node_t *node = NULL;
9973 u32 i, count = mp->count;
9975 struct in6_addr ip6;
9976 vl_api_dhcp_server_t *s;
9978 if (VAT_JSON_ARRAY != vam->json_tree.type)
9980 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9981 vat_json_init_array (&vam->json_tree);
9983 node = vat_json_array_add (&vam->json_tree);
9985 vat_json_init_object (node);
9986 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
9987 vat_json_object_add_bytes (node, "vss-type", &mp->vss_type,
9988 sizeof (mp->vss_type));
9989 vat_json_object_add_string_copy (node, "vss-vpn-ascii-id",
9990 mp->vss_vpn_ascii_id);
9991 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
9992 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
9996 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
9997 vat_json_object_add_ip6 (node, "src_address", ip6);
10001 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
10002 vat_json_object_add_ip4 (node, "src_address", ip4);
10005 for (i = 0; i < count; i++)
10007 s = &mp->servers[i];
10009 vat_json_object_add_uint (node, "server-table-id",
10010 ntohl (s->server_vrf_id));
10014 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
10015 vat_json_object_add_ip4 (node, "src_address", ip4);
10019 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
10020 vat_json_object_add_ip6 (node, "server_address", ip6);
10026 api_dhcp_proxy_dump (vat_main_t * vam)
10028 unformat_input_t *i = vam->input;
10029 vl_api_control_ping_t *mp_ping;
10030 vl_api_dhcp_proxy_dump_t *mp;
10034 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10036 if (unformat (i, "ipv6"))
10040 clib_warning ("parse error '%U'", format_unformat_error, i);
10045 M (DHCP_PROXY_DUMP, mp);
10047 mp->is_ip6 = is_ipv6;
10050 /* Use a control ping for synchronization */
10051 MPING (CONTROL_PING, mp_ping);
10059 api_dhcp_proxy_set_vss (vat_main_t * vam)
10061 unformat_input_t *i = vam->input;
10062 vl_api_dhcp_proxy_set_vss_t *mp;
10066 u8 vss_type = VSS_TYPE_DEFAULT;
10067 u8 *vpn_ascii_id = 0;
10072 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10074 if (unformat (i, "tbl_id %d", &tbl_id))
10076 else if (unformat (i, "vpn_ascii_id %s", &vpn_ascii_id))
10077 vss_type = VSS_TYPE_ASCII;
10078 else if (unformat (i, "fib_id %d", &fib_id))
10079 vss_type = VSS_TYPE_VPN_ID;
10080 else if (unformat (i, "oui %d", &oui))
10081 vss_type = VSS_TYPE_VPN_ID;
10082 else if (unformat (i, "ipv6"))
10084 else if (unformat (i, "del"))
10092 errmsg ("missing tbl_id ");
10093 vec_free (vpn_ascii_id);
10097 if ((vpn_ascii_id) && (vec_len (vpn_ascii_id) > 128))
10099 errmsg ("vpn_ascii_id cannot be longer than 128 ");
10100 vec_free (vpn_ascii_id);
10104 M (DHCP_PROXY_SET_VSS, mp);
10105 mp->tbl_id = ntohl (tbl_id);
10106 mp->vss_type = vss_type;
10109 clib_memcpy (mp->vpn_ascii_id, vpn_ascii_id, vec_len (vpn_ascii_id));
10110 mp->vpn_ascii_id[vec_len (vpn_ascii_id)] = 0;
10112 mp->vpn_index = ntohl (fib_id);
10113 mp->oui = ntohl (oui);
10114 mp->is_ipv6 = is_ipv6;
10115 mp->is_add = is_add;
10120 vec_free (vpn_ascii_id);
10125 api_dhcp_client_config (vat_main_t * vam)
10127 unformat_input_t *i = vam->input;
10128 vl_api_dhcp_client_config_t *mp;
10130 u8 sw_if_index_set = 0;
10133 u8 disable_event = 0;
10136 /* Parse args required to build the message */
10137 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10139 if (unformat (i, "del"))
10142 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10143 sw_if_index_set = 1;
10144 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10145 sw_if_index_set = 1;
10146 else if (unformat (i, "hostname %s", &hostname))
10148 else if (unformat (i, "disable_event"))
10154 if (sw_if_index_set == 0)
10156 errmsg ("missing interface name or sw_if_index");
10160 if (vec_len (hostname) > 63)
10162 errmsg ("hostname too long");
10164 vec_add1 (hostname, 0);
10166 /* Construct the API message */
10167 M (DHCP_CLIENT_CONFIG, mp);
10169 mp->is_add = is_add;
10170 mp->client.sw_if_index = htonl (sw_if_index);
10171 clib_memcpy (mp->client.hostname, hostname, vec_len (hostname));
10172 vec_free (hostname);
10173 mp->client.want_dhcp_event = disable_event ? 0 : 1;
10174 mp->client.pid = htonl (getpid ());
10179 /* Wait for a reply, return good/bad news */
10185 api_set_ip_flow_hash (vat_main_t * vam)
10187 unformat_input_t *i = vam->input;
10188 vl_api_set_ip_flow_hash_t *mp;
10200 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10202 if (unformat (i, "vrf %d", &vrf_id))
10204 else if (unformat (i, "ipv6"))
10206 else if (unformat (i, "src"))
10208 else if (unformat (i, "dst"))
10210 else if (unformat (i, "sport"))
10212 else if (unformat (i, "dport"))
10214 else if (unformat (i, "proto"))
10216 else if (unformat (i, "reverse"))
10221 clib_warning ("parse error '%U'", format_unformat_error, i);
10226 if (vrf_id_set == 0)
10228 errmsg ("missing vrf id");
10232 M (SET_IP_FLOW_HASH, mp);
10238 mp->reverse = reverse;
10239 mp->vrf_id = ntohl (vrf_id);
10240 mp->is_ipv6 = is_ipv6;
10248 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
10250 unformat_input_t *i = vam->input;
10251 vl_api_sw_interface_ip6_enable_disable_t *mp;
10253 u8 sw_if_index_set = 0;
10257 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10259 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10260 sw_if_index_set = 1;
10261 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10262 sw_if_index_set = 1;
10263 else if (unformat (i, "enable"))
10265 else if (unformat (i, "disable"))
10269 clib_warning ("parse error '%U'", format_unformat_error, i);
10274 if (sw_if_index_set == 0)
10276 errmsg ("missing interface name or sw_if_index");
10280 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
10282 mp->sw_if_index = ntohl (sw_if_index);
10283 mp->enable = enable;
10291 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
10293 unformat_input_t *i = vam->input;
10294 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
10296 u8 sw_if_index_set = 0;
10297 u8 v6_address_set = 0;
10298 ip6_address_t v6address;
10301 /* Parse args required to build the message */
10302 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10304 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10305 sw_if_index_set = 1;
10306 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10307 sw_if_index_set = 1;
10308 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10309 v6_address_set = 1;
10314 if (sw_if_index_set == 0)
10316 errmsg ("missing interface name or sw_if_index");
10319 if (!v6_address_set)
10321 errmsg ("no address set");
10325 /* Construct the API message */
10326 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
10328 mp->sw_if_index = ntohl (sw_if_index);
10329 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10334 /* Wait for a reply, return good/bad news */
10340 api_ip6nd_proxy_add_del (vat_main_t * vam)
10342 unformat_input_t *i = vam->input;
10343 vl_api_ip6nd_proxy_add_del_t *mp;
10344 u32 sw_if_index = ~0;
10345 u8 v6_address_set = 0;
10346 ip6_address_t v6address;
10350 /* Parse args required to build the message */
10351 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10353 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10355 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10357 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10358 v6_address_set = 1;
10359 if (unformat (i, "del"))
10363 clib_warning ("parse error '%U'", format_unformat_error, i);
10368 if (sw_if_index == ~0)
10370 errmsg ("missing interface name or sw_if_index");
10373 if (!v6_address_set)
10375 errmsg ("no address set");
10379 /* Construct the API message */
10380 M (IP6ND_PROXY_ADD_DEL, mp);
10382 mp->is_del = is_del;
10383 mp->sw_if_index = ntohl (sw_if_index);
10384 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10389 /* Wait for a reply, return good/bad news */
10395 api_ip6nd_proxy_dump (vat_main_t * vam)
10397 vl_api_ip6nd_proxy_dump_t *mp;
10398 vl_api_control_ping_t *mp_ping;
10401 M (IP6ND_PROXY_DUMP, mp);
10405 /* Use a control ping for synchronization */
10406 MPING (CONTROL_PING, mp_ping);
10413 static void vl_api_ip6nd_proxy_details_t_handler
10414 (vl_api_ip6nd_proxy_details_t * mp)
10416 vat_main_t *vam = &vat_main;
10418 print (vam->ofp, "host %U sw_if_index %d",
10419 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
10422 static void vl_api_ip6nd_proxy_details_t_handler_json
10423 (vl_api_ip6nd_proxy_details_t * mp)
10425 vat_main_t *vam = &vat_main;
10426 struct in6_addr ip6;
10427 vat_json_node_t *node = NULL;
10429 if (VAT_JSON_ARRAY != vam->json_tree.type)
10431 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10432 vat_json_init_array (&vam->json_tree);
10434 node = vat_json_array_add (&vam->json_tree);
10436 vat_json_init_object (node);
10437 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10439 clib_memcpy (&ip6, mp->address, sizeof (ip6));
10440 vat_json_object_add_ip6 (node, "host", ip6);
10444 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
10446 unformat_input_t *i = vam->input;
10447 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
10449 u8 sw_if_index_set = 0;
10450 u32 address_length = 0;
10451 u8 v6_address_set = 0;
10452 ip6_address_t v6address;
10453 u8 use_default = 0;
10454 u8 no_advertise = 0;
10456 u8 no_autoconfig = 0;
10459 u32 val_lifetime = 0;
10460 u32 pref_lifetime = 0;
10463 /* Parse args required to build the message */
10464 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10466 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10467 sw_if_index_set = 1;
10468 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10469 sw_if_index_set = 1;
10470 else if (unformat (i, "%U/%d",
10471 unformat_ip6_address, &v6address, &address_length))
10472 v6_address_set = 1;
10473 else if (unformat (i, "val_life %d", &val_lifetime))
10475 else if (unformat (i, "pref_life %d", &pref_lifetime))
10477 else if (unformat (i, "def"))
10479 else if (unformat (i, "noadv"))
10481 else if (unformat (i, "offl"))
10483 else if (unformat (i, "noauto"))
10485 else if (unformat (i, "nolink"))
10487 else if (unformat (i, "isno"))
10491 clib_warning ("parse error '%U'", format_unformat_error, i);
10496 if (sw_if_index_set == 0)
10498 errmsg ("missing interface name or sw_if_index");
10501 if (!v6_address_set)
10503 errmsg ("no address set");
10507 /* Construct the API message */
10508 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
10510 mp->sw_if_index = ntohl (sw_if_index);
10511 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10512 mp->address_length = address_length;
10513 mp->use_default = use_default;
10514 mp->no_advertise = no_advertise;
10515 mp->off_link = off_link;
10516 mp->no_autoconfig = no_autoconfig;
10517 mp->no_onlink = no_onlink;
10519 mp->val_lifetime = ntohl (val_lifetime);
10520 mp->pref_lifetime = ntohl (pref_lifetime);
10525 /* Wait for a reply, return good/bad news */
10531 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
10533 unformat_input_t *i = vam->input;
10534 vl_api_sw_interface_ip6nd_ra_config_t *mp;
10536 u8 sw_if_index_set = 0;
10541 u8 send_unicast = 0;
10544 u8 default_router = 0;
10545 u32 max_interval = 0;
10546 u32 min_interval = 0;
10548 u32 initial_count = 0;
10549 u32 initial_interval = 0;
10553 /* Parse args required to build the message */
10554 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10556 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10557 sw_if_index_set = 1;
10558 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10559 sw_if_index_set = 1;
10560 else if (unformat (i, "maxint %d", &max_interval))
10562 else if (unformat (i, "minint %d", &min_interval))
10564 else if (unformat (i, "life %d", &lifetime))
10566 else if (unformat (i, "count %d", &initial_count))
10568 else if (unformat (i, "interval %d", &initial_interval))
10570 else if (unformat (i, "suppress") || unformat (i, "surpress"))
10572 else if (unformat (i, "managed"))
10574 else if (unformat (i, "other"))
10576 else if (unformat (i, "ll"))
10578 else if (unformat (i, "send"))
10580 else if (unformat (i, "cease"))
10582 else if (unformat (i, "isno"))
10584 else if (unformat (i, "def"))
10585 default_router = 1;
10588 clib_warning ("parse error '%U'", format_unformat_error, i);
10593 if (sw_if_index_set == 0)
10595 errmsg ("missing interface name or sw_if_index");
10599 /* Construct the API message */
10600 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
10602 mp->sw_if_index = ntohl (sw_if_index);
10603 mp->max_interval = ntohl (max_interval);
10604 mp->min_interval = ntohl (min_interval);
10605 mp->lifetime = ntohl (lifetime);
10606 mp->initial_count = ntohl (initial_count);
10607 mp->initial_interval = ntohl (initial_interval);
10608 mp->suppress = suppress;
10609 mp->managed = managed;
10611 mp->ll_option = ll_option;
10612 mp->send_unicast = send_unicast;
10615 mp->default_router = default_router;
10620 /* Wait for a reply, return good/bad news */
10626 api_set_arp_neighbor_limit (vat_main_t * vam)
10628 unformat_input_t *i = vam->input;
10629 vl_api_set_arp_neighbor_limit_t *mp;
10635 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10637 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
10639 else if (unformat (i, "ipv6"))
10643 clib_warning ("parse error '%U'", format_unformat_error, i);
10648 if (limit_set == 0)
10650 errmsg ("missing limit value");
10654 M (SET_ARP_NEIGHBOR_LIMIT, mp);
10656 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
10657 mp->is_ipv6 = is_ipv6;
10665 api_l2_patch_add_del (vat_main_t * vam)
10667 unformat_input_t *i = vam->input;
10668 vl_api_l2_patch_add_del_t *mp;
10669 u32 rx_sw_if_index;
10670 u8 rx_sw_if_index_set = 0;
10671 u32 tx_sw_if_index;
10672 u8 tx_sw_if_index_set = 0;
10676 /* Parse args required to build the message */
10677 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10679 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
10680 rx_sw_if_index_set = 1;
10681 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
10682 tx_sw_if_index_set = 1;
10683 else if (unformat (i, "rx"))
10685 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10687 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10689 rx_sw_if_index_set = 1;
10694 else if (unformat (i, "tx"))
10696 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10698 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10700 tx_sw_if_index_set = 1;
10705 else if (unformat (i, "del"))
10711 if (rx_sw_if_index_set == 0)
10713 errmsg ("missing rx interface name or rx_sw_if_index");
10717 if (tx_sw_if_index_set == 0)
10719 errmsg ("missing tx interface name or tx_sw_if_index");
10723 M (L2_PATCH_ADD_DEL, mp);
10725 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
10726 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
10727 mp->is_add = is_add;
10735 u8 localsid_addr[16];
10744 api_sr_localsid_add_del (vat_main_t * vam)
10746 unformat_input_t *i = vam->input;
10747 vl_api_sr_localsid_add_del_t *mp;
10750 ip6_address_t localsid;
10754 u32 fib_table = ~(u32) 0;
10755 ip6_address_t nh_addr6;
10756 ip4_address_t nh_addr4;
10757 memset (&nh_addr6, 0, sizeof (ip6_address_t));
10758 memset (&nh_addr4, 0, sizeof (ip4_address_t));
10760 bool nexthop_set = 0;
10764 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10766 if (unformat (i, "del"))
10768 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
10769 else if (unformat (i, "next-hop %U", unformat_ip4_address, &nh_addr4))
10771 else if (unformat (i, "next-hop %U", unformat_ip6_address, &nh_addr6))
10773 else if (unformat (i, "behavior %u", &behavior));
10774 else if (unformat (i, "sw_if_index %u", &sw_if_index));
10775 else if (unformat (i, "fib-table %u", &fib_table));
10776 else if (unformat (i, "end.psp %u", &behavior));
10781 M (SR_LOCALSID_ADD_DEL, mp);
10783 clib_memcpy (mp->localsid.addr, &localsid, sizeof (mp->localsid));
10786 clib_memcpy (mp->nh_addr6, &nh_addr4, sizeof (mp->nh_addr6));
10787 clib_memcpy (mp->nh_addr4, &nh_addr6, sizeof (mp->nh_addr4));
10789 mp->behavior = behavior;
10790 mp->sw_if_index = ntohl (sw_if_index);
10791 mp->fib_table = ntohl (fib_table);
10792 mp->end_psp = end_psp;
10793 mp->is_del = is_del;
10801 api_ioam_enable (vat_main_t * vam)
10803 unformat_input_t *input = vam->input;
10804 vl_api_ioam_enable_t *mp;
10806 int has_trace_option = 0;
10807 int has_pot_option = 0;
10808 int has_seqno_option = 0;
10809 int has_analyse_option = 0;
10812 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10814 if (unformat (input, "trace"))
10815 has_trace_option = 1;
10816 else if (unformat (input, "pot"))
10817 has_pot_option = 1;
10818 else if (unformat (input, "seqno"))
10819 has_seqno_option = 1;
10820 else if (unformat (input, "analyse"))
10821 has_analyse_option = 1;
10825 M (IOAM_ENABLE, mp);
10826 mp->id = htons (id);
10827 mp->seqno = has_seqno_option;
10828 mp->analyse = has_analyse_option;
10829 mp->pot_enable = has_pot_option;
10830 mp->trace_enable = has_trace_option;
10839 api_ioam_disable (vat_main_t * vam)
10841 vl_api_ioam_disable_t *mp;
10844 M (IOAM_DISABLE, mp);
10850 #define foreach_tcp_proto_field \
10854 #define foreach_udp_proto_field \
10858 #define foreach_ip4_proto_field \
10870 u16 src_port, dst_port;
10873 #if VPP_API_TEST_BUILTIN == 0
10875 unformat_tcp_mask (unformat_input_t * input, va_list * args)
10877 u8 **maskp = va_arg (*args, u8 **);
10879 u8 found_something = 0;
10882 #define _(a) u8 a=0;
10883 foreach_tcp_proto_field;
10886 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10889 #define _(a) else if (unformat (input, #a)) a=1;
10890 foreach_tcp_proto_field
10896 #define _(a) found_something += a;
10897 foreach_tcp_proto_field;
10900 if (found_something == 0)
10903 vec_validate (mask, sizeof (*tcp) - 1);
10905 tcp = (tcp_header_t *) mask;
10907 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
10908 foreach_tcp_proto_field;
10916 unformat_udp_mask (unformat_input_t * input, va_list * args)
10918 u8 **maskp = va_arg (*args, u8 **);
10920 u8 found_something = 0;
10923 #define _(a) u8 a=0;
10924 foreach_udp_proto_field;
10927 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10930 #define _(a) else if (unformat (input, #a)) a=1;
10931 foreach_udp_proto_field
10937 #define _(a) found_something += a;
10938 foreach_udp_proto_field;
10941 if (found_something == 0)
10944 vec_validate (mask, sizeof (*udp) - 1);
10946 udp = (udp_header_t *) mask;
10948 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
10949 foreach_udp_proto_field;
10957 unformat_l4_mask (unformat_input_t * input, va_list * args)
10959 u8 **maskp = va_arg (*args, u8 **);
10960 u16 src_port = 0, dst_port = 0;
10961 tcpudp_header_t *tcpudp;
10963 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10965 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
10967 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
10969 else if (unformat (input, "src_port"))
10971 else if (unformat (input, "dst_port"))
10977 if (!src_port && !dst_port)
10981 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
10983 tcpudp = (tcpudp_header_t *) mask;
10984 tcpudp->src_port = src_port;
10985 tcpudp->dst_port = dst_port;
10993 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10995 u8 **maskp = va_arg (*args, u8 **);
10997 u8 found_something = 0;
11000 #define _(a) u8 a=0;
11001 foreach_ip4_proto_field;
11007 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11009 if (unformat (input, "version"))
11011 else if (unformat (input, "hdr_length"))
11013 else if (unformat (input, "src"))
11015 else if (unformat (input, "dst"))
11017 else if (unformat (input, "proto"))
11020 #define _(a) else if (unformat (input, #a)) a=1;
11021 foreach_ip4_proto_field
11027 #define _(a) found_something += a;
11028 foreach_ip4_proto_field;
11031 if (found_something == 0)
11034 vec_validate (mask, sizeof (*ip) - 1);
11036 ip = (ip4_header_t *) mask;
11038 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
11039 foreach_ip4_proto_field;
11042 ip->ip_version_and_header_length = 0;
11045 ip->ip_version_and_header_length |= 0xF0;
11048 ip->ip_version_and_header_length |= 0x0F;
11054 #define foreach_ip6_proto_field \
11057 _(payload_length) \
11062 unformat_ip6_mask (unformat_input_t * input, va_list * args)
11064 u8 **maskp = va_arg (*args, u8 **);
11066 u8 found_something = 0;
11068 u32 ip_version_traffic_class_and_flow_label;
11070 #define _(a) u8 a=0;
11071 foreach_ip6_proto_field;
11074 u8 traffic_class = 0;
11077 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11079 if (unformat (input, "version"))
11081 else if (unformat (input, "traffic-class"))
11083 else if (unformat (input, "flow-label"))
11085 else if (unformat (input, "src"))
11087 else if (unformat (input, "dst"))
11089 else if (unformat (input, "proto"))
11092 #define _(a) else if (unformat (input, #a)) a=1;
11093 foreach_ip6_proto_field
11099 #define _(a) found_something += a;
11100 foreach_ip6_proto_field;
11103 if (found_something == 0)
11106 vec_validate (mask, sizeof (*ip) - 1);
11108 ip = (ip6_header_t *) mask;
11110 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
11111 foreach_ip6_proto_field;
11114 ip_version_traffic_class_and_flow_label = 0;
11117 ip_version_traffic_class_and_flow_label |= 0xF0000000;
11120 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
11123 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
11125 ip->ip_version_traffic_class_and_flow_label =
11126 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11133 unformat_l3_mask (unformat_input_t * input, va_list * args)
11135 u8 **maskp = va_arg (*args, u8 **);
11137 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11139 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
11141 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
11150 unformat_l2_mask (unformat_input_t * input, va_list * args)
11152 u8 **maskp = va_arg (*args, u8 **);
11159 u8 ignore_tag1 = 0;
11160 u8 ignore_tag2 = 0;
11167 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11169 if (unformat (input, "src"))
11171 else if (unformat (input, "dst"))
11173 else if (unformat (input, "proto"))
11175 else if (unformat (input, "tag1"))
11177 else if (unformat (input, "tag2"))
11179 else if (unformat (input, "ignore-tag1"))
11181 else if (unformat (input, "ignore-tag2"))
11183 else if (unformat (input, "cos1"))
11185 else if (unformat (input, "cos2"))
11187 else if (unformat (input, "dot1q"))
11189 else if (unformat (input, "dot1ad"))
11194 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
11195 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11198 if (tag1 || ignore_tag1 || cos1 || dot1q)
11200 if (tag2 || ignore_tag2 || cos2 || dot1ad)
11203 vec_validate (mask, len - 1);
11206 memset (mask, 0xff, 6);
11209 memset (mask + 6, 0xff, 6);
11211 if (tag2 || dot1ad)
11213 /* inner vlan tag */
11222 mask[21] = mask[20] = 0xff;
11243 mask[16] = mask[17] = 0xff;
11253 mask[12] = mask[13] = 0xff;
11260 unformat_classify_mask (unformat_input_t * input, va_list * args)
11262 u8 **maskp = va_arg (*args, u8 **);
11263 u32 *skipp = va_arg (*args, u32 *);
11264 u32 *matchp = va_arg (*args, u32 *);
11272 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11274 if (unformat (input, "hex %U", unformat_hex_string, &mask))
11276 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
11278 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
11280 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
11294 if (mask || l2 || l3 || l4)
11296 if (l2 || l3 || l4)
11298 /* "With a free Ethernet header in every package" */
11300 vec_validate (l2, 13);
11304 vec_append (mask, l3);
11309 vec_append (mask, l4);
11314 /* Scan forward looking for the first significant mask octet */
11315 for (i = 0; i < vec_len (mask); i++)
11319 /* compute (skip, match) params */
11320 *skipp = i / sizeof (u32x4);
11321 vec_delete (mask, *skipp * sizeof (u32x4), 0);
11323 /* Pad mask to an even multiple of the vector size */
11324 while (vec_len (mask) % sizeof (u32x4))
11325 vec_add1 (mask, 0);
11327 match = vec_len (mask) / sizeof (u32x4);
11329 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
11331 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
11332 if (*tmp || *(tmp + 1))
11337 clib_warning ("BUG: match 0");
11339 _vec_len (mask) = match * sizeof (u32x4);
11349 #endif /* VPP_API_TEST_BUILTIN */
11351 #define foreach_l2_next \
11353 _(ethernet, ETHERNET_INPUT) \
11354 _(ip4, IP4_INPUT) \
11358 unformat_l2_next_index (unformat_input_t * input, va_list * args)
11360 u32 *miss_next_indexp = va_arg (*args, u32 *);
11361 u32 next_index = 0;
11365 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
11369 if (unformat (input, "%d", &tmp))
11378 *miss_next_indexp = next_index;
11382 #define foreach_ip_next \
11385 _(rewrite, REWRITE)
11388 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
11390 u32 *miss_next_indexp = va_arg (*args, u32 *);
11391 u32 next_index = 0;
11395 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
11399 if (unformat (input, "%d", &tmp))
11408 *miss_next_indexp = next_index;
11412 #define foreach_acl_next \
11416 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
11418 u32 *miss_next_indexp = va_arg (*args, u32 *);
11419 u32 next_index = 0;
11423 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
11427 if (unformat (input, "permit"))
11432 else if (unformat (input, "%d", &tmp))
11441 *miss_next_indexp = next_index;
11446 unformat_policer_precolor (unformat_input_t * input, va_list * args)
11448 u32 *r = va_arg (*args, u32 *);
11450 if (unformat (input, "conform-color"))
11451 *r = POLICE_CONFORM;
11452 else if (unformat (input, "exceed-color"))
11453 *r = POLICE_EXCEED;
11461 api_classify_add_del_table (vat_main_t * vam)
11463 unformat_input_t *i = vam->input;
11464 vl_api_classify_add_del_table_t *mp;
11471 u32 table_index = ~0;
11472 u32 next_table_index = ~0;
11473 u32 miss_next_index = ~0;
11474 u32 memory_size = 32 << 20;
11476 u32 current_data_flag = 0;
11477 int current_data_offset = 0;
11480 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11482 if (unformat (i, "del"))
11484 else if (unformat (i, "del-chain"))
11489 else if (unformat (i, "buckets %d", &nbuckets))
11491 else if (unformat (i, "memory_size %d", &memory_size))
11493 else if (unformat (i, "skip %d", &skip))
11495 else if (unformat (i, "match %d", &match))
11497 else if (unformat (i, "table %d", &table_index))
11499 else if (unformat (i, "mask %U", unformat_classify_mask,
11500 &mask, &skip, &match))
11502 else if (unformat (i, "next-table %d", &next_table_index))
11504 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
11507 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
11510 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
11513 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
11515 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
11521 if (is_add && mask == 0)
11523 errmsg ("Mask required");
11527 if (is_add && skip == ~0)
11529 errmsg ("skip count required");
11533 if (is_add && match == ~0)
11535 errmsg ("match count required");
11539 if (!is_add && table_index == ~0)
11541 errmsg ("table index required for delete");
11545 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
11547 mp->is_add = is_add;
11548 mp->del_chain = del_chain;
11549 mp->table_index = ntohl (table_index);
11550 mp->nbuckets = ntohl (nbuckets);
11551 mp->memory_size = ntohl (memory_size);
11552 mp->skip_n_vectors = ntohl (skip);
11553 mp->match_n_vectors = ntohl (match);
11554 mp->next_table_index = ntohl (next_table_index);
11555 mp->miss_next_index = ntohl (miss_next_index);
11556 mp->current_data_flag = ntohl (current_data_flag);
11557 mp->current_data_offset = ntohl (current_data_offset);
11558 mp->mask_len = ntohl (vec_len (mask));
11559 clib_memcpy (mp->mask, mask, vec_len (mask));
11568 #if VPP_API_TEST_BUILTIN == 0
11570 unformat_l4_match (unformat_input_t * input, va_list * args)
11572 u8 **matchp = va_arg (*args, u8 **);
11574 u8 *proto_header = 0;
11580 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11582 if (unformat (input, "src_port %d", &src_port))
11584 else if (unformat (input, "dst_port %d", &dst_port))
11590 h.src_port = clib_host_to_net_u16 (src_port);
11591 h.dst_port = clib_host_to_net_u16 (dst_port);
11592 vec_validate (proto_header, sizeof (h) - 1);
11593 memcpy (proto_header, &h, sizeof (h));
11595 *matchp = proto_header;
11601 unformat_ip4_match (unformat_input_t * input, va_list * args)
11603 u8 **matchp = va_arg (*args, u8 **);
11608 int hdr_length = 0;
11609 u32 hdr_length_val;
11610 int src = 0, dst = 0;
11611 ip4_address_t src_val, dst_val;
11618 int fragment_id = 0;
11619 u32 fragment_id_val;
11625 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11627 if (unformat (input, "version %d", &version_val))
11629 else if (unformat (input, "hdr_length %d", &hdr_length_val))
11631 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
11633 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
11635 else if (unformat (input, "proto %d", &proto_val))
11637 else if (unformat (input, "tos %d", &tos_val))
11639 else if (unformat (input, "length %d", &length_val))
11641 else if (unformat (input, "fragment_id %d", &fragment_id_val))
11643 else if (unformat (input, "ttl %d", &ttl_val))
11645 else if (unformat (input, "checksum %d", &checksum_val))
11651 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
11652 + ttl + checksum == 0)
11656 * Aligned because we use the real comparison functions
11658 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11660 ip = (ip4_header_t *) match;
11662 /* These are realistically matched in practice */
11664 ip->src_address.as_u32 = src_val.as_u32;
11667 ip->dst_address.as_u32 = dst_val.as_u32;
11670 ip->protocol = proto_val;
11673 /* These are not, but they're included for completeness */
11675 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
11678 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
11684 ip->length = clib_host_to_net_u16 (length_val);
11690 ip->checksum = clib_host_to_net_u16 (checksum_val);
11697 unformat_ip6_match (unformat_input_t * input, va_list * args)
11699 u8 **matchp = va_arg (*args, u8 **);
11704 u8 traffic_class = 0;
11705 u32 traffic_class_val = 0;
11708 int src = 0, dst = 0;
11709 ip6_address_t src_val, dst_val;
11712 int payload_length = 0;
11713 u32 payload_length_val;
11716 u32 ip_version_traffic_class_and_flow_label;
11718 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11720 if (unformat (input, "version %d", &version_val))
11722 else if (unformat (input, "traffic_class %d", &traffic_class_val))
11724 else if (unformat (input, "flow_label %d", &flow_label_val))
11726 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
11728 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
11730 else if (unformat (input, "proto %d", &proto_val))
11732 else if (unformat (input, "payload_length %d", &payload_length_val))
11733 payload_length = 1;
11734 else if (unformat (input, "hop_limit %d", &hop_limit_val))
11740 if (version + traffic_class + flow_label + src + dst + proto +
11741 payload_length + hop_limit == 0)
11745 * Aligned because we use the real comparison functions
11747 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11749 ip = (ip6_header_t *) match;
11752 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
11755 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
11758 ip->protocol = proto_val;
11760 ip_version_traffic_class_and_flow_label = 0;
11763 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
11766 ip_version_traffic_class_and_flow_label |=
11767 (traffic_class_val & 0xFF) << 20;
11770 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
11772 ip->ip_version_traffic_class_and_flow_label =
11773 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11775 if (payload_length)
11776 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
11779 ip->hop_limit = hop_limit_val;
11786 unformat_l3_match (unformat_input_t * input, va_list * args)
11788 u8 **matchp = va_arg (*args, u8 **);
11790 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11792 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
11794 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
11803 unformat_vlan_tag (unformat_input_t * input, va_list * args)
11805 u8 *tagp = va_arg (*args, u8 *);
11808 if (unformat (input, "%d", &tag))
11810 tagp[0] = (tag >> 8) & 0x0F;
11811 tagp[1] = tag & 0xFF;
11819 unformat_l2_match (unformat_input_t * input, va_list * args)
11821 u8 **matchp = va_arg (*args, u8 **);
11834 u8 ignore_tag1 = 0;
11835 u8 ignore_tag2 = 0;
11841 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11843 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
11846 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
11848 else if (unformat (input, "proto %U",
11849 unformat_ethernet_type_host_byte_order, &proto_val))
11851 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
11853 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
11855 else if (unformat (input, "ignore-tag1"))
11857 else if (unformat (input, "ignore-tag2"))
11859 else if (unformat (input, "cos1 %d", &cos1_val))
11861 else if (unformat (input, "cos2 %d", &cos2_val))
11866 if ((src + dst + proto + tag1 + tag2 +
11867 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11870 if (tag1 || ignore_tag1 || cos1)
11872 if (tag2 || ignore_tag2 || cos2)
11875 vec_validate_aligned (match, len - 1, sizeof (u32x4));
11878 clib_memcpy (match, dst_val, 6);
11881 clib_memcpy (match + 6, src_val, 6);
11885 /* inner vlan tag */
11886 match[19] = tag2_val[1];
11887 match[18] = tag2_val[0];
11889 match[18] |= (cos2_val & 0x7) << 5;
11892 match[21] = proto_val & 0xff;
11893 match[20] = proto_val >> 8;
11897 match[15] = tag1_val[1];
11898 match[14] = tag1_val[0];
11901 match[14] |= (cos1_val & 0x7) << 5;
11907 match[15] = tag1_val[1];
11908 match[14] = tag1_val[0];
11911 match[17] = proto_val & 0xff;
11912 match[16] = proto_val >> 8;
11915 match[14] |= (cos1_val & 0x7) << 5;
11921 match[18] |= (cos2_val & 0x7) << 5;
11923 match[14] |= (cos1_val & 0x7) << 5;
11926 match[13] = proto_val & 0xff;
11927 match[12] = proto_val >> 8;
11935 unformat_qos_source (unformat_input_t * input, va_list * args)
11937 int *qs = va_arg (*args, int *);
11939 if (unformat (input, "ip"))
11940 *qs = QOS_SOURCE_IP;
11941 else if (unformat (input, "mpls"))
11942 *qs = QOS_SOURCE_MPLS;
11943 else if (unformat (input, "ext"))
11944 *qs = QOS_SOURCE_EXT;
11945 else if (unformat (input, "vlan"))
11946 *qs = QOS_SOURCE_VLAN;
11955 api_unformat_classify_match (unformat_input_t * input, va_list * args)
11957 u8 **matchp = va_arg (*args, u8 **);
11958 u32 skip_n_vectors = va_arg (*args, u32);
11959 u32 match_n_vectors = va_arg (*args, u32);
11966 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11968 if (unformat (input, "hex %U", unformat_hex_string, &match))
11970 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
11972 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
11974 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11988 if (match || l2 || l3 || l4)
11990 if (l2 || l3 || l4)
11992 /* "Win a free Ethernet header in every packet" */
11994 vec_validate_aligned (l2, 13, sizeof (u32x4));
11998 vec_append_aligned (match, l3, sizeof (u32x4));
12003 vec_append_aligned (match, l4, sizeof (u32x4));
12008 /* Make sure the vector is big enough even if key is all 0's */
12009 vec_validate_aligned
12010 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
12013 /* Set size, include skipped vectors */
12014 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
12025 api_classify_add_del_session (vat_main_t * vam)
12027 unformat_input_t *i = vam->input;
12028 vl_api_classify_add_del_session_t *mp;
12030 u32 table_index = ~0;
12031 u32 hit_next_index = ~0;
12032 u32 opaque_index = ~0;
12035 u32 skip_n_vectors = 0;
12036 u32 match_n_vectors = 0;
12042 * Warning: you have to supply skip_n and match_n
12043 * because the API client cant simply look at the classify
12047 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12049 if (unformat (i, "del"))
12051 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
12054 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
12057 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
12060 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
12062 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
12064 else if (unformat (i, "opaque-index %d", &opaque_index))
12066 else if (unformat (i, "skip_n %d", &skip_n_vectors))
12068 else if (unformat (i, "match_n %d", &match_n_vectors))
12070 else if (unformat (i, "match %U", api_unformat_classify_match,
12071 &match, skip_n_vectors, match_n_vectors))
12073 else if (unformat (i, "advance %d", &advance))
12075 else if (unformat (i, "table-index %d", &table_index))
12077 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
12079 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
12081 else if (unformat (i, "action %d", &action))
12083 else if (unformat (i, "metadata %d", &metadata))
12089 if (table_index == ~0)
12091 errmsg ("Table index required");
12095 if (is_add && match == 0)
12097 errmsg ("Match value required");
12101 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
12103 mp->is_add = is_add;
12104 mp->table_index = ntohl (table_index);
12105 mp->hit_next_index = ntohl (hit_next_index);
12106 mp->opaque_index = ntohl (opaque_index);
12107 mp->advance = ntohl (advance);
12108 mp->action = action;
12109 mp->metadata = ntohl (metadata);
12110 mp->match_len = ntohl (vec_len (match));
12111 clib_memcpy (mp->match, match, vec_len (match));
12120 api_classify_set_interface_ip_table (vat_main_t * vam)
12122 unformat_input_t *i = vam->input;
12123 vl_api_classify_set_interface_ip_table_t *mp;
12125 int sw_if_index_set;
12126 u32 table_index = ~0;
12130 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12132 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12133 sw_if_index_set = 1;
12134 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12135 sw_if_index_set = 1;
12136 else if (unformat (i, "table %d", &table_index))
12140 clib_warning ("parse error '%U'", format_unformat_error, i);
12145 if (sw_if_index_set == 0)
12147 errmsg ("missing interface name or sw_if_index");
12152 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
12154 mp->sw_if_index = ntohl (sw_if_index);
12155 mp->table_index = ntohl (table_index);
12156 mp->is_ipv6 = is_ipv6;
12164 api_classify_set_interface_l2_tables (vat_main_t * vam)
12166 unformat_input_t *i = vam->input;
12167 vl_api_classify_set_interface_l2_tables_t *mp;
12169 int sw_if_index_set;
12170 u32 ip4_table_index = ~0;
12171 u32 ip6_table_index = ~0;
12172 u32 other_table_index = ~0;
12176 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12178 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12179 sw_if_index_set = 1;
12180 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12181 sw_if_index_set = 1;
12182 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12184 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12186 else if (unformat (i, "other-table %d", &other_table_index))
12188 else if (unformat (i, "is-input %d", &is_input))
12192 clib_warning ("parse error '%U'", format_unformat_error, i);
12197 if (sw_if_index_set == 0)
12199 errmsg ("missing interface name or sw_if_index");
12204 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
12206 mp->sw_if_index = ntohl (sw_if_index);
12207 mp->ip4_table_index = ntohl (ip4_table_index);
12208 mp->ip6_table_index = ntohl (ip6_table_index);
12209 mp->other_table_index = ntohl (other_table_index);
12210 mp->is_input = (u8) is_input;
12218 api_set_ipfix_exporter (vat_main_t * vam)
12220 unformat_input_t *i = vam->input;
12221 vl_api_set_ipfix_exporter_t *mp;
12222 ip4_address_t collector_address;
12223 u8 collector_address_set = 0;
12224 u32 collector_port = ~0;
12225 ip4_address_t src_address;
12226 u8 src_address_set = 0;
12229 u32 template_interval = ~0;
12230 u8 udp_checksum = 0;
12233 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12235 if (unformat (i, "collector_address %U", unformat_ip4_address,
12236 &collector_address))
12237 collector_address_set = 1;
12238 else if (unformat (i, "collector_port %d", &collector_port))
12240 else if (unformat (i, "src_address %U", unformat_ip4_address,
12242 src_address_set = 1;
12243 else if (unformat (i, "vrf_id %d", &vrf_id))
12245 else if (unformat (i, "path_mtu %d", &path_mtu))
12247 else if (unformat (i, "template_interval %d", &template_interval))
12249 else if (unformat (i, "udp_checksum"))
12255 if (collector_address_set == 0)
12257 errmsg ("collector_address required");
12261 if (src_address_set == 0)
12263 errmsg ("src_address required");
12267 M (SET_IPFIX_EXPORTER, mp);
12269 memcpy (mp->collector_address, collector_address.data,
12270 sizeof (collector_address.data));
12271 mp->collector_port = htons ((u16) collector_port);
12272 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
12273 mp->vrf_id = htonl (vrf_id);
12274 mp->path_mtu = htonl (path_mtu);
12275 mp->template_interval = htonl (template_interval);
12276 mp->udp_checksum = udp_checksum;
12284 api_set_ipfix_classify_stream (vat_main_t * vam)
12286 unformat_input_t *i = vam->input;
12287 vl_api_set_ipfix_classify_stream_t *mp;
12289 u32 src_port = UDP_DST_PORT_ipfix;
12292 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12294 if (unformat (i, "domain %d", &domain_id))
12296 else if (unformat (i, "src_port %d", &src_port))
12300 errmsg ("unknown input `%U'", format_unformat_error, i);
12305 M (SET_IPFIX_CLASSIFY_STREAM, mp);
12307 mp->domain_id = htonl (domain_id);
12308 mp->src_port = htons ((u16) src_port);
12316 api_ipfix_classify_table_add_del (vat_main_t * vam)
12318 unformat_input_t *i = vam->input;
12319 vl_api_ipfix_classify_table_add_del_t *mp;
12321 u32 classify_table_index = ~0;
12323 u8 transport_protocol = 255;
12326 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12328 if (unformat (i, "add"))
12330 else if (unformat (i, "del"))
12332 else if (unformat (i, "table %d", &classify_table_index))
12334 else if (unformat (i, "ip4"))
12336 else if (unformat (i, "ip6"))
12338 else if (unformat (i, "tcp"))
12339 transport_protocol = 6;
12340 else if (unformat (i, "udp"))
12341 transport_protocol = 17;
12344 errmsg ("unknown input `%U'", format_unformat_error, i);
12351 errmsg ("expecting: add|del");
12354 if (classify_table_index == ~0)
12356 errmsg ("classifier table not specified");
12359 if (ip_version == 0)
12361 errmsg ("IP version not specified");
12365 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
12367 mp->is_add = is_add;
12368 mp->table_id = htonl (classify_table_index);
12369 mp->ip_version = ip_version;
12370 mp->transport_protocol = transport_protocol;
12378 api_get_node_index (vat_main_t * vam)
12380 unformat_input_t *i = vam->input;
12381 vl_api_get_node_index_t *mp;
12385 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12387 if (unformat (i, "node %s", &name))
12394 errmsg ("node name required");
12397 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12399 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12403 M (GET_NODE_INDEX, mp);
12404 clib_memcpy (mp->node_name, name, vec_len (name));
12413 api_get_next_index (vat_main_t * vam)
12415 unformat_input_t *i = vam->input;
12416 vl_api_get_next_index_t *mp;
12417 u8 *node_name = 0, *next_node_name = 0;
12420 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12422 if (unformat (i, "node-name %s", &node_name))
12424 else if (unformat (i, "next-node-name %s", &next_node_name))
12428 if (node_name == 0)
12430 errmsg ("node name required");
12433 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
12435 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12439 if (next_node_name == 0)
12441 errmsg ("next node name required");
12444 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
12446 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
12450 M (GET_NEXT_INDEX, mp);
12451 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
12452 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
12453 vec_free (node_name);
12454 vec_free (next_node_name);
12462 api_add_node_next (vat_main_t * vam)
12464 unformat_input_t *i = vam->input;
12465 vl_api_add_node_next_t *mp;
12470 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12472 if (unformat (i, "node %s", &name))
12474 else if (unformat (i, "next %s", &next))
12481 errmsg ("node name required");
12484 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12486 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12491 errmsg ("next node required");
12494 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
12496 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
12500 M (ADD_NODE_NEXT, mp);
12501 clib_memcpy (mp->node_name, name, vec_len (name));
12502 clib_memcpy (mp->next_name, next, vec_len (next));
12512 api_l2tpv3_create_tunnel (vat_main_t * vam)
12514 unformat_input_t *i = vam->input;
12515 ip6_address_t client_address, our_address;
12516 int client_address_set = 0;
12517 int our_address_set = 0;
12518 u32 local_session_id = 0;
12519 u32 remote_session_id = 0;
12520 u64 local_cookie = 0;
12521 u64 remote_cookie = 0;
12522 u8 l2_sublayer_present = 0;
12523 vl_api_l2tpv3_create_tunnel_t *mp;
12526 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12528 if (unformat (i, "client_address %U", unformat_ip6_address,
12530 client_address_set = 1;
12531 else if (unformat (i, "our_address %U", unformat_ip6_address,
12533 our_address_set = 1;
12534 else if (unformat (i, "local_session_id %d", &local_session_id))
12536 else if (unformat (i, "remote_session_id %d", &remote_session_id))
12538 else if (unformat (i, "local_cookie %lld", &local_cookie))
12540 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
12542 else if (unformat (i, "l2-sublayer-present"))
12543 l2_sublayer_present = 1;
12548 if (client_address_set == 0)
12550 errmsg ("client_address required");
12554 if (our_address_set == 0)
12556 errmsg ("our_address required");
12560 M (L2TPV3_CREATE_TUNNEL, mp);
12562 clib_memcpy (mp->client_address, client_address.as_u8,
12563 sizeof (mp->client_address));
12565 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
12567 mp->local_session_id = ntohl (local_session_id);
12568 mp->remote_session_id = ntohl (remote_session_id);
12569 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
12570 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
12571 mp->l2_sublayer_present = l2_sublayer_present;
12580 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
12582 unformat_input_t *i = vam->input;
12584 u8 sw_if_index_set = 0;
12585 u64 new_local_cookie = 0;
12586 u64 new_remote_cookie = 0;
12587 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
12590 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12592 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12593 sw_if_index_set = 1;
12594 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12595 sw_if_index_set = 1;
12596 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
12598 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
12604 if (sw_if_index_set == 0)
12606 errmsg ("missing interface name or sw_if_index");
12610 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
12612 mp->sw_if_index = ntohl (sw_if_index);
12613 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
12614 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
12622 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
12624 unformat_input_t *i = vam->input;
12625 vl_api_l2tpv3_interface_enable_disable_t *mp;
12627 u8 sw_if_index_set = 0;
12628 u8 enable_disable = 1;
12631 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12633 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12634 sw_if_index_set = 1;
12635 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12636 sw_if_index_set = 1;
12637 else if (unformat (i, "enable"))
12638 enable_disable = 1;
12639 else if (unformat (i, "disable"))
12640 enable_disable = 0;
12645 if (sw_if_index_set == 0)
12647 errmsg ("missing interface name or sw_if_index");
12651 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
12653 mp->sw_if_index = ntohl (sw_if_index);
12654 mp->enable_disable = enable_disable;
12662 api_l2tpv3_set_lookup_key (vat_main_t * vam)
12664 unformat_input_t *i = vam->input;
12665 vl_api_l2tpv3_set_lookup_key_t *mp;
12669 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12671 if (unformat (i, "lookup_v6_src"))
12672 key = L2T_LOOKUP_SRC_ADDRESS;
12673 else if (unformat (i, "lookup_v6_dst"))
12674 key = L2T_LOOKUP_DST_ADDRESS;
12675 else if (unformat (i, "lookup_session_id"))
12676 key = L2T_LOOKUP_SESSION_ID;
12681 if (key == (u8) ~ 0)
12683 errmsg ("l2tp session lookup key unset");
12687 M (L2TPV3_SET_LOOKUP_KEY, mp);
12696 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
12697 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12699 vat_main_t *vam = &vat_main;
12701 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
12702 format_ip6_address, mp->our_address,
12703 format_ip6_address, mp->client_address,
12704 clib_net_to_host_u32 (mp->sw_if_index));
12707 " local cookies %016llx %016llx remote cookie %016llx",
12708 clib_net_to_host_u64 (mp->local_cookie[0]),
12709 clib_net_to_host_u64 (mp->local_cookie[1]),
12710 clib_net_to_host_u64 (mp->remote_cookie));
12712 print (vam->ofp, " local session-id %d remote session-id %d",
12713 clib_net_to_host_u32 (mp->local_session_id),
12714 clib_net_to_host_u32 (mp->remote_session_id));
12716 print (vam->ofp, " l2 specific sublayer %s\n",
12717 mp->l2_sublayer_present ? "preset" : "absent");
12721 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
12722 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12724 vat_main_t *vam = &vat_main;
12725 vat_json_node_t *node = NULL;
12726 struct in6_addr addr;
12728 if (VAT_JSON_ARRAY != vam->json_tree.type)
12730 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12731 vat_json_init_array (&vam->json_tree);
12733 node = vat_json_array_add (&vam->json_tree);
12735 vat_json_init_object (node);
12737 clib_memcpy (&addr, mp->our_address, sizeof (addr));
12738 vat_json_object_add_ip6 (node, "our_address", addr);
12739 clib_memcpy (&addr, mp->client_address, sizeof (addr));
12740 vat_json_object_add_ip6 (node, "client_address", addr);
12742 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
12743 vat_json_init_array (lc);
12744 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
12745 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
12746 vat_json_object_add_uint (node, "remote_cookie",
12747 clib_net_to_host_u64 (mp->remote_cookie));
12749 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
12750 vat_json_object_add_uint (node, "local_session_id",
12751 clib_net_to_host_u32 (mp->local_session_id));
12752 vat_json_object_add_uint (node, "remote_session_id",
12753 clib_net_to_host_u32 (mp->remote_session_id));
12754 vat_json_object_add_string_copy (node, "l2_sublayer",
12755 mp->l2_sublayer_present ? (u8 *) "present"
12756 : (u8 *) "absent");
12760 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
12762 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
12763 vl_api_control_ping_t *mp_ping;
12766 /* Get list of l2tpv3-tunnel interfaces */
12767 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
12770 /* Use a control ping for synchronization */
12771 MPING (CONTROL_PING, mp_ping);
12779 static void vl_api_sw_interface_tap_details_t_handler
12780 (vl_api_sw_interface_tap_details_t * mp)
12782 vat_main_t *vam = &vat_main;
12784 print (vam->ofp, "%-16s %d",
12785 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
12788 static void vl_api_sw_interface_tap_details_t_handler_json
12789 (vl_api_sw_interface_tap_details_t * mp)
12791 vat_main_t *vam = &vat_main;
12792 vat_json_node_t *node = NULL;
12794 if (VAT_JSON_ARRAY != vam->json_tree.type)
12796 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12797 vat_json_init_array (&vam->json_tree);
12799 node = vat_json_array_add (&vam->json_tree);
12801 vat_json_init_object (node);
12802 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12803 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12807 api_sw_interface_tap_dump (vat_main_t * vam)
12809 vl_api_sw_interface_tap_dump_t *mp;
12810 vl_api_control_ping_t *mp_ping;
12813 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
12814 /* Get list of tap interfaces */
12815 M (SW_INTERFACE_TAP_DUMP, mp);
12818 /* Use a control ping for synchronization */
12819 MPING (CONTROL_PING, mp_ping);
12826 static void vl_api_sw_interface_tap_v2_details_t_handler
12827 (vl_api_sw_interface_tap_v2_details_t * mp)
12829 vat_main_t *vam = &vat_main;
12831 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
12832 mp->host_ip4_prefix_len);
12833 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
12834 mp->host_ip6_prefix_len);
12837 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s",
12838 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
12839 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12840 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
12841 mp->host_bridge, ip4, ip6);
12847 static void vl_api_sw_interface_tap_v2_details_t_handler_json
12848 (vl_api_sw_interface_tap_v2_details_t * mp)
12850 vat_main_t *vam = &vat_main;
12851 vat_json_node_t *node = NULL;
12853 if (VAT_JSON_ARRAY != vam->json_tree.type)
12855 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12856 vat_json_init_array (&vam->json_tree);
12858 node = vat_json_array_add (&vam->json_tree);
12860 vat_json_init_object (node);
12861 vat_json_object_add_uint (node, "id", ntohl (mp->id));
12862 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12863 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12864 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12865 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12866 vat_json_object_add_string_copy (node, "host_mac_addr",
12867 format (0, "%U", format_ethernet_address,
12868 &mp->host_mac_addr));
12869 vat_json_object_add_string_copy (node, "host_namespace",
12870 mp->host_namespace);
12871 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
12872 vat_json_object_add_string_copy (node, "host_ip4_addr",
12873 format (0, "%U/%d", format_ip4_address,
12875 mp->host_ip4_prefix_len));
12876 vat_json_object_add_string_copy (node, "host_ip6_addr",
12877 format (0, "%U/%d", format_ip6_address,
12879 mp->host_ip6_prefix_len));
12884 api_sw_interface_tap_v2_dump (vat_main_t * vam)
12886 vl_api_sw_interface_tap_v2_dump_t *mp;
12887 vl_api_control_ping_t *mp_ping;
12891 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
12892 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
12893 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
12896 /* Get list of tap interfaces */
12897 M (SW_INTERFACE_TAP_V2_DUMP, mp);
12900 /* Use a control ping for synchronization */
12901 MPING (CONTROL_PING, mp_ping);
12909 api_vxlan_offload_rx (vat_main_t * vam)
12911 unformat_input_t *line_input = vam->input;
12912 vl_api_vxlan_offload_rx_t *mp;
12913 u32 hw_if_index = ~0, rx_if_index = ~0;
12917 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12919 if (unformat (line_input, "del"))
12921 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
12924 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
12926 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
12929 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
12933 errmsg ("parse error '%U'", format_unformat_error, line_input);
12938 if (hw_if_index == ~0)
12940 errmsg ("no hw interface");
12944 if (rx_if_index == ~0)
12946 errmsg ("no rx tunnel");
12950 M (VXLAN_OFFLOAD_RX, mp);
12952 mp->hw_if_index = ntohl (hw_if_index);
12953 mp->sw_if_index = ntohl (rx_if_index);
12954 mp->enable = is_add;
12961 static uword unformat_vxlan_decap_next
12962 (unformat_input_t * input, va_list * args)
12964 u32 *result = va_arg (*args, u32 *);
12967 if (unformat (input, "l2"))
12968 *result = VXLAN_INPUT_NEXT_L2_INPUT;
12969 else if (unformat (input, "%d", &tmp))
12977 api_vxlan_add_del_tunnel (vat_main_t * vam)
12979 unformat_input_t *line_input = vam->input;
12980 vl_api_vxlan_add_del_tunnel_t *mp;
12981 ip46_address_t src, dst;
12983 u8 ipv4_set = 0, ipv6_set = 0;
12988 u32 mcast_sw_if_index = ~0;
12989 u32 encap_vrf_id = 0;
12990 u32 decap_next_index = ~0;
12994 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12995 memset (&src, 0, sizeof src);
12996 memset (&dst, 0, sizeof dst);
12998 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13000 if (unformat (line_input, "del"))
13002 else if (unformat (line_input, "instance %d", &instance))
13005 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13011 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13017 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13023 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13028 else if (unformat (line_input, "group %U %U",
13029 unformat_ip4_address, &dst.ip4,
13030 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13032 grp_set = dst_set = 1;
13035 else if (unformat (line_input, "group %U",
13036 unformat_ip4_address, &dst.ip4))
13038 grp_set = dst_set = 1;
13041 else if (unformat (line_input, "group %U %U",
13042 unformat_ip6_address, &dst.ip6,
13043 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13045 grp_set = dst_set = 1;
13048 else if (unformat (line_input, "group %U",
13049 unformat_ip6_address, &dst.ip6))
13051 grp_set = dst_set = 1;
13055 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13057 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13059 else if (unformat (line_input, "decap-next %U",
13060 unformat_vxlan_decap_next, &decap_next_index))
13062 else if (unformat (line_input, "vni %d", &vni))
13066 errmsg ("parse error '%U'", format_unformat_error, line_input);
13073 errmsg ("tunnel src address not specified");
13078 errmsg ("tunnel dst address not specified");
13082 if (grp_set && !ip46_address_is_multicast (&dst))
13084 errmsg ("tunnel group address not multicast");
13087 if (grp_set && mcast_sw_if_index == ~0)
13089 errmsg ("tunnel nonexistent multicast device");
13092 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13094 errmsg ("tunnel dst address must be unicast");
13099 if (ipv4_set && ipv6_set)
13101 errmsg ("both IPv4 and IPv6 addresses specified");
13105 if ((vni == 0) || (vni >> 24))
13107 errmsg ("vni not specified or out of range");
13111 M (VXLAN_ADD_DEL_TUNNEL, mp);
13115 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
13116 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
13120 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
13121 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
13124 mp->instance = htonl (instance);
13125 mp->encap_vrf_id = ntohl (encap_vrf_id);
13126 mp->decap_next_index = ntohl (decap_next_index);
13127 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13128 mp->vni = ntohl (vni);
13129 mp->is_add = is_add;
13130 mp->is_ipv6 = ipv6_set;
13137 static void vl_api_vxlan_tunnel_details_t_handler
13138 (vl_api_vxlan_tunnel_details_t * mp)
13140 vat_main_t *vam = &vat_main;
13141 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13142 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13144 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
13145 ntohl (mp->sw_if_index),
13146 ntohl (mp->instance),
13147 format_ip46_address, &src, IP46_TYPE_ANY,
13148 format_ip46_address, &dst, IP46_TYPE_ANY,
13149 ntohl (mp->encap_vrf_id),
13150 ntohl (mp->decap_next_index), ntohl (mp->vni),
13151 ntohl (mp->mcast_sw_if_index));
13154 static void vl_api_vxlan_tunnel_details_t_handler_json
13155 (vl_api_vxlan_tunnel_details_t * mp)
13157 vat_main_t *vam = &vat_main;
13158 vat_json_node_t *node = NULL;
13160 if (VAT_JSON_ARRAY != vam->json_tree.type)
13162 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13163 vat_json_init_array (&vam->json_tree);
13165 node = vat_json_array_add (&vam->json_tree);
13167 vat_json_init_object (node);
13168 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13170 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13174 struct in6_addr ip6;
13176 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13177 vat_json_object_add_ip6 (node, "src_address", ip6);
13178 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13179 vat_json_object_add_ip6 (node, "dst_address", ip6);
13183 struct in_addr ip4;
13185 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13186 vat_json_object_add_ip4 (node, "src_address", ip4);
13187 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13188 vat_json_object_add_ip4 (node, "dst_address", ip4);
13190 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13191 vat_json_object_add_uint (node, "decap_next_index",
13192 ntohl (mp->decap_next_index));
13193 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13194 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13195 vat_json_object_add_uint (node, "mcast_sw_if_index",
13196 ntohl (mp->mcast_sw_if_index));
13200 api_vxlan_tunnel_dump (vat_main_t * vam)
13202 unformat_input_t *i = vam->input;
13203 vl_api_vxlan_tunnel_dump_t *mp;
13204 vl_api_control_ping_t *mp_ping;
13206 u8 sw_if_index_set = 0;
13209 /* Parse args required to build the message */
13210 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13212 if (unformat (i, "sw_if_index %d", &sw_if_index))
13213 sw_if_index_set = 1;
13218 if (sw_if_index_set == 0)
13223 if (!vam->json_output)
13225 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
13226 "sw_if_index", "instance", "src_address", "dst_address",
13227 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13230 /* Get list of vxlan-tunnel interfaces */
13231 M (VXLAN_TUNNEL_DUMP, mp);
13233 mp->sw_if_index = htonl (sw_if_index);
13237 /* Use a control ping for synchronization */
13238 MPING (CONTROL_PING, mp_ping);
13245 static uword unformat_geneve_decap_next
13246 (unformat_input_t * input, va_list * args)
13248 u32 *result = va_arg (*args, u32 *);
13251 if (unformat (input, "l2"))
13252 *result = GENEVE_INPUT_NEXT_L2_INPUT;
13253 else if (unformat (input, "%d", &tmp))
13261 api_geneve_add_del_tunnel (vat_main_t * vam)
13263 unformat_input_t *line_input = vam->input;
13264 vl_api_geneve_add_del_tunnel_t *mp;
13265 ip46_address_t src, dst;
13267 u8 ipv4_set = 0, ipv6_set = 0;
13271 u32 mcast_sw_if_index = ~0;
13272 u32 encap_vrf_id = 0;
13273 u32 decap_next_index = ~0;
13277 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13278 memset (&src, 0, sizeof src);
13279 memset (&dst, 0, sizeof dst);
13281 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13283 if (unformat (line_input, "del"))
13286 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13292 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13298 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13304 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13309 else if (unformat (line_input, "group %U %U",
13310 unformat_ip4_address, &dst.ip4,
13311 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13313 grp_set = dst_set = 1;
13316 else if (unformat (line_input, "group %U",
13317 unformat_ip4_address, &dst.ip4))
13319 grp_set = dst_set = 1;
13322 else if (unformat (line_input, "group %U %U",
13323 unformat_ip6_address, &dst.ip6,
13324 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13326 grp_set = dst_set = 1;
13329 else if (unformat (line_input, "group %U",
13330 unformat_ip6_address, &dst.ip6))
13332 grp_set = dst_set = 1;
13336 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13338 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13340 else if (unformat (line_input, "decap-next %U",
13341 unformat_geneve_decap_next, &decap_next_index))
13343 else if (unformat (line_input, "vni %d", &vni))
13347 errmsg ("parse error '%U'", format_unformat_error, line_input);
13354 errmsg ("tunnel src address not specified");
13359 errmsg ("tunnel dst address not specified");
13363 if (grp_set && !ip46_address_is_multicast (&dst))
13365 errmsg ("tunnel group address not multicast");
13368 if (grp_set && mcast_sw_if_index == ~0)
13370 errmsg ("tunnel nonexistent multicast device");
13373 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13375 errmsg ("tunnel dst address must be unicast");
13380 if (ipv4_set && ipv6_set)
13382 errmsg ("both IPv4 and IPv6 addresses specified");
13386 if ((vni == 0) || (vni >> 24))
13388 errmsg ("vni not specified or out of range");
13392 M (GENEVE_ADD_DEL_TUNNEL, mp);
13396 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
13397 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
13401 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
13402 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
13404 mp->encap_vrf_id = ntohl (encap_vrf_id);
13405 mp->decap_next_index = ntohl (decap_next_index);
13406 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13407 mp->vni = ntohl (vni);
13408 mp->is_add = is_add;
13409 mp->is_ipv6 = ipv6_set;
13416 static void vl_api_geneve_tunnel_details_t_handler
13417 (vl_api_geneve_tunnel_details_t * mp)
13419 vat_main_t *vam = &vat_main;
13420 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13421 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13423 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
13424 ntohl (mp->sw_if_index),
13425 format_ip46_address, &src, IP46_TYPE_ANY,
13426 format_ip46_address, &dst, IP46_TYPE_ANY,
13427 ntohl (mp->encap_vrf_id),
13428 ntohl (mp->decap_next_index), ntohl (mp->vni),
13429 ntohl (mp->mcast_sw_if_index));
13432 static void vl_api_geneve_tunnel_details_t_handler_json
13433 (vl_api_geneve_tunnel_details_t * mp)
13435 vat_main_t *vam = &vat_main;
13436 vat_json_node_t *node = NULL;
13438 if (VAT_JSON_ARRAY != vam->json_tree.type)
13440 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13441 vat_json_init_array (&vam->json_tree);
13443 node = vat_json_array_add (&vam->json_tree);
13445 vat_json_init_object (node);
13446 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13449 struct in6_addr ip6;
13451 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13452 vat_json_object_add_ip6 (node, "src_address", ip6);
13453 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13454 vat_json_object_add_ip6 (node, "dst_address", ip6);
13458 struct in_addr ip4;
13460 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13461 vat_json_object_add_ip4 (node, "src_address", ip4);
13462 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13463 vat_json_object_add_ip4 (node, "dst_address", ip4);
13465 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13466 vat_json_object_add_uint (node, "decap_next_index",
13467 ntohl (mp->decap_next_index));
13468 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13469 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13470 vat_json_object_add_uint (node, "mcast_sw_if_index",
13471 ntohl (mp->mcast_sw_if_index));
13475 api_geneve_tunnel_dump (vat_main_t * vam)
13477 unformat_input_t *i = vam->input;
13478 vl_api_geneve_tunnel_dump_t *mp;
13479 vl_api_control_ping_t *mp_ping;
13481 u8 sw_if_index_set = 0;
13484 /* Parse args required to build the message */
13485 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13487 if (unformat (i, "sw_if_index %d", &sw_if_index))
13488 sw_if_index_set = 1;
13493 if (sw_if_index_set == 0)
13498 if (!vam->json_output)
13500 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
13501 "sw_if_index", "local_address", "remote_address",
13502 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13505 /* Get list of geneve-tunnel interfaces */
13506 M (GENEVE_TUNNEL_DUMP, mp);
13508 mp->sw_if_index = htonl (sw_if_index);
13512 /* Use a control ping for synchronization */
13513 M (CONTROL_PING, mp_ping);
13521 api_gre_add_del_tunnel (vat_main_t * vam)
13523 unformat_input_t *line_input = vam->input;
13524 vl_api_gre_add_del_tunnel_t *mp;
13525 ip4_address_t src4, dst4;
13526 ip6_address_t src6, dst6;
13530 u8 t_type = GRE_TUNNEL_TYPE_L3;
13533 u32 outer_fib_id = 0;
13534 u32 session_id = 0;
13538 memset (&src4, 0, sizeof src4);
13539 memset (&dst4, 0, sizeof dst4);
13540 memset (&src6, 0, sizeof src6);
13541 memset (&dst6, 0, sizeof dst6);
13543 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13545 if (unformat (line_input, "del"))
13547 else if (unformat (line_input, "instance %d", &instance))
13549 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
13554 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
13559 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
13564 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
13569 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
13571 else if (unformat (line_input, "teb"))
13572 t_type = GRE_TUNNEL_TYPE_TEB;
13573 else if (unformat (line_input, "erspan %d", &session_id))
13574 t_type = GRE_TUNNEL_TYPE_ERSPAN;
13577 errmsg ("parse error '%U'", format_unformat_error, line_input);
13584 errmsg ("tunnel src address not specified");
13589 errmsg ("tunnel dst address not specified");
13592 if (ipv4_set && ipv6_set)
13594 errmsg ("both IPv4 and IPv6 addresses specified");
13599 M (GRE_ADD_DEL_TUNNEL, mp);
13603 clib_memcpy (&mp->src_address, &src4, 4);
13604 clib_memcpy (&mp->dst_address, &dst4, 4);
13608 clib_memcpy (&mp->src_address, &src6, 16);
13609 clib_memcpy (&mp->dst_address, &dst6, 16);
13611 mp->instance = htonl (instance);
13612 mp->outer_fib_id = htonl (outer_fib_id);
13613 mp->is_add = is_add;
13614 mp->session_id = htons ((u16) session_id);
13615 mp->tunnel_type = t_type;
13616 mp->is_ipv6 = ipv6_set;
13623 static void vl_api_gre_tunnel_details_t_handler
13624 (vl_api_gre_tunnel_details_t * mp)
13626 vat_main_t *vam = &vat_main;
13627 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
13628 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
13630 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
13631 ntohl (mp->sw_if_index),
13632 ntohl (mp->instance),
13633 format_ip46_address, &src, IP46_TYPE_ANY,
13634 format_ip46_address, &dst, IP46_TYPE_ANY,
13635 mp->tunnel_type, ntohl (mp->outer_fib_id), ntohl (mp->session_id));
13638 static void vl_api_gre_tunnel_details_t_handler_json
13639 (vl_api_gre_tunnel_details_t * mp)
13641 vat_main_t *vam = &vat_main;
13642 vat_json_node_t *node = NULL;
13643 struct in_addr ip4;
13644 struct in6_addr ip6;
13646 if (VAT_JSON_ARRAY != vam->json_tree.type)
13648 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13649 vat_json_init_array (&vam->json_tree);
13651 node = vat_json_array_add (&vam->json_tree);
13653 vat_json_init_object (node);
13654 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13655 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13658 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
13659 vat_json_object_add_ip4 (node, "src_address", ip4);
13660 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
13661 vat_json_object_add_ip4 (node, "dst_address", ip4);
13665 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
13666 vat_json_object_add_ip6 (node, "src_address", ip6);
13667 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
13668 vat_json_object_add_ip6 (node, "dst_address", ip6);
13670 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel_type);
13671 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
13672 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
13673 vat_json_object_add_uint (node, "session_id", mp->session_id);
13677 api_gre_tunnel_dump (vat_main_t * vam)
13679 unformat_input_t *i = vam->input;
13680 vl_api_gre_tunnel_dump_t *mp;
13681 vl_api_control_ping_t *mp_ping;
13683 u8 sw_if_index_set = 0;
13686 /* Parse args required to build the message */
13687 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13689 if (unformat (i, "sw_if_index %d", &sw_if_index))
13690 sw_if_index_set = 1;
13695 if (sw_if_index_set == 0)
13700 if (!vam->json_output)
13702 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
13703 "sw_if_index", "instance", "src_address", "dst_address",
13704 "tunnel_type", "outer_fib_id", "session_id");
13707 /* Get list of gre-tunnel interfaces */
13708 M (GRE_TUNNEL_DUMP, mp);
13710 mp->sw_if_index = htonl (sw_if_index);
13714 /* Use a control ping for synchronization */
13715 MPING (CONTROL_PING, mp_ping);
13723 api_l2_fib_clear_table (vat_main_t * vam)
13725 // unformat_input_t * i = vam->input;
13726 vl_api_l2_fib_clear_table_t *mp;
13729 M (L2_FIB_CLEAR_TABLE, mp);
13737 api_l2_interface_efp_filter (vat_main_t * vam)
13739 unformat_input_t *i = vam->input;
13740 vl_api_l2_interface_efp_filter_t *mp;
13743 u8 sw_if_index_set = 0;
13746 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13748 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13749 sw_if_index_set = 1;
13750 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13751 sw_if_index_set = 1;
13752 else if (unformat (i, "enable"))
13754 else if (unformat (i, "disable"))
13758 clib_warning ("parse error '%U'", format_unformat_error, i);
13763 if (sw_if_index_set == 0)
13765 errmsg ("missing sw_if_index");
13769 M (L2_INTERFACE_EFP_FILTER, mp);
13771 mp->sw_if_index = ntohl (sw_if_index);
13772 mp->enable_disable = enable;
13779 #define foreach_vtr_op \
13780 _("disable", L2_VTR_DISABLED) \
13781 _("push-1", L2_VTR_PUSH_1) \
13782 _("push-2", L2_VTR_PUSH_2) \
13783 _("pop-1", L2_VTR_POP_1) \
13784 _("pop-2", L2_VTR_POP_2) \
13785 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
13786 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
13787 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
13788 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
13791 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
13793 unformat_input_t *i = vam->input;
13794 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
13796 u8 sw_if_index_set = 0;
13799 u32 push_dot1q = 1;
13804 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13806 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13807 sw_if_index_set = 1;
13808 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13809 sw_if_index_set = 1;
13810 else if (unformat (i, "vtr_op %d", &vtr_op))
13812 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
13815 else if (unformat (i, "push_dot1q %d", &push_dot1q))
13817 else if (unformat (i, "tag1 %d", &tag1))
13819 else if (unformat (i, "tag2 %d", &tag2))
13823 clib_warning ("parse error '%U'", format_unformat_error, i);
13828 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
13830 errmsg ("missing vtr operation or sw_if_index");
13834 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
13835 mp->sw_if_index = ntohl (sw_if_index);
13836 mp->vtr_op = ntohl (vtr_op);
13837 mp->push_dot1q = ntohl (push_dot1q);
13838 mp->tag1 = ntohl (tag1);
13839 mp->tag2 = ntohl (tag2);
13847 api_create_vhost_user_if (vat_main_t * vam)
13849 unformat_input_t *i = vam->input;
13850 vl_api_create_vhost_user_if_t *mp;
13853 u8 file_name_set = 0;
13854 u32 custom_dev_instance = ~0;
13856 u8 use_custom_mac = 0;
13860 /* Shut up coverity */
13861 memset (hwaddr, 0, sizeof (hwaddr));
13863 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13865 if (unformat (i, "socket %s", &file_name))
13869 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13871 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
13872 use_custom_mac = 1;
13873 else if (unformat (i, "server"))
13875 else if (unformat (i, "tag %s", &tag))
13881 if (file_name_set == 0)
13883 errmsg ("missing socket file name");
13887 if (vec_len (file_name) > 255)
13889 errmsg ("socket file name too long");
13892 vec_add1 (file_name, 0);
13894 M (CREATE_VHOST_USER_IF, mp);
13896 mp->is_server = is_server;
13897 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13898 vec_free (file_name);
13899 if (custom_dev_instance != ~0)
13902 mp->custom_dev_instance = ntohl (custom_dev_instance);
13904 mp->use_custom_mac = use_custom_mac;
13905 clib_memcpy (mp->mac_address, hwaddr, 6);
13907 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
13916 api_modify_vhost_user_if (vat_main_t * vam)
13918 unformat_input_t *i = vam->input;
13919 vl_api_modify_vhost_user_if_t *mp;
13922 u8 file_name_set = 0;
13923 u32 custom_dev_instance = ~0;
13924 u8 sw_if_index_set = 0;
13925 u32 sw_if_index = (u32) ~ 0;
13928 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13930 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13931 sw_if_index_set = 1;
13932 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13933 sw_if_index_set = 1;
13934 else if (unformat (i, "socket %s", &file_name))
13938 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13940 else if (unformat (i, "server"))
13946 if (sw_if_index_set == 0)
13948 errmsg ("missing sw_if_index or interface name");
13952 if (file_name_set == 0)
13954 errmsg ("missing socket file name");
13958 if (vec_len (file_name) > 255)
13960 errmsg ("socket file name too long");
13963 vec_add1 (file_name, 0);
13965 M (MODIFY_VHOST_USER_IF, mp);
13967 mp->sw_if_index = ntohl (sw_if_index);
13968 mp->is_server = is_server;
13969 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13970 vec_free (file_name);
13971 if (custom_dev_instance != ~0)
13974 mp->custom_dev_instance = ntohl (custom_dev_instance);
13983 api_delete_vhost_user_if (vat_main_t * vam)
13985 unformat_input_t *i = vam->input;
13986 vl_api_delete_vhost_user_if_t *mp;
13987 u32 sw_if_index = ~0;
13988 u8 sw_if_index_set = 0;
13991 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13993 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13994 sw_if_index_set = 1;
13995 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13996 sw_if_index_set = 1;
14001 if (sw_if_index_set == 0)
14003 errmsg ("missing sw_if_index or interface name");
14008 M (DELETE_VHOST_USER_IF, mp);
14010 mp->sw_if_index = ntohl (sw_if_index);
14017 static void vl_api_sw_interface_vhost_user_details_t_handler
14018 (vl_api_sw_interface_vhost_user_details_t * mp)
14020 vat_main_t *vam = &vat_main;
14022 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
14023 (char *) mp->interface_name,
14024 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
14025 clib_net_to_host_u64 (mp->features), mp->is_server,
14026 ntohl (mp->num_regions), (char *) mp->sock_filename);
14027 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
14030 static void vl_api_sw_interface_vhost_user_details_t_handler_json
14031 (vl_api_sw_interface_vhost_user_details_t * mp)
14033 vat_main_t *vam = &vat_main;
14034 vat_json_node_t *node = NULL;
14036 if (VAT_JSON_ARRAY != vam->json_tree.type)
14038 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14039 vat_json_init_array (&vam->json_tree);
14041 node = vat_json_array_add (&vam->json_tree);
14043 vat_json_init_object (node);
14044 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14045 vat_json_object_add_string_copy (node, "interface_name",
14046 mp->interface_name);
14047 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
14048 ntohl (mp->virtio_net_hdr_sz));
14049 vat_json_object_add_uint (node, "features",
14050 clib_net_to_host_u64 (mp->features));
14051 vat_json_object_add_uint (node, "is_server", mp->is_server);
14052 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
14053 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
14054 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
14058 api_sw_interface_vhost_user_dump (vat_main_t * vam)
14060 vl_api_sw_interface_vhost_user_dump_t *mp;
14061 vl_api_control_ping_t *mp_ping;
14064 "Interface name idx hdr_sz features server regions filename");
14066 /* Get list of vhost-user interfaces */
14067 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
14070 /* Use a control ping for synchronization */
14071 MPING (CONTROL_PING, mp_ping);
14079 api_show_version (vat_main_t * vam)
14081 vl_api_show_version_t *mp;
14084 M (SHOW_VERSION, mp);
14093 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
14095 unformat_input_t *line_input = vam->input;
14096 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
14097 ip4_address_t local4, remote4;
14098 ip6_address_t local6, remote6;
14100 u8 ipv4_set = 0, ipv6_set = 0;
14104 u32 mcast_sw_if_index = ~0;
14105 u32 encap_vrf_id = 0;
14106 u32 decap_vrf_id = 0;
14112 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
14113 memset (&local4, 0, sizeof local4);
14114 memset (&remote4, 0, sizeof remote4);
14115 memset (&local6, 0, sizeof local6);
14116 memset (&remote6, 0, sizeof remote6);
14118 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14120 if (unformat (line_input, "del"))
14122 else if (unformat (line_input, "local %U",
14123 unformat_ip4_address, &local4))
14128 else if (unformat (line_input, "remote %U",
14129 unformat_ip4_address, &remote4))
14134 else if (unformat (line_input, "local %U",
14135 unformat_ip6_address, &local6))
14140 else if (unformat (line_input, "remote %U",
14141 unformat_ip6_address, &remote6))
14146 else if (unformat (line_input, "group %U %U",
14147 unformat_ip4_address, &remote4,
14148 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14150 grp_set = remote_set = 1;
14153 else if (unformat (line_input, "group %U",
14154 unformat_ip4_address, &remote4))
14156 grp_set = remote_set = 1;
14159 else if (unformat (line_input, "group %U %U",
14160 unformat_ip6_address, &remote6,
14161 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14163 grp_set = remote_set = 1;
14166 else if (unformat (line_input, "group %U",
14167 unformat_ip6_address, &remote6))
14169 grp_set = remote_set = 1;
14173 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
14175 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
14177 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
14179 else if (unformat (line_input, "vni %d", &vni))
14181 else if (unformat (line_input, "next-ip4"))
14183 else if (unformat (line_input, "next-ip6"))
14185 else if (unformat (line_input, "next-ethernet"))
14187 else if (unformat (line_input, "next-nsh"))
14191 errmsg ("parse error '%U'", format_unformat_error, line_input);
14196 if (local_set == 0)
14198 errmsg ("tunnel local address not specified");
14201 if (remote_set == 0)
14203 errmsg ("tunnel remote address not specified");
14206 if (grp_set && mcast_sw_if_index == ~0)
14208 errmsg ("tunnel nonexistent multicast device");
14211 if (ipv4_set && ipv6_set)
14213 errmsg ("both IPv4 and IPv6 addresses specified");
14219 errmsg ("vni not specified");
14223 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
14228 clib_memcpy (&mp->local, &local6, sizeof (local6));
14229 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
14233 clib_memcpy (&mp->local, &local4, sizeof (local4));
14234 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
14237 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
14238 mp->encap_vrf_id = ntohl (encap_vrf_id);
14239 mp->decap_vrf_id = ntohl (decap_vrf_id);
14240 mp->protocol = protocol;
14241 mp->vni = ntohl (vni);
14242 mp->is_add = is_add;
14243 mp->is_ipv6 = ipv6_set;
14250 static void vl_api_vxlan_gpe_tunnel_details_t_handler
14251 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14253 vat_main_t *vam = &vat_main;
14254 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
14255 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
14257 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
14258 ntohl (mp->sw_if_index),
14259 format_ip46_address, &local, IP46_TYPE_ANY,
14260 format_ip46_address, &remote, IP46_TYPE_ANY,
14261 ntohl (mp->vni), mp->protocol,
14262 ntohl (mp->mcast_sw_if_index),
14263 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
14267 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
14268 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14270 vat_main_t *vam = &vat_main;
14271 vat_json_node_t *node = NULL;
14272 struct in_addr ip4;
14273 struct in6_addr ip6;
14275 if (VAT_JSON_ARRAY != vam->json_tree.type)
14277 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14278 vat_json_init_array (&vam->json_tree);
14280 node = vat_json_array_add (&vam->json_tree);
14282 vat_json_init_object (node);
14283 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14286 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
14287 vat_json_object_add_ip6 (node, "local", ip6);
14288 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
14289 vat_json_object_add_ip6 (node, "remote", ip6);
14293 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
14294 vat_json_object_add_ip4 (node, "local", ip4);
14295 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
14296 vat_json_object_add_ip4 (node, "remote", ip4);
14298 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
14299 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
14300 vat_json_object_add_uint (node, "mcast_sw_if_index",
14301 ntohl (mp->mcast_sw_if_index));
14302 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
14303 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
14304 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
14308 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
14310 unformat_input_t *i = vam->input;
14311 vl_api_vxlan_gpe_tunnel_dump_t *mp;
14312 vl_api_control_ping_t *mp_ping;
14314 u8 sw_if_index_set = 0;
14317 /* Parse args required to build the message */
14318 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14320 if (unformat (i, "sw_if_index %d", &sw_if_index))
14321 sw_if_index_set = 1;
14326 if (sw_if_index_set == 0)
14331 if (!vam->json_output)
14333 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
14334 "sw_if_index", "local", "remote", "vni",
14335 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
14338 /* Get list of vxlan-tunnel interfaces */
14339 M (VXLAN_GPE_TUNNEL_DUMP, mp);
14341 mp->sw_if_index = htonl (sw_if_index);
14345 /* Use a control ping for synchronization */
14346 MPING (CONTROL_PING, mp_ping);
14353 static void vl_api_l2_fib_table_details_t_handler
14354 (vl_api_l2_fib_table_details_t * mp)
14356 vat_main_t *vam = &vat_main;
14358 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
14360 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
14361 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
14365 static void vl_api_l2_fib_table_details_t_handler_json
14366 (vl_api_l2_fib_table_details_t * mp)
14368 vat_main_t *vam = &vat_main;
14369 vat_json_node_t *node = NULL;
14371 if (VAT_JSON_ARRAY != vam->json_tree.type)
14373 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14374 vat_json_init_array (&vam->json_tree);
14376 node = vat_json_array_add (&vam->json_tree);
14378 vat_json_init_object (node);
14379 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
14380 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
14381 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14382 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
14383 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
14384 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
14388 api_l2_fib_table_dump (vat_main_t * vam)
14390 unformat_input_t *i = vam->input;
14391 vl_api_l2_fib_table_dump_t *mp;
14392 vl_api_control_ping_t *mp_ping;
14397 /* Parse args required to build the message */
14398 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14400 if (unformat (i, "bd_id %d", &bd_id))
14406 if (bd_id_set == 0)
14408 errmsg ("missing bridge domain");
14412 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
14414 /* Get list of l2 fib entries */
14415 M (L2_FIB_TABLE_DUMP, mp);
14417 mp->bd_id = ntohl (bd_id);
14420 /* Use a control ping for synchronization */
14421 MPING (CONTROL_PING, mp_ping);
14430 api_interface_name_renumber (vat_main_t * vam)
14432 unformat_input_t *line_input = vam->input;
14433 vl_api_interface_name_renumber_t *mp;
14434 u32 sw_if_index = ~0;
14435 u32 new_show_dev_instance = ~0;
14438 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14440 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
14443 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14445 else if (unformat (line_input, "new_show_dev_instance %d",
14446 &new_show_dev_instance))
14452 if (sw_if_index == ~0)
14454 errmsg ("missing interface name or sw_if_index");
14458 if (new_show_dev_instance == ~0)
14460 errmsg ("missing new_show_dev_instance");
14464 M (INTERFACE_NAME_RENUMBER, mp);
14466 mp->sw_if_index = ntohl (sw_if_index);
14467 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
14475 api_ip_probe_neighbor (vat_main_t * vam)
14477 unformat_input_t *i = vam->input;
14478 vl_api_ip_probe_neighbor_t *mp;
14486 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14488 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14490 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14492 else if (unformat (i, "address %U", unformat_ip4_address, dst_adr))
14494 else if (unformat (i, "address %U", unformat_ip6_address, dst_adr))
14505 errmsg ("missing interface");
14511 errmsg ("missing addresses");
14515 M (IP_PROBE_NEIGHBOR, mp);
14517 mp->sw_if_index = ntohl (sw_if_index);
14518 mp->is_ipv6 = is_ipv6;
14519 clib_memcpy (mp->dst_address, dst_adr, sizeof (dst_adr));
14527 api_ip_scan_neighbor_enable_disable (vat_main_t * vam)
14529 unformat_input_t *i = vam->input;
14530 vl_api_ip_scan_neighbor_enable_disable_t *mp;
14531 u8 mode = IP_SCAN_V46_NEIGHBORS;
14532 u32 interval = 0, time = 0, update = 0, delay = 0, stale = 0;
14535 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14537 if (unformat (i, "ip4"))
14538 mode = IP_SCAN_V4_NEIGHBORS;
14539 else if (unformat (i, "ip6"))
14540 mode = IP_SCAN_V6_NEIGHBORS;
14541 if (unformat (i, "both"))
14542 mode = IP_SCAN_V46_NEIGHBORS;
14543 else if (unformat (i, "disable"))
14544 mode = IP_SCAN_DISABLED;
14545 else if (unformat (i, "interval %d", &interval))
14547 else if (unformat (i, "max-time %d", &time))
14549 else if (unformat (i, "max-update %d", &update))
14551 else if (unformat (i, "delay %d", &delay))
14553 else if (unformat (i, "stale %d", &stale))
14559 if (interval > 255)
14561 errmsg ("interval cannot exceed 255 minutes.");
14566 errmsg ("max-time cannot exceed 255 usec.");
14571 errmsg ("max-update cannot exceed 255.");
14576 errmsg ("delay cannot exceed 255 msec.");
14581 errmsg ("stale cannot exceed 255 minutes.");
14585 M (IP_SCAN_NEIGHBOR_ENABLE_DISABLE, mp);
14587 mp->scan_interval = interval;
14588 mp->max_proc_time = time;
14589 mp->max_update = update;
14590 mp->scan_int_delay = delay;
14591 mp->stale_threshold = stale;
14599 api_want_ip4_arp_events (vat_main_t * vam)
14601 unformat_input_t *line_input = vam->input;
14602 vl_api_want_ip4_arp_events_t *mp;
14603 ip4_address_t address;
14604 int address_set = 0;
14605 u32 enable_disable = 1;
14608 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14610 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
14612 else if (unformat (line_input, "del"))
14613 enable_disable = 0;
14618 if (address_set == 0)
14620 errmsg ("missing addresses");
14624 M (WANT_IP4_ARP_EVENTS, mp);
14625 mp->enable_disable = enable_disable;
14626 mp->pid = htonl (getpid ());
14627 mp->address = address.as_u32;
14635 api_want_ip6_nd_events (vat_main_t * vam)
14637 unformat_input_t *line_input = vam->input;
14638 vl_api_want_ip6_nd_events_t *mp;
14639 ip6_address_t address;
14640 int address_set = 0;
14641 u32 enable_disable = 1;
14644 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14646 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
14648 else if (unformat (line_input, "del"))
14649 enable_disable = 0;
14654 if (address_set == 0)
14656 errmsg ("missing addresses");
14660 M (WANT_IP6_ND_EVENTS, mp);
14661 mp->enable_disable = enable_disable;
14662 mp->pid = htonl (getpid ());
14663 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
14671 api_want_l2_macs_events (vat_main_t * vam)
14673 unformat_input_t *line_input = vam->input;
14674 vl_api_want_l2_macs_events_t *mp;
14675 u8 enable_disable = 1;
14676 u32 scan_delay = 0;
14677 u32 max_macs_in_event = 0;
14678 u32 learn_limit = 0;
14681 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14683 if (unformat (line_input, "learn-limit %d", &learn_limit))
14685 else if (unformat (line_input, "scan-delay %d", &scan_delay))
14687 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
14689 else if (unformat (line_input, "disable"))
14690 enable_disable = 0;
14695 M (WANT_L2_MACS_EVENTS, mp);
14696 mp->enable_disable = enable_disable;
14697 mp->pid = htonl (getpid ());
14698 mp->learn_limit = htonl (learn_limit);
14699 mp->scan_delay = (u8) scan_delay;
14700 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
14707 api_input_acl_set_interface (vat_main_t * vam)
14709 unformat_input_t *i = vam->input;
14710 vl_api_input_acl_set_interface_t *mp;
14712 int sw_if_index_set;
14713 u32 ip4_table_index = ~0;
14714 u32 ip6_table_index = ~0;
14715 u32 l2_table_index = ~0;
14719 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14721 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14722 sw_if_index_set = 1;
14723 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14724 sw_if_index_set = 1;
14725 else if (unformat (i, "del"))
14727 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14729 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14731 else if (unformat (i, "l2-table %d", &l2_table_index))
14735 clib_warning ("parse error '%U'", format_unformat_error, i);
14740 if (sw_if_index_set == 0)
14742 errmsg ("missing interface name or sw_if_index");
14746 M (INPUT_ACL_SET_INTERFACE, mp);
14748 mp->sw_if_index = ntohl (sw_if_index);
14749 mp->ip4_table_index = ntohl (ip4_table_index);
14750 mp->ip6_table_index = ntohl (ip6_table_index);
14751 mp->l2_table_index = ntohl (l2_table_index);
14752 mp->is_add = is_add;
14760 api_output_acl_set_interface (vat_main_t * vam)
14762 unformat_input_t *i = vam->input;
14763 vl_api_output_acl_set_interface_t *mp;
14765 int sw_if_index_set;
14766 u32 ip4_table_index = ~0;
14767 u32 ip6_table_index = ~0;
14768 u32 l2_table_index = ~0;
14772 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14774 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14775 sw_if_index_set = 1;
14776 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14777 sw_if_index_set = 1;
14778 else if (unformat (i, "del"))
14780 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14782 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14784 else if (unformat (i, "l2-table %d", &l2_table_index))
14788 clib_warning ("parse error '%U'", format_unformat_error, i);
14793 if (sw_if_index_set == 0)
14795 errmsg ("missing interface name or sw_if_index");
14799 M (OUTPUT_ACL_SET_INTERFACE, mp);
14801 mp->sw_if_index = ntohl (sw_if_index);
14802 mp->ip4_table_index = ntohl (ip4_table_index);
14803 mp->ip6_table_index = ntohl (ip6_table_index);
14804 mp->l2_table_index = ntohl (l2_table_index);
14805 mp->is_add = is_add;
14813 api_ip_address_dump (vat_main_t * vam)
14815 unformat_input_t *i = vam->input;
14816 vl_api_ip_address_dump_t *mp;
14817 vl_api_control_ping_t *mp_ping;
14818 u32 sw_if_index = ~0;
14819 u8 sw_if_index_set = 0;
14824 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14826 if (unformat (i, "sw_if_index %d", &sw_if_index))
14827 sw_if_index_set = 1;
14829 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14830 sw_if_index_set = 1;
14831 else if (unformat (i, "ipv4"))
14833 else if (unformat (i, "ipv6"))
14839 if (ipv4_set && ipv6_set)
14841 errmsg ("ipv4 and ipv6 flags cannot be both set");
14845 if ((!ipv4_set) && (!ipv6_set))
14847 errmsg ("no ipv4 nor ipv6 flag set");
14851 if (sw_if_index_set == 0)
14853 errmsg ("missing interface name or sw_if_index");
14857 vam->current_sw_if_index = sw_if_index;
14858 vam->is_ipv6 = ipv6_set;
14860 M (IP_ADDRESS_DUMP, mp);
14861 mp->sw_if_index = ntohl (sw_if_index);
14862 mp->is_ipv6 = ipv6_set;
14865 /* Use a control ping for synchronization */
14866 MPING (CONTROL_PING, mp_ping);
14874 api_ip_dump (vat_main_t * vam)
14876 vl_api_ip_dump_t *mp;
14877 vl_api_control_ping_t *mp_ping;
14878 unformat_input_t *in = vam->input;
14885 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
14887 if (unformat (in, "ipv4"))
14889 else if (unformat (in, "ipv6"))
14895 if (ipv4_set && ipv6_set)
14897 errmsg ("ipv4 and ipv6 flags cannot be both set");
14901 if ((!ipv4_set) && (!ipv6_set))
14903 errmsg ("no ipv4 nor ipv6 flag set");
14907 is_ipv6 = ipv6_set;
14908 vam->is_ipv6 = is_ipv6;
14910 /* free old data */
14911 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
14913 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
14915 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
14918 mp->is_ipv6 = ipv6_set;
14921 /* Use a control ping for synchronization */
14922 MPING (CONTROL_PING, mp_ping);
14930 api_ipsec_spd_add_del (vat_main_t * vam)
14932 unformat_input_t *i = vam->input;
14933 vl_api_ipsec_spd_add_del_t *mp;
14938 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14940 if (unformat (i, "spd_id %d", &spd_id))
14942 else if (unformat (i, "del"))
14946 clib_warning ("parse error '%U'", format_unformat_error, i);
14952 errmsg ("spd_id must be set");
14956 M (IPSEC_SPD_ADD_DEL, mp);
14958 mp->spd_id = ntohl (spd_id);
14959 mp->is_add = is_add;
14967 api_ipsec_interface_add_del_spd (vat_main_t * vam)
14969 unformat_input_t *i = vam->input;
14970 vl_api_ipsec_interface_add_del_spd_t *mp;
14972 u8 sw_if_index_set = 0;
14973 u32 spd_id = (u32) ~ 0;
14977 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14979 if (unformat (i, "del"))
14981 else if (unformat (i, "spd_id %d", &spd_id))
14984 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14985 sw_if_index_set = 1;
14986 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14987 sw_if_index_set = 1;
14990 clib_warning ("parse error '%U'", format_unformat_error, i);
14996 if (spd_id == (u32) ~ 0)
14998 errmsg ("spd_id must be set");
15002 if (sw_if_index_set == 0)
15004 errmsg ("missing interface name or sw_if_index");
15008 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
15010 mp->spd_id = ntohl (spd_id);
15011 mp->sw_if_index = ntohl (sw_if_index);
15012 mp->is_add = is_add;
15020 api_ipsec_spd_add_del_entry (vat_main_t * vam)
15022 unformat_input_t *i = vam->input;
15023 vl_api_ipsec_spd_add_del_entry_t *mp;
15024 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
15025 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
15027 u32 rport_start = 0, rport_stop = (u32) ~ 0;
15028 u32 lport_start = 0, lport_stop = (u32) ~ 0;
15029 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
15030 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
15033 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
15034 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
15035 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
15036 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
15037 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
15038 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
15040 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15042 if (unformat (i, "del"))
15044 if (unformat (i, "outbound"))
15046 if (unformat (i, "inbound"))
15048 else if (unformat (i, "spd_id %d", &spd_id))
15050 else if (unformat (i, "sa_id %d", &sa_id))
15052 else if (unformat (i, "priority %d", &priority))
15054 else if (unformat (i, "protocol %d", &protocol))
15056 else if (unformat (i, "lport_start %d", &lport_start))
15058 else if (unformat (i, "lport_stop %d", &lport_stop))
15060 else if (unformat (i, "rport_start %d", &rport_start))
15062 else if (unformat (i, "rport_stop %d", &rport_stop))
15066 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
15072 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
15079 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
15085 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
15092 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
15098 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
15105 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
15111 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
15117 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
15119 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
15121 clib_warning ("unsupported action: 'resolve'");
15127 clib_warning ("parse error '%U'", format_unformat_error, i);
15133 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
15135 mp->spd_id = ntohl (spd_id);
15136 mp->priority = ntohl (priority);
15137 mp->is_outbound = is_outbound;
15139 mp->is_ipv6 = is_ipv6;
15140 if (is_ipv6 || is_ip_any)
15142 clib_memcpy (mp->remote_address_start, &raddr6_start,
15143 sizeof (ip6_address_t));
15144 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
15145 sizeof (ip6_address_t));
15146 clib_memcpy (mp->local_address_start, &laddr6_start,
15147 sizeof (ip6_address_t));
15148 clib_memcpy (mp->local_address_stop, &laddr6_stop,
15149 sizeof (ip6_address_t));
15153 clib_memcpy (mp->remote_address_start, &raddr4_start,
15154 sizeof (ip4_address_t));
15155 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
15156 sizeof (ip4_address_t));
15157 clib_memcpy (mp->local_address_start, &laddr4_start,
15158 sizeof (ip4_address_t));
15159 clib_memcpy (mp->local_address_stop, &laddr4_stop,
15160 sizeof (ip4_address_t));
15162 mp->protocol = (u8) protocol;
15163 mp->local_port_start = ntohs ((u16) lport_start);
15164 mp->local_port_stop = ntohs ((u16) lport_stop);
15165 mp->remote_port_start = ntohs ((u16) rport_start);
15166 mp->remote_port_stop = ntohs ((u16) rport_stop);
15167 mp->policy = (u8) policy;
15168 mp->sa_id = ntohl (sa_id);
15169 mp->is_add = is_add;
15170 mp->is_ip_any = is_ip_any;
15177 api_ipsec_sad_add_del_entry (vat_main_t * vam)
15179 unformat_input_t *i = vam->input;
15180 vl_api_ipsec_sad_add_del_entry_t *mp;
15181 u32 sad_id = 0, spi = 0;
15182 u8 *ck = 0, *ik = 0;
15185 u8 protocol = IPSEC_PROTOCOL_AH;
15186 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
15187 u32 crypto_alg = 0, integ_alg = 0;
15188 ip4_address_t tun_src4;
15189 ip4_address_t tun_dst4;
15190 ip6_address_t tun_src6;
15191 ip6_address_t tun_dst6;
15194 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15196 if (unformat (i, "del"))
15198 else if (unformat (i, "sad_id %d", &sad_id))
15200 else if (unformat (i, "spi %d", &spi))
15202 else if (unformat (i, "esp"))
15203 protocol = IPSEC_PROTOCOL_ESP;
15204 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
15207 is_tunnel_ipv6 = 0;
15209 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
15212 is_tunnel_ipv6 = 0;
15214 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
15217 is_tunnel_ipv6 = 1;
15219 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
15222 is_tunnel_ipv6 = 1;
15226 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15228 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
15230 clib_warning ("unsupported crypto-alg: '%U'",
15231 format_ipsec_crypto_alg, crypto_alg);
15235 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15239 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15241 if (integ_alg >= IPSEC_INTEG_N_ALG)
15243 clib_warning ("unsupported integ-alg: '%U'",
15244 format_ipsec_integ_alg, integ_alg);
15248 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15252 clib_warning ("parse error '%U'", format_unformat_error, i);
15258 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
15260 mp->sad_id = ntohl (sad_id);
15261 mp->is_add = is_add;
15262 mp->protocol = protocol;
15263 mp->spi = ntohl (spi);
15264 mp->is_tunnel = is_tunnel;
15265 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
15266 mp->crypto_algorithm = crypto_alg;
15267 mp->integrity_algorithm = integ_alg;
15268 mp->crypto_key_length = vec_len (ck);
15269 mp->integrity_key_length = vec_len (ik);
15271 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15272 mp->crypto_key_length = sizeof (mp->crypto_key);
15274 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15275 mp->integrity_key_length = sizeof (mp->integrity_key);
15278 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15280 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15284 if (is_tunnel_ipv6)
15286 clib_memcpy (mp->tunnel_src_address, &tun_src6,
15287 sizeof (ip6_address_t));
15288 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
15289 sizeof (ip6_address_t));
15293 clib_memcpy (mp->tunnel_src_address, &tun_src4,
15294 sizeof (ip4_address_t));
15295 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
15296 sizeof (ip4_address_t));
15306 api_ipsec_sa_set_key (vat_main_t * vam)
15308 unformat_input_t *i = vam->input;
15309 vl_api_ipsec_sa_set_key_t *mp;
15311 u8 *ck = 0, *ik = 0;
15314 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15316 if (unformat (i, "sa_id %d", &sa_id))
15318 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15320 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15324 clib_warning ("parse error '%U'", format_unformat_error, i);
15329 M (IPSEC_SA_SET_KEY, mp);
15331 mp->sa_id = ntohl (sa_id);
15332 mp->crypto_key_length = vec_len (ck);
15333 mp->integrity_key_length = vec_len (ik);
15335 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15336 mp->crypto_key_length = sizeof (mp->crypto_key);
15338 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15339 mp->integrity_key_length = sizeof (mp->integrity_key);
15342 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15344 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15352 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
15354 unformat_input_t *i = vam->input;
15355 vl_api_ipsec_tunnel_if_add_del_t *mp;
15356 u32 local_spi = 0, remote_spi = 0;
15357 u32 crypto_alg = 0, integ_alg = 0;
15358 u8 *lck = NULL, *rck = NULL;
15359 u8 *lik = NULL, *rik = NULL;
15360 ip4_address_t local_ip = { {0} };
15361 ip4_address_t remote_ip = { {0} };
15364 u8 anti_replay = 0;
15369 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15371 if (unformat (i, "del"))
15373 else if (unformat (i, "esn"))
15375 else if (unformat (i, "anti_replay"))
15377 else if (unformat (i, "local_spi %d", &local_spi))
15379 else if (unformat (i, "remote_spi %d", &remote_spi))
15381 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
15383 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
15385 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
15388 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
15390 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
15392 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
15396 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15398 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
15400 errmsg ("unsupported crypto-alg: '%U'\n",
15401 format_ipsec_crypto_alg, crypto_alg);
15407 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15409 if (integ_alg >= IPSEC_INTEG_N_ALG)
15411 errmsg ("unsupported integ-alg: '%U'\n",
15412 format_ipsec_integ_alg, integ_alg);
15416 else if (unformat (i, "instance %u", &instance))
15420 errmsg ("parse error '%U'\n", format_unformat_error, i);
15425 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
15427 mp->is_add = is_add;
15429 mp->anti_replay = anti_replay;
15431 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
15432 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
15434 mp->local_spi = htonl (local_spi);
15435 mp->remote_spi = htonl (remote_spi);
15436 mp->crypto_alg = (u8) crypto_alg;
15438 mp->local_crypto_key_len = 0;
15441 mp->local_crypto_key_len = vec_len (lck);
15442 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
15443 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
15444 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
15447 mp->remote_crypto_key_len = 0;
15450 mp->remote_crypto_key_len = vec_len (rck);
15451 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
15452 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
15453 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
15456 mp->integ_alg = (u8) integ_alg;
15458 mp->local_integ_key_len = 0;
15461 mp->local_integ_key_len = vec_len (lik);
15462 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
15463 mp->local_integ_key_len = sizeof (mp->local_integ_key);
15464 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
15467 mp->remote_integ_key_len = 0;
15470 mp->remote_integ_key_len = vec_len (rik);
15471 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
15472 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
15473 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
15478 mp->renumber = renumber;
15479 mp->show_instance = ntohl (instance);
15488 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
15490 vat_main_t *vam = &vat_main;
15492 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
15493 "crypto_key %U integ_alg %u integ_key %U use_esn %u "
15494 "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u "
15495 "tunnel_src_addr %U tunnel_dst_addr %U "
15496 "salt %u seq_outbound %lu last_seq_inbound %lu "
15497 "replay_window %lu total_data_size %lu\n",
15498 ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi),
15500 mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len,
15501 mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len,
15502 mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6,
15503 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15504 mp->tunnel_src_addr,
15505 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15506 mp->tunnel_dst_addr,
15508 clib_net_to_host_u64 (mp->seq_outbound),
15509 clib_net_to_host_u64 (mp->last_seq_inbound),
15510 clib_net_to_host_u64 (mp->replay_window),
15511 clib_net_to_host_u64 (mp->total_data_size));
15514 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
15515 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
15517 static void vl_api_ipsec_sa_details_t_handler_json
15518 (vl_api_ipsec_sa_details_t * mp)
15520 vat_main_t *vam = &vat_main;
15521 vat_json_node_t *node = NULL;
15522 struct in_addr src_ip4, dst_ip4;
15523 struct in6_addr src_ip6, dst_ip6;
15525 if (VAT_JSON_ARRAY != vam->json_tree.type)
15527 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15528 vat_json_init_array (&vam->json_tree);
15530 node = vat_json_array_add (&vam->json_tree);
15532 vat_json_init_object (node);
15533 vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id));
15534 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
15535 vat_json_object_add_uint (node, "spi", ntohl (mp->spi));
15536 vat_json_object_add_uint (node, "proto", mp->protocol);
15537 vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg);
15538 vat_json_object_add_uint (node, "integ_alg", mp->integ_alg);
15539 vat_json_object_add_uint (node, "use_esn", mp->use_esn);
15540 vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay);
15541 vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel);
15542 vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6);
15543 vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key,
15544 mp->crypto_key_len);
15545 vat_json_object_add_bytes (node, "integ_key", mp->integ_key,
15546 mp->integ_key_len);
15547 if (mp->is_tunnel_ip6)
15549 clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6));
15550 vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6);
15551 clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6));
15552 vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6);
15556 clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4));
15557 vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4);
15558 clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4));
15559 vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4);
15561 vat_json_object_add_uint (node, "replay_window",
15562 clib_net_to_host_u64 (mp->replay_window));
15563 vat_json_object_add_uint (node, "total_data_size",
15564 clib_net_to_host_u64 (mp->total_data_size));
15569 api_ipsec_sa_dump (vat_main_t * vam)
15571 unformat_input_t *i = vam->input;
15572 vl_api_ipsec_sa_dump_t *mp;
15573 vl_api_control_ping_t *mp_ping;
15577 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15579 if (unformat (i, "sa_id %d", &sa_id))
15583 clib_warning ("parse error '%U'", format_unformat_error, i);
15588 M (IPSEC_SA_DUMP, mp);
15590 mp->sa_id = ntohl (sa_id);
15594 /* Use a control ping for synchronization */
15595 M (CONTROL_PING, mp_ping);
15603 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
15605 unformat_input_t *i = vam->input;
15606 vl_api_ipsec_tunnel_if_set_key_t *mp;
15607 u32 sw_if_index = ~0;
15608 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
15613 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15615 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15618 if (unformat (i, "local crypto %U", unformat_ipsec_crypto_alg, &alg))
15619 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
15621 if (unformat (i, "remote crypto %U", unformat_ipsec_crypto_alg, &alg))
15622 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
15623 else if (unformat (i, "local integ %U", unformat_ipsec_integ_alg, &alg))
15624 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
15626 if (unformat (i, "remote integ %U", unformat_ipsec_integ_alg, &alg))
15627 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
15628 else if (unformat (i, "%U", unformat_hex_string, &key))
15632 clib_warning ("parse error '%U'", format_unformat_error, i);
15637 if (sw_if_index == ~0)
15639 errmsg ("interface must be specified");
15643 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
15645 errmsg ("key type must be specified");
15651 errmsg ("algorithm must be specified");
15655 if (vec_len (key) == 0)
15657 errmsg ("key must be specified");
15661 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
15663 mp->sw_if_index = htonl (sw_if_index);
15665 mp->key_type = key_type;
15666 mp->key_len = vec_len (key);
15667 clib_memcpy (mp->key, key, vec_len (key));
15676 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
15678 unformat_input_t *i = vam->input;
15679 vl_api_ipsec_tunnel_if_set_sa_t *mp;
15680 u32 sw_if_index = ~0;
15682 u8 is_outbound = (u8) ~ 0;
15685 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15687 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15689 else if (unformat (i, "sa_id %d", &sa_id))
15691 else if (unformat (i, "outbound"))
15693 else if (unformat (i, "inbound"))
15697 clib_warning ("parse error '%U'", format_unformat_error, i);
15702 if (sw_if_index == ~0)
15704 errmsg ("interface must be specified");
15710 errmsg ("SA ID must be specified");
15714 M (IPSEC_TUNNEL_IF_SET_SA, mp);
15716 mp->sw_if_index = htonl (sw_if_index);
15717 mp->sa_id = htonl (sa_id);
15718 mp->is_outbound = is_outbound;
15727 api_ikev2_profile_add_del (vat_main_t * vam)
15729 unformat_input_t *i = vam->input;
15730 vl_api_ikev2_profile_add_del_t *mp;
15735 const char *valid_chars = "a-zA-Z0-9_";
15737 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15739 if (unformat (i, "del"))
15741 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15742 vec_add1 (name, 0);
15745 errmsg ("parse error '%U'", format_unformat_error, i);
15750 if (!vec_len (name))
15752 errmsg ("profile name must be specified");
15756 if (vec_len (name) > 64)
15758 errmsg ("profile name too long");
15762 M (IKEV2_PROFILE_ADD_DEL, mp);
15764 clib_memcpy (mp->name, name, vec_len (name));
15765 mp->is_add = is_add;
15774 api_ikev2_profile_set_auth (vat_main_t * vam)
15776 unformat_input_t *i = vam->input;
15777 vl_api_ikev2_profile_set_auth_t *mp;
15780 u32 auth_method = 0;
15784 const char *valid_chars = "a-zA-Z0-9_";
15786 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15788 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15789 vec_add1 (name, 0);
15790 else if (unformat (i, "auth_method %U",
15791 unformat_ikev2_auth_method, &auth_method))
15793 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
15795 else if (unformat (i, "auth_data %v", &data))
15799 errmsg ("parse error '%U'", format_unformat_error, i);
15804 if (!vec_len (name))
15806 errmsg ("profile name must be specified");
15810 if (vec_len (name) > 64)
15812 errmsg ("profile name too long");
15816 if (!vec_len (data))
15818 errmsg ("auth_data must be specified");
15824 errmsg ("auth_method must be specified");
15828 M (IKEV2_PROFILE_SET_AUTH, mp);
15830 mp->is_hex = is_hex;
15831 mp->auth_method = (u8) auth_method;
15832 mp->data_len = vec_len (data);
15833 clib_memcpy (mp->name, name, vec_len (name));
15834 clib_memcpy (mp->data, data, vec_len (data));
15844 api_ikev2_profile_set_id (vat_main_t * vam)
15846 unformat_input_t *i = vam->input;
15847 vl_api_ikev2_profile_set_id_t *mp;
15855 const char *valid_chars = "a-zA-Z0-9_";
15857 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15859 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15860 vec_add1 (name, 0);
15861 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
15863 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
15865 data = vec_new (u8, 4);
15866 clib_memcpy (data, ip4.as_u8, 4);
15868 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
15870 else if (unformat (i, "id_data %v", &data))
15872 else if (unformat (i, "local"))
15874 else if (unformat (i, "remote"))
15878 errmsg ("parse error '%U'", format_unformat_error, i);
15883 if (!vec_len (name))
15885 errmsg ("profile name must be specified");
15889 if (vec_len (name) > 64)
15891 errmsg ("profile name too long");
15895 if (!vec_len (data))
15897 errmsg ("id_data must be specified");
15903 errmsg ("id_type must be specified");
15907 M (IKEV2_PROFILE_SET_ID, mp);
15909 mp->is_local = is_local;
15910 mp->id_type = (u8) id_type;
15911 mp->data_len = vec_len (data);
15912 clib_memcpy (mp->name, name, vec_len (name));
15913 clib_memcpy (mp->data, data, vec_len (data));
15923 api_ikev2_profile_set_ts (vat_main_t * vam)
15925 unformat_input_t *i = vam->input;
15926 vl_api_ikev2_profile_set_ts_t *mp;
15929 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
15930 ip4_address_t start_addr, end_addr;
15932 const char *valid_chars = "a-zA-Z0-9_";
15935 start_addr.as_u32 = 0;
15936 end_addr.as_u32 = (u32) ~ 0;
15938 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15940 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15941 vec_add1 (name, 0);
15942 else if (unformat (i, "protocol %d", &proto))
15944 else if (unformat (i, "start_port %d", &start_port))
15946 else if (unformat (i, "end_port %d", &end_port))
15949 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
15951 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
15953 else if (unformat (i, "local"))
15955 else if (unformat (i, "remote"))
15959 errmsg ("parse error '%U'", format_unformat_error, i);
15964 if (!vec_len (name))
15966 errmsg ("profile name must be specified");
15970 if (vec_len (name) > 64)
15972 errmsg ("profile name too long");
15976 M (IKEV2_PROFILE_SET_TS, mp);
15978 mp->is_local = is_local;
15979 mp->proto = (u8) proto;
15980 mp->start_port = (u16) start_port;
15981 mp->end_port = (u16) end_port;
15982 mp->start_addr = start_addr.as_u32;
15983 mp->end_addr = end_addr.as_u32;
15984 clib_memcpy (mp->name, name, vec_len (name));
15993 api_ikev2_set_local_key (vat_main_t * vam)
15995 unformat_input_t *i = vam->input;
15996 vl_api_ikev2_set_local_key_t *mp;
16000 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16002 if (unformat (i, "file %v", &file))
16003 vec_add1 (file, 0);
16006 errmsg ("parse error '%U'", format_unformat_error, i);
16011 if (!vec_len (file))
16013 errmsg ("RSA key file must be specified");
16017 if (vec_len (file) > 256)
16019 errmsg ("file name too long");
16023 M (IKEV2_SET_LOCAL_KEY, mp);
16025 clib_memcpy (mp->key_file, file, vec_len (file));
16034 api_ikev2_set_responder (vat_main_t * vam)
16036 unformat_input_t *i = vam->input;
16037 vl_api_ikev2_set_responder_t *mp;
16040 u32 sw_if_index = ~0;
16041 ip4_address_t address;
16043 const char *valid_chars = "a-zA-Z0-9_";
16045 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16048 (i, "%U interface %d address %U", unformat_token, valid_chars,
16049 &name, &sw_if_index, unformat_ip4_address, &address))
16050 vec_add1 (name, 0);
16053 errmsg ("parse error '%U'", format_unformat_error, i);
16058 if (!vec_len (name))
16060 errmsg ("profile name must be specified");
16064 if (vec_len (name) > 64)
16066 errmsg ("profile name too long");
16070 M (IKEV2_SET_RESPONDER, mp);
16072 clib_memcpy (mp->name, name, vec_len (name));
16075 mp->sw_if_index = sw_if_index;
16076 clib_memcpy (mp->address, &address, sizeof (address));
16084 api_ikev2_set_ike_transforms (vat_main_t * vam)
16086 unformat_input_t *i = vam->input;
16087 vl_api_ikev2_set_ike_transforms_t *mp;
16090 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
16092 const char *valid_chars = "a-zA-Z0-9_";
16094 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16096 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
16097 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
16098 vec_add1 (name, 0);
16101 errmsg ("parse error '%U'", format_unformat_error, i);
16106 if (!vec_len (name))
16108 errmsg ("profile name must be specified");
16112 if (vec_len (name) > 64)
16114 errmsg ("profile name too long");
16118 M (IKEV2_SET_IKE_TRANSFORMS, mp);
16120 clib_memcpy (mp->name, name, vec_len (name));
16122 mp->crypto_alg = crypto_alg;
16123 mp->crypto_key_size = crypto_key_size;
16124 mp->integ_alg = integ_alg;
16125 mp->dh_group = dh_group;
16134 api_ikev2_set_esp_transforms (vat_main_t * vam)
16136 unformat_input_t *i = vam->input;
16137 vl_api_ikev2_set_esp_transforms_t *mp;
16140 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
16142 const char *valid_chars = "a-zA-Z0-9_";
16144 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16146 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
16147 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
16148 vec_add1 (name, 0);
16151 errmsg ("parse error '%U'", format_unformat_error, i);
16156 if (!vec_len (name))
16158 errmsg ("profile name must be specified");
16162 if (vec_len (name) > 64)
16164 errmsg ("profile name too long");
16168 M (IKEV2_SET_ESP_TRANSFORMS, mp);
16170 clib_memcpy (mp->name, name, vec_len (name));
16172 mp->crypto_alg = crypto_alg;
16173 mp->crypto_key_size = crypto_key_size;
16174 mp->integ_alg = integ_alg;
16175 mp->dh_group = dh_group;
16183 api_ikev2_set_sa_lifetime (vat_main_t * vam)
16185 unformat_input_t *i = vam->input;
16186 vl_api_ikev2_set_sa_lifetime_t *mp;
16189 u64 lifetime, lifetime_maxdata;
16190 u32 lifetime_jitter, handover;
16192 const char *valid_chars = "a-zA-Z0-9_";
16194 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16196 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
16197 &lifetime, &lifetime_jitter, &handover,
16198 &lifetime_maxdata))
16199 vec_add1 (name, 0);
16202 errmsg ("parse error '%U'", format_unformat_error, i);
16207 if (!vec_len (name))
16209 errmsg ("profile name must be specified");
16213 if (vec_len (name) > 64)
16215 errmsg ("profile name too long");
16219 M (IKEV2_SET_SA_LIFETIME, mp);
16221 clib_memcpy (mp->name, name, vec_len (name));
16223 mp->lifetime = lifetime;
16224 mp->lifetime_jitter = lifetime_jitter;
16225 mp->handover = handover;
16226 mp->lifetime_maxdata = lifetime_maxdata;
16234 api_ikev2_initiate_sa_init (vat_main_t * vam)
16236 unformat_input_t *i = vam->input;
16237 vl_api_ikev2_initiate_sa_init_t *mp;
16241 const char *valid_chars = "a-zA-Z0-9_";
16243 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16245 if (unformat (i, "%U", unformat_token, valid_chars, &name))
16246 vec_add1 (name, 0);
16249 errmsg ("parse error '%U'", format_unformat_error, i);
16254 if (!vec_len (name))
16256 errmsg ("profile name must be specified");
16260 if (vec_len (name) > 64)
16262 errmsg ("profile name too long");
16266 M (IKEV2_INITIATE_SA_INIT, mp);
16268 clib_memcpy (mp->name, name, vec_len (name));
16277 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
16279 unformat_input_t *i = vam->input;
16280 vl_api_ikev2_initiate_del_ike_sa_t *mp;
16285 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16287 if (unformat (i, "%lx", &ispi))
16291 errmsg ("parse error '%U'", format_unformat_error, i);
16296 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
16306 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
16308 unformat_input_t *i = vam->input;
16309 vl_api_ikev2_initiate_del_child_sa_t *mp;
16314 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16316 if (unformat (i, "%x", &ispi))
16320 errmsg ("parse error '%U'", format_unformat_error, i);
16325 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
16335 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
16337 unformat_input_t *i = vam->input;
16338 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
16343 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16345 if (unformat (i, "%x", &ispi))
16349 errmsg ("parse error '%U'", format_unformat_error, i);
16354 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
16364 api_get_first_msg_id (vat_main_t * vam)
16366 vl_api_get_first_msg_id_t *mp;
16367 unformat_input_t *i = vam->input;
16372 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16374 if (unformat (i, "client %s", &name))
16382 errmsg ("missing client name");
16385 vec_add1 (name, 0);
16387 if (vec_len (name) > 63)
16389 errmsg ("client name too long");
16393 M (GET_FIRST_MSG_ID, mp);
16394 clib_memcpy (mp->name, name, vec_len (name));
16401 api_cop_interface_enable_disable (vat_main_t * vam)
16403 unformat_input_t *line_input = vam->input;
16404 vl_api_cop_interface_enable_disable_t *mp;
16405 u32 sw_if_index = ~0;
16406 u8 enable_disable = 1;
16409 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16411 if (unformat (line_input, "disable"))
16412 enable_disable = 0;
16413 if (unformat (line_input, "enable"))
16414 enable_disable = 1;
16415 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16416 vam, &sw_if_index))
16418 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16424 if (sw_if_index == ~0)
16426 errmsg ("missing interface name or sw_if_index");
16430 /* Construct the API message */
16431 M (COP_INTERFACE_ENABLE_DISABLE, mp);
16432 mp->sw_if_index = ntohl (sw_if_index);
16433 mp->enable_disable = enable_disable;
16437 /* Wait for the reply */
16443 api_cop_whitelist_enable_disable (vat_main_t * vam)
16445 unformat_input_t *line_input = vam->input;
16446 vl_api_cop_whitelist_enable_disable_t *mp;
16447 u32 sw_if_index = ~0;
16448 u8 ip4 = 0, ip6 = 0, default_cop = 0;
16452 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16454 if (unformat (line_input, "ip4"))
16456 else if (unformat (line_input, "ip6"))
16458 else if (unformat (line_input, "default"))
16460 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16461 vam, &sw_if_index))
16463 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16465 else if (unformat (line_input, "fib-id %d", &fib_id))
16471 if (sw_if_index == ~0)
16473 errmsg ("missing interface name or sw_if_index");
16477 /* Construct the API message */
16478 M (COP_WHITELIST_ENABLE_DISABLE, mp);
16479 mp->sw_if_index = ntohl (sw_if_index);
16480 mp->fib_id = ntohl (fib_id);
16483 mp->default_cop = default_cop;
16487 /* Wait for the reply */
16493 api_get_node_graph (vat_main_t * vam)
16495 vl_api_get_node_graph_t *mp;
16498 M (GET_NODE_GRAPH, mp);
16502 /* Wait for the reply */
16508 /** Used for parsing LISP eids */
16509 typedef CLIB_PACKED(struct{
16510 u8 addr[16]; /**< eid address */
16511 u32 len; /**< prefix length if IP */
16512 u8 type; /**< type of eid */
16517 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
16519 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
16521 memset (a, 0, sizeof (a[0]));
16523 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
16525 a->type = 0; /* ipv4 type */
16527 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
16529 a->type = 1; /* ipv6 type */
16531 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
16533 a->type = 2; /* mac type */
16535 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
16537 a->type = 3; /* NSH type */
16538 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
16539 nsh->spi = clib_host_to_net_u32 (nsh->spi);
16546 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
16555 lisp_eid_size_vat (u8 type)
16572 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
16574 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
16578 api_one_add_del_locator_set (vat_main_t * vam)
16580 unformat_input_t *input = vam->input;
16581 vl_api_one_add_del_locator_set_t *mp;
16583 u8 *locator_set_name = NULL;
16584 u8 locator_set_name_set = 0;
16585 vl_api_local_locator_t locator, *locators = 0;
16586 u32 sw_if_index, priority, weight;
16590 /* Parse args required to build the message */
16591 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16593 if (unformat (input, "del"))
16597 else if (unformat (input, "locator-set %s", &locator_set_name))
16599 locator_set_name_set = 1;
16601 else if (unformat (input, "sw_if_index %u p %u w %u",
16602 &sw_if_index, &priority, &weight))
16604 locator.sw_if_index = htonl (sw_if_index);
16605 locator.priority = priority;
16606 locator.weight = weight;
16607 vec_add1 (locators, locator);
16611 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
16612 &sw_if_index, &priority, &weight))
16614 locator.sw_if_index = htonl (sw_if_index);
16615 locator.priority = priority;
16616 locator.weight = weight;
16617 vec_add1 (locators, locator);
16623 if (locator_set_name_set == 0)
16625 errmsg ("missing locator-set name");
16626 vec_free (locators);
16630 if (vec_len (locator_set_name) > 64)
16632 errmsg ("locator-set name too long");
16633 vec_free (locator_set_name);
16634 vec_free (locators);
16637 vec_add1 (locator_set_name, 0);
16639 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
16641 /* Construct the API message */
16642 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
16644 mp->is_add = is_add;
16645 clib_memcpy (mp->locator_set_name, locator_set_name,
16646 vec_len (locator_set_name));
16647 vec_free (locator_set_name);
16649 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
16651 clib_memcpy (mp->locators, locators, data_len);
16652 vec_free (locators);
16657 /* Wait for a reply... */
16662 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
16665 api_one_add_del_locator (vat_main_t * vam)
16667 unformat_input_t *input = vam->input;
16668 vl_api_one_add_del_locator_t *mp;
16669 u32 tmp_if_index = ~0;
16670 u32 sw_if_index = ~0;
16671 u8 sw_if_index_set = 0;
16672 u8 sw_if_index_if_name_set = 0;
16674 u8 priority_set = 0;
16678 u8 *locator_set_name = NULL;
16679 u8 locator_set_name_set = 0;
16682 /* Parse args required to build the message */
16683 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16685 if (unformat (input, "del"))
16689 else if (unformat (input, "locator-set %s", &locator_set_name))
16691 locator_set_name_set = 1;
16693 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
16696 sw_if_index_if_name_set = 1;
16697 sw_if_index = tmp_if_index;
16699 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
16701 sw_if_index_set = 1;
16702 sw_if_index = tmp_if_index;
16704 else if (unformat (input, "p %d", &priority))
16708 else if (unformat (input, "w %d", &weight))
16716 if (locator_set_name_set == 0)
16718 errmsg ("missing locator-set name");
16722 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
16724 errmsg ("missing sw_if_index");
16725 vec_free (locator_set_name);
16729 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
16731 errmsg ("cannot use both params interface name and sw_if_index");
16732 vec_free (locator_set_name);
16736 if (priority_set == 0)
16738 errmsg ("missing locator-set priority");
16739 vec_free (locator_set_name);
16743 if (weight_set == 0)
16745 errmsg ("missing locator-set weight");
16746 vec_free (locator_set_name);
16750 if (vec_len (locator_set_name) > 64)
16752 errmsg ("locator-set name too long");
16753 vec_free (locator_set_name);
16756 vec_add1 (locator_set_name, 0);
16758 /* Construct the API message */
16759 M (ONE_ADD_DEL_LOCATOR, mp);
16761 mp->is_add = is_add;
16762 mp->sw_if_index = ntohl (sw_if_index);
16763 mp->priority = priority;
16764 mp->weight = weight;
16765 clib_memcpy (mp->locator_set_name, locator_set_name,
16766 vec_len (locator_set_name));
16767 vec_free (locator_set_name);
16772 /* Wait for a reply... */
16777 #define api_lisp_add_del_locator api_one_add_del_locator
16780 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
16782 u32 *key_id = va_arg (*args, u32 *);
16785 if (unformat (input, "%s", &s))
16787 if (!strcmp ((char *) s, "sha1"))
16788 key_id[0] = HMAC_SHA_1_96;
16789 else if (!strcmp ((char *) s, "sha256"))
16790 key_id[0] = HMAC_SHA_256_128;
16793 clib_warning ("invalid key_id: '%s'", s);
16794 key_id[0] = HMAC_NO_KEY;
16805 api_one_add_del_local_eid (vat_main_t * vam)
16807 unformat_input_t *input = vam->input;
16808 vl_api_one_add_del_local_eid_t *mp;
16811 lisp_eid_vat_t _eid, *eid = &_eid;
16812 u8 *locator_set_name = 0;
16813 u8 locator_set_name_set = 0;
16819 /* Parse args required to build the message */
16820 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16822 if (unformat (input, "del"))
16826 else if (unformat (input, "vni %d", &vni))
16830 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
16834 else if (unformat (input, "locator-set %s", &locator_set_name))
16836 locator_set_name_set = 1;
16838 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
16840 else if (unformat (input, "secret-key %_%v%_", &key))
16846 if (locator_set_name_set == 0)
16848 errmsg ("missing locator-set name");
16854 errmsg ("EID address not set!");
16855 vec_free (locator_set_name);
16859 if (key && (0 == key_id))
16861 errmsg ("invalid key_id!");
16865 if (vec_len (key) > 64)
16867 errmsg ("key too long");
16872 if (vec_len (locator_set_name) > 64)
16874 errmsg ("locator-set name too long");
16875 vec_free (locator_set_name);
16878 vec_add1 (locator_set_name, 0);
16880 /* Construct the API message */
16881 M (ONE_ADD_DEL_LOCAL_EID, mp);
16883 mp->is_add = is_add;
16884 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
16885 mp->eid_type = eid->type;
16886 mp->prefix_len = eid->len;
16887 mp->vni = clib_host_to_net_u32 (vni);
16888 mp->key_id = clib_host_to_net_u16 (key_id);
16889 clib_memcpy (mp->locator_set_name, locator_set_name,
16890 vec_len (locator_set_name));
16891 clib_memcpy (mp->key, key, vec_len (key));
16893 vec_free (locator_set_name);
16899 /* Wait for a reply... */
16904 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
16907 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
16909 u32 dp_table = 0, vni = 0;;
16910 unformat_input_t *input = vam->input;
16911 vl_api_gpe_add_del_fwd_entry_t *mp;
16913 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
16914 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
16915 u8 rmt_eid_set = 0, lcl_eid_set = 0;
16916 u32 action = ~0, w;
16917 ip4_address_t rmt_rloc4, lcl_rloc4;
16918 ip6_address_t rmt_rloc6, lcl_rloc6;
16919 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
16922 memset (&rloc, 0, sizeof (rloc));
16924 /* Parse args required to build the message */
16925 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16927 if (unformat (input, "del"))
16929 else if (unformat (input, "add"))
16931 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
16935 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
16939 else if (unformat (input, "vrf %d", &dp_table))
16941 else if (unformat (input, "bd %d", &dp_table))
16943 else if (unformat (input, "vni %d", &vni))
16945 else if (unformat (input, "w %d", &w))
16949 errmsg ("No RLOC configured for setting priority/weight!");
16952 curr_rloc->weight = w;
16954 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
16955 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
16959 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
16961 vec_add1 (lcl_locs, rloc);
16963 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
16964 vec_add1 (rmt_locs, rloc);
16965 /* weight saved in rmt loc */
16966 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
16968 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
16969 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
16972 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
16974 vec_add1 (lcl_locs, rloc);
16976 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
16977 vec_add1 (rmt_locs, rloc);
16978 /* weight saved in rmt loc */
16979 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
16981 else if (unformat (input, "action %d", &action))
16987 clib_warning ("parse error '%U'", format_unformat_error, input);
16994 errmsg ("remote eid addresses not set");
16998 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
17000 errmsg ("eid types don't match");
17004 if (0 == rmt_locs && (u32) ~ 0 == action)
17006 errmsg ("action not set for negative mapping");
17010 /* Construct the API message */
17011 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
17012 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
17014 mp->is_add = is_add;
17015 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
17016 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
17017 mp->eid_type = rmt_eid->type;
17018 mp->dp_table = clib_host_to_net_u32 (dp_table);
17019 mp->vni = clib_host_to_net_u32 (vni);
17020 mp->rmt_len = rmt_eid->len;
17021 mp->lcl_len = lcl_eid->len;
17022 mp->action = action;
17024 if (0 != rmt_locs && 0 != lcl_locs)
17026 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
17027 clib_memcpy (mp->locs, lcl_locs,
17028 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
17030 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
17031 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
17032 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
17034 vec_free (lcl_locs);
17035 vec_free (rmt_locs);
17040 /* Wait for a reply... */
17046 api_one_add_del_map_server (vat_main_t * vam)
17048 unformat_input_t *input = vam->input;
17049 vl_api_one_add_del_map_server_t *mp;
17053 ip4_address_t ipv4;
17054 ip6_address_t ipv6;
17057 /* Parse args required to build the message */
17058 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17060 if (unformat (input, "del"))
17064 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17068 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17076 if (ipv4_set && ipv6_set)
17078 errmsg ("both eid v4 and v6 addresses set");
17082 if (!ipv4_set && !ipv6_set)
17084 errmsg ("eid addresses not set");
17088 /* Construct the API message */
17089 M (ONE_ADD_DEL_MAP_SERVER, mp);
17091 mp->is_add = is_add;
17095 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17100 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17106 /* Wait for a reply... */
17111 #define api_lisp_add_del_map_server api_one_add_del_map_server
17114 api_one_add_del_map_resolver (vat_main_t * vam)
17116 unformat_input_t *input = vam->input;
17117 vl_api_one_add_del_map_resolver_t *mp;
17121 ip4_address_t ipv4;
17122 ip6_address_t ipv6;
17125 /* Parse args required to build the message */
17126 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17128 if (unformat (input, "del"))
17132 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17136 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17144 if (ipv4_set && ipv6_set)
17146 errmsg ("both eid v4 and v6 addresses set");
17150 if (!ipv4_set && !ipv6_set)
17152 errmsg ("eid addresses not set");
17156 /* Construct the API message */
17157 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
17159 mp->is_add = is_add;
17163 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17168 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17174 /* Wait for a reply... */
17179 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
17182 api_lisp_gpe_enable_disable (vat_main_t * vam)
17184 unformat_input_t *input = vam->input;
17185 vl_api_gpe_enable_disable_t *mp;
17190 /* Parse args required to build the message */
17191 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17193 if (unformat (input, "enable"))
17198 else if (unformat (input, "disable"))
17209 errmsg ("Value not set");
17213 /* Construct the API message */
17214 M (GPE_ENABLE_DISABLE, mp);
17221 /* Wait for a reply... */
17227 api_one_rloc_probe_enable_disable (vat_main_t * vam)
17229 unformat_input_t *input = vam->input;
17230 vl_api_one_rloc_probe_enable_disable_t *mp;
17235 /* Parse args required to build the message */
17236 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17238 if (unformat (input, "enable"))
17243 else if (unformat (input, "disable"))
17251 errmsg ("Value not set");
17255 /* Construct the API message */
17256 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
17258 mp->is_enabled = is_en;
17263 /* Wait for a reply... */
17268 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
17271 api_one_map_register_enable_disable (vat_main_t * vam)
17273 unformat_input_t *input = vam->input;
17274 vl_api_one_map_register_enable_disable_t *mp;
17279 /* Parse args required to build the message */
17280 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17282 if (unformat (input, "enable"))
17287 else if (unformat (input, "disable"))
17295 errmsg ("Value not set");
17299 /* Construct the API message */
17300 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
17302 mp->is_enabled = is_en;
17307 /* Wait for a reply... */
17312 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
17315 api_one_enable_disable (vat_main_t * vam)
17317 unformat_input_t *input = vam->input;
17318 vl_api_one_enable_disable_t *mp;
17323 /* Parse args required to build the message */
17324 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17326 if (unformat (input, "enable"))
17331 else if (unformat (input, "disable"))
17341 errmsg ("Value not set");
17345 /* Construct the API message */
17346 M (ONE_ENABLE_DISABLE, mp);
17353 /* Wait for a reply... */
17358 #define api_lisp_enable_disable api_one_enable_disable
17361 api_one_enable_disable_xtr_mode (vat_main_t * vam)
17363 unformat_input_t *input = vam->input;
17364 vl_api_one_enable_disable_xtr_mode_t *mp;
17369 /* Parse args required to build the message */
17370 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17372 if (unformat (input, "enable"))
17377 else if (unformat (input, "disable"))
17387 errmsg ("Value not set");
17391 /* Construct the API message */
17392 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
17399 /* Wait for a reply... */
17405 api_one_show_xtr_mode (vat_main_t * vam)
17407 vl_api_one_show_xtr_mode_t *mp;
17410 /* Construct the API message */
17411 M (ONE_SHOW_XTR_MODE, mp);
17416 /* Wait for a reply... */
17422 api_one_enable_disable_pitr_mode (vat_main_t * vam)
17424 unformat_input_t *input = vam->input;
17425 vl_api_one_enable_disable_pitr_mode_t *mp;
17430 /* Parse args required to build the message */
17431 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17433 if (unformat (input, "enable"))
17438 else if (unformat (input, "disable"))
17448 errmsg ("Value not set");
17452 /* Construct the API message */
17453 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
17460 /* Wait for a reply... */
17466 api_one_show_pitr_mode (vat_main_t * vam)
17468 vl_api_one_show_pitr_mode_t *mp;
17471 /* Construct the API message */
17472 M (ONE_SHOW_PITR_MODE, mp);
17477 /* Wait for a reply... */
17483 api_one_enable_disable_petr_mode (vat_main_t * vam)
17485 unformat_input_t *input = vam->input;
17486 vl_api_one_enable_disable_petr_mode_t *mp;
17491 /* Parse args required to build the message */
17492 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17494 if (unformat (input, "enable"))
17499 else if (unformat (input, "disable"))
17509 errmsg ("Value not set");
17513 /* Construct the API message */
17514 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
17521 /* Wait for a reply... */
17527 api_one_show_petr_mode (vat_main_t * vam)
17529 vl_api_one_show_petr_mode_t *mp;
17532 /* Construct the API message */
17533 M (ONE_SHOW_PETR_MODE, mp);
17538 /* Wait for a reply... */
17544 api_show_one_map_register_state (vat_main_t * vam)
17546 vl_api_show_one_map_register_state_t *mp;
17549 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
17554 /* wait for reply */
17559 #define api_show_lisp_map_register_state api_show_one_map_register_state
17562 api_show_one_rloc_probe_state (vat_main_t * vam)
17564 vl_api_show_one_rloc_probe_state_t *mp;
17567 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
17572 /* wait for reply */
17577 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
17580 api_one_add_del_ndp_entry (vat_main_t * vam)
17582 vl_api_one_add_del_ndp_entry_t *mp;
17583 unformat_input_t *input = vam->input;
17588 u8 mac[6] = { 0, };
17589 u8 ip6[16] = { 0, };
17593 /* Parse args required to build the message */
17594 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17596 if (unformat (input, "del"))
17598 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17600 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
17602 else if (unformat (input, "bd %d", &bd))
17606 errmsg ("parse error '%U'", format_unformat_error, input);
17611 if (!bd_set || !ip_set || (!mac_set && is_add))
17613 errmsg ("Missing BD, IP or MAC!");
17617 M (ONE_ADD_DEL_NDP_ENTRY, mp);
17618 mp->is_add = is_add;
17619 clib_memcpy (mp->mac, mac, 6);
17620 mp->bd = clib_host_to_net_u32 (bd);
17621 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
17626 /* wait for reply */
17632 api_one_add_del_l2_arp_entry (vat_main_t * vam)
17634 vl_api_one_add_del_l2_arp_entry_t *mp;
17635 unformat_input_t *input = vam->input;
17640 u8 mac[6] = { 0, };
17641 u32 ip4 = 0, bd = ~0;
17644 /* Parse args required to build the message */
17645 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17647 if (unformat (input, "del"))
17649 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17651 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
17653 else if (unformat (input, "bd %d", &bd))
17657 errmsg ("parse error '%U'", format_unformat_error, input);
17662 if (!bd_set || !ip_set || (!mac_set && is_add))
17664 errmsg ("Missing BD, IP or MAC!");
17668 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
17669 mp->is_add = is_add;
17670 clib_memcpy (mp->mac, mac, 6);
17671 mp->bd = clib_host_to_net_u32 (bd);
17677 /* wait for reply */
17683 api_one_ndp_bd_get (vat_main_t * vam)
17685 vl_api_one_ndp_bd_get_t *mp;
17688 M (ONE_NDP_BD_GET, mp);
17693 /* wait for reply */
17699 api_one_ndp_entries_get (vat_main_t * vam)
17701 vl_api_one_ndp_entries_get_t *mp;
17702 unformat_input_t *input = vam->input;
17707 /* Parse args required to build the message */
17708 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17710 if (unformat (input, "bd %d", &bd))
17714 errmsg ("parse error '%U'", format_unformat_error, input);
17721 errmsg ("Expected bridge domain!");
17725 M (ONE_NDP_ENTRIES_GET, mp);
17726 mp->bd = clib_host_to_net_u32 (bd);
17731 /* wait for reply */
17737 api_one_l2_arp_bd_get (vat_main_t * vam)
17739 vl_api_one_l2_arp_bd_get_t *mp;
17742 M (ONE_L2_ARP_BD_GET, mp);
17747 /* wait for reply */
17753 api_one_l2_arp_entries_get (vat_main_t * vam)
17755 vl_api_one_l2_arp_entries_get_t *mp;
17756 unformat_input_t *input = vam->input;
17761 /* Parse args required to build the message */
17762 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17764 if (unformat (input, "bd %d", &bd))
17768 errmsg ("parse error '%U'", format_unformat_error, input);
17775 errmsg ("Expected bridge domain!");
17779 M (ONE_L2_ARP_ENTRIES_GET, mp);
17780 mp->bd = clib_host_to_net_u32 (bd);
17785 /* wait for reply */
17791 api_one_stats_enable_disable (vat_main_t * vam)
17793 vl_api_one_stats_enable_disable_t *mp;
17794 unformat_input_t *input = vam->input;
17799 /* Parse args required to build the message */
17800 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17802 if (unformat (input, "enable"))
17807 else if (unformat (input, "disable"))
17817 errmsg ("Value not set");
17821 M (ONE_STATS_ENABLE_DISABLE, mp);
17827 /* wait for reply */
17833 api_show_one_stats_enable_disable (vat_main_t * vam)
17835 vl_api_show_one_stats_enable_disable_t *mp;
17838 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
17843 /* wait for reply */
17849 api_show_one_map_request_mode (vat_main_t * vam)
17851 vl_api_show_one_map_request_mode_t *mp;
17854 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
17859 /* wait for reply */
17864 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
17867 api_one_map_request_mode (vat_main_t * vam)
17869 unformat_input_t *input = vam->input;
17870 vl_api_one_map_request_mode_t *mp;
17874 /* Parse args required to build the message */
17875 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17877 if (unformat (input, "dst-only"))
17879 else if (unformat (input, "src-dst"))
17883 errmsg ("parse error '%U'", format_unformat_error, input);
17888 M (ONE_MAP_REQUEST_MODE, mp);
17895 /* wait for reply */
17900 #define api_lisp_map_request_mode api_one_map_request_mode
17903 * Enable/disable ONE proxy ITR.
17905 * @param vam vpp API test context
17906 * @return return code
17909 api_one_pitr_set_locator_set (vat_main_t * vam)
17911 u8 ls_name_set = 0;
17912 unformat_input_t *input = vam->input;
17913 vl_api_one_pitr_set_locator_set_t *mp;
17918 /* Parse args required to build the message */
17919 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17921 if (unformat (input, "del"))
17923 else if (unformat (input, "locator-set %s", &ls_name))
17927 errmsg ("parse error '%U'", format_unformat_error, input);
17934 errmsg ("locator-set name not set!");
17938 M (ONE_PITR_SET_LOCATOR_SET, mp);
17940 mp->is_add = is_add;
17941 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
17942 vec_free (ls_name);
17947 /* wait for reply */
17952 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
17955 api_one_nsh_set_locator_set (vat_main_t * vam)
17957 u8 ls_name_set = 0;
17958 unformat_input_t *input = vam->input;
17959 vl_api_one_nsh_set_locator_set_t *mp;
17964 /* Parse args required to build the message */
17965 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17967 if (unformat (input, "del"))
17969 else if (unformat (input, "ls %s", &ls_name))
17973 errmsg ("parse error '%U'", format_unformat_error, input);
17978 if (!ls_name_set && is_add)
17980 errmsg ("locator-set name not set!");
17984 M (ONE_NSH_SET_LOCATOR_SET, mp);
17986 mp->is_add = is_add;
17987 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
17988 vec_free (ls_name);
17993 /* wait for reply */
17999 api_show_one_pitr (vat_main_t * vam)
18001 vl_api_show_one_pitr_t *mp;
18004 if (!vam->json_output)
18006 print (vam->ofp, "%=20s", "lisp status:");
18009 M (SHOW_ONE_PITR, mp);
18013 /* Wait for a reply... */
18018 #define api_show_lisp_pitr api_show_one_pitr
18021 api_one_use_petr (vat_main_t * vam)
18023 unformat_input_t *input = vam->input;
18024 vl_api_one_use_petr_t *mp;
18029 memset (&ip, 0, sizeof (ip));
18031 /* Parse args required to build the message */
18032 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18034 if (unformat (input, "disable"))
18037 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
18040 ip_addr_version (&ip) = IP4;
18043 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
18046 ip_addr_version (&ip) = IP6;
18050 errmsg ("parse error '%U'", format_unformat_error, input);
18055 M (ONE_USE_PETR, mp);
18057 mp->is_add = is_add;
18060 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
18062 clib_memcpy (mp->address, &ip, 4);
18064 clib_memcpy (mp->address, &ip, 16);
18070 /* wait for reply */
18075 #define api_lisp_use_petr api_one_use_petr
18078 api_show_one_nsh_mapping (vat_main_t * vam)
18080 vl_api_show_one_use_petr_t *mp;
18083 if (!vam->json_output)
18085 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
18088 M (SHOW_ONE_NSH_MAPPING, mp);
18092 /* Wait for a reply... */
18098 api_show_one_use_petr (vat_main_t * vam)
18100 vl_api_show_one_use_petr_t *mp;
18103 if (!vam->json_output)
18105 print (vam->ofp, "%=20s", "Proxy-ETR status:");
18108 M (SHOW_ONE_USE_PETR, mp);
18112 /* Wait for a reply... */
18117 #define api_show_lisp_use_petr api_show_one_use_petr
18120 * Add/delete mapping between vni and vrf
18123 api_one_eid_table_add_del_map (vat_main_t * vam)
18125 unformat_input_t *input = vam->input;
18126 vl_api_one_eid_table_add_del_map_t *mp;
18127 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
18128 u32 vni, vrf, bd_index;
18131 /* Parse args required to build the message */
18132 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18134 if (unformat (input, "del"))
18136 else if (unformat (input, "vrf %d", &vrf))
18138 else if (unformat (input, "bd_index %d", &bd_index))
18140 else if (unformat (input, "vni %d", &vni))
18146 if (!vni_set || (!vrf_set && !bd_index_set))
18148 errmsg ("missing arguments!");
18152 if (vrf_set && bd_index_set)
18154 errmsg ("error: both vrf and bd entered!");
18158 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
18160 mp->is_add = is_add;
18161 mp->vni = htonl (vni);
18162 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
18163 mp->is_l2 = bd_index_set;
18168 /* wait for reply */
18173 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
18176 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
18178 u32 *action = va_arg (*args, u32 *);
18181 if (unformat (input, "%s", &s))
18183 if (!strcmp ((char *) s, "no-action"))
18185 else if (!strcmp ((char *) s, "natively-forward"))
18187 else if (!strcmp ((char *) s, "send-map-request"))
18189 else if (!strcmp ((char *) s, "drop"))
18193 clib_warning ("invalid action: '%s'", s);
18205 * Add/del remote mapping to/from ONE control plane
18207 * @param vam vpp API test context
18208 * @return return code
18211 api_one_add_del_remote_mapping (vat_main_t * vam)
18213 unformat_input_t *input = vam->input;
18214 vl_api_one_add_del_remote_mapping_t *mp;
18216 lisp_eid_vat_t _eid, *eid = &_eid;
18217 lisp_eid_vat_t _seid, *seid = &_seid;
18218 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
18219 u32 action = ~0, p, w, data_len;
18220 ip4_address_t rloc4;
18221 ip6_address_t rloc6;
18222 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
18225 memset (&rloc, 0, sizeof (rloc));
18227 /* Parse args required to build the message */
18228 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18230 if (unformat (input, "del-all"))
18234 else if (unformat (input, "del"))
18238 else if (unformat (input, "add"))
18242 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
18246 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
18250 else if (unformat (input, "vni %d", &vni))
18254 else if (unformat (input, "p %d w %d", &p, &w))
18258 errmsg ("No RLOC configured for setting priority/weight!");
18261 curr_rloc->priority = p;
18262 curr_rloc->weight = w;
18264 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
18267 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
18268 vec_add1 (rlocs, rloc);
18269 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18271 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
18274 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
18275 vec_add1 (rlocs, rloc);
18276 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18278 else if (unformat (input, "action %U",
18279 unformat_negative_mapping_action, &action))
18285 clib_warning ("parse error '%U'", format_unformat_error, input);
18292 errmsg ("missing params!");
18296 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
18298 errmsg ("no action set for negative map-reply!");
18302 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
18304 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
18305 mp->is_add = is_add;
18306 mp->vni = htonl (vni);
18307 mp->action = (u8) action;
18308 mp->is_src_dst = seid_set;
18309 mp->eid_len = eid->len;
18310 mp->seid_len = seid->len;
18311 mp->del_all = del_all;
18312 mp->eid_type = eid->type;
18313 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
18314 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
18316 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
18317 clib_memcpy (mp->rlocs, rlocs, data_len);
18323 /* Wait for a reply... */
18328 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
18331 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
18332 * forwarding entries in data-plane accordingly.
18334 * @param vam vpp API test context
18335 * @return return code
18338 api_one_add_del_adjacency (vat_main_t * vam)
18340 unformat_input_t *input = vam->input;
18341 vl_api_one_add_del_adjacency_t *mp;
18343 ip4_address_t leid4, reid4;
18344 ip6_address_t leid6, reid6;
18345 u8 reid_mac[6] = { 0 };
18346 u8 leid_mac[6] = { 0 };
18347 u8 reid_type, leid_type;
18348 u32 leid_len = 0, reid_len = 0, len;
18352 leid_type = reid_type = (u8) ~ 0;
18354 /* Parse args required to build the message */
18355 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18357 if (unformat (input, "del"))
18361 else if (unformat (input, "add"))
18365 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
18368 reid_type = 0; /* ipv4 */
18371 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
18374 reid_type = 1; /* ipv6 */
18377 else if (unformat (input, "reid %U", unformat_ethernet_address,
18380 reid_type = 2; /* mac */
18382 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
18385 leid_type = 0; /* ipv4 */
18388 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
18391 leid_type = 1; /* ipv6 */
18394 else if (unformat (input, "leid %U", unformat_ethernet_address,
18397 leid_type = 2; /* mac */
18399 else if (unformat (input, "vni %d", &vni))
18405 errmsg ("parse error '%U'", format_unformat_error, input);
18410 if ((u8) ~ 0 == reid_type)
18412 errmsg ("missing params!");
18416 if (leid_type != reid_type)
18418 errmsg ("remote and local EIDs are of different types!");
18422 M (ONE_ADD_DEL_ADJACENCY, mp);
18423 mp->is_add = is_add;
18424 mp->vni = htonl (vni);
18425 mp->leid_len = leid_len;
18426 mp->reid_len = reid_len;
18427 mp->eid_type = reid_type;
18429 switch (mp->eid_type)
18432 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
18433 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
18436 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
18437 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
18440 clib_memcpy (mp->leid, leid_mac, 6);
18441 clib_memcpy (mp->reid, reid_mac, 6);
18444 errmsg ("unknown EID type %d!", mp->eid_type);
18451 /* Wait for a reply... */
18456 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
18459 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
18461 u32 *mode = va_arg (*args, u32 *);
18463 if (unformat (input, "lisp"))
18465 else if (unformat (input, "vxlan"))
18474 api_gpe_get_encap_mode (vat_main_t * vam)
18476 vl_api_gpe_get_encap_mode_t *mp;
18479 /* Construct the API message */
18480 M (GPE_GET_ENCAP_MODE, mp);
18485 /* Wait for a reply... */
18491 api_gpe_set_encap_mode (vat_main_t * vam)
18493 unformat_input_t *input = vam->input;
18494 vl_api_gpe_set_encap_mode_t *mp;
18498 /* Parse args required to build the message */
18499 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18501 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
18507 /* Construct the API message */
18508 M (GPE_SET_ENCAP_MODE, mp);
18515 /* Wait for a reply... */
18521 api_lisp_gpe_add_del_iface (vat_main_t * vam)
18523 unformat_input_t *input = vam->input;
18524 vl_api_gpe_add_del_iface_t *mp;
18525 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
18526 u32 dp_table = 0, vni = 0;
18529 /* Parse args required to build the message */
18530 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18532 if (unformat (input, "up"))
18537 else if (unformat (input, "down"))
18542 else if (unformat (input, "table_id %d", &dp_table))
18546 else if (unformat (input, "bd_id %d", &dp_table))
18551 else if (unformat (input, "vni %d", &vni))
18559 if (action_set == 0)
18561 errmsg ("Action not set");
18564 if (dp_table_set == 0 || vni_set == 0)
18566 errmsg ("vni and dp_table must be set");
18570 /* Construct the API message */
18571 M (GPE_ADD_DEL_IFACE, mp);
18573 mp->is_add = is_add;
18574 mp->dp_table = clib_host_to_net_u32 (dp_table);
18576 mp->vni = clib_host_to_net_u32 (vni);
18581 /* Wait for a reply... */
18587 api_one_map_register_fallback_threshold (vat_main_t * vam)
18589 unformat_input_t *input = vam->input;
18590 vl_api_one_map_register_fallback_threshold_t *mp;
18595 /* Parse args required to build the message */
18596 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18598 if (unformat (input, "%u", &value))
18602 clib_warning ("parse error '%U'", format_unformat_error, input);
18609 errmsg ("fallback threshold value is missing!");
18613 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18614 mp->value = clib_host_to_net_u32 (value);
18619 /* Wait for a reply... */
18625 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
18627 vl_api_show_one_map_register_fallback_threshold_t *mp;
18630 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18635 /* Wait for a reply... */
18641 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
18643 u32 *proto = va_arg (*args, u32 *);
18645 if (unformat (input, "udp"))
18647 else if (unformat (input, "api"))
18656 api_one_set_transport_protocol (vat_main_t * vam)
18658 unformat_input_t *input = vam->input;
18659 vl_api_one_set_transport_protocol_t *mp;
18664 /* Parse args required to build the message */
18665 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18667 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
18671 clib_warning ("parse error '%U'", format_unformat_error, input);
18678 errmsg ("Transport protocol missing!");
18682 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
18683 mp->protocol = (u8) protocol;
18688 /* Wait for a reply... */
18694 api_one_get_transport_protocol (vat_main_t * vam)
18696 vl_api_one_get_transport_protocol_t *mp;
18699 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
18704 /* Wait for a reply... */
18710 api_one_map_register_set_ttl (vat_main_t * vam)
18712 unformat_input_t *input = vam->input;
18713 vl_api_one_map_register_set_ttl_t *mp;
18718 /* Parse args required to build the message */
18719 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18721 if (unformat (input, "%u", &ttl))
18725 clib_warning ("parse error '%U'", format_unformat_error, input);
18732 errmsg ("TTL value missing!");
18736 M (ONE_MAP_REGISTER_SET_TTL, mp);
18737 mp->ttl = clib_host_to_net_u32 (ttl);
18742 /* Wait for a reply... */
18748 api_show_one_map_register_ttl (vat_main_t * vam)
18750 vl_api_show_one_map_register_ttl_t *mp;
18753 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
18758 /* Wait for a reply... */
18764 * Add/del map request itr rlocs from ONE control plane and updates
18766 * @param vam vpp API test context
18767 * @return return code
18770 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
18772 unformat_input_t *input = vam->input;
18773 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
18774 u8 *locator_set_name = 0;
18775 u8 locator_set_name_set = 0;
18779 /* Parse args required to build the message */
18780 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18782 if (unformat (input, "del"))
18786 else if (unformat (input, "%_%v%_", &locator_set_name))
18788 locator_set_name_set = 1;
18792 clib_warning ("parse error '%U'", format_unformat_error, input);
18797 if (is_add && !locator_set_name_set)
18799 errmsg ("itr-rloc is not set!");
18803 if (is_add && vec_len (locator_set_name) > 64)
18805 errmsg ("itr-rloc locator-set name too long");
18806 vec_free (locator_set_name);
18810 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
18811 mp->is_add = is_add;
18814 clib_memcpy (mp->locator_set_name, locator_set_name,
18815 vec_len (locator_set_name));
18819 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
18821 vec_free (locator_set_name);
18826 /* Wait for a reply... */
18831 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
18834 api_one_locator_dump (vat_main_t * vam)
18836 unformat_input_t *input = vam->input;
18837 vl_api_one_locator_dump_t *mp;
18838 vl_api_control_ping_t *mp_ping;
18839 u8 is_index_set = 0, is_name_set = 0;
18844 /* Parse args required to build the message */
18845 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18847 if (unformat (input, "ls_name %_%v%_", &ls_name))
18851 else if (unformat (input, "ls_index %d", &ls_index))
18857 errmsg ("parse error '%U'", format_unformat_error, input);
18862 if (!is_index_set && !is_name_set)
18864 errmsg ("error: expected one of index or name!");
18868 if (is_index_set && is_name_set)
18870 errmsg ("error: only one param expected!");
18874 if (vec_len (ls_name) > 62)
18876 errmsg ("error: locator set name too long!");
18880 if (!vam->json_output)
18882 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
18885 M (ONE_LOCATOR_DUMP, mp);
18886 mp->is_index_set = is_index_set;
18889 mp->ls_index = clib_host_to_net_u32 (ls_index);
18892 vec_add1 (ls_name, 0);
18893 strncpy ((char *) mp->ls_name, (char *) ls_name,
18894 sizeof (mp->ls_name) - 1);
18900 /* Use a control ping for synchronization */
18901 MPING (CONTROL_PING, mp_ping);
18904 /* Wait for a reply... */
18909 #define api_lisp_locator_dump api_one_locator_dump
18912 api_one_locator_set_dump (vat_main_t * vam)
18914 vl_api_one_locator_set_dump_t *mp;
18915 vl_api_control_ping_t *mp_ping;
18916 unformat_input_t *input = vam->input;
18920 /* Parse args required to build the message */
18921 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18923 if (unformat (input, "local"))
18927 else if (unformat (input, "remote"))
18933 errmsg ("parse error '%U'", format_unformat_error, input);
18938 if (!vam->json_output)
18940 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
18943 M (ONE_LOCATOR_SET_DUMP, mp);
18945 mp->filter = filter;
18950 /* Use a control ping for synchronization */
18951 MPING (CONTROL_PING, mp_ping);
18954 /* Wait for a reply... */
18959 #define api_lisp_locator_set_dump api_one_locator_set_dump
18962 api_one_eid_table_map_dump (vat_main_t * vam)
18966 unformat_input_t *input = vam->input;
18967 vl_api_one_eid_table_map_dump_t *mp;
18968 vl_api_control_ping_t *mp_ping;
18971 /* Parse args required to build the message */
18972 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18974 if (unformat (input, "l2"))
18979 else if (unformat (input, "l3"))
18986 errmsg ("parse error '%U'", format_unformat_error, input);
18993 errmsg ("expected one of 'l2' or 'l3' parameter!");
18997 if (!vam->json_output)
18999 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
19002 M (ONE_EID_TABLE_MAP_DUMP, mp);
19008 /* Use a control ping for synchronization */
19009 MPING (CONTROL_PING, mp_ping);
19012 /* Wait for a reply... */
19017 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
19020 api_one_eid_table_vni_dump (vat_main_t * vam)
19022 vl_api_one_eid_table_vni_dump_t *mp;
19023 vl_api_control_ping_t *mp_ping;
19026 if (!vam->json_output)
19028 print (vam->ofp, "VNI");
19031 M (ONE_EID_TABLE_VNI_DUMP, mp);
19036 /* Use a control ping for synchronization */
19037 MPING (CONTROL_PING, mp_ping);
19040 /* Wait for a reply... */
19045 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
19048 api_one_eid_table_dump (vat_main_t * vam)
19050 unformat_input_t *i = vam->input;
19051 vl_api_one_eid_table_dump_t *mp;
19052 vl_api_control_ping_t *mp_ping;
19053 struct in_addr ip4;
19054 struct in6_addr ip6;
19056 u8 eid_type = ~0, eid_set = 0;
19057 u32 prefix_length = ~0, t, vni = 0;
19060 lisp_nsh_api_t nsh;
19062 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19064 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
19070 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
19076 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
19081 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
19086 else if (unformat (i, "vni %d", &t))
19090 else if (unformat (i, "local"))
19094 else if (unformat (i, "remote"))
19100 errmsg ("parse error '%U'", format_unformat_error, i);
19105 if (!vam->json_output)
19107 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
19108 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
19111 M (ONE_EID_TABLE_DUMP, mp);
19113 mp->filter = filter;
19117 mp->vni = htonl (vni);
19118 mp->eid_type = eid_type;
19122 mp->prefix_length = prefix_length;
19123 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
19126 mp->prefix_length = prefix_length;
19127 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
19130 clib_memcpy (mp->eid, mac, sizeof (mac));
19133 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
19136 errmsg ("unknown EID type %d!", eid_type);
19144 /* Use a control ping for synchronization */
19145 MPING (CONTROL_PING, mp_ping);
19148 /* Wait for a reply... */
19153 #define api_lisp_eid_table_dump api_one_eid_table_dump
19156 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
19158 unformat_input_t *i = vam->input;
19159 vl_api_gpe_fwd_entries_get_t *mp;
19164 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19166 if (unformat (i, "vni %d", &vni))
19172 errmsg ("parse error '%U'", format_unformat_error, i);
19179 errmsg ("vni not set!");
19183 if (!vam->json_output)
19185 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
19189 M (GPE_FWD_ENTRIES_GET, mp);
19190 mp->vni = clib_host_to_net_u32 (vni);
19195 /* Wait for a reply... */
19200 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
19201 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
19202 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
19203 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
19204 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
19205 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
19206 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
19207 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
19210 api_one_adjacencies_get (vat_main_t * vam)
19212 unformat_input_t *i = vam->input;
19213 vl_api_one_adjacencies_get_t *mp;
19218 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19220 if (unformat (i, "vni %d", &vni))
19226 errmsg ("parse error '%U'", format_unformat_error, i);
19233 errmsg ("vni not set!");
19237 if (!vam->json_output)
19239 print (vam->ofp, "%s %40s", "leid", "reid");
19242 M (ONE_ADJACENCIES_GET, mp);
19243 mp->vni = clib_host_to_net_u32 (vni);
19248 /* Wait for a reply... */
19253 #define api_lisp_adjacencies_get api_one_adjacencies_get
19256 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
19258 unformat_input_t *i = vam->input;
19259 vl_api_gpe_native_fwd_rpaths_get_t *mp;
19261 u8 ip_family_set = 0, is_ip4 = 1;
19263 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19265 if (unformat (i, "ip4"))
19270 else if (unformat (i, "ip6"))
19277 errmsg ("parse error '%U'", format_unformat_error, i);
19282 if (!ip_family_set)
19284 errmsg ("ip family not set!");
19288 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
19289 mp->is_ip4 = is_ip4;
19294 /* Wait for a reply... */
19300 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
19302 vl_api_gpe_fwd_entry_vnis_get_t *mp;
19305 if (!vam->json_output)
19307 print (vam->ofp, "VNIs");
19310 M (GPE_FWD_ENTRY_VNIS_GET, mp);
19315 /* Wait for a reply... */
19321 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
19323 unformat_input_t *i = vam->input;
19324 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
19326 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
19327 struct in_addr ip4;
19328 struct in6_addr ip6;
19329 u32 table_id = 0, nh_sw_if_index = ~0;
19331 memset (&ip4, 0, sizeof (ip4));
19332 memset (&ip6, 0, sizeof (ip6));
19334 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19336 if (unformat (i, "del"))
19338 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
19339 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19344 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
19345 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19350 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
19354 nh_sw_if_index = ~0;
19356 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
19360 nh_sw_if_index = ~0;
19362 else if (unformat (i, "table %d", &table_id))
19366 errmsg ("parse error '%U'", format_unformat_error, i);
19373 errmsg ("nh addr not set!");
19377 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
19378 mp->is_add = is_add;
19379 mp->table_id = clib_host_to_net_u32 (table_id);
19380 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
19381 mp->is_ip4 = is_ip4;
19383 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
19385 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
19390 /* Wait for a reply... */
19396 api_one_map_server_dump (vat_main_t * vam)
19398 vl_api_one_map_server_dump_t *mp;
19399 vl_api_control_ping_t *mp_ping;
19402 if (!vam->json_output)
19404 print (vam->ofp, "%=20s", "Map server");
19407 M (ONE_MAP_SERVER_DUMP, mp);
19411 /* Use a control ping for synchronization */
19412 MPING (CONTROL_PING, mp_ping);
19415 /* Wait for a reply... */
19420 #define api_lisp_map_server_dump api_one_map_server_dump
19423 api_one_map_resolver_dump (vat_main_t * vam)
19425 vl_api_one_map_resolver_dump_t *mp;
19426 vl_api_control_ping_t *mp_ping;
19429 if (!vam->json_output)
19431 print (vam->ofp, "%=20s", "Map resolver");
19434 M (ONE_MAP_RESOLVER_DUMP, mp);
19438 /* Use a control ping for synchronization */
19439 MPING (CONTROL_PING, mp_ping);
19442 /* Wait for a reply... */
19447 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
19450 api_one_stats_flush (vat_main_t * vam)
19452 vl_api_one_stats_flush_t *mp;
19455 M (ONE_STATS_FLUSH, mp);
19462 api_one_stats_dump (vat_main_t * vam)
19464 vl_api_one_stats_dump_t *mp;
19465 vl_api_control_ping_t *mp_ping;
19468 M (ONE_STATS_DUMP, mp);
19472 /* Use a control ping for synchronization */
19473 MPING (CONTROL_PING, mp_ping);
19476 /* Wait for a reply... */
19482 api_show_one_status (vat_main_t * vam)
19484 vl_api_show_one_status_t *mp;
19487 if (!vam->json_output)
19489 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
19492 M (SHOW_ONE_STATUS, mp);
19495 /* Wait for a reply... */
19500 #define api_show_lisp_status api_show_one_status
19503 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
19505 vl_api_gpe_fwd_entry_path_dump_t *mp;
19506 vl_api_control_ping_t *mp_ping;
19507 unformat_input_t *i = vam->input;
19508 u32 fwd_entry_index = ~0;
19511 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19513 if (unformat (i, "index %d", &fwd_entry_index))
19519 if (~0 == fwd_entry_index)
19521 errmsg ("no index specified!");
19525 if (!vam->json_output)
19527 print (vam->ofp, "first line");
19530 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
19534 /* Use a control ping for synchronization */
19535 MPING (CONTROL_PING, mp_ping);
19538 /* Wait for a reply... */
19544 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
19546 vl_api_one_get_map_request_itr_rlocs_t *mp;
19549 if (!vam->json_output)
19551 print (vam->ofp, "%=20s", "itr-rlocs:");
19554 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
19557 /* Wait for a reply... */
19562 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
19565 api_af_packet_create (vat_main_t * vam)
19567 unformat_input_t *i = vam->input;
19568 vl_api_af_packet_create_t *mp;
19569 u8 *host_if_name = 0;
19571 u8 random_hw_addr = 1;
19574 memset (hw_addr, 0, sizeof (hw_addr));
19576 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19578 if (unformat (i, "name %s", &host_if_name))
19579 vec_add1 (host_if_name, 0);
19580 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19581 random_hw_addr = 0;
19586 if (!vec_len (host_if_name))
19588 errmsg ("host-interface name must be specified");
19592 if (vec_len (host_if_name) > 64)
19594 errmsg ("host-interface name too long");
19598 M (AF_PACKET_CREATE, mp);
19600 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19601 clib_memcpy (mp->hw_addr, hw_addr, 6);
19602 mp->use_random_hw_addr = random_hw_addr;
19603 vec_free (host_if_name);
19611 fprintf (vam->ofp ? vam->ofp : stderr,
19612 " new sw_if_index = %d\n", vam->sw_if_index);
19619 api_af_packet_delete (vat_main_t * vam)
19621 unformat_input_t *i = vam->input;
19622 vl_api_af_packet_delete_t *mp;
19623 u8 *host_if_name = 0;
19626 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19628 if (unformat (i, "name %s", &host_if_name))
19629 vec_add1 (host_if_name, 0);
19634 if (!vec_len (host_if_name))
19636 errmsg ("host-interface name must be specified");
19640 if (vec_len (host_if_name) > 64)
19642 errmsg ("host-interface name too long");
19646 M (AF_PACKET_DELETE, mp);
19648 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19649 vec_free (host_if_name);
19656 static void vl_api_af_packet_details_t_handler
19657 (vl_api_af_packet_details_t * mp)
19659 vat_main_t *vam = &vat_main;
19661 print (vam->ofp, "%-16s %d",
19662 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
19665 static void vl_api_af_packet_details_t_handler_json
19666 (vl_api_af_packet_details_t * mp)
19668 vat_main_t *vam = &vat_main;
19669 vat_json_node_t *node = NULL;
19671 if (VAT_JSON_ARRAY != vam->json_tree.type)
19673 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19674 vat_json_init_array (&vam->json_tree);
19676 node = vat_json_array_add (&vam->json_tree);
19678 vat_json_init_object (node);
19679 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
19680 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
19684 api_af_packet_dump (vat_main_t * vam)
19686 vl_api_af_packet_dump_t *mp;
19687 vl_api_control_ping_t *mp_ping;
19690 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
19691 /* Get list of tap interfaces */
19692 M (AF_PACKET_DUMP, mp);
19695 /* Use a control ping for synchronization */
19696 MPING (CONTROL_PING, mp_ping);
19704 api_policer_add_del (vat_main_t * vam)
19706 unformat_input_t *i = vam->input;
19707 vl_api_policer_add_del_t *mp;
19717 u8 color_aware = 0;
19718 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
19721 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
19722 conform_action.dscp = 0;
19723 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
19724 exceed_action.dscp = 0;
19725 violate_action.action_type = SSE2_QOS_ACTION_DROP;
19726 violate_action.dscp = 0;
19728 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19730 if (unformat (i, "del"))
19732 else if (unformat (i, "name %s", &name))
19733 vec_add1 (name, 0);
19734 else if (unformat (i, "cir %u", &cir))
19736 else if (unformat (i, "eir %u", &eir))
19738 else if (unformat (i, "cb %u", &cb))
19740 else if (unformat (i, "eb %u", &eb))
19742 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
19745 else if (unformat (i, "round_type %U", unformat_policer_round_type,
19748 else if (unformat (i, "type %U", unformat_policer_type, &type))
19750 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
19753 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
19756 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
19759 else if (unformat (i, "color-aware"))
19765 if (!vec_len (name))
19767 errmsg ("policer name must be specified");
19771 if (vec_len (name) > 64)
19773 errmsg ("policer name too long");
19777 M (POLICER_ADD_DEL, mp);
19779 clib_memcpy (mp->name, name, vec_len (name));
19781 mp->is_add = is_add;
19782 mp->cir = ntohl (cir);
19783 mp->eir = ntohl (eir);
19784 mp->cb = clib_net_to_host_u64 (cb);
19785 mp->eb = clib_net_to_host_u64 (eb);
19786 mp->rate_type = rate_type;
19787 mp->round_type = round_type;
19789 mp->conform_action_type = conform_action.action_type;
19790 mp->conform_dscp = conform_action.dscp;
19791 mp->exceed_action_type = exceed_action.action_type;
19792 mp->exceed_dscp = exceed_action.dscp;
19793 mp->violate_action_type = violate_action.action_type;
19794 mp->violate_dscp = violate_action.dscp;
19795 mp->color_aware = color_aware;
19803 api_policer_dump (vat_main_t * vam)
19805 unformat_input_t *i = vam->input;
19806 vl_api_policer_dump_t *mp;
19807 vl_api_control_ping_t *mp_ping;
19808 u8 *match_name = 0;
19809 u8 match_name_valid = 0;
19812 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19814 if (unformat (i, "name %s", &match_name))
19816 vec_add1 (match_name, 0);
19817 match_name_valid = 1;
19823 M (POLICER_DUMP, mp);
19824 mp->match_name_valid = match_name_valid;
19825 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
19826 vec_free (match_name);
19830 /* Use a control ping for synchronization */
19831 MPING (CONTROL_PING, mp_ping);
19834 /* Wait for a reply... */
19840 api_policer_classify_set_interface (vat_main_t * vam)
19842 unformat_input_t *i = vam->input;
19843 vl_api_policer_classify_set_interface_t *mp;
19845 int sw_if_index_set;
19846 u32 ip4_table_index = ~0;
19847 u32 ip6_table_index = ~0;
19848 u32 l2_table_index = ~0;
19852 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19854 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19855 sw_if_index_set = 1;
19856 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19857 sw_if_index_set = 1;
19858 else if (unformat (i, "del"))
19860 else if (unformat (i, "ip4-table %d", &ip4_table_index))
19862 else if (unformat (i, "ip6-table %d", &ip6_table_index))
19864 else if (unformat (i, "l2-table %d", &l2_table_index))
19868 clib_warning ("parse error '%U'", format_unformat_error, i);
19873 if (sw_if_index_set == 0)
19875 errmsg ("missing interface name or sw_if_index");
19879 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
19881 mp->sw_if_index = ntohl (sw_if_index);
19882 mp->ip4_table_index = ntohl (ip4_table_index);
19883 mp->ip6_table_index = ntohl (ip6_table_index);
19884 mp->l2_table_index = ntohl (l2_table_index);
19885 mp->is_add = is_add;
19893 api_policer_classify_dump (vat_main_t * vam)
19895 unformat_input_t *i = vam->input;
19896 vl_api_policer_classify_dump_t *mp;
19897 vl_api_control_ping_t *mp_ping;
19898 u8 type = POLICER_CLASSIFY_N_TABLES;
19901 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
19905 errmsg ("classify table type must be specified");
19909 if (!vam->json_output)
19911 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
19914 M (POLICER_CLASSIFY_DUMP, mp);
19919 /* Use a control ping for synchronization */
19920 MPING (CONTROL_PING, mp_ping);
19923 /* Wait for a reply... */
19929 api_netmap_create (vat_main_t * vam)
19931 unformat_input_t *i = vam->input;
19932 vl_api_netmap_create_t *mp;
19935 u8 random_hw_addr = 1;
19940 memset (hw_addr, 0, sizeof (hw_addr));
19942 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19944 if (unformat (i, "name %s", &if_name))
19945 vec_add1 (if_name, 0);
19946 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19947 random_hw_addr = 0;
19948 else if (unformat (i, "pipe"))
19950 else if (unformat (i, "master"))
19952 else if (unformat (i, "slave"))
19958 if (!vec_len (if_name))
19960 errmsg ("interface name must be specified");
19964 if (vec_len (if_name) > 64)
19966 errmsg ("interface name too long");
19970 M (NETMAP_CREATE, mp);
19972 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
19973 clib_memcpy (mp->hw_addr, hw_addr, 6);
19974 mp->use_random_hw_addr = random_hw_addr;
19975 mp->is_pipe = is_pipe;
19976 mp->is_master = is_master;
19977 vec_free (if_name);
19985 api_netmap_delete (vat_main_t * vam)
19987 unformat_input_t *i = vam->input;
19988 vl_api_netmap_delete_t *mp;
19992 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19994 if (unformat (i, "name %s", &if_name))
19995 vec_add1 (if_name, 0);
20000 if (!vec_len (if_name))
20002 errmsg ("interface name must be specified");
20006 if (vec_len (if_name) > 64)
20008 errmsg ("interface name too long");
20012 M (NETMAP_DELETE, mp);
20014 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20015 vec_free (if_name);
20023 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
20025 if (fp->afi == IP46_TYPE_IP6)
20027 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20028 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20029 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20030 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20031 format_ip6_address, fp->next_hop);
20032 else if (fp->afi == IP46_TYPE_IP4)
20034 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20035 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20036 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20037 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20038 format_ip4_address, fp->next_hop);
20042 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
20043 vl_api_fib_path_t * fp)
20045 struct in_addr ip4;
20046 struct in6_addr ip6;
20048 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20049 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20050 vat_json_object_add_uint (node, "is_local", fp->is_local);
20051 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20052 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20053 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20054 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20055 if (fp->afi == IP46_TYPE_IP4)
20057 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20058 vat_json_object_add_ip4 (node, "next_hop", ip4);
20060 else if (fp->afi == IP46_TYPE_IP6)
20062 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20063 vat_json_object_add_ip6 (node, "next_hop", ip6);
20068 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
20070 vat_main_t *vam = &vat_main;
20071 int count = ntohl (mp->mt_count);
20072 vl_api_fib_path_t *fp;
20075 print (vam->ofp, "[%d]: sw_if_index %d via:",
20076 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
20078 for (i = 0; i < count; i++)
20080 vl_api_mpls_fib_path_print (vam, fp);
20084 print (vam->ofp, "");
20087 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
20088 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
20091 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
20093 vat_main_t *vam = &vat_main;
20094 vat_json_node_t *node = NULL;
20095 int count = ntohl (mp->mt_count);
20096 vl_api_fib_path_t *fp;
20099 if (VAT_JSON_ARRAY != vam->json_tree.type)
20101 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20102 vat_json_init_array (&vam->json_tree);
20104 node = vat_json_array_add (&vam->json_tree);
20106 vat_json_init_object (node);
20107 vat_json_object_add_uint (node, "tunnel_index",
20108 ntohl (mp->mt_tunnel_index));
20109 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
20111 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
20114 for (i = 0; i < count; i++)
20116 vl_api_mpls_fib_path_json_print (node, fp);
20122 api_mpls_tunnel_dump (vat_main_t * vam)
20124 vl_api_mpls_tunnel_dump_t *mp;
20125 vl_api_control_ping_t *mp_ping;
20129 /* Parse args required to build the message */
20130 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
20132 if (!unformat (vam->input, "tunnel_index %d", &index))
20139 print (vam->ofp, " tunnel_index %d", index);
20141 M (MPLS_TUNNEL_DUMP, mp);
20142 mp->tunnel_index = htonl (index);
20145 /* Use a control ping for synchronization */
20146 MPING (CONTROL_PING, mp_ping);
20153 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
20154 #define vl_api_mpls_fib_details_t_print vl_noop_handler
20158 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
20160 vat_main_t *vam = &vat_main;
20161 int count = ntohl (mp->count);
20162 vl_api_fib_path_t *fp;
20166 "table-id %d, label %u, ess_bit %u",
20167 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
20169 for (i = 0; i < count; i++)
20171 vl_api_mpls_fib_path_print (vam, fp);
20176 static void vl_api_mpls_fib_details_t_handler_json
20177 (vl_api_mpls_fib_details_t * mp)
20179 vat_main_t *vam = &vat_main;
20180 int count = ntohl (mp->count);
20181 vat_json_node_t *node = NULL;
20182 vl_api_fib_path_t *fp;
20185 if (VAT_JSON_ARRAY != vam->json_tree.type)
20187 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20188 vat_json_init_array (&vam->json_tree);
20190 node = vat_json_array_add (&vam->json_tree);
20192 vat_json_init_object (node);
20193 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20194 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
20195 vat_json_object_add_uint (node, "label", ntohl (mp->label));
20196 vat_json_object_add_uint (node, "path_count", count);
20198 for (i = 0; i < count; i++)
20200 vl_api_mpls_fib_path_json_print (node, fp);
20206 api_mpls_fib_dump (vat_main_t * vam)
20208 vl_api_mpls_fib_dump_t *mp;
20209 vl_api_control_ping_t *mp_ping;
20212 M (MPLS_FIB_DUMP, mp);
20215 /* Use a control ping for synchronization */
20216 MPING (CONTROL_PING, mp_ping);
20223 #define vl_api_ip_fib_details_t_endian vl_noop_handler
20224 #define vl_api_ip_fib_details_t_print vl_noop_handler
20227 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
20229 vat_main_t *vam = &vat_main;
20230 int count = ntohl (mp->count);
20231 vl_api_fib_path_t *fp;
20235 "table-id %d, prefix %U/%d",
20236 ntohl (mp->table_id), format_ip4_address, mp->address,
20237 mp->address_length);
20239 for (i = 0; i < count; i++)
20241 if (fp->afi == IP46_TYPE_IP6)
20243 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20244 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U, "
20245 "next_hop_table %d",
20246 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20247 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20248 format_ip6_address, fp->next_hop, ntohl (fp->table_id));
20249 else if (fp->afi == IP46_TYPE_IP4)
20251 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20252 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U, "
20253 "next_hop_table %d",
20254 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20255 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20256 format_ip4_address, fp->next_hop, ntohl (fp->table_id));
20261 static void vl_api_ip_fib_details_t_handler_json
20262 (vl_api_ip_fib_details_t * mp)
20264 vat_main_t *vam = &vat_main;
20265 int count = ntohl (mp->count);
20266 vat_json_node_t *node = NULL;
20267 struct in_addr ip4;
20268 struct in6_addr ip6;
20269 vl_api_fib_path_t *fp;
20272 if (VAT_JSON_ARRAY != vam->json_tree.type)
20274 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20275 vat_json_init_array (&vam->json_tree);
20277 node = vat_json_array_add (&vam->json_tree);
20279 vat_json_init_object (node);
20280 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20281 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
20282 vat_json_object_add_ip4 (node, "prefix", ip4);
20283 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20284 vat_json_object_add_uint (node, "path_count", count);
20286 for (i = 0; i < count; i++)
20288 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20289 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20290 vat_json_object_add_uint (node, "is_local", fp->is_local);
20291 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20292 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20293 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20294 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20295 if (fp->afi == IP46_TYPE_IP4)
20297 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20298 vat_json_object_add_ip4 (node, "next_hop", ip4);
20300 else if (fp->afi == IP46_TYPE_IP6)
20302 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20303 vat_json_object_add_ip6 (node, "next_hop", ip6);
20309 api_ip_fib_dump (vat_main_t * vam)
20311 vl_api_ip_fib_dump_t *mp;
20312 vl_api_control_ping_t *mp_ping;
20315 M (IP_FIB_DUMP, mp);
20318 /* Use a control ping for synchronization */
20319 MPING (CONTROL_PING, mp_ping);
20327 api_ip_mfib_dump (vat_main_t * vam)
20329 vl_api_ip_mfib_dump_t *mp;
20330 vl_api_control_ping_t *mp_ping;
20333 M (IP_MFIB_DUMP, mp);
20336 /* Use a control ping for synchronization */
20337 MPING (CONTROL_PING, mp_ping);
20344 static void vl_api_ip_neighbor_details_t_handler
20345 (vl_api_ip_neighbor_details_t * mp)
20347 vat_main_t *vam = &vat_main;
20349 print (vam->ofp, "%c %U %U",
20350 (mp->is_static) ? 'S' : 'D',
20351 format_ethernet_address, &mp->mac_address,
20352 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
20356 static void vl_api_ip_neighbor_details_t_handler_json
20357 (vl_api_ip_neighbor_details_t * mp)
20360 vat_main_t *vam = &vat_main;
20361 vat_json_node_t *node;
20362 struct in_addr ip4;
20363 struct in6_addr ip6;
20365 if (VAT_JSON_ARRAY != vam->json_tree.type)
20367 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20368 vat_json_init_array (&vam->json_tree);
20370 node = vat_json_array_add (&vam->json_tree);
20372 vat_json_init_object (node);
20373 vat_json_object_add_string_copy (node, "flag",
20374 (mp->is_static) ? (u8 *) "static" : (u8 *)
20377 vat_json_object_add_string_copy (node, "link_layer",
20378 format (0, "%U", format_ethernet_address,
20379 &mp->mac_address));
20383 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
20384 vat_json_object_add_ip6 (node, "ip_address", ip6);
20388 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
20389 vat_json_object_add_ip4 (node, "ip_address", ip4);
20394 api_ip_neighbor_dump (vat_main_t * vam)
20396 unformat_input_t *i = vam->input;
20397 vl_api_ip_neighbor_dump_t *mp;
20398 vl_api_control_ping_t *mp_ping;
20400 u32 sw_if_index = ~0;
20403 /* Parse args required to build the message */
20404 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20406 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20408 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20410 else if (unformat (i, "ip6"))
20416 if (sw_if_index == ~0)
20418 errmsg ("missing interface name or sw_if_index");
20422 M (IP_NEIGHBOR_DUMP, mp);
20423 mp->is_ipv6 = (u8) is_ipv6;
20424 mp->sw_if_index = ntohl (sw_if_index);
20427 /* Use a control ping for synchronization */
20428 MPING (CONTROL_PING, mp_ping);
20435 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
20436 #define vl_api_ip6_fib_details_t_print vl_noop_handler
20439 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
20441 vat_main_t *vam = &vat_main;
20442 int count = ntohl (mp->count);
20443 vl_api_fib_path_t *fp;
20447 "table-id %d, prefix %U/%d",
20448 ntohl (mp->table_id), format_ip6_address, mp->address,
20449 mp->address_length);
20451 for (i = 0; i < count; i++)
20453 if (fp->afi == IP46_TYPE_IP6)
20455 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20456 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20457 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20458 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20459 format_ip6_address, fp->next_hop);
20460 else if (fp->afi == IP46_TYPE_IP4)
20462 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20463 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20464 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20465 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20466 format_ip4_address, fp->next_hop);
20471 static void vl_api_ip6_fib_details_t_handler_json
20472 (vl_api_ip6_fib_details_t * mp)
20474 vat_main_t *vam = &vat_main;
20475 int count = ntohl (mp->count);
20476 vat_json_node_t *node = NULL;
20477 struct in_addr ip4;
20478 struct in6_addr ip6;
20479 vl_api_fib_path_t *fp;
20482 if (VAT_JSON_ARRAY != vam->json_tree.type)
20484 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20485 vat_json_init_array (&vam->json_tree);
20487 node = vat_json_array_add (&vam->json_tree);
20489 vat_json_init_object (node);
20490 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20491 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
20492 vat_json_object_add_ip6 (node, "prefix", ip6);
20493 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20494 vat_json_object_add_uint (node, "path_count", count);
20496 for (i = 0; i < count; i++)
20498 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20499 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20500 vat_json_object_add_uint (node, "is_local", fp->is_local);
20501 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20502 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20503 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20504 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20505 if (fp->afi == IP46_TYPE_IP4)
20507 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20508 vat_json_object_add_ip4 (node, "next_hop", ip4);
20510 else if (fp->afi == IP46_TYPE_IP6)
20512 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20513 vat_json_object_add_ip6 (node, "next_hop", ip6);
20519 api_ip6_fib_dump (vat_main_t * vam)
20521 vl_api_ip6_fib_dump_t *mp;
20522 vl_api_control_ping_t *mp_ping;
20525 M (IP6_FIB_DUMP, mp);
20528 /* Use a control ping for synchronization */
20529 MPING (CONTROL_PING, mp_ping);
20537 api_ip6_mfib_dump (vat_main_t * vam)
20539 vl_api_ip6_mfib_dump_t *mp;
20540 vl_api_control_ping_t *mp_ping;
20543 M (IP6_MFIB_DUMP, mp);
20546 /* Use a control ping for synchronization */
20547 MPING (CONTROL_PING, mp_ping);
20555 api_classify_table_ids (vat_main_t * vam)
20557 vl_api_classify_table_ids_t *mp;
20560 /* Construct the API message */
20561 M (CLASSIFY_TABLE_IDS, mp);
20570 api_classify_table_by_interface (vat_main_t * vam)
20572 unformat_input_t *input = vam->input;
20573 vl_api_classify_table_by_interface_t *mp;
20575 u32 sw_if_index = ~0;
20577 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20579 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20581 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20586 if (sw_if_index == ~0)
20588 errmsg ("missing interface name or sw_if_index");
20592 /* Construct the API message */
20593 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
20595 mp->sw_if_index = ntohl (sw_if_index);
20603 api_classify_table_info (vat_main_t * vam)
20605 unformat_input_t *input = vam->input;
20606 vl_api_classify_table_info_t *mp;
20610 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20612 if (unformat (input, "table_id %d", &table_id))
20617 if (table_id == ~0)
20619 errmsg ("missing table id");
20623 /* Construct the API message */
20624 M (CLASSIFY_TABLE_INFO, mp);
20626 mp->table_id = ntohl (table_id);
20634 api_classify_session_dump (vat_main_t * vam)
20636 unformat_input_t *input = vam->input;
20637 vl_api_classify_session_dump_t *mp;
20638 vl_api_control_ping_t *mp_ping;
20642 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20644 if (unformat (input, "table_id %d", &table_id))
20649 if (table_id == ~0)
20651 errmsg ("missing table id");
20655 /* Construct the API message */
20656 M (CLASSIFY_SESSION_DUMP, mp);
20658 mp->table_id = ntohl (table_id);
20661 /* Use a control ping for synchronization */
20662 MPING (CONTROL_PING, mp_ping);
20670 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
20672 vat_main_t *vam = &vat_main;
20674 print (vam->ofp, "collector_address %U, collector_port %d, "
20675 "src_address %U, vrf_id %d, path_mtu %u, "
20676 "template_interval %u, udp_checksum %d",
20677 format_ip4_address, mp->collector_address,
20678 ntohs (mp->collector_port),
20679 format_ip4_address, mp->src_address,
20680 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
20681 ntohl (mp->template_interval), mp->udp_checksum);
20684 vam->result_ready = 1;
20688 vl_api_ipfix_exporter_details_t_handler_json
20689 (vl_api_ipfix_exporter_details_t * mp)
20691 vat_main_t *vam = &vat_main;
20692 vat_json_node_t node;
20693 struct in_addr collector_address;
20694 struct in_addr src_address;
20696 vat_json_init_object (&node);
20697 clib_memcpy (&collector_address, &mp->collector_address,
20698 sizeof (collector_address));
20699 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
20700 vat_json_object_add_uint (&node, "collector_port",
20701 ntohs (mp->collector_port));
20702 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
20703 vat_json_object_add_ip4 (&node, "src_address", src_address);
20704 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
20705 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
20706 vat_json_object_add_uint (&node, "template_interval",
20707 ntohl (mp->template_interval));
20708 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
20710 vat_json_print (vam->ofp, &node);
20711 vat_json_free (&node);
20713 vam->result_ready = 1;
20717 api_ipfix_exporter_dump (vat_main_t * vam)
20719 vl_api_ipfix_exporter_dump_t *mp;
20722 /* Construct the API message */
20723 M (IPFIX_EXPORTER_DUMP, mp);
20732 api_ipfix_classify_stream_dump (vat_main_t * vam)
20734 vl_api_ipfix_classify_stream_dump_t *mp;
20737 /* Construct the API message */
20738 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
20749 vl_api_ipfix_classify_stream_details_t_handler
20750 (vl_api_ipfix_classify_stream_details_t * mp)
20752 vat_main_t *vam = &vat_main;
20753 print (vam->ofp, "domain_id %d, src_port %d",
20754 ntohl (mp->domain_id), ntohs (mp->src_port));
20756 vam->result_ready = 1;
20760 vl_api_ipfix_classify_stream_details_t_handler_json
20761 (vl_api_ipfix_classify_stream_details_t * mp)
20763 vat_main_t *vam = &vat_main;
20764 vat_json_node_t node;
20766 vat_json_init_object (&node);
20767 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
20768 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
20770 vat_json_print (vam->ofp, &node);
20771 vat_json_free (&node);
20773 vam->result_ready = 1;
20777 api_ipfix_classify_table_dump (vat_main_t * vam)
20779 vl_api_ipfix_classify_table_dump_t *mp;
20780 vl_api_control_ping_t *mp_ping;
20783 if (!vam->json_output)
20785 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
20786 "transport_protocol");
20789 /* Construct the API message */
20790 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
20795 /* Use a control ping for synchronization */
20796 MPING (CONTROL_PING, mp_ping);
20804 vl_api_ipfix_classify_table_details_t_handler
20805 (vl_api_ipfix_classify_table_details_t * mp)
20807 vat_main_t *vam = &vat_main;
20808 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
20809 mp->transport_protocol);
20813 vl_api_ipfix_classify_table_details_t_handler_json
20814 (vl_api_ipfix_classify_table_details_t * mp)
20816 vat_json_node_t *node = NULL;
20817 vat_main_t *vam = &vat_main;
20819 if (VAT_JSON_ARRAY != vam->json_tree.type)
20821 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20822 vat_json_init_array (&vam->json_tree);
20825 node = vat_json_array_add (&vam->json_tree);
20826 vat_json_init_object (node);
20828 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
20829 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
20830 vat_json_object_add_uint (node, "transport_protocol",
20831 mp->transport_protocol);
20835 api_sw_interface_span_enable_disable (vat_main_t * vam)
20837 unformat_input_t *i = vam->input;
20838 vl_api_sw_interface_span_enable_disable_t *mp;
20839 u32 src_sw_if_index = ~0;
20840 u32 dst_sw_if_index = ~0;
20845 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20848 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
20850 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
20854 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
20856 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
20858 else if (unformat (i, "disable"))
20860 else if (unformat (i, "rx"))
20862 else if (unformat (i, "tx"))
20864 else if (unformat (i, "both"))
20866 else if (unformat (i, "l2"))
20872 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
20874 mp->sw_if_index_from = htonl (src_sw_if_index);
20875 mp->sw_if_index_to = htonl (dst_sw_if_index);
20885 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
20888 vat_main_t *vam = &vat_main;
20889 u8 *sw_if_from_name = 0;
20890 u8 *sw_if_to_name = 0;
20891 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
20892 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
20893 char *states[] = { "none", "rx", "tx", "both" };
20897 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
20899 if ((u32) p->value[0] == sw_if_index_from)
20901 sw_if_from_name = (u8 *)(p->key);
20905 if ((u32) p->value[0] == sw_if_index_to)
20907 sw_if_to_name = (u8 *)(p->key);
20908 if (sw_if_from_name)
20913 print (vam->ofp, "%20s => %20s (%s) %s",
20914 sw_if_from_name, sw_if_to_name, states[mp->state],
20915 mp->is_l2 ? "l2" : "device");
20919 vl_api_sw_interface_span_details_t_handler_json
20920 (vl_api_sw_interface_span_details_t * mp)
20922 vat_main_t *vam = &vat_main;
20923 vat_json_node_t *node = NULL;
20924 u8 *sw_if_from_name = 0;
20925 u8 *sw_if_to_name = 0;
20926 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
20927 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
20931 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
20933 if ((u32) p->value[0] == sw_if_index_from)
20935 sw_if_from_name = (u8 *)(p->key);
20939 if ((u32) p->value[0] == sw_if_index_to)
20941 sw_if_to_name = (u8 *)(p->key);
20942 if (sw_if_from_name)
20948 if (VAT_JSON_ARRAY != vam->json_tree.type)
20950 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20951 vat_json_init_array (&vam->json_tree);
20953 node = vat_json_array_add (&vam->json_tree);
20955 vat_json_init_object (node);
20956 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
20957 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
20958 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
20959 if (0 != sw_if_to_name)
20961 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
20963 vat_json_object_add_uint (node, "state", mp->state);
20964 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
20968 api_sw_interface_span_dump (vat_main_t * vam)
20970 unformat_input_t *input = vam->input;
20971 vl_api_sw_interface_span_dump_t *mp;
20972 vl_api_control_ping_t *mp_ping;
20976 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20978 if (unformat (input, "l2"))
20984 M (SW_INTERFACE_SPAN_DUMP, mp);
20988 /* Use a control ping for synchronization */
20989 MPING (CONTROL_PING, mp_ping);
20997 api_pg_create_interface (vat_main_t * vam)
20999 unformat_input_t *input = vam->input;
21000 vl_api_pg_create_interface_t *mp;
21004 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21006 if (unformat (input, "if_id %d", &if_id))
21013 errmsg ("missing pg interface index");
21017 /* Construct the API message */
21018 M (PG_CREATE_INTERFACE, mp);
21020 mp->interface_id = ntohl (if_id);
21028 api_pg_capture (vat_main_t * vam)
21030 unformat_input_t *input = vam->input;
21031 vl_api_pg_capture_t *mp;
21036 u8 pcap_file_set = 0;
21039 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21041 if (unformat (input, "if_id %d", &if_id))
21043 else if (unformat (input, "pcap %s", &pcap_file))
21045 else if (unformat (input, "count %d", &count))
21047 else if (unformat (input, "disable"))
21054 errmsg ("missing pg interface index");
21057 if (pcap_file_set > 0)
21059 if (vec_len (pcap_file) > 255)
21061 errmsg ("pcap file name is too long");
21066 u32 name_len = vec_len (pcap_file);
21067 /* Construct the API message */
21068 M (PG_CAPTURE, mp);
21070 mp->interface_id = ntohl (if_id);
21071 mp->is_enabled = enable;
21072 mp->count = ntohl (count);
21073 mp->pcap_name_length = ntohl (name_len);
21074 if (pcap_file_set != 0)
21076 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
21078 vec_free (pcap_file);
21086 api_pg_enable_disable (vat_main_t * vam)
21088 unformat_input_t *input = vam->input;
21089 vl_api_pg_enable_disable_t *mp;
21092 u8 stream_name_set = 0;
21093 u8 *stream_name = 0;
21095 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21097 if (unformat (input, "stream %s", &stream_name))
21098 stream_name_set = 1;
21099 else if (unformat (input, "disable"))
21105 if (stream_name_set > 0)
21107 if (vec_len (stream_name) > 255)
21109 errmsg ("stream name too long");
21114 u32 name_len = vec_len (stream_name);
21115 /* Construct the API message */
21116 M (PG_ENABLE_DISABLE, mp);
21118 mp->is_enabled = enable;
21119 if (stream_name_set != 0)
21121 mp->stream_name_length = ntohl (name_len);
21122 clib_memcpy (mp->stream_name, stream_name, name_len);
21124 vec_free (stream_name);
21132 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
21134 unformat_input_t *input = vam->input;
21135 vl_api_ip_source_and_port_range_check_add_del_t *mp;
21137 u16 *low_ports = 0;
21138 u16 *high_ports = 0;
21141 ip4_address_t ip4_addr;
21142 ip6_address_t ip6_addr;
21151 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21153 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
21159 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
21164 else if (unformat (input, "vrf %d", &vrf_id))
21166 else if (unformat (input, "del"))
21168 else if (unformat (input, "port %d", &tmp))
21170 if (tmp == 0 || tmp > 65535)
21172 errmsg ("port %d out of range", tmp);
21176 this_hi = this_low + 1;
21177 vec_add1 (low_ports, this_low);
21178 vec_add1 (high_ports, this_hi);
21180 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
21182 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
21184 errmsg ("incorrect range parameters");
21188 /* Note: in debug CLI +1 is added to high before
21189 passing to real fn that does "the work"
21190 (ip_source_and_port_range_check_add_del).
21191 This fn is a wrapper around the binary API fn a
21192 control plane will call, which expects this increment
21193 to have occurred. Hence letting the binary API control
21194 plane fn do the increment for consistency between VAT
21195 and other control planes.
21198 vec_add1 (low_ports, this_low);
21199 vec_add1 (high_ports, this_hi);
21205 if (prefix_set == 0)
21207 errmsg ("<address>/<mask> not specified");
21213 errmsg ("VRF ID required, not specified");
21220 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21224 if (vec_len (low_ports) == 0)
21226 errmsg ("At least one port or port range required");
21230 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
21232 mp->is_add = is_add;
21237 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
21242 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
21245 mp->mask_length = length;
21246 mp->number_of_ranges = vec_len (low_ports);
21248 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
21249 vec_free (low_ports);
21251 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
21252 vec_free (high_ports);
21254 mp->vrf_id = ntohl (vrf_id);
21262 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
21264 unformat_input_t *input = vam->input;
21265 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
21266 u32 sw_if_index = ~0;
21268 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
21269 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
21273 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21275 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21277 else if (unformat (input, "sw_if_index %d", &sw_if_index))
21279 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
21281 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
21283 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
21285 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
21287 else if (unformat (input, "del"))
21293 if (sw_if_index == ~0)
21295 errmsg ("Interface required but not specified");
21301 errmsg ("VRF ID required but not specified");
21305 if (tcp_out_vrf_id == 0
21306 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
21309 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21313 /* Construct the API message */
21314 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
21316 mp->sw_if_index = ntohl (sw_if_index);
21317 mp->is_add = is_add;
21318 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
21319 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
21320 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
21321 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
21326 /* Wait for a reply... */
21332 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
21334 unformat_input_t *i = vam->input;
21335 vl_api_ipsec_gre_add_del_tunnel_t *mp;
21336 u32 local_sa_id = 0;
21337 u32 remote_sa_id = 0;
21338 ip4_address_t src_address;
21339 ip4_address_t dst_address;
21343 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21345 if (unformat (i, "local_sa %d", &local_sa_id))
21347 else if (unformat (i, "remote_sa %d", &remote_sa_id))
21349 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
21351 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
21353 else if (unformat (i, "del"))
21357 clib_warning ("parse error '%U'", format_unformat_error, i);
21362 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
21364 mp->local_sa_id = ntohl (local_sa_id);
21365 mp->remote_sa_id = ntohl (remote_sa_id);
21366 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
21367 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
21368 mp->is_add = is_add;
21376 api_punt (vat_main_t * vam)
21378 unformat_input_t *i = vam->input;
21386 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21388 if (unformat (i, "ip %d", &ipv))
21390 else if (unformat (i, "protocol %d", &protocol))
21392 else if (unformat (i, "port %d", &port))
21394 else if (unformat (i, "del"))
21398 clib_warning ("parse error '%U'", format_unformat_error, i);
21405 mp->is_add = (u8) is_add;
21406 mp->ipv = (u8) ipv;
21407 mp->l4_protocol = (u8) protocol;
21408 mp->l4_port = htons ((u16) port);
21415 static void vl_api_ipsec_gre_tunnel_details_t_handler
21416 (vl_api_ipsec_gre_tunnel_details_t * mp)
21418 vat_main_t *vam = &vat_main;
21420 print (vam->ofp, "%11d%15U%15U%14d%14d",
21421 ntohl (mp->sw_if_index),
21422 format_ip4_address, &mp->src_address,
21423 format_ip4_address, &mp->dst_address,
21424 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
21427 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
21428 (vl_api_ipsec_gre_tunnel_details_t * mp)
21430 vat_main_t *vam = &vat_main;
21431 vat_json_node_t *node = NULL;
21432 struct in_addr ip4;
21434 if (VAT_JSON_ARRAY != vam->json_tree.type)
21436 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21437 vat_json_init_array (&vam->json_tree);
21439 node = vat_json_array_add (&vam->json_tree);
21441 vat_json_init_object (node);
21442 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
21443 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
21444 vat_json_object_add_ip4 (node, "src_address", ip4);
21445 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
21446 vat_json_object_add_ip4 (node, "dst_address", ip4);
21447 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
21448 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
21452 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
21454 unformat_input_t *i = vam->input;
21455 vl_api_ipsec_gre_tunnel_dump_t *mp;
21456 vl_api_control_ping_t *mp_ping;
21458 u8 sw_if_index_set = 0;
21461 /* Parse args required to build the message */
21462 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21464 if (unformat (i, "sw_if_index %d", &sw_if_index))
21465 sw_if_index_set = 1;
21470 if (sw_if_index_set == 0)
21475 if (!vam->json_output)
21477 print (vam->ofp, "%11s%15s%15s%14s%14s",
21478 "sw_if_index", "src_address", "dst_address",
21479 "local_sa_id", "remote_sa_id");
21482 /* Get list of gre-tunnel interfaces */
21483 M (IPSEC_GRE_TUNNEL_DUMP, mp);
21485 mp->sw_if_index = htonl (sw_if_index);
21489 /* Use a control ping for synchronization */
21490 MPING (CONTROL_PING, mp_ping);
21498 api_delete_subif (vat_main_t * vam)
21500 unformat_input_t *i = vam->input;
21501 vl_api_delete_subif_t *mp;
21502 u32 sw_if_index = ~0;
21505 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21507 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21509 if (unformat (i, "sw_if_index %d", &sw_if_index))
21515 if (sw_if_index == ~0)
21517 errmsg ("missing sw_if_index");
21521 /* Construct the API message */
21522 M (DELETE_SUBIF, mp);
21523 mp->sw_if_index = ntohl (sw_if_index);
21530 #define foreach_pbb_vtr_op \
21531 _("disable", L2_VTR_DISABLED) \
21532 _("pop", L2_VTR_POP_2) \
21533 _("push", L2_VTR_PUSH_2)
21536 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
21538 unformat_input_t *i = vam->input;
21539 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
21540 u32 sw_if_index = ~0, vtr_op = ~0;
21541 u16 outer_tag = ~0;
21542 u8 dmac[6], smac[6];
21543 u8 dmac_set = 0, smac_set = 0;
21549 /* Shut up coverity */
21550 memset (dmac, 0, sizeof (dmac));
21551 memset (smac, 0, sizeof (smac));
21553 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21555 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21557 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21559 else if (unformat (i, "vtr_op %d", &vtr_op))
21561 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
21564 else if (unformat (i, "translate_pbb_stag"))
21566 if (unformat (i, "%d", &tmp))
21568 vtr_op = L2_VTR_TRANSLATE_2_1;
21574 ("translate_pbb_stag operation requires outer tag definition");
21578 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
21580 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
21582 else if (unformat (i, "sid %d", &sid))
21584 else if (unformat (i, "vlanid %d", &tmp))
21588 clib_warning ("parse error '%U'", format_unformat_error, i);
21593 if ((sw_if_index == ~0) || (vtr_op == ~0))
21595 errmsg ("missing sw_if_index or vtr operation");
21598 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
21599 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
21602 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
21606 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
21607 mp->sw_if_index = ntohl (sw_if_index);
21608 mp->vtr_op = ntohl (vtr_op);
21609 mp->outer_tag = ntohs (outer_tag);
21610 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
21611 clib_memcpy (mp->b_smac, smac, sizeof (smac));
21612 mp->b_vlanid = ntohs (vlanid);
21613 mp->i_sid = ntohl (sid);
21621 api_flow_classify_set_interface (vat_main_t * vam)
21623 unformat_input_t *i = vam->input;
21624 vl_api_flow_classify_set_interface_t *mp;
21626 int sw_if_index_set;
21627 u32 ip4_table_index = ~0;
21628 u32 ip6_table_index = ~0;
21632 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21634 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21635 sw_if_index_set = 1;
21636 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21637 sw_if_index_set = 1;
21638 else if (unformat (i, "del"))
21640 else if (unformat (i, "ip4-table %d", &ip4_table_index))
21642 else if (unformat (i, "ip6-table %d", &ip6_table_index))
21646 clib_warning ("parse error '%U'", format_unformat_error, i);
21651 if (sw_if_index_set == 0)
21653 errmsg ("missing interface name or sw_if_index");
21657 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
21659 mp->sw_if_index = ntohl (sw_if_index);
21660 mp->ip4_table_index = ntohl (ip4_table_index);
21661 mp->ip6_table_index = ntohl (ip6_table_index);
21662 mp->is_add = is_add;
21670 api_flow_classify_dump (vat_main_t * vam)
21672 unformat_input_t *i = vam->input;
21673 vl_api_flow_classify_dump_t *mp;
21674 vl_api_control_ping_t *mp_ping;
21675 u8 type = FLOW_CLASSIFY_N_TABLES;
21678 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
21682 errmsg ("classify table type must be specified");
21686 if (!vam->json_output)
21688 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
21691 M (FLOW_CLASSIFY_DUMP, mp);
21696 /* Use a control ping for synchronization */
21697 MPING (CONTROL_PING, mp_ping);
21700 /* Wait for a reply... */
21706 api_feature_enable_disable (vat_main_t * vam)
21708 unformat_input_t *i = vam->input;
21709 vl_api_feature_enable_disable_t *mp;
21711 u8 *feature_name = 0;
21712 u32 sw_if_index = ~0;
21716 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21718 if (unformat (i, "arc_name %s", &arc_name))
21720 else if (unformat (i, "feature_name %s", &feature_name))
21723 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21725 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21727 else if (unformat (i, "disable"))
21735 errmsg ("missing arc name");
21738 if (vec_len (arc_name) > 63)
21740 errmsg ("arc name too long");
21743 if (feature_name == 0)
21745 errmsg ("missing feature name");
21748 if (vec_len (feature_name) > 63)
21750 errmsg ("feature name too long");
21753 if (sw_if_index == ~0)
21755 errmsg ("missing interface name or sw_if_index");
21759 /* Construct the API message */
21760 M (FEATURE_ENABLE_DISABLE, mp);
21761 mp->sw_if_index = ntohl (sw_if_index);
21762 mp->enable = enable;
21763 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
21764 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
21765 vec_free (arc_name);
21766 vec_free (feature_name);
21774 api_sw_interface_tag_add_del (vat_main_t * vam)
21776 unformat_input_t *i = vam->input;
21777 vl_api_sw_interface_tag_add_del_t *mp;
21778 u32 sw_if_index = ~0;
21783 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21785 if (unformat (i, "tag %s", &tag))
21787 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21789 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21791 else if (unformat (i, "del"))
21797 if (sw_if_index == ~0)
21799 errmsg ("missing interface name or sw_if_index");
21803 if (enable && (tag == 0))
21805 errmsg ("no tag specified");
21809 /* Construct the API message */
21810 M (SW_INTERFACE_TAG_ADD_DEL, mp);
21811 mp->sw_if_index = ntohl (sw_if_index);
21812 mp->is_add = enable;
21814 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
21822 static void vl_api_l2_xconnect_details_t_handler
21823 (vl_api_l2_xconnect_details_t * mp)
21825 vat_main_t *vam = &vat_main;
21827 print (vam->ofp, "%15d%15d",
21828 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
21831 static void vl_api_l2_xconnect_details_t_handler_json
21832 (vl_api_l2_xconnect_details_t * mp)
21834 vat_main_t *vam = &vat_main;
21835 vat_json_node_t *node = NULL;
21837 if (VAT_JSON_ARRAY != vam->json_tree.type)
21839 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21840 vat_json_init_array (&vam->json_tree);
21842 node = vat_json_array_add (&vam->json_tree);
21844 vat_json_init_object (node);
21845 vat_json_object_add_uint (node, "rx_sw_if_index",
21846 ntohl (mp->rx_sw_if_index));
21847 vat_json_object_add_uint (node, "tx_sw_if_index",
21848 ntohl (mp->tx_sw_if_index));
21852 api_l2_xconnect_dump (vat_main_t * vam)
21854 vl_api_l2_xconnect_dump_t *mp;
21855 vl_api_control_ping_t *mp_ping;
21858 if (!vam->json_output)
21860 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
21863 M (L2_XCONNECT_DUMP, mp);
21867 /* Use a control ping for synchronization */
21868 MPING (CONTROL_PING, mp_ping);
21876 api_hw_interface_set_mtu (vat_main_t * vam)
21878 unformat_input_t *i = vam->input;
21879 vl_api_hw_interface_set_mtu_t *mp;
21880 u32 sw_if_index = ~0;
21884 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21886 if (unformat (i, "mtu %d", &mtu))
21888 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21890 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21896 if (sw_if_index == ~0)
21898 errmsg ("missing interface name or sw_if_index");
21904 errmsg ("no mtu specified");
21908 /* Construct the API message */
21909 M (HW_INTERFACE_SET_MTU, mp);
21910 mp->sw_if_index = ntohl (sw_if_index);
21911 mp->mtu = ntohs ((u16) mtu);
21919 api_p2p_ethernet_add (vat_main_t * vam)
21921 unformat_input_t *i = vam->input;
21922 vl_api_p2p_ethernet_add_t *mp;
21923 u32 parent_if_index = ~0;
21929 memset (remote_mac, 0, sizeof (remote_mac));
21930 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21932 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
21934 else if (unformat (i, "sw_if_index %d", &parent_if_index))
21938 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
21940 else if (unformat (i, "sub_id %d", &sub_id))
21944 clib_warning ("parse error '%U'", format_unformat_error, i);
21949 if (parent_if_index == ~0)
21951 errmsg ("missing interface name or sw_if_index");
21956 errmsg ("missing remote mac address");
21961 errmsg ("missing sub-interface id");
21965 M (P2P_ETHERNET_ADD, mp);
21966 mp->parent_if_index = ntohl (parent_if_index);
21967 mp->subif_id = ntohl (sub_id);
21968 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
21976 api_p2p_ethernet_del (vat_main_t * vam)
21978 unformat_input_t *i = vam->input;
21979 vl_api_p2p_ethernet_del_t *mp;
21980 u32 parent_if_index = ~0;
21985 memset (remote_mac, 0, sizeof (remote_mac));
21986 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21988 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
21990 else if (unformat (i, "sw_if_index %d", &parent_if_index))
21994 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
21998 clib_warning ("parse error '%U'", format_unformat_error, i);
22003 if (parent_if_index == ~0)
22005 errmsg ("missing interface name or sw_if_index");
22010 errmsg ("missing remote mac address");
22014 M (P2P_ETHERNET_DEL, mp);
22015 mp->parent_if_index = ntohl (parent_if_index);
22016 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22024 api_lldp_config (vat_main_t * vam)
22026 unformat_input_t *i = vam->input;
22027 vl_api_lldp_config_t *mp;
22029 int tx_interval = 0;
22030 u8 *sys_name = NULL;
22033 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22035 if (unformat (i, "system-name %s", &sys_name))
22037 else if (unformat (i, "tx-hold %d", &tx_hold))
22039 else if (unformat (i, "tx-interval %d", &tx_interval))
22043 clib_warning ("parse error '%U'", format_unformat_error, i);
22048 vec_add1 (sys_name, 0);
22050 M (LLDP_CONFIG, mp);
22051 mp->tx_hold = htonl (tx_hold);
22052 mp->tx_interval = htonl (tx_interval);
22053 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
22054 vec_free (sys_name);
22062 api_sw_interface_set_lldp (vat_main_t * vam)
22064 unformat_input_t *i = vam->input;
22065 vl_api_sw_interface_set_lldp_t *mp;
22066 u32 sw_if_index = ~0;
22068 u8 *port_desc = NULL, *mgmt_oid = NULL;
22069 ip4_address_t ip4_addr;
22070 ip6_address_t ip6_addr;
22073 memset (&ip4_addr, 0, sizeof (ip4_addr));
22074 memset (&ip6_addr, 0, sizeof (ip6_addr));
22076 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22078 if (unformat (i, "disable"))
22081 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22083 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22085 else if (unformat (i, "port-desc %s", &port_desc))
22087 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
22089 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
22091 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
22097 if (sw_if_index == ~0)
22099 errmsg ("missing interface name or sw_if_index");
22103 /* Construct the API message */
22104 vec_add1 (port_desc, 0);
22105 vec_add1 (mgmt_oid, 0);
22106 M (SW_INTERFACE_SET_LLDP, mp);
22107 mp->sw_if_index = ntohl (sw_if_index);
22108 mp->enable = enable;
22109 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
22110 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
22111 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
22112 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
22113 vec_free (port_desc);
22114 vec_free (mgmt_oid);
22122 api_tcp_configure_src_addresses (vat_main_t * vam)
22124 vl_api_tcp_configure_src_addresses_t *mp;
22125 unformat_input_t *i = vam->input;
22126 ip4_address_t v4first, v4last;
22127 ip6_address_t v6first, v6last;
22132 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22134 if (unformat (i, "%U - %U",
22135 unformat_ip4_address, &v4first,
22136 unformat_ip4_address, &v4last))
22140 errmsg ("one range per message (range already set)");
22145 else if (unformat (i, "%U - %U",
22146 unformat_ip6_address, &v6first,
22147 unformat_ip6_address, &v6last))
22151 errmsg ("one range per message (range already set)");
22156 else if (unformat (i, "vrf %d", &vrf_id))
22162 if (range_set == 0)
22164 errmsg ("address range not set");
22168 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
22169 mp->vrf_id = ntohl (vrf_id);
22171 if (range_set == 2)
22174 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
22175 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
22180 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
22181 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
22188 static void vl_api_app_namespace_add_del_reply_t_handler
22189 (vl_api_app_namespace_add_del_reply_t * mp)
22191 vat_main_t *vam = &vat_main;
22192 i32 retval = ntohl (mp->retval);
22193 if (vam->async_mode)
22195 vam->async_errors += (retval < 0);
22199 vam->retval = retval;
22201 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
22202 vam->result_ready = 1;
22206 static void vl_api_app_namespace_add_del_reply_t_handler_json
22207 (vl_api_app_namespace_add_del_reply_t * mp)
22209 vat_main_t *vam = &vat_main;
22210 vat_json_node_t node;
22212 vat_json_init_object (&node);
22213 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
22214 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
22216 vat_json_print (vam->ofp, &node);
22217 vat_json_free (&node);
22219 vam->retval = ntohl (mp->retval);
22220 vam->result_ready = 1;
22224 api_app_namespace_add_del (vat_main_t * vam)
22226 vl_api_app_namespace_add_del_t *mp;
22227 unformat_input_t *i = vam->input;
22228 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
22229 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
22233 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22235 if (unformat (i, "id %_%v%_", &ns_id))
22237 else if (unformat (i, "secret %lu", &secret))
22239 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22240 sw_if_index_set = 1;
22241 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
22243 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
22248 if (!ns_id || !secret_set || !sw_if_index_set)
22250 errmsg ("namespace id, secret and sw_if_index must be set");
22253 if (vec_len (ns_id) > 64)
22255 errmsg ("namespace id too long");
22258 M (APP_NAMESPACE_ADD_DEL, mp);
22260 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
22261 mp->namespace_id_len = vec_len (ns_id);
22262 mp->secret = clib_host_to_net_u64 (secret);
22263 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
22264 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
22265 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
22273 api_sock_init_shm (vat_main_t * vam)
22275 #if VPP_API_TEST_BUILTIN == 0
22276 unformat_input_t *i = vam->input;
22277 vl_api_shm_elem_config_t *config = 0;
22278 u64 size = 64 << 20;
22281 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22283 if (unformat (i, "size %U", unformat_memory_size, &size))
22290 * Canned custom ring allocator config.
22291 * Should probably parse all of this
22293 vec_validate (config, 6);
22294 config[0].type = VL_API_VLIB_RING;
22295 config[0].size = 256;
22296 config[0].count = 32;
22298 config[1].type = VL_API_VLIB_RING;
22299 config[1].size = 1024;
22300 config[1].count = 16;
22302 config[2].type = VL_API_VLIB_RING;
22303 config[2].size = 4096;
22304 config[2].count = 2;
22306 config[3].type = VL_API_CLIENT_RING;
22307 config[3].size = 256;
22308 config[3].count = 32;
22310 config[4].type = VL_API_CLIENT_RING;
22311 config[4].size = 1024;
22312 config[4].count = 16;
22314 config[5].type = VL_API_CLIENT_RING;
22315 config[5].size = 4096;
22316 config[5].count = 2;
22318 config[6].type = VL_API_QUEUE;
22319 config[6].count = 128;
22320 config[6].size = sizeof (uword);
22322 rv = vl_socket_client_init_shm (config);
22324 vam->client_index_invalid = 1;
22332 api_dns_enable_disable (vat_main_t * vam)
22334 unformat_input_t *line_input = vam->input;
22335 vl_api_dns_enable_disable_t *mp;
22336 u8 enable_disable = 1;
22339 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22341 if (unformat (line_input, "disable"))
22342 enable_disable = 0;
22343 if (unformat (line_input, "enable"))
22344 enable_disable = 1;
22349 /* Construct the API message */
22350 M (DNS_ENABLE_DISABLE, mp);
22351 mp->enable = enable_disable;
22355 /* Wait for the reply */
22361 api_dns_resolve_name (vat_main_t * vam)
22363 unformat_input_t *line_input = vam->input;
22364 vl_api_dns_resolve_name_t *mp;
22368 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22370 if (unformat (line_input, "%s", &name))
22376 if (vec_len (name) > 127)
22378 errmsg ("name too long");
22382 /* Construct the API message */
22383 M (DNS_RESOLVE_NAME, mp);
22384 memcpy (mp->name, name, vec_len (name));
22389 /* Wait for the reply */
22395 api_dns_resolve_ip (vat_main_t * vam)
22397 unformat_input_t *line_input = vam->input;
22398 vl_api_dns_resolve_ip_t *mp;
22400 ip4_address_t addr4;
22401 ip6_address_t addr6;
22404 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22406 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
22408 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
22416 errmsg ("missing address");
22420 /* Construct the API message */
22421 M (DNS_RESOLVE_IP, mp);
22422 mp->is_ip6 = is_ip6;
22424 memcpy (mp->address, &addr6, sizeof (addr6));
22426 memcpy (mp->address, &addr4, sizeof (addr4));
22430 /* Wait for the reply */
22436 api_dns_name_server_add_del (vat_main_t * vam)
22438 unformat_input_t *i = vam->input;
22439 vl_api_dns_name_server_add_del_t *mp;
22441 ip6_address_t ip6_server;
22442 ip4_address_t ip4_server;
22447 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22449 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
22451 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
22453 else if (unformat (i, "del"))
22457 clib_warning ("parse error '%U'", format_unformat_error, i);
22462 if (ip4_set && ip6_set)
22464 errmsg ("Only one server address allowed per message");
22467 if ((ip4_set + ip6_set) == 0)
22469 errmsg ("Server address required");
22473 /* Construct the API message */
22474 M (DNS_NAME_SERVER_ADD_DEL, mp);
22478 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
22483 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
22487 mp->is_add = is_add;
22492 /* Wait for a reply, return good/bad news */
22498 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
22500 vat_main_t *vam = &vat_main;
22505 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22506 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22507 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
22508 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
22509 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22510 clib_net_to_host_u32 (mp->action_index), mp->tag);
22515 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22516 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22517 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
22518 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
22519 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22520 clib_net_to_host_u32 (mp->action_index), mp->tag);
22525 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
22528 vat_main_t *vam = &vat_main;
22529 vat_json_node_t *node = NULL;
22530 struct in6_addr ip6;
22531 struct in_addr ip4;
22533 if (VAT_JSON_ARRAY != vam->json_tree.type)
22535 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22536 vat_json_init_array (&vam->json_tree);
22538 node = vat_json_array_add (&vam->json_tree);
22539 vat_json_init_object (node);
22541 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
22542 vat_json_object_add_uint (node, "appns_index",
22543 clib_net_to_host_u32 (mp->appns_index));
22544 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
22545 vat_json_object_add_uint (node, "scope", mp->scope);
22546 vat_json_object_add_uint (node, "action_index",
22547 clib_net_to_host_u32 (mp->action_index));
22548 vat_json_object_add_uint (node, "lcl_port",
22549 clib_net_to_host_u16 (mp->lcl_port));
22550 vat_json_object_add_uint (node, "rmt_port",
22551 clib_net_to_host_u16 (mp->rmt_port));
22552 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
22553 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
22554 vat_json_object_add_string_copy (node, "tag", mp->tag);
22557 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
22558 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
22559 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
22560 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
22564 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
22565 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
22566 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
22567 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
22572 api_session_rule_add_del (vat_main_t * vam)
22574 vl_api_session_rule_add_del_t *mp;
22575 unformat_input_t *i = vam->input;
22576 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
22577 u32 appns_index = 0, scope = 0;
22578 ip4_address_t lcl_ip4, rmt_ip4;
22579 ip6_address_t lcl_ip6, rmt_ip6;
22580 u8 is_ip4 = 1, conn_set = 0;
22581 u8 is_add = 1, *tag = 0;
22584 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22586 if (unformat (i, "del"))
22588 else if (unformat (i, "add"))
22590 else if (unformat (i, "proto tcp"))
22592 else if (unformat (i, "proto udp"))
22594 else if (unformat (i, "appns %d", &appns_index))
22596 else if (unformat (i, "scope %d", &scope))
22598 else if (unformat (i, "tag %_%v%_", &tag))
22602 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
22603 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
22611 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
22612 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
22618 else if (unformat (i, "action %d", &action))
22623 if (proto == ~0 || !conn_set || action == ~0)
22625 errmsg ("transport proto, connection and action must be set");
22631 errmsg ("scope should be 0-3");
22635 M (SESSION_RULE_ADD_DEL, mp);
22637 mp->is_ip4 = is_ip4;
22638 mp->transport_proto = proto;
22639 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
22640 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
22641 mp->lcl_plen = lcl_plen;
22642 mp->rmt_plen = rmt_plen;
22643 mp->action_index = clib_host_to_net_u32 (action);
22644 mp->appns_index = clib_host_to_net_u32 (appns_index);
22646 mp->is_add = is_add;
22649 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
22650 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
22654 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
22655 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
22659 clib_memcpy (mp->tag, tag, vec_len (tag));
22669 api_session_rules_dump (vat_main_t * vam)
22671 vl_api_session_rules_dump_t *mp;
22672 vl_api_control_ping_t *mp_ping;
22675 if (!vam->json_output)
22677 print (vam->ofp, "%=20s", "Session Rules");
22680 M (SESSION_RULES_DUMP, mp);
22684 /* Use a control ping for synchronization */
22685 MPING (CONTROL_PING, mp_ping);
22688 /* Wait for a reply... */
22694 api_ip_container_proxy_add_del (vat_main_t * vam)
22696 vl_api_ip_container_proxy_add_del_t *mp;
22697 unformat_input_t *i = vam->input;
22698 u32 plen = ~0, sw_if_index = ~0;
22705 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22707 if (unformat (i, "del"))
22709 else if (unformat (i, "add"))
22711 if (unformat (i, "%U", unformat_ip4_address, &ip4))
22716 else if (unformat (i, "%U", unformat_ip6_address, &ip6))
22721 else if (unformat (i, "sw_if_index %u", &sw_if_index))
22726 if (sw_if_index == ~0 || plen == ~0)
22728 errmsg ("address and sw_if_index must be set");
22732 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
22734 mp->is_ip4 = is_ip4;
22735 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
22737 mp->is_add = is_add;
22739 clib_memcpy (mp->ip, &ip4, sizeof (ip4));
22741 clib_memcpy (mp->ip, &ip6, sizeof (ip6));
22749 api_qos_record_enable_disable (vat_main_t * vam)
22751 unformat_input_t *i = vam->input;
22752 vl_api_qos_record_enable_disable_t *mp;
22753 u32 sw_if_index, qs = 0xff;
22754 u8 sw_if_index_set = 0;
22758 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22760 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22761 sw_if_index_set = 1;
22762 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22763 sw_if_index_set = 1;
22764 else if (unformat (i, "%U", unformat_qos_source, &qs))
22766 else if (unformat (i, "disable"))
22770 clib_warning ("parse error '%U'", format_unformat_error, i);
22775 if (sw_if_index_set == 0)
22777 errmsg ("missing interface name or sw_if_index");
22782 errmsg ("input location must be specified");
22786 M (QOS_RECORD_ENABLE_DISABLE, mp);
22788 mp->sw_if_index = ntohl (sw_if_index);
22789 mp->input_source = qs;
22790 mp->enable = enable;
22799 q_or_quit (vat_main_t * vam)
22801 #if VPP_API_TEST_BUILTIN == 0
22802 longjmp (vam->jump_buf, 1);
22804 return 0; /* not so much */
22808 q (vat_main_t * vam)
22810 return q_or_quit (vam);
22814 quit (vat_main_t * vam)
22816 return q_or_quit (vam);
22820 comment (vat_main_t * vam)
22826 statseg (vat_main_t * vam)
22828 ssvm_private_t *ssvmp = &vam->stat_segment;
22829 ssvm_shared_header_t *shared_header = ssvmp->sh;
22830 vlib_counter_t **counters;
22831 u64 thread0_index1_packets;
22832 u64 thread0_index1_bytes;
22833 f64 vector_rate, input_rate;
22836 uword *counter_vector_by_name;
22837 if (vam->stat_segment_lockp == 0)
22839 errmsg ("Stat segment not mapped...");
22843 /* look up "/if/rx for sw_if_index 1 as a test */
22845 clib_spinlock_lock (vam->stat_segment_lockp);
22847 counter_vector_by_name = (uword *) shared_header->opaque[1];
22849 p = hash_get_mem (counter_vector_by_name, "/if/rx");
22852 clib_spinlock_unlock (vam->stat_segment_lockp);
22853 errmsg ("/if/tx not found?");
22857 /* Fish per-thread vector of combined counters from shared memory */
22858 counters = (vlib_counter_t **) p[0];
22860 if (vec_len (counters[0]) < 2)
22862 clib_spinlock_unlock (vam->stat_segment_lockp);
22863 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
22867 /* Read thread 0 sw_if_index 1 counter */
22868 thread0_index1_packets = counters[0][1].packets;
22869 thread0_index1_bytes = counters[0][1].bytes;
22871 p = hash_get_mem (counter_vector_by_name, "vector_rate");
22874 clib_spinlock_unlock (vam->stat_segment_lockp);
22875 errmsg ("vector_rate not found?");
22879 vector_rate = *(f64 *) (p[0]);
22880 p = hash_get_mem (counter_vector_by_name, "input_rate");
22883 clib_spinlock_unlock (vam->stat_segment_lockp);
22884 errmsg ("input_rate not found?");
22887 input_rate = *(f64 *) (p[0]);
22889 clib_spinlock_unlock (vam->stat_segment_lockp);
22891 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
22892 vector_rate, input_rate);
22893 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
22894 thread0_index1_packets, thread0_index1_bytes);
22900 cmd_cmp (void *a1, void *a2)
22905 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
22909 help (vat_main_t * vam)
22914 unformat_input_t *i = vam->input;
22917 if (unformat (i, "%s", &name))
22921 vec_add1 (name, 0);
22923 hs = hash_get_mem (vam->help_by_name, name);
22925 print (vam->ofp, "usage: %s %s", name, hs[0]);
22927 print (vam->ofp, "No such msg / command '%s'", name);
22932 print (vam->ofp, "Help is available for the following:");
22935 hash_foreach_pair (p, vam->function_by_name,
22937 vec_add1 (cmds, (u8 *)(p->key));
22941 vec_sort_with_function (cmds, cmd_cmp);
22943 for (j = 0; j < vec_len (cmds); j++)
22944 print (vam->ofp, "%s", cmds[j]);
22951 set (vat_main_t * vam)
22953 u8 *name = 0, *value = 0;
22954 unformat_input_t *i = vam->input;
22956 if (unformat (i, "%s", &name))
22958 /* The input buffer is a vector, not a string. */
22959 value = vec_dup (i->buffer);
22960 vec_delete (value, i->index, 0);
22961 /* Almost certainly has a trailing newline */
22962 if (value[vec_len (value) - 1] == '\n')
22963 value[vec_len (value) - 1] = 0;
22964 /* Make sure it's a proper string, one way or the other */
22965 vec_add1 (value, 0);
22966 (void) clib_macro_set_value (&vam->macro_main,
22967 (char *) name, (char *) value);
22970 errmsg ("usage: set <name> <value>");
22978 unset (vat_main_t * vam)
22982 if (unformat (vam->input, "%s", &name))
22983 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
22984 errmsg ("unset: %s wasn't set", name);
22997 macro_sort_cmp (void *a1, void *a2)
22999 macro_sort_t *s1 = a1;
23000 macro_sort_t *s2 = a2;
23002 return strcmp ((char *) (s1->name), (char *) (s2->name));
23006 dump_macro_table (vat_main_t * vam)
23008 macro_sort_t *sort_me = 0, *sm;
23013 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
23015 vec_add2 (sort_me, sm, 1);
23016 sm->name = (u8 *)(p->key);
23017 sm->value = (u8 *) (p->value[0]);
23021 vec_sort_with_function (sort_me, macro_sort_cmp);
23023 if (vec_len (sort_me))
23024 print (vam->ofp, "%-15s%s", "Name", "Value");
23026 print (vam->ofp, "The macro table is empty...");
23028 for (i = 0; i < vec_len (sort_me); i++)
23029 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
23034 dump_node_table (vat_main_t * vam)
23037 vlib_node_t *node, *next_node;
23039 if (vec_len (vam->graph_nodes) == 0)
23041 print (vam->ofp, "Node table empty, issue get_node_graph...");
23045 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
23047 node = vam->graph_nodes[0][i];
23048 print (vam->ofp, "[%d] %s", i, node->name);
23049 for (j = 0; j < vec_len (node->next_nodes); j++)
23051 if (node->next_nodes[j] != ~0)
23053 next_node = vam->graph_nodes[0][node->next_nodes[j]];
23054 print (vam->ofp, " [%d] %s", j, next_node->name);
23062 value_sort_cmp (void *a1, void *a2)
23064 name_sort_t *n1 = a1;
23065 name_sort_t *n2 = a2;
23067 if (n1->value < n2->value)
23069 if (n1->value > n2->value)
23076 dump_msg_api_table (vat_main_t * vam)
23078 api_main_t *am = &api_main;
23079 name_sort_t *nses = 0, *ns;
23084 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
23086 vec_add2 (nses, ns, 1);
23087 ns->name = (u8 *)(hp->key);
23088 ns->value = (u32) hp->value[0];
23092 vec_sort_with_function (nses, value_sort_cmp);
23094 for (i = 0; i < vec_len (nses); i++)
23095 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
23101 get_msg_id (vat_main_t * vam)
23106 if (unformat (vam->input, "%s", &name_and_crc))
23108 message_index = vl_msg_api_get_msg_index (name_and_crc);
23109 if (message_index == ~0)
23111 print (vam->ofp, " '%s' not found", name_and_crc);
23114 print (vam->ofp, " '%s' has message index %d",
23115 name_and_crc, message_index);
23118 errmsg ("name_and_crc required...");
23123 search_node_table (vat_main_t * vam)
23125 unformat_input_t *line_input = vam->input;
23128 vlib_node_t *node, *next_node;
23131 if (vam->graph_node_index_by_name == 0)
23133 print (vam->ofp, "Node table empty, issue get_node_graph...");
23137 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
23139 if (unformat (line_input, "%s", &node_to_find))
23141 vec_add1 (node_to_find, 0);
23142 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
23145 print (vam->ofp, "%s not found...", node_to_find);
23148 node = vam->graph_nodes[0][p[0]];
23149 print (vam->ofp, "[%d] %s", p[0], node->name);
23150 for (j = 0; j < vec_len (node->next_nodes); j++)
23152 if (node->next_nodes[j] != ~0)
23154 next_node = vam->graph_nodes[0][node->next_nodes[j]];
23155 print (vam->ofp, " [%d] %s", j, next_node->name);
23162 clib_warning ("parse error '%U'", format_unformat_error,
23168 vec_free (node_to_find);
23177 script (vat_main_t * vam)
23179 #if (VPP_API_TEST_BUILTIN==0)
23181 char *save_current_file;
23182 unformat_input_t save_input;
23183 jmp_buf save_jump_buf;
23184 u32 save_line_number;
23186 FILE *new_fp, *save_ifp;
23188 if (unformat (vam->input, "%s", &s))
23190 new_fp = fopen ((char *) s, "r");
23193 errmsg ("Couldn't open script file %s", s);
23200 errmsg ("Missing script name");
23204 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
23205 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
23206 save_ifp = vam->ifp;
23207 save_line_number = vam->input_line_number;
23208 save_current_file = (char *) vam->current_file;
23210 vam->input_line_number = 0;
23212 vam->current_file = s;
23215 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
23216 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
23217 vam->ifp = save_ifp;
23218 vam->input_line_number = save_line_number;
23219 vam->current_file = (u8 *) save_current_file;
23224 clib_warning ("use the exec command...");
23230 echo (vat_main_t * vam)
23232 print (vam->ofp, "%v", vam->input->buffer);
23236 /* List of API message constructors, CLI names map to api_xxx */
23237 #define foreach_vpe_api_msg \
23238 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
23239 _(sw_interface_dump,"") \
23240 _(sw_interface_set_flags, \
23241 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
23242 _(sw_interface_add_del_address, \
23243 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
23244 _(sw_interface_set_rx_mode, \
23245 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
23246 _(sw_interface_set_table, \
23247 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
23248 _(sw_interface_set_mpls_enable, \
23249 "<intfc> | sw_if_index [disable | dis]") \
23250 _(sw_interface_set_vpath, \
23251 "<intfc> | sw_if_index <id> enable | disable") \
23252 _(sw_interface_set_vxlan_bypass, \
23253 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23254 _(sw_interface_set_geneve_bypass, \
23255 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23256 _(sw_interface_set_l2_xconnect, \
23257 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23258 "enable | disable") \
23259 _(sw_interface_set_l2_bridge, \
23260 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
23261 "[shg <split-horizon-group>] [bvi]\n" \
23262 "enable | disable") \
23263 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
23264 _(bridge_domain_add_del, \
23265 "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") \
23266 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
23268 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
23269 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
23270 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
23272 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23274 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23276 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
23278 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
23280 "<vpp-if-name> | sw_if_index <id>") \
23281 _(sw_interface_tap_dump, "") \
23283 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>]") \
23285 "<vpp-if-name> | sw_if_index <id>") \
23286 _(sw_interface_tap_v2_dump, "") \
23288 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
23289 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]}") \
23291 "<vpp-if-name> | sw_if_index <id>") \
23293 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
23294 _(bond_detach_slave, \
23295 "sw_if_index <n>") \
23296 _(sw_interface_bond_dump, "") \
23297 _(sw_interface_slave_dump, \
23298 "<vpp-if-name> | sw_if_index <id>") \
23299 _(ip_table_add_del, \
23300 "table-id <n> [ipv6]\n") \
23301 _(ip_add_del_route, \
23302 "<addr>/<mask> via <addr> [table-id <n>]\n" \
23303 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
23304 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
23305 "[multipath] [count <n>]") \
23306 _(ip_mroute_add_del, \
23307 "<src> <grp>/<mask> [table-id <n>]\n" \
23308 "[<intfc> | sw_if_index <id>] [local] [del]") \
23309 _(mpls_table_add_del, \
23310 "table-id <n>\n") \
23311 _(mpls_route_add_del, \
23312 "<label> <eos> via <addr> [table-id <n>]\n" \
23313 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
23314 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
23315 "[multipath] [count <n>]") \
23316 _(mpls_ip_bind_unbind, \
23317 "<label> <addr/len>") \
23318 _(mpls_tunnel_add_del, \
23319 " via <addr> [table-id <n>]\n" \
23320 "sw_if_index <id>] [l2] [del]") \
23321 _(bier_table_add_del, \
23322 "<label> <sub-domain> <set> <bsl> [del]") \
23323 _(bier_route_add_del, \
23324 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
23325 "[<intfc> | sw_if_index <id>]" \
23326 "[weight <n>] [del] [multipath]") \
23327 _(proxy_arp_add_del, \
23328 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
23329 _(proxy_arp_intfc_enable_disable, \
23330 "<intfc> | sw_if_index <id> enable | disable") \
23331 _(sw_interface_set_unnumbered, \
23332 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
23333 _(ip_neighbor_add_del, \
23334 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
23335 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
23336 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
23337 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
23338 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
23339 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
23340 "[outer_vlan_id_any][inner_vlan_id_any]") \
23341 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
23342 _(reset_fib, "vrf <n> [ipv6]") \
23343 _(dhcp_proxy_config, \
23344 "svr <v46-address> src <v46-address>\n" \
23345 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
23346 _(dhcp_proxy_set_vss, \
23347 "tbl_id <n> [fib_id <n> oui <n> | vpn_ascii_id <text>] [ipv6] [del]") \
23348 _(dhcp_proxy_dump, "ip6") \
23349 _(dhcp_client_config, \
23350 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
23351 _(set_ip_flow_hash, \
23352 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
23353 _(sw_interface_ip6_enable_disable, \
23354 "<intfc> | sw_if_index <id> enable | disable") \
23355 _(sw_interface_ip6_set_link_local_address, \
23356 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
23357 _(ip6nd_proxy_add_del, \
23358 "<intfc> | sw_if_index <id> <ip6-address>") \
23359 _(ip6nd_proxy_dump, "") \
23360 _(sw_interface_ip6nd_ra_prefix, \
23361 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
23362 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
23363 "[nolink] [isno]") \
23364 _(sw_interface_ip6nd_ra_config, \
23365 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
23366 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
23367 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
23368 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
23369 _(l2_patch_add_del, \
23370 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23371 "enable | disable") \
23372 _(sr_localsid_add_del, \
23373 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
23374 "fib-table <num> (end.psp) sw_if_index <num>") \
23375 _(classify_add_del_table, \
23376 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
23377 " [del] [del-chain] mask <mask-value>\n" \
23378 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
23379 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
23380 _(classify_add_del_session, \
23381 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
23382 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
23383 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
23384 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
23385 _(classify_set_interface_ip_table, \
23386 "<intfc> | sw_if_index <nn> table <nn>") \
23387 _(classify_set_interface_l2_tables, \
23388 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23389 " [other-table <nn>]") \
23390 _(get_node_index, "node <node-name") \
23391 _(add_node_next, "node <node-name> next <next-node-name>") \
23392 _(l2tpv3_create_tunnel, \
23393 "client_address <ip6-addr> our_address <ip6-addr>\n" \
23394 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
23395 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
23396 _(l2tpv3_set_tunnel_cookies, \
23397 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
23398 "[new_remote_cookie <nn>]\n") \
23399 _(l2tpv3_interface_enable_disable, \
23400 "<intfc> | sw_if_index <nn> enable | disable") \
23401 _(l2tpv3_set_lookup_key, \
23402 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
23403 _(sw_if_l2tpv3_tunnel_dump, "") \
23404 _(vxlan_offload_rx, \
23405 "hw { <interface name> | hw_if_index <nn>} " \
23406 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
23407 _(vxlan_add_del_tunnel, \
23408 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23409 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
23410 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23411 _(geneve_add_del_tunnel, \
23412 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23413 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23414 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23415 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23416 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23417 _(gre_add_del_tunnel, \
23418 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
23419 "[teb | erspan <session-id>] [del]") \
23420 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23421 _(l2_fib_clear_table, "") \
23422 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
23423 _(l2_interface_vlan_tag_rewrite, \
23424 "<intfc> | sw_if_index <nn> \n" \
23425 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
23426 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
23427 _(create_vhost_user_if, \
23428 "socket <filename> [server] [renumber <dev_instance>] " \
23429 "[mac <mac_address>]") \
23430 _(modify_vhost_user_if, \
23431 "<intfc> | sw_if_index <nn> socket <filename>\n" \
23432 "[server] [renumber <dev_instance>]") \
23433 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
23434 _(sw_interface_vhost_user_dump, "") \
23435 _(show_version, "") \
23436 _(vxlan_gpe_add_del_tunnel, \
23437 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
23438 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23439 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
23440 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
23441 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23442 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
23443 _(interface_name_renumber, \
23444 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
23445 _(input_acl_set_interface, \
23446 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23447 " [l2-table <nn>] [del]") \
23448 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
23449 _(ip_scan_neighbor_enable_disable, "[ip4|ip6|both|disable] [interval <n-min>]\n" \
23450 " [max-time <n-usec>] [max-update <n>] [delay <n-msec>] [stale <n-min>]") \
23451 _(want_ip4_arp_events, "address <ip4-address> [del]") \
23452 _(want_ip6_nd_events, "address <ip6-address> [del]") \
23453 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
23454 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
23455 _(ip_dump, "ipv4 | ipv6") \
23456 _(ipsec_spd_add_del, "spd_id <n> [del]") \
23457 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
23459 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
23460 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
23461 " integ_alg <alg> integ_key <hex>") \
23462 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
23463 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
23464 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
23465 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
23466 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
23467 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
23468 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
23469 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
23470 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
23471 " [instance <n>]") \
23472 _(ipsec_sa_dump, "[sa_id <n>]") \
23473 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
23474 " <alg> <hex>\n") \
23475 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
23476 _(ikev2_profile_add_del, "name <profile_name> [del]") \
23477 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
23478 "(auth_data 0x<data> | auth_data <data>)") \
23479 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
23480 "(id_data 0x<data> | id_data <data>) (local|remote)") \
23481 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
23482 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
23483 "(local|remote)") \
23484 _(ikev2_set_local_key, "file <absolute_file_path>") \
23485 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
23486 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23487 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23488 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
23489 _(ikev2_initiate_sa_init, "<profile_name>") \
23490 _(ikev2_initiate_del_ike_sa, "<ispi>") \
23491 _(ikev2_initiate_del_child_sa, "<ispi>") \
23492 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
23493 _(delete_loopback,"sw_if_index <nn>") \
23494 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
23495 _(bd_ip_mac_dump, "[bd_id] <id>") \
23496 _(want_interface_events, "enable|disable") \
23497 _(want_stats,"enable|disable") \
23498 _(get_first_msg_id, "client <name>") \
23499 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
23500 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
23501 "fib-id <nn> [ip4][ip6][default]") \
23502 _(get_node_graph, " ") \
23503 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
23504 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
23505 _(ioam_disable, "") \
23506 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
23507 " sw_if_index <sw_if_index> p <priority> " \
23508 "w <weight>] [del]") \
23509 _(one_add_del_locator, "locator-set <locator_name> " \
23510 "iface <intf> | sw_if_index <sw_if_index> " \
23511 "p <priority> w <weight> [del]") \
23512 _(one_add_del_local_eid,"vni <vni> eid " \
23513 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23514 "locator-set <locator_name> [del]" \
23515 "[key-id sha1|sha256 secret-key <secret-key>]")\
23516 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
23517 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
23518 _(one_enable_disable, "enable|disable") \
23519 _(one_map_register_enable_disable, "enable|disable") \
23520 _(one_map_register_fallback_threshold, "<value>") \
23521 _(one_rloc_probe_enable_disable, "enable|disable") \
23522 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23524 "rloc <locator> p <prio> " \
23525 "w <weight> [rloc <loc> ... ] " \
23526 "action <action> [del-all]") \
23527 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23529 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23530 _(one_use_petr, "ip-address> | disable") \
23531 _(one_map_request_mode, "src-dst|dst-only") \
23532 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23533 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23534 _(one_locator_set_dump, "[local | remote]") \
23535 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
23536 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23537 "[local] | [remote]") \
23538 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
23539 _(one_ndp_bd_get, "") \
23540 _(one_ndp_entries_get, "bd <bridge-domain>") \
23541 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
23542 _(one_l2_arp_bd_get, "") \
23543 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
23544 _(one_stats_enable_disable, "enable|disalbe") \
23545 _(show_one_stats_enable_disable, "") \
23546 _(one_eid_table_vni_dump, "") \
23547 _(one_eid_table_map_dump, "l2|l3") \
23548 _(one_map_resolver_dump, "") \
23549 _(one_map_server_dump, "") \
23550 _(one_adjacencies_get, "vni <vni>") \
23551 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
23552 _(show_one_rloc_probe_state, "") \
23553 _(show_one_map_register_state, "") \
23554 _(show_one_status, "") \
23555 _(one_stats_dump, "") \
23556 _(one_stats_flush, "") \
23557 _(one_get_map_request_itr_rlocs, "") \
23558 _(one_map_register_set_ttl, "<ttl>") \
23559 _(one_set_transport_protocol, "udp|api") \
23560 _(one_get_transport_protocol, "") \
23561 _(one_enable_disable_xtr_mode, "enable|disable") \
23562 _(one_show_xtr_mode, "") \
23563 _(one_enable_disable_pitr_mode, "enable|disable") \
23564 _(one_show_pitr_mode, "") \
23565 _(one_enable_disable_petr_mode, "enable|disable") \
23566 _(one_show_petr_mode, "") \
23567 _(show_one_nsh_mapping, "") \
23568 _(show_one_pitr, "") \
23569 _(show_one_use_petr, "") \
23570 _(show_one_map_request_mode, "") \
23571 _(show_one_map_register_ttl, "") \
23572 _(show_one_map_register_fallback_threshold, "") \
23573 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
23574 " sw_if_index <sw_if_index> p <priority> " \
23575 "w <weight>] [del]") \
23576 _(lisp_add_del_locator, "locator-set <locator_name> " \
23577 "iface <intf> | sw_if_index <sw_if_index> " \
23578 "p <priority> w <weight> [del]") \
23579 _(lisp_add_del_local_eid,"vni <vni> eid " \
23580 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23581 "locator-set <locator_name> [del]" \
23582 "[key-id sha1|sha256 secret-key <secret-key>]") \
23583 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
23584 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
23585 _(lisp_enable_disable, "enable|disable") \
23586 _(lisp_map_register_enable_disable, "enable|disable") \
23587 _(lisp_rloc_probe_enable_disable, "enable|disable") \
23588 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23590 "rloc <locator> p <prio> " \
23591 "w <weight> [rloc <loc> ... ] " \
23592 "action <action> [del-all]") \
23593 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23595 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23596 _(lisp_use_petr, "<ip-address> | disable") \
23597 _(lisp_map_request_mode, "src-dst|dst-only") \
23598 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23599 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23600 _(lisp_locator_set_dump, "[local | remote]") \
23601 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
23602 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23603 "[local] | [remote]") \
23604 _(lisp_eid_table_vni_dump, "") \
23605 _(lisp_eid_table_map_dump, "l2|l3") \
23606 _(lisp_map_resolver_dump, "") \
23607 _(lisp_map_server_dump, "") \
23608 _(lisp_adjacencies_get, "vni <vni>") \
23609 _(gpe_fwd_entry_vnis_get, "") \
23610 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
23611 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
23612 "[table <table-id>]") \
23613 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
23614 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
23615 _(gpe_set_encap_mode, "lisp|vxlan") \
23616 _(gpe_get_encap_mode, "") \
23617 _(lisp_gpe_add_del_iface, "up|down") \
23618 _(lisp_gpe_enable_disable, "enable|disable") \
23619 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
23620 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
23621 _(show_lisp_rloc_probe_state, "") \
23622 _(show_lisp_map_register_state, "") \
23623 _(show_lisp_status, "") \
23624 _(lisp_get_map_request_itr_rlocs, "") \
23625 _(show_lisp_pitr, "") \
23626 _(show_lisp_use_petr, "") \
23627 _(show_lisp_map_request_mode, "") \
23628 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
23629 _(af_packet_delete, "name <host interface name>") \
23630 _(af_packet_dump, "") \
23631 _(policer_add_del, "name <policer name> <params> [del]") \
23632 _(policer_dump, "[name <policer name>]") \
23633 _(policer_classify_set_interface, \
23634 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23635 " [l2-table <nn>] [del]") \
23636 _(policer_classify_dump, "type [ip4|ip6|l2]") \
23637 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
23638 "[master|slave]") \
23639 _(netmap_delete, "name <interface name>") \
23640 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
23641 _(mpls_fib_dump, "") \
23642 _(classify_table_ids, "") \
23643 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
23644 _(classify_table_info, "table_id <nn>") \
23645 _(classify_session_dump, "table_id <nn>") \
23646 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
23647 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
23648 "[template_interval <nn>] [udp_checksum]") \
23649 _(ipfix_exporter_dump, "") \
23650 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
23651 _(ipfix_classify_stream_dump, "") \
23652 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
23653 _(ipfix_classify_table_dump, "") \
23654 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
23655 _(sw_interface_span_dump, "[l2]") \
23656 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
23657 _(pg_create_interface, "if_id <nn>") \
23658 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
23659 _(pg_enable_disable, "[stream <id>] disable") \
23660 _(ip_source_and_port_range_check_add_del, \
23661 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
23662 _(ip_source_and_port_range_check_interface_add_del, \
23663 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
23664 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
23665 _(ipsec_gre_add_del_tunnel, \
23666 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
23667 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
23668 _(delete_subif,"<intfc> | sw_if_index <nn>") \
23669 _(l2_interface_pbb_tag_rewrite, \
23670 "<intfc> | sw_if_index <nn> \n" \
23671 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
23672 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
23673 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
23674 _(flow_classify_set_interface, \
23675 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
23676 _(flow_classify_dump, "type [ip4|ip6]") \
23677 _(ip_fib_dump, "") \
23678 _(ip_mfib_dump, "") \
23679 _(ip6_fib_dump, "") \
23680 _(ip6_mfib_dump, "") \
23681 _(feature_enable_disable, "arc_name <arc_name> " \
23682 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
23683 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
23685 _(l2_xconnect_dump, "") \
23686 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
23687 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
23688 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
23689 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
23690 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
23691 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
23692 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
23693 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
23694 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
23695 _(sock_init_shm, "size <nnn>") \
23696 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
23697 _(dns_enable_disable, "[enable][disable]") \
23698 _(dns_name_server_add_del, "<ip-address> [del]") \
23699 _(dns_resolve_name, "<hostname>") \
23700 _(dns_resolve_ip, "<ip4|ip6>") \
23701 _(dns_name_server_add_del, "<ip-address> [del]") \
23702 _(dns_resolve_name, "<hostname>") \
23703 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
23704 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
23705 _(session_rules_dump, "") \
23706 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
23707 _(output_acl_set_interface, \
23708 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23709 " [l2-table <nn>] [del]") \
23710 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
23712 /* List of command functions, CLI names map directly to functions */
23713 #define foreach_cli_function \
23714 _(comment, "usage: comment <ignore-rest-of-line>") \
23715 _(dump_interface_table, "usage: dump_interface_table") \
23716 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
23717 _(dump_ipv4_table, "usage: dump_ipv4_table") \
23718 _(dump_ipv6_table, "usage: dump_ipv6_table") \
23719 _(dump_stats_table, "usage: dump_stats_table") \
23720 _(dump_macro_table, "usage: dump_macro_table ") \
23721 _(dump_node_table, "usage: dump_node_table") \
23722 _(dump_msg_api_table, "usage: dump_msg_api_table") \
23723 _(get_msg_id, "usage: get_msg_id name_and_crc") \
23724 _(echo, "usage: echo <message>") \
23725 _(exec, "usage: exec <vpe-debug-CLI-command>") \
23726 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
23727 _(help, "usage: help") \
23728 _(q, "usage: quit") \
23729 _(quit, "usage: quit") \
23730 _(search_node_table, "usage: search_node_table <name>...") \
23731 _(set, "usage: set <variable-name> <value>") \
23732 _(script, "usage: script <file-name>") \
23733 _(statseg, "usage: statseg"); \
23734 _(unset, "usage: unset <variable-name>")
23737 static void vl_api_##n##_t_handler_uni \
23738 (vl_api_##n##_t * mp) \
23740 vat_main_t * vam = &vat_main; \
23741 if (vam->json_output) { \
23742 vl_api_##n##_t_handler_json(mp); \
23744 vl_api_##n##_t_handler(mp); \
23747 foreach_vpe_api_reply_msg;
23748 #if VPP_API_TEST_BUILTIN == 0
23749 foreach_standalone_reply_msg;
23754 vat_api_hookup (vat_main_t * vam)
23757 vl_msg_api_set_handlers(VL_API_##N, #n, \
23758 vl_api_##n##_t_handler_uni, \
23760 vl_api_##n##_t_endian, \
23761 vl_api_##n##_t_print, \
23762 sizeof(vl_api_##n##_t), 1);
23763 foreach_vpe_api_reply_msg;
23764 #if VPP_API_TEST_BUILTIN == 0
23765 foreach_standalone_reply_msg;
23769 #if (VPP_API_TEST_BUILTIN==0)
23770 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
23772 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
23774 vam->function_by_name = hash_create_string (0, sizeof (uword));
23776 vam->help_by_name = hash_create_string (0, sizeof (uword));
23779 /* API messages we can send */
23780 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
23781 foreach_vpe_api_msg;
23785 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
23786 foreach_vpe_api_msg;
23789 /* CLI functions */
23790 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
23791 foreach_cli_function;
23795 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
23796 foreach_cli_function;
23800 #if VPP_API_TEST_BUILTIN
23801 static clib_error_t *
23802 vat_api_hookup_shim (vlib_main_t * vm)
23804 vat_api_hookup (&vat_main);
23808 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
23812 * fd.io coding-style-patch-verification: ON
23815 * eval: (c-set-style "gnu")