2 *------------------------------------------------------------------
5 * Copyright (c) 2014-2016 Cisco and/or its affiliates.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *------------------------------------------------------------------
21 #include <vppinfra/socket.h>
22 #include <vlibapi/api.h>
23 #include <vlibmemory/api.h>
24 #include <vnet/ip/ip.h>
25 #include <vnet/ip/ip_neighbor.h>
26 #include <vnet/l2/l2_input.h>
27 #include <vnet/l2tp/l2tp.h>
28 #include <vnet/vxlan/vxlan.h>
29 #include <vnet/geneve/geneve.h>
30 #include <vnet/gre/gre.h>
31 #include <vnet/vxlan-gpe/vxlan_gpe.h>
32 #include <vnet/lisp-gpe/lisp_gpe.h>
34 #include <vpp/api/vpe_msg_enum.h>
35 #include <vnet/l2/l2_classify.h>
36 #include <vnet/l2/l2_vtr.h>
37 #include <vnet/classify/in_out_acl.h>
38 #include <vnet/classify/policer_classify.h>
39 #include <vnet/classify/flow_classify.h>
40 #include <vnet/mpls/mpls.h>
41 #include <vnet/ipsec/ipsec.h>
42 #include <vnet/ipsec/ikev2.h>
44 #include <vnet/cop/cop.h>
45 #include <vnet/ip/ip6_hop_by_hop.h>
46 #include <vnet/ip/ip_source_and_port_range_check.h>
47 #include <vnet/policer/xlate.h>
48 #include <vnet/span/span.h>
49 #include <vnet/policer/policer.h>
50 #include <vnet/policer/police.h>
51 #include <vnet/mfib/mfib_types.h>
52 #include <vnet/dhcp/dhcp_proxy.h>
53 #include <vnet/bonding/node.h>
54 #include <vnet/qos/qos_types.h>
55 #include "vat/json_format.h"
60 #define vl_typedefs /* define message structures */
61 #include <vpp/api/vpe_all_api_h.h>
64 /* declare message handlers for each api */
66 #define vl_endianfun /* define message structures */
67 #include <vpp/api/vpe_all_api_h.h>
70 /* instantiate all the print functions we know about */
71 #define vl_print(handle, ...)
73 #include <vpp/api/vpe_all_api_h.h>
76 #define __plugin_msg_base 0
77 #include <vlibapi/vat_helper_macros.h>
79 #if VPP_API_TEST_BUILTIN == 0
89 vat_socket_connect (vat_main_t * vam)
91 vam->socket_client_main = &socket_client_main;
92 return vl_socket_client_connect ((char *) vam->socket_name, "vpp_api_test",
93 0 /* default socket rx, tx buffer */ );
95 #else /* vpp built-in case, we don't do sockets... */
97 vat_socket_connect (vat_main_t * vam)
103 vl_socket_client_read (int wait)
109 vl_socket_client_write ()
115 vl_socket_client_msg_alloc (int nbytes)
123 vat_time_now (vat_main_t * vam)
125 #if VPP_API_TEST_BUILTIN
126 return vlib_time_now (vam->vlib_main);
128 return clib_time_now (&vam->clib_time);
133 errmsg (char *fmt, ...)
135 vat_main_t *vam = &vat_main;
140 s = va_format (0, fmt, &va);
145 #if VPP_API_TEST_BUILTIN
146 vlib_cli_output (vam->vlib_main, (char *) s);
149 if (vam->ifp != stdin)
150 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
151 vam->input_line_number);
152 fformat (vam->ofp, (char *) s);
160 #if VPP_API_TEST_BUILTIN == 0
162 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
164 vat_main_t *vam = va_arg (*args, vat_main_t *);
165 u32 *result = va_arg (*args, u32 *);
169 if (!unformat (input, "%s", &if_name))
172 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
180 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
185 /* Parse an IP4 address %d.%d.%d.%d. */
187 unformat_ip4_address (unformat_input_t * input, va_list * args)
189 u8 *result = va_arg (*args, u8 *);
192 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
195 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
207 unformat_ethernet_address (unformat_input_t * input, va_list * args)
209 u8 *result = va_arg (*args, u8 *);
212 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
213 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
217 for (i = 0; i < 6; i++)
218 if (a[i] >= (1 << 8))
221 for (i = 0; i < 6; i++)
227 /* Returns ethernet type as an int in host byte order. */
229 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
232 u16 *result = va_arg (*args, u16 *);
236 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
238 if (type >= (1 << 16))
246 /* Parse an IP6 address. */
248 unformat_ip6_address (unformat_input_t * input, va_list * args)
250 ip6_address_t *result = va_arg (*args, ip6_address_t *);
252 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
253 uword c, n_colon, double_colon_index;
255 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
256 double_colon_index = ARRAY_LEN (hex_quads);
257 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
260 if (c >= '0' && c <= '9')
262 else if (c >= 'a' && c <= 'f')
263 hex_digit = c + 10 - 'a';
264 else if (c >= 'A' && c <= 'F')
265 hex_digit = c + 10 - 'A';
266 else if (c == ':' && n_colon < 2)
270 unformat_put_input (input);
274 /* Too many hex quads. */
275 if (n_hex_quads >= ARRAY_LEN (hex_quads))
280 hex_quad = (hex_quad << 4) | hex_digit;
282 /* Hex quad must fit in 16 bits. */
283 if (n_hex_digits >= 4)
290 /* Save position of :: */
293 /* More than one :: ? */
294 if (double_colon_index < ARRAY_LEN (hex_quads))
296 double_colon_index = n_hex_quads;
299 if (n_colon > 0 && n_hex_digits > 0)
301 hex_quads[n_hex_quads++] = hex_quad;
307 if (n_hex_digits > 0)
308 hex_quads[n_hex_quads++] = hex_quad;
313 /* Expand :: to appropriate number of zero hex quads. */
314 if (double_colon_index < ARRAY_LEN (hex_quads))
316 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
318 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
319 hex_quads[n_zero + i] = hex_quads[i];
321 for (i = 0; i < n_zero; i++)
322 hex_quads[double_colon_index + i] = 0;
324 n_hex_quads = ARRAY_LEN (hex_quads);
327 /* Too few hex quads given. */
328 if (n_hex_quads < ARRAY_LEN (hex_quads))
331 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
332 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
339 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
341 u32 *r = va_arg (*args, u32 *);
344 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
345 foreach_ipsec_policy_action
353 unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args)
355 u32 *r = va_arg (*args, u32 *);
358 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
359 foreach_ipsec_crypto_alg
367 format_ipsec_crypto_alg (u8 * s, va_list * args)
369 u32 i = va_arg (*args, u32);
374 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
375 foreach_ipsec_crypto_alg
378 return format (s, "unknown");
380 return format (s, "%s", t);
384 unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args)
386 u32 *r = va_arg (*args, u32 *);
389 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f;
390 foreach_ipsec_integ_alg
398 format_ipsec_integ_alg (u8 * s, va_list * args)
400 u32 i = va_arg (*args, u32);
405 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
406 foreach_ipsec_integ_alg
409 return format (s, "unknown");
411 return format (s, "%s", t);
415 unformat_ikev2_auth_method (unformat_input_t * input, va_list * args)
417 u32 *r = va_arg (*args, u32 *);
420 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f;
421 foreach_ikev2_auth_method
429 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
431 u32 *r = va_arg (*args, u32 *);
434 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
435 foreach_ikev2_id_type
441 #else /* VPP_API_TEST_BUILTIN == 1 */
443 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
445 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
446 vnet_main_t *vnm = vnet_get_main ();
447 u32 *result = va_arg (*args, u32 *);
449 return unformat (input, "%U", unformat_vnet_sw_interface, vnm, result);
453 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
455 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
456 vnet_main_t *vnm = vnet_get_main ();
457 u32 *result = va_arg (*args, u32 *);
459 return unformat (input, "%U", unformat_vnet_hw_interface, vnm, result);
462 #endif /* VPP_API_TEST_BUILTIN */
465 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
467 u8 *r = va_arg (*args, u8 *);
469 if (unformat (input, "kbps"))
470 *r = SSE2_QOS_RATE_KBPS;
471 else if (unformat (input, "pps"))
472 *r = SSE2_QOS_RATE_PPS;
479 unformat_policer_round_type (unformat_input_t * input, va_list * args)
481 u8 *r = va_arg (*args, u8 *);
483 if (unformat (input, "closest"))
484 *r = SSE2_QOS_ROUND_TO_CLOSEST;
485 else if (unformat (input, "up"))
486 *r = SSE2_QOS_ROUND_TO_UP;
487 else if (unformat (input, "down"))
488 *r = SSE2_QOS_ROUND_TO_DOWN;
495 unformat_policer_type (unformat_input_t * input, va_list * args)
497 u8 *r = va_arg (*args, u8 *);
499 if (unformat (input, "1r2c"))
500 *r = SSE2_QOS_POLICER_TYPE_1R2C;
501 else if (unformat (input, "1r3c"))
502 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
503 else if (unformat (input, "2r3c-2698"))
504 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
505 else if (unformat (input, "2r3c-4115"))
506 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
507 else if (unformat (input, "2r3c-mef5cf1"))
508 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
515 unformat_dscp (unformat_input_t * input, va_list * va)
517 u8 *r = va_arg (*va, u8 *);
520 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
529 unformat_policer_action_type (unformat_input_t * input, va_list * va)
531 sse2_qos_pol_action_params_st *a
532 = va_arg (*va, sse2_qos_pol_action_params_st *);
534 if (unformat (input, "drop"))
535 a->action_type = SSE2_QOS_ACTION_DROP;
536 else if (unformat (input, "transmit"))
537 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
538 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
539 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
546 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
548 u32 *r = va_arg (*va, u32 *);
551 if (unformat (input, "ip4"))
552 tid = POLICER_CLASSIFY_TABLE_IP4;
553 else if (unformat (input, "ip6"))
554 tid = POLICER_CLASSIFY_TABLE_IP6;
555 else if (unformat (input, "l2"))
556 tid = POLICER_CLASSIFY_TABLE_L2;
565 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
567 u32 *r = va_arg (*va, u32 *);
570 if (unformat (input, "ip4"))
571 tid = FLOW_CLASSIFY_TABLE_IP4;
572 else if (unformat (input, "ip6"))
573 tid = FLOW_CLASSIFY_TABLE_IP6;
581 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
582 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
583 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
584 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
586 #if (VPP_API_TEST_BUILTIN==0)
588 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
590 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
591 mfib_itf_attribute_t attr;
594 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
596 if (unformat (input, mfib_itf_flag_long_names[attr]))
597 *iflags |= (1 << attr);
599 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
601 if (unformat (input, mfib_itf_flag_names[attr]))
602 *iflags |= (1 << attr);
605 return (old == *iflags ? 0 : 1);
609 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
611 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
612 mfib_entry_attribute_t attr;
615 FOR_EACH_MFIB_ATTRIBUTE (attr)
617 if (unformat (input, mfib_flag_long_names[attr]))
618 *eflags |= (1 << attr);
620 FOR_EACH_MFIB_ATTRIBUTE (attr)
622 if (unformat (input, mfib_flag_names[attr]))
623 *eflags |= (1 << attr);
626 return (old == *eflags ? 0 : 1);
630 format_ip4_address (u8 * s, va_list * args)
632 u8 *a = va_arg (*args, u8 *);
633 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
637 format_ip6_address (u8 * s, va_list * args)
639 ip6_address_t *a = va_arg (*args, ip6_address_t *);
640 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
642 i_max_n_zero = ARRAY_LEN (a->as_u16);
644 i_first_zero = i_max_n_zero;
646 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
648 u32 is_zero = a->as_u16[i] == 0;
649 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
655 if ((!is_zero && n_zeros > max_n_zeros)
656 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
658 i_max_n_zero = i_first_zero;
659 max_n_zeros = n_zeros;
660 i_first_zero = ARRAY_LEN (a->as_u16);
665 last_double_colon = 0;
666 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
668 if (i == i_max_n_zero && max_n_zeros > 1)
670 s = format (s, "::");
671 i += max_n_zeros - 1;
672 last_double_colon = 1;
676 s = format (s, "%s%x",
677 (last_double_colon || i == 0) ? "" : ":",
678 clib_net_to_host_u16 (a->as_u16[i]));
679 last_double_colon = 0;
686 /* Format an IP46 address. */
688 format_ip46_address (u8 * s, va_list * args)
690 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
691 ip46_type_t type = va_arg (*args, ip46_type_t);
697 is_ip4 = ip46_address_is_ip4 (ip46);
708 format (s, "%U", format_ip4_address, &ip46->ip4) :
709 format (s, "%U", format_ip6_address, &ip46->ip6);
713 format_ethernet_address (u8 * s, va_list * args)
715 u8 *a = va_arg (*args, u8 *);
717 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
718 a[0], a[1], a[2], a[3], a[4], a[5]);
723 increment_v4_address (ip4_address_t * a)
727 v = ntohl (a->as_u32) + 1;
728 a->as_u32 = ntohl (v);
732 increment_v6_address (ip6_address_t * a)
736 v0 = clib_net_to_host_u64 (a->as_u64[0]);
737 v1 = clib_net_to_host_u64 (a->as_u64[1]);
742 a->as_u64[0] = clib_net_to_host_u64 (v0);
743 a->as_u64[1] = clib_net_to_host_u64 (v1);
747 increment_mac_address (u8 * mac)
749 u64 tmp = *((u64 *) mac);
750 tmp = clib_net_to_host_u64 (tmp);
751 tmp += 1 << 16; /* skip unused (least significant) octets */
752 tmp = clib_host_to_net_u64 (tmp);
754 clib_memcpy (mac, &tmp, 6);
757 static void vl_api_create_loopback_reply_t_handler
758 (vl_api_create_loopback_reply_t * mp)
760 vat_main_t *vam = &vat_main;
761 i32 retval = ntohl (mp->retval);
763 vam->retval = retval;
764 vam->regenerate_interface_table = 1;
765 vam->sw_if_index = ntohl (mp->sw_if_index);
766 vam->result_ready = 1;
769 static void vl_api_create_loopback_reply_t_handler_json
770 (vl_api_create_loopback_reply_t * mp)
772 vat_main_t *vam = &vat_main;
773 vat_json_node_t node;
775 vat_json_init_object (&node);
776 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
777 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
779 vat_json_print (vam->ofp, &node);
780 vat_json_free (&node);
781 vam->retval = ntohl (mp->retval);
782 vam->result_ready = 1;
785 static void vl_api_create_loopback_instance_reply_t_handler
786 (vl_api_create_loopback_instance_reply_t * mp)
788 vat_main_t *vam = &vat_main;
789 i32 retval = ntohl (mp->retval);
791 vam->retval = retval;
792 vam->regenerate_interface_table = 1;
793 vam->sw_if_index = ntohl (mp->sw_if_index);
794 vam->result_ready = 1;
797 static void vl_api_create_loopback_instance_reply_t_handler_json
798 (vl_api_create_loopback_instance_reply_t * mp)
800 vat_main_t *vam = &vat_main;
801 vat_json_node_t node;
803 vat_json_init_object (&node);
804 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
805 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
807 vat_json_print (vam->ofp, &node);
808 vat_json_free (&node);
809 vam->retval = ntohl (mp->retval);
810 vam->result_ready = 1;
813 static void vl_api_af_packet_create_reply_t_handler
814 (vl_api_af_packet_create_reply_t * mp)
816 vat_main_t *vam = &vat_main;
817 i32 retval = ntohl (mp->retval);
819 vam->retval = retval;
820 vam->regenerate_interface_table = 1;
821 vam->sw_if_index = ntohl (mp->sw_if_index);
822 vam->result_ready = 1;
825 static void vl_api_af_packet_create_reply_t_handler_json
826 (vl_api_af_packet_create_reply_t * mp)
828 vat_main_t *vam = &vat_main;
829 vat_json_node_t node;
831 vat_json_init_object (&node);
832 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
833 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
835 vat_json_print (vam->ofp, &node);
836 vat_json_free (&node);
838 vam->retval = ntohl (mp->retval);
839 vam->result_ready = 1;
842 static void vl_api_create_vlan_subif_reply_t_handler
843 (vl_api_create_vlan_subif_reply_t * mp)
845 vat_main_t *vam = &vat_main;
846 i32 retval = ntohl (mp->retval);
848 vam->retval = retval;
849 vam->regenerate_interface_table = 1;
850 vam->sw_if_index = ntohl (mp->sw_if_index);
851 vam->result_ready = 1;
854 static void vl_api_create_vlan_subif_reply_t_handler_json
855 (vl_api_create_vlan_subif_reply_t * mp)
857 vat_main_t *vam = &vat_main;
858 vat_json_node_t node;
860 vat_json_init_object (&node);
861 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
862 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
864 vat_json_print (vam->ofp, &node);
865 vat_json_free (&node);
867 vam->retval = ntohl (mp->retval);
868 vam->result_ready = 1;
871 static void vl_api_create_subif_reply_t_handler
872 (vl_api_create_subif_reply_t * mp)
874 vat_main_t *vam = &vat_main;
875 i32 retval = ntohl (mp->retval);
877 vam->retval = retval;
878 vam->regenerate_interface_table = 1;
879 vam->sw_if_index = ntohl (mp->sw_if_index);
880 vam->result_ready = 1;
883 static void vl_api_create_subif_reply_t_handler_json
884 (vl_api_create_subif_reply_t * mp)
886 vat_main_t *vam = &vat_main;
887 vat_json_node_t node;
889 vat_json_init_object (&node);
890 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
891 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
893 vat_json_print (vam->ofp, &node);
894 vat_json_free (&node);
896 vam->retval = ntohl (mp->retval);
897 vam->result_ready = 1;
900 static void vl_api_interface_name_renumber_reply_t_handler
901 (vl_api_interface_name_renumber_reply_t * mp)
903 vat_main_t *vam = &vat_main;
904 i32 retval = ntohl (mp->retval);
906 vam->retval = retval;
907 vam->regenerate_interface_table = 1;
908 vam->result_ready = 1;
911 static void vl_api_interface_name_renumber_reply_t_handler_json
912 (vl_api_interface_name_renumber_reply_t * mp)
914 vat_main_t *vam = &vat_main;
915 vat_json_node_t node;
917 vat_json_init_object (&node);
918 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
920 vat_json_print (vam->ofp, &node);
921 vat_json_free (&node);
923 vam->retval = ntohl (mp->retval);
924 vam->result_ready = 1;
928 * Special-case: build the interface table, maintain
929 * the next loopback sw_if_index vbl.
931 static void vl_api_sw_interface_details_t_handler
932 (vl_api_sw_interface_details_t * mp)
934 vat_main_t *vam = &vat_main;
935 u8 *s = format (0, "%s%c", mp->interface_name, 0);
937 hash_set_mem (vam->sw_if_index_by_interface_name, s,
938 ntohl (mp->sw_if_index));
940 /* In sub interface case, fill the sub interface table entry */
941 if (mp->sw_if_index != mp->sup_sw_if_index)
943 sw_interface_subif_t *sub = NULL;
945 vec_add2 (vam->sw_if_subif_table, sub, 1);
947 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
948 strncpy ((char *) sub->interface_name, (char *) s,
949 vec_len (sub->interface_name));
950 sub->sw_if_index = ntohl (mp->sw_if_index);
951 sub->sub_id = ntohl (mp->sub_id);
953 sub->sub_dot1ad = mp->sub_dot1ad;
954 sub->sub_number_of_tags = mp->sub_number_of_tags;
955 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
956 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
957 sub->sub_exact_match = mp->sub_exact_match;
958 sub->sub_default = mp->sub_default;
959 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
960 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
962 /* vlan tag rewrite */
963 sub->vtr_op = ntohl (mp->vtr_op);
964 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
965 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
966 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
970 static void vl_api_sw_interface_details_t_handler_json
971 (vl_api_sw_interface_details_t * mp)
973 vat_main_t *vam = &vat_main;
974 vat_json_node_t *node = NULL;
976 if (VAT_JSON_ARRAY != vam->json_tree.type)
978 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
979 vat_json_init_array (&vam->json_tree);
981 node = vat_json_array_add (&vam->json_tree);
983 vat_json_init_object (node);
984 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
985 vat_json_object_add_uint (node, "sup_sw_if_index",
986 ntohl (mp->sup_sw_if_index));
987 vat_json_object_add_uint (node, "l2_address_length",
988 ntohl (mp->l2_address_length));
989 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
990 sizeof (mp->l2_address));
991 vat_json_object_add_string_copy (node, "interface_name",
993 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
994 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
995 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
996 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
997 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
998 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
999 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
1000 vat_json_object_add_uint (node, "sub_number_of_tags",
1001 mp->sub_number_of_tags);
1002 vat_json_object_add_uint (node, "sub_outer_vlan_id",
1003 ntohs (mp->sub_outer_vlan_id));
1004 vat_json_object_add_uint (node, "sub_inner_vlan_id",
1005 ntohs (mp->sub_inner_vlan_id));
1006 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
1007 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
1008 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
1009 mp->sub_outer_vlan_id_any);
1010 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
1011 mp->sub_inner_vlan_id_any);
1012 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
1013 vat_json_object_add_uint (node, "vtr_push_dot1q",
1014 ntohl (mp->vtr_push_dot1q));
1015 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
1016 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
1019 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
1021 format_ethernet_address,
1023 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
1025 format_ethernet_address,
1027 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
1028 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
1032 #if VPP_API_TEST_BUILTIN == 0
1033 static void vl_api_sw_interface_event_t_handler
1034 (vl_api_sw_interface_event_t * mp)
1036 vat_main_t *vam = &vat_main;
1037 if (vam->interface_event_display)
1038 errmsg ("interface flags: sw_if_index %d %s %s",
1039 ntohl (mp->sw_if_index),
1040 mp->admin_up_down ? "admin-up" : "admin-down",
1041 mp->link_up_down ? "link-up" : "link-down");
1045 static void vl_api_sw_interface_event_t_handler_json
1046 (vl_api_sw_interface_event_t * mp)
1048 /* JSON output not supported */
1052 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
1054 vat_main_t *vam = &vat_main;
1055 i32 retval = ntohl (mp->retval);
1057 vam->retval = retval;
1058 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1059 vam->result_ready = 1;
1063 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1065 vat_main_t *vam = &vat_main;
1066 vat_json_node_t node;
1067 api_main_t *am = &api_main;
1071 vat_json_init_object (&node);
1072 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1073 vat_json_object_add_uint (&node, "reply_in_shmem",
1074 ntohl (mp->reply_in_shmem));
1075 /* Toss the shared-memory original... */
1076 pthread_mutex_lock (&am->vlib_rp->mutex);
1077 oldheap = svm_push_data_heap (am->vlib_rp);
1079 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1082 svm_pop_heap (oldheap);
1083 pthread_mutex_unlock (&am->vlib_rp->mutex);
1085 vat_json_print (vam->ofp, &node);
1086 vat_json_free (&node);
1088 vam->retval = ntohl (mp->retval);
1089 vam->result_ready = 1;
1093 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1095 vat_main_t *vam = &vat_main;
1096 i32 retval = ntohl (mp->retval);
1097 u32 length = ntohl (mp->length);
1099 vec_reset_length (vam->cmd_reply);
1101 vam->retval = retval;
1104 vec_validate (vam->cmd_reply, length);
1105 clib_memcpy ((char *) (vam->cmd_reply), mp->reply, length);
1106 vam->cmd_reply[length] = 0;
1108 vam->result_ready = 1;
1112 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1114 vat_main_t *vam = &vat_main;
1115 vat_json_node_t node;
1117 vec_reset_length (vam->cmd_reply);
1119 vat_json_init_object (&node);
1120 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1121 vat_json_object_add_string_copy (&node, "reply", mp->reply);
1123 vat_json_print (vam->ofp, &node);
1124 vat_json_free (&node);
1126 vam->retval = ntohl (mp->retval);
1127 vam->result_ready = 1;
1130 static void vl_api_classify_add_del_table_reply_t_handler
1131 (vl_api_classify_add_del_table_reply_t * mp)
1133 vat_main_t *vam = &vat_main;
1134 i32 retval = ntohl (mp->retval);
1135 if (vam->async_mode)
1137 vam->async_errors += (retval < 0);
1141 vam->retval = retval;
1143 ((mp->new_table_index != 0xFFFFFFFF) ||
1144 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1145 (mp->match_n_vectors != 0xFFFFFFFF)))
1147 * Note: this is just barely thread-safe, depends on
1148 * the main thread spinning waiting for an answer...
1150 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1151 ntohl (mp->new_table_index),
1152 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1153 vam->result_ready = 1;
1157 static void vl_api_classify_add_del_table_reply_t_handler_json
1158 (vl_api_classify_add_del_table_reply_t * mp)
1160 vat_main_t *vam = &vat_main;
1161 vat_json_node_t node;
1163 vat_json_init_object (&node);
1164 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1165 vat_json_object_add_uint (&node, "new_table_index",
1166 ntohl (mp->new_table_index));
1167 vat_json_object_add_uint (&node, "skip_n_vectors",
1168 ntohl (mp->skip_n_vectors));
1169 vat_json_object_add_uint (&node, "match_n_vectors",
1170 ntohl (mp->match_n_vectors));
1172 vat_json_print (vam->ofp, &node);
1173 vat_json_free (&node);
1175 vam->retval = ntohl (mp->retval);
1176 vam->result_ready = 1;
1179 static void vl_api_get_node_index_reply_t_handler
1180 (vl_api_get_node_index_reply_t * mp)
1182 vat_main_t *vam = &vat_main;
1183 i32 retval = ntohl (mp->retval);
1184 if (vam->async_mode)
1186 vam->async_errors += (retval < 0);
1190 vam->retval = retval;
1192 errmsg ("node index %d", ntohl (mp->node_index));
1193 vam->result_ready = 1;
1197 static void vl_api_get_node_index_reply_t_handler_json
1198 (vl_api_get_node_index_reply_t * mp)
1200 vat_main_t *vam = &vat_main;
1201 vat_json_node_t node;
1203 vat_json_init_object (&node);
1204 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1205 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1207 vat_json_print (vam->ofp, &node);
1208 vat_json_free (&node);
1210 vam->retval = ntohl (mp->retval);
1211 vam->result_ready = 1;
1214 static void vl_api_get_next_index_reply_t_handler
1215 (vl_api_get_next_index_reply_t * mp)
1217 vat_main_t *vam = &vat_main;
1218 i32 retval = ntohl (mp->retval);
1219 if (vam->async_mode)
1221 vam->async_errors += (retval < 0);
1225 vam->retval = retval;
1227 errmsg ("next node index %d", ntohl (mp->next_index));
1228 vam->result_ready = 1;
1232 static void vl_api_get_next_index_reply_t_handler_json
1233 (vl_api_get_next_index_reply_t * mp)
1235 vat_main_t *vam = &vat_main;
1236 vat_json_node_t node;
1238 vat_json_init_object (&node);
1239 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1240 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1242 vat_json_print (vam->ofp, &node);
1243 vat_json_free (&node);
1245 vam->retval = ntohl (mp->retval);
1246 vam->result_ready = 1;
1249 static void vl_api_add_node_next_reply_t_handler
1250 (vl_api_add_node_next_reply_t * mp)
1252 vat_main_t *vam = &vat_main;
1253 i32 retval = ntohl (mp->retval);
1254 if (vam->async_mode)
1256 vam->async_errors += (retval < 0);
1260 vam->retval = retval;
1262 errmsg ("next index %d", ntohl (mp->next_index));
1263 vam->result_ready = 1;
1267 static void vl_api_add_node_next_reply_t_handler_json
1268 (vl_api_add_node_next_reply_t * mp)
1270 vat_main_t *vam = &vat_main;
1271 vat_json_node_t node;
1273 vat_json_init_object (&node);
1274 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1275 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1277 vat_json_print (vam->ofp, &node);
1278 vat_json_free (&node);
1280 vam->retval = ntohl (mp->retval);
1281 vam->result_ready = 1;
1284 static void vl_api_show_version_reply_t_handler
1285 (vl_api_show_version_reply_t * mp)
1287 vat_main_t *vam = &vat_main;
1288 i32 retval = ntohl (mp->retval);
1292 errmsg (" program: %s", mp->program);
1293 errmsg (" version: %s", mp->version);
1294 errmsg (" build date: %s", mp->build_date);
1295 errmsg ("build directory: %s", mp->build_directory);
1297 vam->retval = retval;
1298 vam->result_ready = 1;
1301 static void vl_api_show_version_reply_t_handler_json
1302 (vl_api_show_version_reply_t * mp)
1304 vat_main_t *vam = &vat_main;
1305 vat_json_node_t node;
1307 vat_json_init_object (&node);
1308 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1309 vat_json_object_add_string_copy (&node, "program", mp->program);
1310 vat_json_object_add_string_copy (&node, "version", mp->version);
1311 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1312 vat_json_object_add_string_copy (&node, "build_directory",
1313 mp->build_directory);
1315 vat_json_print (vam->ofp, &node);
1316 vat_json_free (&node);
1318 vam->retval = ntohl (mp->retval);
1319 vam->result_ready = 1;
1323 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1325 u32 sw_if_index = ntohl (mp->sw_if_index);
1326 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1327 mp->mac_ip ? "mac/ip binding" : "address resolution",
1328 ntohl (mp->pid), format_ip4_address, &mp->address,
1329 format_ethernet_address, mp->new_mac, sw_if_index);
1333 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1335 /* JSON output not supported */
1339 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1341 u32 sw_if_index = ntohl (mp->sw_if_index);
1342 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1343 mp->mac_ip ? "mac/ip binding" : "address resolution",
1344 ntohl (mp->pid), format_ip6_address, mp->address,
1345 format_ethernet_address, mp->new_mac, sw_if_index);
1349 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1351 /* JSON output not supported */
1355 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1357 u32 n_macs = ntohl (mp->n_macs);
1358 errmsg ("L2MAC event recived with pid %d cl-idx %d for %d macs: \n",
1359 ntohl (mp->pid), mp->client_index, n_macs);
1361 for (i = 0; i < n_macs; i++)
1363 vl_api_mac_entry_t *mac = &mp->mac[i];
1364 errmsg (" [%d] sw_if_index %d mac_addr %U action %d \n",
1365 i + 1, ntohl (mac->sw_if_index),
1366 format_ethernet_address, mac->mac_addr, mac->action);
1373 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1375 /* JSON output not supported */
1378 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1379 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1382 * Special-case: build the bridge domain table, maintain
1383 * the next bd id vbl.
1385 static void vl_api_bridge_domain_details_t_handler
1386 (vl_api_bridge_domain_details_t * mp)
1388 vat_main_t *vam = &vat_main;
1389 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1392 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1393 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1395 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1396 ntohl (mp->bd_id), mp->learn, mp->forward,
1397 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1401 vl_api_bridge_domain_sw_if_t *sw_ifs;
1402 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1405 sw_ifs = mp->sw_if_details;
1406 for (i = 0; i < n_sw_ifs; i++)
1412 sw_if_index = ntohl (sw_ifs->sw_if_index);
1415 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1417 if ((u32) p->value[0] == sw_if_index)
1419 sw_if_name = (u8 *)(p->key);
1424 print (vam->ofp, "%7d %3d %s", sw_if_index,
1425 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1426 "sw_if_index not found!");
1433 static void vl_api_bridge_domain_details_t_handler_json
1434 (vl_api_bridge_domain_details_t * mp)
1436 vat_main_t *vam = &vat_main;
1437 vat_json_node_t *node, *array = NULL;
1438 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1440 if (VAT_JSON_ARRAY != vam->json_tree.type)
1442 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1443 vat_json_init_array (&vam->json_tree);
1445 node = vat_json_array_add (&vam->json_tree);
1447 vat_json_init_object (node);
1448 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1449 vat_json_object_add_uint (node, "flood", mp->flood);
1450 vat_json_object_add_uint (node, "forward", mp->forward);
1451 vat_json_object_add_uint (node, "learn", mp->learn);
1452 vat_json_object_add_uint (node, "bvi_sw_if_index",
1453 ntohl (mp->bvi_sw_if_index));
1454 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1455 array = vat_json_object_add (node, "sw_if");
1456 vat_json_init_array (array);
1462 vl_api_bridge_domain_sw_if_t *sw_ifs;
1465 sw_ifs = mp->sw_if_details;
1466 for (i = 0; i < n_sw_ifs; i++)
1468 node = vat_json_array_add (array);
1469 vat_json_init_object (node);
1470 vat_json_object_add_uint (node, "sw_if_index",
1471 ntohl (sw_ifs->sw_if_index));
1472 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1478 static void vl_api_control_ping_reply_t_handler
1479 (vl_api_control_ping_reply_t * mp)
1481 vat_main_t *vam = &vat_main;
1482 i32 retval = ntohl (mp->retval);
1483 if (vam->async_mode)
1485 vam->async_errors += (retval < 0);
1489 vam->retval = retval;
1490 vam->result_ready = 1;
1492 if (vam->socket_client_main)
1493 vam->socket_client_main->control_pings_outstanding--;
1496 static void vl_api_control_ping_reply_t_handler_json
1497 (vl_api_control_ping_reply_t * mp)
1499 vat_main_t *vam = &vat_main;
1500 i32 retval = ntohl (mp->retval);
1502 if (VAT_JSON_NONE != vam->json_tree.type)
1504 vat_json_print (vam->ofp, &vam->json_tree);
1505 vat_json_free (&vam->json_tree);
1506 vam->json_tree.type = VAT_JSON_NONE;
1511 vat_json_init_array (&vam->json_tree);
1512 vat_json_print (vam->ofp, &vam->json_tree);
1513 vam->json_tree.type = VAT_JSON_NONE;
1516 vam->retval = retval;
1517 vam->result_ready = 1;
1521 vl_api_bridge_domain_set_mac_age_reply_t_handler
1522 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1524 vat_main_t *vam = &vat_main;
1525 i32 retval = ntohl (mp->retval);
1526 if (vam->async_mode)
1528 vam->async_errors += (retval < 0);
1532 vam->retval = retval;
1533 vam->result_ready = 1;
1537 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1538 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1540 vat_main_t *vam = &vat_main;
1541 vat_json_node_t node;
1543 vat_json_init_object (&node);
1544 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1546 vat_json_print (vam->ofp, &node);
1547 vat_json_free (&node);
1549 vam->retval = ntohl (mp->retval);
1550 vam->result_ready = 1;
1554 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1556 vat_main_t *vam = &vat_main;
1557 i32 retval = ntohl (mp->retval);
1558 if (vam->async_mode)
1560 vam->async_errors += (retval < 0);
1564 vam->retval = retval;
1565 vam->result_ready = 1;
1569 static void vl_api_l2_flags_reply_t_handler_json
1570 (vl_api_l2_flags_reply_t * mp)
1572 vat_main_t *vam = &vat_main;
1573 vat_json_node_t node;
1575 vat_json_init_object (&node);
1576 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1577 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1578 ntohl (mp->resulting_feature_bitmap));
1580 vat_json_print (vam->ofp, &node);
1581 vat_json_free (&node);
1583 vam->retval = ntohl (mp->retval);
1584 vam->result_ready = 1;
1587 static void vl_api_bridge_flags_reply_t_handler
1588 (vl_api_bridge_flags_reply_t * mp)
1590 vat_main_t *vam = &vat_main;
1591 i32 retval = ntohl (mp->retval);
1592 if (vam->async_mode)
1594 vam->async_errors += (retval < 0);
1598 vam->retval = retval;
1599 vam->result_ready = 1;
1603 static void vl_api_bridge_flags_reply_t_handler_json
1604 (vl_api_bridge_flags_reply_t * mp)
1606 vat_main_t *vam = &vat_main;
1607 vat_json_node_t node;
1609 vat_json_init_object (&node);
1610 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1611 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1612 ntohl (mp->resulting_feature_bitmap));
1614 vat_json_print (vam->ofp, &node);
1615 vat_json_free (&node);
1617 vam->retval = ntohl (mp->retval);
1618 vam->result_ready = 1;
1621 static void vl_api_tap_connect_reply_t_handler
1622 (vl_api_tap_connect_reply_t * mp)
1624 vat_main_t *vam = &vat_main;
1625 i32 retval = ntohl (mp->retval);
1626 if (vam->async_mode)
1628 vam->async_errors += (retval < 0);
1632 vam->retval = retval;
1633 vam->sw_if_index = ntohl (mp->sw_if_index);
1634 vam->result_ready = 1;
1639 static void vl_api_tap_connect_reply_t_handler_json
1640 (vl_api_tap_connect_reply_t * mp)
1642 vat_main_t *vam = &vat_main;
1643 vat_json_node_t node;
1645 vat_json_init_object (&node);
1646 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1647 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1649 vat_json_print (vam->ofp, &node);
1650 vat_json_free (&node);
1652 vam->retval = ntohl (mp->retval);
1653 vam->result_ready = 1;
1658 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1660 vat_main_t *vam = &vat_main;
1661 i32 retval = ntohl (mp->retval);
1662 if (vam->async_mode)
1664 vam->async_errors += (retval < 0);
1668 vam->retval = retval;
1669 vam->sw_if_index = ntohl (mp->sw_if_index);
1670 vam->result_ready = 1;
1674 static void vl_api_tap_modify_reply_t_handler_json
1675 (vl_api_tap_modify_reply_t * mp)
1677 vat_main_t *vam = &vat_main;
1678 vat_json_node_t node;
1680 vat_json_init_object (&node);
1681 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1682 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1684 vat_json_print (vam->ofp, &node);
1685 vat_json_free (&node);
1687 vam->retval = ntohl (mp->retval);
1688 vam->result_ready = 1;
1692 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1694 vat_main_t *vam = &vat_main;
1695 i32 retval = ntohl (mp->retval);
1696 if (vam->async_mode)
1698 vam->async_errors += (retval < 0);
1702 vam->retval = retval;
1703 vam->result_ready = 1;
1707 static void vl_api_tap_delete_reply_t_handler_json
1708 (vl_api_tap_delete_reply_t * mp)
1710 vat_main_t *vam = &vat_main;
1711 vat_json_node_t node;
1713 vat_json_init_object (&node);
1714 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1716 vat_json_print (vam->ofp, &node);
1717 vat_json_free (&node);
1719 vam->retval = ntohl (mp->retval);
1720 vam->result_ready = 1;
1724 vl_api_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_reply_t * mp)
1726 vat_main_t *vam = &vat_main;
1727 i32 retval = ntohl (mp->retval);
1728 if (vam->async_mode)
1730 vam->async_errors += (retval < 0);
1734 vam->retval = retval;
1735 vam->sw_if_index = ntohl (mp->sw_if_index);
1736 vam->result_ready = 1;
1741 static void vl_api_tap_create_v2_reply_t_handler_json
1742 (vl_api_tap_create_v2_reply_t * mp)
1744 vat_main_t *vam = &vat_main;
1745 vat_json_node_t node;
1747 vat_json_init_object (&node);
1748 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1749 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1751 vat_json_print (vam->ofp, &node);
1752 vat_json_free (&node);
1754 vam->retval = ntohl (mp->retval);
1755 vam->result_ready = 1;
1760 vl_api_tap_delete_v2_reply_t_handler (vl_api_tap_delete_v2_reply_t * mp)
1762 vat_main_t *vam = &vat_main;
1763 i32 retval = ntohl (mp->retval);
1764 if (vam->async_mode)
1766 vam->async_errors += (retval < 0);
1770 vam->retval = retval;
1771 vam->result_ready = 1;
1775 static void vl_api_tap_delete_v2_reply_t_handler_json
1776 (vl_api_tap_delete_v2_reply_t * mp)
1778 vat_main_t *vam = &vat_main;
1779 vat_json_node_t node;
1781 vat_json_init_object (&node);
1782 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1784 vat_json_print (vam->ofp, &node);
1785 vat_json_free (&node);
1787 vam->retval = ntohl (mp->retval);
1788 vam->result_ready = 1;
1792 vl_api_bond_create_reply_t_handler (vl_api_bond_create_reply_t * mp)
1794 vat_main_t *vam = &vat_main;
1795 i32 retval = ntohl (mp->retval);
1797 if (vam->async_mode)
1799 vam->async_errors += (retval < 0);
1803 vam->retval = retval;
1804 vam->sw_if_index = ntohl (mp->sw_if_index);
1805 vam->result_ready = 1;
1809 static void vl_api_bond_create_reply_t_handler_json
1810 (vl_api_bond_create_reply_t * mp)
1812 vat_main_t *vam = &vat_main;
1813 vat_json_node_t node;
1815 vat_json_init_object (&node);
1816 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1817 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1819 vat_json_print (vam->ofp, &node);
1820 vat_json_free (&node);
1822 vam->retval = ntohl (mp->retval);
1823 vam->result_ready = 1;
1827 vl_api_bond_delete_reply_t_handler (vl_api_bond_delete_reply_t * mp)
1829 vat_main_t *vam = &vat_main;
1830 i32 retval = ntohl (mp->retval);
1832 if (vam->async_mode)
1834 vam->async_errors += (retval < 0);
1838 vam->retval = retval;
1839 vam->result_ready = 1;
1843 static void vl_api_bond_delete_reply_t_handler_json
1844 (vl_api_bond_delete_reply_t * mp)
1846 vat_main_t *vam = &vat_main;
1847 vat_json_node_t node;
1849 vat_json_init_object (&node);
1850 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1852 vat_json_print (vam->ofp, &node);
1853 vat_json_free (&node);
1855 vam->retval = ntohl (mp->retval);
1856 vam->result_ready = 1;
1860 vl_api_bond_enslave_reply_t_handler (vl_api_bond_enslave_reply_t * mp)
1862 vat_main_t *vam = &vat_main;
1863 i32 retval = ntohl (mp->retval);
1865 if (vam->async_mode)
1867 vam->async_errors += (retval < 0);
1871 vam->retval = retval;
1872 vam->result_ready = 1;
1876 static void vl_api_bond_enslave_reply_t_handler_json
1877 (vl_api_bond_enslave_reply_t * mp)
1879 vat_main_t *vam = &vat_main;
1880 vat_json_node_t node;
1882 vat_json_init_object (&node);
1883 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1885 vat_json_print (vam->ofp, &node);
1886 vat_json_free (&node);
1888 vam->retval = ntohl (mp->retval);
1889 vam->result_ready = 1;
1893 vl_api_bond_detach_slave_reply_t_handler (vl_api_bond_detach_slave_reply_t *
1896 vat_main_t *vam = &vat_main;
1897 i32 retval = ntohl (mp->retval);
1899 if (vam->async_mode)
1901 vam->async_errors += (retval < 0);
1905 vam->retval = retval;
1906 vam->result_ready = 1;
1910 static void vl_api_bond_detach_slave_reply_t_handler_json
1911 (vl_api_bond_detach_slave_reply_t * mp)
1913 vat_main_t *vam = &vat_main;
1914 vat_json_node_t node;
1916 vat_json_init_object (&node);
1917 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1919 vat_json_print (vam->ofp, &node);
1920 vat_json_free (&node);
1922 vam->retval = ntohl (mp->retval);
1923 vam->result_ready = 1;
1926 static void vl_api_sw_interface_bond_details_t_handler
1927 (vl_api_sw_interface_bond_details_t * mp)
1929 vat_main_t *vam = &vat_main;
1932 "%-16s %-12d %-12U %-13U %-14u %-14u",
1933 mp->interface_name, ntohl (mp->sw_if_index),
1934 format_bond_mode, mp->mode, format_bond_load_balance, mp->lb,
1935 ntohl (mp->active_slaves), ntohl (mp->slaves));
1938 static void vl_api_sw_interface_bond_details_t_handler_json
1939 (vl_api_sw_interface_bond_details_t * mp)
1941 vat_main_t *vam = &vat_main;
1942 vat_json_node_t *node = NULL;
1944 if (VAT_JSON_ARRAY != vam->json_tree.type)
1946 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1947 vat_json_init_array (&vam->json_tree);
1949 node = vat_json_array_add (&vam->json_tree);
1951 vat_json_init_object (node);
1952 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1953 vat_json_object_add_string_copy (node, "interface_name",
1954 mp->interface_name);
1955 vat_json_object_add_uint (node, "mode", mp->mode);
1956 vat_json_object_add_uint (node, "load_balance", mp->lb);
1957 vat_json_object_add_uint (node, "active_slaves", ntohl (mp->active_slaves));
1958 vat_json_object_add_uint (node, "slaves", ntohl (mp->slaves));
1962 api_sw_interface_bond_dump (vat_main_t * vam)
1964 vl_api_sw_interface_bond_dump_t *mp;
1965 vl_api_control_ping_t *mp_ping;
1969 "\n%-16s %-12s %-12s %-13s %-14s %-14s",
1970 "interface name", "sw_if_index", "mode", "load balance",
1971 "active slaves", "slaves");
1973 /* Get list of bond interfaces */
1974 M (SW_INTERFACE_BOND_DUMP, mp);
1977 /* Use a control ping for synchronization */
1978 MPING (CONTROL_PING, mp_ping);
1985 static void vl_api_sw_interface_slave_details_t_handler
1986 (vl_api_sw_interface_slave_details_t * mp)
1988 vat_main_t *vam = &vat_main;
1991 "%-25s %-12d %-12d %d", mp->interface_name,
1992 ntohl (mp->sw_if_index), mp->is_passive, mp->is_long_timeout);
1995 static void vl_api_sw_interface_slave_details_t_handler_json
1996 (vl_api_sw_interface_slave_details_t * mp)
1998 vat_main_t *vam = &vat_main;
1999 vat_json_node_t *node = NULL;
2001 if (VAT_JSON_ARRAY != vam->json_tree.type)
2003 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2004 vat_json_init_array (&vam->json_tree);
2006 node = vat_json_array_add (&vam->json_tree);
2008 vat_json_init_object (node);
2009 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2010 vat_json_object_add_string_copy (node, "interface_name",
2011 mp->interface_name);
2012 vat_json_object_add_uint (node, "passive", mp->is_passive);
2013 vat_json_object_add_uint (node, "long_timeout", mp->is_long_timeout);
2017 api_sw_interface_slave_dump (vat_main_t * vam)
2019 unformat_input_t *i = vam->input;
2020 vl_api_sw_interface_slave_dump_t *mp;
2021 vl_api_control_ping_t *mp_ping;
2022 u32 sw_if_index = ~0;
2023 u8 sw_if_index_set = 0;
2026 /* Parse args required to build the message */
2027 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2029 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2030 sw_if_index_set = 1;
2031 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2032 sw_if_index_set = 1;
2037 if (sw_if_index_set == 0)
2039 errmsg ("missing vpp interface name. ");
2044 "\n%-25s %-12s %-12s %s",
2045 "slave interface name", "sw_if_index", "passive", "long_timeout");
2047 /* Get list of bond interfaces */
2048 M (SW_INTERFACE_SLAVE_DUMP, mp);
2049 mp->sw_if_index = ntohl (sw_if_index);
2052 /* Use a control ping for synchronization */
2053 MPING (CONTROL_PING, mp_ping);
2060 static void vl_api_mpls_tunnel_add_del_reply_t_handler
2061 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2063 vat_main_t *vam = &vat_main;
2064 i32 retval = ntohl (mp->retval);
2065 if (vam->async_mode)
2067 vam->async_errors += (retval < 0);
2071 vam->retval = retval;
2072 vam->result_ready = 1;
2076 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
2077 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2079 vat_main_t *vam = &vat_main;
2080 vat_json_node_t node;
2082 vat_json_init_object (&node);
2083 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2084 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
2085 ntohl (mp->sw_if_index));
2087 vat_json_print (vam->ofp, &node);
2088 vat_json_free (&node);
2090 vam->retval = ntohl (mp->retval);
2091 vam->result_ready = 1;
2094 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
2095 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2097 vat_main_t *vam = &vat_main;
2098 i32 retval = ntohl (mp->retval);
2099 if (vam->async_mode)
2101 vam->async_errors += (retval < 0);
2105 vam->retval = retval;
2106 vam->sw_if_index = ntohl (mp->sw_if_index);
2107 vam->result_ready = 1;
2111 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
2112 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2114 vat_main_t *vam = &vat_main;
2115 vat_json_node_t node;
2117 vat_json_init_object (&node);
2118 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2119 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2121 vat_json_print (vam->ofp, &node);
2122 vat_json_free (&node);
2124 vam->retval = ntohl (mp->retval);
2125 vam->result_ready = 1;
2128 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
2129 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2131 vat_main_t *vam = &vat_main;
2132 i32 retval = ntohl (mp->retval);
2133 if (vam->async_mode)
2135 vam->async_errors += (retval < 0);
2139 vam->retval = retval;
2140 vam->result_ready = 1;
2144 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
2145 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2147 vat_main_t *vam = &vat_main;
2148 vat_json_node_t node;
2150 vat_json_init_object (&node);
2151 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2152 vat_json_object_add_uint (&node, "fwd_entry_index",
2153 clib_net_to_host_u32 (mp->fwd_entry_index));
2155 vat_json_print (vam->ofp, &node);
2156 vat_json_free (&node);
2158 vam->retval = ntohl (mp->retval);
2159 vam->result_ready = 1;
2163 format_lisp_transport_protocol (u8 * s, va_list * args)
2165 u32 proto = va_arg (*args, u32);
2170 return format (s, "udp");
2172 return format (s, "api");
2179 static void vl_api_one_get_transport_protocol_reply_t_handler
2180 (vl_api_one_get_transport_protocol_reply_t * mp)
2182 vat_main_t *vam = &vat_main;
2183 i32 retval = ntohl (mp->retval);
2184 if (vam->async_mode)
2186 vam->async_errors += (retval < 0);
2190 u32 proto = mp->protocol;
2191 print (vam->ofp, "Transport protocol: %U",
2192 format_lisp_transport_protocol, proto);
2193 vam->retval = retval;
2194 vam->result_ready = 1;
2198 static void vl_api_one_get_transport_protocol_reply_t_handler_json
2199 (vl_api_one_get_transport_protocol_reply_t * mp)
2201 vat_main_t *vam = &vat_main;
2202 vat_json_node_t node;
2205 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
2208 vat_json_init_object (&node);
2209 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2210 vat_json_object_add_string_copy (&node, "transport-protocol", s);
2213 vat_json_print (vam->ofp, &node);
2214 vat_json_free (&node);
2216 vam->retval = ntohl (mp->retval);
2217 vam->result_ready = 1;
2220 static void vl_api_one_add_del_locator_set_reply_t_handler
2221 (vl_api_one_add_del_locator_set_reply_t * mp)
2223 vat_main_t *vam = &vat_main;
2224 i32 retval = ntohl (mp->retval);
2225 if (vam->async_mode)
2227 vam->async_errors += (retval < 0);
2231 vam->retval = retval;
2232 vam->result_ready = 1;
2236 static void vl_api_one_add_del_locator_set_reply_t_handler_json
2237 (vl_api_one_add_del_locator_set_reply_t * mp)
2239 vat_main_t *vam = &vat_main;
2240 vat_json_node_t node;
2242 vat_json_init_object (&node);
2243 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2244 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
2246 vat_json_print (vam->ofp, &node);
2247 vat_json_free (&node);
2249 vam->retval = ntohl (mp->retval);
2250 vam->result_ready = 1;
2253 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
2254 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2256 vat_main_t *vam = &vat_main;
2257 i32 retval = ntohl (mp->retval);
2258 if (vam->async_mode)
2260 vam->async_errors += (retval < 0);
2264 vam->retval = retval;
2265 vam->sw_if_index = ntohl (mp->sw_if_index);
2266 vam->result_ready = 1;
2268 vam->regenerate_interface_table = 1;
2271 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
2272 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2274 vat_main_t *vam = &vat_main;
2275 vat_json_node_t node;
2277 vat_json_init_object (&node);
2278 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2279 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2281 vat_json_print (vam->ofp, &node);
2282 vat_json_free (&node);
2284 vam->retval = ntohl (mp->retval);
2285 vam->result_ready = 1;
2288 static void vl_api_vxlan_offload_rx_reply_t_handler
2289 (vl_api_vxlan_offload_rx_reply_t * mp)
2291 vat_main_t *vam = &vat_main;
2292 i32 retval = ntohl (mp->retval);
2293 if (vam->async_mode)
2295 vam->async_errors += (retval < 0);
2299 vam->retval = retval;
2300 vam->result_ready = 1;
2304 static void vl_api_vxlan_offload_rx_reply_t_handler_json
2305 (vl_api_vxlan_offload_rx_reply_t * mp)
2307 vat_main_t *vam = &vat_main;
2308 vat_json_node_t node;
2310 vat_json_init_object (&node);
2311 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2313 vat_json_print (vam->ofp, &node);
2314 vat_json_free (&node);
2316 vam->retval = ntohl (mp->retval);
2317 vam->result_ready = 1;
2320 static void vl_api_geneve_add_del_tunnel_reply_t_handler
2321 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2323 vat_main_t *vam = &vat_main;
2324 i32 retval = ntohl (mp->retval);
2325 if (vam->async_mode)
2327 vam->async_errors += (retval < 0);
2331 vam->retval = retval;
2332 vam->sw_if_index = ntohl (mp->sw_if_index);
2333 vam->result_ready = 1;
2337 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
2338 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2340 vat_main_t *vam = &vat_main;
2341 vat_json_node_t node;
2343 vat_json_init_object (&node);
2344 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2345 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2347 vat_json_print (vam->ofp, &node);
2348 vat_json_free (&node);
2350 vam->retval = ntohl (mp->retval);
2351 vam->result_ready = 1;
2354 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
2355 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2357 vat_main_t *vam = &vat_main;
2358 i32 retval = ntohl (mp->retval);
2359 if (vam->async_mode)
2361 vam->async_errors += (retval < 0);
2365 vam->retval = retval;
2366 vam->sw_if_index = ntohl (mp->sw_if_index);
2367 vam->result_ready = 1;
2369 vam->regenerate_interface_table = 1;
2372 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
2373 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2375 vat_main_t *vam = &vat_main;
2376 vat_json_node_t node;
2378 vat_json_init_object (&node);
2379 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2380 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2382 vat_json_print (vam->ofp, &node);
2383 vat_json_free (&node);
2385 vam->retval = ntohl (mp->retval);
2386 vam->result_ready = 1;
2389 static void vl_api_gre_add_del_tunnel_reply_t_handler
2390 (vl_api_gre_add_del_tunnel_reply_t * mp)
2392 vat_main_t *vam = &vat_main;
2393 i32 retval = ntohl (mp->retval);
2394 if (vam->async_mode)
2396 vam->async_errors += (retval < 0);
2400 vam->retval = retval;
2401 vam->sw_if_index = ntohl (mp->sw_if_index);
2402 vam->result_ready = 1;
2406 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
2407 (vl_api_gre_add_del_tunnel_reply_t * mp)
2409 vat_main_t *vam = &vat_main;
2410 vat_json_node_t node;
2412 vat_json_init_object (&node);
2413 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2414 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2416 vat_json_print (vam->ofp, &node);
2417 vat_json_free (&node);
2419 vam->retval = ntohl (mp->retval);
2420 vam->result_ready = 1;
2423 static void vl_api_create_vhost_user_if_reply_t_handler
2424 (vl_api_create_vhost_user_if_reply_t * mp)
2426 vat_main_t *vam = &vat_main;
2427 i32 retval = ntohl (mp->retval);
2428 if (vam->async_mode)
2430 vam->async_errors += (retval < 0);
2434 vam->retval = retval;
2435 vam->sw_if_index = ntohl (mp->sw_if_index);
2436 vam->result_ready = 1;
2438 vam->regenerate_interface_table = 1;
2441 static void vl_api_create_vhost_user_if_reply_t_handler_json
2442 (vl_api_create_vhost_user_if_reply_t * mp)
2444 vat_main_t *vam = &vat_main;
2445 vat_json_node_t node;
2447 vat_json_init_object (&node);
2448 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2449 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2451 vat_json_print (vam->ofp, &node);
2452 vat_json_free (&node);
2454 vam->retval = ntohl (mp->retval);
2455 vam->result_ready = 1;
2458 static void vl_api_dns_resolve_name_reply_t_handler
2459 (vl_api_dns_resolve_name_reply_t * mp)
2461 vat_main_t *vam = &vat_main;
2462 i32 retval = ntohl (mp->retval);
2463 if (vam->async_mode)
2465 vam->async_errors += (retval < 0);
2469 vam->retval = retval;
2470 vam->result_ready = 1;
2475 clib_warning ("ip4 address %U", format_ip4_address,
2476 (ip4_address_t *) mp->ip4_address);
2478 clib_warning ("ip6 address %U", format_ip6_address,
2479 (ip6_address_t *) mp->ip6_address);
2482 clib_warning ("retval %d", retval);
2486 static void vl_api_dns_resolve_name_reply_t_handler_json
2487 (vl_api_dns_resolve_name_reply_t * mp)
2489 clib_warning ("not implemented");
2492 static void vl_api_dns_resolve_ip_reply_t_handler
2493 (vl_api_dns_resolve_ip_reply_t * mp)
2495 vat_main_t *vam = &vat_main;
2496 i32 retval = ntohl (mp->retval);
2497 if (vam->async_mode)
2499 vam->async_errors += (retval < 0);
2503 vam->retval = retval;
2504 vam->result_ready = 1;
2508 clib_warning ("canonical name %s", mp->name);
2511 clib_warning ("retval %d", retval);
2515 static void vl_api_dns_resolve_ip_reply_t_handler_json
2516 (vl_api_dns_resolve_ip_reply_t * mp)
2518 clib_warning ("not implemented");
2522 static void vl_api_ip_address_details_t_handler
2523 (vl_api_ip_address_details_t * mp)
2525 vat_main_t *vam = &vat_main;
2526 static ip_address_details_t empty_ip_address_details = { {0} };
2527 ip_address_details_t *address = NULL;
2528 ip_details_t *current_ip_details = NULL;
2529 ip_details_t *details = NULL;
2531 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2533 if (!details || vam->current_sw_if_index >= vec_len (details)
2534 || !details[vam->current_sw_if_index].present)
2536 errmsg ("ip address details arrived but not stored");
2537 errmsg ("ip_dump should be called first");
2541 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2543 #define addresses (current_ip_details->addr)
2545 vec_validate_init_empty (addresses, vec_len (addresses),
2546 empty_ip_address_details);
2548 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2550 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
2551 address->prefix_length = mp->prefix_length;
2555 static void vl_api_ip_address_details_t_handler_json
2556 (vl_api_ip_address_details_t * mp)
2558 vat_main_t *vam = &vat_main;
2559 vat_json_node_t *node = NULL;
2560 struct in6_addr ip6;
2563 if (VAT_JSON_ARRAY != vam->json_tree.type)
2565 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2566 vat_json_init_array (&vam->json_tree);
2568 node = vat_json_array_add (&vam->json_tree);
2570 vat_json_init_object (node);
2573 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
2574 vat_json_object_add_ip6 (node, "ip", ip6);
2578 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
2579 vat_json_object_add_ip4 (node, "ip", ip4);
2581 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
2585 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2587 vat_main_t *vam = &vat_main;
2588 static ip_details_t empty_ip_details = { 0 };
2589 ip_details_t *ip = NULL;
2590 u32 sw_if_index = ~0;
2592 sw_if_index = ntohl (mp->sw_if_index);
2594 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2595 sw_if_index, empty_ip_details);
2597 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2604 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2606 vat_main_t *vam = &vat_main;
2608 if (VAT_JSON_ARRAY != vam->json_tree.type)
2610 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2611 vat_json_init_array (&vam->json_tree);
2613 vat_json_array_add_uint (&vam->json_tree,
2614 clib_net_to_host_u32 (mp->sw_if_index));
2618 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2620 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2621 "router_addr %U host_mac %U",
2622 ntohl (mp->pid), mp->lease.is_ipv6 ? "ipv6" : "ipv4",
2624 format_ip4_address, &mp->lease.host_address,
2625 format_ip4_address, &mp->lease.router_address,
2626 format_ethernet_address, mp->lease.host_mac);
2629 static void vl_api_dhcp_compl_event_t_handler_json
2630 (vl_api_dhcp_compl_event_t * mp)
2632 /* JSON output not supported */
2636 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2639 vat_main_t *vam = &vat_main;
2640 static u64 default_counter = 0;
2642 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2644 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2645 sw_if_index, default_counter);
2646 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2650 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2651 interface_counter_t counter)
2653 vat_main_t *vam = &vat_main;
2654 static interface_counter_t default_counter = { 0, };
2656 vec_validate_init_empty (vam->combined_interface_counters,
2657 vnet_counter_type, NULL);
2658 vec_validate_init_empty (vam->combined_interface_counters
2659 [vnet_counter_type], sw_if_index, default_counter);
2660 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2663 static void vl_api_vnet_interface_simple_counters_t_handler
2664 (vl_api_vnet_interface_simple_counters_t * mp)
2669 static void vl_api_vnet_interface_combined_counters_t_handler
2670 (vl_api_vnet_interface_combined_counters_t * mp)
2675 static void vl_api_vnet_interface_simple_counters_t_handler_json
2676 (vl_api_vnet_interface_simple_counters_t * mp)
2681 u32 first_sw_if_index;
2684 count = ntohl (mp->count);
2685 first_sw_if_index = ntohl (mp->first_sw_if_index);
2687 v_packets = (u64 *) & mp->data;
2688 for (i = 0; i < count; i++)
2690 packets = clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2691 set_simple_interface_counter (mp->vnet_counter_type,
2692 first_sw_if_index + i, packets);
2697 static void vl_api_vnet_interface_combined_counters_t_handler_json
2698 (vl_api_vnet_interface_combined_counters_t * mp)
2700 interface_counter_t counter;
2702 u32 first_sw_if_index;
2706 count = ntohl (mp->count);
2707 first_sw_if_index = ntohl (mp->first_sw_if_index);
2709 v = (vlib_counter_t *) & mp->data;
2710 for (i = 0; i < count; i++)
2713 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2715 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2716 set_combined_interface_counter (mp->vnet_counter_type,
2717 first_sw_if_index + i, counter);
2723 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2725 vat_main_t *vam = &vat_main;
2728 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2730 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2739 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2741 vat_main_t *vam = &vat_main;
2744 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2746 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2754 static void vl_api_vnet_ip4_fib_counters_t_handler
2755 (vl_api_vnet_ip4_fib_counters_t * mp)
2760 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2761 (vl_api_vnet_ip4_fib_counters_t * mp)
2763 vat_main_t *vam = &vat_main;
2764 vl_api_ip4_fib_counter_t *v;
2765 ip4_fib_counter_t *counter;
2772 vrf_id = ntohl (mp->vrf_id);
2773 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2774 if (~0 == vrf_index)
2776 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2777 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2778 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2779 vec_validate (vam->ip4_fib_counters, vrf_index);
2780 vam->ip4_fib_counters[vrf_index] = NULL;
2783 vec_free (vam->ip4_fib_counters[vrf_index]);
2784 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2785 count = ntohl (mp->count);
2786 for (i = 0; i < count; i++)
2788 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2789 counter = &vam->ip4_fib_counters[vrf_index][i];
2790 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2791 counter->address = ip4;
2792 counter->address_length = v->address_length;
2793 counter->packets = clib_net_to_host_u64 (v->packets);
2794 counter->bytes = clib_net_to_host_u64 (v->bytes);
2799 static void vl_api_vnet_ip4_nbr_counters_t_handler
2800 (vl_api_vnet_ip4_nbr_counters_t * mp)
2805 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2806 (vl_api_vnet_ip4_nbr_counters_t * mp)
2808 vat_main_t *vam = &vat_main;
2809 vl_api_ip4_nbr_counter_t *v;
2810 ip4_nbr_counter_t *counter;
2815 sw_if_index = ntohl (mp->sw_if_index);
2816 count = ntohl (mp->count);
2817 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2820 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2822 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2823 for (i = 0; i < count; i++)
2825 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2826 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2827 counter->address.s_addr = v->address;
2828 counter->packets = clib_net_to_host_u64 (v->packets);
2829 counter->bytes = clib_net_to_host_u64 (v->bytes);
2830 counter->linkt = v->link_type;
2835 static void vl_api_vnet_ip6_fib_counters_t_handler
2836 (vl_api_vnet_ip6_fib_counters_t * mp)
2841 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2842 (vl_api_vnet_ip6_fib_counters_t * mp)
2844 vat_main_t *vam = &vat_main;
2845 vl_api_ip6_fib_counter_t *v;
2846 ip6_fib_counter_t *counter;
2847 struct in6_addr ip6;
2853 vrf_id = ntohl (mp->vrf_id);
2854 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2855 if (~0 == vrf_index)
2857 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2858 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2859 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2860 vec_validate (vam->ip6_fib_counters, vrf_index);
2861 vam->ip6_fib_counters[vrf_index] = NULL;
2864 vec_free (vam->ip6_fib_counters[vrf_index]);
2865 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2866 count = ntohl (mp->count);
2867 for (i = 0; i < count; i++)
2869 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2870 counter = &vam->ip6_fib_counters[vrf_index][i];
2871 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2872 counter->address = ip6;
2873 counter->address_length = v->address_length;
2874 counter->packets = clib_net_to_host_u64 (v->packets);
2875 counter->bytes = clib_net_to_host_u64 (v->bytes);
2880 static void vl_api_vnet_ip6_nbr_counters_t_handler
2881 (vl_api_vnet_ip6_nbr_counters_t * mp)
2886 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2887 (vl_api_vnet_ip6_nbr_counters_t * mp)
2889 vat_main_t *vam = &vat_main;
2890 vl_api_ip6_nbr_counter_t *v;
2891 ip6_nbr_counter_t *counter;
2892 struct in6_addr ip6;
2897 sw_if_index = ntohl (mp->sw_if_index);
2898 count = ntohl (mp->count);
2899 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2902 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2904 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2905 for (i = 0; i < count; i++)
2907 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2908 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2909 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2910 counter->address = ip6;
2911 counter->packets = clib_net_to_host_u64 (v->packets);
2912 counter->bytes = clib_net_to_host_u64 (v->bytes);
2917 static void vl_api_get_first_msg_id_reply_t_handler
2918 (vl_api_get_first_msg_id_reply_t * mp)
2920 vat_main_t *vam = &vat_main;
2921 i32 retval = ntohl (mp->retval);
2923 if (vam->async_mode)
2925 vam->async_errors += (retval < 0);
2929 vam->retval = retval;
2930 vam->result_ready = 1;
2934 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2938 static void vl_api_get_first_msg_id_reply_t_handler_json
2939 (vl_api_get_first_msg_id_reply_t * mp)
2941 vat_main_t *vam = &vat_main;
2942 vat_json_node_t node;
2944 vat_json_init_object (&node);
2945 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2946 vat_json_object_add_uint (&node, "first_msg_id",
2947 (uint) ntohs (mp->first_msg_id));
2949 vat_json_print (vam->ofp, &node);
2950 vat_json_free (&node);
2952 vam->retval = ntohl (mp->retval);
2953 vam->result_ready = 1;
2956 static void vl_api_get_node_graph_reply_t_handler
2957 (vl_api_get_node_graph_reply_t * mp)
2959 vat_main_t *vam = &vat_main;
2960 api_main_t *am = &api_main;
2961 i32 retval = ntohl (mp->retval);
2962 u8 *pvt_copy, *reply;
2967 if (vam->async_mode)
2969 vam->async_errors += (retval < 0);
2973 vam->retval = retval;
2974 vam->result_ready = 1;
2977 /* "Should never happen..." */
2981 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2982 pvt_copy = vec_dup (reply);
2984 /* Toss the shared-memory original... */
2985 pthread_mutex_lock (&am->vlib_rp->mutex);
2986 oldheap = svm_push_data_heap (am->vlib_rp);
2990 svm_pop_heap (oldheap);
2991 pthread_mutex_unlock (&am->vlib_rp->mutex);
2993 if (vam->graph_nodes)
2995 hash_free (vam->graph_node_index_by_name);
2997 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2999 node = vam->graph_nodes[0][i];
3000 vec_free (node->name);
3001 vec_free (node->next_nodes);
3004 vec_free (vam->graph_nodes[0]);
3005 vec_free (vam->graph_nodes);
3008 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
3009 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
3010 vec_free (pvt_copy);
3012 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
3014 node = vam->graph_nodes[0][i];
3015 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
3019 static void vl_api_get_node_graph_reply_t_handler_json
3020 (vl_api_get_node_graph_reply_t * mp)
3022 vat_main_t *vam = &vat_main;
3023 api_main_t *am = &api_main;
3025 vat_json_node_t node;
3028 /* $$$$ make this real? */
3029 vat_json_init_object (&node);
3030 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3031 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
3033 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
3035 /* Toss the shared-memory original... */
3036 pthread_mutex_lock (&am->vlib_rp->mutex);
3037 oldheap = svm_push_data_heap (am->vlib_rp);
3041 svm_pop_heap (oldheap);
3042 pthread_mutex_unlock (&am->vlib_rp->mutex);
3044 vat_json_print (vam->ofp, &node);
3045 vat_json_free (&node);
3047 vam->retval = ntohl (mp->retval);
3048 vam->result_ready = 1;
3052 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
3054 vat_main_t *vam = &vat_main;
3059 s = format (s, "%=16d%=16d%=16d",
3060 ntohl (mp->sw_if_index), mp->priority, mp->weight);
3064 s = format (s, "%=16U%=16d%=16d",
3065 mp->is_ipv6 ? format_ip6_address :
3067 mp->ip_address, mp->priority, mp->weight);
3070 print (vam->ofp, "%v", s);
3075 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
3077 vat_main_t *vam = &vat_main;
3078 vat_json_node_t *node = NULL;
3079 struct in6_addr ip6;
3082 if (VAT_JSON_ARRAY != vam->json_tree.type)
3084 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3085 vat_json_init_array (&vam->json_tree);
3087 node = vat_json_array_add (&vam->json_tree);
3088 vat_json_init_object (node);
3090 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
3091 vat_json_object_add_uint (node, "priority", mp->priority);
3092 vat_json_object_add_uint (node, "weight", mp->weight);
3095 vat_json_object_add_uint (node, "sw_if_index",
3096 clib_net_to_host_u32 (mp->sw_if_index));
3101 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3102 vat_json_object_add_ip6 (node, "address", ip6);
3106 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3107 vat_json_object_add_ip4 (node, "address", ip4);
3113 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
3116 vat_main_t *vam = &vat_main;
3119 ls_name = format (0, "%s", mp->ls_name);
3121 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
3127 vl_api_one_locator_set_details_t_handler_json
3128 (vl_api_one_locator_set_details_t * mp)
3130 vat_main_t *vam = &vat_main;
3131 vat_json_node_t *node = 0;
3134 ls_name = format (0, "%s", mp->ls_name);
3135 vec_add1 (ls_name, 0);
3137 if (VAT_JSON_ARRAY != vam->json_tree.type)
3139 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3140 vat_json_init_array (&vam->json_tree);
3142 node = vat_json_array_add (&vam->json_tree);
3144 vat_json_init_object (node);
3145 vat_json_object_add_string_copy (node, "ls_name", ls_name);
3146 vat_json_object_add_uint (node, "ls_index",
3147 clib_net_to_host_u32 (mp->ls_index));
3155 } __attribute__ ((__packed__)) lisp_nsh_api_t;
3158 unformat_nsh_address (unformat_input_t * input, va_list * args)
3160 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
3161 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
3165 format_nsh_address_vat (u8 * s, va_list * args)
3167 nsh_t *a = va_arg (*args, nsh_t *);
3168 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
3172 format_lisp_flat_eid (u8 * s, va_list * args)
3174 u32 type = va_arg (*args, u32);
3175 u8 *eid = va_arg (*args, u8 *);
3176 u32 eid_len = va_arg (*args, u32);
3181 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
3183 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
3185 return format (s, "%U", format_ethernet_address, eid);
3187 return format (s, "%U", format_nsh_address_vat, eid);
3193 format_lisp_eid_vat (u8 * s, va_list * args)
3195 u32 type = va_arg (*args, u32);
3196 u8 *eid = va_arg (*args, u8 *);
3197 u32 eid_len = va_arg (*args, u32);
3198 u8 *seid = va_arg (*args, u8 *);
3199 u32 seid_len = va_arg (*args, u32);
3200 u32 is_src_dst = va_arg (*args, u32);
3203 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
3205 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
3211 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
3213 vat_main_t *vam = &vat_main;
3214 u8 *s = 0, *eid = 0;
3216 if (~0 == mp->locator_set_index)
3217 s = format (0, "action: %d", mp->action);
3219 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3221 eid = format (0, "%U", format_lisp_eid_vat,
3225 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3228 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3229 clib_net_to_host_u32 (mp->vni),
3231 mp->is_local ? "local" : "remote",
3232 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3233 clib_net_to_host_u16 (mp->key_id), mp->key);
3240 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3243 vat_main_t *vam = &vat_main;
3244 vat_json_node_t *node = 0;
3247 if (VAT_JSON_ARRAY != vam->json_tree.type)
3249 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3250 vat_json_init_array (&vam->json_tree);
3252 node = vat_json_array_add (&vam->json_tree);
3254 vat_json_init_object (node);
3255 if (~0 == mp->locator_set_index)
3256 vat_json_object_add_uint (node, "action", mp->action);
3258 vat_json_object_add_uint (node, "locator_set_index",
3259 clib_net_to_host_u32 (mp->locator_set_index));
3261 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3262 if (mp->eid_type == 3)
3264 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3265 vat_json_init_object (nsh_json);
3266 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3267 vat_json_object_add_uint (nsh_json, "spi",
3268 clib_net_to_host_u32 (nsh->spi));
3269 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3273 eid = format (0, "%U", format_lisp_eid_vat,
3277 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3279 vat_json_object_add_string_copy (node, "eid", eid);
3282 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3283 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3284 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3288 vat_json_object_add_uint (node, "key_id",
3289 clib_net_to_host_u16 (mp->key_id));
3290 vat_json_object_add_string_copy (node, "key", mp->key);
3295 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3297 vat_main_t *vam = &vat_main;
3298 u8 *seid = 0, *deid = 0;
3299 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3301 deid = format (0, "%U", format_lisp_eid_vat,
3302 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3304 seid = format (0, "%U", format_lisp_eid_vat,
3305 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3311 format_ip_address_fcn = format_ip4_address;
3313 format_ip_address_fcn = format_ip6_address;
3316 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3317 clib_net_to_host_u32 (mp->vni),
3319 format_ip_address_fcn, mp->lloc,
3320 format_ip_address_fcn, mp->rloc,
3321 clib_net_to_host_u32 (mp->pkt_count),
3322 clib_net_to_host_u32 (mp->bytes));
3329 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3331 struct in6_addr ip6;
3333 vat_main_t *vam = &vat_main;
3334 vat_json_node_t *node = 0;
3335 u8 *deid = 0, *seid = 0;
3337 if (VAT_JSON_ARRAY != vam->json_tree.type)
3339 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3340 vat_json_init_array (&vam->json_tree);
3342 node = vat_json_array_add (&vam->json_tree);
3344 vat_json_init_object (node);
3345 deid = format (0, "%U", format_lisp_eid_vat,
3346 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3348 seid = format (0, "%U", format_lisp_eid_vat,
3349 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3354 vat_json_object_add_string_copy (node, "seid", seid);
3355 vat_json_object_add_string_copy (node, "deid", deid);
3356 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3360 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3361 vat_json_object_add_ip4 (node, "lloc", ip4);
3362 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3363 vat_json_object_add_ip4 (node, "rloc", ip4);
3367 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3368 vat_json_object_add_ip6 (node, "lloc", ip6);
3369 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3370 vat_json_object_add_ip6 (node, "rloc", ip6);
3372 vat_json_object_add_uint (node, "pkt_count",
3373 clib_net_to_host_u32 (mp->pkt_count));
3374 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3381 vl_api_one_eid_table_map_details_t_handler
3382 (vl_api_one_eid_table_map_details_t * mp)
3384 vat_main_t *vam = &vat_main;
3386 u8 *line = format (0, "%=10d%=10d",
3387 clib_net_to_host_u32 (mp->vni),
3388 clib_net_to_host_u32 (mp->dp_table));
3389 print (vam->ofp, "%v", line);
3394 vl_api_one_eid_table_map_details_t_handler_json
3395 (vl_api_one_eid_table_map_details_t * mp)
3397 vat_main_t *vam = &vat_main;
3398 vat_json_node_t *node = NULL;
3400 if (VAT_JSON_ARRAY != vam->json_tree.type)
3402 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3403 vat_json_init_array (&vam->json_tree);
3405 node = vat_json_array_add (&vam->json_tree);
3406 vat_json_init_object (node);
3407 vat_json_object_add_uint (node, "dp_table",
3408 clib_net_to_host_u32 (mp->dp_table));
3409 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3413 vl_api_one_eid_table_vni_details_t_handler
3414 (vl_api_one_eid_table_vni_details_t * mp)
3416 vat_main_t *vam = &vat_main;
3418 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3419 print (vam->ofp, "%v", line);
3424 vl_api_one_eid_table_vni_details_t_handler_json
3425 (vl_api_one_eid_table_vni_details_t * mp)
3427 vat_main_t *vam = &vat_main;
3428 vat_json_node_t *node = NULL;
3430 if (VAT_JSON_ARRAY != vam->json_tree.type)
3432 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3433 vat_json_init_array (&vam->json_tree);
3435 node = vat_json_array_add (&vam->json_tree);
3436 vat_json_init_object (node);
3437 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3441 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3442 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3444 vat_main_t *vam = &vat_main;
3445 int retval = clib_net_to_host_u32 (mp->retval);
3447 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3448 print (vam->ofp, "fallback threshold value: %d", mp->value);
3450 vam->retval = retval;
3451 vam->result_ready = 1;
3455 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3456 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3458 vat_main_t *vam = &vat_main;
3459 vat_json_node_t _node, *node = &_node;
3460 int retval = clib_net_to_host_u32 (mp->retval);
3462 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3463 vat_json_init_object (node);
3464 vat_json_object_add_uint (node, "value", mp->value);
3466 vat_json_print (vam->ofp, node);
3467 vat_json_free (node);
3469 vam->retval = retval;
3470 vam->result_ready = 1;
3474 vl_api_show_one_map_register_state_reply_t_handler
3475 (vl_api_show_one_map_register_state_reply_t * mp)
3477 vat_main_t *vam = &vat_main;
3478 int retval = clib_net_to_host_u32 (mp->retval);
3480 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3482 vam->retval = retval;
3483 vam->result_ready = 1;
3487 vl_api_show_one_map_register_state_reply_t_handler_json
3488 (vl_api_show_one_map_register_state_reply_t * mp)
3490 vat_main_t *vam = &vat_main;
3491 vat_json_node_t _node, *node = &_node;
3492 int retval = clib_net_to_host_u32 (mp->retval);
3494 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3496 vat_json_init_object (node);
3497 vat_json_object_add_string_copy (node, "state", s);
3499 vat_json_print (vam->ofp, node);
3500 vat_json_free (node);
3502 vam->retval = retval;
3503 vam->result_ready = 1;
3508 vl_api_show_one_rloc_probe_state_reply_t_handler
3509 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3511 vat_main_t *vam = &vat_main;
3512 int retval = clib_net_to_host_u32 (mp->retval);
3517 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3519 vam->retval = retval;
3520 vam->result_ready = 1;
3524 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3525 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3527 vat_main_t *vam = &vat_main;
3528 vat_json_node_t _node, *node = &_node;
3529 int retval = clib_net_to_host_u32 (mp->retval);
3531 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3532 vat_json_init_object (node);
3533 vat_json_object_add_string_copy (node, "state", s);
3535 vat_json_print (vam->ofp, node);
3536 vat_json_free (node);
3538 vam->retval = retval;
3539 vam->result_ready = 1;
3544 vl_api_show_one_stats_enable_disable_reply_t_handler
3545 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3547 vat_main_t *vam = &vat_main;
3548 int retval = clib_net_to_host_u32 (mp->retval);
3553 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3555 vam->retval = retval;
3556 vam->result_ready = 1;
3560 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3561 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3563 vat_main_t *vam = &vat_main;
3564 vat_json_node_t _node, *node = &_node;
3565 int retval = clib_net_to_host_u32 (mp->retval);
3567 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3568 vat_json_init_object (node);
3569 vat_json_object_add_string_copy (node, "state", s);
3571 vat_json_print (vam->ofp, node);
3572 vat_json_free (node);
3574 vam->retval = retval;
3575 vam->result_ready = 1;
3580 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3582 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3583 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3584 e->vni = clib_net_to_host_u32 (e->vni);
3588 gpe_fwd_entries_get_reply_t_net_to_host
3589 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3593 mp->count = clib_net_to_host_u32 (mp->count);
3594 for (i = 0; i < mp->count; i++)
3596 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3601 format_gpe_encap_mode (u8 * s, va_list * args)
3603 u32 mode = va_arg (*args, u32);
3608 return format (s, "lisp");
3610 return format (s, "vxlan");
3616 vl_api_gpe_get_encap_mode_reply_t_handler
3617 (vl_api_gpe_get_encap_mode_reply_t * mp)
3619 vat_main_t *vam = &vat_main;
3621 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3622 vam->retval = ntohl (mp->retval);
3623 vam->result_ready = 1;
3627 vl_api_gpe_get_encap_mode_reply_t_handler_json
3628 (vl_api_gpe_get_encap_mode_reply_t * mp)
3630 vat_main_t *vam = &vat_main;
3631 vat_json_node_t node;
3633 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3634 vec_add1 (encap_mode, 0);
3636 vat_json_init_object (&node);
3637 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3639 vec_free (encap_mode);
3640 vat_json_print (vam->ofp, &node);
3641 vat_json_free (&node);
3643 vam->retval = ntohl (mp->retval);
3644 vam->result_ready = 1;
3648 vl_api_gpe_fwd_entry_path_details_t_handler
3649 (vl_api_gpe_fwd_entry_path_details_t * mp)
3651 vat_main_t *vam = &vat_main;
3652 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3654 if (mp->lcl_loc.is_ip4)
3655 format_ip_address_fcn = format_ip4_address;
3657 format_ip_address_fcn = format_ip6_address;
3659 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3660 format_ip_address_fcn, &mp->lcl_loc,
3661 format_ip_address_fcn, &mp->rmt_loc);
3665 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3667 struct in6_addr ip6;
3672 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3673 vat_json_object_add_ip4 (n, "address", ip4);
3677 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3678 vat_json_object_add_ip6 (n, "address", ip6);
3680 vat_json_object_add_uint (n, "weight", loc->weight);
3684 vl_api_gpe_fwd_entry_path_details_t_handler_json
3685 (vl_api_gpe_fwd_entry_path_details_t * mp)
3687 vat_main_t *vam = &vat_main;
3688 vat_json_node_t *node = NULL;
3689 vat_json_node_t *loc_node;
3691 if (VAT_JSON_ARRAY != vam->json_tree.type)
3693 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3694 vat_json_init_array (&vam->json_tree);
3696 node = vat_json_array_add (&vam->json_tree);
3697 vat_json_init_object (node);
3699 loc_node = vat_json_object_add (node, "local_locator");
3700 vat_json_init_object (loc_node);
3701 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3703 loc_node = vat_json_object_add (node, "remote_locator");
3704 vat_json_init_object (loc_node);
3705 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3709 vl_api_gpe_fwd_entries_get_reply_t_handler
3710 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3712 vat_main_t *vam = &vat_main;
3714 int retval = clib_net_to_host_u32 (mp->retval);
3715 vl_api_gpe_fwd_entry_t *e;
3720 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3722 for (i = 0; i < mp->count; i++)
3724 e = &mp->entries[i];
3725 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3726 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3727 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3731 vam->retval = retval;
3732 vam->result_ready = 1;
3736 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3737 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3740 vat_main_t *vam = &vat_main;
3741 vat_json_node_t *e = 0, root;
3743 int retval = clib_net_to_host_u32 (mp->retval);
3744 vl_api_gpe_fwd_entry_t *fwd;
3749 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3750 vat_json_init_array (&root);
3752 for (i = 0; i < mp->count; i++)
3754 e = vat_json_array_add (&root);
3755 fwd = &mp->entries[i];
3757 vat_json_init_object (e);
3758 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3759 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3760 vat_json_object_add_int (e, "vni", fwd->vni);
3761 vat_json_object_add_int (e, "action", fwd->action);
3763 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3764 fwd->leid_prefix_len);
3766 vat_json_object_add_string_copy (e, "leid", s);
3769 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3770 fwd->reid_prefix_len);
3772 vat_json_object_add_string_copy (e, "reid", s);
3776 vat_json_print (vam->ofp, &root);
3777 vat_json_free (&root);
3780 vam->retval = retval;
3781 vam->result_ready = 1;
3785 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3786 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3788 vat_main_t *vam = &vat_main;
3790 int retval = clib_net_to_host_u32 (mp->retval);
3791 vl_api_gpe_native_fwd_rpath_t *r;
3796 n = clib_net_to_host_u32 (mp->count);
3798 for (i = 0; i < n; i++)
3800 r = &mp->entries[i];
3801 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3802 clib_net_to_host_u32 (r->fib_index),
3803 clib_net_to_host_u32 (r->nh_sw_if_index),
3804 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3808 vam->retval = retval;
3809 vam->result_ready = 1;
3813 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3814 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3816 vat_main_t *vam = &vat_main;
3817 vat_json_node_t root, *e;
3819 int retval = clib_net_to_host_u32 (mp->retval);
3820 vl_api_gpe_native_fwd_rpath_t *r;
3826 n = clib_net_to_host_u32 (mp->count);
3827 vat_json_init_array (&root);
3829 for (i = 0; i < n; i++)
3831 e = vat_json_array_add (&root);
3832 vat_json_init_object (e);
3833 r = &mp->entries[i];
3835 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3838 vat_json_object_add_string_copy (e, "ip4", s);
3841 vat_json_object_add_uint (e, "fib_index",
3842 clib_net_to_host_u32 (r->fib_index));
3843 vat_json_object_add_uint (e, "nh_sw_if_index",
3844 clib_net_to_host_u32 (r->nh_sw_if_index));
3847 vat_json_print (vam->ofp, &root);
3848 vat_json_free (&root);
3851 vam->retval = retval;
3852 vam->result_ready = 1;
3856 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3857 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3859 vat_main_t *vam = &vat_main;
3861 int retval = clib_net_to_host_u32 (mp->retval);
3866 n = clib_net_to_host_u32 (mp->count);
3868 for (i = 0; i < n; i++)
3869 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3872 vam->retval = retval;
3873 vam->result_ready = 1;
3877 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3878 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3880 vat_main_t *vam = &vat_main;
3881 vat_json_node_t root;
3883 int retval = clib_net_to_host_u32 (mp->retval);
3888 n = clib_net_to_host_u32 (mp->count);
3889 vat_json_init_array (&root);
3891 for (i = 0; i < n; i++)
3892 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3894 vat_json_print (vam->ofp, &root);
3895 vat_json_free (&root);
3898 vam->retval = retval;
3899 vam->result_ready = 1;
3903 vl_api_one_ndp_entries_get_reply_t_handler
3904 (vl_api_one_ndp_entries_get_reply_t * mp)
3906 vat_main_t *vam = &vat_main;
3908 int retval = clib_net_to_host_u32 (mp->retval);
3913 n = clib_net_to_host_u32 (mp->count);
3915 for (i = 0; i < n; i++)
3916 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3917 format_ethernet_address, mp->entries[i].mac);
3920 vam->retval = retval;
3921 vam->result_ready = 1;
3925 vl_api_one_ndp_entries_get_reply_t_handler_json
3926 (vl_api_one_ndp_entries_get_reply_t * mp)
3929 vat_main_t *vam = &vat_main;
3930 vat_json_node_t *e = 0, root;
3932 int retval = clib_net_to_host_u32 (mp->retval);
3933 vl_api_one_ndp_entry_t *arp_entry;
3938 n = clib_net_to_host_u32 (mp->count);
3939 vat_json_init_array (&root);
3941 for (i = 0; i < n; i++)
3943 e = vat_json_array_add (&root);
3944 arp_entry = &mp->entries[i];
3946 vat_json_init_object (e);
3947 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3950 vat_json_object_add_string_copy (e, "mac", s);
3953 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3955 vat_json_object_add_string_copy (e, "ip6", s);
3959 vat_json_print (vam->ofp, &root);
3960 vat_json_free (&root);
3963 vam->retval = retval;
3964 vam->result_ready = 1;
3968 vl_api_one_l2_arp_entries_get_reply_t_handler
3969 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3971 vat_main_t *vam = &vat_main;
3973 int retval = clib_net_to_host_u32 (mp->retval);
3978 n = clib_net_to_host_u32 (mp->count);
3980 for (i = 0; i < n; i++)
3981 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3982 format_ethernet_address, mp->entries[i].mac);
3985 vam->retval = retval;
3986 vam->result_ready = 1;
3990 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3991 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3994 vat_main_t *vam = &vat_main;
3995 vat_json_node_t *e = 0, root;
3997 int retval = clib_net_to_host_u32 (mp->retval);
3998 vl_api_one_l2_arp_entry_t *arp_entry;
4003 n = clib_net_to_host_u32 (mp->count);
4004 vat_json_init_array (&root);
4006 for (i = 0; i < n; i++)
4008 e = vat_json_array_add (&root);
4009 arp_entry = &mp->entries[i];
4011 vat_json_init_object (e);
4012 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
4015 vat_json_object_add_string_copy (e, "mac", s);
4018 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
4020 vat_json_object_add_string_copy (e, "ip4", s);
4024 vat_json_print (vam->ofp, &root);
4025 vat_json_free (&root);
4028 vam->retval = retval;
4029 vam->result_ready = 1;
4033 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
4035 vat_main_t *vam = &vat_main;
4037 int retval = clib_net_to_host_u32 (mp->retval);
4042 n = clib_net_to_host_u32 (mp->count);
4044 for (i = 0; i < n; i++)
4046 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
4050 vam->retval = retval;
4051 vam->result_ready = 1;
4055 vl_api_one_ndp_bd_get_reply_t_handler_json
4056 (vl_api_one_ndp_bd_get_reply_t * mp)
4058 vat_main_t *vam = &vat_main;
4059 vat_json_node_t root;
4061 int retval = clib_net_to_host_u32 (mp->retval);
4066 n = clib_net_to_host_u32 (mp->count);
4067 vat_json_init_array (&root);
4069 for (i = 0; i < n; i++)
4071 vat_json_array_add_uint (&root,
4072 clib_net_to_host_u32 (mp->bridge_domains[i]));
4075 vat_json_print (vam->ofp, &root);
4076 vat_json_free (&root);
4079 vam->retval = retval;
4080 vam->result_ready = 1;
4084 vl_api_one_l2_arp_bd_get_reply_t_handler
4085 (vl_api_one_l2_arp_bd_get_reply_t * mp)
4087 vat_main_t *vam = &vat_main;
4089 int retval = clib_net_to_host_u32 (mp->retval);
4094 n = clib_net_to_host_u32 (mp->count);
4096 for (i = 0; i < n; i++)
4098 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
4102 vam->retval = retval;
4103 vam->result_ready = 1;
4107 vl_api_one_l2_arp_bd_get_reply_t_handler_json
4108 (vl_api_one_l2_arp_bd_get_reply_t * mp)
4110 vat_main_t *vam = &vat_main;
4111 vat_json_node_t root;
4113 int retval = clib_net_to_host_u32 (mp->retval);
4118 n = clib_net_to_host_u32 (mp->count);
4119 vat_json_init_array (&root);
4121 for (i = 0; i < n; i++)
4123 vat_json_array_add_uint (&root,
4124 clib_net_to_host_u32 (mp->bridge_domains[i]));
4127 vat_json_print (vam->ofp, &root);
4128 vat_json_free (&root);
4131 vam->retval = retval;
4132 vam->result_ready = 1;
4136 vl_api_one_adjacencies_get_reply_t_handler
4137 (vl_api_one_adjacencies_get_reply_t * mp)
4139 vat_main_t *vam = &vat_main;
4141 int retval = clib_net_to_host_u32 (mp->retval);
4142 vl_api_one_adjacency_t *a;
4147 n = clib_net_to_host_u32 (mp->count);
4149 for (i = 0; i < n; i++)
4151 a = &mp->adjacencies[i];
4152 print (vam->ofp, "%U %40U",
4153 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
4154 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
4158 vam->retval = retval;
4159 vam->result_ready = 1;
4163 vl_api_one_adjacencies_get_reply_t_handler_json
4164 (vl_api_one_adjacencies_get_reply_t * mp)
4167 vat_main_t *vam = &vat_main;
4168 vat_json_node_t *e = 0, root;
4170 int retval = clib_net_to_host_u32 (mp->retval);
4171 vl_api_one_adjacency_t *a;
4176 n = clib_net_to_host_u32 (mp->count);
4177 vat_json_init_array (&root);
4179 for (i = 0; i < n; i++)
4181 e = vat_json_array_add (&root);
4182 a = &mp->adjacencies[i];
4184 vat_json_init_object (e);
4185 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
4186 a->leid_prefix_len);
4188 vat_json_object_add_string_copy (e, "leid", s);
4191 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
4192 a->reid_prefix_len);
4194 vat_json_object_add_string_copy (e, "reid", s);
4198 vat_json_print (vam->ofp, &root);
4199 vat_json_free (&root);
4202 vam->retval = retval;
4203 vam->result_ready = 1;
4207 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
4209 vat_main_t *vam = &vat_main;
4211 print (vam->ofp, "%=20U",
4212 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4217 vl_api_one_map_server_details_t_handler_json
4218 (vl_api_one_map_server_details_t * mp)
4220 vat_main_t *vam = &vat_main;
4221 vat_json_node_t *node = NULL;
4222 struct in6_addr ip6;
4225 if (VAT_JSON_ARRAY != vam->json_tree.type)
4227 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4228 vat_json_init_array (&vam->json_tree);
4230 node = vat_json_array_add (&vam->json_tree);
4232 vat_json_init_object (node);
4235 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4236 vat_json_object_add_ip6 (node, "map-server", ip6);
4240 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4241 vat_json_object_add_ip4 (node, "map-server", ip4);
4246 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4249 vat_main_t *vam = &vat_main;
4251 print (vam->ofp, "%=20U",
4252 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4257 vl_api_one_map_resolver_details_t_handler_json
4258 (vl_api_one_map_resolver_details_t * mp)
4260 vat_main_t *vam = &vat_main;
4261 vat_json_node_t *node = NULL;
4262 struct in6_addr ip6;
4265 if (VAT_JSON_ARRAY != vam->json_tree.type)
4267 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4268 vat_json_init_array (&vam->json_tree);
4270 node = vat_json_array_add (&vam->json_tree);
4272 vat_json_init_object (node);
4275 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4276 vat_json_object_add_ip6 (node, "map resolver", ip6);
4280 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4281 vat_json_object_add_ip4 (node, "map resolver", ip4);
4286 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4288 vat_main_t *vam = &vat_main;
4289 i32 retval = ntohl (mp->retval);
4293 print (vam->ofp, "feature: %s\ngpe: %s",
4294 mp->feature_status ? "enabled" : "disabled",
4295 mp->gpe_status ? "enabled" : "disabled");
4298 vam->retval = retval;
4299 vam->result_ready = 1;
4303 vl_api_show_one_status_reply_t_handler_json
4304 (vl_api_show_one_status_reply_t * mp)
4306 vat_main_t *vam = &vat_main;
4307 vat_json_node_t node;
4308 u8 *gpe_status = NULL;
4309 u8 *feature_status = NULL;
4311 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4312 feature_status = format (0, "%s",
4313 mp->feature_status ? "enabled" : "disabled");
4314 vec_add1 (gpe_status, 0);
4315 vec_add1 (feature_status, 0);
4317 vat_json_init_object (&node);
4318 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4319 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4321 vec_free (gpe_status);
4322 vec_free (feature_status);
4324 vat_json_print (vam->ofp, &node);
4325 vat_json_free (&node);
4327 vam->retval = ntohl (mp->retval);
4328 vam->result_ready = 1;
4332 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4333 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4335 vat_main_t *vam = &vat_main;
4336 i32 retval = ntohl (mp->retval);
4340 print (vam->ofp, "%=20s", mp->locator_set_name);
4343 vam->retval = retval;
4344 vam->result_ready = 1;
4348 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4349 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4351 vat_main_t *vam = &vat_main;
4352 vat_json_node_t *node = NULL;
4354 if (VAT_JSON_ARRAY != vam->json_tree.type)
4356 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4357 vat_json_init_array (&vam->json_tree);
4359 node = vat_json_array_add (&vam->json_tree);
4361 vat_json_init_object (node);
4362 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4364 vat_json_print (vam->ofp, node);
4365 vat_json_free (node);
4367 vam->retval = ntohl (mp->retval);
4368 vam->result_ready = 1;
4372 format_lisp_map_request_mode (u8 * s, va_list * args)
4374 u32 mode = va_arg (*args, u32);
4379 return format (0, "dst-only");
4381 return format (0, "src-dst");
4387 vl_api_show_one_map_request_mode_reply_t_handler
4388 (vl_api_show_one_map_request_mode_reply_t * mp)
4390 vat_main_t *vam = &vat_main;
4391 i32 retval = ntohl (mp->retval);
4395 u32 mode = mp->mode;
4396 print (vam->ofp, "map_request_mode: %U",
4397 format_lisp_map_request_mode, mode);
4400 vam->retval = retval;
4401 vam->result_ready = 1;
4405 vl_api_show_one_map_request_mode_reply_t_handler_json
4406 (vl_api_show_one_map_request_mode_reply_t * mp)
4408 vat_main_t *vam = &vat_main;
4409 vat_json_node_t node;
4414 s = format (0, "%U", format_lisp_map_request_mode, mode);
4417 vat_json_init_object (&node);
4418 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4419 vat_json_print (vam->ofp, &node);
4420 vat_json_free (&node);
4423 vam->retval = ntohl (mp->retval);
4424 vam->result_ready = 1;
4428 vl_api_one_show_xtr_mode_reply_t_handler
4429 (vl_api_one_show_xtr_mode_reply_t * mp)
4431 vat_main_t *vam = &vat_main;
4432 i32 retval = ntohl (mp->retval);
4436 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4439 vam->retval = retval;
4440 vam->result_ready = 1;
4444 vl_api_one_show_xtr_mode_reply_t_handler_json
4445 (vl_api_one_show_xtr_mode_reply_t * mp)
4447 vat_main_t *vam = &vat_main;
4448 vat_json_node_t node;
4451 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4452 vec_add1 (status, 0);
4454 vat_json_init_object (&node);
4455 vat_json_object_add_string_copy (&node, "status", status);
4459 vat_json_print (vam->ofp, &node);
4460 vat_json_free (&node);
4462 vam->retval = ntohl (mp->retval);
4463 vam->result_ready = 1;
4467 vl_api_one_show_pitr_mode_reply_t_handler
4468 (vl_api_one_show_pitr_mode_reply_t * mp)
4470 vat_main_t *vam = &vat_main;
4471 i32 retval = ntohl (mp->retval);
4475 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4478 vam->retval = retval;
4479 vam->result_ready = 1;
4483 vl_api_one_show_pitr_mode_reply_t_handler_json
4484 (vl_api_one_show_pitr_mode_reply_t * mp)
4486 vat_main_t *vam = &vat_main;
4487 vat_json_node_t node;
4490 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4491 vec_add1 (status, 0);
4493 vat_json_init_object (&node);
4494 vat_json_object_add_string_copy (&node, "status", status);
4498 vat_json_print (vam->ofp, &node);
4499 vat_json_free (&node);
4501 vam->retval = ntohl (mp->retval);
4502 vam->result_ready = 1;
4506 vl_api_one_show_petr_mode_reply_t_handler
4507 (vl_api_one_show_petr_mode_reply_t * mp)
4509 vat_main_t *vam = &vat_main;
4510 i32 retval = ntohl (mp->retval);
4514 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4517 vam->retval = retval;
4518 vam->result_ready = 1;
4522 vl_api_one_show_petr_mode_reply_t_handler_json
4523 (vl_api_one_show_petr_mode_reply_t * mp)
4525 vat_main_t *vam = &vat_main;
4526 vat_json_node_t node;
4529 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4530 vec_add1 (status, 0);
4532 vat_json_init_object (&node);
4533 vat_json_object_add_string_copy (&node, "status", status);
4537 vat_json_print (vam->ofp, &node);
4538 vat_json_free (&node);
4540 vam->retval = ntohl (mp->retval);
4541 vam->result_ready = 1;
4545 vl_api_show_one_use_petr_reply_t_handler
4546 (vl_api_show_one_use_petr_reply_t * mp)
4548 vat_main_t *vam = &vat_main;
4549 i32 retval = ntohl (mp->retval);
4553 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4556 print (vam->ofp, "Proxy-ETR address; %U",
4557 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4562 vam->retval = retval;
4563 vam->result_ready = 1;
4567 vl_api_show_one_use_petr_reply_t_handler_json
4568 (vl_api_show_one_use_petr_reply_t * mp)
4570 vat_main_t *vam = &vat_main;
4571 vat_json_node_t node;
4574 struct in6_addr ip6;
4576 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4577 vec_add1 (status, 0);
4579 vat_json_init_object (&node);
4580 vat_json_object_add_string_copy (&node, "status", status);
4585 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4586 vat_json_object_add_ip6 (&node, "address", ip6);
4590 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4591 vat_json_object_add_ip4 (&node, "address", ip4);
4597 vat_json_print (vam->ofp, &node);
4598 vat_json_free (&node);
4600 vam->retval = ntohl (mp->retval);
4601 vam->result_ready = 1;
4605 vl_api_show_one_nsh_mapping_reply_t_handler
4606 (vl_api_show_one_nsh_mapping_reply_t * mp)
4608 vat_main_t *vam = &vat_main;
4609 i32 retval = ntohl (mp->retval);
4613 print (vam->ofp, "%-20s%-16s",
4614 mp->is_set ? "set" : "not-set",
4615 mp->is_set ? (char *) mp->locator_set_name : "");
4618 vam->retval = retval;
4619 vam->result_ready = 1;
4623 vl_api_show_one_nsh_mapping_reply_t_handler_json
4624 (vl_api_show_one_nsh_mapping_reply_t * mp)
4626 vat_main_t *vam = &vat_main;
4627 vat_json_node_t node;
4630 status = format (0, "%s", mp->is_set ? "yes" : "no");
4631 vec_add1 (status, 0);
4633 vat_json_init_object (&node);
4634 vat_json_object_add_string_copy (&node, "is_set", status);
4637 vat_json_object_add_string_copy (&node, "locator_set",
4638 mp->locator_set_name);
4643 vat_json_print (vam->ofp, &node);
4644 vat_json_free (&node);
4646 vam->retval = ntohl (mp->retval);
4647 vam->result_ready = 1;
4651 vl_api_show_one_map_register_ttl_reply_t_handler
4652 (vl_api_show_one_map_register_ttl_reply_t * mp)
4654 vat_main_t *vam = &vat_main;
4655 i32 retval = ntohl (mp->retval);
4657 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4661 print (vam->ofp, "ttl: %u", mp->ttl);
4664 vam->retval = retval;
4665 vam->result_ready = 1;
4669 vl_api_show_one_map_register_ttl_reply_t_handler_json
4670 (vl_api_show_one_map_register_ttl_reply_t * mp)
4672 vat_main_t *vam = &vat_main;
4673 vat_json_node_t node;
4675 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4676 vat_json_init_object (&node);
4677 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4679 vat_json_print (vam->ofp, &node);
4680 vat_json_free (&node);
4682 vam->retval = ntohl (mp->retval);
4683 vam->result_ready = 1;
4687 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4689 vat_main_t *vam = &vat_main;
4690 i32 retval = ntohl (mp->retval);
4694 print (vam->ofp, "%-20s%-16s",
4695 mp->status ? "enabled" : "disabled",
4696 mp->status ? (char *) mp->locator_set_name : "");
4699 vam->retval = retval;
4700 vam->result_ready = 1;
4704 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4706 vat_main_t *vam = &vat_main;
4707 vat_json_node_t node;
4710 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4711 vec_add1 (status, 0);
4713 vat_json_init_object (&node);
4714 vat_json_object_add_string_copy (&node, "status", status);
4717 vat_json_object_add_string_copy (&node, "locator_set",
4718 mp->locator_set_name);
4723 vat_json_print (vam->ofp, &node);
4724 vat_json_free (&node);
4726 vam->retval = ntohl (mp->retval);
4727 vam->result_ready = 1;
4731 format_policer_type (u8 * s, va_list * va)
4733 u32 i = va_arg (*va, u32);
4735 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4736 s = format (s, "1r2c");
4737 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4738 s = format (s, "1r3c");
4739 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4740 s = format (s, "2r3c-2698");
4741 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4742 s = format (s, "2r3c-4115");
4743 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4744 s = format (s, "2r3c-mef5cf1");
4746 s = format (s, "ILLEGAL");
4751 format_policer_rate_type (u8 * s, va_list * va)
4753 u32 i = va_arg (*va, u32);
4755 if (i == SSE2_QOS_RATE_KBPS)
4756 s = format (s, "kbps");
4757 else if (i == SSE2_QOS_RATE_PPS)
4758 s = format (s, "pps");
4760 s = format (s, "ILLEGAL");
4765 format_policer_round_type (u8 * s, va_list * va)
4767 u32 i = va_arg (*va, u32);
4769 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4770 s = format (s, "closest");
4771 else if (i == SSE2_QOS_ROUND_TO_UP)
4772 s = format (s, "up");
4773 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4774 s = format (s, "down");
4776 s = format (s, "ILLEGAL");
4781 format_policer_action_type (u8 * s, va_list * va)
4783 u32 i = va_arg (*va, u32);
4785 if (i == SSE2_QOS_ACTION_DROP)
4786 s = format (s, "drop");
4787 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4788 s = format (s, "transmit");
4789 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4790 s = format (s, "mark-and-transmit");
4792 s = format (s, "ILLEGAL");
4797 format_dscp (u8 * s, va_list * va)
4799 u32 i = va_arg (*va, u32);
4804 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4808 return format (s, "ILLEGAL");
4810 s = format (s, "%s", t);
4815 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4817 vat_main_t *vam = &vat_main;
4818 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4820 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4821 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4823 conform_dscp_str = format (0, "");
4825 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4826 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4828 exceed_dscp_str = format (0, "");
4830 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4831 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4833 violate_dscp_str = format (0, "");
4835 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4836 "rate type %U, round type %U, %s rate, %s color-aware, "
4837 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4838 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4839 "conform action %U%s, exceed action %U%s, violate action %U%s",
4841 format_policer_type, mp->type,
4844 clib_net_to_host_u64 (mp->cb),
4845 clib_net_to_host_u64 (mp->eb),
4846 format_policer_rate_type, mp->rate_type,
4847 format_policer_round_type, mp->round_type,
4848 mp->single_rate ? "single" : "dual",
4849 mp->color_aware ? "is" : "not",
4850 ntohl (mp->cir_tokens_per_period),
4851 ntohl (mp->pir_tokens_per_period),
4853 ntohl (mp->current_limit),
4854 ntohl (mp->current_bucket),
4855 ntohl (mp->extended_limit),
4856 ntohl (mp->extended_bucket),
4857 clib_net_to_host_u64 (mp->last_update_time),
4858 format_policer_action_type, mp->conform_action_type,
4860 format_policer_action_type, mp->exceed_action_type,
4862 format_policer_action_type, mp->violate_action_type,
4865 vec_free (conform_dscp_str);
4866 vec_free (exceed_dscp_str);
4867 vec_free (violate_dscp_str);
4870 static void vl_api_policer_details_t_handler_json
4871 (vl_api_policer_details_t * mp)
4873 vat_main_t *vam = &vat_main;
4874 vat_json_node_t *node;
4875 u8 *rate_type_str, *round_type_str, *type_str;
4876 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4878 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4880 format (0, "%U", format_policer_round_type, mp->round_type);
4881 type_str = format (0, "%U", format_policer_type, mp->type);
4882 conform_action_str = format (0, "%U", format_policer_action_type,
4883 mp->conform_action_type);
4884 exceed_action_str = format (0, "%U", format_policer_action_type,
4885 mp->exceed_action_type);
4886 violate_action_str = format (0, "%U", format_policer_action_type,
4887 mp->violate_action_type);
4889 if (VAT_JSON_ARRAY != vam->json_tree.type)
4891 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4892 vat_json_init_array (&vam->json_tree);
4894 node = vat_json_array_add (&vam->json_tree);
4896 vat_json_init_object (node);
4897 vat_json_object_add_string_copy (node, "name", mp->name);
4898 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4899 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4900 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4901 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4902 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4903 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4904 vat_json_object_add_string_copy (node, "type", type_str);
4905 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4906 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4907 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4908 vat_json_object_add_uint (node, "cir_tokens_per_period",
4909 ntohl (mp->cir_tokens_per_period));
4910 vat_json_object_add_uint (node, "eir_tokens_per_period",
4911 ntohl (mp->pir_tokens_per_period));
4912 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4913 vat_json_object_add_uint (node, "current_bucket",
4914 ntohl (mp->current_bucket));
4915 vat_json_object_add_uint (node, "extended_limit",
4916 ntohl (mp->extended_limit));
4917 vat_json_object_add_uint (node, "extended_bucket",
4918 ntohl (mp->extended_bucket));
4919 vat_json_object_add_uint (node, "last_update_time",
4920 ntohl (mp->last_update_time));
4921 vat_json_object_add_string_copy (node, "conform_action",
4922 conform_action_str);
4923 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4925 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4926 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4927 vec_free (dscp_str);
4929 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4930 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4932 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4933 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4934 vec_free (dscp_str);
4936 vat_json_object_add_string_copy (node, "violate_action",
4937 violate_action_str);
4938 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4940 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4941 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4942 vec_free (dscp_str);
4945 vec_free (rate_type_str);
4946 vec_free (round_type_str);
4947 vec_free (type_str);
4948 vec_free (conform_action_str);
4949 vec_free (exceed_action_str);
4950 vec_free (violate_action_str);
4954 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4957 vat_main_t *vam = &vat_main;
4958 int i, count = ntohl (mp->count);
4961 print (vam->ofp, "classify table ids (%d) : ", count);
4962 for (i = 0; i < count; i++)
4964 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4965 print (vam->ofp, (i < count - 1) ? "," : "");
4967 vam->retval = ntohl (mp->retval);
4968 vam->result_ready = 1;
4972 vl_api_classify_table_ids_reply_t_handler_json
4973 (vl_api_classify_table_ids_reply_t * mp)
4975 vat_main_t *vam = &vat_main;
4976 int i, count = ntohl (mp->count);
4980 vat_json_node_t node;
4982 vat_json_init_object (&node);
4983 for (i = 0; i < count; i++)
4985 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4987 vat_json_print (vam->ofp, &node);
4988 vat_json_free (&node);
4990 vam->retval = ntohl (mp->retval);
4991 vam->result_ready = 1;
4995 vl_api_classify_table_by_interface_reply_t_handler
4996 (vl_api_classify_table_by_interface_reply_t * mp)
4998 vat_main_t *vam = &vat_main;
5001 table_id = ntohl (mp->l2_table_id);
5003 print (vam->ofp, "l2 table id : %d", table_id);
5005 print (vam->ofp, "l2 table id : No input ACL tables configured");
5006 table_id = ntohl (mp->ip4_table_id);
5008 print (vam->ofp, "ip4 table id : %d", table_id);
5010 print (vam->ofp, "ip4 table id : No input ACL tables configured");
5011 table_id = ntohl (mp->ip6_table_id);
5013 print (vam->ofp, "ip6 table id : %d", table_id);
5015 print (vam->ofp, "ip6 table id : No input ACL tables configured");
5016 vam->retval = ntohl (mp->retval);
5017 vam->result_ready = 1;
5021 vl_api_classify_table_by_interface_reply_t_handler_json
5022 (vl_api_classify_table_by_interface_reply_t * mp)
5024 vat_main_t *vam = &vat_main;
5025 vat_json_node_t node;
5027 vat_json_init_object (&node);
5029 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
5030 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
5031 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
5033 vat_json_print (vam->ofp, &node);
5034 vat_json_free (&node);
5036 vam->retval = ntohl (mp->retval);
5037 vam->result_ready = 1;
5040 static void vl_api_policer_add_del_reply_t_handler
5041 (vl_api_policer_add_del_reply_t * mp)
5043 vat_main_t *vam = &vat_main;
5044 i32 retval = ntohl (mp->retval);
5045 if (vam->async_mode)
5047 vam->async_errors += (retval < 0);
5051 vam->retval = retval;
5052 vam->result_ready = 1;
5053 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
5055 * Note: this is just barely thread-safe, depends on
5056 * the main thread spinning waiting for an answer...
5058 errmsg ("policer index %d", ntohl (mp->policer_index));
5062 static void vl_api_policer_add_del_reply_t_handler_json
5063 (vl_api_policer_add_del_reply_t * mp)
5065 vat_main_t *vam = &vat_main;
5066 vat_json_node_t node;
5068 vat_json_init_object (&node);
5069 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5070 vat_json_object_add_uint (&node, "policer_index",
5071 ntohl (mp->policer_index));
5073 vat_json_print (vam->ofp, &node);
5074 vat_json_free (&node);
5076 vam->retval = ntohl (mp->retval);
5077 vam->result_ready = 1;
5080 /* Format hex dump. */
5082 format_hex_bytes (u8 * s, va_list * va)
5084 u8 *bytes = va_arg (*va, u8 *);
5085 int n_bytes = va_arg (*va, int);
5088 /* Print short or long form depending on byte count. */
5089 uword short_form = n_bytes <= 32;
5090 u32 indent = format_get_indent (s);
5095 for (i = 0; i < n_bytes; i++)
5097 if (!short_form && (i % 32) == 0)
5098 s = format (s, "%08x: ", i);
5099 s = format (s, "%02x", bytes[i]);
5100 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
5101 s = format (s, "\n%U", format_white_space, indent);
5108 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
5111 vat_main_t *vam = &vat_main;
5112 i32 retval = ntohl (mp->retval);
5115 print (vam->ofp, "classify table info :");
5116 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
5117 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
5118 ntohl (mp->miss_next_index));
5119 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
5120 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
5121 ntohl (mp->match_n_vectors));
5122 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
5123 ntohl (mp->mask_length));
5125 vam->retval = retval;
5126 vam->result_ready = 1;
5130 vl_api_classify_table_info_reply_t_handler_json
5131 (vl_api_classify_table_info_reply_t * mp)
5133 vat_main_t *vam = &vat_main;
5134 vat_json_node_t node;
5136 i32 retval = ntohl (mp->retval);
5139 vat_json_init_object (&node);
5141 vat_json_object_add_int (&node, "sessions",
5142 ntohl (mp->active_sessions));
5143 vat_json_object_add_int (&node, "nexttbl",
5144 ntohl (mp->next_table_index));
5145 vat_json_object_add_int (&node, "nextnode",
5146 ntohl (mp->miss_next_index));
5147 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
5148 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
5149 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
5150 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
5151 ntohl (mp->mask_length), 0);
5152 vat_json_object_add_string_copy (&node, "mask", s);
5154 vat_json_print (vam->ofp, &node);
5155 vat_json_free (&node);
5157 vam->retval = ntohl (mp->retval);
5158 vam->result_ready = 1;
5162 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
5165 vat_main_t *vam = &vat_main;
5167 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
5168 ntohl (mp->hit_next_index), ntohl (mp->advance),
5169 ntohl (mp->opaque_index));
5170 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
5171 ntohl (mp->match_length));
5175 vl_api_classify_session_details_t_handler_json
5176 (vl_api_classify_session_details_t * mp)
5178 vat_main_t *vam = &vat_main;
5179 vat_json_node_t *node = NULL;
5181 if (VAT_JSON_ARRAY != vam->json_tree.type)
5183 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5184 vat_json_init_array (&vam->json_tree);
5186 node = vat_json_array_add (&vam->json_tree);
5188 vat_json_init_object (node);
5189 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
5190 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
5191 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
5193 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
5195 vat_json_object_add_string_copy (node, "match", s);
5198 static void vl_api_pg_create_interface_reply_t_handler
5199 (vl_api_pg_create_interface_reply_t * mp)
5201 vat_main_t *vam = &vat_main;
5203 vam->retval = ntohl (mp->retval);
5204 vam->result_ready = 1;
5207 static void vl_api_pg_create_interface_reply_t_handler_json
5208 (vl_api_pg_create_interface_reply_t * mp)
5210 vat_main_t *vam = &vat_main;
5211 vat_json_node_t node;
5213 i32 retval = ntohl (mp->retval);
5216 vat_json_init_object (&node);
5218 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
5220 vat_json_print (vam->ofp, &node);
5221 vat_json_free (&node);
5223 vam->retval = ntohl (mp->retval);
5224 vam->result_ready = 1;
5227 static void vl_api_policer_classify_details_t_handler
5228 (vl_api_policer_classify_details_t * mp)
5230 vat_main_t *vam = &vat_main;
5232 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5233 ntohl (mp->table_index));
5236 static void vl_api_policer_classify_details_t_handler_json
5237 (vl_api_policer_classify_details_t * mp)
5239 vat_main_t *vam = &vat_main;
5240 vat_json_node_t *node;
5242 if (VAT_JSON_ARRAY != vam->json_tree.type)
5244 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5245 vat_json_init_array (&vam->json_tree);
5247 node = vat_json_array_add (&vam->json_tree);
5249 vat_json_init_object (node);
5250 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5251 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5254 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
5255 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5257 vat_main_t *vam = &vat_main;
5258 i32 retval = ntohl (mp->retval);
5259 if (vam->async_mode)
5261 vam->async_errors += (retval < 0);
5265 vam->retval = retval;
5266 vam->sw_if_index = ntohl (mp->sw_if_index);
5267 vam->result_ready = 1;
5269 vam->regenerate_interface_table = 1;
5272 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
5273 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5275 vat_main_t *vam = &vat_main;
5276 vat_json_node_t node;
5278 vat_json_init_object (&node);
5279 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5280 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
5282 vat_json_print (vam->ofp, &node);
5283 vat_json_free (&node);
5285 vam->retval = ntohl (mp->retval);
5286 vam->result_ready = 1;
5289 static void vl_api_flow_classify_details_t_handler
5290 (vl_api_flow_classify_details_t * mp)
5292 vat_main_t *vam = &vat_main;
5294 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5295 ntohl (mp->table_index));
5298 static void vl_api_flow_classify_details_t_handler_json
5299 (vl_api_flow_classify_details_t * mp)
5301 vat_main_t *vam = &vat_main;
5302 vat_json_node_t *node;
5304 if (VAT_JSON_ARRAY != vam->json_tree.type)
5306 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5307 vat_json_init_array (&vam->json_tree);
5309 node = vat_json_array_add (&vam->json_tree);
5311 vat_json_init_object (node);
5312 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5313 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5316 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
5317 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
5318 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
5319 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
5320 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
5321 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
5322 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
5323 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
5324 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
5325 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
5326 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
5327 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
5328 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5329 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5330 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5331 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5332 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5333 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5334 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5335 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5336 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5337 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5340 * Generate boilerplate reply handlers, which
5341 * dig the return value out of the xxx_reply_t API message,
5342 * stick it into vam->retval, and set vam->result_ready
5344 * Could also do this by pointing N message decode slots at
5345 * a single function, but that could break in subtle ways.
5348 #define foreach_standard_reply_retval_handler \
5349 _(sw_interface_set_flags_reply) \
5350 _(sw_interface_add_del_address_reply) \
5351 _(sw_interface_set_rx_mode_reply) \
5352 _(sw_interface_set_rx_placement_reply) \
5353 _(sw_interface_set_table_reply) \
5354 _(sw_interface_set_mpls_enable_reply) \
5355 _(sw_interface_set_vpath_reply) \
5356 _(sw_interface_set_vxlan_bypass_reply) \
5357 _(sw_interface_set_geneve_bypass_reply) \
5358 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5359 _(sw_interface_set_l2_bridge_reply) \
5360 _(bridge_domain_add_del_reply) \
5361 _(sw_interface_set_l2_xconnect_reply) \
5362 _(l2fib_add_del_reply) \
5363 _(l2fib_flush_int_reply) \
5364 _(l2fib_flush_bd_reply) \
5365 _(ip_add_del_route_reply) \
5366 _(ip_table_add_del_reply) \
5367 _(ip_mroute_add_del_reply) \
5368 _(mpls_route_add_del_reply) \
5369 _(mpls_table_add_del_reply) \
5370 _(mpls_ip_bind_unbind_reply) \
5371 _(bier_route_add_del_reply) \
5372 _(bier_table_add_del_reply) \
5373 _(proxy_arp_add_del_reply) \
5374 _(proxy_arp_intfc_enable_disable_reply) \
5375 _(sw_interface_set_unnumbered_reply) \
5376 _(ip_neighbor_add_del_reply) \
5377 _(oam_add_del_reply) \
5378 _(reset_fib_reply) \
5379 _(dhcp_proxy_config_reply) \
5380 _(dhcp_proxy_set_vss_reply) \
5381 _(dhcp_client_config_reply) \
5382 _(set_ip_flow_hash_reply) \
5383 _(sw_interface_ip6_enable_disable_reply) \
5384 _(sw_interface_ip6_set_link_local_address_reply) \
5385 _(ip6nd_proxy_add_del_reply) \
5386 _(sw_interface_ip6nd_ra_prefix_reply) \
5387 _(sw_interface_ip6nd_ra_config_reply) \
5388 _(set_arp_neighbor_limit_reply) \
5389 _(l2_patch_add_del_reply) \
5390 _(sr_mpls_policy_add_reply) \
5391 _(sr_mpls_policy_mod_reply) \
5392 _(sr_mpls_policy_del_reply) \
5393 _(sr_policy_add_reply) \
5394 _(sr_policy_mod_reply) \
5395 _(sr_policy_del_reply) \
5396 _(sr_localsid_add_del_reply) \
5397 _(sr_steering_add_del_reply) \
5398 _(classify_add_del_session_reply) \
5399 _(classify_set_interface_ip_table_reply) \
5400 _(classify_set_interface_l2_tables_reply) \
5401 _(l2tpv3_set_tunnel_cookies_reply) \
5402 _(l2tpv3_interface_enable_disable_reply) \
5403 _(l2tpv3_set_lookup_key_reply) \
5404 _(l2_fib_clear_table_reply) \
5405 _(l2_interface_efp_filter_reply) \
5406 _(l2_interface_vlan_tag_rewrite_reply) \
5407 _(modify_vhost_user_if_reply) \
5408 _(delete_vhost_user_if_reply) \
5409 _(ip_probe_neighbor_reply) \
5410 _(ip_scan_neighbor_enable_disable_reply) \
5411 _(want_ip4_arp_events_reply) \
5412 _(want_ip6_nd_events_reply) \
5413 _(want_l2_macs_events_reply) \
5414 _(input_acl_set_interface_reply) \
5415 _(ipsec_spd_add_del_reply) \
5416 _(ipsec_interface_add_del_spd_reply) \
5417 _(ipsec_spd_add_del_entry_reply) \
5418 _(ipsec_sad_add_del_entry_reply) \
5419 _(ipsec_sa_set_key_reply) \
5420 _(ipsec_tunnel_if_add_del_reply) \
5421 _(ipsec_tunnel_if_set_key_reply) \
5422 _(ipsec_tunnel_if_set_sa_reply) \
5423 _(ikev2_profile_add_del_reply) \
5424 _(ikev2_profile_set_auth_reply) \
5425 _(ikev2_profile_set_id_reply) \
5426 _(ikev2_profile_set_ts_reply) \
5427 _(ikev2_set_local_key_reply) \
5428 _(ikev2_set_responder_reply) \
5429 _(ikev2_set_ike_transforms_reply) \
5430 _(ikev2_set_esp_transforms_reply) \
5431 _(ikev2_set_sa_lifetime_reply) \
5432 _(ikev2_initiate_sa_init_reply) \
5433 _(ikev2_initiate_del_ike_sa_reply) \
5434 _(ikev2_initiate_del_child_sa_reply) \
5435 _(ikev2_initiate_rekey_child_sa_reply) \
5436 _(delete_loopback_reply) \
5437 _(bd_ip_mac_add_del_reply) \
5438 _(want_interface_events_reply) \
5439 _(want_stats_reply) \
5440 _(cop_interface_enable_disable_reply) \
5441 _(cop_whitelist_enable_disable_reply) \
5442 _(sw_interface_clear_stats_reply) \
5443 _(ioam_enable_reply) \
5444 _(ioam_disable_reply) \
5445 _(one_add_del_locator_reply) \
5446 _(one_add_del_local_eid_reply) \
5447 _(one_add_del_remote_mapping_reply) \
5448 _(one_add_del_adjacency_reply) \
5449 _(one_add_del_map_resolver_reply) \
5450 _(one_add_del_map_server_reply) \
5451 _(one_enable_disable_reply) \
5452 _(one_rloc_probe_enable_disable_reply) \
5453 _(one_map_register_enable_disable_reply) \
5454 _(one_map_register_set_ttl_reply) \
5455 _(one_set_transport_protocol_reply) \
5456 _(one_map_register_fallback_threshold_reply) \
5457 _(one_pitr_set_locator_set_reply) \
5458 _(one_map_request_mode_reply) \
5459 _(one_add_del_map_request_itr_rlocs_reply) \
5460 _(one_eid_table_add_del_map_reply) \
5461 _(one_use_petr_reply) \
5462 _(one_stats_enable_disable_reply) \
5463 _(one_add_del_l2_arp_entry_reply) \
5464 _(one_add_del_ndp_entry_reply) \
5465 _(one_stats_flush_reply) \
5466 _(one_enable_disable_xtr_mode_reply) \
5467 _(one_enable_disable_pitr_mode_reply) \
5468 _(one_enable_disable_petr_mode_reply) \
5469 _(gpe_enable_disable_reply) \
5470 _(gpe_set_encap_mode_reply) \
5471 _(gpe_add_del_iface_reply) \
5472 _(gpe_add_del_native_fwd_rpath_reply) \
5473 _(af_packet_delete_reply) \
5474 _(policer_classify_set_interface_reply) \
5475 _(netmap_create_reply) \
5476 _(netmap_delete_reply) \
5477 _(set_ipfix_exporter_reply) \
5478 _(set_ipfix_classify_stream_reply) \
5479 _(ipfix_classify_table_add_del_reply) \
5480 _(flow_classify_set_interface_reply) \
5481 _(sw_interface_span_enable_disable_reply) \
5482 _(pg_capture_reply) \
5483 _(pg_enable_disable_reply) \
5484 _(ip_source_and_port_range_check_add_del_reply) \
5485 _(ip_source_and_port_range_check_interface_add_del_reply)\
5486 _(delete_subif_reply) \
5487 _(l2_interface_pbb_tag_rewrite_reply) \
5489 _(feature_enable_disable_reply) \
5490 _(sw_interface_tag_add_del_reply) \
5491 _(hw_interface_set_mtu_reply) \
5492 _(p2p_ethernet_add_reply) \
5493 _(p2p_ethernet_del_reply) \
5494 _(lldp_config_reply) \
5495 _(sw_interface_set_lldp_reply) \
5496 _(tcp_configure_src_addresses_reply) \
5497 _(dns_enable_disable_reply) \
5498 _(dns_name_server_add_del_reply) \
5499 _(session_rule_add_del_reply) \
5500 _(ip_container_proxy_add_del_reply) \
5501 _(output_acl_set_interface_reply) \
5502 _(qos_record_enable_disable_reply)
5505 static void vl_api_##n##_t_handler \
5506 (vl_api_##n##_t * mp) \
5508 vat_main_t * vam = &vat_main; \
5509 i32 retval = ntohl(mp->retval); \
5510 if (vam->async_mode) { \
5511 vam->async_errors += (retval < 0); \
5513 vam->retval = retval; \
5514 vam->result_ready = 1; \
5517 foreach_standard_reply_retval_handler;
5521 static void vl_api_##n##_t_handler_json \
5522 (vl_api_##n##_t * mp) \
5524 vat_main_t * vam = &vat_main; \
5525 vat_json_node_t node; \
5526 vat_json_init_object(&node); \
5527 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5528 vat_json_print(vam->ofp, &node); \
5529 vam->retval = ntohl(mp->retval); \
5530 vam->result_ready = 1; \
5532 foreach_standard_reply_retval_handler;
5536 * Table of message reply handlers, must include boilerplate handlers
5540 #define foreach_vpe_api_reply_msg \
5541 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5542 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5543 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5544 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5545 _(CONTROL_PING_REPLY, control_ping_reply) \
5546 _(CLI_REPLY, cli_reply) \
5547 _(CLI_INBAND_REPLY, cli_inband_reply) \
5548 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5549 sw_interface_add_del_address_reply) \
5550 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5551 _(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
5552 _(SW_INTERFACE_RX_PLACEMENT_DETAILS, sw_interface_rx_placement_details) \
5553 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5554 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5555 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5556 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5557 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5558 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5559 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5560 sw_interface_set_l2_xconnect_reply) \
5561 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5562 sw_interface_set_l2_bridge_reply) \
5563 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5564 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5565 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5566 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5567 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5568 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5569 _(L2_FLAGS_REPLY, l2_flags_reply) \
5570 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5571 _(TAP_CONNECT_REPLY, tap_connect_reply) \
5572 _(TAP_MODIFY_REPLY, tap_modify_reply) \
5573 _(TAP_DELETE_REPLY, tap_delete_reply) \
5574 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
5575 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5576 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5577 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5578 _(BOND_CREATE_REPLY, bond_create_reply) \
5579 _(BOND_DELETE_REPLY, bond_delete_reply) \
5580 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5581 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5582 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5583 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5584 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5585 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5586 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5587 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5588 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5589 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5590 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5591 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5592 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5593 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5594 proxy_arp_intfc_enable_disable_reply) \
5595 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5596 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5597 sw_interface_set_unnumbered_reply) \
5598 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5599 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5600 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5601 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5602 _(RESET_FIB_REPLY, reset_fib_reply) \
5603 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5604 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5605 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5606 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5607 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5608 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5609 sw_interface_ip6_enable_disable_reply) \
5610 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
5611 sw_interface_ip6_set_link_local_address_reply) \
5612 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5613 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5614 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5615 sw_interface_ip6nd_ra_prefix_reply) \
5616 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5617 sw_interface_ip6nd_ra_config_reply) \
5618 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5619 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5620 _(SR_MPLS_POLICY_ADD_REPLY, sr_mpls_policy_add_reply) \
5621 _(SR_MPLS_POLICY_MOD_REPLY, sr_mpls_policy_mod_reply) \
5622 _(SR_MPLS_POLICY_DEL_REPLY, sr_mpls_policy_del_reply) \
5623 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5624 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5625 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5626 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5627 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5628 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5629 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5630 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5631 classify_set_interface_ip_table_reply) \
5632 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5633 classify_set_interface_l2_tables_reply) \
5634 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5635 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5636 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5637 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5638 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5639 l2tpv3_interface_enable_disable_reply) \
5640 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5641 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5642 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5643 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5644 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5645 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5646 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5647 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5648 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5649 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5650 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5651 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5652 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5653 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5654 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5655 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5656 _(SHOW_VERSION_REPLY, show_version_reply) \
5657 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5658 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5659 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5660 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5661 _(IP_PROBE_NEIGHBOR_REPLY, ip_probe_neighbor_reply) \
5662 _(IP_SCAN_NEIGHBOR_ENABLE_DISABLE_REPLY, ip_scan_neighbor_enable_disable_reply) \
5663 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5664 _(IP4_ARP_EVENT, ip4_arp_event) \
5665 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5666 _(IP6_ND_EVENT, ip6_nd_event) \
5667 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5668 _(L2_MACS_EVENT, l2_macs_event) \
5669 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5670 _(IP_ADDRESS_DETAILS, ip_address_details) \
5671 _(IP_DETAILS, ip_details) \
5672 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5673 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5674 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
5675 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
5676 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5677 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5678 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5679 _(IPSEC_TUNNEL_IF_SET_KEY_REPLY, ipsec_tunnel_if_set_key_reply) \
5680 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5681 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
5682 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
5683 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
5684 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
5685 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
5686 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
5687 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
5688 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
5689 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
5690 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
5691 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
5692 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
5693 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
5694 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5695 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5696 _(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
5697 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5698 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5699 _(WANT_STATS_REPLY, want_stats_reply) \
5700 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5701 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5702 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5703 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5704 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5705 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5706 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5707 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5708 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5709 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5710 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5711 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5712 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5713 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5714 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5715 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5716 one_map_register_enable_disable_reply) \
5717 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5718 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5719 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5720 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5721 one_map_register_fallback_threshold_reply) \
5722 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5723 one_rloc_probe_enable_disable_reply) \
5724 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5725 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5726 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5727 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5728 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5729 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5730 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5731 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5732 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5733 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5734 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5735 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5736 _(ONE_STATS_DETAILS, one_stats_details) \
5737 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5738 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5739 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5740 show_one_stats_enable_disable_reply) \
5741 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5742 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5743 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5744 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5745 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5746 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5747 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5748 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5749 one_enable_disable_pitr_mode_reply) \
5750 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5751 one_enable_disable_petr_mode_reply) \
5752 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5753 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5754 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5755 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5756 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5757 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5758 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5759 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5760 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5761 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5762 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5763 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5764 gpe_add_del_native_fwd_rpath_reply) \
5765 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5766 gpe_fwd_entry_path_details) \
5767 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5768 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5769 one_add_del_map_request_itr_rlocs_reply) \
5770 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5771 one_get_map_request_itr_rlocs_reply) \
5772 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5773 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5774 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5775 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5776 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5777 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5778 show_one_map_register_state_reply) \
5779 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5780 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5781 show_one_map_register_fallback_threshold_reply) \
5782 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5783 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5784 _(AF_PACKET_DETAILS, af_packet_details) \
5785 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5786 _(POLICER_DETAILS, policer_details) \
5787 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5788 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5789 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5790 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5791 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5792 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5793 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5794 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5795 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5796 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5797 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5798 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5799 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5800 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5801 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5802 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5803 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5804 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5805 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5806 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5807 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5808 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5809 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5810 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5811 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5812 ip_source_and_port_range_check_add_del_reply) \
5813 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5814 ip_source_and_port_range_check_interface_add_del_reply) \
5815 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5816 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5817 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5818 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5819 _(PUNT_REPLY, punt_reply) \
5820 _(IP_FIB_DETAILS, ip_fib_details) \
5821 _(IP6_FIB_DETAILS, ip6_fib_details) \
5822 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5823 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5824 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5825 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5826 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5827 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5828 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5829 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5830 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5831 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5832 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5833 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5834 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5835 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5836 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
5837 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \
5838 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5839 _(SESSION_RULES_DETAILS, session_rules_details) \
5840 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5841 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5842 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply)
5844 #define foreach_standalone_reply_msg \
5845 _(SW_INTERFACE_EVENT, sw_interface_event) \
5846 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
5847 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
5848 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
5849 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
5850 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
5851 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters)
5859 #define STR_VTR_OP_CASE(op) \
5860 case L2_VTR_ ## op: \
5864 str_vtr_op (u32 vtr_op)
5868 STR_VTR_OP_CASE (DISABLED);
5869 STR_VTR_OP_CASE (PUSH_1);
5870 STR_VTR_OP_CASE (PUSH_2);
5871 STR_VTR_OP_CASE (POP_1);
5872 STR_VTR_OP_CASE (POP_2);
5873 STR_VTR_OP_CASE (TRANSLATE_1_1);
5874 STR_VTR_OP_CASE (TRANSLATE_1_2);
5875 STR_VTR_OP_CASE (TRANSLATE_2_1);
5876 STR_VTR_OP_CASE (TRANSLATE_2_2);
5883 dump_sub_interface_table (vat_main_t * vam)
5885 const sw_interface_subif_t *sub = NULL;
5887 if (vam->json_output)
5890 ("JSON output supported only for VPE API calls and dump_stats_table");
5895 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5896 "Interface", "sw_if_index",
5897 "sub id", "dot1ad", "tags", "outer id",
5898 "inner id", "exact", "default", "outer any", "inner any");
5900 vec_foreach (sub, vam->sw_if_subif_table)
5903 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5904 sub->interface_name,
5906 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5907 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5908 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5909 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5910 if (sub->vtr_op != L2_VTR_DISABLED)
5913 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5914 "tag1: %d tag2: %d ]",
5915 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5916 sub->vtr_tag1, sub->vtr_tag2);
5924 name_sort_cmp (void *a1, void *a2)
5926 name_sort_t *n1 = a1;
5927 name_sort_t *n2 = a2;
5929 return strcmp ((char *) n1->name, (char *) n2->name);
5933 dump_interface_table (vat_main_t * vam)
5936 name_sort_t *nses = 0, *ns;
5938 if (vam->json_output)
5941 ("JSON output supported only for VPE API calls and dump_stats_table");
5946 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5948 vec_add2 (nses, ns, 1);
5949 ns->name = (u8 *)(p->key);
5950 ns->value = (u32) p->value[0];
5954 vec_sort_with_function (nses, name_sort_cmp);
5956 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5957 vec_foreach (ns, nses)
5959 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5966 dump_ip_table (vat_main_t * vam, int is_ipv6)
5968 const ip_details_t *det = NULL;
5969 const ip_address_details_t *address = NULL;
5972 print (vam->ofp, "%-12s", "sw_if_index");
5974 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5981 print (vam->ofp, "%-12d", i);
5982 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5987 vec_foreach (address, det->addr)
5991 is_ipv6 ? format_ip6_address : format_ip4_address,
5992 address->ip, address->prefix_length);
6000 dump_ipv4_table (vat_main_t * vam)
6002 if (vam->json_output)
6005 ("JSON output supported only for VPE API calls and dump_stats_table");
6009 return dump_ip_table (vam, 0);
6013 dump_ipv6_table (vat_main_t * vam)
6015 if (vam->json_output)
6018 ("JSON output supported only for VPE API calls and dump_stats_table");
6022 return dump_ip_table (vam, 1);
6026 counter_type_to_str (u8 counter_type, u8 is_combined)
6030 switch (counter_type)
6032 case VNET_INTERFACE_COUNTER_DROP:
6034 case VNET_INTERFACE_COUNTER_PUNT:
6036 case VNET_INTERFACE_COUNTER_IP4:
6038 case VNET_INTERFACE_COUNTER_IP6:
6040 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
6042 case VNET_INTERFACE_COUNTER_RX_MISS:
6044 case VNET_INTERFACE_COUNTER_RX_ERROR:
6046 case VNET_INTERFACE_COUNTER_TX_ERROR:
6049 return "INVALID-COUNTER-TYPE";
6054 switch (counter_type)
6056 case VNET_INTERFACE_COUNTER_RX:
6058 case VNET_INTERFACE_COUNTER_TX:
6061 return "INVALID-COUNTER-TYPE";
6067 dump_stats_table (vat_main_t * vam)
6069 vat_json_node_t node;
6070 vat_json_node_t *msg_array;
6071 vat_json_node_t *msg;
6072 vat_json_node_t *counter_array;
6073 vat_json_node_t *counter;
6074 interface_counter_t c;
6076 ip4_fib_counter_t *c4;
6077 ip6_fib_counter_t *c6;
6078 ip4_nbr_counter_t *n4;
6079 ip6_nbr_counter_t *n6;
6082 if (!vam->json_output)
6084 clib_warning ("dump_stats_table supported only in JSON format");
6088 vat_json_init_object (&node);
6090 /* interface counters */
6091 msg_array = vat_json_object_add (&node, "interface_counters");
6092 vat_json_init_array (msg_array);
6093 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
6095 msg = vat_json_array_add (msg_array);
6096 vat_json_init_object (msg);
6097 vat_json_object_add_string_copy (msg, "vnet_counter_type",
6098 (u8 *) counter_type_to_str (i, 0));
6099 vat_json_object_add_int (msg, "is_combined", 0);
6100 counter_array = vat_json_object_add (msg, "data");
6101 vat_json_init_array (counter_array);
6102 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
6104 packets = vam->simple_interface_counters[i][j];
6105 vat_json_array_add_uint (counter_array, packets);
6108 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
6110 msg = vat_json_array_add (msg_array);
6111 vat_json_init_object (msg);
6112 vat_json_object_add_string_copy (msg, "vnet_counter_type",
6113 (u8 *) counter_type_to_str (i, 1));
6114 vat_json_object_add_int (msg, "is_combined", 1);
6115 counter_array = vat_json_object_add (msg, "data");
6116 vat_json_init_array (counter_array);
6117 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
6119 c = vam->combined_interface_counters[i][j];
6120 counter = vat_json_array_add (counter_array);
6121 vat_json_init_object (counter);
6122 vat_json_object_add_uint (counter, "packets", c.packets);
6123 vat_json_object_add_uint (counter, "bytes", c.bytes);
6127 /* ip4 fib counters */
6128 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
6129 vat_json_init_array (msg_array);
6130 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
6132 msg = vat_json_array_add (msg_array);
6133 vat_json_init_object (msg);
6134 vat_json_object_add_uint (msg, "vrf_id",
6135 vam->ip4_fib_counters_vrf_id_by_index[i]);
6136 counter_array = vat_json_object_add (msg, "c");
6137 vat_json_init_array (counter_array);
6138 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
6140 counter = vat_json_array_add (counter_array);
6141 vat_json_init_object (counter);
6142 c4 = &vam->ip4_fib_counters[i][j];
6143 vat_json_object_add_ip4 (counter, "address", c4->address);
6144 vat_json_object_add_uint (counter, "address_length",
6145 c4->address_length);
6146 vat_json_object_add_uint (counter, "packets", c4->packets);
6147 vat_json_object_add_uint (counter, "bytes", c4->bytes);
6151 /* ip6 fib counters */
6152 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
6153 vat_json_init_array (msg_array);
6154 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
6156 msg = vat_json_array_add (msg_array);
6157 vat_json_init_object (msg);
6158 vat_json_object_add_uint (msg, "vrf_id",
6159 vam->ip6_fib_counters_vrf_id_by_index[i]);
6160 counter_array = vat_json_object_add (msg, "c");
6161 vat_json_init_array (counter_array);
6162 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
6164 counter = vat_json_array_add (counter_array);
6165 vat_json_init_object (counter);
6166 c6 = &vam->ip6_fib_counters[i][j];
6167 vat_json_object_add_ip6 (counter, "address", c6->address);
6168 vat_json_object_add_uint (counter, "address_length",
6169 c6->address_length);
6170 vat_json_object_add_uint (counter, "packets", c6->packets);
6171 vat_json_object_add_uint (counter, "bytes", c6->bytes);
6175 /* ip4 nbr counters */
6176 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
6177 vat_json_init_array (msg_array);
6178 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
6180 msg = vat_json_array_add (msg_array);
6181 vat_json_init_object (msg);
6182 vat_json_object_add_uint (msg, "sw_if_index", i);
6183 counter_array = vat_json_object_add (msg, "c");
6184 vat_json_init_array (counter_array);
6185 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
6187 counter = vat_json_array_add (counter_array);
6188 vat_json_init_object (counter);
6189 n4 = &vam->ip4_nbr_counters[i][j];
6190 vat_json_object_add_ip4 (counter, "address", n4->address);
6191 vat_json_object_add_uint (counter, "link-type", n4->linkt);
6192 vat_json_object_add_uint (counter, "packets", n4->packets);
6193 vat_json_object_add_uint (counter, "bytes", n4->bytes);
6197 /* ip6 nbr counters */
6198 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
6199 vat_json_init_array (msg_array);
6200 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
6202 msg = vat_json_array_add (msg_array);
6203 vat_json_init_object (msg);
6204 vat_json_object_add_uint (msg, "sw_if_index", i);
6205 counter_array = vat_json_object_add (msg, "c");
6206 vat_json_init_array (counter_array);
6207 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
6209 counter = vat_json_array_add (counter_array);
6210 vat_json_init_object (counter);
6211 n6 = &vam->ip6_nbr_counters[i][j];
6212 vat_json_object_add_ip6 (counter, "address", n6->address);
6213 vat_json_object_add_uint (counter, "packets", n6->packets);
6214 vat_json_object_add_uint (counter, "bytes", n6->bytes);
6218 vat_json_print (vam->ofp, &node);
6219 vat_json_free (&node);
6225 * Pass CLI buffers directly in the CLI_INBAND API message,
6226 * instead of an additional shared memory area.
6229 exec_inband (vat_main_t * vam)
6231 vl_api_cli_inband_t *mp;
6232 unformat_input_t *i = vam->input;
6235 if (vec_len (i->buffer) == 0)
6238 if (vam->exec_mode == 0 && unformat (i, "mode"))
6243 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
6250 * In order for the CLI command to work, it
6251 * must be a vector ending in \n, not a C-string ending
6254 u32 len = vec_len (vam->input->buffer);
6255 M2 (CLI_INBAND, mp, len);
6256 clib_memcpy (mp->cmd, vam->input->buffer, len);
6257 mp->length = htonl (len);
6261 /* json responses may or may not include a useful reply... */
6262 if (vec_len (vam->cmd_reply))
6263 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
6268 exec (vat_main_t * vam)
6270 return exec_inband (vam);
6274 api_create_loopback (vat_main_t * vam)
6276 unformat_input_t *i = vam->input;
6277 vl_api_create_loopback_t *mp;
6278 vl_api_create_loopback_instance_t *mp_lbi;
6281 u8 is_specified = 0;
6282 u32 user_instance = 0;
6285 memset (mac_address, 0, sizeof (mac_address));
6287 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6289 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6291 if (unformat (i, "instance %d", &user_instance))
6299 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
6300 mp_lbi->is_specified = is_specified;
6302 mp_lbi->user_instance = htonl (user_instance);
6304 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
6309 /* Construct the API message */
6310 M (CREATE_LOOPBACK, mp);
6312 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
6321 api_delete_loopback (vat_main_t * vam)
6323 unformat_input_t *i = vam->input;
6324 vl_api_delete_loopback_t *mp;
6325 u32 sw_if_index = ~0;
6328 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6330 if (unformat (i, "sw_if_index %d", &sw_if_index))
6336 if (sw_if_index == ~0)
6338 errmsg ("missing sw_if_index");
6342 /* Construct the API message */
6343 M (DELETE_LOOPBACK, mp);
6344 mp->sw_if_index = ntohl (sw_if_index);
6352 api_want_stats (vat_main_t * vam)
6354 unformat_input_t *i = vam->input;
6355 vl_api_want_stats_t *mp;
6359 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6361 if (unformat (i, "enable"))
6363 else if (unformat (i, "disable"))
6371 errmsg ("missing enable|disable");
6376 mp->enable_disable = enable;
6384 api_want_interface_events (vat_main_t * vam)
6386 unformat_input_t *i = vam->input;
6387 vl_api_want_interface_events_t *mp;
6391 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6393 if (unformat (i, "enable"))
6395 else if (unformat (i, "disable"))
6403 errmsg ("missing enable|disable");
6407 M (WANT_INTERFACE_EVENTS, mp);
6408 mp->enable_disable = enable;
6410 vam->interface_event_display = enable;
6418 /* Note: non-static, called once to set up the initial intfc table */
6420 api_sw_interface_dump (vat_main_t * vam)
6422 vl_api_sw_interface_dump_t *mp;
6423 vl_api_control_ping_t *mp_ping;
6425 name_sort_t *nses = 0, *ns;
6426 sw_interface_subif_t *sub = NULL;
6429 /* Toss the old name table */
6431 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6433 vec_add2 (nses, ns, 1);
6434 ns->name = (u8 *)(p->key);
6435 ns->value = (u32) p->value[0];
6439 hash_free (vam->sw_if_index_by_interface_name);
6441 vec_foreach (ns, nses) vec_free (ns->name);
6445 vec_foreach (sub, vam->sw_if_subif_table)
6447 vec_free (sub->interface_name);
6449 vec_free (vam->sw_if_subif_table);
6451 /* recreate the interface name hash table */
6452 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
6455 * Ask for all interface names. Otherwise, the epic catalog of
6456 * name filters becomes ridiculously long, and vat ends up needing
6457 * to be taught about new interface types.
6459 M (SW_INTERFACE_DUMP, mp);
6462 /* Use a control ping for synchronization */
6463 MPING (CONTROL_PING, mp_ping);
6471 api_sw_interface_set_flags (vat_main_t * vam)
6473 unformat_input_t *i = vam->input;
6474 vl_api_sw_interface_set_flags_t *mp;
6476 u8 sw_if_index_set = 0;
6480 /* Parse args required to build the message */
6481 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6483 if (unformat (i, "admin-up"))
6485 else if (unformat (i, "admin-down"))
6488 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6489 sw_if_index_set = 1;
6490 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6491 sw_if_index_set = 1;
6496 if (sw_if_index_set == 0)
6498 errmsg ("missing interface name or sw_if_index");
6502 /* Construct the API message */
6503 M (SW_INTERFACE_SET_FLAGS, mp);
6504 mp->sw_if_index = ntohl (sw_if_index);
6505 mp->admin_up_down = admin_up;
6510 /* Wait for a reply, return the good/bad news... */
6516 api_sw_interface_set_rx_mode (vat_main_t * vam)
6518 unformat_input_t *i = vam->input;
6519 vl_api_sw_interface_set_rx_mode_t *mp;
6521 u8 sw_if_index_set = 0;
6523 u8 queue_id_valid = 0;
6525 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
6527 /* Parse args required to build the message */
6528 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6530 if (unformat (i, "queue %d", &queue_id))
6532 else if (unformat (i, "polling"))
6533 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
6534 else if (unformat (i, "interrupt"))
6535 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
6536 else if (unformat (i, "adaptive"))
6537 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
6539 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6540 sw_if_index_set = 1;
6541 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6542 sw_if_index_set = 1;
6547 if (sw_if_index_set == 0)
6549 errmsg ("missing interface name or sw_if_index");
6552 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6554 errmsg ("missing rx-mode");
6558 /* Construct the API message */
6559 M (SW_INTERFACE_SET_RX_MODE, mp);
6560 mp->sw_if_index = ntohl (sw_if_index);
6562 mp->queue_id_valid = queue_id_valid;
6563 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6568 /* Wait for a reply, return the good/bad news... */
6574 api_sw_interface_set_rx_placement (vat_main_t * vam)
6576 unformat_input_t *i = vam->input;
6577 vl_api_sw_interface_set_rx_placement_t *mp;
6579 u8 sw_if_index_set = 0;
6582 u32 queue_id, thread_index;
6584 /* Parse args required to build the message */
6585 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6587 if (unformat (i, "queue %d", &queue_id))
6589 else if (unformat (i, "main"))
6591 else if (unformat (i, "worker %d", &thread_index))
6594 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6595 sw_if_index_set = 1;
6596 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6597 sw_if_index_set = 1;
6602 if (sw_if_index_set == 0)
6604 errmsg ("missing interface name or sw_if_index");
6610 /* Construct the API message */
6611 M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
6612 mp->sw_if_index = ntohl (sw_if_index);
6613 mp->worker_id = ntohl (thread_index);
6614 mp->queue_id = ntohl (queue_id);
6615 mp->is_main = is_main;
6619 /* Wait for a reply, return the good/bad news... */
6624 static void vl_api_sw_interface_rx_placement_details_t_handler
6625 (vl_api_sw_interface_rx_placement_details_t * mp)
6627 vat_main_t *vam = &vat_main;
6628 u32 worker_id = ntohl (mp->worker_id);
6631 "\n%-11d %-11s %-6d %-5d %-9s",
6632 ntohl (mp->sw_if_index), (worker_id == 0) ? "main" : "worker",
6633 worker_id, ntohl (mp->queue_id),
6635 1) ? "polling" : ((mp->mode == 2) ? "interrupt" : "adaptive"));
6638 static void vl_api_sw_interface_rx_placement_details_t_handler_json
6639 (vl_api_sw_interface_rx_placement_details_t * mp)
6641 vat_main_t *vam = &vat_main;
6642 vat_json_node_t *node = NULL;
6644 if (VAT_JSON_ARRAY != vam->json_tree.type)
6646 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
6647 vat_json_init_array (&vam->json_tree);
6649 node = vat_json_array_add (&vam->json_tree);
6651 vat_json_init_object (node);
6652 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
6653 vat_json_object_add_uint (node, "worker_id", ntohl (mp->worker_id));
6654 vat_json_object_add_uint (node, "queue_id", ntohl (mp->queue_id));
6655 vat_json_object_add_uint (node, "mode", mp->mode);
6659 api_sw_interface_rx_placement_dump (vat_main_t * vam)
6661 unformat_input_t *i = vam->input;
6662 vl_api_sw_interface_rx_placement_dump_t *mp;
6663 vl_api_control_ping_t *mp_ping;
6666 u8 sw_if_index_set = 0;
6668 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6670 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6672 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6679 "\n%-11s %-11s %-6s %-5s %-4s",
6680 "sw_if_index", "main/worker", "thread", "queue", "mode");
6682 /* Dump Interface rx placement */
6683 M (SW_INTERFACE_RX_PLACEMENT_DUMP, mp);
6685 if (sw_if_index_set)
6686 mp->sw_if_index = htonl (sw_if_index);
6688 mp->sw_if_index = ~0;
6692 /* Use a control ping for synchronization */
6693 MPING (CONTROL_PING, mp_ping);
6701 api_sw_interface_clear_stats (vat_main_t * vam)
6703 unformat_input_t *i = vam->input;
6704 vl_api_sw_interface_clear_stats_t *mp;
6706 u8 sw_if_index_set = 0;
6709 /* Parse args required to build the message */
6710 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6712 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6713 sw_if_index_set = 1;
6714 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6715 sw_if_index_set = 1;
6720 /* Construct the API message */
6721 M (SW_INTERFACE_CLEAR_STATS, mp);
6723 if (sw_if_index_set == 1)
6724 mp->sw_if_index = ntohl (sw_if_index);
6726 mp->sw_if_index = ~0;
6731 /* Wait for a reply, return the good/bad news... */
6737 api_sw_interface_add_del_address (vat_main_t * vam)
6739 unformat_input_t *i = vam->input;
6740 vl_api_sw_interface_add_del_address_t *mp;
6742 u8 sw_if_index_set = 0;
6743 u8 is_add = 1, del_all = 0;
6744 u32 address_length = 0;
6745 u8 v4_address_set = 0;
6746 u8 v6_address_set = 0;
6747 ip4_address_t v4address;
6748 ip6_address_t v6address;
6751 /* Parse args required to build the message */
6752 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6754 if (unformat (i, "del-all"))
6756 else if (unformat (i, "del"))
6759 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6760 sw_if_index_set = 1;
6761 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6762 sw_if_index_set = 1;
6763 else if (unformat (i, "%U/%d",
6764 unformat_ip4_address, &v4address, &address_length))
6766 else if (unformat (i, "%U/%d",
6767 unformat_ip6_address, &v6address, &address_length))
6773 if (sw_if_index_set == 0)
6775 errmsg ("missing interface name or sw_if_index");
6778 if (v4_address_set && v6_address_set)
6780 errmsg ("both v4 and v6 addresses set");
6783 if (!v4_address_set && !v6_address_set && !del_all)
6785 errmsg ("no addresses set");
6789 /* Construct the API message */
6790 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6792 mp->sw_if_index = ntohl (sw_if_index);
6793 mp->is_add = is_add;
6794 mp->del_all = del_all;
6798 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6802 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6804 mp->address_length = address_length;
6809 /* Wait for a reply, return good/bad news */
6815 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6817 unformat_input_t *i = vam->input;
6818 vl_api_sw_interface_set_mpls_enable_t *mp;
6820 u8 sw_if_index_set = 0;
6824 /* Parse args required to build the message */
6825 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6827 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6828 sw_if_index_set = 1;
6829 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6830 sw_if_index_set = 1;
6831 else if (unformat (i, "disable"))
6833 else if (unformat (i, "dis"))
6839 if (sw_if_index_set == 0)
6841 errmsg ("missing interface name or sw_if_index");
6845 /* Construct the API message */
6846 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6848 mp->sw_if_index = ntohl (sw_if_index);
6849 mp->enable = enable;
6854 /* Wait for a reply... */
6860 api_sw_interface_set_table (vat_main_t * vam)
6862 unformat_input_t *i = vam->input;
6863 vl_api_sw_interface_set_table_t *mp;
6864 u32 sw_if_index, vrf_id = 0;
6865 u8 sw_if_index_set = 0;
6869 /* Parse args required to build the message */
6870 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6872 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6873 sw_if_index_set = 1;
6874 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6875 sw_if_index_set = 1;
6876 else if (unformat (i, "vrf %d", &vrf_id))
6878 else if (unformat (i, "ipv6"))
6884 if (sw_if_index_set == 0)
6886 errmsg ("missing interface name or sw_if_index");
6890 /* Construct the API message */
6891 M (SW_INTERFACE_SET_TABLE, mp);
6893 mp->sw_if_index = ntohl (sw_if_index);
6894 mp->is_ipv6 = is_ipv6;
6895 mp->vrf_id = ntohl (vrf_id);
6900 /* Wait for a reply... */
6905 static void vl_api_sw_interface_get_table_reply_t_handler
6906 (vl_api_sw_interface_get_table_reply_t * mp)
6908 vat_main_t *vam = &vat_main;
6910 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6912 vam->retval = ntohl (mp->retval);
6913 vam->result_ready = 1;
6917 static void vl_api_sw_interface_get_table_reply_t_handler_json
6918 (vl_api_sw_interface_get_table_reply_t * mp)
6920 vat_main_t *vam = &vat_main;
6921 vat_json_node_t node;
6923 vat_json_init_object (&node);
6924 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6925 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6927 vat_json_print (vam->ofp, &node);
6928 vat_json_free (&node);
6930 vam->retval = ntohl (mp->retval);
6931 vam->result_ready = 1;
6935 api_sw_interface_get_table (vat_main_t * vam)
6937 unformat_input_t *i = vam->input;
6938 vl_api_sw_interface_get_table_t *mp;
6940 u8 sw_if_index_set = 0;
6944 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6946 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6947 sw_if_index_set = 1;
6948 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6949 sw_if_index_set = 1;
6950 else if (unformat (i, "ipv6"))
6956 if (sw_if_index_set == 0)
6958 errmsg ("missing interface name or sw_if_index");
6962 M (SW_INTERFACE_GET_TABLE, mp);
6963 mp->sw_if_index = htonl (sw_if_index);
6964 mp->is_ipv6 = is_ipv6;
6972 api_sw_interface_set_vpath (vat_main_t * vam)
6974 unformat_input_t *i = vam->input;
6975 vl_api_sw_interface_set_vpath_t *mp;
6976 u32 sw_if_index = 0;
6977 u8 sw_if_index_set = 0;
6981 /* Parse args required to build the message */
6982 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6984 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6985 sw_if_index_set = 1;
6986 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6987 sw_if_index_set = 1;
6988 else if (unformat (i, "enable"))
6990 else if (unformat (i, "disable"))
6996 if (sw_if_index_set == 0)
6998 errmsg ("missing interface name or sw_if_index");
7002 /* Construct the API message */
7003 M (SW_INTERFACE_SET_VPATH, mp);
7005 mp->sw_if_index = ntohl (sw_if_index);
7006 mp->enable = is_enable;
7011 /* Wait for a reply... */
7017 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
7019 unformat_input_t *i = vam->input;
7020 vl_api_sw_interface_set_vxlan_bypass_t *mp;
7021 u32 sw_if_index = 0;
7022 u8 sw_if_index_set = 0;
7027 /* Parse args required to build the message */
7028 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7030 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7031 sw_if_index_set = 1;
7032 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7033 sw_if_index_set = 1;
7034 else if (unformat (i, "enable"))
7036 else if (unformat (i, "disable"))
7038 else if (unformat (i, "ip4"))
7040 else if (unformat (i, "ip6"))
7046 if (sw_if_index_set == 0)
7048 errmsg ("missing interface name or sw_if_index");
7052 /* Construct the API message */
7053 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
7055 mp->sw_if_index = ntohl (sw_if_index);
7056 mp->enable = is_enable;
7057 mp->is_ipv6 = is_ipv6;
7062 /* Wait for a reply... */
7068 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
7070 unformat_input_t *i = vam->input;
7071 vl_api_sw_interface_set_geneve_bypass_t *mp;
7072 u32 sw_if_index = 0;
7073 u8 sw_if_index_set = 0;
7078 /* Parse args required to build the message */
7079 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7081 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7082 sw_if_index_set = 1;
7083 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7084 sw_if_index_set = 1;
7085 else if (unformat (i, "enable"))
7087 else if (unformat (i, "disable"))
7089 else if (unformat (i, "ip4"))
7091 else if (unformat (i, "ip6"))
7097 if (sw_if_index_set == 0)
7099 errmsg ("missing interface name or sw_if_index");
7103 /* Construct the API message */
7104 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
7106 mp->sw_if_index = ntohl (sw_if_index);
7107 mp->enable = is_enable;
7108 mp->is_ipv6 = is_ipv6;
7113 /* Wait for a reply... */
7119 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
7121 unformat_input_t *i = vam->input;
7122 vl_api_sw_interface_set_l2_xconnect_t *mp;
7124 u8 rx_sw_if_index_set = 0;
7126 u8 tx_sw_if_index_set = 0;
7130 /* Parse args required to build the message */
7131 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7133 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
7134 rx_sw_if_index_set = 1;
7135 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
7136 tx_sw_if_index_set = 1;
7137 else if (unformat (i, "rx"))
7139 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7141 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7143 rx_sw_if_index_set = 1;
7148 else if (unformat (i, "tx"))
7150 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7152 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7154 tx_sw_if_index_set = 1;
7159 else if (unformat (i, "enable"))
7161 else if (unformat (i, "disable"))
7167 if (rx_sw_if_index_set == 0)
7169 errmsg ("missing rx interface name or rx_sw_if_index");
7173 if (enable && (tx_sw_if_index_set == 0))
7175 errmsg ("missing tx interface name or tx_sw_if_index");
7179 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
7181 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7182 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
7183 mp->enable = enable;
7191 api_sw_interface_set_l2_bridge (vat_main_t * vam)
7193 unformat_input_t *i = vam->input;
7194 vl_api_sw_interface_set_l2_bridge_t *mp;
7195 vl_api_l2_port_type_t port_type;
7197 u8 rx_sw_if_index_set = 0;
7204 port_type = L2_API_PORT_TYPE_NORMAL;
7206 /* Parse args required to build the message */
7207 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7209 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
7210 rx_sw_if_index_set = 1;
7211 else if (unformat (i, "bd_id %d", &bd_id))
7215 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
7216 rx_sw_if_index_set = 1;
7217 else if (unformat (i, "shg %d", &shg))
7219 else if (unformat (i, "bvi"))
7220 port_type = L2_API_PORT_TYPE_BVI;
7221 else if (unformat (i, "uu-fwd"))
7222 port_type = L2_API_PORT_TYPE_UU_FWD;
7223 else if (unformat (i, "enable"))
7225 else if (unformat (i, "disable"))
7231 if (rx_sw_if_index_set == 0)
7233 errmsg ("missing rx interface name or sw_if_index");
7237 if (enable && (bd_id_set == 0))
7239 errmsg ("missing bridge domain");
7243 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
7245 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7246 mp->bd_id = ntohl (bd_id);
7248 mp->port_type = ntohl (port_type);
7249 mp->enable = enable;
7257 api_bridge_domain_dump (vat_main_t * vam)
7259 unformat_input_t *i = vam->input;
7260 vl_api_bridge_domain_dump_t *mp;
7261 vl_api_control_ping_t *mp_ping;
7265 /* Parse args required to build the message */
7266 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7268 if (unformat (i, "bd_id %d", &bd_id))
7274 M (BRIDGE_DOMAIN_DUMP, mp);
7275 mp->bd_id = ntohl (bd_id);
7278 /* Use a control ping for synchronization */
7279 MPING (CONTROL_PING, mp_ping);
7287 api_bridge_domain_add_del (vat_main_t * vam)
7289 unformat_input_t *i = vam->input;
7290 vl_api_bridge_domain_add_del_t *mp;
7293 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
7298 /* Parse args required to build the message */
7299 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7301 if (unformat (i, "bd_id %d", &bd_id))
7303 else if (unformat (i, "flood %d", &flood))
7305 else if (unformat (i, "uu-flood %d", &uu_flood))
7307 else if (unformat (i, "forward %d", &forward))
7309 else if (unformat (i, "learn %d", &learn))
7311 else if (unformat (i, "arp-term %d", &arp_term))
7313 else if (unformat (i, "mac-age %d", &mac_age))
7315 else if (unformat (i, "bd-tag %s", &bd_tag))
7317 else if (unformat (i, "del"))
7320 flood = uu_flood = forward = learn = 0;
7328 errmsg ("missing bridge domain");
7335 errmsg ("mac age must be less than 256 ");
7340 if ((bd_tag) && (vec_len (bd_tag) > 63))
7342 errmsg ("bd-tag cannot be longer than 63");
7347 M (BRIDGE_DOMAIN_ADD_DEL, mp);
7349 mp->bd_id = ntohl (bd_id);
7351 mp->uu_flood = uu_flood;
7352 mp->forward = forward;
7354 mp->arp_term = arp_term;
7355 mp->is_add = is_add;
7356 mp->mac_age = (u8) mac_age;
7359 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
7360 mp->bd_tag[vec_len (bd_tag)] = 0;
7371 api_l2fib_flush_bd (vat_main_t * vam)
7373 unformat_input_t *i = vam->input;
7374 vl_api_l2fib_flush_bd_t *mp;
7378 /* Parse args required to build the message */
7379 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7381 if (unformat (i, "bd_id %d", &bd_id));
7388 errmsg ("missing bridge domain");
7392 M (L2FIB_FLUSH_BD, mp);
7394 mp->bd_id = htonl (bd_id);
7402 api_l2fib_flush_int (vat_main_t * vam)
7404 unformat_input_t *i = vam->input;
7405 vl_api_l2fib_flush_int_t *mp;
7406 u32 sw_if_index = ~0;
7409 /* Parse args required to build the message */
7410 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7412 if (unformat (i, "sw_if_index %d", &sw_if_index));
7414 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
7419 if (sw_if_index == ~0)
7421 errmsg ("missing interface name or sw_if_index");
7425 M (L2FIB_FLUSH_INT, mp);
7427 mp->sw_if_index = ntohl (sw_if_index);
7435 api_l2fib_add_del (vat_main_t * vam)
7437 unformat_input_t *i = vam->input;
7438 vl_api_l2fib_add_del_t *mp;
7444 u32 sw_if_index = 0;
7445 u8 sw_if_index_set = 0;
7454 /* Parse args required to build the message */
7455 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7457 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
7459 else if (unformat (i, "bd_id %d", &bd_id))
7461 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7462 sw_if_index_set = 1;
7463 else if (unformat (i, "sw_if"))
7465 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7468 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7469 sw_if_index_set = 1;
7474 else if (unformat (i, "static"))
7476 else if (unformat (i, "filter"))
7481 else if (unformat (i, "bvi"))
7486 else if (unformat (i, "del"))
7488 else if (unformat (i, "count %d", &count))
7496 errmsg ("missing mac address");
7502 errmsg ("missing bridge domain");
7506 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7508 errmsg ("missing interface name or sw_if_index");
7514 /* Turn on async mode */
7515 vam->async_mode = 1;
7516 vam->async_errors = 0;
7517 before = vat_time_now (vam);
7520 for (j = 0; j < count; j++)
7522 M (L2FIB_ADD_DEL, mp);
7524 clib_memcpy (mp->mac, mac, 6);
7525 mp->bd_id = ntohl (bd_id);
7526 mp->is_add = is_add;
7527 mp->sw_if_index = ntohl (sw_if_index);
7531 mp->static_mac = static_mac;
7532 mp->filter_mac = filter_mac;
7533 mp->bvi_mac = bvi_mac;
7535 increment_mac_address (mac);
7542 vl_api_control_ping_t *mp_ping;
7545 /* Shut off async mode */
7546 vam->async_mode = 0;
7548 MPING (CONTROL_PING, mp_ping);
7551 timeout = vat_time_now (vam) + 1.0;
7552 while (vat_time_now (vam) < timeout)
7553 if (vam->result_ready == 1)
7558 if (vam->retval == -99)
7561 if (vam->async_errors > 0)
7563 errmsg ("%d asynchronous errors", vam->async_errors);
7566 vam->async_errors = 0;
7567 after = vat_time_now (vam);
7569 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7570 count, after - before, count / (after - before));
7576 /* Wait for a reply... */
7580 /* Return the good/bad news */
7581 return (vam->retval);
7585 api_bridge_domain_set_mac_age (vat_main_t * vam)
7587 unformat_input_t *i = vam->input;
7588 vl_api_bridge_domain_set_mac_age_t *mp;
7593 /* Parse args required to build the message */
7594 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7596 if (unformat (i, "bd_id %d", &bd_id));
7597 else if (unformat (i, "mac-age %d", &mac_age));
7604 errmsg ("missing bridge domain");
7610 errmsg ("mac age must be less than 256 ");
7614 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7616 mp->bd_id = htonl (bd_id);
7617 mp->mac_age = (u8) mac_age;
7625 api_l2_flags (vat_main_t * vam)
7627 unformat_input_t *i = vam->input;
7628 vl_api_l2_flags_t *mp;
7631 u8 sw_if_index_set = 0;
7635 /* Parse args required to build the message */
7636 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7638 if (unformat (i, "sw_if_index %d", &sw_if_index))
7639 sw_if_index_set = 1;
7640 else if (unformat (i, "sw_if"))
7642 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7645 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7646 sw_if_index_set = 1;
7651 else if (unformat (i, "learn"))
7653 else if (unformat (i, "forward"))
7655 else if (unformat (i, "flood"))
7657 else if (unformat (i, "uu-flood"))
7658 flags |= L2_UU_FLOOD;
7659 else if (unformat (i, "arp-term"))
7660 flags |= L2_ARP_TERM;
7661 else if (unformat (i, "off"))
7663 else if (unformat (i, "disable"))
7669 if (sw_if_index_set == 0)
7671 errmsg ("missing interface name or sw_if_index");
7677 mp->sw_if_index = ntohl (sw_if_index);
7678 mp->feature_bitmap = ntohl (flags);
7679 mp->is_set = is_set;
7687 api_bridge_flags (vat_main_t * vam)
7689 unformat_input_t *i = vam->input;
7690 vl_api_bridge_flags_t *mp;
7694 bd_flags_t flags = 0;
7697 /* Parse args required to build the message */
7698 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7700 if (unformat (i, "bd_id %d", &bd_id))
7702 else if (unformat (i, "learn"))
7703 flags |= BRIDGE_API_FLAG_LEARN;
7704 else if (unformat (i, "forward"))
7705 flags |= BRIDGE_API_FLAG_FWD;
7706 else if (unformat (i, "flood"))
7707 flags |= BRIDGE_API_FLAG_FLOOD;
7708 else if (unformat (i, "uu-flood"))
7709 flags |= BRIDGE_API_FLAG_UU_FLOOD;
7710 else if (unformat (i, "arp-term"))
7711 flags |= BRIDGE_API_FLAG_ARP_TERM;
7712 else if (unformat (i, "off"))
7714 else if (unformat (i, "disable"))
7722 errmsg ("missing bridge domain");
7726 M (BRIDGE_FLAGS, mp);
7728 mp->bd_id = ntohl (bd_id);
7729 mp->flags = ntohl (flags);
7730 mp->is_set = is_set;
7738 api_bd_ip_mac_add_del (vat_main_t * vam)
7740 unformat_input_t *i = vam->input;
7741 vl_api_bd_ip_mac_add_del_t *mp;
7748 ip4_address_t v4addr;
7749 ip6_address_t v6addr;
7754 /* Parse args required to build the message */
7755 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7757 if (unformat (i, "bd_id %d", &bd_id))
7761 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
7765 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
7770 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
7774 else if (unformat (i, "del"))
7782 errmsg ("missing bridge domain");
7785 else if (ip_set == 0)
7787 errmsg ("missing IP address");
7790 else if (mac_set == 0)
7792 errmsg ("missing MAC address");
7796 M (BD_IP_MAC_ADD_DEL, mp);
7798 mp->bd_id = ntohl (bd_id);
7799 mp->is_ipv6 = is_ipv6;
7800 mp->is_add = is_add;
7802 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
7804 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
7805 clib_memcpy (mp->mac_address, macaddr, 6);
7811 static void vl_api_bd_ip_mac_details_t_handler
7812 (vl_api_bd_ip_mac_details_t * mp)
7814 vat_main_t *vam = &vat_main;
7819 format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
7822 format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
7825 "\n%-5d %-7s %-20U %-30s",
7826 ntohl (mp->bd_id), mp->is_ipv6 ? "ip6" : "ip4",
7827 format_ethernet_address, mp->mac_address, ip);
7832 static void vl_api_bd_ip_mac_details_t_handler_json
7833 (vl_api_bd_ip_mac_details_t * mp)
7835 vat_main_t *vam = &vat_main;
7836 vat_json_node_t *node = NULL;
7838 if (VAT_JSON_ARRAY != vam->json_tree.type)
7840 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7841 vat_json_init_array (&vam->json_tree);
7843 node = vat_json_array_add (&vam->json_tree);
7845 vat_json_init_object (node);
7846 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
7847 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
7848 vat_json_object_add_string_copy (node, "mac_address",
7849 format (0, "%U", format_ethernet_address,
7855 format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
7858 format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
7859 vat_json_object_add_string_copy (node, "ip_address", ip);
7864 api_bd_ip_mac_dump (vat_main_t * vam)
7866 unformat_input_t *i = vam->input;
7867 vl_api_bd_ip_mac_dump_t *mp;
7868 vl_api_control_ping_t *mp_ping;
7873 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7875 if (unformat (i, "bd_id %d", &bd_id))
7884 "\n%-5s %-7s %-20s %-30s",
7885 "bd_id", "is_ipv6", "mac_address", "ip_address");
7887 /* Dump Bridge Domain Ip to Mac entries */
7888 M (BD_IP_MAC_DUMP, mp);
7891 mp->bd_id = htonl (bd_id);
7897 /* Use a control ping for synchronization */
7898 MPING (CONTROL_PING, mp_ping);
7906 api_tap_connect (vat_main_t * vam)
7908 unformat_input_t *i = vam->input;
7909 vl_api_tap_connect_t *mp;
7915 ip4_address_t ip4_address;
7917 int ip4_address_set = 0;
7918 ip6_address_t ip6_address;
7920 int ip6_address_set = 0;
7923 memset (mac_address, 0, sizeof (mac_address));
7925 /* Parse args required to build the message */
7926 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7928 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7932 else if (unformat (i, "random-mac"))
7934 else if (unformat (i, "tapname %s", &tap_name))
7936 else if (unformat (i, "tag %s", &tag))
7938 else if (unformat (i, "address %U/%d",
7939 unformat_ip4_address, &ip4_address, &ip4_mask_width))
7940 ip4_address_set = 1;
7941 else if (unformat (i, "address %U/%d",
7942 unformat_ip6_address, &ip6_address, &ip6_mask_width))
7943 ip6_address_set = 1;
7950 errmsg ("missing tap name");
7953 if (vec_len (tap_name) > 63)
7955 errmsg ("tap name too long");
7958 vec_add1 (tap_name, 0);
7960 if (vec_len (tag) > 63)
7962 errmsg ("tag too long");
7966 /* Construct the API message */
7967 M (TAP_CONNECT, mp);
7969 mp->use_random_mac = random_mac;
7970 clib_memcpy (mp->mac_address, mac_address, 6);
7971 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7973 clib_memcpy (mp->tag, tag, vec_len (tag));
7975 if (ip4_address_set)
7977 mp->ip4_address_set = 1;
7978 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
7979 mp->ip4_mask_width = ip4_mask_width;
7981 if (ip6_address_set)
7983 mp->ip6_address_set = 1;
7984 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
7985 mp->ip6_mask_width = ip6_mask_width;
7988 vec_free (tap_name);
7994 /* Wait for a reply... */
8000 api_tap_modify (vat_main_t * vam)
8002 unformat_input_t *i = vam->input;
8003 vl_api_tap_modify_t *mp;
8008 u32 sw_if_index = ~0;
8009 u8 sw_if_index_set = 0;
8012 memset (mac_address, 0, sizeof (mac_address));
8014 /* Parse args required to build the message */
8015 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8017 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8018 sw_if_index_set = 1;
8019 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8020 sw_if_index_set = 1;
8021 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
8025 else if (unformat (i, "random-mac"))
8027 else if (unformat (i, "tapname %s", &tap_name))
8033 if (sw_if_index_set == 0)
8035 errmsg ("missing vpp interface name");
8040 errmsg ("missing tap name");
8043 if (vec_len (tap_name) > 63)
8045 errmsg ("tap name too long");
8047 vec_add1 (tap_name, 0);
8049 /* Construct the API message */
8052 mp->use_random_mac = random_mac;
8053 mp->sw_if_index = ntohl (sw_if_index);
8054 clib_memcpy (mp->mac_address, mac_address, 6);
8055 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
8056 vec_free (tap_name);
8061 /* Wait for a reply... */
8067 api_tap_delete (vat_main_t * vam)
8069 unformat_input_t *i = vam->input;
8070 vl_api_tap_delete_t *mp;
8071 u32 sw_if_index = ~0;
8072 u8 sw_if_index_set = 0;
8075 /* Parse args required to build the message */
8076 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8078 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8079 sw_if_index_set = 1;
8080 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8081 sw_if_index_set = 1;
8086 if (sw_if_index_set == 0)
8088 errmsg ("missing vpp interface name");
8092 /* Construct the API message */
8095 mp->sw_if_index = ntohl (sw_if_index);
8100 /* Wait for a reply... */
8106 api_tap_create_v2 (vat_main_t * vam)
8108 unformat_input_t *i = vam->input;
8109 vl_api_tap_create_v2_t *mp;
8113 u8 *host_if_name = 0;
8115 u8 host_mac_addr[6];
8116 u8 host_mac_addr_set = 0;
8117 u8 *host_bridge = 0;
8118 ip4_address_t host_ip4_addr;
8119 ip4_address_t host_ip4_gw;
8120 u8 host_ip4_gw_set = 0;
8121 u32 host_ip4_prefix_len = 0;
8122 ip6_address_t host_ip6_addr;
8123 ip6_address_t host_ip6_gw;
8124 u8 host_ip6_gw_set = 0;
8125 u32 host_ip6_prefix_len = 0;
8127 u32 rx_ring_sz = 0, tx_ring_sz = 0;
8129 memset (mac_address, 0, sizeof (mac_address));
8131 /* Parse args required to build the message */
8132 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8134 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
8138 else if (unformat (i, "id %u", &id))
8140 else if (unformat (i, "host-if-name %s", &host_if_name))
8142 else if (unformat (i, "host-ns %s", &host_ns))
8144 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
8146 host_mac_addr_set = 1;
8147 else if (unformat (i, "host-bridge %s", &host_bridge))
8149 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
8150 &host_ip4_addr, &host_ip4_prefix_len))
8152 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
8153 &host_ip6_addr, &host_ip6_prefix_len))
8155 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
8157 host_ip4_gw_set = 1;
8158 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
8160 host_ip6_gw_set = 1;
8161 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
8163 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
8169 if (vec_len (host_if_name) > 63)
8171 errmsg ("tap name too long. ");
8174 if (vec_len (host_ns) > 63)
8176 errmsg ("host name space too long. ");
8179 if (vec_len (host_bridge) > 63)
8181 errmsg ("host bridge name too long. ");
8184 if (host_ip4_prefix_len > 32)
8186 errmsg ("host ip4 prefix length not valid. ");
8189 if (host_ip6_prefix_len > 128)
8191 errmsg ("host ip6 prefix length not valid. ");
8194 if (!is_pow2 (rx_ring_sz))
8196 errmsg ("rx ring size must be power of 2. ");
8199 if (rx_ring_sz > 32768)
8201 errmsg ("rx ring size must be 32768 or lower. ");
8204 if (!is_pow2 (tx_ring_sz))
8206 errmsg ("tx ring size must be power of 2. ");
8209 if (tx_ring_sz > 32768)
8211 errmsg ("tx ring size must be 32768 or lower. ");
8215 /* Construct the API message */
8216 M (TAP_CREATE_V2, mp);
8218 mp->use_random_mac = random_mac;
8220 mp->id = ntohl (id);
8221 mp->host_namespace_set = host_ns != 0;
8222 mp->host_bridge_set = host_bridge != 0;
8223 mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
8224 mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
8225 mp->rx_ring_sz = ntohs (rx_ring_sz);
8226 mp->tx_ring_sz = ntohs (tx_ring_sz);
8228 if (random_mac == 0)
8229 clib_memcpy (mp->mac_address, mac_address, 6);
8230 if (host_mac_addr_set)
8231 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
8233 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
8235 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
8237 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
8238 if (host_ip4_prefix_len)
8239 clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
8240 if (host_ip4_prefix_len)
8241 clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
8242 if (host_ip4_gw_set)
8243 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
8244 if (host_ip6_gw_set)
8245 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
8248 vec_free (host_if_name);
8249 vec_free (host_bridge);
8254 /* Wait for a reply... */
8260 api_tap_delete_v2 (vat_main_t * vam)
8262 unformat_input_t *i = vam->input;
8263 vl_api_tap_delete_v2_t *mp;
8264 u32 sw_if_index = ~0;
8265 u8 sw_if_index_set = 0;
8268 /* Parse args required to build the message */
8269 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8271 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8272 sw_if_index_set = 1;
8273 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8274 sw_if_index_set = 1;
8279 if (sw_if_index_set == 0)
8281 errmsg ("missing vpp interface name. ");
8285 /* Construct the API message */
8286 M (TAP_DELETE_V2, mp);
8288 mp->sw_if_index = ntohl (sw_if_index);
8293 /* Wait for a reply... */
8299 api_bond_create (vat_main_t * vam)
8301 unformat_input_t *i = vam->input;
8302 vl_api_bond_create_t *mp;
8310 memset (mac_address, 0, sizeof (mac_address));
8313 /* Parse args required to build the message */
8314 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8316 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
8318 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
8319 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
8321 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
8328 if (mode_is_set == 0)
8330 errmsg ("Missing bond mode. ");
8334 /* Construct the API message */
8335 M (BOND_CREATE, mp);
8337 mp->use_custom_mac = custom_mac;
8343 clib_memcpy (mp->mac_address, mac_address, 6);
8348 /* Wait for a reply... */
8354 api_bond_delete (vat_main_t * vam)
8356 unformat_input_t *i = vam->input;
8357 vl_api_bond_delete_t *mp;
8358 u32 sw_if_index = ~0;
8359 u8 sw_if_index_set = 0;
8362 /* Parse args required to build the message */
8363 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8365 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8366 sw_if_index_set = 1;
8367 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8368 sw_if_index_set = 1;
8373 if (sw_if_index_set == 0)
8375 errmsg ("missing vpp interface name. ");
8379 /* Construct the API message */
8380 M (BOND_DELETE, mp);
8382 mp->sw_if_index = ntohl (sw_if_index);
8387 /* Wait for a reply... */
8393 api_bond_enslave (vat_main_t * vam)
8395 unformat_input_t *i = vam->input;
8396 vl_api_bond_enslave_t *mp;
8397 u32 bond_sw_if_index;
8401 u32 bond_sw_if_index_is_set = 0;
8403 u8 sw_if_index_is_set = 0;
8405 /* Parse args required to build the message */
8406 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8408 if (unformat (i, "sw_if_index %d", &sw_if_index))
8409 sw_if_index_is_set = 1;
8410 else if (unformat (i, "bond %u", &bond_sw_if_index))
8411 bond_sw_if_index_is_set = 1;
8412 else if (unformat (i, "passive %d", &is_passive))
8414 else if (unformat (i, "long-timeout %d", &is_long_timeout))
8420 if (bond_sw_if_index_is_set == 0)
8422 errmsg ("Missing bond sw_if_index. ");
8425 if (sw_if_index_is_set == 0)
8427 errmsg ("Missing slave sw_if_index. ");
8431 /* Construct the API message */
8432 M (BOND_ENSLAVE, mp);
8434 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
8435 mp->sw_if_index = ntohl (sw_if_index);
8436 mp->is_long_timeout = is_long_timeout;
8437 mp->is_passive = is_passive;
8442 /* Wait for a reply... */
8448 api_bond_detach_slave (vat_main_t * vam)
8450 unformat_input_t *i = vam->input;
8451 vl_api_bond_detach_slave_t *mp;
8452 u32 sw_if_index = ~0;
8453 u8 sw_if_index_set = 0;
8456 /* Parse args required to build the message */
8457 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8459 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8460 sw_if_index_set = 1;
8461 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8462 sw_if_index_set = 1;
8467 if (sw_if_index_set == 0)
8469 errmsg ("missing vpp interface name. ");
8473 /* Construct the API message */
8474 M (BOND_DETACH_SLAVE, mp);
8476 mp->sw_if_index = ntohl (sw_if_index);
8481 /* Wait for a reply... */
8487 api_ip_table_add_del (vat_main_t * vam)
8489 unformat_input_t *i = vam->input;
8490 vl_api_ip_table_add_del_t *mp;
8496 /* Parse args required to build the message */
8497 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8499 if (unformat (i, "ipv6"))
8501 else if (unformat (i, "del"))
8503 else if (unformat (i, "add"))
8505 else if (unformat (i, "table %d", &table_id))
8509 clib_warning ("parse error '%U'", format_unformat_error, i);
8516 errmsg ("missing table-ID");
8520 /* Construct the API message */
8521 M (IP_TABLE_ADD_DEL, mp);
8523 mp->table_id = ntohl (table_id);
8524 mp->is_ipv6 = is_ipv6;
8525 mp->is_add = is_add;
8530 /* Wait for a reply... */
8537 api_ip_add_del_route (vat_main_t * vam)
8539 unformat_input_t *i = vam->input;
8540 vl_api_ip_add_del_route_t *mp;
8541 u32 sw_if_index = ~0, vrf_id = 0;
8543 u8 is_local = 0, is_drop = 0;
8544 u8 is_unreach = 0, is_prohibit = 0;
8546 u32 next_hop_weight = 1;
8547 u8 is_multipath = 0;
8549 u8 address_length_set = 0;
8550 u32 next_hop_table_id = 0;
8551 u32 resolve_attempts = 0;
8552 u32 dst_address_length = 0;
8553 u8 next_hop_set = 0;
8554 ip4_address_t v4_dst_address, v4_next_hop_address;
8555 ip6_address_t v6_dst_address, v6_next_hop_address;
8559 u32 random_add_del = 0;
8560 u32 *random_vector = 0;
8562 u32 random_seed = 0xdeaddabe;
8563 u32 classify_table_index = ~0;
8565 u8 resolve_host = 0, resolve_attached = 0;
8566 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
8567 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8568 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8570 memset (&v4_next_hop_address, 0, sizeof (ip4_address_t));
8571 memset (&v6_next_hop_address, 0, sizeof (ip6_address_t));
8572 /* Parse args required to build the message */
8573 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8575 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8577 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8579 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
8584 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
8589 else if (unformat (i, "/%d", &dst_address_length))
8591 address_length_set = 1;
8594 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
8595 &v4_next_hop_address))
8599 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
8600 &v6_next_hop_address))
8606 (i, "via %U", api_unformat_sw_if_index, vam, &sw_if_index))
8610 else if (unformat (i, "via sw_if_index %d", &sw_if_index))
8614 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
8616 else if (unformat (i, "weight %d", &next_hop_weight))
8618 else if (unformat (i, "drop"))
8622 else if (unformat (i, "null-send-unreach"))
8626 else if (unformat (i, "null-send-prohibit"))
8630 else if (unformat (i, "local"))
8634 else if (unformat (i, "classify %d", &classify_table_index))
8638 else if (unformat (i, "del"))
8640 else if (unformat (i, "add"))
8642 else if (unformat (i, "resolve-via-host"))
8644 else if (unformat (i, "resolve-via-attached"))
8645 resolve_attached = 1;
8646 else if (unformat (i, "multipath"))
8648 else if (unformat (i, "vrf %d", &vrf_id))
8650 else if (unformat (i, "count %d", &count))
8652 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
8654 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8656 else if (unformat (i, "out-label %d", &next_hop_out_label))
8658 vl_api_fib_mpls_label_t fib_label = {
8659 .label = ntohl (next_hop_out_label),
8663 vec_add1 (next_hop_out_label_stack, fib_label);
8665 else if (unformat (i, "via via-label %d", &next_hop_via_label))
8667 else if (unformat (i, "random"))
8669 else if (unformat (i, "seed %d", &random_seed))
8673 clib_warning ("parse error '%U'", format_unformat_error, i);
8678 if (!next_hop_set && !is_drop && !is_local &&
8679 !is_classify && !is_unreach && !is_prohibit &&
8680 MPLS_LABEL_INVALID == next_hop_via_label)
8683 ("next hop / local / drop / unreach / prohibit / classify not set");
8687 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
8689 errmsg ("next hop and next-hop via label set");
8692 if (address_set == 0)
8694 errmsg ("missing addresses");
8698 if (address_length_set == 0)
8700 errmsg ("missing address length");
8704 /* Generate a pile of unique, random routes */
8707 u32 this_random_address;
8708 random_hash = hash_create (count, sizeof (uword));
8710 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
8711 for (j = 0; j <= count; j++)
8715 this_random_address = random_u32 (&random_seed);
8716 this_random_address =
8717 clib_host_to_net_u32 (this_random_address);
8719 while (hash_get (random_hash, this_random_address));
8720 vec_add1 (random_vector, this_random_address);
8721 hash_set (random_hash, this_random_address, 1);
8723 hash_free (random_hash);
8724 v4_dst_address.as_u32 = random_vector[0];
8729 /* Turn on async mode */
8730 vam->async_mode = 1;
8731 vam->async_errors = 0;
8732 before = vat_time_now (vam);
8735 for (j = 0; j < count; j++)
8737 /* Construct the API message */
8738 M2 (IP_ADD_DEL_ROUTE, mp, sizeof (vl_api_fib_mpls_label_t) *
8739 vec_len (next_hop_out_label_stack));
8741 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8742 mp->table_id = ntohl (vrf_id);
8744 mp->is_add = is_add;
8745 mp->is_drop = is_drop;
8746 mp->is_unreach = is_unreach;
8747 mp->is_prohibit = is_prohibit;
8748 mp->is_ipv6 = is_ipv6;
8749 mp->is_local = is_local;
8750 mp->is_classify = is_classify;
8751 mp->is_multipath = is_multipath;
8752 mp->is_resolve_host = resolve_host;
8753 mp->is_resolve_attached = resolve_attached;
8754 mp->next_hop_weight = next_hop_weight;
8755 mp->dst_address_length = dst_address_length;
8756 mp->next_hop_table_id = ntohl (next_hop_table_id);
8757 mp->classify_table_index = ntohl (classify_table_index);
8758 mp->next_hop_via_label = ntohl (next_hop_via_label);
8759 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8760 if (0 != mp->next_hop_n_out_labels)
8762 memcpy (mp->next_hop_out_label_stack,
8763 next_hop_out_label_stack,
8764 (vec_len (next_hop_out_label_stack) *
8765 sizeof (vl_api_fib_mpls_label_t)));
8766 vec_free (next_hop_out_label_stack);
8771 clib_memcpy (mp->dst_address, &v6_dst_address,
8772 sizeof (v6_dst_address));
8774 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
8775 sizeof (v6_next_hop_address));
8776 increment_v6_address (&v6_dst_address);
8780 clib_memcpy (mp->dst_address, &v4_dst_address,
8781 sizeof (v4_dst_address));
8783 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
8784 sizeof (v4_next_hop_address));
8786 v4_dst_address.as_u32 = random_vector[j + 1];
8788 increment_v4_address (&v4_dst_address);
8792 /* If we receive SIGTERM, stop now... */
8797 /* When testing multiple add/del ops, use a control-ping to sync */
8800 vl_api_control_ping_t *mp_ping;
8804 /* Shut off async mode */
8805 vam->async_mode = 0;
8807 MPING (CONTROL_PING, mp_ping);
8810 timeout = vat_time_now (vam) + 1.0;
8811 while (vat_time_now (vam) < timeout)
8812 if (vam->result_ready == 1)
8817 if (vam->retval == -99)
8820 if (vam->async_errors > 0)
8822 errmsg ("%d asynchronous errors", vam->async_errors);
8825 vam->async_errors = 0;
8826 after = vat_time_now (vam);
8828 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8832 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8833 count, after - before, count / (after - before));
8839 /* Wait for a reply... */
8844 /* Return the good/bad news */
8845 return (vam->retval);
8849 api_ip_mroute_add_del (vat_main_t * vam)
8851 unformat_input_t *i = vam->input;
8852 vl_api_ip_mroute_add_del_t *mp;
8853 u32 sw_if_index = ~0, vrf_id = 0;
8858 u32 grp_address_length = 0;
8859 ip4_address_t v4_grp_address, v4_src_address;
8860 ip6_address_t v6_grp_address, v6_src_address;
8861 mfib_itf_flags_t iflags = 0;
8862 mfib_entry_flags_t eflags = 0;
8865 /* Parse args required to build the message */
8866 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8868 if (unformat (i, "sw_if_index %d", &sw_if_index))
8870 else if (unformat (i, "%U %U",
8871 unformat_ip4_address, &v4_src_address,
8872 unformat_ip4_address, &v4_grp_address))
8874 grp_address_length = 64;
8878 else if (unformat (i, "%U %U",
8879 unformat_ip6_address, &v6_src_address,
8880 unformat_ip6_address, &v6_grp_address))
8882 grp_address_length = 256;
8886 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
8888 memset (&v4_src_address, 0, sizeof (v4_src_address));
8889 grp_address_length = 32;
8893 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
8895 memset (&v6_src_address, 0, sizeof (v6_src_address));
8896 grp_address_length = 128;
8900 else if (unformat (i, "/%d", &grp_address_length))
8902 else if (unformat (i, "local"))
8906 else if (unformat (i, "del"))
8908 else if (unformat (i, "add"))
8910 else if (unformat (i, "vrf %d", &vrf_id))
8912 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
8914 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8918 clib_warning ("parse error '%U'", format_unformat_error, i);
8923 if (address_set == 0)
8925 errmsg ("missing addresses\n");
8929 /* Construct the API message */
8930 M (IP_MROUTE_ADD_DEL, mp);
8932 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8933 mp->table_id = ntohl (vrf_id);
8935 mp->is_add = is_add;
8936 mp->is_ipv6 = is_ipv6;
8937 mp->is_local = is_local;
8938 mp->itf_flags = ntohl (iflags);
8939 mp->entry_flags = ntohl (eflags);
8940 mp->grp_address_length = grp_address_length;
8941 mp->grp_address_length = ntohs (mp->grp_address_length);
8945 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
8946 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
8950 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
8951 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
8957 /* Wait for a reply... */
8963 api_mpls_table_add_del (vat_main_t * vam)
8965 unformat_input_t *i = vam->input;
8966 vl_api_mpls_table_add_del_t *mp;
8971 /* Parse args required to build the message */
8972 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8974 if (unformat (i, "table %d", &table_id))
8976 else if (unformat (i, "del"))
8978 else if (unformat (i, "add"))
8982 clib_warning ("parse error '%U'", format_unformat_error, i);
8989 errmsg ("missing table-ID");
8993 /* Construct the API message */
8994 M (MPLS_TABLE_ADD_DEL, mp);
8996 mp->mt_table_id = ntohl (table_id);
8997 mp->mt_is_add = is_add;
9002 /* Wait for a reply... */
9009 api_mpls_route_add_del (vat_main_t * vam)
9011 unformat_input_t *i = vam->input;
9012 vl_api_mpls_route_add_del_t *mp;
9013 u32 sw_if_index = ~0, table_id = 0;
9015 u32 next_hop_weight = 1;
9016 u8 is_multipath = 0;
9017 u32 next_hop_table_id = 0;
9018 u8 next_hop_set = 0;
9019 ip4_address_t v4_next_hop_address = {
9022 ip6_address_t v6_next_hop_address = { {0} };
9026 u32 classify_table_index = ~0;
9028 u8 resolve_host = 0, resolve_attached = 0;
9029 u8 is_interface_rx = 0;
9030 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
9031 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9032 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
9033 mpls_label_t local_label = MPLS_LABEL_INVALID;
9035 dpo_proto_t next_hop_proto = DPO_PROTO_MPLS;
9037 /* Parse args required to build the message */
9038 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9040 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9042 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9044 else if (unformat (i, "%d", &local_label))
9046 else if (unformat (i, "eos"))
9048 else if (unformat (i, "non-eos"))
9050 else if (unformat (i, "via %U", unformat_ip4_address,
9051 &v4_next_hop_address))
9054 next_hop_proto = DPO_PROTO_IP4;
9056 else if (unformat (i, "via %U", unformat_ip6_address,
9057 &v6_next_hop_address))
9060 next_hop_proto = DPO_PROTO_IP6;
9062 else if (unformat (i, "weight %d", &next_hop_weight))
9064 else if (unformat (i, "classify %d", &classify_table_index))
9068 else if (unformat (i, "del"))
9070 else if (unformat (i, "add"))
9072 else if (unformat (i, "resolve-via-host"))
9074 else if (unformat (i, "resolve-via-attached"))
9075 resolve_attached = 1;
9076 else if (unformat (i, "multipath"))
9078 else if (unformat (i, "count %d", &count))
9080 else if (unformat (i, "via lookup-in-ip4-table %d", &next_hop_table_id))
9083 next_hop_proto = DPO_PROTO_IP4;
9085 else if (unformat (i, "via lookup-in-ip6-table %d", &next_hop_table_id))
9088 next_hop_proto = DPO_PROTO_IP6;
9092 (i, "via l2-input-on %U", api_unformat_sw_if_index, vam,
9096 next_hop_proto = DPO_PROTO_ETHERNET;
9097 is_interface_rx = 1;
9099 else if (unformat (i, "via l2-input-on sw_if_index %d", &sw_if_index))
9102 next_hop_proto = DPO_PROTO_ETHERNET;
9103 is_interface_rx = 1;
9105 else if (unformat (i, "via next-hop-table %d", &next_hop_table_id))
9107 else if (unformat (i, "via via-label %d", &next_hop_via_label))
9109 else if (unformat (i, "out-label %d", &next_hop_out_label))
9111 vl_api_fib_mpls_label_t fib_label = {
9112 .label = ntohl (next_hop_out_label),
9116 vec_add1 (next_hop_out_label_stack, fib_label);
9120 clib_warning ("parse error '%U'", format_unformat_error, i);
9125 if (!next_hop_set && !is_classify)
9127 errmsg ("next hop / classify not set");
9131 if (MPLS_LABEL_INVALID == local_label)
9133 errmsg ("missing label");
9139 /* Turn on async mode */
9140 vam->async_mode = 1;
9141 vam->async_errors = 0;
9142 before = vat_time_now (vam);
9145 for (j = 0; j < count; j++)
9147 /* Construct the API message */
9148 M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_mpls_label_t) *
9149 vec_len (next_hop_out_label_stack));
9151 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
9152 mp->mr_table_id = ntohl (table_id);
9154 mp->mr_is_add = is_add;
9155 mp->mr_next_hop_proto = next_hop_proto;
9156 mp->mr_is_classify = is_classify;
9157 mp->mr_is_multipath = is_multipath;
9158 mp->mr_is_resolve_host = resolve_host;
9159 mp->mr_is_resolve_attached = resolve_attached;
9160 mp->mr_is_interface_rx = is_interface_rx;
9161 mp->mr_next_hop_weight = next_hop_weight;
9162 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
9163 mp->mr_classify_table_index = ntohl (classify_table_index);
9164 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
9165 mp->mr_label = ntohl (local_label);
9166 mp->mr_eos = is_eos;
9168 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
9169 if (0 != mp->mr_next_hop_n_out_labels)
9171 memcpy (mp->mr_next_hop_out_label_stack,
9172 next_hop_out_label_stack,
9173 vec_len (next_hop_out_label_stack) *
9174 sizeof (vl_api_fib_mpls_label_t));
9175 vec_free (next_hop_out_label_stack);
9180 if (DPO_PROTO_IP4 == next_hop_proto)
9182 clib_memcpy (mp->mr_next_hop,
9183 &v4_next_hop_address,
9184 sizeof (v4_next_hop_address));
9186 else if (DPO_PROTO_IP6 == next_hop_proto)
9189 clib_memcpy (mp->mr_next_hop,
9190 &v6_next_hop_address,
9191 sizeof (v6_next_hop_address));
9198 /* If we receive SIGTERM, stop now... */
9203 /* When testing multiple add/del ops, use a control-ping to sync */
9206 vl_api_control_ping_t *mp_ping;
9210 /* Shut off async mode */
9211 vam->async_mode = 0;
9213 MPING (CONTROL_PING, mp_ping);
9216 timeout = vat_time_now (vam) + 1.0;
9217 while (vat_time_now (vam) < timeout)
9218 if (vam->result_ready == 1)
9223 if (vam->retval == -99)
9226 if (vam->async_errors > 0)
9228 errmsg ("%d asynchronous errors", vam->async_errors);
9231 vam->async_errors = 0;
9232 after = vat_time_now (vam);
9234 /* slim chance, but we might have eaten SIGTERM on the first iteration */
9238 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
9239 count, after - before, count / (after - before));
9245 /* Wait for a reply... */
9250 /* Return the good/bad news */
9251 return (vam->retval);
9255 api_mpls_ip_bind_unbind (vat_main_t * vam)
9257 unformat_input_t *i = vam->input;
9258 vl_api_mpls_ip_bind_unbind_t *mp;
9259 u32 ip_table_id = 0;
9262 ip4_address_t v4_address;
9263 ip6_address_t v6_address;
9266 mpls_label_t local_label = MPLS_LABEL_INVALID;
9269 /* Parse args required to build the message */
9270 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9272 if (unformat (i, "%U/%d", unformat_ip4_address,
9273 &v4_address, &address_length))
9278 else if (unformat (i, "%U/%d", unformat_ip6_address,
9279 &v6_address, &address_length))
9284 else if (unformat (i, "%d", &local_label))
9286 else if (unformat (i, "table-id %d", &ip_table_id))
9288 else if (unformat (i, "unbind"))
9290 else if (unformat (i, "bind"))
9294 clib_warning ("parse error '%U'", format_unformat_error, i);
9301 errmsg ("IP addres not set");
9305 if (MPLS_LABEL_INVALID == local_label)
9307 errmsg ("missing label");
9311 /* Construct the API message */
9312 M (MPLS_IP_BIND_UNBIND, mp);
9314 mp->mb_is_bind = is_bind;
9315 mp->mb_is_ip4 = is_ip4;
9316 mp->mb_ip_table_id = ntohl (ip_table_id);
9317 mp->mb_mpls_table_id = 0;
9318 mp->mb_label = ntohl (local_label);
9319 mp->mb_address_length = address_length;
9322 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
9324 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
9329 /* Wait for a reply... */
9335 api_sr_mpls_policy_add (vat_main_t * vam)
9337 unformat_input_t *i = vam->input;
9338 vl_api_sr_mpls_policy_add_t *mp;
9344 u32 *segments = NULL;
9347 /* Parse args required to build the message */
9348 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9350 if (unformat (i, "bsid %d", &bsid))
9352 else if (unformat (i, "weight %d", &weight))
9354 else if (unformat (i, "spray"))
9356 else if (unformat (i, "next %d", &sid))
9359 vec_add1 (segments, htonl (sid));
9363 clib_warning ("parse error '%U'", format_unformat_error, i);
9370 errmsg ("bsid not set");
9374 if (n_segments == 0)
9376 errmsg ("no sid in segment stack");
9380 /* Construct the API message */
9381 M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
9383 mp->bsid = htonl (bsid);
9384 mp->weight = htonl (weight);
9386 mp->n_segments = n_segments;
9387 memcpy (mp->segments, segments, sizeof (u32) * n_segments);
9388 vec_free (segments);
9393 /* Wait for a reply... */
9399 api_sr_mpls_policy_del (vat_main_t * vam)
9401 unformat_input_t *i = vam->input;
9402 vl_api_sr_mpls_policy_del_t *mp;
9406 /* Parse args required to build the message */
9407 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9409 if (unformat (i, "bsid %d", &bsid))
9413 clib_warning ("parse error '%U'", format_unformat_error, i);
9420 errmsg ("bsid not set");
9424 /* Construct the API message */
9425 M (SR_MPLS_POLICY_DEL, mp);
9427 mp->bsid = htonl (bsid);
9432 /* Wait for a reply... */
9438 api_bier_table_add_del (vat_main_t * vam)
9440 unformat_input_t *i = vam->input;
9441 vl_api_bier_table_add_del_t *mp;
9443 u32 set = 0, sub_domain = 0, hdr_len = 3;
9444 mpls_label_t local_label = MPLS_LABEL_INVALID;
9447 /* Parse args required to build the message */
9448 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9450 if (unformat (i, "sub-domain %d", &sub_domain))
9452 else if (unformat (i, "set %d", &set))
9454 else if (unformat (i, "label %d", &local_label))
9456 else if (unformat (i, "hdr-len %d", &hdr_len))
9458 else if (unformat (i, "add"))
9460 else if (unformat (i, "del"))
9464 clib_warning ("parse error '%U'", format_unformat_error, i);
9469 if (MPLS_LABEL_INVALID == local_label)
9471 errmsg ("missing label\n");
9475 /* Construct the API message */
9476 M (BIER_TABLE_ADD_DEL, mp);
9478 mp->bt_is_add = is_add;
9479 mp->bt_label = ntohl (local_label);
9480 mp->bt_tbl_id.bt_set = set;
9481 mp->bt_tbl_id.bt_sub_domain = sub_domain;
9482 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
9487 /* Wait for a reply... */
9494 api_bier_route_add_del (vat_main_t * vam)
9496 unformat_input_t *i = vam->input;
9497 vl_api_bier_route_add_del_t *mp;
9499 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
9500 ip4_address_t v4_next_hop_address;
9501 ip6_address_t v6_next_hop_address;
9502 u8 next_hop_set = 0;
9503 u8 next_hop_proto_is_ip4 = 1;
9504 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9507 /* Parse args required to build the message */
9508 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9510 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
9512 next_hop_proto_is_ip4 = 1;
9515 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
9517 next_hop_proto_is_ip4 = 0;
9520 if (unformat (i, "sub-domain %d", &sub_domain))
9522 else if (unformat (i, "set %d", &set))
9524 else if (unformat (i, "hdr-len %d", &hdr_len))
9526 else if (unformat (i, "bp %d", &bp))
9528 else if (unformat (i, "add"))
9530 else if (unformat (i, "del"))
9532 else if (unformat (i, "out-label %d", &next_hop_out_label))
9536 clib_warning ("parse error '%U'", format_unformat_error, i);
9541 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
9543 errmsg ("next hop / label set\n");
9548 errmsg ("bit=position not set\n");
9552 /* Construct the API message */
9553 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
9555 mp->br_is_add = is_add;
9556 mp->br_tbl_id.bt_set = set;
9557 mp->br_tbl_id.bt_sub_domain = sub_domain;
9558 mp->br_tbl_id.bt_hdr_len_id = hdr_len;
9559 mp->br_bp = ntohs (bp);
9561 mp->br_paths[0].n_labels = 1;
9562 mp->br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
9563 mp->br_paths[0].afi = (next_hop_proto_is_ip4 ? 0 : 1);
9565 if (next_hop_proto_is_ip4)
9567 clib_memcpy (mp->br_paths[0].next_hop,
9568 &v4_next_hop_address, sizeof (v4_next_hop_address));
9572 clib_memcpy (mp->br_paths[0].next_hop,
9573 &v6_next_hop_address, sizeof (v6_next_hop_address));
9579 /* Wait for a reply... */
9586 api_proxy_arp_add_del (vat_main_t * vam)
9588 unformat_input_t *i = vam->input;
9589 vl_api_proxy_arp_add_del_t *mp;
9592 ip4_address_t lo, hi;
9596 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9598 if (unformat (i, "vrf %d", &vrf_id))
9600 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
9601 unformat_ip4_address, &hi))
9603 else if (unformat (i, "del"))
9607 clib_warning ("parse error '%U'", format_unformat_error, i);
9614 errmsg ("address range not set");
9618 M (PROXY_ARP_ADD_DEL, mp);
9620 mp->proxy.vrf_id = ntohl (vrf_id);
9621 mp->is_add = is_add;
9622 clib_memcpy (mp->proxy.low_address, &lo, sizeof (mp->proxy.low_address));
9623 clib_memcpy (mp->proxy.hi_address, &hi, sizeof (mp->proxy.hi_address));
9631 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
9633 unformat_input_t *i = vam->input;
9634 vl_api_proxy_arp_intfc_enable_disable_t *mp;
9637 u8 sw_if_index_set = 0;
9640 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9642 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9643 sw_if_index_set = 1;
9644 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9645 sw_if_index_set = 1;
9646 else if (unformat (i, "enable"))
9648 else if (unformat (i, "disable"))
9652 clib_warning ("parse error '%U'", format_unformat_error, i);
9657 if (sw_if_index_set == 0)
9659 errmsg ("missing interface name or sw_if_index");
9663 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
9665 mp->sw_if_index = ntohl (sw_if_index);
9666 mp->enable_disable = enable;
9674 api_mpls_tunnel_add_del (vat_main_t * vam)
9676 unformat_input_t *i = vam->input;
9677 vl_api_mpls_tunnel_add_del_t *mp;
9681 u32 sw_if_index = ~0;
9682 u32 next_hop_sw_if_index = ~0;
9683 u32 next_hop_proto_is_ip4 = 1;
9685 u32 next_hop_table_id = 0;
9686 ip4_address_t v4_next_hop_address = {
9689 ip6_address_t v6_next_hop_address = { {0} };
9690 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
9691 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
9694 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9696 if (unformat (i, "add"))
9698 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
9700 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
9702 else if (unformat (i, "via %U",
9703 unformat_ip4_address, &v4_next_hop_address))
9705 next_hop_proto_is_ip4 = 1;
9707 else if (unformat (i, "via %U",
9708 unformat_ip6_address, &v6_next_hop_address))
9710 next_hop_proto_is_ip4 = 0;
9712 else if (unformat (i, "via-label %d", &next_hop_via_label))
9714 else if (unformat (i, "l2-only"))
9716 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
9718 else if (unformat (i, "out-label %d", &next_hop_out_label))
9719 vec_add1 (labels, ntohl (next_hop_out_label));
9722 clib_warning ("parse error '%U'", format_unformat_error, i);
9727 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
9729 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
9730 mp->mt_sw_if_index = ntohl (sw_if_index);
9731 mp->mt_is_add = is_add;
9732 mp->mt_l2_only = l2_only;
9733 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
9734 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
9735 mp->mt_next_hop_via_label = ntohl (next_hop_via_label);
9737 mp->mt_next_hop_n_out_labels = vec_len (labels);
9739 if (0 != mp->mt_next_hop_n_out_labels)
9741 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
9742 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
9746 if (next_hop_proto_is_ip4)
9748 clib_memcpy (mp->mt_next_hop,
9749 &v4_next_hop_address, sizeof (v4_next_hop_address));
9753 clib_memcpy (mp->mt_next_hop,
9754 &v6_next_hop_address, sizeof (v6_next_hop_address));
9763 api_sw_interface_set_unnumbered (vat_main_t * vam)
9765 unformat_input_t *i = vam->input;
9766 vl_api_sw_interface_set_unnumbered_t *mp;
9768 u32 unnum_sw_index = ~0;
9770 u8 sw_if_index_set = 0;
9773 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9775 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9776 sw_if_index_set = 1;
9777 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9778 sw_if_index_set = 1;
9779 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
9781 else if (unformat (i, "del"))
9785 clib_warning ("parse error '%U'", format_unformat_error, i);
9790 if (sw_if_index_set == 0)
9792 errmsg ("missing interface name or sw_if_index");
9796 M (SW_INTERFACE_SET_UNNUMBERED, mp);
9798 mp->sw_if_index = ntohl (sw_if_index);
9799 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
9800 mp->is_add = is_add;
9808 api_ip_neighbor_add_del (vat_main_t * vam)
9810 unformat_input_t *i = vam->input;
9811 vl_api_ip_neighbor_add_del_t *mp;
9813 u8 sw_if_index_set = 0;
9816 u8 is_no_fib_entry = 0;
9819 u8 v4_address_set = 0;
9820 u8 v6_address_set = 0;
9821 ip4_address_t v4address;
9822 ip6_address_t v6address;
9825 memset (mac_address, 0, sizeof (mac_address));
9827 /* Parse args required to build the message */
9828 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9830 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
9834 else if (unformat (i, "del"))
9837 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9838 sw_if_index_set = 1;
9839 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9840 sw_if_index_set = 1;
9841 else if (unformat (i, "is_static"))
9843 else if (unformat (i, "no-fib-entry"))
9844 is_no_fib_entry = 1;
9845 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
9847 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
9851 clib_warning ("parse error '%U'", format_unformat_error, i);
9856 if (sw_if_index_set == 0)
9858 errmsg ("missing interface name or sw_if_index");
9861 if (v4_address_set && v6_address_set)
9863 errmsg ("both v4 and v6 addresses set");
9866 if (!v4_address_set && !v6_address_set)
9868 errmsg ("no address set");
9872 /* Construct the API message */
9873 M (IP_NEIGHBOR_ADD_DEL, mp);
9875 mp->sw_if_index = ntohl (sw_if_index);
9876 mp->is_add = is_add;
9877 mp->is_static = is_static;
9878 mp->is_no_adj_fib = is_no_fib_entry;
9880 clib_memcpy (mp->mac_address, mac_address, 6);
9884 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
9888 /* mp->is_ipv6 = 0; via memset in M macro above */
9889 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
9895 /* Wait for a reply, return good/bad news */
9901 api_create_vlan_subif (vat_main_t * vam)
9903 unformat_input_t *i = vam->input;
9904 vl_api_create_vlan_subif_t *mp;
9906 u8 sw_if_index_set = 0;
9911 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9913 if (unformat (i, "sw_if_index %d", &sw_if_index))
9914 sw_if_index_set = 1;
9916 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9917 sw_if_index_set = 1;
9918 else if (unformat (i, "vlan %d", &vlan_id))
9922 clib_warning ("parse error '%U'", format_unformat_error, i);
9927 if (sw_if_index_set == 0)
9929 errmsg ("missing interface name or sw_if_index");
9933 if (vlan_id_set == 0)
9935 errmsg ("missing vlan_id");
9938 M (CREATE_VLAN_SUBIF, mp);
9940 mp->sw_if_index = ntohl (sw_if_index);
9941 mp->vlan_id = ntohl (vlan_id);
9948 #define foreach_create_subif_bit \
9955 _(outer_vlan_id_any) \
9956 _(inner_vlan_id_any)
9959 api_create_subif (vat_main_t * vam)
9961 unformat_input_t *i = vam->input;
9962 vl_api_create_subif_t *mp;
9964 u8 sw_if_index_set = 0;
9971 u32 exact_match = 0;
9972 u32 default_sub = 0;
9973 u32 outer_vlan_id_any = 0;
9974 u32 inner_vlan_id_any = 0;
9976 u16 outer_vlan_id = 0;
9977 u16 inner_vlan_id = 0;
9980 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9982 if (unformat (i, "sw_if_index %d", &sw_if_index))
9983 sw_if_index_set = 1;
9985 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9986 sw_if_index_set = 1;
9987 else if (unformat (i, "sub_id %d", &sub_id))
9989 else if (unformat (i, "outer_vlan_id %d", &tmp))
9990 outer_vlan_id = tmp;
9991 else if (unformat (i, "inner_vlan_id %d", &tmp))
9992 inner_vlan_id = tmp;
9994 #define _(a) else if (unformat (i, #a)) a = 1 ;
9995 foreach_create_subif_bit
9999 clib_warning ("parse error '%U'", format_unformat_error, i);
10004 if (sw_if_index_set == 0)
10006 errmsg ("missing interface name or sw_if_index");
10010 if (sub_id_set == 0)
10012 errmsg ("missing sub_id");
10015 M (CREATE_SUBIF, mp);
10017 mp->sw_if_index = ntohl (sw_if_index);
10018 mp->sub_id = ntohl (sub_id);
10020 #define _(a) mp->a = a;
10021 foreach_create_subif_bit;
10024 mp->outer_vlan_id = ntohs (outer_vlan_id);
10025 mp->inner_vlan_id = ntohs (inner_vlan_id);
10033 api_oam_add_del (vat_main_t * vam)
10035 unformat_input_t *i = vam->input;
10036 vl_api_oam_add_del_t *mp;
10039 ip4_address_t src, dst;
10044 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10046 if (unformat (i, "vrf %d", &vrf_id))
10048 else if (unformat (i, "src %U", unformat_ip4_address, &src))
10050 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
10052 else if (unformat (i, "del"))
10056 clib_warning ("parse error '%U'", format_unformat_error, i);
10063 errmsg ("missing src addr");
10069 errmsg ("missing dst addr");
10073 M (OAM_ADD_DEL, mp);
10075 mp->vrf_id = ntohl (vrf_id);
10076 mp->is_add = is_add;
10077 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
10078 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
10086 api_reset_fib (vat_main_t * vam)
10088 unformat_input_t *i = vam->input;
10089 vl_api_reset_fib_t *mp;
10095 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10097 if (unformat (i, "vrf %d", &vrf_id))
10099 else if (unformat (i, "ipv6"))
10103 clib_warning ("parse error '%U'", format_unformat_error, i);
10108 if (vrf_id_set == 0)
10110 errmsg ("missing vrf id");
10116 mp->vrf_id = ntohl (vrf_id);
10117 mp->is_ipv6 = is_ipv6;
10125 api_dhcp_proxy_config (vat_main_t * vam)
10127 unformat_input_t *i = vam->input;
10128 vl_api_dhcp_proxy_config_t *mp;
10130 u32 server_vrf_id = 0;
10132 u8 v4_address_set = 0;
10133 u8 v6_address_set = 0;
10134 ip4_address_t v4address;
10135 ip6_address_t v6address;
10136 u8 v4_src_address_set = 0;
10137 u8 v6_src_address_set = 0;
10138 ip4_address_t v4srcaddress;
10139 ip6_address_t v6srcaddress;
10142 /* Parse args required to build the message */
10143 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10145 if (unformat (i, "del"))
10147 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
10149 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
10151 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
10152 v4_address_set = 1;
10153 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
10154 v6_address_set = 1;
10155 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
10156 v4_src_address_set = 1;
10157 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
10158 v6_src_address_set = 1;
10163 if (v4_address_set && v6_address_set)
10165 errmsg ("both v4 and v6 server addresses set");
10168 if (!v4_address_set && !v6_address_set)
10170 errmsg ("no server addresses set");
10174 if (v4_src_address_set && v6_src_address_set)
10176 errmsg ("both v4 and v6 src addresses set");
10179 if (!v4_src_address_set && !v6_src_address_set)
10181 errmsg ("no src addresses set");
10185 if (!(v4_src_address_set && v4_address_set) &&
10186 !(v6_src_address_set && v6_address_set))
10188 errmsg ("no matching server and src addresses set");
10192 /* Construct the API message */
10193 M (DHCP_PROXY_CONFIG, mp);
10195 mp->is_add = is_add;
10196 mp->rx_vrf_id = ntohl (rx_vrf_id);
10197 mp->server_vrf_id = ntohl (server_vrf_id);
10198 if (v6_address_set)
10201 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
10202 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
10206 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
10207 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
10213 /* Wait for a reply, return good/bad news */
10218 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
10219 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
10222 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
10224 vat_main_t *vam = &vat_main;
10225 u32 i, count = mp->count;
10226 vl_api_dhcp_server_t *s;
10230 "RX Table-ID %d, Source Address %U, VSS Type %d, "
10231 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
10232 ntohl (mp->rx_vrf_id),
10233 format_ip6_address, mp->dhcp_src_address,
10234 mp->vss_type, mp->vss_vpn_ascii_id,
10235 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
10238 "RX Table-ID %d, Source Address %U, VSS Type %d, "
10239 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
10240 ntohl (mp->rx_vrf_id),
10241 format_ip4_address, mp->dhcp_src_address,
10242 mp->vss_type, mp->vss_vpn_ascii_id,
10243 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
10245 for (i = 0; i < count; i++)
10247 s = &mp->servers[i];
10251 " Server Table-ID %d, Server Address %U",
10252 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
10255 " Server Table-ID %d, Server Address %U",
10256 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
10260 static void vl_api_dhcp_proxy_details_t_handler_json
10261 (vl_api_dhcp_proxy_details_t * mp)
10263 vat_main_t *vam = &vat_main;
10264 vat_json_node_t *node = NULL;
10265 u32 i, count = mp->count;
10266 struct in_addr ip4;
10267 struct in6_addr ip6;
10268 vl_api_dhcp_server_t *s;
10270 if (VAT_JSON_ARRAY != vam->json_tree.type)
10272 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10273 vat_json_init_array (&vam->json_tree);
10275 node = vat_json_array_add (&vam->json_tree);
10277 vat_json_init_object (node);
10278 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
10279 vat_json_object_add_bytes (node, "vss-type", &mp->vss_type,
10280 sizeof (mp->vss_type));
10281 vat_json_object_add_string_copy (node, "vss-vpn-ascii-id",
10282 mp->vss_vpn_ascii_id);
10283 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
10284 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
10288 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
10289 vat_json_object_add_ip6 (node, "src_address", ip6);
10293 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
10294 vat_json_object_add_ip4 (node, "src_address", ip4);
10297 for (i = 0; i < count; i++)
10299 s = &mp->servers[i];
10301 vat_json_object_add_uint (node, "server-table-id",
10302 ntohl (s->server_vrf_id));
10306 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
10307 vat_json_object_add_ip4 (node, "src_address", ip4);
10311 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
10312 vat_json_object_add_ip6 (node, "server_address", ip6);
10318 api_dhcp_proxy_dump (vat_main_t * vam)
10320 unformat_input_t *i = vam->input;
10321 vl_api_control_ping_t *mp_ping;
10322 vl_api_dhcp_proxy_dump_t *mp;
10326 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10328 if (unformat (i, "ipv6"))
10332 clib_warning ("parse error '%U'", format_unformat_error, i);
10337 M (DHCP_PROXY_DUMP, mp);
10339 mp->is_ip6 = is_ipv6;
10342 /* Use a control ping for synchronization */
10343 MPING (CONTROL_PING, mp_ping);
10351 api_dhcp_proxy_set_vss (vat_main_t * vam)
10353 unformat_input_t *i = vam->input;
10354 vl_api_dhcp_proxy_set_vss_t *mp;
10358 u8 vss_type = VSS_TYPE_DEFAULT;
10359 u8 *vpn_ascii_id = 0;
10364 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10366 if (unformat (i, "tbl_id %d", &tbl_id))
10368 else if (unformat (i, "vpn_ascii_id %s", &vpn_ascii_id))
10369 vss_type = VSS_TYPE_ASCII;
10370 else if (unformat (i, "fib_id %d", &fib_id))
10371 vss_type = VSS_TYPE_VPN_ID;
10372 else if (unformat (i, "oui %d", &oui))
10373 vss_type = VSS_TYPE_VPN_ID;
10374 else if (unformat (i, "ipv6"))
10376 else if (unformat (i, "del"))
10384 errmsg ("missing tbl_id ");
10385 vec_free (vpn_ascii_id);
10389 if ((vpn_ascii_id) && (vec_len (vpn_ascii_id) > 128))
10391 errmsg ("vpn_ascii_id cannot be longer than 128 ");
10392 vec_free (vpn_ascii_id);
10396 M (DHCP_PROXY_SET_VSS, mp);
10397 mp->tbl_id = ntohl (tbl_id);
10398 mp->vss_type = vss_type;
10401 clib_memcpy (mp->vpn_ascii_id, vpn_ascii_id, vec_len (vpn_ascii_id));
10402 mp->vpn_ascii_id[vec_len (vpn_ascii_id)] = 0;
10404 mp->vpn_index = ntohl (fib_id);
10405 mp->oui = ntohl (oui);
10406 mp->is_ipv6 = is_ipv6;
10407 mp->is_add = is_add;
10412 vec_free (vpn_ascii_id);
10417 api_dhcp_client_config (vat_main_t * vam)
10419 unformat_input_t *i = vam->input;
10420 vl_api_dhcp_client_config_t *mp;
10422 u8 sw_if_index_set = 0;
10425 u8 disable_event = 0;
10428 /* Parse args required to build the message */
10429 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10431 if (unformat (i, "del"))
10434 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10435 sw_if_index_set = 1;
10436 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10437 sw_if_index_set = 1;
10438 else if (unformat (i, "hostname %s", &hostname))
10440 else if (unformat (i, "disable_event"))
10446 if (sw_if_index_set == 0)
10448 errmsg ("missing interface name or sw_if_index");
10452 if (vec_len (hostname) > 63)
10454 errmsg ("hostname too long");
10456 vec_add1 (hostname, 0);
10458 /* Construct the API message */
10459 M (DHCP_CLIENT_CONFIG, mp);
10461 mp->is_add = is_add;
10462 mp->client.sw_if_index = htonl (sw_if_index);
10463 clib_memcpy (mp->client.hostname, hostname, vec_len (hostname));
10464 vec_free (hostname);
10465 mp->client.want_dhcp_event = disable_event ? 0 : 1;
10466 mp->client.pid = htonl (getpid ());
10471 /* Wait for a reply, return good/bad news */
10477 api_set_ip_flow_hash (vat_main_t * vam)
10479 unformat_input_t *i = vam->input;
10480 vl_api_set_ip_flow_hash_t *mp;
10492 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10494 if (unformat (i, "vrf %d", &vrf_id))
10496 else if (unformat (i, "ipv6"))
10498 else if (unformat (i, "src"))
10500 else if (unformat (i, "dst"))
10502 else if (unformat (i, "sport"))
10504 else if (unformat (i, "dport"))
10506 else if (unformat (i, "proto"))
10508 else if (unformat (i, "reverse"))
10513 clib_warning ("parse error '%U'", format_unformat_error, i);
10518 if (vrf_id_set == 0)
10520 errmsg ("missing vrf id");
10524 M (SET_IP_FLOW_HASH, mp);
10530 mp->reverse = reverse;
10531 mp->vrf_id = ntohl (vrf_id);
10532 mp->is_ipv6 = is_ipv6;
10540 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
10542 unformat_input_t *i = vam->input;
10543 vl_api_sw_interface_ip6_enable_disable_t *mp;
10545 u8 sw_if_index_set = 0;
10549 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10551 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10552 sw_if_index_set = 1;
10553 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10554 sw_if_index_set = 1;
10555 else if (unformat (i, "enable"))
10557 else if (unformat (i, "disable"))
10561 clib_warning ("parse error '%U'", format_unformat_error, i);
10566 if (sw_if_index_set == 0)
10568 errmsg ("missing interface name or sw_if_index");
10572 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
10574 mp->sw_if_index = ntohl (sw_if_index);
10575 mp->enable = enable;
10583 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
10585 unformat_input_t *i = vam->input;
10586 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
10588 u8 sw_if_index_set = 0;
10589 u8 v6_address_set = 0;
10590 ip6_address_t v6address;
10593 /* Parse args required to build the message */
10594 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10596 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10597 sw_if_index_set = 1;
10598 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10599 sw_if_index_set = 1;
10600 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10601 v6_address_set = 1;
10606 if (sw_if_index_set == 0)
10608 errmsg ("missing interface name or sw_if_index");
10611 if (!v6_address_set)
10613 errmsg ("no address set");
10617 /* Construct the API message */
10618 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
10620 mp->sw_if_index = ntohl (sw_if_index);
10621 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10626 /* Wait for a reply, return good/bad news */
10632 api_ip6nd_proxy_add_del (vat_main_t * vam)
10634 unformat_input_t *i = vam->input;
10635 vl_api_ip6nd_proxy_add_del_t *mp;
10636 u32 sw_if_index = ~0;
10637 u8 v6_address_set = 0;
10638 ip6_address_t v6address;
10642 /* Parse args required to build the message */
10643 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10645 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10647 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10649 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10650 v6_address_set = 1;
10651 if (unformat (i, "del"))
10655 clib_warning ("parse error '%U'", format_unformat_error, i);
10660 if (sw_if_index == ~0)
10662 errmsg ("missing interface name or sw_if_index");
10665 if (!v6_address_set)
10667 errmsg ("no address set");
10671 /* Construct the API message */
10672 M (IP6ND_PROXY_ADD_DEL, mp);
10674 mp->is_del = is_del;
10675 mp->sw_if_index = ntohl (sw_if_index);
10676 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10681 /* Wait for a reply, return good/bad news */
10687 api_ip6nd_proxy_dump (vat_main_t * vam)
10689 vl_api_ip6nd_proxy_dump_t *mp;
10690 vl_api_control_ping_t *mp_ping;
10693 M (IP6ND_PROXY_DUMP, mp);
10697 /* Use a control ping for synchronization */
10698 MPING (CONTROL_PING, mp_ping);
10705 static void vl_api_ip6nd_proxy_details_t_handler
10706 (vl_api_ip6nd_proxy_details_t * mp)
10708 vat_main_t *vam = &vat_main;
10710 print (vam->ofp, "host %U sw_if_index %d",
10711 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
10714 static void vl_api_ip6nd_proxy_details_t_handler_json
10715 (vl_api_ip6nd_proxy_details_t * mp)
10717 vat_main_t *vam = &vat_main;
10718 struct in6_addr ip6;
10719 vat_json_node_t *node = NULL;
10721 if (VAT_JSON_ARRAY != vam->json_tree.type)
10723 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10724 vat_json_init_array (&vam->json_tree);
10726 node = vat_json_array_add (&vam->json_tree);
10728 vat_json_init_object (node);
10729 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10731 clib_memcpy (&ip6, mp->address, sizeof (ip6));
10732 vat_json_object_add_ip6 (node, "host", ip6);
10736 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
10738 unformat_input_t *i = vam->input;
10739 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
10741 u8 sw_if_index_set = 0;
10742 u32 address_length = 0;
10743 u8 v6_address_set = 0;
10744 ip6_address_t v6address;
10745 u8 use_default = 0;
10746 u8 no_advertise = 0;
10748 u8 no_autoconfig = 0;
10751 u32 val_lifetime = 0;
10752 u32 pref_lifetime = 0;
10755 /* Parse args required to build the message */
10756 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10758 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10759 sw_if_index_set = 1;
10760 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10761 sw_if_index_set = 1;
10762 else if (unformat (i, "%U/%d",
10763 unformat_ip6_address, &v6address, &address_length))
10764 v6_address_set = 1;
10765 else if (unformat (i, "val_life %d", &val_lifetime))
10767 else if (unformat (i, "pref_life %d", &pref_lifetime))
10769 else if (unformat (i, "def"))
10771 else if (unformat (i, "noadv"))
10773 else if (unformat (i, "offl"))
10775 else if (unformat (i, "noauto"))
10777 else if (unformat (i, "nolink"))
10779 else if (unformat (i, "isno"))
10783 clib_warning ("parse error '%U'", format_unformat_error, i);
10788 if (sw_if_index_set == 0)
10790 errmsg ("missing interface name or sw_if_index");
10793 if (!v6_address_set)
10795 errmsg ("no address set");
10799 /* Construct the API message */
10800 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
10802 mp->sw_if_index = ntohl (sw_if_index);
10803 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10804 mp->address_length = address_length;
10805 mp->use_default = use_default;
10806 mp->no_advertise = no_advertise;
10807 mp->off_link = off_link;
10808 mp->no_autoconfig = no_autoconfig;
10809 mp->no_onlink = no_onlink;
10811 mp->val_lifetime = ntohl (val_lifetime);
10812 mp->pref_lifetime = ntohl (pref_lifetime);
10817 /* Wait for a reply, return good/bad news */
10823 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
10825 unformat_input_t *i = vam->input;
10826 vl_api_sw_interface_ip6nd_ra_config_t *mp;
10828 u8 sw_if_index_set = 0;
10833 u8 send_unicast = 0;
10836 u8 default_router = 0;
10837 u32 max_interval = 0;
10838 u32 min_interval = 0;
10840 u32 initial_count = 0;
10841 u32 initial_interval = 0;
10845 /* Parse args required to build the message */
10846 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10848 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10849 sw_if_index_set = 1;
10850 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10851 sw_if_index_set = 1;
10852 else if (unformat (i, "maxint %d", &max_interval))
10854 else if (unformat (i, "minint %d", &min_interval))
10856 else if (unformat (i, "life %d", &lifetime))
10858 else if (unformat (i, "count %d", &initial_count))
10860 else if (unformat (i, "interval %d", &initial_interval))
10862 else if (unformat (i, "suppress") || unformat (i, "surpress"))
10864 else if (unformat (i, "managed"))
10866 else if (unformat (i, "other"))
10868 else if (unformat (i, "ll"))
10870 else if (unformat (i, "send"))
10872 else if (unformat (i, "cease"))
10874 else if (unformat (i, "isno"))
10876 else if (unformat (i, "def"))
10877 default_router = 1;
10880 clib_warning ("parse error '%U'", format_unformat_error, i);
10885 if (sw_if_index_set == 0)
10887 errmsg ("missing interface name or sw_if_index");
10891 /* Construct the API message */
10892 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
10894 mp->sw_if_index = ntohl (sw_if_index);
10895 mp->max_interval = ntohl (max_interval);
10896 mp->min_interval = ntohl (min_interval);
10897 mp->lifetime = ntohl (lifetime);
10898 mp->initial_count = ntohl (initial_count);
10899 mp->initial_interval = ntohl (initial_interval);
10900 mp->suppress = suppress;
10901 mp->managed = managed;
10903 mp->ll_option = ll_option;
10904 mp->send_unicast = send_unicast;
10907 mp->default_router = default_router;
10912 /* Wait for a reply, return good/bad news */
10918 api_set_arp_neighbor_limit (vat_main_t * vam)
10920 unformat_input_t *i = vam->input;
10921 vl_api_set_arp_neighbor_limit_t *mp;
10927 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10929 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
10931 else if (unformat (i, "ipv6"))
10935 clib_warning ("parse error '%U'", format_unformat_error, i);
10940 if (limit_set == 0)
10942 errmsg ("missing limit value");
10946 M (SET_ARP_NEIGHBOR_LIMIT, mp);
10948 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
10949 mp->is_ipv6 = is_ipv6;
10957 api_l2_patch_add_del (vat_main_t * vam)
10959 unformat_input_t *i = vam->input;
10960 vl_api_l2_patch_add_del_t *mp;
10961 u32 rx_sw_if_index;
10962 u8 rx_sw_if_index_set = 0;
10963 u32 tx_sw_if_index;
10964 u8 tx_sw_if_index_set = 0;
10968 /* Parse args required to build the message */
10969 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10971 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
10972 rx_sw_if_index_set = 1;
10973 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
10974 tx_sw_if_index_set = 1;
10975 else if (unformat (i, "rx"))
10977 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10979 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10981 rx_sw_if_index_set = 1;
10986 else if (unformat (i, "tx"))
10988 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10990 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10992 tx_sw_if_index_set = 1;
10997 else if (unformat (i, "del"))
11003 if (rx_sw_if_index_set == 0)
11005 errmsg ("missing rx interface name or rx_sw_if_index");
11009 if (tx_sw_if_index_set == 0)
11011 errmsg ("missing tx interface name or tx_sw_if_index");
11015 M (L2_PATCH_ADD_DEL, mp);
11017 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
11018 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
11019 mp->is_add = is_add;
11027 u8 localsid_addr[16];
11036 api_sr_localsid_add_del (vat_main_t * vam)
11038 unformat_input_t *i = vam->input;
11039 vl_api_sr_localsid_add_del_t *mp;
11042 ip6_address_t localsid;
11046 u32 fib_table = ~(u32) 0;
11047 ip6_address_t nh_addr6;
11048 ip4_address_t nh_addr4;
11049 memset (&nh_addr6, 0, sizeof (ip6_address_t));
11050 memset (&nh_addr4, 0, sizeof (ip4_address_t));
11052 bool nexthop_set = 0;
11056 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11058 if (unformat (i, "del"))
11060 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
11061 else if (unformat (i, "next-hop %U", unformat_ip4_address, &nh_addr4))
11063 else if (unformat (i, "next-hop %U", unformat_ip6_address, &nh_addr6))
11065 else if (unformat (i, "behavior %u", &behavior));
11066 else if (unformat (i, "sw_if_index %u", &sw_if_index));
11067 else if (unformat (i, "fib-table %u", &fib_table));
11068 else if (unformat (i, "end.psp %u", &behavior));
11073 M (SR_LOCALSID_ADD_DEL, mp);
11075 clib_memcpy (mp->localsid.addr, &localsid, sizeof (mp->localsid));
11078 clib_memcpy (mp->nh_addr6, &nh_addr6, sizeof (mp->nh_addr6));
11079 clib_memcpy (mp->nh_addr4, &nh_addr4, sizeof (mp->nh_addr4));
11081 mp->behavior = behavior;
11082 mp->sw_if_index = ntohl (sw_if_index);
11083 mp->fib_table = ntohl (fib_table);
11084 mp->end_psp = end_psp;
11085 mp->is_del = is_del;
11093 api_ioam_enable (vat_main_t * vam)
11095 unformat_input_t *input = vam->input;
11096 vl_api_ioam_enable_t *mp;
11098 int has_trace_option = 0;
11099 int has_pot_option = 0;
11100 int has_seqno_option = 0;
11101 int has_analyse_option = 0;
11104 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11106 if (unformat (input, "trace"))
11107 has_trace_option = 1;
11108 else if (unformat (input, "pot"))
11109 has_pot_option = 1;
11110 else if (unformat (input, "seqno"))
11111 has_seqno_option = 1;
11112 else if (unformat (input, "analyse"))
11113 has_analyse_option = 1;
11117 M (IOAM_ENABLE, mp);
11118 mp->id = htons (id);
11119 mp->seqno = has_seqno_option;
11120 mp->analyse = has_analyse_option;
11121 mp->pot_enable = has_pot_option;
11122 mp->trace_enable = has_trace_option;
11131 api_ioam_disable (vat_main_t * vam)
11133 vl_api_ioam_disable_t *mp;
11136 M (IOAM_DISABLE, mp);
11142 #define foreach_tcp_proto_field \
11146 #define foreach_udp_proto_field \
11150 #define foreach_ip4_proto_field \
11162 u16 src_port, dst_port;
11165 #if VPP_API_TEST_BUILTIN == 0
11167 unformat_tcp_mask (unformat_input_t * input, va_list * args)
11169 u8 **maskp = va_arg (*args, u8 **);
11171 u8 found_something = 0;
11174 #define _(a) u8 a=0;
11175 foreach_tcp_proto_field;
11178 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11181 #define _(a) else if (unformat (input, #a)) a=1;
11182 foreach_tcp_proto_field
11188 #define _(a) found_something += a;
11189 foreach_tcp_proto_field;
11192 if (found_something == 0)
11195 vec_validate (mask, sizeof (*tcp) - 1);
11197 tcp = (tcp_header_t *) mask;
11199 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
11200 foreach_tcp_proto_field;
11208 unformat_udp_mask (unformat_input_t * input, va_list * args)
11210 u8 **maskp = va_arg (*args, u8 **);
11212 u8 found_something = 0;
11215 #define _(a) u8 a=0;
11216 foreach_udp_proto_field;
11219 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11222 #define _(a) else if (unformat (input, #a)) a=1;
11223 foreach_udp_proto_field
11229 #define _(a) found_something += a;
11230 foreach_udp_proto_field;
11233 if (found_something == 0)
11236 vec_validate (mask, sizeof (*udp) - 1);
11238 udp = (udp_header_t *) mask;
11240 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
11241 foreach_udp_proto_field;
11249 unformat_l4_mask (unformat_input_t * input, va_list * args)
11251 u8 **maskp = va_arg (*args, u8 **);
11252 u16 src_port = 0, dst_port = 0;
11253 tcpudp_header_t *tcpudp;
11255 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11257 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
11259 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
11261 else if (unformat (input, "src_port"))
11263 else if (unformat (input, "dst_port"))
11269 if (!src_port && !dst_port)
11273 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
11275 tcpudp = (tcpudp_header_t *) mask;
11276 tcpudp->src_port = src_port;
11277 tcpudp->dst_port = dst_port;
11285 unformat_ip4_mask (unformat_input_t * input, va_list * args)
11287 u8 **maskp = va_arg (*args, u8 **);
11289 u8 found_something = 0;
11292 #define _(a) u8 a=0;
11293 foreach_ip4_proto_field;
11299 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11301 if (unformat (input, "version"))
11303 else if (unformat (input, "hdr_length"))
11305 else if (unformat (input, "src"))
11307 else if (unformat (input, "dst"))
11309 else if (unformat (input, "proto"))
11312 #define _(a) else if (unformat (input, #a)) a=1;
11313 foreach_ip4_proto_field
11319 #define _(a) found_something += a;
11320 foreach_ip4_proto_field;
11323 if (found_something == 0)
11326 vec_validate (mask, sizeof (*ip) - 1);
11328 ip = (ip4_header_t *) mask;
11330 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
11331 foreach_ip4_proto_field;
11334 ip->ip_version_and_header_length = 0;
11337 ip->ip_version_and_header_length |= 0xF0;
11340 ip->ip_version_and_header_length |= 0x0F;
11346 #define foreach_ip6_proto_field \
11349 _(payload_length) \
11354 unformat_ip6_mask (unformat_input_t * input, va_list * args)
11356 u8 **maskp = va_arg (*args, u8 **);
11358 u8 found_something = 0;
11360 u32 ip_version_traffic_class_and_flow_label;
11362 #define _(a) u8 a=0;
11363 foreach_ip6_proto_field;
11366 u8 traffic_class = 0;
11369 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11371 if (unformat (input, "version"))
11373 else if (unformat (input, "traffic-class"))
11375 else if (unformat (input, "flow-label"))
11377 else if (unformat (input, "src"))
11379 else if (unformat (input, "dst"))
11381 else if (unformat (input, "proto"))
11384 #define _(a) else if (unformat (input, #a)) a=1;
11385 foreach_ip6_proto_field
11391 #define _(a) found_something += a;
11392 foreach_ip6_proto_field;
11395 if (found_something == 0)
11398 vec_validate (mask, sizeof (*ip) - 1);
11400 ip = (ip6_header_t *) mask;
11402 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
11403 foreach_ip6_proto_field;
11406 ip_version_traffic_class_and_flow_label = 0;
11409 ip_version_traffic_class_and_flow_label |= 0xF0000000;
11412 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
11415 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
11417 ip->ip_version_traffic_class_and_flow_label =
11418 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11425 unformat_l3_mask (unformat_input_t * input, va_list * args)
11427 u8 **maskp = va_arg (*args, u8 **);
11429 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11431 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
11433 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
11442 unformat_l2_mask (unformat_input_t * input, va_list * args)
11444 u8 **maskp = va_arg (*args, u8 **);
11451 u8 ignore_tag1 = 0;
11452 u8 ignore_tag2 = 0;
11459 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11461 if (unformat (input, "src"))
11463 else if (unformat (input, "dst"))
11465 else if (unformat (input, "proto"))
11467 else if (unformat (input, "tag1"))
11469 else if (unformat (input, "tag2"))
11471 else if (unformat (input, "ignore-tag1"))
11473 else if (unformat (input, "ignore-tag2"))
11475 else if (unformat (input, "cos1"))
11477 else if (unformat (input, "cos2"))
11479 else if (unformat (input, "dot1q"))
11481 else if (unformat (input, "dot1ad"))
11486 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
11487 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11490 if (tag1 || ignore_tag1 || cos1 || dot1q)
11492 if (tag2 || ignore_tag2 || cos2 || dot1ad)
11495 vec_validate (mask, len - 1);
11498 memset (mask, 0xff, 6);
11501 memset (mask + 6, 0xff, 6);
11503 if (tag2 || dot1ad)
11505 /* inner vlan tag */
11514 mask[21] = mask[20] = 0xff;
11535 mask[16] = mask[17] = 0xff;
11545 mask[12] = mask[13] = 0xff;
11552 unformat_classify_mask (unformat_input_t * input, va_list * args)
11554 u8 **maskp = va_arg (*args, u8 **);
11555 u32 *skipp = va_arg (*args, u32 *);
11556 u32 *matchp = va_arg (*args, u32 *);
11564 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11566 if (unformat (input, "hex %U", unformat_hex_string, &mask))
11568 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
11570 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
11572 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
11586 if (mask || l2 || l3 || l4)
11588 if (l2 || l3 || l4)
11590 /* "With a free Ethernet header in every package" */
11592 vec_validate (l2, 13);
11596 vec_append (mask, l3);
11601 vec_append (mask, l4);
11606 /* Scan forward looking for the first significant mask octet */
11607 for (i = 0; i < vec_len (mask); i++)
11611 /* compute (skip, match) params */
11612 *skipp = i / sizeof (u32x4);
11613 vec_delete (mask, *skipp * sizeof (u32x4), 0);
11615 /* Pad mask to an even multiple of the vector size */
11616 while (vec_len (mask) % sizeof (u32x4))
11617 vec_add1 (mask, 0);
11619 match = vec_len (mask) / sizeof (u32x4);
11621 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
11623 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
11624 if (*tmp || *(tmp + 1))
11629 clib_warning ("BUG: match 0");
11631 _vec_len (mask) = match * sizeof (u32x4);
11641 #endif /* VPP_API_TEST_BUILTIN */
11643 #define foreach_l2_next \
11645 _(ethernet, ETHERNET_INPUT) \
11646 _(ip4, IP4_INPUT) \
11650 unformat_l2_next_index (unformat_input_t * input, va_list * args)
11652 u32 *miss_next_indexp = va_arg (*args, u32 *);
11653 u32 next_index = 0;
11657 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
11661 if (unformat (input, "%d", &tmp))
11670 *miss_next_indexp = next_index;
11674 #define foreach_ip_next \
11677 _(rewrite, REWRITE)
11680 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
11682 u32 *miss_next_indexp = va_arg (*args, u32 *);
11683 u32 next_index = 0;
11687 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
11691 if (unformat (input, "%d", &tmp))
11700 *miss_next_indexp = next_index;
11704 #define foreach_acl_next \
11708 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
11710 u32 *miss_next_indexp = va_arg (*args, u32 *);
11711 u32 next_index = 0;
11715 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
11719 if (unformat (input, "permit"))
11724 else if (unformat (input, "%d", &tmp))
11733 *miss_next_indexp = next_index;
11738 unformat_policer_precolor (unformat_input_t * input, va_list * args)
11740 u32 *r = va_arg (*args, u32 *);
11742 if (unformat (input, "conform-color"))
11743 *r = POLICE_CONFORM;
11744 else if (unformat (input, "exceed-color"))
11745 *r = POLICE_EXCEED;
11753 api_classify_add_del_table (vat_main_t * vam)
11755 unformat_input_t *i = vam->input;
11756 vl_api_classify_add_del_table_t *mp;
11763 u32 table_index = ~0;
11764 u32 next_table_index = ~0;
11765 u32 miss_next_index = ~0;
11766 u32 memory_size = 32 << 20;
11768 u32 current_data_flag = 0;
11769 int current_data_offset = 0;
11772 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11774 if (unformat (i, "del"))
11776 else if (unformat (i, "del-chain"))
11781 else if (unformat (i, "buckets %d", &nbuckets))
11783 else if (unformat (i, "memory_size %d", &memory_size))
11785 else if (unformat (i, "skip %d", &skip))
11787 else if (unformat (i, "match %d", &match))
11789 else if (unformat (i, "table %d", &table_index))
11791 else if (unformat (i, "mask %U", unformat_classify_mask,
11792 &mask, &skip, &match))
11794 else if (unformat (i, "next-table %d", &next_table_index))
11796 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
11799 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
11802 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
11805 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
11807 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
11813 if (is_add && mask == 0)
11815 errmsg ("Mask required");
11819 if (is_add && skip == ~0)
11821 errmsg ("skip count required");
11825 if (is_add && match == ~0)
11827 errmsg ("match count required");
11831 if (!is_add && table_index == ~0)
11833 errmsg ("table index required for delete");
11837 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
11839 mp->is_add = is_add;
11840 mp->del_chain = del_chain;
11841 mp->table_index = ntohl (table_index);
11842 mp->nbuckets = ntohl (nbuckets);
11843 mp->memory_size = ntohl (memory_size);
11844 mp->skip_n_vectors = ntohl (skip);
11845 mp->match_n_vectors = ntohl (match);
11846 mp->next_table_index = ntohl (next_table_index);
11847 mp->miss_next_index = ntohl (miss_next_index);
11848 mp->current_data_flag = ntohl (current_data_flag);
11849 mp->current_data_offset = ntohl (current_data_offset);
11850 mp->mask_len = ntohl (vec_len (mask));
11851 clib_memcpy (mp->mask, mask, vec_len (mask));
11860 #if VPP_API_TEST_BUILTIN == 0
11862 unformat_l4_match (unformat_input_t * input, va_list * args)
11864 u8 **matchp = va_arg (*args, u8 **);
11866 u8 *proto_header = 0;
11872 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11874 if (unformat (input, "src_port %d", &src_port))
11876 else if (unformat (input, "dst_port %d", &dst_port))
11882 h.src_port = clib_host_to_net_u16 (src_port);
11883 h.dst_port = clib_host_to_net_u16 (dst_port);
11884 vec_validate (proto_header, sizeof (h) - 1);
11885 memcpy (proto_header, &h, sizeof (h));
11887 *matchp = proto_header;
11893 unformat_ip4_match (unformat_input_t * input, va_list * args)
11895 u8 **matchp = va_arg (*args, u8 **);
11900 int hdr_length = 0;
11901 u32 hdr_length_val;
11902 int src = 0, dst = 0;
11903 ip4_address_t src_val, dst_val;
11910 int fragment_id = 0;
11911 u32 fragment_id_val;
11917 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11919 if (unformat (input, "version %d", &version_val))
11921 else if (unformat (input, "hdr_length %d", &hdr_length_val))
11923 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
11925 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
11927 else if (unformat (input, "proto %d", &proto_val))
11929 else if (unformat (input, "tos %d", &tos_val))
11931 else if (unformat (input, "length %d", &length_val))
11933 else if (unformat (input, "fragment_id %d", &fragment_id_val))
11935 else if (unformat (input, "ttl %d", &ttl_val))
11937 else if (unformat (input, "checksum %d", &checksum_val))
11943 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
11944 + ttl + checksum == 0)
11948 * Aligned because we use the real comparison functions
11950 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11952 ip = (ip4_header_t *) match;
11954 /* These are realistically matched in practice */
11956 ip->src_address.as_u32 = src_val.as_u32;
11959 ip->dst_address.as_u32 = dst_val.as_u32;
11962 ip->protocol = proto_val;
11965 /* These are not, but they're included for completeness */
11967 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
11970 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
11976 ip->length = clib_host_to_net_u16 (length_val);
11982 ip->checksum = clib_host_to_net_u16 (checksum_val);
11989 unformat_ip6_match (unformat_input_t * input, va_list * args)
11991 u8 **matchp = va_arg (*args, u8 **);
11996 u8 traffic_class = 0;
11997 u32 traffic_class_val = 0;
12000 int src = 0, dst = 0;
12001 ip6_address_t src_val, dst_val;
12004 int payload_length = 0;
12005 u32 payload_length_val;
12008 u32 ip_version_traffic_class_and_flow_label;
12010 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12012 if (unformat (input, "version %d", &version_val))
12014 else if (unformat (input, "traffic_class %d", &traffic_class_val))
12016 else if (unformat (input, "flow_label %d", &flow_label_val))
12018 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
12020 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
12022 else if (unformat (input, "proto %d", &proto_val))
12024 else if (unformat (input, "payload_length %d", &payload_length_val))
12025 payload_length = 1;
12026 else if (unformat (input, "hop_limit %d", &hop_limit_val))
12032 if (version + traffic_class + flow_label + src + dst + proto +
12033 payload_length + hop_limit == 0)
12037 * Aligned because we use the real comparison functions
12039 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
12041 ip = (ip6_header_t *) match;
12044 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
12047 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
12050 ip->protocol = proto_val;
12052 ip_version_traffic_class_and_flow_label = 0;
12055 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
12058 ip_version_traffic_class_and_flow_label |=
12059 (traffic_class_val & 0xFF) << 20;
12062 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
12064 ip->ip_version_traffic_class_and_flow_label =
12065 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
12067 if (payload_length)
12068 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
12071 ip->hop_limit = hop_limit_val;
12078 unformat_l3_match (unformat_input_t * input, va_list * args)
12080 u8 **matchp = va_arg (*args, u8 **);
12082 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12084 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
12086 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
12095 unformat_vlan_tag (unformat_input_t * input, va_list * args)
12097 u8 *tagp = va_arg (*args, u8 *);
12100 if (unformat (input, "%d", &tag))
12102 tagp[0] = (tag >> 8) & 0x0F;
12103 tagp[1] = tag & 0xFF;
12111 unformat_l2_match (unformat_input_t * input, va_list * args)
12113 u8 **matchp = va_arg (*args, u8 **);
12126 u8 ignore_tag1 = 0;
12127 u8 ignore_tag2 = 0;
12133 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12135 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
12138 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
12140 else if (unformat (input, "proto %U",
12141 unformat_ethernet_type_host_byte_order, &proto_val))
12143 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
12145 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
12147 else if (unformat (input, "ignore-tag1"))
12149 else if (unformat (input, "ignore-tag2"))
12151 else if (unformat (input, "cos1 %d", &cos1_val))
12153 else if (unformat (input, "cos2 %d", &cos2_val))
12158 if ((src + dst + proto + tag1 + tag2 +
12159 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
12162 if (tag1 || ignore_tag1 || cos1)
12164 if (tag2 || ignore_tag2 || cos2)
12167 vec_validate_aligned (match, len - 1, sizeof (u32x4));
12170 clib_memcpy (match, dst_val, 6);
12173 clib_memcpy (match + 6, src_val, 6);
12177 /* inner vlan tag */
12178 match[19] = tag2_val[1];
12179 match[18] = tag2_val[0];
12181 match[18] |= (cos2_val & 0x7) << 5;
12184 match[21] = proto_val & 0xff;
12185 match[20] = proto_val >> 8;
12189 match[15] = tag1_val[1];
12190 match[14] = tag1_val[0];
12193 match[14] |= (cos1_val & 0x7) << 5;
12199 match[15] = tag1_val[1];
12200 match[14] = tag1_val[0];
12203 match[17] = proto_val & 0xff;
12204 match[16] = proto_val >> 8;
12207 match[14] |= (cos1_val & 0x7) << 5;
12213 match[18] |= (cos2_val & 0x7) << 5;
12215 match[14] |= (cos1_val & 0x7) << 5;
12218 match[13] = proto_val & 0xff;
12219 match[12] = proto_val >> 8;
12227 unformat_qos_source (unformat_input_t * input, va_list * args)
12229 int *qs = va_arg (*args, int *);
12231 if (unformat (input, "ip"))
12232 *qs = QOS_SOURCE_IP;
12233 else if (unformat (input, "mpls"))
12234 *qs = QOS_SOURCE_MPLS;
12235 else if (unformat (input, "ext"))
12236 *qs = QOS_SOURCE_EXT;
12237 else if (unformat (input, "vlan"))
12238 *qs = QOS_SOURCE_VLAN;
12247 api_unformat_classify_match (unformat_input_t * input, va_list * args)
12249 u8 **matchp = va_arg (*args, u8 **);
12250 u32 skip_n_vectors = va_arg (*args, u32);
12251 u32 match_n_vectors = va_arg (*args, u32);
12258 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12260 if (unformat (input, "hex %U", unformat_hex_string, &match))
12262 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
12264 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
12266 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
12280 if (match || l2 || l3 || l4)
12282 if (l2 || l3 || l4)
12284 /* "Win a free Ethernet header in every packet" */
12286 vec_validate_aligned (l2, 13, sizeof (u32x4));
12290 vec_append_aligned (match, l3, sizeof (u32x4));
12295 vec_append_aligned (match, l4, sizeof (u32x4));
12300 /* Make sure the vector is big enough even if key is all 0's */
12301 vec_validate_aligned
12302 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
12305 /* Set size, include skipped vectors */
12306 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
12317 api_classify_add_del_session (vat_main_t * vam)
12319 unformat_input_t *i = vam->input;
12320 vl_api_classify_add_del_session_t *mp;
12322 u32 table_index = ~0;
12323 u32 hit_next_index = ~0;
12324 u32 opaque_index = ~0;
12327 u32 skip_n_vectors = 0;
12328 u32 match_n_vectors = 0;
12334 * Warning: you have to supply skip_n and match_n
12335 * because the API client cant simply look at the classify
12339 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12341 if (unformat (i, "del"))
12343 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
12346 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
12349 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
12352 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
12354 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
12356 else if (unformat (i, "opaque-index %d", &opaque_index))
12358 else if (unformat (i, "skip_n %d", &skip_n_vectors))
12360 else if (unformat (i, "match_n %d", &match_n_vectors))
12362 else if (unformat (i, "match %U", api_unformat_classify_match,
12363 &match, skip_n_vectors, match_n_vectors))
12365 else if (unformat (i, "advance %d", &advance))
12367 else if (unformat (i, "table-index %d", &table_index))
12369 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
12371 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
12373 else if (unformat (i, "action %d", &action))
12375 else if (unformat (i, "metadata %d", &metadata))
12381 if (table_index == ~0)
12383 errmsg ("Table index required");
12387 if (is_add && match == 0)
12389 errmsg ("Match value required");
12393 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
12395 mp->is_add = is_add;
12396 mp->table_index = ntohl (table_index);
12397 mp->hit_next_index = ntohl (hit_next_index);
12398 mp->opaque_index = ntohl (opaque_index);
12399 mp->advance = ntohl (advance);
12400 mp->action = action;
12401 mp->metadata = ntohl (metadata);
12402 mp->match_len = ntohl (vec_len (match));
12403 clib_memcpy (mp->match, match, vec_len (match));
12412 api_classify_set_interface_ip_table (vat_main_t * vam)
12414 unformat_input_t *i = vam->input;
12415 vl_api_classify_set_interface_ip_table_t *mp;
12417 int sw_if_index_set;
12418 u32 table_index = ~0;
12422 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12424 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12425 sw_if_index_set = 1;
12426 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12427 sw_if_index_set = 1;
12428 else if (unformat (i, "table %d", &table_index))
12432 clib_warning ("parse error '%U'", format_unformat_error, i);
12437 if (sw_if_index_set == 0)
12439 errmsg ("missing interface name or sw_if_index");
12444 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
12446 mp->sw_if_index = ntohl (sw_if_index);
12447 mp->table_index = ntohl (table_index);
12448 mp->is_ipv6 = is_ipv6;
12456 api_classify_set_interface_l2_tables (vat_main_t * vam)
12458 unformat_input_t *i = vam->input;
12459 vl_api_classify_set_interface_l2_tables_t *mp;
12461 int sw_if_index_set;
12462 u32 ip4_table_index = ~0;
12463 u32 ip6_table_index = ~0;
12464 u32 other_table_index = ~0;
12468 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12470 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12471 sw_if_index_set = 1;
12472 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12473 sw_if_index_set = 1;
12474 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12476 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12478 else if (unformat (i, "other-table %d", &other_table_index))
12480 else if (unformat (i, "is-input %d", &is_input))
12484 clib_warning ("parse error '%U'", format_unformat_error, i);
12489 if (sw_if_index_set == 0)
12491 errmsg ("missing interface name or sw_if_index");
12496 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
12498 mp->sw_if_index = ntohl (sw_if_index);
12499 mp->ip4_table_index = ntohl (ip4_table_index);
12500 mp->ip6_table_index = ntohl (ip6_table_index);
12501 mp->other_table_index = ntohl (other_table_index);
12502 mp->is_input = (u8) is_input;
12510 api_set_ipfix_exporter (vat_main_t * vam)
12512 unformat_input_t *i = vam->input;
12513 vl_api_set_ipfix_exporter_t *mp;
12514 ip4_address_t collector_address;
12515 u8 collector_address_set = 0;
12516 u32 collector_port = ~0;
12517 ip4_address_t src_address;
12518 u8 src_address_set = 0;
12521 u32 template_interval = ~0;
12522 u8 udp_checksum = 0;
12525 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12527 if (unformat (i, "collector_address %U", unformat_ip4_address,
12528 &collector_address))
12529 collector_address_set = 1;
12530 else if (unformat (i, "collector_port %d", &collector_port))
12532 else if (unformat (i, "src_address %U", unformat_ip4_address,
12534 src_address_set = 1;
12535 else if (unformat (i, "vrf_id %d", &vrf_id))
12537 else if (unformat (i, "path_mtu %d", &path_mtu))
12539 else if (unformat (i, "template_interval %d", &template_interval))
12541 else if (unformat (i, "udp_checksum"))
12547 if (collector_address_set == 0)
12549 errmsg ("collector_address required");
12553 if (src_address_set == 0)
12555 errmsg ("src_address required");
12559 M (SET_IPFIX_EXPORTER, mp);
12561 memcpy (mp->collector_address, collector_address.data,
12562 sizeof (collector_address.data));
12563 mp->collector_port = htons ((u16) collector_port);
12564 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
12565 mp->vrf_id = htonl (vrf_id);
12566 mp->path_mtu = htonl (path_mtu);
12567 mp->template_interval = htonl (template_interval);
12568 mp->udp_checksum = udp_checksum;
12576 api_set_ipfix_classify_stream (vat_main_t * vam)
12578 unformat_input_t *i = vam->input;
12579 vl_api_set_ipfix_classify_stream_t *mp;
12581 u32 src_port = UDP_DST_PORT_ipfix;
12584 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12586 if (unformat (i, "domain %d", &domain_id))
12588 else if (unformat (i, "src_port %d", &src_port))
12592 errmsg ("unknown input `%U'", format_unformat_error, i);
12597 M (SET_IPFIX_CLASSIFY_STREAM, mp);
12599 mp->domain_id = htonl (domain_id);
12600 mp->src_port = htons ((u16) src_port);
12608 api_ipfix_classify_table_add_del (vat_main_t * vam)
12610 unformat_input_t *i = vam->input;
12611 vl_api_ipfix_classify_table_add_del_t *mp;
12613 u32 classify_table_index = ~0;
12615 u8 transport_protocol = 255;
12618 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12620 if (unformat (i, "add"))
12622 else if (unformat (i, "del"))
12624 else if (unformat (i, "table %d", &classify_table_index))
12626 else if (unformat (i, "ip4"))
12628 else if (unformat (i, "ip6"))
12630 else if (unformat (i, "tcp"))
12631 transport_protocol = 6;
12632 else if (unformat (i, "udp"))
12633 transport_protocol = 17;
12636 errmsg ("unknown input `%U'", format_unformat_error, i);
12643 errmsg ("expecting: add|del");
12646 if (classify_table_index == ~0)
12648 errmsg ("classifier table not specified");
12651 if (ip_version == 0)
12653 errmsg ("IP version not specified");
12657 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
12659 mp->is_add = is_add;
12660 mp->table_id = htonl (classify_table_index);
12661 mp->ip_version = ip_version;
12662 mp->transport_protocol = transport_protocol;
12670 api_get_node_index (vat_main_t * vam)
12672 unformat_input_t *i = vam->input;
12673 vl_api_get_node_index_t *mp;
12677 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12679 if (unformat (i, "node %s", &name))
12686 errmsg ("node name required");
12689 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12691 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12695 M (GET_NODE_INDEX, mp);
12696 clib_memcpy (mp->node_name, name, vec_len (name));
12705 api_get_next_index (vat_main_t * vam)
12707 unformat_input_t *i = vam->input;
12708 vl_api_get_next_index_t *mp;
12709 u8 *node_name = 0, *next_node_name = 0;
12712 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12714 if (unformat (i, "node-name %s", &node_name))
12716 else if (unformat (i, "next-node-name %s", &next_node_name))
12720 if (node_name == 0)
12722 errmsg ("node name required");
12725 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
12727 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12731 if (next_node_name == 0)
12733 errmsg ("next node name required");
12736 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
12738 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
12742 M (GET_NEXT_INDEX, mp);
12743 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
12744 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
12745 vec_free (node_name);
12746 vec_free (next_node_name);
12754 api_add_node_next (vat_main_t * vam)
12756 unformat_input_t *i = vam->input;
12757 vl_api_add_node_next_t *mp;
12762 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12764 if (unformat (i, "node %s", &name))
12766 else if (unformat (i, "next %s", &next))
12773 errmsg ("node name required");
12776 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12778 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12783 errmsg ("next node required");
12786 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
12788 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
12792 M (ADD_NODE_NEXT, mp);
12793 clib_memcpy (mp->node_name, name, vec_len (name));
12794 clib_memcpy (mp->next_name, next, vec_len (next));
12804 api_l2tpv3_create_tunnel (vat_main_t * vam)
12806 unformat_input_t *i = vam->input;
12807 ip6_address_t client_address, our_address;
12808 int client_address_set = 0;
12809 int our_address_set = 0;
12810 u32 local_session_id = 0;
12811 u32 remote_session_id = 0;
12812 u64 local_cookie = 0;
12813 u64 remote_cookie = 0;
12814 u8 l2_sublayer_present = 0;
12815 vl_api_l2tpv3_create_tunnel_t *mp;
12818 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12820 if (unformat (i, "client_address %U", unformat_ip6_address,
12822 client_address_set = 1;
12823 else if (unformat (i, "our_address %U", unformat_ip6_address,
12825 our_address_set = 1;
12826 else if (unformat (i, "local_session_id %d", &local_session_id))
12828 else if (unformat (i, "remote_session_id %d", &remote_session_id))
12830 else if (unformat (i, "local_cookie %lld", &local_cookie))
12832 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
12834 else if (unformat (i, "l2-sublayer-present"))
12835 l2_sublayer_present = 1;
12840 if (client_address_set == 0)
12842 errmsg ("client_address required");
12846 if (our_address_set == 0)
12848 errmsg ("our_address required");
12852 M (L2TPV3_CREATE_TUNNEL, mp);
12854 clib_memcpy (mp->client_address, client_address.as_u8,
12855 sizeof (mp->client_address));
12857 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
12859 mp->local_session_id = ntohl (local_session_id);
12860 mp->remote_session_id = ntohl (remote_session_id);
12861 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
12862 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
12863 mp->l2_sublayer_present = l2_sublayer_present;
12872 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
12874 unformat_input_t *i = vam->input;
12876 u8 sw_if_index_set = 0;
12877 u64 new_local_cookie = 0;
12878 u64 new_remote_cookie = 0;
12879 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
12882 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12884 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12885 sw_if_index_set = 1;
12886 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12887 sw_if_index_set = 1;
12888 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
12890 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
12896 if (sw_if_index_set == 0)
12898 errmsg ("missing interface name or sw_if_index");
12902 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
12904 mp->sw_if_index = ntohl (sw_if_index);
12905 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
12906 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
12914 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
12916 unformat_input_t *i = vam->input;
12917 vl_api_l2tpv3_interface_enable_disable_t *mp;
12919 u8 sw_if_index_set = 0;
12920 u8 enable_disable = 1;
12923 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12925 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12926 sw_if_index_set = 1;
12927 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12928 sw_if_index_set = 1;
12929 else if (unformat (i, "enable"))
12930 enable_disable = 1;
12931 else if (unformat (i, "disable"))
12932 enable_disable = 0;
12937 if (sw_if_index_set == 0)
12939 errmsg ("missing interface name or sw_if_index");
12943 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
12945 mp->sw_if_index = ntohl (sw_if_index);
12946 mp->enable_disable = enable_disable;
12954 api_l2tpv3_set_lookup_key (vat_main_t * vam)
12956 unformat_input_t *i = vam->input;
12957 vl_api_l2tpv3_set_lookup_key_t *mp;
12961 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12963 if (unformat (i, "lookup_v6_src"))
12964 key = L2T_LOOKUP_SRC_ADDRESS;
12965 else if (unformat (i, "lookup_v6_dst"))
12966 key = L2T_LOOKUP_DST_ADDRESS;
12967 else if (unformat (i, "lookup_session_id"))
12968 key = L2T_LOOKUP_SESSION_ID;
12973 if (key == (u8) ~ 0)
12975 errmsg ("l2tp session lookup key unset");
12979 M (L2TPV3_SET_LOOKUP_KEY, mp);
12988 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
12989 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12991 vat_main_t *vam = &vat_main;
12993 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
12994 format_ip6_address, mp->our_address,
12995 format_ip6_address, mp->client_address,
12996 clib_net_to_host_u32 (mp->sw_if_index));
12999 " local cookies %016llx %016llx remote cookie %016llx",
13000 clib_net_to_host_u64 (mp->local_cookie[0]),
13001 clib_net_to_host_u64 (mp->local_cookie[1]),
13002 clib_net_to_host_u64 (mp->remote_cookie));
13004 print (vam->ofp, " local session-id %d remote session-id %d",
13005 clib_net_to_host_u32 (mp->local_session_id),
13006 clib_net_to_host_u32 (mp->remote_session_id));
13008 print (vam->ofp, " l2 specific sublayer %s\n",
13009 mp->l2_sublayer_present ? "preset" : "absent");
13013 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
13014 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
13016 vat_main_t *vam = &vat_main;
13017 vat_json_node_t *node = NULL;
13018 struct in6_addr addr;
13020 if (VAT_JSON_ARRAY != vam->json_tree.type)
13022 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13023 vat_json_init_array (&vam->json_tree);
13025 node = vat_json_array_add (&vam->json_tree);
13027 vat_json_init_object (node);
13029 clib_memcpy (&addr, mp->our_address, sizeof (addr));
13030 vat_json_object_add_ip6 (node, "our_address", addr);
13031 clib_memcpy (&addr, mp->client_address, sizeof (addr));
13032 vat_json_object_add_ip6 (node, "client_address", addr);
13034 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
13035 vat_json_init_array (lc);
13036 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
13037 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
13038 vat_json_object_add_uint (node, "remote_cookie",
13039 clib_net_to_host_u64 (mp->remote_cookie));
13041 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
13042 vat_json_object_add_uint (node, "local_session_id",
13043 clib_net_to_host_u32 (mp->local_session_id));
13044 vat_json_object_add_uint (node, "remote_session_id",
13045 clib_net_to_host_u32 (mp->remote_session_id));
13046 vat_json_object_add_string_copy (node, "l2_sublayer",
13047 mp->l2_sublayer_present ? (u8 *) "present"
13048 : (u8 *) "absent");
13052 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
13054 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
13055 vl_api_control_ping_t *mp_ping;
13058 /* Get list of l2tpv3-tunnel interfaces */
13059 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
13062 /* Use a control ping for synchronization */
13063 MPING (CONTROL_PING, mp_ping);
13071 static void vl_api_sw_interface_tap_details_t_handler
13072 (vl_api_sw_interface_tap_details_t * mp)
13074 vat_main_t *vam = &vat_main;
13076 print (vam->ofp, "%-16s %d",
13077 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
13080 static void vl_api_sw_interface_tap_details_t_handler_json
13081 (vl_api_sw_interface_tap_details_t * mp)
13083 vat_main_t *vam = &vat_main;
13084 vat_json_node_t *node = NULL;
13086 if (VAT_JSON_ARRAY != vam->json_tree.type)
13088 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13089 vat_json_init_array (&vam->json_tree);
13091 node = vat_json_array_add (&vam->json_tree);
13093 vat_json_init_object (node);
13094 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13095 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
13099 api_sw_interface_tap_dump (vat_main_t * vam)
13101 vl_api_sw_interface_tap_dump_t *mp;
13102 vl_api_control_ping_t *mp_ping;
13105 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
13106 /* Get list of tap interfaces */
13107 M (SW_INTERFACE_TAP_DUMP, mp);
13110 /* Use a control ping for synchronization */
13111 MPING (CONTROL_PING, mp_ping);
13118 static void vl_api_sw_interface_tap_v2_details_t_handler
13119 (vl_api_sw_interface_tap_v2_details_t * mp)
13121 vat_main_t *vam = &vat_main;
13123 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
13124 mp->host_ip4_prefix_len);
13125 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
13126 mp->host_ip6_prefix_len);
13129 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s",
13130 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
13131 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
13132 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
13133 mp->host_bridge, ip4, ip6);
13139 static void vl_api_sw_interface_tap_v2_details_t_handler_json
13140 (vl_api_sw_interface_tap_v2_details_t * mp)
13142 vat_main_t *vam = &vat_main;
13143 vat_json_node_t *node = NULL;
13145 if (VAT_JSON_ARRAY != vam->json_tree.type)
13147 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13148 vat_json_init_array (&vam->json_tree);
13150 node = vat_json_array_add (&vam->json_tree);
13152 vat_json_init_object (node);
13153 vat_json_object_add_uint (node, "id", ntohl (mp->id));
13154 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13155 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
13156 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
13157 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
13158 vat_json_object_add_string_copy (node, "host_mac_addr",
13159 format (0, "%U", format_ethernet_address,
13160 &mp->host_mac_addr));
13161 vat_json_object_add_string_copy (node, "host_namespace",
13162 mp->host_namespace);
13163 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
13164 vat_json_object_add_string_copy (node, "host_ip4_addr",
13165 format (0, "%U/%d", format_ip4_address,
13167 mp->host_ip4_prefix_len));
13168 vat_json_object_add_string_copy (node, "host_ip6_addr",
13169 format (0, "%U/%d", format_ip6_address,
13171 mp->host_ip6_prefix_len));
13176 api_sw_interface_tap_v2_dump (vat_main_t * vam)
13178 vl_api_sw_interface_tap_v2_dump_t *mp;
13179 vl_api_control_ping_t *mp_ping;
13183 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
13184 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
13185 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
13188 /* Get list of tap interfaces */
13189 M (SW_INTERFACE_TAP_V2_DUMP, mp);
13192 /* Use a control ping for synchronization */
13193 MPING (CONTROL_PING, mp_ping);
13201 api_vxlan_offload_rx (vat_main_t * vam)
13203 unformat_input_t *line_input = vam->input;
13204 vl_api_vxlan_offload_rx_t *mp;
13205 u32 hw_if_index = ~0, rx_if_index = ~0;
13209 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13211 if (unformat (line_input, "del"))
13213 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
13216 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
13218 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
13221 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
13225 errmsg ("parse error '%U'", format_unformat_error, line_input);
13230 if (hw_if_index == ~0)
13232 errmsg ("no hw interface");
13236 if (rx_if_index == ~0)
13238 errmsg ("no rx tunnel");
13242 M (VXLAN_OFFLOAD_RX, mp);
13244 mp->hw_if_index = ntohl (hw_if_index);
13245 mp->sw_if_index = ntohl (rx_if_index);
13246 mp->enable = is_add;
13253 static uword unformat_vxlan_decap_next
13254 (unformat_input_t * input, va_list * args)
13256 u32 *result = va_arg (*args, u32 *);
13259 if (unformat (input, "l2"))
13260 *result = VXLAN_INPUT_NEXT_L2_INPUT;
13261 else if (unformat (input, "%d", &tmp))
13269 api_vxlan_add_del_tunnel (vat_main_t * vam)
13271 unformat_input_t *line_input = vam->input;
13272 vl_api_vxlan_add_del_tunnel_t *mp;
13273 ip46_address_t src, dst;
13275 u8 ipv4_set = 0, ipv6_set = 0;
13280 u32 mcast_sw_if_index = ~0;
13281 u32 encap_vrf_id = 0;
13282 u32 decap_next_index = ~0;
13286 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13287 memset (&src, 0, sizeof src);
13288 memset (&dst, 0, sizeof dst);
13290 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13292 if (unformat (line_input, "del"))
13294 else if (unformat (line_input, "instance %d", &instance))
13297 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13303 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13309 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13315 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13320 else if (unformat (line_input, "group %U %U",
13321 unformat_ip4_address, &dst.ip4,
13322 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13324 grp_set = dst_set = 1;
13327 else if (unformat (line_input, "group %U",
13328 unformat_ip4_address, &dst.ip4))
13330 grp_set = dst_set = 1;
13333 else if (unformat (line_input, "group %U %U",
13334 unformat_ip6_address, &dst.ip6,
13335 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13337 grp_set = dst_set = 1;
13340 else if (unformat (line_input, "group %U",
13341 unformat_ip6_address, &dst.ip6))
13343 grp_set = dst_set = 1;
13347 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13349 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13351 else if (unformat (line_input, "decap-next %U",
13352 unformat_vxlan_decap_next, &decap_next_index))
13354 else if (unformat (line_input, "vni %d", &vni))
13358 errmsg ("parse error '%U'", format_unformat_error, line_input);
13365 errmsg ("tunnel src address not specified");
13370 errmsg ("tunnel dst address not specified");
13374 if (grp_set && !ip46_address_is_multicast (&dst))
13376 errmsg ("tunnel group address not multicast");
13379 if (grp_set && mcast_sw_if_index == ~0)
13381 errmsg ("tunnel nonexistent multicast device");
13384 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13386 errmsg ("tunnel dst address must be unicast");
13391 if (ipv4_set && ipv6_set)
13393 errmsg ("both IPv4 and IPv6 addresses specified");
13397 if ((vni == 0) || (vni >> 24))
13399 errmsg ("vni not specified or out of range");
13403 M (VXLAN_ADD_DEL_TUNNEL, mp);
13407 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
13408 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
13412 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
13413 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
13416 mp->instance = htonl (instance);
13417 mp->encap_vrf_id = ntohl (encap_vrf_id);
13418 mp->decap_next_index = ntohl (decap_next_index);
13419 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13420 mp->vni = ntohl (vni);
13421 mp->is_add = is_add;
13422 mp->is_ipv6 = ipv6_set;
13429 static void vl_api_vxlan_tunnel_details_t_handler
13430 (vl_api_vxlan_tunnel_details_t * mp)
13432 vat_main_t *vam = &vat_main;
13433 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13434 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13436 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
13437 ntohl (mp->sw_if_index),
13438 ntohl (mp->instance),
13439 format_ip46_address, &src, IP46_TYPE_ANY,
13440 format_ip46_address, &dst, IP46_TYPE_ANY,
13441 ntohl (mp->encap_vrf_id),
13442 ntohl (mp->decap_next_index), ntohl (mp->vni),
13443 ntohl (mp->mcast_sw_if_index));
13446 static void vl_api_vxlan_tunnel_details_t_handler_json
13447 (vl_api_vxlan_tunnel_details_t * mp)
13449 vat_main_t *vam = &vat_main;
13450 vat_json_node_t *node = NULL;
13452 if (VAT_JSON_ARRAY != vam->json_tree.type)
13454 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13455 vat_json_init_array (&vam->json_tree);
13457 node = vat_json_array_add (&vam->json_tree);
13459 vat_json_init_object (node);
13460 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13462 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13466 struct in6_addr ip6;
13468 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13469 vat_json_object_add_ip6 (node, "src_address", ip6);
13470 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13471 vat_json_object_add_ip6 (node, "dst_address", ip6);
13475 struct in_addr ip4;
13477 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13478 vat_json_object_add_ip4 (node, "src_address", ip4);
13479 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13480 vat_json_object_add_ip4 (node, "dst_address", ip4);
13482 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13483 vat_json_object_add_uint (node, "decap_next_index",
13484 ntohl (mp->decap_next_index));
13485 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13486 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13487 vat_json_object_add_uint (node, "mcast_sw_if_index",
13488 ntohl (mp->mcast_sw_if_index));
13492 api_vxlan_tunnel_dump (vat_main_t * vam)
13494 unformat_input_t *i = vam->input;
13495 vl_api_vxlan_tunnel_dump_t *mp;
13496 vl_api_control_ping_t *mp_ping;
13498 u8 sw_if_index_set = 0;
13501 /* Parse args required to build the message */
13502 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13504 if (unformat (i, "sw_if_index %d", &sw_if_index))
13505 sw_if_index_set = 1;
13510 if (sw_if_index_set == 0)
13515 if (!vam->json_output)
13517 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
13518 "sw_if_index", "instance", "src_address", "dst_address",
13519 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13522 /* Get list of vxlan-tunnel interfaces */
13523 M (VXLAN_TUNNEL_DUMP, mp);
13525 mp->sw_if_index = htonl (sw_if_index);
13529 /* Use a control ping for synchronization */
13530 MPING (CONTROL_PING, mp_ping);
13537 static uword unformat_geneve_decap_next
13538 (unformat_input_t * input, va_list * args)
13540 u32 *result = va_arg (*args, u32 *);
13543 if (unformat (input, "l2"))
13544 *result = GENEVE_INPUT_NEXT_L2_INPUT;
13545 else if (unformat (input, "%d", &tmp))
13553 api_geneve_add_del_tunnel (vat_main_t * vam)
13555 unformat_input_t *line_input = vam->input;
13556 vl_api_geneve_add_del_tunnel_t *mp;
13557 ip46_address_t src, dst;
13559 u8 ipv4_set = 0, ipv6_set = 0;
13563 u32 mcast_sw_if_index = ~0;
13564 u32 encap_vrf_id = 0;
13565 u32 decap_next_index = ~0;
13569 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13570 memset (&src, 0, sizeof src);
13571 memset (&dst, 0, sizeof dst);
13573 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13575 if (unformat (line_input, "del"))
13578 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13584 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13590 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13596 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13601 else if (unformat (line_input, "group %U %U",
13602 unformat_ip4_address, &dst.ip4,
13603 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13605 grp_set = dst_set = 1;
13608 else if (unformat (line_input, "group %U",
13609 unformat_ip4_address, &dst.ip4))
13611 grp_set = dst_set = 1;
13614 else if (unformat (line_input, "group %U %U",
13615 unformat_ip6_address, &dst.ip6,
13616 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13618 grp_set = dst_set = 1;
13621 else if (unformat (line_input, "group %U",
13622 unformat_ip6_address, &dst.ip6))
13624 grp_set = dst_set = 1;
13628 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13630 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13632 else if (unformat (line_input, "decap-next %U",
13633 unformat_geneve_decap_next, &decap_next_index))
13635 else if (unformat (line_input, "vni %d", &vni))
13639 errmsg ("parse error '%U'", format_unformat_error, line_input);
13646 errmsg ("tunnel src address not specified");
13651 errmsg ("tunnel dst address not specified");
13655 if (grp_set && !ip46_address_is_multicast (&dst))
13657 errmsg ("tunnel group address not multicast");
13660 if (grp_set && mcast_sw_if_index == ~0)
13662 errmsg ("tunnel nonexistent multicast device");
13665 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13667 errmsg ("tunnel dst address must be unicast");
13672 if (ipv4_set && ipv6_set)
13674 errmsg ("both IPv4 and IPv6 addresses specified");
13678 if ((vni == 0) || (vni >> 24))
13680 errmsg ("vni not specified or out of range");
13684 M (GENEVE_ADD_DEL_TUNNEL, mp);
13688 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
13689 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
13693 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
13694 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
13696 mp->encap_vrf_id = ntohl (encap_vrf_id);
13697 mp->decap_next_index = ntohl (decap_next_index);
13698 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13699 mp->vni = ntohl (vni);
13700 mp->is_add = is_add;
13701 mp->is_ipv6 = ipv6_set;
13708 static void vl_api_geneve_tunnel_details_t_handler
13709 (vl_api_geneve_tunnel_details_t * mp)
13711 vat_main_t *vam = &vat_main;
13712 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13713 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13715 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
13716 ntohl (mp->sw_if_index),
13717 format_ip46_address, &src, IP46_TYPE_ANY,
13718 format_ip46_address, &dst, IP46_TYPE_ANY,
13719 ntohl (mp->encap_vrf_id),
13720 ntohl (mp->decap_next_index), ntohl (mp->vni),
13721 ntohl (mp->mcast_sw_if_index));
13724 static void vl_api_geneve_tunnel_details_t_handler_json
13725 (vl_api_geneve_tunnel_details_t * mp)
13727 vat_main_t *vam = &vat_main;
13728 vat_json_node_t *node = NULL;
13730 if (VAT_JSON_ARRAY != vam->json_tree.type)
13732 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13733 vat_json_init_array (&vam->json_tree);
13735 node = vat_json_array_add (&vam->json_tree);
13737 vat_json_init_object (node);
13738 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13741 struct in6_addr ip6;
13743 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13744 vat_json_object_add_ip6 (node, "src_address", ip6);
13745 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13746 vat_json_object_add_ip6 (node, "dst_address", ip6);
13750 struct in_addr ip4;
13752 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13753 vat_json_object_add_ip4 (node, "src_address", ip4);
13754 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13755 vat_json_object_add_ip4 (node, "dst_address", ip4);
13757 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13758 vat_json_object_add_uint (node, "decap_next_index",
13759 ntohl (mp->decap_next_index));
13760 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13761 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13762 vat_json_object_add_uint (node, "mcast_sw_if_index",
13763 ntohl (mp->mcast_sw_if_index));
13767 api_geneve_tunnel_dump (vat_main_t * vam)
13769 unformat_input_t *i = vam->input;
13770 vl_api_geneve_tunnel_dump_t *mp;
13771 vl_api_control_ping_t *mp_ping;
13773 u8 sw_if_index_set = 0;
13776 /* Parse args required to build the message */
13777 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13779 if (unformat (i, "sw_if_index %d", &sw_if_index))
13780 sw_if_index_set = 1;
13785 if (sw_if_index_set == 0)
13790 if (!vam->json_output)
13792 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
13793 "sw_if_index", "local_address", "remote_address",
13794 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13797 /* Get list of geneve-tunnel interfaces */
13798 M (GENEVE_TUNNEL_DUMP, mp);
13800 mp->sw_if_index = htonl (sw_if_index);
13804 /* Use a control ping for synchronization */
13805 M (CONTROL_PING, mp_ping);
13813 api_gre_add_del_tunnel (vat_main_t * vam)
13815 unformat_input_t *line_input = vam->input;
13816 vl_api_gre_add_del_tunnel_t *mp;
13817 ip4_address_t src4, dst4;
13818 ip6_address_t src6, dst6;
13822 u8 t_type = GRE_TUNNEL_TYPE_L3;
13825 u32 outer_fib_id = 0;
13826 u32 session_id = 0;
13830 memset (&src4, 0, sizeof src4);
13831 memset (&dst4, 0, sizeof dst4);
13832 memset (&src6, 0, sizeof src6);
13833 memset (&dst6, 0, sizeof dst6);
13835 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13837 if (unformat (line_input, "del"))
13839 else if (unformat (line_input, "instance %d", &instance))
13841 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
13846 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
13851 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
13856 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
13861 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
13863 else if (unformat (line_input, "teb"))
13864 t_type = GRE_TUNNEL_TYPE_TEB;
13865 else if (unformat (line_input, "erspan %d", &session_id))
13866 t_type = GRE_TUNNEL_TYPE_ERSPAN;
13869 errmsg ("parse error '%U'", format_unformat_error, line_input);
13876 errmsg ("tunnel src address not specified");
13881 errmsg ("tunnel dst address not specified");
13884 if (ipv4_set && ipv6_set)
13886 errmsg ("both IPv4 and IPv6 addresses specified");
13891 M (GRE_ADD_DEL_TUNNEL, mp);
13895 clib_memcpy (&mp->src_address, &src4, 4);
13896 clib_memcpy (&mp->dst_address, &dst4, 4);
13900 clib_memcpy (&mp->src_address, &src6, 16);
13901 clib_memcpy (&mp->dst_address, &dst6, 16);
13903 mp->instance = htonl (instance);
13904 mp->outer_fib_id = htonl (outer_fib_id);
13905 mp->is_add = is_add;
13906 mp->session_id = htons ((u16) session_id);
13907 mp->tunnel_type = t_type;
13908 mp->is_ipv6 = ipv6_set;
13915 static void vl_api_gre_tunnel_details_t_handler
13916 (vl_api_gre_tunnel_details_t * mp)
13918 vat_main_t *vam = &vat_main;
13919 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
13920 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
13922 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
13923 ntohl (mp->sw_if_index),
13924 ntohl (mp->instance),
13925 format_ip46_address, &src, IP46_TYPE_ANY,
13926 format_ip46_address, &dst, IP46_TYPE_ANY,
13927 mp->tunnel_type, ntohl (mp->outer_fib_id), ntohl (mp->session_id));
13930 static void vl_api_gre_tunnel_details_t_handler_json
13931 (vl_api_gre_tunnel_details_t * mp)
13933 vat_main_t *vam = &vat_main;
13934 vat_json_node_t *node = NULL;
13935 struct in_addr ip4;
13936 struct in6_addr ip6;
13938 if (VAT_JSON_ARRAY != vam->json_tree.type)
13940 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13941 vat_json_init_array (&vam->json_tree);
13943 node = vat_json_array_add (&vam->json_tree);
13945 vat_json_init_object (node);
13946 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13947 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13950 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
13951 vat_json_object_add_ip4 (node, "src_address", ip4);
13952 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
13953 vat_json_object_add_ip4 (node, "dst_address", ip4);
13957 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
13958 vat_json_object_add_ip6 (node, "src_address", ip6);
13959 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
13960 vat_json_object_add_ip6 (node, "dst_address", ip6);
13962 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel_type);
13963 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
13964 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
13965 vat_json_object_add_uint (node, "session_id", mp->session_id);
13969 api_gre_tunnel_dump (vat_main_t * vam)
13971 unformat_input_t *i = vam->input;
13972 vl_api_gre_tunnel_dump_t *mp;
13973 vl_api_control_ping_t *mp_ping;
13975 u8 sw_if_index_set = 0;
13978 /* Parse args required to build the message */
13979 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13981 if (unformat (i, "sw_if_index %d", &sw_if_index))
13982 sw_if_index_set = 1;
13987 if (sw_if_index_set == 0)
13992 if (!vam->json_output)
13994 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
13995 "sw_if_index", "instance", "src_address", "dst_address",
13996 "tunnel_type", "outer_fib_id", "session_id");
13999 /* Get list of gre-tunnel interfaces */
14000 M (GRE_TUNNEL_DUMP, mp);
14002 mp->sw_if_index = htonl (sw_if_index);
14006 /* Use a control ping for synchronization */
14007 MPING (CONTROL_PING, mp_ping);
14015 api_l2_fib_clear_table (vat_main_t * vam)
14017 // unformat_input_t * i = vam->input;
14018 vl_api_l2_fib_clear_table_t *mp;
14021 M (L2_FIB_CLEAR_TABLE, mp);
14029 api_l2_interface_efp_filter (vat_main_t * vam)
14031 unformat_input_t *i = vam->input;
14032 vl_api_l2_interface_efp_filter_t *mp;
14035 u8 sw_if_index_set = 0;
14038 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14040 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14041 sw_if_index_set = 1;
14042 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14043 sw_if_index_set = 1;
14044 else if (unformat (i, "enable"))
14046 else if (unformat (i, "disable"))
14050 clib_warning ("parse error '%U'", format_unformat_error, i);
14055 if (sw_if_index_set == 0)
14057 errmsg ("missing sw_if_index");
14061 M (L2_INTERFACE_EFP_FILTER, mp);
14063 mp->sw_if_index = ntohl (sw_if_index);
14064 mp->enable_disable = enable;
14071 #define foreach_vtr_op \
14072 _("disable", L2_VTR_DISABLED) \
14073 _("push-1", L2_VTR_PUSH_1) \
14074 _("push-2", L2_VTR_PUSH_2) \
14075 _("pop-1", L2_VTR_POP_1) \
14076 _("pop-2", L2_VTR_POP_2) \
14077 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
14078 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
14079 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
14080 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
14083 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
14085 unformat_input_t *i = vam->input;
14086 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
14088 u8 sw_if_index_set = 0;
14091 u32 push_dot1q = 1;
14096 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14098 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14099 sw_if_index_set = 1;
14100 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14101 sw_if_index_set = 1;
14102 else if (unformat (i, "vtr_op %d", &vtr_op))
14104 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
14107 else if (unformat (i, "push_dot1q %d", &push_dot1q))
14109 else if (unformat (i, "tag1 %d", &tag1))
14111 else if (unformat (i, "tag2 %d", &tag2))
14115 clib_warning ("parse error '%U'", format_unformat_error, i);
14120 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
14122 errmsg ("missing vtr operation or sw_if_index");
14126 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
14127 mp->sw_if_index = ntohl (sw_if_index);
14128 mp->vtr_op = ntohl (vtr_op);
14129 mp->push_dot1q = ntohl (push_dot1q);
14130 mp->tag1 = ntohl (tag1);
14131 mp->tag2 = ntohl (tag2);
14139 api_create_vhost_user_if (vat_main_t * vam)
14141 unformat_input_t *i = vam->input;
14142 vl_api_create_vhost_user_if_t *mp;
14145 u8 file_name_set = 0;
14146 u32 custom_dev_instance = ~0;
14148 u8 use_custom_mac = 0;
14149 u8 disable_mrg_rxbuf = 0;
14150 u8 disable_indirect_desc = 0;
14154 /* Shut up coverity */
14155 memset (hwaddr, 0, sizeof (hwaddr));
14157 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14159 if (unformat (i, "socket %s", &file_name))
14163 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
14165 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
14166 use_custom_mac = 1;
14167 else if (unformat (i, "server"))
14169 else if (unformat (i, "disable_mrg_rxbuf"))
14170 disable_mrg_rxbuf = 1;
14171 else if (unformat (i, "disable_indirect_desc"))
14172 disable_indirect_desc = 1;
14173 else if (unformat (i, "tag %s", &tag))
14179 if (file_name_set == 0)
14181 errmsg ("missing socket file name");
14185 if (vec_len (file_name) > 255)
14187 errmsg ("socket file name too long");
14190 vec_add1 (file_name, 0);
14192 M (CREATE_VHOST_USER_IF, mp);
14194 mp->is_server = is_server;
14195 mp->disable_mrg_rxbuf = disable_mrg_rxbuf;
14196 mp->disable_indirect_desc = disable_indirect_desc;
14197 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
14198 vec_free (file_name);
14199 if (custom_dev_instance != ~0)
14202 mp->custom_dev_instance = ntohl (custom_dev_instance);
14205 mp->use_custom_mac = use_custom_mac;
14206 clib_memcpy (mp->mac_address, hwaddr, 6);
14208 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
14217 api_modify_vhost_user_if (vat_main_t * vam)
14219 unformat_input_t *i = vam->input;
14220 vl_api_modify_vhost_user_if_t *mp;
14223 u8 file_name_set = 0;
14224 u32 custom_dev_instance = ~0;
14225 u8 sw_if_index_set = 0;
14226 u32 sw_if_index = (u32) ~ 0;
14229 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14231 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14232 sw_if_index_set = 1;
14233 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14234 sw_if_index_set = 1;
14235 else if (unformat (i, "socket %s", &file_name))
14239 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
14241 else if (unformat (i, "server"))
14247 if (sw_if_index_set == 0)
14249 errmsg ("missing sw_if_index or interface name");
14253 if (file_name_set == 0)
14255 errmsg ("missing socket file name");
14259 if (vec_len (file_name) > 255)
14261 errmsg ("socket file name too long");
14264 vec_add1 (file_name, 0);
14266 M (MODIFY_VHOST_USER_IF, mp);
14268 mp->sw_if_index = ntohl (sw_if_index);
14269 mp->is_server = is_server;
14270 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
14271 vec_free (file_name);
14272 if (custom_dev_instance != ~0)
14275 mp->custom_dev_instance = ntohl (custom_dev_instance);
14284 api_delete_vhost_user_if (vat_main_t * vam)
14286 unformat_input_t *i = vam->input;
14287 vl_api_delete_vhost_user_if_t *mp;
14288 u32 sw_if_index = ~0;
14289 u8 sw_if_index_set = 0;
14292 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14294 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14295 sw_if_index_set = 1;
14296 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14297 sw_if_index_set = 1;
14302 if (sw_if_index_set == 0)
14304 errmsg ("missing sw_if_index or interface name");
14309 M (DELETE_VHOST_USER_IF, mp);
14311 mp->sw_if_index = ntohl (sw_if_index);
14318 static void vl_api_sw_interface_vhost_user_details_t_handler
14319 (vl_api_sw_interface_vhost_user_details_t * mp)
14321 vat_main_t *vam = &vat_main;
14323 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
14324 (char *) mp->interface_name,
14325 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
14326 clib_net_to_host_u64 (mp->features), mp->is_server,
14327 ntohl (mp->num_regions), (char *) mp->sock_filename);
14328 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
14331 static void vl_api_sw_interface_vhost_user_details_t_handler_json
14332 (vl_api_sw_interface_vhost_user_details_t * mp)
14334 vat_main_t *vam = &vat_main;
14335 vat_json_node_t *node = NULL;
14337 if (VAT_JSON_ARRAY != vam->json_tree.type)
14339 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14340 vat_json_init_array (&vam->json_tree);
14342 node = vat_json_array_add (&vam->json_tree);
14344 vat_json_init_object (node);
14345 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14346 vat_json_object_add_string_copy (node, "interface_name",
14347 mp->interface_name);
14348 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
14349 ntohl (mp->virtio_net_hdr_sz));
14350 vat_json_object_add_uint (node, "features",
14351 clib_net_to_host_u64 (mp->features));
14352 vat_json_object_add_uint (node, "is_server", mp->is_server);
14353 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
14354 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
14355 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
14359 api_sw_interface_vhost_user_dump (vat_main_t * vam)
14361 vl_api_sw_interface_vhost_user_dump_t *mp;
14362 vl_api_control_ping_t *mp_ping;
14365 "Interface name idx hdr_sz features server regions filename");
14367 /* Get list of vhost-user interfaces */
14368 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
14371 /* Use a control ping for synchronization */
14372 MPING (CONTROL_PING, mp_ping);
14380 api_show_version (vat_main_t * vam)
14382 vl_api_show_version_t *mp;
14385 M (SHOW_VERSION, mp);
14394 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
14396 unformat_input_t *line_input = vam->input;
14397 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
14398 ip4_address_t local4, remote4;
14399 ip6_address_t local6, remote6;
14401 u8 ipv4_set = 0, ipv6_set = 0;
14405 u32 mcast_sw_if_index = ~0;
14406 u32 encap_vrf_id = 0;
14407 u32 decap_vrf_id = 0;
14413 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
14414 memset (&local4, 0, sizeof local4);
14415 memset (&remote4, 0, sizeof remote4);
14416 memset (&local6, 0, sizeof local6);
14417 memset (&remote6, 0, sizeof remote6);
14419 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14421 if (unformat (line_input, "del"))
14423 else if (unformat (line_input, "local %U",
14424 unformat_ip4_address, &local4))
14429 else if (unformat (line_input, "remote %U",
14430 unformat_ip4_address, &remote4))
14435 else if (unformat (line_input, "local %U",
14436 unformat_ip6_address, &local6))
14441 else if (unformat (line_input, "remote %U",
14442 unformat_ip6_address, &remote6))
14447 else if (unformat (line_input, "group %U %U",
14448 unformat_ip4_address, &remote4,
14449 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14451 grp_set = remote_set = 1;
14454 else if (unformat (line_input, "group %U",
14455 unformat_ip4_address, &remote4))
14457 grp_set = remote_set = 1;
14460 else if (unformat (line_input, "group %U %U",
14461 unformat_ip6_address, &remote6,
14462 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14464 grp_set = remote_set = 1;
14467 else if (unformat (line_input, "group %U",
14468 unformat_ip6_address, &remote6))
14470 grp_set = remote_set = 1;
14474 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
14476 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
14478 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
14480 else if (unformat (line_input, "vni %d", &vni))
14482 else if (unformat (line_input, "next-ip4"))
14484 else if (unformat (line_input, "next-ip6"))
14486 else if (unformat (line_input, "next-ethernet"))
14488 else if (unformat (line_input, "next-nsh"))
14492 errmsg ("parse error '%U'", format_unformat_error, line_input);
14497 if (local_set == 0)
14499 errmsg ("tunnel local address not specified");
14502 if (remote_set == 0)
14504 errmsg ("tunnel remote address not specified");
14507 if (grp_set && mcast_sw_if_index == ~0)
14509 errmsg ("tunnel nonexistent multicast device");
14512 if (ipv4_set && ipv6_set)
14514 errmsg ("both IPv4 and IPv6 addresses specified");
14520 errmsg ("vni not specified");
14524 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
14529 clib_memcpy (&mp->local, &local6, sizeof (local6));
14530 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
14534 clib_memcpy (&mp->local, &local4, sizeof (local4));
14535 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
14538 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
14539 mp->encap_vrf_id = ntohl (encap_vrf_id);
14540 mp->decap_vrf_id = ntohl (decap_vrf_id);
14541 mp->protocol = protocol;
14542 mp->vni = ntohl (vni);
14543 mp->is_add = is_add;
14544 mp->is_ipv6 = ipv6_set;
14551 static void vl_api_vxlan_gpe_tunnel_details_t_handler
14552 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14554 vat_main_t *vam = &vat_main;
14555 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
14556 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
14558 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
14559 ntohl (mp->sw_if_index),
14560 format_ip46_address, &local, IP46_TYPE_ANY,
14561 format_ip46_address, &remote, IP46_TYPE_ANY,
14562 ntohl (mp->vni), mp->protocol,
14563 ntohl (mp->mcast_sw_if_index),
14564 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
14568 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
14569 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14571 vat_main_t *vam = &vat_main;
14572 vat_json_node_t *node = NULL;
14573 struct in_addr ip4;
14574 struct in6_addr ip6;
14576 if (VAT_JSON_ARRAY != vam->json_tree.type)
14578 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14579 vat_json_init_array (&vam->json_tree);
14581 node = vat_json_array_add (&vam->json_tree);
14583 vat_json_init_object (node);
14584 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14587 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
14588 vat_json_object_add_ip6 (node, "local", ip6);
14589 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
14590 vat_json_object_add_ip6 (node, "remote", ip6);
14594 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
14595 vat_json_object_add_ip4 (node, "local", ip4);
14596 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
14597 vat_json_object_add_ip4 (node, "remote", ip4);
14599 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
14600 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
14601 vat_json_object_add_uint (node, "mcast_sw_if_index",
14602 ntohl (mp->mcast_sw_if_index));
14603 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
14604 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
14605 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
14609 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
14611 unformat_input_t *i = vam->input;
14612 vl_api_vxlan_gpe_tunnel_dump_t *mp;
14613 vl_api_control_ping_t *mp_ping;
14615 u8 sw_if_index_set = 0;
14618 /* Parse args required to build the message */
14619 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14621 if (unformat (i, "sw_if_index %d", &sw_if_index))
14622 sw_if_index_set = 1;
14627 if (sw_if_index_set == 0)
14632 if (!vam->json_output)
14634 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
14635 "sw_if_index", "local", "remote", "vni",
14636 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
14639 /* Get list of vxlan-tunnel interfaces */
14640 M (VXLAN_GPE_TUNNEL_DUMP, mp);
14642 mp->sw_if_index = htonl (sw_if_index);
14646 /* Use a control ping for synchronization */
14647 MPING (CONTROL_PING, mp_ping);
14654 static void vl_api_l2_fib_table_details_t_handler
14655 (vl_api_l2_fib_table_details_t * mp)
14657 vat_main_t *vam = &vat_main;
14659 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
14661 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
14662 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
14666 static void vl_api_l2_fib_table_details_t_handler_json
14667 (vl_api_l2_fib_table_details_t * mp)
14669 vat_main_t *vam = &vat_main;
14670 vat_json_node_t *node = NULL;
14672 if (VAT_JSON_ARRAY != vam->json_tree.type)
14674 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14675 vat_json_init_array (&vam->json_tree);
14677 node = vat_json_array_add (&vam->json_tree);
14679 vat_json_init_object (node);
14680 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
14681 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
14682 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14683 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
14684 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
14685 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
14689 api_l2_fib_table_dump (vat_main_t * vam)
14691 unformat_input_t *i = vam->input;
14692 vl_api_l2_fib_table_dump_t *mp;
14693 vl_api_control_ping_t *mp_ping;
14698 /* Parse args required to build the message */
14699 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14701 if (unformat (i, "bd_id %d", &bd_id))
14707 if (bd_id_set == 0)
14709 errmsg ("missing bridge domain");
14713 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
14715 /* Get list of l2 fib entries */
14716 M (L2_FIB_TABLE_DUMP, mp);
14718 mp->bd_id = ntohl (bd_id);
14721 /* Use a control ping for synchronization */
14722 MPING (CONTROL_PING, mp_ping);
14731 api_interface_name_renumber (vat_main_t * vam)
14733 unformat_input_t *line_input = vam->input;
14734 vl_api_interface_name_renumber_t *mp;
14735 u32 sw_if_index = ~0;
14736 u32 new_show_dev_instance = ~0;
14739 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14741 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
14744 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14746 else if (unformat (line_input, "new_show_dev_instance %d",
14747 &new_show_dev_instance))
14753 if (sw_if_index == ~0)
14755 errmsg ("missing interface name or sw_if_index");
14759 if (new_show_dev_instance == ~0)
14761 errmsg ("missing new_show_dev_instance");
14765 M (INTERFACE_NAME_RENUMBER, mp);
14767 mp->sw_if_index = ntohl (sw_if_index);
14768 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
14776 api_ip_probe_neighbor (vat_main_t * vam)
14778 unformat_input_t *i = vam->input;
14779 vl_api_ip_probe_neighbor_t *mp;
14787 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14789 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14791 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14793 else if (unformat (i, "address %U", unformat_ip4_address, dst_adr))
14795 else if (unformat (i, "address %U", unformat_ip6_address, dst_adr))
14806 errmsg ("missing interface");
14812 errmsg ("missing addresses");
14816 M (IP_PROBE_NEIGHBOR, mp);
14818 mp->sw_if_index = ntohl (sw_if_index);
14819 mp->is_ipv6 = is_ipv6;
14820 clib_memcpy (mp->dst_address, dst_adr, sizeof (dst_adr));
14828 api_ip_scan_neighbor_enable_disable (vat_main_t * vam)
14830 unformat_input_t *i = vam->input;
14831 vl_api_ip_scan_neighbor_enable_disable_t *mp;
14832 u8 mode = IP_SCAN_V46_NEIGHBORS;
14833 u32 interval = 0, time = 0, update = 0, delay = 0, stale = 0;
14836 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14838 if (unformat (i, "ip4"))
14839 mode = IP_SCAN_V4_NEIGHBORS;
14840 else if (unformat (i, "ip6"))
14841 mode = IP_SCAN_V6_NEIGHBORS;
14842 if (unformat (i, "both"))
14843 mode = IP_SCAN_V46_NEIGHBORS;
14844 else if (unformat (i, "disable"))
14845 mode = IP_SCAN_DISABLED;
14846 else if (unformat (i, "interval %d", &interval))
14848 else if (unformat (i, "max-time %d", &time))
14850 else if (unformat (i, "max-update %d", &update))
14852 else if (unformat (i, "delay %d", &delay))
14854 else if (unformat (i, "stale %d", &stale))
14860 if (interval > 255)
14862 errmsg ("interval cannot exceed 255 minutes.");
14867 errmsg ("max-time cannot exceed 255 usec.");
14872 errmsg ("max-update cannot exceed 255.");
14877 errmsg ("delay cannot exceed 255 msec.");
14882 errmsg ("stale cannot exceed 255 minutes.");
14886 M (IP_SCAN_NEIGHBOR_ENABLE_DISABLE, mp);
14888 mp->scan_interval = interval;
14889 mp->max_proc_time = time;
14890 mp->max_update = update;
14891 mp->scan_int_delay = delay;
14892 mp->stale_threshold = stale;
14900 api_want_ip4_arp_events (vat_main_t * vam)
14902 unformat_input_t *line_input = vam->input;
14903 vl_api_want_ip4_arp_events_t *mp;
14904 ip4_address_t address;
14905 int address_set = 0;
14906 u32 enable_disable = 1;
14909 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14911 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
14913 else if (unformat (line_input, "del"))
14914 enable_disable = 0;
14919 if (address_set == 0)
14921 errmsg ("missing addresses");
14925 M (WANT_IP4_ARP_EVENTS, mp);
14926 mp->enable_disable = enable_disable;
14927 mp->pid = htonl (getpid ());
14928 mp->address = address.as_u32;
14936 api_want_ip6_nd_events (vat_main_t * vam)
14938 unformat_input_t *line_input = vam->input;
14939 vl_api_want_ip6_nd_events_t *mp;
14940 ip6_address_t address;
14941 int address_set = 0;
14942 u32 enable_disable = 1;
14945 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14947 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
14949 else if (unformat (line_input, "del"))
14950 enable_disable = 0;
14955 if (address_set == 0)
14957 errmsg ("missing addresses");
14961 M (WANT_IP6_ND_EVENTS, mp);
14962 mp->enable_disable = enable_disable;
14963 mp->pid = htonl (getpid ());
14964 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
14972 api_want_l2_macs_events (vat_main_t * vam)
14974 unformat_input_t *line_input = vam->input;
14975 vl_api_want_l2_macs_events_t *mp;
14976 u8 enable_disable = 1;
14977 u32 scan_delay = 0;
14978 u32 max_macs_in_event = 0;
14979 u32 learn_limit = 0;
14982 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14984 if (unformat (line_input, "learn-limit %d", &learn_limit))
14986 else if (unformat (line_input, "scan-delay %d", &scan_delay))
14988 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
14990 else if (unformat (line_input, "disable"))
14991 enable_disable = 0;
14996 M (WANT_L2_MACS_EVENTS, mp);
14997 mp->enable_disable = enable_disable;
14998 mp->pid = htonl (getpid ());
14999 mp->learn_limit = htonl (learn_limit);
15000 mp->scan_delay = (u8) scan_delay;
15001 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
15008 api_input_acl_set_interface (vat_main_t * vam)
15010 unformat_input_t *i = vam->input;
15011 vl_api_input_acl_set_interface_t *mp;
15013 int sw_if_index_set;
15014 u32 ip4_table_index = ~0;
15015 u32 ip6_table_index = ~0;
15016 u32 l2_table_index = ~0;
15020 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15022 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15023 sw_if_index_set = 1;
15024 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15025 sw_if_index_set = 1;
15026 else if (unformat (i, "del"))
15028 else if (unformat (i, "ip4-table %d", &ip4_table_index))
15030 else if (unformat (i, "ip6-table %d", &ip6_table_index))
15032 else if (unformat (i, "l2-table %d", &l2_table_index))
15036 clib_warning ("parse error '%U'", format_unformat_error, i);
15041 if (sw_if_index_set == 0)
15043 errmsg ("missing interface name or sw_if_index");
15047 M (INPUT_ACL_SET_INTERFACE, mp);
15049 mp->sw_if_index = ntohl (sw_if_index);
15050 mp->ip4_table_index = ntohl (ip4_table_index);
15051 mp->ip6_table_index = ntohl (ip6_table_index);
15052 mp->l2_table_index = ntohl (l2_table_index);
15053 mp->is_add = is_add;
15061 api_output_acl_set_interface (vat_main_t * vam)
15063 unformat_input_t *i = vam->input;
15064 vl_api_output_acl_set_interface_t *mp;
15066 int sw_if_index_set;
15067 u32 ip4_table_index = ~0;
15068 u32 ip6_table_index = ~0;
15069 u32 l2_table_index = ~0;
15073 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15075 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15076 sw_if_index_set = 1;
15077 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15078 sw_if_index_set = 1;
15079 else if (unformat (i, "del"))
15081 else if (unformat (i, "ip4-table %d", &ip4_table_index))
15083 else if (unformat (i, "ip6-table %d", &ip6_table_index))
15085 else if (unformat (i, "l2-table %d", &l2_table_index))
15089 clib_warning ("parse error '%U'", format_unformat_error, i);
15094 if (sw_if_index_set == 0)
15096 errmsg ("missing interface name or sw_if_index");
15100 M (OUTPUT_ACL_SET_INTERFACE, mp);
15102 mp->sw_if_index = ntohl (sw_if_index);
15103 mp->ip4_table_index = ntohl (ip4_table_index);
15104 mp->ip6_table_index = ntohl (ip6_table_index);
15105 mp->l2_table_index = ntohl (l2_table_index);
15106 mp->is_add = is_add;
15114 api_ip_address_dump (vat_main_t * vam)
15116 unformat_input_t *i = vam->input;
15117 vl_api_ip_address_dump_t *mp;
15118 vl_api_control_ping_t *mp_ping;
15119 u32 sw_if_index = ~0;
15120 u8 sw_if_index_set = 0;
15125 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15127 if (unformat (i, "sw_if_index %d", &sw_if_index))
15128 sw_if_index_set = 1;
15130 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15131 sw_if_index_set = 1;
15132 else if (unformat (i, "ipv4"))
15134 else if (unformat (i, "ipv6"))
15140 if (ipv4_set && ipv6_set)
15142 errmsg ("ipv4 and ipv6 flags cannot be both set");
15146 if ((!ipv4_set) && (!ipv6_set))
15148 errmsg ("no ipv4 nor ipv6 flag set");
15152 if (sw_if_index_set == 0)
15154 errmsg ("missing interface name or sw_if_index");
15158 vam->current_sw_if_index = sw_if_index;
15159 vam->is_ipv6 = ipv6_set;
15161 M (IP_ADDRESS_DUMP, mp);
15162 mp->sw_if_index = ntohl (sw_if_index);
15163 mp->is_ipv6 = ipv6_set;
15166 /* Use a control ping for synchronization */
15167 MPING (CONTROL_PING, mp_ping);
15175 api_ip_dump (vat_main_t * vam)
15177 vl_api_ip_dump_t *mp;
15178 vl_api_control_ping_t *mp_ping;
15179 unformat_input_t *in = vam->input;
15186 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
15188 if (unformat (in, "ipv4"))
15190 else if (unformat (in, "ipv6"))
15196 if (ipv4_set && ipv6_set)
15198 errmsg ("ipv4 and ipv6 flags cannot be both set");
15202 if ((!ipv4_set) && (!ipv6_set))
15204 errmsg ("no ipv4 nor ipv6 flag set");
15208 is_ipv6 = ipv6_set;
15209 vam->is_ipv6 = is_ipv6;
15211 /* free old data */
15212 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
15214 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
15216 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
15219 mp->is_ipv6 = ipv6_set;
15222 /* Use a control ping for synchronization */
15223 MPING (CONTROL_PING, mp_ping);
15231 api_ipsec_spd_add_del (vat_main_t * vam)
15233 unformat_input_t *i = vam->input;
15234 vl_api_ipsec_spd_add_del_t *mp;
15239 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15241 if (unformat (i, "spd_id %d", &spd_id))
15243 else if (unformat (i, "del"))
15247 clib_warning ("parse error '%U'", format_unformat_error, i);
15253 errmsg ("spd_id must be set");
15257 M (IPSEC_SPD_ADD_DEL, mp);
15259 mp->spd_id = ntohl (spd_id);
15260 mp->is_add = is_add;
15268 api_ipsec_interface_add_del_spd (vat_main_t * vam)
15270 unformat_input_t *i = vam->input;
15271 vl_api_ipsec_interface_add_del_spd_t *mp;
15273 u8 sw_if_index_set = 0;
15274 u32 spd_id = (u32) ~ 0;
15278 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15280 if (unformat (i, "del"))
15282 else if (unformat (i, "spd_id %d", &spd_id))
15285 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15286 sw_if_index_set = 1;
15287 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15288 sw_if_index_set = 1;
15291 clib_warning ("parse error '%U'", format_unformat_error, i);
15297 if (spd_id == (u32) ~ 0)
15299 errmsg ("spd_id must be set");
15303 if (sw_if_index_set == 0)
15305 errmsg ("missing interface name or sw_if_index");
15309 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
15311 mp->spd_id = ntohl (spd_id);
15312 mp->sw_if_index = ntohl (sw_if_index);
15313 mp->is_add = is_add;
15321 api_ipsec_spd_add_del_entry (vat_main_t * vam)
15323 unformat_input_t *i = vam->input;
15324 vl_api_ipsec_spd_add_del_entry_t *mp;
15325 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
15326 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
15328 u32 rport_start = 0, rport_stop = (u32) ~ 0;
15329 u32 lport_start = 0, lport_stop = (u32) ~ 0;
15330 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
15331 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
15334 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
15335 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
15336 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
15337 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
15338 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
15339 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
15341 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15343 if (unformat (i, "del"))
15345 if (unformat (i, "outbound"))
15347 if (unformat (i, "inbound"))
15349 else if (unformat (i, "spd_id %d", &spd_id))
15351 else if (unformat (i, "sa_id %d", &sa_id))
15353 else if (unformat (i, "priority %d", &priority))
15355 else if (unformat (i, "protocol %d", &protocol))
15357 else if (unformat (i, "lport_start %d", &lport_start))
15359 else if (unformat (i, "lport_stop %d", &lport_stop))
15361 else if (unformat (i, "rport_start %d", &rport_start))
15363 else if (unformat (i, "rport_stop %d", &rport_stop))
15367 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
15373 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
15380 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
15386 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
15393 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
15399 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
15406 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
15412 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
15418 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
15420 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
15422 clib_warning ("unsupported action: 'resolve'");
15428 clib_warning ("parse error '%U'", format_unformat_error, i);
15434 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
15436 mp->spd_id = ntohl (spd_id);
15437 mp->priority = ntohl (priority);
15438 mp->is_outbound = is_outbound;
15440 mp->is_ipv6 = is_ipv6;
15441 if (is_ipv6 || is_ip_any)
15443 clib_memcpy (mp->remote_address_start, &raddr6_start,
15444 sizeof (ip6_address_t));
15445 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
15446 sizeof (ip6_address_t));
15447 clib_memcpy (mp->local_address_start, &laddr6_start,
15448 sizeof (ip6_address_t));
15449 clib_memcpy (mp->local_address_stop, &laddr6_stop,
15450 sizeof (ip6_address_t));
15454 clib_memcpy (mp->remote_address_start, &raddr4_start,
15455 sizeof (ip4_address_t));
15456 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
15457 sizeof (ip4_address_t));
15458 clib_memcpy (mp->local_address_start, &laddr4_start,
15459 sizeof (ip4_address_t));
15460 clib_memcpy (mp->local_address_stop, &laddr4_stop,
15461 sizeof (ip4_address_t));
15463 mp->protocol = (u8) protocol;
15464 mp->local_port_start = ntohs ((u16) lport_start);
15465 mp->local_port_stop = ntohs ((u16) lport_stop);
15466 mp->remote_port_start = ntohs ((u16) rport_start);
15467 mp->remote_port_stop = ntohs ((u16) rport_stop);
15468 mp->policy = (u8) policy;
15469 mp->sa_id = ntohl (sa_id);
15470 mp->is_add = is_add;
15471 mp->is_ip_any = is_ip_any;
15478 api_ipsec_sad_add_del_entry (vat_main_t * vam)
15480 unformat_input_t *i = vam->input;
15481 vl_api_ipsec_sad_add_del_entry_t *mp;
15482 u32 sad_id = 0, spi = 0;
15483 u8 *ck = 0, *ik = 0;
15486 u8 protocol = IPSEC_PROTOCOL_AH;
15487 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
15488 u32 crypto_alg = 0, integ_alg = 0;
15489 ip4_address_t tun_src4;
15490 ip4_address_t tun_dst4;
15491 ip6_address_t tun_src6;
15492 ip6_address_t tun_dst6;
15495 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15497 if (unformat (i, "del"))
15499 else if (unformat (i, "sad_id %d", &sad_id))
15501 else if (unformat (i, "spi %d", &spi))
15503 else if (unformat (i, "esp"))
15504 protocol = IPSEC_PROTOCOL_ESP;
15505 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
15508 is_tunnel_ipv6 = 0;
15510 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
15513 is_tunnel_ipv6 = 0;
15515 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
15518 is_tunnel_ipv6 = 1;
15520 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
15523 is_tunnel_ipv6 = 1;
15527 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15529 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
15531 clib_warning ("unsupported crypto-alg: '%U'",
15532 format_ipsec_crypto_alg, crypto_alg);
15536 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15540 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15542 if (integ_alg >= IPSEC_INTEG_N_ALG)
15544 clib_warning ("unsupported integ-alg: '%U'",
15545 format_ipsec_integ_alg, integ_alg);
15549 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15553 clib_warning ("parse error '%U'", format_unformat_error, i);
15559 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
15561 mp->sad_id = ntohl (sad_id);
15562 mp->is_add = is_add;
15563 mp->protocol = protocol;
15564 mp->spi = ntohl (spi);
15565 mp->is_tunnel = is_tunnel;
15566 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
15567 mp->crypto_algorithm = crypto_alg;
15568 mp->integrity_algorithm = integ_alg;
15569 mp->crypto_key_length = vec_len (ck);
15570 mp->integrity_key_length = vec_len (ik);
15572 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15573 mp->crypto_key_length = sizeof (mp->crypto_key);
15575 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15576 mp->integrity_key_length = sizeof (mp->integrity_key);
15579 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15581 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15585 if (is_tunnel_ipv6)
15587 clib_memcpy (mp->tunnel_src_address, &tun_src6,
15588 sizeof (ip6_address_t));
15589 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
15590 sizeof (ip6_address_t));
15594 clib_memcpy (mp->tunnel_src_address, &tun_src4,
15595 sizeof (ip4_address_t));
15596 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
15597 sizeof (ip4_address_t));
15607 api_ipsec_sa_set_key (vat_main_t * vam)
15609 unformat_input_t *i = vam->input;
15610 vl_api_ipsec_sa_set_key_t *mp;
15612 u8 *ck = 0, *ik = 0;
15615 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15617 if (unformat (i, "sa_id %d", &sa_id))
15619 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15621 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15625 clib_warning ("parse error '%U'", format_unformat_error, i);
15630 M (IPSEC_SA_SET_KEY, mp);
15632 mp->sa_id = ntohl (sa_id);
15633 mp->crypto_key_length = vec_len (ck);
15634 mp->integrity_key_length = vec_len (ik);
15636 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15637 mp->crypto_key_length = sizeof (mp->crypto_key);
15639 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15640 mp->integrity_key_length = sizeof (mp->integrity_key);
15643 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15645 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15653 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
15655 unformat_input_t *i = vam->input;
15656 vl_api_ipsec_tunnel_if_add_del_t *mp;
15657 u32 local_spi = 0, remote_spi = 0;
15658 u32 crypto_alg = 0, integ_alg = 0;
15659 u8 *lck = NULL, *rck = NULL;
15660 u8 *lik = NULL, *rik = NULL;
15661 ip4_address_t local_ip = { {0} };
15662 ip4_address_t remote_ip = { {0} };
15665 u8 anti_replay = 0;
15670 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15672 if (unformat (i, "del"))
15674 else if (unformat (i, "esn"))
15676 else if (unformat (i, "anti_replay"))
15678 else if (unformat (i, "local_spi %d", &local_spi))
15680 else if (unformat (i, "remote_spi %d", &remote_spi))
15682 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
15684 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
15686 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
15689 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
15691 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
15693 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
15697 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15699 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
15701 errmsg ("unsupported crypto-alg: '%U'\n",
15702 format_ipsec_crypto_alg, crypto_alg);
15708 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15710 if (integ_alg >= IPSEC_INTEG_N_ALG)
15712 errmsg ("unsupported integ-alg: '%U'\n",
15713 format_ipsec_integ_alg, integ_alg);
15717 else if (unformat (i, "instance %u", &instance))
15721 errmsg ("parse error '%U'\n", format_unformat_error, i);
15726 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
15728 mp->is_add = is_add;
15730 mp->anti_replay = anti_replay;
15732 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
15733 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
15735 mp->local_spi = htonl (local_spi);
15736 mp->remote_spi = htonl (remote_spi);
15737 mp->crypto_alg = (u8) crypto_alg;
15739 mp->local_crypto_key_len = 0;
15742 mp->local_crypto_key_len = vec_len (lck);
15743 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
15744 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
15745 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
15748 mp->remote_crypto_key_len = 0;
15751 mp->remote_crypto_key_len = vec_len (rck);
15752 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
15753 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
15754 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
15757 mp->integ_alg = (u8) integ_alg;
15759 mp->local_integ_key_len = 0;
15762 mp->local_integ_key_len = vec_len (lik);
15763 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
15764 mp->local_integ_key_len = sizeof (mp->local_integ_key);
15765 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
15768 mp->remote_integ_key_len = 0;
15771 mp->remote_integ_key_len = vec_len (rik);
15772 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
15773 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
15774 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
15779 mp->renumber = renumber;
15780 mp->show_instance = ntohl (instance);
15789 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
15791 vat_main_t *vam = &vat_main;
15793 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
15794 "crypto_key %U integ_alg %u integ_key %U use_esn %u "
15795 "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u "
15796 "tunnel_src_addr %U tunnel_dst_addr %U "
15797 "salt %u seq_outbound %lu last_seq_inbound %lu "
15798 "replay_window %lu total_data_size %lu\n",
15799 ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi),
15801 mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len,
15802 mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len,
15803 mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6,
15804 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15805 mp->tunnel_src_addr,
15806 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15807 mp->tunnel_dst_addr,
15809 clib_net_to_host_u64 (mp->seq_outbound),
15810 clib_net_to_host_u64 (mp->last_seq_inbound),
15811 clib_net_to_host_u64 (mp->replay_window),
15812 clib_net_to_host_u64 (mp->total_data_size));
15815 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
15816 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
15818 static void vl_api_ipsec_sa_details_t_handler_json
15819 (vl_api_ipsec_sa_details_t * mp)
15821 vat_main_t *vam = &vat_main;
15822 vat_json_node_t *node = NULL;
15823 struct in_addr src_ip4, dst_ip4;
15824 struct in6_addr src_ip6, dst_ip6;
15826 if (VAT_JSON_ARRAY != vam->json_tree.type)
15828 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15829 vat_json_init_array (&vam->json_tree);
15831 node = vat_json_array_add (&vam->json_tree);
15833 vat_json_init_object (node);
15834 vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id));
15835 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
15836 vat_json_object_add_uint (node, "spi", ntohl (mp->spi));
15837 vat_json_object_add_uint (node, "proto", mp->protocol);
15838 vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg);
15839 vat_json_object_add_uint (node, "integ_alg", mp->integ_alg);
15840 vat_json_object_add_uint (node, "use_esn", mp->use_esn);
15841 vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay);
15842 vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel);
15843 vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6);
15844 vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key,
15845 mp->crypto_key_len);
15846 vat_json_object_add_bytes (node, "integ_key", mp->integ_key,
15847 mp->integ_key_len);
15848 if (mp->is_tunnel_ip6)
15850 clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6));
15851 vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6);
15852 clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6));
15853 vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6);
15857 clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4));
15858 vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4);
15859 clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4));
15860 vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4);
15862 vat_json_object_add_uint (node, "replay_window",
15863 clib_net_to_host_u64 (mp->replay_window));
15864 vat_json_object_add_uint (node, "total_data_size",
15865 clib_net_to_host_u64 (mp->total_data_size));
15870 api_ipsec_sa_dump (vat_main_t * vam)
15872 unformat_input_t *i = vam->input;
15873 vl_api_ipsec_sa_dump_t *mp;
15874 vl_api_control_ping_t *mp_ping;
15878 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15880 if (unformat (i, "sa_id %d", &sa_id))
15884 clib_warning ("parse error '%U'", format_unformat_error, i);
15889 M (IPSEC_SA_DUMP, mp);
15891 mp->sa_id = ntohl (sa_id);
15895 /* Use a control ping for synchronization */
15896 M (CONTROL_PING, mp_ping);
15904 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
15906 unformat_input_t *i = vam->input;
15907 vl_api_ipsec_tunnel_if_set_key_t *mp;
15908 u32 sw_if_index = ~0;
15909 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
15914 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15916 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15919 if (unformat (i, "local crypto %U", unformat_ipsec_crypto_alg, &alg))
15920 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
15922 if (unformat (i, "remote crypto %U", unformat_ipsec_crypto_alg, &alg))
15923 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
15924 else if (unformat (i, "local integ %U", unformat_ipsec_integ_alg, &alg))
15925 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
15927 if (unformat (i, "remote integ %U", unformat_ipsec_integ_alg, &alg))
15928 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
15929 else if (unformat (i, "%U", unformat_hex_string, &key))
15933 clib_warning ("parse error '%U'", format_unformat_error, i);
15938 if (sw_if_index == ~0)
15940 errmsg ("interface must be specified");
15944 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
15946 errmsg ("key type must be specified");
15952 errmsg ("algorithm must be specified");
15956 if (vec_len (key) == 0)
15958 errmsg ("key must be specified");
15962 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
15964 mp->sw_if_index = htonl (sw_if_index);
15966 mp->key_type = key_type;
15967 mp->key_len = vec_len (key);
15968 clib_memcpy (mp->key, key, vec_len (key));
15977 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
15979 unformat_input_t *i = vam->input;
15980 vl_api_ipsec_tunnel_if_set_sa_t *mp;
15981 u32 sw_if_index = ~0;
15983 u8 is_outbound = (u8) ~ 0;
15986 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15988 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15990 else if (unformat (i, "sa_id %d", &sa_id))
15992 else if (unformat (i, "outbound"))
15994 else if (unformat (i, "inbound"))
15998 clib_warning ("parse error '%U'", format_unformat_error, i);
16003 if (sw_if_index == ~0)
16005 errmsg ("interface must be specified");
16011 errmsg ("SA ID must be specified");
16015 M (IPSEC_TUNNEL_IF_SET_SA, mp);
16017 mp->sw_if_index = htonl (sw_if_index);
16018 mp->sa_id = htonl (sa_id);
16019 mp->is_outbound = is_outbound;
16028 api_ikev2_profile_add_del (vat_main_t * vam)
16030 unformat_input_t *i = vam->input;
16031 vl_api_ikev2_profile_add_del_t *mp;
16036 const char *valid_chars = "a-zA-Z0-9_";
16038 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16040 if (unformat (i, "del"))
16042 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
16043 vec_add1 (name, 0);
16046 errmsg ("parse error '%U'", format_unformat_error, i);
16051 if (!vec_len (name))
16053 errmsg ("profile name must be specified");
16057 if (vec_len (name) > 64)
16059 errmsg ("profile name too long");
16063 M (IKEV2_PROFILE_ADD_DEL, mp);
16065 clib_memcpy (mp->name, name, vec_len (name));
16066 mp->is_add = is_add;
16075 api_ikev2_profile_set_auth (vat_main_t * vam)
16077 unformat_input_t *i = vam->input;
16078 vl_api_ikev2_profile_set_auth_t *mp;
16081 u32 auth_method = 0;
16085 const char *valid_chars = "a-zA-Z0-9_";
16087 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16089 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
16090 vec_add1 (name, 0);
16091 else if (unformat (i, "auth_method %U",
16092 unformat_ikev2_auth_method, &auth_method))
16094 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
16096 else if (unformat (i, "auth_data %v", &data))
16100 errmsg ("parse error '%U'", format_unformat_error, i);
16105 if (!vec_len (name))
16107 errmsg ("profile name must be specified");
16111 if (vec_len (name) > 64)
16113 errmsg ("profile name too long");
16117 if (!vec_len (data))
16119 errmsg ("auth_data must be specified");
16125 errmsg ("auth_method must be specified");
16129 M (IKEV2_PROFILE_SET_AUTH, mp);
16131 mp->is_hex = is_hex;
16132 mp->auth_method = (u8) auth_method;
16133 mp->data_len = vec_len (data);
16134 clib_memcpy (mp->name, name, vec_len (name));
16135 clib_memcpy (mp->data, data, vec_len (data));
16145 api_ikev2_profile_set_id (vat_main_t * vam)
16147 unformat_input_t *i = vam->input;
16148 vl_api_ikev2_profile_set_id_t *mp;
16156 const char *valid_chars = "a-zA-Z0-9_";
16158 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16160 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
16161 vec_add1 (name, 0);
16162 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
16164 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
16166 data = vec_new (u8, 4);
16167 clib_memcpy (data, ip4.as_u8, 4);
16169 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
16171 else if (unformat (i, "id_data %v", &data))
16173 else if (unformat (i, "local"))
16175 else if (unformat (i, "remote"))
16179 errmsg ("parse error '%U'", format_unformat_error, i);
16184 if (!vec_len (name))
16186 errmsg ("profile name must be specified");
16190 if (vec_len (name) > 64)
16192 errmsg ("profile name too long");
16196 if (!vec_len (data))
16198 errmsg ("id_data must be specified");
16204 errmsg ("id_type must be specified");
16208 M (IKEV2_PROFILE_SET_ID, mp);
16210 mp->is_local = is_local;
16211 mp->id_type = (u8) id_type;
16212 mp->data_len = vec_len (data);
16213 clib_memcpy (mp->name, name, vec_len (name));
16214 clib_memcpy (mp->data, data, vec_len (data));
16224 api_ikev2_profile_set_ts (vat_main_t * vam)
16226 unformat_input_t *i = vam->input;
16227 vl_api_ikev2_profile_set_ts_t *mp;
16230 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
16231 ip4_address_t start_addr, end_addr;
16233 const char *valid_chars = "a-zA-Z0-9_";
16236 start_addr.as_u32 = 0;
16237 end_addr.as_u32 = (u32) ~ 0;
16239 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16241 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
16242 vec_add1 (name, 0);
16243 else if (unformat (i, "protocol %d", &proto))
16245 else if (unformat (i, "start_port %d", &start_port))
16247 else if (unformat (i, "end_port %d", &end_port))
16250 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
16252 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
16254 else if (unformat (i, "local"))
16256 else if (unformat (i, "remote"))
16260 errmsg ("parse error '%U'", format_unformat_error, i);
16265 if (!vec_len (name))
16267 errmsg ("profile name must be specified");
16271 if (vec_len (name) > 64)
16273 errmsg ("profile name too long");
16277 M (IKEV2_PROFILE_SET_TS, mp);
16279 mp->is_local = is_local;
16280 mp->proto = (u8) proto;
16281 mp->start_port = (u16) start_port;
16282 mp->end_port = (u16) end_port;
16283 mp->start_addr = start_addr.as_u32;
16284 mp->end_addr = end_addr.as_u32;
16285 clib_memcpy (mp->name, name, vec_len (name));
16294 api_ikev2_set_local_key (vat_main_t * vam)
16296 unformat_input_t *i = vam->input;
16297 vl_api_ikev2_set_local_key_t *mp;
16301 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16303 if (unformat (i, "file %v", &file))
16304 vec_add1 (file, 0);
16307 errmsg ("parse error '%U'", format_unformat_error, i);
16312 if (!vec_len (file))
16314 errmsg ("RSA key file must be specified");
16318 if (vec_len (file) > 256)
16320 errmsg ("file name too long");
16324 M (IKEV2_SET_LOCAL_KEY, mp);
16326 clib_memcpy (mp->key_file, file, vec_len (file));
16335 api_ikev2_set_responder (vat_main_t * vam)
16337 unformat_input_t *i = vam->input;
16338 vl_api_ikev2_set_responder_t *mp;
16341 u32 sw_if_index = ~0;
16342 ip4_address_t address;
16344 const char *valid_chars = "a-zA-Z0-9_";
16346 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16349 (i, "%U interface %d address %U", unformat_token, valid_chars,
16350 &name, &sw_if_index, unformat_ip4_address, &address))
16351 vec_add1 (name, 0);
16354 errmsg ("parse error '%U'", format_unformat_error, i);
16359 if (!vec_len (name))
16361 errmsg ("profile name must be specified");
16365 if (vec_len (name) > 64)
16367 errmsg ("profile name too long");
16371 M (IKEV2_SET_RESPONDER, mp);
16373 clib_memcpy (mp->name, name, vec_len (name));
16376 mp->sw_if_index = sw_if_index;
16377 clib_memcpy (mp->address, &address, sizeof (address));
16385 api_ikev2_set_ike_transforms (vat_main_t * vam)
16387 unformat_input_t *i = vam->input;
16388 vl_api_ikev2_set_ike_transforms_t *mp;
16391 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
16393 const char *valid_chars = "a-zA-Z0-9_";
16395 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16397 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
16398 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
16399 vec_add1 (name, 0);
16402 errmsg ("parse error '%U'", format_unformat_error, i);
16407 if (!vec_len (name))
16409 errmsg ("profile name must be specified");
16413 if (vec_len (name) > 64)
16415 errmsg ("profile name too long");
16419 M (IKEV2_SET_IKE_TRANSFORMS, mp);
16421 clib_memcpy (mp->name, name, vec_len (name));
16423 mp->crypto_alg = crypto_alg;
16424 mp->crypto_key_size = crypto_key_size;
16425 mp->integ_alg = integ_alg;
16426 mp->dh_group = dh_group;
16435 api_ikev2_set_esp_transforms (vat_main_t * vam)
16437 unformat_input_t *i = vam->input;
16438 vl_api_ikev2_set_esp_transforms_t *mp;
16441 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
16443 const char *valid_chars = "a-zA-Z0-9_";
16445 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16447 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
16448 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
16449 vec_add1 (name, 0);
16452 errmsg ("parse error '%U'", format_unformat_error, i);
16457 if (!vec_len (name))
16459 errmsg ("profile name must be specified");
16463 if (vec_len (name) > 64)
16465 errmsg ("profile name too long");
16469 M (IKEV2_SET_ESP_TRANSFORMS, mp);
16471 clib_memcpy (mp->name, name, vec_len (name));
16473 mp->crypto_alg = crypto_alg;
16474 mp->crypto_key_size = crypto_key_size;
16475 mp->integ_alg = integ_alg;
16476 mp->dh_group = dh_group;
16484 api_ikev2_set_sa_lifetime (vat_main_t * vam)
16486 unformat_input_t *i = vam->input;
16487 vl_api_ikev2_set_sa_lifetime_t *mp;
16490 u64 lifetime, lifetime_maxdata;
16491 u32 lifetime_jitter, handover;
16493 const char *valid_chars = "a-zA-Z0-9_";
16495 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16497 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
16498 &lifetime, &lifetime_jitter, &handover,
16499 &lifetime_maxdata))
16500 vec_add1 (name, 0);
16503 errmsg ("parse error '%U'", format_unformat_error, i);
16508 if (!vec_len (name))
16510 errmsg ("profile name must be specified");
16514 if (vec_len (name) > 64)
16516 errmsg ("profile name too long");
16520 M (IKEV2_SET_SA_LIFETIME, mp);
16522 clib_memcpy (mp->name, name, vec_len (name));
16524 mp->lifetime = lifetime;
16525 mp->lifetime_jitter = lifetime_jitter;
16526 mp->handover = handover;
16527 mp->lifetime_maxdata = lifetime_maxdata;
16535 api_ikev2_initiate_sa_init (vat_main_t * vam)
16537 unformat_input_t *i = vam->input;
16538 vl_api_ikev2_initiate_sa_init_t *mp;
16542 const char *valid_chars = "a-zA-Z0-9_";
16544 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16546 if (unformat (i, "%U", unformat_token, valid_chars, &name))
16547 vec_add1 (name, 0);
16550 errmsg ("parse error '%U'", format_unformat_error, i);
16555 if (!vec_len (name))
16557 errmsg ("profile name must be specified");
16561 if (vec_len (name) > 64)
16563 errmsg ("profile name too long");
16567 M (IKEV2_INITIATE_SA_INIT, mp);
16569 clib_memcpy (mp->name, name, vec_len (name));
16578 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
16580 unformat_input_t *i = vam->input;
16581 vl_api_ikev2_initiate_del_ike_sa_t *mp;
16586 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16588 if (unformat (i, "%lx", &ispi))
16592 errmsg ("parse error '%U'", format_unformat_error, i);
16597 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
16607 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
16609 unformat_input_t *i = vam->input;
16610 vl_api_ikev2_initiate_del_child_sa_t *mp;
16615 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16617 if (unformat (i, "%x", &ispi))
16621 errmsg ("parse error '%U'", format_unformat_error, i);
16626 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
16636 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
16638 unformat_input_t *i = vam->input;
16639 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
16644 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16646 if (unformat (i, "%x", &ispi))
16650 errmsg ("parse error '%U'", format_unformat_error, i);
16655 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
16665 api_get_first_msg_id (vat_main_t * vam)
16667 vl_api_get_first_msg_id_t *mp;
16668 unformat_input_t *i = vam->input;
16673 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16675 if (unformat (i, "client %s", &name))
16683 errmsg ("missing client name");
16686 vec_add1 (name, 0);
16688 if (vec_len (name) > 63)
16690 errmsg ("client name too long");
16694 M (GET_FIRST_MSG_ID, mp);
16695 clib_memcpy (mp->name, name, vec_len (name));
16702 api_cop_interface_enable_disable (vat_main_t * vam)
16704 unformat_input_t *line_input = vam->input;
16705 vl_api_cop_interface_enable_disable_t *mp;
16706 u32 sw_if_index = ~0;
16707 u8 enable_disable = 1;
16710 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16712 if (unformat (line_input, "disable"))
16713 enable_disable = 0;
16714 if (unformat (line_input, "enable"))
16715 enable_disable = 1;
16716 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16717 vam, &sw_if_index))
16719 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16725 if (sw_if_index == ~0)
16727 errmsg ("missing interface name or sw_if_index");
16731 /* Construct the API message */
16732 M (COP_INTERFACE_ENABLE_DISABLE, mp);
16733 mp->sw_if_index = ntohl (sw_if_index);
16734 mp->enable_disable = enable_disable;
16738 /* Wait for the reply */
16744 api_cop_whitelist_enable_disable (vat_main_t * vam)
16746 unformat_input_t *line_input = vam->input;
16747 vl_api_cop_whitelist_enable_disable_t *mp;
16748 u32 sw_if_index = ~0;
16749 u8 ip4 = 0, ip6 = 0, default_cop = 0;
16753 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16755 if (unformat (line_input, "ip4"))
16757 else if (unformat (line_input, "ip6"))
16759 else if (unformat (line_input, "default"))
16761 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16762 vam, &sw_if_index))
16764 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16766 else if (unformat (line_input, "fib-id %d", &fib_id))
16772 if (sw_if_index == ~0)
16774 errmsg ("missing interface name or sw_if_index");
16778 /* Construct the API message */
16779 M (COP_WHITELIST_ENABLE_DISABLE, mp);
16780 mp->sw_if_index = ntohl (sw_if_index);
16781 mp->fib_id = ntohl (fib_id);
16784 mp->default_cop = default_cop;
16788 /* Wait for the reply */
16794 api_get_node_graph (vat_main_t * vam)
16796 vl_api_get_node_graph_t *mp;
16799 M (GET_NODE_GRAPH, mp);
16803 /* Wait for the reply */
16809 /** Used for parsing LISP eids */
16810 typedef CLIB_PACKED(struct{
16811 u8 addr[16]; /**< eid address */
16812 u32 len; /**< prefix length if IP */
16813 u8 type; /**< type of eid */
16818 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
16820 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
16822 memset (a, 0, sizeof (a[0]));
16824 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
16826 a->type = 0; /* ipv4 type */
16828 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
16830 a->type = 1; /* ipv6 type */
16832 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
16834 a->type = 2; /* mac type */
16836 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
16838 a->type = 3; /* NSH type */
16839 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
16840 nsh->spi = clib_host_to_net_u32 (nsh->spi);
16847 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
16856 lisp_eid_size_vat (u8 type)
16873 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
16875 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
16879 api_one_add_del_locator_set (vat_main_t * vam)
16881 unformat_input_t *input = vam->input;
16882 vl_api_one_add_del_locator_set_t *mp;
16884 u8 *locator_set_name = NULL;
16885 u8 locator_set_name_set = 0;
16886 vl_api_local_locator_t locator, *locators = 0;
16887 u32 sw_if_index, priority, weight;
16891 /* Parse args required to build the message */
16892 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16894 if (unformat (input, "del"))
16898 else if (unformat (input, "locator-set %s", &locator_set_name))
16900 locator_set_name_set = 1;
16902 else if (unformat (input, "sw_if_index %u p %u w %u",
16903 &sw_if_index, &priority, &weight))
16905 locator.sw_if_index = htonl (sw_if_index);
16906 locator.priority = priority;
16907 locator.weight = weight;
16908 vec_add1 (locators, locator);
16912 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
16913 &sw_if_index, &priority, &weight))
16915 locator.sw_if_index = htonl (sw_if_index);
16916 locator.priority = priority;
16917 locator.weight = weight;
16918 vec_add1 (locators, locator);
16924 if (locator_set_name_set == 0)
16926 errmsg ("missing locator-set name");
16927 vec_free (locators);
16931 if (vec_len (locator_set_name) > 64)
16933 errmsg ("locator-set name too long");
16934 vec_free (locator_set_name);
16935 vec_free (locators);
16938 vec_add1 (locator_set_name, 0);
16940 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
16942 /* Construct the API message */
16943 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
16945 mp->is_add = is_add;
16946 clib_memcpy (mp->locator_set_name, locator_set_name,
16947 vec_len (locator_set_name));
16948 vec_free (locator_set_name);
16950 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
16952 clib_memcpy (mp->locators, locators, data_len);
16953 vec_free (locators);
16958 /* Wait for a reply... */
16963 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
16966 api_one_add_del_locator (vat_main_t * vam)
16968 unformat_input_t *input = vam->input;
16969 vl_api_one_add_del_locator_t *mp;
16970 u32 tmp_if_index = ~0;
16971 u32 sw_if_index = ~0;
16972 u8 sw_if_index_set = 0;
16973 u8 sw_if_index_if_name_set = 0;
16975 u8 priority_set = 0;
16979 u8 *locator_set_name = NULL;
16980 u8 locator_set_name_set = 0;
16983 /* Parse args required to build the message */
16984 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16986 if (unformat (input, "del"))
16990 else if (unformat (input, "locator-set %s", &locator_set_name))
16992 locator_set_name_set = 1;
16994 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
16997 sw_if_index_if_name_set = 1;
16998 sw_if_index = tmp_if_index;
17000 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
17002 sw_if_index_set = 1;
17003 sw_if_index = tmp_if_index;
17005 else if (unformat (input, "p %d", &priority))
17009 else if (unformat (input, "w %d", &weight))
17017 if (locator_set_name_set == 0)
17019 errmsg ("missing locator-set name");
17023 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
17025 errmsg ("missing sw_if_index");
17026 vec_free (locator_set_name);
17030 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
17032 errmsg ("cannot use both params interface name and sw_if_index");
17033 vec_free (locator_set_name);
17037 if (priority_set == 0)
17039 errmsg ("missing locator-set priority");
17040 vec_free (locator_set_name);
17044 if (weight_set == 0)
17046 errmsg ("missing locator-set weight");
17047 vec_free (locator_set_name);
17051 if (vec_len (locator_set_name) > 64)
17053 errmsg ("locator-set name too long");
17054 vec_free (locator_set_name);
17057 vec_add1 (locator_set_name, 0);
17059 /* Construct the API message */
17060 M (ONE_ADD_DEL_LOCATOR, mp);
17062 mp->is_add = is_add;
17063 mp->sw_if_index = ntohl (sw_if_index);
17064 mp->priority = priority;
17065 mp->weight = weight;
17066 clib_memcpy (mp->locator_set_name, locator_set_name,
17067 vec_len (locator_set_name));
17068 vec_free (locator_set_name);
17073 /* Wait for a reply... */
17078 #define api_lisp_add_del_locator api_one_add_del_locator
17081 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
17083 u32 *key_id = va_arg (*args, u32 *);
17086 if (unformat (input, "%s", &s))
17088 if (!strcmp ((char *) s, "sha1"))
17089 key_id[0] = HMAC_SHA_1_96;
17090 else if (!strcmp ((char *) s, "sha256"))
17091 key_id[0] = HMAC_SHA_256_128;
17094 clib_warning ("invalid key_id: '%s'", s);
17095 key_id[0] = HMAC_NO_KEY;
17106 api_one_add_del_local_eid (vat_main_t * vam)
17108 unformat_input_t *input = vam->input;
17109 vl_api_one_add_del_local_eid_t *mp;
17112 lisp_eid_vat_t _eid, *eid = &_eid;
17113 u8 *locator_set_name = 0;
17114 u8 locator_set_name_set = 0;
17120 /* Parse args required to build the message */
17121 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17123 if (unformat (input, "del"))
17127 else if (unformat (input, "vni %d", &vni))
17131 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
17135 else if (unformat (input, "locator-set %s", &locator_set_name))
17137 locator_set_name_set = 1;
17139 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
17141 else if (unformat (input, "secret-key %_%v%_", &key))
17147 if (locator_set_name_set == 0)
17149 errmsg ("missing locator-set name");
17155 errmsg ("EID address not set!");
17156 vec_free (locator_set_name);
17160 if (key && (0 == key_id))
17162 errmsg ("invalid key_id!");
17166 if (vec_len (key) > 64)
17168 errmsg ("key too long");
17173 if (vec_len (locator_set_name) > 64)
17175 errmsg ("locator-set name too long");
17176 vec_free (locator_set_name);
17179 vec_add1 (locator_set_name, 0);
17181 /* Construct the API message */
17182 M (ONE_ADD_DEL_LOCAL_EID, mp);
17184 mp->is_add = is_add;
17185 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
17186 mp->eid_type = eid->type;
17187 mp->prefix_len = eid->len;
17188 mp->vni = clib_host_to_net_u32 (vni);
17189 mp->key_id = clib_host_to_net_u16 (key_id);
17190 clib_memcpy (mp->locator_set_name, locator_set_name,
17191 vec_len (locator_set_name));
17192 clib_memcpy (mp->key, key, vec_len (key));
17194 vec_free (locator_set_name);
17200 /* Wait for a reply... */
17205 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
17208 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
17210 u32 dp_table = 0, vni = 0;;
17211 unformat_input_t *input = vam->input;
17212 vl_api_gpe_add_del_fwd_entry_t *mp;
17214 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
17215 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
17216 u8 rmt_eid_set = 0, lcl_eid_set = 0;
17217 u32 action = ~0, w;
17218 ip4_address_t rmt_rloc4, lcl_rloc4;
17219 ip6_address_t rmt_rloc6, lcl_rloc6;
17220 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
17223 memset (&rloc, 0, sizeof (rloc));
17225 /* Parse args required to build the message */
17226 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17228 if (unformat (input, "del"))
17230 else if (unformat (input, "add"))
17232 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
17236 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
17240 else if (unformat (input, "vrf %d", &dp_table))
17242 else if (unformat (input, "bd %d", &dp_table))
17244 else if (unformat (input, "vni %d", &vni))
17246 else if (unformat (input, "w %d", &w))
17250 errmsg ("No RLOC configured for setting priority/weight!");
17253 curr_rloc->weight = w;
17255 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
17256 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
17260 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
17262 vec_add1 (lcl_locs, rloc);
17264 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
17265 vec_add1 (rmt_locs, rloc);
17266 /* weight saved in rmt loc */
17267 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
17269 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
17270 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
17273 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
17275 vec_add1 (lcl_locs, rloc);
17277 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
17278 vec_add1 (rmt_locs, rloc);
17279 /* weight saved in rmt loc */
17280 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
17282 else if (unformat (input, "action %d", &action))
17288 clib_warning ("parse error '%U'", format_unformat_error, input);
17295 errmsg ("remote eid addresses not set");
17299 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
17301 errmsg ("eid types don't match");
17305 if (0 == rmt_locs && (u32) ~ 0 == action)
17307 errmsg ("action not set for negative mapping");
17311 /* Construct the API message */
17312 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
17313 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
17315 mp->is_add = is_add;
17316 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
17317 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
17318 mp->eid_type = rmt_eid->type;
17319 mp->dp_table = clib_host_to_net_u32 (dp_table);
17320 mp->vni = clib_host_to_net_u32 (vni);
17321 mp->rmt_len = rmt_eid->len;
17322 mp->lcl_len = lcl_eid->len;
17323 mp->action = action;
17325 if (0 != rmt_locs && 0 != lcl_locs)
17327 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
17328 clib_memcpy (mp->locs, lcl_locs,
17329 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
17331 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
17332 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
17333 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
17335 vec_free (lcl_locs);
17336 vec_free (rmt_locs);
17341 /* Wait for a reply... */
17347 api_one_add_del_map_server (vat_main_t * vam)
17349 unformat_input_t *input = vam->input;
17350 vl_api_one_add_del_map_server_t *mp;
17354 ip4_address_t ipv4;
17355 ip6_address_t ipv6;
17358 /* Parse args required to build the message */
17359 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17361 if (unformat (input, "del"))
17365 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17369 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17377 if (ipv4_set && ipv6_set)
17379 errmsg ("both eid v4 and v6 addresses set");
17383 if (!ipv4_set && !ipv6_set)
17385 errmsg ("eid addresses not set");
17389 /* Construct the API message */
17390 M (ONE_ADD_DEL_MAP_SERVER, mp);
17392 mp->is_add = is_add;
17396 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17401 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17407 /* Wait for a reply... */
17412 #define api_lisp_add_del_map_server api_one_add_del_map_server
17415 api_one_add_del_map_resolver (vat_main_t * vam)
17417 unformat_input_t *input = vam->input;
17418 vl_api_one_add_del_map_resolver_t *mp;
17422 ip4_address_t ipv4;
17423 ip6_address_t ipv6;
17426 /* Parse args required to build the message */
17427 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17429 if (unformat (input, "del"))
17433 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17437 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17445 if (ipv4_set && ipv6_set)
17447 errmsg ("both eid v4 and v6 addresses set");
17451 if (!ipv4_set && !ipv6_set)
17453 errmsg ("eid addresses not set");
17457 /* Construct the API message */
17458 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
17460 mp->is_add = is_add;
17464 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17469 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17475 /* Wait for a reply... */
17480 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
17483 api_lisp_gpe_enable_disable (vat_main_t * vam)
17485 unformat_input_t *input = vam->input;
17486 vl_api_gpe_enable_disable_t *mp;
17491 /* Parse args required to build the message */
17492 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17494 if (unformat (input, "enable"))
17499 else if (unformat (input, "disable"))
17510 errmsg ("Value not set");
17514 /* Construct the API message */
17515 M (GPE_ENABLE_DISABLE, mp);
17522 /* Wait for a reply... */
17528 api_one_rloc_probe_enable_disable (vat_main_t * vam)
17530 unformat_input_t *input = vam->input;
17531 vl_api_one_rloc_probe_enable_disable_t *mp;
17536 /* Parse args required to build the message */
17537 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17539 if (unformat (input, "enable"))
17544 else if (unformat (input, "disable"))
17552 errmsg ("Value not set");
17556 /* Construct the API message */
17557 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
17559 mp->is_enabled = is_en;
17564 /* Wait for a reply... */
17569 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
17572 api_one_map_register_enable_disable (vat_main_t * vam)
17574 unformat_input_t *input = vam->input;
17575 vl_api_one_map_register_enable_disable_t *mp;
17580 /* Parse args required to build the message */
17581 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17583 if (unformat (input, "enable"))
17588 else if (unformat (input, "disable"))
17596 errmsg ("Value not set");
17600 /* Construct the API message */
17601 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
17603 mp->is_enabled = is_en;
17608 /* Wait for a reply... */
17613 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
17616 api_one_enable_disable (vat_main_t * vam)
17618 unformat_input_t *input = vam->input;
17619 vl_api_one_enable_disable_t *mp;
17624 /* Parse args required to build the message */
17625 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17627 if (unformat (input, "enable"))
17632 else if (unformat (input, "disable"))
17642 errmsg ("Value not set");
17646 /* Construct the API message */
17647 M (ONE_ENABLE_DISABLE, mp);
17654 /* Wait for a reply... */
17659 #define api_lisp_enable_disable api_one_enable_disable
17662 api_one_enable_disable_xtr_mode (vat_main_t * vam)
17664 unformat_input_t *input = vam->input;
17665 vl_api_one_enable_disable_xtr_mode_t *mp;
17670 /* Parse args required to build the message */
17671 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17673 if (unformat (input, "enable"))
17678 else if (unformat (input, "disable"))
17688 errmsg ("Value not set");
17692 /* Construct the API message */
17693 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
17700 /* Wait for a reply... */
17706 api_one_show_xtr_mode (vat_main_t * vam)
17708 vl_api_one_show_xtr_mode_t *mp;
17711 /* Construct the API message */
17712 M (ONE_SHOW_XTR_MODE, mp);
17717 /* Wait for a reply... */
17723 api_one_enable_disable_pitr_mode (vat_main_t * vam)
17725 unformat_input_t *input = vam->input;
17726 vl_api_one_enable_disable_pitr_mode_t *mp;
17731 /* Parse args required to build the message */
17732 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17734 if (unformat (input, "enable"))
17739 else if (unformat (input, "disable"))
17749 errmsg ("Value not set");
17753 /* Construct the API message */
17754 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
17761 /* Wait for a reply... */
17767 api_one_show_pitr_mode (vat_main_t * vam)
17769 vl_api_one_show_pitr_mode_t *mp;
17772 /* Construct the API message */
17773 M (ONE_SHOW_PITR_MODE, mp);
17778 /* Wait for a reply... */
17784 api_one_enable_disable_petr_mode (vat_main_t * vam)
17786 unformat_input_t *input = vam->input;
17787 vl_api_one_enable_disable_petr_mode_t *mp;
17792 /* Parse args required to build the message */
17793 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17795 if (unformat (input, "enable"))
17800 else if (unformat (input, "disable"))
17810 errmsg ("Value not set");
17814 /* Construct the API message */
17815 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
17822 /* Wait for a reply... */
17828 api_one_show_petr_mode (vat_main_t * vam)
17830 vl_api_one_show_petr_mode_t *mp;
17833 /* Construct the API message */
17834 M (ONE_SHOW_PETR_MODE, mp);
17839 /* Wait for a reply... */
17845 api_show_one_map_register_state (vat_main_t * vam)
17847 vl_api_show_one_map_register_state_t *mp;
17850 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
17855 /* wait for reply */
17860 #define api_show_lisp_map_register_state api_show_one_map_register_state
17863 api_show_one_rloc_probe_state (vat_main_t * vam)
17865 vl_api_show_one_rloc_probe_state_t *mp;
17868 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
17873 /* wait for reply */
17878 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
17881 api_one_add_del_ndp_entry (vat_main_t * vam)
17883 vl_api_one_add_del_ndp_entry_t *mp;
17884 unformat_input_t *input = vam->input;
17889 u8 mac[6] = { 0, };
17890 u8 ip6[16] = { 0, };
17894 /* Parse args required to build the message */
17895 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17897 if (unformat (input, "del"))
17899 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17901 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
17903 else if (unformat (input, "bd %d", &bd))
17907 errmsg ("parse error '%U'", format_unformat_error, input);
17912 if (!bd_set || !ip_set || (!mac_set && is_add))
17914 errmsg ("Missing BD, IP or MAC!");
17918 M (ONE_ADD_DEL_NDP_ENTRY, mp);
17919 mp->is_add = is_add;
17920 clib_memcpy (mp->mac, mac, 6);
17921 mp->bd = clib_host_to_net_u32 (bd);
17922 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
17927 /* wait for reply */
17933 api_one_add_del_l2_arp_entry (vat_main_t * vam)
17935 vl_api_one_add_del_l2_arp_entry_t *mp;
17936 unformat_input_t *input = vam->input;
17941 u8 mac[6] = { 0, };
17942 u32 ip4 = 0, bd = ~0;
17945 /* Parse args required to build the message */
17946 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17948 if (unformat (input, "del"))
17950 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17952 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
17954 else if (unformat (input, "bd %d", &bd))
17958 errmsg ("parse error '%U'", format_unformat_error, input);
17963 if (!bd_set || !ip_set || (!mac_set && is_add))
17965 errmsg ("Missing BD, IP or MAC!");
17969 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
17970 mp->is_add = is_add;
17971 clib_memcpy (mp->mac, mac, 6);
17972 mp->bd = clib_host_to_net_u32 (bd);
17978 /* wait for reply */
17984 api_one_ndp_bd_get (vat_main_t * vam)
17986 vl_api_one_ndp_bd_get_t *mp;
17989 M (ONE_NDP_BD_GET, mp);
17994 /* wait for reply */
18000 api_one_ndp_entries_get (vat_main_t * vam)
18002 vl_api_one_ndp_entries_get_t *mp;
18003 unformat_input_t *input = vam->input;
18008 /* Parse args required to build the message */
18009 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18011 if (unformat (input, "bd %d", &bd))
18015 errmsg ("parse error '%U'", format_unformat_error, input);
18022 errmsg ("Expected bridge domain!");
18026 M (ONE_NDP_ENTRIES_GET, mp);
18027 mp->bd = clib_host_to_net_u32 (bd);
18032 /* wait for reply */
18038 api_one_l2_arp_bd_get (vat_main_t * vam)
18040 vl_api_one_l2_arp_bd_get_t *mp;
18043 M (ONE_L2_ARP_BD_GET, mp);
18048 /* wait for reply */
18054 api_one_l2_arp_entries_get (vat_main_t * vam)
18056 vl_api_one_l2_arp_entries_get_t *mp;
18057 unformat_input_t *input = vam->input;
18062 /* Parse args required to build the message */
18063 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18065 if (unformat (input, "bd %d", &bd))
18069 errmsg ("parse error '%U'", format_unformat_error, input);
18076 errmsg ("Expected bridge domain!");
18080 M (ONE_L2_ARP_ENTRIES_GET, mp);
18081 mp->bd = clib_host_to_net_u32 (bd);
18086 /* wait for reply */
18092 api_one_stats_enable_disable (vat_main_t * vam)
18094 vl_api_one_stats_enable_disable_t *mp;
18095 unformat_input_t *input = vam->input;
18100 /* Parse args required to build the message */
18101 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18103 if (unformat (input, "enable"))
18108 else if (unformat (input, "disable"))
18118 errmsg ("Value not set");
18122 M (ONE_STATS_ENABLE_DISABLE, mp);
18128 /* wait for reply */
18134 api_show_one_stats_enable_disable (vat_main_t * vam)
18136 vl_api_show_one_stats_enable_disable_t *mp;
18139 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
18144 /* wait for reply */
18150 api_show_one_map_request_mode (vat_main_t * vam)
18152 vl_api_show_one_map_request_mode_t *mp;
18155 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
18160 /* wait for reply */
18165 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
18168 api_one_map_request_mode (vat_main_t * vam)
18170 unformat_input_t *input = vam->input;
18171 vl_api_one_map_request_mode_t *mp;
18175 /* Parse args required to build the message */
18176 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18178 if (unformat (input, "dst-only"))
18180 else if (unformat (input, "src-dst"))
18184 errmsg ("parse error '%U'", format_unformat_error, input);
18189 M (ONE_MAP_REQUEST_MODE, mp);
18196 /* wait for reply */
18201 #define api_lisp_map_request_mode api_one_map_request_mode
18204 * Enable/disable ONE proxy ITR.
18206 * @param vam vpp API test context
18207 * @return return code
18210 api_one_pitr_set_locator_set (vat_main_t * vam)
18212 u8 ls_name_set = 0;
18213 unformat_input_t *input = vam->input;
18214 vl_api_one_pitr_set_locator_set_t *mp;
18219 /* Parse args required to build the message */
18220 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18222 if (unformat (input, "del"))
18224 else if (unformat (input, "locator-set %s", &ls_name))
18228 errmsg ("parse error '%U'", format_unformat_error, input);
18235 errmsg ("locator-set name not set!");
18239 M (ONE_PITR_SET_LOCATOR_SET, mp);
18241 mp->is_add = is_add;
18242 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
18243 vec_free (ls_name);
18248 /* wait for reply */
18253 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
18256 api_one_nsh_set_locator_set (vat_main_t * vam)
18258 u8 ls_name_set = 0;
18259 unformat_input_t *input = vam->input;
18260 vl_api_one_nsh_set_locator_set_t *mp;
18265 /* Parse args required to build the message */
18266 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18268 if (unformat (input, "del"))
18270 else if (unformat (input, "ls %s", &ls_name))
18274 errmsg ("parse error '%U'", format_unformat_error, input);
18279 if (!ls_name_set && is_add)
18281 errmsg ("locator-set name not set!");
18285 M (ONE_NSH_SET_LOCATOR_SET, mp);
18287 mp->is_add = is_add;
18288 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
18289 vec_free (ls_name);
18294 /* wait for reply */
18300 api_show_one_pitr (vat_main_t * vam)
18302 vl_api_show_one_pitr_t *mp;
18305 if (!vam->json_output)
18307 print (vam->ofp, "%=20s", "lisp status:");
18310 M (SHOW_ONE_PITR, mp);
18314 /* Wait for a reply... */
18319 #define api_show_lisp_pitr api_show_one_pitr
18322 api_one_use_petr (vat_main_t * vam)
18324 unformat_input_t *input = vam->input;
18325 vl_api_one_use_petr_t *mp;
18330 memset (&ip, 0, sizeof (ip));
18332 /* Parse args required to build the message */
18333 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18335 if (unformat (input, "disable"))
18338 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
18341 ip_addr_version (&ip) = IP4;
18344 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
18347 ip_addr_version (&ip) = IP6;
18351 errmsg ("parse error '%U'", format_unformat_error, input);
18356 M (ONE_USE_PETR, mp);
18358 mp->is_add = is_add;
18361 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
18363 clib_memcpy (mp->address, &ip, 4);
18365 clib_memcpy (mp->address, &ip, 16);
18371 /* wait for reply */
18376 #define api_lisp_use_petr api_one_use_petr
18379 api_show_one_nsh_mapping (vat_main_t * vam)
18381 vl_api_show_one_use_petr_t *mp;
18384 if (!vam->json_output)
18386 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
18389 M (SHOW_ONE_NSH_MAPPING, mp);
18393 /* Wait for a reply... */
18399 api_show_one_use_petr (vat_main_t * vam)
18401 vl_api_show_one_use_petr_t *mp;
18404 if (!vam->json_output)
18406 print (vam->ofp, "%=20s", "Proxy-ETR status:");
18409 M (SHOW_ONE_USE_PETR, mp);
18413 /* Wait for a reply... */
18418 #define api_show_lisp_use_petr api_show_one_use_petr
18421 * Add/delete mapping between vni and vrf
18424 api_one_eid_table_add_del_map (vat_main_t * vam)
18426 unformat_input_t *input = vam->input;
18427 vl_api_one_eid_table_add_del_map_t *mp;
18428 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
18429 u32 vni, vrf, bd_index;
18432 /* Parse args required to build the message */
18433 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18435 if (unformat (input, "del"))
18437 else if (unformat (input, "vrf %d", &vrf))
18439 else if (unformat (input, "bd_index %d", &bd_index))
18441 else if (unformat (input, "vni %d", &vni))
18447 if (!vni_set || (!vrf_set && !bd_index_set))
18449 errmsg ("missing arguments!");
18453 if (vrf_set && bd_index_set)
18455 errmsg ("error: both vrf and bd entered!");
18459 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
18461 mp->is_add = is_add;
18462 mp->vni = htonl (vni);
18463 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
18464 mp->is_l2 = bd_index_set;
18469 /* wait for reply */
18474 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
18477 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
18479 u32 *action = va_arg (*args, u32 *);
18482 if (unformat (input, "%s", &s))
18484 if (!strcmp ((char *) s, "no-action"))
18486 else if (!strcmp ((char *) s, "natively-forward"))
18488 else if (!strcmp ((char *) s, "send-map-request"))
18490 else if (!strcmp ((char *) s, "drop"))
18494 clib_warning ("invalid action: '%s'", s);
18506 * Add/del remote mapping to/from ONE control plane
18508 * @param vam vpp API test context
18509 * @return return code
18512 api_one_add_del_remote_mapping (vat_main_t * vam)
18514 unformat_input_t *input = vam->input;
18515 vl_api_one_add_del_remote_mapping_t *mp;
18517 lisp_eid_vat_t _eid, *eid = &_eid;
18518 lisp_eid_vat_t _seid, *seid = &_seid;
18519 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
18520 u32 action = ~0, p, w, data_len;
18521 ip4_address_t rloc4;
18522 ip6_address_t rloc6;
18523 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
18526 memset (&rloc, 0, sizeof (rloc));
18528 /* Parse args required to build the message */
18529 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18531 if (unformat (input, "del-all"))
18535 else if (unformat (input, "del"))
18539 else if (unformat (input, "add"))
18543 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
18547 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
18551 else if (unformat (input, "vni %d", &vni))
18555 else if (unformat (input, "p %d w %d", &p, &w))
18559 errmsg ("No RLOC configured for setting priority/weight!");
18562 curr_rloc->priority = p;
18563 curr_rloc->weight = w;
18565 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
18568 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
18569 vec_add1 (rlocs, rloc);
18570 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18572 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
18575 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
18576 vec_add1 (rlocs, rloc);
18577 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18579 else if (unformat (input, "action %U",
18580 unformat_negative_mapping_action, &action))
18586 clib_warning ("parse error '%U'", format_unformat_error, input);
18593 errmsg ("missing params!");
18597 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
18599 errmsg ("no action set for negative map-reply!");
18603 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
18605 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
18606 mp->is_add = is_add;
18607 mp->vni = htonl (vni);
18608 mp->action = (u8) action;
18609 mp->is_src_dst = seid_set;
18610 mp->eid_len = eid->len;
18611 mp->seid_len = seid->len;
18612 mp->del_all = del_all;
18613 mp->eid_type = eid->type;
18614 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
18615 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
18617 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
18618 clib_memcpy (mp->rlocs, rlocs, data_len);
18624 /* Wait for a reply... */
18629 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
18632 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
18633 * forwarding entries in data-plane accordingly.
18635 * @param vam vpp API test context
18636 * @return return code
18639 api_one_add_del_adjacency (vat_main_t * vam)
18641 unformat_input_t *input = vam->input;
18642 vl_api_one_add_del_adjacency_t *mp;
18644 ip4_address_t leid4, reid4;
18645 ip6_address_t leid6, reid6;
18646 u8 reid_mac[6] = { 0 };
18647 u8 leid_mac[6] = { 0 };
18648 u8 reid_type, leid_type;
18649 u32 leid_len = 0, reid_len = 0, len;
18653 leid_type = reid_type = (u8) ~ 0;
18655 /* Parse args required to build the message */
18656 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18658 if (unformat (input, "del"))
18662 else if (unformat (input, "add"))
18666 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
18669 reid_type = 0; /* ipv4 */
18672 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
18675 reid_type = 1; /* ipv6 */
18678 else if (unformat (input, "reid %U", unformat_ethernet_address,
18681 reid_type = 2; /* mac */
18683 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
18686 leid_type = 0; /* ipv4 */
18689 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
18692 leid_type = 1; /* ipv6 */
18695 else if (unformat (input, "leid %U", unformat_ethernet_address,
18698 leid_type = 2; /* mac */
18700 else if (unformat (input, "vni %d", &vni))
18706 errmsg ("parse error '%U'", format_unformat_error, input);
18711 if ((u8) ~ 0 == reid_type)
18713 errmsg ("missing params!");
18717 if (leid_type != reid_type)
18719 errmsg ("remote and local EIDs are of different types!");
18723 M (ONE_ADD_DEL_ADJACENCY, mp);
18724 mp->is_add = is_add;
18725 mp->vni = htonl (vni);
18726 mp->leid_len = leid_len;
18727 mp->reid_len = reid_len;
18728 mp->eid_type = reid_type;
18730 switch (mp->eid_type)
18733 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
18734 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
18737 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
18738 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
18741 clib_memcpy (mp->leid, leid_mac, 6);
18742 clib_memcpy (mp->reid, reid_mac, 6);
18745 errmsg ("unknown EID type %d!", mp->eid_type);
18752 /* Wait for a reply... */
18757 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
18760 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
18762 u32 *mode = va_arg (*args, u32 *);
18764 if (unformat (input, "lisp"))
18766 else if (unformat (input, "vxlan"))
18775 api_gpe_get_encap_mode (vat_main_t * vam)
18777 vl_api_gpe_get_encap_mode_t *mp;
18780 /* Construct the API message */
18781 M (GPE_GET_ENCAP_MODE, mp);
18786 /* Wait for a reply... */
18792 api_gpe_set_encap_mode (vat_main_t * vam)
18794 unformat_input_t *input = vam->input;
18795 vl_api_gpe_set_encap_mode_t *mp;
18799 /* Parse args required to build the message */
18800 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18802 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
18808 /* Construct the API message */
18809 M (GPE_SET_ENCAP_MODE, mp);
18816 /* Wait for a reply... */
18822 api_lisp_gpe_add_del_iface (vat_main_t * vam)
18824 unformat_input_t *input = vam->input;
18825 vl_api_gpe_add_del_iface_t *mp;
18826 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
18827 u32 dp_table = 0, vni = 0;
18830 /* Parse args required to build the message */
18831 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18833 if (unformat (input, "up"))
18838 else if (unformat (input, "down"))
18843 else if (unformat (input, "table_id %d", &dp_table))
18847 else if (unformat (input, "bd_id %d", &dp_table))
18852 else if (unformat (input, "vni %d", &vni))
18860 if (action_set == 0)
18862 errmsg ("Action not set");
18865 if (dp_table_set == 0 || vni_set == 0)
18867 errmsg ("vni and dp_table must be set");
18871 /* Construct the API message */
18872 M (GPE_ADD_DEL_IFACE, mp);
18874 mp->is_add = is_add;
18875 mp->dp_table = clib_host_to_net_u32 (dp_table);
18877 mp->vni = clib_host_to_net_u32 (vni);
18882 /* Wait for a reply... */
18888 api_one_map_register_fallback_threshold (vat_main_t * vam)
18890 unformat_input_t *input = vam->input;
18891 vl_api_one_map_register_fallback_threshold_t *mp;
18896 /* Parse args required to build the message */
18897 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18899 if (unformat (input, "%u", &value))
18903 clib_warning ("parse error '%U'", format_unformat_error, input);
18910 errmsg ("fallback threshold value is missing!");
18914 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18915 mp->value = clib_host_to_net_u32 (value);
18920 /* Wait for a reply... */
18926 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
18928 vl_api_show_one_map_register_fallback_threshold_t *mp;
18931 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18936 /* Wait for a reply... */
18942 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
18944 u32 *proto = va_arg (*args, u32 *);
18946 if (unformat (input, "udp"))
18948 else if (unformat (input, "api"))
18957 api_one_set_transport_protocol (vat_main_t * vam)
18959 unformat_input_t *input = vam->input;
18960 vl_api_one_set_transport_protocol_t *mp;
18965 /* Parse args required to build the message */
18966 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18968 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
18972 clib_warning ("parse error '%U'", format_unformat_error, input);
18979 errmsg ("Transport protocol missing!");
18983 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
18984 mp->protocol = (u8) protocol;
18989 /* Wait for a reply... */
18995 api_one_get_transport_protocol (vat_main_t * vam)
18997 vl_api_one_get_transport_protocol_t *mp;
19000 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
19005 /* Wait for a reply... */
19011 api_one_map_register_set_ttl (vat_main_t * vam)
19013 unformat_input_t *input = vam->input;
19014 vl_api_one_map_register_set_ttl_t *mp;
19019 /* Parse args required to build the message */
19020 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19022 if (unformat (input, "%u", &ttl))
19026 clib_warning ("parse error '%U'", format_unformat_error, input);
19033 errmsg ("TTL value missing!");
19037 M (ONE_MAP_REGISTER_SET_TTL, mp);
19038 mp->ttl = clib_host_to_net_u32 (ttl);
19043 /* Wait for a reply... */
19049 api_show_one_map_register_ttl (vat_main_t * vam)
19051 vl_api_show_one_map_register_ttl_t *mp;
19054 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
19059 /* Wait for a reply... */
19065 * Add/del map request itr rlocs from ONE control plane and updates
19067 * @param vam vpp API test context
19068 * @return return code
19071 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
19073 unformat_input_t *input = vam->input;
19074 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
19075 u8 *locator_set_name = 0;
19076 u8 locator_set_name_set = 0;
19080 /* Parse args required to build the message */
19081 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19083 if (unformat (input, "del"))
19087 else if (unformat (input, "%_%v%_", &locator_set_name))
19089 locator_set_name_set = 1;
19093 clib_warning ("parse error '%U'", format_unformat_error, input);
19098 if (is_add && !locator_set_name_set)
19100 errmsg ("itr-rloc is not set!");
19104 if (is_add && vec_len (locator_set_name) > 64)
19106 errmsg ("itr-rloc locator-set name too long");
19107 vec_free (locator_set_name);
19111 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
19112 mp->is_add = is_add;
19115 clib_memcpy (mp->locator_set_name, locator_set_name,
19116 vec_len (locator_set_name));
19120 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
19122 vec_free (locator_set_name);
19127 /* Wait for a reply... */
19132 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
19135 api_one_locator_dump (vat_main_t * vam)
19137 unformat_input_t *input = vam->input;
19138 vl_api_one_locator_dump_t *mp;
19139 vl_api_control_ping_t *mp_ping;
19140 u8 is_index_set = 0, is_name_set = 0;
19145 /* Parse args required to build the message */
19146 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19148 if (unformat (input, "ls_name %_%v%_", &ls_name))
19152 else if (unformat (input, "ls_index %d", &ls_index))
19158 errmsg ("parse error '%U'", format_unformat_error, input);
19163 if (!is_index_set && !is_name_set)
19165 errmsg ("error: expected one of index or name!");
19169 if (is_index_set && is_name_set)
19171 errmsg ("error: only one param expected!");
19175 if (vec_len (ls_name) > 62)
19177 errmsg ("error: locator set name too long!");
19181 if (!vam->json_output)
19183 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
19186 M (ONE_LOCATOR_DUMP, mp);
19187 mp->is_index_set = is_index_set;
19190 mp->ls_index = clib_host_to_net_u32 (ls_index);
19193 vec_add1 (ls_name, 0);
19194 strncpy ((char *) mp->ls_name, (char *) ls_name,
19195 sizeof (mp->ls_name) - 1);
19201 /* Use a control ping for synchronization */
19202 MPING (CONTROL_PING, mp_ping);
19205 /* Wait for a reply... */
19210 #define api_lisp_locator_dump api_one_locator_dump
19213 api_one_locator_set_dump (vat_main_t * vam)
19215 vl_api_one_locator_set_dump_t *mp;
19216 vl_api_control_ping_t *mp_ping;
19217 unformat_input_t *input = vam->input;
19221 /* Parse args required to build the message */
19222 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19224 if (unformat (input, "local"))
19228 else if (unformat (input, "remote"))
19234 errmsg ("parse error '%U'", format_unformat_error, input);
19239 if (!vam->json_output)
19241 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
19244 M (ONE_LOCATOR_SET_DUMP, mp);
19246 mp->filter = filter;
19251 /* Use a control ping for synchronization */
19252 MPING (CONTROL_PING, mp_ping);
19255 /* Wait for a reply... */
19260 #define api_lisp_locator_set_dump api_one_locator_set_dump
19263 api_one_eid_table_map_dump (vat_main_t * vam)
19267 unformat_input_t *input = vam->input;
19268 vl_api_one_eid_table_map_dump_t *mp;
19269 vl_api_control_ping_t *mp_ping;
19272 /* Parse args required to build the message */
19273 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19275 if (unformat (input, "l2"))
19280 else if (unformat (input, "l3"))
19287 errmsg ("parse error '%U'", format_unformat_error, input);
19294 errmsg ("expected one of 'l2' or 'l3' parameter!");
19298 if (!vam->json_output)
19300 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
19303 M (ONE_EID_TABLE_MAP_DUMP, mp);
19309 /* Use a control ping for synchronization */
19310 MPING (CONTROL_PING, mp_ping);
19313 /* Wait for a reply... */
19318 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
19321 api_one_eid_table_vni_dump (vat_main_t * vam)
19323 vl_api_one_eid_table_vni_dump_t *mp;
19324 vl_api_control_ping_t *mp_ping;
19327 if (!vam->json_output)
19329 print (vam->ofp, "VNI");
19332 M (ONE_EID_TABLE_VNI_DUMP, mp);
19337 /* Use a control ping for synchronization */
19338 MPING (CONTROL_PING, mp_ping);
19341 /* Wait for a reply... */
19346 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
19349 api_one_eid_table_dump (vat_main_t * vam)
19351 unformat_input_t *i = vam->input;
19352 vl_api_one_eid_table_dump_t *mp;
19353 vl_api_control_ping_t *mp_ping;
19354 struct in_addr ip4;
19355 struct in6_addr ip6;
19357 u8 eid_type = ~0, eid_set = 0;
19358 u32 prefix_length = ~0, t, vni = 0;
19361 lisp_nsh_api_t nsh;
19363 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19365 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
19371 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
19377 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
19382 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
19387 else if (unformat (i, "vni %d", &t))
19391 else if (unformat (i, "local"))
19395 else if (unformat (i, "remote"))
19401 errmsg ("parse error '%U'", format_unformat_error, i);
19406 if (!vam->json_output)
19408 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
19409 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
19412 M (ONE_EID_TABLE_DUMP, mp);
19414 mp->filter = filter;
19418 mp->vni = htonl (vni);
19419 mp->eid_type = eid_type;
19423 mp->prefix_length = prefix_length;
19424 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
19427 mp->prefix_length = prefix_length;
19428 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
19431 clib_memcpy (mp->eid, mac, sizeof (mac));
19434 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
19437 errmsg ("unknown EID type %d!", eid_type);
19445 /* Use a control ping for synchronization */
19446 MPING (CONTROL_PING, mp_ping);
19449 /* Wait for a reply... */
19454 #define api_lisp_eid_table_dump api_one_eid_table_dump
19457 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
19459 unformat_input_t *i = vam->input;
19460 vl_api_gpe_fwd_entries_get_t *mp;
19465 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19467 if (unformat (i, "vni %d", &vni))
19473 errmsg ("parse error '%U'", format_unformat_error, i);
19480 errmsg ("vni not set!");
19484 if (!vam->json_output)
19486 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
19490 M (GPE_FWD_ENTRIES_GET, mp);
19491 mp->vni = clib_host_to_net_u32 (vni);
19496 /* Wait for a reply... */
19501 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
19502 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
19503 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
19504 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
19505 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
19506 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
19507 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
19508 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
19511 api_one_adjacencies_get (vat_main_t * vam)
19513 unformat_input_t *i = vam->input;
19514 vl_api_one_adjacencies_get_t *mp;
19519 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19521 if (unformat (i, "vni %d", &vni))
19527 errmsg ("parse error '%U'", format_unformat_error, i);
19534 errmsg ("vni not set!");
19538 if (!vam->json_output)
19540 print (vam->ofp, "%s %40s", "leid", "reid");
19543 M (ONE_ADJACENCIES_GET, mp);
19544 mp->vni = clib_host_to_net_u32 (vni);
19549 /* Wait for a reply... */
19554 #define api_lisp_adjacencies_get api_one_adjacencies_get
19557 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
19559 unformat_input_t *i = vam->input;
19560 vl_api_gpe_native_fwd_rpaths_get_t *mp;
19562 u8 ip_family_set = 0, is_ip4 = 1;
19564 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19566 if (unformat (i, "ip4"))
19571 else if (unformat (i, "ip6"))
19578 errmsg ("parse error '%U'", format_unformat_error, i);
19583 if (!ip_family_set)
19585 errmsg ("ip family not set!");
19589 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
19590 mp->is_ip4 = is_ip4;
19595 /* Wait for a reply... */
19601 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
19603 vl_api_gpe_fwd_entry_vnis_get_t *mp;
19606 if (!vam->json_output)
19608 print (vam->ofp, "VNIs");
19611 M (GPE_FWD_ENTRY_VNIS_GET, mp);
19616 /* Wait for a reply... */
19622 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
19624 unformat_input_t *i = vam->input;
19625 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
19627 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
19628 struct in_addr ip4;
19629 struct in6_addr ip6;
19630 u32 table_id = 0, nh_sw_if_index = ~0;
19632 memset (&ip4, 0, sizeof (ip4));
19633 memset (&ip6, 0, sizeof (ip6));
19635 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19637 if (unformat (i, "del"))
19639 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
19640 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19645 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
19646 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19651 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
19655 nh_sw_if_index = ~0;
19657 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
19661 nh_sw_if_index = ~0;
19663 else if (unformat (i, "table %d", &table_id))
19667 errmsg ("parse error '%U'", format_unformat_error, i);
19674 errmsg ("nh addr not set!");
19678 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
19679 mp->is_add = is_add;
19680 mp->table_id = clib_host_to_net_u32 (table_id);
19681 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
19682 mp->is_ip4 = is_ip4;
19684 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
19686 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
19691 /* Wait for a reply... */
19697 api_one_map_server_dump (vat_main_t * vam)
19699 vl_api_one_map_server_dump_t *mp;
19700 vl_api_control_ping_t *mp_ping;
19703 if (!vam->json_output)
19705 print (vam->ofp, "%=20s", "Map server");
19708 M (ONE_MAP_SERVER_DUMP, mp);
19712 /* Use a control ping for synchronization */
19713 MPING (CONTROL_PING, mp_ping);
19716 /* Wait for a reply... */
19721 #define api_lisp_map_server_dump api_one_map_server_dump
19724 api_one_map_resolver_dump (vat_main_t * vam)
19726 vl_api_one_map_resolver_dump_t *mp;
19727 vl_api_control_ping_t *mp_ping;
19730 if (!vam->json_output)
19732 print (vam->ofp, "%=20s", "Map resolver");
19735 M (ONE_MAP_RESOLVER_DUMP, mp);
19739 /* Use a control ping for synchronization */
19740 MPING (CONTROL_PING, mp_ping);
19743 /* Wait for a reply... */
19748 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
19751 api_one_stats_flush (vat_main_t * vam)
19753 vl_api_one_stats_flush_t *mp;
19756 M (ONE_STATS_FLUSH, mp);
19763 api_one_stats_dump (vat_main_t * vam)
19765 vl_api_one_stats_dump_t *mp;
19766 vl_api_control_ping_t *mp_ping;
19769 M (ONE_STATS_DUMP, mp);
19773 /* Use a control ping for synchronization */
19774 MPING (CONTROL_PING, mp_ping);
19777 /* Wait for a reply... */
19783 api_show_one_status (vat_main_t * vam)
19785 vl_api_show_one_status_t *mp;
19788 if (!vam->json_output)
19790 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
19793 M (SHOW_ONE_STATUS, mp);
19796 /* Wait for a reply... */
19801 #define api_show_lisp_status api_show_one_status
19804 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
19806 vl_api_gpe_fwd_entry_path_dump_t *mp;
19807 vl_api_control_ping_t *mp_ping;
19808 unformat_input_t *i = vam->input;
19809 u32 fwd_entry_index = ~0;
19812 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19814 if (unformat (i, "index %d", &fwd_entry_index))
19820 if (~0 == fwd_entry_index)
19822 errmsg ("no index specified!");
19826 if (!vam->json_output)
19828 print (vam->ofp, "first line");
19831 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
19835 /* Use a control ping for synchronization */
19836 MPING (CONTROL_PING, mp_ping);
19839 /* Wait for a reply... */
19845 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
19847 vl_api_one_get_map_request_itr_rlocs_t *mp;
19850 if (!vam->json_output)
19852 print (vam->ofp, "%=20s", "itr-rlocs:");
19855 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
19858 /* Wait for a reply... */
19863 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
19866 api_af_packet_create (vat_main_t * vam)
19868 unformat_input_t *i = vam->input;
19869 vl_api_af_packet_create_t *mp;
19870 u8 *host_if_name = 0;
19872 u8 random_hw_addr = 1;
19875 memset (hw_addr, 0, sizeof (hw_addr));
19877 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19879 if (unformat (i, "name %s", &host_if_name))
19880 vec_add1 (host_if_name, 0);
19881 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19882 random_hw_addr = 0;
19887 if (!vec_len (host_if_name))
19889 errmsg ("host-interface name must be specified");
19893 if (vec_len (host_if_name) > 64)
19895 errmsg ("host-interface name too long");
19899 M (AF_PACKET_CREATE, mp);
19901 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19902 clib_memcpy (mp->hw_addr, hw_addr, 6);
19903 mp->use_random_hw_addr = random_hw_addr;
19904 vec_free (host_if_name);
19912 fprintf (vam->ofp ? vam->ofp : stderr,
19913 " new sw_if_index = %d\n", vam->sw_if_index);
19920 api_af_packet_delete (vat_main_t * vam)
19922 unformat_input_t *i = vam->input;
19923 vl_api_af_packet_delete_t *mp;
19924 u8 *host_if_name = 0;
19927 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19929 if (unformat (i, "name %s", &host_if_name))
19930 vec_add1 (host_if_name, 0);
19935 if (!vec_len (host_if_name))
19937 errmsg ("host-interface name must be specified");
19941 if (vec_len (host_if_name) > 64)
19943 errmsg ("host-interface name too long");
19947 M (AF_PACKET_DELETE, mp);
19949 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19950 vec_free (host_if_name);
19957 static void vl_api_af_packet_details_t_handler
19958 (vl_api_af_packet_details_t * mp)
19960 vat_main_t *vam = &vat_main;
19962 print (vam->ofp, "%-16s %d",
19963 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
19966 static void vl_api_af_packet_details_t_handler_json
19967 (vl_api_af_packet_details_t * mp)
19969 vat_main_t *vam = &vat_main;
19970 vat_json_node_t *node = NULL;
19972 if (VAT_JSON_ARRAY != vam->json_tree.type)
19974 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19975 vat_json_init_array (&vam->json_tree);
19977 node = vat_json_array_add (&vam->json_tree);
19979 vat_json_init_object (node);
19980 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
19981 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
19985 api_af_packet_dump (vat_main_t * vam)
19987 vl_api_af_packet_dump_t *mp;
19988 vl_api_control_ping_t *mp_ping;
19991 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
19992 /* Get list of tap interfaces */
19993 M (AF_PACKET_DUMP, mp);
19996 /* Use a control ping for synchronization */
19997 MPING (CONTROL_PING, mp_ping);
20005 api_policer_add_del (vat_main_t * vam)
20007 unformat_input_t *i = vam->input;
20008 vl_api_policer_add_del_t *mp;
20018 u8 color_aware = 0;
20019 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
20022 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
20023 conform_action.dscp = 0;
20024 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
20025 exceed_action.dscp = 0;
20026 violate_action.action_type = SSE2_QOS_ACTION_DROP;
20027 violate_action.dscp = 0;
20029 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20031 if (unformat (i, "del"))
20033 else if (unformat (i, "name %s", &name))
20034 vec_add1 (name, 0);
20035 else if (unformat (i, "cir %u", &cir))
20037 else if (unformat (i, "eir %u", &eir))
20039 else if (unformat (i, "cb %u", &cb))
20041 else if (unformat (i, "eb %u", &eb))
20043 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
20046 else if (unformat (i, "round_type %U", unformat_policer_round_type,
20049 else if (unformat (i, "type %U", unformat_policer_type, &type))
20051 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
20054 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
20057 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
20060 else if (unformat (i, "color-aware"))
20066 if (!vec_len (name))
20068 errmsg ("policer name must be specified");
20072 if (vec_len (name) > 64)
20074 errmsg ("policer name too long");
20078 M (POLICER_ADD_DEL, mp);
20080 clib_memcpy (mp->name, name, vec_len (name));
20082 mp->is_add = is_add;
20083 mp->cir = ntohl (cir);
20084 mp->eir = ntohl (eir);
20085 mp->cb = clib_net_to_host_u64 (cb);
20086 mp->eb = clib_net_to_host_u64 (eb);
20087 mp->rate_type = rate_type;
20088 mp->round_type = round_type;
20090 mp->conform_action_type = conform_action.action_type;
20091 mp->conform_dscp = conform_action.dscp;
20092 mp->exceed_action_type = exceed_action.action_type;
20093 mp->exceed_dscp = exceed_action.dscp;
20094 mp->violate_action_type = violate_action.action_type;
20095 mp->violate_dscp = violate_action.dscp;
20096 mp->color_aware = color_aware;
20104 api_policer_dump (vat_main_t * vam)
20106 unformat_input_t *i = vam->input;
20107 vl_api_policer_dump_t *mp;
20108 vl_api_control_ping_t *mp_ping;
20109 u8 *match_name = 0;
20110 u8 match_name_valid = 0;
20113 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20115 if (unformat (i, "name %s", &match_name))
20117 vec_add1 (match_name, 0);
20118 match_name_valid = 1;
20124 M (POLICER_DUMP, mp);
20125 mp->match_name_valid = match_name_valid;
20126 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
20127 vec_free (match_name);
20131 /* Use a control ping for synchronization */
20132 MPING (CONTROL_PING, mp_ping);
20135 /* Wait for a reply... */
20141 api_policer_classify_set_interface (vat_main_t * vam)
20143 unformat_input_t *i = vam->input;
20144 vl_api_policer_classify_set_interface_t *mp;
20146 int sw_if_index_set;
20147 u32 ip4_table_index = ~0;
20148 u32 ip6_table_index = ~0;
20149 u32 l2_table_index = ~0;
20153 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20155 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20156 sw_if_index_set = 1;
20157 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20158 sw_if_index_set = 1;
20159 else if (unformat (i, "del"))
20161 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20163 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20165 else if (unformat (i, "l2-table %d", &l2_table_index))
20169 clib_warning ("parse error '%U'", format_unformat_error, i);
20174 if (sw_if_index_set == 0)
20176 errmsg ("missing interface name or sw_if_index");
20180 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
20182 mp->sw_if_index = ntohl (sw_if_index);
20183 mp->ip4_table_index = ntohl (ip4_table_index);
20184 mp->ip6_table_index = ntohl (ip6_table_index);
20185 mp->l2_table_index = ntohl (l2_table_index);
20186 mp->is_add = is_add;
20194 api_policer_classify_dump (vat_main_t * vam)
20196 unformat_input_t *i = vam->input;
20197 vl_api_policer_classify_dump_t *mp;
20198 vl_api_control_ping_t *mp_ping;
20199 u8 type = POLICER_CLASSIFY_N_TABLES;
20202 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
20206 errmsg ("classify table type must be specified");
20210 if (!vam->json_output)
20212 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20215 M (POLICER_CLASSIFY_DUMP, mp);
20220 /* Use a control ping for synchronization */
20221 MPING (CONTROL_PING, mp_ping);
20224 /* Wait for a reply... */
20230 api_netmap_create (vat_main_t * vam)
20232 unformat_input_t *i = vam->input;
20233 vl_api_netmap_create_t *mp;
20236 u8 random_hw_addr = 1;
20241 memset (hw_addr, 0, sizeof (hw_addr));
20243 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20245 if (unformat (i, "name %s", &if_name))
20246 vec_add1 (if_name, 0);
20247 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
20248 random_hw_addr = 0;
20249 else if (unformat (i, "pipe"))
20251 else if (unformat (i, "master"))
20253 else if (unformat (i, "slave"))
20259 if (!vec_len (if_name))
20261 errmsg ("interface name must be specified");
20265 if (vec_len (if_name) > 64)
20267 errmsg ("interface name too long");
20271 M (NETMAP_CREATE, mp);
20273 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20274 clib_memcpy (mp->hw_addr, hw_addr, 6);
20275 mp->use_random_hw_addr = random_hw_addr;
20276 mp->is_pipe = is_pipe;
20277 mp->is_master = is_master;
20278 vec_free (if_name);
20286 api_netmap_delete (vat_main_t * vam)
20288 unformat_input_t *i = vam->input;
20289 vl_api_netmap_delete_t *mp;
20293 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20295 if (unformat (i, "name %s", &if_name))
20296 vec_add1 (if_name, 0);
20301 if (!vec_len (if_name))
20303 errmsg ("interface name must be specified");
20307 if (vec_len (if_name) > 64)
20309 errmsg ("interface name too long");
20313 M (NETMAP_DELETE, mp);
20315 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20316 vec_free (if_name);
20324 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
20326 if (fp->afi == IP46_TYPE_IP6)
20328 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20329 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20330 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20331 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20332 format_ip6_address, fp->next_hop);
20333 else if (fp->afi == IP46_TYPE_IP4)
20335 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20336 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20337 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20338 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20339 format_ip4_address, fp->next_hop);
20343 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
20344 vl_api_fib_path_t * fp)
20346 struct in_addr ip4;
20347 struct in6_addr ip6;
20349 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20350 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20351 vat_json_object_add_uint (node, "is_local", fp->is_local);
20352 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20353 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20354 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20355 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20356 if (fp->afi == IP46_TYPE_IP4)
20358 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20359 vat_json_object_add_ip4 (node, "next_hop", ip4);
20361 else if (fp->afi == IP46_TYPE_IP6)
20363 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20364 vat_json_object_add_ip6 (node, "next_hop", ip6);
20369 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
20371 vat_main_t *vam = &vat_main;
20372 int count = ntohl (mp->mt_count);
20373 vl_api_fib_path_t *fp;
20376 print (vam->ofp, "[%d]: sw_if_index %d via:",
20377 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
20379 for (i = 0; i < count; i++)
20381 vl_api_mpls_fib_path_print (vam, fp);
20385 print (vam->ofp, "");
20388 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
20389 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
20392 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
20394 vat_main_t *vam = &vat_main;
20395 vat_json_node_t *node = NULL;
20396 int count = ntohl (mp->mt_count);
20397 vl_api_fib_path_t *fp;
20400 if (VAT_JSON_ARRAY != vam->json_tree.type)
20402 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20403 vat_json_init_array (&vam->json_tree);
20405 node = vat_json_array_add (&vam->json_tree);
20407 vat_json_init_object (node);
20408 vat_json_object_add_uint (node, "tunnel_index",
20409 ntohl (mp->mt_tunnel_index));
20410 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
20412 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
20415 for (i = 0; i < count; i++)
20417 vl_api_mpls_fib_path_json_print (node, fp);
20423 api_mpls_tunnel_dump (vat_main_t * vam)
20425 vl_api_mpls_tunnel_dump_t *mp;
20426 vl_api_control_ping_t *mp_ping;
20430 /* Parse args required to build the message */
20431 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
20433 if (!unformat (vam->input, "tunnel_index %d", &index))
20440 print (vam->ofp, " tunnel_index %d", index);
20442 M (MPLS_TUNNEL_DUMP, mp);
20443 mp->tunnel_index = htonl (index);
20446 /* Use a control ping for synchronization */
20447 MPING (CONTROL_PING, mp_ping);
20454 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
20455 #define vl_api_mpls_fib_details_t_print vl_noop_handler
20459 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
20461 vat_main_t *vam = &vat_main;
20462 int count = ntohl (mp->count);
20463 vl_api_fib_path_t *fp;
20467 "table-id %d, label %u, ess_bit %u",
20468 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
20470 for (i = 0; i < count; i++)
20472 vl_api_mpls_fib_path_print (vam, fp);
20477 static void vl_api_mpls_fib_details_t_handler_json
20478 (vl_api_mpls_fib_details_t * mp)
20480 vat_main_t *vam = &vat_main;
20481 int count = ntohl (mp->count);
20482 vat_json_node_t *node = NULL;
20483 vl_api_fib_path_t *fp;
20486 if (VAT_JSON_ARRAY != vam->json_tree.type)
20488 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20489 vat_json_init_array (&vam->json_tree);
20491 node = vat_json_array_add (&vam->json_tree);
20493 vat_json_init_object (node);
20494 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20495 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
20496 vat_json_object_add_uint (node, "label", ntohl (mp->label));
20497 vat_json_object_add_uint (node, "path_count", count);
20499 for (i = 0; i < count; i++)
20501 vl_api_mpls_fib_path_json_print (node, fp);
20507 api_mpls_fib_dump (vat_main_t * vam)
20509 vl_api_mpls_fib_dump_t *mp;
20510 vl_api_control_ping_t *mp_ping;
20513 M (MPLS_FIB_DUMP, mp);
20516 /* Use a control ping for synchronization */
20517 MPING (CONTROL_PING, mp_ping);
20524 #define vl_api_ip_fib_details_t_endian vl_noop_handler
20525 #define vl_api_ip_fib_details_t_print vl_noop_handler
20528 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
20530 vat_main_t *vam = &vat_main;
20531 int count = ntohl (mp->count);
20532 vl_api_fib_path_t *fp;
20536 "table-id %d, prefix %U/%d stats-index %d",
20537 ntohl (mp->table_id), format_ip4_address, mp->address,
20538 mp->address_length, ntohl (mp->stats_index));
20540 for (i = 0; i < count; i++)
20542 if (fp->afi == IP46_TYPE_IP6)
20544 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20545 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U, "
20546 "next_hop_table %d",
20547 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20548 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20549 format_ip6_address, fp->next_hop, ntohl (fp->table_id));
20550 else if (fp->afi == IP46_TYPE_IP4)
20552 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20553 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U, "
20554 "next_hop_table %d",
20555 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20556 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20557 format_ip4_address, fp->next_hop, ntohl (fp->table_id));
20562 static void vl_api_ip_fib_details_t_handler_json
20563 (vl_api_ip_fib_details_t * mp)
20565 vat_main_t *vam = &vat_main;
20566 int count = ntohl (mp->count);
20567 vat_json_node_t *node = NULL;
20568 struct in_addr ip4;
20569 struct in6_addr ip6;
20570 vl_api_fib_path_t *fp;
20573 if (VAT_JSON_ARRAY != vam->json_tree.type)
20575 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20576 vat_json_init_array (&vam->json_tree);
20578 node = vat_json_array_add (&vam->json_tree);
20580 vat_json_init_object (node);
20581 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20582 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
20583 vat_json_object_add_ip4 (node, "prefix", ip4);
20584 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20585 vat_json_object_add_uint (node, "path_count", count);
20587 for (i = 0; i < count; i++)
20589 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20590 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20591 vat_json_object_add_uint (node, "is_local", fp->is_local);
20592 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20593 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20594 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20595 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20596 if (fp->afi == IP46_TYPE_IP4)
20598 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20599 vat_json_object_add_ip4 (node, "next_hop", ip4);
20601 else if (fp->afi == IP46_TYPE_IP6)
20603 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20604 vat_json_object_add_ip6 (node, "next_hop", ip6);
20610 api_ip_fib_dump (vat_main_t * vam)
20612 vl_api_ip_fib_dump_t *mp;
20613 vl_api_control_ping_t *mp_ping;
20616 M (IP_FIB_DUMP, mp);
20619 /* Use a control ping for synchronization */
20620 MPING (CONTROL_PING, mp_ping);
20628 api_ip_mfib_dump (vat_main_t * vam)
20630 vl_api_ip_mfib_dump_t *mp;
20631 vl_api_control_ping_t *mp_ping;
20634 M (IP_MFIB_DUMP, mp);
20637 /* Use a control ping for synchronization */
20638 MPING (CONTROL_PING, mp_ping);
20645 static void vl_api_ip_neighbor_details_t_handler
20646 (vl_api_ip_neighbor_details_t * mp)
20648 vat_main_t *vam = &vat_main;
20650 print (vam->ofp, "%c %U %U",
20651 (mp->is_static) ? 'S' : 'D',
20652 format_ethernet_address, &mp->mac_address,
20653 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
20657 static void vl_api_ip_neighbor_details_t_handler_json
20658 (vl_api_ip_neighbor_details_t * mp)
20661 vat_main_t *vam = &vat_main;
20662 vat_json_node_t *node;
20663 struct in_addr ip4;
20664 struct in6_addr ip6;
20666 if (VAT_JSON_ARRAY != vam->json_tree.type)
20668 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20669 vat_json_init_array (&vam->json_tree);
20671 node = vat_json_array_add (&vam->json_tree);
20673 vat_json_init_object (node);
20674 vat_json_object_add_string_copy (node, "flag",
20675 (mp->is_static) ? (u8 *) "static" : (u8 *)
20678 vat_json_object_add_string_copy (node, "link_layer",
20679 format (0, "%U", format_ethernet_address,
20680 &mp->mac_address));
20684 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
20685 vat_json_object_add_ip6 (node, "ip_address", ip6);
20689 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
20690 vat_json_object_add_ip4 (node, "ip_address", ip4);
20695 api_ip_neighbor_dump (vat_main_t * vam)
20697 unformat_input_t *i = vam->input;
20698 vl_api_ip_neighbor_dump_t *mp;
20699 vl_api_control_ping_t *mp_ping;
20701 u32 sw_if_index = ~0;
20704 /* Parse args required to build the message */
20705 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20707 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20709 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20711 else if (unformat (i, "ip6"))
20717 if (sw_if_index == ~0)
20719 errmsg ("missing interface name or sw_if_index");
20723 M (IP_NEIGHBOR_DUMP, mp);
20724 mp->is_ipv6 = (u8) is_ipv6;
20725 mp->sw_if_index = ntohl (sw_if_index);
20728 /* Use a control ping for synchronization */
20729 MPING (CONTROL_PING, mp_ping);
20736 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
20737 #define vl_api_ip6_fib_details_t_print vl_noop_handler
20740 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
20742 vat_main_t *vam = &vat_main;
20743 int count = ntohl (mp->count);
20744 vl_api_fib_path_t *fp;
20748 "table-id %d, prefix %U/%d stats-index %d",
20749 ntohl (mp->table_id), format_ip6_address, mp->address,
20750 mp->address_length, ntohl (mp->stats_index));
20752 for (i = 0; i < count; i++)
20754 if (fp->afi == IP46_TYPE_IP6)
20756 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20757 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20758 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20759 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20760 format_ip6_address, fp->next_hop);
20761 else if (fp->afi == IP46_TYPE_IP4)
20763 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20764 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20765 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20766 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20767 format_ip4_address, fp->next_hop);
20772 static void vl_api_ip6_fib_details_t_handler_json
20773 (vl_api_ip6_fib_details_t * mp)
20775 vat_main_t *vam = &vat_main;
20776 int count = ntohl (mp->count);
20777 vat_json_node_t *node = NULL;
20778 struct in_addr ip4;
20779 struct in6_addr ip6;
20780 vl_api_fib_path_t *fp;
20783 if (VAT_JSON_ARRAY != vam->json_tree.type)
20785 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20786 vat_json_init_array (&vam->json_tree);
20788 node = vat_json_array_add (&vam->json_tree);
20790 vat_json_init_object (node);
20791 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20792 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
20793 vat_json_object_add_ip6 (node, "prefix", ip6);
20794 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20795 vat_json_object_add_uint (node, "path_count", count);
20797 for (i = 0; i < count; i++)
20799 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20800 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20801 vat_json_object_add_uint (node, "is_local", fp->is_local);
20802 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20803 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20804 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20805 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20806 if (fp->afi == IP46_TYPE_IP4)
20808 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20809 vat_json_object_add_ip4 (node, "next_hop", ip4);
20811 else if (fp->afi == IP46_TYPE_IP6)
20813 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20814 vat_json_object_add_ip6 (node, "next_hop", ip6);
20820 api_ip6_fib_dump (vat_main_t * vam)
20822 vl_api_ip6_fib_dump_t *mp;
20823 vl_api_control_ping_t *mp_ping;
20826 M (IP6_FIB_DUMP, mp);
20829 /* Use a control ping for synchronization */
20830 MPING (CONTROL_PING, mp_ping);
20838 api_ip6_mfib_dump (vat_main_t * vam)
20840 vl_api_ip6_mfib_dump_t *mp;
20841 vl_api_control_ping_t *mp_ping;
20844 M (IP6_MFIB_DUMP, mp);
20847 /* Use a control ping for synchronization */
20848 MPING (CONTROL_PING, mp_ping);
20856 api_classify_table_ids (vat_main_t * vam)
20858 vl_api_classify_table_ids_t *mp;
20861 /* Construct the API message */
20862 M (CLASSIFY_TABLE_IDS, mp);
20871 api_classify_table_by_interface (vat_main_t * vam)
20873 unformat_input_t *input = vam->input;
20874 vl_api_classify_table_by_interface_t *mp;
20876 u32 sw_if_index = ~0;
20878 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20880 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20882 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20887 if (sw_if_index == ~0)
20889 errmsg ("missing interface name or sw_if_index");
20893 /* Construct the API message */
20894 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
20896 mp->sw_if_index = ntohl (sw_if_index);
20904 api_classify_table_info (vat_main_t * vam)
20906 unformat_input_t *input = vam->input;
20907 vl_api_classify_table_info_t *mp;
20911 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20913 if (unformat (input, "table_id %d", &table_id))
20918 if (table_id == ~0)
20920 errmsg ("missing table id");
20924 /* Construct the API message */
20925 M (CLASSIFY_TABLE_INFO, mp);
20927 mp->table_id = ntohl (table_id);
20935 api_classify_session_dump (vat_main_t * vam)
20937 unformat_input_t *input = vam->input;
20938 vl_api_classify_session_dump_t *mp;
20939 vl_api_control_ping_t *mp_ping;
20943 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20945 if (unformat (input, "table_id %d", &table_id))
20950 if (table_id == ~0)
20952 errmsg ("missing table id");
20956 /* Construct the API message */
20957 M (CLASSIFY_SESSION_DUMP, mp);
20959 mp->table_id = ntohl (table_id);
20962 /* Use a control ping for synchronization */
20963 MPING (CONTROL_PING, mp_ping);
20971 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
20973 vat_main_t *vam = &vat_main;
20975 print (vam->ofp, "collector_address %U, collector_port %d, "
20976 "src_address %U, vrf_id %d, path_mtu %u, "
20977 "template_interval %u, udp_checksum %d",
20978 format_ip4_address, mp->collector_address,
20979 ntohs (mp->collector_port),
20980 format_ip4_address, mp->src_address,
20981 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
20982 ntohl (mp->template_interval), mp->udp_checksum);
20985 vam->result_ready = 1;
20989 vl_api_ipfix_exporter_details_t_handler_json
20990 (vl_api_ipfix_exporter_details_t * mp)
20992 vat_main_t *vam = &vat_main;
20993 vat_json_node_t node;
20994 struct in_addr collector_address;
20995 struct in_addr src_address;
20997 vat_json_init_object (&node);
20998 clib_memcpy (&collector_address, &mp->collector_address,
20999 sizeof (collector_address));
21000 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
21001 vat_json_object_add_uint (&node, "collector_port",
21002 ntohs (mp->collector_port));
21003 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
21004 vat_json_object_add_ip4 (&node, "src_address", src_address);
21005 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
21006 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
21007 vat_json_object_add_uint (&node, "template_interval",
21008 ntohl (mp->template_interval));
21009 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
21011 vat_json_print (vam->ofp, &node);
21012 vat_json_free (&node);
21014 vam->result_ready = 1;
21018 api_ipfix_exporter_dump (vat_main_t * vam)
21020 vl_api_ipfix_exporter_dump_t *mp;
21023 /* Construct the API message */
21024 M (IPFIX_EXPORTER_DUMP, mp);
21033 api_ipfix_classify_stream_dump (vat_main_t * vam)
21035 vl_api_ipfix_classify_stream_dump_t *mp;
21038 /* Construct the API message */
21039 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
21050 vl_api_ipfix_classify_stream_details_t_handler
21051 (vl_api_ipfix_classify_stream_details_t * mp)
21053 vat_main_t *vam = &vat_main;
21054 print (vam->ofp, "domain_id %d, src_port %d",
21055 ntohl (mp->domain_id), ntohs (mp->src_port));
21057 vam->result_ready = 1;
21061 vl_api_ipfix_classify_stream_details_t_handler_json
21062 (vl_api_ipfix_classify_stream_details_t * mp)
21064 vat_main_t *vam = &vat_main;
21065 vat_json_node_t node;
21067 vat_json_init_object (&node);
21068 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
21069 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
21071 vat_json_print (vam->ofp, &node);
21072 vat_json_free (&node);
21074 vam->result_ready = 1;
21078 api_ipfix_classify_table_dump (vat_main_t * vam)
21080 vl_api_ipfix_classify_table_dump_t *mp;
21081 vl_api_control_ping_t *mp_ping;
21084 if (!vam->json_output)
21086 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
21087 "transport_protocol");
21090 /* Construct the API message */
21091 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
21096 /* Use a control ping for synchronization */
21097 MPING (CONTROL_PING, mp_ping);
21105 vl_api_ipfix_classify_table_details_t_handler
21106 (vl_api_ipfix_classify_table_details_t * mp)
21108 vat_main_t *vam = &vat_main;
21109 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
21110 mp->transport_protocol);
21114 vl_api_ipfix_classify_table_details_t_handler_json
21115 (vl_api_ipfix_classify_table_details_t * mp)
21117 vat_json_node_t *node = NULL;
21118 vat_main_t *vam = &vat_main;
21120 if (VAT_JSON_ARRAY != vam->json_tree.type)
21122 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21123 vat_json_init_array (&vam->json_tree);
21126 node = vat_json_array_add (&vam->json_tree);
21127 vat_json_init_object (node);
21129 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
21130 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
21131 vat_json_object_add_uint (node, "transport_protocol",
21132 mp->transport_protocol);
21136 api_sw_interface_span_enable_disable (vat_main_t * vam)
21138 unformat_input_t *i = vam->input;
21139 vl_api_sw_interface_span_enable_disable_t *mp;
21140 u32 src_sw_if_index = ~0;
21141 u32 dst_sw_if_index = ~0;
21146 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21149 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
21151 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
21155 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
21157 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
21159 else if (unformat (i, "disable"))
21161 else if (unformat (i, "rx"))
21163 else if (unformat (i, "tx"))
21165 else if (unformat (i, "both"))
21167 else if (unformat (i, "l2"))
21173 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
21175 mp->sw_if_index_from = htonl (src_sw_if_index);
21176 mp->sw_if_index_to = htonl (dst_sw_if_index);
21186 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
21189 vat_main_t *vam = &vat_main;
21190 u8 *sw_if_from_name = 0;
21191 u8 *sw_if_to_name = 0;
21192 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
21193 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
21194 char *states[] = { "none", "rx", "tx", "both" };
21198 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
21200 if ((u32) p->value[0] == sw_if_index_from)
21202 sw_if_from_name = (u8 *)(p->key);
21206 if ((u32) p->value[0] == sw_if_index_to)
21208 sw_if_to_name = (u8 *)(p->key);
21209 if (sw_if_from_name)
21214 print (vam->ofp, "%20s => %20s (%s) %s",
21215 sw_if_from_name, sw_if_to_name, states[mp->state],
21216 mp->is_l2 ? "l2" : "device");
21220 vl_api_sw_interface_span_details_t_handler_json
21221 (vl_api_sw_interface_span_details_t * mp)
21223 vat_main_t *vam = &vat_main;
21224 vat_json_node_t *node = NULL;
21225 u8 *sw_if_from_name = 0;
21226 u8 *sw_if_to_name = 0;
21227 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
21228 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
21232 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
21234 if ((u32) p->value[0] == sw_if_index_from)
21236 sw_if_from_name = (u8 *)(p->key);
21240 if ((u32) p->value[0] == sw_if_index_to)
21242 sw_if_to_name = (u8 *)(p->key);
21243 if (sw_if_from_name)
21249 if (VAT_JSON_ARRAY != vam->json_tree.type)
21251 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21252 vat_json_init_array (&vam->json_tree);
21254 node = vat_json_array_add (&vam->json_tree);
21256 vat_json_init_object (node);
21257 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
21258 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
21259 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
21260 if (0 != sw_if_to_name)
21262 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
21264 vat_json_object_add_uint (node, "state", mp->state);
21265 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
21269 api_sw_interface_span_dump (vat_main_t * vam)
21271 unformat_input_t *input = vam->input;
21272 vl_api_sw_interface_span_dump_t *mp;
21273 vl_api_control_ping_t *mp_ping;
21277 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21279 if (unformat (input, "l2"))
21285 M (SW_INTERFACE_SPAN_DUMP, mp);
21289 /* Use a control ping for synchronization */
21290 MPING (CONTROL_PING, mp_ping);
21298 api_pg_create_interface (vat_main_t * vam)
21300 unformat_input_t *input = vam->input;
21301 vl_api_pg_create_interface_t *mp;
21305 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21307 if (unformat (input, "if_id %d", &if_id))
21314 errmsg ("missing pg interface index");
21318 /* Construct the API message */
21319 M (PG_CREATE_INTERFACE, mp);
21321 mp->interface_id = ntohl (if_id);
21329 api_pg_capture (vat_main_t * vam)
21331 unformat_input_t *input = vam->input;
21332 vl_api_pg_capture_t *mp;
21337 u8 pcap_file_set = 0;
21340 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21342 if (unformat (input, "if_id %d", &if_id))
21344 else if (unformat (input, "pcap %s", &pcap_file))
21346 else if (unformat (input, "count %d", &count))
21348 else if (unformat (input, "disable"))
21355 errmsg ("missing pg interface index");
21358 if (pcap_file_set > 0)
21360 if (vec_len (pcap_file) > 255)
21362 errmsg ("pcap file name is too long");
21367 u32 name_len = vec_len (pcap_file);
21368 /* Construct the API message */
21369 M (PG_CAPTURE, mp);
21371 mp->interface_id = ntohl (if_id);
21372 mp->is_enabled = enable;
21373 mp->count = ntohl (count);
21374 mp->pcap_name_length = ntohl (name_len);
21375 if (pcap_file_set != 0)
21377 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
21379 vec_free (pcap_file);
21387 api_pg_enable_disable (vat_main_t * vam)
21389 unformat_input_t *input = vam->input;
21390 vl_api_pg_enable_disable_t *mp;
21393 u8 stream_name_set = 0;
21394 u8 *stream_name = 0;
21396 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21398 if (unformat (input, "stream %s", &stream_name))
21399 stream_name_set = 1;
21400 else if (unformat (input, "disable"))
21406 if (stream_name_set > 0)
21408 if (vec_len (stream_name) > 255)
21410 errmsg ("stream name too long");
21415 u32 name_len = vec_len (stream_name);
21416 /* Construct the API message */
21417 M (PG_ENABLE_DISABLE, mp);
21419 mp->is_enabled = enable;
21420 if (stream_name_set != 0)
21422 mp->stream_name_length = ntohl (name_len);
21423 clib_memcpy (mp->stream_name, stream_name, name_len);
21425 vec_free (stream_name);
21433 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
21435 unformat_input_t *input = vam->input;
21436 vl_api_ip_source_and_port_range_check_add_del_t *mp;
21438 u16 *low_ports = 0;
21439 u16 *high_ports = 0;
21442 ip4_address_t ip4_addr;
21443 ip6_address_t ip6_addr;
21452 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21454 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
21460 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
21465 else if (unformat (input, "vrf %d", &vrf_id))
21467 else if (unformat (input, "del"))
21469 else if (unformat (input, "port %d", &tmp))
21471 if (tmp == 0 || tmp > 65535)
21473 errmsg ("port %d out of range", tmp);
21477 this_hi = this_low + 1;
21478 vec_add1 (low_ports, this_low);
21479 vec_add1 (high_ports, this_hi);
21481 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
21483 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
21485 errmsg ("incorrect range parameters");
21489 /* Note: in debug CLI +1 is added to high before
21490 passing to real fn that does "the work"
21491 (ip_source_and_port_range_check_add_del).
21492 This fn is a wrapper around the binary API fn a
21493 control plane will call, which expects this increment
21494 to have occurred. Hence letting the binary API control
21495 plane fn do the increment for consistency between VAT
21496 and other control planes.
21499 vec_add1 (low_ports, this_low);
21500 vec_add1 (high_ports, this_hi);
21506 if (prefix_set == 0)
21508 errmsg ("<address>/<mask> not specified");
21514 errmsg ("VRF ID required, not specified");
21521 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21525 if (vec_len (low_ports) == 0)
21527 errmsg ("At least one port or port range required");
21531 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
21533 mp->is_add = is_add;
21538 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
21543 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
21546 mp->mask_length = length;
21547 mp->number_of_ranges = vec_len (low_ports);
21549 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
21550 vec_free (low_ports);
21552 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
21553 vec_free (high_ports);
21555 mp->vrf_id = ntohl (vrf_id);
21563 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
21565 unformat_input_t *input = vam->input;
21566 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
21567 u32 sw_if_index = ~0;
21569 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
21570 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
21574 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21576 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21578 else if (unformat (input, "sw_if_index %d", &sw_if_index))
21580 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
21582 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
21584 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
21586 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
21588 else if (unformat (input, "del"))
21594 if (sw_if_index == ~0)
21596 errmsg ("Interface required but not specified");
21602 errmsg ("VRF ID required but not specified");
21606 if (tcp_out_vrf_id == 0
21607 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
21610 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21614 /* Construct the API message */
21615 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
21617 mp->sw_if_index = ntohl (sw_if_index);
21618 mp->is_add = is_add;
21619 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
21620 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
21621 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
21622 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
21627 /* Wait for a reply... */
21633 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
21635 unformat_input_t *i = vam->input;
21636 vl_api_ipsec_gre_add_del_tunnel_t *mp;
21637 u32 local_sa_id = 0;
21638 u32 remote_sa_id = 0;
21639 ip4_address_t src_address;
21640 ip4_address_t dst_address;
21644 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21646 if (unformat (i, "local_sa %d", &local_sa_id))
21648 else if (unformat (i, "remote_sa %d", &remote_sa_id))
21650 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
21652 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
21654 else if (unformat (i, "del"))
21658 clib_warning ("parse error '%U'", format_unformat_error, i);
21663 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
21665 mp->local_sa_id = ntohl (local_sa_id);
21666 mp->remote_sa_id = ntohl (remote_sa_id);
21667 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
21668 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
21669 mp->is_add = is_add;
21677 api_punt (vat_main_t * vam)
21679 unformat_input_t *i = vam->input;
21687 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21689 if (unformat (i, "ip %d", &ipv))
21691 else if (unformat (i, "protocol %d", &protocol))
21693 else if (unformat (i, "port %d", &port))
21695 else if (unformat (i, "del"))
21699 clib_warning ("parse error '%U'", format_unformat_error, i);
21706 mp->is_add = (u8) is_add;
21707 mp->ipv = (u8) ipv;
21708 mp->l4_protocol = (u8) protocol;
21709 mp->l4_port = htons ((u16) port);
21716 static void vl_api_ipsec_gre_tunnel_details_t_handler
21717 (vl_api_ipsec_gre_tunnel_details_t * mp)
21719 vat_main_t *vam = &vat_main;
21721 print (vam->ofp, "%11d%15U%15U%14d%14d",
21722 ntohl (mp->sw_if_index),
21723 format_ip4_address, &mp->src_address,
21724 format_ip4_address, &mp->dst_address,
21725 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
21728 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
21729 (vl_api_ipsec_gre_tunnel_details_t * mp)
21731 vat_main_t *vam = &vat_main;
21732 vat_json_node_t *node = NULL;
21733 struct in_addr ip4;
21735 if (VAT_JSON_ARRAY != vam->json_tree.type)
21737 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21738 vat_json_init_array (&vam->json_tree);
21740 node = vat_json_array_add (&vam->json_tree);
21742 vat_json_init_object (node);
21743 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
21744 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
21745 vat_json_object_add_ip4 (node, "src_address", ip4);
21746 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
21747 vat_json_object_add_ip4 (node, "dst_address", ip4);
21748 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
21749 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
21753 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
21755 unformat_input_t *i = vam->input;
21756 vl_api_ipsec_gre_tunnel_dump_t *mp;
21757 vl_api_control_ping_t *mp_ping;
21759 u8 sw_if_index_set = 0;
21762 /* Parse args required to build the message */
21763 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21765 if (unformat (i, "sw_if_index %d", &sw_if_index))
21766 sw_if_index_set = 1;
21771 if (sw_if_index_set == 0)
21776 if (!vam->json_output)
21778 print (vam->ofp, "%11s%15s%15s%14s%14s",
21779 "sw_if_index", "src_address", "dst_address",
21780 "local_sa_id", "remote_sa_id");
21783 /* Get list of gre-tunnel interfaces */
21784 M (IPSEC_GRE_TUNNEL_DUMP, mp);
21786 mp->sw_if_index = htonl (sw_if_index);
21790 /* Use a control ping for synchronization */
21791 MPING (CONTROL_PING, mp_ping);
21799 api_delete_subif (vat_main_t * vam)
21801 unformat_input_t *i = vam->input;
21802 vl_api_delete_subif_t *mp;
21803 u32 sw_if_index = ~0;
21806 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21808 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21810 if (unformat (i, "sw_if_index %d", &sw_if_index))
21816 if (sw_if_index == ~0)
21818 errmsg ("missing sw_if_index");
21822 /* Construct the API message */
21823 M (DELETE_SUBIF, mp);
21824 mp->sw_if_index = ntohl (sw_if_index);
21831 #define foreach_pbb_vtr_op \
21832 _("disable", L2_VTR_DISABLED) \
21833 _("pop", L2_VTR_POP_2) \
21834 _("push", L2_VTR_PUSH_2)
21837 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
21839 unformat_input_t *i = vam->input;
21840 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
21841 u32 sw_if_index = ~0, vtr_op = ~0;
21842 u16 outer_tag = ~0;
21843 u8 dmac[6], smac[6];
21844 u8 dmac_set = 0, smac_set = 0;
21850 /* Shut up coverity */
21851 memset (dmac, 0, sizeof (dmac));
21852 memset (smac, 0, sizeof (smac));
21854 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21856 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21858 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21860 else if (unformat (i, "vtr_op %d", &vtr_op))
21862 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
21865 else if (unformat (i, "translate_pbb_stag"))
21867 if (unformat (i, "%d", &tmp))
21869 vtr_op = L2_VTR_TRANSLATE_2_1;
21875 ("translate_pbb_stag operation requires outer tag definition");
21879 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
21881 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
21883 else if (unformat (i, "sid %d", &sid))
21885 else if (unformat (i, "vlanid %d", &tmp))
21889 clib_warning ("parse error '%U'", format_unformat_error, i);
21894 if ((sw_if_index == ~0) || (vtr_op == ~0))
21896 errmsg ("missing sw_if_index or vtr operation");
21899 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
21900 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
21903 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
21907 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
21908 mp->sw_if_index = ntohl (sw_if_index);
21909 mp->vtr_op = ntohl (vtr_op);
21910 mp->outer_tag = ntohs (outer_tag);
21911 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
21912 clib_memcpy (mp->b_smac, smac, sizeof (smac));
21913 mp->b_vlanid = ntohs (vlanid);
21914 mp->i_sid = ntohl (sid);
21922 api_flow_classify_set_interface (vat_main_t * vam)
21924 unformat_input_t *i = vam->input;
21925 vl_api_flow_classify_set_interface_t *mp;
21927 int sw_if_index_set;
21928 u32 ip4_table_index = ~0;
21929 u32 ip6_table_index = ~0;
21933 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21935 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21936 sw_if_index_set = 1;
21937 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21938 sw_if_index_set = 1;
21939 else if (unformat (i, "del"))
21941 else if (unformat (i, "ip4-table %d", &ip4_table_index))
21943 else if (unformat (i, "ip6-table %d", &ip6_table_index))
21947 clib_warning ("parse error '%U'", format_unformat_error, i);
21952 if (sw_if_index_set == 0)
21954 errmsg ("missing interface name or sw_if_index");
21958 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
21960 mp->sw_if_index = ntohl (sw_if_index);
21961 mp->ip4_table_index = ntohl (ip4_table_index);
21962 mp->ip6_table_index = ntohl (ip6_table_index);
21963 mp->is_add = is_add;
21971 api_flow_classify_dump (vat_main_t * vam)
21973 unformat_input_t *i = vam->input;
21974 vl_api_flow_classify_dump_t *mp;
21975 vl_api_control_ping_t *mp_ping;
21976 u8 type = FLOW_CLASSIFY_N_TABLES;
21979 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
21983 errmsg ("classify table type must be specified");
21987 if (!vam->json_output)
21989 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
21992 M (FLOW_CLASSIFY_DUMP, mp);
21997 /* Use a control ping for synchronization */
21998 MPING (CONTROL_PING, mp_ping);
22001 /* Wait for a reply... */
22007 api_feature_enable_disable (vat_main_t * vam)
22009 unformat_input_t *i = vam->input;
22010 vl_api_feature_enable_disable_t *mp;
22012 u8 *feature_name = 0;
22013 u32 sw_if_index = ~0;
22017 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22019 if (unformat (i, "arc_name %s", &arc_name))
22021 else if (unformat (i, "feature_name %s", &feature_name))
22024 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22026 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22028 else if (unformat (i, "disable"))
22036 errmsg ("missing arc name");
22039 if (vec_len (arc_name) > 63)
22041 errmsg ("arc name too long");
22044 if (feature_name == 0)
22046 errmsg ("missing feature name");
22049 if (vec_len (feature_name) > 63)
22051 errmsg ("feature name too long");
22054 if (sw_if_index == ~0)
22056 errmsg ("missing interface name or sw_if_index");
22060 /* Construct the API message */
22061 M (FEATURE_ENABLE_DISABLE, mp);
22062 mp->sw_if_index = ntohl (sw_if_index);
22063 mp->enable = enable;
22064 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
22065 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
22066 vec_free (arc_name);
22067 vec_free (feature_name);
22075 api_sw_interface_tag_add_del (vat_main_t * vam)
22077 unformat_input_t *i = vam->input;
22078 vl_api_sw_interface_tag_add_del_t *mp;
22079 u32 sw_if_index = ~0;
22084 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22086 if (unformat (i, "tag %s", &tag))
22088 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22090 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22092 else if (unformat (i, "del"))
22098 if (sw_if_index == ~0)
22100 errmsg ("missing interface name or sw_if_index");
22104 if (enable && (tag == 0))
22106 errmsg ("no tag specified");
22110 /* Construct the API message */
22111 M (SW_INTERFACE_TAG_ADD_DEL, mp);
22112 mp->sw_if_index = ntohl (sw_if_index);
22113 mp->is_add = enable;
22115 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
22123 static void vl_api_l2_xconnect_details_t_handler
22124 (vl_api_l2_xconnect_details_t * mp)
22126 vat_main_t *vam = &vat_main;
22128 print (vam->ofp, "%15d%15d",
22129 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
22132 static void vl_api_l2_xconnect_details_t_handler_json
22133 (vl_api_l2_xconnect_details_t * mp)
22135 vat_main_t *vam = &vat_main;
22136 vat_json_node_t *node = NULL;
22138 if (VAT_JSON_ARRAY != vam->json_tree.type)
22140 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22141 vat_json_init_array (&vam->json_tree);
22143 node = vat_json_array_add (&vam->json_tree);
22145 vat_json_init_object (node);
22146 vat_json_object_add_uint (node, "rx_sw_if_index",
22147 ntohl (mp->rx_sw_if_index));
22148 vat_json_object_add_uint (node, "tx_sw_if_index",
22149 ntohl (mp->tx_sw_if_index));
22153 api_l2_xconnect_dump (vat_main_t * vam)
22155 vl_api_l2_xconnect_dump_t *mp;
22156 vl_api_control_ping_t *mp_ping;
22159 if (!vam->json_output)
22161 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
22164 M (L2_XCONNECT_DUMP, mp);
22168 /* Use a control ping for synchronization */
22169 MPING (CONTROL_PING, mp_ping);
22177 api_hw_interface_set_mtu (vat_main_t * vam)
22179 unformat_input_t *i = vam->input;
22180 vl_api_hw_interface_set_mtu_t *mp;
22181 u32 sw_if_index = ~0;
22185 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22187 if (unformat (i, "mtu %d", &mtu))
22189 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22191 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22197 if (sw_if_index == ~0)
22199 errmsg ("missing interface name or sw_if_index");
22205 errmsg ("no mtu specified");
22209 /* Construct the API message */
22210 M (HW_INTERFACE_SET_MTU, mp);
22211 mp->sw_if_index = ntohl (sw_if_index);
22212 mp->mtu = ntohs ((u16) mtu);
22220 api_p2p_ethernet_add (vat_main_t * vam)
22222 unformat_input_t *i = vam->input;
22223 vl_api_p2p_ethernet_add_t *mp;
22224 u32 parent_if_index = ~0;
22230 memset (remote_mac, 0, sizeof (remote_mac));
22231 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22233 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
22235 else if (unformat (i, "sw_if_index %d", &parent_if_index))
22239 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
22241 else if (unformat (i, "sub_id %d", &sub_id))
22245 clib_warning ("parse error '%U'", format_unformat_error, i);
22250 if (parent_if_index == ~0)
22252 errmsg ("missing interface name or sw_if_index");
22257 errmsg ("missing remote mac address");
22262 errmsg ("missing sub-interface id");
22266 M (P2P_ETHERNET_ADD, mp);
22267 mp->parent_if_index = ntohl (parent_if_index);
22268 mp->subif_id = ntohl (sub_id);
22269 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22277 api_p2p_ethernet_del (vat_main_t * vam)
22279 unformat_input_t *i = vam->input;
22280 vl_api_p2p_ethernet_del_t *mp;
22281 u32 parent_if_index = ~0;
22286 memset (remote_mac, 0, sizeof (remote_mac));
22287 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22289 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
22291 else if (unformat (i, "sw_if_index %d", &parent_if_index))
22295 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
22299 clib_warning ("parse error '%U'", format_unformat_error, i);
22304 if (parent_if_index == ~0)
22306 errmsg ("missing interface name or sw_if_index");
22311 errmsg ("missing remote mac address");
22315 M (P2P_ETHERNET_DEL, mp);
22316 mp->parent_if_index = ntohl (parent_if_index);
22317 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22325 api_lldp_config (vat_main_t * vam)
22327 unformat_input_t *i = vam->input;
22328 vl_api_lldp_config_t *mp;
22330 int tx_interval = 0;
22331 u8 *sys_name = NULL;
22334 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22336 if (unformat (i, "system-name %s", &sys_name))
22338 else if (unformat (i, "tx-hold %d", &tx_hold))
22340 else if (unformat (i, "tx-interval %d", &tx_interval))
22344 clib_warning ("parse error '%U'", format_unformat_error, i);
22349 vec_add1 (sys_name, 0);
22351 M (LLDP_CONFIG, mp);
22352 mp->tx_hold = htonl (tx_hold);
22353 mp->tx_interval = htonl (tx_interval);
22354 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
22355 vec_free (sys_name);
22363 api_sw_interface_set_lldp (vat_main_t * vam)
22365 unformat_input_t *i = vam->input;
22366 vl_api_sw_interface_set_lldp_t *mp;
22367 u32 sw_if_index = ~0;
22369 u8 *port_desc = NULL, *mgmt_oid = NULL;
22370 ip4_address_t ip4_addr;
22371 ip6_address_t ip6_addr;
22374 memset (&ip4_addr, 0, sizeof (ip4_addr));
22375 memset (&ip6_addr, 0, sizeof (ip6_addr));
22377 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22379 if (unformat (i, "disable"))
22382 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22384 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22386 else if (unformat (i, "port-desc %s", &port_desc))
22388 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
22390 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
22392 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
22398 if (sw_if_index == ~0)
22400 errmsg ("missing interface name or sw_if_index");
22404 /* Construct the API message */
22405 vec_add1 (port_desc, 0);
22406 vec_add1 (mgmt_oid, 0);
22407 M (SW_INTERFACE_SET_LLDP, mp);
22408 mp->sw_if_index = ntohl (sw_if_index);
22409 mp->enable = enable;
22410 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
22411 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
22412 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
22413 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
22414 vec_free (port_desc);
22415 vec_free (mgmt_oid);
22423 api_tcp_configure_src_addresses (vat_main_t * vam)
22425 vl_api_tcp_configure_src_addresses_t *mp;
22426 unformat_input_t *i = vam->input;
22427 ip4_address_t v4first, v4last;
22428 ip6_address_t v6first, v6last;
22433 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22435 if (unformat (i, "%U - %U",
22436 unformat_ip4_address, &v4first,
22437 unformat_ip4_address, &v4last))
22441 errmsg ("one range per message (range already set)");
22446 else if (unformat (i, "%U - %U",
22447 unformat_ip6_address, &v6first,
22448 unformat_ip6_address, &v6last))
22452 errmsg ("one range per message (range already set)");
22457 else if (unformat (i, "vrf %d", &vrf_id))
22463 if (range_set == 0)
22465 errmsg ("address range not set");
22469 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
22470 mp->vrf_id = ntohl (vrf_id);
22472 if (range_set == 2)
22475 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
22476 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
22481 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
22482 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
22489 static void vl_api_app_namespace_add_del_reply_t_handler
22490 (vl_api_app_namespace_add_del_reply_t * mp)
22492 vat_main_t *vam = &vat_main;
22493 i32 retval = ntohl (mp->retval);
22494 if (vam->async_mode)
22496 vam->async_errors += (retval < 0);
22500 vam->retval = retval;
22502 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
22503 vam->result_ready = 1;
22507 static void vl_api_app_namespace_add_del_reply_t_handler_json
22508 (vl_api_app_namespace_add_del_reply_t * mp)
22510 vat_main_t *vam = &vat_main;
22511 vat_json_node_t node;
22513 vat_json_init_object (&node);
22514 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
22515 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
22517 vat_json_print (vam->ofp, &node);
22518 vat_json_free (&node);
22520 vam->retval = ntohl (mp->retval);
22521 vam->result_ready = 1;
22525 api_app_namespace_add_del (vat_main_t * vam)
22527 vl_api_app_namespace_add_del_t *mp;
22528 unformat_input_t *i = vam->input;
22529 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
22530 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
22534 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22536 if (unformat (i, "id %_%v%_", &ns_id))
22538 else if (unformat (i, "secret %lu", &secret))
22540 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22541 sw_if_index_set = 1;
22542 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
22544 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
22549 if (!ns_id || !secret_set || !sw_if_index_set)
22551 errmsg ("namespace id, secret and sw_if_index must be set");
22554 if (vec_len (ns_id) > 64)
22556 errmsg ("namespace id too long");
22559 M (APP_NAMESPACE_ADD_DEL, mp);
22561 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
22562 mp->namespace_id_len = vec_len (ns_id);
22563 mp->secret = clib_host_to_net_u64 (secret);
22564 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
22565 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
22566 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
22574 api_sock_init_shm (vat_main_t * vam)
22576 #if VPP_API_TEST_BUILTIN == 0
22577 unformat_input_t *i = vam->input;
22578 vl_api_shm_elem_config_t *config = 0;
22579 u64 size = 64 << 20;
22582 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22584 if (unformat (i, "size %U", unformat_memory_size, &size))
22591 * Canned custom ring allocator config.
22592 * Should probably parse all of this
22594 vec_validate (config, 6);
22595 config[0].type = VL_API_VLIB_RING;
22596 config[0].size = 256;
22597 config[0].count = 32;
22599 config[1].type = VL_API_VLIB_RING;
22600 config[1].size = 1024;
22601 config[1].count = 16;
22603 config[2].type = VL_API_VLIB_RING;
22604 config[2].size = 4096;
22605 config[2].count = 2;
22607 config[3].type = VL_API_CLIENT_RING;
22608 config[3].size = 256;
22609 config[3].count = 32;
22611 config[4].type = VL_API_CLIENT_RING;
22612 config[4].size = 1024;
22613 config[4].count = 16;
22615 config[5].type = VL_API_CLIENT_RING;
22616 config[5].size = 4096;
22617 config[5].count = 2;
22619 config[6].type = VL_API_QUEUE;
22620 config[6].count = 128;
22621 config[6].size = sizeof (uword);
22623 rv = vl_socket_client_init_shm (config);
22625 vam->client_index_invalid = 1;
22633 api_dns_enable_disable (vat_main_t * vam)
22635 unformat_input_t *line_input = vam->input;
22636 vl_api_dns_enable_disable_t *mp;
22637 u8 enable_disable = 1;
22640 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22642 if (unformat (line_input, "disable"))
22643 enable_disable = 0;
22644 if (unformat (line_input, "enable"))
22645 enable_disable = 1;
22650 /* Construct the API message */
22651 M (DNS_ENABLE_DISABLE, mp);
22652 mp->enable = enable_disable;
22656 /* Wait for the reply */
22662 api_dns_resolve_name (vat_main_t * vam)
22664 unformat_input_t *line_input = vam->input;
22665 vl_api_dns_resolve_name_t *mp;
22669 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22671 if (unformat (line_input, "%s", &name))
22677 if (vec_len (name) > 127)
22679 errmsg ("name too long");
22683 /* Construct the API message */
22684 M (DNS_RESOLVE_NAME, mp);
22685 memcpy (mp->name, name, vec_len (name));
22690 /* Wait for the reply */
22696 api_dns_resolve_ip (vat_main_t * vam)
22698 unformat_input_t *line_input = vam->input;
22699 vl_api_dns_resolve_ip_t *mp;
22701 ip4_address_t addr4;
22702 ip6_address_t addr6;
22705 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22707 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
22709 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
22717 errmsg ("missing address");
22721 /* Construct the API message */
22722 M (DNS_RESOLVE_IP, mp);
22723 mp->is_ip6 = is_ip6;
22725 memcpy (mp->address, &addr6, sizeof (addr6));
22727 memcpy (mp->address, &addr4, sizeof (addr4));
22731 /* Wait for the reply */
22737 api_dns_name_server_add_del (vat_main_t * vam)
22739 unformat_input_t *i = vam->input;
22740 vl_api_dns_name_server_add_del_t *mp;
22742 ip6_address_t ip6_server;
22743 ip4_address_t ip4_server;
22748 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22750 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
22752 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
22754 else if (unformat (i, "del"))
22758 clib_warning ("parse error '%U'", format_unformat_error, i);
22763 if (ip4_set && ip6_set)
22765 errmsg ("Only one server address allowed per message");
22768 if ((ip4_set + ip6_set) == 0)
22770 errmsg ("Server address required");
22774 /* Construct the API message */
22775 M (DNS_NAME_SERVER_ADD_DEL, mp);
22779 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
22784 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
22788 mp->is_add = is_add;
22793 /* Wait for a reply, return good/bad news */
22799 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
22801 vat_main_t *vam = &vat_main;
22806 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22807 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22808 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
22809 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
22810 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22811 clib_net_to_host_u32 (mp->action_index), mp->tag);
22816 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22817 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22818 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
22819 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
22820 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22821 clib_net_to_host_u32 (mp->action_index), mp->tag);
22826 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
22829 vat_main_t *vam = &vat_main;
22830 vat_json_node_t *node = NULL;
22831 struct in6_addr ip6;
22832 struct in_addr ip4;
22834 if (VAT_JSON_ARRAY != vam->json_tree.type)
22836 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22837 vat_json_init_array (&vam->json_tree);
22839 node = vat_json_array_add (&vam->json_tree);
22840 vat_json_init_object (node);
22842 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
22843 vat_json_object_add_uint (node, "appns_index",
22844 clib_net_to_host_u32 (mp->appns_index));
22845 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
22846 vat_json_object_add_uint (node, "scope", mp->scope);
22847 vat_json_object_add_uint (node, "action_index",
22848 clib_net_to_host_u32 (mp->action_index));
22849 vat_json_object_add_uint (node, "lcl_port",
22850 clib_net_to_host_u16 (mp->lcl_port));
22851 vat_json_object_add_uint (node, "rmt_port",
22852 clib_net_to_host_u16 (mp->rmt_port));
22853 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
22854 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
22855 vat_json_object_add_string_copy (node, "tag", mp->tag);
22858 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
22859 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
22860 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
22861 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
22865 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
22866 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
22867 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
22868 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
22873 api_session_rule_add_del (vat_main_t * vam)
22875 vl_api_session_rule_add_del_t *mp;
22876 unformat_input_t *i = vam->input;
22877 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
22878 u32 appns_index = 0, scope = 0;
22879 ip4_address_t lcl_ip4, rmt_ip4;
22880 ip6_address_t lcl_ip6, rmt_ip6;
22881 u8 is_ip4 = 1, conn_set = 0;
22882 u8 is_add = 1, *tag = 0;
22885 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22887 if (unformat (i, "del"))
22889 else if (unformat (i, "add"))
22891 else if (unformat (i, "proto tcp"))
22893 else if (unformat (i, "proto udp"))
22895 else if (unformat (i, "appns %d", &appns_index))
22897 else if (unformat (i, "scope %d", &scope))
22899 else if (unformat (i, "tag %_%v%_", &tag))
22903 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
22904 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
22912 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
22913 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
22919 else if (unformat (i, "action %d", &action))
22924 if (proto == ~0 || !conn_set || action == ~0)
22926 errmsg ("transport proto, connection and action must be set");
22932 errmsg ("scope should be 0-3");
22936 M (SESSION_RULE_ADD_DEL, mp);
22938 mp->is_ip4 = is_ip4;
22939 mp->transport_proto = proto;
22940 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
22941 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
22942 mp->lcl_plen = lcl_plen;
22943 mp->rmt_plen = rmt_plen;
22944 mp->action_index = clib_host_to_net_u32 (action);
22945 mp->appns_index = clib_host_to_net_u32 (appns_index);
22947 mp->is_add = is_add;
22950 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
22951 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
22955 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
22956 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
22960 clib_memcpy (mp->tag, tag, vec_len (tag));
22970 api_session_rules_dump (vat_main_t * vam)
22972 vl_api_session_rules_dump_t *mp;
22973 vl_api_control_ping_t *mp_ping;
22976 if (!vam->json_output)
22978 print (vam->ofp, "%=20s", "Session Rules");
22981 M (SESSION_RULES_DUMP, mp);
22985 /* Use a control ping for synchronization */
22986 MPING (CONTROL_PING, mp_ping);
22989 /* Wait for a reply... */
22995 api_ip_container_proxy_add_del (vat_main_t * vam)
22997 vl_api_ip_container_proxy_add_del_t *mp;
22998 unformat_input_t *i = vam->input;
22999 u32 plen = ~0, sw_if_index = ~0;
23006 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
23008 if (unformat (i, "del"))
23010 else if (unformat (i, "add"))
23012 if (unformat (i, "%U", unformat_ip4_address, &ip4))
23017 else if (unformat (i, "%U", unformat_ip6_address, &ip6))
23022 else if (unformat (i, "sw_if_index %u", &sw_if_index))
23027 if (sw_if_index == ~0 || plen == ~0)
23029 errmsg ("address and sw_if_index must be set");
23033 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
23035 mp->is_ip4 = is_ip4;
23036 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
23038 mp->is_add = is_add;
23040 clib_memcpy (mp->ip, &ip4, sizeof (ip4));
23042 clib_memcpy (mp->ip, &ip6, sizeof (ip6));
23050 api_qos_record_enable_disable (vat_main_t * vam)
23052 unformat_input_t *i = vam->input;
23053 vl_api_qos_record_enable_disable_t *mp;
23054 u32 sw_if_index, qs = 0xff;
23055 u8 sw_if_index_set = 0;
23059 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
23061 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
23062 sw_if_index_set = 1;
23063 else if (unformat (i, "sw_if_index %d", &sw_if_index))
23064 sw_if_index_set = 1;
23065 else if (unformat (i, "%U", unformat_qos_source, &qs))
23067 else if (unformat (i, "disable"))
23071 clib_warning ("parse error '%U'", format_unformat_error, i);
23076 if (sw_if_index_set == 0)
23078 errmsg ("missing interface name or sw_if_index");
23083 errmsg ("input location must be specified");
23087 M (QOS_RECORD_ENABLE_DISABLE, mp);
23089 mp->sw_if_index = ntohl (sw_if_index);
23090 mp->input_source = qs;
23091 mp->enable = enable;
23100 q_or_quit (vat_main_t * vam)
23102 #if VPP_API_TEST_BUILTIN == 0
23103 longjmp (vam->jump_buf, 1);
23105 return 0; /* not so much */
23109 q (vat_main_t * vam)
23111 return q_or_quit (vam);
23115 quit (vat_main_t * vam)
23117 return q_or_quit (vam);
23121 comment (vat_main_t * vam)
23127 statseg (vat_main_t * vam)
23129 ssvm_private_t *ssvmp = &vam->stat_segment;
23130 ssvm_shared_header_t *shared_header = ssvmp->sh;
23131 vlib_counter_t **counters;
23132 u64 thread0_index1_packets;
23133 u64 thread0_index1_bytes;
23134 f64 vector_rate, input_rate;
23137 uword *counter_vector_by_name;
23138 if (vam->stat_segment_lockp == 0)
23140 errmsg ("Stat segment not mapped...");
23144 /* look up "/if/rx for sw_if_index 1 as a test */
23146 clib_spinlock_lock (vam->stat_segment_lockp);
23148 counter_vector_by_name = (uword *) shared_header->opaque[1];
23150 p = hash_get_mem (counter_vector_by_name, "/if/rx");
23153 clib_spinlock_unlock (vam->stat_segment_lockp);
23154 errmsg ("/if/tx not found?");
23158 /* Fish per-thread vector of combined counters from shared memory */
23159 counters = (vlib_counter_t **) p[0];
23161 if (vec_len (counters[0]) < 2)
23163 clib_spinlock_unlock (vam->stat_segment_lockp);
23164 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
23168 /* Read thread 0 sw_if_index 1 counter */
23169 thread0_index1_packets = counters[0][1].packets;
23170 thread0_index1_bytes = counters[0][1].bytes;
23172 p = hash_get_mem (counter_vector_by_name, "vector_rate");
23175 clib_spinlock_unlock (vam->stat_segment_lockp);
23176 errmsg ("vector_rate not found?");
23180 vector_rate = *(f64 *) (p[0]);
23181 p = hash_get_mem (counter_vector_by_name, "input_rate");
23184 clib_spinlock_unlock (vam->stat_segment_lockp);
23185 errmsg ("input_rate not found?");
23188 input_rate = *(f64 *) (p[0]);
23190 clib_spinlock_unlock (vam->stat_segment_lockp);
23192 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
23193 vector_rate, input_rate);
23194 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
23195 thread0_index1_packets, thread0_index1_bytes);
23201 cmd_cmp (void *a1, void *a2)
23206 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
23210 help (vat_main_t * vam)
23215 unformat_input_t *i = vam->input;
23218 if (unformat (i, "%s", &name))
23222 vec_add1 (name, 0);
23224 hs = hash_get_mem (vam->help_by_name, name);
23226 print (vam->ofp, "usage: %s %s", name, hs[0]);
23228 print (vam->ofp, "No such msg / command '%s'", name);
23233 print (vam->ofp, "Help is available for the following:");
23236 hash_foreach_pair (p, vam->function_by_name,
23238 vec_add1 (cmds, (u8 *)(p->key));
23242 vec_sort_with_function (cmds, cmd_cmp);
23244 for (j = 0; j < vec_len (cmds); j++)
23245 print (vam->ofp, "%s", cmds[j]);
23252 set (vat_main_t * vam)
23254 u8 *name = 0, *value = 0;
23255 unformat_input_t *i = vam->input;
23257 if (unformat (i, "%s", &name))
23259 /* The input buffer is a vector, not a string. */
23260 value = vec_dup (i->buffer);
23261 vec_delete (value, i->index, 0);
23262 /* Almost certainly has a trailing newline */
23263 if (value[vec_len (value) - 1] == '\n')
23264 value[vec_len (value) - 1] = 0;
23265 /* Make sure it's a proper string, one way or the other */
23266 vec_add1 (value, 0);
23267 (void) clib_macro_set_value (&vam->macro_main,
23268 (char *) name, (char *) value);
23271 errmsg ("usage: set <name> <value>");
23279 unset (vat_main_t * vam)
23283 if (unformat (vam->input, "%s", &name))
23284 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
23285 errmsg ("unset: %s wasn't set", name);
23298 macro_sort_cmp (void *a1, void *a2)
23300 macro_sort_t *s1 = a1;
23301 macro_sort_t *s2 = a2;
23303 return strcmp ((char *) (s1->name), (char *) (s2->name));
23307 dump_macro_table (vat_main_t * vam)
23309 macro_sort_t *sort_me = 0, *sm;
23314 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
23316 vec_add2 (sort_me, sm, 1);
23317 sm->name = (u8 *)(p->key);
23318 sm->value = (u8 *) (p->value[0]);
23322 vec_sort_with_function (sort_me, macro_sort_cmp);
23324 if (vec_len (sort_me))
23325 print (vam->ofp, "%-15s%s", "Name", "Value");
23327 print (vam->ofp, "The macro table is empty...");
23329 for (i = 0; i < vec_len (sort_me); i++)
23330 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
23335 dump_node_table (vat_main_t * vam)
23338 vlib_node_t *node, *next_node;
23340 if (vec_len (vam->graph_nodes) == 0)
23342 print (vam->ofp, "Node table empty, issue get_node_graph...");
23346 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
23348 node = vam->graph_nodes[0][i];
23349 print (vam->ofp, "[%d] %s", i, node->name);
23350 for (j = 0; j < vec_len (node->next_nodes); j++)
23352 if (node->next_nodes[j] != ~0)
23354 next_node = vam->graph_nodes[0][node->next_nodes[j]];
23355 print (vam->ofp, " [%d] %s", j, next_node->name);
23363 value_sort_cmp (void *a1, void *a2)
23365 name_sort_t *n1 = a1;
23366 name_sort_t *n2 = a2;
23368 if (n1->value < n2->value)
23370 if (n1->value > n2->value)
23377 dump_msg_api_table (vat_main_t * vam)
23379 api_main_t *am = &api_main;
23380 name_sort_t *nses = 0, *ns;
23385 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
23387 vec_add2 (nses, ns, 1);
23388 ns->name = (u8 *)(hp->key);
23389 ns->value = (u32) hp->value[0];
23393 vec_sort_with_function (nses, value_sort_cmp);
23395 for (i = 0; i < vec_len (nses); i++)
23396 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
23402 get_msg_id (vat_main_t * vam)
23407 if (unformat (vam->input, "%s", &name_and_crc))
23409 message_index = vl_msg_api_get_msg_index (name_and_crc);
23410 if (message_index == ~0)
23412 print (vam->ofp, " '%s' not found", name_and_crc);
23415 print (vam->ofp, " '%s' has message index %d",
23416 name_and_crc, message_index);
23419 errmsg ("name_and_crc required...");
23424 search_node_table (vat_main_t * vam)
23426 unformat_input_t *line_input = vam->input;
23429 vlib_node_t *node, *next_node;
23432 if (vam->graph_node_index_by_name == 0)
23434 print (vam->ofp, "Node table empty, issue get_node_graph...");
23438 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
23440 if (unformat (line_input, "%s", &node_to_find))
23442 vec_add1 (node_to_find, 0);
23443 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
23446 print (vam->ofp, "%s not found...", node_to_find);
23449 node = vam->graph_nodes[0][p[0]];
23450 print (vam->ofp, "[%d] %s", p[0], node->name);
23451 for (j = 0; j < vec_len (node->next_nodes); j++)
23453 if (node->next_nodes[j] != ~0)
23455 next_node = vam->graph_nodes[0][node->next_nodes[j]];
23456 print (vam->ofp, " [%d] %s", j, next_node->name);
23463 clib_warning ("parse error '%U'", format_unformat_error,
23469 vec_free (node_to_find);
23478 script (vat_main_t * vam)
23480 #if (VPP_API_TEST_BUILTIN==0)
23482 char *save_current_file;
23483 unformat_input_t save_input;
23484 jmp_buf save_jump_buf;
23485 u32 save_line_number;
23487 FILE *new_fp, *save_ifp;
23489 if (unformat (vam->input, "%s", &s))
23491 new_fp = fopen ((char *) s, "r");
23494 errmsg ("Couldn't open script file %s", s);
23501 errmsg ("Missing script name");
23505 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
23506 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
23507 save_ifp = vam->ifp;
23508 save_line_number = vam->input_line_number;
23509 save_current_file = (char *) vam->current_file;
23511 vam->input_line_number = 0;
23513 vam->current_file = s;
23516 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
23517 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
23518 vam->ifp = save_ifp;
23519 vam->input_line_number = save_line_number;
23520 vam->current_file = (u8 *) save_current_file;
23525 clib_warning ("use the exec command...");
23531 echo (vat_main_t * vam)
23533 print (vam->ofp, "%v", vam->input->buffer);
23537 /* List of API message constructors, CLI names map to api_xxx */
23538 #define foreach_vpe_api_msg \
23539 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
23540 _(sw_interface_dump,"") \
23541 _(sw_interface_set_flags, \
23542 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
23543 _(sw_interface_add_del_address, \
23544 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
23545 _(sw_interface_set_rx_mode, \
23546 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
23547 _(sw_interface_set_rx_placement, \
23548 "<intfc> | sw_if_index <id> [queue <id>] [worker <id> | main]") \
23549 _(sw_interface_rx_placement_dump, \
23550 "[<intfc> | sw_if_index <id>]") \
23551 _(sw_interface_set_table, \
23552 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
23553 _(sw_interface_set_mpls_enable, \
23554 "<intfc> | sw_if_index [disable | dis]") \
23555 _(sw_interface_set_vpath, \
23556 "<intfc> | sw_if_index <id> enable | disable") \
23557 _(sw_interface_set_vxlan_bypass, \
23558 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23559 _(sw_interface_set_geneve_bypass, \
23560 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23561 _(sw_interface_set_l2_xconnect, \
23562 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23563 "enable | disable") \
23564 _(sw_interface_set_l2_bridge, \
23565 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
23566 "[shg <split-horizon-group>] [bvi]\n" \
23567 "enable | disable") \
23568 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
23569 _(bridge_domain_add_del, \
23570 "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") \
23571 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
23573 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
23574 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
23575 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
23577 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23579 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23581 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
23583 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
23585 "<vpp-if-name> | sw_if_index <id>") \
23586 _(sw_interface_tap_dump, "") \
23588 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>]") \
23590 "<vpp-if-name> | sw_if_index <id>") \
23591 _(sw_interface_tap_v2_dump, "") \
23593 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
23594 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]}") \
23596 "<vpp-if-name> | sw_if_index <id>") \
23598 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
23599 _(bond_detach_slave, \
23600 "sw_if_index <n>") \
23601 _(sw_interface_bond_dump, "") \
23602 _(sw_interface_slave_dump, \
23603 "<vpp-if-name> | sw_if_index <id>") \
23604 _(ip_table_add_del, \
23605 "table <n> [ipv6] [add | del]\n") \
23606 _(ip_add_del_route, \
23607 "<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
23608 "[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
23609 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
23610 "[multipath] [count <n>]") \
23611 _(ip_mroute_add_del, \
23612 "<src> <grp>/<mask> [table-id <n>]\n" \
23613 "[<intfc> | sw_if_index <id>] [local] [del]") \
23614 _(mpls_table_add_del, \
23615 "table <n> [add | del]\n") \
23616 _(mpls_route_add_del, \
23617 "<label> <eos> via <addr | next-hop-table <n> | via-label <n> |\n" \
23618 "lookup-ip4-table <n> | lookup-in-ip6-table <n> |\n" \
23619 "l2-input-on <intfc> | l2-input-on sw_if_index <id>>\n" \
23620 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>] [weight <n>]\n" \
23621 "[drop] [local] [classify <n>] [multipath] [count <n>] [del]") \
23622 _(mpls_ip_bind_unbind, \
23623 "<label> <addr/len>") \
23624 _(mpls_tunnel_add_del, \
23625 " via <addr> [table-id <n>]\n" \
23626 "sw_if_index <id>] [l2] [del]") \
23627 _(sr_mpls_policy_add, \
23628 "bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
23629 _(sr_mpls_policy_del, \
23631 _(bier_table_add_del, \
23632 "<label> <sub-domain> <set> <bsl> [del]") \
23633 _(bier_route_add_del, \
23634 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
23635 "[<intfc> | sw_if_index <id>]" \
23636 "[weight <n>] [del] [multipath]") \
23637 _(proxy_arp_add_del, \
23638 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
23639 _(proxy_arp_intfc_enable_disable, \
23640 "<intfc> | sw_if_index <id> enable | disable") \
23641 _(sw_interface_set_unnumbered, \
23642 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
23643 _(ip_neighbor_add_del, \
23644 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
23645 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
23646 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
23647 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
23648 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
23649 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
23650 "[outer_vlan_id_any][inner_vlan_id_any]") \
23651 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
23652 _(reset_fib, "vrf <n> [ipv6]") \
23653 _(dhcp_proxy_config, \
23654 "svr <v46-address> src <v46-address>\n" \
23655 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
23656 _(dhcp_proxy_set_vss, \
23657 "tbl_id <n> [fib_id <n> oui <n> | vpn_ascii_id <text>] [ipv6] [del]") \
23658 _(dhcp_proxy_dump, "ip6") \
23659 _(dhcp_client_config, \
23660 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
23661 _(set_ip_flow_hash, \
23662 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
23663 _(sw_interface_ip6_enable_disable, \
23664 "<intfc> | sw_if_index <id> enable | disable") \
23665 _(sw_interface_ip6_set_link_local_address, \
23666 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
23667 _(ip6nd_proxy_add_del, \
23668 "<intfc> | sw_if_index <id> <ip6-address>") \
23669 _(ip6nd_proxy_dump, "") \
23670 _(sw_interface_ip6nd_ra_prefix, \
23671 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
23672 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
23673 "[nolink] [isno]") \
23674 _(sw_interface_ip6nd_ra_config, \
23675 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
23676 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
23677 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
23678 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
23679 _(l2_patch_add_del, \
23680 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23681 "enable | disable") \
23682 _(sr_localsid_add_del, \
23683 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
23684 "fib-table <num> (end.psp) sw_if_index <num>") \
23685 _(classify_add_del_table, \
23686 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
23687 " [del] [del-chain] mask <mask-value>\n" \
23688 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
23689 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
23690 _(classify_add_del_session, \
23691 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
23692 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
23693 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
23694 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
23695 _(classify_set_interface_ip_table, \
23696 "<intfc> | sw_if_index <nn> table <nn>") \
23697 _(classify_set_interface_l2_tables, \
23698 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23699 " [other-table <nn>]") \
23700 _(get_node_index, "node <node-name") \
23701 _(add_node_next, "node <node-name> next <next-node-name>") \
23702 _(l2tpv3_create_tunnel, \
23703 "client_address <ip6-addr> our_address <ip6-addr>\n" \
23704 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
23705 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
23706 _(l2tpv3_set_tunnel_cookies, \
23707 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
23708 "[new_remote_cookie <nn>]\n") \
23709 _(l2tpv3_interface_enable_disable, \
23710 "<intfc> | sw_if_index <nn> enable | disable") \
23711 _(l2tpv3_set_lookup_key, \
23712 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
23713 _(sw_if_l2tpv3_tunnel_dump, "") \
23714 _(vxlan_offload_rx, \
23715 "hw { <interface name> | hw_if_index <nn>} " \
23716 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
23717 _(vxlan_add_del_tunnel, \
23718 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23719 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
23720 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23721 _(geneve_add_del_tunnel, \
23722 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23723 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23724 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23725 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23726 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23727 _(gre_add_del_tunnel, \
23728 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
23729 "[teb | erspan <session-id>] [del]") \
23730 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23731 _(l2_fib_clear_table, "") \
23732 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
23733 _(l2_interface_vlan_tag_rewrite, \
23734 "<intfc> | sw_if_index <nn> \n" \
23735 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
23736 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
23737 _(create_vhost_user_if, \
23738 "socket <filename> [server] [renumber <dev_instance>] " \
23739 "[disable_mrg_rxbuf] [disable_indirect_desc] " \
23740 "[mac <mac_address>]") \
23741 _(modify_vhost_user_if, \
23742 "<intfc> | sw_if_index <nn> socket <filename>\n" \
23743 "[server] [renumber <dev_instance>]") \
23744 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
23745 _(sw_interface_vhost_user_dump, "") \
23746 _(show_version, "") \
23747 _(vxlan_gpe_add_del_tunnel, \
23748 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
23749 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23750 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
23751 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
23752 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23753 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
23754 _(interface_name_renumber, \
23755 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
23756 _(input_acl_set_interface, \
23757 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23758 " [l2-table <nn>] [del]") \
23759 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
23760 _(ip_scan_neighbor_enable_disable, "[ip4|ip6|both|disable] [interval <n-min>]\n" \
23761 " [max-time <n-usec>] [max-update <n>] [delay <n-msec>] [stale <n-min>]") \
23762 _(want_ip4_arp_events, "address <ip4-address> [del]") \
23763 _(want_ip6_nd_events, "address <ip6-address> [del]") \
23764 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
23765 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
23766 _(ip_dump, "ipv4 | ipv6") \
23767 _(ipsec_spd_add_del, "spd_id <n> [del]") \
23768 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
23770 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
23771 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
23772 " integ_alg <alg> integ_key <hex>") \
23773 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
23774 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
23775 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
23776 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
23777 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
23778 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
23779 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
23780 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
23781 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
23782 " [instance <n>]") \
23783 _(ipsec_sa_dump, "[sa_id <n>]") \
23784 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
23785 " <alg> <hex>\n") \
23786 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
23787 _(ikev2_profile_add_del, "name <profile_name> [del]") \
23788 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
23789 "(auth_data 0x<data> | auth_data <data>)") \
23790 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
23791 "(id_data 0x<data> | id_data <data>) (local|remote)") \
23792 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
23793 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
23794 "(local|remote)") \
23795 _(ikev2_set_local_key, "file <absolute_file_path>") \
23796 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
23797 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23798 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23799 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
23800 _(ikev2_initiate_sa_init, "<profile_name>") \
23801 _(ikev2_initiate_del_ike_sa, "<ispi>") \
23802 _(ikev2_initiate_del_child_sa, "<ispi>") \
23803 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
23804 _(delete_loopback,"sw_if_index <nn>") \
23805 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
23806 _(bd_ip_mac_dump, "[bd_id] <id>") \
23807 _(want_interface_events, "enable|disable") \
23808 _(want_stats,"enable|disable") \
23809 _(get_first_msg_id, "client <name>") \
23810 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
23811 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
23812 "fib-id <nn> [ip4][ip6][default]") \
23813 _(get_node_graph, " ") \
23814 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
23815 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
23816 _(ioam_disable, "") \
23817 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
23818 " sw_if_index <sw_if_index> p <priority> " \
23819 "w <weight>] [del]") \
23820 _(one_add_del_locator, "locator-set <locator_name> " \
23821 "iface <intf> | sw_if_index <sw_if_index> " \
23822 "p <priority> w <weight> [del]") \
23823 _(one_add_del_local_eid,"vni <vni> eid " \
23824 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23825 "locator-set <locator_name> [del]" \
23826 "[key-id sha1|sha256 secret-key <secret-key>]")\
23827 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
23828 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
23829 _(one_enable_disable, "enable|disable") \
23830 _(one_map_register_enable_disable, "enable|disable") \
23831 _(one_map_register_fallback_threshold, "<value>") \
23832 _(one_rloc_probe_enable_disable, "enable|disable") \
23833 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23835 "rloc <locator> p <prio> " \
23836 "w <weight> [rloc <loc> ... ] " \
23837 "action <action> [del-all]") \
23838 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23840 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23841 _(one_use_petr, "ip-address> | disable") \
23842 _(one_map_request_mode, "src-dst|dst-only") \
23843 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23844 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23845 _(one_locator_set_dump, "[local | remote]") \
23846 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
23847 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23848 "[local] | [remote]") \
23849 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
23850 _(one_ndp_bd_get, "") \
23851 _(one_ndp_entries_get, "bd <bridge-domain>") \
23852 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
23853 _(one_l2_arp_bd_get, "") \
23854 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
23855 _(one_stats_enable_disable, "enable|disalbe") \
23856 _(show_one_stats_enable_disable, "") \
23857 _(one_eid_table_vni_dump, "") \
23858 _(one_eid_table_map_dump, "l2|l3") \
23859 _(one_map_resolver_dump, "") \
23860 _(one_map_server_dump, "") \
23861 _(one_adjacencies_get, "vni <vni>") \
23862 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
23863 _(show_one_rloc_probe_state, "") \
23864 _(show_one_map_register_state, "") \
23865 _(show_one_status, "") \
23866 _(one_stats_dump, "") \
23867 _(one_stats_flush, "") \
23868 _(one_get_map_request_itr_rlocs, "") \
23869 _(one_map_register_set_ttl, "<ttl>") \
23870 _(one_set_transport_protocol, "udp|api") \
23871 _(one_get_transport_protocol, "") \
23872 _(one_enable_disable_xtr_mode, "enable|disable") \
23873 _(one_show_xtr_mode, "") \
23874 _(one_enable_disable_pitr_mode, "enable|disable") \
23875 _(one_show_pitr_mode, "") \
23876 _(one_enable_disable_petr_mode, "enable|disable") \
23877 _(one_show_petr_mode, "") \
23878 _(show_one_nsh_mapping, "") \
23879 _(show_one_pitr, "") \
23880 _(show_one_use_petr, "") \
23881 _(show_one_map_request_mode, "") \
23882 _(show_one_map_register_ttl, "") \
23883 _(show_one_map_register_fallback_threshold, "") \
23884 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
23885 " sw_if_index <sw_if_index> p <priority> " \
23886 "w <weight>] [del]") \
23887 _(lisp_add_del_locator, "locator-set <locator_name> " \
23888 "iface <intf> | sw_if_index <sw_if_index> " \
23889 "p <priority> w <weight> [del]") \
23890 _(lisp_add_del_local_eid,"vni <vni> eid " \
23891 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23892 "locator-set <locator_name> [del]" \
23893 "[key-id sha1|sha256 secret-key <secret-key>]") \
23894 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
23895 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
23896 _(lisp_enable_disable, "enable|disable") \
23897 _(lisp_map_register_enable_disable, "enable|disable") \
23898 _(lisp_rloc_probe_enable_disable, "enable|disable") \
23899 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23901 "rloc <locator> p <prio> " \
23902 "w <weight> [rloc <loc> ... ] " \
23903 "action <action> [del-all]") \
23904 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23906 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23907 _(lisp_use_petr, "<ip-address> | disable") \
23908 _(lisp_map_request_mode, "src-dst|dst-only") \
23909 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23910 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23911 _(lisp_locator_set_dump, "[local | remote]") \
23912 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
23913 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23914 "[local] | [remote]") \
23915 _(lisp_eid_table_vni_dump, "") \
23916 _(lisp_eid_table_map_dump, "l2|l3") \
23917 _(lisp_map_resolver_dump, "") \
23918 _(lisp_map_server_dump, "") \
23919 _(lisp_adjacencies_get, "vni <vni>") \
23920 _(gpe_fwd_entry_vnis_get, "") \
23921 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
23922 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
23923 "[table <table-id>]") \
23924 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
23925 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
23926 _(gpe_set_encap_mode, "lisp|vxlan") \
23927 _(gpe_get_encap_mode, "") \
23928 _(lisp_gpe_add_del_iface, "up|down") \
23929 _(lisp_gpe_enable_disable, "enable|disable") \
23930 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
23931 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
23932 _(show_lisp_rloc_probe_state, "") \
23933 _(show_lisp_map_register_state, "") \
23934 _(show_lisp_status, "") \
23935 _(lisp_get_map_request_itr_rlocs, "") \
23936 _(show_lisp_pitr, "") \
23937 _(show_lisp_use_petr, "") \
23938 _(show_lisp_map_request_mode, "") \
23939 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
23940 _(af_packet_delete, "name <host interface name>") \
23941 _(af_packet_dump, "") \
23942 _(policer_add_del, "name <policer name> <params> [del]") \
23943 _(policer_dump, "[name <policer name>]") \
23944 _(policer_classify_set_interface, \
23945 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23946 " [l2-table <nn>] [del]") \
23947 _(policer_classify_dump, "type [ip4|ip6|l2]") \
23948 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
23949 "[master|slave]") \
23950 _(netmap_delete, "name <interface name>") \
23951 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
23952 _(mpls_fib_dump, "") \
23953 _(classify_table_ids, "") \
23954 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
23955 _(classify_table_info, "table_id <nn>") \
23956 _(classify_session_dump, "table_id <nn>") \
23957 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
23958 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
23959 "[template_interval <nn>] [udp_checksum]") \
23960 _(ipfix_exporter_dump, "") \
23961 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
23962 _(ipfix_classify_stream_dump, "") \
23963 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
23964 _(ipfix_classify_table_dump, "") \
23965 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
23966 _(sw_interface_span_dump, "[l2]") \
23967 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
23968 _(pg_create_interface, "if_id <nn>") \
23969 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
23970 _(pg_enable_disable, "[stream <id>] disable") \
23971 _(ip_source_and_port_range_check_add_del, \
23972 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
23973 _(ip_source_and_port_range_check_interface_add_del, \
23974 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
23975 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
23976 _(ipsec_gre_add_del_tunnel, \
23977 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
23978 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
23979 _(delete_subif,"<intfc> | sw_if_index <nn>") \
23980 _(l2_interface_pbb_tag_rewrite, \
23981 "<intfc> | sw_if_index <nn> \n" \
23982 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
23983 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
23984 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
23985 _(flow_classify_set_interface, \
23986 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
23987 _(flow_classify_dump, "type [ip4|ip6]") \
23988 _(ip_fib_dump, "") \
23989 _(ip_mfib_dump, "") \
23990 _(ip6_fib_dump, "") \
23991 _(ip6_mfib_dump, "") \
23992 _(feature_enable_disable, "arc_name <arc_name> " \
23993 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
23994 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
23996 _(l2_xconnect_dump, "") \
23997 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
23998 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
23999 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
24000 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
24001 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
24002 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
24003 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
24004 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
24005 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
24006 _(sock_init_shm, "size <nnn>") \
24007 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
24008 _(dns_enable_disable, "[enable][disable]") \
24009 _(dns_name_server_add_del, "<ip-address> [del]") \
24010 _(dns_resolve_name, "<hostname>") \
24011 _(dns_resolve_ip, "<ip4|ip6>") \
24012 _(dns_name_server_add_del, "<ip-address> [del]") \
24013 _(dns_resolve_name, "<hostname>") \
24014 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
24015 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
24016 _(session_rules_dump, "") \
24017 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
24018 _(output_acl_set_interface, \
24019 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
24020 " [l2-table <nn>] [del]") \
24021 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
24023 /* List of command functions, CLI names map directly to functions */
24024 #define foreach_cli_function \
24025 _(comment, "usage: comment <ignore-rest-of-line>") \
24026 _(dump_interface_table, "usage: dump_interface_table") \
24027 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
24028 _(dump_ipv4_table, "usage: dump_ipv4_table") \
24029 _(dump_ipv6_table, "usage: dump_ipv6_table") \
24030 _(dump_stats_table, "usage: dump_stats_table") \
24031 _(dump_macro_table, "usage: dump_macro_table ") \
24032 _(dump_node_table, "usage: dump_node_table") \
24033 _(dump_msg_api_table, "usage: dump_msg_api_table") \
24034 _(get_msg_id, "usage: get_msg_id name_and_crc") \
24035 _(echo, "usage: echo <message>") \
24036 _(exec, "usage: exec <vpe-debug-CLI-command>") \
24037 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
24038 _(help, "usage: help") \
24039 _(q, "usage: quit") \
24040 _(quit, "usage: quit") \
24041 _(search_node_table, "usage: search_node_table <name>...") \
24042 _(set, "usage: set <variable-name> <value>") \
24043 _(script, "usage: script <file-name>") \
24044 _(statseg, "usage: statseg"); \
24045 _(unset, "usage: unset <variable-name>")
24048 static void vl_api_##n##_t_handler_uni \
24049 (vl_api_##n##_t * mp) \
24051 vat_main_t * vam = &vat_main; \
24052 if (vam->json_output) { \
24053 vl_api_##n##_t_handler_json(mp); \
24055 vl_api_##n##_t_handler(mp); \
24058 foreach_vpe_api_reply_msg;
24059 #if VPP_API_TEST_BUILTIN == 0
24060 foreach_standalone_reply_msg;
24065 vat_api_hookup (vat_main_t * vam)
24068 vl_msg_api_set_handlers(VL_API_##N, #n, \
24069 vl_api_##n##_t_handler_uni, \
24071 vl_api_##n##_t_endian, \
24072 vl_api_##n##_t_print, \
24073 sizeof(vl_api_##n##_t), 1);
24074 foreach_vpe_api_reply_msg;
24075 #if VPP_API_TEST_BUILTIN == 0
24076 foreach_standalone_reply_msg;
24080 #if (VPP_API_TEST_BUILTIN==0)
24081 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
24083 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
24085 vam->function_by_name = hash_create_string (0, sizeof (uword));
24087 vam->help_by_name = hash_create_string (0, sizeof (uword));
24090 /* API messages we can send */
24091 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
24092 foreach_vpe_api_msg;
24096 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
24097 foreach_vpe_api_msg;
24100 /* CLI functions */
24101 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
24102 foreach_cli_function;
24106 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
24107 foreach_cli_function;
24111 #if VPP_API_TEST_BUILTIN
24112 static clib_error_t *
24113 vat_api_hookup_shim (vlib_main_t * vm)
24115 vat_api_hookup (&vat_main);
24119 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
24123 * fd.io coding-style-patch-verification: ON
24126 * eval: (c-set-style "gnu")