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;
1322 static void vl_api_show_threads_reply_t_handler
1323 (vl_api_show_threads_reply_t * mp)
1325 vat_main_t *vam = &vat_main;
1326 i32 retval = ntohl (mp->retval);
1330 count = ntohl (mp->count);
1332 for (i = 0; i < count; i++)
1334 "\n%-2d %-11s %-11s %-5d %-6d %-4d %-6d",
1335 ntohl (mp->thread_data[i].id), mp->thread_data[i].name,
1336 mp->thread_data[i].type, ntohl (mp->thread_data[i].pid),
1337 ntohl (mp->thread_data[i].cpu_id), ntohl (mp->thread_data[i].core),
1338 ntohl (mp->thread_data[i].cpu_socket));
1340 vam->retval = retval;
1341 vam->result_ready = 1;
1344 static void vl_api_show_threads_reply_t_handler_json
1345 (vl_api_show_threads_reply_t * mp)
1347 vat_main_t *vam = &vat_main;
1348 vat_json_node_t node;
1349 vl_api_thread_data_t *td;
1350 i32 retval = ntohl (mp->retval);
1354 count = ntohl (mp->count);
1356 vat_json_init_object (&node);
1357 vat_json_object_add_int (&node, "retval", retval);
1358 vat_json_object_add_uint (&node, "count", count);
1360 for (i = 0; i < count; i++)
1362 td = &mp->thread_data[i];
1363 vat_json_object_add_uint (&node, "id", ntohl (td->id));
1364 vat_json_object_add_string_copy (&node, "name", td->name);
1365 vat_json_object_add_string_copy (&node, "type", td->type);
1366 vat_json_object_add_uint (&node, "pid", ntohl (td->pid));
1367 vat_json_object_add_int (&node, "cpu_id", ntohl (td->cpu_id));
1368 vat_json_object_add_int (&node, "core", ntohl (td->id));
1369 vat_json_object_add_int (&node, "cpu_socket", ntohl (td->cpu_socket));
1372 vat_json_print (vam->ofp, &node);
1373 vat_json_free (&node);
1375 vam->retval = retval;
1376 vam->result_ready = 1;
1380 api_show_threads (vat_main_t * vam)
1382 vl_api_show_threads_t *mp;
1386 "\n%-2s %-11s %-11s %-5s %-6s %-4s %-6s",
1387 "ID", "Name", "Type", "LWP", "cpu_id", "Core", "Socket");
1389 M (SHOW_THREADS, mp);
1397 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1399 u32 sw_if_index = ntohl (mp->sw_if_index);
1400 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1401 mp->mac_ip ? "mac/ip binding" : "address resolution",
1402 ntohl (mp->pid), format_ip4_address, &mp->address,
1403 format_ethernet_address, mp->new_mac, sw_if_index);
1407 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1409 /* JSON output not supported */
1413 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1415 u32 sw_if_index = ntohl (mp->sw_if_index);
1416 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1417 mp->mac_ip ? "mac/ip binding" : "address resolution",
1418 ntohl (mp->pid), format_ip6_address, mp->address,
1419 format_ethernet_address, mp->new_mac, sw_if_index);
1423 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1425 /* JSON output not supported */
1429 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1431 u32 n_macs = ntohl (mp->n_macs);
1432 errmsg ("L2MAC event received with pid %d cl-idx %d for %d macs: \n",
1433 ntohl (mp->pid), mp->client_index, n_macs);
1435 for (i = 0; i < n_macs; i++)
1437 vl_api_mac_entry_t *mac = &mp->mac[i];
1438 errmsg (" [%d] sw_if_index %d mac_addr %U action %d \n",
1439 i + 1, ntohl (mac->sw_if_index),
1440 format_ethernet_address, mac->mac_addr, mac->action);
1447 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1449 /* JSON output not supported */
1452 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1453 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1456 * Special-case: build the bridge domain table, maintain
1457 * the next bd id vbl.
1459 static void vl_api_bridge_domain_details_t_handler
1460 (vl_api_bridge_domain_details_t * mp)
1462 vat_main_t *vam = &vat_main;
1463 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1466 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-6s %-3s",
1467 " ID", "LRN", "FWD", "FLD", "BVI", "UU-FWD", "#IF");
1469 print (vam->ofp, "%3d %3d %3d %3d %3d %6d %3d",
1470 ntohl (mp->bd_id), mp->learn, mp->forward,
1471 mp->flood, ntohl (mp->bvi_sw_if_index),
1472 ntohl (mp->uu_fwd_sw_if_index), n_sw_ifs);
1476 vl_api_bridge_domain_sw_if_t *sw_ifs;
1477 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1480 sw_ifs = mp->sw_if_details;
1481 for (i = 0; i < n_sw_ifs; i++)
1487 sw_if_index = ntohl (sw_ifs->sw_if_index);
1490 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1492 if ((u32) p->value[0] == sw_if_index)
1494 sw_if_name = (u8 *)(p->key);
1499 print (vam->ofp, "%7d %3d %s", sw_if_index,
1500 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1501 "sw_if_index not found!");
1508 static void vl_api_bridge_domain_details_t_handler_json
1509 (vl_api_bridge_domain_details_t * mp)
1511 vat_main_t *vam = &vat_main;
1512 vat_json_node_t *node, *array = NULL;
1513 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1515 if (VAT_JSON_ARRAY != vam->json_tree.type)
1517 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1518 vat_json_init_array (&vam->json_tree);
1520 node = vat_json_array_add (&vam->json_tree);
1522 vat_json_init_object (node);
1523 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1524 vat_json_object_add_uint (node, "flood", mp->flood);
1525 vat_json_object_add_uint (node, "forward", mp->forward);
1526 vat_json_object_add_uint (node, "learn", mp->learn);
1527 vat_json_object_add_uint (node, "bvi_sw_if_index",
1528 ntohl (mp->bvi_sw_if_index));
1529 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1530 array = vat_json_object_add (node, "sw_if");
1531 vat_json_init_array (array);
1537 vl_api_bridge_domain_sw_if_t *sw_ifs;
1540 sw_ifs = mp->sw_if_details;
1541 for (i = 0; i < n_sw_ifs; i++)
1543 node = vat_json_array_add (array);
1544 vat_json_init_object (node);
1545 vat_json_object_add_uint (node, "sw_if_index",
1546 ntohl (sw_ifs->sw_if_index));
1547 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1553 static void vl_api_control_ping_reply_t_handler
1554 (vl_api_control_ping_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;
1567 if (vam->socket_client_main)
1568 vam->socket_client_main->control_pings_outstanding--;
1571 static void vl_api_control_ping_reply_t_handler_json
1572 (vl_api_control_ping_reply_t * mp)
1574 vat_main_t *vam = &vat_main;
1575 i32 retval = ntohl (mp->retval);
1577 if (VAT_JSON_NONE != vam->json_tree.type)
1579 vat_json_print (vam->ofp, &vam->json_tree);
1580 vat_json_free (&vam->json_tree);
1581 vam->json_tree.type = VAT_JSON_NONE;
1586 vat_json_init_array (&vam->json_tree);
1587 vat_json_print (vam->ofp, &vam->json_tree);
1588 vam->json_tree.type = VAT_JSON_NONE;
1591 vam->retval = retval;
1592 vam->result_ready = 1;
1596 vl_api_bridge_domain_set_mac_age_reply_t_handler
1597 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1599 vat_main_t *vam = &vat_main;
1600 i32 retval = ntohl (mp->retval);
1601 if (vam->async_mode)
1603 vam->async_errors += (retval < 0);
1607 vam->retval = retval;
1608 vam->result_ready = 1;
1612 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1613 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1615 vat_main_t *vam = &vat_main;
1616 vat_json_node_t node;
1618 vat_json_init_object (&node);
1619 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1621 vat_json_print (vam->ofp, &node);
1622 vat_json_free (&node);
1624 vam->retval = ntohl (mp->retval);
1625 vam->result_ready = 1;
1629 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1631 vat_main_t *vam = &vat_main;
1632 i32 retval = ntohl (mp->retval);
1633 if (vam->async_mode)
1635 vam->async_errors += (retval < 0);
1639 vam->retval = retval;
1640 vam->result_ready = 1;
1644 static void vl_api_l2_flags_reply_t_handler_json
1645 (vl_api_l2_flags_reply_t * mp)
1647 vat_main_t *vam = &vat_main;
1648 vat_json_node_t node;
1650 vat_json_init_object (&node);
1651 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1652 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1653 ntohl (mp->resulting_feature_bitmap));
1655 vat_json_print (vam->ofp, &node);
1656 vat_json_free (&node);
1658 vam->retval = ntohl (mp->retval);
1659 vam->result_ready = 1;
1662 static void vl_api_bridge_flags_reply_t_handler
1663 (vl_api_bridge_flags_reply_t * mp)
1665 vat_main_t *vam = &vat_main;
1666 i32 retval = ntohl (mp->retval);
1667 if (vam->async_mode)
1669 vam->async_errors += (retval < 0);
1673 vam->retval = retval;
1674 vam->result_ready = 1;
1678 static void vl_api_bridge_flags_reply_t_handler_json
1679 (vl_api_bridge_flags_reply_t * mp)
1681 vat_main_t *vam = &vat_main;
1682 vat_json_node_t node;
1684 vat_json_init_object (&node);
1685 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1686 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1687 ntohl (mp->resulting_feature_bitmap));
1689 vat_json_print (vam->ofp, &node);
1690 vat_json_free (&node);
1692 vam->retval = ntohl (mp->retval);
1693 vam->result_ready = 1;
1696 static void vl_api_tap_connect_reply_t_handler
1697 (vl_api_tap_connect_reply_t * mp)
1699 vat_main_t *vam = &vat_main;
1700 i32 retval = ntohl (mp->retval);
1701 if (vam->async_mode)
1703 vam->async_errors += (retval < 0);
1707 vam->retval = retval;
1708 vam->sw_if_index = ntohl (mp->sw_if_index);
1709 vam->result_ready = 1;
1714 static void vl_api_tap_connect_reply_t_handler_json
1715 (vl_api_tap_connect_reply_t * mp)
1717 vat_main_t *vam = &vat_main;
1718 vat_json_node_t node;
1720 vat_json_init_object (&node);
1721 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1722 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1724 vat_json_print (vam->ofp, &node);
1725 vat_json_free (&node);
1727 vam->retval = ntohl (mp->retval);
1728 vam->result_ready = 1;
1733 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1735 vat_main_t *vam = &vat_main;
1736 i32 retval = ntohl (mp->retval);
1737 if (vam->async_mode)
1739 vam->async_errors += (retval < 0);
1743 vam->retval = retval;
1744 vam->sw_if_index = ntohl (mp->sw_if_index);
1745 vam->result_ready = 1;
1749 static void vl_api_tap_modify_reply_t_handler_json
1750 (vl_api_tap_modify_reply_t * mp)
1752 vat_main_t *vam = &vat_main;
1753 vat_json_node_t node;
1755 vat_json_init_object (&node);
1756 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1757 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1759 vat_json_print (vam->ofp, &node);
1760 vat_json_free (&node);
1762 vam->retval = ntohl (mp->retval);
1763 vam->result_ready = 1;
1767 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1769 vat_main_t *vam = &vat_main;
1770 i32 retval = ntohl (mp->retval);
1771 if (vam->async_mode)
1773 vam->async_errors += (retval < 0);
1777 vam->retval = retval;
1778 vam->result_ready = 1;
1782 static void vl_api_tap_delete_reply_t_handler_json
1783 (vl_api_tap_delete_reply_t * mp)
1785 vat_main_t *vam = &vat_main;
1786 vat_json_node_t node;
1788 vat_json_init_object (&node);
1789 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1791 vat_json_print (vam->ofp, &node);
1792 vat_json_free (&node);
1794 vam->retval = ntohl (mp->retval);
1795 vam->result_ready = 1;
1799 vl_api_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_reply_t * mp)
1801 vat_main_t *vam = &vat_main;
1802 i32 retval = ntohl (mp->retval);
1803 if (vam->async_mode)
1805 vam->async_errors += (retval < 0);
1809 vam->retval = retval;
1810 vam->sw_if_index = ntohl (mp->sw_if_index);
1811 vam->result_ready = 1;
1816 static void vl_api_tap_create_v2_reply_t_handler_json
1817 (vl_api_tap_create_v2_reply_t * mp)
1819 vat_main_t *vam = &vat_main;
1820 vat_json_node_t node;
1822 vat_json_init_object (&node);
1823 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1824 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1826 vat_json_print (vam->ofp, &node);
1827 vat_json_free (&node);
1829 vam->retval = ntohl (mp->retval);
1830 vam->result_ready = 1;
1835 vl_api_tap_delete_v2_reply_t_handler (vl_api_tap_delete_v2_reply_t * mp)
1837 vat_main_t *vam = &vat_main;
1838 i32 retval = ntohl (mp->retval);
1839 if (vam->async_mode)
1841 vam->async_errors += (retval < 0);
1845 vam->retval = retval;
1846 vam->result_ready = 1;
1850 static void vl_api_tap_delete_v2_reply_t_handler_json
1851 (vl_api_tap_delete_v2_reply_t * mp)
1853 vat_main_t *vam = &vat_main;
1854 vat_json_node_t node;
1856 vat_json_init_object (&node);
1857 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1859 vat_json_print (vam->ofp, &node);
1860 vat_json_free (&node);
1862 vam->retval = ntohl (mp->retval);
1863 vam->result_ready = 1;
1867 vl_api_bond_create_reply_t_handler (vl_api_bond_create_reply_t * mp)
1869 vat_main_t *vam = &vat_main;
1870 i32 retval = ntohl (mp->retval);
1872 if (vam->async_mode)
1874 vam->async_errors += (retval < 0);
1878 vam->retval = retval;
1879 vam->sw_if_index = ntohl (mp->sw_if_index);
1880 vam->result_ready = 1;
1884 static void vl_api_bond_create_reply_t_handler_json
1885 (vl_api_bond_create_reply_t * mp)
1887 vat_main_t *vam = &vat_main;
1888 vat_json_node_t node;
1890 vat_json_init_object (&node);
1891 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1892 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1894 vat_json_print (vam->ofp, &node);
1895 vat_json_free (&node);
1897 vam->retval = ntohl (mp->retval);
1898 vam->result_ready = 1;
1902 vl_api_bond_delete_reply_t_handler (vl_api_bond_delete_reply_t * mp)
1904 vat_main_t *vam = &vat_main;
1905 i32 retval = ntohl (mp->retval);
1907 if (vam->async_mode)
1909 vam->async_errors += (retval < 0);
1913 vam->retval = retval;
1914 vam->result_ready = 1;
1918 static void vl_api_bond_delete_reply_t_handler_json
1919 (vl_api_bond_delete_reply_t * mp)
1921 vat_main_t *vam = &vat_main;
1922 vat_json_node_t node;
1924 vat_json_init_object (&node);
1925 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1927 vat_json_print (vam->ofp, &node);
1928 vat_json_free (&node);
1930 vam->retval = ntohl (mp->retval);
1931 vam->result_ready = 1;
1935 vl_api_bond_enslave_reply_t_handler (vl_api_bond_enslave_reply_t * mp)
1937 vat_main_t *vam = &vat_main;
1938 i32 retval = ntohl (mp->retval);
1940 if (vam->async_mode)
1942 vam->async_errors += (retval < 0);
1946 vam->retval = retval;
1947 vam->result_ready = 1;
1951 static void vl_api_bond_enslave_reply_t_handler_json
1952 (vl_api_bond_enslave_reply_t * mp)
1954 vat_main_t *vam = &vat_main;
1955 vat_json_node_t node;
1957 vat_json_init_object (&node);
1958 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1960 vat_json_print (vam->ofp, &node);
1961 vat_json_free (&node);
1963 vam->retval = ntohl (mp->retval);
1964 vam->result_ready = 1;
1968 vl_api_bond_detach_slave_reply_t_handler (vl_api_bond_detach_slave_reply_t *
1971 vat_main_t *vam = &vat_main;
1972 i32 retval = ntohl (mp->retval);
1974 if (vam->async_mode)
1976 vam->async_errors += (retval < 0);
1980 vam->retval = retval;
1981 vam->result_ready = 1;
1985 static void vl_api_bond_detach_slave_reply_t_handler_json
1986 (vl_api_bond_detach_slave_reply_t * mp)
1988 vat_main_t *vam = &vat_main;
1989 vat_json_node_t node;
1991 vat_json_init_object (&node);
1992 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1994 vat_json_print (vam->ofp, &node);
1995 vat_json_free (&node);
1997 vam->retval = ntohl (mp->retval);
1998 vam->result_ready = 1;
2001 static void vl_api_sw_interface_bond_details_t_handler
2002 (vl_api_sw_interface_bond_details_t * mp)
2004 vat_main_t *vam = &vat_main;
2007 "%-16s %-12d %-12U %-13U %-14u %-14u",
2008 mp->interface_name, ntohl (mp->sw_if_index),
2009 format_bond_mode, mp->mode, format_bond_load_balance, mp->lb,
2010 ntohl (mp->active_slaves), ntohl (mp->slaves));
2013 static void vl_api_sw_interface_bond_details_t_handler_json
2014 (vl_api_sw_interface_bond_details_t * mp)
2016 vat_main_t *vam = &vat_main;
2017 vat_json_node_t *node = NULL;
2019 if (VAT_JSON_ARRAY != vam->json_tree.type)
2021 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2022 vat_json_init_array (&vam->json_tree);
2024 node = vat_json_array_add (&vam->json_tree);
2026 vat_json_init_object (node);
2027 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2028 vat_json_object_add_string_copy (node, "interface_name",
2029 mp->interface_name);
2030 vat_json_object_add_uint (node, "mode", mp->mode);
2031 vat_json_object_add_uint (node, "load_balance", mp->lb);
2032 vat_json_object_add_uint (node, "active_slaves", ntohl (mp->active_slaves));
2033 vat_json_object_add_uint (node, "slaves", ntohl (mp->slaves));
2037 api_sw_interface_bond_dump (vat_main_t * vam)
2039 vl_api_sw_interface_bond_dump_t *mp;
2040 vl_api_control_ping_t *mp_ping;
2044 "\n%-16s %-12s %-12s %-13s %-14s %-14s",
2045 "interface name", "sw_if_index", "mode", "load balance",
2046 "active slaves", "slaves");
2048 /* Get list of bond interfaces */
2049 M (SW_INTERFACE_BOND_DUMP, mp);
2052 /* Use a control ping for synchronization */
2053 MPING (CONTROL_PING, mp_ping);
2060 static void vl_api_sw_interface_slave_details_t_handler
2061 (vl_api_sw_interface_slave_details_t * mp)
2063 vat_main_t *vam = &vat_main;
2066 "%-25s %-12d %-12d %d", mp->interface_name,
2067 ntohl (mp->sw_if_index), mp->is_passive, mp->is_long_timeout);
2070 static void vl_api_sw_interface_slave_details_t_handler_json
2071 (vl_api_sw_interface_slave_details_t * mp)
2073 vat_main_t *vam = &vat_main;
2074 vat_json_node_t *node = NULL;
2076 if (VAT_JSON_ARRAY != vam->json_tree.type)
2078 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2079 vat_json_init_array (&vam->json_tree);
2081 node = vat_json_array_add (&vam->json_tree);
2083 vat_json_init_object (node);
2084 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2085 vat_json_object_add_string_copy (node, "interface_name",
2086 mp->interface_name);
2087 vat_json_object_add_uint (node, "passive", mp->is_passive);
2088 vat_json_object_add_uint (node, "long_timeout", mp->is_long_timeout);
2092 api_sw_interface_slave_dump (vat_main_t * vam)
2094 unformat_input_t *i = vam->input;
2095 vl_api_sw_interface_slave_dump_t *mp;
2096 vl_api_control_ping_t *mp_ping;
2097 u32 sw_if_index = ~0;
2098 u8 sw_if_index_set = 0;
2101 /* Parse args required to build the message */
2102 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2104 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2105 sw_if_index_set = 1;
2106 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2107 sw_if_index_set = 1;
2112 if (sw_if_index_set == 0)
2114 errmsg ("missing vpp interface name. ");
2119 "\n%-25s %-12s %-12s %s",
2120 "slave interface name", "sw_if_index", "passive", "long_timeout");
2122 /* Get list of bond interfaces */
2123 M (SW_INTERFACE_SLAVE_DUMP, mp);
2124 mp->sw_if_index = ntohl (sw_if_index);
2127 /* Use a control ping for synchronization */
2128 MPING (CONTROL_PING, mp_ping);
2135 static void vl_api_mpls_tunnel_add_del_reply_t_handler
2136 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2138 vat_main_t *vam = &vat_main;
2139 i32 retval = ntohl (mp->retval);
2140 if (vam->async_mode)
2142 vam->async_errors += (retval < 0);
2146 vam->retval = retval;
2147 vam->sw_if_index = ntohl (mp->sw_if_index);
2148 vam->result_ready = 1;
2150 vam->regenerate_interface_table = 1;
2153 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
2154 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2156 vat_main_t *vam = &vat_main;
2157 vat_json_node_t node;
2159 vat_json_init_object (&node);
2160 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2161 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
2162 ntohl (mp->sw_if_index));
2164 vat_json_print (vam->ofp, &node);
2165 vat_json_free (&node);
2167 vam->retval = ntohl (mp->retval);
2168 vam->result_ready = 1;
2171 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
2172 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2174 vat_main_t *vam = &vat_main;
2175 i32 retval = ntohl (mp->retval);
2176 if (vam->async_mode)
2178 vam->async_errors += (retval < 0);
2182 vam->retval = retval;
2183 vam->sw_if_index = ntohl (mp->sw_if_index);
2184 vam->result_ready = 1;
2188 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
2189 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2191 vat_main_t *vam = &vat_main;
2192 vat_json_node_t node;
2194 vat_json_init_object (&node);
2195 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2196 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2198 vat_json_print (vam->ofp, &node);
2199 vat_json_free (&node);
2201 vam->retval = ntohl (mp->retval);
2202 vam->result_ready = 1;
2205 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
2206 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2208 vat_main_t *vam = &vat_main;
2209 i32 retval = ntohl (mp->retval);
2210 if (vam->async_mode)
2212 vam->async_errors += (retval < 0);
2216 vam->retval = retval;
2217 vam->result_ready = 1;
2221 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
2222 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2224 vat_main_t *vam = &vat_main;
2225 vat_json_node_t node;
2227 vat_json_init_object (&node);
2228 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2229 vat_json_object_add_uint (&node, "fwd_entry_index",
2230 clib_net_to_host_u32 (mp->fwd_entry_index));
2232 vat_json_print (vam->ofp, &node);
2233 vat_json_free (&node);
2235 vam->retval = ntohl (mp->retval);
2236 vam->result_ready = 1;
2240 format_lisp_transport_protocol (u8 * s, va_list * args)
2242 u32 proto = va_arg (*args, u32);
2247 return format (s, "udp");
2249 return format (s, "api");
2256 static void vl_api_one_get_transport_protocol_reply_t_handler
2257 (vl_api_one_get_transport_protocol_reply_t * mp)
2259 vat_main_t *vam = &vat_main;
2260 i32 retval = ntohl (mp->retval);
2261 if (vam->async_mode)
2263 vam->async_errors += (retval < 0);
2267 u32 proto = mp->protocol;
2268 print (vam->ofp, "Transport protocol: %U",
2269 format_lisp_transport_protocol, proto);
2270 vam->retval = retval;
2271 vam->result_ready = 1;
2275 static void vl_api_one_get_transport_protocol_reply_t_handler_json
2276 (vl_api_one_get_transport_protocol_reply_t * mp)
2278 vat_main_t *vam = &vat_main;
2279 vat_json_node_t node;
2282 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
2285 vat_json_init_object (&node);
2286 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2287 vat_json_object_add_string_copy (&node, "transport-protocol", s);
2290 vat_json_print (vam->ofp, &node);
2291 vat_json_free (&node);
2293 vam->retval = ntohl (mp->retval);
2294 vam->result_ready = 1;
2297 static void vl_api_one_add_del_locator_set_reply_t_handler
2298 (vl_api_one_add_del_locator_set_reply_t * mp)
2300 vat_main_t *vam = &vat_main;
2301 i32 retval = ntohl (mp->retval);
2302 if (vam->async_mode)
2304 vam->async_errors += (retval < 0);
2308 vam->retval = retval;
2309 vam->result_ready = 1;
2313 static void vl_api_one_add_del_locator_set_reply_t_handler_json
2314 (vl_api_one_add_del_locator_set_reply_t * mp)
2316 vat_main_t *vam = &vat_main;
2317 vat_json_node_t node;
2319 vat_json_init_object (&node);
2320 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2321 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
2323 vat_json_print (vam->ofp, &node);
2324 vat_json_free (&node);
2326 vam->retval = ntohl (mp->retval);
2327 vam->result_ready = 1;
2330 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
2331 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2333 vat_main_t *vam = &vat_main;
2334 i32 retval = ntohl (mp->retval);
2335 if (vam->async_mode)
2337 vam->async_errors += (retval < 0);
2341 vam->retval = retval;
2342 vam->sw_if_index = ntohl (mp->sw_if_index);
2343 vam->result_ready = 1;
2345 vam->regenerate_interface_table = 1;
2348 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
2349 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2351 vat_main_t *vam = &vat_main;
2352 vat_json_node_t node;
2354 vat_json_init_object (&node);
2355 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2356 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2358 vat_json_print (vam->ofp, &node);
2359 vat_json_free (&node);
2361 vam->retval = ntohl (mp->retval);
2362 vam->result_ready = 1;
2365 static void vl_api_vxlan_offload_rx_reply_t_handler
2366 (vl_api_vxlan_offload_rx_reply_t * mp)
2368 vat_main_t *vam = &vat_main;
2369 i32 retval = ntohl (mp->retval);
2370 if (vam->async_mode)
2372 vam->async_errors += (retval < 0);
2376 vam->retval = retval;
2377 vam->result_ready = 1;
2381 static void vl_api_vxlan_offload_rx_reply_t_handler_json
2382 (vl_api_vxlan_offload_rx_reply_t * mp)
2384 vat_main_t *vam = &vat_main;
2385 vat_json_node_t node;
2387 vat_json_init_object (&node);
2388 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2390 vat_json_print (vam->ofp, &node);
2391 vat_json_free (&node);
2393 vam->retval = ntohl (mp->retval);
2394 vam->result_ready = 1;
2397 static void vl_api_geneve_add_del_tunnel_reply_t_handler
2398 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2400 vat_main_t *vam = &vat_main;
2401 i32 retval = ntohl (mp->retval);
2402 if (vam->async_mode)
2404 vam->async_errors += (retval < 0);
2408 vam->retval = retval;
2409 vam->sw_if_index = ntohl (mp->sw_if_index);
2410 vam->result_ready = 1;
2414 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
2415 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2417 vat_main_t *vam = &vat_main;
2418 vat_json_node_t node;
2420 vat_json_init_object (&node);
2421 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2422 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2424 vat_json_print (vam->ofp, &node);
2425 vat_json_free (&node);
2427 vam->retval = ntohl (mp->retval);
2428 vam->result_ready = 1;
2431 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
2432 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2434 vat_main_t *vam = &vat_main;
2435 i32 retval = ntohl (mp->retval);
2436 if (vam->async_mode)
2438 vam->async_errors += (retval < 0);
2442 vam->retval = retval;
2443 vam->sw_if_index = ntohl (mp->sw_if_index);
2444 vam->result_ready = 1;
2446 vam->regenerate_interface_table = 1;
2449 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
2450 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2452 vat_main_t *vam = &vat_main;
2453 vat_json_node_t node;
2455 vat_json_init_object (&node);
2456 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2457 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2459 vat_json_print (vam->ofp, &node);
2460 vat_json_free (&node);
2462 vam->retval = ntohl (mp->retval);
2463 vam->result_ready = 1;
2466 static void vl_api_gre_add_del_tunnel_reply_t_handler
2467 (vl_api_gre_add_del_tunnel_reply_t * mp)
2469 vat_main_t *vam = &vat_main;
2470 i32 retval = ntohl (mp->retval);
2471 if (vam->async_mode)
2473 vam->async_errors += (retval < 0);
2477 vam->retval = retval;
2478 vam->sw_if_index = ntohl (mp->sw_if_index);
2479 vam->result_ready = 1;
2483 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
2484 (vl_api_gre_add_del_tunnel_reply_t * mp)
2486 vat_main_t *vam = &vat_main;
2487 vat_json_node_t node;
2489 vat_json_init_object (&node);
2490 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2491 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2493 vat_json_print (vam->ofp, &node);
2494 vat_json_free (&node);
2496 vam->retval = ntohl (mp->retval);
2497 vam->result_ready = 1;
2500 static void vl_api_create_vhost_user_if_reply_t_handler
2501 (vl_api_create_vhost_user_if_reply_t * mp)
2503 vat_main_t *vam = &vat_main;
2504 i32 retval = ntohl (mp->retval);
2505 if (vam->async_mode)
2507 vam->async_errors += (retval < 0);
2511 vam->retval = retval;
2512 vam->sw_if_index = ntohl (mp->sw_if_index);
2513 vam->result_ready = 1;
2515 vam->regenerate_interface_table = 1;
2518 static void vl_api_create_vhost_user_if_reply_t_handler_json
2519 (vl_api_create_vhost_user_if_reply_t * mp)
2521 vat_main_t *vam = &vat_main;
2522 vat_json_node_t node;
2524 vat_json_init_object (&node);
2525 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2526 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2528 vat_json_print (vam->ofp, &node);
2529 vat_json_free (&node);
2531 vam->retval = ntohl (mp->retval);
2532 vam->result_ready = 1;
2535 static void vl_api_dns_resolve_name_reply_t_handler
2536 (vl_api_dns_resolve_name_reply_t * mp)
2538 vat_main_t *vam = &vat_main;
2539 i32 retval = ntohl (mp->retval);
2540 if (vam->async_mode)
2542 vam->async_errors += (retval < 0);
2546 vam->retval = retval;
2547 vam->result_ready = 1;
2552 clib_warning ("ip4 address %U", format_ip4_address,
2553 (ip4_address_t *) mp->ip4_address);
2555 clib_warning ("ip6 address %U", format_ip6_address,
2556 (ip6_address_t *) mp->ip6_address);
2559 clib_warning ("retval %d", retval);
2563 static void vl_api_dns_resolve_name_reply_t_handler_json
2564 (vl_api_dns_resolve_name_reply_t * mp)
2566 clib_warning ("not implemented");
2569 static void vl_api_dns_resolve_ip_reply_t_handler
2570 (vl_api_dns_resolve_ip_reply_t * mp)
2572 vat_main_t *vam = &vat_main;
2573 i32 retval = ntohl (mp->retval);
2574 if (vam->async_mode)
2576 vam->async_errors += (retval < 0);
2580 vam->retval = retval;
2581 vam->result_ready = 1;
2585 clib_warning ("canonical name %s", mp->name);
2588 clib_warning ("retval %d", retval);
2592 static void vl_api_dns_resolve_ip_reply_t_handler_json
2593 (vl_api_dns_resolve_ip_reply_t * mp)
2595 clib_warning ("not implemented");
2599 static void vl_api_ip_address_details_t_handler
2600 (vl_api_ip_address_details_t * mp)
2602 vat_main_t *vam = &vat_main;
2603 static ip_address_details_t empty_ip_address_details = { {0} };
2604 ip_address_details_t *address = NULL;
2605 ip_details_t *current_ip_details = NULL;
2606 ip_details_t *details = NULL;
2608 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2610 if (!details || vam->current_sw_if_index >= vec_len (details)
2611 || !details[vam->current_sw_if_index].present)
2613 errmsg ("ip address details arrived but not stored");
2614 errmsg ("ip_dump should be called first");
2618 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2620 #define addresses (current_ip_details->addr)
2622 vec_validate_init_empty (addresses, vec_len (addresses),
2623 empty_ip_address_details);
2625 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2627 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
2628 address->prefix_length = mp->prefix_length;
2632 static void vl_api_ip_address_details_t_handler_json
2633 (vl_api_ip_address_details_t * mp)
2635 vat_main_t *vam = &vat_main;
2636 vat_json_node_t *node = NULL;
2637 struct in6_addr ip6;
2640 if (VAT_JSON_ARRAY != vam->json_tree.type)
2642 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2643 vat_json_init_array (&vam->json_tree);
2645 node = vat_json_array_add (&vam->json_tree);
2647 vat_json_init_object (node);
2650 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
2651 vat_json_object_add_ip6 (node, "ip", ip6);
2655 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
2656 vat_json_object_add_ip4 (node, "ip", ip4);
2658 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
2662 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2664 vat_main_t *vam = &vat_main;
2665 static ip_details_t empty_ip_details = { 0 };
2666 ip_details_t *ip = NULL;
2667 u32 sw_if_index = ~0;
2669 sw_if_index = ntohl (mp->sw_if_index);
2671 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2672 sw_if_index, empty_ip_details);
2674 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2681 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2683 vat_main_t *vam = &vat_main;
2685 if (VAT_JSON_ARRAY != vam->json_tree.type)
2687 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2688 vat_json_init_array (&vam->json_tree);
2690 vat_json_array_add_uint (&vam->json_tree,
2691 clib_net_to_host_u32 (mp->sw_if_index));
2695 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2697 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2698 "router_addr %U host_mac %U",
2699 ntohl (mp->pid), mp->lease.is_ipv6 ? "ipv6" : "ipv4",
2701 format_ip4_address, &mp->lease.host_address,
2702 format_ip4_address, &mp->lease.router_address,
2703 format_ethernet_address, mp->lease.host_mac);
2706 static void vl_api_dhcp_compl_event_t_handler_json
2707 (vl_api_dhcp_compl_event_t * mp)
2709 /* JSON output not supported */
2713 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2716 vat_main_t *vam = &vat_main;
2717 static u64 default_counter = 0;
2719 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2721 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2722 sw_if_index, default_counter);
2723 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2727 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2728 interface_counter_t counter)
2730 vat_main_t *vam = &vat_main;
2731 static interface_counter_t default_counter = { 0, };
2733 vec_validate_init_empty (vam->combined_interface_counters,
2734 vnet_counter_type, NULL);
2735 vec_validate_init_empty (vam->combined_interface_counters
2736 [vnet_counter_type], sw_if_index, default_counter);
2737 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2740 static void vl_api_vnet_interface_simple_counters_t_handler
2741 (vl_api_vnet_interface_simple_counters_t * mp)
2746 static void vl_api_vnet_interface_combined_counters_t_handler
2747 (vl_api_vnet_interface_combined_counters_t * mp)
2752 static void vl_api_vnet_interface_simple_counters_t_handler_json
2753 (vl_api_vnet_interface_simple_counters_t * mp)
2758 u32 first_sw_if_index;
2761 count = ntohl (mp->count);
2762 first_sw_if_index = ntohl (mp->first_sw_if_index);
2764 v_packets = (u64 *) & mp->data;
2765 for (i = 0; i < count; i++)
2767 packets = clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2768 set_simple_interface_counter (mp->vnet_counter_type,
2769 first_sw_if_index + i, packets);
2774 static void vl_api_vnet_interface_combined_counters_t_handler_json
2775 (vl_api_vnet_interface_combined_counters_t * mp)
2777 interface_counter_t counter;
2779 u32 first_sw_if_index;
2783 count = ntohl (mp->count);
2784 first_sw_if_index = ntohl (mp->first_sw_if_index);
2786 v = (vlib_counter_t *) & mp->data;
2787 for (i = 0; i < count; i++)
2790 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2792 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2793 set_combined_interface_counter (mp->vnet_counter_type,
2794 first_sw_if_index + i, counter);
2800 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2802 vat_main_t *vam = &vat_main;
2805 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2807 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2816 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2818 vat_main_t *vam = &vat_main;
2821 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2823 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2831 static void vl_api_vnet_ip4_fib_counters_t_handler
2832 (vl_api_vnet_ip4_fib_counters_t * mp)
2837 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2838 (vl_api_vnet_ip4_fib_counters_t * mp)
2840 vat_main_t *vam = &vat_main;
2841 vl_api_ip4_fib_counter_t *v;
2842 ip4_fib_counter_t *counter;
2849 vrf_id = ntohl (mp->vrf_id);
2850 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2851 if (~0 == vrf_index)
2853 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2854 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2855 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2856 vec_validate (vam->ip4_fib_counters, vrf_index);
2857 vam->ip4_fib_counters[vrf_index] = NULL;
2860 vec_free (vam->ip4_fib_counters[vrf_index]);
2861 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2862 count = ntohl (mp->count);
2863 for (i = 0; i < count; i++)
2865 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2866 counter = &vam->ip4_fib_counters[vrf_index][i];
2867 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2868 counter->address = ip4;
2869 counter->address_length = v->address_length;
2870 counter->packets = clib_net_to_host_u64 (v->packets);
2871 counter->bytes = clib_net_to_host_u64 (v->bytes);
2876 static void vl_api_vnet_ip4_nbr_counters_t_handler
2877 (vl_api_vnet_ip4_nbr_counters_t * mp)
2882 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2883 (vl_api_vnet_ip4_nbr_counters_t * mp)
2885 vat_main_t *vam = &vat_main;
2886 vl_api_ip4_nbr_counter_t *v;
2887 ip4_nbr_counter_t *counter;
2892 sw_if_index = ntohl (mp->sw_if_index);
2893 count = ntohl (mp->count);
2894 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2897 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2899 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2900 for (i = 0; i < count; i++)
2902 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2903 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2904 counter->address.s_addr = v->address;
2905 counter->packets = clib_net_to_host_u64 (v->packets);
2906 counter->bytes = clib_net_to_host_u64 (v->bytes);
2907 counter->linkt = v->link_type;
2912 static void vl_api_vnet_ip6_fib_counters_t_handler
2913 (vl_api_vnet_ip6_fib_counters_t * mp)
2918 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2919 (vl_api_vnet_ip6_fib_counters_t * mp)
2921 vat_main_t *vam = &vat_main;
2922 vl_api_ip6_fib_counter_t *v;
2923 ip6_fib_counter_t *counter;
2924 struct in6_addr ip6;
2930 vrf_id = ntohl (mp->vrf_id);
2931 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2932 if (~0 == vrf_index)
2934 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2935 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2936 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2937 vec_validate (vam->ip6_fib_counters, vrf_index);
2938 vam->ip6_fib_counters[vrf_index] = NULL;
2941 vec_free (vam->ip6_fib_counters[vrf_index]);
2942 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2943 count = ntohl (mp->count);
2944 for (i = 0; i < count; i++)
2946 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2947 counter = &vam->ip6_fib_counters[vrf_index][i];
2948 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2949 counter->address = ip6;
2950 counter->address_length = v->address_length;
2951 counter->packets = clib_net_to_host_u64 (v->packets);
2952 counter->bytes = clib_net_to_host_u64 (v->bytes);
2957 static void vl_api_vnet_ip6_nbr_counters_t_handler
2958 (vl_api_vnet_ip6_nbr_counters_t * mp)
2963 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2964 (vl_api_vnet_ip6_nbr_counters_t * mp)
2966 vat_main_t *vam = &vat_main;
2967 vl_api_ip6_nbr_counter_t *v;
2968 ip6_nbr_counter_t *counter;
2969 struct in6_addr ip6;
2974 sw_if_index = ntohl (mp->sw_if_index);
2975 count = ntohl (mp->count);
2976 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2979 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2981 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2982 for (i = 0; i < count; i++)
2984 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2985 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2986 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2987 counter->address = ip6;
2988 counter->packets = clib_net_to_host_u64 (v->packets);
2989 counter->bytes = clib_net_to_host_u64 (v->bytes);
2994 static void vl_api_get_first_msg_id_reply_t_handler
2995 (vl_api_get_first_msg_id_reply_t * mp)
2997 vat_main_t *vam = &vat_main;
2998 i32 retval = ntohl (mp->retval);
3000 if (vam->async_mode)
3002 vam->async_errors += (retval < 0);
3006 vam->retval = retval;
3007 vam->result_ready = 1;
3011 errmsg ("first message id %d", ntohs (mp->first_msg_id));
3015 static void vl_api_get_first_msg_id_reply_t_handler_json
3016 (vl_api_get_first_msg_id_reply_t * mp)
3018 vat_main_t *vam = &vat_main;
3019 vat_json_node_t node;
3021 vat_json_init_object (&node);
3022 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3023 vat_json_object_add_uint (&node, "first_msg_id",
3024 (uint) ntohs (mp->first_msg_id));
3026 vat_json_print (vam->ofp, &node);
3027 vat_json_free (&node);
3029 vam->retval = ntohl (mp->retval);
3030 vam->result_ready = 1;
3033 static void vl_api_get_node_graph_reply_t_handler
3034 (vl_api_get_node_graph_reply_t * mp)
3036 vat_main_t *vam = &vat_main;
3037 api_main_t *am = &api_main;
3038 i32 retval = ntohl (mp->retval);
3039 u8 *pvt_copy, *reply;
3044 if (vam->async_mode)
3046 vam->async_errors += (retval < 0);
3050 vam->retval = retval;
3051 vam->result_ready = 1;
3054 /* "Should never happen..." */
3058 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
3059 pvt_copy = vec_dup (reply);
3061 /* Toss the shared-memory original... */
3062 pthread_mutex_lock (&am->vlib_rp->mutex);
3063 oldheap = svm_push_data_heap (am->vlib_rp);
3067 svm_pop_heap (oldheap);
3068 pthread_mutex_unlock (&am->vlib_rp->mutex);
3070 if (vam->graph_nodes)
3072 hash_free (vam->graph_node_index_by_name);
3074 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
3076 node = vam->graph_nodes[0][i];
3077 vec_free (node->name);
3078 vec_free (node->next_nodes);
3081 vec_free (vam->graph_nodes[0]);
3082 vec_free (vam->graph_nodes);
3085 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
3086 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
3087 vec_free (pvt_copy);
3089 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
3091 node = vam->graph_nodes[0][i];
3092 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
3096 static void vl_api_get_node_graph_reply_t_handler_json
3097 (vl_api_get_node_graph_reply_t * mp)
3099 vat_main_t *vam = &vat_main;
3100 api_main_t *am = &api_main;
3102 vat_json_node_t node;
3105 /* $$$$ make this real? */
3106 vat_json_init_object (&node);
3107 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3108 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
3110 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
3112 /* Toss the shared-memory original... */
3113 pthread_mutex_lock (&am->vlib_rp->mutex);
3114 oldheap = svm_push_data_heap (am->vlib_rp);
3118 svm_pop_heap (oldheap);
3119 pthread_mutex_unlock (&am->vlib_rp->mutex);
3121 vat_json_print (vam->ofp, &node);
3122 vat_json_free (&node);
3124 vam->retval = ntohl (mp->retval);
3125 vam->result_ready = 1;
3129 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
3131 vat_main_t *vam = &vat_main;
3136 s = format (s, "%=16d%=16d%=16d",
3137 ntohl (mp->sw_if_index), mp->priority, mp->weight);
3141 s = format (s, "%=16U%=16d%=16d",
3142 mp->is_ipv6 ? format_ip6_address :
3144 mp->ip_address, mp->priority, mp->weight);
3147 print (vam->ofp, "%v", s);
3152 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
3154 vat_main_t *vam = &vat_main;
3155 vat_json_node_t *node = NULL;
3156 struct in6_addr ip6;
3159 if (VAT_JSON_ARRAY != vam->json_tree.type)
3161 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3162 vat_json_init_array (&vam->json_tree);
3164 node = vat_json_array_add (&vam->json_tree);
3165 vat_json_init_object (node);
3167 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
3168 vat_json_object_add_uint (node, "priority", mp->priority);
3169 vat_json_object_add_uint (node, "weight", mp->weight);
3172 vat_json_object_add_uint (node, "sw_if_index",
3173 clib_net_to_host_u32 (mp->sw_if_index));
3178 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3179 vat_json_object_add_ip6 (node, "address", ip6);
3183 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3184 vat_json_object_add_ip4 (node, "address", ip4);
3190 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
3193 vat_main_t *vam = &vat_main;
3196 ls_name = format (0, "%s", mp->ls_name);
3198 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
3204 vl_api_one_locator_set_details_t_handler_json
3205 (vl_api_one_locator_set_details_t * mp)
3207 vat_main_t *vam = &vat_main;
3208 vat_json_node_t *node = 0;
3211 ls_name = format (0, "%s", mp->ls_name);
3212 vec_add1 (ls_name, 0);
3214 if (VAT_JSON_ARRAY != vam->json_tree.type)
3216 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3217 vat_json_init_array (&vam->json_tree);
3219 node = vat_json_array_add (&vam->json_tree);
3221 vat_json_init_object (node);
3222 vat_json_object_add_string_copy (node, "ls_name", ls_name);
3223 vat_json_object_add_uint (node, "ls_index",
3224 clib_net_to_host_u32 (mp->ls_index));
3232 } __attribute__ ((__packed__)) lisp_nsh_api_t;
3235 unformat_nsh_address (unformat_input_t * input, va_list * args)
3237 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
3238 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
3242 format_nsh_address_vat (u8 * s, va_list * args)
3244 nsh_t *a = va_arg (*args, nsh_t *);
3245 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
3249 format_lisp_flat_eid (u8 * s, va_list * args)
3251 u32 type = va_arg (*args, u32);
3252 u8 *eid = va_arg (*args, u8 *);
3253 u32 eid_len = va_arg (*args, u32);
3258 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
3260 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
3262 return format (s, "%U", format_ethernet_address, eid);
3264 return format (s, "%U", format_nsh_address_vat, eid);
3270 format_lisp_eid_vat (u8 * s, va_list * args)
3272 u32 type = va_arg (*args, u32);
3273 u8 *eid = va_arg (*args, u8 *);
3274 u32 eid_len = va_arg (*args, u32);
3275 u8 *seid = va_arg (*args, u8 *);
3276 u32 seid_len = va_arg (*args, u32);
3277 u32 is_src_dst = va_arg (*args, u32);
3280 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
3282 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
3288 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
3290 vat_main_t *vam = &vat_main;
3291 u8 *s = 0, *eid = 0;
3293 if (~0 == mp->locator_set_index)
3294 s = format (0, "action: %d", mp->action);
3296 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3298 eid = format (0, "%U", format_lisp_eid_vat,
3302 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3305 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3306 clib_net_to_host_u32 (mp->vni),
3308 mp->is_local ? "local" : "remote",
3309 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3310 clib_net_to_host_u16 (mp->key_id), mp->key);
3317 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3320 vat_main_t *vam = &vat_main;
3321 vat_json_node_t *node = 0;
3324 if (VAT_JSON_ARRAY != vam->json_tree.type)
3326 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3327 vat_json_init_array (&vam->json_tree);
3329 node = vat_json_array_add (&vam->json_tree);
3331 vat_json_init_object (node);
3332 if (~0 == mp->locator_set_index)
3333 vat_json_object_add_uint (node, "action", mp->action);
3335 vat_json_object_add_uint (node, "locator_set_index",
3336 clib_net_to_host_u32 (mp->locator_set_index));
3338 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3339 if (mp->eid_type == 3)
3341 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3342 vat_json_init_object (nsh_json);
3343 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3344 vat_json_object_add_uint (nsh_json, "spi",
3345 clib_net_to_host_u32 (nsh->spi));
3346 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3350 eid = format (0, "%U", format_lisp_eid_vat,
3354 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3356 vat_json_object_add_string_copy (node, "eid", eid);
3359 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3360 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3361 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3365 vat_json_object_add_uint (node, "key_id",
3366 clib_net_to_host_u16 (mp->key_id));
3367 vat_json_object_add_string_copy (node, "key", mp->key);
3372 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3374 vat_main_t *vam = &vat_main;
3375 u8 *seid = 0, *deid = 0;
3376 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3378 deid = format (0, "%U", format_lisp_eid_vat,
3379 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3381 seid = format (0, "%U", format_lisp_eid_vat,
3382 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3388 format_ip_address_fcn = format_ip4_address;
3390 format_ip_address_fcn = format_ip6_address;
3393 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3394 clib_net_to_host_u32 (mp->vni),
3396 format_ip_address_fcn, mp->lloc,
3397 format_ip_address_fcn, mp->rloc,
3398 clib_net_to_host_u32 (mp->pkt_count),
3399 clib_net_to_host_u32 (mp->bytes));
3406 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3408 struct in6_addr ip6;
3410 vat_main_t *vam = &vat_main;
3411 vat_json_node_t *node = 0;
3412 u8 *deid = 0, *seid = 0;
3414 if (VAT_JSON_ARRAY != vam->json_tree.type)
3416 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3417 vat_json_init_array (&vam->json_tree);
3419 node = vat_json_array_add (&vam->json_tree);
3421 vat_json_init_object (node);
3422 deid = format (0, "%U", format_lisp_eid_vat,
3423 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3425 seid = format (0, "%U", format_lisp_eid_vat,
3426 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3431 vat_json_object_add_string_copy (node, "seid", seid);
3432 vat_json_object_add_string_copy (node, "deid", deid);
3433 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3437 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3438 vat_json_object_add_ip4 (node, "lloc", ip4);
3439 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3440 vat_json_object_add_ip4 (node, "rloc", ip4);
3444 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3445 vat_json_object_add_ip6 (node, "lloc", ip6);
3446 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3447 vat_json_object_add_ip6 (node, "rloc", ip6);
3449 vat_json_object_add_uint (node, "pkt_count",
3450 clib_net_to_host_u32 (mp->pkt_count));
3451 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3458 vl_api_one_eid_table_map_details_t_handler
3459 (vl_api_one_eid_table_map_details_t * mp)
3461 vat_main_t *vam = &vat_main;
3463 u8 *line = format (0, "%=10d%=10d",
3464 clib_net_to_host_u32 (mp->vni),
3465 clib_net_to_host_u32 (mp->dp_table));
3466 print (vam->ofp, "%v", line);
3471 vl_api_one_eid_table_map_details_t_handler_json
3472 (vl_api_one_eid_table_map_details_t * mp)
3474 vat_main_t *vam = &vat_main;
3475 vat_json_node_t *node = NULL;
3477 if (VAT_JSON_ARRAY != vam->json_tree.type)
3479 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3480 vat_json_init_array (&vam->json_tree);
3482 node = vat_json_array_add (&vam->json_tree);
3483 vat_json_init_object (node);
3484 vat_json_object_add_uint (node, "dp_table",
3485 clib_net_to_host_u32 (mp->dp_table));
3486 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3490 vl_api_one_eid_table_vni_details_t_handler
3491 (vl_api_one_eid_table_vni_details_t * mp)
3493 vat_main_t *vam = &vat_main;
3495 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3496 print (vam->ofp, "%v", line);
3501 vl_api_one_eid_table_vni_details_t_handler_json
3502 (vl_api_one_eid_table_vni_details_t * mp)
3504 vat_main_t *vam = &vat_main;
3505 vat_json_node_t *node = NULL;
3507 if (VAT_JSON_ARRAY != vam->json_tree.type)
3509 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3510 vat_json_init_array (&vam->json_tree);
3512 node = vat_json_array_add (&vam->json_tree);
3513 vat_json_init_object (node);
3514 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3518 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3519 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3521 vat_main_t *vam = &vat_main;
3522 int retval = clib_net_to_host_u32 (mp->retval);
3524 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3525 print (vam->ofp, "fallback threshold value: %d", mp->value);
3527 vam->retval = retval;
3528 vam->result_ready = 1;
3532 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3533 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3535 vat_main_t *vam = &vat_main;
3536 vat_json_node_t _node, *node = &_node;
3537 int retval = clib_net_to_host_u32 (mp->retval);
3539 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3540 vat_json_init_object (node);
3541 vat_json_object_add_uint (node, "value", mp->value);
3543 vat_json_print (vam->ofp, node);
3544 vat_json_free (node);
3546 vam->retval = retval;
3547 vam->result_ready = 1;
3551 vl_api_show_one_map_register_state_reply_t_handler
3552 (vl_api_show_one_map_register_state_reply_t * mp)
3554 vat_main_t *vam = &vat_main;
3555 int retval = clib_net_to_host_u32 (mp->retval);
3557 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3559 vam->retval = retval;
3560 vam->result_ready = 1;
3564 vl_api_show_one_map_register_state_reply_t_handler_json
3565 (vl_api_show_one_map_register_state_reply_t * mp)
3567 vat_main_t *vam = &vat_main;
3568 vat_json_node_t _node, *node = &_node;
3569 int retval = clib_net_to_host_u32 (mp->retval);
3571 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3573 vat_json_init_object (node);
3574 vat_json_object_add_string_copy (node, "state", s);
3576 vat_json_print (vam->ofp, node);
3577 vat_json_free (node);
3579 vam->retval = retval;
3580 vam->result_ready = 1;
3585 vl_api_show_one_rloc_probe_state_reply_t_handler
3586 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3588 vat_main_t *vam = &vat_main;
3589 int retval = clib_net_to_host_u32 (mp->retval);
3594 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3596 vam->retval = retval;
3597 vam->result_ready = 1;
3601 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3602 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3604 vat_main_t *vam = &vat_main;
3605 vat_json_node_t _node, *node = &_node;
3606 int retval = clib_net_to_host_u32 (mp->retval);
3608 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3609 vat_json_init_object (node);
3610 vat_json_object_add_string_copy (node, "state", s);
3612 vat_json_print (vam->ofp, node);
3613 vat_json_free (node);
3615 vam->retval = retval;
3616 vam->result_ready = 1;
3621 vl_api_show_one_stats_enable_disable_reply_t_handler
3622 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3624 vat_main_t *vam = &vat_main;
3625 int retval = clib_net_to_host_u32 (mp->retval);
3630 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3632 vam->retval = retval;
3633 vam->result_ready = 1;
3637 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3638 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3640 vat_main_t *vam = &vat_main;
3641 vat_json_node_t _node, *node = &_node;
3642 int retval = clib_net_to_host_u32 (mp->retval);
3644 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3645 vat_json_init_object (node);
3646 vat_json_object_add_string_copy (node, "state", s);
3648 vat_json_print (vam->ofp, node);
3649 vat_json_free (node);
3651 vam->retval = retval;
3652 vam->result_ready = 1;
3657 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3659 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3660 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3661 e->vni = clib_net_to_host_u32 (e->vni);
3665 gpe_fwd_entries_get_reply_t_net_to_host
3666 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3670 mp->count = clib_net_to_host_u32 (mp->count);
3671 for (i = 0; i < mp->count; i++)
3673 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3678 format_gpe_encap_mode (u8 * s, va_list * args)
3680 u32 mode = va_arg (*args, u32);
3685 return format (s, "lisp");
3687 return format (s, "vxlan");
3693 vl_api_gpe_get_encap_mode_reply_t_handler
3694 (vl_api_gpe_get_encap_mode_reply_t * mp)
3696 vat_main_t *vam = &vat_main;
3698 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3699 vam->retval = ntohl (mp->retval);
3700 vam->result_ready = 1;
3704 vl_api_gpe_get_encap_mode_reply_t_handler_json
3705 (vl_api_gpe_get_encap_mode_reply_t * mp)
3707 vat_main_t *vam = &vat_main;
3708 vat_json_node_t node;
3710 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3711 vec_add1 (encap_mode, 0);
3713 vat_json_init_object (&node);
3714 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3716 vec_free (encap_mode);
3717 vat_json_print (vam->ofp, &node);
3718 vat_json_free (&node);
3720 vam->retval = ntohl (mp->retval);
3721 vam->result_ready = 1;
3725 vl_api_gpe_fwd_entry_path_details_t_handler
3726 (vl_api_gpe_fwd_entry_path_details_t * mp)
3728 vat_main_t *vam = &vat_main;
3729 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3731 if (mp->lcl_loc.is_ip4)
3732 format_ip_address_fcn = format_ip4_address;
3734 format_ip_address_fcn = format_ip6_address;
3736 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3737 format_ip_address_fcn, &mp->lcl_loc,
3738 format_ip_address_fcn, &mp->rmt_loc);
3742 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3744 struct in6_addr ip6;
3749 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3750 vat_json_object_add_ip4 (n, "address", ip4);
3754 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3755 vat_json_object_add_ip6 (n, "address", ip6);
3757 vat_json_object_add_uint (n, "weight", loc->weight);
3761 vl_api_gpe_fwd_entry_path_details_t_handler_json
3762 (vl_api_gpe_fwd_entry_path_details_t * mp)
3764 vat_main_t *vam = &vat_main;
3765 vat_json_node_t *node = NULL;
3766 vat_json_node_t *loc_node;
3768 if (VAT_JSON_ARRAY != vam->json_tree.type)
3770 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3771 vat_json_init_array (&vam->json_tree);
3773 node = vat_json_array_add (&vam->json_tree);
3774 vat_json_init_object (node);
3776 loc_node = vat_json_object_add (node, "local_locator");
3777 vat_json_init_object (loc_node);
3778 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3780 loc_node = vat_json_object_add (node, "remote_locator");
3781 vat_json_init_object (loc_node);
3782 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3786 vl_api_gpe_fwd_entries_get_reply_t_handler
3787 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3789 vat_main_t *vam = &vat_main;
3791 int retval = clib_net_to_host_u32 (mp->retval);
3792 vl_api_gpe_fwd_entry_t *e;
3797 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3799 for (i = 0; i < mp->count; i++)
3801 e = &mp->entries[i];
3802 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3803 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3804 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3808 vam->retval = retval;
3809 vam->result_ready = 1;
3813 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3814 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3817 vat_main_t *vam = &vat_main;
3818 vat_json_node_t *e = 0, root;
3820 int retval = clib_net_to_host_u32 (mp->retval);
3821 vl_api_gpe_fwd_entry_t *fwd;
3826 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3827 vat_json_init_array (&root);
3829 for (i = 0; i < mp->count; i++)
3831 e = vat_json_array_add (&root);
3832 fwd = &mp->entries[i];
3834 vat_json_init_object (e);
3835 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3836 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3837 vat_json_object_add_int (e, "vni", fwd->vni);
3838 vat_json_object_add_int (e, "action", fwd->action);
3840 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3841 fwd->leid_prefix_len);
3843 vat_json_object_add_string_copy (e, "leid", s);
3846 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3847 fwd->reid_prefix_len);
3849 vat_json_object_add_string_copy (e, "reid", s);
3853 vat_json_print (vam->ofp, &root);
3854 vat_json_free (&root);
3857 vam->retval = retval;
3858 vam->result_ready = 1;
3862 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3863 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3865 vat_main_t *vam = &vat_main;
3867 int retval = clib_net_to_host_u32 (mp->retval);
3868 vl_api_gpe_native_fwd_rpath_t *r;
3873 n = clib_net_to_host_u32 (mp->count);
3875 for (i = 0; i < n; i++)
3877 r = &mp->entries[i];
3878 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3879 clib_net_to_host_u32 (r->fib_index),
3880 clib_net_to_host_u32 (r->nh_sw_if_index),
3881 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3885 vam->retval = retval;
3886 vam->result_ready = 1;
3890 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3891 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3893 vat_main_t *vam = &vat_main;
3894 vat_json_node_t root, *e;
3896 int retval = clib_net_to_host_u32 (mp->retval);
3897 vl_api_gpe_native_fwd_rpath_t *r;
3903 n = clib_net_to_host_u32 (mp->count);
3904 vat_json_init_array (&root);
3906 for (i = 0; i < n; i++)
3908 e = vat_json_array_add (&root);
3909 vat_json_init_object (e);
3910 r = &mp->entries[i];
3912 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3915 vat_json_object_add_string_copy (e, "ip4", s);
3918 vat_json_object_add_uint (e, "fib_index",
3919 clib_net_to_host_u32 (r->fib_index));
3920 vat_json_object_add_uint (e, "nh_sw_if_index",
3921 clib_net_to_host_u32 (r->nh_sw_if_index));
3924 vat_json_print (vam->ofp, &root);
3925 vat_json_free (&root);
3928 vam->retval = retval;
3929 vam->result_ready = 1;
3933 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3934 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3936 vat_main_t *vam = &vat_main;
3938 int retval = clib_net_to_host_u32 (mp->retval);
3943 n = clib_net_to_host_u32 (mp->count);
3945 for (i = 0; i < n; i++)
3946 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3949 vam->retval = retval;
3950 vam->result_ready = 1;
3954 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3955 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3957 vat_main_t *vam = &vat_main;
3958 vat_json_node_t root;
3960 int retval = clib_net_to_host_u32 (mp->retval);
3965 n = clib_net_to_host_u32 (mp->count);
3966 vat_json_init_array (&root);
3968 for (i = 0; i < n; i++)
3969 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3971 vat_json_print (vam->ofp, &root);
3972 vat_json_free (&root);
3975 vam->retval = retval;
3976 vam->result_ready = 1;
3980 vl_api_one_ndp_entries_get_reply_t_handler
3981 (vl_api_one_ndp_entries_get_reply_t * mp)
3983 vat_main_t *vam = &vat_main;
3985 int retval = clib_net_to_host_u32 (mp->retval);
3990 n = clib_net_to_host_u32 (mp->count);
3992 for (i = 0; i < n; i++)
3993 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3994 format_ethernet_address, mp->entries[i].mac);
3997 vam->retval = retval;
3998 vam->result_ready = 1;
4002 vl_api_one_ndp_entries_get_reply_t_handler_json
4003 (vl_api_one_ndp_entries_get_reply_t * mp)
4006 vat_main_t *vam = &vat_main;
4007 vat_json_node_t *e = 0, root;
4009 int retval = clib_net_to_host_u32 (mp->retval);
4010 vl_api_one_ndp_entry_t *arp_entry;
4015 n = clib_net_to_host_u32 (mp->count);
4016 vat_json_init_array (&root);
4018 for (i = 0; i < n; i++)
4020 e = vat_json_array_add (&root);
4021 arp_entry = &mp->entries[i];
4023 vat_json_init_object (e);
4024 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
4027 vat_json_object_add_string_copy (e, "mac", s);
4030 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
4032 vat_json_object_add_string_copy (e, "ip6", s);
4036 vat_json_print (vam->ofp, &root);
4037 vat_json_free (&root);
4040 vam->retval = retval;
4041 vam->result_ready = 1;
4045 vl_api_one_l2_arp_entries_get_reply_t_handler
4046 (vl_api_one_l2_arp_entries_get_reply_t * mp)
4048 vat_main_t *vam = &vat_main;
4050 int retval = clib_net_to_host_u32 (mp->retval);
4055 n = clib_net_to_host_u32 (mp->count);
4057 for (i = 0; i < n; i++)
4058 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
4059 format_ethernet_address, mp->entries[i].mac);
4062 vam->retval = retval;
4063 vam->result_ready = 1;
4067 vl_api_one_l2_arp_entries_get_reply_t_handler_json
4068 (vl_api_one_l2_arp_entries_get_reply_t * mp)
4071 vat_main_t *vam = &vat_main;
4072 vat_json_node_t *e = 0, root;
4074 int retval = clib_net_to_host_u32 (mp->retval);
4075 vl_api_one_l2_arp_entry_t *arp_entry;
4080 n = clib_net_to_host_u32 (mp->count);
4081 vat_json_init_array (&root);
4083 for (i = 0; i < n; i++)
4085 e = vat_json_array_add (&root);
4086 arp_entry = &mp->entries[i];
4088 vat_json_init_object (e);
4089 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
4092 vat_json_object_add_string_copy (e, "mac", s);
4095 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
4097 vat_json_object_add_string_copy (e, "ip4", s);
4101 vat_json_print (vam->ofp, &root);
4102 vat_json_free (&root);
4105 vam->retval = retval;
4106 vam->result_ready = 1;
4110 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
4112 vat_main_t *vam = &vat_main;
4114 int retval = clib_net_to_host_u32 (mp->retval);
4119 n = clib_net_to_host_u32 (mp->count);
4121 for (i = 0; i < n; i++)
4123 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
4127 vam->retval = retval;
4128 vam->result_ready = 1;
4132 vl_api_one_ndp_bd_get_reply_t_handler_json
4133 (vl_api_one_ndp_bd_get_reply_t * mp)
4135 vat_main_t *vam = &vat_main;
4136 vat_json_node_t root;
4138 int retval = clib_net_to_host_u32 (mp->retval);
4143 n = clib_net_to_host_u32 (mp->count);
4144 vat_json_init_array (&root);
4146 for (i = 0; i < n; i++)
4148 vat_json_array_add_uint (&root,
4149 clib_net_to_host_u32 (mp->bridge_domains[i]));
4152 vat_json_print (vam->ofp, &root);
4153 vat_json_free (&root);
4156 vam->retval = retval;
4157 vam->result_ready = 1;
4161 vl_api_one_l2_arp_bd_get_reply_t_handler
4162 (vl_api_one_l2_arp_bd_get_reply_t * mp)
4164 vat_main_t *vam = &vat_main;
4166 int retval = clib_net_to_host_u32 (mp->retval);
4171 n = clib_net_to_host_u32 (mp->count);
4173 for (i = 0; i < n; i++)
4175 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
4179 vam->retval = retval;
4180 vam->result_ready = 1;
4184 vl_api_one_l2_arp_bd_get_reply_t_handler_json
4185 (vl_api_one_l2_arp_bd_get_reply_t * mp)
4187 vat_main_t *vam = &vat_main;
4188 vat_json_node_t root;
4190 int retval = clib_net_to_host_u32 (mp->retval);
4195 n = clib_net_to_host_u32 (mp->count);
4196 vat_json_init_array (&root);
4198 for (i = 0; i < n; i++)
4200 vat_json_array_add_uint (&root,
4201 clib_net_to_host_u32 (mp->bridge_domains[i]));
4204 vat_json_print (vam->ofp, &root);
4205 vat_json_free (&root);
4208 vam->retval = retval;
4209 vam->result_ready = 1;
4213 vl_api_one_adjacencies_get_reply_t_handler
4214 (vl_api_one_adjacencies_get_reply_t * mp)
4216 vat_main_t *vam = &vat_main;
4218 int retval = clib_net_to_host_u32 (mp->retval);
4219 vl_api_one_adjacency_t *a;
4224 n = clib_net_to_host_u32 (mp->count);
4226 for (i = 0; i < n; i++)
4228 a = &mp->adjacencies[i];
4229 print (vam->ofp, "%U %40U",
4230 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
4231 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
4235 vam->retval = retval;
4236 vam->result_ready = 1;
4240 vl_api_one_adjacencies_get_reply_t_handler_json
4241 (vl_api_one_adjacencies_get_reply_t * mp)
4244 vat_main_t *vam = &vat_main;
4245 vat_json_node_t *e = 0, root;
4247 int retval = clib_net_to_host_u32 (mp->retval);
4248 vl_api_one_adjacency_t *a;
4253 n = clib_net_to_host_u32 (mp->count);
4254 vat_json_init_array (&root);
4256 for (i = 0; i < n; i++)
4258 e = vat_json_array_add (&root);
4259 a = &mp->adjacencies[i];
4261 vat_json_init_object (e);
4262 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
4263 a->leid_prefix_len);
4265 vat_json_object_add_string_copy (e, "leid", s);
4268 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
4269 a->reid_prefix_len);
4271 vat_json_object_add_string_copy (e, "reid", s);
4275 vat_json_print (vam->ofp, &root);
4276 vat_json_free (&root);
4279 vam->retval = retval;
4280 vam->result_ready = 1;
4284 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
4286 vat_main_t *vam = &vat_main;
4288 print (vam->ofp, "%=20U",
4289 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4294 vl_api_one_map_server_details_t_handler_json
4295 (vl_api_one_map_server_details_t * mp)
4297 vat_main_t *vam = &vat_main;
4298 vat_json_node_t *node = NULL;
4299 struct in6_addr ip6;
4302 if (VAT_JSON_ARRAY != vam->json_tree.type)
4304 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4305 vat_json_init_array (&vam->json_tree);
4307 node = vat_json_array_add (&vam->json_tree);
4309 vat_json_init_object (node);
4312 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4313 vat_json_object_add_ip6 (node, "map-server", ip6);
4317 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4318 vat_json_object_add_ip4 (node, "map-server", ip4);
4323 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4326 vat_main_t *vam = &vat_main;
4328 print (vam->ofp, "%=20U",
4329 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4334 vl_api_one_map_resolver_details_t_handler_json
4335 (vl_api_one_map_resolver_details_t * mp)
4337 vat_main_t *vam = &vat_main;
4338 vat_json_node_t *node = NULL;
4339 struct in6_addr ip6;
4342 if (VAT_JSON_ARRAY != vam->json_tree.type)
4344 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4345 vat_json_init_array (&vam->json_tree);
4347 node = vat_json_array_add (&vam->json_tree);
4349 vat_json_init_object (node);
4352 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4353 vat_json_object_add_ip6 (node, "map resolver", ip6);
4357 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4358 vat_json_object_add_ip4 (node, "map resolver", ip4);
4363 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4365 vat_main_t *vam = &vat_main;
4366 i32 retval = ntohl (mp->retval);
4370 print (vam->ofp, "feature: %s\ngpe: %s",
4371 mp->feature_status ? "enabled" : "disabled",
4372 mp->gpe_status ? "enabled" : "disabled");
4375 vam->retval = retval;
4376 vam->result_ready = 1;
4380 vl_api_show_one_status_reply_t_handler_json
4381 (vl_api_show_one_status_reply_t * mp)
4383 vat_main_t *vam = &vat_main;
4384 vat_json_node_t node;
4385 u8 *gpe_status = NULL;
4386 u8 *feature_status = NULL;
4388 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4389 feature_status = format (0, "%s",
4390 mp->feature_status ? "enabled" : "disabled");
4391 vec_add1 (gpe_status, 0);
4392 vec_add1 (feature_status, 0);
4394 vat_json_init_object (&node);
4395 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4396 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4398 vec_free (gpe_status);
4399 vec_free (feature_status);
4401 vat_json_print (vam->ofp, &node);
4402 vat_json_free (&node);
4404 vam->retval = ntohl (mp->retval);
4405 vam->result_ready = 1;
4409 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4410 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4412 vat_main_t *vam = &vat_main;
4413 i32 retval = ntohl (mp->retval);
4417 print (vam->ofp, "%=20s", mp->locator_set_name);
4420 vam->retval = retval;
4421 vam->result_ready = 1;
4425 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4426 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4428 vat_main_t *vam = &vat_main;
4429 vat_json_node_t *node = NULL;
4431 if (VAT_JSON_ARRAY != vam->json_tree.type)
4433 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4434 vat_json_init_array (&vam->json_tree);
4436 node = vat_json_array_add (&vam->json_tree);
4438 vat_json_init_object (node);
4439 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4441 vat_json_print (vam->ofp, node);
4442 vat_json_free (node);
4444 vam->retval = ntohl (mp->retval);
4445 vam->result_ready = 1;
4449 format_lisp_map_request_mode (u8 * s, va_list * args)
4451 u32 mode = va_arg (*args, u32);
4456 return format (0, "dst-only");
4458 return format (0, "src-dst");
4464 vl_api_show_one_map_request_mode_reply_t_handler
4465 (vl_api_show_one_map_request_mode_reply_t * mp)
4467 vat_main_t *vam = &vat_main;
4468 i32 retval = ntohl (mp->retval);
4472 u32 mode = mp->mode;
4473 print (vam->ofp, "map_request_mode: %U",
4474 format_lisp_map_request_mode, mode);
4477 vam->retval = retval;
4478 vam->result_ready = 1;
4482 vl_api_show_one_map_request_mode_reply_t_handler_json
4483 (vl_api_show_one_map_request_mode_reply_t * mp)
4485 vat_main_t *vam = &vat_main;
4486 vat_json_node_t node;
4491 s = format (0, "%U", format_lisp_map_request_mode, mode);
4494 vat_json_init_object (&node);
4495 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4496 vat_json_print (vam->ofp, &node);
4497 vat_json_free (&node);
4500 vam->retval = ntohl (mp->retval);
4501 vam->result_ready = 1;
4505 vl_api_one_show_xtr_mode_reply_t_handler
4506 (vl_api_one_show_xtr_mode_reply_t * mp)
4508 vat_main_t *vam = &vat_main;
4509 i32 retval = ntohl (mp->retval);
4513 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4516 vam->retval = retval;
4517 vam->result_ready = 1;
4521 vl_api_one_show_xtr_mode_reply_t_handler_json
4522 (vl_api_one_show_xtr_mode_reply_t * mp)
4524 vat_main_t *vam = &vat_main;
4525 vat_json_node_t node;
4528 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4529 vec_add1 (status, 0);
4531 vat_json_init_object (&node);
4532 vat_json_object_add_string_copy (&node, "status", status);
4536 vat_json_print (vam->ofp, &node);
4537 vat_json_free (&node);
4539 vam->retval = ntohl (mp->retval);
4540 vam->result_ready = 1;
4544 vl_api_one_show_pitr_mode_reply_t_handler
4545 (vl_api_one_show_pitr_mode_reply_t * mp)
4547 vat_main_t *vam = &vat_main;
4548 i32 retval = ntohl (mp->retval);
4552 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4555 vam->retval = retval;
4556 vam->result_ready = 1;
4560 vl_api_one_show_pitr_mode_reply_t_handler_json
4561 (vl_api_one_show_pitr_mode_reply_t * mp)
4563 vat_main_t *vam = &vat_main;
4564 vat_json_node_t node;
4567 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4568 vec_add1 (status, 0);
4570 vat_json_init_object (&node);
4571 vat_json_object_add_string_copy (&node, "status", status);
4575 vat_json_print (vam->ofp, &node);
4576 vat_json_free (&node);
4578 vam->retval = ntohl (mp->retval);
4579 vam->result_ready = 1;
4583 vl_api_one_show_petr_mode_reply_t_handler
4584 (vl_api_one_show_petr_mode_reply_t * mp)
4586 vat_main_t *vam = &vat_main;
4587 i32 retval = ntohl (mp->retval);
4591 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4594 vam->retval = retval;
4595 vam->result_ready = 1;
4599 vl_api_one_show_petr_mode_reply_t_handler_json
4600 (vl_api_one_show_petr_mode_reply_t * mp)
4602 vat_main_t *vam = &vat_main;
4603 vat_json_node_t node;
4606 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4607 vec_add1 (status, 0);
4609 vat_json_init_object (&node);
4610 vat_json_object_add_string_copy (&node, "status", status);
4614 vat_json_print (vam->ofp, &node);
4615 vat_json_free (&node);
4617 vam->retval = ntohl (mp->retval);
4618 vam->result_ready = 1;
4622 vl_api_show_one_use_petr_reply_t_handler
4623 (vl_api_show_one_use_petr_reply_t * mp)
4625 vat_main_t *vam = &vat_main;
4626 i32 retval = ntohl (mp->retval);
4630 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4633 print (vam->ofp, "Proxy-ETR address; %U",
4634 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4639 vam->retval = retval;
4640 vam->result_ready = 1;
4644 vl_api_show_one_use_petr_reply_t_handler_json
4645 (vl_api_show_one_use_petr_reply_t * mp)
4647 vat_main_t *vam = &vat_main;
4648 vat_json_node_t node;
4651 struct in6_addr ip6;
4653 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4654 vec_add1 (status, 0);
4656 vat_json_init_object (&node);
4657 vat_json_object_add_string_copy (&node, "status", status);
4662 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4663 vat_json_object_add_ip6 (&node, "address", ip6);
4667 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4668 vat_json_object_add_ip4 (&node, "address", ip4);
4674 vat_json_print (vam->ofp, &node);
4675 vat_json_free (&node);
4677 vam->retval = ntohl (mp->retval);
4678 vam->result_ready = 1;
4682 vl_api_show_one_nsh_mapping_reply_t_handler
4683 (vl_api_show_one_nsh_mapping_reply_t * mp)
4685 vat_main_t *vam = &vat_main;
4686 i32 retval = ntohl (mp->retval);
4690 print (vam->ofp, "%-20s%-16s",
4691 mp->is_set ? "set" : "not-set",
4692 mp->is_set ? (char *) mp->locator_set_name : "");
4695 vam->retval = retval;
4696 vam->result_ready = 1;
4700 vl_api_show_one_nsh_mapping_reply_t_handler_json
4701 (vl_api_show_one_nsh_mapping_reply_t * mp)
4703 vat_main_t *vam = &vat_main;
4704 vat_json_node_t node;
4707 status = format (0, "%s", mp->is_set ? "yes" : "no");
4708 vec_add1 (status, 0);
4710 vat_json_init_object (&node);
4711 vat_json_object_add_string_copy (&node, "is_set", status);
4714 vat_json_object_add_string_copy (&node, "locator_set",
4715 mp->locator_set_name);
4720 vat_json_print (vam->ofp, &node);
4721 vat_json_free (&node);
4723 vam->retval = ntohl (mp->retval);
4724 vam->result_ready = 1;
4728 vl_api_show_one_map_register_ttl_reply_t_handler
4729 (vl_api_show_one_map_register_ttl_reply_t * mp)
4731 vat_main_t *vam = &vat_main;
4732 i32 retval = ntohl (mp->retval);
4734 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4738 print (vam->ofp, "ttl: %u", mp->ttl);
4741 vam->retval = retval;
4742 vam->result_ready = 1;
4746 vl_api_show_one_map_register_ttl_reply_t_handler_json
4747 (vl_api_show_one_map_register_ttl_reply_t * mp)
4749 vat_main_t *vam = &vat_main;
4750 vat_json_node_t node;
4752 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4753 vat_json_init_object (&node);
4754 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4756 vat_json_print (vam->ofp, &node);
4757 vat_json_free (&node);
4759 vam->retval = ntohl (mp->retval);
4760 vam->result_ready = 1;
4764 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4766 vat_main_t *vam = &vat_main;
4767 i32 retval = ntohl (mp->retval);
4771 print (vam->ofp, "%-20s%-16s",
4772 mp->status ? "enabled" : "disabled",
4773 mp->status ? (char *) mp->locator_set_name : "");
4776 vam->retval = retval;
4777 vam->result_ready = 1;
4781 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4783 vat_main_t *vam = &vat_main;
4784 vat_json_node_t node;
4787 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4788 vec_add1 (status, 0);
4790 vat_json_init_object (&node);
4791 vat_json_object_add_string_copy (&node, "status", status);
4794 vat_json_object_add_string_copy (&node, "locator_set",
4795 mp->locator_set_name);
4800 vat_json_print (vam->ofp, &node);
4801 vat_json_free (&node);
4803 vam->retval = ntohl (mp->retval);
4804 vam->result_ready = 1;
4808 format_policer_type (u8 * s, va_list * va)
4810 u32 i = va_arg (*va, u32);
4812 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4813 s = format (s, "1r2c");
4814 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4815 s = format (s, "1r3c");
4816 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4817 s = format (s, "2r3c-2698");
4818 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4819 s = format (s, "2r3c-4115");
4820 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4821 s = format (s, "2r3c-mef5cf1");
4823 s = format (s, "ILLEGAL");
4828 format_policer_rate_type (u8 * s, va_list * va)
4830 u32 i = va_arg (*va, u32);
4832 if (i == SSE2_QOS_RATE_KBPS)
4833 s = format (s, "kbps");
4834 else if (i == SSE2_QOS_RATE_PPS)
4835 s = format (s, "pps");
4837 s = format (s, "ILLEGAL");
4842 format_policer_round_type (u8 * s, va_list * va)
4844 u32 i = va_arg (*va, u32);
4846 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4847 s = format (s, "closest");
4848 else if (i == SSE2_QOS_ROUND_TO_UP)
4849 s = format (s, "up");
4850 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4851 s = format (s, "down");
4853 s = format (s, "ILLEGAL");
4858 format_policer_action_type (u8 * s, va_list * va)
4860 u32 i = va_arg (*va, u32);
4862 if (i == SSE2_QOS_ACTION_DROP)
4863 s = format (s, "drop");
4864 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4865 s = format (s, "transmit");
4866 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4867 s = format (s, "mark-and-transmit");
4869 s = format (s, "ILLEGAL");
4874 format_dscp (u8 * s, va_list * va)
4876 u32 i = va_arg (*va, u32);
4881 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4885 return format (s, "ILLEGAL");
4887 s = format (s, "%s", t);
4892 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4894 vat_main_t *vam = &vat_main;
4895 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4897 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4898 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4900 conform_dscp_str = format (0, "");
4902 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4903 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4905 exceed_dscp_str = format (0, "");
4907 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4908 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4910 violate_dscp_str = format (0, "");
4912 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4913 "rate type %U, round type %U, %s rate, %s color-aware, "
4914 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4915 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4916 "conform action %U%s, exceed action %U%s, violate action %U%s",
4918 format_policer_type, mp->type,
4921 clib_net_to_host_u64 (mp->cb),
4922 clib_net_to_host_u64 (mp->eb),
4923 format_policer_rate_type, mp->rate_type,
4924 format_policer_round_type, mp->round_type,
4925 mp->single_rate ? "single" : "dual",
4926 mp->color_aware ? "is" : "not",
4927 ntohl (mp->cir_tokens_per_period),
4928 ntohl (mp->pir_tokens_per_period),
4930 ntohl (mp->current_limit),
4931 ntohl (mp->current_bucket),
4932 ntohl (mp->extended_limit),
4933 ntohl (mp->extended_bucket),
4934 clib_net_to_host_u64 (mp->last_update_time),
4935 format_policer_action_type, mp->conform_action_type,
4937 format_policer_action_type, mp->exceed_action_type,
4939 format_policer_action_type, mp->violate_action_type,
4942 vec_free (conform_dscp_str);
4943 vec_free (exceed_dscp_str);
4944 vec_free (violate_dscp_str);
4947 static void vl_api_policer_details_t_handler_json
4948 (vl_api_policer_details_t * mp)
4950 vat_main_t *vam = &vat_main;
4951 vat_json_node_t *node;
4952 u8 *rate_type_str, *round_type_str, *type_str;
4953 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4955 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4957 format (0, "%U", format_policer_round_type, mp->round_type);
4958 type_str = format (0, "%U", format_policer_type, mp->type);
4959 conform_action_str = format (0, "%U", format_policer_action_type,
4960 mp->conform_action_type);
4961 exceed_action_str = format (0, "%U", format_policer_action_type,
4962 mp->exceed_action_type);
4963 violate_action_str = format (0, "%U", format_policer_action_type,
4964 mp->violate_action_type);
4966 if (VAT_JSON_ARRAY != vam->json_tree.type)
4968 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4969 vat_json_init_array (&vam->json_tree);
4971 node = vat_json_array_add (&vam->json_tree);
4973 vat_json_init_object (node);
4974 vat_json_object_add_string_copy (node, "name", mp->name);
4975 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4976 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4977 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4978 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4979 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4980 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4981 vat_json_object_add_string_copy (node, "type", type_str);
4982 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4983 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4984 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4985 vat_json_object_add_uint (node, "cir_tokens_per_period",
4986 ntohl (mp->cir_tokens_per_period));
4987 vat_json_object_add_uint (node, "eir_tokens_per_period",
4988 ntohl (mp->pir_tokens_per_period));
4989 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4990 vat_json_object_add_uint (node, "current_bucket",
4991 ntohl (mp->current_bucket));
4992 vat_json_object_add_uint (node, "extended_limit",
4993 ntohl (mp->extended_limit));
4994 vat_json_object_add_uint (node, "extended_bucket",
4995 ntohl (mp->extended_bucket));
4996 vat_json_object_add_uint (node, "last_update_time",
4997 ntohl (mp->last_update_time));
4998 vat_json_object_add_string_copy (node, "conform_action",
4999 conform_action_str);
5000 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
5002 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
5003 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
5004 vec_free (dscp_str);
5006 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
5007 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
5009 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
5010 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
5011 vec_free (dscp_str);
5013 vat_json_object_add_string_copy (node, "violate_action",
5014 violate_action_str);
5015 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
5017 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
5018 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
5019 vec_free (dscp_str);
5022 vec_free (rate_type_str);
5023 vec_free (round_type_str);
5024 vec_free (type_str);
5025 vec_free (conform_action_str);
5026 vec_free (exceed_action_str);
5027 vec_free (violate_action_str);
5031 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
5034 vat_main_t *vam = &vat_main;
5035 int i, count = ntohl (mp->count);
5038 print (vam->ofp, "classify table ids (%d) : ", count);
5039 for (i = 0; i < count; i++)
5041 print (vam->ofp, "%d", ntohl (mp->ids[i]));
5042 print (vam->ofp, (i < count - 1) ? "," : "");
5044 vam->retval = ntohl (mp->retval);
5045 vam->result_ready = 1;
5049 vl_api_classify_table_ids_reply_t_handler_json
5050 (vl_api_classify_table_ids_reply_t * mp)
5052 vat_main_t *vam = &vat_main;
5053 int i, count = ntohl (mp->count);
5057 vat_json_node_t node;
5059 vat_json_init_object (&node);
5060 for (i = 0; i < count; i++)
5062 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
5064 vat_json_print (vam->ofp, &node);
5065 vat_json_free (&node);
5067 vam->retval = ntohl (mp->retval);
5068 vam->result_ready = 1;
5072 vl_api_classify_table_by_interface_reply_t_handler
5073 (vl_api_classify_table_by_interface_reply_t * mp)
5075 vat_main_t *vam = &vat_main;
5078 table_id = ntohl (mp->l2_table_id);
5080 print (vam->ofp, "l2 table id : %d", table_id);
5082 print (vam->ofp, "l2 table id : No input ACL tables configured");
5083 table_id = ntohl (mp->ip4_table_id);
5085 print (vam->ofp, "ip4 table id : %d", table_id);
5087 print (vam->ofp, "ip4 table id : No input ACL tables configured");
5088 table_id = ntohl (mp->ip6_table_id);
5090 print (vam->ofp, "ip6 table id : %d", table_id);
5092 print (vam->ofp, "ip6 table id : No input ACL tables configured");
5093 vam->retval = ntohl (mp->retval);
5094 vam->result_ready = 1;
5098 vl_api_classify_table_by_interface_reply_t_handler_json
5099 (vl_api_classify_table_by_interface_reply_t * mp)
5101 vat_main_t *vam = &vat_main;
5102 vat_json_node_t node;
5104 vat_json_init_object (&node);
5106 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
5107 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
5108 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
5110 vat_json_print (vam->ofp, &node);
5111 vat_json_free (&node);
5113 vam->retval = ntohl (mp->retval);
5114 vam->result_ready = 1;
5117 static void vl_api_policer_add_del_reply_t_handler
5118 (vl_api_policer_add_del_reply_t * mp)
5120 vat_main_t *vam = &vat_main;
5121 i32 retval = ntohl (mp->retval);
5122 if (vam->async_mode)
5124 vam->async_errors += (retval < 0);
5128 vam->retval = retval;
5129 vam->result_ready = 1;
5130 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
5132 * Note: this is just barely thread-safe, depends on
5133 * the main thread spinning waiting for an answer...
5135 errmsg ("policer index %d", ntohl (mp->policer_index));
5139 static void vl_api_policer_add_del_reply_t_handler_json
5140 (vl_api_policer_add_del_reply_t * mp)
5142 vat_main_t *vam = &vat_main;
5143 vat_json_node_t node;
5145 vat_json_init_object (&node);
5146 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5147 vat_json_object_add_uint (&node, "policer_index",
5148 ntohl (mp->policer_index));
5150 vat_json_print (vam->ofp, &node);
5151 vat_json_free (&node);
5153 vam->retval = ntohl (mp->retval);
5154 vam->result_ready = 1;
5157 /* Format hex dump. */
5159 format_hex_bytes (u8 * s, va_list * va)
5161 u8 *bytes = va_arg (*va, u8 *);
5162 int n_bytes = va_arg (*va, int);
5165 /* Print short or long form depending on byte count. */
5166 uword short_form = n_bytes <= 32;
5167 u32 indent = format_get_indent (s);
5172 for (i = 0; i < n_bytes; i++)
5174 if (!short_form && (i % 32) == 0)
5175 s = format (s, "%08x: ", i);
5176 s = format (s, "%02x", bytes[i]);
5177 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
5178 s = format (s, "\n%U", format_white_space, indent);
5185 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
5188 vat_main_t *vam = &vat_main;
5189 i32 retval = ntohl (mp->retval);
5192 print (vam->ofp, "classify table info :");
5193 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
5194 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
5195 ntohl (mp->miss_next_index));
5196 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
5197 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
5198 ntohl (mp->match_n_vectors));
5199 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
5200 ntohl (mp->mask_length));
5202 vam->retval = retval;
5203 vam->result_ready = 1;
5207 vl_api_classify_table_info_reply_t_handler_json
5208 (vl_api_classify_table_info_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, "sessions",
5219 ntohl (mp->active_sessions));
5220 vat_json_object_add_int (&node, "nexttbl",
5221 ntohl (mp->next_table_index));
5222 vat_json_object_add_int (&node, "nextnode",
5223 ntohl (mp->miss_next_index));
5224 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
5225 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
5226 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
5227 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
5228 ntohl (mp->mask_length), 0);
5229 vat_json_object_add_string_copy (&node, "mask", s);
5231 vat_json_print (vam->ofp, &node);
5232 vat_json_free (&node);
5234 vam->retval = ntohl (mp->retval);
5235 vam->result_ready = 1;
5239 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
5242 vat_main_t *vam = &vat_main;
5244 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
5245 ntohl (mp->hit_next_index), ntohl (mp->advance),
5246 ntohl (mp->opaque_index));
5247 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
5248 ntohl (mp->match_length));
5252 vl_api_classify_session_details_t_handler_json
5253 (vl_api_classify_session_details_t * mp)
5255 vat_main_t *vam = &vat_main;
5256 vat_json_node_t *node = NULL;
5258 if (VAT_JSON_ARRAY != vam->json_tree.type)
5260 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5261 vat_json_init_array (&vam->json_tree);
5263 node = vat_json_array_add (&vam->json_tree);
5265 vat_json_init_object (node);
5266 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
5267 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
5268 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
5270 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
5272 vat_json_object_add_string_copy (node, "match", s);
5275 static void vl_api_pg_create_interface_reply_t_handler
5276 (vl_api_pg_create_interface_reply_t * mp)
5278 vat_main_t *vam = &vat_main;
5280 vam->retval = ntohl (mp->retval);
5281 vam->result_ready = 1;
5284 static void vl_api_pg_create_interface_reply_t_handler_json
5285 (vl_api_pg_create_interface_reply_t * mp)
5287 vat_main_t *vam = &vat_main;
5288 vat_json_node_t node;
5290 i32 retval = ntohl (mp->retval);
5293 vat_json_init_object (&node);
5295 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
5297 vat_json_print (vam->ofp, &node);
5298 vat_json_free (&node);
5300 vam->retval = ntohl (mp->retval);
5301 vam->result_ready = 1;
5304 static void vl_api_policer_classify_details_t_handler
5305 (vl_api_policer_classify_details_t * mp)
5307 vat_main_t *vam = &vat_main;
5309 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5310 ntohl (mp->table_index));
5313 static void vl_api_policer_classify_details_t_handler_json
5314 (vl_api_policer_classify_details_t * mp)
5316 vat_main_t *vam = &vat_main;
5317 vat_json_node_t *node;
5319 if (VAT_JSON_ARRAY != vam->json_tree.type)
5321 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5322 vat_json_init_array (&vam->json_tree);
5324 node = vat_json_array_add (&vam->json_tree);
5326 vat_json_init_object (node);
5327 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5328 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5331 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
5332 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5334 vat_main_t *vam = &vat_main;
5335 i32 retval = ntohl (mp->retval);
5336 if (vam->async_mode)
5338 vam->async_errors += (retval < 0);
5342 vam->retval = retval;
5343 vam->sw_if_index = ntohl (mp->sw_if_index);
5344 vam->result_ready = 1;
5346 vam->regenerate_interface_table = 1;
5349 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
5350 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5352 vat_main_t *vam = &vat_main;
5353 vat_json_node_t node;
5355 vat_json_init_object (&node);
5356 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5357 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
5359 vat_json_print (vam->ofp, &node);
5360 vat_json_free (&node);
5362 vam->retval = ntohl (mp->retval);
5363 vam->result_ready = 1;
5366 static void vl_api_flow_classify_details_t_handler
5367 (vl_api_flow_classify_details_t * mp)
5369 vat_main_t *vam = &vat_main;
5371 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5372 ntohl (mp->table_index));
5375 static void vl_api_flow_classify_details_t_handler_json
5376 (vl_api_flow_classify_details_t * mp)
5378 vat_main_t *vam = &vat_main;
5379 vat_json_node_t *node;
5381 if (VAT_JSON_ARRAY != vam->json_tree.type)
5383 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5384 vat_json_init_array (&vam->json_tree);
5386 node = vat_json_array_add (&vam->json_tree);
5388 vat_json_init_object (node);
5389 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5390 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5393 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
5394 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
5395 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
5396 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
5397 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
5398 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
5399 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
5400 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
5401 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
5402 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
5403 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
5404 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
5405 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5406 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5407 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5408 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5409 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5410 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5411 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5412 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5413 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5414 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5417 * Generate boilerplate reply handlers, which
5418 * dig the return value out of the xxx_reply_t API message,
5419 * stick it into vam->retval, and set vam->result_ready
5421 * Could also do this by pointing N message decode slots at
5422 * a single function, but that could break in subtle ways.
5425 #define foreach_standard_reply_retval_handler \
5426 _(sw_interface_set_flags_reply) \
5427 _(sw_interface_add_del_address_reply) \
5428 _(sw_interface_set_rx_mode_reply) \
5429 _(sw_interface_set_rx_placement_reply) \
5430 _(sw_interface_set_table_reply) \
5431 _(sw_interface_set_mpls_enable_reply) \
5432 _(sw_interface_set_vpath_reply) \
5433 _(sw_interface_set_vxlan_bypass_reply) \
5434 _(sw_interface_set_geneve_bypass_reply) \
5435 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5436 _(sw_interface_set_l2_bridge_reply) \
5437 _(bridge_domain_add_del_reply) \
5438 _(sw_interface_set_l2_xconnect_reply) \
5439 _(l2fib_add_del_reply) \
5440 _(l2fib_flush_int_reply) \
5441 _(l2fib_flush_bd_reply) \
5442 _(ip_add_del_route_reply) \
5443 _(ip_table_add_del_reply) \
5444 _(ip_mroute_add_del_reply) \
5445 _(mpls_route_add_del_reply) \
5446 _(mpls_table_add_del_reply) \
5447 _(mpls_ip_bind_unbind_reply) \
5448 _(bier_route_add_del_reply) \
5449 _(bier_table_add_del_reply) \
5450 _(proxy_arp_add_del_reply) \
5451 _(proxy_arp_intfc_enable_disable_reply) \
5452 _(sw_interface_set_unnumbered_reply) \
5453 _(ip_neighbor_add_del_reply) \
5454 _(oam_add_del_reply) \
5455 _(reset_fib_reply) \
5456 _(dhcp_proxy_config_reply) \
5457 _(dhcp_proxy_set_vss_reply) \
5458 _(dhcp_client_config_reply) \
5459 _(set_ip_flow_hash_reply) \
5460 _(sw_interface_ip6_enable_disable_reply) \
5461 _(sw_interface_ip6_set_link_local_address_reply) \
5462 _(ip6nd_proxy_add_del_reply) \
5463 _(sw_interface_ip6nd_ra_prefix_reply) \
5464 _(sw_interface_ip6nd_ra_config_reply) \
5465 _(set_arp_neighbor_limit_reply) \
5466 _(l2_patch_add_del_reply) \
5467 _(sr_mpls_policy_add_reply) \
5468 _(sr_mpls_policy_mod_reply) \
5469 _(sr_mpls_policy_del_reply) \
5470 _(sr_policy_add_reply) \
5471 _(sr_policy_mod_reply) \
5472 _(sr_policy_del_reply) \
5473 _(sr_localsid_add_del_reply) \
5474 _(sr_steering_add_del_reply) \
5475 _(classify_add_del_session_reply) \
5476 _(classify_set_interface_ip_table_reply) \
5477 _(classify_set_interface_l2_tables_reply) \
5478 _(l2tpv3_set_tunnel_cookies_reply) \
5479 _(l2tpv3_interface_enable_disable_reply) \
5480 _(l2tpv3_set_lookup_key_reply) \
5481 _(l2_fib_clear_table_reply) \
5482 _(l2_interface_efp_filter_reply) \
5483 _(l2_interface_vlan_tag_rewrite_reply) \
5484 _(modify_vhost_user_if_reply) \
5485 _(delete_vhost_user_if_reply) \
5486 _(ip_probe_neighbor_reply) \
5487 _(ip_scan_neighbor_enable_disable_reply) \
5488 _(want_ip4_arp_events_reply) \
5489 _(want_ip6_nd_events_reply) \
5490 _(want_l2_macs_events_reply) \
5491 _(input_acl_set_interface_reply) \
5492 _(ipsec_spd_add_del_reply) \
5493 _(ipsec_interface_add_del_spd_reply) \
5494 _(ipsec_spd_add_del_entry_reply) \
5495 _(ipsec_sad_add_del_entry_reply) \
5496 _(ipsec_sa_set_key_reply) \
5497 _(ipsec_tunnel_if_add_del_reply) \
5498 _(ipsec_tunnel_if_set_key_reply) \
5499 _(ipsec_tunnel_if_set_sa_reply) \
5500 _(ikev2_profile_add_del_reply) \
5501 _(ikev2_profile_set_auth_reply) \
5502 _(ikev2_profile_set_id_reply) \
5503 _(ikev2_profile_set_ts_reply) \
5504 _(ikev2_set_local_key_reply) \
5505 _(ikev2_set_responder_reply) \
5506 _(ikev2_set_ike_transforms_reply) \
5507 _(ikev2_set_esp_transforms_reply) \
5508 _(ikev2_set_sa_lifetime_reply) \
5509 _(ikev2_initiate_sa_init_reply) \
5510 _(ikev2_initiate_del_ike_sa_reply) \
5511 _(ikev2_initiate_del_child_sa_reply) \
5512 _(ikev2_initiate_rekey_child_sa_reply) \
5513 _(delete_loopback_reply) \
5514 _(bd_ip_mac_add_del_reply) \
5515 _(want_interface_events_reply) \
5516 _(want_stats_reply) \
5517 _(cop_interface_enable_disable_reply) \
5518 _(cop_whitelist_enable_disable_reply) \
5519 _(sw_interface_clear_stats_reply) \
5520 _(ioam_enable_reply) \
5521 _(ioam_disable_reply) \
5522 _(one_add_del_locator_reply) \
5523 _(one_add_del_local_eid_reply) \
5524 _(one_add_del_remote_mapping_reply) \
5525 _(one_add_del_adjacency_reply) \
5526 _(one_add_del_map_resolver_reply) \
5527 _(one_add_del_map_server_reply) \
5528 _(one_enable_disable_reply) \
5529 _(one_rloc_probe_enable_disable_reply) \
5530 _(one_map_register_enable_disable_reply) \
5531 _(one_map_register_set_ttl_reply) \
5532 _(one_set_transport_protocol_reply) \
5533 _(one_map_register_fallback_threshold_reply) \
5534 _(one_pitr_set_locator_set_reply) \
5535 _(one_map_request_mode_reply) \
5536 _(one_add_del_map_request_itr_rlocs_reply) \
5537 _(one_eid_table_add_del_map_reply) \
5538 _(one_use_petr_reply) \
5539 _(one_stats_enable_disable_reply) \
5540 _(one_add_del_l2_arp_entry_reply) \
5541 _(one_add_del_ndp_entry_reply) \
5542 _(one_stats_flush_reply) \
5543 _(one_enable_disable_xtr_mode_reply) \
5544 _(one_enable_disable_pitr_mode_reply) \
5545 _(one_enable_disable_petr_mode_reply) \
5546 _(gpe_enable_disable_reply) \
5547 _(gpe_set_encap_mode_reply) \
5548 _(gpe_add_del_iface_reply) \
5549 _(gpe_add_del_native_fwd_rpath_reply) \
5550 _(af_packet_delete_reply) \
5551 _(policer_classify_set_interface_reply) \
5552 _(netmap_create_reply) \
5553 _(netmap_delete_reply) \
5554 _(set_ipfix_exporter_reply) \
5555 _(set_ipfix_classify_stream_reply) \
5556 _(ipfix_classify_table_add_del_reply) \
5557 _(flow_classify_set_interface_reply) \
5558 _(sw_interface_span_enable_disable_reply) \
5559 _(pg_capture_reply) \
5560 _(pg_enable_disable_reply) \
5561 _(ip_source_and_port_range_check_add_del_reply) \
5562 _(ip_source_and_port_range_check_interface_add_del_reply)\
5563 _(delete_subif_reply) \
5564 _(l2_interface_pbb_tag_rewrite_reply) \
5566 _(feature_enable_disable_reply) \
5567 _(sw_interface_tag_add_del_reply) \
5568 _(hw_interface_set_mtu_reply) \
5569 _(p2p_ethernet_add_reply) \
5570 _(p2p_ethernet_del_reply) \
5571 _(lldp_config_reply) \
5572 _(sw_interface_set_lldp_reply) \
5573 _(tcp_configure_src_addresses_reply) \
5574 _(dns_enable_disable_reply) \
5575 _(dns_name_server_add_del_reply) \
5576 _(session_rule_add_del_reply) \
5577 _(ip_container_proxy_add_del_reply) \
5578 _(output_acl_set_interface_reply) \
5579 _(qos_record_enable_disable_reply)
5582 static void vl_api_##n##_t_handler \
5583 (vl_api_##n##_t * mp) \
5585 vat_main_t * vam = &vat_main; \
5586 i32 retval = ntohl(mp->retval); \
5587 if (vam->async_mode) { \
5588 vam->async_errors += (retval < 0); \
5590 vam->retval = retval; \
5591 vam->result_ready = 1; \
5594 foreach_standard_reply_retval_handler;
5598 static void vl_api_##n##_t_handler_json \
5599 (vl_api_##n##_t * mp) \
5601 vat_main_t * vam = &vat_main; \
5602 vat_json_node_t node; \
5603 vat_json_init_object(&node); \
5604 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5605 vat_json_print(vam->ofp, &node); \
5606 vam->retval = ntohl(mp->retval); \
5607 vam->result_ready = 1; \
5609 foreach_standard_reply_retval_handler;
5613 * Table of message reply handlers, must include boilerplate handlers
5617 #define foreach_vpe_api_reply_msg \
5618 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5619 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5620 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5621 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5622 _(CONTROL_PING_REPLY, control_ping_reply) \
5623 _(CLI_REPLY, cli_reply) \
5624 _(CLI_INBAND_REPLY, cli_inband_reply) \
5625 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5626 sw_interface_add_del_address_reply) \
5627 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5628 _(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
5629 _(SW_INTERFACE_RX_PLACEMENT_DETAILS, sw_interface_rx_placement_details) \
5630 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5631 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5632 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5633 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5634 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5635 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5636 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5637 sw_interface_set_l2_xconnect_reply) \
5638 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5639 sw_interface_set_l2_bridge_reply) \
5640 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5641 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5642 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5643 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5644 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5645 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5646 _(L2_FLAGS_REPLY, l2_flags_reply) \
5647 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5648 _(TAP_CONNECT_REPLY, tap_connect_reply) \
5649 _(TAP_MODIFY_REPLY, tap_modify_reply) \
5650 _(TAP_DELETE_REPLY, tap_delete_reply) \
5651 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
5652 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5653 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5654 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5655 _(BOND_CREATE_REPLY, bond_create_reply) \
5656 _(BOND_DELETE_REPLY, bond_delete_reply) \
5657 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5658 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5659 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5660 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5661 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5662 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5663 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5664 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5665 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5666 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5667 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5668 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5669 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5670 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5671 proxy_arp_intfc_enable_disable_reply) \
5672 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5673 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5674 sw_interface_set_unnumbered_reply) \
5675 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5676 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5677 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5678 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5679 _(RESET_FIB_REPLY, reset_fib_reply) \
5680 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5681 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5682 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5683 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5684 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5685 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5686 sw_interface_ip6_enable_disable_reply) \
5687 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
5688 sw_interface_ip6_set_link_local_address_reply) \
5689 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5690 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5691 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5692 sw_interface_ip6nd_ra_prefix_reply) \
5693 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5694 sw_interface_ip6nd_ra_config_reply) \
5695 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5696 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5697 _(SR_MPLS_POLICY_ADD_REPLY, sr_mpls_policy_add_reply) \
5698 _(SR_MPLS_POLICY_MOD_REPLY, sr_mpls_policy_mod_reply) \
5699 _(SR_MPLS_POLICY_DEL_REPLY, sr_mpls_policy_del_reply) \
5700 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5701 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5702 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5703 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5704 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5705 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5706 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5707 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5708 classify_set_interface_ip_table_reply) \
5709 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5710 classify_set_interface_l2_tables_reply) \
5711 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5712 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5713 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5714 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5715 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5716 l2tpv3_interface_enable_disable_reply) \
5717 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5718 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5719 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5720 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5721 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5722 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5723 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5724 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5725 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5726 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5727 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5728 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5729 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5730 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5731 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5732 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5733 _(SHOW_VERSION_REPLY, show_version_reply) \
5734 _(SHOW_THREADS_REPLY, show_threads_reply) \
5735 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5736 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5737 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5738 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5739 _(IP_PROBE_NEIGHBOR_REPLY, ip_probe_neighbor_reply) \
5740 _(IP_SCAN_NEIGHBOR_ENABLE_DISABLE_REPLY, ip_scan_neighbor_enable_disable_reply) \
5741 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5742 _(IP4_ARP_EVENT, ip4_arp_event) \
5743 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5744 _(IP6_ND_EVENT, ip6_nd_event) \
5745 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5746 _(L2_MACS_EVENT, l2_macs_event) \
5747 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5748 _(IP_ADDRESS_DETAILS, ip_address_details) \
5749 _(IP_DETAILS, ip_details) \
5750 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5751 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5752 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
5753 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
5754 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5755 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5756 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5757 _(IPSEC_TUNNEL_IF_SET_KEY_REPLY, ipsec_tunnel_if_set_key_reply) \
5758 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5759 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
5760 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
5761 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
5762 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
5763 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
5764 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
5765 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
5766 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
5767 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
5768 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
5769 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
5770 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
5771 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
5772 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5773 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5774 _(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
5775 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5776 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5777 _(WANT_STATS_REPLY, want_stats_reply) \
5778 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5779 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5780 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5781 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5782 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5783 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5784 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5785 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5786 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5787 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5788 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5789 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5790 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5791 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5792 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5793 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5794 one_map_register_enable_disable_reply) \
5795 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5796 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5797 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5798 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5799 one_map_register_fallback_threshold_reply) \
5800 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5801 one_rloc_probe_enable_disable_reply) \
5802 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5803 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5804 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5805 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5806 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5807 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5808 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5809 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5810 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5811 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5812 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5813 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5814 _(ONE_STATS_DETAILS, one_stats_details) \
5815 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5816 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5817 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5818 show_one_stats_enable_disable_reply) \
5819 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5820 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5821 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5822 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5823 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5824 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5825 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5826 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5827 one_enable_disable_pitr_mode_reply) \
5828 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5829 one_enable_disable_petr_mode_reply) \
5830 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5831 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5832 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5833 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5834 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5835 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5836 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5837 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5838 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5839 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5840 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5841 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5842 gpe_add_del_native_fwd_rpath_reply) \
5843 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5844 gpe_fwd_entry_path_details) \
5845 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5846 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5847 one_add_del_map_request_itr_rlocs_reply) \
5848 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5849 one_get_map_request_itr_rlocs_reply) \
5850 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5851 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5852 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5853 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5854 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5855 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5856 show_one_map_register_state_reply) \
5857 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5858 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5859 show_one_map_register_fallback_threshold_reply) \
5860 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5861 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5862 _(AF_PACKET_DETAILS, af_packet_details) \
5863 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5864 _(POLICER_DETAILS, policer_details) \
5865 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5866 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5867 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5868 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5869 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5870 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5871 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5872 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5873 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5874 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5875 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5876 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5877 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5878 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5879 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5880 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5881 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5882 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5883 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5884 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5885 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5886 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5887 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5888 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5889 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5890 ip_source_and_port_range_check_add_del_reply) \
5891 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5892 ip_source_and_port_range_check_interface_add_del_reply) \
5893 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5894 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5895 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5896 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5897 _(PUNT_REPLY, punt_reply) \
5898 _(IP_FIB_DETAILS, ip_fib_details) \
5899 _(IP6_FIB_DETAILS, ip6_fib_details) \
5900 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5901 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5902 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5903 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5904 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5905 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5906 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5907 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5908 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5909 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5910 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5911 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5912 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5913 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5914 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
5915 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \
5916 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5917 _(SESSION_RULES_DETAILS, session_rules_details) \
5918 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5919 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5920 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply)
5922 #define foreach_standalone_reply_msg \
5923 _(SW_INTERFACE_EVENT, sw_interface_event) \
5924 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
5925 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
5926 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
5927 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
5928 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
5929 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters)
5937 #define STR_VTR_OP_CASE(op) \
5938 case L2_VTR_ ## op: \
5942 str_vtr_op (u32 vtr_op)
5946 STR_VTR_OP_CASE (DISABLED);
5947 STR_VTR_OP_CASE (PUSH_1);
5948 STR_VTR_OP_CASE (PUSH_2);
5949 STR_VTR_OP_CASE (POP_1);
5950 STR_VTR_OP_CASE (POP_2);
5951 STR_VTR_OP_CASE (TRANSLATE_1_1);
5952 STR_VTR_OP_CASE (TRANSLATE_1_2);
5953 STR_VTR_OP_CASE (TRANSLATE_2_1);
5954 STR_VTR_OP_CASE (TRANSLATE_2_2);
5961 dump_sub_interface_table (vat_main_t * vam)
5963 const sw_interface_subif_t *sub = NULL;
5965 if (vam->json_output)
5968 ("JSON output supported only for VPE API calls and dump_stats_table");
5973 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5974 "Interface", "sw_if_index",
5975 "sub id", "dot1ad", "tags", "outer id",
5976 "inner id", "exact", "default", "outer any", "inner any");
5978 vec_foreach (sub, vam->sw_if_subif_table)
5981 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5982 sub->interface_name,
5984 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5985 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5986 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5987 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5988 if (sub->vtr_op != L2_VTR_DISABLED)
5991 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5992 "tag1: %d tag2: %d ]",
5993 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5994 sub->vtr_tag1, sub->vtr_tag2);
6002 name_sort_cmp (void *a1, void *a2)
6004 name_sort_t *n1 = a1;
6005 name_sort_t *n2 = a2;
6007 return strcmp ((char *) n1->name, (char *) n2->name);
6011 dump_interface_table (vat_main_t * vam)
6014 name_sort_t *nses = 0, *ns;
6016 if (vam->json_output)
6019 ("JSON output supported only for VPE API calls and dump_stats_table");
6024 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6026 vec_add2 (nses, ns, 1);
6027 ns->name = (u8 *)(p->key);
6028 ns->value = (u32) p->value[0];
6032 vec_sort_with_function (nses, name_sort_cmp);
6034 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
6035 vec_foreach (ns, nses)
6037 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
6044 dump_ip_table (vat_main_t * vam, int is_ipv6)
6046 const ip_details_t *det = NULL;
6047 const ip_address_details_t *address = NULL;
6050 print (vam->ofp, "%-12s", "sw_if_index");
6052 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
6059 print (vam->ofp, "%-12d", i);
6060 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
6065 vec_foreach (address, det->addr)
6069 is_ipv6 ? format_ip6_address : format_ip4_address,
6070 address->ip, address->prefix_length);
6078 dump_ipv4_table (vat_main_t * vam)
6080 if (vam->json_output)
6083 ("JSON output supported only for VPE API calls and dump_stats_table");
6087 return dump_ip_table (vam, 0);
6091 dump_ipv6_table (vat_main_t * vam)
6093 if (vam->json_output)
6096 ("JSON output supported only for VPE API calls and dump_stats_table");
6100 return dump_ip_table (vam, 1);
6104 counter_type_to_str (u8 counter_type, u8 is_combined)
6108 switch (counter_type)
6110 case VNET_INTERFACE_COUNTER_DROP:
6112 case VNET_INTERFACE_COUNTER_PUNT:
6114 case VNET_INTERFACE_COUNTER_IP4:
6116 case VNET_INTERFACE_COUNTER_IP6:
6118 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
6120 case VNET_INTERFACE_COUNTER_RX_MISS:
6122 case VNET_INTERFACE_COUNTER_RX_ERROR:
6124 case VNET_INTERFACE_COUNTER_TX_ERROR:
6127 return "INVALID-COUNTER-TYPE";
6132 switch (counter_type)
6134 case VNET_INTERFACE_COUNTER_RX:
6136 case VNET_INTERFACE_COUNTER_TX:
6139 return "INVALID-COUNTER-TYPE";
6145 dump_stats_table (vat_main_t * vam)
6147 vat_json_node_t node;
6148 vat_json_node_t *msg_array;
6149 vat_json_node_t *msg;
6150 vat_json_node_t *counter_array;
6151 vat_json_node_t *counter;
6152 interface_counter_t c;
6154 ip4_fib_counter_t *c4;
6155 ip6_fib_counter_t *c6;
6156 ip4_nbr_counter_t *n4;
6157 ip6_nbr_counter_t *n6;
6160 if (!vam->json_output)
6162 clib_warning ("dump_stats_table supported only in JSON format");
6166 vat_json_init_object (&node);
6168 /* interface counters */
6169 msg_array = vat_json_object_add (&node, "interface_counters");
6170 vat_json_init_array (msg_array);
6171 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
6173 msg = vat_json_array_add (msg_array);
6174 vat_json_init_object (msg);
6175 vat_json_object_add_string_copy (msg, "vnet_counter_type",
6176 (u8 *) counter_type_to_str (i, 0));
6177 vat_json_object_add_int (msg, "is_combined", 0);
6178 counter_array = vat_json_object_add (msg, "data");
6179 vat_json_init_array (counter_array);
6180 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
6182 packets = vam->simple_interface_counters[i][j];
6183 vat_json_array_add_uint (counter_array, packets);
6186 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
6188 msg = vat_json_array_add (msg_array);
6189 vat_json_init_object (msg);
6190 vat_json_object_add_string_copy (msg, "vnet_counter_type",
6191 (u8 *) counter_type_to_str (i, 1));
6192 vat_json_object_add_int (msg, "is_combined", 1);
6193 counter_array = vat_json_object_add (msg, "data");
6194 vat_json_init_array (counter_array);
6195 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
6197 c = vam->combined_interface_counters[i][j];
6198 counter = vat_json_array_add (counter_array);
6199 vat_json_init_object (counter);
6200 vat_json_object_add_uint (counter, "packets", c.packets);
6201 vat_json_object_add_uint (counter, "bytes", c.bytes);
6205 /* ip4 fib counters */
6206 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
6207 vat_json_init_array (msg_array);
6208 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
6210 msg = vat_json_array_add (msg_array);
6211 vat_json_init_object (msg);
6212 vat_json_object_add_uint (msg, "vrf_id",
6213 vam->ip4_fib_counters_vrf_id_by_index[i]);
6214 counter_array = vat_json_object_add (msg, "c");
6215 vat_json_init_array (counter_array);
6216 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
6218 counter = vat_json_array_add (counter_array);
6219 vat_json_init_object (counter);
6220 c4 = &vam->ip4_fib_counters[i][j];
6221 vat_json_object_add_ip4 (counter, "address", c4->address);
6222 vat_json_object_add_uint (counter, "address_length",
6223 c4->address_length);
6224 vat_json_object_add_uint (counter, "packets", c4->packets);
6225 vat_json_object_add_uint (counter, "bytes", c4->bytes);
6229 /* ip6 fib counters */
6230 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
6231 vat_json_init_array (msg_array);
6232 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
6234 msg = vat_json_array_add (msg_array);
6235 vat_json_init_object (msg);
6236 vat_json_object_add_uint (msg, "vrf_id",
6237 vam->ip6_fib_counters_vrf_id_by_index[i]);
6238 counter_array = vat_json_object_add (msg, "c");
6239 vat_json_init_array (counter_array);
6240 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
6242 counter = vat_json_array_add (counter_array);
6243 vat_json_init_object (counter);
6244 c6 = &vam->ip6_fib_counters[i][j];
6245 vat_json_object_add_ip6 (counter, "address", c6->address);
6246 vat_json_object_add_uint (counter, "address_length",
6247 c6->address_length);
6248 vat_json_object_add_uint (counter, "packets", c6->packets);
6249 vat_json_object_add_uint (counter, "bytes", c6->bytes);
6253 /* ip4 nbr counters */
6254 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
6255 vat_json_init_array (msg_array);
6256 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
6258 msg = vat_json_array_add (msg_array);
6259 vat_json_init_object (msg);
6260 vat_json_object_add_uint (msg, "sw_if_index", i);
6261 counter_array = vat_json_object_add (msg, "c");
6262 vat_json_init_array (counter_array);
6263 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
6265 counter = vat_json_array_add (counter_array);
6266 vat_json_init_object (counter);
6267 n4 = &vam->ip4_nbr_counters[i][j];
6268 vat_json_object_add_ip4 (counter, "address", n4->address);
6269 vat_json_object_add_uint (counter, "link-type", n4->linkt);
6270 vat_json_object_add_uint (counter, "packets", n4->packets);
6271 vat_json_object_add_uint (counter, "bytes", n4->bytes);
6275 /* ip6 nbr counters */
6276 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
6277 vat_json_init_array (msg_array);
6278 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
6280 msg = vat_json_array_add (msg_array);
6281 vat_json_init_object (msg);
6282 vat_json_object_add_uint (msg, "sw_if_index", i);
6283 counter_array = vat_json_object_add (msg, "c");
6284 vat_json_init_array (counter_array);
6285 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
6287 counter = vat_json_array_add (counter_array);
6288 vat_json_init_object (counter);
6289 n6 = &vam->ip6_nbr_counters[i][j];
6290 vat_json_object_add_ip6 (counter, "address", n6->address);
6291 vat_json_object_add_uint (counter, "packets", n6->packets);
6292 vat_json_object_add_uint (counter, "bytes", n6->bytes);
6296 vat_json_print (vam->ofp, &node);
6297 vat_json_free (&node);
6303 * Pass CLI buffers directly in the CLI_INBAND API message,
6304 * instead of an additional shared memory area.
6307 exec_inband (vat_main_t * vam)
6309 vl_api_cli_inband_t *mp;
6310 unformat_input_t *i = vam->input;
6313 if (vec_len (i->buffer) == 0)
6316 if (vam->exec_mode == 0 && unformat (i, "mode"))
6321 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
6328 * In order for the CLI command to work, it
6329 * must be a vector ending in \n, not a C-string ending
6332 u32 len = vec_len (vam->input->buffer);
6333 M2 (CLI_INBAND, mp, len);
6334 clib_memcpy (mp->cmd, vam->input->buffer, len);
6335 mp->length = htonl (len);
6339 /* json responses may or may not include a useful reply... */
6340 if (vec_len (vam->cmd_reply))
6341 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
6346 exec (vat_main_t * vam)
6348 return exec_inband (vam);
6352 api_create_loopback (vat_main_t * vam)
6354 unformat_input_t *i = vam->input;
6355 vl_api_create_loopback_t *mp;
6356 vl_api_create_loopback_instance_t *mp_lbi;
6359 u8 is_specified = 0;
6360 u32 user_instance = 0;
6363 clib_memset (mac_address, 0, sizeof (mac_address));
6365 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6367 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6369 if (unformat (i, "instance %d", &user_instance))
6377 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
6378 mp_lbi->is_specified = is_specified;
6380 mp_lbi->user_instance = htonl (user_instance);
6382 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
6387 /* Construct the API message */
6388 M (CREATE_LOOPBACK, mp);
6390 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
6399 api_delete_loopback (vat_main_t * vam)
6401 unformat_input_t *i = vam->input;
6402 vl_api_delete_loopback_t *mp;
6403 u32 sw_if_index = ~0;
6406 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6408 if (unformat (i, "sw_if_index %d", &sw_if_index))
6414 if (sw_if_index == ~0)
6416 errmsg ("missing sw_if_index");
6420 /* Construct the API message */
6421 M (DELETE_LOOPBACK, mp);
6422 mp->sw_if_index = ntohl (sw_if_index);
6430 api_want_stats (vat_main_t * vam)
6432 unformat_input_t *i = vam->input;
6433 vl_api_want_stats_t *mp;
6437 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6439 if (unformat (i, "enable"))
6441 else if (unformat (i, "disable"))
6449 errmsg ("missing enable|disable");
6454 mp->enable_disable = enable;
6462 api_want_interface_events (vat_main_t * vam)
6464 unformat_input_t *i = vam->input;
6465 vl_api_want_interface_events_t *mp;
6469 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6471 if (unformat (i, "enable"))
6473 else if (unformat (i, "disable"))
6481 errmsg ("missing enable|disable");
6485 M (WANT_INTERFACE_EVENTS, mp);
6486 mp->enable_disable = enable;
6488 vam->interface_event_display = enable;
6496 /* Note: non-static, called once to set up the initial intfc table */
6498 api_sw_interface_dump (vat_main_t * vam)
6500 vl_api_sw_interface_dump_t *mp;
6501 vl_api_control_ping_t *mp_ping;
6503 name_sort_t *nses = 0, *ns;
6504 sw_interface_subif_t *sub = NULL;
6507 /* Toss the old name table */
6509 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6511 vec_add2 (nses, ns, 1);
6512 ns->name = (u8 *)(p->key);
6513 ns->value = (u32) p->value[0];
6517 hash_free (vam->sw_if_index_by_interface_name);
6519 vec_foreach (ns, nses) vec_free (ns->name);
6523 vec_foreach (sub, vam->sw_if_subif_table)
6525 vec_free (sub->interface_name);
6527 vec_free (vam->sw_if_subif_table);
6529 /* recreate the interface name hash table */
6530 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
6533 * Ask for all interface names. Otherwise, the epic catalog of
6534 * name filters becomes ridiculously long, and vat ends up needing
6535 * to be taught about new interface types.
6537 M (SW_INTERFACE_DUMP, mp);
6540 /* Use a control ping for synchronization */
6541 MPING (CONTROL_PING, mp_ping);
6549 api_sw_interface_set_flags (vat_main_t * vam)
6551 unformat_input_t *i = vam->input;
6552 vl_api_sw_interface_set_flags_t *mp;
6554 u8 sw_if_index_set = 0;
6558 /* Parse args required to build the message */
6559 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6561 if (unformat (i, "admin-up"))
6563 else if (unformat (i, "admin-down"))
6566 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6567 sw_if_index_set = 1;
6568 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6569 sw_if_index_set = 1;
6574 if (sw_if_index_set == 0)
6576 errmsg ("missing interface name or sw_if_index");
6580 /* Construct the API message */
6581 M (SW_INTERFACE_SET_FLAGS, mp);
6582 mp->sw_if_index = ntohl (sw_if_index);
6583 mp->admin_up_down = admin_up;
6588 /* Wait for a reply, return the good/bad news... */
6594 api_sw_interface_set_rx_mode (vat_main_t * vam)
6596 unformat_input_t *i = vam->input;
6597 vl_api_sw_interface_set_rx_mode_t *mp;
6599 u8 sw_if_index_set = 0;
6601 u8 queue_id_valid = 0;
6603 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
6605 /* Parse args required to build the message */
6606 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6608 if (unformat (i, "queue %d", &queue_id))
6610 else if (unformat (i, "polling"))
6611 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
6612 else if (unformat (i, "interrupt"))
6613 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
6614 else if (unformat (i, "adaptive"))
6615 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
6617 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6618 sw_if_index_set = 1;
6619 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6620 sw_if_index_set = 1;
6625 if (sw_if_index_set == 0)
6627 errmsg ("missing interface name or sw_if_index");
6630 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6632 errmsg ("missing rx-mode");
6636 /* Construct the API message */
6637 M (SW_INTERFACE_SET_RX_MODE, mp);
6638 mp->sw_if_index = ntohl (sw_if_index);
6640 mp->queue_id_valid = queue_id_valid;
6641 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6646 /* Wait for a reply, return the good/bad news... */
6652 api_sw_interface_set_rx_placement (vat_main_t * vam)
6654 unformat_input_t *i = vam->input;
6655 vl_api_sw_interface_set_rx_placement_t *mp;
6657 u8 sw_if_index_set = 0;
6660 u32 queue_id, thread_index;
6662 /* Parse args required to build the message */
6663 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6665 if (unformat (i, "queue %d", &queue_id))
6667 else if (unformat (i, "main"))
6669 else if (unformat (i, "worker %d", &thread_index))
6672 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6673 sw_if_index_set = 1;
6674 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6675 sw_if_index_set = 1;
6680 if (sw_if_index_set == 0)
6682 errmsg ("missing interface name or sw_if_index");
6688 /* Construct the API message */
6689 M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
6690 mp->sw_if_index = ntohl (sw_if_index);
6691 mp->worker_id = ntohl (thread_index);
6692 mp->queue_id = ntohl (queue_id);
6693 mp->is_main = is_main;
6697 /* Wait for a reply, return the good/bad news... */
6702 static void vl_api_sw_interface_rx_placement_details_t_handler
6703 (vl_api_sw_interface_rx_placement_details_t * mp)
6705 vat_main_t *vam = &vat_main;
6706 u32 worker_id = ntohl (mp->worker_id);
6709 "\n%-11d %-11s %-6d %-5d %-9s",
6710 ntohl (mp->sw_if_index), (worker_id == 0) ? "main" : "worker",
6711 worker_id, ntohl (mp->queue_id),
6713 1) ? "polling" : ((mp->mode == 2) ? "interrupt" : "adaptive"));
6716 static void vl_api_sw_interface_rx_placement_details_t_handler_json
6717 (vl_api_sw_interface_rx_placement_details_t * mp)
6719 vat_main_t *vam = &vat_main;
6720 vat_json_node_t *node = NULL;
6722 if (VAT_JSON_ARRAY != vam->json_tree.type)
6724 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
6725 vat_json_init_array (&vam->json_tree);
6727 node = vat_json_array_add (&vam->json_tree);
6729 vat_json_init_object (node);
6730 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
6731 vat_json_object_add_uint (node, "worker_id", ntohl (mp->worker_id));
6732 vat_json_object_add_uint (node, "queue_id", ntohl (mp->queue_id));
6733 vat_json_object_add_uint (node, "mode", mp->mode);
6737 api_sw_interface_rx_placement_dump (vat_main_t * vam)
6739 unformat_input_t *i = vam->input;
6740 vl_api_sw_interface_rx_placement_dump_t *mp;
6741 vl_api_control_ping_t *mp_ping;
6744 u8 sw_if_index_set = 0;
6746 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6748 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6750 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6757 "\n%-11s %-11s %-6s %-5s %-4s",
6758 "sw_if_index", "main/worker", "thread", "queue", "mode");
6760 /* Dump Interface rx placement */
6761 M (SW_INTERFACE_RX_PLACEMENT_DUMP, mp);
6763 if (sw_if_index_set)
6764 mp->sw_if_index = htonl (sw_if_index);
6766 mp->sw_if_index = ~0;
6770 /* Use a control ping for synchronization */
6771 MPING (CONTROL_PING, mp_ping);
6779 api_sw_interface_clear_stats (vat_main_t * vam)
6781 unformat_input_t *i = vam->input;
6782 vl_api_sw_interface_clear_stats_t *mp;
6784 u8 sw_if_index_set = 0;
6787 /* Parse args required to build the message */
6788 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6790 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6791 sw_if_index_set = 1;
6792 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6793 sw_if_index_set = 1;
6798 /* Construct the API message */
6799 M (SW_INTERFACE_CLEAR_STATS, mp);
6801 if (sw_if_index_set == 1)
6802 mp->sw_if_index = ntohl (sw_if_index);
6804 mp->sw_if_index = ~0;
6809 /* Wait for a reply, return the good/bad news... */
6815 api_sw_interface_add_del_address (vat_main_t * vam)
6817 unformat_input_t *i = vam->input;
6818 vl_api_sw_interface_add_del_address_t *mp;
6820 u8 sw_if_index_set = 0;
6821 u8 is_add = 1, del_all = 0;
6822 u32 address_length = 0;
6823 u8 v4_address_set = 0;
6824 u8 v6_address_set = 0;
6825 ip4_address_t v4address;
6826 ip6_address_t v6address;
6829 /* Parse args required to build the message */
6830 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6832 if (unformat (i, "del-all"))
6834 else if (unformat (i, "del"))
6837 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6838 sw_if_index_set = 1;
6839 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6840 sw_if_index_set = 1;
6841 else if (unformat (i, "%U/%d",
6842 unformat_ip4_address, &v4address, &address_length))
6844 else if (unformat (i, "%U/%d",
6845 unformat_ip6_address, &v6address, &address_length))
6851 if (sw_if_index_set == 0)
6853 errmsg ("missing interface name or sw_if_index");
6856 if (v4_address_set && v6_address_set)
6858 errmsg ("both v4 and v6 addresses set");
6861 if (!v4_address_set && !v6_address_set && !del_all)
6863 errmsg ("no addresses set");
6867 /* Construct the API message */
6868 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6870 mp->sw_if_index = ntohl (sw_if_index);
6871 mp->is_add = is_add;
6872 mp->del_all = del_all;
6876 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6880 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6882 mp->address_length = address_length;
6887 /* Wait for a reply, return good/bad news */
6893 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6895 unformat_input_t *i = vam->input;
6896 vl_api_sw_interface_set_mpls_enable_t *mp;
6898 u8 sw_if_index_set = 0;
6902 /* Parse args required to build the message */
6903 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6905 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6906 sw_if_index_set = 1;
6907 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6908 sw_if_index_set = 1;
6909 else if (unformat (i, "disable"))
6911 else if (unformat (i, "dis"))
6917 if (sw_if_index_set == 0)
6919 errmsg ("missing interface name or sw_if_index");
6923 /* Construct the API message */
6924 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6926 mp->sw_if_index = ntohl (sw_if_index);
6927 mp->enable = enable;
6932 /* Wait for a reply... */
6938 api_sw_interface_set_table (vat_main_t * vam)
6940 unformat_input_t *i = vam->input;
6941 vl_api_sw_interface_set_table_t *mp;
6942 u32 sw_if_index, vrf_id = 0;
6943 u8 sw_if_index_set = 0;
6947 /* Parse args required to build the message */
6948 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6950 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6951 sw_if_index_set = 1;
6952 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6953 sw_if_index_set = 1;
6954 else if (unformat (i, "vrf %d", &vrf_id))
6956 else if (unformat (i, "ipv6"))
6962 if (sw_if_index_set == 0)
6964 errmsg ("missing interface name or sw_if_index");
6968 /* Construct the API message */
6969 M (SW_INTERFACE_SET_TABLE, mp);
6971 mp->sw_if_index = ntohl (sw_if_index);
6972 mp->is_ipv6 = is_ipv6;
6973 mp->vrf_id = ntohl (vrf_id);
6978 /* Wait for a reply... */
6983 static void vl_api_sw_interface_get_table_reply_t_handler
6984 (vl_api_sw_interface_get_table_reply_t * mp)
6986 vat_main_t *vam = &vat_main;
6988 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6990 vam->retval = ntohl (mp->retval);
6991 vam->result_ready = 1;
6995 static void vl_api_sw_interface_get_table_reply_t_handler_json
6996 (vl_api_sw_interface_get_table_reply_t * mp)
6998 vat_main_t *vam = &vat_main;
6999 vat_json_node_t node;
7001 vat_json_init_object (&node);
7002 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
7003 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
7005 vat_json_print (vam->ofp, &node);
7006 vat_json_free (&node);
7008 vam->retval = ntohl (mp->retval);
7009 vam->result_ready = 1;
7013 api_sw_interface_get_table (vat_main_t * vam)
7015 unformat_input_t *i = vam->input;
7016 vl_api_sw_interface_get_table_t *mp;
7018 u8 sw_if_index_set = 0;
7022 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7024 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7025 sw_if_index_set = 1;
7026 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7027 sw_if_index_set = 1;
7028 else if (unformat (i, "ipv6"))
7034 if (sw_if_index_set == 0)
7036 errmsg ("missing interface name or sw_if_index");
7040 M (SW_INTERFACE_GET_TABLE, mp);
7041 mp->sw_if_index = htonl (sw_if_index);
7042 mp->is_ipv6 = is_ipv6;
7050 api_sw_interface_set_vpath (vat_main_t * vam)
7052 unformat_input_t *i = vam->input;
7053 vl_api_sw_interface_set_vpath_t *mp;
7054 u32 sw_if_index = 0;
7055 u8 sw_if_index_set = 0;
7059 /* Parse args required to build the message */
7060 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7062 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7063 sw_if_index_set = 1;
7064 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7065 sw_if_index_set = 1;
7066 else if (unformat (i, "enable"))
7068 else if (unformat (i, "disable"))
7074 if (sw_if_index_set == 0)
7076 errmsg ("missing interface name or sw_if_index");
7080 /* Construct the API message */
7081 M (SW_INTERFACE_SET_VPATH, mp);
7083 mp->sw_if_index = ntohl (sw_if_index);
7084 mp->enable = is_enable;
7089 /* Wait for a reply... */
7095 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
7097 unformat_input_t *i = vam->input;
7098 vl_api_sw_interface_set_vxlan_bypass_t *mp;
7099 u32 sw_if_index = 0;
7100 u8 sw_if_index_set = 0;
7105 /* Parse args required to build the message */
7106 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7108 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7109 sw_if_index_set = 1;
7110 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7111 sw_if_index_set = 1;
7112 else if (unformat (i, "enable"))
7114 else if (unformat (i, "disable"))
7116 else if (unformat (i, "ip4"))
7118 else if (unformat (i, "ip6"))
7124 if (sw_if_index_set == 0)
7126 errmsg ("missing interface name or sw_if_index");
7130 /* Construct the API message */
7131 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
7133 mp->sw_if_index = ntohl (sw_if_index);
7134 mp->enable = is_enable;
7135 mp->is_ipv6 = is_ipv6;
7140 /* Wait for a reply... */
7146 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
7148 unformat_input_t *i = vam->input;
7149 vl_api_sw_interface_set_geneve_bypass_t *mp;
7150 u32 sw_if_index = 0;
7151 u8 sw_if_index_set = 0;
7156 /* Parse args required to build the message */
7157 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7159 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7160 sw_if_index_set = 1;
7161 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7162 sw_if_index_set = 1;
7163 else if (unformat (i, "enable"))
7165 else if (unformat (i, "disable"))
7167 else if (unformat (i, "ip4"))
7169 else if (unformat (i, "ip6"))
7175 if (sw_if_index_set == 0)
7177 errmsg ("missing interface name or sw_if_index");
7181 /* Construct the API message */
7182 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
7184 mp->sw_if_index = ntohl (sw_if_index);
7185 mp->enable = is_enable;
7186 mp->is_ipv6 = is_ipv6;
7191 /* Wait for a reply... */
7197 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
7199 unformat_input_t *i = vam->input;
7200 vl_api_sw_interface_set_l2_xconnect_t *mp;
7202 u8 rx_sw_if_index_set = 0;
7204 u8 tx_sw_if_index_set = 0;
7208 /* Parse args required to build the message */
7209 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7211 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
7212 rx_sw_if_index_set = 1;
7213 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
7214 tx_sw_if_index_set = 1;
7215 else if (unformat (i, "rx"))
7217 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7219 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7221 rx_sw_if_index_set = 1;
7226 else if (unformat (i, "tx"))
7228 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7230 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7232 tx_sw_if_index_set = 1;
7237 else if (unformat (i, "enable"))
7239 else if (unformat (i, "disable"))
7245 if (rx_sw_if_index_set == 0)
7247 errmsg ("missing rx interface name or rx_sw_if_index");
7251 if (enable && (tx_sw_if_index_set == 0))
7253 errmsg ("missing tx interface name or tx_sw_if_index");
7257 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
7259 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7260 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
7261 mp->enable = enable;
7269 api_sw_interface_set_l2_bridge (vat_main_t * vam)
7271 unformat_input_t *i = vam->input;
7272 vl_api_sw_interface_set_l2_bridge_t *mp;
7273 vl_api_l2_port_type_t port_type;
7275 u8 rx_sw_if_index_set = 0;
7282 port_type = L2_API_PORT_TYPE_NORMAL;
7284 /* Parse args required to build the message */
7285 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7287 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
7288 rx_sw_if_index_set = 1;
7289 else if (unformat (i, "bd_id %d", &bd_id))
7293 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
7294 rx_sw_if_index_set = 1;
7295 else if (unformat (i, "shg %d", &shg))
7297 else if (unformat (i, "bvi"))
7298 port_type = L2_API_PORT_TYPE_BVI;
7299 else if (unformat (i, "uu-fwd"))
7300 port_type = L2_API_PORT_TYPE_UU_FWD;
7301 else if (unformat (i, "enable"))
7303 else if (unformat (i, "disable"))
7309 if (rx_sw_if_index_set == 0)
7311 errmsg ("missing rx interface name or sw_if_index");
7315 if (enable && (bd_id_set == 0))
7317 errmsg ("missing bridge domain");
7321 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
7323 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7324 mp->bd_id = ntohl (bd_id);
7326 mp->port_type = ntohl (port_type);
7327 mp->enable = enable;
7335 api_bridge_domain_dump (vat_main_t * vam)
7337 unformat_input_t *i = vam->input;
7338 vl_api_bridge_domain_dump_t *mp;
7339 vl_api_control_ping_t *mp_ping;
7343 /* Parse args required to build the message */
7344 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7346 if (unformat (i, "bd_id %d", &bd_id))
7352 M (BRIDGE_DOMAIN_DUMP, mp);
7353 mp->bd_id = ntohl (bd_id);
7356 /* Use a control ping for synchronization */
7357 MPING (CONTROL_PING, mp_ping);
7365 api_bridge_domain_add_del (vat_main_t * vam)
7367 unformat_input_t *i = vam->input;
7368 vl_api_bridge_domain_add_del_t *mp;
7371 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
7376 /* Parse args required to build the message */
7377 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7379 if (unformat (i, "bd_id %d", &bd_id))
7381 else if (unformat (i, "flood %d", &flood))
7383 else if (unformat (i, "uu-flood %d", &uu_flood))
7385 else if (unformat (i, "forward %d", &forward))
7387 else if (unformat (i, "learn %d", &learn))
7389 else if (unformat (i, "arp-term %d", &arp_term))
7391 else if (unformat (i, "mac-age %d", &mac_age))
7393 else if (unformat (i, "bd-tag %s", &bd_tag))
7395 else if (unformat (i, "del"))
7398 flood = uu_flood = forward = learn = 0;
7406 errmsg ("missing bridge domain");
7413 errmsg ("mac age must be less than 256 ");
7418 if ((bd_tag) && (vec_len (bd_tag) > 63))
7420 errmsg ("bd-tag cannot be longer than 63");
7425 M (BRIDGE_DOMAIN_ADD_DEL, mp);
7427 mp->bd_id = ntohl (bd_id);
7429 mp->uu_flood = uu_flood;
7430 mp->forward = forward;
7432 mp->arp_term = arp_term;
7433 mp->is_add = is_add;
7434 mp->mac_age = (u8) mac_age;
7437 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
7438 mp->bd_tag[vec_len (bd_tag)] = 0;
7449 api_l2fib_flush_bd (vat_main_t * vam)
7451 unformat_input_t *i = vam->input;
7452 vl_api_l2fib_flush_bd_t *mp;
7456 /* Parse args required to build the message */
7457 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7459 if (unformat (i, "bd_id %d", &bd_id));
7466 errmsg ("missing bridge domain");
7470 M (L2FIB_FLUSH_BD, mp);
7472 mp->bd_id = htonl (bd_id);
7480 api_l2fib_flush_int (vat_main_t * vam)
7482 unformat_input_t *i = vam->input;
7483 vl_api_l2fib_flush_int_t *mp;
7484 u32 sw_if_index = ~0;
7487 /* Parse args required to build the message */
7488 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7490 if (unformat (i, "sw_if_index %d", &sw_if_index));
7492 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
7497 if (sw_if_index == ~0)
7499 errmsg ("missing interface name or sw_if_index");
7503 M (L2FIB_FLUSH_INT, mp);
7505 mp->sw_if_index = ntohl (sw_if_index);
7513 api_l2fib_add_del (vat_main_t * vam)
7515 unformat_input_t *i = vam->input;
7516 vl_api_l2fib_add_del_t *mp;
7522 u32 sw_if_index = 0;
7523 u8 sw_if_index_set = 0;
7532 /* Parse args required to build the message */
7533 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7535 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
7537 else if (unformat (i, "bd_id %d", &bd_id))
7539 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7540 sw_if_index_set = 1;
7541 else if (unformat (i, "sw_if"))
7543 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7546 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7547 sw_if_index_set = 1;
7552 else if (unformat (i, "static"))
7554 else if (unformat (i, "filter"))
7559 else if (unformat (i, "bvi"))
7564 else if (unformat (i, "del"))
7566 else if (unformat (i, "count %d", &count))
7574 errmsg ("missing mac address");
7580 errmsg ("missing bridge domain");
7584 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7586 errmsg ("missing interface name or sw_if_index");
7592 /* Turn on async mode */
7593 vam->async_mode = 1;
7594 vam->async_errors = 0;
7595 before = vat_time_now (vam);
7598 for (j = 0; j < count; j++)
7600 M (L2FIB_ADD_DEL, mp);
7602 clib_memcpy (mp->mac, mac, 6);
7603 mp->bd_id = ntohl (bd_id);
7604 mp->is_add = is_add;
7605 mp->sw_if_index = ntohl (sw_if_index);
7609 mp->static_mac = static_mac;
7610 mp->filter_mac = filter_mac;
7611 mp->bvi_mac = bvi_mac;
7613 increment_mac_address (mac);
7620 vl_api_control_ping_t *mp_ping;
7623 /* Shut off async mode */
7624 vam->async_mode = 0;
7626 MPING (CONTROL_PING, mp_ping);
7629 timeout = vat_time_now (vam) + 1.0;
7630 while (vat_time_now (vam) < timeout)
7631 if (vam->result_ready == 1)
7636 if (vam->retval == -99)
7639 if (vam->async_errors > 0)
7641 errmsg ("%d asynchronous errors", vam->async_errors);
7644 vam->async_errors = 0;
7645 after = vat_time_now (vam);
7647 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7648 count, after - before, count / (after - before));
7654 /* Wait for a reply... */
7658 /* Return the good/bad news */
7659 return (vam->retval);
7663 api_bridge_domain_set_mac_age (vat_main_t * vam)
7665 unformat_input_t *i = vam->input;
7666 vl_api_bridge_domain_set_mac_age_t *mp;
7671 /* Parse args required to build the message */
7672 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7674 if (unformat (i, "bd_id %d", &bd_id));
7675 else if (unformat (i, "mac-age %d", &mac_age));
7682 errmsg ("missing bridge domain");
7688 errmsg ("mac age must be less than 256 ");
7692 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7694 mp->bd_id = htonl (bd_id);
7695 mp->mac_age = (u8) mac_age;
7703 api_l2_flags (vat_main_t * vam)
7705 unformat_input_t *i = vam->input;
7706 vl_api_l2_flags_t *mp;
7709 u8 sw_if_index_set = 0;
7713 /* Parse args required to build the message */
7714 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7716 if (unformat (i, "sw_if_index %d", &sw_if_index))
7717 sw_if_index_set = 1;
7718 else if (unformat (i, "sw_if"))
7720 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7723 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7724 sw_if_index_set = 1;
7729 else if (unformat (i, "learn"))
7731 else if (unformat (i, "forward"))
7733 else if (unformat (i, "flood"))
7735 else if (unformat (i, "uu-flood"))
7736 flags |= L2_UU_FLOOD;
7737 else if (unformat (i, "arp-term"))
7738 flags |= L2_ARP_TERM;
7739 else if (unformat (i, "off"))
7741 else if (unformat (i, "disable"))
7747 if (sw_if_index_set == 0)
7749 errmsg ("missing interface name or sw_if_index");
7755 mp->sw_if_index = ntohl (sw_if_index);
7756 mp->feature_bitmap = ntohl (flags);
7757 mp->is_set = is_set;
7765 api_bridge_flags (vat_main_t * vam)
7767 unformat_input_t *i = vam->input;
7768 vl_api_bridge_flags_t *mp;
7772 bd_flags_t flags = 0;
7775 /* Parse args required to build the message */
7776 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7778 if (unformat (i, "bd_id %d", &bd_id))
7780 else if (unformat (i, "learn"))
7781 flags |= BRIDGE_API_FLAG_LEARN;
7782 else if (unformat (i, "forward"))
7783 flags |= BRIDGE_API_FLAG_FWD;
7784 else if (unformat (i, "flood"))
7785 flags |= BRIDGE_API_FLAG_FLOOD;
7786 else if (unformat (i, "uu-flood"))
7787 flags |= BRIDGE_API_FLAG_UU_FLOOD;
7788 else if (unformat (i, "arp-term"))
7789 flags |= BRIDGE_API_FLAG_ARP_TERM;
7790 else if (unformat (i, "off"))
7792 else if (unformat (i, "disable"))
7800 errmsg ("missing bridge domain");
7804 M (BRIDGE_FLAGS, mp);
7806 mp->bd_id = ntohl (bd_id);
7807 mp->flags = ntohl (flags);
7808 mp->is_set = is_set;
7816 api_bd_ip_mac_add_del (vat_main_t * vam)
7818 unformat_input_t *i = vam->input;
7819 vl_api_bd_ip_mac_add_del_t *mp;
7826 ip4_address_t v4addr;
7827 ip6_address_t v6addr;
7832 /* Parse args required to build the message */
7833 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7835 if (unformat (i, "bd_id %d", &bd_id))
7839 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
7843 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
7848 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
7852 else if (unformat (i, "del"))
7860 errmsg ("missing bridge domain");
7863 else if (ip_set == 0)
7865 errmsg ("missing IP address");
7868 else if (mac_set == 0)
7870 errmsg ("missing MAC address");
7874 M (BD_IP_MAC_ADD_DEL, mp);
7876 mp->bd_id = ntohl (bd_id);
7877 mp->is_ipv6 = is_ipv6;
7878 mp->is_add = is_add;
7880 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
7882 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
7883 clib_memcpy (mp->mac_address, macaddr, 6);
7889 static void vl_api_bd_ip_mac_details_t_handler
7890 (vl_api_bd_ip_mac_details_t * mp)
7892 vat_main_t *vam = &vat_main;
7897 format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
7900 format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
7903 "\n%-5d %-7s %-20U %-30s",
7904 ntohl (mp->bd_id), mp->is_ipv6 ? "ip6" : "ip4",
7905 format_ethernet_address, mp->mac_address, ip);
7910 static void vl_api_bd_ip_mac_details_t_handler_json
7911 (vl_api_bd_ip_mac_details_t * mp)
7913 vat_main_t *vam = &vat_main;
7914 vat_json_node_t *node = NULL;
7916 if (VAT_JSON_ARRAY != vam->json_tree.type)
7918 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7919 vat_json_init_array (&vam->json_tree);
7921 node = vat_json_array_add (&vam->json_tree);
7923 vat_json_init_object (node);
7924 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
7925 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
7926 vat_json_object_add_string_copy (node, "mac_address",
7927 format (0, "%U", format_ethernet_address,
7933 format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
7936 format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
7937 vat_json_object_add_string_copy (node, "ip_address", ip);
7942 api_bd_ip_mac_dump (vat_main_t * vam)
7944 unformat_input_t *i = vam->input;
7945 vl_api_bd_ip_mac_dump_t *mp;
7946 vl_api_control_ping_t *mp_ping;
7951 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7953 if (unformat (i, "bd_id %d", &bd_id))
7962 "\n%-5s %-7s %-20s %-30s",
7963 "bd_id", "is_ipv6", "mac_address", "ip_address");
7965 /* Dump Bridge Domain Ip to Mac entries */
7966 M (BD_IP_MAC_DUMP, mp);
7969 mp->bd_id = htonl (bd_id);
7975 /* Use a control ping for synchronization */
7976 MPING (CONTROL_PING, mp_ping);
7984 api_tap_connect (vat_main_t * vam)
7986 unformat_input_t *i = vam->input;
7987 vl_api_tap_connect_t *mp;
7993 ip4_address_t ip4_address;
7995 int ip4_address_set = 0;
7996 ip6_address_t ip6_address;
7998 int ip6_address_set = 0;
8001 clib_memset (mac_address, 0, sizeof (mac_address));
8003 /* Parse args required to build the message */
8004 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8006 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
8010 else if (unformat (i, "random-mac"))
8012 else if (unformat (i, "tapname %s", &tap_name))
8014 else if (unformat (i, "tag %s", &tag))
8016 else if (unformat (i, "address %U/%d",
8017 unformat_ip4_address, &ip4_address, &ip4_mask_width))
8018 ip4_address_set = 1;
8019 else if (unformat (i, "address %U/%d",
8020 unformat_ip6_address, &ip6_address, &ip6_mask_width))
8021 ip6_address_set = 1;
8028 errmsg ("missing tap name");
8031 if (vec_len (tap_name) > 63)
8033 errmsg ("tap name too long");
8036 vec_add1 (tap_name, 0);
8038 if (vec_len (tag) > 63)
8040 errmsg ("tag too long");
8044 /* Construct the API message */
8045 M (TAP_CONNECT, mp);
8047 mp->use_random_mac = random_mac;
8048 clib_memcpy (mp->mac_address, mac_address, 6);
8049 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
8051 clib_memcpy (mp->tag, tag, vec_len (tag));
8053 if (ip4_address_set)
8055 mp->ip4_address_set = 1;
8056 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
8057 mp->ip4_mask_width = ip4_mask_width;
8059 if (ip6_address_set)
8061 mp->ip6_address_set = 1;
8062 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
8063 mp->ip6_mask_width = ip6_mask_width;
8066 vec_free (tap_name);
8072 /* Wait for a reply... */
8078 api_tap_modify (vat_main_t * vam)
8080 unformat_input_t *i = vam->input;
8081 vl_api_tap_modify_t *mp;
8086 u32 sw_if_index = ~0;
8087 u8 sw_if_index_set = 0;
8090 clib_memset (mac_address, 0, sizeof (mac_address));
8092 /* Parse args required to build the message */
8093 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8095 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8096 sw_if_index_set = 1;
8097 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8098 sw_if_index_set = 1;
8099 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
8103 else if (unformat (i, "random-mac"))
8105 else if (unformat (i, "tapname %s", &tap_name))
8111 if (sw_if_index_set == 0)
8113 errmsg ("missing vpp interface name");
8118 errmsg ("missing tap name");
8121 if (vec_len (tap_name) > 63)
8123 errmsg ("tap name too long");
8125 vec_add1 (tap_name, 0);
8127 /* Construct the API message */
8130 mp->use_random_mac = random_mac;
8131 mp->sw_if_index = ntohl (sw_if_index);
8132 clib_memcpy (mp->mac_address, mac_address, 6);
8133 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
8134 vec_free (tap_name);
8139 /* Wait for a reply... */
8145 api_tap_delete (vat_main_t * vam)
8147 unformat_input_t *i = vam->input;
8148 vl_api_tap_delete_t *mp;
8149 u32 sw_if_index = ~0;
8150 u8 sw_if_index_set = 0;
8153 /* Parse args required to build the message */
8154 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8156 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8157 sw_if_index_set = 1;
8158 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8159 sw_if_index_set = 1;
8164 if (sw_if_index_set == 0)
8166 errmsg ("missing vpp interface name");
8170 /* Construct the API message */
8173 mp->sw_if_index = ntohl (sw_if_index);
8178 /* Wait for a reply... */
8184 api_tap_create_v2 (vat_main_t * vam)
8186 unformat_input_t *i = vam->input;
8187 vl_api_tap_create_v2_t *mp;
8191 u8 *host_if_name = 0;
8193 u8 host_mac_addr[6];
8194 u8 host_mac_addr_set = 0;
8195 u8 *host_bridge = 0;
8196 ip4_address_t host_ip4_addr;
8197 ip4_address_t host_ip4_gw;
8198 u8 host_ip4_gw_set = 0;
8199 u32 host_ip4_prefix_len = 0;
8200 ip6_address_t host_ip6_addr;
8201 ip6_address_t host_ip6_gw;
8202 u8 host_ip6_gw_set = 0;
8203 u32 host_ip6_prefix_len = 0;
8205 u32 rx_ring_sz = 0, tx_ring_sz = 0;
8207 clib_memset (mac_address, 0, sizeof (mac_address));
8209 /* Parse args required to build the message */
8210 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8212 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
8216 else if (unformat (i, "id %u", &id))
8218 else if (unformat (i, "host-if-name %s", &host_if_name))
8220 else if (unformat (i, "host-ns %s", &host_ns))
8222 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
8224 host_mac_addr_set = 1;
8225 else if (unformat (i, "host-bridge %s", &host_bridge))
8227 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
8228 &host_ip4_addr, &host_ip4_prefix_len))
8230 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
8231 &host_ip6_addr, &host_ip6_prefix_len))
8233 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
8235 host_ip4_gw_set = 1;
8236 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
8238 host_ip6_gw_set = 1;
8239 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
8241 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
8247 if (vec_len (host_if_name) > 63)
8249 errmsg ("tap name too long. ");
8252 if (vec_len (host_ns) > 63)
8254 errmsg ("host name space too long. ");
8257 if (vec_len (host_bridge) > 63)
8259 errmsg ("host bridge name too long. ");
8262 if (host_ip4_prefix_len > 32)
8264 errmsg ("host ip4 prefix length not valid. ");
8267 if (host_ip6_prefix_len > 128)
8269 errmsg ("host ip6 prefix length not valid. ");
8272 if (!is_pow2 (rx_ring_sz))
8274 errmsg ("rx ring size must be power of 2. ");
8277 if (rx_ring_sz > 32768)
8279 errmsg ("rx ring size must be 32768 or lower. ");
8282 if (!is_pow2 (tx_ring_sz))
8284 errmsg ("tx ring size must be power of 2. ");
8287 if (tx_ring_sz > 32768)
8289 errmsg ("tx ring size must be 32768 or lower. ");
8293 /* Construct the API message */
8294 M (TAP_CREATE_V2, mp);
8296 mp->use_random_mac = random_mac;
8298 mp->id = ntohl (id);
8299 mp->host_namespace_set = host_ns != 0;
8300 mp->host_bridge_set = host_bridge != 0;
8301 mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
8302 mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
8303 mp->rx_ring_sz = ntohs (rx_ring_sz);
8304 mp->tx_ring_sz = ntohs (tx_ring_sz);
8306 if (random_mac == 0)
8307 clib_memcpy (mp->mac_address, mac_address, 6);
8308 if (host_mac_addr_set)
8309 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
8311 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
8313 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
8315 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
8316 if (host_ip4_prefix_len)
8317 clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
8318 if (host_ip6_prefix_len)
8319 clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
8320 if (host_ip4_gw_set)
8321 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
8322 if (host_ip6_gw_set)
8323 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
8326 vec_free (host_if_name);
8327 vec_free (host_bridge);
8332 /* Wait for a reply... */
8338 api_tap_delete_v2 (vat_main_t * vam)
8340 unformat_input_t *i = vam->input;
8341 vl_api_tap_delete_v2_t *mp;
8342 u32 sw_if_index = ~0;
8343 u8 sw_if_index_set = 0;
8346 /* Parse args required to build the message */
8347 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8349 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8350 sw_if_index_set = 1;
8351 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8352 sw_if_index_set = 1;
8357 if (sw_if_index_set == 0)
8359 errmsg ("missing vpp interface name. ");
8363 /* Construct the API message */
8364 M (TAP_DELETE_V2, mp);
8366 mp->sw_if_index = ntohl (sw_if_index);
8371 /* Wait for a reply... */
8377 api_bond_create (vat_main_t * vam)
8379 unformat_input_t *i = vam->input;
8380 vl_api_bond_create_t *mp;
8388 clib_memset (mac_address, 0, sizeof (mac_address));
8391 /* Parse args required to build the message */
8392 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8394 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
8396 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
8397 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
8399 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
8406 if (mode_is_set == 0)
8408 errmsg ("Missing bond mode. ");
8412 /* Construct the API message */
8413 M (BOND_CREATE, mp);
8415 mp->use_custom_mac = custom_mac;
8421 clib_memcpy (mp->mac_address, mac_address, 6);
8426 /* Wait for a reply... */
8432 api_bond_delete (vat_main_t * vam)
8434 unformat_input_t *i = vam->input;
8435 vl_api_bond_delete_t *mp;
8436 u32 sw_if_index = ~0;
8437 u8 sw_if_index_set = 0;
8440 /* Parse args required to build the message */
8441 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8443 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8444 sw_if_index_set = 1;
8445 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8446 sw_if_index_set = 1;
8451 if (sw_if_index_set == 0)
8453 errmsg ("missing vpp interface name. ");
8457 /* Construct the API message */
8458 M (BOND_DELETE, mp);
8460 mp->sw_if_index = ntohl (sw_if_index);
8465 /* Wait for a reply... */
8471 api_bond_enslave (vat_main_t * vam)
8473 unformat_input_t *i = vam->input;
8474 vl_api_bond_enslave_t *mp;
8475 u32 bond_sw_if_index;
8479 u32 bond_sw_if_index_is_set = 0;
8481 u8 sw_if_index_is_set = 0;
8483 /* Parse args required to build the message */
8484 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8486 if (unformat (i, "sw_if_index %d", &sw_if_index))
8487 sw_if_index_is_set = 1;
8488 else if (unformat (i, "bond %u", &bond_sw_if_index))
8489 bond_sw_if_index_is_set = 1;
8490 else if (unformat (i, "passive %d", &is_passive))
8492 else if (unformat (i, "long-timeout %d", &is_long_timeout))
8498 if (bond_sw_if_index_is_set == 0)
8500 errmsg ("Missing bond sw_if_index. ");
8503 if (sw_if_index_is_set == 0)
8505 errmsg ("Missing slave sw_if_index. ");
8509 /* Construct the API message */
8510 M (BOND_ENSLAVE, mp);
8512 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
8513 mp->sw_if_index = ntohl (sw_if_index);
8514 mp->is_long_timeout = is_long_timeout;
8515 mp->is_passive = is_passive;
8520 /* Wait for a reply... */
8526 api_bond_detach_slave (vat_main_t * vam)
8528 unformat_input_t *i = vam->input;
8529 vl_api_bond_detach_slave_t *mp;
8530 u32 sw_if_index = ~0;
8531 u8 sw_if_index_set = 0;
8534 /* Parse args required to build the message */
8535 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8537 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8538 sw_if_index_set = 1;
8539 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8540 sw_if_index_set = 1;
8545 if (sw_if_index_set == 0)
8547 errmsg ("missing vpp interface name. ");
8551 /* Construct the API message */
8552 M (BOND_DETACH_SLAVE, mp);
8554 mp->sw_if_index = ntohl (sw_if_index);
8559 /* Wait for a reply... */
8565 api_ip_table_add_del (vat_main_t * vam)
8567 unformat_input_t *i = vam->input;
8568 vl_api_ip_table_add_del_t *mp;
8574 /* Parse args required to build the message */
8575 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8577 if (unformat (i, "ipv6"))
8579 else if (unformat (i, "del"))
8581 else if (unformat (i, "add"))
8583 else if (unformat (i, "table %d", &table_id))
8587 clib_warning ("parse error '%U'", format_unformat_error, i);
8594 errmsg ("missing table-ID");
8598 /* Construct the API message */
8599 M (IP_TABLE_ADD_DEL, mp);
8601 mp->table_id = ntohl (table_id);
8602 mp->is_ipv6 = is_ipv6;
8603 mp->is_add = is_add;
8608 /* Wait for a reply... */
8615 api_ip_add_del_route (vat_main_t * vam)
8617 unformat_input_t *i = vam->input;
8618 vl_api_ip_add_del_route_t *mp;
8619 u32 sw_if_index = ~0, vrf_id = 0;
8621 u8 is_local = 0, is_drop = 0;
8622 u8 is_unreach = 0, is_prohibit = 0;
8624 u32 next_hop_weight = 1;
8625 u8 is_multipath = 0;
8627 u8 address_length_set = 0;
8628 u32 next_hop_table_id = 0;
8629 u32 resolve_attempts = 0;
8630 u32 dst_address_length = 0;
8631 u8 next_hop_set = 0;
8632 ip4_address_t v4_dst_address, v4_next_hop_address;
8633 ip6_address_t v6_dst_address, v6_next_hop_address;
8637 u32 random_add_del = 0;
8638 u32 *random_vector = 0;
8640 u32 random_seed = 0xdeaddabe;
8641 u32 classify_table_index = ~0;
8643 u8 resolve_host = 0, resolve_attached = 0;
8644 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
8645 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8646 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8648 clib_memset (&v4_next_hop_address, 0, sizeof (ip4_address_t));
8649 clib_memset (&v6_next_hop_address, 0, sizeof (ip6_address_t));
8650 /* Parse args required to build the message */
8651 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8653 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8655 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8657 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
8662 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
8667 else if (unformat (i, "/%d", &dst_address_length))
8669 address_length_set = 1;
8672 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
8673 &v4_next_hop_address))
8677 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
8678 &v6_next_hop_address))
8684 (i, "via %U", api_unformat_sw_if_index, vam, &sw_if_index))
8688 else if (unformat (i, "via sw_if_index %d", &sw_if_index))
8692 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
8694 else if (unformat (i, "weight %d", &next_hop_weight))
8696 else if (unformat (i, "drop"))
8700 else if (unformat (i, "null-send-unreach"))
8704 else if (unformat (i, "null-send-prohibit"))
8708 else if (unformat (i, "local"))
8712 else if (unformat (i, "classify %d", &classify_table_index))
8716 else if (unformat (i, "del"))
8718 else if (unformat (i, "add"))
8720 else if (unformat (i, "resolve-via-host"))
8722 else if (unformat (i, "resolve-via-attached"))
8723 resolve_attached = 1;
8724 else if (unformat (i, "multipath"))
8726 else if (unformat (i, "vrf %d", &vrf_id))
8728 else if (unformat (i, "count %d", &count))
8730 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
8732 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8734 else if (unformat (i, "out-label %d", &next_hop_out_label))
8736 vl_api_fib_mpls_label_t fib_label = {
8737 .label = ntohl (next_hop_out_label),
8741 vec_add1 (next_hop_out_label_stack, fib_label);
8743 else if (unformat (i, "via via-label %d", &next_hop_via_label))
8745 else if (unformat (i, "random"))
8747 else if (unformat (i, "seed %d", &random_seed))
8751 clib_warning ("parse error '%U'", format_unformat_error, i);
8756 if (!next_hop_set && !is_drop && !is_local &&
8757 !is_classify && !is_unreach && !is_prohibit &&
8758 MPLS_LABEL_INVALID == next_hop_via_label)
8761 ("next hop / local / drop / unreach / prohibit / classify not set");
8765 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
8767 errmsg ("next hop and next-hop via label set");
8770 if (address_set == 0)
8772 errmsg ("missing addresses");
8776 if (address_length_set == 0)
8778 errmsg ("missing address length");
8782 /* Generate a pile of unique, random routes */
8785 u32 this_random_address;
8786 random_hash = hash_create (count, sizeof (uword));
8788 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
8789 for (j = 0; j <= count; j++)
8793 this_random_address = random_u32 (&random_seed);
8794 this_random_address =
8795 clib_host_to_net_u32 (this_random_address);
8797 while (hash_get (random_hash, this_random_address));
8798 vec_add1 (random_vector, this_random_address);
8799 hash_set (random_hash, this_random_address, 1);
8801 hash_free (random_hash);
8802 v4_dst_address.as_u32 = random_vector[0];
8807 /* Turn on async mode */
8808 vam->async_mode = 1;
8809 vam->async_errors = 0;
8810 before = vat_time_now (vam);
8813 for (j = 0; j < count; j++)
8815 /* Construct the API message */
8816 M2 (IP_ADD_DEL_ROUTE, mp, sizeof (vl_api_fib_mpls_label_t) *
8817 vec_len (next_hop_out_label_stack));
8819 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8820 mp->table_id = ntohl (vrf_id);
8822 mp->is_add = is_add;
8823 mp->is_drop = is_drop;
8824 mp->is_unreach = is_unreach;
8825 mp->is_prohibit = is_prohibit;
8826 mp->is_ipv6 = is_ipv6;
8827 mp->is_local = is_local;
8828 mp->is_classify = is_classify;
8829 mp->is_multipath = is_multipath;
8830 mp->is_resolve_host = resolve_host;
8831 mp->is_resolve_attached = resolve_attached;
8832 mp->next_hop_weight = next_hop_weight;
8833 mp->next_hop_preference = 0;
8834 mp->dst_address_length = dst_address_length;
8835 mp->next_hop_table_id = ntohl (next_hop_table_id);
8836 mp->classify_table_index = ntohl (classify_table_index);
8837 mp->next_hop_via_label = ntohl (next_hop_via_label);
8838 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8839 if (0 != mp->next_hop_n_out_labels)
8841 memcpy (mp->next_hop_out_label_stack,
8842 next_hop_out_label_stack,
8843 (vec_len (next_hop_out_label_stack) *
8844 sizeof (vl_api_fib_mpls_label_t)));
8845 vec_free (next_hop_out_label_stack);
8850 clib_memcpy (mp->dst_address, &v6_dst_address,
8851 sizeof (v6_dst_address));
8853 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
8854 sizeof (v6_next_hop_address));
8855 increment_v6_address (&v6_dst_address);
8859 clib_memcpy (mp->dst_address, &v4_dst_address,
8860 sizeof (v4_dst_address));
8862 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
8863 sizeof (v4_next_hop_address));
8865 v4_dst_address.as_u32 = random_vector[j + 1];
8867 increment_v4_address (&v4_dst_address);
8871 /* If we receive SIGTERM, stop now... */
8876 /* When testing multiple add/del ops, use a control-ping to sync */
8879 vl_api_control_ping_t *mp_ping;
8883 /* Shut off async mode */
8884 vam->async_mode = 0;
8886 MPING (CONTROL_PING, mp_ping);
8889 timeout = vat_time_now (vam) + 1.0;
8890 while (vat_time_now (vam) < timeout)
8891 if (vam->result_ready == 1)
8896 if (vam->retval == -99)
8899 if (vam->async_errors > 0)
8901 errmsg ("%d asynchronous errors", vam->async_errors);
8904 vam->async_errors = 0;
8905 after = vat_time_now (vam);
8907 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8911 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8912 count, after - before, count / (after - before));
8918 /* Wait for a reply... */
8923 /* Return the good/bad news */
8924 return (vam->retval);
8928 api_ip_mroute_add_del (vat_main_t * vam)
8930 unformat_input_t *i = vam->input;
8931 vl_api_ip_mroute_add_del_t *mp;
8932 u32 sw_if_index = ~0, vrf_id = 0;
8937 u32 grp_address_length = 0;
8938 ip4_address_t v4_grp_address, v4_src_address;
8939 ip6_address_t v6_grp_address, v6_src_address;
8940 mfib_itf_flags_t iflags = 0;
8941 mfib_entry_flags_t eflags = 0;
8944 /* Parse args required to build the message */
8945 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8947 if (unformat (i, "sw_if_index %d", &sw_if_index))
8949 else if (unformat (i, "%U %U",
8950 unformat_ip4_address, &v4_src_address,
8951 unformat_ip4_address, &v4_grp_address))
8953 grp_address_length = 64;
8957 else if (unformat (i, "%U %U",
8958 unformat_ip6_address, &v6_src_address,
8959 unformat_ip6_address, &v6_grp_address))
8961 grp_address_length = 256;
8965 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
8967 clib_memset (&v4_src_address, 0, sizeof (v4_src_address));
8968 grp_address_length = 32;
8972 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
8974 clib_memset (&v6_src_address, 0, sizeof (v6_src_address));
8975 grp_address_length = 128;
8979 else if (unformat (i, "/%d", &grp_address_length))
8981 else if (unformat (i, "local"))
8985 else if (unformat (i, "del"))
8987 else if (unformat (i, "add"))
8989 else if (unformat (i, "vrf %d", &vrf_id))
8991 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
8993 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8997 clib_warning ("parse error '%U'", format_unformat_error, i);
9002 if (address_set == 0)
9004 errmsg ("missing addresses\n");
9008 /* Construct the API message */
9009 M (IP_MROUTE_ADD_DEL, mp);
9011 mp->next_hop_sw_if_index = ntohl (sw_if_index);
9012 mp->table_id = ntohl (vrf_id);
9014 mp->is_add = is_add;
9015 mp->is_ipv6 = is_ipv6;
9016 mp->is_local = is_local;
9017 mp->itf_flags = ntohl (iflags);
9018 mp->entry_flags = ntohl (eflags);
9019 mp->grp_address_length = grp_address_length;
9020 mp->grp_address_length = ntohs (mp->grp_address_length);
9024 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
9025 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
9029 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
9030 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
9036 /* Wait for a reply... */
9042 api_mpls_table_add_del (vat_main_t * vam)
9044 unformat_input_t *i = vam->input;
9045 vl_api_mpls_table_add_del_t *mp;
9050 /* Parse args required to build the message */
9051 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9053 if (unformat (i, "table %d", &table_id))
9055 else if (unformat (i, "del"))
9057 else if (unformat (i, "add"))
9061 clib_warning ("parse error '%U'", format_unformat_error, i);
9068 errmsg ("missing table-ID");
9072 /* Construct the API message */
9073 M (MPLS_TABLE_ADD_DEL, mp);
9075 mp->mt_table_id = ntohl (table_id);
9076 mp->mt_is_add = is_add;
9081 /* Wait for a reply... */
9088 api_mpls_route_add_del (vat_main_t * vam)
9090 unformat_input_t *i = vam->input;
9091 vl_api_mpls_route_add_del_t *mp;
9092 u32 sw_if_index = ~0, table_id = 0;
9094 u32 next_hop_weight = 1;
9095 u8 is_multipath = 0;
9096 u32 next_hop_table_id = 0;
9097 u8 next_hop_set = 0;
9098 ip4_address_t v4_next_hop_address = {
9101 ip6_address_t v6_next_hop_address = { {0} };
9105 u32 classify_table_index = ~0;
9107 u8 resolve_host = 0, resolve_attached = 0;
9108 u8 is_interface_rx = 0;
9109 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
9110 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9111 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
9112 mpls_label_t local_label = MPLS_LABEL_INVALID;
9114 dpo_proto_t next_hop_proto = DPO_PROTO_MPLS;
9116 /* Parse args required to build the message */
9117 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9119 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9121 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9123 else if (unformat (i, "%d", &local_label))
9125 else if (unformat (i, "eos"))
9127 else if (unformat (i, "non-eos"))
9129 else if (unformat (i, "via %U", unformat_ip4_address,
9130 &v4_next_hop_address))
9133 next_hop_proto = DPO_PROTO_IP4;
9135 else if (unformat (i, "via %U", unformat_ip6_address,
9136 &v6_next_hop_address))
9139 next_hop_proto = DPO_PROTO_IP6;
9141 else if (unformat (i, "weight %d", &next_hop_weight))
9143 else if (unformat (i, "classify %d", &classify_table_index))
9147 else if (unformat (i, "del"))
9149 else if (unformat (i, "add"))
9151 else if (unformat (i, "resolve-via-host"))
9153 else if (unformat (i, "resolve-via-attached"))
9154 resolve_attached = 1;
9155 else if (unformat (i, "multipath"))
9157 else if (unformat (i, "count %d", &count))
9159 else if (unformat (i, "via lookup-in-ip4-table %d", &next_hop_table_id))
9162 next_hop_proto = DPO_PROTO_IP4;
9164 else if (unformat (i, "via lookup-in-ip6-table %d", &next_hop_table_id))
9167 next_hop_proto = DPO_PROTO_IP6;
9171 (i, "via l2-input-on %U", api_unformat_sw_if_index, vam,
9175 next_hop_proto = DPO_PROTO_ETHERNET;
9176 is_interface_rx = 1;
9178 else if (unformat (i, "via l2-input-on sw_if_index %d", &sw_if_index))
9181 next_hop_proto = DPO_PROTO_ETHERNET;
9182 is_interface_rx = 1;
9184 else if (unformat (i, "via next-hop-table %d", &next_hop_table_id))
9186 else if (unformat (i, "via via-label %d", &next_hop_via_label))
9188 else if (unformat (i, "out-label %d", &next_hop_out_label))
9190 vl_api_fib_mpls_label_t fib_label = {
9191 .label = ntohl (next_hop_out_label),
9195 vec_add1 (next_hop_out_label_stack, fib_label);
9199 clib_warning ("parse error '%U'", format_unformat_error, i);
9204 if (!next_hop_set && !is_classify)
9206 errmsg ("next hop / classify not set");
9210 if (MPLS_LABEL_INVALID == local_label)
9212 errmsg ("missing label");
9218 /* Turn on async mode */
9219 vam->async_mode = 1;
9220 vam->async_errors = 0;
9221 before = vat_time_now (vam);
9224 for (j = 0; j < count; j++)
9226 /* Construct the API message */
9227 M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_mpls_label_t) *
9228 vec_len (next_hop_out_label_stack));
9230 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
9231 mp->mr_table_id = ntohl (table_id);
9233 mp->mr_is_add = is_add;
9234 mp->mr_next_hop_proto = next_hop_proto;
9235 mp->mr_is_classify = is_classify;
9236 mp->mr_is_multipath = is_multipath;
9237 mp->mr_is_resolve_host = resolve_host;
9238 mp->mr_is_resolve_attached = resolve_attached;
9239 mp->mr_is_interface_rx = is_interface_rx;
9240 mp->mr_next_hop_weight = next_hop_weight;
9241 mp->mr_next_hop_preference = 0;
9242 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
9243 mp->mr_classify_table_index = ntohl (classify_table_index);
9244 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
9245 mp->mr_label = ntohl (local_label);
9246 mp->mr_eos = is_eos;
9248 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
9249 if (0 != mp->mr_next_hop_n_out_labels)
9251 memcpy (mp->mr_next_hop_out_label_stack,
9252 next_hop_out_label_stack,
9253 vec_len (next_hop_out_label_stack) *
9254 sizeof (vl_api_fib_mpls_label_t));
9255 vec_free (next_hop_out_label_stack);
9260 if (DPO_PROTO_IP4 == next_hop_proto)
9262 clib_memcpy (mp->mr_next_hop,
9263 &v4_next_hop_address,
9264 sizeof (v4_next_hop_address));
9266 else if (DPO_PROTO_IP6 == next_hop_proto)
9269 clib_memcpy (mp->mr_next_hop,
9270 &v6_next_hop_address,
9271 sizeof (v6_next_hop_address));
9278 /* If we receive SIGTERM, stop now... */
9283 /* When testing multiple add/del ops, use a control-ping to sync */
9286 vl_api_control_ping_t *mp_ping;
9290 /* Shut off async mode */
9291 vam->async_mode = 0;
9293 MPING (CONTROL_PING, mp_ping);
9296 timeout = vat_time_now (vam) + 1.0;
9297 while (vat_time_now (vam) < timeout)
9298 if (vam->result_ready == 1)
9303 if (vam->retval == -99)
9306 if (vam->async_errors > 0)
9308 errmsg ("%d asynchronous errors", vam->async_errors);
9311 vam->async_errors = 0;
9312 after = vat_time_now (vam);
9314 /* slim chance, but we might have eaten SIGTERM on the first iteration */
9318 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
9319 count, after - before, count / (after - before));
9325 /* Wait for a reply... */
9330 /* Return the good/bad news */
9331 return (vam->retval);
9335 api_mpls_ip_bind_unbind (vat_main_t * vam)
9337 unformat_input_t *i = vam->input;
9338 vl_api_mpls_ip_bind_unbind_t *mp;
9339 u32 ip_table_id = 0;
9342 ip4_address_t v4_address;
9343 ip6_address_t v6_address;
9346 mpls_label_t local_label = MPLS_LABEL_INVALID;
9349 /* Parse args required to build the message */
9350 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9352 if (unformat (i, "%U/%d", unformat_ip4_address,
9353 &v4_address, &address_length))
9358 else if (unformat (i, "%U/%d", unformat_ip6_address,
9359 &v6_address, &address_length))
9364 else if (unformat (i, "%d", &local_label))
9366 else if (unformat (i, "table-id %d", &ip_table_id))
9368 else if (unformat (i, "unbind"))
9370 else if (unformat (i, "bind"))
9374 clib_warning ("parse error '%U'", format_unformat_error, i);
9381 errmsg ("IP address not set");
9385 if (MPLS_LABEL_INVALID == local_label)
9387 errmsg ("missing label");
9391 /* Construct the API message */
9392 M (MPLS_IP_BIND_UNBIND, mp);
9394 mp->mb_is_bind = is_bind;
9395 mp->mb_is_ip4 = is_ip4;
9396 mp->mb_ip_table_id = ntohl (ip_table_id);
9397 mp->mb_mpls_table_id = 0;
9398 mp->mb_label = ntohl (local_label);
9399 mp->mb_address_length = address_length;
9402 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
9404 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
9409 /* Wait for a reply... */
9415 api_sr_mpls_policy_add (vat_main_t * vam)
9417 unformat_input_t *i = vam->input;
9418 vl_api_sr_mpls_policy_add_t *mp;
9424 u32 *segments = NULL;
9427 /* Parse args required to build the message */
9428 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9430 if (unformat (i, "bsid %d", &bsid))
9432 else if (unformat (i, "weight %d", &weight))
9434 else if (unformat (i, "spray"))
9436 else if (unformat (i, "next %d", &sid))
9439 vec_add1 (segments, htonl (sid));
9443 clib_warning ("parse error '%U'", format_unformat_error, i);
9450 errmsg ("bsid not set");
9454 if (n_segments == 0)
9456 errmsg ("no sid in segment stack");
9460 /* Construct the API message */
9461 M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
9463 mp->bsid = htonl (bsid);
9464 mp->weight = htonl (weight);
9466 mp->n_segments = n_segments;
9467 memcpy (mp->segments, segments, sizeof (u32) * n_segments);
9468 vec_free (segments);
9473 /* Wait for a reply... */
9479 api_sr_mpls_policy_del (vat_main_t * vam)
9481 unformat_input_t *i = vam->input;
9482 vl_api_sr_mpls_policy_del_t *mp;
9486 /* Parse args required to build the message */
9487 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9489 if (unformat (i, "bsid %d", &bsid))
9493 clib_warning ("parse error '%U'", format_unformat_error, i);
9500 errmsg ("bsid not set");
9504 /* Construct the API message */
9505 M (SR_MPLS_POLICY_DEL, mp);
9507 mp->bsid = htonl (bsid);
9512 /* Wait for a reply... */
9518 api_bier_table_add_del (vat_main_t * vam)
9520 unformat_input_t *i = vam->input;
9521 vl_api_bier_table_add_del_t *mp;
9523 u32 set = 0, sub_domain = 0, hdr_len = 3;
9524 mpls_label_t local_label = MPLS_LABEL_INVALID;
9527 /* Parse args required to build the message */
9528 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9530 if (unformat (i, "sub-domain %d", &sub_domain))
9532 else if (unformat (i, "set %d", &set))
9534 else if (unformat (i, "label %d", &local_label))
9536 else if (unformat (i, "hdr-len %d", &hdr_len))
9538 else if (unformat (i, "add"))
9540 else if (unformat (i, "del"))
9544 clib_warning ("parse error '%U'", format_unformat_error, i);
9549 if (MPLS_LABEL_INVALID == local_label)
9551 errmsg ("missing label\n");
9555 /* Construct the API message */
9556 M (BIER_TABLE_ADD_DEL, mp);
9558 mp->bt_is_add = is_add;
9559 mp->bt_label = ntohl (local_label);
9560 mp->bt_tbl_id.bt_set = set;
9561 mp->bt_tbl_id.bt_sub_domain = sub_domain;
9562 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
9567 /* Wait for a reply... */
9574 api_bier_route_add_del (vat_main_t * vam)
9576 unformat_input_t *i = vam->input;
9577 vl_api_bier_route_add_del_t *mp;
9579 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
9580 ip4_address_t v4_next_hop_address;
9581 ip6_address_t v6_next_hop_address;
9582 u8 next_hop_set = 0;
9583 u8 next_hop_proto_is_ip4 = 1;
9584 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9587 /* Parse args required to build the message */
9588 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9590 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
9592 next_hop_proto_is_ip4 = 1;
9595 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
9597 next_hop_proto_is_ip4 = 0;
9600 if (unformat (i, "sub-domain %d", &sub_domain))
9602 else if (unformat (i, "set %d", &set))
9604 else if (unformat (i, "hdr-len %d", &hdr_len))
9606 else if (unformat (i, "bp %d", &bp))
9608 else if (unformat (i, "add"))
9610 else if (unformat (i, "del"))
9612 else if (unformat (i, "out-label %d", &next_hop_out_label))
9616 clib_warning ("parse error '%U'", format_unformat_error, i);
9621 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
9623 errmsg ("next hop / label set\n");
9628 errmsg ("bit=position not set\n");
9632 /* Construct the API message */
9633 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
9635 mp->br_is_add = is_add;
9636 mp->br_tbl_id.bt_set = set;
9637 mp->br_tbl_id.bt_sub_domain = sub_domain;
9638 mp->br_tbl_id.bt_hdr_len_id = hdr_len;
9639 mp->br_bp = ntohs (bp);
9641 mp->br_paths[0].n_labels = 1;
9642 mp->br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
9643 mp->br_paths[0].afi = (next_hop_proto_is_ip4 ? 0 : 1);
9645 if (next_hop_proto_is_ip4)
9647 clib_memcpy (mp->br_paths[0].next_hop,
9648 &v4_next_hop_address, sizeof (v4_next_hop_address));
9652 clib_memcpy (mp->br_paths[0].next_hop,
9653 &v6_next_hop_address, sizeof (v6_next_hop_address));
9659 /* Wait for a reply... */
9666 api_proxy_arp_add_del (vat_main_t * vam)
9668 unformat_input_t *i = vam->input;
9669 vl_api_proxy_arp_add_del_t *mp;
9672 ip4_address_t lo, hi;
9676 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9678 if (unformat (i, "vrf %d", &vrf_id))
9680 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
9681 unformat_ip4_address, &hi))
9683 else if (unformat (i, "del"))
9687 clib_warning ("parse error '%U'", format_unformat_error, i);
9694 errmsg ("address range not set");
9698 M (PROXY_ARP_ADD_DEL, mp);
9700 mp->proxy.vrf_id = ntohl (vrf_id);
9701 mp->is_add = is_add;
9702 clib_memcpy (mp->proxy.low_address, &lo, sizeof (mp->proxy.low_address));
9703 clib_memcpy (mp->proxy.hi_address, &hi, sizeof (mp->proxy.hi_address));
9711 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
9713 unformat_input_t *i = vam->input;
9714 vl_api_proxy_arp_intfc_enable_disable_t *mp;
9717 u8 sw_if_index_set = 0;
9720 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9722 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9723 sw_if_index_set = 1;
9724 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9725 sw_if_index_set = 1;
9726 else if (unformat (i, "enable"))
9728 else if (unformat (i, "disable"))
9732 clib_warning ("parse error '%U'", format_unformat_error, i);
9737 if (sw_if_index_set == 0)
9739 errmsg ("missing interface name or sw_if_index");
9743 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
9745 mp->sw_if_index = ntohl (sw_if_index);
9746 mp->enable_disable = enable;
9754 api_mpls_tunnel_add_del (vat_main_t * vam)
9756 unformat_input_t *i = vam->input;
9757 vl_api_mpls_tunnel_add_del_t *mp;
9761 u32 sw_if_index = ~0;
9762 u32 next_hop_sw_if_index = ~0;
9763 u32 next_hop_proto_is_ip4 = 1;
9765 u32 next_hop_table_id = 0;
9766 ip4_address_t v4_next_hop_address = {
9769 ip6_address_t v6_next_hop_address = { {0} };
9770 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
9771 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
9772 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9775 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9777 if (unformat (i, "add"))
9781 (i, "del %U", api_unformat_sw_if_index, vam, &sw_if_index))
9783 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
9785 else if (unformat (i, "via %U",
9786 unformat_ip4_address, &v4_next_hop_address))
9788 next_hop_proto_is_ip4 = 1;
9790 else if (unformat (i, "via %U",
9791 unformat_ip6_address, &v6_next_hop_address))
9793 next_hop_proto_is_ip4 = 0;
9795 else if (unformat (i, "via-label %d", &next_hop_via_label))
9799 (i, "%U", api_unformat_sw_if_index, vam, &next_hop_sw_if_index))
9801 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
9803 else if (unformat (i, "l2-only"))
9805 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
9807 else if (unformat (i, "out-label %d", &next_hop_out_label))
9809 vl_api_fib_mpls_label_t fib_label = {
9810 .label = ntohl (next_hop_out_label),
9814 vec_add1 (next_hop_out_label_stack, fib_label);
9818 clib_warning ("parse error '%U'", format_unformat_error, i);
9823 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (vl_api_fib_mpls_label_t) *
9824 vec_len (next_hop_out_label_stack));
9826 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
9827 mp->mt_sw_if_index = ntohl (sw_if_index);
9828 mp->mt_is_add = is_add;
9829 mp->mt_l2_only = l2_only;
9830 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
9831 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
9832 mp->mt_next_hop_via_label = ntohl (next_hop_via_label);
9833 mp->mt_next_hop_weight = 1;
9834 mp->mt_next_hop_preference = 0;
9836 mp->mt_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
9838 if (0 != mp->mt_next_hop_n_out_labels)
9840 clib_memcpy (mp->mt_next_hop_out_label_stack,
9841 next_hop_out_label_stack,
9842 (vec_len (next_hop_out_label_stack) *
9843 sizeof (vl_api_fib_mpls_label_t)));
9844 vec_free (next_hop_out_label_stack);
9847 if (next_hop_proto_is_ip4)
9849 clib_memcpy (mp->mt_next_hop,
9850 &v4_next_hop_address, sizeof (v4_next_hop_address));
9854 clib_memcpy (mp->mt_next_hop,
9855 &v6_next_hop_address, sizeof (v6_next_hop_address));
9864 api_sw_interface_set_unnumbered (vat_main_t * vam)
9866 unformat_input_t *i = vam->input;
9867 vl_api_sw_interface_set_unnumbered_t *mp;
9869 u32 unnum_sw_index = ~0;
9871 u8 sw_if_index_set = 0;
9874 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9876 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9877 sw_if_index_set = 1;
9878 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9879 sw_if_index_set = 1;
9880 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
9882 else if (unformat (i, "del"))
9886 clib_warning ("parse error '%U'", format_unformat_error, i);
9891 if (sw_if_index_set == 0)
9893 errmsg ("missing interface name or sw_if_index");
9897 M (SW_INTERFACE_SET_UNNUMBERED, mp);
9899 mp->sw_if_index = ntohl (sw_if_index);
9900 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
9901 mp->is_add = is_add;
9909 api_ip_neighbor_add_del (vat_main_t * vam)
9911 unformat_input_t *i = vam->input;
9912 vl_api_ip_neighbor_add_del_t *mp;
9914 u8 sw_if_index_set = 0;
9917 u8 is_no_fib_entry = 0;
9920 u8 v4_address_set = 0;
9921 u8 v6_address_set = 0;
9922 ip4_address_t v4address;
9923 ip6_address_t v6address;
9926 clib_memset (mac_address, 0, sizeof (mac_address));
9928 /* Parse args required to build the message */
9929 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9931 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
9935 else if (unformat (i, "del"))
9938 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9939 sw_if_index_set = 1;
9940 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9941 sw_if_index_set = 1;
9942 else if (unformat (i, "is_static"))
9944 else if (unformat (i, "no-fib-entry"))
9945 is_no_fib_entry = 1;
9946 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
9948 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
9952 clib_warning ("parse error '%U'", format_unformat_error, i);
9957 if (sw_if_index_set == 0)
9959 errmsg ("missing interface name or sw_if_index");
9962 if (v4_address_set && v6_address_set)
9964 errmsg ("both v4 and v6 addresses set");
9967 if (!v4_address_set && !v6_address_set)
9969 errmsg ("no address set");
9973 /* Construct the API message */
9974 M (IP_NEIGHBOR_ADD_DEL, mp);
9976 mp->sw_if_index = ntohl (sw_if_index);
9977 mp->is_add = is_add;
9978 mp->is_static = is_static;
9979 mp->is_no_adj_fib = is_no_fib_entry;
9981 clib_memcpy (mp->mac_address, mac_address, 6);
9985 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
9989 /* mp->is_ipv6 = 0; via clib_memset in M macro above */
9990 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
9996 /* Wait for a reply, return good/bad news */
10002 api_create_vlan_subif (vat_main_t * vam)
10004 unformat_input_t *i = vam->input;
10005 vl_api_create_vlan_subif_t *mp;
10007 u8 sw_if_index_set = 0;
10009 u8 vlan_id_set = 0;
10012 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10014 if (unformat (i, "sw_if_index %d", &sw_if_index))
10015 sw_if_index_set = 1;
10017 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10018 sw_if_index_set = 1;
10019 else if (unformat (i, "vlan %d", &vlan_id))
10023 clib_warning ("parse error '%U'", format_unformat_error, i);
10028 if (sw_if_index_set == 0)
10030 errmsg ("missing interface name or sw_if_index");
10034 if (vlan_id_set == 0)
10036 errmsg ("missing vlan_id");
10039 M (CREATE_VLAN_SUBIF, mp);
10041 mp->sw_if_index = ntohl (sw_if_index);
10042 mp->vlan_id = ntohl (vlan_id);
10049 #define foreach_create_subif_bit \
10056 _(outer_vlan_id_any) \
10057 _(inner_vlan_id_any)
10060 api_create_subif (vat_main_t * vam)
10062 unformat_input_t *i = vam->input;
10063 vl_api_create_subif_t *mp;
10065 u8 sw_if_index_set = 0;
10072 u32 exact_match = 0;
10073 u32 default_sub = 0;
10074 u32 outer_vlan_id_any = 0;
10075 u32 inner_vlan_id_any = 0;
10077 u16 outer_vlan_id = 0;
10078 u16 inner_vlan_id = 0;
10081 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10083 if (unformat (i, "sw_if_index %d", &sw_if_index))
10084 sw_if_index_set = 1;
10086 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10087 sw_if_index_set = 1;
10088 else if (unformat (i, "sub_id %d", &sub_id))
10090 else if (unformat (i, "outer_vlan_id %d", &tmp))
10091 outer_vlan_id = tmp;
10092 else if (unformat (i, "inner_vlan_id %d", &tmp))
10093 inner_vlan_id = tmp;
10095 #define _(a) else if (unformat (i, #a)) a = 1 ;
10096 foreach_create_subif_bit
10100 clib_warning ("parse error '%U'", format_unformat_error, i);
10105 if (sw_if_index_set == 0)
10107 errmsg ("missing interface name or sw_if_index");
10111 if (sub_id_set == 0)
10113 errmsg ("missing sub_id");
10116 M (CREATE_SUBIF, mp);
10118 mp->sw_if_index = ntohl (sw_if_index);
10119 mp->sub_id = ntohl (sub_id);
10121 #define _(a) mp->a = a;
10122 foreach_create_subif_bit;
10125 mp->outer_vlan_id = ntohs (outer_vlan_id);
10126 mp->inner_vlan_id = ntohs (inner_vlan_id);
10134 api_oam_add_del (vat_main_t * vam)
10136 unformat_input_t *i = vam->input;
10137 vl_api_oam_add_del_t *mp;
10140 ip4_address_t src, dst;
10145 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10147 if (unformat (i, "vrf %d", &vrf_id))
10149 else if (unformat (i, "src %U", unformat_ip4_address, &src))
10151 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
10153 else if (unformat (i, "del"))
10157 clib_warning ("parse error '%U'", format_unformat_error, i);
10164 errmsg ("missing src addr");
10170 errmsg ("missing dst addr");
10174 M (OAM_ADD_DEL, mp);
10176 mp->vrf_id = ntohl (vrf_id);
10177 mp->is_add = is_add;
10178 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
10179 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
10187 api_reset_fib (vat_main_t * vam)
10189 unformat_input_t *i = vam->input;
10190 vl_api_reset_fib_t *mp;
10196 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10198 if (unformat (i, "vrf %d", &vrf_id))
10200 else if (unformat (i, "ipv6"))
10204 clib_warning ("parse error '%U'", format_unformat_error, i);
10209 if (vrf_id_set == 0)
10211 errmsg ("missing vrf id");
10217 mp->vrf_id = ntohl (vrf_id);
10218 mp->is_ipv6 = is_ipv6;
10226 api_dhcp_proxy_config (vat_main_t * vam)
10228 unformat_input_t *i = vam->input;
10229 vl_api_dhcp_proxy_config_t *mp;
10231 u32 server_vrf_id = 0;
10233 u8 v4_address_set = 0;
10234 u8 v6_address_set = 0;
10235 ip4_address_t v4address;
10236 ip6_address_t v6address;
10237 u8 v4_src_address_set = 0;
10238 u8 v6_src_address_set = 0;
10239 ip4_address_t v4srcaddress;
10240 ip6_address_t v6srcaddress;
10243 /* Parse args required to build the message */
10244 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10246 if (unformat (i, "del"))
10248 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
10250 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
10252 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
10253 v4_address_set = 1;
10254 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
10255 v6_address_set = 1;
10256 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
10257 v4_src_address_set = 1;
10258 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
10259 v6_src_address_set = 1;
10264 if (v4_address_set && v6_address_set)
10266 errmsg ("both v4 and v6 server addresses set");
10269 if (!v4_address_set && !v6_address_set)
10271 errmsg ("no server addresses set");
10275 if (v4_src_address_set && v6_src_address_set)
10277 errmsg ("both v4 and v6 src addresses set");
10280 if (!v4_src_address_set && !v6_src_address_set)
10282 errmsg ("no src addresses set");
10286 if (!(v4_src_address_set && v4_address_set) &&
10287 !(v6_src_address_set && v6_address_set))
10289 errmsg ("no matching server and src addresses set");
10293 /* Construct the API message */
10294 M (DHCP_PROXY_CONFIG, mp);
10296 mp->is_add = is_add;
10297 mp->rx_vrf_id = ntohl (rx_vrf_id);
10298 mp->server_vrf_id = ntohl (server_vrf_id);
10299 if (v6_address_set)
10302 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
10303 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
10307 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
10308 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
10314 /* Wait for a reply, return good/bad news */
10319 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
10320 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
10323 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
10325 vat_main_t *vam = &vat_main;
10326 u32 i, count = mp->count;
10327 vl_api_dhcp_server_t *s;
10331 "RX Table-ID %d, Source Address %U, VSS Type %d, "
10332 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
10333 ntohl (mp->rx_vrf_id),
10334 format_ip6_address, mp->dhcp_src_address,
10335 mp->vss_type, mp->vss_vpn_ascii_id,
10336 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
10339 "RX Table-ID %d, Source Address %U, VSS Type %d, "
10340 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
10341 ntohl (mp->rx_vrf_id),
10342 format_ip4_address, mp->dhcp_src_address,
10343 mp->vss_type, mp->vss_vpn_ascii_id,
10344 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
10346 for (i = 0; i < count; i++)
10348 s = &mp->servers[i];
10352 " Server Table-ID %d, Server Address %U",
10353 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
10356 " Server Table-ID %d, Server Address %U",
10357 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
10361 static void vl_api_dhcp_proxy_details_t_handler_json
10362 (vl_api_dhcp_proxy_details_t * mp)
10364 vat_main_t *vam = &vat_main;
10365 vat_json_node_t *node = NULL;
10366 u32 i, count = mp->count;
10367 struct in_addr ip4;
10368 struct in6_addr ip6;
10369 vl_api_dhcp_server_t *s;
10371 if (VAT_JSON_ARRAY != vam->json_tree.type)
10373 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10374 vat_json_init_array (&vam->json_tree);
10376 node = vat_json_array_add (&vam->json_tree);
10378 vat_json_init_object (node);
10379 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
10380 vat_json_object_add_bytes (node, "vss-type", &mp->vss_type,
10381 sizeof (mp->vss_type));
10382 vat_json_object_add_string_copy (node, "vss-vpn-ascii-id",
10383 mp->vss_vpn_ascii_id);
10384 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
10385 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
10389 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
10390 vat_json_object_add_ip6 (node, "src_address", ip6);
10394 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
10395 vat_json_object_add_ip4 (node, "src_address", ip4);
10398 for (i = 0; i < count; i++)
10400 s = &mp->servers[i];
10402 vat_json_object_add_uint (node, "server-table-id",
10403 ntohl (s->server_vrf_id));
10407 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
10408 vat_json_object_add_ip4 (node, "src_address", ip4);
10412 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
10413 vat_json_object_add_ip6 (node, "server_address", ip6);
10419 api_dhcp_proxy_dump (vat_main_t * vam)
10421 unformat_input_t *i = vam->input;
10422 vl_api_control_ping_t *mp_ping;
10423 vl_api_dhcp_proxy_dump_t *mp;
10427 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10429 if (unformat (i, "ipv6"))
10433 clib_warning ("parse error '%U'", format_unformat_error, i);
10438 M (DHCP_PROXY_DUMP, mp);
10440 mp->is_ip6 = is_ipv6;
10443 /* Use a control ping for synchronization */
10444 MPING (CONTROL_PING, mp_ping);
10452 api_dhcp_proxy_set_vss (vat_main_t * vam)
10454 unformat_input_t *i = vam->input;
10455 vl_api_dhcp_proxy_set_vss_t *mp;
10459 u8 vss_type = VSS_TYPE_DEFAULT;
10460 u8 *vpn_ascii_id = 0;
10465 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10467 if (unformat (i, "tbl_id %d", &tbl_id))
10469 else if (unformat (i, "vpn_ascii_id %s", &vpn_ascii_id))
10470 vss_type = VSS_TYPE_ASCII;
10471 else if (unformat (i, "fib_id %d", &fib_id))
10472 vss_type = VSS_TYPE_VPN_ID;
10473 else if (unformat (i, "oui %d", &oui))
10474 vss_type = VSS_TYPE_VPN_ID;
10475 else if (unformat (i, "ipv6"))
10477 else if (unformat (i, "del"))
10485 errmsg ("missing tbl_id ");
10486 vec_free (vpn_ascii_id);
10490 if ((vpn_ascii_id) && (vec_len (vpn_ascii_id) > 128))
10492 errmsg ("vpn_ascii_id cannot be longer than 128 ");
10493 vec_free (vpn_ascii_id);
10497 M (DHCP_PROXY_SET_VSS, mp);
10498 mp->tbl_id = ntohl (tbl_id);
10499 mp->vss_type = vss_type;
10502 clib_memcpy (mp->vpn_ascii_id, vpn_ascii_id, vec_len (vpn_ascii_id));
10503 mp->vpn_ascii_id[vec_len (vpn_ascii_id)] = 0;
10505 mp->vpn_index = ntohl (fib_id);
10506 mp->oui = ntohl (oui);
10507 mp->is_ipv6 = is_ipv6;
10508 mp->is_add = is_add;
10513 vec_free (vpn_ascii_id);
10518 api_dhcp_client_config (vat_main_t * vam)
10520 unformat_input_t *i = vam->input;
10521 vl_api_dhcp_client_config_t *mp;
10523 u8 sw_if_index_set = 0;
10526 u8 disable_event = 0;
10529 /* Parse args required to build the message */
10530 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10532 if (unformat (i, "del"))
10535 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10536 sw_if_index_set = 1;
10537 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10538 sw_if_index_set = 1;
10539 else if (unformat (i, "hostname %s", &hostname))
10541 else if (unformat (i, "disable_event"))
10547 if (sw_if_index_set == 0)
10549 errmsg ("missing interface name or sw_if_index");
10553 if (vec_len (hostname) > 63)
10555 errmsg ("hostname too long");
10557 vec_add1 (hostname, 0);
10559 /* Construct the API message */
10560 M (DHCP_CLIENT_CONFIG, mp);
10562 mp->is_add = is_add;
10563 mp->client.sw_if_index = htonl (sw_if_index);
10564 clib_memcpy (mp->client.hostname, hostname, vec_len (hostname));
10565 vec_free (hostname);
10566 mp->client.want_dhcp_event = disable_event ? 0 : 1;
10567 mp->client.pid = htonl (getpid ());
10572 /* Wait for a reply, return good/bad news */
10578 api_set_ip_flow_hash (vat_main_t * vam)
10580 unformat_input_t *i = vam->input;
10581 vl_api_set_ip_flow_hash_t *mp;
10593 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10595 if (unformat (i, "vrf %d", &vrf_id))
10597 else if (unformat (i, "ipv6"))
10599 else if (unformat (i, "src"))
10601 else if (unformat (i, "dst"))
10603 else if (unformat (i, "sport"))
10605 else if (unformat (i, "dport"))
10607 else if (unformat (i, "proto"))
10609 else if (unformat (i, "reverse"))
10614 clib_warning ("parse error '%U'", format_unformat_error, i);
10619 if (vrf_id_set == 0)
10621 errmsg ("missing vrf id");
10625 M (SET_IP_FLOW_HASH, mp);
10631 mp->reverse = reverse;
10632 mp->vrf_id = ntohl (vrf_id);
10633 mp->is_ipv6 = is_ipv6;
10641 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
10643 unformat_input_t *i = vam->input;
10644 vl_api_sw_interface_ip6_enable_disable_t *mp;
10646 u8 sw_if_index_set = 0;
10650 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10652 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10653 sw_if_index_set = 1;
10654 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10655 sw_if_index_set = 1;
10656 else if (unformat (i, "enable"))
10658 else if (unformat (i, "disable"))
10662 clib_warning ("parse error '%U'", format_unformat_error, i);
10667 if (sw_if_index_set == 0)
10669 errmsg ("missing interface name or sw_if_index");
10673 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
10675 mp->sw_if_index = ntohl (sw_if_index);
10676 mp->enable = enable;
10684 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
10686 unformat_input_t *i = vam->input;
10687 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
10689 u8 sw_if_index_set = 0;
10690 u8 v6_address_set = 0;
10691 ip6_address_t v6address;
10694 /* Parse args required to build the message */
10695 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10697 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10698 sw_if_index_set = 1;
10699 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10700 sw_if_index_set = 1;
10701 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10702 v6_address_set = 1;
10707 if (sw_if_index_set == 0)
10709 errmsg ("missing interface name or sw_if_index");
10712 if (!v6_address_set)
10714 errmsg ("no address set");
10718 /* Construct the API message */
10719 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
10721 mp->sw_if_index = ntohl (sw_if_index);
10722 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10727 /* Wait for a reply, return good/bad news */
10733 api_ip6nd_proxy_add_del (vat_main_t * vam)
10735 unformat_input_t *i = vam->input;
10736 vl_api_ip6nd_proxy_add_del_t *mp;
10737 u32 sw_if_index = ~0;
10738 u8 v6_address_set = 0;
10739 ip6_address_t v6address;
10743 /* Parse args required to build the message */
10744 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10746 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10748 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10750 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10751 v6_address_set = 1;
10752 if (unformat (i, "del"))
10756 clib_warning ("parse error '%U'", format_unformat_error, i);
10761 if (sw_if_index == ~0)
10763 errmsg ("missing interface name or sw_if_index");
10766 if (!v6_address_set)
10768 errmsg ("no address set");
10772 /* Construct the API message */
10773 M (IP6ND_PROXY_ADD_DEL, mp);
10775 mp->is_del = is_del;
10776 mp->sw_if_index = ntohl (sw_if_index);
10777 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10782 /* Wait for a reply, return good/bad news */
10788 api_ip6nd_proxy_dump (vat_main_t * vam)
10790 vl_api_ip6nd_proxy_dump_t *mp;
10791 vl_api_control_ping_t *mp_ping;
10794 M (IP6ND_PROXY_DUMP, mp);
10798 /* Use a control ping for synchronization */
10799 MPING (CONTROL_PING, mp_ping);
10806 static void vl_api_ip6nd_proxy_details_t_handler
10807 (vl_api_ip6nd_proxy_details_t * mp)
10809 vat_main_t *vam = &vat_main;
10811 print (vam->ofp, "host %U sw_if_index %d",
10812 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
10815 static void vl_api_ip6nd_proxy_details_t_handler_json
10816 (vl_api_ip6nd_proxy_details_t * mp)
10818 vat_main_t *vam = &vat_main;
10819 struct in6_addr ip6;
10820 vat_json_node_t *node = NULL;
10822 if (VAT_JSON_ARRAY != vam->json_tree.type)
10824 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10825 vat_json_init_array (&vam->json_tree);
10827 node = vat_json_array_add (&vam->json_tree);
10829 vat_json_init_object (node);
10830 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10832 clib_memcpy (&ip6, mp->address, sizeof (ip6));
10833 vat_json_object_add_ip6 (node, "host", ip6);
10837 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
10839 unformat_input_t *i = vam->input;
10840 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
10842 u8 sw_if_index_set = 0;
10843 u32 address_length = 0;
10844 u8 v6_address_set = 0;
10845 ip6_address_t v6address;
10846 u8 use_default = 0;
10847 u8 no_advertise = 0;
10849 u8 no_autoconfig = 0;
10852 u32 val_lifetime = 0;
10853 u32 pref_lifetime = 0;
10856 /* Parse args required to build the message */
10857 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10859 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10860 sw_if_index_set = 1;
10861 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10862 sw_if_index_set = 1;
10863 else if (unformat (i, "%U/%d",
10864 unformat_ip6_address, &v6address, &address_length))
10865 v6_address_set = 1;
10866 else if (unformat (i, "val_life %d", &val_lifetime))
10868 else if (unformat (i, "pref_life %d", &pref_lifetime))
10870 else if (unformat (i, "def"))
10872 else if (unformat (i, "noadv"))
10874 else if (unformat (i, "offl"))
10876 else if (unformat (i, "noauto"))
10878 else if (unformat (i, "nolink"))
10880 else if (unformat (i, "isno"))
10884 clib_warning ("parse error '%U'", format_unformat_error, i);
10889 if (sw_if_index_set == 0)
10891 errmsg ("missing interface name or sw_if_index");
10894 if (!v6_address_set)
10896 errmsg ("no address set");
10900 /* Construct the API message */
10901 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
10903 mp->sw_if_index = ntohl (sw_if_index);
10904 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10905 mp->address_length = address_length;
10906 mp->use_default = use_default;
10907 mp->no_advertise = no_advertise;
10908 mp->off_link = off_link;
10909 mp->no_autoconfig = no_autoconfig;
10910 mp->no_onlink = no_onlink;
10912 mp->val_lifetime = ntohl (val_lifetime);
10913 mp->pref_lifetime = ntohl (pref_lifetime);
10918 /* Wait for a reply, return good/bad news */
10924 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
10926 unformat_input_t *i = vam->input;
10927 vl_api_sw_interface_ip6nd_ra_config_t *mp;
10929 u8 sw_if_index_set = 0;
10934 u8 send_unicast = 0;
10937 u8 default_router = 0;
10938 u32 max_interval = 0;
10939 u32 min_interval = 0;
10941 u32 initial_count = 0;
10942 u32 initial_interval = 0;
10946 /* Parse args required to build the message */
10947 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10949 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10950 sw_if_index_set = 1;
10951 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10952 sw_if_index_set = 1;
10953 else if (unformat (i, "maxint %d", &max_interval))
10955 else if (unformat (i, "minint %d", &min_interval))
10957 else if (unformat (i, "life %d", &lifetime))
10959 else if (unformat (i, "count %d", &initial_count))
10961 else if (unformat (i, "interval %d", &initial_interval))
10963 else if (unformat (i, "suppress") || unformat (i, "surpress"))
10965 else if (unformat (i, "managed"))
10967 else if (unformat (i, "other"))
10969 else if (unformat (i, "ll"))
10971 else if (unformat (i, "send"))
10973 else if (unformat (i, "cease"))
10975 else if (unformat (i, "isno"))
10977 else if (unformat (i, "def"))
10978 default_router = 1;
10981 clib_warning ("parse error '%U'", format_unformat_error, i);
10986 if (sw_if_index_set == 0)
10988 errmsg ("missing interface name or sw_if_index");
10992 /* Construct the API message */
10993 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
10995 mp->sw_if_index = ntohl (sw_if_index);
10996 mp->max_interval = ntohl (max_interval);
10997 mp->min_interval = ntohl (min_interval);
10998 mp->lifetime = ntohl (lifetime);
10999 mp->initial_count = ntohl (initial_count);
11000 mp->initial_interval = ntohl (initial_interval);
11001 mp->suppress = suppress;
11002 mp->managed = managed;
11004 mp->ll_option = ll_option;
11005 mp->send_unicast = send_unicast;
11008 mp->default_router = default_router;
11013 /* Wait for a reply, return good/bad news */
11019 api_set_arp_neighbor_limit (vat_main_t * vam)
11021 unformat_input_t *i = vam->input;
11022 vl_api_set_arp_neighbor_limit_t *mp;
11028 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11030 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
11032 else if (unformat (i, "ipv6"))
11036 clib_warning ("parse error '%U'", format_unformat_error, i);
11041 if (limit_set == 0)
11043 errmsg ("missing limit value");
11047 M (SET_ARP_NEIGHBOR_LIMIT, mp);
11049 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
11050 mp->is_ipv6 = is_ipv6;
11058 api_l2_patch_add_del (vat_main_t * vam)
11060 unformat_input_t *i = vam->input;
11061 vl_api_l2_patch_add_del_t *mp;
11062 u32 rx_sw_if_index;
11063 u8 rx_sw_if_index_set = 0;
11064 u32 tx_sw_if_index;
11065 u8 tx_sw_if_index_set = 0;
11069 /* Parse args required to build the message */
11070 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11072 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
11073 rx_sw_if_index_set = 1;
11074 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
11075 tx_sw_if_index_set = 1;
11076 else if (unformat (i, "rx"))
11078 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11080 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
11082 rx_sw_if_index_set = 1;
11087 else if (unformat (i, "tx"))
11089 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11091 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
11093 tx_sw_if_index_set = 1;
11098 else if (unformat (i, "del"))
11104 if (rx_sw_if_index_set == 0)
11106 errmsg ("missing rx interface name or rx_sw_if_index");
11110 if (tx_sw_if_index_set == 0)
11112 errmsg ("missing tx interface name or tx_sw_if_index");
11116 M (L2_PATCH_ADD_DEL, mp);
11118 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
11119 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
11120 mp->is_add = is_add;
11128 u8 localsid_addr[16];
11137 api_sr_localsid_add_del (vat_main_t * vam)
11139 unformat_input_t *i = vam->input;
11140 vl_api_sr_localsid_add_del_t *mp;
11143 ip6_address_t localsid;
11147 u32 fib_table = ~(u32) 0;
11148 ip6_address_t nh_addr6;
11149 ip4_address_t nh_addr4;
11150 clib_memset (&nh_addr6, 0, sizeof (ip6_address_t));
11151 clib_memset (&nh_addr4, 0, sizeof (ip4_address_t));
11153 bool nexthop_set = 0;
11157 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11159 if (unformat (i, "del"))
11161 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
11162 else if (unformat (i, "next-hop %U", unformat_ip4_address, &nh_addr4))
11164 else if (unformat (i, "next-hop %U", unformat_ip6_address, &nh_addr6))
11166 else if (unformat (i, "behavior %u", &behavior));
11167 else if (unformat (i, "sw_if_index %u", &sw_if_index));
11168 else if (unformat (i, "fib-table %u", &fib_table));
11169 else if (unformat (i, "end.psp %u", &behavior));
11174 M (SR_LOCALSID_ADD_DEL, mp);
11176 clib_memcpy (mp->localsid.addr, &localsid, sizeof (mp->localsid));
11179 clib_memcpy (mp->nh_addr6, &nh_addr6, sizeof (mp->nh_addr6));
11180 clib_memcpy (mp->nh_addr4, &nh_addr4, sizeof (mp->nh_addr4));
11182 mp->behavior = behavior;
11183 mp->sw_if_index = ntohl (sw_if_index);
11184 mp->fib_table = ntohl (fib_table);
11185 mp->end_psp = end_psp;
11186 mp->is_del = is_del;
11194 api_ioam_enable (vat_main_t * vam)
11196 unformat_input_t *input = vam->input;
11197 vl_api_ioam_enable_t *mp;
11199 int has_trace_option = 0;
11200 int has_pot_option = 0;
11201 int has_seqno_option = 0;
11202 int has_analyse_option = 0;
11205 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11207 if (unformat (input, "trace"))
11208 has_trace_option = 1;
11209 else if (unformat (input, "pot"))
11210 has_pot_option = 1;
11211 else if (unformat (input, "seqno"))
11212 has_seqno_option = 1;
11213 else if (unformat (input, "analyse"))
11214 has_analyse_option = 1;
11218 M (IOAM_ENABLE, mp);
11219 mp->id = htons (id);
11220 mp->seqno = has_seqno_option;
11221 mp->analyse = has_analyse_option;
11222 mp->pot_enable = has_pot_option;
11223 mp->trace_enable = has_trace_option;
11232 api_ioam_disable (vat_main_t * vam)
11234 vl_api_ioam_disable_t *mp;
11237 M (IOAM_DISABLE, mp);
11243 #define foreach_tcp_proto_field \
11247 #define foreach_udp_proto_field \
11251 #define foreach_ip4_proto_field \
11263 u16 src_port, dst_port;
11266 #if VPP_API_TEST_BUILTIN == 0
11268 unformat_tcp_mask (unformat_input_t * input, va_list * args)
11270 u8 **maskp = va_arg (*args, u8 **);
11272 u8 found_something = 0;
11275 #define _(a) u8 a=0;
11276 foreach_tcp_proto_field;
11279 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11282 #define _(a) else if (unformat (input, #a)) a=1;
11283 foreach_tcp_proto_field
11289 #define _(a) found_something += a;
11290 foreach_tcp_proto_field;
11293 if (found_something == 0)
11296 vec_validate (mask, sizeof (*tcp) - 1);
11298 tcp = (tcp_header_t *) mask;
11300 #define _(a) if (a) clib_memset (&tcp->a, 0xff, sizeof (tcp->a));
11301 foreach_tcp_proto_field;
11309 unformat_udp_mask (unformat_input_t * input, va_list * args)
11311 u8 **maskp = va_arg (*args, u8 **);
11313 u8 found_something = 0;
11316 #define _(a) u8 a=0;
11317 foreach_udp_proto_field;
11320 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11323 #define _(a) else if (unformat (input, #a)) a=1;
11324 foreach_udp_proto_field
11330 #define _(a) found_something += a;
11331 foreach_udp_proto_field;
11334 if (found_something == 0)
11337 vec_validate (mask, sizeof (*udp) - 1);
11339 udp = (udp_header_t *) mask;
11341 #define _(a) if (a) clib_memset (&udp->a, 0xff, sizeof (udp->a));
11342 foreach_udp_proto_field;
11350 unformat_l4_mask (unformat_input_t * input, va_list * args)
11352 u8 **maskp = va_arg (*args, u8 **);
11353 u16 src_port = 0, dst_port = 0;
11354 tcpudp_header_t *tcpudp;
11356 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11358 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
11360 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
11362 else if (unformat (input, "src_port"))
11364 else if (unformat (input, "dst_port"))
11370 if (!src_port && !dst_port)
11374 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
11376 tcpudp = (tcpudp_header_t *) mask;
11377 tcpudp->src_port = src_port;
11378 tcpudp->dst_port = dst_port;
11386 unformat_ip4_mask (unformat_input_t * input, va_list * args)
11388 u8 **maskp = va_arg (*args, u8 **);
11390 u8 found_something = 0;
11393 #define _(a) u8 a=0;
11394 foreach_ip4_proto_field;
11400 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11402 if (unformat (input, "version"))
11404 else if (unformat (input, "hdr_length"))
11406 else if (unformat (input, "src"))
11408 else if (unformat (input, "dst"))
11410 else if (unformat (input, "proto"))
11413 #define _(a) else if (unformat (input, #a)) a=1;
11414 foreach_ip4_proto_field
11420 #define _(a) found_something += a;
11421 foreach_ip4_proto_field;
11424 if (found_something == 0)
11427 vec_validate (mask, sizeof (*ip) - 1);
11429 ip = (ip4_header_t *) mask;
11431 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
11432 foreach_ip4_proto_field;
11435 ip->ip_version_and_header_length = 0;
11438 ip->ip_version_and_header_length |= 0xF0;
11441 ip->ip_version_and_header_length |= 0x0F;
11447 #define foreach_ip6_proto_field \
11450 _(payload_length) \
11455 unformat_ip6_mask (unformat_input_t * input, va_list * args)
11457 u8 **maskp = va_arg (*args, u8 **);
11459 u8 found_something = 0;
11461 u32 ip_version_traffic_class_and_flow_label;
11463 #define _(a) u8 a=0;
11464 foreach_ip6_proto_field;
11467 u8 traffic_class = 0;
11470 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11472 if (unformat (input, "version"))
11474 else if (unformat (input, "traffic-class"))
11476 else if (unformat (input, "flow-label"))
11478 else if (unformat (input, "src"))
11480 else if (unformat (input, "dst"))
11482 else if (unformat (input, "proto"))
11485 #define _(a) else if (unformat (input, #a)) a=1;
11486 foreach_ip6_proto_field
11492 #define _(a) found_something += a;
11493 foreach_ip6_proto_field;
11496 if (found_something == 0)
11499 vec_validate (mask, sizeof (*ip) - 1);
11501 ip = (ip6_header_t *) mask;
11503 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
11504 foreach_ip6_proto_field;
11507 ip_version_traffic_class_and_flow_label = 0;
11510 ip_version_traffic_class_and_flow_label |= 0xF0000000;
11513 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
11516 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
11518 ip->ip_version_traffic_class_and_flow_label =
11519 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11526 unformat_l3_mask (unformat_input_t * input, va_list * args)
11528 u8 **maskp = va_arg (*args, u8 **);
11530 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11532 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
11534 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
11543 unformat_l2_mask (unformat_input_t * input, va_list * args)
11545 u8 **maskp = va_arg (*args, u8 **);
11552 u8 ignore_tag1 = 0;
11553 u8 ignore_tag2 = 0;
11560 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11562 if (unformat (input, "src"))
11564 else if (unformat (input, "dst"))
11566 else if (unformat (input, "proto"))
11568 else if (unformat (input, "tag1"))
11570 else if (unformat (input, "tag2"))
11572 else if (unformat (input, "ignore-tag1"))
11574 else if (unformat (input, "ignore-tag2"))
11576 else if (unformat (input, "cos1"))
11578 else if (unformat (input, "cos2"))
11580 else if (unformat (input, "dot1q"))
11582 else if (unformat (input, "dot1ad"))
11587 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
11588 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11591 if (tag1 || ignore_tag1 || cos1 || dot1q)
11593 if (tag2 || ignore_tag2 || cos2 || dot1ad)
11596 vec_validate (mask, len - 1);
11599 clib_memset (mask, 0xff, 6);
11602 clib_memset (mask + 6, 0xff, 6);
11604 if (tag2 || dot1ad)
11606 /* inner vlan tag */
11615 mask[21] = mask[20] = 0xff;
11636 mask[16] = mask[17] = 0xff;
11646 mask[12] = mask[13] = 0xff;
11653 unformat_classify_mask (unformat_input_t * input, va_list * args)
11655 u8 **maskp = va_arg (*args, u8 **);
11656 u32 *skipp = va_arg (*args, u32 *);
11657 u32 *matchp = va_arg (*args, u32 *);
11665 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11667 if (unformat (input, "hex %U", unformat_hex_string, &mask))
11669 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
11671 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
11673 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
11687 if (mask || l2 || l3 || l4)
11689 if (l2 || l3 || l4)
11691 /* "With a free Ethernet header in every package" */
11693 vec_validate (l2, 13);
11697 vec_append (mask, l3);
11702 vec_append (mask, l4);
11707 /* Scan forward looking for the first significant mask octet */
11708 for (i = 0; i < vec_len (mask); i++)
11712 /* compute (skip, match) params */
11713 *skipp = i / sizeof (u32x4);
11714 vec_delete (mask, *skipp * sizeof (u32x4), 0);
11716 /* Pad mask to an even multiple of the vector size */
11717 while (vec_len (mask) % sizeof (u32x4))
11718 vec_add1 (mask, 0);
11720 match = vec_len (mask) / sizeof (u32x4);
11722 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
11724 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
11725 if (*tmp || *(tmp + 1))
11730 clib_warning ("BUG: match 0");
11732 _vec_len (mask) = match * sizeof (u32x4);
11742 #endif /* VPP_API_TEST_BUILTIN */
11744 #define foreach_l2_next \
11746 _(ethernet, ETHERNET_INPUT) \
11747 _(ip4, IP4_INPUT) \
11751 unformat_l2_next_index (unformat_input_t * input, va_list * args)
11753 u32 *miss_next_indexp = va_arg (*args, u32 *);
11754 u32 next_index = 0;
11758 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
11762 if (unformat (input, "%d", &tmp))
11771 *miss_next_indexp = next_index;
11775 #define foreach_ip_next \
11778 _(rewrite, REWRITE)
11781 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
11783 u32 *miss_next_indexp = va_arg (*args, u32 *);
11784 u32 next_index = 0;
11788 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
11792 if (unformat (input, "%d", &tmp))
11801 *miss_next_indexp = next_index;
11805 #define foreach_acl_next \
11809 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
11811 u32 *miss_next_indexp = va_arg (*args, u32 *);
11812 u32 next_index = 0;
11816 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
11820 if (unformat (input, "permit"))
11825 else if (unformat (input, "%d", &tmp))
11834 *miss_next_indexp = next_index;
11839 unformat_policer_precolor (unformat_input_t * input, va_list * args)
11841 u32 *r = va_arg (*args, u32 *);
11843 if (unformat (input, "conform-color"))
11844 *r = POLICE_CONFORM;
11845 else if (unformat (input, "exceed-color"))
11846 *r = POLICE_EXCEED;
11854 api_classify_add_del_table (vat_main_t * vam)
11856 unformat_input_t *i = vam->input;
11857 vl_api_classify_add_del_table_t *mp;
11864 u32 table_index = ~0;
11865 u32 next_table_index = ~0;
11866 u32 miss_next_index = ~0;
11867 u32 memory_size = 32 << 20;
11869 u32 current_data_flag = 0;
11870 int current_data_offset = 0;
11873 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11875 if (unformat (i, "del"))
11877 else if (unformat (i, "del-chain"))
11882 else if (unformat (i, "buckets %d", &nbuckets))
11884 else if (unformat (i, "memory_size %d", &memory_size))
11886 else if (unformat (i, "skip %d", &skip))
11888 else if (unformat (i, "match %d", &match))
11890 else if (unformat (i, "table %d", &table_index))
11892 else if (unformat (i, "mask %U", unformat_classify_mask,
11893 &mask, &skip, &match))
11895 else if (unformat (i, "next-table %d", &next_table_index))
11897 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
11900 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
11903 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
11906 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
11908 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
11914 if (is_add && mask == 0)
11916 errmsg ("Mask required");
11920 if (is_add && skip == ~0)
11922 errmsg ("skip count required");
11926 if (is_add && match == ~0)
11928 errmsg ("match count required");
11932 if (!is_add && table_index == ~0)
11934 errmsg ("table index required for delete");
11938 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
11940 mp->is_add = is_add;
11941 mp->del_chain = del_chain;
11942 mp->table_index = ntohl (table_index);
11943 mp->nbuckets = ntohl (nbuckets);
11944 mp->memory_size = ntohl (memory_size);
11945 mp->skip_n_vectors = ntohl (skip);
11946 mp->match_n_vectors = ntohl (match);
11947 mp->next_table_index = ntohl (next_table_index);
11948 mp->miss_next_index = ntohl (miss_next_index);
11949 mp->current_data_flag = ntohl (current_data_flag);
11950 mp->current_data_offset = ntohl (current_data_offset);
11951 mp->mask_len = ntohl (vec_len (mask));
11952 clib_memcpy (mp->mask, mask, vec_len (mask));
11961 #if VPP_API_TEST_BUILTIN == 0
11963 unformat_l4_match (unformat_input_t * input, va_list * args)
11965 u8 **matchp = va_arg (*args, u8 **);
11967 u8 *proto_header = 0;
11973 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11975 if (unformat (input, "src_port %d", &src_port))
11977 else if (unformat (input, "dst_port %d", &dst_port))
11983 h.src_port = clib_host_to_net_u16 (src_port);
11984 h.dst_port = clib_host_to_net_u16 (dst_port);
11985 vec_validate (proto_header, sizeof (h) - 1);
11986 memcpy (proto_header, &h, sizeof (h));
11988 *matchp = proto_header;
11994 unformat_ip4_match (unformat_input_t * input, va_list * args)
11996 u8 **matchp = va_arg (*args, u8 **);
12001 int hdr_length = 0;
12002 u32 hdr_length_val;
12003 int src = 0, dst = 0;
12004 ip4_address_t src_val, dst_val;
12011 int fragment_id = 0;
12012 u32 fragment_id_val;
12018 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12020 if (unformat (input, "version %d", &version_val))
12022 else if (unformat (input, "hdr_length %d", &hdr_length_val))
12024 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
12026 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
12028 else if (unformat (input, "proto %d", &proto_val))
12030 else if (unformat (input, "tos %d", &tos_val))
12032 else if (unformat (input, "length %d", &length_val))
12034 else if (unformat (input, "fragment_id %d", &fragment_id_val))
12036 else if (unformat (input, "ttl %d", &ttl_val))
12038 else if (unformat (input, "checksum %d", &checksum_val))
12044 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
12045 + ttl + checksum == 0)
12049 * Aligned because we use the real comparison functions
12051 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
12053 ip = (ip4_header_t *) match;
12055 /* These are realistically matched in practice */
12057 ip->src_address.as_u32 = src_val.as_u32;
12060 ip->dst_address.as_u32 = dst_val.as_u32;
12063 ip->protocol = proto_val;
12066 /* These are not, but they're included for completeness */
12068 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
12071 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
12077 ip->length = clib_host_to_net_u16 (length_val);
12083 ip->checksum = clib_host_to_net_u16 (checksum_val);
12090 unformat_ip6_match (unformat_input_t * input, va_list * args)
12092 u8 **matchp = va_arg (*args, u8 **);
12097 u8 traffic_class = 0;
12098 u32 traffic_class_val = 0;
12101 int src = 0, dst = 0;
12102 ip6_address_t src_val, dst_val;
12105 int payload_length = 0;
12106 u32 payload_length_val;
12109 u32 ip_version_traffic_class_and_flow_label;
12111 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12113 if (unformat (input, "version %d", &version_val))
12115 else if (unformat (input, "traffic_class %d", &traffic_class_val))
12117 else if (unformat (input, "flow_label %d", &flow_label_val))
12119 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
12121 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
12123 else if (unformat (input, "proto %d", &proto_val))
12125 else if (unformat (input, "payload_length %d", &payload_length_val))
12126 payload_length = 1;
12127 else if (unformat (input, "hop_limit %d", &hop_limit_val))
12133 if (version + traffic_class + flow_label + src + dst + proto +
12134 payload_length + hop_limit == 0)
12138 * Aligned because we use the real comparison functions
12140 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
12142 ip = (ip6_header_t *) match;
12145 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
12148 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
12151 ip->protocol = proto_val;
12153 ip_version_traffic_class_and_flow_label = 0;
12156 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
12159 ip_version_traffic_class_and_flow_label |=
12160 (traffic_class_val & 0xFF) << 20;
12163 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
12165 ip->ip_version_traffic_class_and_flow_label =
12166 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
12168 if (payload_length)
12169 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
12172 ip->hop_limit = hop_limit_val;
12179 unformat_l3_match (unformat_input_t * input, va_list * args)
12181 u8 **matchp = va_arg (*args, u8 **);
12183 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12185 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
12187 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
12196 unformat_vlan_tag (unformat_input_t * input, va_list * args)
12198 u8 *tagp = va_arg (*args, u8 *);
12201 if (unformat (input, "%d", &tag))
12203 tagp[0] = (tag >> 8) & 0x0F;
12204 tagp[1] = tag & 0xFF;
12212 unformat_l2_match (unformat_input_t * input, va_list * args)
12214 u8 **matchp = va_arg (*args, u8 **);
12227 u8 ignore_tag1 = 0;
12228 u8 ignore_tag2 = 0;
12234 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12236 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
12239 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
12241 else if (unformat (input, "proto %U",
12242 unformat_ethernet_type_host_byte_order, &proto_val))
12244 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
12246 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
12248 else if (unformat (input, "ignore-tag1"))
12250 else if (unformat (input, "ignore-tag2"))
12252 else if (unformat (input, "cos1 %d", &cos1_val))
12254 else if (unformat (input, "cos2 %d", &cos2_val))
12259 if ((src + dst + proto + tag1 + tag2 +
12260 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
12263 if (tag1 || ignore_tag1 || cos1)
12265 if (tag2 || ignore_tag2 || cos2)
12268 vec_validate_aligned (match, len - 1, sizeof (u32x4));
12271 clib_memcpy (match, dst_val, 6);
12274 clib_memcpy (match + 6, src_val, 6);
12278 /* inner vlan tag */
12279 match[19] = tag2_val[1];
12280 match[18] = tag2_val[0];
12282 match[18] |= (cos2_val & 0x7) << 5;
12285 match[21] = proto_val & 0xff;
12286 match[20] = proto_val >> 8;
12290 match[15] = tag1_val[1];
12291 match[14] = tag1_val[0];
12294 match[14] |= (cos1_val & 0x7) << 5;
12300 match[15] = tag1_val[1];
12301 match[14] = tag1_val[0];
12304 match[17] = proto_val & 0xff;
12305 match[16] = proto_val >> 8;
12308 match[14] |= (cos1_val & 0x7) << 5;
12314 match[18] |= (cos2_val & 0x7) << 5;
12316 match[14] |= (cos1_val & 0x7) << 5;
12319 match[13] = proto_val & 0xff;
12320 match[12] = proto_val >> 8;
12328 unformat_qos_source (unformat_input_t * input, va_list * args)
12330 int *qs = va_arg (*args, int *);
12332 if (unformat (input, "ip"))
12333 *qs = QOS_SOURCE_IP;
12334 else if (unformat (input, "mpls"))
12335 *qs = QOS_SOURCE_MPLS;
12336 else if (unformat (input, "ext"))
12337 *qs = QOS_SOURCE_EXT;
12338 else if (unformat (input, "vlan"))
12339 *qs = QOS_SOURCE_VLAN;
12348 api_unformat_classify_match (unformat_input_t * input, va_list * args)
12350 u8 **matchp = va_arg (*args, u8 **);
12351 u32 skip_n_vectors = va_arg (*args, u32);
12352 u32 match_n_vectors = va_arg (*args, u32);
12359 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12361 if (unformat (input, "hex %U", unformat_hex_string, &match))
12363 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
12365 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
12367 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
12381 if (match || l2 || l3 || l4)
12383 if (l2 || l3 || l4)
12385 /* "Win a free Ethernet header in every packet" */
12387 vec_validate_aligned (l2, 13, sizeof (u32x4));
12391 vec_append_aligned (match, l3, sizeof (u32x4));
12396 vec_append_aligned (match, l4, sizeof (u32x4));
12401 /* Make sure the vector is big enough even if key is all 0's */
12402 vec_validate_aligned
12403 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
12406 /* Set size, include skipped vectors */
12407 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
12418 api_classify_add_del_session (vat_main_t * vam)
12420 unformat_input_t *i = vam->input;
12421 vl_api_classify_add_del_session_t *mp;
12423 u32 table_index = ~0;
12424 u32 hit_next_index = ~0;
12425 u32 opaque_index = ~0;
12428 u32 skip_n_vectors = 0;
12429 u32 match_n_vectors = 0;
12435 * Warning: you have to supply skip_n and match_n
12436 * because the API client cant simply look at the classify
12440 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12442 if (unformat (i, "del"))
12444 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
12447 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
12450 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
12453 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
12455 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
12457 else if (unformat (i, "opaque-index %d", &opaque_index))
12459 else if (unformat (i, "skip_n %d", &skip_n_vectors))
12461 else if (unformat (i, "match_n %d", &match_n_vectors))
12463 else if (unformat (i, "match %U", api_unformat_classify_match,
12464 &match, skip_n_vectors, match_n_vectors))
12466 else if (unformat (i, "advance %d", &advance))
12468 else if (unformat (i, "table-index %d", &table_index))
12470 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
12472 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
12474 else if (unformat (i, "action %d", &action))
12476 else if (unformat (i, "metadata %d", &metadata))
12482 if (table_index == ~0)
12484 errmsg ("Table index required");
12488 if (is_add && match == 0)
12490 errmsg ("Match value required");
12494 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
12496 mp->is_add = is_add;
12497 mp->table_index = ntohl (table_index);
12498 mp->hit_next_index = ntohl (hit_next_index);
12499 mp->opaque_index = ntohl (opaque_index);
12500 mp->advance = ntohl (advance);
12501 mp->action = action;
12502 mp->metadata = ntohl (metadata);
12503 mp->match_len = ntohl (vec_len (match));
12504 clib_memcpy (mp->match, match, vec_len (match));
12513 api_classify_set_interface_ip_table (vat_main_t * vam)
12515 unformat_input_t *i = vam->input;
12516 vl_api_classify_set_interface_ip_table_t *mp;
12518 int sw_if_index_set;
12519 u32 table_index = ~0;
12523 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12525 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12526 sw_if_index_set = 1;
12527 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12528 sw_if_index_set = 1;
12529 else if (unformat (i, "table %d", &table_index))
12533 clib_warning ("parse error '%U'", format_unformat_error, i);
12538 if (sw_if_index_set == 0)
12540 errmsg ("missing interface name or sw_if_index");
12545 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
12547 mp->sw_if_index = ntohl (sw_if_index);
12548 mp->table_index = ntohl (table_index);
12549 mp->is_ipv6 = is_ipv6;
12557 api_classify_set_interface_l2_tables (vat_main_t * vam)
12559 unformat_input_t *i = vam->input;
12560 vl_api_classify_set_interface_l2_tables_t *mp;
12562 int sw_if_index_set;
12563 u32 ip4_table_index = ~0;
12564 u32 ip6_table_index = ~0;
12565 u32 other_table_index = ~0;
12569 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12571 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12572 sw_if_index_set = 1;
12573 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12574 sw_if_index_set = 1;
12575 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12577 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12579 else if (unformat (i, "other-table %d", &other_table_index))
12581 else if (unformat (i, "is-input %d", &is_input))
12585 clib_warning ("parse error '%U'", format_unformat_error, i);
12590 if (sw_if_index_set == 0)
12592 errmsg ("missing interface name or sw_if_index");
12597 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
12599 mp->sw_if_index = ntohl (sw_if_index);
12600 mp->ip4_table_index = ntohl (ip4_table_index);
12601 mp->ip6_table_index = ntohl (ip6_table_index);
12602 mp->other_table_index = ntohl (other_table_index);
12603 mp->is_input = (u8) is_input;
12611 api_set_ipfix_exporter (vat_main_t * vam)
12613 unformat_input_t *i = vam->input;
12614 vl_api_set_ipfix_exporter_t *mp;
12615 ip4_address_t collector_address;
12616 u8 collector_address_set = 0;
12617 u32 collector_port = ~0;
12618 ip4_address_t src_address;
12619 u8 src_address_set = 0;
12622 u32 template_interval = ~0;
12623 u8 udp_checksum = 0;
12626 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12628 if (unformat (i, "collector_address %U", unformat_ip4_address,
12629 &collector_address))
12630 collector_address_set = 1;
12631 else if (unformat (i, "collector_port %d", &collector_port))
12633 else if (unformat (i, "src_address %U", unformat_ip4_address,
12635 src_address_set = 1;
12636 else if (unformat (i, "vrf_id %d", &vrf_id))
12638 else if (unformat (i, "path_mtu %d", &path_mtu))
12640 else if (unformat (i, "template_interval %d", &template_interval))
12642 else if (unformat (i, "udp_checksum"))
12648 if (collector_address_set == 0)
12650 errmsg ("collector_address required");
12654 if (src_address_set == 0)
12656 errmsg ("src_address required");
12660 M (SET_IPFIX_EXPORTER, mp);
12662 memcpy (mp->collector_address, collector_address.data,
12663 sizeof (collector_address.data));
12664 mp->collector_port = htons ((u16) collector_port);
12665 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
12666 mp->vrf_id = htonl (vrf_id);
12667 mp->path_mtu = htonl (path_mtu);
12668 mp->template_interval = htonl (template_interval);
12669 mp->udp_checksum = udp_checksum;
12677 api_set_ipfix_classify_stream (vat_main_t * vam)
12679 unformat_input_t *i = vam->input;
12680 vl_api_set_ipfix_classify_stream_t *mp;
12682 u32 src_port = UDP_DST_PORT_ipfix;
12685 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12687 if (unformat (i, "domain %d", &domain_id))
12689 else if (unformat (i, "src_port %d", &src_port))
12693 errmsg ("unknown input `%U'", format_unformat_error, i);
12698 M (SET_IPFIX_CLASSIFY_STREAM, mp);
12700 mp->domain_id = htonl (domain_id);
12701 mp->src_port = htons ((u16) src_port);
12709 api_ipfix_classify_table_add_del (vat_main_t * vam)
12711 unformat_input_t *i = vam->input;
12712 vl_api_ipfix_classify_table_add_del_t *mp;
12714 u32 classify_table_index = ~0;
12716 u8 transport_protocol = 255;
12719 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12721 if (unformat (i, "add"))
12723 else if (unformat (i, "del"))
12725 else if (unformat (i, "table %d", &classify_table_index))
12727 else if (unformat (i, "ip4"))
12729 else if (unformat (i, "ip6"))
12731 else if (unformat (i, "tcp"))
12732 transport_protocol = 6;
12733 else if (unformat (i, "udp"))
12734 transport_protocol = 17;
12737 errmsg ("unknown input `%U'", format_unformat_error, i);
12744 errmsg ("expecting: add|del");
12747 if (classify_table_index == ~0)
12749 errmsg ("classifier table not specified");
12752 if (ip_version == 0)
12754 errmsg ("IP version not specified");
12758 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
12760 mp->is_add = is_add;
12761 mp->table_id = htonl (classify_table_index);
12762 mp->ip_version = ip_version;
12763 mp->transport_protocol = transport_protocol;
12771 api_get_node_index (vat_main_t * vam)
12773 unformat_input_t *i = vam->input;
12774 vl_api_get_node_index_t *mp;
12778 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12780 if (unformat (i, "node %s", &name))
12787 errmsg ("node name required");
12790 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12792 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12796 M (GET_NODE_INDEX, mp);
12797 clib_memcpy (mp->node_name, name, vec_len (name));
12806 api_get_next_index (vat_main_t * vam)
12808 unformat_input_t *i = vam->input;
12809 vl_api_get_next_index_t *mp;
12810 u8 *node_name = 0, *next_node_name = 0;
12813 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12815 if (unformat (i, "node-name %s", &node_name))
12817 else if (unformat (i, "next-node-name %s", &next_node_name))
12821 if (node_name == 0)
12823 errmsg ("node name required");
12826 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
12828 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12832 if (next_node_name == 0)
12834 errmsg ("next node name required");
12837 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
12839 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
12843 M (GET_NEXT_INDEX, mp);
12844 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
12845 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
12846 vec_free (node_name);
12847 vec_free (next_node_name);
12855 api_add_node_next (vat_main_t * vam)
12857 unformat_input_t *i = vam->input;
12858 vl_api_add_node_next_t *mp;
12863 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12865 if (unformat (i, "node %s", &name))
12867 else if (unformat (i, "next %s", &next))
12874 errmsg ("node name required");
12877 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12879 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12884 errmsg ("next node required");
12887 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
12889 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
12893 M (ADD_NODE_NEXT, mp);
12894 clib_memcpy (mp->node_name, name, vec_len (name));
12895 clib_memcpy (mp->next_name, next, vec_len (next));
12905 api_l2tpv3_create_tunnel (vat_main_t * vam)
12907 unformat_input_t *i = vam->input;
12908 ip6_address_t client_address, our_address;
12909 int client_address_set = 0;
12910 int our_address_set = 0;
12911 u32 local_session_id = 0;
12912 u32 remote_session_id = 0;
12913 u64 local_cookie = 0;
12914 u64 remote_cookie = 0;
12915 u8 l2_sublayer_present = 0;
12916 vl_api_l2tpv3_create_tunnel_t *mp;
12919 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12921 if (unformat (i, "client_address %U", unformat_ip6_address,
12923 client_address_set = 1;
12924 else if (unformat (i, "our_address %U", unformat_ip6_address,
12926 our_address_set = 1;
12927 else if (unformat (i, "local_session_id %d", &local_session_id))
12929 else if (unformat (i, "remote_session_id %d", &remote_session_id))
12931 else if (unformat (i, "local_cookie %lld", &local_cookie))
12933 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
12935 else if (unformat (i, "l2-sublayer-present"))
12936 l2_sublayer_present = 1;
12941 if (client_address_set == 0)
12943 errmsg ("client_address required");
12947 if (our_address_set == 0)
12949 errmsg ("our_address required");
12953 M (L2TPV3_CREATE_TUNNEL, mp);
12955 clib_memcpy (mp->client_address, client_address.as_u8,
12956 sizeof (mp->client_address));
12958 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
12960 mp->local_session_id = ntohl (local_session_id);
12961 mp->remote_session_id = ntohl (remote_session_id);
12962 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
12963 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
12964 mp->l2_sublayer_present = l2_sublayer_present;
12973 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
12975 unformat_input_t *i = vam->input;
12977 u8 sw_if_index_set = 0;
12978 u64 new_local_cookie = 0;
12979 u64 new_remote_cookie = 0;
12980 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
12983 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12985 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12986 sw_if_index_set = 1;
12987 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12988 sw_if_index_set = 1;
12989 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
12991 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
12997 if (sw_if_index_set == 0)
12999 errmsg ("missing interface name or sw_if_index");
13003 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
13005 mp->sw_if_index = ntohl (sw_if_index);
13006 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
13007 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
13015 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
13017 unformat_input_t *i = vam->input;
13018 vl_api_l2tpv3_interface_enable_disable_t *mp;
13020 u8 sw_if_index_set = 0;
13021 u8 enable_disable = 1;
13024 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13026 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13027 sw_if_index_set = 1;
13028 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13029 sw_if_index_set = 1;
13030 else if (unformat (i, "enable"))
13031 enable_disable = 1;
13032 else if (unformat (i, "disable"))
13033 enable_disable = 0;
13038 if (sw_if_index_set == 0)
13040 errmsg ("missing interface name or sw_if_index");
13044 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
13046 mp->sw_if_index = ntohl (sw_if_index);
13047 mp->enable_disable = enable_disable;
13055 api_l2tpv3_set_lookup_key (vat_main_t * vam)
13057 unformat_input_t *i = vam->input;
13058 vl_api_l2tpv3_set_lookup_key_t *mp;
13062 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13064 if (unformat (i, "lookup_v6_src"))
13065 key = L2T_LOOKUP_SRC_ADDRESS;
13066 else if (unformat (i, "lookup_v6_dst"))
13067 key = L2T_LOOKUP_DST_ADDRESS;
13068 else if (unformat (i, "lookup_session_id"))
13069 key = L2T_LOOKUP_SESSION_ID;
13074 if (key == (u8) ~ 0)
13076 errmsg ("l2tp session lookup key unset");
13080 M (L2TPV3_SET_LOOKUP_KEY, mp);
13089 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
13090 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
13092 vat_main_t *vam = &vat_main;
13094 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
13095 format_ip6_address, mp->our_address,
13096 format_ip6_address, mp->client_address,
13097 clib_net_to_host_u32 (mp->sw_if_index));
13100 " local cookies %016llx %016llx remote cookie %016llx",
13101 clib_net_to_host_u64 (mp->local_cookie[0]),
13102 clib_net_to_host_u64 (mp->local_cookie[1]),
13103 clib_net_to_host_u64 (mp->remote_cookie));
13105 print (vam->ofp, " local session-id %d remote session-id %d",
13106 clib_net_to_host_u32 (mp->local_session_id),
13107 clib_net_to_host_u32 (mp->remote_session_id));
13109 print (vam->ofp, " l2 specific sublayer %s\n",
13110 mp->l2_sublayer_present ? "preset" : "absent");
13114 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
13115 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
13117 vat_main_t *vam = &vat_main;
13118 vat_json_node_t *node = NULL;
13119 struct in6_addr addr;
13121 if (VAT_JSON_ARRAY != vam->json_tree.type)
13123 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13124 vat_json_init_array (&vam->json_tree);
13126 node = vat_json_array_add (&vam->json_tree);
13128 vat_json_init_object (node);
13130 clib_memcpy (&addr, mp->our_address, sizeof (addr));
13131 vat_json_object_add_ip6 (node, "our_address", addr);
13132 clib_memcpy (&addr, mp->client_address, sizeof (addr));
13133 vat_json_object_add_ip6 (node, "client_address", addr);
13135 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
13136 vat_json_init_array (lc);
13137 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
13138 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
13139 vat_json_object_add_uint (node, "remote_cookie",
13140 clib_net_to_host_u64 (mp->remote_cookie));
13142 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
13143 vat_json_object_add_uint (node, "local_session_id",
13144 clib_net_to_host_u32 (mp->local_session_id));
13145 vat_json_object_add_uint (node, "remote_session_id",
13146 clib_net_to_host_u32 (mp->remote_session_id));
13147 vat_json_object_add_string_copy (node, "l2_sublayer",
13148 mp->l2_sublayer_present ? (u8 *) "present"
13149 : (u8 *) "absent");
13153 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
13155 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
13156 vl_api_control_ping_t *mp_ping;
13159 /* Get list of l2tpv3-tunnel interfaces */
13160 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
13163 /* Use a control ping for synchronization */
13164 MPING (CONTROL_PING, mp_ping);
13172 static void vl_api_sw_interface_tap_details_t_handler
13173 (vl_api_sw_interface_tap_details_t * mp)
13175 vat_main_t *vam = &vat_main;
13177 print (vam->ofp, "%-16s %d",
13178 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
13181 static void vl_api_sw_interface_tap_details_t_handler_json
13182 (vl_api_sw_interface_tap_details_t * mp)
13184 vat_main_t *vam = &vat_main;
13185 vat_json_node_t *node = NULL;
13187 if (VAT_JSON_ARRAY != vam->json_tree.type)
13189 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13190 vat_json_init_array (&vam->json_tree);
13192 node = vat_json_array_add (&vam->json_tree);
13194 vat_json_init_object (node);
13195 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13196 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
13200 api_sw_interface_tap_dump (vat_main_t * vam)
13202 vl_api_sw_interface_tap_dump_t *mp;
13203 vl_api_control_ping_t *mp_ping;
13206 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
13207 /* Get list of tap interfaces */
13208 M (SW_INTERFACE_TAP_DUMP, mp);
13211 /* Use a control ping for synchronization */
13212 MPING (CONTROL_PING, mp_ping);
13219 static void vl_api_sw_interface_tap_v2_details_t_handler
13220 (vl_api_sw_interface_tap_v2_details_t * mp)
13222 vat_main_t *vam = &vat_main;
13224 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
13225 mp->host_ip4_prefix_len);
13226 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
13227 mp->host_ip6_prefix_len);
13230 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s",
13231 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
13232 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
13233 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
13234 mp->host_bridge, ip4, ip6);
13240 static void vl_api_sw_interface_tap_v2_details_t_handler_json
13241 (vl_api_sw_interface_tap_v2_details_t * mp)
13243 vat_main_t *vam = &vat_main;
13244 vat_json_node_t *node = NULL;
13246 if (VAT_JSON_ARRAY != vam->json_tree.type)
13248 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13249 vat_json_init_array (&vam->json_tree);
13251 node = vat_json_array_add (&vam->json_tree);
13253 vat_json_init_object (node);
13254 vat_json_object_add_uint (node, "id", ntohl (mp->id));
13255 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13256 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
13257 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
13258 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
13259 vat_json_object_add_string_copy (node, "host_mac_addr",
13260 format (0, "%U", format_ethernet_address,
13261 &mp->host_mac_addr));
13262 vat_json_object_add_string_copy (node, "host_namespace",
13263 mp->host_namespace);
13264 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
13265 vat_json_object_add_string_copy (node, "host_ip4_addr",
13266 format (0, "%U/%d", format_ip4_address,
13268 mp->host_ip4_prefix_len));
13269 vat_json_object_add_string_copy (node, "host_ip6_addr",
13270 format (0, "%U/%d", format_ip6_address,
13272 mp->host_ip6_prefix_len));
13277 api_sw_interface_tap_v2_dump (vat_main_t * vam)
13279 vl_api_sw_interface_tap_v2_dump_t *mp;
13280 vl_api_control_ping_t *mp_ping;
13284 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
13285 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
13286 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
13289 /* Get list of tap interfaces */
13290 M (SW_INTERFACE_TAP_V2_DUMP, mp);
13293 /* Use a control ping for synchronization */
13294 MPING (CONTROL_PING, mp_ping);
13302 api_vxlan_offload_rx (vat_main_t * vam)
13304 unformat_input_t *line_input = vam->input;
13305 vl_api_vxlan_offload_rx_t *mp;
13306 u32 hw_if_index = ~0, rx_if_index = ~0;
13310 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13312 if (unformat (line_input, "del"))
13314 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
13317 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
13319 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
13322 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
13326 errmsg ("parse error '%U'", format_unformat_error, line_input);
13331 if (hw_if_index == ~0)
13333 errmsg ("no hw interface");
13337 if (rx_if_index == ~0)
13339 errmsg ("no rx tunnel");
13343 M (VXLAN_OFFLOAD_RX, mp);
13345 mp->hw_if_index = ntohl (hw_if_index);
13346 mp->sw_if_index = ntohl (rx_if_index);
13347 mp->enable = is_add;
13354 static uword unformat_vxlan_decap_next
13355 (unformat_input_t * input, va_list * args)
13357 u32 *result = va_arg (*args, u32 *);
13360 if (unformat (input, "l2"))
13361 *result = VXLAN_INPUT_NEXT_L2_INPUT;
13362 else if (unformat (input, "%d", &tmp))
13370 api_vxlan_add_del_tunnel (vat_main_t * vam)
13372 unformat_input_t *line_input = vam->input;
13373 vl_api_vxlan_add_del_tunnel_t *mp;
13374 ip46_address_t src, dst;
13376 u8 ipv4_set = 0, ipv6_set = 0;
13381 u32 mcast_sw_if_index = ~0;
13382 u32 encap_vrf_id = 0;
13383 u32 decap_next_index = ~0;
13387 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13388 clib_memset (&src, 0, sizeof src);
13389 clib_memset (&dst, 0, sizeof dst);
13391 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13393 if (unformat (line_input, "del"))
13395 else if (unformat (line_input, "instance %d", &instance))
13398 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13404 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13410 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13416 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13421 else if (unformat (line_input, "group %U %U",
13422 unformat_ip4_address, &dst.ip4,
13423 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13425 grp_set = dst_set = 1;
13428 else if (unformat (line_input, "group %U",
13429 unformat_ip4_address, &dst.ip4))
13431 grp_set = dst_set = 1;
13434 else if (unformat (line_input, "group %U %U",
13435 unformat_ip6_address, &dst.ip6,
13436 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13438 grp_set = dst_set = 1;
13441 else if (unformat (line_input, "group %U",
13442 unformat_ip6_address, &dst.ip6))
13444 grp_set = dst_set = 1;
13448 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13450 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13452 else if (unformat (line_input, "decap-next %U",
13453 unformat_vxlan_decap_next, &decap_next_index))
13455 else if (unformat (line_input, "vni %d", &vni))
13459 errmsg ("parse error '%U'", format_unformat_error, line_input);
13466 errmsg ("tunnel src address not specified");
13471 errmsg ("tunnel dst address not specified");
13475 if (grp_set && !ip46_address_is_multicast (&dst))
13477 errmsg ("tunnel group address not multicast");
13480 if (grp_set && mcast_sw_if_index == ~0)
13482 errmsg ("tunnel nonexistent multicast device");
13485 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13487 errmsg ("tunnel dst address must be unicast");
13492 if (ipv4_set && ipv6_set)
13494 errmsg ("both IPv4 and IPv6 addresses specified");
13498 if ((vni == 0) || (vni >> 24))
13500 errmsg ("vni not specified or out of range");
13504 M (VXLAN_ADD_DEL_TUNNEL, mp);
13508 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
13509 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
13513 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
13514 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
13517 mp->instance = htonl (instance);
13518 mp->encap_vrf_id = ntohl (encap_vrf_id);
13519 mp->decap_next_index = ntohl (decap_next_index);
13520 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13521 mp->vni = ntohl (vni);
13522 mp->is_add = is_add;
13523 mp->is_ipv6 = ipv6_set;
13530 static void vl_api_vxlan_tunnel_details_t_handler
13531 (vl_api_vxlan_tunnel_details_t * mp)
13533 vat_main_t *vam = &vat_main;
13534 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13535 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13537 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
13538 ntohl (mp->sw_if_index),
13539 ntohl (mp->instance),
13540 format_ip46_address, &src, IP46_TYPE_ANY,
13541 format_ip46_address, &dst, IP46_TYPE_ANY,
13542 ntohl (mp->encap_vrf_id),
13543 ntohl (mp->decap_next_index), ntohl (mp->vni),
13544 ntohl (mp->mcast_sw_if_index));
13547 static void vl_api_vxlan_tunnel_details_t_handler_json
13548 (vl_api_vxlan_tunnel_details_t * mp)
13550 vat_main_t *vam = &vat_main;
13551 vat_json_node_t *node = NULL;
13553 if (VAT_JSON_ARRAY != vam->json_tree.type)
13555 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13556 vat_json_init_array (&vam->json_tree);
13558 node = vat_json_array_add (&vam->json_tree);
13560 vat_json_init_object (node);
13561 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13563 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13567 struct in6_addr ip6;
13569 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13570 vat_json_object_add_ip6 (node, "src_address", ip6);
13571 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13572 vat_json_object_add_ip6 (node, "dst_address", ip6);
13576 struct in_addr ip4;
13578 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13579 vat_json_object_add_ip4 (node, "src_address", ip4);
13580 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13581 vat_json_object_add_ip4 (node, "dst_address", ip4);
13583 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13584 vat_json_object_add_uint (node, "decap_next_index",
13585 ntohl (mp->decap_next_index));
13586 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13587 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13588 vat_json_object_add_uint (node, "mcast_sw_if_index",
13589 ntohl (mp->mcast_sw_if_index));
13593 api_vxlan_tunnel_dump (vat_main_t * vam)
13595 unformat_input_t *i = vam->input;
13596 vl_api_vxlan_tunnel_dump_t *mp;
13597 vl_api_control_ping_t *mp_ping;
13599 u8 sw_if_index_set = 0;
13602 /* Parse args required to build the message */
13603 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13605 if (unformat (i, "sw_if_index %d", &sw_if_index))
13606 sw_if_index_set = 1;
13611 if (sw_if_index_set == 0)
13616 if (!vam->json_output)
13618 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
13619 "sw_if_index", "instance", "src_address", "dst_address",
13620 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13623 /* Get list of vxlan-tunnel interfaces */
13624 M (VXLAN_TUNNEL_DUMP, mp);
13626 mp->sw_if_index = htonl (sw_if_index);
13630 /* Use a control ping for synchronization */
13631 MPING (CONTROL_PING, mp_ping);
13638 static uword unformat_geneve_decap_next
13639 (unformat_input_t * input, va_list * args)
13641 u32 *result = va_arg (*args, u32 *);
13644 if (unformat (input, "l2"))
13645 *result = GENEVE_INPUT_NEXT_L2_INPUT;
13646 else if (unformat (input, "%d", &tmp))
13654 api_geneve_add_del_tunnel (vat_main_t * vam)
13656 unformat_input_t *line_input = vam->input;
13657 vl_api_geneve_add_del_tunnel_t *mp;
13658 ip46_address_t src, dst;
13660 u8 ipv4_set = 0, ipv6_set = 0;
13664 u32 mcast_sw_if_index = ~0;
13665 u32 encap_vrf_id = 0;
13666 u32 decap_next_index = ~0;
13670 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13671 clib_memset (&src, 0, sizeof src);
13672 clib_memset (&dst, 0, sizeof dst);
13674 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13676 if (unformat (line_input, "del"))
13679 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13685 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13691 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13697 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13702 else if (unformat (line_input, "group %U %U",
13703 unformat_ip4_address, &dst.ip4,
13704 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13706 grp_set = dst_set = 1;
13709 else if (unformat (line_input, "group %U",
13710 unformat_ip4_address, &dst.ip4))
13712 grp_set = dst_set = 1;
13715 else if (unformat (line_input, "group %U %U",
13716 unformat_ip6_address, &dst.ip6,
13717 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13719 grp_set = dst_set = 1;
13722 else if (unformat (line_input, "group %U",
13723 unformat_ip6_address, &dst.ip6))
13725 grp_set = dst_set = 1;
13729 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13731 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13733 else if (unformat (line_input, "decap-next %U",
13734 unformat_geneve_decap_next, &decap_next_index))
13736 else if (unformat (line_input, "vni %d", &vni))
13740 errmsg ("parse error '%U'", format_unformat_error, line_input);
13747 errmsg ("tunnel src address not specified");
13752 errmsg ("tunnel dst address not specified");
13756 if (grp_set && !ip46_address_is_multicast (&dst))
13758 errmsg ("tunnel group address not multicast");
13761 if (grp_set && mcast_sw_if_index == ~0)
13763 errmsg ("tunnel nonexistent multicast device");
13766 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13768 errmsg ("tunnel dst address must be unicast");
13773 if (ipv4_set && ipv6_set)
13775 errmsg ("both IPv4 and IPv6 addresses specified");
13779 if ((vni == 0) || (vni >> 24))
13781 errmsg ("vni not specified or out of range");
13785 M (GENEVE_ADD_DEL_TUNNEL, mp);
13789 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
13790 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
13794 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
13795 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
13797 mp->encap_vrf_id = ntohl (encap_vrf_id);
13798 mp->decap_next_index = ntohl (decap_next_index);
13799 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13800 mp->vni = ntohl (vni);
13801 mp->is_add = is_add;
13802 mp->is_ipv6 = ipv6_set;
13809 static void vl_api_geneve_tunnel_details_t_handler
13810 (vl_api_geneve_tunnel_details_t * mp)
13812 vat_main_t *vam = &vat_main;
13813 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13814 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13816 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
13817 ntohl (mp->sw_if_index),
13818 format_ip46_address, &src, IP46_TYPE_ANY,
13819 format_ip46_address, &dst, IP46_TYPE_ANY,
13820 ntohl (mp->encap_vrf_id),
13821 ntohl (mp->decap_next_index), ntohl (mp->vni),
13822 ntohl (mp->mcast_sw_if_index));
13825 static void vl_api_geneve_tunnel_details_t_handler_json
13826 (vl_api_geneve_tunnel_details_t * mp)
13828 vat_main_t *vam = &vat_main;
13829 vat_json_node_t *node = NULL;
13831 if (VAT_JSON_ARRAY != vam->json_tree.type)
13833 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13834 vat_json_init_array (&vam->json_tree);
13836 node = vat_json_array_add (&vam->json_tree);
13838 vat_json_init_object (node);
13839 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13842 struct in6_addr ip6;
13844 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13845 vat_json_object_add_ip6 (node, "src_address", ip6);
13846 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13847 vat_json_object_add_ip6 (node, "dst_address", ip6);
13851 struct in_addr ip4;
13853 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13854 vat_json_object_add_ip4 (node, "src_address", ip4);
13855 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13856 vat_json_object_add_ip4 (node, "dst_address", ip4);
13858 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13859 vat_json_object_add_uint (node, "decap_next_index",
13860 ntohl (mp->decap_next_index));
13861 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13862 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13863 vat_json_object_add_uint (node, "mcast_sw_if_index",
13864 ntohl (mp->mcast_sw_if_index));
13868 api_geneve_tunnel_dump (vat_main_t * vam)
13870 unformat_input_t *i = vam->input;
13871 vl_api_geneve_tunnel_dump_t *mp;
13872 vl_api_control_ping_t *mp_ping;
13874 u8 sw_if_index_set = 0;
13877 /* Parse args required to build the message */
13878 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13880 if (unformat (i, "sw_if_index %d", &sw_if_index))
13881 sw_if_index_set = 1;
13886 if (sw_if_index_set == 0)
13891 if (!vam->json_output)
13893 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
13894 "sw_if_index", "local_address", "remote_address",
13895 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13898 /* Get list of geneve-tunnel interfaces */
13899 M (GENEVE_TUNNEL_DUMP, mp);
13901 mp->sw_if_index = htonl (sw_if_index);
13905 /* Use a control ping for synchronization */
13906 M (CONTROL_PING, mp_ping);
13914 api_gre_add_del_tunnel (vat_main_t * vam)
13916 unformat_input_t *line_input = vam->input;
13917 vl_api_gre_add_del_tunnel_t *mp;
13918 ip4_address_t src4, dst4;
13919 ip6_address_t src6, dst6;
13923 u8 t_type = GRE_TUNNEL_TYPE_L3;
13926 u32 outer_fib_id = 0;
13927 u32 session_id = 0;
13931 clib_memset (&src4, 0, sizeof src4);
13932 clib_memset (&dst4, 0, sizeof dst4);
13933 clib_memset (&src6, 0, sizeof src6);
13934 clib_memset (&dst6, 0, sizeof dst6);
13936 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13938 if (unformat (line_input, "del"))
13940 else if (unformat (line_input, "instance %d", &instance))
13942 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
13947 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
13952 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
13957 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
13962 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
13964 else if (unformat (line_input, "teb"))
13965 t_type = GRE_TUNNEL_TYPE_TEB;
13966 else if (unformat (line_input, "erspan %d", &session_id))
13967 t_type = GRE_TUNNEL_TYPE_ERSPAN;
13970 errmsg ("parse error '%U'", format_unformat_error, line_input);
13977 errmsg ("tunnel src address not specified");
13982 errmsg ("tunnel dst address not specified");
13985 if (ipv4_set && ipv6_set)
13987 errmsg ("both IPv4 and IPv6 addresses specified");
13992 M (GRE_ADD_DEL_TUNNEL, mp);
13996 clib_memcpy (&mp->src_address, &src4, 4);
13997 clib_memcpy (&mp->dst_address, &dst4, 4);
14001 clib_memcpy (&mp->src_address, &src6, 16);
14002 clib_memcpy (&mp->dst_address, &dst6, 16);
14004 mp->instance = htonl (instance);
14005 mp->outer_fib_id = htonl (outer_fib_id);
14006 mp->is_add = is_add;
14007 mp->session_id = htons ((u16) session_id);
14008 mp->tunnel_type = t_type;
14009 mp->is_ipv6 = ipv6_set;
14016 static void vl_api_gre_tunnel_details_t_handler
14017 (vl_api_gre_tunnel_details_t * mp)
14019 vat_main_t *vam = &vat_main;
14020 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
14021 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
14023 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
14024 ntohl (mp->sw_if_index),
14025 ntohl (mp->instance),
14026 format_ip46_address, &src, IP46_TYPE_ANY,
14027 format_ip46_address, &dst, IP46_TYPE_ANY,
14028 mp->tunnel_type, ntohl (mp->outer_fib_id), ntohl (mp->session_id));
14031 static void vl_api_gre_tunnel_details_t_handler_json
14032 (vl_api_gre_tunnel_details_t * mp)
14034 vat_main_t *vam = &vat_main;
14035 vat_json_node_t *node = NULL;
14036 struct in_addr ip4;
14037 struct in6_addr ip6;
14039 if (VAT_JSON_ARRAY != vam->json_tree.type)
14041 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14042 vat_json_init_array (&vam->json_tree);
14044 node = vat_json_array_add (&vam->json_tree);
14046 vat_json_init_object (node);
14047 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14048 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
14051 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
14052 vat_json_object_add_ip4 (node, "src_address", ip4);
14053 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
14054 vat_json_object_add_ip4 (node, "dst_address", ip4);
14058 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
14059 vat_json_object_add_ip6 (node, "src_address", ip6);
14060 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
14061 vat_json_object_add_ip6 (node, "dst_address", ip6);
14063 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel_type);
14064 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
14065 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
14066 vat_json_object_add_uint (node, "session_id", mp->session_id);
14070 api_gre_tunnel_dump (vat_main_t * vam)
14072 unformat_input_t *i = vam->input;
14073 vl_api_gre_tunnel_dump_t *mp;
14074 vl_api_control_ping_t *mp_ping;
14076 u8 sw_if_index_set = 0;
14079 /* Parse args required to build the message */
14080 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14082 if (unformat (i, "sw_if_index %d", &sw_if_index))
14083 sw_if_index_set = 1;
14088 if (sw_if_index_set == 0)
14093 if (!vam->json_output)
14095 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
14096 "sw_if_index", "instance", "src_address", "dst_address",
14097 "tunnel_type", "outer_fib_id", "session_id");
14100 /* Get list of gre-tunnel interfaces */
14101 M (GRE_TUNNEL_DUMP, mp);
14103 mp->sw_if_index = htonl (sw_if_index);
14107 /* Use a control ping for synchronization */
14108 MPING (CONTROL_PING, mp_ping);
14116 api_l2_fib_clear_table (vat_main_t * vam)
14118 // unformat_input_t * i = vam->input;
14119 vl_api_l2_fib_clear_table_t *mp;
14122 M (L2_FIB_CLEAR_TABLE, mp);
14130 api_l2_interface_efp_filter (vat_main_t * vam)
14132 unformat_input_t *i = vam->input;
14133 vl_api_l2_interface_efp_filter_t *mp;
14136 u8 sw_if_index_set = 0;
14139 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14141 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14142 sw_if_index_set = 1;
14143 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14144 sw_if_index_set = 1;
14145 else if (unformat (i, "enable"))
14147 else if (unformat (i, "disable"))
14151 clib_warning ("parse error '%U'", format_unformat_error, i);
14156 if (sw_if_index_set == 0)
14158 errmsg ("missing sw_if_index");
14162 M (L2_INTERFACE_EFP_FILTER, mp);
14164 mp->sw_if_index = ntohl (sw_if_index);
14165 mp->enable_disable = enable;
14172 #define foreach_vtr_op \
14173 _("disable", L2_VTR_DISABLED) \
14174 _("push-1", L2_VTR_PUSH_1) \
14175 _("push-2", L2_VTR_PUSH_2) \
14176 _("pop-1", L2_VTR_POP_1) \
14177 _("pop-2", L2_VTR_POP_2) \
14178 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
14179 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
14180 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
14181 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
14184 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
14186 unformat_input_t *i = vam->input;
14187 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
14189 u8 sw_if_index_set = 0;
14192 u32 push_dot1q = 1;
14197 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14199 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14200 sw_if_index_set = 1;
14201 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14202 sw_if_index_set = 1;
14203 else if (unformat (i, "vtr_op %d", &vtr_op))
14205 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
14208 else if (unformat (i, "push_dot1q %d", &push_dot1q))
14210 else if (unformat (i, "tag1 %d", &tag1))
14212 else if (unformat (i, "tag2 %d", &tag2))
14216 clib_warning ("parse error '%U'", format_unformat_error, i);
14221 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
14223 errmsg ("missing vtr operation or sw_if_index");
14227 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
14228 mp->sw_if_index = ntohl (sw_if_index);
14229 mp->vtr_op = ntohl (vtr_op);
14230 mp->push_dot1q = ntohl (push_dot1q);
14231 mp->tag1 = ntohl (tag1);
14232 mp->tag2 = ntohl (tag2);
14240 api_create_vhost_user_if (vat_main_t * vam)
14242 unformat_input_t *i = vam->input;
14243 vl_api_create_vhost_user_if_t *mp;
14246 u8 file_name_set = 0;
14247 u32 custom_dev_instance = ~0;
14249 u8 use_custom_mac = 0;
14250 u8 disable_mrg_rxbuf = 0;
14251 u8 disable_indirect_desc = 0;
14255 /* Shut up coverity */
14256 clib_memset (hwaddr, 0, sizeof (hwaddr));
14258 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14260 if (unformat (i, "socket %s", &file_name))
14264 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
14266 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
14267 use_custom_mac = 1;
14268 else if (unformat (i, "server"))
14270 else if (unformat (i, "disable_mrg_rxbuf"))
14271 disable_mrg_rxbuf = 1;
14272 else if (unformat (i, "disable_indirect_desc"))
14273 disable_indirect_desc = 1;
14274 else if (unformat (i, "tag %s", &tag))
14280 if (file_name_set == 0)
14282 errmsg ("missing socket file name");
14286 if (vec_len (file_name) > 255)
14288 errmsg ("socket file name too long");
14291 vec_add1 (file_name, 0);
14293 M (CREATE_VHOST_USER_IF, mp);
14295 mp->is_server = is_server;
14296 mp->disable_mrg_rxbuf = disable_mrg_rxbuf;
14297 mp->disable_indirect_desc = disable_indirect_desc;
14298 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
14299 vec_free (file_name);
14300 if (custom_dev_instance != ~0)
14303 mp->custom_dev_instance = ntohl (custom_dev_instance);
14306 mp->use_custom_mac = use_custom_mac;
14307 clib_memcpy (mp->mac_address, hwaddr, 6);
14309 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
14318 api_modify_vhost_user_if (vat_main_t * vam)
14320 unformat_input_t *i = vam->input;
14321 vl_api_modify_vhost_user_if_t *mp;
14324 u8 file_name_set = 0;
14325 u32 custom_dev_instance = ~0;
14326 u8 sw_if_index_set = 0;
14327 u32 sw_if_index = (u32) ~ 0;
14330 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14332 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14333 sw_if_index_set = 1;
14334 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14335 sw_if_index_set = 1;
14336 else if (unformat (i, "socket %s", &file_name))
14340 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
14342 else if (unformat (i, "server"))
14348 if (sw_if_index_set == 0)
14350 errmsg ("missing sw_if_index or interface name");
14354 if (file_name_set == 0)
14356 errmsg ("missing socket file name");
14360 if (vec_len (file_name) > 255)
14362 errmsg ("socket file name too long");
14365 vec_add1 (file_name, 0);
14367 M (MODIFY_VHOST_USER_IF, mp);
14369 mp->sw_if_index = ntohl (sw_if_index);
14370 mp->is_server = is_server;
14371 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
14372 vec_free (file_name);
14373 if (custom_dev_instance != ~0)
14376 mp->custom_dev_instance = ntohl (custom_dev_instance);
14385 api_delete_vhost_user_if (vat_main_t * vam)
14387 unformat_input_t *i = vam->input;
14388 vl_api_delete_vhost_user_if_t *mp;
14389 u32 sw_if_index = ~0;
14390 u8 sw_if_index_set = 0;
14393 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14395 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14396 sw_if_index_set = 1;
14397 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14398 sw_if_index_set = 1;
14403 if (sw_if_index_set == 0)
14405 errmsg ("missing sw_if_index or interface name");
14410 M (DELETE_VHOST_USER_IF, mp);
14412 mp->sw_if_index = ntohl (sw_if_index);
14419 static void vl_api_sw_interface_vhost_user_details_t_handler
14420 (vl_api_sw_interface_vhost_user_details_t * mp)
14422 vat_main_t *vam = &vat_main;
14424 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
14425 (char *) mp->interface_name,
14426 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
14427 clib_net_to_host_u64 (mp->features), mp->is_server,
14428 ntohl (mp->num_regions), (char *) mp->sock_filename);
14429 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
14432 static void vl_api_sw_interface_vhost_user_details_t_handler_json
14433 (vl_api_sw_interface_vhost_user_details_t * mp)
14435 vat_main_t *vam = &vat_main;
14436 vat_json_node_t *node = NULL;
14438 if (VAT_JSON_ARRAY != vam->json_tree.type)
14440 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14441 vat_json_init_array (&vam->json_tree);
14443 node = vat_json_array_add (&vam->json_tree);
14445 vat_json_init_object (node);
14446 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14447 vat_json_object_add_string_copy (node, "interface_name",
14448 mp->interface_name);
14449 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
14450 ntohl (mp->virtio_net_hdr_sz));
14451 vat_json_object_add_uint (node, "features",
14452 clib_net_to_host_u64 (mp->features));
14453 vat_json_object_add_uint (node, "is_server", mp->is_server);
14454 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
14455 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
14456 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
14460 api_sw_interface_vhost_user_dump (vat_main_t * vam)
14462 vl_api_sw_interface_vhost_user_dump_t *mp;
14463 vl_api_control_ping_t *mp_ping;
14466 "Interface name idx hdr_sz features server regions filename");
14468 /* Get list of vhost-user interfaces */
14469 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
14472 /* Use a control ping for synchronization */
14473 MPING (CONTROL_PING, mp_ping);
14481 api_show_version (vat_main_t * vam)
14483 vl_api_show_version_t *mp;
14486 M (SHOW_VERSION, mp);
14495 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
14497 unformat_input_t *line_input = vam->input;
14498 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
14499 ip4_address_t local4, remote4;
14500 ip6_address_t local6, remote6;
14502 u8 ipv4_set = 0, ipv6_set = 0;
14506 u32 mcast_sw_if_index = ~0;
14507 u32 encap_vrf_id = 0;
14508 u32 decap_vrf_id = 0;
14514 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
14515 clib_memset (&local4, 0, sizeof local4);
14516 clib_memset (&remote4, 0, sizeof remote4);
14517 clib_memset (&local6, 0, sizeof local6);
14518 clib_memset (&remote6, 0, sizeof remote6);
14520 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14522 if (unformat (line_input, "del"))
14524 else if (unformat (line_input, "local %U",
14525 unformat_ip4_address, &local4))
14530 else if (unformat (line_input, "remote %U",
14531 unformat_ip4_address, &remote4))
14536 else if (unformat (line_input, "local %U",
14537 unformat_ip6_address, &local6))
14542 else if (unformat (line_input, "remote %U",
14543 unformat_ip6_address, &remote6))
14548 else if (unformat (line_input, "group %U %U",
14549 unformat_ip4_address, &remote4,
14550 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14552 grp_set = remote_set = 1;
14555 else if (unformat (line_input, "group %U",
14556 unformat_ip4_address, &remote4))
14558 grp_set = remote_set = 1;
14561 else if (unformat (line_input, "group %U %U",
14562 unformat_ip6_address, &remote6,
14563 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14565 grp_set = remote_set = 1;
14568 else if (unformat (line_input, "group %U",
14569 unformat_ip6_address, &remote6))
14571 grp_set = remote_set = 1;
14575 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
14577 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
14579 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
14581 else if (unformat (line_input, "vni %d", &vni))
14583 else if (unformat (line_input, "next-ip4"))
14585 else if (unformat (line_input, "next-ip6"))
14587 else if (unformat (line_input, "next-ethernet"))
14589 else if (unformat (line_input, "next-nsh"))
14593 errmsg ("parse error '%U'", format_unformat_error, line_input);
14598 if (local_set == 0)
14600 errmsg ("tunnel local address not specified");
14603 if (remote_set == 0)
14605 errmsg ("tunnel remote address not specified");
14608 if (grp_set && mcast_sw_if_index == ~0)
14610 errmsg ("tunnel nonexistent multicast device");
14613 if (ipv4_set && ipv6_set)
14615 errmsg ("both IPv4 and IPv6 addresses specified");
14621 errmsg ("vni not specified");
14625 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
14630 clib_memcpy (&mp->local, &local6, sizeof (local6));
14631 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
14635 clib_memcpy (&mp->local, &local4, sizeof (local4));
14636 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
14639 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
14640 mp->encap_vrf_id = ntohl (encap_vrf_id);
14641 mp->decap_vrf_id = ntohl (decap_vrf_id);
14642 mp->protocol = protocol;
14643 mp->vni = ntohl (vni);
14644 mp->is_add = is_add;
14645 mp->is_ipv6 = ipv6_set;
14652 static void vl_api_vxlan_gpe_tunnel_details_t_handler
14653 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14655 vat_main_t *vam = &vat_main;
14656 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
14657 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
14659 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
14660 ntohl (mp->sw_if_index),
14661 format_ip46_address, &local, IP46_TYPE_ANY,
14662 format_ip46_address, &remote, IP46_TYPE_ANY,
14663 ntohl (mp->vni), mp->protocol,
14664 ntohl (mp->mcast_sw_if_index),
14665 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
14669 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
14670 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14672 vat_main_t *vam = &vat_main;
14673 vat_json_node_t *node = NULL;
14674 struct in_addr ip4;
14675 struct in6_addr ip6;
14677 if (VAT_JSON_ARRAY != vam->json_tree.type)
14679 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14680 vat_json_init_array (&vam->json_tree);
14682 node = vat_json_array_add (&vam->json_tree);
14684 vat_json_init_object (node);
14685 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14688 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
14689 vat_json_object_add_ip6 (node, "local", ip6);
14690 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
14691 vat_json_object_add_ip6 (node, "remote", ip6);
14695 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
14696 vat_json_object_add_ip4 (node, "local", ip4);
14697 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
14698 vat_json_object_add_ip4 (node, "remote", ip4);
14700 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
14701 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
14702 vat_json_object_add_uint (node, "mcast_sw_if_index",
14703 ntohl (mp->mcast_sw_if_index));
14704 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
14705 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
14706 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
14710 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
14712 unformat_input_t *i = vam->input;
14713 vl_api_vxlan_gpe_tunnel_dump_t *mp;
14714 vl_api_control_ping_t *mp_ping;
14716 u8 sw_if_index_set = 0;
14719 /* Parse args required to build the message */
14720 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14722 if (unformat (i, "sw_if_index %d", &sw_if_index))
14723 sw_if_index_set = 1;
14728 if (sw_if_index_set == 0)
14733 if (!vam->json_output)
14735 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
14736 "sw_if_index", "local", "remote", "vni",
14737 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
14740 /* Get list of vxlan-tunnel interfaces */
14741 M (VXLAN_GPE_TUNNEL_DUMP, mp);
14743 mp->sw_if_index = htonl (sw_if_index);
14747 /* Use a control ping for synchronization */
14748 MPING (CONTROL_PING, mp_ping);
14755 static void vl_api_l2_fib_table_details_t_handler
14756 (vl_api_l2_fib_table_details_t * mp)
14758 vat_main_t *vam = &vat_main;
14760 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
14762 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
14763 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
14767 static void vl_api_l2_fib_table_details_t_handler_json
14768 (vl_api_l2_fib_table_details_t * mp)
14770 vat_main_t *vam = &vat_main;
14771 vat_json_node_t *node = NULL;
14773 if (VAT_JSON_ARRAY != vam->json_tree.type)
14775 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14776 vat_json_init_array (&vam->json_tree);
14778 node = vat_json_array_add (&vam->json_tree);
14780 vat_json_init_object (node);
14781 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
14782 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
14783 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14784 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
14785 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
14786 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
14790 api_l2_fib_table_dump (vat_main_t * vam)
14792 unformat_input_t *i = vam->input;
14793 vl_api_l2_fib_table_dump_t *mp;
14794 vl_api_control_ping_t *mp_ping;
14799 /* Parse args required to build the message */
14800 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14802 if (unformat (i, "bd_id %d", &bd_id))
14808 if (bd_id_set == 0)
14810 errmsg ("missing bridge domain");
14814 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
14816 /* Get list of l2 fib entries */
14817 M (L2_FIB_TABLE_DUMP, mp);
14819 mp->bd_id = ntohl (bd_id);
14822 /* Use a control ping for synchronization */
14823 MPING (CONTROL_PING, mp_ping);
14832 api_interface_name_renumber (vat_main_t * vam)
14834 unformat_input_t *line_input = vam->input;
14835 vl_api_interface_name_renumber_t *mp;
14836 u32 sw_if_index = ~0;
14837 u32 new_show_dev_instance = ~0;
14840 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14842 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
14845 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14847 else if (unformat (line_input, "new_show_dev_instance %d",
14848 &new_show_dev_instance))
14854 if (sw_if_index == ~0)
14856 errmsg ("missing interface name or sw_if_index");
14860 if (new_show_dev_instance == ~0)
14862 errmsg ("missing new_show_dev_instance");
14866 M (INTERFACE_NAME_RENUMBER, mp);
14868 mp->sw_if_index = ntohl (sw_if_index);
14869 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
14877 api_ip_probe_neighbor (vat_main_t * vam)
14879 unformat_input_t *i = vam->input;
14880 vl_api_ip_probe_neighbor_t *mp;
14888 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14890 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14892 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14894 else if (unformat (i, "address %U", unformat_ip4_address, dst_adr))
14896 else if (unformat (i, "address %U", unformat_ip6_address, dst_adr))
14907 errmsg ("missing interface");
14913 errmsg ("missing addresses");
14917 M (IP_PROBE_NEIGHBOR, mp);
14919 mp->sw_if_index = ntohl (sw_if_index);
14920 mp->is_ipv6 = is_ipv6;
14921 clib_memcpy (mp->dst_address, dst_adr, sizeof (dst_adr));
14929 api_ip_scan_neighbor_enable_disable (vat_main_t * vam)
14931 unformat_input_t *i = vam->input;
14932 vl_api_ip_scan_neighbor_enable_disable_t *mp;
14933 u8 mode = IP_SCAN_V46_NEIGHBORS;
14934 u32 interval = 0, time = 0, update = 0, delay = 0, stale = 0;
14937 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14939 if (unformat (i, "ip4"))
14940 mode = IP_SCAN_V4_NEIGHBORS;
14941 else if (unformat (i, "ip6"))
14942 mode = IP_SCAN_V6_NEIGHBORS;
14943 if (unformat (i, "both"))
14944 mode = IP_SCAN_V46_NEIGHBORS;
14945 else if (unformat (i, "disable"))
14946 mode = IP_SCAN_DISABLED;
14947 else if (unformat (i, "interval %d", &interval))
14949 else if (unformat (i, "max-time %d", &time))
14951 else if (unformat (i, "max-update %d", &update))
14953 else if (unformat (i, "delay %d", &delay))
14955 else if (unformat (i, "stale %d", &stale))
14961 if (interval > 255)
14963 errmsg ("interval cannot exceed 255 minutes.");
14968 errmsg ("max-time cannot exceed 255 usec.");
14973 errmsg ("max-update cannot exceed 255.");
14978 errmsg ("delay cannot exceed 255 msec.");
14983 errmsg ("stale cannot exceed 255 minutes.");
14987 M (IP_SCAN_NEIGHBOR_ENABLE_DISABLE, mp);
14989 mp->scan_interval = interval;
14990 mp->max_proc_time = time;
14991 mp->max_update = update;
14992 mp->scan_int_delay = delay;
14993 mp->stale_threshold = stale;
15001 api_want_ip4_arp_events (vat_main_t * vam)
15003 unformat_input_t *line_input = vam->input;
15004 vl_api_want_ip4_arp_events_t *mp;
15005 ip4_address_t address;
15006 int address_set = 0;
15007 u32 enable_disable = 1;
15010 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15012 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
15014 else if (unformat (line_input, "del"))
15015 enable_disable = 0;
15020 if (address_set == 0)
15022 errmsg ("missing addresses");
15026 M (WANT_IP4_ARP_EVENTS, mp);
15027 mp->enable_disable = enable_disable;
15028 mp->pid = htonl (getpid ());
15029 mp->address = address.as_u32;
15037 api_want_ip6_nd_events (vat_main_t * vam)
15039 unformat_input_t *line_input = vam->input;
15040 vl_api_want_ip6_nd_events_t *mp;
15041 ip6_address_t address;
15042 int address_set = 0;
15043 u32 enable_disable = 1;
15046 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15048 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
15050 else if (unformat (line_input, "del"))
15051 enable_disable = 0;
15056 if (address_set == 0)
15058 errmsg ("missing addresses");
15062 M (WANT_IP6_ND_EVENTS, mp);
15063 mp->enable_disable = enable_disable;
15064 mp->pid = htonl (getpid ());
15065 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
15073 api_want_l2_macs_events (vat_main_t * vam)
15075 unformat_input_t *line_input = vam->input;
15076 vl_api_want_l2_macs_events_t *mp;
15077 u8 enable_disable = 1;
15078 u32 scan_delay = 0;
15079 u32 max_macs_in_event = 0;
15080 u32 learn_limit = 0;
15083 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15085 if (unformat (line_input, "learn-limit %d", &learn_limit))
15087 else if (unformat (line_input, "scan-delay %d", &scan_delay))
15089 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
15091 else if (unformat (line_input, "disable"))
15092 enable_disable = 0;
15097 M (WANT_L2_MACS_EVENTS, mp);
15098 mp->enable_disable = enable_disable;
15099 mp->pid = htonl (getpid ());
15100 mp->learn_limit = htonl (learn_limit);
15101 mp->scan_delay = (u8) scan_delay;
15102 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
15109 api_input_acl_set_interface (vat_main_t * vam)
15111 unformat_input_t *i = vam->input;
15112 vl_api_input_acl_set_interface_t *mp;
15114 int sw_if_index_set;
15115 u32 ip4_table_index = ~0;
15116 u32 ip6_table_index = ~0;
15117 u32 l2_table_index = ~0;
15121 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15123 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15124 sw_if_index_set = 1;
15125 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15126 sw_if_index_set = 1;
15127 else if (unformat (i, "del"))
15129 else if (unformat (i, "ip4-table %d", &ip4_table_index))
15131 else if (unformat (i, "ip6-table %d", &ip6_table_index))
15133 else if (unformat (i, "l2-table %d", &l2_table_index))
15137 clib_warning ("parse error '%U'", format_unformat_error, i);
15142 if (sw_if_index_set == 0)
15144 errmsg ("missing interface name or sw_if_index");
15148 M (INPUT_ACL_SET_INTERFACE, mp);
15150 mp->sw_if_index = ntohl (sw_if_index);
15151 mp->ip4_table_index = ntohl (ip4_table_index);
15152 mp->ip6_table_index = ntohl (ip6_table_index);
15153 mp->l2_table_index = ntohl (l2_table_index);
15154 mp->is_add = is_add;
15162 api_output_acl_set_interface (vat_main_t * vam)
15164 unformat_input_t *i = vam->input;
15165 vl_api_output_acl_set_interface_t *mp;
15167 int sw_if_index_set;
15168 u32 ip4_table_index = ~0;
15169 u32 ip6_table_index = ~0;
15170 u32 l2_table_index = ~0;
15174 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15176 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15177 sw_if_index_set = 1;
15178 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15179 sw_if_index_set = 1;
15180 else if (unformat (i, "del"))
15182 else if (unformat (i, "ip4-table %d", &ip4_table_index))
15184 else if (unformat (i, "ip6-table %d", &ip6_table_index))
15186 else if (unformat (i, "l2-table %d", &l2_table_index))
15190 clib_warning ("parse error '%U'", format_unformat_error, i);
15195 if (sw_if_index_set == 0)
15197 errmsg ("missing interface name or sw_if_index");
15201 M (OUTPUT_ACL_SET_INTERFACE, mp);
15203 mp->sw_if_index = ntohl (sw_if_index);
15204 mp->ip4_table_index = ntohl (ip4_table_index);
15205 mp->ip6_table_index = ntohl (ip6_table_index);
15206 mp->l2_table_index = ntohl (l2_table_index);
15207 mp->is_add = is_add;
15215 api_ip_address_dump (vat_main_t * vam)
15217 unformat_input_t *i = vam->input;
15218 vl_api_ip_address_dump_t *mp;
15219 vl_api_control_ping_t *mp_ping;
15220 u32 sw_if_index = ~0;
15221 u8 sw_if_index_set = 0;
15226 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15228 if (unformat (i, "sw_if_index %d", &sw_if_index))
15229 sw_if_index_set = 1;
15231 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15232 sw_if_index_set = 1;
15233 else if (unformat (i, "ipv4"))
15235 else if (unformat (i, "ipv6"))
15241 if (ipv4_set && ipv6_set)
15243 errmsg ("ipv4 and ipv6 flags cannot be both set");
15247 if ((!ipv4_set) && (!ipv6_set))
15249 errmsg ("no ipv4 nor ipv6 flag set");
15253 if (sw_if_index_set == 0)
15255 errmsg ("missing interface name or sw_if_index");
15259 vam->current_sw_if_index = sw_if_index;
15260 vam->is_ipv6 = ipv6_set;
15262 M (IP_ADDRESS_DUMP, mp);
15263 mp->sw_if_index = ntohl (sw_if_index);
15264 mp->is_ipv6 = ipv6_set;
15267 /* Use a control ping for synchronization */
15268 MPING (CONTROL_PING, mp_ping);
15276 api_ip_dump (vat_main_t * vam)
15278 vl_api_ip_dump_t *mp;
15279 vl_api_control_ping_t *mp_ping;
15280 unformat_input_t *in = vam->input;
15287 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
15289 if (unformat (in, "ipv4"))
15291 else if (unformat (in, "ipv6"))
15297 if (ipv4_set && ipv6_set)
15299 errmsg ("ipv4 and ipv6 flags cannot be both set");
15303 if ((!ipv4_set) && (!ipv6_set))
15305 errmsg ("no ipv4 nor ipv6 flag set");
15309 is_ipv6 = ipv6_set;
15310 vam->is_ipv6 = is_ipv6;
15312 /* free old data */
15313 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
15315 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
15317 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
15320 mp->is_ipv6 = ipv6_set;
15323 /* Use a control ping for synchronization */
15324 MPING (CONTROL_PING, mp_ping);
15332 api_ipsec_spd_add_del (vat_main_t * vam)
15334 unformat_input_t *i = vam->input;
15335 vl_api_ipsec_spd_add_del_t *mp;
15340 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15342 if (unformat (i, "spd_id %d", &spd_id))
15344 else if (unformat (i, "del"))
15348 clib_warning ("parse error '%U'", format_unformat_error, i);
15354 errmsg ("spd_id must be set");
15358 M (IPSEC_SPD_ADD_DEL, mp);
15360 mp->spd_id = ntohl (spd_id);
15361 mp->is_add = is_add;
15369 api_ipsec_interface_add_del_spd (vat_main_t * vam)
15371 unformat_input_t *i = vam->input;
15372 vl_api_ipsec_interface_add_del_spd_t *mp;
15374 u8 sw_if_index_set = 0;
15375 u32 spd_id = (u32) ~ 0;
15379 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15381 if (unformat (i, "del"))
15383 else if (unformat (i, "spd_id %d", &spd_id))
15386 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15387 sw_if_index_set = 1;
15388 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15389 sw_if_index_set = 1;
15392 clib_warning ("parse error '%U'", format_unformat_error, i);
15398 if (spd_id == (u32) ~ 0)
15400 errmsg ("spd_id must be set");
15404 if (sw_if_index_set == 0)
15406 errmsg ("missing interface name or sw_if_index");
15410 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
15412 mp->spd_id = ntohl (spd_id);
15413 mp->sw_if_index = ntohl (sw_if_index);
15414 mp->is_add = is_add;
15422 api_ipsec_spd_add_del_entry (vat_main_t * vam)
15424 unformat_input_t *i = vam->input;
15425 vl_api_ipsec_spd_add_del_entry_t *mp;
15426 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
15427 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
15429 u32 rport_start = 0, rport_stop = (u32) ~ 0;
15430 u32 lport_start = 0, lport_stop = (u32) ~ 0;
15431 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
15432 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
15435 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
15436 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
15437 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
15438 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
15439 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
15440 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
15442 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15444 if (unformat (i, "del"))
15446 if (unformat (i, "outbound"))
15448 if (unformat (i, "inbound"))
15450 else if (unformat (i, "spd_id %d", &spd_id))
15452 else if (unformat (i, "sa_id %d", &sa_id))
15454 else if (unformat (i, "priority %d", &priority))
15456 else if (unformat (i, "protocol %d", &protocol))
15458 else if (unformat (i, "lport_start %d", &lport_start))
15460 else if (unformat (i, "lport_stop %d", &lport_stop))
15462 else if (unformat (i, "rport_start %d", &rport_start))
15464 else if (unformat (i, "rport_stop %d", &rport_stop))
15468 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
15474 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
15481 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
15487 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
15494 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
15500 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
15507 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
15513 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
15519 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
15521 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
15523 clib_warning ("unsupported action: 'resolve'");
15529 clib_warning ("parse error '%U'", format_unformat_error, i);
15535 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
15537 mp->spd_id = ntohl (spd_id);
15538 mp->priority = ntohl (priority);
15539 mp->is_outbound = is_outbound;
15541 mp->is_ipv6 = is_ipv6;
15542 if (is_ipv6 || is_ip_any)
15544 clib_memcpy (mp->remote_address_start, &raddr6_start,
15545 sizeof (ip6_address_t));
15546 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
15547 sizeof (ip6_address_t));
15548 clib_memcpy (mp->local_address_start, &laddr6_start,
15549 sizeof (ip6_address_t));
15550 clib_memcpy (mp->local_address_stop, &laddr6_stop,
15551 sizeof (ip6_address_t));
15555 clib_memcpy (mp->remote_address_start, &raddr4_start,
15556 sizeof (ip4_address_t));
15557 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
15558 sizeof (ip4_address_t));
15559 clib_memcpy (mp->local_address_start, &laddr4_start,
15560 sizeof (ip4_address_t));
15561 clib_memcpy (mp->local_address_stop, &laddr4_stop,
15562 sizeof (ip4_address_t));
15564 mp->protocol = (u8) protocol;
15565 mp->local_port_start = ntohs ((u16) lport_start);
15566 mp->local_port_stop = ntohs ((u16) lport_stop);
15567 mp->remote_port_start = ntohs ((u16) rport_start);
15568 mp->remote_port_stop = ntohs ((u16) rport_stop);
15569 mp->policy = (u8) policy;
15570 mp->sa_id = ntohl (sa_id);
15571 mp->is_add = is_add;
15572 mp->is_ip_any = is_ip_any;
15579 api_ipsec_sad_add_del_entry (vat_main_t * vam)
15581 unformat_input_t *i = vam->input;
15582 vl_api_ipsec_sad_add_del_entry_t *mp;
15583 u32 sad_id = 0, spi = 0;
15584 u8 *ck = 0, *ik = 0;
15587 u8 protocol = IPSEC_PROTOCOL_AH;
15588 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
15589 u32 crypto_alg = 0, integ_alg = 0;
15590 ip4_address_t tun_src4;
15591 ip4_address_t tun_dst4;
15592 ip6_address_t tun_src6;
15593 ip6_address_t tun_dst6;
15596 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15598 if (unformat (i, "del"))
15600 else if (unformat (i, "sad_id %d", &sad_id))
15602 else if (unformat (i, "spi %d", &spi))
15604 else if (unformat (i, "esp"))
15605 protocol = IPSEC_PROTOCOL_ESP;
15606 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
15609 is_tunnel_ipv6 = 0;
15611 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
15614 is_tunnel_ipv6 = 0;
15616 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
15619 is_tunnel_ipv6 = 1;
15621 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
15624 is_tunnel_ipv6 = 1;
15628 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15630 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
15632 clib_warning ("unsupported crypto-alg: '%U'",
15633 format_ipsec_crypto_alg, crypto_alg);
15637 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15641 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15643 if (integ_alg >= IPSEC_INTEG_N_ALG)
15645 clib_warning ("unsupported integ-alg: '%U'",
15646 format_ipsec_integ_alg, integ_alg);
15650 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15654 clib_warning ("parse error '%U'", format_unformat_error, i);
15660 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
15662 mp->sad_id = ntohl (sad_id);
15663 mp->is_add = is_add;
15664 mp->protocol = protocol;
15665 mp->spi = ntohl (spi);
15666 mp->is_tunnel = is_tunnel;
15667 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
15668 mp->crypto_algorithm = crypto_alg;
15669 mp->integrity_algorithm = integ_alg;
15670 mp->crypto_key_length = vec_len (ck);
15671 mp->integrity_key_length = vec_len (ik);
15673 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15674 mp->crypto_key_length = sizeof (mp->crypto_key);
15676 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15677 mp->integrity_key_length = sizeof (mp->integrity_key);
15680 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15682 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15686 if (is_tunnel_ipv6)
15688 clib_memcpy (mp->tunnel_src_address, &tun_src6,
15689 sizeof (ip6_address_t));
15690 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
15691 sizeof (ip6_address_t));
15695 clib_memcpy (mp->tunnel_src_address, &tun_src4,
15696 sizeof (ip4_address_t));
15697 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
15698 sizeof (ip4_address_t));
15708 api_ipsec_sa_set_key (vat_main_t * vam)
15710 unformat_input_t *i = vam->input;
15711 vl_api_ipsec_sa_set_key_t *mp;
15713 u8 *ck = 0, *ik = 0;
15716 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15718 if (unformat (i, "sa_id %d", &sa_id))
15720 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15722 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15726 clib_warning ("parse error '%U'", format_unformat_error, i);
15731 M (IPSEC_SA_SET_KEY, mp);
15733 mp->sa_id = ntohl (sa_id);
15734 mp->crypto_key_length = vec_len (ck);
15735 mp->integrity_key_length = vec_len (ik);
15737 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15738 mp->crypto_key_length = sizeof (mp->crypto_key);
15740 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15741 mp->integrity_key_length = sizeof (mp->integrity_key);
15744 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15746 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15754 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
15756 unformat_input_t *i = vam->input;
15757 vl_api_ipsec_tunnel_if_add_del_t *mp;
15758 u32 local_spi = 0, remote_spi = 0;
15759 u32 crypto_alg = 0, integ_alg = 0;
15760 u8 *lck = NULL, *rck = NULL;
15761 u8 *lik = NULL, *rik = NULL;
15762 ip4_address_t local_ip = { {0} };
15763 ip4_address_t remote_ip = { {0} };
15766 u8 anti_replay = 0;
15771 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15773 if (unformat (i, "del"))
15775 else if (unformat (i, "esn"))
15777 else if (unformat (i, "anti_replay"))
15779 else if (unformat (i, "local_spi %d", &local_spi))
15781 else if (unformat (i, "remote_spi %d", &remote_spi))
15783 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
15785 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
15787 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
15790 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
15792 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
15794 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
15798 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15800 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
15802 errmsg ("unsupported crypto-alg: '%U'\n",
15803 format_ipsec_crypto_alg, crypto_alg);
15809 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15811 if (integ_alg >= IPSEC_INTEG_N_ALG)
15813 errmsg ("unsupported integ-alg: '%U'\n",
15814 format_ipsec_integ_alg, integ_alg);
15818 else if (unformat (i, "instance %u", &instance))
15822 errmsg ("parse error '%U'\n", format_unformat_error, i);
15827 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
15829 mp->is_add = is_add;
15831 mp->anti_replay = anti_replay;
15833 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
15834 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
15836 mp->local_spi = htonl (local_spi);
15837 mp->remote_spi = htonl (remote_spi);
15838 mp->crypto_alg = (u8) crypto_alg;
15840 mp->local_crypto_key_len = 0;
15843 mp->local_crypto_key_len = vec_len (lck);
15844 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
15845 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
15846 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
15849 mp->remote_crypto_key_len = 0;
15852 mp->remote_crypto_key_len = vec_len (rck);
15853 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
15854 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
15855 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
15858 mp->integ_alg = (u8) integ_alg;
15860 mp->local_integ_key_len = 0;
15863 mp->local_integ_key_len = vec_len (lik);
15864 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
15865 mp->local_integ_key_len = sizeof (mp->local_integ_key);
15866 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
15869 mp->remote_integ_key_len = 0;
15872 mp->remote_integ_key_len = vec_len (rik);
15873 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
15874 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
15875 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
15880 mp->renumber = renumber;
15881 mp->show_instance = ntohl (instance);
15890 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
15892 vat_main_t *vam = &vat_main;
15894 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
15895 "crypto_key %U integ_alg %u integ_key %U use_esn %u "
15896 "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u "
15897 "tunnel_src_addr %U tunnel_dst_addr %U "
15898 "salt %u seq_outbound %lu last_seq_inbound %lu "
15899 "replay_window %lu total_data_size %lu\n",
15900 ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi),
15902 mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len,
15903 mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len,
15904 mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6,
15905 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15906 mp->tunnel_src_addr,
15907 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15908 mp->tunnel_dst_addr,
15910 clib_net_to_host_u64 (mp->seq_outbound),
15911 clib_net_to_host_u64 (mp->last_seq_inbound),
15912 clib_net_to_host_u64 (mp->replay_window),
15913 clib_net_to_host_u64 (mp->total_data_size));
15916 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
15917 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
15919 static void vl_api_ipsec_sa_details_t_handler_json
15920 (vl_api_ipsec_sa_details_t * mp)
15922 vat_main_t *vam = &vat_main;
15923 vat_json_node_t *node = NULL;
15924 struct in_addr src_ip4, dst_ip4;
15925 struct in6_addr src_ip6, dst_ip6;
15927 if (VAT_JSON_ARRAY != vam->json_tree.type)
15929 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15930 vat_json_init_array (&vam->json_tree);
15932 node = vat_json_array_add (&vam->json_tree);
15934 vat_json_init_object (node);
15935 vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id));
15936 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
15937 vat_json_object_add_uint (node, "spi", ntohl (mp->spi));
15938 vat_json_object_add_uint (node, "proto", mp->protocol);
15939 vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg);
15940 vat_json_object_add_uint (node, "integ_alg", mp->integ_alg);
15941 vat_json_object_add_uint (node, "use_esn", mp->use_esn);
15942 vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay);
15943 vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel);
15944 vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6);
15945 vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key,
15946 mp->crypto_key_len);
15947 vat_json_object_add_bytes (node, "integ_key", mp->integ_key,
15948 mp->integ_key_len);
15949 if (mp->is_tunnel_ip6)
15951 clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6));
15952 vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6);
15953 clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6));
15954 vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6);
15958 clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4));
15959 vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4);
15960 clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4));
15961 vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4);
15963 vat_json_object_add_uint (node, "replay_window",
15964 clib_net_to_host_u64 (mp->replay_window));
15965 vat_json_object_add_uint (node, "total_data_size",
15966 clib_net_to_host_u64 (mp->total_data_size));
15971 api_ipsec_sa_dump (vat_main_t * vam)
15973 unformat_input_t *i = vam->input;
15974 vl_api_ipsec_sa_dump_t *mp;
15975 vl_api_control_ping_t *mp_ping;
15979 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15981 if (unformat (i, "sa_id %d", &sa_id))
15985 clib_warning ("parse error '%U'", format_unformat_error, i);
15990 M (IPSEC_SA_DUMP, mp);
15992 mp->sa_id = ntohl (sa_id);
15996 /* Use a control ping for synchronization */
15997 M (CONTROL_PING, mp_ping);
16005 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
16007 unformat_input_t *i = vam->input;
16008 vl_api_ipsec_tunnel_if_set_key_t *mp;
16009 u32 sw_if_index = ~0;
16010 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
16015 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16017 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16020 if (unformat (i, "local crypto %U", unformat_ipsec_crypto_alg, &alg))
16021 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
16023 if (unformat (i, "remote crypto %U", unformat_ipsec_crypto_alg, &alg))
16024 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
16025 else if (unformat (i, "local integ %U", unformat_ipsec_integ_alg, &alg))
16026 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
16028 if (unformat (i, "remote integ %U", unformat_ipsec_integ_alg, &alg))
16029 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
16030 else if (unformat (i, "%U", unformat_hex_string, &key))
16034 clib_warning ("parse error '%U'", format_unformat_error, i);
16039 if (sw_if_index == ~0)
16041 errmsg ("interface must be specified");
16045 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
16047 errmsg ("key type must be specified");
16053 errmsg ("algorithm must be specified");
16057 if (vec_len (key) == 0)
16059 errmsg ("key must be specified");
16063 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
16065 mp->sw_if_index = htonl (sw_if_index);
16067 mp->key_type = key_type;
16068 mp->key_len = vec_len (key);
16069 clib_memcpy (mp->key, key, vec_len (key));
16078 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
16080 unformat_input_t *i = vam->input;
16081 vl_api_ipsec_tunnel_if_set_sa_t *mp;
16082 u32 sw_if_index = ~0;
16084 u8 is_outbound = (u8) ~ 0;
16087 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16089 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16091 else if (unformat (i, "sa_id %d", &sa_id))
16093 else if (unformat (i, "outbound"))
16095 else if (unformat (i, "inbound"))
16099 clib_warning ("parse error '%U'", format_unformat_error, i);
16104 if (sw_if_index == ~0)
16106 errmsg ("interface must be specified");
16112 errmsg ("SA ID must be specified");
16116 M (IPSEC_TUNNEL_IF_SET_SA, mp);
16118 mp->sw_if_index = htonl (sw_if_index);
16119 mp->sa_id = htonl (sa_id);
16120 mp->is_outbound = is_outbound;
16129 api_ikev2_profile_add_del (vat_main_t * vam)
16131 unformat_input_t *i = vam->input;
16132 vl_api_ikev2_profile_add_del_t *mp;
16137 const char *valid_chars = "a-zA-Z0-9_";
16139 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16141 if (unformat (i, "del"))
16143 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
16144 vec_add1 (name, 0);
16147 errmsg ("parse error '%U'", format_unformat_error, i);
16152 if (!vec_len (name))
16154 errmsg ("profile name must be specified");
16158 if (vec_len (name) > 64)
16160 errmsg ("profile name too long");
16164 M (IKEV2_PROFILE_ADD_DEL, mp);
16166 clib_memcpy (mp->name, name, vec_len (name));
16167 mp->is_add = is_add;
16176 api_ikev2_profile_set_auth (vat_main_t * vam)
16178 unformat_input_t *i = vam->input;
16179 vl_api_ikev2_profile_set_auth_t *mp;
16182 u32 auth_method = 0;
16186 const char *valid_chars = "a-zA-Z0-9_";
16188 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16190 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
16191 vec_add1 (name, 0);
16192 else if (unformat (i, "auth_method %U",
16193 unformat_ikev2_auth_method, &auth_method))
16195 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
16197 else if (unformat (i, "auth_data %v", &data))
16201 errmsg ("parse error '%U'", format_unformat_error, i);
16206 if (!vec_len (name))
16208 errmsg ("profile name must be specified");
16212 if (vec_len (name) > 64)
16214 errmsg ("profile name too long");
16218 if (!vec_len (data))
16220 errmsg ("auth_data must be specified");
16226 errmsg ("auth_method must be specified");
16230 M (IKEV2_PROFILE_SET_AUTH, mp);
16232 mp->is_hex = is_hex;
16233 mp->auth_method = (u8) auth_method;
16234 mp->data_len = vec_len (data);
16235 clib_memcpy (mp->name, name, vec_len (name));
16236 clib_memcpy (mp->data, data, vec_len (data));
16246 api_ikev2_profile_set_id (vat_main_t * vam)
16248 unformat_input_t *i = vam->input;
16249 vl_api_ikev2_profile_set_id_t *mp;
16257 const char *valid_chars = "a-zA-Z0-9_";
16259 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16261 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
16262 vec_add1 (name, 0);
16263 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
16265 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
16267 data = vec_new (u8, 4);
16268 clib_memcpy (data, ip4.as_u8, 4);
16270 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
16272 else if (unformat (i, "id_data %v", &data))
16274 else if (unformat (i, "local"))
16276 else if (unformat (i, "remote"))
16280 errmsg ("parse error '%U'", format_unformat_error, i);
16285 if (!vec_len (name))
16287 errmsg ("profile name must be specified");
16291 if (vec_len (name) > 64)
16293 errmsg ("profile name too long");
16297 if (!vec_len (data))
16299 errmsg ("id_data must be specified");
16305 errmsg ("id_type must be specified");
16309 M (IKEV2_PROFILE_SET_ID, mp);
16311 mp->is_local = is_local;
16312 mp->id_type = (u8) id_type;
16313 mp->data_len = vec_len (data);
16314 clib_memcpy (mp->name, name, vec_len (name));
16315 clib_memcpy (mp->data, data, vec_len (data));
16325 api_ikev2_profile_set_ts (vat_main_t * vam)
16327 unformat_input_t *i = vam->input;
16328 vl_api_ikev2_profile_set_ts_t *mp;
16331 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
16332 ip4_address_t start_addr, end_addr;
16334 const char *valid_chars = "a-zA-Z0-9_";
16337 start_addr.as_u32 = 0;
16338 end_addr.as_u32 = (u32) ~ 0;
16340 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16342 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
16343 vec_add1 (name, 0);
16344 else if (unformat (i, "protocol %d", &proto))
16346 else if (unformat (i, "start_port %d", &start_port))
16348 else if (unformat (i, "end_port %d", &end_port))
16351 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
16353 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
16355 else if (unformat (i, "local"))
16357 else if (unformat (i, "remote"))
16361 errmsg ("parse error '%U'", format_unformat_error, i);
16366 if (!vec_len (name))
16368 errmsg ("profile name must be specified");
16372 if (vec_len (name) > 64)
16374 errmsg ("profile name too long");
16378 M (IKEV2_PROFILE_SET_TS, mp);
16380 mp->is_local = is_local;
16381 mp->proto = (u8) proto;
16382 mp->start_port = (u16) start_port;
16383 mp->end_port = (u16) end_port;
16384 mp->start_addr = start_addr.as_u32;
16385 mp->end_addr = end_addr.as_u32;
16386 clib_memcpy (mp->name, name, vec_len (name));
16395 api_ikev2_set_local_key (vat_main_t * vam)
16397 unformat_input_t *i = vam->input;
16398 vl_api_ikev2_set_local_key_t *mp;
16402 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16404 if (unformat (i, "file %v", &file))
16405 vec_add1 (file, 0);
16408 errmsg ("parse error '%U'", format_unformat_error, i);
16413 if (!vec_len (file))
16415 errmsg ("RSA key file must be specified");
16419 if (vec_len (file) > 256)
16421 errmsg ("file name too long");
16425 M (IKEV2_SET_LOCAL_KEY, mp);
16427 clib_memcpy (mp->key_file, file, vec_len (file));
16436 api_ikev2_set_responder (vat_main_t * vam)
16438 unformat_input_t *i = vam->input;
16439 vl_api_ikev2_set_responder_t *mp;
16442 u32 sw_if_index = ~0;
16443 ip4_address_t address;
16445 const char *valid_chars = "a-zA-Z0-9_";
16447 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16450 (i, "%U interface %d address %U", unformat_token, valid_chars,
16451 &name, &sw_if_index, unformat_ip4_address, &address))
16452 vec_add1 (name, 0);
16455 errmsg ("parse error '%U'", format_unformat_error, i);
16460 if (!vec_len (name))
16462 errmsg ("profile name must be specified");
16466 if (vec_len (name) > 64)
16468 errmsg ("profile name too long");
16472 M (IKEV2_SET_RESPONDER, mp);
16474 clib_memcpy (mp->name, name, vec_len (name));
16477 mp->sw_if_index = sw_if_index;
16478 clib_memcpy (mp->address, &address, sizeof (address));
16486 api_ikev2_set_ike_transforms (vat_main_t * vam)
16488 unformat_input_t *i = vam->input;
16489 vl_api_ikev2_set_ike_transforms_t *mp;
16492 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
16494 const char *valid_chars = "a-zA-Z0-9_";
16496 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16498 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
16499 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
16500 vec_add1 (name, 0);
16503 errmsg ("parse error '%U'", format_unformat_error, i);
16508 if (!vec_len (name))
16510 errmsg ("profile name must be specified");
16514 if (vec_len (name) > 64)
16516 errmsg ("profile name too long");
16520 M (IKEV2_SET_IKE_TRANSFORMS, mp);
16522 clib_memcpy (mp->name, name, vec_len (name));
16524 mp->crypto_alg = crypto_alg;
16525 mp->crypto_key_size = crypto_key_size;
16526 mp->integ_alg = integ_alg;
16527 mp->dh_group = dh_group;
16536 api_ikev2_set_esp_transforms (vat_main_t * vam)
16538 unformat_input_t *i = vam->input;
16539 vl_api_ikev2_set_esp_transforms_t *mp;
16542 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
16544 const char *valid_chars = "a-zA-Z0-9_";
16546 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16548 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
16549 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
16550 vec_add1 (name, 0);
16553 errmsg ("parse error '%U'", format_unformat_error, i);
16558 if (!vec_len (name))
16560 errmsg ("profile name must be specified");
16564 if (vec_len (name) > 64)
16566 errmsg ("profile name too long");
16570 M (IKEV2_SET_ESP_TRANSFORMS, mp);
16572 clib_memcpy (mp->name, name, vec_len (name));
16574 mp->crypto_alg = crypto_alg;
16575 mp->crypto_key_size = crypto_key_size;
16576 mp->integ_alg = integ_alg;
16577 mp->dh_group = dh_group;
16585 api_ikev2_set_sa_lifetime (vat_main_t * vam)
16587 unformat_input_t *i = vam->input;
16588 vl_api_ikev2_set_sa_lifetime_t *mp;
16591 u64 lifetime, lifetime_maxdata;
16592 u32 lifetime_jitter, handover;
16594 const char *valid_chars = "a-zA-Z0-9_";
16596 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16598 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
16599 &lifetime, &lifetime_jitter, &handover,
16600 &lifetime_maxdata))
16601 vec_add1 (name, 0);
16604 errmsg ("parse error '%U'", format_unformat_error, i);
16609 if (!vec_len (name))
16611 errmsg ("profile name must be specified");
16615 if (vec_len (name) > 64)
16617 errmsg ("profile name too long");
16621 M (IKEV2_SET_SA_LIFETIME, mp);
16623 clib_memcpy (mp->name, name, vec_len (name));
16625 mp->lifetime = lifetime;
16626 mp->lifetime_jitter = lifetime_jitter;
16627 mp->handover = handover;
16628 mp->lifetime_maxdata = lifetime_maxdata;
16636 api_ikev2_initiate_sa_init (vat_main_t * vam)
16638 unformat_input_t *i = vam->input;
16639 vl_api_ikev2_initiate_sa_init_t *mp;
16643 const char *valid_chars = "a-zA-Z0-9_";
16645 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16647 if (unformat (i, "%U", unformat_token, valid_chars, &name))
16648 vec_add1 (name, 0);
16651 errmsg ("parse error '%U'", format_unformat_error, i);
16656 if (!vec_len (name))
16658 errmsg ("profile name must be specified");
16662 if (vec_len (name) > 64)
16664 errmsg ("profile name too long");
16668 M (IKEV2_INITIATE_SA_INIT, mp);
16670 clib_memcpy (mp->name, name, vec_len (name));
16679 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
16681 unformat_input_t *i = vam->input;
16682 vl_api_ikev2_initiate_del_ike_sa_t *mp;
16687 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16689 if (unformat (i, "%lx", &ispi))
16693 errmsg ("parse error '%U'", format_unformat_error, i);
16698 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
16708 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
16710 unformat_input_t *i = vam->input;
16711 vl_api_ikev2_initiate_del_child_sa_t *mp;
16716 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16718 if (unformat (i, "%x", &ispi))
16722 errmsg ("parse error '%U'", format_unformat_error, i);
16727 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
16737 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
16739 unformat_input_t *i = vam->input;
16740 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
16745 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16747 if (unformat (i, "%x", &ispi))
16751 errmsg ("parse error '%U'", format_unformat_error, i);
16756 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
16766 api_get_first_msg_id (vat_main_t * vam)
16768 vl_api_get_first_msg_id_t *mp;
16769 unformat_input_t *i = vam->input;
16774 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16776 if (unformat (i, "client %s", &name))
16784 errmsg ("missing client name");
16787 vec_add1 (name, 0);
16789 if (vec_len (name) > 63)
16791 errmsg ("client name too long");
16795 M (GET_FIRST_MSG_ID, mp);
16796 clib_memcpy (mp->name, name, vec_len (name));
16803 api_cop_interface_enable_disable (vat_main_t * vam)
16805 unformat_input_t *line_input = vam->input;
16806 vl_api_cop_interface_enable_disable_t *mp;
16807 u32 sw_if_index = ~0;
16808 u8 enable_disable = 1;
16811 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16813 if (unformat (line_input, "disable"))
16814 enable_disable = 0;
16815 if (unformat (line_input, "enable"))
16816 enable_disable = 1;
16817 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16818 vam, &sw_if_index))
16820 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16826 if (sw_if_index == ~0)
16828 errmsg ("missing interface name or sw_if_index");
16832 /* Construct the API message */
16833 M (COP_INTERFACE_ENABLE_DISABLE, mp);
16834 mp->sw_if_index = ntohl (sw_if_index);
16835 mp->enable_disable = enable_disable;
16839 /* Wait for the reply */
16845 api_cop_whitelist_enable_disable (vat_main_t * vam)
16847 unformat_input_t *line_input = vam->input;
16848 vl_api_cop_whitelist_enable_disable_t *mp;
16849 u32 sw_if_index = ~0;
16850 u8 ip4 = 0, ip6 = 0, default_cop = 0;
16854 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16856 if (unformat (line_input, "ip4"))
16858 else if (unformat (line_input, "ip6"))
16860 else if (unformat (line_input, "default"))
16862 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16863 vam, &sw_if_index))
16865 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16867 else if (unformat (line_input, "fib-id %d", &fib_id))
16873 if (sw_if_index == ~0)
16875 errmsg ("missing interface name or sw_if_index");
16879 /* Construct the API message */
16880 M (COP_WHITELIST_ENABLE_DISABLE, mp);
16881 mp->sw_if_index = ntohl (sw_if_index);
16882 mp->fib_id = ntohl (fib_id);
16885 mp->default_cop = default_cop;
16889 /* Wait for the reply */
16895 api_get_node_graph (vat_main_t * vam)
16897 vl_api_get_node_graph_t *mp;
16900 M (GET_NODE_GRAPH, mp);
16904 /* Wait for the reply */
16910 /** Used for parsing LISP eids */
16911 typedef CLIB_PACKED(struct{
16912 u8 addr[16]; /**< eid address */
16913 u32 len; /**< prefix length if IP */
16914 u8 type; /**< type of eid */
16919 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
16921 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
16923 clib_memset (a, 0, sizeof (a[0]));
16925 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
16927 a->type = 0; /* ipv4 type */
16929 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
16931 a->type = 1; /* ipv6 type */
16933 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
16935 a->type = 2; /* mac type */
16937 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
16939 a->type = 3; /* NSH type */
16940 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
16941 nsh->spi = clib_host_to_net_u32 (nsh->spi);
16948 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
16957 lisp_eid_size_vat (u8 type)
16974 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
16976 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
16980 api_one_add_del_locator_set (vat_main_t * vam)
16982 unformat_input_t *input = vam->input;
16983 vl_api_one_add_del_locator_set_t *mp;
16985 u8 *locator_set_name = NULL;
16986 u8 locator_set_name_set = 0;
16987 vl_api_local_locator_t locator, *locators = 0;
16988 u32 sw_if_index, priority, weight;
16992 /* Parse args required to build the message */
16993 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16995 if (unformat (input, "del"))
16999 else if (unformat (input, "locator-set %s", &locator_set_name))
17001 locator_set_name_set = 1;
17003 else if (unformat (input, "sw_if_index %u p %u w %u",
17004 &sw_if_index, &priority, &weight))
17006 locator.sw_if_index = htonl (sw_if_index);
17007 locator.priority = priority;
17008 locator.weight = weight;
17009 vec_add1 (locators, locator);
17013 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
17014 &sw_if_index, &priority, &weight))
17016 locator.sw_if_index = htonl (sw_if_index);
17017 locator.priority = priority;
17018 locator.weight = weight;
17019 vec_add1 (locators, locator);
17025 if (locator_set_name_set == 0)
17027 errmsg ("missing locator-set name");
17028 vec_free (locators);
17032 if (vec_len (locator_set_name) > 64)
17034 errmsg ("locator-set name too long");
17035 vec_free (locator_set_name);
17036 vec_free (locators);
17039 vec_add1 (locator_set_name, 0);
17041 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
17043 /* Construct the API message */
17044 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
17046 mp->is_add = is_add;
17047 clib_memcpy (mp->locator_set_name, locator_set_name,
17048 vec_len (locator_set_name));
17049 vec_free (locator_set_name);
17051 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
17053 clib_memcpy (mp->locators, locators, data_len);
17054 vec_free (locators);
17059 /* Wait for a reply... */
17064 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
17067 api_one_add_del_locator (vat_main_t * vam)
17069 unformat_input_t *input = vam->input;
17070 vl_api_one_add_del_locator_t *mp;
17071 u32 tmp_if_index = ~0;
17072 u32 sw_if_index = ~0;
17073 u8 sw_if_index_set = 0;
17074 u8 sw_if_index_if_name_set = 0;
17076 u8 priority_set = 0;
17080 u8 *locator_set_name = NULL;
17081 u8 locator_set_name_set = 0;
17084 /* Parse args required to build the message */
17085 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17087 if (unformat (input, "del"))
17091 else if (unformat (input, "locator-set %s", &locator_set_name))
17093 locator_set_name_set = 1;
17095 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
17098 sw_if_index_if_name_set = 1;
17099 sw_if_index = tmp_if_index;
17101 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
17103 sw_if_index_set = 1;
17104 sw_if_index = tmp_if_index;
17106 else if (unformat (input, "p %d", &priority))
17110 else if (unformat (input, "w %d", &weight))
17118 if (locator_set_name_set == 0)
17120 errmsg ("missing locator-set name");
17124 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
17126 errmsg ("missing sw_if_index");
17127 vec_free (locator_set_name);
17131 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
17133 errmsg ("cannot use both params interface name and sw_if_index");
17134 vec_free (locator_set_name);
17138 if (priority_set == 0)
17140 errmsg ("missing locator-set priority");
17141 vec_free (locator_set_name);
17145 if (weight_set == 0)
17147 errmsg ("missing locator-set weight");
17148 vec_free (locator_set_name);
17152 if (vec_len (locator_set_name) > 64)
17154 errmsg ("locator-set name too long");
17155 vec_free (locator_set_name);
17158 vec_add1 (locator_set_name, 0);
17160 /* Construct the API message */
17161 M (ONE_ADD_DEL_LOCATOR, mp);
17163 mp->is_add = is_add;
17164 mp->sw_if_index = ntohl (sw_if_index);
17165 mp->priority = priority;
17166 mp->weight = weight;
17167 clib_memcpy (mp->locator_set_name, locator_set_name,
17168 vec_len (locator_set_name));
17169 vec_free (locator_set_name);
17174 /* Wait for a reply... */
17179 #define api_lisp_add_del_locator api_one_add_del_locator
17182 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
17184 u32 *key_id = va_arg (*args, u32 *);
17187 if (unformat (input, "%s", &s))
17189 if (!strcmp ((char *) s, "sha1"))
17190 key_id[0] = HMAC_SHA_1_96;
17191 else if (!strcmp ((char *) s, "sha256"))
17192 key_id[0] = HMAC_SHA_256_128;
17195 clib_warning ("invalid key_id: '%s'", s);
17196 key_id[0] = HMAC_NO_KEY;
17207 api_one_add_del_local_eid (vat_main_t * vam)
17209 unformat_input_t *input = vam->input;
17210 vl_api_one_add_del_local_eid_t *mp;
17213 lisp_eid_vat_t _eid, *eid = &_eid;
17214 u8 *locator_set_name = 0;
17215 u8 locator_set_name_set = 0;
17221 /* Parse args required to build the message */
17222 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17224 if (unformat (input, "del"))
17228 else if (unformat (input, "vni %d", &vni))
17232 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
17236 else if (unformat (input, "locator-set %s", &locator_set_name))
17238 locator_set_name_set = 1;
17240 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
17242 else if (unformat (input, "secret-key %_%v%_", &key))
17248 if (locator_set_name_set == 0)
17250 errmsg ("missing locator-set name");
17256 errmsg ("EID address not set!");
17257 vec_free (locator_set_name);
17261 if (key && (0 == key_id))
17263 errmsg ("invalid key_id!");
17267 if (vec_len (key) > 64)
17269 errmsg ("key too long");
17274 if (vec_len (locator_set_name) > 64)
17276 errmsg ("locator-set name too long");
17277 vec_free (locator_set_name);
17280 vec_add1 (locator_set_name, 0);
17282 /* Construct the API message */
17283 M (ONE_ADD_DEL_LOCAL_EID, mp);
17285 mp->is_add = is_add;
17286 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
17287 mp->eid_type = eid->type;
17288 mp->prefix_len = eid->len;
17289 mp->vni = clib_host_to_net_u32 (vni);
17290 mp->key_id = clib_host_to_net_u16 (key_id);
17291 clib_memcpy (mp->locator_set_name, locator_set_name,
17292 vec_len (locator_set_name));
17293 clib_memcpy (mp->key, key, vec_len (key));
17295 vec_free (locator_set_name);
17301 /* Wait for a reply... */
17306 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
17309 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
17311 u32 dp_table = 0, vni = 0;;
17312 unformat_input_t *input = vam->input;
17313 vl_api_gpe_add_del_fwd_entry_t *mp;
17315 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
17316 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
17317 u8 rmt_eid_set = 0, lcl_eid_set = 0;
17318 u32 action = ~0, w;
17319 ip4_address_t rmt_rloc4, lcl_rloc4;
17320 ip6_address_t rmt_rloc6, lcl_rloc6;
17321 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
17324 clib_memset (&rloc, 0, sizeof (rloc));
17326 /* Parse args required to build the message */
17327 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17329 if (unformat (input, "del"))
17331 else if (unformat (input, "add"))
17333 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
17337 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
17341 else if (unformat (input, "vrf %d", &dp_table))
17343 else if (unformat (input, "bd %d", &dp_table))
17345 else if (unformat (input, "vni %d", &vni))
17347 else if (unformat (input, "w %d", &w))
17351 errmsg ("No RLOC configured for setting priority/weight!");
17354 curr_rloc->weight = w;
17356 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
17357 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
17361 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
17363 vec_add1 (lcl_locs, rloc);
17365 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
17366 vec_add1 (rmt_locs, rloc);
17367 /* weight saved in rmt loc */
17368 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
17370 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
17371 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
17374 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
17376 vec_add1 (lcl_locs, rloc);
17378 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
17379 vec_add1 (rmt_locs, rloc);
17380 /* weight saved in rmt loc */
17381 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
17383 else if (unformat (input, "action %d", &action))
17389 clib_warning ("parse error '%U'", format_unformat_error, input);
17396 errmsg ("remote eid addresses not set");
17400 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
17402 errmsg ("eid types don't match");
17406 if (0 == rmt_locs && (u32) ~ 0 == action)
17408 errmsg ("action not set for negative mapping");
17412 /* Construct the API message */
17413 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
17414 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
17416 mp->is_add = is_add;
17417 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
17418 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
17419 mp->eid_type = rmt_eid->type;
17420 mp->dp_table = clib_host_to_net_u32 (dp_table);
17421 mp->vni = clib_host_to_net_u32 (vni);
17422 mp->rmt_len = rmt_eid->len;
17423 mp->lcl_len = lcl_eid->len;
17424 mp->action = action;
17426 if (0 != rmt_locs && 0 != lcl_locs)
17428 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
17429 clib_memcpy (mp->locs, lcl_locs,
17430 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
17432 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
17433 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
17434 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
17436 vec_free (lcl_locs);
17437 vec_free (rmt_locs);
17442 /* Wait for a reply... */
17448 api_one_add_del_map_server (vat_main_t * vam)
17450 unformat_input_t *input = vam->input;
17451 vl_api_one_add_del_map_server_t *mp;
17455 ip4_address_t ipv4;
17456 ip6_address_t ipv6;
17459 /* Parse args required to build the message */
17460 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17462 if (unformat (input, "del"))
17466 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17470 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17478 if (ipv4_set && ipv6_set)
17480 errmsg ("both eid v4 and v6 addresses set");
17484 if (!ipv4_set && !ipv6_set)
17486 errmsg ("eid addresses not set");
17490 /* Construct the API message */
17491 M (ONE_ADD_DEL_MAP_SERVER, mp);
17493 mp->is_add = is_add;
17497 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17502 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17508 /* Wait for a reply... */
17513 #define api_lisp_add_del_map_server api_one_add_del_map_server
17516 api_one_add_del_map_resolver (vat_main_t * vam)
17518 unformat_input_t *input = vam->input;
17519 vl_api_one_add_del_map_resolver_t *mp;
17523 ip4_address_t ipv4;
17524 ip6_address_t ipv6;
17527 /* Parse args required to build the message */
17528 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17530 if (unformat (input, "del"))
17534 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17538 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17546 if (ipv4_set && ipv6_set)
17548 errmsg ("both eid v4 and v6 addresses set");
17552 if (!ipv4_set && !ipv6_set)
17554 errmsg ("eid addresses not set");
17558 /* Construct the API message */
17559 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
17561 mp->is_add = is_add;
17565 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17570 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17576 /* Wait for a reply... */
17581 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
17584 api_lisp_gpe_enable_disable (vat_main_t * vam)
17586 unformat_input_t *input = vam->input;
17587 vl_api_gpe_enable_disable_t *mp;
17592 /* Parse args required to build the message */
17593 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17595 if (unformat (input, "enable"))
17600 else if (unformat (input, "disable"))
17611 errmsg ("Value not set");
17615 /* Construct the API message */
17616 M (GPE_ENABLE_DISABLE, mp);
17623 /* Wait for a reply... */
17629 api_one_rloc_probe_enable_disable (vat_main_t * vam)
17631 unformat_input_t *input = vam->input;
17632 vl_api_one_rloc_probe_enable_disable_t *mp;
17637 /* Parse args required to build the message */
17638 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17640 if (unformat (input, "enable"))
17645 else if (unformat (input, "disable"))
17653 errmsg ("Value not set");
17657 /* Construct the API message */
17658 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
17660 mp->is_enabled = is_en;
17665 /* Wait for a reply... */
17670 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
17673 api_one_map_register_enable_disable (vat_main_t * vam)
17675 unformat_input_t *input = vam->input;
17676 vl_api_one_map_register_enable_disable_t *mp;
17681 /* Parse args required to build the message */
17682 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17684 if (unformat (input, "enable"))
17689 else if (unformat (input, "disable"))
17697 errmsg ("Value not set");
17701 /* Construct the API message */
17702 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
17704 mp->is_enabled = is_en;
17709 /* Wait for a reply... */
17714 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
17717 api_one_enable_disable (vat_main_t * vam)
17719 unformat_input_t *input = vam->input;
17720 vl_api_one_enable_disable_t *mp;
17725 /* Parse args required to build the message */
17726 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17728 if (unformat (input, "enable"))
17733 else if (unformat (input, "disable"))
17743 errmsg ("Value not set");
17747 /* Construct the API message */
17748 M (ONE_ENABLE_DISABLE, mp);
17755 /* Wait for a reply... */
17760 #define api_lisp_enable_disable api_one_enable_disable
17763 api_one_enable_disable_xtr_mode (vat_main_t * vam)
17765 unformat_input_t *input = vam->input;
17766 vl_api_one_enable_disable_xtr_mode_t *mp;
17771 /* Parse args required to build the message */
17772 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17774 if (unformat (input, "enable"))
17779 else if (unformat (input, "disable"))
17789 errmsg ("Value not set");
17793 /* Construct the API message */
17794 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
17801 /* Wait for a reply... */
17807 api_one_show_xtr_mode (vat_main_t * vam)
17809 vl_api_one_show_xtr_mode_t *mp;
17812 /* Construct the API message */
17813 M (ONE_SHOW_XTR_MODE, mp);
17818 /* Wait for a reply... */
17824 api_one_enable_disable_pitr_mode (vat_main_t * vam)
17826 unformat_input_t *input = vam->input;
17827 vl_api_one_enable_disable_pitr_mode_t *mp;
17832 /* Parse args required to build the message */
17833 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17835 if (unformat (input, "enable"))
17840 else if (unformat (input, "disable"))
17850 errmsg ("Value not set");
17854 /* Construct the API message */
17855 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
17862 /* Wait for a reply... */
17868 api_one_show_pitr_mode (vat_main_t * vam)
17870 vl_api_one_show_pitr_mode_t *mp;
17873 /* Construct the API message */
17874 M (ONE_SHOW_PITR_MODE, mp);
17879 /* Wait for a reply... */
17885 api_one_enable_disable_petr_mode (vat_main_t * vam)
17887 unformat_input_t *input = vam->input;
17888 vl_api_one_enable_disable_petr_mode_t *mp;
17893 /* Parse args required to build the message */
17894 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17896 if (unformat (input, "enable"))
17901 else if (unformat (input, "disable"))
17911 errmsg ("Value not set");
17915 /* Construct the API message */
17916 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
17923 /* Wait for a reply... */
17929 api_one_show_petr_mode (vat_main_t * vam)
17931 vl_api_one_show_petr_mode_t *mp;
17934 /* Construct the API message */
17935 M (ONE_SHOW_PETR_MODE, mp);
17940 /* Wait for a reply... */
17946 api_show_one_map_register_state (vat_main_t * vam)
17948 vl_api_show_one_map_register_state_t *mp;
17951 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
17956 /* wait for reply */
17961 #define api_show_lisp_map_register_state api_show_one_map_register_state
17964 api_show_one_rloc_probe_state (vat_main_t * vam)
17966 vl_api_show_one_rloc_probe_state_t *mp;
17969 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
17974 /* wait for reply */
17979 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
17982 api_one_add_del_ndp_entry (vat_main_t * vam)
17984 vl_api_one_add_del_ndp_entry_t *mp;
17985 unformat_input_t *input = vam->input;
17990 u8 mac[6] = { 0, };
17991 u8 ip6[16] = { 0, };
17995 /* Parse args required to build the message */
17996 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17998 if (unformat (input, "del"))
18000 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
18002 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
18004 else if (unformat (input, "bd %d", &bd))
18008 errmsg ("parse error '%U'", format_unformat_error, input);
18013 if (!bd_set || !ip_set || (!mac_set && is_add))
18015 errmsg ("Missing BD, IP or MAC!");
18019 M (ONE_ADD_DEL_NDP_ENTRY, mp);
18020 mp->is_add = is_add;
18021 clib_memcpy (mp->mac, mac, 6);
18022 mp->bd = clib_host_to_net_u32 (bd);
18023 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
18028 /* wait for reply */
18034 api_one_add_del_l2_arp_entry (vat_main_t * vam)
18036 vl_api_one_add_del_l2_arp_entry_t *mp;
18037 unformat_input_t *input = vam->input;
18042 u8 mac[6] = { 0, };
18043 u32 ip4 = 0, bd = ~0;
18046 /* Parse args required to build the message */
18047 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18049 if (unformat (input, "del"))
18051 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
18053 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
18055 else if (unformat (input, "bd %d", &bd))
18059 errmsg ("parse error '%U'", format_unformat_error, input);
18064 if (!bd_set || !ip_set || (!mac_set && is_add))
18066 errmsg ("Missing BD, IP or MAC!");
18070 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
18071 mp->is_add = is_add;
18072 clib_memcpy (mp->mac, mac, 6);
18073 mp->bd = clib_host_to_net_u32 (bd);
18079 /* wait for reply */
18085 api_one_ndp_bd_get (vat_main_t * vam)
18087 vl_api_one_ndp_bd_get_t *mp;
18090 M (ONE_NDP_BD_GET, mp);
18095 /* wait for reply */
18101 api_one_ndp_entries_get (vat_main_t * vam)
18103 vl_api_one_ndp_entries_get_t *mp;
18104 unformat_input_t *input = vam->input;
18109 /* Parse args required to build the message */
18110 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18112 if (unformat (input, "bd %d", &bd))
18116 errmsg ("parse error '%U'", format_unformat_error, input);
18123 errmsg ("Expected bridge domain!");
18127 M (ONE_NDP_ENTRIES_GET, mp);
18128 mp->bd = clib_host_to_net_u32 (bd);
18133 /* wait for reply */
18139 api_one_l2_arp_bd_get (vat_main_t * vam)
18141 vl_api_one_l2_arp_bd_get_t *mp;
18144 M (ONE_L2_ARP_BD_GET, mp);
18149 /* wait for reply */
18155 api_one_l2_arp_entries_get (vat_main_t * vam)
18157 vl_api_one_l2_arp_entries_get_t *mp;
18158 unformat_input_t *input = vam->input;
18163 /* Parse args required to build the message */
18164 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18166 if (unformat (input, "bd %d", &bd))
18170 errmsg ("parse error '%U'", format_unformat_error, input);
18177 errmsg ("Expected bridge domain!");
18181 M (ONE_L2_ARP_ENTRIES_GET, mp);
18182 mp->bd = clib_host_to_net_u32 (bd);
18187 /* wait for reply */
18193 api_one_stats_enable_disable (vat_main_t * vam)
18195 vl_api_one_stats_enable_disable_t *mp;
18196 unformat_input_t *input = vam->input;
18201 /* Parse args required to build the message */
18202 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18204 if (unformat (input, "enable"))
18209 else if (unformat (input, "disable"))
18219 errmsg ("Value not set");
18223 M (ONE_STATS_ENABLE_DISABLE, mp);
18229 /* wait for reply */
18235 api_show_one_stats_enable_disable (vat_main_t * vam)
18237 vl_api_show_one_stats_enable_disable_t *mp;
18240 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
18245 /* wait for reply */
18251 api_show_one_map_request_mode (vat_main_t * vam)
18253 vl_api_show_one_map_request_mode_t *mp;
18256 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
18261 /* wait for reply */
18266 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
18269 api_one_map_request_mode (vat_main_t * vam)
18271 unformat_input_t *input = vam->input;
18272 vl_api_one_map_request_mode_t *mp;
18276 /* Parse args required to build the message */
18277 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18279 if (unformat (input, "dst-only"))
18281 else if (unformat (input, "src-dst"))
18285 errmsg ("parse error '%U'", format_unformat_error, input);
18290 M (ONE_MAP_REQUEST_MODE, mp);
18297 /* wait for reply */
18302 #define api_lisp_map_request_mode api_one_map_request_mode
18305 * Enable/disable ONE proxy ITR.
18307 * @param vam vpp API test context
18308 * @return return code
18311 api_one_pitr_set_locator_set (vat_main_t * vam)
18313 u8 ls_name_set = 0;
18314 unformat_input_t *input = vam->input;
18315 vl_api_one_pitr_set_locator_set_t *mp;
18320 /* Parse args required to build the message */
18321 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18323 if (unformat (input, "del"))
18325 else if (unformat (input, "locator-set %s", &ls_name))
18329 errmsg ("parse error '%U'", format_unformat_error, input);
18336 errmsg ("locator-set name not set!");
18340 M (ONE_PITR_SET_LOCATOR_SET, mp);
18342 mp->is_add = is_add;
18343 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
18344 vec_free (ls_name);
18349 /* wait for reply */
18354 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
18357 api_one_nsh_set_locator_set (vat_main_t * vam)
18359 u8 ls_name_set = 0;
18360 unformat_input_t *input = vam->input;
18361 vl_api_one_nsh_set_locator_set_t *mp;
18366 /* Parse args required to build the message */
18367 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18369 if (unformat (input, "del"))
18371 else if (unformat (input, "ls %s", &ls_name))
18375 errmsg ("parse error '%U'", format_unformat_error, input);
18380 if (!ls_name_set && is_add)
18382 errmsg ("locator-set name not set!");
18386 M (ONE_NSH_SET_LOCATOR_SET, mp);
18388 mp->is_add = is_add;
18389 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
18390 vec_free (ls_name);
18395 /* wait for reply */
18401 api_show_one_pitr (vat_main_t * vam)
18403 vl_api_show_one_pitr_t *mp;
18406 if (!vam->json_output)
18408 print (vam->ofp, "%=20s", "lisp status:");
18411 M (SHOW_ONE_PITR, mp);
18415 /* Wait for a reply... */
18420 #define api_show_lisp_pitr api_show_one_pitr
18423 api_one_use_petr (vat_main_t * vam)
18425 unformat_input_t *input = vam->input;
18426 vl_api_one_use_petr_t *mp;
18431 clib_memset (&ip, 0, sizeof (ip));
18433 /* Parse args required to build the message */
18434 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18436 if (unformat (input, "disable"))
18439 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
18442 ip_addr_version (&ip) = IP4;
18445 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
18448 ip_addr_version (&ip) = IP6;
18452 errmsg ("parse error '%U'", format_unformat_error, input);
18457 M (ONE_USE_PETR, mp);
18459 mp->is_add = is_add;
18462 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
18464 clib_memcpy (mp->address, &ip, 4);
18466 clib_memcpy (mp->address, &ip, 16);
18472 /* wait for reply */
18477 #define api_lisp_use_petr api_one_use_petr
18480 api_show_one_nsh_mapping (vat_main_t * vam)
18482 vl_api_show_one_use_petr_t *mp;
18485 if (!vam->json_output)
18487 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
18490 M (SHOW_ONE_NSH_MAPPING, mp);
18494 /* Wait for a reply... */
18500 api_show_one_use_petr (vat_main_t * vam)
18502 vl_api_show_one_use_petr_t *mp;
18505 if (!vam->json_output)
18507 print (vam->ofp, "%=20s", "Proxy-ETR status:");
18510 M (SHOW_ONE_USE_PETR, mp);
18514 /* Wait for a reply... */
18519 #define api_show_lisp_use_petr api_show_one_use_petr
18522 * Add/delete mapping between vni and vrf
18525 api_one_eid_table_add_del_map (vat_main_t * vam)
18527 unformat_input_t *input = vam->input;
18528 vl_api_one_eid_table_add_del_map_t *mp;
18529 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
18530 u32 vni, vrf, bd_index;
18533 /* Parse args required to build the message */
18534 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18536 if (unformat (input, "del"))
18538 else if (unformat (input, "vrf %d", &vrf))
18540 else if (unformat (input, "bd_index %d", &bd_index))
18542 else if (unformat (input, "vni %d", &vni))
18548 if (!vni_set || (!vrf_set && !bd_index_set))
18550 errmsg ("missing arguments!");
18554 if (vrf_set && bd_index_set)
18556 errmsg ("error: both vrf and bd entered!");
18560 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
18562 mp->is_add = is_add;
18563 mp->vni = htonl (vni);
18564 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
18565 mp->is_l2 = bd_index_set;
18570 /* wait for reply */
18575 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
18578 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
18580 u32 *action = va_arg (*args, u32 *);
18583 if (unformat (input, "%s", &s))
18585 if (!strcmp ((char *) s, "no-action"))
18587 else if (!strcmp ((char *) s, "natively-forward"))
18589 else if (!strcmp ((char *) s, "send-map-request"))
18591 else if (!strcmp ((char *) s, "drop"))
18595 clib_warning ("invalid action: '%s'", s);
18607 * Add/del remote mapping to/from ONE control plane
18609 * @param vam vpp API test context
18610 * @return return code
18613 api_one_add_del_remote_mapping (vat_main_t * vam)
18615 unformat_input_t *input = vam->input;
18616 vl_api_one_add_del_remote_mapping_t *mp;
18618 lisp_eid_vat_t _eid, *eid = &_eid;
18619 lisp_eid_vat_t _seid, *seid = &_seid;
18620 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
18621 u32 action = ~0, p, w, data_len;
18622 ip4_address_t rloc4;
18623 ip6_address_t rloc6;
18624 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
18627 clib_memset (&rloc, 0, sizeof (rloc));
18629 /* Parse args required to build the message */
18630 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18632 if (unformat (input, "del-all"))
18636 else if (unformat (input, "del"))
18640 else if (unformat (input, "add"))
18644 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
18648 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
18652 else if (unformat (input, "vni %d", &vni))
18656 else if (unformat (input, "p %d w %d", &p, &w))
18660 errmsg ("No RLOC configured for setting priority/weight!");
18663 curr_rloc->priority = p;
18664 curr_rloc->weight = w;
18666 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
18669 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
18670 vec_add1 (rlocs, rloc);
18671 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18673 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
18676 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
18677 vec_add1 (rlocs, rloc);
18678 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18680 else if (unformat (input, "action %U",
18681 unformat_negative_mapping_action, &action))
18687 clib_warning ("parse error '%U'", format_unformat_error, input);
18694 errmsg ("missing params!");
18698 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
18700 errmsg ("no action set for negative map-reply!");
18704 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
18706 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
18707 mp->is_add = is_add;
18708 mp->vni = htonl (vni);
18709 mp->action = (u8) action;
18710 mp->is_src_dst = seid_set;
18711 mp->eid_len = eid->len;
18712 mp->seid_len = seid->len;
18713 mp->del_all = del_all;
18714 mp->eid_type = eid->type;
18715 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
18716 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
18718 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
18719 clib_memcpy (mp->rlocs, rlocs, data_len);
18725 /* Wait for a reply... */
18730 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
18733 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
18734 * forwarding entries in data-plane accordingly.
18736 * @param vam vpp API test context
18737 * @return return code
18740 api_one_add_del_adjacency (vat_main_t * vam)
18742 unformat_input_t *input = vam->input;
18743 vl_api_one_add_del_adjacency_t *mp;
18745 ip4_address_t leid4, reid4;
18746 ip6_address_t leid6, reid6;
18747 u8 reid_mac[6] = { 0 };
18748 u8 leid_mac[6] = { 0 };
18749 u8 reid_type, leid_type;
18750 u32 leid_len = 0, reid_len = 0, len;
18754 leid_type = reid_type = (u8) ~ 0;
18756 /* Parse args required to build the message */
18757 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18759 if (unformat (input, "del"))
18763 else if (unformat (input, "add"))
18767 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
18770 reid_type = 0; /* ipv4 */
18773 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
18776 reid_type = 1; /* ipv6 */
18779 else if (unformat (input, "reid %U", unformat_ethernet_address,
18782 reid_type = 2; /* mac */
18784 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
18787 leid_type = 0; /* ipv4 */
18790 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
18793 leid_type = 1; /* ipv6 */
18796 else if (unformat (input, "leid %U", unformat_ethernet_address,
18799 leid_type = 2; /* mac */
18801 else if (unformat (input, "vni %d", &vni))
18807 errmsg ("parse error '%U'", format_unformat_error, input);
18812 if ((u8) ~ 0 == reid_type)
18814 errmsg ("missing params!");
18818 if (leid_type != reid_type)
18820 errmsg ("remote and local EIDs are of different types!");
18824 M (ONE_ADD_DEL_ADJACENCY, mp);
18825 mp->is_add = is_add;
18826 mp->vni = htonl (vni);
18827 mp->leid_len = leid_len;
18828 mp->reid_len = reid_len;
18829 mp->eid_type = reid_type;
18831 switch (mp->eid_type)
18834 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
18835 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
18838 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
18839 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
18842 clib_memcpy (mp->leid, leid_mac, 6);
18843 clib_memcpy (mp->reid, reid_mac, 6);
18846 errmsg ("unknown EID type %d!", mp->eid_type);
18853 /* Wait for a reply... */
18858 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
18861 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
18863 u32 *mode = va_arg (*args, u32 *);
18865 if (unformat (input, "lisp"))
18867 else if (unformat (input, "vxlan"))
18876 api_gpe_get_encap_mode (vat_main_t * vam)
18878 vl_api_gpe_get_encap_mode_t *mp;
18881 /* Construct the API message */
18882 M (GPE_GET_ENCAP_MODE, mp);
18887 /* Wait for a reply... */
18893 api_gpe_set_encap_mode (vat_main_t * vam)
18895 unformat_input_t *input = vam->input;
18896 vl_api_gpe_set_encap_mode_t *mp;
18900 /* Parse args required to build the message */
18901 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18903 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
18909 /* Construct the API message */
18910 M (GPE_SET_ENCAP_MODE, mp);
18917 /* Wait for a reply... */
18923 api_lisp_gpe_add_del_iface (vat_main_t * vam)
18925 unformat_input_t *input = vam->input;
18926 vl_api_gpe_add_del_iface_t *mp;
18927 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
18928 u32 dp_table = 0, vni = 0;
18931 /* Parse args required to build the message */
18932 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18934 if (unformat (input, "up"))
18939 else if (unformat (input, "down"))
18944 else if (unformat (input, "table_id %d", &dp_table))
18948 else if (unformat (input, "bd_id %d", &dp_table))
18953 else if (unformat (input, "vni %d", &vni))
18961 if (action_set == 0)
18963 errmsg ("Action not set");
18966 if (dp_table_set == 0 || vni_set == 0)
18968 errmsg ("vni and dp_table must be set");
18972 /* Construct the API message */
18973 M (GPE_ADD_DEL_IFACE, mp);
18975 mp->is_add = is_add;
18976 mp->dp_table = clib_host_to_net_u32 (dp_table);
18978 mp->vni = clib_host_to_net_u32 (vni);
18983 /* Wait for a reply... */
18989 api_one_map_register_fallback_threshold (vat_main_t * vam)
18991 unformat_input_t *input = vam->input;
18992 vl_api_one_map_register_fallback_threshold_t *mp;
18997 /* Parse args required to build the message */
18998 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19000 if (unformat (input, "%u", &value))
19004 clib_warning ("parse error '%U'", format_unformat_error, input);
19011 errmsg ("fallback threshold value is missing!");
19015 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
19016 mp->value = clib_host_to_net_u32 (value);
19021 /* Wait for a reply... */
19027 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
19029 vl_api_show_one_map_register_fallback_threshold_t *mp;
19032 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
19037 /* Wait for a reply... */
19043 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
19045 u32 *proto = va_arg (*args, u32 *);
19047 if (unformat (input, "udp"))
19049 else if (unformat (input, "api"))
19058 api_one_set_transport_protocol (vat_main_t * vam)
19060 unformat_input_t *input = vam->input;
19061 vl_api_one_set_transport_protocol_t *mp;
19066 /* Parse args required to build the message */
19067 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19069 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
19073 clib_warning ("parse error '%U'", format_unformat_error, input);
19080 errmsg ("Transport protocol missing!");
19084 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
19085 mp->protocol = (u8) protocol;
19090 /* Wait for a reply... */
19096 api_one_get_transport_protocol (vat_main_t * vam)
19098 vl_api_one_get_transport_protocol_t *mp;
19101 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
19106 /* Wait for a reply... */
19112 api_one_map_register_set_ttl (vat_main_t * vam)
19114 unformat_input_t *input = vam->input;
19115 vl_api_one_map_register_set_ttl_t *mp;
19120 /* Parse args required to build the message */
19121 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19123 if (unformat (input, "%u", &ttl))
19127 clib_warning ("parse error '%U'", format_unformat_error, input);
19134 errmsg ("TTL value missing!");
19138 M (ONE_MAP_REGISTER_SET_TTL, mp);
19139 mp->ttl = clib_host_to_net_u32 (ttl);
19144 /* Wait for a reply... */
19150 api_show_one_map_register_ttl (vat_main_t * vam)
19152 vl_api_show_one_map_register_ttl_t *mp;
19155 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
19160 /* Wait for a reply... */
19166 * Add/del map request itr rlocs from ONE control plane and updates
19168 * @param vam vpp API test context
19169 * @return return code
19172 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
19174 unformat_input_t *input = vam->input;
19175 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
19176 u8 *locator_set_name = 0;
19177 u8 locator_set_name_set = 0;
19181 /* Parse args required to build the message */
19182 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19184 if (unformat (input, "del"))
19188 else if (unformat (input, "%_%v%_", &locator_set_name))
19190 locator_set_name_set = 1;
19194 clib_warning ("parse error '%U'", format_unformat_error, input);
19199 if (is_add && !locator_set_name_set)
19201 errmsg ("itr-rloc is not set!");
19205 if (is_add && vec_len (locator_set_name) > 64)
19207 errmsg ("itr-rloc locator-set name too long");
19208 vec_free (locator_set_name);
19212 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
19213 mp->is_add = is_add;
19216 clib_memcpy (mp->locator_set_name, locator_set_name,
19217 vec_len (locator_set_name));
19221 clib_memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
19223 vec_free (locator_set_name);
19228 /* Wait for a reply... */
19233 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
19236 api_one_locator_dump (vat_main_t * vam)
19238 unformat_input_t *input = vam->input;
19239 vl_api_one_locator_dump_t *mp;
19240 vl_api_control_ping_t *mp_ping;
19241 u8 is_index_set = 0, is_name_set = 0;
19246 /* Parse args required to build the message */
19247 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19249 if (unformat (input, "ls_name %_%v%_", &ls_name))
19253 else if (unformat (input, "ls_index %d", &ls_index))
19259 errmsg ("parse error '%U'", format_unformat_error, input);
19264 if (!is_index_set && !is_name_set)
19266 errmsg ("error: expected one of index or name!");
19270 if (is_index_set && is_name_set)
19272 errmsg ("error: only one param expected!");
19276 if (vec_len (ls_name) > 62)
19278 errmsg ("error: locator set name too long!");
19282 if (!vam->json_output)
19284 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
19287 M (ONE_LOCATOR_DUMP, mp);
19288 mp->is_index_set = is_index_set;
19291 mp->ls_index = clib_host_to_net_u32 (ls_index);
19294 vec_add1 (ls_name, 0);
19295 strncpy ((char *) mp->ls_name, (char *) ls_name,
19296 sizeof (mp->ls_name) - 1);
19302 /* Use a control ping for synchronization */
19303 MPING (CONTROL_PING, mp_ping);
19306 /* Wait for a reply... */
19311 #define api_lisp_locator_dump api_one_locator_dump
19314 api_one_locator_set_dump (vat_main_t * vam)
19316 vl_api_one_locator_set_dump_t *mp;
19317 vl_api_control_ping_t *mp_ping;
19318 unformat_input_t *input = vam->input;
19322 /* Parse args required to build the message */
19323 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19325 if (unformat (input, "local"))
19329 else if (unformat (input, "remote"))
19335 errmsg ("parse error '%U'", format_unformat_error, input);
19340 if (!vam->json_output)
19342 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
19345 M (ONE_LOCATOR_SET_DUMP, mp);
19347 mp->filter = filter;
19352 /* Use a control ping for synchronization */
19353 MPING (CONTROL_PING, mp_ping);
19356 /* Wait for a reply... */
19361 #define api_lisp_locator_set_dump api_one_locator_set_dump
19364 api_one_eid_table_map_dump (vat_main_t * vam)
19368 unformat_input_t *input = vam->input;
19369 vl_api_one_eid_table_map_dump_t *mp;
19370 vl_api_control_ping_t *mp_ping;
19373 /* Parse args required to build the message */
19374 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19376 if (unformat (input, "l2"))
19381 else if (unformat (input, "l3"))
19388 errmsg ("parse error '%U'", format_unformat_error, input);
19395 errmsg ("expected one of 'l2' or 'l3' parameter!");
19399 if (!vam->json_output)
19401 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
19404 M (ONE_EID_TABLE_MAP_DUMP, mp);
19410 /* Use a control ping for synchronization */
19411 MPING (CONTROL_PING, mp_ping);
19414 /* Wait for a reply... */
19419 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
19422 api_one_eid_table_vni_dump (vat_main_t * vam)
19424 vl_api_one_eid_table_vni_dump_t *mp;
19425 vl_api_control_ping_t *mp_ping;
19428 if (!vam->json_output)
19430 print (vam->ofp, "VNI");
19433 M (ONE_EID_TABLE_VNI_DUMP, mp);
19438 /* Use a control ping for synchronization */
19439 MPING (CONTROL_PING, mp_ping);
19442 /* Wait for a reply... */
19447 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
19450 api_one_eid_table_dump (vat_main_t * vam)
19452 unformat_input_t *i = vam->input;
19453 vl_api_one_eid_table_dump_t *mp;
19454 vl_api_control_ping_t *mp_ping;
19455 struct in_addr ip4;
19456 struct in6_addr ip6;
19458 u8 eid_type = ~0, eid_set = 0;
19459 u32 prefix_length = ~0, t, vni = 0;
19462 lisp_nsh_api_t nsh;
19464 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19466 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
19472 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
19478 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
19483 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
19488 else if (unformat (i, "vni %d", &t))
19492 else if (unformat (i, "local"))
19496 else if (unformat (i, "remote"))
19502 errmsg ("parse error '%U'", format_unformat_error, i);
19507 if (!vam->json_output)
19509 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
19510 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
19513 M (ONE_EID_TABLE_DUMP, mp);
19515 mp->filter = filter;
19519 mp->vni = htonl (vni);
19520 mp->eid_type = eid_type;
19524 mp->prefix_length = prefix_length;
19525 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
19528 mp->prefix_length = prefix_length;
19529 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
19532 clib_memcpy (mp->eid, mac, sizeof (mac));
19535 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
19538 errmsg ("unknown EID type %d!", eid_type);
19546 /* Use a control ping for synchronization */
19547 MPING (CONTROL_PING, mp_ping);
19550 /* Wait for a reply... */
19555 #define api_lisp_eid_table_dump api_one_eid_table_dump
19558 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
19560 unformat_input_t *i = vam->input;
19561 vl_api_gpe_fwd_entries_get_t *mp;
19566 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19568 if (unformat (i, "vni %d", &vni))
19574 errmsg ("parse error '%U'", format_unformat_error, i);
19581 errmsg ("vni not set!");
19585 if (!vam->json_output)
19587 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
19591 M (GPE_FWD_ENTRIES_GET, mp);
19592 mp->vni = clib_host_to_net_u32 (vni);
19597 /* Wait for a reply... */
19602 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
19603 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
19604 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
19605 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
19606 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
19607 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
19608 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
19609 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
19612 api_one_adjacencies_get (vat_main_t * vam)
19614 unformat_input_t *i = vam->input;
19615 vl_api_one_adjacencies_get_t *mp;
19620 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19622 if (unformat (i, "vni %d", &vni))
19628 errmsg ("parse error '%U'", format_unformat_error, i);
19635 errmsg ("vni not set!");
19639 if (!vam->json_output)
19641 print (vam->ofp, "%s %40s", "leid", "reid");
19644 M (ONE_ADJACENCIES_GET, mp);
19645 mp->vni = clib_host_to_net_u32 (vni);
19650 /* Wait for a reply... */
19655 #define api_lisp_adjacencies_get api_one_adjacencies_get
19658 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
19660 unformat_input_t *i = vam->input;
19661 vl_api_gpe_native_fwd_rpaths_get_t *mp;
19663 u8 ip_family_set = 0, is_ip4 = 1;
19665 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19667 if (unformat (i, "ip4"))
19672 else if (unformat (i, "ip6"))
19679 errmsg ("parse error '%U'", format_unformat_error, i);
19684 if (!ip_family_set)
19686 errmsg ("ip family not set!");
19690 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
19691 mp->is_ip4 = is_ip4;
19696 /* Wait for a reply... */
19702 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
19704 vl_api_gpe_fwd_entry_vnis_get_t *mp;
19707 if (!vam->json_output)
19709 print (vam->ofp, "VNIs");
19712 M (GPE_FWD_ENTRY_VNIS_GET, mp);
19717 /* Wait for a reply... */
19723 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
19725 unformat_input_t *i = vam->input;
19726 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
19728 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
19729 struct in_addr ip4;
19730 struct in6_addr ip6;
19731 u32 table_id = 0, nh_sw_if_index = ~0;
19733 clib_memset (&ip4, 0, sizeof (ip4));
19734 clib_memset (&ip6, 0, sizeof (ip6));
19736 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19738 if (unformat (i, "del"))
19740 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
19741 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19746 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
19747 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19752 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
19756 nh_sw_if_index = ~0;
19758 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
19762 nh_sw_if_index = ~0;
19764 else if (unformat (i, "table %d", &table_id))
19768 errmsg ("parse error '%U'", format_unformat_error, i);
19775 errmsg ("nh addr not set!");
19779 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
19780 mp->is_add = is_add;
19781 mp->table_id = clib_host_to_net_u32 (table_id);
19782 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
19783 mp->is_ip4 = is_ip4;
19785 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
19787 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
19792 /* Wait for a reply... */
19798 api_one_map_server_dump (vat_main_t * vam)
19800 vl_api_one_map_server_dump_t *mp;
19801 vl_api_control_ping_t *mp_ping;
19804 if (!vam->json_output)
19806 print (vam->ofp, "%=20s", "Map server");
19809 M (ONE_MAP_SERVER_DUMP, mp);
19813 /* Use a control ping for synchronization */
19814 MPING (CONTROL_PING, mp_ping);
19817 /* Wait for a reply... */
19822 #define api_lisp_map_server_dump api_one_map_server_dump
19825 api_one_map_resolver_dump (vat_main_t * vam)
19827 vl_api_one_map_resolver_dump_t *mp;
19828 vl_api_control_ping_t *mp_ping;
19831 if (!vam->json_output)
19833 print (vam->ofp, "%=20s", "Map resolver");
19836 M (ONE_MAP_RESOLVER_DUMP, mp);
19840 /* Use a control ping for synchronization */
19841 MPING (CONTROL_PING, mp_ping);
19844 /* Wait for a reply... */
19849 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
19852 api_one_stats_flush (vat_main_t * vam)
19854 vl_api_one_stats_flush_t *mp;
19857 M (ONE_STATS_FLUSH, mp);
19864 api_one_stats_dump (vat_main_t * vam)
19866 vl_api_one_stats_dump_t *mp;
19867 vl_api_control_ping_t *mp_ping;
19870 M (ONE_STATS_DUMP, mp);
19874 /* Use a control ping for synchronization */
19875 MPING (CONTROL_PING, mp_ping);
19878 /* Wait for a reply... */
19884 api_show_one_status (vat_main_t * vam)
19886 vl_api_show_one_status_t *mp;
19889 if (!vam->json_output)
19891 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
19894 M (SHOW_ONE_STATUS, mp);
19897 /* Wait for a reply... */
19902 #define api_show_lisp_status api_show_one_status
19905 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
19907 vl_api_gpe_fwd_entry_path_dump_t *mp;
19908 vl_api_control_ping_t *mp_ping;
19909 unformat_input_t *i = vam->input;
19910 u32 fwd_entry_index = ~0;
19913 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19915 if (unformat (i, "index %d", &fwd_entry_index))
19921 if (~0 == fwd_entry_index)
19923 errmsg ("no index specified!");
19927 if (!vam->json_output)
19929 print (vam->ofp, "first line");
19932 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
19936 /* Use a control ping for synchronization */
19937 MPING (CONTROL_PING, mp_ping);
19940 /* Wait for a reply... */
19946 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
19948 vl_api_one_get_map_request_itr_rlocs_t *mp;
19951 if (!vam->json_output)
19953 print (vam->ofp, "%=20s", "itr-rlocs:");
19956 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
19959 /* Wait for a reply... */
19964 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
19967 api_af_packet_create (vat_main_t * vam)
19969 unformat_input_t *i = vam->input;
19970 vl_api_af_packet_create_t *mp;
19971 u8 *host_if_name = 0;
19973 u8 random_hw_addr = 1;
19976 clib_memset (hw_addr, 0, sizeof (hw_addr));
19978 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19980 if (unformat (i, "name %s", &host_if_name))
19981 vec_add1 (host_if_name, 0);
19982 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19983 random_hw_addr = 0;
19988 if (!vec_len (host_if_name))
19990 errmsg ("host-interface name must be specified");
19994 if (vec_len (host_if_name) > 64)
19996 errmsg ("host-interface name too long");
20000 M (AF_PACKET_CREATE, mp);
20002 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
20003 clib_memcpy (mp->hw_addr, hw_addr, 6);
20004 mp->use_random_hw_addr = random_hw_addr;
20005 vec_free (host_if_name);
20013 fprintf (vam->ofp ? vam->ofp : stderr,
20014 " new sw_if_index = %d\n", vam->sw_if_index);
20021 api_af_packet_delete (vat_main_t * vam)
20023 unformat_input_t *i = vam->input;
20024 vl_api_af_packet_delete_t *mp;
20025 u8 *host_if_name = 0;
20028 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20030 if (unformat (i, "name %s", &host_if_name))
20031 vec_add1 (host_if_name, 0);
20036 if (!vec_len (host_if_name))
20038 errmsg ("host-interface name must be specified");
20042 if (vec_len (host_if_name) > 64)
20044 errmsg ("host-interface name too long");
20048 M (AF_PACKET_DELETE, mp);
20050 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
20051 vec_free (host_if_name);
20058 static void vl_api_af_packet_details_t_handler
20059 (vl_api_af_packet_details_t * mp)
20061 vat_main_t *vam = &vat_main;
20063 print (vam->ofp, "%-16s %d",
20064 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
20067 static void vl_api_af_packet_details_t_handler_json
20068 (vl_api_af_packet_details_t * mp)
20070 vat_main_t *vam = &vat_main;
20071 vat_json_node_t *node = NULL;
20073 if (VAT_JSON_ARRAY != vam->json_tree.type)
20075 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20076 vat_json_init_array (&vam->json_tree);
20078 node = vat_json_array_add (&vam->json_tree);
20080 vat_json_init_object (node);
20081 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
20082 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
20086 api_af_packet_dump (vat_main_t * vam)
20088 vl_api_af_packet_dump_t *mp;
20089 vl_api_control_ping_t *mp_ping;
20092 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
20093 /* Get list of tap interfaces */
20094 M (AF_PACKET_DUMP, mp);
20097 /* Use a control ping for synchronization */
20098 MPING (CONTROL_PING, mp_ping);
20106 api_policer_add_del (vat_main_t * vam)
20108 unformat_input_t *i = vam->input;
20109 vl_api_policer_add_del_t *mp;
20119 u8 color_aware = 0;
20120 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
20123 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
20124 conform_action.dscp = 0;
20125 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
20126 exceed_action.dscp = 0;
20127 violate_action.action_type = SSE2_QOS_ACTION_DROP;
20128 violate_action.dscp = 0;
20130 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20132 if (unformat (i, "del"))
20134 else if (unformat (i, "name %s", &name))
20135 vec_add1 (name, 0);
20136 else if (unformat (i, "cir %u", &cir))
20138 else if (unformat (i, "eir %u", &eir))
20140 else if (unformat (i, "cb %u", &cb))
20142 else if (unformat (i, "eb %u", &eb))
20144 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
20147 else if (unformat (i, "round_type %U", unformat_policer_round_type,
20150 else if (unformat (i, "type %U", unformat_policer_type, &type))
20152 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
20155 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
20158 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
20161 else if (unformat (i, "color-aware"))
20167 if (!vec_len (name))
20169 errmsg ("policer name must be specified");
20173 if (vec_len (name) > 64)
20175 errmsg ("policer name too long");
20179 M (POLICER_ADD_DEL, mp);
20181 clib_memcpy (mp->name, name, vec_len (name));
20183 mp->is_add = is_add;
20184 mp->cir = ntohl (cir);
20185 mp->eir = ntohl (eir);
20186 mp->cb = clib_net_to_host_u64 (cb);
20187 mp->eb = clib_net_to_host_u64 (eb);
20188 mp->rate_type = rate_type;
20189 mp->round_type = round_type;
20191 mp->conform_action_type = conform_action.action_type;
20192 mp->conform_dscp = conform_action.dscp;
20193 mp->exceed_action_type = exceed_action.action_type;
20194 mp->exceed_dscp = exceed_action.dscp;
20195 mp->violate_action_type = violate_action.action_type;
20196 mp->violate_dscp = violate_action.dscp;
20197 mp->color_aware = color_aware;
20205 api_policer_dump (vat_main_t * vam)
20207 unformat_input_t *i = vam->input;
20208 vl_api_policer_dump_t *mp;
20209 vl_api_control_ping_t *mp_ping;
20210 u8 *match_name = 0;
20211 u8 match_name_valid = 0;
20214 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20216 if (unformat (i, "name %s", &match_name))
20218 vec_add1 (match_name, 0);
20219 match_name_valid = 1;
20225 M (POLICER_DUMP, mp);
20226 mp->match_name_valid = match_name_valid;
20227 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
20228 vec_free (match_name);
20232 /* Use a control ping for synchronization */
20233 MPING (CONTROL_PING, mp_ping);
20236 /* Wait for a reply... */
20242 api_policer_classify_set_interface (vat_main_t * vam)
20244 unformat_input_t *i = vam->input;
20245 vl_api_policer_classify_set_interface_t *mp;
20247 int sw_if_index_set;
20248 u32 ip4_table_index = ~0;
20249 u32 ip6_table_index = ~0;
20250 u32 l2_table_index = ~0;
20254 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20256 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20257 sw_if_index_set = 1;
20258 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20259 sw_if_index_set = 1;
20260 else if (unformat (i, "del"))
20262 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20264 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20266 else if (unformat (i, "l2-table %d", &l2_table_index))
20270 clib_warning ("parse error '%U'", format_unformat_error, i);
20275 if (sw_if_index_set == 0)
20277 errmsg ("missing interface name or sw_if_index");
20281 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
20283 mp->sw_if_index = ntohl (sw_if_index);
20284 mp->ip4_table_index = ntohl (ip4_table_index);
20285 mp->ip6_table_index = ntohl (ip6_table_index);
20286 mp->l2_table_index = ntohl (l2_table_index);
20287 mp->is_add = is_add;
20295 api_policer_classify_dump (vat_main_t * vam)
20297 unformat_input_t *i = vam->input;
20298 vl_api_policer_classify_dump_t *mp;
20299 vl_api_control_ping_t *mp_ping;
20300 u8 type = POLICER_CLASSIFY_N_TABLES;
20303 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
20307 errmsg ("classify table type must be specified");
20311 if (!vam->json_output)
20313 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20316 M (POLICER_CLASSIFY_DUMP, mp);
20321 /* Use a control ping for synchronization */
20322 MPING (CONTROL_PING, mp_ping);
20325 /* Wait for a reply... */
20331 api_netmap_create (vat_main_t * vam)
20333 unformat_input_t *i = vam->input;
20334 vl_api_netmap_create_t *mp;
20337 u8 random_hw_addr = 1;
20342 clib_memset (hw_addr, 0, sizeof (hw_addr));
20344 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20346 if (unformat (i, "name %s", &if_name))
20347 vec_add1 (if_name, 0);
20348 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
20349 random_hw_addr = 0;
20350 else if (unformat (i, "pipe"))
20352 else if (unformat (i, "master"))
20354 else if (unformat (i, "slave"))
20360 if (!vec_len (if_name))
20362 errmsg ("interface name must be specified");
20366 if (vec_len (if_name) > 64)
20368 errmsg ("interface name too long");
20372 M (NETMAP_CREATE, mp);
20374 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20375 clib_memcpy (mp->hw_addr, hw_addr, 6);
20376 mp->use_random_hw_addr = random_hw_addr;
20377 mp->is_pipe = is_pipe;
20378 mp->is_master = is_master;
20379 vec_free (if_name);
20387 api_netmap_delete (vat_main_t * vam)
20389 unformat_input_t *i = vam->input;
20390 vl_api_netmap_delete_t *mp;
20394 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20396 if (unformat (i, "name %s", &if_name))
20397 vec_add1 (if_name, 0);
20402 if (!vec_len (if_name))
20404 errmsg ("interface name must be specified");
20408 if (vec_len (if_name) > 64)
20410 errmsg ("interface name too long");
20414 M (NETMAP_DELETE, mp);
20416 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20417 vec_free (if_name);
20425 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
20427 if (fp->afi == IP46_TYPE_IP6)
20429 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20430 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20431 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20432 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20433 format_ip6_address, fp->next_hop);
20434 else if (fp->afi == IP46_TYPE_IP4)
20436 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20437 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20438 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20439 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20440 format_ip4_address, fp->next_hop);
20444 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
20445 vl_api_fib_path_t * fp)
20447 struct in_addr ip4;
20448 struct in6_addr ip6;
20450 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20451 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20452 vat_json_object_add_uint (node, "is_local", fp->is_local);
20453 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20454 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20455 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20456 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20457 if (fp->afi == IP46_TYPE_IP4)
20459 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20460 vat_json_object_add_ip4 (node, "next_hop", ip4);
20462 else if (fp->afi == IP46_TYPE_IP6)
20464 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20465 vat_json_object_add_ip6 (node, "next_hop", ip6);
20470 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
20472 vat_main_t *vam = &vat_main;
20473 int count = ntohl (mp->mt_count);
20474 vl_api_fib_path_t *fp;
20477 print (vam->ofp, "[%d]: sw_if_index %d via:",
20478 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
20480 for (i = 0; i < count; i++)
20482 vl_api_mpls_fib_path_print (vam, fp);
20486 print (vam->ofp, "");
20489 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
20490 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
20493 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
20495 vat_main_t *vam = &vat_main;
20496 vat_json_node_t *node = NULL;
20497 int count = ntohl (mp->mt_count);
20498 vl_api_fib_path_t *fp;
20501 if (VAT_JSON_ARRAY != vam->json_tree.type)
20503 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20504 vat_json_init_array (&vam->json_tree);
20506 node = vat_json_array_add (&vam->json_tree);
20508 vat_json_init_object (node);
20509 vat_json_object_add_uint (node, "tunnel_index",
20510 ntohl (mp->mt_tunnel_index));
20511 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
20513 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
20516 for (i = 0; i < count; i++)
20518 vl_api_mpls_fib_path_json_print (node, fp);
20524 api_mpls_tunnel_dump (vat_main_t * vam)
20526 vl_api_mpls_tunnel_dump_t *mp;
20527 vl_api_control_ping_t *mp_ping;
20528 u32 sw_if_index = ~0;
20531 /* Parse args required to build the message */
20532 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
20534 if (unformat (vam->input, "sw_if_index %d", &sw_if_index))
20538 print (vam->ofp, " sw_if_index %d", sw_if_index);
20540 M (MPLS_TUNNEL_DUMP, mp);
20541 mp->sw_if_index = htonl (sw_if_index);
20544 /* Use a control ping for synchronization */
20545 MPING (CONTROL_PING, mp_ping);
20552 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
20553 #define vl_api_mpls_fib_details_t_print vl_noop_handler
20557 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
20559 vat_main_t *vam = &vat_main;
20560 int count = ntohl (mp->count);
20561 vl_api_fib_path_t *fp;
20565 "table-id %d, label %u, ess_bit %u",
20566 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
20568 for (i = 0; i < count; i++)
20570 vl_api_mpls_fib_path_print (vam, fp);
20575 static void vl_api_mpls_fib_details_t_handler_json
20576 (vl_api_mpls_fib_details_t * mp)
20578 vat_main_t *vam = &vat_main;
20579 int count = ntohl (mp->count);
20580 vat_json_node_t *node = NULL;
20581 vl_api_fib_path_t *fp;
20584 if (VAT_JSON_ARRAY != vam->json_tree.type)
20586 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20587 vat_json_init_array (&vam->json_tree);
20589 node = vat_json_array_add (&vam->json_tree);
20591 vat_json_init_object (node);
20592 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20593 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
20594 vat_json_object_add_uint (node, "label", ntohl (mp->label));
20595 vat_json_object_add_uint (node, "path_count", count);
20597 for (i = 0; i < count; i++)
20599 vl_api_mpls_fib_path_json_print (node, fp);
20605 api_mpls_fib_dump (vat_main_t * vam)
20607 vl_api_mpls_fib_dump_t *mp;
20608 vl_api_control_ping_t *mp_ping;
20611 M (MPLS_FIB_DUMP, mp);
20614 /* Use a control ping for synchronization */
20615 MPING (CONTROL_PING, mp_ping);
20622 #define vl_api_ip_fib_details_t_endian vl_noop_handler
20623 #define vl_api_ip_fib_details_t_print vl_noop_handler
20626 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
20628 vat_main_t *vam = &vat_main;
20629 int count = ntohl (mp->count);
20630 vl_api_fib_path_t *fp;
20634 "table-id %d, prefix %U/%d stats-index %d",
20635 ntohl (mp->table_id), format_ip4_address, mp->address,
20636 mp->address_length, ntohl (mp->stats_index));
20638 for (i = 0; i < count; i++)
20640 if (fp->afi == IP46_TYPE_IP6)
20642 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20643 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U, "
20644 "next_hop_table %d",
20645 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20646 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20647 format_ip6_address, fp->next_hop, ntohl (fp->table_id));
20648 else if (fp->afi == IP46_TYPE_IP4)
20650 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20651 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U, "
20652 "next_hop_table %d",
20653 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20654 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20655 format_ip4_address, fp->next_hop, ntohl (fp->table_id));
20660 static void vl_api_ip_fib_details_t_handler_json
20661 (vl_api_ip_fib_details_t * mp)
20663 vat_main_t *vam = &vat_main;
20664 int count = ntohl (mp->count);
20665 vat_json_node_t *node = NULL;
20666 struct in_addr ip4;
20667 struct in6_addr ip6;
20668 vl_api_fib_path_t *fp;
20671 if (VAT_JSON_ARRAY != vam->json_tree.type)
20673 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20674 vat_json_init_array (&vam->json_tree);
20676 node = vat_json_array_add (&vam->json_tree);
20678 vat_json_init_object (node);
20679 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20680 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
20681 vat_json_object_add_ip4 (node, "prefix", ip4);
20682 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20683 vat_json_object_add_uint (node, "path_count", count);
20685 for (i = 0; i < count; i++)
20687 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20688 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20689 vat_json_object_add_uint (node, "is_local", fp->is_local);
20690 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20691 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20692 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20693 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20694 if (fp->afi == IP46_TYPE_IP4)
20696 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20697 vat_json_object_add_ip4 (node, "next_hop", ip4);
20699 else if (fp->afi == IP46_TYPE_IP6)
20701 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20702 vat_json_object_add_ip6 (node, "next_hop", ip6);
20708 api_ip_fib_dump (vat_main_t * vam)
20710 vl_api_ip_fib_dump_t *mp;
20711 vl_api_control_ping_t *mp_ping;
20714 M (IP_FIB_DUMP, mp);
20717 /* Use a control ping for synchronization */
20718 MPING (CONTROL_PING, mp_ping);
20726 api_ip_mfib_dump (vat_main_t * vam)
20728 vl_api_ip_mfib_dump_t *mp;
20729 vl_api_control_ping_t *mp_ping;
20732 M (IP_MFIB_DUMP, mp);
20735 /* Use a control ping for synchronization */
20736 MPING (CONTROL_PING, mp_ping);
20743 static void vl_api_ip_neighbor_details_t_handler
20744 (vl_api_ip_neighbor_details_t * mp)
20746 vat_main_t *vam = &vat_main;
20748 print (vam->ofp, "%c %U %U",
20749 (mp->is_static) ? 'S' : 'D',
20750 format_ethernet_address, &mp->mac_address,
20751 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
20755 static void vl_api_ip_neighbor_details_t_handler_json
20756 (vl_api_ip_neighbor_details_t * mp)
20759 vat_main_t *vam = &vat_main;
20760 vat_json_node_t *node;
20761 struct in_addr ip4;
20762 struct in6_addr ip6;
20764 if (VAT_JSON_ARRAY != vam->json_tree.type)
20766 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20767 vat_json_init_array (&vam->json_tree);
20769 node = vat_json_array_add (&vam->json_tree);
20771 vat_json_init_object (node);
20772 vat_json_object_add_string_copy (node, "flag",
20773 (mp->is_static) ? (u8 *) "static" : (u8 *)
20776 vat_json_object_add_string_copy (node, "link_layer",
20777 format (0, "%U", format_ethernet_address,
20778 &mp->mac_address));
20782 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
20783 vat_json_object_add_ip6 (node, "ip_address", ip6);
20787 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
20788 vat_json_object_add_ip4 (node, "ip_address", ip4);
20793 api_ip_neighbor_dump (vat_main_t * vam)
20795 unformat_input_t *i = vam->input;
20796 vl_api_ip_neighbor_dump_t *mp;
20797 vl_api_control_ping_t *mp_ping;
20799 u32 sw_if_index = ~0;
20802 /* Parse args required to build the message */
20803 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20805 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20807 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20809 else if (unformat (i, "ip6"))
20815 if (sw_if_index == ~0)
20817 errmsg ("missing interface name or sw_if_index");
20821 M (IP_NEIGHBOR_DUMP, mp);
20822 mp->is_ipv6 = (u8) is_ipv6;
20823 mp->sw_if_index = ntohl (sw_if_index);
20826 /* Use a control ping for synchronization */
20827 MPING (CONTROL_PING, mp_ping);
20834 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
20835 #define vl_api_ip6_fib_details_t_print vl_noop_handler
20838 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
20840 vat_main_t *vam = &vat_main;
20841 int count = ntohl (mp->count);
20842 vl_api_fib_path_t *fp;
20846 "table-id %d, prefix %U/%d stats-index %d",
20847 ntohl (mp->table_id), format_ip6_address, mp->address,
20848 mp->address_length, ntohl (mp->stats_index));
20850 for (i = 0; i < count; i++)
20852 if (fp->afi == IP46_TYPE_IP6)
20854 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20855 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20856 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20857 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20858 format_ip6_address, fp->next_hop);
20859 else if (fp->afi == IP46_TYPE_IP4)
20861 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20862 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20863 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20864 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20865 format_ip4_address, fp->next_hop);
20870 static void vl_api_ip6_fib_details_t_handler_json
20871 (vl_api_ip6_fib_details_t * mp)
20873 vat_main_t *vam = &vat_main;
20874 int count = ntohl (mp->count);
20875 vat_json_node_t *node = NULL;
20876 struct in_addr ip4;
20877 struct in6_addr ip6;
20878 vl_api_fib_path_t *fp;
20881 if (VAT_JSON_ARRAY != vam->json_tree.type)
20883 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20884 vat_json_init_array (&vam->json_tree);
20886 node = vat_json_array_add (&vam->json_tree);
20888 vat_json_init_object (node);
20889 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20890 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
20891 vat_json_object_add_ip6 (node, "prefix", ip6);
20892 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20893 vat_json_object_add_uint (node, "path_count", count);
20895 for (i = 0; i < count; i++)
20897 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20898 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20899 vat_json_object_add_uint (node, "is_local", fp->is_local);
20900 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20901 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20902 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20903 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20904 if (fp->afi == IP46_TYPE_IP4)
20906 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20907 vat_json_object_add_ip4 (node, "next_hop", ip4);
20909 else if (fp->afi == IP46_TYPE_IP6)
20911 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20912 vat_json_object_add_ip6 (node, "next_hop", ip6);
20918 api_ip6_fib_dump (vat_main_t * vam)
20920 vl_api_ip6_fib_dump_t *mp;
20921 vl_api_control_ping_t *mp_ping;
20924 M (IP6_FIB_DUMP, mp);
20927 /* Use a control ping for synchronization */
20928 MPING (CONTROL_PING, mp_ping);
20936 api_ip6_mfib_dump (vat_main_t * vam)
20938 vl_api_ip6_mfib_dump_t *mp;
20939 vl_api_control_ping_t *mp_ping;
20942 M (IP6_MFIB_DUMP, mp);
20945 /* Use a control ping for synchronization */
20946 MPING (CONTROL_PING, mp_ping);
20954 api_classify_table_ids (vat_main_t * vam)
20956 vl_api_classify_table_ids_t *mp;
20959 /* Construct the API message */
20960 M (CLASSIFY_TABLE_IDS, mp);
20969 api_classify_table_by_interface (vat_main_t * vam)
20971 unformat_input_t *input = vam->input;
20972 vl_api_classify_table_by_interface_t *mp;
20974 u32 sw_if_index = ~0;
20976 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20978 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20980 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20985 if (sw_if_index == ~0)
20987 errmsg ("missing interface name or sw_if_index");
20991 /* Construct the API message */
20992 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
20994 mp->sw_if_index = ntohl (sw_if_index);
21002 api_classify_table_info (vat_main_t * vam)
21004 unformat_input_t *input = vam->input;
21005 vl_api_classify_table_info_t *mp;
21009 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21011 if (unformat (input, "table_id %d", &table_id))
21016 if (table_id == ~0)
21018 errmsg ("missing table id");
21022 /* Construct the API message */
21023 M (CLASSIFY_TABLE_INFO, mp);
21025 mp->table_id = ntohl (table_id);
21033 api_classify_session_dump (vat_main_t * vam)
21035 unformat_input_t *input = vam->input;
21036 vl_api_classify_session_dump_t *mp;
21037 vl_api_control_ping_t *mp_ping;
21041 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21043 if (unformat (input, "table_id %d", &table_id))
21048 if (table_id == ~0)
21050 errmsg ("missing table id");
21054 /* Construct the API message */
21055 M (CLASSIFY_SESSION_DUMP, mp);
21057 mp->table_id = ntohl (table_id);
21060 /* Use a control ping for synchronization */
21061 MPING (CONTROL_PING, mp_ping);
21069 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
21071 vat_main_t *vam = &vat_main;
21073 print (vam->ofp, "collector_address %U, collector_port %d, "
21074 "src_address %U, vrf_id %d, path_mtu %u, "
21075 "template_interval %u, udp_checksum %d",
21076 format_ip4_address, mp->collector_address,
21077 ntohs (mp->collector_port),
21078 format_ip4_address, mp->src_address,
21079 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
21080 ntohl (mp->template_interval), mp->udp_checksum);
21083 vam->result_ready = 1;
21087 vl_api_ipfix_exporter_details_t_handler_json
21088 (vl_api_ipfix_exporter_details_t * mp)
21090 vat_main_t *vam = &vat_main;
21091 vat_json_node_t node;
21092 struct in_addr collector_address;
21093 struct in_addr src_address;
21095 vat_json_init_object (&node);
21096 clib_memcpy (&collector_address, &mp->collector_address,
21097 sizeof (collector_address));
21098 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
21099 vat_json_object_add_uint (&node, "collector_port",
21100 ntohs (mp->collector_port));
21101 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
21102 vat_json_object_add_ip4 (&node, "src_address", src_address);
21103 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
21104 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
21105 vat_json_object_add_uint (&node, "template_interval",
21106 ntohl (mp->template_interval));
21107 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
21109 vat_json_print (vam->ofp, &node);
21110 vat_json_free (&node);
21112 vam->result_ready = 1;
21116 api_ipfix_exporter_dump (vat_main_t * vam)
21118 vl_api_ipfix_exporter_dump_t *mp;
21121 /* Construct the API message */
21122 M (IPFIX_EXPORTER_DUMP, mp);
21131 api_ipfix_classify_stream_dump (vat_main_t * vam)
21133 vl_api_ipfix_classify_stream_dump_t *mp;
21136 /* Construct the API message */
21137 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
21148 vl_api_ipfix_classify_stream_details_t_handler
21149 (vl_api_ipfix_classify_stream_details_t * mp)
21151 vat_main_t *vam = &vat_main;
21152 print (vam->ofp, "domain_id %d, src_port %d",
21153 ntohl (mp->domain_id), ntohs (mp->src_port));
21155 vam->result_ready = 1;
21159 vl_api_ipfix_classify_stream_details_t_handler_json
21160 (vl_api_ipfix_classify_stream_details_t * mp)
21162 vat_main_t *vam = &vat_main;
21163 vat_json_node_t node;
21165 vat_json_init_object (&node);
21166 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
21167 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
21169 vat_json_print (vam->ofp, &node);
21170 vat_json_free (&node);
21172 vam->result_ready = 1;
21176 api_ipfix_classify_table_dump (vat_main_t * vam)
21178 vl_api_ipfix_classify_table_dump_t *mp;
21179 vl_api_control_ping_t *mp_ping;
21182 if (!vam->json_output)
21184 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
21185 "transport_protocol");
21188 /* Construct the API message */
21189 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
21194 /* Use a control ping for synchronization */
21195 MPING (CONTROL_PING, mp_ping);
21203 vl_api_ipfix_classify_table_details_t_handler
21204 (vl_api_ipfix_classify_table_details_t * mp)
21206 vat_main_t *vam = &vat_main;
21207 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
21208 mp->transport_protocol);
21212 vl_api_ipfix_classify_table_details_t_handler_json
21213 (vl_api_ipfix_classify_table_details_t * mp)
21215 vat_json_node_t *node = NULL;
21216 vat_main_t *vam = &vat_main;
21218 if (VAT_JSON_ARRAY != vam->json_tree.type)
21220 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21221 vat_json_init_array (&vam->json_tree);
21224 node = vat_json_array_add (&vam->json_tree);
21225 vat_json_init_object (node);
21227 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
21228 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
21229 vat_json_object_add_uint (node, "transport_protocol",
21230 mp->transport_protocol);
21234 api_sw_interface_span_enable_disable (vat_main_t * vam)
21236 unformat_input_t *i = vam->input;
21237 vl_api_sw_interface_span_enable_disable_t *mp;
21238 u32 src_sw_if_index = ~0;
21239 u32 dst_sw_if_index = ~0;
21244 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21247 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
21249 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
21253 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
21255 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
21257 else if (unformat (i, "disable"))
21259 else if (unformat (i, "rx"))
21261 else if (unformat (i, "tx"))
21263 else if (unformat (i, "both"))
21265 else if (unformat (i, "l2"))
21271 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
21273 mp->sw_if_index_from = htonl (src_sw_if_index);
21274 mp->sw_if_index_to = htonl (dst_sw_if_index);
21284 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
21287 vat_main_t *vam = &vat_main;
21288 u8 *sw_if_from_name = 0;
21289 u8 *sw_if_to_name = 0;
21290 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
21291 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
21292 char *states[] = { "none", "rx", "tx", "both" };
21296 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
21298 if ((u32) p->value[0] == sw_if_index_from)
21300 sw_if_from_name = (u8 *)(p->key);
21304 if ((u32) p->value[0] == sw_if_index_to)
21306 sw_if_to_name = (u8 *)(p->key);
21307 if (sw_if_from_name)
21312 print (vam->ofp, "%20s => %20s (%s) %s",
21313 sw_if_from_name, sw_if_to_name, states[mp->state],
21314 mp->is_l2 ? "l2" : "device");
21318 vl_api_sw_interface_span_details_t_handler_json
21319 (vl_api_sw_interface_span_details_t * mp)
21321 vat_main_t *vam = &vat_main;
21322 vat_json_node_t *node = NULL;
21323 u8 *sw_if_from_name = 0;
21324 u8 *sw_if_to_name = 0;
21325 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
21326 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
21330 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
21332 if ((u32) p->value[0] == sw_if_index_from)
21334 sw_if_from_name = (u8 *)(p->key);
21338 if ((u32) p->value[0] == sw_if_index_to)
21340 sw_if_to_name = (u8 *)(p->key);
21341 if (sw_if_from_name)
21347 if (VAT_JSON_ARRAY != vam->json_tree.type)
21349 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21350 vat_json_init_array (&vam->json_tree);
21352 node = vat_json_array_add (&vam->json_tree);
21354 vat_json_init_object (node);
21355 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
21356 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
21357 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
21358 if (0 != sw_if_to_name)
21360 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
21362 vat_json_object_add_uint (node, "state", mp->state);
21363 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
21367 api_sw_interface_span_dump (vat_main_t * vam)
21369 unformat_input_t *input = vam->input;
21370 vl_api_sw_interface_span_dump_t *mp;
21371 vl_api_control_ping_t *mp_ping;
21375 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21377 if (unformat (input, "l2"))
21383 M (SW_INTERFACE_SPAN_DUMP, mp);
21387 /* Use a control ping for synchronization */
21388 MPING (CONTROL_PING, mp_ping);
21396 api_pg_create_interface (vat_main_t * vam)
21398 unformat_input_t *input = vam->input;
21399 vl_api_pg_create_interface_t *mp;
21403 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21405 if (unformat (input, "if_id %d", &if_id))
21412 errmsg ("missing pg interface index");
21416 /* Construct the API message */
21417 M (PG_CREATE_INTERFACE, mp);
21419 mp->interface_id = ntohl (if_id);
21427 api_pg_capture (vat_main_t * vam)
21429 unformat_input_t *input = vam->input;
21430 vl_api_pg_capture_t *mp;
21435 u8 pcap_file_set = 0;
21438 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21440 if (unformat (input, "if_id %d", &if_id))
21442 else if (unformat (input, "pcap %s", &pcap_file))
21444 else if (unformat (input, "count %d", &count))
21446 else if (unformat (input, "disable"))
21453 errmsg ("missing pg interface index");
21456 if (pcap_file_set > 0)
21458 if (vec_len (pcap_file) > 255)
21460 errmsg ("pcap file name is too long");
21465 u32 name_len = vec_len (pcap_file);
21466 /* Construct the API message */
21467 M (PG_CAPTURE, mp);
21469 mp->interface_id = ntohl (if_id);
21470 mp->is_enabled = enable;
21471 mp->count = ntohl (count);
21472 mp->pcap_name_length = ntohl (name_len);
21473 if (pcap_file_set != 0)
21475 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
21477 vec_free (pcap_file);
21485 api_pg_enable_disable (vat_main_t * vam)
21487 unformat_input_t *input = vam->input;
21488 vl_api_pg_enable_disable_t *mp;
21491 u8 stream_name_set = 0;
21492 u8 *stream_name = 0;
21494 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21496 if (unformat (input, "stream %s", &stream_name))
21497 stream_name_set = 1;
21498 else if (unformat (input, "disable"))
21504 if (stream_name_set > 0)
21506 if (vec_len (stream_name) > 255)
21508 errmsg ("stream name too long");
21513 u32 name_len = vec_len (stream_name);
21514 /* Construct the API message */
21515 M (PG_ENABLE_DISABLE, mp);
21517 mp->is_enabled = enable;
21518 if (stream_name_set != 0)
21520 mp->stream_name_length = ntohl (name_len);
21521 clib_memcpy (mp->stream_name, stream_name, name_len);
21523 vec_free (stream_name);
21531 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
21533 unformat_input_t *input = vam->input;
21534 vl_api_ip_source_and_port_range_check_add_del_t *mp;
21536 u16 *low_ports = 0;
21537 u16 *high_ports = 0;
21540 ip4_address_t ip4_addr;
21541 ip6_address_t ip6_addr;
21550 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21552 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
21558 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
21563 else if (unformat (input, "vrf %d", &vrf_id))
21565 else if (unformat (input, "del"))
21567 else if (unformat (input, "port %d", &tmp))
21569 if (tmp == 0 || tmp > 65535)
21571 errmsg ("port %d out of range", tmp);
21575 this_hi = this_low + 1;
21576 vec_add1 (low_ports, this_low);
21577 vec_add1 (high_ports, this_hi);
21579 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
21581 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
21583 errmsg ("incorrect range parameters");
21587 /* Note: in debug CLI +1 is added to high before
21588 passing to real fn that does "the work"
21589 (ip_source_and_port_range_check_add_del).
21590 This fn is a wrapper around the binary API fn a
21591 control plane will call, which expects this increment
21592 to have occurred. Hence letting the binary API control
21593 plane fn do the increment for consistency between VAT
21594 and other control planes.
21597 vec_add1 (low_ports, this_low);
21598 vec_add1 (high_ports, this_hi);
21604 if (prefix_set == 0)
21606 errmsg ("<address>/<mask> not specified");
21612 errmsg ("VRF ID required, not specified");
21619 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21623 if (vec_len (low_ports) == 0)
21625 errmsg ("At least one port or port range required");
21629 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
21631 mp->is_add = is_add;
21636 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
21641 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
21644 mp->mask_length = length;
21645 mp->number_of_ranges = vec_len (low_ports);
21647 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
21648 vec_free (low_ports);
21650 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
21651 vec_free (high_ports);
21653 mp->vrf_id = ntohl (vrf_id);
21661 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
21663 unformat_input_t *input = vam->input;
21664 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
21665 u32 sw_if_index = ~0;
21667 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
21668 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
21672 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21674 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21676 else if (unformat (input, "sw_if_index %d", &sw_if_index))
21678 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
21680 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
21682 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
21684 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
21686 else if (unformat (input, "del"))
21692 if (sw_if_index == ~0)
21694 errmsg ("Interface required but not specified");
21700 errmsg ("VRF ID required but not specified");
21704 if (tcp_out_vrf_id == 0
21705 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
21708 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21712 /* Construct the API message */
21713 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
21715 mp->sw_if_index = ntohl (sw_if_index);
21716 mp->is_add = is_add;
21717 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
21718 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
21719 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
21720 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
21725 /* Wait for a reply... */
21731 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
21733 unformat_input_t *i = vam->input;
21734 vl_api_ipsec_gre_add_del_tunnel_t *mp;
21735 u32 local_sa_id = 0;
21736 u32 remote_sa_id = 0;
21737 ip4_address_t src_address;
21738 ip4_address_t dst_address;
21742 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21744 if (unformat (i, "local_sa %d", &local_sa_id))
21746 else if (unformat (i, "remote_sa %d", &remote_sa_id))
21748 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
21750 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
21752 else if (unformat (i, "del"))
21756 clib_warning ("parse error '%U'", format_unformat_error, i);
21761 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
21763 mp->local_sa_id = ntohl (local_sa_id);
21764 mp->remote_sa_id = ntohl (remote_sa_id);
21765 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
21766 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
21767 mp->is_add = is_add;
21775 api_punt (vat_main_t * vam)
21777 unformat_input_t *i = vam->input;
21785 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21787 if (unformat (i, "ip %d", &ipv))
21789 else if (unformat (i, "protocol %d", &protocol))
21791 else if (unformat (i, "port %d", &port))
21793 else if (unformat (i, "del"))
21797 clib_warning ("parse error '%U'", format_unformat_error, i);
21804 mp->is_add = (u8) is_add;
21805 mp->ipv = (u8) ipv;
21806 mp->l4_protocol = (u8) protocol;
21807 mp->l4_port = htons ((u16) port);
21814 static void vl_api_ipsec_gre_tunnel_details_t_handler
21815 (vl_api_ipsec_gre_tunnel_details_t * mp)
21817 vat_main_t *vam = &vat_main;
21819 print (vam->ofp, "%11d%15U%15U%14d%14d",
21820 ntohl (mp->sw_if_index),
21821 format_ip4_address, &mp->src_address,
21822 format_ip4_address, &mp->dst_address,
21823 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
21826 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
21827 (vl_api_ipsec_gre_tunnel_details_t * mp)
21829 vat_main_t *vam = &vat_main;
21830 vat_json_node_t *node = NULL;
21831 struct in_addr ip4;
21833 if (VAT_JSON_ARRAY != vam->json_tree.type)
21835 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21836 vat_json_init_array (&vam->json_tree);
21838 node = vat_json_array_add (&vam->json_tree);
21840 vat_json_init_object (node);
21841 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
21842 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
21843 vat_json_object_add_ip4 (node, "src_address", ip4);
21844 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
21845 vat_json_object_add_ip4 (node, "dst_address", ip4);
21846 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
21847 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
21851 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
21853 unformat_input_t *i = vam->input;
21854 vl_api_ipsec_gre_tunnel_dump_t *mp;
21855 vl_api_control_ping_t *mp_ping;
21857 u8 sw_if_index_set = 0;
21860 /* Parse args required to build the message */
21861 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21863 if (unformat (i, "sw_if_index %d", &sw_if_index))
21864 sw_if_index_set = 1;
21869 if (sw_if_index_set == 0)
21874 if (!vam->json_output)
21876 print (vam->ofp, "%11s%15s%15s%14s%14s",
21877 "sw_if_index", "src_address", "dst_address",
21878 "local_sa_id", "remote_sa_id");
21881 /* Get list of gre-tunnel interfaces */
21882 M (IPSEC_GRE_TUNNEL_DUMP, mp);
21884 mp->sw_if_index = htonl (sw_if_index);
21888 /* Use a control ping for synchronization */
21889 MPING (CONTROL_PING, mp_ping);
21897 api_delete_subif (vat_main_t * vam)
21899 unformat_input_t *i = vam->input;
21900 vl_api_delete_subif_t *mp;
21901 u32 sw_if_index = ~0;
21904 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21906 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21908 if (unformat (i, "sw_if_index %d", &sw_if_index))
21914 if (sw_if_index == ~0)
21916 errmsg ("missing sw_if_index");
21920 /* Construct the API message */
21921 M (DELETE_SUBIF, mp);
21922 mp->sw_if_index = ntohl (sw_if_index);
21929 #define foreach_pbb_vtr_op \
21930 _("disable", L2_VTR_DISABLED) \
21931 _("pop", L2_VTR_POP_2) \
21932 _("push", L2_VTR_PUSH_2)
21935 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
21937 unformat_input_t *i = vam->input;
21938 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
21939 u32 sw_if_index = ~0, vtr_op = ~0;
21940 u16 outer_tag = ~0;
21941 u8 dmac[6], smac[6];
21942 u8 dmac_set = 0, smac_set = 0;
21948 /* Shut up coverity */
21949 clib_memset (dmac, 0, sizeof (dmac));
21950 clib_memset (smac, 0, sizeof (smac));
21952 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21954 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21956 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21958 else if (unformat (i, "vtr_op %d", &vtr_op))
21960 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
21963 else if (unformat (i, "translate_pbb_stag"))
21965 if (unformat (i, "%d", &tmp))
21967 vtr_op = L2_VTR_TRANSLATE_2_1;
21973 ("translate_pbb_stag operation requires outer tag definition");
21977 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
21979 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
21981 else if (unformat (i, "sid %d", &sid))
21983 else if (unformat (i, "vlanid %d", &tmp))
21987 clib_warning ("parse error '%U'", format_unformat_error, i);
21992 if ((sw_if_index == ~0) || (vtr_op == ~0))
21994 errmsg ("missing sw_if_index or vtr operation");
21997 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
21998 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
22001 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
22005 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
22006 mp->sw_if_index = ntohl (sw_if_index);
22007 mp->vtr_op = ntohl (vtr_op);
22008 mp->outer_tag = ntohs (outer_tag);
22009 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
22010 clib_memcpy (mp->b_smac, smac, sizeof (smac));
22011 mp->b_vlanid = ntohs (vlanid);
22012 mp->i_sid = ntohl (sid);
22020 api_flow_classify_set_interface (vat_main_t * vam)
22022 unformat_input_t *i = vam->input;
22023 vl_api_flow_classify_set_interface_t *mp;
22025 int sw_if_index_set;
22026 u32 ip4_table_index = ~0;
22027 u32 ip6_table_index = ~0;
22031 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22033 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22034 sw_if_index_set = 1;
22035 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22036 sw_if_index_set = 1;
22037 else if (unformat (i, "del"))
22039 else if (unformat (i, "ip4-table %d", &ip4_table_index))
22041 else if (unformat (i, "ip6-table %d", &ip6_table_index))
22045 clib_warning ("parse error '%U'", format_unformat_error, i);
22050 if (sw_if_index_set == 0)
22052 errmsg ("missing interface name or sw_if_index");
22056 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
22058 mp->sw_if_index = ntohl (sw_if_index);
22059 mp->ip4_table_index = ntohl (ip4_table_index);
22060 mp->ip6_table_index = ntohl (ip6_table_index);
22061 mp->is_add = is_add;
22069 api_flow_classify_dump (vat_main_t * vam)
22071 unformat_input_t *i = vam->input;
22072 vl_api_flow_classify_dump_t *mp;
22073 vl_api_control_ping_t *mp_ping;
22074 u8 type = FLOW_CLASSIFY_N_TABLES;
22077 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
22081 errmsg ("classify table type must be specified");
22085 if (!vam->json_output)
22087 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
22090 M (FLOW_CLASSIFY_DUMP, mp);
22095 /* Use a control ping for synchronization */
22096 MPING (CONTROL_PING, mp_ping);
22099 /* Wait for a reply... */
22105 api_feature_enable_disable (vat_main_t * vam)
22107 unformat_input_t *i = vam->input;
22108 vl_api_feature_enable_disable_t *mp;
22110 u8 *feature_name = 0;
22111 u32 sw_if_index = ~0;
22115 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22117 if (unformat (i, "arc_name %s", &arc_name))
22119 else if (unformat (i, "feature_name %s", &feature_name))
22122 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22124 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22126 else if (unformat (i, "disable"))
22134 errmsg ("missing arc name");
22137 if (vec_len (arc_name) > 63)
22139 errmsg ("arc name too long");
22142 if (feature_name == 0)
22144 errmsg ("missing feature name");
22147 if (vec_len (feature_name) > 63)
22149 errmsg ("feature name too long");
22152 if (sw_if_index == ~0)
22154 errmsg ("missing interface name or sw_if_index");
22158 /* Construct the API message */
22159 M (FEATURE_ENABLE_DISABLE, mp);
22160 mp->sw_if_index = ntohl (sw_if_index);
22161 mp->enable = enable;
22162 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
22163 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
22164 vec_free (arc_name);
22165 vec_free (feature_name);
22173 api_sw_interface_tag_add_del (vat_main_t * vam)
22175 unformat_input_t *i = vam->input;
22176 vl_api_sw_interface_tag_add_del_t *mp;
22177 u32 sw_if_index = ~0;
22182 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22184 if (unformat (i, "tag %s", &tag))
22186 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22188 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22190 else if (unformat (i, "del"))
22196 if (sw_if_index == ~0)
22198 errmsg ("missing interface name or sw_if_index");
22202 if (enable && (tag == 0))
22204 errmsg ("no tag specified");
22208 /* Construct the API message */
22209 M (SW_INTERFACE_TAG_ADD_DEL, mp);
22210 mp->sw_if_index = ntohl (sw_if_index);
22211 mp->is_add = enable;
22213 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
22221 static void vl_api_l2_xconnect_details_t_handler
22222 (vl_api_l2_xconnect_details_t * mp)
22224 vat_main_t *vam = &vat_main;
22226 print (vam->ofp, "%15d%15d",
22227 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
22230 static void vl_api_l2_xconnect_details_t_handler_json
22231 (vl_api_l2_xconnect_details_t * mp)
22233 vat_main_t *vam = &vat_main;
22234 vat_json_node_t *node = NULL;
22236 if (VAT_JSON_ARRAY != vam->json_tree.type)
22238 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22239 vat_json_init_array (&vam->json_tree);
22241 node = vat_json_array_add (&vam->json_tree);
22243 vat_json_init_object (node);
22244 vat_json_object_add_uint (node, "rx_sw_if_index",
22245 ntohl (mp->rx_sw_if_index));
22246 vat_json_object_add_uint (node, "tx_sw_if_index",
22247 ntohl (mp->tx_sw_if_index));
22251 api_l2_xconnect_dump (vat_main_t * vam)
22253 vl_api_l2_xconnect_dump_t *mp;
22254 vl_api_control_ping_t *mp_ping;
22257 if (!vam->json_output)
22259 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
22262 M (L2_XCONNECT_DUMP, mp);
22266 /* Use a control ping for synchronization */
22267 MPING (CONTROL_PING, mp_ping);
22275 api_hw_interface_set_mtu (vat_main_t * vam)
22277 unformat_input_t *i = vam->input;
22278 vl_api_hw_interface_set_mtu_t *mp;
22279 u32 sw_if_index = ~0;
22283 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22285 if (unformat (i, "mtu %d", &mtu))
22287 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22289 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22295 if (sw_if_index == ~0)
22297 errmsg ("missing interface name or sw_if_index");
22303 errmsg ("no mtu specified");
22307 /* Construct the API message */
22308 M (HW_INTERFACE_SET_MTU, mp);
22309 mp->sw_if_index = ntohl (sw_if_index);
22310 mp->mtu = ntohs ((u16) mtu);
22318 api_p2p_ethernet_add (vat_main_t * vam)
22320 unformat_input_t *i = vam->input;
22321 vl_api_p2p_ethernet_add_t *mp;
22322 u32 parent_if_index = ~0;
22328 clib_memset (remote_mac, 0, sizeof (remote_mac));
22329 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22331 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
22333 else if (unformat (i, "sw_if_index %d", &parent_if_index))
22337 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
22339 else if (unformat (i, "sub_id %d", &sub_id))
22343 clib_warning ("parse error '%U'", format_unformat_error, i);
22348 if (parent_if_index == ~0)
22350 errmsg ("missing interface name or sw_if_index");
22355 errmsg ("missing remote mac address");
22360 errmsg ("missing sub-interface id");
22364 M (P2P_ETHERNET_ADD, mp);
22365 mp->parent_if_index = ntohl (parent_if_index);
22366 mp->subif_id = ntohl (sub_id);
22367 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22375 api_p2p_ethernet_del (vat_main_t * vam)
22377 unformat_input_t *i = vam->input;
22378 vl_api_p2p_ethernet_del_t *mp;
22379 u32 parent_if_index = ~0;
22384 clib_memset (remote_mac, 0, sizeof (remote_mac));
22385 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22387 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
22389 else if (unformat (i, "sw_if_index %d", &parent_if_index))
22393 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
22397 clib_warning ("parse error '%U'", format_unformat_error, i);
22402 if (parent_if_index == ~0)
22404 errmsg ("missing interface name or sw_if_index");
22409 errmsg ("missing remote mac address");
22413 M (P2P_ETHERNET_DEL, mp);
22414 mp->parent_if_index = ntohl (parent_if_index);
22415 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22423 api_lldp_config (vat_main_t * vam)
22425 unformat_input_t *i = vam->input;
22426 vl_api_lldp_config_t *mp;
22428 int tx_interval = 0;
22429 u8 *sys_name = NULL;
22432 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22434 if (unformat (i, "system-name %s", &sys_name))
22436 else if (unformat (i, "tx-hold %d", &tx_hold))
22438 else if (unformat (i, "tx-interval %d", &tx_interval))
22442 clib_warning ("parse error '%U'", format_unformat_error, i);
22447 vec_add1 (sys_name, 0);
22449 M (LLDP_CONFIG, mp);
22450 mp->tx_hold = htonl (tx_hold);
22451 mp->tx_interval = htonl (tx_interval);
22452 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
22453 vec_free (sys_name);
22461 api_sw_interface_set_lldp (vat_main_t * vam)
22463 unformat_input_t *i = vam->input;
22464 vl_api_sw_interface_set_lldp_t *mp;
22465 u32 sw_if_index = ~0;
22467 u8 *port_desc = NULL, *mgmt_oid = NULL;
22468 ip4_address_t ip4_addr;
22469 ip6_address_t ip6_addr;
22472 clib_memset (&ip4_addr, 0, sizeof (ip4_addr));
22473 clib_memset (&ip6_addr, 0, sizeof (ip6_addr));
22475 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22477 if (unformat (i, "disable"))
22480 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22482 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22484 else if (unformat (i, "port-desc %s", &port_desc))
22486 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
22488 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
22490 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
22496 if (sw_if_index == ~0)
22498 errmsg ("missing interface name or sw_if_index");
22502 /* Construct the API message */
22503 vec_add1 (port_desc, 0);
22504 vec_add1 (mgmt_oid, 0);
22505 M (SW_INTERFACE_SET_LLDP, mp);
22506 mp->sw_if_index = ntohl (sw_if_index);
22507 mp->enable = enable;
22508 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
22509 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
22510 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
22511 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
22512 vec_free (port_desc);
22513 vec_free (mgmt_oid);
22521 api_tcp_configure_src_addresses (vat_main_t * vam)
22523 vl_api_tcp_configure_src_addresses_t *mp;
22524 unformat_input_t *i = vam->input;
22525 ip4_address_t v4first, v4last;
22526 ip6_address_t v6first, v6last;
22531 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22533 if (unformat (i, "%U - %U",
22534 unformat_ip4_address, &v4first,
22535 unformat_ip4_address, &v4last))
22539 errmsg ("one range per message (range already set)");
22544 else if (unformat (i, "%U - %U",
22545 unformat_ip6_address, &v6first,
22546 unformat_ip6_address, &v6last))
22550 errmsg ("one range per message (range already set)");
22555 else if (unformat (i, "vrf %d", &vrf_id))
22561 if (range_set == 0)
22563 errmsg ("address range not set");
22567 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
22568 mp->vrf_id = ntohl (vrf_id);
22570 if (range_set == 2)
22573 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
22574 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
22579 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
22580 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
22587 static void vl_api_app_namespace_add_del_reply_t_handler
22588 (vl_api_app_namespace_add_del_reply_t * mp)
22590 vat_main_t *vam = &vat_main;
22591 i32 retval = ntohl (mp->retval);
22592 if (vam->async_mode)
22594 vam->async_errors += (retval < 0);
22598 vam->retval = retval;
22600 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
22601 vam->result_ready = 1;
22605 static void vl_api_app_namespace_add_del_reply_t_handler_json
22606 (vl_api_app_namespace_add_del_reply_t * mp)
22608 vat_main_t *vam = &vat_main;
22609 vat_json_node_t node;
22611 vat_json_init_object (&node);
22612 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
22613 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
22615 vat_json_print (vam->ofp, &node);
22616 vat_json_free (&node);
22618 vam->retval = ntohl (mp->retval);
22619 vam->result_ready = 1;
22623 api_app_namespace_add_del (vat_main_t * vam)
22625 vl_api_app_namespace_add_del_t *mp;
22626 unformat_input_t *i = vam->input;
22627 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
22628 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
22632 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22634 if (unformat (i, "id %_%v%_", &ns_id))
22636 else if (unformat (i, "secret %lu", &secret))
22638 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22639 sw_if_index_set = 1;
22640 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
22642 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
22647 if (!ns_id || !secret_set || !sw_if_index_set)
22649 errmsg ("namespace id, secret and sw_if_index must be set");
22652 if (vec_len (ns_id) > 64)
22654 errmsg ("namespace id too long");
22657 M (APP_NAMESPACE_ADD_DEL, mp);
22659 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
22660 mp->namespace_id_len = vec_len (ns_id);
22661 mp->secret = clib_host_to_net_u64 (secret);
22662 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
22663 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
22664 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
22672 api_sock_init_shm (vat_main_t * vam)
22674 #if VPP_API_TEST_BUILTIN == 0
22675 unformat_input_t *i = vam->input;
22676 vl_api_shm_elem_config_t *config = 0;
22677 u64 size = 64 << 20;
22680 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22682 if (unformat (i, "size %U", unformat_memory_size, &size))
22689 * Canned custom ring allocator config.
22690 * Should probably parse all of this
22692 vec_validate (config, 6);
22693 config[0].type = VL_API_VLIB_RING;
22694 config[0].size = 256;
22695 config[0].count = 32;
22697 config[1].type = VL_API_VLIB_RING;
22698 config[1].size = 1024;
22699 config[1].count = 16;
22701 config[2].type = VL_API_VLIB_RING;
22702 config[2].size = 4096;
22703 config[2].count = 2;
22705 config[3].type = VL_API_CLIENT_RING;
22706 config[3].size = 256;
22707 config[3].count = 32;
22709 config[4].type = VL_API_CLIENT_RING;
22710 config[4].size = 1024;
22711 config[4].count = 16;
22713 config[5].type = VL_API_CLIENT_RING;
22714 config[5].size = 4096;
22715 config[5].count = 2;
22717 config[6].type = VL_API_QUEUE;
22718 config[6].count = 128;
22719 config[6].size = sizeof (uword);
22721 rv = vl_socket_client_init_shm (config);
22723 vam->client_index_invalid = 1;
22731 api_dns_enable_disable (vat_main_t * vam)
22733 unformat_input_t *line_input = vam->input;
22734 vl_api_dns_enable_disable_t *mp;
22735 u8 enable_disable = 1;
22738 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22740 if (unformat (line_input, "disable"))
22741 enable_disable = 0;
22742 if (unformat (line_input, "enable"))
22743 enable_disable = 1;
22748 /* Construct the API message */
22749 M (DNS_ENABLE_DISABLE, mp);
22750 mp->enable = enable_disable;
22754 /* Wait for the reply */
22760 api_dns_resolve_name (vat_main_t * vam)
22762 unformat_input_t *line_input = vam->input;
22763 vl_api_dns_resolve_name_t *mp;
22767 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22769 if (unformat (line_input, "%s", &name))
22775 if (vec_len (name) > 127)
22777 errmsg ("name too long");
22781 /* Construct the API message */
22782 M (DNS_RESOLVE_NAME, mp);
22783 memcpy (mp->name, name, vec_len (name));
22788 /* Wait for the reply */
22794 api_dns_resolve_ip (vat_main_t * vam)
22796 unformat_input_t *line_input = vam->input;
22797 vl_api_dns_resolve_ip_t *mp;
22799 ip4_address_t addr4;
22800 ip6_address_t addr6;
22803 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22805 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
22807 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
22815 errmsg ("missing address");
22819 /* Construct the API message */
22820 M (DNS_RESOLVE_IP, mp);
22821 mp->is_ip6 = is_ip6;
22823 memcpy (mp->address, &addr6, sizeof (addr6));
22825 memcpy (mp->address, &addr4, sizeof (addr4));
22829 /* Wait for the reply */
22835 api_dns_name_server_add_del (vat_main_t * vam)
22837 unformat_input_t *i = vam->input;
22838 vl_api_dns_name_server_add_del_t *mp;
22840 ip6_address_t ip6_server;
22841 ip4_address_t ip4_server;
22846 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22848 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
22850 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
22852 else if (unformat (i, "del"))
22856 clib_warning ("parse error '%U'", format_unformat_error, i);
22861 if (ip4_set && ip6_set)
22863 errmsg ("Only one server address allowed per message");
22866 if ((ip4_set + ip6_set) == 0)
22868 errmsg ("Server address required");
22872 /* Construct the API message */
22873 M (DNS_NAME_SERVER_ADD_DEL, mp);
22877 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
22882 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
22886 mp->is_add = is_add;
22891 /* Wait for a reply, return good/bad news */
22897 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
22899 vat_main_t *vam = &vat_main;
22904 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22905 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22906 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
22907 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
22908 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22909 clib_net_to_host_u32 (mp->action_index), mp->tag);
22914 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22915 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22916 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
22917 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
22918 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22919 clib_net_to_host_u32 (mp->action_index), mp->tag);
22924 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
22927 vat_main_t *vam = &vat_main;
22928 vat_json_node_t *node = NULL;
22929 struct in6_addr ip6;
22930 struct in_addr ip4;
22932 if (VAT_JSON_ARRAY != vam->json_tree.type)
22934 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22935 vat_json_init_array (&vam->json_tree);
22937 node = vat_json_array_add (&vam->json_tree);
22938 vat_json_init_object (node);
22940 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
22941 vat_json_object_add_uint (node, "appns_index",
22942 clib_net_to_host_u32 (mp->appns_index));
22943 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
22944 vat_json_object_add_uint (node, "scope", mp->scope);
22945 vat_json_object_add_uint (node, "action_index",
22946 clib_net_to_host_u32 (mp->action_index));
22947 vat_json_object_add_uint (node, "lcl_port",
22948 clib_net_to_host_u16 (mp->lcl_port));
22949 vat_json_object_add_uint (node, "rmt_port",
22950 clib_net_to_host_u16 (mp->rmt_port));
22951 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
22952 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
22953 vat_json_object_add_string_copy (node, "tag", mp->tag);
22956 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
22957 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
22958 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
22959 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
22963 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
22964 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
22965 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
22966 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
22971 api_session_rule_add_del (vat_main_t * vam)
22973 vl_api_session_rule_add_del_t *mp;
22974 unformat_input_t *i = vam->input;
22975 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
22976 u32 appns_index = 0, scope = 0;
22977 ip4_address_t lcl_ip4, rmt_ip4;
22978 ip6_address_t lcl_ip6, rmt_ip6;
22979 u8 is_ip4 = 1, conn_set = 0;
22980 u8 is_add = 1, *tag = 0;
22983 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22985 if (unformat (i, "del"))
22987 else if (unformat (i, "add"))
22989 else if (unformat (i, "proto tcp"))
22991 else if (unformat (i, "proto udp"))
22993 else if (unformat (i, "appns %d", &appns_index))
22995 else if (unformat (i, "scope %d", &scope))
22997 else if (unformat (i, "tag %_%v%_", &tag))
23001 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
23002 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
23010 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
23011 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
23017 else if (unformat (i, "action %d", &action))
23022 if (proto == ~0 || !conn_set || action == ~0)
23024 errmsg ("transport proto, connection and action must be set");
23030 errmsg ("scope should be 0-3");
23034 M (SESSION_RULE_ADD_DEL, mp);
23036 mp->is_ip4 = is_ip4;
23037 mp->transport_proto = proto;
23038 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
23039 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
23040 mp->lcl_plen = lcl_plen;
23041 mp->rmt_plen = rmt_plen;
23042 mp->action_index = clib_host_to_net_u32 (action);
23043 mp->appns_index = clib_host_to_net_u32 (appns_index);
23045 mp->is_add = is_add;
23048 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
23049 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
23053 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
23054 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
23058 clib_memcpy (mp->tag, tag, vec_len (tag));
23068 api_session_rules_dump (vat_main_t * vam)
23070 vl_api_session_rules_dump_t *mp;
23071 vl_api_control_ping_t *mp_ping;
23074 if (!vam->json_output)
23076 print (vam->ofp, "%=20s", "Session Rules");
23079 M (SESSION_RULES_DUMP, mp);
23083 /* Use a control ping for synchronization */
23084 MPING (CONTROL_PING, mp_ping);
23087 /* Wait for a reply... */
23093 api_ip_container_proxy_add_del (vat_main_t * vam)
23095 vl_api_ip_container_proxy_add_del_t *mp;
23096 unformat_input_t *i = vam->input;
23097 u32 plen = ~0, sw_if_index = ~0;
23104 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
23106 if (unformat (i, "del"))
23108 else if (unformat (i, "add"))
23110 if (unformat (i, "%U", unformat_ip4_address, &ip4))
23115 else if (unformat (i, "%U", unformat_ip6_address, &ip6))
23120 else if (unformat (i, "sw_if_index %u", &sw_if_index))
23125 if (sw_if_index == ~0 || plen == ~0)
23127 errmsg ("address and sw_if_index must be set");
23131 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
23133 mp->is_ip4 = is_ip4;
23134 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
23136 mp->is_add = is_add;
23138 clib_memcpy (mp->ip, &ip4, sizeof (ip4));
23140 clib_memcpy (mp->ip, &ip6, sizeof (ip6));
23148 api_qos_record_enable_disable (vat_main_t * vam)
23150 unformat_input_t *i = vam->input;
23151 vl_api_qos_record_enable_disable_t *mp;
23152 u32 sw_if_index, qs = 0xff;
23153 u8 sw_if_index_set = 0;
23157 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
23159 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
23160 sw_if_index_set = 1;
23161 else if (unformat (i, "sw_if_index %d", &sw_if_index))
23162 sw_if_index_set = 1;
23163 else if (unformat (i, "%U", unformat_qos_source, &qs))
23165 else if (unformat (i, "disable"))
23169 clib_warning ("parse error '%U'", format_unformat_error, i);
23174 if (sw_if_index_set == 0)
23176 errmsg ("missing interface name or sw_if_index");
23181 errmsg ("input location must be specified");
23185 M (QOS_RECORD_ENABLE_DISABLE, mp);
23187 mp->sw_if_index = ntohl (sw_if_index);
23188 mp->input_source = qs;
23189 mp->enable = enable;
23198 q_or_quit (vat_main_t * vam)
23200 #if VPP_API_TEST_BUILTIN == 0
23201 longjmp (vam->jump_buf, 1);
23203 return 0; /* not so much */
23207 q (vat_main_t * vam)
23209 return q_or_quit (vam);
23213 quit (vat_main_t * vam)
23215 return q_or_quit (vam);
23219 comment (vat_main_t * vam)
23225 statseg (vat_main_t * vam)
23227 ssvm_private_t *ssvmp = &vam->stat_segment;
23228 ssvm_shared_header_t *shared_header = ssvmp->sh;
23229 vlib_counter_t **counters;
23230 u64 thread0_index1_packets;
23231 u64 thread0_index1_bytes;
23232 f64 vector_rate, input_rate;
23235 uword *counter_vector_by_name;
23236 if (vam->stat_segment_lockp == 0)
23238 errmsg ("Stat segment not mapped...");
23242 /* look up "/if/rx for sw_if_index 1 as a test */
23244 clib_spinlock_lock (vam->stat_segment_lockp);
23246 counter_vector_by_name = (uword *) shared_header->opaque[1];
23248 p = hash_get_mem (counter_vector_by_name, "/if/rx");
23251 clib_spinlock_unlock (vam->stat_segment_lockp);
23252 errmsg ("/if/tx not found?");
23256 /* Fish per-thread vector of combined counters from shared memory */
23257 counters = (vlib_counter_t **) p[0];
23259 if (vec_len (counters[0]) < 2)
23261 clib_spinlock_unlock (vam->stat_segment_lockp);
23262 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
23266 /* Read thread 0 sw_if_index 1 counter */
23267 thread0_index1_packets = counters[0][1].packets;
23268 thread0_index1_bytes = counters[0][1].bytes;
23270 p = hash_get_mem (counter_vector_by_name, "vector_rate");
23273 clib_spinlock_unlock (vam->stat_segment_lockp);
23274 errmsg ("vector_rate not found?");
23278 vector_rate = *(f64 *) (p[0]);
23279 p = hash_get_mem (counter_vector_by_name, "input_rate");
23282 clib_spinlock_unlock (vam->stat_segment_lockp);
23283 errmsg ("input_rate not found?");
23286 input_rate = *(f64 *) (p[0]);
23288 clib_spinlock_unlock (vam->stat_segment_lockp);
23290 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
23291 vector_rate, input_rate);
23292 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
23293 thread0_index1_packets, thread0_index1_bytes);
23299 cmd_cmp (void *a1, void *a2)
23304 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
23308 help (vat_main_t * vam)
23313 unformat_input_t *i = vam->input;
23316 if (unformat (i, "%s", &name))
23320 vec_add1 (name, 0);
23322 hs = hash_get_mem (vam->help_by_name, name);
23324 print (vam->ofp, "usage: %s %s", name, hs[0]);
23326 print (vam->ofp, "No such msg / command '%s'", name);
23331 print (vam->ofp, "Help is available for the following:");
23334 hash_foreach_pair (p, vam->function_by_name,
23336 vec_add1 (cmds, (u8 *)(p->key));
23340 vec_sort_with_function (cmds, cmd_cmp);
23342 for (j = 0; j < vec_len (cmds); j++)
23343 print (vam->ofp, "%s", cmds[j]);
23350 set (vat_main_t * vam)
23352 u8 *name = 0, *value = 0;
23353 unformat_input_t *i = vam->input;
23355 if (unformat (i, "%s", &name))
23357 /* The input buffer is a vector, not a string. */
23358 value = vec_dup (i->buffer);
23359 vec_delete (value, i->index, 0);
23360 /* Almost certainly has a trailing newline */
23361 if (value[vec_len (value) - 1] == '\n')
23362 value[vec_len (value) - 1] = 0;
23363 /* Make sure it's a proper string, one way or the other */
23364 vec_add1 (value, 0);
23365 (void) clib_macro_set_value (&vam->macro_main,
23366 (char *) name, (char *) value);
23369 errmsg ("usage: set <name> <value>");
23377 unset (vat_main_t * vam)
23381 if (unformat (vam->input, "%s", &name))
23382 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
23383 errmsg ("unset: %s wasn't set", name);
23396 macro_sort_cmp (void *a1, void *a2)
23398 macro_sort_t *s1 = a1;
23399 macro_sort_t *s2 = a2;
23401 return strcmp ((char *) (s1->name), (char *) (s2->name));
23405 dump_macro_table (vat_main_t * vam)
23407 macro_sort_t *sort_me = 0, *sm;
23412 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
23414 vec_add2 (sort_me, sm, 1);
23415 sm->name = (u8 *)(p->key);
23416 sm->value = (u8 *) (p->value[0]);
23420 vec_sort_with_function (sort_me, macro_sort_cmp);
23422 if (vec_len (sort_me))
23423 print (vam->ofp, "%-15s%s", "Name", "Value");
23425 print (vam->ofp, "The macro table is empty...");
23427 for (i = 0; i < vec_len (sort_me); i++)
23428 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
23433 dump_node_table (vat_main_t * vam)
23436 vlib_node_t *node, *next_node;
23438 if (vec_len (vam->graph_nodes) == 0)
23440 print (vam->ofp, "Node table empty, issue get_node_graph...");
23444 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
23446 node = vam->graph_nodes[0][i];
23447 print (vam->ofp, "[%d] %s", i, node->name);
23448 for (j = 0; j < vec_len (node->next_nodes); j++)
23450 if (node->next_nodes[j] != ~0)
23452 next_node = vam->graph_nodes[0][node->next_nodes[j]];
23453 print (vam->ofp, " [%d] %s", j, next_node->name);
23461 value_sort_cmp (void *a1, void *a2)
23463 name_sort_t *n1 = a1;
23464 name_sort_t *n2 = a2;
23466 if (n1->value < n2->value)
23468 if (n1->value > n2->value)
23475 dump_msg_api_table (vat_main_t * vam)
23477 api_main_t *am = &api_main;
23478 name_sort_t *nses = 0, *ns;
23483 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
23485 vec_add2 (nses, ns, 1);
23486 ns->name = (u8 *)(hp->key);
23487 ns->value = (u32) hp->value[0];
23491 vec_sort_with_function (nses, value_sort_cmp);
23493 for (i = 0; i < vec_len (nses); i++)
23494 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
23500 get_msg_id (vat_main_t * vam)
23505 if (unformat (vam->input, "%s", &name_and_crc))
23507 message_index = vl_msg_api_get_msg_index (name_and_crc);
23508 if (message_index == ~0)
23510 print (vam->ofp, " '%s' not found", name_and_crc);
23513 print (vam->ofp, " '%s' has message index %d",
23514 name_and_crc, message_index);
23517 errmsg ("name_and_crc required...");
23522 search_node_table (vat_main_t * vam)
23524 unformat_input_t *line_input = vam->input;
23527 vlib_node_t *node, *next_node;
23530 if (vam->graph_node_index_by_name == 0)
23532 print (vam->ofp, "Node table empty, issue get_node_graph...");
23536 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
23538 if (unformat (line_input, "%s", &node_to_find))
23540 vec_add1 (node_to_find, 0);
23541 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
23544 print (vam->ofp, "%s not found...", node_to_find);
23547 node = vam->graph_nodes[0][p[0]];
23548 print (vam->ofp, "[%d] %s", p[0], node->name);
23549 for (j = 0; j < vec_len (node->next_nodes); j++)
23551 if (node->next_nodes[j] != ~0)
23553 next_node = vam->graph_nodes[0][node->next_nodes[j]];
23554 print (vam->ofp, " [%d] %s", j, next_node->name);
23561 clib_warning ("parse error '%U'", format_unformat_error,
23567 vec_free (node_to_find);
23576 script (vat_main_t * vam)
23578 #if (VPP_API_TEST_BUILTIN==0)
23580 char *save_current_file;
23581 unformat_input_t save_input;
23582 jmp_buf save_jump_buf;
23583 u32 save_line_number;
23585 FILE *new_fp, *save_ifp;
23587 if (unformat (vam->input, "%s", &s))
23589 new_fp = fopen ((char *) s, "r");
23592 errmsg ("Couldn't open script file %s", s);
23599 errmsg ("Missing script name");
23603 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
23604 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
23605 save_ifp = vam->ifp;
23606 save_line_number = vam->input_line_number;
23607 save_current_file = (char *) vam->current_file;
23609 vam->input_line_number = 0;
23611 vam->current_file = s;
23614 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
23615 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
23616 vam->ifp = save_ifp;
23617 vam->input_line_number = save_line_number;
23618 vam->current_file = (u8 *) save_current_file;
23623 clib_warning ("use the exec command...");
23629 echo (vat_main_t * vam)
23631 print (vam->ofp, "%v", vam->input->buffer);
23635 /* List of API message constructors, CLI names map to api_xxx */
23636 #define foreach_vpe_api_msg \
23637 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
23638 _(sw_interface_dump,"") \
23639 _(sw_interface_set_flags, \
23640 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
23641 _(sw_interface_add_del_address, \
23642 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
23643 _(sw_interface_set_rx_mode, \
23644 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
23645 _(sw_interface_set_rx_placement, \
23646 "<intfc> | sw_if_index <id> [queue <id>] [worker <id> | main]") \
23647 _(sw_interface_rx_placement_dump, \
23648 "[<intfc> | sw_if_index <id>]") \
23649 _(sw_interface_set_table, \
23650 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
23651 _(sw_interface_set_mpls_enable, \
23652 "<intfc> | sw_if_index [disable | dis]") \
23653 _(sw_interface_set_vpath, \
23654 "<intfc> | sw_if_index <id> enable | disable") \
23655 _(sw_interface_set_vxlan_bypass, \
23656 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23657 _(sw_interface_set_geneve_bypass, \
23658 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23659 _(sw_interface_set_l2_xconnect, \
23660 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23661 "enable | disable") \
23662 _(sw_interface_set_l2_bridge, \
23663 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
23664 "[shg <split-horizon-group>] [bvi]\n" \
23665 "enable | disable") \
23666 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
23667 _(bridge_domain_add_del, \
23668 "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") \
23669 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
23671 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
23672 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
23673 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
23675 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23677 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23679 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
23681 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
23683 "<vpp-if-name> | sw_if_index <id>") \
23684 _(sw_interface_tap_dump, "") \
23686 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>]") \
23688 "<vpp-if-name> | sw_if_index <id>") \
23689 _(sw_interface_tap_v2_dump, "") \
23691 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
23692 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]}") \
23694 "<vpp-if-name> | sw_if_index <id>") \
23696 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
23697 _(bond_detach_slave, \
23698 "sw_if_index <n>") \
23699 _(sw_interface_bond_dump, "") \
23700 _(sw_interface_slave_dump, \
23701 "<vpp-if-name> | sw_if_index <id>") \
23702 _(ip_table_add_del, \
23703 "table <n> [ipv6] [add | del]\n") \
23704 _(ip_add_del_route, \
23705 "<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
23706 "[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
23707 "[weight <n>] [drop] [local] [classify <n>] [out-label <n>]\n" \
23708 "[multipath] [count <n>] [del]") \
23709 _(ip_mroute_add_del, \
23710 "<src> <grp>/<mask> [table-id <n>]\n" \
23711 "[<intfc> | sw_if_index <id>] [local] [del]") \
23712 _(mpls_table_add_del, \
23713 "table <n> [add | del]\n") \
23714 _(mpls_route_add_del, \
23715 "<label> <eos> via <addr | next-hop-table <n> | via-label <n> |\n" \
23716 "lookup-ip4-table <n> | lookup-in-ip6-table <n> |\n" \
23717 "l2-input-on <intfc> | l2-input-on sw_if_index <id>>\n" \
23718 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>] [weight <n>]\n" \
23719 "[drop] [local] [classify <n>] [out-label <n>] [multipath]\n" \
23720 "[count <n>] [del]") \
23721 _(mpls_ip_bind_unbind, \
23722 "<label> <addr/len>") \
23723 _(mpls_tunnel_add_del, \
23724 "[add | del <intfc | sw_if_index <id>>] via <addr | via-label <n>>\n" \
23725 "[<intfc> | sw_if_index <id> | next-hop-table <id>]\n" \
23726 "[l2-only] [out-label <n>]") \
23727 _(sr_mpls_policy_add, \
23728 "bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
23729 _(sr_mpls_policy_del, \
23731 _(bier_table_add_del, \
23732 "<label> <sub-domain> <set> <bsl> [del]") \
23733 _(bier_route_add_del, \
23734 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
23735 "[<intfc> | sw_if_index <id>]" \
23736 "[weight <n>] [del] [multipath]") \
23737 _(proxy_arp_add_del, \
23738 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
23739 _(proxy_arp_intfc_enable_disable, \
23740 "<intfc> | sw_if_index <id> enable | disable") \
23741 _(sw_interface_set_unnumbered, \
23742 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
23743 _(ip_neighbor_add_del, \
23744 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
23745 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
23746 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
23747 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
23748 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
23749 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
23750 "[outer_vlan_id_any][inner_vlan_id_any]") \
23751 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
23752 _(reset_fib, "vrf <n> [ipv6]") \
23753 _(dhcp_proxy_config, \
23754 "svr <v46-address> src <v46-address>\n" \
23755 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
23756 _(dhcp_proxy_set_vss, \
23757 "tbl_id <n> [fib_id <n> oui <n> | vpn_ascii_id <text>] [ipv6] [del]") \
23758 _(dhcp_proxy_dump, "ip6") \
23759 _(dhcp_client_config, \
23760 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
23761 _(set_ip_flow_hash, \
23762 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
23763 _(sw_interface_ip6_enable_disable, \
23764 "<intfc> | sw_if_index <id> enable | disable") \
23765 _(sw_interface_ip6_set_link_local_address, \
23766 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
23767 _(ip6nd_proxy_add_del, \
23768 "<intfc> | sw_if_index <id> <ip6-address>") \
23769 _(ip6nd_proxy_dump, "") \
23770 _(sw_interface_ip6nd_ra_prefix, \
23771 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
23772 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
23773 "[nolink] [isno]") \
23774 _(sw_interface_ip6nd_ra_config, \
23775 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
23776 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
23777 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
23778 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
23779 _(l2_patch_add_del, \
23780 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23781 "enable | disable") \
23782 _(sr_localsid_add_del, \
23783 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
23784 "fib-table <num> (end.psp) sw_if_index <num>") \
23785 _(classify_add_del_table, \
23786 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
23787 " [del] [del-chain] mask <mask-value>\n" \
23788 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
23789 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
23790 _(classify_add_del_session, \
23791 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
23792 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
23793 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
23794 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
23795 _(classify_set_interface_ip_table, \
23796 "<intfc> | sw_if_index <nn> table <nn>") \
23797 _(classify_set_interface_l2_tables, \
23798 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23799 " [other-table <nn>]") \
23800 _(get_node_index, "node <node-name") \
23801 _(add_node_next, "node <node-name> next <next-node-name>") \
23802 _(l2tpv3_create_tunnel, \
23803 "client_address <ip6-addr> our_address <ip6-addr>\n" \
23804 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
23805 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
23806 _(l2tpv3_set_tunnel_cookies, \
23807 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
23808 "[new_remote_cookie <nn>]\n") \
23809 _(l2tpv3_interface_enable_disable, \
23810 "<intfc> | sw_if_index <nn> enable | disable") \
23811 _(l2tpv3_set_lookup_key, \
23812 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
23813 _(sw_if_l2tpv3_tunnel_dump, "") \
23814 _(vxlan_offload_rx, \
23815 "hw { <interface name> | hw_if_index <nn>} " \
23816 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
23817 _(vxlan_add_del_tunnel, \
23818 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23819 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
23820 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23821 _(geneve_add_del_tunnel, \
23822 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23823 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23824 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23825 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23826 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23827 _(gre_add_del_tunnel, \
23828 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
23829 "[teb | erspan <session-id>] [del]") \
23830 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23831 _(l2_fib_clear_table, "") \
23832 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
23833 _(l2_interface_vlan_tag_rewrite, \
23834 "<intfc> | sw_if_index <nn> \n" \
23835 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
23836 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
23837 _(create_vhost_user_if, \
23838 "socket <filename> [server] [renumber <dev_instance>] " \
23839 "[disable_mrg_rxbuf] [disable_indirect_desc] " \
23840 "[mac <mac_address>]") \
23841 _(modify_vhost_user_if, \
23842 "<intfc> | sw_if_index <nn> socket <filename>\n" \
23843 "[server] [renumber <dev_instance>]") \
23844 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
23845 _(sw_interface_vhost_user_dump, "") \
23846 _(show_version, "") \
23847 _(show_threads, "") \
23848 _(vxlan_gpe_add_del_tunnel, \
23849 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
23850 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23851 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
23852 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
23853 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23854 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
23855 _(interface_name_renumber, \
23856 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
23857 _(input_acl_set_interface, \
23858 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23859 " [l2-table <nn>] [del]") \
23860 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
23861 _(ip_scan_neighbor_enable_disable, "[ip4|ip6|both|disable] [interval <n-min>]\n" \
23862 " [max-time <n-usec>] [max-update <n>] [delay <n-msec>] [stale <n-min>]") \
23863 _(want_ip4_arp_events, "address <ip4-address> [del]") \
23864 _(want_ip6_nd_events, "address <ip6-address> [del]") \
23865 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
23866 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
23867 _(ip_dump, "ipv4 | ipv6") \
23868 _(ipsec_spd_add_del, "spd_id <n> [del]") \
23869 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
23871 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
23872 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
23873 " integ_alg <alg> integ_key <hex>") \
23874 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
23875 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
23876 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
23877 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
23878 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
23879 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
23880 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
23881 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
23882 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
23883 " [instance <n>]") \
23884 _(ipsec_sa_dump, "[sa_id <n>]") \
23885 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
23886 " <alg> <hex>\n") \
23887 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
23888 _(ikev2_profile_add_del, "name <profile_name> [del]") \
23889 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
23890 "(auth_data 0x<data> | auth_data <data>)") \
23891 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
23892 "(id_data 0x<data> | id_data <data>) (local|remote)") \
23893 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
23894 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
23895 "(local|remote)") \
23896 _(ikev2_set_local_key, "file <absolute_file_path>") \
23897 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
23898 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23899 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23900 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
23901 _(ikev2_initiate_sa_init, "<profile_name>") \
23902 _(ikev2_initiate_del_ike_sa, "<ispi>") \
23903 _(ikev2_initiate_del_child_sa, "<ispi>") \
23904 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
23905 _(delete_loopback,"sw_if_index <nn>") \
23906 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
23907 _(bd_ip_mac_dump, "[bd_id] <id>") \
23908 _(want_interface_events, "enable|disable") \
23909 _(want_stats,"enable|disable") \
23910 _(get_first_msg_id, "client <name>") \
23911 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
23912 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
23913 "fib-id <nn> [ip4][ip6][default]") \
23914 _(get_node_graph, " ") \
23915 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
23916 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
23917 _(ioam_disable, "") \
23918 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
23919 " sw_if_index <sw_if_index> p <priority> " \
23920 "w <weight>] [del]") \
23921 _(one_add_del_locator, "locator-set <locator_name> " \
23922 "iface <intf> | sw_if_index <sw_if_index> " \
23923 "p <priority> w <weight> [del]") \
23924 _(one_add_del_local_eid,"vni <vni> eid " \
23925 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23926 "locator-set <locator_name> [del]" \
23927 "[key-id sha1|sha256 secret-key <secret-key>]")\
23928 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
23929 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
23930 _(one_enable_disable, "enable|disable") \
23931 _(one_map_register_enable_disable, "enable|disable") \
23932 _(one_map_register_fallback_threshold, "<value>") \
23933 _(one_rloc_probe_enable_disable, "enable|disable") \
23934 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23936 "rloc <locator> p <prio> " \
23937 "w <weight> [rloc <loc> ... ] " \
23938 "action <action> [del-all]") \
23939 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23941 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23942 _(one_use_petr, "ip-address> | disable") \
23943 _(one_map_request_mode, "src-dst|dst-only") \
23944 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23945 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23946 _(one_locator_set_dump, "[local | remote]") \
23947 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
23948 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23949 "[local] | [remote]") \
23950 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
23951 _(one_ndp_bd_get, "") \
23952 _(one_ndp_entries_get, "bd <bridge-domain>") \
23953 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
23954 _(one_l2_arp_bd_get, "") \
23955 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
23956 _(one_stats_enable_disable, "enable|disable") \
23957 _(show_one_stats_enable_disable, "") \
23958 _(one_eid_table_vni_dump, "") \
23959 _(one_eid_table_map_dump, "l2|l3") \
23960 _(one_map_resolver_dump, "") \
23961 _(one_map_server_dump, "") \
23962 _(one_adjacencies_get, "vni <vni>") \
23963 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
23964 _(show_one_rloc_probe_state, "") \
23965 _(show_one_map_register_state, "") \
23966 _(show_one_status, "") \
23967 _(one_stats_dump, "") \
23968 _(one_stats_flush, "") \
23969 _(one_get_map_request_itr_rlocs, "") \
23970 _(one_map_register_set_ttl, "<ttl>") \
23971 _(one_set_transport_protocol, "udp|api") \
23972 _(one_get_transport_protocol, "") \
23973 _(one_enable_disable_xtr_mode, "enable|disable") \
23974 _(one_show_xtr_mode, "") \
23975 _(one_enable_disable_pitr_mode, "enable|disable") \
23976 _(one_show_pitr_mode, "") \
23977 _(one_enable_disable_petr_mode, "enable|disable") \
23978 _(one_show_petr_mode, "") \
23979 _(show_one_nsh_mapping, "") \
23980 _(show_one_pitr, "") \
23981 _(show_one_use_petr, "") \
23982 _(show_one_map_request_mode, "") \
23983 _(show_one_map_register_ttl, "") \
23984 _(show_one_map_register_fallback_threshold, "") \
23985 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
23986 " sw_if_index <sw_if_index> p <priority> " \
23987 "w <weight>] [del]") \
23988 _(lisp_add_del_locator, "locator-set <locator_name> " \
23989 "iface <intf> | sw_if_index <sw_if_index> " \
23990 "p <priority> w <weight> [del]") \
23991 _(lisp_add_del_local_eid,"vni <vni> eid " \
23992 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23993 "locator-set <locator_name> [del]" \
23994 "[key-id sha1|sha256 secret-key <secret-key>]") \
23995 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
23996 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
23997 _(lisp_enable_disable, "enable|disable") \
23998 _(lisp_map_register_enable_disable, "enable|disable") \
23999 _(lisp_rloc_probe_enable_disable, "enable|disable") \
24000 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
24002 "rloc <locator> p <prio> " \
24003 "w <weight> [rloc <loc> ... ] " \
24004 "action <action> [del-all]") \
24005 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
24007 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
24008 _(lisp_use_petr, "<ip-address> | disable") \
24009 _(lisp_map_request_mode, "src-dst|dst-only") \
24010 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
24011 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
24012 _(lisp_locator_set_dump, "[local | remote]") \
24013 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
24014 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
24015 "[local] | [remote]") \
24016 _(lisp_eid_table_vni_dump, "") \
24017 _(lisp_eid_table_map_dump, "l2|l3") \
24018 _(lisp_map_resolver_dump, "") \
24019 _(lisp_map_server_dump, "") \
24020 _(lisp_adjacencies_get, "vni <vni>") \
24021 _(gpe_fwd_entry_vnis_get, "") \
24022 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
24023 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
24024 "[table <table-id>]") \
24025 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
24026 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
24027 _(gpe_set_encap_mode, "lisp|vxlan") \
24028 _(gpe_get_encap_mode, "") \
24029 _(lisp_gpe_add_del_iface, "up|down") \
24030 _(lisp_gpe_enable_disable, "enable|disable") \
24031 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
24032 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
24033 _(show_lisp_rloc_probe_state, "") \
24034 _(show_lisp_map_register_state, "") \
24035 _(show_lisp_status, "") \
24036 _(lisp_get_map_request_itr_rlocs, "") \
24037 _(show_lisp_pitr, "") \
24038 _(show_lisp_use_petr, "") \
24039 _(show_lisp_map_request_mode, "") \
24040 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
24041 _(af_packet_delete, "name <host interface name>") \
24042 _(af_packet_dump, "") \
24043 _(policer_add_del, "name <policer name> <params> [del]") \
24044 _(policer_dump, "[name <policer name>]") \
24045 _(policer_classify_set_interface, \
24046 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
24047 " [l2-table <nn>] [del]") \
24048 _(policer_classify_dump, "type [ip4|ip6|l2]") \
24049 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
24050 "[master|slave]") \
24051 _(netmap_delete, "name <interface name>") \
24052 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
24053 _(mpls_fib_dump, "") \
24054 _(classify_table_ids, "") \
24055 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
24056 _(classify_table_info, "table_id <nn>") \
24057 _(classify_session_dump, "table_id <nn>") \
24058 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
24059 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
24060 "[template_interval <nn>] [udp_checksum]") \
24061 _(ipfix_exporter_dump, "") \
24062 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
24063 _(ipfix_classify_stream_dump, "") \
24064 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
24065 _(ipfix_classify_table_dump, "") \
24066 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
24067 _(sw_interface_span_dump, "[l2]") \
24068 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
24069 _(pg_create_interface, "if_id <nn>") \
24070 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
24071 _(pg_enable_disable, "[stream <id>] disable") \
24072 _(ip_source_and_port_range_check_add_del, \
24073 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
24074 _(ip_source_and_port_range_check_interface_add_del, \
24075 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
24076 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
24077 _(ipsec_gre_add_del_tunnel, \
24078 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
24079 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
24080 _(delete_subif,"<intfc> | sw_if_index <nn>") \
24081 _(l2_interface_pbb_tag_rewrite, \
24082 "<intfc> | sw_if_index <nn> \n" \
24083 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
24084 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
24085 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
24086 _(flow_classify_set_interface, \
24087 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
24088 _(flow_classify_dump, "type [ip4|ip6]") \
24089 _(ip_fib_dump, "") \
24090 _(ip_mfib_dump, "") \
24091 _(ip6_fib_dump, "") \
24092 _(ip6_mfib_dump, "") \
24093 _(feature_enable_disable, "arc_name <arc_name> " \
24094 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
24095 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
24097 _(l2_xconnect_dump, "") \
24098 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
24099 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
24100 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
24101 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
24102 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
24103 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
24104 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
24105 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
24106 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
24107 _(sock_init_shm, "size <nnn>") \
24108 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
24109 _(dns_enable_disable, "[enable][disable]") \
24110 _(dns_name_server_add_del, "<ip-address> [del]") \
24111 _(dns_resolve_name, "<hostname>") \
24112 _(dns_resolve_ip, "<ip4|ip6>") \
24113 _(dns_name_server_add_del, "<ip-address> [del]") \
24114 _(dns_resolve_name, "<hostname>") \
24115 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
24116 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
24117 _(session_rules_dump, "") \
24118 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
24119 _(output_acl_set_interface, \
24120 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
24121 " [l2-table <nn>] [del]") \
24122 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
24124 /* List of command functions, CLI names map directly to functions */
24125 #define foreach_cli_function \
24126 _(comment, "usage: comment <ignore-rest-of-line>") \
24127 _(dump_interface_table, "usage: dump_interface_table") \
24128 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
24129 _(dump_ipv4_table, "usage: dump_ipv4_table") \
24130 _(dump_ipv6_table, "usage: dump_ipv6_table") \
24131 _(dump_stats_table, "usage: dump_stats_table") \
24132 _(dump_macro_table, "usage: dump_macro_table ") \
24133 _(dump_node_table, "usage: dump_node_table") \
24134 _(dump_msg_api_table, "usage: dump_msg_api_table") \
24135 _(get_msg_id, "usage: get_msg_id name_and_crc") \
24136 _(echo, "usage: echo <message>") \
24137 _(exec, "usage: exec <vpe-debug-CLI-command>") \
24138 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
24139 _(help, "usage: help") \
24140 _(q, "usage: quit") \
24141 _(quit, "usage: quit") \
24142 _(search_node_table, "usage: search_node_table <name>...") \
24143 _(set, "usage: set <variable-name> <value>") \
24144 _(script, "usage: script <file-name>") \
24145 _(statseg, "usage: statseg"); \
24146 _(unset, "usage: unset <variable-name>")
24149 static void vl_api_##n##_t_handler_uni \
24150 (vl_api_##n##_t * mp) \
24152 vat_main_t * vam = &vat_main; \
24153 if (vam->json_output) { \
24154 vl_api_##n##_t_handler_json(mp); \
24156 vl_api_##n##_t_handler(mp); \
24159 foreach_vpe_api_reply_msg;
24160 #if VPP_API_TEST_BUILTIN == 0
24161 foreach_standalone_reply_msg;
24166 vat_api_hookup (vat_main_t * vam)
24169 vl_msg_api_set_handlers(VL_API_##N, #n, \
24170 vl_api_##n##_t_handler_uni, \
24172 vl_api_##n##_t_endian, \
24173 vl_api_##n##_t_print, \
24174 sizeof(vl_api_##n##_t), 1);
24175 foreach_vpe_api_reply_msg;
24176 #if VPP_API_TEST_BUILTIN == 0
24177 foreach_standalone_reply_msg;
24181 #if (VPP_API_TEST_BUILTIN==0)
24182 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
24184 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
24186 vam->function_by_name = hash_create_string (0, sizeof (uword));
24188 vam->help_by_name = hash_create_string (0, sizeof (uword));
24191 /* API messages we can send */
24192 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
24193 foreach_vpe_api_msg;
24197 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
24198 foreach_vpe_api_msg;
24201 /* CLI functions */
24202 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
24203 foreach_cli_function;
24207 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
24208 foreach_cli_function;
24212 #if VPP_API_TEST_BUILTIN
24213 static clib_error_t *
24214 vat_api_hookup_shim (vlib_main_t * vm)
24216 vat_api_hookup (&vat_main);
24220 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
24224 * fd.io coding-style-patch-verification: ON
24227 * eval: (c-set-style "gnu")