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_rx_placement_reply) \
5353 _(sw_interface_set_table_reply) \
5354 _(sw_interface_set_mpls_enable_reply) \
5355 _(sw_interface_set_vpath_reply) \
5356 _(sw_interface_set_vxlan_bypass_reply) \
5357 _(sw_interface_set_geneve_bypass_reply) \
5358 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5359 _(sw_interface_set_l2_bridge_reply) \
5360 _(bridge_domain_add_del_reply) \
5361 _(sw_interface_set_l2_xconnect_reply) \
5362 _(l2fib_add_del_reply) \
5363 _(l2fib_flush_int_reply) \
5364 _(l2fib_flush_bd_reply) \
5365 _(ip_add_del_route_reply) \
5366 _(ip_table_add_del_reply) \
5367 _(ip_mroute_add_del_reply) \
5368 _(mpls_route_add_del_reply) \
5369 _(mpls_table_add_del_reply) \
5370 _(mpls_ip_bind_unbind_reply) \
5371 _(bier_route_add_del_reply) \
5372 _(bier_table_add_del_reply) \
5373 _(proxy_arp_add_del_reply) \
5374 _(proxy_arp_intfc_enable_disable_reply) \
5375 _(sw_interface_set_unnumbered_reply) \
5376 _(ip_neighbor_add_del_reply) \
5377 _(oam_add_del_reply) \
5378 _(reset_fib_reply) \
5379 _(dhcp_proxy_config_reply) \
5380 _(dhcp_proxy_set_vss_reply) \
5381 _(dhcp_client_config_reply) \
5382 _(set_ip_flow_hash_reply) \
5383 _(sw_interface_ip6_enable_disable_reply) \
5384 _(sw_interface_ip6_set_link_local_address_reply) \
5385 _(ip6nd_proxy_add_del_reply) \
5386 _(sw_interface_ip6nd_ra_prefix_reply) \
5387 _(sw_interface_ip6nd_ra_config_reply) \
5388 _(set_arp_neighbor_limit_reply) \
5389 _(l2_patch_add_del_reply) \
5390 _(sr_policy_add_reply) \
5391 _(sr_policy_mod_reply) \
5392 _(sr_policy_del_reply) \
5393 _(sr_localsid_add_del_reply) \
5394 _(sr_steering_add_del_reply) \
5395 _(classify_add_del_session_reply) \
5396 _(classify_set_interface_ip_table_reply) \
5397 _(classify_set_interface_l2_tables_reply) \
5398 _(l2tpv3_set_tunnel_cookies_reply) \
5399 _(l2tpv3_interface_enable_disable_reply) \
5400 _(l2tpv3_set_lookup_key_reply) \
5401 _(l2_fib_clear_table_reply) \
5402 _(l2_interface_efp_filter_reply) \
5403 _(l2_interface_vlan_tag_rewrite_reply) \
5404 _(modify_vhost_user_if_reply) \
5405 _(delete_vhost_user_if_reply) \
5406 _(ip_probe_neighbor_reply) \
5407 _(ip_scan_neighbor_enable_disable_reply) \
5408 _(want_ip4_arp_events_reply) \
5409 _(want_ip6_nd_events_reply) \
5410 _(want_l2_macs_events_reply) \
5411 _(input_acl_set_interface_reply) \
5412 _(ipsec_spd_add_del_reply) \
5413 _(ipsec_interface_add_del_spd_reply) \
5414 _(ipsec_spd_add_del_entry_reply) \
5415 _(ipsec_sad_add_del_entry_reply) \
5416 _(ipsec_sa_set_key_reply) \
5417 _(ipsec_tunnel_if_add_del_reply) \
5418 _(ipsec_tunnel_if_set_key_reply) \
5419 _(ipsec_tunnel_if_set_sa_reply) \
5420 _(ikev2_profile_add_del_reply) \
5421 _(ikev2_profile_set_auth_reply) \
5422 _(ikev2_profile_set_id_reply) \
5423 _(ikev2_profile_set_ts_reply) \
5424 _(ikev2_set_local_key_reply) \
5425 _(ikev2_set_responder_reply) \
5426 _(ikev2_set_ike_transforms_reply) \
5427 _(ikev2_set_esp_transforms_reply) \
5428 _(ikev2_set_sa_lifetime_reply) \
5429 _(ikev2_initiate_sa_init_reply) \
5430 _(ikev2_initiate_del_ike_sa_reply) \
5431 _(ikev2_initiate_del_child_sa_reply) \
5432 _(ikev2_initiate_rekey_child_sa_reply) \
5433 _(delete_loopback_reply) \
5434 _(bd_ip_mac_add_del_reply) \
5435 _(want_interface_events_reply) \
5436 _(want_stats_reply) \
5437 _(cop_interface_enable_disable_reply) \
5438 _(cop_whitelist_enable_disable_reply) \
5439 _(sw_interface_clear_stats_reply) \
5440 _(ioam_enable_reply) \
5441 _(ioam_disable_reply) \
5442 _(one_add_del_locator_reply) \
5443 _(one_add_del_local_eid_reply) \
5444 _(one_add_del_remote_mapping_reply) \
5445 _(one_add_del_adjacency_reply) \
5446 _(one_add_del_map_resolver_reply) \
5447 _(one_add_del_map_server_reply) \
5448 _(one_enable_disable_reply) \
5449 _(one_rloc_probe_enable_disable_reply) \
5450 _(one_map_register_enable_disable_reply) \
5451 _(one_map_register_set_ttl_reply) \
5452 _(one_set_transport_protocol_reply) \
5453 _(one_map_register_fallback_threshold_reply) \
5454 _(one_pitr_set_locator_set_reply) \
5455 _(one_map_request_mode_reply) \
5456 _(one_add_del_map_request_itr_rlocs_reply) \
5457 _(one_eid_table_add_del_map_reply) \
5458 _(one_use_petr_reply) \
5459 _(one_stats_enable_disable_reply) \
5460 _(one_add_del_l2_arp_entry_reply) \
5461 _(one_add_del_ndp_entry_reply) \
5462 _(one_stats_flush_reply) \
5463 _(one_enable_disable_xtr_mode_reply) \
5464 _(one_enable_disable_pitr_mode_reply) \
5465 _(one_enable_disable_petr_mode_reply) \
5466 _(gpe_enable_disable_reply) \
5467 _(gpe_set_encap_mode_reply) \
5468 _(gpe_add_del_iface_reply) \
5469 _(gpe_add_del_native_fwd_rpath_reply) \
5470 _(af_packet_delete_reply) \
5471 _(policer_classify_set_interface_reply) \
5472 _(netmap_create_reply) \
5473 _(netmap_delete_reply) \
5474 _(set_ipfix_exporter_reply) \
5475 _(set_ipfix_classify_stream_reply) \
5476 _(ipfix_classify_table_add_del_reply) \
5477 _(flow_classify_set_interface_reply) \
5478 _(sw_interface_span_enable_disable_reply) \
5479 _(pg_capture_reply) \
5480 _(pg_enable_disable_reply) \
5481 _(ip_source_and_port_range_check_add_del_reply) \
5482 _(ip_source_and_port_range_check_interface_add_del_reply)\
5483 _(delete_subif_reply) \
5484 _(l2_interface_pbb_tag_rewrite_reply) \
5486 _(feature_enable_disable_reply) \
5487 _(sw_interface_tag_add_del_reply) \
5488 _(hw_interface_set_mtu_reply) \
5489 _(p2p_ethernet_add_reply) \
5490 _(p2p_ethernet_del_reply) \
5491 _(lldp_config_reply) \
5492 _(sw_interface_set_lldp_reply) \
5493 _(tcp_configure_src_addresses_reply) \
5494 _(dns_enable_disable_reply) \
5495 _(dns_name_server_add_del_reply) \
5496 _(session_rule_add_del_reply) \
5497 _(ip_container_proxy_add_del_reply) \
5498 _(output_acl_set_interface_reply) \
5499 _(qos_record_enable_disable_reply)
5502 static void vl_api_##n##_t_handler \
5503 (vl_api_##n##_t * mp) \
5505 vat_main_t * vam = &vat_main; \
5506 i32 retval = ntohl(mp->retval); \
5507 if (vam->async_mode) { \
5508 vam->async_errors += (retval < 0); \
5510 vam->retval = retval; \
5511 vam->result_ready = 1; \
5514 foreach_standard_reply_retval_handler;
5518 static void vl_api_##n##_t_handler_json \
5519 (vl_api_##n##_t * mp) \
5521 vat_main_t * vam = &vat_main; \
5522 vat_json_node_t node; \
5523 vat_json_init_object(&node); \
5524 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5525 vat_json_print(vam->ofp, &node); \
5526 vam->retval = ntohl(mp->retval); \
5527 vam->result_ready = 1; \
5529 foreach_standard_reply_retval_handler;
5533 * Table of message reply handlers, must include boilerplate handlers
5537 #define foreach_vpe_api_reply_msg \
5538 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5539 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5540 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5541 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5542 _(CONTROL_PING_REPLY, control_ping_reply) \
5543 _(CLI_REPLY, cli_reply) \
5544 _(CLI_INBAND_REPLY, cli_inband_reply) \
5545 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5546 sw_interface_add_del_address_reply) \
5547 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5548 _(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
5549 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5550 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5551 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5552 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5553 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5554 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5555 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5556 sw_interface_set_l2_xconnect_reply) \
5557 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5558 sw_interface_set_l2_bridge_reply) \
5559 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5560 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5561 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5562 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5563 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5564 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5565 _(L2_FLAGS_REPLY, l2_flags_reply) \
5566 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5567 _(TAP_CONNECT_REPLY, tap_connect_reply) \
5568 _(TAP_MODIFY_REPLY, tap_modify_reply) \
5569 _(TAP_DELETE_REPLY, tap_delete_reply) \
5570 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
5571 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5572 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5573 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5574 _(BOND_CREATE_REPLY, bond_create_reply) \
5575 _(BOND_DELETE_REPLY, bond_delete_reply) \
5576 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5577 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5578 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5579 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5580 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5581 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5582 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5583 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5584 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5585 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5586 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5587 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5588 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5589 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5590 proxy_arp_intfc_enable_disable_reply) \
5591 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5592 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5593 sw_interface_set_unnumbered_reply) \
5594 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5595 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5596 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5597 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5598 _(RESET_FIB_REPLY, reset_fib_reply) \
5599 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5600 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5601 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5602 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5603 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5604 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5605 sw_interface_ip6_enable_disable_reply) \
5606 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
5607 sw_interface_ip6_set_link_local_address_reply) \
5608 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5609 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5610 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5611 sw_interface_ip6nd_ra_prefix_reply) \
5612 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5613 sw_interface_ip6nd_ra_config_reply) \
5614 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5615 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5616 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5617 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5618 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5619 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5620 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5621 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5622 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5623 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5624 classify_set_interface_ip_table_reply) \
5625 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5626 classify_set_interface_l2_tables_reply) \
5627 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5628 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5629 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5630 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5631 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5632 l2tpv3_interface_enable_disable_reply) \
5633 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5634 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5635 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5636 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5637 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5638 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5639 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5640 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5641 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5642 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5643 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5644 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5645 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5646 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5647 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5648 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5649 _(SHOW_VERSION_REPLY, show_version_reply) \
5650 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5651 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5652 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5653 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5654 _(IP_PROBE_NEIGHBOR_REPLY, ip_probe_neighbor_reply) \
5655 _(IP_SCAN_NEIGHBOR_ENABLE_DISABLE_REPLY, ip_scan_neighbor_enable_disable_reply) \
5656 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5657 _(IP4_ARP_EVENT, ip4_arp_event) \
5658 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5659 _(IP6_ND_EVENT, ip6_nd_event) \
5660 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5661 _(L2_MACS_EVENT, l2_macs_event) \
5662 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5663 _(IP_ADDRESS_DETAILS, ip_address_details) \
5664 _(IP_DETAILS, ip_details) \
5665 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5666 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5667 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
5668 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
5669 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5670 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5671 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5672 _(IPSEC_TUNNEL_IF_SET_KEY_REPLY, ipsec_tunnel_if_set_key_reply) \
5673 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5674 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
5675 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
5676 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
5677 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
5678 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
5679 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
5680 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
5681 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
5682 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
5683 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
5684 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
5685 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
5686 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
5687 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5688 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5689 _(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
5690 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5691 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5692 _(WANT_STATS_REPLY, want_stats_reply) \
5693 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5694 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5695 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5696 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5697 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5698 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5699 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5700 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5701 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5702 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5703 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5704 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5705 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5706 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5707 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5708 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5709 one_map_register_enable_disable_reply) \
5710 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5711 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5712 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5713 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5714 one_map_register_fallback_threshold_reply) \
5715 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5716 one_rloc_probe_enable_disable_reply) \
5717 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5718 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5719 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5720 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5721 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5722 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5723 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5724 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5725 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5726 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5727 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5728 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5729 _(ONE_STATS_DETAILS, one_stats_details) \
5730 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5731 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5732 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5733 show_one_stats_enable_disable_reply) \
5734 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5735 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5736 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5737 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5738 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5739 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5740 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5741 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5742 one_enable_disable_pitr_mode_reply) \
5743 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5744 one_enable_disable_petr_mode_reply) \
5745 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5746 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5747 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5748 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5749 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5750 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5751 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5752 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5753 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5754 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5755 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5756 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5757 gpe_add_del_native_fwd_rpath_reply) \
5758 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5759 gpe_fwd_entry_path_details) \
5760 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5761 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5762 one_add_del_map_request_itr_rlocs_reply) \
5763 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5764 one_get_map_request_itr_rlocs_reply) \
5765 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5766 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5767 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5768 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5769 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5770 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5771 show_one_map_register_state_reply) \
5772 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5773 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5774 show_one_map_register_fallback_threshold_reply) \
5775 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5776 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5777 _(AF_PACKET_DETAILS, af_packet_details) \
5778 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5779 _(POLICER_DETAILS, policer_details) \
5780 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5781 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5782 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5783 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5784 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5785 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5786 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5787 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5788 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5789 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5790 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5791 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5792 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5793 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5794 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5795 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5796 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5797 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5798 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5799 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5800 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5801 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5802 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5803 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5804 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5805 ip_source_and_port_range_check_add_del_reply) \
5806 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5807 ip_source_and_port_range_check_interface_add_del_reply) \
5808 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5809 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5810 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5811 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5812 _(PUNT_REPLY, punt_reply) \
5813 _(IP_FIB_DETAILS, ip_fib_details) \
5814 _(IP6_FIB_DETAILS, ip6_fib_details) \
5815 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5816 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5817 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5818 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5819 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5820 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5821 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5822 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5823 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5824 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5825 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5826 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5827 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5828 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5829 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
5830 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \
5831 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5832 _(SESSION_RULES_DETAILS, session_rules_details) \
5833 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5834 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5835 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply)
5837 #define foreach_standalone_reply_msg \
5838 _(SW_INTERFACE_EVENT, sw_interface_event) \
5839 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
5840 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
5841 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
5842 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
5843 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
5844 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters)
5852 #define STR_VTR_OP_CASE(op) \
5853 case L2_VTR_ ## op: \
5857 str_vtr_op (u32 vtr_op)
5861 STR_VTR_OP_CASE (DISABLED);
5862 STR_VTR_OP_CASE (PUSH_1);
5863 STR_VTR_OP_CASE (PUSH_2);
5864 STR_VTR_OP_CASE (POP_1);
5865 STR_VTR_OP_CASE (POP_2);
5866 STR_VTR_OP_CASE (TRANSLATE_1_1);
5867 STR_VTR_OP_CASE (TRANSLATE_1_2);
5868 STR_VTR_OP_CASE (TRANSLATE_2_1);
5869 STR_VTR_OP_CASE (TRANSLATE_2_2);
5876 dump_sub_interface_table (vat_main_t * vam)
5878 const sw_interface_subif_t *sub = NULL;
5880 if (vam->json_output)
5883 ("JSON output supported only for VPE API calls and dump_stats_table");
5888 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5889 "Interface", "sw_if_index",
5890 "sub id", "dot1ad", "tags", "outer id",
5891 "inner id", "exact", "default", "outer any", "inner any");
5893 vec_foreach (sub, vam->sw_if_subif_table)
5896 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5897 sub->interface_name,
5899 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5900 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5901 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5902 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5903 if (sub->vtr_op != L2_VTR_DISABLED)
5906 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5907 "tag1: %d tag2: %d ]",
5908 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5909 sub->vtr_tag1, sub->vtr_tag2);
5917 name_sort_cmp (void *a1, void *a2)
5919 name_sort_t *n1 = a1;
5920 name_sort_t *n2 = a2;
5922 return strcmp ((char *) n1->name, (char *) n2->name);
5926 dump_interface_table (vat_main_t * vam)
5929 name_sort_t *nses = 0, *ns;
5931 if (vam->json_output)
5934 ("JSON output supported only for VPE API calls and dump_stats_table");
5939 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5941 vec_add2 (nses, ns, 1);
5942 ns->name = (u8 *)(p->key);
5943 ns->value = (u32) p->value[0];
5947 vec_sort_with_function (nses, name_sort_cmp);
5949 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5950 vec_foreach (ns, nses)
5952 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5959 dump_ip_table (vat_main_t * vam, int is_ipv6)
5961 const ip_details_t *det = NULL;
5962 const ip_address_details_t *address = NULL;
5965 print (vam->ofp, "%-12s", "sw_if_index");
5967 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5974 print (vam->ofp, "%-12d", i);
5975 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5980 vec_foreach (address, det->addr)
5984 is_ipv6 ? format_ip6_address : format_ip4_address,
5985 address->ip, address->prefix_length);
5993 dump_ipv4_table (vat_main_t * vam)
5995 if (vam->json_output)
5998 ("JSON output supported only for VPE API calls and dump_stats_table");
6002 return dump_ip_table (vam, 0);
6006 dump_ipv6_table (vat_main_t * vam)
6008 if (vam->json_output)
6011 ("JSON output supported only for VPE API calls and dump_stats_table");
6015 return dump_ip_table (vam, 1);
6019 counter_type_to_str (u8 counter_type, u8 is_combined)
6023 switch (counter_type)
6025 case VNET_INTERFACE_COUNTER_DROP:
6027 case VNET_INTERFACE_COUNTER_PUNT:
6029 case VNET_INTERFACE_COUNTER_IP4:
6031 case VNET_INTERFACE_COUNTER_IP6:
6033 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
6035 case VNET_INTERFACE_COUNTER_RX_MISS:
6037 case VNET_INTERFACE_COUNTER_RX_ERROR:
6039 case VNET_INTERFACE_COUNTER_TX_ERROR:
6042 return "INVALID-COUNTER-TYPE";
6047 switch (counter_type)
6049 case VNET_INTERFACE_COUNTER_RX:
6051 case VNET_INTERFACE_COUNTER_TX:
6054 return "INVALID-COUNTER-TYPE";
6060 dump_stats_table (vat_main_t * vam)
6062 vat_json_node_t node;
6063 vat_json_node_t *msg_array;
6064 vat_json_node_t *msg;
6065 vat_json_node_t *counter_array;
6066 vat_json_node_t *counter;
6067 interface_counter_t c;
6069 ip4_fib_counter_t *c4;
6070 ip6_fib_counter_t *c6;
6071 ip4_nbr_counter_t *n4;
6072 ip6_nbr_counter_t *n6;
6075 if (!vam->json_output)
6077 clib_warning ("dump_stats_table supported only in JSON format");
6081 vat_json_init_object (&node);
6083 /* interface counters */
6084 msg_array = vat_json_object_add (&node, "interface_counters");
6085 vat_json_init_array (msg_array);
6086 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
6088 msg = vat_json_array_add (msg_array);
6089 vat_json_init_object (msg);
6090 vat_json_object_add_string_copy (msg, "vnet_counter_type",
6091 (u8 *) counter_type_to_str (i, 0));
6092 vat_json_object_add_int (msg, "is_combined", 0);
6093 counter_array = vat_json_object_add (msg, "data");
6094 vat_json_init_array (counter_array);
6095 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
6097 packets = vam->simple_interface_counters[i][j];
6098 vat_json_array_add_uint (counter_array, packets);
6101 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
6103 msg = vat_json_array_add (msg_array);
6104 vat_json_init_object (msg);
6105 vat_json_object_add_string_copy (msg, "vnet_counter_type",
6106 (u8 *) counter_type_to_str (i, 1));
6107 vat_json_object_add_int (msg, "is_combined", 1);
6108 counter_array = vat_json_object_add (msg, "data");
6109 vat_json_init_array (counter_array);
6110 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
6112 c = vam->combined_interface_counters[i][j];
6113 counter = vat_json_array_add (counter_array);
6114 vat_json_init_object (counter);
6115 vat_json_object_add_uint (counter, "packets", c.packets);
6116 vat_json_object_add_uint (counter, "bytes", c.bytes);
6120 /* ip4 fib counters */
6121 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
6122 vat_json_init_array (msg_array);
6123 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
6125 msg = vat_json_array_add (msg_array);
6126 vat_json_init_object (msg);
6127 vat_json_object_add_uint (msg, "vrf_id",
6128 vam->ip4_fib_counters_vrf_id_by_index[i]);
6129 counter_array = vat_json_object_add (msg, "c");
6130 vat_json_init_array (counter_array);
6131 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
6133 counter = vat_json_array_add (counter_array);
6134 vat_json_init_object (counter);
6135 c4 = &vam->ip4_fib_counters[i][j];
6136 vat_json_object_add_ip4 (counter, "address", c4->address);
6137 vat_json_object_add_uint (counter, "address_length",
6138 c4->address_length);
6139 vat_json_object_add_uint (counter, "packets", c4->packets);
6140 vat_json_object_add_uint (counter, "bytes", c4->bytes);
6144 /* ip6 fib counters */
6145 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
6146 vat_json_init_array (msg_array);
6147 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
6149 msg = vat_json_array_add (msg_array);
6150 vat_json_init_object (msg);
6151 vat_json_object_add_uint (msg, "vrf_id",
6152 vam->ip6_fib_counters_vrf_id_by_index[i]);
6153 counter_array = vat_json_object_add (msg, "c");
6154 vat_json_init_array (counter_array);
6155 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
6157 counter = vat_json_array_add (counter_array);
6158 vat_json_init_object (counter);
6159 c6 = &vam->ip6_fib_counters[i][j];
6160 vat_json_object_add_ip6 (counter, "address", c6->address);
6161 vat_json_object_add_uint (counter, "address_length",
6162 c6->address_length);
6163 vat_json_object_add_uint (counter, "packets", c6->packets);
6164 vat_json_object_add_uint (counter, "bytes", c6->bytes);
6168 /* ip4 nbr counters */
6169 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
6170 vat_json_init_array (msg_array);
6171 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
6173 msg = vat_json_array_add (msg_array);
6174 vat_json_init_object (msg);
6175 vat_json_object_add_uint (msg, "sw_if_index", i);
6176 counter_array = vat_json_object_add (msg, "c");
6177 vat_json_init_array (counter_array);
6178 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
6180 counter = vat_json_array_add (counter_array);
6181 vat_json_init_object (counter);
6182 n4 = &vam->ip4_nbr_counters[i][j];
6183 vat_json_object_add_ip4 (counter, "address", n4->address);
6184 vat_json_object_add_uint (counter, "link-type", n4->linkt);
6185 vat_json_object_add_uint (counter, "packets", n4->packets);
6186 vat_json_object_add_uint (counter, "bytes", n4->bytes);
6190 /* ip6 nbr counters */
6191 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
6192 vat_json_init_array (msg_array);
6193 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
6195 msg = vat_json_array_add (msg_array);
6196 vat_json_init_object (msg);
6197 vat_json_object_add_uint (msg, "sw_if_index", i);
6198 counter_array = vat_json_object_add (msg, "c");
6199 vat_json_init_array (counter_array);
6200 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
6202 counter = vat_json_array_add (counter_array);
6203 vat_json_init_object (counter);
6204 n6 = &vam->ip6_nbr_counters[i][j];
6205 vat_json_object_add_ip6 (counter, "address", n6->address);
6206 vat_json_object_add_uint (counter, "packets", n6->packets);
6207 vat_json_object_add_uint (counter, "bytes", n6->bytes);
6211 vat_json_print (vam->ofp, &node);
6212 vat_json_free (&node);
6218 * Pass CLI buffers directly in the CLI_INBAND API message,
6219 * instead of an additional shared memory area.
6222 exec_inband (vat_main_t * vam)
6224 vl_api_cli_inband_t *mp;
6225 unformat_input_t *i = vam->input;
6228 if (vec_len (i->buffer) == 0)
6231 if (vam->exec_mode == 0 && unformat (i, "mode"))
6236 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
6243 * In order for the CLI command to work, it
6244 * must be a vector ending in \n, not a C-string ending
6247 u32 len = vec_len (vam->input->buffer);
6248 M2 (CLI_INBAND, mp, len);
6249 clib_memcpy (mp->cmd, vam->input->buffer, len);
6250 mp->length = htonl (len);
6254 /* json responses may or may not include a useful reply... */
6255 if (vec_len (vam->cmd_reply))
6256 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
6261 exec (vat_main_t * vam)
6263 return exec_inband (vam);
6267 api_create_loopback (vat_main_t * vam)
6269 unformat_input_t *i = vam->input;
6270 vl_api_create_loopback_t *mp;
6271 vl_api_create_loopback_instance_t *mp_lbi;
6274 u8 is_specified = 0;
6275 u32 user_instance = 0;
6278 memset (mac_address, 0, sizeof (mac_address));
6280 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6282 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6284 if (unformat (i, "instance %d", &user_instance))
6292 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
6293 mp_lbi->is_specified = is_specified;
6295 mp_lbi->user_instance = htonl (user_instance);
6297 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
6302 /* Construct the API message */
6303 M (CREATE_LOOPBACK, mp);
6305 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
6314 api_delete_loopback (vat_main_t * vam)
6316 unformat_input_t *i = vam->input;
6317 vl_api_delete_loopback_t *mp;
6318 u32 sw_if_index = ~0;
6321 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6323 if (unformat (i, "sw_if_index %d", &sw_if_index))
6329 if (sw_if_index == ~0)
6331 errmsg ("missing sw_if_index");
6335 /* Construct the API message */
6336 M (DELETE_LOOPBACK, mp);
6337 mp->sw_if_index = ntohl (sw_if_index);
6345 api_want_stats (vat_main_t * vam)
6347 unformat_input_t *i = vam->input;
6348 vl_api_want_stats_t *mp;
6352 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6354 if (unformat (i, "enable"))
6356 else if (unformat (i, "disable"))
6364 errmsg ("missing enable|disable");
6369 mp->enable_disable = enable;
6377 api_want_interface_events (vat_main_t * vam)
6379 unformat_input_t *i = vam->input;
6380 vl_api_want_interface_events_t *mp;
6384 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6386 if (unformat (i, "enable"))
6388 else if (unformat (i, "disable"))
6396 errmsg ("missing enable|disable");
6400 M (WANT_INTERFACE_EVENTS, mp);
6401 mp->enable_disable = enable;
6403 vam->interface_event_display = enable;
6411 /* Note: non-static, called once to set up the initial intfc table */
6413 api_sw_interface_dump (vat_main_t * vam)
6415 vl_api_sw_interface_dump_t *mp;
6416 vl_api_control_ping_t *mp_ping;
6418 name_sort_t *nses = 0, *ns;
6419 sw_interface_subif_t *sub = NULL;
6422 /* Toss the old name table */
6424 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6426 vec_add2 (nses, ns, 1);
6427 ns->name = (u8 *)(p->key);
6428 ns->value = (u32) p->value[0];
6432 hash_free (vam->sw_if_index_by_interface_name);
6434 vec_foreach (ns, nses) vec_free (ns->name);
6438 vec_foreach (sub, vam->sw_if_subif_table)
6440 vec_free (sub->interface_name);
6442 vec_free (vam->sw_if_subif_table);
6444 /* recreate the interface name hash table */
6445 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
6448 * Ask for all interface names. Otherwise, the epic catalog of
6449 * name filters becomes ridiculously long, and vat ends up needing
6450 * to be taught about new interface types.
6452 M (SW_INTERFACE_DUMP, mp);
6455 /* Use a control ping for synchronization */
6456 MPING (CONTROL_PING, mp_ping);
6464 api_sw_interface_set_flags (vat_main_t * vam)
6466 unformat_input_t *i = vam->input;
6467 vl_api_sw_interface_set_flags_t *mp;
6469 u8 sw_if_index_set = 0;
6473 /* Parse args required to build the message */
6474 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6476 if (unformat (i, "admin-up"))
6478 else if (unformat (i, "admin-down"))
6481 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6482 sw_if_index_set = 1;
6483 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6484 sw_if_index_set = 1;
6489 if (sw_if_index_set == 0)
6491 errmsg ("missing interface name or sw_if_index");
6495 /* Construct the API message */
6496 M (SW_INTERFACE_SET_FLAGS, mp);
6497 mp->sw_if_index = ntohl (sw_if_index);
6498 mp->admin_up_down = admin_up;
6503 /* Wait for a reply, return the good/bad news... */
6509 api_sw_interface_set_rx_mode (vat_main_t * vam)
6511 unformat_input_t *i = vam->input;
6512 vl_api_sw_interface_set_rx_mode_t *mp;
6514 u8 sw_if_index_set = 0;
6516 u8 queue_id_valid = 0;
6518 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
6520 /* Parse args required to build the message */
6521 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6523 if (unformat (i, "queue %d", &queue_id))
6525 else if (unformat (i, "polling"))
6526 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
6527 else if (unformat (i, "interrupt"))
6528 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
6529 else if (unformat (i, "adaptive"))
6530 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
6532 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6533 sw_if_index_set = 1;
6534 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6535 sw_if_index_set = 1;
6540 if (sw_if_index_set == 0)
6542 errmsg ("missing interface name or sw_if_index");
6545 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6547 errmsg ("missing rx-mode");
6551 /* Construct the API message */
6552 M (SW_INTERFACE_SET_RX_MODE, mp);
6553 mp->sw_if_index = ntohl (sw_if_index);
6555 mp->queue_id_valid = queue_id_valid;
6556 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6561 /* Wait for a reply, return the good/bad news... */
6567 api_sw_interface_set_rx_placement (vat_main_t * vam)
6569 unformat_input_t *i = vam->input;
6570 vl_api_sw_interface_set_rx_placement_t *mp;
6572 u8 sw_if_index_set = 0;
6575 u32 queue_id, thread_index;
6577 /* Parse args required to build the message */
6578 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6580 if (unformat (i, "queue %d", &queue_id))
6582 else if (unformat (i, "main"))
6584 else if (unformat (i, "worker %d", &thread_index))
6587 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6588 sw_if_index_set = 1;
6589 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6590 sw_if_index_set = 1;
6595 if (sw_if_index_set == 0)
6597 errmsg ("missing interface name or sw_if_index");
6603 /* Construct the API message */
6604 M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
6605 mp->sw_if_index = ntohl (sw_if_index);
6606 mp->worker_id = ntohl (thread_index);
6607 mp->queue_id = ntohl (queue_id);
6608 mp->is_main = is_main;
6612 /* Wait for a reply, return the good/bad news... */
6618 api_sw_interface_clear_stats (vat_main_t * vam)
6620 unformat_input_t *i = vam->input;
6621 vl_api_sw_interface_clear_stats_t *mp;
6623 u8 sw_if_index_set = 0;
6626 /* Parse args required to build the message */
6627 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6629 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6630 sw_if_index_set = 1;
6631 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6632 sw_if_index_set = 1;
6637 /* Construct the API message */
6638 M (SW_INTERFACE_CLEAR_STATS, mp);
6640 if (sw_if_index_set == 1)
6641 mp->sw_if_index = ntohl (sw_if_index);
6643 mp->sw_if_index = ~0;
6648 /* Wait for a reply, return the good/bad news... */
6654 api_sw_interface_add_del_address (vat_main_t * vam)
6656 unformat_input_t *i = vam->input;
6657 vl_api_sw_interface_add_del_address_t *mp;
6659 u8 sw_if_index_set = 0;
6660 u8 is_add = 1, del_all = 0;
6661 u32 address_length = 0;
6662 u8 v4_address_set = 0;
6663 u8 v6_address_set = 0;
6664 ip4_address_t v4address;
6665 ip6_address_t v6address;
6668 /* Parse args required to build the message */
6669 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6671 if (unformat (i, "del-all"))
6673 else if (unformat (i, "del"))
6676 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6677 sw_if_index_set = 1;
6678 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6679 sw_if_index_set = 1;
6680 else if (unformat (i, "%U/%d",
6681 unformat_ip4_address, &v4address, &address_length))
6683 else if (unformat (i, "%U/%d",
6684 unformat_ip6_address, &v6address, &address_length))
6690 if (sw_if_index_set == 0)
6692 errmsg ("missing interface name or sw_if_index");
6695 if (v4_address_set && v6_address_set)
6697 errmsg ("both v4 and v6 addresses set");
6700 if (!v4_address_set && !v6_address_set && !del_all)
6702 errmsg ("no addresses set");
6706 /* Construct the API message */
6707 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6709 mp->sw_if_index = ntohl (sw_if_index);
6710 mp->is_add = is_add;
6711 mp->del_all = del_all;
6715 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6719 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6721 mp->address_length = address_length;
6726 /* Wait for a reply, return good/bad news */
6732 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6734 unformat_input_t *i = vam->input;
6735 vl_api_sw_interface_set_mpls_enable_t *mp;
6737 u8 sw_if_index_set = 0;
6741 /* Parse args required to build the message */
6742 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6744 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6745 sw_if_index_set = 1;
6746 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6747 sw_if_index_set = 1;
6748 else if (unformat (i, "disable"))
6750 else if (unformat (i, "dis"))
6756 if (sw_if_index_set == 0)
6758 errmsg ("missing interface name or sw_if_index");
6762 /* Construct the API message */
6763 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6765 mp->sw_if_index = ntohl (sw_if_index);
6766 mp->enable = enable;
6771 /* Wait for a reply... */
6777 api_sw_interface_set_table (vat_main_t * vam)
6779 unformat_input_t *i = vam->input;
6780 vl_api_sw_interface_set_table_t *mp;
6781 u32 sw_if_index, vrf_id = 0;
6782 u8 sw_if_index_set = 0;
6786 /* Parse args required to build the message */
6787 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6789 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6790 sw_if_index_set = 1;
6791 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6792 sw_if_index_set = 1;
6793 else if (unformat (i, "vrf %d", &vrf_id))
6795 else if (unformat (i, "ipv6"))
6801 if (sw_if_index_set == 0)
6803 errmsg ("missing interface name or sw_if_index");
6807 /* Construct the API message */
6808 M (SW_INTERFACE_SET_TABLE, mp);
6810 mp->sw_if_index = ntohl (sw_if_index);
6811 mp->is_ipv6 = is_ipv6;
6812 mp->vrf_id = ntohl (vrf_id);
6817 /* Wait for a reply... */
6822 static void vl_api_sw_interface_get_table_reply_t_handler
6823 (vl_api_sw_interface_get_table_reply_t * mp)
6825 vat_main_t *vam = &vat_main;
6827 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6829 vam->retval = ntohl (mp->retval);
6830 vam->result_ready = 1;
6834 static void vl_api_sw_interface_get_table_reply_t_handler_json
6835 (vl_api_sw_interface_get_table_reply_t * mp)
6837 vat_main_t *vam = &vat_main;
6838 vat_json_node_t node;
6840 vat_json_init_object (&node);
6841 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6842 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6844 vat_json_print (vam->ofp, &node);
6845 vat_json_free (&node);
6847 vam->retval = ntohl (mp->retval);
6848 vam->result_ready = 1;
6852 api_sw_interface_get_table (vat_main_t * vam)
6854 unformat_input_t *i = vam->input;
6855 vl_api_sw_interface_get_table_t *mp;
6857 u8 sw_if_index_set = 0;
6861 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6863 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6864 sw_if_index_set = 1;
6865 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6866 sw_if_index_set = 1;
6867 else if (unformat (i, "ipv6"))
6873 if (sw_if_index_set == 0)
6875 errmsg ("missing interface name or sw_if_index");
6879 M (SW_INTERFACE_GET_TABLE, mp);
6880 mp->sw_if_index = htonl (sw_if_index);
6881 mp->is_ipv6 = is_ipv6;
6889 api_sw_interface_set_vpath (vat_main_t * vam)
6891 unformat_input_t *i = vam->input;
6892 vl_api_sw_interface_set_vpath_t *mp;
6893 u32 sw_if_index = 0;
6894 u8 sw_if_index_set = 0;
6898 /* Parse args required to build the message */
6899 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6901 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6902 sw_if_index_set = 1;
6903 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6904 sw_if_index_set = 1;
6905 else if (unformat (i, "enable"))
6907 else if (unformat (i, "disable"))
6913 if (sw_if_index_set == 0)
6915 errmsg ("missing interface name or sw_if_index");
6919 /* Construct the API message */
6920 M (SW_INTERFACE_SET_VPATH, mp);
6922 mp->sw_if_index = ntohl (sw_if_index);
6923 mp->enable = is_enable;
6928 /* Wait for a reply... */
6934 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6936 unformat_input_t *i = vam->input;
6937 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6938 u32 sw_if_index = 0;
6939 u8 sw_if_index_set = 0;
6944 /* Parse args required to build the message */
6945 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6947 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6948 sw_if_index_set = 1;
6949 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6950 sw_if_index_set = 1;
6951 else if (unformat (i, "enable"))
6953 else if (unformat (i, "disable"))
6955 else if (unformat (i, "ip4"))
6957 else if (unformat (i, "ip6"))
6963 if (sw_if_index_set == 0)
6965 errmsg ("missing interface name or sw_if_index");
6969 /* Construct the API message */
6970 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6972 mp->sw_if_index = ntohl (sw_if_index);
6973 mp->enable = is_enable;
6974 mp->is_ipv6 = is_ipv6;
6979 /* Wait for a reply... */
6985 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6987 unformat_input_t *i = vam->input;
6988 vl_api_sw_interface_set_geneve_bypass_t *mp;
6989 u32 sw_if_index = 0;
6990 u8 sw_if_index_set = 0;
6995 /* Parse args required to build the message */
6996 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6998 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6999 sw_if_index_set = 1;
7000 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7001 sw_if_index_set = 1;
7002 else if (unformat (i, "enable"))
7004 else if (unformat (i, "disable"))
7006 else if (unformat (i, "ip4"))
7008 else if (unformat (i, "ip6"))
7014 if (sw_if_index_set == 0)
7016 errmsg ("missing interface name or sw_if_index");
7020 /* Construct the API message */
7021 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
7023 mp->sw_if_index = ntohl (sw_if_index);
7024 mp->enable = is_enable;
7025 mp->is_ipv6 = is_ipv6;
7030 /* Wait for a reply... */
7036 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
7038 unformat_input_t *i = vam->input;
7039 vl_api_sw_interface_set_l2_xconnect_t *mp;
7041 u8 rx_sw_if_index_set = 0;
7043 u8 tx_sw_if_index_set = 0;
7047 /* Parse args required to build the message */
7048 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7050 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
7051 rx_sw_if_index_set = 1;
7052 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
7053 tx_sw_if_index_set = 1;
7054 else if (unformat (i, "rx"))
7056 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7058 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7060 rx_sw_if_index_set = 1;
7065 else if (unformat (i, "tx"))
7067 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7069 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7071 tx_sw_if_index_set = 1;
7076 else if (unformat (i, "enable"))
7078 else if (unformat (i, "disable"))
7084 if (rx_sw_if_index_set == 0)
7086 errmsg ("missing rx interface name or rx_sw_if_index");
7090 if (enable && (tx_sw_if_index_set == 0))
7092 errmsg ("missing tx interface name or tx_sw_if_index");
7096 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
7098 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7099 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
7100 mp->enable = enable;
7108 api_sw_interface_set_l2_bridge (vat_main_t * vam)
7110 unformat_input_t *i = vam->input;
7111 vl_api_sw_interface_set_l2_bridge_t *mp;
7113 u8 rx_sw_if_index_set = 0;
7121 /* Parse args required to build the message */
7122 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7124 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
7125 rx_sw_if_index_set = 1;
7126 else if (unformat (i, "bd_id %d", &bd_id))
7130 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
7131 rx_sw_if_index_set = 1;
7132 else if (unformat (i, "shg %d", &shg))
7134 else if (unformat (i, "bvi"))
7136 else if (unformat (i, "enable"))
7138 else if (unformat (i, "disable"))
7144 if (rx_sw_if_index_set == 0)
7146 errmsg ("missing rx interface name or sw_if_index");
7150 if (enable && (bd_id_set == 0))
7152 errmsg ("missing bridge domain");
7156 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
7158 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7159 mp->bd_id = ntohl (bd_id);
7162 mp->enable = enable;
7170 api_bridge_domain_dump (vat_main_t * vam)
7172 unformat_input_t *i = vam->input;
7173 vl_api_bridge_domain_dump_t *mp;
7174 vl_api_control_ping_t *mp_ping;
7178 /* Parse args required to build the message */
7179 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7181 if (unformat (i, "bd_id %d", &bd_id))
7187 M (BRIDGE_DOMAIN_DUMP, mp);
7188 mp->bd_id = ntohl (bd_id);
7191 /* Use a control ping for synchronization */
7192 MPING (CONTROL_PING, mp_ping);
7200 api_bridge_domain_add_del (vat_main_t * vam)
7202 unformat_input_t *i = vam->input;
7203 vl_api_bridge_domain_add_del_t *mp;
7206 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
7211 /* Parse args required to build the message */
7212 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7214 if (unformat (i, "bd_id %d", &bd_id))
7216 else if (unformat (i, "flood %d", &flood))
7218 else if (unformat (i, "uu-flood %d", &uu_flood))
7220 else if (unformat (i, "forward %d", &forward))
7222 else if (unformat (i, "learn %d", &learn))
7224 else if (unformat (i, "arp-term %d", &arp_term))
7226 else if (unformat (i, "mac-age %d", &mac_age))
7228 else if (unformat (i, "bd-tag %s", &bd_tag))
7230 else if (unformat (i, "del"))
7233 flood = uu_flood = forward = learn = 0;
7241 errmsg ("missing bridge domain");
7248 errmsg ("mac age must be less than 256 ");
7253 if ((bd_tag) && (vec_len (bd_tag) > 63))
7255 errmsg ("bd-tag cannot be longer than 63");
7260 M (BRIDGE_DOMAIN_ADD_DEL, mp);
7262 mp->bd_id = ntohl (bd_id);
7264 mp->uu_flood = uu_flood;
7265 mp->forward = forward;
7267 mp->arp_term = arp_term;
7268 mp->is_add = is_add;
7269 mp->mac_age = (u8) mac_age;
7272 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
7273 mp->bd_tag[vec_len (bd_tag)] = 0;
7284 api_l2fib_flush_bd (vat_main_t * vam)
7286 unformat_input_t *i = vam->input;
7287 vl_api_l2fib_flush_bd_t *mp;
7291 /* Parse args required to build the message */
7292 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7294 if (unformat (i, "bd_id %d", &bd_id));
7301 errmsg ("missing bridge domain");
7305 M (L2FIB_FLUSH_BD, mp);
7307 mp->bd_id = htonl (bd_id);
7315 api_l2fib_flush_int (vat_main_t * vam)
7317 unformat_input_t *i = vam->input;
7318 vl_api_l2fib_flush_int_t *mp;
7319 u32 sw_if_index = ~0;
7322 /* Parse args required to build the message */
7323 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7325 if (unformat (i, "sw_if_index %d", &sw_if_index));
7327 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
7332 if (sw_if_index == ~0)
7334 errmsg ("missing interface name or sw_if_index");
7338 M (L2FIB_FLUSH_INT, mp);
7340 mp->sw_if_index = ntohl (sw_if_index);
7348 api_l2fib_add_del (vat_main_t * vam)
7350 unformat_input_t *i = vam->input;
7351 vl_api_l2fib_add_del_t *mp;
7357 u32 sw_if_index = 0;
7358 u8 sw_if_index_set = 0;
7367 /* Parse args required to build the message */
7368 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7370 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
7372 else if (unformat (i, "bd_id %d", &bd_id))
7374 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7375 sw_if_index_set = 1;
7376 else if (unformat (i, "sw_if"))
7378 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7381 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7382 sw_if_index_set = 1;
7387 else if (unformat (i, "static"))
7389 else if (unformat (i, "filter"))
7394 else if (unformat (i, "bvi"))
7399 else if (unformat (i, "del"))
7401 else if (unformat (i, "count %d", &count))
7409 errmsg ("missing mac address");
7415 errmsg ("missing bridge domain");
7419 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7421 errmsg ("missing interface name or sw_if_index");
7427 /* Turn on async mode */
7428 vam->async_mode = 1;
7429 vam->async_errors = 0;
7430 before = vat_time_now (vam);
7433 for (j = 0; j < count; j++)
7435 M (L2FIB_ADD_DEL, mp);
7437 clib_memcpy (mp->mac, mac, 6);
7438 mp->bd_id = ntohl (bd_id);
7439 mp->is_add = is_add;
7440 mp->sw_if_index = ntohl (sw_if_index);
7444 mp->static_mac = static_mac;
7445 mp->filter_mac = filter_mac;
7446 mp->bvi_mac = bvi_mac;
7448 increment_mac_address (mac);
7455 vl_api_control_ping_t *mp_ping;
7458 /* Shut off async mode */
7459 vam->async_mode = 0;
7461 MPING (CONTROL_PING, mp_ping);
7464 timeout = vat_time_now (vam) + 1.0;
7465 while (vat_time_now (vam) < timeout)
7466 if (vam->result_ready == 1)
7471 if (vam->retval == -99)
7474 if (vam->async_errors > 0)
7476 errmsg ("%d asynchronous errors", vam->async_errors);
7479 vam->async_errors = 0;
7480 after = vat_time_now (vam);
7482 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7483 count, after - before, count / (after - before));
7489 /* Wait for a reply... */
7493 /* Return the good/bad news */
7494 return (vam->retval);
7498 api_bridge_domain_set_mac_age (vat_main_t * vam)
7500 unformat_input_t *i = vam->input;
7501 vl_api_bridge_domain_set_mac_age_t *mp;
7506 /* Parse args required to build the message */
7507 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7509 if (unformat (i, "bd_id %d", &bd_id));
7510 else if (unformat (i, "mac-age %d", &mac_age));
7517 errmsg ("missing bridge domain");
7523 errmsg ("mac age must be less than 256 ");
7527 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7529 mp->bd_id = htonl (bd_id);
7530 mp->mac_age = (u8) mac_age;
7538 api_l2_flags (vat_main_t * vam)
7540 unformat_input_t *i = vam->input;
7541 vl_api_l2_flags_t *mp;
7544 u8 sw_if_index_set = 0;
7548 /* Parse args required to build the message */
7549 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7551 if (unformat (i, "sw_if_index %d", &sw_if_index))
7552 sw_if_index_set = 1;
7553 else if (unformat (i, "sw_if"))
7555 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7558 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7559 sw_if_index_set = 1;
7564 else if (unformat (i, "learn"))
7566 else if (unformat (i, "forward"))
7568 else if (unformat (i, "flood"))
7570 else if (unformat (i, "uu-flood"))
7571 flags |= L2_UU_FLOOD;
7572 else if (unformat (i, "arp-term"))
7573 flags |= L2_ARP_TERM;
7574 else if (unformat (i, "off"))
7576 else if (unformat (i, "disable"))
7582 if (sw_if_index_set == 0)
7584 errmsg ("missing interface name or sw_if_index");
7590 mp->sw_if_index = ntohl (sw_if_index);
7591 mp->feature_bitmap = ntohl (flags);
7592 mp->is_set = is_set;
7600 api_bridge_flags (vat_main_t * vam)
7602 unformat_input_t *i = vam->input;
7603 vl_api_bridge_flags_t *mp;
7610 /* Parse args required to build the message */
7611 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7613 if (unformat (i, "bd_id %d", &bd_id))
7615 else if (unformat (i, "learn"))
7617 else if (unformat (i, "forward"))
7619 else if (unformat (i, "flood"))
7621 else if (unformat (i, "uu-flood"))
7622 flags |= L2_UU_FLOOD;
7623 else if (unformat (i, "arp-term"))
7624 flags |= L2_ARP_TERM;
7625 else if (unformat (i, "off"))
7627 else if (unformat (i, "disable"))
7635 errmsg ("missing bridge domain");
7639 M (BRIDGE_FLAGS, mp);
7641 mp->bd_id = ntohl (bd_id);
7642 mp->feature_bitmap = ntohl (flags);
7643 mp->is_set = is_set;
7651 api_bd_ip_mac_add_del (vat_main_t * vam)
7653 unformat_input_t *i = vam->input;
7654 vl_api_bd_ip_mac_add_del_t *mp;
7661 ip4_address_t v4addr;
7662 ip6_address_t v6addr;
7667 /* Parse args required to build the message */
7668 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7670 if (unformat (i, "bd_id %d", &bd_id))
7674 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
7678 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
7683 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
7687 else if (unformat (i, "del"))
7695 errmsg ("missing bridge domain");
7698 else if (ip_set == 0)
7700 errmsg ("missing IP address");
7703 else if (mac_set == 0)
7705 errmsg ("missing MAC address");
7709 M (BD_IP_MAC_ADD_DEL, mp);
7711 mp->bd_id = ntohl (bd_id);
7712 mp->is_ipv6 = is_ipv6;
7713 mp->is_add = is_add;
7715 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
7717 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
7718 clib_memcpy (mp->mac_address, macaddr, 6);
7724 static void vl_api_bd_ip_mac_details_t_handler
7725 (vl_api_bd_ip_mac_details_t * mp)
7727 vat_main_t *vam = &vat_main;
7732 format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
7735 format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
7738 "\n%-5d %-7s %-20U %-30s",
7739 ntohl (mp->bd_id), mp->is_ipv6 ? "ip6" : "ip4",
7740 format_ethernet_address, mp->mac_address, ip);
7745 static void vl_api_bd_ip_mac_details_t_handler_json
7746 (vl_api_bd_ip_mac_details_t * mp)
7748 vat_main_t *vam = &vat_main;
7749 vat_json_node_t *node = NULL;
7751 if (VAT_JSON_ARRAY != vam->json_tree.type)
7753 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7754 vat_json_init_array (&vam->json_tree);
7756 node = vat_json_array_add (&vam->json_tree);
7758 vat_json_init_object (node);
7759 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
7760 vat_json_object_add_uint (node, "is_ipv6", ntohl (mp->is_ipv6));
7761 vat_json_object_add_string_copy (node, "mac_address",
7762 format (0, "%U", format_ethernet_address,
7768 format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
7771 format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
7772 vat_json_object_add_string_copy (node, "ip_address", ip);
7777 api_bd_ip_mac_dump (vat_main_t * vam)
7779 unformat_input_t *i = vam->input;
7780 vl_api_bd_ip_mac_dump_t *mp;
7781 vl_api_control_ping_t *mp_ping;
7786 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7788 if (unformat (i, "bd_id %d", &bd_id))
7797 "\n%-5s %-7s %-20s %-30s",
7798 "bd_id", "is_ipv6", "mac_address", "ip_address");
7800 /* Dump Bridge Domain Ip to Mac entries */
7801 M (BD_IP_MAC_DUMP, mp);
7804 mp->bd_id = htonl (bd_id);
7810 /* Use a control ping for synchronization */
7811 MPING (CONTROL_PING, mp_ping);
7819 api_tap_connect (vat_main_t * vam)
7821 unformat_input_t *i = vam->input;
7822 vl_api_tap_connect_t *mp;
7828 ip4_address_t ip4_address;
7830 int ip4_address_set = 0;
7831 ip6_address_t ip6_address;
7833 int ip6_address_set = 0;
7836 memset (mac_address, 0, sizeof (mac_address));
7838 /* Parse args required to build the message */
7839 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7841 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7845 else if (unformat (i, "random-mac"))
7847 else if (unformat (i, "tapname %s", &tap_name))
7849 else if (unformat (i, "tag %s", &tag))
7851 else if (unformat (i, "address %U/%d",
7852 unformat_ip4_address, &ip4_address, &ip4_mask_width))
7853 ip4_address_set = 1;
7854 else if (unformat (i, "address %U/%d",
7855 unformat_ip6_address, &ip6_address, &ip6_mask_width))
7856 ip6_address_set = 1;
7863 errmsg ("missing tap name");
7866 if (vec_len (tap_name) > 63)
7868 errmsg ("tap name too long");
7871 vec_add1 (tap_name, 0);
7873 if (vec_len (tag) > 63)
7875 errmsg ("tag too long");
7879 /* Construct the API message */
7880 M (TAP_CONNECT, mp);
7882 mp->use_random_mac = random_mac;
7883 clib_memcpy (mp->mac_address, mac_address, 6);
7884 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7886 clib_memcpy (mp->tag, tag, vec_len (tag));
7888 if (ip4_address_set)
7890 mp->ip4_address_set = 1;
7891 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
7892 mp->ip4_mask_width = ip4_mask_width;
7894 if (ip6_address_set)
7896 mp->ip6_address_set = 1;
7897 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
7898 mp->ip6_mask_width = ip6_mask_width;
7901 vec_free (tap_name);
7907 /* Wait for a reply... */
7913 api_tap_modify (vat_main_t * vam)
7915 unformat_input_t *i = vam->input;
7916 vl_api_tap_modify_t *mp;
7921 u32 sw_if_index = ~0;
7922 u8 sw_if_index_set = 0;
7925 memset (mac_address, 0, sizeof (mac_address));
7927 /* Parse args required to build the message */
7928 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7930 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7931 sw_if_index_set = 1;
7932 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7933 sw_if_index_set = 1;
7934 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7938 else if (unformat (i, "random-mac"))
7940 else if (unformat (i, "tapname %s", &tap_name))
7946 if (sw_if_index_set == 0)
7948 errmsg ("missing vpp interface name");
7953 errmsg ("missing tap name");
7956 if (vec_len (tap_name) > 63)
7958 errmsg ("tap name too long");
7960 vec_add1 (tap_name, 0);
7962 /* Construct the API message */
7965 mp->use_random_mac = random_mac;
7966 mp->sw_if_index = ntohl (sw_if_index);
7967 clib_memcpy (mp->mac_address, mac_address, 6);
7968 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7969 vec_free (tap_name);
7974 /* Wait for a reply... */
7980 api_tap_delete (vat_main_t * vam)
7982 unformat_input_t *i = vam->input;
7983 vl_api_tap_delete_t *mp;
7984 u32 sw_if_index = ~0;
7985 u8 sw_if_index_set = 0;
7988 /* Parse args required to build the message */
7989 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7991 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7992 sw_if_index_set = 1;
7993 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7994 sw_if_index_set = 1;
7999 if (sw_if_index_set == 0)
8001 errmsg ("missing vpp interface name");
8005 /* Construct the API message */
8008 mp->sw_if_index = ntohl (sw_if_index);
8013 /* Wait for a reply... */
8019 api_tap_create_v2 (vat_main_t * vam)
8021 unformat_input_t *i = vam->input;
8022 vl_api_tap_create_v2_t *mp;
8026 u8 *host_if_name = 0;
8028 u8 host_mac_addr[6];
8029 u8 host_mac_addr_set = 0;
8030 u8 *host_bridge = 0;
8031 ip4_address_t host_ip4_addr;
8032 ip4_address_t host_ip4_gw;
8033 u8 host_ip4_gw_set = 0;
8034 u32 host_ip4_prefix_len = 0;
8035 ip6_address_t host_ip6_addr;
8036 ip6_address_t host_ip6_gw;
8037 u8 host_ip6_gw_set = 0;
8038 u32 host_ip6_prefix_len = 0;
8040 u32 rx_ring_sz = 0, tx_ring_sz = 0;
8042 memset (mac_address, 0, sizeof (mac_address));
8044 /* Parse args required to build the message */
8045 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8047 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
8051 else if (unformat (i, "id %u", &id))
8053 else if (unformat (i, "host-if-name %s", &host_if_name))
8055 else if (unformat (i, "host-ns %s", &host_ns))
8057 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
8059 host_mac_addr_set = 1;
8060 else if (unformat (i, "host-bridge %s", &host_bridge))
8062 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
8063 &host_ip4_addr, &host_ip4_prefix_len))
8065 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
8066 &host_ip6_addr, &host_ip6_prefix_len))
8068 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
8070 host_ip4_gw_set = 1;
8071 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
8073 host_ip6_gw_set = 1;
8074 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
8076 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
8082 if (vec_len (host_if_name) > 63)
8084 errmsg ("tap name too long. ");
8087 if (vec_len (host_ns) > 63)
8089 errmsg ("host name space too long. ");
8092 if (vec_len (host_bridge) > 63)
8094 errmsg ("host bridge name too long. ");
8097 if (host_ip4_prefix_len > 32)
8099 errmsg ("host ip4 prefix length not valid. ");
8102 if (host_ip6_prefix_len > 128)
8104 errmsg ("host ip6 prefix length not valid. ");
8107 if (!is_pow2 (rx_ring_sz))
8109 errmsg ("rx ring size must be power of 2. ");
8112 if (rx_ring_sz > 32768)
8114 errmsg ("rx ring size must be 32768 or lower. ");
8117 if (!is_pow2 (tx_ring_sz))
8119 errmsg ("tx ring size must be power of 2. ");
8122 if (tx_ring_sz > 32768)
8124 errmsg ("tx ring size must be 32768 or lower. ");
8128 /* Construct the API message */
8129 M (TAP_CREATE_V2, mp);
8131 mp->use_random_mac = random_mac;
8133 mp->id = ntohl (id);
8134 mp->host_namespace_set = host_ns != 0;
8135 mp->host_bridge_set = host_bridge != 0;
8136 mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
8137 mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
8138 mp->rx_ring_sz = ntohs (rx_ring_sz);
8139 mp->tx_ring_sz = ntohs (tx_ring_sz);
8141 if (random_mac == 0)
8142 clib_memcpy (mp->mac_address, mac_address, 6);
8143 if (host_mac_addr_set)
8144 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
8146 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
8148 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
8150 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
8151 if (host_ip4_prefix_len)
8152 clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
8153 if (host_ip4_prefix_len)
8154 clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
8155 if (host_ip4_gw_set)
8156 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
8157 if (host_ip6_gw_set)
8158 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
8161 vec_free (host_if_name);
8162 vec_free (host_bridge);
8167 /* Wait for a reply... */
8173 api_tap_delete_v2 (vat_main_t * vam)
8175 unformat_input_t *i = vam->input;
8176 vl_api_tap_delete_v2_t *mp;
8177 u32 sw_if_index = ~0;
8178 u8 sw_if_index_set = 0;
8181 /* Parse args required to build the message */
8182 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8184 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8185 sw_if_index_set = 1;
8186 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8187 sw_if_index_set = 1;
8192 if (sw_if_index_set == 0)
8194 errmsg ("missing vpp interface name. ");
8198 /* Construct the API message */
8199 M (TAP_DELETE_V2, mp);
8201 mp->sw_if_index = ntohl (sw_if_index);
8206 /* Wait for a reply... */
8212 api_bond_create (vat_main_t * vam)
8214 unformat_input_t *i = vam->input;
8215 vl_api_bond_create_t *mp;
8223 memset (mac_address, 0, sizeof (mac_address));
8226 /* Parse args required to build the message */
8227 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8229 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
8231 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
8232 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
8234 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
8241 if (mode_is_set == 0)
8243 errmsg ("Missing bond mode. ");
8247 /* Construct the API message */
8248 M (BOND_CREATE, mp);
8250 mp->use_custom_mac = custom_mac;
8256 clib_memcpy (mp->mac_address, mac_address, 6);
8261 /* Wait for a reply... */
8267 api_bond_delete (vat_main_t * vam)
8269 unformat_input_t *i = vam->input;
8270 vl_api_bond_delete_t *mp;
8271 u32 sw_if_index = ~0;
8272 u8 sw_if_index_set = 0;
8275 /* Parse args required to build the message */
8276 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8278 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8279 sw_if_index_set = 1;
8280 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8281 sw_if_index_set = 1;
8286 if (sw_if_index_set == 0)
8288 errmsg ("missing vpp interface name. ");
8292 /* Construct the API message */
8293 M (BOND_DELETE, mp);
8295 mp->sw_if_index = ntohl (sw_if_index);
8300 /* Wait for a reply... */
8306 api_bond_enslave (vat_main_t * vam)
8308 unformat_input_t *i = vam->input;
8309 vl_api_bond_enslave_t *mp;
8310 u32 bond_sw_if_index;
8314 u32 bond_sw_if_index_is_set = 0;
8316 u8 sw_if_index_is_set = 0;
8318 /* Parse args required to build the message */
8319 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8321 if (unformat (i, "sw_if_index %d", &sw_if_index))
8322 sw_if_index_is_set = 1;
8323 else if (unformat (i, "bond %u", &bond_sw_if_index))
8324 bond_sw_if_index_is_set = 1;
8325 else if (unformat (i, "passive %d", &is_passive))
8327 else if (unformat (i, "long-timeout %d", &is_long_timeout))
8333 if (bond_sw_if_index_is_set == 0)
8335 errmsg ("Missing bond sw_if_index. ");
8338 if (sw_if_index_is_set == 0)
8340 errmsg ("Missing slave sw_if_index. ");
8344 /* Construct the API message */
8345 M (BOND_ENSLAVE, mp);
8347 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
8348 mp->sw_if_index = ntohl (sw_if_index);
8349 mp->is_long_timeout = is_long_timeout;
8350 mp->is_passive = is_passive;
8355 /* Wait for a reply... */
8361 api_bond_detach_slave (vat_main_t * vam)
8363 unformat_input_t *i = vam->input;
8364 vl_api_bond_detach_slave_t *mp;
8365 u32 sw_if_index = ~0;
8366 u8 sw_if_index_set = 0;
8369 /* Parse args required to build the message */
8370 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8372 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8373 sw_if_index_set = 1;
8374 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8375 sw_if_index_set = 1;
8380 if (sw_if_index_set == 0)
8382 errmsg ("missing vpp interface name. ");
8386 /* Construct the API message */
8387 M (BOND_DETACH_SLAVE, mp);
8389 mp->sw_if_index = ntohl (sw_if_index);
8394 /* Wait for a reply... */
8400 api_ip_table_add_del (vat_main_t * vam)
8402 unformat_input_t *i = vam->input;
8403 vl_api_ip_table_add_del_t *mp;
8409 /* Parse args required to build the message */
8410 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8412 if (unformat (i, "ipv6"))
8414 else if (unformat (i, "del"))
8416 else if (unformat (i, "add"))
8418 else if (unformat (i, "table %d", &table_id))
8422 clib_warning ("parse error '%U'", format_unformat_error, i);
8429 errmsg ("missing table-ID");
8433 /* Construct the API message */
8434 M (IP_TABLE_ADD_DEL, mp);
8436 mp->table_id = ntohl (table_id);
8437 mp->is_ipv6 = is_ipv6;
8438 mp->is_add = is_add;
8443 /* Wait for a reply... */
8450 api_ip_add_del_route (vat_main_t * vam)
8452 unformat_input_t *i = vam->input;
8453 vl_api_ip_add_del_route_t *mp;
8454 u32 sw_if_index = ~0, vrf_id = 0;
8456 u8 is_local = 0, is_drop = 0;
8457 u8 is_unreach = 0, is_prohibit = 0;
8459 u32 next_hop_weight = 1;
8460 u8 is_multipath = 0;
8462 u8 address_length_set = 0;
8463 u32 next_hop_table_id = 0;
8464 u32 resolve_attempts = 0;
8465 u32 dst_address_length = 0;
8466 u8 next_hop_set = 0;
8467 ip4_address_t v4_dst_address, v4_next_hop_address;
8468 ip6_address_t v6_dst_address, v6_next_hop_address;
8472 u32 random_add_del = 0;
8473 u32 *random_vector = 0;
8475 u32 random_seed = 0xdeaddabe;
8476 u32 classify_table_index = ~0;
8478 u8 resolve_host = 0, resolve_attached = 0;
8479 mpls_label_t *next_hop_out_label_stack = NULL;
8480 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8481 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8483 /* Parse args required to build the message */
8484 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8486 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8488 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8490 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
8495 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
8500 else if (unformat (i, "/%d", &dst_address_length))
8502 address_length_set = 1;
8505 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
8506 &v4_next_hop_address))
8510 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
8511 &v6_next_hop_address))
8515 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
8517 else if (unformat (i, "weight %d", &next_hop_weight))
8519 else if (unformat (i, "drop"))
8523 else if (unformat (i, "null-send-unreach"))
8527 else if (unformat (i, "null-send-prohibit"))
8531 else if (unformat (i, "local"))
8535 else if (unformat (i, "classify %d", &classify_table_index))
8539 else if (unformat (i, "del"))
8541 else if (unformat (i, "add"))
8543 else if (unformat (i, "resolve-via-host"))
8545 else if (unformat (i, "resolve-via-attached"))
8546 resolve_attached = 1;
8547 else if (unformat (i, "multipath"))
8549 else if (unformat (i, "vrf %d", &vrf_id))
8551 else if (unformat (i, "count %d", &count))
8553 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
8555 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8557 else if (unformat (i, "out-label %d", &next_hop_out_label))
8558 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
8559 else if (unformat (i, "via-label %d", &next_hop_via_label))
8561 else if (unformat (i, "random"))
8563 else if (unformat (i, "seed %d", &random_seed))
8567 clib_warning ("parse error '%U'", format_unformat_error, i);
8572 if (!next_hop_set && !is_drop && !is_local &&
8573 !is_classify && !is_unreach && !is_prohibit &&
8574 MPLS_LABEL_INVALID == next_hop_via_label)
8577 ("next hop / local / drop / unreach / prohibit / classify not set");
8581 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
8583 errmsg ("next hop and next-hop via label set");
8586 if (address_set == 0)
8588 errmsg ("missing addresses");
8592 if (address_length_set == 0)
8594 errmsg ("missing address length");
8598 /* Generate a pile of unique, random routes */
8601 u32 this_random_address;
8602 random_hash = hash_create (count, sizeof (uword));
8604 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
8605 for (j = 0; j <= count; j++)
8609 this_random_address = random_u32 (&random_seed);
8610 this_random_address =
8611 clib_host_to_net_u32 (this_random_address);
8613 while (hash_get (random_hash, this_random_address));
8614 vec_add1 (random_vector, this_random_address);
8615 hash_set (random_hash, this_random_address, 1);
8617 hash_free (random_hash);
8618 v4_dst_address.as_u32 = random_vector[0];
8623 /* Turn on async mode */
8624 vam->async_mode = 1;
8625 vam->async_errors = 0;
8626 before = vat_time_now (vam);
8629 for (j = 0; j < count; j++)
8631 /* Construct the API message */
8632 M2 (IP_ADD_DEL_ROUTE, mp,
8633 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
8635 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8636 mp->table_id = ntohl (vrf_id);
8638 mp->is_add = is_add;
8639 mp->is_drop = is_drop;
8640 mp->is_unreach = is_unreach;
8641 mp->is_prohibit = is_prohibit;
8642 mp->is_ipv6 = is_ipv6;
8643 mp->is_local = is_local;
8644 mp->is_classify = is_classify;
8645 mp->is_multipath = is_multipath;
8646 mp->is_resolve_host = resolve_host;
8647 mp->is_resolve_attached = resolve_attached;
8648 mp->next_hop_weight = next_hop_weight;
8649 mp->dst_address_length = dst_address_length;
8650 mp->next_hop_table_id = ntohl (next_hop_table_id);
8651 mp->classify_table_index = ntohl (classify_table_index);
8652 mp->next_hop_via_label = ntohl (next_hop_via_label);
8653 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8654 if (0 != mp->next_hop_n_out_labels)
8656 memcpy (mp->next_hop_out_label_stack,
8657 next_hop_out_label_stack,
8658 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
8659 vec_free (next_hop_out_label_stack);
8664 clib_memcpy (mp->dst_address, &v6_dst_address,
8665 sizeof (v6_dst_address));
8667 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
8668 sizeof (v6_next_hop_address));
8669 increment_v6_address (&v6_dst_address);
8673 clib_memcpy (mp->dst_address, &v4_dst_address,
8674 sizeof (v4_dst_address));
8676 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
8677 sizeof (v4_next_hop_address));
8679 v4_dst_address.as_u32 = random_vector[j + 1];
8681 increment_v4_address (&v4_dst_address);
8685 /* If we receive SIGTERM, stop now... */
8690 /* When testing multiple add/del ops, use a control-ping to sync */
8693 vl_api_control_ping_t *mp_ping;
8697 /* Shut off async mode */
8698 vam->async_mode = 0;
8700 MPING (CONTROL_PING, mp_ping);
8703 timeout = vat_time_now (vam) + 1.0;
8704 while (vat_time_now (vam) < timeout)
8705 if (vam->result_ready == 1)
8710 if (vam->retval == -99)
8713 if (vam->async_errors > 0)
8715 errmsg ("%d asynchronous errors", vam->async_errors);
8718 vam->async_errors = 0;
8719 after = vat_time_now (vam);
8721 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8725 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8726 count, after - before, count / (after - before));
8732 /* Wait for a reply... */
8737 /* Return the good/bad news */
8738 return (vam->retval);
8742 api_ip_mroute_add_del (vat_main_t * vam)
8744 unformat_input_t *i = vam->input;
8745 vl_api_ip_mroute_add_del_t *mp;
8746 u32 sw_if_index = ~0, vrf_id = 0;
8751 u32 grp_address_length = 0;
8752 ip4_address_t v4_grp_address, v4_src_address;
8753 ip6_address_t v6_grp_address, v6_src_address;
8754 mfib_itf_flags_t iflags = 0;
8755 mfib_entry_flags_t eflags = 0;
8758 /* Parse args required to build the message */
8759 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8761 if (unformat (i, "sw_if_index %d", &sw_if_index))
8763 else if (unformat (i, "%U %U",
8764 unformat_ip4_address, &v4_src_address,
8765 unformat_ip4_address, &v4_grp_address))
8767 grp_address_length = 64;
8771 else if (unformat (i, "%U %U",
8772 unformat_ip6_address, &v6_src_address,
8773 unformat_ip6_address, &v6_grp_address))
8775 grp_address_length = 256;
8779 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
8781 memset (&v4_src_address, 0, sizeof (v4_src_address));
8782 grp_address_length = 32;
8786 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
8788 memset (&v6_src_address, 0, sizeof (v6_src_address));
8789 grp_address_length = 128;
8793 else if (unformat (i, "/%d", &grp_address_length))
8795 else if (unformat (i, "local"))
8799 else if (unformat (i, "del"))
8801 else if (unformat (i, "add"))
8803 else if (unformat (i, "vrf %d", &vrf_id))
8805 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
8807 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8811 clib_warning ("parse error '%U'", format_unformat_error, i);
8816 if (address_set == 0)
8818 errmsg ("missing addresses\n");
8822 /* Construct the API message */
8823 M (IP_MROUTE_ADD_DEL, mp);
8825 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8826 mp->table_id = ntohl (vrf_id);
8828 mp->is_add = is_add;
8829 mp->is_ipv6 = is_ipv6;
8830 mp->is_local = is_local;
8831 mp->itf_flags = ntohl (iflags);
8832 mp->entry_flags = ntohl (eflags);
8833 mp->grp_address_length = grp_address_length;
8834 mp->grp_address_length = ntohs (mp->grp_address_length);
8838 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
8839 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
8843 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
8844 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
8850 /* Wait for a reply... */
8856 api_mpls_table_add_del (vat_main_t * vam)
8858 unformat_input_t *i = vam->input;
8859 vl_api_mpls_table_add_del_t *mp;
8864 /* Parse args required to build the message */
8865 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8867 if (unformat (i, "table %d", &table_id))
8869 else if (unformat (i, "del"))
8871 else if (unformat (i, "add"))
8875 clib_warning ("parse error '%U'", format_unformat_error, i);
8882 errmsg ("missing table-ID");
8886 /* Construct the API message */
8887 M (MPLS_TABLE_ADD_DEL, mp);
8889 mp->mt_table_id = ntohl (table_id);
8890 mp->mt_is_add = is_add;
8895 /* Wait for a reply... */
8902 api_mpls_route_add_del (vat_main_t * vam)
8904 unformat_input_t *i = vam->input;
8905 vl_api_mpls_route_add_del_t *mp;
8906 u32 sw_if_index = ~0, table_id = 0;
8908 u32 next_hop_weight = 1;
8909 u8 is_multipath = 0;
8910 u32 next_hop_table_id = 0;
8911 u8 next_hop_set = 0;
8912 ip4_address_t v4_next_hop_address = {
8915 ip6_address_t v6_next_hop_address = { {0} };
8919 u32 classify_table_index = ~0;
8921 u8 resolve_host = 0, resolve_attached = 0;
8922 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8923 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8924 mpls_label_t *next_hop_out_label_stack = NULL;
8925 mpls_label_t local_label = MPLS_LABEL_INVALID;
8927 dpo_proto_t next_hop_proto = DPO_PROTO_IP4;
8929 /* Parse args required to build the message */
8930 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8932 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8934 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8936 else if (unformat (i, "%d", &local_label))
8938 else if (unformat (i, "eos"))
8940 else if (unformat (i, "non-eos"))
8942 else if (unformat (i, "via %U", unformat_ip4_address,
8943 &v4_next_hop_address))
8946 next_hop_proto = DPO_PROTO_IP4;
8948 else if (unformat (i, "via %U", unformat_ip6_address,
8949 &v6_next_hop_address))
8952 next_hop_proto = DPO_PROTO_IP6;
8954 else if (unformat (i, "weight %d", &next_hop_weight))
8956 else if (unformat (i, "classify %d", &classify_table_index))
8960 else if (unformat (i, "del"))
8962 else if (unformat (i, "add"))
8964 else if (unformat (i, "resolve-via-host"))
8966 else if (unformat (i, "resolve-via-attached"))
8967 resolve_attached = 1;
8968 else if (unformat (i, "multipath"))
8970 else if (unformat (i, "count %d", &count))
8972 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
8975 next_hop_proto = DPO_PROTO_IP4;
8977 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
8980 next_hop_proto = DPO_PROTO_IP6;
8982 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8984 else if (unformat (i, "via-label %d", &next_hop_via_label))
8986 else if (unformat (i, "out-label %d", &next_hop_out_label))
8987 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
8990 clib_warning ("parse error '%U'", format_unformat_error, i);
8995 if (!next_hop_set && !is_classify)
8997 errmsg ("next hop / classify not set");
9001 if (MPLS_LABEL_INVALID == local_label)
9003 errmsg ("missing label");
9009 /* Turn on async mode */
9010 vam->async_mode = 1;
9011 vam->async_errors = 0;
9012 before = vat_time_now (vam);
9015 for (j = 0; j < count; j++)
9017 /* Construct the API message */
9018 M2 (MPLS_ROUTE_ADD_DEL, mp,
9019 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
9021 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
9022 mp->mr_table_id = ntohl (table_id);
9024 mp->mr_is_add = is_add;
9025 mp->mr_next_hop_proto = next_hop_proto;
9026 mp->mr_is_classify = is_classify;
9027 mp->mr_is_multipath = is_multipath;
9028 mp->mr_is_resolve_host = resolve_host;
9029 mp->mr_is_resolve_attached = resolve_attached;
9030 mp->mr_next_hop_weight = next_hop_weight;
9031 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
9032 mp->mr_classify_table_index = ntohl (classify_table_index);
9033 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
9034 mp->mr_label = ntohl (local_label);
9035 mp->mr_eos = is_eos;
9037 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
9038 if (0 != mp->mr_next_hop_n_out_labels)
9040 memcpy (mp->mr_next_hop_out_label_stack,
9041 next_hop_out_label_stack,
9042 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
9043 vec_free (next_hop_out_label_stack);
9048 if (DPO_PROTO_IP4 == next_hop_proto)
9050 clib_memcpy (mp->mr_next_hop,
9051 &v4_next_hop_address,
9052 sizeof (v4_next_hop_address));
9054 else if (DPO_PROTO_IP6 == next_hop_proto)
9057 clib_memcpy (mp->mr_next_hop,
9058 &v6_next_hop_address,
9059 sizeof (v6_next_hop_address));
9066 /* If we receive SIGTERM, stop now... */
9071 /* When testing multiple add/del ops, use a control-ping to sync */
9074 vl_api_control_ping_t *mp_ping;
9078 /* Shut off async mode */
9079 vam->async_mode = 0;
9081 MPING (CONTROL_PING, mp_ping);
9084 timeout = vat_time_now (vam) + 1.0;
9085 while (vat_time_now (vam) < timeout)
9086 if (vam->result_ready == 1)
9091 if (vam->retval == -99)
9094 if (vam->async_errors > 0)
9096 errmsg ("%d asynchronous errors", vam->async_errors);
9099 vam->async_errors = 0;
9100 after = vat_time_now (vam);
9102 /* slim chance, but we might have eaten SIGTERM on the first iteration */
9106 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
9107 count, after - before, count / (after - before));
9113 /* Wait for a reply... */
9118 /* Return the good/bad news */
9119 return (vam->retval);
9123 api_mpls_ip_bind_unbind (vat_main_t * vam)
9125 unformat_input_t *i = vam->input;
9126 vl_api_mpls_ip_bind_unbind_t *mp;
9127 u32 ip_table_id = 0;
9130 ip4_address_t v4_address;
9131 ip6_address_t v6_address;
9134 mpls_label_t local_label = MPLS_LABEL_INVALID;
9137 /* Parse args required to build the message */
9138 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9140 if (unformat (i, "%U/%d", unformat_ip4_address,
9141 &v4_address, &address_length))
9146 else if (unformat (i, "%U/%d", unformat_ip6_address,
9147 &v6_address, &address_length))
9152 else if (unformat (i, "%d", &local_label))
9154 else if (unformat (i, "table-id %d", &ip_table_id))
9156 else if (unformat (i, "unbind"))
9158 else if (unformat (i, "bind"))
9162 clib_warning ("parse error '%U'", format_unformat_error, i);
9169 errmsg ("IP addres not set");
9173 if (MPLS_LABEL_INVALID == local_label)
9175 errmsg ("missing label");
9179 /* Construct the API message */
9180 M (MPLS_IP_BIND_UNBIND, mp);
9182 mp->mb_is_bind = is_bind;
9183 mp->mb_is_ip4 = is_ip4;
9184 mp->mb_ip_table_id = ntohl (ip_table_id);
9185 mp->mb_mpls_table_id = 0;
9186 mp->mb_label = ntohl (local_label);
9187 mp->mb_address_length = address_length;
9190 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
9192 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
9197 /* Wait for a reply... */
9203 api_bier_table_add_del (vat_main_t * vam)
9205 unformat_input_t *i = vam->input;
9206 vl_api_bier_table_add_del_t *mp;
9208 u32 set = 0, sub_domain = 0, hdr_len = 3;
9209 mpls_label_t local_label = MPLS_LABEL_INVALID;
9212 /* Parse args required to build the message */
9213 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9215 if (unformat (i, "sub-domain %d", &sub_domain))
9217 else if (unformat (i, "set %d", &set))
9219 else if (unformat (i, "label %d", &local_label))
9221 else if (unformat (i, "hdr-len %d", &hdr_len))
9223 else if (unformat (i, "add"))
9225 else if (unformat (i, "del"))
9229 clib_warning ("parse error '%U'", format_unformat_error, i);
9234 if (MPLS_LABEL_INVALID == local_label)
9236 errmsg ("missing label\n");
9240 /* Construct the API message */
9241 M (BIER_TABLE_ADD_DEL, mp);
9243 mp->bt_is_add = is_add;
9244 mp->bt_label = ntohl (local_label);
9245 mp->bt_tbl_id.bt_set = set;
9246 mp->bt_tbl_id.bt_sub_domain = sub_domain;
9247 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
9252 /* Wait for a reply... */
9259 api_bier_route_add_del (vat_main_t * vam)
9261 unformat_input_t *i = vam->input;
9262 vl_api_bier_route_add_del_t *mp;
9264 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
9265 ip4_address_t v4_next_hop_address;
9266 ip6_address_t v6_next_hop_address;
9267 u8 next_hop_set = 0;
9268 u8 next_hop_proto_is_ip4 = 1;
9269 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9272 /* Parse args required to build the message */
9273 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9275 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
9277 next_hop_proto_is_ip4 = 1;
9280 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
9282 next_hop_proto_is_ip4 = 0;
9285 if (unformat (i, "sub-domain %d", &sub_domain))
9287 else if (unformat (i, "set %d", &set))
9289 else if (unformat (i, "hdr-len %d", &hdr_len))
9291 else if (unformat (i, "bp %d", &bp))
9293 else if (unformat (i, "add"))
9295 else if (unformat (i, "del"))
9297 else if (unformat (i, "out-label %d", &next_hop_out_label))
9301 clib_warning ("parse error '%U'", format_unformat_error, i);
9306 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
9308 errmsg ("next hop / label set\n");
9313 errmsg ("bit=position not set\n");
9317 /* Construct the API message */
9318 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
9320 mp->br_is_add = is_add;
9321 mp->br_tbl_id.bt_set = set;
9322 mp->br_tbl_id.bt_sub_domain = sub_domain;
9323 mp->br_tbl_id.bt_hdr_len_id = hdr_len;
9324 mp->br_bp = ntohs (bp);
9326 mp->br_paths[0].n_labels = 1;
9327 mp->br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
9328 mp->br_paths[0].afi = (next_hop_proto_is_ip4 ? 0 : 1);
9330 if (next_hop_proto_is_ip4)
9332 clib_memcpy (mp->br_paths[0].next_hop,
9333 &v4_next_hop_address, sizeof (v4_next_hop_address));
9337 clib_memcpy (mp->br_paths[0].next_hop,
9338 &v6_next_hop_address, sizeof (v6_next_hop_address));
9344 /* Wait for a reply... */
9351 api_proxy_arp_add_del (vat_main_t * vam)
9353 unformat_input_t *i = vam->input;
9354 vl_api_proxy_arp_add_del_t *mp;
9357 ip4_address_t lo, hi;
9361 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9363 if (unformat (i, "vrf %d", &vrf_id))
9365 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
9366 unformat_ip4_address, &hi))
9368 else if (unformat (i, "del"))
9372 clib_warning ("parse error '%U'", format_unformat_error, i);
9379 errmsg ("address range not set");
9383 M (PROXY_ARP_ADD_DEL, mp);
9385 mp->proxy.vrf_id = ntohl (vrf_id);
9386 mp->is_add = is_add;
9387 clib_memcpy (mp->proxy.low_address, &lo, sizeof (mp->proxy.low_address));
9388 clib_memcpy (mp->proxy.hi_address, &hi, sizeof (mp->proxy.hi_address));
9396 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
9398 unformat_input_t *i = vam->input;
9399 vl_api_proxy_arp_intfc_enable_disable_t *mp;
9402 u8 sw_if_index_set = 0;
9405 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9407 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9408 sw_if_index_set = 1;
9409 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9410 sw_if_index_set = 1;
9411 else if (unformat (i, "enable"))
9413 else if (unformat (i, "disable"))
9417 clib_warning ("parse error '%U'", format_unformat_error, i);
9422 if (sw_if_index_set == 0)
9424 errmsg ("missing interface name or sw_if_index");
9428 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
9430 mp->sw_if_index = ntohl (sw_if_index);
9431 mp->enable_disable = enable;
9439 api_mpls_tunnel_add_del (vat_main_t * vam)
9441 unformat_input_t *i = vam->input;
9442 vl_api_mpls_tunnel_add_del_t *mp;
9446 u32 sw_if_index = ~0;
9447 u32 next_hop_sw_if_index = ~0;
9448 u32 next_hop_proto_is_ip4 = 1;
9450 u32 next_hop_table_id = 0;
9451 ip4_address_t v4_next_hop_address = {
9454 ip6_address_t v6_next_hop_address = { {0} };
9455 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
9458 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9460 if (unformat (i, "add"))
9462 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
9464 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
9466 else if (unformat (i, "via %U",
9467 unformat_ip4_address, &v4_next_hop_address))
9469 next_hop_proto_is_ip4 = 1;
9471 else if (unformat (i, "via %U",
9472 unformat_ip6_address, &v6_next_hop_address))
9474 next_hop_proto_is_ip4 = 0;
9476 else if (unformat (i, "l2-only"))
9478 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
9480 else if (unformat (i, "out-label %d", &next_hop_out_label))
9481 vec_add1 (labels, ntohl (next_hop_out_label));
9484 clib_warning ("parse error '%U'", format_unformat_error, i);
9489 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
9491 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
9492 mp->mt_sw_if_index = ntohl (sw_if_index);
9493 mp->mt_is_add = is_add;
9494 mp->mt_l2_only = l2_only;
9495 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
9496 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
9498 mp->mt_next_hop_n_out_labels = vec_len (labels);
9500 if (0 != mp->mt_next_hop_n_out_labels)
9502 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
9503 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
9507 if (next_hop_proto_is_ip4)
9509 clib_memcpy (mp->mt_next_hop,
9510 &v4_next_hop_address, sizeof (v4_next_hop_address));
9514 clib_memcpy (mp->mt_next_hop,
9515 &v6_next_hop_address, sizeof (v6_next_hop_address));
9524 api_sw_interface_set_unnumbered (vat_main_t * vam)
9526 unformat_input_t *i = vam->input;
9527 vl_api_sw_interface_set_unnumbered_t *mp;
9529 u32 unnum_sw_index = ~0;
9531 u8 sw_if_index_set = 0;
9534 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9536 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9537 sw_if_index_set = 1;
9538 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9539 sw_if_index_set = 1;
9540 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
9542 else if (unformat (i, "del"))
9546 clib_warning ("parse error '%U'", format_unformat_error, i);
9551 if (sw_if_index_set == 0)
9553 errmsg ("missing interface name or sw_if_index");
9557 M (SW_INTERFACE_SET_UNNUMBERED, mp);
9559 mp->sw_if_index = ntohl (sw_if_index);
9560 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
9561 mp->is_add = is_add;
9569 api_ip_neighbor_add_del (vat_main_t * vam)
9571 unformat_input_t *i = vam->input;
9572 vl_api_ip_neighbor_add_del_t *mp;
9574 u8 sw_if_index_set = 0;
9577 u8 is_no_fib_entry = 0;
9580 u8 v4_address_set = 0;
9581 u8 v6_address_set = 0;
9582 ip4_address_t v4address;
9583 ip6_address_t v6address;
9586 memset (mac_address, 0, sizeof (mac_address));
9588 /* Parse args required to build the message */
9589 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9591 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
9595 else if (unformat (i, "del"))
9598 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9599 sw_if_index_set = 1;
9600 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9601 sw_if_index_set = 1;
9602 else if (unformat (i, "is_static"))
9604 else if (unformat (i, "no-fib-entry"))
9605 is_no_fib_entry = 1;
9606 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
9608 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
9612 clib_warning ("parse error '%U'", format_unformat_error, i);
9617 if (sw_if_index_set == 0)
9619 errmsg ("missing interface name or sw_if_index");
9622 if (v4_address_set && v6_address_set)
9624 errmsg ("both v4 and v6 addresses set");
9627 if (!v4_address_set && !v6_address_set)
9629 errmsg ("no address set");
9633 /* Construct the API message */
9634 M (IP_NEIGHBOR_ADD_DEL, mp);
9636 mp->sw_if_index = ntohl (sw_if_index);
9637 mp->is_add = is_add;
9638 mp->is_static = is_static;
9639 mp->is_no_adj_fib = is_no_fib_entry;
9641 clib_memcpy (mp->mac_address, mac_address, 6);
9645 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
9649 /* mp->is_ipv6 = 0; via memset in M macro above */
9650 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
9656 /* Wait for a reply, return good/bad news */
9662 api_create_vlan_subif (vat_main_t * vam)
9664 unformat_input_t *i = vam->input;
9665 vl_api_create_vlan_subif_t *mp;
9667 u8 sw_if_index_set = 0;
9672 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9674 if (unformat (i, "sw_if_index %d", &sw_if_index))
9675 sw_if_index_set = 1;
9677 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9678 sw_if_index_set = 1;
9679 else if (unformat (i, "vlan %d", &vlan_id))
9683 clib_warning ("parse error '%U'", format_unformat_error, i);
9688 if (sw_if_index_set == 0)
9690 errmsg ("missing interface name or sw_if_index");
9694 if (vlan_id_set == 0)
9696 errmsg ("missing vlan_id");
9699 M (CREATE_VLAN_SUBIF, mp);
9701 mp->sw_if_index = ntohl (sw_if_index);
9702 mp->vlan_id = ntohl (vlan_id);
9709 #define foreach_create_subif_bit \
9716 _(outer_vlan_id_any) \
9717 _(inner_vlan_id_any)
9720 api_create_subif (vat_main_t * vam)
9722 unformat_input_t *i = vam->input;
9723 vl_api_create_subif_t *mp;
9725 u8 sw_if_index_set = 0;
9732 u32 exact_match = 0;
9733 u32 default_sub = 0;
9734 u32 outer_vlan_id_any = 0;
9735 u32 inner_vlan_id_any = 0;
9737 u16 outer_vlan_id = 0;
9738 u16 inner_vlan_id = 0;
9741 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9743 if (unformat (i, "sw_if_index %d", &sw_if_index))
9744 sw_if_index_set = 1;
9746 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9747 sw_if_index_set = 1;
9748 else if (unformat (i, "sub_id %d", &sub_id))
9750 else if (unformat (i, "outer_vlan_id %d", &tmp))
9751 outer_vlan_id = tmp;
9752 else if (unformat (i, "inner_vlan_id %d", &tmp))
9753 inner_vlan_id = tmp;
9755 #define _(a) else if (unformat (i, #a)) a = 1 ;
9756 foreach_create_subif_bit
9760 clib_warning ("parse error '%U'", format_unformat_error, i);
9765 if (sw_if_index_set == 0)
9767 errmsg ("missing interface name or sw_if_index");
9771 if (sub_id_set == 0)
9773 errmsg ("missing sub_id");
9776 M (CREATE_SUBIF, mp);
9778 mp->sw_if_index = ntohl (sw_if_index);
9779 mp->sub_id = ntohl (sub_id);
9781 #define _(a) mp->a = a;
9782 foreach_create_subif_bit;
9785 mp->outer_vlan_id = ntohs (outer_vlan_id);
9786 mp->inner_vlan_id = ntohs (inner_vlan_id);
9794 api_oam_add_del (vat_main_t * vam)
9796 unformat_input_t *i = vam->input;
9797 vl_api_oam_add_del_t *mp;
9800 ip4_address_t src, dst;
9805 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9807 if (unformat (i, "vrf %d", &vrf_id))
9809 else if (unformat (i, "src %U", unformat_ip4_address, &src))
9811 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
9813 else if (unformat (i, "del"))
9817 clib_warning ("parse error '%U'", format_unformat_error, i);
9824 errmsg ("missing src addr");
9830 errmsg ("missing dst addr");
9834 M (OAM_ADD_DEL, mp);
9836 mp->vrf_id = ntohl (vrf_id);
9837 mp->is_add = is_add;
9838 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
9839 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
9847 api_reset_fib (vat_main_t * vam)
9849 unformat_input_t *i = vam->input;
9850 vl_api_reset_fib_t *mp;
9856 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9858 if (unformat (i, "vrf %d", &vrf_id))
9860 else if (unformat (i, "ipv6"))
9864 clib_warning ("parse error '%U'", format_unformat_error, i);
9869 if (vrf_id_set == 0)
9871 errmsg ("missing vrf id");
9877 mp->vrf_id = ntohl (vrf_id);
9878 mp->is_ipv6 = is_ipv6;
9886 api_dhcp_proxy_config (vat_main_t * vam)
9888 unformat_input_t *i = vam->input;
9889 vl_api_dhcp_proxy_config_t *mp;
9891 u32 server_vrf_id = 0;
9893 u8 v4_address_set = 0;
9894 u8 v6_address_set = 0;
9895 ip4_address_t v4address;
9896 ip6_address_t v6address;
9897 u8 v4_src_address_set = 0;
9898 u8 v6_src_address_set = 0;
9899 ip4_address_t v4srcaddress;
9900 ip6_address_t v6srcaddress;
9903 /* Parse args required to build the message */
9904 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9906 if (unformat (i, "del"))
9908 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
9910 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
9912 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
9914 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
9916 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
9917 v4_src_address_set = 1;
9918 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
9919 v6_src_address_set = 1;
9924 if (v4_address_set && v6_address_set)
9926 errmsg ("both v4 and v6 server addresses set");
9929 if (!v4_address_set && !v6_address_set)
9931 errmsg ("no server addresses set");
9935 if (v4_src_address_set && v6_src_address_set)
9937 errmsg ("both v4 and v6 src addresses set");
9940 if (!v4_src_address_set && !v6_src_address_set)
9942 errmsg ("no src addresses set");
9946 if (!(v4_src_address_set && v4_address_set) &&
9947 !(v6_src_address_set && v6_address_set))
9949 errmsg ("no matching server and src addresses set");
9953 /* Construct the API message */
9954 M (DHCP_PROXY_CONFIG, mp);
9956 mp->is_add = is_add;
9957 mp->rx_vrf_id = ntohl (rx_vrf_id);
9958 mp->server_vrf_id = ntohl (server_vrf_id);
9962 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
9963 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
9967 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
9968 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
9974 /* Wait for a reply, return good/bad news */
9979 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
9980 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
9983 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
9985 vat_main_t *vam = &vat_main;
9986 u32 i, count = mp->count;
9987 vl_api_dhcp_server_t *s;
9991 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9992 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9993 ntohl (mp->rx_vrf_id),
9994 format_ip6_address, mp->dhcp_src_address,
9995 mp->vss_type, mp->vss_vpn_ascii_id,
9996 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9999 "RX Table-ID %d, Source Address %U, VSS Type %d, "
10000 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
10001 ntohl (mp->rx_vrf_id),
10002 format_ip4_address, mp->dhcp_src_address,
10003 mp->vss_type, mp->vss_vpn_ascii_id,
10004 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
10006 for (i = 0; i < count; i++)
10008 s = &mp->servers[i];
10012 " Server Table-ID %d, Server Address %U",
10013 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
10016 " Server Table-ID %d, Server Address %U",
10017 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
10021 static void vl_api_dhcp_proxy_details_t_handler_json
10022 (vl_api_dhcp_proxy_details_t * mp)
10024 vat_main_t *vam = &vat_main;
10025 vat_json_node_t *node = NULL;
10026 u32 i, count = mp->count;
10027 struct in_addr ip4;
10028 struct in6_addr ip6;
10029 vl_api_dhcp_server_t *s;
10031 if (VAT_JSON_ARRAY != vam->json_tree.type)
10033 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10034 vat_json_init_array (&vam->json_tree);
10036 node = vat_json_array_add (&vam->json_tree);
10038 vat_json_init_object (node);
10039 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
10040 vat_json_object_add_bytes (node, "vss-type", &mp->vss_type,
10041 sizeof (mp->vss_type));
10042 vat_json_object_add_string_copy (node, "vss-vpn-ascii-id",
10043 mp->vss_vpn_ascii_id);
10044 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
10045 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
10049 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
10050 vat_json_object_add_ip6 (node, "src_address", ip6);
10054 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
10055 vat_json_object_add_ip4 (node, "src_address", ip4);
10058 for (i = 0; i < count; i++)
10060 s = &mp->servers[i];
10062 vat_json_object_add_uint (node, "server-table-id",
10063 ntohl (s->server_vrf_id));
10067 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
10068 vat_json_object_add_ip4 (node, "src_address", ip4);
10072 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
10073 vat_json_object_add_ip6 (node, "server_address", ip6);
10079 api_dhcp_proxy_dump (vat_main_t * vam)
10081 unformat_input_t *i = vam->input;
10082 vl_api_control_ping_t *mp_ping;
10083 vl_api_dhcp_proxy_dump_t *mp;
10087 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10089 if (unformat (i, "ipv6"))
10093 clib_warning ("parse error '%U'", format_unformat_error, i);
10098 M (DHCP_PROXY_DUMP, mp);
10100 mp->is_ip6 = is_ipv6;
10103 /* Use a control ping for synchronization */
10104 MPING (CONTROL_PING, mp_ping);
10112 api_dhcp_proxy_set_vss (vat_main_t * vam)
10114 unformat_input_t *i = vam->input;
10115 vl_api_dhcp_proxy_set_vss_t *mp;
10119 u8 vss_type = VSS_TYPE_DEFAULT;
10120 u8 *vpn_ascii_id = 0;
10125 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10127 if (unformat (i, "tbl_id %d", &tbl_id))
10129 else if (unformat (i, "vpn_ascii_id %s", &vpn_ascii_id))
10130 vss_type = VSS_TYPE_ASCII;
10131 else if (unformat (i, "fib_id %d", &fib_id))
10132 vss_type = VSS_TYPE_VPN_ID;
10133 else if (unformat (i, "oui %d", &oui))
10134 vss_type = VSS_TYPE_VPN_ID;
10135 else if (unformat (i, "ipv6"))
10137 else if (unformat (i, "del"))
10145 errmsg ("missing tbl_id ");
10146 vec_free (vpn_ascii_id);
10150 if ((vpn_ascii_id) && (vec_len (vpn_ascii_id) > 128))
10152 errmsg ("vpn_ascii_id cannot be longer than 128 ");
10153 vec_free (vpn_ascii_id);
10157 M (DHCP_PROXY_SET_VSS, mp);
10158 mp->tbl_id = ntohl (tbl_id);
10159 mp->vss_type = vss_type;
10162 clib_memcpy (mp->vpn_ascii_id, vpn_ascii_id, vec_len (vpn_ascii_id));
10163 mp->vpn_ascii_id[vec_len (vpn_ascii_id)] = 0;
10165 mp->vpn_index = ntohl (fib_id);
10166 mp->oui = ntohl (oui);
10167 mp->is_ipv6 = is_ipv6;
10168 mp->is_add = is_add;
10173 vec_free (vpn_ascii_id);
10178 api_dhcp_client_config (vat_main_t * vam)
10180 unformat_input_t *i = vam->input;
10181 vl_api_dhcp_client_config_t *mp;
10183 u8 sw_if_index_set = 0;
10186 u8 disable_event = 0;
10189 /* Parse args required to build the message */
10190 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10192 if (unformat (i, "del"))
10195 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10196 sw_if_index_set = 1;
10197 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10198 sw_if_index_set = 1;
10199 else if (unformat (i, "hostname %s", &hostname))
10201 else if (unformat (i, "disable_event"))
10207 if (sw_if_index_set == 0)
10209 errmsg ("missing interface name or sw_if_index");
10213 if (vec_len (hostname) > 63)
10215 errmsg ("hostname too long");
10217 vec_add1 (hostname, 0);
10219 /* Construct the API message */
10220 M (DHCP_CLIENT_CONFIG, mp);
10222 mp->is_add = is_add;
10223 mp->client.sw_if_index = htonl (sw_if_index);
10224 clib_memcpy (mp->client.hostname, hostname, vec_len (hostname));
10225 vec_free (hostname);
10226 mp->client.want_dhcp_event = disable_event ? 0 : 1;
10227 mp->client.pid = htonl (getpid ());
10232 /* Wait for a reply, return good/bad news */
10238 api_set_ip_flow_hash (vat_main_t * vam)
10240 unformat_input_t *i = vam->input;
10241 vl_api_set_ip_flow_hash_t *mp;
10253 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10255 if (unformat (i, "vrf %d", &vrf_id))
10257 else if (unformat (i, "ipv6"))
10259 else if (unformat (i, "src"))
10261 else if (unformat (i, "dst"))
10263 else if (unformat (i, "sport"))
10265 else if (unformat (i, "dport"))
10267 else if (unformat (i, "proto"))
10269 else if (unformat (i, "reverse"))
10274 clib_warning ("parse error '%U'", format_unformat_error, i);
10279 if (vrf_id_set == 0)
10281 errmsg ("missing vrf id");
10285 M (SET_IP_FLOW_HASH, mp);
10291 mp->reverse = reverse;
10292 mp->vrf_id = ntohl (vrf_id);
10293 mp->is_ipv6 = is_ipv6;
10301 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
10303 unformat_input_t *i = vam->input;
10304 vl_api_sw_interface_ip6_enable_disable_t *mp;
10306 u8 sw_if_index_set = 0;
10310 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10312 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10313 sw_if_index_set = 1;
10314 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10315 sw_if_index_set = 1;
10316 else if (unformat (i, "enable"))
10318 else if (unformat (i, "disable"))
10322 clib_warning ("parse error '%U'", format_unformat_error, i);
10327 if (sw_if_index_set == 0)
10329 errmsg ("missing interface name or sw_if_index");
10333 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
10335 mp->sw_if_index = ntohl (sw_if_index);
10336 mp->enable = enable;
10344 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
10346 unformat_input_t *i = vam->input;
10347 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
10349 u8 sw_if_index_set = 0;
10350 u8 v6_address_set = 0;
10351 ip6_address_t v6address;
10354 /* Parse args required to build the message */
10355 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10357 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10358 sw_if_index_set = 1;
10359 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10360 sw_if_index_set = 1;
10361 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10362 v6_address_set = 1;
10367 if (sw_if_index_set == 0)
10369 errmsg ("missing interface name or sw_if_index");
10372 if (!v6_address_set)
10374 errmsg ("no address set");
10378 /* Construct the API message */
10379 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
10381 mp->sw_if_index = ntohl (sw_if_index);
10382 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10387 /* Wait for a reply, return good/bad news */
10393 api_ip6nd_proxy_add_del (vat_main_t * vam)
10395 unformat_input_t *i = vam->input;
10396 vl_api_ip6nd_proxy_add_del_t *mp;
10397 u32 sw_if_index = ~0;
10398 u8 v6_address_set = 0;
10399 ip6_address_t v6address;
10403 /* Parse args required to build the message */
10404 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10406 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10408 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10410 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10411 v6_address_set = 1;
10412 if (unformat (i, "del"))
10416 clib_warning ("parse error '%U'", format_unformat_error, i);
10421 if (sw_if_index == ~0)
10423 errmsg ("missing interface name or sw_if_index");
10426 if (!v6_address_set)
10428 errmsg ("no address set");
10432 /* Construct the API message */
10433 M (IP6ND_PROXY_ADD_DEL, mp);
10435 mp->is_del = is_del;
10436 mp->sw_if_index = ntohl (sw_if_index);
10437 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10442 /* Wait for a reply, return good/bad news */
10448 api_ip6nd_proxy_dump (vat_main_t * vam)
10450 vl_api_ip6nd_proxy_dump_t *mp;
10451 vl_api_control_ping_t *mp_ping;
10454 M (IP6ND_PROXY_DUMP, mp);
10458 /* Use a control ping for synchronization */
10459 MPING (CONTROL_PING, mp_ping);
10466 static void vl_api_ip6nd_proxy_details_t_handler
10467 (vl_api_ip6nd_proxy_details_t * mp)
10469 vat_main_t *vam = &vat_main;
10471 print (vam->ofp, "host %U sw_if_index %d",
10472 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
10475 static void vl_api_ip6nd_proxy_details_t_handler_json
10476 (vl_api_ip6nd_proxy_details_t * mp)
10478 vat_main_t *vam = &vat_main;
10479 struct in6_addr ip6;
10480 vat_json_node_t *node = NULL;
10482 if (VAT_JSON_ARRAY != vam->json_tree.type)
10484 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10485 vat_json_init_array (&vam->json_tree);
10487 node = vat_json_array_add (&vam->json_tree);
10489 vat_json_init_object (node);
10490 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10492 clib_memcpy (&ip6, mp->address, sizeof (ip6));
10493 vat_json_object_add_ip6 (node, "host", ip6);
10497 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
10499 unformat_input_t *i = vam->input;
10500 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
10502 u8 sw_if_index_set = 0;
10503 u32 address_length = 0;
10504 u8 v6_address_set = 0;
10505 ip6_address_t v6address;
10506 u8 use_default = 0;
10507 u8 no_advertise = 0;
10509 u8 no_autoconfig = 0;
10512 u32 val_lifetime = 0;
10513 u32 pref_lifetime = 0;
10516 /* Parse args required to build the message */
10517 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10519 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10520 sw_if_index_set = 1;
10521 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10522 sw_if_index_set = 1;
10523 else if (unformat (i, "%U/%d",
10524 unformat_ip6_address, &v6address, &address_length))
10525 v6_address_set = 1;
10526 else if (unformat (i, "val_life %d", &val_lifetime))
10528 else if (unformat (i, "pref_life %d", &pref_lifetime))
10530 else if (unformat (i, "def"))
10532 else if (unformat (i, "noadv"))
10534 else if (unformat (i, "offl"))
10536 else if (unformat (i, "noauto"))
10538 else if (unformat (i, "nolink"))
10540 else if (unformat (i, "isno"))
10544 clib_warning ("parse error '%U'", format_unformat_error, i);
10549 if (sw_if_index_set == 0)
10551 errmsg ("missing interface name or sw_if_index");
10554 if (!v6_address_set)
10556 errmsg ("no address set");
10560 /* Construct the API message */
10561 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
10563 mp->sw_if_index = ntohl (sw_if_index);
10564 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10565 mp->address_length = address_length;
10566 mp->use_default = use_default;
10567 mp->no_advertise = no_advertise;
10568 mp->off_link = off_link;
10569 mp->no_autoconfig = no_autoconfig;
10570 mp->no_onlink = no_onlink;
10572 mp->val_lifetime = ntohl (val_lifetime);
10573 mp->pref_lifetime = ntohl (pref_lifetime);
10578 /* Wait for a reply, return good/bad news */
10584 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
10586 unformat_input_t *i = vam->input;
10587 vl_api_sw_interface_ip6nd_ra_config_t *mp;
10589 u8 sw_if_index_set = 0;
10594 u8 send_unicast = 0;
10597 u8 default_router = 0;
10598 u32 max_interval = 0;
10599 u32 min_interval = 0;
10601 u32 initial_count = 0;
10602 u32 initial_interval = 0;
10606 /* Parse args required to build the message */
10607 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10609 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10610 sw_if_index_set = 1;
10611 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10612 sw_if_index_set = 1;
10613 else if (unformat (i, "maxint %d", &max_interval))
10615 else if (unformat (i, "minint %d", &min_interval))
10617 else if (unformat (i, "life %d", &lifetime))
10619 else if (unformat (i, "count %d", &initial_count))
10621 else if (unformat (i, "interval %d", &initial_interval))
10623 else if (unformat (i, "suppress") || unformat (i, "surpress"))
10625 else if (unformat (i, "managed"))
10627 else if (unformat (i, "other"))
10629 else if (unformat (i, "ll"))
10631 else if (unformat (i, "send"))
10633 else if (unformat (i, "cease"))
10635 else if (unformat (i, "isno"))
10637 else if (unformat (i, "def"))
10638 default_router = 1;
10641 clib_warning ("parse error '%U'", format_unformat_error, i);
10646 if (sw_if_index_set == 0)
10648 errmsg ("missing interface name or sw_if_index");
10652 /* Construct the API message */
10653 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
10655 mp->sw_if_index = ntohl (sw_if_index);
10656 mp->max_interval = ntohl (max_interval);
10657 mp->min_interval = ntohl (min_interval);
10658 mp->lifetime = ntohl (lifetime);
10659 mp->initial_count = ntohl (initial_count);
10660 mp->initial_interval = ntohl (initial_interval);
10661 mp->suppress = suppress;
10662 mp->managed = managed;
10664 mp->ll_option = ll_option;
10665 mp->send_unicast = send_unicast;
10668 mp->default_router = default_router;
10673 /* Wait for a reply, return good/bad news */
10679 api_set_arp_neighbor_limit (vat_main_t * vam)
10681 unformat_input_t *i = vam->input;
10682 vl_api_set_arp_neighbor_limit_t *mp;
10688 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10690 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
10692 else if (unformat (i, "ipv6"))
10696 clib_warning ("parse error '%U'", format_unformat_error, i);
10701 if (limit_set == 0)
10703 errmsg ("missing limit value");
10707 M (SET_ARP_NEIGHBOR_LIMIT, mp);
10709 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
10710 mp->is_ipv6 = is_ipv6;
10718 api_l2_patch_add_del (vat_main_t * vam)
10720 unformat_input_t *i = vam->input;
10721 vl_api_l2_patch_add_del_t *mp;
10722 u32 rx_sw_if_index;
10723 u8 rx_sw_if_index_set = 0;
10724 u32 tx_sw_if_index;
10725 u8 tx_sw_if_index_set = 0;
10729 /* Parse args required to build the message */
10730 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10732 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
10733 rx_sw_if_index_set = 1;
10734 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
10735 tx_sw_if_index_set = 1;
10736 else if (unformat (i, "rx"))
10738 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10740 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10742 rx_sw_if_index_set = 1;
10747 else if (unformat (i, "tx"))
10749 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10751 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10753 tx_sw_if_index_set = 1;
10758 else if (unformat (i, "del"))
10764 if (rx_sw_if_index_set == 0)
10766 errmsg ("missing rx interface name or rx_sw_if_index");
10770 if (tx_sw_if_index_set == 0)
10772 errmsg ("missing tx interface name or tx_sw_if_index");
10776 M (L2_PATCH_ADD_DEL, mp);
10778 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
10779 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
10780 mp->is_add = is_add;
10788 u8 localsid_addr[16];
10797 api_sr_localsid_add_del (vat_main_t * vam)
10799 unformat_input_t *i = vam->input;
10800 vl_api_sr_localsid_add_del_t *mp;
10803 ip6_address_t localsid;
10807 u32 fib_table = ~(u32) 0;
10808 ip6_address_t nh_addr6;
10809 ip4_address_t nh_addr4;
10810 memset (&nh_addr6, 0, sizeof (ip6_address_t));
10811 memset (&nh_addr4, 0, sizeof (ip4_address_t));
10813 bool nexthop_set = 0;
10817 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10819 if (unformat (i, "del"))
10821 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
10822 else if (unformat (i, "next-hop %U", unformat_ip4_address, &nh_addr4))
10824 else if (unformat (i, "next-hop %U", unformat_ip6_address, &nh_addr6))
10826 else if (unformat (i, "behavior %u", &behavior));
10827 else if (unformat (i, "sw_if_index %u", &sw_if_index));
10828 else if (unformat (i, "fib-table %u", &fib_table));
10829 else if (unformat (i, "end.psp %u", &behavior));
10834 M (SR_LOCALSID_ADD_DEL, mp);
10836 clib_memcpy (mp->localsid.addr, &localsid, sizeof (mp->localsid));
10839 clib_memcpy (mp->nh_addr6, &nh_addr6, sizeof (mp->nh_addr6));
10840 clib_memcpy (mp->nh_addr4, &nh_addr4, sizeof (mp->nh_addr4));
10842 mp->behavior = behavior;
10843 mp->sw_if_index = ntohl (sw_if_index);
10844 mp->fib_table = ntohl (fib_table);
10845 mp->end_psp = end_psp;
10846 mp->is_del = is_del;
10854 api_ioam_enable (vat_main_t * vam)
10856 unformat_input_t *input = vam->input;
10857 vl_api_ioam_enable_t *mp;
10859 int has_trace_option = 0;
10860 int has_pot_option = 0;
10861 int has_seqno_option = 0;
10862 int has_analyse_option = 0;
10865 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10867 if (unformat (input, "trace"))
10868 has_trace_option = 1;
10869 else if (unformat (input, "pot"))
10870 has_pot_option = 1;
10871 else if (unformat (input, "seqno"))
10872 has_seqno_option = 1;
10873 else if (unformat (input, "analyse"))
10874 has_analyse_option = 1;
10878 M (IOAM_ENABLE, mp);
10879 mp->id = htons (id);
10880 mp->seqno = has_seqno_option;
10881 mp->analyse = has_analyse_option;
10882 mp->pot_enable = has_pot_option;
10883 mp->trace_enable = has_trace_option;
10892 api_ioam_disable (vat_main_t * vam)
10894 vl_api_ioam_disable_t *mp;
10897 M (IOAM_DISABLE, mp);
10903 #define foreach_tcp_proto_field \
10907 #define foreach_udp_proto_field \
10911 #define foreach_ip4_proto_field \
10923 u16 src_port, dst_port;
10926 #if VPP_API_TEST_BUILTIN == 0
10928 unformat_tcp_mask (unformat_input_t * input, va_list * args)
10930 u8 **maskp = va_arg (*args, u8 **);
10932 u8 found_something = 0;
10935 #define _(a) u8 a=0;
10936 foreach_tcp_proto_field;
10939 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10942 #define _(a) else if (unformat (input, #a)) a=1;
10943 foreach_tcp_proto_field
10949 #define _(a) found_something += a;
10950 foreach_tcp_proto_field;
10953 if (found_something == 0)
10956 vec_validate (mask, sizeof (*tcp) - 1);
10958 tcp = (tcp_header_t *) mask;
10960 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
10961 foreach_tcp_proto_field;
10969 unformat_udp_mask (unformat_input_t * input, va_list * args)
10971 u8 **maskp = va_arg (*args, u8 **);
10973 u8 found_something = 0;
10976 #define _(a) u8 a=0;
10977 foreach_udp_proto_field;
10980 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10983 #define _(a) else if (unformat (input, #a)) a=1;
10984 foreach_udp_proto_field
10990 #define _(a) found_something += a;
10991 foreach_udp_proto_field;
10994 if (found_something == 0)
10997 vec_validate (mask, sizeof (*udp) - 1);
10999 udp = (udp_header_t *) mask;
11001 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
11002 foreach_udp_proto_field;
11010 unformat_l4_mask (unformat_input_t * input, va_list * args)
11012 u8 **maskp = va_arg (*args, u8 **);
11013 u16 src_port = 0, dst_port = 0;
11014 tcpudp_header_t *tcpudp;
11016 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11018 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
11020 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
11022 else if (unformat (input, "src_port"))
11024 else if (unformat (input, "dst_port"))
11030 if (!src_port && !dst_port)
11034 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
11036 tcpudp = (tcpudp_header_t *) mask;
11037 tcpudp->src_port = src_port;
11038 tcpudp->dst_port = dst_port;
11046 unformat_ip4_mask (unformat_input_t * input, va_list * args)
11048 u8 **maskp = va_arg (*args, u8 **);
11050 u8 found_something = 0;
11053 #define _(a) u8 a=0;
11054 foreach_ip4_proto_field;
11060 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11062 if (unformat (input, "version"))
11064 else if (unformat (input, "hdr_length"))
11066 else if (unformat (input, "src"))
11068 else if (unformat (input, "dst"))
11070 else if (unformat (input, "proto"))
11073 #define _(a) else if (unformat (input, #a)) a=1;
11074 foreach_ip4_proto_field
11080 #define _(a) found_something += a;
11081 foreach_ip4_proto_field;
11084 if (found_something == 0)
11087 vec_validate (mask, sizeof (*ip) - 1);
11089 ip = (ip4_header_t *) mask;
11091 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
11092 foreach_ip4_proto_field;
11095 ip->ip_version_and_header_length = 0;
11098 ip->ip_version_and_header_length |= 0xF0;
11101 ip->ip_version_and_header_length |= 0x0F;
11107 #define foreach_ip6_proto_field \
11110 _(payload_length) \
11115 unformat_ip6_mask (unformat_input_t * input, va_list * args)
11117 u8 **maskp = va_arg (*args, u8 **);
11119 u8 found_something = 0;
11121 u32 ip_version_traffic_class_and_flow_label;
11123 #define _(a) u8 a=0;
11124 foreach_ip6_proto_field;
11127 u8 traffic_class = 0;
11130 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11132 if (unformat (input, "version"))
11134 else if (unformat (input, "traffic-class"))
11136 else if (unformat (input, "flow-label"))
11138 else if (unformat (input, "src"))
11140 else if (unformat (input, "dst"))
11142 else if (unformat (input, "proto"))
11145 #define _(a) else if (unformat (input, #a)) a=1;
11146 foreach_ip6_proto_field
11152 #define _(a) found_something += a;
11153 foreach_ip6_proto_field;
11156 if (found_something == 0)
11159 vec_validate (mask, sizeof (*ip) - 1);
11161 ip = (ip6_header_t *) mask;
11163 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
11164 foreach_ip6_proto_field;
11167 ip_version_traffic_class_and_flow_label = 0;
11170 ip_version_traffic_class_and_flow_label |= 0xF0000000;
11173 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
11176 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
11178 ip->ip_version_traffic_class_and_flow_label =
11179 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11186 unformat_l3_mask (unformat_input_t * input, va_list * args)
11188 u8 **maskp = va_arg (*args, u8 **);
11190 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11192 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
11194 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
11203 unformat_l2_mask (unformat_input_t * input, va_list * args)
11205 u8 **maskp = va_arg (*args, u8 **);
11212 u8 ignore_tag1 = 0;
11213 u8 ignore_tag2 = 0;
11220 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11222 if (unformat (input, "src"))
11224 else if (unformat (input, "dst"))
11226 else if (unformat (input, "proto"))
11228 else if (unformat (input, "tag1"))
11230 else if (unformat (input, "tag2"))
11232 else if (unformat (input, "ignore-tag1"))
11234 else if (unformat (input, "ignore-tag2"))
11236 else if (unformat (input, "cos1"))
11238 else if (unformat (input, "cos2"))
11240 else if (unformat (input, "dot1q"))
11242 else if (unformat (input, "dot1ad"))
11247 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
11248 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11251 if (tag1 || ignore_tag1 || cos1 || dot1q)
11253 if (tag2 || ignore_tag2 || cos2 || dot1ad)
11256 vec_validate (mask, len - 1);
11259 memset (mask, 0xff, 6);
11262 memset (mask + 6, 0xff, 6);
11264 if (tag2 || dot1ad)
11266 /* inner vlan tag */
11275 mask[21] = mask[20] = 0xff;
11296 mask[16] = mask[17] = 0xff;
11306 mask[12] = mask[13] = 0xff;
11313 unformat_classify_mask (unformat_input_t * input, va_list * args)
11315 u8 **maskp = va_arg (*args, u8 **);
11316 u32 *skipp = va_arg (*args, u32 *);
11317 u32 *matchp = va_arg (*args, u32 *);
11325 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11327 if (unformat (input, "hex %U", unformat_hex_string, &mask))
11329 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
11331 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
11333 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
11347 if (mask || l2 || l3 || l4)
11349 if (l2 || l3 || l4)
11351 /* "With a free Ethernet header in every package" */
11353 vec_validate (l2, 13);
11357 vec_append (mask, l3);
11362 vec_append (mask, l4);
11367 /* Scan forward looking for the first significant mask octet */
11368 for (i = 0; i < vec_len (mask); i++)
11372 /* compute (skip, match) params */
11373 *skipp = i / sizeof (u32x4);
11374 vec_delete (mask, *skipp * sizeof (u32x4), 0);
11376 /* Pad mask to an even multiple of the vector size */
11377 while (vec_len (mask) % sizeof (u32x4))
11378 vec_add1 (mask, 0);
11380 match = vec_len (mask) / sizeof (u32x4);
11382 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
11384 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
11385 if (*tmp || *(tmp + 1))
11390 clib_warning ("BUG: match 0");
11392 _vec_len (mask) = match * sizeof (u32x4);
11402 #endif /* VPP_API_TEST_BUILTIN */
11404 #define foreach_l2_next \
11406 _(ethernet, ETHERNET_INPUT) \
11407 _(ip4, IP4_INPUT) \
11411 unformat_l2_next_index (unformat_input_t * input, va_list * args)
11413 u32 *miss_next_indexp = va_arg (*args, u32 *);
11414 u32 next_index = 0;
11418 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
11422 if (unformat (input, "%d", &tmp))
11431 *miss_next_indexp = next_index;
11435 #define foreach_ip_next \
11438 _(rewrite, REWRITE)
11441 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
11443 u32 *miss_next_indexp = va_arg (*args, u32 *);
11444 u32 next_index = 0;
11448 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
11452 if (unformat (input, "%d", &tmp))
11461 *miss_next_indexp = next_index;
11465 #define foreach_acl_next \
11469 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
11471 u32 *miss_next_indexp = va_arg (*args, u32 *);
11472 u32 next_index = 0;
11476 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
11480 if (unformat (input, "permit"))
11485 else if (unformat (input, "%d", &tmp))
11494 *miss_next_indexp = next_index;
11499 unformat_policer_precolor (unformat_input_t * input, va_list * args)
11501 u32 *r = va_arg (*args, u32 *);
11503 if (unformat (input, "conform-color"))
11504 *r = POLICE_CONFORM;
11505 else if (unformat (input, "exceed-color"))
11506 *r = POLICE_EXCEED;
11514 api_classify_add_del_table (vat_main_t * vam)
11516 unformat_input_t *i = vam->input;
11517 vl_api_classify_add_del_table_t *mp;
11524 u32 table_index = ~0;
11525 u32 next_table_index = ~0;
11526 u32 miss_next_index = ~0;
11527 u32 memory_size = 32 << 20;
11529 u32 current_data_flag = 0;
11530 int current_data_offset = 0;
11533 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11535 if (unformat (i, "del"))
11537 else if (unformat (i, "del-chain"))
11542 else if (unformat (i, "buckets %d", &nbuckets))
11544 else if (unformat (i, "memory_size %d", &memory_size))
11546 else if (unformat (i, "skip %d", &skip))
11548 else if (unformat (i, "match %d", &match))
11550 else if (unformat (i, "table %d", &table_index))
11552 else if (unformat (i, "mask %U", unformat_classify_mask,
11553 &mask, &skip, &match))
11555 else if (unformat (i, "next-table %d", &next_table_index))
11557 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
11560 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
11563 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
11566 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
11568 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
11574 if (is_add && mask == 0)
11576 errmsg ("Mask required");
11580 if (is_add && skip == ~0)
11582 errmsg ("skip count required");
11586 if (is_add && match == ~0)
11588 errmsg ("match count required");
11592 if (!is_add && table_index == ~0)
11594 errmsg ("table index required for delete");
11598 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
11600 mp->is_add = is_add;
11601 mp->del_chain = del_chain;
11602 mp->table_index = ntohl (table_index);
11603 mp->nbuckets = ntohl (nbuckets);
11604 mp->memory_size = ntohl (memory_size);
11605 mp->skip_n_vectors = ntohl (skip);
11606 mp->match_n_vectors = ntohl (match);
11607 mp->next_table_index = ntohl (next_table_index);
11608 mp->miss_next_index = ntohl (miss_next_index);
11609 mp->current_data_flag = ntohl (current_data_flag);
11610 mp->current_data_offset = ntohl (current_data_offset);
11611 mp->mask_len = ntohl (vec_len (mask));
11612 clib_memcpy (mp->mask, mask, vec_len (mask));
11621 #if VPP_API_TEST_BUILTIN == 0
11623 unformat_l4_match (unformat_input_t * input, va_list * args)
11625 u8 **matchp = va_arg (*args, u8 **);
11627 u8 *proto_header = 0;
11633 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11635 if (unformat (input, "src_port %d", &src_port))
11637 else if (unformat (input, "dst_port %d", &dst_port))
11643 h.src_port = clib_host_to_net_u16 (src_port);
11644 h.dst_port = clib_host_to_net_u16 (dst_port);
11645 vec_validate (proto_header, sizeof (h) - 1);
11646 memcpy (proto_header, &h, sizeof (h));
11648 *matchp = proto_header;
11654 unformat_ip4_match (unformat_input_t * input, va_list * args)
11656 u8 **matchp = va_arg (*args, u8 **);
11661 int hdr_length = 0;
11662 u32 hdr_length_val;
11663 int src = 0, dst = 0;
11664 ip4_address_t src_val, dst_val;
11671 int fragment_id = 0;
11672 u32 fragment_id_val;
11678 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11680 if (unformat (input, "version %d", &version_val))
11682 else if (unformat (input, "hdr_length %d", &hdr_length_val))
11684 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
11686 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
11688 else if (unformat (input, "proto %d", &proto_val))
11690 else if (unformat (input, "tos %d", &tos_val))
11692 else if (unformat (input, "length %d", &length_val))
11694 else if (unformat (input, "fragment_id %d", &fragment_id_val))
11696 else if (unformat (input, "ttl %d", &ttl_val))
11698 else if (unformat (input, "checksum %d", &checksum_val))
11704 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
11705 + ttl + checksum == 0)
11709 * Aligned because we use the real comparison functions
11711 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11713 ip = (ip4_header_t *) match;
11715 /* These are realistically matched in practice */
11717 ip->src_address.as_u32 = src_val.as_u32;
11720 ip->dst_address.as_u32 = dst_val.as_u32;
11723 ip->protocol = proto_val;
11726 /* These are not, but they're included for completeness */
11728 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
11731 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
11737 ip->length = clib_host_to_net_u16 (length_val);
11743 ip->checksum = clib_host_to_net_u16 (checksum_val);
11750 unformat_ip6_match (unformat_input_t * input, va_list * args)
11752 u8 **matchp = va_arg (*args, u8 **);
11757 u8 traffic_class = 0;
11758 u32 traffic_class_val = 0;
11761 int src = 0, dst = 0;
11762 ip6_address_t src_val, dst_val;
11765 int payload_length = 0;
11766 u32 payload_length_val;
11769 u32 ip_version_traffic_class_and_flow_label;
11771 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11773 if (unformat (input, "version %d", &version_val))
11775 else if (unformat (input, "traffic_class %d", &traffic_class_val))
11777 else if (unformat (input, "flow_label %d", &flow_label_val))
11779 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
11781 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
11783 else if (unformat (input, "proto %d", &proto_val))
11785 else if (unformat (input, "payload_length %d", &payload_length_val))
11786 payload_length = 1;
11787 else if (unformat (input, "hop_limit %d", &hop_limit_val))
11793 if (version + traffic_class + flow_label + src + dst + proto +
11794 payload_length + hop_limit == 0)
11798 * Aligned because we use the real comparison functions
11800 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11802 ip = (ip6_header_t *) match;
11805 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
11808 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
11811 ip->protocol = proto_val;
11813 ip_version_traffic_class_and_flow_label = 0;
11816 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
11819 ip_version_traffic_class_and_flow_label |=
11820 (traffic_class_val & 0xFF) << 20;
11823 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
11825 ip->ip_version_traffic_class_and_flow_label =
11826 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11828 if (payload_length)
11829 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
11832 ip->hop_limit = hop_limit_val;
11839 unformat_l3_match (unformat_input_t * input, va_list * args)
11841 u8 **matchp = va_arg (*args, u8 **);
11843 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11845 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
11847 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
11856 unformat_vlan_tag (unformat_input_t * input, va_list * args)
11858 u8 *tagp = va_arg (*args, u8 *);
11861 if (unformat (input, "%d", &tag))
11863 tagp[0] = (tag >> 8) & 0x0F;
11864 tagp[1] = tag & 0xFF;
11872 unformat_l2_match (unformat_input_t * input, va_list * args)
11874 u8 **matchp = va_arg (*args, u8 **);
11887 u8 ignore_tag1 = 0;
11888 u8 ignore_tag2 = 0;
11894 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11896 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
11899 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
11901 else if (unformat (input, "proto %U",
11902 unformat_ethernet_type_host_byte_order, &proto_val))
11904 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
11906 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
11908 else if (unformat (input, "ignore-tag1"))
11910 else if (unformat (input, "ignore-tag2"))
11912 else if (unformat (input, "cos1 %d", &cos1_val))
11914 else if (unformat (input, "cos2 %d", &cos2_val))
11919 if ((src + dst + proto + tag1 + tag2 +
11920 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11923 if (tag1 || ignore_tag1 || cos1)
11925 if (tag2 || ignore_tag2 || cos2)
11928 vec_validate_aligned (match, len - 1, sizeof (u32x4));
11931 clib_memcpy (match, dst_val, 6);
11934 clib_memcpy (match + 6, src_val, 6);
11938 /* inner vlan tag */
11939 match[19] = tag2_val[1];
11940 match[18] = tag2_val[0];
11942 match[18] |= (cos2_val & 0x7) << 5;
11945 match[21] = proto_val & 0xff;
11946 match[20] = proto_val >> 8;
11950 match[15] = tag1_val[1];
11951 match[14] = tag1_val[0];
11954 match[14] |= (cos1_val & 0x7) << 5;
11960 match[15] = tag1_val[1];
11961 match[14] = tag1_val[0];
11964 match[17] = proto_val & 0xff;
11965 match[16] = proto_val >> 8;
11968 match[14] |= (cos1_val & 0x7) << 5;
11974 match[18] |= (cos2_val & 0x7) << 5;
11976 match[14] |= (cos1_val & 0x7) << 5;
11979 match[13] = proto_val & 0xff;
11980 match[12] = proto_val >> 8;
11988 unformat_qos_source (unformat_input_t * input, va_list * args)
11990 int *qs = va_arg (*args, int *);
11992 if (unformat (input, "ip"))
11993 *qs = QOS_SOURCE_IP;
11994 else if (unformat (input, "mpls"))
11995 *qs = QOS_SOURCE_MPLS;
11996 else if (unformat (input, "ext"))
11997 *qs = QOS_SOURCE_EXT;
11998 else if (unformat (input, "vlan"))
11999 *qs = QOS_SOURCE_VLAN;
12008 api_unformat_classify_match (unformat_input_t * input, va_list * args)
12010 u8 **matchp = va_arg (*args, u8 **);
12011 u32 skip_n_vectors = va_arg (*args, u32);
12012 u32 match_n_vectors = va_arg (*args, u32);
12019 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12021 if (unformat (input, "hex %U", unformat_hex_string, &match))
12023 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
12025 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
12027 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
12041 if (match || l2 || l3 || l4)
12043 if (l2 || l3 || l4)
12045 /* "Win a free Ethernet header in every packet" */
12047 vec_validate_aligned (l2, 13, sizeof (u32x4));
12051 vec_append_aligned (match, l3, sizeof (u32x4));
12056 vec_append_aligned (match, l4, sizeof (u32x4));
12061 /* Make sure the vector is big enough even if key is all 0's */
12062 vec_validate_aligned
12063 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
12066 /* Set size, include skipped vectors */
12067 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
12078 api_classify_add_del_session (vat_main_t * vam)
12080 unformat_input_t *i = vam->input;
12081 vl_api_classify_add_del_session_t *mp;
12083 u32 table_index = ~0;
12084 u32 hit_next_index = ~0;
12085 u32 opaque_index = ~0;
12088 u32 skip_n_vectors = 0;
12089 u32 match_n_vectors = 0;
12095 * Warning: you have to supply skip_n and match_n
12096 * because the API client cant simply look at the classify
12100 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12102 if (unformat (i, "del"))
12104 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
12107 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
12110 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
12113 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
12115 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
12117 else if (unformat (i, "opaque-index %d", &opaque_index))
12119 else if (unformat (i, "skip_n %d", &skip_n_vectors))
12121 else if (unformat (i, "match_n %d", &match_n_vectors))
12123 else if (unformat (i, "match %U", api_unformat_classify_match,
12124 &match, skip_n_vectors, match_n_vectors))
12126 else if (unformat (i, "advance %d", &advance))
12128 else if (unformat (i, "table-index %d", &table_index))
12130 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
12132 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
12134 else if (unformat (i, "action %d", &action))
12136 else if (unformat (i, "metadata %d", &metadata))
12142 if (table_index == ~0)
12144 errmsg ("Table index required");
12148 if (is_add && match == 0)
12150 errmsg ("Match value required");
12154 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
12156 mp->is_add = is_add;
12157 mp->table_index = ntohl (table_index);
12158 mp->hit_next_index = ntohl (hit_next_index);
12159 mp->opaque_index = ntohl (opaque_index);
12160 mp->advance = ntohl (advance);
12161 mp->action = action;
12162 mp->metadata = ntohl (metadata);
12163 mp->match_len = ntohl (vec_len (match));
12164 clib_memcpy (mp->match, match, vec_len (match));
12173 api_classify_set_interface_ip_table (vat_main_t * vam)
12175 unformat_input_t *i = vam->input;
12176 vl_api_classify_set_interface_ip_table_t *mp;
12178 int sw_if_index_set;
12179 u32 table_index = ~0;
12183 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12185 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12186 sw_if_index_set = 1;
12187 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12188 sw_if_index_set = 1;
12189 else if (unformat (i, "table %d", &table_index))
12193 clib_warning ("parse error '%U'", format_unformat_error, i);
12198 if (sw_if_index_set == 0)
12200 errmsg ("missing interface name or sw_if_index");
12205 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
12207 mp->sw_if_index = ntohl (sw_if_index);
12208 mp->table_index = ntohl (table_index);
12209 mp->is_ipv6 = is_ipv6;
12217 api_classify_set_interface_l2_tables (vat_main_t * vam)
12219 unformat_input_t *i = vam->input;
12220 vl_api_classify_set_interface_l2_tables_t *mp;
12222 int sw_if_index_set;
12223 u32 ip4_table_index = ~0;
12224 u32 ip6_table_index = ~0;
12225 u32 other_table_index = ~0;
12229 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12231 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12232 sw_if_index_set = 1;
12233 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12234 sw_if_index_set = 1;
12235 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12237 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12239 else if (unformat (i, "other-table %d", &other_table_index))
12241 else if (unformat (i, "is-input %d", &is_input))
12245 clib_warning ("parse error '%U'", format_unformat_error, i);
12250 if (sw_if_index_set == 0)
12252 errmsg ("missing interface name or sw_if_index");
12257 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
12259 mp->sw_if_index = ntohl (sw_if_index);
12260 mp->ip4_table_index = ntohl (ip4_table_index);
12261 mp->ip6_table_index = ntohl (ip6_table_index);
12262 mp->other_table_index = ntohl (other_table_index);
12263 mp->is_input = (u8) is_input;
12271 api_set_ipfix_exporter (vat_main_t * vam)
12273 unformat_input_t *i = vam->input;
12274 vl_api_set_ipfix_exporter_t *mp;
12275 ip4_address_t collector_address;
12276 u8 collector_address_set = 0;
12277 u32 collector_port = ~0;
12278 ip4_address_t src_address;
12279 u8 src_address_set = 0;
12282 u32 template_interval = ~0;
12283 u8 udp_checksum = 0;
12286 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12288 if (unformat (i, "collector_address %U", unformat_ip4_address,
12289 &collector_address))
12290 collector_address_set = 1;
12291 else if (unformat (i, "collector_port %d", &collector_port))
12293 else if (unformat (i, "src_address %U", unformat_ip4_address,
12295 src_address_set = 1;
12296 else if (unformat (i, "vrf_id %d", &vrf_id))
12298 else if (unformat (i, "path_mtu %d", &path_mtu))
12300 else if (unformat (i, "template_interval %d", &template_interval))
12302 else if (unformat (i, "udp_checksum"))
12308 if (collector_address_set == 0)
12310 errmsg ("collector_address required");
12314 if (src_address_set == 0)
12316 errmsg ("src_address required");
12320 M (SET_IPFIX_EXPORTER, mp);
12322 memcpy (mp->collector_address, collector_address.data,
12323 sizeof (collector_address.data));
12324 mp->collector_port = htons ((u16) collector_port);
12325 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
12326 mp->vrf_id = htonl (vrf_id);
12327 mp->path_mtu = htonl (path_mtu);
12328 mp->template_interval = htonl (template_interval);
12329 mp->udp_checksum = udp_checksum;
12337 api_set_ipfix_classify_stream (vat_main_t * vam)
12339 unformat_input_t *i = vam->input;
12340 vl_api_set_ipfix_classify_stream_t *mp;
12342 u32 src_port = UDP_DST_PORT_ipfix;
12345 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12347 if (unformat (i, "domain %d", &domain_id))
12349 else if (unformat (i, "src_port %d", &src_port))
12353 errmsg ("unknown input `%U'", format_unformat_error, i);
12358 M (SET_IPFIX_CLASSIFY_STREAM, mp);
12360 mp->domain_id = htonl (domain_id);
12361 mp->src_port = htons ((u16) src_port);
12369 api_ipfix_classify_table_add_del (vat_main_t * vam)
12371 unformat_input_t *i = vam->input;
12372 vl_api_ipfix_classify_table_add_del_t *mp;
12374 u32 classify_table_index = ~0;
12376 u8 transport_protocol = 255;
12379 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12381 if (unformat (i, "add"))
12383 else if (unformat (i, "del"))
12385 else if (unformat (i, "table %d", &classify_table_index))
12387 else if (unformat (i, "ip4"))
12389 else if (unformat (i, "ip6"))
12391 else if (unformat (i, "tcp"))
12392 transport_protocol = 6;
12393 else if (unformat (i, "udp"))
12394 transport_protocol = 17;
12397 errmsg ("unknown input `%U'", format_unformat_error, i);
12404 errmsg ("expecting: add|del");
12407 if (classify_table_index == ~0)
12409 errmsg ("classifier table not specified");
12412 if (ip_version == 0)
12414 errmsg ("IP version not specified");
12418 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
12420 mp->is_add = is_add;
12421 mp->table_id = htonl (classify_table_index);
12422 mp->ip_version = ip_version;
12423 mp->transport_protocol = transport_protocol;
12431 api_get_node_index (vat_main_t * vam)
12433 unformat_input_t *i = vam->input;
12434 vl_api_get_node_index_t *mp;
12438 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12440 if (unformat (i, "node %s", &name))
12447 errmsg ("node name required");
12450 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12452 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12456 M (GET_NODE_INDEX, mp);
12457 clib_memcpy (mp->node_name, name, vec_len (name));
12466 api_get_next_index (vat_main_t * vam)
12468 unformat_input_t *i = vam->input;
12469 vl_api_get_next_index_t *mp;
12470 u8 *node_name = 0, *next_node_name = 0;
12473 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12475 if (unformat (i, "node-name %s", &node_name))
12477 else if (unformat (i, "next-node-name %s", &next_node_name))
12481 if (node_name == 0)
12483 errmsg ("node name required");
12486 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
12488 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12492 if (next_node_name == 0)
12494 errmsg ("next node name required");
12497 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
12499 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
12503 M (GET_NEXT_INDEX, mp);
12504 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
12505 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
12506 vec_free (node_name);
12507 vec_free (next_node_name);
12515 api_add_node_next (vat_main_t * vam)
12517 unformat_input_t *i = vam->input;
12518 vl_api_add_node_next_t *mp;
12523 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12525 if (unformat (i, "node %s", &name))
12527 else if (unformat (i, "next %s", &next))
12534 errmsg ("node name required");
12537 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12539 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12544 errmsg ("next node required");
12547 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
12549 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
12553 M (ADD_NODE_NEXT, mp);
12554 clib_memcpy (mp->node_name, name, vec_len (name));
12555 clib_memcpy (mp->next_name, next, vec_len (next));
12565 api_l2tpv3_create_tunnel (vat_main_t * vam)
12567 unformat_input_t *i = vam->input;
12568 ip6_address_t client_address, our_address;
12569 int client_address_set = 0;
12570 int our_address_set = 0;
12571 u32 local_session_id = 0;
12572 u32 remote_session_id = 0;
12573 u64 local_cookie = 0;
12574 u64 remote_cookie = 0;
12575 u8 l2_sublayer_present = 0;
12576 vl_api_l2tpv3_create_tunnel_t *mp;
12579 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12581 if (unformat (i, "client_address %U", unformat_ip6_address,
12583 client_address_set = 1;
12584 else if (unformat (i, "our_address %U", unformat_ip6_address,
12586 our_address_set = 1;
12587 else if (unformat (i, "local_session_id %d", &local_session_id))
12589 else if (unformat (i, "remote_session_id %d", &remote_session_id))
12591 else if (unformat (i, "local_cookie %lld", &local_cookie))
12593 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
12595 else if (unformat (i, "l2-sublayer-present"))
12596 l2_sublayer_present = 1;
12601 if (client_address_set == 0)
12603 errmsg ("client_address required");
12607 if (our_address_set == 0)
12609 errmsg ("our_address required");
12613 M (L2TPV3_CREATE_TUNNEL, mp);
12615 clib_memcpy (mp->client_address, client_address.as_u8,
12616 sizeof (mp->client_address));
12618 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
12620 mp->local_session_id = ntohl (local_session_id);
12621 mp->remote_session_id = ntohl (remote_session_id);
12622 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
12623 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
12624 mp->l2_sublayer_present = l2_sublayer_present;
12633 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
12635 unformat_input_t *i = vam->input;
12637 u8 sw_if_index_set = 0;
12638 u64 new_local_cookie = 0;
12639 u64 new_remote_cookie = 0;
12640 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
12643 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12645 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12646 sw_if_index_set = 1;
12647 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12648 sw_if_index_set = 1;
12649 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
12651 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
12657 if (sw_if_index_set == 0)
12659 errmsg ("missing interface name or sw_if_index");
12663 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
12665 mp->sw_if_index = ntohl (sw_if_index);
12666 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
12667 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
12675 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
12677 unformat_input_t *i = vam->input;
12678 vl_api_l2tpv3_interface_enable_disable_t *mp;
12680 u8 sw_if_index_set = 0;
12681 u8 enable_disable = 1;
12684 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12686 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12687 sw_if_index_set = 1;
12688 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12689 sw_if_index_set = 1;
12690 else if (unformat (i, "enable"))
12691 enable_disable = 1;
12692 else if (unformat (i, "disable"))
12693 enable_disable = 0;
12698 if (sw_if_index_set == 0)
12700 errmsg ("missing interface name or sw_if_index");
12704 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
12706 mp->sw_if_index = ntohl (sw_if_index);
12707 mp->enable_disable = enable_disable;
12715 api_l2tpv3_set_lookup_key (vat_main_t * vam)
12717 unformat_input_t *i = vam->input;
12718 vl_api_l2tpv3_set_lookup_key_t *mp;
12722 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12724 if (unformat (i, "lookup_v6_src"))
12725 key = L2T_LOOKUP_SRC_ADDRESS;
12726 else if (unformat (i, "lookup_v6_dst"))
12727 key = L2T_LOOKUP_DST_ADDRESS;
12728 else if (unformat (i, "lookup_session_id"))
12729 key = L2T_LOOKUP_SESSION_ID;
12734 if (key == (u8) ~ 0)
12736 errmsg ("l2tp session lookup key unset");
12740 M (L2TPV3_SET_LOOKUP_KEY, mp);
12749 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
12750 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12752 vat_main_t *vam = &vat_main;
12754 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
12755 format_ip6_address, mp->our_address,
12756 format_ip6_address, mp->client_address,
12757 clib_net_to_host_u32 (mp->sw_if_index));
12760 " local cookies %016llx %016llx remote cookie %016llx",
12761 clib_net_to_host_u64 (mp->local_cookie[0]),
12762 clib_net_to_host_u64 (mp->local_cookie[1]),
12763 clib_net_to_host_u64 (mp->remote_cookie));
12765 print (vam->ofp, " local session-id %d remote session-id %d",
12766 clib_net_to_host_u32 (mp->local_session_id),
12767 clib_net_to_host_u32 (mp->remote_session_id));
12769 print (vam->ofp, " l2 specific sublayer %s\n",
12770 mp->l2_sublayer_present ? "preset" : "absent");
12774 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
12775 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12777 vat_main_t *vam = &vat_main;
12778 vat_json_node_t *node = NULL;
12779 struct in6_addr addr;
12781 if (VAT_JSON_ARRAY != vam->json_tree.type)
12783 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12784 vat_json_init_array (&vam->json_tree);
12786 node = vat_json_array_add (&vam->json_tree);
12788 vat_json_init_object (node);
12790 clib_memcpy (&addr, mp->our_address, sizeof (addr));
12791 vat_json_object_add_ip6 (node, "our_address", addr);
12792 clib_memcpy (&addr, mp->client_address, sizeof (addr));
12793 vat_json_object_add_ip6 (node, "client_address", addr);
12795 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
12796 vat_json_init_array (lc);
12797 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
12798 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
12799 vat_json_object_add_uint (node, "remote_cookie",
12800 clib_net_to_host_u64 (mp->remote_cookie));
12802 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
12803 vat_json_object_add_uint (node, "local_session_id",
12804 clib_net_to_host_u32 (mp->local_session_id));
12805 vat_json_object_add_uint (node, "remote_session_id",
12806 clib_net_to_host_u32 (mp->remote_session_id));
12807 vat_json_object_add_string_copy (node, "l2_sublayer",
12808 mp->l2_sublayer_present ? (u8 *) "present"
12809 : (u8 *) "absent");
12813 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
12815 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
12816 vl_api_control_ping_t *mp_ping;
12819 /* Get list of l2tpv3-tunnel interfaces */
12820 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
12823 /* Use a control ping for synchronization */
12824 MPING (CONTROL_PING, mp_ping);
12832 static void vl_api_sw_interface_tap_details_t_handler
12833 (vl_api_sw_interface_tap_details_t * mp)
12835 vat_main_t *vam = &vat_main;
12837 print (vam->ofp, "%-16s %d",
12838 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
12841 static void vl_api_sw_interface_tap_details_t_handler_json
12842 (vl_api_sw_interface_tap_details_t * mp)
12844 vat_main_t *vam = &vat_main;
12845 vat_json_node_t *node = NULL;
12847 if (VAT_JSON_ARRAY != vam->json_tree.type)
12849 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12850 vat_json_init_array (&vam->json_tree);
12852 node = vat_json_array_add (&vam->json_tree);
12854 vat_json_init_object (node);
12855 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12856 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12860 api_sw_interface_tap_dump (vat_main_t * vam)
12862 vl_api_sw_interface_tap_dump_t *mp;
12863 vl_api_control_ping_t *mp_ping;
12866 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
12867 /* Get list of tap interfaces */
12868 M (SW_INTERFACE_TAP_DUMP, mp);
12871 /* Use a control ping for synchronization */
12872 MPING (CONTROL_PING, mp_ping);
12879 static void vl_api_sw_interface_tap_v2_details_t_handler
12880 (vl_api_sw_interface_tap_v2_details_t * mp)
12882 vat_main_t *vam = &vat_main;
12884 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
12885 mp->host_ip4_prefix_len);
12886 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
12887 mp->host_ip6_prefix_len);
12890 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s",
12891 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
12892 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12893 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
12894 mp->host_bridge, ip4, ip6);
12900 static void vl_api_sw_interface_tap_v2_details_t_handler_json
12901 (vl_api_sw_interface_tap_v2_details_t * mp)
12903 vat_main_t *vam = &vat_main;
12904 vat_json_node_t *node = NULL;
12906 if (VAT_JSON_ARRAY != vam->json_tree.type)
12908 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12909 vat_json_init_array (&vam->json_tree);
12911 node = vat_json_array_add (&vam->json_tree);
12913 vat_json_init_object (node);
12914 vat_json_object_add_uint (node, "id", ntohl (mp->id));
12915 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12916 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12917 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12918 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12919 vat_json_object_add_string_copy (node, "host_mac_addr",
12920 format (0, "%U", format_ethernet_address,
12921 &mp->host_mac_addr));
12922 vat_json_object_add_string_copy (node, "host_namespace",
12923 mp->host_namespace);
12924 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
12925 vat_json_object_add_string_copy (node, "host_ip4_addr",
12926 format (0, "%U/%d", format_ip4_address,
12928 mp->host_ip4_prefix_len));
12929 vat_json_object_add_string_copy (node, "host_ip6_addr",
12930 format (0, "%U/%d", format_ip6_address,
12932 mp->host_ip6_prefix_len));
12937 api_sw_interface_tap_v2_dump (vat_main_t * vam)
12939 vl_api_sw_interface_tap_v2_dump_t *mp;
12940 vl_api_control_ping_t *mp_ping;
12944 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
12945 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
12946 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
12949 /* Get list of tap interfaces */
12950 M (SW_INTERFACE_TAP_V2_DUMP, mp);
12953 /* Use a control ping for synchronization */
12954 MPING (CONTROL_PING, mp_ping);
12962 api_vxlan_offload_rx (vat_main_t * vam)
12964 unformat_input_t *line_input = vam->input;
12965 vl_api_vxlan_offload_rx_t *mp;
12966 u32 hw_if_index = ~0, rx_if_index = ~0;
12970 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12972 if (unformat (line_input, "del"))
12974 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
12977 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
12979 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
12982 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
12986 errmsg ("parse error '%U'", format_unformat_error, line_input);
12991 if (hw_if_index == ~0)
12993 errmsg ("no hw interface");
12997 if (rx_if_index == ~0)
12999 errmsg ("no rx tunnel");
13003 M (VXLAN_OFFLOAD_RX, mp);
13005 mp->hw_if_index = ntohl (hw_if_index);
13006 mp->sw_if_index = ntohl (rx_if_index);
13007 mp->enable = is_add;
13014 static uword unformat_vxlan_decap_next
13015 (unformat_input_t * input, va_list * args)
13017 u32 *result = va_arg (*args, u32 *);
13020 if (unformat (input, "l2"))
13021 *result = VXLAN_INPUT_NEXT_L2_INPUT;
13022 else if (unformat (input, "%d", &tmp))
13030 api_vxlan_add_del_tunnel (vat_main_t * vam)
13032 unformat_input_t *line_input = vam->input;
13033 vl_api_vxlan_add_del_tunnel_t *mp;
13034 ip46_address_t src, dst;
13036 u8 ipv4_set = 0, ipv6_set = 0;
13041 u32 mcast_sw_if_index = ~0;
13042 u32 encap_vrf_id = 0;
13043 u32 decap_next_index = ~0;
13047 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13048 memset (&src, 0, sizeof src);
13049 memset (&dst, 0, sizeof dst);
13051 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13053 if (unformat (line_input, "del"))
13055 else if (unformat (line_input, "instance %d", &instance))
13058 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13064 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13070 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13076 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13081 else if (unformat (line_input, "group %U %U",
13082 unformat_ip4_address, &dst.ip4,
13083 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13085 grp_set = dst_set = 1;
13088 else if (unformat (line_input, "group %U",
13089 unformat_ip4_address, &dst.ip4))
13091 grp_set = dst_set = 1;
13094 else if (unformat (line_input, "group %U %U",
13095 unformat_ip6_address, &dst.ip6,
13096 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13098 grp_set = dst_set = 1;
13101 else if (unformat (line_input, "group %U",
13102 unformat_ip6_address, &dst.ip6))
13104 grp_set = dst_set = 1;
13108 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13110 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13112 else if (unformat (line_input, "decap-next %U",
13113 unformat_vxlan_decap_next, &decap_next_index))
13115 else if (unformat (line_input, "vni %d", &vni))
13119 errmsg ("parse error '%U'", format_unformat_error, line_input);
13126 errmsg ("tunnel src address not specified");
13131 errmsg ("tunnel dst address not specified");
13135 if (grp_set && !ip46_address_is_multicast (&dst))
13137 errmsg ("tunnel group address not multicast");
13140 if (grp_set && mcast_sw_if_index == ~0)
13142 errmsg ("tunnel nonexistent multicast device");
13145 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13147 errmsg ("tunnel dst address must be unicast");
13152 if (ipv4_set && ipv6_set)
13154 errmsg ("both IPv4 and IPv6 addresses specified");
13158 if ((vni == 0) || (vni >> 24))
13160 errmsg ("vni not specified or out of range");
13164 M (VXLAN_ADD_DEL_TUNNEL, mp);
13168 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
13169 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
13173 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
13174 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
13177 mp->instance = htonl (instance);
13178 mp->encap_vrf_id = ntohl (encap_vrf_id);
13179 mp->decap_next_index = ntohl (decap_next_index);
13180 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13181 mp->vni = ntohl (vni);
13182 mp->is_add = is_add;
13183 mp->is_ipv6 = ipv6_set;
13190 static void vl_api_vxlan_tunnel_details_t_handler
13191 (vl_api_vxlan_tunnel_details_t * mp)
13193 vat_main_t *vam = &vat_main;
13194 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13195 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13197 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
13198 ntohl (mp->sw_if_index),
13199 ntohl (mp->instance),
13200 format_ip46_address, &src, IP46_TYPE_ANY,
13201 format_ip46_address, &dst, IP46_TYPE_ANY,
13202 ntohl (mp->encap_vrf_id),
13203 ntohl (mp->decap_next_index), ntohl (mp->vni),
13204 ntohl (mp->mcast_sw_if_index));
13207 static void vl_api_vxlan_tunnel_details_t_handler_json
13208 (vl_api_vxlan_tunnel_details_t * mp)
13210 vat_main_t *vam = &vat_main;
13211 vat_json_node_t *node = NULL;
13213 if (VAT_JSON_ARRAY != vam->json_tree.type)
13215 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13216 vat_json_init_array (&vam->json_tree);
13218 node = vat_json_array_add (&vam->json_tree);
13220 vat_json_init_object (node);
13221 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13223 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13227 struct in6_addr ip6;
13229 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13230 vat_json_object_add_ip6 (node, "src_address", ip6);
13231 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13232 vat_json_object_add_ip6 (node, "dst_address", ip6);
13236 struct in_addr ip4;
13238 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13239 vat_json_object_add_ip4 (node, "src_address", ip4);
13240 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13241 vat_json_object_add_ip4 (node, "dst_address", ip4);
13243 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13244 vat_json_object_add_uint (node, "decap_next_index",
13245 ntohl (mp->decap_next_index));
13246 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13247 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13248 vat_json_object_add_uint (node, "mcast_sw_if_index",
13249 ntohl (mp->mcast_sw_if_index));
13253 api_vxlan_tunnel_dump (vat_main_t * vam)
13255 unformat_input_t *i = vam->input;
13256 vl_api_vxlan_tunnel_dump_t *mp;
13257 vl_api_control_ping_t *mp_ping;
13259 u8 sw_if_index_set = 0;
13262 /* Parse args required to build the message */
13263 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13265 if (unformat (i, "sw_if_index %d", &sw_if_index))
13266 sw_if_index_set = 1;
13271 if (sw_if_index_set == 0)
13276 if (!vam->json_output)
13278 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
13279 "sw_if_index", "instance", "src_address", "dst_address",
13280 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13283 /* Get list of vxlan-tunnel interfaces */
13284 M (VXLAN_TUNNEL_DUMP, mp);
13286 mp->sw_if_index = htonl (sw_if_index);
13290 /* Use a control ping for synchronization */
13291 MPING (CONTROL_PING, mp_ping);
13298 static uword unformat_geneve_decap_next
13299 (unformat_input_t * input, va_list * args)
13301 u32 *result = va_arg (*args, u32 *);
13304 if (unformat (input, "l2"))
13305 *result = GENEVE_INPUT_NEXT_L2_INPUT;
13306 else if (unformat (input, "%d", &tmp))
13314 api_geneve_add_del_tunnel (vat_main_t * vam)
13316 unformat_input_t *line_input = vam->input;
13317 vl_api_geneve_add_del_tunnel_t *mp;
13318 ip46_address_t src, dst;
13320 u8 ipv4_set = 0, ipv6_set = 0;
13324 u32 mcast_sw_if_index = ~0;
13325 u32 encap_vrf_id = 0;
13326 u32 decap_next_index = ~0;
13330 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13331 memset (&src, 0, sizeof src);
13332 memset (&dst, 0, sizeof dst);
13334 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13336 if (unformat (line_input, "del"))
13339 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13345 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13351 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13357 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13362 else if (unformat (line_input, "group %U %U",
13363 unformat_ip4_address, &dst.ip4,
13364 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13366 grp_set = dst_set = 1;
13369 else if (unformat (line_input, "group %U",
13370 unformat_ip4_address, &dst.ip4))
13372 grp_set = dst_set = 1;
13375 else if (unformat (line_input, "group %U %U",
13376 unformat_ip6_address, &dst.ip6,
13377 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13379 grp_set = dst_set = 1;
13382 else if (unformat (line_input, "group %U",
13383 unformat_ip6_address, &dst.ip6))
13385 grp_set = dst_set = 1;
13389 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13391 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13393 else if (unformat (line_input, "decap-next %U",
13394 unformat_geneve_decap_next, &decap_next_index))
13396 else if (unformat (line_input, "vni %d", &vni))
13400 errmsg ("parse error '%U'", format_unformat_error, line_input);
13407 errmsg ("tunnel src address not specified");
13412 errmsg ("tunnel dst address not specified");
13416 if (grp_set && !ip46_address_is_multicast (&dst))
13418 errmsg ("tunnel group address not multicast");
13421 if (grp_set && mcast_sw_if_index == ~0)
13423 errmsg ("tunnel nonexistent multicast device");
13426 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13428 errmsg ("tunnel dst address must be unicast");
13433 if (ipv4_set && ipv6_set)
13435 errmsg ("both IPv4 and IPv6 addresses specified");
13439 if ((vni == 0) || (vni >> 24))
13441 errmsg ("vni not specified or out of range");
13445 M (GENEVE_ADD_DEL_TUNNEL, mp);
13449 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
13450 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
13454 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
13455 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
13457 mp->encap_vrf_id = ntohl (encap_vrf_id);
13458 mp->decap_next_index = ntohl (decap_next_index);
13459 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13460 mp->vni = ntohl (vni);
13461 mp->is_add = is_add;
13462 mp->is_ipv6 = ipv6_set;
13469 static void vl_api_geneve_tunnel_details_t_handler
13470 (vl_api_geneve_tunnel_details_t * mp)
13472 vat_main_t *vam = &vat_main;
13473 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13474 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13476 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
13477 ntohl (mp->sw_if_index),
13478 format_ip46_address, &src, IP46_TYPE_ANY,
13479 format_ip46_address, &dst, IP46_TYPE_ANY,
13480 ntohl (mp->encap_vrf_id),
13481 ntohl (mp->decap_next_index), ntohl (mp->vni),
13482 ntohl (mp->mcast_sw_if_index));
13485 static void vl_api_geneve_tunnel_details_t_handler_json
13486 (vl_api_geneve_tunnel_details_t * mp)
13488 vat_main_t *vam = &vat_main;
13489 vat_json_node_t *node = NULL;
13491 if (VAT_JSON_ARRAY != vam->json_tree.type)
13493 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13494 vat_json_init_array (&vam->json_tree);
13496 node = vat_json_array_add (&vam->json_tree);
13498 vat_json_init_object (node);
13499 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13502 struct in6_addr ip6;
13504 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13505 vat_json_object_add_ip6 (node, "src_address", ip6);
13506 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13507 vat_json_object_add_ip6 (node, "dst_address", ip6);
13511 struct in_addr ip4;
13513 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13514 vat_json_object_add_ip4 (node, "src_address", ip4);
13515 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13516 vat_json_object_add_ip4 (node, "dst_address", ip4);
13518 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13519 vat_json_object_add_uint (node, "decap_next_index",
13520 ntohl (mp->decap_next_index));
13521 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13522 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13523 vat_json_object_add_uint (node, "mcast_sw_if_index",
13524 ntohl (mp->mcast_sw_if_index));
13528 api_geneve_tunnel_dump (vat_main_t * vam)
13530 unformat_input_t *i = vam->input;
13531 vl_api_geneve_tunnel_dump_t *mp;
13532 vl_api_control_ping_t *mp_ping;
13534 u8 sw_if_index_set = 0;
13537 /* Parse args required to build the message */
13538 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13540 if (unformat (i, "sw_if_index %d", &sw_if_index))
13541 sw_if_index_set = 1;
13546 if (sw_if_index_set == 0)
13551 if (!vam->json_output)
13553 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
13554 "sw_if_index", "local_address", "remote_address",
13555 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13558 /* Get list of geneve-tunnel interfaces */
13559 M (GENEVE_TUNNEL_DUMP, mp);
13561 mp->sw_if_index = htonl (sw_if_index);
13565 /* Use a control ping for synchronization */
13566 M (CONTROL_PING, mp_ping);
13574 api_gre_add_del_tunnel (vat_main_t * vam)
13576 unformat_input_t *line_input = vam->input;
13577 vl_api_gre_add_del_tunnel_t *mp;
13578 ip4_address_t src4, dst4;
13579 ip6_address_t src6, dst6;
13583 u8 t_type = GRE_TUNNEL_TYPE_L3;
13586 u32 outer_fib_id = 0;
13587 u32 session_id = 0;
13591 memset (&src4, 0, sizeof src4);
13592 memset (&dst4, 0, sizeof dst4);
13593 memset (&src6, 0, sizeof src6);
13594 memset (&dst6, 0, sizeof dst6);
13596 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13598 if (unformat (line_input, "del"))
13600 else if (unformat (line_input, "instance %d", &instance))
13602 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
13607 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
13612 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
13617 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
13622 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
13624 else if (unformat (line_input, "teb"))
13625 t_type = GRE_TUNNEL_TYPE_TEB;
13626 else if (unformat (line_input, "erspan %d", &session_id))
13627 t_type = GRE_TUNNEL_TYPE_ERSPAN;
13630 errmsg ("parse error '%U'", format_unformat_error, line_input);
13637 errmsg ("tunnel src address not specified");
13642 errmsg ("tunnel dst address not specified");
13645 if (ipv4_set && ipv6_set)
13647 errmsg ("both IPv4 and IPv6 addresses specified");
13652 M (GRE_ADD_DEL_TUNNEL, mp);
13656 clib_memcpy (&mp->src_address, &src4, 4);
13657 clib_memcpy (&mp->dst_address, &dst4, 4);
13661 clib_memcpy (&mp->src_address, &src6, 16);
13662 clib_memcpy (&mp->dst_address, &dst6, 16);
13664 mp->instance = htonl (instance);
13665 mp->outer_fib_id = htonl (outer_fib_id);
13666 mp->is_add = is_add;
13667 mp->session_id = htons ((u16) session_id);
13668 mp->tunnel_type = t_type;
13669 mp->is_ipv6 = ipv6_set;
13676 static void vl_api_gre_tunnel_details_t_handler
13677 (vl_api_gre_tunnel_details_t * mp)
13679 vat_main_t *vam = &vat_main;
13680 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
13681 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
13683 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
13684 ntohl (mp->sw_if_index),
13685 ntohl (mp->instance),
13686 format_ip46_address, &src, IP46_TYPE_ANY,
13687 format_ip46_address, &dst, IP46_TYPE_ANY,
13688 mp->tunnel_type, ntohl (mp->outer_fib_id), ntohl (mp->session_id));
13691 static void vl_api_gre_tunnel_details_t_handler_json
13692 (vl_api_gre_tunnel_details_t * mp)
13694 vat_main_t *vam = &vat_main;
13695 vat_json_node_t *node = NULL;
13696 struct in_addr ip4;
13697 struct in6_addr ip6;
13699 if (VAT_JSON_ARRAY != vam->json_tree.type)
13701 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13702 vat_json_init_array (&vam->json_tree);
13704 node = vat_json_array_add (&vam->json_tree);
13706 vat_json_init_object (node);
13707 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13708 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13711 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
13712 vat_json_object_add_ip4 (node, "src_address", ip4);
13713 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
13714 vat_json_object_add_ip4 (node, "dst_address", ip4);
13718 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
13719 vat_json_object_add_ip6 (node, "src_address", ip6);
13720 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
13721 vat_json_object_add_ip6 (node, "dst_address", ip6);
13723 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel_type);
13724 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
13725 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
13726 vat_json_object_add_uint (node, "session_id", mp->session_id);
13730 api_gre_tunnel_dump (vat_main_t * vam)
13732 unformat_input_t *i = vam->input;
13733 vl_api_gre_tunnel_dump_t *mp;
13734 vl_api_control_ping_t *mp_ping;
13736 u8 sw_if_index_set = 0;
13739 /* Parse args required to build the message */
13740 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13742 if (unformat (i, "sw_if_index %d", &sw_if_index))
13743 sw_if_index_set = 1;
13748 if (sw_if_index_set == 0)
13753 if (!vam->json_output)
13755 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
13756 "sw_if_index", "instance", "src_address", "dst_address",
13757 "tunnel_type", "outer_fib_id", "session_id");
13760 /* Get list of gre-tunnel interfaces */
13761 M (GRE_TUNNEL_DUMP, mp);
13763 mp->sw_if_index = htonl (sw_if_index);
13767 /* Use a control ping for synchronization */
13768 MPING (CONTROL_PING, mp_ping);
13776 api_l2_fib_clear_table (vat_main_t * vam)
13778 // unformat_input_t * i = vam->input;
13779 vl_api_l2_fib_clear_table_t *mp;
13782 M (L2_FIB_CLEAR_TABLE, mp);
13790 api_l2_interface_efp_filter (vat_main_t * vam)
13792 unformat_input_t *i = vam->input;
13793 vl_api_l2_interface_efp_filter_t *mp;
13796 u8 sw_if_index_set = 0;
13799 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13801 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13802 sw_if_index_set = 1;
13803 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13804 sw_if_index_set = 1;
13805 else if (unformat (i, "enable"))
13807 else if (unformat (i, "disable"))
13811 clib_warning ("parse error '%U'", format_unformat_error, i);
13816 if (sw_if_index_set == 0)
13818 errmsg ("missing sw_if_index");
13822 M (L2_INTERFACE_EFP_FILTER, mp);
13824 mp->sw_if_index = ntohl (sw_if_index);
13825 mp->enable_disable = enable;
13832 #define foreach_vtr_op \
13833 _("disable", L2_VTR_DISABLED) \
13834 _("push-1", L2_VTR_PUSH_1) \
13835 _("push-2", L2_VTR_PUSH_2) \
13836 _("pop-1", L2_VTR_POP_1) \
13837 _("pop-2", L2_VTR_POP_2) \
13838 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
13839 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
13840 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
13841 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
13844 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
13846 unformat_input_t *i = vam->input;
13847 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
13849 u8 sw_if_index_set = 0;
13852 u32 push_dot1q = 1;
13857 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13859 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13860 sw_if_index_set = 1;
13861 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13862 sw_if_index_set = 1;
13863 else if (unformat (i, "vtr_op %d", &vtr_op))
13865 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
13868 else if (unformat (i, "push_dot1q %d", &push_dot1q))
13870 else if (unformat (i, "tag1 %d", &tag1))
13872 else if (unformat (i, "tag2 %d", &tag2))
13876 clib_warning ("parse error '%U'", format_unformat_error, i);
13881 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
13883 errmsg ("missing vtr operation or sw_if_index");
13887 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
13888 mp->sw_if_index = ntohl (sw_if_index);
13889 mp->vtr_op = ntohl (vtr_op);
13890 mp->push_dot1q = ntohl (push_dot1q);
13891 mp->tag1 = ntohl (tag1);
13892 mp->tag2 = ntohl (tag2);
13900 api_create_vhost_user_if (vat_main_t * vam)
13902 unformat_input_t *i = vam->input;
13903 vl_api_create_vhost_user_if_t *mp;
13906 u8 file_name_set = 0;
13907 u32 custom_dev_instance = ~0;
13909 u8 use_custom_mac = 0;
13913 /* Shut up coverity */
13914 memset (hwaddr, 0, sizeof (hwaddr));
13916 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13918 if (unformat (i, "socket %s", &file_name))
13922 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13924 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
13925 use_custom_mac = 1;
13926 else if (unformat (i, "server"))
13928 else if (unformat (i, "tag %s", &tag))
13934 if (file_name_set == 0)
13936 errmsg ("missing socket file name");
13940 if (vec_len (file_name) > 255)
13942 errmsg ("socket file name too long");
13945 vec_add1 (file_name, 0);
13947 M (CREATE_VHOST_USER_IF, mp);
13949 mp->is_server = is_server;
13950 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13951 vec_free (file_name);
13952 if (custom_dev_instance != ~0)
13955 mp->custom_dev_instance = ntohl (custom_dev_instance);
13957 mp->use_custom_mac = use_custom_mac;
13958 clib_memcpy (mp->mac_address, hwaddr, 6);
13960 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
13969 api_modify_vhost_user_if (vat_main_t * vam)
13971 unformat_input_t *i = vam->input;
13972 vl_api_modify_vhost_user_if_t *mp;
13975 u8 file_name_set = 0;
13976 u32 custom_dev_instance = ~0;
13977 u8 sw_if_index_set = 0;
13978 u32 sw_if_index = (u32) ~ 0;
13981 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13983 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13984 sw_if_index_set = 1;
13985 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13986 sw_if_index_set = 1;
13987 else if (unformat (i, "socket %s", &file_name))
13991 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13993 else if (unformat (i, "server"))
13999 if (sw_if_index_set == 0)
14001 errmsg ("missing sw_if_index or interface name");
14005 if (file_name_set == 0)
14007 errmsg ("missing socket file name");
14011 if (vec_len (file_name) > 255)
14013 errmsg ("socket file name too long");
14016 vec_add1 (file_name, 0);
14018 M (MODIFY_VHOST_USER_IF, mp);
14020 mp->sw_if_index = ntohl (sw_if_index);
14021 mp->is_server = is_server;
14022 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
14023 vec_free (file_name);
14024 if (custom_dev_instance != ~0)
14027 mp->custom_dev_instance = ntohl (custom_dev_instance);
14036 api_delete_vhost_user_if (vat_main_t * vam)
14038 unformat_input_t *i = vam->input;
14039 vl_api_delete_vhost_user_if_t *mp;
14040 u32 sw_if_index = ~0;
14041 u8 sw_if_index_set = 0;
14044 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14046 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14047 sw_if_index_set = 1;
14048 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14049 sw_if_index_set = 1;
14054 if (sw_if_index_set == 0)
14056 errmsg ("missing sw_if_index or interface name");
14061 M (DELETE_VHOST_USER_IF, mp);
14063 mp->sw_if_index = ntohl (sw_if_index);
14070 static void vl_api_sw_interface_vhost_user_details_t_handler
14071 (vl_api_sw_interface_vhost_user_details_t * mp)
14073 vat_main_t *vam = &vat_main;
14075 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
14076 (char *) mp->interface_name,
14077 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
14078 clib_net_to_host_u64 (mp->features), mp->is_server,
14079 ntohl (mp->num_regions), (char *) mp->sock_filename);
14080 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
14083 static void vl_api_sw_interface_vhost_user_details_t_handler_json
14084 (vl_api_sw_interface_vhost_user_details_t * mp)
14086 vat_main_t *vam = &vat_main;
14087 vat_json_node_t *node = NULL;
14089 if (VAT_JSON_ARRAY != vam->json_tree.type)
14091 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14092 vat_json_init_array (&vam->json_tree);
14094 node = vat_json_array_add (&vam->json_tree);
14096 vat_json_init_object (node);
14097 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14098 vat_json_object_add_string_copy (node, "interface_name",
14099 mp->interface_name);
14100 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
14101 ntohl (mp->virtio_net_hdr_sz));
14102 vat_json_object_add_uint (node, "features",
14103 clib_net_to_host_u64 (mp->features));
14104 vat_json_object_add_uint (node, "is_server", mp->is_server);
14105 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
14106 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
14107 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
14111 api_sw_interface_vhost_user_dump (vat_main_t * vam)
14113 vl_api_sw_interface_vhost_user_dump_t *mp;
14114 vl_api_control_ping_t *mp_ping;
14117 "Interface name idx hdr_sz features server regions filename");
14119 /* Get list of vhost-user interfaces */
14120 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
14123 /* Use a control ping for synchronization */
14124 MPING (CONTROL_PING, mp_ping);
14132 api_show_version (vat_main_t * vam)
14134 vl_api_show_version_t *mp;
14137 M (SHOW_VERSION, mp);
14146 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
14148 unformat_input_t *line_input = vam->input;
14149 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
14150 ip4_address_t local4, remote4;
14151 ip6_address_t local6, remote6;
14153 u8 ipv4_set = 0, ipv6_set = 0;
14157 u32 mcast_sw_if_index = ~0;
14158 u32 encap_vrf_id = 0;
14159 u32 decap_vrf_id = 0;
14165 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
14166 memset (&local4, 0, sizeof local4);
14167 memset (&remote4, 0, sizeof remote4);
14168 memset (&local6, 0, sizeof local6);
14169 memset (&remote6, 0, sizeof remote6);
14171 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14173 if (unformat (line_input, "del"))
14175 else if (unformat (line_input, "local %U",
14176 unformat_ip4_address, &local4))
14181 else if (unformat (line_input, "remote %U",
14182 unformat_ip4_address, &remote4))
14187 else if (unformat (line_input, "local %U",
14188 unformat_ip6_address, &local6))
14193 else if (unformat (line_input, "remote %U",
14194 unformat_ip6_address, &remote6))
14199 else if (unformat (line_input, "group %U %U",
14200 unformat_ip4_address, &remote4,
14201 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14203 grp_set = remote_set = 1;
14206 else if (unformat (line_input, "group %U",
14207 unformat_ip4_address, &remote4))
14209 grp_set = remote_set = 1;
14212 else if (unformat (line_input, "group %U %U",
14213 unformat_ip6_address, &remote6,
14214 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14216 grp_set = remote_set = 1;
14219 else if (unformat (line_input, "group %U",
14220 unformat_ip6_address, &remote6))
14222 grp_set = remote_set = 1;
14226 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
14228 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
14230 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
14232 else if (unformat (line_input, "vni %d", &vni))
14234 else if (unformat (line_input, "next-ip4"))
14236 else if (unformat (line_input, "next-ip6"))
14238 else if (unformat (line_input, "next-ethernet"))
14240 else if (unformat (line_input, "next-nsh"))
14244 errmsg ("parse error '%U'", format_unformat_error, line_input);
14249 if (local_set == 0)
14251 errmsg ("tunnel local address not specified");
14254 if (remote_set == 0)
14256 errmsg ("tunnel remote address not specified");
14259 if (grp_set && mcast_sw_if_index == ~0)
14261 errmsg ("tunnel nonexistent multicast device");
14264 if (ipv4_set && ipv6_set)
14266 errmsg ("both IPv4 and IPv6 addresses specified");
14272 errmsg ("vni not specified");
14276 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
14281 clib_memcpy (&mp->local, &local6, sizeof (local6));
14282 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
14286 clib_memcpy (&mp->local, &local4, sizeof (local4));
14287 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
14290 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
14291 mp->encap_vrf_id = ntohl (encap_vrf_id);
14292 mp->decap_vrf_id = ntohl (decap_vrf_id);
14293 mp->protocol = protocol;
14294 mp->vni = ntohl (vni);
14295 mp->is_add = is_add;
14296 mp->is_ipv6 = ipv6_set;
14303 static void vl_api_vxlan_gpe_tunnel_details_t_handler
14304 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14306 vat_main_t *vam = &vat_main;
14307 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
14308 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
14310 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
14311 ntohl (mp->sw_if_index),
14312 format_ip46_address, &local, IP46_TYPE_ANY,
14313 format_ip46_address, &remote, IP46_TYPE_ANY,
14314 ntohl (mp->vni), mp->protocol,
14315 ntohl (mp->mcast_sw_if_index),
14316 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
14320 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
14321 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14323 vat_main_t *vam = &vat_main;
14324 vat_json_node_t *node = NULL;
14325 struct in_addr ip4;
14326 struct in6_addr ip6;
14328 if (VAT_JSON_ARRAY != vam->json_tree.type)
14330 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14331 vat_json_init_array (&vam->json_tree);
14333 node = vat_json_array_add (&vam->json_tree);
14335 vat_json_init_object (node);
14336 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14339 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
14340 vat_json_object_add_ip6 (node, "local", ip6);
14341 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
14342 vat_json_object_add_ip6 (node, "remote", ip6);
14346 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
14347 vat_json_object_add_ip4 (node, "local", ip4);
14348 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
14349 vat_json_object_add_ip4 (node, "remote", ip4);
14351 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
14352 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
14353 vat_json_object_add_uint (node, "mcast_sw_if_index",
14354 ntohl (mp->mcast_sw_if_index));
14355 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
14356 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
14357 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
14361 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
14363 unformat_input_t *i = vam->input;
14364 vl_api_vxlan_gpe_tunnel_dump_t *mp;
14365 vl_api_control_ping_t *mp_ping;
14367 u8 sw_if_index_set = 0;
14370 /* Parse args required to build the message */
14371 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14373 if (unformat (i, "sw_if_index %d", &sw_if_index))
14374 sw_if_index_set = 1;
14379 if (sw_if_index_set == 0)
14384 if (!vam->json_output)
14386 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
14387 "sw_if_index", "local", "remote", "vni",
14388 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
14391 /* Get list of vxlan-tunnel interfaces */
14392 M (VXLAN_GPE_TUNNEL_DUMP, mp);
14394 mp->sw_if_index = htonl (sw_if_index);
14398 /* Use a control ping for synchronization */
14399 MPING (CONTROL_PING, mp_ping);
14406 static void vl_api_l2_fib_table_details_t_handler
14407 (vl_api_l2_fib_table_details_t * mp)
14409 vat_main_t *vam = &vat_main;
14411 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
14413 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
14414 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
14418 static void vl_api_l2_fib_table_details_t_handler_json
14419 (vl_api_l2_fib_table_details_t * mp)
14421 vat_main_t *vam = &vat_main;
14422 vat_json_node_t *node = NULL;
14424 if (VAT_JSON_ARRAY != vam->json_tree.type)
14426 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14427 vat_json_init_array (&vam->json_tree);
14429 node = vat_json_array_add (&vam->json_tree);
14431 vat_json_init_object (node);
14432 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
14433 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
14434 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14435 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
14436 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
14437 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
14441 api_l2_fib_table_dump (vat_main_t * vam)
14443 unformat_input_t *i = vam->input;
14444 vl_api_l2_fib_table_dump_t *mp;
14445 vl_api_control_ping_t *mp_ping;
14450 /* Parse args required to build the message */
14451 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14453 if (unformat (i, "bd_id %d", &bd_id))
14459 if (bd_id_set == 0)
14461 errmsg ("missing bridge domain");
14465 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
14467 /* Get list of l2 fib entries */
14468 M (L2_FIB_TABLE_DUMP, mp);
14470 mp->bd_id = ntohl (bd_id);
14473 /* Use a control ping for synchronization */
14474 MPING (CONTROL_PING, mp_ping);
14483 api_interface_name_renumber (vat_main_t * vam)
14485 unformat_input_t *line_input = vam->input;
14486 vl_api_interface_name_renumber_t *mp;
14487 u32 sw_if_index = ~0;
14488 u32 new_show_dev_instance = ~0;
14491 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14493 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
14496 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14498 else if (unformat (line_input, "new_show_dev_instance %d",
14499 &new_show_dev_instance))
14505 if (sw_if_index == ~0)
14507 errmsg ("missing interface name or sw_if_index");
14511 if (new_show_dev_instance == ~0)
14513 errmsg ("missing new_show_dev_instance");
14517 M (INTERFACE_NAME_RENUMBER, mp);
14519 mp->sw_if_index = ntohl (sw_if_index);
14520 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
14528 api_ip_probe_neighbor (vat_main_t * vam)
14530 unformat_input_t *i = vam->input;
14531 vl_api_ip_probe_neighbor_t *mp;
14539 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14541 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14543 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14545 else if (unformat (i, "address %U", unformat_ip4_address, dst_adr))
14547 else if (unformat (i, "address %U", unformat_ip6_address, dst_adr))
14558 errmsg ("missing interface");
14564 errmsg ("missing addresses");
14568 M (IP_PROBE_NEIGHBOR, mp);
14570 mp->sw_if_index = ntohl (sw_if_index);
14571 mp->is_ipv6 = is_ipv6;
14572 clib_memcpy (mp->dst_address, dst_adr, sizeof (dst_adr));
14580 api_ip_scan_neighbor_enable_disable (vat_main_t * vam)
14582 unformat_input_t *i = vam->input;
14583 vl_api_ip_scan_neighbor_enable_disable_t *mp;
14584 u8 mode = IP_SCAN_V46_NEIGHBORS;
14585 u32 interval = 0, time = 0, update = 0, delay = 0, stale = 0;
14588 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14590 if (unformat (i, "ip4"))
14591 mode = IP_SCAN_V4_NEIGHBORS;
14592 else if (unformat (i, "ip6"))
14593 mode = IP_SCAN_V6_NEIGHBORS;
14594 if (unformat (i, "both"))
14595 mode = IP_SCAN_V46_NEIGHBORS;
14596 else if (unformat (i, "disable"))
14597 mode = IP_SCAN_DISABLED;
14598 else if (unformat (i, "interval %d", &interval))
14600 else if (unformat (i, "max-time %d", &time))
14602 else if (unformat (i, "max-update %d", &update))
14604 else if (unformat (i, "delay %d", &delay))
14606 else if (unformat (i, "stale %d", &stale))
14612 if (interval > 255)
14614 errmsg ("interval cannot exceed 255 minutes.");
14619 errmsg ("max-time cannot exceed 255 usec.");
14624 errmsg ("max-update cannot exceed 255.");
14629 errmsg ("delay cannot exceed 255 msec.");
14634 errmsg ("stale cannot exceed 255 minutes.");
14638 M (IP_SCAN_NEIGHBOR_ENABLE_DISABLE, mp);
14640 mp->scan_interval = interval;
14641 mp->max_proc_time = time;
14642 mp->max_update = update;
14643 mp->scan_int_delay = delay;
14644 mp->stale_threshold = stale;
14652 api_want_ip4_arp_events (vat_main_t * vam)
14654 unformat_input_t *line_input = vam->input;
14655 vl_api_want_ip4_arp_events_t *mp;
14656 ip4_address_t address;
14657 int address_set = 0;
14658 u32 enable_disable = 1;
14661 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14663 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
14665 else if (unformat (line_input, "del"))
14666 enable_disable = 0;
14671 if (address_set == 0)
14673 errmsg ("missing addresses");
14677 M (WANT_IP4_ARP_EVENTS, mp);
14678 mp->enable_disable = enable_disable;
14679 mp->pid = htonl (getpid ());
14680 mp->address = address.as_u32;
14688 api_want_ip6_nd_events (vat_main_t * vam)
14690 unformat_input_t *line_input = vam->input;
14691 vl_api_want_ip6_nd_events_t *mp;
14692 ip6_address_t address;
14693 int address_set = 0;
14694 u32 enable_disable = 1;
14697 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14699 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
14701 else if (unformat (line_input, "del"))
14702 enable_disable = 0;
14707 if (address_set == 0)
14709 errmsg ("missing addresses");
14713 M (WANT_IP6_ND_EVENTS, mp);
14714 mp->enable_disable = enable_disable;
14715 mp->pid = htonl (getpid ());
14716 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
14724 api_want_l2_macs_events (vat_main_t * vam)
14726 unformat_input_t *line_input = vam->input;
14727 vl_api_want_l2_macs_events_t *mp;
14728 u8 enable_disable = 1;
14729 u32 scan_delay = 0;
14730 u32 max_macs_in_event = 0;
14731 u32 learn_limit = 0;
14734 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14736 if (unformat (line_input, "learn-limit %d", &learn_limit))
14738 else if (unformat (line_input, "scan-delay %d", &scan_delay))
14740 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
14742 else if (unformat (line_input, "disable"))
14743 enable_disable = 0;
14748 M (WANT_L2_MACS_EVENTS, mp);
14749 mp->enable_disable = enable_disable;
14750 mp->pid = htonl (getpid ());
14751 mp->learn_limit = htonl (learn_limit);
14752 mp->scan_delay = (u8) scan_delay;
14753 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
14760 api_input_acl_set_interface (vat_main_t * vam)
14762 unformat_input_t *i = vam->input;
14763 vl_api_input_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 (INPUT_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_output_acl_set_interface (vat_main_t * vam)
14815 unformat_input_t *i = vam->input;
14816 vl_api_output_acl_set_interface_t *mp;
14818 int sw_if_index_set;
14819 u32 ip4_table_index = ~0;
14820 u32 ip6_table_index = ~0;
14821 u32 l2_table_index = ~0;
14825 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14827 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14828 sw_if_index_set = 1;
14829 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14830 sw_if_index_set = 1;
14831 else if (unformat (i, "del"))
14833 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14835 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14837 else if (unformat (i, "l2-table %d", &l2_table_index))
14841 clib_warning ("parse error '%U'", format_unformat_error, i);
14846 if (sw_if_index_set == 0)
14848 errmsg ("missing interface name or sw_if_index");
14852 M (OUTPUT_ACL_SET_INTERFACE, mp);
14854 mp->sw_if_index = ntohl (sw_if_index);
14855 mp->ip4_table_index = ntohl (ip4_table_index);
14856 mp->ip6_table_index = ntohl (ip6_table_index);
14857 mp->l2_table_index = ntohl (l2_table_index);
14858 mp->is_add = is_add;
14866 api_ip_address_dump (vat_main_t * vam)
14868 unformat_input_t *i = vam->input;
14869 vl_api_ip_address_dump_t *mp;
14870 vl_api_control_ping_t *mp_ping;
14871 u32 sw_if_index = ~0;
14872 u8 sw_if_index_set = 0;
14877 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14879 if (unformat (i, "sw_if_index %d", &sw_if_index))
14880 sw_if_index_set = 1;
14882 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14883 sw_if_index_set = 1;
14884 else if (unformat (i, "ipv4"))
14886 else if (unformat (i, "ipv6"))
14892 if (ipv4_set && ipv6_set)
14894 errmsg ("ipv4 and ipv6 flags cannot be both set");
14898 if ((!ipv4_set) && (!ipv6_set))
14900 errmsg ("no ipv4 nor ipv6 flag set");
14904 if (sw_if_index_set == 0)
14906 errmsg ("missing interface name or sw_if_index");
14910 vam->current_sw_if_index = sw_if_index;
14911 vam->is_ipv6 = ipv6_set;
14913 M (IP_ADDRESS_DUMP, mp);
14914 mp->sw_if_index = ntohl (sw_if_index);
14915 mp->is_ipv6 = ipv6_set;
14918 /* Use a control ping for synchronization */
14919 MPING (CONTROL_PING, mp_ping);
14927 api_ip_dump (vat_main_t * vam)
14929 vl_api_ip_dump_t *mp;
14930 vl_api_control_ping_t *mp_ping;
14931 unformat_input_t *in = vam->input;
14938 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
14940 if (unformat (in, "ipv4"))
14942 else if (unformat (in, "ipv6"))
14948 if (ipv4_set && ipv6_set)
14950 errmsg ("ipv4 and ipv6 flags cannot be both set");
14954 if ((!ipv4_set) && (!ipv6_set))
14956 errmsg ("no ipv4 nor ipv6 flag set");
14960 is_ipv6 = ipv6_set;
14961 vam->is_ipv6 = is_ipv6;
14963 /* free old data */
14964 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
14966 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
14968 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
14971 mp->is_ipv6 = ipv6_set;
14974 /* Use a control ping for synchronization */
14975 MPING (CONTROL_PING, mp_ping);
14983 api_ipsec_spd_add_del (vat_main_t * vam)
14985 unformat_input_t *i = vam->input;
14986 vl_api_ipsec_spd_add_del_t *mp;
14991 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14993 if (unformat (i, "spd_id %d", &spd_id))
14995 else if (unformat (i, "del"))
14999 clib_warning ("parse error '%U'", format_unformat_error, i);
15005 errmsg ("spd_id must be set");
15009 M (IPSEC_SPD_ADD_DEL, mp);
15011 mp->spd_id = ntohl (spd_id);
15012 mp->is_add = is_add;
15020 api_ipsec_interface_add_del_spd (vat_main_t * vam)
15022 unformat_input_t *i = vam->input;
15023 vl_api_ipsec_interface_add_del_spd_t *mp;
15025 u8 sw_if_index_set = 0;
15026 u32 spd_id = (u32) ~ 0;
15030 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15032 if (unformat (i, "del"))
15034 else if (unformat (i, "spd_id %d", &spd_id))
15037 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15038 sw_if_index_set = 1;
15039 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15040 sw_if_index_set = 1;
15043 clib_warning ("parse error '%U'", format_unformat_error, i);
15049 if (spd_id == (u32) ~ 0)
15051 errmsg ("spd_id must be set");
15055 if (sw_if_index_set == 0)
15057 errmsg ("missing interface name or sw_if_index");
15061 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
15063 mp->spd_id = ntohl (spd_id);
15064 mp->sw_if_index = ntohl (sw_if_index);
15065 mp->is_add = is_add;
15073 api_ipsec_spd_add_del_entry (vat_main_t * vam)
15075 unformat_input_t *i = vam->input;
15076 vl_api_ipsec_spd_add_del_entry_t *mp;
15077 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
15078 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
15080 u32 rport_start = 0, rport_stop = (u32) ~ 0;
15081 u32 lport_start = 0, lport_stop = (u32) ~ 0;
15082 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
15083 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
15086 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
15087 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
15088 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
15089 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
15090 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
15091 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
15093 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15095 if (unformat (i, "del"))
15097 if (unformat (i, "outbound"))
15099 if (unformat (i, "inbound"))
15101 else if (unformat (i, "spd_id %d", &spd_id))
15103 else if (unformat (i, "sa_id %d", &sa_id))
15105 else if (unformat (i, "priority %d", &priority))
15107 else if (unformat (i, "protocol %d", &protocol))
15109 else if (unformat (i, "lport_start %d", &lport_start))
15111 else if (unformat (i, "lport_stop %d", &lport_stop))
15113 else if (unformat (i, "rport_start %d", &rport_start))
15115 else if (unformat (i, "rport_stop %d", &rport_stop))
15119 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
15125 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
15132 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
15138 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
15145 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
15151 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
15158 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
15164 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
15170 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
15172 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
15174 clib_warning ("unsupported action: 'resolve'");
15180 clib_warning ("parse error '%U'", format_unformat_error, i);
15186 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
15188 mp->spd_id = ntohl (spd_id);
15189 mp->priority = ntohl (priority);
15190 mp->is_outbound = is_outbound;
15192 mp->is_ipv6 = is_ipv6;
15193 if (is_ipv6 || is_ip_any)
15195 clib_memcpy (mp->remote_address_start, &raddr6_start,
15196 sizeof (ip6_address_t));
15197 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
15198 sizeof (ip6_address_t));
15199 clib_memcpy (mp->local_address_start, &laddr6_start,
15200 sizeof (ip6_address_t));
15201 clib_memcpy (mp->local_address_stop, &laddr6_stop,
15202 sizeof (ip6_address_t));
15206 clib_memcpy (mp->remote_address_start, &raddr4_start,
15207 sizeof (ip4_address_t));
15208 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
15209 sizeof (ip4_address_t));
15210 clib_memcpy (mp->local_address_start, &laddr4_start,
15211 sizeof (ip4_address_t));
15212 clib_memcpy (mp->local_address_stop, &laddr4_stop,
15213 sizeof (ip4_address_t));
15215 mp->protocol = (u8) protocol;
15216 mp->local_port_start = ntohs ((u16) lport_start);
15217 mp->local_port_stop = ntohs ((u16) lport_stop);
15218 mp->remote_port_start = ntohs ((u16) rport_start);
15219 mp->remote_port_stop = ntohs ((u16) rport_stop);
15220 mp->policy = (u8) policy;
15221 mp->sa_id = ntohl (sa_id);
15222 mp->is_add = is_add;
15223 mp->is_ip_any = is_ip_any;
15230 api_ipsec_sad_add_del_entry (vat_main_t * vam)
15232 unformat_input_t *i = vam->input;
15233 vl_api_ipsec_sad_add_del_entry_t *mp;
15234 u32 sad_id = 0, spi = 0;
15235 u8 *ck = 0, *ik = 0;
15238 u8 protocol = IPSEC_PROTOCOL_AH;
15239 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
15240 u32 crypto_alg = 0, integ_alg = 0;
15241 ip4_address_t tun_src4;
15242 ip4_address_t tun_dst4;
15243 ip6_address_t tun_src6;
15244 ip6_address_t tun_dst6;
15247 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15249 if (unformat (i, "del"))
15251 else if (unformat (i, "sad_id %d", &sad_id))
15253 else if (unformat (i, "spi %d", &spi))
15255 else if (unformat (i, "esp"))
15256 protocol = IPSEC_PROTOCOL_ESP;
15257 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
15260 is_tunnel_ipv6 = 0;
15262 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
15265 is_tunnel_ipv6 = 0;
15267 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
15270 is_tunnel_ipv6 = 1;
15272 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
15275 is_tunnel_ipv6 = 1;
15279 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15281 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
15283 clib_warning ("unsupported crypto-alg: '%U'",
15284 format_ipsec_crypto_alg, crypto_alg);
15288 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15292 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15294 if (integ_alg >= IPSEC_INTEG_N_ALG)
15296 clib_warning ("unsupported integ-alg: '%U'",
15297 format_ipsec_integ_alg, integ_alg);
15301 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15305 clib_warning ("parse error '%U'", format_unformat_error, i);
15311 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
15313 mp->sad_id = ntohl (sad_id);
15314 mp->is_add = is_add;
15315 mp->protocol = protocol;
15316 mp->spi = ntohl (spi);
15317 mp->is_tunnel = is_tunnel;
15318 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
15319 mp->crypto_algorithm = crypto_alg;
15320 mp->integrity_algorithm = integ_alg;
15321 mp->crypto_key_length = vec_len (ck);
15322 mp->integrity_key_length = vec_len (ik);
15324 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15325 mp->crypto_key_length = sizeof (mp->crypto_key);
15327 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15328 mp->integrity_key_length = sizeof (mp->integrity_key);
15331 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15333 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15337 if (is_tunnel_ipv6)
15339 clib_memcpy (mp->tunnel_src_address, &tun_src6,
15340 sizeof (ip6_address_t));
15341 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
15342 sizeof (ip6_address_t));
15346 clib_memcpy (mp->tunnel_src_address, &tun_src4,
15347 sizeof (ip4_address_t));
15348 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
15349 sizeof (ip4_address_t));
15359 api_ipsec_sa_set_key (vat_main_t * vam)
15361 unformat_input_t *i = vam->input;
15362 vl_api_ipsec_sa_set_key_t *mp;
15364 u8 *ck = 0, *ik = 0;
15367 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15369 if (unformat (i, "sa_id %d", &sa_id))
15371 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15373 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15377 clib_warning ("parse error '%U'", format_unformat_error, i);
15382 M (IPSEC_SA_SET_KEY, mp);
15384 mp->sa_id = ntohl (sa_id);
15385 mp->crypto_key_length = vec_len (ck);
15386 mp->integrity_key_length = vec_len (ik);
15388 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15389 mp->crypto_key_length = sizeof (mp->crypto_key);
15391 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15392 mp->integrity_key_length = sizeof (mp->integrity_key);
15395 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15397 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15405 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
15407 unformat_input_t *i = vam->input;
15408 vl_api_ipsec_tunnel_if_add_del_t *mp;
15409 u32 local_spi = 0, remote_spi = 0;
15410 u32 crypto_alg = 0, integ_alg = 0;
15411 u8 *lck = NULL, *rck = NULL;
15412 u8 *lik = NULL, *rik = NULL;
15413 ip4_address_t local_ip = { {0} };
15414 ip4_address_t remote_ip = { {0} };
15417 u8 anti_replay = 0;
15422 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15424 if (unformat (i, "del"))
15426 else if (unformat (i, "esn"))
15428 else if (unformat (i, "anti_replay"))
15430 else if (unformat (i, "local_spi %d", &local_spi))
15432 else if (unformat (i, "remote_spi %d", &remote_spi))
15434 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
15436 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
15438 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
15441 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
15443 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
15445 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
15449 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15451 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
15453 errmsg ("unsupported crypto-alg: '%U'\n",
15454 format_ipsec_crypto_alg, crypto_alg);
15460 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15462 if (integ_alg >= IPSEC_INTEG_N_ALG)
15464 errmsg ("unsupported integ-alg: '%U'\n",
15465 format_ipsec_integ_alg, integ_alg);
15469 else if (unformat (i, "instance %u", &instance))
15473 errmsg ("parse error '%U'\n", format_unformat_error, i);
15478 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
15480 mp->is_add = is_add;
15482 mp->anti_replay = anti_replay;
15484 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
15485 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
15487 mp->local_spi = htonl (local_spi);
15488 mp->remote_spi = htonl (remote_spi);
15489 mp->crypto_alg = (u8) crypto_alg;
15491 mp->local_crypto_key_len = 0;
15494 mp->local_crypto_key_len = vec_len (lck);
15495 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
15496 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
15497 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
15500 mp->remote_crypto_key_len = 0;
15503 mp->remote_crypto_key_len = vec_len (rck);
15504 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
15505 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
15506 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
15509 mp->integ_alg = (u8) integ_alg;
15511 mp->local_integ_key_len = 0;
15514 mp->local_integ_key_len = vec_len (lik);
15515 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
15516 mp->local_integ_key_len = sizeof (mp->local_integ_key);
15517 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
15520 mp->remote_integ_key_len = 0;
15523 mp->remote_integ_key_len = vec_len (rik);
15524 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
15525 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
15526 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
15531 mp->renumber = renumber;
15532 mp->show_instance = ntohl (instance);
15541 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
15543 vat_main_t *vam = &vat_main;
15545 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
15546 "crypto_key %U integ_alg %u integ_key %U use_esn %u "
15547 "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u "
15548 "tunnel_src_addr %U tunnel_dst_addr %U "
15549 "salt %u seq_outbound %lu last_seq_inbound %lu "
15550 "replay_window %lu total_data_size %lu\n",
15551 ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi),
15553 mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len,
15554 mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len,
15555 mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6,
15556 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15557 mp->tunnel_src_addr,
15558 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15559 mp->tunnel_dst_addr,
15561 clib_net_to_host_u64 (mp->seq_outbound),
15562 clib_net_to_host_u64 (mp->last_seq_inbound),
15563 clib_net_to_host_u64 (mp->replay_window),
15564 clib_net_to_host_u64 (mp->total_data_size));
15567 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
15568 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
15570 static void vl_api_ipsec_sa_details_t_handler_json
15571 (vl_api_ipsec_sa_details_t * mp)
15573 vat_main_t *vam = &vat_main;
15574 vat_json_node_t *node = NULL;
15575 struct in_addr src_ip4, dst_ip4;
15576 struct in6_addr src_ip6, dst_ip6;
15578 if (VAT_JSON_ARRAY != vam->json_tree.type)
15580 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15581 vat_json_init_array (&vam->json_tree);
15583 node = vat_json_array_add (&vam->json_tree);
15585 vat_json_init_object (node);
15586 vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id));
15587 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
15588 vat_json_object_add_uint (node, "spi", ntohl (mp->spi));
15589 vat_json_object_add_uint (node, "proto", mp->protocol);
15590 vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg);
15591 vat_json_object_add_uint (node, "integ_alg", mp->integ_alg);
15592 vat_json_object_add_uint (node, "use_esn", mp->use_esn);
15593 vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay);
15594 vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel);
15595 vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6);
15596 vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key,
15597 mp->crypto_key_len);
15598 vat_json_object_add_bytes (node, "integ_key", mp->integ_key,
15599 mp->integ_key_len);
15600 if (mp->is_tunnel_ip6)
15602 clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6));
15603 vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6);
15604 clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6));
15605 vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6);
15609 clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4));
15610 vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4);
15611 clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4));
15612 vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4);
15614 vat_json_object_add_uint (node, "replay_window",
15615 clib_net_to_host_u64 (mp->replay_window));
15616 vat_json_object_add_uint (node, "total_data_size",
15617 clib_net_to_host_u64 (mp->total_data_size));
15622 api_ipsec_sa_dump (vat_main_t * vam)
15624 unformat_input_t *i = vam->input;
15625 vl_api_ipsec_sa_dump_t *mp;
15626 vl_api_control_ping_t *mp_ping;
15630 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15632 if (unformat (i, "sa_id %d", &sa_id))
15636 clib_warning ("parse error '%U'", format_unformat_error, i);
15641 M (IPSEC_SA_DUMP, mp);
15643 mp->sa_id = ntohl (sa_id);
15647 /* Use a control ping for synchronization */
15648 M (CONTROL_PING, mp_ping);
15656 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
15658 unformat_input_t *i = vam->input;
15659 vl_api_ipsec_tunnel_if_set_key_t *mp;
15660 u32 sw_if_index = ~0;
15661 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
15666 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15668 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15671 if (unformat (i, "local crypto %U", unformat_ipsec_crypto_alg, &alg))
15672 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
15674 if (unformat (i, "remote crypto %U", unformat_ipsec_crypto_alg, &alg))
15675 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
15676 else if (unformat (i, "local integ %U", unformat_ipsec_integ_alg, &alg))
15677 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
15679 if (unformat (i, "remote integ %U", unformat_ipsec_integ_alg, &alg))
15680 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
15681 else if (unformat (i, "%U", unformat_hex_string, &key))
15685 clib_warning ("parse error '%U'", format_unformat_error, i);
15690 if (sw_if_index == ~0)
15692 errmsg ("interface must be specified");
15696 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
15698 errmsg ("key type must be specified");
15704 errmsg ("algorithm must be specified");
15708 if (vec_len (key) == 0)
15710 errmsg ("key must be specified");
15714 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
15716 mp->sw_if_index = htonl (sw_if_index);
15718 mp->key_type = key_type;
15719 mp->key_len = vec_len (key);
15720 clib_memcpy (mp->key, key, vec_len (key));
15729 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
15731 unformat_input_t *i = vam->input;
15732 vl_api_ipsec_tunnel_if_set_sa_t *mp;
15733 u32 sw_if_index = ~0;
15735 u8 is_outbound = (u8) ~ 0;
15738 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15740 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15742 else if (unformat (i, "sa_id %d", &sa_id))
15744 else if (unformat (i, "outbound"))
15746 else if (unformat (i, "inbound"))
15750 clib_warning ("parse error '%U'", format_unformat_error, i);
15755 if (sw_if_index == ~0)
15757 errmsg ("interface must be specified");
15763 errmsg ("SA ID must be specified");
15767 M (IPSEC_TUNNEL_IF_SET_SA, mp);
15769 mp->sw_if_index = htonl (sw_if_index);
15770 mp->sa_id = htonl (sa_id);
15771 mp->is_outbound = is_outbound;
15780 api_ikev2_profile_add_del (vat_main_t * vam)
15782 unformat_input_t *i = vam->input;
15783 vl_api_ikev2_profile_add_del_t *mp;
15788 const char *valid_chars = "a-zA-Z0-9_";
15790 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15792 if (unformat (i, "del"))
15794 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15795 vec_add1 (name, 0);
15798 errmsg ("parse error '%U'", format_unformat_error, i);
15803 if (!vec_len (name))
15805 errmsg ("profile name must be specified");
15809 if (vec_len (name) > 64)
15811 errmsg ("profile name too long");
15815 M (IKEV2_PROFILE_ADD_DEL, mp);
15817 clib_memcpy (mp->name, name, vec_len (name));
15818 mp->is_add = is_add;
15827 api_ikev2_profile_set_auth (vat_main_t * vam)
15829 unformat_input_t *i = vam->input;
15830 vl_api_ikev2_profile_set_auth_t *mp;
15833 u32 auth_method = 0;
15837 const char *valid_chars = "a-zA-Z0-9_";
15839 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15841 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15842 vec_add1 (name, 0);
15843 else if (unformat (i, "auth_method %U",
15844 unformat_ikev2_auth_method, &auth_method))
15846 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
15848 else if (unformat (i, "auth_data %v", &data))
15852 errmsg ("parse error '%U'", format_unformat_error, i);
15857 if (!vec_len (name))
15859 errmsg ("profile name must be specified");
15863 if (vec_len (name) > 64)
15865 errmsg ("profile name too long");
15869 if (!vec_len (data))
15871 errmsg ("auth_data must be specified");
15877 errmsg ("auth_method must be specified");
15881 M (IKEV2_PROFILE_SET_AUTH, mp);
15883 mp->is_hex = is_hex;
15884 mp->auth_method = (u8) auth_method;
15885 mp->data_len = vec_len (data);
15886 clib_memcpy (mp->name, name, vec_len (name));
15887 clib_memcpy (mp->data, data, vec_len (data));
15897 api_ikev2_profile_set_id (vat_main_t * vam)
15899 unformat_input_t *i = vam->input;
15900 vl_api_ikev2_profile_set_id_t *mp;
15908 const char *valid_chars = "a-zA-Z0-9_";
15910 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15912 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15913 vec_add1 (name, 0);
15914 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
15916 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
15918 data = vec_new (u8, 4);
15919 clib_memcpy (data, ip4.as_u8, 4);
15921 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
15923 else if (unformat (i, "id_data %v", &data))
15925 else if (unformat (i, "local"))
15927 else if (unformat (i, "remote"))
15931 errmsg ("parse error '%U'", format_unformat_error, i);
15936 if (!vec_len (name))
15938 errmsg ("profile name must be specified");
15942 if (vec_len (name) > 64)
15944 errmsg ("profile name too long");
15948 if (!vec_len (data))
15950 errmsg ("id_data must be specified");
15956 errmsg ("id_type must be specified");
15960 M (IKEV2_PROFILE_SET_ID, mp);
15962 mp->is_local = is_local;
15963 mp->id_type = (u8) id_type;
15964 mp->data_len = vec_len (data);
15965 clib_memcpy (mp->name, name, vec_len (name));
15966 clib_memcpy (mp->data, data, vec_len (data));
15976 api_ikev2_profile_set_ts (vat_main_t * vam)
15978 unformat_input_t *i = vam->input;
15979 vl_api_ikev2_profile_set_ts_t *mp;
15982 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
15983 ip4_address_t start_addr, end_addr;
15985 const char *valid_chars = "a-zA-Z0-9_";
15988 start_addr.as_u32 = 0;
15989 end_addr.as_u32 = (u32) ~ 0;
15991 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15993 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15994 vec_add1 (name, 0);
15995 else if (unformat (i, "protocol %d", &proto))
15997 else if (unformat (i, "start_port %d", &start_port))
15999 else if (unformat (i, "end_port %d", &end_port))
16002 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
16004 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
16006 else if (unformat (i, "local"))
16008 else if (unformat (i, "remote"))
16012 errmsg ("parse error '%U'", format_unformat_error, i);
16017 if (!vec_len (name))
16019 errmsg ("profile name must be specified");
16023 if (vec_len (name) > 64)
16025 errmsg ("profile name too long");
16029 M (IKEV2_PROFILE_SET_TS, mp);
16031 mp->is_local = is_local;
16032 mp->proto = (u8) proto;
16033 mp->start_port = (u16) start_port;
16034 mp->end_port = (u16) end_port;
16035 mp->start_addr = start_addr.as_u32;
16036 mp->end_addr = end_addr.as_u32;
16037 clib_memcpy (mp->name, name, vec_len (name));
16046 api_ikev2_set_local_key (vat_main_t * vam)
16048 unformat_input_t *i = vam->input;
16049 vl_api_ikev2_set_local_key_t *mp;
16053 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16055 if (unformat (i, "file %v", &file))
16056 vec_add1 (file, 0);
16059 errmsg ("parse error '%U'", format_unformat_error, i);
16064 if (!vec_len (file))
16066 errmsg ("RSA key file must be specified");
16070 if (vec_len (file) > 256)
16072 errmsg ("file name too long");
16076 M (IKEV2_SET_LOCAL_KEY, mp);
16078 clib_memcpy (mp->key_file, file, vec_len (file));
16087 api_ikev2_set_responder (vat_main_t * vam)
16089 unformat_input_t *i = vam->input;
16090 vl_api_ikev2_set_responder_t *mp;
16093 u32 sw_if_index = ~0;
16094 ip4_address_t address;
16096 const char *valid_chars = "a-zA-Z0-9_";
16098 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16101 (i, "%U interface %d address %U", unformat_token, valid_chars,
16102 &name, &sw_if_index, unformat_ip4_address, &address))
16103 vec_add1 (name, 0);
16106 errmsg ("parse error '%U'", format_unformat_error, i);
16111 if (!vec_len (name))
16113 errmsg ("profile name must be specified");
16117 if (vec_len (name) > 64)
16119 errmsg ("profile name too long");
16123 M (IKEV2_SET_RESPONDER, mp);
16125 clib_memcpy (mp->name, name, vec_len (name));
16128 mp->sw_if_index = sw_if_index;
16129 clib_memcpy (mp->address, &address, sizeof (address));
16137 api_ikev2_set_ike_transforms (vat_main_t * vam)
16139 unformat_input_t *i = vam->input;
16140 vl_api_ikev2_set_ike_transforms_t *mp;
16143 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
16145 const char *valid_chars = "a-zA-Z0-9_";
16147 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16149 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
16150 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
16151 vec_add1 (name, 0);
16154 errmsg ("parse error '%U'", format_unformat_error, i);
16159 if (!vec_len (name))
16161 errmsg ("profile name must be specified");
16165 if (vec_len (name) > 64)
16167 errmsg ("profile name too long");
16171 M (IKEV2_SET_IKE_TRANSFORMS, mp);
16173 clib_memcpy (mp->name, name, vec_len (name));
16175 mp->crypto_alg = crypto_alg;
16176 mp->crypto_key_size = crypto_key_size;
16177 mp->integ_alg = integ_alg;
16178 mp->dh_group = dh_group;
16187 api_ikev2_set_esp_transforms (vat_main_t * vam)
16189 unformat_input_t *i = vam->input;
16190 vl_api_ikev2_set_esp_transforms_t *mp;
16193 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
16195 const char *valid_chars = "a-zA-Z0-9_";
16197 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16199 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
16200 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
16201 vec_add1 (name, 0);
16204 errmsg ("parse error '%U'", format_unformat_error, i);
16209 if (!vec_len (name))
16211 errmsg ("profile name must be specified");
16215 if (vec_len (name) > 64)
16217 errmsg ("profile name too long");
16221 M (IKEV2_SET_ESP_TRANSFORMS, mp);
16223 clib_memcpy (mp->name, name, vec_len (name));
16225 mp->crypto_alg = crypto_alg;
16226 mp->crypto_key_size = crypto_key_size;
16227 mp->integ_alg = integ_alg;
16228 mp->dh_group = dh_group;
16236 api_ikev2_set_sa_lifetime (vat_main_t * vam)
16238 unformat_input_t *i = vam->input;
16239 vl_api_ikev2_set_sa_lifetime_t *mp;
16242 u64 lifetime, lifetime_maxdata;
16243 u32 lifetime_jitter, handover;
16245 const char *valid_chars = "a-zA-Z0-9_";
16247 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16249 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
16250 &lifetime, &lifetime_jitter, &handover,
16251 &lifetime_maxdata))
16252 vec_add1 (name, 0);
16255 errmsg ("parse error '%U'", format_unformat_error, i);
16260 if (!vec_len (name))
16262 errmsg ("profile name must be specified");
16266 if (vec_len (name) > 64)
16268 errmsg ("profile name too long");
16272 M (IKEV2_SET_SA_LIFETIME, mp);
16274 clib_memcpy (mp->name, name, vec_len (name));
16276 mp->lifetime = lifetime;
16277 mp->lifetime_jitter = lifetime_jitter;
16278 mp->handover = handover;
16279 mp->lifetime_maxdata = lifetime_maxdata;
16287 api_ikev2_initiate_sa_init (vat_main_t * vam)
16289 unformat_input_t *i = vam->input;
16290 vl_api_ikev2_initiate_sa_init_t *mp;
16294 const char *valid_chars = "a-zA-Z0-9_";
16296 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16298 if (unformat (i, "%U", unformat_token, valid_chars, &name))
16299 vec_add1 (name, 0);
16302 errmsg ("parse error '%U'", format_unformat_error, i);
16307 if (!vec_len (name))
16309 errmsg ("profile name must be specified");
16313 if (vec_len (name) > 64)
16315 errmsg ("profile name too long");
16319 M (IKEV2_INITIATE_SA_INIT, mp);
16321 clib_memcpy (mp->name, name, vec_len (name));
16330 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
16332 unformat_input_t *i = vam->input;
16333 vl_api_ikev2_initiate_del_ike_sa_t *mp;
16338 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16340 if (unformat (i, "%lx", &ispi))
16344 errmsg ("parse error '%U'", format_unformat_error, i);
16349 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
16359 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
16361 unformat_input_t *i = vam->input;
16362 vl_api_ikev2_initiate_del_child_sa_t *mp;
16367 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16369 if (unformat (i, "%x", &ispi))
16373 errmsg ("parse error '%U'", format_unformat_error, i);
16378 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
16388 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
16390 unformat_input_t *i = vam->input;
16391 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
16396 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16398 if (unformat (i, "%x", &ispi))
16402 errmsg ("parse error '%U'", format_unformat_error, i);
16407 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
16417 api_get_first_msg_id (vat_main_t * vam)
16419 vl_api_get_first_msg_id_t *mp;
16420 unformat_input_t *i = vam->input;
16425 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16427 if (unformat (i, "client %s", &name))
16435 errmsg ("missing client name");
16438 vec_add1 (name, 0);
16440 if (vec_len (name) > 63)
16442 errmsg ("client name too long");
16446 M (GET_FIRST_MSG_ID, mp);
16447 clib_memcpy (mp->name, name, vec_len (name));
16454 api_cop_interface_enable_disable (vat_main_t * vam)
16456 unformat_input_t *line_input = vam->input;
16457 vl_api_cop_interface_enable_disable_t *mp;
16458 u32 sw_if_index = ~0;
16459 u8 enable_disable = 1;
16462 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16464 if (unformat (line_input, "disable"))
16465 enable_disable = 0;
16466 if (unformat (line_input, "enable"))
16467 enable_disable = 1;
16468 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16469 vam, &sw_if_index))
16471 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16477 if (sw_if_index == ~0)
16479 errmsg ("missing interface name or sw_if_index");
16483 /* Construct the API message */
16484 M (COP_INTERFACE_ENABLE_DISABLE, mp);
16485 mp->sw_if_index = ntohl (sw_if_index);
16486 mp->enable_disable = enable_disable;
16490 /* Wait for the reply */
16496 api_cop_whitelist_enable_disable (vat_main_t * vam)
16498 unformat_input_t *line_input = vam->input;
16499 vl_api_cop_whitelist_enable_disable_t *mp;
16500 u32 sw_if_index = ~0;
16501 u8 ip4 = 0, ip6 = 0, default_cop = 0;
16505 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16507 if (unformat (line_input, "ip4"))
16509 else if (unformat (line_input, "ip6"))
16511 else if (unformat (line_input, "default"))
16513 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16514 vam, &sw_if_index))
16516 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16518 else if (unformat (line_input, "fib-id %d", &fib_id))
16524 if (sw_if_index == ~0)
16526 errmsg ("missing interface name or sw_if_index");
16530 /* Construct the API message */
16531 M (COP_WHITELIST_ENABLE_DISABLE, mp);
16532 mp->sw_if_index = ntohl (sw_if_index);
16533 mp->fib_id = ntohl (fib_id);
16536 mp->default_cop = default_cop;
16540 /* Wait for the reply */
16546 api_get_node_graph (vat_main_t * vam)
16548 vl_api_get_node_graph_t *mp;
16551 M (GET_NODE_GRAPH, mp);
16555 /* Wait for the reply */
16561 /** Used for parsing LISP eids */
16562 typedef CLIB_PACKED(struct{
16563 u8 addr[16]; /**< eid address */
16564 u32 len; /**< prefix length if IP */
16565 u8 type; /**< type of eid */
16570 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
16572 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
16574 memset (a, 0, sizeof (a[0]));
16576 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
16578 a->type = 0; /* ipv4 type */
16580 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
16582 a->type = 1; /* ipv6 type */
16584 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
16586 a->type = 2; /* mac type */
16588 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
16590 a->type = 3; /* NSH type */
16591 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
16592 nsh->spi = clib_host_to_net_u32 (nsh->spi);
16599 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
16608 lisp_eid_size_vat (u8 type)
16625 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
16627 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
16631 api_one_add_del_locator_set (vat_main_t * vam)
16633 unformat_input_t *input = vam->input;
16634 vl_api_one_add_del_locator_set_t *mp;
16636 u8 *locator_set_name = NULL;
16637 u8 locator_set_name_set = 0;
16638 vl_api_local_locator_t locator, *locators = 0;
16639 u32 sw_if_index, priority, weight;
16643 /* Parse args required to build the message */
16644 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16646 if (unformat (input, "del"))
16650 else if (unformat (input, "locator-set %s", &locator_set_name))
16652 locator_set_name_set = 1;
16654 else if (unformat (input, "sw_if_index %u p %u w %u",
16655 &sw_if_index, &priority, &weight))
16657 locator.sw_if_index = htonl (sw_if_index);
16658 locator.priority = priority;
16659 locator.weight = weight;
16660 vec_add1 (locators, locator);
16664 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
16665 &sw_if_index, &priority, &weight))
16667 locator.sw_if_index = htonl (sw_if_index);
16668 locator.priority = priority;
16669 locator.weight = weight;
16670 vec_add1 (locators, locator);
16676 if (locator_set_name_set == 0)
16678 errmsg ("missing locator-set name");
16679 vec_free (locators);
16683 if (vec_len (locator_set_name) > 64)
16685 errmsg ("locator-set name too long");
16686 vec_free (locator_set_name);
16687 vec_free (locators);
16690 vec_add1 (locator_set_name, 0);
16692 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
16694 /* Construct the API message */
16695 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
16697 mp->is_add = is_add;
16698 clib_memcpy (mp->locator_set_name, locator_set_name,
16699 vec_len (locator_set_name));
16700 vec_free (locator_set_name);
16702 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
16704 clib_memcpy (mp->locators, locators, data_len);
16705 vec_free (locators);
16710 /* Wait for a reply... */
16715 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
16718 api_one_add_del_locator (vat_main_t * vam)
16720 unformat_input_t *input = vam->input;
16721 vl_api_one_add_del_locator_t *mp;
16722 u32 tmp_if_index = ~0;
16723 u32 sw_if_index = ~0;
16724 u8 sw_if_index_set = 0;
16725 u8 sw_if_index_if_name_set = 0;
16727 u8 priority_set = 0;
16731 u8 *locator_set_name = NULL;
16732 u8 locator_set_name_set = 0;
16735 /* Parse args required to build the message */
16736 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16738 if (unformat (input, "del"))
16742 else if (unformat (input, "locator-set %s", &locator_set_name))
16744 locator_set_name_set = 1;
16746 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
16749 sw_if_index_if_name_set = 1;
16750 sw_if_index = tmp_if_index;
16752 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
16754 sw_if_index_set = 1;
16755 sw_if_index = tmp_if_index;
16757 else if (unformat (input, "p %d", &priority))
16761 else if (unformat (input, "w %d", &weight))
16769 if (locator_set_name_set == 0)
16771 errmsg ("missing locator-set name");
16775 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
16777 errmsg ("missing sw_if_index");
16778 vec_free (locator_set_name);
16782 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
16784 errmsg ("cannot use both params interface name and sw_if_index");
16785 vec_free (locator_set_name);
16789 if (priority_set == 0)
16791 errmsg ("missing locator-set priority");
16792 vec_free (locator_set_name);
16796 if (weight_set == 0)
16798 errmsg ("missing locator-set weight");
16799 vec_free (locator_set_name);
16803 if (vec_len (locator_set_name) > 64)
16805 errmsg ("locator-set name too long");
16806 vec_free (locator_set_name);
16809 vec_add1 (locator_set_name, 0);
16811 /* Construct the API message */
16812 M (ONE_ADD_DEL_LOCATOR, mp);
16814 mp->is_add = is_add;
16815 mp->sw_if_index = ntohl (sw_if_index);
16816 mp->priority = priority;
16817 mp->weight = weight;
16818 clib_memcpy (mp->locator_set_name, locator_set_name,
16819 vec_len (locator_set_name));
16820 vec_free (locator_set_name);
16825 /* Wait for a reply... */
16830 #define api_lisp_add_del_locator api_one_add_del_locator
16833 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
16835 u32 *key_id = va_arg (*args, u32 *);
16838 if (unformat (input, "%s", &s))
16840 if (!strcmp ((char *) s, "sha1"))
16841 key_id[0] = HMAC_SHA_1_96;
16842 else if (!strcmp ((char *) s, "sha256"))
16843 key_id[0] = HMAC_SHA_256_128;
16846 clib_warning ("invalid key_id: '%s'", s);
16847 key_id[0] = HMAC_NO_KEY;
16858 api_one_add_del_local_eid (vat_main_t * vam)
16860 unformat_input_t *input = vam->input;
16861 vl_api_one_add_del_local_eid_t *mp;
16864 lisp_eid_vat_t _eid, *eid = &_eid;
16865 u8 *locator_set_name = 0;
16866 u8 locator_set_name_set = 0;
16872 /* Parse args required to build the message */
16873 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16875 if (unformat (input, "del"))
16879 else if (unformat (input, "vni %d", &vni))
16883 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
16887 else if (unformat (input, "locator-set %s", &locator_set_name))
16889 locator_set_name_set = 1;
16891 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
16893 else if (unformat (input, "secret-key %_%v%_", &key))
16899 if (locator_set_name_set == 0)
16901 errmsg ("missing locator-set name");
16907 errmsg ("EID address not set!");
16908 vec_free (locator_set_name);
16912 if (key && (0 == key_id))
16914 errmsg ("invalid key_id!");
16918 if (vec_len (key) > 64)
16920 errmsg ("key too long");
16925 if (vec_len (locator_set_name) > 64)
16927 errmsg ("locator-set name too long");
16928 vec_free (locator_set_name);
16931 vec_add1 (locator_set_name, 0);
16933 /* Construct the API message */
16934 M (ONE_ADD_DEL_LOCAL_EID, mp);
16936 mp->is_add = is_add;
16937 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
16938 mp->eid_type = eid->type;
16939 mp->prefix_len = eid->len;
16940 mp->vni = clib_host_to_net_u32 (vni);
16941 mp->key_id = clib_host_to_net_u16 (key_id);
16942 clib_memcpy (mp->locator_set_name, locator_set_name,
16943 vec_len (locator_set_name));
16944 clib_memcpy (mp->key, key, vec_len (key));
16946 vec_free (locator_set_name);
16952 /* Wait for a reply... */
16957 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
16960 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
16962 u32 dp_table = 0, vni = 0;;
16963 unformat_input_t *input = vam->input;
16964 vl_api_gpe_add_del_fwd_entry_t *mp;
16966 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
16967 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
16968 u8 rmt_eid_set = 0, lcl_eid_set = 0;
16969 u32 action = ~0, w;
16970 ip4_address_t rmt_rloc4, lcl_rloc4;
16971 ip6_address_t rmt_rloc6, lcl_rloc6;
16972 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
16975 memset (&rloc, 0, sizeof (rloc));
16977 /* Parse args required to build the message */
16978 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16980 if (unformat (input, "del"))
16982 else if (unformat (input, "add"))
16984 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
16988 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
16992 else if (unformat (input, "vrf %d", &dp_table))
16994 else if (unformat (input, "bd %d", &dp_table))
16996 else if (unformat (input, "vni %d", &vni))
16998 else if (unformat (input, "w %d", &w))
17002 errmsg ("No RLOC configured for setting priority/weight!");
17005 curr_rloc->weight = w;
17007 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
17008 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
17012 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
17014 vec_add1 (lcl_locs, rloc);
17016 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
17017 vec_add1 (rmt_locs, rloc);
17018 /* weight saved in rmt loc */
17019 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
17021 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
17022 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
17025 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
17027 vec_add1 (lcl_locs, rloc);
17029 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
17030 vec_add1 (rmt_locs, rloc);
17031 /* weight saved in rmt loc */
17032 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
17034 else if (unformat (input, "action %d", &action))
17040 clib_warning ("parse error '%U'", format_unformat_error, input);
17047 errmsg ("remote eid addresses not set");
17051 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
17053 errmsg ("eid types don't match");
17057 if (0 == rmt_locs && (u32) ~ 0 == action)
17059 errmsg ("action not set for negative mapping");
17063 /* Construct the API message */
17064 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
17065 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
17067 mp->is_add = is_add;
17068 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
17069 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
17070 mp->eid_type = rmt_eid->type;
17071 mp->dp_table = clib_host_to_net_u32 (dp_table);
17072 mp->vni = clib_host_to_net_u32 (vni);
17073 mp->rmt_len = rmt_eid->len;
17074 mp->lcl_len = lcl_eid->len;
17075 mp->action = action;
17077 if (0 != rmt_locs && 0 != lcl_locs)
17079 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
17080 clib_memcpy (mp->locs, lcl_locs,
17081 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
17083 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
17084 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
17085 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
17087 vec_free (lcl_locs);
17088 vec_free (rmt_locs);
17093 /* Wait for a reply... */
17099 api_one_add_del_map_server (vat_main_t * vam)
17101 unformat_input_t *input = vam->input;
17102 vl_api_one_add_del_map_server_t *mp;
17106 ip4_address_t ipv4;
17107 ip6_address_t ipv6;
17110 /* Parse args required to build the message */
17111 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17113 if (unformat (input, "del"))
17117 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17121 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17129 if (ipv4_set && ipv6_set)
17131 errmsg ("both eid v4 and v6 addresses set");
17135 if (!ipv4_set && !ipv6_set)
17137 errmsg ("eid addresses not set");
17141 /* Construct the API message */
17142 M (ONE_ADD_DEL_MAP_SERVER, mp);
17144 mp->is_add = is_add;
17148 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17153 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17159 /* Wait for a reply... */
17164 #define api_lisp_add_del_map_server api_one_add_del_map_server
17167 api_one_add_del_map_resolver (vat_main_t * vam)
17169 unformat_input_t *input = vam->input;
17170 vl_api_one_add_del_map_resolver_t *mp;
17174 ip4_address_t ipv4;
17175 ip6_address_t ipv6;
17178 /* Parse args required to build the message */
17179 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17181 if (unformat (input, "del"))
17185 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17189 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17197 if (ipv4_set && ipv6_set)
17199 errmsg ("both eid v4 and v6 addresses set");
17203 if (!ipv4_set && !ipv6_set)
17205 errmsg ("eid addresses not set");
17209 /* Construct the API message */
17210 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
17212 mp->is_add = is_add;
17216 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17221 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17227 /* Wait for a reply... */
17232 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
17235 api_lisp_gpe_enable_disable (vat_main_t * vam)
17237 unformat_input_t *input = vam->input;
17238 vl_api_gpe_enable_disable_t *mp;
17243 /* Parse args required to build the message */
17244 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17246 if (unformat (input, "enable"))
17251 else if (unformat (input, "disable"))
17262 errmsg ("Value not set");
17266 /* Construct the API message */
17267 M (GPE_ENABLE_DISABLE, mp);
17274 /* Wait for a reply... */
17280 api_one_rloc_probe_enable_disable (vat_main_t * vam)
17282 unformat_input_t *input = vam->input;
17283 vl_api_one_rloc_probe_enable_disable_t *mp;
17288 /* Parse args required to build the message */
17289 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17291 if (unformat (input, "enable"))
17296 else if (unformat (input, "disable"))
17304 errmsg ("Value not set");
17308 /* Construct the API message */
17309 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
17311 mp->is_enabled = is_en;
17316 /* Wait for a reply... */
17321 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
17324 api_one_map_register_enable_disable (vat_main_t * vam)
17326 unformat_input_t *input = vam->input;
17327 vl_api_one_map_register_enable_disable_t *mp;
17332 /* Parse args required to build the message */
17333 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17335 if (unformat (input, "enable"))
17340 else if (unformat (input, "disable"))
17348 errmsg ("Value not set");
17352 /* Construct the API message */
17353 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
17355 mp->is_enabled = is_en;
17360 /* Wait for a reply... */
17365 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
17368 api_one_enable_disable (vat_main_t * vam)
17370 unformat_input_t *input = vam->input;
17371 vl_api_one_enable_disable_t *mp;
17376 /* Parse args required to build the message */
17377 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17379 if (unformat (input, "enable"))
17384 else if (unformat (input, "disable"))
17394 errmsg ("Value not set");
17398 /* Construct the API message */
17399 M (ONE_ENABLE_DISABLE, mp);
17406 /* Wait for a reply... */
17411 #define api_lisp_enable_disable api_one_enable_disable
17414 api_one_enable_disable_xtr_mode (vat_main_t * vam)
17416 unformat_input_t *input = vam->input;
17417 vl_api_one_enable_disable_xtr_mode_t *mp;
17422 /* Parse args required to build the message */
17423 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17425 if (unformat (input, "enable"))
17430 else if (unformat (input, "disable"))
17440 errmsg ("Value not set");
17444 /* Construct the API message */
17445 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
17452 /* Wait for a reply... */
17458 api_one_show_xtr_mode (vat_main_t * vam)
17460 vl_api_one_show_xtr_mode_t *mp;
17463 /* Construct the API message */
17464 M (ONE_SHOW_XTR_MODE, mp);
17469 /* Wait for a reply... */
17475 api_one_enable_disable_pitr_mode (vat_main_t * vam)
17477 unformat_input_t *input = vam->input;
17478 vl_api_one_enable_disable_pitr_mode_t *mp;
17483 /* Parse args required to build the message */
17484 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17486 if (unformat (input, "enable"))
17491 else if (unformat (input, "disable"))
17501 errmsg ("Value not set");
17505 /* Construct the API message */
17506 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
17513 /* Wait for a reply... */
17519 api_one_show_pitr_mode (vat_main_t * vam)
17521 vl_api_one_show_pitr_mode_t *mp;
17524 /* Construct the API message */
17525 M (ONE_SHOW_PITR_MODE, mp);
17530 /* Wait for a reply... */
17536 api_one_enable_disable_petr_mode (vat_main_t * vam)
17538 unformat_input_t *input = vam->input;
17539 vl_api_one_enable_disable_petr_mode_t *mp;
17544 /* Parse args required to build the message */
17545 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17547 if (unformat (input, "enable"))
17552 else if (unformat (input, "disable"))
17562 errmsg ("Value not set");
17566 /* Construct the API message */
17567 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
17574 /* Wait for a reply... */
17580 api_one_show_petr_mode (vat_main_t * vam)
17582 vl_api_one_show_petr_mode_t *mp;
17585 /* Construct the API message */
17586 M (ONE_SHOW_PETR_MODE, mp);
17591 /* Wait for a reply... */
17597 api_show_one_map_register_state (vat_main_t * vam)
17599 vl_api_show_one_map_register_state_t *mp;
17602 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
17607 /* wait for reply */
17612 #define api_show_lisp_map_register_state api_show_one_map_register_state
17615 api_show_one_rloc_probe_state (vat_main_t * vam)
17617 vl_api_show_one_rloc_probe_state_t *mp;
17620 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
17625 /* wait for reply */
17630 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
17633 api_one_add_del_ndp_entry (vat_main_t * vam)
17635 vl_api_one_add_del_ndp_entry_t *mp;
17636 unformat_input_t *input = vam->input;
17641 u8 mac[6] = { 0, };
17642 u8 ip6[16] = { 0, };
17646 /* Parse args required to build the message */
17647 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17649 if (unformat (input, "del"))
17651 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17653 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
17655 else if (unformat (input, "bd %d", &bd))
17659 errmsg ("parse error '%U'", format_unformat_error, input);
17664 if (!bd_set || !ip_set || (!mac_set && is_add))
17666 errmsg ("Missing BD, IP or MAC!");
17670 M (ONE_ADD_DEL_NDP_ENTRY, mp);
17671 mp->is_add = is_add;
17672 clib_memcpy (mp->mac, mac, 6);
17673 mp->bd = clib_host_to_net_u32 (bd);
17674 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
17679 /* wait for reply */
17685 api_one_add_del_l2_arp_entry (vat_main_t * vam)
17687 vl_api_one_add_del_l2_arp_entry_t *mp;
17688 unformat_input_t *input = vam->input;
17693 u8 mac[6] = { 0, };
17694 u32 ip4 = 0, bd = ~0;
17697 /* Parse args required to build the message */
17698 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17700 if (unformat (input, "del"))
17702 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17704 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
17706 else if (unformat (input, "bd %d", &bd))
17710 errmsg ("parse error '%U'", format_unformat_error, input);
17715 if (!bd_set || !ip_set || (!mac_set && is_add))
17717 errmsg ("Missing BD, IP or MAC!");
17721 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
17722 mp->is_add = is_add;
17723 clib_memcpy (mp->mac, mac, 6);
17724 mp->bd = clib_host_to_net_u32 (bd);
17730 /* wait for reply */
17736 api_one_ndp_bd_get (vat_main_t * vam)
17738 vl_api_one_ndp_bd_get_t *mp;
17741 M (ONE_NDP_BD_GET, mp);
17746 /* wait for reply */
17752 api_one_ndp_entries_get (vat_main_t * vam)
17754 vl_api_one_ndp_entries_get_t *mp;
17755 unformat_input_t *input = vam->input;
17760 /* Parse args required to build the message */
17761 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17763 if (unformat (input, "bd %d", &bd))
17767 errmsg ("parse error '%U'", format_unformat_error, input);
17774 errmsg ("Expected bridge domain!");
17778 M (ONE_NDP_ENTRIES_GET, mp);
17779 mp->bd = clib_host_to_net_u32 (bd);
17784 /* wait for reply */
17790 api_one_l2_arp_bd_get (vat_main_t * vam)
17792 vl_api_one_l2_arp_bd_get_t *mp;
17795 M (ONE_L2_ARP_BD_GET, mp);
17800 /* wait for reply */
17806 api_one_l2_arp_entries_get (vat_main_t * vam)
17808 vl_api_one_l2_arp_entries_get_t *mp;
17809 unformat_input_t *input = vam->input;
17814 /* Parse args required to build the message */
17815 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17817 if (unformat (input, "bd %d", &bd))
17821 errmsg ("parse error '%U'", format_unformat_error, input);
17828 errmsg ("Expected bridge domain!");
17832 M (ONE_L2_ARP_ENTRIES_GET, mp);
17833 mp->bd = clib_host_to_net_u32 (bd);
17838 /* wait for reply */
17844 api_one_stats_enable_disable (vat_main_t * vam)
17846 vl_api_one_stats_enable_disable_t *mp;
17847 unformat_input_t *input = vam->input;
17852 /* Parse args required to build the message */
17853 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17855 if (unformat (input, "enable"))
17860 else if (unformat (input, "disable"))
17870 errmsg ("Value not set");
17874 M (ONE_STATS_ENABLE_DISABLE, mp);
17880 /* wait for reply */
17886 api_show_one_stats_enable_disable (vat_main_t * vam)
17888 vl_api_show_one_stats_enable_disable_t *mp;
17891 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
17896 /* wait for reply */
17902 api_show_one_map_request_mode (vat_main_t * vam)
17904 vl_api_show_one_map_request_mode_t *mp;
17907 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
17912 /* wait for reply */
17917 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
17920 api_one_map_request_mode (vat_main_t * vam)
17922 unformat_input_t *input = vam->input;
17923 vl_api_one_map_request_mode_t *mp;
17927 /* Parse args required to build the message */
17928 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17930 if (unformat (input, "dst-only"))
17932 else if (unformat (input, "src-dst"))
17936 errmsg ("parse error '%U'", format_unformat_error, input);
17941 M (ONE_MAP_REQUEST_MODE, mp);
17948 /* wait for reply */
17953 #define api_lisp_map_request_mode api_one_map_request_mode
17956 * Enable/disable ONE proxy ITR.
17958 * @param vam vpp API test context
17959 * @return return code
17962 api_one_pitr_set_locator_set (vat_main_t * vam)
17964 u8 ls_name_set = 0;
17965 unformat_input_t *input = vam->input;
17966 vl_api_one_pitr_set_locator_set_t *mp;
17971 /* Parse args required to build the message */
17972 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17974 if (unformat (input, "del"))
17976 else if (unformat (input, "locator-set %s", &ls_name))
17980 errmsg ("parse error '%U'", format_unformat_error, input);
17987 errmsg ("locator-set name not set!");
17991 M (ONE_PITR_SET_LOCATOR_SET, mp);
17993 mp->is_add = is_add;
17994 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
17995 vec_free (ls_name);
18000 /* wait for reply */
18005 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
18008 api_one_nsh_set_locator_set (vat_main_t * vam)
18010 u8 ls_name_set = 0;
18011 unformat_input_t *input = vam->input;
18012 vl_api_one_nsh_set_locator_set_t *mp;
18017 /* Parse args required to build the message */
18018 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18020 if (unformat (input, "del"))
18022 else if (unformat (input, "ls %s", &ls_name))
18026 errmsg ("parse error '%U'", format_unformat_error, input);
18031 if (!ls_name_set && is_add)
18033 errmsg ("locator-set name not set!");
18037 M (ONE_NSH_SET_LOCATOR_SET, mp);
18039 mp->is_add = is_add;
18040 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
18041 vec_free (ls_name);
18046 /* wait for reply */
18052 api_show_one_pitr (vat_main_t * vam)
18054 vl_api_show_one_pitr_t *mp;
18057 if (!vam->json_output)
18059 print (vam->ofp, "%=20s", "lisp status:");
18062 M (SHOW_ONE_PITR, mp);
18066 /* Wait for a reply... */
18071 #define api_show_lisp_pitr api_show_one_pitr
18074 api_one_use_petr (vat_main_t * vam)
18076 unformat_input_t *input = vam->input;
18077 vl_api_one_use_petr_t *mp;
18082 memset (&ip, 0, sizeof (ip));
18084 /* Parse args required to build the message */
18085 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18087 if (unformat (input, "disable"))
18090 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
18093 ip_addr_version (&ip) = IP4;
18096 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
18099 ip_addr_version (&ip) = IP6;
18103 errmsg ("parse error '%U'", format_unformat_error, input);
18108 M (ONE_USE_PETR, mp);
18110 mp->is_add = is_add;
18113 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
18115 clib_memcpy (mp->address, &ip, 4);
18117 clib_memcpy (mp->address, &ip, 16);
18123 /* wait for reply */
18128 #define api_lisp_use_petr api_one_use_petr
18131 api_show_one_nsh_mapping (vat_main_t * vam)
18133 vl_api_show_one_use_petr_t *mp;
18136 if (!vam->json_output)
18138 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
18141 M (SHOW_ONE_NSH_MAPPING, mp);
18145 /* Wait for a reply... */
18151 api_show_one_use_petr (vat_main_t * vam)
18153 vl_api_show_one_use_petr_t *mp;
18156 if (!vam->json_output)
18158 print (vam->ofp, "%=20s", "Proxy-ETR status:");
18161 M (SHOW_ONE_USE_PETR, mp);
18165 /* Wait for a reply... */
18170 #define api_show_lisp_use_petr api_show_one_use_petr
18173 * Add/delete mapping between vni and vrf
18176 api_one_eid_table_add_del_map (vat_main_t * vam)
18178 unformat_input_t *input = vam->input;
18179 vl_api_one_eid_table_add_del_map_t *mp;
18180 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
18181 u32 vni, vrf, bd_index;
18184 /* Parse args required to build the message */
18185 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18187 if (unformat (input, "del"))
18189 else if (unformat (input, "vrf %d", &vrf))
18191 else if (unformat (input, "bd_index %d", &bd_index))
18193 else if (unformat (input, "vni %d", &vni))
18199 if (!vni_set || (!vrf_set && !bd_index_set))
18201 errmsg ("missing arguments!");
18205 if (vrf_set && bd_index_set)
18207 errmsg ("error: both vrf and bd entered!");
18211 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
18213 mp->is_add = is_add;
18214 mp->vni = htonl (vni);
18215 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
18216 mp->is_l2 = bd_index_set;
18221 /* wait for reply */
18226 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
18229 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
18231 u32 *action = va_arg (*args, u32 *);
18234 if (unformat (input, "%s", &s))
18236 if (!strcmp ((char *) s, "no-action"))
18238 else if (!strcmp ((char *) s, "natively-forward"))
18240 else if (!strcmp ((char *) s, "send-map-request"))
18242 else if (!strcmp ((char *) s, "drop"))
18246 clib_warning ("invalid action: '%s'", s);
18258 * Add/del remote mapping to/from ONE control plane
18260 * @param vam vpp API test context
18261 * @return return code
18264 api_one_add_del_remote_mapping (vat_main_t * vam)
18266 unformat_input_t *input = vam->input;
18267 vl_api_one_add_del_remote_mapping_t *mp;
18269 lisp_eid_vat_t _eid, *eid = &_eid;
18270 lisp_eid_vat_t _seid, *seid = &_seid;
18271 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
18272 u32 action = ~0, p, w, data_len;
18273 ip4_address_t rloc4;
18274 ip6_address_t rloc6;
18275 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
18278 memset (&rloc, 0, sizeof (rloc));
18280 /* Parse args required to build the message */
18281 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18283 if (unformat (input, "del-all"))
18287 else if (unformat (input, "del"))
18291 else if (unformat (input, "add"))
18295 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
18299 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
18303 else if (unformat (input, "vni %d", &vni))
18307 else if (unformat (input, "p %d w %d", &p, &w))
18311 errmsg ("No RLOC configured for setting priority/weight!");
18314 curr_rloc->priority = p;
18315 curr_rloc->weight = w;
18317 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
18320 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
18321 vec_add1 (rlocs, rloc);
18322 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18324 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
18327 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
18328 vec_add1 (rlocs, rloc);
18329 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18331 else if (unformat (input, "action %U",
18332 unformat_negative_mapping_action, &action))
18338 clib_warning ("parse error '%U'", format_unformat_error, input);
18345 errmsg ("missing params!");
18349 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
18351 errmsg ("no action set for negative map-reply!");
18355 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
18357 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
18358 mp->is_add = is_add;
18359 mp->vni = htonl (vni);
18360 mp->action = (u8) action;
18361 mp->is_src_dst = seid_set;
18362 mp->eid_len = eid->len;
18363 mp->seid_len = seid->len;
18364 mp->del_all = del_all;
18365 mp->eid_type = eid->type;
18366 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
18367 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
18369 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
18370 clib_memcpy (mp->rlocs, rlocs, data_len);
18376 /* Wait for a reply... */
18381 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
18384 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
18385 * forwarding entries in data-plane accordingly.
18387 * @param vam vpp API test context
18388 * @return return code
18391 api_one_add_del_adjacency (vat_main_t * vam)
18393 unformat_input_t *input = vam->input;
18394 vl_api_one_add_del_adjacency_t *mp;
18396 ip4_address_t leid4, reid4;
18397 ip6_address_t leid6, reid6;
18398 u8 reid_mac[6] = { 0 };
18399 u8 leid_mac[6] = { 0 };
18400 u8 reid_type, leid_type;
18401 u32 leid_len = 0, reid_len = 0, len;
18405 leid_type = reid_type = (u8) ~ 0;
18407 /* Parse args required to build the message */
18408 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18410 if (unformat (input, "del"))
18414 else if (unformat (input, "add"))
18418 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
18421 reid_type = 0; /* ipv4 */
18424 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
18427 reid_type = 1; /* ipv6 */
18430 else if (unformat (input, "reid %U", unformat_ethernet_address,
18433 reid_type = 2; /* mac */
18435 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
18438 leid_type = 0; /* ipv4 */
18441 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
18444 leid_type = 1; /* ipv6 */
18447 else if (unformat (input, "leid %U", unformat_ethernet_address,
18450 leid_type = 2; /* mac */
18452 else if (unformat (input, "vni %d", &vni))
18458 errmsg ("parse error '%U'", format_unformat_error, input);
18463 if ((u8) ~ 0 == reid_type)
18465 errmsg ("missing params!");
18469 if (leid_type != reid_type)
18471 errmsg ("remote and local EIDs are of different types!");
18475 M (ONE_ADD_DEL_ADJACENCY, mp);
18476 mp->is_add = is_add;
18477 mp->vni = htonl (vni);
18478 mp->leid_len = leid_len;
18479 mp->reid_len = reid_len;
18480 mp->eid_type = reid_type;
18482 switch (mp->eid_type)
18485 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
18486 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
18489 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
18490 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
18493 clib_memcpy (mp->leid, leid_mac, 6);
18494 clib_memcpy (mp->reid, reid_mac, 6);
18497 errmsg ("unknown EID type %d!", mp->eid_type);
18504 /* Wait for a reply... */
18509 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
18512 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
18514 u32 *mode = va_arg (*args, u32 *);
18516 if (unformat (input, "lisp"))
18518 else if (unformat (input, "vxlan"))
18527 api_gpe_get_encap_mode (vat_main_t * vam)
18529 vl_api_gpe_get_encap_mode_t *mp;
18532 /* Construct the API message */
18533 M (GPE_GET_ENCAP_MODE, mp);
18538 /* Wait for a reply... */
18544 api_gpe_set_encap_mode (vat_main_t * vam)
18546 unformat_input_t *input = vam->input;
18547 vl_api_gpe_set_encap_mode_t *mp;
18551 /* Parse args required to build the message */
18552 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18554 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
18560 /* Construct the API message */
18561 M (GPE_SET_ENCAP_MODE, mp);
18568 /* Wait for a reply... */
18574 api_lisp_gpe_add_del_iface (vat_main_t * vam)
18576 unformat_input_t *input = vam->input;
18577 vl_api_gpe_add_del_iface_t *mp;
18578 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
18579 u32 dp_table = 0, vni = 0;
18582 /* Parse args required to build the message */
18583 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18585 if (unformat (input, "up"))
18590 else if (unformat (input, "down"))
18595 else if (unformat (input, "table_id %d", &dp_table))
18599 else if (unformat (input, "bd_id %d", &dp_table))
18604 else if (unformat (input, "vni %d", &vni))
18612 if (action_set == 0)
18614 errmsg ("Action not set");
18617 if (dp_table_set == 0 || vni_set == 0)
18619 errmsg ("vni and dp_table must be set");
18623 /* Construct the API message */
18624 M (GPE_ADD_DEL_IFACE, mp);
18626 mp->is_add = is_add;
18627 mp->dp_table = clib_host_to_net_u32 (dp_table);
18629 mp->vni = clib_host_to_net_u32 (vni);
18634 /* Wait for a reply... */
18640 api_one_map_register_fallback_threshold (vat_main_t * vam)
18642 unformat_input_t *input = vam->input;
18643 vl_api_one_map_register_fallback_threshold_t *mp;
18648 /* Parse args required to build the message */
18649 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18651 if (unformat (input, "%u", &value))
18655 clib_warning ("parse error '%U'", format_unformat_error, input);
18662 errmsg ("fallback threshold value is missing!");
18666 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18667 mp->value = clib_host_to_net_u32 (value);
18672 /* Wait for a reply... */
18678 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
18680 vl_api_show_one_map_register_fallback_threshold_t *mp;
18683 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18688 /* Wait for a reply... */
18694 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
18696 u32 *proto = va_arg (*args, u32 *);
18698 if (unformat (input, "udp"))
18700 else if (unformat (input, "api"))
18709 api_one_set_transport_protocol (vat_main_t * vam)
18711 unformat_input_t *input = vam->input;
18712 vl_api_one_set_transport_protocol_t *mp;
18717 /* Parse args required to build the message */
18718 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18720 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
18724 clib_warning ("parse error '%U'", format_unformat_error, input);
18731 errmsg ("Transport protocol missing!");
18735 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
18736 mp->protocol = (u8) protocol;
18741 /* Wait for a reply... */
18747 api_one_get_transport_protocol (vat_main_t * vam)
18749 vl_api_one_get_transport_protocol_t *mp;
18752 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
18757 /* Wait for a reply... */
18763 api_one_map_register_set_ttl (vat_main_t * vam)
18765 unformat_input_t *input = vam->input;
18766 vl_api_one_map_register_set_ttl_t *mp;
18771 /* Parse args required to build the message */
18772 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18774 if (unformat (input, "%u", &ttl))
18778 clib_warning ("parse error '%U'", format_unformat_error, input);
18785 errmsg ("TTL value missing!");
18789 M (ONE_MAP_REGISTER_SET_TTL, mp);
18790 mp->ttl = clib_host_to_net_u32 (ttl);
18795 /* Wait for a reply... */
18801 api_show_one_map_register_ttl (vat_main_t * vam)
18803 vl_api_show_one_map_register_ttl_t *mp;
18806 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
18811 /* Wait for a reply... */
18817 * Add/del map request itr rlocs from ONE control plane and updates
18819 * @param vam vpp API test context
18820 * @return return code
18823 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
18825 unformat_input_t *input = vam->input;
18826 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
18827 u8 *locator_set_name = 0;
18828 u8 locator_set_name_set = 0;
18832 /* Parse args required to build the message */
18833 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18835 if (unformat (input, "del"))
18839 else if (unformat (input, "%_%v%_", &locator_set_name))
18841 locator_set_name_set = 1;
18845 clib_warning ("parse error '%U'", format_unformat_error, input);
18850 if (is_add && !locator_set_name_set)
18852 errmsg ("itr-rloc is not set!");
18856 if (is_add && vec_len (locator_set_name) > 64)
18858 errmsg ("itr-rloc locator-set name too long");
18859 vec_free (locator_set_name);
18863 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
18864 mp->is_add = is_add;
18867 clib_memcpy (mp->locator_set_name, locator_set_name,
18868 vec_len (locator_set_name));
18872 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
18874 vec_free (locator_set_name);
18879 /* Wait for a reply... */
18884 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
18887 api_one_locator_dump (vat_main_t * vam)
18889 unformat_input_t *input = vam->input;
18890 vl_api_one_locator_dump_t *mp;
18891 vl_api_control_ping_t *mp_ping;
18892 u8 is_index_set = 0, is_name_set = 0;
18897 /* Parse args required to build the message */
18898 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18900 if (unformat (input, "ls_name %_%v%_", &ls_name))
18904 else if (unformat (input, "ls_index %d", &ls_index))
18910 errmsg ("parse error '%U'", format_unformat_error, input);
18915 if (!is_index_set && !is_name_set)
18917 errmsg ("error: expected one of index or name!");
18921 if (is_index_set && is_name_set)
18923 errmsg ("error: only one param expected!");
18927 if (vec_len (ls_name) > 62)
18929 errmsg ("error: locator set name too long!");
18933 if (!vam->json_output)
18935 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
18938 M (ONE_LOCATOR_DUMP, mp);
18939 mp->is_index_set = is_index_set;
18942 mp->ls_index = clib_host_to_net_u32 (ls_index);
18945 vec_add1 (ls_name, 0);
18946 strncpy ((char *) mp->ls_name, (char *) ls_name,
18947 sizeof (mp->ls_name) - 1);
18953 /* Use a control ping for synchronization */
18954 MPING (CONTROL_PING, mp_ping);
18957 /* Wait for a reply... */
18962 #define api_lisp_locator_dump api_one_locator_dump
18965 api_one_locator_set_dump (vat_main_t * vam)
18967 vl_api_one_locator_set_dump_t *mp;
18968 vl_api_control_ping_t *mp_ping;
18969 unformat_input_t *input = vam->input;
18973 /* Parse args required to build the message */
18974 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18976 if (unformat (input, "local"))
18980 else if (unformat (input, "remote"))
18986 errmsg ("parse error '%U'", format_unformat_error, input);
18991 if (!vam->json_output)
18993 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
18996 M (ONE_LOCATOR_SET_DUMP, mp);
18998 mp->filter = filter;
19003 /* Use a control ping for synchronization */
19004 MPING (CONTROL_PING, mp_ping);
19007 /* Wait for a reply... */
19012 #define api_lisp_locator_set_dump api_one_locator_set_dump
19015 api_one_eid_table_map_dump (vat_main_t * vam)
19019 unformat_input_t *input = vam->input;
19020 vl_api_one_eid_table_map_dump_t *mp;
19021 vl_api_control_ping_t *mp_ping;
19024 /* Parse args required to build the message */
19025 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19027 if (unformat (input, "l2"))
19032 else if (unformat (input, "l3"))
19039 errmsg ("parse error '%U'", format_unformat_error, input);
19046 errmsg ("expected one of 'l2' or 'l3' parameter!");
19050 if (!vam->json_output)
19052 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
19055 M (ONE_EID_TABLE_MAP_DUMP, mp);
19061 /* Use a control ping for synchronization */
19062 MPING (CONTROL_PING, mp_ping);
19065 /* Wait for a reply... */
19070 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
19073 api_one_eid_table_vni_dump (vat_main_t * vam)
19075 vl_api_one_eid_table_vni_dump_t *mp;
19076 vl_api_control_ping_t *mp_ping;
19079 if (!vam->json_output)
19081 print (vam->ofp, "VNI");
19084 M (ONE_EID_TABLE_VNI_DUMP, mp);
19089 /* Use a control ping for synchronization */
19090 MPING (CONTROL_PING, mp_ping);
19093 /* Wait for a reply... */
19098 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
19101 api_one_eid_table_dump (vat_main_t * vam)
19103 unformat_input_t *i = vam->input;
19104 vl_api_one_eid_table_dump_t *mp;
19105 vl_api_control_ping_t *mp_ping;
19106 struct in_addr ip4;
19107 struct in6_addr ip6;
19109 u8 eid_type = ~0, eid_set = 0;
19110 u32 prefix_length = ~0, t, vni = 0;
19113 lisp_nsh_api_t nsh;
19115 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19117 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
19123 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
19129 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
19134 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
19139 else if (unformat (i, "vni %d", &t))
19143 else if (unformat (i, "local"))
19147 else if (unformat (i, "remote"))
19153 errmsg ("parse error '%U'", format_unformat_error, i);
19158 if (!vam->json_output)
19160 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
19161 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
19164 M (ONE_EID_TABLE_DUMP, mp);
19166 mp->filter = filter;
19170 mp->vni = htonl (vni);
19171 mp->eid_type = eid_type;
19175 mp->prefix_length = prefix_length;
19176 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
19179 mp->prefix_length = prefix_length;
19180 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
19183 clib_memcpy (mp->eid, mac, sizeof (mac));
19186 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
19189 errmsg ("unknown EID type %d!", eid_type);
19197 /* Use a control ping for synchronization */
19198 MPING (CONTROL_PING, mp_ping);
19201 /* Wait for a reply... */
19206 #define api_lisp_eid_table_dump api_one_eid_table_dump
19209 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
19211 unformat_input_t *i = vam->input;
19212 vl_api_gpe_fwd_entries_get_t *mp;
19217 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19219 if (unformat (i, "vni %d", &vni))
19225 errmsg ("parse error '%U'", format_unformat_error, i);
19232 errmsg ("vni not set!");
19236 if (!vam->json_output)
19238 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
19242 M (GPE_FWD_ENTRIES_GET, mp);
19243 mp->vni = clib_host_to_net_u32 (vni);
19248 /* Wait for a reply... */
19253 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
19254 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
19255 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
19256 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
19257 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
19258 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
19259 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
19260 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
19263 api_one_adjacencies_get (vat_main_t * vam)
19265 unformat_input_t *i = vam->input;
19266 vl_api_one_adjacencies_get_t *mp;
19271 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19273 if (unformat (i, "vni %d", &vni))
19279 errmsg ("parse error '%U'", format_unformat_error, i);
19286 errmsg ("vni not set!");
19290 if (!vam->json_output)
19292 print (vam->ofp, "%s %40s", "leid", "reid");
19295 M (ONE_ADJACENCIES_GET, mp);
19296 mp->vni = clib_host_to_net_u32 (vni);
19301 /* Wait for a reply... */
19306 #define api_lisp_adjacencies_get api_one_adjacencies_get
19309 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
19311 unformat_input_t *i = vam->input;
19312 vl_api_gpe_native_fwd_rpaths_get_t *mp;
19314 u8 ip_family_set = 0, is_ip4 = 1;
19316 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19318 if (unformat (i, "ip4"))
19323 else if (unformat (i, "ip6"))
19330 errmsg ("parse error '%U'", format_unformat_error, i);
19335 if (!ip_family_set)
19337 errmsg ("ip family not set!");
19341 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
19342 mp->is_ip4 = is_ip4;
19347 /* Wait for a reply... */
19353 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
19355 vl_api_gpe_fwd_entry_vnis_get_t *mp;
19358 if (!vam->json_output)
19360 print (vam->ofp, "VNIs");
19363 M (GPE_FWD_ENTRY_VNIS_GET, mp);
19368 /* Wait for a reply... */
19374 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
19376 unformat_input_t *i = vam->input;
19377 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
19379 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
19380 struct in_addr ip4;
19381 struct in6_addr ip6;
19382 u32 table_id = 0, nh_sw_if_index = ~0;
19384 memset (&ip4, 0, sizeof (ip4));
19385 memset (&ip6, 0, sizeof (ip6));
19387 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19389 if (unformat (i, "del"))
19391 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
19392 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19397 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
19398 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19403 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
19407 nh_sw_if_index = ~0;
19409 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
19413 nh_sw_if_index = ~0;
19415 else if (unformat (i, "table %d", &table_id))
19419 errmsg ("parse error '%U'", format_unformat_error, i);
19426 errmsg ("nh addr not set!");
19430 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
19431 mp->is_add = is_add;
19432 mp->table_id = clib_host_to_net_u32 (table_id);
19433 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
19434 mp->is_ip4 = is_ip4;
19436 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
19438 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
19443 /* Wait for a reply... */
19449 api_one_map_server_dump (vat_main_t * vam)
19451 vl_api_one_map_server_dump_t *mp;
19452 vl_api_control_ping_t *mp_ping;
19455 if (!vam->json_output)
19457 print (vam->ofp, "%=20s", "Map server");
19460 M (ONE_MAP_SERVER_DUMP, mp);
19464 /* Use a control ping for synchronization */
19465 MPING (CONTROL_PING, mp_ping);
19468 /* Wait for a reply... */
19473 #define api_lisp_map_server_dump api_one_map_server_dump
19476 api_one_map_resolver_dump (vat_main_t * vam)
19478 vl_api_one_map_resolver_dump_t *mp;
19479 vl_api_control_ping_t *mp_ping;
19482 if (!vam->json_output)
19484 print (vam->ofp, "%=20s", "Map resolver");
19487 M (ONE_MAP_RESOLVER_DUMP, mp);
19491 /* Use a control ping for synchronization */
19492 MPING (CONTROL_PING, mp_ping);
19495 /* Wait for a reply... */
19500 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
19503 api_one_stats_flush (vat_main_t * vam)
19505 vl_api_one_stats_flush_t *mp;
19508 M (ONE_STATS_FLUSH, mp);
19515 api_one_stats_dump (vat_main_t * vam)
19517 vl_api_one_stats_dump_t *mp;
19518 vl_api_control_ping_t *mp_ping;
19521 M (ONE_STATS_DUMP, mp);
19525 /* Use a control ping for synchronization */
19526 MPING (CONTROL_PING, mp_ping);
19529 /* Wait for a reply... */
19535 api_show_one_status (vat_main_t * vam)
19537 vl_api_show_one_status_t *mp;
19540 if (!vam->json_output)
19542 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
19545 M (SHOW_ONE_STATUS, mp);
19548 /* Wait for a reply... */
19553 #define api_show_lisp_status api_show_one_status
19556 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
19558 vl_api_gpe_fwd_entry_path_dump_t *mp;
19559 vl_api_control_ping_t *mp_ping;
19560 unformat_input_t *i = vam->input;
19561 u32 fwd_entry_index = ~0;
19564 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19566 if (unformat (i, "index %d", &fwd_entry_index))
19572 if (~0 == fwd_entry_index)
19574 errmsg ("no index specified!");
19578 if (!vam->json_output)
19580 print (vam->ofp, "first line");
19583 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
19587 /* Use a control ping for synchronization */
19588 MPING (CONTROL_PING, mp_ping);
19591 /* Wait for a reply... */
19597 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
19599 vl_api_one_get_map_request_itr_rlocs_t *mp;
19602 if (!vam->json_output)
19604 print (vam->ofp, "%=20s", "itr-rlocs:");
19607 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
19610 /* Wait for a reply... */
19615 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
19618 api_af_packet_create (vat_main_t * vam)
19620 unformat_input_t *i = vam->input;
19621 vl_api_af_packet_create_t *mp;
19622 u8 *host_if_name = 0;
19624 u8 random_hw_addr = 1;
19627 memset (hw_addr, 0, sizeof (hw_addr));
19629 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19631 if (unformat (i, "name %s", &host_if_name))
19632 vec_add1 (host_if_name, 0);
19633 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19634 random_hw_addr = 0;
19639 if (!vec_len (host_if_name))
19641 errmsg ("host-interface name must be specified");
19645 if (vec_len (host_if_name) > 64)
19647 errmsg ("host-interface name too long");
19651 M (AF_PACKET_CREATE, mp);
19653 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19654 clib_memcpy (mp->hw_addr, hw_addr, 6);
19655 mp->use_random_hw_addr = random_hw_addr;
19656 vec_free (host_if_name);
19664 fprintf (vam->ofp ? vam->ofp : stderr,
19665 " new sw_if_index = %d\n", vam->sw_if_index);
19672 api_af_packet_delete (vat_main_t * vam)
19674 unformat_input_t *i = vam->input;
19675 vl_api_af_packet_delete_t *mp;
19676 u8 *host_if_name = 0;
19679 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19681 if (unformat (i, "name %s", &host_if_name))
19682 vec_add1 (host_if_name, 0);
19687 if (!vec_len (host_if_name))
19689 errmsg ("host-interface name must be specified");
19693 if (vec_len (host_if_name) > 64)
19695 errmsg ("host-interface name too long");
19699 M (AF_PACKET_DELETE, mp);
19701 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19702 vec_free (host_if_name);
19709 static void vl_api_af_packet_details_t_handler
19710 (vl_api_af_packet_details_t * mp)
19712 vat_main_t *vam = &vat_main;
19714 print (vam->ofp, "%-16s %d",
19715 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
19718 static void vl_api_af_packet_details_t_handler_json
19719 (vl_api_af_packet_details_t * mp)
19721 vat_main_t *vam = &vat_main;
19722 vat_json_node_t *node = NULL;
19724 if (VAT_JSON_ARRAY != vam->json_tree.type)
19726 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19727 vat_json_init_array (&vam->json_tree);
19729 node = vat_json_array_add (&vam->json_tree);
19731 vat_json_init_object (node);
19732 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
19733 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
19737 api_af_packet_dump (vat_main_t * vam)
19739 vl_api_af_packet_dump_t *mp;
19740 vl_api_control_ping_t *mp_ping;
19743 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
19744 /* Get list of tap interfaces */
19745 M (AF_PACKET_DUMP, mp);
19748 /* Use a control ping for synchronization */
19749 MPING (CONTROL_PING, mp_ping);
19757 api_policer_add_del (vat_main_t * vam)
19759 unformat_input_t *i = vam->input;
19760 vl_api_policer_add_del_t *mp;
19770 u8 color_aware = 0;
19771 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
19774 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
19775 conform_action.dscp = 0;
19776 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
19777 exceed_action.dscp = 0;
19778 violate_action.action_type = SSE2_QOS_ACTION_DROP;
19779 violate_action.dscp = 0;
19781 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19783 if (unformat (i, "del"))
19785 else if (unformat (i, "name %s", &name))
19786 vec_add1 (name, 0);
19787 else if (unformat (i, "cir %u", &cir))
19789 else if (unformat (i, "eir %u", &eir))
19791 else if (unformat (i, "cb %u", &cb))
19793 else if (unformat (i, "eb %u", &eb))
19795 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
19798 else if (unformat (i, "round_type %U", unformat_policer_round_type,
19801 else if (unformat (i, "type %U", unformat_policer_type, &type))
19803 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
19806 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
19809 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
19812 else if (unformat (i, "color-aware"))
19818 if (!vec_len (name))
19820 errmsg ("policer name must be specified");
19824 if (vec_len (name) > 64)
19826 errmsg ("policer name too long");
19830 M (POLICER_ADD_DEL, mp);
19832 clib_memcpy (mp->name, name, vec_len (name));
19834 mp->is_add = is_add;
19835 mp->cir = ntohl (cir);
19836 mp->eir = ntohl (eir);
19837 mp->cb = clib_net_to_host_u64 (cb);
19838 mp->eb = clib_net_to_host_u64 (eb);
19839 mp->rate_type = rate_type;
19840 mp->round_type = round_type;
19842 mp->conform_action_type = conform_action.action_type;
19843 mp->conform_dscp = conform_action.dscp;
19844 mp->exceed_action_type = exceed_action.action_type;
19845 mp->exceed_dscp = exceed_action.dscp;
19846 mp->violate_action_type = violate_action.action_type;
19847 mp->violate_dscp = violate_action.dscp;
19848 mp->color_aware = color_aware;
19856 api_policer_dump (vat_main_t * vam)
19858 unformat_input_t *i = vam->input;
19859 vl_api_policer_dump_t *mp;
19860 vl_api_control_ping_t *mp_ping;
19861 u8 *match_name = 0;
19862 u8 match_name_valid = 0;
19865 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19867 if (unformat (i, "name %s", &match_name))
19869 vec_add1 (match_name, 0);
19870 match_name_valid = 1;
19876 M (POLICER_DUMP, mp);
19877 mp->match_name_valid = match_name_valid;
19878 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
19879 vec_free (match_name);
19883 /* Use a control ping for synchronization */
19884 MPING (CONTROL_PING, mp_ping);
19887 /* Wait for a reply... */
19893 api_policer_classify_set_interface (vat_main_t * vam)
19895 unformat_input_t *i = vam->input;
19896 vl_api_policer_classify_set_interface_t *mp;
19898 int sw_if_index_set;
19899 u32 ip4_table_index = ~0;
19900 u32 ip6_table_index = ~0;
19901 u32 l2_table_index = ~0;
19905 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19907 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19908 sw_if_index_set = 1;
19909 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19910 sw_if_index_set = 1;
19911 else if (unformat (i, "del"))
19913 else if (unformat (i, "ip4-table %d", &ip4_table_index))
19915 else if (unformat (i, "ip6-table %d", &ip6_table_index))
19917 else if (unformat (i, "l2-table %d", &l2_table_index))
19921 clib_warning ("parse error '%U'", format_unformat_error, i);
19926 if (sw_if_index_set == 0)
19928 errmsg ("missing interface name or sw_if_index");
19932 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
19934 mp->sw_if_index = ntohl (sw_if_index);
19935 mp->ip4_table_index = ntohl (ip4_table_index);
19936 mp->ip6_table_index = ntohl (ip6_table_index);
19937 mp->l2_table_index = ntohl (l2_table_index);
19938 mp->is_add = is_add;
19946 api_policer_classify_dump (vat_main_t * vam)
19948 unformat_input_t *i = vam->input;
19949 vl_api_policer_classify_dump_t *mp;
19950 vl_api_control_ping_t *mp_ping;
19951 u8 type = POLICER_CLASSIFY_N_TABLES;
19954 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
19958 errmsg ("classify table type must be specified");
19962 if (!vam->json_output)
19964 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
19967 M (POLICER_CLASSIFY_DUMP, mp);
19972 /* Use a control ping for synchronization */
19973 MPING (CONTROL_PING, mp_ping);
19976 /* Wait for a reply... */
19982 api_netmap_create (vat_main_t * vam)
19984 unformat_input_t *i = vam->input;
19985 vl_api_netmap_create_t *mp;
19988 u8 random_hw_addr = 1;
19993 memset (hw_addr, 0, sizeof (hw_addr));
19995 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19997 if (unformat (i, "name %s", &if_name))
19998 vec_add1 (if_name, 0);
19999 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
20000 random_hw_addr = 0;
20001 else if (unformat (i, "pipe"))
20003 else if (unformat (i, "master"))
20005 else if (unformat (i, "slave"))
20011 if (!vec_len (if_name))
20013 errmsg ("interface name must be specified");
20017 if (vec_len (if_name) > 64)
20019 errmsg ("interface name too long");
20023 M (NETMAP_CREATE, mp);
20025 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20026 clib_memcpy (mp->hw_addr, hw_addr, 6);
20027 mp->use_random_hw_addr = random_hw_addr;
20028 mp->is_pipe = is_pipe;
20029 mp->is_master = is_master;
20030 vec_free (if_name);
20038 api_netmap_delete (vat_main_t * vam)
20040 unformat_input_t *i = vam->input;
20041 vl_api_netmap_delete_t *mp;
20045 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20047 if (unformat (i, "name %s", &if_name))
20048 vec_add1 (if_name, 0);
20053 if (!vec_len (if_name))
20055 errmsg ("interface name must be specified");
20059 if (vec_len (if_name) > 64)
20061 errmsg ("interface name too long");
20065 M (NETMAP_DELETE, mp);
20067 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20068 vec_free (if_name);
20076 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
20078 if (fp->afi == IP46_TYPE_IP6)
20080 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20081 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20082 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20083 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20084 format_ip6_address, fp->next_hop);
20085 else if (fp->afi == IP46_TYPE_IP4)
20087 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20088 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20089 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20090 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20091 format_ip4_address, fp->next_hop);
20095 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
20096 vl_api_fib_path_t * fp)
20098 struct in_addr ip4;
20099 struct in6_addr ip6;
20101 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20102 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20103 vat_json_object_add_uint (node, "is_local", fp->is_local);
20104 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20105 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20106 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20107 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20108 if (fp->afi == IP46_TYPE_IP4)
20110 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20111 vat_json_object_add_ip4 (node, "next_hop", ip4);
20113 else if (fp->afi == IP46_TYPE_IP6)
20115 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20116 vat_json_object_add_ip6 (node, "next_hop", ip6);
20121 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
20123 vat_main_t *vam = &vat_main;
20124 int count = ntohl (mp->mt_count);
20125 vl_api_fib_path_t *fp;
20128 print (vam->ofp, "[%d]: sw_if_index %d via:",
20129 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
20131 for (i = 0; i < count; i++)
20133 vl_api_mpls_fib_path_print (vam, fp);
20137 print (vam->ofp, "");
20140 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
20141 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
20144 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
20146 vat_main_t *vam = &vat_main;
20147 vat_json_node_t *node = NULL;
20148 int count = ntohl (mp->mt_count);
20149 vl_api_fib_path_t *fp;
20152 if (VAT_JSON_ARRAY != vam->json_tree.type)
20154 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20155 vat_json_init_array (&vam->json_tree);
20157 node = vat_json_array_add (&vam->json_tree);
20159 vat_json_init_object (node);
20160 vat_json_object_add_uint (node, "tunnel_index",
20161 ntohl (mp->mt_tunnel_index));
20162 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
20164 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
20167 for (i = 0; i < count; i++)
20169 vl_api_mpls_fib_path_json_print (node, fp);
20175 api_mpls_tunnel_dump (vat_main_t * vam)
20177 vl_api_mpls_tunnel_dump_t *mp;
20178 vl_api_control_ping_t *mp_ping;
20182 /* Parse args required to build the message */
20183 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
20185 if (!unformat (vam->input, "tunnel_index %d", &index))
20192 print (vam->ofp, " tunnel_index %d", index);
20194 M (MPLS_TUNNEL_DUMP, mp);
20195 mp->tunnel_index = htonl (index);
20198 /* Use a control ping for synchronization */
20199 MPING (CONTROL_PING, mp_ping);
20206 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
20207 #define vl_api_mpls_fib_details_t_print vl_noop_handler
20211 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
20213 vat_main_t *vam = &vat_main;
20214 int count = ntohl (mp->count);
20215 vl_api_fib_path_t *fp;
20219 "table-id %d, label %u, ess_bit %u",
20220 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
20222 for (i = 0; i < count; i++)
20224 vl_api_mpls_fib_path_print (vam, fp);
20229 static void vl_api_mpls_fib_details_t_handler_json
20230 (vl_api_mpls_fib_details_t * mp)
20232 vat_main_t *vam = &vat_main;
20233 int count = ntohl (mp->count);
20234 vat_json_node_t *node = NULL;
20235 vl_api_fib_path_t *fp;
20238 if (VAT_JSON_ARRAY != vam->json_tree.type)
20240 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20241 vat_json_init_array (&vam->json_tree);
20243 node = vat_json_array_add (&vam->json_tree);
20245 vat_json_init_object (node);
20246 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20247 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
20248 vat_json_object_add_uint (node, "label", ntohl (mp->label));
20249 vat_json_object_add_uint (node, "path_count", count);
20251 for (i = 0; i < count; i++)
20253 vl_api_mpls_fib_path_json_print (node, fp);
20259 api_mpls_fib_dump (vat_main_t * vam)
20261 vl_api_mpls_fib_dump_t *mp;
20262 vl_api_control_ping_t *mp_ping;
20265 M (MPLS_FIB_DUMP, mp);
20268 /* Use a control ping for synchronization */
20269 MPING (CONTROL_PING, mp_ping);
20276 #define vl_api_ip_fib_details_t_endian vl_noop_handler
20277 #define vl_api_ip_fib_details_t_print vl_noop_handler
20280 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
20282 vat_main_t *vam = &vat_main;
20283 int count = ntohl (mp->count);
20284 vl_api_fib_path_t *fp;
20288 "table-id %d, prefix %U/%d",
20289 ntohl (mp->table_id), format_ip4_address, mp->address,
20290 mp->address_length);
20292 for (i = 0; i < count; i++)
20294 if (fp->afi == IP46_TYPE_IP6)
20296 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20297 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U, "
20298 "next_hop_table %d",
20299 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20300 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20301 format_ip6_address, fp->next_hop, ntohl (fp->table_id));
20302 else if (fp->afi == IP46_TYPE_IP4)
20304 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20305 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U, "
20306 "next_hop_table %d",
20307 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20308 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20309 format_ip4_address, fp->next_hop, ntohl (fp->table_id));
20314 static void vl_api_ip_fib_details_t_handler_json
20315 (vl_api_ip_fib_details_t * mp)
20317 vat_main_t *vam = &vat_main;
20318 int count = ntohl (mp->count);
20319 vat_json_node_t *node = NULL;
20320 struct in_addr ip4;
20321 struct in6_addr ip6;
20322 vl_api_fib_path_t *fp;
20325 if (VAT_JSON_ARRAY != vam->json_tree.type)
20327 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20328 vat_json_init_array (&vam->json_tree);
20330 node = vat_json_array_add (&vam->json_tree);
20332 vat_json_init_object (node);
20333 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20334 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
20335 vat_json_object_add_ip4 (node, "prefix", ip4);
20336 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20337 vat_json_object_add_uint (node, "path_count", count);
20339 for (i = 0; i < count; i++)
20341 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20342 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20343 vat_json_object_add_uint (node, "is_local", fp->is_local);
20344 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20345 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20346 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20347 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20348 if (fp->afi == IP46_TYPE_IP4)
20350 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20351 vat_json_object_add_ip4 (node, "next_hop", ip4);
20353 else if (fp->afi == IP46_TYPE_IP6)
20355 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20356 vat_json_object_add_ip6 (node, "next_hop", ip6);
20362 api_ip_fib_dump (vat_main_t * vam)
20364 vl_api_ip_fib_dump_t *mp;
20365 vl_api_control_ping_t *mp_ping;
20368 M (IP_FIB_DUMP, mp);
20371 /* Use a control ping for synchronization */
20372 MPING (CONTROL_PING, mp_ping);
20380 api_ip_mfib_dump (vat_main_t * vam)
20382 vl_api_ip_mfib_dump_t *mp;
20383 vl_api_control_ping_t *mp_ping;
20386 M (IP_MFIB_DUMP, mp);
20389 /* Use a control ping for synchronization */
20390 MPING (CONTROL_PING, mp_ping);
20397 static void vl_api_ip_neighbor_details_t_handler
20398 (vl_api_ip_neighbor_details_t * mp)
20400 vat_main_t *vam = &vat_main;
20402 print (vam->ofp, "%c %U %U",
20403 (mp->is_static) ? 'S' : 'D',
20404 format_ethernet_address, &mp->mac_address,
20405 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
20409 static void vl_api_ip_neighbor_details_t_handler_json
20410 (vl_api_ip_neighbor_details_t * mp)
20413 vat_main_t *vam = &vat_main;
20414 vat_json_node_t *node;
20415 struct in_addr ip4;
20416 struct in6_addr ip6;
20418 if (VAT_JSON_ARRAY != vam->json_tree.type)
20420 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20421 vat_json_init_array (&vam->json_tree);
20423 node = vat_json_array_add (&vam->json_tree);
20425 vat_json_init_object (node);
20426 vat_json_object_add_string_copy (node, "flag",
20427 (mp->is_static) ? (u8 *) "static" : (u8 *)
20430 vat_json_object_add_string_copy (node, "link_layer",
20431 format (0, "%U", format_ethernet_address,
20432 &mp->mac_address));
20436 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
20437 vat_json_object_add_ip6 (node, "ip_address", ip6);
20441 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
20442 vat_json_object_add_ip4 (node, "ip_address", ip4);
20447 api_ip_neighbor_dump (vat_main_t * vam)
20449 unformat_input_t *i = vam->input;
20450 vl_api_ip_neighbor_dump_t *mp;
20451 vl_api_control_ping_t *mp_ping;
20453 u32 sw_if_index = ~0;
20456 /* Parse args required to build the message */
20457 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20459 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20461 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20463 else if (unformat (i, "ip6"))
20469 if (sw_if_index == ~0)
20471 errmsg ("missing interface name or sw_if_index");
20475 M (IP_NEIGHBOR_DUMP, mp);
20476 mp->is_ipv6 = (u8) is_ipv6;
20477 mp->sw_if_index = ntohl (sw_if_index);
20480 /* Use a control ping for synchronization */
20481 MPING (CONTROL_PING, mp_ping);
20488 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
20489 #define vl_api_ip6_fib_details_t_print vl_noop_handler
20492 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
20494 vat_main_t *vam = &vat_main;
20495 int count = ntohl (mp->count);
20496 vl_api_fib_path_t *fp;
20500 "table-id %d, prefix %U/%d",
20501 ntohl (mp->table_id), format_ip6_address, mp->address,
20502 mp->address_length);
20504 for (i = 0; i < count; i++)
20506 if (fp->afi == IP46_TYPE_IP6)
20508 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20509 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20510 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20511 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20512 format_ip6_address, fp->next_hop);
20513 else if (fp->afi == IP46_TYPE_IP4)
20515 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20516 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20517 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20518 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20519 format_ip4_address, fp->next_hop);
20524 static void vl_api_ip6_fib_details_t_handler_json
20525 (vl_api_ip6_fib_details_t * mp)
20527 vat_main_t *vam = &vat_main;
20528 int count = ntohl (mp->count);
20529 vat_json_node_t *node = NULL;
20530 struct in_addr ip4;
20531 struct in6_addr ip6;
20532 vl_api_fib_path_t *fp;
20535 if (VAT_JSON_ARRAY != vam->json_tree.type)
20537 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20538 vat_json_init_array (&vam->json_tree);
20540 node = vat_json_array_add (&vam->json_tree);
20542 vat_json_init_object (node);
20543 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20544 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
20545 vat_json_object_add_ip6 (node, "prefix", ip6);
20546 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20547 vat_json_object_add_uint (node, "path_count", count);
20549 for (i = 0; i < count; i++)
20551 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20552 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20553 vat_json_object_add_uint (node, "is_local", fp->is_local);
20554 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20555 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20556 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20557 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20558 if (fp->afi == IP46_TYPE_IP4)
20560 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20561 vat_json_object_add_ip4 (node, "next_hop", ip4);
20563 else if (fp->afi == IP46_TYPE_IP6)
20565 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20566 vat_json_object_add_ip6 (node, "next_hop", ip6);
20572 api_ip6_fib_dump (vat_main_t * vam)
20574 vl_api_ip6_fib_dump_t *mp;
20575 vl_api_control_ping_t *mp_ping;
20578 M (IP6_FIB_DUMP, mp);
20581 /* Use a control ping for synchronization */
20582 MPING (CONTROL_PING, mp_ping);
20590 api_ip6_mfib_dump (vat_main_t * vam)
20592 vl_api_ip6_mfib_dump_t *mp;
20593 vl_api_control_ping_t *mp_ping;
20596 M (IP6_MFIB_DUMP, mp);
20599 /* Use a control ping for synchronization */
20600 MPING (CONTROL_PING, mp_ping);
20608 api_classify_table_ids (vat_main_t * vam)
20610 vl_api_classify_table_ids_t *mp;
20613 /* Construct the API message */
20614 M (CLASSIFY_TABLE_IDS, mp);
20623 api_classify_table_by_interface (vat_main_t * vam)
20625 unformat_input_t *input = vam->input;
20626 vl_api_classify_table_by_interface_t *mp;
20628 u32 sw_if_index = ~0;
20630 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20632 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20634 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20639 if (sw_if_index == ~0)
20641 errmsg ("missing interface name or sw_if_index");
20645 /* Construct the API message */
20646 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
20648 mp->sw_if_index = ntohl (sw_if_index);
20656 api_classify_table_info (vat_main_t * vam)
20658 unformat_input_t *input = vam->input;
20659 vl_api_classify_table_info_t *mp;
20663 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20665 if (unformat (input, "table_id %d", &table_id))
20670 if (table_id == ~0)
20672 errmsg ("missing table id");
20676 /* Construct the API message */
20677 M (CLASSIFY_TABLE_INFO, mp);
20679 mp->table_id = ntohl (table_id);
20687 api_classify_session_dump (vat_main_t * vam)
20689 unformat_input_t *input = vam->input;
20690 vl_api_classify_session_dump_t *mp;
20691 vl_api_control_ping_t *mp_ping;
20695 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20697 if (unformat (input, "table_id %d", &table_id))
20702 if (table_id == ~0)
20704 errmsg ("missing table id");
20708 /* Construct the API message */
20709 M (CLASSIFY_SESSION_DUMP, mp);
20711 mp->table_id = ntohl (table_id);
20714 /* Use a control ping for synchronization */
20715 MPING (CONTROL_PING, mp_ping);
20723 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
20725 vat_main_t *vam = &vat_main;
20727 print (vam->ofp, "collector_address %U, collector_port %d, "
20728 "src_address %U, vrf_id %d, path_mtu %u, "
20729 "template_interval %u, udp_checksum %d",
20730 format_ip4_address, mp->collector_address,
20731 ntohs (mp->collector_port),
20732 format_ip4_address, mp->src_address,
20733 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
20734 ntohl (mp->template_interval), mp->udp_checksum);
20737 vam->result_ready = 1;
20741 vl_api_ipfix_exporter_details_t_handler_json
20742 (vl_api_ipfix_exporter_details_t * mp)
20744 vat_main_t *vam = &vat_main;
20745 vat_json_node_t node;
20746 struct in_addr collector_address;
20747 struct in_addr src_address;
20749 vat_json_init_object (&node);
20750 clib_memcpy (&collector_address, &mp->collector_address,
20751 sizeof (collector_address));
20752 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
20753 vat_json_object_add_uint (&node, "collector_port",
20754 ntohs (mp->collector_port));
20755 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
20756 vat_json_object_add_ip4 (&node, "src_address", src_address);
20757 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
20758 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
20759 vat_json_object_add_uint (&node, "template_interval",
20760 ntohl (mp->template_interval));
20761 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
20763 vat_json_print (vam->ofp, &node);
20764 vat_json_free (&node);
20766 vam->result_ready = 1;
20770 api_ipfix_exporter_dump (vat_main_t * vam)
20772 vl_api_ipfix_exporter_dump_t *mp;
20775 /* Construct the API message */
20776 M (IPFIX_EXPORTER_DUMP, mp);
20785 api_ipfix_classify_stream_dump (vat_main_t * vam)
20787 vl_api_ipfix_classify_stream_dump_t *mp;
20790 /* Construct the API message */
20791 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
20802 vl_api_ipfix_classify_stream_details_t_handler
20803 (vl_api_ipfix_classify_stream_details_t * mp)
20805 vat_main_t *vam = &vat_main;
20806 print (vam->ofp, "domain_id %d, src_port %d",
20807 ntohl (mp->domain_id), ntohs (mp->src_port));
20809 vam->result_ready = 1;
20813 vl_api_ipfix_classify_stream_details_t_handler_json
20814 (vl_api_ipfix_classify_stream_details_t * mp)
20816 vat_main_t *vam = &vat_main;
20817 vat_json_node_t node;
20819 vat_json_init_object (&node);
20820 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
20821 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
20823 vat_json_print (vam->ofp, &node);
20824 vat_json_free (&node);
20826 vam->result_ready = 1;
20830 api_ipfix_classify_table_dump (vat_main_t * vam)
20832 vl_api_ipfix_classify_table_dump_t *mp;
20833 vl_api_control_ping_t *mp_ping;
20836 if (!vam->json_output)
20838 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
20839 "transport_protocol");
20842 /* Construct the API message */
20843 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
20848 /* Use a control ping for synchronization */
20849 MPING (CONTROL_PING, mp_ping);
20857 vl_api_ipfix_classify_table_details_t_handler
20858 (vl_api_ipfix_classify_table_details_t * mp)
20860 vat_main_t *vam = &vat_main;
20861 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
20862 mp->transport_protocol);
20866 vl_api_ipfix_classify_table_details_t_handler_json
20867 (vl_api_ipfix_classify_table_details_t * mp)
20869 vat_json_node_t *node = NULL;
20870 vat_main_t *vam = &vat_main;
20872 if (VAT_JSON_ARRAY != vam->json_tree.type)
20874 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20875 vat_json_init_array (&vam->json_tree);
20878 node = vat_json_array_add (&vam->json_tree);
20879 vat_json_init_object (node);
20881 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
20882 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
20883 vat_json_object_add_uint (node, "transport_protocol",
20884 mp->transport_protocol);
20888 api_sw_interface_span_enable_disable (vat_main_t * vam)
20890 unformat_input_t *i = vam->input;
20891 vl_api_sw_interface_span_enable_disable_t *mp;
20892 u32 src_sw_if_index = ~0;
20893 u32 dst_sw_if_index = ~0;
20898 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20901 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
20903 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
20907 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
20909 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
20911 else if (unformat (i, "disable"))
20913 else if (unformat (i, "rx"))
20915 else if (unformat (i, "tx"))
20917 else if (unformat (i, "both"))
20919 else if (unformat (i, "l2"))
20925 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
20927 mp->sw_if_index_from = htonl (src_sw_if_index);
20928 mp->sw_if_index_to = htonl (dst_sw_if_index);
20938 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
20941 vat_main_t *vam = &vat_main;
20942 u8 *sw_if_from_name = 0;
20943 u8 *sw_if_to_name = 0;
20944 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
20945 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
20946 char *states[] = { "none", "rx", "tx", "both" };
20950 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
20952 if ((u32) p->value[0] == sw_if_index_from)
20954 sw_if_from_name = (u8 *)(p->key);
20958 if ((u32) p->value[0] == sw_if_index_to)
20960 sw_if_to_name = (u8 *)(p->key);
20961 if (sw_if_from_name)
20966 print (vam->ofp, "%20s => %20s (%s) %s",
20967 sw_if_from_name, sw_if_to_name, states[mp->state],
20968 mp->is_l2 ? "l2" : "device");
20972 vl_api_sw_interface_span_details_t_handler_json
20973 (vl_api_sw_interface_span_details_t * mp)
20975 vat_main_t *vam = &vat_main;
20976 vat_json_node_t *node = NULL;
20977 u8 *sw_if_from_name = 0;
20978 u8 *sw_if_to_name = 0;
20979 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
20980 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
20984 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
20986 if ((u32) p->value[0] == sw_if_index_from)
20988 sw_if_from_name = (u8 *)(p->key);
20992 if ((u32) p->value[0] == sw_if_index_to)
20994 sw_if_to_name = (u8 *)(p->key);
20995 if (sw_if_from_name)
21001 if (VAT_JSON_ARRAY != vam->json_tree.type)
21003 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21004 vat_json_init_array (&vam->json_tree);
21006 node = vat_json_array_add (&vam->json_tree);
21008 vat_json_init_object (node);
21009 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
21010 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
21011 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
21012 if (0 != sw_if_to_name)
21014 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
21016 vat_json_object_add_uint (node, "state", mp->state);
21017 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
21021 api_sw_interface_span_dump (vat_main_t * vam)
21023 unformat_input_t *input = vam->input;
21024 vl_api_sw_interface_span_dump_t *mp;
21025 vl_api_control_ping_t *mp_ping;
21029 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21031 if (unformat (input, "l2"))
21037 M (SW_INTERFACE_SPAN_DUMP, mp);
21041 /* Use a control ping for synchronization */
21042 MPING (CONTROL_PING, mp_ping);
21050 api_pg_create_interface (vat_main_t * vam)
21052 unformat_input_t *input = vam->input;
21053 vl_api_pg_create_interface_t *mp;
21057 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21059 if (unformat (input, "if_id %d", &if_id))
21066 errmsg ("missing pg interface index");
21070 /* Construct the API message */
21071 M (PG_CREATE_INTERFACE, mp);
21073 mp->interface_id = ntohl (if_id);
21081 api_pg_capture (vat_main_t * vam)
21083 unformat_input_t *input = vam->input;
21084 vl_api_pg_capture_t *mp;
21089 u8 pcap_file_set = 0;
21092 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21094 if (unformat (input, "if_id %d", &if_id))
21096 else if (unformat (input, "pcap %s", &pcap_file))
21098 else if (unformat (input, "count %d", &count))
21100 else if (unformat (input, "disable"))
21107 errmsg ("missing pg interface index");
21110 if (pcap_file_set > 0)
21112 if (vec_len (pcap_file) > 255)
21114 errmsg ("pcap file name is too long");
21119 u32 name_len = vec_len (pcap_file);
21120 /* Construct the API message */
21121 M (PG_CAPTURE, mp);
21123 mp->interface_id = ntohl (if_id);
21124 mp->is_enabled = enable;
21125 mp->count = ntohl (count);
21126 mp->pcap_name_length = ntohl (name_len);
21127 if (pcap_file_set != 0)
21129 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
21131 vec_free (pcap_file);
21139 api_pg_enable_disable (vat_main_t * vam)
21141 unformat_input_t *input = vam->input;
21142 vl_api_pg_enable_disable_t *mp;
21145 u8 stream_name_set = 0;
21146 u8 *stream_name = 0;
21148 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21150 if (unformat (input, "stream %s", &stream_name))
21151 stream_name_set = 1;
21152 else if (unformat (input, "disable"))
21158 if (stream_name_set > 0)
21160 if (vec_len (stream_name) > 255)
21162 errmsg ("stream name too long");
21167 u32 name_len = vec_len (stream_name);
21168 /* Construct the API message */
21169 M (PG_ENABLE_DISABLE, mp);
21171 mp->is_enabled = enable;
21172 if (stream_name_set != 0)
21174 mp->stream_name_length = ntohl (name_len);
21175 clib_memcpy (mp->stream_name, stream_name, name_len);
21177 vec_free (stream_name);
21185 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
21187 unformat_input_t *input = vam->input;
21188 vl_api_ip_source_and_port_range_check_add_del_t *mp;
21190 u16 *low_ports = 0;
21191 u16 *high_ports = 0;
21194 ip4_address_t ip4_addr;
21195 ip6_address_t ip6_addr;
21204 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21206 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
21212 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
21217 else if (unformat (input, "vrf %d", &vrf_id))
21219 else if (unformat (input, "del"))
21221 else if (unformat (input, "port %d", &tmp))
21223 if (tmp == 0 || tmp > 65535)
21225 errmsg ("port %d out of range", tmp);
21229 this_hi = this_low + 1;
21230 vec_add1 (low_ports, this_low);
21231 vec_add1 (high_ports, this_hi);
21233 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
21235 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
21237 errmsg ("incorrect range parameters");
21241 /* Note: in debug CLI +1 is added to high before
21242 passing to real fn that does "the work"
21243 (ip_source_and_port_range_check_add_del).
21244 This fn is a wrapper around the binary API fn a
21245 control plane will call, which expects this increment
21246 to have occurred. Hence letting the binary API control
21247 plane fn do the increment for consistency between VAT
21248 and other control planes.
21251 vec_add1 (low_ports, this_low);
21252 vec_add1 (high_ports, this_hi);
21258 if (prefix_set == 0)
21260 errmsg ("<address>/<mask> not specified");
21266 errmsg ("VRF ID required, not specified");
21273 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21277 if (vec_len (low_ports) == 0)
21279 errmsg ("At least one port or port range required");
21283 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
21285 mp->is_add = is_add;
21290 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
21295 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
21298 mp->mask_length = length;
21299 mp->number_of_ranges = vec_len (low_ports);
21301 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
21302 vec_free (low_ports);
21304 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
21305 vec_free (high_ports);
21307 mp->vrf_id = ntohl (vrf_id);
21315 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
21317 unformat_input_t *input = vam->input;
21318 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
21319 u32 sw_if_index = ~0;
21321 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
21322 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
21326 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21328 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21330 else if (unformat (input, "sw_if_index %d", &sw_if_index))
21332 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
21334 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
21336 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
21338 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
21340 else if (unformat (input, "del"))
21346 if (sw_if_index == ~0)
21348 errmsg ("Interface required but not specified");
21354 errmsg ("VRF ID required but not specified");
21358 if (tcp_out_vrf_id == 0
21359 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
21362 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21366 /* Construct the API message */
21367 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
21369 mp->sw_if_index = ntohl (sw_if_index);
21370 mp->is_add = is_add;
21371 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
21372 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
21373 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
21374 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
21379 /* Wait for a reply... */
21385 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
21387 unformat_input_t *i = vam->input;
21388 vl_api_ipsec_gre_add_del_tunnel_t *mp;
21389 u32 local_sa_id = 0;
21390 u32 remote_sa_id = 0;
21391 ip4_address_t src_address;
21392 ip4_address_t dst_address;
21396 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21398 if (unformat (i, "local_sa %d", &local_sa_id))
21400 else if (unformat (i, "remote_sa %d", &remote_sa_id))
21402 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
21404 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
21406 else if (unformat (i, "del"))
21410 clib_warning ("parse error '%U'", format_unformat_error, i);
21415 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
21417 mp->local_sa_id = ntohl (local_sa_id);
21418 mp->remote_sa_id = ntohl (remote_sa_id);
21419 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
21420 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
21421 mp->is_add = is_add;
21429 api_punt (vat_main_t * vam)
21431 unformat_input_t *i = vam->input;
21439 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21441 if (unformat (i, "ip %d", &ipv))
21443 else if (unformat (i, "protocol %d", &protocol))
21445 else if (unformat (i, "port %d", &port))
21447 else if (unformat (i, "del"))
21451 clib_warning ("parse error '%U'", format_unformat_error, i);
21458 mp->is_add = (u8) is_add;
21459 mp->ipv = (u8) ipv;
21460 mp->l4_protocol = (u8) protocol;
21461 mp->l4_port = htons ((u16) port);
21468 static void vl_api_ipsec_gre_tunnel_details_t_handler
21469 (vl_api_ipsec_gre_tunnel_details_t * mp)
21471 vat_main_t *vam = &vat_main;
21473 print (vam->ofp, "%11d%15U%15U%14d%14d",
21474 ntohl (mp->sw_if_index),
21475 format_ip4_address, &mp->src_address,
21476 format_ip4_address, &mp->dst_address,
21477 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
21480 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
21481 (vl_api_ipsec_gre_tunnel_details_t * mp)
21483 vat_main_t *vam = &vat_main;
21484 vat_json_node_t *node = NULL;
21485 struct in_addr ip4;
21487 if (VAT_JSON_ARRAY != vam->json_tree.type)
21489 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21490 vat_json_init_array (&vam->json_tree);
21492 node = vat_json_array_add (&vam->json_tree);
21494 vat_json_init_object (node);
21495 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
21496 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
21497 vat_json_object_add_ip4 (node, "src_address", ip4);
21498 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
21499 vat_json_object_add_ip4 (node, "dst_address", ip4);
21500 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
21501 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
21505 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
21507 unformat_input_t *i = vam->input;
21508 vl_api_ipsec_gre_tunnel_dump_t *mp;
21509 vl_api_control_ping_t *mp_ping;
21511 u8 sw_if_index_set = 0;
21514 /* Parse args required to build the message */
21515 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21517 if (unformat (i, "sw_if_index %d", &sw_if_index))
21518 sw_if_index_set = 1;
21523 if (sw_if_index_set == 0)
21528 if (!vam->json_output)
21530 print (vam->ofp, "%11s%15s%15s%14s%14s",
21531 "sw_if_index", "src_address", "dst_address",
21532 "local_sa_id", "remote_sa_id");
21535 /* Get list of gre-tunnel interfaces */
21536 M (IPSEC_GRE_TUNNEL_DUMP, mp);
21538 mp->sw_if_index = htonl (sw_if_index);
21542 /* Use a control ping for synchronization */
21543 MPING (CONTROL_PING, mp_ping);
21551 api_delete_subif (vat_main_t * vam)
21553 unformat_input_t *i = vam->input;
21554 vl_api_delete_subif_t *mp;
21555 u32 sw_if_index = ~0;
21558 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21560 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21562 if (unformat (i, "sw_if_index %d", &sw_if_index))
21568 if (sw_if_index == ~0)
21570 errmsg ("missing sw_if_index");
21574 /* Construct the API message */
21575 M (DELETE_SUBIF, mp);
21576 mp->sw_if_index = ntohl (sw_if_index);
21583 #define foreach_pbb_vtr_op \
21584 _("disable", L2_VTR_DISABLED) \
21585 _("pop", L2_VTR_POP_2) \
21586 _("push", L2_VTR_PUSH_2)
21589 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
21591 unformat_input_t *i = vam->input;
21592 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
21593 u32 sw_if_index = ~0, vtr_op = ~0;
21594 u16 outer_tag = ~0;
21595 u8 dmac[6], smac[6];
21596 u8 dmac_set = 0, smac_set = 0;
21602 /* Shut up coverity */
21603 memset (dmac, 0, sizeof (dmac));
21604 memset (smac, 0, sizeof (smac));
21606 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21608 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21610 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21612 else if (unformat (i, "vtr_op %d", &vtr_op))
21614 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
21617 else if (unformat (i, "translate_pbb_stag"))
21619 if (unformat (i, "%d", &tmp))
21621 vtr_op = L2_VTR_TRANSLATE_2_1;
21627 ("translate_pbb_stag operation requires outer tag definition");
21631 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
21633 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
21635 else if (unformat (i, "sid %d", &sid))
21637 else if (unformat (i, "vlanid %d", &tmp))
21641 clib_warning ("parse error '%U'", format_unformat_error, i);
21646 if ((sw_if_index == ~0) || (vtr_op == ~0))
21648 errmsg ("missing sw_if_index or vtr operation");
21651 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
21652 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
21655 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
21659 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
21660 mp->sw_if_index = ntohl (sw_if_index);
21661 mp->vtr_op = ntohl (vtr_op);
21662 mp->outer_tag = ntohs (outer_tag);
21663 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
21664 clib_memcpy (mp->b_smac, smac, sizeof (smac));
21665 mp->b_vlanid = ntohs (vlanid);
21666 mp->i_sid = ntohl (sid);
21674 api_flow_classify_set_interface (vat_main_t * vam)
21676 unformat_input_t *i = vam->input;
21677 vl_api_flow_classify_set_interface_t *mp;
21679 int sw_if_index_set;
21680 u32 ip4_table_index = ~0;
21681 u32 ip6_table_index = ~0;
21685 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21687 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21688 sw_if_index_set = 1;
21689 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21690 sw_if_index_set = 1;
21691 else if (unformat (i, "del"))
21693 else if (unformat (i, "ip4-table %d", &ip4_table_index))
21695 else if (unformat (i, "ip6-table %d", &ip6_table_index))
21699 clib_warning ("parse error '%U'", format_unformat_error, i);
21704 if (sw_if_index_set == 0)
21706 errmsg ("missing interface name or sw_if_index");
21710 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
21712 mp->sw_if_index = ntohl (sw_if_index);
21713 mp->ip4_table_index = ntohl (ip4_table_index);
21714 mp->ip6_table_index = ntohl (ip6_table_index);
21715 mp->is_add = is_add;
21723 api_flow_classify_dump (vat_main_t * vam)
21725 unformat_input_t *i = vam->input;
21726 vl_api_flow_classify_dump_t *mp;
21727 vl_api_control_ping_t *mp_ping;
21728 u8 type = FLOW_CLASSIFY_N_TABLES;
21731 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
21735 errmsg ("classify table type must be specified");
21739 if (!vam->json_output)
21741 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
21744 M (FLOW_CLASSIFY_DUMP, mp);
21749 /* Use a control ping for synchronization */
21750 MPING (CONTROL_PING, mp_ping);
21753 /* Wait for a reply... */
21759 api_feature_enable_disable (vat_main_t * vam)
21761 unformat_input_t *i = vam->input;
21762 vl_api_feature_enable_disable_t *mp;
21764 u8 *feature_name = 0;
21765 u32 sw_if_index = ~0;
21769 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21771 if (unformat (i, "arc_name %s", &arc_name))
21773 else if (unformat (i, "feature_name %s", &feature_name))
21776 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21778 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21780 else if (unformat (i, "disable"))
21788 errmsg ("missing arc name");
21791 if (vec_len (arc_name) > 63)
21793 errmsg ("arc name too long");
21796 if (feature_name == 0)
21798 errmsg ("missing feature name");
21801 if (vec_len (feature_name) > 63)
21803 errmsg ("feature name too long");
21806 if (sw_if_index == ~0)
21808 errmsg ("missing interface name or sw_if_index");
21812 /* Construct the API message */
21813 M (FEATURE_ENABLE_DISABLE, mp);
21814 mp->sw_if_index = ntohl (sw_if_index);
21815 mp->enable = enable;
21816 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
21817 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
21818 vec_free (arc_name);
21819 vec_free (feature_name);
21827 api_sw_interface_tag_add_del (vat_main_t * vam)
21829 unformat_input_t *i = vam->input;
21830 vl_api_sw_interface_tag_add_del_t *mp;
21831 u32 sw_if_index = ~0;
21836 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21838 if (unformat (i, "tag %s", &tag))
21840 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21842 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21844 else if (unformat (i, "del"))
21850 if (sw_if_index == ~0)
21852 errmsg ("missing interface name or sw_if_index");
21856 if (enable && (tag == 0))
21858 errmsg ("no tag specified");
21862 /* Construct the API message */
21863 M (SW_INTERFACE_TAG_ADD_DEL, mp);
21864 mp->sw_if_index = ntohl (sw_if_index);
21865 mp->is_add = enable;
21867 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
21875 static void vl_api_l2_xconnect_details_t_handler
21876 (vl_api_l2_xconnect_details_t * mp)
21878 vat_main_t *vam = &vat_main;
21880 print (vam->ofp, "%15d%15d",
21881 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
21884 static void vl_api_l2_xconnect_details_t_handler_json
21885 (vl_api_l2_xconnect_details_t * mp)
21887 vat_main_t *vam = &vat_main;
21888 vat_json_node_t *node = NULL;
21890 if (VAT_JSON_ARRAY != vam->json_tree.type)
21892 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21893 vat_json_init_array (&vam->json_tree);
21895 node = vat_json_array_add (&vam->json_tree);
21897 vat_json_init_object (node);
21898 vat_json_object_add_uint (node, "rx_sw_if_index",
21899 ntohl (mp->rx_sw_if_index));
21900 vat_json_object_add_uint (node, "tx_sw_if_index",
21901 ntohl (mp->tx_sw_if_index));
21905 api_l2_xconnect_dump (vat_main_t * vam)
21907 vl_api_l2_xconnect_dump_t *mp;
21908 vl_api_control_ping_t *mp_ping;
21911 if (!vam->json_output)
21913 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
21916 M (L2_XCONNECT_DUMP, mp);
21920 /* Use a control ping for synchronization */
21921 MPING (CONTROL_PING, mp_ping);
21929 api_hw_interface_set_mtu (vat_main_t * vam)
21931 unformat_input_t *i = vam->input;
21932 vl_api_hw_interface_set_mtu_t *mp;
21933 u32 sw_if_index = ~0;
21937 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21939 if (unformat (i, "mtu %d", &mtu))
21941 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21943 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21949 if (sw_if_index == ~0)
21951 errmsg ("missing interface name or sw_if_index");
21957 errmsg ("no mtu specified");
21961 /* Construct the API message */
21962 M (HW_INTERFACE_SET_MTU, mp);
21963 mp->sw_if_index = ntohl (sw_if_index);
21964 mp->mtu = ntohs ((u16) mtu);
21972 api_p2p_ethernet_add (vat_main_t * vam)
21974 unformat_input_t *i = vam->input;
21975 vl_api_p2p_ethernet_add_t *mp;
21976 u32 parent_if_index = ~0;
21982 memset (remote_mac, 0, sizeof (remote_mac));
21983 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21985 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
21987 else if (unformat (i, "sw_if_index %d", &parent_if_index))
21991 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
21993 else if (unformat (i, "sub_id %d", &sub_id))
21997 clib_warning ("parse error '%U'", format_unformat_error, i);
22002 if (parent_if_index == ~0)
22004 errmsg ("missing interface name or sw_if_index");
22009 errmsg ("missing remote mac address");
22014 errmsg ("missing sub-interface id");
22018 M (P2P_ETHERNET_ADD, mp);
22019 mp->parent_if_index = ntohl (parent_if_index);
22020 mp->subif_id = ntohl (sub_id);
22021 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22029 api_p2p_ethernet_del (vat_main_t * vam)
22031 unformat_input_t *i = vam->input;
22032 vl_api_p2p_ethernet_del_t *mp;
22033 u32 parent_if_index = ~0;
22038 memset (remote_mac, 0, sizeof (remote_mac));
22039 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22041 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
22043 else if (unformat (i, "sw_if_index %d", &parent_if_index))
22047 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
22051 clib_warning ("parse error '%U'", format_unformat_error, i);
22056 if (parent_if_index == ~0)
22058 errmsg ("missing interface name or sw_if_index");
22063 errmsg ("missing remote mac address");
22067 M (P2P_ETHERNET_DEL, mp);
22068 mp->parent_if_index = ntohl (parent_if_index);
22069 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22077 api_lldp_config (vat_main_t * vam)
22079 unformat_input_t *i = vam->input;
22080 vl_api_lldp_config_t *mp;
22082 int tx_interval = 0;
22083 u8 *sys_name = NULL;
22086 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22088 if (unformat (i, "system-name %s", &sys_name))
22090 else if (unformat (i, "tx-hold %d", &tx_hold))
22092 else if (unformat (i, "tx-interval %d", &tx_interval))
22096 clib_warning ("parse error '%U'", format_unformat_error, i);
22101 vec_add1 (sys_name, 0);
22103 M (LLDP_CONFIG, mp);
22104 mp->tx_hold = htonl (tx_hold);
22105 mp->tx_interval = htonl (tx_interval);
22106 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
22107 vec_free (sys_name);
22115 api_sw_interface_set_lldp (vat_main_t * vam)
22117 unformat_input_t *i = vam->input;
22118 vl_api_sw_interface_set_lldp_t *mp;
22119 u32 sw_if_index = ~0;
22121 u8 *port_desc = NULL, *mgmt_oid = NULL;
22122 ip4_address_t ip4_addr;
22123 ip6_address_t ip6_addr;
22126 memset (&ip4_addr, 0, sizeof (ip4_addr));
22127 memset (&ip6_addr, 0, sizeof (ip6_addr));
22129 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22131 if (unformat (i, "disable"))
22134 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22136 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22138 else if (unformat (i, "port-desc %s", &port_desc))
22140 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
22142 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
22144 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
22150 if (sw_if_index == ~0)
22152 errmsg ("missing interface name or sw_if_index");
22156 /* Construct the API message */
22157 vec_add1 (port_desc, 0);
22158 vec_add1 (mgmt_oid, 0);
22159 M (SW_INTERFACE_SET_LLDP, mp);
22160 mp->sw_if_index = ntohl (sw_if_index);
22161 mp->enable = enable;
22162 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
22163 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
22164 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
22165 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
22166 vec_free (port_desc);
22167 vec_free (mgmt_oid);
22175 api_tcp_configure_src_addresses (vat_main_t * vam)
22177 vl_api_tcp_configure_src_addresses_t *mp;
22178 unformat_input_t *i = vam->input;
22179 ip4_address_t v4first, v4last;
22180 ip6_address_t v6first, v6last;
22185 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22187 if (unformat (i, "%U - %U",
22188 unformat_ip4_address, &v4first,
22189 unformat_ip4_address, &v4last))
22193 errmsg ("one range per message (range already set)");
22198 else if (unformat (i, "%U - %U",
22199 unformat_ip6_address, &v6first,
22200 unformat_ip6_address, &v6last))
22204 errmsg ("one range per message (range already set)");
22209 else if (unformat (i, "vrf %d", &vrf_id))
22215 if (range_set == 0)
22217 errmsg ("address range not set");
22221 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
22222 mp->vrf_id = ntohl (vrf_id);
22224 if (range_set == 2)
22227 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
22228 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
22233 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
22234 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
22241 static void vl_api_app_namespace_add_del_reply_t_handler
22242 (vl_api_app_namespace_add_del_reply_t * mp)
22244 vat_main_t *vam = &vat_main;
22245 i32 retval = ntohl (mp->retval);
22246 if (vam->async_mode)
22248 vam->async_errors += (retval < 0);
22252 vam->retval = retval;
22254 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
22255 vam->result_ready = 1;
22259 static void vl_api_app_namespace_add_del_reply_t_handler_json
22260 (vl_api_app_namespace_add_del_reply_t * mp)
22262 vat_main_t *vam = &vat_main;
22263 vat_json_node_t node;
22265 vat_json_init_object (&node);
22266 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
22267 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
22269 vat_json_print (vam->ofp, &node);
22270 vat_json_free (&node);
22272 vam->retval = ntohl (mp->retval);
22273 vam->result_ready = 1;
22277 api_app_namespace_add_del (vat_main_t * vam)
22279 vl_api_app_namespace_add_del_t *mp;
22280 unformat_input_t *i = vam->input;
22281 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
22282 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
22286 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22288 if (unformat (i, "id %_%v%_", &ns_id))
22290 else if (unformat (i, "secret %lu", &secret))
22292 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22293 sw_if_index_set = 1;
22294 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
22296 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
22301 if (!ns_id || !secret_set || !sw_if_index_set)
22303 errmsg ("namespace id, secret and sw_if_index must be set");
22306 if (vec_len (ns_id) > 64)
22308 errmsg ("namespace id too long");
22311 M (APP_NAMESPACE_ADD_DEL, mp);
22313 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
22314 mp->namespace_id_len = vec_len (ns_id);
22315 mp->secret = clib_host_to_net_u64 (secret);
22316 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
22317 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
22318 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
22326 api_sock_init_shm (vat_main_t * vam)
22328 #if VPP_API_TEST_BUILTIN == 0
22329 unformat_input_t *i = vam->input;
22330 vl_api_shm_elem_config_t *config = 0;
22331 u64 size = 64 << 20;
22334 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22336 if (unformat (i, "size %U", unformat_memory_size, &size))
22343 * Canned custom ring allocator config.
22344 * Should probably parse all of this
22346 vec_validate (config, 6);
22347 config[0].type = VL_API_VLIB_RING;
22348 config[0].size = 256;
22349 config[0].count = 32;
22351 config[1].type = VL_API_VLIB_RING;
22352 config[1].size = 1024;
22353 config[1].count = 16;
22355 config[2].type = VL_API_VLIB_RING;
22356 config[2].size = 4096;
22357 config[2].count = 2;
22359 config[3].type = VL_API_CLIENT_RING;
22360 config[3].size = 256;
22361 config[3].count = 32;
22363 config[4].type = VL_API_CLIENT_RING;
22364 config[4].size = 1024;
22365 config[4].count = 16;
22367 config[5].type = VL_API_CLIENT_RING;
22368 config[5].size = 4096;
22369 config[5].count = 2;
22371 config[6].type = VL_API_QUEUE;
22372 config[6].count = 128;
22373 config[6].size = sizeof (uword);
22375 rv = vl_socket_client_init_shm (config);
22377 vam->client_index_invalid = 1;
22385 api_dns_enable_disable (vat_main_t * vam)
22387 unformat_input_t *line_input = vam->input;
22388 vl_api_dns_enable_disable_t *mp;
22389 u8 enable_disable = 1;
22392 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22394 if (unformat (line_input, "disable"))
22395 enable_disable = 0;
22396 if (unformat (line_input, "enable"))
22397 enable_disable = 1;
22402 /* Construct the API message */
22403 M (DNS_ENABLE_DISABLE, mp);
22404 mp->enable = enable_disable;
22408 /* Wait for the reply */
22414 api_dns_resolve_name (vat_main_t * vam)
22416 unformat_input_t *line_input = vam->input;
22417 vl_api_dns_resolve_name_t *mp;
22421 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22423 if (unformat (line_input, "%s", &name))
22429 if (vec_len (name) > 127)
22431 errmsg ("name too long");
22435 /* Construct the API message */
22436 M (DNS_RESOLVE_NAME, mp);
22437 memcpy (mp->name, name, vec_len (name));
22442 /* Wait for the reply */
22448 api_dns_resolve_ip (vat_main_t * vam)
22450 unformat_input_t *line_input = vam->input;
22451 vl_api_dns_resolve_ip_t *mp;
22453 ip4_address_t addr4;
22454 ip6_address_t addr6;
22457 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22459 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
22461 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
22469 errmsg ("missing address");
22473 /* Construct the API message */
22474 M (DNS_RESOLVE_IP, mp);
22475 mp->is_ip6 = is_ip6;
22477 memcpy (mp->address, &addr6, sizeof (addr6));
22479 memcpy (mp->address, &addr4, sizeof (addr4));
22483 /* Wait for the reply */
22489 api_dns_name_server_add_del (vat_main_t * vam)
22491 unformat_input_t *i = vam->input;
22492 vl_api_dns_name_server_add_del_t *mp;
22494 ip6_address_t ip6_server;
22495 ip4_address_t ip4_server;
22500 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22502 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
22504 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
22506 else if (unformat (i, "del"))
22510 clib_warning ("parse error '%U'", format_unformat_error, i);
22515 if (ip4_set && ip6_set)
22517 errmsg ("Only one server address allowed per message");
22520 if ((ip4_set + ip6_set) == 0)
22522 errmsg ("Server address required");
22526 /* Construct the API message */
22527 M (DNS_NAME_SERVER_ADD_DEL, mp);
22531 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
22536 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
22540 mp->is_add = is_add;
22545 /* Wait for a reply, return good/bad news */
22551 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
22553 vat_main_t *vam = &vat_main;
22558 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22559 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22560 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
22561 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
22562 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22563 clib_net_to_host_u32 (mp->action_index), mp->tag);
22568 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22569 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22570 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
22571 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
22572 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22573 clib_net_to_host_u32 (mp->action_index), mp->tag);
22578 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
22581 vat_main_t *vam = &vat_main;
22582 vat_json_node_t *node = NULL;
22583 struct in6_addr ip6;
22584 struct in_addr ip4;
22586 if (VAT_JSON_ARRAY != vam->json_tree.type)
22588 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22589 vat_json_init_array (&vam->json_tree);
22591 node = vat_json_array_add (&vam->json_tree);
22592 vat_json_init_object (node);
22594 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
22595 vat_json_object_add_uint (node, "appns_index",
22596 clib_net_to_host_u32 (mp->appns_index));
22597 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
22598 vat_json_object_add_uint (node, "scope", mp->scope);
22599 vat_json_object_add_uint (node, "action_index",
22600 clib_net_to_host_u32 (mp->action_index));
22601 vat_json_object_add_uint (node, "lcl_port",
22602 clib_net_to_host_u16 (mp->lcl_port));
22603 vat_json_object_add_uint (node, "rmt_port",
22604 clib_net_to_host_u16 (mp->rmt_port));
22605 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
22606 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
22607 vat_json_object_add_string_copy (node, "tag", mp->tag);
22610 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
22611 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
22612 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
22613 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
22617 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
22618 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
22619 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
22620 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
22625 api_session_rule_add_del (vat_main_t * vam)
22627 vl_api_session_rule_add_del_t *mp;
22628 unformat_input_t *i = vam->input;
22629 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
22630 u32 appns_index = 0, scope = 0;
22631 ip4_address_t lcl_ip4, rmt_ip4;
22632 ip6_address_t lcl_ip6, rmt_ip6;
22633 u8 is_ip4 = 1, conn_set = 0;
22634 u8 is_add = 1, *tag = 0;
22637 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22639 if (unformat (i, "del"))
22641 else if (unformat (i, "add"))
22643 else if (unformat (i, "proto tcp"))
22645 else if (unformat (i, "proto udp"))
22647 else if (unformat (i, "appns %d", &appns_index))
22649 else if (unformat (i, "scope %d", &scope))
22651 else if (unformat (i, "tag %_%v%_", &tag))
22655 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
22656 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
22664 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
22665 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
22671 else if (unformat (i, "action %d", &action))
22676 if (proto == ~0 || !conn_set || action == ~0)
22678 errmsg ("transport proto, connection and action must be set");
22684 errmsg ("scope should be 0-3");
22688 M (SESSION_RULE_ADD_DEL, mp);
22690 mp->is_ip4 = is_ip4;
22691 mp->transport_proto = proto;
22692 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
22693 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
22694 mp->lcl_plen = lcl_plen;
22695 mp->rmt_plen = rmt_plen;
22696 mp->action_index = clib_host_to_net_u32 (action);
22697 mp->appns_index = clib_host_to_net_u32 (appns_index);
22699 mp->is_add = is_add;
22702 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
22703 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
22707 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
22708 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
22712 clib_memcpy (mp->tag, tag, vec_len (tag));
22722 api_session_rules_dump (vat_main_t * vam)
22724 vl_api_session_rules_dump_t *mp;
22725 vl_api_control_ping_t *mp_ping;
22728 if (!vam->json_output)
22730 print (vam->ofp, "%=20s", "Session Rules");
22733 M (SESSION_RULES_DUMP, mp);
22737 /* Use a control ping for synchronization */
22738 MPING (CONTROL_PING, mp_ping);
22741 /* Wait for a reply... */
22747 api_ip_container_proxy_add_del (vat_main_t * vam)
22749 vl_api_ip_container_proxy_add_del_t *mp;
22750 unformat_input_t *i = vam->input;
22751 u32 plen = ~0, sw_if_index = ~0;
22758 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22760 if (unformat (i, "del"))
22762 else if (unformat (i, "add"))
22764 if (unformat (i, "%U", unformat_ip4_address, &ip4))
22769 else if (unformat (i, "%U", unformat_ip6_address, &ip6))
22774 else if (unformat (i, "sw_if_index %u", &sw_if_index))
22779 if (sw_if_index == ~0 || plen == ~0)
22781 errmsg ("address and sw_if_index must be set");
22785 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
22787 mp->is_ip4 = is_ip4;
22788 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
22790 mp->is_add = is_add;
22792 clib_memcpy (mp->ip, &ip4, sizeof (ip4));
22794 clib_memcpy (mp->ip, &ip6, sizeof (ip6));
22802 api_qos_record_enable_disable (vat_main_t * vam)
22804 unformat_input_t *i = vam->input;
22805 vl_api_qos_record_enable_disable_t *mp;
22806 u32 sw_if_index, qs = 0xff;
22807 u8 sw_if_index_set = 0;
22811 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22813 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22814 sw_if_index_set = 1;
22815 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22816 sw_if_index_set = 1;
22817 else if (unformat (i, "%U", unformat_qos_source, &qs))
22819 else if (unformat (i, "disable"))
22823 clib_warning ("parse error '%U'", format_unformat_error, i);
22828 if (sw_if_index_set == 0)
22830 errmsg ("missing interface name or sw_if_index");
22835 errmsg ("input location must be specified");
22839 M (QOS_RECORD_ENABLE_DISABLE, mp);
22841 mp->sw_if_index = ntohl (sw_if_index);
22842 mp->input_source = qs;
22843 mp->enable = enable;
22852 q_or_quit (vat_main_t * vam)
22854 #if VPP_API_TEST_BUILTIN == 0
22855 longjmp (vam->jump_buf, 1);
22857 return 0; /* not so much */
22861 q (vat_main_t * vam)
22863 return q_or_quit (vam);
22867 quit (vat_main_t * vam)
22869 return q_or_quit (vam);
22873 comment (vat_main_t * vam)
22879 statseg (vat_main_t * vam)
22881 ssvm_private_t *ssvmp = &vam->stat_segment;
22882 ssvm_shared_header_t *shared_header = ssvmp->sh;
22883 vlib_counter_t **counters;
22884 u64 thread0_index1_packets;
22885 u64 thread0_index1_bytes;
22886 f64 vector_rate, input_rate;
22889 uword *counter_vector_by_name;
22890 if (vam->stat_segment_lockp == 0)
22892 errmsg ("Stat segment not mapped...");
22896 /* look up "/if/rx for sw_if_index 1 as a test */
22898 clib_spinlock_lock (vam->stat_segment_lockp);
22900 counter_vector_by_name = (uword *) shared_header->opaque[1];
22902 p = hash_get_mem (counter_vector_by_name, "/if/rx");
22905 clib_spinlock_unlock (vam->stat_segment_lockp);
22906 errmsg ("/if/tx not found?");
22910 /* Fish per-thread vector of combined counters from shared memory */
22911 counters = (vlib_counter_t **) p[0];
22913 if (vec_len (counters[0]) < 2)
22915 clib_spinlock_unlock (vam->stat_segment_lockp);
22916 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
22920 /* Read thread 0 sw_if_index 1 counter */
22921 thread0_index1_packets = counters[0][1].packets;
22922 thread0_index1_bytes = counters[0][1].bytes;
22924 p = hash_get_mem (counter_vector_by_name, "vector_rate");
22927 clib_spinlock_unlock (vam->stat_segment_lockp);
22928 errmsg ("vector_rate not found?");
22932 vector_rate = *(f64 *) (p[0]);
22933 p = hash_get_mem (counter_vector_by_name, "input_rate");
22936 clib_spinlock_unlock (vam->stat_segment_lockp);
22937 errmsg ("input_rate not found?");
22940 input_rate = *(f64 *) (p[0]);
22942 clib_spinlock_unlock (vam->stat_segment_lockp);
22944 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
22945 vector_rate, input_rate);
22946 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
22947 thread0_index1_packets, thread0_index1_bytes);
22953 cmd_cmp (void *a1, void *a2)
22958 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
22962 help (vat_main_t * vam)
22967 unformat_input_t *i = vam->input;
22970 if (unformat (i, "%s", &name))
22974 vec_add1 (name, 0);
22976 hs = hash_get_mem (vam->help_by_name, name);
22978 print (vam->ofp, "usage: %s %s", name, hs[0]);
22980 print (vam->ofp, "No such msg / command '%s'", name);
22985 print (vam->ofp, "Help is available for the following:");
22988 hash_foreach_pair (p, vam->function_by_name,
22990 vec_add1 (cmds, (u8 *)(p->key));
22994 vec_sort_with_function (cmds, cmd_cmp);
22996 for (j = 0; j < vec_len (cmds); j++)
22997 print (vam->ofp, "%s", cmds[j]);
23004 set (vat_main_t * vam)
23006 u8 *name = 0, *value = 0;
23007 unformat_input_t *i = vam->input;
23009 if (unformat (i, "%s", &name))
23011 /* The input buffer is a vector, not a string. */
23012 value = vec_dup (i->buffer);
23013 vec_delete (value, i->index, 0);
23014 /* Almost certainly has a trailing newline */
23015 if (value[vec_len (value) - 1] == '\n')
23016 value[vec_len (value) - 1] = 0;
23017 /* Make sure it's a proper string, one way or the other */
23018 vec_add1 (value, 0);
23019 (void) clib_macro_set_value (&vam->macro_main,
23020 (char *) name, (char *) value);
23023 errmsg ("usage: set <name> <value>");
23031 unset (vat_main_t * vam)
23035 if (unformat (vam->input, "%s", &name))
23036 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
23037 errmsg ("unset: %s wasn't set", name);
23050 macro_sort_cmp (void *a1, void *a2)
23052 macro_sort_t *s1 = a1;
23053 macro_sort_t *s2 = a2;
23055 return strcmp ((char *) (s1->name), (char *) (s2->name));
23059 dump_macro_table (vat_main_t * vam)
23061 macro_sort_t *sort_me = 0, *sm;
23066 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
23068 vec_add2 (sort_me, sm, 1);
23069 sm->name = (u8 *)(p->key);
23070 sm->value = (u8 *) (p->value[0]);
23074 vec_sort_with_function (sort_me, macro_sort_cmp);
23076 if (vec_len (sort_me))
23077 print (vam->ofp, "%-15s%s", "Name", "Value");
23079 print (vam->ofp, "The macro table is empty...");
23081 for (i = 0; i < vec_len (sort_me); i++)
23082 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
23087 dump_node_table (vat_main_t * vam)
23090 vlib_node_t *node, *next_node;
23092 if (vec_len (vam->graph_nodes) == 0)
23094 print (vam->ofp, "Node table empty, issue get_node_graph...");
23098 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
23100 node = vam->graph_nodes[0][i];
23101 print (vam->ofp, "[%d] %s", i, node->name);
23102 for (j = 0; j < vec_len (node->next_nodes); j++)
23104 if (node->next_nodes[j] != ~0)
23106 next_node = vam->graph_nodes[0][node->next_nodes[j]];
23107 print (vam->ofp, " [%d] %s", j, next_node->name);
23115 value_sort_cmp (void *a1, void *a2)
23117 name_sort_t *n1 = a1;
23118 name_sort_t *n2 = a2;
23120 if (n1->value < n2->value)
23122 if (n1->value > n2->value)
23129 dump_msg_api_table (vat_main_t * vam)
23131 api_main_t *am = &api_main;
23132 name_sort_t *nses = 0, *ns;
23137 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
23139 vec_add2 (nses, ns, 1);
23140 ns->name = (u8 *)(hp->key);
23141 ns->value = (u32) hp->value[0];
23145 vec_sort_with_function (nses, value_sort_cmp);
23147 for (i = 0; i < vec_len (nses); i++)
23148 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
23154 get_msg_id (vat_main_t * vam)
23159 if (unformat (vam->input, "%s", &name_and_crc))
23161 message_index = vl_msg_api_get_msg_index (name_and_crc);
23162 if (message_index == ~0)
23164 print (vam->ofp, " '%s' not found", name_and_crc);
23167 print (vam->ofp, " '%s' has message index %d",
23168 name_and_crc, message_index);
23171 errmsg ("name_and_crc required...");
23176 search_node_table (vat_main_t * vam)
23178 unformat_input_t *line_input = vam->input;
23181 vlib_node_t *node, *next_node;
23184 if (vam->graph_node_index_by_name == 0)
23186 print (vam->ofp, "Node table empty, issue get_node_graph...");
23190 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
23192 if (unformat (line_input, "%s", &node_to_find))
23194 vec_add1 (node_to_find, 0);
23195 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
23198 print (vam->ofp, "%s not found...", node_to_find);
23201 node = vam->graph_nodes[0][p[0]];
23202 print (vam->ofp, "[%d] %s", p[0], node->name);
23203 for (j = 0; j < vec_len (node->next_nodes); j++)
23205 if (node->next_nodes[j] != ~0)
23207 next_node = vam->graph_nodes[0][node->next_nodes[j]];
23208 print (vam->ofp, " [%d] %s", j, next_node->name);
23215 clib_warning ("parse error '%U'", format_unformat_error,
23221 vec_free (node_to_find);
23230 script (vat_main_t * vam)
23232 #if (VPP_API_TEST_BUILTIN==0)
23234 char *save_current_file;
23235 unformat_input_t save_input;
23236 jmp_buf save_jump_buf;
23237 u32 save_line_number;
23239 FILE *new_fp, *save_ifp;
23241 if (unformat (vam->input, "%s", &s))
23243 new_fp = fopen ((char *) s, "r");
23246 errmsg ("Couldn't open script file %s", s);
23253 errmsg ("Missing script name");
23257 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
23258 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
23259 save_ifp = vam->ifp;
23260 save_line_number = vam->input_line_number;
23261 save_current_file = (char *) vam->current_file;
23263 vam->input_line_number = 0;
23265 vam->current_file = s;
23268 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
23269 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
23270 vam->ifp = save_ifp;
23271 vam->input_line_number = save_line_number;
23272 vam->current_file = (u8 *) save_current_file;
23277 clib_warning ("use the exec command...");
23283 echo (vat_main_t * vam)
23285 print (vam->ofp, "%v", vam->input->buffer);
23289 /* List of API message constructors, CLI names map to api_xxx */
23290 #define foreach_vpe_api_msg \
23291 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
23292 _(sw_interface_dump,"") \
23293 _(sw_interface_set_flags, \
23294 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
23295 _(sw_interface_add_del_address, \
23296 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
23297 _(sw_interface_set_rx_mode, \
23298 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
23299 _(sw_interface_set_rx_placement, \
23300 "<intfc> | sw_if_index <id> [queue <id>] [worker <id> | main]") \
23301 _(sw_interface_set_table, \
23302 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
23303 _(sw_interface_set_mpls_enable, \
23304 "<intfc> | sw_if_index [disable | dis]") \
23305 _(sw_interface_set_vpath, \
23306 "<intfc> | sw_if_index <id> enable | disable") \
23307 _(sw_interface_set_vxlan_bypass, \
23308 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23309 _(sw_interface_set_geneve_bypass, \
23310 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23311 _(sw_interface_set_l2_xconnect, \
23312 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23313 "enable | disable") \
23314 _(sw_interface_set_l2_bridge, \
23315 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
23316 "[shg <split-horizon-group>] [bvi]\n" \
23317 "enable | disable") \
23318 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
23319 _(bridge_domain_add_del, \
23320 "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") \
23321 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
23323 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
23324 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
23325 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
23327 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23329 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23331 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
23333 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
23335 "<vpp-if-name> | sw_if_index <id>") \
23336 _(sw_interface_tap_dump, "") \
23338 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>]") \
23340 "<vpp-if-name> | sw_if_index <id>") \
23341 _(sw_interface_tap_v2_dump, "") \
23343 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
23344 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]}") \
23346 "<vpp-if-name> | sw_if_index <id>") \
23348 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
23349 _(bond_detach_slave, \
23350 "sw_if_index <n>") \
23351 _(sw_interface_bond_dump, "") \
23352 _(sw_interface_slave_dump, \
23353 "<vpp-if-name> | sw_if_index <id>") \
23354 _(ip_table_add_del, \
23355 "table-id <n> [ipv6]\n") \
23356 _(ip_add_del_route, \
23357 "<addr>/<mask> via <addr> [table-id <n>]\n" \
23358 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
23359 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
23360 "[multipath] [count <n>]") \
23361 _(ip_mroute_add_del, \
23362 "<src> <grp>/<mask> [table-id <n>]\n" \
23363 "[<intfc> | sw_if_index <id>] [local] [del]") \
23364 _(mpls_table_add_del, \
23365 "table-id <n>\n") \
23366 _(mpls_route_add_del, \
23367 "<label> <eos> via <addr> [table-id <n>]\n" \
23368 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
23369 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
23370 "[multipath] [count <n>]") \
23371 _(mpls_ip_bind_unbind, \
23372 "<label> <addr/len>") \
23373 _(mpls_tunnel_add_del, \
23374 " via <addr> [table-id <n>]\n" \
23375 "sw_if_index <id>] [l2] [del]") \
23376 _(bier_table_add_del, \
23377 "<label> <sub-domain> <set> <bsl> [del]") \
23378 _(bier_route_add_del, \
23379 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
23380 "[<intfc> | sw_if_index <id>]" \
23381 "[weight <n>] [del] [multipath]") \
23382 _(proxy_arp_add_del, \
23383 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
23384 _(proxy_arp_intfc_enable_disable, \
23385 "<intfc> | sw_if_index <id> enable | disable") \
23386 _(sw_interface_set_unnumbered, \
23387 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
23388 _(ip_neighbor_add_del, \
23389 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
23390 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
23391 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
23392 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
23393 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
23394 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
23395 "[outer_vlan_id_any][inner_vlan_id_any]") \
23396 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
23397 _(reset_fib, "vrf <n> [ipv6]") \
23398 _(dhcp_proxy_config, \
23399 "svr <v46-address> src <v46-address>\n" \
23400 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
23401 _(dhcp_proxy_set_vss, \
23402 "tbl_id <n> [fib_id <n> oui <n> | vpn_ascii_id <text>] [ipv6] [del]") \
23403 _(dhcp_proxy_dump, "ip6") \
23404 _(dhcp_client_config, \
23405 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
23406 _(set_ip_flow_hash, \
23407 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
23408 _(sw_interface_ip6_enable_disable, \
23409 "<intfc> | sw_if_index <id> enable | disable") \
23410 _(sw_interface_ip6_set_link_local_address, \
23411 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
23412 _(ip6nd_proxy_add_del, \
23413 "<intfc> | sw_if_index <id> <ip6-address>") \
23414 _(ip6nd_proxy_dump, "") \
23415 _(sw_interface_ip6nd_ra_prefix, \
23416 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
23417 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
23418 "[nolink] [isno]") \
23419 _(sw_interface_ip6nd_ra_config, \
23420 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
23421 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
23422 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
23423 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
23424 _(l2_patch_add_del, \
23425 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23426 "enable | disable") \
23427 _(sr_localsid_add_del, \
23428 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
23429 "fib-table <num> (end.psp) sw_if_index <num>") \
23430 _(classify_add_del_table, \
23431 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
23432 " [del] [del-chain] mask <mask-value>\n" \
23433 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
23434 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
23435 _(classify_add_del_session, \
23436 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
23437 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
23438 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
23439 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
23440 _(classify_set_interface_ip_table, \
23441 "<intfc> | sw_if_index <nn> table <nn>") \
23442 _(classify_set_interface_l2_tables, \
23443 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23444 " [other-table <nn>]") \
23445 _(get_node_index, "node <node-name") \
23446 _(add_node_next, "node <node-name> next <next-node-name>") \
23447 _(l2tpv3_create_tunnel, \
23448 "client_address <ip6-addr> our_address <ip6-addr>\n" \
23449 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
23450 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
23451 _(l2tpv3_set_tunnel_cookies, \
23452 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
23453 "[new_remote_cookie <nn>]\n") \
23454 _(l2tpv3_interface_enable_disable, \
23455 "<intfc> | sw_if_index <nn> enable | disable") \
23456 _(l2tpv3_set_lookup_key, \
23457 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
23458 _(sw_if_l2tpv3_tunnel_dump, "") \
23459 _(vxlan_offload_rx, \
23460 "hw { <interface name> | hw_if_index <nn>} " \
23461 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
23462 _(vxlan_add_del_tunnel, \
23463 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23464 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
23465 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23466 _(geneve_add_del_tunnel, \
23467 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23468 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23469 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23470 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23471 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23472 _(gre_add_del_tunnel, \
23473 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
23474 "[teb | erspan <session-id>] [del]") \
23475 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23476 _(l2_fib_clear_table, "") \
23477 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
23478 _(l2_interface_vlan_tag_rewrite, \
23479 "<intfc> | sw_if_index <nn> \n" \
23480 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
23481 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
23482 _(create_vhost_user_if, \
23483 "socket <filename> [server] [renumber <dev_instance>] " \
23484 "[mac <mac_address>]") \
23485 _(modify_vhost_user_if, \
23486 "<intfc> | sw_if_index <nn> socket <filename>\n" \
23487 "[server] [renumber <dev_instance>]") \
23488 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
23489 _(sw_interface_vhost_user_dump, "") \
23490 _(show_version, "") \
23491 _(vxlan_gpe_add_del_tunnel, \
23492 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
23493 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23494 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
23495 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
23496 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23497 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
23498 _(interface_name_renumber, \
23499 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
23500 _(input_acl_set_interface, \
23501 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23502 " [l2-table <nn>] [del]") \
23503 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
23504 _(ip_scan_neighbor_enable_disable, "[ip4|ip6|both|disable] [interval <n-min>]\n" \
23505 " [max-time <n-usec>] [max-update <n>] [delay <n-msec>] [stale <n-min>]") \
23506 _(want_ip4_arp_events, "address <ip4-address> [del]") \
23507 _(want_ip6_nd_events, "address <ip6-address> [del]") \
23508 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
23509 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
23510 _(ip_dump, "ipv4 | ipv6") \
23511 _(ipsec_spd_add_del, "spd_id <n> [del]") \
23512 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
23514 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
23515 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
23516 " integ_alg <alg> integ_key <hex>") \
23517 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
23518 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
23519 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
23520 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
23521 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
23522 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
23523 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
23524 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
23525 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
23526 " [instance <n>]") \
23527 _(ipsec_sa_dump, "[sa_id <n>]") \
23528 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
23529 " <alg> <hex>\n") \
23530 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
23531 _(ikev2_profile_add_del, "name <profile_name> [del]") \
23532 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
23533 "(auth_data 0x<data> | auth_data <data>)") \
23534 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
23535 "(id_data 0x<data> | id_data <data>) (local|remote)") \
23536 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
23537 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
23538 "(local|remote)") \
23539 _(ikev2_set_local_key, "file <absolute_file_path>") \
23540 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
23541 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23542 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23543 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
23544 _(ikev2_initiate_sa_init, "<profile_name>") \
23545 _(ikev2_initiate_del_ike_sa, "<ispi>") \
23546 _(ikev2_initiate_del_child_sa, "<ispi>") \
23547 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
23548 _(delete_loopback,"sw_if_index <nn>") \
23549 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
23550 _(bd_ip_mac_dump, "[bd_id] <id>") \
23551 _(want_interface_events, "enable|disable") \
23552 _(want_stats,"enable|disable") \
23553 _(get_first_msg_id, "client <name>") \
23554 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
23555 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
23556 "fib-id <nn> [ip4][ip6][default]") \
23557 _(get_node_graph, " ") \
23558 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
23559 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
23560 _(ioam_disable, "") \
23561 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
23562 " sw_if_index <sw_if_index> p <priority> " \
23563 "w <weight>] [del]") \
23564 _(one_add_del_locator, "locator-set <locator_name> " \
23565 "iface <intf> | sw_if_index <sw_if_index> " \
23566 "p <priority> w <weight> [del]") \
23567 _(one_add_del_local_eid,"vni <vni> eid " \
23568 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23569 "locator-set <locator_name> [del]" \
23570 "[key-id sha1|sha256 secret-key <secret-key>]")\
23571 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
23572 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
23573 _(one_enable_disable, "enable|disable") \
23574 _(one_map_register_enable_disable, "enable|disable") \
23575 _(one_map_register_fallback_threshold, "<value>") \
23576 _(one_rloc_probe_enable_disable, "enable|disable") \
23577 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23579 "rloc <locator> p <prio> " \
23580 "w <weight> [rloc <loc> ... ] " \
23581 "action <action> [del-all]") \
23582 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23584 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23585 _(one_use_petr, "ip-address> | disable") \
23586 _(one_map_request_mode, "src-dst|dst-only") \
23587 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23588 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23589 _(one_locator_set_dump, "[local | remote]") \
23590 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
23591 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23592 "[local] | [remote]") \
23593 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
23594 _(one_ndp_bd_get, "") \
23595 _(one_ndp_entries_get, "bd <bridge-domain>") \
23596 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
23597 _(one_l2_arp_bd_get, "") \
23598 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
23599 _(one_stats_enable_disable, "enable|disalbe") \
23600 _(show_one_stats_enable_disable, "") \
23601 _(one_eid_table_vni_dump, "") \
23602 _(one_eid_table_map_dump, "l2|l3") \
23603 _(one_map_resolver_dump, "") \
23604 _(one_map_server_dump, "") \
23605 _(one_adjacencies_get, "vni <vni>") \
23606 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
23607 _(show_one_rloc_probe_state, "") \
23608 _(show_one_map_register_state, "") \
23609 _(show_one_status, "") \
23610 _(one_stats_dump, "") \
23611 _(one_stats_flush, "") \
23612 _(one_get_map_request_itr_rlocs, "") \
23613 _(one_map_register_set_ttl, "<ttl>") \
23614 _(one_set_transport_protocol, "udp|api") \
23615 _(one_get_transport_protocol, "") \
23616 _(one_enable_disable_xtr_mode, "enable|disable") \
23617 _(one_show_xtr_mode, "") \
23618 _(one_enable_disable_pitr_mode, "enable|disable") \
23619 _(one_show_pitr_mode, "") \
23620 _(one_enable_disable_petr_mode, "enable|disable") \
23621 _(one_show_petr_mode, "") \
23622 _(show_one_nsh_mapping, "") \
23623 _(show_one_pitr, "") \
23624 _(show_one_use_petr, "") \
23625 _(show_one_map_request_mode, "") \
23626 _(show_one_map_register_ttl, "") \
23627 _(show_one_map_register_fallback_threshold, "") \
23628 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
23629 " sw_if_index <sw_if_index> p <priority> " \
23630 "w <weight>] [del]") \
23631 _(lisp_add_del_locator, "locator-set <locator_name> " \
23632 "iface <intf> | sw_if_index <sw_if_index> " \
23633 "p <priority> w <weight> [del]") \
23634 _(lisp_add_del_local_eid,"vni <vni> eid " \
23635 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23636 "locator-set <locator_name> [del]" \
23637 "[key-id sha1|sha256 secret-key <secret-key>]") \
23638 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
23639 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
23640 _(lisp_enable_disable, "enable|disable") \
23641 _(lisp_map_register_enable_disable, "enable|disable") \
23642 _(lisp_rloc_probe_enable_disable, "enable|disable") \
23643 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23645 "rloc <locator> p <prio> " \
23646 "w <weight> [rloc <loc> ... ] " \
23647 "action <action> [del-all]") \
23648 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23650 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23651 _(lisp_use_petr, "<ip-address> | disable") \
23652 _(lisp_map_request_mode, "src-dst|dst-only") \
23653 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23654 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23655 _(lisp_locator_set_dump, "[local | remote]") \
23656 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
23657 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23658 "[local] | [remote]") \
23659 _(lisp_eid_table_vni_dump, "") \
23660 _(lisp_eid_table_map_dump, "l2|l3") \
23661 _(lisp_map_resolver_dump, "") \
23662 _(lisp_map_server_dump, "") \
23663 _(lisp_adjacencies_get, "vni <vni>") \
23664 _(gpe_fwd_entry_vnis_get, "") \
23665 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
23666 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
23667 "[table <table-id>]") \
23668 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
23669 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
23670 _(gpe_set_encap_mode, "lisp|vxlan") \
23671 _(gpe_get_encap_mode, "") \
23672 _(lisp_gpe_add_del_iface, "up|down") \
23673 _(lisp_gpe_enable_disable, "enable|disable") \
23674 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
23675 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
23676 _(show_lisp_rloc_probe_state, "") \
23677 _(show_lisp_map_register_state, "") \
23678 _(show_lisp_status, "") \
23679 _(lisp_get_map_request_itr_rlocs, "") \
23680 _(show_lisp_pitr, "") \
23681 _(show_lisp_use_petr, "") \
23682 _(show_lisp_map_request_mode, "") \
23683 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
23684 _(af_packet_delete, "name <host interface name>") \
23685 _(af_packet_dump, "") \
23686 _(policer_add_del, "name <policer name> <params> [del]") \
23687 _(policer_dump, "[name <policer name>]") \
23688 _(policer_classify_set_interface, \
23689 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23690 " [l2-table <nn>] [del]") \
23691 _(policer_classify_dump, "type [ip4|ip6|l2]") \
23692 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
23693 "[master|slave]") \
23694 _(netmap_delete, "name <interface name>") \
23695 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
23696 _(mpls_fib_dump, "") \
23697 _(classify_table_ids, "") \
23698 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
23699 _(classify_table_info, "table_id <nn>") \
23700 _(classify_session_dump, "table_id <nn>") \
23701 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
23702 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
23703 "[template_interval <nn>] [udp_checksum]") \
23704 _(ipfix_exporter_dump, "") \
23705 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
23706 _(ipfix_classify_stream_dump, "") \
23707 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
23708 _(ipfix_classify_table_dump, "") \
23709 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
23710 _(sw_interface_span_dump, "[l2]") \
23711 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
23712 _(pg_create_interface, "if_id <nn>") \
23713 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
23714 _(pg_enable_disable, "[stream <id>] disable") \
23715 _(ip_source_and_port_range_check_add_del, \
23716 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
23717 _(ip_source_and_port_range_check_interface_add_del, \
23718 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
23719 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
23720 _(ipsec_gre_add_del_tunnel, \
23721 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
23722 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
23723 _(delete_subif,"<intfc> | sw_if_index <nn>") \
23724 _(l2_interface_pbb_tag_rewrite, \
23725 "<intfc> | sw_if_index <nn> \n" \
23726 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
23727 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
23728 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
23729 _(flow_classify_set_interface, \
23730 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
23731 _(flow_classify_dump, "type [ip4|ip6]") \
23732 _(ip_fib_dump, "") \
23733 _(ip_mfib_dump, "") \
23734 _(ip6_fib_dump, "") \
23735 _(ip6_mfib_dump, "") \
23736 _(feature_enable_disable, "arc_name <arc_name> " \
23737 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
23738 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
23740 _(l2_xconnect_dump, "") \
23741 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
23742 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
23743 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
23744 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
23745 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
23746 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
23747 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
23748 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
23749 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
23750 _(sock_init_shm, "size <nnn>") \
23751 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
23752 _(dns_enable_disable, "[enable][disable]") \
23753 _(dns_name_server_add_del, "<ip-address> [del]") \
23754 _(dns_resolve_name, "<hostname>") \
23755 _(dns_resolve_ip, "<ip4|ip6>") \
23756 _(dns_name_server_add_del, "<ip-address> [del]") \
23757 _(dns_resolve_name, "<hostname>") \
23758 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
23759 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
23760 _(session_rules_dump, "") \
23761 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
23762 _(output_acl_set_interface, \
23763 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23764 " [l2-table <nn>] [del]") \
23765 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
23767 /* List of command functions, CLI names map directly to functions */
23768 #define foreach_cli_function \
23769 _(comment, "usage: comment <ignore-rest-of-line>") \
23770 _(dump_interface_table, "usage: dump_interface_table") \
23771 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
23772 _(dump_ipv4_table, "usage: dump_ipv4_table") \
23773 _(dump_ipv6_table, "usage: dump_ipv6_table") \
23774 _(dump_stats_table, "usage: dump_stats_table") \
23775 _(dump_macro_table, "usage: dump_macro_table ") \
23776 _(dump_node_table, "usage: dump_node_table") \
23777 _(dump_msg_api_table, "usage: dump_msg_api_table") \
23778 _(get_msg_id, "usage: get_msg_id name_and_crc") \
23779 _(echo, "usage: echo <message>") \
23780 _(exec, "usage: exec <vpe-debug-CLI-command>") \
23781 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
23782 _(help, "usage: help") \
23783 _(q, "usage: quit") \
23784 _(quit, "usage: quit") \
23785 _(search_node_table, "usage: search_node_table <name>...") \
23786 _(set, "usage: set <variable-name> <value>") \
23787 _(script, "usage: script <file-name>") \
23788 _(statseg, "usage: statseg"); \
23789 _(unset, "usage: unset <variable-name>")
23792 static void vl_api_##n##_t_handler_uni \
23793 (vl_api_##n##_t * mp) \
23795 vat_main_t * vam = &vat_main; \
23796 if (vam->json_output) { \
23797 vl_api_##n##_t_handler_json(mp); \
23799 vl_api_##n##_t_handler(mp); \
23802 foreach_vpe_api_reply_msg;
23803 #if VPP_API_TEST_BUILTIN == 0
23804 foreach_standalone_reply_msg;
23809 vat_api_hookup (vat_main_t * vam)
23812 vl_msg_api_set_handlers(VL_API_##N, #n, \
23813 vl_api_##n##_t_handler_uni, \
23815 vl_api_##n##_t_endian, \
23816 vl_api_##n##_t_print, \
23817 sizeof(vl_api_##n##_t), 1);
23818 foreach_vpe_api_reply_msg;
23819 #if VPP_API_TEST_BUILTIN == 0
23820 foreach_standalone_reply_msg;
23824 #if (VPP_API_TEST_BUILTIN==0)
23825 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
23827 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
23829 vam->function_by_name = hash_create_string (0, sizeof (uword));
23831 vam->help_by_name = hash_create_string (0, sizeof (uword));
23834 /* API messages we can send */
23835 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
23836 foreach_vpe_api_msg;
23840 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
23841 foreach_vpe_api_msg;
23844 /* CLI functions */
23845 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
23846 foreach_cli_function;
23850 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
23851 foreach_cli_function;
23855 #if VPP_API_TEST_BUILTIN
23856 static clib_error_t *
23857 vat_api_hookup_shim (vlib_main_t * vm)
23859 vat_api_hookup (&vat_main);
23863 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
23867 * fd.io coding-style-patch-verification: ON
23870 * eval: (c-set-style "gnu")