2 *------------------------------------------------------------------
5 * Copyright (c) 2014-2016 Cisco and/or its affiliates.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *------------------------------------------------------------------
21 #include <vppinfra/socket.h>
22 #include <vlibapi/api.h>
23 #include <vlibmemory/api.h>
24 #include <vnet/ip/ip.h>
25 #include <vnet/ip/ip_neighbor.h>
26 #include <vnet/l2/l2_input.h>
27 #include <vnet/l2tp/l2tp.h>
28 #include <vnet/vxlan/vxlan.h>
29 #include <vnet/geneve/geneve.h>
30 #include <vnet/gre/gre.h>
31 #include <vnet/vxlan-gpe/vxlan_gpe.h>
32 #include <vnet/lisp-gpe/lisp_gpe.h>
34 #include <vpp/api/vpe_msg_enum.h>
35 #include <vnet/l2/l2_classify.h>
36 #include <vnet/l2/l2_vtr.h>
37 #include <vnet/classify/in_out_acl.h>
38 #include <vnet/classify/policer_classify.h>
39 #include <vnet/classify/flow_classify.h>
40 #include <vnet/mpls/mpls.h>
41 #include <vnet/ipsec/ipsec.h>
42 #include <vnet/ipsec/ikev2.h>
44 #include <vnet/cop/cop.h>
45 #include <vnet/ip/ip6_hop_by_hop.h>
46 #include <vnet/ip/ip_source_and_port_range_check.h>
47 #include <vnet/policer/xlate.h>
48 #include <vnet/span/span.h>
49 #include <vnet/policer/policer.h>
50 #include <vnet/policer/police.h>
51 #include <vnet/mfib/mfib_types.h>
52 #include <vnet/dhcp/dhcp_proxy.h>
53 #include <vnet/bonding/node.h>
54 #include <vnet/qos/qos_types.h>
55 #include "vat/json_format.h"
60 #define vl_typedefs /* define message structures */
61 #include <vpp/api/vpe_all_api_h.h>
64 /* declare message handlers for each api */
66 #define vl_endianfun /* define message structures */
67 #include <vpp/api/vpe_all_api_h.h>
70 /* instantiate all the print functions we know about */
71 #define vl_print(handle, ...)
73 #include <vpp/api/vpe_all_api_h.h>
76 #define __plugin_msg_base 0
77 #include <vlibapi/vat_helper_macros.h>
79 #if VPP_API_TEST_BUILTIN == 0
89 vat_socket_connect (vat_main_t * vam)
91 vam->socket_client_main = &socket_client_main;
92 return vl_socket_client_connect ((char *) vam->socket_name, "vpp_api_test",
93 0 /* default socket rx, tx buffer */ );
95 #else /* vpp built-in case, we don't do sockets... */
97 vat_socket_connect (vat_main_t * vam)
103 vl_socket_client_read (int wait)
109 vl_socket_client_write ()
115 vl_socket_client_msg_alloc (int nbytes)
123 vat_time_now (vat_main_t * vam)
125 #if VPP_API_TEST_BUILTIN
126 return vlib_time_now (vam->vlib_main);
128 return clib_time_now (&vam->clib_time);
133 errmsg (char *fmt, ...)
135 vat_main_t *vam = &vat_main;
140 s = va_format (0, fmt, &va);
145 #if VPP_API_TEST_BUILTIN
146 vlib_cli_output (vam->vlib_main, (char *) s);
149 if (vam->ifp != stdin)
150 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
151 vam->input_line_number);
152 fformat (vam->ofp, (char *) s);
160 #if VPP_API_TEST_BUILTIN == 0
162 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
164 vat_main_t *vam = va_arg (*args, vat_main_t *);
165 u32 *result = va_arg (*args, u32 *);
169 if (!unformat (input, "%s", &if_name))
172 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
180 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
185 /* Parse an IP4 address %d.%d.%d.%d. */
187 unformat_ip4_address (unformat_input_t * input, va_list * args)
189 u8 *result = va_arg (*args, u8 *);
192 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
195 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
207 unformat_ethernet_address (unformat_input_t * input, va_list * args)
209 u8 *result = va_arg (*args, u8 *);
212 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
213 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
217 for (i = 0; i < 6; i++)
218 if (a[i] >= (1 << 8))
221 for (i = 0; i < 6; i++)
227 /* Returns ethernet type as an int in host byte order. */
229 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
232 u16 *result = va_arg (*args, u16 *);
236 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
238 if (type >= (1 << 16))
246 /* Parse an IP6 address. */
248 unformat_ip6_address (unformat_input_t * input, va_list * args)
250 ip6_address_t *result = va_arg (*args, ip6_address_t *);
252 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
253 uword c, n_colon, double_colon_index;
255 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
256 double_colon_index = ARRAY_LEN (hex_quads);
257 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
260 if (c >= '0' && c <= '9')
262 else if (c >= 'a' && c <= 'f')
263 hex_digit = c + 10 - 'a';
264 else if (c >= 'A' && c <= 'F')
265 hex_digit = c + 10 - 'A';
266 else if (c == ':' && n_colon < 2)
270 unformat_put_input (input);
274 /* Too many hex quads. */
275 if (n_hex_quads >= ARRAY_LEN (hex_quads))
280 hex_quad = (hex_quad << 4) | hex_digit;
282 /* Hex quad must fit in 16 bits. */
283 if (n_hex_digits >= 4)
290 /* Save position of :: */
293 /* More than one :: ? */
294 if (double_colon_index < ARRAY_LEN (hex_quads))
296 double_colon_index = n_hex_quads;
299 if (n_colon > 0 && n_hex_digits > 0)
301 hex_quads[n_hex_quads++] = hex_quad;
307 if (n_hex_digits > 0)
308 hex_quads[n_hex_quads++] = hex_quad;
313 /* Expand :: to appropriate number of zero hex quads. */
314 if (double_colon_index < ARRAY_LEN (hex_quads))
316 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
318 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
319 hex_quads[n_zero + i] = hex_quads[i];
321 for (i = 0; i < n_zero; i++)
322 hex_quads[double_colon_index + i] = 0;
324 n_hex_quads = ARRAY_LEN (hex_quads);
327 /* Too few hex quads given. */
328 if (n_hex_quads < ARRAY_LEN (hex_quads))
331 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
332 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
339 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
341 u32 *r = va_arg (*args, u32 *);
344 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
345 foreach_ipsec_policy_action
353 unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args)
355 u32 *r = va_arg (*args, u32 *);
358 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
359 foreach_ipsec_crypto_alg
367 format_ipsec_crypto_alg (u8 * s, va_list * args)
369 u32 i = va_arg (*args, u32);
374 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
375 foreach_ipsec_crypto_alg
378 return format (s, "unknown");
380 return format (s, "%s", t);
384 unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args)
386 u32 *r = va_arg (*args, u32 *);
389 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f;
390 foreach_ipsec_integ_alg
398 format_ipsec_integ_alg (u8 * s, va_list * args)
400 u32 i = va_arg (*args, u32);
405 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
406 foreach_ipsec_integ_alg
409 return format (s, "unknown");
411 return format (s, "%s", t);
415 unformat_ikev2_auth_method (unformat_input_t * input, va_list * args)
417 u32 *r = va_arg (*args, u32 *);
420 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f;
421 foreach_ikev2_auth_method
429 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
431 u32 *r = va_arg (*args, u32 *);
434 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
435 foreach_ikev2_id_type
441 #else /* VPP_API_TEST_BUILTIN == 1 */
443 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
445 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
446 vnet_main_t *vnm = vnet_get_main ();
447 u32 *result = va_arg (*args, u32 *);
449 return unformat (input, "%U", unformat_vnet_sw_interface, vnm, result);
453 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
455 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
456 vnet_main_t *vnm = vnet_get_main ();
457 u32 *result = va_arg (*args, u32 *);
459 return unformat (input, "%U", unformat_vnet_hw_interface, vnm, result);
462 #endif /* VPP_API_TEST_BUILTIN */
465 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
467 u8 *r = va_arg (*args, u8 *);
469 if (unformat (input, "kbps"))
470 *r = SSE2_QOS_RATE_KBPS;
471 else if (unformat (input, "pps"))
472 *r = SSE2_QOS_RATE_PPS;
479 unformat_policer_round_type (unformat_input_t * input, va_list * args)
481 u8 *r = va_arg (*args, u8 *);
483 if (unformat (input, "closest"))
484 *r = SSE2_QOS_ROUND_TO_CLOSEST;
485 else if (unformat (input, "up"))
486 *r = SSE2_QOS_ROUND_TO_UP;
487 else if (unformat (input, "down"))
488 *r = SSE2_QOS_ROUND_TO_DOWN;
495 unformat_policer_type (unformat_input_t * input, va_list * args)
497 u8 *r = va_arg (*args, u8 *);
499 if (unformat (input, "1r2c"))
500 *r = SSE2_QOS_POLICER_TYPE_1R2C;
501 else if (unformat (input, "1r3c"))
502 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
503 else if (unformat (input, "2r3c-2698"))
504 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
505 else if (unformat (input, "2r3c-4115"))
506 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
507 else if (unformat (input, "2r3c-mef5cf1"))
508 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
515 unformat_dscp (unformat_input_t * input, va_list * va)
517 u8 *r = va_arg (*va, u8 *);
520 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
529 unformat_policer_action_type (unformat_input_t * input, va_list * va)
531 sse2_qos_pol_action_params_st *a
532 = va_arg (*va, sse2_qos_pol_action_params_st *);
534 if (unformat (input, "drop"))
535 a->action_type = SSE2_QOS_ACTION_DROP;
536 else if (unformat (input, "transmit"))
537 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
538 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
539 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
546 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
548 u32 *r = va_arg (*va, u32 *);
551 if (unformat (input, "ip4"))
552 tid = POLICER_CLASSIFY_TABLE_IP4;
553 else if (unformat (input, "ip6"))
554 tid = POLICER_CLASSIFY_TABLE_IP6;
555 else if (unformat (input, "l2"))
556 tid = POLICER_CLASSIFY_TABLE_L2;
565 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
567 u32 *r = va_arg (*va, u32 *);
570 if (unformat (input, "ip4"))
571 tid = FLOW_CLASSIFY_TABLE_IP4;
572 else if (unformat (input, "ip6"))
573 tid = FLOW_CLASSIFY_TABLE_IP6;
581 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
582 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
583 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
584 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
586 #if (VPP_API_TEST_BUILTIN==0)
588 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
590 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
591 mfib_itf_attribute_t attr;
594 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
596 if (unformat (input, mfib_itf_flag_long_names[attr]))
597 *iflags |= (1 << attr);
599 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
601 if (unformat (input, mfib_itf_flag_names[attr]))
602 *iflags |= (1 << attr);
605 return (old == *iflags ? 0 : 1);
609 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
611 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
612 mfib_entry_attribute_t attr;
615 FOR_EACH_MFIB_ATTRIBUTE (attr)
617 if (unformat (input, mfib_flag_long_names[attr]))
618 *eflags |= (1 << attr);
620 FOR_EACH_MFIB_ATTRIBUTE (attr)
622 if (unformat (input, mfib_flag_names[attr]))
623 *eflags |= (1 << attr);
626 return (old == *eflags ? 0 : 1);
630 format_ip4_address (u8 * s, va_list * args)
632 u8 *a = va_arg (*args, u8 *);
633 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
637 format_ip6_address (u8 * s, va_list * args)
639 ip6_address_t *a = va_arg (*args, ip6_address_t *);
640 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
642 i_max_n_zero = ARRAY_LEN (a->as_u16);
644 i_first_zero = i_max_n_zero;
646 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
648 u32 is_zero = a->as_u16[i] == 0;
649 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
655 if ((!is_zero && n_zeros > max_n_zeros)
656 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
658 i_max_n_zero = i_first_zero;
659 max_n_zeros = n_zeros;
660 i_first_zero = ARRAY_LEN (a->as_u16);
665 last_double_colon = 0;
666 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
668 if (i == i_max_n_zero && max_n_zeros > 1)
670 s = format (s, "::");
671 i += max_n_zeros - 1;
672 last_double_colon = 1;
676 s = format (s, "%s%x",
677 (last_double_colon || i == 0) ? "" : ":",
678 clib_net_to_host_u16 (a->as_u16[i]));
679 last_double_colon = 0;
686 /* Format an IP46 address. */
688 format_ip46_address (u8 * s, va_list * args)
690 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
691 ip46_type_t type = va_arg (*args, ip46_type_t);
697 is_ip4 = ip46_address_is_ip4 (ip46);
708 format (s, "%U", format_ip4_address, &ip46->ip4) :
709 format (s, "%U", format_ip6_address, &ip46->ip6);
713 format_ethernet_address (u8 * s, va_list * args)
715 u8 *a = va_arg (*args, u8 *);
717 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
718 a[0], a[1], a[2], a[3], a[4], a[5]);
723 increment_v4_address (ip4_address_t * a)
727 v = ntohl (a->as_u32) + 1;
728 a->as_u32 = ntohl (v);
732 increment_v6_address (ip6_address_t * a)
736 v0 = clib_net_to_host_u64 (a->as_u64[0]);
737 v1 = clib_net_to_host_u64 (a->as_u64[1]);
742 a->as_u64[0] = clib_net_to_host_u64 (v0);
743 a->as_u64[1] = clib_net_to_host_u64 (v1);
747 increment_mac_address (u8 * mac)
749 u64 tmp = *((u64 *) mac);
750 tmp = clib_net_to_host_u64 (tmp);
751 tmp += 1 << 16; /* skip unused (least significant) octets */
752 tmp = clib_host_to_net_u64 (tmp);
754 clib_memcpy (mac, &tmp, 6);
757 static void vl_api_create_loopback_reply_t_handler
758 (vl_api_create_loopback_reply_t * mp)
760 vat_main_t *vam = &vat_main;
761 i32 retval = ntohl (mp->retval);
763 vam->retval = retval;
764 vam->regenerate_interface_table = 1;
765 vam->sw_if_index = ntohl (mp->sw_if_index);
766 vam->result_ready = 1;
769 static void vl_api_create_loopback_reply_t_handler_json
770 (vl_api_create_loopback_reply_t * mp)
772 vat_main_t *vam = &vat_main;
773 vat_json_node_t node;
775 vat_json_init_object (&node);
776 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
777 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
779 vat_json_print (vam->ofp, &node);
780 vat_json_free (&node);
781 vam->retval = ntohl (mp->retval);
782 vam->result_ready = 1;
785 static void vl_api_create_loopback_instance_reply_t_handler
786 (vl_api_create_loopback_instance_reply_t * mp)
788 vat_main_t *vam = &vat_main;
789 i32 retval = ntohl (mp->retval);
791 vam->retval = retval;
792 vam->regenerate_interface_table = 1;
793 vam->sw_if_index = ntohl (mp->sw_if_index);
794 vam->result_ready = 1;
797 static void vl_api_create_loopback_instance_reply_t_handler_json
798 (vl_api_create_loopback_instance_reply_t * mp)
800 vat_main_t *vam = &vat_main;
801 vat_json_node_t node;
803 vat_json_init_object (&node);
804 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
805 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
807 vat_json_print (vam->ofp, &node);
808 vat_json_free (&node);
809 vam->retval = ntohl (mp->retval);
810 vam->result_ready = 1;
813 static void vl_api_af_packet_create_reply_t_handler
814 (vl_api_af_packet_create_reply_t * mp)
816 vat_main_t *vam = &vat_main;
817 i32 retval = ntohl (mp->retval);
819 vam->retval = retval;
820 vam->regenerate_interface_table = 1;
821 vam->sw_if_index = ntohl (mp->sw_if_index);
822 vam->result_ready = 1;
825 static void vl_api_af_packet_create_reply_t_handler_json
826 (vl_api_af_packet_create_reply_t * mp)
828 vat_main_t *vam = &vat_main;
829 vat_json_node_t node;
831 vat_json_init_object (&node);
832 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
833 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
835 vat_json_print (vam->ofp, &node);
836 vat_json_free (&node);
838 vam->retval = ntohl (mp->retval);
839 vam->result_ready = 1;
842 static void vl_api_create_vlan_subif_reply_t_handler
843 (vl_api_create_vlan_subif_reply_t * mp)
845 vat_main_t *vam = &vat_main;
846 i32 retval = ntohl (mp->retval);
848 vam->retval = retval;
849 vam->regenerate_interface_table = 1;
850 vam->sw_if_index = ntohl (mp->sw_if_index);
851 vam->result_ready = 1;
854 static void vl_api_create_vlan_subif_reply_t_handler_json
855 (vl_api_create_vlan_subif_reply_t * mp)
857 vat_main_t *vam = &vat_main;
858 vat_json_node_t node;
860 vat_json_init_object (&node);
861 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
862 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
864 vat_json_print (vam->ofp, &node);
865 vat_json_free (&node);
867 vam->retval = ntohl (mp->retval);
868 vam->result_ready = 1;
871 static void vl_api_create_subif_reply_t_handler
872 (vl_api_create_subif_reply_t * mp)
874 vat_main_t *vam = &vat_main;
875 i32 retval = ntohl (mp->retval);
877 vam->retval = retval;
878 vam->regenerate_interface_table = 1;
879 vam->sw_if_index = ntohl (mp->sw_if_index);
880 vam->result_ready = 1;
883 static void vl_api_create_subif_reply_t_handler_json
884 (vl_api_create_subif_reply_t * mp)
886 vat_main_t *vam = &vat_main;
887 vat_json_node_t node;
889 vat_json_init_object (&node);
890 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
891 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
893 vat_json_print (vam->ofp, &node);
894 vat_json_free (&node);
896 vam->retval = ntohl (mp->retval);
897 vam->result_ready = 1;
900 static void vl_api_interface_name_renumber_reply_t_handler
901 (vl_api_interface_name_renumber_reply_t * mp)
903 vat_main_t *vam = &vat_main;
904 i32 retval = ntohl (mp->retval);
906 vam->retval = retval;
907 vam->regenerate_interface_table = 1;
908 vam->result_ready = 1;
911 static void vl_api_interface_name_renumber_reply_t_handler_json
912 (vl_api_interface_name_renumber_reply_t * mp)
914 vat_main_t *vam = &vat_main;
915 vat_json_node_t node;
917 vat_json_init_object (&node);
918 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
920 vat_json_print (vam->ofp, &node);
921 vat_json_free (&node);
923 vam->retval = ntohl (mp->retval);
924 vam->result_ready = 1;
928 * Special-case: build the interface table, maintain
929 * the next loopback sw_if_index vbl.
931 static void vl_api_sw_interface_details_t_handler
932 (vl_api_sw_interface_details_t * mp)
934 vat_main_t *vam = &vat_main;
935 u8 *s = format (0, "%s%c", mp->interface_name, 0);
937 hash_set_mem (vam->sw_if_index_by_interface_name, s,
938 ntohl (mp->sw_if_index));
940 /* In sub interface case, fill the sub interface table entry */
941 if (mp->sw_if_index != mp->sup_sw_if_index)
943 sw_interface_subif_t *sub = NULL;
945 vec_add2 (vam->sw_if_subif_table, sub, 1);
947 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
948 strncpy ((char *) sub->interface_name, (char *) s,
949 vec_len (sub->interface_name));
950 sub->sw_if_index = ntohl (mp->sw_if_index);
951 sub->sub_id = ntohl (mp->sub_id);
953 sub->sub_dot1ad = mp->sub_dot1ad;
954 sub->sub_number_of_tags = mp->sub_number_of_tags;
955 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
956 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
957 sub->sub_exact_match = mp->sub_exact_match;
958 sub->sub_default = mp->sub_default;
959 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
960 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
962 /* vlan tag rewrite */
963 sub->vtr_op = ntohl (mp->vtr_op);
964 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
965 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
966 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
970 static void vl_api_sw_interface_details_t_handler_json
971 (vl_api_sw_interface_details_t * mp)
973 vat_main_t *vam = &vat_main;
974 vat_json_node_t *node = NULL;
976 if (VAT_JSON_ARRAY != vam->json_tree.type)
978 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
979 vat_json_init_array (&vam->json_tree);
981 node = vat_json_array_add (&vam->json_tree);
983 vat_json_init_object (node);
984 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
985 vat_json_object_add_uint (node, "sup_sw_if_index",
986 ntohl (mp->sup_sw_if_index));
987 vat_json_object_add_uint (node, "l2_address_length",
988 ntohl (mp->l2_address_length));
989 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
990 sizeof (mp->l2_address));
991 vat_json_object_add_string_copy (node, "interface_name",
993 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
994 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
995 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
996 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
997 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
998 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
999 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
1000 vat_json_object_add_uint (node, "sub_number_of_tags",
1001 mp->sub_number_of_tags);
1002 vat_json_object_add_uint (node, "sub_outer_vlan_id",
1003 ntohs (mp->sub_outer_vlan_id));
1004 vat_json_object_add_uint (node, "sub_inner_vlan_id",
1005 ntohs (mp->sub_inner_vlan_id));
1006 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
1007 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
1008 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
1009 mp->sub_outer_vlan_id_any);
1010 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
1011 mp->sub_inner_vlan_id_any);
1012 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
1013 vat_json_object_add_uint (node, "vtr_push_dot1q",
1014 ntohl (mp->vtr_push_dot1q));
1015 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
1016 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
1019 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
1021 format_ethernet_address,
1023 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
1025 format_ethernet_address,
1027 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
1028 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
1032 #if VPP_API_TEST_BUILTIN == 0
1033 static void vl_api_sw_interface_event_t_handler
1034 (vl_api_sw_interface_event_t * mp)
1036 vat_main_t *vam = &vat_main;
1037 if (vam->interface_event_display)
1038 errmsg ("interface flags: sw_if_index %d %s %s",
1039 ntohl (mp->sw_if_index),
1040 mp->admin_up_down ? "admin-up" : "admin-down",
1041 mp->link_up_down ? "link-up" : "link-down");
1045 static void vl_api_sw_interface_event_t_handler_json
1046 (vl_api_sw_interface_event_t * mp)
1048 /* JSON output not supported */
1052 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
1054 vat_main_t *vam = &vat_main;
1055 i32 retval = ntohl (mp->retval);
1057 vam->retval = retval;
1058 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1059 vam->result_ready = 1;
1063 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1065 vat_main_t *vam = &vat_main;
1066 vat_json_node_t node;
1067 api_main_t *am = &api_main;
1071 vat_json_init_object (&node);
1072 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1073 vat_json_object_add_uint (&node, "reply_in_shmem",
1074 ntohl (mp->reply_in_shmem));
1075 /* Toss the shared-memory original... */
1076 pthread_mutex_lock (&am->vlib_rp->mutex);
1077 oldheap = svm_push_data_heap (am->vlib_rp);
1079 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1082 svm_pop_heap (oldheap);
1083 pthread_mutex_unlock (&am->vlib_rp->mutex);
1085 vat_json_print (vam->ofp, &node);
1086 vat_json_free (&node);
1088 vam->retval = ntohl (mp->retval);
1089 vam->result_ready = 1;
1093 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1095 vat_main_t *vam = &vat_main;
1096 i32 retval = ntohl (mp->retval);
1097 u32 length = ntohl (mp->length);
1099 vec_reset_length (vam->cmd_reply);
1101 vam->retval = retval;
1104 vec_validate (vam->cmd_reply, length);
1105 clib_memcpy ((char *) (vam->cmd_reply), mp->reply, length);
1106 vam->cmd_reply[length] = 0;
1108 vam->result_ready = 1;
1112 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1114 vat_main_t *vam = &vat_main;
1115 vat_json_node_t node;
1117 vec_reset_length (vam->cmd_reply);
1119 vat_json_init_object (&node);
1120 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1121 vat_json_object_add_string_copy (&node, "reply", mp->reply);
1123 vat_json_print (vam->ofp, &node);
1124 vat_json_free (&node);
1126 vam->retval = ntohl (mp->retval);
1127 vam->result_ready = 1;
1130 static void vl_api_classify_add_del_table_reply_t_handler
1131 (vl_api_classify_add_del_table_reply_t * mp)
1133 vat_main_t *vam = &vat_main;
1134 i32 retval = ntohl (mp->retval);
1135 if (vam->async_mode)
1137 vam->async_errors += (retval < 0);
1141 vam->retval = retval;
1143 ((mp->new_table_index != 0xFFFFFFFF) ||
1144 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1145 (mp->match_n_vectors != 0xFFFFFFFF)))
1147 * Note: this is just barely thread-safe, depends on
1148 * the main thread spinning waiting for an answer...
1150 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1151 ntohl (mp->new_table_index),
1152 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1153 vam->result_ready = 1;
1157 static void vl_api_classify_add_del_table_reply_t_handler_json
1158 (vl_api_classify_add_del_table_reply_t * mp)
1160 vat_main_t *vam = &vat_main;
1161 vat_json_node_t node;
1163 vat_json_init_object (&node);
1164 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1165 vat_json_object_add_uint (&node, "new_table_index",
1166 ntohl (mp->new_table_index));
1167 vat_json_object_add_uint (&node, "skip_n_vectors",
1168 ntohl (mp->skip_n_vectors));
1169 vat_json_object_add_uint (&node, "match_n_vectors",
1170 ntohl (mp->match_n_vectors));
1172 vat_json_print (vam->ofp, &node);
1173 vat_json_free (&node);
1175 vam->retval = ntohl (mp->retval);
1176 vam->result_ready = 1;
1179 static void vl_api_get_node_index_reply_t_handler
1180 (vl_api_get_node_index_reply_t * mp)
1182 vat_main_t *vam = &vat_main;
1183 i32 retval = ntohl (mp->retval);
1184 if (vam->async_mode)
1186 vam->async_errors += (retval < 0);
1190 vam->retval = retval;
1192 errmsg ("node index %d", ntohl (mp->node_index));
1193 vam->result_ready = 1;
1197 static void vl_api_get_node_index_reply_t_handler_json
1198 (vl_api_get_node_index_reply_t * mp)
1200 vat_main_t *vam = &vat_main;
1201 vat_json_node_t node;
1203 vat_json_init_object (&node);
1204 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1205 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1207 vat_json_print (vam->ofp, &node);
1208 vat_json_free (&node);
1210 vam->retval = ntohl (mp->retval);
1211 vam->result_ready = 1;
1214 static void vl_api_get_next_index_reply_t_handler
1215 (vl_api_get_next_index_reply_t * mp)
1217 vat_main_t *vam = &vat_main;
1218 i32 retval = ntohl (mp->retval);
1219 if (vam->async_mode)
1221 vam->async_errors += (retval < 0);
1225 vam->retval = retval;
1227 errmsg ("next node index %d", ntohl (mp->next_index));
1228 vam->result_ready = 1;
1232 static void vl_api_get_next_index_reply_t_handler_json
1233 (vl_api_get_next_index_reply_t * mp)
1235 vat_main_t *vam = &vat_main;
1236 vat_json_node_t node;
1238 vat_json_init_object (&node);
1239 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1240 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1242 vat_json_print (vam->ofp, &node);
1243 vat_json_free (&node);
1245 vam->retval = ntohl (mp->retval);
1246 vam->result_ready = 1;
1249 static void vl_api_add_node_next_reply_t_handler
1250 (vl_api_add_node_next_reply_t * mp)
1252 vat_main_t *vam = &vat_main;
1253 i32 retval = ntohl (mp->retval);
1254 if (vam->async_mode)
1256 vam->async_errors += (retval < 0);
1260 vam->retval = retval;
1262 errmsg ("next index %d", ntohl (mp->next_index));
1263 vam->result_ready = 1;
1267 static void vl_api_add_node_next_reply_t_handler_json
1268 (vl_api_add_node_next_reply_t * mp)
1270 vat_main_t *vam = &vat_main;
1271 vat_json_node_t node;
1273 vat_json_init_object (&node);
1274 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1275 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1277 vat_json_print (vam->ofp, &node);
1278 vat_json_free (&node);
1280 vam->retval = ntohl (mp->retval);
1281 vam->result_ready = 1;
1284 static void vl_api_show_version_reply_t_handler
1285 (vl_api_show_version_reply_t * mp)
1287 vat_main_t *vam = &vat_main;
1288 i32 retval = ntohl (mp->retval);
1292 errmsg (" program: %s", mp->program);
1293 errmsg (" version: %s", mp->version);
1294 errmsg (" build date: %s", mp->build_date);
1295 errmsg ("build directory: %s", mp->build_directory);
1297 vam->retval = retval;
1298 vam->result_ready = 1;
1301 static void vl_api_show_version_reply_t_handler_json
1302 (vl_api_show_version_reply_t * mp)
1304 vat_main_t *vam = &vat_main;
1305 vat_json_node_t node;
1307 vat_json_init_object (&node);
1308 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1309 vat_json_object_add_string_copy (&node, "program", mp->program);
1310 vat_json_object_add_string_copy (&node, "version", mp->version);
1311 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1312 vat_json_object_add_string_copy (&node, "build_directory",
1313 mp->build_directory);
1315 vat_json_print (vam->ofp, &node);
1316 vat_json_free (&node);
1318 vam->retval = ntohl (mp->retval);
1319 vam->result_ready = 1;
1322 static void vl_api_show_threads_reply_t_handler
1323 (vl_api_show_threads_reply_t * mp)
1325 vat_main_t *vam = &vat_main;
1326 i32 retval = ntohl (mp->retval);
1330 count = ntohl (mp->count);
1332 for (i = 0; i < count; i++)
1334 "\n%-2d %-11s %-11s %-5d %-6d %-4d %-6d",
1335 ntohl (mp->thread_data[i].id), mp->thread_data[i].name,
1336 mp->thread_data[i].type, ntohl (mp->thread_data[i].pid),
1337 ntohl (mp->thread_data[i].cpu_id), ntohl (mp->thread_data[i].core),
1338 ntohl (mp->thread_data[i].cpu_socket));
1340 vam->retval = retval;
1341 vam->result_ready = 1;
1344 static void vl_api_show_threads_reply_t_handler_json
1345 (vl_api_show_threads_reply_t * mp)
1347 vat_main_t *vam = &vat_main;
1348 vat_json_node_t node;
1349 vl_api_thread_data_t *td;
1350 i32 retval = ntohl (mp->retval);
1354 count = ntohl (mp->count);
1356 vat_json_init_object (&node);
1357 vat_json_object_add_int (&node, "retval", retval);
1358 vat_json_object_add_uint (&node, "count", count);
1360 for (i = 0; i < count; i++)
1362 td = &mp->thread_data[i];
1363 vat_json_object_add_uint (&node, "id", ntohl (td->id));
1364 vat_json_object_add_string_copy (&node, "name", td->name);
1365 vat_json_object_add_string_copy (&node, "type", td->type);
1366 vat_json_object_add_uint (&node, "pid", ntohl (td->pid));
1367 vat_json_object_add_int (&node, "cpu_id", ntohl (td->cpu_id));
1368 vat_json_object_add_int (&node, "core", ntohl (td->id));
1369 vat_json_object_add_int (&node, "cpu_socket", ntohl (td->cpu_socket));
1372 vat_json_print (vam->ofp, &node);
1373 vat_json_free (&node);
1375 vam->retval = retval;
1376 vam->result_ready = 1;
1380 api_show_threads (vat_main_t * vam)
1382 vl_api_show_threads_t *mp;
1386 "\n%-2s %-11s %-11s %-5s %-6s %-4s %-6s",
1387 "ID", "Name", "Type", "LWP", "cpu_id", "Core", "Socket");
1389 M (SHOW_THREADS, mp);
1397 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1399 u32 sw_if_index = ntohl (mp->sw_if_index);
1400 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1401 mp->mac_ip ? "mac/ip binding" : "address resolution",
1402 ntohl (mp->pid), format_ip4_address, &mp->address,
1403 format_ethernet_address, mp->new_mac, sw_if_index);
1407 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1409 /* JSON output not supported */
1413 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1415 u32 sw_if_index = ntohl (mp->sw_if_index);
1416 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1417 mp->mac_ip ? "mac/ip binding" : "address resolution",
1418 ntohl (mp->pid), format_ip6_address, mp->address,
1419 format_ethernet_address, mp->new_mac, sw_if_index);
1423 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1425 /* JSON output not supported */
1429 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1431 u32 n_macs = ntohl (mp->n_macs);
1432 errmsg ("L2MAC event received with pid %d cl-idx %d for %d macs: \n",
1433 ntohl (mp->pid), mp->client_index, n_macs);
1435 for (i = 0; i < n_macs; i++)
1437 vl_api_mac_entry_t *mac = &mp->mac[i];
1438 errmsg (" [%d] sw_if_index %d mac_addr %U action %d \n",
1439 i + 1, ntohl (mac->sw_if_index),
1440 format_ethernet_address, mac->mac_addr, mac->action);
1447 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1449 /* JSON output not supported */
1452 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1453 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1456 * Special-case: build the bridge domain table, maintain
1457 * the next bd id vbl.
1459 static void vl_api_bridge_domain_details_t_handler
1460 (vl_api_bridge_domain_details_t * mp)
1462 vat_main_t *vam = &vat_main;
1463 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1466 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-6s %-3s",
1467 " ID", "LRN", "FWD", "FLD", "BVI", "UU-FWD", "#IF");
1469 print (vam->ofp, "%3d %3d %3d %3d %3d %6d %3d",
1470 ntohl (mp->bd_id), mp->learn, mp->forward,
1471 mp->flood, ntohl (mp->bvi_sw_if_index),
1472 ntohl (mp->uu_fwd_sw_if_index), n_sw_ifs);
1476 vl_api_bridge_domain_sw_if_t *sw_ifs;
1477 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1480 sw_ifs = mp->sw_if_details;
1481 for (i = 0; i < n_sw_ifs; i++)
1487 sw_if_index = ntohl (sw_ifs->sw_if_index);
1490 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1492 if ((u32) p->value[0] == sw_if_index)
1494 sw_if_name = (u8 *)(p->key);
1499 print (vam->ofp, "%7d %3d %s", sw_if_index,
1500 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1501 "sw_if_index not found!");
1508 static void vl_api_bridge_domain_details_t_handler_json
1509 (vl_api_bridge_domain_details_t * mp)
1511 vat_main_t *vam = &vat_main;
1512 vat_json_node_t *node, *array = NULL;
1513 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1515 if (VAT_JSON_ARRAY != vam->json_tree.type)
1517 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1518 vat_json_init_array (&vam->json_tree);
1520 node = vat_json_array_add (&vam->json_tree);
1522 vat_json_init_object (node);
1523 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1524 vat_json_object_add_uint (node, "flood", mp->flood);
1525 vat_json_object_add_uint (node, "forward", mp->forward);
1526 vat_json_object_add_uint (node, "learn", mp->learn);
1527 vat_json_object_add_uint (node, "bvi_sw_if_index",
1528 ntohl (mp->bvi_sw_if_index));
1529 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1530 array = vat_json_object_add (node, "sw_if");
1531 vat_json_init_array (array);
1537 vl_api_bridge_domain_sw_if_t *sw_ifs;
1540 sw_ifs = mp->sw_if_details;
1541 for (i = 0; i < n_sw_ifs; i++)
1543 node = vat_json_array_add (array);
1544 vat_json_init_object (node);
1545 vat_json_object_add_uint (node, "sw_if_index",
1546 ntohl (sw_ifs->sw_if_index));
1547 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1553 static void vl_api_control_ping_reply_t_handler
1554 (vl_api_control_ping_reply_t * mp)
1556 vat_main_t *vam = &vat_main;
1557 i32 retval = ntohl (mp->retval);
1558 if (vam->async_mode)
1560 vam->async_errors += (retval < 0);
1564 vam->retval = retval;
1565 vam->result_ready = 1;
1567 if (vam->socket_client_main)
1568 vam->socket_client_main->control_pings_outstanding--;
1571 static void vl_api_control_ping_reply_t_handler_json
1572 (vl_api_control_ping_reply_t * mp)
1574 vat_main_t *vam = &vat_main;
1575 i32 retval = ntohl (mp->retval);
1577 if (VAT_JSON_NONE != vam->json_tree.type)
1579 vat_json_print (vam->ofp, &vam->json_tree);
1580 vat_json_free (&vam->json_tree);
1581 vam->json_tree.type = VAT_JSON_NONE;
1586 vat_json_init_array (&vam->json_tree);
1587 vat_json_print (vam->ofp, &vam->json_tree);
1588 vam->json_tree.type = VAT_JSON_NONE;
1591 vam->retval = retval;
1592 vam->result_ready = 1;
1596 vl_api_bridge_domain_set_mac_age_reply_t_handler
1597 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1599 vat_main_t *vam = &vat_main;
1600 i32 retval = ntohl (mp->retval);
1601 if (vam->async_mode)
1603 vam->async_errors += (retval < 0);
1607 vam->retval = retval;
1608 vam->result_ready = 1;
1612 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1613 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1615 vat_main_t *vam = &vat_main;
1616 vat_json_node_t node;
1618 vat_json_init_object (&node);
1619 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1621 vat_json_print (vam->ofp, &node);
1622 vat_json_free (&node);
1624 vam->retval = ntohl (mp->retval);
1625 vam->result_ready = 1;
1629 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1631 vat_main_t *vam = &vat_main;
1632 i32 retval = ntohl (mp->retval);
1633 if (vam->async_mode)
1635 vam->async_errors += (retval < 0);
1639 vam->retval = retval;
1640 vam->result_ready = 1;
1644 static void vl_api_l2_flags_reply_t_handler_json
1645 (vl_api_l2_flags_reply_t * mp)
1647 vat_main_t *vam = &vat_main;
1648 vat_json_node_t node;
1650 vat_json_init_object (&node);
1651 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1652 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1653 ntohl (mp->resulting_feature_bitmap));
1655 vat_json_print (vam->ofp, &node);
1656 vat_json_free (&node);
1658 vam->retval = ntohl (mp->retval);
1659 vam->result_ready = 1;
1662 static void vl_api_bridge_flags_reply_t_handler
1663 (vl_api_bridge_flags_reply_t * mp)
1665 vat_main_t *vam = &vat_main;
1666 i32 retval = ntohl (mp->retval);
1667 if (vam->async_mode)
1669 vam->async_errors += (retval < 0);
1673 vam->retval = retval;
1674 vam->result_ready = 1;
1678 static void vl_api_bridge_flags_reply_t_handler_json
1679 (vl_api_bridge_flags_reply_t * mp)
1681 vat_main_t *vam = &vat_main;
1682 vat_json_node_t node;
1684 vat_json_init_object (&node);
1685 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1686 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1687 ntohl (mp->resulting_feature_bitmap));
1689 vat_json_print (vam->ofp, &node);
1690 vat_json_free (&node);
1692 vam->retval = ntohl (mp->retval);
1693 vam->result_ready = 1;
1696 static void vl_api_tap_connect_reply_t_handler
1697 (vl_api_tap_connect_reply_t * mp)
1699 vat_main_t *vam = &vat_main;
1700 i32 retval = ntohl (mp->retval);
1701 if (vam->async_mode)
1703 vam->async_errors += (retval < 0);
1707 vam->retval = retval;
1708 vam->sw_if_index = ntohl (mp->sw_if_index);
1709 vam->result_ready = 1;
1714 static void vl_api_tap_connect_reply_t_handler_json
1715 (vl_api_tap_connect_reply_t * mp)
1717 vat_main_t *vam = &vat_main;
1718 vat_json_node_t node;
1720 vat_json_init_object (&node);
1721 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1722 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1724 vat_json_print (vam->ofp, &node);
1725 vat_json_free (&node);
1727 vam->retval = ntohl (mp->retval);
1728 vam->result_ready = 1;
1733 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1735 vat_main_t *vam = &vat_main;
1736 i32 retval = ntohl (mp->retval);
1737 if (vam->async_mode)
1739 vam->async_errors += (retval < 0);
1743 vam->retval = retval;
1744 vam->sw_if_index = ntohl (mp->sw_if_index);
1745 vam->result_ready = 1;
1749 static void vl_api_tap_modify_reply_t_handler_json
1750 (vl_api_tap_modify_reply_t * mp)
1752 vat_main_t *vam = &vat_main;
1753 vat_json_node_t node;
1755 vat_json_init_object (&node);
1756 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1757 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1759 vat_json_print (vam->ofp, &node);
1760 vat_json_free (&node);
1762 vam->retval = ntohl (mp->retval);
1763 vam->result_ready = 1;
1767 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1769 vat_main_t *vam = &vat_main;
1770 i32 retval = ntohl (mp->retval);
1771 if (vam->async_mode)
1773 vam->async_errors += (retval < 0);
1777 vam->retval = retval;
1778 vam->result_ready = 1;
1782 static void vl_api_tap_delete_reply_t_handler_json
1783 (vl_api_tap_delete_reply_t * mp)
1785 vat_main_t *vam = &vat_main;
1786 vat_json_node_t node;
1788 vat_json_init_object (&node);
1789 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1791 vat_json_print (vam->ofp, &node);
1792 vat_json_free (&node);
1794 vam->retval = ntohl (mp->retval);
1795 vam->result_ready = 1;
1799 vl_api_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_reply_t * mp)
1801 vat_main_t *vam = &vat_main;
1802 i32 retval = ntohl (mp->retval);
1803 if (vam->async_mode)
1805 vam->async_errors += (retval < 0);
1809 vam->retval = retval;
1810 vam->sw_if_index = ntohl (mp->sw_if_index);
1811 vam->result_ready = 1;
1816 static void vl_api_tap_create_v2_reply_t_handler_json
1817 (vl_api_tap_create_v2_reply_t * mp)
1819 vat_main_t *vam = &vat_main;
1820 vat_json_node_t node;
1822 vat_json_init_object (&node);
1823 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1824 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1826 vat_json_print (vam->ofp, &node);
1827 vat_json_free (&node);
1829 vam->retval = ntohl (mp->retval);
1830 vam->result_ready = 1;
1835 vl_api_tap_delete_v2_reply_t_handler (vl_api_tap_delete_v2_reply_t * mp)
1837 vat_main_t *vam = &vat_main;
1838 i32 retval = ntohl (mp->retval);
1839 if (vam->async_mode)
1841 vam->async_errors += (retval < 0);
1845 vam->retval = retval;
1846 vam->result_ready = 1;
1850 static void vl_api_tap_delete_v2_reply_t_handler_json
1851 (vl_api_tap_delete_v2_reply_t * mp)
1853 vat_main_t *vam = &vat_main;
1854 vat_json_node_t node;
1856 vat_json_init_object (&node);
1857 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1859 vat_json_print (vam->ofp, &node);
1860 vat_json_free (&node);
1862 vam->retval = ntohl (mp->retval);
1863 vam->result_ready = 1;
1867 vl_api_bond_create_reply_t_handler (vl_api_bond_create_reply_t * mp)
1869 vat_main_t *vam = &vat_main;
1870 i32 retval = ntohl (mp->retval);
1872 if (vam->async_mode)
1874 vam->async_errors += (retval < 0);
1878 vam->retval = retval;
1879 vam->sw_if_index = ntohl (mp->sw_if_index);
1880 vam->result_ready = 1;
1884 static void vl_api_bond_create_reply_t_handler_json
1885 (vl_api_bond_create_reply_t * mp)
1887 vat_main_t *vam = &vat_main;
1888 vat_json_node_t node;
1890 vat_json_init_object (&node);
1891 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1892 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1894 vat_json_print (vam->ofp, &node);
1895 vat_json_free (&node);
1897 vam->retval = ntohl (mp->retval);
1898 vam->result_ready = 1;
1902 vl_api_bond_delete_reply_t_handler (vl_api_bond_delete_reply_t * mp)
1904 vat_main_t *vam = &vat_main;
1905 i32 retval = ntohl (mp->retval);
1907 if (vam->async_mode)
1909 vam->async_errors += (retval < 0);
1913 vam->retval = retval;
1914 vam->result_ready = 1;
1918 static void vl_api_bond_delete_reply_t_handler_json
1919 (vl_api_bond_delete_reply_t * mp)
1921 vat_main_t *vam = &vat_main;
1922 vat_json_node_t node;
1924 vat_json_init_object (&node);
1925 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1927 vat_json_print (vam->ofp, &node);
1928 vat_json_free (&node);
1930 vam->retval = ntohl (mp->retval);
1931 vam->result_ready = 1;
1935 vl_api_bond_enslave_reply_t_handler (vl_api_bond_enslave_reply_t * mp)
1937 vat_main_t *vam = &vat_main;
1938 i32 retval = ntohl (mp->retval);
1940 if (vam->async_mode)
1942 vam->async_errors += (retval < 0);
1946 vam->retval = retval;
1947 vam->result_ready = 1;
1951 static void vl_api_bond_enslave_reply_t_handler_json
1952 (vl_api_bond_enslave_reply_t * mp)
1954 vat_main_t *vam = &vat_main;
1955 vat_json_node_t node;
1957 vat_json_init_object (&node);
1958 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1960 vat_json_print (vam->ofp, &node);
1961 vat_json_free (&node);
1963 vam->retval = ntohl (mp->retval);
1964 vam->result_ready = 1;
1968 vl_api_bond_detach_slave_reply_t_handler (vl_api_bond_detach_slave_reply_t *
1971 vat_main_t *vam = &vat_main;
1972 i32 retval = ntohl (mp->retval);
1974 if (vam->async_mode)
1976 vam->async_errors += (retval < 0);
1980 vam->retval = retval;
1981 vam->result_ready = 1;
1985 static void vl_api_bond_detach_slave_reply_t_handler_json
1986 (vl_api_bond_detach_slave_reply_t * mp)
1988 vat_main_t *vam = &vat_main;
1989 vat_json_node_t node;
1991 vat_json_init_object (&node);
1992 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1994 vat_json_print (vam->ofp, &node);
1995 vat_json_free (&node);
1997 vam->retval = ntohl (mp->retval);
1998 vam->result_ready = 1;
2001 static void vl_api_sw_interface_bond_details_t_handler
2002 (vl_api_sw_interface_bond_details_t * mp)
2004 vat_main_t *vam = &vat_main;
2007 "%-16s %-12d %-12U %-13U %-14u %-14u",
2008 mp->interface_name, ntohl (mp->sw_if_index),
2009 format_bond_mode, mp->mode, format_bond_load_balance, mp->lb,
2010 ntohl (mp->active_slaves), ntohl (mp->slaves));
2013 static void vl_api_sw_interface_bond_details_t_handler_json
2014 (vl_api_sw_interface_bond_details_t * mp)
2016 vat_main_t *vam = &vat_main;
2017 vat_json_node_t *node = NULL;
2019 if (VAT_JSON_ARRAY != vam->json_tree.type)
2021 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2022 vat_json_init_array (&vam->json_tree);
2024 node = vat_json_array_add (&vam->json_tree);
2026 vat_json_init_object (node);
2027 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2028 vat_json_object_add_string_copy (node, "interface_name",
2029 mp->interface_name);
2030 vat_json_object_add_uint (node, "mode", mp->mode);
2031 vat_json_object_add_uint (node, "load_balance", mp->lb);
2032 vat_json_object_add_uint (node, "active_slaves", ntohl (mp->active_slaves));
2033 vat_json_object_add_uint (node, "slaves", ntohl (mp->slaves));
2037 api_sw_interface_bond_dump (vat_main_t * vam)
2039 vl_api_sw_interface_bond_dump_t *mp;
2040 vl_api_control_ping_t *mp_ping;
2044 "\n%-16s %-12s %-12s %-13s %-14s %-14s",
2045 "interface name", "sw_if_index", "mode", "load balance",
2046 "active slaves", "slaves");
2048 /* Get list of bond interfaces */
2049 M (SW_INTERFACE_BOND_DUMP, mp);
2052 /* Use a control ping for synchronization */
2053 MPING (CONTROL_PING, mp_ping);
2060 static void vl_api_sw_interface_slave_details_t_handler
2061 (vl_api_sw_interface_slave_details_t * mp)
2063 vat_main_t *vam = &vat_main;
2066 "%-25s %-12d %-12d %d", mp->interface_name,
2067 ntohl (mp->sw_if_index), mp->is_passive, mp->is_long_timeout);
2070 static void vl_api_sw_interface_slave_details_t_handler_json
2071 (vl_api_sw_interface_slave_details_t * mp)
2073 vat_main_t *vam = &vat_main;
2074 vat_json_node_t *node = NULL;
2076 if (VAT_JSON_ARRAY != vam->json_tree.type)
2078 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2079 vat_json_init_array (&vam->json_tree);
2081 node = vat_json_array_add (&vam->json_tree);
2083 vat_json_init_object (node);
2084 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2085 vat_json_object_add_string_copy (node, "interface_name",
2086 mp->interface_name);
2087 vat_json_object_add_uint (node, "passive", mp->is_passive);
2088 vat_json_object_add_uint (node, "long_timeout", mp->is_long_timeout);
2092 api_sw_interface_slave_dump (vat_main_t * vam)
2094 unformat_input_t *i = vam->input;
2095 vl_api_sw_interface_slave_dump_t *mp;
2096 vl_api_control_ping_t *mp_ping;
2097 u32 sw_if_index = ~0;
2098 u8 sw_if_index_set = 0;
2101 /* Parse args required to build the message */
2102 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2104 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2105 sw_if_index_set = 1;
2106 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2107 sw_if_index_set = 1;
2112 if (sw_if_index_set == 0)
2114 errmsg ("missing vpp interface name. ");
2119 "\n%-25s %-12s %-12s %s",
2120 "slave interface name", "sw_if_index", "passive", "long_timeout");
2122 /* Get list of bond interfaces */
2123 M (SW_INTERFACE_SLAVE_DUMP, mp);
2124 mp->sw_if_index = ntohl (sw_if_index);
2127 /* Use a control ping for synchronization */
2128 MPING (CONTROL_PING, mp_ping);
2135 static void vl_api_mpls_tunnel_add_del_reply_t_handler
2136 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2138 vat_main_t *vam = &vat_main;
2139 i32 retval = ntohl (mp->retval);
2140 if (vam->async_mode)
2142 vam->async_errors += (retval < 0);
2146 vam->retval = retval;
2147 vam->result_ready = 1;
2151 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
2152 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2154 vat_main_t *vam = &vat_main;
2155 vat_json_node_t node;
2157 vat_json_init_object (&node);
2158 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2159 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
2160 ntohl (mp->sw_if_index));
2162 vat_json_print (vam->ofp, &node);
2163 vat_json_free (&node);
2165 vam->retval = ntohl (mp->retval);
2166 vam->result_ready = 1;
2169 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
2170 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2172 vat_main_t *vam = &vat_main;
2173 i32 retval = ntohl (mp->retval);
2174 if (vam->async_mode)
2176 vam->async_errors += (retval < 0);
2180 vam->retval = retval;
2181 vam->sw_if_index = ntohl (mp->sw_if_index);
2182 vam->result_ready = 1;
2186 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
2187 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2189 vat_main_t *vam = &vat_main;
2190 vat_json_node_t node;
2192 vat_json_init_object (&node);
2193 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2194 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2196 vat_json_print (vam->ofp, &node);
2197 vat_json_free (&node);
2199 vam->retval = ntohl (mp->retval);
2200 vam->result_ready = 1;
2203 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
2204 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2206 vat_main_t *vam = &vat_main;
2207 i32 retval = ntohl (mp->retval);
2208 if (vam->async_mode)
2210 vam->async_errors += (retval < 0);
2214 vam->retval = retval;
2215 vam->result_ready = 1;
2219 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
2220 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2222 vat_main_t *vam = &vat_main;
2223 vat_json_node_t node;
2225 vat_json_init_object (&node);
2226 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2227 vat_json_object_add_uint (&node, "fwd_entry_index",
2228 clib_net_to_host_u32 (mp->fwd_entry_index));
2230 vat_json_print (vam->ofp, &node);
2231 vat_json_free (&node);
2233 vam->retval = ntohl (mp->retval);
2234 vam->result_ready = 1;
2238 format_lisp_transport_protocol (u8 * s, va_list * args)
2240 u32 proto = va_arg (*args, u32);
2245 return format (s, "udp");
2247 return format (s, "api");
2254 static void vl_api_one_get_transport_protocol_reply_t_handler
2255 (vl_api_one_get_transport_protocol_reply_t * mp)
2257 vat_main_t *vam = &vat_main;
2258 i32 retval = ntohl (mp->retval);
2259 if (vam->async_mode)
2261 vam->async_errors += (retval < 0);
2265 u32 proto = mp->protocol;
2266 print (vam->ofp, "Transport protocol: %U",
2267 format_lisp_transport_protocol, proto);
2268 vam->retval = retval;
2269 vam->result_ready = 1;
2273 static void vl_api_one_get_transport_protocol_reply_t_handler_json
2274 (vl_api_one_get_transport_protocol_reply_t * mp)
2276 vat_main_t *vam = &vat_main;
2277 vat_json_node_t node;
2280 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
2283 vat_json_init_object (&node);
2284 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2285 vat_json_object_add_string_copy (&node, "transport-protocol", s);
2288 vat_json_print (vam->ofp, &node);
2289 vat_json_free (&node);
2291 vam->retval = ntohl (mp->retval);
2292 vam->result_ready = 1;
2295 static void vl_api_one_add_del_locator_set_reply_t_handler
2296 (vl_api_one_add_del_locator_set_reply_t * mp)
2298 vat_main_t *vam = &vat_main;
2299 i32 retval = ntohl (mp->retval);
2300 if (vam->async_mode)
2302 vam->async_errors += (retval < 0);
2306 vam->retval = retval;
2307 vam->result_ready = 1;
2311 static void vl_api_one_add_del_locator_set_reply_t_handler_json
2312 (vl_api_one_add_del_locator_set_reply_t * mp)
2314 vat_main_t *vam = &vat_main;
2315 vat_json_node_t node;
2317 vat_json_init_object (&node);
2318 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2319 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
2321 vat_json_print (vam->ofp, &node);
2322 vat_json_free (&node);
2324 vam->retval = ntohl (mp->retval);
2325 vam->result_ready = 1;
2328 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
2329 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2331 vat_main_t *vam = &vat_main;
2332 i32 retval = ntohl (mp->retval);
2333 if (vam->async_mode)
2335 vam->async_errors += (retval < 0);
2339 vam->retval = retval;
2340 vam->sw_if_index = ntohl (mp->sw_if_index);
2341 vam->result_ready = 1;
2343 vam->regenerate_interface_table = 1;
2346 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
2347 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2349 vat_main_t *vam = &vat_main;
2350 vat_json_node_t node;
2352 vat_json_init_object (&node);
2353 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2354 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2356 vat_json_print (vam->ofp, &node);
2357 vat_json_free (&node);
2359 vam->retval = ntohl (mp->retval);
2360 vam->result_ready = 1;
2363 static void vl_api_vxlan_offload_rx_reply_t_handler
2364 (vl_api_vxlan_offload_rx_reply_t * mp)
2366 vat_main_t *vam = &vat_main;
2367 i32 retval = ntohl (mp->retval);
2368 if (vam->async_mode)
2370 vam->async_errors += (retval < 0);
2374 vam->retval = retval;
2375 vam->result_ready = 1;
2379 static void vl_api_vxlan_offload_rx_reply_t_handler_json
2380 (vl_api_vxlan_offload_rx_reply_t * mp)
2382 vat_main_t *vam = &vat_main;
2383 vat_json_node_t node;
2385 vat_json_init_object (&node);
2386 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2388 vat_json_print (vam->ofp, &node);
2389 vat_json_free (&node);
2391 vam->retval = ntohl (mp->retval);
2392 vam->result_ready = 1;
2395 static void vl_api_geneve_add_del_tunnel_reply_t_handler
2396 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2398 vat_main_t *vam = &vat_main;
2399 i32 retval = ntohl (mp->retval);
2400 if (vam->async_mode)
2402 vam->async_errors += (retval < 0);
2406 vam->retval = retval;
2407 vam->sw_if_index = ntohl (mp->sw_if_index);
2408 vam->result_ready = 1;
2412 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
2413 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2415 vat_main_t *vam = &vat_main;
2416 vat_json_node_t node;
2418 vat_json_init_object (&node);
2419 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2420 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2422 vat_json_print (vam->ofp, &node);
2423 vat_json_free (&node);
2425 vam->retval = ntohl (mp->retval);
2426 vam->result_ready = 1;
2429 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
2430 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2432 vat_main_t *vam = &vat_main;
2433 i32 retval = ntohl (mp->retval);
2434 if (vam->async_mode)
2436 vam->async_errors += (retval < 0);
2440 vam->retval = retval;
2441 vam->sw_if_index = ntohl (mp->sw_if_index);
2442 vam->result_ready = 1;
2444 vam->regenerate_interface_table = 1;
2447 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
2448 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2450 vat_main_t *vam = &vat_main;
2451 vat_json_node_t node;
2453 vat_json_init_object (&node);
2454 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2455 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2457 vat_json_print (vam->ofp, &node);
2458 vat_json_free (&node);
2460 vam->retval = ntohl (mp->retval);
2461 vam->result_ready = 1;
2464 static void vl_api_gre_add_del_tunnel_reply_t_handler
2465 (vl_api_gre_add_del_tunnel_reply_t * mp)
2467 vat_main_t *vam = &vat_main;
2468 i32 retval = ntohl (mp->retval);
2469 if (vam->async_mode)
2471 vam->async_errors += (retval < 0);
2475 vam->retval = retval;
2476 vam->sw_if_index = ntohl (mp->sw_if_index);
2477 vam->result_ready = 1;
2481 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
2482 (vl_api_gre_add_del_tunnel_reply_t * mp)
2484 vat_main_t *vam = &vat_main;
2485 vat_json_node_t node;
2487 vat_json_init_object (&node);
2488 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2489 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2491 vat_json_print (vam->ofp, &node);
2492 vat_json_free (&node);
2494 vam->retval = ntohl (mp->retval);
2495 vam->result_ready = 1;
2498 static void vl_api_create_vhost_user_if_reply_t_handler
2499 (vl_api_create_vhost_user_if_reply_t * mp)
2501 vat_main_t *vam = &vat_main;
2502 i32 retval = ntohl (mp->retval);
2503 if (vam->async_mode)
2505 vam->async_errors += (retval < 0);
2509 vam->retval = retval;
2510 vam->sw_if_index = ntohl (mp->sw_if_index);
2511 vam->result_ready = 1;
2513 vam->regenerate_interface_table = 1;
2516 static void vl_api_create_vhost_user_if_reply_t_handler_json
2517 (vl_api_create_vhost_user_if_reply_t * mp)
2519 vat_main_t *vam = &vat_main;
2520 vat_json_node_t node;
2522 vat_json_init_object (&node);
2523 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2524 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2526 vat_json_print (vam->ofp, &node);
2527 vat_json_free (&node);
2529 vam->retval = ntohl (mp->retval);
2530 vam->result_ready = 1;
2533 static void vl_api_dns_resolve_name_reply_t_handler
2534 (vl_api_dns_resolve_name_reply_t * mp)
2536 vat_main_t *vam = &vat_main;
2537 i32 retval = ntohl (mp->retval);
2538 if (vam->async_mode)
2540 vam->async_errors += (retval < 0);
2544 vam->retval = retval;
2545 vam->result_ready = 1;
2550 clib_warning ("ip4 address %U", format_ip4_address,
2551 (ip4_address_t *) mp->ip4_address);
2553 clib_warning ("ip6 address %U", format_ip6_address,
2554 (ip6_address_t *) mp->ip6_address);
2557 clib_warning ("retval %d", retval);
2561 static void vl_api_dns_resolve_name_reply_t_handler_json
2562 (vl_api_dns_resolve_name_reply_t * mp)
2564 clib_warning ("not implemented");
2567 static void vl_api_dns_resolve_ip_reply_t_handler
2568 (vl_api_dns_resolve_ip_reply_t * mp)
2570 vat_main_t *vam = &vat_main;
2571 i32 retval = ntohl (mp->retval);
2572 if (vam->async_mode)
2574 vam->async_errors += (retval < 0);
2578 vam->retval = retval;
2579 vam->result_ready = 1;
2583 clib_warning ("canonical name %s", mp->name);
2586 clib_warning ("retval %d", retval);
2590 static void vl_api_dns_resolve_ip_reply_t_handler_json
2591 (vl_api_dns_resolve_ip_reply_t * mp)
2593 clib_warning ("not implemented");
2597 static void vl_api_ip_address_details_t_handler
2598 (vl_api_ip_address_details_t * mp)
2600 vat_main_t *vam = &vat_main;
2601 static ip_address_details_t empty_ip_address_details = { {0} };
2602 ip_address_details_t *address = NULL;
2603 ip_details_t *current_ip_details = NULL;
2604 ip_details_t *details = NULL;
2606 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2608 if (!details || vam->current_sw_if_index >= vec_len (details)
2609 || !details[vam->current_sw_if_index].present)
2611 errmsg ("ip address details arrived but not stored");
2612 errmsg ("ip_dump should be called first");
2616 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2618 #define addresses (current_ip_details->addr)
2620 vec_validate_init_empty (addresses, vec_len (addresses),
2621 empty_ip_address_details);
2623 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2625 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
2626 address->prefix_length = mp->prefix_length;
2630 static void vl_api_ip_address_details_t_handler_json
2631 (vl_api_ip_address_details_t * mp)
2633 vat_main_t *vam = &vat_main;
2634 vat_json_node_t *node = NULL;
2635 struct in6_addr ip6;
2638 if (VAT_JSON_ARRAY != vam->json_tree.type)
2640 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2641 vat_json_init_array (&vam->json_tree);
2643 node = vat_json_array_add (&vam->json_tree);
2645 vat_json_init_object (node);
2648 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
2649 vat_json_object_add_ip6 (node, "ip", ip6);
2653 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
2654 vat_json_object_add_ip4 (node, "ip", ip4);
2656 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
2660 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2662 vat_main_t *vam = &vat_main;
2663 static ip_details_t empty_ip_details = { 0 };
2664 ip_details_t *ip = NULL;
2665 u32 sw_if_index = ~0;
2667 sw_if_index = ntohl (mp->sw_if_index);
2669 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2670 sw_if_index, empty_ip_details);
2672 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2679 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2681 vat_main_t *vam = &vat_main;
2683 if (VAT_JSON_ARRAY != vam->json_tree.type)
2685 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2686 vat_json_init_array (&vam->json_tree);
2688 vat_json_array_add_uint (&vam->json_tree,
2689 clib_net_to_host_u32 (mp->sw_if_index));
2693 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2695 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2696 "router_addr %U host_mac %U",
2697 ntohl (mp->pid), mp->lease.is_ipv6 ? "ipv6" : "ipv4",
2699 format_ip4_address, &mp->lease.host_address,
2700 format_ip4_address, &mp->lease.router_address,
2701 format_ethernet_address, mp->lease.host_mac);
2704 static void vl_api_dhcp_compl_event_t_handler_json
2705 (vl_api_dhcp_compl_event_t * mp)
2707 /* JSON output not supported */
2711 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2714 vat_main_t *vam = &vat_main;
2715 static u64 default_counter = 0;
2717 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2719 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2720 sw_if_index, default_counter);
2721 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2725 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2726 interface_counter_t counter)
2728 vat_main_t *vam = &vat_main;
2729 static interface_counter_t default_counter = { 0, };
2731 vec_validate_init_empty (vam->combined_interface_counters,
2732 vnet_counter_type, NULL);
2733 vec_validate_init_empty (vam->combined_interface_counters
2734 [vnet_counter_type], sw_if_index, default_counter);
2735 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2738 static void vl_api_vnet_interface_simple_counters_t_handler
2739 (vl_api_vnet_interface_simple_counters_t * mp)
2744 static void vl_api_vnet_interface_combined_counters_t_handler
2745 (vl_api_vnet_interface_combined_counters_t * mp)
2750 static void vl_api_vnet_interface_simple_counters_t_handler_json
2751 (vl_api_vnet_interface_simple_counters_t * mp)
2756 u32 first_sw_if_index;
2759 count = ntohl (mp->count);
2760 first_sw_if_index = ntohl (mp->first_sw_if_index);
2762 v_packets = (u64 *) & mp->data;
2763 for (i = 0; i < count; i++)
2765 packets = clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2766 set_simple_interface_counter (mp->vnet_counter_type,
2767 first_sw_if_index + i, packets);
2772 static void vl_api_vnet_interface_combined_counters_t_handler_json
2773 (vl_api_vnet_interface_combined_counters_t * mp)
2775 interface_counter_t counter;
2777 u32 first_sw_if_index;
2781 count = ntohl (mp->count);
2782 first_sw_if_index = ntohl (mp->first_sw_if_index);
2784 v = (vlib_counter_t *) & mp->data;
2785 for (i = 0; i < count; i++)
2788 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2790 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2791 set_combined_interface_counter (mp->vnet_counter_type,
2792 first_sw_if_index + i, counter);
2798 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2800 vat_main_t *vam = &vat_main;
2803 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2805 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2814 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2816 vat_main_t *vam = &vat_main;
2819 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2821 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2829 static void vl_api_vnet_ip4_fib_counters_t_handler
2830 (vl_api_vnet_ip4_fib_counters_t * mp)
2835 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2836 (vl_api_vnet_ip4_fib_counters_t * mp)
2838 vat_main_t *vam = &vat_main;
2839 vl_api_ip4_fib_counter_t *v;
2840 ip4_fib_counter_t *counter;
2847 vrf_id = ntohl (mp->vrf_id);
2848 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2849 if (~0 == vrf_index)
2851 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2852 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2853 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2854 vec_validate (vam->ip4_fib_counters, vrf_index);
2855 vam->ip4_fib_counters[vrf_index] = NULL;
2858 vec_free (vam->ip4_fib_counters[vrf_index]);
2859 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2860 count = ntohl (mp->count);
2861 for (i = 0; i < count; i++)
2863 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2864 counter = &vam->ip4_fib_counters[vrf_index][i];
2865 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2866 counter->address = ip4;
2867 counter->address_length = v->address_length;
2868 counter->packets = clib_net_to_host_u64 (v->packets);
2869 counter->bytes = clib_net_to_host_u64 (v->bytes);
2874 static void vl_api_vnet_ip4_nbr_counters_t_handler
2875 (vl_api_vnet_ip4_nbr_counters_t * mp)
2880 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2881 (vl_api_vnet_ip4_nbr_counters_t * mp)
2883 vat_main_t *vam = &vat_main;
2884 vl_api_ip4_nbr_counter_t *v;
2885 ip4_nbr_counter_t *counter;
2890 sw_if_index = ntohl (mp->sw_if_index);
2891 count = ntohl (mp->count);
2892 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2895 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2897 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2898 for (i = 0; i < count; i++)
2900 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2901 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2902 counter->address.s_addr = v->address;
2903 counter->packets = clib_net_to_host_u64 (v->packets);
2904 counter->bytes = clib_net_to_host_u64 (v->bytes);
2905 counter->linkt = v->link_type;
2910 static void vl_api_vnet_ip6_fib_counters_t_handler
2911 (vl_api_vnet_ip6_fib_counters_t * mp)
2916 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2917 (vl_api_vnet_ip6_fib_counters_t * mp)
2919 vat_main_t *vam = &vat_main;
2920 vl_api_ip6_fib_counter_t *v;
2921 ip6_fib_counter_t *counter;
2922 struct in6_addr ip6;
2928 vrf_id = ntohl (mp->vrf_id);
2929 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2930 if (~0 == vrf_index)
2932 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2933 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2934 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2935 vec_validate (vam->ip6_fib_counters, vrf_index);
2936 vam->ip6_fib_counters[vrf_index] = NULL;
2939 vec_free (vam->ip6_fib_counters[vrf_index]);
2940 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2941 count = ntohl (mp->count);
2942 for (i = 0; i < count; i++)
2944 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2945 counter = &vam->ip6_fib_counters[vrf_index][i];
2946 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2947 counter->address = ip6;
2948 counter->address_length = v->address_length;
2949 counter->packets = clib_net_to_host_u64 (v->packets);
2950 counter->bytes = clib_net_to_host_u64 (v->bytes);
2955 static void vl_api_vnet_ip6_nbr_counters_t_handler
2956 (vl_api_vnet_ip6_nbr_counters_t * mp)
2961 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2962 (vl_api_vnet_ip6_nbr_counters_t * mp)
2964 vat_main_t *vam = &vat_main;
2965 vl_api_ip6_nbr_counter_t *v;
2966 ip6_nbr_counter_t *counter;
2967 struct in6_addr ip6;
2972 sw_if_index = ntohl (mp->sw_if_index);
2973 count = ntohl (mp->count);
2974 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2977 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2979 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2980 for (i = 0; i < count; i++)
2982 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2983 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2984 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2985 counter->address = ip6;
2986 counter->packets = clib_net_to_host_u64 (v->packets);
2987 counter->bytes = clib_net_to_host_u64 (v->bytes);
2992 static void vl_api_get_first_msg_id_reply_t_handler
2993 (vl_api_get_first_msg_id_reply_t * mp)
2995 vat_main_t *vam = &vat_main;
2996 i32 retval = ntohl (mp->retval);
2998 if (vam->async_mode)
3000 vam->async_errors += (retval < 0);
3004 vam->retval = retval;
3005 vam->result_ready = 1;
3009 errmsg ("first message id %d", ntohs (mp->first_msg_id));
3013 static void vl_api_get_first_msg_id_reply_t_handler_json
3014 (vl_api_get_first_msg_id_reply_t * mp)
3016 vat_main_t *vam = &vat_main;
3017 vat_json_node_t node;
3019 vat_json_init_object (&node);
3020 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3021 vat_json_object_add_uint (&node, "first_msg_id",
3022 (uint) ntohs (mp->first_msg_id));
3024 vat_json_print (vam->ofp, &node);
3025 vat_json_free (&node);
3027 vam->retval = ntohl (mp->retval);
3028 vam->result_ready = 1;
3031 static void vl_api_get_node_graph_reply_t_handler
3032 (vl_api_get_node_graph_reply_t * mp)
3034 vat_main_t *vam = &vat_main;
3035 api_main_t *am = &api_main;
3036 i32 retval = ntohl (mp->retval);
3037 u8 *pvt_copy, *reply;
3042 if (vam->async_mode)
3044 vam->async_errors += (retval < 0);
3048 vam->retval = retval;
3049 vam->result_ready = 1;
3052 /* "Should never happen..." */
3056 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
3057 pvt_copy = vec_dup (reply);
3059 /* Toss the shared-memory original... */
3060 pthread_mutex_lock (&am->vlib_rp->mutex);
3061 oldheap = svm_push_data_heap (am->vlib_rp);
3065 svm_pop_heap (oldheap);
3066 pthread_mutex_unlock (&am->vlib_rp->mutex);
3068 if (vam->graph_nodes)
3070 hash_free (vam->graph_node_index_by_name);
3072 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
3074 node = vam->graph_nodes[0][i];
3075 vec_free (node->name);
3076 vec_free (node->next_nodes);
3079 vec_free (vam->graph_nodes[0]);
3080 vec_free (vam->graph_nodes);
3083 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
3084 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
3085 vec_free (pvt_copy);
3087 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
3089 node = vam->graph_nodes[0][i];
3090 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
3094 static void vl_api_get_node_graph_reply_t_handler_json
3095 (vl_api_get_node_graph_reply_t * mp)
3097 vat_main_t *vam = &vat_main;
3098 api_main_t *am = &api_main;
3100 vat_json_node_t node;
3103 /* $$$$ make this real? */
3104 vat_json_init_object (&node);
3105 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3106 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
3108 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
3110 /* Toss the shared-memory original... */
3111 pthread_mutex_lock (&am->vlib_rp->mutex);
3112 oldheap = svm_push_data_heap (am->vlib_rp);
3116 svm_pop_heap (oldheap);
3117 pthread_mutex_unlock (&am->vlib_rp->mutex);
3119 vat_json_print (vam->ofp, &node);
3120 vat_json_free (&node);
3122 vam->retval = ntohl (mp->retval);
3123 vam->result_ready = 1;
3127 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
3129 vat_main_t *vam = &vat_main;
3134 s = format (s, "%=16d%=16d%=16d",
3135 ntohl (mp->sw_if_index), mp->priority, mp->weight);
3139 s = format (s, "%=16U%=16d%=16d",
3140 mp->is_ipv6 ? format_ip6_address :
3142 mp->ip_address, mp->priority, mp->weight);
3145 print (vam->ofp, "%v", s);
3150 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
3152 vat_main_t *vam = &vat_main;
3153 vat_json_node_t *node = NULL;
3154 struct in6_addr ip6;
3157 if (VAT_JSON_ARRAY != vam->json_tree.type)
3159 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3160 vat_json_init_array (&vam->json_tree);
3162 node = vat_json_array_add (&vam->json_tree);
3163 vat_json_init_object (node);
3165 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
3166 vat_json_object_add_uint (node, "priority", mp->priority);
3167 vat_json_object_add_uint (node, "weight", mp->weight);
3170 vat_json_object_add_uint (node, "sw_if_index",
3171 clib_net_to_host_u32 (mp->sw_if_index));
3176 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3177 vat_json_object_add_ip6 (node, "address", ip6);
3181 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3182 vat_json_object_add_ip4 (node, "address", ip4);
3188 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
3191 vat_main_t *vam = &vat_main;
3194 ls_name = format (0, "%s", mp->ls_name);
3196 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
3202 vl_api_one_locator_set_details_t_handler_json
3203 (vl_api_one_locator_set_details_t * mp)
3205 vat_main_t *vam = &vat_main;
3206 vat_json_node_t *node = 0;
3209 ls_name = format (0, "%s", mp->ls_name);
3210 vec_add1 (ls_name, 0);
3212 if (VAT_JSON_ARRAY != vam->json_tree.type)
3214 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3215 vat_json_init_array (&vam->json_tree);
3217 node = vat_json_array_add (&vam->json_tree);
3219 vat_json_init_object (node);
3220 vat_json_object_add_string_copy (node, "ls_name", ls_name);
3221 vat_json_object_add_uint (node, "ls_index",
3222 clib_net_to_host_u32 (mp->ls_index));
3230 } __attribute__ ((__packed__)) lisp_nsh_api_t;
3233 unformat_nsh_address (unformat_input_t * input, va_list * args)
3235 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
3236 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
3240 format_nsh_address_vat (u8 * s, va_list * args)
3242 nsh_t *a = va_arg (*args, nsh_t *);
3243 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
3247 format_lisp_flat_eid (u8 * s, va_list * args)
3249 u32 type = va_arg (*args, u32);
3250 u8 *eid = va_arg (*args, u8 *);
3251 u32 eid_len = va_arg (*args, u32);
3256 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
3258 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
3260 return format (s, "%U", format_ethernet_address, eid);
3262 return format (s, "%U", format_nsh_address_vat, eid);
3268 format_lisp_eid_vat (u8 * s, va_list * args)
3270 u32 type = va_arg (*args, u32);
3271 u8 *eid = va_arg (*args, u8 *);
3272 u32 eid_len = va_arg (*args, u32);
3273 u8 *seid = va_arg (*args, u8 *);
3274 u32 seid_len = va_arg (*args, u32);
3275 u32 is_src_dst = va_arg (*args, u32);
3278 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
3280 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
3286 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
3288 vat_main_t *vam = &vat_main;
3289 u8 *s = 0, *eid = 0;
3291 if (~0 == mp->locator_set_index)
3292 s = format (0, "action: %d", mp->action);
3294 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3296 eid = format (0, "%U", format_lisp_eid_vat,
3300 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3303 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3304 clib_net_to_host_u32 (mp->vni),
3306 mp->is_local ? "local" : "remote",
3307 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3308 clib_net_to_host_u16 (mp->key_id), mp->key);
3315 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3318 vat_main_t *vam = &vat_main;
3319 vat_json_node_t *node = 0;
3322 if (VAT_JSON_ARRAY != vam->json_tree.type)
3324 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3325 vat_json_init_array (&vam->json_tree);
3327 node = vat_json_array_add (&vam->json_tree);
3329 vat_json_init_object (node);
3330 if (~0 == mp->locator_set_index)
3331 vat_json_object_add_uint (node, "action", mp->action);
3333 vat_json_object_add_uint (node, "locator_set_index",
3334 clib_net_to_host_u32 (mp->locator_set_index));
3336 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3337 if (mp->eid_type == 3)
3339 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3340 vat_json_init_object (nsh_json);
3341 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3342 vat_json_object_add_uint (nsh_json, "spi",
3343 clib_net_to_host_u32 (nsh->spi));
3344 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3348 eid = format (0, "%U", format_lisp_eid_vat,
3352 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3354 vat_json_object_add_string_copy (node, "eid", eid);
3357 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3358 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3359 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3363 vat_json_object_add_uint (node, "key_id",
3364 clib_net_to_host_u16 (mp->key_id));
3365 vat_json_object_add_string_copy (node, "key", mp->key);
3370 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3372 vat_main_t *vam = &vat_main;
3373 u8 *seid = 0, *deid = 0;
3374 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3376 deid = format (0, "%U", format_lisp_eid_vat,
3377 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3379 seid = format (0, "%U", format_lisp_eid_vat,
3380 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3386 format_ip_address_fcn = format_ip4_address;
3388 format_ip_address_fcn = format_ip6_address;
3391 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3392 clib_net_to_host_u32 (mp->vni),
3394 format_ip_address_fcn, mp->lloc,
3395 format_ip_address_fcn, mp->rloc,
3396 clib_net_to_host_u32 (mp->pkt_count),
3397 clib_net_to_host_u32 (mp->bytes));
3404 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3406 struct in6_addr ip6;
3408 vat_main_t *vam = &vat_main;
3409 vat_json_node_t *node = 0;
3410 u8 *deid = 0, *seid = 0;
3412 if (VAT_JSON_ARRAY != vam->json_tree.type)
3414 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3415 vat_json_init_array (&vam->json_tree);
3417 node = vat_json_array_add (&vam->json_tree);
3419 vat_json_init_object (node);
3420 deid = format (0, "%U", format_lisp_eid_vat,
3421 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3423 seid = format (0, "%U", format_lisp_eid_vat,
3424 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3429 vat_json_object_add_string_copy (node, "seid", seid);
3430 vat_json_object_add_string_copy (node, "deid", deid);
3431 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3435 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3436 vat_json_object_add_ip4 (node, "lloc", ip4);
3437 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3438 vat_json_object_add_ip4 (node, "rloc", ip4);
3442 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3443 vat_json_object_add_ip6 (node, "lloc", ip6);
3444 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3445 vat_json_object_add_ip6 (node, "rloc", ip6);
3447 vat_json_object_add_uint (node, "pkt_count",
3448 clib_net_to_host_u32 (mp->pkt_count));
3449 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3456 vl_api_one_eid_table_map_details_t_handler
3457 (vl_api_one_eid_table_map_details_t * mp)
3459 vat_main_t *vam = &vat_main;
3461 u8 *line = format (0, "%=10d%=10d",
3462 clib_net_to_host_u32 (mp->vni),
3463 clib_net_to_host_u32 (mp->dp_table));
3464 print (vam->ofp, "%v", line);
3469 vl_api_one_eid_table_map_details_t_handler_json
3470 (vl_api_one_eid_table_map_details_t * mp)
3472 vat_main_t *vam = &vat_main;
3473 vat_json_node_t *node = NULL;
3475 if (VAT_JSON_ARRAY != vam->json_tree.type)
3477 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3478 vat_json_init_array (&vam->json_tree);
3480 node = vat_json_array_add (&vam->json_tree);
3481 vat_json_init_object (node);
3482 vat_json_object_add_uint (node, "dp_table",
3483 clib_net_to_host_u32 (mp->dp_table));
3484 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3488 vl_api_one_eid_table_vni_details_t_handler
3489 (vl_api_one_eid_table_vni_details_t * mp)
3491 vat_main_t *vam = &vat_main;
3493 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3494 print (vam->ofp, "%v", line);
3499 vl_api_one_eid_table_vni_details_t_handler_json
3500 (vl_api_one_eid_table_vni_details_t * mp)
3502 vat_main_t *vam = &vat_main;
3503 vat_json_node_t *node = NULL;
3505 if (VAT_JSON_ARRAY != vam->json_tree.type)
3507 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3508 vat_json_init_array (&vam->json_tree);
3510 node = vat_json_array_add (&vam->json_tree);
3511 vat_json_init_object (node);
3512 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3516 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3517 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3519 vat_main_t *vam = &vat_main;
3520 int retval = clib_net_to_host_u32 (mp->retval);
3522 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3523 print (vam->ofp, "fallback threshold value: %d", mp->value);
3525 vam->retval = retval;
3526 vam->result_ready = 1;
3530 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3531 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3533 vat_main_t *vam = &vat_main;
3534 vat_json_node_t _node, *node = &_node;
3535 int retval = clib_net_to_host_u32 (mp->retval);
3537 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3538 vat_json_init_object (node);
3539 vat_json_object_add_uint (node, "value", mp->value);
3541 vat_json_print (vam->ofp, node);
3542 vat_json_free (node);
3544 vam->retval = retval;
3545 vam->result_ready = 1;
3549 vl_api_show_one_map_register_state_reply_t_handler
3550 (vl_api_show_one_map_register_state_reply_t * mp)
3552 vat_main_t *vam = &vat_main;
3553 int retval = clib_net_to_host_u32 (mp->retval);
3555 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3557 vam->retval = retval;
3558 vam->result_ready = 1;
3562 vl_api_show_one_map_register_state_reply_t_handler_json
3563 (vl_api_show_one_map_register_state_reply_t * mp)
3565 vat_main_t *vam = &vat_main;
3566 vat_json_node_t _node, *node = &_node;
3567 int retval = clib_net_to_host_u32 (mp->retval);
3569 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3571 vat_json_init_object (node);
3572 vat_json_object_add_string_copy (node, "state", s);
3574 vat_json_print (vam->ofp, node);
3575 vat_json_free (node);
3577 vam->retval = retval;
3578 vam->result_ready = 1;
3583 vl_api_show_one_rloc_probe_state_reply_t_handler
3584 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3586 vat_main_t *vam = &vat_main;
3587 int retval = clib_net_to_host_u32 (mp->retval);
3592 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3594 vam->retval = retval;
3595 vam->result_ready = 1;
3599 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3600 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3602 vat_main_t *vam = &vat_main;
3603 vat_json_node_t _node, *node = &_node;
3604 int retval = clib_net_to_host_u32 (mp->retval);
3606 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3607 vat_json_init_object (node);
3608 vat_json_object_add_string_copy (node, "state", s);
3610 vat_json_print (vam->ofp, node);
3611 vat_json_free (node);
3613 vam->retval = retval;
3614 vam->result_ready = 1;
3619 vl_api_show_one_stats_enable_disable_reply_t_handler
3620 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3622 vat_main_t *vam = &vat_main;
3623 int retval = clib_net_to_host_u32 (mp->retval);
3628 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3630 vam->retval = retval;
3631 vam->result_ready = 1;
3635 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3636 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3638 vat_main_t *vam = &vat_main;
3639 vat_json_node_t _node, *node = &_node;
3640 int retval = clib_net_to_host_u32 (mp->retval);
3642 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3643 vat_json_init_object (node);
3644 vat_json_object_add_string_copy (node, "state", s);
3646 vat_json_print (vam->ofp, node);
3647 vat_json_free (node);
3649 vam->retval = retval;
3650 vam->result_ready = 1;
3655 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3657 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3658 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3659 e->vni = clib_net_to_host_u32 (e->vni);
3663 gpe_fwd_entries_get_reply_t_net_to_host
3664 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3668 mp->count = clib_net_to_host_u32 (mp->count);
3669 for (i = 0; i < mp->count; i++)
3671 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3676 format_gpe_encap_mode (u8 * s, va_list * args)
3678 u32 mode = va_arg (*args, u32);
3683 return format (s, "lisp");
3685 return format (s, "vxlan");
3691 vl_api_gpe_get_encap_mode_reply_t_handler
3692 (vl_api_gpe_get_encap_mode_reply_t * mp)
3694 vat_main_t *vam = &vat_main;
3696 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3697 vam->retval = ntohl (mp->retval);
3698 vam->result_ready = 1;
3702 vl_api_gpe_get_encap_mode_reply_t_handler_json
3703 (vl_api_gpe_get_encap_mode_reply_t * mp)
3705 vat_main_t *vam = &vat_main;
3706 vat_json_node_t node;
3708 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3709 vec_add1 (encap_mode, 0);
3711 vat_json_init_object (&node);
3712 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3714 vec_free (encap_mode);
3715 vat_json_print (vam->ofp, &node);
3716 vat_json_free (&node);
3718 vam->retval = ntohl (mp->retval);
3719 vam->result_ready = 1;
3723 vl_api_gpe_fwd_entry_path_details_t_handler
3724 (vl_api_gpe_fwd_entry_path_details_t * mp)
3726 vat_main_t *vam = &vat_main;
3727 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3729 if (mp->lcl_loc.is_ip4)
3730 format_ip_address_fcn = format_ip4_address;
3732 format_ip_address_fcn = format_ip6_address;
3734 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3735 format_ip_address_fcn, &mp->lcl_loc,
3736 format_ip_address_fcn, &mp->rmt_loc);
3740 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3742 struct in6_addr ip6;
3747 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3748 vat_json_object_add_ip4 (n, "address", ip4);
3752 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3753 vat_json_object_add_ip6 (n, "address", ip6);
3755 vat_json_object_add_uint (n, "weight", loc->weight);
3759 vl_api_gpe_fwd_entry_path_details_t_handler_json
3760 (vl_api_gpe_fwd_entry_path_details_t * mp)
3762 vat_main_t *vam = &vat_main;
3763 vat_json_node_t *node = NULL;
3764 vat_json_node_t *loc_node;
3766 if (VAT_JSON_ARRAY != vam->json_tree.type)
3768 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3769 vat_json_init_array (&vam->json_tree);
3771 node = vat_json_array_add (&vam->json_tree);
3772 vat_json_init_object (node);
3774 loc_node = vat_json_object_add (node, "local_locator");
3775 vat_json_init_object (loc_node);
3776 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3778 loc_node = vat_json_object_add (node, "remote_locator");
3779 vat_json_init_object (loc_node);
3780 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3784 vl_api_gpe_fwd_entries_get_reply_t_handler
3785 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3787 vat_main_t *vam = &vat_main;
3789 int retval = clib_net_to_host_u32 (mp->retval);
3790 vl_api_gpe_fwd_entry_t *e;
3795 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3797 for (i = 0; i < mp->count; i++)
3799 e = &mp->entries[i];
3800 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3801 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3802 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3806 vam->retval = retval;
3807 vam->result_ready = 1;
3811 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3812 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3815 vat_main_t *vam = &vat_main;
3816 vat_json_node_t *e = 0, root;
3818 int retval = clib_net_to_host_u32 (mp->retval);
3819 vl_api_gpe_fwd_entry_t *fwd;
3824 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3825 vat_json_init_array (&root);
3827 for (i = 0; i < mp->count; i++)
3829 e = vat_json_array_add (&root);
3830 fwd = &mp->entries[i];
3832 vat_json_init_object (e);
3833 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3834 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3835 vat_json_object_add_int (e, "vni", fwd->vni);
3836 vat_json_object_add_int (e, "action", fwd->action);
3838 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3839 fwd->leid_prefix_len);
3841 vat_json_object_add_string_copy (e, "leid", s);
3844 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3845 fwd->reid_prefix_len);
3847 vat_json_object_add_string_copy (e, "reid", s);
3851 vat_json_print (vam->ofp, &root);
3852 vat_json_free (&root);
3855 vam->retval = retval;
3856 vam->result_ready = 1;
3860 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3861 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3863 vat_main_t *vam = &vat_main;
3865 int retval = clib_net_to_host_u32 (mp->retval);
3866 vl_api_gpe_native_fwd_rpath_t *r;
3871 n = clib_net_to_host_u32 (mp->count);
3873 for (i = 0; i < n; i++)
3875 r = &mp->entries[i];
3876 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3877 clib_net_to_host_u32 (r->fib_index),
3878 clib_net_to_host_u32 (r->nh_sw_if_index),
3879 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3883 vam->retval = retval;
3884 vam->result_ready = 1;
3888 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3889 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3891 vat_main_t *vam = &vat_main;
3892 vat_json_node_t root, *e;
3894 int retval = clib_net_to_host_u32 (mp->retval);
3895 vl_api_gpe_native_fwd_rpath_t *r;
3901 n = clib_net_to_host_u32 (mp->count);
3902 vat_json_init_array (&root);
3904 for (i = 0; i < n; i++)
3906 e = vat_json_array_add (&root);
3907 vat_json_init_object (e);
3908 r = &mp->entries[i];
3910 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3913 vat_json_object_add_string_copy (e, "ip4", s);
3916 vat_json_object_add_uint (e, "fib_index",
3917 clib_net_to_host_u32 (r->fib_index));
3918 vat_json_object_add_uint (e, "nh_sw_if_index",
3919 clib_net_to_host_u32 (r->nh_sw_if_index));
3922 vat_json_print (vam->ofp, &root);
3923 vat_json_free (&root);
3926 vam->retval = retval;
3927 vam->result_ready = 1;
3931 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3932 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3934 vat_main_t *vam = &vat_main;
3936 int retval = clib_net_to_host_u32 (mp->retval);
3941 n = clib_net_to_host_u32 (mp->count);
3943 for (i = 0; i < n; i++)
3944 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3947 vam->retval = retval;
3948 vam->result_ready = 1;
3952 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3953 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3955 vat_main_t *vam = &vat_main;
3956 vat_json_node_t root;
3958 int retval = clib_net_to_host_u32 (mp->retval);
3963 n = clib_net_to_host_u32 (mp->count);
3964 vat_json_init_array (&root);
3966 for (i = 0; i < n; i++)
3967 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3969 vat_json_print (vam->ofp, &root);
3970 vat_json_free (&root);
3973 vam->retval = retval;
3974 vam->result_ready = 1;
3978 vl_api_one_ndp_entries_get_reply_t_handler
3979 (vl_api_one_ndp_entries_get_reply_t * mp)
3981 vat_main_t *vam = &vat_main;
3983 int retval = clib_net_to_host_u32 (mp->retval);
3988 n = clib_net_to_host_u32 (mp->count);
3990 for (i = 0; i < n; i++)
3991 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3992 format_ethernet_address, mp->entries[i].mac);
3995 vam->retval = retval;
3996 vam->result_ready = 1;
4000 vl_api_one_ndp_entries_get_reply_t_handler_json
4001 (vl_api_one_ndp_entries_get_reply_t * mp)
4004 vat_main_t *vam = &vat_main;
4005 vat_json_node_t *e = 0, root;
4007 int retval = clib_net_to_host_u32 (mp->retval);
4008 vl_api_one_ndp_entry_t *arp_entry;
4013 n = clib_net_to_host_u32 (mp->count);
4014 vat_json_init_array (&root);
4016 for (i = 0; i < n; i++)
4018 e = vat_json_array_add (&root);
4019 arp_entry = &mp->entries[i];
4021 vat_json_init_object (e);
4022 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
4025 vat_json_object_add_string_copy (e, "mac", s);
4028 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
4030 vat_json_object_add_string_copy (e, "ip6", s);
4034 vat_json_print (vam->ofp, &root);
4035 vat_json_free (&root);
4038 vam->retval = retval;
4039 vam->result_ready = 1;
4043 vl_api_one_l2_arp_entries_get_reply_t_handler
4044 (vl_api_one_l2_arp_entries_get_reply_t * mp)
4046 vat_main_t *vam = &vat_main;
4048 int retval = clib_net_to_host_u32 (mp->retval);
4053 n = clib_net_to_host_u32 (mp->count);
4055 for (i = 0; i < n; i++)
4056 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
4057 format_ethernet_address, mp->entries[i].mac);
4060 vam->retval = retval;
4061 vam->result_ready = 1;
4065 vl_api_one_l2_arp_entries_get_reply_t_handler_json
4066 (vl_api_one_l2_arp_entries_get_reply_t * mp)
4069 vat_main_t *vam = &vat_main;
4070 vat_json_node_t *e = 0, root;
4072 int retval = clib_net_to_host_u32 (mp->retval);
4073 vl_api_one_l2_arp_entry_t *arp_entry;
4078 n = clib_net_to_host_u32 (mp->count);
4079 vat_json_init_array (&root);
4081 for (i = 0; i < n; i++)
4083 e = vat_json_array_add (&root);
4084 arp_entry = &mp->entries[i];
4086 vat_json_init_object (e);
4087 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
4090 vat_json_object_add_string_copy (e, "mac", s);
4093 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
4095 vat_json_object_add_string_copy (e, "ip4", s);
4099 vat_json_print (vam->ofp, &root);
4100 vat_json_free (&root);
4103 vam->retval = retval;
4104 vam->result_ready = 1;
4108 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
4110 vat_main_t *vam = &vat_main;
4112 int retval = clib_net_to_host_u32 (mp->retval);
4117 n = clib_net_to_host_u32 (mp->count);
4119 for (i = 0; i < n; i++)
4121 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
4125 vam->retval = retval;
4126 vam->result_ready = 1;
4130 vl_api_one_ndp_bd_get_reply_t_handler_json
4131 (vl_api_one_ndp_bd_get_reply_t * mp)
4133 vat_main_t *vam = &vat_main;
4134 vat_json_node_t root;
4136 int retval = clib_net_to_host_u32 (mp->retval);
4141 n = clib_net_to_host_u32 (mp->count);
4142 vat_json_init_array (&root);
4144 for (i = 0; i < n; i++)
4146 vat_json_array_add_uint (&root,
4147 clib_net_to_host_u32 (mp->bridge_domains[i]));
4150 vat_json_print (vam->ofp, &root);
4151 vat_json_free (&root);
4154 vam->retval = retval;
4155 vam->result_ready = 1;
4159 vl_api_one_l2_arp_bd_get_reply_t_handler
4160 (vl_api_one_l2_arp_bd_get_reply_t * mp)
4162 vat_main_t *vam = &vat_main;
4164 int retval = clib_net_to_host_u32 (mp->retval);
4169 n = clib_net_to_host_u32 (mp->count);
4171 for (i = 0; i < n; i++)
4173 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
4177 vam->retval = retval;
4178 vam->result_ready = 1;
4182 vl_api_one_l2_arp_bd_get_reply_t_handler_json
4183 (vl_api_one_l2_arp_bd_get_reply_t * mp)
4185 vat_main_t *vam = &vat_main;
4186 vat_json_node_t root;
4188 int retval = clib_net_to_host_u32 (mp->retval);
4193 n = clib_net_to_host_u32 (mp->count);
4194 vat_json_init_array (&root);
4196 for (i = 0; i < n; i++)
4198 vat_json_array_add_uint (&root,
4199 clib_net_to_host_u32 (mp->bridge_domains[i]));
4202 vat_json_print (vam->ofp, &root);
4203 vat_json_free (&root);
4206 vam->retval = retval;
4207 vam->result_ready = 1;
4211 vl_api_one_adjacencies_get_reply_t_handler
4212 (vl_api_one_adjacencies_get_reply_t * mp)
4214 vat_main_t *vam = &vat_main;
4216 int retval = clib_net_to_host_u32 (mp->retval);
4217 vl_api_one_adjacency_t *a;
4222 n = clib_net_to_host_u32 (mp->count);
4224 for (i = 0; i < n; i++)
4226 a = &mp->adjacencies[i];
4227 print (vam->ofp, "%U %40U",
4228 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
4229 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
4233 vam->retval = retval;
4234 vam->result_ready = 1;
4238 vl_api_one_adjacencies_get_reply_t_handler_json
4239 (vl_api_one_adjacencies_get_reply_t * mp)
4242 vat_main_t *vam = &vat_main;
4243 vat_json_node_t *e = 0, root;
4245 int retval = clib_net_to_host_u32 (mp->retval);
4246 vl_api_one_adjacency_t *a;
4251 n = clib_net_to_host_u32 (mp->count);
4252 vat_json_init_array (&root);
4254 for (i = 0; i < n; i++)
4256 e = vat_json_array_add (&root);
4257 a = &mp->adjacencies[i];
4259 vat_json_init_object (e);
4260 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
4261 a->leid_prefix_len);
4263 vat_json_object_add_string_copy (e, "leid", s);
4266 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
4267 a->reid_prefix_len);
4269 vat_json_object_add_string_copy (e, "reid", s);
4273 vat_json_print (vam->ofp, &root);
4274 vat_json_free (&root);
4277 vam->retval = retval;
4278 vam->result_ready = 1;
4282 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
4284 vat_main_t *vam = &vat_main;
4286 print (vam->ofp, "%=20U",
4287 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4292 vl_api_one_map_server_details_t_handler_json
4293 (vl_api_one_map_server_details_t * mp)
4295 vat_main_t *vam = &vat_main;
4296 vat_json_node_t *node = NULL;
4297 struct in6_addr ip6;
4300 if (VAT_JSON_ARRAY != vam->json_tree.type)
4302 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4303 vat_json_init_array (&vam->json_tree);
4305 node = vat_json_array_add (&vam->json_tree);
4307 vat_json_init_object (node);
4310 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4311 vat_json_object_add_ip6 (node, "map-server", ip6);
4315 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4316 vat_json_object_add_ip4 (node, "map-server", ip4);
4321 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4324 vat_main_t *vam = &vat_main;
4326 print (vam->ofp, "%=20U",
4327 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4332 vl_api_one_map_resolver_details_t_handler_json
4333 (vl_api_one_map_resolver_details_t * mp)
4335 vat_main_t *vam = &vat_main;
4336 vat_json_node_t *node = NULL;
4337 struct in6_addr ip6;
4340 if (VAT_JSON_ARRAY != vam->json_tree.type)
4342 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4343 vat_json_init_array (&vam->json_tree);
4345 node = vat_json_array_add (&vam->json_tree);
4347 vat_json_init_object (node);
4350 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4351 vat_json_object_add_ip6 (node, "map resolver", ip6);
4355 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4356 vat_json_object_add_ip4 (node, "map resolver", ip4);
4361 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4363 vat_main_t *vam = &vat_main;
4364 i32 retval = ntohl (mp->retval);
4368 print (vam->ofp, "feature: %s\ngpe: %s",
4369 mp->feature_status ? "enabled" : "disabled",
4370 mp->gpe_status ? "enabled" : "disabled");
4373 vam->retval = retval;
4374 vam->result_ready = 1;
4378 vl_api_show_one_status_reply_t_handler_json
4379 (vl_api_show_one_status_reply_t * mp)
4381 vat_main_t *vam = &vat_main;
4382 vat_json_node_t node;
4383 u8 *gpe_status = NULL;
4384 u8 *feature_status = NULL;
4386 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4387 feature_status = format (0, "%s",
4388 mp->feature_status ? "enabled" : "disabled");
4389 vec_add1 (gpe_status, 0);
4390 vec_add1 (feature_status, 0);
4392 vat_json_init_object (&node);
4393 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4394 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4396 vec_free (gpe_status);
4397 vec_free (feature_status);
4399 vat_json_print (vam->ofp, &node);
4400 vat_json_free (&node);
4402 vam->retval = ntohl (mp->retval);
4403 vam->result_ready = 1;
4407 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4408 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4410 vat_main_t *vam = &vat_main;
4411 i32 retval = ntohl (mp->retval);
4415 print (vam->ofp, "%=20s", mp->locator_set_name);
4418 vam->retval = retval;
4419 vam->result_ready = 1;
4423 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4424 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4426 vat_main_t *vam = &vat_main;
4427 vat_json_node_t *node = NULL;
4429 if (VAT_JSON_ARRAY != vam->json_tree.type)
4431 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4432 vat_json_init_array (&vam->json_tree);
4434 node = vat_json_array_add (&vam->json_tree);
4436 vat_json_init_object (node);
4437 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4439 vat_json_print (vam->ofp, node);
4440 vat_json_free (node);
4442 vam->retval = ntohl (mp->retval);
4443 vam->result_ready = 1;
4447 format_lisp_map_request_mode (u8 * s, va_list * args)
4449 u32 mode = va_arg (*args, u32);
4454 return format (0, "dst-only");
4456 return format (0, "src-dst");
4462 vl_api_show_one_map_request_mode_reply_t_handler
4463 (vl_api_show_one_map_request_mode_reply_t * mp)
4465 vat_main_t *vam = &vat_main;
4466 i32 retval = ntohl (mp->retval);
4470 u32 mode = mp->mode;
4471 print (vam->ofp, "map_request_mode: %U",
4472 format_lisp_map_request_mode, mode);
4475 vam->retval = retval;
4476 vam->result_ready = 1;
4480 vl_api_show_one_map_request_mode_reply_t_handler_json
4481 (vl_api_show_one_map_request_mode_reply_t * mp)
4483 vat_main_t *vam = &vat_main;
4484 vat_json_node_t node;
4489 s = format (0, "%U", format_lisp_map_request_mode, mode);
4492 vat_json_init_object (&node);
4493 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4494 vat_json_print (vam->ofp, &node);
4495 vat_json_free (&node);
4498 vam->retval = ntohl (mp->retval);
4499 vam->result_ready = 1;
4503 vl_api_one_show_xtr_mode_reply_t_handler
4504 (vl_api_one_show_xtr_mode_reply_t * mp)
4506 vat_main_t *vam = &vat_main;
4507 i32 retval = ntohl (mp->retval);
4511 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4514 vam->retval = retval;
4515 vam->result_ready = 1;
4519 vl_api_one_show_xtr_mode_reply_t_handler_json
4520 (vl_api_one_show_xtr_mode_reply_t * mp)
4522 vat_main_t *vam = &vat_main;
4523 vat_json_node_t node;
4526 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4527 vec_add1 (status, 0);
4529 vat_json_init_object (&node);
4530 vat_json_object_add_string_copy (&node, "status", status);
4534 vat_json_print (vam->ofp, &node);
4535 vat_json_free (&node);
4537 vam->retval = ntohl (mp->retval);
4538 vam->result_ready = 1;
4542 vl_api_one_show_pitr_mode_reply_t_handler
4543 (vl_api_one_show_pitr_mode_reply_t * mp)
4545 vat_main_t *vam = &vat_main;
4546 i32 retval = ntohl (mp->retval);
4550 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4553 vam->retval = retval;
4554 vam->result_ready = 1;
4558 vl_api_one_show_pitr_mode_reply_t_handler_json
4559 (vl_api_one_show_pitr_mode_reply_t * mp)
4561 vat_main_t *vam = &vat_main;
4562 vat_json_node_t node;
4565 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4566 vec_add1 (status, 0);
4568 vat_json_init_object (&node);
4569 vat_json_object_add_string_copy (&node, "status", status);
4573 vat_json_print (vam->ofp, &node);
4574 vat_json_free (&node);
4576 vam->retval = ntohl (mp->retval);
4577 vam->result_ready = 1;
4581 vl_api_one_show_petr_mode_reply_t_handler
4582 (vl_api_one_show_petr_mode_reply_t * mp)
4584 vat_main_t *vam = &vat_main;
4585 i32 retval = ntohl (mp->retval);
4589 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4592 vam->retval = retval;
4593 vam->result_ready = 1;
4597 vl_api_one_show_petr_mode_reply_t_handler_json
4598 (vl_api_one_show_petr_mode_reply_t * mp)
4600 vat_main_t *vam = &vat_main;
4601 vat_json_node_t node;
4604 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4605 vec_add1 (status, 0);
4607 vat_json_init_object (&node);
4608 vat_json_object_add_string_copy (&node, "status", status);
4612 vat_json_print (vam->ofp, &node);
4613 vat_json_free (&node);
4615 vam->retval = ntohl (mp->retval);
4616 vam->result_ready = 1;
4620 vl_api_show_one_use_petr_reply_t_handler
4621 (vl_api_show_one_use_petr_reply_t * mp)
4623 vat_main_t *vam = &vat_main;
4624 i32 retval = ntohl (mp->retval);
4628 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4631 print (vam->ofp, "Proxy-ETR address; %U",
4632 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4637 vam->retval = retval;
4638 vam->result_ready = 1;
4642 vl_api_show_one_use_petr_reply_t_handler_json
4643 (vl_api_show_one_use_petr_reply_t * mp)
4645 vat_main_t *vam = &vat_main;
4646 vat_json_node_t node;
4649 struct in6_addr ip6;
4651 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4652 vec_add1 (status, 0);
4654 vat_json_init_object (&node);
4655 vat_json_object_add_string_copy (&node, "status", status);
4660 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4661 vat_json_object_add_ip6 (&node, "address", ip6);
4665 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4666 vat_json_object_add_ip4 (&node, "address", ip4);
4672 vat_json_print (vam->ofp, &node);
4673 vat_json_free (&node);
4675 vam->retval = ntohl (mp->retval);
4676 vam->result_ready = 1;
4680 vl_api_show_one_nsh_mapping_reply_t_handler
4681 (vl_api_show_one_nsh_mapping_reply_t * mp)
4683 vat_main_t *vam = &vat_main;
4684 i32 retval = ntohl (mp->retval);
4688 print (vam->ofp, "%-20s%-16s",
4689 mp->is_set ? "set" : "not-set",
4690 mp->is_set ? (char *) mp->locator_set_name : "");
4693 vam->retval = retval;
4694 vam->result_ready = 1;
4698 vl_api_show_one_nsh_mapping_reply_t_handler_json
4699 (vl_api_show_one_nsh_mapping_reply_t * mp)
4701 vat_main_t *vam = &vat_main;
4702 vat_json_node_t node;
4705 status = format (0, "%s", mp->is_set ? "yes" : "no");
4706 vec_add1 (status, 0);
4708 vat_json_init_object (&node);
4709 vat_json_object_add_string_copy (&node, "is_set", status);
4712 vat_json_object_add_string_copy (&node, "locator_set",
4713 mp->locator_set_name);
4718 vat_json_print (vam->ofp, &node);
4719 vat_json_free (&node);
4721 vam->retval = ntohl (mp->retval);
4722 vam->result_ready = 1;
4726 vl_api_show_one_map_register_ttl_reply_t_handler
4727 (vl_api_show_one_map_register_ttl_reply_t * mp)
4729 vat_main_t *vam = &vat_main;
4730 i32 retval = ntohl (mp->retval);
4732 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4736 print (vam->ofp, "ttl: %u", mp->ttl);
4739 vam->retval = retval;
4740 vam->result_ready = 1;
4744 vl_api_show_one_map_register_ttl_reply_t_handler_json
4745 (vl_api_show_one_map_register_ttl_reply_t * mp)
4747 vat_main_t *vam = &vat_main;
4748 vat_json_node_t node;
4750 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4751 vat_json_init_object (&node);
4752 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4754 vat_json_print (vam->ofp, &node);
4755 vat_json_free (&node);
4757 vam->retval = ntohl (mp->retval);
4758 vam->result_ready = 1;
4762 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4764 vat_main_t *vam = &vat_main;
4765 i32 retval = ntohl (mp->retval);
4769 print (vam->ofp, "%-20s%-16s",
4770 mp->status ? "enabled" : "disabled",
4771 mp->status ? (char *) mp->locator_set_name : "");
4774 vam->retval = retval;
4775 vam->result_ready = 1;
4779 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4781 vat_main_t *vam = &vat_main;
4782 vat_json_node_t node;
4785 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4786 vec_add1 (status, 0);
4788 vat_json_init_object (&node);
4789 vat_json_object_add_string_copy (&node, "status", status);
4792 vat_json_object_add_string_copy (&node, "locator_set",
4793 mp->locator_set_name);
4798 vat_json_print (vam->ofp, &node);
4799 vat_json_free (&node);
4801 vam->retval = ntohl (mp->retval);
4802 vam->result_ready = 1;
4806 format_policer_type (u8 * s, va_list * va)
4808 u32 i = va_arg (*va, u32);
4810 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4811 s = format (s, "1r2c");
4812 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4813 s = format (s, "1r3c");
4814 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4815 s = format (s, "2r3c-2698");
4816 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4817 s = format (s, "2r3c-4115");
4818 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4819 s = format (s, "2r3c-mef5cf1");
4821 s = format (s, "ILLEGAL");
4826 format_policer_rate_type (u8 * s, va_list * va)
4828 u32 i = va_arg (*va, u32);
4830 if (i == SSE2_QOS_RATE_KBPS)
4831 s = format (s, "kbps");
4832 else if (i == SSE2_QOS_RATE_PPS)
4833 s = format (s, "pps");
4835 s = format (s, "ILLEGAL");
4840 format_policer_round_type (u8 * s, va_list * va)
4842 u32 i = va_arg (*va, u32);
4844 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4845 s = format (s, "closest");
4846 else if (i == SSE2_QOS_ROUND_TO_UP)
4847 s = format (s, "up");
4848 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4849 s = format (s, "down");
4851 s = format (s, "ILLEGAL");
4856 format_policer_action_type (u8 * s, va_list * va)
4858 u32 i = va_arg (*va, u32);
4860 if (i == SSE2_QOS_ACTION_DROP)
4861 s = format (s, "drop");
4862 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4863 s = format (s, "transmit");
4864 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4865 s = format (s, "mark-and-transmit");
4867 s = format (s, "ILLEGAL");
4872 format_dscp (u8 * s, va_list * va)
4874 u32 i = va_arg (*va, u32);
4879 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4883 return format (s, "ILLEGAL");
4885 s = format (s, "%s", t);
4890 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4892 vat_main_t *vam = &vat_main;
4893 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4895 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4896 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4898 conform_dscp_str = format (0, "");
4900 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4901 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4903 exceed_dscp_str = format (0, "");
4905 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4906 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4908 violate_dscp_str = format (0, "");
4910 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4911 "rate type %U, round type %U, %s rate, %s color-aware, "
4912 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4913 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4914 "conform action %U%s, exceed action %U%s, violate action %U%s",
4916 format_policer_type, mp->type,
4919 clib_net_to_host_u64 (mp->cb),
4920 clib_net_to_host_u64 (mp->eb),
4921 format_policer_rate_type, mp->rate_type,
4922 format_policer_round_type, mp->round_type,
4923 mp->single_rate ? "single" : "dual",
4924 mp->color_aware ? "is" : "not",
4925 ntohl (mp->cir_tokens_per_period),
4926 ntohl (mp->pir_tokens_per_period),
4928 ntohl (mp->current_limit),
4929 ntohl (mp->current_bucket),
4930 ntohl (mp->extended_limit),
4931 ntohl (mp->extended_bucket),
4932 clib_net_to_host_u64 (mp->last_update_time),
4933 format_policer_action_type, mp->conform_action_type,
4935 format_policer_action_type, mp->exceed_action_type,
4937 format_policer_action_type, mp->violate_action_type,
4940 vec_free (conform_dscp_str);
4941 vec_free (exceed_dscp_str);
4942 vec_free (violate_dscp_str);
4945 static void vl_api_policer_details_t_handler_json
4946 (vl_api_policer_details_t * mp)
4948 vat_main_t *vam = &vat_main;
4949 vat_json_node_t *node;
4950 u8 *rate_type_str, *round_type_str, *type_str;
4951 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4953 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4955 format (0, "%U", format_policer_round_type, mp->round_type);
4956 type_str = format (0, "%U", format_policer_type, mp->type);
4957 conform_action_str = format (0, "%U", format_policer_action_type,
4958 mp->conform_action_type);
4959 exceed_action_str = format (0, "%U", format_policer_action_type,
4960 mp->exceed_action_type);
4961 violate_action_str = format (0, "%U", format_policer_action_type,
4962 mp->violate_action_type);
4964 if (VAT_JSON_ARRAY != vam->json_tree.type)
4966 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4967 vat_json_init_array (&vam->json_tree);
4969 node = vat_json_array_add (&vam->json_tree);
4971 vat_json_init_object (node);
4972 vat_json_object_add_string_copy (node, "name", mp->name);
4973 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4974 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4975 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4976 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4977 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4978 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4979 vat_json_object_add_string_copy (node, "type", type_str);
4980 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4981 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4982 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4983 vat_json_object_add_uint (node, "cir_tokens_per_period",
4984 ntohl (mp->cir_tokens_per_period));
4985 vat_json_object_add_uint (node, "eir_tokens_per_period",
4986 ntohl (mp->pir_tokens_per_period));
4987 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4988 vat_json_object_add_uint (node, "current_bucket",
4989 ntohl (mp->current_bucket));
4990 vat_json_object_add_uint (node, "extended_limit",
4991 ntohl (mp->extended_limit));
4992 vat_json_object_add_uint (node, "extended_bucket",
4993 ntohl (mp->extended_bucket));
4994 vat_json_object_add_uint (node, "last_update_time",
4995 ntohl (mp->last_update_time));
4996 vat_json_object_add_string_copy (node, "conform_action",
4997 conform_action_str);
4998 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
5000 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
5001 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
5002 vec_free (dscp_str);
5004 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
5005 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
5007 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
5008 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
5009 vec_free (dscp_str);
5011 vat_json_object_add_string_copy (node, "violate_action",
5012 violate_action_str);
5013 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
5015 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
5016 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
5017 vec_free (dscp_str);
5020 vec_free (rate_type_str);
5021 vec_free (round_type_str);
5022 vec_free (type_str);
5023 vec_free (conform_action_str);
5024 vec_free (exceed_action_str);
5025 vec_free (violate_action_str);
5029 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
5032 vat_main_t *vam = &vat_main;
5033 int i, count = ntohl (mp->count);
5036 print (vam->ofp, "classify table ids (%d) : ", count);
5037 for (i = 0; i < count; i++)
5039 print (vam->ofp, "%d", ntohl (mp->ids[i]));
5040 print (vam->ofp, (i < count - 1) ? "," : "");
5042 vam->retval = ntohl (mp->retval);
5043 vam->result_ready = 1;
5047 vl_api_classify_table_ids_reply_t_handler_json
5048 (vl_api_classify_table_ids_reply_t * mp)
5050 vat_main_t *vam = &vat_main;
5051 int i, count = ntohl (mp->count);
5055 vat_json_node_t node;
5057 vat_json_init_object (&node);
5058 for (i = 0; i < count; i++)
5060 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
5062 vat_json_print (vam->ofp, &node);
5063 vat_json_free (&node);
5065 vam->retval = ntohl (mp->retval);
5066 vam->result_ready = 1;
5070 vl_api_classify_table_by_interface_reply_t_handler
5071 (vl_api_classify_table_by_interface_reply_t * mp)
5073 vat_main_t *vam = &vat_main;
5076 table_id = ntohl (mp->l2_table_id);
5078 print (vam->ofp, "l2 table id : %d", table_id);
5080 print (vam->ofp, "l2 table id : No input ACL tables configured");
5081 table_id = ntohl (mp->ip4_table_id);
5083 print (vam->ofp, "ip4 table id : %d", table_id);
5085 print (vam->ofp, "ip4 table id : No input ACL tables configured");
5086 table_id = ntohl (mp->ip6_table_id);
5088 print (vam->ofp, "ip6 table id : %d", table_id);
5090 print (vam->ofp, "ip6 table id : No input ACL tables configured");
5091 vam->retval = ntohl (mp->retval);
5092 vam->result_ready = 1;
5096 vl_api_classify_table_by_interface_reply_t_handler_json
5097 (vl_api_classify_table_by_interface_reply_t * mp)
5099 vat_main_t *vam = &vat_main;
5100 vat_json_node_t node;
5102 vat_json_init_object (&node);
5104 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
5105 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
5106 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
5108 vat_json_print (vam->ofp, &node);
5109 vat_json_free (&node);
5111 vam->retval = ntohl (mp->retval);
5112 vam->result_ready = 1;
5115 static void vl_api_policer_add_del_reply_t_handler
5116 (vl_api_policer_add_del_reply_t * mp)
5118 vat_main_t *vam = &vat_main;
5119 i32 retval = ntohl (mp->retval);
5120 if (vam->async_mode)
5122 vam->async_errors += (retval < 0);
5126 vam->retval = retval;
5127 vam->result_ready = 1;
5128 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
5130 * Note: this is just barely thread-safe, depends on
5131 * the main thread spinning waiting for an answer...
5133 errmsg ("policer index %d", ntohl (mp->policer_index));
5137 static void vl_api_policer_add_del_reply_t_handler_json
5138 (vl_api_policer_add_del_reply_t * mp)
5140 vat_main_t *vam = &vat_main;
5141 vat_json_node_t node;
5143 vat_json_init_object (&node);
5144 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5145 vat_json_object_add_uint (&node, "policer_index",
5146 ntohl (mp->policer_index));
5148 vat_json_print (vam->ofp, &node);
5149 vat_json_free (&node);
5151 vam->retval = ntohl (mp->retval);
5152 vam->result_ready = 1;
5155 /* Format hex dump. */
5157 format_hex_bytes (u8 * s, va_list * va)
5159 u8 *bytes = va_arg (*va, u8 *);
5160 int n_bytes = va_arg (*va, int);
5163 /* Print short or long form depending on byte count. */
5164 uword short_form = n_bytes <= 32;
5165 u32 indent = format_get_indent (s);
5170 for (i = 0; i < n_bytes; i++)
5172 if (!short_form && (i % 32) == 0)
5173 s = format (s, "%08x: ", i);
5174 s = format (s, "%02x", bytes[i]);
5175 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
5176 s = format (s, "\n%U", format_white_space, indent);
5183 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
5186 vat_main_t *vam = &vat_main;
5187 i32 retval = ntohl (mp->retval);
5190 print (vam->ofp, "classify table info :");
5191 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
5192 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
5193 ntohl (mp->miss_next_index));
5194 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
5195 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
5196 ntohl (mp->match_n_vectors));
5197 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
5198 ntohl (mp->mask_length));
5200 vam->retval = retval;
5201 vam->result_ready = 1;
5205 vl_api_classify_table_info_reply_t_handler_json
5206 (vl_api_classify_table_info_reply_t * mp)
5208 vat_main_t *vam = &vat_main;
5209 vat_json_node_t node;
5211 i32 retval = ntohl (mp->retval);
5214 vat_json_init_object (&node);
5216 vat_json_object_add_int (&node, "sessions",
5217 ntohl (mp->active_sessions));
5218 vat_json_object_add_int (&node, "nexttbl",
5219 ntohl (mp->next_table_index));
5220 vat_json_object_add_int (&node, "nextnode",
5221 ntohl (mp->miss_next_index));
5222 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
5223 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
5224 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
5225 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
5226 ntohl (mp->mask_length), 0);
5227 vat_json_object_add_string_copy (&node, "mask", s);
5229 vat_json_print (vam->ofp, &node);
5230 vat_json_free (&node);
5232 vam->retval = ntohl (mp->retval);
5233 vam->result_ready = 1;
5237 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
5240 vat_main_t *vam = &vat_main;
5242 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
5243 ntohl (mp->hit_next_index), ntohl (mp->advance),
5244 ntohl (mp->opaque_index));
5245 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
5246 ntohl (mp->match_length));
5250 vl_api_classify_session_details_t_handler_json
5251 (vl_api_classify_session_details_t * mp)
5253 vat_main_t *vam = &vat_main;
5254 vat_json_node_t *node = NULL;
5256 if (VAT_JSON_ARRAY != vam->json_tree.type)
5258 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5259 vat_json_init_array (&vam->json_tree);
5261 node = vat_json_array_add (&vam->json_tree);
5263 vat_json_init_object (node);
5264 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
5265 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
5266 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
5268 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
5270 vat_json_object_add_string_copy (node, "match", s);
5273 static void vl_api_pg_create_interface_reply_t_handler
5274 (vl_api_pg_create_interface_reply_t * mp)
5276 vat_main_t *vam = &vat_main;
5278 vam->retval = ntohl (mp->retval);
5279 vam->result_ready = 1;
5282 static void vl_api_pg_create_interface_reply_t_handler_json
5283 (vl_api_pg_create_interface_reply_t * mp)
5285 vat_main_t *vam = &vat_main;
5286 vat_json_node_t node;
5288 i32 retval = ntohl (mp->retval);
5291 vat_json_init_object (&node);
5293 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
5295 vat_json_print (vam->ofp, &node);
5296 vat_json_free (&node);
5298 vam->retval = ntohl (mp->retval);
5299 vam->result_ready = 1;
5302 static void vl_api_policer_classify_details_t_handler
5303 (vl_api_policer_classify_details_t * mp)
5305 vat_main_t *vam = &vat_main;
5307 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5308 ntohl (mp->table_index));
5311 static void vl_api_policer_classify_details_t_handler_json
5312 (vl_api_policer_classify_details_t * mp)
5314 vat_main_t *vam = &vat_main;
5315 vat_json_node_t *node;
5317 if (VAT_JSON_ARRAY != vam->json_tree.type)
5319 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5320 vat_json_init_array (&vam->json_tree);
5322 node = vat_json_array_add (&vam->json_tree);
5324 vat_json_init_object (node);
5325 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5326 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5329 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
5330 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5332 vat_main_t *vam = &vat_main;
5333 i32 retval = ntohl (mp->retval);
5334 if (vam->async_mode)
5336 vam->async_errors += (retval < 0);
5340 vam->retval = retval;
5341 vam->sw_if_index = ntohl (mp->sw_if_index);
5342 vam->result_ready = 1;
5344 vam->regenerate_interface_table = 1;
5347 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
5348 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5350 vat_main_t *vam = &vat_main;
5351 vat_json_node_t node;
5353 vat_json_init_object (&node);
5354 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5355 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
5357 vat_json_print (vam->ofp, &node);
5358 vat_json_free (&node);
5360 vam->retval = ntohl (mp->retval);
5361 vam->result_ready = 1;
5364 static void vl_api_flow_classify_details_t_handler
5365 (vl_api_flow_classify_details_t * mp)
5367 vat_main_t *vam = &vat_main;
5369 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5370 ntohl (mp->table_index));
5373 static void vl_api_flow_classify_details_t_handler_json
5374 (vl_api_flow_classify_details_t * mp)
5376 vat_main_t *vam = &vat_main;
5377 vat_json_node_t *node;
5379 if (VAT_JSON_ARRAY != vam->json_tree.type)
5381 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5382 vat_json_init_array (&vam->json_tree);
5384 node = vat_json_array_add (&vam->json_tree);
5386 vat_json_init_object (node);
5387 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5388 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5391 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
5392 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
5393 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
5394 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
5395 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
5396 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
5397 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
5398 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
5399 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
5400 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
5401 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
5402 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
5403 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5404 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5405 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5406 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5407 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5408 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5409 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5410 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5411 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5412 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5415 * Generate boilerplate reply handlers, which
5416 * dig the return value out of the xxx_reply_t API message,
5417 * stick it into vam->retval, and set vam->result_ready
5419 * Could also do this by pointing N message decode slots at
5420 * a single function, but that could break in subtle ways.
5423 #define foreach_standard_reply_retval_handler \
5424 _(sw_interface_set_flags_reply) \
5425 _(sw_interface_add_del_address_reply) \
5426 _(sw_interface_set_rx_mode_reply) \
5427 _(sw_interface_set_rx_placement_reply) \
5428 _(sw_interface_set_table_reply) \
5429 _(sw_interface_set_mpls_enable_reply) \
5430 _(sw_interface_set_vpath_reply) \
5431 _(sw_interface_set_vxlan_bypass_reply) \
5432 _(sw_interface_set_geneve_bypass_reply) \
5433 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5434 _(sw_interface_set_l2_bridge_reply) \
5435 _(bridge_domain_add_del_reply) \
5436 _(sw_interface_set_l2_xconnect_reply) \
5437 _(l2fib_add_del_reply) \
5438 _(l2fib_flush_int_reply) \
5439 _(l2fib_flush_bd_reply) \
5440 _(ip_add_del_route_reply) \
5441 _(ip_table_add_del_reply) \
5442 _(ip_mroute_add_del_reply) \
5443 _(mpls_route_add_del_reply) \
5444 _(mpls_table_add_del_reply) \
5445 _(mpls_ip_bind_unbind_reply) \
5446 _(bier_route_add_del_reply) \
5447 _(bier_table_add_del_reply) \
5448 _(proxy_arp_add_del_reply) \
5449 _(proxy_arp_intfc_enable_disable_reply) \
5450 _(sw_interface_set_unnumbered_reply) \
5451 _(ip_neighbor_add_del_reply) \
5452 _(oam_add_del_reply) \
5453 _(reset_fib_reply) \
5454 _(dhcp_proxy_config_reply) \
5455 _(dhcp_proxy_set_vss_reply) \
5456 _(dhcp_client_config_reply) \
5457 _(set_ip_flow_hash_reply) \
5458 _(sw_interface_ip6_enable_disable_reply) \
5459 _(sw_interface_ip6_set_link_local_address_reply) \
5460 _(ip6nd_proxy_add_del_reply) \
5461 _(sw_interface_ip6nd_ra_prefix_reply) \
5462 _(sw_interface_ip6nd_ra_config_reply) \
5463 _(set_arp_neighbor_limit_reply) \
5464 _(l2_patch_add_del_reply) \
5465 _(sr_mpls_policy_add_reply) \
5466 _(sr_mpls_policy_mod_reply) \
5467 _(sr_mpls_policy_del_reply) \
5468 _(sr_policy_add_reply) \
5469 _(sr_policy_mod_reply) \
5470 _(sr_policy_del_reply) \
5471 _(sr_localsid_add_del_reply) \
5472 _(sr_steering_add_del_reply) \
5473 _(classify_add_del_session_reply) \
5474 _(classify_set_interface_ip_table_reply) \
5475 _(classify_set_interface_l2_tables_reply) \
5476 _(l2tpv3_set_tunnel_cookies_reply) \
5477 _(l2tpv3_interface_enable_disable_reply) \
5478 _(l2tpv3_set_lookup_key_reply) \
5479 _(l2_fib_clear_table_reply) \
5480 _(l2_interface_efp_filter_reply) \
5481 _(l2_interface_vlan_tag_rewrite_reply) \
5482 _(modify_vhost_user_if_reply) \
5483 _(delete_vhost_user_if_reply) \
5484 _(ip_probe_neighbor_reply) \
5485 _(ip_scan_neighbor_enable_disable_reply) \
5486 _(want_ip4_arp_events_reply) \
5487 _(want_ip6_nd_events_reply) \
5488 _(want_l2_macs_events_reply) \
5489 _(input_acl_set_interface_reply) \
5490 _(ipsec_spd_add_del_reply) \
5491 _(ipsec_interface_add_del_spd_reply) \
5492 _(ipsec_spd_add_del_entry_reply) \
5493 _(ipsec_sad_add_del_entry_reply) \
5494 _(ipsec_sa_set_key_reply) \
5495 _(ipsec_tunnel_if_add_del_reply) \
5496 _(ipsec_tunnel_if_set_key_reply) \
5497 _(ipsec_tunnel_if_set_sa_reply) \
5498 _(ikev2_profile_add_del_reply) \
5499 _(ikev2_profile_set_auth_reply) \
5500 _(ikev2_profile_set_id_reply) \
5501 _(ikev2_profile_set_ts_reply) \
5502 _(ikev2_set_local_key_reply) \
5503 _(ikev2_set_responder_reply) \
5504 _(ikev2_set_ike_transforms_reply) \
5505 _(ikev2_set_esp_transforms_reply) \
5506 _(ikev2_set_sa_lifetime_reply) \
5507 _(ikev2_initiate_sa_init_reply) \
5508 _(ikev2_initiate_del_ike_sa_reply) \
5509 _(ikev2_initiate_del_child_sa_reply) \
5510 _(ikev2_initiate_rekey_child_sa_reply) \
5511 _(delete_loopback_reply) \
5512 _(bd_ip_mac_add_del_reply) \
5513 _(want_interface_events_reply) \
5514 _(want_stats_reply) \
5515 _(cop_interface_enable_disable_reply) \
5516 _(cop_whitelist_enable_disable_reply) \
5517 _(sw_interface_clear_stats_reply) \
5518 _(ioam_enable_reply) \
5519 _(ioam_disable_reply) \
5520 _(one_add_del_locator_reply) \
5521 _(one_add_del_local_eid_reply) \
5522 _(one_add_del_remote_mapping_reply) \
5523 _(one_add_del_adjacency_reply) \
5524 _(one_add_del_map_resolver_reply) \
5525 _(one_add_del_map_server_reply) \
5526 _(one_enable_disable_reply) \
5527 _(one_rloc_probe_enable_disable_reply) \
5528 _(one_map_register_enable_disable_reply) \
5529 _(one_map_register_set_ttl_reply) \
5530 _(one_set_transport_protocol_reply) \
5531 _(one_map_register_fallback_threshold_reply) \
5532 _(one_pitr_set_locator_set_reply) \
5533 _(one_map_request_mode_reply) \
5534 _(one_add_del_map_request_itr_rlocs_reply) \
5535 _(one_eid_table_add_del_map_reply) \
5536 _(one_use_petr_reply) \
5537 _(one_stats_enable_disable_reply) \
5538 _(one_add_del_l2_arp_entry_reply) \
5539 _(one_add_del_ndp_entry_reply) \
5540 _(one_stats_flush_reply) \
5541 _(one_enable_disable_xtr_mode_reply) \
5542 _(one_enable_disable_pitr_mode_reply) \
5543 _(one_enable_disable_petr_mode_reply) \
5544 _(gpe_enable_disable_reply) \
5545 _(gpe_set_encap_mode_reply) \
5546 _(gpe_add_del_iface_reply) \
5547 _(gpe_add_del_native_fwd_rpath_reply) \
5548 _(af_packet_delete_reply) \
5549 _(policer_classify_set_interface_reply) \
5550 _(netmap_create_reply) \
5551 _(netmap_delete_reply) \
5552 _(set_ipfix_exporter_reply) \
5553 _(set_ipfix_classify_stream_reply) \
5554 _(ipfix_classify_table_add_del_reply) \
5555 _(flow_classify_set_interface_reply) \
5556 _(sw_interface_span_enable_disable_reply) \
5557 _(pg_capture_reply) \
5558 _(pg_enable_disable_reply) \
5559 _(ip_source_and_port_range_check_add_del_reply) \
5560 _(ip_source_and_port_range_check_interface_add_del_reply)\
5561 _(delete_subif_reply) \
5562 _(l2_interface_pbb_tag_rewrite_reply) \
5564 _(feature_enable_disable_reply) \
5565 _(sw_interface_tag_add_del_reply) \
5566 _(hw_interface_set_mtu_reply) \
5567 _(p2p_ethernet_add_reply) \
5568 _(p2p_ethernet_del_reply) \
5569 _(lldp_config_reply) \
5570 _(sw_interface_set_lldp_reply) \
5571 _(tcp_configure_src_addresses_reply) \
5572 _(dns_enable_disable_reply) \
5573 _(dns_name_server_add_del_reply) \
5574 _(session_rule_add_del_reply) \
5575 _(ip_container_proxy_add_del_reply) \
5576 _(output_acl_set_interface_reply) \
5577 _(qos_record_enable_disable_reply)
5580 static void vl_api_##n##_t_handler \
5581 (vl_api_##n##_t * mp) \
5583 vat_main_t * vam = &vat_main; \
5584 i32 retval = ntohl(mp->retval); \
5585 if (vam->async_mode) { \
5586 vam->async_errors += (retval < 0); \
5588 vam->retval = retval; \
5589 vam->result_ready = 1; \
5592 foreach_standard_reply_retval_handler;
5596 static void vl_api_##n##_t_handler_json \
5597 (vl_api_##n##_t * mp) \
5599 vat_main_t * vam = &vat_main; \
5600 vat_json_node_t node; \
5601 vat_json_init_object(&node); \
5602 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5603 vat_json_print(vam->ofp, &node); \
5604 vam->retval = ntohl(mp->retval); \
5605 vam->result_ready = 1; \
5607 foreach_standard_reply_retval_handler;
5611 * Table of message reply handlers, must include boilerplate handlers
5615 #define foreach_vpe_api_reply_msg \
5616 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5617 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5618 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5619 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5620 _(CONTROL_PING_REPLY, control_ping_reply) \
5621 _(CLI_REPLY, cli_reply) \
5622 _(CLI_INBAND_REPLY, cli_inband_reply) \
5623 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5624 sw_interface_add_del_address_reply) \
5625 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5626 _(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
5627 _(SW_INTERFACE_RX_PLACEMENT_DETAILS, sw_interface_rx_placement_details) \
5628 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5629 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5630 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5631 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5632 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5633 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5634 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5635 sw_interface_set_l2_xconnect_reply) \
5636 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5637 sw_interface_set_l2_bridge_reply) \
5638 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5639 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5640 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5641 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5642 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5643 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5644 _(L2_FLAGS_REPLY, l2_flags_reply) \
5645 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5646 _(TAP_CONNECT_REPLY, tap_connect_reply) \
5647 _(TAP_MODIFY_REPLY, tap_modify_reply) \
5648 _(TAP_DELETE_REPLY, tap_delete_reply) \
5649 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
5650 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5651 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5652 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5653 _(BOND_CREATE_REPLY, bond_create_reply) \
5654 _(BOND_DELETE_REPLY, bond_delete_reply) \
5655 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5656 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5657 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5658 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5659 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5660 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5661 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5662 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5663 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5664 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5665 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5666 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5667 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5668 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5669 proxy_arp_intfc_enable_disable_reply) \
5670 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5671 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5672 sw_interface_set_unnumbered_reply) \
5673 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5674 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5675 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5676 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5677 _(RESET_FIB_REPLY, reset_fib_reply) \
5678 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5679 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5680 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5681 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5682 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5683 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5684 sw_interface_ip6_enable_disable_reply) \
5685 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
5686 sw_interface_ip6_set_link_local_address_reply) \
5687 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5688 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5689 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5690 sw_interface_ip6nd_ra_prefix_reply) \
5691 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5692 sw_interface_ip6nd_ra_config_reply) \
5693 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5694 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5695 _(SR_MPLS_POLICY_ADD_REPLY, sr_mpls_policy_add_reply) \
5696 _(SR_MPLS_POLICY_MOD_REPLY, sr_mpls_policy_mod_reply) \
5697 _(SR_MPLS_POLICY_DEL_REPLY, sr_mpls_policy_del_reply) \
5698 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5699 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5700 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5701 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5702 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5703 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5704 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5705 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5706 classify_set_interface_ip_table_reply) \
5707 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5708 classify_set_interface_l2_tables_reply) \
5709 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5710 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5711 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5712 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5713 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5714 l2tpv3_interface_enable_disable_reply) \
5715 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5716 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5717 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5718 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5719 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5720 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5721 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5722 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5723 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5724 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5725 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5726 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5727 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5728 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5729 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5730 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5731 _(SHOW_VERSION_REPLY, show_version_reply) \
5732 _(SHOW_THREADS_REPLY, show_threads_reply) \
5733 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5734 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5735 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5736 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5737 _(IP_PROBE_NEIGHBOR_REPLY, ip_probe_neighbor_reply) \
5738 _(IP_SCAN_NEIGHBOR_ENABLE_DISABLE_REPLY, ip_scan_neighbor_enable_disable_reply) \
5739 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5740 _(IP4_ARP_EVENT, ip4_arp_event) \
5741 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5742 _(IP6_ND_EVENT, ip6_nd_event) \
5743 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5744 _(L2_MACS_EVENT, l2_macs_event) \
5745 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5746 _(IP_ADDRESS_DETAILS, ip_address_details) \
5747 _(IP_DETAILS, ip_details) \
5748 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5749 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5750 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
5751 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
5752 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5753 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5754 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5755 _(IPSEC_TUNNEL_IF_SET_KEY_REPLY, ipsec_tunnel_if_set_key_reply) \
5756 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5757 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
5758 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
5759 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
5760 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
5761 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
5762 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
5763 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
5764 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
5765 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
5766 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
5767 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
5768 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
5769 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
5770 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5771 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5772 _(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
5773 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5774 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5775 _(WANT_STATS_REPLY, want_stats_reply) \
5776 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5777 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5778 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5779 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5780 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5781 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5782 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5783 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5784 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5785 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5786 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5787 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5788 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5789 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5790 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5791 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5792 one_map_register_enable_disable_reply) \
5793 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5794 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5795 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5796 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5797 one_map_register_fallback_threshold_reply) \
5798 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5799 one_rloc_probe_enable_disable_reply) \
5800 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5801 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5802 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5803 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5804 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5805 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5806 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5807 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5808 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5809 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5810 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5811 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5812 _(ONE_STATS_DETAILS, one_stats_details) \
5813 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5814 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5815 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5816 show_one_stats_enable_disable_reply) \
5817 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5818 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5819 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5820 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5821 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5822 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5823 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5824 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5825 one_enable_disable_pitr_mode_reply) \
5826 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5827 one_enable_disable_petr_mode_reply) \
5828 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5829 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5830 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5831 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5832 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5833 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5834 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5835 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5836 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5837 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5838 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5839 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5840 gpe_add_del_native_fwd_rpath_reply) \
5841 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5842 gpe_fwd_entry_path_details) \
5843 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5844 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5845 one_add_del_map_request_itr_rlocs_reply) \
5846 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5847 one_get_map_request_itr_rlocs_reply) \
5848 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5849 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5850 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5851 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5852 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5853 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5854 show_one_map_register_state_reply) \
5855 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5856 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5857 show_one_map_register_fallback_threshold_reply) \
5858 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5859 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5860 _(AF_PACKET_DETAILS, af_packet_details) \
5861 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5862 _(POLICER_DETAILS, policer_details) \
5863 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5864 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5865 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5866 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5867 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5868 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5869 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5870 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5871 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5872 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5873 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5874 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5875 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5876 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5877 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5878 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5879 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5880 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5881 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5882 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5883 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5884 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5885 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5886 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5887 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5888 ip_source_and_port_range_check_add_del_reply) \
5889 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5890 ip_source_and_port_range_check_interface_add_del_reply) \
5891 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5892 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5893 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5894 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5895 _(PUNT_REPLY, punt_reply) \
5896 _(IP_FIB_DETAILS, ip_fib_details) \
5897 _(IP6_FIB_DETAILS, ip6_fib_details) \
5898 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5899 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5900 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5901 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5902 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5903 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5904 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5905 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5906 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5907 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5908 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5909 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5910 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5911 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5912 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
5913 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \
5914 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5915 _(SESSION_RULES_DETAILS, session_rules_details) \
5916 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5917 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5918 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply)
5920 #define foreach_standalone_reply_msg \
5921 _(SW_INTERFACE_EVENT, sw_interface_event) \
5922 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
5923 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
5924 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
5925 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
5926 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
5927 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters)
5935 #define STR_VTR_OP_CASE(op) \
5936 case L2_VTR_ ## op: \
5940 str_vtr_op (u32 vtr_op)
5944 STR_VTR_OP_CASE (DISABLED);
5945 STR_VTR_OP_CASE (PUSH_1);
5946 STR_VTR_OP_CASE (PUSH_2);
5947 STR_VTR_OP_CASE (POP_1);
5948 STR_VTR_OP_CASE (POP_2);
5949 STR_VTR_OP_CASE (TRANSLATE_1_1);
5950 STR_VTR_OP_CASE (TRANSLATE_1_2);
5951 STR_VTR_OP_CASE (TRANSLATE_2_1);
5952 STR_VTR_OP_CASE (TRANSLATE_2_2);
5959 dump_sub_interface_table (vat_main_t * vam)
5961 const sw_interface_subif_t *sub = NULL;
5963 if (vam->json_output)
5966 ("JSON output supported only for VPE API calls and dump_stats_table");
5971 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5972 "Interface", "sw_if_index",
5973 "sub id", "dot1ad", "tags", "outer id",
5974 "inner id", "exact", "default", "outer any", "inner any");
5976 vec_foreach (sub, vam->sw_if_subif_table)
5979 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5980 sub->interface_name,
5982 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5983 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5984 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5985 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5986 if (sub->vtr_op != L2_VTR_DISABLED)
5989 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5990 "tag1: %d tag2: %d ]",
5991 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5992 sub->vtr_tag1, sub->vtr_tag2);
6000 name_sort_cmp (void *a1, void *a2)
6002 name_sort_t *n1 = a1;
6003 name_sort_t *n2 = a2;
6005 return strcmp ((char *) n1->name, (char *) n2->name);
6009 dump_interface_table (vat_main_t * vam)
6012 name_sort_t *nses = 0, *ns;
6014 if (vam->json_output)
6017 ("JSON output supported only for VPE API calls and dump_stats_table");
6022 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6024 vec_add2 (nses, ns, 1);
6025 ns->name = (u8 *)(p->key);
6026 ns->value = (u32) p->value[0];
6030 vec_sort_with_function (nses, name_sort_cmp);
6032 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
6033 vec_foreach (ns, nses)
6035 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
6042 dump_ip_table (vat_main_t * vam, int is_ipv6)
6044 const ip_details_t *det = NULL;
6045 const ip_address_details_t *address = NULL;
6048 print (vam->ofp, "%-12s", "sw_if_index");
6050 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
6057 print (vam->ofp, "%-12d", i);
6058 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
6063 vec_foreach (address, det->addr)
6067 is_ipv6 ? format_ip6_address : format_ip4_address,
6068 address->ip, address->prefix_length);
6076 dump_ipv4_table (vat_main_t * vam)
6078 if (vam->json_output)
6081 ("JSON output supported only for VPE API calls and dump_stats_table");
6085 return dump_ip_table (vam, 0);
6089 dump_ipv6_table (vat_main_t * vam)
6091 if (vam->json_output)
6094 ("JSON output supported only for VPE API calls and dump_stats_table");
6098 return dump_ip_table (vam, 1);
6102 counter_type_to_str (u8 counter_type, u8 is_combined)
6106 switch (counter_type)
6108 case VNET_INTERFACE_COUNTER_DROP:
6110 case VNET_INTERFACE_COUNTER_PUNT:
6112 case VNET_INTERFACE_COUNTER_IP4:
6114 case VNET_INTERFACE_COUNTER_IP6:
6116 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
6118 case VNET_INTERFACE_COUNTER_RX_MISS:
6120 case VNET_INTERFACE_COUNTER_RX_ERROR:
6122 case VNET_INTERFACE_COUNTER_TX_ERROR:
6125 return "INVALID-COUNTER-TYPE";
6130 switch (counter_type)
6132 case VNET_INTERFACE_COUNTER_RX:
6134 case VNET_INTERFACE_COUNTER_TX:
6137 return "INVALID-COUNTER-TYPE";
6143 dump_stats_table (vat_main_t * vam)
6145 vat_json_node_t node;
6146 vat_json_node_t *msg_array;
6147 vat_json_node_t *msg;
6148 vat_json_node_t *counter_array;
6149 vat_json_node_t *counter;
6150 interface_counter_t c;
6152 ip4_fib_counter_t *c4;
6153 ip6_fib_counter_t *c6;
6154 ip4_nbr_counter_t *n4;
6155 ip6_nbr_counter_t *n6;
6158 if (!vam->json_output)
6160 clib_warning ("dump_stats_table supported only in JSON format");
6164 vat_json_init_object (&node);
6166 /* interface counters */
6167 msg_array = vat_json_object_add (&node, "interface_counters");
6168 vat_json_init_array (msg_array);
6169 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
6171 msg = vat_json_array_add (msg_array);
6172 vat_json_init_object (msg);
6173 vat_json_object_add_string_copy (msg, "vnet_counter_type",
6174 (u8 *) counter_type_to_str (i, 0));
6175 vat_json_object_add_int (msg, "is_combined", 0);
6176 counter_array = vat_json_object_add (msg, "data");
6177 vat_json_init_array (counter_array);
6178 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
6180 packets = vam->simple_interface_counters[i][j];
6181 vat_json_array_add_uint (counter_array, packets);
6184 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
6186 msg = vat_json_array_add (msg_array);
6187 vat_json_init_object (msg);
6188 vat_json_object_add_string_copy (msg, "vnet_counter_type",
6189 (u8 *) counter_type_to_str (i, 1));
6190 vat_json_object_add_int (msg, "is_combined", 1);
6191 counter_array = vat_json_object_add (msg, "data");
6192 vat_json_init_array (counter_array);
6193 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
6195 c = vam->combined_interface_counters[i][j];
6196 counter = vat_json_array_add (counter_array);
6197 vat_json_init_object (counter);
6198 vat_json_object_add_uint (counter, "packets", c.packets);
6199 vat_json_object_add_uint (counter, "bytes", c.bytes);
6203 /* ip4 fib counters */
6204 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
6205 vat_json_init_array (msg_array);
6206 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
6208 msg = vat_json_array_add (msg_array);
6209 vat_json_init_object (msg);
6210 vat_json_object_add_uint (msg, "vrf_id",
6211 vam->ip4_fib_counters_vrf_id_by_index[i]);
6212 counter_array = vat_json_object_add (msg, "c");
6213 vat_json_init_array (counter_array);
6214 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
6216 counter = vat_json_array_add (counter_array);
6217 vat_json_init_object (counter);
6218 c4 = &vam->ip4_fib_counters[i][j];
6219 vat_json_object_add_ip4 (counter, "address", c4->address);
6220 vat_json_object_add_uint (counter, "address_length",
6221 c4->address_length);
6222 vat_json_object_add_uint (counter, "packets", c4->packets);
6223 vat_json_object_add_uint (counter, "bytes", c4->bytes);
6227 /* ip6 fib counters */
6228 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
6229 vat_json_init_array (msg_array);
6230 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
6232 msg = vat_json_array_add (msg_array);
6233 vat_json_init_object (msg);
6234 vat_json_object_add_uint (msg, "vrf_id",
6235 vam->ip6_fib_counters_vrf_id_by_index[i]);
6236 counter_array = vat_json_object_add (msg, "c");
6237 vat_json_init_array (counter_array);
6238 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
6240 counter = vat_json_array_add (counter_array);
6241 vat_json_init_object (counter);
6242 c6 = &vam->ip6_fib_counters[i][j];
6243 vat_json_object_add_ip6 (counter, "address", c6->address);
6244 vat_json_object_add_uint (counter, "address_length",
6245 c6->address_length);
6246 vat_json_object_add_uint (counter, "packets", c6->packets);
6247 vat_json_object_add_uint (counter, "bytes", c6->bytes);
6251 /* ip4 nbr counters */
6252 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
6253 vat_json_init_array (msg_array);
6254 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
6256 msg = vat_json_array_add (msg_array);
6257 vat_json_init_object (msg);
6258 vat_json_object_add_uint (msg, "sw_if_index", i);
6259 counter_array = vat_json_object_add (msg, "c");
6260 vat_json_init_array (counter_array);
6261 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
6263 counter = vat_json_array_add (counter_array);
6264 vat_json_init_object (counter);
6265 n4 = &vam->ip4_nbr_counters[i][j];
6266 vat_json_object_add_ip4 (counter, "address", n4->address);
6267 vat_json_object_add_uint (counter, "link-type", n4->linkt);
6268 vat_json_object_add_uint (counter, "packets", n4->packets);
6269 vat_json_object_add_uint (counter, "bytes", n4->bytes);
6273 /* ip6 nbr counters */
6274 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
6275 vat_json_init_array (msg_array);
6276 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
6278 msg = vat_json_array_add (msg_array);
6279 vat_json_init_object (msg);
6280 vat_json_object_add_uint (msg, "sw_if_index", i);
6281 counter_array = vat_json_object_add (msg, "c");
6282 vat_json_init_array (counter_array);
6283 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
6285 counter = vat_json_array_add (counter_array);
6286 vat_json_init_object (counter);
6287 n6 = &vam->ip6_nbr_counters[i][j];
6288 vat_json_object_add_ip6 (counter, "address", n6->address);
6289 vat_json_object_add_uint (counter, "packets", n6->packets);
6290 vat_json_object_add_uint (counter, "bytes", n6->bytes);
6294 vat_json_print (vam->ofp, &node);
6295 vat_json_free (&node);
6301 * Pass CLI buffers directly in the CLI_INBAND API message,
6302 * instead of an additional shared memory area.
6305 exec_inband (vat_main_t * vam)
6307 vl_api_cli_inband_t *mp;
6308 unformat_input_t *i = vam->input;
6311 if (vec_len (i->buffer) == 0)
6314 if (vam->exec_mode == 0 && unformat (i, "mode"))
6319 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
6326 * In order for the CLI command to work, it
6327 * must be a vector ending in \n, not a C-string ending
6330 u32 len = vec_len (vam->input->buffer);
6331 M2 (CLI_INBAND, mp, len);
6332 clib_memcpy (mp->cmd, vam->input->buffer, len);
6333 mp->length = htonl (len);
6337 /* json responses may or may not include a useful reply... */
6338 if (vec_len (vam->cmd_reply))
6339 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
6344 exec (vat_main_t * vam)
6346 return exec_inband (vam);
6350 api_create_loopback (vat_main_t * vam)
6352 unformat_input_t *i = vam->input;
6353 vl_api_create_loopback_t *mp;
6354 vl_api_create_loopback_instance_t *mp_lbi;
6357 u8 is_specified = 0;
6358 u32 user_instance = 0;
6361 memset (mac_address, 0, sizeof (mac_address));
6363 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6365 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6367 if (unformat (i, "instance %d", &user_instance))
6375 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
6376 mp_lbi->is_specified = is_specified;
6378 mp_lbi->user_instance = htonl (user_instance);
6380 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
6385 /* Construct the API message */
6386 M (CREATE_LOOPBACK, mp);
6388 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
6397 api_delete_loopback (vat_main_t * vam)
6399 unformat_input_t *i = vam->input;
6400 vl_api_delete_loopback_t *mp;
6401 u32 sw_if_index = ~0;
6404 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6406 if (unformat (i, "sw_if_index %d", &sw_if_index))
6412 if (sw_if_index == ~0)
6414 errmsg ("missing sw_if_index");
6418 /* Construct the API message */
6419 M (DELETE_LOOPBACK, mp);
6420 mp->sw_if_index = ntohl (sw_if_index);
6428 api_want_stats (vat_main_t * vam)
6430 unformat_input_t *i = vam->input;
6431 vl_api_want_stats_t *mp;
6435 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6437 if (unformat (i, "enable"))
6439 else if (unformat (i, "disable"))
6447 errmsg ("missing enable|disable");
6452 mp->enable_disable = enable;
6460 api_want_interface_events (vat_main_t * vam)
6462 unformat_input_t *i = vam->input;
6463 vl_api_want_interface_events_t *mp;
6467 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6469 if (unformat (i, "enable"))
6471 else if (unformat (i, "disable"))
6479 errmsg ("missing enable|disable");
6483 M (WANT_INTERFACE_EVENTS, mp);
6484 mp->enable_disable = enable;
6486 vam->interface_event_display = enable;
6494 /* Note: non-static, called once to set up the initial intfc table */
6496 api_sw_interface_dump (vat_main_t * vam)
6498 vl_api_sw_interface_dump_t *mp;
6499 vl_api_control_ping_t *mp_ping;
6501 name_sort_t *nses = 0, *ns;
6502 sw_interface_subif_t *sub = NULL;
6505 /* Toss the old name table */
6507 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6509 vec_add2 (nses, ns, 1);
6510 ns->name = (u8 *)(p->key);
6511 ns->value = (u32) p->value[0];
6515 hash_free (vam->sw_if_index_by_interface_name);
6517 vec_foreach (ns, nses) vec_free (ns->name);
6521 vec_foreach (sub, vam->sw_if_subif_table)
6523 vec_free (sub->interface_name);
6525 vec_free (vam->sw_if_subif_table);
6527 /* recreate the interface name hash table */
6528 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
6531 * Ask for all interface names. Otherwise, the epic catalog of
6532 * name filters becomes ridiculously long, and vat ends up needing
6533 * to be taught about new interface types.
6535 M (SW_INTERFACE_DUMP, mp);
6538 /* Use a control ping for synchronization */
6539 MPING (CONTROL_PING, mp_ping);
6547 api_sw_interface_set_flags (vat_main_t * vam)
6549 unformat_input_t *i = vam->input;
6550 vl_api_sw_interface_set_flags_t *mp;
6552 u8 sw_if_index_set = 0;
6556 /* Parse args required to build the message */
6557 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6559 if (unformat (i, "admin-up"))
6561 else if (unformat (i, "admin-down"))
6564 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6565 sw_if_index_set = 1;
6566 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6567 sw_if_index_set = 1;
6572 if (sw_if_index_set == 0)
6574 errmsg ("missing interface name or sw_if_index");
6578 /* Construct the API message */
6579 M (SW_INTERFACE_SET_FLAGS, mp);
6580 mp->sw_if_index = ntohl (sw_if_index);
6581 mp->admin_up_down = admin_up;
6586 /* Wait for a reply, return the good/bad news... */
6592 api_sw_interface_set_rx_mode (vat_main_t * vam)
6594 unformat_input_t *i = vam->input;
6595 vl_api_sw_interface_set_rx_mode_t *mp;
6597 u8 sw_if_index_set = 0;
6599 u8 queue_id_valid = 0;
6601 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
6603 /* Parse args required to build the message */
6604 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6606 if (unformat (i, "queue %d", &queue_id))
6608 else if (unformat (i, "polling"))
6609 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
6610 else if (unformat (i, "interrupt"))
6611 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
6612 else if (unformat (i, "adaptive"))
6613 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
6615 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6616 sw_if_index_set = 1;
6617 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6618 sw_if_index_set = 1;
6623 if (sw_if_index_set == 0)
6625 errmsg ("missing interface name or sw_if_index");
6628 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6630 errmsg ("missing rx-mode");
6634 /* Construct the API message */
6635 M (SW_INTERFACE_SET_RX_MODE, mp);
6636 mp->sw_if_index = ntohl (sw_if_index);
6638 mp->queue_id_valid = queue_id_valid;
6639 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6644 /* Wait for a reply, return the good/bad news... */
6650 api_sw_interface_set_rx_placement (vat_main_t * vam)
6652 unformat_input_t *i = vam->input;
6653 vl_api_sw_interface_set_rx_placement_t *mp;
6655 u8 sw_if_index_set = 0;
6658 u32 queue_id, thread_index;
6660 /* Parse args required to build the message */
6661 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6663 if (unformat (i, "queue %d", &queue_id))
6665 else if (unformat (i, "main"))
6667 else if (unformat (i, "worker %d", &thread_index))
6670 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6671 sw_if_index_set = 1;
6672 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6673 sw_if_index_set = 1;
6678 if (sw_if_index_set == 0)
6680 errmsg ("missing interface name or sw_if_index");
6686 /* Construct the API message */
6687 M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
6688 mp->sw_if_index = ntohl (sw_if_index);
6689 mp->worker_id = ntohl (thread_index);
6690 mp->queue_id = ntohl (queue_id);
6691 mp->is_main = is_main;
6695 /* Wait for a reply, return the good/bad news... */
6700 static void vl_api_sw_interface_rx_placement_details_t_handler
6701 (vl_api_sw_interface_rx_placement_details_t * mp)
6703 vat_main_t *vam = &vat_main;
6704 u32 worker_id = ntohl (mp->worker_id);
6707 "\n%-11d %-11s %-6d %-5d %-9s",
6708 ntohl (mp->sw_if_index), (worker_id == 0) ? "main" : "worker",
6709 worker_id, ntohl (mp->queue_id),
6711 1) ? "polling" : ((mp->mode == 2) ? "interrupt" : "adaptive"));
6714 static void vl_api_sw_interface_rx_placement_details_t_handler_json
6715 (vl_api_sw_interface_rx_placement_details_t * mp)
6717 vat_main_t *vam = &vat_main;
6718 vat_json_node_t *node = NULL;
6720 if (VAT_JSON_ARRAY != vam->json_tree.type)
6722 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
6723 vat_json_init_array (&vam->json_tree);
6725 node = vat_json_array_add (&vam->json_tree);
6727 vat_json_init_object (node);
6728 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
6729 vat_json_object_add_uint (node, "worker_id", ntohl (mp->worker_id));
6730 vat_json_object_add_uint (node, "queue_id", ntohl (mp->queue_id));
6731 vat_json_object_add_uint (node, "mode", mp->mode);
6735 api_sw_interface_rx_placement_dump (vat_main_t * vam)
6737 unformat_input_t *i = vam->input;
6738 vl_api_sw_interface_rx_placement_dump_t *mp;
6739 vl_api_control_ping_t *mp_ping;
6742 u8 sw_if_index_set = 0;
6744 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6746 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6748 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6755 "\n%-11s %-11s %-6s %-5s %-4s",
6756 "sw_if_index", "main/worker", "thread", "queue", "mode");
6758 /* Dump Interface rx placement */
6759 M (SW_INTERFACE_RX_PLACEMENT_DUMP, mp);
6761 if (sw_if_index_set)
6762 mp->sw_if_index = htonl (sw_if_index);
6764 mp->sw_if_index = ~0;
6768 /* Use a control ping for synchronization */
6769 MPING (CONTROL_PING, mp_ping);
6777 api_sw_interface_clear_stats (vat_main_t * vam)
6779 unformat_input_t *i = vam->input;
6780 vl_api_sw_interface_clear_stats_t *mp;
6782 u8 sw_if_index_set = 0;
6785 /* Parse args required to build the message */
6786 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6788 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6789 sw_if_index_set = 1;
6790 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6791 sw_if_index_set = 1;
6796 /* Construct the API message */
6797 M (SW_INTERFACE_CLEAR_STATS, mp);
6799 if (sw_if_index_set == 1)
6800 mp->sw_if_index = ntohl (sw_if_index);
6802 mp->sw_if_index = ~0;
6807 /* Wait for a reply, return the good/bad news... */
6813 api_sw_interface_add_del_address (vat_main_t * vam)
6815 unformat_input_t *i = vam->input;
6816 vl_api_sw_interface_add_del_address_t *mp;
6818 u8 sw_if_index_set = 0;
6819 u8 is_add = 1, del_all = 0;
6820 u32 address_length = 0;
6821 u8 v4_address_set = 0;
6822 u8 v6_address_set = 0;
6823 ip4_address_t v4address;
6824 ip6_address_t v6address;
6827 /* Parse args required to build the message */
6828 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6830 if (unformat (i, "del-all"))
6832 else if (unformat (i, "del"))
6835 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6836 sw_if_index_set = 1;
6837 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6838 sw_if_index_set = 1;
6839 else if (unformat (i, "%U/%d",
6840 unformat_ip4_address, &v4address, &address_length))
6842 else if (unformat (i, "%U/%d",
6843 unformat_ip6_address, &v6address, &address_length))
6849 if (sw_if_index_set == 0)
6851 errmsg ("missing interface name or sw_if_index");
6854 if (v4_address_set && v6_address_set)
6856 errmsg ("both v4 and v6 addresses set");
6859 if (!v4_address_set && !v6_address_set && !del_all)
6861 errmsg ("no addresses set");
6865 /* Construct the API message */
6866 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6868 mp->sw_if_index = ntohl (sw_if_index);
6869 mp->is_add = is_add;
6870 mp->del_all = del_all;
6874 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6878 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6880 mp->address_length = address_length;
6885 /* Wait for a reply, return good/bad news */
6891 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6893 unformat_input_t *i = vam->input;
6894 vl_api_sw_interface_set_mpls_enable_t *mp;
6896 u8 sw_if_index_set = 0;
6900 /* Parse args required to build the message */
6901 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6903 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6904 sw_if_index_set = 1;
6905 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6906 sw_if_index_set = 1;
6907 else if (unformat (i, "disable"))
6909 else if (unformat (i, "dis"))
6915 if (sw_if_index_set == 0)
6917 errmsg ("missing interface name or sw_if_index");
6921 /* Construct the API message */
6922 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6924 mp->sw_if_index = ntohl (sw_if_index);
6925 mp->enable = enable;
6930 /* Wait for a reply... */
6936 api_sw_interface_set_table (vat_main_t * vam)
6938 unformat_input_t *i = vam->input;
6939 vl_api_sw_interface_set_table_t *mp;
6940 u32 sw_if_index, vrf_id = 0;
6941 u8 sw_if_index_set = 0;
6945 /* Parse args required to build the message */
6946 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6948 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6949 sw_if_index_set = 1;
6950 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6951 sw_if_index_set = 1;
6952 else if (unformat (i, "vrf %d", &vrf_id))
6954 else if (unformat (i, "ipv6"))
6960 if (sw_if_index_set == 0)
6962 errmsg ("missing interface name or sw_if_index");
6966 /* Construct the API message */
6967 M (SW_INTERFACE_SET_TABLE, mp);
6969 mp->sw_if_index = ntohl (sw_if_index);
6970 mp->is_ipv6 = is_ipv6;
6971 mp->vrf_id = ntohl (vrf_id);
6976 /* Wait for a reply... */
6981 static void vl_api_sw_interface_get_table_reply_t_handler
6982 (vl_api_sw_interface_get_table_reply_t * mp)
6984 vat_main_t *vam = &vat_main;
6986 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6988 vam->retval = ntohl (mp->retval);
6989 vam->result_ready = 1;
6993 static void vl_api_sw_interface_get_table_reply_t_handler_json
6994 (vl_api_sw_interface_get_table_reply_t * mp)
6996 vat_main_t *vam = &vat_main;
6997 vat_json_node_t node;
6999 vat_json_init_object (&node);
7000 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
7001 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
7003 vat_json_print (vam->ofp, &node);
7004 vat_json_free (&node);
7006 vam->retval = ntohl (mp->retval);
7007 vam->result_ready = 1;
7011 api_sw_interface_get_table (vat_main_t * vam)
7013 unformat_input_t *i = vam->input;
7014 vl_api_sw_interface_get_table_t *mp;
7016 u8 sw_if_index_set = 0;
7020 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7022 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7023 sw_if_index_set = 1;
7024 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7025 sw_if_index_set = 1;
7026 else if (unformat (i, "ipv6"))
7032 if (sw_if_index_set == 0)
7034 errmsg ("missing interface name or sw_if_index");
7038 M (SW_INTERFACE_GET_TABLE, mp);
7039 mp->sw_if_index = htonl (sw_if_index);
7040 mp->is_ipv6 = is_ipv6;
7048 api_sw_interface_set_vpath (vat_main_t * vam)
7050 unformat_input_t *i = vam->input;
7051 vl_api_sw_interface_set_vpath_t *mp;
7052 u32 sw_if_index = 0;
7053 u8 sw_if_index_set = 0;
7057 /* Parse args required to build the message */
7058 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7060 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7061 sw_if_index_set = 1;
7062 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7063 sw_if_index_set = 1;
7064 else if (unformat (i, "enable"))
7066 else if (unformat (i, "disable"))
7072 if (sw_if_index_set == 0)
7074 errmsg ("missing interface name or sw_if_index");
7078 /* Construct the API message */
7079 M (SW_INTERFACE_SET_VPATH, mp);
7081 mp->sw_if_index = ntohl (sw_if_index);
7082 mp->enable = is_enable;
7087 /* Wait for a reply... */
7093 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
7095 unformat_input_t *i = vam->input;
7096 vl_api_sw_interface_set_vxlan_bypass_t *mp;
7097 u32 sw_if_index = 0;
7098 u8 sw_if_index_set = 0;
7103 /* Parse args required to build the message */
7104 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7106 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7107 sw_if_index_set = 1;
7108 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7109 sw_if_index_set = 1;
7110 else if (unformat (i, "enable"))
7112 else if (unformat (i, "disable"))
7114 else if (unformat (i, "ip4"))
7116 else if (unformat (i, "ip6"))
7122 if (sw_if_index_set == 0)
7124 errmsg ("missing interface name or sw_if_index");
7128 /* Construct the API message */
7129 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
7131 mp->sw_if_index = ntohl (sw_if_index);
7132 mp->enable = is_enable;
7133 mp->is_ipv6 = is_ipv6;
7138 /* Wait for a reply... */
7144 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
7146 unformat_input_t *i = vam->input;
7147 vl_api_sw_interface_set_geneve_bypass_t *mp;
7148 u32 sw_if_index = 0;
7149 u8 sw_if_index_set = 0;
7154 /* Parse args required to build the message */
7155 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7157 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7158 sw_if_index_set = 1;
7159 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7160 sw_if_index_set = 1;
7161 else if (unformat (i, "enable"))
7163 else if (unformat (i, "disable"))
7165 else if (unformat (i, "ip4"))
7167 else if (unformat (i, "ip6"))
7173 if (sw_if_index_set == 0)
7175 errmsg ("missing interface name or sw_if_index");
7179 /* Construct the API message */
7180 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
7182 mp->sw_if_index = ntohl (sw_if_index);
7183 mp->enable = is_enable;
7184 mp->is_ipv6 = is_ipv6;
7189 /* Wait for a reply... */
7195 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
7197 unformat_input_t *i = vam->input;
7198 vl_api_sw_interface_set_l2_xconnect_t *mp;
7200 u8 rx_sw_if_index_set = 0;
7202 u8 tx_sw_if_index_set = 0;
7206 /* Parse args required to build the message */
7207 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7209 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
7210 rx_sw_if_index_set = 1;
7211 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
7212 tx_sw_if_index_set = 1;
7213 else if (unformat (i, "rx"))
7215 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7217 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7219 rx_sw_if_index_set = 1;
7224 else if (unformat (i, "tx"))
7226 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7228 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7230 tx_sw_if_index_set = 1;
7235 else if (unformat (i, "enable"))
7237 else if (unformat (i, "disable"))
7243 if (rx_sw_if_index_set == 0)
7245 errmsg ("missing rx interface name or rx_sw_if_index");
7249 if (enable && (tx_sw_if_index_set == 0))
7251 errmsg ("missing tx interface name or tx_sw_if_index");
7255 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
7257 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7258 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
7259 mp->enable = enable;
7267 api_sw_interface_set_l2_bridge (vat_main_t * vam)
7269 unformat_input_t *i = vam->input;
7270 vl_api_sw_interface_set_l2_bridge_t *mp;
7271 vl_api_l2_port_type_t port_type;
7273 u8 rx_sw_if_index_set = 0;
7280 port_type = L2_API_PORT_TYPE_NORMAL;
7282 /* Parse args required to build the message */
7283 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7285 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
7286 rx_sw_if_index_set = 1;
7287 else if (unformat (i, "bd_id %d", &bd_id))
7291 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
7292 rx_sw_if_index_set = 1;
7293 else if (unformat (i, "shg %d", &shg))
7295 else if (unformat (i, "bvi"))
7296 port_type = L2_API_PORT_TYPE_BVI;
7297 else if (unformat (i, "uu-fwd"))
7298 port_type = L2_API_PORT_TYPE_UU_FWD;
7299 else if (unformat (i, "enable"))
7301 else if (unformat (i, "disable"))
7307 if (rx_sw_if_index_set == 0)
7309 errmsg ("missing rx interface name or sw_if_index");
7313 if (enable && (bd_id_set == 0))
7315 errmsg ("missing bridge domain");
7319 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
7321 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7322 mp->bd_id = ntohl (bd_id);
7324 mp->port_type = ntohl (port_type);
7325 mp->enable = enable;
7333 api_bridge_domain_dump (vat_main_t * vam)
7335 unformat_input_t *i = vam->input;
7336 vl_api_bridge_domain_dump_t *mp;
7337 vl_api_control_ping_t *mp_ping;
7341 /* Parse args required to build the message */
7342 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7344 if (unformat (i, "bd_id %d", &bd_id))
7350 M (BRIDGE_DOMAIN_DUMP, mp);
7351 mp->bd_id = ntohl (bd_id);
7354 /* Use a control ping for synchronization */
7355 MPING (CONTROL_PING, mp_ping);
7363 api_bridge_domain_add_del (vat_main_t * vam)
7365 unformat_input_t *i = vam->input;
7366 vl_api_bridge_domain_add_del_t *mp;
7369 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
7374 /* Parse args required to build the message */
7375 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7377 if (unformat (i, "bd_id %d", &bd_id))
7379 else if (unformat (i, "flood %d", &flood))
7381 else if (unformat (i, "uu-flood %d", &uu_flood))
7383 else if (unformat (i, "forward %d", &forward))
7385 else if (unformat (i, "learn %d", &learn))
7387 else if (unformat (i, "arp-term %d", &arp_term))
7389 else if (unformat (i, "mac-age %d", &mac_age))
7391 else if (unformat (i, "bd-tag %s", &bd_tag))
7393 else if (unformat (i, "del"))
7396 flood = uu_flood = forward = learn = 0;
7404 errmsg ("missing bridge domain");
7411 errmsg ("mac age must be less than 256 ");
7416 if ((bd_tag) && (vec_len (bd_tag) > 63))
7418 errmsg ("bd-tag cannot be longer than 63");
7423 M (BRIDGE_DOMAIN_ADD_DEL, mp);
7425 mp->bd_id = ntohl (bd_id);
7427 mp->uu_flood = uu_flood;
7428 mp->forward = forward;
7430 mp->arp_term = arp_term;
7431 mp->is_add = is_add;
7432 mp->mac_age = (u8) mac_age;
7435 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
7436 mp->bd_tag[vec_len (bd_tag)] = 0;
7447 api_l2fib_flush_bd (vat_main_t * vam)
7449 unformat_input_t *i = vam->input;
7450 vl_api_l2fib_flush_bd_t *mp;
7454 /* Parse args required to build the message */
7455 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7457 if (unformat (i, "bd_id %d", &bd_id));
7464 errmsg ("missing bridge domain");
7468 M (L2FIB_FLUSH_BD, mp);
7470 mp->bd_id = htonl (bd_id);
7478 api_l2fib_flush_int (vat_main_t * vam)
7480 unformat_input_t *i = vam->input;
7481 vl_api_l2fib_flush_int_t *mp;
7482 u32 sw_if_index = ~0;
7485 /* Parse args required to build the message */
7486 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7488 if (unformat (i, "sw_if_index %d", &sw_if_index));
7490 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
7495 if (sw_if_index == ~0)
7497 errmsg ("missing interface name or sw_if_index");
7501 M (L2FIB_FLUSH_INT, mp);
7503 mp->sw_if_index = ntohl (sw_if_index);
7511 api_l2fib_add_del (vat_main_t * vam)
7513 unformat_input_t *i = vam->input;
7514 vl_api_l2fib_add_del_t *mp;
7520 u32 sw_if_index = 0;
7521 u8 sw_if_index_set = 0;
7530 /* Parse args required to build the message */
7531 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7533 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
7535 else if (unformat (i, "bd_id %d", &bd_id))
7537 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7538 sw_if_index_set = 1;
7539 else if (unformat (i, "sw_if"))
7541 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7544 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7545 sw_if_index_set = 1;
7550 else if (unformat (i, "static"))
7552 else if (unformat (i, "filter"))
7557 else if (unformat (i, "bvi"))
7562 else if (unformat (i, "del"))
7564 else if (unformat (i, "count %d", &count))
7572 errmsg ("missing mac address");
7578 errmsg ("missing bridge domain");
7582 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7584 errmsg ("missing interface name or sw_if_index");
7590 /* Turn on async mode */
7591 vam->async_mode = 1;
7592 vam->async_errors = 0;
7593 before = vat_time_now (vam);
7596 for (j = 0; j < count; j++)
7598 M (L2FIB_ADD_DEL, mp);
7600 clib_memcpy (mp->mac, mac, 6);
7601 mp->bd_id = ntohl (bd_id);
7602 mp->is_add = is_add;
7603 mp->sw_if_index = ntohl (sw_if_index);
7607 mp->static_mac = static_mac;
7608 mp->filter_mac = filter_mac;
7609 mp->bvi_mac = bvi_mac;
7611 increment_mac_address (mac);
7618 vl_api_control_ping_t *mp_ping;
7621 /* Shut off async mode */
7622 vam->async_mode = 0;
7624 MPING (CONTROL_PING, mp_ping);
7627 timeout = vat_time_now (vam) + 1.0;
7628 while (vat_time_now (vam) < timeout)
7629 if (vam->result_ready == 1)
7634 if (vam->retval == -99)
7637 if (vam->async_errors > 0)
7639 errmsg ("%d asynchronous errors", vam->async_errors);
7642 vam->async_errors = 0;
7643 after = vat_time_now (vam);
7645 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7646 count, after - before, count / (after - before));
7652 /* Wait for a reply... */
7656 /* Return the good/bad news */
7657 return (vam->retval);
7661 api_bridge_domain_set_mac_age (vat_main_t * vam)
7663 unformat_input_t *i = vam->input;
7664 vl_api_bridge_domain_set_mac_age_t *mp;
7669 /* Parse args required to build the message */
7670 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7672 if (unformat (i, "bd_id %d", &bd_id));
7673 else if (unformat (i, "mac-age %d", &mac_age));
7680 errmsg ("missing bridge domain");
7686 errmsg ("mac age must be less than 256 ");
7690 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7692 mp->bd_id = htonl (bd_id);
7693 mp->mac_age = (u8) mac_age;
7701 api_l2_flags (vat_main_t * vam)
7703 unformat_input_t *i = vam->input;
7704 vl_api_l2_flags_t *mp;
7707 u8 sw_if_index_set = 0;
7711 /* Parse args required to build the message */
7712 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7714 if (unformat (i, "sw_if_index %d", &sw_if_index))
7715 sw_if_index_set = 1;
7716 else if (unformat (i, "sw_if"))
7718 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7721 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7722 sw_if_index_set = 1;
7727 else if (unformat (i, "learn"))
7729 else if (unformat (i, "forward"))
7731 else if (unformat (i, "flood"))
7733 else if (unformat (i, "uu-flood"))
7734 flags |= L2_UU_FLOOD;
7735 else if (unformat (i, "arp-term"))
7736 flags |= L2_ARP_TERM;
7737 else if (unformat (i, "off"))
7739 else if (unformat (i, "disable"))
7745 if (sw_if_index_set == 0)
7747 errmsg ("missing interface name or sw_if_index");
7753 mp->sw_if_index = ntohl (sw_if_index);
7754 mp->feature_bitmap = ntohl (flags);
7755 mp->is_set = is_set;
7763 api_bridge_flags (vat_main_t * vam)
7765 unformat_input_t *i = vam->input;
7766 vl_api_bridge_flags_t *mp;
7770 bd_flags_t flags = 0;
7773 /* Parse args required to build the message */
7774 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7776 if (unformat (i, "bd_id %d", &bd_id))
7778 else if (unformat (i, "learn"))
7779 flags |= BRIDGE_API_FLAG_LEARN;
7780 else if (unformat (i, "forward"))
7781 flags |= BRIDGE_API_FLAG_FWD;
7782 else if (unformat (i, "flood"))
7783 flags |= BRIDGE_API_FLAG_FLOOD;
7784 else if (unformat (i, "uu-flood"))
7785 flags |= BRIDGE_API_FLAG_UU_FLOOD;
7786 else if (unformat (i, "arp-term"))
7787 flags |= BRIDGE_API_FLAG_ARP_TERM;
7788 else if (unformat (i, "off"))
7790 else if (unformat (i, "disable"))
7798 errmsg ("missing bridge domain");
7802 M (BRIDGE_FLAGS, mp);
7804 mp->bd_id = ntohl (bd_id);
7805 mp->flags = ntohl (flags);
7806 mp->is_set = is_set;
7814 api_bd_ip_mac_add_del (vat_main_t * vam)
7816 unformat_input_t *i = vam->input;
7817 vl_api_bd_ip_mac_add_del_t *mp;
7824 ip4_address_t v4addr;
7825 ip6_address_t v6addr;
7830 /* Parse args required to build the message */
7831 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7833 if (unformat (i, "bd_id %d", &bd_id))
7837 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
7841 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
7846 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
7850 else if (unformat (i, "del"))
7858 errmsg ("missing bridge domain");
7861 else if (ip_set == 0)
7863 errmsg ("missing IP address");
7866 else if (mac_set == 0)
7868 errmsg ("missing MAC address");
7872 M (BD_IP_MAC_ADD_DEL, mp);
7874 mp->bd_id = ntohl (bd_id);
7875 mp->is_ipv6 = is_ipv6;
7876 mp->is_add = is_add;
7878 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
7880 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
7881 clib_memcpy (mp->mac_address, macaddr, 6);
7887 static void vl_api_bd_ip_mac_details_t_handler
7888 (vl_api_bd_ip_mac_details_t * mp)
7890 vat_main_t *vam = &vat_main;
7895 format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
7898 format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
7901 "\n%-5d %-7s %-20U %-30s",
7902 ntohl (mp->bd_id), mp->is_ipv6 ? "ip6" : "ip4",
7903 format_ethernet_address, mp->mac_address, ip);
7908 static void vl_api_bd_ip_mac_details_t_handler_json
7909 (vl_api_bd_ip_mac_details_t * mp)
7911 vat_main_t *vam = &vat_main;
7912 vat_json_node_t *node = NULL;
7914 if (VAT_JSON_ARRAY != vam->json_tree.type)
7916 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7917 vat_json_init_array (&vam->json_tree);
7919 node = vat_json_array_add (&vam->json_tree);
7921 vat_json_init_object (node);
7922 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
7923 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
7924 vat_json_object_add_string_copy (node, "mac_address",
7925 format (0, "%U", format_ethernet_address,
7931 format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
7934 format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
7935 vat_json_object_add_string_copy (node, "ip_address", ip);
7940 api_bd_ip_mac_dump (vat_main_t * vam)
7942 unformat_input_t *i = vam->input;
7943 vl_api_bd_ip_mac_dump_t *mp;
7944 vl_api_control_ping_t *mp_ping;
7949 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7951 if (unformat (i, "bd_id %d", &bd_id))
7960 "\n%-5s %-7s %-20s %-30s",
7961 "bd_id", "is_ipv6", "mac_address", "ip_address");
7963 /* Dump Bridge Domain Ip to Mac entries */
7964 M (BD_IP_MAC_DUMP, mp);
7967 mp->bd_id = htonl (bd_id);
7973 /* Use a control ping for synchronization */
7974 MPING (CONTROL_PING, mp_ping);
7982 api_tap_connect (vat_main_t * vam)
7984 unformat_input_t *i = vam->input;
7985 vl_api_tap_connect_t *mp;
7991 ip4_address_t ip4_address;
7993 int ip4_address_set = 0;
7994 ip6_address_t ip6_address;
7996 int ip6_address_set = 0;
7999 memset (mac_address, 0, sizeof (mac_address));
8001 /* Parse args required to build the message */
8002 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8004 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
8008 else if (unformat (i, "random-mac"))
8010 else if (unformat (i, "tapname %s", &tap_name))
8012 else if (unformat (i, "tag %s", &tag))
8014 else if (unformat (i, "address %U/%d",
8015 unformat_ip4_address, &ip4_address, &ip4_mask_width))
8016 ip4_address_set = 1;
8017 else if (unformat (i, "address %U/%d",
8018 unformat_ip6_address, &ip6_address, &ip6_mask_width))
8019 ip6_address_set = 1;
8026 errmsg ("missing tap name");
8029 if (vec_len (tap_name) > 63)
8031 errmsg ("tap name too long");
8034 vec_add1 (tap_name, 0);
8036 if (vec_len (tag) > 63)
8038 errmsg ("tag too long");
8042 /* Construct the API message */
8043 M (TAP_CONNECT, mp);
8045 mp->use_random_mac = random_mac;
8046 clib_memcpy (mp->mac_address, mac_address, 6);
8047 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
8049 clib_memcpy (mp->tag, tag, vec_len (tag));
8051 if (ip4_address_set)
8053 mp->ip4_address_set = 1;
8054 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
8055 mp->ip4_mask_width = ip4_mask_width;
8057 if (ip6_address_set)
8059 mp->ip6_address_set = 1;
8060 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
8061 mp->ip6_mask_width = ip6_mask_width;
8064 vec_free (tap_name);
8070 /* Wait for a reply... */
8076 api_tap_modify (vat_main_t * vam)
8078 unformat_input_t *i = vam->input;
8079 vl_api_tap_modify_t *mp;
8084 u32 sw_if_index = ~0;
8085 u8 sw_if_index_set = 0;
8088 memset (mac_address, 0, sizeof (mac_address));
8090 /* Parse args required to build the message */
8091 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8093 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8094 sw_if_index_set = 1;
8095 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8096 sw_if_index_set = 1;
8097 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
8101 else if (unformat (i, "random-mac"))
8103 else if (unformat (i, "tapname %s", &tap_name))
8109 if (sw_if_index_set == 0)
8111 errmsg ("missing vpp interface name");
8116 errmsg ("missing tap name");
8119 if (vec_len (tap_name) > 63)
8121 errmsg ("tap name too long");
8123 vec_add1 (tap_name, 0);
8125 /* Construct the API message */
8128 mp->use_random_mac = random_mac;
8129 mp->sw_if_index = ntohl (sw_if_index);
8130 clib_memcpy (mp->mac_address, mac_address, 6);
8131 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
8132 vec_free (tap_name);
8137 /* Wait for a reply... */
8143 api_tap_delete (vat_main_t * vam)
8145 unformat_input_t *i = vam->input;
8146 vl_api_tap_delete_t *mp;
8147 u32 sw_if_index = ~0;
8148 u8 sw_if_index_set = 0;
8151 /* Parse args required to build the message */
8152 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8154 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8155 sw_if_index_set = 1;
8156 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8157 sw_if_index_set = 1;
8162 if (sw_if_index_set == 0)
8164 errmsg ("missing vpp interface name");
8168 /* Construct the API message */
8171 mp->sw_if_index = ntohl (sw_if_index);
8176 /* Wait for a reply... */
8182 api_tap_create_v2 (vat_main_t * vam)
8184 unformat_input_t *i = vam->input;
8185 vl_api_tap_create_v2_t *mp;
8189 u8 *host_if_name = 0;
8191 u8 host_mac_addr[6];
8192 u8 host_mac_addr_set = 0;
8193 u8 *host_bridge = 0;
8194 ip4_address_t host_ip4_addr;
8195 ip4_address_t host_ip4_gw;
8196 u8 host_ip4_gw_set = 0;
8197 u32 host_ip4_prefix_len = 0;
8198 ip6_address_t host_ip6_addr;
8199 ip6_address_t host_ip6_gw;
8200 u8 host_ip6_gw_set = 0;
8201 u32 host_ip6_prefix_len = 0;
8203 u32 rx_ring_sz = 0, tx_ring_sz = 0;
8205 memset (mac_address, 0, sizeof (mac_address));
8207 /* Parse args required to build the message */
8208 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8210 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
8214 else if (unformat (i, "id %u", &id))
8216 else if (unformat (i, "host-if-name %s", &host_if_name))
8218 else if (unformat (i, "host-ns %s", &host_ns))
8220 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
8222 host_mac_addr_set = 1;
8223 else if (unformat (i, "host-bridge %s", &host_bridge))
8225 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
8226 &host_ip4_addr, &host_ip4_prefix_len))
8228 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
8229 &host_ip6_addr, &host_ip6_prefix_len))
8231 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
8233 host_ip4_gw_set = 1;
8234 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
8236 host_ip6_gw_set = 1;
8237 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
8239 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
8245 if (vec_len (host_if_name) > 63)
8247 errmsg ("tap name too long. ");
8250 if (vec_len (host_ns) > 63)
8252 errmsg ("host name space too long. ");
8255 if (vec_len (host_bridge) > 63)
8257 errmsg ("host bridge name too long. ");
8260 if (host_ip4_prefix_len > 32)
8262 errmsg ("host ip4 prefix length not valid. ");
8265 if (host_ip6_prefix_len > 128)
8267 errmsg ("host ip6 prefix length not valid. ");
8270 if (!is_pow2 (rx_ring_sz))
8272 errmsg ("rx ring size must be power of 2. ");
8275 if (rx_ring_sz > 32768)
8277 errmsg ("rx ring size must be 32768 or lower. ");
8280 if (!is_pow2 (tx_ring_sz))
8282 errmsg ("tx ring size must be power of 2. ");
8285 if (tx_ring_sz > 32768)
8287 errmsg ("tx ring size must be 32768 or lower. ");
8291 /* Construct the API message */
8292 M (TAP_CREATE_V2, mp);
8294 mp->use_random_mac = random_mac;
8296 mp->id = ntohl (id);
8297 mp->host_namespace_set = host_ns != 0;
8298 mp->host_bridge_set = host_bridge != 0;
8299 mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
8300 mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
8301 mp->rx_ring_sz = ntohs (rx_ring_sz);
8302 mp->tx_ring_sz = ntohs (tx_ring_sz);
8304 if (random_mac == 0)
8305 clib_memcpy (mp->mac_address, mac_address, 6);
8306 if (host_mac_addr_set)
8307 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
8309 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
8311 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
8313 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
8314 if (host_ip4_prefix_len)
8315 clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
8316 if (host_ip4_prefix_len)
8317 clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
8318 if (host_ip4_gw_set)
8319 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
8320 if (host_ip6_gw_set)
8321 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
8324 vec_free (host_if_name);
8325 vec_free (host_bridge);
8330 /* Wait for a reply... */
8336 api_tap_delete_v2 (vat_main_t * vam)
8338 unformat_input_t *i = vam->input;
8339 vl_api_tap_delete_v2_t *mp;
8340 u32 sw_if_index = ~0;
8341 u8 sw_if_index_set = 0;
8344 /* Parse args required to build the message */
8345 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8347 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8348 sw_if_index_set = 1;
8349 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8350 sw_if_index_set = 1;
8355 if (sw_if_index_set == 0)
8357 errmsg ("missing vpp interface name. ");
8361 /* Construct the API message */
8362 M (TAP_DELETE_V2, mp);
8364 mp->sw_if_index = ntohl (sw_if_index);
8369 /* Wait for a reply... */
8375 api_bond_create (vat_main_t * vam)
8377 unformat_input_t *i = vam->input;
8378 vl_api_bond_create_t *mp;
8386 memset (mac_address, 0, sizeof (mac_address));
8389 /* Parse args required to build the message */
8390 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8392 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
8394 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
8395 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
8397 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
8404 if (mode_is_set == 0)
8406 errmsg ("Missing bond mode. ");
8410 /* Construct the API message */
8411 M (BOND_CREATE, mp);
8413 mp->use_custom_mac = custom_mac;
8419 clib_memcpy (mp->mac_address, mac_address, 6);
8424 /* Wait for a reply... */
8430 api_bond_delete (vat_main_t * vam)
8432 unformat_input_t *i = vam->input;
8433 vl_api_bond_delete_t *mp;
8434 u32 sw_if_index = ~0;
8435 u8 sw_if_index_set = 0;
8438 /* Parse args required to build the message */
8439 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8441 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8442 sw_if_index_set = 1;
8443 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8444 sw_if_index_set = 1;
8449 if (sw_if_index_set == 0)
8451 errmsg ("missing vpp interface name. ");
8455 /* Construct the API message */
8456 M (BOND_DELETE, mp);
8458 mp->sw_if_index = ntohl (sw_if_index);
8463 /* Wait for a reply... */
8469 api_bond_enslave (vat_main_t * vam)
8471 unformat_input_t *i = vam->input;
8472 vl_api_bond_enslave_t *mp;
8473 u32 bond_sw_if_index;
8477 u32 bond_sw_if_index_is_set = 0;
8479 u8 sw_if_index_is_set = 0;
8481 /* Parse args required to build the message */
8482 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8484 if (unformat (i, "sw_if_index %d", &sw_if_index))
8485 sw_if_index_is_set = 1;
8486 else if (unformat (i, "bond %u", &bond_sw_if_index))
8487 bond_sw_if_index_is_set = 1;
8488 else if (unformat (i, "passive %d", &is_passive))
8490 else if (unformat (i, "long-timeout %d", &is_long_timeout))
8496 if (bond_sw_if_index_is_set == 0)
8498 errmsg ("Missing bond sw_if_index. ");
8501 if (sw_if_index_is_set == 0)
8503 errmsg ("Missing slave sw_if_index. ");
8507 /* Construct the API message */
8508 M (BOND_ENSLAVE, mp);
8510 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
8511 mp->sw_if_index = ntohl (sw_if_index);
8512 mp->is_long_timeout = is_long_timeout;
8513 mp->is_passive = is_passive;
8518 /* Wait for a reply... */
8524 api_bond_detach_slave (vat_main_t * vam)
8526 unformat_input_t *i = vam->input;
8527 vl_api_bond_detach_slave_t *mp;
8528 u32 sw_if_index = ~0;
8529 u8 sw_if_index_set = 0;
8532 /* Parse args required to build the message */
8533 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8535 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8536 sw_if_index_set = 1;
8537 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8538 sw_if_index_set = 1;
8543 if (sw_if_index_set == 0)
8545 errmsg ("missing vpp interface name. ");
8549 /* Construct the API message */
8550 M (BOND_DETACH_SLAVE, mp);
8552 mp->sw_if_index = ntohl (sw_if_index);
8557 /* Wait for a reply... */
8563 api_ip_table_add_del (vat_main_t * vam)
8565 unformat_input_t *i = vam->input;
8566 vl_api_ip_table_add_del_t *mp;
8572 /* Parse args required to build the message */
8573 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8575 if (unformat (i, "ipv6"))
8577 else if (unformat (i, "del"))
8579 else if (unformat (i, "add"))
8581 else if (unformat (i, "table %d", &table_id))
8585 clib_warning ("parse error '%U'", format_unformat_error, i);
8592 errmsg ("missing table-ID");
8596 /* Construct the API message */
8597 M (IP_TABLE_ADD_DEL, mp);
8599 mp->table_id = ntohl (table_id);
8600 mp->is_ipv6 = is_ipv6;
8601 mp->is_add = is_add;
8606 /* Wait for a reply... */
8613 api_ip_add_del_route (vat_main_t * vam)
8615 unformat_input_t *i = vam->input;
8616 vl_api_ip_add_del_route_t *mp;
8617 u32 sw_if_index = ~0, vrf_id = 0;
8619 u8 is_local = 0, is_drop = 0;
8620 u8 is_unreach = 0, is_prohibit = 0;
8622 u32 next_hop_weight = 1;
8623 u8 is_multipath = 0;
8625 u8 address_length_set = 0;
8626 u32 next_hop_table_id = 0;
8627 u32 resolve_attempts = 0;
8628 u32 dst_address_length = 0;
8629 u8 next_hop_set = 0;
8630 ip4_address_t v4_dst_address, v4_next_hop_address;
8631 ip6_address_t v6_dst_address, v6_next_hop_address;
8635 u32 random_add_del = 0;
8636 u32 *random_vector = 0;
8638 u32 random_seed = 0xdeaddabe;
8639 u32 classify_table_index = ~0;
8641 u8 resolve_host = 0, resolve_attached = 0;
8642 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
8643 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8644 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8646 memset (&v4_next_hop_address, 0, sizeof (ip4_address_t));
8647 memset (&v6_next_hop_address, 0, sizeof (ip6_address_t));
8648 /* Parse args required to build the message */
8649 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8651 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8653 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8655 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
8660 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
8665 else if (unformat (i, "/%d", &dst_address_length))
8667 address_length_set = 1;
8670 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
8671 &v4_next_hop_address))
8675 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
8676 &v6_next_hop_address))
8682 (i, "via %U", api_unformat_sw_if_index, vam, &sw_if_index))
8686 else if (unformat (i, "via sw_if_index %d", &sw_if_index))
8690 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
8692 else if (unformat (i, "weight %d", &next_hop_weight))
8694 else if (unformat (i, "drop"))
8698 else if (unformat (i, "null-send-unreach"))
8702 else if (unformat (i, "null-send-prohibit"))
8706 else if (unformat (i, "local"))
8710 else if (unformat (i, "classify %d", &classify_table_index))
8714 else if (unformat (i, "del"))
8716 else if (unformat (i, "add"))
8718 else if (unformat (i, "resolve-via-host"))
8720 else if (unformat (i, "resolve-via-attached"))
8721 resolve_attached = 1;
8722 else if (unformat (i, "multipath"))
8724 else if (unformat (i, "vrf %d", &vrf_id))
8726 else if (unformat (i, "count %d", &count))
8728 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
8730 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8732 else if (unformat (i, "out-label %d", &next_hop_out_label))
8734 vl_api_fib_mpls_label_t fib_label = {
8735 .label = ntohl (next_hop_out_label),
8739 vec_add1 (next_hop_out_label_stack, fib_label);
8741 else if (unformat (i, "via via-label %d", &next_hop_via_label))
8743 else if (unformat (i, "random"))
8745 else if (unformat (i, "seed %d", &random_seed))
8749 clib_warning ("parse error '%U'", format_unformat_error, i);
8754 if (!next_hop_set && !is_drop && !is_local &&
8755 !is_classify && !is_unreach && !is_prohibit &&
8756 MPLS_LABEL_INVALID == next_hop_via_label)
8759 ("next hop / local / drop / unreach / prohibit / classify not set");
8763 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
8765 errmsg ("next hop and next-hop via label set");
8768 if (address_set == 0)
8770 errmsg ("missing addresses");
8774 if (address_length_set == 0)
8776 errmsg ("missing address length");
8780 /* Generate a pile of unique, random routes */
8783 u32 this_random_address;
8784 random_hash = hash_create (count, sizeof (uword));
8786 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
8787 for (j = 0; j <= count; j++)
8791 this_random_address = random_u32 (&random_seed);
8792 this_random_address =
8793 clib_host_to_net_u32 (this_random_address);
8795 while (hash_get (random_hash, this_random_address));
8796 vec_add1 (random_vector, this_random_address);
8797 hash_set (random_hash, this_random_address, 1);
8799 hash_free (random_hash);
8800 v4_dst_address.as_u32 = random_vector[0];
8805 /* Turn on async mode */
8806 vam->async_mode = 1;
8807 vam->async_errors = 0;
8808 before = vat_time_now (vam);
8811 for (j = 0; j < count; j++)
8813 /* Construct the API message */
8814 M2 (IP_ADD_DEL_ROUTE, mp, sizeof (vl_api_fib_mpls_label_t) *
8815 vec_len (next_hop_out_label_stack));
8817 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8818 mp->table_id = ntohl (vrf_id);
8820 mp->is_add = is_add;
8821 mp->is_drop = is_drop;
8822 mp->is_unreach = is_unreach;
8823 mp->is_prohibit = is_prohibit;
8824 mp->is_ipv6 = is_ipv6;
8825 mp->is_local = is_local;
8826 mp->is_classify = is_classify;
8827 mp->is_multipath = is_multipath;
8828 mp->is_resolve_host = resolve_host;
8829 mp->is_resolve_attached = resolve_attached;
8830 mp->next_hop_weight = next_hop_weight;
8831 mp->dst_address_length = dst_address_length;
8832 mp->next_hop_table_id = ntohl (next_hop_table_id);
8833 mp->classify_table_index = ntohl (classify_table_index);
8834 mp->next_hop_via_label = ntohl (next_hop_via_label);
8835 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8836 if (0 != mp->next_hop_n_out_labels)
8838 memcpy (mp->next_hop_out_label_stack,
8839 next_hop_out_label_stack,
8840 (vec_len (next_hop_out_label_stack) *
8841 sizeof (vl_api_fib_mpls_label_t)));
8842 vec_free (next_hop_out_label_stack);
8847 clib_memcpy (mp->dst_address, &v6_dst_address,
8848 sizeof (v6_dst_address));
8850 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
8851 sizeof (v6_next_hop_address));
8852 increment_v6_address (&v6_dst_address);
8856 clib_memcpy (mp->dst_address, &v4_dst_address,
8857 sizeof (v4_dst_address));
8859 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
8860 sizeof (v4_next_hop_address));
8862 v4_dst_address.as_u32 = random_vector[j + 1];
8864 increment_v4_address (&v4_dst_address);
8868 /* If we receive SIGTERM, stop now... */
8873 /* When testing multiple add/del ops, use a control-ping to sync */
8876 vl_api_control_ping_t *mp_ping;
8880 /* Shut off async mode */
8881 vam->async_mode = 0;
8883 MPING (CONTROL_PING, mp_ping);
8886 timeout = vat_time_now (vam) + 1.0;
8887 while (vat_time_now (vam) < timeout)
8888 if (vam->result_ready == 1)
8893 if (vam->retval == -99)
8896 if (vam->async_errors > 0)
8898 errmsg ("%d asynchronous errors", vam->async_errors);
8901 vam->async_errors = 0;
8902 after = vat_time_now (vam);
8904 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8908 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8909 count, after - before, count / (after - before));
8915 /* Wait for a reply... */
8920 /* Return the good/bad news */
8921 return (vam->retval);
8925 api_ip_mroute_add_del (vat_main_t * vam)
8927 unformat_input_t *i = vam->input;
8928 vl_api_ip_mroute_add_del_t *mp;
8929 u32 sw_if_index = ~0, vrf_id = 0;
8934 u32 grp_address_length = 0;
8935 ip4_address_t v4_grp_address, v4_src_address;
8936 ip6_address_t v6_grp_address, v6_src_address;
8937 mfib_itf_flags_t iflags = 0;
8938 mfib_entry_flags_t eflags = 0;
8941 /* Parse args required to build the message */
8942 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8944 if (unformat (i, "sw_if_index %d", &sw_if_index))
8946 else if (unformat (i, "%U %U",
8947 unformat_ip4_address, &v4_src_address,
8948 unformat_ip4_address, &v4_grp_address))
8950 grp_address_length = 64;
8954 else if (unformat (i, "%U %U",
8955 unformat_ip6_address, &v6_src_address,
8956 unformat_ip6_address, &v6_grp_address))
8958 grp_address_length = 256;
8962 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
8964 memset (&v4_src_address, 0, sizeof (v4_src_address));
8965 grp_address_length = 32;
8969 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
8971 memset (&v6_src_address, 0, sizeof (v6_src_address));
8972 grp_address_length = 128;
8976 else if (unformat (i, "/%d", &grp_address_length))
8978 else if (unformat (i, "local"))
8982 else if (unformat (i, "del"))
8984 else if (unformat (i, "add"))
8986 else if (unformat (i, "vrf %d", &vrf_id))
8988 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
8990 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8994 clib_warning ("parse error '%U'", format_unformat_error, i);
8999 if (address_set == 0)
9001 errmsg ("missing addresses\n");
9005 /* Construct the API message */
9006 M (IP_MROUTE_ADD_DEL, mp);
9008 mp->next_hop_sw_if_index = ntohl (sw_if_index);
9009 mp->table_id = ntohl (vrf_id);
9011 mp->is_add = is_add;
9012 mp->is_ipv6 = is_ipv6;
9013 mp->is_local = is_local;
9014 mp->itf_flags = ntohl (iflags);
9015 mp->entry_flags = ntohl (eflags);
9016 mp->grp_address_length = grp_address_length;
9017 mp->grp_address_length = ntohs (mp->grp_address_length);
9021 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
9022 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
9026 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
9027 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
9033 /* Wait for a reply... */
9039 api_mpls_table_add_del (vat_main_t * vam)
9041 unformat_input_t *i = vam->input;
9042 vl_api_mpls_table_add_del_t *mp;
9047 /* Parse args required to build the message */
9048 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9050 if (unformat (i, "table %d", &table_id))
9052 else if (unformat (i, "del"))
9054 else if (unformat (i, "add"))
9058 clib_warning ("parse error '%U'", format_unformat_error, i);
9065 errmsg ("missing table-ID");
9069 /* Construct the API message */
9070 M (MPLS_TABLE_ADD_DEL, mp);
9072 mp->mt_table_id = ntohl (table_id);
9073 mp->mt_is_add = is_add;
9078 /* Wait for a reply... */
9085 api_mpls_route_add_del (vat_main_t * vam)
9087 unformat_input_t *i = vam->input;
9088 vl_api_mpls_route_add_del_t *mp;
9089 u32 sw_if_index = ~0, table_id = 0;
9091 u32 next_hop_weight = 1;
9092 u8 is_multipath = 0;
9093 u32 next_hop_table_id = 0;
9094 u8 next_hop_set = 0;
9095 ip4_address_t v4_next_hop_address = {
9098 ip6_address_t v6_next_hop_address = { {0} };
9102 u32 classify_table_index = ~0;
9104 u8 resolve_host = 0, resolve_attached = 0;
9105 u8 is_interface_rx = 0;
9106 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
9107 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9108 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
9109 mpls_label_t local_label = MPLS_LABEL_INVALID;
9111 dpo_proto_t next_hop_proto = DPO_PROTO_MPLS;
9113 /* Parse args required to build the message */
9114 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9116 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9118 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9120 else if (unformat (i, "%d", &local_label))
9122 else if (unformat (i, "eos"))
9124 else if (unformat (i, "non-eos"))
9126 else if (unformat (i, "via %U", unformat_ip4_address,
9127 &v4_next_hop_address))
9130 next_hop_proto = DPO_PROTO_IP4;
9132 else if (unformat (i, "via %U", unformat_ip6_address,
9133 &v6_next_hop_address))
9136 next_hop_proto = DPO_PROTO_IP6;
9138 else if (unformat (i, "weight %d", &next_hop_weight))
9140 else if (unformat (i, "classify %d", &classify_table_index))
9144 else if (unformat (i, "del"))
9146 else if (unformat (i, "add"))
9148 else if (unformat (i, "resolve-via-host"))
9150 else if (unformat (i, "resolve-via-attached"))
9151 resolve_attached = 1;
9152 else if (unformat (i, "multipath"))
9154 else if (unformat (i, "count %d", &count))
9156 else if (unformat (i, "via lookup-in-ip4-table %d", &next_hop_table_id))
9159 next_hop_proto = DPO_PROTO_IP4;
9161 else if (unformat (i, "via lookup-in-ip6-table %d", &next_hop_table_id))
9164 next_hop_proto = DPO_PROTO_IP6;
9168 (i, "via l2-input-on %U", api_unformat_sw_if_index, vam,
9172 next_hop_proto = DPO_PROTO_ETHERNET;
9173 is_interface_rx = 1;
9175 else if (unformat (i, "via l2-input-on sw_if_index %d", &sw_if_index))
9178 next_hop_proto = DPO_PROTO_ETHERNET;
9179 is_interface_rx = 1;
9181 else if (unformat (i, "via next-hop-table %d", &next_hop_table_id))
9183 else if (unformat (i, "via via-label %d", &next_hop_via_label))
9185 else if (unformat (i, "out-label %d", &next_hop_out_label))
9187 vl_api_fib_mpls_label_t fib_label = {
9188 .label = ntohl (next_hop_out_label),
9192 vec_add1 (next_hop_out_label_stack, fib_label);
9196 clib_warning ("parse error '%U'", format_unformat_error, i);
9201 if (!next_hop_set && !is_classify)
9203 errmsg ("next hop / classify not set");
9207 if (MPLS_LABEL_INVALID == local_label)
9209 errmsg ("missing label");
9215 /* Turn on async mode */
9216 vam->async_mode = 1;
9217 vam->async_errors = 0;
9218 before = vat_time_now (vam);
9221 for (j = 0; j < count; j++)
9223 /* Construct the API message */
9224 M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_mpls_label_t) *
9225 vec_len (next_hop_out_label_stack));
9227 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
9228 mp->mr_table_id = ntohl (table_id);
9230 mp->mr_is_add = is_add;
9231 mp->mr_next_hop_proto = next_hop_proto;
9232 mp->mr_is_classify = is_classify;
9233 mp->mr_is_multipath = is_multipath;
9234 mp->mr_is_resolve_host = resolve_host;
9235 mp->mr_is_resolve_attached = resolve_attached;
9236 mp->mr_is_interface_rx = is_interface_rx;
9237 mp->mr_next_hop_weight = next_hop_weight;
9238 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
9239 mp->mr_classify_table_index = ntohl (classify_table_index);
9240 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
9241 mp->mr_label = ntohl (local_label);
9242 mp->mr_eos = is_eos;
9244 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
9245 if (0 != mp->mr_next_hop_n_out_labels)
9247 memcpy (mp->mr_next_hop_out_label_stack,
9248 next_hop_out_label_stack,
9249 vec_len (next_hop_out_label_stack) *
9250 sizeof (vl_api_fib_mpls_label_t));
9251 vec_free (next_hop_out_label_stack);
9256 if (DPO_PROTO_IP4 == next_hop_proto)
9258 clib_memcpy (mp->mr_next_hop,
9259 &v4_next_hop_address,
9260 sizeof (v4_next_hop_address));
9262 else if (DPO_PROTO_IP6 == next_hop_proto)
9265 clib_memcpy (mp->mr_next_hop,
9266 &v6_next_hop_address,
9267 sizeof (v6_next_hop_address));
9274 /* If we receive SIGTERM, stop now... */
9279 /* When testing multiple add/del ops, use a control-ping to sync */
9282 vl_api_control_ping_t *mp_ping;
9286 /* Shut off async mode */
9287 vam->async_mode = 0;
9289 MPING (CONTROL_PING, mp_ping);
9292 timeout = vat_time_now (vam) + 1.0;
9293 while (vat_time_now (vam) < timeout)
9294 if (vam->result_ready == 1)
9299 if (vam->retval == -99)
9302 if (vam->async_errors > 0)
9304 errmsg ("%d asynchronous errors", vam->async_errors);
9307 vam->async_errors = 0;
9308 after = vat_time_now (vam);
9310 /* slim chance, but we might have eaten SIGTERM on the first iteration */
9314 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
9315 count, after - before, count / (after - before));
9321 /* Wait for a reply... */
9326 /* Return the good/bad news */
9327 return (vam->retval);
9331 api_mpls_ip_bind_unbind (vat_main_t * vam)
9333 unformat_input_t *i = vam->input;
9334 vl_api_mpls_ip_bind_unbind_t *mp;
9335 u32 ip_table_id = 0;
9338 ip4_address_t v4_address;
9339 ip6_address_t v6_address;
9342 mpls_label_t local_label = MPLS_LABEL_INVALID;
9345 /* Parse args required to build the message */
9346 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9348 if (unformat (i, "%U/%d", unformat_ip4_address,
9349 &v4_address, &address_length))
9354 else if (unformat (i, "%U/%d", unformat_ip6_address,
9355 &v6_address, &address_length))
9360 else if (unformat (i, "%d", &local_label))
9362 else if (unformat (i, "table-id %d", &ip_table_id))
9364 else if (unformat (i, "unbind"))
9366 else if (unformat (i, "bind"))
9370 clib_warning ("parse error '%U'", format_unformat_error, i);
9377 errmsg ("IP address not set");
9381 if (MPLS_LABEL_INVALID == local_label)
9383 errmsg ("missing label");
9387 /* Construct the API message */
9388 M (MPLS_IP_BIND_UNBIND, mp);
9390 mp->mb_is_bind = is_bind;
9391 mp->mb_is_ip4 = is_ip4;
9392 mp->mb_ip_table_id = ntohl (ip_table_id);
9393 mp->mb_mpls_table_id = 0;
9394 mp->mb_label = ntohl (local_label);
9395 mp->mb_address_length = address_length;
9398 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
9400 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
9405 /* Wait for a reply... */
9411 api_sr_mpls_policy_add (vat_main_t * vam)
9413 unformat_input_t *i = vam->input;
9414 vl_api_sr_mpls_policy_add_t *mp;
9420 u32 *segments = NULL;
9423 /* Parse args required to build the message */
9424 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9426 if (unformat (i, "bsid %d", &bsid))
9428 else if (unformat (i, "weight %d", &weight))
9430 else if (unformat (i, "spray"))
9432 else if (unformat (i, "next %d", &sid))
9435 vec_add1 (segments, htonl (sid));
9439 clib_warning ("parse error '%U'", format_unformat_error, i);
9446 errmsg ("bsid not set");
9450 if (n_segments == 0)
9452 errmsg ("no sid in segment stack");
9456 /* Construct the API message */
9457 M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
9459 mp->bsid = htonl (bsid);
9460 mp->weight = htonl (weight);
9462 mp->n_segments = n_segments;
9463 memcpy (mp->segments, segments, sizeof (u32) * n_segments);
9464 vec_free (segments);
9469 /* Wait for a reply... */
9475 api_sr_mpls_policy_del (vat_main_t * vam)
9477 unformat_input_t *i = vam->input;
9478 vl_api_sr_mpls_policy_del_t *mp;
9482 /* Parse args required to build the message */
9483 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9485 if (unformat (i, "bsid %d", &bsid))
9489 clib_warning ("parse error '%U'", format_unformat_error, i);
9496 errmsg ("bsid not set");
9500 /* Construct the API message */
9501 M (SR_MPLS_POLICY_DEL, mp);
9503 mp->bsid = htonl (bsid);
9508 /* Wait for a reply... */
9514 api_bier_table_add_del (vat_main_t * vam)
9516 unformat_input_t *i = vam->input;
9517 vl_api_bier_table_add_del_t *mp;
9519 u32 set = 0, sub_domain = 0, hdr_len = 3;
9520 mpls_label_t local_label = MPLS_LABEL_INVALID;
9523 /* Parse args required to build the message */
9524 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9526 if (unformat (i, "sub-domain %d", &sub_domain))
9528 else if (unformat (i, "set %d", &set))
9530 else if (unformat (i, "label %d", &local_label))
9532 else if (unformat (i, "hdr-len %d", &hdr_len))
9534 else if (unformat (i, "add"))
9536 else if (unformat (i, "del"))
9540 clib_warning ("parse error '%U'", format_unformat_error, i);
9545 if (MPLS_LABEL_INVALID == local_label)
9547 errmsg ("missing label\n");
9551 /* Construct the API message */
9552 M (BIER_TABLE_ADD_DEL, mp);
9554 mp->bt_is_add = is_add;
9555 mp->bt_label = ntohl (local_label);
9556 mp->bt_tbl_id.bt_set = set;
9557 mp->bt_tbl_id.bt_sub_domain = sub_domain;
9558 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
9563 /* Wait for a reply... */
9570 api_bier_route_add_del (vat_main_t * vam)
9572 unformat_input_t *i = vam->input;
9573 vl_api_bier_route_add_del_t *mp;
9575 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
9576 ip4_address_t v4_next_hop_address;
9577 ip6_address_t v6_next_hop_address;
9578 u8 next_hop_set = 0;
9579 u8 next_hop_proto_is_ip4 = 1;
9580 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9583 /* Parse args required to build the message */
9584 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9586 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
9588 next_hop_proto_is_ip4 = 1;
9591 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
9593 next_hop_proto_is_ip4 = 0;
9596 if (unformat (i, "sub-domain %d", &sub_domain))
9598 else if (unformat (i, "set %d", &set))
9600 else if (unformat (i, "hdr-len %d", &hdr_len))
9602 else if (unformat (i, "bp %d", &bp))
9604 else if (unformat (i, "add"))
9606 else if (unformat (i, "del"))
9608 else if (unformat (i, "out-label %d", &next_hop_out_label))
9612 clib_warning ("parse error '%U'", format_unformat_error, i);
9617 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
9619 errmsg ("next hop / label set\n");
9624 errmsg ("bit=position not set\n");
9628 /* Construct the API message */
9629 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
9631 mp->br_is_add = is_add;
9632 mp->br_tbl_id.bt_set = set;
9633 mp->br_tbl_id.bt_sub_domain = sub_domain;
9634 mp->br_tbl_id.bt_hdr_len_id = hdr_len;
9635 mp->br_bp = ntohs (bp);
9637 mp->br_paths[0].n_labels = 1;
9638 mp->br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
9639 mp->br_paths[0].afi = (next_hop_proto_is_ip4 ? 0 : 1);
9641 if (next_hop_proto_is_ip4)
9643 clib_memcpy (mp->br_paths[0].next_hop,
9644 &v4_next_hop_address, sizeof (v4_next_hop_address));
9648 clib_memcpy (mp->br_paths[0].next_hop,
9649 &v6_next_hop_address, sizeof (v6_next_hop_address));
9655 /* Wait for a reply... */
9662 api_proxy_arp_add_del (vat_main_t * vam)
9664 unformat_input_t *i = vam->input;
9665 vl_api_proxy_arp_add_del_t *mp;
9668 ip4_address_t lo, hi;
9672 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9674 if (unformat (i, "vrf %d", &vrf_id))
9676 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
9677 unformat_ip4_address, &hi))
9679 else if (unformat (i, "del"))
9683 clib_warning ("parse error '%U'", format_unformat_error, i);
9690 errmsg ("address range not set");
9694 M (PROXY_ARP_ADD_DEL, mp);
9696 mp->proxy.vrf_id = ntohl (vrf_id);
9697 mp->is_add = is_add;
9698 clib_memcpy (mp->proxy.low_address, &lo, sizeof (mp->proxy.low_address));
9699 clib_memcpy (mp->proxy.hi_address, &hi, sizeof (mp->proxy.hi_address));
9707 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
9709 unformat_input_t *i = vam->input;
9710 vl_api_proxy_arp_intfc_enable_disable_t *mp;
9713 u8 sw_if_index_set = 0;
9716 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9718 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9719 sw_if_index_set = 1;
9720 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9721 sw_if_index_set = 1;
9722 else if (unformat (i, "enable"))
9724 else if (unformat (i, "disable"))
9728 clib_warning ("parse error '%U'", format_unformat_error, i);
9733 if (sw_if_index_set == 0)
9735 errmsg ("missing interface name or sw_if_index");
9739 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
9741 mp->sw_if_index = ntohl (sw_if_index);
9742 mp->enable_disable = enable;
9750 api_mpls_tunnel_add_del (vat_main_t * vam)
9752 unformat_input_t *i = vam->input;
9753 vl_api_mpls_tunnel_add_del_t *mp;
9757 u32 sw_if_index = ~0;
9758 u32 next_hop_sw_if_index = ~0;
9759 u32 next_hop_proto_is_ip4 = 1;
9761 u32 next_hop_table_id = 0;
9762 ip4_address_t v4_next_hop_address = {
9765 ip6_address_t v6_next_hop_address = { {0} };
9766 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
9767 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
9770 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9772 if (unformat (i, "add"))
9774 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
9776 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
9778 else if (unformat (i, "via %U",
9779 unformat_ip4_address, &v4_next_hop_address))
9781 next_hop_proto_is_ip4 = 1;
9783 else if (unformat (i, "via %U",
9784 unformat_ip6_address, &v6_next_hop_address))
9786 next_hop_proto_is_ip4 = 0;
9788 else if (unformat (i, "via-label %d", &next_hop_via_label))
9790 else if (unformat (i, "l2-only"))
9792 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
9794 else if (unformat (i, "out-label %d", &next_hop_out_label))
9795 vec_add1 (labels, ntohl (next_hop_out_label));
9798 clib_warning ("parse error '%U'", format_unformat_error, i);
9803 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
9805 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
9806 mp->mt_sw_if_index = ntohl (sw_if_index);
9807 mp->mt_is_add = is_add;
9808 mp->mt_l2_only = l2_only;
9809 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
9810 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
9811 mp->mt_next_hop_via_label = ntohl (next_hop_via_label);
9813 mp->mt_next_hop_n_out_labels = vec_len (labels);
9815 if (0 != mp->mt_next_hop_n_out_labels)
9817 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
9818 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
9822 if (next_hop_proto_is_ip4)
9824 clib_memcpy (mp->mt_next_hop,
9825 &v4_next_hop_address, sizeof (v4_next_hop_address));
9829 clib_memcpy (mp->mt_next_hop,
9830 &v6_next_hop_address, sizeof (v6_next_hop_address));
9839 api_sw_interface_set_unnumbered (vat_main_t * vam)
9841 unformat_input_t *i = vam->input;
9842 vl_api_sw_interface_set_unnumbered_t *mp;
9844 u32 unnum_sw_index = ~0;
9846 u8 sw_if_index_set = 0;
9849 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9851 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9852 sw_if_index_set = 1;
9853 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9854 sw_if_index_set = 1;
9855 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
9857 else if (unformat (i, "del"))
9861 clib_warning ("parse error '%U'", format_unformat_error, i);
9866 if (sw_if_index_set == 0)
9868 errmsg ("missing interface name or sw_if_index");
9872 M (SW_INTERFACE_SET_UNNUMBERED, mp);
9874 mp->sw_if_index = ntohl (sw_if_index);
9875 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
9876 mp->is_add = is_add;
9884 api_ip_neighbor_add_del (vat_main_t * vam)
9886 unformat_input_t *i = vam->input;
9887 vl_api_ip_neighbor_add_del_t *mp;
9889 u8 sw_if_index_set = 0;
9892 u8 is_no_fib_entry = 0;
9895 u8 v4_address_set = 0;
9896 u8 v6_address_set = 0;
9897 ip4_address_t v4address;
9898 ip6_address_t v6address;
9901 memset (mac_address, 0, sizeof (mac_address));
9903 /* Parse args required to build the message */
9904 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9906 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
9910 else if (unformat (i, "del"))
9913 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9914 sw_if_index_set = 1;
9915 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9916 sw_if_index_set = 1;
9917 else if (unformat (i, "is_static"))
9919 else if (unformat (i, "no-fib-entry"))
9920 is_no_fib_entry = 1;
9921 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
9923 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
9927 clib_warning ("parse error '%U'", format_unformat_error, i);
9932 if (sw_if_index_set == 0)
9934 errmsg ("missing interface name or sw_if_index");
9937 if (v4_address_set && v6_address_set)
9939 errmsg ("both v4 and v6 addresses set");
9942 if (!v4_address_set && !v6_address_set)
9944 errmsg ("no address set");
9948 /* Construct the API message */
9949 M (IP_NEIGHBOR_ADD_DEL, mp);
9951 mp->sw_if_index = ntohl (sw_if_index);
9952 mp->is_add = is_add;
9953 mp->is_static = is_static;
9954 mp->is_no_adj_fib = is_no_fib_entry;
9956 clib_memcpy (mp->mac_address, mac_address, 6);
9960 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
9964 /* mp->is_ipv6 = 0; via memset in M macro above */
9965 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
9971 /* Wait for a reply, return good/bad news */
9977 api_create_vlan_subif (vat_main_t * vam)
9979 unformat_input_t *i = vam->input;
9980 vl_api_create_vlan_subif_t *mp;
9982 u8 sw_if_index_set = 0;
9987 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9989 if (unformat (i, "sw_if_index %d", &sw_if_index))
9990 sw_if_index_set = 1;
9992 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9993 sw_if_index_set = 1;
9994 else if (unformat (i, "vlan %d", &vlan_id))
9998 clib_warning ("parse error '%U'", format_unformat_error, i);
10003 if (sw_if_index_set == 0)
10005 errmsg ("missing interface name or sw_if_index");
10009 if (vlan_id_set == 0)
10011 errmsg ("missing vlan_id");
10014 M (CREATE_VLAN_SUBIF, mp);
10016 mp->sw_if_index = ntohl (sw_if_index);
10017 mp->vlan_id = ntohl (vlan_id);
10024 #define foreach_create_subif_bit \
10031 _(outer_vlan_id_any) \
10032 _(inner_vlan_id_any)
10035 api_create_subif (vat_main_t * vam)
10037 unformat_input_t *i = vam->input;
10038 vl_api_create_subif_t *mp;
10040 u8 sw_if_index_set = 0;
10047 u32 exact_match = 0;
10048 u32 default_sub = 0;
10049 u32 outer_vlan_id_any = 0;
10050 u32 inner_vlan_id_any = 0;
10052 u16 outer_vlan_id = 0;
10053 u16 inner_vlan_id = 0;
10056 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10058 if (unformat (i, "sw_if_index %d", &sw_if_index))
10059 sw_if_index_set = 1;
10061 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10062 sw_if_index_set = 1;
10063 else if (unformat (i, "sub_id %d", &sub_id))
10065 else if (unformat (i, "outer_vlan_id %d", &tmp))
10066 outer_vlan_id = tmp;
10067 else if (unformat (i, "inner_vlan_id %d", &tmp))
10068 inner_vlan_id = tmp;
10070 #define _(a) else if (unformat (i, #a)) a = 1 ;
10071 foreach_create_subif_bit
10075 clib_warning ("parse error '%U'", format_unformat_error, i);
10080 if (sw_if_index_set == 0)
10082 errmsg ("missing interface name or sw_if_index");
10086 if (sub_id_set == 0)
10088 errmsg ("missing sub_id");
10091 M (CREATE_SUBIF, mp);
10093 mp->sw_if_index = ntohl (sw_if_index);
10094 mp->sub_id = ntohl (sub_id);
10096 #define _(a) mp->a = a;
10097 foreach_create_subif_bit;
10100 mp->outer_vlan_id = ntohs (outer_vlan_id);
10101 mp->inner_vlan_id = ntohs (inner_vlan_id);
10109 api_oam_add_del (vat_main_t * vam)
10111 unformat_input_t *i = vam->input;
10112 vl_api_oam_add_del_t *mp;
10115 ip4_address_t src, dst;
10120 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10122 if (unformat (i, "vrf %d", &vrf_id))
10124 else if (unformat (i, "src %U", unformat_ip4_address, &src))
10126 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
10128 else if (unformat (i, "del"))
10132 clib_warning ("parse error '%U'", format_unformat_error, i);
10139 errmsg ("missing src addr");
10145 errmsg ("missing dst addr");
10149 M (OAM_ADD_DEL, mp);
10151 mp->vrf_id = ntohl (vrf_id);
10152 mp->is_add = is_add;
10153 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
10154 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
10162 api_reset_fib (vat_main_t * vam)
10164 unformat_input_t *i = vam->input;
10165 vl_api_reset_fib_t *mp;
10171 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10173 if (unformat (i, "vrf %d", &vrf_id))
10175 else if (unformat (i, "ipv6"))
10179 clib_warning ("parse error '%U'", format_unformat_error, i);
10184 if (vrf_id_set == 0)
10186 errmsg ("missing vrf id");
10192 mp->vrf_id = ntohl (vrf_id);
10193 mp->is_ipv6 = is_ipv6;
10201 api_dhcp_proxy_config (vat_main_t * vam)
10203 unformat_input_t *i = vam->input;
10204 vl_api_dhcp_proxy_config_t *mp;
10206 u32 server_vrf_id = 0;
10208 u8 v4_address_set = 0;
10209 u8 v6_address_set = 0;
10210 ip4_address_t v4address;
10211 ip6_address_t v6address;
10212 u8 v4_src_address_set = 0;
10213 u8 v6_src_address_set = 0;
10214 ip4_address_t v4srcaddress;
10215 ip6_address_t v6srcaddress;
10218 /* Parse args required to build the message */
10219 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10221 if (unformat (i, "del"))
10223 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
10225 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
10227 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
10228 v4_address_set = 1;
10229 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
10230 v6_address_set = 1;
10231 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
10232 v4_src_address_set = 1;
10233 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
10234 v6_src_address_set = 1;
10239 if (v4_address_set && v6_address_set)
10241 errmsg ("both v4 and v6 server addresses set");
10244 if (!v4_address_set && !v6_address_set)
10246 errmsg ("no server addresses set");
10250 if (v4_src_address_set && v6_src_address_set)
10252 errmsg ("both v4 and v6 src addresses set");
10255 if (!v4_src_address_set && !v6_src_address_set)
10257 errmsg ("no src addresses set");
10261 if (!(v4_src_address_set && v4_address_set) &&
10262 !(v6_src_address_set && v6_address_set))
10264 errmsg ("no matching server and src addresses set");
10268 /* Construct the API message */
10269 M (DHCP_PROXY_CONFIG, mp);
10271 mp->is_add = is_add;
10272 mp->rx_vrf_id = ntohl (rx_vrf_id);
10273 mp->server_vrf_id = ntohl (server_vrf_id);
10274 if (v6_address_set)
10277 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
10278 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
10282 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
10283 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
10289 /* Wait for a reply, return good/bad news */
10294 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
10295 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
10298 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
10300 vat_main_t *vam = &vat_main;
10301 u32 i, count = mp->count;
10302 vl_api_dhcp_server_t *s;
10306 "RX Table-ID %d, Source Address %U, VSS Type %d, "
10307 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
10308 ntohl (mp->rx_vrf_id),
10309 format_ip6_address, mp->dhcp_src_address,
10310 mp->vss_type, mp->vss_vpn_ascii_id,
10311 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
10314 "RX Table-ID %d, Source Address %U, VSS Type %d, "
10315 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
10316 ntohl (mp->rx_vrf_id),
10317 format_ip4_address, mp->dhcp_src_address,
10318 mp->vss_type, mp->vss_vpn_ascii_id,
10319 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
10321 for (i = 0; i < count; i++)
10323 s = &mp->servers[i];
10327 " Server Table-ID %d, Server Address %U",
10328 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
10331 " Server Table-ID %d, Server Address %U",
10332 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
10336 static void vl_api_dhcp_proxy_details_t_handler_json
10337 (vl_api_dhcp_proxy_details_t * mp)
10339 vat_main_t *vam = &vat_main;
10340 vat_json_node_t *node = NULL;
10341 u32 i, count = mp->count;
10342 struct in_addr ip4;
10343 struct in6_addr ip6;
10344 vl_api_dhcp_server_t *s;
10346 if (VAT_JSON_ARRAY != vam->json_tree.type)
10348 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10349 vat_json_init_array (&vam->json_tree);
10351 node = vat_json_array_add (&vam->json_tree);
10353 vat_json_init_object (node);
10354 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
10355 vat_json_object_add_bytes (node, "vss-type", &mp->vss_type,
10356 sizeof (mp->vss_type));
10357 vat_json_object_add_string_copy (node, "vss-vpn-ascii-id",
10358 mp->vss_vpn_ascii_id);
10359 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
10360 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
10364 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
10365 vat_json_object_add_ip6 (node, "src_address", ip6);
10369 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
10370 vat_json_object_add_ip4 (node, "src_address", ip4);
10373 for (i = 0; i < count; i++)
10375 s = &mp->servers[i];
10377 vat_json_object_add_uint (node, "server-table-id",
10378 ntohl (s->server_vrf_id));
10382 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
10383 vat_json_object_add_ip4 (node, "src_address", ip4);
10387 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
10388 vat_json_object_add_ip6 (node, "server_address", ip6);
10394 api_dhcp_proxy_dump (vat_main_t * vam)
10396 unformat_input_t *i = vam->input;
10397 vl_api_control_ping_t *mp_ping;
10398 vl_api_dhcp_proxy_dump_t *mp;
10402 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10404 if (unformat (i, "ipv6"))
10408 clib_warning ("parse error '%U'", format_unformat_error, i);
10413 M (DHCP_PROXY_DUMP, mp);
10415 mp->is_ip6 = is_ipv6;
10418 /* Use a control ping for synchronization */
10419 MPING (CONTROL_PING, mp_ping);
10427 api_dhcp_proxy_set_vss (vat_main_t * vam)
10429 unformat_input_t *i = vam->input;
10430 vl_api_dhcp_proxy_set_vss_t *mp;
10434 u8 vss_type = VSS_TYPE_DEFAULT;
10435 u8 *vpn_ascii_id = 0;
10440 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10442 if (unformat (i, "tbl_id %d", &tbl_id))
10444 else if (unformat (i, "vpn_ascii_id %s", &vpn_ascii_id))
10445 vss_type = VSS_TYPE_ASCII;
10446 else if (unformat (i, "fib_id %d", &fib_id))
10447 vss_type = VSS_TYPE_VPN_ID;
10448 else if (unformat (i, "oui %d", &oui))
10449 vss_type = VSS_TYPE_VPN_ID;
10450 else if (unformat (i, "ipv6"))
10452 else if (unformat (i, "del"))
10460 errmsg ("missing tbl_id ");
10461 vec_free (vpn_ascii_id);
10465 if ((vpn_ascii_id) && (vec_len (vpn_ascii_id) > 128))
10467 errmsg ("vpn_ascii_id cannot be longer than 128 ");
10468 vec_free (vpn_ascii_id);
10472 M (DHCP_PROXY_SET_VSS, mp);
10473 mp->tbl_id = ntohl (tbl_id);
10474 mp->vss_type = vss_type;
10477 clib_memcpy (mp->vpn_ascii_id, vpn_ascii_id, vec_len (vpn_ascii_id));
10478 mp->vpn_ascii_id[vec_len (vpn_ascii_id)] = 0;
10480 mp->vpn_index = ntohl (fib_id);
10481 mp->oui = ntohl (oui);
10482 mp->is_ipv6 = is_ipv6;
10483 mp->is_add = is_add;
10488 vec_free (vpn_ascii_id);
10493 api_dhcp_client_config (vat_main_t * vam)
10495 unformat_input_t *i = vam->input;
10496 vl_api_dhcp_client_config_t *mp;
10498 u8 sw_if_index_set = 0;
10501 u8 disable_event = 0;
10504 /* Parse args required to build the message */
10505 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10507 if (unformat (i, "del"))
10510 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10511 sw_if_index_set = 1;
10512 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10513 sw_if_index_set = 1;
10514 else if (unformat (i, "hostname %s", &hostname))
10516 else if (unformat (i, "disable_event"))
10522 if (sw_if_index_set == 0)
10524 errmsg ("missing interface name or sw_if_index");
10528 if (vec_len (hostname) > 63)
10530 errmsg ("hostname too long");
10532 vec_add1 (hostname, 0);
10534 /* Construct the API message */
10535 M (DHCP_CLIENT_CONFIG, mp);
10537 mp->is_add = is_add;
10538 mp->client.sw_if_index = htonl (sw_if_index);
10539 clib_memcpy (mp->client.hostname, hostname, vec_len (hostname));
10540 vec_free (hostname);
10541 mp->client.want_dhcp_event = disable_event ? 0 : 1;
10542 mp->client.pid = htonl (getpid ());
10547 /* Wait for a reply, return good/bad news */
10553 api_set_ip_flow_hash (vat_main_t * vam)
10555 unformat_input_t *i = vam->input;
10556 vl_api_set_ip_flow_hash_t *mp;
10568 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10570 if (unformat (i, "vrf %d", &vrf_id))
10572 else if (unformat (i, "ipv6"))
10574 else if (unformat (i, "src"))
10576 else if (unformat (i, "dst"))
10578 else if (unformat (i, "sport"))
10580 else if (unformat (i, "dport"))
10582 else if (unformat (i, "proto"))
10584 else if (unformat (i, "reverse"))
10589 clib_warning ("parse error '%U'", format_unformat_error, i);
10594 if (vrf_id_set == 0)
10596 errmsg ("missing vrf id");
10600 M (SET_IP_FLOW_HASH, mp);
10606 mp->reverse = reverse;
10607 mp->vrf_id = ntohl (vrf_id);
10608 mp->is_ipv6 = is_ipv6;
10616 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
10618 unformat_input_t *i = vam->input;
10619 vl_api_sw_interface_ip6_enable_disable_t *mp;
10621 u8 sw_if_index_set = 0;
10625 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10627 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10628 sw_if_index_set = 1;
10629 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10630 sw_if_index_set = 1;
10631 else if (unformat (i, "enable"))
10633 else if (unformat (i, "disable"))
10637 clib_warning ("parse error '%U'", format_unformat_error, i);
10642 if (sw_if_index_set == 0)
10644 errmsg ("missing interface name or sw_if_index");
10648 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
10650 mp->sw_if_index = ntohl (sw_if_index);
10651 mp->enable = enable;
10659 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
10661 unformat_input_t *i = vam->input;
10662 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
10664 u8 sw_if_index_set = 0;
10665 u8 v6_address_set = 0;
10666 ip6_address_t v6address;
10669 /* Parse args required to build the message */
10670 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10672 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10673 sw_if_index_set = 1;
10674 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10675 sw_if_index_set = 1;
10676 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10677 v6_address_set = 1;
10682 if (sw_if_index_set == 0)
10684 errmsg ("missing interface name or sw_if_index");
10687 if (!v6_address_set)
10689 errmsg ("no address set");
10693 /* Construct the API message */
10694 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
10696 mp->sw_if_index = ntohl (sw_if_index);
10697 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10702 /* Wait for a reply, return good/bad news */
10708 api_ip6nd_proxy_add_del (vat_main_t * vam)
10710 unformat_input_t *i = vam->input;
10711 vl_api_ip6nd_proxy_add_del_t *mp;
10712 u32 sw_if_index = ~0;
10713 u8 v6_address_set = 0;
10714 ip6_address_t v6address;
10718 /* Parse args required to build the message */
10719 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10721 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10723 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10725 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10726 v6_address_set = 1;
10727 if (unformat (i, "del"))
10731 clib_warning ("parse error '%U'", format_unformat_error, i);
10736 if (sw_if_index == ~0)
10738 errmsg ("missing interface name or sw_if_index");
10741 if (!v6_address_set)
10743 errmsg ("no address set");
10747 /* Construct the API message */
10748 M (IP6ND_PROXY_ADD_DEL, mp);
10750 mp->is_del = is_del;
10751 mp->sw_if_index = ntohl (sw_if_index);
10752 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10757 /* Wait for a reply, return good/bad news */
10763 api_ip6nd_proxy_dump (vat_main_t * vam)
10765 vl_api_ip6nd_proxy_dump_t *mp;
10766 vl_api_control_ping_t *mp_ping;
10769 M (IP6ND_PROXY_DUMP, mp);
10773 /* Use a control ping for synchronization */
10774 MPING (CONTROL_PING, mp_ping);
10781 static void vl_api_ip6nd_proxy_details_t_handler
10782 (vl_api_ip6nd_proxy_details_t * mp)
10784 vat_main_t *vam = &vat_main;
10786 print (vam->ofp, "host %U sw_if_index %d",
10787 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
10790 static void vl_api_ip6nd_proxy_details_t_handler_json
10791 (vl_api_ip6nd_proxy_details_t * mp)
10793 vat_main_t *vam = &vat_main;
10794 struct in6_addr ip6;
10795 vat_json_node_t *node = NULL;
10797 if (VAT_JSON_ARRAY != vam->json_tree.type)
10799 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10800 vat_json_init_array (&vam->json_tree);
10802 node = vat_json_array_add (&vam->json_tree);
10804 vat_json_init_object (node);
10805 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10807 clib_memcpy (&ip6, mp->address, sizeof (ip6));
10808 vat_json_object_add_ip6 (node, "host", ip6);
10812 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
10814 unformat_input_t *i = vam->input;
10815 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
10817 u8 sw_if_index_set = 0;
10818 u32 address_length = 0;
10819 u8 v6_address_set = 0;
10820 ip6_address_t v6address;
10821 u8 use_default = 0;
10822 u8 no_advertise = 0;
10824 u8 no_autoconfig = 0;
10827 u32 val_lifetime = 0;
10828 u32 pref_lifetime = 0;
10831 /* Parse args required to build the message */
10832 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10834 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10835 sw_if_index_set = 1;
10836 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10837 sw_if_index_set = 1;
10838 else if (unformat (i, "%U/%d",
10839 unformat_ip6_address, &v6address, &address_length))
10840 v6_address_set = 1;
10841 else if (unformat (i, "val_life %d", &val_lifetime))
10843 else if (unformat (i, "pref_life %d", &pref_lifetime))
10845 else if (unformat (i, "def"))
10847 else if (unformat (i, "noadv"))
10849 else if (unformat (i, "offl"))
10851 else if (unformat (i, "noauto"))
10853 else if (unformat (i, "nolink"))
10855 else if (unformat (i, "isno"))
10859 clib_warning ("parse error '%U'", format_unformat_error, i);
10864 if (sw_if_index_set == 0)
10866 errmsg ("missing interface name or sw_if_index");
10869 if (!v6_address_set)
10871 errmsg ("no address set");
10875 /* Construct the API message */
10876 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
10878 mp->sw_if_index = ntohl (sw_if_index);
10879 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10880 mp->address_length = address_length;
10881 mp->use_default = use_default;
10882 mp->no_advertise = no_advertise;
10883 mp->off_link = off_link;
10884 mp->no_autoconfig = no_autoconfig;
10885 mp->no_onlink = no_onlink;
10887 mp->val_lifetime = ntohl (val_lifetime);
10888 mp->pref_lifetime = ntohl (pref_lifetime);
10893 /* Wait for a reply, return good/bad news */
10899 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
10901 unformat_input_t *i = vam->input;
10902 vl_api_sw_interface_ip6nd_ra_config_t *mp;
10904 u8 sw_if_index_set = 0;
10909 u8 send_unicast = 0;
10912 u8 default_router = 0;
10913 u32 max_interval = 0;
10914 u32 min_interval = 0;
10916 u32 initial_count = 0;
10917 u32 initial_interval = 0;
10921 /* Parse args required to build the message */
10922 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10924 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10925 sw_if_index_set = 1;
10926 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10927 sw_if_index_set = 1;
10928 else if (unformat (i, "maxint %d", &max_interval))
10930 else if (unformat (i, "minint %d", &min_interval))
10932 else if (unformat (i, "life %d", &lifetime))
10934 else if (unformat (i, "count %d", &initial_count))
10936 else if (unformat (i, "interval %d", &initial_interval))
10938 else if (unformat (i, "suppress") || unformat (i, "surpress"))
10940 else if (unformat (i, "managed"))
10942 else if (unformat (i, "other"))
10944 else if (unformat (i, "ll"))
10946 else if (unformat (i, "send"))
10948 else if (unformat (i, "cease"))
10950 else if (unformat (i, "isno"))
10952 else if (unformat (i, "def"))
10953 default_router = 1;
10956 clib_warning ("parse error '%U'", format_unformat_error, i);
10961 if (sw_if_index_set == 0)
10963 errmsg ("missing interface name or sw_if_index");
10967 /* Construct the API message */
10968 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
10970 mp->sw_if_index = ntohl (sw_if_index);
10971 mp->max_interval = ntohl (max_interval);
10972 mp->min_interval = ntohl (min_interval);
10973 mp->lifetime = ntohl (lifetime);
10974 mp->initial_count = ntohl (initial_count);
10975 mp->initial_interval = ntohl (initial_interval);
10976 mp->suppress = suppress;
10977 mp->managed = managed;
10979 mp->ll_option = ll_option;
10980 mp->send_unicast = send_unicast;
10983 mp->default_router = default_router;
10988 /* Wait for a reply, return good/bad news */
10994 api_set_arp_neighbor_limit (vat_main_t * vam)
10996 unformat_input_t *i = vam->input;
10997 vl_api_set_arp_neighbor_limit_t *mp;
11003 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11005 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
11007 else if (unformat (i, "ipv6"))
11011 clib_warning ("parse error '%U'", format_unformat_error, i);
11016 if (limit_set == 0)
11018 errmsg ("missing limit value");
11022 M (SET_ARP_NEIGHBOR_LIMIT, mp);
11024 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
11025 mp->is_ipv6 = is_ipv6;
11033 api_l2_patch_add_del (vat_main_t * vam)
11035 unformat_input_t *i = vam->input;
11036 vl_api_l2_patch_add_del_t *mp;
11037 u32 rx_sw_if_index;
11038 u8 rx_sw_if_index_set = 0;
11039 u32 tx_sw_if_index;
11040 u8 tx_sw_if_index_set = 0;
11044 /* Parse args required to build the message */
11045 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11047 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
11048 rx_sw_if_index_set = 1;
11049 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
11050 tx_sw_if_index_set = 1;
11051 else if (unformat (i, "rx"))
11053 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11055 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
11057 rx_sw_if_index_set = 1;
11062 else if (unformat (i, "tx"))
11064 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11066 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
11068 tx_sw_if_index_set = 1;
11073 else if (unformat (i, "del"))
11079 if (rx_sw_if_index_set == 0)
11081 errmsg ("missing rx interface name or rx_sw_if_index");
11085 if (tx_sw_if_index_set == 0)
11087 errmsg ("missing tx interface name or tx_sw_if_index");
11091 M (L2_PATCH_ADD_DEL, mp);
11093 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
11094 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
11095 mp->is_add = is_add;
11103 u8 localsid_addr[16];
11112 api_sr_localsid_add_del (vat_main_t * vam)
11114 unformat_input_t *i = vam->input;
11115 vl_api_sr_localsid_add_del_t *mp;
11118 ip6_address_t localsid;
11122 u32 fib_table = ~(u32) 0;
11123 ip6_address_t nh_addr6;
11124 ip4_address_t nh_addr4;
11125 memset (&nh_addr6, 0, sizeof (ip6_address_t));
11126 memset (&nh_addr4, 0, sizeof (ip4_address_t));
11128 bool nexthop_set = 0;
11132 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11134 if (unformat (i, "del"))
11136 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
11137 else if (unformat (i, "next-hop %U", unformat_ip4_address, &nh_addr4))
11139 else if (unformat (i, "next-hop %U", unformat_ip6_address, &nh_addr6))
11141 else if (unformat (i, "behavior %u", &behavior));
11142 else if (unformat (i, "sw_if_index %u", &sw_if_index));
11143 else if (unformat (i, "fib-table %u", &fib_table));
11144 else if (unformat (i, "end.psp %u", &behavior));
11149 M (SR_LOCALSID_ADD_DEL, mp);
11151 clib_memcpy (mp->localsid.addr, &localsid, sizeof (mp->localsid));
11154 clib_memcpy (mp->nh_addr6, &nh_addr6, sizeof (mp->nh_addr6));
11155 clib_memcpy (mp->nh_addr4, &nh_addr4, sizeof (mp->nh_addr4));
11157 mp->behavior = behavior;
11158 mp->sw_if_index = ntohl (sw_if_index);
11159 mp->fib_table = ntohl (fib_table);
11160 mp->end_psp = end_psp;
11161 mp->is_del = is_del;
11169 api_ioam_enable (vat_main_t * vam)
11171 unformat_input_t *input = vam->input;
11172 vl_api_ioam_enable_t *mp;
11174 int has_trace_option = 0;
11175 int has_pot_option = 0;
11176 int has_seqno_option = 0;
11177 int has_analyse_option = 0;
11180 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11182 if (unformat (input, "trace"))
11183 has_trace_option = 1;
11184 else if (unformat (input, "pot"))
11185 has_pot_option = 1;
11186 else if (unformat (input, "seqno"))
11187 has_seqno_option = 1;
11188 else if (unformat (input, "analyse"))
11189 has_analyse_option = 1;
11193 M (IOAM_ENABLE, mp);
11194 mp->id = htons (id);
11195 mp->seqno = has_seqno_option;
11196 mp->analyse = has_analyse_option;
11197 mp->pot_enable = has_pot_option;
11198 mp->trace_enable = has_trace_option;
11207 api_ioam_disable (vat_main_t * vam)
11209 vl_api_ioam_disable_t *mp;
11212 M (IOAM_DISABLE, mp);
11218 #define foreach_tcp_proto_field \
11222 #define foreach_udp_proto_field \
11226 #define foreach_ip4_proto_field \
11238 u16 src_port, dst_port;
11241 #if VPP_API_TEST_BUILTIN == 0
11243 unformat_tcp_mask (unformat_input_t * input, va_list * args)
11245 u8 **maskp = va_arg (*args, u8 **);
11247 u8 found_something = 0;
11250 #define _(a) u8 a=0;
11251 foreach_tcp_proto_field;
11254 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11257 #define _(a) else if (unformat (input, #a)) a=1;
11258 foreach_tcp_proto_field
11264 #define _(a) found_something += a;
11265 foreach_tcp_proto_field;
11268 if (found_something == 0)
11271 vec_validate (mask, sizeof (*tcp) - 1);
11273 tcp = (tcp_header_t *) mask;
11275 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
11276 foreach_tcp_proto_field;
11284 unformat_udp_mask (unformat_input_t * input, va_list * args)
11286 u8 **maskp = va_arg (*args, u8 **);
11288 u8 found_something = 0;
11291 #define _(a) u8 a=0;
11292 foreach_udp_proto_field;
11295 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11298 #define _(a) else if (unformat (input, #a)) a=1;
11299 foreach_udp_proto_field
11305 #define _(a) found_something += a;
11306 foreach_udp_proto_field;
11309 if (found_something == 0)
11312 vec_validate (mask, sizeof (*udp) - 1);
11314 udp = (udp_header_t *) mask;
11316 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
11317 foreach_udp_proto_field;
11325 unformat_l4_mask (unformat_input_t * input, va_list * args)
11327 u8 **maskp = va_arg (*args, u8 **);
11328 u16 src_port = 0, dst_port = 0;
11329 tcpudp_header_t *tcpudp;
11331 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11333 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
11335 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
11337 else if (unformat (input, "src_port"))
11339 else if (unformat (input, "dst_port"))
11345 if (!src_port && !dst_port)
11349 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
11351 tcpudp = (tcpudp_header_t *) mask;
11352 tcpudp->src_port = src_port;
11353 tcpudp->dst_port = dst_port;
11361 unformat_ip4_mask (unformat_input_t * input, va_list * args)
11363 u8 **maskp = va_arg (*args, u8 **);
11365 u8 found_something = 0;
11368 #define _(a) u8 a=0;
11369 foreach_ip4_proto_field;
11375 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11377 if (unformat (input, "version"))
11379 else if (unformat (input, "hdr_length"))
11381 else if (unformat (input, "src"))
11383 else if (unformat (input, "dst"))
11385 else if (unformat (input, "proto"))
11388 #define _(a) else if (unformat (input, #a)) a=1;
11389 foreach_ip4_proto_field
11395 #define _(a) found_something += a;
11396 foreach_ip4_proto_field;
11399 if (found_something == 0)
11402 vec_validate (mask, sizeof (*ip) - 1);
11404 ip = (ip4_header_t *) mask;
11406 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
11407 foreach_ip4_proto_field;
11410 ip->ip_version_and_header_length = 0;
11413 ip->ip_version_and_header_length |= 0xF0;
11416 ip->ip_version_and_header_length |= 0x0F;
11422 #define foreach_ip6_proto_field \
11425 _(payload_length) \
11430 unformat_ip6_mask (unformat_input_t * input, va_list * args)
11432 u8 **maskp = va_arg (*args, u8 **);
11434 u8 found_something = 0;
11436 u32 ip_version_traffic_class_and_flow_label;
11438 #define _(a) u8 a=0;
11439 foreach_ip6_proto_field;
11442 u8 traffic_class = 0;
11445 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11447 if (unformat (input, "version"))
11449 else if (unformat (input, "traffic-class"))
11451 else if (unformat (input, "flow-label"))
11453 else if (unformat (input, "src"))
11455 else if (unformat (input, "dst"))
11457 else if (unformat (input, "proto"))
11460 #define _(a) else if (unformat (input, #a)) a=1;
11461 foreach_ip6_proto_field
11467 #define _(a) found_something += a;
11468 foreach_ip6_proto_field;
11471 if (found_something == 0)
11474 vec_validate (mask, sizeof (*ip) - 1);
11476 ip = (ip6_header_t *) mask;
11478 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
11479 foreach_ip6_proto_field;
11482 ip_version_traffic_class_and_flow_label = 0;
11485 ip_version_traffic_class_and_flow_label |= 0xF0000000;
11488 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
11491 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
11493 ip->ip_version_traffic_class_and_flow_label =
11494 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11501 unformat_l3_mask (unformat_input_t * input, va_list * args)
11503 u8 **maskp = va_arg (*args, u8 **);
11505 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11507 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
11509 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
11518 unformat_l2_mask (unformat_input_t * input, va_list * args)
11520 u8 **maskp = va_arg (*args, u8 **);
11527 u8 ignore_tag1 = 0;
11528 u8 ignore_tag2 = 0;
11535 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11537 if (unformat (input, "src"))
11539 else if (unformat (input, "dst"))
11541 else if (unformat (input, "proto"))
11543 else if (unformat (input, "tag1"))
11545 else if (unformat (input, "tag2"))
11547 else if (unformat (input, "ignore-tag1"))
11549 else if (unformat (input, "ignore-tag2"))
11551 else if (unformat (input, "cos1"))
11553 else if (unformat (input, "cos2"))
11555 else if (unformat (input, "dot1q"))
11557 else if (unformat (input, "dot1ad"))
11562 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
11563 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11566 if (tag1 || ignore_tag1 || cos1 || dot1q)
11568 if (tag2 || ignore_tag2 || cos2 || dot1ad)
11571 vec_validate (mask, len - 1);
11574 memset (mask, 0xff, 6);
11577 memset (mask + 6, 0xff, 6);
11579 if (tag2 || dot1ad)
11581 /* inner vlan tag */
11590 mask[21] = mask[20] = 0xff;
11611 mask[16] = mask[17] = 0xff;
11621 mask[12] = mask[13] = 0xff;
11628 unformat_classify_mask (unformat_input_t * input, va_list * args)
11630 u8 **maskp = va_arg (*args, u8 **);
11631 u32 *skipp = va_arg (*args, u32 *);
11632 u32 *matchp = va_arg (*args, u32 *);
11640 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11642 if (unformat (input, "hex %U", unformat_hex_string, &mask))
11644 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
11646 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
11648 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
11662 if (mask || l2 || l3 || l4)
11664 if (l2 || l3 || l4)
11666 /* "With a free Ethernet header in every package" */
11668 vec_validate (l2, 13);
11672 vec_append (mask, l3);
11677 vec_append (mask, l4);
11682 /* Scan forward looking for the first significant mask octet */
11683 for (i = 0; i < vec_len (mask); i++)
11687 /* compute (skip, match) params */
11688 *skipp = i / sizeof (u32x4);
11689 vec_delete (mask, *skipp * sizeof (u32x4), 0);
11691 /* Pad mask to an even multiple of the vector size */
11692 while (vec_len (mask) % sizeof (u32x4))
11693 vec_add1 (mask, 0);
11695 match = vec_len (mask) / sizeof (u32x4);
11697 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
11699 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
11700 if (*tmp || *(tmp + 1))
11705 clib_warning ("BUG: match 0");
11707 _vec_len (mask) = match * sizeof (u32x4);
11717 #endif /* VPP_API_TEST_BUILTIN */
11719 #define foreach_l2_next \
11721 _(ethernet, ETHERNET_INPUT) \
11722 _(ip4, IP4_INPUT) \
11726 unformat_l2_next_index (unformat_input_t * input, va_list * args)
11728 u32 *miss_next_indexp = va_arg (*args, u32 *);
11729 u32 next_index = 0;
11733 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
11737 if (unformat (input, "%d", &tmp))
11746 *miss_next_indexp = next_index;
11750 #define foreach_ip_next \
11753 _(rewrite, REWRITE)
11756 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
11758 u32 *miss_next_indexp = va_arg (*args, u32 *);
11759 u32 next_index = 0;
11763 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
11767 if (unformat (input, "%d", &tmp))
11776 *miss_next_indexp = next_index;
11780 #define foreach_acl_next \
11784 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
11786 u32 *miss_next_indexp = va_arg (*args, u32 *);
11787 u32 next_index = 0;
11791 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
11795 if (unformat (input, "permit"))
11800 else if (unformat (input, "%d", &tmp))
11809 *miss_next_indexp = next_index;
11814 unformat_policer_precolor (unformat_input_t * input, va_list * args)
11816 u32 *r = va_arg (*args, u32 *);
11818 if (unformat (input, "conform-color"))
11819 *r = POLICE_CONFORM;
11820 else if (unformat (input, "exceed-color"))
11821 *r = POLICE_EXCEED;
11829 api_classify_add_del_table (vat_main_t * vam)
11831 unformat_input_t *i = vam->input;
11832 vl_api_classify_add_del_table_t *mp;
11839 u32 table_index = ~0;
11840 u32 next_table_index = ~0;
11841 u32 miss_next_index = ~0;
11842 u32 memory_size = 32 << 20;
11844 u32 current_data_flag = 0;
11845 int current_data_offset = 0;
11848 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11850 if (unformat (i, "del"))
11852 else if (unformat (i, "del-chain"))
11857 else if (unformat (i, "buckets %d", &nbuckets))
11859 else if (unformat (i, "memory_size %d", &memory_size))
11861 else if (unformat (i, "skip %d", &skip))
11863 else if (unformat (i, "match %d", &match))
11865 else if (unformat (i, "table %d", &table_index))
11867 else if (unformat (i, "mask %U", unformat_classify_mask,
11868 &mask, &skip, &match))
11870 else if (unformat (i, "next-table %d", &next_table_index))
11872 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
11875 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
11878 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
11881 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
11883 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
11889 if (is_add && mask == 0)
11891 errmsg ("Mask required");
11895 if (is_add && skip == ~0)
11897 errmsg ("skip count required");
11901 if (is_add && match == ~0)
11903 errmsg ("match count required");
11907 if (!is_add && table_index == ~0)
11909 errmsg ("table index required for delete");
11913 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
11915 mp->is_add = is_add;
11916 mp->del_chain = del_chain;
11917 mp->table_index = ntohl (table_index);
11918 mp->nbuckets = ntohl (nbuckets);
11919 mp->memory_size = ntohl (memory_size);
11920 mp->skip_n_vectors = ntohl (skip);
11921 mp->match_n_vectors = ntohl (match);
11922 mp->next_table_index = ntohl (next_table_index);
11923 mp->miss_next_index = ntohl (miss_next_index);
11924 mp->current_data_flag = ntohl (current_data_flag);
11925 mp->current_data_offset = ntohl (current_data_offset);
11926 mp->mask_len = ntohl (vec_len (mask));
11927 clib_memcpy (mp->mask, mask, vec_len (mask));
11936 #if VPP_API_TEST_BUILTIN == 0
11938 unformat_l4_match (unformat_input_t * input, va_list * args)
11940 u8 **matchp = va_arg (*args, u8 **);
11942 u8 *proto_header = 0;
11948 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11950 if (unformat (input, "src_port %d", &src_port))
11952 else if (unformat (input, "dst_port %d", &dst_port))
11958 h.src_port = clib_host_to_net_u16 (src_port);
11959 h.dst_port = clib_host_to_net_u16 (dst_port);
11960 vec_validate (proto_header, sizeof (h) - 1);
11961 memcpy (proto_header, &h, sizeof (h));
11963 *matchp = proto_header;
11969 unformat_ip4_match (unformat_input_t * input, va_list * args)
11971 u8 **matchp = va_arg (*args, u8 **);
11976 int hdr_length = 0;
11977 u32 hdr_length_val;
11978 int src = 0, dst = 0;
11979 ip4_address_t src_val, dst_val;
11986 int fragment_id = 0;
11987 u32 fragment_id_val;
11993 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11995 if (unformat (input, "version %d", &version_val))
11997 else if (unformat (input, "hdr_length %d", &hdr_length_val))
11999 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
12001 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
12003 else if (unformat (input, "proto %d", &proto_val))
12005 else if (unformat (input, "tos %d", &tos_val))
12007 else if (unformat (input, "length %d", &length_val))
12009 else if (unformat (input, "fragment_id %d", &fragment_id_val))
12011 else if (unformat (input, "ttl %d", &ttl_val))
12013 else if (unformat (input, "checksum %d", &checksum_val))
12019 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
12020 + ttl + checksum == 0)
12024 * Aligned because we use the real comparison functions
12026 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
12028 ip = (ip4_header_t *) match;
12030 /* These are realistically matched in practice */
12032 ip->src_address.as_u32 = src_val.as_u32;
12035 ip->dst_address.as_u32 = dst_val.as_u32;
12038 ip->protocol = proto_val;
12041 /* These are not, but they're included for completeness */
12043 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
12046 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
12052 ip->length = clib_host_to_net_u16 (length_val);
12058 ip->checksum = clib_host_to_net_u16 (checksum_val);
12065 unformat_ip6_match (unformat_input_t * input, va_list * args)
12067 u8 **matchp = va_arg (*args, u8 **);
12072 u8 traffic_class = 0;
12073 u32 traffic_class_val = 0;
12076 int src = 0, dst = 0;
12077 ip6_address_t src_val, dst_val;
12080 int payload_length = 0;
12081 u32 payload_length_val;
12084 u32 ip_version_traffic_class_and_flow_label;
12086 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12088 if (unformat (input, "version %d", &version_val))
12090 else if (unformat (input, "traffic_class %d", &traffic_class_val))
12092 else if (unformat (input, "flow_label %d", &flow_label_val))
12094 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
12096 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
12098 else if (unformat (input, "proto %d", &proto_val))
12100 else if (unformat (input, "payload_length %d", &payload_length_val))
12101 payload_length = 1;
12102 else if (unformat (input, "hop_limit %d", &hop_limit_val))
12108 if (version + traffic_class + flow_label + src + dst + proto +
12109 payload_length + hop_limit == 0)
12113 * Aligned because we use the real comparison functions
12115 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
12117 ip = (ip6_header_t *) match;
12120 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
12123 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
12126 ip->protocol = proto_val;
12128 ip_version_traffic_class_and_flow_label = 0;
12131 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
12134 ip_version_traffic_class_and_flow_label |=
12135 (traffic_class_val & 0xFF) << 20;
12138 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
12140 ip->ip_version_traffic_class_and_flow_label =
12141 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
12143 if (payload_length)
12144 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
12147 ip->hop_limit = hop_limit_val;
12154 unformat_l3_match (unformat_input_t * input, va_list * args)
12156 u8 **matchp = va_arg (*args, u8 **);
12158 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12160 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
12162 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
12171 unformat_vlan_tag (unformat_input_t * input, va_list * args)
12173 u8 *tagp = va_arg (*args, u8 *);
12176 if (unformat (input, "%d", &tag))
12178 tagp[0] = (tag >> 8) & 0x0F;
12179 tagp[1] = tag & 0xFF;
12187 unformat_l2_match (unformat_input_t * input, va_list * args)
12189 u8 **matchp = va_arg (*args, u8 **);
12202 u8 ignore_tag1 = 0;
12203 u8 ignore_tag2 = 0;
12209 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12211 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
12214 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
12216 else if (unformat (input, "proto %U",
12217 unformat_ethernet_type_host_byte_order, &proto_val))
12219 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
12221 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
12223 else if (unformat (input, "ignore-tag1"))
12225 else if (unformat (input, "ignore-tag2"))
12227 else if (unformat (input, "cos1 %d", &cos1_val))
12229 else if (unformat (input, "cos2 %d", &cos2_val))
12234 if ((src + dst + proto + tag1 + tag2 +
12235 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
12238 if (tag1 || ignore_tag1 || cos1)
12240 if (tag2 || ignore_tag2 || cos2)
12243 vec_validate_aligned (match, len - 1, sizeof (u32x4));
12246 clib_memcpy (match, dst_val, 6);
12249 clib_memcpy (match + 6, src_val, 6);
12253 /* inner vlan tag */
12254 match[19] = tag2_val[1];
12255 match[18] = tag2_val[0];
12257 match[18] |= (cos2_val & 0x7) << 5;
12260 match[21] = proto_val & 0xff;
12261 match[20] = proto_val >> 8;
12265 match[15] = tag1_val[1];
12266 match[14] = tag1_val[0];
12269 match[14] |= (cos1_val & 0x7) << 5;
12275 match[15] = tag1_val[1];
12276 match[14] = tag1_val[0];
12279 match[17] = proto_val & 0xff;
12280 match[16] = proto_val >> 8;
12283 match[14] |= (cos1_val & 0x7) << 5;
12289 match[18] |= (cos2_val & 0x7) << 5;
12291 match[14] |= (cos1_val & 0x7) << 5;
12294 match[13] = proto_val & 0xff;
12295 match[12] = proto_val >> 8;
12303 unformat_qos_source (unformat_input_t * input, va_list * args)
12305 int *qs = va_arg (*args, int *);
12307 if (unformat (input, "ip"))
12308 *qs = QOS_SOURCE_IP;
12309 else if (unformat (input, "mpls"))
12310 *qs = QOS_SOURCE_MPLS;
12311 else if (unformat (input, "ext"))
12312 *qs = QOS_SOURCE_EXT;
12313 else if (unformat (input, "vlan"))
12314 *qs = QOS_SOURCE_VLAN;
12323 api_unformat_classify_match (unformat_input_t * input, va_list * args)
12325 u8 **matchp = va_arg (*args, u8 **);
12326 u32 skip_n_vectors = va_arg (*args, u32);
12327 u32 match_n_vectors = va_arg (*args, u32);
12334 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12336 if (unformat (input, "hex %U", unformat_hex_string, &match))
12338 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
12340 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
12342 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
12356 if (match || l2 || l3 || l4)
12358 if (l2 || l3 || l4)
12360 /* "Win a free Ethernet header in every packet" */
12362 vec_validate_aligned (l2, 13, sizeof (u32x4));
12366 vec_append_aligned (match, l3, sizeof (u32x4));
12371 vec_append_aligned (match, l4, sizeof (u32x4));
12376 /* Make sure the vector is big enough even if key is all 0's */
12377 vec_validate_aligned
12378 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
12381 /* Set size, include skipped vectors */
12382 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
12393 api_classify_add_del_session (vat_main_t * vam)
12395 unformat_input_t *i = vam->input;
12396 vl_api_classify_add_del_session_t *mp;
12398 u32 table_index = ~0;
12399 u32 hit_next_index = ~0;
12400 u32 opaque_index = ~0;
12403 u32 skip_n_vectors = 0;
12404 u32 match_n_vectors = 0;
12410 * Warning: you have to supply skip_n and match_n
12411 * because the API client cant simply look at the classify
12415 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12417 if (unformat (i, "del"))
12419 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
12422 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
12425 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
12428 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
12430 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
12432 else if (unformat (i, "opaque-index %d", &opaque_index))
12434 else if (unformat (i, "skip_n %d", &skip_n_vectors))
12436 else if (unformat (i, "match_n %d", &match_n_vectors))
12438 else if (unformat (i, "match %U", api_unformat_classify_match,
12439 &match, skip_n_vectors, match_n_vectors))
12441 else if (unformat (i, "advance %d", &advance))
12443 else if (unformat (i, "table-index %d", &table_index))
12445 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
12447 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
12449 else if (unformat (i, "action %d", &action))
12451 else if (unformat (i, "metadata %d", &metadata))
12457 if (table_index == ~0)
12459 errmsg ("Table index required");
12463 if (is_add && match == 0)
12465 errmsg ("Match value required");
12469 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
12471 mp->is_add = is_add;
12472 mp->table_index = ntohl (table_index);
12473 mp->hit_next_index = ntohl (hit_next_index);
12474 mp->opaque_index = ntohl (opaque_index);
12475 mp->advance = ntohl (advance);
12476 mp->action = action;
12477 mp->metadata = ntohl (metadata);
12478 mp->match_len = ntohl (vec_len (match));
12479 clib_memcpy (mp->match, match, vec_len (match));
12488 api_classify_set_interface_ip_table (vat_main_t * vam)
12490 unformat_input_t *i = vam->input;
12491 vl_api_classify_set_interface_ip_table_t *mp;
12493 int sw_if_index_set;
12494 u32 table_index = ~0;
12498 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12500 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12501 sw_if_index_set = 1;
12502 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12503 sw_if_index_set = 1;
12504 else if (unformat (i, "table %d", &table_index))
12508 clib_warning ("parse error '%U'", format_unformat_error, i);
12513 if (sw_if_index_set == 0)
12515 errmsg ("missing interface name or sw_if_index");
12520 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
12522 mp->sw_if_index = ntohl (sw_if_index);
12523 mp->table_index = ntohl (table_index);
12524 mp->is_ipv6 = is_ipv6;
12532 api_classify_set_interface_l2_tables (vat_main_t * vam)
12534 unformat_input_t *i = vam->input;
12535 vl_api_classify_set_interface_l2_tables_t *mp;
12537 int sw_if_index_set;
12538 u32 ip4_table_index = ~0;
12539 u32 ip6_table_index = ~0;
12540 u32 other_table_index = ~0;
12544 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12546 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12547 sw_if_index_set = 1;
12548 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12549 sw_if_index_set = 1;
12550 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12552 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12554 else if (unformat (i, "other-table %d", &other_table_index))
12556 else if (unformat (i, "is-input %d", &is_input))
12560 clib_warning ("parse error '%U'", format_unformat_error, i);
12565 if (sw_if_index_set == 0)
12567 errmsg ("missing interface name or sw_if_index");
12572 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
12574 mp->sw_if_index = ntohl (sw_if_index);
12575 mp->ip4_table_index = ntohl (ip4_table_index);
12576 mp->ip6_table_index = ntohl (ip6_table_index);
12577 mp->other_table_index = ntohl (other_table_index);
12578 mp->is_input = (u8) is_input;
12586 api_set_ipfix_exporter (vat_main_t * vam)
12588 unformat_input_t *i = vam->input;
12589 vl_api_set_ipfix_exporter_t *mp;
12590 ip4_address_t collector_address;
12591 u8 collector_address_set = 0;
12592 u32 collector_port = ~0;
12593 ip4_address_t src_address;
12594 u8 src_address_set = 0;
12597 u32 template_interval = ~0;
12598 u8 udp_checksum = 0;
12601 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12603 if (unformat (i, "collector_address %U", unformat_ip4_address,
12604 &collector_address))
12605 collector_address_set = 1;
12606 else if (unformat (i, "collector_port %d", &collector_port))
12608 else if (unformat (i, "src_address %U", unformat_ip4_address,
12610 src_address_set = 1;
12611 else if (unformat (i, "vrf_id %d", &vrf_id))
12613 else if (unformat (i, "path_mtu %d", &path_mtu))
12615 else if (unformat (i, "template_interval %d", &template_interval))
12617 else if (unformat (i, "udp_checksum"))
12623 if (collector_address_set == 0)
12625 errmsg ("collector_address required");
12629 if (src_address_set == 0)
12631 errmsg ("src_address required");
12635 M (SET_IPFIX_EXPORTER, mp);
12637 memcpy (mp->collector_address, collector_address.data,
12638 sizeof (collector_address.data));
12639 mp->collector_port = htons ((u16) collector_port);
12640 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
12641 mp->vrf_id = htonl (vrf_id);
12642 mp->path_mtu = htonl (path_mtu);
12643 mp->template_interval = htonl (template_interval);
12644 mp->udp_checksum = udp_checksum;
12652 api_set_ipfix_classify_stream (vat_main_t * vam)
12654 unformat_input_t *i = vam->input;
12655 vl_api_set_ipfix_classify_stream_t *mp;
12657 u32 src_port = UDP_DST_PORT_ipfix;
12660 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12662 if (unformat (i, "domain %d", &domain_id))
12664 else if (unformat (i, "src_port %d", &src_port))
12668 errmsg ("unknown input `%U'", format_unformat_error, i);
12673 M (SET_IPFIX_CLASSIFY_STREAM, mp);
12675 mp->domain_id = htonl (domain_id);
12676 mp->src_port = htons ((u16) src_port);
12684 api_ipfix_classify_table_add_del (vat_main_t * vam)
12686 unformat_input_t *i = vam->input;
12687 vl_api_ipfix_classify_table_add_del_t *mp;
12689 u32 classify_table_index = ~0;
12691 u8 transport_protocol = 255;
12694 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12696 if (unformat (i, "add"))
12698 else if (unformat (i, "del"))
12700 else if (unformat (i, "table %d", &classify_table_index))
12702 else if (unformat (i, "ip4"))
12704 else if (unformat (i, "ip6"))
12706 else if (unformat (i, "tcp"))
12707 transport_protocol = 6;
12708 else if (unformat (i, "udp"))
12709 transport_protocol = 17;
12712 errmsg ("unknown input `%U'", format_unformat_error, i);
12719 errmsg ("expecting: add|del");
12722 if (classify_table_index == ~0)
12724 errmsg ("classifier table not specified");
12727 if (ip_version == 0)
12729 errmsg ("IP version not specified");
12733 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
12735 mp->is_add = is_add;
12736 mp->table_id = htonl (classify_table_index);
12737 mp->ip_version = ip_version;
12738 mp->transport_protocol = transport_protocol;
12746 api_get_node_index (vat_main_t * vam)
12748 unformat_input_t *i = vam->input;
12749 vl_api_get_node_index_t *mp;
12753 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12755 if (unformat (i, "node %s", &name))
12762 errmsg ("node name required");
12765 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12767 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12771 M (GET_NODE_INDEX, mp);
12772 clib_memcpy (mp->node_name, name, vec_len (name));
12781 api_get_next_index (vat_main_t * vam)
12783 unformat_input_t *i = vam->input;
12784 vl_api_get_next_index_t *mp;
12785 u8 *node_name = 0, *next_node_name = 0;
12788 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12790 if (unformat (i, "node-name %s", &node_name))
12792 else if (unformat (i, "next-node-name %s", &next_node_name))
12796 if (node_name == 0)
12798 errmsg ("node name required");
12801 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
12803 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12807 if (next_node_name == 0)
12809 errmsg ("next node name required");
12812 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
12814 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
12818 M (GET_NEXT_INDEX, mp);
12819 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
12820 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
12821 vec_free (node_name);
12822 vec_free (next_node_name);
12830 api_add_node_next (vat_main_t * vam)
12832 unformat_input_t *i = vam->input;
12833 vl_api_add_node_next_t *mp;
12838 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12840 if (unformat (i, "node %s", &name))
12842 else if (unformat (i, "next %s", &next))
12849 errmsg ("node name required");
12852 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12854 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12859 errmsg ("next node required");
12862 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
12864 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
12868 M (ADD_NODE_NEXT, mp);
12869 clib_memcpy (mp->node_name, name, vec_len (name));
12870 clib_memcpy (mp->next_name, next, vec_len (next));
12880 api_l2tpv3_create_tunnel (vat_main_t * vam)
12882 unformat_input_t *i = vam->input;
12883 ip6_address_t client_address, our_address;
12884 int client_address_set = 0;
12885 int our_address_set = 0;
12886 u32 local_session_id = 0;
12887 u32 remote_session_id = 0;
12888 u64 local_cookie = 0;
12889 u64 remote_cookie = 0;
12890 u8 l2_sublayer_present = 0;
12891 vl_api_l2tpv3_create_tunnel_t *mp;
12894 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12896 if (unformat (i, "client_address %U", unformat_ip6_address,
12898 client_address_set = 1;
12899 else if (unformat (i, "our_address %U", unformat_ip6_address,
12901 our_address_set = 1;
12902 else if (unformat (i, "local_session_id %d", &local_session_id))
12904 else if (unformat (i, "remote_session_id %d", &remote_session_id))
12906 else if (unformat (i, "local_cookie %lld", &local_cookie))
12908 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
12910 else if (unformat (i, "l2-sublayer-present"))
12911 l2_sublayer_present = 1;
12916 if (client_address_set == 0)
12918 errmsg ("client_address required");
12922 if (our_address_set == 0)
12924 errmsg ("our_address required");
12928 M (L2TPV3_CREATE_TUNNEL, mp);
12930 clib_memcpy (mp->client_address, client_address.as_u8,
12931 sizeof (mp->client_address));
12933 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
12935 mp->local_session_id = ntohl (local_session_id);
12936 mp->remote_session_id = ntohl (remote_session_id);
12937 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
12938 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
12939 mp->l2_sublayer_present = l2_sublayer_present;
12948 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
12950 unformat_input_t *i = vam->input;
12952 u8 sw_if_index_set = 0;
12953 u64 new_local_cookie = 0;
12954 u64 new_remote_cookie = 0;
12955 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
12958 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12960 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12961 sw_if_index_set = 1;
12962 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12963 sw_if_index_set = 1;
12964 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
12966 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
12972 if (sw_if_index_set == 0)
12974 errmsg ("missing interface name or sw_if_index");
12978 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
12980 mp->sw_if_index = ntohl (sw_if_index);
12981 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
12982 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
12990 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
12992 unformat_input_t *i = vam->input;
12993 vl_api_l2tpv3_interface_enable_disable_t *mp;
12995 u8 sw_if_index_set = 0;
12996 u8 enable_disable = 1;
12999 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13001 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13002 sw_if_index_set = 1;
13003 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13004 sw_if_index_set = 1;
13005 else if (unformat (i, "enable"))
13006 enable_disable = 1;
13007 else if (unformat (i, "disable"))
13008 enable_disable = 0;
13013 if (sw_if_index_set == 0)
13015 errmsg ("missing interface name or sw_if_index");
13019 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
13021 mp->sw_if_index = ntohl (sw_if_index);
13022 mp->enable_disable = enable_disable;
13030 api_l2tpv3_set_lookup_key (vat_main_t * vam)
13032 unformat_input_t *i = vam->input;
13033 vl_api_l2tpv3_set_lookup_key_t *mp;
13037 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13039 if (unformat (i, "lookup_v6_src"))
13040 key = L2T_LOOKUP_SRC_ADDRESS;
13041 else if (unformat (i, "lookup_v6_dst"))
13042 key = L2T_LOOKUP_DST_ADDRESS;
13043 else if (unformat (i, "lookup_session_id"))
13044 key = L2T_LOOKUP_SESSION_ID;
13049 if (key == (u8) ~ 0)
13051 errmsg ("l2tp session lookup key unset");
13055 M (L2TPV3_SET_LOOKUP_KEY, mp);
13064 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
13065 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
13067 vat_main_t *vam = &vat_main;
13069 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
13070 format_ip6_address, mp->our_address,
13071 format_ip6_address, mp->client_address,
13072 clib_net_to_host_u32 (mp->sw_if_index));
13075 " local cookies %016llx %016llx remote cookie %016llx",
13076 clib_net_to_host_u64 (mp->local_cookie[0]),
13077 clib_net_to_host_u64 (mp->local_cookie[1]),
13078 clib_net_to_host_u64 (mp->remote_cookie));
13080 print (vam->ofp, " local session-id %d remote session-id %d",
13081 clib_net_to_host_u32 (mp->local_session_id),
13082 clib_net_to_host_u32 (mp->remote_session_id));
13084 print (vam->ofp, " l2 specific sublayer %s\n",
13085 mp->l2_sublayer_present ? "preset" : "absent");
13089 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
13090 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
13092 vat_main_t *vam = &vat_main;
13093 vat_json_node_t *node = NULL;
13094 struct in6_addr addr;
13096 if (VAT_JSON_ARRAY != vam->json_tree.type)
13098 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13099 vat_json_init_array (&vam->json_tree);
13101 node = vat_json_array_add (&vam->json_tree);
13103 vat_json_init_object (node);
13105 clib_memcpy (&addr, mp->our_address, sizeof (addr));
13106 vat_json_object_add_ip6 (node, "our_address", addr);
13107 clib_memcpy (&addr, mp->client_address, sizeof (addr));
13108 vat_json_object_add_ip6 (node, "client_address", addr);
13110 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
13111 vat_json_init_array (lc);
13112 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
13113 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
13114 vat_json_object_add_uint (node, "remote_cookie",
13115 clib_net_to_host_u64 (mp->remote_cookie));
13117 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
13118 vat_json_object_add_uint (node, "local_session_id",
13119 clib_net_to_host_u32 (mp->local_session_id));
13120 vat_json_object_add_uint (node, "remote_session_id",
13121 clib_net_to_host_u32 (mp->remote_session_id));
13122 vat_json_object_add_string_copy (node, "l2_sublayer",
13123 mp->l2_sublayer_present ? (u8 *) "present"
13124 : (u8 *) "absent");
13128 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
13130 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
13131 vl_api_control_ping_t *mp_ping;
13134 /* Get list of l2tpv3-tunnel interfaces */
13135 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
13138 /* Use a control ping for synchronization */
13139 MPING (CONTROL_PING, mp_ping);
13147 static void vl_api_sw_interface_tap_details_t_handler
13148 (vl_api_sw_interface_tap_details_t * mp)
13150 vat_main_t *vam = &vat_main;
13152 print (vam->ofp, "%-16s %d",
13153 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
13156 static void vl_api_sw_interface_tap_details_t_handler_json
13157 (vl_api_sw_interface_tap_details_t * mp)
13159 vat_main_t *vam = &vat_main;
13160 vat_json_node_t *node = NULL;
13162 if (VAT_JSON_ARRAY != vam->json_tree.type)
13164 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13165 vat_json_init_array (&vam->json_tree);
13167 node = vat_json_array_add (&vam->json_tree);
13169 vat_json_init_object (node);
13170 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13171 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
13175 api_sw_interface_tap_dump (vat_main_t * vam)
13177 vl_api_sw_interface_tap_dump_t *mp;
13178 vl_api_control_ping_t *mp_ping;
13181 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
13182 /* Get list of tap interfaces */
13183 M (SW_INTERFACE_TAP_DUMP, mp);
13186 /* Use a control ping for synchronization */
13187 MPING (CONTROL_PING, mp_ping);
13194 static void vl_api_sw_interface_tap_v2_details_t_handler
13195 (vl_api_sw_interface_tap_v2_details_t * mp)
13197 vat_main_t *vam = &vat_main;
13199 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
13200 mp->host_ip4_prefix_len);
13201 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
13202 mp->host_ip6_prefix_len);
13205 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s",
13206 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
13207 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
13208 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
13209 mp->host_bridge, ip4, ip6);
13215 static void vl_api_sw_interface_tap_v2_details_t_handler_json
13216 (vl_api_sw_interface_tap_v2_details_t * mp)
13218 vat_main_t *vam = &vat_main;
13219 vat_json_node_t *node = NULL;
13221 if (VAT_JSON_ARRAY != vam->json_tree.type)
13223 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13224 vat_json_init_array (&vam->json_tree);
13226 node = vat_json_array_add (&vam->json_tree);
13228 vat_json_init_object (node);
13229 vat_json_object_add_uint (node, "id", ntohl (mp->id));
13230 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13231 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
13232 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
13233 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
13234 vat_json_object_add_string_copy (node, "host_mac_addr",
13235 format (0, "%U", format_ethernet_address,
13236 &mp->host_mac_addr));
13237 vat_json_object_add_string_copy (node, "host_namespace",
13238 mp->host_namespace);
13239 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
13240 vat_json_object_add_string_copy (node, "host_ip4_addr",
13241 format (0, "%U/%d", format_ip4_address,
13243 mp->host_ip4_prefix_len));
13244 vat_json_object_add_string_copy (node, "host_ip6_addr",
13245 format (0, "%U/%d", format_ip6_address,
13247 mp->host_ip6_prefix_len));
13252 api_sw_interface_tap_v2_dump (vat_main_t * vam)
13254 vl_api_sw_interface_tap_v2_dump_t *mp;
13255 vl_api_control_ping_t *mp_ping;
13259 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
13260 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
13261 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
13264 /* Get list of tap interfaces */
13265 M (SW_INTERFACE_TAP_V2_DUMP, mp);
13268 /* Use a control ping for synchronization */
13269 MPING (CONTROL_PING, mp_ping);
13277 api_vxlan_offload_rx (vat_main_t * vam)
13279 unformat_input_t *line_input = vam->input;
13280 vl_api_vxlan_offload_rx_t *mp;
13281 u32 hw_if_index = ~0, rx_if_index = ~0;
13285 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13287 if (unformat (line_input, "del"))
13289 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
13292 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
13294 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
13297 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
13301 errmsg ("parse error '%U'", format_unformat_error, line_input);
13306 if (hw_if_index == ~0)
13308 errmsg ("no hw interface");
13312 if (rx_if_index == ~0)
13314 errmsg ("no rx tunnel");
13318 M (VXLAN_OFFLOAD_RX, mp);
13320 mp->hw_if_index = ntohl (hw_if_index);
13321 mp->sw_if_index = ntohl (rx_if_index);
13322 mp->enable = is_add;
13329 static uword unformat_vxlan_decap_next
13330 (unformat_input_t * input, va_list * args)
13332 u32 *result = va_arg (*args, u32 *);
13335 if (unformat (input, "l2"))
13336 *result = VXLAN_INPUT_NEXT_L2_INPUT;
13337 else if (unformat (input, "%d", &tmp))
13345 api_vxlan_add_del_tunnel (vat_main_t * vam)
13347 unformat_input_t *line_input = vam->input;
13348 vl_api_vxlan_add_del_tunnel_t *mp;
13349 ip46_address_t src, dst;
13351 u8 ipv4_set = 0, ipv6_set = 0;
13356 u32 mcast_sw_if_index = ~0;
13357 u32 encap_vrf_id = 0;
13358 u32 decap_next_index = ~0;
13362 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13363 memset (&src, 0, sizeof src);
13364 memset (&dst, 0, sizeof dst);
13366 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13368 if (unformat (line_input, "del"))
13370 else if (unformat (line_input, "instance %d", &instance))
13373 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13379 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13385 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13391 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13396 else if (unformat (line_input, "group %U %U",
13397 unformat_ip4_address, &dst.ip4,
13398 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13400 grp_set = dst_set = 1;
13403 else if (unformat (line_input, "group %U",
13404 unformat_ip4_address, &dst.ip4))
13406 grp_set = dst_set = 1;
13409 else if (unformat (line_input, "group %U %U",
13410 unformat_ip6_address, &dst.ip6,
13411 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13413 grp_set = dst_set = 1;
13416 else if (unformat (line_input, "group %U",
13417 unformat_ip6_address, &dst.ip6))
13419 grp_set = dst_set = 1;
13423 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13425 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13427 else if (unformat (line_input, "decap-next %U",
13428 unformat_vxlan_decap_next, &decap_next_index))
13430 else if (unformat (line_input, "vni %d", &vni))
13434 errmsg ("parse error '%U'", format_unformat_error, line_input);
13441 errmsg ("tunnel src address not specified");
13446 errmsg ("tunnel dst address not specified");
13450 if (grp_set && !ip46_address_is_multicast (&dst))
13452 errmsg ("tunnel group address not multicast");
13455 if (grp_set && mcast_sw_if_index == ~0)
13457 errmsg ("tunnel nonexistent multicast device");
13460 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13462 errmsg ("tunnel dst address must be unicast");
13467 if (ipv4_set && ipv6_set)
13469 errmsg ("both IPv4 and IPv6 addresses specified");
13473 if ((vni == 0) || (vni >> 24))
13475 errmsg ("vni not specified or out of range");
13479 M (VXLAN_ADD_DEL_TUNNEL, mp);
13483 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
13484 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
13488 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
13489 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
13492 mp->instance = htonl (instance);
13493 mp->encap_vrf_id = ntohl (encap_vrf_id);
13494 mp->decap_next_index = ntohl (decap_next_index);
13495 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13496 mp->vni = ntohl (vni);
13497 mp->is_add = is_add;
13498 mp->is_ipv6 = ipv6_set;
13505 static void vl_api_vxlan_tunnel_details_t_handler
13506 (vl_api_vxlan_tunnel_details_t * mp)
13508 vat_main_t *vam = &vat_main;
13509 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13510 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13512 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
13513 ntohl (mp->sw_if_index),
13514 ntohl (mp->instance),
13515 format_ip46_address, &src, IP46_TYPE_ANY,
13516 format_ip46_address, &dst, IP46_TYPE_ANY,
13517 ntohl (mp->encap_vrf_id),
13518 ntohl (mp->decap_next_index), ntohl (mp->vni),
13519 ntohl (mp->mcast_sw_if_index));
13522 static void vl_api_vxlan_tunnel_details_t_handler_json
13523 (vl_api_vxlan_tunnel_details_t * mp)
13525 vat_main_t *vam = &vat_main;
13526 vat_json_node_t *node = NULL;
13528 if (VAT_JSON_ARRAY != vam->json_tree.type)
13530 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13531 vat_json_init_array (&vam->json_tree);
13533 node = vat_json_array_add (&vam->json_tree);
13535 vat_json_init_object (node);
13536 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13538 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13542 struct in6_addr ip6;
13544 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13545 vat_json_object_add_ip6 (node, "src_address", ip6);
13546 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13547 vat_json_object_add_ip6 (node, "dst_address", ip6);
13551 struct in_addr ip4;
13553 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13554 vat_json_object_add_ip4 (node, "src_address", ip4);
13555 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13556 vat_json_object_add_ip4 (node, "dst_address", ip4);
13558 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13559 vat_json_object_add_uint (node, "decap_next_index",
13560 ntohl (mp->decap_next_index));
13561 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13562 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13563 vat_json_object_add_uint (node, "mcast_sw_if_index",
13564 ntohl (mp->mcast_sw_if_index));
13568 api_vxlan_tunnel_dump (vat_main_t * vam)
13570 unformat_input_t *i = vam->input;
13571 vl_api_vxlan_tunnel_dump_t *mp;
13572 vl_api_control_ping_t *mp_ping;
13574 u8 sw_if_index_set = 0;
13577 /* Parse args required to build the message */
13578 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13580 if (unformat (i, "sw_if_index %d", &sw_if_index))
13581 sw_if_index_set = 1;
13586 if (sw_if_index_set == 0)
13591 if (!vam->json_output)
13593 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
13594 "sw_if_index", "instance", "src_address", "dst_address",
13595 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13598 /* Get list of vxlan-tunnel interfaces */
13599 M (VXLAN_TUNNEL_DUMP, mp);
13601 mp->sw_if_index = htonl (sw_if_index);
13605 /* Use a control ping for synchronization */
13606 MPING (CONTROL_PING, mp_ping);
13613 static uword unformat_geneve_decap_next
13614 (unformat_input_t * input, va_list * args)
13616 u32 *result = va_arg (*args, u32 *);
13619 if (unformat (input, "l2"))
13620 *result = GENEVE_INPUT_NEXT_L2_INPUT;
13621 else if (unformat (input, "%d", &tmp))
13629 api_geneve_add_del_tunnel (vat_main_t * vam)
13631 unformat_input_t *line_input = vam->input;
13632 vl_api_geneve_add_del_tunnel_t *mp;
13633 ip46_address_t src, dst;
13635 u8 ipv4_set = 0, ipv6_set = 0;
13639 u32 mcast_sw_if_index = ~0;
13640 u32 encap_vrf_id = 0;
13641 u32 decap_next_index = ~0;
13645 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13646 memset (&src, 0, sizeof src);
13647 memset (&dst, 0, sizeof dst);
13649 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13651 if (unformat (line_input, "del"))
13654 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13660 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13666 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13672 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13677 else if (unformat (line_input, "group %U %U",
13678 unformat_ip4_address, &dst.ip4,
13679 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13681 grp_set = dst_set = 1;
13684 else if (unformat (line_input, "group %U",
13685 unformat_ip4_address, &dst.ip4))
13687 grp_set = dst_set = 1;
13690 else if (unformat (line_input, "group %U %U",
13691 unformat_ip6_address, &dst.ip6,
13692 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13694 grp_set = dst_set = 1;
13697 else if (unformat (line_input, "group %U",
13698 unformat_ip6_address, &dst.ip6))
13700 grp_set = dst_set = 1;
13704 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13706 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13708 else if (unformat (line_input, "decap-next %U",
13709 unformat_geneve_decap_next, &decap_next_index))
13711 else if (unformat (line_input, "vni %d", &vni))
13715 errmsg ("parse error '%U'", format_unformat_error, line_input);
13722 errmsg ("tunnel src address not specified");
13727 errmsg ("tunnel dst address not specified");
13731 if (grp_set && !ip46_address_is_multicast (&dst))
13733 errmsg ("tunnel group address not multicast");
13736 if (grp_set && mcast_sw_if_index == ~0)
13738 errmsg ("tunnel nonexistent multicast device");
13741 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13743 errmsg ("tunnel dst address must be unicast");
13748 if (ipv4_set && ipv6_set)
13750 errmsg ("both IPv4 and IPv6 addresses specified");
13754 if ((vni == 0) || (vni >> 24))
13756 errmsg ("vni not specified or out of range");
13760 M (GENEVE_ADD_DEL_TUNNEL, mp);
13764 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
13765 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
13769 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
13770 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
13772 mp->encap_vrf_id = ntohl (encap_vrf_id);
13773 mp->decap_next_index = ntohl (decap_next_index);
13774 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13775 mp->vni = ntohl (vni);
13776 mp->is_add = is_add;
13777 mp->is_ipv6 = ipv6_set;
13784 static void vl_api_geneve_tunnel_details_t_handler
13785 (vl_api_geneve_tunnel_details_t * mp)
13787 vat_main_t *vam = &vat_main;
13788 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13789 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13791 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
13792 ntohl (mp->sw_if_index),
13793 format_ip46_address, &src, IP46_TYPE_ANY,
13794 format_ip46_address, &dst, IP46_TYPE_ANY,
13795 ntohl (mp->encap_vrf_id),
13796 ntohl (mp->decap_next_index), ntohl (mp->vni),
13797 ntohl (mp->mcast_sw_if_index));
13800 static void vl_api_geneve_tunnel_details_t_handler_json
13801 (vl_api_geneve_tunnel_details_t * mp)
13803 vat_main_t *vam = &vat_main;
13804 vat_json_node_t *node = NULL;
13806 if (VAT_JSON_ARRAY != vam->json_tree.type)
13808 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13809 vat_json_init_array (&vam->json_tree);
13811 node = vat_json_array_add (&vam->json_tree);
13813 vat_json_init_object (node);
13814 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13817 struct in6_addr ip6;
13819 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13820 vat_json_object_add_ip6 (node, "src_address", ip6);
13821 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13822 vat_json_object_add_ip6 (node, "dst_address", ip6);
13826 struct in_addr ip4;
13828 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13829 vat_json_object_add_ip4 (node, "src_address", ip4);
13830 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13831 vat_json_object_add_ip4 (node, "dst_address", ip4);
13833 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13834 vat_json_object_add_uint (node, "decap_next_index",
13835 ntohl (mp->decap_next_index));
13836 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13837 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13838 vat_json_object_add_uint (node, "mcast_sw_if_index",
13839 ntohl (mp->mcast_sw_if_index));
13843 api_geneve_tunnel_dump (vat_main_t * vam)
13845 unformat_input_t *i = vam->input;
13846 vl_api_geneve_tunnel_dump_t *mp;
13847 vl_api_control_ping_t *mp_ping;
13849 u8 sw_if_index_set = 0;
13852 /* Parse args required to build the message */
13853 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13855 if (unformat (i, "sw_if_index %d", &sw_if_index))
13856 sw_if_index_set = 1;
13861 if (sw_if_index_set == 0)
13866 if (!vam->json_output)
13868 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
13869 "sw_if_index", "local_address", "remote_address",
13870 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13873 /* Get list of geneve-tunnel interfaces */
13874 M (GENEVE_TUNNEL_DUMP, mp);
13876 mp->sw_if_index = htonl (sw_if_index);
13880 /* Use a control ping for synchronization */
13881 M (CONTROL_PING, mp_ping);
13889 api_gre_add_del_tunnel (vat_main_t * vam)
13891 unformat_input_t *line_input = vam->input;
13892 vl_api_gre_add_del_tunnel_t *mp;
13893 ip4_address_t src4, dst4;
13894 ip6_address_t src6, dst6;
13898 u8 t_type = GRE_TUNNEL_TYPE_L3;
13901 u32 outer_fib_id = 0;
13902 u32 session_id = 0;
13906 memset (&src4, 0, sizeof src4);
13907 memset (&dst4, 0, sizeof dst4);
13908 memset (&src6, 0, sizeof src6);
13909 memset (&dst6, 0, sizeof dst6);
13911 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13913 if (unformat (line_input, "del"))
13915 else if (unformat (line_input, "instance %d", &instance))
13917 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
13922 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
13927 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
13932 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
13937 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
13939 else if (unformat (line_input, "teb"))
13940 t_type = GRE_TUNNEL_TYPE_TEB;
13941 else if (unformat (line_input, "erspan %d", &session_id))
13942 t_type = GRE_TUNNEL_TYPE_ERSPAN;
13945 errmsg ("parse error '%U'", format_unformat_error, line_input);
13952 errmsg ("tunnel src address not specified");
13957 errmsg ("tunnel dst address not specified");
13960 if (ipv4_set && ipv6_set)
13962 errmsg ("both IPv4 and IPv6 addresses specified");
13967 M (GRE_ADD_DEL_TUNNEL, mp);
13971 clib_memcpy (&mp->src_address, &src4, 4);
13972 clib_memcpy (&mp->dst_address, &dst4, 4);
13976 clib_memcpy (&mp->src_address, &src6, 16);
13977 clib_memcpy (&mp->dst_address, &dst6, 16);
13979 mp->instance = htonl (instance);
13980 mp->outer_fib_id = htonl (outer_fib_id);
13981 mp->is_add = is_add;
13982 mp->session_id = htons ((u16) session_id);
13983 mp->tunnel_type = t_type;
13984 mp->is_ipv6 = ipv6_set;
13991 static void vl_api_gre_tunnel_details_t_handler
13992 (vl_api_gre_tunnel_details_t * mp)
13994 vat_main_t *vam = &vat_main;
13995 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
13996 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
13998 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
13999 ntohl (mp->sw_if_index),
14000 ntohl (mp->instance),
14001 format_ip46_address, &src, IP46_TYPE_ANY,
14002 format_ip46_address, &dst, IP46_TYPE_ANY,
14003 mp->tunnel_type, ntohl (mp->outer_fib_id), ntohl (mp->session_id));
14006 static void vl_api_gre_tunnel_details_t_handler_json
14007 (vl_api_gre_tunnel_details_t * mp)
14009 vat_main_t *vam = &vat_main;
14010 vat_json_node_t *node = NULL;
14011 struct in_addr ip4;
14012 struct in6_addr ip6;
14014 if (VAT_JSON_ARRAY != vam->json_tree.type)
14016 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14017 vat_json_init_array (&vam->json_tree);
14019 node = vat_json_array_add (&vam->json_tree);
14021 vat_json_init_object (node);
14022 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14023 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
14026 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
14027 vat_json_object_add_ip4 (node, "src_address", ip4);
14028 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
14029 vat_json_object_add_ip4 (node, "dst_address", ip4);
14033 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
14034 vat_json_object_add_ip6 (node, "src_address", ip6);
14035 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
14036 vat_json_object_add_ip6 (node, "dst_address", ip6);
14038 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel_type);
14039 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
14040 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
14041 vat_json_object_add_uint (node, "session_id", mp->session_id);
14045 api_gre_tunnel_dump (vat_main_t * vam)
14047 unformat_input_t *i = vam->input;
14048 vl_api_gre_tunnel_dump_t *mp;
14049 vl_api_control_ping_t *mp_ping;
14051 u8 sw_if_index_set = 0;
14054 /* Parse args required to build the message */
14055 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14057 if (unformat (i, "sw_if_index %d", &sw_if_index))
14058 sw_if_index_set = 1;
14063 if (sw_if_index_set == 0)
14068 if (!vam->json_output)
14070 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
14071 "sw_if_index", "instance", "src_address", "dst_address",
14072 "tunnel_type", "outer_fib_id", "session_id");
14075 /* Get list of gre-tunnel interfaces */
14076 M (GRE_TUNNEL_DUMP, mp);
14078 mp->sw_if_index = htonl (sw_if_index);
14082 /* Use a control ping for synchronization */
14083 MPING (CONTROL_PING, mp_ping);
14091 api_l2_fib_clear_table (vat_main_t * vam)
14093 // unformat_input_t * i = vam->input;
14094 vl_api_l2_fib_clear_table_t *mp;
14097 M (L2_FIB_CLEAR_TABLE, mp);
14105 api_l2_interface_efp_filter (vat_main_t * vam)
14107 unformat_input_t *i = vam->input;
14108 vl_api_l2_interface_efp_filter_t *mp;
14111 u8 sw_if_index_set = 0;
14114 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14116 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14117 sw_if_index_set = 1;
14118 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14119 sw_if_index_set = 1;
14120 else if (unformat (i, "enable"))
14122 else if (unformat (i, "disable"))
14126 clib_warning ("parse error '%U'", format_unformat_error, i);
14131 if (sw_if_index_set == 0)
14133 errmsg ("missing sw_if_index");
14137 M (L2_INTERFACE_EFP_FILTER, mp);
14139 mp->sw_if_index = ntohl (sw_if_index);
14140 mp->enable_disable = enable;
14147 #define foreach_vtr_op \
14148 _("disable", L2_VTR_DISABLED) \
14149 _("push-1", L2_VTR_PUSH_1) \
14150 _("push-2", L2_VTR_PUSH_2) \
14151 _("pop-1", L2_VTR_POP_1) \
14152 _("pop-2", L2_VTR_POP_2) \
14153 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
14154 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
14155 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
14156 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
14159 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
14161 unformat_input_t *i = vam->input;
14162 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
14164 u8 sw_if_index_set = 0;
14167 u32 push_dot1q = 1;
14172 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14174 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14175 sw_if_index_set = 1;
14176 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14177 sw_if_index_set = 1;
14178 else if (unformat (i, "vtr_op %d", &vtr_op))
14180 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
14183 else if (unformat (i, "push_dot1q %d", &push_dot1q))
14185 else if (unformat (i, "tag1 %d", &tag1))
14187 else if (unformat (i, "tag2 %d", &tag2))
14191 clib_warning ("parse error '%U'", format_unformat_error, i);
14196 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
14198 errmsg ("missing vtr operation or sw_if_index");
14202 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
14203 mp->sw_if_index = ntohl (sw_if_index);
14204 mp->vtr_op = ntohl (vtr_op);
14205 mp->push_dot1q = ntohl (push_dot1q);
14206 mp->tag1 = ntohl (tag1);
14207 mp->tag2 = ntohl (tag2);
14215 api_create_vhost_user_if (vat_main_t * vam)
14217 unformat_input_t *i = vam->input;
14218 vl_api_create_vhost_user_if_t *mp;
14221 u8 file_name_set = 0;
14222 u32 custom_dev_instance = ~0;
14224 u8 use_custom_mac = 0;
14225 u8 disable_mrg_rxbuf = 0;
14226 u8 disable_indirect_desc = 0;
14230 /* Shut up coverity */
14231 memset (hwaddr, 0, sizeof (hwaddr));
14233 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14235 if (unformat (i, "socket %s", &file_name))
14239 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
14241 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
14242 use_custom_mac = 1;
14243 else if (unformat (i, "server"))
14245 else if (unformat (i, "disable_mrg_rxbuf"))
14246 disable_mrg_rxbuf = 1;
14247 else if (unformat (i, "disable_indirect_desc"))
14248 disable_indirect_desc = 1;
14249 else if (unformat (i, "tag %s", &tag))
14255 if (file_name_set == 0)
14257 errmsg ("missing socket file name");
14261 if (vec_len (file_name) > 255)
14263 errmsg ("socket file name too long");
14266 vec_add1 (file_name, 0);
14268 M (CREATE_VHOST_USER_IF, mp);
14270 mp->is_server = is_server;
14271 mp->disable_mrg_rxbuf = disable_mrg_rxbuf;
14272 mp->disable_indirect_desc = disable_indirect_desc;
14273 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
14274 vec_free (file_name);
14275 if (custom_dev_instance != ~0)
14278 mp->custom_dev_instance = ntohl (custom_dev_instance);
14281 mp->use_custom_mac = use_custom_mac;
14282 clib_memcpy (mp->mac_address, hwaddr, 6);
14284 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
14293 api_modify_vhost_user_if (vat_main_t * vam)
14295 unformat_input_t *i = vam->input;
14296 vl_api_modify_vhost_user_if_t *mp;
14299 u8 file_name_set = 0;
14300 u32 custom_dev_instance = ~0;
14301 u8 sw_if_index_set = 0;
14302 u32 sw_if_index = (u32) ~ 0;
14305 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14307 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14308 sw_if_index_set = 1;
14309 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14310 sw_if_index_set = 1;
14311 else if (unformat (i, "socket %s", &file_name))
14315 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
14317 else if (unformat (i, "server"))
14323 if (sw_if_index_set == 0)
14325 errmsg ("missing sw_if_index or interface name");
14329 if (file_name_set == 0)
14331 errmsg ("missing socket file name");
14335 if (vec_len (file_name) > 255)
14337 errmsg ("socket file name too long");
14340 vec_add1 (file_name, 0);
14342 M (MODIFY_VHOST_USER_IF, mp);
14344 mp->sw_if_index = ntohl (sw_if_index);
14345 mp->is_server = is_server;
14346 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
14347 vec_free (file_name);
14348 if (custom_dev_instance != ~0)
14351 mp->custom_dev_instance = ntohl (custom_dev_instance);
14360 api_delete_vhost_user_if (vat_main_t * vam)
14362 unformat_input_t *i = vam->input;
14363 vl_api_delete_vhost_user_if_t *mp;
14364 u32 sw_if_index = ~0;
14365 u8 sw_if_index_set = 0;
14368 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14370 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14371 sw_if_index_set = 1;
14372 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14373 sw_if_index_set = 1;
14378 if (sw_if_index_set == 0)
14380 errmsg ("missing sw_if_index or interface name");
14385 M (DELETE_VHOST_USER_IF, mp);
14387 mp->sw_if_index = ntohl (sw_if_index);
14394 static void vl_api_sw_interface_vhost_user_details_t_handler
14395 (vl_api_sw_interface_vhost_user_details_t * mp)
14397 vat_main_t *vam = &vat_main;
14399 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
14400 (char *) mp->interface_name,
14401 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
14402 clib_net_to_host_u64 (mp->features), mp->is_server,
14403 ntohl (mp->num_regions), (char *) mp->sock_filename);
14404 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
14407 static void vl_api_sw_interface_vhost_user_details_t_handler_json
14408 (vl_api_sw_interface_vhost_user_details_t * mp)
14410 vat_main_t *vam = &vat_main;
14411 vat_json_node_t *node = NULL;
14413 if (VAT_JSON_ARRAY != vam->json_tree.type)
14415 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14416 vat_json_init_array (&vam->json_tree);
14418 node = vat_json_array_add (&vam->json_tree);
14420 vat_json_init_object (node);
14421 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14422 vat_json_object_add_string_copy (node, "interface_name",
14423 mp->interface_name);
14424 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
14425 ntohl (mp->virtio_net_hdr_sz));
14426 vat_json_object_add_uint (node, "features",
14427 clib_net_to_host_u64 (mp->features));
14428 vat_json_object_add_uint (node, "is_server", mp->is_server);
14429 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
14430 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
14431 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
14435 api_sw_interface_vhost_user_dump (vat_main_t * vam)
14437 vl_api_sw_interface_vhost_user_dump_t *mp;
14438 vl_api_control_ping_t *mp_ping;
14441 "Interface name idx hdr_sz features server regions filename");
14443 /* Get list of vhost-user interfaces */
14444 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
14447 /* Use a control ping for synchronization */
14448 MPING (CONTROL_PING, mp_ping);
14456 api_show_version (vat_main_t * vam)
14458 vl_api_show_version_t *mp;
14461 M (SHOW_VERSION, mp);
14470 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
14472 unformat_input_t *line_input = vam->input;
14473 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
14474 ip4_address_t local4, remote4;
14475 ip6_address_t local6, remote6;
14477 u8 ipv4_set = 0, ipv6_set = 0;
14481 u32 mcast_sw_if_index = ~0;
14482 u32 encap_vrf_id = 0;
14483 u32 decap_vrf_id = 0;
14489 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
14490 memset (&local4, 0, sizeof local4);
14491 memset (&remote4, 0, sizeof remote4);
14492 memset (&local6, 0, sizeof local6);
14493 memset (&remote6, 0, sizeof remote6);
14495 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14497 if (unformat (line_input, "del"))
14499 else if (unformat (line_input, "local %U",
14500 unformat_ip4_address, &local4))
14505 else if (unformat (line_input, "remote %U",
14506 unformat_ip4_address, &remote4))
14511 else if (unformat (line_input, "local %U",
14512 unformat_ip6_address, &local6))
14517 else if (unformat (line_input, "remote %U",
14518 unformat_ip6_address, &remote6))
14523 else if (unformat (line_input, "group %U %U",
14524 unformat_ip4_address, &remote4,
14525 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14527 grp_set = remote_set = 1;
14530 else if (unformat (line_input, "group %U",
14531 unformat_ip4_address, &remote4))
14533 grp_set = remote_set = 1;
14536 else if (unformat (line_input, "group %U %U",
14537 unformat_ip6_address, &remote6,
14538 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14540 grp_set = remote_set = 1;
14543 else if (unformat (line_input, "group %U",
14544 unformat_ip6_address, &remote6))
14546 grp_set = remote_set = 1;
14550 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
14552 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
14554 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
14556 else if (unformat (line_input, "vni %d", &vni))
14558 else if (unformat (line_input, "next-ip4"))
14560 else if (unformat (line_input, "next-ip6"))
14562 else if (unformat (line_input, "next-ethernet"))
14564 else if (unformat (line_input, "next-nsh"))
14568 errmsg ("parse error '%U'", format_unformat_error, line_input);
14573 if (local_set == 0)
14575 errmsg ("tunnel local address not specified");
14578 if (remote_set == 0)
14580 errmsg ("tunnel remote address not specified");
14583 if (grp_set && mcast_sw_if_index == ~0)
14585 errmsg ("tunnel nonexistent multicast device");
14588 if (ipv4_set && ipv6_set)
14590 errmsg ("both IPv4 and IPv6 addresses specified");
14596 errmsg ("vni not specified");
14600 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
14605 clib_memcpy (&mp->local, &local6, sizeof (local6));
14606 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
14610 clib_memcpy (&mp->local, &local4, sizeof (local4));
14611 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
14614 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
14615 mp->encap_vrf_id = ntohl (encap_vrf_id);
14616 mp->decap_vrf_id = ntohl (decap_vrf_id);
14617 mp->protocol = protocol;
14618 mp->vni = ntohl (vni);
14619 mp->is_add = is_add;
14620 mp->is_ipv6 = ipv6_set;
14627 static void vl_api_vxlan_gpe_tunnel_details_t_handler
14628 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14630 vat_main_t *vam = &vat_main;
14631 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
14632 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
14634 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
14635 ntohl (mp->sw_if_index),
14636 format_ip46_address, &local, IP46_TYPE_ANY,
14637 format_ip46_address, &remote, IP46_TYPE_ANY,
14638 ntohl (mp->vni), mp->protocol,
14639 ntohl (mp->mcast_sw_if_index),
14640 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
14644 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
14645 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14647 vat_main_t *vam = &vat_main;
14648 vat_json_node_t *node = NULL;
14649 struct in_addr ip4;
14650 struct in6_addr ip6;
14652 if (VAT_JSON_ARRAY != vam->json_tree.type)
14654 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14655 vat_json_init_array (&vam->json_tree);
14657 node = vat_json_array_add (&vam->json_tree);
14659 vat_json_init_object (node);
14660 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14663 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
14664 vat_json_object_add_ip6 (node, "local", ip6);
14665 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
14666 vat_json_object_add_ip6 (node, "remote", ip6);
14670 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
14671 vat_json_object_add_ip4 (node, "local", ip4);
14672 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
14673 vat_json_object_add_ip4 (node, "remote", ip4);
14675 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
14676 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
14677 vat_json_object_add_uint (node, "mcast_sw_if_index",
14678 ntohl (mp->mcast_sw_if_index));
14679 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
14680 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
14681 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
14685 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
14687 unformat_input_t *i = vam->input;
14688 vl_api_vxlan_gpe_tunnel_dump_t *mp;
14689 vl_api_control_ping_t *mp_ping;
14691 u8 sw_if_index_set = 0;
14694 /* Parse args required to build the message */
14695 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14697 if (unformat (i, "sw_if_index %d", &sw_if_index))
14698 sw_if_index_set = 1;
14703 if (sw_if_index_set == 0)
14708 if (!vam->json_output)
14710 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
14711 "sw_if_index", "local", "remote", "vni",
14712 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
14715 /* Get list of vxlan-tunnel interfaces */
14716 M (VXLAN_GPE_TUNNEL_DUMP, mp);
14718 mp->sw_if_index = htonl (sw_if_index);
14722 /* Use a control ping for synchronization */
14723 MPING (CONTROL_PING, mp_ping);
14730 static void vl_api_l2_fib_table_details_t_handler
14731 (vl_api_l2_fib_table_details_t * mp)
14733 vat_main_t *vam = &vat_main;
14735 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
14737 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
14738 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
14742 static void vl_api_l2_fib_table_details_t_handler_json
14743 (vl_api_l2_fib_table_details_t * mp)
14745 vat_main_t *vam = &vat_main;
14746 vat_json_node_t *node = NULL;
14748 if (VAT_JSON_ARRAY != vam->json_tree.type)
14750 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14751 vat_json_init_array (&vam->json_tree);
14753 node = vat_json_array_add (&vam->json_tree);
14755 vat_json_init_object (node);
14756 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
14757 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
14758 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14759 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
14760 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
14761 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
14765 api_l2_fib_table_dump (vat_main_t * vam)
14767 unformat_input_t *i = vam->input;
14768 vl_api_l2_fib_table_dump_t *mp;
14769 vl_api_control_ping_t *mp_ping;
14774 /* Parse args required to build the message */
14775 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14777 if (unformat (i, "bd_id %d", &bd_id))
14783 if (bd_id_set == 0)
14785 errmsg ("missing bridge domain");
14789 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
14791 /* Get list of l2 fib entries */
14792 M (L2_FIB_TABLE_DUMP, mp);
14794 mp->bd_id = ntohl (bd_id);
14797 /* Use a control ping for synchronization */
14798 MPING (CONTROL_PING, mp_ping);
14807 api_interface_name_renumber (vat_main_t * vam)
14809 unformat_input_t *line_input = vam->input;
14810 vl_api_interface_name_renumber_t *mp;
14811 u32 sw_if_index = ~0;
14812 u32 new_show_dev_instance = ~0;
14815 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14817 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
14820 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14822 else if (unformat (line_input, "new_show_dev_instance %d",
14823 &new_show_dev_instance))
14829 if (sw_if_index == ~0)
14831 errmsg ("missing interface name or sw_if_index");
14835 if (new_show_dev_instance == ~0)
14837 errmsg ("missing new_show_dev_instance");
14841 M (INTERFACE_NAME_RENUMBER, mp);
14843 mp->sw_if_index = ntohl (sw_if_index);
14844 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
14852 api_ip_probe_neighbor (vat_main_t * vam)
14854 unformat_input_t *i = vam->input;
14855 vl_api_ip_probe_neighbor_t *mp;
14863 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14865 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14867 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14869 else if (unformat (i, "address %U", unformat_ip4_address, dst_adr))
14871 else if (unformat (i, "address %U", unformat_ip6_address, dst_adr))
14882 errmsg ("missing interface");
14888 errmsg ("missing addresses");
14892 M (IP_PROBE_NEIGHBOR, mp);
14894 mp->sw_if_index = ntohl (sw_if_index);
14895 mp->is_ipv6 = is_ipv6;
14896 clib_memcpy (mp->dst_address, dst_adr, sizeof (dst_adr));
14904 api_ip_scan_neighbor_enable_disable (vat_main_t * vam)
14906 unformat_input_t *i = vam->input;
14907 vl_api_ip_scan_neighbor_enable_disable_t *mp;
14908 u8 mode = IP_SCAN_V46_NEIGHBORS;
14909 u32 interval = 0, time = 0, update = 0, delay = 0, stale = 0;
14912 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14914 if (unformat (i, "ip4"))
14915 mode = IP_SCAN_V4_NEIGHBORS;
14916 else if (unformat (i, "ip6"))
14917 mode = IP_SCAN_V6_NEIGHBORS;
14918 if (unformat (i, "both"))
14919 mode = IP_SCAN_V46_NEIGHBORS;
14920 else if (unformat (i, "disable"))
14921 mode = IP_SCAN_DISABLED;
14922 else if (unformat (i, "interval %d", &interval))
14924 else if (unformat (i, "max-time %d", &time))
14926 else if (unformat (i, "max-update %d", &update))
14928 else if (unformat (i, "delay %d", &delay))
14930 else if (unformat (i, "stale %d", &stale))
14936 if (interval > 255)
14938 errmsg ("interval cannot exceed 255 minutes.");
14943 errmsg ("max-time cannot exceed 255 usec.");
14948 errmsg ("max-update cannot exceed 255.");
14953 errmsg ("delay cannot exceed 255 msec.");
14958 errmsg ("stale cannot exceed 255 minutes.");
14962 M (IP_SCAN_NEIGHBOR_ENABLE_DISABLE, mp);
14964 mp->scan_interval = interval;
14965 mp->max_proc_time = time;
14966 mp->max_update = update;
14967 mp->scan_int_delay = delay;
14968 mp->stale_threshold = stale;
14976 api_want_ip4_arp_events (vat_main_t * vam)
14978 unformat_input_t *line_input = vam->input;
14979 vl_api_want_ip4_arp_events_t *mp;
14980 ip4_address_t address;
14981 int address_set = 0;
14982 u32 enable_disable = 1;
14985 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14987 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
14989 else if (unformat (line_input, "del"))
14990 enable_disable = 0;
14995 if (address_set == 0)
14997 errmsg ("missing addresses");
15001 M (WANT_IP4_ARP_EVENTS, mp);
15002 mp->enable_disable = enable_disable;
15003 mp->pid = htonl (getpid ());
15004 mp->address = address.as_u32;
15012 api_want_ip6_nd_events (vat_main_t * vam)
15014 unformat_input_t *line_input = vam->input;
15015 vl_api_want_ip6_nd_events_t *mp;
15016 ip6_address_t address;
15017 int address_set = 0;
15018 u32 enable_disable = 1;
15021 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15023 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
15025 else if (unformat (line_input, "del"))
15026 enable_disable = 0;
15031 if (address_set == 0)
15033 errmsg ("missing addresses");
15037 M (WANT_IP6_ND_EVENTS, mp);
15038 mp->enable_disable = enable_disable;
15039 mp->pid = htonl (getpid ());
15040 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
15048 api_want_l2_macs_events (vat_main_t * vam)
15050 unformat_input_t *line_input = vam->input;
15051 vl_api_want_l2_macs_events_t *mp;
15052 u8 enable_disable = 1;
15053 u32 scan_delay = 0;
15054 u32 max_macs_in_event = 0;
15055 u32 learn_limit = 0;
15058 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15060 if (unformat (line_input, "learn-limit %d", &learn_limit))
15062 else if (unformat (line_input, "scan-delay %d", &scan_delay))
15064 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
15066 else if (unformat (line_input, "disable"))
15067 enable_disable = 0;
15072 M (WANT_L2_MACS_EVENTS, mp);
15073 mp->enable_disable = enable_disable;
15074 mp->pid = htonl (getpid ());
15075 mp->learn_limit = htonl (learn_limit);
15076 mp->scan_delay = (u8) scan_delay;
15077 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
15084 api_input_acl_set_interface (vat_main_t * vam)
15086 unformat_input_t *i = vam->input;
15087 vl_api_input_acl_set_interface_t *mp;
15089 int sw_if_index_set;
15090 u32 ip4_table_index = ~0;
15091 u32 ip6_table_index = ~0;
15092 u32 l2_table_index = ~0;
15096 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15098 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15099 sw_if_index_set = 1;
15100 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15101 sw_if_index_set = 1;
15102 else if (unformat (i, "del"))
15104 else if (unformat (i, "ip4-table %d", &ip4_table_index))
15106 else if (unformat (i, "ip6-table %d", &ip6_table_index))
15108 else if (unformat (i, "l2-table %d", &l2_table_index))
15112 clib_warning ("parse error '%U'", format_unformat_error, i);
15117 if (sw_if_index_set == 0)
15119 errmsg ("missing interface name or sw_if_index");
15123 M (INPUT_ACL_SET_INTERFACE, mp);
15125 mp->sw_if_index = ntohl (sw_if_index);
15126 mp->ip4_table_index = ntohl (ip4_table_index);
15127 mp->ip6_table_index = ntohl (ip6_table_index);
15128 mp->l2_table_index = ntohl (l2_table_index);
15129 mp->is_add = is_add;
15137 api_output_acl_set_interface (vat_main_t * vam)
15139 unformat_input_t *i = vam->input;
15140 vl_api_output_acl_set_interface_t *mp;
15142 int sw_if_index_set;
15143 u32 ip4_table_index = ~0;
15144 u32 ip6_table_index = ~0;
15145 u32 l2_table_index = ~0;
15149 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15151 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15152 sw_if_index_set = 1;
15153 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15154 sw_if_index_set = 1;
15155 else if (unformat (i, "del"))
15157 else if (unformat (i, "ip4-table %d", &ip4_table_index))
15159 else if (unformat (i, "ip6-table %d", &ip6_table_index))
15161 else if (unformat (i, "l2-table %d", &l2_table_index))
15165 clib_warning ("parse error '%U'", format_unformat_error, i);
15170 if (sw_if_index_set == 0)
15172 errmsg ("missing interface name or sw_if_index");
15176 M (OUTPUT_ACL_SET_INTERFACE, mp);
15178 mp->sw_if_index = ntohl (sw_if_index);
15179 mp->ip4_table_index = ntohl (ip4_table_index);
15180 mp->ip6_table_index = ntohl (ip6_table_index);
15181 mp->l2_table_index = ntohl (l2_table_index);
15182 mp->is_add = is_add;
15190 api_ip_address_dump (vat_main_t * vam)
15192 unformat_input_t *i = vam->input;
15193 vl_api_ip_address_dump_t *mp;
15194 vl_api_control_ping_t *mp_ping;
15195 u32 sw_if_index = ~0;
15196 u8 sw_if_index_set = 0;
15201 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15203 if (unformat (i, "sw_if_index %d", &sw_if_index))
15204 sw_if_index_set = 1;
15206 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15207 sw_if_index_set = 1;
15208 else if (unformat (i, "ipv4"))
15210 else if (unformat (i, "ipv6"))
15216 if (ipv4_set && ipv6_set)
15218 errmsg ("ipv4 and ipv6 flags cannot be both set");
15222 if ((!ipv4_set) && (!ipv6_set))
15224 errmsg ("no ipv4 nor ipv6 flag set");
15228 if (sw_if_index_set == 0)
15230 errmsg ("missing interface name or sw_if_index");
15234 vam->current_sw_if_index = sw_if_index;
15235 vam->is_ipv6 = ipv6_set;
15237 M (IP_ADDRESS_DUMP, mp);
15238 mp->sw_if_index = ntohl (sw_if_index);
15239 mp->is_ipv6 = ipv6_set;
15242 /* Use a control ping for synchronization */
15243 MPING (CONTROL_PING, mp_ping);
15251 api_ip_dump (vat_main_t * vam)
15253 vl_api_ip_dump_t *mp;
15254 vl_api_control_ping_t *mp_ping;
15255 unformat_input_t *in = vam->input;
15262 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
15264 if (unformat (in, "ipv4"))
15266 else if (unformat (in, "ipv6"))
15272 if (ipv4_set && ipv6_set)
15274 errmsg ("ipv4 and ipv6 flags cannot be both set");
15278 if ((!ipv4_set) && (!ipv6_set))
15280 errmsg ("no ipv4 nor ipv6 flag set");
15284 is_ipv6 = ipv6_set;
15285 vam->is_ipv6 = is_ipv6;
15287 /* free old data */
15288 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
15290 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
15292 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
15295 mp->is_ipv6 = ipv6_set;
15298 /* Use a control ping for synchronization */
15299 MPING (CONTROL_PING, mp_ping);
15307 api_ipsec_spd_add_del (vat_main_t * vam)
15309 unformat_input_t *i = vam->input;
15310 vl_api_ipsec_spd_add_del_t *mp;
15315 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15317 if (unformat (i, "spd_id %d", &spd_id))
15319 else if (unformat (i, "del"))
15323 clib_warning ("parse error '%U'", format_unformat_error, i);
15329 errmsg ("spd_id must be set");
15333 M (IPSEC_SPD_ADD_DEL, mp);
15335 mp->spd_id = ntohl (spd_id);
15336 mp->is_add = is_add;
15344 api_ipsec_interface_add_del_spd (vat_main_t * vam)
15346 unformat_input_t *i = vam->input;
15347 vl_api_ipsec_interface_add_del_spd_t *mp;
15349 u8 sw_if_index_set = 0;
15350 u32 spd_id = (u32) ~ 0;
15354 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15356 if (unformat (i, "del"))
15358 else if (unformat (i, "spd_id %d", &spd_id))
15361 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15362 sw_if_index_set = 1;
15363 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15364 sw_if_index_set = 1;
15367 clib_warning ("parse error '%U'", format_unformat_error, i);
15373 if (spd_id == (u32) ~ 0)
15375 errmsg ("spd_id must be set");
15379 if (sw_if_index_set == 0)
15381 errmsg ("missing interface name or sw_if_index");
15385 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
15387 mp->spd_id = ntohl (spd_id);
15388 mp->sw_if_index = ntohl (sw_if_index);
15389 mp->is_add = is_add;
15397 api_ipsec_spd_add_del_entry (vat_main_t * vam)
15399 unformat_input_t *i = vam->input;
15400 vl_api_ipsec_spd_add_del_entry_t *mp;
15401 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
15402 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
15404 u32 rport_start = 0, rport_stop = (u32) ~ 0;
15405 u32 lport_start = 0, lport_stop = (u32) ~ 0;
15406 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
15407 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
15410 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
15411 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
15412 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
15413 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
15414 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
15415 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
15417 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15419 if (unformat (i, "del"))
15421 if (unformat (i, "outbound"))
15423 if (unformat (i, "inbound"))
15425 else if (unformat (i, "spd_id %d", &spd_id))
15427 else if (unformat (i, "sa_id %d", &sa_id))
15429 else if (unformat (i, "priority %d", &priority))
15431 else if (unformat (i, "protocol %d", &protocol))
15433 else if (unformat (i, "lport_start %d", &lport_start))
15435 else if (unformat (i, "lport_stop %d", &lport_stop))
15437 else if (unformat (i, "rport_start %d", &rport_start))
15439 else if (unformat (i, "rport_stop %d", &rport_stop))
15443 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
15449 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
15456 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
15462 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
15469 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
15475 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
15482 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
15488 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
15494 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
15496 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
15498 clib_warning ("unsupported action: 'resolve'");
15504 clib_warning ("parse error '%U'", format_unformat_error, i);
15510 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
15512 mp->spd_id = ntohl (spd_id);
15513 mp->priority = ntohl (priority);
15514 mp->is_outbound = is_outbound;
15516 mp->is_ipv6 = is_ipv6;
15517 if (is_ipv6 || is_ip_any)
15519 clib_memcpy (mp->remote_address_start, &raddr6_start,
15520 sizeof (ip6_address_t));
15521 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
15522 sizeof (ip6_address_t));
15523 clib_memcpy (mp->local_address_start, &laddr6_start,
15524 sizeof (ip6_address_t));
15525 clib_memcpy (mp->local_address_stop, &laddr6_stop,
15526 sizeof (ip6_address_t));
15530 clib_memcpy (mp->remote_address_start, &raddr4_start,
15531 sizeof (ip4_address_t));
15532 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
15533 sizeof (ip4_address_t));
15534 clib_memcpy (mp->local_address_start, &laddr4_start,
15535 sizeof (ip4_address_t));
15536 clib_memcpy (mp->local_address_stop, &laddr4_stop,
15537 sizeof (ip4_address_t));
15539 mp->protocol = (u8) protocol;
15540 mp->local_port_start = ntohs ((u16) lport_start);
15541 mp->local_port_stop = ntohs ((u16) lport_stop);
15542 mp->remote_port_start = ntohs ((u16) rport_start);
15543 mp->remote_port_stop = ntohs ((u16) rport_stop);
15544 mp->policy = (u8) policy;
15545 mp->sa_id = ntohl (sa_id);
15546 mp->is_add = is_add;
15547 mp->is_ip_any = is_ip_any;
15554 api_ipsec_sad_add_del_entry (vat_main_t * vam)
15556 unformat_input_t *i = vam->input;
15557 vl_api_ipsec_sad_add_del_entry_t *mp;
15558 u32 sad_id = 0, spi = 0;
15559 u8 *ck = 0, *ik = 0;
15562 u8 protocol = IPSEC_PROTOCOL_AH;
15563 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
15564 u32 crypto_alg = 0, integ_alg = 0;
15565 ip4_address_t tun_src4;
15566 ip4_address_t tun_dst4;
15567 ip6_address_t tun_src6;
15568 ip6_address_t tun_dst6;
15571 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15573 if (unformat (i, "del"))
15575 else if (unformat (i, "sad_id %d", &sad_id))
15577 else if (unformat (i, "spi %d", &spi))
15579 else if (unformat (i, "esp"))
15580 protocol = IPSEC_PROTOCOL_ESP;
15581 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
15584 is_tunnel_ipv6 = 0;
15586 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
15589 is_tunnel_ipv6 = 0;
15591 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
15594 is_tunnel_ipv6 = 1;
15596 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
15599 is_tunnel_ipv6 = 1;
15603 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15605 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
15607 clib_warning ("unsupported crypto-alg: '%U'",
15608 format_ipsec_crypto_alg, crypto_alg);
15612 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15616 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15618 if (integ_alg >= IPSEC_INTEG_N_ALG)
15620 clib_warning ("unsupported integ-alg: '%U'",
15621 format_ipsec_integ_alg, integ_alg);
15625 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15629 clib_warning ("parse error '%U'", format_unformat_error, i);
15635 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
15637 mp->sad_id = ntohl (sad_id);
15638 mp->is_add = is_add;
15639 mp->protocol = protocol;
15640 mp->spi = ntohl (spi);
15641 mp->is_tunnel = is_tunnel;
15642 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
15643 mp->crypto_algorithm = crypto_alg;
15644 mp->integrity_algorithm = integ_alg;
15645 mp->crypto_key_length = vec_len (ck);
15646 mp->integrity_key_length = vec_len (ik);
15648 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15649 mp->crypto_key_length = sizeof (mp->crypto_key);
15651 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15652 mp->integrity_key_length = sizeof (mp->integrity_key);
15655 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15657 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15661 if (is_tunnel_ipv6)
15663 clib_memcpy (mp->tunnel_src_address, &tun_src6,
15664 sizeof (ip6_address_t));
15665 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
15666 sizeof (ip6_address_t));
15670 clib_memcpy (mp->tunnel_src_address, &tun_src4,
15671 sizeof (ip4_address_t));
15672 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
15673 sizeof (ip4_address_t));
15683 api_ipsec_sa_set_key (vat_main_t * vam)
15685 unformat_input_t *i = vam->input;
15686 vl_api_ipsec_sa_set_key_t *mp;
15688 u8 *ck = 0, *ik = 0;
15691 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15693 if (unformat (i, "sa_id %d", &sa_id))
15695 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15697 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15701 clib_warning ("parse error '%U'", format_unformat_error, i);
15706 M (IPSEC_SA_SET_KEY, mp);
15708 mp->sa_id = ntohl (sa_id);
15709 mp->crypto_key_length = vec_len (ck);
15710 mp->integrity_key_length = vec_len (ik);
15712 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15713 mp->crypto_key_length = sizeof (mp->crypto_key);
15715 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15716 mp->integrity_key_length = sizeof (mp->integrity_key);
15719 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15721 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15729 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
15731 unformat_input_t *i = vam->input;
15732 vl_api_ipsec_tunnel_if_add_del_t *mp;
15733 u32 local_spi = 0, remote_spi = 0;
15734 u32 crypto_alg = 0, integ_alg = 0;
15735 u8 *lck = NULL, *rck = NULL;
15736 u8 *lik = NULL, *rik = NULL;
15737 ip4_address_t local_ip = { {0} };
15738 ip4_address_t remote_ip = { {0} };
15741 u8 anti_replay = 0;
15746 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15748 if (unformat (i, "del"))
15750 else if (unformat (i, "esn"))
15752 else if (unformat (i, "anti_replay"))
15754 else if (unformat (i, "local_spi %d", &local_spi))
15756 else if (unformat (i, "remote_spi %d", &remote_spi))
15758 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
15760 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
15762 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
15765 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
15767 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
15769 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
15773 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15775 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
15777 errmsg ("unsupported crypto-alg: '%U'\n",
15778 format_ipsec_crypto_alg, crypto_alg);
15784 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15786 if (integ_alg >= IPSEC_INTEG_N_ALG)
15788 errmsg ("unsupported integ-alg: '%U'\n",
15789 format_ipsec_integ_alg, integ_alg);
15793 else if (unformat (i, "instance %u", &instance))
15797 errmsg ("parse error '%U'\n", format_unformat_error, i);
15802 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
15804 mp->is_add = is_add;
15806 mp->anti_replay = anti_replay;
15808 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
15809 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
15811 mp->local_spi = htonl (local_spi);
15812 mp->remote_spi = htonl (remote_spi);
15813 mp->crypto_alg = (u8) crypto_alg;
15815 mp->local_crypto_key_len = 0;
15818 mp->local_crypto_key_len = vec_len (lck);
15819 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
15820 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
15821 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
15824 mp->remote_crypto_key_len = 0;
15827 mp->remote_crypto_key_len = vec_len (rck);
15828 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
15829 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
15830 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
15833 mp->integ_alg = (u8) integ_alg;
15835 mp->local_integ_key_len = 0;
15838 mp->local_integ_key_len = vec_len (lik);
15839 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
15840 mp->local_integ_key_len = sizeof (mp->local_integ_key);
15841 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
15844 mp->remote_integ_key_len = 0;
15847 mp->remote_integ_key_len = vec_len (rik);
15848 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
15849 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
15850 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
15855 mp->renumber = renumber;
15856 mp->show_instance = ntohl (instance);
15865 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
15867 vat_main_t *vam = &vat_main;
15869 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
15870 "crypto_key %U integ_alg %u integ_key %U use_esn %u "
15871 "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u "
15872 "tunnel_src_addr %U tunnel_dst_addr %U "
15873 "salt %u seq_outbound %lu last_seq_inbound %lu "
15874 "replay_window %lu total_data_size %lu\n",
15875 ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi),
15877 mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len,
15878 mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len,
15879 mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6,
15880 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15881 mp->tunnel_src_addr,
15882 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15883 mp->tunnel_dst_addr,
15885 clib_net_to_host_u64 (mp->seq_outbound),
15886 clib_net_to_host_u64 (mp->last_seq_inbound),
15887 clib_net_to_host_u64 (mp->replay_window),
15888 clib_net_to_host_u64 (mp->total_data_size));
15891 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
15892 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
15894 static void vl_api_ipsec_sa_details_t_handler_json
15895 (vl_api_ipsec_sa_details_t * mp)
15897 vat_main_t *vam = &vat_main;
15898 vat_json_node_t *node = NULL;
15899 struct in_addr src_ip4, dst_ip4;
15900 struct in6_addr src_ip6, dst_ip6;
15902 if (VAT_JSON_ARRAY != vam->json_tree.type)
15904 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15905 vat_json_init_array (&vam->json_tree);
15907 node = vat_json_array_add (&vam->json_tree);
15909 vat_json_init_object (node);
15910 vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id));
15911 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
15912 vat_json_object_add_uint (node, "spi", ntohl (mp->spi));
15913 vat_json_object_add_uint (node, "proto", mp->protocol);
15914 vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg);
15915 vat_json_object_add_uint (node, "integ_alg", mp->integ_alg);
15916 vat_json_object_add_uint (node, "use_esn", mp->use_esn);
15917 vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay);
15918 vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel);
15919 vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6);
15920 vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key,
15921 mp->crypto_key_len);
15922 vat_json_object_add_bytes (node, "integ_key", mp->integ_key,
15923 mp->integ_key_len);
15924 if (mp->is_tunnel_ip6)
15926 clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6));
15927 vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6);
15928 clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6));
15929 vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6);
15933 clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4));
15934 vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4);
15935 clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4));
15936 vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4);
15938 vat_json_object_add_uint (node, "replay_window",
15939 clib_net_to_host_u64 (mp->replay_window));
15940 vat_json_object_add_uint (node, "total_data_size",
15941 clib_net_to_host_u64 (mp->total_data_size));
15946 api_ipsec_sa_dump (vat_main_t * vam)
15948 unformat_input_t *i = vam->input;
15949 vl_api_ipsec_sa_dump_t *mp;
15950 vl_api_control_ping_t *mp_ping;
15954 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15956 if (unformat (i, "sa_id %d", &sa_id))
15960 clib_warning ("parse error '%U'", format_unformat_error, i);
15965 M (IPSEC_SA_DUMP, mp);
15967 mp->sa_id = ntohl (sa_id);
15971 /* Use a control ping for synchronization */
15972 M (CONTROL_PING, mp_ping);
15980 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
15982 unformat_input_t *i = vam->input;
15983 vl_api_ipsec_tunnel_if_set_key_t *mp;
15984 u32 sw_if_index = ~0;
15985 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
15990 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15992 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15995 if (unformat (i, "local crypto %U", unformat_ipsec_crypto_alg, &alg))
15996 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
15998 if (unformat (i, "remote crypto %U", unformat_ipsec_crypto_alg, &alg))
15999 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
16000 else if (unformat (i, "local integ %U", unformat_ipsec_integ_alg, &alg))
16001 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
16003 if (unformat (i, "remote integ %U", unformat_ipsec_integ_alg, &alg))
16004 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
16005 else if (unformat (i, "%U", unformat_hex_string, &key))
16009 clib_warning ("parse error '%U'", format_unformat_error, i);
16014 if (sw_if_index == ~0)
16016 errmsg ("interface must be specified");
16020 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
16022 errmsg ("key type must be specified");
16028 errmsg ("algorithm must be specified");
16032 if (vec_len (key) == 0)
16034 errmsg ("key must be specified");
16038 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
16040 mp->sw_if_index = htonl (sw_if_index);
16042 mp->key_type = key_type;
16043 mp->key_len = vec_len (key);
16044 clib_memcpy (mp->key, key, vec_len (key));
16053 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
16055 unformat_input_t *i = vam->input;
16056 vl_api_ipsec_tunnel_if_set_sa_t *mp;
16057 u32 sw_if_index = ~0;
16059 u8 is_outbound = (u8) ~ 0;
16062 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16064 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16066 else if (unformat (i, "sa_id %d", &sa_id))
16068 else if (unformat (i, "outbound"))
16070 else if (unformat (i, "inbound"))
16074 clib_warning ("parse error '%U'", format_unformat_error, i);
16079 if (sw_if_index == ~0)
16081 errmsg ("interface must be specified");
16087 errmsg ("SA ID must be specified");
16091 M (IPSEC_TUNNEL_IF_SET_SA, mp);
16093 mp->sw_if_index = htonl (sw_if_index);
16094 mp->sa_id = htonl (sa_id);
16095 mp->is_outbound = is_outbound;
16104 api_ikev2_profile_add_del (vat_main_t * vam)
16106 unformat_input_t *i = vam->input;
16107 vl_api_ikev2_profile_add_del_t *mp;
16112 const char *valid_chars = "a-zA-Z0-9_";
16114 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16116 if (unformat (i, "del"))
16118 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
16119 vec_add1 (name, 0);
16122 errmsg ("parse error '%U'", format_unformat_error, i);
16127 if (!vec_len (name))
16129 errmsg ("profile name must be specified");
16133 if (vec_len (name) > 64)
16135 errmsg ("profile name too long");
16139 M (IKEV2_PROFILE_ADD_DEL, mp);
16141 clib_memcpy (mp->name, name, vec_len (name));
16142 mp->is_add = is_add;
16151 api_ikev2_profile_set_auth (vat_main_t * vam)
16153 unformat_input_t *i = vam->input;
16154 vl_api_ikev2_profile_set_auth_t *mp;
16157 u32 auth_method = 0;
16161 const char *valid_chars = "a-zA-Z0-9_";
16163 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16165 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
16166 vec_add1 (name, 0);
16167 else if (unformat (i, "auth_method %U",
16168 unformat_ikev2_auth_method, &auth_method))
16170 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
16172 else if (unformat (i, "auth_data %v", &data))
16176 errmsg ("parse error '%U'", format_unformat_error, i);
16181 if (!vec_len (name))
16183 errmsg ("profile name must be specified");
16187 if (vec_len (name) > 64)
16189 errmsg ("profile name too long");
16193 if (!vec_len (data))
16195 errmsg ("auth_data must be specified");
16201 errmsg ("auth_method must be specified");
16205 M (IKEV2_PROFILE_SET_AUTH, mp);
16207 mp->is_hex = is_hex;
16208 mp->auth_method = (u8) auth_method;
16209 mp->data_len = vec_len (data);
16210 clib_memcpy (mp->name, name, vec_len (name));
16211 clib_memcpy (mp->data, data, vec_len (data));
16221 api_ikev2_profile_set_id (vat_main_t * vam)
16223 unformat_input_t *i = vam->input;
16224 vl_api_ikev2_profile_set_id_t *mp;
16232 const char *valid_chars = "a-zA-Z0-9_";
16234 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16236 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
16237 vec_add1 (name, 0);
16238 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
16240 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
16242 data = vec_new (u8, 4);
16243 clib_memcpy (data, ip4.as_u8, 4);
16245 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
16247 else if (unformat (i, "id_data %v", &data))
16249 else if (unformat (i, "local"))
16251 else if (unformat (i, "remote"))
16255 errmsg ("parse error '%U'", format_unformat_error, i);
16260 if (!vec_len (name))
16262 errmsg ("profile name must be specified");
16266 if (vec_len (name) > 64)
16268 errmsg ("profile name too long");
16272 if (!vec_len (data))
16274 errmsg ("id_data must be specified");
16280 errmsg ("id_type must be specified");
16284 M (IKEV2_PROFILE_SET_ID, mp);
16286 mp->is_local = is_local;
16287 mp->id_type = (u8) id_type;
16288 mp->data_len = vec_len (data);
16289 clib_memcpy (mp->name, name, vec_len (name));
16290 clib_memcpy (mp->data, data, vec_len (data));
16300 api_ikev2_profile_set_ts (vat_main_t * vam)
16302 unformat_input_t *i = vam->input;
16303 vl_api_ikev2_profile_set_ts_t *mp;
16306 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
16307 ip4_address_t start_addr, end_addr;
16309 const char *valid_chars = "a-zA-Z0-9_";
16312 start_addr.as_u32 = 0;
16313 end_addr.as_u32 = (u32) ~ 0;
16315 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16317 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
16318 vec_add1 (name, 0);
16319 else if (unformat (i, "protocol %d", &proto))
16321 else if (unformat (i, "start_port %d", &start_port))
16323 else if (unformat (i, "end_port %d", &end_port))
16326 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
16328 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
16330 else if (unformat (i, "local"))
16332 else if (unformat (i, "remote"))
16336 errmsg ("parse error '%U'", format_unformat_error, i);
16341 if (!vec_len (name))
16343 errmsg ("profile name must be specified");
16347 if (vec_len (name) > 64)
16349 errmsg ("profile name too long");
16353 M (IKEV2_PROFILE_SET_TS, mp);
16355 mp->is_local = is_local;
16356 mp->proto = (u8) proto;
16357 mp->start_port = (u16) start_port;
16358 mp->end_port = (u16) end_port;
16359 mp->start_addr = start_addr.as_u32;
16360 mp->end_addr = end_addr.as_u32;
16361 clib_memcpy (mp->name, name, vec_len (name));
16370 api_ikev2_set_local_key (vat_main_t * vam)
16372 unformat_input_t *i = vam->input;
16373 vl_api_ikev2_set_local_key_t *mp;
16377 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16379 if (unformat (i, "file %v", &file))
16380 vec_add1 (file, 0);
16383 errmsg ("parse error '%U'", format_unformat_error, i);
16388 if (!vec_len (file))
16390 errmsg ("RSA key file must be specified");
16394 if (vec_len (file) > 256)
16396 errmsg ("file name too long");
16400 M (IKEV2_SET_LOCAL_KEY, mp);
16402 clib_memcpy (mp->key_file, file, vec_len (file));
16411 api_ikev2_set_responder (vat_main_t * vam)
16413 unformat_input_t *i = vam->input;
16414 vl_api_ikev2_set_responder_t *mp;
16417 u32 sw_if_index = ~0;
16418 ip4_address_t address;
16420 const char *valid_chars = "a-zA-Z0-9_";
16422 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16425 (i, "%U interface %d address %U", unformat_token, valid_chars,
16426 &name, &sw_if_index, unformat_ip4_address, &address))
16427 vec_add1 (name, 0);
16430 errmsg ("parse error '%U'", format_unformat_error, i);
16435 if (!vec_len (name))
16437 errmsg ("profile name must be specified");
16441 if (vec_len (name) > 64)
16443 errmsg ("profile name too long");
16447 M (IKEV2_SET_RESPONDER, mp);
16449 clib_memcpy (mp->name, name, vec_len (name));
16452 mp->sw_if_index = sw_if_index;
16453 clib_memcpy (mp->address, &address, sizeof (address));
16461 api_ikev2_set_ike_transforms (vat_main_t * vam)
16463 unformat_input_t *i = vam->input;
16464 vl_api_ikev2_set_ike_transforms_t *mp;
16467 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
16469 const char *valid_chars = "a-zA-Z0-9_";
16471 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16473 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
16474 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
16475 vec_add1 (name, 0);
16478 errmsg ("parse error '%U'", format_unformat_error, i);
16483 if (!vec_len (name))
16485 errmsg ("profile name must be specified");
16489 if (vec_len (name) > 64)
16491 errmsg ("profile name too long");
16495 M (IKEV2_SET_IKE_TRANSFORMS, mp);
16497 clib_memcpy (mp->name, name, vec_len (name));
16499 mp->crypto_alg = crypto_alg;
16500 mp->crypto_key_size = crypto_key_size;
16501 mp->integ_alg = integ_alg;
16502 mp->dh_group = dh_group;
16511 api_ikev2_set_esp_transforms (vat_main_t * vam)
16513 unformat_input_t *i = vam->input;
16514 vl_api_ikev2_set_esp_transforms_t *mp;
16517 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
16519 const char *valid_chars = "a-zA-Z0-9_";
16521 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16523 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
16524 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
16525 vec_add1 (name, 0);
16528 errmsg ("parse error '%U'", format_unformat_error, i);
16533 if (!vec_len (name))
16535 errmsg ("profile name must be specified");
16539 if (vec_len (name) > 64)
16541 errmsg ("profile name too long");
16545 M (IKEV2_SET_ESP_TRANSFORMS, mp);
16547 clib_memcpy (mp->name, name, vec_len (name));
16549 mp->crypto_alg = crypto_alg;
16550 mp->crypto_key_size = crypto_key_size;
16551 mp->integ_alg = integ_alg;
16552 mp->dh_group = dh_group;
16560 api_ikev2_set_sa_lifetime (vat_main_t * vam)
16562 unformat_input_t *i = vam->input;
16563 vl_api_ikev2_set_sa_lifetime_t *mp;
16566 u64 lifetime, lifetime_maxdata;
16567 u32 lifetime_jitter, handover;
16569 const char *valid_chars = "a-zA-Z0-9_";
16571 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16573 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
16574 &lifetime, &lifetime_jitter, &handover,
16575 &lifetime_maxdata))
16576 vec_add1 (name, 0);
16579 errmsg ("parse error '%U'", format_unformat_error, i);
16584 if (!vec_len (name))
16586 errmsg ("profile name must be specified");
16590 if (vec_len (name) > 64)
16592 errmsg ("profile name too long");
16596 M (IKEV2_SET_SA_LIFETIME, mp);
16598 clib_memcpy (mp->name, name, vec_len (name));
16600 mp->lifetime = lifetime;
16601 mp->lifetime_jitter = lifetime_jitter;
16602 mp->handover = handover;
16603 mp->lifetime_maxdata = lifetime_maxdata;
16611 api_ikev2_initiate_sa_init (vat_main_t * vam)
16613 unformat_input_t *i = vam->input;
16614 vl_api_ikev2_initiate_sa_init_t *mp;
16618 const char *valid_chars = "a-zA-Z0-9_";
16620 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16622 if (unformat (i, "%U", unformat_token, valid_chars, &name))
16623 vec_add1 (name, 0);
16626 errmsg ("parse error '%U'", format_unformat_error, i);
16631 if (!vec_len (name))
16633 errmsg ("profile name must be specified");
16637 if (vec_len (name) > 64)
16639 errmsg ("profile name too long");
16643 M (IKEV2_INITIATE_SA_INIT, mp);
16645 clib_memcpy (mp->name, name, vec_len (name));
16654 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
16656 unformat_input_t *i = vam->input;
16657 vl_api_ikev2_initiate_del_ike_sa_t *mp;
16662 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16664 if (unformat (i, "%lx", &ispi))
16668 errmsg ("parse error '%U'", format_unformat_error, i);
16673 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
16683 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
16685 unformat_input_t *i = vam->input;
16686 vl_api_ikev2_initiate_del_child_sa_t *mp;
16691 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16693 if (unformat (i, "%x", &ispi))
16697 errmsg ("parse error '%U'", format_unformat_error, i);
16702 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
16712 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
16714 unformat_input_t *i = vam->input;
16715 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
16720 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16722 if (unformat (i, "%x", &ispi))
16726 errmsg ("parse error '%U'", format_unformat_error, i);
16731 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
16741 api_get_first_msg_id (vat_main_t * vam)
16743 vl_api_get_first_msg_id_t *mp;
16744 unformat_input_t *i = vam->input;
16749 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16751 if (unformat (i, "client %s", &name))
16759 errmsg ("missing client name");
16762 vec_add1 (name, 0);
16764 if (vec_len (name) > 63)
16766 errmsg ("client name too long");
16770 M (GET_FIRST_MSG_ID, mp);
16771 clib_memcpy (mp->name, name, vec_len (name));
16778 api_cop_interface_enable_disable (vat_main_t * vam)
16780 unformat_input_t *line_input = vam->input;
16781 vl_api_cop_interface_enable_disable_t *mp;
16782 u32 sw_if_index = ~0;
16783 u8 enable_disable = 1;
16786 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16788 if (unformat (line_input, "disable"))
16789 enable_disable = 0;
16790 if (unformat (line_input, "enable"))
16791 enable_disable = 1;
16792 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16793 vam, &sw_if_index))
16795 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16801 if (sw_if_index == ~0)
16803 errmsg ("missing interface name or sw_if_index");
16807 /* Construct the API message */
16808 M (COP_INTERFACE_ENABLE_DISABLE, mp);
16809 mp->sw_if_index = ntohl (sw_if_index);
16810 mp->enable_disable = enable_disable;
16814 /* Wait for the reply */
16820 api_cop_whitelist_enable_disable (vat_main_t * vam)
16822 unformat_input_t *line_input = vam->input;
16823 vl_api_cop_whitelist_enable_disable_t *mp;
16824 u32 sw_if_index = ~0;
16825 u8 ip4 = 0, ip6 = 0, default_cop = 0;
16829 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16831 if (unformat (line_input, "ip4"))
16833 else if (unformat (line_input, "ip6"))
16835 else if (unformat (line_input, "default"))
16837 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16838 vam, &sw_if_index))
16840 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16842 else if (unformat (line_input, "fib-id %d", &fib_id))
16848 if (sw_if_index == ~0)
16850 errmsg ("missing interface name or sw_if_index");
16854 /* Construct the API message */
16855 M (COP_WHITELIST_ENABLE_DISABLE, mp);
16856 mp->sw_if_index = ntohl (sw_if_index);
16857 mp->fib_id = ntohl (fib_id);
16860 mp->default_cop = default_cop;
16864 /* Wait for the reply */
16870 api_get_node_graph (vat_main_t * vam)
16872 vl_api_get_node_graph_t *mp;
16875 M (GET_NODE_GRAPH, mp);
16879 /* Wait for the reply */
16885 /** Used for parsing LISP eids */
16886 typedef CLIB_PACKED(struct{
16887 u8 addr[16]; /**< eid address */
16888 u32 len; /**< prefix length if IP */
16889 u8 type; /**< type of eid */
16894 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
16896 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
16898 memset (a, 0, sizeof (a[0]));
16900 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
16902 a->type = 0; /* ipv4 type */
16904 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
16906 a->type = 1; /* ipv6 type */
16908 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
16910 a->type = 2; /* mac type */
16912 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
16914 a->type = 3; /* NSH type */
16915 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
16916 nsh->spi = clib_host_to_net_u32 (nsh->spi);
16923 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
16932 lisp_eid_size_vat (u8 type)
16949 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
16951 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
16955 api_one_add_del_locator_set (vat_main_t * vam)
16957 unformat_input_t *input = vam->input;
16958 vl_api_one_add_del_locator_set_t *mp;
16960 u8 *locator_set_name = NULL;
16961 u8 locator_set_name_set = 0;
16962 vl_api_local_locator_t locator, *locators = 0;
16963 u32 sw_if_index, priority, weight;
16967 /* Parse args required to build the message */
16968 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16970 if (unformat (input, "del"))
16974 else if (unformat (input, "locator-set %s", &locator_set_name))
16976 locator_set_name_set = 1;
16978 else if (unformat (input, "sw_if_index %u p %u w %u",
16979 &sw_if_index, &priority, &weight))
16981 locator.sw_if_index = htonl (sw_if_index);
16982 locator.priority = priority;
16983 locator.weight = weight;
16984 vec_add1 (locators, locator);
16988 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
16989 &sw_if_index, &priority, &weight))
16991 locator.sw_if_index = htonl (sw_if_index);
16992 locator.priority = priority;
16993 locator.weight = weight;
16994 vec_add1 (locators, locator);
17000 if (locator_set_name_set == 0)
17002 errmsg ("missing locator-set name");
17003 vec_free (locators);
17007 if (vec_len (locator_set_name) > 64)
17009 errmsg ("locator-set name too long");
17010 vec_free (locator_set_name);
17011 vec_free (locators);
17014 vec_add1 (locator_set_name, 0);
17016 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
17018 /* Construct the API message */
17019 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
17021 mp->is_add = is_add;
17022 clib_memcpy (mp->locator_set_name, locator_set_name,
17023 vec_len (locator_set_name));
17024 vec_free (locator_set_name);
17026 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
17028 clib_memcpy (mp->locators, locators, data_len);
17029 vec_free (locators);
17034 /* Wait for a reply... */
17039 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
17042 api_one_add_del_locator (vat_main_t * vam)
17044 unformat_input_t *input = vam->input;
17045 vl_api_one_add_del_locator_t *mp;
17046 u32 tmp_if_index = ~0;
17047 u32 sw_if_index = ~0;
17048 u8 sw_if_index_set = 0;
17049 u8 sw_if_index_if_name_set = 0;
17051 u8 priority_set = 0;
17055 u8 *locator_set_name = NULL;
17056 u8 locator_set_name_set = 0;
17059 /* Parse args required to build the message */
17060 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17062 if (unformat (input, "del"))
17066 else if (unformat (input, "locator-set %s", &locator_set_name))
17068 locator_set_name_set = 1;
17070 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
17073 sw_if_index_if_name_set = 1;
17074 sw_if_index = tmp_if_index;
17076 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
17078 sw_if_index_set = 1;
17079 sw_if_index = tmp_if_index;
17081 else if (unformat (input, "p %d", &priority))
17085 else if (unformat (input, "w %d", &weight))
17093 if (locator_set_name_set == 0)
17095 errmsg ("missing locator-set name");
17099 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
17101 errmsg ("missing sw_if_index");
17102 vec_free (locator_set_name);
17106 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
17108 errmsg ("cannot use both params interface name and sw_if_index");
17109 vec_free (locator_set_name);
17113 if (priority_set == 0)
17115 errmsg ("missing locator-set priority");
17116 vec_free (locator_set_name);
17120 if (weight_set == 0)
17122 errmsg ("missing locator-set weight");
17123 vec_free (locator_set_name);
17127 if (vec_len (locator_set_name) > 64)
17129 errmsg ("locator-set name too long");
17130 vec_free (locator_set_name);
17133 vec_add1 (locator_set_name, 0);
17135 /* Construct the API message */
17136 M (ONE_ADD_DEL_LOCATOR, mp);
17138 mp->is_add = is_add;
17139 mp->sw_if_index = ntohl (sw_if_index);
17140 mp->priority = priority;
17141 mp->weight = weight;
17142 clib_memcpy (mp->locator_set_name, locator_set_name,
17143 vec_len (locator_set_name));
17144 vec_free (locator_set_name);
17149 /* Wait for a reply... */
17154 #define api_lisp_add_del_locator api_one_add_del_locator
17157 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
17159 u32 *key_id = va_arg (*args, u32 *);
17162 if (unformat (input, "%s", &s))
17164 if (!strcmp ((char *) s, "sha1"))
17165 key_id[0] = HMAC_SHA_1_96;
17166 else if (!strcmp ((char *) s, "sha256"))
17167 key_id[0] = HMAC_SHA_256_128;
17170 clib_warning ("invalid key_id: '%s'", s);
17171 key_id[0] = HMAC_NO_KEY;
17182 api_one_add_del_local_eid (vat_main_t * vam)
17184 unformat_input_t *input = vam->input;
17185 vl_api_one_add_del_local_eid_t *mp;
17188 lisp_eid_vat_t _eid, *eid = &_eid;
17189 u8 *locator_set_name = 0;
17190 u8 locator_set_name_set = 0;
17196 /* Parse args required to build the message */
17197 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17199 if (unformat (input, "del"))
17203 else if (unformat (input, "vni %d", &vni))
17207 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
17211 else if (unformat (input, "locator-set %s", &locator_set_name))
17213 locator_set_name_set = 1;
17215 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
17217 else if (unformat (input, "secret-key %_%v%_", &key))
17223 if (locator_set_name_set == 0)
17225 errmsg ("missing locator-set name");
17231 errmsg ("EID address not set!");
17232 vec_free (locator_set_name);
17236 if (key && (0 == key_id))
17238 errmsg ("invalid key_id!");
17242 if (vec_len (key) > 64)
17244 errmsg ("key too long");
17249 if (vec_len (locator_set_name) > 64)
17251 errmsg ("locator-set name too long");
17252 vec_free (locator_set_name);
17255 vec_add1 (locator_set_name, 0);
17257 /* Construct the API message */
17258 M (ONE_ADD_DEL_LOCAL_EID, mp);
17260 mp->is_add = is_add;
17261 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
17262 mp->eid_type = eid->type;
17263 mp->prefix_len = eid->len;
17264 mp->vni = clib_host_to_net_u32 (vni);
17265 mp->key_id = clib_host_to_net_u16 (key_id);
17266 clib_memcpy (mp->locator_set_name, locator_set_name,
17267 vec_len (locator_set_name));
17268 clib_memcpy (mp->key, key, vec_len (key));
17270 vec_free (locator_set_name);
17276 /* Wait for a reply... */
17281 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
17284 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
17286 u32 dp_table = 0, vni = 0;;
17287 unformat_input_t *input = vam->input;
17288 vl_api_gpe_add_del_fwd_entry_t *mp;
17290 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
17291 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
17292 u8 rmt_eid_set = 0, lcl_eid_set = 0;
17293 u32 action = ~0, w;
17294 ip4_address_t rmt_rloc4, lcl_rloc4;
17295 ip6_address_t rmt_rloc6, lcl_rloc6;
17296 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
17299 memset (&rloc, 0, sizeof (rloc));
17301 /* Parse args required to build the message */
17302 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17304 if (unformat (input, "del"))
17306 else if (unformat (input, "add"))
17308 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
17312 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
17316 else if (unformat (input, "vrf %d", &dp_table))
17318 else if (unformat (input, "bd %d", &dp_table))
17320 else if (unformat (input, "vni %d", &vni))
17322 else if (unformat (input, "w %d", &w))
17326 errmsg ("No RLOC configured for setting priority/weight!");
17329 curr_rloc->weight = w;
17331 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
17332 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
17336 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
17338 vec_add1 (lcl_locs, rloc);
17340 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
17341 vec_add1 (rmt_locs, rloc);
17342 /* weight saved in rmt loc */
17343 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
17345 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
17346 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
17349 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
17351 vec_add1 (lcl_locs, rloc);
17353 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
17354 vec_add1 (rmt_locs, rloc);
17355 /* weight saved in rmt loc */
17356 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
17358 else if (unformat (input, "action %d", &action))
17364 clib_warning ("parse error '%U'", format_unformat_error, input);
17371 errmsg ("remote eid addresses not set");
17375 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
17377 errmsg ("eid types don't match");
17381 if (0 == rmt_locs && (u32) ~ 0 == action)
17383 errmsg ("action not set for negative mapping");
17387 /* Construct the API message */
17388 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
17389 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
17391 mp->is_add = is_add;
17392 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
17393 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
17394 mp->eid_type = rmt_eid->type;
17395 mp->dp_table = clib_host_to_net_u32 (dp_table);
17396 mp->vni = clib_host_to_net_u32 (vni);
17397 mp->rmt_len = rmt_eid->len;
17398 mp->lcl_len = lcl_eid->len;
17399 mp->action = action;
17401 if (0 != rmt_locs && 0 != lcl_locs)
17403 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
17404 clib_memcpy (mp->locs, lcl_locs,
17405 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
17407 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
17408 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
17409 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
17411 vec_free (lcl_locs);
17412 vec_free (rmt_locs);
17417 /* Wait for a reply... */
17423 api_one_add_del_map_server (vat_main_t * vam)
17425 unformat_input_t *input = vam->input;
17426 vl_api_one_add_del_map_server_t *mp;
17430 ip4_address_t ipv4;
17431 ip6_address_t ipv6;
17434 /* Parse args required to build the message */
17435 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17437 if (unformat (input, "del"))
17441 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17445 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17453 if (ipv4_set && ipv6_set)
17455 errmsg ("both eid v4 and v6 addresses set");
17459 if (!ipv4_set && !ipv6_set)
17461 errmsg ("eid addresses not set");
17465 /* Construct the API message */
17466 M (ONE_ADD_DEL_MAP_SERVER, mp);
17468 mp->is_add = is_add;
17472 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17477 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17483 /* Wait for a reply... */
17488 #define api_lisp_add_del_map_server api_one_add_del_map_server
17491 api_one_add_del_map_resolver (vat_main_t * vam)
17493 unformat_input_t *input = vam->input;
17494 vl_api_one_add_del_map_resolver_t *mp;
17498 ip4_address_t ipv4;
17499 ip6_address_t ipv6;
17502 /* Parse args required to build the message */
17503 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17505 if (unformat (input, "del"))
17509 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17513 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17521 if (ipv4_set && ipv6_set)
17523 errmsg ("both eid v4 and v6 addresses set");
17527 if (!ipv4_set && !ipv6_set)
17529 errmsg ("eid addresses not set");
17533 /* Construct the API message */
17534 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
17536 mp->is_add = is_add;
17540 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17545 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17551 /* Wait for a reply... */
17556 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
17559 api_lisp_gpe_enable_disable (vat_main_t * vam)
17561 unformat_input_t *input = vam->input;
17562 vl_api_gpe_enable_disable_t *mp;
17567 /* Parse args required to build the message */
17568 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17570 if (unformat (input, "enable"))
17575 else if (unformat (input, "disable"))
17586 errmsg ("Value not set");
17590 /* Construct the API message */
17591 M (GPE_ENABLE_DISABLE, mp);
17598 /* Wait for a reply... */
17604 api_one_rloc_probe_enable_disable (vat_main_t * vam)
17606 unformat_input_t *input = vam->input;
17607 vl_api_one_rloc_probe_enable_disable_t *mp;
17612 /* Parse args required to build the message */
17613 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17615 if (unformat (input, "enable"))
17620 else if (unformat (input, "disable"))
17628 errmsg ("Value not set");
17632 /* Construct the API message */
17633 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
17635 mp->is_enabled = is_en;
17640 /* Wait for a reply... */
17645 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
17648 api_one_map_register_enable_disable (vat_main_t * vam)
17650 unformat_input_t *input = vam->input;
17651 vl_api_one_map_register_enable_disable_t *mp;
17656 /* Parse args required to build the message */
17657 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17659 if (unformat (input, "enable"))
17664 else if (unformat (input, "disable"))
17672 errmsg ("Value not set");
17676 /* Construct the API message */
17677 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
17679 mp->is_enabled = is_en;
17684 /* Wait for a reply... */
17689 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
17692 api_one_enable_disable (vat_main_t * vam)
17694 unformat_input_t *input = vam->input;
17695 vl_api_one_enable_disable_t *mp;
17700 /* Parse args required to build the message */
17701 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17703 if (unformat (input, "enable"))
17708 else if (unformat (input, "disable"))
17718 errmsg ("Value not set");
17722 /* Construct the API message */
17723 M (ONE_ENABLE_DISABLE, mp);
17730 /* Wait for a reply... */
17735 #define api_lisp_enable_disable api_one_enable_disable
17738 api_one_enable_disable_xtr_mode (vat_main_t * vam)
17740 unformat_input_t *input = vam->input;
17741 vl_api_one_enable_disable_xtr_mode_t *mp;
17746 /* Parse args required to build the message */
17747 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17749 if (unformat (input, "enable"))
17754 else if (unformat (input, "disable"))
17764 errmsg ("Value not set");
17768 /* Construct the API message */
17769 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
17776 /* Wait for a reply... */
17782 api_one_show_xtr_mode (vat_main_t * vam)
17784 vl_api_one_show_xtr_mode_t *mp;
17787 /* Construct the API message */
17788 M (ONE_SHOW_XTR_MODE, mp);
17793 /* Wait for a reply... */
17799 api_one_enable_disable_pitr_mode (vat_main_t * vam)
17801 unformat_input_t *input = vam->input;
17802 vl_api_one_enable_disable_pitr_mode_t *mp;
17807 /* Parse args required to build the message */
17808 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17810 if (unformat (input, "enable"))
17815 else if (unformat (input, "disable"))
17825 errmsg ("Value not set");
17829 /* Construct the API message */
17830 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
17837 /* Wait for a reply... */
17843 api_one_show_pitr_mode (vat_main_t * vam)
17845 vl_api_one_show_pitr_mode_t *mp;
17848 /* Construct the API message */
17849 M (ONE_SHOW_PITR_MODE, mp);
17854 /* Wait for a reply... */
17860 api_one_enable_disable_petr_mode (vat_main_t * vam)
17862 unformat_input_t *input = vam->input;
17863 vl_api_one_enable_disable_petr_mode_t *mp;
17868 /* Parse args required to build the message */
17869 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17871 if (unformat (input, "enable"))
17876 else if (unformat (input, "disable"))
17886 errmsg ("Value not set");
17890 /* Construct the API message */
17891 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
17898 /* Wait for a reply... */
17904 api_one_show_petr_mode (vat_main_t * vam)
17906 vl_api_one_show_petr_mode_t *mp;
17909 /* Construct the API message */
17910 M (ONE_SHOW_PETR_MODE, mp);
17915 /* Wait for a reply... */
17921 api_show_one_map_register_state (vat_main_t * vam)
17923 vl_api_show_one_map_register_state_t *mp;
17926 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
17931 /* wait for reply */
17936 #define api_show_lisp_map_register_state api_show_one_map_register_state
17939 api_show_one_rloc_probe_state (vat_main_t * vam)
17941 vl_api_show_one_rloc_probe_state_t *mp;
17944 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
17949 /* wait for reply */
17954 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
17957 api_one_add_del_ndp_entry (vat_main_t * vam)
17959 vl_api_one_add_del_ndp_entry_t *mp;
17960 unformat_input_t *input = vam->input;
17965 u8 mac[6] = { 0, };
17966 u8 ip6[16] = { 0, };
17970 /* Parse args required to build the message */
17971 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17973 if (unformat (input, "del"))
17975 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17977 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
17979 else if (unformat (input, "bd %d", &bd))
17983 errmsg ("parse error '%U'", format_unformat_error, input);
17988 if (!bd_set || !ip_set || (!mac_set && is_add))
17990 errmsg ("Missing BD, IP or MAC!");
17994 M (ONE_ADD_DEL_NDP_ENTRY, mp);
17995 mp->is_add = is_add;
17996 clib_memcpy (mp->mac, mac, 6);
17997 mp->bd = clib_host_to_net_u32 (bd);
17998 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
18003 /* wait for reply */
18009 api_one_add_del_l2_arp_entry (vat_main_t * vam)
18011 vl_api_one_add_del_l2_arp_entry_t *mp;
18012 unformat_input_t *input = vam->input;
18017 u8 mac[6] = { 0, };
18018 u32 ip4 = 0, bd = ~0;
18021 /* Parse args required to build the message */
18022 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18024 if (unformat (input, "del"))
18026 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
18028 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
18030 else if (unformat (input, "bd %d", &bd))
18034 errmsg ("parse error '%U'", format_unformat_error, input);
18039 if (!bd_set || !ip_set || (!mac_set && is_add))
18041 errmsg ("Missing BD, IP or MAC!");
18045 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
18046 mp->is_add = is_add;
18047 clib_memcpy (mp->mac, mac, 6);
18048 mp->bd = clib_host_to_net_u32 (bd);
18054 /* wait for reply */
18060 api_one_ndp_bd_get (vat_main_t * vam)
18062 vl_api_one_ndp_bd_get_t *mp;
18065 M (ONE_NDP_BD_GET, mp);
18070 /* wait for reply */
18076 api_one_ndp_entries_get (vat_main_t * vam)
18078 vl_api_one_ndp_entries_get_t *mp;
18079 unformat_input_t *input = vam->input;
18084 /* Parse args required to build the message */
18085 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18087 if (unformat (input, "bd %d", &bd))
18091 errmsg ("parse error '%U'", format_unformat_error, input);
18098 errmsg ("Expected bridge domain!");
18102 M (ONE_NDP_ENTRIES_GET, mp);
18103 mp->bd = clib_host_to_net_u32 (bd);
18108 /* wait for reply */
18114 api_one_l2_arp_bd_get (vat_main_t * vam)
18116 vl_api_one_l2_arp_bd_get_t *mp;
18119 M (ONE_L2_ARP_BD_GET, mp);
18124 /* wait for reply */
18130 api_one_l2_arp_entries_get (vat_main_t * vam)
18132 vl_api_one_l2_arp_entries_get_t *mp;
18133 unformat_input_t *input = vam->input;
18138 /* Parse args required to build the message */
18139 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18141 if (unformat (input, "bd %d", &bd))
18145 errmsg ("parse error '%U'", format_unformat_error, input);
18152 errmsg ("Expected bridge domain!");
18156 M (ONE_L2_ARP_ENTRIES_GET, mp);
18157 mp->bd = clib_host_to_net_u32 (bd);
18162 /* wait for reply */
18168 api_one_stats_enable_disable (vat_main_t * vam)
18170 vl_api_one_stats_enable_disable_t *mp;
18171 unformat_input_t *input = vam->input;
18176 /* Parse args required to build the message */
18177 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18179 if (unformat (input, "enable"))
18184 else if (unformat (input, "disable"))
18194 errmsg ("Value not set");
18198 M (ONE_STATS_ENABLE_DISABLE, mp);
18204 /* wait for reply */
18210 api_show_one_stats_enable_disable (vat_main_t * vam)
18212 vl_api_show_one_stats_enable_disable_t *mp;
18215 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
18220 /* wait for reply */
18226 api_show_one_map_request_mode (vat_main_t * vam)
18228 vl_api_show_one_map_request_mode_t *mp;
18231 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
18236 /* wait for reply */
18241 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
18244 api_one_map_request_mode (vat_main_t * vam)
18246 unformat_input_t *input = vam->input;
18247 vl_api_one_map_request_mode_t *mp;
18251 /* Parse args required to build the message */
18252 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18254 if (unformat (input, "dst-only"))
18256 else if (unformat (input, "src-dst"))
18260 errmsg ("parse error '%U'", format_unformat_error, input);
18265 M (ONE_MAP_REQUEST_MODE, mp);
18272 /* wait for reply */
18277 #define api_lisp_map_request_mode api_one_map_request_mode
18280 * Enable/disable ONE proxy ITR.
18282 * @param vam vpp API test context
18283 * @return return code
18286 api_one_pitr_set_locator_set (vat_main_t * vam)
18288 u8 ls_name_set = 0;
18289 unformat_input_t *input = vam->input;
18290 vl_api_one_pitr_set_locator_set_t *mp;
18295 /* Parse args required to build the message */
18296 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18298 if (unformat (input, "del"))
18300 else if (unformat (input, "locator-set %s", &ls_name))
18304 errmsg ("parse error '%U'", format_unformat_error, input);
18311 errmsg ("locator-set name not set!");
18315 M (ONE_PITR_SET_LOCATOR_SET, mp);
18317 mp->is_add = is_add;
18318 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
18319 vec_free (ls_name);
18324 /* wait for reply */
18329 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
18332 api_one_nsh_set_locator_set (vat_main_t * vam)
18334 u8 ls_name_set = 0;
18335 unformat_input_t *input = vam->input;
18336 vl_api_one_nsh_set_locator_set_t *mp;
18341 /* Parse args required to build the message */
18342 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18344 if (unformat (input, "del"))
18346 else if (unformat (input, "ls %s", &ls_name))
18350 errmsg ("parse error '%U'", format_unformat_error, input);
18355 if (!ls_name_set && is_add)
18357 errmsg ("locator-set name not set!");
18361 M (ONE_NSH_SET_LOCATOR_SET, mp);
18363 mp->is_add = is_add;
18364 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
18365 vec_free (ls_name);
18370 /* wait for reply */
18376 api_show_one_pitr (vat_main_t * vam)
18378 vl_api_show_one_pitr_t *mp;
18381 if (!vam->json_output)
18383 print (vam->ofp, "%=20s", "lisp status:");
18386 M (SHOW_ONE_PITR, mp);
18390 /* Wait for a reply... */
18395 #define api_show_lisp_pitr api_show_one_pitr
18398 api_one_use_petr (vat_main_t * vam)
18400 unformat_input_t *input = vam->input;
18401 vl_api_one_use_petr_t *mp;
18406 memset (&ip, 0, sizeof (ip));
18408 /* Parse args required to build the message */
18409 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18411 if (unformat (input, "disable"))
18414 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
18417 ip_addr_version (&ip) = IP4;
18420 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
18423 ip_addr_version (&ip) = IP6;
18427 errmsg ("parse error '%U'", format_unformat_error, input);
18432 M (ONE_USE_PETR, mp);
18434 mp->is_add = is_add;
18437 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
18439 clib_memcpy (mp->address, &ip, 4);
18441 clib_memcpy (mp->address, &ip, 16);
18447 /* wait for reply */
18452 #define api_lisp_use_petr api_one_use_petr
18455 api_show_one_nsh_mapping (vat_main_t * vam)
18457 vl_api_show_one_use_petr_t *mp;
18460 if (!vam->json_output)
18462 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
18465 M (SHOW_ONE_NSH_MAPPING, mp);
18469 /* Wait for a reply... */
18475 api_show_one_use_petr (vat_main_t * vam)
18477 vl_api_show_one_use_petr_t *mp;
18480 if (!vam->json_output)
18482 print (vam->ofp, "%=20s", "Proxy-ETR status:");
18485 M (SHOW_ONE_USE_PETR, mp);
18489 /* Wait for a reply... */
18494 #define api_show_lisp_use_petr api_show_one_use_petr
18497 * Add/delete mapping between vni and vrf
18500 api_one_eid_table_add_del_map (vat_main_t * vam)
18502 unformat_input_t *input = vam->input;
18503 vl_api_one_eid_table_add_del_map_t *mp;
18504 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
18505 u32 vni, vrf, bd_index;
18508 /* Parse args required to build the message */
18509 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18511 if (unformat (input, "del"))
18513 else if (unformat (input, "vrf %d", &vrf))
18515 else if (unformat (input, "bd_index %d", &bd_index))
18517 else if (unformat (input, "vni %d", &vni))
18523 if (!vni_set || (!vrf_set && !bd_index_set))
18525 errmsg ("missing arguments!");
18529 if (vrf_set && bd_index_set)
18531 errmsg ("error: both vrf and bd entered!");
18535 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
18537 mp->is_add = is_add;
18538 mp->vni = htonl (vni);
18539 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
18540 mp->is_l2 = bd_index_set;
18545 /* wait for reply */
18550 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
18553 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
18555 u32 *action = va_arg (*args, u32 *);
18558 if (unformat (input, "%s", &s))
18560 if (!strcmp ((char *) s, "no-action"))
18562 else if (!strcmp ((char *) s, "natively-forward"))
18564 else if (!strcmp ((char *) s, "send-map-request"))
18566 else if (!strcmp ((char *) s, "drop"))
18570 clib_warning ("invalid action: '%s'", s);
18582 * Add/del remote mapping to/from ONE control plane
18584 * @param vam vpp API test context
18585 * @return return code
18588 api_one_add_del_remote_mapping (vat_main_t * vam)
18590 unformat_input_t *input = vam->input;
18591 vl_api_one_add_del_remote_mapping_t *mp;
18593 lisp_eid_vat_t _eid, *eid = &_eid;
18594 lisp_eid_vat_t _seid, *seid = &_seid;
18595 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
18596 u32 action = ~0, p, w, data_len;
18597 ip4_address_t rloc4;
18598 ip6_address_t rloc6;
18599 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
18602 memset (&rloc, 0, sizeof (rloc));
18604 /* Parse args required to build the message */
18605 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18607 if (unformat (input, "del-all"))
18611 else if (unformat (input, "del"))
18615 else if (unformat (input, "add"))
18619 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
18623 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
18627 else if (unformat (input, "vni %d", &vni))
18631 else if (unformat (input, "p %d w %d", &p, &w))
18635 errmsg ("No RLOC configured for setting priority/weight!");
18638 curr_rloc->priority = p;
18639 curr_rloc->weight = w;
18641 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
18644 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
18645 vec_add1 (rlocs, rloc);
18646 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18648 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
18651 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
18652 vec_add1 (rlocs, rloc);
18653 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18655 else if (unformat (input, "action %U",
18656 unformat_negative_mapping_action, &action))
18662 clib_warning ("parse error '%U'", format_unformat_error, input);
18669 errmsg ("missing params!");
18673 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
18675 errmsg ("no action set for negative map-reply!");
18679 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
18681 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
18682 mp->is_add = is_add;
18683 mp->vni = htonl (vni);
18684 mp->action = (u8) action;
18685 mp->is_src_dst = seid_set;
18686 mp->eid_len = eid->len;
18687 mp->seid_len = seid->len;
18688 mp->del_all = del_all;
18689 mp->eid_type = eid->type;
18690 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
18691 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
18693 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
18694 clib_memcpy (mp->rlocs, rlocs, data_len);
18700 /* Wait for a reply... */
18705 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
18708 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
18709 * forwarding entries in data-plane accordingly.
18711 * @param vam vpp API test context
18712 * @return return code
18715 api_one_add_del_adjacency (vat_main_t * vam)
18717 unformat_input_t *input = vam->input;
18718 vl_api_one_add_del_adjacency_t *mp;
18720 ip4_address_t leid4, reid4;
18721 ip6_address_t leid6, reid6;
18722 u8 reid_mac[6] = { 0 };
18723 u8 leid_mac[6] = { 0 };
18724 u8 reid_type, leid_type;
18725 u32 leid_len = 0, reid_len = 0, len;
18729 leid_type = reid_type = (u8) ~ 0;
18731 /* Parse args required to build the message */
18732 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18734 if (unformat (input, "del"))
18738 else if (unformat (input, "add"))
18742 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
18745 reid_type = 0; /* ipv4 */
18748 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
18751 reid_type = 1; /* ipv6 */
18754 else if (unformat (input, "reid %U", unformat_ethernet_address,
18757 reid_type = 2; /* mac */
18759 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
18762 leid_type = 0; /* ipv4 */
18765 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
18768 leid_type = 1; /* ipv6 */
18771 else if (unformat (input, "leid %U", unformat_ethernet_address,
18774 leid_type = 2; /* mac */
18776 else if (unformat (input, "vni %d", &vni))
18782 errmsg ("parse error '%U'", format_unformat_error, input);
18787 if ((u8) ~ 0 == reid_type)
18789 errmsg ("missing params!");
18793 if (leid_type != reid_type)
18795 errmsg ("remote and local EIDs are of different types!");
18799 M (ONE_ADD_DEL_ADJACENCY, mp);
18800 mp->is_add = is_add;
18801 mp->vni = htonl (vni);
18802 mp->leid_len = leid_len;
18803 mp->reid_len = reid_len;
18804 mp->eid_type = reid_type;
18806 switch (mp->eid_type)
18809 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
18810 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
18813 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
18814 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
18817 clib_memcpy (mp->leid, leid_mac, 6);
18818 clib_memcpy (mp->reid, reid_mac, 6);
18821 errmsg ("unknown EID type %d!", mp->eid_type);
18828 /* Wait for a reply... */
18833 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
18836 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
18838 u32 *mode = va_arg (*args, u32 *);
18840 if (unformat (input, "lisp"))
18842 else if (unformat (input, "vxlan"))
18851 api_gpe_get_encap_mode (vat_main_t * vam)
18853 vl_api_gpe_get_encap_mode_t *mp;
18856 /* Construct the API message */
18857 M (GPE_GET_ENCAP_MODE, mp);
18862 /* Wait for a reply... */
18868 api_gpe_set_encap_mode (vat_main_t * vam)
18870 unformat_input_t *input = vam->input;
18871 vl_api_gpe_set_encap_mode_t *mp;
18875 /* Parse args required to build the message */
18876 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18878 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
18884 /* Construct the API message */
18885 M (GPE_SET_ENCAP_MODE, mp);
18892 /* Wait for a reply... */
18898 api_lisp_gpe_add_del_iface (vat_main_t * vam)
18900 unformat_input_t *input = vam->input;
18901 vl_api_gpe_add_del_iface_t *mp;
18902 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
18903 u32 dp_table = 0, vni = 0;
18906 /* Parse args required to build the message */
18907 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18909 if (unformat (input, "up"))
18914 else if (unformat (input, "down"))
18919 else if (unformat (input, "table_id %d", &dp_table))
18923 else if (unformat (input, "bd_id %d", &dp_table))
18928 else if (unformat (input, "vni %d", &vni))
18936 if (action_set == 0)
18938 errmsg ("Action not set");
18941 if (dp_table_set == 0 || vni_set == 0)
18943 errmsg ("vni and dp_table must be set");
18947 /* Construct the API message */
18948 M (GPE_ADD_DEL_IFACE, mp);
18950 mp->is_add = is_add;
18951 mp->dp_table = clib_host_to_net_u32 (dp_table);
18953 mp->vni = clib_host_to_net_u32 (vni);
18958 /* Wait for a reply... */
18964 api_one_map_register_fallback_threshold (vat_main_t * vam)
18966 unformat_input_t *input = vam->input;
18967 vl_api_one_map_register_fallback_threshold_t *mp;
18972 /* Parse args required to build the message */
18973 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18975 if (unformat (input, "%u", &value))
18979 clib_warning ("parse error '%U'", format_unformat_error, input);
18986 errmsg ("fallback threshold value is missing!");
18990 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18991 mp->value = clib_host_to_net_u32 (value);
18996 /* Wait for a reply... */
19002 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
19004 vl_api_show_one_map_register_fallback_threshold_t *mp;
19007 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
19012 /* Wait for a reply... */
19018 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
19020 u32 *proto = va_arg (*args, u32 *);
19022 if (unformat (input, "udp"))
19024 else if (unformat (input, "api"))
19033 api_one_set_transport_protocol (vat_main_t * vam)
19035 unformat_input_t *input = vam->input;
19036 vl_api_one_set_transport_protocol_t *mp;
19041 /* Parse args required to build the message */
19042 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19044 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
19048 clib_warning ("parse error '%U'", format_unformat_error, input);
19055 errmsg ("Transport protocol missing!");
19059 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
19060 mp->protocol = (u8) protocol;
19065 /* Wait for a reply... */
19071 api_one_get_transport_protocol (vat_main_t * vam)
19073 vl_api_one_get_transport_protocol_t *mp;
19076 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
19081 /* Wait for a reply... */
19087 api_one_map_register_set_ttl (vat_main_t * vam)
19089 unformat_input_t *input = vam->input;
19090 vl_api_one_map_register_set_ttl_t *mp;
19095 /* Parse args required to build the message */
19096 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19098 if (unformat (input, "%u", &ttl))
19102 clib_warning ("parse error '%U'", format_unformat_error, input);
19109 errmsg ("TTL value missing!");
19113 M (ONE_MAP_REGISTER_SET_TTL, mp);
19114 mp->ttl = clib_host_to_net_u32 (ttl);
19119 /* Wait for a reply... */
19125 api_show_one_map_register_ttl (vat_main_t * vam)
19127 vl_api_show_one_map_register_ttl_t *mp;
19130 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
19135 /* Wait for a reply... */
19141 * Add/del map request itr rlocs from ONE control plane and updates
19143 * @param vam vpp API test context
19144 * @return return code
19147 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
19149 unformat_input_t *input = vam->input;
19150 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
19151 u8 *locator_set_name = 0;
19152 u8 locator_set_name_set = 0;
19156 /* Parse args required to build the message */
19157 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19159 if (unformat (input, "del"))
19163 else if (unformat (input, "%_%v%_", &locator_set_name))
19165 locator_set_name_set = 1;
19169 clib_warning ("parse error '%U'", format_unformat_error, input);
19174 if (is_add && !locator_set_name_set)
19176 errmsg ("itr-rloc is not set!");
19180 if (is_add && vec_len (locator_set_name) > 64)
19182 errmsg ("itr-rloc locator-set name too long");
19183 vec_free (locator_set_name);
19187 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
19188 mp->is_add = is_add;
19191 clib_memcpy (mp->locator_set_name, locator_set_name,
19192 vec_len (locator_set_name));
19196 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
19198 vec_free (locator_set_name);
19203 /* Wait for a reply... */
19208 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
19211 api_one_locator_dump (vat_main_t * vam)
19213 unformat_input_t *input = vam->input;
19214 vl_api_one_locator_dump_t *mp;
19215 vl_api_control_ping_t *mp_ping;
19216 u8 is_index_set = 0, is_name_set = 0;
19221 /* Parse args required to build the message */
19222 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19224 if (unformat (input, "ls_name %_%v%_", &ls_name))
19228 else if (unformat (input, "ls_index %d", &ls_index))
19234 errmsg ("parse error '%U'", format_unformat_error, input);
19239 if (!is_index_set && !is_name_set)
19241 errmsg ("error: expected one of index or name!");
19245 if (is_index_set && is_name_set)
19247 errmsg ("error: only one param expected!");
19251 if (vec_len (ls_name) > 62)
19253 errmsg ("error: locator set name too long!");
19257 if (!vam->json_output)
19259 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
19262 M (ONE_LOCATOR_DUMP, mp);
19263 mp->is_index_set = is_index_set;
19266 mp->ls_index = clib_host_to_net_u32 (ls_index);
19269 vec_add1 (ls_name, 0);
19270 strncpy ((char *) mp->ls_name, (char *) ls_name,
19271 sizeof (mp->ls_name) - 1);
19277 /* Use a control ping for synchronization */
19278 MPING (CONTROL_PING, mp_ping);
19281 /* Wait for a reply... */
19286 #define api_lisp_locator_dump api_one_locator_dump
19289 api_one_locator_set_dump (vat_main_t * vam)
19291 vl_api_one_locator_set_dump_t *mp;
19292 vl_api_control_ping_t *mp_ping;
19293 unformat_input_t *input = vam->input;
19297 /* Parse args required to build the message */
19298 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19300 if (unformat (input, "local"))
19304 else if (unformat (input, "remote"))
19310 errmsg ("parse error '%U'", format_unformat_error, input);
19315 if (!vam->json_output)
19317 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
19320 M (ONE_LOCATOR_SET_DUMP, mp);
19322 mp->filter = filter;
19327 /* Use a control ping for synchronization */
19328 MPING (CONTROL_PING, mp_ping);
19331 /* Wait for a reply... */
19336 #define api_lisp_locator_set_dump api_one_locator_set_dump
19339 api_one_eid_table_map_dump (vat_main_t * vam)
19343 unformat_input_t *input = vam->input;
19344 vl_api_one_eid_table_map_dump_t *mp;
19345 vl_api_control_ping_t *mp_ping;
19348 /* Parse args required to build the message */
19349 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19351 if (unformat (input, "l2"))
19356 else if (unformat (input, "l3"))
19363 errmsg ("parse error '%U'", format_unformat_error, input);
19370 errmsg ("expected one of 'l2' or 'l3' parameter!");
19374 if (!vam->json_output)
19376 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
19379 M (ONE_EID_TABLE_MAP_DUMP, mp);
19385 /* Use a control ping for synchronization */
19386 MPING (CONTROL_PING, mp_ping);
19389 /* Wait for a reply... */
19394 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
19397 api_one_eid_table_vni_dump (vat_main_t * vam)
19399 vl_api_one_eid_table_vni_dump_t *mp;
19400 vl_api_control_ping_t *mp_ping;
19403 if (!vam->json_output)
19405 print (vam->ofp, "VNI");
19408 M (ONE_EID_TABLE_VNI_DUMP, mp);
19413 /* Use a control ping for synchronization */
19414 MPING (CONTROL_PING, mp_ping);
19417 /* Wait for a reply... */
19422 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
19425 api_one_eid_table_dump (vat_main_t * vam)
19427 unformat_input_t *i = vam->input;
19428 vl_api_one_eid_table_dump_t *mp;
19429 vl_api_control_ping_t *mp_ping;
19430 struct in_addr ip4;
19431 struct in6_addr ip6;
19433 u8 eid_type = ~0, eid_set = 0;
19434 u32 prefix_length = ~0, t, vni = 0;
19437 lisp_nsh_api_t nsh;
19439 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19441 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
19447 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
19453 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
19458 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
19463 else if (unformat (i, "vni %d", &t))
19467 else if (unformat (i, "local"))
19471 else if (unformat (i, "remote"))
19477 errmsg ("parse error '%U'", format_unformat_error, i);
19482 if (!vam->json_output)
19484 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
19485 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
19488 M (ONE_EID_TABLE_DUMP, mp);
19490 mp->filter = filter;
19494 mp->vni = htonl (vni);
19495 mp->eid_type = eid_type;
19499 mp->prefix_length = prefix_length;
19500 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
19503 mp->prefix_length = prefix_length;
19504 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
19507 clib_memcpy (mp->eid, mac, sizeof (mac));
19510 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
19513 errmsg ("unknown EID type %d!", eid_type);
19521 /* Use a control ping for synchronization */
19522 MPING (CONTROL_PING, mp_ping);
19525 /* Wait for a reply... */
19530 #define api_lisp_eid_table_dump api_one_eid_table_dump
19533 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
19535 unformat_input_t *i = vam->input;
19536 vl_api_gpe_fwd_entries_get_t *mp;
19541 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19543 if (unformat (i, "vni %d", &vni))
19549 errmsg ("parse error '%U'", format_unformat_error, i);
19556 errmsg ("vni not set!");
19560 if (!vam->json_output)
19562 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
19566 M (GPE_FWD_ENTRIES_GET, mp);
19567 mp->vni = clib_host_to_net_u32 (vni);
19572 /* Wait for a reply... */
19577 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
19578 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
19579 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
19580 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
19581 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
19582 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
19583 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
19584 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
19587 api_one_adjacencies_get (vat_main_t * vam)
19589 unformat_input_t *i = vam->input;
19590 vl_api_one_adjacencies_get_t *mp;
19595 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19597 if (unformat (i, "vni %d", &vni))
19603 errmsg ("parse error '%U'", format_unformat_error, i);
19610 errmsg ("vni not set!");
19614 if (!vam->json_output)
19616 print (vam->ofp, "%s %40s", "leid", "reid");
19619 M (ONE_ADJACENCIES_GET, mp);
19620 mp->vni = clib_host_to_net_u32 (vni);
19625 /* Wait for a reply... */
19630 #define api_lisp_adjacencies_get api_one_adjacencies_get
19633 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
19635 unformat_input_t *i = vam->input;
19636 vl_api_gpe_native_fwd_rpaths_get_t *mp;
19638 u8 ip_family_set = 0, is_ip4 = 1;
19640 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19642 if (unformat (i, "ip4"))
19647 else if (unformat (i, "ip6"))
19654 errmsg ("parse error '%U'", format_unformat_error, i);
19659 if (!ip_family_set)
19661 errmsg ("ip family not set!");
19665 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
19666 mp->is_ip4 = is_ip4;
19671 /* Wait for a reply... */
19677 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
19679 vl_api_gpe_fwd_entry_vnis_get_t *mp;
19682 if (!vam->json_output)
19684 print (vam->ofp, "VNIs");
19687 M (GPE_FWD_ENTRY_VNIS_GET, mp);
19692 /* Wait for a reply... */
19698 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
19700 unformat_input_t *i = vam->input;
19701 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
19703 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
19704 struct in_addr ip4;
19705 struct in6_addr ip6;
19706 u32 table_id = 0, nh_sw_if_index = ~0;
19708 memset (&ip4, 0, sizeof (ip4));
19709 memset (&ip6, 0, sizeof (ip6));
19711 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19713 if (unformat (i, "del"))
19715 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
19716 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19721 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
19722 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19727 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
19731 nh_sw_if_index = ~0;
19733 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
19737 nh_sw_if_index = ~0;
19739 else if (unformat (i, "table %d", &table_id))
19743 errmsg ("parse error '%U'", format_unformat_error, i);
19750 errmsg ("nh addr not set!");
19754 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
19755 mp->is_add = is_add;
19756 mp->table_id = clib_host_to_net_u32 (table_id);
19757 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
19758 mp->is_ip4 = is_ip4;
19760 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
19762 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
19767 /* Wait for a reply... */
19773 api_one_map_server_dump (vat_main_t * vam)
19775 vl_api_one_map_server_dump_t *mp;
19776 vl_api_control_ping_t *mp_ping;
19779 if (!vam->json_output)
19781 print (vam->ofp, "%=20s", "Map server");
19784 M (ONE_MAP_SERVER_DUMP, mp);
19788 /* Use a control ping for synchronization */
19789 MPING (CONTROL_PING, mp_ping);
19792 /* Wait for a reply... */
19797 #define api_lisp_map_server_dump api_one_map_server_dump
19800 api_one_map_resolver_dump (vat_main_t * vam)
19802 vl_api_one_map_resolver_dump_t *mp;
19803 vl_api_control_ping_t *mp_ping;
19806 if (!vam->json_output)
19808 print (vam->ofp, "%=20s", "Map resolver");
19811 M (ONE_MAP_RESOLVER_DUMP, mp);
19815 /* Use a control ping for synchronization */
19816 MPING (CONTROL_PING, mp_ping);
19819 /* Wait for a reply... */
19824 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
19827 api_one_stats_flush (vat_main_t * vam)
19829 vl_api_one_stats_flush_t *mp;
19832 M (ONE_STATS_FLUSH, mp);
19839 api_one_stats_dump (vat_main_t * vam)
19841 vl_api_one_stats_dump_t *mp;
19842 vl_api_control_ping_t *mp_ping;
19845 M (ONE_STATS_DUMP, mp);
19849 /* Use a control ping for synchronization */
19850 MPING (CONTROL_PING, mp_ping);
19853 /* Wait for a reply... */
19859 api_show_one_status (vat_main_t * vam)
19861 vl_api_show_one_status_t *mp;
19864 if (!vam->json_output)
19866 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
19869 M (SHOW_ONE_STATUS, mp);
19872 /* Wait for a reply... */
19877 #define api_show_lisp_status api_show_one_status
19880 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
19882 vl_api_gpe_fwd_entry_path_dump_t *mp;
19883 vl_api_control_ping_t *mp_ping;
19884 unformat_input_t *i = vam->input;
19885 u32 fwd_entry_index = ~0;
19888 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19890 if (unformat (i, "index %d", &fwd_entry_index))
19896 if (~0 == fwd_entry_index)
19898 errmsg ("no index specified!");
19902 if (!vam->json_output)
19904 print (vam->ofp, "first line");
19907 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
19911 /* Use a control ping for synchronization */
19912 MPING (CONTROL_PING, mp_ping);
19915 /* Wait for a reply... */
19921 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
19923 vl_api_one_get_map_request_itr_rlocs_t *mp;
19926 if (!vam->json_output)
19928 print (vam->ofp, "%=20s", "itr-rlocs:");
19931 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
19934 /* Wait for a reply... */
19939 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
19942 api_af_packet_create (vat_main_t * vam)
19944 unformat_input_t *i = vam->input;
19945 vl_api_af_packet_create_t *mp;
19946 u8 *host_if_name = 0;
19948 u8 random_hw_addr = 1;
19951 memset (hw_addr, 0, sizeof (hw_addr));
19953 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19955 if (unformat (i, "name %s", &host_if_name))
19956 vec_add1 (host_if_name, 0);
19957 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19958 random_hw_addr = 0;
19963 if (!vec_len (host_if_name))
19965 errmsg ("host-interface name must be specified");
19969 if (vec_len (host_if_name) > 64)
19971 errmsg ("host-interface name too long");
19975 M (AF_PACKET_CREATE, mp);
19977 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19978 clib_memcpy (mp->hw_addr, hw_addr, 6);
19979 mp->use_random_hw_addr = random_hw_addr;
19980 vec_free (host_if_name);
19988 fprintf (vam->ofp ? vam->ofp : stderr,
19989 " new sw_if_index = %d\n", vam->sw_if_index);
19996 api_af_packet_delete (vat_main_t * vam)
19998 unformat_input_t *i = vam->input;
19999 vl_api_af_packet_delete_t *mp;
20000 u8 *host_if_name = 0;
20003 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20005 if (unformat (i, "name %s", &host_if_name))
20006 vec_add1 (host_if_name, 0);
20011 if (!vec_len (host_if_name))
20013 errmsg ("host-interface name must be specified");
20017 if (vec_len (host_if_name) > 64)
20019 errmsg ("host-interface name too long");
20023 M (AF_PACKET_DELETE, mp);
20025 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
20026 vec_free (host_if_name);
20033 static void vl_api_af_packet_details_t_handler
20034 (vl_api_af_packet_details_t * mp)
20036 vat_main_t *vam = &vat_main;
20038 print (vam->ofp, "%-16s %d",
20039 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
20042 static void vl_api_af_packet_details_t_handler_json
20043 (vl_api_af_packet_details_t * mp)
20045 vat_main_t *vam = &vat_main;
20046 vat_json_node_t *node = NULL;
20048 if (VAT_JSON_ARRAY != vam->json_tree.type)
20050 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20051 vat_json_init_array (&vam->json_tree);
20053 node = vat_json_array_add (&vam->json_tree);
20055 vat_json_init_object (node);
20056 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
20057 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
20061 api_af_packet_dump (vat_main_t * vam)
20063 vl_api_af_packet_dump_t *mp;
20064 vl_api_control_ping_t *mp_ping;
20067 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
20068 /* Get list of tap interfaces */
20069 M (AF_PACKET_DUMP, mp);
20072 /* Use a control ping for synchronization */
20073 MPING (CONTROL_PING, mp_ping);
20081 api_policer_add_del (vat_main_t * vam)
20083 unformat_input_t *i = vam->input;
20084 vl_api_policer_add_del_t *mp;
20094 u8 color_aware = 0;
20095 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
20098 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
20099 conform_action.dscp = 0;
20100 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
20101 exceed_action.dscp = 0;
20102 violate_action.action_type = SSE2_QOS_ACTION_DROP;
20103 violate_action.dscp = 0;
20105 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20107 if (unformat (i, "del"))
20109 else if (unformat (i, "name %s", &name))
20110 vec_add1 (name, 0);
20111 else if (unformat (i, "cir %u", &cir))
20113 else if (unformat (i, "eir %u", &eir))
20115 else if (unformat (i, "cb %u", &cb))
20117 else if (unformat (i, "eb %u", &eb))
20119 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
20122 else if (unformat (i, "round_type %U", unformat_policer_round_type,
20125 else if (unformat (i, "type %U", unformat_policer_type, &type))
20127 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
20130 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
20133 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
20136 else if (unformat (i, "color-aware"))
20142 if (!vec_len (name))
20144 errmsg ("policer name must be specified");
20148 if (vec_len (name) > 64)
20150 errmsg ("policer name too long");
20154 M (POLICER_ADD_DEL, mp);
20156 clib_memcpy (mp->name, name, vec_len (name));
20158 mp->is_add = is_add;
20159 mp->cir = ntohl (cir);
20160 mp->eir = ntohl (eir);
20161 mp->cb = clib_net_to_host_u64 (cb);
20162 mp->eb = clib_net_to_host_u64 (eb);
20163 mp->rate_type = rate_type;
20164 mp->round_type = round_type;
20166 mp->conform_action_type = conform_action.action_type;
20167 mp->conform_dscp = conform_action.dscp;
20168 mp->exceed_action_type = exceed_action.action_type;
20169 mp->exceed_dscp = exceed_action.dscp;
20170 mp->violate_action_type = violate_action.action_type;
20171 mp->violate_dscp = violate_action.dscp;
20172 mp->color_aware = color_aware;
20180 api_policer_dump (vat_main_t * vam)
20182 unformat_input_t *i = vam->input;
20183 vl_api_policer_dump_t *mp;
20184 vl_api_control_ping_t *mp_ping;
20185 u8 *match_name = 0;
20186 u8 match_name_valid = 0;
20189 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20191 if (unformat (i, "name %s", &match_name))
20193 vec_add1 (match_name, 0);
20194 match_name_valid = 1;
20200 M (POLICER_DUMP, mp);
20201 mp->match_name_valid = match_name_valid;
20202 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
20203 vec_free (match_name);
20207 /* Use a control ping for synchronization */
20208 MPING (CONTROL_PING, mp_ping);
20211 /* Wait for a reply... */
20217 api_policer_classify_set_interface (vat_main_t * vam)
20219 unformat_input_t *i = vam->input;
20220 vl_api_policer_classify_set_interface_t *mp;
20222 int sw_if_index_set;
20223 u32 ip4_table_index = ~0;
20224 u32 ip6_table_index = ~0;
20225 u32 l2_table_index = ~0;
20229 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20231 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20232 sw_if_index_set = 1;
20233 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20234 sw_if_index_set = 1;
20235 else if (unformat (i, "del"))
20237 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20239 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20241 else if (unformat (i, "l2-table %d", &l2_table_index))
20245 clib_warning ("parse error '%U'", format_unformat_error, i);
20250 if (sw_if_index_set == 0)
20252 errmsg ("missing interface name or sw_if_index");
20256 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
20258 mp->sw_if_index = ntohl (sw_if_index);
20259 mp->ip4_table_index = ntohl (ip4_table_index);
20260 mp->ip6_table_index = ntohl (ip6_table_index);
20261 mp->l2_table_index = ntohl (l2_table_index);
20262 mp->is_add = is_add;
20270 api_policer_classify_dump (vat_main_t * vam)
20272 unformat_input_t *i = vam->input;
20273 vl_api_policer_classify_dump_t *mp;
20274 vl_api_control_ping_t *mp_ping;
20275 u8 type = POLICER_CLASSIFY_N_TABLES;
20278 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
20282 errmsg ("classify table type must be specified");
20286 if (!vam->json_output)
20288 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20291 M (POLICER_CLASSIFY_DUMP, mp);
20296 /* Use a control ping for synchronization */
20297 MPING (CONTROL_PING, mp_ping);
20300 /* Wait for a reply... */
20306 api_netmap_create (vat_main_t * vam)
20308 unformat_input_t *i = vam->input;
20309 vl_api_netmap_create_t *mp;
20312 u8 random_hw_addr = 1;
20317 memset (hw_addr, 0, sizeof (hw_addr));
20319 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20321 if (unformat (i, "name %s", &if_name))
20322 vec_add1 (if_name, 0);
20323 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
20324 random_hw_addr = 0;
20325 else if (unformat (i, "pipe"))
20327 else if (unformat (i, "master"))
20329 else if (unformat (i, "slave"))
20335 if (!vec_len (if_name))
20337 errmsg ("interface name must be specified");
20341 if (vec_len (if_name) > 64)
20343 errmsg ("interface name too long");
20347 M (NETMAP_CREATE, mp);
20349 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20350 clib_memcpy (mp->hw_addr, hw_addr, 6);
20351 mp->use_random_hw_addr = random_hw_addr;
20352 mp->is_pipe = is_pipe;
20353 mp->is_master = is_master;
20354 vec_free (if_name);
20362 api_netmap_delete (vat_main_t * vam)
20364 unformat_input_t *i = vam->input;
20365 vl_api_netmap_delete_t *mp;
20369 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20371 if (unformat (i, "name %s", &if_name))
20372 vec_add1 (if_name, 0);
20377 if (!vec_len (if_name))
20379 errmsg ("interface name must be specified");
20383 if (vec_len (if_name) > 64)
20385 errmsg ("interface name too long");
20389 M (NETMAP_DELETE, mp);
20391 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20392 vec_free (if_name);
20400 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
20402 if (fp->afi == IP46_TYPE_IP6)
20404 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20405 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20406 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20407 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20408 format_ip6_address, fp->next_hop);
20409 else if (fp->afi == IP46_TYPE_IP4)
20411 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20412 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20413 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20414 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20415 format_ip4_address, fp->next_hop);
20419 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
20420 vl_api_fib_path_t * fp)
20422 struct in_addr ip4;
20423 struct in6_addr ip6;
20425 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20426 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20427 vat_json_object_add_uint (node, "is_local", fp->is_local);
20428 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20429 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20430 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20431 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20432 if (fp->afi == IP46_TYPE_IP4)
20434 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20435 vat_json_object_add_ip4 (node, "next_hop", ip4);
20437 else if (fp->afi == IP46_TYPE_IP6)
20439 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20440 vat_json_object_add_ip6 (node, "next_hop", ip6);
20445 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
20447 vat_main_t *vam = &vat_main;
20448 int count = ntohl (mp->mt_count);
20449 vl_api_fib_path_t *fp;
20452 print (vam->ofp, "[%d]: sw_if_index %d via:",
20453 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
20455 for (i = 0; i < count; i++)
20457 vl_api_mpls_fib_path_print (vam, fp);
20461 print (vam->ofp, "");
20464 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
20465 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
20468 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
20470 vat_main_t *vam = &vat_main;
20471 vat_json_node_t *node = NULL;
20472 int count = ntohl (mp->mt_count);
20473 vl_api_fib_path_t *fp;
20476 if (VAT_JSON_ARRAY != vam->json_tree.type)
20478 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20479 vat_json_init_array (&vam->json_tree);
20481 node = vat_json_array_add (&vam->json_tree);
20483 vat_json_init_object (node);
20484 vat_json_object_add_uint (node, "tunnel_index",
20485 ntohl (mp->mt_tunnel_index));
20486 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
20488 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
20491 for (i = 0; i < count; i++)
20493 vl_api_mpls_fib_path_json_print (node, fp);
20499 api_mpls_tunnel_dump (vat_main_t * vam)
20501 vl_api_mpls_tunnel_dump_t *mp;
20502 vl_api_control_ping_t *mp_ping;
20503 u32 sw_if_index = ~0;
20506 /* Parse args required to build the message */
20507 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
20509 if (unformat (vam->input, "sw_if_index %d", &sw_if_index))
20513 print (vam->ofp, " sw_if_index %d", sw_if_index);
20515 M (MPLS_TUNNEL_DUMP, mp);
20516 mp->sw_if_index = htonl (sw_if_index);
20519 /* Use a control ping for synchronization */
20520 MPING (CONTROL_PING, mp_ping);
20527 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
20528 #define vl_api_mpls_fib_details_t_print vl_noop_handler
20532 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
20534 vat_main_t *vam = &vat_main;
20535 int count = ntohl (mp->count);
20536 vl_api_fib_path_t *fp;
20540 "table-id %d, label %u, ess_bit %u",
20541 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
20543 for (i = 0; i < count; i++)
20545 vl_api_mpls_fib_path_print (vam, fp);
20550 static void vl_api_mpls_fib_details_t_handler_json
20551 (vl_api_mpls_fib_details_t * mp)
20553 vat_main_t *vam = &vat_main;
20554 int count = ntohl (mp->count);
20555 vat_json_node_t *node = NULL;
20556 vl_api_fib_path_t *fp;
20559 if (VAT_JSON_ARRAY != vam->json_tree.type)
20561 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20562 vat_json_init_array (&vam->json_tree);
20564 node = vat_json_array_add (&vam->json_tree);
20566 vat_json_init_object (node);
20567 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20568 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
20569 vat_json_object_add_uint (node, "label", ntohl (mp->label));
20570 vat_json_object_add_uint (node, "path_count", count);
20572 for (i = 0; i < count; i++)
20574 vl_api_mpls_fib_path_json_print (node, fp);
20580 api_mpls_fib_dump (vat_main_t * vam)
20582 vl_api_mpls_fib_dump_t *mp;
20583 vl_api_control_ping_t *mp_ping;
20586 M (MPLS_FIB_DUMP, mp);
20589 /* Use a control ping for synchronization */
20590 MPING (CONTROL_PING, mp_ping);
20597 #define vl_api_ip_fib_details_t_endian vl_noop_handler
20598 #define vl_api_ip_fib_details_t_print vl_noop_handler
20601 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
20603 vat_main_t *vam = &vat_main;
20604 int count = ntohl (mp->count);
20605 vl_api_fib_path_t *fp;
20609 "table-id %d, prefix %U/%d stats-index %d",
20610 ntohl (mp->table_id), format_ip4_address, mp->address,
20611 mp->address_length, ntohl (mp->stats_index));
20613 for (i = 0; i < count; i++)
20615 if (fp->afi == IP46_TYPE_IP6)
20617 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20618 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U, "
20619 "next_hop_table %d",
20620 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20621 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20622 format_ip6_address, fp->next_hop, ntohl (fp->table_id));
20623 else if (fp->afi == IP46_TYPE_IP4)
20625 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20626 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U, "
20627 "next_hop_table %d",
20628 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20629 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20630 format_ip4_address, fp->next_hop, ntohl (fp->table_id));
20635 static void vl_api_ip_fib_details_t_handler_json
20636 (vl_api_ip_fib_details_t * mp)
20638 vat_main_t *vam = &vat_main;
20639 int count = ntohl (mp->count);
20640 vat_json_node_t *node = NULL;
20641 struct in_addr ip4;
20642 struct in6_addr ip6;
20643 vl_api_fib_path_t *fp;
20646 if (VAT_JSON_ARRAY != vam->json_tree.type)
20648 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20649 vat_json_init_array (&vam->json_tree);
20651 node = vat_json_array_add (&vam->json_tree);
20653 vat_json_init_object (node);
20654 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20655 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
20656 vat_json_object_add_ip4 (node, "prefix", ip4);
20657 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20658 vat_json_object_add_uint (node, "path_count", count);
20660 for (i = 0; i < count; i++)
20662 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20663 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20664 vat_json_object_add_uint (node, "is_local", fp->is_local);
20665 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20666 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20667 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20668 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20669 if (fp->afi == IP46_TYPE_IP4)
20671 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20672 vat_json_object_add_ip4 (node, "next_hop", ip4);
20674 else if (fp->afi == IP46_TYPE_IP6)
20676 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20677 vat_json_object_add_ip6 (node, "next_hop", ip6);
20683 api_ip_fib_dump (vat_main_t * vam)
20685 vl_api_ip_fib_dump_t *mp;
20686 vl_api_control_ping_t *mp_ping;
20689 M (IP_FIB_DUMP, mp);
20692 /* Use a control ping for synchronization */
20693 MPING (CONTROL_PING, mp_ping);
20701 api_ip_mfib_dump (vat_main_t * vam)
20703 vl_api_ip_mfib_dump_t *mp;
20704 vl_api_control_ping_t *mp_ping;
20707 M (IP_MFIB_DUMP, mp);
20710 /* Use a control ping for synchronization */
20711 MPING (CONTROL_PING, mp_ping);
20718 static void vl_api_ip_neighbor_details_t_handler
20719 (vl_api_ip_neighbor_details_t * mp)
20721 vat_main_t *vam = &vat_main;
20723 print (vam->ofp, "%c %U %U",
20724 (mp->is_static) ? 'S' : 'D',
20725 format_ethernet_address, &mp->mac_address,
20726 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
20730 static void vl_api_ip_neighbor_details_t_handler_json
20731 (vl_api_ip_neighbor_details_t * mp)
20734 vat_main_t *vam = &vat_main;
20735 vat_json_node_t *node;
20736 struct in_addr ip4;
20737 struct in6_addr ip6;
20739 if (VAT_JSON_ARRAY != vam->json_tree.type)
20741 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20742 vat_json_init_array (&vam->json_tree);
20744 node = vat_json_array_add (&vam->json_tree);
20746 vat_json_init_object (node);
20747 vat_json_object_add_string_copy (node, "flag",
20748 (mp->is_static) ? (u8 *) "static" : (u8 *)
20751 vat_json_object_add_string_copy (node, "link_layer",
20752 format (0, "%U", format_ethernet_address,
20753 &mp->mac_address));
20757 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
20758 vat_json_object_add_ip6 (node, "ip_address", ip6);
20762 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
20763 vat_json_object_add_ip4 (node, "ip_address", ip4);
20768 api_ip_neighbor_dump (vat_main_t * vam)
20770 unformat_input_t *i = vam->input;
20771 vl_api_ip_neighbor_dump_t *mp;
20772 vl_api_control_ping_t *mp_ping;
20774 u32 sw_if_index = ~0;
20777 /* Parse args required to build the message */
20778 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20780 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20782 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20784 else if (unformat (i, "ip6"))
20790 if (sw_if_index == ~0)
20792 errmsg ("missing interface name or sw_if_index");
20796 M (IP_NEIGHBOR_DUMP, mp);
20797 mp->is_ipv6 = (u8) is_ipv6;
20798 mp->sw_if_index = ntohl (sw_if_index);
20801 /* Use a control ping for synchronization */
20802 MPING (CONTROL_PING, mp_ping);
20809 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
20810 #define vl_api_ip6_fib_details_t_print vl_noop_handler
20813 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
20815 vat_main_t *vam = &vat_main;
20816 int count = ntohl (mp->count);
20817 vl_api_fib_path_t *fp;
20821 "table-id %d, prefix %U/%d stats-index %d",
20822 ntohl (mp->table_id), format_ip6_address, mp->address,
20823 mp->address_length, ntohl (mp->stats_index));
20825 for (i = 0; i < count; i++)
20827 if (fp->afi == IP46_TYPE_IP6)
20829 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20830 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20831 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20832 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20833 format_ip6_address, fp->next_hop);
20834 else if (fp->afi == IP46_TYPE_IP4)
20836 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20837 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20838 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20839 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20840 format_ip4_address, fp->next_hop);
20845 static void vl_api_ip6_fib_details_t_handler_json
20846 (vl_api_ip6_fib_details_t * mp)
20848 vat_main_t *vam = &vat_main;
20849 int count = ntohl (mp->count);
20850 vat_json_node_t *node = NULL;
20851 struct in_addr ip4;
20852 struct in6_addr ip6;
20853 vl_api_fib_path_t *fp;
20856 if (VAT_JSON_ARRAY != vam->json_tree.type)
20858 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20859 vat_json_init_array (&vam->json_tree);
20861 node = vat_json_array_add (&vam->json_tree);
20863 vat_json_init_object (node);
20864 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20865 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
20866 vat_json_object_add_ip6 (node, "prefix", ip6);
20867 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20868 vat_json_object_add_uint (node, "path_count", count);
20870 for (i = 0; i < count; i++)
20872 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20873 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20874 vat_json_object_add_uint (node, "is_local", fp->is_local);
20875 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20876 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20877 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20878 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20879 if (fp->afi == IP46_TYPE_IP4)
20881 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20882 vat_json_object_add_ip4 (node, "next_hop", ip4);
20884 else if (fp->afi == IP46_TYPE_IP6)
20886 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20887 vat_json_object_add_ip6 (node, "next_hop", ip6);
20893 api_ip6_fib_dump (vat_main_t * vam)
20895 vl_api_ip6_fib_dump_t *mp;
20896 vl_api_control_ping_t *mp_ping;
20899 M (IP6_FIB_DUMP, mp);
20902 /* Use a control ping for synchronization */
20903 MPING (CONTROL_PING, mp_ping);
20911 api_ip6_mfib_dump (vat_main_t * vam)
20913 vl_api_ip6_mfib_dump_t *mp;
20914 vl_api_control_ping_t *mp_ping;
20917 M (IP6_MFIB_DUMP, mp);
20920 /* Use a control ping for synchronization */
20921 MPING (CONTROL_PING, mp_ping);
20929 api_classify_table_ids (vat_main_t * vam)
20931 vl_api_classify_table_ids_t *mp;
20934 /* Construct the API message */
20935 M (CLASSIFY_TABLE_IDS, mp);
20944 api_classify_table_by_interface (vat_main_t * vam)
20946 unformat_input_t *input = vam->input;
20947 vl_api_classify_table_by_interface_t *mp;
20949 u32 sw_if_index = ~0;
20951 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20953 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20955 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20960 if (sw_if_index == ~0)
20962 errmsg ("missing interface name or sw_if_index");
20966 /* Construct the API message */
20967 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
20969 mp->sw_if_index = ntohl (sw_if_index);
20977 api_classify_table_info (vat_main_t * vam)
20979 unformat_input_t *input = vam->input;
20980 vl_api_classify_table_info_t *mp;
20984 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20986 if (unformat (input, "table_id %d", &table_id))
20991 if (table_id == ~0)
20993 errmsg ("missing table id");
20997 /* Construct the API message */
20998 M (CLASSIFY_TABLE_INFO, mp);
21000 mp->table_id = ntohl (table_id);
21008 api_classify_session_dump (vat_main_t * vam)
21010 unformat_input_t *input = vam->input;
21011 vl_api_classify_session_dump_t *mp;
21012 vl_api_control_ping_t *mp_ping;
21016 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21018 if (unformat (input, "table_id %d", &table_id))
21023 if (table_id == ~0)
21025 errmsg ("missing table id");
21029 /* Construct the API message */
21030 M (CLASSIFY_SESSION_DUMP, mp);
21032 mp->table_id = ntohl (table_id);
21035 /* Use a control ping for synchronization */
21036 MPING (CONTROL_PING, mp_ping);
21044 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
21046 vat_main_t *vam = &vat_main;
21048 print (vam->ofp, "collector_address %U, collector_port %d, "
21049 "src_address %U, vrf_id %d, path_mtu %u, "
21050 "template_interval %u, udp_checksum %d",
21051 format_ip4_address, mp->collector_address,
21052 ntohs (mp->collector_port),
21053 format_ip4_address, mp->src_address,
21054 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
21055 ntohl (mp->template_interval), mp->udp_checksum);
21058 vam->result_ready = 1;
21062 vl_api_ipfix_exporter_details_t_handler_json
21063 (vl_api_ipfix_exporter_details_t * mp)
21065 vat_main_t *vam = &vat_main;
21066 vat_json_node_t node;
21067 struct in_addr collector_address;
21068 struct in_addr src_address;
21070 vat_json_init_object (&node);
21071 clib_memcpy (&collector_address, &mp->collector_address,
21072 sizeof (collector_address));
21073 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
21074 vat_json_object_add_uint (&node, "collector_port",
21075 ntohs (mp->collector_port));
21076 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
21077 vat_json_object_add_ip4 (&node, "src_address", src_address);
21078 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
21079 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
21080 vat_json_object_add_uint (&node, "template_interval",
21081 ntohl (mp->template_interval));
21082 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
21084 vat_json_print (vam->ofp, &node);
21085 vat_json_free (&node);
21087 vam->result_ready = 1;
21091 api_ipfix_exporter_dump (vat_main_t * vam)
21093 vl_api_ipfix_exporter_dump_t *mp;
21096 /* Construct the API message */
21097 M (IPFIX_EXPORTER_DUMP, mp);
21106 api_ipfix_classify_stream_dump (vat_main_t * vam)
21108 vl_api_ipfix_classify_stream_dump_t *mp;
21111 /* Construct the API message */
21112 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
21123 vl_api_ipfix_classify_stream_details_t_handler
21124 (vl_api_ipfix_classify_stream_details_t * mp)
21126 vat_main_t *vam = &vat_main;
21127 print (vam->ofp, "domain_id %d, src_port %d",
21128 ntohl (mp->domain_id), ntohs (mp->src_port));
21130 vam->result_ready = 1;
21134 vl_api_ipfix_classify_stream_details_t_handler_json
21135 (vl_api_ipfix_classify_stream_details_t * mp)
21137 vat_main_t *vam = &vat_main;
21138 vat_json_node_t node;
21140 vat_json_init_object (&node);
21141 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
21142 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
21144 vat_json_print (vam->ofp, &node);
21145 vat_json_free (&node);
21147 vam->result_ready = 1;
21151 api_ipfix_classify_table_dump (vat_main_t * vam)
21153 vl_api_ipfix_classify_table_dump_t *mp;
21154 vl_api_control_ping_t *mp_ping;
21157 if (!vam->json_output)
21159 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
21160 "transport_protocol");
21163 /* Construct the API message */
21164 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
21169 /* Use a control ping for synchronization */
21170 MPING (CONTROL_PING, mp_ping);
21178 vl_api_ipfix_classify_table_details_t_handler
21179 (vl_api_ipfix_classify_table_details_t * mp)
21181 vat_main_t *vam = &vat_main;
21182 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
21183 mp->transport_protocol);
21187 vl_api_ipfix_classify_table_details_t_handler_json
21188 (vl_api_ipfix_classify_table_details_t * mp)
21190 vat_json_node_t *node = NULL;
21191 vat_main_t *vam = &vat_main;
21193 if (VAT_JSON_ARRAY != vam->json_tree.type)
21195 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21196 vat_json_init_array (&vam->json_tree);
21199 node = vat_json_array_add (&vam->json_tree);
21200 vat_json_init_object (node);
21202 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
21203 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
21204 vat_json_object_add_uint (node, "transport_protocol",
21205 mp->transport_protocol);
21209 api_sw_interface_span_enable_disable (vat_main_t * vam)
21211 unformat_input_t *i = vam->input;
21212 vl_api_sw_interface_span_enable_disable_t *mp;
21213 u32 src_sw_if_index = ~0;
21214 u32 dst_sw_if_index = ~0;
21219 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21222 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
21224 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
21228 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
21230 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
21232 else if (unformat (i, "disable"))
21234 else if (unformat (i, "rx"))
21236 else if (unformat (i, "tx"))
21238 else if (unformat (i, "both"))
21240 else if (unformat (i, "l2"))
21246 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
21248 mp->sw_if_index_from = htonl (src_sw_if_index);
21249 mp->sw_if_index_to = htonl (dst_sw_if_index);
21259 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
21262 vat_main_t *vam = &vat_main;
21263 u8 *sw_if_from_name = 0;
21264 u8 *sw_if_to_name = 0;
21265 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
21266 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
21267 char *states[] = { "none", "rx", "tx", "both" };
21271 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
21273 if ((u32) p->value[0] == sw_if_index_from)
21275 sw_if_from_name = (u8 *)(p->key);
21279 if ((u32) p->value[0] == sw_if_index_to)
21281 sw_if_to_name = (u8 *)(p->key);
21282 if (sw_if_from_name)
21287 print (vam->ofp, "%20s => %20s (%s) %s",
21288 sw_if_from_name, sw_if_to_name, states[mp->state],
21289 mp->is_l2 ? "l2" : "device");
21293 vl_api_sw_interface_span_details_t_handler_json
21294 (vl_api_sw_interface_span_details_t * mp)
21296 vat_main_t *vam = &vat_main;
21297 vat_json_node_t *node = NULL;
21298 u8 *sw_if_from_name = 0;
21299 u8 *sw_if_to_name = 0;
21300 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
21301 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
21305 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
21307 if ((u32) p->value[0] == sw_if_index_from)
21309 sw_if_from_name = (u8 *)(p->key);
21313 if ((u32) p->value[0] == sw_if_index_to)
21315 sw_if_to_name = (u8 *)(p->key);
21316 if (sw_if_from_name)
21322 if (VAT_JSON_ARRAY != vam->json_tree.type)
21324 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21325 vat_json_init_array (&vam->json_tree);
21327 node = vat_json_array_add (&vam->json_tree);
21329 vat_json_init_object (node);
21330 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
21331 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
21332 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
21333 if (0 != sw_if_to_name)
21335 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
21337 vat_json_object_add_uint (node, "state", mp->state);
21338 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
21342 api_sw_interface_span_dump (vat_main_t * vam)
21344 unformat_input_t *input = vam->input;
21345 vl_api_sw_interface_span_dump_t *mp;
21346 vl_api_control_ping_t *mp_ping;
21350 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21352 if (unformat (input, "l2"))
21358 M (SW_INTERFACE_SPAN_DUMP, mp);
21362 /* Use a control ping for synchronization */
21363 MPING (CONTROL_PING, mp_ping);
21371 api_pg_create_interface (vat_main_t * vam)
21373 unformat_input_t *input = vam->input;
21374 vl_api_pg_create_interface_t *mp;
21378 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21380 if (unformat (input, "if_id %d", &if_id))
21387 errmsg ("missing pg interface index");
21391 /* Construct the API message */
21392 M (PG_CREATE_INTERFACE, mp);
21394 mp->interface_id = ntohl (if_id);
21402 api_pg_capture (vat_main_t * vam)
21404 unformat_input_t *input = vam->input;
21405 vl_api_pg_capture_t *mp;
21410 u8 pcap_file_set = 0;
21413 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21415 if (unformat (input, "if_id %d", &if_id))
21417 else if (unformat (input, "pcap %s", &pcap_file))
21419 else if (unformat (input, "count %d", &count))
21421 else if (unformat (input, "disable"))
21428 errmsg ("missing pg interface index");
21431 if (pcap_file_set > 0)
21433 if (vec_len (pcap_file) > 255)
21435 errmsg ("pcap file name is too long");
21440 u32 name_len = vec_len (pcap_file);
21441 /* Construct the API message */
21442 M (PG_CAPTURE, mp);
21444 mp->interface_id = ntohl (if_id);
21445 mp->is_enabled = enable;
21446 mp->count = ntohl (count);
21447 mp->pcap_name_length = ntohl (name_len);
21448 if (pcap_file_set != 0)
21450 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
21452 vec_free (pcap_file);
21460 api_pg_enable_disable (vat_main_t * vam)
21462 unformat_input_t *input = vam->input;
21463 vl_api_pg_enable_disable_t *mp;
21466 u8 stream_name_set = 0;
21467 u8 *stream_name = 0;
21469 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21471 if (unformat (input, "stream %s", &stream_name))
21472 stream_name_set = 1;
21473 else if (unformat (input, "disable"))
21479 if (stream_name_set > 0)
21481 if (vec_len (stream_name) > 255)
21483 errmsg ("stream name too long");
21488 u32 name_len = vec_len (stream_name);
21489 /* Construct the API message */
21490 M (PG_ENABLE_DISABLE, mp);
21492 mp->is_enabled = enable;
21493 if (stream_name_set != 0)
21495 mp->stream_name_length = ntohl (name_len);
21496 clib_memcpy (mp->stream_name, stream_name, name_len);
21498 vec_free (stream_name);
21506 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
21508 unformat_input_t *input = vam->input;
21509 vl_api_ip_source_and_port_range_check_add_del_t *mp;
21511 u16 *low_ports = 0;
21512 u16 *high_ports = 0;
21515 ip4_address_t ip4_addr;
21516 ip6_address_t ip6_addr;
21525 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21527 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
21533 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
21538 else if (unformat (input, "vrf %d", &vrf_id))
21540 else if (unformat (input, "del"))
21542 else if (unformat (input, "port %d", &tmp))
21544 if (tmp == 0 || tmp > 65535)
21546 errmsg ("port %d out of range", tmp);
21550 this_hi = this_low + 1;
21551 vec_add1 (low_ports, this_low);
21552 vec_add1 (high_ports, this_hi);
21554 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
21556 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
21558 errmsg ("incorrect range parameters");
21562 /* Note: in debug CLI +1 is added to high before
21563 passing to real fn that does "the work"
21564 (ip_source_and_port_range_check_add_del).
21565 This fn is a wrapper around the binary API fn a
21566 control plane will call, which expects this increment
21567 to have occurred. Hence letting the binary API control
21568 plane fn do the increment for consistency between VAT
21569 and other control planes.
21572 vec_add1 (low_ports, this_low);
21573 vec_add1 (high_ports, this_hi);
21579 if (prefix_set == 0)
21581 errmsg ("<address>/<mask> not specified");
21587 errmsg ("VRF ID required, not specified");
21594 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21598 if (vec_len (low_ports) == 0)
21600 errmsg ("At least one port or port range required");
21604 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
21606 mp->is_add = is_add;
21611 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
21616 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
21619 mp->mask_length = length;
21620 mp->number_of_ranges = vec_len (low_ports);
21622 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
21623 vec_free (low_ports);
21625 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
21626 vec_free (high_ports);
21628 mp->vrf_id = ntohl (vrf_id);
21636 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
21638 unformat_input_t *input = vam->input;
21639 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
21640 u32 sw_if_index = ~0;
21642 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
21643 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
21647 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21649 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21651 else if (unformat (input, "sw_if_index %d", &sw_if_index))
21653 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
21655 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
21657 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
21659 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
21661 else if (unformat (input, "del"))
21667 if (sw_if_index == ~0)
21669 errmsg ("Interface required but not specified");
21675 errmsg ("VRF ID required but not specified");
21679 if (tcp_out_vrf_id == 0
21680 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
21683 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21687 /* Construct the API message */
21688 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
21690 mp->sw_if_index = ntohl (sw_if_index);
21691 mp->is_add = is_add;
21692 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
21693 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
21694 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
21695 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
21700 /* Wait for a reply... */
21706 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
21708 unformat_input_t *i = vam->input;
21709 vl_api_ipsec_gre_add_del_tunnel_t *mp;
21710 u32 local_sa_id = 0;
21711 u32 remote_sa_id = 0;
21712 ip4_address_t src_address;
21713 ip4_address_t dst_address;
21717 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21719 if (unformat (i, "local_sa %d", &local_sa_id))
21721 else if (unformat (i, "remote_sa %d", &remote_sa_id))
21723 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
21725 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
21727 else if (unformat (i, "del"))
21731 clib_warning ("parse error '%U'", format_unformat_error, i);
21736 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
21738 mp->local_sa_id = ntohl (local_sa_id);
21739 mp->remote_sa_id = ntohl (remote_sa_id);
21740 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
21741 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
21742 mp->is_add = is_add;
21750 api_punt (vat_main_t * vam)
21752 unformat_input_t *i = vam->input;
21760 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21762 if (unformat (i, "ip %d", &ipv))
21764 else if (unformat (i, "protocol %d", &protocol))
21766 else if (unformat (i, "port %d", &port))
21768 else if (unformat (i, "del"))
21772 clib_warning ("parse error '%U'", format_unformat_error, i);
21779 mp->is_add = (u8) is_add;
21780 mp->ipv = (u8) ipv;
21781 mp->l4_protocol = (u8) protocol;
21782 mp->l4_port = htons ((u16) port);
21789 static void vl_api_ipsec_gre_tunnel_details_t_handler
21790 (vl_api_ipsec_gre_tunnel_details_t * mp)
21792 vat_main_t *vam = &vat_main;
21794 print (vam->ofp, "%11d%15U%15U%14d%14d",
21795 ntohl (mp->sw_if_index),
21796 format_ip4_address, &mp->src_address,
21797 format_ip4_address, &mp->dst_address,
21798 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
21801 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
21802 (vl_api_ipsec_gre_tunnel_details_t * mp)
21804 vat_main_t *vam = &vat_main;
21805 vat_json_node_t *node = NULL;
21806 struct in_addr ip4;
21808 if (VAT_JSON_ARRAY != vam->json_tree.type)
21810 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21811 vat_json_init_array (&vam->json_tree);
21813 node = vat_json_array_add (&vam->json_tree);
21815 vat_json_init_object (node);
21816 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
21817 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
21818 vat_json_object_add_ip4 (node, "src_address", ip4);
21819 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
21820 vat_json_object_add_ip4 (node, "dst_address", ip4);
21821 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
21822 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
21826 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
21828 unformat_input_t *i = vam->input;
21829 vl_api_ipsec_gre_tunnel_dump_t *mp;
21830 vl_api_control_ping_t *mp_ping;
21832 u8 sw_if_index_set = 0;
21835 /* Parse args required to build the message */
21836 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21838 if (unformat (i, "sw_if_index %d", &sw_if_index))
21839 sw_if_index_set = 1;
21844 if (sw_if_index_set == 0)
21849 if (!vam->json_output)
21851 print (vam->ofp, "%11s%15s%15s%14s%14s",
21852 "sw_if_index", "src_address", "dst_address",
21853 "local_sa_id", "remote_sa_id");
21856 /* Get list of gre-tunnel interfaces */
21857 M (IPSEC_GRE_TUNNEL_DUMP, mp);
21859 mp->sw_if_index = htonl (sw_if_index);
21863 /* Use a control ping for synchronization */
21864 MPING (CONTROL_PING, mp_ping);
21872 api_delete_subif (vat_main_t * vam)
21874 unformat_input_t *i = vam->input;
21875 vl_api_delete_subif_t *mp;
21876 u32 sw_if_index = ~0;
21879 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21881 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21883 if (unformat (i, "sw_if_index %d", &sw_if_index))
21889 if (sw_if_index == ~0)
21891 errmsg ("missing sw_if_index");
21895 /* Construct the API message */
21896 M (DELETE_SUBIF, mp);
21897 mp->sw_if_index = ntohl (sw_if_index);
21904 #define foreach_pbb_vtr_op \
21905 _("disable", L2_VTR_DISABLED) \
21906 _("pop", L2_VTR_POP_2) \
21907 _("push", L2_VTR_PUSH_2)
21910 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
21912 unformat_input_t *i = vam->input;
21913 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
21914 u32 sw_if_index = ~0, vtr_op = ~0;
21915 u16 outer_tag = ~0;
21916 u8 dmac[6], smac[6];
21917 u8 dmac_set = 0, smac_set = 0;
21923 /* Shut up coverity */
21924 memset (dmac, 0, sizeof (dmac));
21925 memset (smac, 0, sizeof (smac));
21927 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21929 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21931 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21933 else if (unformat (i, "vtr_op %d", &vtr_op))
21935 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
21938 else if (unformat (i, "translate_pbb_stag"))
21940 if (unformat (i, "%d", &tmp))
21942 vtr_op = L2_VTR_TRANSLATE_2_1;
21948 ("translate_pbb_stag operation requires outer tag definition");
21952 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
21954 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
21956 else if (unformat (i, "sid %d", &sid))
21958 else if (unformat (i, "vlanid %d", &tmp))
21962 clib_warning ("parse error '%U'", format_unformat_error, i);
21967 if ((sw_if_index == ~0) || (vtr_op == ~0))
21969 errmsg ("missing sw_if_index or vtr operation");
21972 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
21973 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
21976 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
21980 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
21981 mp->sw_if_index = ntohl (sw_if_index);
21982 mp->vtr_op = ntohl (vtr_op);
21983 mp->outer_tag = ntohs (outer_tag);
21984 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
21985 clib_memcpy (mp->b_smac, smac, sizeof (smac));
21986 mp->b_vlanid = ntohs (vlanid);
21987 mp->i_sid = ntohl (sid);
21995 api_flow_classify_set_interface (vat_main_t * vam)
21997 unformat_input_t *i = vam->input;
21998 vl_api_flow_classify_set_interface_t *mp;
22000 int sw_if_index_set;
22001 u32 ip4_table_index = ~0;
22002 u32 ip6_table_index = ~0;
22006 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22008 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22009 sw_if_index_set = 1;
22010 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22011 sw_if_index_set = 1;
22012 else if (unformat (i, "del"))
22014 else if (unformat (i, "ip4-table %d", &ip4_table_index))
22016 else if (unformat (i, "ip6-table %d", &ip6_table_index))
22020 clib_warning ("parse error '%U'", format_unformat_error, i);
22025 if (sw_if_index_set == 0)
22027 errmsg ("missing interface name or sw_if_index");
22031 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
22033 mp->sw_if_index = ntohl (sw_if_index);
22034 mp->ip4_table_index = ntohl (ip4_table_index);
22035 mp->ip6_table_index = ntohl (ip6_table_index);
22036 mp->is_add = is_add;
22044 api_flow_classify_dump (vat_main_t * vam)
22046 unformat_input_t *i = vam->input;
22047 vl_api_flow_classify_dump_t *mp;
22048 vl_api_control_ping_t *mp_ping;
22049 u8 type = FLOW_CLASSIFY_N_TABLES;
22052 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
22056 errmsg ("classify table type must be specified");
22060 if (!vam->json_output)
22062 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
22065 M (FLOW_CLASSIFY_DUMP, mp);
22070 /* Use a control ping for synchronization */
22071 MPING (CONTROL_PING, mp_ping);
22074 /* Wait for a reply... */
22080 api_feature_enable_disable (vat_main_t * vam)
22082 unformat_input_t *i = vam->input;
22083 vl_api_feature_enable_disable_t *mp;
22085 u8 *feature_name = 0;
22086 u32 sw_if_index = ~0;
22090 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22092 if (unformat (i, "arc_name %s", &arc_name))
22094 else if (unformat (i, "feature_name %s", &feature_name))
22097 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22099 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22101 else if (unformat (i, "disable"))
22109 errmsg ("missing arc name");
22112 if (vec_len (arc_name) > 63)
22114 errmsg ("arc name too long");
22117 if (feature_name == 0)
22119 errmsg ("missing feature name");
22122 if (vec_len (feature_name) > 63)
22124 errmsg ("feature name too long");
22127 if (sw_if_index == ~0)
22129 errmsg ("missing interface name or sw_if_index");
22133 /* Construct the API message */
22134 M (FEATURE_ENABLE_DISABLE, mp);
22135 mp->sw_if_index = ntohl (sw_if_index);
22136 mp->enable = enable;
22137 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
22138 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
22139 vec_free (arc_name);
22140 vec_free (feature_name);
22148 api_sw_interface_tag_add_del (vat_main_t * vam)
22150 unformat_input_t *i = vam->input;
22151 vl_api_sw_interface_tag_add_del_t *mp;
22152 u32 sw_if_index = ~0;
22157 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22159 if (unformat (i, "tag %s", &tag))
22161 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22163 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22165 else if (unformat (i, "del"))
22171 if (sw_if_index == ~0)
22173 errmsg ("missing interface name or sw_if_index");
22177 if (enable && (tag == 0))
22179 errmsg ("no tag specified");
22183 /* Construct the API message */
22184 M (SW_INTERFACE_TAG_ADD_DEL, mp);
22185 mp->sw_if_index = ntohl (sw_if_index);
22186 mp->is_add = enable;
22188 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
22196 static void vl_api_l2_xconnect_details_t_handler
22197 (vl_api_l2_xconnect_details_t * mp)
22199 vat_main_t *vam = &vat_main;
22201 print (vam->ofp, "%15d%15d",
22202 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
22205 static void vl_api_l2_xconnect_details_t_handler_json
22206 (vl_api_l2_xconnect_details_t * mp)
22208 vat_main_t *vam = &vat_main;
22209 vat_json_node_t *node = NULL;
22211 if (VAT_JSON_ARRAY != vam->json_tree.type)
22213 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22214 vat_json_init_array (&vam->json_tree);
22216 node = vat_json_array_add (&vam->json_tree);
22218 vat_json_init_object (node);
22219 vat_json_object_add_uint (node, "rx_sw_if_index",
22220 ntohl (mp->rx_sw_if_index));
22221 vat_json_object_add_uint (node, "tx_sw_if_index",
22222 ntohl (mp->tx_sw_if_index));
22226 api_l2_xconnect_dump (vat_main_t * vam)
22228 vl_api_l2_xconnect_dump_t *mp;
22229 vl_api_control_ping_t *mp_ping;
22232 if (!vam->json_output)
22234 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
22237 M (L2_XCONNECT_DUMP, mp);
22241 /* Use a control ping for synchronization */
22242 MPING (CONTROL_PING, mp_ping);
22250 api_hw_interface_set_mtu (vat_main_t * vam)
22252 unformat_input_t *i = vam->input;
22253 vl_api_hw_interface_set_mtu_t *mp;
22254 u32 sw_if_index = ~0;
22258 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22260 if (unformat (i, "mtu %d", &mtu))
22262 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22264 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22270 if (sw_if_index == ~0)
22272 errmsg ("missing interface name or sw_if_index");
22278 errmsg ("no mtu specified");
22282 /* Construct the API message */
22283 M (HW_INTERFACE_SET_MTU, mp);
22284 mp->sw_if_index = ntohl (sw_if_index);
22285 mp->mtu = ntohs ((u16) mtu);
22293 api_p2p_ethernet_add (vat_main_t * vam)
22295 unformat_input_t *i = vam->input;
22296 vl_api_p2p_ethernet_add_t *mp;
22297 u32 parent_if_index = ~0;
22303 memset (remote_mac, 0, sizeof (remote_mac));
22304 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22306 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
22308 else if (unformat (i, "sw_if_index %d", &parent_if_index))
22312 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
22314 else if (unformat (i, "sub_id %d", &sub_id))
22318 clib_warning ("parse error '%U'", format_unformat_error, i);
22323 if (parent_if_index == ~0)
22325 errmsg ("missing interface name or sw_if_index");
22330 errmsg ("missing remote mac address");
22335 errmsg ("missing sub-interface id");
22339 M (P2P_ETHERNET_ADD, mp);
22340 mp->parent_if_index = ntohl (parent_if_index);
22341 mp->subif_id = ntohl (sub_id);
22342 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22350 api_p2p_ethernet_del (vat_main_t * vam)
22352 unformat_input_t *i = vam->input;
22353 vl_api_p2p_ethernet_del_t *mp;
22354 u32 parent_if_index = ~0;
22359 memset (remote_mac, 0, sizeof (remote_mac));
22360 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22362 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
22364 else if (unformat (i, "sw_if_index %d", &parent_if_index))
22368 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
22372 clib_warning ("parse error '%U'", format_unformat_error, i);
22377 if (parent_if_index == ~0)
22379 errmsg ("missing interface name or sw_if_index");
22384 errmsg ("missing remote mac address");
22388 M (P2P_ETHERNET_DEL, mp);
22389 mp->parent_if_index = ntohl (parent_if_index);
22390 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22398 api_lldp_config (vat_main_t * vam)
22400 unformat_input_t *i = vam->input;
22401 vl_api_lldp_config_t *mp;
22403 int tx_interval = 0;
22404 u8 *sys_name = NULL;
22407 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22409 if (unformat (i, "system-name %s", &sys_name))
22411 else if (unformat (i, "tx-hold %d", &tx_hold))
22413 else if (unformat (i, "tx-interval %d", &tx_interval))
22417 clib_warning ("parse error '%U'", format_unformat_error, i);
22422 vec_add1 (sys_name, 0);
22424 M (LLDP_CONFIG, mp);
22425 mp->tx_hold = htonl (tx_hold);
22426 mp->tx_interval = htonl (tx_interval);
22427 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
22428 vec_free (sys_name);
22436 api_sw_interface_set_lldp (vat_main_t * vam)
22438 unformat_input_t *i = vam->input;
22439 vl_api_sw_interface_set_lldp_t *mp;
22440 u32 sw_if_index = ~0;
22442 u8 *port_desc = NULL, *mgmt_oid = NULL;
22443 ip4_address_t ip4_addr;
22444 ip6_address_t ip6_addr;
22447 memset (&ip4_addr, 0, sizeof (ip4_addr));
22448 memset (&ip6_addr, 0, sizeof (ip6_addr));
22450 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22452 if (unformat (i, "disable"))
22455 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22457 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22459 else if (unformat (i, "port-desc %s", &port_desc))
22461 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
22463 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
22465 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
22471 if (sw_if_index == ~0)
22473 errmsg ("missing interface name or sw_if_index");
22477 /* Construct the API message */
22478 vec_add1 (port_desc, 0);
22479 vec_add1 (mgmt_oid, 0);
22480 M (SW_INTERFACE_SET_LLDP, mp);
22481 mp->sw_if_index = ntohl (sw_if_index);
22482 mp->enable = enable;
22483 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
22484 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
22485 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
22486 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
22487 vec_free (port_desc);
22488 vec_free (mgmt_oid);
22496 api_tcp_configure_src_addresses (vat_main_t * vam)
22498 vl_api_tcp_configure_src_addresses_t *mp;
22499 unformat_input_t *i = vam->input;
22500 ip4_address_t v4first, v4last;
22501 ip6_address_t v6first, v6last;
22506 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22508 if (unformat (i, "%U - %U",
22509 unformat_ip4_address, &v4first,
22510 unformat_ip4_address, &v4last))
22514 errmsg ("one range per message (range already set)");
22519 else if (unformat (i, "%U - %U",
22520 unformat_ip6_address, &v6first,
22521 unformat_ip6_address, &v6last))
22525 errmsg ("one range per message (range already set)");
22530 else if (unformat (i, "vrf %d", &vrf_id))
22536 if (range_set == 0)
22538 errmsg ("address range not set");
22542 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
22543 mp->vrf_id = ntohl (vrf_id);
22545 if (range_set == 2)
22548 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
22549 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
22554 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
22555 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
22562 static void vl_api_app_namespace_add_del_reply_t_handler
22563 (vl_api_app_namespace_add_del_reply_t * mp)
22565 vat_main_t *vam = &vat_main;
22566 i32 retval = ntohl (mp->retval);
22567 if (vam->async_mode)
22569 vam->async_errors += (retval < 0);
22573 vam->retval = retval;
22575 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
22576 vam->result_ready = 1;
22580 static void vl_api_app_namespace_add_del_reply_t_handler_json
22581 (vl_api_app_namespace_add_del_reply_t * mp)
22583 vat_main_t *vam = &vat_main;
22584 vat_json_node_t node;
22586 vat_json_init_object (&node);
22587 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
22588 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
22590 vat_json_print (vam->ofp, &node);
22591 vat_json_free (&node);
22593 vam->retval = ntohl (mp->retval);
22594 vam->result_ready = 1;
22598 api_app_namespace_add_del (vat_main_t * vam)
22600 vl_api_app_namespace_add_del_t *mp;
22601 unformat_input_t *i = vam->input;
22602 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
22603 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
22607 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22609 if (unformat (i, "id %_%v%_", &ns_id))
22611 else if (unformat (i, "secret %lu", &secret))
22613 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22614 sw_if_index_set = 1;
22615 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
22617 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
22622 if (!ns_id || !secret_set || !sw_if_index_set)
22624 errmsg ("namespace id, secret and sw_if_index must be set");
22627 if (vec_len (ns_id) > 64)
22629 errmsg ("namespace id too long");
22632 M (APP_NAMESPACE_ADD_DEL, mp);
22634 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
22635 mp->namespace_id_len = vec_len (ns_id);
22636 mp->secret = clib_host_to_net_u64 (secret);
22637 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
22638 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
22639 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
22647 api_sock_init_shm (vat_main_t * vam)
22649 #if VPP_API_TEST_BUILTIN == 0
22650 unformat_input_t *i = vam->input;
22651 vl_api_shm_elem_config_t *config = 0;
22652 u64 size = 64 << 20;
22655 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22657 if (unformat (i, "size %U", unformat_memory_size, &size))
22664 * Canned custom ring allocator config.
22665 * Should probably parse all of this
22667 vec_validate (config, 6);
22668 config[0].type = VL_API_VLIB_RING;
22669 config[0].size = 256;
22670 config[0].count = 32;
22672 config[1].type = VL_API_VLIB_RING;
22673 config[1].size = 1024;
22674 config[1].count = 16;
22676 config[2].type = VL_API_VLIB_RING;
22677 config[2].size = 4096;
22678 config[2].count = 2;
22680 config[3].type = VL_API_CLIENT_RING;
22681 config[3].size = 256;
22682 config[3].count = 32;
22684 config[4].type = VL_API_CLIENT_RING;
22685 config[4].size = 1024;
22686 config[4].count = 16;
22688 config[5].type = VL_API_CLIENT_RING;
22689 config[5].size = 4096;
22690 config[5].count = 2;
22692 config[6].type = VL_API_QUEUE;
22693 config[6].count = 128;
22694 config[6].size = sizeof (uword);
22696 rv = vl_socket_client_init_shm (config);
22698 vam->client_index_invalid = 1;
22706 api_dns_enable_disable (vat_main_t * vam)
22708 unformat_input_t *line_input = vam->input;
22709 vl_api_dns_enable_disable_t *mp;
22710 u8 enable_disable = 1;
22713 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22715 if (unformat (line_input, "disable"))
22716 enable_disable = 0;
22717 if (unformat (line_input, "enable"))
22718 enable_disable = 1;
22723 /* Construct the API message */
22724 M (DNS_ENABLE_DISABLE, mp);
22725 mp->enable = enable_disable;
22729 /* Wait for the reply */
22735 api_dns_resolve_name (vat_main_t * vam)
22737 unformat_input_t *line_input = vam->input;
22738 vl_api_dns_resolve_name_t *mp;
22742 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22744 if (unformat (line_input, "%s", &name))
22750 if (vec_len (name) > 127)
22752 errmsg ("name too long");
22756 /* Construct the API message */
22757 M (DNS_RESOLVE_NAME, mp);
22758 memcpy (mp->name, name, vec_len (name));
22763 /* Wait for the reply */
22769 api_dns_resolve_ip (vat_main_t * vam)
22771 unformat_input_t *line_input = vam->input;
22772 vl_api_dns_resolve_ip_t *mp;
22774 ip4_address_t addr4;
22775 ip6_address_t addr6;
22778 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22780 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
22782 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
22790 errmsg ("missing address");
22794 /* Construct the API message */
22795 M (DNS_RESOLVE_IP, mp);
22796 mp->is_ip6 = is_ip6;
22798 memcpy (mp->address, &addr6, sizeof (addr6));
22800 memcpy (mp->address, &addr4, sizeof (addr4));
22804 /* Wait for the reply */
22810 api_dns_name_server_add_del (vat_main_t * vam)
22812 unformat_input_t *i = vam->input;
22813 vl_api_dns_name_server_add_del_t *mp;
22815 ip6_address_t ip6_server;
22816 ip4_address_t ip4_server;
22821 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22823 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
22825 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
22827 else if (unformat (i, "del"))
22831 clib_warning ("parse error '%U'", format_unformat_error, i);
22836 if (ip4_set && ip6_set)
22838 errmsg ("Only one server address allowed per message");
22841 if ((ip4_set + ip6_set) == 0)
22843 errmsg ("Server address required");
22847 /* Construct the API message */
22848 M (DNS_NAME_SERVER_ADD_DEL, mp);
22852 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
22857 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
22861 mp->is_add = is_add;
22866 /* Wait for a reply, return good/bad news */
22872 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
22874 vat_main_t *vam = &vat_main;
22879 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22880 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22881 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
22882 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
22883 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22884 clib_net_to_host_u32 (mp->action_index), mp->tag);
22889 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22890 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22891 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
22892 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
22893 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22894 clib_net_to_host_u32 (mp->action_index), mp->tag);
22899 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
22902 vat_main_t *vam = &vat_main;
22903 vat_json_node_t *node = NULL;
22904 struct in6_addr ip6;
22905 struct in_addr ip4;
22907 if (VAT_JSON_ARRAY != vam->json_tree.type)
22909 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22910 vat_json_init_array (&vam->json_tree);
22912 node = vat_json_array_add (&vam->json_tree);
22913 vat_json_init_object (node);
22915 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
22916 vat_json_object_add_uint (node, "appns_index",
22917 clib_net_to_host_u32 (mp->appns_index));
22918 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
22919 vat_json_object_add_uint (node, "scope", mp->scope);
22920 vat_json_object_add_uint (node, "action_index",
22921 clib_net_to_host_u32 (mp->action_index));
22922 vat_json_object_add_uint (node, "lcl_port",
22923 clib_net_to_host_u16 (mp->lcl_port));
22924 vat_json_object_add_uint (node, "rmt_port",
22925 clib_net_to_host_u16 (mp->rmt_port));
22926 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
22927 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
22928 vat_json_object_add_string_copy (node, "tag", mp->tag);
22931 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
22932 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
22933 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
22934 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
22938 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
22939 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
22940 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
22941 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
22946 api_session_rule_add_del (vat_main_t * vam)
22948 vl_api_session_rule_add_del_t *mp;
22949 unformat_input_t *i = vam->input;
22950 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
22951 u32 appns_index = 0, scope = 0;
22952 ip4_address_t lcl_ip4, rmt_ip4;
22953 ip6_address_t lcl_ip6, rmt_ip6;
22954 u8 is_ip4 = 1, conn_set = 0;
22955 u8 is_add = 1, *tag = 0;
22958 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22960 if (unformat (i, "del"))
22962 else if (unformat (i, "add"))
22964 else if (unformat (i, "proto tcp"))
22966 else if (unformat (i, "proto udp"))
22968 else if (unformat (i, "appns %d", &appns_index))
22970 else if (unformat (i, "scope %d", &scope))
22972 else if (unformat (i, "tag %_%v%_", &tag))
22976 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
22977 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
22985 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
22986 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
22992 else if (unformat (i, "action %d", &action))
22997 if (proto == ~0 || !conn_set || action == ~0)
22999 errmsg ("transport proto, connection and action must be set");
23005 errmsg ("scope should be 0-3");
23009 M (SESSION_RULE_ADD_DEL, mp);
23011 mp->is_ip4 = is_ip4;
23012 mp->transport_proto = proto;
23013 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
23014 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
23015 mp->lcl_plen = lcl_plen;
23016 mp->rmt_plen = rmt_plen;
23017 mp->action_index = clib_host_to_net_u32 (action);
23018 mp->appns_index = clib_host_to_net_u32 (appns_index);
23020 mp->is_add = is_add;
23023 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
23024 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
23028 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
23029 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
23033 clib_memcpy (mp->tag, tag, vec_len (tag));
23043 api_session_rules_dump (vat_main_t * vam)
23045 vl_api_session_rules_dump_t *mp;
23046 vl_api_control_ping_t *mp_ping;
23049 if (!vam->json_output)
23051 print (vam->ofp, "%=20s", "Session Rules");
23054 M (SESSION_RULES_DUMP, mp);
23058 /* Use a control ping for synchronization */
23059 MPING (CONTROL_PING, mp_ping);
23062 /* Wait for a reply... */
23068 api_ip_container_proxy_add_del (vat_main_t * vam)
23070 vl_api_ip_container_proxy_add_del_t *mp;
23071 unformat_input_t *i = vam->input;
23072 u32 plen = ~0, sw_if_index = ~0;
23079 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
23081 if (unformat (i, "del"))
23083 else if (unformat (i, "add"))
23085 if (unformat (i, "%U", unformat_ip4_address, &ip4))
23090 else if (unformat (i, "%U", unformat_ip6_address, &ip6))
23095 else if (unformat (i, "sw_if_index %u", &sw_if_index))
23100 if (sw_if_index == ~0 || plen == ~0)
23102 errmsg ("address and sw_if_index must be set");
23106 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
23108 mp->is_ip4 = is_ip4;
23109 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
23111 mp->is_add = is_add;
23113 clib_memcpy (mp->ip, &ip4, sizeof (ip4));
23115 clib_memcpy (mp->ip, &ip6, sizeof (ip6));
23123 api_qos_record_enable_disable (vat_main_t * vam)
23125 unformat_input_t *i = vam->input;
23126 vl_api_qos_record_enable_disable_t *mp;
23127 u32 sw_if_index, qs = 0xff;
23128 u8 sw_if_index_set = 0;
23132 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
23134 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
23135 sw_if_index_set = 1;
23136 else if (unformat (i, "sw_if_index %d", &sw_if_index))
23137 sw_if_index_set = 1;
23138 else if (unformat (i, "%U", unformat_qos_source, &qs))
23140 else if (unformat (i, "disable"))
23144 clib_warning ("parse error '%U'", format_unformat_error, i);
23149 if (sw_if_index_set == 0)
23151 errmsg ("missing interface name or sw_if_index");
23156 errmsg ("input location must be specified");
23160 M (QOS_RECORD_ENABLE_DISABLE, mp);
23162 mp->sw_if_index = ntohl (sw_if_index);
23163 mp->input_source = qs;
23164 mp->enable = enable;
23173 q_or_quit (vat_main_t * vam)
23175 #if VPP_API_TEST_BUILTIN == 0
23176 longjmp (vam->jump_buf, 1);
23178 return 0; /* not so much */
23182 q (vat_main_t * vam)
23184 return q_or_quit (vam);
23188 quit (vat_main_t * vam)
23190 return q_or_quit (vam);
23194 comment (vat_main_t * vam)
23200 statseg (vat_main_t * vam)
23202 ssvm_private_t *ssvmp = &vam->stat_segment;
23203 ssvm_shared_header_t *shared_header = ssvmp->sh;
23204 vlib_counter_t **counters;
23205 u64 thread0_index1_packets;
23206 u64 thread0_index1_bytes;
23207 f64 vector_rate, input_rate;
23210 uword *counter_vector_by_name;
23211 if (vam->stat_segment_lockp == 0)
23213 errmsg ("Stat segment not mapped...");
23217 /* look up "/if/rx for sw_if_index 1 as a test */
23219 clib_spinlock_lock (vam->stat_segment_lockp);
23221 counter_vector_by_name = (uword *) shared_header->opaque[1];
23223 p = hash_get_mem (counter_vector_by_name, "/if/rx");
23226 clib_spinlock_unlock (vam->stat_segment_lockp);
23227 errmsg ("/if/tx not found?");
23231 /* Fish per-thread vector of combined counters from shared memory */
23232 counters = (vlib_counter_t **) p[0];
23234 if (vec_len (counters[0]) < 2)
23236 clib_spinlock_unlock (vam->stat_segment_lockp);
23237 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
23241 /* Read thread 0 sw_if_index 1 counter */
23242 thread0_index1_packets = counters[0][1].packets;
23243 thread0_index1_bytes = counters[0][1].bytes;
23245 p = hash_get_mem (counter_vector_by_name, "vector_rate");
23248 clib_spinlock_unlock (vam->stat_segment_lockp);
23249 errmsg ("vector_rate not found?");
23253 vector_rate = *(f64 *) (p[0]);
23254 p = hash_get_mem (counter_vector_by_name, "input_rate");
23257 clib_spinlock_unlock (vam->stat_segment_lockp);
23258 errmsg ("input_rate not found?");
23261 input_rate = *(f64 *) (p[0]);
23263 clib_spinlock_unlock (vam->stat_segment_lockp);
23265 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
23266 vector_rate, input_rate);
23267 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
23268 thread0_index1_packets, thread0_index1_bytes);
23274 cmd_cmp (void *a1, void *a2)
23279 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
23283 help (vat_main_t * vam)
23288 unformat_input_t *i = vam->input;
23291 if (unformat (i, "%s", &name))
23295 vec_add1 (name, 0);
23297 hs = hash_get_mem (vam->help_by_name, name);
23299 print (vam->ofp, "usage: %s %s", name, hs[0]);
23301 print (vam->ofp, "No such msg / command '%s'", name);
23306 print (vam->ofp, "Help is available for the following:");
23309 hash_foreach_pair (p, vam->function_by_name,
23311 vec_add1 (cmds, (u8 *)(p->key));
23315 vec_sort_with_function (cmds, cmd_cmp);
23317 for (j = 0; j < vec_len (cmds); j++)
23318 print (vam->ofp, "%s", cmds[j]);
23325 set (vat_main_t * vam)
23327 u8 *name = 0, *value = 0;
23328 unformat_input_t *i = vam->input;
23330 if (unformat (i, "%s", &name))
23332 /* The input buffer is a vector, not a string. */
23333 value = vec_dup (i->buffer);
23334 vec_delete (value, i->index, 0);
23335 /* Almost certainly has a trailing newline */
23336 if (value[vec_len (value) - 1] == '\n')
23337 value[vec_len (value) - 1] = 0;
23338 /* Make sure it's a proper string, one way or the other */
23339 vec_add1 (value, 0);
23340 (void) clib_macro_set_value (&vam->macro_main,
23341 (char *) name, (char *) value);
23344 errmsg ("usage: set <name> <value>");
23352 unset (vat_main_t * vam)
23356 if (unformat (vam->input, "%s", &name))
23357 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
23358 errmsg ("unset: %s wasn't set", name);
23371 macro_sort_cmp (void *a1, void *a2)
23373 macro_sort_t *s1 = a1;
23374 macro_sort_t *s2 = a2;
23376 return strcmp ((char *) (s1->name), (char *) (s2->name));
23380 dump_macro_table (vat_main_t * vam)
23382 macro_sort_t *sort_me = 0, *sm;
23387 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
23389 vec_add2 (sort_me, sm, 1);
23390 sm->name = (u8 *)(p->key);
23391 sm->value = (u8 *) (p->value[0]);
23395 vec_sort_with_function (sort_me, macro_sort_cmp);
23397 if (vec_len (sort_me))
23398 print (vam->ofp, "%-15s%s", "Name", "Value");
23400 print (vam->ofp, "The macro table is empty...");
23402 for (i = 0; i < vec_len (sort_me); i++)
23403 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
23408 dump_node_table (vat_main_t * vam)
23411 vlib_node_t *node, *next_node;
23413 if (vec_len (vam->graph_nodes) == 0)
23415 print (vam->ofp, "Node table empty, issue get_node_graph...");
23419 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
23421 node = vam->graph_nodes[0][i];
23422 print (vam->ofp, "[%d] %s", i, node->name);
23423 for (j = 0; j < vec_len (node->next_nodes); j++)
23425 if (node->next_nodes[j] != ~0)
23427 next_node = vam->graph_nodes[0][node->next_nodes[j]];
23428 print (vam->ofp, " [%d] %s", j, next_node->name);
23436 value_sort_cmp (void *a1, void *a2)
23438 name_sort_t *n1 = a1;
23439 name_sort_t *n2 = a2;
23441 if (n1->value < n2->value)
23443 if (n1->value > n2->value)
23450 dump_msg_api_table (vat_main_t * vam)
23452 api_main_t *am = &api_main;
23453 name_sort_t *nses = 0, *ns;
23458 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
23460 vec_add2 (nses, ns, 1);
23461 ns->name = (u8 *)(hp->key);
23462 ns->value = (u32) hp->value[0];
23466 vec_sort_with_function (nses, value_sort_cmp);
23468 for (i = 0; i < vec_len (nses); i++)
23469 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
23475 get_msg_id (vat_main_t * vam)
23480 if (unformat (vam->input, "%s", &name_and_crc))
23482 message_index = vl_msg_api_get_msg_index (name_and_crc);
23483 if (message_index == ~0)
23485 print (vam->ofp, " '%s' not found", name_and_crc);
23488 print (vam->ofp, " '%s' has message index %d",
23489 name_and_crc, message_index);
23492 errmsg ("name_and_crc required...");
23497 search_node_table (vat_main_t * vam)
23499 unformat_input_t *line_input = vam->input;
23502 vlib_node_t *node, *next_node;
23505 if (vam->graph_node_index_by_name == 0)
23507 print (vam->ofp, "Node table empty, issue get_node_graph...");
23511 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
23513 if (unformat (line_input, "%s", &node_to_find))
23515 vec_add1 (node_to_find, 0);
23516 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
23519 print (vam->ofp, "%s not found...", node_to_find);
23522 node = vam->graph_nodes[0][p[0]];
23523 print (vam->ofp, "[%d] %s", p[0], node->name);
23524 for (j = 0; j < vec_len (node->next_nodes); j++)
23526 if (node->next_nodes[j] != ~0)
23528 next_node = vam->graph_nodes[0][node->next_nodes[j]];
23529 print (vam->ofp, " [%d] %s", j, next_node->name);
23536 clib_warning ("parse error '%U'", format_unformat_error,
23542 vec_free (node_to_find);
23551 script (vat_main_t * vam)
23553 #if (VPP_API_TEST_BUILTIN==0)
23555 char *save_current_file;
23556 unformat_input_t save_input;
23557 jmp_buf save_jump_buf;
23558 u32 save_line_number;
23560 FILE *new_fp, *save_ifp;
23562 if (unformat (vam->input, "%s", &s))
23564 new_fp = fopen ((char *) s, "r");
23567 errmsg ("Couldn't open script file %s", s);
23574 errmsg ("Missing script name");
23578 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
23579 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
23580 save_ifp = vam->ifp;
23581 save_line_number = vam->input_line_number;
23582 save_current_file = (char *) vam->current_file;
23584 vam->input_line_number = 0;
23586 vam->current_file = s;
23589 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
23590 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
23591 vam->ifp = save_ifp;
23592 vam->input_line_number = save_line_number;
23593 vam->current_file = (u8 *) save_current_file;
23598 clib_warning ("use the exec command...");
23604 echo (vat_main_t * vam)
23606 print (vam->ofp, "%v", vam->input->buffer);
23610 /* List of API message constructors, CLI names map to api_xxx */
23611 #define foreach_vpe_api_msg \
23612 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
23613 _(sw_interface_dump,"") \
23614 _(sw_interface_set_flags, \
23615 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
23616 _(sw_interface_add_del_address, \
23617 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
23618 _(sw_interface_set_rx_mode, \
23619 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
23620 _(sw_interface_set_rx_placement, \
23621 "<intfc> | sw_if_index <id> [queue <id>] [worker <id> | main]") \
23622 _(sw_interface_rx_placement_dump, \
23623 "[<intfc> | sw_if_index <id>]") \
23624 _(sw_interface_set_table, \
23625 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
23626 _(sw_interface_set_mpls_enable, \
23627 "<intfc> | sw_if_index [disable | dis]") \
23628 _(sw_interface_set_vpath, \
23629 "<intfc> | sw_if_index <id> enable | disable") \
23630 _(sw_interface_set_vxlan_bypass, \
23631 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23632 _(sw_interface_set_geneve_bypass, \
23633 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23634 _(sw_interface_set_l2_xconnect, \
23635 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23636 "enable | disable") \
23637 _(sw_interface_set_l2_bridge, \
23638 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
23639 "[shg <split-horizon-group>] [bvi]\n" \
23640 "enable | disable") \
23641 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
23642 _(bridge_domain_add_del, \
23643 "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") \
23644 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
23646 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
23647 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
23648 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
23650 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23652 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23654 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
23656 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
23658 "<vpp-if-name> | sw_if_index <id>") \
23659 _(sw_interface_tap_dump, "") \
23661 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>]") \
23663 "<vpp-if-name> | sw_if_index <id>") \
23664 _(sw_interface_tap_v2_dump, "") \
23666 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
23667 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]}") \
23669 "<vpp-if-name> | sw_if_index <id>") \
23671 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
23672 _(bond_detach_slave, \
23673 "sw_if_index <n>") \
23674 _(sw_interface_bond_dump, "") \
23675 _(sw_interface_slave_dump, \
23676 "<vpp-if-name> | sw_if_index <id>") \
23677 _(ip_table_add_del, \
23678 "table <n> [ipv6] [add | del]\n") \
23679 _(ip_add_del_route, \
23680 "<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
23681 "[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
23682 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
23683 "[multipath] [count <n>]") \
23684 _(ip_mroute_add_del, \
23685 "<src> <grp>/<mask> [table-id <n>]\n" \
23686 "[<intfc> | sw_if_index <id>] [local] [del]") \
23687 _(mpls_table_add_del, \
23688 "table <n> [add | del]\n") \
23689 _(mpls_route_add_del, \
23690 "<label> <eos> via <addr | next-hop-table <n> | via-label <n> |\n" \
23691 "lookup-ip4-table <n> | lookup-in-ip6-table <n> |\n" \
23692 "l2-input-on <intfc> | l2-input-on sw_if_index <id>>\n" \
23693 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>] [weight <n>]\n" \
23694 "[drop] [local] [classify <n>] [multipath] [count <n>] [del]") \
23695 _(mpls_ip_bind_unbind, \
23696 "<label> <addr/len>") \
23697 _(mpls_tunnel_add_del, \
23698 " via <addr> [table-id <n>]\n" \
23699 "sw_if_index <id>] [l2] [del]") \
23700 _(sr_mpls_policy_add, \
23701 "bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
23702 _(sr_mpls_policy_del, \
23704 _(bier_table_add_del, \
23705 "<label> <sub-domain> <set> <bsl> [del]") \
23706 _(bier_route_add_del, \
23707 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
23708 "[<intfc> | sw_if_index <id>]" \
23709 "[weight <n>] [del] [multipath]") \
23710 _(proxy_arp_add_del, \
23711 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
23712 _(proxy_arp_intfc_enable_disable, \
23713 "<intfc> | sw_if_index <id> enable | disable") \
23714 _(sw_interface_set_unnumbered, \
23715 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
23716 _(ip_neighbor_add_del, \
23717 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
23718 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
23719 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
23720 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
23721 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
23722 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
23723 "[outer_vlan_id_any][inner_vlan_id_any]") \
23724 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
23725 _(reset_fib, "vrf <n> [ipv6]") \
23726 _(dhcp_proxy_config, \
23727 "svr <v46-address> src <v46-address>\n" \
23728 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
23729 _(dhcp_proxy_set_vss, \
23730 "tbl_id <n> [fib_id <n> oui <n> | vpn_ascii_id <text>] [ipv6] [del]") \
23731 _(dhcp_proxy_dump, "ip6") \
23732 _(dhcp_client_config, \
23733 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
23734 _(set_ip_flow_hash, \
23735 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
23736 _(sw_interface_ip6_enable_disable, \
23737 "<intfc> | sw_if_index <id> enable | disable") \
23738 _(sw_interface_ip6_set_link_local_address, \
23739 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
23740 _(ip6nd_proxy_add_del, \
23741 "<intfc> | sw_if_index <id> <ip6-address>") \
23742 _(ip6nd_proxy_dump, "") \
23743 _(sw_interface_ip6nd_ra_prefix, \
23744 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
23745 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
23746 "[nolink] [isno]") \
23747 _(sw_interface_ip6nd_ra_config, \
23748 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
23749 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
23750 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
23751 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
23752 _(l2_patch_add_del, \
23753 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23754 "enable | disable") \
23755 _(sr_localsid_add_del, \
23756 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
23757 "fib-table <num> (end.psp) sw_if_index <num>") \
23758 _(classify_add_del_table, \
23759 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
23760 " [del] [del-chain] mask <mask-value>\n" \
23761 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
23762 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
23763 _(classify_add_del_session, \
23764 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
23765 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
23766 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
23767 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
23768 _(classify_set_interface_ip_table, \
23769 "<intfc> | sw_if_index <nn> table <nn>") \
23770 _(classify_set_interface_l2_tables, \
23771 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23772 " [other-table <nn>]") \
23773 _(get_node_index, "node <node-name") \
23774 _(add_node_next, "node <node-name> next <next-node-name>") \
23775 _(l2tpv3_create_tunnel, \
23776 "client_address <ip6-addr> our_address <ip6-addr>\n" \
23777 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
23778 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
23779 _(l2tpv3_set_tunnel_cookies, \
23780 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
23781 "[new_remote_cookie <nn>]\n") \
23782 _(l2tpv3_interface_enable_disable, \
23783 "<intfc> | sw_if_index <nn> enable | disable") \
23784 _(l2tpv3_set_lookup_key, \
23785 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
23786 _(sw_if_l2tpv3_tunnel_dump, "") \
23787 _(vxlan_offload_rx, \
23788 "hw { <interface name> | hw_if_index <nn>} " \
23789 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
23790 _(vxlan_add_del_tunnel, \
23791 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23792 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
23793 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23794 _(geneve_add_del_tunnel, \
23795 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23796 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23797 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23798 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23799 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23800 _(gre_add_del_tunnel, \
23801 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
23802 "[teb | erspan <session-id>] [del]") \
23803 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23804 _(l2_fib_clear_table, "") \
23805 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
23806 _(l2_interface_vlan_tag_rewrite, \
23807 "<intfc> | sw_if_index <nn> \n" \
23808 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
23809 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
23810 _(create_vhost_user_if, \
23811 "socket <filename> [server] [renumber <dev_instance>] " \
23812 "[disable_mrg_rxbuf] [disable_indirect_desc] " \
23813 "[mac <mac_address>]") \
23814 _(modify_vhost_user_if, \
23815 "<intfc> | sw_if_index <nn> socket <filename>\n" \
23816 "[server] [renumber <dev_instance>]") \
23817 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
23818 _(sw_interface_vhost_user_dump, "") \
23819 _(show_version, "") \
23820 _(show_threads, "") \
23821 _(vxlan_gpe_add_del_tunnel, \
23822 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
23823 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23824 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
23825 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
23826 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23827 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
23828 _(interface_name_renumber, \
23829 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
23830 _(input_acl_set_interface, \
23831 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23832 " [l2-table <nn>] [del]") \
23833 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
23834 _(ip_scan_neighbor_enable_disable, "[ip4|ip6|both|disable] [interval <n-min>]\n" \
23835 " [max-time <n-usec>] [max-update <n>] [delay <n-msec>] [stale <n-min>]") \
23836 _(want_ip4_arp_events, "address <ip4-address> [del]") \
23837 _(want_ip6_nd_events, "address <ip6-address> [del]") \
23838 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
23839 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
23840 _(ip_dump, "ipv4 | ipv6") \
23841 _(ipsec_spd_add_del, "spd_id <n> [del]") \
23842 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
23844 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
23845 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
23846 " integ_alg <alg> integ_key <hex>") \
23847 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
23848 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
23849 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
23850 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
23851 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
23852 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
23853 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
23854 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
23855 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
23856 " [instance <n>]") \
23857 _(ipsec_sa_dump, "[sa_id <n>]") \
23858 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
23859 " <alg> <hex>\n") \
23860 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
23861 _(ikev2_profile_add_del, "name <profile_name> [del]") \
23862 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
23863 "(auth_data 0x<data> | auth_data <data>)") \
23864 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
23865 "(id_data 0x<data> | id_data <data>) (local|remote)") \
23866 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
23867 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
23868 "(local|remote)") \
23869 _(ikev2_set_local_key, "file <absolute_file_path>") \
23870 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
23871 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23872 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23873 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
23874 _(ikev2_initiate_sa_init, "<profile_name>") \
23875 _(ikev2_initiate_del_ike_sa, "<ispi>") \
23876 _(ikev2_initiate_del_child_sa, "<ispi>") \
23877 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
23878 _(delete_loopback,"sw_if_index <nn>") \
23879 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
23880 _(bd_ip_mac_dump, "[bd_id] <id>") \
23881 _(want_interface_events, "enable|disable") \
23882 _(want_stats,"enable|disable") \
23883 _(get_first_msg_id, "client <name>") \
23884 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
23885 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
23886 "fib-id <nn> [ip4][ip6][default]") \
23887 _(get_node_graph, " ") \
23888 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
23889 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
23890 _(ioam_disable, "") \
23891 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
23892 " sw_if_index <sw_if_index> p <priority> " \
23893 "w <weight>] [del]") \
23894 _(one_add_del_locator, "locator-set <locator_name> " \
23895 "iface <intf> | sw_if_index <sw_if_index> " \
23896 "p <priority> w <weight> [del]") \
23897 _(one_add_del_local_eid,"vni <vni> eid " \
23898 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23899 "locator-set <locator_name> [del]" \
23900 "[key-id sha1|sha256 secret-key <secret-key>]")\
23901 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
23902 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
23903 _(one_enable_disable, "enable|disable") \
23904 _(one_map_register_enable_disable, "enable|disable") \
23905 _(one_map_register_fallback_threshold, "<value>") \
23906 _(one_rloc_probe_enable_disable, "enable|disable") \
23907 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23909 "rloc <locator> p <prio> " \
23910 "w <weight> [rloc <loc> ... ] " \
23911 "action <action> [del-all]") \
23912 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23914 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23915 _(one_use_petr, "ip-address> | disable") \
23916 _(one_map_request_mode, "src-dst|dst-only") \
23917 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23918 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23919 _(one_locator_set_dump, "[local | remote]") \
23920 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
23921 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23922 "[local] | [remote]") \
23923 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
23924 _(one_ndp_bd_get, "") \
23925 _(one_ndp_entries_get, "bd <bridge-domain>") \
23926 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
23927 _(one_l2_arp_bd_get, "") \
23928 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
23929 _(one_stats_enable_disable, "enable|disable") \
23930 _(show_one_stats_enable_disable, "") \
23931 _(one_eid_table_vni_dump, "") \
23932 _(one_eid_table_map_dump, "l2|l3") \
23933 _(one_map_resolver_dump, "") \
23934 _(one_map_server_dump, "") \
23935 _(one_adjacencies_get, "vni <vni>") \
23936 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
23937 _(show_one_rloc_probe_state, "") \
23938 _(show_one_map_register_state, "") \
23939 _(show_one_status, "") \
23940 _(one_stats_dump, "") \
23941 _(one_stats_flush, "") \
23942 _(one_get_map_request_itr_rlocs, "") \
23943 _(one_map_register_set_ttl, "<ttl>") \
23944 _(one_set_transport_protocol, "udp|api") \
23945 _(one_get_transport_protocol, "") \
23946 _(one_enable_disable_xtr_mode, "enable|disable") \
23947 _(one_show_xtr_mode, "") \
23948 _(one_enable_disable_pitr_mode, "enable|disable") \
23949 _(one_show_pitr_mode, "") \
23950 _(one_enable_disable_petr_mode, "enable|disable") \
23951 _(one_show_petr_mode, "") \
23952 _(show_one_nsh_mapping, "") \
23953 _(show_one_pitr, "") \
23954 _(show_one_use_petr, "") \
23955 _(show_one_map_request_mode, "") \
23956 _(show_one_map_register_ttl, "") \
23957 _(show_one_map_register_fallback_threshold, "") \
23958 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
23959 " sw_if_index <sw_if_index> p <priority> " \
23960 "w <weight>] [del]") \
23961 _(lisp_add_del_locator, "locator-set <locator_name> " \
23962 "iface <intf> | sw_if_index <sw_if_index> " \
23963 "p <priority> w <weight> [del]") \
23964 _(lisp_add_del_local_eid,"vni <vni> eid " \
23965 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23966 "locator-set <locator_name> [del]" \
23967 "[key-id sha1|sha256 secret-key <secret-key>]") \
23968 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
23969 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
23970 _(lisp_enable_disable, "enable|disable") \
23971 _(lisp_map_register_enable_disable, "enable|disable") \
23972 _(lisp_rloc_probe_enable_disable, "enable|disable") \
23973 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23975 "rloc <locator> p <prio> " \
23976 "w <weight> [rloc <loc> ... ] " \
23977 "action <action> [del-all]") \
23978 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23980 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23981 _(lisp_use_petr, "<ip-address> | disable") \
23982 _(lisp_map_request_mode, "src-dst|dst-only") \
23983 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23984 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23985 _(lisp_locator_set_dump, "[local | remote]") \
23986 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
23987 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23988 "[local] | [remote]") \
23989 _(lisp_eid_table_vni_dump, "") \
23990 _(lisp_eid_table_map_dump, "l2|l3") \
23991 _(lisp_map_resolver_dump, "") \
23992 _(lisp_map_server_dump, "") \
23993 _(lisp_adjacencies_get, "vni <vni>") \
23994 _(gpe_fwd_entry_vnis_get, "") \
23995 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
23996 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
23997 "[table <table-id>]") \
23998 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
23999 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
24000 _(gpe_set_encap_mode, "lisp|vxlan") \
24001 _(gpe_get_encap_mode, "") \
24002 _(lisp_gpe_add_del_iface, "up|down") \
24003 _(lisp_gpe_enable_disable, "enable|disable") \
24004 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
24005 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
24006 _(show_lisp_rloc_probe_state, "") \
24007 _(show_lisp_map_register_state, "") \
24008 _(show_lisp_status, "") \
24009 _(lisp_get_map_request_itr_rlocs, "") \
24010 _(show_lisp_pitr, "") \
24011 _(show_lisp_use_petr, "") \
24012 _(show_lisp_map_request_mode, "") \
24013 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
24014 _(af_packet_delete, "name <host interface name>") \
24015 _(af_packet_dump, "") \
24016 _(policer_add_del, "name <policer name> <params> [del]") \
24017 _(policer_dump, "[name <policer name>]") \
24018 _(policer_classify_set_interface, \
24019 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
24020 " [l2-table <nn>] [del]") \
24021 _(policer_classify_dump, "type [ip4|ip6|l2]") \
24022 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
24023 "[master|slave]") \
24024 _(netmap_delete, "name <interface name>") \
24025 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
24026 _(mpls_fib_dump, "") \
24027 _(classify_table_ids, "") \
24028 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
24029 _(classify_table_info, "table_id <nn>") \
24030 _(classify_session_dump, "table_id <nn>") \
24031 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
24032 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
24033 "[template_interval <nn>] [udp_checksum]") \
24034 _(ipfix_exporter_dump, "") \
24035 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
24036 _(ipfix_classify_stream_dump, "") \
24037 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
24038 _(ipfix_classify_table_dump, "") \
24039 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
24040 _(sw_interface_span_dump, "[l2]") \
24041 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
24042 _(pg_create_interface, "if_id <nn>") \
24043 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
24044 _(pg_enable_disable, "[stream <id>] disable") \
24045 _(ip_source_and_port_range_check_add_del, \
24046 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
24047 _(ip_source_and_port_range_check_interface_add_del, \
24048 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
24049 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
24050 _(ipsec_gre_add_del_tunnel, \
24051 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
24052 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
24053 _(delete_subif,"<intfc> | sw_if_index <nn>") \
24054 _(l2_interface_pbb_tag_rewrite, \
24055 "<intfc> | sw_if_index <nn> \n" \
24056 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
24057 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
24058 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
24059 _(flow_classify_set_interface, \
24060 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
24061 _(flow_classify_dump, "type [ip4|ip6]") \
24062 _(ip_fib_dump, "") \
24063 _(ip_mfib_dump, "") \
24064 _(ip6_fib_dump, "") \
24065 _(ip6_mfib_dump, "") \
24066 _(feature_enable_disable, "arc_name <arc_name> " \
24067 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
24068 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
24070 _(l2_xconnect_dump, "") \
24071 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
24072 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
24073 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
24074 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
24075 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
24076 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
24077 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
24078 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
24079 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
24080 _(sock_init_shm, "size <nnn>") \
24081 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
24082 _(dns_enable_disable, "[enable][disable]") \
24083 _(dns_name_server_add_del, "<ip-address> [del]") \
24084 _(dns_resolve_name, "<hostname>") \
24085 _(dns_resolve_ip, "<ip4|ip6>") \
24086 _(dns_name_server_add_del, "<ip-address> [del]") \
24087 _(dns_resolve_name, "<hostname>") \
24088 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
24089 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
24090 _(session_rules_dump, "") \
24091 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
24092 _(output_acl_set_interface, \
24093 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
24094 " [l2-table <nn>] [del]") \
24095 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
24097 /* List of command functions, CLI names map directly to functions */
24098 #define foreach_cli_function \
24099 _(comment, "usage: comment <ignore-rest-of-line>") \
24100 _(dump_interface_table, "usage: dump_interface_table") \
24101 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
24102 _(dump_ipv4_table, "usage: dump_ipv4_table") \
24103 _(dump_ipv6_table, "usage: dump_ipv6_table") \
24104 _(dump_stats_table, "usage: dump_stats_table") \
24105 _(dump_macro_table, "usage: dump_macro_table ") \
24106 _(dump_node_table, "usage: dump_node_table") \
24107 _(dump_msg_api_table, "usage: dump_msg_api_table") \
24108 _(get_msg_id, "usage: get_msg_id name_and_crc") \
24109 _(echo, "usage: echo <message>") \
24110 _(exec, "usage: exec <vpe-debug-CLI-command>") \
24111 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
24112 _(help, "usage: help") \
24113 _(q, "usage: quit") \
24114 _(quit, "usage: quit") \
24115 _(search_node_table, "usage: search_node_table <name>...") \
24116 _(set, "usage: set <variable-name> <value>") \
24117 _(script, "usage: script <file-name>") \
24118 _(statseg, "usage: statseg"); \
24119 _(unset, "usage: unset <variable-name>")
24122 static void vl_api_##n##_t_handler_uni \
24123 (vl_api_##n##_t * mp) \
24125 vat_main_t * vam = &vat_main; \
24126 if (vam->json_output) { \
24127 vl_api_##n##_t_handler_json(mp); \
24129 vl_api_##n##_t_handler(mp); \
24132 foreach_vpe_api_reply_msg;
24133 #if VPP_API_TEST_BUILTIN == 0
24134 foreach_standalone_reply_msg;
24139 vat_api_hookup (vat_main_t * vam)
24142 vl_msg_api_set_handlers(VL_API_##N, #n, \
24143 vl_api_##n##_t_handler_uni, \
24145 vl_api_##n##_t_endian, \
24146 vl_api_##n##_t_print, \
24147 sizeof(vl_api_##n##_t), 1);
24148 foreach_vpe_api_reply_msg;
24149 #if VPP_API_TEST_BUILTIN == 0
24150 foreach_standalone_reply_msg;
24154 #if (VPP_API_TEST_BUILTIN==0)
24155 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
24157 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
24159 vam->function_by_name = hash_create_string (0, sizeof (uword));
24161 vam->help_by_name = hash_create_string (0, sizeof (uword));
24164 /* API messages we can send */
24165 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
24166 foreach_vpe_api_msg;
24170 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
24171 foreach_vpe_api_msg;
24174 /* CLI functions */
24175 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
24176 foreach_cli_function;
24180 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
24181 foreach_cli_function;
24185 #if VPP_API_TEST_BUILTIN
24186 static clib_error_t *
24187 vat_api_hookup_shim (vlib_main_t * vm)
24189 vat_api_hookup (&vat_main);
24193 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
24197 * fd.io coding-style-patch-verification: ON
24200 * eval: (c-set-style "gnu")