2 *------------------------------------------------------------------
5 * Copyright (c) 2014-2016 Cisco and/or its affiliates.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *------------------------------------------------------------------
21 #include <vppinfra/socket.h>
22 #include <vlibapi/api.h>
23 #include <vlibmemory/api.h>
24 #include <vnet/ip/ip.h>
25 #include <vnet/ip/ip_neighbor.h>
26 #include <vnet/l2/l2_input.h>
27 #include <vnet/l2tp/l2tp.h>
28 #include <vnet/vxlan/vxlan.h>
29 #include <vnet/geneve/geneve.h>
30 #include <vnet/gre/gre.h>
31 #include <vnet/vxlan-gpe/vxlan_gpe.h>
32 #include <vnet/lisp-gpe/lisp_gpe.h>
34 #include <vpp/api/vpe_msg_enum.h>
35 #include <vnet/l2/l2_classify.h>
36 #include <vnet/l2/l2_vtr.h>
37 #include <vnet/classify/in_out_acl.h>
38 #include <vnet/classify/policer_classify.h>
39 #include <vnet/classify/flow_classify.h>
40 #include <vnet/mpls/mpls.h>
41 #include <vnet/ipsec/ipsec.h>
42 #include <vnet/ipsec/ikev2.h>
44 #include <vnet/cop/cop.h>
45 #include <vnet/ip/ip6_hop_by_hop.h>
46 #include <vnet/ip/ip_source_and_port_range_check.h>
47 #include <vnet/policer/xlate.h>
48 #include <vnet/span/span.h>
49 #include <vnet/policer/policer.h>
50 #include <vnet/policer/police.h>
51 #include <vnet/mfib/mfib_types.h>
52 #include <vnet/dhcp/dhcp_proxy.h>
53 #include <vnet/bonding/node.h>
54 #include <vnet/qos/qos_types.h>
55 #include "vat/json_format.h"
60 #define vl_typedefs /* define message structures */
61 #include <vpp/api/vpe_all_api_h.h>
64 /* declare message handlers for each api */
66 #define vl_endianfun /* define message structures */
67 #include <vpp/api/vpe_all_api_h.h>
70 /* instantiate all the print functions we know about */
71 #define vl_print(handle, ...)
73 #include <vpp/api/vpe_all_api_h.h>
76 #define __plugin_msg_base 0
77 #include <vlibapi/vat_helper_macros.h>
79 #if VPP_API_TEST_BUILTIN == 0
89 vat_socket_connect (vat_main_t * vam)
91 vam->socket_client_main = &socket_client_main;
92 return vl_socket_client_connect ((char *) vam->socket_name, "vpp_api_test",
93 0 /* default socket rx, tx buffer */ );
95 #else /* vpp built-in case, we don't do sockets... */
97 vat_socket_connect (vat_main_t * vam)
103 vl_socket_client_read (int wait)
109 vl_socket_client_write ()
115 vl_socket_client_msg_alloc (int nbytes)
123 vat_time_now (vat_main_t * vam)
125 #if VPP_API_TEST_BUILTIN
126 return vlib_time_now (vam->vlib_main);
128 return clib_time_now (&vam->clib_time);
133 errmsg (char *fmt, ...)
135 vat_main_t *vam = &vat_main;
140 s = va_format (0, fmt, &va);
145 #if VPP_API_TEST_BUILTIN
146 vlib_cli_output (vam->vlib_main, (char *) s);
149 if (vam->ifp != stdin)
150 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
151 vam->input_line_number);
152 fformat (vam->ofp, (char *) s);
160 #if VPP_API_TEST_BUILTIN == 0
162 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
164 vat_main_t *vam = va_arg (*args, vat_main_t *);
165 u32 *result = va_arg (*args, u32 *);
169 if (!unformat (input, "%s", &if_name))
172 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
180 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
185 /* Parse an IP4 address %d.%d.%d.%d. */
187 unformat_ip4_address (unformat_input_t * input, va_list * args)
189 u8 *result = va_arg (*args, u8 *);
192 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
195 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
207 unformat_ethernet_address (unformat_input_t * input, va_list * args)
209 u8 *result = va_arg (*args, u8 *);
212 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
213 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
217 for (i = 0; i < 6; i++)
218 if (a[i] >= (1 << 8))
221 for (i = 0; i < 6; i++)
227 /* Returns ethernet type as an int in host byte order. */
229 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
232 u16 *result = va_arg (*args, u16 *);
236 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
238 if (type >= (1 << 16))
246 /* Parse an IP6 address. */
248 unformat_ip6_address (unformat_input_t * input, va_list * args)
250 ip6_address_t *result = va_arg (*args, ip6_address_t *);
252 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
253 uword c, n_colon, double_colon_index;
255 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
256 double_colon_index = ARRAY_LEN (hex_quads);
257 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
260 if (c >= '0' && c <= '9')
262 else if (c >= 'a' && c <= 'f')
263 hex_digit = c + 10 - 'a';
264 else if (c >= 'A' && c <= 'F')
265 hex_digit = c + 10 - 'A';
266 else if (c == ':' && n_colon < 2)
270 unformat_put_input (input);
274 /* Too many hex quads. */
275 if (n_hex_quads >= ARRAY_LEN (hex_quads))
280 hex_quad = (hex_quad << 4) | hex_digit;
282 /* Hex quad must fit in 16 bits. */
283 if (n_hex_digits >= 4)
290 /* Save position of :: */
293 /* More than one :: ? */
294 if (double_colon_index < ARRAY_LEN (hex_quads))
296 double_colon_index = n_hex_quads;
299 if (n_colon > 0 && n_hex_digits > 0)
301 hex_quads[n_hex_quads++] = hex_quad;
307 if (n_hex_digits > 0)
308 hex_quads[n_hex_quads++] = hex_quad;
313 /* Expand :: to appropriate number of zero hex quads. */
314 if (double_colon_index < ARRAY_LEN (hex_quads))
316 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
318 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
319 hex_quads[n_zero + i] = hex_quads[i];
321 for (i = 0; i < n_zero; i++)
322 hex_quads[double_colon_index + i] = 0;
324 n_hex_quads = ARRAY_LEN (hex_quads);
327 /* Too few hex quads given. */
328 if (n_hex_quads < ARRAY_LEN (hex_quads))
331 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
332 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
339 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
341 u32 *r = va_arg (*args, u32 *);
344 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
345 foreach_ipsec_policy_action
353 unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args)
355 u32 *r = va_arg (*args, u32 *);
358 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
359 foreach_ipsec_crypto_alg
367 format_ipsec_crypto_alg (u8 * s, va_list * args)
369 u32 i = va_arg (*args, u32);
374 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
375 foreach_ipsec_crypto_alg
378 return format (s, "unknown");
380 return format (s, "%s", t);
384 unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args)
386 u32 *r = va_arg (*args, u32 *);
389 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f;
390 foreach_ipsec_integ_alg
398 format_ipsec_integ_alg (u8 * s, va_list * args)
400 u32 i = va_arg (*args, u32);
405 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
406 foreach_ipsec_integ_alg
409 return format (s, "unknown");
411 return format (s, "%s", t);
415 unformat_ikev2_auth_method (unformat_input_t * input, va_list * args)
417 u32 *r = va_arg (*args, u32 *);
420 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f;
421 foreach_ikev2_auth_method
429 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
431 u32 *r = va_arg (*args, u32 *);
434 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
435 foreach_ikev2_id_type
441 #else /* VPP_API_TEST_BUILTIN == 1 */
443 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
445 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
446 vnet_main_t *vnm = vnet_get_main ();
447 u32 *result = va_arg (*args, u32 *);
449 return unformat (input, "%U", unformat_vnet_sw_interface, vnm, result);
453 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
455 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
456 vnet_main_t *vnm = vnet_get_main ();
457 u32 *result = va_arg (*args, u32 *);
459 return unformat (input, "%U", unformat_vnet_hw_interface, vnm, result);
462 #endif /* VPP_API_TEST_BUILTIN */
465 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
467 u8 *r = va_arg (*args, u8 *);
469 if (unformat (input, "kbps"))
470 *r = SSE2_QOS_RATE_KBPS;
471 else if (unformat (input, "pps"))
472 *r = SSE2_QOS_RATE_PPS;
479 unformat_policer_round_type (unformat_input_t * input, va_list * args)
481 u8 *r = va_arg (*args, u8 *);
483 if (unformat (input, "closest"))
484 *r = SSE2_QOS_ROUND_TO_CLOSEST;
485 else if (unformat (input, "up"))
486 *r = SSE2_QOS_ROUND_TO_UP;
487 else if (unformat (input, "down"))
488 *r = SSE2_QOS_ROUND_TO_DOWN;
495 unformat_policer_type (unformat_input_t * input, va_list * args)
497 u8 *r = va_arg (*args, u8 *);
499 if (unformat (input, "1r2c"))
500 *r = SSE2_QOS_POLICER_TYPE_1R2C;
501 else if (unformat (input, "1r3c"))
502 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
503 else if (unformat (input, "2r3c-2698"))
504 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
505 else if (unformat (input, "2r3c-4115"))
506 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
507 else if (unformat (input, "2r3c-mef5cf1"))
508 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
515 unformat_dscp (unformat_input_t * input, va_list * va)
517 u8 *r = va_arg (*va, u8 *);
520 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
529 unformat_policer_action_type (unformat_input_t * input, va_list * va)
531 sse2_qos_pol_action_params_st *a
532 = va_arg (*va, sse2_qos_pol_action_params_st *);
534 if (unformat (input, "drop"))
535 a->action_type = SSE2_QOS_ACTION_DROP;
536 else if (unformat (input, "transmit"))
537 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
538 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
539 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
546 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
548 u32 *r = va_arg (*va, u32 *);
551 if (unformat (input, "ip4"))
552 tid = POLICER_CLASSIFY_TABLE_IP4;
553 else if (unformat (input, "ip6"))
554 tid = POLICER_CLASSIFY_TABLE_IP6;
555 else if (unformat (input, "l2"))
556 tid = POLICER_CLASSIFY_TABLE_L2;
565 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
567 u32 *r = va_arg (*va, u32 *);
570 if (unformat (input, "ip4"))
571 tid = FLOW_CLASSIFY_TABLE_IP4;
572 else if (unformat (input, "ip6"))
573 tid = FLOW_CLASSIFY_TABLE_IP6;
581 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
582 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
583 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
584 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
586 #if (VPP_API_TEST_BUILTIN==0)
588 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
590 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
591 mfib_itf_attribute_t attr;
594 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
596 if (unformat (input, mfib_itf_flag_long_names[attr]))
597 *iflags |= (1 << attr);
599 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
601 if (unformat (input, mfib_itf_flag_names[attr]))
602 *iflags |= (1 << attr);
605 return (old == *iflags ? 0 : 1);
609 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
611 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
612 mfib_entry_attribute_t attr;
615 FOR_EACH_MFIB_ATTRIBUTE (attr)
617 if (unformat (input, mfib_flag_long_names[attr]))
618 *eflags |= (1 << attr);
620 FOR_EACH_MFIB_ATTRIBUTE (attr)
622 if (unformat (input, mfib_flag_names[attr]))
623 *eflags |= (1 << attr);
626 return (old == *eflags ? 0 : 1);
630 format_ip4_address (u8 * s, va_list * args)
632 u8 *a = va_arg (*args, u8 *);
633 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
637 format_ip6_address (u8 * s, va_list * args)
639 ip6_address_t *a = va_arg (*args, ip6_address_t *);
640 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
642 i_max_n_zero = ARRAY_LEN (a->as_u16);
644 i_first_zero = i_max_n_zero;
646 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
648 u32 is_zero = a->as_u16[i] == 0;
649 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
655 if ((!is_zero && n_zeros > max_n_zeros)
656 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
658 i_max_n_zero = i_first_zero;
659 max_n_zeros = n_zeros;
660 i_first_zero = ARRAY_LEN (a->as_u16);
665 last_double_colon = 0;
666 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
668 if (i == i_max_n_zero && max_n_zeros > 1)
670 s = format (s, "::");
671 i += max_n_zeros - 1;
672 last_double_colon = 1;
676 s = format (s, "%s%x",
677 (last_double_colon || i == 0) ? "" : ":",
678 clib_net_to_host_u16 (a->as_u16[i]));
679 last_double_colon = 0;
686 /* Format an IP46 address. */
688 format_ip46_address (u8 * s, va_list * args)
690 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
691 ip46_type_t type = va_arg (*args, ip46_type_t);
697 is_ip4 = ip46_address_is_ip4 (ip46);
708 format (s, "%U", format_ip4_address, &ip46->ip4) :
709 format (s, "%U", format_ip6_address, &ip46->ip6);
713 format_ethernet_address (u8 * s, va_list * args)
715 u8 *a = va_arg (*args, u8 *);
717 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
718 a[0], a[1], a[2], a[3], a[4], a[5]);
723 increment_v4_address (ip4_address_t * a)
727 v = ntohl (a->as_u32) + 1;
728 a->as_u32 = ntohl (v);
732 increment_v6_address (ip6_address_t * a)
736 v0 = clib_net_to_host_u64 (a->as_u64[0]);
737 v1 = clib_net_to_host_u64 (a->as_u64[1]);
742 a->as_u64[0] = clib_net_to_host_u64 (v0);
743 a->as_u64[1] = clib_net_to_host_u64 (v1);
747 increment_mac_address (u8 * mac)
749 u64 tmp = *((u64 *) mac);
750 tmp = clib_net_to_host_u64 (tmp);
751 tmp += 1 << 16; /* skip unused (least significant) octets */
752 tmp = clib_host_to_net_u64 (tmp);
754 clib_memcpy (mac, &tmp, 6);
757 static void vl_api_create_loopback_reply_t_handler
758 (vl_api_create_loopback_reply_t * mp)
760 vat_main_t *vam = &vat_main;
761 i32 retval = ntohl (mp->retval);
763 vam->retval = retval;
764 vam->regenerate_interface_table = 1;
765 vam->sw_if_index = ntohl (mp->sw_if_index);
766 vam->result_ready = 1;
769 static void vl_api_create_loopback_reply_t_handler_json
770 (vl_api_create_loopback_reply_t * mp)
772 vat_main_t *vam = &vat_main;
773 vat_json_node_t node;
775 vat_json_init_object (&node);
776 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
777 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
779 vat_json_print (vam->ofp, &node);
780 vat_json_free (&node);
781 vam->retval = ntohl (mp->retval);
782 vam->result_ready = 1;
785 static void vl_api_create_loopback_instance_reply_t_handler
786 (vl_api_create_loopback_instance_reply_t * mp)
788 vat_main_t *vam = &vat_main;
789 i32 retval = ntohl (mp->retval);
791 vam->retval = retval;
792 vam->regenerate_interface_table = 1;
793 vam->sw_if_index = ntohl (mp->sw_if_index);
794 vam->result_ready = 1;
797 static void vl_api_create_loopback_instance_reply_t_handler_json
798 (vl_api_create_loopback_instance_reply_t * mp)
800 vat_main_t *vam = &vat_main;
801 vat_json_node_t node;
803 vat_json_init_object (&node);
804 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
805 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
807 vat_json_print (vam->ofp, &node);
808 vat_json_free (&node);
809 vam->retval = ntohl (mp->retval);
810 vam->result_ready = 1;
813 static void vl_api_af_packet_create_reply_t_handler
814 (vl_api_af_packet_create_reply_t * mp)
816 vat_main_t *vam = &vat_main;
817 i32 retval = ntohl (mp->retval);
819 vam->retval = retval;
820 vam->regenerate_interface_table = 1;
821 vam->sw_if_index = ntohl (mp->sw_if_index);
822 vam->result_ready = 1;
825 static void vl_api_af_packet_create_reply_t_handler_json
826 (vl_api_af_packet_create_reply_t * mp)
828 vat_main_t *vam = &vat_main;
829 vat_json_node_t node;
831 vat_json_init_object (&node);
832 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
833 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
835 vat_json_print (vam->ofp, &node);
836 vat_json_free (&node);
838 vam->retval = ntohl (mp->retval);
839 vam->result_ready = 1;
842 static void vl_api_create_vlan_subif_reply_t_handler
843 (vl_api_create_vlan_subif_reply_t * mp)
845 vat_main_t *vam = &vat_main;
846 i32 retval = ntohl (mp->retval);
848 vam->retval = retval;
849 vam->regenerate_interface_table = 1;
850 vam->sw_if_index = ntohl (mp->sw_if_index);
851 vam->result_ready = 1;
854 static void vl_api_create_vlan_subif_reply_t_handler_json
855 (vl_api_create_vlan_subif_reply_t * mp)
857 vat_main_t *vam = &vat_main;
858 vat_json_node_t node;
860 vat_json_init_object (&node);
861 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
862 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
864 vat_json_print (vam->ofp, &node);
865 vat_json_free (&node);
867 vam->retval = ntohl (mp->retval);
868 vam->result_ready = 1;
871 static void vl_api_create_subif_reply_t_handler
872 (vl_api_create_subif_reply_t * mp)
874 vat_main_t *vam = &vat_main;
875 i32 retval = ntohl (mp->retval);
877 vam->retval = retval;
878 vam->regenerate_interface_table = 1;
879 vam->sw_if_index = ntohl (mp->sw_if_index);
880 vam->result_ready = 1;
883 static void vl_api_create_subif_reply_t_handler_json
884 (vl_api_create_subif_reply_t * mp)
886 vat_main_t *vam = &vat_main;
887 vat_json_node_t node;
889 vat_json_init_object (&node);
890 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
891 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
893 vat_json_print (vam->ofp, &node);
894 vat_json_free (&node);
896 vam->retval = ntohl (mp->retval);
897 vam->result_ready = 1;
900 static void vl_api_interface_name_renumber_reply_t_handler
901 (vl_api_interface_name_renumber_reply_t * mp)
903 vat_main_t *vam = &vat_main;
904 i32 retval = ntohl (mp->retval);
906 vam->retval = retval;
907 vam->regenerate_interface_table = 1;
908 vam->result_ready = 1;
911 static void vl_api_interface_name_renumber_reply_t_handler_json
912 (vl_api_interface_name_renumber_reply_t * mp)
914 vat_main_t *vam = &vat_main;
915 vat_json_node_t node;
917 vat_json_init_object (&node);
918 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
920 vat_json_print (vam->ofp, &node);
921 vat_json_free (&node);
923 vam->retval = ntohl (mp->retval);
924 vam->result_ready = 1;
928 * Special-case: build the interface table, maintain
929 * the next loopback sw_if_index vbl.
931 static void vl_api_sw_interface_details_t_handler
932 (vl_api_sw_interface_details_t * mp)
934 vat_main_t *vam = &vat_main;
935 u8 *s = format (0, "%s%c", mp->interface_name, 0);
937 hash_set_mem (vam->sw_if_index_by_interface_name, s,
938 ntohl (mp->sw_if_index));
940 /* In sub interface case, fill the sub interface table entry */
941 if (mp->sw_if_index != mp->sup_sw_if_index)
943 sw_interface_subif_t *sub = NULL;
945 vec_add2 (vam->sw_if_subif_table, sub, 1);
947 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
948 strncpy ((char *) sub->interface_name, (char *) s,
949 vec_len (sub->interface_name));
950 sub->sw_if_index = ntohl (mp->sw_if_index);
951 sub->sub_id = ntohl (mp->sub_id);
953 sub->sub_dot1ad = mp->sub_dot1ad;
954 sub->sub_number_of_tags = mp->sub_number_of_tags;
955 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
956 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
957 sub->sub_exact_match = mp->sub_exact_match;
958 sub->sub_default = mp->sub_default;
959 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
960 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
962 /* vlan tag rewrite */
963 sub->vtr_op = ntohl (mp->vtr_op);
964 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
965 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
966 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
970 static void vl_api_sw_interface_details_t_handler_json
971 (vl_api_sw_interface_details_t * mp)
973 vat_main_t *vam = &vat_main;
974 vat_json_node_t *node = NULL;
976 if (VAT_JSON_ARRAY != vam->json_tree.type)
978 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
979 vat_json_init_array (&vam->json_tree);
981 node = vat_json_array_add (&vam->json_tree);
983 vat_json_init_object (node);
984 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
985 vat_json_object_add_uint (node, "sup_sw_if_index",
986 ntohl (mp->sup_sw_if_index));
987 vat_json_object_add_uint (node, "l2_address_length",
988 ntohl (mp->l2_address_length));
989 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
990 sizeof (mp->l2_address));
991 vat_json_object_add_string_copy (node, "interface_name",
993 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
994 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
995 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
996 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
997 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
998 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
999 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
1000 vat_json_object_add_uint (node, "sub_number_of_tags",
1001 mp->sub_number_of_tags);
1002 vat_json_object_add_uint (node, "sub_outer_vlan_id",
1003 ntohs (mp->sub_outer_vlan_id));
1004 vat_json_object_add_uint (node, "sub_inner_vlan_id",
1005 ntohs (mp->sub_inner_vlan_id));
1006 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
1007 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
1008 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
1009 mp->sub_outer_vlan_id_any);
1010 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
1011 mp->sub_inner_vlan_id_any);
1012 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
1013 vat_json_object_add_uint (node, "vtr_push_dot1q",
1014 ntohl (mp->vtr_push_dot1q));
1015 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
1016 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
1019 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
1021 format_ethernet_address,
1023 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
1025 format_ethernet_address,
1027 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
1028 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
1032 #if VPP_API_TEST_BUILTIN == 0
1033 static void vl_api_sw_interface_event_t_handler
1034 (vl_api_sw_interface_event_t * mp)
1036 vat_main_t *vam = &vat_main;
1037 if (vam->interface_event_display)
1038 errmsg ("interface flags: sw_if_index %d %s %s",
1039 ntohl (mp->sw_if_index),
1040 mp->admin_up_down ? "admin-up" : "admin-down",
1041 mp->link_up_down ? "link-up" : "link-down");
1045 static void vl_api_sw_interface_event_t_handler_json
1046 (vl_api_sw_interface_event_t * mp)
1048 /* JSON output not supported */
1052 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
1054 vat_main_t *vam = &vat_main;
1055 i32 retval = ntohl (mp->retval);
1057 vam->retval = retval;
1058 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1059 vam->result_ready = 1;
1063 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1065 vat_main_t *vam = &vat_main;
1066 vat_json_node_t node;
1067 api_main_t *am = &api_main;
1071 vat_json_init_object (&node);
1072 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1073 vat_json_object_add_uint (&node, "reply_in_shmem",
1074 ntohl (mp->reply_in_shmem));
1075 /* Toss the shared-memory original... */
1076 pthread_mutex_lock (&am->vlib_rp->mutex);
1077 oldheap = svm_push_data_heap (am->vlib_rp);
1079 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1082 svm_pop_heap (oldheap);
1083 pthread_mutex_unlock (&am->vlib_rp->mutex);
1085 vat_json_print (vam->ofp, &node);
1086 vat_json_free (&node);
1088 vam->retval = ntohl (mp->retval);
1089 vam->result_ready = 1;
1093 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1095 vat_main_t *vam = &vat_main;
1096 i32 retval = ntohl (mp->retval);
1097 u32 length = ntohl (mp->length);
1099 vec_reset_length (vam->cmd_reply);
1101 vam->retval = retval;
1104 vec_validate (vam->cmd_reply, length);
1105 clib_memcpy ((char *) (vam->cmd_reply), mp->reply, length);
1106 vam->cmd_reply[length] = 0;
1108 vam->result_ready = 1;
1112 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1114 vat_main_t *vam = &vat_main;
1115 vat_json_node_t node;
1117 vec_reset_length (vam->cmd_reply);
1119 vat_json_init_object (&node);
1120 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1121 vat_json_object_add_string_copy (&node, "reply", mp->reply);
1123 vat_json_print (vam->ofp, &node);
1124 vat_json_free (&node);
1126 vam->retval = ntohl (mp->retval);
1127 vam->result_ready = 1;
1130 static void vl_api_classify_add_del_table_reply_t_handler
1131 (vl_api_classify_add_del_table_reply_t * mp)
1133 vat_main_t *vam = &vat_main;
1134 i32 retval = ntohl (mp->retval);
1135 if (vam->async_mode)
1137 vam->async_errors += (retval < 0);
1141 vam->retval = retval;
1143 ((mp->new_table_index != 0xFFFFFFFF) ||
1144 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1145 (mp->match_n_vectors != 0xFFFFFFFF)))
1147 * Note: this is just barely thread-safe, depends on
1148 * the main thread spinning waiting for an answer...
1150 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1151 ntohl (mp->new_table_index),
1152 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1153 vam->result_ready = 1;
1157 static void vl_api_classify_add_del_table_reply_t_handler_json
1158 (vl_api_classify_add_del_table_reply_t * mp)
1160 vat_main_t *vam = &vat_main;
1161 vat_json_node_t node;
1163 vat_json_init_object (&node);
1164 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1165 vat_json_object_add_uint (&node, "new_table_index",
1166 ntohl (mp->new_table_index));
1167 vat_json_object_add_uint (&node, "skip_n_vectors",
1168 ntohl (mp->skip_n_vectors));
1169 vat_json_object_add_uint (&node, "match_n_vectors",
1170 ntohl (mp->match_n_vectors));
1172 vat_json_print (vam->ofp, &node);
1173 vat_json_free (&node);
1175 vam->retval = ntohl (mp->retval);
1176 vam->result_ready = 1;
1179 static void vl_api_get_node_index_reply_t_handler
1180 (vl_api_get_node_index_reply_t * mp)
1182 vat_main_t *vam = &vat_main;
1183 i32 retval = ntohl (mp->retval);
1184 if (vam->async_mode)
1186 vam->async_errors += (retval < 0);
1190 vam->retval = retval;
1192 errmsg ("node index %d", ntohl (mp->node_index));
1193 vam->result_ready = 1;
1197 static void vl_api_get_node_index_reply_t_handler_json
1198 (vl_api_get_node_index_reply_t * mp)
1200 vat_main_t *vam = &vat_main;
1201 vat_json_node_t node;
1203 vat_json_init_object (&node);
1204 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1205 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1207 vat_json_print (vam->ofp, &node);
1208 vat_json_free (&node);
1210 vam->retval = ntohl (mp->retval);
1211 vam->result_ready = 1;
1214 static void vl_api_get_next_index_reply_t_handler
1215 (vl_api_get_next_index_reply_t * mp)
1217 vat_main_t *vam = &vat_main;
1218 i32 retval = ntohl (mp->retval);
1219 if (vam->async_mode)
1221 vam->async_errors += (retval < 0);
1225 vam->retval = retval;
1227 errmsg ("next node index %d", ntohl (mp->next_index));
1228 vam->result_ready = 1;
1232 static void vl_api_get_next_index_reply_t_handler_json
1233 (vl_api_get_next_index_reply_t * mp)
1235 vat_main_t *vam = &vat_main;
1236 vat_json_node_t node;
1238 vat_json_init_object (&node);
1239 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1240 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1242 vat_json_print (vam->ofp, &node);
1243 vat_json_free (&node);
1245 vam->retval = ntohl (mp->retval);
1246 vam->result_ready = 1;
1249 static void vl_api_add_node_next_reply_t_handler
1250 (vl_api_add_node_next_reply_t * mp)
1252 vat_main_t *vam = &vat_main;
1253 i32 retval = ntohl (mp->retval);
1254 if (vam->async_mode)
1256 vam->async_errors += (retval < 0);
1260 vam->retval = retval;
1262 errmsg ("next index %d", ntohl (mp->next_index));
1263 vam->result_ready = 1;
1267 static void vl_api_add_node_next_reply_t_handler_json
1268 (vl_api_add_node_next_reply_t * mp)
1270 vat_main_t *vam = &vat_main;
1271 vat_json_node_t node;
1273 vat_json_init_object (&node);
1274 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1275 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1277 vat_json_print (vam->ofp, &node);
1278 vat_json_free (&node);
1280 vam->retval = ntohl (mp->retval);
1281 vam->result_ready = 1;
1284 static void vl_api_show_version_reply_t_handler
1285 (vl_api_show_version_reply_t * mp)
1287 vat_main_t *vam = &vat_main;
1288 i32 retval = ntohl (mp->retval);
1292 errmsg (" program: %s", mp->program);
1293 errmsg (" version: %s", mp->version);
1294 errmsg (" build date: %s", mp->build_date);
1295 errmsg ("build directory: %s", mp->build_directory);
1297 vam->retval = retval;
1298 vam->result_ready = 1;
1301 static void vl_api_show_version_reply_t_handler_json
1302 (vl_api_show_version_reply_t * mp)
1304 vat_main_t *vam = &vat_main;
1305 vat_json_node_t node;
1307 vat_json_init_object (&node);
1308 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1309 vat_json_object_add_string_copy (&node, "program", mp->program);
1310 vat_json_object_add_string_copy (&node, "version", mp->version);
1311 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1312 vat_json_object_add_string_copy (&node, "build_directory",
1313 mp->build_directory);
1315 vat_json_print (vam->ofp, &node);
1316 vat_json_free (&node);
1318 vam->retval = ntohl (mp->retval);
1319 vam->result_ready = 1;
1323 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1325 u32 sw_if_index = ntohl (mp->sw_if_index);
1326 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1327 mp->mac_ip ? "mac/ip binding" : "address resolution",
1328 ntohl (mp->pid), format_ip4_address, &mp->address,
1329 format_ethernet_address, mp->new_mac, sw_if_index);
1333 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1335 /* JSON output not supported */
1339 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1341 u32 sw_if_index = ntohl (mp->sw_if_index);
1342 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1343 mp->mac_ip ? "mac/ip binding" : "address resolution",
1344 ntohl (mp->pid), format_ip6_address, mp->address,
1345 format_ethernet_address, mp->new_mac, sw_if_index);
1349 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1351 /* JSON output not supported */
1355 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1357 u32 n_macs = ntohl (mp->n_macs);
1358 errmsg ("L2MAC event recived with pid %d cl-idx %d for %d macs: \n",
1359 ntohl (mp->pid), mp->client_index, n_macs);
1361 for (i = 0; i < n_macs; i++)
1363 vl_api_mac_entry_t *mac = &mp->mac[i];
1364 errmsg (" [%d] sw_if_index %d mac_addr %U action %d \n",
1365 i + 1, ntohl (mac->sw_if_index),
1366 format_ethernet_address, mac->mac_addr, mac->action);
1373 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1375 /* JSON output not supported */
1378 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1379 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1382 * Special-case: build the bridge domain table, maintain
1383 * the next bd id vbl.
1385 static void vl_api_bridge_domain_details_t_handler
1386 (vl_api_bridge_domain_details_t * mp)
1388 vat_main_t *vam = &vat_main;
1389 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1392 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1393 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1395 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1396 ntohl (mp->bd_id), mp->learn, mp->forward,
1397 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1401 vl_api_bridge_domain_sw_if_t *sw_ifs;
1402 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1405 sw_ifs = mp->sw_if_details;
1406 for (i = 0; i < n_sw_ifs; i++)
1412 sw_if_index = ntohl (sw_ifs->sw_if_index);
1415 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1417 if ((u32) p->value[0] == sw_if_index)
1419 sw_if_name = (u8 *)(p->key);
1424 print (vam->ofp, "%7d %3d %s", sw_if_index,
1425 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1426 "sw_if_index not found!");
1433 static void vl_api_bridge_domain_details_t_handler_json
1434 (vl_api_bridge_domain_details_t * mp)
1436 vat_main_t *vam = &vat_main;
1437 vat_json_node_t *node, *array = NULL;
1438 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1440 if (VAT_JSON_ARRAY != vam->json_tree.type)
1442 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1443 vat_json_init_array (&vam->json_tree);
1445 node = vat_json_array_add (&vam->json_tree);
1447 vat_json_init_object (node);
1448 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1449 vat_json_object_add_uint (node, "flood", mp->flood);
1450 vat_json_object_add_uint (node, "forward", mp->forward);
1451 vat_json_object_add_uint (node, "learn", mp->learn);
1452 vat_json_object_add_uint (node, "bvi_sw_if_index",
1453 ntohl (mp->bvi_sw_if_index));
1454 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1455 array = vat_json_object_add (node, "sw_if");
1456 vat_json_init_array (array);
1462 vl_api_bridge_domain_sw_if_t *sw_ifs;
1465 sw_ifs = mp->sw_if_details;
1466 for (i = 0; i < n_sw_ifs; i++)
1468 node = vat_json_array_add (array);
1469 vat_json_init_object (node);
1470 vat_json_object_add_uint (node, "sw_if_index",
1471 ntohl (sw_ifs->sw_if_index));
1472 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1478 static void vl_api_control_ping_reply_t_handler
1479 (vl_api_control_ping_reply_t * mp)
1481 vat_main_t *vam = &vat_main;
1482 i32 retval = ntohl (mp->retval);
1483 if (vam->async_mode)
1485 vam->async_errors += (retval < 0);
1489 vam->retval = retval;
1490 vam->result_ready = 1;
1492 if (vam->socket_client_main)
1493 vam->socket_client_main->control_pings_outstanding--;
1496 static void vl_api_control_ping_reply_t_handler_json
1497 (vl_api_control_ping_reply_t * mp)
1499 vat_main_t *vam = &vat_main;
1500 i32 retval = ntohl (mp->retval);
1502 if (VAT_JSON_NONE != vam->json_tree.type)
1504 vat_json_print (vam->ofp, &vam->json_tree);
1505 vat_json_free (&vam->json_tree);
1506 vam->json_tree.type = VAT_JSON_NONE;
1511 vat_json_init_array (&vam->json_tree);
1512 vat_json_print (vam->ofp, &vam->json_tree);
1513 vam->json_tree.type = VAT_JSON_NONE;
1516 vam->retval = retval;
1517 vam->result_ready = 1;
1521 vl_api_bridge_domain_set_mac_age_reply_t_handler
1522 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1524 vat_main_t *vam = &vat_main;
1525 i32 retval = ntohl (mp->retval);
1526 if (vam->async_mode)
1528 vam->async_errors += (retval < 0);
1532 vam->retval = retval;
1533 vam->result_ready = 1;
1537 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1538 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1540 vat_main_t *vam = &vat_main;
1541 vat_json_node_t node;
1543 vat_json_init_object (&node);
1544 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1546 vat_json_print (vam->ofp, &node);
1547 vat_json_free (&node);
1549 vam->retval = ntohl (mp->retval);
1550 vam->result_ready = 1;
1554 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1556 vat_main_t *vam = &vat_main;
1557 i32 retval = ntohl (mp->retval);
1558 if (vam->async_mode)
1560 vam->async_errors += (retval < 0);
1564 vam->retval = retval;
1565 vam->result_ready = 1;
1569 static void vl_api_l2_flags_reply_t_handler_json
1570 (vl_api_l2_flags_reply_t * mp)
1572 vat_main_t *vam = &vat_main;
1573 vat_json_node_t node;
1575 vat_json_init_object (&node);
1576 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1577 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1578 ntohl (mp->resulting_feature_bitmap));
1580 vat_json_print (vam->ofp, &node);
1581 vat_json_free (&node);
1583 vam->retval = ntohl (mp->retval);
1584 vam->result_ready = 1;
1587 static void vl_api_bridge_flags_reply_t_handler
1588 (vl_api_bridge_flags_reply_t * mp)
1590 vat_main_t *vam = &vat_main;
1591 i32 retval = ntohl (mp->retval);
1592 if (vam->async_mode)
1594 vam->async_errors += (retval < 0);
1598 vam->retval = retval;
1599 vam->result_ready = 1;
1603 static void vl_api_bridge_flags_reply_t_handler_json
1604 (vl_api_bridge_flags_reply_t * mp)
1606 vat_main_t *vam = &vat_main;
1607 vat_json_node_t node;
1609 vat_json_init_object (&node);
1610 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1611 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1612 ntohl (mp->resulting_feature_bitmap));
1614 vat_json_print (vam->ofp, &node);
1615 vat_json_free (&node);
1617 vam->retval = ntohl (mp->retval);
1618 vam->result_ready = 1;
1621 static void vl_api_tap_connect_reply_t_handler
1622 (vl_api_tap_connect_reply_t * mp)
1624 vat_main_t *vam = &vat_main;
1625 i32 retval = ntohl (mp->retval);
1626 if (vam->async_mode)
1628 vam->async_errors += (retval < 0);
1632 vam->retval = retval;
1633 vam->sw_if_index = ntohl (mp->sw_if_index);
1634 vam->result_ready = 1;
1639 static void vl_api_tap_connect_reply_t_handler_json
1640 (vl_api_tap_connect_reply_t * mp)
1642 vat_main_t *vam = &vat_main;
1643 vat_json_node_t node;
1645 vat_json_init_object (&node);
1646 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1647 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1649 vat_json_print (vam->ofp, &node);
1650 vat_json_free (&node);
1652 vam->retval = ntohl (mp->retval);
1653 vam->result_ready = 1;
1658 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1660 vat_main_t *vam = &vat_main;
1661 i32 retval = ntohl (mp->retval);
1662 if (vam->async_mode)
1664 vam->async_errors += (retval < 0);
1668 vam->retval = retval;
1669 vam->sw_if_index = ntohl (mp->sw_if_index);
1670 vam->result_ready = 1;
1674 static void vl_api_tap_modify_reply_t_handler_json
1675 (vl_api_tap_modify_reply_t * mp)
1677 vat_main_t *vam = &vat_main;
1678 vat_json_node_t node;
1680 vat_json_init_object (&node);
1681 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1682 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1684 vat_json_print (vam->ofp, &node);
1685 vat_json_free (&node);
1687 vam->retval = ntohl (mp->retval);
1688 vam->result_ready = 1;
1692 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1694 vat_main_t *vam = &vat_main;
1695 i32 retval = ntohl (mp->retval);
1696 if (vam->async_mode)
1698 vam->async_errors += (retval < 0);
1702 vam->retval = retval;
1703 vam->result_ready = 1;
1707 static void vl_api_tap_delete_reply_t_handler_json
1708 (vl_api_tap_delete_reply_t * mp)
1710 vat_main_t *vam = &vat_main;
1711 vat_json_node_t node;
1713 vat_json_init_object (&node);
1714 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1716 vat_json_print (vam->ofp, &node);
1717 vat_json_free (&node);
1719 vam->retval = ntohl (mp->retval);
1720 vam->result_ready = 1;
1724 vl_api_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_reply_t * mp)
1726 vat_main_t *vam = &vat_main;
1727 i32 retval = ntohl (mp->retval);
1728 if (vam->async_mode)
1730 vam->async_errors += (retval < 0);
1734 vam->retval = retval;
1735 vam->sw_if_index = ntohl (mp->sw_if_index);
1736 vam->result_ready = 1;
1741 static void vl_api_tap_create_v2_reply_t_handler_json
1742 (vl_api_tap_create_v2_reply_t * mp)
1744 vat_main_t *vam = &vat_main;
1745 vat_json_node_t node;
1747 vat_json_init_object (&node);
1748 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1749 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1751 vat_json_print (vam->ofp, &node);
1752 vat_json_free (&node);
1754 vam->retval = ntohl (mp->retval);
1755 vam->result_ready = 1;
1760 vl_api_tap_delete_v2_reply_t_handler (vl_api_tap_delete_v2_reply_t * mp)
1762 vat_main_t *vam = &vat_main;
1763 i32 retval = ntohl (mp->retval);
1764 if (vam->async_mode)
1766 vam->async_errors += (retval < 0);
1770 vam->retval = retval;
1771 vam->result_ready = 1;
1775 static void vl_api_tap_delete_v2_reply_t_handler_json
1776 (vl_api_tap_delete_v2_reply_t * mp)
1778 vat_main_t *vam = &vat_main;
1779 vat_json_node_t node;
1781 vat_json_init_object (&node);
1782 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1784 vat_json_print (vam->ofp, &node);
1785 vat_json_free (&node);
1787 vam->retval = ntohl (mp->retval);
1788 vam->result_ready = 1;
1792 vl_api_bond_create_reply_t_handler (vl_api_bond_create_reply_t * mp)
1794 vat_main_t *vam = &vat_main;
1795 i32 retval = ntohl (mp->retval);
1797 if (vam->async_mode)
1799 vam->async_errors += (retval < 0);
1803 vam->retval = retval;
1804 vam->sw_if_index = ntohl (mp->sw_if_index);
1805 vam->result_ready = 1;
1809 static void vl_api_bond_create_reply_t_handler_json
1810 (vl_api_bond_create_reply_t * mp)
1812 vat_main_t *vam = &vat_main;
1813 vat_json_node_t node;
1815 vat_json_init_object (&node);
1816 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1817 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1819 vat_json_print (vam->ofp, &node);
1820 vat_json_free (&node);
1822 vam->retval = ntohl (mp->retval);
1823 vam->result_ready = 1;
1827 vl_api_bond_delete_reply_t_handler (vl_api_bond_delete_reply_t * mp)
1829 vat_main_t *vam = &vat_main;
1830 i32 retval = ntohl (mp->retval);
1832 if (vam->async_mode)
1834 vam->async_errors += (retval < 0);
1838 vam->retval = retval;
1839 vam->result_ready = 1;
1843 static void vl_api_bond_delete_reply_t_handler_json
1844 (vl_api_bond_delete_reply_t * mp)
1846 vat_main_t *vam = &vat_main;
1847 vat_json_node_t node;
1849 vat_json_init_object (&node);
1850 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1852 vat_json_print (vam->ofp, &node);
1853 vat_json_free (&node);
1855 vam->retval = ntohl (mp->retval);
1856 vam->result_ready = 1;
1860 vl_api_bond_enslave_reply_t_handler (vl_api_bond_enslave_reply_t * mp)
1862 vat_main_t *vam = &vat_main;
1863 i32 retval = ntohl (mp->retval);
1865 if (vam->async_mode)
1867 vam->async_errors += (retval < 0);
1871 vam->retval = retval;
1872 vam->result_ready = 1;
1876 static void vl_api_bond_enslave_reply_t_handler_json
1877 (vl_api_bond_enslave_reply_t * mp)
1879 vat_main_t *vam = &vat_main;
1880 vat_json_node_t node;
1882 vat_json_init_object (&node);
1883 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1885 vat_json_print (vam->ofp, &node);
1886 vat_json_free (&node);
1888 vam->retval = ntohl (mp->retval);
1889 vam->result_ready = 1;
1893 vl_api_bond_detach_slave_reply_t_handler (vl_api_bond_detach_slave_reply_t *
1896 vat_main_t *vam = &vat_main;
1897 i32 retval = ntohl (mp->retval);
1899 if (vam->async_mode)
1901 vam->async_errors += (retval < 0);
1905 vam->retval = retval;
1906 vam->result_ready = 1;
1910 static void vl_api_bond_detach_slave_reply_t_handler_json
1911 (vl_api_bond_detach_slave_reply_t * mp)
1913 vat_main_t *vam = &vat_main;
1914 vat_json_node_t node;
1916 vat_json_init_object (&node);
1917 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1919 vat_json_print (vam->ofp, &node);
1920 vat_json_free (&node);
1922 vam->retval = ntohl (mp->retval);
1923 vam->result_ready = 1;
1926 static void vl_api_sw_interface_bond_details_t_handler
1927 (vl_api_sw_interface_bond_details_t * mp)
1929 vat_main_t *vam = &vat_main;
1932 "%-16s %-12d %-12U %-13U %-14u %-14u",
1933 mp->interface_name, ntohl (mp->sw_if_index),
1934 format_bond_mode, mp->mode, format_bond_load_balance, mp->lb,
1935 ntohl (mp->active_slaves), ntohl (mp->slaves));
1938 static void vl_api_sw_interface_bond_details_t_handler_json
1939 (vl_api_sw_interface_bond_details_t * mp)
1941 vat_main_t *vam = &vat_main;
1942 vat_json_node_t *node = NULL;
1944 if (VAT_JSON_ARRAY != vam->json_tree.type)
1946 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1947 vat_json_init_array (&vam->json_tree);
1949 node = vat_json_array_add (&vam->json_tree);
1951 vat_json_init_object (node);
1952 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1953 vat_json_object_add_string_copy (node, "interface_name",
1954 mp->interface_name);
1955 vat_json_object_add_uint (node, "mode", mp->mode);
1956 vat_json_object_add_uint (node, "load_balance", mp->lb);
1957 vat_json_object_add_uint (node, "active_slaves", ntohl (mp->active_slaves));
1958 vat_json_object_add_uint (node, "slaves", ntohl (mp->slaves));
1962 api_sw_interface_bond_dump (vat_main_t * vam)
1964 vl_api_sw_interface_bond_dump_t *mp;
1965 vl_api_control_ping_t *mp_ping;
1969 "\n%-16s %-12s %-12s %-13s %-14s %-14s",
1970 "interface name", "sw_if_index", "mode", "load balance",
1971 "active slaves", "slaves");
1973 /* Get list of bond interfaces */
1974 M (SW_INTERFACE_BOND_DUMP, mp);
1977 /* Use a control ping for synchronization */
1978 MPING (CONTROL_PING, mp_ping);
1985 static void vl_api_sw_interface_slave_details_t_handler
1986 (vl_api_sw_interface_slave_details_t * mp)
1988 vat_main_t *vam = &vat_main;
1991 "%-25s %-12d %-12d %d", mp->interface_name,
1992 ntohl (mp->sw_if_index), mp->is_passive, mp->is_long_timeout);
1995 static void vl_api_sw_interface_slave_details_t_handler_json
1996 (vl_api_sw_interface_slave_details_t * mp)
1998 vat_main_t *vam = &vat_main;
1999 vat_json_node_t *node = NULL;
2001 if (VAT_JSON_ARRAY != vam->json_tree.type)
2003 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2004 vat_json_init_array (&vam->json_tree);
2006 node = vat_json_array_add (&vam->json_tree);
2008 vat_json_init_object (node);
2009 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2010 vat_json_object_add_string_copy (node, "interface_name",
2011 mp->interface_name);
2012 vat_json_object_add_uint (node, "passive", mp->is_passive);
2013 vat_json_object_add_uint (node, "long_timeout", mp->is_long_timeout);
2017 api_sw_interface_slave_dump (vat_main_t * vam)
2019 unformat_input_t *i = vam->input;
2020 vl_api_sw_interface_slave_dump_t *mp;
2021 vl_api_control_ping_t *mp_ping;
2022 u32 sw_if_index = ~0;
2023 u8 sw_if_index_set = 0;
2026 /* Parse args required to build the message */
2027 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2029 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2030 sw_if_index_set = 1;
2031 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2032 sw_if_index_set = 1;
2037 if (sw_if_index_set == 0)
2039 errmsg ("missing vpp interface name. ");
2044 "\n%-25s %-12s %-12s %s",
2045 "slave interface name", "sw_if_index", "passive", "long_timeout");
2047 /* Get list of bond interfaces */
2048 M (SW_INTERFACE_SLAVE_DUMP, mp);
2049 mp->sw_if_index = ntohl (sw_if_index);
2052 /* Use a control ping for synchronization */
2053 MPING (CONTROL_PING, mp_ping);
2060 static void vl_api_mpls_tunnel_add_del_reply_t_handler
2061 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2063 vat_main_t *vam = &vat_main;
2064 i32 retval = ntohl (mp->retval);
2065 if (vam->async_mode)
2067 vam->async_errors += (retval < 0);
2071 vam->retval = retval;
2072 vam->result_ready = 1;
2076 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
2077 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2079 vat_main_t *vam = &vat_main;
2080 vat_json_node_t node;
2082 vat_json_init_object (&node);
2083 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2084 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
2085 ntohl (mp->sw_if_index));
2087 vat_json_print (vam->ofp, &node);
2088 vat_json_free (&node);
2090 vam->retval = ntohl (mp->retval);
2091 vam->result_ready = 1;
2094 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
2095 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2097 vat_main_t *vam = &vat_main;
2098 i32 retval = ntohl (mp->retval);
2099 if (vam->async_mode)
2101 vam->async_errors += (retval < 0);
2105 vam->retval = retval;
2106 vam->sw_if_index = ntohl (mp->sw_if_index);
2107 vam->result_ready = 1;
2111 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
2112 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2114 vat_main_t *vam = &vat_main;
2115 vat_json_node_t node;
2117 vat_json_init_object (&node);
2118 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2119 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2121 vat_json_print (vam->ofp, &node);
2122 vat_json_free (&node);
2124 vam->retval = ntohl (mp->retval);
2125 vam->result_ready = 1;
2128 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
2129 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2131 vat_main_t *vam = &vat_main;
2132 i32 retval = ntohl (mp->retval);
2133 if (vam->async_mode)
2135 vam->async_errors += (retval < 0);
2139 vam->retval = retval;
2140 vam->result_ready = 1;
2144 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
2145 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2147 vat_main_t *vam = &vat_main;
2148 vat_json_node_t node;
2150 vat_json_init_object (&node);
2151 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2152 vat_json_object_add_uint (&node, "fwd_entry_index",
2153 clib_net_to_host_u32 (mp->fwd_entry_index));
2155 vat_json_print (vam->ofp, &node);
2156 vat_json_free (&node);
2158 vam->retval = ntohl (mp->retval);
2159 vam->result_ready = 1;
2163 format_lisp_transport_protocol (u8 * s, va_list * args)
2165 u32 proto = va_arg (*args, u32);
2170 return format (s, "udp");
2172 return format (s, "api");
2179 static void vl_api_one_get_transport_protocol_reply_t_handler
2180 (vl_api_one_get_transport_protocol_reply_t * mp)
2182 vat_main_t *vam = &vat_main;
2183 i32 retval = ntohl (mp->retval);
2184 if (vam->async_mode)
2186 vam->async_errors += (retval < 0);
2190 u32 proto = mp->protocol;
2191 print (vam->ofp, "Transport protocol: %U",
2192 format_lisp_transport_protocol, proto);
2193 vam->retval = retval;
2194 vam->result_ready = 1;
2198 static void vl_api_one_get_transport_protocol_reply_t_handler_json
2199 (vl_api_one_get_transport_protocol_reply_t * mp)
2201 vat_main_t *vam = &vat_main;
2202 vat_json_node_t node;
2205 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
2208 vat_json_init_object (&node);
2209 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2210 vat_json_object_add_string_copy (&node, "transport-protocol", s);
2213 vat_json_print (vam->ofp, &node);
2214 vat_json_free (&node);
2216 vam->retval = ntohl (mp->retval);
2217 vam->result_ready = 1;
2220 static void vl_api_one_add_del_locator_set_reply_t_handler
2221 (vl_api_one_add_del_locator_set_reply_t * mp)
2223 vat_main_t *vam = &vat_main;
2224 i32 retval = ntohl (mp->retval);
2225 if (vam->async_mode)
2227 vam->async_errors += (retval < 0);
2231 vam->retval = retval;
2232 vam->result_ready = 1;
2236 static void vl_api_one_add_del_locator_set_reply_t_handler_json
2237 (vl_api_one_add_del_locator_set_reply_t * mp)
2239 vat_main_t *vam = &vat_main;
2240 vat_json_node_t node;
2242 vat_json_init_object (&node);
2243 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2244 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
2246 vat_json_print (vam->ofp, &node);
2247 vat_json_free (&node);
2249 vam->retval = ntohl (mp->retval);
2250 vam->result_ready = 1;
2253 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
2254 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2256 vat_main_t *vam = &vat_main;
2257 i32 retval = ntohl (mp->retval);
2258 if (vam->async_mode)
2260 vam->async_errors += (retval < 0);
2264 vam->retval = retval;
2265 vam->sw_if_index = ntohl (mp->sw_if_index);
2266 vam->result_ready = 1;
2268 vam->regenerate_interface_table = 1;
2271 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
2272 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2274 vat_main_t *vam = &vat_main;
2275 vat_json_node_t node;
2277 vat_json_init_object (&node);
2278 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2279 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2281 vat_json_print (vam->ofp, &node);
2282 vat_json_free (&node);
2284 vam->retval = ntohl (mp->retval);
2285 vam->result_ready = 1;
2288 static void vl_api_vxlan_offload_rx_reply_t_handler
2289 (vl_api_vxlan_offload_rx_reply_t * mp)
2291 vat_main_t *vam = &vat_main;
2292 i32 retval = ntohl (mp->retval);
2293 if (vam->async_mode)
2295 vam->async_errors += (retval < 0);
2299 vam->retval = retval;
2300 vam->result_ready = 1;
2304 static void vl_api_vxlan_offload_rx_reply_t_handler_json
2305 (vl_api_vxlan_offload_rx_reply_t * mp)
2307 vat_main_t *vam = &vat_main;
2308 vat_json_node_t node;
2310 vat_json_init_object (&node);
2311 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2313 vat_json_print (vam->ofp, &node);
2314 vat_json_free (&node);
2316 vam->retval = ntohl (mp->retval);
2317 vam->result_ready = 1;
2320 static void vl_api_geneve_add_del_tunnel_reply_t_handler
2321 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2323 vat_main_t *vam = &vat_main;
2324 i32 retval = ntohl (mp->retval);
2325 if (vam->async_mode)
2327 vam->async_errors += (retval < 0);
2331 vam->retval = retval;
2332 vam->sw_if_index = ntohl (mp->sw_if_index);
2333 vam->result_ready = 1;
2337 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
2338 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2340 vat_main_t *vam = &vat_main;
2341 vat_json_node_t node;
2343 vat_json_init_object (&node);
2344 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2345 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2347 vat_json_print (vam->ofp, &node);
2348 vat_json_free (&node);
2350 vam->retval = ntohl (mp->retval);
2351 vam->result_ready = 1;
2354 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
2355 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2357 vat_main_t *vam = &vat_main;
2358 i32 retval = ntohl (mp->retval);
2359 if (vam->async_mode)
2361 vam->async_errors += (retval < 0);
2365 vam->retval = retval;
2366 vam->sw_if_index = ntohl (mp->sw_if_index);
2367 vam->result_ready = 1;
2369 vam->regenerate_interface_table = 1;
2372 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
2373 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2375 vat_main_t *vam = &vat_main;
2376 vat_json_node_t node;
2378 vat_json_init_object (&node);
2379 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2380 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2382 vat_json_print (vam->ofp, &node);
2383 vat_json_free (&node);
2385 vam->retval = ntohl (mp->retval);
2386 vam->result_ready = 1;
2389 static void vl_api_gre_add_del_tunnel_reply_t_handler
2390 (vl_api_gre_add_del_tunnel_reply_t * mp)
2392 vat_main_t *vam = &vat_main;
2393 i32 retval = ntohl (mp->retval);
2394 if (vam->async_mode)
2396 vam->async_errors += (retval < 0);
2400 vam->retval = retval;
2401 vam->sw_if_index = ntohl (mp->sw_if_index);
2402 vam->result_ready = 1;
2406 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
2407 (vl_api_gre_add_del_tunnel_reply_t * mp)
2409 vat_main_t *vam = &vat_main;
2410 vat_json_node_t node;
2412 vat_json_init_object (&node);
2413 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2414 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2416 vat_json_print (vam->ofp, &node);
2417 vat_json_free (&node);
2419 vam->retval = ntohl (mp->retval);
2420 vam->result_ready = 1;
2423 static void vl_api_create_vhost_user_if_reply_t_handler
2424 (vl_api_create_vhost_user_if_reply_t * mp)
2426 vat_main_t *vam = &vat_main;
2427 i32 retval = ntohl (mp->retval);
2428 if (vam->async_mode)
2430 vam->async_errors += (retval < 0);
2434 vam->retval = retval;
2435 vam->sw_if_index = ntohl (mp->sw_if_index);
2436 vam->result_ready = 1;
2438 vam->regenerate_interface_table = 1;
2441 static void vl_api_create_vhost_user_if_reply_t_handler_json
2442 (vl_api_create_vhost_user_if_reply_t * mp)
2444 vat_main_t *vam = &vat_main;
2445 vat_json_node_t node;
2447 vat_json_init_object (&node);
2448 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2449 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2451 vat_json_print (vam->ofp, &node);
2452 vat_json_free (&node);
2454 vam->retval = ntohl (mp->retval);
2455 vam->result_ready = 1;
2458 static void vl_api_dns_resolve_name_reply_t_handler
2459 (vl_api_dns_resolve_name_reply_t * mp)
2461 vat_main_t *vam = &vat_main;
2462 i32 retval = ntohl (mp->retval);
2463 if (vam->async_mode)
2465 vam->async_errors += (retval < 0);
2469 vam->retval = retval;
2470 vam->result_ready = 1;
2475 clib_warning ("ip4 address %U", format_ip4_address,
2476 (ip4_address_t *) mp->ip4_address);
2478 clib_warning ("ip6 address %U", format_ip6_address,
2479 (ip6_address_t *) mp->ip6_address);
2482 clib_warning ("retval %d", retval);
2486 static void vl_api_dns_resolve_name_reply_t_handler_json
2487 (vl_api_dns_resolve_name_reply_t * mp)
2489 clib_warning ("not implemented");
2492 static void vl_api_dns_resolve_ip_reply_t_handler
2493 (vl_api_dns_resolve_ip_reply_t * mp)
2495 vat_main_t *vam = &vat_main;
2496 i32 retval = ntohl (mp->retval);
2497 if (vam->async_mode)
2499 vam->async_errors += (retval < 0);
2503 vam->retval = retval;
2504 vam->result_ready = 1;
2508 clib_warning ("canonical name %s", mp->name);
2511 clib_warning ("retval %d", retval);
2515 static void vl_api_dns_resolve_ip_reply_t_handler_json
2516 (vl_api_dns_resolve_ip_reply_t * mp)
2518 clib_warning ("not implemented");
2522 static void vl_api_ip_address_details_t_handler
2523 (vl_api_ip_address_details_t * mp)
2525 vat_main_t *vam = &vat_main;
2526 static ip_address_details_t empty_ip_address_details = { {0} };
2527 ip_address_details_t *address = NULL;
2528 ip_details_t *current_ip_details = NULL;
2529 ip_details_t *details = NULL;
2531 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2533 if (!details || vam->current_sw_if_index >= vec_len (details)
2534 || !details[vam->current_sw_if_index].present)
2536 errmsg ("ip address details arrived but not stored");
2537 errmsg ("ip_dump should be called first");
2541 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2543 #define addresses (current_ip_details->addr)
2545 vec_validate_init_empty (addresses, vec_len (addresses),
2546 empty_ip_address_details);
2548 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2550 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
2551 address->prefix_length = mp->prefix_length;
2555 static void vl_api_ip_address_details_t_handler_json
2556 (vl_api_ip_address_details_t * mp)
2558 vat_main_t *vam = &vat_main;
2559 vat_json_node_t *node = NULL;
2560 struct in6_addr ip6;
2563 if (VAT_JSON_ARRAY != vam->json_tree.type)
2565 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2566 vat_json_init_array (&vam->json_tree);
2568 node = vat_json_array_add (&vam->json_tree);
2570 vat_json_init_object (node);
2573 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
2574 vat_json_object_add_ip6 (node, "ip", ip6);
2578 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
2579 vat_json_object_add_ip4 (node, "ip", ip4);
2581 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
2585 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2587 vat_main_t *vam = &vat_main;
2588 static ip_details_t empty_ip_details = { 0 };
2589 ip_details_t *ip = NULL;
2590 u32 sw_if_index = ~0;
2592 sw_if_index = ntohl (mp->sw_if_index);
2594 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2595 sw_if_index, empty_ip_details);
2597 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2604 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2606 vat_main_t *vam = &vat_main;
2608 if (VAT_JSON_ARRAY != vam->json_tree.type)
2610 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2611 vat_json_init_array (&vam->json_tree);
2613 vat_json_array_add_uint (&vam->json_tree,
2614 clib_net_to_host_u32 (mp->sw_if_index));
2618 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2620 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2621 "router_addr %U host_mac %U",
2622 ntohl (mp->pid), mp->lease.is_ipv6 ? "ipv6" : "ipv4",
2624 format_ip4_address, &mp->lease.host_address,
2625 format_ip4_address, &mp->lease.router_address,
2626 format_ethernet_address, mp->lease.host_mac);
2629 static void vl_api_dhcp_compl_event_t_handler_json
2630 (vl_api_dhcp_compl_event_t * mp)
2632 /* JSON output not supported */
2636 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2639 vat_main_t *vam = &vat_main;
2640 static u64 default_counter = 0;
2642 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2644 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2645 sw_if_index, default_counter);
2646 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2650 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2651 interface_counter_t counter)
2653 vat_main_t *vam = &vat_main;
2654 static interface_counter_t default_counter = { 0, };
2656 vec_validate_init_empty (vam->combined_interface_counters,
2657 vnet_counter_type, NULL);
2658 vec_validate_init_empty (vam->combined_interface_counters
2659 [vnet_counter_type], sw_if_index, default_counter);
2660 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2663 static void vl_api_vnet_interface_simple_counters_t_handler
2664 (vl_api_vnet_interface_simple_counters_t * mp)
2669 static void vl_api_vnet_interface_combined_counters_t_handler
2670 (vl_api_vnet_interface_combined_counters_t * mp)
2675 static void vl_api_vnet_interface_simple_counters_t_handler_json
2676 (vl_api_vnet_interface_simple_counters_t * mp)
2681 u32 first_sw_if_index;
2684 count = ntohl (mp->count);
2685 first_sw_if_index = ntohl (mp->first_sw_if_index);
2687 v_packets = (u64 *) & mp->data;
2688 for (i = 0; i < count; i++)
2690 packets = clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2691 set_simple_interface_counter (mp->vnet_counter_type,
2692 first_sw_if_index + i, packets);
2697 static void vl_api_vnet_interface_combined_counters_t_handler_json
2698 (vl_api_vnet_interface_combined_counters_t * mp)
2700 interface_counter_t counter;
2702 u32 first_sw_if_index;
2706 count = ntohl (mp->count);
2707 first_sw_if_index = ntohl (mp->first_sw_if_index);
2709 v = (vlib_counter_t *) & mp->data;
2710 for (i = 0; i < count; i++)
2713 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2715 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2716 set_combined_interface_counter (mp->vnet_counter_type,
2717 first_sw_if_index + i, counter);
2723 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2725 vat_main_t *vam = &vat_main;
2728 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2730 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2739 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2741 vat_main_t *vam = &vat_main;
2744 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2746 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2754 static void vl_api_vnet_ip4_fib_counters_t_handler
2755 (vl_api_vnet_ip4_fib_counters_t * mp)
2760 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2761 (vl_api_vnet_ip4_fib_counters_t * mp)
2763 vat_main_t *vam = &vat_main;
2764 vl_api_ip4_fib_counter_t *v;
2765 ip4_fib_counter_t *counter;
2772 vrf_id = ntohl (mp->vrf_id);
2773 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2774 if (~0 == vrf_index)
2776 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2777 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2778 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2779 vec_validate (vam->ip4_fib_counters, vrf_index);
2780 vam->ip4_fib_counters[vrf_index] = NULL;
2783 vec_free (vam->ip4_fib_counters[vrf_index]);
2784 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2785 count = ntohl (mp->count);
2786 for (i = 0; i < count; i++)
2788 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2789 counter = &vam->ip4_fib_counters[vrf_index][i];
2790 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2791 counter->address = ip4;
2792 counter->address_length = v->address_length;
2793 counter->packets = clib_net_to_host_u64 (v->packets);
2794 counter->bytes = clib_net_to_host_u64 (v->bytes);
2799 static void vl_api_vnet_ip4_nbr_counters_t_handler
2800 (vl_api_vnet_ip4_nbr_counters_t * mp)
2805 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2806 (vl_api_vnet_ip4_nbr_counters_t * mp)
2808 vat_main_t *vam = &vat_main;
2809 vl_api_ip4_nbr_counter_t *v;
2810 ip4_nbr_counter_t *counter;
2815 sw_if_index = ntohl (mp->sw_if_index);
2816 count = ntohl (mp->count);
2817 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2820 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2822 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2823 for (i = 0; i < count; i++)
2825 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2826 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2827 counter->address.s_addr = v->address;
2828 counter->packets = clib_net_to_host_u64 (v->packets);
2829 counter->bytes = clib_net_to_host_u64 (v->bytes);
2830 counter->linkt = v->link_type;
2835 static void vl_api_vnet_ip6_fib_counters_t_handler
2836 (vl_api_vnet_ip6_fib_counters_t * mp)
2841 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2842 (vl_api_vnet_ip6_fib_counters_t * mp)
2844 vat_main_t *vam = &vat_main;
2845 vl_api_ip6_fib_counter_t *v;
2846 ip6_fib_counter_t *counter;
2847 struct in6_addr ip6;
2853 vrf_id = ntohl (mp->vrf_id);
2854 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2855 if (~0 == vrf_index)
2857 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2858 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2859 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2860 vec_validate (vam->ip6_fib_counters, vrf_index);
2861 vam->ip6_fib_counters[vrf_index] = NULL;
2864 vec_free (vam->ip6_fib_counters[vrf_index]);
2865 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2866 count = ntohl (mp->count);
2867 for (i = 0; i < count; i++)
2869 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2870 counter = &vam->ip6_fib_counters[vrf_index][i];
2871 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2872 counter->address = ip6;
2873 counter->address_length = v->address_length;
2874 counter->packets = clib_net_to_host_u64 (v->packets);
2875 counter->bytes = clib_net_to_host_u64 (v->bytes);
2880 static void vl_api_vnet_ip6_nbr_counters_t_handler
2881 (vl_api_vnet_ip6_nbr_counters_t * mp)
2886 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2887 (vl_api_vnet_ip6_nbr_counters_t * mp)
2889 vat_main_t *vam = &vat_main;
2890 vl_api_ip6_nbr_counter_t *v;
2891 ip6_nbr_counter_t *counter;
2892 struct in6_addr ip6;
2897 sw_if_index = ntohl (mp->sw_if_index);
2898 count = ntohl (mp->count);
2899 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2902 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2904 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2905 for (i = 0; i < count; i++)
2907 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2908 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2909 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2910 counter->address = ip6;
2911 counter->packets = clib_net_to_host_u64 (v->packets);
2912 counter->bytes = clib_net_to_host_u64 (v->bytes);
2917 static void vl_api_get_first_msg_id_reply_t_handler
2918 (vl_api_get_first_msg_id_reply_t * mp)
2920 vat_main_t *vam = &vat_main;
2921 i32 retval = ntohl (mp->retval);
2923 if (vam->async_mode)
2925 vam->async_errors += (retval < 0);
2929 vam->retval = retval;
2930 vam->result_ready = 1;
2934 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2938 static void vl_api_get_first_msg_id_reply_t_handler_json
2939 (vl_api_get_first_msg_id_reply_t * mp)
2941 vat_main_t *vam = &vat_main;
2942 vat_json_node_t node;
2944 vat_json_init_object (&node);
2945 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2946 vat_json_object_add_uint (&node, "first_msg_id",
2947 (uint) ntohs (mp->first_msg_id));
2949 vat_json_print (vam->ofp, &node);
2950 vat_json_free (&node);
2952 vam->retval = ntohl (mp->retval);
2953 vam->result_ready = 1;
2956 static void vl_api_get_node_graph_reply_t_handler
2957 (vl_api_get_node_graph_reply_t * mp)
2959 vat_main_t *vam = &vat_main;
2960 api_main_t *am = &api_main;
2961 i32 retval = ntohl (mp->retval);
2962 u8 *pvt_copy, *reply;
2967 if (vam->async_mode)
2969 vam->async_errors += (retval < 0);
2973 vam->retval = retval;
2974 vam->result_ready = 1;
2977 /* "Should never happen..." */
2981 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2982 pvt_copy = vec_dup (reply);
2984 /* Toss the shared-memory original... */
2985 pthread_mutex_lock (&am->vlib_rp->mutex);
2986 oldheap = svm_push_data_heap (am->vlib_rp);
2990 svm_pop_heap (oldheap);
2991 pthread_mutex_unlock (&am->vlib_rp->mutex);
2993 if (vam->graph_nodes)
2995 hash_free (vam->graph_node_index_by_name);
2997 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2999 node = vam->graph_nodes[0][i];
3000 vec_free (node->name);
3001 vec_free (node->next_nodes);
3004 vec_free (vam->graph_nodes[0]);
3005 vec_free (vam->graph_nodes);
3008 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
3009 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
3010 vec_free (pvt_copy);
3012 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
3014 node = vam->graph_nodes[0][i];
3015 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
3019 static void vl_api_get_node_graph_reply_t_handler_json
3020 (vl_api_get_node_graph_reply_t * mp)
3022 vat_main_t *vam = &vat_main;
3023 api_main_t *am = &api_main;
3025 vat_json_node_t node;
3028 /* $$$$ make this real? */
3029 vat_json_init_object (&node);
3030 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3031 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
3033 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
3035 /* Toss the shared-memory original... */
3036 pthread_mutex_lock (&am->vlib_rp->mutex);
3037 oldheap = svm_push_data_heap (am->vlib_rp);
3041 svm_pop_heap (oldheap);
3042 pthread_mutex_unlock (&am->vlib_rp->mutex);
3044 vat_json_print (vam->ofp, &node);
3045 vat_json_free (&node);
3047 vam->retval = ntohl (mp->retval);
3048 vam->result_ready = 1;
3052 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
3054 vat_main_t *vam = &vat_main;
3059 s = format (s, "%=16d%=16d%=16d",
3060 ntohl (mp->sw_if_index), mp->priority, mp->weight);
3064 s = format (s, "%=16U%=16d%=16d",
3065 mp->is_ipv6 ? format_ip6_address :
3067 mp->ip_address, mp->priority, mp->weight);
3070 print (vam->ofp, "%v", s);
3075 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
3077 vat_main_t *vam = &vat_main;
3078 vat_json_node_t *node = NULL;
3079 struct in6_addr ip6;
3082 if (VAT_JSON_ARRAY != vam->json_tree.type)
3084 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3085 vat_json_init_array (&vam->json_tree);
3087 node = vat_json_array_add (&vam->json_tree);
3088 vat_json_init_object (node);
3090 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
3091 vat_json_object_add_uint (node, "priority", mp->priority);
3092 vat_json_object_add_uint (node, "weight", mp->weight);
3095 vat_json_object_add_uint (node, "sw_if_index",
3096 clib_net_to_host_u32 (mp->sw_if_index));
3101 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3102 vat_json_object_add_ip6 (node, "address", ip6);
3106 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3107 vat_json_object_add_ip4 (node, "address", ip4);
3113 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
3116 vat_main_t *vam = &vat_main;
3119 ls_name = format (0, "%s", mp->ls_name);
3121 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
3127 vl_api_one_locator_set_details_t_handler_json
3128 (vl_api_one_locator_set_details_t * mp)
3130 vat_main_t *vam = &vat_main;
3131 vat_json_node_t *node = 0;
3134 ls_name = format (0, "%s", mp->ls_name);
3135 vec_add1 (ls_name, 0);
3137 if (VAT_JSON_ARRAY != vam->json_tree.type)
3139 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3140 vat_json_init_array (&vam->json_tree);
3142 node = vat_json_array_add (&vam->json_tree);
3144 vat_json_init_object (node);
3145 vat_json_object_add_string_copy (node, "ls_name", ls_name);
3146 vat_json_object_add_uint (node, "ls_index",
3147 clib_net_to_host_u32 (mp->ls_index));
3155 } __attribute__ ((__packed__)) lisp_nsh_api_t;
3158 unformat_nsh_address (unformat_input_t * input, va_list * args)
3160 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
3161 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
3165 format_nsh_address_vat (u8 * s, va_list * args)
3167 nsh_t *a = va_arg (*args, nsh_t *);
3168 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
3172 format_lisp_flat_eid (u8 * s, va_list * args)
3174 u32 type = va_arg (*args, u32);
3175 u8 *eid = va_arg (*args, u8 *);
3176 u32 eid_len = va_arg (*args, u32);
3181 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
3183 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
3185 return format (s, "%U", format_ethernet_address, eid);
3187 return format (s, "%U", format_nsh_address_vat, eid);
3193 format_lisp_eid_vat (u8 * s, va_list * args)
3195 u32 type = va_arg (*args, u32);
3196 u8 *eid = va_arg (*args, u8 *);
3197 u32 eid_len = va_arg (*args, u32);
3198 u8 *seid = va_arg (*args, u8 *);
3199 u32 seid_len = va_arg (*args, u32);
3200 u32 is_src_dst = va_arg (*args, u32);
3203 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
3205 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
3211 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
3213 vat_main_t *vam = &vat_main;
3214 u8 *s = 0, *eid = 0;
3216 if (~0 == mp->locator_set_index)
3217 s = format (0, "action: %d", mp->action);
3219 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3221 eid = format (0, "%U", format_lisp_eid_vat,
3225 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3228 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3229 clib_net_to_host_u32 (mp->vni),
3231 mp->is_local ? "local" : "remote",
3232 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3233 clib_net_to_host_u16 (mp->key_id), mp->key);
3240 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3243 vat_main_t *vam = &vat_main;
3244 vat_json_node_t *node = 0;
3247 if (VAT_JSON_ARRAY != vam->json_tree.type)
3249 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3250 vat_json_init_array (&vam->json_tree);
3252 node = vat_json_array_add (&vam->json_tree);
3254 vat_json_init_object (node);
3255 if (~0 == mp->locator_set_index)
3256 vat_json_object_add_uint (node, "action", mp->action);
3258 vat_json_object_add_uint (node, "locator_set_index",
3259 clib_net_to_host_u32 (mp->locator_set_index));
3261 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3262 if (mp->eid_type == 3)
3264 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3265 vat_json_init_object (nsh_json);
3266 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3267 vat_json_object_add_uint (nsh_json, "spi",
3268 clib_net_to_host_u32 (nsh->spi));
3269 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3273 eid = format (0, "%U", format_lisp_eid_vat,
3277 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3279 vat_json_object_add_string_copy (node, "eid", eid);
3282 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3283 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3284 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3288 vat_json_object_add_uint (node, "key_id",
3289 clib_net_to_host_u16 (mp->key_id));
3290 vat_json_object_add_string_copy (node, "key", mp->key);
3295 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3297 vat_main_t *vam = &vat_main;
3298 u8 *seid = 0, *deid = 0;
3299 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3301 deid = format (0, "%U", format_lisp_eid_vat,
3302 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3304 seid = format (0, "%U", format_lisp_eid_vat,
3305 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3311 format_ip_address_fcn = format_ip4_address;
3313 format_ip_address_fcn = format_ip6_address;
3316 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3317 clib_net_to_host_u32 (mp->vni),
3319 format_ip_address_fcn, mp->lloc,
3320 format_ip_address_fcn, mp->rloc,
3321 clib_net_to_host_u32 (mp->pkt_count),
3322 clib_net_to_host_u32 (mp->bytes));
3329 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3331 struct in6_addr ip6;
3333 vat_main_t *vam = &vat_main;
3334 vat_json_node_t *node = 0;
3335 u8 *deid = 0, *seid = 0;
3337 if (VAT_JSON_ARRAY != vam->json_tree.type)
3339 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3340 vat_json_init_array (&vam->json_tree);
3342 node = vat_json_array_add (&vam->json_tree);
3344 vat_json_init_object (node);
3345 deid = format (0, "%U", format_lisp_eid_vat,
3346 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3348 seid = format (0, "%U", format_lisp_eid_vat,
3349 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3354 vat_json_object_add_string_copy (node, "seid", seid);
3355 vat_json_object_add_string_copy (node, "deid", deid);
3356 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3360 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3361 vat_json_object_add_ip4 (node, "lloc", ip4);
3362 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3363 vat_json_object_add_ip4 (node, "rloc", ip4);
3367 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3368 vat_json_object_add_ip6 (node, "lloc", ip6);
3369 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3370 vat_json_object_add_ip6 (node, "rloc", ip6);
3372 vat_json_object_add_uint (node, "pkt_count",
3373 clib_net_to_host_u32 (mp->pkt_count));
3374 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3381 vl_api_one_eid_table_map_details_t_handler
3382 (vl_api_one_eid_table_map_details_t * mp)
3384 vat_main_t *vam = &vat_main;
3386 u8 *line = format (0, "%=10d%=10d",
3387 clib_net_to_host_u32 (mp->vni),
3388 clib_net_to_host_u32 (mp->dp_table));
3389 print (vam->ofp, "%v", line);
3394 vl_api_one_eid_table_map_details_t_handler_json
3395 (vl_api_one_eid_table_map_details_t * mp)
3397 vat_main_t *vam = &vat_main;
3398 vat_json_node_t *node = NULL;
3400 if (VAT_JSON_ARRAY != vam->json_tree.type)
3402 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3403 vat_json_init_array (&vam->json_tree);
3405 node = vat_json_array_add (&vam->json_tree);
3406 vat_json_init_object (node);
3407 vat_json_object_add_uint (node, "dp_table",
3408 clib_net_to_host_u32 (mp->dp_table));
3409 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3413 vl_api_one_eid_table_vni_details_t_handler
3414 (vl_api_one_eid_table_vni_details_t * mp)
3416 vat_main_t *vam = &vat_main;
3418 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3419 print (vam->ofp, "%v", line);
3424 vl_api_one_eid_table_vni_details_t_handler_json
3425 (vl_api_one_eid_table_vni_details_t * mp)
3427 vat_main_t *vam = &vat_main;
3428 vat_json_node_t *node = NULL;
3430 if (VAT_JSON_ARRAY != vam->json_tree.type)
3432 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3433 vat_json_init_array (&vam->json_tree);
3435 node = vat_json_array_add (&vam->json_tree);
3436 vat_json_init_object (node);
3437 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3441 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3442 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3444 vat_main_t *vam = &vat_main;
3445 int retval = clib_net_to_host_u32 (mp->retval);
3447 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3448 print (vam->ofp, "fallback threshold value: %d", mp->value);
3450 vam->retval = retval;
3451 vam->result_ready = 1;
3455 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3456 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3458 vat_main_t *vam = &vat_main;
3459 vat_json_node_t _node, *node = &_node;
3460 int retval = clib_net_to_host_u32 (mp->retval);
3462 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3463 vat_json_init_object (node);
3464 vat_json_object_add_uint (node, "value", mp->value);
3466 vat_json_print (vam->ofp, node);
3467 vat_json_free (node);
3469 vam->retval = retval;
3470 vam->result_ready = 1;
3474 vl_api_show_one_map_register_state_reply_t_handler
3475 (vl_api_show_one_map_register_state_reply_t * mp)
3477 vat_main_t *vam = &vat_main;
3478 int retval = clib_net_to_host_u32 (mp->retval);
3480 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3482 vam->retval = retval;
3483 vam->result_ready = 1;
3487 vl_api_show_one_map_register_state_reply_t_handler_json
3488 (vl_api_show_one_map_register_state_reply_t * mp)
3490 vat_main_t *vam = &vat_main;
3491 vat_json_node_t _node, *node = &_node;
3492 int retval = clib_net_to_host_u32 (mp->retval);
3494 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3496 vat_json_init_object (node);
3497 vat_json_object_add_string_copy (node, "state", s);
3499 vat_json_print (vam->ofp, node);
3500 vat_json_free (node);
3502 vam->retval = retval;
3503 vam->result_ready = 1;
3508 vl_api_show_one_rloc_probe_state_reply_t_handler
3509 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3511 vat_main_t *vam = &vat_main;
3512 int retval = clib_net_to_host_u32 (mp->retval);
3517 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3519 vam->retval = retval;
3520 vam->result_ready = 1;
3524 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3525 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3527 vat_main_t *vam = &vat_main;
3528 vat_json_node_t _node, *node = &_node;
3529 int retval = clib_net_to_host_u32 (mp->retval);
3531 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3532 vat_json_init_object (node);
3533 vat_json_object_add_string_copy (node, "state", s);
3535 vat_json_print (vam->ofp, node);
3536 vat_json_free (node);
3538 vam->retval = retval;
3539 vam->result_ready = 1;
3544 vl_api_show_one_stats_enable_disable_reply_t_handler
3545 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3547 vat_main_t *vam = &vat_main;
3548 int retval = clib_net_to_host_u32 (mp->retval);
3553 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3555 vam->retval = retval;
3556 vam->result_ready = 1;
3560 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3561 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3563 vat_main_t *vam = &vat_main;
3564 vat_json_node_t _node, *node = &_node;
3565 int retval = clib_net_to_host_u32 (mp->retval);
3567 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3568 vat_json_init_object (node);
3569 vat_json_object_add_string_copy (node, "state", s);
3571 vat_json_print (vam->ofp, node);
3572 vat_json_free (node);
3574 vam->retval = retval;
3575 vam->result_ready = 1;
3580 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3582 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3583 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3584 e->vni = clib_net_to_host_u32 (e->vni);
3588 gpe_fwd_entries_get_reply_t_net_to_host
3589 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3593 mp->count = clib_net_to_host_u32 (mp->count);
3594 for (i = 0; i < mp->count; i++)
3596 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3601 format_gpe_encap_mode (u8 * s, va_list * args)
3603 u32 mode = va_arg (*args, u32);
3608 return format (s, "lisp");
3610 return format (s, "vxlan");
3616 vl_api_gpe_get_encap_mode_reply_t_handler
3617 (vl_api_gpe_get_encap_mode_reply_t * mp)
3619 vat_main_t *vam = &vat_main;
3621 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3622 vam->retval = ntohl (mp->retval);
3623 vam->result_ready = 1;
3627 vl_api_gpe_get_encap_mode_reply_t_handler_json
3628 (vl_api_gpe_get_encap_mode_reply_t * mp)
3630 vat_main_t *vam = &vat_main;
3631 vat_json_node_t node;
3633 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3634 vec_add1 (encap_mode, 0);
3636 vat_json_init_object (&node);
3637 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3639 vec_free (encap_mode);
3640 vat_json_print (vam->ofp, &node);
3641 vat_json_free (&node);
3643 vam->retval = ntohl (mp->retval);
3644 vam->result_ready = 1;
3648 vl_api_gpe_fwd_entry_path_details_t_handler
3649 (vl_api_gpe_fwd_entry_path_details_t * mp)
3651 vat_main_t *vam = &vat_main;
3652 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3654 if (mp->lcl_loc.is_ip4)
3655 format_ip_address_fcn = format_ip4_address;
3657 format_ip_address_fcn = format_ip6_address;
3659 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3660 format_ip_address_fcn, &mp->lcl_loc,
3661 format_ip_address_fcn, &mp->rmt_loc);
3665 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3667 struct in6_addr ip6;
3672 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3673 vat_json_object_add_ip4 (n, "address", ip4);
3677 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3678 vat_json_object_add_ip6 (n, "address", ip6);
3680 vat_json_object_add_uint (n, "weight", loc->weight);
3684 vl_api_gpe_fwd_entry_path_details_t_handler_json
3685 (vl_api_gpe_fwd_entry_path_details_t * mp)
3687 vat_main_t *vam = &vat_main;
3688 vat_json_node_t *node = NULL;
3689 vat_json_node_t *loc_node;
3691 if (VAT_JSON_ARRAY != vam->json_tree.type)
3693 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3694 vat_json_init_array (&vam->json_tree);
3696 node = vat_json_array_add (&vam->json_tree);
3697 vat_json_init_object (node);
3699 loc_node = vat_json_object_add (node, "local_locator");
3700 vat_json_init_object (loc_node);
3701 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3703 loc_node = vat_json_object_add (node, "remote_locator");
3704 vat_json_init_object (loc_node);
3705 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3709 vl_api_gpe_fwd_entries_get_reply_t_handler
3710 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3712 vat_main_t *vam = &vat_main;
3714 int retval = clib_net_to_host_u32 (mp->retval);
3715 vl_api_gpe_fwd_entry_t *e;
3720 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3722 for (i = 0; i < mp->count; i++)
3724 e = &mp->entries[i];
3725 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3726 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3727 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3731 vam->retval = retval;
3732 vam->result_ready = 1;
3736 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3737 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3740 vat_main_t *vam = &vat_main;
3741 vat_json_node_t *e = 0, root;
3743 int retval = clib_net_to_host_u32 (mp->retval);
3744 vl_api_gpe_fwd_entry_t *fwd;
3749 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3750 vat_json_init_array (&root);
3752 for (i = 0; i < mp->count; i++)
3754 e = vat_json_array_add (&root);
3755 fwd = &mp->entries[i];
3757 vat_json_init_object (e);
3758 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3759 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3760 vat_json_object_add_int (e, "vni", fwd->vni);
3761 vat_json_object_add_int (e, "action", fwd->action);
3763 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3764 fwd->leid_prefix_len);
3766 vat_json_object_add_string_copy (e, "leid", s);
3769 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3770 fwd->reid_prefix_len);
3772 vat_json_object_add_string_copy (e, "reid", s);
3776 vat_json_print (vam->ofp, &root);
3777 vat_json_free (&root);
3780 vam->retval = retval;
3781 vam->result_ready = 1;
3785 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3786 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3788 vat_main_t *vam = &vat_main;
3790 int retval = clib_net_to_host_u32 (mp->retval);
3791 vl_api_gpe_native_fwd_rpath_t *r;
3796 n = clib_net_to_host_u32 (mp->count);
3798 for (i = 0; i < n; i++)
3800 r = &mp->entries[i];
3801 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3802 clib_net_to_host_u32 (r->fib_index),
3803 clib_net_to_host_u32 (r->nh_sw_if_index),
3804 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3808 vam->retval = retval;
3809 vam->result_ready = 1;
3813 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3814 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3816 vat_main_t *vam = &vat_main;
3817 vat_json_node_t root, *e;
3819 int retval = clib_net_to_host_u32 (mp->retval);
3820 vl_api_gpe_native_fwd_rpath_t *r;
3826 n = clib_net_to_host_u32 (mp->count);
3827 vat_json_init_array (&root);
3829 for (i = 0; i < n; i++)
3831 e = vat_json_array_add (&root);
3832 vat_json_init_object (e);
3833 r = &mp->entries[i];
3835 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3838 vat_json_object_add_string_copy (e, "ip4", s);
3841 vat_json_object_add_uint (e, "fib_index",
3842 clib_net_to_host_u32 (r->fib_index));
3843 vat_json_object_add_uint (e, "nh_sw_if_index",
3844 clib_net_to_host_u32 (r->nh_sw_if_index));
3847 vat_json_print (vam->ofp, &root);
3848 vat_json_free (&root);
3851 vam->retval = retval;
3852 vam->result_ready = 1;
3856 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3857 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3859 vat_main_t *vam = &vat_main;
3861 int retval = clib_net_to_host_u32 (mp->retval);
3866 n = clib_net_to_host_u32 (mp->count);
3868 for (i = 0; i < n; i++)
3869 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3872 vam->retval = retval;
3873 vam->result_ready = 1;
3877 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3878 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3880 vat_main_t *vam = &vat_main;
3881 vat_json_node_t root;
3883 int retval = clib_net_to_host_u32 (mp->retval);
3888 n = clib_net_to_host_u32 (mp->count);
3889 vat_json_init_array (&root);
3891 for (i = 0; i < n; i++)
3892 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3894 vat_json_print (vam->ofp, &root);
3895 vat_json_free (&root);
3898 vam->retval = retval;
3899 vam->result_ready = 1;
3903 vl_api_one_ndp_entries_get_reply_t_handler
3904 (vl_api_one_ndp_entries_get_reply_t * mp)
3906 vat_main_t *vam = &vat_main;
3908 int retval = clib_net_to_host_u32 (mp->retval);
3913 n = clib_net_to_host_u32 (mp->count);
3915 for (i = 0; i < n; i++)
3916 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3917 format_ethernet_address, mp->entries[i].mac);
3920 vam->retval = retval;
3921 vam->result_ready = 1;
3925 vl_api_one_ndp_entries_get_reply_t_handler_json
3926 (vl_api_one_ndp_entries_get_reply_t * mp)
3929 vat_main_t *vam = &vat_main;
3930 vat_json_node_t *e = 0, root;
3932 int retval = clib_net_to_host_u32 (mp->retval);
3933 vl_api_one_ndp_entry_t *arp_entry;
3938 n = clib_net_to_host_u32 (mp->count);
3939 vat_json_init_array (&root);
3941 for (i = 0; i < n; i++)
3943 e = vat_json_array_add (&root);
3944 arp_entry = &mp->entries[i];
3946 vat_json_init_object (e);
3947 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3950 vat_json_object_add_string_copy (e, "mac", s);
3953 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3955 vat_json_object_add_string_copy (e, "ip6", s);
3959 vat_json_print (vam->ofp, &root);
3960 vat_json_free (&root);
3963 vam->retval = retval;
3964 vam->result_ready = 1;
3968 vl_api_one_l2_arp_entries_get_reply_t_handler
3969 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3971 vat_main_t *vam = &vat_main;
3973 int retval = clib_net_to_host_u32 (mp->retval);
3978 n = clib_net_to_host_u32 (mp->count);
3980 for (i = 0; i < n; i++)
3981 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3982 format_ethernet_address, mp->entries[i].mac);
3985 vam->retval = retval;
3986 vam->result_ready = 1;
3990 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3991 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3994 vat_main_t *vam = &vat_main;
3995 vat_json_node_t *e = 0, root;
3997 int retval = clib_net_to_host_u32 (mp->retval);
3998 vl_api_one_l2_arp_entry_t *arp_entry;
4003 n = clib_net_to_host_u32 (mp->count);
4004 vat_json_init_array (&root);
4006 for (i = 0; i < n; i++)
4008 e = vat_json_array_add (&root);
4009 arp_entry = &mp->entries[i];
4011 vat_json_init_object (e);
4012 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
4015 vat_json_object_add_string_copy (e, "mac", s);
4018 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
4020 vat_json_object_add_string_copy (e, "ip4", s);
4024 vat_json_print (vam->ofp, &root);
4025 vat_json_free (&root);
4028 vam->retval = retval;
4029 vam->result_ready = 1;
4033 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
4035 vat_main_t *vam = &vat_main;
4037 int retval = clib_net_to_host_u32 (mp->retval);
4042 n = clib_net_to_host_u32 (mp->count);
4044 for (i = 0; i < n; i++)
4046 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
4050 vam->retval = retval;
4051 vam->result_ready = 1;
4055 vl_api_one_ndp_bd_get_reply_t_handler_json
4056 (vl_api_one_ndp_bd_get_reply_t * mp)
4058 vat_main_t *vam = &vat_main;
4059 vat_json_node_t root;
4061 int retval = clib_net_to_host_u32 (mp->retval);
4066 n = clib_net_to_host_u32 (mp->count);
4067 vat_json_init_array (&root);
4069 for (i = 0; i < n; i++)
4071 vat_json_array_add_uint (&root,
4072 clib_net_to_host_u32 (mp->bridge_domains[i]));
4075 vat_json_print (vam->ofp, &root);
4076 vat_json_free (&root);
4079 vam->retval = retval;
4080 vam->result_ready = 1;
4084 vl_api_one_l2_arp_bd_get_reply_t_handler
4085 (vl_api_one_l2_arp_bd_get_reply_t * mp)
4087 vat_main_t *vam = &vat_main;
4089 int retval = clib_net_to_host_u32 (mp->retval);
4094 n = clib_net_to_host_u32 (mp->count);
4096 for (i = 0; i < n; i++)
4098 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
4102 vam->retval = retval;
4103 vam->result_ready = 1;
4107 vl_api_one_l2_arp_bd_get_reply_t_handler_json
4108 (vl_api_one_l2_arp_bd_get_reply_t * mp)
4110 vat_main_t *vam = &vat_main;
4111 vat_json_node_t root;
4113 int retval = clib_net_to_host_u32 (mp->retval);
4118 n = clib_net_to_host_u32 (mp->count);
4119 vat_json_init_array (&root);
4121 for (i = 0; i < n; i++)
4123 vat_json_array_add_uint (&root,
4124 clib_net_to_host_u32 (mp->bridge_domains[i]));
4127 vat_json_print (vam->ofp, &root);
4128 vat_json_free (&root);
4131 vam->retval = retval;
4132 vam->result_ready = 1;
4136 vl_api_one_adjacencies_get_reply_t_handler
4137 (vl_api_one_adjacencies_get_reply_t * mp)
4139 vat_main_t *vam = &vat_main;
4141 int retval = clib_net_to_host_u32 (mp->retval);
4142 vl_api_one_adjacency_t *a;
4147 n = clib_net_to_host_u32 (mp->count);
4149 for (i = 0; i < n; i++)
4151 a = &mp->adjacencies[i];
4152 print (vam->ofp, "%U %40U",
4153 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
4154 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
4158 vam->retval = retval;
4159 vam->result_ready = 1;
4163 vl_api_one_adjacencies_get_reply_t_handler_json
4164 (vl_api_one_adjacencies_get_reply_t * mp)
4167 vat_main_t *vam = &vat_main;
4168 vat_json_node_t *e = 0, root;
4170 int retval = clib_net_to_host_u32 (mp->retval);
4171 vl_api_one_adjacency_t *a;
4176 n = clib_net_to_host_u32 (mp->count);
4177 vat_json_init_array (&root);
4179 for (i = 0; i < n; i++)
4181 e = vat_json_array_add (&root);
4182 a = &mp->adjacencies[i];
4184 vat_json_init_object (e);
4185 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
4186 a->leid_prefix_len);
4188 vat_json_object_add_string_copy (e, "leid", s);
4191 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
4192 a->reid_prefix_len);
4194 vat_json_object_add_string_copy (e, "reid", s);
4198 vat_json_print (vam->ofp, &root);
4199 vat_json_free (&root);
4202 vam->retval = retval;
4203 vam->result_ready = 1;
4207 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
4209 vat_main_t *vam = &vat_main;
4211 print (vam->ofp, "%=20U",
4212 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4217 vl_api_one_map_server_details_t_handler_json
4218 (vl_api_one_map_server_details_t * mp)
4220 vat_main_t *vam = &vat_main;
4221 vat_json_node_t *node = NULL;
4222 struct in6_addr ip6;
4225 if (VAT_JSON_ARRAY != vam->json_tree.type)
4227 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4228 vat_json_init_array (&vam->json_tree);
4230 node = vat_json_array_add (&vam->json_tree);
4232 vat_json_init_object (node);
4235 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4236 vat_json_object_add_ip6 (node, "map-server", ip6);
4240 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4241 vat_json_object_add_ip4 (node, "map-server", ip4);
4246 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4249 vat_main_t *vam = &vat_main;
4251 print (vam->ofp, "%=20U",
4252 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4257 vl_api_one_map_resolver_details_t_handler_json
4258 (vl_api_one_map_resolver_details_t * mp)
4260 vat_main_t *vam = &vat_main;
4261 vat_json_node_t *node = NULL;
4262 struct in6_addr ip6;
4265 if (VAT_JSON_ARRAY != vam->json_tree.type)
4267 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4268 vat_json_init_array (&vam->json_tree);
4270 node = vat_json_array_add (&vam->json_tree);
4272 vat_json_init_object (node);
4275 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4276 vat_json_object_add_ip6 (node, "map resolver", ip6);
4280 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4281 vat_json_object_add_ip4 (node, "map resolver", ip4);
4286 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4288 vat_main_t *vam = &vat_main;
4289 i32 retval = ntohl (mp->retval);
4293 print (vam->ofp, "feature: %s\ngpe: %s",
4294 mp->feature_status ? "enabled" : "disabled",
4295 mp->gpe_status ? "enabled" : "disabled");
4298 vam->retval = retval;
4299 vam->result_ready = 1;
4303 vl_api_show_one_status_reply_t_handler_json
4304 (vl_api_show_one_status_reply_t * mp)
4306 vat_main_t *vam = &vat_main;
4307 vat_json_node_t node;
4308 u8 *gpe_status = NULL;
4309 u8 *feature_status = NULL;
4311 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4312 feature_status = format (0, "%s",
4313 mp->feature_status ? "enabled" : "disabled");
4314 vec_add1 (gpe_status, 0);
4315 vec_add1 (feature_status, 0);
4317 vat_json_init_object (&node);
4318 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4319 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4321 vec_free (gpe_status);
4322 vec_free (feature_status);
4324 vat_json_print (vam->ofp, &node);
4325 vat_json_free (&node);
4327 vam->retval = ntohl (mp->retval);
4328 vam->result_ready = 1;
4332 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4333 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4335 vat_main_t *vam = &vat_main;
4336 i32 retval = ntohl (mp->retval);
4340 print (vam->ofp, "%=20s", mp->locator_set_name);
4343 vam->retval = retval;
4344 vam->result_ready = 1;
4348 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4349 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4351 vat_main_t *vam = &vat_main;
4352 vat_json_node_t *node = NULL;
4354 if (VAT_JSON_ARRAY != vam->json_tree.type)
4356 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4357 vat_json_init_array (&vam->json_tree);
4359 node = vat_json_array_add (&vam->json_tree);
4361 vat_json_init_object (node);
4362 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4364 vat_json_print (vam->ofp, node);
4365 vat_json_free (node);
4367 vam->retval = ntohl (mp->retval);
4368 vam->result_ready = 1;
4372 format_lisp_map_request_mode (u8 * s, va_list * args)
4374 u32 mode = va_arg (*args, u32);
4379 return format (0, "dst-only");
4381 return format (0, "src-dst");
4387 vl_api_show_one_map_request_mode_reply_t_handler
4388 (vl_api_show_one_map_request_mode_reply_t * mp)
4390 vat_main_t *vam = &vat_main;
4391 i32 retval = ntohl (mp->retval);
4395 u32 mode = mp->mode;
4396 print (vam->ofp, "map_request_mode: %U",
4397 format_lisp_map_request_mode, mode);
4400 vam->retval = retval;
4401 vam->result_ready = 1;
4405 vl_api_show_one_map_request_mode_reply_t_handler_json
4406 (vl_api_show_one_map_request_mode_reply_t * mp)
4408 vat_main_t *vam = &vat_main;
4409 vat_json_node_t node;
4414 s = format (0, "%U", format_lisp_map_request_mode, mode);
4417 vat_json_init_object (&node);
4418 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4419 vat_json_print (vam->ofp, &node);
4420 vat_json_free (&node);
4423 vam->retval = ntohl (mp->retval);
4424 vam->result_ready = 1;
4428 vl_api_one_show_xtr_mode_reply_t_handler
4429 (vl_api_one_show_xtr_mode_reply_t * mp)
4431 vat_main_t *vam = &vat_main;
4432 i32 retval = ntohl (mp->retval);
4436 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4439 vam->retval = retval;
4440 vam->result_ready = 1;
4444 vl_api_one_show_xtr_mode_reply_t_handler_json
4445 (vl_api_one_show_xtr_mode_reply_t * mp)
4447 vat_main_t *vam = &vat_main;
4448 vat_json_node_t node;
4451 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4452 vec_add1 (status, 0);
4454 vat_json_init_object (&node);
4455 vat_json_object_add_string_copy (&node, "status", status);
4459 vat_json_print (vam->ofp, &node);
4460 vat_json_free (&node);
4462 vam->retval = ntohl (mp->retval);
4463 vam->result_ready = 1;
4467 vl_api_one_show_pitr_mode_reply_t_handler
4468 (vl_api_one_show_pitr_mode_reply_t * mp)
4470 vat_main_t *vam = &vat_main;
4471 i32 retval = ntohl (mp->retval);
4475 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4478 vam->retval = retval;
4479 vam->result_ready = 1;
4483 vl_api_one_show_pitr_mode_reply_t_handler_json
4484 (vl_api_one_show_pitr_mode_reply_t * mp)
4486 vat_main_t *vam = &vat_main;
4487 vat_json_node_t node;
4490 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4491 vec_add1 (status, 0);
4493 vat_json_init_object (&node);
4494 vat_json_object_add_string_copy (&node, "status", status);
4498 vat_json_print (vam->ofp, &node);
4499 vat_json_free (&node);
4501 vam->retval = ntohl (mp->retval);
4502 vam->result_ready = 1;
4506 vl_api_one_show_petr_mode_reply_t_handler
4507 (vl_api_one_show_petr_mode_reply_t * mp)
4509 vat_main_t *vam = &vat_main;
4510 i32 retval = ntohl (mp->retval);
4514 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4517 vam->retval = retval;
4518 vam->result_ready = 1;
4522 vl_api_one_show_petr_mode_reply_t_handler_json
4523 (vl_api_one_show_petr_mode_reply_t * mp)
4525 vat_main_t *vam = &vat_main;
4526 vat_json_node_t node;
4529 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4530 vec_add1 (status, 0);
4532 vat_json_init_object (&node);
4533 vat_json_object_add_string_copy (&node, "status", status);
4537 vat_json_print (vam->ofp, &node);
4538 vat_json_free (&node);
4540 vam->retval = ntohl (mp->retval);
4541 vam->result_ready = 1;
4545 vl_api_show_one_use_petr_reply_t_handler
4546 (vl_api_show_one_use_petr_reply_t * mp)
4548 vat_main_t *vam = &vat_main;
4549 i32 retval = ntohl (mp->retval);
4553 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4556 print (vam->ofp, "Proxy-ETR address; %U",
4557 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4562 vam->retval = retval;
4563 vam->result_ready = 1;
4567 vl_api_show_one_use_petr_reply_t_handler_json
4568 (vl_api_show_one_use_petr_reply_t * mp)
4570 vat_main_t *vam = &vat_main;
4571 vat_json_node_t node;
4574 struct in6_addr ip6;
4576 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4577 vec_add1 (status, 0);
4579 vat_json_init_object (&node);
4580 vat_json_object_add_string_copy (&node, "status", status);
4585 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4586 vat_json_object_add_ip6 (&node, "address", ip6);
4590 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4591 vat_json_object_add_ip4 (&node, "address", ip4);
4597 vat_json_print (vam->ofp, &node);
4598 vat_json_free (&node);
4600 vam->retval = ntohl (mp->retval);
4601 vam->result_ready = 1;
4605 vl_api_show_one_nsh_mapping_reply_t_handler
4606 (vl_api_show_one_nsh_mapping_reply_t * mp)
4608 vat_main_t *vam = &vat_main;
4609 i32 retval = ntohl (mp->retval);
4613 print (vam->ofp, "%-20s%-16s",
4614 mp->is_set ? "set" : "not-set",
4615 mp->is_set ? (char *) mp->locator_set_name : "");
4618 vam->retval = retval;
4619 vam->result_ready = 1;
4623 vl_api_show_one_nsh_mapping_reply_t_handler_json
4624 (vl_api_show_one_nsh_mapping_reply_t * mp)
4626 vat_main_t *vam = &vat_main;
4627 vat_json_node_t node;
4630 status = format (0, "%s", mp->is_set ? "yes" : "no");
4631 vec_add1 (status, 0);
4633 vat_json_init_object (&node);
4634 vat_json_object_add_string_copy (&node, "is_set", status);
4637 vat_json_object_add_string_copy (&node, "locator_set",
4638 mp->locator_set_name);
4643 vat_json_print (vam->ofp, &node);
4644 vat_json_free (&node);
4646 vam->retval = ntohl (mp->retval);
4647 vam->result_ready = 1;
4651 vl_api_show_one_map_register_ttl_reply_t_handler
4652 (vl_api_show_one_map_register_ttl_reply_t * mp)
4654 vat_main_t *vam = &vat_main;
4655 i32 retval = ntohl (mp->retval);
4657 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4661 print (vam->ofp, "ttl: %u", mp->ttl);
4664 vam->retval = retval;
4665 vam->result_ready = 1;
4669 vl_api_show_one_map_register_ttl_reply_t_handler_json
4670 (vl_api_show_one_map_register_ttl_reply_t * mp)
4672 vat_main_t *vam = &vat_main;
4673 vat_json_node_t node;
4675 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4676 vat_json_init_object (&node);
4677 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4679 vat_json_print (vam->ofp, &node);
4680 vat_json_free (&node);
4682 vam->retval = ntohl (mp->retval);
4683 vam->result_ready = 1;
4687 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4689 vat_main_t *vam = &vat_main;
4690 i32 retval = ntohl (mp->retval);
4694 print (vam->ofp, "%-20s%-16s",
4695 mp->status ? "enabled" : "disabled",
4696 mp->status ? (char *) mp->locator_set_name : "");
4699 vam->retval = retval;
4700 vam->result_ready = 1;
4704 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4706 vat_main_t *vam = &vat_main;
4707 vat_json_node_t node;
4710 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4711 vec_add1 (status, 0);
4713 vat_json_init_object (&node);
4714 vat_json_object_add_string_copy (&node, "status", status);
4717 vat_json_object_add_string_copy (&node, "locator_set",
4718 mp->locator_set_name);
4723 vat_json_print (vam->ofp, &node);
4724 vat_json_free (&node);
4726 vam->retval = ntohl (mp->retval);
4727 vam->result_ready = 1;
4731 format_policer_type (u8 * s, va_list * va)
4733 u32 i = va_arg (*va, u32);
4735 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4736 s = format (s, "1r2c");
4737 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4738 s = format (s, "1r3c");
4739 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4740 s = format (s, "2r3c-2698");
4741 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4742 s = format (s, "2r3c-4115");
4743 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4744 s = format (s, "2r3c-mef5cf1");
4746 s = format (s, "ILLEGAL");
4751 format_policer_rate_type (u8 * s, va_list * va)
4753 u32 i = va_arg (*va, u32);
4755 if (i == SSE2_QOS_RATE_KBPS)
4756 s = format (s, "kbps");
4757 else if (i == SSE2_QOS_RATE_PPS)
4758 s = format (s, "pps");
4760 s = format (s, "ILLEGAL");
4765 format_policer_round_type (u8 * s, va_list * va)
4767 u32 i = va_arg (*va, u32);
4769 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4770 s = format (s, "closest");
4771 else if (i == SSE2_QOS_ROUND_TO_UP)
4772 s = format (s, "up");
4773 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4774 s = format (s, "down");
4776 s = format (s, "ILLEGAL");
4781 format_policer_action_type (u8 * s, va_list * va)
4783 u32 i = va_arg (*va, u32);
4785 if (i == SSE2_QOS_ACTION_DROP)
4786 s = format (s, "drop");
4787 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4788 s = format (s, "transmit");
4789 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4790 s = format (s, "mark-and-transmit");
4792 s = format (s, "ILLEGAL");
4797 format_dscp (u8 * s, va_list * va)
4799 u32 i = va_arg (*va, u32);
4804 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4808 return format (s, "ILLEGAL");
4810 s = format (s, "%s", t);
4815 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4817 vat_main_t *vam = &vat_main;
4818 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4820 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4821 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4823 conform_dscp_str = format (0, "");
4825 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4826 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4828 exceed_dscp_str = format (0, "");
4830 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4831 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4833 violate_dscp_str = format (0, "");
4835 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4836 "rate type %U, round type %U, %s rate, %s color-aware, "
4837 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4838 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4839 "conform action %U%s, exceed action %U%s, violate action %U%s",
4841 format_policer_type, mp->type,
4844 clib_net_to_host_u64 (mp->cb),
4845 clib_net_to_host_u64 (mp->eb),
4846 format_policer_rate_type, mp->rate_type,
4847 format_policer_round_type, mp->round_type,
4848 mp->single_rate ? "single" : "dual",
4849 mp->color_aware ? "is" : "not",
4850 ntohl (mp->cir_tokens_per_period),
4851 ntohl (mp->pir_tokens_per_period),
4853 ntohl (mp->current_limit),
4854 ntohl (mp->current_bucket),
4855 ntohl (mp->extended_limit),
4856 ntohl (mp->extended_bucket),
4857 clib_net_to_host_u64 (mp->last_update_time),
4858 format_policer_action_type, mp->conform_action_type,
4860 format_policer_action_type, mp->exceed_action_type,
4862 format_policer_action_type, mp->violate_action_type,
4865 vec_free (conform_dscp_str);
4866 vec_free (exceed_dscp_str);
4867 vec_free (violate_dscp_str);
4870 static void vl_api_policer_details_t_handler_json
4871 (vl_api_policer_details_t * mp)
4873 vat_main_t *vam = &vat_main;
4874 vat_json_node_t *node;
4875 u8 *rate_type_str, *round_type_str, *type_str;
4876 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4878 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4880 format (0, "%U", format_policer_round_type, mp->round_type);
4881 type_str = format (0, "%U", format_policer_type, mp->type);
4882 conform_action_str = format (0, "%U", format_policer_action_type,
4883 mp->conform_action_type);
4884 exceed_action_str = format (0, "%U", format_policer_action_type,
4885 mp->exceed_action_type);
4886 violate_action_str = format (0, "%U", format_policer_action_type,
4887 mp->violate_action_type);
4889 if (VAT_JSON_ARRAY != vam->json_tree.type)
4891 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4892 vat_json_init_array (&vam->json_tree);
4894 node = vat_json_array_add (&vam->json_tree);
4896 vat_json_init_object (node);
4897 vat_json_object_add_string_copy (node, "name", mp->name);
4898 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4899 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4900 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4901 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4902 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4903 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4904 vat_json_object_add_string_copy (node, "type", type_str);
4905 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4906 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4907 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4908 vat_json_object_add_uint (node, "cir_tokens_per_period",
4909 ntohl (mp->cir_tokens_per_period));
4910 vat_json_object_add_uint (node, "eir_tokens_per_period",
4911 ntohl (mp->pir_tokens_per_period));
4912 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4913 vat_json_object_add_uint (node, "current_bucket",
4914 ntohl (mp->current_bucket));
4915 vat_json_object_add_uint (node, "extended_limit",
4916 ntohl (mp->extended_limit));
4917 vat_json_object_add_uint (node, "extended_bucket",
4918 ntohl (mp->extended_bucket));
4919 vat_json_object_add_uint (node, "last_update_time",
4920 ntohl (mp->last_update_time));
4921 vat_json_object_add_string_copy (node, "conform_action",
4922 conform_action_str);
4923 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4925 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4926 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4927 vec_free (dscp_str);
4929 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4930 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4932 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4933 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4934 vec_free (dscp_str);
4936 vat_json_object_add_string_copy (node, "violate_action",
4937 violate_action_str);
4938 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4940 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4941 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4942 vec_free (dscp_str);
4945 vec_free (rate_type_str);
4946 vec_free (round_type_str);
4947 vec_free (type_str);
4948 vec_free (conform_action_str);
4949 vec_free (exceed_action_str);
4950 vec_free (violate_action_str);
4954 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4957 vat_main_t *vam = &vat_main;
4958 int i, count = ntohl (mp->count);
4961 print (vam->ofp, "classify table ids (%d) : ", count);
4962 for (i = 0; i < count; i++)
4964 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4965 print (vam->ofp, (i < count - 1) ? "," : "");
4967 vam->retval = ntohl (mp->retval);
4968 vam->result_ready = 1;
4972 vl_api_classify_table_ids_reply_t_handler_json
4973 (vl_api_classify_table_ids_reply_t * mp)
4975 vat_main_t *vam = &vat_main;
4976 int i, count = ntohl (mp->count);
4980 vat_json_node_t node;
4982 vat_json_init_object (&node);
4983 for (i = 0; i < count; i++)
4985 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4987 vat_json_print (vam->ofp, &node);
4988 vat_json_free (&node);
4990 vam->retval = ntohl (mp->retval);
4991 vam->result_ready = 1;
4995 vl_api_classify_table_by_interface_reply_t_handler
4996 (vl_api_classify_table_by_interface_reply_t * mp)
4998 vat_main_t *vam = &vat_main;
5001 table_id = ntohl (mp->l2_table_id);
5003 print (vam->ofp, "l2 table id : %d", table_id);
5005 print (vam->ofp, "l2 table id : No input ACL tables configured");
5006 table_id = ntohl (mp->ip4_table_id);
5008 print (vam->ofp, "ip4 table id : %d", table_id);
5010 print (vam->ofp, "ip4 table id : No input ACL tables configured");
5011 table_id = ntohl (mp->ip6_table_id);
5013 print (vam->ofp, "ip6 table id : %d", table_id);
5015 print (vam->ofp, "ip6 table id : No input ACL tables configured");
5016 vam->retval = ntohl (mp->retval);
5017 vam->result_ready = 1;
5021 vl_api_classify_table_by_interface_reply_t_handler_json
5022 (vl_api_classify_table_by_interface_reply_t * mp)
5024 vat_main_t *vam = &vat_main;
5025 vat_json_node_t node;
5027 vat_json_init_object (&node);
5029 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
5030 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
5031 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
5033 vat_json_print (vam->ofp, &node);
5034 vat_json_free (&node);
5036 vam->retval = ntohl (mp->retval);
5037 vam->result_ready = 1;
5040 static void vl_api_policer_add_del_reply_t_handler
5041 (vl_api_policer_add_del_reply_t * mp)
5043 vat_main_t *vam = &vat_main;
5044 i32 retval = ntohl (mp->retval);
5045 if (vam->async_mode)
5047 vam->async_errors += (retval < 0);
5051 vam->retval = retval;
5052 vam->result_ready = 1;
5053 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
5055 * Note: this is just barely thread-safe, depends on
5056 * the main thread spinning waiting for an answer...
5058 errmsg ("policer index %d", ntohl (mp->policer_index));
5062 static void vl_api_policer_add_del_reply_t_handler_json
5063 (vl_api_policer_add_del_reply_t * mp)
5065 vat_main_t *vam = &vat_main;
5066 vat_json_node_t node;
5068 vat_json_init_object (&node);
5069 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5070 vat_json_object_add_uint (&node, "policer_index",
5071 ntohl (mp->policer_index));
5073 vat_json_print (vam->ofp, &node);
5074 vat_json_free (&node);
5076 vam->retval = ntohl (mp->retval);
5077 vam->result_ready = 1;
5080 /* Format hex dump. */
5082 format_hex_bytes (u8 * s, va_list * va)
5084 u8 *bytes = va_arg (*va, u8 *);
5085 int n_bytes = va_arg (*va, int);
5088 /* Print short or long form depending on byte count. */
5089 uword short_form = n_bytes <= 32;
5090 u32 indent = format_get_indent (s);
5095 for (i = 0; i < n_bytes; i++)
5097 if (!short_form && (i % 32) == 0)
5098 s = format (s, "%08x: ", i);
5099 s = format (s, "%02x", bytes[i]);
5100 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
5101 s = format (s, "\n%U", format_white_space, indent);
5108 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
5111 vat_main_t *vam = &vat_main;
5112 i32 retval = ntohl (mp->retval);
5115 print (vam->ofp, "classify table info :");
5116 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
5117 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
5118 ntohl (mp->miss_next_index));
5119 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
5120 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
5121 ntohl (mp->match_n_vectors));
5122 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
5123 ntohl (mp->mask_length));
5125 vam->retval = retval;
5126 vam->result_ready = 1;
5130 vl_api_classify_table_info_reply_t_handler_json
5131 (vl_api_classify_table_info_reply_t * mp)
5133 vat_main_t *vam = &vat_main;
5134 vat_json_node_t node;
5136 i32 retval = ntohl (mp->retval);
5139 vat_json_init_object (&node);
5141 vat_json_object_add_int (&node, "sessions",
5142 ntohl (mp->active_sessions));
5143 vat_json_object_add_int (&node, "nexttbl",
5144 ntohl (mp->next_table_index));
5145 vat_json_object_add_int (&node, "nextnode",
5146 ntohl (mp->miss_next_index));
5147 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
5148 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
5149 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
5150 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
5151 ntohl (mp->mask_length), 0);
5152 vat_json_object_add_string_copy (&node, "mask", s);
5154 vat_json_print (vam->ofp, &node);
5155 vat_json_free (&node);
5157 vam->retval = ntohl (mp->retval);
5158 vam->result_ready = 1;
5162 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
5165 vat_main_t *vam = &vat_main;
5167 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
5168 ntohl (mp->hit_next_index), ntohl (mp->advance),
5169 ntohl (mp->opaque_index));
5170 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
5171 ntohl (mp->match_length));
5175 vl_api_classify_session_details_t_handler_json
5176 (vl_api_classify_session_details_t * mp)
5178 vat_main_t *vam = &vat_main;
5179 vat_json_node_t *node = NULL;
5181 if (VAT_JSON_ARRAY != vam->json_tree.type)
5183 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5184 vat_json_init_array (&vam->json_tree);
5186 node = vat_json_array_add (&vam->json_tree);
5188 vat_json_init_object (node);
5189 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
5190 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
5191 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
5193 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
5195 vat_json_object_add_string_copy (node, "match", s);
5198 static void vl_api_pg_create_interface_reply_t_handler
5199 (vl_api_pg_create_interface_reply_t * mp)
5201 vat_main_t *vam = &vat_main;
5203 vam->retval = ntohl (mp->retval);
5204 vam->result_ready = 1;
5207 static void vl_api_pg_create_interface_reply_t_handler_json
5208 (vl_api_pg_create_interface_reply_t * mp)
5210 vat_main_t *vam = &vat_main;
5211 vat_json_node_t node;
5213 i32 retval = ntohl (mp->retval);
5216 vat_json_init_object (&node);
5218 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
5220 vat_json_print (vam->ofp, &node);
5221 vat_json_free (&node);
5223 vam->retval = ntohl (mp->retval);
5224 vam->result_ready = 1;
5227 static void vl_api_policer_classify_details_t_handler
5228 (vl_api_policer_classify_details_t * mp)
5230 vat_main_t *vam = &vat_main;
5232 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5233 ntohl (mp->table_index));
5236 static void vl_api_policer_classify_details_t_handler_json
5237 (vl_api_policer_classify_details_t * mp)
5239 vat_main_t *vam = &vat_main;
5240 vat_json_node_t *node;
5242 if (VAT_JSON_ARRAY != vam->json_tree.type)
5244 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5245 vat_json_init_array (&vam->json_tree);
5247 node = vat_json_array_add (&vam->json_tree);
5249 vat_json_init_object (node);
5250 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5251 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5254 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
5255 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5257 vat_main_t *vam = &vat_main;
5258 i32 retval = ntohl (mp->retval);
5259 if (vam->async_mode)
5261 vam->async_errors += (retval < 0);
5265 vam->retval = retval;
5266 vam->sw_if_index = ntohl (mp->sw_if_index);
5267 vam->result_ready = 1;
5269 vam->regenerate_interface_table = 1;
5272 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
5273 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5275 vat_main_t *vam = &vat_main;
5276 vat_json_node_t node;
5278 vat_json_init_object (&node);
5279 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5280 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
5282 vat_json_print (vam->ofp, &node);
5283 vat_json_free (&node);
5285 vam->retval = ntohl (mp->retval);
5286 vam->result_ready = 1;
5289 static void vl_api_flow_classify_details_t_handler
5290 (vl_api_flow_classify_details_t * mp)
5292 vat_main_t *vam = &vat_main;
5294 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5295 ntohl (mp->table_index));
5298 static void vl_api_flow_classify_details_t_handler_json
5299 (vl_api_flow_classify_details_t * mp)
5301 vat_main_t *vam = &vat_main;
5302 vat_json_node_t *node;
5304 if (VAT_JSON_ARRAY != vam->json_tree.type)
5306 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5307 vat_json_init_array (&vam->json_tree);
5309 node = vat_json_array_add (&vam->json_tree);
5311 vat_json_init_object (node);
5312 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5313 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5316 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
5317 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
5318 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
5319 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
5320 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
5321 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
5322 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
5323 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
5324 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
5325 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
5326 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
5327 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
5328 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5329 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5330 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5331 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5332 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5333 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5334 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5335 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5336 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5337 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5340 * Generate boilerplate reply handlers, which
5341 * dig the return value out of the xxx_reply_t API message,
5342 * stick it into vam->retval, and set vam->result_ready
5344 * Could also do this by pointing N message decode slots at
5345 * a single function, but that could break in subtle ways.
5348 #define foreach_standard_reply_retval_handler \
5349 _(sw_interface_set_flags_reply) \
5350 _(sw_interface_add_del_address_reply) \
5351 _(sw_interface_set_rx_mode_reply) \
5352 _(sw_interface_set_table_reply) \
5353 _(sw_interface_set_mpls_enable_reply) \
5354 _(sw_interface_set_vpath_reply) \
5355 _(sw_interface_set_vxlan_bypass_reply) \
5356 _(sw_interface_set_geneve_bypass_reply) \
5357 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5358 _(sw_interface_set_l2_bridge_reply) \
5359 _(bridge_domain_add_del_reply) \
5360 _(sw_interface_set_l2_xconnect_reply) \
5361 _(l2fib_add_del_reply) \
5362 _(l2fib_flush_int_reply) \
5363 _(l2fib_flush_bd_reply) \
5364 _(ip_add_del_route_reply) \
5365 _(ip_table_add_del_reply) \
5366 _(ip_mroute_add_del_reply) \
5367 _(mpls_route_add_del_reply) \
5368 _(mpls_table_add_del_reply) \
5369 _(mpls_ip_bind_unbind_reply) \
5370 _(bier_route_add_del_reply) \
5371 _(bier_table_add_del_reply) \
5372 _(proxy_arp_add_del_reply) \
5373 _(proxy_arp_intfc_enable_disable_reply) \
5374 _(sw_interface_set_unnumbered_reply) \
5375 _(ip_neighbor_add_del_reply) \
5376 _(oam_add_del_reply) \
5377 _(reset_fib_reply) \
5378 _(dhcp_proxy_config_reply) \
5379 _(dhcp_proxy_set_vss_reply) \
5380 _(dhcp_client_config_reply) \
5381 _(set_ip_flow_hash_reply) \
5382 _(sw_interface_ip6_enable_disable_reply) \
5383 _(sw_interface_ip6_set_link_local_address_reply) \
5384 _(ip6nd_proxy_add_del_reply) \
5385 _(sw_interface_ip6nd_ra_prefix_reply) \
5386 _(sw_interface_ip6nd_ra_config_reply) \
5387 _(set_arp_neighbor_limit_reply) \
5388 _(l2_patch_add_del_reply) \
5389 _(sr_policy_add_reply) \
5390 _(sr_policy_mod_reply) \
5391 _(sr_policy_del_reply) \
5392 _(sr_localsid_add_del_reply) \
5393 _(sr_steering_add_del_reply) \
5394 _(classify_add_del_session_reply) \
5395 _(classify_set_interface_ip_table_reply) \
5396 _(classify_set_interface_l2_tables_reply) \
5397 _(l2tpv3_set_tunnel_cookies_reply) \
5398 _(l2tpv3_interface_enable_disable_reply) \
5399 _(l2tpv3_set_lookup_key_reply) \
5400 _(l2_fib_clear_table_reply) \
5401 _(l2_interface_efp_filter_reply) \
5402 _(l2_interface_vlan_tag_rewrite_reply) \
5403 _(modify_vhost_user_if_reply) \
5404 _(delete_vhost_user_if_reply) \
5405 _(ip_probe_neighbor_reply) \
5406 _(ip_scan_neighbor_enable_disable_reply) \
5407 _(want_ip4_arp_events_reply) \
5408 _(want_ip6_nd_events_reply) \
5409 _(want_l2_macs_events_reply) \
5410 _(input_acl_set_interface_reply) \
5411 _(ipsec_spd_add_del_reply) \
5412 _(ipsec_interface_add_del_spd_reply) \
5413 _(ipsec_spd_add_del_entry_reply) \
5414 _(ipsec_sad_add_del_entry_reply) \
5415 _(ipsec_sa_set_key_reply) \
5416 _(ipsec_tunnel_if_add_del_reply) \
5417 _(ipsec_tunnel_if_set_key_reply) \
5418 _(ipsec_tunnel_if_set_sa_reply) \
5419 _(ikev2_profile_add_del_reply) \
5420 _(ikev2_profile_set_auth_reply) \
5421 _(ikev2_profile_set_id_reply) \
5422 _(ikev2_profile_set_ts_reply) \
5423 _(ikev2_set_local_key_reply) \
5424 _(ikev2_set_responder_reply) \
5425 _(ikev2_set_ike_transforms_reply) \
5426 _(ikev2_set_esp_transforms_reply) \
5427 _(ikev2_set_sa_lifetime_reply) \
5428 _(ikev2_initiate_sa_init_reply) \
5429 _(ikev2_initiate_del_ike_sa_reply) \
5430 _(ikev2_initiate_del_child_sa_reply) \
5431 _(ikev2_initiate_rekey_child_sa_reply) \
5432 _(delete_loopback_reply) \
5433 _(bd_ip_mac_add_del_reply) \
5434 _(want_interface_events_reply) \
5435 _(want_stats_reply) \
5436 _(cop_interface_enable_disable_reply) \
5437 _(cop_whitelist_enable_disable_reply) \
5438 _(sw_interface_clear_stats_reply) \
5439 _(ioam_enable_reply) \
5440 _(ioam_disable_reply) \
5441 _(one_add_del_locator_reply) \
5442 _(one_add_del_local_eid_reply) \
5443 _(one_add_del_remote_mapping_reply) \
5444 _(one_add_del_adjacency_reply) \
5445 _(one_add_del_map_resolver_reply) \
5446 _(one_add_del_map_server_reply) \
5447 _(one_enable_disable_reply) \
5448 _(one_rloc_probe_enable_disable_reply) \
5449 _(one_map_register_enable_disable_reply) \
5450 _(one_map_register_set_ttl_reply) \
5451 _(one_set_transport_protocol_reply) \
5452 _(one_map_register_fallback_threshold_reply) \
5453 _(one_pitr_set_locator_set_reply) \
5454 _(one_map_request_mode_reply) \
5455 _(one_add_del_map_request_itr_rlocs_reply) \
5456 _(one_eid_table_add_del_map_reply) \
5457 _(one_use_petr_reply) \
5458 _(one_stats_enable_disable_reply) \
5459 _(one_add_del_l2_arp_entry_reply) \
5460 _(one_add_del_ndp_entry_reply) \
5461 _(one_stats_flush_reply) \
5462 _(one_enable_disable_xtr_mode_reply) \
5463 _(one_enable_disable_pitr_mode_reply) \
5464 _(one_enable_disable_petr_mode_reply) \
5465 _(gpe_enable_disable_reply) \
5466 _(gpe_set_encap_mode_reply) \
5467 _(gpe_add_del_iface_reply) \
5468 _(gpe_add_del_native_fwd_rpath_reply) \
5469 _(af_packet_delete_reply) \
5470 _(policer_classify_set_interface_reply) \
5471 _(netmap_create_reply) \
5472 _(netmap_delete_reply) \
5473 _(set_ipfix_exporter_reply) \
5474 _(set_ipfix_classify_stream_reply) \
5475 _(ipfix_classify_table_add_del_reply) \
5476 _(flow_classify_set_interface_reply) \
5477 _(sw_interface_span_enable_disable_reply) \
5478 _(pg_capture_reply) \
5479 _(pg_enable_disable_reply) \
5480 _(ip_source_and_port_range_check_add_del_reply) \
5481 _(ip_source_and_port_range_check_interface_add_del_reply)\
5482 _(delete_subif_reply) \
5483 _(l2_interface_pbb_tag_rewrite_reply) \
5485 _(feature_enable_disable_reply) \
5486 _(sw_interface_tag_add_del_reply) \
5487 _(hw_interface_set_mtu_reply) \
5488 _(p2p_ethernet_add_reply) \
5489 _(p2p_ethernet_del_reply) \
5490 _(lldp_config_reply) \
5491 _(sw_interface_set_lldp_reply) \
5492 _(tcp_configure_src_addresses_reply) \
5493 _(dns_enable_disable_reply) \
5494 _(dns_name_server_add_del_reply) \
5495 _(session_rule_add_del_reply) \
5496 _(ip_container_proxy_add_del_reply) \
5497 _(output_acl_set_interface_reply) \
5498 _(qos_record_enable_disable_reply)
5501 static void vl_api_##n##_t_handler \
5502 (vl_api_##n##_t * mp) \
5504 vat_main_t * vam = &vat_main; \
5505 i32 retval = ntohl(mp->retval); \
5506 if (vam->async_mode) { \
5507 vam->async_errors += (retval < 0); \
5509 vam->retval = retval; \
5510 vam->result_ready = 1; \
5513 foreach_standard_reply_retval_handler;
5517 static void vl_api_##n##_t_handler_json \
5518 (vl_api_##n##_t * mp) \
5520 vat_main_t * vam = &vat_main; \
5521 vat_json_node_t node; \
5522 vat_json_init_object(&node); \
5523 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5524 vat_json_print(vam->ofp, &node); \
5525 vam->retval = ntohl(mp->retval); \
5526 vam->result_ready = 1; \
5528 foreach_standard_reply_retval_handler;
5532 * Table of message reply handlers, must include boilerplate handlers
5536 #define foreach_vpe_api_reply_msg \
5537 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5538 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5539 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5540 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5541 _(CONTROL_PING_REPLY, control_ping_reply) \
5542 _(CLI_REPLY, cli_reply) \
5543 _(CLI_INBAND_REPLY, cli_inband_reply) \
5544 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5545 sw_interface_add_del_address_reply) \
5546 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5547 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5548 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5549 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5550 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5551 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5552 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5553 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5554 sw_interface_set_l2_xconnect_reply) \
5555 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5556 sw_interface_set_l2_bridge_reply) \
5557 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5558 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5559 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5560 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5561 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5562 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5563 _(L2_FLAGS_REPLY, l2_flags_reply) \
5564 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5565 _(TAP_CONNECT_REPLY, tap_connect_reply) \
5566 _(TAP_MODIFY_REPLY, tap_modify_reply) \
5567 _(TAP_DELETE_REPLY, tap_delete_reply) \
5568 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
5569 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5570 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5571 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5572 _(BOND_CREATE_REPLY, bond_create_reply) \
5573 _(BOND_DELETE_REPLY, bond_delete_reply) \
5574 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5575 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5576 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5577 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5578 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5579 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5580 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5581 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5582 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5583 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5584 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5585 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5586 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5587 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5588 proxy_arp_intfc_enable_disable_reply) \
5589 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5590 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5591 sw_interface_set_unnumbered_reply) \
5592 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5593 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5594 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5595 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5596 _(RESET_FIB_REPLY, reset_fib_reply) \
5597 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5598 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5599 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5600 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5601 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5602 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5603 sw_interface_ip6_enable_disable_reply) \
5604 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
5605 sw_interface_ip6_set_link_local_address_reply) \
5606 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5607 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5608 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5609 sw_interface_ip6nd_ra_prefix_reply) \
5610 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5611 sw_interface_ip6nd_ra_config_reply) \
5612 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5613 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5614 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5615 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5616 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5617 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5618 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5619 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5620 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5621 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5622 classify_set_interface_ip_table_reply) \
5623 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5624 classify_set_interface_l2_tables_reply) \
5625 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5626 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5627 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5628 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5629 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5630 l2tpv3_interface_enable_disable_reply) \
5631 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5632 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5633 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5634 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5635 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5636 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5637 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5638 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5639 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5640 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5641 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5642 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5643 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5644 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5645 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5646 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5647 _(SHOW_VERSION_REPLY, show_version_reply) \
5648 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5649 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5650 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5651 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5652 _(IP_PROBE_NEIGHBOR_REPLY, ip_probe_neighbor_reply) \
5653 _(IP_SCAN_NEIGHBOR_ENABLE_DISABLE_REPLY, ip_scan_neighbor_enable_disable_reply) \
5654 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5655 _(IP4_ARP_EVENT, ip4_arp_event) \
5656 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5657 _(IP6_ND_EVENT, ip6_nd_event) \
5658 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5659 _(L2_MACS_EVENT, l2_macs_event) \
5660 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5661 _(IP_ADDRESS_DETAILS, ip_address_details) \
5662 _(IP_DETAILS, ip_details) \
5663 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5664 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5665 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
5666 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
5667 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5668 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5669 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5670 _(IPSEC_TUNNEL_IF_SET_KEY_REPLY, ipsec_tunnel_if_set_key_reply) \
5671 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5672 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
5673 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
5674 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
5675 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
5676 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
5677 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
5678 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
5679 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
5680 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
5681 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
5682 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
5683 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
5684 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
5685 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5686 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5687 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5688 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5689 _(WANT_STATS_REPLY, want_stats_reply) \
5690 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5691 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5692 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5693 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5694 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5695 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5696 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5697 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5698 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5699 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5700 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5701 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5702 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5703 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5704 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5705 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5706 one_map_register_enable_disable_reply) \
5707 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5708 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5709 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5710 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5711 one_map_register_fallback_threshold_reply) \
5712 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5713 one_rloc_probe_enable_disable_reply) \
5714 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5715 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5716 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5717 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5718 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5719 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5720 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5721 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5722 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5723 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5724 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5725 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5726 _(ONE_STATS_DETAILS, one_stats_details) \
5727 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5728 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5729 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5730 show_one_stats_enable_disable_reply) \
5731 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5732 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5733 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5734 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5735 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5736 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5737 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5738 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5739 one_enable_disable_pitr_mode_reply) \
5740 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5741 one_enable_disable_petr_mode_reply) \
5742 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5743 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5744 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5745 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5746 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5747 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5748 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5749 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5750 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5751 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5752 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5753 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5754 gpe_add_del_native_fwd_rpath_reply) \
5755 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5756 gpe_fwd_entry_path_details) \
5757 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5758 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5759 one_add_del_map_request_itr_rlocs_reply) \
5760 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5761 one_get_map_request_itr_rlocs_reply) \
5762 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5763 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5764 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5765 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5766 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5767 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5768 show_one_map_register_state_reply) \
5769 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5770 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5771 show_one_map_register_fallback_threshold_reply) \
5772 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5773 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5774 _(AF_PACKET_DETAILS, af_packet_details) \
5775 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5776 _(POLICER_DETAILS, policer_details) \
5777 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5778 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5779 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5780 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5781 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5782 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5783 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5784 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5785 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5786 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5787 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5788 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5789 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5790 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5791 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5792 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5793 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5794 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5795 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5796 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5797 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5798 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5799 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5800 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5801 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5802 ip_source_and_port_range_check_add_del_reply) \
5803 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5804 ip_source_and_port_range_check_interface_add_del_reply) \
5805 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5806 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5807 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5808 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5809 _(PUNT_REPLY, punt_reply) \
5810 _(IP_FIB_DETAILS, ip_fib_details) \
5811 _(IP6_FIB_DETAILS, ip6_fib_details) \
5812 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5813 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5814 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5815 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5816 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5817 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5818 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5819 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5820 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5821 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5822 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5823 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5824 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5825 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5826 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
5827 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \
5828 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5829 _(SESSION_RULES_DETAILS, session_rules_details) \
5830 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5831 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5832 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply)
5834 #define foreach_standalone_reply_msg \
5835 _(SW_INTERFACE_EVENT, sw_interface_event) \
5836 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
5837 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
5838 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
5839 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
5840 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
5841 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters)
5849 #define STR_VTR_OP_CASE(op) \
5850 case L2_VTR_ ## op: \
5854 str_vtr_op (u32 vtr_op)
5858 STR_VTR_OP_CASE (DISABLED);
5859 STR_VTR_OP_CASE (PUSH_1);
5860 STR_VTR_OP_CASE (PUSH_2);
5861 STR_VTR_OP_CASE (POP_1);
5862 STR_VTR_OP_CASE (POP_2);
5863 STR_VTR_OP_CASE (TRANSLATE_1_1);
5864 STR_VTR_OP_CASE (TRANSLATE_1_2);
5865 STR_VTR_OP_CASE (TRANSLATE_2_1);
5866 STR_VTR_OP_CASE (TRANSLATE_2_2);
5873 dump_sub_interface_table (vat_main_t * vam)
5875 const sw_interface_subif_t *sub = NULL;
5877 if (vam->json_output)
5880 ("JSON output supported only for VPE API calls and dump_stats_table");
5885 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5886 "Interface", "sw_if_index",
5887 "sub id", "dot1ad", "tags", "outer id",
5888 "inner id", "exact", "default", "outer any", "inner any");
5890 vec_foreach (sub, vam->sw_if_subif_table)
5893 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5894 sub->interface_name,
5896 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5897 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5898 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5899 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5900 if (sub->vtr_op != L2_VTR_DISABLED)
5903 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5904 "tag1: %d tag2: %d ]",
5905 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5906 sub->vtr_tag1, sub->vtr_tag2);
5914 name_sort_cmp (void *a1, void *a2)
5916 name_sort_t *n1 = a1;
5917 name_sort_t *n2 = a2;
5919 return strcmp ((char *) n1->name, (char *) n2->name);
5923 dump_interface_table (vat_main_t * vam)
5926 name_sort_t *nses = 0, *ns;
5928 if (vam->json_output)
5931 ("JSON output supported only for VPE API calls and dump_stats_table");
5936 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5938 vec_add2 (nses, ns, 1);
5939 ns->name = (u8 *)(p->key);
5940 ns->value = (u32) p->value[0];
5944 vec_sort_with_function (nses, name_sort_cmp);
5946 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5947 vec_foreach (ns, nses)
5949 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5956 dump_ip_table (vat_main_t * vam, int is_ipv6)
5958 const ip_details_t *det = NULL;
5959 const ip_address_details_t *address = NULL;
5962 print (vam->ofp, "%-12s", "sw_if_index");
5964 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5971 print (vam->ofp, "%-12d", i);
5972 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5977 vec_foreach (address, det->addr)
5981 is_ipv6 ? format_ip6_address : format_ip4_address,
5982 address->ip, address->prefix_length);
5990 dump_ipv4_table (vat_main_t * vam)
5992 if (vam->json_output)
5995 ("JSON output supported only for VPE API calls and dump_stats_table");
5999 return dump_ip_table (vam, 0);
6003 dump_ipv6_table (vat_main_t * vam)
6005 if (vam->json_output)
6008 ("JSON output supported only for VPE API calls and dump_stats_table");
6012 return dump_ip_table (vam, 1);
6016 counter_type_to_str (u8 counter_type, u8 is_combined)
6020 switch (counter_type)
6022 case VNET_INTERFACE_COUNTER_DROP:
6024 case VNET_INTERFACE_COUNTER_PUNT:
6026 case VNET_INTERFACE_COUNTER_IP4:
6028 case VNET_INTERFACE_COUNTER_IP6:
6030 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
6032 case VNET_INTERFACE_COUNTER_RX_MISS:
6034 case VNET_INTERFACE_COUNTER_RX_ERROR:
6036 case VNET_INTERFACE_COUNTER_TX_ERROR:
6039 return "INVALID-COUNTER-TYPE";
6044 switch (counter_type)
6046 case VNET_INTERFACE_COUNTER_RX:
6048 case VNET_INTERFACE_COUNTER_TX:
6051 return "INVALID-COUNTER-TYPE";
6057 dump_stats_table (vat_main_t * vam)
6059 vat_json_node_t node;
6060 vat_json_node_t *msg_array;
6061 vat_json_node_t *msg;
6062 vat_json_node_t *counter_array;
6063 vat_json_node_t *counter;
6064 interface_counter_t c;
6066 ip4_fib_counter_t *c4;
6067 ip6_fib_counter_t *c6;
6068 ip4_nbr_counter_t *n4;
6069 ip6_nbr_counter_t *n6;
6072 if (!vam->json_output)
6074 clib_warning ("dump_stats_table supported only in JSON format");
6078 vat_json_init_object (&node);
6080 /* interface counters */
6081 msg_array = vat_json_object_add (&node, "interface_counters");
6082 vat_json_init_array (msg_array);
6083 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
6085 msg = vat_json_array_add (msg_array);
6086 vat_json_init_object (msg);
6087 vat_json_object_add_string_copy (msg, "vnet_counter_type",
6088 (u8 *) counter_type_to_str (i, 0));
6089 vat_json_object_add_int (msg, "is_combined", 0);
6090 counter_array = vat_json_object_add (msg, "data");
6091 vat_json_init_array (counter_array);
6092 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
6094 packets = vam->simple_interface_counters[i][j];
6095 vat_json_array_add_uint (counter_array, packets);
6098 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
6100 msg = vat_json_array_add (msg_array);
6101 vat_json_init_object (msg);
6102 vat_json_object_add_string_copy (msg, "vnet_counter_type",
6103 (u8 *) counter_type_to_str (i, 1));
6104 vat_json_object_add_int (msg, "is_combined", 1);
6105 counter_array = vat_json_object_add (msg, "data");
6106 vat_json_init_array (counter_array);
6107 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
6109 c = vam->combined_interface_counters[i][j];
6110 counter = vat_json_array_add (counter_array);
6111 vat_json_init_object (counter);
6112 vat_json_object_add_uint (counter, "packets", c.packets);
6113 vat_json_object_add_uint (counter, "bytes", c.bytes);
6117 /* ip4 fib counters */
6118 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
6119 vat_json_init_array (msg_array);
6120 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
6122 msg = vat_json_array_add (msg_array);
6123 vat_json_init_object (msg);
6124 vat_json_object_add_uint (msg, "vrf_id",
6125 vam->ip4_fib_counters_vrf_id_by_index[i]);
6126 counter_array = vat_json_object_add (msg, "c");
6127 vat_json_init_array (counter_array);
6128 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
6130 counter = vat_json_array_add (counter_array);
6131 vat_json_init_object (counter);
6132 c4 = &vam->ip4_fib_counters[i][j];
6133 vat_json_object_add_ip4 (counter, "address", c4->address);
6134 vat_json_object_add_uint (counter, "address_length",
6135 c4->address_length);
6136 vat_json_object_add_uint (counter, "packets", c4->packets);
6137 vat_json_object_add_uint (counter, "bytes", c4->bytes);
6141 /* ip6 fib counters */
6142 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
6143 vat_json_init_array (msg_array);
6144 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
6146 msg = vat_json_array_add (msg_array);
6147 vat_json_init_object (msg);
6148 vat_json_object_add_uint (msg, "vrf_id",
6149 vam->ip6_fib_counters_vrf_id_by_index[i]);
6150 counter_array = vat_json_object_add (msg, "c");
6151 vat_json_init_array (counter_array);
6152 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
6154 counter = vat_json_array_add (counter_array);
6155 vat_json_init_object (counter);
6156 c6 = &vam->ip6_fib_counters[i][j];
6157 vat_json_object_add_ip6 (counter, "address", c6->address);
6158 vat_json_object_add_uint (counter, "address_length",
6159 c6->address_length);
6160 vat_json_object_add_uint (counter, "packets", c6->packets);
6161 vat_json_object_add_uint (counter, "bytes", c6->bytes);
6165 /* ip4 nbr counters */
6166 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
6167 vat_json_init_array (msg_array);
6168 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
6170 msg = vat_json_array_add (msg_array);
6171 vat_json_init_object (msg);
6172 vat_json_object_add_uint (msg, "sw_if_index", i);
6173 counter_array = vat_json_object_add (msg, "c");
6174 vat_json_init_array (counter_array);
6175 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
6177 counter = vat_json_array_add (counter_array);
6178 vat_json_init_object (counter);
6179 n4 = &vam->ip4_nbr_counters[i][j];
6180 vat_json_object_add_ip4 (counter, "address", n4->address);
6181 vat_json_object_add_uint (counter, "link-type", n4->linkt);
6182 vat_json_object_add_uint (counter, "packets", n4->packets);
6183 vat_json_object_add_uint (counter, "bytes", n4->bytes);
6187 /* ip6 nbr counters */
6188 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
6189 vat_json_init_array (msg_array);
6190 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
6192 msg = vat_json_array_add (msg_array);
6193 vat_json_init_object (msg);
6194 vat_json_object_add_uint (msg, "sw_if_index", i);
6195 counter_array = vat_json_object_add (msg, "c");
6196 vat_json_init_array (counter_array);
6197 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
6199 counter = vat_json_array_add (counter_array);
6200 vat_json_init_object (counter);
6201 n6 = &vam->ip6_nbr_counters[i][j];
6202 vat_json_object_add_ip6 (counter, "address", n6->address);
6203 vat_json_object_add_uint (counter, "packets", n6->packets);
6204 vat_json_object_add_uint (counter, "bytes", n6->bytes);
6208 vat_json_print (vam->ofp, &node);
6209 vat_json_free (&node);
6215 * Pass CLI buffers directly in the CLI_INBAND API message,
6216 * instead of an additional shared memory area.
6219 exec_inband (vat_main_t * vam)
6221 vl_api_cli_inband_t *mp;
6222 unformat_input_t *i = vam->input;
6225 if (vec_len (i->buffer) == 0)
6228 if (vam->exec_mode == 0 && unformat (i, "mode"))
6233 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
6240 * In order for the CLI command to work, it
6241 * must be a vector ending in \n, not a C-string ending
6244 u32 len = vec_len (vam->input->buffer);
6245 M2 (CLI_INBAND, mp, len);
6246 clib_memcpy (mp->cmd, vam->input->buffer, len);
6247 mp->length = htonl (len);
6251 /* json responses may or may not include a useful reply... */
6252 if (vec_len (vam->cmd_reply))
6253 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
6258 exec (vat_main_t * vam)
6260 return exec_inband (vam);
6264 api_create_loopback (vat_main_t * vam)
6266 unformat_input_t *i = vam->input;
6267 vl_api_create_loopback_t *mp;
6268 vl_api_create_loopback_instance_t *mp_lbi;
6271 u8 is_specified = 0;
6272 u32 user_instance = 0;
6275 memset (mac_address, 0, sizeof (mac_address));
6277 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6279 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6281 if (unformat (i, "instance %d", &user_instance))
6289 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
6290 mp_lbi->is_specified = is_specified;
6292 mp_lbi->user_instance = htonl (user_instance);
6294 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
6299 /* Construct the API message */
6300 M (CREATE_LOOPBACK, mp);
6302 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
6311 api_delete_loopback (vat_main_t * vam)
6313 unformat_input_t *i = vam->input;
6314 vl_api_delete_loopback_t *mp;
6315 u32 sw_if_index = ~0;
6318 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6320 if (unformat (i, "sw_if_index %d", &sw_if_index))
6326 if (sw_if_index == ~0)
6328 errmsg ("missing sw_if_index");
6332 /* Construct the API message */
6333 M (DELETE_LOOPBACK, mp);
6334 mp->sw_if_index = ntohl (sw_if_index);
6342 api_want_stats (vat_main_t * vam)
6344 unformat_input_t *i = vam->input;
6345 vl_api_want_stats_t *mp;
6349 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6351 if (unformat (i, "enable"))
6353 else if (unformat (i, "disable"))
6361 errmsg ("missing enable|disable");
6366 mp->enable_disable = enable;
6374 api_want_interface_events (vat_main_t * vam)
6376 unformat_input_t *i = vam->input;
6377 vl_api_want_interface_events_t *mp;
6381 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6383 if (unformat (i, "enable"))
6385 else if (unformat (i, "disable"))
6393 errmsg ("missing enable|disable");
6397 M (WANT_INTERFACE_EVENTS, mp);
6398 mp->enable_disable = enable;
6400 vam->interface_event_display = enable;
6408 /* Note: non-static, called once to set up the initial intfc table */
6410 api_sw_interface_dump (vat_main_t * vam)
6412 vl_api_sw_interface_dump_t *mp;
6413 vl_api_control_ping_t *mp_ping;
6415 name_sort_t *nses = 0, *ns;
6416 sw_interface_subif_t *sub = NULL;
6419 /* Toss the old name table */
6421 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6423 vec_add2 (nses, ns, 1);
6424 ns->name = (u8 *)(p->key);
6425 ns->value = (u32) p->value[0];
6429 hash_free (vam->sw_if_index_by_interface_name);
6431 vec_foreach (ns, nses) vec_free (ns->name);
6435 vec_foreach (sub, vam->sw_if_subif_table)
6437 vec_free (sub->interface_name);
6439 vec_free (vam->sw_if_subif_table);
6441 /* recreate the interface name hash table */
6442 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
6445 * Ask for all interface names. Otherwise, the epic catalog of
6446 * name filters becomes ridiculously long, and vat ends up needing
6447 * to be taught about new interface types.
6449 M (SW_INTERFACE_DUMP, mp);
6452 /* Use a control ping for synchronization */
6453 MPING (CONTROL_PING, mp_ping);
6461 api_sw_interface_set_flags (vat_main_t * vam)
6463 unformat_input_t *i = vam->input;
6464 vl_api_sw_interface_set_flags_t *mp;
6466 u8 sw_if_index_set = 0;
6470 /* Parse args required to build the message */
6471 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6473 if (unformat (i, "admin-up"))
6475 else if (unformat (i, "admin-down"))
6478 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6479 sw_if_index_set = 1;
6480 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6481 sw_if_index_set = 1;
6486 if (sw_if_index_set == 0)
6488 errmsg ("missing interface name or sw_if_index");
6492 /* Construct the API message */
6493 M (SW_INTERFACE_SET_FLAGS, mp);
6494 mp->sw_if_index = ntohl (sw_if_index);
6495 mp->admin_up_down = admin_up;
6500 /* Wait for a reply, return the good/bad news... */
6506 api_sw_interface_set_rx_mode (vat_main_t * vam)
6508 unformat_input_t *i = vam->input;
6509 vl_api_sw_interface_set_rx_mode_t *mp;
6511 u8 sw_if_index_set = 0;
6513 u8 queue_id_valid = 0;
6515 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
6517 /* Parse args required to build the message */
6518 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6520 if (unformat (i, "queue %d", &queue_id))
6522 else if (unformat (i, "polling"))
6523 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
6524 else if (unformat (i, "interrupt"))
6525 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
6526 else if (unformat (i, "adaptive"))
6527 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
6529 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6530 sw_if_index_set = 1;
6531 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6532 sw_if_index_set = 1;
6537 if (sw_if_index_set == 0)
6539 errmsg ("missing interface name or sw_if_index");
6542 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6544 errmsg ("missing rx-mode");
6548 /* Construct the API message */
6549 M (SW_INTERFACE_SET_RX_MODE, mp);
6550 mp->sw_if_index = ntohl (sw_if_index);
6552 mp->queue_id_valid = queue_id_valid;
6553 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6558 /* Wait for a reply, return the good/bad news... */
6564 api_sw_interface_clear_stats (vat_main_t * vam)
6566 unformat_input_t *i = vam->input;
6567 vl_api_sw_interface_clear_stats_t *mp;
6569 u8 sw_if_index_set = 0;
6572 /* Parse args required to build the message */
6573 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6575 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6576 sw_if_index_set = 1;
6577 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6578 sw_if_index_set = 1;
6583 /* Construct the API message */
6584 M (SW_INTERFACE_CLEAR_STATS, mp);
6586 if (sw_if_index_set == 1)
6587 mp->sw_if_index = ntohl (sw_if_index);
6589 mp->sw_if_index = ~0;
6594 /* Wait for a reply, return the good/bad news... */
6600 api_sw_interface_add_del_address (vat_main_t * vam)
6602 unformat_input_t *i = vam->input;
6603 vl_api_sw_interface_add_del_address_t *mp;
6605 u8 sw_if_index_set = 0;
6606 u8 is_add = 1, del_all = 0;
6607 u32 address_length = 0;
6608 u8 v4_address_set = 0;
6609 u8 v6_address_set = 0;
6610 ip4_address_t v4address;
6611 ip6_address_t v6address;
6614 /* Parse args required to build the message */
6615 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6617 if (unformat (i, "del-all"))
6619 else if (unformat (i, "del"))
6622 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6623 sw_if_index_set = 1;
6624 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6625 sw_if_index_set = 1;
6626 else if (unformat (i, "%U/%d",
6627 unformat_ip4_address, &v4address, &address_length))
6629 else if (unformat (i, "%U/%d",
6630 unformat_ip6_address, &v6address, &address_length))
6636 if (sw_if_index_set == 0)
6638 errmsg ("missing interface name or sw_if_index");
6641 if (v4_address_set && v6_address_set)
6643 errmsg ("both v4 and v6 addresses set");
6646 if (!v4_address_set && !v6_address_set && !del_all)
6648 errmsg ("no addresses set");
6652 /* Construct the API message */
6653 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6655 mp->sw_if_index = ntohl (sw_if_index);
6656 mp->is_add = is_add;
6657 mp->del_all = del_all;
6661 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6665 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6667 mp->address_length = address_length;
6672 /* Wait for a reply, return good/bad news */
6678 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6680 unformat_input_t *i = vam->input;
6681 vl_api_sw_interface_set_mpls_enable_t *mp;
6683 u8 sw_if_index_set = 0;
6687 /* Parse args required to build the message */
6688 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6690 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6691 sw_if_index_set = 1;
6692 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6693 sw_if_index_set = 1;
6694 else if (unformat (i, "disable"))
6696 else if (unformat (i, "dis"))
6702 if (sw_if_index_set == 0)
6704 errmsg ("missing interface name or sw_if_index");
6708 /* Construct the API message */
6709 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6711 mp->sw_if_index = ntohl (sw_if_index);
6712 mp->enable = enable;
6717 /* Wait for a reply... */
6723 api_sw_interface_set_table (vat_main_t * vam)
6725 unformat_input_t *i = vam->input;
6726 vl_api_sw_interface_set_table_t *mp;
6727 u32 sw_if_index, vrf_id = 0;
6728 u8 sw_if_index_set = 0;
6732 /* Parse args required to build the message */
6733 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6735 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6736 sw_if_index_set = 1;
6737 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6738 sw_if_index_set = 1;
6739 else if (unformat (i, "vrf %d", &vrf_id))
6741 else if (unformat (i, "ipv6"))
6747 if (sw_if_index_set == 0)
6749 errmsg ("missing interface name or sw_if_index");
6753 /* Construct the API message */
6754 M (SW_INTERFACE_SET_TABLE, mp);
6756 mp->sw_if_index = ntohl (sw_if_index);
6757 mp->is_ipv6 = is_ipv6;
6758 mp->vrf_id = ntohl (vrf_id);
6763 /* Wait for a reply... */
6768 static void vl_api_sw_interface_get_table_reply_t_handler
6769 (vl_api_sw_interface_get_table_reply_t * mp)
6771 vat_main_t *vam = &vat_main;
6773 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6775 vam->retval = ntohl (mp->retval);
6776 vam->result_ready = 1;
6780 static void vl_api_sw_interface_get_table_reply_t_handler_json
6781 (vl_api_sw_interface_get_table_reply_t * mp)
6783 vat_main_t *vam = &vat_main;
6784 vat_json_node_t node;
6786 vat_json_init_object (&node);
6787 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6788 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6790 vat_json_print (vam->ofp, &node);
6791 vat_json_free (&node);
6793 vam->retval = ntohl (mp->retval);
6794 vam->result_ready = 1;
6798 api_sw_interface_get_table (vat_main_t * vam)
6800 unformat_input_t *i = vam->input;
6801 vl_api_sw_interface_get_table_t *mp;
6803 u8 sw_if_index_set = 0;
6807 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6809 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6810 sw_if_index_set = 1;
6811 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6812 sw_if_index_set = 1;
6813 else if (unformat (i, "ipv6"))
6819 if (sw_if_index_set == 0)
6821 errmsg ("missing interface name or sw_if_index");
6825 M (SW_INTERFACE_GET_TABLE, mp);
6826 mp->sw_if_index = htonl (sw_if_index);
6827 mp->is_ipv6 = is_ipv6;
6835 api_sw_interface_set_vpath (vat_main_t * vam)
6837 unformat_input_t *i = vam->input;
6838 vl_api_sw_interface_set_vpath_t *mp;
6839 u32 sw_if_index = 0;
6840 u8 sw_if_index_set = 0;
6844 /* Parse args required to build the message */
6845 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6847 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6848 sw_if_index_set = 1;
6849 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6850 sw_if_index_set = 1;
6851 else if (unformat (i, "enable"))
6853 else if (unformat (i, "disable"))
6859 if (sw_if_index_set == 0)
6861 errmsg ("missing interface name or sw_if_index");
6865 /* Construct the API message */
6866 M (SW_INTERFACE_SET_VPATH, mp);
6868 mp->sw_if_index = ntohl (sw_if_index);
6869 mp->enable = is_enable;
6874 /* Wait for a reply... */
6880 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6882 unformat_input_t *i = vam->input;
6883 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6884 u32 sw_if_index = 0;
6885 u8 sw_if_index_set = 0;
6890 /* Parse args required to build the message */
6891 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6893 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6894 sw_if_index_set = 1;
6895 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6896 sw_if_index_set = 1;
6897 else if (unformat (i, "enable"))
6899 else if (unformat (i, "disable"))
6901 else if (unformat (i, "ip4"))
6903 else if (unformat (i, "ip6"))
6909 if (sw_if_index_set == 0)
6911 errmsg ("missing interface name or sw_if_index");
6915 /* Construct the API message */
6916 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6918 mp->sw_if_index = ntohl (sw_if_index);
6919 mp->enable = is_enable;
6920 mp->is_ipv6 = is_ipv6;
6925 /* Wait for a reply... */
6931 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6933 unformat_input_t *i = vam->input;
6934 vl_api_sw_interface_set_geneve_bypass_t *mp;
6935 u32 sw_if_index = 0;
6936 u8 sw_if_index_set = 0;
6941 /* Parse args required to build the message */
6942 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6944 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6945 sw_if_index_set = 1;
6946 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6947 sw_if_index_set = 1;
6948 else if (unformat (i, "enable"))
6950 else if (unformat (i, "disable"))
6952 else if (unformat (i, "ip4"))
6954 else if (unformat (i, "ip6"))
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_GENEVE_BYPASS, mp);
6969 mp->sw_if_index = ntohl (sw_if_index);
6970 mp->enable = is_enable;
6971 mp->is_ipv6 = is_ipv6;
6976 /* Wait for a reply... */
6982 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6984 unformat_input_t *i = vam->input;
6985 vl_api_sw_interface_set_l2_xconnect_t *mp;
6987 u8 rx_sw_if_index_set = 0;
6989 u8 tx_sw_if_index_set = 0;
6993 /* Parse args required to build the message */
6994 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6996 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6997 rx_sw_if_index_set = 1;
6998 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6999 tx_sw_if_index_set = 1;
7000 else if (unformat (i, "rx"))
7002 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7004 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7006 rx_sw_if_index_set = 1;
7011 else if (unformat (i, "tx"))
7013 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7015 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7017 tx_sw_if_index_set = 1;
7022 else if (unformat (i, "enable"))
7024 else if (unformat (i, "disable"))
7030 if (rx_sw_if_index_set == 0)
7032 errmsg ("missing rx interface name or rx_sw_if_index");
7036 if (enable && (tx_sw_if_index_set == 0))
7038 errmsg ("missing tx interface name or tx_sw_if_index");
7042 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
7044 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7045 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
7046 mp->enable = enable;
7054 api_sw_interface_set_l2_bridge (vat_main_t * vam)
7056 unformat_input_t *i = vam->input;
7057 vl_api_sw_interface_set_l2_bridge_t *mp;
7059 u8 rx_sw_if_index_set = 0;
7067 /* Parse args required to build the message */
7068 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7070 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
7071 rx_sw_if_index_set = 1;
7072 else if (unformat (i, "bd_id %d", &bd_id))
7076 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
7077 rx_sw_if_index_set = 1;
7078 else if (unformat (i, "shg %d", &shg))
7080 else if (unformat (i, "bvi"))
7082 else if (unformat (i, "enable"))
7084 else if (unformat (i, "disable"))
7090 if (rx_sw_if_index_set == 0)
7092 errmsg ("missing rx interface name or sw_if_index");
7096 if (enable && (bd_id_set == 0))
7098 errmsg ("missing bridge domain");
7102 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
7104 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7105 mp->bd_id = ntohl (bd_id);
7108 mp->enable = enable;
7116 api_bridge_domain_dump (vat_main_t * vam)
7118 unformat_input_t *i = vam->input;
7119 vl_api_bridge_domain_dump_t *mp;
7120 vl_api_control_ping_t *mp_ping;
7124 /* Parse args required to build the message */
7125 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7127 if (unformat (i, "bd_id %d", &bd_id))
7133 M (BRIDGE_DOMAIN_DUMP, mp);
7134 mp->bd_id = ntohl (bd_id);
7137 /* Use a control ping for synchronization */
7138 MPING (CONTROL_PING, mp_ping);
7146 api_bridge_domain_add_del (vat_main_t * vam)
7148 unformat_input_t *i = vam->input;
7149 vl_api_bridge_domain_add_del_t *mp;
7152 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
7157 /* Parse args required to build the message */
7158 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7160 if (unformat (i, "bd_id %d", &bd_id))
7162 else if (unformat (i, "flood %d", &flood))
7164 else if (unformat (i, "uu-flood %d", &uu_flood))
7166 else if (unformat (i, "forward %d", &forward))
7168 else if (unformat (i, "learn %d", &learn))
7170 else if (unformat (i, "arp-term %d", &arp_term))
7172 else if (unformat (i, "mac-age %d", &mac_age))
7174 else if (unformat (i, "bd-tag %s", &bd_tag))
7176 else if (unformat (i, "del"))
7179 flood = uu_flood = forward = learn = 0;
7187 errmsg ("missing bridge domain");
7194 errmsg ("mac age must be less than 256 ");
7199 if ((bd_tag) && (vec_len (bd_tag) > 63))
7201 errmsg ("bd-tag cannot be longer than 63");
7206 M (BRIDGE_DOMAIN_ADD_DEL, mp);
7208 mp->bd_id = ntohl (bd_id);
7210 mp->uu_flood = uu_flood;
7211 mp->forward = forward;
7213 mp->arp_term = arp_term;
7214 mp->is_add = is_add;
7215 mp->mac_age = (u8) mac_age;
7218 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
7219 mp->bd_tag[vec_len (bd_tag)] = 0;
7230 api_l2fib_flush_bd (vat_main_t * vam)
7232 unformat_input_t *i = vam->input;
7233 vl_api_l2fib_flush_bd_t *mp;
7237 /* Parse args required to build the message */
7238 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7240 if (unformat (i, "bd_id %d", &bd_id));
7247 errmsg ("missing bridge domain");
7251 M (L2FIB_FLUSH_BD, mp);
7253 mp->bd_id = htonl (bd_id);
7261 api_l2fib_flush_int (vat_main_t * vam)
7263 unformat_input_t *i = vam->input;
7264 vl_api_l2fib_flush_int_t *mp;
7265 u32 sw_if_index = ~0;
7268 /* Parse args required to build the message */
7269 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7271 if (unformat (i, "sw_if_index %d", &sw_if_index));
7273 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
7278 if (sw_if_index == ~0)
7280 errmsg ("missing interface name or sw_if_index");
7284 M (L2FIB_FLUSH_INT, mp);
7286 mp->sw_if_index = ntohl (sw_if_index);
7294 api_l2fib_add_del (vat_main_t * vam)
7296 unformat_input_t *i = vam->input;
7297 vl_api_l2fib_add_del_t *mp;
7303 u32 sw_if_index = 0;
7304 u8 sw_if_index_set = 0;
7313 /* Parse args required to build the message */
7314 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7316 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
7318 else if (unformat (i, "bd_id %d", &bd_id))
7320 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7321 sw_if_index_set = 1;
7322 else if (unformat (i, "sw_if"))
7324 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7327 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7328 sw_if_index_set = 1;
7333 else if (unformat (i, "static"))
7335 else if (unformat (i, "filter"))
7340 else if (unformat (i, "bvi"))
7345 else if (unformat (i, "del"))
7347 else if (unformat (i, "count %d", &count))
7355 errmsg ("missing mac address");
7361 errmsg ("missing bridge domain");
7365 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7367 errmsg ("missing interface name or sw_if_index");
7373 /* Turn on async mode */
7374 vam->async_mode = 1;
7375 vam->async_errors = 0;
7376 before = vat_time_now (vam);
7379 for (j = 0; j < count; j++)
7381 M (L2FIB_ADD_DEL, mp);
7383 clib_memcpy (mp->mac, mac, 6);
7384 mp->bd_id = ntohl (bd_id);
7385 mp->is_add = is_add;
7386 mp->sw_if_index = ntohl (sw_if_index);
7390 mp->static_mac = static_mac;
7391 mp->filter_mac = filter_mac;
7392 mp->bvi_mac = bvi_mac;
7394 increment_mac_address (mac);
7401 vl_api_control_ping_t *mp_ping;
7404 /* Shut off async mode */
7405 vam->async_mode = 0;
7407 MPING (CONTROL_PING, mp_ping);
7410 timeout = vat_time_now (vam) + 1.0;
7411 while (vat_time_now (vam) < timeout)
7412 if (vam->result_ready == 1)
7417 if (vam->retval == -99)
7420 if (vam->async_errors > 0)
7422 errmsg ("%d asynchronous errors", vam->async_errors);
7425 vam->async_errors = 0;
7426 after = vat_time_now (vam);
7428 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7429 count, after - before, count / (after - before));
7435 /* Wait for a reply... */
7439 /* Return the good/bad news */
7440 return (vam->retval);
7444 api_bridge_domain_set_mac_age (vat_main_t * vam)
7446 unformat_input_t *i = vam->input;
7447 vl_api_bridge_domain_set_mac_age_t *mp;
7452 /* Parse args required to build the message */
7453 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7455 if (unformat (i, "bd_id %d", &bd_id));
7456 else if (unformat (i, "mac-age %d", &mac_age));
7463 errmsg ("missing bridge domain");
7469 errmsg ("mac age must be less than 256 ");
7473 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7475 mp->bd_id = htonl (bd_id);
7476 mp->mac_age = (u8) mac_age;
7484 api_l2_flags (vat_main_t * vam)
7486 unformat_input_t *i = vam->input;
7487 vl_api_l2_flags_t *mp;
7490 u8 sw_if_index_set = 0;
7494 /* Parse args required to build the message */
7495 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7497 if (unformat (i, "sw_if_index %d", &sw_if_index))
7498 sw_if_index_set = 1;
7499 else if (unformat (i, "sw_if"))
7501 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7504 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7505 sw_if_index_set = 1;
7510 else if (unformat (i, "learn"))
7512 else if (unformat (i, "forward"))
7514 else if (unformat (i, "flood"))
7516 else if (unformat (i, "uu-flood"))
7517 flags |= L2_UU_FLOOD;
7518 else if (unformat (i, "arp-term"))
7519 flags |= L2_ARP_TERM;
7520 else if (unformat (i, "off"))
7522 else if (unformat (i, "disable"))
7528 if (sw_if_index_set == 0)
7530 errmsg ("missing interface name or sw_if_index");
7536 mp->sw_if_index = ntohl (sw_if_index);
7537 mp->feature_bitmap = ntohl (flags);
7538 mp->is_set = is_set;
7546 api_bridge_flags (vat_main_t * vam)
7548 unformat_input_t *i = vam->input;
7549 vl_api_bridge_flags_t *mp;
7556 /* Parse args required to build the message */
7557 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7559 if (unformat (i, "bd_id %d", &bd_id))
7561 else if (unformat (i, "learn"))
7563 else if (unformat (i, "forward"))
7565 else if (unformat (i, "flood"))
7567 else if (unformat (i, "uu-flood"))
7568 flags |= L2_UU_FLOOD;
7569 else if (unformat (i, "arp-term"))
7570 flags |= L2_ARP_TERM;
7571 else if (unformat (i, "off"))
7573 else if (unformat (i, "disable"))
7581 errmsg ("missing bridge domain");
7585 M (BRIDGE_FLAGS, mp);
7587 mp->bd_id = ntohl (bd_id);
7588 mp->feature_bitmap = ntohl (flags);
7589 mp->is_set = is_set;
7597 api_bd_ip_mac_add_del (vat_main_t * vam)
7599 unformat_input_t *i = vam->input;
7600 vl_api_bd_ip_mac_add_del_t *mp;
7607 ip4_address_t v4addr;
7608 ip6_address_t v6addr;
7613 /* Parse args required to build the message */
7614 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7616 if (unformat (i, "bd_id %d", &bd_id))
7620 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
7624 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
7629 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
7633 else if (unformat (i, "del"))
7641 errmsg ("missing bridge domain");
7644 else if (ip_set == 0)
7646 errmsg ("missing IP address");
7649 else if (mac_set == 0)
7651 errmsg ("missing MAC address");
7655 M (BD_IP_MAC_ADD_DEL, mp);
7657 mp->bd_id = ntohl (bd_id);
7658 mp->is_ipv6 = is_ipv6;
7659 mp->is_add = is_add;
7661 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
7663 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
7664 clib_memcpy (mp->mac_address, macaddr, 6);
7671 api_tap_connect (vat_main_t * vam)
7673 unformat_input_t *i = vam->input;
7674 vl_api_tap_connect_t *mp;
7680 ip4_address_t ip4_address;
7682 int ip4_address_set = 0;
7683 ip6_address_t ip6_address;
7685 int ip6_address_set = 0;
7688 memset (mac_address, 0, sizeof (mac_address));
7690 /* Parse args required to build the message */
7691 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7693 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7697 else if (unformat (i, "random-mac"))
7699 else if (unformat (i, "tapname %s", &tap_name))
7701 else if (unformat (i, "tag %s", &tag))
7703 else if (unformat (i, "address %U/%d",
7704 unformat_ip4_address, &ip4_address, &ip4_mask_width))
7705 ip4_address_set = 1;
7706 else if (unformat (i, "address %U/%d",
7707 unformat_ip6_address, &ip6_address, &ip6_mask_width))
7708 ip6_address_set = 1;
7715 errmsg ("missing tap name");
7718 if (vec_len (tap_name) > 63)
7720 errmsg ("tap name too long");
7723 vec_add1 (tap_name, 0);
7725 if (vec_len (tag) > 63)
7727 errmsg ("tag too long");
7731 /* Construct the API message */
7732 M (TAP_CONNECT, mp);
7734 mp->use_random_mac = random_mac;
7735 clib_memcpy (mp->mac_address, mac_address, 6);
7736 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7738 clib_memcpy (mp->tag, tag, vec_len (tag));
7740 if (ip4_address_set)
7742 mp->ip4_address_set = 1;
7743 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
7744 mp->ip4_mask_width = ip4_mask_width;
7746 if (ip6_address_set)
7748 mp->ip6_address_set = 1;
7749 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
7750 mp->ip6_mask_width = ip6_mask_width;
7753 vec_free (tap_name);
7759 /* Wait for a reply... */
7765 api_tap_modify (vat_main_t * vam)
7767 unformat_input_t *i = vam->input;
7768 vl_api_tap_modify_t *mp;
7773 u32 sw_if_index = ~0;
7774 u8 sw_if_index_set = 0;
7777 memset (mac_address, 0, sizeof (mac_address));
7779 /* Parse args required to build the message */
7780 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7782 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7783 sw_if_index_set = 1;
7784 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7785 sw_if_index_set = 1;
7786 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7790 else if (unformat (i, "random-mac"))
7792 else if (unformat (i, "tapname %s", &tap_name))
7798 if (sw_if_index_set == 0)
7800 errmsg ("missing vpp interface name");
7805 errmsg ("missing tap name");
7808 if (vec_len (tap_name) > 63)
7810 errmsg ("tap name too long");
7812 vec_add1 (tap_name, 0);
7814 /* Construct the API message */
7817 mp->use_random_mac = random_mac;
7818 mp->sw_if_index = ntohl (sw_if_index);
7819 clib_memcpy (mp->mac_address, mac_address, 6);
7820 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7821 vec_free (tap_name);
7826 /* Wait for a reply... */
7832 api_tap_delete (vat_main_t * vam)
7834 unformat_input_t *i = vam->input;
7835 vl_api_tap_delete_t *mp;
7836 u32 sw_if_index = ~0;
7837 u8 sw_if_index_set = 0;
7840 /* Parse args required to build the message */
7841 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7843 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7844 sw_if_index_set = 1;
7845 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7846 sw_if_index_set = 1;
7851 if (sw_if_index_set == 0)
7853 errmsg ("missing vpp interface name");
7857 /* Construct the API message */
7860 mp->sw_if_index = ntohl (sw_if_index);
7865 /* Wait for a reply... */
7871 api_tap_create_v2 (vat_main_t * vam)
7873 unformat_input_t *i = vam->input;
7874 vl_api_tap_create_v2_t *mp;
7878 u8 *host_if_name = 0;
7880 u8 host_mac_addr[6];
7881 u8 host_mac_addr_set = 0;
7882 u8 *host_bridge = 0;
7883 ip4_address_t host_ip4_addr;
7884 ip4_address_t host_ip4_gw;
7885 u8 host_ip4_gw_set = 0;
7886 u32 host_ip4_prefix_len = 0;
7887 ip6_address_t host_ip6_addr;
7888 ip6_address_t host_ip6_gw;
7889 u8 host_ip6_gw_set = 0;
7890 u32 host_ip6_prefix_len = 0;
7892 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7894 memset (mac_address, 0, sizeof (mac_address));
7896 /* Parse args required to build the message */
7897 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7899 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7903 else if (unformat (i, "id %u", &id))
7905 else if (unformat (i, "host-if-name %s", &host_if_name))
7907 else if (unformat (i, "host-ns %s", &host_ns))
7909 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
7911 host_mac_addr_set = 1;
7912 else if (unformat (i, "host-bridge %s", &host_bridge))
7914 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
7915 &host_ip4_addr, &host_ip4_prefix_len))
7917 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
7918 &host_ip6_addr, &host_ip6_prefix_len))
7920 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
7922 host_ip4_gw_set = 1;
7923 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
7925 host_ip6_gw_set = 1;
7926 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
7928 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
7934 if (vec_len (host_if_name) > 63)
7936 errmsg ("tap name too long. ");
7939 if (vec_len (host_ns) > 63)
7941 errmsg ("host name space too long. ");
7944 if (vec_len (host_bridge) > 63)
7946 errmsg ("host bridge name too long. ");
7949 if (host_ip4_prefix_len > 32)
7951 errmsg ("host ip4 prefix length not valid. ");
7954 if (host_ip6_prefix_len > 128)
7956 errmsg ("host ip6 prefix length not valid. ");
7959 if (!is_pow2 (rx_ring_sz))
7961 errmsg ("rx ring size must be power of 2. ");
7964 if (rx_ring_sz > 32768)
7966 errmsg ("rx ring size must be 32768 or lower. ");
7969 if (!is_pow2 (tx_ring_sz))
7971 errmsg ("tx ring size must be power of 2. ");
7974 if (tx_ring_sz > 32768)
7976 errmsg ("tx ring size must be 32768 or lower. ");
7980 /* Construct the API message */
7981 M (TAP_CREATE_V2, mp);
7983 mp->use_random_mac = random_mac;
7985 mp->id = ntohl (id);
7986 mp->host_namespace_set = host_ns != 0;
7987 mp->host_bridge_set = host_bridge != 0;
7988 mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
7989 mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
7990 mp->rx_ring_sz = ntohs (rx_ring_sz);
7991 mp->tx_ring_sz = ntohs (tx_ring_sz);
7993 if (random_mac == 0)
7994 clib_memcpy (mp->mac_address, mac_address, 6);
7995 if (host_mac_addr_set)
7996 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
7998 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
8000 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
8002 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
8003 if (host_ip4_prefix_len)
8004 clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
8005 if (host_ip4_prefix_len)
8006 clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
8007 if (host_ip4_gw_set)
8008 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
8009 if (host_ip6_gw_set)
8010 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
8013 vec_free (host_if_name);
8014 vec_free (host_bridge);
8019 /* Wait for a reply... */
8025 api_tap_delete_v2 (vat_main_t * vam)
8027 unformat_input_t *i = vam->input;
8028 vl_api_tap_delete_v2_t *mp;
8029 u32 sw_if_index = ~0;
8030 u8 sw_if_index_set = 0;
8033 /* Parse args required to build the message */
8034 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8036 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8037 sw_if_index_set = 1;
8038 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8039 sw_if_index_set = 1;
8044 if (sw_if_index_set == 0)
8046 errmsg ("missing vpp interface name. ");
8050 /* Construct the API message */
8051 M (TAP_DELETE_V2, mp);
8053 mp->sw_if_index = ntohl (sw_if_index);
8058 /* Wait for a reply... */
8064 api_bond_create (vat_main_t * vam)
8066 unformat_input_t *i = vam->input;
8067 vl_api_bond_create_t *mp;
8075 memset (mac_address, 0, sizeof (mac_address));
8078 /* Parse args required to build the message */
8079 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8081 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
8083 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
8084 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
8086 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
8093 if (mode_is_set == 0)
8095 errmsg ("Missing bond mode. ");
8099 /* Construct the API message */
8100 M (BOND_CREATE, mp);
8102 mp->use_custom_mac = custom_mac;
8108 clib_memcpy (mp->mac_address, mac_address, 6);
8113 /* Wait for a reply... */
8119 api_bond_delete (vat_main_t * vam)
8121 unformat_input_t *i = vam->input;
8122 vl_api_bond_delete_t *mp;
8123 u32 sw_if_index = ~0;
8124 u8 sw_if_index_set = 0;
8127 /* Parse args required to build the message */
8128 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8130 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8131 sw_if_index_set = 1;
8132 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8133 sw_if_index_set = 1;
8138 if (sw_if_index_set == 0)
8140 errmsg ("missing vpp interface name. ");
8144 /* Construct the API message */
8145 M (BOND_DELETE, mp);
8147 mp->sw_if_index = ntohl (sw_if_index);
8152 /* Wait for a reply... */
8158 api_bond_enslave (vat_main_t * vam)
8160 unformat_input_t *i = vam->input;
8161 vl_api_bond_enslave_t *mp;
8162 u32 bond_sw_if_index;
8166 u32 bond_sw_if_index_is_set = 0;
8168 u8 sw_if_index_is_set = 0;
8170 /* Parse args required to build the message */
8171 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8173 if (unformat (i, "sw_if_index %d", &sw_if_index))
8174 sw_if_index_is_set = 1;
8175 else if (unformat (i, "bond %u", &bond_sw_if_index))
8176 bond_sw_if_index_is_set = 1;
8177 else if (unformat (i, "passive %d", &is_passive))
8179 else if (unformat (i, "long-timeout %d", &is_long_timeout))
8185 if (bond_sw_if_index_is_set == 0)
8187 errmsg ("Missing bond sw_if_index. ");
8190 if (sw_if_index_is_set == 0)
8192 errmsg ("Missing slave sw_if_index. ");
8196 /* Construct the API message */
8197 M (BOND_ENSLAVE, mp);
8199 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
8200 mp->sw_if_index = ntohl (sw_if_index);
8201 mp->is_long_timeout = is_long_timeout;
8202 mp->is_passive = is_passive;
8207 /* Wait for a reply... */
8213 api_bond_detach_slave (vat_main_t * vam)
8215 unformat_input_t *i = vam->input;
8216 vl_api_bond_detach_slave_t *mp;
8217 u32 sw_if_index = ~0;
8218 u8 sw_if_index_set = 0;
8221 /* Parse args required to build the message */
8222 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8224 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8225 sw_if_index_set = 1;
8226 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8227 sw_if_index_set = 1;
8232 if (sw_if_index_set == 0)
8234 errmsg ("missing vpp interface name. ");
8238 /* Construct the API message */
8239 M (BOND_DETACH_SLAVE, mp);
8241 mp->sw_if_index = ntohl (sw_if_index);
8246 /* Wait for a reply... */
8252 api_ip_table_add_del (vat_main_t * vam)
8254 unformat_input_t *i = vam->input;
8255 vl_api_ip_table_add_del_t *mp;
8261 /* Parse args required to build the message */
8262 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8264 if (unformat (i, "ipv6"))
8266 else if (unformat (i, "del"))
8268 else if (unformat (i, "add"))
8270 else if (unformat (i, "table %d", &table_id))
8274 clib_warning ("parse error '%U'", format_unformat_error, i);
8281 errmsg ("missing table-ID");
8285 /* Construct the API message */
8286 M (IP_TABLE_ADD_DEL, mp);
8288 mp->table_id = ntohl (table_id);
8289 mp->is_ipv6 = is_ipv6;
8290 mp->is_add = is_add;
8295 /* Wait for a reply... */
8302 api_ip_add_del_route (vat_main_t * vam)
8304 unformat_input_t *i = vam->input;
8305 vl_api_ip_add_del_route_t *mp;
8306 u32 sw_if_index = ~0, vrf_id = 0;
8308 u8 is_local = 0, is_drop = 0;
8309 u8 is_unreach = 0, is_prohibit = 0;
8311 u32 next_hop_weight = 1;
8312 u8 is_multipath = 0;
8314 u8 address_length_set = 0;
8315 u32 next_hop_table_id = 0;
8316 u32 resolve_attempts = 0;
8317 u32 dst_address_length = 0;
8318 u8 next_hop_set = 0;
8319 ip4_address_t v4_dst_address, v4_next_hop_address;
8320 ip6_address_t v6_dst_address, v6_next_hop_address;
8324 u32 random_add_del = 0;
8325 u32 *random_vector = 0;
8327 u32 random_seed = 0xdeaddabe;
8328 u32 classify_table_index = ~0;
8330 u8 resolve_host = 0, resolve_attached = 0;
8331 mpls_label_t *next_hop_out_label_stack = NULL;
8332 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8333 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8335 /* Parse args required to build the message */
8336 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8338 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8340 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8342 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
8347 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
8352 else if (unformat (i, "/%d", &dst_address_length))
8354 address_length_set = 1;
8357 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
8358 &v4_next_hop_address))
8362 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
8363 &v6_next_hop_address))
8367 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
8369 else if (unformat (i, "weight %d", &next_hop_weight))
8371 else if (unformat (i, "drop"))
8375 else if (unformat (i, "null-send-unreach"))
8379 else if (unformat (i, "null-send-prohibit"))
8383 else if (unformat (i, "local"))
8387 else if (unformat (i, "classify %d", &classify_table_index))
8391 else if (unformat (i, "del"))
8393 else if (unformat (i, "add"))
8395 else if (unformat (i, "resolve-via-host"))
8397 else if (unformat (i, "resolve-via-attached"))
8398 resolve_attached = 1;
8399 else if (unformat (i, "multipath"))
8401 else if (unformat (i, "vrf %d", &vrf_id))
8403 else if (unformat (i, "count %d", &count))
8405 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
8407 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8409 else if (unformat (i, "out-label %d", &next_hop_out_label))
8410 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
8411 else if (unformat (i, "via-label %d", &next_hop_via_label))
8413 else if (unformat (i, "random"))
8415 else if (unformat (i, "seed %d", &random_seed))
8419 clib_warning ("parse error '%U'", format_unformat_error, i);
8424 if (!next_hop_set && !is_drop && !is_local &&
8425 !is_classify && !is_unreach && !is_prohibit &&
8426 MPLS_LABEL_INVALID == next_hop_via_label)
8429 ("next hop / local / drop / unreach / prohibit / classify not set");
8433 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
8435 errmsg ("next hop and next-hop via label set");
8438 if (address_set == 0)
8440 errmsg ("missing addresses");
8444 if (address_length_set == 0)
8446 errmsg ("missing address length");
8450 /* Generate a pile of unique, random routes */
8453 u32 this_random_address;
8454 random_hash = hash_create (count, sizeof (uword));
8456 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
8457 for (j = 0; j <= count; j++)
8461 this_random_address = random_u32 (&random_seed);
8462 this_random_address =
8463 clib_host_to_net_u32 (this_random_address);
8465 while (hash_get (random_hash, this_random_address));
8466 vec_add1 (random_vector, this_random_address);
8467 hash_set (random_hash, this_random_address, 1);
8469 hash_free (random_hash);
8470 v4_dst_address.as_u32 = random_vector[0];
8475 /* Turn on async mode */
8476 vam->async_mode = 1;
8477 vam->async_errors = 0;
8478 before = vat_time_now (vam);
8481 for (j = 0; j < count; j++)
8483 /* Construct the API message */
8484 M2 (IP_ADD_DEL_ROUTE, mp,
8485 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
8487 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8488 mp->table_id = ntohl (vrf_id);
8490 mp->is_add = is_add;
8491 mp->is_drop = is_drop;
8492 mp->is_unreach = is_unreach;
8493 mp->is_prohibit = is_prohibit;
8494 mp->is_ipv6 = is_ipv6;
8495 mp->is_local = is_local;
8496 mp->is_classify = is_classify;
8497 mp->is_multipath = is_multipath;
8498 mp->is_resolve_host = resolve_host;
8499 mp->is_resolve_attached = resolve_attached;
8500 mp->next_hop_weight = next_hop_weight;
8501 mp->dst_address_length = dst_address_length;
8502 mp->next_hop_table_id = ntohl (next_hop_table_id);
8503 mp->classify_table_index = ntohl (classify_table_index);
8504 mp->next_hop_via_label = ntohl (next_hop_via_label);
8505 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8506 if (0 != mp->next_hop_n_out_labels)
8508 memcpy (mp->next_hop_out_label_stack,
8509 next_hop_out_label_stack,
8510 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
8511 vec_free (next_hop_out_label_stack);
8516 clib_memcpy (mp->dst_address, &v6_dst_address,
8517 sizeof (v6_dst_address));
8519 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
8520 sizeof (v6_next_hop_address));
8521 increment_v6_address (&v6_dst_address);
8525 clib_memcpy (mp->dst_address, &v4_dst_address,
8526 sizeof (v4_dst_address));
8528 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
8529 sizeof (v4_next_hop_address));
8531 v4_dst_address.as_u32 = random_vector[j + 1];
8533 increment_v4_address (&v4_dst_address);
8537 /* If we receive SIGTERM, stop now... */
8542 /* When testing multiple add/del ops, use a control-ping to sync */
8545 vl_api_control_ping_t *mp_ping;
8549 /* Shut off async mode */
8550 vam->async_mode = 0;
8552 MPING (CONTROL_PING, mp_ping);
8555 timeout = vat_time_now (vam) + 1.0;
8556 while (vat_time_now (vam) < timeout)
8557 if (vam->result_ready == 1)
8562 if (vam->retval == -99)
8565 if (vam->async_errors > 0)
8567 errmsg ("%d asynchronous errors", vam->async_errors);
8570 vam->async_errors = 0;
8571 after = vat_time_now (vam);
8573 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8577 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8578 count, after - before, count / (after - before));
8584 /* Wait for a reply... */
8589 /* Return the good/bad news */
8590 return (vam->retval);
8594 api_ip_mroute_add_del (vat_main_t * vam)
8596 unformat_input_t *i = vam->input;
8597 vl_api_ip_mroute_add_del_t *mp;
8598 u32 sw_if_index = ~0, vrf_id = 0;
8603 u32 grp_address_length = 0;
8604 ip4_address_t v4_grp_address, v4_src_address;
8605 ip6_address_t v6_grp_address, v6_src_address;
8606 mfib_itf_flags_t iflags = 0;
8607 mfib_entry_flags_t eflags = 0;
8610 /* Parse args required to build the message */
8611 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8613 if (unformat (i, "sw_if_index %d", &sw_if_index))
8615 else if (unformat (i, "%U %U",
8616 unformat_ip4_address, &v4_src_address,
8617 unformat_ip4_address, &v4_grp_address))
8619 grp_address_length = 64;
8623 else if (unformat (i, "%U %U",
8624 unformat_ip6_address, &v6_src_address,
8625 unformat_ip6_address, &v6_grp_address))
8627 grp_address_length = 256;
8631 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
8633 memset (&v4_src_address, 0, sizeof (v4_src_address));
8634 grp_address_length = 32;
8638 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
8640 memset (&v6_src_address, 0, sizeof (v6_src_address));
8641 grp_address_length = 128;
8645 else if (unformat (i, "/%d", &grp_address_length))
8647 else if (unformat (i, "local"))
8651 else if (unformat (i, "del"))
8653 else if (unformat (i, "add"))
8655 else if (unformat (i, "vrf %d", &vrf_id))
8657 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
8659 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8663 clib_warning ("parse error '%U'", format_unformat_error, i);
8668 if (address_set == 0)
8670 errmsg ("missing addresses\n");
8674 /* Construct the API message */
8675 M (IP_MROUTE_ADD_DEL, mp);
8677 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8678 mp->table_id = ntohl (vrf_id);
8680 mp->is_add = is_add;
8681 mp->is_ipv6 = is_ipv6;
8682 mp->is_local = is_local;
8683 mp->itf_flags = ntohl (iflags);
8684 mp->entry_flags = ntohl (eflags);
8685 mp->grp_address_length = grp_address_length;
8686 mp->grp_address_length = ntohs (mp->grp_address_length);
8690 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
8691 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
8695 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
8696 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
8702 /* Wait for a reply... */
8708 api_mpls_table_add_del (vat_main_t * vam)
8710 unformat_input_t *i = vam->input;
8711 vl_api_mpls_table_add_del_t *mp;
8716 /* Parse args required to build the message */
8717 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8719 if (unformat (i, "table %d", &table_id))
8721 else if (unformat (i, "del"))
8723 else if (unformat (i, "add"))
8727 clib_warning ("parse error '%U'", format_unformat_error, i);
8734 errmsg ("missing table-ID");
8738 /* Construct the API message */
8739 M (MPLS_TABLE_ADD_DEL, mp);
8741 mp->mt_table_id = ntohl (table_id);
8742 mp->mt_is_add = is_add;
8747 /* Wait for a reply... */
8754 api_mpls_route_add_del (vat_main_t * vam)
8756 unformat_input_t *i = vam->input;
8757 vl_api_mpls_route_add_del_t *mp;
8758 u32 sw_if_index = ~0, table_id = 0;
8760 u32 next_hop_weight = 1;
8761 u8 is_multipath = 0;
8762 u32 next_hop_table_id = 0;
8763 u8 next_hop_set = 0;
8764 ip4_address_t v4_next_hop_address = {
8767 ip6_address_t v6_next_hop_address = { {0} };
8771 u32 classify_table_index = ~0;
8773 u8 resolve_host = 0, resolve_attached = 0;
8774 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8775 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8776 mpls_label_t *next_hop_out_label_stack = NULL;
8777 mpls_label_t local_label = MPLS_LABEL_INVALID;
8779 dpo_proto_t next_hop_proto = DPO_PROTO_IP4;
8781 /* Parse args required to build the message */
8782 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8784 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8786 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8788 else if (unformat (i, "%d", &local_label))
8790 else if (unformat (i, "eos"))
8792 else if (unformat (i, "non-eos"))
8794 else if (unformat (i, "via %U", unformat_ip4_address,
8795 &v4_next_hop_address))
8798 next_hop_proto = DPO_PROTO_IP4;
8800 else if (unformat (i, "via %U", unformat_ip6_address,
8801 &v6_next_hop_address))
8804 next_hop_proto = DPO_PROTO_IP6;
8806 else if (unformat (i, "weight %d", &next_hop_weight))
8808 else if (unformat (i, "classify %d", &classify_table_index))
8812 else if (unformat (i, "del"))
8814 else if (unformat (i, "add"))
8816 else if (unformat (i, "resolve-via-host"))
8818 else if (unformat (i, "resolve-via-attached"))
8819 resolve_attached = 1;
8820 else if (unformat (i, "multipath"))
8822 else if (unformat (i, "count %d", &count))
8824 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
8827 next_hop_proto = DPO_PROTO_IP4;
8829 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
8832 next_hop_proto = DPO_PROTO_IP6;
8834 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8836 else if (unformat (i, "via-label %d", &next_hop_via_label))
8838 else if (unformat (i, "out-label %d", &next_hop_out_label))
8839 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
8842 clib_warning ("parse error '%U'", format_unformat_error, i);
8847 if (!next_hop_set && !is_classify)
8849 errmsg ("next hop / classify not set");
8853 if (MPLS_LABEL_INVALID == local_label)
8855 errmsg ("missing label");
8861 /* Turn on async mode */
8862 vam->async_mode = 1;
8863 vam->async_errors = 0;
8864 before = vat_time_now (vam);
8867 for (j = 0; j < count; j++)
8869 /* Construct the API message */
8870 M2 (MPLS_ROUTE_ADD_DEL, mp,
8871 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
8873 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
8874 mp->mr_table_id = ntohl (table_id);
8876 mp->mr_is_add = is_add;
8877 mp->mr_next_hop_proto = next_hop_proto;
8878 mp->mr_is_classify = is_classify;
8879 mp->mr_is_multipath = is_multipath;
8880 mp->mr_is_resolve_host = resolve_host;
8881 mp->mr_is_resolve_attached = resolve_attached;
8882 mp->mr_next_hop_weight = next_hop_weight;
8883 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
8884 mp->mr_classify_table_index = ntohl (classify_table_index);
8885 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
8886 mp->mr_label = ntohl (local_label);
8887 mp->mr_eos = is_eos;
8889 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8890 if (0 != mp->mr_next_hop_n_out_labels)
8892 memcpy (mp->mr_next_hop_out_label_stack,
8893 next_hop_out_label_stack,
8894 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
8895 vec_free (next_hop_out_label_stack);
8900 if (DPO_PROTO_IP4 == next_hop_proto)
8902 clib_memcpy (mp->mr_next_hop,
8903 &v4_next_hop_address,
8904 sizeof (v4_next_hop_address));
8906 else if (DPO_PROTO_IP6 == next_hop_proto)
8909 clib_memcpy (mp->mr_next_hop,
8910 &v6_next_hop_address,
8911 sizeof (v6_next_hop_address));
8918 /* If we receive SIGTERM, stop now... */
8923 /* When testing multiple add/del ops, use a control-ping to sync */
8926 vl_api_control_ping_t *mp_ping;
8930 /* Shut off async mode */
8931 vam->async_mode = 0;
8933 MPING (CONTROL_PING, mp_ping);
8936 timeout = vat_time_now (vam) + 1.0;
8937 while (vat_time_now (vam) < timeout)
8938 if (vam->result_ready == 1)
8943 if (vam->retval == -99)
8946 if (vam->async_errors > 0)
8948 errmsg ("%d asynchronous errors", vam->async_errors);
8951 vam->async_errors = 0;
8952 after = vat_time_now (vam);
8954 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8958 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8959 count, after - before, count / (after - before));
8965 /* Wait for a reply... */
8970 /* Return the good/bad news */
8971 return (vam->retval);
8975 api_mpls_ip_bind_unbind (vat_main_t * vam)
8977 unformat_input_t *i = vam->input;
8978 vl_api_mpls_ip_bind_unbind_t *mp;
8979 u32 ip_table_id = 0;
8982 ip4_address_t v4_address;
8983 ip6_address_t v6_address;
8986 mpls_label_t local_label = MPLS_LABEL_INVALID;
8989 /* Parse args required to build the message */
8990 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8992 if (unformat (i, "%U/%d", unformat_ip4_address,
8993 &v4_address, &address_length))
8998 else if (unformat (i, "%U/%d", unformat_ip6_address,
8999 &v6_address, &address_length))
9004 else if (unformat (i, "%d", &local_label))
9006 else if (unformat (i, "table-id %d", &ip_table_id))
9008 else if (unformat (i, "unbind"))
9010 else if (unformat (i, "bind"))
9014 clib_warning ("parse error '%U'", format_unformat_error, i);
9021 errmsg ("IP addres not set");
9025 if (MPLS_LABEL_INVALID == local_label)
9027 errmsg ("missing label");
9031 /* Construct the API message */
9032 M (MPLS_IP_BIND_UNBIND, mp);
9034 mp->mb_is_bind = is_bind;
9035 mp->mb_is_ip4 = is_ip4;
9036 mp->mb_ip_table_id = ntohl (ip_table_id);
9037 mp->mb_mpls_table_id = 0;
9038 mp->mb_label = ntohl (local_label);
9039 mp->mb_address_length = address_length;
9042 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
9044 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
9049 /* Wait for a reply... */
9055 api_bier_table_add_del (vat_main_t * vam)
9057 unformat_input_t *i = vam->input;
9058 vl_api_bier_table_add_del_t *mp;
9060 u32 set = 0, sub_domain = 0, hdr_len = 3;
9061 mpls_label_t local_label = MPLS_LABEL_INVALID;
9064 /* Parse args required to build the message */
9065 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9067 if (unformat (i, "sub-domain %d", &sub_domain))
9069 else if (unformat (i, "set %d", &set))
9071 else if (unformat (i, "label %d", &local_label))
9073 else if (unformat (i, "hdr-len %d", &hdr_len))
9075 else if (unformat (i, "add"))
9077 else if (unformat (i, "del"))
9081 clib_warning ("parse error '%U'", format_unformat_error, i);
9086 if (MPLS_LABEL_INVALID == local_label)
9088 errmsg ("missing label\n");
9092 /* Construct the API message */
9093 M (BIER_TABLE_ADD_DEL, mp);
9095 mp->bt_is_add = is_add;
9096 mp->bt_label = ntohl (local_label);
9097 mp->bt_tbl_id.bt_set = set;
9098 mp->bt_tbl_id.bt_sub_domain = sub_domain;
9099 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
9104 /* Wait for a reply... */
9111 api_bier_route_add_del (vat_main_t * vam)
9113 unformat_input_t *i = vam->input;
9114 vl_api_bier_route_add_del_t *mp;
9116 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
9117 ip4_address_t v4_next_hop_address;
9118 ip6_address_t v6_next_hop_address;
9119 u8 next_hop_set = 0;
9120 u8 next_hop_proto_is_ip4 = 1;
9121 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9124 /* Parse args required to build the message */
9125 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9127 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
9129 next_hop_proto_is_ip4 = 1;
9132 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
9134 next_hop_proto_is_ip4 = 0;
9137 if (unformat (i, "sub-domain %d", &sub_domain))
9139 else if (unformat (i, "set %d", &set))
9141 else if (unformat (i, "hdr-len %d", &hdr_len))
9143 else if (unformat (i, "bp %d", &bp))
9145 else if (unformat (i, "add"))
9147 else if (unformat (i, "del"))
9149 else if (unformat (i, "out-label %d", &next_hop_out_label))
9153 clib_warning ("parse error '%U'", format_unformat_error, i);
9158 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
9160 errmsg ("next hop / label set\n");
9165 errmsg ("bit=position not set\n");
9169 /* Construct the API message */
9170 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
9172 mp->br_is_add = is_add;
9173 mp->br_tbl_id.bt_set = set;
9174 mp->br_tbl_id.bt_sub_domain = sub_domain;
9175 mp->br_tbl_id.bt_hdr_len_id = hdr_len;
9176 mp->br_bp = ntohs (bp);
9178 mp->br_paths[0].n_labels = 1;
9179 mp->br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
9180 mp->br_paths[0].afi = (next_hop_proto_is_ip4 ? 0 : 1);
9182 if (next_hop_proto_is_ip4)
9184 clib_memcpy (mp->br_paths[0].next_hop,
9185 &v4_next_hop_address, sizeof (v4_next_hop_address));
9189 clib_memcpy (mp->br_paths[0].next_hop,
9190 &v6_next_hop_address, sizeof (v6_next_hop_address));
9196 /* Wait for a reply... */
9203 api_proxy_arp_add_del (vat_main_t * vam)
9205 unformat_input_t *i = vam->input;
9206 vl_api_proxy_arp_add_del_t *mp;
9209 ip4_address_t lo, hi;
9213 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9215 if (unformat (i, "vrf %d", &vrf_id))
9217 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
9218 unformat_ip4_address, &hi))
9220 else if (unformat (i, "del"))
9224 clib_warning ("parse error '%U'", format_unformat_error, i);
9231 errmsg ("address range not set");
9235 M (PROXY_ARP_ADD_DEL, mp);
9237 mp->proxy.vrf_id = ntohl (vrf_id);
9238 mp->is_add = is_add;
9239 clib_memcpy (mp->proxy.low_address, &lo, sizeof (mp->proxy.low_address));
9240 clib_memcpy (mp->proxy.hi_address, &hi, sizeof (mp->proxy.hi_address));
9248 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
9250 unformat_input_t *i = vam->input;
9251 vl_api_proxy_arp_intfc_enable_disable_t *mp;
9254 u8 sw_if_index_set = 0;
9257 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9259 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9260 sw_if_index_set = 1;
9261 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9262 sw_if_index_set = 1;
9263 else if (unformat (i, "enable"))
9265 else if (unformat (i, "disable"))
9269 clib_warning ("parse error '%U'", format_unformat_error, i);
9274 if (sw_if_index_set == 0)
9276 errmsg ("missing interface name or sw_if_index");
9280 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
9282 mp->sw_if_index = ntohl (sw_if_index);
9283 mp->enable_disable = enable;
9291 api_mpls_tunnel_add_del (vat_main_t * vam)
9293 unformat_input_t *i = vam->input;
9294 vl_api_mpls_tunnel_add_del_t *mp;
9298 u32 sw_if_index = ~0;
9299 u32 next_hop_sw_if_index = ~0;
9300 u32 next_hop_proto_is_ip4 = 1;
9302 u32 next_hop_table_id = 0;
9303 ip4_address_t v4_next_hop_address = {
9306 ip6_address_t v6_next_hop_address = { {0} };
9307 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
9310 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9312 if (unformat (i, "add"))
9314 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
9316 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
9318 else if (unformat (i, "via %U",
9319 unformat_ip4_address, &v4_next_hop_address))
9321 next_hop_proto_is_ip4 = 1;
9323 else if (unformat (i, "via %U",
9324 unformat_ip6_address, &v6_next_hop_address))
9326 next_hop_proto_is_ip4 = 0;
9328 else if (unformat (i, "l2-only"))
9330 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
9332 else if (unformat (i, "out-label %d", &next_hop_out_label))
9333 vec_add1 (labels, ntohl (next_hop_out_label));
9336 clib_warning ("parse error '%U'", format_unformat_error, i);
9341 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
9343 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
9344 mp->mt_sw_if_index = ntohl (sw_if_index);
9345 mp->mt_is_add = is_add;
9346 mp->mt_l2_only = l2_only;
9347 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
9348 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
9350 mp->mt_next_hop_n_out_labels = vec_len (labels);
9352 if (0 != mp->mt_next_hop_n_out_labels)
9354 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
9355 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
9359 if (next_hop_proto_is_ip4)
9361 clib_memcpy (mp->mt_next_hop,
9362 &v4_next_hop_address, sizeof (v4_next_hop_address));
9366 clib_memcpy (mp->mt_next_hop,
9367 &v6_next_hop_address, sizeof (v6_next_hop_address));
9376 api_sw_interface_set_unnumbered (vat_main_t * vam)
9378 unformat_input_t *i = vam->input;
9379 vl_api_sw_interface_set_unnumbered_t *mp;
9381 u32 unnum_sw_index = ~0;
9383 u8 sw_if_index_set = 0;
9386 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9388 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9389 sw_if_index_set = 1;
9390 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9391 sw_if_index_set = 1;
9392 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
9394 else if (unformat (i, "del"))
9398 clib_warning ("parse error '%U'", format_unformat_error, i);
9403 if (sw_if_index_set == 0)
9405 errmsg ("missing interface name or sw_if_index");
9409 M (SW_INTERFACE_SET_UNNUMBERED, mp);
9411 mp->sw_if_index = ntohl (sw_if_index);
9412 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
9413 mp->is_add = is_add;
9421 api_ip_neighbor_add_del (vat_main_t * vam)
9423 unformat_input_t *i = vam->input;
9424 vl_api_ip_neighbor_add_del_t *mp;
9426 u8 sw_if_index_set = 0;
9429 u8 is_no_fib_entry = 0;
9432 u8 v4_address_set = 0;
9433 u8 v6_address_set = 0;
9434 ip4_address_t v4address;
9435 ip6_address_t v6address;
9438 memset (mac_address, 0, sizeof (mac_address));
9440 /* Parse args required to build the message */
9441 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9443 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
9447 else if (unformat (i, "del"))
9450 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9451 sw_if_index_set = 1;
9452 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9453 sw_if_index_set = 1;
9454 else if (unformat (i, "is_static"))
9456 else if (unformat (i, "no-fib-entry"))
9457 is_no_fib_entry = 1;
9458 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
9460 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
9464 clib_warning ("parse error '%U'", format_unformat_error, i);
9469 if (sw_if_index_set == 0)
9471 errmsg ("missing interface name or sw_if_index");
9474 if (v4_address_set && v6_address_set)
9476 errmsg ("both v4 and v6 addresses set");
9479 if (!v4_address_set && !v6_address_set)
9481 errmsg ("no address set");
9485 /* Construct the API message */
9486 M (IP_NEIGHBOR_ADD_DEL, mp);
9488 mp->sw_if_index = ntohl (sw_if_index);
9489 mp->is_add = is_add;
9490 mp->is_static = is_static;
9491 mp->is_no_adj_fib = is_no_fib_entry;
9493 clib_memcpy (mp->mac_address, mac_address, 6);
9497 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
9501 /* mp->is_ipv6 = 0; via memset in M macro above */
9502 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
9508 /* Wait for a reply, return good/bad news */
9514 api_create_vlan_subif (vat_main_t * vam)
9516 unformat_input_t *i = vam->input;
9517 vl_api_create_vlan_subif_t *mp;
9519 u8 sw_if_index_set = 0;
9524 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9526 if (unformat (i, "sw_if_index %d", &sw_if_index))
9527 sw_if_index_set = 1;
9529 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9530 sw_if_index_set = 1;
9531 else if (unformat (i, "vlan %d", &vlan_id))
9535 clib_warning ("parse error '%U'", format_unformat_error, i);
9540 if (sw_if_index_set == 0)
9542 errmsg ("missing interface name or sw_if_index");
9546 if (vlan_id_set == 0)
9548 errmsg ("missing vlan_id");
9551 M (CREATE_VLAN_SUBIF, mp);
9553 mp->sw_if_index = ntohl (sw_if_index);
9554 mp->vlan_id = ntohl (vlan_id);
9561 #define foreach_create_subif_bit \
9568 _(outer_vlan_id_any) \
9569 _(inner_vlan_id_any)
9572 api_create_subif (vat_main_t * vam)
9574 unformat_input_t *i = vam->input;
9575 vl_api_create_subif_t *mp;
9577 u8 sw_if_index_set = 0;
9584 u32 exact_match = 0;
9585 u32 default_sub = 0;
9586 u32 outer_vlan_id_any = 0;
9587 u32 inner_vlan_id_any = 0;
9589 u16 outer_vlan_id = 0;
9590 u16 inner_vlan_id = 0;
9593 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9595 if (unformat (i, "sw_if_index %d", &sw_if_index))
9596 sw_if_index_set = 1;
9598 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9599 sw_if_index_set = 1;
9600 else if (unformat (i, "sub_id %d", &sub_id))
9602 else if (unformat (i, "outer_vlan_id %d", &tmp))
9603 outer_vlan_id = tmp;
9604 else if (unformat (i, "inner_vlan_id %d", &tmp))
9605 inner_vlan_id = tmp;
9607 #define _(a) else if (unformat (i, #a)) a = 1 ;
9608 foreach_create_subif_bit
9612 clib_warning ("parse error '%U'", format_unformat_error, i);
9617 if (sw_if_index_set == 0)
9619 errmsg ("missing interface name or sw_if_index");
9623 if (sub_id_set == 0)
9625 errmsg ("missing sub_id");
9628 M (CREATE_SUBIF, mp);
9630 mp->sw_if_index = ntohl (sw_if_index);
9631 mp->sub_id = ntohl (sub_id);
9633 #define _(a) mp->a = a;
9634 foreach_create_subif_bit;
9637 mp->outer_vlan_id = ntohs (outer_vlan_id);
9638 mp->inner_vlan_id = ntohs (inner_vlan_id);
9646 api_oam_add_del (vat_main_t * vam)
9648 unformat_input_t *i = vam->input;
9649 vl_api_oam_add_del_t *mp;
9652 ip4_address_t src, dst;
9657 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9659 if (unformat (i, "vrf %d", &vrf_id))
9661 else if (unformat (i, "src %U", unformat_ip4_address, &src))
9663 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
9665 else if (unformat (i, "del"))
9669 clib_warning ("parse error '%U'", format_unformat_error, i);
9676 errmsg ("missing src addr");
9682 errmsg ("missing dst addr");
9686 M (OAM_ADD_DEL, mp);
9688 mp->vrf_id = ntohl (vrf_id);
9689 mp->is_add = is_add;
9690 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
9691 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
9699 api_reset_fib (vat_main_t * vam)
9701 unformat_input_t *i = vam->input;
9702 vl_api_reset_fib_t *mp;
9708 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9710 if (unformat (i, "vrf %d", &vrf_id))
9712 else if (unformat (i, "ipv6"))
9716 clib_warning ("parse error '%U'", format_unformat_error, i);
9721 if (vrf_id_set == 0)
9723 errmsg ("missing vrf id");
9729 mp->vrf_id = ntohl (vrf_id);
9730 mp->is_ipv6 = is_ipv6;
9738 api_dhcp_proxy_config (vat_main_t * vam)
9740 unformat_input_t *i = vam->input;
9741 vl_api_dhcp_proxy_config_t *mp;
9743 u32 server_vrf_id = 0;
9745 u8 v4_address_set = 0;
9746 u8 v6_address_set = 0;
9747 ip4_address_t v4address;
9748 ip6_address_t v6address;
9749 u8 v4_src_address_set = 0;
9750 u8 v6_src_address_set = 0;
9751 ip4_address_t v4srcaddress;
9752 ip6_address_t v6srcaddress;
9755 /* Parse args required to build the message */
9756 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9758 if (unformat (i, "del"))
9760 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
9762 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
9764 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
9766 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
9768 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
9769 v4_src_address_set = 1;
9770 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
9771 v6_src_address_set = 1;
9776 if (v4_address_set && v6_address_set)
9778 errmsg ("both v4 and v6 server addresses set");
9781 if (!v4_address_set && !v6_address_set)
9783 errmsg ("no server addresses set");
9787 if (v4_src_address_set && v6_src_address_set)
9789 errmsg ("both v4 and v6 src addresses set");
9792 if (!v4_src_address_set && !v6_src_address_set)
9794 errmsg ("no src addresses set");
9798 if (!(v4_src_address_set && v4_address_set) &&
9799 !(v6_src_address_set && v6_address_set))
9801 errmsg ("no matching server and src addresses set");
9805 /* Construct the API message */
9806 M (DHCP_PROXY_CONFIG, mp);
9808 mp->is_add = is_add;
9809 mp->rx_vrf_id = ntohl (rx_vrf_id);
9810 mp->server_vrf_id = ntohl (server_vrf_id);
9814 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
9815 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
9819 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
9820 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
9826 /* Wait for a reply, return good/bad news */
9831 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
9832 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
9835 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
9837 vat_main_t *vam = &vat_main;
9838 u32 i, count = mp->count;
9839 vl_api_dhcp_server_t *s;
9843 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9844 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9845 ntohl (mp->rx_vrf_id),
9846 format_ip6_address, mp->dhcp_src_address,
9847 mp->vss_type, mp->vss_vpn_ascii_id,
9848 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9851 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9852 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9853 ntohl (mp->rx_vrf_id),
9854 format_ip4_address, mp->dhcp_src_address,
9855 mp->vss_type, mp->vss_vpn_ascii_id,
9856 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9858 for (i = 0; i < count; i++)
9860 s = &mp->servers[i];
9864 " Server Table-ID %d, Server Address %U",
9865 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
9868 " Server Table-ID %d, Server Address %U",
9869 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
9873 static void vl_api_dhcp_proxy_details_t_handler_json
9874 (vl_api_dhcp_proxy_details_t * mp)
9876 vat_main_t *vam = &vat_main;
9877 vat_json_node_t *node = NULL;
9878 u32 i, count = mp->count;
9880 struct in6_addr ip6;
9881 vl_api_dhcp_server_t *s;
9883 if (VAT_JSON_ARRAY != vam->json_tree.type)
9885 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9886 vat_json_init_array (&vam->json_tree);
9888 node = vat_json_array_add (&vam->json_tree);
9890 vat_json_init_object (node);
9891 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
9892 vat_json_object_add_bytes (node, "vss-type", &mp->vss_type,
9893 sizeof (mp->vss_type));
9894 vat_json_object_add_string_copy (node, "vss-vpn-ascii-id",
9895 mp->vss_vpn_ascii_id);
9896 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
9897 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
9901 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
9902 vat_json_object_add_ip6 (node, "src_address", ip6);
9906 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
9907 vat_json_object_add_ip4 (node, "src_address", ip4);
9910 for (i = 0; i < count; i++)
9912 s = &mp->servers[i];
9914 vat_json_object_add_uint (node, "server-table-id",
9915 ntohl (s->server_vrf_id));
9919 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
9920 vat_json_object_add_ip4 (node, "src_address", ip4);
9924 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
9925 vat_json_object_add_ip6 (node, "server_address", ip6);
9931 api_dhcp_proxy_dump (vat_main_t * vam)
9933 unformat_input_t *i = vam->input;
9934 vl_api_control_ping_t *mp_ping;
9935 vl_api_dhcp_proxy_dump_t *mp;
9939 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9941 if (unformat (i, "ipv6"))
9945 clib_warning ("parse error '%U'", format_unformat_error, i);
9950 M (DHCP_PROXY_DUMP, mp);
9952 mp->is_ip6 = is_ipv6;
9955 /* Use a control ping for synchronization */
9956 MPING (CONTROL_PING, mp_ping);
9964 api_dhcp_proxy_set_vss (vat_main_t * vam)
9966 unformat_input_t *i = vam->input;
9967 vl_api_dhcp_proxy_set_vss_t *mp;
9971 u8 vss_type = VSS_TYPE_DEFAULT;
9972 u8 *vpn_ascii_id = 0;
9977 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9979 if (unformat (i, "tbl_id %d", &tbl_id))
9981 else if (unformat (i, "vpn_ascii_id %s", &vpn_ascii_id))
9982 vss_type = VSS_TYPE_ASCII;
9983 else if (unformat (i, "fib_id %d", &fib_id))
9984 vss_type = VSS_TYPE_VPN_ID;
9985 else if (unformat (i, "oui %d", &oui))
9986 vss_type = VSS_TYPE_VPN_ID;
9987 else if (unformat (i, "ipv6"))
9989 else if (unformat (i, "del"))
9997 errmsg ("missing tbl_id ");
9998 vec_free (vpn_ascii_id);
10002 if ((vpn_ascii_id) && (vec_len (vpn_ascii_id) > 128))
10004 errmsg ("vpn_ascii_id cannot be longer than 128 ");
10005 vec_free (vpn_ascii_id);
10009 M (DHCP_PROXY_SET_VSS, mp);
10010 mp->tbl_id = ntohl (tbl_id);
10011 mp->vss_type = vss_type;
10014 clib_memcpy (mp->vpn_ascii_id, vpn_ascii_id, vec_len (vpn_ascii_id));
10015 mp->vpn_ascii_id[vec_len (vpn_ascii_id)] = 0;
10017 mp->vpn_index = ntohl (fib_id);
10018 mp->oui = ntohl (oui);
10019 mp->is_ipv6 = is_ipv6;
10020 mp->is_add = is_add;
10025 vec_free (vpn_ascii_id);
10030 api_dhcp_client_config (vat_main_t * vam)
10032 unformat_input_t *i = vam->input;
10033 vl_api_dhcp_client_config_t *mp;
10035 u8 sw_if_index_set = 0;
10038 u8 disable_event = 0;
10041 /* Parse args required to build the message */
10042 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10044 if (unformat (i, "del"))
10047 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10048 sw_if_index_set = 1;
10049 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10050 sw_if_index_set = 1;
10051 else if (unformat (i, "hostname %s", &hostname))
10053 else if (unformat (i, "disable_event"))
10059 if (sw_if_index_set == 0)
10061 errmsg ("missing interface name or sw_if_index");
10065 if (vec_len (hostname) > 63)
10067 errmsg ("hostname too long");
10069 vec_add1 (hostname, 0);
10071 /* Construct the API message */
10072 M (DHCP_CLIENT_CONFIG, mp);
10074 mp->is_add = is_add;
10075 mp->client.sw_if_index = htonl (sw_if_index);
10076 clib_memcpy (mp->client.hostname, hostname, vec_len (hostname));
10077 vec_free (hostname);
10078 mp->client.want_dhcp_event = disable_event ? 0 : 1;
10079 mp->client.pid = htonl (getpid ());
10084 /* Wait for a reply, return good/bad news */
10090 api_set_ip_flow_hash (vat_main_t * vam)
10092 unformat_input_t *i = vam->input;
10093 vl_api_set_ip_flow_hash_t *mp;
10105 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10107 if (unformat (i, "vrf %d", &vrf_id))
10109 else if (unformat (i, "ipv6"))
10111 else if (unformat (i, "src"))
10113 else if (unformat (i, "dst"))
10115 else if (unformat (i, "sport"))
10117 else if (unformat (i, "dport"))
10119 else if (unformat (i, "proto"))
10121 else if (unformat (i, "reverse"))
10126 clib_warning ("parse error '%U'", format_unformat_error, i);
10131 if (vrf_id_set == 0)
10133 errmsg ("missing vrf id");
10137 M (SET_IP_FLOW_HASH, mp);
10143 mp->reverse = reverse;
10144 mp->vrf_id = ntohl (vrf_id);
10145 mp->is_ipv6 = is_ipv6;
10153 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
10155 unformat_input_t *i = vam->input;
10156 vl_api_sw_interface_ip6_enable_disable_t *mp;
10158 u8 sw_if_index_set = 0;
10162 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10164 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10165 sw_if_index_set = 1;
10166 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10167 sw_if_index_set = 1;
10168 else if (unformat (i, "enable"))
10170 else if (unformat (i, "disable"))
10174 clib_warning ("parse error '%U'", format_unformat_error, i);
10179 if (sw_if_index_set == 0)
10181 errmsg ("missing interface name or sw_if_index");
10185 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
10187 mp->sw_if_index = ntohl (sw_if_index);
10188 mp->enable = enable;
10196 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
10198 unformat_input_t *i = vam->input;
10199 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
10201 u8 sw_if_index_set = 0;
10202 u8 v6_address_set = 0;
10203 ip6_address_t v6address;
10206 /* Parse args required to build the message */
10207 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10209 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10210 sw_if_index_set = 1;
10211 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10212 sw_if_index_set = 1;
10213 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10214 v6_address_set = 1;
10219 if (sw_if_index_set == 0)
10221 errmsg ("missing interface name or sw_if_index");
10224 if (!v6_address_set)
10226 errmsg ("no address set");
10230 /* Construct the API message */
10231 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
10233 mp->sw_if_index = ntohl (sw_if_index);
10234 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10239 /* Wait for a reply, return good/bad news */
10245 api_ip6nd_proxy_add_del (vat_main_t * vam)
10247 unformat_input_t *i = vam->input;
10248 vl_api_ip6nd_proxy_add_del_t *mp;
10249 u32 sw_if_index = ~0;
10250 u8 v6_address_set = 0;
10251 ip6_address_t v6address;
10255 /* Parse args required to build the message */
10256 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10258 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10260 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10262 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10263 v6_address_set = 1;
10264 if (unformat (i, "del"))
10268 clib_warning ("parse error '%U'", format_unformat_error, i);
10273 if (sw_if_index == ~0)
10275 errmsg ("missing interface name or sw_if_index");
10278 if (!v6_address_set)
10280 errmsg ("no address set");
10284 /* Construct the API message */
10285 M (IP6ND_PROXY_ADD_DEL, mp);
10287 mp->is_del = is_del;
10288 mp->sw_if_index = ntohl (sw_if_index);
10289 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10294 /* Wait for a reply, return good/bad news */
10300 api_ip6nd_proxy_dump (vat_main_t * vam)
10302 vl_api_ip6nd_proxy_dump_t *mp;
10303 vl_api_control_ping_t *mp_ping;
10306 M (IP6ND_PROXY_DUMP, mp);
10310 /* Use a control ping for synchronization */
10311 MPING (CONTROL_PING, mp_ping);
10318 static void vl_api_ip6nd_proxy_details_t_handler
10319 (vl_api_ip6nd_proxy_details_t * mp)
10321 vat_main_t *vam = &vat_main;
10323 print (vam->ofp, "host %U sw_if_index %d",
10324 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
10327 static void vl_api_ip6nd_proxy_details_t_handler_json
10328 (vl_api_ip6nd_proxy_details_t * mp)
10330 vat_main_t *vam = &vat_main;
10331 struct in6_addr ip6;
10332 vat_json_node_t *node = NULL;
10334 if (VAT_JSON_ARRAY != vam->json_tree.type)
10336 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10337 vat_json_init_array (&vam->json_tree);
10339 node = vat_json_array_add (&vam->json_tree);
10341 vat_json_init_object (node);
10342 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10344 clib_memcpy (&ip6, mp->address, sizeof (ip6));
10345 vat_json_object_add_ip6 (node, "host", ip6);
10349 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
10351 unformat_input_t *i = vam->input;
10352 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
10354 u8 sw_if_index_set = 0;
10355 u32 address_length = 0;
10356 u8 v6_address_set = 0;
10357 ip6_address_t v6address;
10358 u8 use_default = 0;
10359 u8 no_advertise = 0;
10361 u8 no_autoconfig = 0;
10364 u32 val_lifetime = 0;
10365 u32 pref_lifetime = 0;
10368 /* Parse args required to build the message */
10369 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10371 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10372 sw_if_index_set = 1;
10373 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10374 sw_if_index_set = 1;
10375 else if (unformat (i, "%U/%d",
10376 unformat_ip6_address, &v6address, &address_length))
10377 v6_address_set = 1;
10378 else if (unformat (i, "val_life %d", &val_lifetime))
10380 else if (unformat (i, "pref_life %d", &pref_lifetime))
10382 else if (unformat (i, "def"))
10384 else if (unformat (i, "noadv"))
10386 else if (unformat (i, "offl"))
10388 else if (unformat (i, "noauto"))
10390 else if (unformat (i, "nolink"))
10392 else if (unformat (i, "isno"))
10396 clib_warning ("parse error '%U'", format_unformat_error, i);
10401 if (sw_if_index_set == 0)
10403 errmsg ("missing interface name or sw_if_index");
10406 if (!v6_address_set)
10408 errmsg ("no address set");
10412 /* Construct the API message */
10413 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
10415 mp->sw_if_index = ntohl (sw_if_index);
10416 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10417 mp->address_length = address_length;
10418 mp->use_default = use_default;
10419 mp->no_advertise = no_advertise;
10420 mp->off_link = off_link;
10421 mp->no_autoconfig = no_autoconfig;
10422 mp->no_onlink = no_onlink;
10424 mp->val_lifetime = ntohl (val_lifetime);
10425 mp->pref_lifetime = ntohl (pref_lifetime);
10430 /* Wait for a reply, return good/bad news */
10436 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
10438 unformat_input_t *i = vam->input;
10439 vl_api_sw_interface_ip6nd_ra_config_t *mp;
10441 u8 sw_if_index_set = 0;
10446 u8 send_unicast = 0;
10449 u8 default_router = 0;
10450 u32 max_interval = 0;
10451 u32 min_interval = 0;
10453 u32 initial_count = 0;
10454 u32 initial_interval = 0;
10458 /* Parse args required to build the message */
10459 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10461 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10462 sw_if_index_set = 1;
10463 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10464 sw_if_index_set = 1;
10465 else if (unformat (i, "maxint %d", &max_interval))
10467 else if (unformat (i, "minint %d", &min_interval))
10469 else if (unformat (i, "life %d", &lifetime))
10471 else if (unformat (i, "count %d", &initial_count))
10473 else if (unformat (i, "interval %d", &initial_interval))
10475 else if (unformat (i, "suppress") || unformat (i, "surpress"))
10477 else if (unformat (i, "managed"))
10479 else if (unformat (i, "other"))
10481 else if (unformat (i, "ll"))
10483 else if (unformat (i, "send"))
10485 else if (unformat (i, "cease"))
10487 else if (unformat (i, "isno"))
10489 else if (unformat (i, "def"))
10490 default_router = 1;
10493 clib_warning ("parse error '%U'", format_unformat_error, i);
10498 if (sw_if_index_set == 0)
10500 errmsg ("missing interface name or sw_if_index");
10504 /* Construct the API message */
10505 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
10507 mp->sw_if_index = ntohl (sw_if_index);
10508 mp->max_interval = ntohl (max_interval);
10509 mp->min_interval = ntohl (min_interval);
10510 mp->lifetime = ntohl (lifetime);
10511 mp->initial_count = ntohl (initial_count);
10512 mp->initial_interval = ntohl (initial_interval);
10513 mp->suppress = suppress;
10514 mp->managed = managed;
10516 mp->ll_option = ll_option;
10517 mp->send_unicast = send_unicast;
10520 mp->default_router = default_router;
10525 /* Wait for a reply, return good/bad news */
10531 api_set_arp_neighbor_limit (vat_main_t * vam)
10533 unformat_input_t *i = vam->input;
10534 vl_api_set_arp_neighbor_limit_t *mp;
10540 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10542 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
10544 else if (unformat (i, "ipv6"))
10548 clib_warning ("parse error '%U'", format_unformat_error, i);
10553 if (limit_set == 0)
10555 errmsg ("missing limit value");
10559 M (SET_ARP_NEIGHBOR_LIMIT, mp);
10561 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
10562 mp->is_ipv6 = is_ipv6;
10570 api_l2_patch_add_del (vat_main_t * vam)
10572 unformat_input_t *i = vam->input;
10573 vl_api_l2_patch_add_del_t *mp;
10574 u32 rx_sw_if_index;
10575 u8 rx_sw_if_index_set = 0;
10576 u32 tx_sw_if_index;
10577 u8 tx_sw_if_index_set = 0;
10581 /* Parse args required to build the message */
10582 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10584 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
10585 rx_sw_if_index_set = 1;
10586 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
10587 tx_sw_if_index_set = 1;
10588 else if (unformat (i, "rx"))
10590 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10592 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10594 rx_sw_if_index_set = 1;
10599 else if (unformat (i, "tx"))
10601 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10603 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10605 tx_sw_if_index_set = 1;
10610 else if (unformat (i, "del"))
10616 if (rx_sw_if_index_set == 0)
10618 errmsg ("missing rx interface name or rx_sw_if_index");
10622 if (tx_sw_if_index_set == 0)
10624 errmsg ("missing tx interface name or tx_sw_if_index");
10628 M (L2_PATCH_ADD_DEL, mp);
10630 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
10631 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
10632 mp->is_add = is_add;
10640 u8 localsid_addr[16];
10649 api_sr_localsid_add_del (vat_main_t * vam)
10651 unformat_input_t *i = vam->input;
10652 vl_api_sr_localsid_add_del_t *mp;
10655 ip6_address_t localsid;
10659 u32 fib_table = ~(u32) 0;
10660 ip6_address_t nh_addr6;
10661 ip4_address_t nh_addr4;
10662 memset (&nh_addr6, 0, sizeof (ip6_address_t));
10663 memset (&nh_addr4, 0, sizeof (ip4_address_t));
10665 bool nexthop_set = 0;
10669 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10671 if (unformat (i, "del"))
10673 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
10674 else if (unformat (i, "next-hop %U", unformat_ip4_address, &nh_addr4))
10676 else if (unformat (i, "next-hop %U", unformat_ip6_address, &nh_addr6))
10678 else if (unformat (i, "behavior %u", &behavior));
10679 else if (unformat (i, "sw_if_index %u", &sw_if_index));
10680 else if (unformat (i, "fib-table %u", &fib_table));
10681 else if (unformat (i, "end.psp %u", &behavior));
10686 M (SR_LOCALSID_ADD_DEL, mp);
10688 clib_memcpy (mp->localsid.addr, &localsid, sizeof (mp->localsid));
10691 clib_memcpy (mp->nh_addr6, &nh_addr4, sizeof (mp->nh_addr6));
10692 clib_memcpy (mp->nh_addr4, &nh_addr6, sizeof (mp->nh_addr4));
10694 mp->behavior = behavior;
10695 mp->sw_if_index = ntohl (sw_if_index);
10696 mp->fib_table = ntohl (fib_table);
10697 mp->end_psp = end_psp;
10698 mp->is_del = is_del;
10706 api_ioam_enable (vat_main_t * vam)
10708 unformat_input_t *input = vam->input;
10709 vl_api_ioam_enable_t *mp;
10711 int has_trace_option = 0;
10712 int has_pot_option = 0;
10713 int has_seqno_option = 0;
10714 int has_analyse_option = 0;
10717 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10719 if (unformat (input, "trace"))
10720 has_trace_option = 1;
10721 else if (unformat (input, "pot"))
10722 has_pot_option = 1;
10723 else if (unformat (input, "seqno"))
10724 has_seqno_option = 1;
10725 else if (unformat (input, "analyse"))
10726 has_analyse_option = 1;
10730 M (IOAM_ENABLE, mp);
10731 mp->id = htons (id);
10732 mp->seqno = has_seqno_option;
10733 mp->analyse = has_analyse_option;
10734 mp->pot_enable = has_pot_option;
10735 mp->trace_enable = has_trace_option;
10744 api_ioam_disable (vat_main_t * vam)
10746 vl_api_ioam_disable_t *mp;
10749 M (IOAM_DISABLE, mp);
10755 #define foreach_tcp_proto_field \
10759 #define foreach_udp_proto_field \
10763 #define foreach_ip4_proto_field \
10775 u16 src_port, dst_port;
10778 #if VPP_API_TEST_BUILTIN == 0
10780 unformat_tcp_mask (unformat_input_t * input, va_list * args)
10782 u8 **maskp = va_arg (*args, u8 **);
10784 u8 found_something = 0;
10787 #define _(a) u8 a=0;
10788 foreach_tcp_proto_field;
10791 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10794 #define _(a) else if (unformat (input, #a)) a=1;
10795 foreach_tcp_proto_field
10801 #define _(a) found_something += a;
10802 foreach_tcp_proto_field;
10805 if (found_something == 0)
10808 vec_validate (mask, sizeof (*tcp) - 1);
10810 tcp = (tcp_header_t *) mask;
10812 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
10813 foreach_tcp_proto_field;
10821 unformat_udp_mask (unformat_input_t * input, va_list * args)
10823 u8 **maskp = va_arg (*args, u8 **);
10825 u8 found_something = 0;
10828 #define _(a) u8 a=0;
10829 foreach_udp_proto_field;
10832 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10835 #define _(a) else if (unformat (input, #a)) a=1;
10836 foreach_udp_proto_field
10842 #define _(a) found_something += a;
10843 foreach_udp_proto_field;
10846 if (found_something == 0)
10849 vec_validate (mask, sizeof (*udp) - 1);
10851 udp = (udp_header_t *) mask;
10853 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
10854 foreach_udp_proto_field;
10862 unformat_l4_mask (unformat_input_t * input, va_list * args)
10864 u8 **maskp = va_arg (*args, u8 **);
10865 u16 src_port = 0, dst_port = 0;
10866 tcpudp_header_t *tcpudp;
10868 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10870 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
10872 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
10874 else if (unformat (input, "src_port"))
10876 else if (unformat (input, "dst_port"))
10882 if (!src_port && !dst_port)
10886 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
10888 tcpudp = (tcpudp_header_t *) mask;
10889 tcpudp->src_port = src_port;
10890 tcpudp->dst_port = dst_port;
10898 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10900 u8 **maskp = va_arg (*args, u8 **);
10902 u8 found_something = 0;
10905 #define _(a) u8 a=0;
10906 foreach_ip4_proto_field;
10912 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10914 if (unformat (input, "version"))
10916 else if (unformat (input, "hdr_length"))
10918 else if (unformat (input, "src"))
10920 else if (unformat (input, "dst"))
10922 else if (unformat (input, "proto"))
10925 #define _(a) else if (unformat (input, #a)) a=1;
10926 foreach_ip4_proto_field
10932 #define _(a) found_something += a;
10933 foreach_ip4_proto_field;
10936 if (found_something == 0)
10939 vec_validate (mask, sizeof (*ip) - 1);
10941 ip = (ip4_header_t *) mask;
10943 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
10944 foreach_ip4_proto_field;
10947 ip->ip_version_and_header_length = 0;
10950 ip->ip_version_and_header_length |= 0xF0;
10953 ip->ip_version_and_header_length |= 0x0F;
10959 #define foreach_ip6_proto_field \
10962 _(payload_length) \
10967 unformat_ip6_mask (unformat_input_t * input, va_list * args)
10969 u8 **maskp = va_arg (*args, u8 **);
10971 u8 found_something = 0;
10973 u32 ip_version_traffic_class_and_flow_label;
10975 #define _(a) u8 a=0;
10976 foreach_ip6_proto_field;
10979 u8 traffic_class = 0;
10982 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10984 if (unformat (input, "version"))
10986 else if (unformat (input, "traffic-class"))
10988 else if (unformat (input, "flow-label"))
10990 else if (unformat (input, "src"))
10992 else if (unformat (input, "dst"))
10994 else if (unformat (input, "proto"))
10997 #define _(a) else if (unformat (input, #a)) a=1;
10998 foreach_ip6_proto_field
11004 #define _(a) found_something += a;
11005 foreach_ip6_proto_field;
11008 if (found_something == 0)
11011 vec_validate (mask, sizeof (*ip) - 1);
11013 ip = (ip6_header_t *) mask;
11015 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
11016 foreach_ip6_proto_field;
11019 ip_version_traffic_class_and_flow_label = 0;
11022 ip_version_traffic_class_and_flow_label |= 0xF0000000;
11025 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
11028 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
11030 ip->ip_version_traffic_class_and_flow_label =
11031 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11038 unformat_l3_mask (unformat_input_t * input, va_list * args)
11040 u8 **maskp = va_arg (*args, u8 **);
11042 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11044 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
11046 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
11055 unformat_l2_mask (unformat_input_t * input, va_list * args)
11057 u8 **maskp = va_arg (*args, u8 **);
11064 u8 ignore_tag1 = 0;
11065 u8 ignore_tag2 = 0;
11072 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11074 if (unformat (input, "src"))
11076 else if (unformat (input, "dst"))
11078 else if (unformat (input, "proto"))
11080 else if (unformat (input, "tag1"))
11082 else if (unformat (input, "tag2"))
11084 else if (unformat (input, "ignore-tag1"))
11086 else if (unformat (input, "ignore-tag2"))
11088 else if (unformat (input, "cos1"))
11090 else if (unformat (input, "cos2"))
11092 else if (unformat (input, "dot1q"))
11094 else if (unformat (input, "dot1ad"))
11099 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
11100 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11103 if (tag1 || ignore_tag1 || cos1 || dot1q)
11105 if (tag2 || ignore_tag2 || cos2 || dot1ad)
11108 vec_validate (mask, len - 1);
11111 memset (mask, 0xff, 6);
11114 memset (mask + 6, 0xff, 6);
11116 if (tag2 || dot1ad)
11118 /* inner vlan tag */
11127 mask[21] = mask[20] = 0xff;
11148 mask[16] = mask[17] = 0xff;
11158 mask[12] = mask[13] = 0xff;
11165 unformat_classify_mask (unformat_input_t * input, va_list * args)
11167 u8 **maskp = va_arg (*args, u8 **);
11168 u32 *skipp = va_arg (*args, u32 *);
11169 u32 *matchp = va_arg (*args, u32 *);
11177 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11179 if (unformat (input, "hex %U", unformat_hex_string, &mask))
11181 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
11183 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
11185 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
11199 if (mask || l2 || l3 || l4)
11201 if (l2 || l3 || l4)
11203 /* "With a free Ethernet header in every package" */
11205 vec_validate (l2, 13);
11209 vec_append (mask, l3);
11214 vec_append (mask, l4);
11219 /* Scan forward looking for the first significant mask octet */
11220 for (i = 0; i < vec_len (mask); i++)
11224 /* compute (skip, match) params */
11225 *skipp = i / sizeof (u32x4);
11226 vec_delete (mask, *skipp * sizeof (u32x4), 0);
11228 /* Pad mask to an even multiple of the vector size */
11229 while (vec_len (mask) % sizeof (u32x4))
11230 vec_add1 (mask, 0);
11232 match = vec_len (mask) / sizeof (u32x4);
11234 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
11236 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
11237 if (*tmp || *(tmp + 1))
11242 clib_warning ("BUG: match 0");
11244 _vec_len (mask) = match * sizeof (u32x4);
11254 #endif /* VPP_API_TEST_BUILTIN */
11256 #define foreach_l2_next \
11258 _(ethernet, ETHERNET_INPUT) \
11259 _(ip4, IP4_INPUT) \
11263 unformat_l2_next_index (unformat_input_t * input, va_list * args)
11265 u32 *miss_next_indexp = va_arg (*args, u32 *);
11266 u32 next_index = 0;
11270 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
11274 if (unformat (input, "%d", &tmp))
11283 *miss_next_indexp = next_index;
11287 #define foreach_ip_next \
11290 _(rewrite, REWRITE)
11293 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
11295 u32 *miss_next_indexp = va_arg (*args, u32 *);
11296 u32 next_index = 0;
11300 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
11304 if (unformat (input, "%d", &tmp))
11313 *miss_next_indexp = next_index;
11317 #define foreach_acl_next \
11321 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
11323 u32 *miss_next_indexp = va_arg (*args, u32 *);
11324 u32 next_index = 0;
11328 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
11332 if (unformat (input, "permit"))
11337 else if (unformat (input, "%d", &tmp))
11346 *miss_next_indexp = next_index;
11351 unformat_policer_precolor (unformat_input_t * input, va_list * args)
11353 u32 *r = va_arg (*args, u32 *);
11355 if (unformat (input, "conform-color"))
11356 *r = POLICE_CONFORM;
11357 else if (unformat (input, "exceed-color"))
11358 *r = POLICE_EXCEED;
11366 api_classify_add_del_table (vat_main_t * vam)
11368 unformat_input_t *i = vam->input;
11369 vl_api_classify_add_del_table_t *mp;
11376 u32 table_index = ~0;
11377 u32 next_table_index = ~0;
11378 u32 miss_next_index = ~0;
11379 u32 memory_size = 32 << 20;
11381 u32 current_data_flag = 0;
11382 int current_data_offset = 0;
11385 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11387 if (unformat (i, "del"))
11389 else if (unformat (i, "del-chain"))
11394 else if (unformat (i, "buckets %d", &nbuckets))
11396 else if (unformat (i, "memory_size %d", &memory_size))
11398 else if (unformat (i, "skip %d", &skip))
11400 else if (unformat (i, "match %d", &match))
11402 else if (unformat (i, "table %d", &table_index))
11404 else if (unformat (i, "mask %U", unformat_classify_mask,
11405 &mask, &skip, &match))
11407 else if (unformat (i, "next-table %d", &next_table_index))
11409 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
11412 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
11415 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
11418 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
11420 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
11426 if (is_add && mask == 0)
11428 errmsg ("Mask required");
11432 if (is_add && skip == ~0)
11434 errmsg ("skip count required");
11438 if (is_add && match == ~0)
11440 errmsg ("match count required");
11444 if (!is_add && table_index == ~0)
11446 errmsg ("table index required for delete");
11450 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
11452 mp->is_add = is_add;
11453 mp->del_chain = del_chain;
11454 mp->table_index = ntohl (table_index);
11455 mp->nbuckets = ntohl (nbuckets);
11456 mp->memory_size = ntohl (memory_size);
11457 mp->skip_n_vectors = ntohl (skip);
11458 mp->match_n_vectors = ntohl (match);
11459 mp->next_table_index = ntohl (next_table_index);
11460 mp->miss_next_index = ntohl (miss_next_index);
11461 mp->current_data_flag = ntohl (current_data_flag);
11462 mp->current_data_offset = ntohl (current_data_offset);
11463 mp->mask_len = ntohl (vec_len (mask));
11464 clib_memcpy (mp->mask, mask, vec_len (mask));
11473 #if VPP_API_TEST_BUILTIN == 0
11475 unformat_l4_match (unformat_input_t * input, va_list * args)
11477 u8 **matchp = va_arg (*args, u8 **);
11479 u8 *proto_header = 0;
11485 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11487 if (unformat (input, "src_port %d", &src_port))
11489 else if (unformat (input, "dst_port %d", &dst_port))
11495 h.src_port = clib_host_to_net_u16 (src_port);
11496 h.dst_port = clib_host_to_net_u16 (dst_port);
11497 vec_validate (proto_header, sizeof (h) - 1);
11498 memcpy (proto_header, &h, sizeof (h));
11500 *matchp = proto_header;
11506 unformat_ip4_match (unformat_input_t * input, va_list * args)
11508 u8 **matchp = va_arg (*args, u8 **);
11513 int hdr_length = 0;
11514 u32 hdr_length_val;
11515 int src = 0, dst = 0;
11516 ip4_address_t src_val, dst_val;
11523 int fragment_id = 0;
11524 u32 fragment_id_val;
11530 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11532 if (unformat (input, "version %d", &version_val))
11534 else if (unformat (input, "hdr_length %d", &hdr_length_val))
11536 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
11538 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
11540 else if (unformat (input, "proto %d", &proto_val))
11542 else if (unformat (input, "tos %d", &tos_val))
11544 else if (unformat (input, "length %d", &length_val))
11546 else if (unformat (input, "fragment_id %d", &fragment_id_val))
11548 else if (unformat (input, "ttl %d", &ttl_val))
11550 else if (unformat (input, "checksum %d", &checksum_val))
11556 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
11557 + ttl + checksum == 0)
11561 * Aligned because we use the real comparison functions
11563 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11565 ip = (ip4_header_t *) match;
11567 /* These are realistically matched in practice */
11569 ip->src_address.as_u32 = src_val.as_u32;
11572 ip->dst_address.as_u32 = dst_val.as_u32;
11575 ip->protocol = proto_val;
11578 /* These are not, but they're included for completeness */
11580 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
11583 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
11589 ip->length = clib_host_to_net_u16 (length_val);
11595 ip->checksum = clib_host_to_net_u16 (checksum_val);
11602 unformat_ip6_match (unformat_input_t * input, va_list * args)
11604 u8 **matchp = va_arg (*args, u8 **);
11609 u8 traffic_class = 0;
11610 u32 traffic_class_val = 0;
11613 int src = 0, dst = 0;
11614 ip6_address_t src_val, dst_val;
11617 int payload_length = 0;
11618 u32 payload_length_val;
11621 u32 ip_version_traffic_class_and_flow_label;
11623 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11625 if (unformat (input, "version %d", &version_val))
11627 else if (unformat (input, "traffic_class %d", &traffic_class_val))
11629 else if (unformat (input, "flow_label %d", &flow_label_val))
11631 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
11633 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
11635 else if (unformat (input, "proto %d", &proto_val))
11637 else if (unformat (input, "payload_length %d", &payload_length_val))
11638 payload_length = 1;
11639 else if (unformat (input, "hop_limit %d", &hop_limit_val))
11645 if (version + traffic_class + flow_label + src + dst + proto +
11646 payload_length + hop_limit == 0)
11650 * Aligned because we use the real comparison functions
11652 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11654 ip = (ip6_header_t *) match;
11657 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
11660 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
11663 ip->protocol = proto_val;
11665 ip_version_traffic_class_and_flow_label = 0;
11668 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
11671 ip_version_traffic_class_and_flow_label |=
11672 (traffic_class_val & 0xFF) << 20;
11675 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
11677 ip->ip_version_traffic_class_and_flow_label =
11678 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11680 if (payload_length)
11681 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
11684 ip->hop_limit = hop_limit_val;
11691 unformat_l3_match (unformat_input_t * input, va_list * args)
11693 u8 **matchp = va_arg (*args, u8 **);
11695 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11697 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
11699 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
11708 unformat_vlan_tag (unformat_input_t * input, va_list * args)
11710 u8 *tagp = va_arg (*args, u8 *);
11713 if (unformat (input, "%d", &tag))
11715 tagp[0] = (tag >> 8) & 0x0F;
11716 tagp[1] = tag & 0xFF;
11724 unformat_l2_match (unformat_input_t * input, va_list * args)
11726 u8 **matchp = va_arg (*args, u8 **);
11739 u8 ignore_tag1 = 0;
11740 u8 ignore_tag2 = 0;
11746 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11748 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
11751 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
11753 else if (unformat (input, "proto %U",
11754 unformat_ethernet_type_host_byte_order, &proto_val))
11756 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
11758 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
11760 else if (unformat (input, "ignore-tag1"))
11762 else if (unformat (input, "ignore-tag2"))
11764 else if (unformat (input, "cos1 %d", &cos1_val))
11766 else if (unformat (input, "cos2 %d", &cos2_val))
11771 if ((src + dst + proto + tag1 + tag2 +
11772 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11775 if (tag1 || ignore_tag1 || cos1)
11777 if (tag2 || ignore_tag2 || cos2)
11780 vec_validate_aligned (match, len - 1, sizeof (u32x4));
11783 clib_memcpy (match, dst_val, 6);
11786 clib_memcpy (match + 6, src_val, 6);
11790 /* inner vlan tag */
11791 match[19] = tag2_val[1];
11792 match[18] = tag2_val[0];
11794 match[18] |= (cos2_val & 0x7) << 5;
11797 match[21] = proto_val & 0xff;
11798 match[20] = proto_val >> 8;
11802 match[15] = tag1_val[1];
11803 match[14] = tag1_val[0];
11806 match[14] |= (cos1_val & 0x7) << 5;
11812 match[15] = tag1_val[1];
11813 match[14] = tag1_val[0];
11816 match[17] = proto_val & 0xff;
11817 match[16] = proto_val >> 8;
11820 match[14] |= (cos1_val & 0x7) << 5;
11826 match[18] |= (cos2_val & 0x7) << 5;
11828 match[14] |= (cos1_val & 0x7) << 5;
11831 match[13] = proto_val & 0xff;
11832 match[12] = proto_val >> 8;
11840 unformat_qos_source (unformat_input_t * input, va_list * args)
11842 int *qs = va_arg (*args, int *);
11844 if (unformat (input, "ip"))
11845 *qs = QOS_SOURCE_IP;
11846 else if (unformat (input, "mpls"))
11847 *qs = QOS_SOURCE_MPLS;
11848 else if (unformat (input, "ext"))
11849 *qs = QOS_SOURCE_EXT;
11850 else if (unformat (input, "vlan"))
11851 *qs = QOS_SOURCE_VLAN;
11860 api_unformat_classify_match (unformat_input_t * input, va_list * args)
11862 u8 **matchp = va_arg (*args, u8 **);
11863 u32 skip_n_vectors = va_arg (*args, u32);
11864 u32 match_n_vectors = va_arg (*args, u32);
11871 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11873 if (unformat (input, "hex %U", unformat_hex_string, &match))
11875 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
11877 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
11879 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11893 if (match || l2 || l3 || l4)
11895 if (l2 || l3 || l4)
11897 /* "Win a free Ethernet header in every packet" */
11899 vec_validate_aligned (l2, 13, sizeof (u32x4));
11903 vec_append_aligned (match, l3, sizeof (u32x4));
11908 vec_append_aligned (match, l4, sizeof (u32x4));
11913 /* Make sure the vector is big enough even if key is all 0's */
11914 vec_validate_aligned
11915 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11918 /* Set size, include skipped vectors */
11919 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11930 api_classify_add_del_session (vat_main_t * vam)
11932 unformat_input_t *i = vam->input;
11933 vl_api_classify_add_del_session_t *mp;
11935 u32 table_index = ~0;
11936 u32 hit_next_index = ~0;
11937 u32 opaque_index = ~0;
11940 u32 skip_n_vectors = 0;
11941 u32 match_n_vectors = 0;
11947 * Warning: you have to supply skip_n and match_n
11948 * because the API client cant simply look at the classify
11952 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11954 if (unformat (i, "del"))
11956 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
11959 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
11962 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
11965 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
11967 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
11969 else if (unformat (i, "opaque-index %d", &opaque_index))
11971 else if (unformat (i, "skip_n %d", &skip_n_vectors))
11973 else if (unformat (i, "match_n %d", &match_n_vectors))
11975 else if (unformat (i, "match %U", api_unformat_classify_match,
11976 &match, skip_n_vectors, match_n_vectors))
11978 else if (unformat (i, "advance %d", &advance))
11980 else if (unformat (i, "table-index %d", &table_index))
11982 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
11984 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
11986 else if (unformat (i, "action %d", &action))
11988 else if (unformat (i, "metadata %d", &metadata))
11994 if (table_index == ~0)
11996 errmsg ("Table index required");
12000 if (is_add && match == 0)
12002 errmsg ("Match value required");
12006 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
12008 mp->is_add = is_add;
12009 mp->table_index = ntohl (table_index);
12010 mp->hit_next_index = ntohl (hit_next_index);
12011 mp->opaque_index = ntohl (opaque_index);
12012 mp->advance = ntohl (advance);
12013 mp->action = action;
12014 mp->metadata = ntohl (metadata);
12015 mp->match_len = ntohl (vec_len (match));
12016 clib_memcpy (mp->match, match, vec_len (match));
12025 api_classify_set_interface_ip_table (vat_main_t * vam)
12027 unformat_input_t *i = vam->input;
12028 vl_api_classify_set_interface_ip_table_t *mp;
12030 int sw_if_index_set;
12031 u32 table_index = ~0;
12035 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12037 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12038 sw_if_index_set = 1;
12039 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12040 sw_if_index_set = 1;
12041 else if (unformat (i, "table %d", &table_index))
12045 clib_warning ("parse error '%U'", format_unformat_error, i);
12050 if (sw_if_index_set == 0)
12052 errmsg ("missing interface name or sw_if_index");
12057 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
12059 mp->sw_if_index = ntohl (sw_if_index);
12060 mp->table_index = ntohl (table_index);
12061 mp->is_ipv6 = is_ipv6;
12069 api_classify_set_interface_l2_tables (vat_main_t * vam)
12071 unformat_input_t *i = vam->input;
12072 vl_api_classify_set_interface_l2_tables_t *mp;
12074 int sw_if_index_set;
12075 u32 ip4_table_index = ~0;
12076 u32 ip6_table_index = ~0;
12077 u32 other_table_index = ~0;
12081 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12083 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12084 sw_if_index_set = 1;
12085 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12086 sw_if_index_set = 1;
12087 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12089 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12091 else if (unformat (i, "other-table %d", &other_table_index))
12093 else if (unformat (i, "is-input %d", &is_input))
12097 clib_warning ("parse error '%U'", format_unformat_error, i);
12102 if (sw_if_index_set == 0)
12104 errmsg ("missing interface name or sw_if_index");
12109 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
12111 mp->sw_if_index = ntohl (sw_if_index);
12112 mp->ip4_table_index = ntohl (ip4_table_index);
12113 mp->ip6_table_index = ntohl (ip6_table_index);
12114 mp->other_table_index = ntohl (other_table_index);
12115 mp->is_input = (u8) is_input;
12123 api_set_ipfix_exporter (vat_main_t * vam)
12125 unformat_input_t *i = vam->input;
12126 vl_api_set_ipfix_exporter_t *mp;
12127 ip4_address_t collector_address;
12128 u8 collector_address_set = 0;
12129 u32 collector_port = ~0;
12130 ip4_address_t src_address;
12131 u8 src_address_set = 0;
12134 u32 template_interval = ~0;
12135 u8 udp_checksum = 0;
12138 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12140 if (unformat (i, "collector_address %U", unformat_ip4_address,
12141 &collector_address))
12142 collector_address_set = 1;
12143 else if (unformat (i, "collector_port %d", &collector_port))
12145 else if (unformat (i, "src_address %U", unformat_ip4_address,
12147 src_address_set = 1;
12148 else if (unformat (i, "vrf_id %d", &vrf_id))
12150 else if (unformat (i, "path_mtu %d", &path_mtu))
12152 else if (unformat (i, "template_interval %d", &template_interval))
12154 else if (unformat (i, "udp_checksum"))
12160 if (collector_address_set == 0)
12162 errmsg ("collector_address required");
12166 if (src_address_set == 0)
12168 errmsg ("src_address required");
12172 M (SET_IPFIX_EXPORTER, mp);
12174 memcpy (mp->collector_address, collector_address.data,
12175 sizeof (collector_address.data));
12176 mp->collector_port = htons ((u16) collector_port);
12177 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
12178 mp->vrf_id = htonl (vrf_id);
12179 mp->path_mtu = htonl (path_mtu);
12180 mp->template_interval = htonl (template_interval);
12181 mp->udp_checksum = udp_checksum;
12189 api_set_ipfix_classify_stream (vat_main_t * vam)
12191 unformat_input_t *i = vam->input;
12192 vl_api_set_ipfix_classify_stream_t *mp;
12194 u32 src_port = UDP_DST_PORT_ipfix;
12197 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12199 if (unformat (i, "domain %d", &domain_id))
12201 else if (unformat (i, "src_port %d", &src_port))
12205 errmsg ("unknown input `%U'", format_unformat_error, i);
12210 M (SET_IPFIX_CLASSIFY_STREAM, mp);
12212 mp->domain_id = htonl (domain_id);
12213 mp->src_port = htons ((u16) src_port);
12221 api_ipfix_classify_table_add_del (vat_main_t * vam)
12223 unformat_input_t *i = vam->input;
12224 vl_api_ipfix_classify_table_add_del_t *mp;
12226 u32 classify_table_index = ~0;
12228 u8 transport_protocol = 255;
12231 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12233 if (unformat (i, "add"))
12235 else if (unformat (i, "del"))
12237 else if (unformat (i, "table %d", &classify_table_index))
12239 else if (unformat (i, "ip4"))
12241 else if (unformat (i, "ip6"))
12243 else if (unformat (i, "tcp"))
12244 transport_protocol = 6;
12245 else if (unformat (i, "udp"))
12246 transport_protocol = 17;
12249 errmsg ("unknown input `%U'", format_unformat_error, i);
12256 errmsg ("expecting: add|del");
12259 if (classify_table_index == ~0)
12261 errmsg ("classifier table not specified");
12264 if (ip_version == 0)
12266 errmsg ("IP version not specified");
12270 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
12272 mp->is_add = is_add;
12273 mp->table_id = htonl (classify_table_index);
12274 mp->ip_version = ip_version;
12275 mp->transport_protocol = transport_protocol;
12283 api_get_node_index (vat_main_t * vam)
12285 unformat_input_t *i = vam->input;
12286 vl_api_get_node_index_t *mp;
12290 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12292 if (unformat (i, "node %s", &name))
12299 errmsg ("node name required");
12302 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12304 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12308 M (GET_NODE_INDEX, mp);
12309 clib_memcpy (mp->node_name, name, vec_len (name));
12318 api_get_next_index (vat_main_t * vam)
12320 unformat_input_t *i = vam->input;
12321 vl_api_get_next_index_t *mp;
12322 u8 *node_name = 0, *next_node_name = 0;
12325 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12327 if (unformat (i, "node-name %s", &node_name))
12329 else if (unformat (i, "next-node-name %s", &next_node_name))
12333 if (node_name == 0)
12335 errmsg ("node name required");
12338 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
12340 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12344 if (next_node_name == 0)
12346 errmsg ("next node name required");
12349 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
12351 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
12355 M (GET_NEXT_INDEX, mp);
12356 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
12357 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
12358 vec_free (node_name);
12359 vec_free (next_node_name);
12367 api_add_node_next (vat_main_t * vam)
12369 unformat_input_t *i = vam->input;
12370 vl_api_add_node_next_t *mp;
12375 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12377 if (unformat (i, "node %s", &name))
12379 else if (unformat (i, "next %s", &next))
12386 errmsg ("node name required");
12389 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12391 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12396 errmsg ("next node required");
12399 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
12401 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
12405 M (ADD_NODE_NEXT, mp);
12406 clib_memcpy (mp->node_name, name, vec_len (name));
12407 clib_memcpy (mp->next_name, next, vec_len (next));
12417 api_l2tpv3_create_tunnel (vat_main_t * vam)
12419 unformat_input_t *i = vam->input;
12420 ip6_address_t client_address, our_address;
12421 int client_address_set = 0;
12422 int our_address_set = 0;
12423 u32 local_session_id = 0;
12424 u32 remote_session_id = 0;
12425 u64 local_cookie = 0;
12426 u64 remote_cookie = 0;
12427 u8 l2_sublayer_present = 0;
12428 vl_api_l2tpv3_create_tunnel_t *mp;
12431 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12433 if (unformat (i, "client_address %U", unformat_ip6_address,
12435 client_address_set = 1;
12436 else if (unformat (i, "our_address %U", unformat_ip6_address,
12438 our_address_set = 1;
12439 else if (unformat (i, "local_session_id %d", &local_session_id))
12441 else if (unformat (i, "remote_session_id %d", &remote_session_id))
12443 else if (unformat (i, "local_cookie %lld", &local_cookie))
12445 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
12447 else if (unformat (i, "l2-sublayer-present"))
12448 l2_sublayer_present = 1;
12453 if (client_address_set == 0)
12455 errmsg ("client_address required");
12459 if (our_address_set == 0)
12461 errmsg ("our_address required");
12465 M (L2TPV3_CREATE_TUNNEL, mp);
12467 clib_memcpy (mp->client_address, client_address.as_u8,
12468 sizeof (mp->client_address));
12470 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
12472 mp->local_session_id = ntohl (local_session_id);
12473 mp->remote_session_id = ntohl (remote_session_id);
12474 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
12475 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
12476 mp->l2_sublayer_present = l2_sublayer_present;
12485 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
12487 unformat_input_t *i = vam->input;
12489 u8 sw_if_index_set = 0;
12490 u64 new_local_cookie = 0;
12491 u64 new_remote_cookie = 0;
12492 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
12495 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12497 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12498 sw_if_index_set = 1;
12499 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12500 sw_if_index_set = 1;
12501 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
12503 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
12509 if (sw_if_index_set == 0)
12511 errmsg ("missing interface name or sw_if_index");
12515 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
12517 mp->sw_if_index = ntohl (sw_if_index);
12518 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
12519 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
12527 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
12529 unformat_input_t *i = vam->input;
12530 vl_api_l2tpv3_interface_enable_disable_t *mp;
12532 u8 sw_if_index_set = 0;
12533 u8 enable_disable = 1;
12536 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12538 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12539 sw_if_index_set = 1;
12540 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12541 sw_if_index_set = 1;
12542 else if (unformat (i, "enable"))
12543 enable_disable = 1;
12544 else if (unformat (i, "disable"))
12545 enable_disable = 0;
12550 if (sw_if_index_set == 0)
12552 errmsg ("missing interface name or sw_if_index");
12556 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
12558 mp->sw_if_index = ntohl (sw_if_index);
12559 mp->enable_disable = enable_disable;
12567 api_l2tpv3_set_lookup_key (vat_main_t * vam)
12569 unformat_input_t *i = vam->input;
12570 vl_api_l2tpv3_set_lookup_key_t *mp;
12574 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12576 if (unformat (i, "lookup_v6_src"))
12577 key = L2T_LOOKUP_SRC_ADDRESS;
12578 else if (unformat (i, "lookup_v6_dst"))
12579 key = L2T_LOOKUP_DST_ADDRESS;
12580 else if (unformat (i, "lookup_session_id"))
12581 key = L2T_LOOKUP_SESSION_ID;
12586 if (key == (u8) ~ 0)
12588 errmsg ("l2tp session lookup key unset");
12592 M (L2TPV3_SET_LOOKUP_KEY, mp);
12601 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
12602 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12604 vat_main_t *vam = &vat_main;
12606 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
12607 format_ip6_address, mp->our_address,
12608 format_ip6_address, mp->client_address,
12609 clib_net_to_host_u32 (mp->sw_if_index));
12612 " local cookies %016llx %016llx remote cookie %016llx",
12613 clib_net_to_host_u64 (mp->local_cookie[0]),
12614 clib_net_to_host_u64 (mp->local_cookie[1]),
12615 clib_net_to_host_u64 (mp->remote_cookie));
12617 print (vam->ofp, " local session-id %d remote session-id %d",
12618 clib_net_to_host_u32 (mp->local_session_id),
12619 clib_net_to_host_u32 (mp->remote_session_id));
12621 print (vam->ofp, " l2 specific sublayer %s\n",
12622 mp->l2_sublayer_present ? "preset" : "absent");
12626 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
12627 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12629 vat_main_t *vam = &vat_main;
12630 vat_json_node_t *node = NULL;
12631 struct in6_addr addr;
12633 if (VAT_JSON_ARRAY != vam->json_tree.type)
12635 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12636 vat_json_init_array (&vam->json_tree);
12638 node = vat_json_array_add (&vam->json_tree);
12640 vat_json_init_object (node);
12642 clib_memcpy (&addr, mp->our_address, sizeof (addr));
12643 vat_json_object_add_ip6 (node, "our_address", addr);
12644 clib_memcpy (&addr, mp->client_address, sizeof (addr));
12645 vat_json_object_add_ip6 (node, "client_address", addr);
12647 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
12648 vat_json_init_array (lc);
12649 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
12650 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
12651 vat_json_object_add_uint (node, "remote_cookie",
12652 clib_net_to_host_u64 (mp->remote_cookie));
12654 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
12655 vat_json_object_add_uint (node, "local_session_id",
12656 clib_net_to_host_u32 (mp->local_session_id));
12657 vat_json_object_add_uint (node, "remote_session_id",
12658 clib_net_to_host_u32 (mp->remote_session_id));
12659 vat_json_object_add_string_copy (node, "l2_sublayer",
12660 mp->l2_sublayer_present ? (u8 *) "present"
12661 : (u8 *) "absent");
12665 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
12667 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
12668 vl_api_control_ping_t *mp_ping;
12671 /* Get list of l2tpv3-tunnel interfaces */
12672 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
12675 /* Use a control ping for synchronization */
12676 MPING (CONTROL_PING, mp_ping);
12684 static void vl_api_sw_interface_tap_details_t_handler
12685 (vl_api_sw_interface_tap_details_t * mp)
12687 vat_main_t *vam = &vat_main;
12689 print (vam->ofp, "%-16s %d",
12690 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
12693 static void vl_api_sw_interface_tap_details_t_handler_json
12694 (vl_api_sw_interface_tap_details_t * mp)
12696 vat_main_t *vam = &vat_main;
12697 vat_json_node_t *node = NULL;
12699 if (VAT_JSON_ARRAY != vam->json_tree.type)
12701 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12702 vat_json_init_array (&vam->json_tree);
12704 node = vat_json_array_add (&vam->json_tree);
12706 vat_json_init_object (node);
12707 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12708 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12712 api_sw_interface_tap_dump (vat_main_t * vam)
12714 vl_api_sw_interface_tap_dump_t *mp;
12715 vl_api_control_ping_t *mp_ping;
12718 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
12719 /* Get list of tap interfaces */
12720 M (SW_INTERFACE_TAP_DUMP, mp);
12723 /* Use a control ping for synchronization */
12724 MPING (CONTROL_PING, mp_ping);
12731 static void vl_api_sw_interface_tap_v2_details_t_handler
12732 (vl_api_sw_interface_tap_v2_details_t * mp)
12734 vat_main_t *vam = &vat_main;
12736 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
12737 mp->host_ip4_prefix_len);
12738 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
12739 mp->host_ip6_prefix_len);
12742 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s",
12743 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
12744 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12745 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
12746 mp->host_bridge, ip4, ip6);
12752 static void vl_api_sw_interface_tap_v2_details_t_handler_json
12753 (vl_api_sw_interface_tap_v2_details_t * mp)
12755 vat_main_t *vam = &vat_main;
12756 vat_json_node_t *node = NULL;
12758 if (VAT_JSON_ARRAY != vam->json_tree.type)
12760 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12761 vat_json_init_array (&vam->json_tree);
12763 node = vat_json_array_add (&vam->json_tree);
12765 vat_json_init_object (node);
12766 vat_json_object_add_uint (node, "id", ntohl (mp->id));
12767 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12768 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12769 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12770 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12771 vat_json_object_add_string_copy (node, "host_mac_addr",
12772 format (0, "%U", format_ethernet_address,
12773 &mp->host_mac_addr));
12774 vat_json_object_add_string_copy (node, "host_namespace",
12775 mp->host_namespace);
12776 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
12777 vat_json_object_add_string_copy (node, "host_ip4_addr",
12778 format (0, "%U/%d", format_ip4_address,
12780 mp->host_ip4_prefix_len));
12781 vat_json_object_add_string_copy (node, "host_ip6_addr",
12782 format (0, "%U/%d", format_ip6_address,
12784 mp->host_ip6_prefix_len));
12789 api_sw_interface_tap_v2_dump (vat_main_t * vam)
12791 vl_api_sw_interface_tap_v2_dump_t *mp;
12792 vl_api_control_ping_t *mp_ping;
12796 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
12797 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
12798 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
12801 /* Get list of tap interfaces */
12802 M (SW_INTERFACE_TAP_V2_DUMP, mp);
12805 /* Use a control ping for synchronization */
12806 MPING (CONTROL_PING, mp_ping);
12814 api_vxlan_offload_rx (vat_main_t * vam)
12816 unformat_input_t *line_input = vam->input;
12817 vl_api_vxlan_offload_rx_t *mp;
12818 u32 hw_if_index = ~0, rx_if_index = ~0;
12822 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12824 if (unformat (line_input, "del"))
12826 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
12829 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
12831 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
12834 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
12838 errmsg ("parse error '%U'", format_unformat_error, line_input);
12843 if (hw_if_index == ~0)
12845 errmsg ("no hw interface");
12849 if (rx_if_index == ~0)
12851 errmsg ("no rx tunnel");
12855 M (VXLAN_OFFLOAD_RX, mp);
12857 mp->hw_if_index = ntohl (hw_if_index);
12858 mp->sw_if_index = ntohl (rx_if_index);
12859 mp->enable = is_add;
12866 static uword unformat_vxlan_decap_next
12867 (unformat_input_t * input, va_list * args)
12869 u32 *result = va_arg (*args, u32 *);
12872 if (unformat (input, "l2"))
12873 *result = VXLAN_INPUT_NEXT_L2_INPUT;
12874 else if (unformat (input, "%d", &tmp))
12882 api_vxlan_add_del_tunnel (vat_main_t * vam)
12884 unformat_input_t *line_input = vam->input;
12885 vl_api_vxlan_add_del_tunnel_t *mp;
12886 ip46_address_t src, dst;
12888 u8 ipv4_set = 0, ipv6_set = 0;
12893 u32 mcast_sw_if_index = ~0;
12894 u32 encap_vrf_id = 0;
12895 u32 decap_next_index = ~0;
12899 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12900 memset (&src, 0, sizeof src);
12901 memset (&dst, 0, sizeof dst);
12903 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12905 if (unformat (line_input, "del"))
12907 else if (unformat (line_input, "instance %d", &instance))
12910 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12916 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12922 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12928 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12933 else if (unformat (line_input, "group %U %U",
12934 unformat_ip4_address, &dst.ip4,
12935 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12937 grp_set = dst_set = 1;
12940 else if (unformat (line_input, "group %U",
12941 unformat_ip4_address, &dst.ip4))
12943 grp_set = dst_set = 1;
12946 else if (unformat (line_input, "group %U %U",
12947 unformat_ip6_address, &dst.ip6,
12948 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12950 grp_set = dst_set = 1;
12953 else if (unformat (line_input, "group %U",
12954 unformat_ip6_address, &dst.ip6))
12956 grp_set = dst_set = 1;
12960 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12962 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12964 else if (unformat (line_input, "decap-next %U",
12965 unformat_vxlan_decap_next, &decap_next_index))
12967 else if (unformat (line_input, "vni %d", &vni))
12971 errmsg ("parse error '%U'", format_unformat_error, line_input);
12978 errmsg ("tunnel src address not specified");
12983 errmsg ("tunnel dst address not specified");
12987 if (grp_set && !ip46_address_is_multicast (&dst))
12989 errmsg ("tunnel group address not multicast");
12992 if (grp_set && mcast_sw_if_index == ~0)
12994 errmsg ("tunnel nonexistent multicast device");
12997 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12999 errmsg ("tunnel dst address must be unicast");
13004 if (ipv4_set && ipv6_set)
13006 errmsg ("both IPv4 and IPv6 addresses specified");
13010 if ((vni == 0) || (vni >> 24))
13012 errmsg ("vni not specified or out of range");
13016 M (VXLAN_ADD_DEL_TUNNEL, mp);
13020 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
13021 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
13025 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
13026 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
13029 mp->instance = htonl (instance);
13030 mp->encap_vrf_id = ntohl (encap_vrf_id);
13031 mp->decap_next_index = ntohl (decap_next_index);
13032 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13033 mp->vni = ntohl (vni);
13034 mp->is_add = is_add;
13035 mp->is_ipv6 = ipv6_set;
13042 static void vl_api_vxlan_tunnel_details_t_handler
13043 (vl_api_vxlan_tunnel_details_t * mp)
13045 vat_main_t *vam = &vat_main;
13046 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13047 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13049 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
13050 ntohl (mp->sw_if_index),
13051 ntohl (mp->instance),
13052 format_ip46_address, &src, IP46_TYPE_ANY,
13053 format_ip46_address, &dst, IP46_TYPE_ANY,
13054 ntohl (mp->encap_vrf_id),
13055 ntohl (mp->decap_next_index), ntohl (mp->vni),
13056 ntohl (mp->mcast_sw_if_index));
13059 static void vl_api_vxlan_tunnel_details_t_handler_json
13060 (vl_api_vxlan_tunnel_details_t * mp)
13062 vat_main_t *vam = &vat_main;
13063 vat_json_node_t *node = NULL;
13065 if (VAT_JSON_ARRAY != vam->json_tree.type)
13067 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13068 vat_json_init_array (&vam->json_tree);
13070 node = vat_json_array_add (&vam->json_tree);
13072 vat_json_init_object (node);
13073 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13075 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13079 struct in6_addr ip6;
13081 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13082 vat_json_object_add_ip6 (node, "src_address", ip6);
13083 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13084 vat_json_object_add_ip6 (node, "dst_address", ip6);
13088 struct in_addr ip4;
13090 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13091 vat_json_object_add_ip4 (node, "src_address", ip4);
13092 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13093 vat_json_object_add_ip4 (node, "dst_address", ip4);
13095 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13096 vat_json_object_add_uint (node, "decap_next_index",
13097 ntohl (mp->decap_next_index));
13098 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13099 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13100 vat_json_object_add_uint (node, "mcast_sw_if_index",
13101 ntohl (mp->mcast_sw_if_index));
13105 api_vxlan_tunnel_dump (vat_main_t * vam)
13107 unformat_input_t *i = vam->input;
13108 vl_api_vxlan_tunnel_dump_t *mp;
13109 vl_api_control_ping_t *mp_ping;
13111 u8 sw_if_index_set = 0;
13114 /* Parse args required to build the message */
13115 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13117 if (unformat (i, "sw_if_index %d", &sw_if_index))
13118 sw_if_index_set = 1;
13123 if (sw_if_index_set == 0)
13128 if (!vam->json_output)
13130 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
13131 "sw_if_index", "instance", "src_address", "dst_address",
13132 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13135 /* Get list of vxlan-tunnel interfaces */
13136 M (VXLAN_TUNNEL_DUMP, mp);
13138 mp->sw_if_index = htonl (sw_if_index);
13142 /* Use a control ping for synchronization */
13143 MPING (CONTROL_PING, mp_ping);
13150 static uword unformat_geneve_decap_next
13151 (unformat_input_t * input, va_list * args)
13153 u32 *result = va_arg (*args, u32 *);
13156 if (unformat (input, "l2"))
13157 *result = GENEVE_INPUT_NEXT_L2_INPUT;
13158 else if (unformat (input, "%d", &tmp))
13166 api_geneve_add_del_tunnel (vat_main_t * vam)
13168 unformat_input_t *line_input = vam->input;
13169 vl_api_geneve_add_del_tunnel_t *mp;
13170 ip46_address_t src, dst;
13172 u8 ipv4_set = 0, ipv6_set = 0;
13176 u32 mcast_sw_if_index = ~0;
13177 u32 encap_vrf_id = 0;
13178 u32 decap_next_index = ~0;
13182 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13183 memset (&src, 0, sizeof src);
13184 memset (&dst, 0, sizeof dst);
13186 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13188 if (unformat (line_input, "del"))
13191 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13197 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13203 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13209 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13214 else if (unformat (line_input, "group %U %U",
13215 unformat_ip4_address, &dst.ip4,
13216 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13218 grp_set = dst_set = 1;
13221 else if (unformat (line_input, "group %U",
13222 unformat_ip4_address, &dst.ip4))
13224 grp_set = dst_set = 1;
13227 else if (unformat (line_input, "group %U %U",
13228 unformat_ip6_address, &dst.ip6,
13229 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13231 grp_set = dst_set = 1;
13234 else if (unformat (line_input, "group %U",
13235 unformat_ip6_address, &dst.ip6))
13237 grp_set = dst_set = 1;
13241 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13243 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13245 else if (unformat (line_input, "decap-next %U",
13246 unformat_geneve_decap_next, &decap_next_index))
13248 else if (unformat (line_input, "vni %d", &vni))
13252 errmsg ("parse error '%U'", format_unformat_error, line_input);
13259 errmsg ("tunnel src address not specified");
13264 errmsg ("tunnel dst address not specified");
13268 if (grp_set && !ip46_address_is_multicast (&dst))
13270 errmsg ("tunnel group address not multicast");
13273 if (grp_set && mcast_sw_if_index == ~0)
13275 errmsg ("tunnel nonexistent multicast device");
13278 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13280 errmsg ("tunnel dst address must be unicast");
13285 if (ipv4_set && ipv6_set)
13287 errmsg ("both IPv4 and IPv6 addresses specified");
13291 if ((vni == 0) || (vni >> 24))
13293 errmsg ("vni not specified or out of range");
13297 M (GENEVE_ADD_DEL_TUNNEL, mp);
13301 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
13302 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
13306 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
13307 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
13309 mp->encap_vrf_id = ntohl (encap_vrf_id);
13310 mp->decap_next_index = ntohl (decap_next_index);
13311 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13312 mp->vni = ntohl (vni);
13313 mp->is_add = is_add;
13314 mp->is_ipv6 = ipv6_set;
13321 static void vl_api_geneve_tunnel_details_t_handler
13322 (vl_api_geneve_tunnel_details_t * mp)
13324 vat_main_t *vam = &vat_main;
13325 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13326 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13328 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
13329 ntohl (mp->sw_if_index),
13330 format_ip46_address, &src, IP46_TYPE_ANY,
13331 format_ip46_address, &dst, IP46_TYPE_ANY,
13332 ntohl (mp->encap_vrf_id),
13333 ntohl (mp->decap_next_index), ntohl (mp->vni),
13334 ntohl (mp->mcast_sw_if_index));
13337 static void vl_api_geneve_tunnel_details_t_handler_json
13338 (vl_api_geneve_tunnel_details_t * mp)
13340 vat_main_t *vam = &vat_main;
13341 vat_json_node_t *node = NULL;
13343 if (VAT_JSON_ARRAY != vam->json_tree.type)
13345 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13346 vat_json_init_array (&vam->json_tree);
13348 node = vat_json_array_add (&vam->json_tree);
13350 vat_json_init_object (node);
13351 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13354 struct in6_addr ip6;
13356 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13357 vat_json_object_add_ip6 (node, "src_address", ip6);
13358 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13359 vat_json_object_add_ip6 (node, "dst_address", ip6);
13363 struct in_addr ip4;
13365 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13366 vat_json_object_add_ip4 (node, "src_address", ip4);
13367 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13368 vat_json_object_add_ip4 (node, "dst_address", ip4);
13370 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13371 vat_json_object_add_uint (node, "decap_next_index",
13372 ntohl (mp->decap_next_index));
13373 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13374 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13375 vat_json_object_add_uint (node, "mcast_sw_if_index",
13376 ntohl (mp->mcast_sw_if_index));
13380 api_geneve_tunnel_dump (vat_main_t * vam)
13382 unformat_input_t *i = vam->input;
13383 vl_api_geneve_tunnel_dump_t *mp;
13384 vl_api_control_ping_t *mp_ping;
13386 u8 sw_if_index_set = 0;
13389 /* Parse args required to build the message */
13390 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13392 if (unformat (i, "sw_if_index %d", &sw_if_index))
13393 sw_if_index_set = 1;
13398 if (sw_if_index_set == 0)
13403 if (!vam->json_output)
13405 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
13406 "sw_if_index", "local_address", "remote_address",
13407 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13410 /* Get list of geneve-tunnel interfaces */
13411 M (GENEVE_TUNNEL_DUMP, mp);
13413 mp->sw_if_index = htonl (sw_if_index);
13417 /* Use a control ping for synchronization */
13418 M (CONTROL_PING, mp_ping);
13426 api_gre_add_del_tunnel (vat_main_t * vam)
13428 unformat_input_t *line_input = vam->input;
13429 vl_api_gre_add_del_tunnel_t *mp;
13430 ip4_address_t src4, dst4;
13431 ip6_address_t src6, dst6;
13435 u8 t_type = GRE_TUNNEL_TYPE_L3;
13438 u32 outer_fib_id = 0;
13439 u32 session_id = 0;
13443 memset (&src4, 0, sizeof src4);
13444 memset (&dst4, 0, sizeof dst4);
13445 memset (&src6, 0, sizeof src6);
13446 memset (&dst6, 0, sizeof dst6);
13448 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13450 if (unformat (line_input, "del"))
13452 else if (unformat (line_input, "instance %d", &instance))
13454 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
13459 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
13464 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
13469 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
13474 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
13476 else if (unformat (line_input, "teb"))
13477 t_type = GRE_TUNNEL_TYPE_TEB;
13478 else if (unformat (line_input, "erspan %d", &session_id))
13479 t_type = GRE_TUNNEL_TYPE_ERSPAN;
13482 errmsg ("parse error '%U'", format_unformat_error, line_input);
13489 errmsg ("tunnel src address not specified");
13494 errmsg ("tunnel dst address not specified");
13497 if (ipv4_set && ipv6_set)
13499 errmsg ("both IPv4 and IPv6 addresses specified");
13504 M (GRE_ADD_DEL_TUNNEL, mp);
13508 clib_memcpy (&mp->src_address, &src4, 4);
13509 clib_memcpy (&mp->dst_address, &dst4, 4);
13513 clib_memcpy (&mp->src_address, &src6, 16);
13514 clib_memcpy (&mp->dst_address, &dst6, 16);
13516 mp->instance = htonl (instance);
13517 mp->outer_fib_id = htonl (outer_fib_id);
13518 mp->is_add = is_add;
13519 mp->session_id = htons ((u16) session_id);
13520 mp->tunnel_type = t_type;
13521 mp->is_ipv6 = ipv6_set;
13528 static void vl_api_gre_tunnel_details_t_handler
13529 (vl_api_gre_tunnel_details_t * mp)
13531 vat_main_t *vam = &vat_main;
13532 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
13533 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
13535 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
13536 ntohl (mp->sw_if_index),
13537 ntohl (mp->instance),
13538 format_ip46_address, &src, IP46_TYPE_ANY,
13539 format_ip46_address, &dst, IP46_TYPE_ANY,
13540 mp->tunnel_type, ntohl (mp->outer_fib_id), ntohl (mp->session_id));
13543 static void vl_api_gre_tunnel_details_t_handler_json
13544 (vl_api_gre_tunnel_details_t * mp)
13546 vat_main_t *vam = &vat_main;
13547 vat_json_node_t *node = NULL;
13548 struct in_addr ip4;
13549 struct in6_addr ip6;
13551 if (VAT_JSON_ARRAY != vam->json_tree.type)
13553 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13554 vat_json_init_array (&vam->json_tree);
13556 node = vat_json_array_add (&vam->json_tree);
13558 vat_json_init_object (node);
13559 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13560 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13563 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
13564 vat_json_object_add_ip4 (node, "src_address", ip4);
13565 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
13566 vat_json_object_add_ip4 (node, "dst_address", ip4);
13570 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
13571 vat_json_object_add_ip6 (node, "src_address", ip6);
13572 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
13573 vat_json_object_add_ip6 (node, "dst_address", ip6);
13575 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel_type);
13576 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
13577 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
13578 vat_json_object_add_uint (node, "session_id", mp->session_id);
13582 api_gre_tunnel_dump (vat_main_t * vam)
13584 unformat_input_t *i = vam->input;
13585 vl_api_gre_tunnel_dump_t *mp;
13586 vl_api_control_ping_t *mp_ping;
13588 u8 sw_if_index_set = 0;
13591 /* Parse args required to build the message */
13592 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13594 if (unformat (i, "sw_if_index %d", &sw_if_index))
13595 sw_if_index_set = 1;
13600 if (sw_if_index_set == 0)
13605 if (!vam->json_output)
13607 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
13608 "sw_if_index", "instance", "src_address", "dst_address",
13609 "tunnel_type", "outer_fib_id", "session_id");
13612 /* Get list of gre-tunnel interfaces */
13613 M (GRE_TUNNEL_DUMP, mp);
13615 mp->sw_if_index = htonl (sw_if_index);
13619 /* Use a control ping for synchronization */
13620 MPING (CONTROL_PING, mp_ping);
13628 api_l2_fib_clear_table (vat_main_t * vam)
13630 // unformat_input_t * i = vam->input;
13631 vl_api_l2_fib_clear_table_t *mp;
13634 M (L2_FIB_CLEAR_TABLE, mp);
13642 api_l2_interface_efp_filter (vat_main_t * vam)
13644 unformat_input_t *i = vam->input;
13645 vl_api_l2_interface_efp_filter_t *mp;
13648 u8 sw_if_index_set = 0;
13651 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13653 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13654 sw_if_index_set = 1;
13655 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13656 sw_if_index_set = 1;
13657 else if (unformat (i, "enable"))
13659 else if (unformat (i, "disable"))
13663 clib_warning ("parse error '%U'", format_unformat_error, i);
13668 if (sw_if_index_set == 0)
13670 errmsg ("missing sw_if_index");
13674 M (L2_INTERFACE_EFP_FILTER, mp);
13676 mp->sw_if_index = ntohl (sw_if_index);
13677 mp->enable_disable = enable;
13684 #define foreach_vtr_op \
13685 _("disable", L2_VTR_DISABLED) \
13686 _("push-1", L2_VTR_PUSH_1) \
13687 _("push-2", L2_VTR_PUSH_2) \
13688 _("pop-1", L2_VTR_POP_1) \
13689 _("pop-2", L2_VTR_POP_2) \
13690 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
13691 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
13692 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
13693 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
13696 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
13698 unformat_input_t *i = vam->input;
13699 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
13701 u8 sw_if_index_set = 0;
13704 u32 push_dot1q = 1;
13709 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13711 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13712 sw_if_index_set = 1;
13713 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13714 sw_if_index_set = 1;
13715 else if (unformat (i, "vtr_op %d", &vtr_op))
13717 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
13720 else if (unformat (i, "push_dot1q %d", &push_dot1q))
13722 else if (unformat (i, "tag1 %d", &tag1))
13724 else if (unformat (i, "tag2 %d", &tag2))
13728 clib_warning ("parse error '%U'", format_unformat_error, i);
13733 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
13735 errmsg ("missing vtr operation or sw_if_index");
13739 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
13740 mp->sw_if_index = ntohl (sw_if_index);
13741 mp->vtr_op = ntohl (vtr_op);
13742 mp->push_dot1q = ntohl (push_dot1q);
13743 mp->tag1 = ntohl (tag1);
13744 mp->tag2 = ntohl (tag2);
13752 api_create_vhost_user_if (vat_main_t * vam)
13754 unformat_input_t *i = vam->input;
13755 vl_api_create_vhost_user_if_t *mp;
13758 u8 file_name_set = 0;
13759 u32 custom_dev_instance = ~0;
13761 u8 use_custom_mac = 0;
13765 /* Shut up coverity */
13766 memset (hwaddr, 0, sizeof (hwaddr));
13768 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13770 if (unformat (i, "socket %s", &file_name))
13774 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13776 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
13777 use_custom_mac = 1;
13778 else if (unformat (i, "server"))
13780 else if (unformat (i, "tag %s", &tag))
13786 if (file_name_set == 0)
13788 errmsg ("missing socket file name");
13792 if (vec_len (file_name) > 255)
13794 errmsg ("socket file name too long");
13797 vec_add1 (file_name, 0);
13799 M (CREATE_VHOST_USER_IF, mp);
13801 mp->is_server = is_server;
13802 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13803 vec_free (file_name);
13804 if (custom_dev_instance != ~0)
13807 mp->custom_dev_instance = ntohl (custom_dev_instance);
13809 mp->use_custom_mac = use_custom_mac;
13810 clib_memcpy (mp->mac_address, hwaddr, 6);
13812 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
13821 api_modify_vhost_user_if (vat_main_t * vam)
13823 unformat_input_t *i = vam->input;
13824 vl_api_modify_vhost_user_if_t *mp;
13827 u8 file_name_set = 0;
13828 u32 custom_dev_instance = ~0;
13829 u8 sw_if_index_set = 0;
13830 u32 sw_if_index = (u32) ~ 0;
13833 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13835 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13836 sw_if_index_set = 1;
13837 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13838 sw_if_index_set = 1;
13839 else if (unformat (i, "socket %s", &file_name))
13843 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13845 else if (unformat (i, "server"))
13851 if (sw_if_index_set == 0)
13853 errmsg ("missing sw_if_index or interface name");
13857 if (file_name_set == 0)
13859 errmsg ("missing socket file name");
13863 if (vec_len (file_name) > 255)
13865 errmsg ("socket file name too long");
13868 vec_add1 (file_name, 0);
13870 M (MODIFY_VHOST_USER_IF, mp);
13872 mp->sw_if_index = ntohl (sw_if_index);
13873 mp->is_server = is_server;
13874 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13875 vec_free (file_name);
13876 if (custom_dev_instance != ~0)
13879 mp->custom_dev_instance = ntohl (custom_dev_instance);
13888 api_delete_vhost_user_if (vat_main_t * vam)
13890 unformat_input_t *i = vam->input;
13891 vl_api_delete_vhost_user_if_t *mp;
13892 u32 sw_if_index = ~0;
13893 u8 sw_if_index_set = 0;
13896 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13898 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13899 sw_if_index_set = 1;
13900 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13901 sw_if_index_set = 1;
13906 if (sw_if_index_set == 0)
13908 errmsg ("missing sw_if_index or interface name");
13913 M (DELETE_VHOST_USER_IF, mp);
13915 mp->sw_if_index = ntohl (sw_if_index);
13922 static void vl_api_sw_interface_vhost_user_details_t_handler
13923 (vl_api_sw_interface_vhost_user_details_t * mp)
13925 vat_main_t *vam = &vat_main;
13927 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
13928 (char *) mp->interface_name,
13929 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
13930 clib_net_to_host_u64 (mp->features), mp->is_server,
13931 ntohl (mp->num_regions), (char *) mp->sock_filename);
13932 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
13935 static void vl_api_sw_interface_vhost_user_details_t_handler_json
13936 (vl_api_sw_interface_vhost_user_details_t * mp)
13938 vat_main_t *vam = &vat_main;
13939 vat_json_node_t *node = NULL;
13941 if (VAT_JSON_ARRAY != vam->json_tree.type)
13943 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13944 vat_json_init_array (&vam->json_tree);
13946 node = vat_json_array_add (&vam->json_tree);
13948 vat_json_init_object (node);
13949 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13950 vat_json_object_add_string_copy (node, "interface_name",
13951 mp->interface_name);
13952 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
13953 ntohl (mp->virtio_net_hdr_sz));
13954 vat_json_object_add_uint (node, "features",
13955 clib_net_to_host_u64 (mp->features));
13956 vat_json_object_add_uint (node, "is_server", mp->is_server);
13957 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
13958 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
13959 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
13963 api_sw_interface_vhost_user_dump (vat_main_t * vam)
13965 vl_api_sw_interface_vhost_user_dump_t *mp;
13966 vl_api_control_ping_t *mp_ping;
13969 "Interface name idx hdr_sz features server regions filename");
13971 /* Get list of vhost-user interfaces */
13972 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
13975 /* Use a control ping for synchronization */
13976 MPING (CONTROL_PING, mp_ping);
13984 api_show_version (vat_main_t * vam)
13986 vl_api_show_version_t *mp;
13989 M (SHOW_VERSION, mp);
13998 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
14000 unformat_input_t *line_input = vam->input;
14001 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
14002 ip4_address_t local4, remote4;
14003 ip6_address_t local6, remote6;
14005 u8 ipv4_set = 0, ipv6_set = 0;
14009 u32 mcast_sw_if_index = ~0;
14010 u32 encap_vrf_id = 0;
14011 u32 decap_vrf_id = 0;
14017 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
14018 memset (&local4, 0, sizeof local4);
14019 memset (&remote4, 0, sizeof remote4);
14020 memset (&local6, 0, sizeof local6);
14021 memset (&remote6, 0, sizeof remote6);
14023 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14025 if (unformat (line_input, "del"))
14027 else if (unformat (line_input, "local %U",
14028 unformat_ip4_address, &local4))
14033 else if (unformat (line_input, "remote %U",
14034 unformat_ip4_address, &remote4))
14039 else if (unformat (line_input, "local %U",
14040 unformat_ip6_address, &local6))
14045 else if (unformat (line_input, "remote %U",
14046 unformat_ip6_address, &remote6))
14051 else if (unformat (line_input, "group %U %U",
14052 unformat_ip4_address, &remote4,
14053 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14055 grp_set = remote_set = 1;
14058 else if (unformat (line_input, "group %U",
14059 unformat_ip4_address, &remote4))
14061 grp_set = remote_set = 1;
14064 else if (unformat (line_input, "group %U %U",
14065 unformat_ip6_address, &remote6,
14066 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14068 grp_set = remote_set = 1;
14071 else if (unformat (line_input, "group %U",
14072 unformat_ip6_address, &remote6))
14074 grp_set = remote_set = 1;
14078 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
14080 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
14082 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
14084 else if (unformat (line_input, "vni %d", &vni))
14086 else if (unformat (line_input, "next-ip4"))
14088 else if (unformat (line_input, "next-ip6"))
14090 else if (unformat (line_input, "next-ethernet"))
14092 else if (unformat (line_input, "next-nsh"))
14096 errmsg ("parse error '%U'", format_unformat_error, line_input);
14101 if (local_set == 0)
14103 errmsg ("tunnel local address not specified");
14106 if (remote_set == 0)
14108 errmsg ("tunnel remote address not specified");
14111 if (grp_set && mcast_sw_if_index == ~0)
14113 errmsg ("tunnel nonexistent multicast device");
14116 if (ipv4_set && ipv6_set)
14118 errmsg ("both IPv4 and IPv6 addresses specified");
14124 errmsg ("vni not specified");
14128 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
14133 clib_memcpy (&mp->local, &local6, sizeof (local6));
14134 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
14138 clib_memcpy (&mp->local, &local4, sizeof (local4));
14139 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
14142 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
14143 mp->encap_vrf_id = ntohl (encap_vrf_id);
14144 mp->decap_vrf_id = ntohl (decap_vrf_id);
14145 mp->protocol = protocol;
14146 mp->vni = ntohl (vni);
14147 mp->is_add = is_add;
14148 mp->is_ipv6 = ipv6_set;
14155 static void vl_api_vxlan_gpe_tunnel_details_t_handler
14156 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14158 vat_main_t *vam = &vat_main;
14159 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
14160 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
14162 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
14163 ntohl (mp->sw_if_index),
14164 format_ip46_address, &local, IP46_TYPE_ANY,
14165 format_ip46_address, &remote, IP46_TYPE_ANY,
14166 ntohl (mp->vni), mp->protocol,
14167 ntohl (mp->mcast_sw_if_index),
14168 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
14172 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
14173 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14175 vat_main_t *vam = &vat_main;
14176 vat_json_node_t *node = NULL;
14177 struct in_addr ip4;
14178 struct in6_addr ip6;
14180 if (VAT_JSON_ARRAY != vam->json_tree.type)
14182 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14183 vat_json_init_array (&vam->json_tree);
14185 node = vat_json_array_add (&vam->json_tree);
14187 vat_json_init_object (node);
14188 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14191 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
14192 vat_json_object_add_ip6 (node, "local", ip6);
14193 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
14194 vat_json_object_add_ip6 (node, "remote", ip6);
14198 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
14199 vat_json_object_add_ip4 (node, "local", ip4);
14200 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
14201 vat_json_object_add_ip4 (node, "remote", ip4);
14203 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
14204 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
14205 vat_json_object_add_uint (node, "mcast_sw_if_index",
14206 ntohl (mp->mcast_sw_if_index));
14207 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
14208 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
14209 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
14213 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
14215 unformat_input_t *i = vam->input;
14216 vl_api_vxlan_gpe_tunnel_dump_t *mp;
14217 vl_api_control_ping_t *mp_ping;
14219 u8 sw_if_index_set = 0;
14222 /* Parse args required to build the message */
14223 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14225 if (unformat (i, "sw_if_index %d", &sw_if_index))
14226 sw_if_index_set = 1;
14231 if (sw_if_index_set == 0)
14236 if (!vam->json_output)
14238 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
14239 "sw_if_index", "local", "remote", "vni",
14240 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
14243 /* Get list of vxlan-tunnel interfaces */
14244 M (VXLAN_GPE_TUNNEL_DUMP, mp);
14246 mp->sw_if_index = htonl (sw_if_index);
14250 /* Use a control ping for synchronization */
14251 MPING (CONTROL_PING, mp_ping);
14258 static void vl_api_l2_fib_table_details_t_handler
14259 (vl_api_l2_fib_table_details_t * mp)
14261 vat_main_t *vam = &vat_main;
14263 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
14265 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
14266 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
14270 static void vl_api_l2_fib_table_details_t_handler_json
14271 (vl_api_l2_fib_table_details_t * mp)
14273 vat_main_t *vam = &vat_main;
14274 vat_json_node_t *node = NULL;
14276 if (VAT_JSON_ARRAY != vam->json_tree.type)
14278 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14279 vat_json_init_array (&vam->json_tree);
14281 node = vat_json_array_add (&vam->json_tree);
14283 vat_json_init_object (node);
14284 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
14285 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
14286 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14287 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
14288 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
14289 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
14293 api_l2_fib_table_dump (vat_main_t * vam)
14295 unformat_input_t *i = vam->input;
14296 vl_api_l2_fib_table_dump_t *mp;
14297 vl_api_control_ping_t *mp_ping;
14302 /* Parse args required to build the message */
14303 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14305 if (unformat (i, "bd_id %d", &bd_id))
14311 if (bd_id_set == 0)
14313 errmsg ("missing bridge domain");
14317 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
14319 /* Get list of l2 fib entries */
14320 M (L2_FIB_TABLE_DUMP, mp);
14322 mp->bd_id = ntohl (bd_id);
14325 /* Use a control ping for synchronization */
14326 MPING (CONTROL_PING, mp_ping);
14335 api_interface_name_renumber (vat_main_t * vam)
14337 unformat_input_t *line_input = vam->input;
14338 vl_api_interface_name_renumber_t *mp;
14339 u32 sw_if_index = ~0;
14340 u32 new_show_dev_instance = ~0;
14343 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14345 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
14348 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14350 else if (unformat (line_input, "new_show_dev_instance %d",
14351 &new_show_dev_instance))
14357 if (sw_if_index == ~0)
14359 errmsg ("missing interface name or sw_if_index");
14363 if (new_show_dev_instance == ~0)
14365 errmsg ("missing new_show_dev_instance");
14369 M (INTERFACE_NAME_RENUMBER, mp);
14371 mp->sw_if_index = ntohl (sw_if_index);
14372 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
14380 api_ip_probe_neighbor (vat_main_t * vam)
14382 unformat_input_t *i = vam->input;
14383 vl_api_ip_probe_neighbor_t *mp;
14391 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14393 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14395 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14397 else if (unformat (i, "address %U", unformat_ip4_address, dst_adr))
14399 else if (unformat (i, "address %U", unformat_ip6_address, dst_adr))
14410 errmsg ("missing interface");
14416 errmsg ("missing addresses");
14420 M (IP_PROBE_NEIGHBOR, mp);
14422 mp->sw_if_index = ntohl (sw_if_index);
14423 mp->is_ipv6 = is_ipv6;
14424 clib_memcpy (mp->dst_address, dst_adr, sizeof (dst_adr));
14432 api_ip_scan_neighbor_enable_disable (vat_main_t * vam)
14434 unformat_input_t *i = vam->input;
14435 vl_api_ip_scan_neighbor_enable_disable_t *mp;
14436 u8 mode = IP_SCAN_V46_NEIGHBORS;
14437 u32 interval = 0, time = 0, update = 0, delay = 0, stale = 0;
14440 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14442 if (unformat (i, "ip4"))
14443 mode = IP_SCAN_V4_NEIGHBORS;
14444 else if (unformat (i, "ip6"))
14445 mode = IP_SCAN_V6_NEIGHBORS;
14446 if (unformat (i, "both"))
14447 mode = IP_SCAN_V46_NEIGHBORS;
14448 else if (unformat (i, "disable"))
14449 mode = IP_SCAN_DISABLED;
14450 else if (unformat (i, "interval %d", &interval))
14452 else if (unformat (i, "max-time %d", &time))
14454 else if (unformat (i, "max-update %d", &update))
14456 else if (unformat (i, "delay %d", &delay))
14458 else if (unformat (i, "stale %d", &stale))
14464 if (interval > 255)
14466 errmsg ("interval cannot exceed 255 minutes.");
14471 errmsg ("max-time cannot exceed 255 usec.");
14476 errmsg ("max-update cannot exceed 255.");
14481 errmsg ("delay cannot exceed 255 msec.");
14486 errmsg ("stale cannot exceed 255 minutes.");
14490 M (IP_SCAN_NEIGHBOR_ENABLE_DISABLE, mp);
14492 mp->scan_interval = interval;
14493 mp->max_proc_time = time;
14494 mp->max_update = update;
14495 mp->scan_int_delay = delay;
14496 mp->stale_threshold = stale;
14504 api_want_ip4_arp_events (vat_main_t * vam)
14506 unformat_input_t *line_input = vam->input;
14507 vl_api_want_ip4_arp_events_t *mp;
14508 ip4_address_t address;
14509 int address_set = 0;
14510 u32 enable_disable = 1;
14513 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14515 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
14517 else if (unformat (line_input, "del"))
14518 enable_disable = 0;
14523 if (address_set == 0)
14525 errmsg ("missing addresses");
14529 M (WANT_IP4_ARP_EVENTS, mp);
14530 mp->enable_disable = enable_disable;
14531 mp->pid = htonl (getpid ());
14532 mp->address = address.as_u32;
14540 api_want_ip6_nd_events (vat_main_t * vam)
14542 unformat_input_t *line_input = vam->input;
14543 vl_api_want_ip6_nd_events_t *mp;
14544 ip6_address_t address;
14545 int address_set = 0;
14546 u32 enable_disable = 1;
14549 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14551 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
14553 else if (unformat (line_input, "del"))
14554 enable_disable = 0;
14559 if (address_set == 0)
14561 errmsg ("missing addresses");
14565 M (WANT_IP6_ND_EVENTS, mp);
14566 mp->enable_disable = enable_disable;
14567 mp->pid = htonl (getpid ());
14568 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
14576 api_want_l2_macs_events (vat_main_t * vam)
14578 unformat_input_t *line_input = vam->input;
14579 vl_api_want_l2_macs_events_t *mp;
14580 u8 enable_disable = 1;
14581 u32 scan_delay = 0;
14582 u32 max_macs_in_event = 0;
14583 u32 learn_limit = 0;
14586 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14588 if (unformat (line_input, "learn-limit %d", &learn_limit))
14590 else if (unformat (line_input, "scan-delay %d", &scan_delay))
14592 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
14594 else if (unformat (line_input, "disable"))
14595 enable_disable = 0;
14600 M (WANT_L2_MACS_EVENTS, mp);
14601 mp->enable_disable = enable_disable;
14602 mp->pid = htonl (getpid ());
14603 mp->learn_limit = htonl (learn_limit);
14604 mp->scan_delay = (u8) scan_delay;
14605 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
14612 api_input_acl_set_interface (vat_main_t * vam)
14614 unformat_input_t *i = vam->input;
14615 vl_api_input_acl_set_interface_t *mp;
14617 int sw_if_index_set;
14618 u32 ip4_table_index = ~0;
14619 u32 ip6_table_index = ~0;
14620 u32 l2_table_index = ~0;
14624 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14626 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14627 sw_if_index_set = 1;
14628 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14629 sw_if_index_set = 1;
14630 else if (unformat (i, "del"))
14632 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14634 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14636 else if (unformat (i, "l2-table %d", &l2_table_index))
14640 clib_warning ("parse error '%U'", format_unformat_error, i);
14645 if (sw_if_index_set == 0)
14647 errmsg ("missing interface name or sw_if_index");
14651 M (INPUT_ACL_SET_INTERFACE, mp);
14653 mp->sw_if_index = ntohl (sw_if_index);
14654 mp->ip4_table_index = ntohl (ip4_table_index);
14655 mp->ip6_table_index = ntohl (ip6_table_index);
14656 mp->l2_table_index = ntohl (l2_table_index);
14657 mp->is_add = is_add;
14665 api_output_acl_set_interface (vat_main_t * vam)
14667 unformat_input_t *i = vam->input;
14668 vl_api_output_acl_set_interface_t *mp;
14670 int sw_if_index_set;
14671 u32 ip4_table_index = ~0;
14672 u32 ip6_table_index = ~0;
14673 u32 l2_table_index = ~0;
14677 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14679 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14680 sw_if_index_set = 1;
14681 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14682 sw_if_index_set = 1;
14683 else if (unformat (i, "del"))
14685 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14687 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14689 else if (unformat (i, "l2-table %d", &l2_table_index))
14693 clib_warning ("parse error '%U'", format_unformat_error, i);
14698 if (sw_if_index_set == 0)
14700 errmsg ("missing interface name or sw_if_index");
14704 M (OUTPUT_ACL_SET_INTERFACE, mp);
14706 mp->sw_if_index = ntohl (sw_if_index);
14707 mp->ip4_table_index = ntohl (ip4_table_index);
14708 mp->ip6_table_index = ntohl (ip6_table_index);
14709 mp->l2_table_index = ntohl (l2_table_index);
14710 mp->is_add = is_add;
14718 api_ip_address_dump (vat_main_t * vam)
14720 unformat_input_t *i = vam->input;
14721 vl_api_ip_address_dump_t *mp;
14722 vl_api_control_ping_t *mp_ping;
14723 u32 sw_if_index = ~0;
14724 u8 sw_if_index_set = 0;
14729 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14731 if (unformat (i, "sw_if_index %d", &sw_if_index))
14732 sw_if_index_set = 1;
14734 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14735 sw_if_index_set = 1;
14736 else if (unformat (i, "ipv4"))
14738 else if (unformat (i, "ipv6"))
14744 if (ipv4_set && ipv6_set)
14746 errmsg ("ipv4 and ipv6 flags cannot be both set");
14750 if ((!ipv4_set) && (!ipv6_set))
14752 errmsg ("no ipv4 nor ipv6 flag set");
14756 if (sw_if_index_set == 0)
14758 errmsg ("missing interface name or sw_if_index");
14762 vam->current_sw_if_index = sw_if_index;
14763 vam->is_ipv6 = ipv6_set;
14765 M (IP_ADDRESS_DUMP, mp);
14766 mp->sw_if_index = ntohl (sw_if_index);
14767 mp->is_ipv6 = ipv6_set;
14770 /* Use a control ping for synchronization */
14771 MPING (CONTROL_PING, mp_ping);
14779 api_ip_dump (vat_main_t * vam)
14781 vl_api_ip_dump_t *mp;
14782 vl_api_control_ping_t *mp_ping;
14783 unformat_input_t *in = vam->input;
14790 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
14792 if (unformat (in, "ipv4"))
14794 else if (unformat (in, "ipv6"))
14800 if (ipv4_set && ipv6_set)
14802 errmsg ("ipv4 and ipv6 flags cannot be both set");
14806 if ((!ipv4_set) && (!ipv6_set))
14808 errmsg ("no ipv4 nor ipv6 flag set");
14812 is_ipv6 = ipv6_set;
14813 vam->is_ipv6 = is_ipv6;
14815 /* free old data */
14816 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
14818 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
14820 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
14823 mp->is_ipv6 = ipv6_set;
14826 /* Use a control ping for synchronization */
14827 MPING (CONTROL_PING, mp_ping);
14835 api_ipsec_spd_add_del (vat_main_t * vam)
14837 unformat_input_t *i = vam->input;
14838 vl_api_ipsec_spd_add_del_t *mp;
14843 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14845 if (unformat (i, "spd_id %d", &spd_id))
14847 else if (unformat (i, "del"))
14851 clib_warning ("parse error '%U'", format_unformat_error, i);
14857 errmsg ("spd_id must be set");
14861 M (IPSEC_SPD_ADD_DEL, mp);
14863 mp->spd_id = ntohl (spd_id);
14864 mp->is_add = is_add;
14872 api_ipsec_interface_add_del_spd (vat_main_t * vam)
14874 unformat_input_t *i = vam->input;
14875 vl_api_ipsec_interface_add_del_spd_t *mp;
14877 u8 sw_if_index_set = 0;
14878 u32 spd_id = (u32) ~ 0;
14882 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14884 if (unformat (i, "del"))
14886 else if (unformat (i, "spd_id %d", &spd_id))
14889 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14890 sw_if_index_set = 1;
14891 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14892 sw_if_index_set = 1;
14895 clib_warning ("parse error '%U'", format_unformat_error, i);
14901 if (spd_id == (u32) ~ 0)
14903 errmsg ("spd_id must be set");
14907 if (sw_if_index_set == 0)
14909 errmsg ("missing interface name or sw_if_index");
14913 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
14915 mp->spd_id = ntohl (spd_id);
14916 mp->sw_if_index = ntohl (sw_if_index);
14917 mp->is_add = is_add;
14925 api_ipsec_spd_add_del_entry (vat_main_t * vam)
14927 unformat_input_t *i = vam->input;
14928 vl_api_ipsec_spd_add_del_entry_t *mp;
14929 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
14930 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
14932 u32 rport_start = 0, rport_stop = (u32) ~ 0;
14933 u32 lport_start = 0, lport_stop = (u32) ~ 0;
14934 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
14935 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
14938 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
14939 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
14940 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
14941 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
14942 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
14943 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
14945 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14947 if (unformat (i, "del"))
14949 if (unformat (i, "outbound"))
14951 if (unformat (i, "inbound"))
14953 else if (unformat (i, "spd_id %d", &spd_id))
14955 else if (unformat (i, "sa_id %d", &sa_id))
14957 else if (unformat (i, "priority %d", &priority))
14959 else if (unformat (i, "protocol %d", &protocol))
14961 else if (unformat (i, "lport_start %d", &lport_start))
14963 else if (unformat (i, "lport_stop %d", &lport_stop))
14965 else if (unformat (i, "rport_start %d", &rport_start))
14967 else if (unformat (i, "rport_stop %d", &rport_stop))
14971 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
14977 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
14984 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
14990 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
14997 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
15003 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
15010 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
15016 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
15022 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
15024 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
15026 clib_warning ("unsupported action: 'resolve'");
15032 clib_warning ("parse error '%U'", format_unformat_error, i);
15038 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
15040 mp->spd_id = ntohl (spd_id);
15041 mp->priority = ntohl (priority);
15042 mp->is_outbound = is_outbound;
15044 mp->is_ipv6 = is_ipv6;
15045 if (is_ipv6 || is_ip_any)
15047 clib_memcpy (mp->remote_address_start, &raddr6_start,
15048 sizeof (ip6_address_t));
15049 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
15050 sizeof (ip6_address_t));
15051 clib_memcpy (mp->local_address_start, &laddr6_start,
15052 sizeof (ip6_address_t));
15053 clib_memcpy (mp->local_address_stop, &laddr6_stop,
15054 sizeof (ip6_address_t));
15058 clib_memcpy (mp->remote_address_start, &raddr4_start,
15059 sizeof (ip4_address_t));
15060 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
15061 sizeof (ip4_address_t));
15062 clib_memcpy (mp->local_address_start, &laddr4_start,
15063 sizeof (ip4_address_t));
15064 clib_memcpy (mp->local_address_stop, &laddr4_stop,
15065 sizeof (ip4_address_t));
15067 mp->protocol = (u8) protocol;
15068 mp->local_port_start = ntohs ((u16) lport_start);
15069 mp->local_port_stop = ntohs ((u16) lport_stop);
15070 mp->remote_port_start = ntohs ((u16) rport_start);
15071 mp->remote_port_stop = ntohs ((u16) rport_stop);
15072 mp->policy = (u8) policy;
15073 mp->sa_id = ntohl (sa_id);
15074 mp->is_add = is_add;
15075 mp->is_ip_any = is_ip_any;
15082 api_ipsec_sad_add_del_entry (vat_main_t * vam)
15084 unformat_input_t *i = vam->input;
15085 vl_api_ipsec_sad_add_del_entry_t *mp;
15086 u32 sad_id = 0, spi = 0;
15087 u8 *ck = 0, *ik = 0;
15090 u8 protocol = IPSEC_PROTOCOL_AH;
15091 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
15092 u32 crypto_alg = 0, integ_alg = 0;
15093 ip4_address_t tun_src4;
15094 ip4_address_t tun_dst4;
15095 ip6_address_t tun_src6;
15096 ip6_address_t tun_dst6;
15099 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15101 if (unformat (i, "del"))
15103 else if (unformat (i, "sad_id %d", &sad_id))
15105 else if (unformat (i, "spi %d", &spi))
15107 else if (unformat (i, "esp"))
15108 protocol = IPSEC_PROTOCOL_ESP;
15109 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
15112 is_tunnel_ipv6 = 0;
15114 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
15117 is_tunnel_ipv6 = 0;
15119 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
15122 is_tunnel_ipv6 = 1;
15124 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
15127 is_tunnel_ipv6 = 1;
15131 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15133 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
15135 clib_warning ("unsupported crypto-alg: '%U'",
15136 format_ipsec_crypto_alg, crypto_alg);
15140 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15144 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15146 if (integ_alg >= IPSEC_INTEG_N_ALG)
15148 clib_warning ("unsupported integ-alg: '%U'",
15149 format_ipsec_integ_alg, integ_alg);
15153 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15157 clib_warning ("parse error '%U'", format_unformat_error, i);
15163 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
15165 mp->sad_id = ntohl (sad_id);
15166 mp->is_add = is_add;
15167 mp->protocol = protocol;
15168 mp->spi = ntohl (spi);
15169 mp->is_tunnel = is_tunnel;
15170 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
15171 mp->crypto_algorithm = crypto_alg;
15172 mp->integrity_algorithm = integ_alg;
15173 mp->crypto_key_length = vec_len (ck);
15174 mp->integrity_key_length = vec_len (ik);
15176 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15177 mp->crypto_key_length = sizeof (mp->crypto_key);
15179 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15180 mp->integrity_key_length = sizeof (mp->integrity_key);
15183 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15185 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15189 if (is_tunnel_ipv6)
15191 clib_memcpy (mp->tunnel_src_address, &tun_src6,
15192 sizeof (ip6_address_t));
15193 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
15194 sizeof (ip6_address_t));
15198 clib_memcpy (mp->tunnel_src_address, &tun_src4,
15199 sizeof (ip4_address_t));
15200 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
15201 sizeof (ip4_address_t));
15211 api_ipsec_sa_set_key (vat_main_t * vam)
15213 unformat_input_t *i = vam->input;
15214 vl_api_ipsec_sa_set_key_t *mp;
15216 u8 *ck = 0, *ik = 0;
15219 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15221 if (unformat (i, "sa_id %d", &sa_id))
15223 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15225 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15229 clib_warning ("parse error '%U'", format_unformat_error, i);
15234 M (IPSEC_SA_SET_KEY, mp);
15236 mp->sa_id = ntohl (sa_id);
15237 mp->crypto_key_length = vec_len (ck);
15238 mp->integrity_key_length = vec_len (ik);
15240 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15241 mp->crypto_key_length = sizeof (mp->crypto_key);
15243 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15244 mp->integrity_key_length = sizeof (mp->integrity_key);
15247 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15249 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15257 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
15259 unformat_input_t *i = vam->input;
15260 vl_api_ipsec_tunnel_if_add_del_t *mp;
15261 u32 local_spi = 0, remote_spi = 0;
15262 u32 crypto_alg = 0, integ_alg = 0;
15263 u8 *lck = NULL, *rck = NULL;
15264 u8 *lik = NULL, *rik = NULL;
15265 ip4_address_t local_ip = { {0} };
15266 ip4_address_t remote_ip = { {0} };
15269 u8 anti_replay = 0;
15274 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15276 if (unformat (i, "del"))
15278 else if (unformat (i, "esn"))
15280 else if (unformat (i, "anti_replay"))
15282 else if (unformat (i, "local_spi %d", &local_spi))
15284 else if (unformat (i, "remote_spi %d", &remote_spi))
15286 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
15288 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
15290 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
15293 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
15295 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
15297 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
15301 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15303 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
15305 errmsg ("unsupported crypto-alg: '%U'\n",
15306 format_ipsec_crypto_alg, crypto_alg);
15312 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15314 if (integ_alg >= IPSEC_INTEG_N_ALG)
15316 errmsg ("unsupported integ-alg: '%U'\n",
15317 format_ipsec_integ_alg, integ_alg);
15321 else if (unformat (i, "instance %u", &instance))
15325 errmsg ("parse error '%U'\n", format_unformat_error, i);
15330 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
15332 mp->is_add = is_add;
15334 mp->anti_replay = anti_replay;
15336 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
15337 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
15339 mp->local_spi = htonl (local_spi);
15340 mp->remote_spi = htonl (remote_spi);
15341 mp->crypto_alg = (u8) crypto_alg;
15343 mp->local_crypto_key_len = 0;
15346 mp->local_crypto_key_len = vec_len (lck);
15347 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
15348 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
15349 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
15352 mp->remote_crypto_key_len = 0;
15355 mp->remote_crypto_key_len = vec_len (rck);
15356 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
15357 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
15358 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
15361 mp->integ_alg = (u8) integ_alg;
15363 mp->local_integ_key_len = 0;
15366 mp->local_integ_key_len = vec_len (lik);
15367 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
15368 mp->local_integ_key_len = sizeof (mp->local_integ_key);
15369 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
15372 mp->remote_integ_key_len = 0;
15375 mp->remote_integ_key_len = vec_len (rik);
15376 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
15377 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
15378 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
15383 mp->renumber = renumber;
15384 mp->show_instance = ntohl (instance);
15393 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
15395 vat_main_t *vam = &vat_main;
15397 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
15398 "crypto_key %U integ_alg %u integ_key %U use_esn %u "
15399 "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u "
15400 "tunnel_src_addr %U tunnel_dst_addr %U "
15401 "salt %u seq_outbound %lu last_seq_inbound %lu "
15402 "replay_window %lu total_data_size %lu\n",
15403 ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi),
15405 mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len,
15406 mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len,
15407 mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6,
15408 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15409 mp->tunnel_src_addr,
15410 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15411 mp->tunnel_dst_addr,
15413 clib_net_to_host_u64 (mp->seq_outbound),
15414 clib_net_to_host_u64 (mp->last_seq_inbound),
15415 clib_net_to_host_u64 (mp->replay_window),
15416 clib_net_to_host_u64 (mp->total_data_size));
15419 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
15420 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
15422 static void vl_api_ipsec_sa_details_t_handler_json
15423 (vl_api_ipsec_sa_details_t * mp)
15425 vat_main_t *vam = &vat_main;
15426 vat_json_node_t *node = NULL;
15427 struct in_addr src_ip4, dst_ip4;
15428 struct in6_addr src_ip6, dst_ip6;
15430 if (VAT_JSON_ARRAY != vam->json_tree.type)
15432 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15433 vat_json_init_array (&vam->json_tree);
15435 node = vat_json_array_add (&vam->json_tree);
15437 vat_json_init_object (node);
15438 vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id));
15439 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
15440 vat_json_object_add_uint (node, "spi", ntohl (mp->spi));
15441 vat_json_object_add_uint (node, "proto", mp->protocol);
15442 vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg);
15443 vat_json_object_add_uint (node, "integ_alg", mp->integ_alg);
15444 vat_json_object_add_uint (node, "use_esn", mp->use_esn);
15445 vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay);
15446 vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel);
15447 vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6);
15448 vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key,
15449 mp->crypto_key_len);
15450 vat_json_object_add_bytes (node, "integ_key", mp->integ_key,
15451 mp->integ_key_len);
15452 if (mp->is_tunnel_ip6)
15454 clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6));
15455 vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6);
15456 clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6));
15457 vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6);
15461 clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4));
15462 vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4);
15463 clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4));
15464 vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4);
15466 vat_json_object_add_uint (node, "replay_window",
15467 clib_net_to_host_u64 (mp->replay_window));
15468 vat_json_object_add_uint (node, "total_data_size",
15469 clib_net_to_host_u64 (mp->total_data_size));
15474 api_ipsec_sa_dump (vat_main_t * vam)
15476 unformat_input_t *i = vam->input;
15477 vl_api_ipsec_sa_dump_t *mp;
15478 vl_api_control_ping_t *mp_ping;
15482 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15484 if (unformat (i, "sa_id %d", &sa_id))
15488 clib_warning ("parse error '%U'", format_unformat_error, i);
15493 M (IPSEC_SA_DUMP, mp);
15495 mp->sa_id = ntohl (sa_id);
15499 /* Use a control ping for synchronization */
15500 M (CONTROL_PING, mp_ping);
15508 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
15510 unformat_input_t *i = vam->input;
15511 vl_api_ipsec_tunnel_if_set_key_t *mp;
15512 u32 sw_if_index = ~0;
15513 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
15518 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15520 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15523 if (unformat (i, "local crypto %U", unformat_ipsec_crypto_alg, &alg))
15524 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
15526 if (unformat (i, "remote crypto %U", unformat_ipsec_crypto_alg, &alg))
15527 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
15528 else if (unformat (i, "local integ %U", unformat_ipsec_integ_alg, &alg))
15529 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
15531 if (unformat (i, "remote integ %U", unformat_ipsec_integ_alg, &alg))
15532 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
15533 else if (unformat (i, "%U", unformat_hex_string, &key))
15537 clib_warning ("parse error '%U'", format_unformat_error, i);
15542 if (sw_if_index == ~0)
15544 errmsg ("interface must be specified");
15548 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
15550 errmsg ("key type must be specified");
15556 errmsg ("algorithm must be specified");
15560 if (vec_len (key) == 0)
15562 errmsg ("key must be specified");
15566 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
15568 mp->sw_if_index = htonl (sw_if_index);
15570 mp->key_type = key_type;
15571 mp->key_len = vec_len (key);
15572 clib_memcpy (mp->key, key, vec_len (key));
15581 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
15583 unformat_input_t *i = vam->input;
15584 vl_api_ipsec_tunnel_if_set_sa_t *mp;
15585 u32 sw_if_index = ~0;
15587 u8 is_outbound = (u8) ~ 0;
15590 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15592 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15594 else if (unformat (i, "sa_id %d", &sa_id))
15596 else if (unformat (i, "outbound"))
15598 else if (unformat (i, "inbound"))
15602 clib_warning ("parse error '%U'", format_unformat_error, i);
15607 if (sw_if_index == ~0)
15609 errmsg ("interface must be specified");
15615 errmsg ("SA ID must be specified");
15619 M (IPSEC_TUNNEL_IF_SET_SA, mp);
15621 mp->sw_if_index = htonl (sw_if_index);
15622 mp->sa_id = htonl (sa_id);
15623 mp->is_outbound = is_outbound;
15632 api_ikev2_profile_add_del (vat_main_t * vam)
15634 unformat_input_t *i = vam->input;
15635 vl_api_ikev2_profile_add_del_t *mp;
15640 const char *valid_chars = "a-zA-Z0-9_";
15642 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15644 if (unformat (i, "del"))
15646 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15647 vec_add1 (name, 0);
15650 errmsg ("parse error '%U'", format_unformat_error, i);
15655 if (!vec_len (name))
15657 errmsg ("profile name must be specified");
15661 if (vec_len (name) > 64)
15663 errmsg ("profile name too long");
15667 M (IKEV2_PROFILE_ADD_DEL, mp);
15669 clib_memcpy (mp->name, name, vec_len (name));
15670 mp->is_add = is_add;
15679 api_ikev2_profile_set_auth (vat_main_t * vam)
15681 unformat_input_t *i = vam->input;
15682 vl_api_ikev2_profile_set_auth_t *mp;
15685 u32 auth_method = 0;
15689 const char *valid_chars = "a-zA-Z0-9_";
15691 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15693 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15694 vec_add1 (name, 0);
15695 else if (unformat (i, "auth_method %U",
15696 unformat_ikev2_auth_method, &auth_method))
15698 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
15700 else if (unformat (i, "auth_data %v", &data))
15704 errmsg ("parse error '%U'", format_unformat_error, i);
15709 if (!vec_len (name))
15711 errmsg ("profile name must be specified");
15715 if (vec_len (name) > 64)
15717 errmsg ("profile name too long");
15721 if (!vec_len (data))
15723 errmsg ("auth_data must be specified");
15729 errmsg ("auth_method must be specified");
15733 M (IKEV2_PROFILE_SET_AUTH, mp);
15735 mp->is_hex = is_hex;
15736 mp->auth_method = (u8) auth_method;
15737 mp->data_len = vec_len (data);
15738 clib_memcpy (mp->name, name, vec_len (name));
15739 clib_memcpy (mp->data, data, vec_len (data));
15749 api_ikev2_profile_set_id (vat_main_t * vam)
15751 unformat_input_t *i = vam->input;
15752 vl_api_ikev2_profile_set_id_t *mp;
15760 const char *valid_chars = "a-zA-Z0-9_";
15762 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15764 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15765 vec_add1 (name, 0);
15766 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
15768 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
15770 data = vec_new (u8, 4);
15771 clib_memcpy (data, ip4.as_u8, 4);
15773 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
15775 else if (unformat (i, "id_data %v", &data))
15777 else if (unformat (i, "local"))
15779 else if (unformat (i, "remote"))
15783 errmsg ("parse error '%U'", format_unformat_error, i);
15788 if (!vec_len (name))
15790 errmsg ("profile name must be specified");
15794 if (vec_len (name) > 64)
15796 errmsg ("profile name too long");
15800 if (!vec_len (data))
15802 errmsg ("id_data must be specified");
15808 errmsg ("id_type must be specified");
15812 M (IKEV2_PROFILE_SET_ID, mp);
15814 mp->is_local = is_local;
15815 mp->id_type = (u8) id_type;
15816 mp->data_len = vec_len (data);
15817 clib_memcpy (mp->name, name, vec_len (name));
15818 clib_memcpy (mp->data, data, vec_len (data));
15828 api_ikev2_profile_set_ts (vat_main_t * vam)
15830 unformat_input_t *i = vam->input;
15831 vl_api_ikev2_profile_set_ts_t *mp;
15834 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
15835 ip4_address_t start_addr, end_addr;
15837 const char *valid_chars = "a-zA-Z0-9_";
15840 start_addr.as_u32 = 0;
15841 end_addr.as_u32 = (u32) ~ 0;
15843 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15845 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15846 vec_add1 (name, 0);
15847 else if (unformat (i, "protocol %d", &proto))
15849 else if (unformat (i, "start_port %d", &start_port))
15851 else if (unformat (i, "end_port %d", &end_port))
15854 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
15856 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
15858 else if (unformat (i, "local"))
15860 else if (unformat (i, "remote"))
15864 errmsg ("parse error '%U'", format_unformat_error, i);
15869 if (!vec_len (name))
15871 errmsg ("profile name must be specified");
15875 if (vec_len (name) > 64)
15877 errmsg ("profile name too long");
15881 M (IKEV2_PROFILE_SET_TS, mp);
15883 mp->is_local = is_local;
15884 mp->proto = (u8) proto;
15885 mp->start_port = (u16) start_port;
15886 mp->end_port = (u16) end_port;
15887 mp->start_addr = start_addr.as_u32;
15888 mp->end_addr = end_addr.as_u32;
15889 clib_memcpy (mp->name, name, vec_len (name));
15898 api_ikev2_set_local_key (vat_main_t * vam)
15900 unformat_input_t *i = vam->input;
15901 vl_api_ikev2_set_local_key_t *mp;
15905 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15907 if (unformat (i, "file %v", &file))
15908 vec_add1 (file, 0);
15911 errmsg ("parse error '%U'", format_unformat_error, i);
15916 if (!vec_len (file))
15918 errmsg ("RSA key file must be specified");
15922 if (vec_len (file) > 256)
15924 errmsg ("file name too long");
15928 M (IKEV2_SET_LOCAL_KEY, mp);
15930 clib_memcpy (mp->key_file, file, vec_len (file));
15939 api_ikev2_set_responder (vat_main_t * vam)
15941 unformat_input_t *i = vam->input;
15942 vl_api_ikev2_set_responder_t *mp;
15945 u32 sw_if_index = ~0;
15946 ip4_address_t address;
15948 const char *valid_chars = "a-zA-Z0-9_";
15950 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15953 (i, "%U interface %d address %U", unformat_token, valid_chars,
15954 &name, &sw_if_index, unformat_ip4_address, &address))
15955 vec_add1 (name, 0);
15958 errmsg ("parse error '%U'", format_unformat_error, i);
15963 if (!vec_len (name))
15965 errmsg ("profile name must be specified");
15969 if (vec_len (name) > 64)
15971 errmsg ("profile name too long");
15975 M (IKEV2_SET_RESPONDER, mp);
15977 clib_memcpy (mp->name, name, vec_len (name));
15980 mp->sw_if_index = sw_if_index;
15981 clib_memcpy (mp->address, &address, sizeof (address));
15989 api_ikev2_set_ike_transforms (vat_main_t * vam)
15991 unformat_input_t *i = vam->input;
15992 vl_api_ikev2_set_ike_transforms_t *mp;
15995 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
15997 const char *valid_chars = "a-zA-Z0-9_";
15999 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16001 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
16002 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
16003 vec_add1 (name, 0);
16006 errmsg ("parse error '%U'", format_unformat_error, i);
16011 if (!vec_len (name))
16013 errmsg ("profile name must be specified");
16017 if (vec_len (name) > 64)
16019 errmsg ("profile name too long");
16023 M (IKEV2_SET_IKE_TRANSFORMS, mp);
16025 clib_memcpy (mp->name, name, vec_len (name));
16027 mp->crypto_alg = crypto_alg;
16028 mp->crypto_key_size = crypto_key_size;
16029 mp->integ_alg = integ_alg;
16030 mp->dh_group = dh_group;
16039 api_ikev2_set_esp_transforms (vat_main_t * vam)
16041 unformat_input_t *i = vam->input;
16042 vl_api_ikev2_set_esp_transforms_t *mp;
16045 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
16047 const char *valid_chars = "a-zA-Z0-9_";
16049 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16051 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
16052 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
16053 vec_add1 (name, 0);
16056 errmsg ("parse error '%U'", format_unformat_error, i);
16061 if (!vec_len (name))
16063 errmsg ("profile name must be specified");
16067 if (vec_len (name) > 64)
16069 errmsg ("profile name too long");
16073 M (IKEV2_SET_ESP_TRANSFORMS, mp);
16075 clib_memcpy (mp->name, name, vec_len (name));
16077 mp->crypto_alg = crypto_alg;
16078 mp->crypto_key_size = crypto_key_size;
16079 mp->integ_alg = integ_alg;
16080 mp->dh_group = dh_group;
16088 api_ikev2_set_sa_lifetime (vat_main_t * vam)
16090 unformat_input_t *i = vam->input;
16091 vl_api_ikev2_set_sa_lifetime_t *mp;
16094 u64 lifetime, lifetime_maxdata;
16095 u32 lifetime_jitter, handover;
16097 const char *valid_chars = "a-zA-Z0-9_";
16099 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16101 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
16102 &lifetime, &lifetime_jitter, &handover,
16103 &lifetime_maxdata))
16104 vec_add1 (name, 0);
16107 errmsg ("parse error '%U'", format_unformat_error, i);
16112 if (!vec_len (name))
16114 errmsg ("profile name must be specified");
16118 if (vec_len (name) > 64)
16120 errmsg ("profile name too long");
16124 M (IKEV2_SET_SA_LIFETIME, mp);
16126 clib_memcpy (mp->name, name, vec_len (name));
16128 mp->lifetime = lifetime;
16129 mp->lifetime_jitter = lifetime_jitter;
16130 mp->handover = handover;
16131 mp->lifetime_maxdata = lifetime_maxdata;
16139 api_ikev2_initiate_sa_init (vat_main_t * vam)
16141 unformat_input_t *i = vam->input;
16142 vl_api_ikev2_initiate_sa_init_t *mp;
16146 const char *valid_chars = "a-zA-Z0-9_";
16148 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16150 if (unformat (i, "%U", unformat_token, valid_chars, &name))
16151 vec_add1 (name, 0);
16154 errmsg ("parse error '%U'", format_unformat_error, i);
16159 if (!vec_len (name))
16161 errmsg ("profile name must be specified");
16165 if (vec_len (name) > 64)
16167 errmsg ("profile name too long");
16171 M (IKEV2_INITIATE_SA_INIT, mp);
16173 clib_memcpy (mp->name, name, vec_len (name));
16182 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
16184 unformat_input_t *i = vam->input;
16185 vl_api_ikev2_initiate_del_ike_sa_t *mp;
16190 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16192 if (unformat (i, "%lx", &ispi))
16196 errmsg ("parse error '%U'", format_unformat_error, i);
16201 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
16211 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
16213 unformat_input_t *i = vam->input;
16214 vl_api_ikev2_initiate_del_child_sa_t *mp;
16219 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16221 if (unformat (i, "%x", &ispi))
16225 errmsg ("parse error '%U'", format_unformat_error, i);
16230 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
16240 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
16242 unformat_input_t *i = vam->input;
16243 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
16248 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16250 if (unformat (i, "%x", &ispi))
16254 errmsg ("parse error '%U'", format_unformat_error, i);
16259 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
16269 api_get_first_msg_id (vat_main_t * vam)
16271 vl_api_get_first_msg_id_t *mp;
16272 unformat_input_t *i = vam->input;
16277 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16279 if (unformat (i, "client %s", &name))
16287 errmsg ("missing client name");
16290 vec_add1 (name, 0);
16292 if (vec_len (name) > 63)
16294 errmsg ("client name too long");
16298 M (GET_FIRST_MSG_ID, mp);
16299 clib_memcpy (mp->name, name, vec_len (name));
16306 api_cop_interface_enable_disable (vat_main_t * vam)
16308 unformat_input_t *line_input = vam->input;
16309 vl_api_cop_interface_enable_disable_t *mp;
16310 u32 sw_if_index = ~0;
16311 u8 enable_disable = 1;
16314 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16316 if (unformat (line_input, "disable"))
16317 enable_disable = 0;
16318 if (unformat (line_input, "enable"))
16319 enable_disable = 1;
16320 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16321 vam, &sw_if_index))
16323 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16329 if (sw_if_index == ~0)
16331 errmsg ("missing interface name or sw_if_index");
16335 /* Construct the API message */
16336 M (COP_INTERFACE_ENABLE_DISABLE, mp);
16337 mp->sw_if_index = ntohl (sw_if_index);
16338 mp->enable_disable = enable_disable;
16342 /* Wait for the reply */
16348 api_cop_whitelist_enable_disable (vat_main_t * vam)
16350 unformat_input_t *line_input = vam->input;
16351 vl_api_cop_whitelist_enable_disable_t *mp;
16352 u32 sw_if_index = ~0;
16353 u8 ip4 = 0, ip6 = 0, default_cop = 0;
16357 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16359 if (unformat (line_input, "ip4"))
16361 else if (unformat (line_input, "ip6"))
16363 else if (unformat (line_input, "default"))
16365 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16366 vam, &sw_if_index))
16368 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16370 else if (unformat (line_input, "fib-id %d", &fib_id))
16376 if (sw_if_index == ~0)
16378 errmsg ("missing interface name or sw_if_index");
16382 /* Construct the API message */
16383 M (COP_WHITELIST_ENABLE_DISABLE, mp);
16384 mp->sw_if_index = ntohl (sw_if_index);
16385 mp->fib_id = ntohl (fib_id);
16388 mp->default_cop = default_cop;
16392 /* Wait for the reply */
16398 api_get_node_graph (vat_main_t * vam)
16400 vl_api_get_node_graph_t *mp;
16403 M (GET_NODE_GRAPH, mp);
16407 /* Wait for the reply */
16413 /** Used for parsing LISP eids */
16414 typedef CLIB_PACKED(struct{
16415 u8 addr[16]; /**< eid address */
16416 u32 len; /**< prefix length if IP */
16417 u8 type; /**< type of eid */
16422 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
16424 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
16426 memset (a, 0, sizeof (a[0]));
16428 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
16430 a->type = 0; /* ipv4 type */
16432 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
16434 a->type = 1; /* ipv6 type */
16436 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
16438 a->type = 2; /* mac type */
16440 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
16442 a->type = 3; /* NSH type */
16443 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
16444 nsh->spi = clib_host_to_net_u32 (nsh->spi);
16451 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
16460 lisp_eid_size_vat (u8 type)
16477 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
16479 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
16483 api_one_add_del_locator_set (vat_main_t * vam)
16485 unformat_input_t *input = vam->input;
16486 vl_api_one_add_del_locator_set_t *mp;
16488 u8 *locator_set_name = NULL;
16489 u8 locator_set_name_set = 0;
16490 vl_api_local_locator_t locator, *locators = 0;
16491 u32 sw_if_index, priority, weight;
16495 /* Parse args required to build the message */
16496 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16498 if (unformat (input, "del"))
16502 else if (unformat (input, "locator-set %s", &locator_set_name))
16504 locator_set_name_set = 1;
16506 else if (unformat (input, "sw_if_index %u p %u w %u",
16507 &sw_if_index, &priority, &weight))
16509 locator.sw_if_index = htonl (sw_if_index);
16510 locator.priority = priority;
16511 locator.weight = weight;
16512 vec_add1 (locators, locator);
16516 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
16517 &sw_if_index, &priority, &weight))
16519 locator.sw_if_index = htonl (sw_if_index);
16520 locator.priority = priority;
16521 locator.weight = weight;
16522 vec_add1 (locators, locator);
16528 if (locator_set_name_set == 0)
16530 errmsg ("missing locator-set name");
16531 vec_free (locators);
16535 if (vec_len (locator_set_name) > 64)
16537 errmsg ("locator-set name too long");
16538 vec_free (locator_set_name);
16539 vec_free (locators);
16542 vec_add1 (locator_set_name, 0);
16544 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
16546 /* Construct the API message */
16547 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
16549 mp->is_add = is_add;
16550 clib_memcpy (mp->locator_set_name, locator_set_name,
16551 vec_len (locator_set_name));
16552 vec_free (locator_set_name);
16554 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
16556 clib_memcpy (mp->locators, locators, data_len);
16557 vec_free (locators);
16562 /* Wait for a reply... */
16567 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
16570 api_one_add_del_locator (vat_main_t * vam)
16572 unformat_input_t *input = vam->input;
16573 vl_api_one_add_del_locator_t *mp;
16574 u32 tmp_if_index = ~0;
16575 u32 sw_if_index = ~0;
16576 u8 sw_if_index_set = 0;
16577 u8 sw_if_index_if_name_set = 0;
16579 u8 priority_set = 0;
16583 u8 *locator_set_name = NULL;
16584 u8 locator_set_name_set = 0;
16587 /* Parse args required to build the message */
16588 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16590 if (unformat (input, "del"))
16594 else if (unformat (input, "locator-set %s", &locator_set_name))
16596 locator_set_name_set = 1;
16598 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
16601 sw_if_index_if_name_set = 1;
16602 sw_if_index = tmp_if_index;
16604 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
16606 sw_if_index_set = 1;
16607 sw_if_index = tmp_if_index;
16609 else if (unformat (input, "p %d", &priority))
16613 else if (unformat (input, "w %d", &weight))
16621 if (locator_set_name_set == 0)
16623 errmsg ("missing locator-set name");
16627 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
16629 errmsg ("missing sw_if_index");
16630 vec_free (locator_set_name);
16634 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
16636 errmsg ("cannot use both params interface name and sw_if_index");
16637 vec_free (locator_set_name);
16641 if (priority_set == 0)
16643 errmsg ("missing locator-set priority");
16644 vec_free (locator_set_name);
16648 if (weight_set == 0)
16650 errmsg ("missing locator-set weight");
16651 vec_free (locator_set_name);
16655 if (vec_len (locator_set_name) > 64)
16657 errmsg ("locator-set name too long");
16658 vec_free (locator_set_name);
16661 vec_add1 (locator_set_name, 0);
16663 /* Construct the API message */
16664 M (ONE_ADD_DEL_LOCATOR, mp);
16666 mp->is_add = is_add;
16667 mp->sw_if_index = ntohl (sw_if_index);
16668 mp->priority = priority;
16669 mp->weight = weight;
16670 clib_memcpy (mp->locator_set_name, locator_set_name,
16671 vec_len (locator_set_name));
16672 vec_free (locator_set_name);
16677 /* Wait for a reply... */
16682 #define api_lisp_add_del_locator api_one_add_del_locator
16685 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
16687 u32 *key_id = va_arg (*args, u32 *);
16690 if (unformat (input, "%s", &s))
16692 if (!strcmp ((char *) s, "sha1"))
16693 key_id[0] = HMAC_SHA_1_96;
16694 else if (!strcmp ((char *) s, "sha256"))
16695 key_id[0] = HMAC_SHA_256_128;
16698 clib_warning ("invalid key_id: '%s'", s);
16699 key_id[0] = HMAC_NO_KEY;
16710 api_one_add_del_local_eid (vat_main_t * vam)
16712 unformat_input_t *input = vam->input;
16713 vl_api_one_add_del_local_eid_t *mp;
16716 lisp_eid_vat_t _eid, *eid = &_eid;
16717 u8 *locator_set_name = 0;
16718 u8 locator_set_name_set = 0;
16724 /* Parse args required to build the message */
16725 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16727 if (unformat (input, "del"))
16731 else if (unformat (input, "vni %d", &vni))
16735 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
16739 else if (unformat (input, "locator-set %s", &locator_set_name))
16741 locator_set_name_set = 1;
16743 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
16745 else if (unformat (input, "secret-key %_%v%_", &key))
16751 if (locator_set_name_set == 0)
16753 errmsg ("missing locator-set name");
16759 errmsg ("EID address not set!");
16760 vec_free (locator_set_name);
16764 if (key && (0 == key_id))
16766 errmsg ("invalid key_id!");
16770 if (vec_len (key) > 64)
16772 errmsg ("key too long");
16777 if (vec_len (locator_set_name) > 64)
16779 errmsg ("locator-set name too long");
16780 vec_free (locator_set_name);
16783 vec_add1 (locator_set_name, 0);
16785 /* Construct the API message */
16786 M (ONE_ADD_DEL_LOCAL_EID, mp);
16788 mp->is_add = is_add;
16789 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
16790 mp->eid_type = eid->type;
16791 mp->prefix_len = eid->len;
16792 mp->vni = clib_host_to_net_u32 (vni);
16793 mp->key_id = clib_host_to_net_u16 (key_id);
16794 clib_memcpy (mp->locator_set_name, locator_set_name,
16795 vec_len (locator_set_name));
16796 clib_memcpy (mp->key, key, vec_len (key));
16798 vec_free (locator_set_name);
16804 /* Wait for a reply... */
16809 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
16812 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
16814 u32 dp_table = 0, vni = 0;;
16815 unformat_input_t *input = vam->input;
16816 vl_api_gpe_add_del_fwd_entry_t *mp;
16818 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
16819 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
16820 u8 rmt_eid_set = 0, lcl_eid_set = 0;
16821 u32 action = ~0, w;
16822 ip4_address_t rmt_rloc4, lcl_rloc4;
16823 ip6_address_t rmt_rloc6, lcl_rloc6;
16824 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
16827 memset (&rloc, 0, sizeof (rloc));
16829 /* Parse args required to build the message */
16830 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16832 if (unformat (input, "del"))
16834 else if (unformat (input, "add"))
16836 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
16840 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
16844 else if (unformat (input, "vrf %d", &dp_table))
16846 else if (unformat (input, "bd %d", &dp_table))
16848 else if (unformat (input, "vni %d", &vni))
16850 else if (unformat (input, "w %d", &w))
16854 errmsg ("No RLOC configured for setting priority/weight!");
16857 curr_rloc->weight = w;
16859 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
16860 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
16864 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
16866 vec_add1 (lcl_locs, rloc);
16868 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
16869 vec_add1 (rmt_locs, rloc);
16870 /* weight saved in rmt loc */
16871 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
16873 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
16874 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
16877 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
16879 vec_add1 (lcl_locs, rloc);
16881 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
16882 vec_add1 (rmt_locs, rloc);
16883 /* weight saved in rmt loc */
16884 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
16886 else if (unformat (input, "action %d", &action))
16892 clib_warning ("parse error '%U'", format_unformat_error, input);
16899 errmsg ("remote eid addresses not set");
16903 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
16905 errmsg ("eid types don't match");
16909 if (0 == rmt_locs && (u32) ~ 0 == action)
16911 errmsg ("action not set for negative mapping");
16915 /* Construct the API message */
16916 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
16917 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
16919 mp->is_add = is_add;
16920 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
16921 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
16922 mp->eid_type = rmt_eid->type;
16923 mp->dp_table = clib_host_to_net_u32 (dp_table);
16924 mp->vni = clib_host_to_net_u32 (vni);
16925 mp->rmt_len = rmt_eid->len;
16926 mp->lcl_len = lcl_eid->len;
16927 mp->action = action;
16929 if (0 != rmt_locs && 0 != lcl_locs)
16931 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
16932 clib_memcpy (mp->locs, lcl_locs,
16933 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
16935 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
16936 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
16937 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
16939 vec_free (lcl_locs);
16940 vec_free (rmt_locs);
16945 /* Wait for a reply... */
16951 api_one_add_del_map_server (vat_main_t * vam)
16953 unformat_input_t *input = vam->input;
16954 vl_api_one_add_del_map_server_t *mp;
16958 ip4_address_t ipv4;
16959 ip6_address_t ipv6;
16962 /* Parse args required to build the message */
16963 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16965 if (unformat (input, "del"))
16969 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
16973 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
16981 if (ipv4_set && ipv6_set)
16983 errmsg ("both eid v4 and v6 addresses set");
16987 if (!ipv4_set && !ipv6_set)
16989 errmsg ("eid addresses not set");
16993 /* Construct the API message */
16994 M (ONE_ADD_DEL_MAP_SERVER, mp);
16996 mp->is_add = is_add;
17000 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17005 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17011 /* Wait for a reply... */
17016 #define api_lisp_add_del_map_server api_one_add_del_map_server
17019 api_one_add_del_map_resolver (vat_main_t * vam)
17021 unformat_input_t *input = vam->input;
17022 vl_api_one_add_del_map_resolver_t *mp;
17026 ip4_address_t ipv4;
17027 ip6_address_t ipv6;
17030 /* Parse args required to build the message */
17031 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17033 if (unformat (input, "del"))
17037 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17041 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17049 if (ipv4_set && ipv6_set)
17051 errmsg ("both eid v4 and v6 addresses set");
17055 if (!ipv4_set && !ipv6_set)
17057 errmsg ("eid addresses not set");
17061 /* Construct the API message */
17062 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
17064 mp->is_add = is_add;
17068 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17073 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17079 /* Wait for a reply... */
17084 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
17087 api_lisp_gpe_enable_disable (vat_main_t * vam)
17089 unformat_input_t *input = vam->input;
17090 vl_api_gpe_enable_disable_t *mp;
17095 /* Parse args required to build the message */
17096 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17098 if (unformat (input, "enable"))
17103 else if (unformat (input, "disable"))
17114 errmsg ("Value not set");
17118 /* Construct the API message */
17119 M (GPE_ENABLE_DISABLE, mp);
17126 /* Wait for a reply... */
17132 api_one_rloc_probe_enable_disable (vat_main_t * vam)
17134 unformat_input_t *input = vam->input;
17135 vl_api_one_rloc_probe_enable_disable_t *mp;
17140 /* Parse args required to build the message */
17141 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17143 if (unformat (input, "enable"))
17148 else if (unformat (input, "disable"))
17156 errmsg ("Value not set");
17160 /* Construct the API message */
17161 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
17163 mp->is_enabled = is_en;
17168 /* Wait for a reply... */
17173 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
17176 api_one_map_register_enable_disable (vat_main_t * vam)
17178 unformat_input_t *input = vam->input;
17179 vl_api_one_map_register_enable_disable_t *mp;
17184 /* Parse args required to build the message */
17185 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17187 if (unformat (input, "enable"))
17192 else if (unformat (input, "disable"))
17200 errmsg ("Value not set");
17204 /* Construct the API message */
17205 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
17207 mp->is_enabled = is_en;
17212 /* Wait for a reply... */
17217 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
17220 api_one_enable_disable (vat_main_t * vam)
17222 unformat_input_t *input = vam->input;
17223 vl_api_one_enable_disable_t *mp;
17228 /* Parse args required to build the message */
17229 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17231 if (unformat (input, "enable"))
17236 else if (unformat (input, "disable"))
17246 errmsg ("Value not set");
17250 /* Construct the API message */
17251 M (ONE_ENABLE_DISABLE, mp);
17258 /* Wait for a reply... */
17263 #define api_lisp_enable_disable api_one_enable_disable
17266 api_one_enable_disable_xtr_mode (vat_main_t * vam)
17268 unformat_input_t *input = vam->input;
17269 vl_api_one_enable_disable_xtr_mode_t *mp;
17274 /* Parse args required to build the message */
17275 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17277 if (unformat (input, "enable"))
17282 else if (unformat (input, "disable"))
17292 errmsg ("Value not set");
17296 /* Construct the API message */
17297 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
17304 /* Wait for a reply... */
17310 api_one_show_xtr_mode (vat_main_t * vam)
17312 vl_api_one_show_xtr_mode_t *mp;
17315 /* Construct the API message */
17316 M (ONE_SHOW_XTR_MODE, mp);
17321 /* Wait for a reply... */
17327 api_one_enable_disable_pitr_mode (vat_main_t * vam)
17329 unformat_input_t *input = vam->input;
17330 vl_api_one_enable_disable_pitr_mode_t *mp;
17335 /* Parse args required to build the message */
17336 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17338 if (unformat (input, "enable"))
17343 else if (unformat (input, "disable"))
17353 errmsg ("Value not set");
17357 /* Construct the API message */
17358 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
17365 /* Wait for a reply... */
17371 api_one_show_pitr_mode (vat_main_t * vam)
17373 vl_api_one_show_pitr_mode_t *mp;
17376 /* Construct the API message */
17377 M (ONE_SHOW_PITR_MODE, mp);
17382 /* Wait for a reply... */
17388 api_one_enable_disable_petr_mode (vat_main_t * vam)
17390 unformat_input_t *input = vam->input;
17391 vl_api_one_enable_disable_petr_mode_t *mp;
17396 /* Parse args required to build the message */
17397 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17399 if (unformat (input, "enable"))
17404 else if (unformat (input, "disable"))
17414 errmsg ("Value not set");
17418 /* Construct the API message */
17419 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
17426 /* Wait for a reply... */
17432 api_one_show_petr_mode (vat_main_t * vam)
17434 vl_api_one_show_petr_mode_t *mp;
17437 /* Construct the API message */
17438 M (ONE_SHOW_PETR_MODE, mp);
17443 /* Wait for a reply... */
17449 api_show_one_map_register_state (vat_main_t * vam)
17451 vl_api_show_one_map_register_state_t *mp;
17454 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
17459 /* wait for reply */
17464 #define api_show_lisp_map_register_state api_show_one_map_register_state
17467 api_show_one_rloc_probe_state (vat_main_t * vam)
17469 vl_api_show_one_rloc_probe_state_t *mp;
17472 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
17477 /* wait for reply */
17482 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
17485 api_one_add_del_ndp_entry (vat_main_t * vam)
17487 vl_api_one_add_del_ndp_entry_t *mp;
17488 unformat_input_t *input = vam->input;
17493 u8 mac[6] = { 0, };
17494 u8 ip6[16] = { 0, };
17498 /* Parse args required to build the message */
17499 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17501 if (unformat (input, "del"))
17503 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17505 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
17507 else if (unformat (input, "bd %d", &bd))
17511 errmsg ("parse error '%U'", format_unformat_error, input);
17516 if (!bd_set || !ip_set || (!mac_set && is_add))
17518 errmsg ("Missing BD, IP or MAC!");
17522 M (ONE_ADD_DEL_NDP_ENTRY, mp);
17523 mp->is_add = is_add;
17524 clib_memcpy (mp->mac, mac, 6);
17525 mp->bd = clib_host_to_net_u32 (bd);
17526 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
17531 /* wait for reply */
17537 api_one_add_del_l2_arp_entry (vat_main_t * vam)
17539 vl_api_one_add_del_l2_arp_entry_t *mp;
17540 unformat_input_t *input = vam->input;
17545 u8 mac[6] = { 0, };
17546 u32 ip4 = 0, bd = ~0;
17549 /* Parse args required to build the message */
17550 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17552 if (unformat (input, "del"))
17554 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17556 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
17558 else if (unformat (input, "bd %d", &bd))
17562 errmsg ("parse error '%U'", format_unformat_error, input);
17567 if (!bd_set || !ip_set || (!mac_set && is_add))
17569 errmsg ("Missing BD, IP or MAC!");
17573 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
17574 mp->is_add = is_add;
17575 clib_memcpy (mp->mac, mac, 6);
17576 mp->bd = clib_host_to_net_u32 (bd);
17582 /* wait for reply */
17588 api_one_ndp_bd_get (vat_main_t * vam)
17590 vl_api_one_ndp_bd_get_t *mp;
17593 M (ONE_NDP_BD_GET, mp);
17598 /* wait for reply */
17604 api_one_ndp_entries_get (vat_main_t * vam)
17606 vl_api_one_ndp_entries_get_t *mp;
17607 unformat_input_t *input = vam->input;
17612 /* Parse args required to build the message */
17613 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17615 if (unformat (input, "bd %d", &bd))
17619 errmsg ("parse error '%U'", format_unformat_error, input);
17626 errmsg ("Expected bridge domain!");
17630 M (ONE_NDP_ENTRIES_GET, mp);
17631 mp->bd = clib_host_to_net_u32 (bd);
17636 /* wait for reply */
17642 api_one_l2_arp_bd_get (vat_main_t * vam)
17644 vl_api_one_l2_arp_bd_get_t *mp;
17647 M (ONE_L2_ARP_BD_GET, mp);
17652 /* wait for reply */
17658 api_one_l2_arp_entries_get (vat_main_t * vam)
17660 vl_api_one_l2_arp_entries_get_t *mp;
17661 unformat_input_t *input = vam->input;
17666 /* Parse args required to build the message */
17667 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17669 if (unformat (input, "bd %d", &bd))
17673 errmsg ("parse error '%U'", format_unformat_error, input);
17680 errmsg ("Expected bridge domain!");
17684 M (ONE_L2_ARP_ENTRIES_GET, mp);
17685 mp->bd = clib_host_to_net_u32 (bd);
17690 /* wait for reply */
17696 api_one_stats_enable_disable (vat_main_t * vam)
17698 vl_api_one_stats_enable_disable_t *mp;
17699 unformat_input_t *input = vam->input;
17704 /* Parse args required to build the message */
17705 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17707 if (unformat (input, "enable"))
17712 else if (unformat (input, "disable"))
17722 errmsg ("Value not set");
17726 M (ONE_STATS_ENABLE_DISABLE, mp);
17732 /* wait for reply */
17738 api_show_one_stats_enable_disable (vat_main_t * vam)
17740 vl_api_show_one_stats_enable_disable_t *mp;
17743 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
17748 /* wait for reply */
17754 api_show_one_map_request_mode (vat_main_t * vam)
17756 vl_api_show_one_map_request_mode_t *mp;
17759 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
17764 /* wait for reply */
17769 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
17772 api_one_map_request_mode (vat_main_t * vam)
17774 unformat_input_t *input = vam->input;
17775 vl_api_one_map_request_mode_t *mp;
17779 /* Parse args required to build the message */
17780 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17782 if (unformat (input, "dst-only"))
17784 else if (unformat (input, "src-dst"))
17788 errmsg ("parse error '%U'", format_unformat_error, input);
17793 M (ONE_MAP_REQUEST_MODE, mp);
17800 /* wait for reply */
17805 #define api_lisp_map_request_mode api_one_map_request_mode
17808 * Enable/disable ONE proxy ITR.
17810 * @param vam vpp API test context
17811 * @return return code
17814 api_one_pitr_set_locator_set (vat_main_t * vam)
17816 u8 ls_name_set = 0;
17817 unformat_input_t *input = vam->input;
17818 vl_api_one_pitr_set_locator_set_t *mp;
17823 /* Parse args required to build the message */
17824 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17826 if (unformat (input, "del"))
17828 else if (unformat (input, "locator-set %s", &ls_name))
17832 errmsg ("parse error '%U'", format_unformat_error, input);
17839 errmsg ("locator-set name not set!");
17843 M (ONE_PITR_SET_LOCATOR_SET, mp);
17845 mp->is_add = is_add;
17846 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
17847 vec_free (ls_name);
17852 /* wait for reply */
17857 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
17860 api_one_nsh_set_locator_set (vat_main_t * vam)
17862 u8 ls_name_set = 0;
17863 unformat_input_t *input = vam->input;
17864 vl_api_one_nsh_set_locator_set_t *mp;
17869 /* Parse args required to build the message */
17870 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17872 if (unformat (input, "del"))
17874 else if (unformat (input, "ls %s", &ls_name))
17878 errmsg ("parse error '%U'", format_unformat_error, input);
17883 if (!ls_name_set && is_add)
17885 errmsg ("locator-set name not set!");
17889 M (ONE_NSH_SET_LOCATOR_SET, mp);
17891 mp->is_add = is_add;
17892 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
17893 vec_free (ls_name);
17898 /* wait for reply */
17904 api_show_one_pitr (vat_main_t * vam)
17906 vl_api_show_one_pitr_t *mp;
17909 if (!vam->json_output)
17911 print (vam->ofp, "%=20s", "lisp status:");
17914 M (SHOW_ONE_PITR, mp);
17918 /* Wait for a reply... */
17923 #define api_show_lisp_pitr api_show_one_pitr
17926 api_one_use_petr (vat_main_t * vam)
17928 unformat_input_t *input = vam->input;
17929 vl_api_one_use_petr_t *mp;
17934 memset (&ip, 0, sizeof (ip));
17936 /* Parse args required to build the message */
17937 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17939 if (unformat (input, "disable"))
17942 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
17945 ip_addr_version (&ip) = IP4;
17948 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
17951 ip_addr_version (&ip) = IP6;
17955 errmsg ("parse error '%U'", format_unformat_error, input);
17960 M (ONE_USE_PETR, mp);
17962 mp->is_add = is_add;
17965 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
17967 clib_memcpy (mp->address, &ip, 4);
17969 clib_memcpy (mp->address, &ip, 16);
17975 /* wait for reply */
17980 #define api_lisp_use_petr api_one_use_petr
17983 api_show_one_nsh_mapping (vat_main_t * vam)
17985 vl_api_show_one_use_petr_t *mp;
17988 if (!vam->json_output)
17990 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
17993 M (SHOW_ONE_NSH_MAPPING, mp);
17997 /* Wait for a reply... */
18003 api_show_one_use_petr (vat_main_t * vam)
18005 vl_api_show_one_use_petr_t *mp;
18008 if (!vam->json_output)
18010 print (vam->ofp, "%=20s", "Proxy-ETR status:");
18013 M (SHOW_ONE_USE_PETR, mp);
18017 /* Wait for a reply... */
18022 #define api_show_lisp_use_petr api_show_one_use_petr
18025 * Add/delete mapping between vni and vrf
18028 api_one_eid_table_add_del_map (vat_main_t * vam)
18030 unformat_input_t *input = vam->input;
18031 vl_api_one_eid_table_add_del_map_t *mp;
18032 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
18033 u32 vni, vrf, bd_index;
18036 /* Parse args required to build the message */
18037 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18039 if (unformat (input, "del"))
18041 else if (unformat (input, "vrf %d", &vrf))
18043 else if (unformat (input, "bd_index %d", &bd_index))
18045 else if (unformat (input, "vni %d", &vni))
18051 if (!vni_set || (!vrf_set && !bd_index_set))
18053 errmsg ("missing arguments!");
18057 if (vrf_set && bd_index_set)
18059 errmsg ("error: both vrf and bd entered!");
18063 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
18065 mp->is_add = is_add;
18066 mp->vni = htonl (vni);
18067 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
18068 mp->is_l2 = bd_index_set;
18073 /* wait for reply */
18078 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
18081 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
18083 u32 *action = va_arg (*args, u32 *);
18086 if (unformat (input, "%s", &s))
18088 if (!strcmp ((char *) s, "no-action"))
18090 else if (!strcmp ((char *) s, "natively-forward"))
18092 else if (!strcmp ((char *) s, "send-map-request"))
18094 else if (!strcmp ((char *) s, "drop"))
18098 clib_warning ("invalid action: '%s'", s);
18110 * Add/del remote mapping to/from ONE control plane
18112 * @param vam vpp API test context
18113 * @return return code
18116 api_one_add_del_remote_mapping (vat_main_t * vam)
18118 unformat_input_t *input = vam->input;
18119 vl_api_one_add_del_remote_mapping_t *mp;
18121 lisp_eid_vat_t _eid, *eid = &_eid;
18122 lisp_eid_vat_t _seid, *seid = &_seid;
18123 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
18124 u32 action = ~0, p, w, data_len;
18125 ip4_address_t rloc4;
18126 ip6_address_t rloc6;
18127 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
18130 memset (&rloc, 0, sizeof (rloc));
18132 /* Parse args required to build the message */
18133 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18135 if (unformat (input, "del-all"))
18139 else if (unformat (input, "del"))
18143 else if (unformat (input, "add"))
18147 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
18151 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
18155 else if (unformat (input, "vni %d", &vni))
18159 else if (unformat (input, "p %d w %d", &p, &w))
18163 errmsg ("No RLOC configured for setting priority/weight!");
18166 curr_rloc->priority = p;
18167 curr_rloc->weight = w;
18169 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
18172 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
18173 vec_add1 (rlocs, rloc);
18174 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18176 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
18179 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
18180 vec_add1 (rlocs, rloc);
18181 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18183 else if (unformat (input, "action %U",
18184 unformat_negative_mapping_action, &action))
18190 clib_warning ("parse error '%U'", format_unformat_error, input);
18197 errmsg ("missing params!");
18201 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
18203 errmsg ("no action set for negative map-reply!");
18207 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
18209 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
18210 mp->is_add = is_add;
18211 mp->vni = htonl (vni);
18212 mp->action = (u8) action;
18213 mp->is_src_dst = seid_set;
18214 mp->eid_len = eid->len;
18215 mp->seid_len = seid->len;
18216 mp->del_all = del_all;
18217 mp->eid_type = eid->type;
18218 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
18219 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
18221 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
18222 clib_memcpy (mp->rlocs, rlocs, data_len);
18228 /* Wait for a reply... */
18233 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
18236 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
18237 * forwarding entries in data-plane accordingly.
18239 * @param vam vpp API test context
18240 * @return return code
18243 api_one_add_del_adjacency (vat_main_t * vam)
18245 unformat_input_t *input = vam->input;
18246 vl_api_one_add_del_adjacency_t *mp;
18248 ip4_address_t leid4, reid4;
18249 ip6_address_t leid6, reid6;
18250 u8 reid_mac[6] = { 0 };
18251 u8 leid_mac[6] = { 0 };
18252 u8 reid_type, leid_type;
18253 u32 leid_len = 0, reid_len = 0, len;
18257 leid_type = reid_type = (u8) ~ 0;
18259 /* Parse args required to build the message */
18260 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18262 if (unformat (input, "del"))
18266 else if (unformat (input, "add"))
18270 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
18273 reid_type = 0; /* ipv4 */
18276 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
18279 reid_type = 1; /* ipv6 */
18282 else if (unformat (input, "reid %U", unformat_ethernet_address,
18285 reid_type = 2; /* mac */
18287 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
18290 leid_type = 0; /* ipv4 */
18293 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
18296 leid_type = 1; /* ipv6 */
18299 else if (unformat (input, "leid %U", unformat_ethernet_address,
18302 leid_type = 2; /* mac */
18304 else if (unformat (input, "vni %d", &vni))
18310 errmsg ("parse error '%U'", format_unformat_error, input);
18315 if ((u8) ~ 0 == reid_type)
18317 errmsg ("missing params!");
18321 if (leid_type != reid_type)
18323 errmsg ("remote and local EIDs are of different types!");
18327 M (ONE_ADD_DEL_ADJACENCY, mp);
18328 mp->is_add = is_add;
18329 mp->vni = htonl (vni);
18330 mp->leid_len = leid_len;
18331 mp->reid_len = reid_len;
18332 mp->eid_type = reid_type;
18334 switch (mp->eid_type)
18337 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
18338 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
18341 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
18342 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
18345 clib_memcpy (mp->leid, leid_mac, 6);
18346 clib_memcpy (mp->reid, reid_mac, 6);
18349 errmsg ("unknown EID type %d!", mp->eid_type);
18356 /* Wait for a reply... */
18361 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
18364 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
18366 u32 *mode = va_arg (*args, u32 *);
18368 if (unformat (input, "lisp"))
18370 else if (unformat (input, "vxlan"))
18379 api_gpe_get_encap_mode (vat_main_t * vam)
18381 vl_api_gpe_get_encap_mode_t *mp;
18384 /* Construct the API message */
18385 M (GPE_GET_ENCAP_MODE, mp);
18390 /* Wait for a reply... */
18396 api_gpe_set_encap_mode (vat_main_t * vam)
18398 unformat_input_t *input = vam->input;
18399 vl_api_gpe_set_encap_mode_t *mp;
18403 /* Parse args required to build the message */
18404 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18406 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
18412 /* Construct the API message */
18413 M (GPE_SET_ENCAP_MODE, mp);
18420 /* Wait for a reply... */
18426 api_lisp_gpe_add_del_iface (vat_main_t * vam)
18428 unformat_input_t *input = vam->input;
18429 vl_api_gpe_add_del_iface_t *mp;
18430 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
18431 u32 dp_table = 0, vni = 0;
18434 /* Parse args required to build the message */
18435 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18437 if (unformat (input, "up"))
18442 else if (unformat (input, "down"))
18447 else if (unformat (input, "table_id %d", &dp_table))
18451 else if (unformat (input, "bd_id %d", &dp_table))
18456 else if (unformat (input, "vni %d", &vni))
18464 if (action_set == 0)
18466 errmsg ("Action not set");
18469 if (dp_table_set == 0 || vni_set == 0)
18471 errmsg ("vni and dp_table must be set");
18475 /* Construct the API message */
18476 M (GPE_ADD_DEL_IFACE, mp);
18478 mp->is_add = is_add;
18479 mp->dp_table = clib_host_to_net_u32 (dp_table);
18481 mp->vni = clib_host_to_net_u32 (vni);
18486 /* Wait for a reply... */
18492 api_one_map_register_fallback_threshold (vat_main_t * vam)
18494 unformat_input_t *input = vam->input;
18495 vl_api_one_map_register_fallback_threshold_t *mp;
18500 /* Parse args required to build the message */
18501 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18503 if (unformat (input, "%u", &value))
18507 clib_warning ("parse error '%U'", format_unformat_error, input);
18514 errmsg ("fallback threshold value is missing!");
18518 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18519 mp->value = clib_host_to_net_u32 (value);
18524 /* Wait for a reply... */
18530 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
18532 vl_api_show_one_map_register_fallback_threshold_t *mp;
18535 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18540 /* Wait for a reply... */
18546 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
18548 u32 *proto = va_arg (*args, u32 *);
18550 if (unformat (input, "udp"))
18552 else if (unformat (input, "api"))
18561 api_one_set_transport_protocol (vat_main_t * vam)
18563 unformat_input_t *input = vam->input;
18564 vl_api_one_set_transport_protocol_t *mp;
18569 /* Parse args required to build the message */
18570 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18572 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
18576 clib_warning ("parse error '%U'", format_unformat_error, input);
18583 errmsg ("Transport protocol missing!");
18587 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
18588 mp->protocol = (u8) protocol;
18593 /* Wait for a reply... */
18599 api_one_get_transport_protocol (vat_main_t * vam)
18601 vl_api_one_get_transport_protocol_t *mp;
18604 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
18609 /* Wait for a reply... */
18615 api_one_map_register_set_ttl (vat_main_t * vam)
18617 unformat_input_t *input = vam->input;
18618 vl_api_one_map_register_set_ttl_t *mp;
18623 /* Parse args required to build the message */
18624 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18626 if (unformat (input, "%u", &ttl))
18630 clib_warning ("parse error '%U'", format_unformat_error, input);
18637 errmsg ("TTL value missing!");
18641 M (ONE_MAP_REGISTER_SET_TTL, mp);
18642 mp->ttl = clib_host_to_net_u32 (ttl);
18647 /* Wait for a reply... */
18653 api_show_one_map_register_ttl (vat_main_t * vam)
18655 vl_api_show_one_map_register_ttl_t *mp;
18658 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
18663 /* Wait for a reply... */
18669 * Add/del map request itr rlocs from ONE control plane and updates
18671 * @param vam vpp API test context
18672 * @return return code
18675 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
18677 unformat_input_t *input = vam->input;
18678 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
18679 u8 *locator_set_name = 0;
18680 u8 locator_set_name_set = 0;
18684 /* Parse args required to build the message */
18685 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18687 if (unformat (input, "del"))
18691 else if (unformat (input, "%_%v%_", &locator_set_name))
18693 locator_set_name_set = 1;
18697 clib_warning ("parse error '%U'", format_unformat_error, input);
18702 if (is_add && !locator_set_name_set)
18704 errmsg ("itr-rloc is not set!");
18708 if (is_add && vec_len (locator_set_name) > 64)
18710 errmsg ("itr-rloc locator-set name too long");
18711 vec_free (locator_set_name);
18715 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
18716 mp->is_add = is_add;
18719 clib_memcpy (mp->locator_set_name, locator_set_name,
18720 vec_len (locator_set_name));
18724 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
18726 vec_free (locator_set_name);
18731 /* Wait for a reply... */
18736 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
18739 api_one_locator_dump (vat_main_t * vam)
18741 unformat_input_t *input = vam->input;
18742 vl_api_one_locator_dump_t *mp;
18743 vl_api_control_ping_t *mp_ping;
18744 u8 is_index_set = 0, is_name_set = 0;
18749 /* Parse args required to build the message */
18750 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18752 if (unformat (input, "ls_name %_%v%_", &ls_name))
18756 else if (unformat (input, "ls_index %d", &ls_index))
18762 errmsg ("parse error '%U'", format_unformat_error, input);
18767 if (!is_index_set && !is_name_set)
18769 errmsg ("error: expected one of index or name!");
18773 if (is_index_set && is_name_set)
18775 errmsg ("error: only one param expected!");
18779 if (vec_len (ls_name) > 62)
18781 errmsg ("error: locator set name too long!");
18785 if (!vam->json_output)
18787 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
18790 M (ONE_LOCATOR_DUMP, mp);
18791 mp->is_index_set = is_index_set;
18794 mp->ls_index = clib_host_to_net_u32 (ls_index);
18797 vec_add1 (ls_name, 0);
18798 strncpy ((char *) mp->ls_name, (char *) ls_name,
18799 sizeof (mp->ls_name) - 1);
18805 /* Use a control ping for synchronization */
18806 MPING (CONTROL_PING, mp_ping);
18809 /* Wait for a reply... */
18814 #define api_lisp_locator_dump api_one_locator_dump
18817 api_one_locator_set_dump (vat_main_t * vam)
18819 vl_api_one_locator_set_dump_t *mp;
18820 vl_api_control_ping_t *mp_ping;
18821 unformat_input_t *input = vam->input;
18825 /* Parse args required to build the message */
18826 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18828 if (unformat (input, "local"))
18832 else if (unformat (input, "remote"))
18838 errmsg ("parse error '%U'", format_unformat_error, input);
18843 if (!vam->json_output)
18845 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
18848 M (ONE_LOCATOR_SET_DUMP, mp);
18850 mp->filter = filter;
18855 /* Use a control ping for synchronization */
18856 MPING (CONTROL_PING, mp_ping);
18859 /* Wait for a reply... */
18864 #define api_lisp_locator_set_dump api_one_locator_set_dump
18867 api_one_eid_table_map_dump (vat_main_t * vam)
18871 unformat_input_t *input = vam->input;
18872 vl_api_one_eid_table_map_dump_t *mp;
18873 vl_api_control_ping_t *mp_ping;
18876 /* Parse args required to build the message */
18877 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18879 if (unformat (input, "l2"))
18884 else if (unformat (input, "l3"))
18891 errmsg ("parse error '%U'", format_unformat_error, input);
18898 errmsg ("expected one of 'l2' or 'l3' parameter!");
18902 if (!vam->json_output)
18904 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
18907 M (ONE_EID_TABLE_MAP_DUMP, mp);
18913 /* Use a control ping for synchronization */
18914 MPING (CONTROL_PING, mp_ping);
18917 /* Wait for a reply... */
18922 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
18925 api_one_eid_table_vni_dump (vat_main_t * vam)
18927 vl_api_one_eid_table_vni_dump_t *mp;
18928 vl_api_control_ping_t *mp_ping;
18931 if (!vam->json_output)
18933 print (vam->ofp, "VNI");
18936 M (ONE_EID_TABLE_VNI_DUMP, mp);
18941 /* Use a control ping for synchronization */
18942 MPING (CONTROL_PING, mp_ping);
18945 /* Wait for a reply... */
18950 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
18953 api_one_eid_table_dump (vat_main_t * vam)
18955 unformat_input_t *i = vam->input;
18956 vl_api_one_eid_table_dump_t *mp;
18957 vl_api_control_ping_t *mp_ping;
18958 struct in_addr ip4;
18959 struct in6_addr ip6;
18961 u8 eid_type = ~0, eid_set = 0;
18962 u32 prefix_length = ~0, t, vni = 0;
18965 lisp_nsh_api_t nsh;
18967 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18969 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
18975 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
18981 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
18986 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
18991 else if (unformat (i, "vni %d", &t))
18995 else if (unformat (i, "local"))
18999 else if (unformat (i, "remote"))
19005 errmsg ("parse error '%U'", format_unformat_error, i);
19010 if (!vam->json_output)
19012 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
19013 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
19016 M (ONE_EID_TABLE_DUMP, mp);
19018 mp->filter = filter;
19022 mp->vni = htonl (vni);
19023 mp->eid_type = eid_type;
19027 mp->prefix_length = prefix_length;
19028 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
19031 mp->prefix_length = prefix_length;
19032 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
19035 clib_memcpy (mp->eid, mac, sizeof (mac));
19038 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
19041 errmsg ("unknown EID type %d!", eid_type);
19049 /* Use a control ping for synchronization */
19050 MPING (CONTROL_PING, mp_ping);
19053 /* Wait for a reply... */
19058 #define api_lisp_eid_table_dump api_one_eid_table_dump
19061 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
19063 unformat_input_t *i = vam->input;
19064 vl_api_gpe_fwd_entries_get_t *mp;
19069 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19071 if (unformat (i, "vni %d", &vni))
19077 errmsg ("parse error '%U'", format_unformat_error, i);
19084 errmsg ("vni not set!");
19088 if (!vam->json_output)
19090 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
19094 M (GPE_FWD_ENTRIES_GET, mp);
19095 mp->vni = clib_host_to_net_u32 (vni);
19100 /* Wait for a reply... */
19105 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
19106 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
19107 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
19108 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
19109 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
19110 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
19111 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
19112 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
19115 api_one_adjacencies_get (vat_main_t * vam)
19117 unformat_input_t *i = vam->input;
19118 vl_api_one_adjacencies_get_t *mp;
19123 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19125 if (unformat (i, "vni %d", &vni))
19131 errmsg ("parse error '%U'", format_unformat_error, i);
19138 errmsg ("vni not set!");
19142 if (!vam->json_output)
19144 print (vam->ofp, "%s %40s", "leid", "reid");
19147 M (ONE_ADJACENCIES_GET, mp);
19148 mp->vni = clib_host_to_net_u32 (vni);
19153 /* Wait for a reply... */
19158 #define api_lisp_adjacencies_get api_one_adjacencies_get
19161 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
19163 unformat_input_t *i = vam->input;
19164 vl_api_gpe_native_fwd_rpaths_get_t *mp;
19166 u8 ip_family_set = 0, is_ip4 = 1;
19168 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19170 if (unformat (i, "ip4"))
19175 else if (unformat (i, "ip6"))
19182 errmsg ("parse error '%U'", format_unformat_error, i);
19187 if (!ip_family_set)
19189 errmsg ("ip family not set!");
19193 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
19194 mp->is_ip4 = is_ip4;
19199 /* Wait for a reply... */
19205 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
19207 vl_api_gpe_fwd_entry_vnis_get_t *mp;
19210 if (!vam->json_output)
19212 print (vam->ofp, "VNIs");
19215 M (GPE_FWD_ENTRY_VNIS_GET, mp);
19220 /* Wait for a reply... */
19226 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
19228 unformat_input_t *i = vam->input;
19229 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
19231 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
19232 struct in_addr ip4;
19233 struct in6_addr ip6;
19234 u32 table_id = 0, nh_sw_if_index = ~0;
19236 memset (&ip4, 0, sizeof (ip4));
19237 memset (&ip6, 0, sizeof (ip6));
19239 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19241 if (unformat (i, "del"))
19243 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
19244 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19249 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
19250 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19255 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
19259 nh_sw_if_index = ~0;
19261 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
19265 nh_sw_if_index = ~0;
19267 else if (unformat (i, "table %d", &table_id))
19271 errmsg ("parse error '%U'", format_unformat_error, i);
19278 errmsg ("nh addr not set!");
19282 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
19283 mp->is_add = is_add;
19284 mp->table_id = clib_host_to_net_u32 (table_id);
19285 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
19286 mp->is_ip4 = is_ip4;
19288 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
19290 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
19295 /* Wait for a reply... */
19301 api_one_map_server_dump (vat_main_t * vam)
19303 vl_api_one_map_server_dump_t *mp;
19304 vl_api_control_ping_t *mp_ping;
19307 if (!vam->json_output)
19309 print (vam->ofp, "%=20s", "Map server");
19312 M (ONE_MAP_SERVER_DUMP, mp);
19316 /* Use a control ping for synchronization */
19317 MPING (CONTROL_PING, mp_ping);
19320 /* Wait for a reply... */
19325 #define api_lisp_map_server_dump api_one_map_server_dump
19328 api_one_map_resolver_dump (vat_main_t * vam)
19330 vl_api_one_map_resolver_dump_t *mp;
19331 vl_api_control_ping_t *mp_ping;
19334 if (!vam->json_output)
19336 print (vam->ofp, "%=20s", "Map resolver");
19339 M (ONE_MAP_RESOLVER_DUMP, mp);
19343 /* Use a control ping for synchronization */
19344 MPING (CONTROL_PING, mp_ping);
19347 /* Wait for a reply... */
19352 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
19355 api_one_stats_flush (vat_main_t * vam)
19357 vl_api_one_stats_flush_t *mp;
19360 M (ONE_STATS_FLUSH, mp);
19367 api_one_stats_dump (vat_main_t * vam)
19369 vl_api_one_stats_dump_t *mp;
19370 vl_api_control_ping_t *mp_ping;
19373 M (ONE_STATS_DUMP, mp);
19377 /* Use a control ping for synchronization */
19378 MPING (CONTROL_PING, mp_ping);
19381 /* Wait for a reply... */
19387 api_show_one_status (vat_main_t * vam)
19389 vl_api_show_one_status_t *mp;
19392 if (!vam->json_output)
19394 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
19397 M (SHOW_ONE_STATUS, mp);
19400 /* Wait for a reply... */
19405 #define api_show_lisp_status api_show_one_status
19408 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
19410 vl_api_gpe_fwd_entry_path_dump_t *mp;
19411 vl_api_control_ping_t *mp_ping;
19412 unformat_input_t *i = vam->input;
19413 u32 fwd_entry_index = ~0;
19416 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19418 if (unformat (i, "index %d", &fwd_entry_index))
19424 if (~0 == fwd_entry_index)
19426 errmsg ("no index specified!");
19430 if (!vam->json_output)
19432 print (vam->ofp, "first line");
19435 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
19439 /* Use a control ping for synchronization */
19440 MPING (CONTROL_PING, mp_ping);
19443 /* Wait for a reply... */
19449 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
19451 vl_api_one_get_map_request_itr_rlocs_t *mp;
19454 if (!vam->json_output)
19456 print (vam->ofp, "%=20s", "itr-rlocs:");
19459 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
19462 /* Wait for a reply... */
19467 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
19470 api_af_packet_create (vat_main_t * vam)
19472 unformat_input_t *i = vam->input;
19473 vl_api_af_packet_create_t *mp;
19474 u8 *host_if_name = 0;
19476 u8 random_hw_addr = 1;
19479 memset (hw_addr, 0, sizeof (hw_addr));
19481 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19483 if (unformat (i, "name %s", &host_if_name))
19484 vec_add1 (host_if_name, 0);
19485 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19486 random_hw_addr = 0;
19491 if (!vec_len (host_if_name))
19493 errmsg ("host-interface name must be specified");
19497 if (vec_len (host_if_name) > 64)
19499 errmsg ("host-interface name too long");
19503 M (AF_PACKET_CREATE, mp);
19505 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19506 clib_memcpy (mp->hw_addr, hw_addr, 6);
19507 mp->use_random_hw_addr = random_hw_addr;
19508 vec_free (host_if_name);
19516 fprintf (vam->ofp ? vam->ofp : stderr,
19517 " new sw_if_index = %d\n", vam->sw_if_index);
19524 api_af_packet_delete (vat_main_t * vam)
19526 unformat_input_t *i = vam->input;
19527 vl_api_af_packet_delete_t *mp;
19528 u8 *host_if_name = 0;
19531 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19533 if (unformat (i, "name %s", &host_if_name))
19534 vec_add1 (host_if_name, 0);
19539 if (!vec_len (host_if_name))
19541 errmsg ("host-interface name must be specified");
19545 if (vec_len (host_if_name) > 64)
19547 errmsg ("host-interface name too long");
19551 M (AF_PACKET_DELETE, mp);
19553 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19554 vec_free (host_if_name);
19561 static void vl_api_af_packet_details_t_handler
19562 (vl_api_af_packet_details_t * mp)
19564 vat_main_t *vam = &vat_main;
19566 print (vam->ofp, "%-16s %d",
19567 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
19570 static void vl_api_af_packet_details_t_handler_json
19571 (vl_api_af_packet_details_t * mp)
19573 vat_main_t *vam = &vat_main;
19574 vat_json_node_t *node = NULL;
19576 if (VAT_JSON_ARRAY != vam->json_tree.type)
19578 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19579 vat_json_init_array (&vam->json_tree);
19581 node = vat_json_array_add (&vam->json_tree);
19583 vat_json_init_object (node);
19584 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
19585 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
19589 api_af_packet_dump (vat_main_t * vam)
19591 vl_api_af_packet_dump_t *mp;
19592 vl_api_control_ping_t *mp_ping;
19595 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
19596 /* Get list of tap interfaces */
19597 M (AF_PACKET_DUMP, mp);
19600 /* Use a control ping for synchronization */
19601 MPING (CONTROL_PING, mp_ping);
19609 api_policer_add_del (vat_main_t * vam)
19611 unformat_input_t *i = vam->input;
19612 vl_api_policer_add_del_t *mp;
19622 u8 color_aware = 0;
19623 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
19626 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
19627 conform_action.dscp = 0;
19628 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
19629 exceed_action.dscp = 0;
19630 violate_action.action_type = SSE2_QOS_ACTION_DROP;
19631 violate_action.dscp = 0;
19633 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19635 if (unformat (i, "del"))
19637 else if (unformat (i, "name %s", &name))
19638 vec_add1 (name, 0);
19639 else if (unformat (i, "cir %u", &cir))
19641 else if (unformat (i, "eir %u", &eir))
19643 else if (unformat (i, "cb %u", &cb))
19645 else if (unformat (i, "eb %u", &eb))
19647 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
19650 else if (unformat (i, "round_type %U", unformat_policer_round_type,
19653 else if (unformat (i, "type %U", unformat_policer_type, &type))
19655 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
19658 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
19661 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
19664 else if (unformat (i, "color-aware"))
19670 if (!vec_len (name))
19672 errmsg ("policer name must be specified");
19676 if (vec_len (name) > 64)
19678 errmsg ("policer name too long");
19682 M (POLICER_ADD_DEL, mp);
19684 clib_memcpy (mp->name, name, vec_len (name));
19686 mp->is_add = is_add;
19687 mp->cir = ntohl (cir);
19688 mp->eir = ntohl (eir);
19689 mp->cb = clib_net_to_host_u64 (cb);
19690 mp->eb = clib_net_to_host_u64 (eb);
19691 mp->rate_type = rate_type;
19692 mp->round_type = round_type;
19694 mp->conform_action_type = conform_action.action_type;
19695 mp->conform_dscp = conform_action.dscp;
19696 mp->exceed_action_type = exceed_action.action_type;
19697 mp->exceed_dscp = exceed_action.dscp;
19698 mp->violate_action_type = violate_action.action_type;
19699 mp->violate_dscp = violate_action.dscp;
19700 mp->color_aware = color_aware;
19708 api_policer_dump (vat_main_t * vam)
19710 unformat_input_t *i = vam->input;
19711 vl_api_policer_dump_t *mp;
19712 vl_api_control_ping_t *mp_ping;
19713 u8 *match_name = 0;
19714 u8 match_name_valid = 0;
19717 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19719 if (unformat (i, "name %s", &match_name))
19721 vec_add1 (match_name, 0);
19722 match_name_valid = 1;
19728 M (POLICER_DUMP, mp);
19729 mp->match_name_valid = match_name_valid;
19730 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
19731 vec_free (match_name);
19735 /* Use a control ping for synchronization */
19736 MPING (CONTROL_PING, mp_ping);
19739 /* Wait for a reply... */
19745 api_policer_classify_set_interface (vat_main_t * vam)
19747 unformat_input_t *i = vam->input;
19748 vl_api_policer_classify_set_interface_t *mp;
19750 int sw_if_index_set;
19751 u32 ip4_table_index = ~0;
19752 u32 ip6_table_index = ~0;
19753 u32 l2_table_index = ~0;
19757 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19759 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19760 sw_if_index_set = 1;
19761 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19762 sw_if_index_set = 1;
19763 else if (unformat (i, "del"))
19765 else if (unformat (i, "ip4-table %d", &ip4_table_index))
19767 else if (unformat (i, "ip6-table %d", &ip6_table_index))
19769 else if (unformat (i, "l2-table %d", &l2_table_index))
19773 clib_warning ("parse error '%U'", format_unformat_error, i);
19778 if (sw_if_index_set == 0)
19780 errmsg ("missing interface name or sw_if_index");
19784 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
19786 mp->sw_if_index = ntohl (sw_if_index);
19787 mp->ip4_table_index = ntohl (ip4_table_index);
19788 mp->ip6_table_index = ntohl (ip6_table_index);
19789 mp->l2_table_index = ntohl (l2_table_index);
19790 mp->is_add = is_add;
19798 api_policer_classify_dump (vat_main_t * vam)
19800 unformat_input_t *i = vam->input;
19801 vl_api_policer_classify_dump_t *mp;
19802 vl_api_control_ping_t *mp_ping;
19803 u8 type = POLICER_CLASSIFY_N_TABLES;
19806 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
19810 errmsg ("classify table type must be specified");
19814 if (!vam->json_output)
19816 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
19819 M (POLICER_CLASSIFY_DUMP, mp);
19824 /* Use a control ping for synchronization */
19825 MPING (CONTROL_PING, mp_ping);
19828 /* Wait for a reply... */
19834 api_netmap_create (vat_main_t * vam)
19836 unformat_input_t *i = vam->input;
19837 vl_api_netmap_create_t *mp;
19840 u8 random_hw_addr = 1;
19845 memset (hw_addr, 0, sizeof (hw_addr));
19847 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19849 if (unformat (i, "name %s", &if_name))
19850 vec_add1 (if_name, 0);
19851 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19852 random_hw_addr = 0;
19853 else if (unformat (i, "pipe"))
19855 else if (unformat (i, "master"))
19857 else if (unformat (i, "slave"))
19863 if (!vec_len (if_name))
19865 errmsg ("interface name must be specified");
19869 if (vec_len (if_name) > 64)
19871 errmsg ("interface name too long");
19875 M (NETMAP_CREATE, mp);
19877 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
19878 clib_memcpy (mp->hw_addr, hw_addr, 6);
19879 mp->use_random_hw_addr = random_hw_addr;
19880 mp->is_pipe = is_pipe;
19881 mp->is_master = is_master;
19882 vec_free (if_name);
19890 api_netmap_delete (vat_main_t * vam)
19892 unformat_input_t *i = vam->input;
19893 vl_api_netmap_delete_t *mp;
19897 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19899 if (unformat (i, "name %s", &if_name))
19900 vec_add1 (if_name, 0);
19905 if (!vec_len (if_name))
19907 errmsg ("interface name must be specified");
19911 if (vec_len (if_name) > 64)
19913 errmsg ("interface name too long");
19917 M (NETMAP_DELETE, mp);
19919 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
19920 vec_free (if_name);
19928 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
19930 if (fp->afi == IP46_TYPE_IP6)
19932 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19933 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19934 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19935 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19936 format_ip6_address, fp->next_hop);
19937 else if (fp->afi == IP46_TYPE_IP4)
19939 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19940 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19941 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19942 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19943 format_ip4_address, fp->next_hop);
19947 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
19948 vl_api_fib_path_t * fp)
19950 struct in_addr ip4;
19951 struct in6_addr ip6;
19953 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19954 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19955 vat_json_object_add_uint (node, "is_local", fp->is_local);
19956 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19957 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19958 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19959 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19960 if (fp->afi == IP46_TYPE_IP4)
19962 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19963 vat_json_object_add_ip4 (node, "next_hop", ip4);
19965 else if (fp->afi == IP46_TYPE_IP6)
19967 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19968 vat_json_object_add_ip6 (node, "next_hop", ip6);
19973 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
19975 vat_main_t *vam = &vat_main;
19976 int count = ntohl (mp->mt_count);
19977 vl_api_fib_path_t *fp;
19980 print (vam->ofp, "[%d]: sw_if_index %d via:",
19981 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
19983 for (i = 0; i < count; i++)
19985 vl_api_mpls_fib_path_print (vam, fp);
19989 print (vam->ofp, "");
19992 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
19993 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
19996 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
19998 vat_main_t *vam = &vat_main;
19999 vat_json_node_t *node = NULL;
20000 int count = ntohl (mp->mt_count);
20001 vl_api_fib_path_t *fp;
20004 if (VAT_JSON_ARRAY != vam->json_tree.type)
20006 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20007 vat_json_init_array (&vam->json_tree);
20009 node = vat_json_array_add (&vam->json_tree);
20011 vat_json_init_object (node);
20012 vat_json_object_add_uint (node, "tunnel_index",
20013 ntohl (mp->mt_tunnel_index));
20014 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
20016 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
20019 for (i = 0; i < count; i++)
20021 vl_api_mpls_fib_path_json_print (node, fp);
20027 api_mpls_tunnel_dump (vat_main_t * vam)
20029 vl_api_mpls_tunnel_dump_t *mp;
20030 vl_api_control_ping_t *mp_ping;
20034 /* Parse args required to build the message */
20035 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
20037 if (!unformat (vam->input, "tunnel_index %d", &index))
20044 print (vam->ofp, " tunnel_index %d", index);
20046 M (MPLS_TUNNEL_DUMP, mp);
20047 mp->tunnel_index = htonl (index);
20050 /* Use a control ping for synchronization */
20051 MPING (CONTROL_PING, mp_ping);
20058 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
20059 #define vl_api_mpls_fib_details_t_print vl_noop_handler
20063 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
20065 vat_main_t *vam = &vat_main;
20066 int count = ntohl (mp->count);
20067 vl_api_fib_path_t *fp;
20071 "table-id %d, label %u, ess_bit %u",
20072 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
20074 for (i = 0; i < count; i++)
20076 vl_api_mpls_fib_path_print (vam, fp);
20081 static void vl_api_mpls_fib_details_t_handler_json
20082 (vl_api_mpls_fib_details_t * mp)
20084 vat_main_t *vam = &vat_main;
20085 int count = ntohl (mp->count);
20086 vat_json_node_t *node = NULL;
20087 vl_api_fib_path_t *fp;
20090 if (VAT_JSON_ARRAY != vam->json_tree.type)
20092 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20093 vat_json_init_array (&vam->json_tree);
20095 node = vat_json_array_add (&vam->json_tree);
20097 vat_json_init_object (node);
20098 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20099 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
20100 vat_json_object_add_uint (node, "label", ntohl (mp->label));
20101 vat_json_object_add_uint (node, "path_count", count);
20103 for (i = 0; i < count; i++)
20105 vl_api_mpls_fib_path_json_print (node, fp);
20111 api_mpls_fib_dump (vat_main_t * vam)
20113 vl_api_mpls_fib_dump_t *mp;
20114 vl_api_control_ping_t *mp_ping;
20117 M (MPLS_FIB_DUMP, mp);
20120 /* Use a control ping for synchronization */
20121 MPING (CONTROL_PING, mp_ping);
20128 #define vl_api_ip_fib_details_t_endian vl_noop_handler
20129 #define vl_api_ip_fib_details_t_print vl_noop_handler
20132 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
20134 vat_main_t *vam = &vat_main;
20135 int count = ntohl (mp->count);
20136 vl_api_fib_path_t *fp;
20140 "table-id %d, prefix %U/%d",
20141 ntohl (mp->table_id), format_ip4_address, mp->address,
20142 mp->address_length);
20144 for (i = 0; i < count; i++)
20146 if (fp->afi == IP46_TYPE_IP6)
20148 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20149 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U, "
20150 "next_hop_table %d",
20151 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20152 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20153 format_ip6_address, fp->next_hop, ntohl (fp->table_id));
20154 else if (fp->afi == IP46_TYPE_IP4)
20156 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20157 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U, "
20158 "next_hop_table %d",
20159 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20160 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20161 format_ip4_address, fp->next_hop, ntohl (fp->table_id));
20166 static void vl_api_ip_fib_details_t_handler_json
20167 (vl_api_ip_fib_details_t * mp)
20169 vat_main_t *vam = &vat_main;
20170 int count = ntohl (mp->count);
20171 vat_json_node_t *node = NULL;
20172 struct in_addr ip4;
20173 struct in6_addr ip6;
20174 vl_api_fib_path_t *fp;
20177 if (VAT_JSON_ARRAY != vam->json_tree.type)
20179 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20180 vat_json_init_array (&vam->json_tree);
20182 node = vat_json_array_add (&vam->json_tree);
20184 vat_json_init_object (node);
20185 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20186 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
20187 vat_json_object_add_ip4 (node, "prefix", ip4);
20188 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20189 vat_json_object_add_uint (node, "path_count", count);
20191 for (i = 0; i < count; i++)
20193 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20194 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20195 vat_json_object_add_uint (node, "is_local", fp->is_local);
20196 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20197 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20198 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20199 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20200 if (fp->afi == IP46_TYPE_IP4)
20202 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20203 vat_json_object_add_ip4 (node, "next_hop", ip4);
20205 else if (fp->afi == IP46_TYPE_IP6)
20207 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20208 vat_json_object_add_ip6 (node, "next_hop", ip6);
20214 api_ip_fib_dump (vat_main_t * vam)
20216 vl_api_ip_fib_dump_t *mp;
20217 vl_api_control_ping_t *mp_ping;
20220 M (IP_FIB_DUMP, mp);
20223 /* Use a control ping for synchronization */
20224 MPING (CONTROL_PING, mp_ping);
20232 api_ip_mfib_dump (vat_main_t * vam)
20234 vl_api_ip_mfib_dump_t *mp;
20235 vl_api_control_ping_t *mp_ping;
20238 M (IP_MFIB_DUMP, mp);
20241 /* Use a control ping for synchronization */
20242 MPING (CONTROL_PING, mp_ping);
20249 static void vl_api_ip_neighbor_details_t_handler
20250 (vl_api_ip_neighbor_details_t * mp)
20252 vat_main_t *vam = &vat_main;
20254 print (vam->ofp, "%c %U %U",
20255 (mp->is_static) ? 'S' : 'D',
20256 format_ethernet_address, &mp->mac_address,
20257 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
20261 static void vl_api_ip_neighbor_details_t_handler_json
20262 (vl_api_ip_neighbor_details_t * mp)
20265 vat_main_t *vam = &vat_main;
20266 vat_json_node_t *node;
20267 struct in_addr ip4;
20268 struct in6_addr ip6;
20270 if (VAT_JSON_ARRAY != vam->json_tree.type)
20272 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20273 vat_json_init_array (&vam->json_tree);
20275 node = vat_json_array_add (&vam->json_tree);
20277 vat_json_init_object (node);
20278 vat_json_object_add_string_copy (node, "flag",
20279 (mp->is_static) ? (u8 *) "static" : (u8 *)
20282 vat_json_object_add_string_copy (node, "link_layer",
20283 format (0, "%U", format_ethernet_address,
20284 &mp->mac_address));
20288 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
20289 vat_json_object_add_ip6 (node, "ip_address", ip6);
20293 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
20294 vat_json_object_add_ip4 (node, "ip_address", ip4);
20299 api_ip_neighbor_dump (vat_main_t * vam)
20301 unformat_input_t *i = vam->input;
20302 vl_api_ip_neighbor_dump_t *mp;
20303 vl_api_control_ping_t *mp_ping;
20305 u32 sw_if_index = ~0;
20308 /* Parse args required to build the message */
20309 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20311 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20313 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20315 else if (unformat (i, "ip6"))
20321 if (sw_if_index == ~0)
20323 errmsg ("missing interface name or sw_if_index");
20327 M (IP_NEIGHBOR_DUMP, mp);
20328 mp->is_ipv6 = (u8) is_ipv6;
20329 mp->sw_if_index = ntohl (sw_if_index);
20332 /* Use a control ping for synchronization */
20333 MPING (CONTROL_PING, mp_ping);
20340 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
20341 #define vl_api_ip6_fib_details_t_print vl_noop_handler
20344 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
20346 vat_main_t *vam = &vat_main;
20347 int count = ntohl (mp->count);
20348 vl_api_fib_path_t *fp;
20352 "table-id %d, prefix %U/%d",
20353 ntohl (mp->table_id), format_ip6_address, mp->address,
20354 mp->address_length);
20356 for (i = 0; i < count; i++)
20358 if (fp->afi == IP46_TYPE_IP6)
20360 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20361 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20362 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20363 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20364 format_ip6_address, fp->next_hop);
20365 else if (fp->afi == IP46_TYPE_IP4)
20367 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20368 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20369 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20370 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20371 format_ip4_address, fp->next_hop);
20376 static void vl_api_ip6_fib_details_t_handler_json
20377 (vl_api_ip6_fib_details_t * mp)
20379 vat_main_t *vam = &vat_main;
20380 int count = ntohl (mp->count);
20381 vat_json_node_t *node = NULL;
20382 struct in_addr ip4;
20383 struct in6_addr ip6;
20384 vl_api_fib_path_t *fp;
20387 if (VAT_JSON_ARRAY != vam->json_tree.type)
20389 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20390 vat_json_init_array (&vam->json_tree);
20392 node = vat_json_array_add (&vam->json_tree);
20394 vat_json_init_object (node);
20395 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20396 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
20397 vat_json_object_add_ip6 (node, "prefix", ip6);
20398 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20399 vat_json_object_add_uint (node, "path_count", count);
20401 for (i = 0; i < count; i++)
20403 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20404 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20405 vat_json_object_add_uint (node, "is_local", fp->is_local);
20406 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20407 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20408 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20409 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20410 if (fp->afi == IP46_TYPE_IP4)
20412 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20413 vat_json_object_add_ip4 (node, "next_hop", ip4);
20415 else if (fp->afi == IP46_TYPE_IP6)
20417 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20418 vat_json_object_add_ip6 (node, "next_hop", ip6);
20424 api_ip6_fib_dump (vat_main_t * vam)
20426 vl_api_ip6_fib_dump_t *mp;
20427 vl_api_control_ping_t *mp_ping;
20430 M (IP6_FIB_DUMP, mp);
20433 /* Use a control ping for synchronization */
20434 MPING (CONTROL_PING, mp_ping);
20442 api_ip6_mfib_dump (vat_main_t * vam)
20444 vl_api_ip6_mfib_dump_t *mp;
20445 vl_api_control_ping_t *mp_ping;
20448 M (IP6_MFIB_DUMP, mp);
20451 /* Use a control ping for synchronization */
20452 MPING (CONTROL_PING, mp_ping);
20460 api_classify_table_ids (vat_main_t * vam)
20462 vl_api_classify_table_ids_t *mp;
20465 /* Construct the API message */
20466 M (CLASSIFY_TABLE_IDS, mp);
20475 api_classify_table_by_interface (vat_main_t * vam)
20477 unformat_input_t *input = vam->input;
20478 vl_api_classify_table_by_interface_t *mp;
20480 u32 sw_if_index = ~0;
20482 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20484 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20486 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20491 if (sw_if_index == ~0)
20493 errmsg ("missing interface name or sw_if_index");
20497 /* Construct the API message */
20498 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
20500 mp->sw_if_index = ntohl (sw_if_index);
20508 api_classify_table_info (vat_main_t * vam)
20510 unformat_input_t *input = vam->input;
20511 vl_api_classify_table_info_t *mp;
20515 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20517 if (unformat (input, "table_id %d", &table_id))
20522 if (table_id == ~0)
20524 errmsg ("missing table id");
20528 /* Construct the API message */
20529 M (CLASSIFY_TABLE_INFO, mp);
20531 mp->table_id = ntohl (table_id);
20539 api_classify_session_dump (vat_main_t * vam)
20541 unformat_input_t *input = vam->input;
20542 vl_api_classify_session_dump_t *mp;
20543 vl_api_control_ping_t *mp_ping;
20547 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20549 if (unformat (input, "table_id %d", &table_id))
20554 if (table_id == ~0)
20556 errmsg ("missing table id");
20560 /* Construct the API message */
20561 M (CLASSIFY_SESSION_DUMP, mp);
20563 mp->table_id = ntohl (table_id);
20566 /* Use a control ping for synchronization */
20567 MPING (CONTROL_PING, mp_ping);
20575 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
20577 vat_main_t *vam = &vat_main;
20579 print (vam->ofp, "collector_address %U, collector_port %d, "
20580 "src_address %U, vrf_id %d, path_mtu %u, "
20581 "template_interval %u, udp_checksum %d",
20582 format_ip4_address, mp->collector_address,
20583 ntohs (mp->collector_port),
20584 format_ip4_address, mp->src_address,
20585 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
20586 ntohl (mp->template_interval), mp->udp_checksum);
20589 vam->result_ready = 1;
20593 vl_api_ipfix_exporter_details_t_handler_json
20594 (vl_api_ipfix_exporter_details_t * mp)
20596 vat_main_t *vam = &vat_main;
20597 vat_json_node_t node;
20598 struct in_addr collector_address;
20599 struct in_addr src_address;
20601 vat_json_init_object (&node);
20602 clib_memcpy (&collector_address, &mp->collector_address,
20603 sizeof (collector_address));
20604 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
20605 vat_json_object_add_uint (&node, "collector_port",
20606 ntohs (mp->collector_port));
20607 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
20608 vat_json_object_add_ip4 (&node, "src_address", src_address);
20609 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
20610 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
20611 vat_json_object_add_uint (&node, "template_interval",
20612 ntohl (mp->template_interval));
20613 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
20615 vat_json_print (vam->ofp, &node);
20616 vat_json_free (&node);
20618 vam->result_ready = 1;
20622 api_ipfix_exporter_dump (vat_main_t * vam)
20624 vl_api_ipfix_exporter_dump_t *mp;
20627 /* Construct the API message */
20628 M (IPFIX_EXPORTER_DUMP, mp);
20637 api_ipfix_classify_stream_dump (vat_main_t * vam)
20639 vl_api_ipfix_classify_stream_dump_t *mp;
20642 /* Construct the API message */
20643 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
20654 vl_api_ipfix_classify_stream_details_t_handler
20655 (vl_api_ipfix_classify_stream_details_t * mp)
20657 vat_main_t *vam = &vat_main;
20658 print (vam->ofp, "domain_id %d, src_port %d",
20659 ntohl (mp->domain_id), ntohs (mp->src_port));
20661 vam->result_ready = 1;
20665 vl_api_ipfix_classify_stream_details_t_handler_json
20666 (vl_api_ipfix_classify_stream_details_t * mp)
20668 vat_main_t *vam = &vat_main;
20669 vat_json_node_t node;
20671 vat_json_init_object (&node);
20672 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
20673 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
20675 vat_json_print (vam->ofp, &node);
20676 vat_json_free (&node);
20678 vam->result_ready = 1;
20682 api_ipfix_classify_table_dump (vat_main_t * vam)
20684 vl_api_ipfix_classify_table_dump_t *mp;
20685 vl_api_control_ping_t *mp_ping;
20688 if (!vam->json_output)
20690 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
20691 "transport_protocol");
20694 /* Construct the API message */
20695 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
20700 /* Use a control ping for synchronization */
20701 MPING (CONTROL_PING, mp_ping);
20709 vl_api_ipfix_classify_table_details_t_handler
20710 (vl_api_ipfix_classify_table_details_t * mp)
20712 vat_main_t *vam = &vat_main;
20713 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
20714 mp->transport_protocol);
20718 vl_api_ipfix_classify_table_details_t_handler_json
20719 (vl_api_ipfix_classify_table_details_t * mp)
20721 vat_json_node_t *node = NULL;
20722 vat_main_t *vam = &vat_main;
20724 if (VAT_JSON_ARRAY != vam->json_tree.type)
20726 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20727 vat_json_init_array (&vam->json_tree);
20730 node = vat_json_array_add (&vam->json_tree);
20731 vat_json_init_object (node);
20733 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
20734 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
20735 vat_json_object_add_uint (node, "transport_protocol",
20736 mp->transport_protocol);
20740 api_sw_interface_span_enable_disable (vat_main_t * vam)
20742 unformat_input_t *i = vam->input;
20743 vl_api_sw_interface_span_enable_disable_t *mp;
20744 u32 src_sw_if_index = ~0;
20745 u32 dst_sw_if_index = ~0;
20750 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20753 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
20755 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
20759 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
20761 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
20763 else if (unformat (i, "disable"))
20765 else if (unformat (i, "rx"))
20767 else if (unformat (i, "tx"))
20769 else if (unformat (i, "both"))
20771 else if (unformat (i, "l2"))
20777 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
20779 mp->sw_if_index_from = htonl (src_sw_if_index);
20780 mp->sw_if_index_to = htonl (dst_sw_if_index);
20790 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
20793 vat_main_t *vam = &vat_main;
20794 u8 *sw_if_from_name = 0;
20795 u8 *sw_if_to_name = 0;
20796 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
20797 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
20798 char *states[] = { "none", "rx", "tx", "both" };
20802 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
20804 if ((u32) p->value[0] == sw_if_index_from)
20806 sw_if_from_name = (u8 *)(p->key);
20810 if ((u32) p->value[0] == sw_if_index_to)
20812 sw_if_to_name = (u8 *)(p->key);
20813 if (sw_if_from_name)
20818 print (vam->ofp, "%20s => %20s (%s) %s",
20819 sw_if_from_name, sw_if_to_name, states[mp->state],
20820 mp->is_l2 ? "l2" : "device");
20824 vl_api_sw_interface_span_details_t_handler_json
20825 (vl_api_sw_interface_span_details_t * mp)
20827 vat_main_t *vam = &vat_main;
20828 vat_json_node_t *node = NULL;
20829 u8 *sw_if_from_name = 0;
20830 u8 *sw_if_to_name = 0;
20831 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
20832 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
20836 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
20838 if ((u32) p->value[0] == sw_if_index_from)
20840 sw_if_from_name = (u8 *)(p->key);
20844 if ((u32) p->value[0] == sw_if_index_to)
20846 sw_if_to_name = (u8 *)(p->key);
20847 if (sw_if_from_name)
20853 if (VAT_JSON_ARRAY != vam->json_tree.type)
20855 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20856 vat_json_init_array (&vam->json_tree);
20858 node = vat_json_array_add (&vam->json_tree);
20860 vat_json_init_object (node);
20861 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
20862 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
20863 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
20864 if (0 != sw_if_to_name)
20866 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
20868 vat_json_object_add_uint (node, "state", mp->state);
20869 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
20873 api_sw_interface_span_dump (vat_main_t * vam)
20875 unformat_input_t *input = vam->input;
20876 vl_api_sw_interface_span_dump_t *mp;
20877 vl_api_control_ping_t *mp_ping;
20881 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20883 if (unformat (input, "l2"))
20889 M (SW_INTERFACE_SPAN_DUMP, mp);
20893 /* Use a control ping for synchronization */
20894 MPING (CONTROL_PING, mp_ping);
20902 api_pg_create_interface (vat_main_t * vam)
20904 unformat_input_t *input = vam->input;
20905 vl_api_pg_create_interface_t *mp;
20909 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20911 if (unformat (input, "if_id %d", &if_id))
20918 errmsg ("missing pg interface index");
20922 /* Construct the API message */
20923 M (PG_CREATE_INTERFACE, mp);
20925 mp->interface_id = ntohl (if_id);
20933 api_pg_capture (vat_main_t * vam)
20935 unformat_input_t *input = vam->input;
20936 vl_api_pg_capture_t *mp;
20941 u8 pcap_file_set = 0;
20944 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20946 if (unformat (input, "if_id %d", &if_id))
20948 else if (unformat (input, "pcap %s", &pcap_file))
20950 else if (unformat (input, "count %d", &count))
20952 else if (unformat (input, "disable"))
20959 errmsg ("missing pg interface index");
20962 if (pcap_file_set > 0)
20964 if (vec_len (pcap_file) > 255)
20966 errmsg ("pcap file name is too long");
20971 u32 name_len = vec_len (pcap_file);
20972 /* Construct the API message */
20973 M (PG_CAPTURE, mp);
20975 mp->interface_id = ntohl (if_id);
20976 mp->is_enabled = enable;
20977 mp->count = ntohl (count);
20978 mp->pcap_name_length = ntohl (name_len);
20979 if (pcap_file_set != 0)
20981 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
20983 vec_free (pcap_file);
20991 api_pg_enable_disable (vat_main_t * vam)
20993 unformat_input_t *input = vam->input;
20994 vl_api_pg_enable_disable_t *mp;
20997 u8 stream_name_set = 0;
20998 u8 *stream_name = 0;
21000 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21002 if (unformat (input, "stream %s", &stream_name))
21003 stream_name_set = 1;
21004 else if (unformat (input, "disable"))
21010 if (stream_name_set > 0)
21012 if (vec_len (stream_name) > 255)
21014 errmsg ("stream name too long");
21019 u32 name_len = vec_len (stream_name);
21020 /* Construct the API message */
21021 M (PG_ENABLE_DISABLE, mp);
21023 mp->is_enabled = enable;
21024 if (stream_name_set != 0)
21026 mp->stream_name_length = ntohl (name_len);
21027 clib_memcpy (mp->stream_name, stream_name, name_len);
21029 vec_free (stream_name);
21037 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
21039 unformat_input_t *input = vam->input;
21040 vl_api_ip_source_and_port_range_check_add_del_t *mp;
21042 u16 *low_ports = 0;
21043 u16 *high_ports = 0;
21046 ip4_address_t ip4_addr;
21047 ip6_address_t ip6_addr;
21056 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21058 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
21064 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
21069 else if (unformat (input, "vrf %d", &vrf_id))
21071 else if (unformat (input, "del"))
21073 else if (unformat (input, "port %d", &tmp))
21075 if (tmp == 0 || tmp > 65535)
21077 errmsg ("port %d out of range", tmp);
21081 this_hi = this_low + 1;
21082 vec_add1 (low_ports, this_low);
21083 vec_add1 (high_ports, this_hi);
21085 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
21087 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
21089 errmsg ("incorrect range parameters");
21093 /* Note: in debug CLI +1 is added to high before
21094 passing to real fn that does "the work"
21095 (ip_source_and_port_range_check_add_del).
21096 This fn is a wrapper around the binary API fn a
21097 control plane will call, which expects this increment
21098 to have occurred. Hence letting the binary API control
21099 plane fn do the increment for consistency between VAT
21100 and other control planes.
21103 vec_add1 (low_ports, this_low);
21104 vec_add1 (high_ports, this_hi);
21110 if (prefix_set == 0)
21112 errmsg ("<address>/<mask> not specified");
21118 errmsg ("VRF ID required, not specified");
21125 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21129 if (vec_len (low_ports) == 0)
21131 errmsg ("At least one port or port range required");
21135 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
21137 mp->is_add = is_add;
21142 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
21147 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
21150 mp->mask_length = length;
21151 mp->number_of_ranges = vec_len (low_ports);
21153 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
21154 vec_free (low_ports);
21156 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
21157 vec_free (high_ports);
21159 mp->vrf_id = ntohl (vrf_id);
21167 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
21169 unformat_input_t *input = vam->input;
21170 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
21171 u32 sw_if_index = ~0;
21173 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
21174 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
21178 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21180 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21182 else if (unformat (input, "sw_if_index %d", &sw_if_index))
21184 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
21186 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
21188 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
21190 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
21192 else if (unformat (input, "del"))
21198 if (sw_if_index == ~0)
21200 errmsg ("Interface required but not specified");
21206 errmsg ("VRF ID required but not specified");
21210 if (tcp_out_vrf_id == 0
21211 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
21214 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21218 /* Construct the API message */
21219 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
21221 mp->sw_if_index = ntohl (sw_if_index);
21222 mp->is_add = is_add;
21223 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
21224 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
21225 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
21226 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
21231 /* Wait for a reply... */
21237 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
21239 unformat_input_t *i = vam->input;
21240 vl_api_ipsec_gre_add_del_tunnel_t *mp;
21241 u32 local_sa_id = 0;
21242 u32 remote_sa_id = 0;
21243 ip4_address_t src_address;
21244 ip4_address_t dst_address;
21248 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21250 if (unformat (i, "local_sa %d", &local_sa_id))
21252 else if (unformat (i, "remote_sa %d", &remote_sa_id))
21254 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
21256 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
21258 else if (unformat (i, "del"))
21262 clib_warning ("parse error '%U'", format_unformat_error, i);
21267 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
21269 mp->local_sa_id = ntohl (local_sa_id);
21270 mp->remote_sa_id = ntohl (remote_sa_id);
21271 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
21272 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
21273 mp->is_add = is_add;
21281 api_punt (vat_main_t * vam)
21283 unformat_input_t *i = vam->input;
21291 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21293 if (unformat (i, "ip %d", &ipv))
21295 else if (unformat (i, "protocol %d", &protocol))
21297 else if (unformat (i, "port %d", &port))
21299 else if (unformat (i, "del"))
21303 clib_warning ("parse error '%U'", format_unformat_error, i);
21310 mp->is_add = (u8) is_add;
21311 mp->ipv = (u8) ipv;
21312 mp->l4_protocol = (u8) protocol;
21313 mp->l4_port = htons ((u16) port);
21320 static void vl_api_ipsec_gre_tunnel_details_t_handler
21321 (vl_api_ipsec_gre_tunnel_details_t * mp)
21323 vat_main_t *vam = &vat_main;
21325 print (vam->ofp, "%11d%15U%15U%14d%14d",
21326 ntohl (mp->sw_if_index),
21327 format_ip4_address, &mp->src_address,
21328 format_ip4_address, &mp->dst_address,
21329 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
21332 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
21333 (vl_api_ipsec_gre_tunnel_details_t * mp)
21335 vat_main_t *vam = &vat_main;
21336 vat_json_node_t *node = NULL;
21337 struct in_addr ip4;
21339 if (VAT_JSON_ARRAY != vam->json_tree.type)
21341 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21342 vat_json_init_array (&vam->json_tree);
21344 node = vat_json_array_add (&vam->json_tree);
21346 vat_json_init_object (node);
21347 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
21348 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
21349 vat_json_object_add_ip4 (node, "src_address", ip4);
21350 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
21351 vat_json_object_add_ip4 (node, "dst_address", ip4);
21352 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
21353 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
21357 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
21359 unformat_input_t *i = vam->input;
21360 vl_api_ipsec_gre_tunnel_dump_t *mp;
21361 vl_api_control_ping_t *mp_ping;
21363 u8 sw_if_index_set = 0;
21366 /* Parse args required to build the message */
21367 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21369 if (unformat (i, "sw_if_index %d", &sw_if_index))
21370 sw_if_index_set = 1;
21375 if (sw_if_index_set == 0)
21380 if (!vam->json_output)
21382 print (vam->ofp, "%11s%15s%15s%14s%14s",
21383 "sw_if_index", "src_address", "dst_address",
21384 "local_sa_id", "remote_sa_id");
21387 /* Get list of gre-tunnel interfaces */
21388 M (IPSEC_GRE_TUNNEL_DUMP, mp);
21390 mp->sw_if_index = htonl (sw_if_index);
21394 /* Use a control ping for synchronization */
21395 MPING (CONTROL_PING, mp_ping);
21403 api_delete_subif (vat_main_t * vam)
21405 unformat_input_t *i = vam->input;
21406 vl_api_delete_subif_t *mp;
21407 u32 sw_if_index = ~0;
21410 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21412 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21414 if (unformat (i, "sw_if_index %d", &sw_if_index))
21420 if (sw_if_index == ~0)
21422 errmsg ("missing sw_if_index");
21426 /* Construct the API message */
21427 M (DELETE_SUBIF, mp);
21428 mp->sw_if_index = ntohl (sw_if_index);
21435 #define foreach_pbb_vtr_op \
21436 _("disable", L2_VTR_DISABLED) \
21437 _("pop", L2_VTR_POP_2) \
21438 _("push", L2_VTR_PUSH_2)
21441 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
21443 unformat_input_t *i = vam->input;
21444 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
21445 u32 sw_if_index = ~0, vtr_op = ~0;
21446 u16 outer_tag = ~0;
21447 u8 dmac[6], smac[6];
21448 u8 dmac_set = 0, smac_set = 0;
21454 /* Shut up coverity */
21455 memset (dmac, 0, sizeof (dmac));
21456 memset (smac, 0, sizeof (smac));
21458 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21460 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21462 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21464 else if (unformat (i, "vtr_op %d", &vtr_op))
21466 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
21469 else if (unformat (i, "translate_pbb_stag"))
21471 if (unformat (i, "%d", &tmp))
21473 vtr_op = L2_VTR_TRANSLATE_2_1;
21479 ("translate_pbb_stag operation requires outer tag definition");
21483 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
21485 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
21487 else if (unformat (i, "sid %d", &sid))
21489 else if (unformat (i, "vlanid %d", &tmp))
21493 clib_warning ("parse error '%U'", format_unformat_error, i);
21498 if ((sw_if_index == ~0) || (vtr_op == ~0))
21500 errmsg ("missing sw_if_index or vtr operation");
21503 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
21504 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
21507 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
21511 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
21512 mp->sw_if_index = ntohl (sw_if_index);
21513 mp->vtr_op = ntohl (vtr_op);
21514 mp->outer_tag = ntohs (outer_tag);
21515 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
21516 clib_memcpy (mp->b_smac, smac, sizeof (smac));
21517 mp->b_vlanid = ntohs (vlanid);
21518 mp->i_sid = ntohl (sid);
21526 api_flow_classify_set_interface (vat_main_t * vam)
21528 unformat_input_t *i = vam->input;
21529 vl_api_flow_classify_set_interface_t *mp;
21531 int sw_if_index_set;
21532 u32 ip4_table_index = ~0;
21533 u32 ip6_table_index = ~0;
21537 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21539 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21540 sw_if_index_set = 1;
21541 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21542 sw_if_index_set = 1;
21543 else if (unformat (i, "del"))
21545 else if (unformat (i, "ip4-table %d", &ip4_table_index))
21547 else if (unformat (i, "ip6-table %d", &ip6_table_index))
21551 clib_warning ("parse error '%U'", format_unformat_error, i);
21556 if (sw_if_index_set == 0)
21558 errmsg ("missing interface name or sw_if_index");
21562 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
21564 mp->sw_if_index = ntohl (sw_if_index);
21565 mp->ip4_table_index = ntohl (ip4_table_index);
21566 mp->ip6_table_index = ntohl (ip6_table_index);
21567 mp->is_add = is_add;
21575 api_flow_classify_dump (vat_main_t * vam)
21577 unformat_input_t *i = vam->input;
21578 vl_api_flow_classify_dump_t *mp;
21579 vl_api_control_ping_t *mp_ping;
21580 u8 type = FLOW_CLASSIFY_N_TABLES;
21583 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
21587 errmsg ("classify table type must be specified");
21591 if (!vam->json_output)
21593 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
21596 M (FLOW_CLASSIFY_DUMP, mp);
21601 /* Use a control ping for synchronization */
21602 MPING (CONTROL_PING, mp_ping);
21605 /* Wait for a reply... */
21611 api_feature_enable_disable (vat_main_t * vam)
21613 unformat_input_t *i = vam->input;
21614 vl_api_feature_enable_disable_t *mp;
21616 u8 *feature_name = 0;
21617 u32 sw_if_index = ~0;
21621 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21623 if (unformat (i, "arc_name %s", &arc_name))
21625 else if (unformat (i, "feature_name %s", &feature_name))
21628 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21630 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21632 else if (unformat (i, "disable"))
21640 errmsg ("missing arc name");
21643 if (vec_len (arc_name) > 63)
21645 errmsg ("arc name too long");
21648 if (feature_name == 0)
21650 errmsg ("missing feature name");
21653 if (vec_len (feature_name) > 63)
21655 errmsg ("feature name too long");
21658 if (sw_if_index == ~0)
21660 errmsg ("missing interface name or sw_if_index");
21664 /* Construct the API message */
21665 M (FEATURE_ENABLE_DISABLE, mp);
21666 mp->sw_if_index = ntohl (sw_if_index);
21667 mp->enable = enable;
21668 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
21669 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
21670 vec_free (arc_name);
21671 vec_free (feature_name);
21679 api_sw_interface_tag_add_del (vat_main_t * vam)
21681 unformat_input_t *i = vam->input;
21682 vl_api_sw_interface_tag_add_del_t *mp;
21683 u32 sw_if_index = ~0;
21688 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21690 if (unformat (i, "tag %s", &tag))
21692 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21694 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21696 else if (unformat (i, "del"))
21702 if (sw_if_index == ~0)
21704 errmsg ("missing interface name or sw_if_index");
21708 if (enable && (tag == 0))
21710 errmsg ("no tag specified");
21714 /* Construct the API message */
21715 M (SW_INTERFACE_TAG_ADD_DEL, mp);
21716 mp->sw_if_index = ntohl (sw_if_index);
21717 mp->is_add = enable;
21719 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
21727 static void vl_api_l2_xconnect_details_t_handler
21728 (vl_api_l2_xconnect_details_t * mp)
21730 vat_main_t *vam = &vat_main;
21732 print (vam->ofp, "%15d%15d",
21733 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
21736 static void vl_api_l2_xconnect_details_t_handler_json
21737 (vl_api_l2_xconnect_details_t * mp)
21739 vat_main_t *vam = &vat_main;
21740 vat_json_node_t *node = NULL;
21742 if (VAT_JSON_ARRAY != vam->json_tree.type)
21744 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21745 vat_json_init_array (&vam->json_tree);
21747 node = vat_json_array_add (&vam->json_tree);
21749 vat_json_init_object (node);
21750 vat_json_object_add_uint (node, "rx_sw_if_index",
21751 ntohl (mp->rx_sw_if_index));
21752 vat_json_object_add_uint (node, "tx_sw_if_index",
21753 ntohl (mp->tx_sw_if_index));
21757 api_l2_xconnect_dump (vat_main_t * vam)
21759 vl_api_l2_xconnect_dump_t *mp;
21760 vl_api_control_ping_t *mp_ping;
21763 if (!vam->json_output)
21765 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
21768 M (L2_XCONNECT_DUMP, mp);
21772 /* Use a control ping for synchronization */
21773 MPING (CONTROL_PING, mp_ping);
21781 api_hw_interface_set_mtu (vat_main_t * vam)
21783 unformat_input_t *i = vam->input;
21784 vl_api_hw_interface_set_mtu_t *mp;
21785 u32 sw_if_index = ~0;
21789 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21791 if (unformat (i, "mtu %d", &mtu))
21793 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21795 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21801 if (sw_if_index == ~0)
21803 errmsg ("missing interface name or sw_if_index");
21809 errmsg ("no mtu specified");
21813 /* Construct the API message */
21814 M (HW_INTERFACE_SET_MTU, mp);
21815 mp->sw_if_index = ntohl (sw_if_index);
21816 mp->mtu = ntohs ((u16) mtu);
21824 api_p2p_ethernet_add (vat_main_t * vam)
21826 unformat_input_t *i = vam->input;
21827 vl_api_p2p_ethernet_add_t *mp;
21828 u32 parent_if_index = ~0;
21834 memset (remote_mac, 0, sizeof (remote_mac));
21835 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21837 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
21839 else if (unformat (i, "sw_if_index %d", &parent_if_index))
21843 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
21845 else if (unformat (i, "sub_id %d", &sub_id))
21849 clib_warning ("parse error '%U'", format_unformat_error, i);
21854 if (parent_if_index == ~0)
21856 errmsg ("missing interface name or sw_if_index");
21861 errmsg ("missing remote mac address");
21866 errmsg ("missing sub-interface id");
21870 M (P2P_ETHERNET_ADD, mp);
21871 mp->parent_if_index = ntohl (parent_if_index);
21872 mp->subif_id = ntohl (sub_id);
21873 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
21881 api_p2p_ethernet_del (vat_main_t * vam)
21883 unformat_input_t *i = vam->input;
21884 vl_api_p2p_ethernet_del_t *mp;
21885 u32 parent_if_index = ~0;
21890 memset (remote_mac, 0, sizeof (remote_mac));
21891 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21893 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
21895 else if (unformat (i, "sw_if_index %d", &parent_if_index))
21899 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
21903 clib_warning ("parse error '%U'", format_unformat_error, i);
21908 if (parent_if_index == ~0)
21910 errmsg ("missing interface name or sw_if_index");
21915 errmsg ("missing remote mac address");
21919 M (P2P_ETHERNET_DEL, mp);
21920 mp->parent_if_index = ntohl (parent_if_index);
21921 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
21929 api_lldp_config (vat_main_t * vam)
21931 unformat_input_t *i = vam->input;
21932 vl_api_lldp_config_t *mp;
21934 int tx_interval = 0;
21935 u8 *sys_name = NULL;
21938 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21940 if (unformat (i, "system-name %s", &sys_name))
21942 else if (unformat (i, "tx-hold %d", &tx_hold))
21944 else if (unformat (i, "tx-interval %d", &tx_interval))
21948 clib_warning ("parse error '%U'", format_unformat_error, i);
21953 vec_add1 (sys_name, 0);
21955 M (LLDP_CONFIG, mp);
21956 mp->tx_hold = htonl (tx_hold);
21957 mp->tx_interval = htonl (tx_interval);
21958 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
21959 vec_free (sys_name);
21967 api_sw_interface_set_lldp (vat_main_t * vam)
21969 unformat_input_t *i = vam->input;
21970 vl_api_sw_interface_set_lldp_t *mp;
21971 u32 sw_if_index = ~0;
21973 u8 *port_desc = NULL, *mgmt_oid = NULL;
21974 ip4_address_t ip4_addr;
21975 ip6_address_t ip6_addr;
21978 memset (&ip4_addr, 0, sizeof (ip4_addr));
21979 memset (&ip6_addr, 0, sizeof (ip6_addr));
21981 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21983 if (unformat (i, "disable"))
21986 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21988 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21990 else if (unformat (i, "port-desc %s", &port_desc))
21992 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
21994 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
21996 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
22002 if (sw_if_index == ~0)
22004 errmsg ("missing interface name or sw_if_index");
22008 /* Construct the API message */
22009 vec_add1 (port_desc, 0);
22010 vec_add1 (mgmt_oid, 0);
22011 M (SW_INTERFACE_SET_LLDP, mp);
22012 mp->sw_if_index = ntohl (sw_if_index);
22013 mp->enable = enable;
22014 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
22015 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
22016 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
22017 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
22018 vec_free (port_desc);
22019 vec_free (mgmt_oid);
22027 api_tcp_configure_src_addresses (vat_main_t * vam)
22029 vl_api_tcp_configure_src_addresses_t *mp;
22030 unformat_input_t *i = vam->input;
22031 ip4_address_t v4first, v4last;
22032 ip6_address_t v6first, v6last;
22037 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22039 if (unformat (i, "%U - %U",
22040 unformat_ip4_address, &v4first,
22041 unformat_ip4_address, &v4last))
22045 errmsg ("one range per message (range already set)");
22050 else if (unformat (i, "%U - %U",
22051 unformat_ip6_address, &v6first,
22052 unformat_ip6_address, &v6last))
22056 errmsg ("one range per message (range already set)");
22061 else if (unformat (i, "vrf %d", &vrf_id))
22067 if (range_set == 0)
22069 errmsg ("address range not set");
22073 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
22074 mp->vrf_id = ntohl (vrf_id);
22076 if (range_set == 2)
22079 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
22080 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
22085 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
22086 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
22093 static void vl_api_app_namespace_add_del_reply_t_handler
22094 (vl_api_app_namespace_add_del_reply_t * mp)
22096 vat_main_t *vam = &vat_main;
22097 i32 retval = ntohl (mp->retval);
22098 if (vam->async_mode)
22100 vam->async_errors += (retval < 0);
22104 vam->retval = retval;
22106 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
22107 vam->result_ready = 1;
22111 static void vl_api_app_namespace_add_del_reply_t_handler_json
22112 (vl_api_app_namespace_add_del_reply_t * mp)
22114 vat_main_t *vam = &vat_main;
22115 vat_json_node_t node;
22117 vat_json_init_object (&node);
22118 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
22119 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
22121 vat_json_print (vam->ofp, &node);
22122 vat_json_free (&node);
22124 vam->retval = ntohl (mp->retval);
22125 vam->result_ready = 1;
22129 api_app_namespace_add_del (vat_main_t * vam)
22131 vl_api_app_namespace_add_del_t *mp;
22132 unformat_input_t *i = vam->input;
22133 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
22134 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
22138 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22140 if (unformat (i, "id %_%v%_", &ns_id))
22142 else if (unformat (i, "secret %lu", &secret))
22144 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22145 sw_if_index_set = 1;
22146 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
22148 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
22153 if (!ns_id || !secret_set || !sw_if_index_set)
22155 errmsg ("namespace id, secret and sw_if_index must be set");
22158 if (vec_len (ns_id) > 64)
22160 errmsg ("namespace id too long");
22163 M (APP_NAMESPACE_ADD_DEL, mp);
22165 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
22166 mp->namespace_id_len = vec_len (ns_id);
22167 mp->secret = clib_host_to_net_u64 (secret);
22168 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
22169 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
22170 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
22178 api_sock_init_shm (vat_main_t * vam)
22180 #if VPP_API_TEST_BUILTIN == 0
22181 unformat_input_t *i = vam->input;
22182 vl_api_shm_elem_config_t *config = 0;
22183 u64 size = 64 << 20;
22186 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22188 if (unformat (i, "size %U", unformat_memory_size, &size))
22195 * Canned custom ring allocator config.
22196 * Should probably parse all of this
22198 vec_validate (config, 6);
22199 config[0].type = VL_API_VLIB_RING;
22200 config[0].size = 256;
22201 config[0].count = 32;
22203 config[1].type = VL_API_VLIB_RING;
22204 config[1].size = 1024;
22205 config[1].count = 16;
22207 config[2].type = VL_API_VLIB_RING;
22208 config[2].size = 4096;
22209 config[2].count = 2;
22211 config[3].type = VL_API_CLIENT_RING;
22212 config[3].size = 256;
22213 config[3].count = 32;
22215 config[4].type = VL_API_CLIENT_RING;
22216 config[4].size = 1024;
22217 config[4].count = 16;
22219 config[5].type = VL_API_CLIENT_RING;
22220 config[5].size = 4096;
22221 config[5].count = 2;
22223 config[6].type = VL_API_QUEUE;
22224 config[6].count = 128;
22225 config[6].size = sizeof (uword);
22227 rv = vl_socket_client_init_shm (config);
22229 vam->client_index_invalid = 1;
22237 api_dns_enable_disable (vat_main_t * vam)
22239 unformat_input_t *line_input = vam->input;
22240 vl_api_dns_enable_disable_t *mp;
22241 u8 enable_disable = 1;
22244 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22246 if (unformat (line_input, "disable"))
22247 enable_disable = 0;
22248 if (unformat (line_input, "enable"))
22249 enable_disable = 1;
22254 /* Construct the API message */
22255 M (DNS_ENABLE_DISABLE, mp);
22256 mp->enable = enable_disable;
22260 /* Wait for the reply */
22266 api_dns_resolve_name (vat_main_t * vam)
22268 unformat_input_t *line_input = vam->input;
22269 vl_api_dns_resolve_name_t *mp;
22273 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22275 if (unformat (line_input, "%s", &name))
22281 if (vec_len (name) > 127)
22283 errmsg ("name too long");
22287 /* Construct the API message */
22288 M (DNS_RESOLVE_NAME, mp);
22289 memcpy (mp->name, name, vec_len (name));
22294 /* Wait for the reply */
22300 api_dns_resolve_ip (vat_main_t * vam)
22302 unformat_input_t *line_input = vam->input;
22303 vl_api_dns_resolve_ip_t *mp;
22305 ip4_address_t addr4;
22306 ip6_address_t addr6;
22309 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22311 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
22313 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
22321 errmsg ("missing address");
22325 /* Construct the API message */
22326 M (DNS_RESOLVE_IP, mp);
22327 mp->is_ip6 = is_ip6;
22329 memcpy (mp->address, &addr6, sizeof (addr6));
22331 memcpy (mp->address, &addr4, sizeof (addr4));
22335 /* Wait for the reply */
22341 api_dns_name_server_add_del (vat_main_t * vam)
22343 unformat_input_t *i = vam->input;
22344 vl_api_dns_name_server_add_del_t *mp;
22346 ip6_address_t ip6_server;
22347 ip4_address_t ip4_server;
22352 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22354 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
22356 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
22358 else if (unformat (i, "del"))
22362 clib_warning ("parse error '%U'", format_unformat_error, i);
22367 if (ip4_set && ip6_set)
22369 errmsg ("Only one server address allowed per message");
22372 if ((ip4_set + ip6_set) == 0)
22374 errmsg ("Server address required");
22378 /* Construct the API message */
22379 M (DNS_NAME_SERVER_ADD_DEL, mp);
22383 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
22388 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
22392 mp->is_add = is_add;
22397 /* Wait for a reply, return good/bad news */
22403 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
22405 vat_main_t *vam = &vat_main;
22410 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22411 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22412 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
22413 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
22414 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22415 clib_net_to_host_u32 (mp->action_index), mp->tag);
22420 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22421 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22422 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
22423 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
22424 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22425 clib_net_to_host_u32 (mp->action_index), mp->tag);
22430 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
22433 vat_main_t *vam = &vat_main;
22434 vat_json_node_t *node = NULL;
22435 struct in6_addr ip6;
22436 struct in_addr ip4;
22438 if (VAT_JSON_ARRAY != vam->json_tree.type)
22440 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22441 vat_json_init_array (&vam->json_tree);
22443 node = vat_json_array_add (&vam->json_tree);
22444 vat_json_init_object (node);
22446 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
22447 vat_json_object_add_uint (node, "appns_index",
22448 clib_net_to_host_u32 (mp->appns_index));
22449 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
22450 vat_json_object_add_uint (node, "scope", mp->scope);
22451 vat_json_object_add_uint (node, "action_index",
22452 clib_net_to_host_u32 (mp->action_index));
22453 vat_json_object_add_uint (node, "lcl_port",
22454 clib_net_to_host_u16 (mp->lcl_port));
22455 vat_json_object_add_uint (node, "rmt_port",
22456 clib_net_to_host_u16 (mp->rmt_port));
22457 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
22458 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
22459 vat_json_object_add_string_copy (node, "tag", mp->tag);
22462 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
22463 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
22464 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
22465 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
22469 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
22470 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
22471 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
22472 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
22477 api_session_rule_add_del (vat_main_t * vam)
22479 vl_api_session_rule_add_del_t *mp;
22480 unformat_input_t *i = vam->input;
22481 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
22482 u32 appns_index = 0, scope = 0;
22483 ip4_address_t lcl_ip4, rmt_ip4;
22484 ip6_address_t lcl_ip6, rmt_ip6;
22485 u8 is_ip4 = 1, conn_set = 0;
22486 u8 is_add = 1, *tag = 0;
22489 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22491 if (unformat (i, "del"))
22493 else if (unformat (i, "add"))
22495 else if (unformat (i, "proto tcp"))
22497 else if (unformat (i, "proto udp"))
22499 else if (unformat (i, "appns %d", &appns_index))
22501 else if (unformat (i, "scope %d", &scope))
22503 else if (unformat (i, "tag %_%v%_", &tag))
22507 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
22508 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
22516 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
22517 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
22523 else if (unformat (i, "action %d", &action))
22528 if (proto == ~0 || !conn_set || action == ~0)
22530 errmsg ("transport proto, connection and action must be set");
22536 errmsg ("scope should be 0-3");
22540 M (SESSION_RULE_ADD_DEL, mp);
22542 mp->is_ip4 = is_ip4;
22543 mp->transport_proto = proto;
22544 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
22545 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
22546 mp->lcl_plen = lcl_plen;
22547 mp->rmt_plen = rmt_plen;
22548 mp->action_index = clib_host_to_net_u32 (action);
22549 mp->appns_index = clib_host_to_net_u32 (appns_index);
22551 mp->is_add = is_add;
22554 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
22555 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
22559 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
22560 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
22564 clib_memcpy (mp->tag, tag, vec_len (tag));
22574 api_session_rules_dump (vat_main_t * vam)
22576 vl_api_session_rules_dump_t *mp;
22577 vl_api_control_ping_t *mp_ping;
22580 if (!vam->json_output)
22582 print (vam->ofp, "%=20s", "Session Rules");
22585 M (SESSION_RULES_DUMP, mp);
22589 /* Use a control ping for synchronization */
22590 MPING (CONTROL_PING, mp_ping);
22593 /* Wait for a reply... */
22599 api_ip_container_proxy_add_del (vat_main_t * vam)
22601 vl_api_ip_container_proxy_add_del_t *mp;
22602 unformat_input_t *i = vam->input;
22603 u32 plen = ~0, sw_if_index = ~0;
22610 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22612 if (unformat (i, "del"))
22614 else if (unformat (i, "add"))
22616 if (unformat (i, "%U", unformat_ip4_address, &ip4))
22621 else if (unformat (i, "%U", unformat_ip6_address, &ip6))
22626 else if (unformat (i, "sw_if_index %u", &sw_if_index))
22631 if (sw_if_index == ~0 || plen == ~0)
22633 errmsg ("address and sw_if_index must be set");
22637 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
22639 mp->is_ip4 = is_ip4;
22640 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
22642 mp->is_add = is_add;
22644 clib_memcpy (mp->ip, &ip4, sizeof (ip4));
22646 clib_memcpy (mp->ip, &ip6, sizeof (ip6));
22654 api_qos_record_enable_disable (vat_main_t * vam)
22656 unformat_input_t *i = vam->input;
22657 vl_api_qos_record_enable_disable_t *mp;
22658 u32 sw_if_index, qs = 0xff;
22659 u8 sw_if_index_set = 0;
22663 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22665 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22666 sw_if_index_set = 1;
22667 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22668 sw_if_index_set = 1;
22669 else if (unformat (i, "%U", unformat_qos_source, &qs))
22671 else if (unformat (i, "disable"))
22675 clib_warning ("parse error '%U'", format_unformat_error, i);
22680 if (sw_if_index_set == 0)
22682 errmsg ("missing interface name or sw_if_index");
22687 errmsg ("input location must be specified");
22691 M (QOS_RECORD_ENABLE_DISABLE, mp);
22693 mp->sw_if_index = ntohl (sw_if_index);
22694 mp->input_source = qs;
22695 mp->enable = enable;
22704 q_or_quit (vat_main_t * vam)
22706 #if VPP_API_TEST_BUILTIN == 0
22707 longjmp (vam->jump_buf, 1);
22709 return 0; /* not so much */
22713 q (vat_main_t * vam)
22715 return q_or_quit (vam);
22719 quit (vat_main_t * vam)
22721 return q_or_quit (vam);
22725 comment (vat_main_t * vam)
22731 statseg (vat_main_t * vam)
22733 ssvm_private_t *ssvmp = &vam->stat_segment;
22734 ssvm_shared_header_t *shared_header = ssvmp->sh;
22735 vlib_counter_t **counters;
22736 u64 thread0_index1_packets;
22737 u64 thread0_index1_bytes;
22738 f64 vector_rate, input_rate;
22741 uword *counter_vector_by_name;
22742 if (vam->stat_segment_lockp == 0)
22744 errmsg ("Stat segment not mapped...");
22748 /* look up "/if/rx for sw_if_index 1 as a test */
22750 clib_spinlock_lock (vam->stat_segment_lockp);
22752 counter_vector_by_name = (uword *) shared_header->opaque[1];
22754 p = hash_get_mem (counter_vector_by_name, "/if/rx");
22757 clib_spinlock_unlock (vam->stat_segment_lockp);
22758 errmsg ("/if/tx not found?");
22762 /* Fish per-thread vector of combined counters from shared memory */
22763 counters = (vlib_counter_t **) p[0];
22765 if (vec_len (counters[0]) < 2)
22767 clib_spinlock_unlock (vam->stat_segment_lockp);
22768 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
22772 /* Read thread 0 sw_if_index 1 counter */
22773 thread0_index1_packets = counters[0][1].packets;
22774 thread0_index1_bytes = counters[0][1].bytes;
22776 p = hash_get_mem (counter_vector_by_name, "vector_rate");
22779 clib_spinlock_unlock (vam->stat_segment_lockp);
22780 errmsg ("vector_rate not found?");
22784 vector_rate = *(f64 *) (p[0]);
22785 p = hash_get_mem (counter_vector_by_name, "input_rate");
22788 clib_spinlock_unlock (vam->stat_segment_lockp);
22789 errmsg ("input_rate not found?");
22792 input_rate = *(f64 *) (p[0]);
22794 clib_spinlock_unlock (vam->stat_segment_lockp);
22796 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
22797 vector_rate, input_rate);
22798 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
22799 thread0_index1_packets, thread0_index1_bytes);
22805 cmd_cmp (void *a1, void *a2)
22810 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
22814 help (vat_main_t * vam)
22819 unformat_input_t *i = vam->input;
22822 if (unformat (i, "%s", &name))
22826 vec_add1 (name, 0);
22828 hs = hash_get_mem (vam->help_by_name, name);
22830 print (vam->ofp, "usage: %s %s", name, hs[0]);
22832 print (vam->ofp, "No such msg / command '%s'", name);
22837 print (vam->ofp, "Help is available for the following:");
22840 hash_foreach_pair (p, vam->function_by_name,
22842 vec_add1 (cmds, (u8 *)(p->key));
22846 vec_sort_with_function (cmds, cmd_cmp);
22848 for (j = 0; j < vec_len (cmds); j++)
22849 print (vam->ofp, "%s", cmds[j]);
22856 set (vat_main_t * vam)
22858 u8 *name = 0, *value = 0;
22859 unformat_input_t *i = vam->input;
22861 if (unformat (i, "%s", &name))
22863 /* The input buffer is a vector, not a string. */
22864 value = vec_dup (i->buffer);
22865 vec_delete (value, i->index, 0);
22866 /* Almost certainly has a trailing newline */
22867 if (value[vec_len (value) - 1] == '\n')
22868 value[vec_len (value) - 1] = 0;
22869 /* Make sure it's a proper string, one way or the other */
22870 vec_add1 (value, 0);
22871 (void) clib_macro_set_value (&vam->macro_main,
22872 (char *) name, (char *) value);
22875 errmsg ("usage: set <name> <value>");
22883 unset (vat_main_t * vam)
22887 if (unformat (vam->input, "%s", &name))
22888 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
22889 errmsg ("unset: %s wasn't set", name);
22902 macro_sort_cmp (void *a1, void *a2)
22904 macro_sort_t *s1 = a1;
22905 macro_sort_t *s2 = a2;
22907 return strcmp ((char *) (s1->name), (char *) (s2->name));
22911 dump_macro_table (vat_main_t * vam)
22913 macro_sort_t *sort_me = 0, *sm;
22918 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
22920 vec_add2 (sort_me, sm, 1);
22921 sm->name = (u8 *)(p->key);
22922 sm->value = (u8 *) (p->value[0]);
22926 vec_sort_with_function (sort_me, macro_sort_cmp);
22928 if (vec_len (sort_me))
22929 print (vam->ofp, "%-15s%s", "Name", "Value");
22931 print (vam->ofp, "The macro table is empty...");
22933 for (i = 0; i < vec_len (sort_me); i++)
22934 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
22939 dump_node_table (vat_main_t * vam)
22942 vlib_node_t *node, *next_node;
22944 if (vec_len (vam->graph_nodes) == 0)
22946 print (vam->ofp, "Node table empty, issue get_node_graph...");
22950 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
22952 node = vam->graph_nodes[0][i];
22953 print (vam->ofp, "[%d] %s", i, node->name);
22954 for (j = 0; j < vec_len (node->next_nodes); j++)
22956 if (node->next_nodes[j] != ~0)
22958 next_node = vam->graph_nodes[0][node->next_nodes[j]];
22959 print (vam->ofp, " [%d] %s", j, next_node->name);
22967 value_sort_cmp (void *a1, void *a2)
22969 name_sort_t *n1 = a1;
22970 name_sort_t *n2 = a2;
22972 if (n1->value < n2->value)
22974 if (n1->value > n2->value)
22981 dump_msg_api_table (vat_main_t * vam)
22983 api_main_t *am = &api_main;
22984 name_sort_t *nses = 0, *ns;
22989 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
22991 vec_add2 (nses, ns, 1);
22992 ns->name = (u8 *)(hp->key);
22993 ns->value = (u32) hp->value[0];
22997 vec_sort_with_function (nses, value_sort_cmp);
22999 for (i = 0; i < vec_len (nses); i++)
23000 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
23006 get_msg_id (vat_main_t * vam)
23011 if (unformat (vam->input, "%s", &name_and_crc))
23013 message_index = vl_msg_api_get_msg_index (name_and_crc);
23014 if (message_index == ~0)
23016 print (vam->ofp, " '%s' not found", name_and_crc);
23019 print (vam->ofp, " '%s' has message index %d",
23020 name_and_crc, message_index);
23023 errmsg ("name_and_crc required...");
23028 search_node_table (vat_main_t * vam)
23030 unformat_input_t *line_input = vam->input;
23033 vlib_node_t *node, *next_node;
23036 if (vam->graph_node_index_by_name == 0)
23038 print (vam->ofp, "Node table empty, issue get_node_graph...");
23042 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
23044 if (unformat (line_input, "%s", &node_to_find))
23046 vec_add1 (node_to_find, 0);
23047 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
23050 print (vam->ofp, "%s not found...", node_to_find);
23053 node = vam->graph_nodes[0][p[0]];
23054 print (vam->ofp, "[%d] %s", p[0], node->name);
23055 for (j = 0; j < vec_len (node->next_nodes); j++)
23057 if (node->next_nodes[j] != ~0)
23059 next_node = vam->graph_nodes[0][node->next_nodes[j]];
23060 print (vam->ofp, " [%d] %s", j, next_node->name);
23067 clib_warning ("parse error '%U'", format_unformat_error,
23073 vec_free (node_to_find);
23082 script (vat_main_t * vam)
23084 #if (VPP_API_TEST_BUILTIN==0)
23086 char *save_current_file;
23087 unformat_input_t save_input;
23088 jmp_buf save_jump_buf;
23089 u32 save_line_number;
23091 FILE *new_fp, *save_ifp;
23093 if (unformat (vam->input, "%s", &s))
23095 new_fp = fopen ((char *) s, "r");
23098 errmsg ("Couldn't open script file %s", s);
23105 errmsg ("Missing script name");
23109 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
23110 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
23111 save_ifp = vam->ifp;
23112 save_line_number = vam->input_line_number;
23113 save_current_file = (char *) vam->current_file;
23115 vam->input_line_number = 0;
23117 vam->current_file = s;
23120 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
23121 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
23122 vam->ifp = save_ifp;
23123 vam->input_line_number = save_line_number;
23124 vam->current_file = (u8 *) save_current_file;
23129 clib_warning ("use the exec command...");
23135 echo (vat_main_t * vam)
23137 print (vam->ofp, "%v", vam->input->buffer);
23141 /* List of API message constructors, CLI names map to api_xxx */
23142 #define foreach_vpe_api_msg \
23143 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
23144 _(sw_interface_dump,"") \
23145 _(sw_interface_set_flags, \
23146 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
23147 _(sw_interface_add_del_address, \
23148 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
23149 _(sw_interface_set_rx_mode, \
23150 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
23151 _(sw_interface_set_table, \
23152 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
23153 _(sw_interface_set_mpls_enable, \
23154 "<intfc> | sw_if_index [disable | dis]") \
23155 _(sw_interface_set_vpath, \
23156 "<intfc> | sw_if_index <id> enable | disable") \
23157 _(sw_interface_set_vxlan_bypass, \
23158 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23159 _(sw_interface_set_geneve_bypass, \
23160 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23161 _(sw_interface_set_l2_xconnect, \
23162 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23163 "enable | disable") \
23164 _(sw_interface_set_l2_bridge, \
23165 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
23166 "[shg <split-horizon-group>] [bvi]\n" \
23167 "enable | disable") \
23168 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
23169 _(bridge_domain_add_del, \
23170 "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") \
23171 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
23173 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
23174 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
23175 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
23177 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23179 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23181 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
23183 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
23185 "<vpp-if-name> | sw_if_index <id>") \
23186 _(sw_interface_tap_dump, "") \
23188 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>]") \
23190 "<vpp-if-name> | sw_if_index <id>") \
23191 _(sw_interface_tap_v2_dump, "") \
23193 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
23194 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]}") \
23196 "<vpp-if-name> | sw_if_index <id>") \
23198 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
23199 _(bond_detach_slave, \
23200 "sw_if_index <n>") \
23201 _(sw_interface_bond_dump, "") \
23202 _(sw_interface_slave_dump, \
23203 "<vpp-if-name> | sw_if_index <id>") \
23204 _(ip_table_add_del, \
23205 "table-id <n> [ipv6]\n") \
23206 _(ip_add_del_route, \
23207 "<addr>/<mask> via <addr> [table-id <n>]\n" \
23208 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
23209 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
23210 "[multipath] [count <n>]") \
23211 _(ip_mroute_add_del, \
23212 "<src> <grp>/<mask> [table-id <n>]\n" \
23213 "[<intfc> | sw_if_index <id>] [local] [del]") \
23214 _(mpls_table_add_del, \
23215 "table-id <n>\n") \
23216 _(mpls_route_add_del, \
23217 "<label> <eos> via <addr> [table-id <n>]\n" \
23218 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
23219 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
23220 "[multipath] [count <n>]") \
23221 _(mpls_ip_bind_unbind, \
23222 "<label> <addr/len>") \
23223 _(mpls_tunnel_add_del, \
23224 " via <addr> [table-id <n>]\n" \
23225 "sw_if_index <id>] [l2] [del]") \
23226 _(bier_table_add_del, \
23227 "<label> <sub-domain> <set> <bsl> [del]") \
23228 _(bier_route_add_del, \
23229 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
23230 "[<intfc> | sw_if_index <id>]" \
23231 "[weight <n>] [del] [multipath]") \
23232 _(proxy_arp_add_del, \
23233 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
23234 _(proxy_arp_intfc_enable_disable, \
23235 "<intfc> | sw_if_index <id> enable | disable") \
23236 _(sw_interface_set_unnumbered, \
23237 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
23238 _(ip_neighbor_add_del, \
23239 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
23240 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
23241 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
23242 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
23243 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
23244 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
23245 "[outer_vlan_id_any][inner_vlan_id_any]") \
23246 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
23247 _(reset_fib, "vrf <n> [ipv6]") \
23248 _(dhcp_proxy_config, \
23249 "svr <v46-address> src <v46-address>\n" \
23250 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
23251 _(dhcp_proxy_set_vss, \
23252 "tbl_id <n> [fib_id <n> oui <n> | vpn_ascii_id <text>] [ipv6] [del]") \
23253 _(dhcp_proxy_dump, "ip6") \
23254 _(dhcp_client_config, \
23255 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
23256 _(set_ip_flow_hash, \
23257 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
23258 _(sw_interface_ip6_enable_disable, \
23259 "<intfc> | sw_if_index <id> enable | disable") \
23260 _(sw_interface_ip6_set_link_local_address, \
23261 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
23262 _(ip6nd_proxy_add_del, \
23263 "<intfc> | sw_if_index <id> <ip6-address>") \
23264 _(ip6nd_proxy_dump, "") \
23265 _(sw_interface_ip6nd_ra_prefix, \
23266 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
23267 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
23268 "[nolink] [isno]") \
23269 _(sw_interface_ip6nd_ra_config, \
23270 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
23271 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
23272 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
23273 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
23274 _(l2_patch_add_del, \
23275 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23276 "enable | disable") \
23277 _(sr_localsid_add_del, \
23278 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
23279 "fib-table <num> (end.psp) sw_if_index <num>") \
23280 _(classify_add_del_table, \
23281 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
23282 " [del] [del-chain] mask <mask-value>\n" \
23283 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
23284 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
23285 _(classify_add_del_session, \
23286 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
23287 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
23288 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
23289 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
23290 _(classify_set_interface_ip_table, \
23291 "<intfc> | sw_if_index <nn> table <nn>") \
23292 _(classify_set_interface_l2_tables, \
23293 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23294 " [other-table <nn>]") \
23295 _(get_node_index, "node <node-name") \
23296 _(add_node_next, "node <node-name> next <next-node-name>") \
23297 _(l2tpv3_create_tunnel, \
23298 "client_address <ip6-addr> our_address <ip6-addr>\n" \
23299 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
23300 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
23301 _(l2tpv3_set_tunnel_cookies, \
23302 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
23303 "[new_remote_cookie <nn>]\n") \
23304 _(l2tpv3_interface_enable_disable, \
23305 "<intfc> | sw_if_index <nn> enable | disable") \
23306 _(l2tpv3_set_lookup_key, \
23307 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
23308 _(sw_if_l2tpv3_tunnel_dump, "") \
23309 _(vxlan_offload_rx, \
23310 "hw { <interface name> | hw_if_index <nn>} " \
23311 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
23312 _(vxlan_add_del_tunnel, \
23313 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23314 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
23315 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23316 _(geneve_add_del_tunnel, \
23317 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23318 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23319 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23320 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23321 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23322 _(gre_add_del_tunnel, \
23323 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
23324 "[teb | erspan <session-id>] [del]") \
23325 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23326 _(l2_fib_clear_table, "") \
23327 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
23328 _(l2_interface_vlan_tag_rewrite, \
23329 "<intfc> | sw_if_index <nn> \n" \
23330 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
23331 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
23332 _(create_vhost_user_if, \
23333 "socket <filename> [server] [renumber <dev_instance>] " \
23334 "[mac <mac_address>]") \
23335 _(modify_vhost_user_if, \
23336 "<intfc> | sw_if_index <nn> socket <filename>\n" \
23337 "[server] [renumber <dev_instance>]") \
23338 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
23339 _(sw_interface_vhost_user_dump, "") \
23340 _(show_version, "") \
23341 _(vxlan_gpe_add_del_tunnel, \
23342 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
23343 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23344 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
23345 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
23346 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23347 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
23348 _(interface_name_renumber, \
23349 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
23350 _(input_acl_set_interface, \
23351 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23352 " [l2-table <nn>] [del]") \
23353 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
23354 _(ip_scan_neighbor_enable_disable, "[ip4|ip6|both|disable] [interval <n-min>]\n" \
23355 " [max-time <n-usec>] [max-update <n>] [delay <n-msec>] [stale <n-min>]") \
23356 _(want_ip4_arp_events, "address <ip4-address> [del]") \
23357 _(want_ip6_nd_events, "address <ip6-address> [del]") \
23358 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
23359 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
23360 _(ip_dump, "ipv4 | ipv6") \
23361 _(ipsec_spd_add_del, "spd_id <n> [del]") \
23362 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
23364 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
23365 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
23366 " integ_alg <alg> integ_key <hex>") \
23367 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
23368 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
23369 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
23370 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
23371 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
23372 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
23373 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
23374 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
23375 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
23376 " [instance <n>]") \
23377 _(ipsec_sa_dump, "[sa_id <n>]") \
23378 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
23379 " <alg> <hex>\n") \
23380 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
23381 _(ikev2_profile_add_del, "name <profile_name> [del]") \
23382 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
23383 "(auth_data 0x<data> | auth_data <data>)") \
23384 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
23385 "(id_data 0x<data> | id_data <data>) (local|remote)") \
23386 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
23387 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
23388 "(local|remote)") \
23389 _(ikev2_set_local_key, "file <absolute_file_path>") \
23390 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
23391 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23392 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23393 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
23394 _(ikev2_initiate_sa_init, "<profile_name>") \
23395 _(ikev2_initiate_del_ike_sa, "<ispi>") \
23396 _(ikev2_initiate_del_child_sa, "<ispi>") \
23397 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
23398 _(delete_loopback,"sw_if_index <nn>") \
23399 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
23400 _(want_interface_events, "enable|disable") \
23401 _(want_stats,"enable|disable") \
23402 _(get_first_msg_id, "client <name>") \
23403 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
23404 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
23405 "fib-id <nn> [ip4][ip6][default]") \
23406 _(get_node_graph, " ") \
23407 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
23408 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
23409 _(ioam_disable, "") \
23410 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
23411 " sw_if_index <sw_if_index> p <priority> " \
23412 "w <weight>] [del]") \
23413 _(one_add_del_locator, "locator-set <locator_name> " \
23414 "iface <intf> | sw_if_index <sw_if_index> " \
23415 "p <priority> w <weight> [del]") \
23416 _(one_add_del_local_eid,"vni <vni> eid " \
23417 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23418 "locator-set <locator_name> [del]" \
23419 "[key-id sha1|sha256 secret-key <secret-key>]")\
23420 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
23421 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
23422 _(one_enable_disable, "enable|disable") \
23423 _(one_map_register_enable_disable, "enable|disable") \
23424 _(one_map_register_fallback_threshold, "<value>") \
23425 _(one_rloc_probe_enable_disable, "enable|disable") \
23426 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23428 "rloc <locator> p <prio> " \
23429 "w <weight> [rloc <loc> ... ] " \
23430 "action <action> [del-all]") \
23431 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23433 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23434 _(one_use_petr, "ip-address> | disable") \
23435 _(one_map_request_mode, "src-dst|dst-only") \
23436 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23437 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23438 _(one_locator_set_dump, "[local | remote]") \
23439 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
23440 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23441 "[local] | [remote]") \
23442 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
23443 _(one_ndp_bd_get, "") \
23444 _(one_ndp_entries_get, "bd <bridge-domain>") \
23445 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
23446 _(one_l2_arp_bd_get, "") \
23447 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
23448 _(one_stats_enable_disable, "enable|disalbe") \
23449 _(show_one_stats_enable_disable, "") \
23450 _(one_eid_table_vni_dump, "") \
23451 _(one_eid_table_map_dump, "l2|l3") \
23452 _(one_map_resolver_dump, "") \
23453 _(one_map_server_dump, "") \
23454 _(one_adjacencies_get, "vni <vni>") \
23455 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
23456 _(show_one_rloc_probe_state, "") \
23457 _(show_one_map_register_state, "") \
23458 _(show_one_status, "") \
23459 _(one_stats_dump, "") \
23460 _(one_stats_flush, "") \
23461 _(one_get_map_request_itr_rlocs, "") \
23462 _(one_map_register_set_ttl, "<ttl>") \
23463 _(one_set_transport_protocol, "udp|api") \
23464 _(one_get_transport_protocol, "") \
23465 _(one_enable_disable_xtr_mode, "enable|disable") \
23466 _(one_show_xtr_mode, "") \
23467 _(one_enable_disable_pitr_mode, "enable|disable") \
23468 _(one_show_pitr_mode, "") \
23469 _(one_enable_disable_petr_mode, "enable|disable") \
23470 _(one_show_petr_mode, "") \
23471 _(show_one_nsh_mapping, "") \
23472 _(show_one_pitr, "") \
23473 _(show_one_use_petr, "") \
23474 _(show_one_map_request_mode, "") \
23475 _(show_one_map_register_ttl, "") \
23476 _(show_one_map_register_fallback_threshold, "") \
23477 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
23478 " sw_if_index <sw_if_index> p <priority> " \
23479 "w <weight>] [del]") \
23480 _(lisp_add_del_locator, "locator-set <locator_name> " \
23481 "iface <intf> | sw_if_index <sw_if_index> " \
23482 "p <priority> w <weight> [del]") \
23483 _(lisp_add_del_local_eid,"vni <vni> eid " \
23484 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23485 "locator-set <locator_name> [del]" \
23486 "[key-id sha1|sha256 secret-key <secret-key>]") \
23487 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
23488 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
23489 _(lisp_enable_disable, "enable|disable") \
23490 _(lisp_map_register_enable_disable, "enable|disable") \
23491 _(lisp_rloc_probe_enable_disable, "enable|disable") \
23492 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23494 "rloc <locator> p <prio> " \
23495 "w <weight> [rloc <loc> ... ] " \
23496 "action <action> [del-all]") \
23497 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23499 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23500 _(lisp_use_petr, "<ip-address> | disable") \
23501 _(lisp_map_request_mode, "src-dst|dst-only") \
23502 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23503 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23504 _(lisp_locator_set_dump, "[local | remote]") \
23505 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
23506 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23507 "[local] | [remote]") \
23508 _(lisp_eid_table_vni_dump, "") \
23509 _(lisp_eid_table_map_dump, "l2|l3") \
23510 _(lisp_map_resolver_dump, "") \
23511 _(lisp_map_server_dump, "") \
23512 _(lisp_adjacencies_get, "vni <vni>") \
23513 _(gpe_fwd_entry_vnis_get, "") \
23514 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
23515 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
23516 "[table <table-id>]") \
23517 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
23518 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
23519 _(gpe_set_encap_mode, "lisp|vxlan") \
23520 _(gpe_get_encap_mode, "") \
23521 _(lisp_gpe_add_del_iface, "up|down") \
23522 _(lisp_gpe_enable_disable, "enable|disable") \
23523 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
23524 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
23525 _(show_lisp_rloc_probe_state, "") \
23526 _(show_lisp_map_register_state, "") \
23527 _(show_lisp_status, "") \
23528 _(lisp_get_map_request_itr_rlocs, "") \
23529 _(show_lisp_pitr, "") \
23530 _(show_lisp_use_petr, "") \
23531 _(show_lisp_map_request_mode, "") \
23532 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
23533 _(af_packet_delete, "name <host interface name>") \
23534 _(af_packet_dump, "") \
23535 _(policer_add_del, "name <policer name> <params> [del]") \
23536 _(policer_dump, "[name <policer name>]") \
23537 _(policer_classify_set_interface, \
23538 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23539 " [l2-table <nn>] [del]") \
23540 _(policer_classify_dump, "type [ip4|ip6|l2]") \
23541 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
23542 "[master|slave]") \
23543 _(netmap_delete, "name <interface name>") \
23544 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
23545 _(mpls_fib_dump, "") \
23546 _(classify_table_ids, "") \
23547 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
23548 _(classify_table_info, "table_id <nn>") \
23549 _(classify_session_dump, "table_id <nn>") \
23550 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
23551 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
23552 "[template_interval <nn>] [udp_checksum]") \
23553 _(ipfix_exporter_dump, "") \
23554 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
23555 _(ipfix_classify_stream_dump, "") \
23556 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
23557 _(ipfix_classify_table_dump, "") \
23558 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
23559 _(sw_interface_span_dump, "[l2]") \
23560 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
23561 _(pg_create_interface, "if_id <nn>") \
23562 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
23563 _(pg_enable_disable, "[stream <id>] disable") \
23564 _(ip_source_and_port_range_check_add_del, \
23565 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
23566 _(ip_source_and_port_range_check_interface_add_del, \
23567 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
23568 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
23569 _(ipsec_gre_add_del_tunnel, \
23570 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
23571 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
23572 _(delete_subif,"<intfc> | sw_if_index <nn>") \
23573 _(l2_interface_pbb_tag_rewrite, \
23574 "<intfc> | sw_if_index <nn> \n" \
23575 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
23576 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
23577 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
23578 _(flow_classify_set_interface, \
23579 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
23580 _(flow_classify_dump, "type [ip4|ip6]") \
23581 _(ip_fib_dump, "") \
23582 _(ip_mfib_dump, "") \
23583 _(ip6_fib_dump, "") \
23584 _(ip6_mfib_dump, "") \
23585 _(feature_enable_disable, "arc_name <arc_name> " \
23586 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
23587 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
23589 _(l2_xconnect_dump, "") \
23590 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
23591 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
23592 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
23593 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
23594 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
23595 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
23596 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
23597 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
23598 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
23599 _(sock_init_shm, "size <nnn>") \
23600 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
23601 _(dns_enable_disable, "[enable][disable]") \
23602 _(dns_name_server_add_del, "<ip-address> [del]") \
23603 _(dns_resolve_name, "<hostname>") \
23604 _(dns_resolve_ip, "<ip4|ip6>") \
23605 _(dns_name_server_add_del, "<ip-address> [del]") \
23606 _(dns_resolve_name, "<hostname>") \
23607 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
23608 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
23609 _(session_rules_dump, "") \
23610 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
23611 _(output_acl_set_interface, \
23612 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23613 " [l2-table <nn>] [del]") \
23614 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
23616 /* List of command functions, CLI names map directly to functions */
23617 #define foreach_cli_function \
23618 _(comment, "usage: comment <ignore-rest-of-line>") \
23619 _(dump_interface_table, "usage: dump_interface_table") \
23620 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
23621 _(dump_ipv4_table, "usage: dump_ipv4_table") \
23622 _(dump_ipv6_table, "usage: dump_ipv6_table") \
23623 _(dump_stats_table, "usage: dump_stats_table") \
23624 _(dump_macro_table, "usage: dump_macro_table ") \
23625 _(dump_node_table, "usage: dump_node_table") \
23626 _(dump_msg_api_table, "usage: dump_msg_api_table") \
23627 _(get_msg_id, "usage: get_msg_id name_and_crc") \
23628 _(echo, "usage: echo <message>") \
23629 _(exec, "usage: exec <vpe-debug-CLI-command>") \
23630 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
23631 _(help, "usage: help") \
23632 _(q, "usage: quit") \
23633 _(quit, "usage: quit") \
23634 _(search_node_table, "usage: search_node_table <name>...") \
23635 _(set, "usage: set <variable-name> <value>") \
23636 _(script, "usage: script <file-name>") \
23637 _(statseg, "usage: statseg"); \
23638 _(unset, "usage: unset <variable-name>")
23641 static void vl_api_##n##_t_handler_uni \
23642 (vl_api_##n##_t * mp) \
23644 vat_main_t * vam = &vat_main; \
23645 if (vam->json_output) { \
23646 vl_api_##n##_t_handler_json(mp); \
23648 vl_api_##n##_t_handler(mp); \
23651 foreach_vpe_api_reply_msg;
23652 #if VPP_API_TEST_BUILTIN == 0
23653 foreach_standalone_reply_msg;
23658 vat_api_hookup (vat_main_t * vam)
23661 vl_msg_api_set_handlers(VL_API_##N, #n, \
23662 vl_api_##n##_t_handler_uni, \
23664 vl_api_##n##_t_endian, \
23665 vl_api_##n##_t_print, \
23666 sizeof(vl_api_##n##_t), 1);
23667 foreach_vpe_api_reply_msg;
23668 #if VPP_API_TEST_BUILTIN == 0
23669 foreach_standalone_reply_msg;
23673 #if (VPP_API_TEST_BUILTIN==0)
23674 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
23676 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
23678 vam->function_by_name = hash_create_string (0, sizeof (uword));
23680 vam->help_by_name = hash_create_string (0, sizeof (uword));
23683 /* API messages we can send */
23684 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
23685 foreach_vpe_api_msg;
23689 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
23690 foreach_vpe_api_msg;
23693 /* CLI functions */
23694 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
23695 foreach_cli_function;
23699 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
23700 foreach_cli_function;
23704 #if VPP_API_TEST_BUILTIN
23705 static clib_error_t *
23706 vat_api_hookup_shim (vlib_main_t * vm)
23708 vat_api_hookup (&vat_main);
23712 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
23716 * fd.io coding-style-patch-verification: ON
23719 * eval: (c-set-style "gnu")