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 int i, count = ntohl (mp->count);
1352 vat_json_init_object (&node);
1353 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1354 vat_json_object_add_uint (&node, "count", count);
1356 for (i = 0; i < count; i++)
1358 td = &mp->thread_data[i];
1359 vat_json_object_add_uint (&node, "id", ntohl (td->id));
1360 vat_json_object_add_string_copy (&node, "name", td->name);
1361 vat_json_object_add_string_copy (&node, "type", td->type);
1362 vat_json_object_add_uint (&node, "pid", ntohl (td->pid));
1363 vat_json_object_add_int (&node, "cpu_id", ntohl (td->cpu_id));
1364 vat_json_object_add_int (&node, "core", ntohl (td->id));
1365 vat_json_object_add_int (&node, "cpu_socket", ntohl (td->cpu_socket));
1368 vat_json_print (vam->ofp, &node);
1369 vat_json_free (&node);
1371 vam->retval = ntohl (mp->retval);
1372 vam->result_ready = 1;
1376 api_show_threads (vat_main_t * vam)
1378 vl_api_show_threads_t *mp;
1382 "\n%-2s %-11s %-11s %-5s %-6s %-4s %-6s",
1383 "ID", "Name", "Type", "LWP", "cpu_id", "Core", "Socket");
1385 M (SHOW_THREADS, mp);
1393 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1395 u32 sw_if_index = ntohl (mp->sw_if_index);
1396 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1397 mp->mac_ip ? "mac/ip binding" : "address resolution",
1398 ntohl (mp->pid), format_ip4_address, &mp->address,
1399 format_ethernet_address, mp->new_mac, sw_if_index);
1403 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1405 /* JSON output not supported */
1409 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1411 u32 sw_if_index = ntohl (mp->sw_if_index);
1412 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1413 mp->mac_ip ? "mac/ip binding" : "address resolution",
1414 ntohl (mp->pid), format_ip6_address, mp->address,
1415 format_ethernet_address, mp->new_mac, sw_if_index);
1419 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1421 /* JSON output not supported */
1425 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1427 u32 n_macs = ntohl (mp->n_macs);
1428 errmsg ("L2MAC event received with pid %d cl-idx %d for %d macs: \n",
1429 ntohl (mp->pid), mp->client_index, n_macs);
1431 for (i = 0; i < n_macs; i++)
1433 vl_api_mac_entry_t *mac = &mp->mac[i];
1434 errmsg (" [%d] sw_if_index %d mac_addr %U action %d \n",
1435 i + 1, ntohl (mac->sw_if_index),
1436 format_ethernet_address, mac->mac_addr, mac->action);
1443 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1445 /* JSON output not supported */
1448 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1449 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1452 * Special-case: build the bridge domain table, maintain
1453 * the next bd id vbl.
1455 static void vl_api_bridge_domain_details_t_handler
1456 (vl_api_bridge_domain_details_t * mp)
1458 vat_main_t *vam = &vat_main;
1459 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1462 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-6s %-3s",
1463 " ID", "LRN", "FWD", "FLD", "BVI", "UU-FWD", "#IF");
1465 print (vam->ofp, "%3d %3d %3d %3d %3d %6d %3d",
1466 ntohl (mp->bd_id), mp->learn, mp->forward,
1467 mp->flood, ntohl (mp->bvi_sw_if_index),
1468 ntohl (mp->uu_fwd_sw_if_index), n_sw_ifs);
1472 vl_api_bridge_domain_sw_if_t *sw_ifs;
1473 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1476 sw_ifs = mp->sw_if_details;
1477 for (i = 0; i < n_sw_ifs; i++)
1483 sw_if_index = ntohl (sw_ifs->sw_if_index);
1486 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1488 if ((u32) p->value[0] == sw_if_index)
1490 sw_if_name = (u8 *)(p->key);
1495 print (vam->ofp, "%7d %3d %s", sw_if_index,
1496 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1497 "sw_if_index not found!");
1504 static void vl_api_bridge_domain_details_t_handler_json
1505 (vl_api_bridge_domain_details_t * mp)
1507 vat_main_t *vam = &vat_main;
1508 vat_json_node_t *node, *array = NULL;
1509 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1511 if (VAT_JSON_ARRAY != vam->json_tree.type)
1513 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1514 vat_json_init_array (&vam->json_tree);
1516 node = vat_json_array_add (&vam->json_tree);
1518 vat_json_init_object (node);
1519 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1520 vat_json_object_add_uint (node, "flood", mp->flood);
1521 vat_json_object_add_uint (node, "forward", mp->forward);
1522 vat_json_object_add_uint (node, "learn", mp->learn);
1523 vat_json_object_add_uint (node, "bvi_sw_if_index",
1524 ntohl (mp->bvi_sw_if_index));
1525 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1526 array = vat_json_object_add (node, "sw_if");
1527 vat_json_init_array (array);
1533 vl_api_bridge_domain_sw_if_t *sw_ifs;
1536 sw_ifs = mp->sw_if_details;
1537 for (i = 0; i < n_sw_ifs; i++)
1539 node = vat_json_array_add (array);
1540 vat_json_init_object (node);
1541 vat_json_object_add_uint (node, "sw_if_index",
1542 ntohl (sw_ifs->sw_if_index));
1543 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1549 static void vl_api_control_ping_reply_t_handler
1550 (vl_api_control_ping_reply_t * mp)
1552 vat_main_t *vam = &vat_main;
1553 i32 retval = ntohl (mp->retval);
1554 if (vam->async_mode)
1556 vam->async_errors += (retval < 0);
1560 vam->retval = retval;
1561 vam->result_ready = 1;
1563 if (vam->socket_client_main)
1564 vam->socket_client_main->control_pings_outstanding--;
1567 static void vl_api_control_ping_reply_t_handler_json
1568 (vl_api_control_ping_reply_t * mp)
1570 vat_main_t *vam = &vat_main;
1571 i32 retval = ntohl (mp->retval);
1573 if (VAT_JSON_NONE != vam->json_tree.type)
1575 vat_json_print (vam->ofp, &vam->json_tree);
1576 vat_json_free (&vam->json_tree);
1577 vam->json_tree.type = VAT_JSON_NONE;
1582 vat_json_init_array (&vam->json_tree);
1583 vat_json_print (vam->ofp, &vam->json_tree);
1584 vam->json_tree.type = VAT_JSON_NONE;
1587 vam->retval = retval;
1588 vam->result_ready = 1;
1592 vl_api_bridge_domain_set_mac_age_reply_t_handler
1593 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1595 vat_main_t *vam = &vat_main;
1596 i32 retval = ntohl (mp->retval);
1597 if (vam->async_mode)
1599 vam->async_errors += (retval < 0);
1603 vam->retval = retval;
1604 vam->result_ready = 1;
1608 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1609 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1611 vat_main_t *vam = &vat_main;
1612 vat_json_node_t node;
1614 vat_json_init_object (&node);
1615 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1617 vat_json_print (vam->ofp, &node);
1618 vat_json_free (&node);
1620 vam->retval = ntohl (mp->retval);
1621 vam->result_ready = 1;
1625 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1627 vat_main_t *vam = &vat_main;
1628 i32 retval = ntohl (mp->retval);
1629 if (vam->async_mode)
1631 vam->async_errors += (retval < 0);
1635 vam->retval = retval;
1636 vam->result_ready = 1;
1640 static void vl_api_l2_flags_reply_t_handler_json
1641 (vl_api_l2_flags_reply_t * mp)
1643 vat_main_t *vam = &vat_main;
1644 vat_json_node_t node;
1646 vat_json_init_object (&node);
1647 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1648 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1649 ntohl (mp->resulting_feature_bitmap));
1651 vat_json_print (vam->ofp, &node);
1652 vat_json_free (&node);
1654 vam->retval = ntohl (mp->retval);
1655 vam->result_ready = 1;
1658 static void vl_api_bridge_flags_reply_t_handler
1659 (vl_api_bridge_flags_reply_t * mp)
1661 vat_main_t *vam = &vat_main;
1662 i32 retval = ntohl (mp->retval);
1663 if (vam->async_mode)
1665 vam->async_errors += (retval < 0);
1669 vam->retval = retval;
1670 vam->result_ready = 1;
1674 static void vl_api_bridge_flags_reply_t_handler_json
1675 (vl_api_bridge_flags_reply_t * mp)
1677 vat_main_t *vam = &vat_main;
1678 vat_json_node_t node;
1680 vat_json_init_object (&node);
1681 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1682 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1683 ntohl (mp->resulting_feature_bitmap));
1685 vat_json_print (vam->ofp, &node);
1686 vat_json_free (&node);
1688 vam->retval = ntohl (mp->retval);
1689 vam->result_ready = 1;
1692 static void vl_api_tap_connect_reply_t_handler
1693 (vl_api_tap_connect_reply_t * mp)
1695 vat_main_t *vam = &vat_main;
1696 i32 retval = ntohl (mp->retval);
1697 if (vam->async_mode)
1699 vam->async_errors += (retval < 0);
1703 vam->retval = retval;
1704 vam->sw_if_index = ntohl (mp->sw_if_index);
1705 vam->result_ready = 1;
1710 static void vl_api_tap_connect_reply_t_handler_json
1711 (vl_api_tap_connect_reply_t * mp)
1713 vat_main_t *vam = &vat_main;
1714 vat_json_node_t node;
1716 vat_json_init_object (&node);
1717 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1718 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1720 vat_json_print (vam->ofp, &node);
1721 vat_json_free (&node);
1723 vam->retval = ntohl (mp->retval);
1724 vam->result_ready = 1;
1729 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1731 vat_main_t *vam = &vat_main;
1732 i32 retval = ntohl (mp->retval);
1733 if (vam->async_mode)
1735 vam->async_errors += (retval < 0);
1739 vam->retval = retval;
1740 vam->sw_if_index = ntohl (mp->sw_if_index);
1741 vam->result_ready = 1;
1745 static void vl_api_tap_modify_reply_t_handler_json
1746 (vl_api_tap_modify_reply_t * mp)
1748 vat_main_t *vam = &vat_main;
1749 vat_json_node_t node;
1751 vat_json_init_object (&node);
1752 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1753 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1755 vat_json_print (vam->ofp, &node);
1756 vat_json_free (&node);
1758 vam->retval = ntohl (mp->retval);
1759 vam->result_ready = 1;
1763 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1765 vat_main_t *vam = &vat_main;
1766 i32 retval = ntohl (mp->retval);
1767 if (vam->async_mode)
1769 vam->async_errors += (retval < 0);
1773 vam->retval = retval;
1774 vam->result_ready = 1;
1778 static void vl_api_tap_delete_reply_t_handler_json
1779 (vl_api_tap_delete_reply_t * mp)
1781 vat_main_t *vam = &vat_main;
1782 vat_json_node_t node;
1784 vat_json_init_object (&node);
1785 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1787 vat_json_print (vam->ofp, &node);
1788 vat_json_free (&node);
1790 vam->retval = ntohl (mp->retval);
1791 vam->result_ready = 1;
1795 vl_api_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_reply_t * mp)
1797 vat_main_t *vam = &vat_main;
1798 i32 retval = ntohl (mp->retval);
1799 if (vam->async_mode)
1801 vam->async_errors += (retval < 0);
1805 vam->retval = retval;
1806 vam->sw_if_index = ntohl (mp->sw_if_index);
1807 vam->result_ready = 1;
1812 static void vl_api_tap_create_v2_reply_t_handler_json
1813 (vl_api_tap_create_v2_reply_t * mp)
1815 vat_main_t *vam = &vat_main;
1816 vat_json_node_t node;
1818 vat_json_init_object (&node);
1819 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1820 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1822 vat_json_print (vam->ofp, &node);
1823 vat_json_free (&node);
1825 vam->retval = ntohl (mp->retval);
1826 vam->result_ready = 1;
1831 vl_api_tap_delete_v2_reply_t_handler (vl_api_tap_delete_v2_reply_t * mp)
1833 vat_main_t *vam = &vat_main;
1834 i32 retval = ntohl (mp->retval);
1835 if (vam->async_mode)
1837 vam->async_errors += (retval < 0);
1841 vam->retval = retval;
1842 vam->result_ready = 1;
1846 static void vl_api_tap_delete_v2_reply_t_handler_json
1847 (vl_api_tap_delete_v2_reply_t * mp)
1849 vat_main_t *vam = &vat_main;
1850 vat_json_node_t node;
1852 vat_json_init_object (&node);
1853 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1855 vat_json_print (vam->ofp, &node);
1856 vat_json_free (&node);
1858 vam->retval = ntohl (mp->retval);
1859 vam->result_ready = 1;
1863 vl_api_bond_create_reply_t_handler (vl_api_bond_create_reply_t * mp)
1865 vat_main_t *vam = &vat_main;
1866 i32 retval = ntohl (mp->retval);
1868 if (vam->async_mode)
1870 vam->async_errors += (retval < 0);
1874 vam->retval = retval;
1875 vam->sw_if_index = ntohl (mp->sw_if_index);
1876 vam->result_ready = 1;
1880 static void vl_api_bond_create_reply_t_handler_json
1881 (vl_api_bond_create_reply_t * mp)
1883 vat_main_t *vam = &vat_main;
1884 vat_json_node_t node;
1886 vat_json_init_object (&node);
1887 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1888 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1890 vat_json_print (vam->ofp, &node);
1891 vat_json_free (&node);
1893 vam->retval = ntohl (mp->retval);
1894 vam->result_ready = 1;
1898 vl_api_bond_delete_reply_t_handler (vl_api_bond_delete_reply_t * mp)
1900 vat_main_t *vam = &vat_main;
1901 i32 retval = ntohl (mp->retval);
1903 if (vam->async_mode)
1905 vam->async_errors += (retval < 0);
1909 vam->retval = retval;
1910 vam->result_ready = 1;
1914 static void vl_api_bond_delete_reply_t_handler_json
1915 (vl_api_bond_delete_reply_t * mp)
1917 vat_main_t *vam = &vat_main;
1918 vat_json_node_t node;
1920 vat_json_init_object (&node);
1921 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1923 vat_json_print (vam->ofp, &node);
1924 vat_json_free (&node);
1926 vam->retval = ntohl (mp->retval);
1927 vam->result_ready = 1;
1931 vl_api_bond_enslave_reply_t_handler (vl_api_bond_enslave_reply_t * mp)
1933 vat_main_t *vam = &vat_main;
1934 i32 retval = ntohl (mp->retval);
1936 if (vam->async_mode)
1938 vam->async_errors += (retval < 0);
1942 vam->retval = retval;
1943 vam->result_ready = 1;
1947 static void vl_api_bond_enslave_reply_t_handler_json
1948 (vl_api_bond_enslave_reply_t * mp)
1950 vat_main_t *vam = &vat_main;
1951 vat_json_node_t node;
1953 vat_json_init_object (&node);
1954 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1956 vat_json_print (vam->ofp, &node);
1957 vat_json_free (&node);
1959 vam->retval = ntohl (mp->retval);
1960 vam->result_ready = 1;
1964 vl_api_bond_detach_slave_reply_t_handler (vl_api_bond_detach_slave_reply_t *
1967 vat_main_t *vam = &vat_main;
1968 i32 retval = ntohl (mp->retval);
1970 if (vam->async_mode)
1972 vam->async_errors += (retval < 0);
1976 vam->retval = retval;
1977 vam->result_ready = 1;
1981 static void vl_api_bond_detach_slave_reply_t_handler_json
1982 (vl_api_bond_detach_slave_reply_t * mp)
1984 vat_main_t *vam = &vat_main;
1985 vat_json_node_t node;
1987 vat_json_init_object (&node);
1988 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1990 vat_json_print (vam->ofp, &node);
1991 vat_json_free (&node);
1993 vam->retval = ntohl (mp->retval);
1994 vam->result_ready = 1;
1997 static void vl_api_sw_interface_bond_details_t_handler
1998 (vl_api_sw_interface_bond_details_t * mp)
2000 vat_main_t *vam = &vat_main;
2003 "%-16s %-12d %-12U %-13U %-14u %-14u",
2004 mp->interface_name, ntohl (mp->sw_if_index),
2005 format_bond_mode, mp->mode, format_bond_load_balance, mp->lb,
2006 ntohl (mp->active_slaves), ntohl (mp->slaves));
2009 static void vl_api_sw_interface_bond_details_t_handler_json
2010 (vl_api_sw_interface_bond_details_t * mp)
2012 vat_main_t *vam = &vat_main;
2013 vat_json_node_t *node = NULL;
2015 if (VAT_JSON_ARRAY != vam->json_tree.type)
2017 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2018 vat_json_init_array (&vam->json_tree);
2020 node = vat_json_array_add (&vam->json_tree);
2022 vat_json_init_object (node);
2023 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2024 vat_json_object_add_string_copy (node, "interface_name",
2025 mp->interface_name);
2026 vat_json_object_add_uint (node, "mode", mp->mode);
2027 vat_json_object_add_uint (node, "load_balance", mp->lb);
2028 vat_json_object_add_uint (node, "active_slaves", ntohl (mp->active_slaves));
2029 vat_json_object_add_uint (node, "slaves", ntohl (mp->slaves));
2033 api_sw_interface_bond_dump (vat_main_t * vam)
2035 vl_api_sw_interface_bond_dump_t *mp;
2036 vl_api_control_ping_t *mp_ping;
2040 "\n%-16s %-12s %-12s %-13s %-14s %-14s",
2041 "interface name", "sw_if_index", "mode", "load balance",
2042 "active slaves", "slaves");
2044 /* Get list of bond interfaces */
2045 M (SW_INTERFACE_BOND_DUMP, mp);
2048 /* Use a control ping for synchronization */
2049 MPING (CONTROL_PING, mp_ping);
2056 static void vl_api_sw_interface_slave_details_t_handler
2057 (vl_api_sw_interface_slave_details_t * mp)
2059 vat_main_t *vam = &vat_main;
2062 "%-25s %-12d %-12d %d", mp->interface_name,
2063 ntohl (mp->sw_if_index), mp->is_passive, mp->is_long_timeout);
2066 static void vl_api_sw_interface_slave_details_t_handler_json
2067 (vl_api_sw_interface_slave_details_t * mp)
2069 vat_main_t *vam = &vat_main;
2070 vat_json_node_t *node = NULL;
2072 if (VAT_JSON_ARRAY != vam->json_tree.type)
2074 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2075 vat_json_init_array (&vam->json_tree);
2077 node = vat_json_array_add (&vam->json_tree);
2079 vat_json_init_object (node);
2080 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2081 vat_json_object_add_string_copy (node, "interface_name",
2082 mp->interface_name);
2083 vat_json_object_add_uint (node, "passive", mp->is_passive);
2084 vat_json_object_add_uint (node, "long_timeout", mp->is_long_timeout);
2088 api_sw_interface_slave_dump (vat_main_t * vam)
2090 unformat_input_t *i = vam->input;
2091 vl_api_sw_interface_slave_dump_t *mp;
2092 vl_api_control_ping_t *mp_ping;
2093 u32 sw_if_index = ~0;
2094 u8 sw_if_index_set = 0;
2097 /* Parse args required to build the message */
2098 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2100 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2101 sw_if_index_set = 1;
2102 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2103 sw_if_index_set = 1;
2108 if (sw_if_index_set == 0)
2110 errmsg ("missing vpp interface name. ");
2115 "\n%-25s %-12s %-12s %s",
2116 "slave interface name", "sw_if_index", "passive", "long_timeout");
2118 /* Get list of bond interfaces */
2119 M (SW_INTERFACE_SLAVE_DUMP, mp);
2120 mp->sw_if_index = ntohl (sw_if_index);
2123 /* Use a control ping for synchronization */
2124 MPING (CONTROL_PING, mp_ping);
2131 static void vl_api_mpls_tunnel_add_del_reply_t_handler
2132 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2134 vat_main_t *vam = &vat_main;
2135 i32 retval = ntohl (mp->retval);
2136 if (vam->async_mode)
2138 vam->async_errors += (retval < 0);
2142 vam->retval = retval;
2143 vam->result_ready = 1;
2147 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
2148 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2150 vat_main_t *vam = &vat_main;
2151 vat_json_node_t node;
2153 vat_json_init_object (&node);
2154 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2155 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
2156 ntohl (mp->sw_if_index));
2158 vat_json_print (vam->ofp, &node);
2159 vat_json_free (&node);
2161 vam->retval = ntohl (mp->retval);
2162 vam->result_ready = 1;
2165 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
2166 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2168 vat_main_t *vam = &vat_main;
2169 i32 retval = ntohl (mp->retval);
2170 if (vam->async_mode)
2172 vam->async_errors += (retval < 0);
2176 vam->retval = retval;
2177 vam->sw_if_index = ntohl (mp->sw_if_index);
2178 vam->result_ready = 1;
2182 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
2183 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2185 vat_main_t *vam = &vat_main;
2186 vat_json_node_t node;
2188 vat_json_init_object (&node);
2189 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2190 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2192 vat_json_print (vam->ofp, &node);
2193 vat_json_free (&node);
2195 vam->retval = ntohl (mp->retval);
2196 vam->result_ready = 1;
2199 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
2200 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2202 vat_main_t *vam = &vat_main;
2203 i32 retval = ntohl (mp->retval);
2204 if (vam->async_mode)
2206 vam->async_errors += (retval < 0);
2210 vam->retval = retval;
2211 vam->result_ready = 1;
2215 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
2216 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2218 vat_main_t *vam = &vat_main;
2219 vat_json_node_t node;
2221 vat_json_init_object (&node);
2222 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2223 vat_json_object_add_uint (&node, "fwd_entry_index",
2224 clib_net_to_host_u32 (mp->fwd_entry_index));
2226 vat_json_print (vam->ofp, &node);
2227 vat_json_free (&node);
2229 vam->retval = ntohl (mp->retval);
2230 vam->result_ready = 1;
2234 format_lisp_transport_protocol (u8 * s, va_list * args)
2236 u32 proto = va_arg (*args, u32);
2241 return format (s, "udp");
2243 return format (s, "api");
2250 static void vl_api_one_get_transport_protocol_reply_t_handler
2251 (vl_api_one_get_transport_protocol_reply_t * mp)
2253 vat_main_t *vam = &vat_main;
2254 i32 retval = ntohl (mp->retval);
2255 if (vam->async_mode)
2257 vam->async_errors += (retval < 0);
2261 u32 proto = mp->protocol;
2262 print (vam->ofp, "Transport protocol: %U",
2263 format_lisp_transport_protocol, proto);
2264 vam->retval = retval;
2265 vam->result_ready = 1;
2269 static void vl_api_one_get_transport_protocol_reply_t_handler_json
2270 (vl_api_one_get_transport_protocol_reply_t * mp)
2272 vat_main_t *vam = &vat_main;
2273 vat_json_node_t node;
2276 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
2279 vat_json_init_object (&node);
2280 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2281 vat_json_object_add_string_copy (&node, "transport-protocol", s);
2284 vat_json_print (vam->ofp, &node);
2285 vat_json_free (&node);
2287 vam->retval = ntohl (mp->retval);
2288 vam->result_ready = 1;
2291 static void vl_api_one_add_del_locator_set_reply_t_handler
2292 (vl_api_one_add_del_locator_set_reply_t * mp)
2294 vat_main_t *vam = &vat_main;
2295 i32 retval = ntohl (mp->retval);
2296 if (vam->async_mode)
2298 vam->async_errors += (retval < 0);
2302 vam->retval = retval;
2303 vam->result_ready = 1;
2307 static void vl_api_one_add_del_locator_set_reply_t_handler_json
2308 (vl_api_one_add_del_locator_set_reply_t * mp)
2310 vat_main_t *vam = &vat_main;
2311 vat_json_node_t node;
2313 vat_json_init_object (&node);
2314 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2315 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
2317 vat_json_print (vam->ofp, &node);
2318 vat_json_free (&node);
2320 vam->retval = ntohl (mp->retval);
2321 vam->result_ready = 1;
2324 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
2325 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2327 vat_main_t *vam = &vat_main;
2328 i32 retval = ntohl (mp->retval);
2329 if (vam->async_mode)
2331 vam->async_errors += (retval < 0);
2335 vam->retval = retval;
2336 vam->sw_if_index = ntohl (mp->sw_if_index);
2337 vam->result_ready = 1;
2339 vam->regenerate_interface_table = 1;
2342 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
2343 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2345 vat_main_t *vam = &vat_main;
2346 vat_json_node_t node;
2348 vat_json_init_object (&node);
2349 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2350 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2352 vat_json_print (vam->ofp, &node);
2353 vat_json_free (&node);
2355 vam->retval = ntohl (mp->retval);
2356 vam->result_ready = 1;
2359 static void vl_api_vxlan_offload_rx_reply_t_handler
2360 (vl_api_vxlan_offload_rx_reply_t * mp)
2362 vat_main_t *vam = &vat_main;
2363 i32 retval = ntohl (mp->retval);
2364 if (vam->async_mode)
2366 vam->async_errors += (retval < 0);
2370 vam->retval = retval;
2371 vam->result_ready = 1;
2375 static void vl_api_vxlan_offload_rx_reply_t_handler_json
2376 (vl_api_vxlan_offload_rx_reply_t * mp)
2378 vat_main_t *vam = &vat_main;
2379 vat_json_node_t node;
2381 vat_json_init_object (&node);
2382 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2384 vat_json_print (vam->ofp, &node);
2385 vat_json_free (&node);
2387 vam->retval = ntohl (mp->retval);
2388 vam->result_ready = 1;
2391 static void vl_api_geneve_add_del_tunnel_reply_t_handler
2392 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2394 vat_main_t *vam = &vat_main;
2395 i32 retval = ntohl (mp->retval);
2396 if (vam->async_mode)
2398 vam->async_errors += (retval < 0);
2402 vam->retval = retval;
2403 vam->sw_if_index = ntohl (mp->sw_if_index);
2404 vam->result_ready = 1;
2408 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
2409 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2411 vat_main_t *vam = &vat_main;
2412 vat_json_node_t node;
2414 vat_json_init_object (&node);
2415 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2416 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2418 vat_json_print (vam->ofp, &node);
2419 vat_json_free (&node);
2421 vam->retval = ntohl (mp->retval);
2422 vam->result_ready = 1;
2425 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
2426 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2428 vat_main_t *vam = &vat_main;
2429 i32 retval = ntohl (mp->retval);
2430 if (vam->async_mode)
2432 vam->async_errors += (retval < 0);
2436 vam->retval = retval;
2437 vam->sw_if_index = ntohl (mp->sw_if_index);
2438 vam->result_ready = 1;
2440 vam->regenerate_interface_table = 1;
2443 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
2444 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2446 vat_main_t *vam = &vat_main;
2447 vat_json_node_t node;
2449 vat_json_init_object (&node);
2450 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2451 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2453 vat_json_print (vam->ofp, &node);
2454 vat_json_free (&node);
2456 vam->retval = ntohl (mp->retval);
2457 vam->result_ready = 1;
2460 static void vl_api_gre_add_del_tunnel_reply_t_handler
2461 (vl_api_gre_add_del_tunnel_reply_t * mp)
2463 vat_main_t *vam = &vat_main;
2464 i32 retval = ntohl (mp->retval);
2465 if (vam->async_mode)
2467 vam->async_errors += (retval < 0);
2471 vam->retval = retval;
2472 vam->sw_if_index = ntohl (mp->sw_if_index);
2473 vam->result_ready = 1;
2477 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
2478 (vl_api_gre_add_del_tunnel_reply_t * mp)
2480 vat_main_t *vam = &vat_main;
2481 vat_json_node_t node;
2483 vat_json_init_object (&node);
2484 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2485 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2487 vat_json_print (vam->ofp, &node);
2488 vat_json_free (&node);
2490 vam->retval = ntohl (mp->retval);
2491 vam->result_ready = 1;
2494 static void vl_api_create_vhost_user_if_reply_t_handler
2495 (vl_api_create_vhost_user_if_reply_t * mp)
2497 vat_main_t *vam = &vat_main;
2498 i32 retval = ntohl (mp->retval);
2499 if (vam->async_mode)
2501 vam->async_errors += (retval < 0);
2505 vam->retval = retval;
2506 vam->sw_if_index = ntohl (mp->sw_if_index);
2507 vam->result_ready = 1;
2509 vam->regenerate_interface_table = 1;
2512 static void vl_api_create_vhost_user_if_reply_t_handler_json
2513 (vl_api_create_vhost_user_if_reply_t * mp)
2515 vat_main_t *vam = &vat_main;
2516 vat_json_node_t node;
2518 vat_json_init_object (&node);
2519 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2520 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2522 vat_json_print (vam->ofp, &node);
2523 vat_json_free (&node);
2525 vam->retval = ntohl (mp->retval);
2526 vam->result_ready = 1;
2529 static void vl_api_dns_resolve_name_reply_t_handler
2530 (vl_api_dns_resolve_name_reply_t * mp)
2532 vat_main_t *vam = &vat_main;
2533 i32 retval = ntohl (mp->retval);
2534 if (vam->async_mode)
2536 vam->async_errors += (retval < 0);
2540 vam->retval = retval;
2541 vam->result_ready = 1;
2546 clib_warning ("ip4 address %U", format_ip4_address,
2547 (ip4_address_t *) mp->ip4_address);
2549 clib_warning ("ip6 address %U", format_ip6_address,
2550 (ip6_address_t *) mp->ip6_address);
2553 clib_warning ("retval %d", retval);
2557 static void vl_api_dns_resolve_name_reply_t_handler_json
2558 (vl_api_dns_resolve_name_reply_t * mp)
2560 clib_warning ("not implemented");
2563 static void vl_api_dns_resolve_ip_reply_t_handler
2564 (vl_api_dns_resolve_ip_reply_t * mp)
2566 vat_main_t *vam = &vat_main;
2567 i32 retval = ntohl (mp->retval);
2568 if (vam->async_mode)
2570 vam->async_errors += (retval < 0);
2574 vam->retval = retval;
2575 vam->result_ready = 1;
2579 clib_warning ("canonical name %s", mp->name);
2582 clib_warning ("retval %d", retval);
2586 static void vl_api_dns_resolve_ip_reply_t_handler_json
2587 (vl_api_dns_resolve_ip_reply_t * mp)
2589 clib_warning ("not implemented");
2593 static void vl_api_ip_address_details_t_handler
2594 (vl_api_ip_address_details_t * mp)
2596 vat_main_t *vam = &vat_main;
2597 static ip_address_details_t empty_ip_address_details = { {0} };
2598 ip_address_details_t *address = NULL;
2599 ip_details_t *current_ip_details = NULL;
2600 ip_details_t *details = NULL;
2602 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2604 if (!details || vam->current_sw_if_index >= vec_len (details)
2605 || !details[vam->current_sw_if_index].present)
2607 errmsg ("ip address details arrived but not stored");
2608 errmsg ("ip_dump should be called first");
2612 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2614 #define addresses (current_ip_details->addr)
2616 vec_validate_init_empty (addresses, vec_len (addresses),
2617 empty_ip_address_details);
2619 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2621 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
2622 address->prefix_length = mp->prefix_length;
2626 static void vl_api_ip_address_details_t_handler_json
2627 (vl_api_ip_address_details_t * mp)
2629 vat_main_t *vam = &vat_main;
2630 vat_json_node_t *node = NULL;
2631 struct in6_addr ip6;
2634 if (VAT_JSON_ARRAY != vam->json_tree.type)
2636 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2637 vat_json_init_array (&vam->json_tree);
2639 node = vat_json_array_add (&vam->json_tree);
2641 vat_json_init_object (node);
2644 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
2645 vat_json_object_add_ip6 (node, "ip", ip6);
2649 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
2650 vat_json_object_add_ip4 (node, "ip", ip4);
2652 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
2656 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2658 vat_main_t *vam = &vat_main;
2659 static ip_details_t empty_ip_details = { 0 };
2660 ip_details_t *ip = NULL;
2661 u32 sw_if_index = ~0;
2663 sw_if_index = ntohl (mp->sw_if_index);
2665 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2666 sw_if_index, empty_ip_details);
2668 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2675 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2677 vat_main_t *vam = &vat_main;
2679 if (VAT_JSON_ARRAY != vam->json_tree.type)
2681 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2682 vat_json_init_array (&vam->json_tree);
2684 vat_json_array_add_uint (&vam->json_tree,
2685 clib_net_to_host_u32 (mp->sw_if_index));
2689 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2691 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2692 "router_addr %U host_mac %U",
2693 ntohl (mp->pid), mp->lease.is_ipv6 ? "ipv6" : "ipv4",
2695 format_ip4_address, &mp->lease.host_address,
2696 format_ip4_address, &mp->lease.router_address,
2697 format_ethernet_address, mp->lease.host_mac);
2700 static void vl_api_dhcp_compl_event_t_handler_json
2701 (vl_api_dhcp_compl_event_t * mp)
2703 /* JSON output not supported */
2707 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2710 vat_main_t *vam = &vat_main;
2711 static u64 default_counter = 0;
2713 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2715 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2716 sw_if_index, default_counter);
2717 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2721 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2722 interface_counter_t counter)
2724 vat_main_t *vam = &vat_main;
2725 static interface_counter_t default_counter = { 0, };
2727 vec_validate_init_empty (vam->combined_interface_counters,
2728 vnet_counter_type, NULL);
2729 vec_validate_init_empty (vam->combined_interface_counters
2730 [vnet_counter_type], sw_if_index, default_counter);
2731 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2734 static void vl_api_vnet_interface_simple_counters_t_handler
2735 (vl_api_vnet_interface_simple_counters_t * mp)
2740 static void vl_api_vnet_interface_combined_counters_t_handler
2741 (vl_api_vnet_interface_combined_counters_t * mp)
2746 static void vl_api_vnet_interface_simple_counters_t_handler_json
2747 (vl_api_vnet_interface_simple_counters_t * mp)
2752 u32 first_sw_if_index;
2755 count = ntohl (mp->count);
2756 first_sw_if_index = ntohl (mp->first_sw_if_index);
2758 v_packets = (u64 *) & mp->data;
2759 for (i = 0; i < count; i++)
2761 packets = clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2762 set_simple_interface_counter (mp->vnet_counter_type,
2763 first_sw_if_index + i, packets);
2768 static void vl_api_vnet_interface_combined_counters_t_handler_json
2769 (vl_api_vnet_interface_combined_counters_t * mp)
2771 interface_counter_t counter;
2773 u32 first_sw_if_index;
2777 count = ntohl (mp->count);
2778 first_sw_if_index = ntohl (mp->first_sw_if_index);
2780 v = (vlib_counter_t *) & mp->data;
2781 for (i = 0; i < count; i++)
2784 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2786 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2787 set_combined_interface_counter (mp->vnet_counter_type,
2788 first_sw_if_index + i, counter);
2794 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2796 vat_main_t *vam = &vat_main;
2799 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2801 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2810 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2812 vat_main_t *vam = &vat_main;
2815 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2817 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2825 static void vl_api_vnet_ip4_fib_counters_t_handler
2826 (vl_api_vnet_ip4_fib_counters_t * mp)
2831 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2832 (vl_api_vnet_ip4_fib_counters_t * mp)
2834 vat_main_t *vam = &vat_main;
2835 vl_api_ip4_fib_counter_t *v;
2836 ip4_fib_counter_t *counter;
2843 vrf_id = ntohl (mp->vrf_id);
2844 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2845 if (~0 == vrf_index)
2847 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2848 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2849 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2850 vec_validate (vam->ip4_fib_counters, vrf_index);
2851 vam->ip4_fib_counters[vrf_index] = NULL;
2854 vec_free (vam->ip4_fib_counters[vrf_index]);
2855 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2856 count = ntohl (mp->count);
2857 for (i = 0; i < count; i++)
2859 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2860 counter = &vam->ip4_fib_counters[vrf_index][i];
2861 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2862 counter->address = ip4;
2863 counter->address_length = v->address_length;
2864 counter->packets = clib_net_to_host_u64 (v->packets);
2865 counter->bytes = clib_net_to_host_u64 (v->bytes);
2870 static void vl_api_vnet_ip4_nbr_counters_t_handler
2871 (vl_api_vnet_ip4_nbr_counters_t * mp)
2876 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2877 (vl_api_vnet_ip4_nbr_counters_t * mp)
2879 vat_main_t *vam = &vat_main;
2880 vl_api_ip4_nbr_counter_t *v;
2881 ip4_nbr_counter_t *counter;
2886 sw_if_index = ntohl (mp->sw_if_index);
2887 count = ntohl (mp->count);
2888 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2891 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2893 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2894 for (i = 0; i < count; i++)
2896 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2897 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2898 counter->address.s_addr = v->address;
2899 counter->packets = clib_net_to_host_u64 (v->packets);
2900 counter->bytes = clib_net_to_host_u64 (v->bytes);
2901 counter->linkt = v->link_type;
2906 static void vl_api_vnet_ip6_fib_counters_t_handler
2907 (vl_api_vnet_ip6_fib_counters_t * mp)
2912 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2913 (vl_api_vnet_ip6_fib_counters_t * mp)
2915 vat_main_t *vam = &vat_main;
2916 vl_api_ip6_fib_counter_t *v;
2917 ip6_fib_counter_t *counter;
2918 struct in6_addr ip6;
2924 vrf_id = ntohl (mp->vrf_id);
2925 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2926 if (~0 == vrf_index)
2928 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2929 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2930 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2931 vec_validate (vam->ip6_fib_counters, vrf_index);
2932 vam->ip6_fib_counters[vrf_index] = NULL;
2935 vec_free (vam->ip6_fib_counters[vrf_index]);
2936 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2937 count = ntohl (mp->count);
2938 for (i = 0; i < count; i++)
2940 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2941 counter = &vam->ip6_fib_counters[vrf_index][i];
2942 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2943 counter->address = ip6;
2944 counter->address_length = v->address_length;
2945 counter->packets = clib_net_to_host_u64 (v->packets);
2946 counter->bytes = clib_net_to_host_u64 (v->bytes);
2951 static void vl_api_vnet_ip6_nbr_counters_t_handler
2952 (vl_api_vnet_ip6_nbr_counters_t * mp)
2957 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2958 (vl_api_vnet_ip6_nbr_counters_t * mp)
2960 vat_main_t *vam = &vat_main;
2961 vl_api_ip6_nbr_counter_t *v;
2962 ip6_nbr_counter_t *counter;
2963 struct in6_addr ip6;
2968 sw_if_index = ntohl (mp->sw_if_index);
2969 count = ntohl (mp->count);
2970 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2973 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2975 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2976 for (i = 0; i < count; i++)
2978 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2979 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2980 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2981 counter->address = ip6;
2982 counter->packets = clib_net_to_host_u64 (v->packets);
2983 counter->bytes = clib_net_to_host_u64 (v->bytes);
2988 static void vl_api_get_first_msg_id_reply_t_handler
2989 (vl_api_get_first_msg_id_reply_t * mp)
2991 vat_main_t *vam = &vat_main;
2992 i32 retval = ntohl (mp->retval);
2994 if (vam->async_mode)
2996 vam->async_errors += (retval < 0);
3000 vam->retval = retval;
3001 vam->result_ready = 1;
3005 errmsg ("first message id %d", ntohs (mp->first_msg_id));
3009 static void vl_api_get_first_msg_id_reply_t_handler_json
3010 (vl_api_get_first_msg_id_reply_t * mp)
3012 vat_main_t *vam = &vat_main;
3013 vat_json_node_t node;
3015 vat_json_init_object (&node);
3016 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3017 vat_json_object_add_uint (&node, "first_msg_id",
3018 (uint) ntohs (mp->first_msg_id));
3020 vat_json_print (vam->ofp, &node);
3021 vat_json_free (&node);
3023 vam->retval = ntohl (mp->retval);
3024 vam->result_ready = 1;
3027 static void vl_api_get_node_graph_reply_t_handler
3028 (vl_api_get_node_graph_reply_t * mp)
3030 vat_main_t *vam = &vat_main;
3031 api_main_t *am = &api_main;
3032 i32 retval = ntohl (mp->retval);
3033 u8 *pvt_copy, *reply;
3038 if (vam->async_mode)
3040 vam->async_errors += (retval < 0);
3044 vam->retval = retval;
3045 vam->result_ready = 1;
3048 /* "Should never happen..." */
3052 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
3053 pvt_copy = vec_dup (reply);
3055 /* Toss the shared-memory original... */
3056 pthread_mutex_lock (&am->vlib_rp->mutex);
3057 oldheap = svm_push_data_heap (am->vlib_rp);
3061 svm_pop_heap (oldheap);
3062 pthread_mutex_unlock (&am->vlib_rp->mutex);
3064 if (vam->graph_nodes)
3066 hash_free (vam->graph_node_index_by_name);
3068 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
3070 node = vam->graph_nodes[0][i];
3071 vec_free (node->name);
3072 vec_free (node->next_nodes);
3075 vec_free (vam->graph_nodes[0]);
3076 vec_free (vam->graph_nodes);
3079 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
3080 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
3081 vec_free (pvt_copy);
3083 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
3085 node = vam->graph_nodes[0][i];
3086 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
3090 static void vl_api_get_node_graph_reply_t_handler_json
3091 (vl_api_get_node_graph_reply_t * mp)
3093 vat_main_t *vam = &vat_main;
3094 api_main_t *am = &api_main;
3096 vat_json_node_t node;
3099 /* $$$$ make this real? */
3100 vat_json_init_object (&node);
3101 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3102 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
3104 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
3106 /* Toss the shared-memory original... */
3107 pthread_mutex_lock (&am->vlib_rp->mutex);
3108 oldheap = svm_push_data_heap (am->vlib_rp);
3112 svm_pop_heap (oldheap);
3113 pthread_mutex_unlock (&am->vlib_rp->mutex);
3115 vat_json_print (vam->ofp, &node);
3116 vat_json_free (&node);
3118 vam->retval = ntohl (mp->retval);
3119 vam->result_ready = 1;
3123 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
3125 vat_main_t *vam = &vat_main;
3130 s = format (s, "%=16d%=16d%=16d",
3131 ntohl (mp->sw_if_index), mp->priority, mp->weight);
3135 s = format (s, "%=16U%=16d%=16d",
3136 mp->is_ipv6 ? format_ip6_address :
3138 mp->ip_address, mp->priority, mp->weight);
3141 print (vam->ofp, "%v", s);
3146 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
3148 vat_main_t *vam = &vat_main;
3149 vat_json_node_t *node = NULL;
3150 struct in6_addr ip6;
3153 if (VAT_JSON_ARRAY != vam->json_tree.type)
3155 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3156 vat_json_init_array (&vam->json_tree);
3158 node = vat_json_array_add (&vam->json_tree);
3159 vat_json_init_object (node);
3161 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
3162 vat_json_object_add_uint (node, "priority", mp->priority);
3163 vat_json_object_add_uint (node, "weight", mp->weight);
3166 vat_json_object_add_uint (node, "sw_if_index",
3167 clib_net_to_host_u32 (mp->sw_if_index));
3172 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3173 vat_json_object_add_ip6 (node, "address", ip6);
3177 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3178 vat_json_object_add_ip4 (node, "address", ip4);
3184 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
3187 vat_main_t *vam = &vat_main;
3190 ls_name = format (0, "%s", mp->ls_name);
3192 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
3198 vl_api_one_locator_set_details_t_handler_json
3199 (vl_api_one_locator_set_details_t * mp)
3201 vat_main_t *vam = &vat_main;
3202 vat_json_node_t *node = 0;
3205 ls_name = format (0, "%s", mp->ls_name);
3206 vec_add1 (ls_name, 0);
3208 if (VAT_JSON_ARRAY != vam->json_tree.type)
3210 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3211 vat_json_init_array (&vam->json_tree);
3213 node = vat_json_array_add (&vam->json_tree);
3215 vat_json_init_object (node);
3216 vat_json_object_add_string_copy (node, "ls_name", ls_name);
3217 vat_json_object_add_uint (node, "ls_index",
3218 clib_net_to_host_u32 (mp->ls_index));
3226 } __attribute__ ((__packed__)) lisp_nsh_api_t;
3229 unformat_nsh_address (unformat_input_t * input, va_list * args)
3231 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
3232 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
3236 format_nsh_address_vat (u8 * s, va_list * args)
3238 nsh_t *a = va_arg (*args, nsh_t *);
3239 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
3243 format_lisp_flat_eid (u8 * s, va_list * args)
3245 u32 type = va_arg (*args, u32);
3246 u8 *eid = va_arg (*args, u8 *);
3247 u32 eid_len = va_arg (*args, u32);
3252 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
3254 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
3256 return format (s, "%U", format_ethernet_address, eid);
3258 return format (s, "%U", format_nsh_address_vat, eid);
3264 format_lisp_eid_vat (u8 * s, va_list * args)
3266 u32 type = va_arg (*args, u32);
3267 u8 *eid = va_arg (*args, u8 *);
3268 u32 eid_len = va_arg (*args, u32);
3269 u8 *seid = va_arg (*args, u8 *);
3270 u32 seid_len = va_arg (*args, u32);
3271 u32 is_src_dst = va_arg (*args, u32);
3274 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
3276 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
3282 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
3284 vat_main_t *vam = &vat_main;
3285 u8 *s = 0, *eid = 0;
3287 if (~0 == mp->locator_set_index)
3288 s = format (0, "action: %d", mp->action);
3290 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3292 eid = format (0, "%U", format_lisp_eid_vat,
3296 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3299 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3300 clib_net_to_host_u32 (mp->vni),
3302 mp->is_local ? "local" : "remote",
3303 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3304 clib_net_to_host_u16 (mp->key_id), mp->key);
3311 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3314 vat_main_t *vam = &vat_main;
3315 vat_json_node_t *node = 0;
3318 if (VAT_JSON_ARRAY != vam->json_tree.type)
3320 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3321 vat_json_init_array (&vam->json_tree);
3323 node = vat_json_array_add (&vam->json_tree);
3325 vat_json_init_object (node);
3326 if (~0 == mp->locator_set_index)
3327 vat_json_object_add_uint (node, "action", mp->action);
3329 vat_json_object_add_uint (node, "locator_set_index",
3330 clib_net_to_host_u32 (mp->locator_set_index));
3332 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3333 if (mp->eid_type == 3)
3335 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3336 vat_json_init_object (nsh_json);
3337 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3338 vat_json_object_add_uint (nsh_json, "spi",
3339 clib_net_to_host_u32 (nsh->spi));
3340 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3344 eid = format (0, "%U", format_lisp_eid_vat,
3348 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3350 vat_json_object_add_string_copy (node, "eid", eid);
3353 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3354 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3355 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3359 vat_json_object_add_uint (node, "key_id",
3360 clib_net_to_host_u16 (mp->key_id));
3361 vat_json_object_add_string_copy (node, "key", mp->key);
3366 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3368 vat_main_t *vam = &vat_main;
3369 u8 *seid = 0, *deid = 0;
3370 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3372 deid = format (0, "%U", format_lisp_eid_vat,
3373 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3375 seid = format (0, "%U", format_lisp_eid_vat,
3376 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3382 format_ip_address_fcn = format_ip4_address;
3384 format_ip_address_fcn = format_ip6_address;
3387 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3388 clib_net_to_host_u32 (mp->vni),
3390 format_ip_address_fcn, mp->lloc,
3391 format_ip_address_fcn, mp->rloc,
3392 clib_net_to_host_u32 (mp->pkt_count),
3393 clib_net_to_host_u32 (mp->bytes));
3400 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3402 struct in6_addr ip6;
3404 vat_main_t *vam = &vat_main;
3405 vat_json_node_t *node = 0;
3406 u8 *deid = 0, *seid = 0;
3408 if (VAT_JSON_ARRAY != vam->json_tree.type)
3410 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3411 vat_json_init_array (&vam->json_tree);
3413 node = vat_json_array_add (&vam->json_tree);
3415 vat_json_init_object (node);
3416 deid = format (0, "%U", format_lisp_eid_vat,
3417 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3419 seid = format (0, "%U", format_lisp_eid_vat,
3420 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3425 vat_json_object_add_string_copy (node, "seid", seid);
3426 vat_json_object_add_string_copy (node, "deid", deid);
3427 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3431 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3432 vat_json_object_add_ip4 (node, "lloc", ip4);
3433 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3434 vat_json_object_add_ip4 (node, "rloc", ip4);
3438 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3439 vat_json_object_add_ip6 (node, "lloc", ip6);
3440 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3441 vat_json_object_add_ip6 (node, "rloc", ip6);
3443 vat_json_object_add_uint (node, "pkt_count",
3444 clib_net_to_host_u32 (mp->pkt_count));
3445 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3452 vl_api_one_eid_table_map_details_t_handler
3453 (vl_api_one_eid_table_map_details_t * mp)
3455 vat_main_t *vam = &vat_main;
3457 u8 *line = format (0, "%=10d%=10d",
3458 clib_net_to_host_u32 (mp->vni),
3459 clib_net_to_host_u32 (mp->dp_table));
3460 print (vam->ofp, "%v", line);
3465 vl_api_one_eid_table_map_details_t_handler_json
3466 (vl_api_one_eid_table_map_details_t * mp)
3468 vat_main_t *vam = &vat_main;
3469 vat_json_node_t *node = NULL;
3471 if (VAT_JSON_ARRAY != vam->json_tree.type)
3473 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3474 vat_json_init_array (&vam->json_tree);
3476 node = vat_json_array_add (&vam->json_tree);
3477 vat_json_init_object (node);
3478 vat_json_object_add_uint (node, "dp_table",
3479 clib_net_to_host_u32 (mp->dp_table));
3480 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3484 vl_api_one_eid_table_vni_details_t_handler
3485 (vl_api_one_eid_table_vni_details_t * mp)
3487 vat_main_t *vam = &vat_main;
3489 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3490 print (vam->ofp, "%v", line);
3495 vl_api_one_eid_table_vni_details_t_handler_json
3496 (vl_api_one_eid_table_vni_details_t * mp)
3498 vat_main_t *vam = &vat_main;
3499 vat_json_node_t *node = NULL;
3501 if (VAT_JSON_ARRAY != vam->json_tree.type)
3503 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3504 vat_json_init_array (&vam->json_tree);
3506 node = vat_json_array_add (&vam->json_tree);
3507 vat_json_init_object (node);
3508 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3512 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3513 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3515 vat_main_t *vam = &vat_main;
3516 int retval = clib_net_to_host_u32 (mp->retval);
3518 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3519 print (vam->ofp, "fallback threshold value: %d", mp->value);
3521 vam->retval = retval;
3522 vam->result_ready = 1;
3526 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3527 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3529 vat_main_t *vam = &vat_main;
3530 vat_json_node_t _node, *node = &_node;
3531 int retval = clib_net_to_host_u32 (mp->retval);
3533 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3534 vat_json_init_object (node);
3535 vat_json_object_add_uint (node, "value", mp->value);
3537 vat_json_print (vam->ofp, node);
3538 vat_json_free (node);
3540 vam->retval = retval;
3541 vam->result_ready = 1;
3545 vl_api_show_one_map_register_state_reply_t_handler
3546 (vl_api_show_one_map_register_state_reply_t * mp)
3548 vat_main_t *vam = &vat_main;
3549 int retval = clib_net_to_host_u32 (mp->retval);
3551 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3553 vam->retval = retval;
3554 vam->result_ready = 1;
3558 vl_api_show_one_map_register_state_reply_t_handler_json
3559 (vl_api_show_one_map_register_state_reply_t * mp)
3561 vat_main_t *vam = &vat_main;
3562 vat_json_node_t _node, *node = &_node;
3563 int retval = clib_net_to_host_u32 (mp->retval);
3565 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3567 vat_json_init_object (node);
3568 vat_json_object_add_string_copy (node, "state", s);
3570 vat_json_print (vam->ofp, node);
3571 vat_json_free (node);
3573 vam->retval = retval;
3574 vam->result_ready = 1;
3579 vl_api_show_one_rloc_probe_state_reply_t_handler
3580 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3582 vat_main_t *vam = &vat_main;
3583 int retval = clib_net_to_host_u32 (mp->retval);
3588 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3590 vam->retval = retval;
3591 vam->result_ready = 1;
3595 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3596 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3598 vat_main_t *vam = &vat_main;
3599 vat_json_node_t _node, *node = &_node;
3600 int retval = clib_net_to_host_u32 (mp->retval);
3602 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3603 vat_json_init_object (node);
3604 vat_json_object_add_string_copy (node, "state", s);
3606 vat_json_print (vam->ofp, node);
3607 vat_json_free (node);
3609 vam->retval = retval;
3610 vam->result_ready = 1;
3615 vl_api_show_one_stats_enable_disable_reply_t_handler
3616 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3618 vat_main_t *vam = &vat_main;
3619 int retval = clib_net_to_host_u32 (mp->retval);
3624 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3626 vam->retval = retval;
3627 vam->result_ready = 1;
3631 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3632 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3634 vat_main_t *vam = &vat_main;
3635 vat_json_node_t _node, *node = &_node;
3636 int retval = clib_net_to_host_u32 (mp->retval);
3638 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3639 vat_json_init_object (node);
3640 vat_json_object_add_string_copy (node, "state", s);
3642 vat_json_print (vam->ofp, node);
3643 vat_json_free (node);
3645 vam->retval = retval;
3646 vam->result_ready = 1;
3651 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3653 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3654 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3655 e->vni = clib_net_to_host_u32 (e->vni);
3659 gpe_fwd_entries_get_reply_t_net_to_host
3660 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3664 mp->count = clib_net_to_host_u32 (mp->count);
3665 for (i = 0; i < mp->count; i++)
3667 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3672 format_gpe_encap_mode (u8 * s, va_list * args)
3674 u32 mode = va_arg (*args, u32);
3679 return format (s, "lisp");
3681 return format (s, "vxlan");
3687 vl_api_gpe_get_encap_mode_reply_t_handler
3688 (vl_api_gpe_get_encap_mode_reply_t * mp)
3690 vat_main_t *vam = &vat_main;
3692 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3693 vam->retval = ntohl (mp->retval);
3694 vam->result_ready = 1;
3698 vl_api_gpe_get_encap_mode_reply_t_handler_json
3699 (vl_api_gpe_get_encap_mode_reply_t * mp)
3701 vat_main_t *vam = &vat_main;
3702 vat_json_node_t node;
3704 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3705 vec_add1 (encap_mode, 0);
3707 vat_json_init_object (&node);
3708 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3710 vec_free (encap_mode);
3711 vat_json_print (vam->ofp, &node);
3712 vat_json_free (&node);
3714 vam->retval = ntohl (mp->retval);
3715 vam->result_ready = 1;
3719 vl_api_gpe_fwd_entry_path_details_t_handler
3720 (vl_api_gpe_fwd_entry_path_details_t * mp)
3722 vat_main_t *vam = &vat_main;
3723 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3725 if (mp->lcl_loc.is_ip4)
3726 format_ip_address_fcn = format_ip4_address;
3728 format_ip_address_fcn = format_ip6_address;
3730 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3731 format_ip_address_fcn, &mp->lcl_loc,
3732 format_ip_address_fcn, &mp->rmt_loc);
3736 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3738 struct in6_addr ip6;
3743 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3744 vat_json_object_add_ip4 (n, "address", ip4);
3748 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3749 vat_json_object_add_ip6 (n, "address", ip6);
3751 vat_json_object_add_uint (n, "weight", loc->weight);
3755 vl_api_gpe_fwd_entry_path_details_t_handler_json
3756 (vl_api_gpe_fwd_entry_path_details_t * mp)
3758 vat_main_t *vam = &vat_main;
3759 vat_json_node_t *node = NULL;
3760 vat_json_node_t *loc_node;
3762 if (VAT_JSON_ARRAY != vam->json_tree.type)
3764 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3765 vat_json_init_array (&vam->json_tree);
3767 node = vat_json_array_add (&vam->json_tree);
3768 vat_json_init_object (node);
3770 loc_node = vat_json_object_add (node, "local_locator");
3771 vat_json_init_object (loc_node);
3772 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3774 loc_node = vat_json_object_add (node, "remote_locator");
3775 vat_json_init_object (loc_node);
3776 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3780 vl_api_gpe_fwd_entries_get_reply_t_handler
3781 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3783 vat_main_t *vam = &vat_main;
3785 int retval = clib_net_to_host_u32 (mp->retval);
3786 vl_api_gpe_fwd_entry_t *e;
3791 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3793 for (i = 0; i < mp->count; i++)
3795 e = &mp->entries[i];
3796 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3797 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3798 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3802 vam->retval = retval;
3803 vam->result_ready = 1;
3807 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3808 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3811 vat_main_t *vam = &vat_main;
3812 vat_json_node_t *e = 0, root;
3814 int retval = clib_net_to_host_u32 (mp->retval);
3815 vl_api_gpe_fwd_entry_t *fwd;
3820 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3821 vat_json_init_array (&root);
3823 for (i = 0; i < mp->count; i++)
3825 e = vat_json_array_add (&root);
3826 fwd = &mp->entries[i];
3828 vat_json_init_object (e);
3829 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3830 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3831 vat_json_object_add_int (e, "vni", fwd->vni);
3832 vat_json_object_add_int (e, "action", fwd->action);
3834 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3835 fwd->leid_prefix_len);
3837 vat_json_object_add_string_copy (e, "leid", s);
3840 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3841 fwd->reid_prefix_len);
3843 vat_json_object_add_string_copy (e, "reid", s);
3847 vat_json_print (vam->ofp, &root);
3848 vat_json_free (&root);
3851 vam->retval = retval;
3852 vam->result_ready = 1;
3856 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3857 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3859 vat_main_t *vam = &vat_main;
3861 int retval = clib_net_to_host_u32 (mp->retval);
3862 vl_api_gpe_native_fwd_rpath_t *r;
3867 n = clib_net_to_host_u32 (mp->count);
3869 for (i = 0; i < n; i++)
3871 r = &mp->entries[i];
3872 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3873 clib_net_to_host_u32 (r->fib_index),
3874 clib_net_to_host_u32 (r->nh_sw_if_index),
3875 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3879 vam->retval = retval;
3880 vam->result_ready = 1;
3884 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3885 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3887 vat_main_t *vam = &vat_main;
3888 vat_json_node_t root, *e;
3890 int retval = clib_net_to_host_u32 (mp->retval);
3891 vl_api_gpe_native_fwd_rpath_t *r;
3897 n = clib_net_to_host_u32 (mp->count);
3898 vat_json_init_array (&root);
3900 for (i = 0; i < n; i++)
3902 e = vat_json_array_add (&root);
3903 vat_json_init_object (e);
3904 r = &mp->entries[i];
3906 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3909 vat_json_object_add_string_copy (e, "ip4", s);
3912 vat_json_object_add_uint (e, "fib_index",
3913 clib_net_to_host_u32 (r->fib_index));
3914 vat_json_object_add_uint (e, "nh_sw_if_index",
3915 clib_net_to_host_u32 (r->nh_sw_if_index));
3918 vat_json_print (vam->ofp, &root);
3919 vat_json_free (&root);
3922 vam->retval = retval;
3923 vam->result_ready = 1;
3927 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3928 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3930 vat_main_t *vam = &vat_main;
3932 int retval = clib_net_to_host_u32 (mp->retval);
3937 n = clib_net_to_host_u32 (mp->count);
3939 for (i = 0; i < n; i++)
3940 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3943 vam->retval = retval;
3944 vam->result_ready = 1;
3948 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3949 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3951 vat_main_t *vam = &vat_main;
3952 vat_json_node_t root;
3954 int retval = clib_net_to_host_u32 (mp->retval);
3959 n = clib_net_to_host_u32 (mp->count);
3960 vat_json_init_array (&root);
3962 for (i = 0; i < n; i++)
3963 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3965 vat_json_print (vam->ofp, &root);
3966 vat_json_free (&root);
3969 vam->retval = retval;
3970 vam->result_ready = 1;
3974 vl_api_one_ndp_entries_get_reply_t_handler
3975 (vl_api_one_ndp_entries_get_reply_t * mp)
3977 vat_main_t *vam = &vat_main;
3979 int retval = clib_net_to_host_u32 (mp->retval);
3984 n = clib_net_to_host_u32 (mp->count);
3986 for (i = 0; i < n; i++)
3987 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3988 format_ethernet_address, mp->entries[i].mac);
3991 vam->retval = retval;
3992 vam->result_ready = 1;
3996 vl_api_one_ndp_entries_get_reply_t_handler_json
3997 (vl_api_one_ndp_entries_get_reply_t * mp)
4000 vat_main_t *vam = &vat_main;
4001 vat_json_node_t *e = 0, root;
4003 int retval = clib_net_to_host_u32 (mp->retval);
4004 vl_api_one_ndp_entry_t *arp_entry;
4009 n = clib_net_to_host_u32 (mp->count);
4010 vat_json_init_array (&root);
4012 for (i = 0; i < n; i++)
4014 e = vat_json_array_add (&root);
4015 arp_entry = &mp->entries[i];
4017 vat_json_init_object (e);
4018 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
4021 vat_json_object_add_string_copy (e, "mac", s);
4024 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
4026 vat_json_object_add_string_copy (e, "ip6", s);
4030 vat_json_print (vam->ofp, &root);
4031 vat_json_free (&root);
4034 vam->retval = retval;
4035 vam->result_ready = 1;
4039 vl_api_one_l2_arp_entries_get_reply_t_handler
4040 (vl_api_one_l2_arp_entries_get_reply_t * mp)
4042 vat_main_t *vam = &vat_main;
4044 int retval = clib_net_to_host_u32 (mp->retval);
4049 n = clib_net_to_host_u32 (mp->count);
4051 for (i = 0; i < n; i++)
4052 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
4053 format_ethernet_address, mp->entries[i].mac);
4056 vam->retval = retval;
4057 vam->result_ready = 1;
4061 vl_api_one_l2_arp_entries_get_reply_t_handler_json
4062 (vl_api_one_l2_arp_entries_get_reply_t * mp)
4065 vat_main_t *vam = &vat_main;
4066 vat_json_node_t *e = 0, root;
4068 int retval = clib_net_to_host_u32 (mp->retval);
4069 vl_api_one_l2_arp_entry_t *arp_entry;
4074 n = clib_net_to_host_u32 (mp->count);
4075 vat_json_init_array (&root);
4077 for (i = 0; i < n; i++)
4079 e = vat_json_array_add (&root);
4080 arp_entry = &mp->entries[i];
4082 vat_json_init_object (e);
4083 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
4086 vat_json_object_add_string_copy (e, "mac", s);
4089 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
4091 vat_json_object_add_string_copy (e, "ip4", s);
4095 vat_json_print (vam->ofp, &root);
4096 vat_json_free (&root);
4099 vam->retval = retval;
4100 vam->result_ready = 1;
4104 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
4106 vat_main_t *vam = &vat_main;
4108 int retval = clib_net_to_host_u32 (mp->retval);
4113 n = clib_net_to_host_u32 (mp->count);
4115 for (i = 0; i < n; i++)
4117 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
4121 vam->retval = retval;
4122 vam->result_ready = 1;
4126 vl_api_one_ndp_bd_get_reply_t_handler_json
4127 (vl_api_one_ndp_bd_get_reply_t * mp)
4129 vat_main_t *vam = &vat_main;
4130 vat_json_node_t root;
4132 int retval = clib_net_to_host_u32 (mp->retval);
4137 n = clib_net_to_host_u32 (mp->count);
4138 vat_json_init_array (&root);
4140 for (i = 0; i < n; i++)
4142 vat_json_array_add_uint (&root,
4143 clib_net_to_host_u32 (mp->bridge_domains[i]));
4146 vat_json_print (vam->ofp, &root);
4147 vat_json_free (&root);
4150 vam->retval = retval;
4151 vam->result_ready = 1;
4155 vl_api_one_l2_arp_bd_get_reply_t_handler
4156 (vl_api_one_l2_arp_bd_get_reply_t * mp)
4158 vat_main_t *vam = &vat_main;
4160 int retval = clib_net_to_host_u32 (mp->retval);
4165 n = clib_net_to_host_u32 (mp->count);
4167 for (i = 0; i < n; i++)
4169 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
4173 vam->retval = retval;
4174 vam->result_ready = 1;
4178 vl_api_one_l2_arp_bd_get_reply_t_handler_json
4179 (vl_api_one_l2_arp_bd_get_reply_t * mp)
4181 vat_main_t *vam = &vat_main;
4182 vat_json_node_t root;
4184 int retval = clib_net_to_host_u32 (mp->retval);
4189 n = clib_net_to_host_u32 (mp->count);
4190 vat_json_init_array (&root);
4192 for (i = 0; i < n; i++)
4194 vat_json_array_add_uint (&root,
4195 clib_net_to_host_u32 (mp->bridge_domains[i]));
4198 vat_json_print (vam->ofp, &root);
4199 vat_json_free (&root);
4202 vam->retval = retval;
4203 vam->result_ready = 1;
4207 vl_api_one_adjacencies_get_reply_t_handler
4208 (vl_api_one_adjacencies_get_reply_t * mp)
4210 vat_main_t *vam = &vat_main;
4212 int retval = clib_net_to_host_u32 (mp->retval);
4213 vl_api_one_adjacency_t *a;
4218 n = clib_net_to_host_u32 (mp->count);
4220 for (i = 0; i < n; i++)
4222 a = &mp->adjacencies[i];
4223 print (vam->ofp, "%U %40U",
4224 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
4225 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
4229 vam->retval = retval;
4230 vam->result_ready = 1;
4234 vl_api_one_adjacencies_get_reply_t_handler_json
4235 (vl_api_one_adjacencies_get_reply_t * mp)
4238 vat_main_t *vam = &vat_main;
4239 vat_json_node_t *e = 0, root;
4241 int retval = clib_net_to_host_u32 (mp->retval);
4242 vl_api_one_adjacency_t *a;
4247 n = clib_net_to_host_u32 (mp->count);
4248 vat_json_init_array (&root);
4250 for (i = 0; i < n; i++)
4252 e = vat_json_array_add (&root);
4253 a = &mp->adjacencies[i];
4255 vat_json_init_object (e);
4256 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
4257 a->leid_prefix_len);
4259 vat_json_object_add_string_copy (e, "leid", s);
4262 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
4263 a->reid_prefix_len);
4265 vat_json_object_add_string_copy (e, "reid", s);
4269 vat_json_print (vam->ofp, &root);
4270 vat_json_free (&root);
4273 vam->retval = retval;
4274 vam->result_ready = 1;
4278 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
4280 vat_main_t *vam = &vat_main;
4282 print (vam->ofp, "%=20U",
4283 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4288 vl_api_one_map_server_details_t_handler_json
4289 (vl_api_one_map_server_details_t * mp)
4291 vat_main_t *vam = &vat_main;
4292 vat_json_node_t *node = NULL;
4293 struct in6_addr ip6;
4296 if (VAT_JSON_ARRAY != vam->json_tree.type)
4298 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4299 vat_json_init_array (&vam->json_tree);
4301 node = vat_json_array_add (&vam->json_tree);
4303 vat_json_init_object (node);
4306 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4307 vat_json_object_add_ip6 (node, "map-server", ip6);
4311 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4312 vat_json_object_add_ip4 (node, "map-server", ip4);
4317 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4320 vat_main_t *vam = &vat_main;
4322 print (vam->ofp, "%=20U",
4323 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4328 vl_api_one_map_resolver_details_t_handler_json
4329 (vl_api_one_map_resolver_details_t * mp)
4331 vat_main_t *vam = &vat_main;
4332 vat_json_node_t *node = NULL;
4333 struct in6_addr ip6;
4336 if (VAT_JSON_ARRAY != vam->json_tree.type)
4338 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4339 vat_json_init_array (&vam->json_tree);
4341 node = vat_json_array_add (&vam->json_tree);
4343 vat_json_init_object (node);
4346 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4347 vat_json_object_add_ip6 (node, "map resolver", ip6);
4351 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4352 vat_json_object_add_ip4 (node, "map resolver", ip4);
4357 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4359 vat_main_t *vam = &vat_main;
4360 i32 retval = ntohl (mp->retval);
4364 print (vam->ofp, "feature: %s\ngpe: %s",
4365 mp->feature_status ? "enabled" : "disabled",
4366 mp->gpe_status ? "enabled" : "disabled");
4369 vam->retval = retval;
4370 vam->result_ready = 1;
4374 vl_api_show_one_status_reply_t_handler_json
4375 (vl_api_show_one_status_reply_t * mp)
4377 vat_main_t *vam = &vat_main;
4378 vat_json_node_t node;
4379 u8 *gpe_status = NULL;
4380 u8 *feature_status = NULL;
4382 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4383 feature_status = format (0, "%s",
4384 mp->feature_status ? "enabled" : "disabled");
4385 vec_add1 (gpe_status, 0);
4386 vec_add1 (feature_status, 0);
4388 vat_json_init_object (&node);
4389 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4390 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4392 vec_free (gpe_status);
4393 vec_free (feature_status);
4395 vat_json_print (vam->ofp, &node);
4396 vat_json_free (&node);
4398 vam->retval = ntohl (mp->retval);
4399 vam->result_ready = 1;
4403 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4404 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4406 vat_main_t *vam = &vat_main;
4407 i32 retval = ntohl (mp->retval);
4411 print (vam->ofp, "%=20s", mp->locator_set_name);
4414 vam->retval = retval;
4415 vam->result_ready = 1;
4419 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4420 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4422 vat_main_t *vam = &vat_main;
4423 vat_json_node_t *node = NULL;
4425 if (VAT_JSON_ARRAY != vam->json_tree.type)
4427 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4428 vat_json_init_array (&vam->json_tree);
4430 node = vat_json_array_add (&vam->json_tree);
4432 vat_json_init_object (node);
4433 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4435 vat_json_print (vam->ofp, node);
4436 vat_json_free (node);
4438 vam->retval = ntohl (mp->retval);
4439 vam->result_ready = 1;
4443 format_lisp_map_request_mode (u8 * s, va_list * args)
4445 u32 mode = va_arg (*args, u32);
4450 return format (0, "dst-only");
4452 return format (0, "src-dst");
4458 vl_api_show_one_map_request_mode_reply_t_handler
4459 (vl_api_show_one_map_request_mode_reply_t * mp)
4461 vat_main_t *vam = &vat_main;
4462 i32 retval = ntohl (mp->retval);
4466 u32 mode = mp->mode;
4467 print (vam->ofp, "map_request_mode: %U",
4468 format_lisp_map_request_mode, mode);
4471 vam->retval = retval;
4472 vam->result_ready = 1;
4476 vl_api_show_one_map_request_mode_reply_t_handler_json
4477 (vl_api_show_one_map_request_mode_reply_t * mp)
4479 vat_main_t *vam = &vat_main;
4480 vat_json_node_t node;
4485 s = format (0, "%U", format_lisp_map_request_mode, mode);
4488 vat_json_init_object (&node);
4489 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4490 vat_json_print (vam->ofp, &node);
4491 vat_json_free (&node);
4494 vam->retval = ntohl (mp->retval);
4495 vam->result_ready = 1;
4499 vl_api_one_show_xtr_mode_reply_t_handler
4500 (vl_api_one_show_xtr_mode_reply_t * mp)
4502 vat_main_t *vam = &vat_main;
4503 i32 retval = ntohl (mp->retval);
4507 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4510 vam->retval = retval;
4511 vam->result_ready = 1;
4515 vl_api_one_show_xtr_mode_reply_t_handler_json
4516 (vl_api_one_show_xtr_mode_reply_t * mp)
4518 vat_main_t *vam = &vat_main;
4519 vat_json_node_t node;
4522 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4523 vec_add1 (status, 0);
4525 vat_json_init_object (&node);
4526 vat_json_object_add_string_copy (&node, "status", status);
4530 vat_json_print (vam->ofp, &node);
4531 vat_json_free (&node);
4533 vam->retval = ntohl (mp->retval);
4534 vam->result_ready = 1;
4538 vl_api_one_show_pitr_mode_reply_t_handler
4539 (vl_api_one_show_pitr_mode_reply_t * mp)
4541 vat_main_t *vam = &vat_main;
4542 i32 retval = ntohl (mp->retval);
4546 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4549 vam->retval = retval;
4550 vam->result_ready = 1;
4554 vl_api_one_show_pitr_mode_reply_t_handler_json
4555 (vl_api_one_show_pitr_mode_reply_t * mp)
4557 vat_main_t *vam = &vat_main;
4558 vat_json_node_t node;
4561 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4562 vec_add1 (status, 0);
4564 vat_json_init_object (&node);
4565 vat_json_object_add_string_copy (&node, "status", status);
4569 vat_json_print (vam->ofp, &node);
4570 vat_json_free (&node);
4572 vam->retval = ntohl (mp->retval);
4573 vam->result_ready = 1;
4577 vl_api_one_show_petr_mode_reply_t_handler
4578 (vl_api_one_show_petr_mode_reply_t * mp)
4580 vat_main_t *vam = &vat_main;
4581 i32 retval = ntohl (mp->retval);
4585 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4588 vam->retval = retval;
4589 vam->result_ready = 1;
4593 vl_api_one_show_petr_mode_reply_t_handler_json
4594 (vl_api_one_show_petr_mode_reply_t * mp)
4596 vat_main_t *vam = &vat_main;
4597 vat_json_node_t node;
4600 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4601 vec_add1 (status, 0);
4603 vat_json_init_object (&node);
4604 vat_json_object_add_string_copy (&node, "status", status);
4608 vat_json_print (vam->ofp, &node);
4609 vat_json_free (&node);
4611 vam->retval = ntohl (mp->retval);
4612 vam->result_ready = 1;
4616 vl_api_show_one_use_petr_reply_t_handler
4617 (vl_api_show_one_use_petr_reply_t * mp)
4619 vat_main_t *vam = &vat_main;
4620 i32 retval = ntohl (mp->retval);
4624 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4627 print (vam->ofp, "Proxy-ETR address; %U",
4628 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4633 vam->retval = retval;
4634 vam->result_ready = 1;
4638 vl_api_show_one_use_petr_reply_t_handler_json
4639 (vl_api_show_one_use_petr_reply_t * mp)
4641 vat_main_t *vam = &vat_main;
4642 vat_json_node_t node;
4645 struct in6_addr ip6;
4647 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4648 vec_add1 (status, 0);
4650 vat_json_init_object (&node);
4651 vat_json_object_add_string_copy (&node, "status", status);
4656 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4657 vat_json_object_add_ip6 (&node, "address", ip6);
4661 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4662 vat_json_object_add_ip4 (&node, "address", ip4);
4668 vat_json_print (vam->ofp, &node);
4669 vat_json_free (&node);
4671 vam->retval = ntohl (mp->retval);
4672 vam->result_ready = 1;
4676 vl_api_show_one_nsh_mapping_reply_t_handler
4677 (vl_api_show_one_nsh_mapping_reply_t * mp)
4679 vat_main_t *vam = &vat_main;
4680 i32 retval = ntohl (mp->retval);
4684 print (vam->ofp, "%-20s%-16s",
4685 mp->is_set ? "set" : "not-set",
4686 mp->is_set ? (char *) mp->locator_set_name : "");
4689 vam->retval = retval;
4690 vam->result_ready = 1;
4694 vl_api_show_one_nsh_mapping_reply_t_handler_json
4695 (vl_api_show_one_nsh_mapping_reply_t * mp)
4697 vat_main_t *vam = &vat_main;
4698 vat_json_node_t node;
4701 status = format (0, "%s", mp->is_set ? "yes" : "no");
4702 vec_add1 (status, 0);
4704 vat_json_init_object (&node);
4705 vat_json_object_add_string_copy (&node, "is_set", status);
4708 vat_json_object_add_string_copy (&node, "locator_set",
4709 mp->locator_set_name);
4714 vat_json_print (vam->ofp, &node);
4715 vat_json_free (&node);
4717 vam->retval = ntohl (mp->retval);
4718 vam->result_ready = 1;
4722 vl_api_show_one_map_register_ttl_reply_t_handler
4723 (vl_api_show_one_map_register_ttl_reply_t * mp)
4725 vat_main_t *vam = &vat_main;
4726 i32 retval = ntohl (mp->retval);
4728 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4732 print (vam->ofp, "ttl: %u", mp->ttl);
4735 vam->retval = retval;
4736 vam->result_ready = 1;
4740 vl_api_show_one_map_register_ttl_reply_t_handler_json
4741 (vl_api_show_one_map_register_ttl_reply_t * mp)
4743 vat_main_t *vam = &vat_main;
4744 vat_json_node_t node;
4746 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4747 vat_json_init_object (&node);
4748 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4750 vat_json_print (vam->ofp, &node);
4751 vat_json_free (&node);
4753 vam->retval = ntohl (mp->retval);
4754 vam->result_ready = 1;
4758 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4760 vat_main_t *vam = &vat_main;
4761 i32 retval = ntohl (mp->retval);
4765 print (vam->ofp, "%-20s%-16s",
4766 mp->status ? "enabled" : "disabled",
4767 mp->status ? (char *) mp->locator_set_name : "");
4770 vam->retval = retval;
4771 vam->result_ready = 1;
4775 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4777 vat_main_t *vam = &vat_main;
4778 vat_json_node_t node;
4781 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4782 vec_add1 (status, 0);
4784 vat_json_init_object (&node);
4785 vat_json_object_add_string_copy (&node, "status", status);
4788 vat_json_object_add_string_copy (&node, "locator_set",
4789 mp->locator_set_name);
4794 vat_json_print (vam->ofp, &node);
4795 vat_json_free (&node);
4797 vam->retval = ntohl (mp->retval);
4798 vam->result_ready = 1;
4802 format_policer_type (u8 * s, va_list * va)
4804 u32 i = va_arg (*va, u32);
4806 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4807 s = format (s, "1r2c");
4808 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4809 s = format (s, "1r3c");
4810 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4811 s = format (s, "2r3c-2698");
4812 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4813 s = format (s, "2r3c-4115");
4814 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4815 s = format (s, "2r3c-mef5cf1");
4817 s = format (s, "ILLEGAL");
4822 format_policer_rate_type (u8 * s, va_list * va)
4824 u32 i = va_arg (*va, u32);
4826 if (i == SSE2_QOS_RATE_KBPS)
4827 s = format (s, "kbps");
4828 else if (i == SSE2_QOS_RATE_PPS)
4829 s = format (s, "pps");
4831 s = format (s, "ILLEGAL");
4836 format_policer_round_type (u8 * s, va_list * va)
4838 u32 i = va_arg (*va, u32);
4840 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4841 s = format (s, "closest");
4842 else if (i == SSE2_QOS_ROUND_TO_UP)
4843 s = format (s, "up");
4844 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4845 s = format (s, "down");
4847 s = format (s, "ILLEGAL");
4852 format_policer_action_type (u8 * s, va_list * va)
4854 u32 i = va_arg (*va, u32);
4856 if (i == SSE2_QOS_ACTION_DROP)
4857 s = format (s, "drop");
4858 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4859 s = format (s, "transmit");
4860 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4861 s = format (s, "mark-and-transmit");
4863 s = format (s, "ILLEGAL");
4868 format_dscp (u8 * s, va_list * va)
4870 u32 i = va_arg (*va, u32);
4875 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4879 return format (s, "ILLEGAL");
4881 s = format (s, "%s", t);
4886 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4888 vat_main_t *vam = &vat_main;
4889 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4891 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4892 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4894 conform_dscp_str = format (0, "");
4896 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4897 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4899 exceed_dscp_str = format (0, "");
4901 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4902 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4904 violate_dscp_str = format (0, "");
4906 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4907 "rate type %U, round type %U, %s rate, %s color-aware, "
4908 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4909 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4910 "conform action %U%s, exceed action %U%s, violate action %U%s",
4912 format_policer_type, mp->type,
4915 clib_net_to_host_u64 (mp->cb),
4916 clib_net_to_host_u64 (mp->eb),
4917 format_policer_rate_type, mp->rate_type,
4918 format_policer_round_type, mp->round_type,
4919 mp->single_rate ? "single" : "dual",
4920 mp->color_aware ? "is" : "not",
4921 ntohl (mp->cir_tokens_per_period),
4922 ntohl (mp->pir_tokens_per_period),
4924 ntohl (mp->current_limit),
4925 ntohl (mp->current_bucket),
4926 ntohl (mp->extended_limit),
4927 ntohl (mp->extended_bucket),
4928 clib_net_to_host_u64 (mp->last_update_time),
4929 format_policer_action_type, mp->conform_action_type,
4931 format_policer_action_type, mp->exceed_action_type,
4933 format_policer_action_type, mp->violate_action_type,
4936 vec_free (conform_dscp_str);
4937 vec_free (exceed_dscp_str);
4938 vec_free (violate_dscp_str);
4941 static void vl_api_policer_details_t_handler_json
4942 (vl_api_policer_details_t * mp)
4944 vat_main_t *vam = &vat_main;
4945 vat_json_node_t *node;
4946 u8 *rate_type_str, *round_type_str, *type_str;
4947 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4949 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4951 format (0, "%U", format_policer_round_type, mp->round_type);
4952 type_str = format (0, "%U", format_policer_type, mp->type);
4953 conform_action_str = format (0, "%U", format_policer_action_type,
4954 mp->conform_action_type);
4955 exceed_action_str = format (0, "%U", format_policer_action_type,
4956 mp->exceed_action_type);
4957 violate_action_str = format (0, "%U", format_policer_action_type,
4958 mp->violate_action_type);
4960 if (VAT_JSON_ARRAY != vam->json_tree.type)
4962 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4963 vat_json_init_array (&vam->json_tree);
4965 node = vat_json_array_add (&vam->json_tree);
4967 vat_json_init_object (node);
4968 vat_json_object_add_string_copy (node, "name", mp->name);
4969 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4970 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4971 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4972 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4973 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4974 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4975 vat_json_object_add_string_copy (node, "type", type_str);
4976 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4977 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4978 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4979 vat_json_object_add_uint (node, "cir_tokens_per_period",
4980 ntohl (mp->cir_tokens_per_period));
4981 vat_json_object_add_uint (node, "eir_tokens_per_period",
4982 ntohl (mp->pir_tokens_per_period));
4983 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4984 vat_json_object_add_uint (node, "current_bucket",
4985 ntohl (mp->current_bucket));
4986 vat_json_object_add_uint (node, "extended_limit",
4987 ntohl (mp->extended_limit));
4988 vat_json_object_add_uint (node, "extended_bucket",
4989 ntohl (mp->extended_bucket));
4990 vat_json_object_add_uint (node, "last_update_time",
4991 ntohl (mp->last_update_time));
4992 vat_json_object_add_string_copy (node, "conform_action",
4993 conform_action_str);
4994 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4996 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4997 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4998 vec_free (dscp_str);
5000 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
5001 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
5003 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
5004 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
5005 vec_free (dscp_str);
5007 vat_json_object_add_string_copy (node, "violate_action",
5008 violate_action_str);
5009 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
5011 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
5012 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
5013 vec_free (dscp_str);
5016 vec_free (rate_type_str);
5017 vec_free (round_type_str);
5018 vec_free (type_str);
5019 vec_free (conform_action_str);
5020 vec_free (exceed_action_str);
5021 vec_free (violate_action_str);
5025 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
5028 vat_main_t *vam = &vat_main;
5029 int i, count = ntohl (mp->count);
5032 print (vam->ofp, "classify table ids (%d) : ", count);
5033 for (i = 0; i < count; i++)
5035 print (vam->ofp, "%d", ntohl (mp->ids[i]));
5036 print (vam->ofp, (i < count - 1) ? "," : "");
5038 vam->retval = ntohl (mp->retval);
5039 vam->result_ready = 1;
5043 vl_api_classify_table_ids_reply_t_handler_json
5044 (vl_api_classify_table_ids_reply_t * mp)
5046 vat_main_t *vam = &vat_main;
5047 int i, count = ntohl (mp->count);
5051 vat_json_node_t node;
5053 vat_json_init_object (&node);
5054 for (i = 0; i < count; i++)
5056 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
5058 vat_json_print (vam->ofp, &node);
5059 vat_json_free (&node);
5061 vam->retval = ntohl (mp->retval);
5062 vam->result_ready = 1;
5066 vl_api_classify_table_by_interface_reply_t_handler
5067 (vl_api_classify_table_by_interface_reply_t * mp)
5069 vat_main_t *vam = &vat_main;
5072 table_id = ntohl (mp->l2_table_id);
5074 print (vam->ofp, "l2 table id : %d", table_id);
5076 print (vam->ofp, "l2 table id : No input ACL tables configured");
5077 table_id = ntohl (mp->ip4_table_id);
5079 print (vam->ofp, "ip4 table id : %d", table_id);
5081 print (vam->ofp, "ip4 table id : No input ACL tables configured");
5082 table_id = ntohl (mp->ip6_table_id);
5084 print (vam->ofp, "ip6 table id : %d", table_id);
5086 print (vam->ofp, "ip6 table id : No input ACL tables configured");
5087 vam->retval = ntohl (mp->retval);
5088 vam->result_ready = 1;
5092 vl_api_classify_table_by_interface_reply_t_handler_json
5093 (vl_api_classify_table_by_interface_reply_t * mp)
5095 vat_main_t *vam = &vat_main;
5096 vat_json_node_t node;
5098 vat_json_init_object (&node);
5100 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
5101 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
5102 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
5104 vat_json_print (vam->ofp, &node);
5105 vat_json_free (&node);
5107 vam->retval = ntohl (mp->retval);
5108 vam->result_ready = 1;
5111 static void vl_api_policer_add_del_reply_t_handler
5112 (vl_api_policer_add_del_reply_t * mp)
5114 vat_main_t *vam = &vat_main;
5115 i32 retval = ntohl (mp->retval);
5116 if (vam->async_mode)
5118 vam->async_errors += (retval < 0);
5122 vam->retval = retval;
5123 vam->result_ready = 1;
5124 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
5126 * Note: this is just barely thread-safe, depends on
5127 * the main thread spinning waiting for an answer...
5129 errmsg ("policer index %d", ntohl (mp->policer_index));
5133 static void vl_api_policer_add_del_reply_t_handler_json
5134 (vl_api_policer_add_del_reply_t * mp)
5136 vat_main_t *vam = &vat_main;
5137 vat_json_node_t node;
5139 vat_json_init_object (&node);
5140 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5141 vat_json_object_add_uint (&node, "policer_index",
5142 ntohl (mp->policer_index));
5144 vat_json_print (vam->ofp, &node);
5145 vat_json_free (&node);
5147 vam->retval = ntohl (mp->retval);
5148 vam->result_ready = 1;
5151 /* Format hex dump. */
5153 format_hex_bytes (u8 * s, va_list * va)
5155 u8 *bytes = va_arg (*va, u8 *);
5156 int n_bytes = va_arg (*va, int);
5159 /* Print short or long form depending on byte count. */
5160 uword short_form = n_bytes <= 32;
5161 u32 indent = format_get_indent (s);
5166 for (i = 0; i < n_bytes; i++)
5168 if (!short_form && (i % 32) == 0)
5169 s = format (s, "%08x: ", i);
5170 s = format (s, "%02x", bytes[i]);
5171 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
5172 s = format (s, "\n%U", format_white_space, indent);
5179 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
5182 vat_main_t *vam = &vat_main;
5183 i32 retval = ntohl (mp->retval);
5186 print (vam->ofp, "classify table info :");
5187 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
5188 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
5189 ntohl (mp->miss_next_index));
5190 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
5191 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
5192 ntohl (mp->match_n_vectors));
5193 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
5194 ntohl (mp->mask_length));
5196 vam->retval = retval;
5197 vam->result_ready = 1;
5201 vl_api_classify_table_info_reply_t_handler_json
5202 (vl_api_classify_table_info_reply_t * mp)
5204 vat_main_t *vam = &vat_main;
5205 vat_json_node_t node;
5207 i32 retval = ntohl (mp->retval);
5210 vat_json_init_object (&node);
5212 vat_json_object_add_int (&node, "sessions",
5213 ntohl (mp->active_sessions));
5214 vat_json_object_add_int (&node, "nexttbl",
5215 ntohl (mp->next_table_index));
5216 vat_json_object_add_int (&node, "nextnode",
5217 ntohl (mp->miss_next_index));
5218 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
5219 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
5220 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
5221 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
5222 ntohl (mp->mask_length), 0);
5223 vat_json_object_add_string_copy (&node, "mask", s);
5225 vat_json_print (vam->ofp, &node);
5226 vat_json_free (&node);
5228 vam->retval = ntohl (mp->retval);
5229 vam->result_ready = 1;
5233 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
5236 vat_main_t *vam = &vat_main;
5238 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
5239 ntohl (mp->hit_next_index), ntohl (mp->advance),
5240 ntohl (mp->opaque_index));
5241 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
5242 ntohl (mp->match_length));
5246 vl_api_classify_session_details_t_handler_json
5247 (vl_api_classify_session_details_t * mp)
5249 vat_main_t *vam = &vat_main;
5250 vat_json_node_t *node = NULL;
5252 if (VAT_JSON_ARRAY != vam->json_tree.type)
5254 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5255 vat_json_init_array (&vam->json_tree);
5257 node = vat_json_array_add (&vam->json_tree);
5259 vat_json_init_object (node);
5260 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
5261 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
5262 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
5264 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
5266 vat_json_object_add_string_copy (node, "match", s);
5269 static void vl_api_pg_create_interface_reply_t_handler
5270 (vl_api_pg_create_interface_reply_t * mp)
5272 vat_main_t *vam = &vat_main;
5274 vam->retval = ntohl (mp->retval);
5275 vam->result_ready = 1;
5278 static void vl_api_pg_create_interface_reply_t_handler_json
5279 (vl_api_pg_create_interface_reply_t * mp)
5281 vat_main_t *vam = &vat_main;
5282 vat_json_node_t node;
5284 i32 retval = ntohl (mp->retval);
5287 vat_json_init_object (&node);
5289 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
5291 vat_json_print (vam->ofp, &node);
5292 vat_json_free (&node);
5294 vam->retval = ntohl (mp->retval);
5295 vam->result_ready = 1;
5298 static void vl_api_policer_classify_details_t_handler
5299 (vl_api_policer_classify_details_t * mp)
5301 vat_main_t *vam = &vat_main;
5303 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5304 ntohl (mp->table_index));
5307 static void vl_api_policer_classify_details_t_handler_json
5308 (vl_api_policer_classify_details_t * mp)
5310 vat_main_t *vam = &vat_main;
5311 vat_json_node_t *node;
5313 if (VAT_JSON_ARRAY != vam->json_tree.type)
5315 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5316 vat_json_init_array (&vam->json_tree);
5318 node = vat_json_array_add (&vam->json_tree);
5320 vat_json_init_object (node);
5321 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5322 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5325 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
5326 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5328 vat_main_t *vam = &vat_main;
5329 i32 retval = ntohl (mp->retval);
5330 if (vam->async_mode)
5332 vam->async_errors += (retval < 0);
5336 vam->retval = retval;
5337 vam->sw_if_index = ntohl (mp->sw_if_index);
5338 vam->result_ready = 1;
5340 vam->regenerate_interface_table = 1;
5343 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
5344 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5346 vat_main_t *vam = &vat_main;
5347 vat_json_node_t node;
5349 vat_json_init_object (&node);
5350 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5351 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
5353 vat_json_print (vam->ofp, &node);
5354 vat_json_free (&node);
5356 vam->retval = ntohl (mp->retval);
5357 vam->result_ready = 1;
5360 static void vl_api_flow_classify_details_t_handler
5361 (vl_api_flow_classify_details_t * mp)
5363 vat_main_t *vam = &vat_main;
5365 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5366 ntohl (mp->table_index));
5369 static void vl_api_flow_classify_details_t_handler_json
5370 (vl_api_flow_classify_details_t * mp)
5372 vat_main_t *vam = &vat_main;
5373 vat_json_node_t *node;
5375 if (VAT_JSON_ARRAY != vam->json_tree.type)
5377 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5378 vat_json_init_array (&vam->json_tree);
5380 node = vat_json_array_add (&vam->json_tree);
5382 vat_json_init_object (node);
5383 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5384 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5387 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
5388 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
5389 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
5390 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
5391 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
5392 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
5393 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
5394 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
5395 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
5396 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
5397 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
5398 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
5399 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5400 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5401 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5402 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5403 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5404 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5405 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5406 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5407 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5408 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5411 * Generate boilerplate reply handlers, which
5412 * dig the return value out of the xxx_reply_t API message,
5413 * stick it into vam->retval, and set vam->result_ready
5415 * Could also do this by pointing N message decode slots at
5416 * a single function, but that could break in subtle ways.
5419 #define foreach_standard_reply_retval_handler \
5420 _(sw_interface_set_flags_reply) \
5421 _(sw_interface_add_del_address_reply) \
5422 _(sw_interface_set_rx_mode_reply) \
5423 _(sw_interface_set_rx_placement_reply) \
5424 _(sw_interface_set_table_reply) \
5425 _(sw_interface_set_mpls_enable_reply) \
5426 _(sw_interface_set_vpath_reply) \
5427 _(sw_interface_set_vxlan_bypass_reply) \
5428 _(sw_interface_set_geneve_bypass_reply) \
5429 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5430 _(sw_interface_set_l2_bridge_reply) \
5431 _(bridge_domain_add_del_reply) \
5432 _(sw_interface_set_l2_xconnect_reply) \
5433 _(l2fib_add_del_reply) \
5434 _(l2fib_flush_int_reply) \
5435 _(l2fib_flush_bd_reply) \
5436 _(ip_add_del_route_reply) \
5437 _(ip_table_add_del_reply) \
5438 _(ip_mroute_add_del_reply) \
5439 _(mpls_route_add_del_reply) \
5440 _(mpls_table_add_del_reply) \
5441 _(mpls_ip_bind_unbind_reply) \
5442 _(bier_route_add_del_reply) \
5443 _(bier_table_add_del_reply) \
5444 _(proxy_arp_add_del_reply) \
5445 _(proxy_arp_intfc_enable_disable_reply) \
5446 _(sw_interface_set_unnumbered_reply) \
5447 _(ip_neighbor_add_del_reply) \
5448 _(oam_add_del_reply) \
5449 _(reset_fib_reply) \
5450 _(dhcp_proxy_config_reply) \
5451 _(dhcp_proxy_set_vss_reply) \
5452 _(dhcp_client_config_reply) \
5453 _(set_ip_flow_hash_reply) \
5454 _(sw_interface_ip6_enable_disable_reply) \
5455 _(sw_interface_ip6_set_link_local_address_reply) \
5456 _(ip6nd_proxy_add_del_reply) \
5457 _(sw_interface_ip6nd_ra_prefix_reply) \
5458 _(sw_interface_ip6nd_ra_config_reply) \
5459 _(set_arp_neighbor_limit_reply) \
5460 _(l2_patch_add_del_reply) \
5461 _(sr_mpls_policy_add_reply) \
5462 _(sr_mpls_policy_mod_reply) \
5463 _(sr_mpls_policy_del_reply) \
5464 _(sr_policy_add_reply) \
5465 _(sr_policy_mod_reply) \
5466 _(sr_policy_del_reply) \
5467 _(sr_localsid_add_del_reply) \
5468 _(sr_steering_add_del_reply) \
5469 _(classify_add_del_session_reply) \
5470 _(classify_set_interface_ip_table_reply) \
5471 _(classify_set_interface_l2_tables_reply) \
5472 _(l2tpv3_set_tunnel_cookies_reply) \
5473 _(l2tpv3_interface_enable_disable_reply) \
5474 _(l2tpv3_set_lookup_key_reply) \
5475 _(l2_fib_clear_table_reply) \
5476 _(l2_interface_efp_filter_reply) \
5477 _(l2_interface_vlan_tag_rewrite_reply) \
5478 _(modify_vhost_user_if_reply) \
5479 _(delete_vhost_user_if_reply) \
5480 _(ip_probe_neighbor_reply) \
5481 _(ip_scan_neighbor_enable_disable_reply) \
5482 _(want_ip4_arp_events_reply) \
5483 _(want_ip6_nd_events_reply) \
5484 _(want_l2_macs_events_reply) \
5485 _(input_acl_set_interface_reply) \
5486 _(ipsec_spd_add_del_reply) \
5487 _(ipsec_interface_add_del_spd_reply) \
5488 _(ipsec_spd_add_del_entry_reply) \
5489 _(ipsec_sad_add_del_entry_reply) \
5490 _(ipsec_sa_set_key_reply) \
5491 _(ipsec_tunnel_if_add_del_reply) \
5492 _(ipsec_tunnel_if_set_key_reply) \
5493 _(ipsec_tunnel_if_set_sa_reply) \
5494 _(ikev2_profile_add_del_reply) \
5495 _(ikev2_profile_set_auth_reply) \
5496 _(ikev2_profile_set_id_reply) \
5497 _(ikev2_profile_set_ts_reply) \
5498 _(ikev2_set_local_key_reply) \
5499 _(ikev2_set_responder_reply) \
5500 _(ikev2_set_ike_transforms_reply) \
5501 _(ikev2_set_esp_transforms_reply) \
5502 _(ikev2_set_sa_lifetime_reply) \
5503 _(ikev2_initiate_sa_init_reply) \
5504 _(ikev2_initiate_del_ike_sa_reply) \
5505 _(ikev2_initiate_del_child_sa_reply) \
5506 _(ikev2_initiate_rekey_child_sa_reply) \
5507 _(delete_loopback_reply) \
5508 _(bd_ip_mac_add_del_reply) \
5509 _(want_interface_events_reply) \
5510 _(want_stats_reply) \
5511 _(cop_interface_enable_disable_reply) \
5512 _(cop_whitelist_enable_disable_reply) \
5513 _(sw_interface_clear_stats_reply) \
5514 _(ioam_enable_reply) \
5515 _(ioam_disable_reply) \
5516 _(one_add_del_locator_reply) \
5517 _(one_add_del_local_eid_reply) \
5518 _(one_add_del_remote_mapping_reply) \
5519 _(one_add_del_adjacency_reply) \
5520 _(one_add_del_map_resolver_reply) \
5521 _(one_add_del_map_server_reply) \
5522 _(one_enable_disable_reply) \
5523 _(one_rloc_probe_enable_disable_reply) \
5524 _(one_map_register_enable_disable_reply) \
5525 _(one_map_register_set_ttl_reply) \
5526 _(one_set_transport_protocol_reply) \
5527 _(one_map_register_fallback_threshold_reply) \
5528 _(one_pitr_set_locator_set_reply) \
5529 _(one_map_request_mode_reply) \
5530 _(one_add_del_map_request_itr_rlocs_reply) \
5531 _(one_eid_table_add_del_map_reply) \
5532 _(one_use_petr_reply) \
5533 _(one_stats_enable_disable_reply) \
5534 _(one_add_del_l2_arp_entry_reply) \
5535 _(one_add_del_ndp_entry_reply) \
5536 _(one_stats_flush_reply) \
5537 _(one_enable_disable_xtr_mode_reply) \
5538 _(one_enable_disable_pitr_mode_reply) \
5539 _(one_enable_disable_petr_mode_reply) \
5540 _(gpe_enable_disable_reply) \
5541 _(gpe_set_encap_mode_reply) \
5542 _(gpe_add_del_iface_reply) \
5543 _(gpe_add_del_native_fwd_rpath_reply) \
5544 _(af_packet_delete_reply) \
5545 _(policer_classify_set_interface_reply) \
5546 _(netmap_create_reply) \
5547 _(netmap_delete_reply) \
5548 _(set_ipfix_exporter_reply) \
5549 _(set_ipfix_classify_stream_reply) \
5550 _(ipfix_classify_table_add_del_reply) \
5551 _(flow_classify_set_interface_reply) \
5552 _(sw_interface_span_enable_disable_reply) \
5553 _(pg_capture_reply) \
5554 _(pg_enable_disable_reply) \
5555 _(ip_source_and_port_range_check_add_del_reply) \
5556 _(ip_source_and_port_range_check_interface_add_del_reply)\
5557 _(delete_subif_reply) \
5558 _(l2_interface_pbb_tag_rewrite_reply) \
5560 _(feature_enable_disable_reply) \
5561 _(sw_interface_tag_add_del_reply) \
5562 _(hw_interface_set_mtu_reply) \
5563 _(p2p_ethernet_add_reply) \
5564 _(p2p_ethernet_del_reply) \
5565 _(lldp_config_reply) \
5566 _(sw_interface_set_lldp_reply) \
5567 _(tcp_configure_src_addresses_reply) \
5568 _(dns_enable_disable_reply) \
5569 _(dns_name_server_add_del_reply) \
5570 _(session_rule_add_del_reply) \
5571 _(ip_container_proxy_add_del_reply) \
5572 _(output_acl_set_interface_reply) \
5573 _(qos_record_enable_disable_reply)
5576 static void vl_api_##n##_t_handler \
5577 (vl_api_##n##_t * mp) \
5579 vat_main_t * vam = &vat_main; \
5580 i32 retval = ntohl(mp->retval); \
5581 if (vam->async_mode) { \
5582 vam->async_errors += (retval < 0); \
5584 vam->retval = retval; \
5585 vam->result_ready = 1; \
5588 foreach_standard_reply_retval_handler;
5592 static void vl_api_##n##_t_handler_json \
5593 (vl_api_##n##_t * mp) \
5595 vat_main_t * vam = &vat_main; \
5596 vat_json_node_t node; \
5597 vat_json_init_object(&node); \
5598 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5599 vat_json_print(vam->ofp, &node); \
5600 vam->retval = ntohl(mp->retval); \
5601 vam->result_ready = 1; \
5603 foreach_standard_reply_retval_handler;
5607 * Table of message reply handlers, must include boilerplate handlers
5611 #define foreach_vpe_api_reply_msg \
5612 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5613 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5614 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5615 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5616 _(CONTROL_PING_REPLY, control_ping_reply) \
5617 _(CLI_REPLY, cli_reply) \
5618 _(CLI_INBAND_REPLY, cli_inband_reply) \
5619 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5620 sw_interface_add_del_address_reply) \
5621 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5622 _(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
5623 _(SW_INTERFACE_RX_PLACEMENT_DETAILS, sw_interface_rx_placement_details) \
5624 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5625 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5626 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5627 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5628 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5629 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5630 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5631 sw_interface_set_l2_xconnect_reply) \
5632 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5633 sw_interface_set_l2_bridge_reply) \
5634 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5635 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5636 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5637 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5638 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5639 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5640 _(L2_FLAGS_REPLY, l2_flags_reply) \
5641 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5642 _(TAP_CONNECT_REPLY, tap_connect_reply) \
5643 _(TAP_MODIFY_REPLY, tap_modify_reply) \
5644 _(TAP_DELETE_REPLY, tap_delete_reply) \
5645 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
5646 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5647 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5648 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5649 _(BOND_CREATE_REPLY, bond_create_reply) \
5650 _(BOND_DELETE_REPLY, bond_delete_reply) \
5651 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5652 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5653 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5654 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5655 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5656 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5657 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5658 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5659 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5660 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5661 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5662 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5663 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5664 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5665 proxy_arp_intfc_enable_disable_reply) \
5666 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5667 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5668 sw_interface_set_unnumbered_reply) \
5669 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5670 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5671 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5672 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5673 _(RESET_FIB_REPLY, reset_fib_reply) \
5674 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5675 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5676 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5677 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5678 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5679 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5680 sw_interface_ip6_enable_disable_reply) \
5681 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
5682 sw_interface_ip6_set_link_local_address_reply) \
5683 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5684 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5685 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5686 sw_interface_ip6nd_ra_prefix_reply) \
5687 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5688 sw_interface_ip6nd_ra_config_reply) \
5689 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5690 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5691 _(SR_MPLS_POLICY_ADD_REPLY, sr_mpls_policy_add_reply) \
5692 _(SR_MPLS_POLICY_MOD_REPLY, sr_mpls_policy_mod_reply) \
5693 _(SR_MPLS_POLICY_DEL_REPLY, sr_mpls_policy_del_reply) \
5694 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5695 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5696 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5697 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5698 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5699 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5700 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5701 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5702 classify_set_interface_ip_table_reply) \
5703 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5704 classify_set_interface_l2_tables_reply) \
5705 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5706 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5707 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5708 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5709 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5710 l2tpv3_interface_enable_disable_reply) \
5711 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5712 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5713 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5714 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5715 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5716 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5717 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5718 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5719 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5720 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5721 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5722 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5723 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5724 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5725 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5726 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5727 _(SHOW_VERSION_REPLY, show_version_reply) \
5728 _(SHOW_THREADS_REPLY, show_threads_reply) \
5729 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5730 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5731 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5732 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5733 _(IP_PROBE_NEIGHBOR_REPLY, ip_probe_neighbor_reply) \
5734 _(IP_SCAN_NEIGHBOR_ENABLE_DISABLE_REPLY, ip_scan_neighbor_enable_disable_reply) \
5735 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5736 _(IP4_ARP_EVENT, ip4_arp_event) \
5737 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5738 _(IP6_ND_EVENT, ip6_nd_event) \
5739 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5740 _(L2_MACS_EVENT, l2_macs_event) \
5741 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5742 _(IP_ADDRESS_DETAILS, ip_address_details) \
5743 _(IP_DETAILS, ip_details) \
5744 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5745 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5746 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
5747 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
5748 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5749 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5750 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5751 _(IPSEC_TUNNEL_IF_SET_KEY_REPLY, ipsec_tunnel_if_set_key_reply) \
5752 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5753 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
5754 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
5755 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
5756 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
5757 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
5758 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
5759 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
5760 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
5761 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
5762 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
5763 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
5764 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
5765 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
5766 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5767 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5768 _(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
5769 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5770 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5771 _(WANT_STATS_REPLY, want_stats_reply) \
5772 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5773 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5774 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5775 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5776 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5777 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5778 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5779 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5780 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5781 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5782 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5783 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5784 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5785 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5786 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5787 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5788 one_map_register_enable_disable_reply) \
5789 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5790 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5791 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5792 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5793 one_map_register_fallback_threshold_reply) \
5794 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5795 one_rloc_probe_enable_disable_reply) \
5796 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5797 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5798 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5799 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5800 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5801 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5802 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5803 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5804 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5805 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5806 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5807 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5808 _(ONE_STATS_DETAILS, one_stats_details) \
5809 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5810 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5811 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5812 show_one_stats_enable_disable_reply) \
5813 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5814 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5815 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5816 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5817 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5818 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5819 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5820 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5821 one_enable_disable_pitr_mode_reply) \
5822 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5823 one_enable_disable_petr_mode_reply) \
5824 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5825 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5826 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5827 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5828 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5829 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5830 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5831 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5832 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5833 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5834 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5835 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5836 gpe_add_del_native_fwd_rpath_reply) \
5837 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5838 gpe_fwd_entry_path_details) \
5839 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5840 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5841 one_add_del_map_request_itr_rlocs_reply) \
5842 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5843 one_get_map_request_itr_rlocs_reply) \
5844 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5845 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5846 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5847 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5848 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5849 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5850 show_one_map_register_state_reply) \
5851 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5852 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5853 show_one_map_register_fallback_threshold_reply) \
5854 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5855 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5856 _(AF_PACKET_DETAILS, af_packet_details) \
5857 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5858 _(POLICER_DETAILS, policer_details) \
5859 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5860 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5861 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5862 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5863 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5864 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5865 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5866 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5867 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5868 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5869 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5870 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5871 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5872 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5873 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5874 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5875 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5876 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5877 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5878 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5879 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5880 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5881 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5882 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5883 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5884 ip_source_and_port_range_check_add_del_reply) \
5885 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5886 ip_source_and_port_range_check_interface_add_del_reply) \
5887 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5888 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5889 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5890 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5891 _(PUNT_REPLY, punt_reply) \
5892 _(IP_FIB_DETAILS, ip_fib_details) \
5893 _(IP6_FIB_DETAILS, ip6_fib_details) \
5894 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5895 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5896 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5897 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5898 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5899 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5900 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5901 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5902 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5903 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5904 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5905 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5906 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5907 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5908 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
5909 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \
5910 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5911 _(SESSION_RULES_DETAILS, session_rules_details) \
5912 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5913 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5914 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply)
5916 #define foreach_standalone_reply_msg \
5917 _(SW_INTERFACE_EVENT, sw_interface_event) \
5918 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
5919 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
5920 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
5921 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
5922 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
5923 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters)
5931 #define STR_VTR_OP_CASE(op) \
5932 case L2_VTR_ ## op: \
5936 str_vtr_op (u32 vtr_op)
5940 STR_VTR_OP_CASE (DISABLED);
5941 STR_VTR_OP_CASE (PUSH_1);
5942 STR_VTR_OP_CASE (PUSH_2);
5943 STR_VTR_OP_CASE (POP_1);
5944 STR_VTR_OP_CASE (POP_2);
5945 STR_VTR_OP_CASE (TRANSLATE_1_1);
5946 STR_VTR_OP_CASE (TRANSLATE_1_2);
5947 STR_VTR_OP_CASE (TRANSLATE_2_1);
5948 STR_VTR_OP_CASE (TRANSLATE_2_2);
5955 dump_sub_interface_table (vat_main_t * vam)
5957 const sw_interface_subif_t *sub = NULL;
5959 if (vam->json_output)
5962 ("JSON output supported only for VPE API calls and dump_stats_table");
5967 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5968 "Interface", "sw_if_index",
5969 "sub id", "dot1ad", "tags", "outer id",
5970 "inner id", "exact", "default", "outer any", "inner any");
5972 vec_foreach (sub, vam->sw_if_subif_table)
5975 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5976 sub->interface_name,
5978 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5979 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5980 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5981 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5982 if (sub->vtr_op != L2_VTR_DISABLED)
5985 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5986 "tag1: %d tag2: %d ]",
5987 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5988 sub->vtr_tag1, sub->vtr_tag2);
5996 name_sort_cmp (void *a1, void *a2)
5998 name_sort_t *n1 = a1;
5999 name_sort_t *n2 = a2;
6001 return strcmp ((char *) n1->name, (char *) n2->name);
6005 dump_interface_table (vat_main_t * vam)
6008 name_sort_t *nses = 0, *ns;
6010 if (vam->json_output)
6013 ("JSON output supported only for VPE API calls and dump_stats_table");
6018 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6020 vec_add2 (nses, ns, 1);
6021 ns->name = (u8 *)(p->key);
6022 ns->value = (u32) p->value[0];
6026 vec_sort_with_function (nses, name_sort_cmp);
6028 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
6029 vec_foreach (ns, nses)
6031 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
6038 dump_ip_table (vat_main_t * vam, int is_ipv6)
6040 const ip_details_t *det = NULL;
6041 const ip_address_details_t *address = NULL;
6044 print (vam->ofp, "%-12s", "sw_if_index");
6046 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
6053 print (vam->ofp, "%-12d", i);
6054 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
6059 vec_foreach (address, det->addr)
6063 is_ipv6 ? format_ip6_address : format_ip4_address,
6064 address->ip, address->prefix_length);
6072 dump_ipv4_table (vat_main_t * vam)
6074 if (vam->json_output)
6077 ("JSON output supported only for VPE API calls and dump_stats_table");
6081 return dump_ip_table (vam, 0);
6085 dump_ipv6_table (vat_main_t * vam)
6087 if (vam->json_output)
6090 ("JSON output supported only for VPE API calls and dump_stats_table");
6094 return dump_ip_table (vam, 1);
6098 counter_type_to_str (u8 counter_type, u8 is_combined)
6102 switch (counter_type)
6104 case VNET_INTERFACE_COUNTER_DROP:
6106 case VNET_INTERFACE_COUNTER_PUNT:
6108 case VNET_INTERFACE_COUNTER_IP4:
6110 case VNET_INTERFACE_COUNTER_IP6:
6112 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
6114 case VNET_INTERFACE_COUNTER_RX_MISS:
6116 case VNET_INTERFACE_COUNTER_RX_ERROR:
6118 case VNET_INTERFACE_COUNTER_TX_ERROR:
6121 return "INVALID-COUNTER-TYPE";
6126 switch (counter_type)
6128 case VNET_INTERFACE_COUNTER_RX:
6130 case VNET_INTERFACE_COUNTER_TX:
6133 return "INVALID-COUNTER-TYPE";
6139 dump_stats_table (vat_main_t * vam)
6141 vat_json_node_t node;
6142 vat_json_node_t *msg_array;
6143 vat_json_node_t *msg;
6144 vat_json_node_t *counter_array;
6145 vat_json_node_t *counter;
6146 interface_counter_t c;
6148 ip4_fib_counter_t *c4;
6149 ip6_fib_counter_t *c6;
6150 ip4_nbr_counter_t *n4;
6151 ip6_nbr_counter_t *n6;
6154 if (!vam->json_output)
6156 clib_warning ("dump_stats_table supported only in JSON format");
6160 vat_json_init_object (&node);
6162 /* interface counters */
6163 msg_array = vat_json_object_add (&node, "interface_counters");
6164 vat_json_init_array (msg_array);
6165 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
6167 msg = vat_json_array_add (msg_array);
6168 vat_json_init_object (msg);
6169 vat_json_object_add_string_copy (msg, "vnet_counter_type",
6170 (u8 *) counter_type_to_str (i, 0));
6171 vat_json_object_add_int (msg, "is_combined", 0);
6172 counter_array = vat_json_object_add (msg, "data");
6173 vat_json_init_array (counter_array);
6174 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
6176 packets = vam->simple_interface_counters[i][j];
6177 vat_json_array_add_uint (counter_array, packets);
6180 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
6182 msg = vat_json_array_add (msg_array);
6183 vat_json_init_object (msg);
6184 vat_json_object_add_string_copy (msg, "vnet_counter_type",
6185 (u8 *) counter_type_to_str (i, 1));
6186 vat_json_object_add_int (msg, "is_combined", 1);
6187 counter_array = vat_json_object_add (msg, "data");
6188 vat_json_init_array (counter_array);
6189 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
6191 c = vam->combined_interface_counters[i][j];
6192 counter = vat_json_array_add (counter_array);
6193 vat_json_init_object (counter);
6194 vat_json_object_add_uint (counter, "packets", c.packets);
6195 vat_json_object_add_uint (counter, "bytes", c.bytes);
6199 /* ip4 fib counters */
6200 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
6201 vat_json_init_array (msg_array);
6202 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
6204 msg = vat_json_array_add (msg_array);
6205 vat_json_init_object (msg);
6206 vat_json_object_add_uint (msg, "vrf_id",
6207 vam->ip4_fib_counters_vrf_id_by_index[i]);
6208 counter_array = vat_json_object_add (msg, "c");
6209 vat_json_init_array (counter_array);
6210 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
6212 counter = vat_json_array_add (counter_array);
6213 vat_json_init_object (counter);
6214 c4 = &vam->ip4_fib_counters[i][j];
6215 vat_json_object_add_ip4 (counter, "address", c4->address);
6216 vat_json_object_add_uint (counter, "address_length",
6217 c4->address_length);
6218 vat_json_object_add_uint (counter, "packets", c4->packets);
6219 vat_json_object_add_uint (counter, "bytes", c4->bytes);
6223 /* ip6 fib counters */
6224 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
6225 vat_json_init_array (msg_array);
6226 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
6228 msg = vat_json_array_add (msg_array);
6229 vat_json_init_object (msg);
6230 vat_json_object_add_uint (msg, "vrf_id",
6231 vam->ip6_fib_counters_vrf_id_by_index[i]);
6232 counter_array = vat_json_object_add (msg, "c");
6233 vat_json_init_array (counter_array);
6234 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
6236 counter = vat_json_array_add (counter_array);
6237 vat_json_init_object (counter);
6238 c6 = &vam->ip6_fib_counters[i][j];
6239 vat_json_object_add_ip6 (counter, "address", c6->address);
6240 vat_json_object_add_uint (counter, "address_length",
6241 c6->address_length);
6242 vat_json_object_add_uint (counter, "packets", c6->packets);
6243 vat_json_object_add_uint (counter, "bytes", c6->bytes);
6247 /* ip4 nbr counters */
6248 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
6249 vat_json_init_array (msg_array);
6250 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
6252 msg = vat_json_array_add (msg_array);
6253 vat_json_init_object (msg);
6254 vat_json_object_add_uint (msg, "sw_if_index", i);
6255 counter_array = vat_json_object_add (msg, "c");
6256 vat_json_init_array (counter_array);
6257 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
6259 counter = vat_json_array_add (counter_array);
6260 vat_json_init_object (counter);
6261 n4 = &vam->ip4_nbr_counters[i][j];
6262 vat_json_object_add_ip4 (counter, "address", n4->address);
6263 vat_json_object_add_uint (counter, "link-type", n4->linkt);
6264 vat_json_object_add_uint (counter, "packets", n4->packets);
6265 vat_json_object_add_uint (counter, "bytes", n4->bytes);
6269 /* ip6 nbr counters */
6270 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
6271 vat_json_init_array (msg_array);
6272 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
6274 msg = vat_json_array_add (msg_array);
6275 vat_json_init_object (msg);
6276 vat_json_object_add_uint (msg, "sw_if_index", i);
6277 counter_array = vat_json_object_add (msg, "c");
6278 vat_json_init_array (counter_array);
6279 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
6281 counter = vat_json_array_add (counter_array);
6282 vat_json_init_object (counter);
6283 n6 = &vam->ip6_nbr_counters[i][j];
6284 vat_json_object_add_ip6 (counter, "address", n6->address);
6285 vat_json_object_add_uint (counter, "packets", n6->packets);
6286 vat_json_object_add_uint (counter, "bytes", n6->bytes);
6290 vat_json_print (vam->ofp, &node);
6291 vat_json_free (&node);
6297 * Pass CLI buffers directly in the CLI_INBAND API message,
6298 * instead of an additional shared memory area.
6301 exec_inband (vat_main_t * vam)
6303 vl_api_cli_inband_t *mp;
6304 unformat_input_t *i = vam->input;
6307 if (vec_len (i->buffer) == 0)
6310 if (vam->exec_mode == 0 && unformat (i, "mode"))
6315 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
6322 * In order for the CLI command to work, it
6323 * must be a vector ending in \n, not a C-string ending
6326 u32 len = vec_len (vam->input->buffer);
6327 M2 (CLI_INBAND, mp, len);
6328 clib_memcpy (mp->cmd, vam->input->buffer, len);
6329 mp->length = htonl (len);
6333 /* json responses may or may not include a useful reply... */
6334 if (vec_len (vam->cmd_reply))
6335 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
6340 exec (vat_main_t * vam)
6342 return exec_inband (vam);
6346 api_create_loopback (vat_main_t * vam)
6348 unformat_input_t *i = vam->input;
6349 vl_api_create_loopback_t *mp;
6350 vl_api_create_loopback_instance_t *mp_lbi;
6353 u8 is_specified = 0;
6354 u32 user_instance = 0;
6357 memset (mac_address, 0, sizeof (mac_address));
6359 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6361 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6363 if (unformat (i, "instance %d", &user_instance))
6371 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
6372 mp_lbi->is_specified = is_specified;
6374 mp_lbi->user_instance = htonl (user_instance);
6376 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
6381 /* Construct the API message */
6382 M (CREATE_LOOPBACK, mp);
6384 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
6393 api_delete_loopback (vat_main_t * vam)
6395 unformat_input_t *i = vam->input;
6396 vl_api_delete_loopback_t *mp;
6397 u32 sw_if_index = ~0;
6400 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6402 if (unformat (i, "sw_if_index %d", &sw_if_index))
6408 if (sw_if_index == ~0)
6410 errmsg ("missing sw_if_index");
6414 /* Construct the API message */
6415 M (DELETE_LOOPBACK, mp);
6416 mp->sw_if_index = ntohl (sw_if_index);
6424 api_want_stats (vat_main_t * vam)
6426 unformat_input_t *i = vam->input;
6427 vl_api_want_stats_t *mp;
6431 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6433 if (unformat (i, "enable"))
6435 else if (unformat (i, "disable"))
6443 errmsg ("missing enable|disable");
6448 mp->enable_disable = enable;
6456 api_want_interface_events (vat_main_t * vam)
6458 unformat_input_t *i = vam->input;
6459 vl_api_want_interface_events_t *mp;
6463 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6465 if (unformat (i, "enable"))
6467 else if (unformat (i, "disable"))
6475 errmsg ("missing enable|disable");
6479 M (WANT_INTERFACE_EVENTS, mp);
6480 mp->enable_disable = enable;
6482 vam->interface_event_display = enable;
6490 /* Note: non-static, called once to set up the initial intfc table */
6492 api_sw_interface_dump (vat_main_t * vam)
6494 vl_api_sw_interface_dump_t *mp;
6495 vl_api_control_ping_t *mp_ping;
6497 name_sort_t *nses = 0, *ns;
6498 sw_interface_subif_t *sub = NULL;
6501 /* Toss the old name table */
6503 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6505 vec_add2 (nses, ns, 1);
6506 ns->name = (u8 *)(p->key);
6507 ns->value = (u32) p->value[0];
6511 hash_free (vam->sw_if_index_by_interface_name);
6513 vec_foreach (ns, nses) vec_free (ns->name);
6517 vec_foreach (sub, vam->sw_if_subif_table)
6519 vec_free (sub->interface_name);
6521 vec_free (vam->sw_if_subif_table);
6523 /* recreate the interface name hash table */
6524 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
6527 * Ask for all interface names. Otherwise, the epic catalog of
6528 * name filters becomes ridiculously long, and vat ends up needing
6529 * to be taught about new interface types.
6531 M (SW_INTERFACE_DUMP, mp);
6534 /* Use a control ping for synchronization */
6535 MPING (CONTROL_PING, mp_ping);
6543 api_sw_interface_set_flags (vat_main_t * vam)
6545 unformat_input_t *i = vam->input;
6546 vl_api_sw_interface_set_flags_t *mp;
6548 u8 sw_if_index_set = 0;
6552 /* Parse args required to build the message */
6553 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6555 if (unformat (i, "admin-up"))
6557 else if (unformat (i, "admin-down"))
6560 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6561 sw_if_index_set = 1;
6562 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6563 sw_if_index_set = 1;
6568 if (sw_if_index_set == 0)
6570 errmsg ("missing interface name or sw_if_index");
6574 /* Construct the API message */
6575 M (SW_INTERFACE_SET_FLAGS, mp);
6576 mp->sw_if_index = ntohl (sw_if_index);
6577 mp->admin_up_down = admin_up;
6582 /* Wait for a reply, return the good/bad news... */
6588 api_sw_interface_set_rx_mode (vat_main_t * vam)
6590 unformat_input_t *i = vam->input;
6591 vl_api_sw_interface_set_rx_mode_t *mp;
6593 u8 sw_if_index_set = 0;
6595 u8 queue_id_valid = 0;
6597 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
6599 /* Parse args required to build the message */
6600 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6602 if (unformat (i, "queue %d", &queue_id))
6604 else if (unformat (i, "polling"))
6605 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
6606 else if (unformat (i, "interrupt"))
6607 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
6608 else if (unformat (i, "adaptive"))
6609 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
6611 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6612 sw_if_index_set = 1;
6613 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6614 sw_if_index_set = 1;
6619 if (sw_if_index_set == 0)
6621 errmsg ("missing interface name or sw_if_index");
6624 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6626 errmsg ("missing rx-mode");
6630 /* Construct the API message */
6631 M (SW_INTERFACE_SET_RX_MODE, mp);
6632 mp->sw_if_index = ntohl (sw_if_index);
6634 mp->queue_id_valid = queue_id_valid;
6635 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6640 /* Wait for a reply, return the good/bad news... */
6646 api_sw_interface_set_rx_placement (vat_main_t * vam)
6648 unformat_input_t *i = vam->input;
6649 vl_api_sw_interface_set_rx_placement_t *mp;
6651 u8 sw_if_index_set = 0;
6654 u32 queue_id, thread_index;
6656 /* Parse args required to build the message */
6657 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6659 if (unformat (i, "queue %d", &queue_id))
6661 else if (unformat (i, "main"))
6663 else if (unformat (i, "worker %d", &thread_index))
6666 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6667 sw_if_index_set = 1;
6668 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6669 sw_if_index_set = 1;
6674 if (sw_if_index_set == 0)
6676 errmsg ("missing interface name or sw_if_index");
6682 /* Construct the API message */
6683 M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
6684 mp->sw_if_index = ntohl (sw_if_index);
6685 mp->worker_id = ntohl (thread_index);
6686 mp->queue_id = ntohl (queue_id);
6687 mp->is_main = is_main;
6691 /* Wait for a reply, return the good/bad news... */
6696 static void vl_api_sw_interface_rx_placement_details_t_handler
6697 (vl_api_sw_interface_rx_placement_details_t * mp)
6699 vat_main_t *vam = &vat_main;
6700 u32 worker_id = ntohl (mp->worker_id);
6703 "\n%-11d %-11s %-6d %-5d %-9s",
6704 ntohl (mp->sw_if_index), (worker_id == 0) ? "main" : "worker",
6705 worker_id, ntohl (mp->queue_id),
6707 1) ? "polling" : ((mp->mode == 2) ? "interrupt" : "adaptive"));
6710 static void vl_api_sw_interface_rx_placement_details_t_handler_json
6711 (vl_api_sw_interface_rx_placement_details_t * mp)
6713 vat_main_t *vam = &vat_main;
6714 vat_json_node_t *node = NULL;
6716 if (VAT_JSON_ARRAY != vam->json_tree.type)
6718 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
6719 vat_json_init_array (&vam->json_tree);
6721 node = vat_json_array_add (&vam->json_tree);
6723 vat_json_init_object (node);
6724 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
6725 vat_json_object_add_uint (node, "worker_id", ntohl (mp->worker_id));
6726 vat_json_object_add_uint (node, "queue_id", ntohl (mp->queue_id));
6727 vat_json_object_add_uint (node, "mode", mp->mode);
6731 api_sw_interface_rx_placement_dump (vat_main_t * vam)
6733 unformat_input_t *i = vam->input;
6734 vl_api_sw_interface_rx_placement_dump_t *mp;
6735 vl_api_control_ping_t *mp_ping;
6738 u8 sw_if_index_set = 0;
6740 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6742 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6744 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6751 "\n%-11s %-11s %-6s %-5s %-4s",
6752 "sw_if_index", "main/worker", "thread", "queue", "mode");
6754 /* Dump Interface rx placement */
6755 M (SW_INTERFACE_RX_PLACEMENT_DUMP, mp);
6757 if (sw_if_index_set)
6758 mp->sw_if_index = htonl (sw_if_index);
6760 mp->sw_if_index = ~0;
6764 /* Use a control ping for synchronization */
6765 MPING (CONTROL_PING, mp_ping);
6773 api_sw_interface_clear_stats (vat_main_t * vam)
6775 unformat_input_t *i = vam->input;
6776 vl_api_sw_interface_clear_stats_t *mp;
6778 u8 sw_if_index_set = 0;
6781 /* Parse args required to build the message */
6782 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6784 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6785 sw_if_index_set = 1;
6786 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6787 sw_if_index_set = 1;
6792 /* Construct the API message */
6793 M (SW_INTERFACE_CLEAR_STATS, mp);
6795 if (sw_if_index_set == 1)
6796 mp->sw_if_index = ntohl (sw_if_index);
6798 mp->sw_if_index = ~0;
6803 /* Wait for a reply, return the good/bad news... */
6809 api_sw_interface_add_del_address (vat_main_t * vam)
6811 unformat_input_t *i = vam->input;
6812 vl_api_sw_interface_add_del_address_t *mp;
6814 u8 sw_if_index_set = 0;
6815 u8 is_add = 1, del_all = 0;
6816 u32 address_length = 0;
6817 u8 v4_address_set = 0;
6818 u8 v6_address_set = 0;
6819 ip4_address_t v4address;
6820 ip6_address_t v6address;
6823 /* Parse args required to build the message */
6824 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6826 if (unformat (i, "del-all"))
6828 else if (unformat (i, "del"))
6831 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6832 sw_if_index_set = 1;
6833 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6834 sw_if_index_set = 1;
6835 else if (unformat (i, "%U/%d",
6836 unformat_ip4_address, &v4address, &address_length))
6838 else if (unformat (i, "%U/%d",
6839 unformat_ip6_address, &v6address, &address_length))
6845 if (sw_if_index_set == 0)
6847 errmsg ("missing interface name or sw_if_index");
6850 if (v4_address_set && v6_address_set)
6852 errmsg ("both v4 and v6 addresses set");
6855 if (!v4_address_set && !v6_address_set && !del_all)
6857 errmsg ("no addresses set");
6861 /* Construct the API message */
6862 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6864 mp->sw_if_index = ntohl (sw_if_index);
6865 mp->is_add = is_add;
6866 mp->del_all = del_all;
6870 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6874 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6876 mp->address_length = address_length;
6881 /* Wait for a reply, return good/bad news */
6887 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6889 unformat_input_t *i = vam->input;
6890 vl_api_sw_interface_set_mpls_enable_t *mp;
6892 u8 sw_if_index_set = 0;
6896 /* Parse args required to build the message */
6897 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6899 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6900 sw_if_index_set = 1;
6901 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6902 sw_if_index_set = 1;
6903 else if (unformat (i, "disable"))
6905 else if (unformat (i, "dis"))
6911 if (sw_if_index_set == 0)
6913 errmsg ("missing interface name or sw_if_index");
6917 /* Construct the API message */
6918 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6920 mp->sw_if_index = ntohl (sw_if_index);
6921 mp->enable = enable;
6926 /* Wait for a reply... */
6932 api_sw_interface_set_table (vat_main_t * vam)
6934 unformat_input_t *i = vam->input;
6935 vl_api_sw_interface_set_table_t *mp;
6936 u32 sw_if_index, vrf_id = 0;
6937 u8 sw_if_index_set = 0;
6941 /* Parse args required to build the message */
6942 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6944 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6945 sw_if_index_set = 1;
6946 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6947 sw_if_index_set = 1;
6948 else if (unformat (i, "vrf %d", &vrf_id))
6950 else if (unformat (i, "ipv6"))
6956 if (sw_if_index_set == 0)
6958 errmsg ("missing interface name or sw_if_index");
6962 /* Construct the API message */
6963 M (SW_INTERFACE_SET_TABLE, mp);
6965 mp->sw_if_index = ntohl (sw_if_index);
6966 mp->is_ipv6 = is_ipv6;
6967 mp->vrf_id = ntohl (vrf_id);
6972 /* Wait for a reply... */
6977 static void vl_api_sw_interface_get_table_reply_t_handler
6978 (vl_api_sw_interface_get_table_reply_t * mp)
6980 vat_main_t *vam = &vat_main;
6982 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6984 vam->retval = ntohl (mp->retval);
6985 vam->result_ready = 1;
6989 static void vl_api_sw_interface_get_table_reply_t_handler_json
6990 (vl_api_sw_interface_get_table_reply_t * mp)
6992 vat_main_t *vam = &vat_main;
6993 vat_json_node_t node;
6995 vat_json_init_object (&node);
6996 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6997 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6999 vat_json_print (vam->ofp, &node);
7000 vat_json_free (&node);
7002 vam->retval = ntohl (mp->retval);
7003 vam->result_ready = 1;
7007 api_sw_interface_get_table (vat_main_t * vam)
7009 unformat_input_t *i = vam->input;
7010 vl_api_sw_interface_get_table_t *mp;
7012 u8 sw_if_index_set = 0;
7016 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7018 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7019 sw_if_index_set = 1;
7020 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7021 sw_if_index_set = 1;
7022 else if (unformat (i, "ipv6"))
7028 if (sw_if_index_set == 0)
7030 errmsg ("missing interface name or sw_if_index");
7034 M (SW_INTERFACE_GET_TABLE, mp);
7035 mp->sw_if_index = htonl (sw_if_index);
7036 mp->is_ipv6 = is_ipv6;
7044 api_sw_interface_set_vpath (vat_main_t * vam)
7046 unformat_input_t *i = vam->input;
7047 vl_api_sw_interface_set_vpath_t *mp;
7048 u32 sw_if_index = 0;
7049 u8 sw_if_index_set = 0;
7053 /* Parse args required to build the message */
7054 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7056 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7057 sw_if_index_set = 1;
7058 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7059 sw_if_index_set = 1;
7060 else if (unformat (i, "enable"))
7062 else if (unformat (i, "disable"))
7068 if (sw_if_index_set == 0)
7070 errmsg ("missing interface name or sw_if_index");
7074 /* Construct the API message */
7075 M (SW_INTERFACE_SET_VPATH, mp);
7077 mp->sw_if_index = ntohl (sw_if_index);
7078 mp->enable = is_enable;
7083 /* Wait for a reply... */
7089 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
7091 unformat_input_t *i = vam->input;
7092 vl_api_sw_interface_set_vxlan_bypass_t *mp;
7093 u32 sw_if_index = 0;
7094 u8 sw_if_index_set = 0;
7099 /* Parse args required to build the message */
7100 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7102 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7103 sw_if_index_set = 1;
7104 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7105 sw_if_index_set = 1;
7106 else if (unformat (i, "enable"))
7108 else if (unformat (i, "disable"))
7110 else if (unformat (i, "ip4"))
7112 else if (unformat (i, "ip6"))
7118 if (sw_if_index_set == 0)
7120 errmsg ("missing interface name or sw_if_index");
7124 /* Construct the API message */
7125 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
7127 mp->sw_if_index = ntohl (sw_if_index);
7128 mp->enable = is_enable;
7129 mp->is_ipv6 = is_ipv6;
7134 /* Wait for a reply... */
7140 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
7142 unformat_input_t *i = vam->input;
7143 vl_api_sw_interface_set_geneve_bypass_t *mp;
7144 u32 sw_if_index = 0;
7145 u8 sw_if_index_set = 0;
7150 /* Parse args required to build the message */
7151 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7153 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7154 sw_if_index_set = 1;
7155 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7156 sw_if_index_set = 1;
7157 else if (unformat (i, "enable"))
7159 else if (unformat (i, "disable"))
7161 else if (unformat (i, "ip4"))
7163 else if (unformat (i, "ip6"))
7169 if (sw_if_index_set == 0)
7171 errmsg ("missing interface name or sw_if_index");
7175 /* Construct the API message */
7176 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
7178 mp->sw_if_index = ntohl (sw_if_index);
7179 mp->enable = is_enable;
7180 mp->is_ipv6 = is_ipv6;
7185 /* Wait for a reply... */
7191 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
7193 unformat_input_t *i = vam->input;
7194 vl_api_sw_interface_set_l2_xconnect_t *mp;
7196 u8 rx_sw_if_index_set = 0;
7198 u8 tx_sw_if_index_set = 0;
7202 /* Parse args required to build the message */
7203 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7205 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
7206 rx_sw_if_index_set = 1;
7207 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
7208 tx_sw_if_index_set = 1;
7209 else if (unformat (i, "rx"))
7211 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7213 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7215 rx_sw_if_index_set = 1;
7220 else if (unformat (i, "tx"))
7222 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7224 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7226 tx_sw_if_index_set = 1;
7231 else if (unformat (i, "enable"))
7233 else if (unformat (i, "disable"))
7239 if (rx_sw_if_index_set == 0)
7241 errmsg ("missing rx interface name or rx_sw_if_index");
7245 if (enable && (tx_sw_if_index_set == 0))
7247 errmsg ("missing tx interface name or tx_sw_if_index");
7251 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
7253 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7254 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
7255 mp->enable = enable;
7263 api_sw_interface_set_l2_bridge (vat_main_t * vam)
7265 unformat_input_t *i = vam->input;
7266 vl_api_sw_interface_set_l2_bridge_t *mp;
7267 vl_api_l2_port_type_t port_type;
7269 u8 rx_sw_if_index_set = 0;
7276 port_type = L2_API_PORT_TYPE_NORMAL;
7278 /* Parse args required to build the message */
7279 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7281 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
7282 rx_sw_if_index_set = 1;
7283 else if (unformat (i, "bd_id %d", &bd_id))
7287 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
7288 rx_sw_if_index_set = 1;
7289 else if (unformat (i, "shg %d", &shg))
7291 else if (unformat (i, "bvi"))
7292 port_type = L2_API_PORT_TYPE_BVI;
7293 else if (unformat (i, "uu-fwd"))
7294 port_type = L2_API_PORT_TYPE_UU_FWD;
7295 else if (unformat (i, "enable"))
7297 else if (unformat (i, "disable"))
7303 if (rx_sw_if_index_set == 0)
7305 errmsg ("missing rx interface name or sw_if_index");
7309 if (enable && (bd_id_set == 0))
7311 errmsg ("missing bridge domain");
7315 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
7317 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7318 mp->bd_id = ntohl (bd_id);
7320 mp->port_type = ntohl (port_type);
7321 mp->enable = enable;
7329 api_bridge_domain_dump (vat_main_t * vam)
7331 unformat_input_t *i = vam->input;
7332 vl_api_bridge_domain_dump_t *mp;
7333 vl_api_control_ping_t *mp_ping;
7337 /* Parse args required to build the message */
7338 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7340 if (unformat (i, "bd_id %d", &bd_id))
7346 M (BRIDGE_DOMAIN_DUMP, mp);
7347 mp->bd_id = ntohl (bd_id);
7350 /* Use a control ping for synchronization */
7351 MPING (CONTROL_PING, mp_ping);
7359 api_bridge_domain_add_del (vat_main_t * vam)
7361 unformat_input_t *i = vam->input;
7362 vl_api_bridge_domain_add_del_t *mp;
7365 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
7370 /* Parse args required to build the message */
7371 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7373 if (unformat (i, "bd_id %d", &bd_id))
7375 else if (unformat (i, "flood %d", &flood))
7377 else if (unformat (i, "uu-flood %d", &uu_flood))
7379 else if (unformat (i, "forward %d", &forward))
7381 else if (unformat (i, "learn %d", &learn))
7383 else if (unformat (i, "arp-term %d", &arp_term))
7385 else if (unformat (i, "mac-age %d", &mac_age))
7387 else if (unformat (i, "bd-tag %s", &bd_tag))
7389 else if (unformat (i, "del"))
7392 flood = uu_flood = forward = learn = 0;
7400 errmsg ("missing bridge domain");
7407 errmsg ("mac age must be less than 256 ");
7412 if ((bd_tag) && (vec_len (bd_tag) > 63))
7414 errmsg ("bd-tag cannot be longer than 63");
7419 M (BRIDGE_DOMAIN_ADD_DEL, mp);
7421 mp->bd_id = ntohl (bd_id);
7423 mp->uu_flood = uu_flood;
7424 mp->forward = forward;
7426 mp->arp_term = arp_term;
7427 mp->is_add = is_add;
7428 mp->mac_age = (u8) mac_age;
7431 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
7432 mp->bd_tag[vec_len (bd_tag)] = 0;
7443 api_l2fib_flush_bd (vat_main_t * vam)
7445 unformat_input_t *i = vam->input;
7446 vl_api_l2fib_flush_bd_t *mp;
7450 /* Parse args required to build the message */
7451 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7453 if (unformat (i, "bd_id %d", &bd_id));
7460 errmsg ("missing bridge domain");
7464 M (L2FIB_FLUSH_BD, mp);
7466 mp->bd_id = htonl (bd_id);
7474 api_l2fib_flush_int (vat_main_t * vam)
7476 unformat_input_t *i = vam->input;
7477 vl_api_l2fib_flush_int_t *mp;
7478 u32 sw_if_index = ~0;
7481 /* Parse args required to build the message */
7482 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7484 if (unformat (i, "sw_if_index %d", &sw_if_index));
7486 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
7491 if (sw_if_index == ~0)
7493 errmsg ("missing interface name or sw_if_index");
7497 M (L2FIB_FLUSH_INT, mp);
7499 mp->sw_if_index = ntohl (sw_if_index);
7507 api_l2fib_add_del (vat_main_t * vam)
7509 unformat_input_t *i = vam->input;
7510 vl_api_l2fib_add_del_t *mp;
7516 u32 sw_if_index = 0;
7517 u8 sw_if_index_set = 0;
7526 /* Parse args required to build the message */
7527 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7529 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
7531 else if (unformat (i, "bd_id %d", &bd_id))
7533 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7534 sw_if_index_set = 1;
7535 else if (unformat (i, "sw_if"))
7537 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7540 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7541 sw_if_index_set = 1;
7546 else if (unformat (i, "static"))
7548 else if (unformat (i, "filter"))
7553 else if (unformat (i, "bvi"))
7558 else if (unformat (i, "del"))
7560 else if (unformat (i, "count %d", &count))
7568 errmsg ("missing mac address");
7574 errmsg ("missing bridge domain");
7578 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7580 errmsg ("missing interface name or sw_if_index");
7586 /* Turn on async mode */
7587 vam->async_mode = 1;
7588 vam->async_errors = 0;
7589 before = vat_time_now (vam);
7592 for (j = 0; j < count; j++)
7594 M (L2FIB_ADD_DEL, mp);
7596 clib_memcpy (mp->mac, mac, 6);
7597 mp->bd_id = ntohl (bd_id);
7598 mp->is_add = is_add;
7599 mp->sw_if_index = ntohl (sw_if_index);
7603 mp->static_mac = static_mac;
7604 mp->filter_mac = filter_mac;
7605 mp->bvi_mac = bvi_mac;
7607 increment_mac_address (mac);
7614 vl_api_control_ping_t *mp_ping;
7617 /* Shut off async mode */
7618 vam->async_mode = 0;
7620 MPING (CONTROL_PING, mp_ping);
7623 timeout = vat_time_now (vam) + 1.0;
7624 while (vat_time_now (vam) < timeout)
7625 if (vam->result_ready == 1)
7630 if (vam->retval == -99)
7633 if (vam->async_errors > 0)
7635 errmsg ("%d asynchronous errors", vam->async_errors);
7638 vam->async_errors = 0;
7639 after = vat_time_now (vam);
7641 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7642 count, after - before, count / (after - before));
7648 /* Wait for a reply... */
7652 /* Return the good/bad news */
7653 return (vam->retval);
7657 api_bridge_domain_set_mac_age (vat_main_t * vam)
7659 unformat_input_t *i = vam->input;
7660 vl_api_bridge_domain_set_mac_age_t *mp;
7665 /* Parse args required to build the message */
7666 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7668 if (unformat (i, "bd_id %d", &bd_id));
7669 else if (unformat (i, "mac-age %d", &mac_age));
7676 errmsg ("missing bridge domain");
7682 errmsg ("mac age must be less than 256 ");
7686 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7688 mp->bd_id = htonl (bd_id);
7689 mp->mac_age = (u8) mac_age;
7697 api_l2_flags (vat_main_t * vam)
7699 unformat_input_t *i = vam->input;
7700 vl_api_l2_flags_t *mp;
7703 u8 sw_if_index_set = 0;
7707 /* Parse args required to build the message */
7708 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7710 if (unformat (i, "sw_if_index %d", &sw_if_index))
7711 sw_if_index_set = 1;
7712 else if (unformat (i, "sw_if"))
7714 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7717 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7718 sw_if_index_set = 1;
7723 else if (unformat (i, "learn"))
7725 else if (unformat (i, "forward"))
7727 else if (unformat (i, "flood"))
7729 else if (unformat (i, "uu-flood"))
7730 flags |= L2_UU_FLOOD;
7731 else if (unformat (i, "arp-term"))
7732 flags |= L2_ARP_TERM;
7733 else if (unformat (i, "off"))
7735 else if (unformat (i, "disable"))
7741 if (sw_if_index_set == 0)
7743 errmsg ("missing interface name or sw_if_index");
7749 mp->sw_if_index = ntohl (sw_if_index);
7750 mp->feature_bitmap = ntohl (flags);
7751 mp->is_set = is_set;
7759 api_bridge_flags (vat_main_t * vam)
7761 unformat_input_t *i = vam->input;
7762 vl_api_bridge_flags_t *mp;
7766 bd_flags_t flags = 0;
7769 /* Parse args required to build the message */
7770 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7772 if (unformat (i, "bd_id %d", &bd_id))
7774 else if (unformat (i, "learn"))
7775 flags |= BRIDGE_API_FLAG_LEARN;
7776 else if (unformat (i, "forward"))
7777 flags |= BRIDGE_API_FLAG_FWD;
7778 else if (unformat (i, "flood"))
7779 flags |= BRIDGE_API_FLAG_FLOOD;
7780 else if (unformat (i, "uu-flood"))
7781 flags |= BRIDGE_API_FLAG_UU_FLOOD;
7782 else if (unformat (i, "arp-term"))
7783 flags |= BRIDGE_API_FLAG_ARP_TERM;
7784 else if (unformat (i, "off"))
7786 else if (unformat (i, "disable"))
7794 errmsg ("missing bridge domain");
7798 M (BRIDGE_FLAGS, mp);
7800 mp->bd_id = ntohl (bd_id);
7801 mp->flags = ntohl (flags);
7802 mp->is_set = is_set;
7810 api_bd_ip_mac_add_del (vat_main_t * vam)
7812 unformat_input_t *i = vam->input;
7813 vl_api_bd_ip_mac_add_del_t *mp;
7820 ip4_address_t v4addr;
7821 ip6_address_t v6addr;
7826 /* Parse args required to build the message */
7827 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7829 if (unformat (i, "bd_id %d", &bd_id))
7833 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
7837 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
7842 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
7846 else if (unformat (i, "del"))
7854 errmsg ("missing bridge domain");
7857 else if (ip_set == 0)
7859 errmsg ("missing IP address");
7862 else if (mac_set == 0)
7864 errmsg ("missing MAC address");
7868 M (BD_IP_MAC_ADD_DEL, mp);
7870 mp->bd_id = ntohl (bd_id);
7871 mp->is_ipv6 = is_ipv6;
7872 mp->is_add = is_add;
7874 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
7876 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
7877 clib_memcpy (mp->mac_address, macaddr, 6);
7883 static void vl_api_bd_ip_mac_details_t_handler
7884 (vl_api_bd_ip_mac_details_t * mp)
7886 vat_main_t *vam = &vat_main;
7891 format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
7894 format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
7897 "\n%-5d %-7s %-20U %-30s",
7898 ntohl (mp->bd_id), mp->is_ipv6 ? "ip6" : "ip4",
7899 format_ethernet_address, mp->mac_address, ip);
7904 static void vl_api_bd_ip_mac_details_t_handler_json
7905 (vl_api_bd_ip_mac_details_t * mp)
7907 vat_main_t *vam = &vat_main;
7908 vat_json_node_t *node = NULL;
7910 if (VAT_JSON_ARRAY != vam->json_tree.type)
7912 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7913 vat_json_init_array (&vam->json_tree);
7915 node = vat_json_array_add (&vam->json_tree);
7917 vat_json_init_object (node);
7918 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
7919 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
7920 vat_json_object_add_string_copy (node, "mac_address",
7921 format (0, "%U", format_ethernet_address,
7927 format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
7930 format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
7931 vat_json_object_add_string_copy (node, "ip_address", ip);
7936 api_bd_ip_mac_dump (vat_main_t * vam)
7938 unformat_input_t *i = vam->input;
7939 vl_api_bd_ip_mac_dump_t *mp;
7940 vl_api_control_ping_t *mp_ping;
7945 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7947 if (unformat (i, "bd_id %d", &bd_id))
7956 "\n%-5s %-7s %-20s %-30s",
7957 "bd_id", "is_ipv6", "mac_address", "ip_address");
7959 /* Dump Bridge Domain Ip to Mac entries */
7960 M (BD_IP_MAC_DUMP, mp);
7963 mp->bd_id = htonl (bd_id);
7969 /* Use a control ping for synchronization */
7970 MPING (CONTROL_PING, mp_ping);
7978 api_tap_connect (vat_main_t * vam)
7980 unformat_input_t *i = vam->input;
7981 vl_api_tap_connect_t *mp;
7987 ip4_address_t ip4_address;
7989 int ip4_address_set = 0;
7990 ip6_address_t ip6_address;
7992 int ip6_address_set = 0;
7995 memset (mac_address, 0, sizeof (mac_address));
7997 /* Parse args required to build the message */
7998 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8000 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
8004 else if (unformat (i, "random-mac"))
8006 else if (unformat (i, "tapname %s", &tap_name))
8008 else if (unformat (i, "tag %s", &tag))
8010 else if (unformat (i, "address %U/%d",
8011 unformat_ip4_address, &ip4_address, &ip4_mask_width))
8012 ip4_address_set = 1;
8013 else if (unformat (i, "address %U/%d",
8014 unformat_ip6_address, &ip6_address, &ip6_mask_width))
8015 ip6_address_set = 1;
8022 errmsg ("missing tap name");
8025 if (vec_len (tap_name) > 63)
8027 errmsg ("tap name too long");
8030 vec_add1 (tap_name, 0);
8032 if (vec_len (tag) > 63)
8034 errmsg ("tag too long");
8038 /* Construct the API message */
8039 M (TAP_CONNECT, mp);
8041 mp->use_random_mac = random_mac;
8042 clib_memcpy (mp->mac_address, mac_address, 6);
8043 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
8045 clib_memcpy (mp->tag, tag, vec_len (tag));
8047 if (ip4_address_set)
8049 mp->ip4_address_set = 1;
8050 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
8051 mp->ip4_mask_width = ip4_mask_width;
8053 if (ip6_address_set)
8055 mp->ip6_address_set = 1;
8056 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
8057 mp->ip6_mask_width = ip6_mask_width;
8060 vec_free (tap_name);
8066 /* Wait for a reply... */
8072 api_tap_modify (vat_main_t * vam)
8074 unformat_input_t *i = vam->input;
8075 vl_api_tap_modify_t *mp;
8080 u32 sw_if_index = ~0;
8081 u8 sw_if_index_set = 0;
8084 memset (mac_address, 0, sizeof (mac_address));
8086 /* Parse args required to build the message */
8087 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8089 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8090 sw_if_index_set = 1;
8091 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8092 sw_if_index_set = 1;
8093 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
8097 else if (unformat (i, "random-mac"))
8099 else if (unformat (i, "tapname %s", &tap_name))
8105 if (sw_if_index_set == 0)
8107 errmsg ("missing vpp interface name");
8112 errmsg ("missing tap name");
8115 if (vec_len (tap_name) > 63)
8117 errmsg ("tap name too long");
8119 vec_add1 (tap_name, 0);
8121 /* Construct the API message */
8124 mp->use_random_mac = random_mac;
8125 mp->sw_if_index = ntohl (sw_if_index);
8126 clib_memcpy (mp->mac_address, mac_address, 6);
8127 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
8128 vec_free (tap_name);
8133 /* Wait for a reply... */
8139 api_tap_delete (vat_main_t * vam)
8141 unformat_input_t *i = vam->input;
8142 vl_api_tap_delete_t *mp;
8143 u32 sw_if_index = ~0;
8144 u8 sw_if_index_set = 0;
8147 /* Parse args required to build the message */
8148 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8150 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8151 sw_if_index_set = 1;
8152 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8153 sw_if_index_set = 1;
8158 if (sw_if_index_set == 0)
8160 errmsg ("missing vpp interface name");
8164 /* Construct the API message */
8167 mp->sw_if_index = ntohl (sw_if_index);
8172 /* Wait for a reply... */
8178 api_tap_create_v2 (vat_main_t * vam)
8180 unformat_input_t *i = vam->input;
8181 vl_api_tap_create_v2_t *mp;
8185 u8 *host_if_name = 0;
8187 u8 host_mac_addr[6];
8188 u8 host_mac_addr_set = 0;
8189 u8 *host_bridge = 0;
8190 ip4_address_t host_ip4_addr;
8191 ip4_address_t host_ip4_gw;
8192 u8 host_ip4_gw_set = 0;
8193 u32 host_ip4_prefix_len = 0;
8194 ip6_address_t host_ip6_addr;
8195 ip6_address_t host_ip6_gw;
8196 u8 host_ip6_gw_set = 0;
8197 u32 host_ip6_prefix_len = 0;
8199 u32 rx_ring_sz = 0, tx_ring_sz = 0;
8201 memset (mac_address, 0, sizeof (mac_address));
8203 /* Parse args required to build the message */
8204 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8206 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
8210 else if (unformat (i, "id %u", &id))
8212 else if (unformat (i, "host-if-name %s", &host_if_name))
8214 else if (unformat (i, "host-ns %s", &host_ns))
8216 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
8218 host_mac_addr_set = 1;
8219 else if (unformat (i, "host-bridge %s", &host_bridge))
8221 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
8222 &host_ip4_addr, &host_ip4_prefix_len))
8224 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
8225 &host_ip6_addr, &host_ip6_prefix_len))
8227 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
8229 host_ip4_gw_set = 1;
8230 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
8232 host_ip6_gw_set = 1;
8233 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
8235 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
8241 if (vec_len (host_if_name) > 63)
8243 errmsg ("tap name too long. ");
8246 if (vec_len (host_ns) > 63)
8248 errmsg ("host name space too long. ");
8251 if (vec_len (host_bridge) > 63)
8253 errmsg ("host bridge name too long. ");
8256 if (host_ip4_prefix_len > 32)
8258 errmsg ("host ip4 prefix length not valid. ");
8261 if (host_ip6_prefix_len > 128)
8263 errmsg ("host ip6 prefix length not valid. ");
8266 if (!is_pow2 (rx_ring_sz))
8268 errmsg ("rx ring size must be power of 2. ");
8271 if (rx_ring_sz > 32768)
8273 errmsg ("rx ring size must be 32768 or lower. ");
8276 if (!is_pow2 (tx_ring_sz))
8278 errmsg ("tx ring size must be power of 2. ");
8281 if (tx_ring_sz > 32768)
8283 errmsg ("tx ring size must be 32768 or lower. ");
8287 /* Construct the API message */
8288 M (TAP_CREATE_V2, mp);
8290 mp->use_random_mac = random_mac;
8292 mp->id = ntohl (id);
8293 mp->host_namespace_set = host_ns != 0;
8294 mp->host_bridge_set = host_bridge != 0;
8295 mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
8296 mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
8297 mp->rx_ring_sz = ntohs (rx_ring_sz);
8298 mp->tx_ring_sz = ntohs (tx_ring_sz);
8300 if (random_mac == 0)
8301 clib_memcpy (mp->mac_address, mac_address, 6);
8302 if (host_mac_addr_set)
8303 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
8305 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
8307 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
8309 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
8310 if (host_ip4_prefix_len)
8311 clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
8312 if (host_ip4_prefix_len)
8313 clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
8314 if (host_ip4_gw_set)
8315 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
8316 if (host_ip6_gw_set)
8317 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
8320 vec_free (host_if_name);
8321 vec_free (host_bridge);
8326 /* Wait for a reply... */
8332 api_tap_delete_v2 (vat_main_t * vam)
8334 unformat_input_t *i = vam->input;
8335 vl_api_tap_delete_v2_t *mp;
8336 u32 sw_if_index = ~0;
8337 u8 sw_if_index_set = 0;
8340 /* Parse args required to build the message */
8341 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8343 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8344 sw_if_index_set = 1;
8345 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8346 sw_if_index_set = 1;
8351 if (sw_if_index_set == 0)
8353 errmsg ("missing vpp interface name. ");
8357 /* Construct the API message */
8358 M (TAP_DELETE_V2, mp);
8360 mp->sw_if_index = ntohl (sw_if_index);
8365 /* Wait for a reply... */
8371 api_bond_create (vat_main_t * vam)
8373 unformat_input_t *i = vam->input;
8374 vl_api_bond_create_t *mp;
8382 memset (mac_address, 0, sizeof (mac_address));
8385 /* Parse args required to build the message */
8386 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8388 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
8390 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
8391 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
8393 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
8400 if (mode_is_set == 0)
8402 errmsg ("Missing bond mode. ");
8406 /* Construct the API message */
8407 M (BOND_CREATE, mp);
8409 mp->use_custom_mac = custom_mac;
8415 clib_memcpy (mp->mac_address, mac_address, 6);
8420 /* Wait for a reply... */
8426 api_bond_delete (vat_main_t * vam)
8428 unformat_input_t *i = vam->input;
8429 vl_api_bond_delete_t *mp;
8430 u32 sw_if_index = ~0;
8431 u8 sw_if_index_set = 0;
8434 /* Parse args required to build the message */
8435 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8437 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8438 sw_if_index_set = 1;
8439 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8440 sw_if_index_set = 1;
8445 if (sw_if_index_set == 0)
8447 errmsg ("missing vpp interface name. ");
8451 /* Construct the API message */
8452 M (BOND_DELETE, mp);
8454 mp->sw_if_index = ntohl (sw_if_index);
8459 /* Wait for a reply... */
8465 api_bond_enslave (vat_main_t * vam)
8467 unformat_input_t *i = vam->input;
8468 vl_api_bond_enslave_t *mp;
8469 u32 bond_sw_if_index;
8473 u32 bond_sw_if_index_is_set = 0;
8475 u8 sw_if_index_is_set = 0;
8477 /* Parse args required to build the message */
8478 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8480 if (unformat (i, "sw_if_index %d", &sw_if_index))
8481 sw_if_index_is_set = 1;
8482 else if (unformat (i, "bond %u", &bond_sw_if_index))
8483 bond_sw_if_index_is_set = 1;
8484 else if (unformat (i, "passive %d", &is_passive))
8486 else if (unformat (i, "long-timeout %d", &is_long_timeout))
8492 if (bond_sw_if_index_is_set == 0)
8494 errmsg ("Missing bond sw_if_index. ");
8497 if (sw_if_index_is_set == 0)
8499 errmsg ("Missing slave sw_if_index. ");
8503 /* Construct the API message */
8504 M (BOND_ENSLAVE, mp);
8506 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
8507 mp->sw_if_index = ntohl (sw_if_index);
8508 mp->is_long_timeout = is_long_timeout;
8509 mp->is_passive = is_passive;
8514 /* Wait for a reply... */
8520 api_bond_detach_slave (vat_main_t * vam)
8522 unformat_input_t *i = vam->input;
8523 vl_api_bond_detach_slave_t *mp;
8524 u32 sw_if_index = ~0;
8525 u8 sw_if_index_set = 0;
8528 /* Parse args required to build the message */
8529 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8531 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8532 sw_if_index_set = 1;
8533 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8534 sw_if_index_set = 1;
8539 if (sw_if_index_set == 0)
8541 errmsg ("missing vpp interface name. ");
8545 /* Construct the API message */
8546 M (BOND_DETACH_SLAVE, mp);
8548 mp->sw_if_index = ntohl (sw_if_index);
8553 /* Wait for a reply... */
8559 api_ip_table_add_del (vat_main_t * vam)
8561 unformat_input_t *i = vam->input;
8562 vl_api_ip_table_add_del_t *mp;
8568 /* Parse args required to build the message */
8569 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8571 if (unformat (i, "ipv6"))
8573 else if (unformat (i, "del"))
8575 else if (unformat (i, "add"))
8577 else if (unformat (i, "table %d", &table_id))
8581 clib_warning ("parse error '%U'", format_unformat_error, i);
8588 errmsg ("missing table-ID");
8592 /* Construct the API message */
8593 M (IP_TABLE_ADD_DEL, mp);
8595 mp->table_id = ntohl (table_id);
8596 mp->is_ipv6 = is_ipv6;
8597 mp->is_add = is_add;
8602 /* Wait for a reply... */
8609 api_ip_add_del_route (vat_main_t * vam)
8611 unformat_input_t *i = vam->input;
8612 vl_api_ip_add_del_route_t *mp;
8613 u32 sw_if_index = ~0, vrf_id = 0;
8615 u8 is_local = 0, is_drop = 0;
8616 u8 is_unreach = 0, is_prohibit = 0;
8618 u32 next_hop_weight = 1;
8619 u8 is_multipath = 0;
8621 u8 address_length_set = 0;
8622 u32 next_hop_table_id = 0;
8623 u32 resolve_attempts = 0;
8624 u32 dst_address_length = 0;
8625 u8 next_hop_set = 0;
8626 ip4_address_t v4_dst_address, v4_next_hop_address;
8627 ip6_address_t v6_dst_address, v6_next_hop_address;
8631 u32 random_add_del = 0;
8632 u32 *random_vector = 0;
8634 u32 random_seed = 0xdeaddabe;
8635 u32 classify_table_index = ~0;
8637 u8 resolve_host = 0, resolve_attached = 0;
8638 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
8639 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8640 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8642 memset (&v4_next_hop_address, 0, sizeof (ip4_address_t));
8643 memset (&v6_next_hop_address, 0, sizeof (ip6_address_t));
8644 /* Parse args required to build the message */
8645 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8647 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8649 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8651 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
8656 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
8661 else if (unformat (i, "/%d", &dst_address_length))
8663 address_length_set = 1;
8666 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
8667 &v4_next_hop_address))
8671 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
8672 &v6_next_hop_address))
8678 (i, "via %U", api_unformat_sw_if_index, vam, &sw_if_index))
8682 else if (unformat (i, "via sw_if_index %d", &sw_if_index))
8686 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
8688 else if (unformat (i, "weight %d", &next_hop_weight))
8690 else if (unformat (i, "drop"))
8694 else if (unformat (i, "null-send-unreach"))
8698 else if (unformat (i, "null-send-prohibit"))
8702 else if (unformat (i, "local"))
8706 else if (unformat (i, "classify %d", &classify_table_index))
8710 else if (unformat (i, "del"))
8712 else if (unformat (i, "add"))
8714 else if (unformat (i, "resolve-via-host"))
8716 else if (unformat (i, "resolve-via-attached"))
8717 resolve_attached = 1;
8718 else if (unformat (i, "multipath"))
8720 else if (unformat (i, "vrf %d", &vrf_id))
8722 else if (unformat (i, "count %d", &count))
8724 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
8726 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8728 else if (unformat (i, "out-label %d", &next_hop_out_label))
8730 vl_api_fib_mpls_label_t fib_label = {
8731 .label = ntohl (next_hop_out_label),
8735 vec_add1 (next_hop_out_label_stack, fib_label);
8737 else if (unformat (i, "via via-label %d", &next_hop_via_label))
8739 else if (unformat (i, "random"))
8741 else if (unformat (i, "seed %d", &random_seed))
8745 clib_warning ("parse error '%U'", format_unformat_error, i);
8750 if (!next_hop_set && !is_drop && !is_local &&
8751 !is_classify && !is_unreach && !is_prohibit &&
8752 MPLS_LABEL_INVALID == next_hop_via_label)
8755 ("next hop / local / drop / unreach / prohibit / classify not set");
8759 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
8761 errmsg ("next hop and next-hop via label set");
8764 if (address_set == 0)
8766 errmsg ("missing addresses");
8770 if (address_length_set == 0)
8772 errmsg ("missing address length");
8776 /* Generate a pile of unique, random routes */
8779 u32 this_random_address;
8780 random_hash = hash_create (count, sizeof (uword));
8782 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
8783 for (j = 0; j <= count; j++)
8787 this_random_address = random_u32 (&random_seed);
8788 this_random_address =
8789 clib_host_to_net_u32 (this_random_address);
8791 while (hash_get (random_hash, this_random_address));
8792 vec_add1 (random_vector, this_random_address);
8793 hash_set (random_hash, this_random_address, 1);
8795 hash_free (random_hash);
8796 v4_dst_address.as_u32 = random_vector[0];
8801 /* Turn on async mode */
8802 vam->async_mode = 1;
8803 vam->async_errors = 0;
8804 before = vat_time_now (vam);
8807 for (j = 0; j < count; j++)
8809 /* Construct the API message */
8810 M2 (IP_ADD_DEL_ROUTE, mp, sizeof (vl_api_fib_mpls_label_t) *
8811 vec_len (next_hop_out_label_stack));
8813 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8814 mp->table_id = ntohl (vrf_id);
8816 mp->is_add = is_add;
8817 mp->is_drop = is_drop;
8818 mp->is_unreach = is_unreach;
8819 mp->is_prohibit = is_prohibit;
8820 mp->is_ipv6 = is_ipv6;
8821 mp->is_local = is_local;
8822 mp->is_classify = is_classify;
8823 mp->is_multipath = is_multipath;
8824 mp->is_resolve_host = resolve_host;
8825 mp->is_resolve_attached = resolve_attached;
8826 mp->next_hop_weight = next_hop_weight;
8827 mp->dst_address_length = dst_address_length;
8828 mp->next_hop_table_id = ntohl (next_hop_table_id);
8829 mp->classify_table_index = ntohl (classify_table_index);
8830 mp->next_hop_via_label = ntohl (next_hop_via_label);
8831 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8832 if (0 != mp->next_hop_n_out_labels)
8834 memcpy (mp->next_hop_out_label_stack,
8835 next_hop_out_label_stack,
8836 (vec_len (next_hop_out_label_stack) *
8837 sizeof (vl_api_fib_mpls_label_t)));
8838 vec_free (next_hop_out_label_stack);
8843 clib_memcpy (mp->dst_address, &v6_dst_address,
8844 sizeof (v6_dst_address));
8846 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
8847 sizeof (v6_next_hop_address));
8848 increment_v6_address (&v6_dst_address);
8852 clib_memcpy (mp->dst_address, &v4_dst_address,
8853 sizeof (v4_dst_address));
8855 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
8856 sizeof (v4_next_hop_address));
8858 v4_dst_address.as_u32 = random_vector[j + 1];
8860 increment_v4_address (&v4_dst_address);
8864 /* If we receive SIGTERM, stop now... */
8869 /* When testing multiple add/del ops, use a control-ping to sync */
8872 vl_api_control_ping_t *mp_ping;
8876 /* Shut off async mode */
8877 vam->async_mode = 0;
8879 MPING (CONTROL_PING, mp_ping);
8882 timeout = vat_time_now (vam) + 1.0;
8883 while (vat_time_now (vam) < timeout)
8884 if (vam->result_ready == 1)
8889 if (vam->retval == -99)
8892 if (vam->async_errors > 0)
8894 errmsg ("%d asynchronous errors", vam->async_errors);
8897 vam->async_errors = 0;
8898 after = vat_time_now (vam);
8900 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8904 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8905 count, after - before, count / (after - before));
8911 /* Wait for a reply... */
8916 /* Return the good/bad news */
8917 return (vam->retval);
8921 api_ip_mroute_add_del (vat_main_t * vam)
8923 unformat_input_t *i = vam->input;
8924 vl_api_ip_mroute_add_del_t *mp;
8925 u32 sw_if_index = ~0, vrf_id = 0;
8930 u32 grp_address_length = 0;
8931 ip4_address_t v4_grp_address, v4_src_address;
8932 ip6_address_t v6_grp_address, v6_src_address;
8933 mfib_itf_flags_t iflags = 0;
8934 mfib_entry_flags_t eflags = 0;
8937 /* Parse args required to build the message */
8938 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8940 if (unformat (i, "sw_if_index %d", &sw_if_index))
8942 else if (unformat (i, "%U %U",
8943 unformat_ip4_address, &v4_src_address,
8944 unformat_ip4_address, &v4_grp_address))
8946 grp_address_length = 64;
8950 else if (unformat (i, "%U %U",
8951 unformat_ip6_address, &v6_src_address,
8952 unformat_ip6_address, &v6_grp_address))
8954 grp_address_length = 256;
8958 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
8960 memset (&v4_src_address, 0, sizeof (v4_src_address));
8961 grp_address_length = 32;
8965 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
8967 memset (&v6_src_address, 0, sizeof (v6_src_address));
8968 grp_address_length = 128;
8972 else if (unformat (i, "/%d", &grp_address_length))
8974 else if (unformat (i, "local"))
8978 else if (unformat (i, "del"))
8980 else if (unformat (i, "add"))
8982 else if (unformat (i, "vrf %d", &vrf_id))
8984 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
8986 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8990 clib_warning ("parse error '%U'", format_unformat_error, i);
8995 if (address_set == 0)
8997 errmsg ("missing addresses\n");
9001 /* Construct the API message */
9002 M (IP_MROUTE_ADD_DEL, mp);
9004 mp->next_hop_sw_if_index = ntohl (sw_if_index);
9005 mp->table_id = ntohl (vrf_id);
9007 mp->is_add = is_add;
9008 mp->is_ipv6 = is_ipv6;
9009 mp->is_local = is_local;
9010 mp->itf_flags = ntohl (iflags);
9011 mp->entry_flags = ntohl (eflags);
9012 mp->grp_address_length = grp_address_length;
9013 mp->grp_address_length = ntohs (mp->grp_address_length);
9017 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
9018 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
9022 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
9023 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
9029 /* Wait for a reply... */
9035 api_mpls_table_add_del (vat_main_t * vam)
9037 unformat_input_t *i = vam->input;
9038 vl_api_mpls_table_add_del_t *mp;
9043 /* Parse args required to build the message */
9044 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9046 if (unformat (i, "table %d", &table_id))
9048 else if (unformat (i, "del"))
9050 else if (unformat (i, "add"))
9054 clib_warning ("parse error '%U'", format_unformat_error, i);
9061 errmsg ("missing table-ID");
9065 /* Construct the API message */
9066 M (MPLS_TABLE_ADD_DEL, mp);
9068 mp->mt_table_id = ntohl (table_id);
9069 mp->mt_is_add = is_add;
9074 /* Wait for a reply... */
9081 api_mpls_route_add_del (vat_main_t * vam)
9083 unformat_input_t *i = vam->input;
9084 vl_api_mpls_route_add_del_t *mp;
9085 u32 sw_if_index = ~0, table_id = 0;
9087 u32 next_hop_weight = 1;
9088 u8 is_multipath = 0;
9089 u32 next_hop_table_id = 0;
9090 u8 next_hop_set = 0;
9091 ip4_address_t v4_next_hop_address = {
9094 ip6_address_t v6_next_hop_address = { {0} };
9098 u32 classify_table_index = ~0;
9100 u8 resolve_host = 0, resolve_attached = 0;
9101 u8 is_interface_rx = 0;
9102 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
9103 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9104 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
9105 mpls_label_t local_label = MPLS_LABEL_INVALID;
9107 dpo_proto_t next_hop_proto = DPO_PROTO_MPLS;
9109 /* Parse args required to build the message */
9110 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9112 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9114 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9116 else if (unformat (i, "%d", &local_label))
9118 else if (unformat (i, "eos"))
9120 else if (unformat (i, "non-eos"))
9122 else if (unformat (i, "via %U", unformat_ip4_address,
9123 &v4_next_hop_address))
9126 next_hop_proto = DPO_PROTO_IP4;
9128 else if (unformat (i, "via %U", unformat_ip6_address,
9129 &v6_next_hop_address))
9132 next_hop_proto = DPO_PROTO_IP6;
9134 else if (unformat (i, "weight %d", &next_hop_weight))
9136 else if (unformat (i, "classify %d", &classify_table_index))
9140 else if (unformat (i, "del"))
9142 else if (unformat (i, "add"))
9144 else if (unformat (i, "resolve-via-host"))
9146 else if (unformat (i, "resolve-via-attached"))
9147 resolve_attached = 1;
9148 else if (unformat (i, "multipath"))
9150 else if (unformat (i, "count %d", &count))
9152 else if (unformat (i, "via lookup-in-ip4-table %d", &next_hop_table_id))
9155 next_hop_proto = DPO_PROTO_IP4;
9157 else if (unformat (i, "via lookup-in-ip6-table %d", &next_hop_table_id))
9160 next_hop_proto = DPO_PROTO_IP6;
9164 (i, "via l2-input-on %U", api_unformat_sw_if_index, vam,
9168 next_hop_proto = DPO_PROTO_ETHERNET;
9169 is_interface_rx = 1;
9171 else if (unformat (i, "via l2-input-on sw_if_index %d", &sw_if_index))
9174 next_hop_proto = DPO_PROTO_ETHERNET;
9175 is_interface_rx = 1;
9177 else if (unformat (i, "via next-hop-table %d", &next_hop_table_id))
9179 else if (unformat (i, "via via-label %d", &next_hop_via_label))
9181 else if (unformat (i, "out-label %d", &next_hop_out_label))
9183 vl_api_fib_mpls_label_t fib_label = {
9184 .label = ntohl (next_hop_out_label),
9188 vec_add1 (next_hop_out_label_stack, fib_label);
9192 clib_warning ("parse error '%U'", format_unformat_error, i);
9197 if (!next_hop_set && !is_classify)
9199 errmsg ("next hop / classify not set");
9203 if (MPLS_LABEL_INVALID == local_label)
9205 errmsg ("missing label");
9211 /* Turn on async mode */
9212 vam->async_mode = 1;
9213 vam->async_errors = 0;
9214 before = vat_time_now (vam);
9217 for (j = 0; j < count; j++)
9219 /* Construct the API message */
9220 M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_mpls_label_t) *
9221 vec_len (next_hop_out_label_stack));
9223 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
9224 mp->mr_table_id = ntohl (table_id);
9226 mp->mr_is_add = is_add;
9227 mp->mr_next_hop_proto = next_hop_proto;
9228 mp->mr_is_classify = is_classify;
9229 mp->mr_is_multipath = is_multipath;
9230 mp->mr_is_resolve_host = resolve_host;
9231 mp->mr_is_resolve_attached = resolve_attached;
9232 mp->mr_is_interface_rx = is_interface_rx;
9233 mp->mr_next_hop_weight = next_hop_weight;
9234 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
9235 mp->mr_classify_table_index = ntohl (classify_table_index);
9236 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
9237 mp->mr_label = ntohl (local_label);
9238 mp->mr_eos = is_eos;
9240 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
9241 if (0 != mp->mr_next_hop_n_out_labels)
9243 memcpy (mp->mr_next_hop_out_label_stack,
9244 next_hop_out_label_stack,
9245 vec_len (next_hop_out_label_stack) *
9246 sizeof (vl_api_fib_mpls_label_t));
9247 vec_free (next_hop_out_label_stack);
9252 if (DPO_PROTO_IP4 == next_hop_proto)
9254 clib_memcpy (mp->mr_next_hop,
9255 &v4_next_hop_address,
9256 sizeof (v4_next_hop_address));
9258 else if (DPO_PROTO_IP6 == next_hop_proto)
9261 clib_memcpy (mp->mr_next_hop,
9262 &v6_next_hop_address,
9263 sizeof (v6_next_hop_address));
9270 /* If we receive SIGTERM, stop now... */
9275 /* When testing multiple add/del ops, use a control-ping to sync */
9278 vl_api_control_ping_t *mp_ping;
9282 /* Shut off async mode */
9283 vam->async_mode = 0;
9285 MPING (CONTROL_PING, mp_ping);
9288 timeout = vat_time_now (vam) + 1.0;
9289 while (vat_time_now (vam) < timeout)
9290 if (vam->result_ready == 1)
9295 if (vam->retval == -99)
9298 if (vam->async_errors > 0)
9300 errmsg ("%d asynchronous errors", vam->async_errors);
9303 vam->async_errors = 0;
9304 after = vat_time_now (vam);
9306 /* slim chance, but we might have eaten SIGTERM on the first iteration */
9310 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
9311 count, after - before, count / (after - before));
9317 /* Wait for a reply... */
9322 /* Return the good/bad news */
9323 return (vam->retval);
9327 api_mpls_ip_bind_unbind (vat_main_t * vam)
9329 unformat_input_t *i = vam->input;
9330 vl_api_mpls_ip_bind_unbind_t *mp;
9331 u32 ip_table_id = 0;
9334 ip4_address_t v4_address;
9335 ip6_address_t v6_address;
9338 mpls_label_t local_label = MPLS_LABEL_INVALID;
9341 /* Parse args required to build the message */
9342 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9344 if (unformat (i, "%U/%d", unformat_ip4_address,
9345 &v4_address, &address_length))
9350 else if (unformat (i, "%U/%d", unformat_ip6_address,
9351 &v6_address, &address_length))
9356 else if (unformat (i, "%d", &local_label))
9358 else if (unformat (i, "table-id %d", &ip_table_id))
9360 else if (unformat (i, "unbind"))
9362 else if (unformat (i, "bind"))
9366 clib_warning ("parse error '%U'", format_unformat_error, i);
9373 errmsg ("IP address not set");
9377 if (MPLS_LABEL_INVALID == local_label)
9379 errmsg ("missing label");
9383 /* Construct the API message */
9384 M (MPLS_IP_BIND_UNBIND, mp);
9386 mp->mb_is_bind = is_bind;
9387 mp->mb_is_ip4 = is_ip4;
9388 mp->mb_ip_table_id = ntohl (ip_table_id);
9389 mp->mb_mpls_table_id = 0;
9390 mp->mb_label = ntohl (local_label);
9391 mp->mb_address_length = address_length;
9394 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
9396 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
9401 /* Wait for a reply... */
9407 api_sr_mpls_policy_add (vat_main_t * vam)
9409 unformat_input_t *i = vam->input;
9410 vl_api_sr_mpls_policy_add_t *mp;
9416 u32 *segments = NULL;
9419 /* Parse args required to build the message */
9420 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9422 if (unformat (i, "bsid %d", &bsid))
9424 else if (unformat (i, "weight %d", &weight))
9426 else if (unformat (i, "spray"))
9428 else if (unformat (i, "next %d", &sid))
9431 vec_add1 (segments, htonl (sid));
9435 clib_warning ("parse error '%U'", format_unformat_error, i);
9442 errmsg ("bsid not set");
9446 if (n_segments == 0)
9448 errmsg ("no sid in segment stack");
9452 /* Construct the API message */
9453 M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
9455 mp->bsid = htonl (bsid);
9456 mp->weight = htonl (weight);
9458 mp->n_segments = n_segments;
9459 memcpy (mp->segments, segments, sizeof (u32) * n_segments);
9460 vec_free (segments);
9465 /* Wait for a reply... */
9471 api_sr_mpls_policy_del (vat_main_t * vam)
9473 unformat_input_t *i = vam->input;
9474 vl_api_sr_mpls_policy_del_t *mp;
9478 /* Parse args required to build the message */
9479 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9481 if (unformat (i, "bsid %d", &bsid))
9485 clib_warning ("parse error '%U'", format_unformat_error, i);
9492 errmsg ("bsid not set");
9496 /* Construct the API message */
9497 M (SR_MPLS_POLICY_DEL, mp);
9499 mp->bsid = htonl (bsid);
9504 /* Wait for a reply... */
9510 api_bier_table_add_del (vat_main_t * vam)
9512 unformat_input_t *i = vam->input;
9513 vl_api_bier_table_add_del_t *mp;
9515 u32 set = 0, sub_domain = 0, hdr_len = 3;
9516 mpls_label_t local_label = MPLS_LABEL_INVALID;
9519 /* Parse args required to build the message */
9520 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9522 if (unformat (i, "sub-domain %d", &sub_domain))
9524 else if (unformat (i, "set %d", &set))
9526 else if (unformat (i, "label %d", &local_label))
9528 else if (unformat (i, "hdr-len %d", &hdr_len))
9530 else if (unformat (i, "add"))
9532 else if (unformat (i, "del"))
9536 clib_warning ("parse error '%U'", format_unformat_error, i);
9541 if (MPLS_LABEL_INVALID == local_label)
9543 errmsg ("missing label\n");
9547 /* Construct the API message */
9548 M (BIER_TABLE_ADD_DEL, mp);
9550 mp->bt_is_add = is_add;
9551 mp->bt_label = ntohl (local_label);
9552 mp->bt_tbl_id.bt_set = set;
9553 mp->bt_tbl_id.bt_sub_domain = sub_domain;
9554 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
9559 /* Wait for a reply... */
9566 api_bier_route_add_del (vat_main_t * vam)
9568 unformat_input_t *i = vam->input;
9569 vl_api_bier_route_add_del_t *mp;
9571 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
9572 ip4_address_t v4_next_hop_address;
9573 ip6_address_t v6_next_hop_address;
9574 u8 next_hop_set = 0;
9575 u8 next_hop_proto_is_ip4 = 1;
9576 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9579 /* Parse args required to build the message */
9580 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9582 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
9584 next_hop_proto_is_ip4 = 1;
9587 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
9589 next_hop_proto_is_ip4 = 0;
9592 if (unformat (i, "sub-domain %d", &sub_domain))
9594 else if (unformat (i, "set %d", &set))
9596 else if (unformat (i, "hdr-len %d", &hdr_len))
9598 else if (unformat (i, "bp %d", &bp))
9600 else if (unformat (i, "add"))
9602 else if (unformat (i, "del"))
9604 else if (unformat (i, "out-label %d", &next_hop_out_label))
9608 clib_warning ("parse error '%U'", format_unformat_error, i);
9613 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
9615 errmsg ("next hop / label set\n");
9620 errmsg ("bit=position not set\n");
9624 /* Construct the API message */
9625 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
9627 mp->br_is_add = is_add;
9628 mp->br_tbl_id.bt_set = set;
9629 mp->br_tbl_id.bt_sub_domain = sub_domain;
9630 mp->br_tbl_id.bt_hdr_len_id = hdr_len;
9631 mp->br_bp = ntohs (bp);
9633 mp->br_paths[0].n_labels = 1;
9634 mp->br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
9635 mp->br_paths[0].afi = (next_hop_proto_is_ip4 ? 0 : 1);
9637 if (next_hop_proto_is_ip4)
9639 clib_memcpy (mp->br_paths[0].next_hop,
9640 &v4_next_hop_address, sizeof (v4_next_hop_address));
9644 clib_memcpy (mp->br_paths[0].next_hop,
9645 &v6_next_hop_address, sizeof (v6_next_hop_address));
9651 /* Wait for a reply... */
9658 api_proxy_arp_add_del (vat_main_t * vam)
9660 unformat_input_t *i = vam->input;
9661 vl_api_proxy_arp_add_del_t *mp;
9664 ip4_address_t lo, hi;
9668 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9670 if (unformat (i, "vrf %d", &vrf_id))
9672 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
9673 unformat_ip4_address, &hi))
9675 else if (unformat (i, "del"))
9679 clib_warning ("parse error '%U'", format_unformat_error, i);
9686 errmsg ("address range not set");
9690 M (PROXY_ARP_ADD_DEL, mp);
9692 mp->proxy.vrf_id = ntohl (vrf_id);
9693 mp->is_add = is_add;
9694 clib_memcpy (mp->proxy.low_address, &lo, sizeof (mp->proxy.low_address));
9695 clib_memcpy (mp->proxy.hi_address, &hi, sizeof (mp->proxy.hi_address));
9703 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
9705 unformat_input_t *i = vam->input;
9706 vl_api_proxy_arp_intfc_enable_disable_t *mp;
9709 u8 sw_if_index_set = 0;
9712 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9714 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9715 sw_if_index_set = 1;
9716 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9717 sw_if_index_set = 1;
9718 else if (unformat (i, "enable"))
9720 else if (unformat (i, "disable"))
9724 clib_warning ("parse error '%U'", format_unformat_error, i);
9729 if (sw_if_index_set == 0)
9731 errmsg ("missing interface name or sw_if_index");
9735 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
9737 mp->sw_if_index = ntohl (sw_if_index);
9738 mp->enable_disable = enable;
9746 api_mpls_tunnel_add_del (vat_main_t * vam)
9748 unformat_input_t *i = vam->input;
9749 vl_api_mpls_tunnel_add_del_t *mp;
9753 u32 sw_if_index = ~0;
9754 u32 next_hop_sw_if_index = ~0;
9755 u32 next_hop_proto_is_ip4 = 1;
9757 u32 next_hop_table_id = 0;
9758 ip4_address_t v4_next_hop_address = {
9761 ip6_address_t v6_next_hop_address = { {0} };
9762 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
9763 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
9766 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9768 if (unformat (i, "add"))
9770 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
9772 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
9774 else if (unformat (i, "via %U",
9775 unformat_ip4_address, &v4_next_hop_address))
9777 next_hop_proto_is_ip4 = 1;
9779 else if (unformat (i, "via %U",
9780 unformat_ip6_address, &v6_next_hop_address))
9782 next_hop_proto_is_ip4 = 0;
9784 else if (unformat (i, "via-label %d", &next_hop_via_label))
9786 else if (unformat (i, "l2-only"))
9788 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
9790 else if (unformat (i, "out-label %d", &next_hop_out_label))
9791 vec_add1 (labels, ntohl (next_hop_out_label));
9794 clib_warning ("parse error '%U'", format_unformat_error, i);
9799 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
9801 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
9802 mp->mt_sw_if_index = ntohl (sw_if_index);
9803 mp->mt_is_add = is_add;
9804 mp->mt_l2_only = l2_only;
9805 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
9806 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
9807 mp->mt_next_hop_via_label = ntohl (next_hop_via_label);
9809 mp->mt_next_hop_n_out_labels = vec_len (labels);
9811 if (0 != mp->mt_next_hop_n_out_labels)
9813 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
9814 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
9818 if (next_hop_proto_is_ip4)
9820 clib_memcpy (mp->mt_next_hop,
9821 &v4_next_hop_address, sizeof (v4_next_hop_address));
9825 clib_memcpy (mp->mt_next_hop,
9826 &v6_next_hop_address, sizeof (v6_next_hop_address));
9835 api_sw_interface_set_unnumbered (vat_main_t * vam)
9837 unformat_input_t *i = vam->input;
9838 vl_api_sw_interface_set_unnumbered_t *mp;
9840 u32 unnum_sw_index = ~0;
9842 u8 sw_if_index_set = 0;
9845 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9847 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9848 sw_if_index_set = 1;
9849 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9850 sw_if_index_set = 1;
9851 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
9853 else if (unformat (i, "del"))
9857 clib_warning ("parse error '%U'", format_unformat_error, i);
9862 if (sw_if_index_set == 0)
9864 errmsg ("missing interface name or sw_if_index");
9868 M (SW_INTERFACE_SET_UNNUMBERED, mp);
9870 mp->sw_if_index = ntohl (sw_if_index);
9871 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
9872 mp->is_add = is_add;
9880 api_ip_neighbor_add_del (vat_main_t * vam)
9882 unformat_input_t *i = vam->input;
9883 vl_api_ip_neighbor_add_del_t *mp;
9885 u8 sw_if_index_set = 0;
9888 u8 is_no_fib_entry = 0;
9891 u8 v4_address_set = 0;
9892 u8 v6_address_set = 0;
9893 ip4_address_t v4address;
9894 ip6_address_t v6address;
9897 memset (mac_address, 0, sizeof (mac_address));
9899 /* Parse args required to build the message */
9900 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9902 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
9906 else if (unformat (i, "del"))
9909 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9910 sw_if_index_set = 1;
9911 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9912 sw_if_index_set = 1;
9913 else if (unformat (i, "is_static"))
9915 else if (unformat (i, "no-fib-entry"))
9916 is_no_fib_entry = 1;
9917 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
9919 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
9923 clib_warning ("parse error '%U'", format_unformat_error, i);
9928 if (sw_if_index_set == 0)
9930 errmsg ("missing interface name or sw_if_index");
9933 if (v4_address_set && v6_address_set)
9935 errmsg ("both v4 and v6 addresses set");
9938 if (!v4_address_set && !v6_address_set)
9940 errmsg ("no address set");
9944 /* Construct the API message */
9945 M (IP_NEIGHBOR_ADD_DEL, mp);
9947 mp->sw_if_index = ntohl (sw_if_index);
9948 mp->is_add = is_add;
9949 mp->is_static = is_static;
9950 mp->is_no_adj_fib = is_no_fib_entry;
9952 clib_memcpy (mp->mac_address, mac_address, 6);
9956 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
9960 /* mp->is_ipv6 = 0; via memset in M macro above */
9961 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
9967 /* Wait for a reply, return good/bad news */
9973 api_create_vlan_subif (vat_main_t * vam)
9975 unformat_input_t *i = vam->input;
9976 vl_api_create_vlan_subif_t *mp;
9978 u8 sw_if_index_set = 0;
9983 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9985 if (unformat (i, "sw_if_index %d", &sw_if_index))
9986 sw_if_index_set = 1;
9988 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9989 sw_if_index_set = 1;
9990 else if (unformat (i, "vlan %d", &vlan_id))
9994 clib_warning ("parse error '%U'", format_unformat_error, i);
9999 if (sw_if_index_set == 0)
10001 errmsg ("missing interface name or sw_if_index");
10005 if (vlan_id_set == 0)
10007 errmsg ("missing vlan_id");
10010 M (CREATE_VLAN_SUBIF, mp);
10012 mp->sw_if_index = ntohl (sw_if_index);
10013 mp->vlan_id = ntohl (vlan_id);
10020 #define foreach_create_subif_bit \
10027 _(outer_vlan_id_any) \
10028 _(inner_vlan_id_any)
10031 api_create_subif (vat_main_t * vam)
10033 unformat_input_t *i = vam->input;
10034 vl_api_create_subif_t *mp;
10036 u8 sw_if_index_set = 0;
10043 u32 exact_match = 0;
10044 u32 default_sub = 0;
10045 u32 outer_vlan_id_any = 0;
10046 u32 inner_vlan_id_any = 0;
10048 u16 outer_vlan_id = 0;
10049 u16 inner_vlan_id = 0;
10052 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10054 if (unformat (i, "sw_if_index %d", &sw_if_index))
10055 sw_if_index_set = 1;
10057 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10058 sw_if_index_set = 1;
10059 else if (unformat (i, "sub_id %d", &sub_id))
10061 else if (unformat (i, "outer_vlan_id %d", &tmp))
10062 outer_vlan_id = tmp;
10063 else if (unformat (i, "inner_vlan_id %d", &tmp))
10064 inner_vlan_id = tmp;
10066 #define _(a) else if (unformat (i, #a)) a = 1 ;
10067 foreach_create_subif_bit
10071 clib_warning ("parse error '%U'", format_unformat_error, i);
10076 if (sw_if_index_set == 0)
10078 errmsg ("missing interface name or sw_if_index");
10082 if (sub_id_set == 0)
10084 errmsg ("missing sub_id");
10087 M (CREATE_SUBIF, mp);
10089 mp->sw_if_index = ntohl (sw_if_index);
10090 mp->sub_id = ntohl (sub_id);
10092 #define _(a) mp->a = a;
10093 foreach_create_subif_bit;
10096 mp->outer_vlan_id = ntohs (outer_vlan_id);
10097 mp->inner_vlan_id = ntohs (inner_vlan_id);
10105 api_oam_add_del (vat_main_t * vam)
10107 unformat_input_t *i = vam->input;
10108 vl_api_oam_add_del_t *mp;
10111 ip4_address_t src, dst;
10116 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10118 if (unformat (i, "vrf %d", &vrf_id))
10120 else if (unformat (i, "src %U", unformat_ip4_address, &src))
10122 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
10124 else if (unformat (i, "del"))
10128 clib_warning ("parse error '%U'", format_unformat_error, i);
10135 errmsg ("missing src addr");
10141 errmsg ("missing dst addr");
10145 M (OAM_ADD_DEL, mp);
10147 mp->vrf_id = ntohl (vrf_id);
10148 mp->is_add = is_add;
10149 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
10150 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
10158 api_reset_fib (vat_main_t * vam)
10160 unformat_input_t *i = vam->input;
10161 vl_api_reset_fib_t *mp;
10167 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10169 if (unformat (i, "vrf %d", &vrf_id))
10171 else if (unformat (i, "ipv6"))
10175 clib_warning ("parse error '%U'", format_unformat_error, i);
10180 if (vrf_id_set == 0)
10182 errmsg ("missing vrf id");
10188 mp->vrf_id = ntohl (vrf_id);
10189 mp->is_ipv6 = is_ipv6;
10197 api_dhcp_proxy_config (vat_main_t * vam)
10199 unformat_input_t *i = vam->input;
10200 vl_api_dhcp_proxy_config_t *mp;
10202 u32 server_vrf_id = 0;
10204 u8 v4_address_set = 0;
10205 u8 v6_address_set = 0;
10206 ip4_address_t v4address;
10207 ip6_address_t v6address;
10208 u8 v4_src_address_set = 0;
10209 u8 v6_src_address_set = 0;
10210 ip4_address_t v4srcaddress;
10211 ip6_address_t v6srcaddress;
10214 /* Parse args required to build the message */
10215 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10217 if (unformat (i, "del"))
10219 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
10221 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
10223 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
10224 v4_address_set = 1;
10225 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
10226 v6_address_set = 1;
10227 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
10228 v4_src_address_set = 1;
10229 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
10230 v6_src_address_set = 1;
10235 if (v4_address_set && v6_address_set)
10237 errmsg ("both v4 and v6 server addresses set");
10240 if (!v4_address_set && !v6_address_set)
10242 errmsg ("no server addresses set");
10246 if (v4_src_address_set && v6_src_address_set)
10248 errmsg ("both v4 and v6 src addresses set");
10251 if (!v4_src_address_set && !v6_src_address_set)
10253 errmsg ("no src addresses set");
10257 if (!(v4_src_address_set && v4_address_set) &&
10258 !(v6_src_address_set && v6_address_set))
10260 errmsg ("no matching server and src addresses set");
10264 /* Construct the API message */
10265 M (DHCP_PROXY_CONFIG, mp);
10267 mp->is_add = is_add;
10268 mp->rx_vrf_id = ntohl (rx_vrf_id);
10269 mp->server_vrf_id = ntohl (server_vrf_id);
10270 if (v6_address_set)
10273 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
10274 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
10278 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
10279 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
10285 /* Wait for a reply, return good/bad news */
10290 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
10291 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
10294 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
10296 vat_main_t *vam = &vat_main;
10297 u32 i, count = mp->count;
10298 vl_api_dhcp_server_t *s;
10302 "RX Table-ID %d, Source Address %U, VSS Type %d, "
10303 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
10304 ntohl (mp->rx_vrf_id),
10305 format_ip6_address, mp->dhcp_src_address,
10306 mp->vss_type, mp->vss_vpn_ascii_id,
10307 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
10310 "RX Table-ID %d, Source Address %U, VSS Type %d, "
10311 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
10312 ntohl (mp->rx_vrf_id),
10313 format_ip4_address, mp->dhcp_src_address,
10314 mp->vss_type, mp->vss_vpn_ascii_id,
10315 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
10317 for (i = 0; i < count; i++)
10319 s = &mp->servers[i];
10323 " Server Table-ID %d, Server Address %U",
10324 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
10327 " Server Table-ID %d, Server Address %U",
10328 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
10332 static void vl_api_dhcp_proxy_details_t_handler_json
10333 (vl_api_dhcp_proxy_details_t * mp)
10335 vat_main_t *vam = &vat_main;
10336 vat_json_node_t *node = NULL;
10337 u32 i, count = mp->count;
10338 struct in_addr ip4;
10339 struct in6_addr ip6;
10340 vl_api_dhcp_server_t *s;
10342 if (VAT_JSON_ARRAY != vam->json_tree.type)
10344 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10345 vat_json_init_array (&vam->json_tree);
10347 node = vat_json_array_add (&vam->json_tree);
10349 vat_json_init_object (node);
10350 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
10351 vat_json_object_add_bytes (node, "vss-type", &mp->vss_type,
10352 sizeof (mp->vss_type));
10353 vat_json_object_add_string_copy (node, "vss-vpn-ascii-id",
10354 mp->vss_vpn_ascii_id);
10355 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
10356 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
10360 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
10361 vat_json_object_add_ip6 (node, "src_address", ip6);
10365 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
10366 vat_json_object_add_ip4 (node, "src_address", ip4);
10369 for (i = 0; i < count; i++)
10371 s = &mp->servers[i];
10373 vat_json_object_add_uint (node, "server-table-id",
10374 ntohl (s->server_vrf_id));
10378 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
10379 vat_json_object_add_ip4 (node, "src_address", ip4);
10383 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
10384 vat_json_object_add_ip6 (node, "server_address", ip6);
10390 api_dhcp_proxy_dump (vat_main_t * vam)
10392 unformat_input_t *i = vam->input;
10393 vl_api_control_ping_t *mp_ping;
10394 vl_api_dhcp_proxy_dump_t *mp;
10398 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10400 if (unformat (i, "ipv6"))
10404 clib_warning ("parse error '%U'", format_unformat_error, i);
10409 M (DHCP_PROXY_DUMP, mp);
10411 mp->is_ip6 = is_ipv6;
10414 /* Use a control ping for synchronization */
10415 MPING (CONTROL_PING, mp_ping);
10423 api_dhcp_proxy_set_vss (vat_main_t * vam)
10425 unformat_input_t *i = vam->input;
10426 vl_api_dhcp_proxy_set_vss_t *mp;
10430 u8 vss_type = VSS_TYPE_DEFAULT;
10431 u8 *vpn_ascii_id = 0;
10436 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10438 if (unformat (i, "tbl_id %d", &tbl_id))
10440 else if (unformat (i, "vpn_ascii_id %s", &vpn_ascii_id))
10441 vss_type = VSS_TYPE_ASCII;
10442 else if (unformat (i, "fib_id %d", &fib_id))
10443 vss_type = VSS_TYPE_VPN_ID;
10444 else if (unformat (i, "oui %d", &oui))
10445 vss_type = VSS_TYPE_VPN_ID;
10446 else if (unformat (i, "ipv6"))
10448 else if (unformat (i, "del"))
10456 errmsg ("missing tbl_id ");
10457 vec_free (vpn_ascii_id);
10461 if ((vpn_ascii_id) && (vec_len (vpn_ascii_id) > 128))
10463 errmsg ("vpn_ascii_id cannot be longer than 128 ");
10464 vec_free (vpn_ascii_id);
10468 M (DHCP_PROXY_SET_VSS, mp);
10469 mp->tbl_id = ntohl (tbl_id);
10470 mp->vss_type = vss_type;
10473 clib_memcpy (mp->vpn_ascii_id, vpn_ascii_id, vec_len (vpn_ascii_id));
10474 mp->vpn_ascii_id[vec_len (vpn_ascii_id)] = 0;
10476 mp->vpn_index = ntohl (fib_id);
10477 mp->oui = ntohl (oui);
10478 mp->is_ipv6 = is_ipv6;
10479 mp->is_add = is_add;
10484 vec_free (vpn_ascii_id);
10489 api_dhcp_client_config (vat_main_t * vam)
10491 unformat_input_t *i = vam->input;
10492 vl_api_dhcp_client_config_t *mp;
10494 u8 sw_if_index_set = 0;
10497 u8 disable_event = 0;
10500 /* Parse args required to build the message */
10501 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10503 if (unformat (i, "del"))
10506 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10507 sw_if_index_set = 1;
10508 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10509 sw_if_index_set = 1;
10510 else if (unformat (i, "hostname %s", &hostname))
10512 else if (unformat (i, "disable_event"))
10518 if (sw_if_index_set == 0)
10520 errmsg ("missing interface name or sw_if_index");
10524 if (vec_len (hostname) > 63)
10526 errmsg ("hostname too long");
10528 vec_add1 (hostname, 0);
10530 /* Construct the API message */
10531 M (DHCP_CLIENT_CONFIG, mp);
10533 mp->is_add = is_add;
10534 mp->client.sw_if_index = htonl (sw_if_index);
10535 clib_memcpy (mp->client.hostname, hostname, vec_len (hostname));
10536 vec_free (hostname);
10537 mp->client.want_dhcp_event = disable_event ? 0 : 1;
10538 mp->client.pid = htonl (getpid ());
10543 /* Wait for a reply, return good/bad news */
10549 api_set_ip_flow_hash (vat_main_t * vam)
10551 unformat_input_t *i = vam->input;
10552 vl_api_set_ip_flow_hash_t *mp;
10564 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10566 if (unformat (i, "vrf %d", &vrf_id))
10568 else if (unformat (i, "ipv6"))
10570 else if (unformat (i, "src"))
10572 else if (unformat (i, "dst"))
10574 else if (unformat (i, "sport"))
10576 else if (unformat (i, "dport"))
10578 else if (unformat (i, "proto"))
10580 else if (unformat (i, "reverse"))
10585 clib_warning ("parse error '%U'", format_unformat_error, i);
10590 if (vrf_id_set == 0)
10592 errmsg ("missing vrf id");
10596 M (SET_IP_FLOW_HASH, mp);
10602 mp->reverse = reverse;
10603 mp->vrf_id = ntohl (vrf_id);
10604 mp->is_ipv6 = is_ipv6;
10612 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
10614 unformat_input_t *i = vam->input;
10615 vl_api_sw_interface_ip6_enable_disable_t *mp;
10617 u8 sw_if_index_set = 0;
10621 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10623 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10624 sw_if_index_set = 1;
10625 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10626 sw_if_index_set = 1;
10627 else if (unformat (i, "enable"))
10629 else if (unformat (i, "disable"))
10633 clib_warning ("parse error '%U'", format_unformat_error, i);
10638 if (sw_if_index_set == 0)
10640 errmsg ("missing interface name or sw_if_index");
10644 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
10646 mp->sw_if_index = ntohl (sw_if_index);
10647 mp->enable = enable;
10655 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
10657 unformat_input_t *i = vam->input;
10658 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
10660 u8 sw_if_index_set = 0;
10661 u8 v6_address_set = 0;
10662 ip6_address_t v6address;
10665 /* Parse args required to build the message */
10666 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10668 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10669 sw_if_index_set = 1;
10670 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10671 sw_if_index_set = 1;
10672 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10673 v6_address_set = 1;
10678 if (sw_if_index_set == 0)
10680 errmsg ("missing interface name or sw_if_index");
10683 if (!v6_address_set)
10685 errmsg ("no address set");
10689 /* Construct the API message */
10690 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
10692 mp->sw_if_index = ntohl (sw_if_index);
10693 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10698 /* Wait for a reply, return good/bad news */
10704 api_ip6nd_proxy_add_del (vat_main_t * vam)
10706 unformat_input_t *i = vam->input;
10707 vl_api_ip6nd_proxy_add_del_t *mp;
10708 u32 sw_if_index = ~0;
10709 u8 v6_address_set = 0;
10710 ip6_address_t v6address;
10714 /* Parse args required to build the message */
10715 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10717 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10719 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10721 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10722 v6_address_set = 1;
10723 if (unformat (i, "del"))
10727 clib_warning ("parse error '%U'", format_unformat_error, i);
10732 if (sw_if_index == ~0)
10734 errmsg ("missing interface name or sw_if_index");
10737 if (!v6_address_set)
10739 errmsg ("no address set");
10743 /* Construct the API message */
10744 M (IP6ND_PROXY_ADD_DEL, mp);
10746 mp->is_del = is_del;
10747 mp->sw_if_index = ntohl (sw_if_index);
10748 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10753 /* Wait for a reply, return good/bad news */
10759 api_ip6nd_proxy_dump (vat_main_t * vam)
10761 vl_api_ip6nd_proxy_dump_t *mp;
10762 vl_api_control_ping_t *mp_ping;
10765 M (IP6ND_PROXY_DUMP, mp);
10769 /* Use a control ping for synchronization */
10770 MPING (CONTROL_PING, mp_ping);
10777 static void vl_api_ip6nd_proxy_details_t_handler
10778 (vl_api_ip6nd_proxy_details_t * mp)
10780 vat_main_t *vam = &vat_main;
10782 print (vam->ofp, "host %U sw_if_index %d",
10783 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
10786 static void vl_api_ip6nd_proxy_details_t_handler_json
10787 (vl_api_ip6nd_proxy_details_t * mp)
10789 vat_main_t *vam = &vat_main;
10790 struct in6_addr ip6;
10791 vat_json_node_t *node = NULL;
10793 if (VAT_JSON_ARRAY != vam->json_tree.type)
10795 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10796 vat_json_init_array (&vam->json_tree);
10798 node = vat_json_array_add (&vam->json_tree);
10800 vat_json_init_object (node);
10801 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10803 clib_memcpy (&ip6, mp->address, sizeof (ip6));
10804 vat_json_object_add_ip6 (node, "host", ip6);
10808 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
10810 unformat_input_t *i = vam->input;
10811 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
10813 u8 sw_if_index_set = 0;
10814 u32 address_length = 0;
10815 u8 v6_address_set = 0;
10816 ip6_address_t v6address;
10817 u8 use_default = 0;
10818 u8 no_advertise = 0;
10820 u8 no_autoconfig = 0;
10823 u32 val_lifetime = 0;
10824 u32 pref_lifetime = 0;
10827 /* Parse args required to build the message */
10828 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10830 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10831 sw_if_index_set = 1;
10832 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10833 sw_if_index_set = 1;
10834 else if (unformat (i, "%U/%d",
10835 unformat_ip6_address, &v6address, &address_length))
10836 v6_address_set = 1;
10837 else if (unformat (i, "val_life %d", &val_lifetime))
10839 else if (unformat (i, "pref_life %d", &pref_lifetime))
10841 else if (unformat (i, "def"))
10843 else if (unformat (i, "noadv"))
10845 else if (unformat (i, "offl"))
10847 else if (unformat (i, "noauto"))
10849 else if (unformat (i, "nolink"))
10851 else if (unformat (i, "isno"))
10855 clib_warning ("parse error '%U'", format_unformat_error, i);
10860 if (sw_if_index_set == 0)
10862 errmsg ("missing interface name or sw_if_index");
10865 if (!v6_address_set)
10867 errmsg ("no address set");
10871 /* Construct the API message */
10872 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
10874 mp->sw_if_index = ntohl (sw_if_index);
10875 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10876 mp->address_length = address_length;
10877 mp->use_default = use_default;
10878 mp->no_advertise = no_advertise;
10879 mp->off_link = off_link;
10880 mp->no_autoconfig = no_autoconfig;
10881 mp->no_onlink = no_onlink;
10883 mp->val_lifetime = ntohl (val_lifetime);
10884 mp->pref_lifetime = ntohl (pref_lifetime);
10889 /* Wait for a reply, return good/bad news */
10895 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
10897 unformat_input_t *i = vam->input;
10898 vl_api_sw_interface_ip6nd_ra_config_t *mp;
10900 u8 sw_if_index_set = 0;
10905 u8 send_unicast = 0;
10908 u8 default_router = 0;
10909 u32 max_interval = 0;
10910 u32 min_interval = 0;
10912 u32 initial_count = 0;
10913 u32 initial_interval = 0;
10917 /* Parse args required to build the message */
10918 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10920 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10921 sw_if_index_set = 1;
10922 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10923 sw_if_index_set = 1;
10924 else if (unformat (i, "maxint %d", &max_interval))
10926 else if (unformat (i, "minint %d", &min_interval))
10928 else if (unformat (i, "life %d", &lifetime))
10930 else if (unformat (i, "count %d", &initial_count))
10932 else if (unformat (i, "interval %d", &initial_interval))
10934 else if (unformat (i, "suppress") || unformat (i, "surpress"))
10936 else if (unformat (i, "managed"))
10938 else if (unformat (i, "other"))
10940 else if (unformat (i, "ll"))
10942 else if (unformat (i, "send"))
10944 else if (unformat (i, "cease"))
10946 else if (unformat (i, "isno"))
10948 else if (unformat (i, "def"))
10949 default_router = 1;
10952 clib_warning ("parse error '%U'", format_unformat_error, i);
10957 if (sw_if_index_set == 0)
10959 errmsg ("missing interface name or sw_if_index");
10963 /* Construct the API message */
10964 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
10966 mp->sw_if_index = ntohl (sw_if_index);
10967 mp->max_interval = ntohl (max_interval);
10968 mp->min_interval = ntohl (min_interval);
10969 mp->lifetime = ntohl (lifetime);
10970 mp->initial_count = ntohl (initial_count);
10971 mp->initial_interval = ntohl (initial_interval);
10972 mp->suppress = suppress;
10973 mp->managed = managed;
10975 mp->ll_option = ll_option;
10976 mp->send_unicast = send_unicast;
10979 mp->default_router = default_router;
10984 /* Wait for a reply, return good/bad news */
10990 api_set_arp_neighbor_limit (vat_main_t * vam)
10992 unformat_input_t *i = vam->input;
10993 vl_api_set_arp_neighbor_limit_t *mp;
10999 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11001 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
11003 else if (unformat (i, "ipv6"))
11007 clib_warning ("parse error '%U'", format_unformat_error, i);
11012 if (limit_set == 0)
11014 errmsg ("missing limit value");
11018 M (SET_ARP_NEIGHBOR_LIMIT, mp);
11020 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
11021 mp->is_ipv6 = is_ipv6;
11029 api_l2_patch_add_del (vat_main_t * vam)
11031 unformat_input_t *i = vam->input;
11032 vl_api_l2_patch_add_del_t *mp;
11033 u32 rx_sw_if_index;
11034 u8 rx_sw_if_index_set = 0;
11035 u32 tx_sw_if_index;
11036 u8 tx_sw_if_index_set = 0;
11040 /* Parse args required to build the message */
11041 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11043 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
11044 rx_sw_if_index_set = 1;
11045 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
11046 tx_sw_if_index_set = 1;
11047 else if (unformat (i, "rx"))
11049 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11051 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
11053 rx_sw_if_index_set = 1;
11058 else if (unformat (i, "tx"))
11060 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11062 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
11064 tx_sw_if_index_set = 1;
11069 else if (unformat (i, "del"))
11075 if (rx_sw_if_index_set == 0)
11077 errmsg ("missing rx interface name or rx_sw_if_index");
11081 if (tx_sw_if_index_set == 0)
11083 errmsg ("missing tx interface name or tx_sw_if_index");
11087 M (L2_PATCH_ADD_DEL, mp);
11089 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
11090 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
11091 mp->is_add = is_add;
11099 u8 localsid_addr[16];
11108 api_sr_localsid_add_del (vat_main_t * vam)
11110 unformat_input_t *i = vam->input;
11111 vl_api_sr_localsid_add_del_t *mp;
11114 ip6_address_t localsid;
11118 u32 fib_table = ~(u32) 0;
11119 ip6_address_t nh_addr6;
11120 ip4_address_t nh_addr4;
11121 memset (&nh_addr6, 0, sizeof (ip6_address_t));
11122 memset (&nh_addr4, 0, sizeof (ip4_address_t));
11124 bool nexthop_set = 0;
11128 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11130 if (unformat (i, "del"))
11132 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
11133 else if (unformat (i, "next-hop %U", unformat_ip4_address, &nh_addr4))
11135 else if (unformat (i, "next-hop %U", unformat_ip6_address, &nh_addr6))
11137 else if (unformat (i, "behavior %u", &behavior));
11138 else if (unformat (i, "sw_if_index %u", &sw_if_index));
11139 else if (unformat (i, "fib-table %u", &fib_table));
11140 else if (unformat (i, "end.psp %u", &behavior));
11145 M (SR_LOCALSID_ADD_DEL, mp);
11147 clib_memcpy (mp->localsid.addr, &localsid, sizeof (mp->localsid));
11150 clib_memcpy (mp->nh_addr6, &nh_addr6, sizeof (mp->nh_addr6));
11151 clib_memcpy (mp->nh_addr4, &nh_addr4, sizeof (mp->nh_addr4));
11153 mp->behavior = behavior;
11154 mp->sw_if_index = ntohl (sw_if_index);
11155 mp->fib_table = ntohl (fib_table);
11156 mp->end_psp = end_psp;
11157 mp->is_del = is_del;
11165 api_ioam_enable (vat_main_t * vam)
11167 unformat_input_t *input = vam->input;
11168 vl_api_ioam_enable_t *mp;
11170 int has_trace_option = 0;
11171 int has_pot_option = 0;
11172 int has_seqno_option = 0;
11173 int has_analyse_option = 0;
11176 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11178 if (unformat (input, "trace"))
11179 has_trace_option = 1;
11180 else if (unformat (input, "pot"))
11181 has_pot_option = 1;
11182 else if (unformat (input, "seqno"))
11183 has_seqno_option = 1;
11184 else if (unformat (input, "analyse"))
11185 has_analyse_option = 1;
11189 M (IOAM_ENABLE, mp);
11190 mp->id = htons (id);
11191 mp->seqno = has_seqno_option;
11192 mp->analyse = has_analyse_option;
11193 mp->pot_enable = has_pot_option;
11194 mp->trace_enable = has_trace_option;
11203 api_ioam_disable (vat_main_t * vam)
11205 vl_api_ioam_disable_t *mp;
11208 M (IOAM_DISABLE, mp);
11214 #define foreach_tcp_proto_field \
11218 #define foreach_udp_proto_field \
11222 #define foreach_ip4_proto_field \
11234 u16 src_port, dst_port;
11237 #if VPP_API_TEST_BUILTIN == 0
11239 unformat_tcp_mask (unformat_input_t * input, va_list * args)
11241 u8 **maskp = va_arg (*args, u8 **);
11243 u8 found_something = 0;
11246 #define _(a) u8 a=0;
11247 foreach_tcp_proto_field;
11250 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11253 #define _(a) else if (unformat (input, #a)) a=1;
11254 foreach_tcp_proto_field
11260 #define _(a) found_something += a;
11261 foreach_tcp_proto_field;
11264 if (found_something == 0)
11267 vec_validate (mask, sizeof (*tcp) - 1);
11269 tcp = (tcp_header_t *) mask;
11271 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
11272 foreach_tcp_proto_field;
11280 unformat_udp_mask (unformat_input_t * input, va_list * args)
11282 u8 **maskp = va_arg (*args, u8 **);
11284 u8 found_something = 0;
11287 #define _(a) u8 a=0;
11288 foreach_udp_proto_field;
11291 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11294 #define _(a) else if (unformat (input, #a)) a=1;
11295 foreach_udp_proto_field
11301 #define _(a) found_something += a;
11302 foreach_udp_proto_field;
11305 if (found_something == 0)
11308 vec_validate (mask, sizeof (*udp) - 1);
11310 udp = (udp_header_t *) mask;
11312 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
11313 foreach_udp_proto_field;
11321 unformat_l4_mask (unformat_input_t * input, va_list * args)
11323 u8 **maskp = va_arg (*args, u8 **);
11324 u16 src_port = 0, dst_port = 0;
11325 tcpudp_header_t *tcpudp;
11327 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11329 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
11331 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
11333 else if (unformat (input, "src_port"))
11335 else if (unformat (input, "dst_port"))
11341 if (!src_port && !dst_port)
11345 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
11347 tcpudp = (tcpudp_header_t *) mask;
11348 tcpudp->src_port = src_port;
11349 tcpudp->dst_port = dst_port;
11357 unformat_ip4_mask (unformat_input_t * input, va_list * args)
11359 u8 **maskp = va_arg (*args, u8 **);
11361 u8 found_something = 0;
11364 #define _(a) u8 a=0;
11365 foreach_ip4_proto_field;
11371 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11373 if (unformat (input, "version"))
11375 else if (unformat (input, "hdr_length"))
11377 else if (unformat (input, "src"))
11379 else if (unformat (input, "dst"))
11381 else if (unformat (input, "proto"))
11384 #define _(a) else if (unformat (input, #a)) a=1;
11385 foreach_ip4_proto_field
11391 #define _(a) found_something += a;
11392 foreach_ip4_proto_field;
11395 if (found_something == 0)
11398 vec_validate (mask, sizeof (*ip) - 1);
11400 ip = (ip4_header_t *) mask;
11402 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
11403 foreach_ip4_proto_field;
11406 ip->ip_version_and_header_length = 0;
11409 ip->ip_version_and_header_length |= 0xF0;
11412 ip->ip_version_and_header_length |= 0x0F;
11418 #define foreach_ip6_proto_field \
11421 _(payload_length) \
11426 unformat_ip6_mask (unformat_input_t * input, va_list * args)
11428 u8 **maskp = va_arg (*args, u8 **);
11430 u8 found_something = 0;
11432 u32 ip_version_traffic_class_and_flow_label;
11434 #define _(a) u8 a=0;
11435 foreach_ip6_proto_field;
11438 u8 traffic_class = 0;
11441 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11443 if (unformat (input, "version"))
11445 else if (unformat (input, "traffic-class"))
11447 else if (unformat (input, "flow-label"))
11449 else if (unformat (input, "src"))
11451 else if (unformat (input, "dst"))
11453 else if (unformat (input, "proto"))
11456 #define _(a) else if (unformat (input, #a)) a=1;
11457 foreach_ip6_proto_field
11463 #define _(a) found_something += a;
11464 foreach_ip6_proto_field;
11467 if (found_something == 0)
11470 vec_validate (mask, sizeof (*ip) - 1);
11472 ip = (ip6_header_t *) mask;
11474 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
11475 foreach_ip6_proto_field;
11478 ip_version_traffic_class_and_flow_label = 0;
11481 ip_version_traffic_class_and_flow_label |= 0xF0000000;
11484 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
11487 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
11489 ip->ip_version_traffic_class_and_flow_label =
11490 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11497 unformat_l3_mask (unformat_input_t * input, va_list * args)
11499 u8 **maskp = va_arg (*args, u8 **);
11501 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11503 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
11505 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
11514 unformat_l2_mask (unformat_input_t * input, va_list * args)
11516 u8 **maskp = va_arg (*args, u8 **);
11523 u8 ignore_tag1 = 0;
11524 u8 ignore_tag2 = 0;
11531 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11533 if (unformat (input, "src"))
11535 else if (unformat (input, "dst"))
11537 else if (unformat (input, "proto"))
11539 else if (unformat (input, "tag1"))
11541 else if (unformat (input, "tag2"))
11543 else if (unformat (input, "ignore-tag1"))
11545 else if (unformat (input, "ignore-tag2"))
11547 else if (unformat (input, "cos1"))
11549 else if (unformat (input, "cos2"))
11551 else if (unformat (input, "dot1q"))
11553 else if (unformat (input, "dot1ad"))
11558 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
11559 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11562 if (tag1 || ignore_tag1 || cos1 || dot1q)
11564 if (tag2 || ignore_tag2 || cos2 || dot1ad)
11567 vec_validate (mask, len - 1);
11570 memset (mask, 0xff, 6);
11573 memset (mask + 6, 0xff, 6);
11575 if (tag2 || dot1ad)
11577 /* inner vlan tag */
11586 mask[21] = mask[20] = 0xff;
11607 mask[16] = mask[17] = 0xff;
11617 mask[12] = mask[13] = 0xff;
11624 unformat_classify_mask (unformat_input_t * input, va_list * args)
11626 u8 **maskp = va_arg (*args, u8 **);
11627 u32 *skipp = va_arg (*args, u32 *);
11628 u32 *matchp = va_arg (*args, u32 *);
11636 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11638 if (unformat (input, "hex %U", unformat_hex_string, &mask))
11640 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
11642 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
11644 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
11658 if (mask || l2 || l3 || l4)
11660 if (l2 || l3 || l4)
11662 /* "With a free Ethernet header in every package" */
11664 vec_validate (l2, 13);
11668 vec_append (mask, l3);
11673 vec_append (mask, l4);
11678 /* Scan forward looking for the first significant mask octet */
11679 for (i = 0; i < vec_len (mask); i++)
11683 /* compute (skip, match) params */
11684 *skipp = i / sizeof (u32x4);
11685 vec_delete (mask, *skipp * sizeof (u32x4), 0);
11687 /* Pad mask to an even multiple of the vector size */
11688 while (vec_len (mask) % sizeof (u32x4))
11689 vec_add1 (mask, 0);
11691 match = vec_len (mask) / sizeof (u32x4);
11693 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
11695 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
11696 if (*tmp || *(tmp + 1))
11701 clib_warning ("BUG: match 0");
11703 _vec_len (mask) = match * sizeof (u32x4);
11713 #endif /* VPP_API_TEST_BUILTIN */
11715 #define foreach_l2_next \
11717 _(ethernet, ETHERNET_INPUT) \
11718 _(ip4, IP4_INPUT) \
11722 unformat_l2_next_index (unformat_input_t * input, va_list * args)
11724 u32 *miss_next_indexp = va_arg (*args, u32 *);
11725 u32 next_index = 0;
11729 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
11733 if (unformat (input, "%d", &tmp))
11742 *miss_next_indexp = next_index;
11746 #define foreach_ip_next \
11749 _(rewrite, REWRITE)
11752 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
11754 u32 *miss_next_indexp = va_arg (*args, u32 *);
11755 u32 next_index = 0;
11759 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
11763 if (unformat (input, "%d", &tmp))
11772 *miss_next_indexp = next_index;
11776 #define foreach_acl_next \
11780 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
11782 u32 *miss_next_indexp = va_arg (*args, u32 *);
11783 u32 next_index = 0;
11787 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
11791 if (unformat (input, "permit"))
11796 else if (unformat (input, "%d", &tmp))
11805 *miss_next_indexp = next_index;
11810 unformat_policer_precolor (unformat_input_t * input, va_list * args)
11812 u32 *r = va_arg (*args, u32 *);
11814 if (unformat (input, "conform-color"))
11815 *r = POLICE_CONFORM;
11816 else if (unformat (input, "exceed-color"))
11817 *r = POLICE_EXCEED;
11825 api_classify_add_del_table (vat_main_t * vam)
11827 unformat_input_t *i = vam->input;
11828 vl_api_classify_add_del_table_t *mp;
11835 u32 table_index = ~0;
11836 u32 next_table_index = ~0;
11837 u32 miss_next_index = ~0;
11838 u32 memory_size = 32 << 20;
11840 u32 current_data_flag = 0;
11841 int current_data_offset = 0;
11844 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11846 if (unformat (i, "del"))
11848 else if (unformat (i, "del-chain"))
11853 else if (unformat (i, "buckets %d", &nbuckets))
11855 else if (unformat (i, "memory_size %d", &memory_size))
11857 else if (unformat (i, "skip %d", &skip))
11859 else if (unformat (i, "match %d", &match))
11861 else if (unformat (i, "table %d", &table_index))
11863 else if (unformat (i, "mask %U", unformat_classify_mask,
11864 &mask, &skip, &match))
11866 else if (unformat (i, "next-table %d", &next_table_index))
11868 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
11871 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
11874 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
11877 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
11879 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
11885 if (is_add && mask == 0)
11887 errmsg ("Mask required");
11891 if (is_add && skip == ~0)
11893 errmsg ("skip count required");
11897 if (is_add && match == ~0)
11899 errmsg ("match count required");
11903 if (!is_add && table_index == ~0)
11905 errmsg ("table index required for delete");
11909 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
11911 mp->is_add = is_add;
11912 mp->del_chain = del_chain;
11913 mp->table_index = ntohl (table_index);
11914 mp->nbuckets = ntohl (nbuckets);
11915 mp->memory_size = ntohl (memory_size);
11916 mp->skip_n_vectors = ntohl (skip);
11917 mp->match_n_vectors = ntohl (match);
11918 mp->next_table_index = ntohl (next_table_index);
11919 mp->miss_next_index = ntohl (miss_next_index);
11920 mp->current_data_flag = ntohl (current_data_flag);
11921 mp->current_data_offset = ntohl (current_data_offset);
11922 mp->mask_len = ntohl (vec_len (mask));
11923 clib_memcpy (mp->mask, mask, vec_len (mask));
11932 #if VPP_API_TEST_BUILTIN == 0
11934 unformat_l4_match (unformat_input_t * input, va_list * args)
11936 u8 **matchp = va_arg (*args, u8 **);
11938 u8 *proto_header = 0;
11944 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11946 if (unformat (input, "src_port %d", &src_port))
11948 else if (unformat (input, "dst_port %d", &dst_port))
11954 h.src_port = clib_host_to_net_u16 (src_port);
11955 h.dst_port = clib_host_to_net_u16 (dst_port);
11956 vec_validate (proto_header, sizeof (h) - 1);
11957 memcpy (proto_header, &h, sizeof (h));
11959 *matchp = proto_header;
11965 unformat_ip4_match (unformat_input_t * input, va_list * args)
11967 u8 **matchp = va_arg (*args, u8 **);
11972 int hdr_length = 0;
11973 u32 hdr_length_val;
11974 int src = 0, dst = 0;
11975 ip4_address_t src_val, dst_val;
11982 int fragment_id = 0;
11983 u32 fragment_id_val;
11989 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11991 if (unformat (input, "version %d", &version_val))
11993 else if (unformat (input, "hdr_length %d", &hdr_length_val))
11995 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
11997 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
11999 else if (unformat (input, "proto %d", &proto_val))
12001 else if (unformat (input, "tos %d", &tos_val))
12003 else if (unformat (input, "length %d", &length_val))
12005 else if (unformat (input, "fragment_id %d", &fragment_id_val))
12007 else if (unformat (input, "ttl %d", &ttl_val))
12009 else if (unformat (input, "checksum %d", &checksum_val))
12015 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
12016 + ttl + checksum == 0)
12020 * Aligned because we use the real comparison functions
12022 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
12024 ip = (ip4_header_t *) match;
12026 /* These are realistically matched in practice */
12028 ip->src_address.as_u32 = src_val.as_u32;
12031 ip->dst_address.as_u32 = dst_val.as_u32;
12034 ip->protocol = proto_val;
12037 /* These are not, but they're included for completeness */
12039 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
12042 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
12048 ip->length = clib_host_to_net_u16 (length_val);
12054 ip->checksum = clib_host_to_net_u16 (checksum_val);
12061 unformat_ip6_match (unformat_input_t * input, va_list * args)
12063 u8 **matchp = va_arg (*args, u8 **);
12068 u8 traffic_class = 0;
12069 u32 traffic_class_val = 0;
12072 int src = 0, dst = 0;
12073 ip6_address_t src_val, dst_val;
12076 int payload_length = 0;
12077 u32 payload_length_val;
12080 u32 ip_version_traffic_class_and_flow_label;
12082 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12084 if (unformat (input, "version %d", &version_val))
12086 else if (unformat (input, "traffic_class %d", &traffic_class_val))
12088 else if (unformat (input, "flow_label %d", &flow_label_val))
12090 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
12092 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
12094 else if (unformat (input, "proto %d", &proto_val))
12096 else if (unformat (input, "payload_length %d", &payload_length_val))
12097 payload_length = 1;
12098 else if (unformat (input, "hop_limit %d", &hop_limit_val))
12104 if (version + traffic_class + flow_label + src + dst + proto +
12105 payload_length + hop_limit == 0)
12109 * Aligned because we use the real comparison functions
12111 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
12113 ip = (ip6_header_t *) match;
12116 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
12119 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
12122 ip->protocol = proto_val;
12124 ip_version_traffic_class_and_flow_label = 0;
12127 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
12130 ip_version_traffic_class_and_flow_label |=
12131 (traffic_class_val & 0xFF) << 20;
12134 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
12136 ip->ip_version_traffic_class_and_flow_label =
12137 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
12139 if (payload_length)
12140 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
12143 ip->hop_limit = hop_limit_val;
12150 unformat_l3_match (unformat_input_t * input, va_list * args)
12152 u8 **matchp = va_arg (*args, u8 **);
12154 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12156 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
12158 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
12167 unformat_vlan_tag (unformat_input_t * input, va_list * args)
12169 u8 *tagp = va_arg (*args, u8 *);
12172 if (unformat (input, "%d", &tag))
12174 tagp[0] = (tag >> 8) & 0x0F;
12175 tagp[1] = tag & 0xFF;
12183 unformat_l2_match (unformat_input_t * input, va_list * args)
12185 u8 **matchp = va_arg (*args, u8 **);
12198 u8 ignore_tag1 = 0;
12199 u8 ignore_tag2 = 0;
12205 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12207 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
12210 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
12212 else if (unformat (input, "proto %U",
12213 unformat_ethernet_type_host_byte_order, &proto_val))
12215 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
12217 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
12219 else if (unformat (input, "ignore-tag1"))
12221 else if (unformat (input, "ignore-tag2"))
12223 else if (unformat (input, "cos1 %d", &cos1_val))
12225 else if (unformat (input, "cos2 %d", &cos2_val))
12230 if ((src + dst + proto + tag1 + tag2 +
12231 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
12234 if (tag1 || ignore_tag1 || cos1)
12236 if (tag2 || ignore_tag2 || cos2)
12239 vec_validate_aligned (match, len - 1, sizeof (u32x4));
12242 clib_memcpy (match, dst_val, 6);
12245 clib_memcpy (match + 6, src_val, 6);
12249 /* inner vlan tag */
12250 match[19] = tag2_val[1];
12251 match[18] = tag2_val[0];
12253 match[18] |= (cos2_val & 0x7) << 5;
12256 match[21] = proto_val & 0xff;
12257 match[20] = proto_val >> 8;
12261 match[15] = tag1_val[1];
12262 match[14] = tag1_val[0];
12265 match[14] |= (cos1_val & 0x7) << 5;
12271 match[15] = tag1_val[1];
12272 match[14] = tag1_val[0];
12275 match[17] = proto_val & 0xff;
12276 match[16] = proto_val >> 8;
12279 match[14] |= (cos1_val & 0x7) << 5;
12285 match[18] |= (cos2_val & 0x7) << 5;
12287 match[14] |= (cos1_val & 0x7) << 5;
12290 match[13] = proto_val & 0xff;
12291 match[12] = proto_val >> 8;
12299 unformat_qos_source (unformat_input_t * input, va_list * args)
12301 int *qs = va_arg (*args, int *);
12303 if (unformat (input, "ip"))
12304 *qs = QOS_SOURCE_IP;
12305 else if (unformat (input, "mpls"))
12306 *qs = QOS_SOURCE_MPLS;
12307 else if (unformat (input, "ext"))
12308 *qs = QOS_SOURCE_EXT;
12309 else if (unformat (input, "vlan"))
12310 *qs = QOS_SOURCE_VLAN;
12319 api_unformat_classify_match (unformat_input_t * input, va_list * args)
12321 u8 **matchp = va_arg (*args, u8 **);
12322 u32 skip_n_vectors = va_arg (*args, u32);
12323 u32 match_n_vectors = va_arg (*args, u32);
12330 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12332 if (unformat (input, "hex %U", unformat_hex_string, &match))
12334 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
12336 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
12338 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
12352 if (match || l2 || l3 || l4)
12354 if (l2 || l3 || l4)
12356 /* "Win a free Ethernet header in every packet" */
12358 vec_validate_aligned (l2, 13, sizeof (u32x4));
12362 vec_append_aligned (match, l3, sizeof (u32x4));
12367 vec_append_aligned (match, l4, sizeof (u32x4));
12372 /* Make sure the vector is big enough even if key is all 0's */
12373 vec_validate_aligned
12374 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
12377 /* Set size, include skipped vectors */
12378 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
12389 api_classify_add_del_session (vat_main_t * vam)
12391 unformat_input_t *i = vam->input;
12392 vl_api_classify_add_del_session_t *mp;
12394 u32 table_index = ~0;
12395 u32 hit_next_index = ~0;
12396 u32 opaque_index = ~0;
12399 u32 skip_n_vectors = 0;
12400 u32 match_n_vectors = 0;
12406 * Warning: you have to supply skip_n and match_n
12407 * because the API client cant simply look at the classify
12411 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12413 if (unformat (i, "del"))
12415 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
12418 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
12421 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
12424 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
12426 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
12428 else if (unformat (i, "opaque-index %d", &opaque_index))
12430 else if (unformat (i, "skip_n %d", &skip_n_vectors))
12432 else if (unformat (i, "match_n %d", &match_n_vectors))
12434 else if (unformat (i, "match %U", api_unformat_classify_match,
12435 &match, skip_n_vectors, match_n_vectors))
12437 else if (unformat (i, "advance %d", &advance))
12439 else if (unformat (i, "table-index %d", &table_index))
12441 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
12443 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
12445 else if (unformat (i, "action %d", &action))
12447 else if (unformat (i, "metadata %d", &metadata))
12453 if (table_index == ~0)
12455 errmsg ("Table index required");
12459 if (is_add && match == 0)
12461 errmsg ("Match value required");
12465 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
12467 mp->is_add = is_add;
12468 mp->table_index = ntohl (table_index);
12469 mp->hit_next_index = ntohl (hit_next_index);
12470 mp->opaque_index = ntohl (opaque_index);
12471 mp->advance = ntohl (advance);
12472 mp->action = action;
12473 mp->metadata = ntohl (metadata);
12474 mp->match_len = ntohl (vec_len (match));
12475 clib_memcpy (mp->match, match, vec_len (match));
12484 api_classify_set_interface_ip_table (vat_main_t * vam)
12486 unformat_input_t *i = vam->input;
12487 vl_api_classify_set_interface_ip_table_t *mp;
12489 int sw_if_index_set;
12490 u32 table_index = ~0;
12494 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12496 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12497 sw_if_index_set = 1;
12498 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12499 sw_if_index_set = 1;
12500 else if (unformat (i, "table %d", &table_index))
12504 clib_warning ("parse error '%U'", format_unformat_error, i);
12509 if (sw_if_index_set == 0)
12511 errmsg ("missing interface name or sw_if_index");
12516 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
12518 mp->sw_if_index = ntohl (sw_if_index);
12519 mp->table_index = ntohl (table_index);
12520 mp->is_ipv6 = is_ipv6;
12528 api_classify_set_interface_l2_tables (vat_main_t * vam)
12530 unformat_input_t *i = vam->input;
12531 vl_api_classify_set_interface_l2_tables_t *mp;
12533 int sw_if_index_set;
12534 u32 ip4_table_index = ~0;
12535 u32 ip6_table_index = ~0;
12536 u32 other_table_index = ~0;
12540 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12542 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12543 sw_if_index_set = 1;
12544 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12545 sw_if_index_set = 1;
12546 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12548 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12550 else if (unformat (i, "other-table %d", &other_table_index))
12552 else if (unformat (i, "is-input %d", &is_input))
12556 clib_warning ("parse error '%U'", format_unformat_error, i);
12561 if (sw_if_index_set == 0)
12563 errmsg ("missing interface name or sw_if_index");
12568 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
12570 mp->sw_if_index = ntohl (sw_if_index);
12571 mp->ip4_table_index = ntohl (ip4_table_index);
12572 mp->ip6_table_index = ntohl (ip6_table_index);
12573 mp->other_table_index = ntohl (other_table_index);
12574 mp->is_input = (u8) is_input;
12582 api_set_ipfix_exporter (vat_main_t * vam)
12584 unformat_input_t *i = vam->input;
12585 vl_api_set_ipfix_exporter_t *mp;
12586 ip4_address_t collector_address;
12587 u8 collector_address_set = 0;
12588 u32 collector_port = ~0;
12589 ip4_address_t src_address;
12590 u8 src_address_set = 0;
12593 u32 template_interval = ~0;
12594 u8 udp_checksum = 0;
12597 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12599 if (unformat (i, "collector_address %U", unformat_ip4_address,
12600 &collector_address))
12601 collector_address_set = 1;
12602 else if (unformat (i, "collector_port %d", &collector_port))
12604 else if (unformat (i, "src_address %U", unformat_ip4_address,
12606 src_address_set = 1;
12607 else if (unformat (i, "vrf_id %d", &vrf_id))
12609 else if (unformat (i, "path_mtu %d", &path_mtu))
12611 else if (unformat (i, "template_interval %d", &template_interval))
12613 else if (unformat (i, "udp_checksum"))
12619 if (collector_address_set == 0)
12621 errmsg ("collector_address required");
12625 if (src_address_set == 0)
12627 errmsg ("src_address required");
12631 M (SET_IPFIX_EXPORTER, mp);
12633 memcpy (mp->collector_address, collector_address.data,
12634 sizeof (collector_address.data));
12635 mp->collector_port = htons ((u16) collector_port);
12636 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
12637 mp->vrf_id = htonl (vrf_id);
12638 mp->path_mtu = htonl (path_mtu);
12639 mp->template_interval = htonl (template_interval);
12640 mp->udp_checksum = udp_checksum;
12648 api_set_ipfix_classify_stream (vat_main_t * vam)
12650 unformat_input_t *i = vam->input;
12651 vl_api_set_ipfix_classify_stream_t *mp;
12653 u32 src_port = UDP_DST_PORT_ipfix;
12656 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12658 if (unformat (i, "domain %d", &domain_id))
12660 else if (unformat (i, "src_port %d", &src_port))
12664 errmsg ("unknown input `%U'", format_unformat_error, i);
12669 M (SET_IPFIX_CLASSIFY_STREAM, mp);
12671 mp->domain_id = htonl (domain_id);
12672 mp->src_port = htons ((u16) src_port);
12680 api_ipfix_classify_table_add_del (vat_main_t * vam)
12682 unformat_input_t *i = vam->input;
12683 vl_api_ipfix_classify_table_add_del_t *mp;
12685 u32 classify_table_index = ~0;
12687 u8 transport_protocol = 255;
12690 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12692 if (unformat (i, "add"))
12694 else if (unformat (i, "del"))
12696 else if (unformat (i, "table %d", &classify_table_index))
12698 else if (unformat (i, "ip4"))
12700 else if (unformat (i, "ip6"))
12702 else if (unformat (i, "tcp"))
12703 transport_protocol = 6;
12704 else if (unformat (i, "udp"))
12705 transport_protocol = 17;
12708 errmsg ("unknown input `%U'", format_unformat_error, i);
12715 errmsg ("expecting: add|del");
12718 if (classify_table_index == ~0)
12720 errmsg ("classifier table not specified");
12723 if (ip_version == 0)
12725 errmsg ("IP version not specified");
12729 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
12731 mp->is_add = is_add;
12732 mp->table_id = htonl (classify_table_index);
12733 mp->ip_version = ip_version;
12734 mp->transport_protocol = transport_protocol;
12742 api_get_node_index (vat_main_t * vam)
12744 unformat_input_t *i = vam->input;
12745 vl_api_get_node_index_t *mp;
12749 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12751 if (unformat (i, "node %s", &name))
12758 errmsg ("node name required");
12761 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12763 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12767 M (GET_NODE_INDEX, mp);
12768 clib_memcpy (mp->node_name, name, vec_len (name));
12777 api_get_next_index (vat_main_t * vam)
12779 unformat_input_t *i = vam->input;
12780 vl_api_get_next_index_t *mp;
12781 u8 *node_name = 0, *next_node_name = 0;
12784 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12786 if (unformat (i, "node-name %s", &node_name))
12788 else if (unformat (i, "next-node-name %s", &next_node_name))
12792 if (node_name == 0)
12794 errmsg ("node name required");
12797 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
12799 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12803 if (next_node_name == 0)
12805 errmsg ("next node name required");
12808 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
12810 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
12814 M (GET_NEXT_INDEX, mp);
12815 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
12816 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
12817 vec_free (node_name);
12818 vec_free (next_node_name);
12826 api_add_node_next (vat_main_t * vam)
12828 unformat_input_t *i = vam->input;
12829 vl_api_add_node_next_t *mp;
12834 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12836 if (unformat (i, "node %s", &name))
12838 else if (unformat (i, "next %s", &next))
12845 errmsg ("node name required");
12848 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12850 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12855 errmsg ("next node required");
12858 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
12860 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
12864 M (ADD_NODE_NEXT, mp);
12865 clib_memcpy (mp->node_name, name, vec_len (name));
12866 clib_memcpy (mp->next_name, next, vec_len (next));
12876 api_l2tpv3_create_tunnel (vat_main_t * vam)
12878 unformat_input_t *i = vam->input;
12879 ip6_address_t client_address, our_address;
12880 int client_address_set = 0;
12881 int our_address_set = 0;
12882 u32 local_session_id = 0;
12883 u32 remote_session_id = 0;
12884 u64 local_cookie = 0;
12885 u64 remote_cookie = 0;
12886 u8 l2_sublayer_present = 0;
12887 vl_api_l2tpv3_create_tunnel_t *mp;
12890 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12892 if (unformat (i, "client_address %U", unformat_ip6_address,
12894 client_address_set = 1;
12895 else if (unformat (i, "our_address %U", unformat_ip6_address,
12897 our_address_set = 1;
12898 else if (unformat (i, "local_session_id %d", &local_session_id))
12900 else if (unformat (i, "remote_session_id %d", &remote_session_id))
12902 else if (unformat (i, "local_cookie %lld", &local_cookie))
12904 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
12906 else if (unformat (i, "l2-sublayer-present"))
12907 l2_sublayer_present = 1;
12912 if (client_address_set == 0)
12914 errmsg ("client_address required");
12918 if (our_address_set == 0)
12920 errmsg ("our_address required");
12924 M (L2TPV3_CREATE_TUNNEL, mp);
12926 clib_memcpy (mp->client_address, client_address.as_u8,
12927 sizeof (mp->client_address));
12929 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
12931 mp->local_session_id = ntohl (local_session_id);
12932 mp->remote_session_id = ntohl (remote_session_id);
12933 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
12934 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
12935 mp->l2_sublayer_present = l2_sublayer_present;
12944 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
12946 unformat_input_t *i = vam->input;
12948 u8 sw_if_index_set = 0;
12949 u64 new_local_cookie = 0;
12950 u64 new_remote_cookie = 0;
12951 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
12954 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12956 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12957 sw_if_index_set = 1;
12958 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12959 sw_if_index_set = 1;
12960 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
12962 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
12968 if (sw_if_index_set == 0)
12970 errmsg ("missing interface name or sw_if_index");
12974 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
12976 mp->sw_if_index = ntohl (sw_if_index);
12977 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
12978 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
12986 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
12988 unformat_input_t *i = vam->input;
12989 vl_api_l2tpv3_interface_enable_disable_t *mp;
12991 u8 sw_if_index_set = 0;
12992 u8 enable_disable = 1;
12995 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12997 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12998 sw_if_index_set = 1;
12999 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13000 sw_if_index_set = 1;
13001 else if (unformat (i, "enable"))
13002 enable_disable = 1;
13003 else if (unformat (i, "disable"))
13004 enable_disable = 0;
13009 if (sw_if_index_set == 0)
13011 errmsg ("missing interface name or sw_if_index");
13015 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
13017 mp->sw_if_index = ntohl (sw_if_index);
13018 mp->enable_disable = enable_disable;
13026 api_l2tpv3_set_lookup_key (vat_main_t * vam)
13028 unformat_input_t *i = vam->input;
13029 vl_api_l2tpv3_set_lookup_key_t *mp;
13033 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13035 if (unformat (i, "lookup_v6_src"))
13036 key = L2T_LOOKUP_SRC_ADDRESS;
13037 else if (unformat (i, "lookup_v6_dst"))
13038 key = L2T_LOOKUP_DST_ADDRESS;
13039 else if (unformat (i, "lookup_session_id"))
13040 key = L2T_LOOKUP_SESSION_ID;
13045 if (key == (u8) ~ 0)
13047 errmsg ("l2tp session lookup key unset");
13051 M (L2TPV3_SET_LOOKUP_KEY, mp);
13060 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
13061 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
13063 vat_main_t *vam = &vat_main;
13065 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
13066 format_ip6_address, mp->our_address,
13067 format_ip6_address, mp->client_address,
13068 clib_net_to_host_u32 (mp->sw_if_index));
13071 " local cookies %016llx %016llx remote cookie %016llx",
13072 clib_net_to_host_u64 (mp->local_cookie[0]),
13073 clib_net_to_host_u64 (mp->local_cookie[1]),
13074 clib_net_to_host_u64 (mp->remote_cookie));
13076 print (vam->ofp, " local session-id %d remote session-id %d",
13077 clib_net_to_host_u32 (mp->local_session_id),
13078 clib_net_to_host_u32 (mp->remote_session_id));
13080 print (vam->ofp, " l2 specific sublayer %s\n",
13081 mp->l2_sublayer_present ? "preset" : "absent");
13085 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
13086 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
13088 vat_main_t *vam = &vat_main;
13089 vat_json_node_t *node = NULL;
13090 struct in6_addr addr;
13092 if (VAT_JSON_ARRAY != vam->json_tree.type)
13094 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13095 vat_json_init_array (&vam->json_tree);
13097 node = vat_json_array_add (&vam->json_tree);
13099 vat_json_init_object (node);
13101 clib_memcpy (&addr, mp->our_address, sizeof (addr));
13102 vat_json_object_add_ip6 (node, "our_address", addr);
13103 clib_memcpy (&addr, mp->client_address, sizeof (addr));
13104 vat_json_object_add_ip6 (node, "client_address", addr);
13106 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
13107 vat_json_init_array (lc);
13108 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
13109 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
13110 vat_json_object_add_uint (node, "remote_cookie",
13111 clib_net_to_host_u64 (mp->remote_cookie));
13113 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
13114 vat_json_object_add_uint (node, "local_session_id",
13115 clib_net_to_host_u32 (mp->local_session_id));
13116 vat_json_object_add_uint (node, "remote_session_id",
13117 clib_net_to_host_u32 (mp->remote_session_id));
13118 vat_json_object_add_string_copy (node, "l2_sublayer",
13119 mp->l2_sublayer_present ? (u8 *) "present"
13120 : (u8 *) "absent");
13124 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
13126 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
13127 vl_api_control_ping_t *mp_ping;
13130 /* Get list of l2tpv3-tunnel interfaces */
13131 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
13134 /* Use a control ping for synchronization */
13135 MPING (CONTROL_PING, mp_ping);
13143 static void vl_api_sw_interface_tap_details_t_handler
13144 (vl_api_sw_interface_tap_details_t * mp)
13146 vat_main_t *vam = &vat_main;
13148 print (vam->ofp, "%-16s %d",
13149 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
13152 static void vl_api_sw_interface_tap_details_t_handler_json
13153 (vl_api_sw_interface_tap_details_t * mp)
13155 vat_main_t *vam = &vat_main;
13156 vat_json_node_t *node = NULL;
13158 if (VAT_JSON_ARRAY != vam->json_tree.type)
13160 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13161 vat_json_init_array (&vam->json_tree);
13163 node = vat_json_array_add (&vam->json_tree);
13165 vat_json_init_object (node);
13166 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13167 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
13171 api_sw_interface_tap_dump (vat_main_t * vam)
13173 vl_api_sw_interface_tap_dump_t *mp;
13174 vl_api_control_ping_t *mp_ping;
13177 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
13178 /* Get list of tap interfaces */
13179 M (SW_INTERFACE_TAP_DUMP, mp);
13182 /* Use a control ping for synchronization */
13183 MPING (CONTROL_PING, mp_ping);
13190 static void vl_api_sw_interface_tap_v2_details_t_handler
13191 (vl_api_sw_interface_tap_v2_details_t * mp)
13193 vat_main_t *vam = &vat_main;
13195 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
13196 mp->host_ip4_prefix_len);
13197 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
13198 mp->host_ip6_prefix_len);
13201 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s",
13202 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
13203 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
13204 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
13205 mp->host_bridge, ip4, ip6);
13211 static void vl_api_sw_interface_tap_v2_details_t_handler_json
13212 (vl_api_sw_interface_tap_v2_details_t * mp)
13214 vat_main_t *vam = &vat_main;
13215 vat_json_node_t *node = NULL;
13217 if (VAT_JSON_ARRAY != vam->json_tree.type)
13219 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13220 vat_json_init_array (&vam->json_tree);
13222 node = vat_json_array_add (&vam->json_tree);
13224 vat_json_init_object (node);
13225 vat_json_object_add_uint (node, "id", ntohl (mp->id));
13226 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13227 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
13228 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
13229 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
13230 vat_json_object_add_string_copy (node, "host_mac_addr",
13231 format (0, "%U", format_ethernet_address,
13232 &mp->host_mac_addr));
13233 vat_json_object_add_string_copy (node, "host_namespace",
13234 mp->host_namespace);
13235 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
13236 vat_json_object_add_string_copy (node, "host_ip4_addr",
13237 format (0, "%U/%d", format_ip4_address,
13239 mp->host_ip4_prefix_len));
13240 vat_json_object_add_string_copy (node, "host_ip6_addr",
13241 format (0, "%U/%d", format_ip6_address,
13243 mp->host_ip6_prefix_len));
13248 api_sw_interface_tap_v2_dump (vat_main_t * vam)
13250 vl_api_sw_interface_tap_v2_dump_t *mp;
13251 vl_api_control_ping_t *mp_ping;
13255 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
13256 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
13257 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
13260 /* Get list of tap interfaces */
13261 M (SW_INTERFACE_TAP_V2_DUMP, mp);
13264 /* Use a control ping for synchronization */
13265 MPING (CONTROL_PING, mp_ping);
13273 api_vxlan_offload_rx (vat_main_t * vam)
13275 unformat_input_t *line_input = vam->input;
13276 vl_api_vxlan_offload_rx_t *mp;
13277 u32 hw_if_index = ~0, rx_if_index = ~0;
13281 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13283 if (unformat (line_input, "del"))
13285 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
13288 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
13290 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
13293 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
13297 errmsg ("parse error '%U'", format_unformat_error, line_input);
13302 if (hw_if_index == ~0)
13304 errmsg ("no hw interface");
13308 if (rx_if_index == ~0)
13310 errmsg ("no rx tunnel");
13314 M (VXLAN_OFFLOAD_RX, mp);
13316 mp->hw_if_index = ntohl (hw_if_index);
13317 mp->sw_if_index = ntohl (rx_if_index);
13318 mp->enable = is_add;
13325 static uword unformat_vxlan_decap_next
13326 (unformat_input_t * input, va_list * args)
13328 u32 *result = va_arg (*args, u32 *);
13331 if (unformat (input, "l2"))
13332 *result = VXLAN_INPUT_NEXT_L2_INPUT;
13333 else if (unformat (input, "%d", &tmp))
13341 api_vxlan_add_del_tunnel (vat_main_t * vam)
13343 unformat_input_t *line_input = vam->input;
13344 vl_api_vxlan_add_del_tunnel_t *mp;
13345 ip46_address_t src, dst;
13347 u8 ipv4_set = 0, ipv6_set = 0;
13352 u32 mcast_sw_if_index = ~0;
13353 u32 encap_vrf_id = 0;
13354 u32 decap_next_index = ~0;
13358 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13359 memset (&src, 0, sizeof src);
13360 memset (&dst, 0, sizeof dst);
13362 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13364 if (unformat (line_input, "del"))
13366 else if (unformat (line_input, "instance %d", &instance))
13369 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13375 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13381 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13387 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13392 else if (unformat (line_input, "group %U %U",
13393 unformat_ip4_address, &dst.ip4,
13394 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13396 grp_set = dst_set = 1;
13399 else if (unformat (line_input, "group %U",
13400 unformat_ip4_address, &dst.ip4))
13402 grp_set = dst_set = 1;
13405 else if (unformat (line_input, "group %U %U",
13406 unformat_ip6_address, &dst.ip6,
13407 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13409 grp_set = dst_set = 1;
13412 else if (unformat (line_input, "group %U",
13413 unformat_ip6_address, &dst.ip6))
13415 grp_set = dst_set = 1;
13419 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13421 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13423 else if (unformat (line_input, "decap-next %U",
13424 unformat_vxlan_decap_next, &decap_next_index))
13426 else if (unformat (line_input, "vni %d", &vni))
13430 errmsg ("parse error '%U'", format_unformat_error, line_input);
13437 errmsg ("tunnel src address not specified");
13442 errmsg ("tunnel dst address not specified");
13446 if (grp_set && !ip46_address_is_multicast (&dst))
13448 errmsg ("tunnel group address not multicast");
13451 if (grp_set && mcast_sw_if_index == ~0)
13453 errmsg ("tunnel nonexistent multicast device");
13456 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13458 errmsg ("tunnel dst address must be unicast");
13463 if (ipv4_set && ipv6_set)
13465 errmsg ("both IPv4 and IPv6 addresses specified");
13469 if ((vni == 0) || (vni >> 24))
13471 errmsg ("vni not specified or out of range");
13475 M (VXLAN_ADD_DEL_TUNNEL, mp);
13479 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
13480 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
13484 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
13485 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
13488 mp->instance = htonl (instance);
13489 mp->encap_vrf_id = ntohl (encap_vrf_id);
13490 mp->decap_next_index = ntohl (decap_next_index);
13491 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13492 mp->vni = ntohl (vni);
13493 mp->is_add = is_add;
13494 mp->is_ipv6 = ipv6_set;
13501 static void vl_api_vxlan_tunnel_details_t_handler
13502 (vl_api_vxlan_tunnel_details_t * mp)
13504 vat_main_t *vam = &vat_main;
13505 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13506 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13508 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
13509 ntohl (mp->sw_if_index),
13510 ntohl (mp->instance),
13511 format_ip46_address, &src, IP46_TYPE_ANY,
13512 format_ip46_address, &dst, IP46_TYPE_ANY,
13513 ntohl (mp->encap_vrf_id),
13514 ntohl (mp->decap_next_index), ntohl (mp->vni),
13515 ntohl (mp->mcast_sw_if_index));
13518 static void vl_api_vxlan_tunnel_details_t_handler_json
13519 (vl_api_vxlan_tunnel_details_t * mp)
13521 vat_main_t *vam = &vat_main;
13522 vat_json_node_t *node = NULL;
13524 if (VAT_JSON_ARRAY != vam->json_tree.type)
13526 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13527 vat_json_init_array (&vam->json_tree);
13529 node = vat_json_array_add (&vam->json_tree);
13531 vat_json_init_object (node);
13532 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13534 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13538 struct in6_addr ip6;
13540 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13541 vat_json_object_add_ip6 (node, "src_address", ip6);
13542 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13543 vat_json_object_add_ip6 (node, "dst_address", ip6);
13547 struct in_addr ip4;
13549 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13550 vat_json_object_add_ip4 (node, "src_address", ip4);
13551 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13552 vat_json_object_add_ip4 (node, "dst_address", ip4);
13554 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13555 vat_json_object_add_uint (node, "decap_next_index",
13556 ntohl (mp->decap_next_index));
13557 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13558 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13559 vat_json_object_add_uint (node, "mcast_sw_if_index",
13560 ntohl (mp->mcast_sw_if_index));
13564 api_vxlan_tunnel_dump (vat_main_t * vam)
13566 unformat_input_t *i = vam->input;
13567 vl_api_vxlan_tunnel_dump_t *mp;
13568 vl_api_control_ping_t *mp_ping;
13570 u8 sw_if_index_set = 0;
13573 /* Parse args required to build the message */
13574 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13576 if (unformat (i, "sw_if_index %d", &sw_if_index))
13577 sw_if_index_set = 1;
13582 if (sw_if_index_set == 0)
13587 if (!vam->json_output)
13589 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
13590 "sw_if_index", "instance", "src_address", "dst_address",
13591 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13594 /* Get list of vxlan-tunnel interfaces */
13595 M (VXLAN_TUNNEL_DUMP, mp);
13597 mp->sw_if_index = htonl (sw_if_index);
13601 /* Use a control ping for synchronization */
13602 MPING (CONTROL_PING, mp_ping);
13609 static uword unformat_geneve_decap_next
13610 (unformat_input_t * input, va_list * args)
13612 u32 *result = va_arg (*args, u32 *);
13615 if (unformat (input, "l2"))
13616 *result = GENEVE_INPUT_NEXT_L2_INPUT;
13617 else if (unformat (input, "%d", &tmp))
13625 api_geneve_add_del_tunnel (vat_main_t * vam)
13627 unformat_input_t *line_input = vam->input;
13628 vl_api_geneve_add_del_tunnel_t *mp;
13629 ip46_address_t src, dst;
13631 u8 ipv4_set = 0, ipv6_set = 0;
13635 u32 mcast_sw_if_index = ~0;
13636 u32 encap_vrf_id = 0;
13637 u32 decap_next_index = ~0;
13641 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13642 memset (&src, 0, sizeof src);
13643 memset (&dst, 0, sizeof dst);
13645 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13647 if (unformat (line_input, "del"))
13650 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13656 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13662 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13668 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13673 else if (unformat (line_input, "group %U %U",
13674 unformat_ip4_address, &dst.ip4,
13675 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13677 grp_set = dst_set = 1;
13680 else if (unformat (line_input, "group %U",
13681 unformat_ip4_address, &dst.ip4))
13683 grp_set = dst_set = 1;
13686 else if (unformat (line_input, "group %U %U",
13687 unformat_ip6_address, &dst.ip6,
13688 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13690 grp_set = dst_set = 1;
13693 else if (unformat (line_input, "group %U",
13694 unformat_ip6_address, &dst.ip6))
13696 grp_set = dst_set = 1;
13700 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13702 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13704 else if (unformat (line_input, "decap-next %U",
13705 unformat_geneve_decap_next, &decap_next_index))
13707 else if (unformat (line_input, "vni %d", &vni))
13711 errmsg ("parse error '%U'", format_unformat_error, line_input);
13718 errmsg ("tunnel src address not specified");
13723 errmsg ("tunnel dst address not specified");
13727 if (grp_set && !ip46_address_is_multicast (&dst))
13729 errmsg ("tunnel group address not multicast");
13732 if (grp_set && mcast_sw_if_index == ~0)
13734 errmsg ("tunnel nonexistent multicast device");
13737 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13739 errmsg ("tunnel dst address must be unicast");
13744 if (ipv4_set && ipv6_set)
13746 errmsg ("both IPv4 and IPv6 addresses specified");
13750 if ((vni == 0) || (vni >> 24))
13752 errmsg ("vni not specified or out of range");
13756 M (GENEVE_ADD_DEL_TUNNEL, mp);
13760 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
13761 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
13765 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
13766 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
13768 mp->encap_vrf_id = ntohl (encap_vrf_id);
13769 mp->decap_next_index = ntohl (decap_next_index);
13770 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13771 mp->vni = ntohl (vni);
13772 mp->is_add = is_add;
13773 mp->is_ipv6 = ipv6_set;
13780 static void vl_api_geneve_tunnel_details_t_handler
13781 (vl_api_geneve_tunnel_details_t * mp)
13783 vat_main_t *vam = &vat_main;
13784 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13785 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13787 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
13788 ntohl (mp->sw_if_index),
13789 format_ip46_address, &src, IP46_TYPE_ANY,
13790 format_ip46_address, &dst, IP46_TYPE_ANY,
13791 ntohl (mp->encap_vrf_id),
13792 ntohl (mp->decap_next_index), ntohl (mp->vni),
13793 ntohl (mp->mcast_sw_if_index));
13796 static void vl_api_geneve_tunnel_details_t_handler_json
13797 (vl_api_geneve_tunnel_details_t * mp)
13799 vat_main_t *vam = &vat_main;
13800 vat_json_node_t *node = NULL;
13802 if (VAT_JSON_ARRAY != vam->json_tree.type)
13804 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13805 vat_json_init_array (&vam->json_tree);
13807 node = vat_json_array_add (&vam->json_tree);
13809 vat_json_init_object (node);
13810 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13813 struct in6_addr ip6;
13815 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13816 vat_json_object_add_ip6 (node, "src_address", ip6);
13817 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13818 vat_json_object_add_ip6 (node, "dst_address", ip6);
13822 struct in_addr ip4;
13824 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13825 vat_json_object_add_ip4 (node, "src_address", ip4);
13826 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13827 vat_json_object_add_ip4 (node, "dst_address", ip4);
13829 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13830 vat_json_object_add_uint (node, "decap_next_index",
13831 ntohl (mp->decap_next_index));
13832 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13833 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13834 vat_json_object_add_uint (node, "mcast_sw_if_index",
13835 ntohl (mp->mcast_sw_if_index));
13839 api_geneve_tunnel_dump (vat_main_t * vam)
13841 unformat_input_t *i = vam->input;
13842 vl_api_geneve_tunnel_dump_t *mp;
13843 vl_api_control_ping_t *mp_ping;
13845 u8 sw_if_index_set = 0;
13848 /* Parse args required to build the message */
13849 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13851 if (unformat (i, "sw_if_index %d", &sw_if_index))
13852 sw_if_index_set = 1;
13857 if (sw_if_index_set == 0)
13862 if (!vam->json_output)
13864 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
13865 "sw_if_index", "local_address", "remote_address",
13866 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13869 /* Get list of geneve-tunnel interfaces */
13870 M (GENEVE_TUNNEL_DUMP, mp);
13872 mp->sw_if_index = htonl (sw_if_index);
13876 /* Use a control ping for synchronization */
13877 M (CONTROL_PING, mp_ping);
13885 api_gre_add_del_tunnel (vat_main_t * vam)
13887 unformat_input_t *line_input = vam->input;
13888 vl_api_gre_add_del_tunnel_t *mp;
13889 ip4_address_t src4, dst4;
13890 ip6_address_t src6, dst6;
13894 u8 t_type = GRE_TUNNEL_TYPE_L3;
13897 u32 outer_fib_id = 0;
13898 u32 session_id = 0;
13902 memset (&src4, 0, sizeof src4);
13903 memset (&dst4, 0, sizeof dst4);
13904 memset (&src6, 0, sizeof src6);
13905 memset (&dst6, 0, sizeof dst6);
13907 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13909 if (unformat (line_input, "del"))
13911 else if (unformat (line_input, "instance %d", &instance))
13913 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
13918 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
13923 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
13928 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
13933 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
13935 else if (unformat (line_input, "teb"))
13936 t_type = GRE_TUNNEL_TYPE_TEB;
13937 else if (unformat (line_input, "erspan %d", &session_id))
13938 t_type = GRE_TUNNEL_TYPE_ERSPAN;
13941 errmsg ("parse error '%U'", format_unformat_error, line_input);
13948 errmsg ("tunnel src address not specified");
13953 errmsg ("tunnel dst address not specified");
13956 if (ipv4_set && ipv6_set)
13958 errmsg ("both IPv4 and IPv6 addresses specified");
13963 M (GRE_ADD_DEL_TUNNEL, mp);
13967 clib_memcpy (&mp->src_address, &src4, 4);
13968 clib_memcpy (&mp->dst_address, &dst4, 4);
13972 clib_memcpy (&mp->src_address, &src6, 16);
13973 clib_memcpy (&mp->dst_address, &dst6, 16);
13975 mp->instance = htonl (instance);
13976 mp->outer_fib_id = htonl (outer_fib_id);
13977 mp->is_add = is_add;
13978 mp->session_id = htons ((u16) session_id);
13979 mp->tunnel_type = t_type;
13980 mp->is_ipv6 = ipv6_set;
13987 static void vl_api_gre_tunnel_details_t_handler
13988 (vl_api_gre_tunnel_details_t * mp)
13990 vat_main_t *vam = &vat_main;
13991 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
13992 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
13994 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
13995 ntohl (mp->sw_if_index),
13996 ntohl (mp->instance),
13997 format_ip46_address, &src, IP46_TYPE_ANY,
13998 format_ip46_address, &dst, IP46_TYPE_ANY,
13999 mp->tunnel_type, ntohl (mp->outer_fib_id), ntohl (mp->session_id));
14002 static void vl_api_gre_tunnel_details_t_handler_json
14003 (vl_api_gre_tunnel_details_t * mp)
14005 vat_main_t *vam = &vat_main;
14006 vat_json_node_t *node = NULL;
14007 struct in_addr ip4;
14008 struct in6_addr ip6;
14010 if (VAT_JSON_ARRAY != vam->json_tree.type)
14012 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14013 vat_json_init_array (&vam->json_tree);
14015 node = vat_json_array_add (&vam->json_tree);
14017 vat_json_init_object (node);
14018 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14019 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
14022 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
14023 vat_json_object_add_ip4 (node, "src_address", ip4);
14024 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
14025 vat_json_object_add_ip4 (node, "dst_address", ip4);
14029 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
14030 vat_json_object_add_ip6 (node, "src_address", ip6);
14031 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
14032 vat_json_object_add_ip6 (node, "dst_address", ip6);
14034 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel_type);
14035 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
14036 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
14037 vat_json_object_add_uint (node, "session_id", mp->session_id);
14041 api_gre_tunnel_dump (vat_main_t * vam)
14043 unformat_input_t *i = vam->input;
14044 vl_api_gre_tunnel_dump_t *mp;
14045 vl_api_control_ping_t *mp_ping;
14047 u8 sw_if_index_set = 0;
14050 /* Parse args required to build the message */
14051 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14053 if (unformat (i, "sw_if_index %d", &sw_if_index))
14054 sw_if_index_set = 1;
14059 if (sw_if_index_set == 0)
14064 if (!vam->json_output)
14066 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
14067 "sw_if_index", "instance", "src_address", "dst_address",
14068 "tunnel_type", "outer_fib_id", "session_id");
14071 /* Get list of gre-tunnel interfaces */
14072 M (GRE_TUNNEL_DUMP, mp);
14074 mp->sw_if_index = htonl (sw_if_index);
14078 /* Use a control ping for synchronization */
14079 MPING (CONTROL_PING, mp_ping);
14087 api_l2_fib_clear_table (vat_main_t * vam)
14089 // unformat_input_t * i = vam->input;
14090 vl_api_l2_fib_clear_table_t *mp;
14093 M (L2_FIB_CLEAR_TABLE, mp);
14101 api_l2_interface_efp_filter (vat_main_t * vam)
14103 unformat_input_t *i = vam->input;
14104 vl_api_l2_interface_efp_filter_t *mp;
14107 u8 sw_if_index_set = 0;
14110 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14112 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14113 sw_if_index_set = 1;
14114 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14115 sw_if_index_set = 1;
14116 else if (unformat (i, "enable"))
14118 else if (unformat (i, "disable"))
14122 clib_warning ("parse error '%U'", format_unformat_error, i);
14127 if (sw_if_index_set == 0)
14129 errmsg ("missing sw_if_index");
14133 M (L2_INTERFACE_EFP_FILTER, mp);
14135 mp->sw_if_index = ntohl (sw_if_index);
14136 mp->enable_disable = enable;
14143 #define foreach_vtr_op \
14144 _("disable", L2_VTR_DISABLED) \
14145 _("push-1", L2_VTR_PUSH_1) \
14146 _("push-2", L2_VTR_PUSH_2) \
14147 _("pop-1", L2_VTR_POP_1) \
14148 _("pop-2", L2_VTR_POP_2) \
14149 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
14150 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
14151 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
14152 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
14155 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
14157 unformat_input_t *i = vam->input;
14158 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
14160 u8 sw_if_index_set = 0;
14163 u32 push_dot1q = 1;
14168 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14170 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14171 sw_if_index_set = 1;
14172 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14173 sw_if_index_set = 1;
14174 else if (unformat (i, "vtr_op %d", &vtr_op))
14176 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
14179 else if (unformat (i, "push_dot1q %d", &push_dot1q))
14181 else if (unformat (i, "tag1 %d", &tag1))
14183 else if (unformat (i, "tag2 %d", &tag2))
14187 clib_warning ("parse error '%U'", format_unformat_error, i);
14192 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
14194 errmsg ("missing vtr operation or sw_if_index");
14198 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
14199 mp->sw_if_index = ntohl (sw_if_index);
14200 mp->vtr_op = ntohl (vtr_op);
14201 mp->push_dot1q = ntohl (push_dot1q);
14202 mp->tag1 = ntohl (tag1);
14203 mp->tag2 = ntohl (tag2);
14211 api_create_vhost_user_if (vat_main_t * vam)
14213 unformat_input_t *i = vam->input;
14214 vl_api_create_vhost_user_if_t *mp;
14217 u8 file_name_set = 0;
14218 u32 custom_dev_instance = ~0;
14220 u8 use_custom_mac = 0;
14221 u8 disable_mrg_rxbuf = 0;
14222 u8 disable_indirect_desc = 0;
14226 /* Shut up coverity */
14227 memset (hwaddr, 0, sizeof (hwaddr));
14229 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14231 if (unformat (i, "socket %s", &file_name))
14235 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
14237 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
14238 use_custom_mac = 1;
14239 else if (unformat (i, "server"))
14241 else if (unformat (i, "disable_mrg_rxbuf"))
14242 disable_mrg_rxbuf = 1;
14243 else if (unformat (i, "disable_indirect_desc"))
14244 disable_indirect_desc = 1;
14245 else if (unformat (i, "tag %s", &tag))
14251 if (file_name_set == 0)
14253 errmsg ("missing socket file name");
14257 if (vec_len (file_name) > 255)
14259 errmsg ("socket file name too long");
14262 vec_add1 (file_name, 0);
14264 M (CREATE_VHOST_USER_IF, mp);
14266 mp->is_server = is_server;
14267 mp->disable_mrg_rxbuf = disable_mrg_rxbuf;
14268 mp->disable_indirect_desc = disable_indirect_desc;
14269 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
14270 vec_free (file_name);
14271 if (custom_dev_instance != ~0)
14274 mp->custom_dev_instance = ntohl (custom_dev_instance);
14277 mp->use_custom_mac = use_custom_mac;
14278 clib_memcpy (mp->mac_address, hwaddr, 6);
14280 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
14289 api_modify_vhost_user_if (vat_main_t * vam)
14291 unformat_input_t *i = vam->input;
14292 vl_api_modify_vhost_user_if_t *mp;
14295 u8 file_name_set = 0;
14296 u32 custom_dev_instance = ~0;
14297 u8 sw_if_index_set = 0;
14298 u32 sw_if_index = (u32) ~ 0;
14301 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14303 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14304 sw_if_index_set = 1;
14305 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14306 sw_if_index_set = 1;
14307 else if (unformat (i, "socket %s", &file_name))
14311 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
14313 else if (unformat (i, "server"))
14319 if (sw_if_index_set == 0)
14321 errmsg ("missing sw_if_index or interface name");
14325 if (file_name_set == 0)
14327 errmsg ("missing socket file name");
14331 if (vec_len (file_name) > 255)
14333 errmsg ("socket file name too long");
14336 vec_add1 (file_name, 0);
14338 M (MODIFY_VHOST_USER_IF, mp);
14340 mp->sw_if_index = ntohl (sw_if_index);
14341 mp->is_server = is_server;
14342 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
14343 vec_free (file_name);
14344 if (custom_dev_instance != ~0)
14347 mp->custom_dev_instance = ntohl (custom_dev_instance);
14356 api_delete_vhost_user_if (vat_main_t * vam)
14358 unformat_input_t *i = vam->input;
14359 vl_api_delete_vhost_user_if_t *mp;
14360 u32 sw_if_index = ~0;
14361 u8 sw_if_index_set = 0;
14364 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14366 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14367 sw_if_index_set = 1;
14368 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14369 sw_if_index_set = 1;
14374 if (sw_if_index_set == 0)
14376 errmsg ("missing sw_if_index or interface name");
14381 M (DELETE_VHOST_USER_IF, mp);
14383 mp->sw_if_index = ntohl (sw_if_index);
14390 static void vl_api_sw_interface_vhost_user_details_t_handler
14391 (vl_api_sw_interface_vhost_user_details_t * mp)
14393 vat_main_t *vam = &vat_main;
14395 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
14396 (char *) mp->interface_name,
14397 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
14398 clib_net_to_host_u64 (mp->features), mp->is_server,
14399 ntohl (mp->num_regions), (char *) mp->sock_filename);
14400 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
14403 static void vl_api_sw_interface_vhost_user_details_t_handler_json
14404 (vl_api_sw_interface_vhost_user_details_t * mp)
14406 vat_main_t *vam = &vat_main;
14407 vat_json_node_t *node = NULL;
14409 if (VAT_JSON_ARRAY != vam->json_tree.type)
14411 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14412 vat_json_init_array (&vam->json_tree);
14414 node = vat_json_array_add (&vam->json_tree);
14416 vat_json_init_object (node);
14417 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14418 vat_json_object_add_string_copy (node, "interface_name",
14419 mp->interface_name);
14420 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
14421 ntohl (mp->virtio_net_hdr_sz));
14422 vat_json_object_add_uint (node, "features",
14423 clib_net_to_host_u64 (mp->features));
14424 vat_json_object_add_uint (node, "is_server", mp->is_server);
14425 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
14426 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
14427 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
14431 api_sw_interface_vhost_user_dump (vat_main_t * vam)
14433 vl_api_sw_interface_vhost_user_dump_t *mp;
14434 vl_api_control_ping_t *mp_ping;
14437 "Interface name idx hdr_sz features server regions filename");
14439 /* Get list of vhost-user interfaces */
14440 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
14443 /* Use a control ping for synchronization */
14444 MPING (CONTROL_PING, mp_ping);
14452 api_show_version (vat_main_t * vam)
14454 vl_api_show_version_t *mp;
14457 M (SHOW_VERSION, mp);
14466 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
14468 unformat_input_t *line_input = vam->input;
14469 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
14470 ip4_address_t local4, remote4;
14471 ip6_address_t local6, remote6;
14473 u8 ipv4_set = 0, ipv6_set = 0;
14477 u32 mcast_sw_if_index = ~0;
14478 u32 encap_vrf_id = 0;
14479 u32 decap_vrf_id = 0;
14485 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
14486 memset (&local4, 0, sizeof local4);
14487 memset (&remote4, 0, sizeof remote4);
14488 memset (&local6, 0, sizeof local6);
14489 memset (&remote6, 0, sizeof remote6);
14491 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14493 if (unformat (line_input, "del"))
14495 else if (unformat (line_input, "local %U",
14496 unformat_ip4_address, &local4))
14501 else if (unformat (line_input, "remote %U",
14502 unformat_ip4_address, &remote4))
14507 else if (unformat (line_input, "local %U",
14508 unformat_ip6_address, &local6))
14513 else if (unformat (line_input, "remote %U",
14514 unformat_ip6_address, &remote6))
14519 else if (unformat (line_input, "group %U %U",
14520 unformat_ip4_address, &remote4,
14521 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14523 grp_set = remote_set = 1;
14526 else if (unformat (line_input, "group %U",
14527 unformat_ip4_address, &remote4))
14529 grp_set = remote_set = 1;
14532 else if (unformat (line_input, "group %U %U",
14533 unformat_ip6_address, &remote6,
14534 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14536 grp_set = remote_set = 1;
14539 else if (unformat (line_input, "group %U",
14540 unformat_ip6_address, &remote6))
14542 grp_set = remote_set = 1;
14546 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
14548 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
14550 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
14552 else if (unformat (line_input, "vni %d", &vni))
14554 else if (unformat (line_input, "next-ip4"))
14556 else if (unformat (line_input, "next-ip6"))
14558 else if (unformat (line_input, "next-ethernet"))
14560 else if (unformat (line_input, "next-nsh"))
14564 errmsg ("parse error '%U'", format_unformat_error, line_input);
14569 if (local_set == 0)
14571 errmsg ("tunnel local address not specified");
14574 if (remote_set == 0)
14576 errmsg ("tunnel remote address not specified");
14579 if (grp_set && mcast_sw_if_index == ~0)
14581 errmsg ("tunnel nonexistent multicast device");
14584 if (ipv4_set && ipv6_set)
14586 errmsg ("both IPv4 and IPv6 addresses specified");
14592 errmsg ("vni not specified");
14596 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
14601 clib_memcpy (&mp->local, &local6, sizeof (local6));
14602 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
14606 clib_memcpy (&mp->local, &local4, sizeof (local4));
14607 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
14610 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
14611 mp->encap_vrf_id = ntohl (encap_vrf_id);
14612 mp->decap_vrf_id = ntohl (decap_vrf_id);
14613 mp->protocol = protocol;
14614 mp->vni = ntohl (vni);
14615 mp->is_add = is_add;
14616 mp->is_ipv6 = ipv6_set;
14623 static void vl_api_vxlan_gpe_tunnel_details_t_handler
14624 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14626 vat_main_t *vam = &vat_main;
14627 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
14628 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
14630 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
14631 ntohl (mp->sw_if_index),
14632 format_ip46_address, &local, IP46_TYPE_ANY,
14633 format_ip46_address, &remote, IP46_TYPE_ANY,
14634 ntohl (mp->vni), mp->protocol,
14635 ntohl (mp->mcast_sw_if_index),
14636 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
14640 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
14641 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14643 vat_main_t *vam = &vat_main;
14644 vat_json_node_t *node = NULL;
14645 struct in_addr ip4;
14646 struct in6_addr ip6;
14648 if (VAT_JSON_ARRAY != vam->json_tree.type)
14650 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14651 vat_json_init_array (&vam->json_tree);
14653 node = vat_json_array_add (&vam->json_tree);
14655 vat_json_init_object (node);
14656 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14659 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
14660 vat_json_object_add_ip6 (node, "local", ip6);
14661 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
14662 vat_json_object_add_ip6 (node, "remote", ip6);
14666 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
14667 vat_json_object_add_ip4 (node, "local", ip4);
14668 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
14669 vat_json_object_add_ip4 (node, "remote", ip4);
14671 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
14672 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
14673 vat_json_object_add_uint (node, "mcast_sw_if_index",
14674 ntohl (mp->mcast_sw_if_index));
14675 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
14676 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
14677 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
14681 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
14683 unformat_input_t *i = vam->input;
14684 vl_api_vxlan_gpe_tunnel_dump_t *mp;
14685 vl_api_control_ping_t *mp_ping;
14687 u8 sw_if_index_set = 0;
14690 /* Parse args required to build the message */
14691 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14693 if (unformat (i, "sw_if_index %d", &sw_if_index))
14694 sw_if_index_set = 1;
14699 if (sw_if_index_set == 0)
14704 if (!vam->json_output)
14706 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
14707 "sw_if_index", "local", "remote", "vni",
14708 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
14711 /* Get list of vxlan-tunnel interfaces */
14712 M (VXLAN_GPE_TUNNEL_DUMP, mp);
14714 mp->sw_if_index = htonl (sw_if_index);
14718 /* Use a control ping for synchronization */
14719 MPING (CONTROL_PING, mp_ping);
14726 static void vl_api_l2_fib_table_details_t_handler
14727 (vl_api_l2_fib_table_details_t * mp)
14729 vat_main_t *vam = &vat_main;
14731 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
14733 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
14734 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
14738 static void vl_api_l2_fib_table_details_t_handler_json
14739 (vl_api_l2_fib_table_details_t * mp)
14741 vat_main_t *vam = &vat_main;
14742 vat_json_node_t *node = NULL;
14744 if (VAT_JSON_ARRAY != vam->json_tree.type)
14746 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14747 vat_json_init_array (&vam->json_tree);
14749 node = vat_json_array_add (&vam->json_tree);
14751 vat_json_init_object (node);
14752 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
14753 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
14754 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14755 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
14756 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
14757 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
14761 api_l2_fib_table_dump (vat_main_t * vam)
14763 unformat_input_t *i = vam->input;
14764 vl_api_l2_fib_table_dump_t *mp;
14765 vl_api_control_ping_t *mp_ping;
14770 /* Parse args required to build the message */
14771 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14773 if (unformat (i, "bd_id %d", &bd_id))
14779 if (bd_id_set == 0)
14781 errmsg ("missing bridge domain");
14785 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
14787 /* Get list of l2 fib entries */
14788 M (L2_FIB_TABLE_DUMP, mp);
14790 mp->bd_id = ntohl (bd_id);
14793 /* Use a control ping for synchronization */
14794 MPING (CONTROL_PING, mp_ping);
14803 api_interface_name_renumber (vat_main_t * vam)
14805 unformat_input_t *line_input = vam->input;
14806 vl_api_interface_name_renumber_t *mp;
14807 u32 sw_if_index = ~0;
14808 u32 new_show_dev_instance = ~0;
14811 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14813 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
14816 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14818 else if (unformat (line_input, "new_show_dev_instance %d",
14819 &new_show_dev_instance))
14825 if (sw_if_index == ~0)
14827 errmsg ("missing interface name or sw_if_index");
14831 if (new_show_dev_instance == ~0)
14833 errmsg ("missing new_show_dev_instance");
14837 M (INTERFACE_NAME_RENUMBER, mp);
14839 mp->sw_if_index = ntohl (sw_if_index);
14840 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
14848 api_ip_probe_neighbor (vat_main_t * vam)
14850 unformat_input_t *i = vam->input;
14851 vl_api_ip_probe_neighbor_t *mp;
14859 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14861 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14863 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14865 else if (unformat (i, "address %U", unformat_ip4_address, dst_adr))
14867 else if (unformat (i, "address %U", unformat_ip6_address, dst_adr))
14878 errmsg ("missing interface");
14884 errmsg ("missing addresses");
14888 M (IP_PROBE_NEIGHBOR, mp);
14890 mp->sw_if_index = ntohl (sw_if_index);
14891 mp->is_ipv6 = is_ipv6;
14892 clib_memcpy (mp->dst_address, dst_adr, sizeof (dst_adr));
14900 api_ip_scan_neighbor_enable_disable (vat_main_t * vam)
14902 unformat_input_t *i = vam->input;
14903 vl_api_ip_scan_neighbor_enable_disable_t *mp;
14904 u8 mode = IP_SCAN_V46_NEIGHBORS;
14905 u32 interval = 0, time = 0, update = 0, delay = 0, stale = 0;
14908 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14910 if (unformat (i, "ip4"))
14911 mode = IP_SCAN_V4_NEIGHBORS;
14912 else if (unformat (i, "ip6"))
14913 mode = IP_SCAN_V6_NEIGHBORS;
14914 if (unformat (i, "both"))
14915 mode = IP_SCAN_V46_NEIGHBORS;
14916 else if (unformat (i, "disable"))
14917 mode = IP_SCAN_DISABLED;
14918 else if (unformat (i, "interval %d", &interval))
14920 else if (unformat (i, "max-time %d", &time))
14922 else if (unformat (i, "max-update %d", &update))
14924 else if (unformat (i, "delay %d", &delay))
14926 else if (unformat (i, "stale %d", &stale))
14932 if (interval > 255)
14934 errmsg ("interval cannot exceed 255 minutes.");
14939 errmsg ("max-time cannot exceed 255 usec.");
14944 errmsg ("max-update cannot exceed 255.");
14949 errmsg ("delay cannot exceed 255 msec.");
14954 errmsg ("stale cannot exceed 255 minutes.");
14958 M (IP_SCAN_NEIGHBOR_ENABLE_DISABLE, mp);
14960 mp->scan_interval = interval;
14961 mp->max_proc_time = time;
14962 mp->max_update = update;
14963 mp->scan_int_delay = delay;
14964 mp->stale_threshold = stale;
14972 api_want_ip4_arp_events (vat_main_t * vam)
14974 unformat_input_t *line_input = vam->input;
14975 vl_api_want_ip4_arp_events_t *mp;
14976 ip4_address_t address;
14977 int address_set = 0;
14978 u32 enable_disable = 1;
14981 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14983 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
14985 else if (unformat (line_input, "del"))
14986 enable_disable = 0;
14991 if (address_set == 0)
14993 errmsg ("missing addresses");
14997 M (WANT_IP4_ARP_EVENTS, mp);
14998 mp->enable_disable = enable_disable;
14999 mp->pid = htonl (getpid ());
15000 mp->address = address.as_u32;
15008 api_want_ip6_nd_events (vat_main_t * vam)
15010 unformat_input_t *line_input = vam->input;
15011 vl_api_want_ip6_nd_events_t *mp;
15012 ip6_address_t address;
15013 int address_set = 0;
15014 u32 enable_disable = 1;
15017 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15019 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
15021 else if (unformat (line_input, "del"))
15022 enable_disable = 0;
15027 if (address_set == 0)
15029 errmsg ("missing addresses");
15033 M (WANT_IP6_ND_EVENTS, mp);
15034 mp->enable_disable = enable_disable;
15035 mp->pid = htonl (getpid ());
15036 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
15044 api_want_l2_macs_events (vat_main_t * vam)
15046 unformat_input_t *line_input = vam->input;
15047 vl_api_want_l2_macs_events_t *mp;
15048 u8 enable_disable = 1;
15049 u32 scan_delay = 0;
15050 u32 max_macs_in_event = 0;
15051 u32 learn_limit = 0;
15054 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15056 if (unformat (line_input, "learn-limit %d", &learn_limit))
15058 else if (unformat (line_input, "scan-delay %d", &scan_delay))
15060 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
15062 else if (unformat (line_input, "disable"))
15063 enable_disable = 0;
15068 M (WANT_L2_MACS_EVENTS, mp);
15069 mp->enable_disable = enable_disable;
15070 mp->pid = htonl (getpid ());
15071 mp->learn_limit = htonl (learn_limit);
15072 mp->scan_delay = (u8) scan_delay;
15073 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
15080 api_input_acl_set_interface (vat_main_t * vam)
15082 unformat_input_t *i = vam->input;
15083 vl_api_input_acl_set_interface_t *mp;
15085 int sw_if_index_set;
15086 u32 ip4_table_index = ~0;
15087 u32 ip6_table_index = ~0;
15088 u32 l2_table_index = ~0;
15092 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15094 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15095 sw_if_index_set = 1;
15096 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15097 sw_if_index_set = 1;
15098 else if (unformat (i, "del"))
15100 else if (unformat (i, "ip4-table %d", &ip4_table_index))
15102 else if (unformat (i, "ip6-table %d", &ip6_table_index))
15104 else if (unformat (i, "l2-table %d", &l2_table_index))
15108 clib_warning ("parse error '%U'", format_unformat_error, i);
15113 if (sw_if_index_set == 0)
15115 errmsg ("missing interface name or sw_if_index");
15119 M (INPUT_ACL_SET_INTERFACE, mp);
15121 mp->sw_if_index = ntohl (sw_if_index);
15122 mp->ip4_table_index = ntohl (ip4_table_index);
15123 mp->ip6_table_index = ntohl (ip6_table_index);
15124 mp->l2_table_index = ntohl (l2_table_index);
15125 mp->is_add = is_add;
15133 api_output_acl_set_interface (vat_main_t * vam)
15135 unformat_input_t *i = vam->input;
15136 vl_api_output_acl_set_interface_t *mp;
15138 int sw_if_index_set;
15139 u32 ip4_table_index = ~0;
15140 u32 ip6_table_index = ~0;
15141 u32 l2_table_index = ~0;
15145 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15147 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15148 sw_if_index_set = 1;
15149 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15150 sw_if_index_set = 1;
15151 else if (unformat (i, "del"))
15153 else if (unformat (i, "ip4-table %d", &ip4_table_index))
15155 else if (unformat (i, "ip6-table %d", &ip6_table_index))
15157 else if (unformat (i, "l2-table %d", &l2_table_index))
15161 clib_warning ("parse error '%U'", format_unformat_error, i);
15166 if (sw_if_index_set == 0)
15168 errmsg ("missing interface name or sw_if_index");
15172 M (OUTPUT_ACL_SET_INTERFACE, mp);
15174 mp->sw_if_index = ntohl (sw_if_index);
15175 mp->ip4_table_index = ntohl (ip4_table_index);
15176 mp->ip6_table_index = ntohl (ip6_table_index);
15177 mp->l2_table_index = ntohl (l2_table_index);
15178 mp->is_add = is_add;
15186 api_ip_address_dump (vat_main_t * vam)
15188 unformat_input_t *i = vam->input;
15189 vl_api_ip_address_dump_t *mp;
15190 vl_api_control_ping_t *mp_ping;
15191 u32 sw_if_index = ~0;
15192 u8 sw_if_index_set = 0;
15197 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15199 if (unformat (i, "sw_if_index %d", &sw_if_index))
15200 sw_if_index_set = 1;
15202 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15203 sw_if_index_set = 1;
15204 else if (unformat (i, "ipv4"))
15206 else if (unformat (i, "ipv6"))
15212 if (ipv4_set && ipv6_set)
15214 errmsg ("ipv4 and ipv6 flags cannot be both set");
15218 if ((!ipv4_set) && (!ipv6_set))
15220 errmsg ("no ipv4 nor ipv6 flag set");
15224 if (sw_if_index_set == 0)
15226 errmsg ("missing interface name or sw_if_index");
15230 vam->current_sw_if_index = sw_if_index;
15231 vam->is_ipv6 = ipv6_set;
15233 M (IP_ADDRESS_DUMP, mp);
15234 mp->sw_if_index = ntohl (sw_if_index);
15235 mp->is_ipv6 = ipv6_set;
15238 /* Use a control ping for synchronization */
15239 MPING (CONTROL_PING, mp_ping);
15247 api_ip_dump (vat_main_t * vam)
15249 vl_api_ip_dump_t *mp;
15250 vl_api_control_ping_t *mp_ping;
15251 unformat_input_t *in = vam->input;
15258 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
15260 if (unformat (in, "ipv4"))
15262 else if (unformat (in, "ipv6"))
15268 if (ipv4_set && ipv6_set)
15270 errmsg ("ipv4 and ipv6 flags cannot be both set");
15274 if ((!ipv4_set) && (!ipv6_set))
15276 errmsg ("no ipv4 nor ipv6 flag set");
15280 is_ipv6 = ipv6_set;
15281 vam->is_ipv6 = is_ipv6;
15283 /* free old data */
15284 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
15286 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
15288 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
15291 mp->is_ipv6 = ipv6_set;
15294 /* Use a control ping for synchronization */
15295 MPING (CONTROL_PING, mp_ping);
15303 api_ipsec_spd_add_del (vat_main_t * vam)
15305 unformat_input_t *i = vam->input;
15306 vl_api_ipsec_spd_add_del_t *mp;
15311 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15313 if (unformat (i, "spd_id %d", &spd_id))
15315 else if (unformat (i, "del"))
15319 clib_warning ("parse error '%U'", format_unformat_error, i);
15325 errmsg ("spd_id must be set");
15329 M (IPSEC_SPD_ADD_DEL, mp);
15331 mp->spd_id = ntohl (spd_id);
15332 mp->is_add = is_add;
15340 api_ipsec_interface_add_del_spd (vat_main_t * vam)
15342 unformat_input_t *i = vam->input;
15343 vl_api_ipsec_interface_add_del_spd_t *mp;
15345 u8 sw_if_index_set = 0;
15346 u32 spd_id = (u32) ~ 0;
15350 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15352 if (unformat (i, "del"))
15354 else if (unformat (i, "spd_id %d", &spd_id))
15357 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15358 sw_if_index_set = 1;
15359 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15360 sw_if_index_set = 1;
15363 clib_warning ("parse error '%U'", format_unformat_error, i);
15369 if (spd_id == (u32) ~ 0)
15371 errmsg ("spd_id must be set");
15375 if (sw_if_index_set == 0)
15377 errmsg ("missing interface name or sw_if_index");
15381 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
15383 mp->spd_id = ntohl (spd_id);
15384 mp->sw_if_index = ntohl (sw_if_index);
15385 mp->is_add = is_add;
15393 api_ipsec_spd_add_del_entry (vat_main_t * vam)
15395 unformat_input_t *i = vam->input;
15396 vl_api_ipsec_spd_add_del_entry_t *mp;
15397 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
15398 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
15400 u32 rport_start = 0, rport_stop = (u32) ~ 0;
15401 u32 lport_start = 0, lport_stop = (u32) ~ 0;
15402 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
15403 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
15406 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
15407 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
15408 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
15409 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
15410 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
15411 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
15413 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15415 if (unformat (i, "del"))
15417 if (unformat (i, "outbound"))
15419 if (unformat (i, "inbound"))
15421 else if (unformat (i, "spd_id %d", &spd_id))
15423 else if (unformat (i, "sa_id %d", &sa_id))
15425 else if (unformat (i, "priority %d", &priority))
15427 else if (unformat (i, "protocol %d", &protocol))
15429 else if (unformat (i, "lport_start %d", &lport_start))
15431 else if (unformat (i, "lport_stop %d", &lport_stop))
15433 else if (unformat (i, "rport_start %d", &rport_start))
15435 else if (unformat (i, "rport_stop %d", &rport_stop))
15439 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
15445 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
15452 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
15458 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
15465 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
15471 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
15478 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
15484 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
15490 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
15492 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
15494 clib_warning ("unsupported action: 'resolve'");
15500 clib_warning ("parse error '%U'", format_unformat_error, i);
15506 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
15508 mp->spd_id = ntohl (spd_id);
15509 mp->priority = ntohl (priority);
15510 mp->is_outbound = is_outbound;
15512 mp->is_ipv6 = is_ipv6;
15513 if (is_ipv6 || is_ip_any)
15515 clib_memcpy (mp->remote_address_start, &raddr6_start,
15516 sizeof (ip6_address_t));
15517 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
15518 sizeof (ip6_address_t));
15519 clib_memcpy (mp->local_address_start, &laddr6_start,
15520 sizeof (ip6_address_t));
15521 clib_memcpy (mp->local_address_stop, &laddr6_stop,
15522 sizeof (ip6_address_t));
15526 clib_memcpy (mp->remote_address_start, &raddr4_start,
15527 sizeof (ip4_address_t));
15528 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
15529 sizeof (ip4_address_t));
15530 clib_memcpy (mp->local_address_start, &laddr4_start,
15531 sizeof (ip4_address_t));
15532 clib_memcpy (mp->local_address_stop, &laddr4_stop,
15533 sizeof (ip4_address_t));
15535 mp->protocol = (u8) protocol;
15536 mp->local_port_start = ntohs ((u16) lport_start);
15537 mp->local_port_stop = ntohs ((u16) lport_stop);
15538 mp->remote_port_start = ntohs ((u16) rport_start);
15539 mp->remote_port_stop = ntohs ((u16) rport_stop);
15540 mp->policy = (u8) policy;
15541 mp->sa_id = ntohl (sa_id);
15542 mp->is_add = is_add;
15543 mp->is_ip_any = is_ip_any;
15550 api_ipsec_sad_add_del_entry (vat_main_t * vam)
15552 unformat_input_t *i = vam->input;
15553 vl_api_ipsec_sad_add_del_entry_t *mp;
15554 u32 sad_id = 0, spi = 0;
15555 u8 *ck = 0, *ik = 0;
15558 u8 protocol = IPSEC_PROTOCOL_AH;
15559 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
15560 u32 crypto_alg = 0, integ_alg = 0;
15561 ip4_address_t tun_src4;
15562 ip4_address_t tun_dst4;
15563 ip6_address_t tun_src6;
15564 ip6_address_t tun_dst6;
15567 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15569 if (unformat (i, "del"))
15571 else if (unformat (i, "sad_id %d", &sad_id))
15573 else if (unformat (i, "spi %d", &spi))
15575 else if (unformat (i, "esp"))
15576 protocol = IPSEC_PROTOCOL_ESP;
15577 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
15580 is_tunnel_ipv6 = 0;
15582 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
15585 is_tunnel_ipv6 = 0;
15587 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
15590 is_tunnel_ipv6 = 1;
15592 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
15595 is_tunnel_ipv6 = 1;
15599 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15601 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
15603 clib_warning ("unsupported crypto-alg: '%U'",
15604 format_ipsec_crypto_alg, crypto_alg);
15608 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15612 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15614 if (integ_alg >= IPSEC_INTEG_N_ALG)
15616 clib_warning ("unsupported integ-alg: '%U'",
15617 format_ipsec_integ_alg, integ_alg);
15621 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15625 clib_warning ("parse error '%U'", format_unformat_error, i);
15631 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
15633 mp->sad_id = ntohl (sad_id);
15634 mp->is_add = is_add;
15635 mp->protocol = protocol;
15636 mp->spi = ntohl (spi);
15637 mp->is_tunnel = is_tunnel;
15638 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
15639 mp->crypto_algorithm = crypto_alg;
15640 mp->integrity_algorithm = integ_alg;
15641 mp->crypto_key_length = vec_len (ck);
15642 mp->integrity_key_length = vec_len (ik);
15644 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15645 mp->crypto_key_length = sizeof (mp->crypto_key);
15647 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15648 mp->integrity_key_length = sizeof (mp->integrity_key);
15651 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15653 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15657 if (is_tunnel_ipv6)
15659 clib_memcpy (mp->tunnel_src_address, &tun_src6,
15660 sizeof (ip6_address_t));
15661 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
15662 sizeof (ip6_address_t));
15666 clib_memcpy (mp->tunnel_src_address, &tun_src4,
15667 sizeof (ip4_address_t));
15668 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
15669 sizeof (ip4_address_t));
15679 api_ipsec_sa_set_key (vat_main_t * vam)
15681 unformat_input_t *i = vam->input;
15682 vl_api_ipsec_sa_set_key_t *mp;
15684 u8 *ck = 0, *ik = 0;
15687 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15689 if (unformat (i, "sa_id %d", &sa_id))
15691 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15693 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15697 clib_warning ("parse error '%U'", format_unformat_error, i);
15702 M (IPSEC_SA_SET_KEY, mp);
15704 mp->sa_id = ntohl (sa_id);
15705 mp->crypto_key_length = vec_len (ck);
15706 mp->integrity_key_length = vec_len (ik);
15708 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15709 mp->crypto_key_length = sizeof (mp->crypto_key);
15711 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15712 mp->integrity_key_length = sizeof (mp->integrity_key);
15715 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15717 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15725 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
15727 unformat_input_t *i = vam->input;
15728 vl_api_ipsec_tunnel_if_add_del_t *mp;
15729 u32 local_spi = 0, remote_spi = 0;
15730 u32 crypto_alg = 0, integ_alg = 0;
15731 u8 *lck = NULL, *rck = NULL;
15732 u8 *lik = NULL, *rik = NULL;
15733 ip4_address_t local_ip = { {0} };
15734 ip4_address_t remote_ip = { {0} };
15737 u8 anti_replay = 0;
15742 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15744 if (unformat (i, "del"))
15746 else if (unformat (i, "esn"))
15748 else if (unformat (i, "anti_replay"))
15750 else if (unformat (i, "local_spi %d", &local_spi))
15752 else if (unformat (i, "remote_spi %d", &remote_spi))
15754 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
15756 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
15758 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
15761 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
15763 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
15765 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
15769 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15771 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
15773 errmsg ("unsupported crypto-alg: '%U'\n",
15774 format_ipsec_crypto_alg, crypto_alg);
15780 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15782 if (integ_alg >= IPSEC_INTEG_N_ALG)
15784 errmsg ("unsupported integ-alg: '%U'\n",
15785 format_ipsec_integ_alg, integ_alg);
15789 else if (unformat (i, "instance %u", &instance))
15793 errmsg ("parse error '%U'\n", format_unformat_error, i);
15798 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
15800 mp->is_add = is_add;
15802 mp->anti_replay = anti_replay;
15804 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
15805 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
15807 mp->local_spi = htonl (local_spi);
15808 mp->remote_spi = htonl (remote_spi);
15809 mp->crypto_alg = (u8) crypto_alg;
15811 mp->local_crypto_key_len = 0;
15814 mp->local_crypto_key_len = vec_len (lck);
15815 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
15816 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
15817 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
15820 mp->remote_crypto_key_len = 0;
15823 mp->remote_crypto_key_len = vec_len (rck);
15824 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
15825 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
15826 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
15829 mp->integ_alg = (u8) integ_alg;
15831 mp->local_integ_key_len = 0;
15834 mp->local_integ_key_len = vec_len (lik);
15835 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
15836 mp->local_integ_key_len = sizeof (mp->local_integ_key);
15837 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
15840 mp->remote_integ_key_len = 0;
15843 mp->remote_integ_key_len = vec_len (rik);
15844 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
15845 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
15846 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
15851 mp->renumber = renumber;
15852 mp->show_instance = ntohl (instance);
15861 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
15863 vat_main_t *vam = &vat_main;
15865 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
15866 "crypto_key %U integ_alg %u integ_key %U use_esn %u "
15867 "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u "
15868 "tunnel_src_addr %U tunnel_dst_addr %U "
15869 "salt %u seq_outbound %lu last_seq_inbound %lu "
15870 "replay_window %lu total_data_size %lu\n",
15871 ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi),
15873 mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len,
15874 mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len,
15875 mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6,
15876 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15877 mp->tunnel_src_addr,
15878 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15879 mp->tunnel_dst_addr,
15881 clib_net_to_host_u64 (mp->seq_outbound),
15882 clib_net_to_host_u64 (mp->last_seq_inbound),
15883 clib_net_to_host_u64 (mp->replay_window),
15884 clib_net_to_host_u64 (mp->total_data_size));
15887 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
15888 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
15890 static void vl_api_ipsec_sa_details_t_handler_json
15891 (vl_api_ipsec_sa_details_t * mp)
15893 vat_main_t *vam = &vat_main;
15894 vat_json_node_t *node = NULL;
15895 struct in_addr src_ip4, dst_ip4;
15896 struct in6_addr src_ip6, dst_ip6;
15898 if (VAT_JSON_ARRAY != vam->json_tree.type)
15900 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15901 vat_json_init_array (&vam->json_tree);
15903 node = vat_json_array_add (&vam->json_tree);
15905 vat_json_init_object (node);
15906 vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id));
15907 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
15908 vat_json_object_add_uint (node, "spi", ntohl (mp->spi));
15909 vat_json_object_add_uint (node, "proto", mp->protocol);
15910 vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg);
15911 vat_json_object_add_uint (node, "integ_alg", mp->integ_alg);
15912 vat_json_object_add_uint (node, "use_esn", mp->use_esn);
15913 vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay);
15914 vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel);
15915 vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6);
15916 vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key,
15917 mp->crypto_key_len);
15918 vat_json_object_add_bytes (node, "integ_key", mp->integ_key,
15919 mp->integ_key_len);
15920 if (mp->is_tunnel_ip6)
15922 clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6));
15923 vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6);
15924 clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6));
15925 vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6);
15929 clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4));
15930 vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4);
15931 clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4));
15932 vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4);
15934 vat_json_object_add_uint (node, "replay_window",
15935 clib_net_to_host_u64 (mp->replay_window));
15936 vat_json_object_add_uint (node, "total_data_size",
15937 clib_net_to_host_u64 (mp->total_data_size));
15942 api_ipsec_sa_dump (vat_main_t * vam)
15944 unformat_input_t *i = vam->input;
15945 vl_api_ipsec_sa_dump_t *mp;
15946 vl_api_control_ping_t *mp_ping;
15950 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15952 if (unformat (i, "sa_id %d", &sa_id))
15956 clib_warning ("parse error '%U'", format_unformat_error, i);
15961 M (IPSEC_SA_DUMP, mp);
15963 mp->sa_id = ntohl (sa_id);
15967 /* Use a control ping for synchronization */
15968 M (CONTROL_PING, mp_ping);
15976 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
15978 unformat_input_t *i = vam->input;
15979 vl_api_ipsec_tunnel_if_set_key_t *mp;
15980 u32 sw_if_index = ~0;
15981 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
15986 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15988 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15991 if (unformat (i, "local crypto %U", unformat_ipsec_crypto_alg, &alg))
15992 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
15994 if (unformat (i, "remote crypto %U", unformat_ipsec_crypto_alg, &alg))
15995 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
15996 else if (unformat (i, "local integ %U", unformat_ipsec_integ_alg, &alg))
15997 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
15999 if (unformat (i, "remote integ %U", unformat_ipsec_integ_alg, &alg))
16000 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
16001 else if (unformat (i, "%U", unformat_hex_string, &key))
16005 clib_warning ("parse error '%U'", format_unformat_error, i);
16010 if (sw_if_index == ~0)
16012 errmsg ("interface must be specified");
16016 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
16018 errmsg ("key type must be specified");
16024 errmsg ("algorithm must be specified");
16028 if (vec_len (key) == 0)
16030 errmsg ("key must be specified");
16034 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
16036 mp->sw_if_index = htonl (sw_if_index);
16038 mp->key_type = key_type;
16039 mp->key_len = vec_len (key);
16040 clib_memcpy (mp->key, key, vec_len (key));
16049 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
16051 unformat_input_t *i = vam->input;
16052 vl_api_ipsec_tunnel_if_set_sa_t *mp;
16053 u32 sw_if_index = ~0;
16055 u8 is_outbound = (u8) ~ 0;
16058 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16060 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16062 else if (unformat (i, "sa_id %d", &sa_id))
16064 else if (unformat (i, "outbound"))
16066 else if (unformat (i, "inbound"))
16070 clib_warning ("parse error '%U'", format_unformat_error, i);
16075 if (sw_if_index == ~0)
16077 errmsg ("interface must be specified");
16083 errmsg ("SA ID must be specified");
16087 M (IPSEC_TUNNEL_IF_SET_SA, mp);
16089 mp->sw_if_index = htonl (sw_if_index);
16090 mp->sa_id = htonl (sa_id);
16091 mp->is_outbound = is_outbound;
16100 api_ikev2_profile_add_del (vat_main_t * vam)
16102 unformat_input_t *i = vam->input;
16103 vl_api_ikev2_profile_add_del_t *mp;
16108 const char *valid_chars = "a-zA-Z0-9_";
16110 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16112 if (unformat (i, "del"))
16114 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
16115 vec_add1 (name, 0);
16118 errmsg ("parse error '%U'", format_unformat_error, i);
16123 if (!vec_len (name))
16125 errmsg ("profile name must be specified");
16129 if (vec_len (name) > 64)
16131 errmsg ("profile name too long");
16135 M (IKEV2_PROFILE_ADD_DEL, mp);
16137 clib_memcpy (mp->name, name, vec_len (name));
16138 mp->is_add = is_add;
16147 api_ikev2_profile_set_auth (vat_main_t * vam)
16149 unformat_input_t *i = vam->input;
16150 vl_api_ikev2_profile_set_auth_t *mp;
16153 u32 auth_method = 0;
16157 const char *valid_chars = "a-zA-Z0-9_";
16159 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16161 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
16162 vec_add1 (name, 0);
16163 else if (unformat (i, "auth_method %U",
16164 unformat_ikev2_auth_method, &auth_method))
16166 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
16168 else if (unformat (i, "auth_data %v", &data))
16172 errmsg ("parse error '%U'", format_unformat_error, i);
16177 if (!vec_len (name))
16179 errmsg ("profile name must be specified");
16183 if (vec_len (name) > 64)
16185 errmsg ("profile name too long");
16189 if (!vec_len (data))
16191 errmsg ("auth_data must be specified");
16197 errmsg ("auth_method must be specified");
16201 M (IKEV2_PROFILE_SET_AUTH, mp);
16203 mp->is_hex = is_hex;
16204 mp->auth_method = (u8) auth_method;
16205 mp->data_len = vec_len (data);
16206 clib_memcpy (mp->name, name, vec_len (name));
16207 clib_memcpy (mp->data, data, vec_len (data));
16217 api_ikev2_profile_set_id (vat_main_t * vam)
16219 unformat_input_t *i = vam->input;
16220 vl_api_ikev2_profile_set_id_t *mp;
16228 const char *valid_chars = "a-zA-Z0-9_";
16230 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16232 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
16233 vec_add1 (name, 0);
16234 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
16236 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
16238 data = vec_new (u8, 4);
16239 clib_memcpy (data, ip4.as_u8, 4);
16241 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
16243 else if (unformat (i, "id_data %v", &data))
16245 else if (unformat (i, "local"))
16247 else if (unformat (i, "remote"))
16251 errmsg ("parse error '%U'", format_unformat_error, i);
16256 if (!vec_len (name))
16258 errmsg ("profile name must be specified");
16262 if (vec_len (name) > 64)
16264 errmsg ("profile name too long");
16268 if (!vec_len (data))
16270 errmsg ("id_data must be specified");
16276 errmsg ("id_type must be specified");
16280 M (IKEV2_PROFILE_SET_ID, mp);
16282 mp->is_local = is_local;
16283 mp->id_type = (u8) id_type;
16284 mp->data_len = vec_len (data);
16285 clib_memcpy (mp->name, name, vec_len (name));
16286 clib_memcpy (mp->data, data, vec_len (data));
16296 api_ikev2_profile_set_ts (vat_main_t * vam)
16298 unformat_input_t *i = vam->input;
16299 vl_api_ikev2_profile_set_ts_t *mp;
16302 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
16303 ip4_address_t start_addr, end_addr;
16305 const char *valid_chars = "a-zA-Z0-9_";
16308 start_addr.as_u32 = 0;
16309 end_addr.as_u32 = (u32) ~ 0;
16311 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16313 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
16314 vec_add1 (name, 0);
16315 else if (unformat (i, "protocol %d", &proto))
16317 else if (unformat (i, "start_port %d", &start_port))
16319 else if (unformat (i, "end_port %d", &end_port))
16322 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
16324 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
16326 else if (unformat (i, "local"))
16328 else if (unformat (i, "remote"))
16332 errmsg ("parse error '%U'", format_unformat_error, i);
16337 if (!vec_len (name))
16339 errmsg ("profile name must be specified");
16343 if (vec_len (name) > 64)
16345 errmsg ("profile name too long");
16349 M (IKEV2_PROFILE_SET_TS, mp);
16351 mp->is_local = is_local;
16352 mp->proto = (u8) proto;
16353 mp->start_port = (u16) start_port;
16354 mp->end_port = (u16) end_port;
16355 mp->start_addr = start_addr.as_u32;
16356 mp->end_addr = end_addr.as_u32;
16357 clib_memcpy (mp->name, name, vec_len (name));
16366 api_ikev2_set_local_key (vat_main_t * vam)
16368 unformat_input_t *i = vam->input;
16369 vl_api_ikev2_set_local_key_t *mp;
16373 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16375 if (unformat (i, "file %v", &file))
16376 vec_add1 (file, 0);
16379 errmsg ("parse error '%U'", format_unformat_error, i);
16384 if (!vec_len (file))
16386 errmsg ("RSA key file must be specified");
16390 if (vec_len (file) > 256)
16392 errmsg ("file name too long");
16396 M (IKEV2_SET_LOCAL_KEY, mp);
16398 clib_memcpy (mp->key_file, file, vec_len (file));
16407 api_ikev2_set_responder (vat_main_t * vam)
16409 unformat_input_t *i = vam->input;
16410 vl_api_ikev2_set_responder_t *mp;
16413 u32 sw_if_index = ~0;
16414 ip4_address_t address;
16416 const char *valid_chars = "a-zA-Z0-9_";
16418 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16421 (i, "%U interface %d address %U", unformat_token, valid_chars,
16422 &name, &sw_if_index, unformat_ip4_address, &address))
16423 vec_add1 (name, 0);
16426 errmsg ("parse error '%U'", format_unformat_error, i);
16431 if (!vec_len (name))
16433 errmsg ("profile name must be specified");
16437 if (vec_len (name) > 64)
16439 errmsg ("profile name too long");
16443 M (IKEV2_SET_RESPONDER, mp);
16445 clib_memcpy (mp->name, name, vec_len (name));
16448 mp->sw_if_index = sw_if_index;
16449 clib_memcpy (mp->address, &address, sizeof (address));
16457 api_ikev2_set_ike_transforms (vat_main_t * vam)
16459 unformat_input_t *i = vam->input;
16460 vl_api_ikev2_set_ike_transforms_t *mp;
16463 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
16465 const char *valid_chars = "a-zA-Z0-9_";
16467 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16469 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
16470 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
16471 vec_add1 (name, 0);
16474 errmsg ("parse error '%U'", format_unformat_error, i);
16479 if (!vec_len (name))
16481 errmsg ("profile name must be specified");
16485 if (vec_len (name) > 64)
16487 errmsg ("profile name too long");
16491 M (IKEV2_SET_IKE_TRANSFORMS, mp);
16493 clib_memcpy (mp->name, name, vec_len (name));
16495 mp->crypto_alg = crypto_alg;
16496 mp->crypto_key_size = crypto_key_size;
16497 mp->integ_alg = integ_alg;
16498 mp->dh_group = dh_group;
16507 api_ikev2_set_esp_transforms (vat_main_t * vam)
16509 unformat_input_t *i = vam->input;
16510 vl_api_ikev2_set_esp_transforms_t *mp;
16513 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
16515 const char *valid_chars = "a-zA-Z0-9_";
16517 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16519 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
16520 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
16521 vec_add1 (name, 0);
16524 errmsg ("parse error '%U'", format_unformat_error, i);
16529 if (!vec_len (name))
16531 errmsg ("profile name must be specified");
16535 if (vec_len (name) > 64)
16537 errmsg ("profile name too long");
16541 M (IKEV2_SET_ESP_TRANSFORMS, mp);
16543 clib_memcpy (mp->name, name, vec_len (name));
16545 mp->crypto_alg = crypto_alg;
16546 mp->crypto_key_size = crypto_key_size;
16547 mp->integ_alg = integ_alg;
16548 mp->dh_group = dh_group;
16556 api_ikev2_set_sa_lifetime (vat_main_t * vam)
16558 unformat_input_t *i = vam->input;
16559 vl_api_ikev2_set_sa_lifetime_t *mp;
16562 u64 lifetime, lifetime_maxdata;
16563 u32 lifetime_jitter, handover;
16565 const char *valid_chars = "a-zA-Z0-9_";
16567 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16569 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
16570 &lifetime, &lifetime_jitter, &handover,
16571 &lifetime_maxdata))
16572 vec_add1 (name, 0);
16575 errmsg ("parse error '%U'", format_unformat_error, i);
16580 if (!vec_len (name))
16582 errmsg ("profile name must be specified");
16586 if (vec_len (name) > 64)
16588 errmsg ("profile name too long");
16592 M (IKEV2_SET_SA_LIFETIME, mp);
16594 clib_memcpy (mp->name, name, vec_len (name));
16596 mp->lifetime = lifetime;
16597 mp->lifetime_jitter = lifetime_jitter;
16598 mp->handover = handover;
16599 mp->lifetime_maxdata = lifetime_maxdata;
16607 api_ikev2_initiate_sa_init (vat_main_t * vam)
16609 unformat_input_t *i = vam->input;
16610 vl_api_ikev2_initiate_sa_init_t *mp;
16614 const char *valid_chars = "a-zA-Z0-9_";
16616 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16618 if (unformat (i, "%U", unformat_token, valid_chars, &name))
16619 vec_add1 (name, 0);
16622 errmsg ("parse error '%U'", format_unformat_error, i);
16627 if (!vec_len (name))
16629 errmsg ("profile name must be specified");
16633 if (vec_len (name) > 64)
16635 errmsg ("profile name too long");
16639 M (IKEV2_INITIATE_SA_INIT, mp);
16641 clib_memcpy (mp->name, name, vec_len (name));
16650 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
16652 unformat_input_t *i = vam->input;
16653 vl_api_ikev2_initiate_del_ike_sa_t *mp;
16658 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16660 if (unformat (i, "%lx", &ispi))
16664 errmsg ("parse error '%U'", format_unformat_error, i);
16669 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
16679 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
16681 unformat_input_t *i = vam->input;
16682 vl_api_ikev2_initiate_del_child_sa_t *mp;
16687 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16689 if (unformat (i, "%x", &ispi))
16693 errmsg ("parse error '%U'", format_unformat_error, i);
16698 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
16708 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
16710 unformat_input_t *i = vam->input;
16711 vl_api_ikev2_initiate_rekey_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_REKEY_CHILD_SA, mp);
16737 api_get_first_msg_id (vat_main_t * vam)
16739 vl_api_get_first_msg_id_t *mp;
16740 unformat_input_t *i = vam->input;
16745 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16747 if (unformat (i, "client %s", &name))
16755 errmsg ("missing client name");
16758 vec_add1 (name, 0);
16760 if (vec_len (name) > 63)
16762 errmsg ("client name too long");
16766 M (GET_FIRST_MSG_ID, mp);
16767 clib_memcpy (mp->name, name, vec_len (name));
16774 api_cop_interface_enable_disable (vat_main_t * vam)
16776 unformat_input_t *line_input = vam->input;
16777 vl_api_cop_interface_enable_disable_t *mp;
16778 u32 sw_if_index = ~0;
16779 u8 enable_disable = 1;
16782 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16784 if (unformat (line_input, "disable"))
16785 enable_disable = 0;
16786 if (unformat (line_input, "enable"))
16787 enable_disable = 1;
16788 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16789 vam, &sw_if_index))
16791 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16797 if (sw_if_index == ~0)
16799 errmsg ("missing interface name or sw_if_index");
16803 /* Construct the API message */
16804 M (COP_INTERFACE_ENABLE_DISABLE, mp);
16805 mp->sw_if_index = ntohl (sw_if_index);
16806 mp->enable_disable = enable_disable;
16810 /* Wait for the reply */
16816 api_cop_whitelist_enable_disable (vat_main_t * vam)
16818 unformat_input_t *line_input = vam->input;
16819 vl_api_cop_whitelist_enable_disable_t *mp;
16820 u32 sw_if_index = ~0;
16821 u8 ip4 = 0, ip6 = 0, default_cop = 0;
16825 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16827 if (unformat (line_input, "ip4"))
16829 else if (unformat (line_input, "ip6"))
16831 else if (unformat (line_input, "default"))
16833 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16834 vam, &sw_if_index))
16836 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16838 else if (unformat (line_input, "fib-id %d", &fib_id))
16844 if (sw_if_index == ~0)
16846 errmsg ("missing interface name or sw_if_index");
16850 /* Construct the API message */
16851 M (COP_WHITELIST_ENABLE_DISABLE, mp);
16852 mp->sw_if_index = ntohl (sw_if_index);
16853 mp->fib_id = ntohl (fib_id);
16856 mp->default_cop = default_cop;
16860 /* Wait for the reply */
16866 api_get_node_graph (vat_main_t * vam)
16868 vl_api_get_node_graph_t *mp;
16871 M (GET_NODE_GRAPH, mp);
16875 /* Wait for the reply */
16881 /** Used for parsing LISP eids */
16882 typedef CLIB_PACKED(struct{
16883 u8 addr[16]; /**< eid address */
16884 u32 len; /**< prefix length if IP */
16885 u8 type; /**< type of eid */
16890 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
16892 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
16894 memset (a, 0, sizeof (a[0]));
16896 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
16898 a->type = 0; /* ipv4 type */
16900 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
16902 a->type = 1; /* ipv6 type */
16904 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
16906 a->type = 2; /* mac type */
16908 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
16910 a->type = 3; /* NSH type */
16911 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
16912 nsh->spi = clib_host_to_net_u32 (nsh->spi);
16919 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
16928 lisp_eid_size_vat (u8 type)
16945 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
16947 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
16951 api_one_add_del_locator_set (vat_main_t * vam)
16953 unformat_input_t *input = vam->input;
16954 vl_api_one_add_del_locator_set_t *mp;
16956 u8 *locator_set_name = NULL;
16957 u8 locator_set_name_set = 0;
16958 vl_api_local_locator_t locator, *locators = 0;
16959 u32 sw_if_index, priority, weight;
16963 /* Parse args required to build the message */
16964 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16966 if (unformat (input, "del"))
16970 else if (unformat (input, "locator-set %s", &locator_set_name))
16972 locator_set_name_set = 1;
16974 else if (unformat (input, "sw_if_index %u p %u w %u",
16975 &sw_if_index, &priority, &weight))
16977 locator.sw_if_index = htonl (sw_if_index);
16978 locator.priority = priority;
16979 locator.weight = weight;
16980 vec_add1 (locators, locator);
16984 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
16985 &sw_if_index, &priority, &weight))
16987 locator.sw_if_index = htonl (sw_if_index);
16988 locator.priority = priority;
16989 locator.weight = weight;
16990 vec_add1 (locators, locator);
16996 if (locator_set_name_set == 0)
16998 errmsg ("missing locator-set name");
16999 vec_free (locators);
17003 if (vec_len (locator_set_name) > 64)
17005 errmsg ("locator-set name too long");
17006 vec_free (locator_set_name);
17007 vec_free (locators);
17010 vec_add1 (locator_set_name, 0);
17012 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
17014 /* Construct the API message */
17015 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
17017 mp->is_add = is_add;
17018 clib_memcpy (mp->locator_set_name, locator_set_name,
17019 vec_len (locator_set_name));
17020 vec_free (locator_set_name);
17022 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
17024 clib_memcpy (mp->locators, locators, data_len);
17025 vec_free (locators);
17030 /* Wait for a reply... */
17035 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
17038 api_one_add_del_locator (vat_main_t * vam)
17040 unformat_input_t *input = vam->input;
17041 vl_api_one_add_del_locator_t *mp;
17042 u32 tmp_if_index = ~0;
17043 u32 sw_if_index = ~0;
17044 u8 sw_if_index_set = 0;
17045 u8 sw_if_index_if_name_set = 0;
17047 u8 priority_set = 0;
17051 u8 *locator_set_name = NULL;
17052 u8 locator_set_name_set = 0;
17055 /* Parse args required to build the message */
17056 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17058 if (unformat (input, "del"))
17062 else if (unformat (input, "locator-set %s", &locator_set_name))
17064 locator_set_name_set = 1;
17066 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
17069 sw_if_index_if_name_set = 1;
17070 sw_if_index = tmp_if_index;
17072 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
17074 sw_if_index_set = 1;
17075 sw_if_index = tmp_if_index;
17077 else if (unformat (input, "p %d", &priority))
17081 else if (unformat (input, "w %d", &weight))
17089 if (locator_set_name_set == 0)
17091 errmsg ("missing locator-set name");
17095 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
17097 errmsg ("missing sw_if_index");
17098 vec_free (locator_set_name);
17102 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
17104 errmsg ("cannot use both params interface name and sw_if_index");
17105 vec_free (locator_set_name);
17109 if (priority_set == 0)
17111 errmsg ("missing locator-set priority");
17112 vec_free (locator_set_name);
17116 if (weight_set == 0)
17118 errmsg ("missing locator-set weight");
17119 vec_free (locator_set_name);
17123 if (vec_len (locator_set_name) > 64)
17125 errmsg ("locator-set name too long");
17126 vec_free (locator_set_name);
17129 vec_add1 (locator_set_name, 0);
17131 /* Construct the API message */
17132 M (ONE_ADD_DEL_LOCATOR, mp);
17134 mp->is_add = is_add;
17135 mp->sw_if_index = ntohl (sw_if_index);
17136 mp->priority = priority;
17137 mp->weight = weight;
17138 clib_memcpy (mp->locator_set_name, locator_set_name,
17139 vec_len (locator_set_name));
17140 vec_free (locator_set_name);
17145 /* Wait for a reply... */
17150 #define api_lisp_add_del_locator api_one_add_del_locator
17153 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
17155 u32 *key_id = va_arg (*args, u32 *);
17158 if (unformat (input, "%s", &s))
17160 if (!strcmp ((char *) s, "sha1"))
17161 key_id[0] = HMAC_SHA_1_96;
17162 else if (!strcmp ((char *) s, "sha256"))
17163 key_id[0] = HMAC_SHA_256_128;
17166 clib_warning ("invalid key_id: '%s'", s);
17167 key_id[0] = HMAC_NO_KEY;
17178 api_one_add_del_local_eid (vat_main_t * vam)
17180 unformat_input_t *input = vam->input;
17181 vl_api_one_add_del_local_eid_t *mp;
17184 lisp_eid_vat_t _eid, *eid = &_eid;
17185 u8 *locator_set_name = 0;
17186 u8 locator_set_name_set = 0;
17192 /* Parse args required to build the message */
17193 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17195 if (unformat (input, "del"))
17199 else if (unformat (input, "vni %d", &vni))
17203 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
17207 else if (unformat (input, "locator-set %s", &locator_set_name))
17209 locator_set_name_set = 1;
17211 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
17213 else if (unformat (input, "secret-key %_%v%_", &key))
17219 if (locator_set_name_set == 0)
17221 errmsg ("missing locator-set name");
17227 errmsg ("EID address not set!");
17228 vec_free (locator_set_name);
17232 if (key && (0 == key_id))
17234 errmsg ("invalid key_id!");
17238 if (vec_len (key) > 64)
17240 errmsg ("key too long");
17245 if (vec_len (locator_set_name) > 64)
17247 errmsg ("locator-set name too long");
17248 vec_free (locator_set_name);
17251 vec_add1 (locator_set_name, 0);
17253 /* Construct the API message */
17254 M (ONE_ADD_DEL_LOCAL_EID, mp);
17256 mp->is_add = is_add;
17257 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
17258 mp->eid_type = eid->type;
17259 mp->prefix_len = eid->len;
17260 mp->vni = clib_host_to_net_u32 (vni);
17261 mp->key_id = clib_host_to_net_u16 (key_id);
17262 clib_memcpy (mp->locator_set_name, locator_set_name,
17263 vec_len (locator_set_name));
17264 clib_memcpy (mp->key, key, vec_len (key));
17266 vec_free (locator_set_name);
17272 /* Wait for a reply... */
17277 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
17280 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
17282 u32 dp_table = 0, vni = 0;;
17283 unformat_input_t *input = vam->input;
17284 vl_api_gpe_add_del_fwd_entry_t *mp;
17286 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
17287 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
17288 u8 rmt_eid_set = 0, lcl_eid_set = 0;
17289 u32 action = ~0, w;
17290 ip4_address_t rmt_rloc4, lcl_rloc4;
17291 ip6_address_t rmt_rloc6, lcl_rloc6;
17292 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
17295 memset (&rloc, 0, sizeof (rloc));
17297 /* Parse args required to build the message */
17298 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17300 if (unformat (input, "del"))
17302 else if (unformat (input, "add"))
17304 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
17308 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
17312 else if (unformat (input, "vrf %d", &dp_table))
17314 else if (unformat (input, "bd %d", &dp_table))
17316 else if (unformat (input, "vni %d", &vni))
17318 else if (unformat (input, "w %d", &w))
17322 errmsg ("No RLOC configured for setting priority/weight!");
17325 curr_rloc->weight = w;
17327 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
17328 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
17332 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
17334 vec_add1 (lcl_locs, rloc);
17336 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
17337 vec_add1 (rmt_locs, rloc);
17338 /* weight saved in rmt loc */
17339 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
17341 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
17342 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
17345 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
17347 vec_add1 (lcl_locs, rloc);
17349 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
17350 vec_add1 (rmt_locs, rloc);
17351 /* weight saved in rmt loc */
17352 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
17354 else if (unformat (input, "action %d", &action))
17360 clib_warning ("parse error '%U'", format_unformat_error, input);
17367 errmsg ("remote eid addresses not set");
17371 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
17373 errmsg ("eid types don't match");
17377 if (0 == rmt_locs && (u32) ~ 0 == action)
17379 errmsg ("action not set for negative mapping");
17383 /* Construct the API message */
17384 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
17385 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
17387 mp->is_add = is_add;
17388 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
17389 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
17390 mp->eid_type = rmt_eid->type;
17391 mp->dp_table = clib_host_to_net_u32 (dp_table);
17392 mp->vni = clib_host_to_net_u32 (vni);
17393 mp->rmt_len = rmt_eid->len;
17394 mp->lcl_len = lcl_eid->len;
17395 mp->action = action;
17397 if (0 != rmt_locs && 0 != lcl_locs)
17399 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
17400 clib_memcpy (mp->locs, lcl_locs,
17401 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
17403 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
17404 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
17405 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
17407 vec_free (lcl_locs);
17408 vec_free (rmt_locs);
17413 /* Wait for a reply... */
17419 api_one_add_del_map_server (vat_main_t * vam)
17421 unformat_input_t *input = vam->input;
17422 vl_api_one_add_del_map_server_t *mp;
17426 ip4_address_t ipv4;
17427 ip6_address_t ipv6;
17430 /* Parse args required to build the message */
17431 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17433 if (unformat (input, "del"))
17437 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17441 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17449 if (ipv4_set && ipv6_set)
17451 errmsg ("both eid v4 and v6 addresses set");
17455 if (!ipv4_set && !ipv6_set)
17457 errmsg ("eid addresses not set");
17461 /* Construct the API message */
17462 M (ONE_ADD_DEL_MAP_SERVER, mp);
17464 mp->is_add = is_add;
17468 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17473 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17479 /* Wait for a reply... */
17484 #define api_lisp_add_del_map_server api_one_add_del_map_server
17487 api_one_add_del_map_resolver (vat_main_t * vam)
17489 unformat_input_t *input = vam->input;
17490 vl_api_one_add_del_map_resolver_t *mp;
17494 ip4_address_t ipv4;
17495 ip6_address_t ipv6;
17498 /* Parse args required to build the message */
17499 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17501 if (unformat (input, "del"))
17505 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17509 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17517 if (ipv4_set && ipv6_set)
17519 errmsg ("both eid v4 and v6 addresses set");
17523 if (!ipv4_set && !ipv6_set)
17525 errmsg ("eid addresses not set");
17529 /* Construct the API message */
17530 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
17532 mp->is_add = is_add;
17536 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17541 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17547 /* Wait for a reply... */
17552 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
17555 api_lisp_gpe_enable_disable (vat_main_t * vam)
17557 unformat_input_t *input = vam->input;
17558 vl_api_gpe_enable_disable_t *mp;
17563 /* Parse args required to build the message */
17564 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17566 if (unformat (input, "enable"))
17571 else if (unformat (input, "disable"))
17582 errmsg ("Value not set");
17586 /* Construct the API message */
17587 M (GPE_ENABLE_DISABLE, mp);
17594 /* Wait for a reply... */
17600 api_one_rloc_probe_enable_disable (vat_main_t * vam)
17602 unformat_input_t *input = vam->input;
17603 vl_api_one_rloc_probe_enable_disable_t *mp;
17608 /* Parse args required to build the message */
17609 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17611 if (unformat (input, "enable"))
17616 else if (unformat (input, "disable"))
17624 errmsg ("Value not set");
17628 /* Construct the API message */
17629 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
17631 mp->is_enabled = is_en;
17636 /* Wait for a reply... */
17641 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
17644 api_one_map_register_enable_disable (vat_main_t * vam)
17646 unformat_input_t *input = vam->input;
17647 vl_api_one_map_register_enable_disable_t *mp;
17652 /* Parse args required to build the message */
17653 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17655 if (unformat (input, "enable"))
17660 else if (unformat (input, "disable"))
17668 errmsg ("Value not set");
17672 /* Construct the API message */
17673 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
17675 mp->is_enabled = is_en;
17680 /* Wait for a reply... */
17685 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
17688 api_one_enable_disable (vat_main_t * vam)
17690 unformat_input_t *input = vam->input;
17691 vl_api_one_enable_disable_t *mp;
17696 /* Parse args required to build the message */
17697 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17699 if (unformat (input, "enable"))
17704 else if (unformat (input, "disable"))
17714 errmsg ("Value not set");
17718 /* Construct the API message */
17719 M (ONE_ENABLE_DISABLE, mp);
17726 /* Wait for a reply... */
17731 #define api_lisp_enable_disable api_one_enable_disable
17734 api_one_enable_disable_xtr_mode (vat_main_t * vam)
17736 unformat_input_t *input = vam->input;
17737 vl_api_one_enable_disable_xtr_mode_t *mp;
17742 /* Parse args required to build the message */
17743 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17745 if (unformat (input, "enable"))
17750 else if (unformat (input, "disable"))
17760 errmsg ("Value not set");
17764 /* Construct the API message */
17765 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
17772 /* Wait for a reply... */
17778 api_one_show_xtr_mode (vat_main_t * vam)
17780 vl_api_one_show_xtr_mode_t *mp;
17783 /* Construct the API message */
17784 M (ONE_SHOW_XTR_MODE, mp);
17789 /* Wait for a reply... */
17795 api_one_enable_disable_pitr_mode (vat_main_t * vam)
17797 unformat_input_t *input = vam->input;
17798 vl_api_one_enable_disable_pitr_mode_t *mp;
17803 /* Parse args required to build the message */
17804 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17806 if (unformat (input, "enable"))
17811 else if (unformat (input, "disable"))
17821 errmsg ("Value not set");
17825 /* Construct the API message */
17826 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
17833 /* Wait for a reply... */
17839 api_one_show_pitr_mode (vat_main_t * vam)
17841 vl_api_one_show_pitr_mode_t *mp;
17844 /* Construct the API message */
17845 M (ONE_SHOW_PITR_MODE, mp);
17850 /* Wait for a reply... */
17856 api_one_enable_disable_petr_mode (vat_main_t * vam)
17858 unformat_input_t *input = vam->input;
17859 vl_api_one_enable_disable_petr_mode_t *mp;
17864 /* Parse args required to build the message */
17865 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17867 if (unformat (input, "enable"))
17872 else if (unformat (input, "disable"))
17882 errmsg ("Value not set");
17886 /* Construct the API message */
17887 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
17894 /* Wait for a reply... */
17900 api_one_show_petr_mode (vat_main_t * vam)
17902 vl_api_one_show_petr_mode_t *mp;
17905 /* Construct the API message */
17906 M (ONE_SHOW_PETR_MODE, mp);
17911 /* Wait for a reply... */
17917 api_show_one_map_register_state (vat_main_t * vam)
17919 vl_api_show_one_map_register_state_t *mp;
17922 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
17927 /* wait for reply */
17932 #define api_show_lisp_map_register_state api_show_one_map_register_state
17935 api_show_one_rloc_probe_state (vat_main_t * vam)
17937 vl_api_show_one_rloc_probe_state_t *mp;
17940 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
17945 /* wait for reply */
17950 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
17953 api_one_add_del_ndp_entry (vat_main_t * vam)
17955 vl_api_one_add_del_ndp_entry_t *mp;
17956 unformat_input_t *input = vam->input;
17961 u8 mac[6] = { 0, };
17962 u8 ip6[16] = { 0, };
17966 /* Parse args required to build the message */
17967 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17969 if (unformat (input, "del"))
17971 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17973 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
17975 else if (unformat (input, "bd %d", &bd))
17979 errmsg ("parse error '%U'", format_unformat_error, input);
17984 if (!bd_set || !ip_set || (!mac_set && is_add))
17986 errmsg ("Missing BD, IP or MAC!");
17990 M (ONE_ADD_DEL_NDP_ENTRY, mp);
17991 mp->is_add = is_add;
17992 clib_memcpy (mp->mac, mac, 6);
17993 mp->bd = clib_host_to_net_u32 (bd);
17994 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
17999 /* wait for reply */
18005 api_one_add_del_l2_arp_entry (vat_main_t * vam)
18007 vl_api_one_add_del_l2_arp_entry_t *mp;
18008 unformat_input_t *input = vam->input;
18013 u8 mac[6] = { 0, };
18014 u32 ip4 = 0, bd = ~0;
18017 /* Parse args required to build the message */
18018 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18020 if (unformat (input, "del"))
18022 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
18024 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
18026 else if (unformat (input, "bd %d", &bd))
18030 errmsg ("parse error '%U'", format_unformat_error, input);
18035 if (!bd_set || !ip_set || (!mac_set && is_add))
18037 errmsg ("Missing BD, IP or MAC!");
18041 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
18042 mp->is_add = is_add;
18043 clib_memcpy (mp->mac, mac, 6);
18044 mp->bd = clib_host_to_net_u32 (bd);
18050 /* wait for reply */
18056 api_one_ndp_bd_get (vat_main_t * vam)
18058 vl_api_one_ndp_bd_get_t *mp;
18061 M (ONE_NDP_BD_GET, mp);
18066 /* wait for reply */
18072 api_one_ndp_entries_get (vat_main_t * vam)
18074 vl_api_one_ndp_entries_get_t *mp;
18075 unformat_input_t *input = vam->input;
18080 /* Parse args required to build the message */
18081 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18083 if (unformat (input, "bd %d", &bd))
18087 errmsg ("parse error '%U'", format_unformat_error, input);
18094 errmsg ("Expected bridge domain!");
18098 M (ONE_NDP_ENTRIES_GET, mp);
18099 mp->bd = clib_host_to_net_u32 (bd);
18104 /* wait for reply */
18110 api_one_l2_arp_bd_get (vat_main_t * vam)
18112 vl_api_one_l2_arp_bd_get_t *mp;
18115 M (ONE_L2_ARP_BD_GET, mp);
18120 /* wait for reply */
18126 api_one_l2_arp_entries_get (vat_main_t * vam)
18128 vl_api_one_l2_arp_entries_get_t *mp;
18129 unformat_input_t *input = vam->input;
18134 /* Parse args required to build the message */
18135 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18137 if (unformat (input, "bd %d", &bd))
18141 errmsg ("parse error '%U'", format_unformat_error, input);
18148 errmsg ("Expected bridge domain!");
18152 M (ONE_L2_ARP_ENTRIES_GET, mp);
18153 mp->bd = clib_host_to_net_u32 (bd);
18158 /* wait for reply */
18164 api_one_stats_enable_disable (vat_main_t * vam)
18166 vl_api_one_stats_enable_disable_t *mp;
18167 unformat_input_t *input = vam->input;
18172 /* Parse args required to build the message */
18173 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18175 if (unformat (input, "enable"))
18180 else if (unformat (input, "disable"))
18190 errmsg ("Value not set");
18194 M (ONE_STATS_ENABLE_DISABLE, mp);
18200 /* wait for reply */
18206 api_show_one_stats_enable_disable (vat_main_t * vam)
18208 vl_api_show_one_stats_enable_disable_t *mp;
18211 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
18216 /* wait for reply */
18222 api_show_one_map_request_mode (vat_main_t * vam)
18224 vl_api_show_one_map_request_mode_t *mp;
18227 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
18232 /* wait for reply */
18237 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
18240 api_one_map_request_mode (vat_main_t * vam)
18242 unformat_input_t *input = vam->input;
18243 vl_api_one_map_request_mode_t *mp;
18247 /* Parse args required to build the message */
18248 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18250 if (unformat (input, "dst-only"))
18252 else if (unformat (input, "src-dst"))
18256 errmsg ("parse error '%U'", format_unformat_error, input);
18261 M (ONE_MAP_REQUEST_MODE, mp);
18268 /* wait for reply */
18273 #define api_lisp_map_request_mode api_one_map_request_mode
18276 * Enable/disable ONE proxy ITR.
18278 * @param vam vpp API test context
18279 * @return return code
18282 api_one_pitr_set_locator_set (vat_main_t * vam)
18284 u8 ls_name_set = 0;
18285 unformat_input_t *input = vam->input;
18286 vl_api_one_pitr_set_locator_set_t *mp;
18291 /* Parse args required to build the message */
18292 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18294 if (unformat (input, "del"))
18296 else if (unformat (input, "locator-set %s", &ls_name))
18300 errmsg ("parse error '%U'", format_unformat_error, input);
18307 errmsg ("locator-set name not set!");
18311 M (ONE_PITR_SET_LOCATOR_SET, mp);
18313 mp->is_add = is_add;
18314 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
18315 vec_free (ls_name);
18320 /* wait for reply */
18325 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
18328 api_one_nsh_set_locator_set (vat_main_t * vam)
18330 u8 ls_name_set = 0;
18331 unformat_input_t *input = vam->input;
18332 vl_api_one_nsh_set_locator_set_t *mp;
18337 /* Parse args required to build the message */
18338 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18340 if (unformat (input, "del"))
18342 else if (unformat (input, "ls %s", &ls_name))
18346 errmsg ("parse error '%U'", format_unformat_error, input);
18351 if (!ls_name_set && is_add)
18353 errmsg ("locator-set name not set!");
18357 M (ONE_NSH_SET_LOCATOR_SET, mp);
18359 mp->is_add = is_add;
18360 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
18361 vec_free (ls_name);
18366 /* wait for reply */
18372 api_show_one_pitr (vat_main_t * vam)
18374 vl_api_show_one_pitr_t *mp;
18377 if (!vam->json_output)
18379 print (vam->ofp, "%=20s", "lisp status:");
18382 M (SHOW_ONE_PITR, mp);
18386 /* Wait for a reply... */
18391 #define api_show_lisp_pitr api_show_one_pitr
18394 api_one_use_petr (vat_main_t * vam)
18396 unformat_input_t *input = vam->input;
18397 vl_api_one_use_petr_t *mp;
18402 memset (&ip, 0, sizeof (ip));
18404 /* Parse args required to build the message */
18405 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18407 if (unformat (input, "disable"))
18410 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
18413 ip_addr_version (&ip) = IP4;
18416 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
18419 ip_addr_version (&ip) = IP6;
18423 errmsg ("parse error '%U'", format_unformat_error, input);
18428 M (ONE_USE_PETR, mp);
18430 mp->is_add = is_add;
18433 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
18435 clib_memcpy (mp->address, &ip, 4);
18437 clib_memcpy (mp->address, &ip, 16);
18443 /* wait for reply */
18448 #define api_lisp_use_petr api_one_use_petr
18451 api_show_one_nsh_mapping (vat_main_t * vam)
18453 vl_api_show_one_use_petr_t *mp;
18456 if (!vam->json_output)
18458 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
18461 M (SHOW_ONE_NSH_MAPPING, mp);
18465 /* Wait for a reply... */
18471 api_show_one_use_petr (vat_main_t * vam)
18473 vl_api_show_one_use_petr_t *mp;
18476 if (!vam->json_output)
18478 print (vam->ofp, "%=20s", "Proxy-ETR status:");
18481 M (SHOW_ONE_USE_PETR, mp);
18485 /* Wait for a reply... */
18490 #define api_show_lisp_use_petr api_show_one_use_petr
18493 * Add/delete mapping between vni and vrf
18496 api_one_eid_table_add_del_map (vat_main_t * vam)
18498 unformat_input_t *input = vam->input;
18499 vl_api_one_eid_table_add_del_map_t *mp;
18500 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
18501 u32 vni, vrf, bd_index;
18504 /* Parse args required to build the message */
18505 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18507 if (unformat (input, "del"))
18509 else if (unformat (input, "vrf %d", &vrf))
18511 else if (unformat (input, "bd_index %d", &bd_index))
18513 else if (unformat (input, "vni %d", &vni))
18519 if (!vni_set || (!vrf_set && !bd_index_set))
18521 errmsg ("missing arguments!");
18525 if (vrf_set && bd_index_set)
18527 errmsg ("error: both vrf and bd entered!");
18531 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
18533 mp->is_add = is_add;
18534 mp->vni = htonl (vni);
18535 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
18536 mp->is_l2 = bd_index_set;
18541 /* wait for reply */
18546 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
18549 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
18551 u32 *action = va_arg (*args, u32 *);
18554 if (unformat (input, "%s", &s))
18556 if (!strcmp ((char *) s, "no-action"))
18558 else if (!strcmp ((char *) s, "natively-forward"))
18560 else if (!strcmp ((char *) s, "send-map-request"))
18562 else if (!strcmp ((char *) s, "drop"))
18566 clib_warning ("invalid action: '%s'", s);
18578 * Add/del remote mapping to/from ONE control plane
18580 * @param vam vpp API test context
18581 * @return return code
18584 api_one_add_del_remote_mapping (vat_main_t * vam)
18586 unformat_input_t *input = vam->input;
18587 vl_api_one_add_del_remote_mapping_t *mp;
18589 lisp_eid_vat_t _eid, *eid = &_eid;
18590 lisp_eid_vat_t _seid, *seid = &_seid;
18591 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
18592 u32 action = ~0, p, w, data_len;
18593 ip4_address_t rloc4;
18594 ip6_address_t rloc6;
18595 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
18598 memset (&rloc, 0, sizeof (rloc));
18600 /* Parse args required to build the message */
18601 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18603 if (unformat (input, "del-all"))
18607 else if (unformat (input, "del"))
18611 else if (unformat (input, "add"))
18615 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
18619 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
18623 else if (unformat (input, "vni %d", &vni))
18627 else if (unformat (input, "p %d w %d", &p, &w))
18631 errmsg ("No RLOC configured for setting priority/weight!");
18634 curr_rloc->priority = p;
18635 curr_rloc->weight = w;
18637 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
18640 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
18641 vec_add1 (rlocs, rloc);
18642 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18644 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
18647 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
18648 vec_add1 (rlocs, rloc);
18649 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18651 else if (unformat (input, "action %U",
18652 unformat_negative_mapping_action, &action))
18658 clib_warning ("parse error '%U'", format_unformat_error, input);
18665 errmsg ("missing params!");
18669 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
18671 errmsg ("no action set for negative map-reply!");
18675 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
18677 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
18678 mp->is_add = is_add;
18679 mp->vni = htonl (vni);
18680 mp->action = (u8) action;
18681 mp->is_src_dst = seid_set;
18682 mp->eid_len = eid->len;
18683 mp->seid_len = seid->len;
18684 mp->del_all = del_all;
18685 mp->eid_type = eid->type;
18686 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
18687 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
18689 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
18690 clib_memcpy (mp->rlocs, rlocs, data_len);
18696 /* Wait for a reply... */
18701 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
18704 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
18705 * forwarding entries in data-plane accordingly.
18707 * @param vam vpp API test context
18708 * @return return code
18711 api_one_add_del_adjacency (vat_main_t * vam)
18713 unformat_input_t *input = vam->input;
18714 vl_api_one_add_del_adjacency_t *mp;
18716 ip4_address_t leid4, reid4;
18717 ip6_address_t leid6, reid6;
18718 u8 reid_mac[6] = { 0 };
18719 u8 leid_mac[6] = { 0 };
18720 u8 reid_type, leid_type;
18721 u32 leid_len = 0, reid_len = 0, len;
18725 leid_type = reid_type = (u8) ~ 0;
18727 /* Parse args required to build the message */
18728 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18730 if (unformat (input, "del"))
18734 else if (unformat (input, "add"))
18738 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
18741 reid_type = 0; /* ipv4 */
18744 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
18747 reid_type = 1; /* ipv6 */
18750 else if (unformat (input, "reid %U", unformat_ethernet_address,
18753 reid_type = 2; /* mac */
18755 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
18758 leid_type = 0; /* ipv4 */
18761 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
18764 leid_type = 1; /* ipv6 */
18767 else if (unformat (input, "leid %U", unformat_ethernet_address,
18770 leid_type = 2; /* mac */
18772 else if (unformat (input, "vni %d", &vni))
18778 errmsg ("parse error '%U'", format_unformat_error, input);
18783 if ((u8) ~ 0 == reid_type)
18785 errmsg ("missing params!");
18789 if (leid_type != reid_type)
18791 errmsg ("remote and local EIDs are of different types!");
18795 M (ONE_ADD_DEL_ADJACENCY, mp);
18796 mp->is_add = is_add;
18797 mp->vni = htonl (vni);
18798 mp->leid_len = leid_len;
18799 mp->reid_len = reid_len;
18800 mp->eid_type = reid_type;
18802 switch (mp->eid_type)
18805 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
18806 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
18809 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
18810 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
18813 clib_memcpy (mp->leid, leid_mac, 6);
18814 clib_memcpy (mp->reid, reid_mac, 6);
18817 errmsg ("unknown EID type %d!", mp->eid_type);
18824 /* Wait for a reply... */
18829 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
18832 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
18834 u32 *mode = va_arg (*args, u32 *);
18836 if (unformat (input, "lisp"))
18838 else if (unformat (input, "vxlan"))
18847 api_gpe_get_encap_mode (vat_main_t * vam)
18849 vl_api_gpe_get_encap_mode_t *mp;
18852 /* Construct the API message */
18853 M (GPE_GET_ENCAP_MODE, mp);
18858 /* Wait for a reply... */
18864 api_gpe_set_encap_mode (vat_main_t * vam)
18866 unformat_input_t *input = vam->input;
18867 vl_api_gpe_set_encap_mode_t *mp;
18871 /* Parse args required to build the message */
18872 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18874 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
18880 /* Construct the API message */
18881 M (GPE_SET_ENCAP_MODE, mp);
18888 /* Wait for a reply... */
18894 api_lisp_gpe_add_del_iface (vat_main_t * vam)
18896 unformat_input_t *input = vam->input;
18897 vl_api_gpe_add_del_iface_t *mp;
18898 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
18899 u32 dp_table = 0, vni = 0;
18902 /* Parse args required to build the message */
18903 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18905 if (unformat (input, "up"))
18910 else if (unformat (input, "down"))
18915 else if (unformat (input, "table_id %d", &dp_table))
18919 else if (unformat (input, "bd_id %d", &dp_table))
18924 else if (unformat (input, "vni %d", &vni))
18932 if (action_set == 0)
18934 errmsg ("Action not set");
18937 if (dp_table_set == 0 || vni_set == 0)
18939 errmsg ("vni and dp_table must be set");
18943 /* Construct the API message */
18944 M (GPE_ADD_DEL_IFACE, mp);
18946 mp->is_add = is_add;
18947 mp->dp_table = clib_host_to_net_u32 (dp_table);
18949 mp->vni = clib_host_to_net_u32 (vni);
18954 /* Wait for a reply... */
18960 api_one_map_register_fallback_threshold (vat_main_t * vam)
18962 unformat_input_t *input = vam->input;
18963 vl_api_one_map_register_fallback_threshold_t *mp;
18968 /* Parse args required to build the message */
18969 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18971 if (unformat (input, "%u", &value))
18975 clib_warning ("parse error '%U'", format_unformat_error, input);
18982 errmsg ("fallback threshold value is missing!");
18986 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18987 mp->value = clib_host_to_net_u32 (value);
18992 /* Wait for a reply... */
18998 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
19000 vl_api_show_one_map_register_fallback_threshold_t *mp;
19003 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
19008 /* Wait for a reply... */
19014 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
19016 u32 *proto = va_arg (*args, u32 *);
19018 if (unformat (input, "udp"))
19020 else if (unformat (input, "api"))
19029 api_one_set_transport_protocol (vat_main_t * vam)
19031 unformat_input_t *input = vam->input;
19032 vl_api_one_set_transport_protocol_t *mp;
19037 /* Parse args required to build the message */
19038 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19040 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
19044 clib_warning ("parse error '%U'", format_unformat_error, input);
19051 errmsg ("Transport protocol missing!");
19055 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
19056 mp->protocol = (u8) protocol;
19061 /* Wait for a reply... */
19067 api_one_get_transport_protocol (vat_main_t * vam)
19069 vl_api_one_get_transport_protocol_t *mp;
19072 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
19077 /* Wait for a reply... */
19083 api_one_map_register_set_ttl (vat_main_t * vam)
19085 unformat_input_t *input = vam->input;
19086 vl_api_one_map_register_set_ttl_t *mp;
19091 /* Parse args required to build the message */
19092 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19094 if (unformat (input, "%u", &ttl))
19098 clib_warning ("parse error '%U'", format_unformat_error, input);
19105 errmsg ("TTL value missing!");
19109 M (ONE_MAP_REGISTER_SET_TTL, mp);
19110 mp->ttl = clib_host_to_net_u32 (ttl);
19115 /* Wait for a reply... */
19121 api_show_one_map_register_ttl (vat_main_t * vam)
19123 vl_api_show_one_map_register_ttl_t *mp;
19126 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
19131 /* Wait for a reply... */
19137 * Add/del map request itr rlocs from ONE control plane and updates
19139 * @param vam vpp API test context
19140 * @return return code
19143 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
19145 unformat_input_t *input = vam->input;
19146 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
19147 u8 *locator_set_name = 0;
19148 u8 locator_set_name_set = 0;
19152 /* Parse args required to build the message */
19153 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19155 if (unformat (input, "del"))
19159 else if (unformat (input, "%_%v%_", &locator_set_name))
19161 locator_set_name_set = 1;
19165 clib_warning ("parse error '%U'", format_unformat_error, input);
19170 if (is_add && !locator_set_name_set)
19172 errmsg ("itr-rloc is not set!");
19176 if (is_add && vec_len (locator_set_name) > 64)
19178 errmsg ("itr-rloc locator-set name too long");
19179 vec_free (locator_set_name);
19183 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
19184 mp->is_add = is_add;
19187 clib_memcpy (mp->locator_set_name, locator_set_name,
19188 vec_len (locator_set_name));
19192 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
19194 vec_free (locator_set_name);
19199 /* Wait for a reply... */
19204 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
19207 api_one_locator_dump (vat_main_t * vam)
19209 unformat_input_t *input = vam->input;
19210 vl_api_one_locator_dump_t *mp;
19211 vl_api_control_ping_t *mp_ping;
19212 u8 is_index_set = 0, is_name_set = 0;
19217 /* Parse args required to build the message */
19218 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19220 if (unformat (input, "ls_name %_%v%_", &ls_name))
19224 else if (unformat (input, "ls_index %d", &ls_index))
19230 errmsg ("parse error '%U'", format_unformat_error, input);
19235 if (!is_index_set && !is_name_set)
19237 errmsg ("error: expected one of index or name!");
19241 if (is_index_set && is_name_set)
19243 errmsg ("error: only one param expected!");
19247 if (vec_len (ls_name) > 62)
19249 errmsg ("error: locator set name too long!");
19253 if (!vam->json_output)
19255 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
19258 M (ONE_LOCATOR_DUMP, mp);
19259 mp->is_index_set = is_index_set;
19262 mp->ls_index = clib_host_to_net_u32 (ls_index);
19265 vec_add1 (ls_name, 0);
19266 strncpy ((char *) mp->ls_name, (char *) ls_name,
19267 sizeof (mp->ls_name) - 1);
19273 /* Use a control ping for synchronization */
19274 MPING (CONTROL_PING, mp_ping);
19277 /* Wait for a reply... */
19282 #define api_lisp_locator_dump api_one_locator_dump
19285 api_one_locator_set_dump (vat_main_t * vam)
19287 vl_api_one_locator_set_dump_t *mp;
19288 vl_api_control_ping_t *mp_ping;
19289 unformat_input_t *input = vam->input;
19293 /* Parse args required to build the message */
19294 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19296 if (unformat (input, "local"))
19300 else if (unformat (input, "remote"))
19306 errmsg ("parse error '%U'", format_unformat_error, input);
19311 if (!vam->json_output)
19313 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
19316 M (ONE_LOCATOR_SET_DUMP, mp);
19318 mp->filter = filter;
19323 /* Use a control ping for synchronization */
19324 MPING (CONTROL_PING, mp_ping);
19327 /* Wait for a reply... */
19332 #define api_lisp_locator_set_dump api_one_locator_set_dump
19335 api_one_eid_table_map_dump (vat_main_t * vam)
19339 unformat_input_t *input = vam->input;
19340 vl_api_one_eid_table_map_dump_t *mp;
19341 vl_api_control_ping_t *mp_ping;
19344 /* Parse args required to build the message */
19345 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19347 if (unformat (input, "l2"))
19352 else if (unformat (input, "l3"))
19359 errmsg ("parse error '%U'", format_unformat_error, input);
19366 errmsg ("expected one of 'l2' or 'l3' parameter!");
19370 if (!vam->json_output)
19372 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
19375 M (ONE_EID_TABLE_MAP_DUMP, mp);
19381 /* Use a control ping for synchronization */
19382 MPING (CONTROL_PING, mp_ping);
19385 /* Wait for a reply... */
19390 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
19393 api_one_eid_table_vni_dump (vat_main_t * vam)
19395 vl_api_one_eid_table_vni_dump_t *mp;
19396 vl_api_control_ping_t *mp_ping;
19399 if (!vam->json_output)
19401 print (vam->ofp, "VNI");
19404 M (ONE_EID_TABLE_VNI_DUMP, mp);
19409 /* Use a control ping for synchronization */
19410 MPING (CONTROL_PING, mp_ping);
19413 /* Wait for a reply... */
19418 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
19421 api_one_eid_table_dump (vat_main_t * vam)
19423 unformat_input_t *i = vam->input;
19424 vl_api_one_eid_table_dump_t *mp;
19425 vl_api_control_ping_t *mp_ping;
19426 struct in_addr ip4;
19427 struct in6_addr ip6;
19429 u8 eid_type = ~0, eid_set = 0;
19430 u32 prefix_length = ~0, t, vni = 0;
19433 lisp_nsh_api_t nsh;
19435 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19437 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
19443 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
19449 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
19454 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
19459 else if (unformat (i, "vni %d", &t))
19463 else if (unformat (i, "local"))
19467 else if (unformat (i, "remote"))
19473 errmsg ("parse error '%U'", format_unformat_error, i);
19478 if (!vam->json_output)
19480 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
19481 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
19484 M (ONE_EID_TABLE_DUMP, mp);
19486 mp->filter = filter;
19490 mp->vni = htonl (vni);
19491 mp->eid_type = eid_type;
19495 mp->prefix_length = prefix_length;
19496 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
19499 mp->prefix_length = prefix_length;
19500 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
19503 clib_memcpy (mp->eid, mac, sizeof (mac));
19506 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
19509 errmsg ("unknown EID type %d!", eid_type);
19517 /* Use a control ping for synchronization */
19518 MPING (CONTROL_PING, mp_ping);
19521 /* Wait for a reply... */
19526 #define api_lisp_eid_table_dump api_one_eid_table_dump
19529 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
19531 unformat_input_t *i = vam->input;
19532 vl_api_gpe_fwd_entries_get_t *mp;
19537 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19539 if (unformat (i, "vni %d", &vni))
19545 errmsg ("parse error '%U'", format_unformat_error, i);
19552 errmsg ("vni not set!");
19556 if (!vam->json_output)
19558 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
19562 M (GPE_FWD_ENTRIES_GET, mp);
19563 mp->vni = clib_host_to_net_u32 (vni);
19568 /* Wait for a reply... */
19573 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
19574 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
19575 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
19576 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
19577 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
19578 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
19579 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
19580 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
19583 api_one_adjacencies_get (vat_main_t * vam)
19585 unformat_input_t *i = vam->input;
19586 vl_api_one_adjacencies_get_t *mp;
19591 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19593 if (unformat (i, "vni %d", &vni))
19599 errmsg ("parse error '%U'", format_unformat_error, i);
19606 errmsg ("vni not set!");
19610 if (!vam->json_output)
19612 print (vam->ofp, "%s %40s", "leid", "reid");
19615 M (ONE_ADJACENCIES_GET, mp);
19616 mp->vni = clib_host_to_net_u32 (vni);
19621 /* Wait for a reply... */
19626 #define api_lisp_adjacencies_get api_one_adjacencies_get
19629 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
19631 unformat_input_t *i = vam->input;
19632 vl_api_gpe_native_fwd_rpaths_get_t *mp;
19634 u8 ip_family_set = 0, is_ip4 = 1;
19636 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19638 if (unformat (i, "ip4"))
19643 else if (unformat (i, "ip6"))
19650 errmsg ("parse error '%U'", format_unformat_error, i);
19655 if (!ip_family_set)
19657 errmsg ("ip family not set!");
19661 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
19662 mp->is_ip4 = is_ip4;
19667 /* Wait for a reply... */
19673 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
19675 vl_api_gpe_fwd_entry_vnis_get_t *mp;
19678 if (!vam->json_output)
19680 print (vam->ofp, "VNIs");
19683 M (GPE_FWD_ENTRY_VNIS_GET, mp);
19688 /* Wait for a reply... */
19694 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
19696 unformat_input_t *i = vam->input;
19697 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
19699 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
19700 struct in_addr ip4;
19701 struct in6_addr ip6;
19702 u32 table_id = 0, nh_sw_if_index = ~0;
19704 memset (&ip4, 0, sizeof (ip4));
19705 memset (&ip6, 0, sizeof (ip6));
19707 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19709 if (unformat (i, "del"))
19711 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
19712 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19717 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
19718 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19723 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
19727 nh_sw_if_index = ~0;
19729 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
19733 nh_sw_if_index = ~0;
19735 else if (unformat (i, "table %d", &table_id))
19739 errmsg ("parse error '%U'", format_unformat_error, i);
19746 errmsg ("nh addr not set!");
19750 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
19751 mp->is_add = is_add;
19752 mp->table_id = clib_host_to_net_u32 (table_id);
19753 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
19754 mp->is_ip4 = is_ip4;
19756 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
19758 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
19763 /* Wait for a reply... */
19769 api_one_map_server_dump (vat_main_t * vam)
19771 vl_api_one_map_server_dump_t *mp;
19772 vl_api_control_ping_t *mp_ping;
19775 if (!vam->json_output)
19777 print (vam->ofp, "%=20s", "Map server");
19780 M (ONE_MAP_SERVER_DUMP, mp);
19784 /* Use a control ping for synchronization */
19785 MPING (CONTROL_PING, mp_ping);
19788 /* Wait for a reply... */
19793 #define api_lisp_map_server_dump api_one_map_server_dump
19796 api_one_map_resolver_dump (vat_main_t * vam)
19798 vl_api_one_map_resolver_dump_t *mp;
19799 vl_api_control_ping_t *mp_ping;
19802 if (!vam->json_output)
19804 print (vam->ofp, "%=20s", "Map resolver");
19807 M (ONE_MAP_RESOLVER_DUMP, mp);
19811 /* Use a control ping for synchronization */
19812 MPING (CONTROL_PING, mp_ping);
19815 /* Wait for a reply... */
19820 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
19823 api_one_stats_flush (vat_main_t * vam)
19825 vl_api_one_stats_flush_t *mp;
19828 M (ONE_STATS_FLUSH, mp);
19835 api_one_stats_dump (vat_main_t * vam)
19837 vl_api_one_stats_dump_t *mp;
19838 vl_api_control_ping_t *mp_ping;
19841 M (ONE_STATS_DUMP, mp);
19845 /* Use a control ping for synchronization */
19846 MPING (CONTROL_PING, mp_ping);
19849 /* Wait for a reply... */
19855 api_show_one_status (vat_main_t * vam)
19857 vl_api_show_one_status_t *mp;
19860 if (!vam->json_output)
19862 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
19865 M (SHOW_ONE_STATUS, mp);
19868 /* Wait for a reply... */
19873 #define api_show_lisp_status api_show_one_status
19876 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
19878 vl_api_gpe_fwd_entry_path_dump_t *mp;
19879 vl_api_control_ping_t *mp_ping;
19880 unformat_input_t *i = vam->input;
19881 u32 fwd_entry_index = ~0;
19884 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19886 if (unformat (i, "index %d", &fwd_entry_index))
19892 if (~0 == fwd_entry_index)
19894 errmsg ("no index specified!");
19898 if (!vam->json_output)
19900 print (vam->ofp, "first line");
19903 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
19907 /* Use a control ping for synchronization */
19908 MPING (CONTROL_PING, mp_ping);
19911 /* Wait for a reply... */
19917 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
19919 vl_api_one_get_map_request_itr_rlocs_t *mp;
19922 if (!vam->json_output)
19924 print (vam->ofp, "%=20s", "itr-rlocs:");
19927 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
19930 /* Wait for a reply... */
19935 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
19938 api_af_packet_create (vat_main_t * vam)
19940 unformat_input_t *i = vam->input;
19941 vl_api_af_packet_create_t *mp;
19942 u8 *host_if_name = 0;
19944 u8 random_hw_addr = 1;
19947 memset (hw_addr, 0, sizeof (hw_addr));
19949 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19951 if (unformat (i, "name %s", &host_if_name))
19952 vec_add1 (host_if_name, 0);
19953 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19954 random_hw_addr = 0;
19959 if (!vec_len (host_if_name))
19961 errmsg ("host-interface name must be specified");
19965 if (vec_len (host_if_name) > 64)
19967 errmsg ("host-interface name too long");
19971 M (AF_PACKET_CREATE, mp);
19973 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19974 clib_memcpy (mp->hw_addr, hw_addr, 6);
19975 mp->use_random_hw_addr = random_hw_addr;
19976 vec_free (host_if_name);
19984 fprintf (vam->ofp ? vam->ofp : stderr,
19985 " new sw_if_index = %d\n", vam->sw_if_index);
19992 api_af_packet_delete (vat_main_t * vam)
19994 unformat_input_t *i = vam->input;
19995 vl_api_af_packet_delete_t *mp;
19996 u8 *host_if_name = 0;
19999 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20001 if (unformat (i, "name %s", &host_if_name))
20002 vec_add1 (host_if_name, 0);
20007 if (!vec_len (host_if_name))
20009 errmsg ("host-interface name must be specified");
20013 if (vec_len (host_if_name) > 64)
20015 errmsg ("host-interface name too long");
20019 M (AF_PACKET_DELETE, mp);
20021 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
20022 vec_free (host_if_name);
20029 static void vl_api_af_packet_details_t_handler
20030 (vl_api_af_packet_details_t * mp)
20032 vat_main_t *vam = &vat_main;
20034 print (vam->ofp, "%-16s %d",
20035 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
20038 static void vl_api_af_packet_details_t_handler_json
20039 (vl_api_af_packet_details_t * mp)
20041 vat_main_t *vam = &vat_main;
20042 vat_json_node_t *node = NULL;
20044 if (VAT_JSON_ARRAY != vam->json_tree.type)
20046 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20047 vat_json_init_array (&vam->json_tree);
20049 node = vat_json_array_add (&vam->json_tree);
20051 vat_json_init_object (node);
20052 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
20053 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
20057 api_af_packet_dump (vat_main_t * vam)
20059 vl_api_af_packet_dump_t *mp;
20060 vl_api_control_ping_t *mp_ping;
20063 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
20064 /* Get list of tap interfaces */
20065 M (AF_PACKET_DUMP, mp);
20068 /* Use a control ping for synchronization */
20069 MPING (CONTROL_PING, mp_ping);
20077 api_policer_add_del (vat_main_t * vam)
20079 unformat_input_t *i = vam->input;
20080 vl_api_policer_add_del_t *mp;
20090 u8 color_aware = 0;
20091 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
20094 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
20095 conform_action.dscp = 0;
20096 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
20097 exceed_action.dscp = 0;
20098 violate_action.action_type = SSE2_QOS_ACTION_DROP;
20099 violate_action.dscp = 0;
20101 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20103 if (unformat (i, "del"))
20105 else if (unformat (i, "name %s", &name))
20106 vec_add1 (name, 0);
20107 else if (unformat (i, "cir %u", &cir))
20109 else if (unformat (i, "eir %u", &eir))
20111 else if (unformat (i, "cb %u", &cb))
20113 else if (unformat (i, "eb %u", &eb))
20115 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
20118 else if (unformat (i, "round_type %U", unformat_policer_round_type,
20121 else if (unformat (i, "type %U", unformat_policer_type, &type))
20123 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
20126 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
20129 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
20132 else if (unformat (i, "color-aware"))
20138 if (!vec_len (name))
20140 errmsg ("policer name must be specified");
20144 if (vec_len (name) > 64)
20146 errmsg ("policer name too long");
20150 M (POLICER_ADD_DEL, mp);
20152 clib_memcpy (mp->name, name, vec_len (name));
20154 mp->is_add = is_add;
20155 mp->cir = ntohl (cir);
20156 mp->eir = ntohl (eir);
20157 mp->cb = clib_net_to_host_u64 (cb);
20158 mp->eb = clib_net_to_host_u64 (eb);
20159 mp->rate_type = rate_type;
20160 mp->round_type = round_type;
20162 mp->conform_action_type = conform_action.action_type;
20163 mp->conform_dscp = conform_action.dscp;
20164 mp->exceed_action_type = exceed_action.action_type;
20165 mp->exceed_dscp = exceed_action.dscp;
20166 mp->violate_action_type = violate_action.action_type;
20167 mp->violate_dscp = violate_action.dscp;
20168 mp->color_aware = color_aware;
20176 api_policer_dump (vat_main_t * vam)
20178 unformat_input_t *i = vam->input;
20179 vl_api_policer_dump_t *mp;
20180 vl_api_control_ping_t *mp_ping;
20181 u8 *match_name = 0;
20182 u8 match_name_valid = 0;
20185 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20187 if (unformat (i, "name %s", &match_name))
20189 vec_add1 (match_name, 0);
20190 match_name_valid = 1;
20196 M (POLICER_DUMP, mp);
20197 mp->match_name_valid = match_name_valid;
20198 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
20199 vec_free (match_name);
20203 /* Use a control ping for synchronization */
20204 MPING (CONTROL_PING, mp_ping);
20207 /* Wait for a reply... */
20213 api_policer_classify_set_interface (vat_main_t * vam)
20215 unformat_input_t *i = vam->input;
20216 vl_api_policer_classify_set_interface_t *mp;
20218 int sw_if_index_set;
20219 u32 ip4_table_index = ~0;
20220 u32 ip6_table_index = ~0;
20221 u32 l2_table_index = ~0;
20225 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20227 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20228 sw_if_index_set = 1;
20229 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20230 sw_if_index_set = 1;
20231 else if (unformat (i, "del"))
20233 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20235 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20237 else if (unformat (i, "l2-table %d", &l2_table_index))
20241 clib_warning ("parse error '%U'", format_unformat_error, i);
20246 if (sw_if_index_set == 0)
20248 errmsg ("missing interface name or sw_if_index");
20252 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
20254 mp->sw_if_index = ntohl (sw_if_index);
20255 mp->ip4_table_index = ntohl (ip4_table_index);
20256 mp->ip6_table_index = ntohl (ip6_table_index);
20257 mp->l2_table_index = ntohl (l2_table_index);
20258 mp->is_add = is_add;
20266 api_policer_classify_dump (vat_main_t * vam)
20268 unformat_input_t *i = vam->input;
20269 vl_api_policer_classify_dump_t *mp;
20270 vl_api_control_ping_t *mp_ping;
20271 u8 type = POLICER_CLASSIFY_N_TABLES;
20274 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
20278 errmsg ("classify table type must be specified");
20282 if (!vam->json_output)
20284 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20287 M (POLICER_CLASSIFY_DUMP, mp);
20292 /* Use a control ping for synchronization */
20293 MPING (CONTROL_PING, mp_ping);
20296 /* Wait for a reply... */
20302 api_netmap_create (vat_main_t * vam)
20304 unformat_input_t *i = vam->input;
20305 vl_api_netmap_create_t *mp;
20308 u8 random_hw_addr = 1;
20313 memset (hw_addr, 0, sizeof (hw_addr));
20315 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20317 if (unformat (i, "name %s", &if_name))
20318 vec_add1 (if_name, 0);
20319 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
20320 random_hw_addr = 0;
20321 else if (unformat (i, "pipe"))
20323 else if (unformat (i, "master"))
20325 else if (unformat (i, "slave"))
20331 if (!vec_len (if_name))
20333 errmsg ("interface name must be specified");
20337 if (vec_len (if_name) > 64)
20339 errmsg ("interface name too long");
20343 M (NETMAP_CREATE, mp);
20345 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20346 clib_memcpy (mp->hw_addr, hw_addr, 6);
20347 mp->use_random_hw_addr = random_hw_addr;
20348 mp->is_pipe = is_pipe;
20349 mp->is_master = is_master;
20350 vec_free (if_name);
20358 api_netmap_delete (vat_main_t * vam)
20360 unformat_input_t *i = vam->input;
20361 vl_api_netmap_delete_t *mp;
20365 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20367 if (unformat (i, "name %s", &if_name))
20368 vec_add1 (if_name, 0);
20373 if (!vec_len (if_name))
20375 errmsg ("interface name must be specified");
20379 if (vec_len (if_name) > 64)
20381 errmsg ("interface name too long");
20385 M (NETMAP_DELETE, mp);
20387 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20388 vec_free (if_name);
20396 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
20398 if (fp->afi == IP46_TYPE_IP6)
20400 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20401 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20402 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20403 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20404 format_ip6_address, fp->next_hop);
20405 else if (fp->afi == IP46_TYPE_IP4)
20407 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20408 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20409 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20410 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20411 format_ip4_address, fp->next_hop);
20415 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
20416 vl_api_fib_path_t * fp)
20418 struct in_addr ip4;
20419 struct in6_addr ip6;
20421 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20422 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20423 vat_json_object_add_uint (node, "is_local", fp->is_local);
20424 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20425 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20426 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20427 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20428 if (fp->afi == IP46_TYPE_IP4)
20430 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20431 vat_json_object_add_ip4 (node, "next_hop", ip4);
20433 else if (fp->afi == IP46_TYPE_IP6)
20435 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20436 vat_json_object_add_ip6 (node, "next_hop", ip6);
20441 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
20443 vat_main_t *vam = &vat_main;
20444 int count = ntohl (mp->mt_count);
20445 vl_api_fib_path_t *fp;
20448 print (vam->ofp, "[%d]: sw_if_index %d via:",
20449 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
20451 for (i = 0; i < count; i++)
20453 vl_api_mpls_fib_path_print (vam, fp);
20457 print (vam->ofp, "");
20460 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
20461 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
20464 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
20466 vat_main_t *vam = &vat_main;
20467 vat_json_node_t *node = NULL;
20468 int count = ntohl (mp->mt_count);
20469 vl_api_fib_path_t *fp;
20472 if (VAT_JSON_ARRAY != vam->json_tree.type)
20474 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20475 vat_json_init_array (&vam->json_tree);
20477 node = vat_json_array_add (&vam->json_tree);
20479 vat_json_init_object (node);
20480 vat_json_object_add_uint (node, "tunnel_index",
20481 ntohl (mp->mt_tunnel_index));
20482 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
20484 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
20487 for (i = 0; i < count; i++)
20489 vl_api_mpls_fib_path_json_print (node, fp);
20495 api_mpls_tunnel_dump (vat_main_t * vam)
20497 vl_api_mpls_tunnel_dump_t *mp;
20498 vl_api_control_ping_t *mp_ping;
20499 u32 sw_if_index = ~0;
20502 /* Parse args required to build the message */
20503 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
20505 if (unformat (vam->input, "sw_if_index %d", &sw_if_index))
20509 print (vam->ofp, " sw_if_index %d", sw_if_index);
20511 M (MPLS_TUNNEL_DUMP, mp);
20512 mp->sw_if_index = htonl (sw_if_index);
20515 /* Use a control ping for synchronization */
20516 MPING (CONTROL_PING, mp_ping);
20523 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
20524 #define vl_api_mpls_fib_details_t_print vl_noop_handler
20528 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
20530 vat_main_t *vam = &vat_main;
20531 int count = ntohl (mp->count);
20532 vl_api_fib_path_t *fp;
20536 "table-id %d, label %u, ess_bit %u",
20537 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
20539 for (i = 0; i < count; i++)
20541 vl_api_mpls_fib_path_print (vam, fp);
20546 static void vl_api_mpls_fib_details_t_handler_json
20547 (vl_api_mpls_fib_details_t * mp)
20549 vat_main_t *vam = &vat_main;
20550 int count = ntohl (mp->count);
20551 vat_json_node_t *node = NULL;
20552 vl_api_fib_path_t *fp;
20555 if (VAT_JSON_ARRAY != vam->json_tree.type)
20557 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20558 vat_json_init_array (&vam->json_tree);
20560 node = vat_json_array_add (&vam->json_tree);
20562 vat_json_init_object (node);
20563 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20564 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
20565 vat_json_object_add_uint (node, "label", ntohl (mp->label));
20566 vat_json_object_add_uint (node, "path_count", count);
20568 for (i = 0; i < count; i++)
20570 vl_api_mpls_fib_path_json_print (node, fp);
20576 api_mpls_fib_dump (vat_main_t * vam)
20578 vl_api_mpls_fib_dump_t *mp;
20579 vl_api_control_ping_t *mp_ping;
20582 M (MPLS_FIB_DUMP, mp);
20585 /* Use a control ping for synchronization */
20586 MPING (CONTROL_PING, mp_ping);
20593 #define vl_api_ip_fib_details_t_endian vl_noop_handler
20594 #define vl_api_ip_fib_details_t_print vl_noop_handler
20597 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
20599 vat_main_t *vam = &vat_main;
20600 int count = ntohl (mp->count);
20601 vl_api_fib_path_t *fp;
20605 "table-id %d, prefix %U/%d stats-index %d",
20606 ntohl (mp->table_id), format_ip4_address, mp->address,
20607 mp->address_length, ntohl (mp->stats_index));
20609 for (i = 0; i < count; i++)
20611 if (fp->afi == IP46_TYPE_IP6)
20613 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20614 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U, "
20615 "next_hop_table %d",
20616 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20617 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20618 format_ip6_address, fp->next_hop, ntohl (fp->table_id));
20619 else if (fp->afi == IP46_TYPE_IP4)
20621 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20622 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U, "
20623 "next_hop_table %d",
20624 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20625 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20626 format_ip4_address, fp->next_hop, ntohl (fp->table_id));
20631 static void vl_api_ip_fib_details_t_handler_json
20632 (vl_api_ip_fib_details_t * mp)
20634 vat_main_t *vam = &vat_main;
20635 int count = ntohl (mp->count);
20636 vat_json_node_t *node = NULL;
20637 struct in_addr ip4;
20638 struct in6_addr ip6;
20639 vl_api_fib_path_t *fp;
20642 if (VAT_JSON_ARRAY != vam->json_tree.type)
20644 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20645 vat_json_init_array (&vam->json_tree);
20647 node = vat_json_array_add (&vam->json_tree);
20649 vat_json_init_object (node);
20650 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20651 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
20652 vat_json_object_add_ip4 (node, "prefix", ip4);
20653 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20654 vat_json_object_add_uint (node, "path_count", count);
20656 for (i = 0; i < count; i++)
20658 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20659 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20660 vat_json_object_add_uint (node, "is_local", fp->is_local);
20661 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20662 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20663 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20664 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20665 if (fp->afi == IP46_TYPE_IP4)
20667 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20668 vat_json_object_add_ip4 (node, "next_hop", ip4);
20670 else if (fp->afi == IP46_TYPE_IP6)
20672 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20673 vat_json_object_add_ip6 (node, "next_hop", ip6);
20679 api_ip_fib_dump (vat_main_t * vam)
20681 vl_api_ip_fib_dump_t *mp;
20682 vl_api_control_ping_t *mp_ping;
20685 M (IP_FIB_DUMP, mp);
20688 /* Use a control ping for synchronization */
20689 MPING (CONTROL_PING, mp_ping);
20697 api_ip_mfib_dump (vat_main_t * vam)
20699 vl_api_ip_mfib_dump_t *mp;
20700 vl_api_control_ping_t *mp_ping;
20703 M (IP_MFIB_DUMP, mp);
20706 /* Use a control ping for synchronization */
20707 MPING (CONTROL_PING, mp_ping);
20714 static void vl_api_ip_neighbor_details_t_handler
20715 (vl_api_ip_neighbor_details_t * mp)
20717 vat_main_t *vam = &vat_main;
20719 print (vam->ofp, "%c %U %U",
20720 (mp->is_static) ? 'S' : 'D',
20721 format_ethernet_address, &mp->mac_address,
20722 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
20726 static void vl_api_ip_neighbor_details_t_handler_json
20727 (vl_api_ip_neighbor_details_t * mp)
20730 vat_main_t *vam = &vat_main;
20731 vat_json_node_t *node;
20732 struct in_addr ip4;
20733 struct in6_addr ip6;
20735 if (VAT_JSON_ARRAY != vam->json_tree.type)
20737 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20738 vat_json_init_array (&vam->json_tree);
20740 node = vat_json_array_add (&vam->json_tree);
20742 vat_json_init_object (node);
20743 vat_json_object_add_string_copy (node, "flag",
20744 (mp->is_static) ? (u8 *) "static" : (u8 *)
20747 vat_json_object_add_string_copy (node, "link_layer",
20748 format (0, "%U", format_ethernet_address,
20749 &mp->mac_address));
20753 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
20754 vat_json_object_add_ip6 (node, "ip_address", ip6);
20758 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
20759 vat_json_object_add_ip4 (node, "ip_address", ip4);
20764 api_ip_neighbor_dump (vat_main_t * vam)
20766 unformat_input_t *i = vam->input;
20767 vl_api_ip_neighbor_dump_t *mp;
20768 vl_api_control_ping_t *mp_ping;
20770 u32 sw_if_index = ~0;
20773 /* Parse args required to build the message */
20774 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20776 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20778 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20780 else if (unformat (i, "ip6"))
20786 if (sw_if_index == ~0)
20788 errmsg ("missing interface name or sw_if_index");
20792 M (IP_NEIGHBOR_DUMP, mp);
20793 mp->is_ipv6 = (u8) is_ipv6;
20794 mp->sw_if_index = ntohl (sw_if_index);
20797 /* Use a control ping for synchronization */
20798 MPING (CONTROL_PING, mp_ping);
20805 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
20806 #define vl_api_ip6_fib_details_t_print vl_noop_handler
20809 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
20811 vat_main_t *vam = &vat_main;
20812 int count = ntohl (mp->count);
20813 vl_api_fib_path_t *fp;
20817 "table-id %d, prefix %U/%d stats-index %d",
20818 ntohl (mp->table_id), format_ip6_address, mp->address,
20819 mp->address_length, ntohl (mp->stats_index));
20821 for (i = 0; i < count; i++)
20823 if (fp->afi == IP46_TYPE_IP6)
20825 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20826 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20827 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20828 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20829 format_ip6_address, fp->next_hop);
20830 else if (fp->afi == IP46_TYPE_IP4)
20832 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20833 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20834 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20835 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20836 format_ip4_address, fp->next_hop);
20841 static void vl_api_ip6_fib_details_t_handler_json
20842 (vl_api_ip6_fib_details_t * mp)
20844 vat_main_t *vam = &vat_main;
20845 int count = ntohl (mp->count);
20846 vat_json_node_t *node = NULL;
20847 struct in_addr ip4;
20848 struct in6_addr ip6;
20849 vl_api_fib_path_t *fp;
20852 if (VAT_JSON_ARRAY != vam->json_tree.type)
20854 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20855 vat_json_init_array (&vam->json_tree);
20857 node = vat_json_array_add (&vam->json_tree);
20859 vat_json_init_object (node);
20860 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20861 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
20862 vat_json_object_add_ip6 (node, "prefix", ip6);
20863 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20864 vat_json_object_add_uint (node, "path_count", count);
20866 for (i = 0; i < count; i++)
20868 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20869 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20870 vat_json_object_add_uint (node, "is_local", fp->is_local);
20871 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20872 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20873 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20874 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20875 if (fp->afi == IP46_TYPE_IP4)
20877 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20878 vat_json_object_add_ip4 (node, "next_hop", ip4);
20880 else if (fp->afi == IP46_TYPE_IP6)
20882 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20883 vat_json_object_add_ip6 (node, "next_hop", ip6);
20889 api_ip6_fib_dump (vat_main_t * vam)
20891 vl_api_ip6_fib_dump_t *mp;
20892 vl_api_control_ping_t *mp_ping;
20895 M (IP6_FIB_DUMP, mp);
20898 /* Use a control ping for synchronization */
20899 MPING (CONTROL_PING, mp_ping);
20907 api_ip6_mfib_dump (vat_main_t * vam)
20909 vl_api_ip6_mfib_dump_t *mp;
20910 vl_api_control_ping_t *mp_ping;
20913 M (IP6_MFIB_DUMP, mp);
20916 /* Use a control ping for synchronization */
20917 MPING (CONTROL_PING, mp_ping);
20925 api_classify_table_ids (vat_main_t * vam)
20927 vl_api_classify_table_ids_t *mp;
20930 /* Construct the API message */
20931 M (CLASSIFY_TABLE_IDS, mp);
20940 api_classify_table_by_interface (vat_main_t * vam)
20942 unformat_input_t *input = vam->input;
20943 vl_api_classify_table_by_interface_t *mp;
20945 u32 sw_if_index = ~0;
20947 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20949 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20951 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20956 if (sw_if_index == ~0)
20958 errmsg ("missing interface name or sw_if_index");
20962 /* Construct the API message */
20963 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
20965 mp->sw_if_index = ntohl (sw_if_index);
20973 api_classify_table_info (vat_main_t * vam)
20975 unformat_input_t *input = vam->input;
20976 vl_api_classify_table_info_t *mp;
20980 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20982 if (unformat (input, "table_id %d", &table_id))
20987 if (table_id == ~0)
20989 errmsg ("missing table id");
20993 /* Construct the API message */
20994 M (CLASSIFY_TABLE_INFO, mp);
20996 mp->table_id = ntohl (table_id);
21004 api_classify_session_dump (vat_main_t * vam)
21006 unformat_input_t *input = vam->input;
21007 vl_api_classify_session_dump_t *mp;
21008 vl_api_control_ping_t *mp_ping;
21012 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21014 if (unformat (input, "table_id %d", &table_id))
21019 if (table_id == ~0)
21021 errmsg ("missing table id");
21025 /* Construct the API message */
21026 M (CLASSIFY_SESSION_DUMP, mp);
21028 mp->table_id = ntohl (table_id);
21031 /* Use a control ping for synchronization */
21032 MPING (CONTROL_PING, mp_ping);
21040 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
21042 vat_main_t *vam = &vat_main;
21044 print (vam->ofp, "collector_address %U, collector_port %d, "
21045 "src_address %U, vrf_id %d, path_mtu %u, "
21046 "template_interval %u, udp_checksum %d",
21047 format_ip4_address, mp->collector_address,
21048 ntohs (mp->collector_port),
21049 format_ip4_address, mp->src_address,
21050 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
21051 ntohl (mp->template_interval), mp->udp_checksum);
21054 vam->result_ready = 1;
21058 vl_api_ipfix_exporter_details_t_handler_json
21059 (vl_api_ipfix_exporter_details_t * mp)
21061 vat_main_t *vam = &vat_main;
21062 vat_json_node_t node;
21063 struct in_addr collector_address;
21064 struct in_addr src_address;
21066 vat_json_init_object (&node);
21067 clib_memcpy (&collector_address, &mp->collector_address,
21068 sizeof (collector_address));
21069 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
21070 vat_json_object_add_uint (&node, "collector_port",
21071 ntohs (mp->collector_port));
21072 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
21073 vat_json_object_add_ip4 (&node, "src_address", src_address);
21074 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
21075 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
21076 vat_json_object_add_uint (&node, "template_interval",
21077 ntohl (mp->template_interval));
21078 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
21080 vat_json_print (vam->ofp, &node);
21081 vat_json_free (&node);
21083 vam->result_ready = 1;
21087 api_ipfix_exporter_dump (vat_main_t * vam)
21089 vl_api_ipfix_exporter_dump_t *mp;
21092 /* Construct the API message */
21093 M (IPFIX_EXPORTER_DUMP, mp);
21102 api_ipfix_classify_stream_dump (vat_main_t * vam)
21104 vl_api_ipfix_classify_stream_dump_t *mp;
21107 /* Construct the API message */
21108 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
21119 vl_api_ipfix_classify_stream_details_t_handler
21120 (vl_api_ipfix_classify_stream_details_t * mp)
21122 vat_main_t *vam = &vat_main;
21123 print (vam->ofp, "domain_id %d, src_port %d",
21124 ntohl (mp->domain_id), ntohs (mp->src_port));
21126 vam->result_ready = 1;
21130 vl_api_ipfix_classify_stream_details_t_handler_json
21131 (vl_api_ipfix_classify_stream_details_t * mp)
21133 vat_main_t *vam = &vat_main;
21134 vat_json_node_t node;
21136 vat_json_init_object (&node);
21137 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
21138 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
21140 vat_json_print (vam->ofp, &node);
21141 vat_json_free (&node);
21143 vam->result_ready = 1;
21147 api_ipfix_classify_table_dump (vat_main_t * vam)
21149 vl_api_ipfix_classify_table_dump_t *mp;
21150 vl_api_control_ping_t *mp_ping;
21153 if (!vam->json_output)
21155 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
21156 "transport_protocol");
21159 /* Construct the API message */
21160 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
21165 /* Use a control ping for synchronization */
21166 MPING (CONTROL_PING, mp_ping);
21174 vl_api_ipfix_classify_table_details_t_handler
21175 (vl_api_ipfix_classify_table_details_t * mp)
21177 vat_main_t *vam = &vat_main;
21178 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
21179 mp->transport_protocol);
21183 vl_api_ipfix_classify_table_details_t_handler_json
21184 (vl_api_ipfix_classify_table_details_t * mp)
21186 vat_json_node_t *node = NULL;
21187 vat_main_t *vam = &vat_main;
21189 if (VAT_JSON_ARRAY != vam->json_tree.type)
21191 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21192 vat_json_init_array (&vam->json_tree);
21195 node = vat_json_array_add (&vam->json_tree);
21196 vat_json_init_object (node);
21198 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
21199 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
21200 vat_json_object_add_uint (node, "transport_protocol",
21201 mp->transport_protocol);
21205 api_sw_interface_span_enable_disable (vat_main_t * vam)
21207 unformat_input_t *i = vam->input;
21208 vl_api_sw_interface_span_enable_disable_t *mp;
21209 u32 src_sw_if_index = ~0;
21210 u32 dst_sw_if_index = ~0;
21215 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21218 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
21220 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
21224 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
21226 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
21228 else if (unformat (i, "disable"))
21230 else if (unformat (i, "rx"))
21232 else if (unformat (i, "tx"))
21234 else if (unformat (i, "both"))
21236 else if (unformat (i, "l2"))
21242 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
21244 mp->sw_if_index_from = htonl (src_sw_if_index);
21245 mp->sw_if_index_to = htonl (dst_sw_if_index);
21255 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
21258 vat_main_t *vam = &vat_main;
21259 u8 *sw_if_from_name = 0;
21260 u8 *sw_if_to_name = 0;
21261 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
21262 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
21263 char *states[] = { "none", "rx", "tx", "both" };
21267 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
21269 if ((u32) p->value[0] == sw_if_index_from)
21271 sw_if_from_name = (u8 *)(p->key);
21275 if ((u32) p->value[0] == sw_if_index_to)
21277 sw_if_to_name = (u8 *)(p->key);
21278 if (sw_if_from_name)
21283 print (vam->ofp, "%20s => %20s (%s) %s",
21284 sw_if_from_name, sw_if_to_name, states[mp->state],
21285 mp->is_l2 ? "l2" : "device");
21289 vl_api_sw_interface_span_details_t_handler_json
21290 (vl_api_sw_interface_span_details_t * mp)
21292 vat_main_t *vam = &vat_main;
21293 vat_json_node_t *node = NULL;
21294 u8 *sw_if_from_name = 0;
21295 u8 *sw_if_to_name = 0;
21296 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
21297 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
21301 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
21303 if ((u32) p->value[0] == sw_if_index_from)
21305 sw_if_from_name = (u8 *)(p->key);
21309 if ((u32) p->value[0] == sw_if_index_to)
21311 sw_if_to_name = (u8 *)(p->key);
21312 if (sw_if_from_name)
21318 if (VAT_JSON_ARRAY != vam->json_tree.type)
21320 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21321 vat_json_init_array (&vam->json_tree);
21323 node = vat_json_array_add (&vam->json_tree);
21325 vat_json_init_object (node);
21326 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
21327 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
21328 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
21329 if (0 != sw_if_to_name)
21331 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
21333 vat_json_object_add_uint (node, "state", mp->state);
21334 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
21338 api_sw_interface_span_dump (vat_main_t * vam)
21340 unformat_input_t *input = vam->input;
21341 vl_api_sw_interface_span_dump_t *mp;
21342 vl_api_control_ping_t *mp_ping;
21346 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21348 if (unformat (input, "l2"))
21354 M (SW_INTERFACE_SPAN_DUMP, mp);
21358 /* Use a control ping for synchronization */
21359 MPING (CONTROL_PING, mp_ping);
21367 api_pg_create_interface (vat_main_t * vam)
21369 unformat_input_t *input = vam->input;
21370 vl_api_pg_create_interface_t *mp;
21374 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21376 if (unformat (input, "if_id %d", &if_id))
21383 errmsg ("missing pg interface index");
21387 /* Construct the API message */
21388 M (PG_CREATE_INTERFACE, mp);
21390 mp->interface_id = ntohl (if_id);
21398 api_pg_capture (vat_main_t * vam)
21400 unformat_input_t *input = vam->input;
21401 vl_api_pg_capture_t *mp;
21406 u8 pcap_file_set = 0;
21409 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21411 if (unformat (input, "if_id %d", &if_id))
21413 else if (unformat (input, "pcap %s", &pcap_file))
21415 else if (unformat (input, "count %d", &count))
21417 else if (unformat (input, "disable"))
21424 errmsg ("missing pg interface index");
21427 if (pcap_file_set > 0)
21429 if (vec_len (pcap_file) > 255)
21431 errmsg ("pcap file name is too long");
21436 u32 name_len = vec_len (pcap_file);
21437 /* Construct the API message */
21438 M (PG_CAPTURE, mp);
21440 mp->interface_id = ntohl (if_id);
21441 mp->is_enabled = enable;
21442 mp->count = ntohl (count);
21443 mp->pcap_name_length = ntohl (name_len);
21444 if (pcap_file_set != 0)
21446 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
21448 vec_free (pcap_file);
21456 api_pg_enable_disable (vat_main_t * vam)
21458 unformat_input_t *input = vam->input;
21459 vl_api_pg_enable_disable_t *mp;
21462 u8 stream_name_set = 0;
21463 u8 *stream_name = 0;
21465 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21467 if (unformat (input, "stream %s", &stream_name))
21468 stream_name_set = 1;
21469 else if (unformat (input, "disable"))
21475 if (stream_name_set > 0)
21477 if (vec_len (stream_name) > 255)
21479 errmsg ("stream name too long");
21484 u32 name_len = vec_len (stream_name);
21485 /* Construct the API message */
21486 M (PG_ENABLE_DISABLE, mp);
21488 mp->is_enabled = enable;
21489 if (stream_name_set != 0)
21491 mp->stream_name_length = ntohl (name_len);
21492 clib_memcpy (mp->stream_name, stream_name, name_len);
21494 vec_free (stream_name);
21502 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
21504 unformat_input_t *input = vam->input;
21505 vl_api_ip_source_and_port_range_check_add_del_t *mp;
21507 u16 *low_ports = 0;
21508 u16 *high_ports = 0;
21511 ip4_address_t ip4_addr;
21512 ip6_address_t ip6_addr;
21521 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21523 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
21529 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
21534 else if (unformat (input, "vrf %d", &vrf_id))
21536 else if (unformat (input, "del"))
21538 else if (unformat (input, "port %d", &tmp))
21540 if (tmp == 0 || tmp > 65535)
21542 errmsg ("port %d out of range", tmp);
21546 this_hi = this_low + 1;
21547 vec_add1 (low_ports, this_low);
21548 vec_add1 (high_ports, this_hi);
21550 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
21552 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
21554 errmsg ("incorrect range parameters");
21558 /* Note: in debug CLI +1 is added to high before
21559 passing to real fn that does "the work"
21560 (ip_source_and_port_range_check_add_del).
21561 This fn is a wrapper around the binary API fn a
21562 control plane will call, which expects this increment
21563 to have occurred. Hence letting the binary API control
21564 plane fn do the increment for consistency between VAT
21565 and other control planes.
21568 vec_add1 (low_ports, this_low);
21569 vec_add1 (high_ports, this_hi);
21575 if (prefix_set == 0)
21577 errmsg ("<address>/<mask> not specified");
21583 errmsg ("VRF ID required, not specified");
21590 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21594 if (vec_len (low_ports) == 0)
21596 errmsg ("At least one port or port range required");
21600 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
21602 mp->is_add = is_add;
21607 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
21612 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
21615 mp->mask_length = length;
21616 mp->number_of_ranges = vec_len (low_ports);
21618 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
21619 vec_free (low_ports);
21621 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
21622 vec_free (high_ports);
21624 mp->vrf_id = ntohl (vrf_id);
21632 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
21634 unformat_input_t *input = vam->input;
21635 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
21636 u32 sw_if_index = ~0;
21638 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
21639 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
21643 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21645 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21647 else if (unformat (input, "sw_if_index %d", &sw_if_index))
21649 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
21651 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
21653 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
21655 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
21657 else if (unformat (input, "del"))
21663 if (sw_if_index == ~0)
21665 errmsg ("Interface required but not specified");
21671 errmsg ("VRF ID required but not specified");
21675 if (tcp_out_vrf_id == 0
21676 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
21679 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21683 /* Construct the API message */
21684 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
21686 mp->sw_if_index = ntohl (sw_if_index);
21687 mp->is_add = is_add;
21688 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
21689 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
21690 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
21691 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
21696 /* Wait for a reply... */
21702 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
21704 unformat_input_t *i = vam->input;
21705 vl_api_ipsec_gre_add_del_tunnel_t *mp;
21706 u32 local_sa_id = 0;
21707 u32 remote_sa_id = 0;
21708 ip4_address_t src_address;
21709 ip4_address_t dst_address;
21713 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21715 if (unformat (i, "local_sa %d", &local_sa_id))
21717 else if (unformat (i, "remote_sa %d", &remote_sa_id))
21719 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
21721 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
21723 else if (unformat (i, "del"))
21727 clib_warning ("parse error '%U'", format_unformat_error, i);
21732 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
21734 mp->local_sa_id = ntohl (local_sa_id);
21735 mp->remote_sa_id = ntohl (remote_sa_id);
21736 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
21737 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
21738 mp->is_add = is_add;
21746 api_punt (vat_main_t * vam)
21748 unformat_input_t *i = vam->input;
21756 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21758 if (unformat (i, "ip %d", &ipv))
21760 else if (unformat (i, "protocol %d", &protocol))
21762 else if (unformat (i, "port %d", &port))
21764 else if (unformat (i, "del"))
21768 clib_warning ("parse error '%U'", format_unformat_error, i);
21775 mp->is_add = (u8) is_add;
21776 mp->ipv = (u8) ipv;
21777 mp->l4_protocol = (u8) protocol;
21778 mp->l4_port = htons ((u16) port);
21785 static void vl_api_ipsec_gre_tunnel_details_t_handler
21786 (vl_api_ipsec_gre_tunnel_details_t * mp)
21788 vat_main_t *vam = &vat_main;
21790 print (vam->ofp, "%11d%15U%15U%14d%14d",
21791 ntohl (mp->sw_if_index),
21792 format_ip4_address, &mp->src_address,
21793 format_ip4_address, &mp->dst_address,
21794 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
21797 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
21798 (vl_api_ipsec_gre_tunnel_details_t * mp)
21800 vat_main_t *vam = &vat_main;
21801 vat_json_node_t *node = NULL;
21802 struct in_addr ip4;
21804 if (VAT_JSON_ARRAY != vam->json_tree.type)
21806 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21807 vat_json_init_array (&vam->json_tree);
21809 node = vat_json_array_add (&vam->json_tree);
21811 vat_json_init_object (node);
21812 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
21813 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
21814 vat_json_object_add_ip4 (node, "src_address", ip4);
21815 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
21816 vat_json_object_add_ip4 (node, "dst_address", ip4);
21817 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
21818 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
21822 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
21824 unformat_input_t *i = vam->input;
21825 vl_api_ipsec_gre_tunnel_dump_t *mp;
21826 vl_api_control_ping_t *mp_ping;
21828 u8 sw_if_index_set = 0;
21831 /* Parse args required to build the message */
21832 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21834 if (unformat (i, "sw_if_index %d", &sw_if_index))
21835 sw_if_index_set = 1;
21840 if (sw_if_index_set == 0)
21845 if (!vam->json_output)
21847 print (vam->ofp, "%11s%15s%15s%14s%14s",
21848 "sw_if_index", "src_address", "dst_address",
21849 "local_sa_id", "remote_sa_id");
21852 /* Get list of gre-tunnel interfaces */
21853 M (IPSEC_GRE_TUNNEL_DUMP, mp);
21855 mp->sw_if_index = htonl (sw_if_index);
21859 /* Use a control ping for synchronization */
21860 MPING (CONTROL_PING, mp_ping);
21868 api_delete_subif (vat_main_t * vam)
21870 unformat_input_t *i = vam->input;
21871 vl_api_delete_subif_t *mp;
21872 u32 sw_if_index = ~0;
21875 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21877 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21879 if (unformat (i, "sw_if_index %d", &sw_if_index))
21885 if (sw_if_index == ~0)
21887 errmsg ("missing sw_if_index");
21891 /* Construct the API message */
21892 M (DELETE_SUBIF, mp);
21893 mp->sw_if_index = ntohl (sw_if_index);
21900 #define foreach_pbb_vtr_op \
21901 _("disable", L2_VTR_DISABLED) \
21902 _("pop", L2_VTR_POP_2) \
21903 _("push", L2_VTR_PUSH_2)
21906 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
21908 unformat_input_t *i = vam->input;
21909 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
21910 u32 sw_if_index = ~0, vtr_op = ~0;
21911 u16 outer_tag = ~0;
21912 u8 dmac[6], smac[6];
21913 u8 dmac_set = 0, smac_set = 0;
21919 /* Shut up coverity */
21920 memset (dmac, 0, sizeof (dmac));
21921 memset (smac, 0, sizeof (smac));
21923 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21925 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21927 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21929 else if (unformat (i, "vtr_op %d", &vtr_op))
21931 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
21934 else if (unformat (i, "translate_pbb_stag"))
21936 if (unformat (i, "%d", &tmp))
21938 vtr_op = L2_VTR_TRANSLATE_2_1;
21944 ("translate_pbb_stag operation requires outer tag definition");
21948 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
21950 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
21952 else if (unformat (i, "sid %d", &sid))
21954 else if (unformat (i, "vlanid %d", &tmp))
21958 clib_warning ("parse error '%U'", format_unformat_error, i);
21963 if ((sw_if_index == ~0) || (vtr_op == ~0))
21965 errmsg ("missing sw_if_index or vtr operation");
21968 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
21969 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
21972 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
21976 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
21977 mp->sw_if_index = ntohl (sw_if_index);
21978 mp->vtr_op = ntohl (vtr_op);
21979 mp->outer_tag = ntohs (outer_tag);
21980 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
21981 clib_memcpy (mp->b_smac, smac, sizeof (smac));
21982 mp->b_vlanid = ntohs (vlanid);
21983 mp->i_sid = ntohl (sid);
21991 api_flow_classify_set_interface (vat_main_t * vam)
21993 unformat_input_t *i = vam->input;
21994 vl_api_flow_classify_set_interface_t *mp;
21996 int sw_if_index_set;
21997 u32 ip4_table_index = ~0;
21998 u32 ip6_table_index = ~0;
22002 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22004 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22005 sw_if_index_set = 1;
22006 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22007 sw_if_index_set = 1;
22008 else if (unformat (i, "del"))
22010 else if (unformat (i, "ip4-table %d", &ip4_table_index))
22012 else if (unformat (i, "ip6-table %d", &ip6_table_index))
22016 clib_warning ("parse error '%U'", format_unformat_error, i);
22021 if (sw_if_index_set == 0)
22023 errmsg ("missing interface name or sw_if_index");
22027 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
22029 mp->sw_if_index = ntohl (sw_if_index);
22030 mp->ip4_table_index = ntohl (ip4_table_index);
22031 mp->ip6_table_index = ntohl (ip6_table_index);
22032 mp->is_add = is_add;
22040 api_flow_classify_dump (vat_main_t * vam)
22042 unformat_input_t *i = vam->input;
22043 vl_api_flow_classify_dump_t *mp;
22044 vl_api_control_ping_t *mp_ping;
22045 u8 type = FLOW_CLASSIFY_N_TABLES;
22048 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
22052 errmsg ("classify table type must be specified");
22056 if (!vam->json_output)
22058 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
22061 M (FLOW_CLASSIFY_DUMP, mp);
22066 /* Use a control ping for synchronization */
22067 MPING (CONTROL_PING, mp_ping);
22070 /* Wait for a reply... */
22076 api_feature_enable_disable (vat_main_t * vam)
22078 unformat_input_t *i = vam->input;
22079 vl_api_feature_enable_disable_t *mp;
22081 u8 *feature_name = 0;
22082 u32 sw_if_index = ~0;
22086 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22088 if (unformat (i, "arc_name %s", &arc_name))
22090 else if (unformat (i, "feature_name %s", &feature_name))
22093 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22095 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22097 else if (unformat (i, "disable"))
22105 errmsg ("missing arc name");
22108 if (vec_len (arc_name) > 63)
22110 errmsg ("arc name too long");
22113 if (feature_name == 0)
22115 errmsg ("missing feature name");
22118 if (vec_len (feature_name) > 63)
22120 errmsg ("feature name too long");
22123 if (sw_if_index == ~0)
22125 errmsg ("missing interface name or sw_if_index");
22129 /* Construct the API message */
22130 M (FEATURE_ENABLE_DISABLE, mp);
22131 mp->sw_if_index = ntohl (sw_if_index);
22132 mp->enable = enable;
22133 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
22134 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
22135 vec_free (arc_name);
22136 vec_free (feature_name);
22144 api_sw_interface_tag_add_del (vat_main_t * vam)
22146 unformat_input_t *i = vam->input;
22147 vl_api_sw_interface_tag_add_del_t *mp;
22148 u32 sw_if_index = ~0;
22153 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22155 if (unformat (i, "tag %s", &tag))
22157 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22159 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22161 else if (unformat (i, "del"))
22167 if (sw_if_index == ~0)
22169 errmsg ("missing interface name or sw_if_index");
22173 if (enable && (tag == 0))
22175 errmsg ("no tag specified");
22179 /* Construct the API message */
22180 M (SW_INTERFACE_TAG_ADD_DEL, mp);
22181 mp->sw_if_index = ntohl (sw_if_index);
22182 mp->is_add = enable;
22184 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
22192 static void vl_api_l2_xconnect_details_t_handler
22193 (vl_api_l2_xconnect_details_t * mp)
22195 vat_main_t *vam = &vat_main;
22197 print (vam->ofp, "%15d%15d",
22198 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
22201 static void vl_api_l2_xconnect_details_t_handler_json
22202 (vl_api_l2_xconnect_details_t * mp)
22204 vat_main_t *vam = &vat_main;
22205 vat_json_node_t *node = NULL;
22207 if (VAT_JSON_ARRAY != vam->json_tree.type)
22209 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22210 vat_json_init_array (&vam->json_tree);
22212 node = vat_json_array_add (&vam->json_tree);
22214 vat_json_init_object (node);
22215 vat_json_object_add_uint (node, "rx_sw_if_index",
22216 ntohl (mp->rx_sw_if_index));
22217 vat_json_object_add_uint (node, "tx_sw_if_index",
22218 ntohl (mp->tx_sw_if_index));
22222 api_l2_xconnect_dump (vat_main_t * vam)
22224 vl_api_l2_xconnect_dump_t *mp;
22225 vl_api_control_ping_t *mp_ping;
22228 if (!vam->json_output)
22230 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
22233 M (L2_XCONNECT_DUMP, mp);
22237 /* Use a control ping for synchronization */
22238 MPING (CONTROL_PING, mp_ping);
22246 api_hw_interface_set_mtu (vat_main_t * vam)
22248 unformat_input_t *i = vam->input;
22249 vl_api_hw_interface_set_mtu_t *mp;
22250 u32 sw_if_index = ~0;
22254 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22256 if (unformat (i, "mtu %d", &mtu))
22258 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22260 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22266 if (sw_if_index == ~0)
22268 errmsg ("missing interface name or sw_if_index");
22274 errmsg ("no mtu specified");
22278 /* Construct the API message */
22279 M (HW_INTERFACE_SET_MTU, mp);
22280 mp->sw_if_index = ntohl (sw_if_index);
22281 mp->mtu = ntohs ((u16) mtu);
22289 api_p2p_ethernet_add (vat_main_t * vam)
22291 unformat_input_t *i = vam->input;
22292 vl_api_p2p_ethernet_add_t *mp;
22293 u32 parent_if_index = ~0;
22299 memset (remote_mac, 0, sizeof (remote_mac));
22300 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22302 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
22304 else if (unformat (i, "sw_if_index %d", &parent_if_index))
22308 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
22310 else if (unformat (i, "sub_id %d", &sub_id))
22314 clib_warning ("parse error '%U'", format_unformat_error, i);
22319 if (parent_if_index == ~0)
22321 errmsg ("missing interface name or sw_if_index");
22326 errmsg ("missing remote mac address");
22331 errmsg ("missing sub-interface id");
22335 M (P2P_ETHERNET_ADD, mp);
22336 mp->parent_if_index = ntohl (parent_if_index);
22337 mp->subif_id = ntohl (sub_id);
22338 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22346 api_p2p_ethernet_del (vat_main_t * vam)
22348 unformat_input_t *i = vam->input;
22349 vl_api_p2p_ethernet_del_t *mp;
22350 u32 parent_if_index = ~0;
22355 memset (remote_mac, 0, sizeof (remote_mac));
22356 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22358 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
22360 else if (unformat (i, "sw_if_index %d", &parent_if_index))
22364 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
22368 clib_warning ("parse error '%U'", format_unformat_error, i);
22373 if (parent_if_index == ~0)
22375 errmsg ("missing interface name or sw_if_index");
22380 errmsg ("missing remote mac address");
22384 M (P2P_ETHERNET_DEL, mp);
22385 mp->parent_if_index = ntohl (parent_if_index);
22386 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22394 api_lldp_config (vat_main_t * vam)
22396 unformat_input_t *i = vam->input;
22397 vl_api_lldp_config_t *mp;
22399 int tx_interval = 0;
22400 u8 *sys_name = NULL;
22403 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22405 if (unformat (i, "system-name %s", &sys_name))
22407 else if (unformat (i, "tx-hold %d", &tx_hold))
22409 else if (unformat (i, "tx-interval %d", &tx_interval))
22413 clib_warning ("parse error '%U'", format_unformat_error, i);
22418 vec_add1 (sys_name, 0);
22420 M (LLDP_CONFIG, mp);
22421 mp->tx_hold = htonl (tx_hold);
22422 mp->tx_interval = htonl (tx_interval);
22423 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
22424 vec_free (sys_name);
22432 api_sw_interface_set_lldp (vat_main_t * vam)
22434 unformat_input_t *i = vam->input;
22435 vl_api_sw_interface_set_lldp_t *mp;
22436 u32 sw_if_index = ~0;
22438 u8 *port_desc = NULL, *mgmt_oid = NULL;
22439 ip4_address_t ip4_addr;
22440 ip6_address_t ip6_addr;
22443 memset (&ip4_addr, 0, sizeof (ip4_addr));
22444 memset (&ip6_addr, 0, sizeof (ip6_addr));
22446 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22448 if (unformat (i, "disable"))
22451 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22453 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22455 else if (unformat (i, "port-desc %s", &port_desc))
22457 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
22459 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
22461 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
22467 if (sw_if_index == ~0)
22469 errmsg ("missing interface name or sw_if_index");
22473 /* Construct the API message */
22474 vec_add1 (port_desc, 0);
22475 vec_add1 (mgmt_oid, 0);
22476 M (SW_INTERFACE_SET_LLDP, mp);
22477 mp->sw_if_index = ntohl (sw_if_index);
22478 mp->enable = enable;
22479 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
22480 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
22481 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
22482 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
22483 vec_free (port_desc);
22484 vec_free (mgmt_oid);
22492 api_tcp_configure_src_addresses (vat_main_t * vam)
22494 vl_api_tcp_configure_src_addresses_t *mp;
22495 unformat_input_t *i = vam->input;
22496 ip4_address_t v4first, v4last;
22497 ip6_address_t v6first, v6last;
22502 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22504 if (unformat (i, "%U - %U",
22505 unformat_ip4_address, &v4first,
22506 unformat_ip4_address, &v4last))
22510 errmsg ("one range per message (range already set)");
22515 else if (unformat (i, "%U - %U",
22516 unformat_ip6_address, &v6first,
22517 unformat_ip6_address, &v6last))
22521 errmsg ("one range per message (range already set)");
22526 else if (unformat (i, "vrf %d", &vrf_id))
22532 if (range_set == 0)
22534 errmsg ("address range not set");
22538 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
22539 mp->vrf_id = ntohl (vrf_id);
22541 if (range_set == 2)
22544 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
22545 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
22550 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
22551 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
22558 static void vl_api_app_namespace_add_del_reply_t_handler
22559 (vl_api_app_namespace_add_del_reply_t * mp)
22561 vat_main_t *vam = &vat_main;
22562 i32 retval = ntohl (mp->retval);
22563 if (vam->async_mode)
22565 vam->async_errors += (retval < 0);
22569 vam->retval = retval;
22571 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
22572 vam->result_ready = 1;
22576 static void vl_api_app_namespace_add_del_reply_t_handler_json
22577 (vl_api_app_namespace_add_del_reply_t * mp)
22579 vat_main_t *vam = &vat_main;
22580 vat_json_node_t node;
22582 vat_json_init_object (&node);
22583 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
22584 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
22586 vat_json_print (vam->ofp, &node);
22587 vat_json_free (&node);
22589 vam->retval = ntohl (mp->retval);
22590 vam->result_ready = 1;
22594 api_app_namespace_add_del (vat_main_t * vam)
22596 vl_api_app_namespace_add_del_t *mp;
22597 unformat_input_t *i = vam->input;
22598 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
22599 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
22603 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22605 if (unformat (i, "id %_%v%_", &ns_id))
22607 else if (unformat (i, "secret %lu", &secret))
22609 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22610 sw_if_index_set = 1;
22611 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
22613 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
22618 if (!ns_id || !secret_set || !sw_if_index_set)
22620 errmsg ("namespace id, secret and sw_if_index must be set");
22623 if (vec_len (ns_id) > 64)
22625 errmsg ("namespace id too long");
22628 M (APP_NAMESPACE_ADD_DEL, mp);
22630 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
22631 mp->namespace_id_len = vec_len (ns_id);
22632 mp->secret = clib_host_to_net_u64 (secret);
22633 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
22634 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
22635 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
22643 api_sock_init_shm (vat_main_t * vam)
22645 #if VPP_API_TEST_BUILTIN == 0
22646 unformat_input_t *i = vam->input;
22647 vl_api_shm_elem_config_t *config = 0;
22648 u64 size = 64 << 20;
22651 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22653 if (unformat (i, "size %U", unformat_memory_size, &size))
22660 * Canned custom ring allocator config.
22661 * Should probably parse all of this
22663 vec_validate (config, 6);
22664 config[0].type = VL_API_VLIB_RING;
22665 config[0].size = 256;
22666 config[0].count = 32;
22668 config[1].type = VL_API_VLIB_RING;
22669 config[1].size = 1024;
22670 config[1].count = 16;
22672 config[2].type = VL_API_VLIB_RING;
22673 config[2].size = 4096;
22674 config[2].count = 2;
22676 config[3].type = VL_API_CLIENT_RING;
22677 config[3].size = 256;
22678 config[3].count = 32;
22680 config[4].type = VL_API_CLIENT_RING;
22681 config[4].size = 1024;
22682 config[4].count = 16;
22684 config[5].type = VL_API_CLIENT_RING;
22685 config[5].size = 4096;
22686 config[5].count = 2;
22688 config[6].type = VL_API_QUEUE;
22689 config[6].count = 128;
22690 config[6].size = sizeof (uword);
22692 rv = vl_socket_client_init_shm (config);
22694 vam->client_index_invalid = 1;
22702 api_dns_enable_disable (vat_main_t * vam)
22704 unformat_input_t *line_input = vam->input;
22705 vl_api_dns_enable_disable_t *mp;
22706 u8 enable_disable = 1;
22709 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22711 if (unformat (line_input, "disable"))
22712 enable_disable = 0;
22713 if (unformat (line_input, "enable"))
22714 enable_disable = 1;
22719 /* Construct the API message */
22720 M (DNS_ENABLE_DISABLE, mp);
22721 mp->enable = enable_disable;
22725 /* Wait for the reply */
22731 api_dns_resolve_name (vat_main_t * vam)
22733 unformat_input_t *line_input = vam->input;
22734 vl_api_dns_resolve_name_t *mp;
22738 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22740 if (unformat (line_input, "%s", &name))
22746 if (vec_len (name) > 127)
22748 errmsg ("name too long");
22752 /* Construct the API message */
22753 M (DNS_RESOLVE_NAME, mp);
22754 memcpy (mp->name, name, vec_len (name));
22759 /* Wait for the reply */
22765 api_dns_resolve_ip (vat_main_t * vam)
22767 unformat_input_t *line_input = vam->input;
22768 vl_api_dns_resolve_ip_t *mp;
22770 ip4_address_t addr4;
22771 ip6_address_t addr6;
22774 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22776 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
22778 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
22786 errmsg ("missing address");
22790 /* Construct the API message */
22791 M (DNS_RESOLVE_IP, mp);
22792 mp->is_ip6 = is_ip6;
22794 memcpy (mp->address, &addr6, sizeof (addr6));
22796 memcpy (mp->address, &addr4, sizeof (addr4));
22800 /* Wait for the reply */
22806 api_dns_name_server_add_del (vat_main_t * vam)
22808 unformat_input_t *i = vam->input;
22809 vl_api_dns_name_server_add_del_t *mp;
22811 ip6_address_t ip6_server;
22812 ip4_address_t ip4_server;
22817 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22819 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
22821 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
22823 else if (unformat (i, "del"))
22827 clib_warning ("parse error '%U'", format_unformat_error, i);
22832 if (ip4_set && ip6_set)
22834 errmsg ("Only one server address allowed per message");
22837 if ((ip4_set + ip6_set) == 0)
22839 errmsg ("Server address required");
22843 /* Construct the API message */
22844 M (DNS_NAME_SERVER_ADD_DEL, mp);
22848 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
22853 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
22857 mp->is_add = is_add;
22862 /* Wait for a reply, return good/bad news */
22868 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
22870 vat_main_t *vam = &vat_main;
22875 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22876 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22877 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
22878 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
22879 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22880 clib_net_to_host_u32 (mp->action_index), mp->tag);
22885 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22886 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22887 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
22888 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
22889 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22890 clib_net_to_host_u32 (mp->action_index), mp->tag);
22895 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
22898 vat_main_t *vam = &vat_main;
22899 vat_json_node_t *node = NULL;
22900 struct in6_addr ip6;
22901 struct in_addr ip4;
22903 if (VAT_JSON_ARRAY != vam->json_tree.type)
22905 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22906 vat_json_init_array (&vam->json_tree);
22908 node = vat_json_array_add (&vam->json_tree);
22909 vat_json_init_object (node);
22911 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
22912 vat_json_object_add_uint (node, "appns_index",
22913 clib_net_to_host_u32 (mp->appns_index));
22914 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
22915 vat_json_object_add_uint (node, "scope", mp->scope);
22916 vat_json_object_add_uint (node, "action_index",
22917 clib_net_to_host_u32 (mp->action_index));
22918 vat_json_object_add_uint (node, "lcl_port",
22919 clib_net_to_host_u16 (mp->lcl_port));
22920 vat_json_object_add_uint (node, "rmt_port",
22921 clib_net_to_host_u16 (mp->rmt_port));
22922 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
22923 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
22924 vat_json_object_add_string_copy (node, "tag", mp->tag);
22927 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
22928 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
22929 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
22930 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
22934 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
22935 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
22936 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
22937 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
22942 api_session_rule_add_del (vat_main_t * vam)
22944 vl_api_session_rule_add_del_t *mp;
22945 unformat_input_t *i = vam->input;
22946 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
22947 u32 appns_index = 0, scope = 0;
22948 ip4_address_t lcl_ip4, rmt_ip4;
22949 ip6_address_t lcl_ip6, rmt_ip6;
22950 u8 is_ip4 = 1, conn_set = 0;
22951 u8 is_add = 1, *tag = 0;
22954 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22956 if (unformat (i, "del"))
22958 else if (unformat (i, "add"))
22960 else if (unformat (i, "proto tcp"))
22962 else if (unformat (i, "proto udp"))
22964 else if (unformat (i, "appns %d", &appns_index))
22966 else if (unformat (i, "scope %d", &scope))
22968 else if (unformat (i, "tag %_%v%_", &tag))
22972 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
22973 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
22981 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
22982 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
22988 else if (unformat (i, "action %d", &action))
22993 if (proto == ~0 || !conn_set || action == ~0)
22995 errmsg ("transport proto, connection and action must be set");
23001 errmsg ("scope should be 0-3");
23005 M (SESSION_RULE_ADD_DEL, mp);
23007 mp->is_ip4 = is_ip4;
23008 mp->transport_proto = proto;
23009 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
23010 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
23011 mp->lcl_plen = lcl_plen;
23012 mp->rmt_plen = rmt_plen;
23013 mp->action_index = clib_host_to_net_u32 (action);
23014 mp->appns_index = clib_host_to_net_u32 (appns_index);
23016 mp->is_add = is_add;
23019 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
23020 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
23024 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
23025 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
23029 clib_memcpy (mp->tag, tag, vec_len (tag));
23039 api_session_rules_dump (vat_main_t * vam)
23041 vl_api_session_rules_dump_t *mp;
23042 vl_api_control_ping_t *mp_ping;
23045 if (!vam->json_output)
23047 print (vam->ofp, "%=20s", "Session Rules");
23050 M (SESSION_RULES_DUMP, mp);
23054 /* Use a control ping for synchronization */
23055 MPING (CONTROL_PING, mp_ping);
23058 /* Wait for a reply... */
23064 api_ip_container_proxy_add_del (vat_main_t * vam)
23066 vl_api_ip_container_proxy_add_del_t *mp;
23067 unformat_input_t *i = vam->input;
23068 u32 plen = ~0, sw_if_index = ~0;
23075 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
23077 if (unformat (i, "del"))
23079 else if (unformat (i, "add"))
23081 if (unformat (i, "%U", unformat_ip4_address, &ip4))
23086 else if (unformat (i, "%U", unformat_ip6_address, &ip6))
23091 else if (unformat (i, "sw_if_index %u", &sw_if_index))
23096 if (sw_if_index == ~0 || plen == ~0)
23098 errmsg ("address and sw_if_index must be set");
23102 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
23104 mp->is_ip4 = is_ip4;
23105 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
23107 mp->is_add = is_add;
23109 clib_memcpy (mp->ip, &ip4, sizeof (ip4));
23111 clib_memcpy (mp->ip, &ip6, sizeof (ip6));
23119 api_qos_record_enable_disable (vat_main_t * vam)
23121 unformat_input_t *i = vam->input;
23122 vl_api_qos_record_enable_disable_t *mp;
23123 u32 sw_if_index, qs = 0xff;
23124 u8 sw_if_index_set = 0;
23128 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
23130 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
23131 sw_if_index_set = 1;
23132 else if (unformat (i, "sw_if_index %d", &sw_if_index))
23133 sw_if_index_set = 1;
23134 else if (unformat (i, "%U", unformat_qos_source, &qs))
23136 else if (unformat (i, "disable"))
23140 clib_warning ("parse error '%U'", format_unformat_error, i);
23145 if (sw_if_index_set == 0)
23147 errmsg ("missing interface name or sw_if_index");
23152 errmsg ("input location must be specified");
23156 M (QOS_RECORD_ENABLE_DISABLE, mp);
23158 mp->sw_if_index = ntohl (sw_if_index);
23159 mp->input_source = qs;
23160 mp->enable = enable;
23169 q_or_quit (vat_main_t * vam)
23171 #if VPP_API_TEST_BUILTIN == 0
23172 longjmp (vam->jump_buf, 1);
23174 return 0; /* not so much */
23178 q (vat_main_t * vam)
23180 return q_or_quit (vam);
23184 quit (vat_main_t * vam)
23186 return q_or_quit (vam);
23190 comment (vat_main_t * vam)
23196 statseg (vat_main_t * vam)
23198 ssvm_private_t *ssvmp = &vam->stat_segment;
23199 ssvm_shared_header_t *shared_header = ssvmp->sh;
23200 vlib_counter_t **counters;
23201 u64 thread0_index1_packets;
23202 u64 thread0_index1_bytes;
23203 f64 vector_rate, input_rate;
23206 uword *counter_vector_by_name;
23207 if (vam->stat_segment_lockp == 0)
23209 errmsg ("Stat segment not mapped...");
23213 /* look up "/if/rx for sw_if_index 1 as a test */
23215 clib_spinlock_lock (vam->stat_segment_lockp);
23217 counter_vector_by_name = (uword *) shared_header->opaque[1];
23219 p = hash_get_mem (counter_vector_by_name, "/if/rx");
23222 clib_spinlock_unlock (vam->stat_segment_lockp);
23223 errmsg ("/if/tx not found?");
23227 /* Fish per-thread vector of combined counters from shared memory */
23228 counters = (vlib_counter_t **) p[0];
23230 if (vec_len (counters[0]) < 2)
23232 clib_spinlock_unlock (vam->stat_segment_lockp);
23233 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
23237 /* Read thread 0 sw_if_index 1 counter */
23238 thread0_index1_packets = counters[0][1].packets;
23239 thread0_index1_bytes = counters[0][1].bytes;
23241 p = hash_get_mem (counter_vector_by_name, "vector_rate");
23244 clib_spinlock_unlock (vam->stat_segment_lockp);
23245 errmsg ("vector_rate not found?");
23249 vector_rate = *(f64 *) (p[0]);
23250 p = hash_get_mem (counter_vector_by_name, "input_rate");
23253 clib_spinlock_unlock (vam->stat_segment_lockp);
23254 errmsg ("input_rate not found?");
23257 input_rate = *(f64 *) (p[0]);
23259 clib_spinlock_unlock (vam->stat_segment_lockp);
23261 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
23262 vector_rate, input_rate);
23263 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
23264 thread0_index1_packets, thread0_index1_bytes);
23270 cmd_cmp (void *a1, void *a2)
23275 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
23279 help (vat_main_t * vam)
23284 unformat_input_t *i = vam->input;
23287 if (unformat (i, "%s", &name))
23291 vec_add1 (name, 0);
23293 hs = hash_get_mem (vam->help_by_name, name);
23295 print (vam->ofp, "usage: %s %s", name, hs[0]);
23297 print (vam->ofp, "No such msg / command '%s'", name);
23302 print (vam->ofp, "Help is available for the following:");
23305 hash_foreach_pair (p, vam->function_by_name,
23307 vec_add1 (cmds, (u8 *)(p->key));
23311 vec_sort_with_function (cmds, cmd_cmp);
23313 for (j = 0; j < vec_len (cmds); j++)
23314 print (vam->ofp, "%s", cmds[j]);
23321 set (vat_main_t * vam)
23323 u8 *name = 0, *value = 0;
23324 unformat_input_t *i = vam->input;
23326 if (unformat (i, "%s", &name))
23328 /* The input buffer is a vector, not a string. */
23329 value = vec_dup (i->buffer);
23330 vec_delete (value, i->index, 0);
23331 /* Almost certainly has a trailing newline */
23332 if (value[vec_len (value) - 1] == '\n')
23333 value[vec_len (value) - 1] = 0;
23334 /* Make sure it's a proper string, one way or the other */
23335 vec_add1 (value, 0);
23336 (void) clib_macro_set_value (&vam->macro_main,
23337 (char *) name, (char *) value);
23340 errmsg ("usage: set <name> <value>");
23348 unset (vat_main_t * vam)
23352 if (unformat (vam->input, "%s", &name))
23353 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
23354 errmsg ("unset: %s wasn't set", name);
23367 macro_sort_cmp (void *a1, void *a2)
23369 macro_sort_t *s1 = a1;
23370 macro_sort_t *s2 = a2;
23372 return strcmp ((char *) (s1->name), (char *) (s2->name));
23376 dump_macro_table (vat_main_t * vam)
23378 macro_sort_t *sort_me = 0, *sm;
23383 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
23385 vec_add2 (sort_me, sm, 1);
23386 sm->name = (u8 *)(p->key);
23387 sm->value = (u8 *) (p->value[0]);
23391 vec_sort_with_function (sort_me, macro_sort_cmp);
23393 if (vec_len (sort_me))
23394 print (vam->ofp, "%-15s%s", "Name", "Value");
23396 print (vam->ofp, "The macro table is empty...");
23398 for (i = 0; i < vec_len (sort_me); i++)
23399 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
23404 dump_node_table (vat_main_t * vam)
23407 vlib_node_t *node, *next_node;
23409 if (vec_len (vam->graph_nodes) == 0)
23411 print (vam->ofp, "Node table empty, issue get_node_graph...");
23415 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
23417 node = vam->graph_nodes[0][i];
23418 print (vam->ofp, "[%d] %s", i, node->name);
23419 for (j = 0; j < vec_len (node->next_nodes); j++)
23421 if (node->next_nodes[j] != ~0)
23423 next_node = vam->graph_nodes[0][node->next_nodes[j]];
23424 print (vam->ofp, " [%d] %s", j, next_node->name);
23432 value_sort_cmp (void *a1, void *a2)
23434 name_sort_t *n1 = a1;
23435 name_sort_t *n2 = a2;
23437 if (n1->value < n2->value)
23439 if (n1->value > n2->value)
23446 dump_msg_api_table (vat_main_t * vam)
23448 api_main_t *am = &api_main;
23449 name_sort_t *nses = 0, *ns;
23454 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
23456 vec_add2 (nses, ns, 1);
23457 ns->name = (u8 *)(hp->key);
23458 ns->value = (u32) hp->value[0];
23462 vec_sort_with_function (nses, value_sort_cmp);
23464 for (i = 0; i < vec_len (nses); i++)
23465 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
23471 get_msg_id (vat_main_t * vam)
23476 if (unformat (vam->input, "%s", &name_and_crc))
23478 message_index = vl_msg_api_get_msg_index (name_and_crc);
23479 if (message_index == ~0)
23481 print (vam->ofp, " '%s' not found", name_and_crc);
23484 print (vam->ofp, " '%s' has message index %d",
23485 name_and_crc, message_index);
23488 errmsg ("name_and_crc required...");
23493 search_node_table (vat_main_t * vam)
23495 unformat_input_t *line_input = vam->input;
23498 vlib_node_t *node, *next_node;
23501 if (vam->graph_node_index_by_name == 0)
23503 print (vam->ofp, "Node table empty, issue get_node_graph...");
23507 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
23509 if (unformat (line_input, "%s", &node_to_find))
23511 vec_add1 (node_to_find, 0);
23512 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
23515 print (vam->ofp, "%s not found...", node_to_find);
23518 node = vam->graph_nodes[0][p[0]];
23519 print (vam->ofp, "[%d] %s", p[0], node->name);
23520 for (j = 0; j < vec_len (node->next_nodes); j++)
23522 if (node->next_nodes[j] != ~0)
23524 next_node = vam->graph_nodes[0][node->next_nodes[j]];
23525 print (vam->ofp, " [%d] %s", j, next_node->name);
23532 clib_warning ("parse error '%U'", format_unformat_error,
23538 vec_free (node_to_find);
23547 script (vat_main_t * vam)
23549 #if (VPP_API_TEST_BUILTIN==0)
23551 char *save_current_file;
23552 unformat_input_t save_input;
23553 jmp_buf save_jump_buf;
23554 u32 save_line_number;
23556 FILE *new_fp, *save_ifp;
23558 if (unformat (vam->input, "%s", &s))
23560 new_fp = fopen ((char *) s, "r");
23563 errmsg ("Couldn't open script file %s", s);
23570 errmsg ("Missing script name");
23574 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
23575 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
23576 save_ifp = vam->ifp;
23577 save_line_number = vam->input_line_number;
23578 save_current_file = (char *) vam->current_file;
23580 vam->input_line_number = 0;
23582 vam->current_file = s;
23585 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
23586 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
23587 vam->ifp = save_ifp;
23588 vam->input_line_number = save_line_number;
23589 vam->current_file = (u8 *) save_current_file;
23594 clib_warning ("use the exec command...");
23600 echo (vat_main_t * vam)
23602 print (vam->ofp, "%v", vam->input->buffer);
23606 /* List of API message constructors, CLI names map to api_xxx */
23607 #define foreach_vpe_api_msg \
23608 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
23609 _(sw_interface_dump,"") \
23610 _(sw_interface_set_flags, \
23611 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
23612 _(sw_interface_add_del_address, \
23613 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
23614 _(sw_interface_set_rx_mode, \
23615 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
23616 _(sw_interface_set_rx_placement, \
23617 "<intfc> | sw_if_index <id> [queue <id>] [worker <id> | main]") \
23618 _(sw_interface_rx_placement_dump, \
23619 "[<intfc> | sw_if_index <id>]") \
23620 _(sw_interface_set_table, \
23621 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
23622 _(sw_interface_set_mpls_enable, \
23623 "<intfc> | sw_if_index [disable | dis]") \
23624 _(sw_interface_set_vpath, \
23625 "<intfc> | sw_if_index <id> enable | disable") \
23626 _(sw_interface_set_vxlan_bypass, \
23627 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23628 _(sw_interface_set_geneve_bypass, \
23629 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23630 _(sw_interface_set_l2_xconnect, \
23631 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23632 "enable | disable") \
23633 _(sw_interface_set_l2_bridge, \
23634 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
23635 "[shg <split-horizon-group>] [bvi]\n" \
23636 "enable | disable") \
23637 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
23638 _(bridge_domain_add_del, \
23639 "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") \
23640 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
23642 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
23643 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
23644 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
23646 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23648 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23650 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
23652 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
23654 "<vpp-if-name> | sw_if_index <id>") \
23655 _(sw_interface_tap_dump, "") \
23657 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>]") \
23659 "<vpp-if-name> | sw_if_index <id>") \
23660 _(sw_interface_tap_v2_dump, "") \
23662 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
23663 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]}") \
23665 "<vpp-if-name> | sw_if_index <id>") \
23667 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
23668 _(bond_detach_slave, \
23669 "sw_if_index <n>") \
23670 _(sw_interface_bond_dump, "") \
23671 _(sw_interface_slave_dump, \
23672 "<vpp-if-name> | sw_if_index <id>") \
23673 _(ip_table_add_del, \
23674 "table <n> [ipv6] [add | del]\n") \
23675 _(ip_add_del_route, \
23676 "<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
23677 "[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
23678 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
23679 "[multipath] [count <n>]") \
23680 _(ip_mroute_add_del, \
23681 "<src> <grp>/<mask> [table-id <n>]\n" \
23682 "[<intfc> | sw_if_index <id>] [local] [del]") \
23683 _(mpls_table_add_del, \
23684 "table <n> [add | del]\n") \
23685 _(mpls_route_add_del, \
23686 "<label> <eos> via <addr | next-hop-table <n> | via-label <n> |\n" \
23687 "lookup-ip4-table <n> | lookup-in-ip6-table <n> |\n" \
23688 "l2-input-on <intfc> | l2-input-on sw_if_index <id>>\n" \
23689 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>] [weight <n>]\n" \
23690 "[drop] [local] [classify <n>] [multipath] [count <n>] [del]") \
23691 _(mpls_ip_bind_unbind, \
23692 "<label> <addr/len>") \
23693 _(mpls_tunnel_add_del, \
23694 " via <addr> [table-id <n>]\n" \
23695 "sw_if_index <id>] [l2] [del]") \
23696 _(sr_mpls_policy_add, \
23697 "bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
23698 _(sr_mpls_policy_del, \
23700 _(bier_table_add_del, \
23701 "<label> <sub-domain> <set> <bsl> [del]") \
23702 _(bier_route_add_del, \
23703 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
23704 "[<intfc> | sw_if_index <id>]" \
23705 "[weight <n>] [del] [multipath]") \
23706 _(proxy_arp_add_del, \
23707 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
23708 _(proxy_arp_intfc_enable_disable, \
23709 "<intfc> | sw_if_index <id> enable | disable") \
23710 _(sw_interface_set_unnumbered, \
23711 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
23712 _(ip_neighbor_add_del, \
23713 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
23714 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
23715 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
23716 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
23717 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
23718 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
23719 "[outer_vlan_id_any][inner_vlan_id_any]") \
23720 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
23721 _(reset_fib, "vrf <n> [ipv6]") \
23722 _(dhcp_proxy_config, \
23723 "svr <v46-address> src <v46-address>\n" \
23724 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
23725 _(dhcp_proxy_set_vss, \
23726 "tbl_id <n> [fib_id <n> oui <n> | vpn_ascii_id <text>] [ipv6] [del]") \
23727 _(dhcp_proxy_dump, "ip6") \
23728 _(dhcp_client_config, \
23729 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
23730 _(set_ip_flow_hash, \
23731 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
23732 _(sw_interface_ip6_enable_disable, \
23733 "<intfc> | sw_if_index <id> enable | disable") \
23734 _(sw_interface_ip6_set_link_local_address, \
23735 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
23736 _(ip6nd_proxy_add_del, \
23737 "<intfc> | sw_if_index <id> <ip6-address>") \
23738 _(ip6nd_proxy_dump, "") \
23739 _(sw_interface_ip6nd_ra_prefix, \
23740 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
23741 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
23742 "[nolink] [isno]") \
23743 _(sw_interface_ip6nd_ra_config, \
23744 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
23745 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
23746 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
23747 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
23748 _(l2_patch_add_del, \
23749 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23750 "enable | disable") \
23751 _(sr_localsid_add_del, \
23752 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
23753 "fib-table <num> (end.psp) sw_if_index <num>") \
23754 _(classify_add_del_table, \
23755 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
23756 " [del] [del-chain] mask <mask-value>\n" \
23757 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
23758 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
23759 _(classify_add_del_session, \
23760 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
23761 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
23762 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
23763 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
23764 _(classify_set_interface_ip_table, \
23765 "<intfc> | sw_if_index <nn> table <nn>") \
23766 _(classify_set_interface_l2_tables, \
23767 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23768 " [other-table <nn>]") \
23769 _(get_node_index, "node <node-name") \
23770 _(add_node_next, "node <node-name> next <next-node-name>") \
23771 _(l2tpv3_create_tunnel, \
23772 "client_address <ip6-addr> our_address <ip6-addr>\n" \
23773 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
23774 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
23775 _(l2tpv3_set_tunnel_cookies, \
23776 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
23777 "[new_remote_cookie <nn>]\n") \
23778 _(l2tpv3_interface_enable_disable, \
23779 "<intfc> | sw_if_index <nn> enable | disable") \
23780 _(l2tpv3_set_lookup_key, \
23781 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
23782 _(sw_if_l2tpv3_tunnel_dump, "") \
23783 _(vxlan_offload_rx, \
23784 "hw { <interface name> | hw_if_index <nn>} " \
23785 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
23786 _(vxlan_add_del_tunnel, \
23787 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23788 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
23789 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23790 _(geneve_add_del_tunnel, \
23791 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23792 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23793 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23794 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23795 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23796 _(gre_add_del_tunnel, \
23797 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
23798 "[teb | erspan <session-id>] [del]") \
23799 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23800 _(l2_fib_clear_table, "") \
23801 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
23802 _(l2_interface_vlan_tag_rewrite, \
23803 "<intfc> | sw_if_index <nn> \n" \
23804 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
23805 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
23806 _(create_vhost_user_if, \
23807 "socket <filename> [server] [renumber <dev_instance>] " \
23808 "[disable_mrg_rxbuf] [disable_indirect_desc] " \
23809 "[mac <mac_address>]") \
23810 _(modify_vhost_user_if, \
23811 "<intfc> | sw_if_index <nn> socket <filename>\n" \
23812 "[server] [renumber <dev_instance>]") \
23813 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
23814 _(sw_interface_vhost_user_dump, "") \
23815 _(show_version, "") \
23816 _(show_threads, "") \
23817 _(vxlan_gpe_add_del_tunnel, \
23818 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
23819 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23820 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
23821 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
23822 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23823 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
23824 _(interface_name_renumber, \
23825 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
23826 _(input_acl_set_interface, \
23827 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23828 " [l2-table <nn>] [del]") \
23829 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
23830 _(ip_scan_neighbor_enable_disable, "[ip4|ip6|both|disable] [interval <n-min>]\n" \
23831 " [max-time <n-usec>] [max-update <n>] [delay <n-msec>] [stale <n-min>]") \
23832 _(want_ip4_arp_events, "address <ip4-address> [del]") \
23833 _(want_ip6_nd_events, "address <ip6-address> [del]") \
23834 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
23835 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
23836 _(ip_dump, "ipv4 | ipv6") \
23837 _(ipsec_spd_add_del, "spd_id <n> [del]") \
23838 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
23840 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
23841 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
23842 " integ_alg <alg> integ_key <hex>") \
23843 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
23844 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
23845 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
23846 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
23847 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
23848 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
23849 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
23850 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
23851 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
23852 " [instance <n>]") \
23853 _(ipsec_sa_dump, "[sa_id <n>]") \
23854 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
23855 " <alg> <hex>\n") \
23856 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
23857 _(ikev2_profile_add_del, "name <profile_name> [del]") \
23858 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
23859 "(auth_data 0x<data> | auth_data <data>)") \
23860 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
23861 "(id_data 0x<data> | id_data <data>) (local|remote)") \
23862 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
23863 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
23864 "(local|remote)") \
23865 _(ikev2_set_local_key, "file <absolute_file_path>") \
23866 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
23867 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23868 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23869 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
23870 _(ikev2_initiate_sa_init, "<profile_name>") \
23871 _(ikev2_initiate_del_ike_sa, "<ispi>") \
23872 _(ikev2_initiate_del_child_sa, "<ispi>") \
23873 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
23874 _(delete_loopback,"sw_if_index <nn>") \
23875 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
23876 _(bd_ip_mac_dump, "[bd_id] <id>") \
23877 _(want_interface_events, "enable|disable") \
23878 _(want_stats,"enable|disable") \
23879 _(get_first_msg_id, "client <name>") \
23880 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
23881 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
23882 "fib-id <nn> [ip4][ip6][default]") \
23883 _(get_node_graph, " ") \
23884 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
23885 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
23886 _(ioam_disable, "") \
23887 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
23888 " sw_if_index <sw_if_index> p <priority> " \
23889 "w <weight>] [del]") \
23890 _(one_add_del_locator, "locator-set <locator_name> " \
23891 "iface <intf> | sw_if_index <sw_if_index> " \
23892 "p <priority> w <weight> [del]") \
23893 _(one_add_del_local_eid,"vni <vni> eid " \
23894 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23895 "locator-set <locator_name> [del]" \
23896 "[key-id sha1|sha256 secret-key <secret-key>]")\
23897 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
23898 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
23899 _(one_enable_disable, "enable|disable") \
23900 _(one_map_register_enable_disable, "enable|disable") \
23901 _(one_map_register_fallback_threshold, "<value>") \
23902 _(one_rloc_probe_enable_disable, "enable|disable") \
23903 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23905 "rloc <locator> p <prio> " \
23906 "w <weight> [rloc <loc> ... ] " \
23907 "action <action> [del-all]") \
23908 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23910 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23911 _(one_use_petr, "ip-address> | disable") \
23912 _(one_map_request_mode, "src-dst|dst-only") \
23913 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23914 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23915 _(one_locator_set_dump, "[local | remote]") \
23916 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
23917 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23918 "[local] | [remote]") \
23919 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
23920 _(one_ndp_bd_get, "") \
23921 _(one_ndp_entries_get, "bd <bridge-domain>") \
23922 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
23923 _(one_l2_arp_bd_get, "") \
23924 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
23925 _(one_stats_enable_disable, "enable|disable") \
23926 _(show_one_stats_enable_disable, "") \
23927 _(one_eid_table_vni_dump, "") \
23928 _(one_eid_table_map_dump, "l2|l3") \
23929 _(one_map_resolver_dump, "") \
23930 _(one_map_server_dump, "") \
23931 _(one_adjacencies_get, "vni <vni>") \
23932 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
23933 _(show_one_rloc_probe_state, "") \
23934 _(show_one_map_register_state, "") \
23935 _(show_one_status, "") \
23936 _(one_stats_dump, "") \
23937 _(one_stats_flush, "") \
23938 _(one_get_map_request_itr_rlocs, "") \
23939 _(one_map_register_set_ttl, "<ttl>") \
23940 _(one_set_transport_protocol, "udp|api") \
23941 _(one_get_transport_protocol, "") \
23942 _(one_enable_disable_xtr_mode, "enable|disable") \
23943 _(one_show_xtr_mode, "") \
23944 _(one_enable_disable_pitr_mode, "enable|disable") \
23945 _(one_show_pitr_mode, "") \
23946 _(one_enable_disable_petr_mode, "enable|disable") \
23947 _(one_show_petr_mode, "") \
23948 _(show_one_nsh_mapping, "") \
23949 _(show_one_pitr, "") \
23950 _(show_one_use_petr, "") \
23951 _(show_one_map_request_mode, "") \
23952 _(show_one_map_register_ttl, "") \
23953 _(show_one_map_register_fallback_threshold, "") \
23954 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
23955 " sw_if_index <sw_if_index> p <priority> " \
23956 "w <weight>] [del]") \
23957 _(lisp_add_del_locator, "locator-set <locator_name> " \
23958 "iface <intf> | sw_if_index <sw_if_index> " \
23959 "p <priority> w <weight> [del]") \
23960 _(lisp_add_del_local_eid,"vni <vni> eid " \
23961 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23962 "locator-set <locator_name> [del]" \
23963 "[key-id sha1|sha256 secret-key <secret-key>]") \
23964 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
23965 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
23966 _(lisp_enable_disable, "enable|disable") \
23967 _(lisp_map_register_enable_disable, "enable|disable") \
23968 _(lisp_rloc_probe_enable_disable, "enable|disable") \
23969 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23971 "rloc <locator> p <prio> " \
23972 "w <weight> [rloc <loc> ... ] " \
23973 "action <action> [del-all]") \
23974 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23976 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23977 _(lisp_use_petr, "<ip-address> | disable") \
23978 _(lisp_map_request_mode, "src-dst|dst-only") \
23979 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23980 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23981 _(lisp_locator_set_dump, "[local | remote]") \
23982 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
23983 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23984 "[local] | [remote]") \
23985 _(lisp_eid_table_vni_dump, "") \
23986 _(lisp_eid_table_map_dump, "l2|l3") \
23987 _(lisp_map_resolver_dump, "") \
23988 _(lisp_map_server_dump, "") \
23989 _(lisp_adjacencies_get, "vni <vni>") \
23990 _(gpe_fwd_entry_vnis_get, "") \
23991 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
23992 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
23993 "[table <table-id>]") \
23994 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
23995 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
23996 _(gpe_set_encap_mode, "lisp|vxlan") \
23997 _(gpe_get_encap_mode, "") \
23998 _(lisp_gpe_add_del_iface, "up|down") \
23999 _(lisp_gpe_enable_disable, "enable|disable") \
24000 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
24001 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
24002 _(show_lisp_rloc_probe_state, "") \
24003 _(show_lisp_map_register_state, "") \
24004 _(show_lisp_status, "") \
24005 _(lisp_get_map_request_itr_rlocs, "") \
24006 _(show_lisp_pitr, "") \
24007 _(show_lisp_use_petr, "") \
24008 _(show_lisp_map_request_mode, "") \
24009 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
24010 _(af_packet_delete, "name <host interface name>") \
24011 _(af_packet_dump, "") \
24012 _(policer_add_del, "name <policer name> <params> [del]") \
24013 _(policer_dump, "[name <policer name>]") \
24014 _(policer_classify_set_interface, \
24015 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
24016 " [l2-table <nn>] [del]") \
24017 _(policer_classify_dump, "type [ip4|ip6|l2]") \
24018 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
24019 "[master|slave]") \
24020 _(netmap_delete, "name <interface name>") \
24021 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
24022 _(mpls_fib_dump, "") \
24023 _(classify_table_ids, "") \
24024 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
24025 _(classify_table_info, "table_id <nn>") \
24026 _(classify_session_dump, "table_id <nn>") \
24027 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
24028 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
24029 "[template_interval <nn>] [udp_checksum]") \
24030 _(ipfix_exporter_dump, "") \
24031 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
24032 _(ipfix_classify_stream_dump, "") \
24033 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
24034 _(ipfix_classify_table_dump, "") \
24035 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
24036 _(sw_interface_span_dump, "[l2]") \
24037 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
24038 _(pg_create_interface, "if_id <nn>") \
24039 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
24040 _(pg_enable_disable, "[stream <id>] disable") \
24041 _(ip_source_and_port_range_check_add_del, \
24042 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
24043 _(ip_source_and_port_range_check_interface_add_del, \
24044 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
24045 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
24046 _(ipsec_gre_add_del_tunnel, \
24047 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
24048 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
24049 _(delete_subif,"<intfc> | sw_if_index <nn>") \
24050 _(l2_interface_pbb_tag_rewrite, \
24051 "<intfc> | sw_if_index <nn> \n" \
24052 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
24053 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
24054 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
24055 _(flow_classify_set_interface, \
24056 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
24057 _(flow_classify_dump, "type [ip4|ip6]") \
24058 _(ip_fib_dump, "") \
24059 _(ip_mfib_dump, "") \
24060 _(ip6_fib_dump, "") \
24061 _(ip6_mfib_dump, "") \
24062 _(feature_enable_disable, "arc_name <arc_name> " \
24063 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
24064 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
24066 _(l2_xconnect_dump, "") \
24067 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
24068 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
24069 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
24070 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
24071 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
24072 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
24073 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
24074 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
24075 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
24076 _(sock_init_shm, "size <nnn>") \
24077 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
24078 _(dns_enable_disable, "[enable][disable]") \
24079 _(dns_name_server_add_del, "<ip-address> [del]") \
24080 _(dns_resolve_name, "<hostname>") \
24081 _(dns_resolve_ip, "<ip4|ip6>") \
24082 _(dns_name_server_add_del, "<ip-address> [del]") \
24083 _(dns_resolve_name, "<hostname>") \
24084 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
24085 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
24086 _(session_rules_dump, "") \
24087 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
24088 _(output_acl_set_interface, \
24089 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
24090 " [l2-table <nn>] [del]") \
24091 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
24093 /* List of command functions, CLI names map directly to functions */
24094 #define foreach_cli_function \
24095 _(comment, "usage: comment <ignore-rest-of-line>") \
24096 _(dump_interface_table, "usage: dump_interface_table") \
24097 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
24098 _(dump_ipv4_table, "usage: dump_ipv4_table") \
24099 _(dump_ipv6_table, "usage: dump_ipv6_table") \
24100 _(dump_stats_table, "usage: dump_stats_table") \
24101 _(dump_macro_table, "usage: dump_macro_table ") \
24102 _(dump_node_table, "usage: dump_node_table") \
24103 _(dump_msg_api_table, "usage: dump_msg_api_table") \
24104 _(get_msg_id, "usage: get_msg_id name_and_crc") \
24105 _(echo, "usage: echo <message>") \
24106 _(exec, "usage: exec <vpe-debug-CLI-command>") \
24107 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
24108 _(help, "usage: help") \
24109 _(q, "usage: quit") \
24110 _(quit, "usage: quit") \
24111 _(search_node_table, "usage: search_node_table <name>...") \
24112 _(set, "usage: set <variable-name> <value>") \
24113 _(script, "usage: script <file-name>") \
24114 _(statseg, "usage: statseg"); \
24115 _(unset, "usage: unset <variable-name>")
24118 static void vl_api_##n##_t_handler_uni \
24119 (vl_api_##n##_t * mp) \
24121 vat_main_t * vam = &vat_main; \
24122 if (vam->json_output) { \
24123 vl_api_##n##_t_handler_json(mp); \
24125 vl_api_##n##_t_handler(mp); \
24128 foreach_vpe_api_reply_msg;
24129 #if VPP_API_TEST_BUILTIN == 0
24130 foreach_standalone_reply_msg;
24135 vat_api_hookup (vat_main_t * vam)
24138 vl_msg_api_set_handlers(VL_API_##N, #n, \
24139 vl_api_##n##_t_handler_uni, \
24141 vl_api_##n##_t_endian, \
24142 vl_api_##n##_t_print, \
24143 sizeof(vl_api_##n##_t), 1);
24144 foreach_vpe_api_reply_msg;
24145 #if VPP_API_TEST_BUILTIN == 0
24146 foreach_standalone_reply_msg;
24150 #if (VPP_API_TEST_BUILTIN==0)
24151 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
24153 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
24155 vam->function_by_name = hash_create_string (0, sizeof (uword));
24157 vam->help_by_name = hash_create_string (0, sizeof (uword));
24160 /* API messages we can send */
24161 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
24162 foreach_vpe_api_msg;
24166 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
24167 foreach_vpe_api_msg;
24170 /* CLI functions */
24171 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
24172 foreach_cli_function;
24176 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
24177 foreach_cli_function;
24181 #if VPP_API_TEST_BUILTIN
24182 static clib_error_t *
24183 vat_api_hookup_shim (vlib_main_t * vm)
24185 vat_api_hookup (&vat_main);
24189 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
24193 * fd.io coding-style-patch-verification: ON
24196 * eval: (c-set-style "gnu")