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 received 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 %-6s %-3s",
1393 " ID", "LRN", "FWD", "FLD", "BVI", "UU-FWD", "#IF");
1395 print (vam->ofp, "%3d %3d %3d %3d %3d %6d %3d",
1396 ntohl (mp->bd_id), mp->learn, mp->forward,
1397 mp->flood, ntohl (mp->bvi_sw_if_index),
1398 ntohl (mp->uu_fwd_sw_if_index), n_sw_ifs);
1402 vl_api_bridge_domain_sw_if_t *sw_ifs;
1403 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1406 sw_ifs = mp->sw_if_details;
1407 for (i = 0; i < n_sw_ifs; i++)
1413 sw_if_index = ntohl (sw_ifs->sw_if_index);
1416 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1418 if ((u32) p->value[0] == sw_if_index)
1420 sw_if_name = (u8 *)(p->key);
1425 print (vam->ofp, "%7d %3d %s", sw_if_index,
1426 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1427 "sw_if_index not found!");
1434 static void vl_api_bridge_domain_details_t_handler_json
1435 (vl_api_bridge_domain_details_t * mp)
1437 vat_main_t *vam = &vat_main;
1438 vat_json_node_t *node, *array = NULL;
1439 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1441 if (VAT_JSON_ARRAY != vam->json_tree.type)
1443 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1444 vat_json_init_array (&vam->json_tree);
1446 node = vat_json_array_add (&vam->json_tree);
1448 vat_json_init_object (node);
1449 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1450 vat_json_object_add_uint (node, "flood", mp->flood);
1451 vat_json_object_add_uint (node, "forward", mp->forward);
1452 vat_json_object_add_uint (node, "learn", mp->learn);
1453 vat_json_object_add_uint (node, "bvi_sw_if_index",
1454 ntohl (mp->bvi_sw_if_index));
1455 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1456 array = vat_json_object_add (node, "sw_if");
1457 vat_json_init_array (array);
1463 vl_api_bridge_domain_sw_if_t *sw_ifs;
1466 sw_ifs = mp->sw_if_details;
1467 for (i = 0; i < n_sw_ifs; i++)
1469 node = vat_json_array_add (array);
1470 vat_json_init_object (node);
1471 vat_json_object_add_uint (node, "sw_if_index",
1472 ntohl (sw_ifs->sw_if_index));
1473 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1479 static void vl_api_control_ping_reply_t_handler
1480 (vl_api_control_ping_reply_t * mp)
1482 vat_main_t *vam = &vat_main;
1483 i32 retval = ntohl (mp->retval);
1484 if (vam->async_mode)
1486 vam->async_errors += (retval < 0);
1490 vam->retval = retval;
1491 vam->result_ready = 1;
1493 if (vam->socket_client_main)
1494 vam->socket_client_main->control_pings_outstanding--;
1497 static void vl_api_control_ping_reply_t_handler_json
1498 (vl_api_control_ping_reply_t * mp)
1500 vat_main_t *vam = &vat_main;
1501 i32 retval = ntohl (mp->retval);
1503 if (VAT_JSON_NONE != vam->json_tree.type)
1505 vat_json_print (vam->ofp, &vam->json_tree);
1506 vat_json_free (&vam->json_tree);
1507 vam->json_tree.type = VAT_JSON_NONE;
1512 vat_json_init_array (&vam->json_tree);
1513 vat_json_print (vam->ofp, &vam->json_tree);
1514 vam->json_tree.type = VAT_JSON_NONE;
1517 vam->retval = retval;
1518 vam->result_ready = 1;
1522 vl_api_bridge_domain_set_mac_age_reply_t_handler
1523 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1525 vat_main_t *vam = &vat_main;
1526 i32 retval = ntohl (mp->retval);
1527 if (vam->async_mode)
1529 vam->async_errors += (retval < 0);
1533 vam->retval = retval;
1534 vam->result_ready = 1;
1538 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1539 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1541 vat_main_t *vam = &vat_main;
1542 vat_json_node_t node;
1544 vat_json_init_object (&node);
1545 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1547 vat_json_print (vam->ofp, &node);
1548 vat_json_free (&node);
1550 vam->retval = ntohl (mp->retval);
1551 vam->result_ready = 1;
1555 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1557 vat_main_t *vam = &vat_main;
1558 i32 retval = ntohl (mp->retval);
1559 if (vam->async_mode)
1561 vam->async_errors += (retval < 0);
1565 vam->retval = retval;
1566 vam->result_ready = 1;
1570 static void vl_api_l2_flags_reply_t_handler_json
1571 (vl_api_l2_flags_reply_t * mp)
1573 vat_main_t *vam = &vat_main;
1574 vat_json_node_t node;
1576 vat_json_init_object (&node);
1577 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1578 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1579 ntohl (mp->resulting_feature_bitmap));
1581 vat_json_print (vam->ofp, &node);
1582 vat_json_free (&node);
1584 vam->retval = ntohl (mp->retval);
1585 vam->result_ready = 1;
1588 static void vl_api_bridge_flags_reply_t_handler
1589 (vl_api_bridge_flags_reply_t * mp)
1591 vat_main_t *vam = &vat_main;
1592 i32 retval = ntohl (mp->retval);
1593 if (vam->async_mode)
1595 vam->async_errors += (retval < 0);
1599 vam->retval = retval;
1600 vam->result_ready = 1;
1604 static void vl_api_bridge_flags_reply_t_handler_json
1605 (vl_api_bridge_flags_reply_t * mp)
1607 vat_main_t *vam = &vat_main;
1608 vat_json_node_t node;
1610 vat_json_init_object (&node);
1611 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1612 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1613 ntohl (mp->resulting_feature_bitmap));
1615 vat_json_print (vam->ofp, &node);
1616 vat_json_free (&node);
1618 vam->retval = ntohl (mp->retval);
1619 vam->result_ready = 1;
1622 static void vl_api_tap_connect_reply_t_handler
1623 (vl_api_tap_connect_reply_t * mp)
1625 vat_main_t *vam = &vat_main;
1626 i32 retval = ntohl (mp->retval);
1627 if (vam->async_mode)
1629 vam->async_errors += (retval < 0);
1633 vam->retval = retval;
1634 vam->sw_if_index = ntohl (mp->sw_if_index);
1635 vam->result_ready = 1;
1640 static void vl_api_tap_connect_reply_t_handler_json
1641 (vl_api_tap_connect_reply_t * mp)
1643 vat_main_t *vam = &vat_main;
1644 vat_json_node_t node;
1646 vat_json_init_object (&node);
1647 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1648 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1650 vat_json_print (vam->ofp, &node);
1651 vat_json_free (&node);
1653 vam->retval = ntohl (mp->retval);
1654 vam->result_ready = 1;
1659 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1661 vat_main_t *vam = &vat_main;
1662 i32 retval = ntohl (mp->retval);
1663 if (vam->async_mode)
1665 vam->async_errors += (retval < 0);
1669 vam->retval = retval;
1670 vam->sw_if_index = ntohl (mp->sw_if_index);
1671 vam->result_ready = 1;
1675 static void vl_api_tap_modify_reply_t_handler_json
1676 (vl_api_tap_modify_reply_t * mp)
1678 vat_main_t *vam = &vat_main;
1679 vat_json_node_t node;
1681 vat_json_init_object (&node);
1682 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1683 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1685 vat_json_print (vam->ofp, &node);
1686 vat_json_free (&node);
1688 vam->retval = ntohl (mp->retval);
1689 vam->result_ready = 1;
1693 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1695 vat_main_t *vam = &vat_main;
1696 i32 retval = ntohl (mp->retval);
1697 if (vam->async_mode)
1699 vam->async_errors += (retval < 0);
1703 vam->retval = retval;
1704 vam->result_ready = 1;
1708 static void vl_api_tap_delete_reply_t_handler_json
1709 (vl_api_tap_delete_reply_t * mp)
1711 vat_main_t *vam = &vat_main;
1712 vat_json_node_t node;
1714 vat_json_init_object (&node);
1715 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1717 vat_json_print (vam->ofp, &node);
1718 vat_json_free (&node);
1720 vam->retval = ntohl (mp->retval);
1721 vam->result_ready = 1;
1725 vl_api_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_reply_t * mp)
1727 vat_main_t *vam = &vat_main;
1728 i32 retval = ntohl (mp->retval);
1729 if (vam->async_mode)
1731 vam->async_errors += (retval < 0);
1735 vam->retval = retval;
1736 vam->sw_if_index = ntohl (mp->sw_if_index);
1737 vam->result_ready = 1;
1742 static void vl_api_tap_create_v2_reply_t_handler_json
1743 (vl_api_tap_create_v2_reply_t * mp)
1745 vat_main_t *vam = &vat_main;
1746 vat_json_node_t node;
1748 vat_json_init_object (&node);
1749 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1750 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1752 vat_json_print (vam->ofp, &node);
1753 vat_json_free (&node);
1755 vam->retval = ntohl (mp->retval);
1756 vam->result_ready = 1;
1761 vl_api_tap_delete_v2_reply_t_handler (vl_api_tap_delete_v2_reply_t * mp)
1763 vat_main_t *vam = &vat_main;
1764 i32 retval = ntohl (mp->retval);
1765 if (vam->async_mode)
1767 vam->async_errors += (retval < 0);
1771 vam->retval = retval;
1772 vam->result_ready = 1;
1776 static void vl_api_tap_delete_v2_reply_t_handler_json
1777 (vl_api_tap_delete_v2_reply_t * mp)
1779 vat_main_t *vam = &vat_main;
1780 vat_json_node_t node;
1782 vat_json_init_object (&node);
1783 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1785 vat_json_print (vam->ofp, &node);
1786 vat_json_free (&node);
1788 vam->retval = ntohl (mp->retval);
1789 vam->result_ready = 1;
1793 vl_api_bond_create_reply_t_handler (vl_api_bond_create_reply_t * mp)
1795 vat_main_t *vam = &vat_main;
1796 i32 retval = ntohl (mp->retval);
1798 if (vam->async_mode)
1800 vam->async_errors += (retval < 0);
1804 vam->retval = retval;
1805 vam->sw_if_index = ntohl (mp->sw_if_index);
1806 vam->result_ready = 1;
1810 static void vl_api_bond_create_reply_t_handler_json
1811 (vl_api_bond_create_reply_t * mp)
1813 vat_main_t *vam = &vat_main;
1814 vat_json_node_t node;
1816 vat_json_init_object (&node);
1817 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1818 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1820 vat_json_print (vam->ofp, &node);
1821 vat_json_free (&node);
1823 vam->retval = ntohl (mp->retval);
1824 vam->result_ready = 1;
1828 vl_api_bond_delete_reply_t_handler (vl_api_bond_delete_reply_t * mp)
1830 vat_main_t *vam = &vat_main;
1831 i32 retval = ntohl (mp->retval);
1833 if (vam->async_mode)
1835 vam->async_errors += (retval < 0);
1839 vam->retval = retval;
1840 vam->result_ready = 1;
1844 static void vl_api_bond_delete_reply_t_handler_json
1845 (vl_api_bond_delete_reply_t * mp)
1847 vat_main_t *vam = &vat_main;
1848 vat_json_node_t node;
1850 vat_json_init_object (&node);
1851 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1853 vat_json_print (vam->ofp, &node);
1854 vat_json_free (&node);
1856 vam->retval = ntohl (mp->retval);
1857 vam->result_ready = 1;
1861 vl_api_bond_enslave_reply_t_handler (vl_api_bond_enslave_reply_t * mp)
1863 vat_main_t *vam = &vat_main;
1864 i32 retval = ntohl (mp->retval);
1866 if (vam->async_mode)
1868 vam->async_errors += (retval < 0);
1872 vam->retval = retval;
1873 vam->result_ready = 1;
1877 static void vl_api_bond_enslave_reply_t_handler_json
1878 (vl_api_bond_enslave_reply_t * mp)
1880 vat_main_t *vam = &vat_main;
1881 vat_json_node_t node;
1883 vat_json_init_object (&node);
1884 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1886 vat_json_print (vam->ofp, &node);
1887 vat_json_free (&node);
1889 vam->retval = ntohl (mp->retval);
1890 vam->result_ready = 1;
1894 vl_api_bond_detach_slave_reply_t_handler (vl_api_bond_detach_slave_reply_t *
1897 vat_main_t *vam = &vat_main;
1898 i32 retval = ntohl (mp->retval);
1900 if (vam->async_mode)
1902 vam->async_errors += (retval < 0);
1906 vam->retval = retval;
1907 vam->result_ready = 1;
1911 static void vl_api_bond_detach_slave_reply_t_handler_json
1912 (vl_api_bond_detach_slave_reply_t * mp)
1914 vat_main_t *vam = &vat_main;
1915 vat_json_node_t node;
1917 vat_json_init_object (&node);
1918 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1920 vat_json_print (vam->ofp, &node);
1921 vat_json_free (&node);
1923 vam->retval = ntohl (mp->retval);
1924 vam->result_ready = 1;
1927 static void vl_api_sw_interface_bond_details_t_handler
1928 (vl_api_sw_interface_bond_details_t * mp)
1930 vat_main_t *vam = &vat_main;
1933 "%-16s %-12d %-12U %-13U %-14u %-14u",
1934 mp->interface_name, ntohl (mp->sw_if_index),
1935 format_bond_mode, mp->mode, format_bond_load_balance, mp->lb,
1936 ntohl (mp->active_slaves), ntohl (mp->slaves));
1939 static void vl_api_sw_interface_bond_details_t_handler_json
1940 (vl_api_sw_interface_bond_details_t * mp)
1942 vat_main_t *vam = &vat_main;
1943 vat_json_node_t *node = NULL;
1945 if (VAT_JSON_ARRAY != vam->json_tree.type)
1947 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1948 vat_json_init_array (&vam->json_tree);
1950 node = vat_json_array_add (&vam->json_tree);
1952 vat_json_init_object (node);
1953 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1954 vat_json_object_add_string_copy (node, "interface_name",
1955 mp->interface_name);
1956 vat_json_object_add_uint (node, "mode", mp->mode);
1957 vat_json_object_add_uint (node, "load_balance", mp->lb);
1958 vat_json_object_add_uint (node, "active_slaves", ntohl (mp->active_slaves));
1959 vat_json_object_add_uint (node, "slaves", ntohl (mp->slaves));
1963 api_sw_interface_bond_dump (vat_main_t * vam)
1965 vl_api_sw_interface_bond_dump_t *mp;
1966 vl_api_control_ping_t *mp_ping;
1970 "\n%-16s %-12s %-12s %-13s %-14s %-14s",
1971 "interface name", "sw_if_index", "mode", "load balance",
1972 "active slaves", "slaves");
1974 /* Get list of bond interfaces */
1975 M (SW_INTERFACE_BOND_DUMP, mp);
1978 /* Use a control ping for synchronization */
1979 MPING (CONTROL_PING, mp_ping);
1986 static void vl_api_sw_interface_slave_details_t_handler
1987 (vl_api_sw_interface_slave_details_t * mp)
1989 vat_main_t *vam = &vat_main;
1992 "%-25s %-12d %-12d %d", mp->interface_name,
1993 ntohl (mp->sw_if_index), mp->is_passive, mp->is_long_timeout);
1996 static void vl_api_sw_interface_slave_details_t_handler_json
1997 (vl_api_sw_interface_slave_details_t * mp)
1999 vat_main_t *vam = &vat_main;
2000 vat_json_node_t *node = NULL;
2002 if (VAT_JSON_ARRAY != vam->json_tree.type)
2004 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2005 vat_json_init_array (&vam->json_tree);
2007 node = vat_json_array_add (&vam->json_tree);
2009 vat_json_init_object (node);
2010 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2011 vat_json_object_add_string_copy (node, "interface_name",
2012 mp->interface_name);
2013 vat_json_object_add_uint (node, "passive", mp->is_passive);
2014 vat_json_object_add_uint (node, "long_timeout", mp->is_long_timeout);
2018 api_sw_interface_slave_dump (vat_main_t * vam)
2020 unformat_input_t *i = vam->input;
2021 vl_api_sw_interface_slave_dump_t *mp;
2022 vl_api_control_ping_t *mp_ping;
2023 u32 sw_if_index = ~0;
2024 u8 sw_if_index_set = 0;
2027 /* Parse args required to build the message */
2028 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2030 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2031 sw_if_index_set = 1;
2032 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2033 sw_if_index_set = 1;
2038 if (sw_if_index_set == 0)
2040 errmsg ("missing vpp interface name. ");
2045 "\n%-25s %-12s %-12s %s",
2046 "slave interface name", "sw_if_index", "passive", "long_timeout");
2048 /* Get list of bond interfaces */
2049 M (SW_INTERFACE_SLAVE_DUMP, mp);
2050 mp->sw_if_index = ntohl (sw_if_index);
2053 /* Use a control ping for synchronization */
2054 MPING (CONTROL_PING, mp_ping);
2061 static void vl_api_mpls_tunnel_add_del_reply_t_handler
2062 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2064 vat_main_t *vam = &vat_main;
2065 i32 retval = ntohl (mp->retval);
2066 if (vam->async_mode)
2068 vam->async_errors += (retval < 0);
2072 vam->retval = retval;
2073 vam->result_ready = 1;
2077 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
2078 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2080 vat_main_t *vam = &vat_main;
2081 vat_json_node_t node;
2083 vat_json_init_object (&node);
2084 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2085 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
2086 ntohl (mp->sw_if_index));
2088 vat_json_print (vam->ofp, &node);
2089 vat_json_free (&node);
2091 vam->retval = ntohl (mp->retval);
2092 vam->result_ready = 1;
2095 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
2096 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2098 vat_main_t *vam = &vat_main;
2099 i32 retval = ntohl (mp->retval);
2100 if (vam->async_mode)
2102 vam->async_errors += (retval < 0);
2106 vam->retval = retval;
2107 vam->sw_if_index = ntohl (mp->sw_if_index);
2108 vam->result_ready = 1;
2112 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
2113 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2115 vat_main_t *vam = &vat_main;
2116 vat_json_node_t node;
2118 vat_json_init_object (&node);
2119 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2120 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2122 vat_json_print (vam->ofp, &node);
2123 vat_json_free (&node);
2125 vam->retval = ntohl (mp->retval);
2126 vam->result_ready = 1;
2129 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
2130 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2132 vat_main_t *vam = &vat_main;
2133 i32 retval = ntohl (mp->retval);
2134 if (vam->async_mode)
2136 vam->async_errors += (retval < 0);
2140 vam->retval = retval;
2141 vam->result_ready = 1;
2145 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
2146 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2148 vat_main_t *vam = &vat_main;
2149 vat_json_node_t node;
2151 vat_json_init_object (&node);
2152 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2153 vat_json_object_add_uint (&node, "fwd_entry_index",
2154 clib_net_to_host_u32 (mp->fwd_entry_index));
2156 vat_json_print (vam->ofp, &node);
2157 vat_json_free (&node);
2159 vam->retval = ntohl (mp->retval);
2160 vam->result_ready = 1;
2164 format_lisp_transport_protocol (u8 * s, va_list * args)
2166 u32 proto = va_arg (*args, u32);
2171 return format (s, "udp");
2173 return format (s, "api");
2180 static void vl_api_one_get_transport_protocol_reply_t_handler
2181 (vl_api_one_get_transport_protocol_reply_t * mp)
2183 vat_main_t *vam = &vat_main;
2184 i32 retval = ntohl (mp->retval);
2185 if (vam->async_mode)
2187 vam->async_errors += (retval < 0);
2191 u32 proto = mp->protocol;
2192 print (vam->ofp, "Transport protocol: %U",
2193 format_lisp_transport_protocol, proto);
2194 vam->retval = retval;
2195 vam->result_ready = 1;
2199 static void vl_api_one_get_transport_protocol_reply_t_handler_json
2200 (vl_api_one_get_transport_protocol_reply_t * mp)
2202 vat_main_t *vam = &vat_main;
2203 vat_json_node_t node;
2206 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
2209 vat_json_init_object (&node);
2210 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2211 vat_json_object_add_string_copy (&node, "transport-protocol", s);
2214 vat_json_print (vam->ofp, &node);
2215 vat_json_free (&node);
2217 vam->retval = ntohl (mp->retval);
2218 vam->result_ready = 1;
2221 static void vl_api_one_add_del_locator_set_reply_t_handler
2222 (vl_api_one_add_del_locator_set_reply_t * mp)
2224 vat_main_t *vam = &vat_main;
2225 i32 retval = ntohl (mp->retval);
2226 if (vam->async_mode)
2228 vam->async_errors += (retval < 0);
2232 vam->retval = retval;
2233 vam->result_ready = 1;
2237 static void vl_api_one_add_del_locator_set_reply_t_handler_json
2238 (vl_api_one_add_del_locator_set_reply_t * mp)
2240 vat_main_t *vam = &vat_main;
2241 vat_json_node_t node;
2243 vat_json_init_object (&node);
2244 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2245 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
2247 vat_json_print (vam->ofp, &node);
2248 vat_json_free (&node);
2250 vam->retval = ntohl (mp->retval);
2251 vam->result_ready = 1;
2254 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
2255 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2257 vat_main_t *vam = &vat_main;
2258 i32 retval = ntohl (mp->retval);
2259 if (vam->async_mode)
2261 vam->async_errors += (retval < 0);
2265 vam->retval = retval;
2266 vam->sw_if_index = ntohl (mp->sw_if_index);
2267 vam->result_ready = 1;
2269 vam->regenerate_interface_table = 1;
2272 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
2273 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2275 vat_main_t *vam = &vat_main;
2276 vat_json_node_t node;
2278 vat_json_init_object (&node);
2279 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2280 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2282 vat_json_print (vam->ofp, &node);
2283 vat_json_free (&node);
2285 vam->retval = ntohl (mp->retval);
2286 vam->result_ready = 1;
2289 static void vl_api_vxlan_offload_rx_reply_t_handler
2290 (vl_api_vxlan_offload_rx_reply_t * mp)
2292 vat_main_t *vam = &vat_main;
2293 i32 retval = ntohl (mp->retval);
2294 if (vam->async_mode)
2296 vam->async_errors += (retval < 0);
2300 vam->retval = retval;
2301 vam->result_ready = 1;
2305 static void vl_api_vxlan_offload_rx_reply_t_handler_json
2306 (vl_api_vxlan_offload_rx_reply_t * mp)
2308 vat_main_t *vam = &vat_main;
2309 vat_json_node_t node;
2311 vat_json_init_object (&node);
2312 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2314 vat_json_print (vam->ofp, &node);
2315 vat_json_free (&node);
2317 vam->retval = ntohl (mp->retval);
2318 vam->result_ready = 1;
2321 static void vl_api_geneve_add_del_tunnel_reply_t_handler
2322 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2324 vat_main_t *vam = &vat_main;
2325 i32 retval = ntohl (mp->retval);
2326 if (vam->async_mode)
2328 vam->async_errors += (retval < 0);
2332 vam->retval = retval;
2333 vam->sw_if_index = ntohl (mp->sw_if_index);
2334 vam->result_ready = 1;
2338 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
2339 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2341 vat_main_t *vam = &vat_main;
2342 vat_json_node_t node;
2344 vat_json_init_object (&node);
2345 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2346 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2348 vat_json_print (vam->ofp, &node);
2349 vat_json_free (&node);
2351 vam->retval = ntohl (mp->retval);
2352 vam->result_ready = 1;
2355 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
2356 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2358 vat_main_t *vam = &vat_main;
2359 i32 retval = ntohl (mp->retval);
2360 if (vam->async_mode)
2362 vam->async_errors += (retval < 0);
2366 vam->retval = retval;
2367 vam->sw_if_index = ntohl (mp->sw_if_index);
2368 vam->result_ready = 1;
2370 vam->regenerate_interface_table = 1;
2373 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
2374 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2376 vat_main_t *vam = &vat_main;
2377 vat_json_node_t node;
2379 vat_json_init_object (&node);
2380 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2381 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2383 vat_json_print (vam->ofp, &node);
2384 vat_json_free (&node);
2386 vam->retval = ntohl (mp->retval);
2387 vam->result_ready = 1;
2390 static void vl_api_gre_add_del_tunnel_reply_t_handler
2391 (vl_api_gre_add_del_tunnel_reply_t * mp)
2393 vat_main_t *vam = &vat_main;
2394 i32 retval = ntohl (mp->retval);
2395 if (vam->async_mode)
2397 vam->async_errors += (retval < 0);
2401 vam->retval = retval;
2402 vam->sw_if_index = ntohl (mp->sw_if_index);
2403 vam->result_ready = 1;
2407 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
2408 (vl_api_gre_add_del_tunnel_reply_t * mp)
2410 vat_main_t *vam = &vat_main;
2411 vat_json_node_t node;
2413 vat_json_init_object (&node);
2414 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2415 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2417 vat_json_print (vam->ofp, &node);
2418 vat_json_free (&node);
2420 vam->retval = ntohl (mp->retval);
2421 vam->result_ready = 1;
2424 static void vl_api_create_vhost_user_if_reply_t_handler
2425 (vl_api_create_vhost_user_if_reply_t * mp)
2427 vat_main_t *vam = &vat_main;
2428 i32 retval = ntohl (mp->retval);
2429 if (vam->async_mode)
2431 vam->async_errors += (retval < 0);
2435 vam->retval = retval;
2436 vam->sw_if_index = ntohl (mp->sw_if_index);
2437 vam->result_ready = 1;
2439 vam->regenerate_interface_table = 1;
2442 static void vl_api_create_vhost_user_if_reply_t_handler_json
2443 (vl_api_create_vhost_user_if_reply_t * mp)
2445 vat_main_t *vam = &vat_main;
2446 vat_json_node_t node;
2448 vat_json_init_object (&node);
2449 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2450 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2452 vat_json_print (vam->ofp, &node);
2453 vat_json_free (&node);
2455 vam->retval = ntohl (mp->retval);
2456 vam->result_ready = 1;
2459 static void vl_api_dns_resolve_name_reply_t_handler
2460 (vl_api_dns_resolve_name_reply_t * mp)
2462 vat_main_t *vam = &vat_main;
2463 i32 retval = ntohl (mp->retval);
2464 if (vam->async_mode)
2466 vam->async_errors += (retval < 0);
2470 vam->retval = retval;
2471 vam->result_ready = 1;
2476 clib_warning ("ip4 address %U", format_ip4_address,
2477 (ip4_address_t *) mp->ip4_address);
2479 clib_warning ("ip6 address %U", format_ip6_address,
2480 (ip6_address_t *) mp->ip6_address);
2483 clib_warning ("retval %d", retval);
2487 static void vl_api_dns_resolve_name_reply_t_handler_json
2488 (vl_api_dns_resolve_name_reply_t * mp)
2490 clib_warning ("not implemented");
2493 static void vl_api_dns_resolve_ip_reply_t_handler
2494 (vl_api_dns_resolve_ip_reply_t * mp)
2496 vat_main_t *vam = &vat_main;
2497 i32 retval = ntohl (mp->retval);
2498 if (vam->async_mode)
2500 vam->async_errors += (retval < 0);
2504 vam->retval = retval;
2505 vam->result_ready = 1;
2509 clib_warning ("canonical name %s", mp->name);
2512 clib_warning ("retval %d", retval);
2516 static void vl_api_dns_resolve_ip_reply_t_handler_json
2517 (vl_api_dns_resolve_ip_reply_t * mp)
2519 clib_warning ("not implemented");
2523 static void vl_api_ip_address_details_t_handler
2524 (vl_api_ip_address_details_t * mp)
2526 vat_main_t *vam = &vat_main;
2527 static ip_address_details_t empty_ip_address_details = { {0} };
2528 ip_address_details_t *address = NULL;
2529 ip_details_t *current_ip_details = NULL;
2530 ip_details_t *details = NULL;
2532 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2534 if (!details || vam->current_sw_if_index >= vec_len (details)
2535 || !details[vam->current_sw_if_index].present)
2537 errmsg ("ip address details arrived but not stored");
2538 errmsg ("ip_dump should be called first");
2542 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2544 #define addresses (current_ip_details->addr)
2546 vec_validate_init_empty (addresses, vec_len (addresses),
2547 empty_ip_address_details);
2549 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2551 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
2552 address->prefix_length = mp->prefix_length;
2556 static void vl_api_ip_address_details_t_handler_json
2557 (vl_api_ip_address_details_t * mp)
2559 vat_main_t *vam = &vat_main;
2560 vat_json_node_t *node = NULL;
2561 struct in6_addr ip6;
2564 if (VAT_JSON_ARRAY != vam->json_tree.type)
2566 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2567 vat_json_init_array (&vam->json_tree);
2569 node = vat_json_array_add (&vam->json_tree);
2571 vat_json_init_object (node);
2574 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
2575 vat_json_object_add_ip6 (node, "ip", ip6);
2579 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
2580 vat_json_object_add_ip4 (node, "ip", ip4);
2582 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
2586 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2588 vat_main_t *vam = &vat_main;
2589 static ip_details_t empty_ip_details = { 0 };
2590 ip_details_t *ip = NULL;
2591 u32 sw_if_index = ~0;
2593 sw_if_index = ntohl (mp->sw_if_index);
2595 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2596 sw_if_index, empty_ip_details);
2598 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2605 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2607 vat_main_t *vam = &vat_main;
2609 if (VAT_JSON_ARRAY != vam->json_tree.type)
2611 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2612 vat_json_init_array (&vam->json_tree);
2614 vat_json_array_add_uint (&vam->json_tree,
2615 clib_net_to_host_u32 (mp->sw_if_index));
2619 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2621 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2622 "router_addr %U host_mac %U",
2623 ntohl (mp->pid), mp->lease.is_ipv6 ? "ipv6" : "ipv4",
2625 format_ip4_address, &mp->lease.host_address,
2626 format_ip4_address, &mp->lease.router_address,
2627 format_ethernet_address, mp->lease.host_mac);
2630 static void vl_api_dhcp_compl_event_t_handler_json
2631 (vl_api_dhcp_compl_event_t * mp)
2633 /* JSON output not supported */
2637 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2640 vat_main_t *vam = &vat_main;
2641 static u64 default_counter = 0;
2643 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2645 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2646 sw_if_index, default_counter);
2647 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2651 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2652 interface_counter_t counter)
2654 vat_main_t *vam = &vat_main;
2655 static interface_counter_t default_counter = { 0, };
2657 vec_validate_init_empty (vam->combined_interface_counters,
2658 vnet_counter_type, NULL);
2659 vec_validate_init_empty (vam->combined_interface_counters
2660 [vnet_counter_type], sw_if_index, default_counter);
2661 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2664 static void vl_api_vnet_interface_simple_counters_t_handler
2665 (vl_api_vnet_interface_simple_counters_t * mp)
2670 static void vl_api_vnet_interface_combined_counters_t_handler
2671 (vl_api_vnet_interface_combined_counters_t * mp)
2676 static void vl_api_vnet_interface_simple_counters_t_handler_json
2677 (vl_api_vnet_interface_simple_counters_t * mp)
2682 u32 first_sw_if_index;
2685 count = ntohl (mp->count);
2686 first_sw_if_index = ntohl (mp->first_sw_if_index);
2688 v_packets = (u64 *) & mp->data;
2689 for (i = 0; i < count; i++)
2691 packets = clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2692 set_simple_interface_counter (mp->vnet_counter_type,
2693 first_sw_if_index + i, packets);
2698 static void vl_api_vnet_interface_combined_counters_t_handler_json
2699 (vl_api_vnet_interface_combined_counters_t * mp)
2701 interface_counter_t counter;
2703 u32 first_sw_if_index;
2707 count = ntohl (mp->count);
2708 first_sw_if_index = ntohl (mp->first_sw_if_index);
2710 v = (vlib_counter_t *) & mp->data;
2711 for (i = 0; i < count; i++)
2714 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2716 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2717 set_combined_interface_counter (mp->vnet_counter_type,
2718 first_sw_if_index + i, counter);
2724 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2726 vat_main_t *vam = &vat_main;
2729 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2731 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2740 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2742 vat_main_t *vam = &vat_main;
2745 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2747 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2755 static void vl_api_vnet_ip4_fib_counters_t_handler
2756 (vl_api_vnet_ip4_fib_counters_t * mp)
2761 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2762 (vl_api_vnet_ip4_fib_counters_t * mp)
2764 vat_main_t *vam = &vat_main;
2765 vl_api_ip4_fib_counter_t *v;
2766 ip4_fib_counter_t *counter;
2773 vrf_id = ntohl (mp->vrf_id);
2774 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2775 if (~0 == vrf_index)
2777 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2778 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2779 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2780 vec_validate (vam->ip4_fib_counters, vrf_index);
2781 vam->ip4_fib_counters[vrf_index] = NULL;
2784 vec_free (vam->ip4_fib_counters[vrf_index]);
2785 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2786 count = ntohl (mp->count);
2787 for (i = 0; i < count; i++)
2789 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2790 counter = &vam->ip4_fib_counters[vrf_index][i];
2791 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2792 counter->address = ip4;
2793 counter->address_length = v->address_length;
2794 counter->packets = clib_net_to_host_u64 (v->packets);
2795 counter->bytes = clib_net_to_host_u64 (v->bytes);
2800 static void vl_api_vnet_ip4_nbr_counters_t_handler
2801 (vl_api_vnet_ip4_nbr_counters_t * mp)
2806 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2807 (vl_api_vnet_ip4_nbr_counters_t * mp)
2809 vat_main_t *vam = &vat_main;
2810 vl_api_ip4_nbr_counter_t *v;
2811 ip4_nbr_counter_t *counter;
2816 sw_if_index = ntohl (mp->sw_if_index);
2817 count = ntohl (mp->count);
2818 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2821 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2823 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2824 for (i = 0; i < count; i++)
2826 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2827 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2828 counter->address.s_addr = v->address;
2829 counter->packets = clib_net_to_host_u64 (v->packets);
2830 counter->bytes = clib_net_to_host_u64 (v->bytes);
2831 counter->linkt = v->link_type;
2836 static void vl_api_vnet_ip6_fib_counters_t_handler
2837 (vl_api_vnet_ip6_fib_counters_t * mp)
2842 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2843 (vl_api_vnet_ip6_fib_counters_t * mp)
2845 vat_main_t *vam = &vat_main;
2846 vl_api_ip6_fib_counter_t *v;
2847 ip6_fib_counter_t *counter;
2848 struct in6_addr ip6;
2854 vrf_id = ntohl (mp->vrf_id);
2855 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2856 if (~0 == vrf_index)
2858 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2859 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2860 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2861 vec_validate (vam->ip6_fib_counters, vrf_index);
2862 vam->ip6_fib_counters[vrf_index] = NULL;
2865 vec_free (vam->ip6_fib_counters[vrf_index]);
2866 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2867 count = ntohl (mp->count);
2868 for (i = 0; i < count; i++)
2870 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2871 counter = &vam->ip6_fib_counters[vrf_index][i];
2872 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2873 counter->address = ip6;
2874 counter->address_length = v->address_length;
2875 counter->packets = clib_net_to_host_u64 (v->packets);
2876 counter->bytes = clib_net_to_host_u64 (v->bytes);
2881 static void vl_api_vnet_ip6_nbr_counters_t_handler
2882 (vl_api_vnet_ip6_nbr_counters_t * mp)
2887 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2888 (vl_api_vnet_ip6_nbr_counters_t * mp)
2890 vat_main_t *vam = &vat_main;
2891 vl_api_ip6_nbr_counter_t *v;
2892 ip6_nbr_counter_t *counter;
2893 struct in6_addr ip6;
2898 sw_if_index = ntohl (mp->sw_if_index);
2899 count = ntohl (mp->count);
2900 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2903 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2905 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2906 for (i = 0; i < count; i++)
2908 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2909 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2910 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2911 counter->address = ip6;
2912 counter->packets = clib_net_to_host_u64 (v->packets);
2913 counter->bytes = clib_net_to_host_u64 (v->bytes);
2918 static void vl_api_get_first_msg_id_reply_t_handler
2919 (vl_api_get_first_msg_id_reply_t * mp)
2921 vat_main_t *vam = &vat_main;
2922 i32 retval = ntohl (mp->retval);
2924 if (vam->async_mode)
2926 vam->async_errors += (retval < 0);
2930 vam->retval = retval;
2931 vam->result_ready = 1;
2935 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2939 static void vl_api_get_first_msg_id_reply_t_handler_json
2940 (vl_api_get_first_msg_id_reply_t * mp)
2942 vat_main_t *vam = &vat_main;
2943 vat_json_node_t node;
2945 vat_json_init_object (&node);
2946 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2947 vat_json_object_add_uint (&node, "first_msg_id",
2948 (uint) ntohs (mp->first_msg_id));
2950 vat_json_print (vam->ofp, &node);
2951 vat_json_free (&node);
2953 vam->retval = ntohl (mp->retval);
2954 vam->result_ready = 1;
2957 static void vl_api_get_node_graph_reply_t_handler
2958 (vl_api_get_node_graph_reply_t * mp)
2960 vat_main_t *vam = &vat_main;
2961 api_main_t *am = &api_main;
2962 i32 retval = ntohl (mp->retval);
2963 u8 *pvt_copy, *reply;
2968 if (vam->async_mode)
2970 vam->async_errors += (retval < 0);
2974 vam->retval = retval;
2975 vam->result_ready = 1;
2978 /* "Should never happen..." */
2982 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2983 pvt_copy = vec_dup (reply);
2985 /* Toss the shared-memory original... */
2986 pthread_mutex_lock (&am->vlib_rp->mutex);
2987 oldheap = svm_push_data_heap (am->vlib_rp);
2991 svm_pop_heap (oldheap);
2992 pthread_mutex_unlock (&am->vlib_rp->mutex);
2994 if (vam->graph_nodes)
2996 hash_free (vam->graph_node_index_by_name);
2998 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
3000 node = vam->graph_nodes[0][i];
3001 vec_free (node->name);
3002 vec_free (node->next_nodes);
3005 vec_free (vam->graph_nodes[0]);
3006 vec_free (vam->graph_nodes);
3009 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
3010 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
3011 vec_free (pvt_copy);
3013 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
3015 node = vam->graph_nodes[0][i];
3016 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
3020 static void vl_api_get_node_graph_reply_t_handler_json
3021 (vl_api_get_node_graph_reply_t * mp)
3023 vat_main_t *vam = &vat_main;
3024 api_main_t *am = &api_main;
3026 vat_json_node_t node;
3029 /* $$$$ make this real? */
3030 vat_json_init_object (&node);
3031 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3032 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
3034 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
3036 /* Toss the shared-memory original... */
3037 pthread_mutex_lock (&am->vlib_rp->mutex);
3038 oldheap = svm_push_data_heap (am->vlib_rp);
3042 svm_pop_heap (oldheap);
3043 pthread_mutex_unlock (&am->vlib_rp->mutex);
3045 vat_json_print (vam->ofp, &node);
3046 vat_json_free (&node);
3048 vam->retval = ntohl (mp->retval);
3049 vam->result_ready = 1;
3053 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
3055 vat_main_t *vam = &vat_main;
3060 s = format (s, "%=16d%=16d%=16d",
3061 ntohl (mp->sw_if_index), mp->priority, mp->weight);
3065 s = format (s, "%=16U%=16d%=16d",
3066 mp->is_ipv6 ? format_ip6_address :
3068 mp->ip_address, mp->priority, mp->weight);
3071 print (vam->ofp, "%v", s);
3076 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
3078 vat_main_t *vam = &vat_main;
3079 vat_json_node_t *node = NULL;
3080 struct in6_addr ip6;
3083 if (VAT_JSON_ARRAY != vam->json_tree.type)
3085 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3086 vat_json_init_array (&vam->json_tree);
3088 node = vat_json_array_add (&vam->json_tree);
3089 vat_json_init_object (node);
3091 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
3092 vat_json_object_add_uint (node, "priority", mp->priority);
3093 vat_json_object_add_uint (node, "weight", mp->weight);
3096 vat_json_object_add_uint (node, "sw_if_index",
3097 clib_net_to_host_u32 (mp->sw_if_index));
3102 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3103 vat_json_object_add_ip6 (node, "address", ip6);
3107 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3108 vat_json_object_add_ip4 (node, "address", ip4);
3114 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
3117 vat_main_t *vam = &vat_main;
3120 ls_name = format (0, "%s", mp->ls_name);
3122 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
3128 vl_api_one_locator_set_details_t_handler_json
3129 (vl_api_one_locator_set_details_t * mp)
3131 vat_main_t *vam = &vat_main;
3132 vat_json_node_t *node = 0;
3135 ls_name = format (0, "%s", mp->ls_name);
3136 vec_add1 (ls_name, 0);
3138 if (VAT_JSON_ARRAY != vam->json_tree.type)
3140 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3141 vat_json_init_array (&vam->json_tree);
3143 node = vat_json_array_add (&vam->json_tree);
3145 vat_json_init_object (node);
3146 vat_json_object_add_string_copy (node, "ls_name", ls_name);
3147 vat_json_object_add_uint (node, "ls_index",
3148 clib_net_to_host_u32 (mp->ls_index));
3156 } __attribute__ ((__packed__)) lisp_nsh_api_t;
3159 unformat_nsh_address (unformat_input_t * input, va_list * args)
3161 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
3162 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
3166 format_nsh_address_vat (u8 * s, va_list * args)
3168 nsh_t *a = va_arg (*args, nsh_t *);
3169 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
3173 format_lisp_flat_eid (u8 * s, va_list * args)
3175 u32 type = va_arg (*args, u32);
3176 u8 *eid = va_arg (*args, u8 *);
3177 u32 eid_len = va_arg (*args, u32);
3182 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
3184 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
3186 return format (s, "%U", format_ethernet_address, eid);
3188 return format (s, "%U", format_nsh_address_vat, eid);
3194 format_lisp_eid_vat (u8 * s, va_list * args)
3196 u32 type = va_arg (*args, u32);
3197 u8 *eid = va_arg (*args, u8 *);
3198 u32 eid_len = va_arg (*args, u32);
3199 u8 *seid = va_arg (*args, u8 *);
3200 u32 seid_len = va_arg (*args, u32);
3201 u32 is_src_dst = va_arg (*args, u32);
3204 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
3206 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
3212 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
3214 vat_main_t *vam = &vat_main;
3215 u8 *s = 0, *eid = 0;
3217 if (~0 == mp->locator_set_index)
3218 s = format (0, "action: %d", mp->action);
3220 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3222 eid = format (0, "%U", format_lisp_eid_vat,
3226 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3229 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3230 clib_net_to_host_u32 (mp->vni),
3232 mp->is_local ? "local" : "remote",
3233 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3234 clib_net_to_host_u16 (mp->key_id), mp->key);
3241 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3244 vat_main_t *vam = &vat_main;
3245 vat_json_node_t *node = 0;
3248 if (VAT_JSON_ARRAY != vam->json_tree.type)
3250 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3251 vat_json_init_array (&vam->json_tree);
3253 node = vat_json_array_add (&vam->json_tree);
3255 vat_json_init_object (node);
3256 if (~0 == mp->locator_set_index)
3257 vat_json_object_add_uint (node, "action", mp->action);
3259 vat_json_object_add_uint (node, "locator_set_index",
3260 clib_net_to_host_u32 (mp->locator_set_index));
3262 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3263 if (mp->eid_type == 3)
3265 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3266 vat_json_init_object (nsh_json);
3267 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3268 vat_json_object_add_uint (nsh_json, "spi",
3269 clib_net_to_host_u32 (nsh->spi));
3270 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3274 eid = format (0, "%U", format_lisp_eid_vat,
3278 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3280 vat_json_object_add_string_copy (node, "eid", eid);
3283 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3284 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3285 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3289 vat_json_object_add_uint (node, "key_id",
3290 clib_net_to_host_u16 (mp->key_id));
3291 vat_json_object_add_string_copy (node, "key", mp->key);
3296 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3298 vat_main_t *vam = &vat_main;
3299 u8 *seid = 0, *deid = 0;
3300 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3302 deid = format (0, "%U", format_lisp_eid_vat,
3303 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3305 seid = format (0, "%U", format_lisp_eid_vat,
3306 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3312 format_ip_address_fcn = format_ip4_address;
3314 format_ip_address_fcn = format_ip6_address;
3317 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3318 clib_net_to_host_u32 (mp->vni),
3320 format_ip_address_fcn, mp->lloc,
3321 format_ip_address_fcn, mp->rloc,
3322 clib_net_to_host_u32 (mp->pkt_count),
3323 clib_net_to_host_u32 (mp->bytes));
3330 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3332 struct in6_addr ip6;
3334 vat_main_t *vam = &vat_main;
3335 vat_json_node_t *node = 0;
3336 u8 *deid = 0, *seid = 0;
3338 if (VAT_JSON_ARRAY != vam->json_tree.type)
3340 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3341 vat_json_init_array (&vam->json_tree);
3343 node = vat_json_array_add (&vam->json_tree);
3345 vat_json_init_object (node);
3346 deid = format (0, "%U", format_lisp_eid_vat,
3347 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3349 seid = format (0, "%U", format_lisp_eid_vat,
3350 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3355 vat_json_object_add_string_copy (node, "seid", seid);
3356 vat_json_object_add_string_copy (node, "deid", deid);
3357 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3361 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3362 vat_json_object_add_ip4 (node, "lloc", ip4);
3363 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3364 vat_json_object_add_ip4 (node, "rloc", ip4);
3368 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3369 vat_json_object_add_ip6 (node, "lloc", ip6);
3370 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3371 vat_json_object_add_ip6 (node, "rloc", ip6);
3373 vat_json_object_add_uint (node, "pkt_count",
3374 clib_net_to_host_u32 (mp->pkt_count));
3375 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3382 vl_api_one_eid_table_map_details_t_handler
3383 (vl_api_one_eid_table_map_details_t * mp)
3385 vat_main_t *vam = &vat_main;
3387 u8 *line = format (0, "%=10d%=10d",
3388 clib_net_to_host_u32 (mp->vni),
3389 clib_net_to_host_u32 (mp->dp_table));
3390 print (vam->ofp, "%v", line);
3395 vl_api_one_eid_table_map_details_t_handler_json
3396 (vl_api_one_eid_table_map_details_t * mp)
3398 vat_main_t *vam = &vat_main;
3399 vat_json_node_t *node = NULL;
3401 if (VAT_JSON_ARRAY != vam->json_tree.type)
3403 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3404 vat_json_init_array (&vam->json_tree);
3406 node = vat_json_array_add (&vam->json_tree);
3407 vat_json_init_object (node);
3408 vat_json_object_add_uint (node, "dp_table",
3409 clib_net_to_host_u32 (mp->dp_table));
3410 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3414 vl_api_one_eid_table_vni_details_t_handler
3415 (vl_api_one_eid_table_vni_details_t * mp)
3417 vat_main_t *vam = &vat_main;
3419 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3420 print (vam->ofp, "%v", line);
3425 vl_api_one_eid_table_vni_details_t_handler_json
3426 (vl_api_one_eid_table_vni_details_t * mp)
3428 vat_main_t *vam = &vat_main;
3429 vat_json_node_t *node = NULL;
3431 if (VAT_JSON_ARRAY != vam->json_tree.type)
3433 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3434 vat_json_init_array (&vam->json_tree);
3436 node = vat_json_array_add (&vam->json_tree);
3437 vat_json_init_object (node);
3438 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3442 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3443 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3445 vat_main_t *vam = &vat_main;
3446 int retval = clib_net_to_host_u32 (mp->retval);
3448 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3449 print (vam->ofp, "fallback threshold value: %d", mp->value);
3451 vam->retval = retval;
3452 vam->result_ready = 1;
3456 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3457 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3459 vat_main_t *vam = &vat_main;
3460 vat_json_node_t _node, *node = &_node;
3461 int retval = clib_net_to_host_u32 (mp->retval);
3463 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3464 vat_json_init_object (node);
3465 vat_json_object_add_uint (node, "value", mp->value);
3467 vat_json_print (vam->ofp, node);
3468 vat_json_free (node);
3470 vam->retval = retval;
3471 vam->result_ready = 1;
3475 vl_api_show_one_map_register_state_reply_t_handler
3476 (vl_api_show_one_map_register_state_reply_t * mp)
3478 vat_main_t *vam = &vat_main;
3479 int retval = clib_net_to_host_u32 (mp->retval);
3481 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3483 vam->retval = retval;
3484 vam->result_ready = 1;
3488 vl_api_show_one_map_register_state_reply_t_handler_json
3489 (vl_api_show_one_map_register_state_reply_t * mp)
3491 vat_main_t *vam = &vat_main;
3492 vat_json_node_t _node, *node = &_node;
3493 int retval = clib_net_to_host_u32 (mp->retval);
3495 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3497 vat_json_init_object (node);
3498 vat_json_object_add_string_copy (node, "state", s);
3500 vat_json_print (vam->ofp, node);
3501 vat_json_free (node);
3503 vam->retval = retval;
3504 vam->result_ready = 1;
3509 vl_api_show_one_rloc_probe_state_reply_t_handler
3510 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3512 vat_main_t *vam = &vat_main;
3513 int retval = clib_net_to_host_u32 (mp->retval);
3518 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3520 vam->retval = retval;
3521 vam->result_ready = 1;
3525 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3526 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3528 vat_main_t *vam = &vat_main;
3529 vat_json_node_t _node, *node = &_node;
3530 int retval = clib_net_to_host_u32 (mp->retval);
3532 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3533 vat_json_init_object (node);
3534 vat_json_object_add_string_copy (node, "state", s);
3536 vat_json_print (vam->ofp, node);
3537 vat_json_free (node);
3539 vam->retval = retval;
3540 vam->result_ready = 1;
3545 vl_api_show_one_stats_enable_disable_reply_t_handler
3546 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3548 vat_main_t *vam = &vat_main;
3549 int retval = clib_net_to_host_u32 (mp->retval);
3554 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3556 vam->retval = retval;
3557 vam->result_ready = 1;
3561 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3562 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3564 vat_main_t *vam = &vat_main;
3565 vat_json_node_t _node, *node = &_node;
3566 int retval = clib_net_to_host_u32 (mp->retval);
3568 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3569 vat_json_init_object (node);
3570 vat_json_object_add_string_copy (node, "state", s);
3572 vat_json_print (vam->ofp, node);
3573 vat_json_free (node);
3575 vam->retval = retval;
3576 vam->result_ready = 1;
3581 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3583 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3584 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3585 e->vni = clib_net_to_host_u32 (e->vni);
3589 gpe_fwd_entries_get_reply_t_net_to_host
3590 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3594 mp->count = clib_net_to_host_u32 (mp->count);
3595 for (i = 0; i < mp->count; i++)
3597 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3602 format_gpe_encap_mode (u8 * s, va_list * args)
3604 u32 mode = va_arg (*args, u32);
3609 return format (s, "lisp");
3611 return format (s, "vxlan");
3617 vl_api_gpe_get_encap_mode_reply_t_handler
3618 (vl_api_gpe_get_encap_mode_reply_t * mp)
3620 vat_main_t *vam = &vat_main;
3622 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3623 vam->retval = ntohl (mp->retval);
3624 vam->result_ready = 1;
3628 vl_api_gpe_get_encap_mode_reply_t_handler_json
3629 (vl_api_gpe_get_encap_mode_reply_t * mp)
3631 vat_main_t *vam = &vat_main;
3632 vat_json_node_t node;
3634 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3635 vec_add1 (encap_mode, 0);
3637 vat_json_init_object (&node);
3638 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3640 vec_free (encap_mode);
3641 vat_json_print (vam->ofp, &node);
3642 vat_json_free (&node);
3644 vam->retval = ntohl (mp->retval);
3645 vam->result_ready = 1;
3649 vl_api_gpe_fwd_entry_path_details_t_handler
3650 (vl_api_gpe_fwd_entry_path_details_t * mp)
3652 vat_main_t *vam = &vat_main;
3653 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3655 if (mp->lcl_loc.is_ip4)
3656 format_ip_address_fcn = format_ip4_address;
3658 format_ip_address_fcn = format_ip6_address;
3660 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3661 format_ip_address_fcn, &mp->lcl_loc,
3662 format_ip_address_fcn, &mp->rmt_loc);
3666 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3668 struct in6_addr ip6;
3673 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3674 vat_json_object_add_ip4 (n, "address", ip4);
3678 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3679 vat_json_object_add_ip6 (n, "address", ip6);
3681 vat_json_object_add_uint (n, "weight", loc->weight);
3685 vl_api_gpe_fwd_entry_path_details_t_handler_json
3686 (vl_api_gpe_fwd_entry_path_details_t * mp)
3688 vat_main_t *vam = &vat_main;
3689 vat_json_node_t *node = NULL;
3690 vat_json_node_t *loc_node;
3692 if (VAT_JSON_ARRAY != vam->json_tree.type)
3694 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3695 vat_json_init_array (&vam->json_tree);
3697 node = vat_json_array_add (&vam->json_tree);
3698 vat_json_init_object (node);
3700 loc_node = vat_json_object_add (node, "local_locator");
3701 vat_json_init_object (loc_node);
3702 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3704 loc_node = vat_json_object_add (node, "remote_locator");
3705 vat_json_init_object (loc_node);
3706 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3710 vl_api_gpe_fwd_entries_get_reply_t_handler
3711 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3713 vat_main_t *vam = &vat_main;
3715 int retval = clib_net_to_host_u32 (mp->retval);
3716 vl_api_gpe_fwd_entry_t *e;
3721 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3723 for (i = 0; i < mp->count; i++)
3725 e = &mp->entries[i];
3726 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3727 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3728 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3732 vam->retval = retval;
3733 vam->result_ready = 1;
3737 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3738 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3741 vat_main_t *vam = &vat_main;
3742 vat_json_node_t *e = 0, root;
3744 int retval = clib_net_to_host_u32 (mp->retval);
3745 vl_api_gpe_fwd_entry_t *fwd;
3750 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3751 vat_json_init_array (&root);
3753 for (i = 0; i < mp->count; i++)
3755 e = vat_json_array_add (&root);
3756 fwd = &mp->entries[i];
3758 vat_json_init_object (e);
3759 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3760 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3761 vat_json_object_add_int (e, "vni", fwd->vni);
3762 vat_json_object_add_int (e, "action", fwd->action);
3764 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3765 fwd->leid_prefix_len);
3767 vat_json_object_add_string_copy (e, "leid", s);
3770 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3771 fwd->reid_prefix_len);
3773 vat_json_object_add_string_copy (e, "reid", s);
3777 vat_json_print (vam->ofp, &root);
3778 vat_json_free (&root);
3781 vam->retval = retval;
3782 vam->result_ready = 1;
3786 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3787 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3789 vat_main_t *vam = &vat_main;
3791 int retval = clib_net_to_host_u32 (mp->retval);
3792 vl_api_gpe_native_fwd_rpath_t *r;
3797 n = clib_net_to_host_u32 (mp->count);
3799 for (i = 0; i < n; i++)
3801 r = &mp->entries[i];
3802 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3803 clib_net_to_host_u32 (r->fib_index),
3804 clib_net_to_host_u32 (r->nh_sw_if_index),
3805 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3809 vam->retval = retval;
3810 vam->result_ready = 1;
3814 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3815 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3817 vat_main_t *vam = &vat_main;
3818 vat_json_node_t root, *e;
3820 int retval = clib_net_to_host_u32 (mp->retval);
3821 vl_api_gpe_native_fwd_rpath_t *r;
3827 n = clib_net_to_host_u32 (mp->count);
3828 vat_json_init_array (&root);
3830 for (i = 0; i < n; i++)
3832 e = vat_json_array_add (&root);
3833 vat_json_init_object (e);
3834 r = &mp->entries[i];
3836 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3839 vat_json_object_add_string_copy (e, "ip4", s);
3842 vat_json_object_add_uint (e, "fib_index",
3843 clib_net_to_host_u32 (r->fib_index));
3844 vat_json_object_add_uint (e, "nh_sw_if_index",
3845 clib_net_to_host_u32 (r->nh_sw_if_index));
3848 vat_json_print (vam->ofp, &root);
3849 vat_json_free (&root);
3852 vam->retval = retval;
3853 vam->result_ready = 1;
3857 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3858 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3860 vat_main_t *vam = &vat_main;
3862 int retval = clib_net_to_host_u32 (mp->retval);
3867 n = clib_net_to_host_u32 (mp->count);
3869 for (i = 0; i < n; i++)
3870 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3873 vam->retval = retval;
3874 vam->result_ready = 1;
3878 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3879 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3881 vat_main_t *vam = &vat_main;
3882 vat_json_node_t root;
3884 int retval = clib_net_to_host_u32 (mp->retval);
3889 n = clib_net_to_host_u32 (mp->count);
3890 vat_json_init_array (&root);
3892 for (i = 0; i < n; i++)
3893 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3895 vat_json_print (vam->ofp, &root);
3896 vat_json_free (&root);
3899 vam->retval = retval;
3900 vam->result_ready = 1;
3904 vl_api_one_ndp_entries_get_reply_t_handler
3905 (vl_api_one_ndp_entries_get_reply_t * mp)
3907 vat_main_t *vam = &vat_main;
3909 int retval = clib_net_to_host_u32 (mp->retval);
3914 n = clib_net_to_host_u32 (mp->count);
3916 for (i = 0; i < n; i++)
3917 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3918 format_ethernet_address, mp->entries[i].mac);
3921 vam->retval = retval;
3922 vam->result_ready = 1;
3926 vl_api_one_ndp_entries_get_reply_t_handler_json
3927 (vl_api_one_ndp_entries_get_reply_t * mp)
3930 vat_main_t *vam = &vat_main;
3931 vat_json_node_t *e = 0, root;
3933 int retval = clib_net_to_host_u32 (mp->retval);
3934 vl_api_one_ndp_entry_t *arp_entry;
3939 n = clib_net_to_host_u32 (mp->count);
3940 vat_json_init_array (&root);
3942 for (i = 0; i < n; i++)
3944 e = vat_json_array_add (&root);
3945 arp_entry = &mp->entries[i];
3947 vat_json_init_object (e);
3948 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3951 vat_json_object_add_string_copy (e, "mac", s);
3954 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3956 vat_json_object_add_string_copy (e, "ip6", s);
3960 vat_json_print (vam->ofp, &root);
3961 vat_json_free (&root);
3964 vam->retval = retval;
3965 vam->result_ready = 1;
3969 vl_api_one_l2_arp_entries_get_reply_t_handler
3970 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3972 vat_main_t *vam = &vat_main;
3974 int retval = clib_net_to_host_u32 (mp->retval);
3979 n = clib_net_to_host_u32 (mp->count);
3981 for (i = 0; i < n; i++)
3982 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3983 format_ethernet_address, mp->entries[i].mac);
3986 vam->retval = retval;
3987 vam->result_ready = 1;
3991 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3992 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3995 vat_main_t *vam = &vat_main;
3996 vat_json_node_t *e = 0, root;
3998 int retval = clib_net_to_host_u32 (mp->retval);
3999 vl_api_one_l2_arp_entry_t *arp_entry;
4004 n = clib_net_to_host_u32 (mp->count);
4005 vat_json_init_array (&root);
4007 for (i = 0; i < n; i++)
4009 e = vat_json_array_add (&root);
4010 arp_entry = &mp->entries[i];
4012 vat_json_init_object (e);
4013 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
4016 vat_json_object_add_string_copy (e, "mac", s);
4019 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
4021 vat_json_object_add_string_copy (e, "ip4", s);
4025 vat_json_print (vam->ofp, &root);
4026 vat_json_free (&root);
4029 vam->retval = retval;
4030 vam->result_ready = 1;
4034 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
4036 vat_main_t *vam = &vat_main;
4038 int retval = clib_net_to_host_u32 (mp->retval);
4043 n = clib_net_to_host_u32 (mp->count);
4045 for (i = 0; i < n; i++)
4047 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
4051 vam->retval = retval;
4052 vam->result_ready = 1;
4056 vl_api_one_ndp_bd_get_reply_t_handler_json
4057 (vl_api_one_ndp_bd_get_reply_t * mp)
4059 vat_main_t *vam = &vat_main;
4060 vat_json_node_t root;
4062 int retval = clib_net_to_host_u32 (mp->retval);
4067 n = clib_net_to_host_u32 (mp->count);
4068 vat_json_init_array (&root);
4070 for (i = 0; i < n; i++)
4072 vat_json_array_add_uint (&root,
4073 clib_net_to_host_u32 (mp->bridge_domains[i]));
4076 vat_json_print (vam->ofp, &root);
4077 vat_json_free (&root);
4080 vam->retval = retval;
4081 vam->result_ready = 1;
4085 vl_api_one_l2_arp_bd_get_reply_t_handler
4086 (vl_api_one_l2_arp_bd_get_reply_t * mp)
4088 vat_main_t *vam = &vat_main;
4090 int retval = clib_net_to_host_u32 (mp->retval);
4095 n = clib_net_to_host_u32 (mp->count);
4097 for (i = 0; i < n; i++)
4099 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
4103 vam->retval = retval;
4104 vam->result_ready = 1;
4108 vl_api_one_l2_arp_bd_get_reply_t_handler_json
4109 (vl_api_one_l2_arp_bd_get_reply_t * mp)
4111 vat_main_t *vam = &vat_main;
4112 vat_json_node_t root;
4114 int retval = clib_net_to_host_u32 (mp->retval);
4119 n = clib_net_to_host_u32 (mp->count);
4120 vat_json_init_array (&root);
4122 for (i = 0; i < n; i++)
4124 vat_json_array_add_uint (&root,
4125 clib_net_to_host_u32 (mp->bridge_domains[i]));
4128 vat_json_print (vam->ofp, &root);
4129 vat_json_free (&root);
4132 vam->retval = retval;
4133 vam->result_ready = 1;
4137 vl_api_one_adjacencies_get_reply_t_handler
4138 (vl_api_one_adjacencies_get_reply_t * mp)
4140 vat_main_t *vam = &vat_main;
4142 int retval = clib_net_to_host_u32 (mp->retval);
4143 vl_api_one_adjacency_t *a;
4148 n = clib_net_to_host_u32 (mp->count);
4150 for (i = 0; i < n; i++)
4152 a = &mp->adjacencies[i];
4153 print (vam->ofp, "%U %40U",
4154 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
4155 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
4159 vam->retval = retval;
4160 vam->result_ready = 1;
4164 vl_api_one_adjacencies_get_reply_t_handler_json
4165 (vl_api_one_adjacencies_get_reply_t * mp)
4168 vat_main_t *vam = &vat_main;
4169 vat_json_node_t *e = 0, root;
4171 int retval = clib_net_to_host_u32 (mp->retval);
4172 vl_api_one_adjacency_t *a;
4177 n = clib_net_to_host_u32 (mp->count);
4178 vat_json_init_array (&root);
4180 for (i = 0; i < n; i++)
4182 e = vat_json_array_add (&root);
4183 a = &mp->adjacencies[i];
4185 vat_json_init_object (e);
4186 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
4187 a->leid_prefix_len);
4189 vat_json_object_add_string_copy (e, "leid", s);
4192 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
4193 a->reid_prefix_len);
4195 vat_json_object_add_string_copy (e, "reid", s);
4199 vat_json_print (vam->ofp, &root);
4200 vat_json_free (&root);
4203 vam->retval = retval;
4204 vam->result_ready = 1;
4208 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
4210 vat_main_t *vam = &vat_main;
4212 print (vam->ofp, "%=20U",
4213 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4218 vl_api_one_map_server_details_t_handler_json
4219 (vl_api_one_map_server_details_t * mp)
4221 vat_main_t *vam = &vat_main;
4222 vat_json_node_t *node = NULL;
4223 struct in6_addr ip6;
4226 if (VAT_JSON_ARRAY != vam->json_tree.type)
4228 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4229 vat_json_init_array (&vam->json_tree);
4231 node = vat_json_array_add (&vam->json_tree);
4233 vat_json_init_object (node);
4236 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4237 vat_json_object_add_ip6 (node, "map-server", ip6);
4241 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4242 vat_json_object_add_ip4 (node, "map-server", ip4);
4247 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4250 vat_main_t *vam = &vat_main;
4252 print (vam->ofp, "%=20U",
4253 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4258 vl_api_one_map_resolver_details_t_handler_json
4259 (vl_api_one_map_resolver_details_t * mp)
4261 vat_main_t *vam = &vat_main;
4262 vat_json_node_t *node = NULL;
4263 struct in6_addr ip6;
4266 if (VAT_JSON_ARRAY != vam->json_tree.type)
4268 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4269 vat_json_init_array (&vam->json_tree);
4271 node = vat_json_array_add (&vam->json_tree);
4273 vat_json_init_object (node);
4276 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4277 vat_json_object_add_ip6 (node, "map resolver", ip6);
4281 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4282 vat_json_object_add_ip4 (node, "map resolver", ip4);
4287 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4289 vat_main_t *vam = &vat_main;
4290 i32 retval = ntohl (mp->retval);
4294 print (vam->ofp, "feature: %s\ngpe: %s",
4295 mp->feature_status ? "enabled" : "disabled",
4296 mp->gpe_status ? "enabled" : "disabled");
4299 vam->retval = retval;
4300 vam->result_ready = 1;
4304 vl_api_show_one_status_reply_t_handler_json
4305 (vl_api_show_one_status_reply_t * mp)
4307 vat_main_t *vam = &vat_main;
4308 vat_json_node_t node;
4309 u8 *gpe_status = NULL;
4310 u8 *feature_status = NULL;
4312 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4313 feature_status = format (0, "%s",
4314 mp->feature_status ? "enabled" : "disabled");
4315 vec_add1 (gpe_status, 0);
4316 vec_add1 (feature_status, 0);
4318 vat_json_init_object (&node);
4319 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4320 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4322 vec_free (gpe_status);
4323 vec_free (feature_status);
4325 vat_json_print (vam->ofp, &node);
4326 vat_json_free (&node);
4328 vam->retval = ntohl (mp->retval);
4329 vam->result_ready = 1;
4333 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4334 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4336 vat_main_t *vam = &vat_main;
4337 i32 retval = ntohl (mp->retval);
4341 print (vam->ofp, "%=20s", mp->locator_set_name);
4344 vam->retval = retval;
4345 vam->result_ready = 1;
4349 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4350 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4352 vat_main_t *vam = &vat_main;
4353 vat_json_node_t *node = NULL;
4355 if (VAT_JSON_ARRAY != vam->json_tree.type)
4357 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4358 vat_json_init_array (&vam->json_tree);
4360 node = vat_json_array_add (&vam->json_tree);
4362 vat_json_init_object (node);
4363 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4365 vat_json_print (vam->ofp, node);
4366 vat_json_free (node);
4368 vam->retval = ntohl (mp->retval);
4369 vam->result_ready = 1;
4373 format_lisp_map_request_mode (u8 * s, va_list * args)
4375 u32 mode = va_arg (*args, u32);
4380 return format (0, "dst-only");
4382 return format (0, "src-dst");
4388 vl_api_show_one_map_request_mode_reply_t_handler
4389 (vl_api_show_one_map_request_mode_reply_t * mp)
4391 vat_main_t *vam = &vat_main;
4392 i32 retval = ntohl (mp->retval);
4396 u32 mode = mp->mode;
4397 print (vam->ofp, "map_request_mode: %U",
4398 format_lisp_map_request_mode, mode);
4401 vam->retval = retval;
4402 vam->result_ready = 1;
4406 vl_api_show_one_map_request_mode_reply_t_handler_json
4407 (vl_api_show_one_map_request_mode_reply_t * mp)
4409 vat_main_t *vam = &vat_main;
4410 vat_json_node_t node;
4415 s = format (0, "%U", format_lisp_map_request_mode, mode);
4418 vat_json_init_object (&node);
4419 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4420 vat_json_print (vam->ofp, &node);
4421 vat_json_free (&node);
4424 vam->retval = ntohl (mp->retval);
4425 vam->result_ready = 1;
4429 vl_api_one_show_xtr_mode_reply_t_handler
4430 (vl_api_one_show_xtr_mode_reply_t * mp)
4432 vat_main_t *vam = &vat_main;
4433 i32 retval = ntohl (mp->retval);
4437 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4440 vam->retval = retval;
4441 vam->result_ready = 1;
4445 vl_api_one_show_xtr_mode_reply_t_handler_json
4446 (vl_api_one_show_xtr_mode_reply_t * mp)
4448 vat_main_t *vam = &vat_main;
4449 vat_json_node_t node;
4452 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4453 vec_add1 (status, 0);
4455 vat_json_init_object (&node);
4456 vat_json_object_add_string_copy (&node, "status", status);
4460 vat_json_print (vam->ofp, &node);
4461 vat_json_free (&node);
4463 vam->retval = ntohl (mp->retval);
4464 vam->result_ready = 1;
4468 vl_api_one_show_pitr_mode_reply_t_handler
4469 (vl_api_one_show_pitr_mode_reply_t * mp)
4471 vat_main_t *vam = &vat_main;
4472 i32 retval = ntohl (mp->retval);
4476 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4479 vam->retval = retval;
4480 vam->result_ready = 1;
4484 vl_api_one_show_pitr_mode_reply_t_handler_json
4485 (vl_api_one_show_pitr_mode_reply_t * mp)
4487 vat_main_t *vam = &vat_main;
4488 vat_json_node_t node;
4491 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4492 vec_add1 (status, 0);
4494 vat_json_init_object (&node);
4495 vat_json_object_add_string_copy (&node, "status", status);
4499 vat_json_print (vam->ofp, &node);
4500 vat_json_free (&node);
4502 vam->retval = ntohl (mp->retval);
4503 vam->result_ready = 1;
4507 vl_api_one_show_petr_mode_reply_t_handler
4508 (vl_api_one_show_petr_mode_reply_t * mp)
4510 vat_main_t *vam = &vat_main;
4511 i32 retval = ntohl (mp->retval);
4515 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4518 vam->retval = retval;
4519 vam->result_ready = 1;
4523 vl_api_one_show_petr_mode_reply_t_handler_json
4524 (vl_api_one_show_petr_mode_reply_t * mp)
4526 vat_main_t *vam = &vat_main;
4527 vat_json_node_t node;
4530 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4531 vec_add1 (status, 0);
4533 vat_json_init_object (&node);
4534 vat_json_object_add_string_copy (&node, "status", status);
4538 vat_json_print (vam->ofp, &node);
4539 vat_json_free (&node);
4541 vam->retval = ntohl (mp->retval);
4542 vam->result_ready = 1;
4546 vl_api_show_one_use_petr_reply_t_handler
4547 (vl_api_show_one_use_petr_reply_t * mp)
4549 vat_main_t *vam = &vat_main;
4550 i32 retval = ntohl (mp->retval);
4554 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4557 print (vam->ofp, "Proxy-ETR address; %U",
4558 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4563 vam->retval = retval;
4564 vam->result_ready = 1;
4568 vl_api_show_one_use_petr_reply_t_handler_json
4569 (vl_api_show_one_use_petr_reply_t * mp)
4571 vat_main_t *vam = &vat_main;
4572 vat_json_node_t node;
4575 struct in6_addr ip6;
4577 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4578 vec_add1 (status, 0);
4580 vat_json_init_object (&node);
4581 vat_json_object_add_string_copy (&node, "status", status);
4586 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4587 vat_json_object_add_ip6 (&node, "address", ip6);
4591 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4592 vat_json_object_add_ip4 (&node, "address", ip4);
4598 vat_json_print (vam->ofp, &node);
4599 vat_json_free (&node);
4601 vam->retval = ntohl (mp->retval);
4602 vam->result_ready = 1;
4606 vl_api_show_one_nsh_mapping_reply_t_handler
4607 (vl_api_show_one_nsh_mapping_reply_t * mp)
4609 vat_main_t *vam = &vat_main;
4610 i32 retval = ntohl (mp->retval);
4614 print (vam->ofp, "%-20s%-16s",
4615 mp->is_set ? "set" : "not-set",
4616 mp->is_set ? (char *) mp->locator_set_name : "");
4619 vam->retval = retval;
4620 vam->result_ready = 1;
4624 vl_api_show_one_nsh_mapping_reply_t_handler_json
4625 (vl_api_show_one_nsh_mapping_reply_t * mp)
4627 vat_main_t *vam = &vat_main;
4628 vat_json_node_t node;
4631 status = format (0, "%s", mp->is_set ? "yes" : "no");
4632 vec_add1 (status, 0);
4634 vat_json_init_object (&node);
4635 vat_json_object_add_string_copy (&node, "is_set", status);
4638 vat_json_object_add_string_copy (&node, "locator_set",
4639 mp->locator_set_name);
4644 vat_json_print (vam->ofp, &node);
4645 vat_json_free (&node);
4647 vam->retval = ntohl (mp->retval);
4648 vam->result_ready = 1;
4652 vl_api_show_one_map_register_ttl_reply_t_handler
4653 (vl_api_show_one_map_register_ttl_reply_t * mp)
4655 vat_main_t *vam = &vat_main;
4656 i32 retval = ntohl (mp->retval);
4658 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4662 print (vam->ofp, "ttl: %u", mp->ttl);
4665 vam->retval = retval;
4666 vam->result_ready = 1;
4670 vl_api_show_one_map_register_ttl_reply_t_handler_json
4671 (vl_api_show_one_map_register_ttl_reply_t * mp)
4673 vat_main_t *vam = &vat_main;
4674 vat_json_node_t node;
4676 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4677 vat_json_init_object (&node);
4678 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4680 vat_json_print (vam->ofp, &node);
4681 vat_json_free (&node);
4683 vam->retval = ntohl (mp->retval);
4684 vam->result_ready = 1;
4688 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4690 vat_main_t *vam = &vat_main;
4691 i32 retval = ntohl (mp->retval);
4695 print (vam->ofp, "%-20s%-16s",
4696 mp->status ? "enabled" : "disabled",
4697 mp->status ? (char *) mp->locator_set_name : "");
4700 vam->retval = retval;
4701 vam->result_ready = 1;
4705 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4707 vat_main_t *vam = &vat_main;
4708 vat_json_node_t node;
4711 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4712 vec_add1 (status, 0);
4714 vat_json_init_object (&node);
4715 vat_json_object_add_string_copy (&node, "status", status);
4718 vat_json_object_add_string_copy (&node, "locator_set",
4719 mp->locator_set_name);
4724 vat_json_print (vam->ofp, &node);
4725 vat_json_free (&node);
4727 vam->retval = ntohl (mp->retval);
4728 vam->result_ready = 1;
4732 format_policer_type (u8 * s, va_list * va)
4734 u32 i = va_arg (*va, u32);
4736 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4737 s = format (s, "1r2c");
4738 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4739 s = format (s, "1r3c");
4740 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4741 s = format (s, "2r3c-2698");
4742 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4743 s = format (s, "2r3c-4115");
4744 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4745 s = format (s, "2r3c-mef5cf1");
4747 s = format (s, "ILLEGAL");
4752 format_policer_rate_type (u8 * s, va_list * va)
4754 u32 i = va_arg (*va, u32);
4756 if (i == SSE2_QOS_RATE_KBPS)
4757 s = format (s, "kbps");
4758 else if (i == SSE2_QOS_RATE_PPS)
4759 s = format (s, "pps");
4761 s = format (s, "ILLEGAL");
4766 format_policer_round_type (u8 * s, va_list * va)
4768 u32 i = va_arg (*va, u32);
4770 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4771 s = format (s, "closest");
4772 else if (i == SSE2_QOS_ROUND_TO_UP)
4773 s = format (s, "up");
4774 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4775 s = format (s, "down");
4777 s = format (s, "ILLEGAL");
4782 format_policer_action_type (u8 * s, va_list * va)
4784 u32 i = va_arg (*va, u32);
4786 if (i == SSE2_QOS_ACTION_DROP)
4787 s = format (s, "drop");
4788 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4789 s = format (s, "transmit");
4790 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4791 s = format (s, "mark-and-transmit");
4793 s = format (s, "ILLEGAL");
4798 format_dscp (u8 * s, va_list * va)
4800 u32 i = va_arg (*va, u32);
4805 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4809 return format (s, "ILLEGAL");
4811 s = format (s, "%s", t);
4816 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4818 vat_main_t *vam = &vat_main;
4819 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4821 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4822 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4824 conform_dscp_str = format (0, "");
4826 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4827 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4829 exceed_dscp_str = format (0, "");
4831 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4832 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4834 violate_dscp_str = format (0, "");
4836 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4837 "rate type %U, round type %U, %s rate, %s color-aware, "
4838 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4839 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4840 "conform action %U%s, exceed action %U%s, violate action %U%s",
4842 format_policer_type, mp->type,
4845 clib_net_to_host_u64 (mp->cb),
4846 clib_net_to_host_u64 (mp->eb),
4847 format_policer_rate_type, mp->rate_type,
4848 format_policer_round_type, mp->round_type,
4849 mp->single_rate ? "single" : "dual",
4850 mp->color_aware ? "is" : "not",
4851 ntohl (mp->cir_tokens_per_period),
4852 ntohl (mp->pir_tokens_per_period),
4854 ntohl (mp->current_limit),
4855 ntohl (mp->current_bucket),
4856 ntohl (mp->extended_limit),
4857 ntohl (mp->extended_bucket),
4858 clib_net_to_host_u64 (mp->last_update_time),
4859 format_policer_action_type, mp->conform_action_type,
4861 format_policer_action_type, mp->exceed_action_type,
4863 format_policer_action_type, mp->violate_action_type,
4866 vec_free (conform_dscp_str);
4867 vec_free (exceed_dscp_str);
4868 vec_free (violate_dscp_str);
4871 static void vl_api_policer_details_t_handler_json
4872 (vl_api_policer_details_t * mp)
4874 vat_main_t *vam = &vat_main;
4875 vat_json_node_t *node;
4876 u8 *rate_type_str, *round_type_str, *type_str;
4877 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4879 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4881 format (0, "%U", format_policer_round_type, mp->round_type);
4882 type_str = format (0, "%U", format_policer_type, mp->type);
4883 conform_action_str = format (0, "%U", format_policer_action_type,
4884 mp->conform_action_type);
4885 exceed_action_str = format (0, "%U", format_policer_action_type,
4886 mp->exceed_action_type);
4887 violate_action_str = format (0, "%U", format_policer_action_type,
4888 mp->violate_action_type);
4890 if (VAT_JSON_ARRAY != vam->json_tree.type)
4892 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4893 vat_json_init_array (&vam->json_tree);
4895 node = vat_json_array_add (&vam->json_tree);
4897 vat_json_init_object (node);
4898 vat_json_object_add_string_copy (node, "name", mp->name);
4899 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4900 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4901 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4902 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4903 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4904 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4905 vat_json_object_add_string_copy (node, "type", type_str);
4906 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4907 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4908 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4909 vat_json_object_add_uint (node, "cir_tokens_per_period",
4910 ntohl (mp->cir_tokens_per_period));
4911 vat_json_object_add_uint (node, "eir_tokens_per_period",
4912 ntohl (mp->pir_tokens_per_period));
4913 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4914 vat_json_object_add_uint (node, "current_bucket",
4915 ntohl (mp->current_bucket));
4916 vat_json_object_add_uint (node, "extended_limit",
4917 ntohl (mp->extended_limit));
4918 vat_json_object_add_uint (node, "extended_bucket",
4919 ntohl (mp->extended_bucket));
4920 vat_json_object_add_uint (node, "last_update_time",
4921 ntohl (mp->last_update_time));
4922 vat_json_object_add_string_copy (node, "conform_action",
4923 conform_action_str);
4924 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4926 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4927 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4928 vec_free (dscp_str);
4930 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4931 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4933 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4934 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4935 vec_free (dscp_str);
4937 vat_json_object_add_string_copy (node, "violate_action",
4938 violate_action_str);
4939 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4941 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4942 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4943 vec_free (dscp_str);
4946 vec_free (rate_type_str);
4947 vec_free (round_type_str);
4948 vec_free (type_str);
4949 vec_free (conform_action_str);
4950 vec_free (exceed_action_str);
4951 vec_free (violate_action_str);
4955 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4958 vat_main_t *vam = &vat_main;
4959 int i, count = ntohl (mp->count);
4962 print (vam->ofp, "classify table ids (%d) : ", count);
4963 for (i = 0; i < count; i++)
4965 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4966 print (vam->ofp, (i < count - 1) ? "," : "");
4968 vam->retval = ntohl (mp->retval);
4969 vam->result_ready = 1;
4973 vl_api_classify_table_ids_reply_t_handler_json
4974 (vl_api_classify_table_ids_reply_t * mp)
4976 vat_main_t *vam = &vat_main;
4977 int i, count = ntohl (mp->count);
4981 vat_json_node_t node;
4983 vat_json_init_object (&node);
4984 for (i = 0; i < count; i++)
4986 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4988 vat_json_print (vam->ofp, &node);
4989 vat_json_free (&node);
4991 vam->retval = ntohl (mp->retval);
4992 vam->result_ready = 1;
4996 vl_api_classify_table_by_interface_reply_t_handler
4997 (vl_api_classify_table_by_interface_reply_t * mp)
4999 vat_main_t *vam = &vat_main;
5002 table_id = ntohl (mp->l2_table_id);
5004 print (vam->ofp, "l2 table id : %d", table_id);
5006 print (vam->ofp, "l2 table id : No input ACL tables configured");
5007 table_id = ntohl (mp->ip4_table_id);
5009 print (vam->ofp, "ip4 table id : %d", table_id);
5011 print (vam->ofp, "ip4 table id : No input ACL tables configured");
5012 table_id = ntohl (mp->ip6_table_id);
5014 print (vam->ofp, "ip6 table id : %d", table_id);
5016 print (vam->ofp, "ip6 table id : No input ACL tables configured");
5017 vam->retval = ntohl (mp->retval);
5018 vam->result_ready = 1;
5022 vl_api_classify_table_by_interface_reply_t_handler_json
5023 (vl_api_classify_table_by_interface_reply_t * mp)
5025 vat_main_t *vam = &vat_main;
5026 vat_json_node_t node;
5028 vat_json_init_object (&node);
5030 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
5031 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
5032 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
5034 vat_json_print (vam->ofp, &node);
5035 vat_json_free (&node);
5037 vam->retval = ntohl (mp->retval);
5038 vam->result_ready = 1;
5041 static void vl_api_policer_add_del_reply_t_handler
5042 (vl_api_policer_add_del_reply_t * mp)
5044 vat_main_t *vam = &vat_main;
5045 i32 retval = ntohl (mp->retval);
5046 if (vam->async_mode)
5048 vam->async_errors += (retval < 0);
5052 vam->retval = retval;
5053 vam->result_ready = 1;
5054 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
5056 * Note: this is just barely thread-safe, depends on
5057 * the main thread spinning waiting for an answer...
5059 errmsg ("policer index %d", ntohl (mp->policer_index));
5063 static void vl_api_policer_add_del_reply_t_handler_json
5064 (vl_api_policer_add_del_reply_t * mp)
5066 vat_main_t *vam = &vat_main;
5067 vat_json_node_t node;
5069 vat_json_init_object (&node);
5070 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5071 vat_json_object_add_uint (&node, "policer_index",
5072 ntohl (mp->policer_index));
5074 vat_json_print (vam->ofp, &node);
5075 vat_json_free (&node);
5077 vam->retval = ntohl (mp->retval);
5078 vam->result_ready = 1;
5081 /* Format hex dump. */
5083 format_hex_bytes (u8 * s, va_list * va)
5085 u8 *bytes = va_arg (*va, u8 *);
5086 int n_bytes = va_arg (*va, int);
5089 /* Print short or long form depending on byte count. */
5090 uword short_form = n_bytes <= 32;
5091 u32 indent = format_get_indent (s);
5096 for (i = 0; i < n_bytes; i++)
5098 if (!short_form && (i % 32) == 0)
5099 s = format (s, "%08x: ", i);
5100 s = format (s, "%02x", bytes[i]);
5101 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
5102 s = format (s, "\n%U", format_white_space, indent);
5109 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
5112 vat_main_t *vam = &vat_main;
5113 i32 retval = ntohl (mp->retval);
5116 print (vam->ofp, "classify table info :");
5117 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
5118 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
5119 ntohl (mp->miss_next_index));
5120 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
5121 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
5122 ntohl (mp->match_n_vectors));
5123 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
5124 ntohl (mp->mask_length));
5126 vam->retval = retval;
5127 vam->result_ready = 1;
5131 vl_api_classify_table_info_reply_t_handler_json
5132 (vl_api_classify_table_info_reply_t * mp)
5134 vat_main_t *vam = &vat_main;
5135 vat_json_node_t node;
5137 i32 retval = ntohl (mp->retval);
5140 vat_json_init_object (&node);
5142 vat_json_object_add_int (&node, "sessions",
5143 ntohl (mp->active_sessions));
5144 vat_json_object_add_int (&node, "nexttbl",
5145 ntohl (mp->next_table_index));
5146 vat_json_object_add_int (&node, "nextnode",
5147 ntohl (mp->miss_next_index));
5148 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
5149 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
5150 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
5151 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
5152 ntohl (mp->mask_length), 0);
5153 vat_json_object_add_string_copy (&node, "mask", s);
5155 vat_json_print (vam->ofp, &node);
5156 vat_json_free (&node);
5158 vam->retval = ntohl (mp->retval);
5159 vam->result_ready = 1;
5163 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
5166 vat_main_t *vam = &vat_main;
5168 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
5169 ntohl (mp->hit_next_index), ntohl (mp->advance),
5170 ntohl (mp->opaque_index));
5171 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
5172 ntohl (mp->match_length));
5176 vl_api_classify_session_details_t_handler_json
5177 (vl_api_classify_session_details_t * mp)
5179 vat_main_t *vam = &vat_main;
5180 vat_json_node_t *node = NULL;
5182 if (VAT_JSON_ARRAY != vam->json_tree.type)
5184 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5185 vat_json_init_array (&vam->json_tree);
5187 node = vat_json_array_add (&vam->json_tree);
5189 vat_json_init_object (node);
5190 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
5191 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
5192 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
5194 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
5196 vat_json_object_add_string_copy (node, "match", s);
5199 static void vl_api_pg_create_interface_reply_t_handler
5200 (vl_api_pg_create_interface_reply_t * mp)
5202 vat_main_t *vam = &vat_main;
5204 vam->retval = ntohl (mp->retval);
5205 vam->result_ready = 1;
5208 static void vl_api_pg_create_interface_reply_t_handler_json
5209 (vl_api_pg_create_interface_reply_t * mp)
5211 vat_main_t *vam = &vat_main;
5212 vat_json_node_t node;
5214 i32 retval = ntohl (mp->retval);
5217 vat_json_init_object (&node);
5219 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
5221 vat_json_print (vam->ofp, &node);
5222 vat_json_free (&node);
5224 vam->retval = ntohl (mp->retval);
5225 vam->result_ready = 1;
5228 static void vl_api_policer_classify_details_t_handler
5229 (vl_api_policer_classify_details_t * mp)
5231 vat_main_t *vam = &vat_main;
5233 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5234 ntohl (mp->table_index));
5237 static void vl_api_policer_classify_details_t_handler_json
5238 (vl_api_policer_classify_details_t * mp)
5240 vat_main_t *vam = &vat_main;
5241 vat_json_node_t *node;
5243 if (VAT_JSON_ARRAY != vam->json_tree.type)
5245 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5246 vat_json_init_array (&vam->json_tree);
5248 node = vat_json_array_add (&vam->json_tree);
5250 vat_json_init_object (node);
5251 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5252 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5255 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
5256 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5258 vat_main_t *vam = &vat_main;
5259 i32 retval = ntohl (mp->retval);
5260 if (vam->async_mode)
5262 vam->async_errors += (retval < 0);
5266 vam->retval = retval;
5267 vam->sw_if_index = ntohl (mp->sw_if_index);
5268 vam->result_ready = 1;
5270 vam->regenerate_interface_table = 1;
5273 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
5274 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5276 vat_main_t *vam = &vat_main;
5277 vat_json_node_t node;
5279 vat_json_init_object (&node);
5280 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5281 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
5283 vat_json_print (vam->ofp, &node);
5284 vat_json_free (&node);
5286 vam->retval = ntohl (mp->retval);
5287 vam->result_ready = 1;
5290 static void vl_api_flow_classify_details_t_handler
5291 (vl_api_flow_classify_details_t * mp)
5293 vat_main_t *vam = &vat_main;
5295 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5296 ntohl (mp->table_index));
5299 static void vl_api_flow_classify_details_t_handler_json
5300 (vl_api_flow_classify_details_t * mp)
5302 vat_main_t *vam = &vat_main;
5303 vat_json_node_t *node;
5305 if (VAT_JSON_ARRAY != vam->json_tree.type)
5307 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5308 vat_json_init_array (&vam->json_tree);
5310 node = vat_json_array_add (&vam->json_tree);
5312 vat_json_init_object (node);
5313 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5314 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5317 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
5318 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
5319 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
5320 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
5321 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
5322 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
5323 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
5324 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
5325 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
5326 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
5327 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
5328 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
5329 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5330 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5331 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5332 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5333 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5334 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5335 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5336 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5337 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5338 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5341 * Generate boilerplate reply handlers, which
5342 * dig the return value out of the xxx_reply_t API message,
5343 * stick it into vam->retval, and set vam->result_ready
5345 * Could also do this by pointing N message decode slots at
5346 * a single function, but that could break in subtle ways.
5349 #define foreach_standard_reply_retval_handler \
5350 _(sw_interface_set_flags_reply) \
5351 _(sw_interface_add_del_address_reply) \
5352 _(sw_interface_set_rx_mode_reply) \
5353 _(sw_interface_set_rx_placement_reply) \
5354 _(sw_interface_set_table_reply) \
5355 _(sw_interface_set_mpls_enable_reply) \
5356 _(sw_interface_set_vpath_reply) \
5357 _(sw_interface_set_vxlan_bypass_reply) \
5358 _(sw_interface_set_geneve_bypass_reply) \
5359 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5360 _(sw_interface_set_l2_bridge_reply) \
5361 _(bridge_domain_add_del_reply) \
5362 _(sw_interface_set_l2_xconnect_reply) \
5363 _(l2fib_add_del_reply) \
5364 _(l2fib_flush_int_reply) \
5365 _(l2fib_flush_bd_reply) \
5366 _(ip_add_del_route_reply) \
5367 _(ip_table_add_del_reply) \
5368 _(ip_mroute_add_del_reply) \
5369 _(mpls_route_add_del_reply) \
5370 _(mpls_table_add_del_reply) \
5371 _(mpls_ip_bind_unbind_reply) \
5372 _(bier_route_add_del_reply) \
5373 _(bier_table_add_del_reply) \
5374 _(proxy_arp_add_del_reply) \
5375 _(proxy_arp_intfc_enable_disable_reply) \
5376 _(sw_interface_set_unnumbered_reply) \
5377 _(ip_neighbor_add_del_reply) \
5378 _(oam_add_del_reply) \
5379 _(reset_fib_reply) \
5380 _(dhcp_proxy_config_reply) \
5381 _(dhcp_proxy_set_vss_reply) \
5382 _(dhcp_client_config_reply) \
5383 _(set_ip_flow_hash_reply) \
5384 _(sw_interface_ip6_enable_disable_reply) \
5385 _(sw_interface_ip6_set_link_local_address_reply) \
5386 _(ip6nd_proxy_add_del_reply) \
5387 _(sw_interface_ip6nd_ra_prefix_reply) \
5388 _(sw_interface_ip6nd_ra_config_reply) \
5389 _(set_arp_neighbor_limit_reply) \
5390 _(l2_patch_add_del_reply) \
5391 _(sr_mpls_policy_add_reply) \
5392 _(sr_mpls_policy_mod_reply) \
5393 _(sr_mpls_policy_del_reply) \
5394 _(sr_policy_add_reply) \
5395 _(sr_policy_mod_reply) \
5396 _(sr_policy_del_reply) \
5397 _(sr_localsid_add_del_reply) \
5398 _(sr_steering_add_del_reply) \
5399 _(classify_add_del_session_reply) \
5400 _(classify_set_interface_ip_table_reply) \
5401 _(classify_set_interface_l2_tables_reply) \
5402 _(l2tpv3_set_tunnel_cookies_reply) \
5403 _(l2tpv3_interface_enable_disable_reply) \
5404 _(l2tpv3_set_lookup_key_reply) \
5405 _(l2_fib_clear_table_reply) \
5406 _(l2_interface_efp_filter_reply) \
5407 _(l2_interface_vlan_tag_rewrite_reply) \
5408 _(modify_vhost_user_if_reply) \
5409 _(delete_vhost_user_if_reply) \
5410 _(ip_probe_neighbor_reply) \
5411 _(ip_scan_neighbor_enable_disable_reply) \
5412 _(want_ip4_arp_events_reply) \
5413 _(want_ip6_nd_events_reply) \
5414 _(want_l2_macs_events_reply) \
5415 _(input_acl_set_interface_reply) \
5416 _(ipsec_spd_add_del_reply) \
5417 _(ipsec_interface_add_del_spd_reply) \
5418 _(ipsec_spd_add_del_entry_reply) \
5419 _(ipsec_sad_add_del_entry_reply) \
5420 _(ipsec_sa_set_key_reply) \
5421 _(ipsec_tunnel_if_add_del_reply) \
5422 _(ipsec_tunnel_if_set_key_reply) \
5423 _(ipsec_tunnel_if_set_sa_reply) \
5424 _(ikev2_profile_add_del_reply) \
5425 _(ikev2_profile_set_auth_reply) \
5426 _(ikev2_profile_set_id_reply) \
5427 _(ikev2_profile_set_ts_reply) \
5428 _(ikev2_set_local_key_reply) \
5429 _(ikev2_set_responder_reply) \
5430 _(ikev2_set_ike_transforms_reply) \
5431 _(ikev2_set_esp_transforms_reply) \
5432 _(ikev2_set_sa_lifetime_reply) \
5433 _(ikev2_initiate_sa_init_reply) \
5434 _(ikev2_initiate_del_ike_sa_reply) \
5435 _(ikev2_initiate_del_child_sa_reply) \
5436 _(ikev2_initiate_rekey_child_sa_reply) \
5437 _(delete_loopback_reply) \
5438 _(bd_ip_mac_add_del_reply) \
5439 _(want_interface_events_reply) \
5440 _(want_stats_reply) \
5441 _(cop_interface_enable_disable_reply) \
5442 _(cop_whitelist_enable_disable_reply) \
5443 _(sw_interface_clear_stats_reply) \
5444 _(ioam_enable_reply) \
5445 _(ioam_disable_reply) \
5446 _(one_add_del_locator_reply) \
5447 _(one_add_del_local_eid_reply) \
5448 _(one_add_del_remote_mapping_reply) \
5449 _(one_add_del_adjacency_reply) \
5450 _(one_add_del_map_resolver_reply) \
5451 _(one_add_del_map_server_reply) \
5452 _(one_enable_disable_reply) \
5453 _(one_rloc_probe_enable_disable_reply) \
5454 _(one_map_register_enable_disable_reply) \
5455 _(one_map_register_set_ttl_reply) \
5456 _(one_set_transport_protocol_reply) \
5457 _(one_map_register_fallback_threshold_reply) \
5458 _(one_pitr_set_locator_set_reply) \
5459 _(one_map_request_mode_reply) \
5460 _(one_add_del_map_request_itr_rlocs_reply) \
5461 _(one_eid_table_add_del_map_reply) \
5462 _(one_use_petr_reply) \
5463 _(one_stats_enable_disable_reply) \
5464 _(one_add_del_l2_arp_entry_reply) \
5465 _(one_add_del_ndp_entry_reply) \
5466 _(one_stats_flush_reply) \
5467 _(one_enable_disable_xtr_mode_reply) \
5468 _(one_enable_disable_pitr_mode_reply) \
5469 _(one_enable_disable_petr_mode_reply) \
5470 _(gpe_enable_disable_reply) \
5471 _(gpe_set_encap_mode_reply) \
5472 _(gpe_add_del_iface_reply) \
5473 _(gpe_add_del_native_fwd_rpath_reply) \
5474 _(af_packet_delete_reply) \
5475 _(policer_classify_set_interface_reply) \
5476 _(netmap_create_reply) \
5477 _(netmap_delete_reply) \
5478 _(set_ipfix_exporter_reply) \
5479 _(set_ipfix_classify_stream_reply) \
5480 _(ipfix_classify_table_add_del_reply) \
5481 _(flow_classify_set_interface_reply) \
5482 _(sw_interface_span_enable_disable_reply) \
5483 _(pg_capture_reply) \
5484 _(pg_enable_disable_reply) \
5485 _(ip_source_and_port_range_check_add_del_reply) \
5486 _(ip_source_and_port_range_check_interface_add_del_reply)\
5487 _(delete_subif_reply) \
5488 _(l2_interface_pbb_tag_rewrite_reply) \
5490 _(feature_enable_disable_reply) \
5491 _(sw_interface_tag_add_del_reply) \
5492 _(hw_interface_set_mtu_reply) \
5493 _(p2p_ethernet_add_reply) \
5494 _(p2p_ethernet_del_reply) \
5495 _(lldp_config_reply) \
5496 _(sw_interface_set_lldp_reply) \
5497 _(tcp_configure_src_addresses_reply) \
5498 _(dns_enable_disable_reply) \
5499 _(dns_name_server_add_del_reply) \
5500 _(session_rule_add_del_reply) \
5501 _(ip_container_proxy_add_del_reply) \
5502 _(output_acl_set_interface_reply) \
5503 _(qos_record_enable_disable_reply)
5506 static void vl_api_##n##_t_handler \
5507 (vl_api_##n##_t * mp) \
5509 vat_main_t * vam = &vat_main; \
5510 i32 retval = ntohl(mp->retval); \
5511 if (vam->async_mode) { \
5512 vam->async_errors += (retval < 0); \
5514 vam->retval = retval; \
5515 vam->result_ready = 1; \
5518 foreach_standard_reply_retval_handler;
5522 static void vl_api_##n##_t_handler_json \
5523 (vl_api_##n##_t * mp) \
5525 vat_main_t * vam = &vat_main; \
5526 vat_json_node_t node; \
5527 vat_json_init_object(&node); \
5528 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5529 vat_json_print(vam->ofp, &node); \
5530 vam->retval = ntohl(mp->retval); \
5531 vam->result_ready = 1; \
5533 foreach_standard_reply_retval_handler;
5537 * Table of message reply handlers, must include boilerplate handlers
5541 #define foreach_vpe_api_reply_msg \
5542 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5543 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5544 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5545 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5546 _(CONTROL_PING_REPLY, control_ping_reply) \
5547 _(CLI_REPLY, cli_reply) \
5548 _(CLI_INBAND_REPLY, cli_inband_reply) \
5549 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5550 sw_interface_add_del_address_reply) \
5551 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5552 _(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
5553 _(SW_INTERFACE_RX_PLACEMENT_DETAILS, sw_interface_rx_placement_details) \
5554 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5555 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5556 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5557 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5558 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5559 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5560 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5561 sw_interface_set_l2_xconnect_reply) \
5562 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5563 sw_interface_set_l2_bridge_reply) \
5564 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5565 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5566 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5567 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5568 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5569 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5570 _(L2_FLAGS_REPLY, l2_flags_reply) \
5571 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5572 _(TAP_CONNECT_REPLY, tap_connect_reply) \
5573 _(TAP_MODIFY_REPLY, tap_modify_reply) \
5574 _(TAP_DELETE_REPLY, tap_delete_reply) \
5575 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
5576 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5577 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5578 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5579 _(BOND_CREATE_REPLY, bond_create_reply) \
5580 _(BOND_DELETE_REPLY, bond_delete_reply) \
5581 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5582 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5583 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5584 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5585 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5586 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5587 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5588 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5589 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5590 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5591 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5592 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5593 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5594 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5595 proxy_arp_intfc_enable_disable_reply) \
5596 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5597 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5598 sw_interface_set_unnumbered_reply) \
5599 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5600 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5601 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5602 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5603 _(RESET_FIB_REPLY, reset_fib_reply) \
5604 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5605 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5606 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5607 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5608 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5609 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5610 sw_interface_ip6_enable_disable_reply) \
5611 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
5612 sw_interface_ip6_set_link_local_address_reply) \
5613 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5614 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5615 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5616 sw_interface_ip6nd_ra_prefix_reply) \
5617 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5618 sw_interface_ip6nd_ra_config_reply) \
5619 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5620 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5621 _(SR_MPLS_POLICY_ADD_REPLY, sr_mpls_policy_add_reply) \
5622 _(SR_MPLS_POLICY_MOD_REPLY, sr_mpls_policy_mod_reply) \
5623 _(SR_MPLS_POLICY_DEL_REPLY, sr_mpls_policy_del_reply) \
5624 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5625 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5626 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5627 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5628 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5629 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5630 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5631 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5632 classify_set_interface_ip_table_reply) \
5633 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5634 classify_set_interface_l2_tables_reply) \
5635 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5636 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5637 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5638 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5639 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5640 l2tpv3_interface_enable_disable_reply) \
5641 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5642 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5643 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5644 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5645 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5646 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5647 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5648 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5649 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5650 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5651 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5652 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5653 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5654 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5655 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5656 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5657 _(SHOW_VERSION_REPLY, show_version_reply) \
5658 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5659 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5660 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5661 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5662 _(IP_PROBE_NEIGHBOR_REPLY, ip_probe_neighbor_reply) \
5663 _(IP_SCAN_NEIGHBOR_ENABLE_DISABLE_REPLY, ip_scan_neighbor_enable_disable_reply) \
5664 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5665 _(IP4_ARP_EVENT, ip4_arp_event) \
5666 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5667 _(IP6_ND_EVENT, ip6_nd_event) \
5668 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5669 _(L2_MACS_EVENT, l2_macs_event) \
5670 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5671 _(IP_ADDRESS_DETAILS, ip_address_details) \
5672 _(IP_DETAILS, ip_details) \
5673 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5674 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5675 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
5676 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
5677 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5678 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5679 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5680 _(IPSEC_TUNNEL_IF_SET_KEY_REPLY, ipsec_tunnel_if_set_key_reply) \
5681 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5682 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
5683 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
5684 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
5685 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
5686 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
5687 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
5688 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
5689 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
5690 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
5691 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
5692 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
5693 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
5694 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
5695 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5696 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5697 _(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
5698 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5699 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5700 _(WANT_STATS_REPLY, want_stats_reply) \
5701 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5702 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5703 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5704 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5705 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5706 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5707 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5708 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5709 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5710 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5711 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5712 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5713 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5714 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5715 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5716 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5717 one_map_register_enable_disable_reply) \
5718 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5719 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5720 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5721 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5722 one_map_register_fallback_threshold_reply) \
5723 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5724 one_rloc_probe_enable_disable_reply) \
5725 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5726 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5727 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5728 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5729 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5730 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5731 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5732 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5733 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5734 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5735 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5736 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5737 _(ONE_STATS_DETAILS, one_stats_details) \
5738 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5739 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5740 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5741 show_one_stats_enable_disable_reply) \
5742 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5743 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5744 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5745 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5746 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5747 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5748 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5749 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5750 one_enable_disable_pitr_mode_reply) \
5751 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5752 one_enable_disable_petr_mode_reply) \
5753 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5754 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5755 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5756 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5757 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5758 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5759 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5760 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5761 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5762 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5763 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5764 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5765 gpe_add_del_native_fwd_rpath_reply) \
5766 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5767 gpe_fwd_entry_path_details) \
5768 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5769 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5770 one_add_del_map_request_itr_rlocs_reply) \
5771 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5772 one_get_map_request_itr_rlocs_reply) \
5773 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5774 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5775 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5776 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5777 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5778 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5779 show_one_map_register_state_reply) \
5780 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5781 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5782 show_one_map_register_fallback_threshold_reply) \
5783 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5784 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5785 _(AF_PACKET_DETAILS, af_packet_details) \
5786 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5787 _(POLICER_DETAILS, policer_details) \
5788 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5789 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5790 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5791 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5792 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5793 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5794 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5795 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5796 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5797 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5798 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5799 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5800 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5801 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5802 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5803 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5804 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5805 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5806 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5807 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5808 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5809 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5810 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5811 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5812 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5813 ip_source_and_port_range_check_add_del_reply) \
5814 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5815 ip_source_and_port_range_check_interface_add_del_reply) \
5816 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5817 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5818 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5819 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5820 _(PUNT_REPLY, punt_reply) \
5821 _(IP_FIB_DETAILS, ip_fib_details) \
5822 _(IP6_FIB_DETAILS, ip6_fib_details) \
5823 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5824 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5825 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5826 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5827 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5828 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5829 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5830 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5831 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5832 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5833 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5834 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5835 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5836 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5837 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
5838 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \
5839 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5840 _(SESSION_RULES_DETAILS, session_rules_details) \
5841 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5842 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5843 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply)
5845 #define foreach_standalone_reply_msg \
5846 _(SW_INTERFACE_EVENT, sw_interface_event) \
5847 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
5848 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
5849 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
5850 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
5851 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
5852 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters)
5860 #define STR_VTR_OP_CASE(op) \
5861 case L2_VTR_ ## op: \
5865 str_vtr_op (u32 vtr_op)
5869 STR_VTR_OP_CASE (DISABLED);
5870 STR_VTR_OP_CASE (PUSH_1);
5871 STR_VTR_OP_CASE (PUSH_2);
5872 STR_VTR_OP_CASE (POP_1);
5873 STR_VTR_OP_CASE (POP_2);
5874 STR_VTR_OP_CASE (TRANSLATE_1_1);
5875 STR_VTR_OP_CASE (TRANSLATE_1_2);
5876 STR_VTR_OP_CASE (TRANSLATE_2_1);
5877 STR_VTR_OP_CASE (TRANSLATE_2_2);
5884 dump_sub_interface_table (vat_main_t * vam)
5886 const sw_interface_subif_t *sub = NULL;
5888 if (vam->json_output)
5891 ("JSON output supported only for VPE API calls and dump_stats_table");
5896 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5897 "Interface", "sw_if_index",
5898 "sub id", "dot1ad", "tags", "outer id",
5899 "inner id", "exact", "default", "outer any", "inner any");
5901 vec_foreach (sub, vam->sw_if_subif_table)
5904 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5905 sub->interface_name,
5907 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5908 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5909 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5910 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5911 if (sub->vtr_op != L2_VTR_DISABLED)
5914 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5915 "tag1: %d tag2: %d ]",
5916 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5917 sub->vtr_tag1, sub->vtr_tag2);
5925 name_sort_cmp (void *a1, void *a2)
5927 name_sort_t *n1 = a1;
5928 name_sort_t *n2 = a2;
5930 return strcmp ((char *) n1->name, (char *) n2->name);
5934 dump_interface_table (vat_main_t * vam)
5937 name_sort_t *nses = 0, *ns;
5939 if (vam->json_output)
5942 ("JSON output supported only for VPE API calls and dump_stats_table");
5947 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5949 vec_add2 (nses, ns, 1);
5950 ns->name = (u8 *)(p->key);
5951 ns->value = (u32) p->value[0];
5955 vec_sort_with_function (nses, name_sort_cmp);
5957 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5958 vec_foreach (ns, nses)
5960 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5967 dump_ip_table (vat_main_t * vam, int is_ipv6)
5969 const ip_details_t *det = NULL;
5970 const ip_address_details_t *address = NULL;
5973 print (vam->ofp, "%-12s", "sw_if_index");
5975 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5982 print (vam->ofp, "%-12d", i);
5983 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5988 vec_foreach (address, det->addr)
5992 is_ipv6 ? format_ip6_address : format_ip4_address,
5993 address->ip, address->prefix_length);
6001 dump_ipv4_table (vat_main_t * vam)
6003 if (vam->json_output)
6006 ("JSON output supported only for VPE API calls and dump_stats_table");
6010 return dump_ip_table (vam, 0);
6014 dump_ipv6_table (vat_main_t * vam)
6016 if (vam->json_output)
6019 ("JSON output supported only for VPE API calls and dump_stats_table");
6023 return dump_ip_table (vam, 1);
6027 counter_type_to_str (u8 counter_type, u8 is_combined)
6031 switch (counter_type)
6033 case VNET_INTERFACE_COUNTER_DROP:
6035 case VNET_INTERFACE_COUNTER_PUNT:
6037 case VNET_INTERFACE_COUNTER_IP4:
6039 case VNET_INTERFACE_COUNTER_IP6:
6041 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
6043 case VNET_INTERFACE_COUNTER_RX_MISS:
6045 case VNET_INTERFACE_COUNTER_RX_ERROR:
6047 case VNET_INTERFACE_COUNTER_TX_ERROR:
6050 return "INVALID-COUNTER-TYPE";
6055 switch (counter_type)
6057 case VNET_INTERFACE_COUNTER_RX:
6059 case VNET_INTERFACE_COUNTER_TX:
6062 return "INVALID-COUNTER-TYPE";
6068 dump_stats_table (vat_main_t * vam)
6070 vat_json_node_t node;
6071 vat_json_node_t *msg_array;
6072 vat_json_node_t *msg;
6073 vat_json_node_t *counter_array;
6074 vat_json_node_t *counter;
6075 interface_counter_t c;
6077 ip4_fib_counter_t *c4;
6078 ip6_fib_counter_t *c6;
6079 ip4_nbr_counter_t *n4;
6080 ip6_nbr_counter_t *n6;
6083 if (!vam->json_output)
6085 clib_warning ("dump_stats_table supported only in JSON format");
6089 vat_json_init_object (&node);
6091 /* interface counters */
6092 msg_array = vat_json_object_add (&node, "interface_counters");
6093 vat_json_init_array (msg_array);
6094 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
6096 msg = vat_json_array_add (msg_array);
6097 vat_json_init_object (msg);
6098 vat_json_object_add_string_copy (msg, "vnet_counter_type",
6099 (u8 *) counter_type_to_str (i, 0));
6100 vat_json_object_add_int (msg, "is_combined", 0);
6101 counter_array = vat_json_object_add (msg, "data");
6102 vat_json_init_array (counter_array);
6103 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
6105 packets = vam->simple_interface_counters[i][j];
6106 vat_json_array_add_uint (counter_array, packets);
6109 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
6111 msg = vat_json_array_add (msg_array);
6112 vat_json_init_object (msg);
6113 vat_json_object_add_string_copy (msg, "vnet_counter_type",
6114 (u8 *) counter_type_to_str (i, 1));
6115 vat_json_object_add_int (msg, "is_combined", 1);
6116 counter_array = vat_json_object_add (msg, "data");
6117 vat_json_init_array (counter_array);
6118 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
6120 c = vam->combined_interface_counters[i][j];
6121 counter = vat_json_array_add (counter_array);
6122 vat_json_init_object (counter);
6123 vat_json_object_add_uint (counter, "packets", c.packets);
6124 vat_json_object_add_uint (counter, "bytes", c.bytes);
6128 /* ip4 fib counters */
6129 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
6130 vat_json_init_array (msg_array);
6131 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
6133 msg = vat_json_array_add (msg_array);
6134 vat_json_init_object (msg);
6135 vat_json_object_add_uint (msg, "vrf_id",
6136 vam->ip4_fib_counters_vrf_id_by_index[i]);
6137 counter_array = vat_json_object_add (msg, "c");
6138 vat_json_init_array (counter_array);
6139 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
6141 counter = vat_json_array_add (counter_array);
6142 vat_json_init_object (counter);
6143 c4 = &vam->ip4_fib_counters[i][j];
6144 vat_json_object_add_ip4 (counter, "address", c4->address);
6145 vat_json_object_add_uint (counter, "address_length",
6146 c4->address_length);
6147 vat_json_object_add_uint (counter, "packets", c4->packets);
6148 vat_json_object_add_uint (counter, "bytes", c4->bytes);
6152 /* ip6 fib counters */
6153 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
6154 vat_json_init_array (msg_array);
6155 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
6157 msg = vat_json_array_add (msg_array);
6158 vat_json_init_object (msg);
6159 vat_json_object_add_uint (msg, "vrf_id",
6160 vam->ip6_fib_counters_vrf_id_by_index[i]);
6161 counter_array = vat_json_object_add (msg, "c");
6162 vat_json_init_array (counter_array);
6163 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
6165 counter = vat_json_array_add (counter_array);
6166 vat_json_init_object (counter);
6167 c6 = &vam->ip6_fib_counters[i][j];
6168 vat_json_object_add_ip6 (counter, "address", c6->address);
6169 vat_json_object_add_uint (counter, "address_length",
6170 c6->address_length);
6171 vat_json_object_add_uint (counter, "packets", c6->packets);
6172 vat_json_object_add_uint (counter, "bytes", c6->bytes);
6176 /* ip4 nbr counters */
6177 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
6178 vat_json_init_array (msg_array);
6179 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
6181 msg = vat_json_array_add (msg_array);
6182 vat_json_init_object (msg);
6183 vat_json_object_add_uint (msg, "sw_if_index", i);
6184 counter_array = vat_json_object_add (msg, "c");
6185 vat_json_init_array (counter_array);
6186 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
6188 counter = vat_json_array_add (counter_array);
6189 vat_json_init_object (counter);
6190 n4 = &vam->ip4_nbr_counters[i][j];
6191 vat_json_object_add_ip4 (counter, "address", n4->address);
6192 vat_json_object_add_uint (counter, "link-type", n4->linkt);
6193 vat_json_object_add_uint (counter, "packets", n4->packets);
6194 vat_json_object_add_uint (counter, "bytes", n4->bytes);
6198 /* ip6 nbr counters */
6199 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
6200 vat_json_init_array (msg_array);
6201 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
6203 msg = vat_json_array_add (msg_array);
6204 vat_json_init_object (msg);
6205 vat_json_object_add_uint (msg, "sw_if_index", i);
6206 counter_array = vat_json_object_add (msg, "c");
6207 vat_json_init_array (counter_array);
6208 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
6210 counter = vat_json_array_add (counter_array);
6211 vat_json_init_object (counter);
6212 n6 = &vam->ip6_nbr_counters[i][j];
6213 vat_json_object_add_ip6 (counter, "address", n6->address);
6214 vat_json_object_add_uint (counter, "packets", n6->packets);
6215 vat_json_object_add_uint (counter, "bytes", n6->bytes);
6219 vat_json_print (vam->ofp, &node);
6220 vat_json_free (&node);
6226 * Pass CLI buffers directly in the CLI_INBAND API message,
6227 * instead of an additional shared memory area.
6230 exec_inband (vat_main_t * vam)
6232 vl_api_cli_inband_t *mp;
6233 unformat_input_t *i = vam->input;
6236 if (vec_len (i->buffer) == 0)
6239 if (vam->exec_mode == 0 && unformat (i, "mode"))
6244 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
6251 * In order for the CLI command to work, it
6252 * must be a vector ending in \n, not a C-string ending
6255 u32 len = vec_len (vam->input->buffer);
6256 M2 (CLI_INBAND, mp, len);
6257 clib_memcpy (mp->cmd, vam->input->buffer, len);
6258 mp->length = htonl (len);
6262 /* json responses may or may not include a useful reply... */
6263 if (vec_len (vam->cmd_reply))
6264 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
6269 exec (vat_main_t * vam)
6271 return exec_inband (vam);
6275 api_create_loopback (vat_main_t * vam)
6277 unformat_input_t *i = vam->input;
6278 vl_api_create_loopback_t *mp;
6279 vl_api_create_loopback_instance_t *mp_lbi;
6282 u8 is_specified = 0;
6283 u32 user_instance = 0;
6286 memset (mac_address, 0, sizeof (mac_address));
6288 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6290 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6292 if (unformat (i, "instance %d", &user_instance))
6300 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
6301 mp_lbi->is_specified = is_specified;
6303 mp_lbi->user_instance = htonl (user_instance);
6305 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
6310 /* Construct the API message */
6311 M (CREATE_LOOPBACK, mp);
6313 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
6322 api_delete_loopback (vat_main_t * vam)
6324 unformat_input_t *i = vam->input;
6325 vl_api_delete_loopback_t *mp;
6326 u32 sw_if_index = ~0;
6329 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6331 if (unformat (i, "sw_if_index %d", &sw_if_index))
6337 if (sw_if_index == ~0)
6339 errmsg ("missing sw_if_index");
6343 /* Construct the API message */
6344 M (DELETE_LOOPBACK, mp);
6345 mp->sw_if_index = ntohl (sw_if_index);
6353 api_want_stats (vat_main_t * vam)
6355 unformat_input_t *i = vam->input;
6356 vl_api_want_stats_t *mp;
6360 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6362 if (unformat (i, "enable"))
6364 else if (unformat (i, "disable"))
6372 errmsg ("missing enable|disable");
6377 mp->enable_disable = enable;
6385 api_want_interface_events (vat_main_t * vam)
6387 unformat_input_t *i = vam->input;
6388 vl_api_want_interface_events_t *mp;
6392 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6394 if (unformat (i, "enable"))
6396 else if (unformat (i, "disable"))
6404 errmsg ("missing enable|disable");
6408 M (WANT_INTERFACE_EVENTS, mp);
6409 mp->enable_disable = enable;
6411 vam->interface_event_display = enable;
6419 /* Note: non-static, called once to set up the initial intfc table */
6421 api_sw_interface_dump (vat_main_t * vam)
6423 vl_api_sw_interface_dump_t *mp;
6424 vl_api_control_ping_t *mp_ping;
6426 name_sort_t *nses = 0, *ns;
6427 sw_interface_subif_t *sub = NULL;
6430 /* Toss the old name table */
6432 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6434 vec_add2 (nses, ns, 1);
6435 ns->name = (u8 *)(p->key);
6436 ns->value = (u32) p->value[0];
6440 hash_free (vam->sw_if_index_by_interface_name);
6442 vec_foreach (ns, nses) vec_free (ns->name);
6446 vec_foreach (sub, vam->sw_if_subif_table)
6448 vec_free (sub->interface_name);
6450 vec_free (vam->sw_if_subif_table);
6452 /* recreate the interface name hash table */
6453 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
6456 * Ask for all interface names. Otherwise, the epic catalog of
6457 * name filters becomes ridiculously long, and vat ends up needing
6458 * to be taught about new interface types.
6460 M (SW_INTERFACE_DUMP, mp);
6463 /* Use a control ping for synchronization */
6464 MPING (CONTROL_PING, mp_ping);
6472 api_sw_interface_set_flags (vat_main_t * vam)
6474 unformat_input_t *i = vam->input;
6475 vl_api_sw_interface_set_flags_t *mp;
6477 u8 sw_if_index_set = 0;
6481 /* Parse args required to build the message */
6482 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6484 if (unformat (i, "admin-up"))
6486 else if (unformat (i, "admin-down"))
6489 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6490 sw_if_index_set = 1;
6491 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6492 sw_if_index_set = 1;
6497 if (sw_if_index_set == 0)
6499 errmsg ("missing interface name or sw_if_index");
6503 /* Construct the API message */
6504 M (SW_INTERFACE_SET_FLAGS, mp);
6505 mp->sw_if_index = ntohl (sw_if_index);
6506 mp->admin_up_down = admin_up;
6511 /* Wait for a reply, return the good/bad news... */
6517 api_sw_interface_set_rx_mode (vat_main_t * vam)
6519 unformat_input_t *i = vam->input;
6520 vl_api_sw_interface_set_rx_mode_t *mp;
6522 u8 sw_if_index_set = 0;
6524 u8 queue_id_valid = 0;
6526 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
6528 /* Parse args required to build the message */
6529 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6531 if (unformat (i, "queue %d", &queue_id))
6533 else if (unformat (i, "polling"))
6534 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
6535 else if (unformat (i, "interrupt"))
6536 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
6537 else if (unformat (i, "adaptive"))
6538 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
6540 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6541 sw_if_index_set = 1;
6542 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6543 sw_if_index_set = 1;
6548 if (sw_if_index_set == 0)
6550 errmsg ("missing interface name or sw_if_index");
6553 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6555 errmsg ("missing rx-mode");
6559 /* Construct the API message */
6560 M (SW_INTERFACE_SET_RX_MODE, mp);
6561 mp->sw_if_index = ntohl (sw_if_index);
6563 mp->queue_id_valid = queue_id_valid;
6564 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6569 /* Wait for a reply, return the good/bad news... */
6575 api_sw_interface_set_rx_placement (vat_main_t * vam)
6577 unformat_input_t *i = vam->input;
6578 vl_api_sw_interface_set_rx_placement_t *mp;
6580 u8 sw_if_index_set = 0;
6583 u32 queue_id, thread_index;
6585 /* Parse args required to build the message */
6586 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6588 if (unformat (i, "queue %d", &queue_id))
6590 else if (unformat (i, "main"))
6592 else if (unformat (i, "worker %d", &thread_index))
6595 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6596 sw_if_index_set = 1;
6597 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6598 sw_if_index_set = 1;
6603 if (sw_if_index_set == 0)
6605 errmsg ("missing interface name or sw_if_index");
6611 /* Construct the API message */
6612 M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
6613 mp->sw_if_index = ntohl (sw_if_index);
6614 mp->worker_id = ntohl (thread_index);
6615 mp->queue_id = ntohl (queue_id);
6616 mp->is_main = is_main;
6620 /* Wait for a reply, return the good/bad news... */
6625 static void vl_api_sw_interface_rx_placement_details_t_handler
6626 (vl_api_sw_interface_rx_placement_details_t * mp)
6628 vat_main_t *vam = &vat_main;
6629 u32 worker_id = ntohl (mp->worker_id);
6632 "\n%-11d %-11s %-6d %-5d %-9s",
6633 ntohl (mp->sw_if_index), (worker_id == 0) ? "main" : "worker",
6634 worker_id, ntohl (mp->queue_id),
6636 1) ? "polling" : ((mp->mode == 2) ? "interrupt" : "adaptive"));
6639 static void vl_api_sw_interface_rx_placement_details_t_handler_json
6640 (vl_api_sw_interface_rx_placement_details_t * mp)
6642 vat_main_t *vam = &vat_main;
6643 vat_json_node_t *node = NULL;
6645 if (VAT_JSON_ARRAY != vam->json_tree.type)
6647 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
6648 vat_json_init_array (&vam->json_tree);
6650 node = vat_json_array_add (&vam->json_tree);
6652 vat_json_init_object (node);
6653 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
6654 vat_json_object_add_uint (node, "worker_id", ntohl (mp->worker_id));
6655 vat_json_object_add_uint (node, "queue_id", ntohl (mp->queue_id));
6656 vat_json_object_add_uint (node, "mode", mp->mode);
6660 api_sw_interface_rx_placement_dump (vat_main_t * vam)
6662 unformat_input_t *i = vam->input;
6663 vl_api_sw_interface_rx_placement_dump_t *mp;
6664 vl_api_control_ping_t *mp_ping;
6667 u8 sw_if_index_set = 0;
6669 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6671 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6673 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6680 "\n%-11s %-11s %-6s %-5s %-4s",
6681 "sw_if_index", "main/worker", "thread", "queue", "mode");
6683 /* Dump Interface rx placement */
6684 M (SW_INTERFACE_RX_PLACEMENT_DUMP, mp);
6686 if (sw_if_index_set)
6687 mp->sw_if_index = htonl (sw_if_index);
6689 mp->sw_if_index = ~0;
6693 /* Use a control ping for synchronization */
6694 MPING (CONTROL_PING, mp_ping);
6702 api_sw_interface_clear_stats (vat_main_t * vam)
6704 unformat_input_t *i = vam->input;
6705 vl_api_sw_interface_clear_stats_t *mp;
6707 u8 sw_if_index_set = 0;
6710 /* Parse args required to build the message */
6711 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6713 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6714 sw_if_index_set = 1;
6715 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6716 sw_if_index_set = 1;
6721 /* Construct the API message */
6722 M (SW_INTERFACE_CLEAR_STATS, mp);
6724 if (sw_if_index_set == 1)
6725 mp->sw_if_index = ntohl (sw_if_index);
6727 mp->sw_if_index = ~0;
6732 /* Wait for a reply, return the good/bad news... */
6738 api_sw_interface_add_del_address (vat_main_t * vam)
6740 unformat_input_t *i = vam->input;
6741 vl_api_sw_interface_add_del_address_t *mp;
6743 u8 sw_if_index_set = 0;
6744 u8 is_add = 1, del_all = 0;
6745 u32 address_length = 0;
6746 u8 v4_address_set = 0;
6747 u8 v6_address_set = 0;
6748 ip4_address_t v4address;
6749 ip6_address_t v6address;
6752 /* Parse args required to build the message */
6753 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6755 if (unformat (i, "del-all"))
6757 else if (unformat (i, "del"))
6760 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6761 sw_if_index_set = 1;
6762 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6763 sw_if_index_set = 1;
6764 else if (unformat (i, "%U/%d",
6765 unformat_ip4_address, &v4address, &address_length))
6767 else if (unformat (i, "%U/%d",
6768 unformat_ip6_address, &v6address, &address_length))
6774 if (sw_if_index_set == 0)
6776 errmsg ("missing interface name or sw_if_index");
6779 if (v4_address_set && v6_address_set)
6781 errmsg ("both v4 and v6 addresses set");
6784 if (!v4_address_set && !v6_address_set && !del_all)
6786 errmsg ("no addresses set");
6790 /* Construct the API message */
6791 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6793 mp->sw_if_index = ntohl (sw_if_index);
6794 mp->is_add = is_add;
6795 mp->del_all = del_all;
6799 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6803 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6805 mp->address_length = address_length;
6810 /* Wait for a reply, return good/bad news */
6816 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6818 unformat_input_t *i = vam->input;
6819 vl_api_sw_interface_set_mpls_enable_t *mp;
6821 u8 sw_if_index_set = 0;
6825 /* Parse args required to build the message */
6826 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6828 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6829 sw_if_index_set = 1;
6830 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6831 sw_if_index_set = 1;
6832 else if (unformat (i, "disable"))
6834 else if (unformat (i, "dis"))
6840 if (sw_if_index_set == 0)
6842 errmsg ("missing interface name or sw_if_index");
6846 /* Construct the API message */
6847 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6849 mp->sw_if_index = ntohl (sw_if_index);
6850 mp->enable = enable;
6855 /* Wait for a reply... */
6861 api_sw_interface_set_table (vat_main_t * vam)
6863 unformat_input_t *i = vam->input;
6864 vl_api_sw_interface_set_table_t *mp;
6865 u32 sw_if_index, vrf_id = 0;
6866 u8 sw_if_index_set = 0;
6870 /* Parse args required to build the message */
6871 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6873 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6874 sw_if_index_set = 1;
6875 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6876 sw_if_index_set = 1;
6877 else if (unformat (i, "vrf %d", &vrf_id))
6879 else if (unformat (i, "ipv6"))
6885 if (sw_if_index_set == 0)
6887 errmsg ("missing interface name or sw_if_index");
6891 /* Construct the API message */
6892 M (SW_INTERFACE_SET_TABLE, mp);
6894 mp->sw_if_index = ntohl (sw_if_index);
6895 mp->is_ipv6 = is_ipv6;
6896 mp->vrf_id = ntohl (vrf_id);
6901 /* Wait for a reply... */
6906 static void vl_api_sw_interface_get_table_reply_t_handler
6907 (vl_api_sw_interface_get_table_reply_t * mp)
6909 vat_main_t *vam = &vat_main;
6911 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6913 vam->retval = ntohl (mp->retval);
6914 vam->result_ready = 1;
6918 static void vl_api_sw_interface_get_table_reply_t_handler_json
6919 (vl_api_sw_interface_get_table_reply_t * mp)
6921 vat_main_t *vam = &vat_main;
6922 vat_json_node_t node;
6924 vat_json_init_object (&node);
6925 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6926 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6928 vat_json_print (vam->ofp, &node);
6929 vat_json_free (&node);
6931 vam->retval = ntohl (mp->retval);
6932 vam->result_ready = 1;
6936 api_sw_interface_get_table (vat_main_t * vam)
6938 unformat_input_t *i = vam->input;
6939 vl_api_sw_interface_get_table_t *mp;
6941 u8 sw_if_index_set = 0;
6945 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6947 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6948 sw_if_index_set = 1;
6949 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6950 sw_if_index_set = 1;
6951 else if (unformat (i, "ipv6"))
6957 if (sw_if_index_set == 0)
6959 errmsg ("missing interface name or sw_if_index");
6963 M (SW_INTERFACE_GET_TABLE, mp);
6964 mp->sw_if_index = htonl (sw_if_index);
6965 mp->is_ipv6 = is_ipv6;
6973 api_sw_interface_set_vpath (vat_main_t * vam)
6975 unformat_input_t *i = vam->input;
6976 vl_api_sw_interface_set_vpath_t *mp;
6977 u32 sw_if_index = 0;
6978 u8 sw_if_index_set = 0;
6982 /* Parse args required to build the message */
6983 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6985 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6986 sw_if_index_set = 1;
6987 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6988 sw_if_index_set = 1;
6989 else if (unformat (i, "enable"))
6991 else if (unformat (i, "disable"))
6997 if (sw_if_index_set == 0)
6999 errmsg ("missing interface name or sw_if_index");
7003 /* Construct the API message */
7004 M (SW_INTERFACE_SET_VPATH, mp);
7006 mp->sw_if_index = ntohl (sw_if_index);
7007 mp->enable = is_enable;
7012 /* Wait for a reply... */
7018 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
7020 unformat_input_t *i = vam->input;
7021 vl_api_sw_interface_set_vxlan_bypass_t *mp;
7022 u32 sw_if_index = 0;
7023 u8 sw_if_index_set = 0;
7028 /* Parse args required to build the message */
7029 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7031 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7032 sw_if_index_set = 1;
7033 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7034 sw_if_index_set = 1;
7035 else if (unformat (i, "enable"))
7037 else if (unformat (i, "disable"))
7039 else if (unformat (i, "ip4"))
7041 else if (unformat (i, "ip6"))
7047 if (sw_if_index_set == 0)
7049 errmsg ("missing interface name or sw_if_index");
7053 /* Construct the API message */
7054 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
7056 mp->sw_if_index = ntohl (sw_if_index);
7057 mp->enable = is_enable;
7058 mp->is_ipv6 = is_ipv6;
7063 /* Wait for a reply... */
7069 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
7071 unformat_input_t *i = vam->input;
7072 vl_api_sw_interface_set_geneve_bypass_t *mp;
7073 u32 sw_if_index = 0;
7074 u8 sw_if_index_set = 0;
7079 /* Parse args required to build the message */
7080 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7082 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7083 sw_if_index_set = 1;
7084 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7085 sw_if_index_set = 1;
7086 else if (unformat (i, "enable"))
7088 else if (unformat (i, "disable"))
7090 else if (unformat (i, "ip4"))
7092 else if (unformat (i, "ip6"))
7098 if (sw_if_index_set == 0)
7100 errmsg ("missing interface name or sw_if_index");
7104 /* Construct the API message */
7105 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
7107 mp->sw_if_index = ntohl (sw_if_index);
7108 mp->enable = is_enable;
7109 mp->is_ipv6 = is_ipv6;
7114 /* Wait for a reply... */
7120 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
7122 unformat_input_t *i = vam->input;
7123 vl_api_sw_interface_set_l2_xconnect_t *mp;
7125 u8 rx_sw_if_index_set = 0;
7127 u8 tx_sw_if_index_set = 0;
7131 /* Parse args required to build the message */
7132 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7134 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
7135 rx_sw_if_index_set = 1;
7136 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
7137 tx_sw_if_index_set = 1;
7138 else if (unformat (i, "rx"))
7140 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7142 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7144 rx_sw_if_index_set = 1;
7149 else if (unformat (i, "tx"))
7151 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7153 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7155 tx_sw_if_index_set = 1;
7160 else if (unformat (i, "enable"))
7162 else if (unformat (i, "disable"))
7168 if (rx_sw_if_index_set == 0)
7170 errmsg ("missing rx interface name or rx_sw_if_index");
7174 if (enable && (tx_sw_if_index_set == 0))
7176 errmsg ("missing tx interface name or tx_sw_if_index");
7180 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
7182 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7183 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
7184 mp->enable = enable;
7192 api_sw_interface_set_l2_bridge (vat_main_t * vam)
7194 unformat_input_t *i = vam->input;
7195 vl_api_sw_interface_set_l2_bridge_t *mp;
7196 vl_api_l2_port_type_t port_type;
7198 u8 rx_sw_if_index_set = 0;
7205 port_type = L2_API_PORT_TYPE_NORMAL;
7207 /* Parse args required to build the message */
7208 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7210 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
7211 rx_sw_if_index_set = 1;
7212 else if (unformat (i, "bd_id %d", &bd_id))
7216 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
7217 rx_sw_if_index_set = 1;
7218 else if (unformat (i, "shg %d", &shg))
7220 else if (unformat (i, "bvi"))
7221 port_type = L2_API_PORT_TYPE_BVI;
7222 else if (unformat (i, "uu-fwd"))
7223 port_type = L2_API_PORT_TYPE_UU_FWD;
7224 else if (unformat (i, "enable"))
7226 else if (unformat (i, "disable"))
7232 if (rx_sw_if_index_set == 0)
7234 errmsg ("missing rx interface name or sw_if_index");
7238 if (enable && (bd_id_set == 0))
7240 errmsg ("missing bridge domain");
7244 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
7246 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7247 mp->bd_id = ntohl (bd_id);
7249 mp->port_type = ntohl (port_type);
7250 mp->enable = enable;
7258 api_bridge_domain_dump (vat_main_t * vam)
7260 unformat_input_t *i = vam->input;
7261 vl_api_bridge_domain_dump_t *mp;
7262 vl_api_control_ping_t *mp_ping;
7266 /* Parse args required to build the message */
7267 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7269 if (unformat (i, "bd_id %d", &bd_id))
7275 M (BRIDGE_DOMAIN_DUMP, mp);
7276 mp->bd_id = ntohl (bd_id);
7279 /* Use a control ping for synchronization */
7280 MPING (CONTROL_PING, mp_ping);
7288 api_bridge_domain_add_del (vat_main_t * vam)
7290 unformat_input_t *i = vam->input;
7291 vl_api_bridge_domain_add_del_t *mp;
7294 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
7299 /* Parse args required to build the message */
7300 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7302 if (unformat (i, "bd_id %d", &bd_id))
7304 else if (unformat (i, "flood %d", &flood))
7306 else if (unformat (i, "uu-flood %d", &uu_flood))
7308 else if (unformat (i, "forward %d", &forward))
7310 else if (unformat (i, "learn %d", &learn))
7312 else if (unformat (i, "arp-term %d", &arp_term))
7314 else if (unformat (i, "mac-age %d", &mac_age))
7316 else if (unformat (i, "bd-tag %s", &bd_tag))
7318 else if (unformat (i, "del"))
7321 flood = uu_flood = forward = learn = 0;
7329 errmsg ("missing bridge domain");
7336 errmsg ("mac age must be less than 256 ");
7341 if ((bd_tag) && (vec_len (bd_tag) > 63))
7343 errmsg ("bd-tag cannot be longer than 63");
7348 M (BRIDGE_DOMAIN_ADD_DEL, mp);
7350 mp->bd_id = ntohl (bd_id);
7352 mp->uu_flood = uu_flood;
7353 mp->forward = forward;
7355 mp->arp_term = arp_term;
7356 mp->is_add = is_add;
7357 mp->mac_age = (u8) mac_age;
7360 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
7361 mp->bd_tag[vec_len (bd_tag)] = 0;
7372 api_l2fib_flush_bd (vat_main_t * vam)
7374 unformat_input_t *i = vam->input;
7375 vl_api_l2fib_flush_bd_t *mp;
7379 /* Parse args required to build the message */
7380 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7382 if (unformat (i, "bd_id %d", &bd_id));
7389 errmsg ("missing bridge domain");
7393 M (L2FIB_FLUSH_BD, mp);
7395 mp->bd_id = htonl (bd_id);
7403 api_l2fib_flush_int (vat_main_t * vam)
7405 unformat_input_t *i = vam->input;
7406 vl_api_l2fib_flush_int_t *mp;
7407 u32 sw_if_index = ~0;
7410 /* Parse args required to build the message */
7411 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7413 if (unformat (i, "sw_if_index %d", &sw_if_index));
7415 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
7420 if (sw_if_index == ~0)
7422 errmsg ("missing interface name or sw_if_index");
7426 M (L2FIB_FLUSH_INT, mp);
7428 mp->sw_if_index = ntohl (sw_if_index);
7436 api_l2fib_add_del (vat_main_t * vam)
7438 unformat_input_t *i = vam->input;
7439 vl_api_l2fib_add_del_t *mp;
7445 u32 sw_if_index = 0;
7446 u8 sw_if_index_set = 0;
7455 /* Parse args required to build the message */
7456 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7458 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
7460 else if (unformat (i, "bd_id %d", &bd_id))
7462 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7463 sw_if_index_set = 1;
7464 else if (unformat (i, "sw_if"))
7466 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7469 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7470 sw_if_index_set = 1;
7475 else if (unformat (i, "static"))
7477 else if (unformat (i, "filter"))
7482 else if (unformat (i, "bvi"))
7487 else if (unformat (i, "del"))
7489 else if (unformat (i, "count %d", &count))
7497 errmsg ("missing mac address");
7503 errmsg ("missing bridge domain");
7507 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7509 errmsg ("missing interface name or sw_if_index");
7515 /* Turn on async mode */
7516 vam->async_mode = 1;
7517 vam->async_errors = 0;
7518 before = vat_time_now (vam);
7521 for (j = 0; j < count; j++)
7523 M (L2FIB_ADD_DEL, mp);
7525 clib_memcpy (mp->mac, mac, 6);
7526 mp->bd_id = ntohl (bd_id);
7527 mp->is_add = is_add;
7528 mp->sw_if_index = ntohl (sw_if_index);
7532 mp->static_mac = static_mac;
7533 mp->filter_mac = filter_mac;
7534 mp->bvi_mac = bvi_mac;
7536 increment_mac_address (mac);
7543 vl_api_control_ping_t *mp_ping;
7546 /* Shut off async mode */
7547 vam->async_mode = 0;
7549 MPING (CONTROL_PING, mp_ping);
7552 timeout = vat_time_now (vam) + 1.0;
7553 while (vat_time_now (vam) < timeout)
7554 if (vam->result_ready == 1)
7559 if (vam->retval == -99)
7562 if (vam->async_errors > 0)
7564 errmsg ("%d asynchronous errors", vam->async_errors);
7567 vam->async_errors = 0;
7568 after = vat_time_now (vam);
7570 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7571 count, after - before, count / (after - before));
7577 /* Wait for a reply... */
7581 /* Return the good/bad news */
7582 return (vam->retval);
7586 api_bridge_domain_set_mac_age (vat_main_t * vam)
7588 unformat_input_t *i = vam->input;
7589 vl_api_bridge_domain_set_mac_age_t *mp;
7594 /* Parse args required to build the message */
7595 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7597 if (unformat (i, "bd_id %d", &bd_id));
7598 else if (unformat (i, "mac-age %d", &mac_age));
7605 errmsg ("missing bridge domain");
7611 errmsg ("mac age must be less than 256 ");
7615 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7617 mp->bd_id = htonl (bd_id);
7618 mp->mac_age = (u8) mac_age;
7626 api_l2_flags (vat_main_t * vam)
7628 unformat_input_t *i = vam->input;
7629 vl_api_l2_flags_t *mp;
7632 u8 sw_if_index_set = 0;
7636 /* Parse args required to build the message */
7637 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7639 if (unformat (i, "sw_if_index %d", &sw_if_index))
7640 sw_if_index_set = 1;
7641 else if (unformat (i, "sw_if"))
7643 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7646 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7647 sw_if_index_set = 1;
7652 else if (unformat (i, "learn"))
7654 else if (unformat (i, "forward"))
7656 else if (unformat (i, "flood"))
7658 else if (unformat (i, "uu-flood"))
7659 flags |= L2_UU_FLOOD;
7660 else if (unformat (i, "arp-term"))
7661 flags |= L2_ARP_TERM;
7662 else if (unformat (i, "off"))
7664 else if (unformat (i, "disable"))
7670 if (sw_if_index_set == 0)
7672 errmsg ("missing interface name or sw_if_index");
7678 mp->sw_if_index = ntohl (sw_if_index);
7679 mp->feature_bitmap = ntohl (flags);
7680 mp->is_set = is_set;
7688 api_bridge_flags (vat_main_t * vam)
7690 unformat_input_t *i = vam->input;
7691 vl_api_bridge_flags_t *mp;
7695 bd_flags_t flags = 0;
7698 /* Parse args required to build the message */
7699 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7701 if (unformat (i, "bd_id %d", &bd_id))
7703 else if (unformat (i, "learn"))
7704 flags |= BRIDGE_API_FLAG_LEARN;
7705 else if (unformat (i, "forward"))
7706 flags |= BRIDGE_API_FLAG_FWD;
7707 else if (unformat (i, "flood"))
7708 flags |= BRIDGE_API_FLAG_FLOOD;
7709 else if (unformat (i, "uu-flood"))
7710 flags |= BRIDGE_API_FLAG_UU_FLOOD;
7711 else if (unformat (i, "arp-term"))
7712 flags |= BRIDGE_API_FLAG_ARP_TERM;
7713 else if (unformat (i, "off"))
7715 else if (unformat (i, "disable"))
7723 errmsg ("missing bridge domain");
7727 M (BRIDGE_FLAGS, mp);
7729 mp->bd_id = ntohl (bd_id);
7730 mp->flags = ntohl (flags);
7731 mp->is_set = is_set;
7739 api_bd_ip_mac_add_del (vat_main_t * vam)
7741 unformat_input_t *i = vam->input;
7742 vl_api_bd_ip_mac_add_del_t *mp;
7749 ip4_address_t v4addr;
7750 ip6_address_t v6addr;
7755 /* Parse args required to build the message */
7756 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7758 if (unformat (i, "bd_id %d", &bd_id))
7762 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
7766 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
7771 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
7775 else if (unformat (i, "del"))
7783 errmsg ("missing bridge domain");
7786 else if (ip_set == 0)
7788 errmsg ("missing IP address");
7791 else if (mac_set == 0)
7793 errmsg ("missing MAC address");
7797 M (BD_IP_MAC_ADD_DEL, mp);
7799 mp->bd_id = ntohl (bd_id);
7800 mp->is_ipv6 = is_ipv6;
7801 mp->is_add = is_add;
7803 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
7805 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
7806 clib_memcpy (mp->mac_address, macaddr, 6);
7812 static void vl_api_bd_ip_mac_details_t_handler
7813 (vl_api_bd_ip_mac_details_t * mp)
7815 vat_main_t *vam = &vat_main;
7820 format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
7823 format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
7826 "\n%-5d %-7s %-20U %-30s",
7827 ntohl (mp->bd_id), mp->is_ipv6 ? "ip6" : "ip4",
7828 format_ethernet_address, mp->mac_address, ip);
7833 static void vl_api_bd_ip_mac_details_t_handler_json
7834 (vl_api_bd_ip_mac_details_t * mp)
7836 vat_main_t *vam = &vat_main;
7837 vat_json_node_t *node = NULL;
7839 if (VAT_JSON_ARRAY != vam->json_tree.type)
7841 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7842 vat_json_init_array (&vam->json_tree);
7844 node = vat_json_array_add (&vam->json_tree);
7846 vat_json_init_object (node);
7847 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
7848 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
7849 vat_json_object_add_string_copy (node, "mac_address",
7850 format (0, "%U", format_ethernet_address,
7856 format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
7859 format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
7860 vat_json_object_add_string_copy (node, "ip_address", ip);
7865 api_bd_ip_mac_dump (vat_main_t * vam)
7867 unformat_input_t *i = vam->input;
7868 vl_api_bd_ip_mac_dump_t *mp;
7869 vl_api_control_ping_t *mp_ping;
7874 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7876 if (unformat (i, "bd_id %d", &bd_id))
7885 "\n%-5s %-7s %-20s %-30s",
7886 "bd_id", "is_ipv6", "mac_address", "ip_address");
7888 /* Dump Bridge Domain Ip to Mac entries */
7889 M (BD_IP_MAC_DUMP, mp);
7892 mp->bd_id = htonl (bd_id);
7898 /* Use a control ping for synchronization */
7899 MPING (CONTROL_PING, mp_ping);
7907 api_tap_connect (vat_main_t * vam)
7909 unformat_input_t *i = vam->input;
7910 vl_api_tap_connect_t *mp;
7916 ip4_address_t ip4_address;
7918 int ip4_address_set = 0;
7919 ip6_address_t ip6_address;
7921 int ip6_address_set = 0;
7924 memset (mac_address, 0, sizeof (mac_address));
7926 /* Parse args required to build the message */
7927 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7929 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7933 else if (unformat (i, "random-mac"))
7935 else if (unformat (i, "tapname %s", &tap_name))
7937 else if (unformat (i, "tag %s", &tag))
7939 else if (unformat (i, "address %U/%d",
7940 unformat_ip4_address, &ip4_address, &ip4_mask_width))
7941 ip4_address_set = 1;
7942 else if (unformat (i, "address %U/%d",
7943 unformat_ip6_address, &ip6_address, &ip6_mask_width))
7944 ip6_address_set = 1;
7951 errmsg ("missing tap name");
7954 if (vec_len (tap_name) > 63)
7956 errmsg ("tap name too long");
7959 vec_add1 (tap_name, 0);
7961 if (vec_len (tag) > 63)
7963 errmsg ("tag too long");
7967 /* Construct the API message */
7968 M (TAP_CONNECT, mp);
7970 mp->use_random_mac = random_mac;
7971 clib_memcpy (mp->mac_address, mac_address, 6);
7972 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7974 clib_memcpy (mp->tag, tag, vec_len (tag));
7976 if (ip4_address_set)
7978 mp->ip4_address_set = 1;
7979 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
7980 mp->ip4_mask_width = ip4_mask_width;
7982 if (ip6_address_set)
7984 mp->ip6_address_set = 1;
7985 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
7986 mp->ip6_mask_width = ip6_mask_width;
7989 vec_free (tap_name);
7995 /* Wait for a reply... */
8001 api_tap_modify (vat_main_t * vam)
8003 unformat_input_t *i = vam->input;
8004 vl_api_tap_modify_t *mp;
8009 u32 sw_if_index = ~0;
8010 u8 sw_if_index_set = 0;
8013 memset (mac_address, 0, sizeof (mac_address));
8015 /* Parse args required to build the message */
8016 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8018 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8019 sw_if_index_set = 1;
8020 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8021 sw_if_index_set = 1;
8022 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
8026 else if (unformat (i, "random-mac"))
8028 else if (unformat (i, "tapname %s", &tap_name))
8034 if (sw_if_index_set == 0)
8036 errmsg ("missing vpp interface name");
8041 errmsg ("missing tap name");
8044 if (vec_len (tap_name) > 63)
8046 errmsg ("tap name too long");
8048 vec_add1 (tap_name, 0);
8050 /* Construct the API message */
8053 mp->use_random_mac = random_mac;
8054 mp->sw_if_index = ntohl (sw_if_index);
8055 clib_memcpy (mp->mac_address, mac_address, 6);
8056 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
8057 vec_free (tap_name);
8062 /* Wait for a reply... */
8068 api_tap_delete (vat_main_t * vam)
8070 unformat_input_t *i = vam->input;
8071 vl_api_tap_delete_t *mp;
8072 u32 sw_if_index = ~0;
8073 u8 sw_if_index_set = 0;
8076 /* Parse args required to build the message */
8077 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8079 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8080 sw_if_index_set = 1;
8081 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8082 sw_if_index_set = 1;
8087 if (sw_if_index_set == 0)
8089 errmsg ("missing vpp interface name");
8093 /* Construct the API message */
8096 mp->sw_if_index = ntohl (sw_if_index);
8101 /* Wait for a reply... */
8107 api_tap_create_v2 (vat_main_t * vam)
8109 unformat_input_t *i = vam->input;
8110 vl_api_tap_create_v2_t *mp;
8114 u8 *host_if_name = 0;
8116 u8 host_mac_addr[6];
8117 u8 host_mac_addr_set = 0;
8118 u8 *host_bridge = 0;
8119 ip4_address_t host_ip4_addr;
8120 ip4_address_t host_ip4_gw;
8121 u8 host_ip4_gw_set = 0;
8122 u32 host_ip4_prefix_len = 0;
8123 ip6_address_t host_ip6_addr;
8124 ip6_address_t host_ip6_gw;
8125 u8 host_ip6_gw_set = 0;
8126 u32 host_ip6_prefix_len = 0;
8128 u32 rx_ring_sz = 0, tx_ring_sz = 0;
8130 memset (mac_address, 0, sizeof (mac_address));
8132 /* Parse args required to build the message */
8133 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8135 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
8139 else if (unformat (i, "id %u", &id))
8141 else if (unformat (i, "host-if-name %s", &host_if_name))
8143 else if (unformat (i, "host-ns %s", &host_ns))
8145 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
8147 host_mac_addr_set = 1;
8148 else if (unformat (i, "host-bridge %s", &host_bridge))
8150 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
8151 &host_ip4_addr, &host_ip4_prefix_len))
8153 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
8154 &host_ip6_addr, &host_ip6_prefix_len))
8156 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
8158 host_ip4_gw_set = 1;
8159 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
8161 host_ip6_gw_set = 1;
8162 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
8164 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
8170 if (vec_len (host_if_name) > 63)
8172 errmsg ("tap name too long. ");
8175 if (vec_len (host_ns) > 63)
8177 errmsg ("host name space too long. ");
8180 if (vec_len (host_bridge) > 63)
8182 errmsg ("host bridge name too long. ");
8185 if (host_ip4_prefix_len > 32)
8187 errmsg ("host ip4 prefix length not valid. ");
8190 if (host_ip6_prefix_len > 128)
8192 errmsg ("host ip6 prefix length not valid. ");
8195 if (!is_pow2 (rx_ring_sz))
8197 errmsg ("rx ring size must be power of 2. ");
8200 if (rx_ring_sz > 32768)
8202 errmsg ("rx ring size must be 32768 or lower. ");
8205 if (!is_pow2 (tx_ring_sz))
8207 errmsg ("tx ring size must be power of 2. ");
8210 if (tx_ring_sz > 32768)
8212 errmsg ("tx ring size must be 32768 or lower. ");
8216 /* Construct the API message */
8217 M (TAP_CREATE_V2, mp);
8219 mp->use_random_mac = random_mac;
8221 mp->id = ntohl (id);
8222 mp->host_namespace_set = host_ns != 0;
8223 mp->host_bridge_set = host_bridge != 0;
8224 mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
8225 mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
8226 mp->rx_ring_sz = ntohs (rx_ring_sz);
8227 mp->tx_ring_sz = ntohs (tx_ring_sz);
8229 if (random_mac == 0)
8230 clib_memcpy (mp->mac_address, mac_address, 6);
8231 if (host_mac_addr_set)
8232 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
8234 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
8236 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
8238 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
8239 if (host_ip4_prefix_len)
8240 clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
8241 if (host_ip4_prefix_len)
8242 clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
8243 if (host_ip4_gw_set)
8244 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
8245 if (host_ip6_gw_set)
8246 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
8249 vec_free (host_if_name);
8250 vec_free (host_bridge);
8255 /* Wait for a reply... */
8261 api_tap_delete_v2 (vat_main_t * vam)
8263 unformat_input_t *i = vam->input;
8264 vl_api_tap_delete_v2_t *mp;
8265 u32 sw_if_index = ~0;
8266 u8 sw_if_index_set = 0;
8269 /* Parse args required to build the message */
8270 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8272 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8273 sw_if_index_set = 1;
8274 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8275 sw_if_index_set = 1;
8280 if (sw_if_index_set == 0)
8282 errmsg ("missing vpp interface name. ");
8286 /* Construct the API message */
8287 M (TAP_DELETE_V2, mp);
8289 mp->sw_if_index = ntohl (sw_if_index);
8294 /* Wait for a reply... */
8300 api_bond_create (vat_main_t * vam)
8302 unformat_input_t *i = vam->input;
8303 vl_api_bond_create_t *mp;
8311 memset (mac_address, 0, sizeof (mac_address));
8314 /* Parse args required to build the message */
8315 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8317 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
8319 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
8320 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
8322 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
8329 if (mode_is_set == 0)
8331 errmsg ("Missing bond mode. ");
8335 /* Construct the API message */
8336 M (BOND_CREATE, mp);
8338 mp->use_custom_mac = custom_mac;
8344 clib_memcpy (mp->mac_address, mac_address, 6);
8349 /* Wait for a reply... */
8355 api_bond_delete (vat_main_t * vam)
8357 unformat_input_t *i = vam->input;
8358 vl_api_bond_delete_t *mp;
8359 u32 sw_if_index = ~0;
8360 u8 sw_if_index_set = 0;
8363 /* Parse args required to build the message */
8364 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8366 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8367 sw_if_index_set = 1;
8368 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8369 sw_if_index_set = 1;
8374 if (sw_if_index_set == 0)
8376 errmsg ("missing vpp interface name. ");
8380 /* Construct the API message */
8381 M (BOND_DELETE, mp);
8383 mp->sw_if_index = ntohl (sw_if_index);
8388 /* Wait for a reply... */
8394 api_bond_enslave (vat_main_t * vam)
8396 unformat_input_t *i = vam->input;
8397 vl_api_bond_enslave_t *mp;
8398 u32 bond_sw_if_index;
8402 u32 bond_sw_if_index_is_set = 0;
8404 u8 sw_if_index_is_set = 0;
8406 /* Parse args required to build the message */
8407 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8409 if (unformat (i, "sw_if_index %d", &sw_if_index))
8410 sw_if_index_is_set = 1;
8411 else if (unformat (i, "bond %u", &bond_sw_if_index))
8412 bond_sw_if_index_is_set = 1;
8413 else if (unformat (i, "passive %d", &is_passive))
8415 else if (unformat (i, "long-timeout %d", &is_long_timeout))
8421 if (bond_sw_if_index_is_set == 0)
8423 errmsg ("Missing bond sw_if_index. ");
8426 if (sw_if_index_is_set == 0)
8428 errmsg ("Missing slave sw_if_index. ");
8432 /* Construct the API message */
8433 M (BOND_ENSLAVE, mp);
8435 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
8436 mp->sw_if_index = ntohl (sw_if_index);
8437 mp->is_long_timeout = is_long_timeout;
8438 mp->is_passive = is_passive;
8443 /* Wait for a reply... */
8449 api_bond_detach_slave (vat_main_t * vam)
8451 unformat_input_t *i = vam->input;
8452 vl_api_bond_detach_slave_t *mp;
8453 u32 sw_if_index = ~0;
8454 u8 sw_if_index_set = 0;
8457 /* Parse args required to build the message */
8458 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8460 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8461 sw_if_index_set = 1;
8462 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8463 sw_if_index_set = 1;
8468 if (sw_if_index_set == 0)
8470 errmsg ("missing vpp interface name. ");
8474 /* Construct the API message */
8475 M (BOND_DETACH_SLAVE, mp);
8477 mp->sw_if_index = ntohl (sw_if_index);
8482 /* Wait for a reply... */
8488 api_ip_table_add_del (vat_main_t * vam)
8490 unformat_input_t *i = vam->input;
8491 vl_api_ip_table_add_del_t *mp;
8497 /* Parse args required to build the message */
8498 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8500 if (unformat (i, "ipv6"))
8502 else if (unformat (i, "del"))
8504 else if (unformat (i, "add"))
8506 else if (unformat (i, "table %d", &table_id))
8510 clib_warning ("parse error '%U'", format_unformat_error, i);
8517 errmsg ("missing table-ID");
8521 /* Construct the API message */
8522 M (IP_TABLE_ADD_DEL, mp);
8524 mp->table_id = ntohl (table_id);
8525 mp->is_ipv6 = is_ipv6;
8526 mp->is_add = is_add;
8531 /* Wait for a reply... */
8538 api_ip_add_del_route (vat_main_t * vam)
8540 unformat_input_t *i = vam->input;
8541 vl_api_ip_add_del_route_t *mp;
8542 u32 sw_if_index = ~0, vrf_id = 0;
8544 u8 is_local = 0, is_drop = 0;
8545 u8 is_unreach = 0, is_prohibit = 0;
8547 u32 next_hop_weight = 1;
8548 u8 is_multipath = 0;
8550 u8 address_length_set = 0;
8551 u32 next_hop_table_id = 0;
8552 u32 resolve_attempts = 0;
8553 u32 dst_address_length = 0;
8554 u8 next_hop_set = 0;
8555 ip4_address_t v4_dst_address, v4_next_hop_address;
8556 ip6_address_t v6_dst_address, v6_next_hop_address;
8560 u32 random_add_del = 0;
8561 u32 *random_vector = 0;
8563 u32 random_seed = 0xdeaddabe;
8564 u32 classify_table_index = ~0;
8566 u8 resolve_host = 0, resolve_attached = 0;
8567 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
8568 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8569 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8571 memset (&v4_next_hop_address, 0, sizeof (ip4_address_t));
8572 memset (&v6_next_hop_address, 0, sizeof (ip6_address_t));
8573 /* Parse args required to build the message */
8574 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8576 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8578 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8580 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
8585 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
8590 else if (unformat (i, "/%d", &dst_address_length))
8592 address_length_set = 1;
8595 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
8596 &v4_next_hop_address))
8600 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
8601 &v6_next_hop_address))
8607 (i, "via %U", api_unformat_sw_if_index, vam, &sw_if_index))
8611 else if (unformat (i, "via sw_if_index %d", &sw_if_index))
8615 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
8617 else if (unformat (i, "weight %d", &next_hop_weight))
8619 else if (unformat (i, "drop"))
8623 else if (unformat (i, "null-send-unreach"))
8627 else if (unformat (i, "null-send-prohibit"))
8631 else if (unformat (i, "local"))
8635 else if (unformat (i, "classify %d", &classify_table_index))
8639 else if (unformat (i, "del"))
8641 else if (unformat (i, "add"))
8643 else if (unformat (i, "resolve-via-host"))
8645 else if (unformat (i, "resolve-via-attached"))
8646 resolve_attached = 1;
8647 else if (unformat (i, "multipath"))
8649 else if (unformat (i, "vrf %d", &vrf_id))
8651 else if (unformat (i, "count %d", &count))
8653 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
8655 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8657 else if (unformat (i, "out-label %d", &next_hop_out_label))
8659 vl_api_fib_mpls_label_t fib_label = {
8660 .label = ntohl (next_hop_out_label),
8664 vec_add1 (next_hop_out_label_stack, fib_label);
8666 else if (unformat (i, "via via-label %d", &next_hop_via_label))
8668 else if (unformat (i, "random"))
8670 else if (unformat (i, "seed %d", &random_seed))
8674 clib_warning ("parse error '%U'", format_unformat_error, i);
8679 if (!next_hop_set && !is_drop && !is_local &&
8680 !is_classify && !is_unreach && !is_prohibit &&
8681 MPLS_LABEL_INVALID == next_hop_via_label)
8684 ("next hop / local / drop / unreach / prohibit / classify not set");
8688 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
8690 errmsg ("next hop and next-hop via label set");
8693 if (address_set == 0)
8695 errmsg ("missing addresses");
8699 if (address_length_set == 0)
8701 errmsg ("missing address length");
8705 /* Generate a pile of unique, random routes */
8708 u32 this_random_address;
8709 random_hash = hash_create (count, sizeof (uword));
8711 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
8712 for (j = 0; j <= count; j++)
8716 this_random_address = random_u32 (&random_seed);
8717 this_random_address =
8718 clib_host_to_net_u32 (this_random_address);
8720 while (hash_get (random_hash, this_random_address));
8721 vec_add1 (random_vector, this_random_address);
8722 hash_set (random_hash, this_random_address, 1);
8724 hash_free (random_hash);
8725 v4_dst_address.as_u32 = random_vector[0];
8730 /* Turn on async mode */
8731 vam->async_mode = 1;
8732 vam->async_errors = 0;
8733 before = vat_time_now (vam);
8736 for (j = 0; j < count; j++)
8738 /* Construct the API message */
8739 M2 (IP_ADD_DEL_ROUTE, mp, sizeof (vl_api_fib_mpls_label_t) *
8740 vec_len (next_hop_out_label_stack));
8742 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8743 mp->table_id = ntohl (vrf_id);
8745 mp->is_add = is_add;
8746 mp->is_drop = is_drop;
8747 mp->is_unreach = is_unreach;
8748 mp->is_prohibit = is_prohibit;
8749 mp->is_ipv6 = is_ipv6;
8750 mp->is_local = is_local;
8751 mp->is_classify = is_classify;
8752 mp->is_multipath = is_multipath;
8753 mp->is_resolve_host = resolve_host;
8754 mp->is_resolve_attached = resolve_attached;
8755 mp->next_hop_weight = next_hop_weight;
8756 mp->dst_address_length = dst_address_length;
8757 mp->next_hop_table_id = ntohl (next_hop_table_id);
8758 mp->classify_table_index = ntohl (classify_table_index);
8759 mp->next_hop_via_label = ntohl (next_hop_via_label);
8760 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8761 if (0 != mp->next_hop_n_out_labels)
8763 memcpy (mp->next_hop_out_label_stack,
8764 next_hop_out_label_stack,
8765 (vec_len (next_hop_out_label_stack) *
8766 sizeof (vl_api_fib_mpls_label_t)));
8767 vec_free (next_hop_out_label_stack);
8772 clib_memcpy (mp->dst_address, &v6_dst_address,
8773 sizeof (v6_dst_address));
8775 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
8776 sizeof (v6_next_hop_address));
8777 increment_v6_address (&v6_dst_address);
8781 clib_memcpy (mp->dst_address, &v4_dst_address,
8782 sizeof (v4_dst_address));
8784 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
8785 sizeof (v4_next_hop_address));
8787 v4_dst_address.as_u32 = random_vector[j + 1];
8789 increment_v4_address (&v4_dst_address);
8793 /* If we receive SIGTERM, stop now... */
8798 /* When testing multiple add/del ops, use a control-ping to sync */
8801 vl_api_control_ping_t *mp_ping;
8805 /* Shut off async mode */
8806 vam->async_mode = 0;
8808 MPING (CONTROL_PING, mp_ping);
8811 timeout = vat_time_now (vam) + 1.0;
8812 while (vat_time_now (vam) < timeout)
8813 if (vam->result_ready == 1)
8818 if (vam->retval == -99)
8821 if (vam->async_errors > 0)
8823 errmsg ("%d asynchronous errors", vam->async_errors);
8826 vam->async_errors = 0;
8827 after = vat_time_now (vam);
8829 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8833 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8834 count, after - before, count / (after - before));
8840 /* Wait for a reply... */
8845 /* Return the good/bad news */
8846 return (vam->retval);
8850 api_ip_mroute_add_del (vat_main_t * vam)
8852 unformat_input_t *i = vam->input;
8853 vl_api_ip_mroute_add_del_t *mp;
8854 u32 sw_if_index = ~0, vrf_id = 0;
8859 u32 grp_address_length = 0;
8860 ip4_address_t v4_grp_address, v4_src_address;
8861 ip6_address_t v6_grp_address, v6_src_address;
8862 mfib_itf_flags_t iflags = 0;
8863 mfib_entry_flags_t eflags = 0;
8866 /* Parse args required to build the message */
8867 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8869 if (unformat (i, "sw_if_index %d", &sw_if_index))
8871 else if (unformat (i, "%U %U",
8872 unformat_ip4_address, &v4_src_address,
8873 unformat_ip4_address, &v4_grp_address))
8875 grp_address_length = 64;
8879 else if (unformat (i, "%U %U",
8880 unformat_ip6_address, &v6_src_address,
8881 unformat_ip6_address, &v6_grp_address))
8883 grp_address_length = 256;
8887 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
8889 memset (&v4_src_address, 0, sizeof (v4_src_address));
8890 grp_address_length = 32;
8894 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
8896 memset (&v6_src_address, 0, sizeof (v6_src_address));
8897 grp_address_length = 128;
8901 else if (unformat (i, "/%d", &grp_address_length))
8903 else if (unformat (i, "local"))
8907 else if (unformat (i, "del"))
8909 else if (unformat (i, "add"))
8911 else if (unformat (i, "vrf %d", &vrf_id))
8913 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
8915 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8919 clib_warning ("parse error '%U'", format_unformat_error, i);
8924 if (address_set == 0)
8926 errmsg ("missing addresses\n");
8930 /* Construct the API message */
8931 M (IP_MROUTE_ADD_DEL, mp);
8933 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8934 mp->table_id = ntohl (vrf_id);
8936 mp->is_add = is_add;
8937 mp->is_ipv6 = is_ipv6;
8938 mp->is_local = is_local;
8939 mp->itf_flags = ntohl (iflags);
8940 mp->entry_flags = ntohl (eflags);
8941 mp->grp_address_length = grp_address_length;
8942 mp->grp_address_length = ntohs (mp->grp_address_length);
8946 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
8947 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
8951 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
8952 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
8958 /* Wait for a reply... */
8964 api_mpls_table_add_del (vat_main_t * vam)
8966 unformat_input_t *i = vam->input;
8967 vl_api_mpls_table_add_del_t *mp;
8972 /* Parse args required to build the message */
8973 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8975 if (unformat (i, "table %d", &table_id))
8977 else if (unformat (i, "del"))
8979 else if (unformat (i, "add"))
8983 clib_warning ("parse error '%U'", format_unformat_error, i);
8990 errmsg ("missing table-ID");
8994 /* Construct the API message */
8995 M (MPLS_TABLE_ADD_DEL, mp);
8997 mp->mt_table_id = ntohl (table_id);
8998 mp->mt_is_add = is_add;
9003 /* Wait for a reply... */
9010 api_mpls_route_add_del (vat_main_t * vam)
9012 unformat_input_t *i = vam->input;
9013 vl_api_mpls_route_add_del_t *mp;
9014 u32 sw_if_index = ~0, table_id = 0;
9016 u32 next_hop_weight = 1;
9017 u8 is_multipath = 0;
9018 u32 next_hop_table_id = 0;
9019 u8 next_hop_set = 0;
9020 ip4_address_t v4_next_hop_address = {
9023 ip6_address_t v6_next_hop_address = { {0} };
9027 u32 classify_table_index = ~0;
9029 u8 resolve_host = 0, resolve_attached = 0;
9030 u8 is_interface_rx = 0;
9031 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
9032 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9033 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
9034 mpls_label_t local_label = MPLS_LABEL_INVALID;
9036 dpo_proto_t next_hop_proto = DPO_PROTO_MPLS;
9038 /* Parse args required to build the message */
9039 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9041 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9043 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9045 else if (unformat (i, "%d", &local_label))
9047 else if (unformat (i, "eos"))
9049 else if (unformat (i, "non-eos"))
9051 else if (unformat (i, "via %U", unformat_ip4_address,
9052 &v4_next_hop_address))
9055 next_hop_proto = DPO_PROTO_IP4;
9057 else if (unformat (i, "via %U", unformat_ip6_address,
9058 &v6_next_hop_address))
9061 next_hop_proto = DPO_PROTO_IP6;
9063 else if (unformat (i, "weight %d", &next_hop_weight))
9065 else if (unformat (i, "classify %d", &classify_table_index))
9069 else if (unformat (i, "del"))
9071 else if (unformat (i, "add"))
9073 else if (unformat (i, "resolve-via-host"))
9075 else if (unformat (i, "resolve-via-attached"))
9076 resolve_attached = 1;
9077 else if (unformat (i, "multipath"))
9079 else if (unformat (i, "count %d", &count))
9081 else if (unformat (i, "via lookup-in-ip4-table %d", &next_hop_table_id))
9084 next_hop_proto = DPO_PROTO_IP4;
9086 else if (unformat (i, "via lookup-in-ip6-table %d", &next_hop_table_id))
9089 next_hop_proto = DPO_PROTO_IP6;
9093 (i, "via l2-input-on %U", api_unformat_sw_if_index, vam,
9097 next_hop_proto = DPO_PROTO_ETHERNET;
9098 is_interface_rx = 1;
9100 else if (unformat (i, "via l2-input-on sw_if_index %d", &sw_if_index))
9103 next_hop_proto = DPO_PROTO_ETHERNET;
9104 is_interface_rx = 1;
9106 else if (unformat (i, "via next-hop-table %d", &next_hop_table_id))
9108 else if (unformat (i, "via via-label %d", &next_hop_via_label))
9110 else if (unformat (i, "out-label %d", &next_hop_out_label))
9112 vl_api_fib_mpls_label_t fib_label = {
9113 .label = ntohl (next_hop_out_label),
9117 vec_add1 (next_hop_out_label_stack, fib_label);
9121 clib_warning ("parse error '%U'", format_unformat_error, i);
9126 if (!next_hop_set && !is_classify)
9128 errmsg ("next hop / classify not set");
9132 if (MPLS_LABEL_INVALID == local_label)
9134 errmsg ("missing label");
9140 /* Turn on async mode */
9141 vam->async_mode = 1;
9142 vam->async_errors = 0;
9143 before = vat_time_now (vam);
9146 for (j = 0; j < count; j++)
9148 /* Construct the API message */
9149 M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_mpls_label_t) *
9150 vec_len (next_hop_out_label_stack));
9152 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
9153 mp->mr_table_id = ntohl (table_id);
9155 mp->mr_is_add = is_add;
9156 mp->mr_next_hop_proto = next_hop_proto;
9157 mp->mr_is_classify = is_classify;
9158 mp->mr_is_multipath = is_multipath;
9159 mp->mr_is_resolve_host = resolve_host;
9160 mp->mr_is_resolve_attached = resolve_attached;
9161 mp->mr_is_interface_rx = is_interface_rx;
9162 mp->mr_next_hop_weight = next_hop_weight;
9163 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
9164 mp->mr_classify_table_index = ntohl (classify_table_index);
9165 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
9166 mp->mr_label = ntohl (local_label);
9167 mp->mr_eos = is_eos;
9169 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
9170 if (0 != mp->mr_next_hop_n_out_labels)
9172 memcpy (mp->mr_next_hop_out_label_stack,
9173 next_hop_out_label_stack,
9174 vec_len (next_hop_out_label_stack) *
9175 sizeof (vl_api_fib_mpls_label_t));
9176 vec_free (next_hop_out_label_stack);
9181 if (DPO_PROTO_IP4 == next_hop_proto)
9183 clib_memcpy (mp->mr_next_hop,
9184 &v4_next_hop_address,
9185 sizeof (v4_next_hop_address));
9187 else if (DPO_PROTO_IP6 == next_hop_proto)
9190 clib_memcpy (mp->mr_next_hop,
9191 &v6_next_hop_address,
9192 sizeof (v6_next_hop_address));
9199 /* If we receive SIGTERM, stop now... */
9204 /* When testing multiple add/del ops, use a control-ping to sync */
9207 vl_api_control_ping_t *mp_ping;
9211 /* Shut off async mode */
9212 vam->async_mode = 0;
9214 MPING (CONTROL_PING, mp_ping);
9217 timeout = vat_time_now (vam) + 1.0;
9218 while (vat_time_now (vam) < timeout)
9219 if (vam->result_ready == 1)
9224 if (vam->retval == -99)
9227 if (vam->async_errors > 0)
9229 errmsg ("%d asynchronous errors", vam->async_errors);
9232 vam->async_errors = 0;
9233 after = vat_time_now (vam);
9235 /* slim chance, but we might have eaten SIGTERM on the first iteration */
9239 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
9240 count, after - before, count / (after - before));
9246 /* Wait for a reply... */
9251 /* Return the good/bad news */
9252 return (vam->retval);
9256 api_mpls_ip_bind_unbind (vat_main_t * vam)
9258 unformat_input_t *i = vam->input;
9259 vl_api_mpls_ip_bind_unbind_t *mp;
9260 u32 ip_table_id = 0;
9263 ip4_address_t v4_address;
9264 ip6_address_t v6_address;
9267 mpls_label_t local_label = MPLS_LABEL_INVALID;
9270 /* Parse args required to build the message */
9271 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9273 if (unformat (i, "%U/%d", unformat_ip4_address,
9274 &v4_address, &address_length))
9279 else if (unformat (i, "%U/%d", unformat_ip6_address,
9280 &v6_address, &address_length))
9285 else if (unformat (i, "%d", &local_label))
9287 else if (unformat (i, "table-id %d", &ip_table_id))
9289 else if (unformat (i, "unbind"))
9291 else if (unformat (i, "bind"))
9295 clib_warning ("parse error '%U'", format_unformat_error, i);
9302 errmsg ("IP address not set");
9306 if (MPLS_LABEL_INVALID == local_label)
9308 errmsg ("missing label");
9312 /* Construct the API message */
9313 M (MPLS_IP_BIND_UNBIND, mp);
9315 mp->mb_is_bind = is_bind;
9316 mp->mb_is_ip4 = is_ip4;
9317 mp->mb_ip_table_id = ntohl (ip_table_id);
9318 mp->mb_mpls_table_id = 0;
9319 mp->mb_label = ntohl (local_label);
9320 mp->mb_address_length = address_length;
9323 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
9325 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
9330 /* Wait for a reply... */
9336 api_sr_mpls_policy_add (vat_main_t * vam)
9338 unformat_input_t *i = vam->input;
9339 vl_api_sr_mpls_policy_add_t *mp;
9345 u32 *segments = NULL;
9348 /* Parse args required to build the message */
9349 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9351 if (unformat (i, "bsid %d", &bsid))
9353 else if (unformat (i, "weight %d", &weight))
9355 else if (unformat (i, "spray"))
9357 else if (unformat (i, "next %d", &sid))
9360 vec_add1 (segments, htonl (sid));
9364 clib_warning ("parse error '%U'", format_unformat_error, i);
9371 errmsg ("bsid not set");
9375 if (n_segments == 0)
9377 errmsg ("no sid in segment stack");
9381 /* Construct the API message */
9382 M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
9384 mp->bsid = htonl (bsid);
9385 mp->weight = htonl (weight);
9387 mp->n_segments = n_segments;
9388 memcpy (mp->segments, segments, sizeof (u32) * n_segments);
9389 vec_free (segments);
9394 /* Wait for a reply... */
9400 api_sr_mpls_policy_del (vat_main_t * vam)
9402 unformat_input_t *i = vam->input;
9403 vl_api_sr_mpls_policy_del_t *mp;
9407 /* Parse args required to build the message */
9408 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9410 if (unformat (i, "bsid %d", &bsid))
9414 clib_warning ("parse error '%U'", format_unformat_error, i);
9421 errmsg ("bsid not set");
9425 /* Construct the API message */
9426 M (SR_MPLS_POLICY_DEL, mp);
9428 mp->bsid = htonl (bsid);
9433 /* Wait for a reply... */
9439 api_bier_table_add_del (vat_main_t * vam)
9441 unformat_input_t *i = vam->input;
9442 vl_api_bier_table_add_del_t *mp;
9444 u32 set = 0, sub_domain = 0, hdr_len = 3;
9445 mpls_label_t local_label = MPLS_LABEL_INVALID;
9448 /* Parse args required to build the message */
9449 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9451 if (unformat (i, "sub-domain %d", &sub_domain))
9453 else if (unformat (i, "set %d", &set))
9455 else if (unformat (i, "label %d", &local_label))
9457 else if (unformat (i, "hdr-len %d", &hdr_len))
9459 else if (unformat (i, "add"))
9461 else if (unformat (i, "del"))
9465 clib_warning ("parse error '%U'", format_unformat_error, i);
9470 if (MPLS_LABEL_INVALID == local_label)
9472 errmsg ("missing label\n");
9476 /* Construct the API message */
9477 M (BIER_TABLE_ADD_DEL, mp);
9479 mp->bt_is_add = is_add;
9480 mp->bt_label = ntohl (local_label);
9481 mp->bt_tbl_id.bt_set = set;
9482 mp->bt_tbl_id.bt_sub_domain = sub_domain;
9483 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
9488 /* Wait for a reply... */
9495 api_bier_route_add_del (vat_main_t * vam)
9497 unformat_input_t *i = vam->input;
9498 vl_api_bier_route_add_del_t *mp;
9500 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
9501 ip4_address_t v4_next_hop_address;
9502 ip6_address_t v6_next_hop_address;
9503 u8 next_hop_set = 0;
9504 u8 next_hop_proto_is_ip4 = 1;
9505 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9508 /* Parse args required to build the message */
9509 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9511 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
9513 next_hop_proto_is_ip4 = 1;
9516 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
9518 next_hop_proto_is_ip4 = 0;
9521 if (unformat (i, "sub-domain %d", &sub_domain))
9523 else if (unformat (i, "set %d", &set))
9525 else if (unformat (i, "hdr-len %d", &hdr_len))
9527 else if (unformat (i, "bp %d", &bp))
9529 else if (unformat (i, "add"))
9531 else if (unformat (i, "del"))
9533 else if (unformat (i, "out-label %d", &next_hop_out_label))
9537 clib_warning ("parse error '%U'", format_unformat_error, i);
9542 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
9544 errmsg ("next hop / label set\n");
9549 errmsg ("bit=position not set\n");
9553 /* Construct the API message */
9554 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
9556 mp->br_is_add = is_add;
9557 mp->br_tbl_id.bt_set = set;
9558 mp->br_tbl_id.bt_sub_domain = sub_domain;
9559 mp->br_tbl_id.bt_hdr_len_id = hdr_len;
9560 mp->br_bp = ntohs (bp);
9562 mp->br_paths[0].n_labels = 1;
9563 mp->br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
9564 mp->br_paths[0].afi = (next_hop_proto_is_ip4 ? 0 : 1);
9566 if (next_hop_proto_is_ip4)
9568 clib_memcpy (mp->br_paths[0].next_hop,
9569 &v4_next_hop_address, sizeof (v4_next_hop_address));
9573 clib_memcpy (mp->br_paths[0].next_hop,
9574 &v6_next_hop_address, sizeof (v6_next_hop_address));
9580 /* Wait for a reply... */
9587 api_proxy_arp_add_del (vat_main_t * vam)
9589 unformat_input_t *i = vam->input;
9590 vl_api_proxy_arp_add_del_t *mp;
9593 ip4_address_t lo, hi;
9597 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9599 if (unformat (i, "vrf %d", &vrf_id))
9601 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
9602 unformat_ip4_address, &hi))
9604 else if (unformat (i, "del"))
9608 clib_warning ("parse error '%U'", format_unformat_error, i);
9615 errmsg ("address range not set");
9619 M (PROXY_ARP_ADD_DEL, mp);
9621 mp->proxy.vrf_id = ntohl (vrf_id);
9622 mp->is_add = is_add;
9623 clib_memcpy (mp->proxy.low_address, &lo, sizeof (mp->proxy.low_address));
9624 clib_memcpy (mp->proxy.hi_address, &hi, sizeof (mp->proxy.hi_address));
9632 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
9634 unformat_input_t *i = vam->input;
9635 vl_api_proxy_arp_intfc_enable_disable_t *mp;
9638 u8 sw_if_index_set = 0;
9641 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9643 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9644 sw_if_index_set = 1;
9645 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9646 sw_if_index_set = 1;
9647 else if (unformat (i, "enable"))
9649 else if (unformat (i, "disable"))
9653 clib_warning ("parse error '%U'", format_unformat_error, i);
9658 if (sw_if_index_set == 0)
9660 errmsg ("missing interface name or sw_if_index");
9664 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
9666 mp->sw_if_index = ntohl (sw_if_index);
9667 mp->enable_disable = enable;
9675 api_mpls_tunnel_add_del (vat_main_t * vam)
9677 unformat_input_t *i = vam->input;
9678 vl_api_mpls_tunnel_add_del_t *mp;
9682 u32 sw_if_index = ~0;
9683 u32 next_hop_sw_if_index = ~0;
9684 u32 next_hop_proto_is_ip4 = 1;
9686 u32 next_hop_table_id = 0;
9687 ip4_address_t v4_next_hop_address = {
9690 ip6_address_t v6_next_hop_address = { {0} };
9691 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
9692 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
9695 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9697 if (unformat (i, "add"))
9699 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
9701 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
9703 else if (unformat (i, "via %U",
9704 unformat_ip4_address, &v4_next_hop_address))
9706 next_hop_proto_is_ip4 = 1;
9708 else if (unformat (i, "via %U",
9709 unformat_ip6_address, &v6_next_hop_address))
9711 next_hop_proto_is_ip4 = 0;
9713 else if (unformat (i, "via-label %d", &next_hop_via_label))
9715 else if (unformat (i, "l2-only"))
9717 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
9719 else if (unformat (i, "out-label %d", &next_hop_out_label))
9720 vec_add1 (labels, ntohl (next_hop_out_label));
9723 clib_warning ("parse error '%U'", format_unformat_error, i);
9728 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
9730 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
9731 mp->mt_sw_if_index = ntohl (sw_if_index);
9732 mp->mt_is_add = is_add;
9733 mp->mt_l2_only = l2_only;
9734 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
9735 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
9736 mp->mt_next_hop_via_label = ntohl (next_hop_via_label);
9738 mp->mt_next_hop_n_out_labels = vec_len (labels);
9740 if (0 != mp->mt_next_hop_n_out_labels)
9742 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
9743 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
9747 if (next_hop_proto_is_ip4)
9749 clib_memcpy (mp->mt_next_hop,
9750 &v4_next_hop_address, sizeof (v4_next_hop_address));
9754 clib_memcpy (mp->mt_next_hop,
9755 &v6_next_hop_address, sizeof (v6_next_hop_address));
9764 api_sw_interface_set_unnumbered (vat_main_t * vam)
9766 unformat_input_t *i = vam->input;
9767 vl_api_sw_interface_set_unnumbered_t *mp;
9769 u32 unnum_sw_index = ~0;
9771 u8 sw_if_index_set = 0;
9774 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9776 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9777 sw_if_index_set = 1;
9778 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9779 sw_if_index_set = 1;
9780 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
9782 else if (unformat (i, "del"))
9786 clib_warning ("parse error '%U'", format_unformat_error, i);
9791 if (sw_if_index_set == 0)
9793 errmsg ("missing interface name or sw_if_index");
9797 M (SW_INTERFACE_SET_UNNUMBERED, mp);
9799 mp->sw_if_index = ntohl (sw_if_index);
9800 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
9801 mp->is_add = is_add;
9809 api_ip_neighbor_add_del (vat_main_t * vam)
9811 unformat_input_t *i = vam->input;
9812 vl_api_ip_neighbor_add_del_t *mp;
9814 u8 sw_if_index_set = 0;
9817 u8 is_no_fib_entry = 0;
9820 u8 v4_address_set = 0;
9821 u8 v6_address_set = 0;
9822 ip4_address_t v4address;
9823 ip6_address_t v6address;
9826 memset (mac_address, 0, sizeof (mac_address));
9828 /* Parse args required to build the message */
9829 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9831 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
9835 else if (unformat (i, "del"))
9838 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9839 sw_if_index_set = 1;
9840 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9841 sw_if_index_set = 1;
9842 else if (unformat (i, "is_static"))
9844 else if (unformat (i, "no-fib-entry"))
9845 is_no_fib_entry = 1;
9846 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
9848 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
9852 clib_warning ("parse error '%U'", format_unformat_error, i);
9857 if (sw_if_index_set == 0)
9859 errmsg ("missing interface name or sw_if_index");
9862 if (v4_address_set && v6_address_set)
9864 errmsg ("both v4 and v6 addresses set");
9867 if (!v4_address_set && !v6_address_set)
9869 errmsg ("no address set");
9873 /* Construct the API message */
9874 M (IP_NEIGHBOR_ADD_DEL, mp);
9876 mp->sw_if_index = ntohl (sw_if_index);
9877 mp->is_add = is_add;
9878 mp->is_static = is_static;
9879 mp->is_no_adj_fib = is_no_fib_entry;
9881 clib_memcpy (mp->mac_address, mac_address, 6);
9885 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
9889 /* mp->is_ipv6 = 0; via memset in M macro above */
9890 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
9896 /* Wait for a reply, return good/bad news */
9902 api_create_vlan_subif (vat_main_t * vam)
9904 unformat_input_t *i = vam->input;
9905 vl_api_create_vlan_subif_t *mp;
9907 u8 sw_if_index_set = 0;
9912 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9914 if (unformat (i, "sw_if_index %d", &sw_if_index))
9915 sw_if_index_set = 1;
9917 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9918 sw_if_index_set = 1;
9919 else if (unformat (i, "vlan %d", &vlan_id))
9923 clib_warning ("parse error '%U'", format_unformat_error, i);
9928 if (sw_if_index_set == 0)
9930 errmsg ("missing interface name or sw_if_index");
9934 if (vlan_id_set == 0)
9936 errmsg ("missing vlan_id");
9939 M (CREATE_VLAN_SUBIF, mp);
9941 mp->sw_if_index = ntohl (sw_if_index);
9942 mp->vlan_id = ntohl (vlan_id);
9949 #define foreach_create_subif_bit \
9956 _(outer_vlan_id_any) \
9957 _(inner_vlan_id_any)
9960 api_create_subif (vat_main_t * vam)
9962 unformat_input_t *i = vam->input;
9963 vl_api_create_subif_t *mp;
9965 u8 sw_if_index_set = 0;
9972 u32 exact_match = 0;
9973 u32 default_sub = 0;
9974 u32 outer_vlan_id_any = 0;
9975 u32 inner_vlan_id_any = 0;
9977 u16 outer_vlan_id = 0;
9978 u16 inner_vlan_id = 0;
9981 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9983 if (unformat (i, "sw_if_index %d", &sw_if_index))
9984 sw_if_index_set = 1;
9986 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9987 sw_if_index_set = 1;
9988 else if (unformat (i, "sub_id %d", &sub_id))
9990 else if (unformat (i, "outer_vlan_id %d", &tmp))
9991 outer_vlan_id = tmp;
9992 else if (unformat (i, "inner_vlan_id %d", &tmp))
9993 inner_vlan_id = tmp;
9995 #define _(a) else if (unformat (i, #a)) a = 1 ;
9996 foreach_create_subif_bit
10000 clib_warning ("parse error '%U'", format_unformat_error, i);
10005 if (sw_if_index_set == 0)
10007 errmsg ("missing interface name or sw_if_index");
10011 if (sub_id_set == 0)
10013 errmsg ("missing sub_id");
10016 M (CREATE_SUBIF, mp);
10018 mp->sw_if_index = ntohl (sw_if_index);
10019 mp->sub_id = ntohl (sub_id);
10021 #define _(a) mp->a = a;
10022 foreach_create_subif_bit;
10025 mp->outer_vlan_id = ntohs (outer_vlan_id);
10026 mp->inner_vlan_id = ntohs (inner_vlan_id);
10034 api_oam_add_del (vat_main_t * vam)
10036 unformat_input_t *i = vam->input;
10037 vl_api_oam_add_del_t *mp;
10040 ip4_address_t src, dst;
10045 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10047 if (unformat (i, "vrf %d", &vrf_id))
10049 else if (unformat (i, "src %U", unformat_ip4_address, &src))
10051 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
10053 else if (unformat (i, "del"))
10057 clib_warning ("parse error '%U'", format_unformat_error, i);
10064 errmsg ("missing src addr");
10070 errmsg ("missing dst addr");
10074 M (OAM_ADD_DEL, mp);
10076 mp->vrf_id = ntohl (vrf_id);
10077 mp->is_add = is_add;
10078 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
10079 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
10087 api_reset_fib (vat_main_t * vam)
10089 unformat_input_t *i = vam->input;
10090 vl_api_reset_fib_t *mp;
10096 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10098 if (unformat (i, "vrf %d", &vrf_id))
10100 else if (unformat (i, "ipv6"))
10104 clib_warning ("parse error '%U'", format_unformat_error, i);
10109 if (vrf_id_set == 0)
10111 errmsg ("missing vrf id");
10117 mp->vrf_id = ntohl (vrf_id);
10118 mp->is_ipv6 = is_ipv6;
10126 api_dhcp_proxy_config (vat_main_t * vam)
10128 unformat_input_t *i = vam->input;
10129 vl_api_dhcp_proxy_config_t *mp;
10131 u32 server_vrf_id = 0;
10133 u8 v4_address_set = 0;
10134 u8 v6_address_set = 0;
10135 ip4_address_t v4address;
10136 ip6_address_t v6address;
10137 u8 v4_src_address_set = 0;
10138 u8 v6_src_address_set = 0;
10139 ip4_address_t v4srcaddress;
10140 ip6_address_t v6srcaddress;
10143 /* Parse args required to build the message */
10144 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10146 if (unformat (i, "del"))
10148 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
10150 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
10152 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
10153 v4_address_set = 1;
10154 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
10155 v6_address_set = 1;
10156 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
10157 v4_src_address_set = 1;
10158 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
10159 v6_src_address_set = 1;
10164 if (v4_address_set && v6_address_set)
10166 errmsg ("both v4 and v6 server addresses set");
10169 if (!v4_address_set && !v6_address_set)
10171 errmsg ("no server addresses set");
10175 if (v4_src_address_set && v6_src_address_set)
10177 errmsg ("both v4 and v6 src addresses set");
10180 if (!v4_src_address_set && !v6_src_address_set)
10182 errmsg ("no src addresses set");
10186 if (!(v4_src_address_set && v4_address_set) &&
10187 !(v6_src_address_set && v6_address_set))
10189 errmsg ("no matching server and src addresses set");
10193 /* Construct the API message */
10194 M (DHCP_PROXY_CONFIG, mp);
10196 mp->is_add = is_add;
10197 mp->rx_vrf_id = ntohl (rx_vrf_id);
10198 mp->server_vrf_id = ntohl (server_vrf_id);
10199 if (v6_address_set)
10202 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
10203 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
10207 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
10208 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
10214 /* Wait for a reply, return good/bad news */
10219 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
10220 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
10223 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
10225 vat_main_t *vam = &vat_main;
10226 u32 i, count = mp->count;
10227 vl_api_dhcp_server_t *s;
10231 "RX Table-ID %d, Source Address %U, VSS Type %d, "
10232 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
10233 ntohl (mp->rx_vrf_id),
10234 format_ip6_address, mp->dhcp_src_address,
10235 mp->vss_type, mp->vss_vpn_ascii_id,
10236 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
10239 "RX Table-ID %d, Source Address %U, VSS Type %d, "
10240 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
10241 ntohl (mp->rx_vrf_id),
10242 format_ip4_address, mp->dhcp_src_address,
10243 mp->vss_type, mp->vss_vpn_ascii_id,
10244 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
10246 for (i = 0; i < count; i++)
10248 s = &mp->servers[i];
10252 " Server Table-ID %d, Server Address %U",
10253 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
10256 " Server Table-ID %d, Server Address %U",
10257 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
10261 static void vl_api_dhcp_proxy_details_t_handler_json
10262 (vl_api_dhcp_proxy_details_t * mp)
10264 vat_main_t *vam = &vat_main;
10265 vat_json_node_t *node = NULL;
10266 u32 i, count = mp->count;
10267 struct in_addr ip4;
10268 struct in6_addr ip6;
10269 vl_api_dhcp_server_t *s;
10271 if (VAT_JSON_ARRAY != vam->json_tree.type)
10273 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10274 vat_json_init_array (&vam->json_tree);
10276 node = vat_json_array_add (&vam->json_tree);
10278 vat_json_init_object (node);
10279 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
10280 vat_json_object_add_bytes (node, "vss-type", &mp->vss_type,
10281 sizeof (mp->vss_type));
10282 vat_json_object_add_string_copy (node, "vss-vpn-ascii-id",
10283 mp->vss_vpn_ascii_id);
10284 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
10285 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
10289 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
10290 vat_json_object_add_ip6 (node, "src_address", ip6);
10294 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
10295 vat_json_object_add_ip4 (node, "src_address", ip4);
10298 for (i = 0; i < count; i++)
10300 s = &mp->servers[i];
10302 vat_json_object_add_uint (node, "server-table-id",
10303 ntohl (s->server_vrf_id));
10307 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
10308 vat_json_object_add_ip4 (node, "src_address", ip4);
10312 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
10313 vat_json_object_add_ip6 (node, "server_address", ip6);
10319 api_dhcp_proxy_dump (vat_main_t * vam)
10321 unformat_input_t *i = vam->input;
10322 vl_api_control_ping_t *mp_ping;
10323 vl_api_dhcp_proxy_dump_t *mp;
10327 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10329 if (unformat (i, "ipv6"))
10333 clib_warning ("parse error '%U'", format_unformat_error, i);
10338 M (DHCP_PROXY_DUMP, mp);
10340 mp->is_ip6 = is_ipv6;
10343 /* Use a control ping for synchronization */
10344 MPING (CONTROL_PING, mp_ping);
10352 api_dhcp_proxy_set_vss (vat_main_t * vam)
10354 unformat_input_t *i = vam->input;
10355 vl_api_dhcp_proxy_set_vss_t *mp;
10359 u8 vss_type = VSS_TYPE_DEFAULT;
10360 u8 *vpn_ascii_id = 0;
10365 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10367 if (unformat (i, "tbl_id %d", &tbl_id))
10369 else if (unformat (i, "vpn_ascii_id %s", &vpn_ascii_id))
10370 vss_type = VSS_TYPE_ASCII;
10371 else if (unformat (i, "fib_id %d", &fib_id))
10372 vss_type = VSS_TYPE_VPN_ID;
10373 else if (unformat (i, "oui %d", &oui))
10374 vss_type = VSS_TYPE_VPN_ID;
10375 else if (unformat (i, "ipv6"))
10377 else if (unformat (i, "del"))
10385 errmsg ("missing tbl_id ");
10386 vec_free (vpn_ascii_id);
10390 if ((vpn_ascii_id) && (vec_len (vpn_ascii_id) > 128))
10392 errmsg ("vpn_ascii_id cannot be longer than 128 ");
10393 vec_free (vpn_ascii_id);
10397 M (DHCP_PROXY_SET_VSS, mp);
10398 mp->tbl_id = ntohl (tbl_id);
10399 mp->vss_type = vss_type;
10402 clib_memcpy (mp->vpn_ascii_id, vpn_ascii_id, vec_len (vpn_ascii_id));
10403 mp->vpn_ascii_id[vec_len (vpn_ascii_id)] = 0;
10405 mp->vpn_index = ntohl (fib_id);
10406 mp->oui = ntohl (oui);
10407 mp->is_ipv6 = is_ipv6;
10408 mp->is_add = is_add;
10413 vec_free (vpn_ascii_id);
10418 api_dhcp_client_config (vat_main_t * vam)
10420 unformat_input_t *i = vam->input;
10421 vl_api_dhcp_client_config_t *mp;
10423 u8 sw_if_index_set = 0;
10426 u8 disable_event = 0;
10429 /* Parse args required to build the message */
10430 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10432 if (unformat (i, "del"))
10435 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10436 sw_if_index_set = 1;
10437 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10438 sw_if_index_set = 1;
10439 else if (unformat (i, "hostname %s", &hostname))
10441 else if (unformat (i, "disable_event"))
10447 if (sw_if_index_set == 0)
10449 errmsg ("missing interface name or sw_if_index");
10453 if (vec_len (hostname) > 63)
10455 errmsg ("hostname too long");
10457 vec_add1 (hostname, 0);
10459 /* Construct the API message */
10460 M (DHCP_CLIENT_CONFIG, mp);
10462 mp->is_add = is_add;
10463 mp->client.sw_if_index = htonl (sw_if_index);
10464 clib_memcpy (mp->client.hostname, hostname, vec_len (hostname));
10465 vec_free (hostname);
10466 mp->client.want_dhcp_event = disable_event ? 0 : 1;
10467 mp->client.pid = htonl (getpid ());
10472 /* Wait for a reply, return good/bad news */
10478 api_set_ip_flow_hash (vat_main_t * vam)
10480 unformat_input_t *i = vam->input;
10481 vl_api_set_ip_flow_hash_t *mp;
10493 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10495 if (unformat (i, "vrf %d", &vrf_id))
10497 else if (unformat (i, "ipv6"))
10499 else if (unformat (i, "src"))
10501 else if (unformat (i, "dst"))
10503 else if (unformat (i, "sport"))
10505 else if (unformat (i, "dport"))
10507 else if (unformat (i, "proto"))
10509 else if (unformat (i, "reverse"))
10514 clib_warning ("parse error '%U'", format_unformat_error, i);
10519 if (vrf_id_set == 0)
10521 errmsg ("missing vrf id");
10525 M (SET_IP_FLOW_HASH, mp);
10531 mp->reverse = reverse;
10532 mp->vrf_id = ntohl (vrf_id);
10533 mp->is_ipv6 = is_ipv6;
10541 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
10543 unformat_input_t *i = vam->input;
10544 vl_api_sw_interface_ip6_enable_disable_t *mp;
10546 u8 sw_if_index_set = 0;
10550 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10552 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10553 sw_if_index_set = 1;
10554 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10555 sw_if_index_set = 1;
10556 else if (unformat (i, "enable"))
10558 else if (unformat (i, "disable"))
10562 clib_warning ("parse error '%U'", format_unformat_error, i);
10567 if (sw_if_index_set == 0)
10569 errmsg ("missing interface name or sw_if_index");
10573 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
10575 mp->sw_if_index = ntohl (sw_if_index);
10576 mp->enable = enable;
10584 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
10586 unformat_input_t *i = vam->input;
10587 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
10589 u8 sw_if_index_set = 0;
10590 u8 v6_address_set = 0;
10591 ip6_address_t v6address;
10594 /* Parse args required to build the message */
10595 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10597 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10598 sw_if_index_set = 1;
10599 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10600 sw_if_index_set = 1;
10601 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10602 v6_address_set = 1;
10607 if (sw_if_index_set == 0)
10609 errmsg ("missing interface name or sw_if_index");
10612 if (!v6_address_set)
10614 errmsg ("no address set");
10618 /* Construct the API message */
10619 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
10621 mp->sw_if_index = ntohl (sw_if_index);
10622 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10627 /* Wait for a reply, return good/bad news */
10633 api_ip6nd_proxy_add_del (vat_main_t * vam)
10635 unformat_input_t *i = vam->input;
10636 vl_api_ip6nd_proxy_add_del_t *mp;
10637 u32 sw_if_index = ~0;
10638 u8 v6_address_set = 0;
10639 ip6_address_t v6address;
10643 /* Parse args required to build the message */
10644 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10646 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10648 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10650 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10651 v6_address_set = 1;
10652 if (unformat (i, "del"))
10656 clib_warning ("parse error '%U'", format_unformat_error, i);
10661 if (sw_if_index == ~0)
10663 errmsg ("missing interface name or sw_if_index");
10666 if (!v6_address_set)
10668 errmsg ("no address set");
10672 /* Construct the API message */
10673 M (IP6ND_PROXY_ADD_DEL, mp);
10675 mp->is_del = is_del;
10676 mp->sw_if_index = ntohl (sw_if_index);
10677 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10682 /* Wait for a reply, return good/bad news */
10688 api_ip6nd_proxy_dump (vat_main_t * vam)
10690 vl_api_ip6nd_proxy_dump_t *mp;
10691 vl_api_control_ping_t *mp_ping;
10694 M (IP6ND_PROXY_DUMP, mp);
10698 /* Use a control ping for synchronization */
10699 MPING (CONTROL_PING, mp_ping);
10706 static void vl_api_ip6nd_proxy_details_t_handler
10707 (vl_api_ip6nd_proxy_details_t * mp)
10709 vat_main_t *vam = &vat_main;
10711 print (vam->ofp, "host %U sw_if_index %d",
10712 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
10715 static void vl_api_ip6nd_proxy_details_t_handler_json
10716 (vl_api_ip6nd_proxy_details_t * mp)
10718 vat_main_t *vam = &vat_main;
10719 struct in6_addr ip6;
10720 vat_json_node_t *node = NULL;
10722 if (VAT_JSON_ARRAY != vam->json_tree.type)
10724 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10725 vat_json_init_array (&vam->json_tree);
10727 node = vat_json_array_add (&vam->json_tree);
10729 vat_json_init_object (node);
10730 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10732 clib_memcpy (&ip6, mp->address, sizeof (ip6));
10733 vat_json_object_add_ip6 (node, "host", ip6);
10737 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
10739 unformat_input_t *i = vam->input;
10740 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
10742 u8 sw_if_index_set = 0;
10743 u32 address_length = 0;
10744 u8 v6_address_set = 0;
10745 ip6_address_t v6address;
10746 u8 use_default = 0;
10747 u8 no_advertise = 0;
10749 u8 no_autoconfig = 0;
10752 u32 val_lifetime = 0;
10753 u32 pref_lifetime = 0;
10756 /* Parse args required to build the message */
10757 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10759 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10760 sw_if_index_set = 1;
10761 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10762 sw_if_index_set = 1;
10763 else if (unformat (i, "%U/%d",
10764 unformat_ip6_address, &v6address, &address_length))
10765 v6_address_set = 1;
10766 else if (unformat (i, "val_life %d", &val_lifetime))
10768 else if (unformat (i, "pref_life %d", &pref_lifetime))
10770 else if (unformat (i, "def"))
10772 else if (unformat (i, "noadv"))
10774 else if (unformat (i, "offl"))
10776 else if (unformat (i, "noauto"))
10778 else if (unformat (i, "nolink"))
10780 else if (unformat (i, "isno"))
10784 clib_warning ("parse error '%U'", format_unformat_error, i);
10789 if (sw_if_index_set == 0)
10791 errmsg ("missing interface name or sw_if_index");
10794 if (!v6_address_set)
10796 errmsg ("no address set");
10800 /* Construct the API message */
10801 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
10803 mp->sw_if_index = ntohl (sw_if_index);
10804 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10805 mp->address_length = address_length;
10806 mp->use_default = use_default;
10807 mp->no_advertise = no_advertise;
10808 mp->off_link = off_link;
10809 mp->no_autoconfig = no_autoconfig;
10810 mp->no_onlink = no_onlink;
10812 mp->val_lifetime = ntohl (val_lifetime);
10813 mp->pref_lifetime = ntohl (pref_lifetime);
10818 /* Wait for a reply, return good/bad news */
10824 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
10826 unformat_input_t *i = vam->input;
10827 vl_api_sw_interface_ip6nd_ra_config_t *mp;
10829 u8 sw_if_index_set = 0;
10834 u8 send_unicast = 0;
10837 u8 default_router = 0;
10838 u32 max_interval = 0;
10839 u32 min_interval = 0;
10841 u32 initial_count = 0;
10842 u32 initial_interval = 0;
10846 /* Parse args required to build the message */
10847 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10849 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10850 sw_if_index_set = 1;
10851 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10852 sw_if_index_set = 1;
10853 else if (unformat (i, "maxint %d", &max_interval))
10855 else if (unformat (i, "minint %d", &min_interval))
10857 else if (unformat (i, "life %d", &lifetime))
10859 else if (unformat (i, "count %d", &initial_count))
10861 else if (unformat (i, "interval %d", &initial_interval))
10863 else if (unformat (i, "suppress") || unformat (i, "surpress"))
10865 else if (unformat (i, "managed"))
10867 else if (unformat (i, "other"))
10869 else if (unformat (i, "ll"))
10871 else if (unformat (i, "send"))
10873 else if (unformat (i, "cease"))
10875 else if (unformat (i, "isno"))
10877 else if (unformat (i, "def"))
10878 default_router = 1;
10881 clib_warning ("parse error '%U'", format_unformat_error, i);
10886 if (sw_if_index_set == 0)
10888 errmsg ("missing interface name or sw_if_index");
10892 /* Construct the API message */
10893 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
10895 mp->sw_if_index = ntohl (sw_if_index);
10896 mp->max_interval = ntohl (max_interval);
10897 mp->min_interval = ntohl (min_interval);
10898 mp->lifetime = ntohl (lifetime);
10899 mp->initial_count = ntohl (initial_count);
10900 mp->initial_interval = ntohl (initial_interval);
10901 mp->suppress = suppress;
10902 mp->managed = managed;
10904 mp->ll_option = ll_option;
10905 mp->send_unicast = send_unicast;
10908 mp->default_router = default_router;
10913 /* Wait for a reply, return good/bad news */
10919 api_set_arp_neighbor_limit (vat_main_t * vam)
10921 unformat_input_t *i = vam->input;
10922 vl_api_set_arp_neighbor_limit_t *mp;
10928 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10930 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
10932 else if (unformat (i, "ipv6"))
10936 clib_warning ("parse error '%U'", format_unformat_error, i);
10941 if (limit_set == 0)
10943 errmsg ("missing limit value");
10947 M (SET_ARP_NEIGHBOR_LIMIT, mp);
10949 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
10950 mp->is_ipv6 = is_ipv6;
10958 api_l2_patch_add_del (vat_main_t * vam)
10960 unformat_input_t *i = vam->input;
10961 vl_api_l2_patch_add_del_t *mp;
10962 u32 rx_sw_if_index;
10963 u8 rx_sw_if_index_set = 0;
10964 u32 tx_sw_if_index;
10965 u8 tx_sw_if_index_set = 0;
10969 /* Parse args required to build the message */
10970 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10972 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
10973 rx_sw_if_index_set = 1;
10974 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
10975 tx_sw_if_index_set = 1;
10976 else if (unformat (i, "rx"))
10978 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10980 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10982 rx_sw_if_index_set = 1;
10987 else if (unformat (i, "tx"))
10989 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10991 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10993 tx_sw_if_index_set = 1;
10998 else if (unformat (i, "del"))
11004 if (rx_sw_if_index_set == 0)
11006 errmsg ("missing rx interface name or rx_sw_if_index");
11010 if (tx_sw_if_index_set == 0)
11012 errmsg ("missing tx interface name or tx_sw_if_index");
11016 M (L2_PATCH_ADD_DEL, mp);
11018 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
11019 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
11020 mp->is_add = is_add;
11028 u8 localsid_addr[16];
11037 api_sr_localsid_add_del (vat_main_t * vam)
11039 unformat_input_t *i = vam->input;
11040 vl_api_sr_localsid_add_del_t *mp;
11043 ip6_address_t localsid;
11047 u32 fib_table = ~(u32) 0;
11048 ip6_address_t nh_addr6;
11049 ip4_address_t nh_addr4;
11050 memset (&nh_addr6, 0, sizeof (ip6_address_t));
11051 memset (&nh_addr4, 0, sizeof (ip4_address_t));
11053 bool nexthop_set = 0;
11057 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11059 if (unformat (i, "del"))
11061 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
11062 else if (unformat (i, "next-hop %U", unformat_ip4_address, &nh_addr4))
11064 else if (unformat (i, "next-hop %U", unformat_ip6_address, &nh_addr6))
11066 else if (unformat (i, "behavior %u", &behavior));
11067 else if (unformat (i, "sw_if_index %u", &sw_if_index));
11068 else if (unformat (i, "fib-table %u", &fib_table));
11069 else if (unformat (i, "end.psp %u", &behavior));
11074 M (SR_LOCALSID_ADD_DEL, mp);
11076 clib_memcpy (mp->localsid.addr, &localsid, sizeof (mp->localsid));
11079 clib_memcpy (mp->nh_addr6, &nh_addr6, sizeof (mp->nh_addr6));
11080 clib_memcpy (mp->nh_addr4, &nh_addr4, sizeof (mp->nh_addr4));
11082 mp->behavior = behavior;
11083 mp->sw_if_index = ntohl (sw_if_index);
11084 mp->fib_table = ntohl (fib_table);
11085 mp->end_psp = end_psp;
11086 mp->is_del = is_del;
11094 api_ioam_enable (vat_main_t * vam)
11096 unformat_input_t *input = vam->input;
11097 vl_api_ioam_enable_t *mp;
11099 int has_trace_option = 0;
11100 int has_pot_option = 0;
11101 int has_seqno_option = 0;
11102 int has_analyse_option = 0;
11105 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11107 if (unformat (input, "trace"))
11108 has_trace_option = 1;
11109 else if (unformat (input, "pot"))
11110 has_pot_option = 1;
11111 else if (unformat (input, "seqno"))
11112 has_seqno_option = 1;
11113 else if (unformat (input, "analyse"))
11114 has_analyse_option = 1;
11118 M (IOAM_ENABLE, mp);
11119 mp->id = htons (id);
11120 mp->seqno = has_seqno_option;
11121 mp->analyse = has_analyse_option;
11122 mp->pot_enable = has_pot_option;
11123 mp->trace_enable = has_trace_option;
11132 api_ioam_disable (vat_main_t * vam)
11134 vl_api_ioam_disable_t *mp;
11137 M (IOAM_DISABLE, mp);
11143 #define foreach_tcp_proto_field \
11147 #define foreach_udp_proto_field \
11151 #define foreach_ip4_proto_field \
11163 u16 src_port, dst_port;
11166 #if VPP_API_TEST_BUILTIN == 0
11168 unformat_tcp_mask (unformat_input_t * input, va_list * args)
11170 u8 **maskp = va_arg (*args, u8 **);
11172 u8 found_something = 0;
11175 #define _(a) u8 a=0;
11176 foreach_tcp_proto_field;
11179 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11182 #define _(a) else if (unformat (input, #a)) a=1;
11183 foreach_tcp_proto_field
11189 #define _(a) found_something += a;
11190 foreach_tcp_proto_field;
11193 if (found_something == 0)
11196 vec_validate (mask, sizeof (*tcp) - 1);
11198 tcp = (tcp_header_t *) mask;
11200 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
11201 foreach_tcp_proto_field;
11209 unformat_udp_mask (unformat_input_t * input, va_list * args)
11211 u8 **maskp = va_arg (*args, u8 **);
11213 u8 found_something = 0;
11216 #define _(a) u8 a=0;
11217 foreach_udp_proto_field;
11220 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11223 #define _(a) else if (unformat (input, #a)) a=1;
11224 foreach_udp_proto_field
11230 #define _(a) found_something += a;
11231 foreach_udp_proto_field;
11234 if (found_something == 0)
11237 vec_validate (mask, sizeof (*udp) - 1);
11239 udp = (udp_header_t *) mask;
11241 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
11242 foreach_udp_proto_field;
11250 unformat_l4_mask (unformat_input_t * input, va_list * args)
11252 u8 **maskp = va_arg (*args, u8 **);
11253 u16 src_port = 0, dst_port = 0;
11254 tcpudp_header_t *tcpudp;
11256 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11258 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
11260 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
11262 else if (unformat (input, "src_port"))
11264 else if (unformat (input, "dst_port"))
11270 if (!src_port && !dst_port)
11274 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
11276 tcpudp = (tcpudp_header_t *) mask;
11277 tcpudp->src_port = src_port;
11278 tcpudp->dst_port = dst_port;
11286 unformat_ip4_mask (unformat_input_t * input, va_list * args)
11288 u8 **maskp = va_arg (*args, u8 **);
11290 u8 found_something = 0;
11293 #define _(a) u8 a=0;
11294 foreach_ip4_proto_field;
11300 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11302 if (unformat (input, "version"))
11304 else if (unformat (input, "hdr_length"))
11306 else if (unformat (input, "src"))
11308 else if (unformat (input, "dst"))
11310 else if (unformat (input, "proto"))
11313 #define _(a) else if (unformat (input, #a)) a=1;
11314 foreach_ip4_proto_field
11320 #define _(a) found_something += a;
11321 foreach_ip4_proto_field;
11324 if (found_something == 0)
11327 vec_validate (mask, sizeof (*ip) - 1);
11329 ip = (ip4_header_t *) mask;
11331 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
11332 foreach_ip4_proto_field;
11335 ip->ip_version_and_header_length = 0;
11338 ip->ip_version_and_header_length |= 0xF0;
11341 ip->ip_version_and_header_length |= 0x0F;
11347 #define foreach_ip6_proto_field \
11350 _(payload_length) \
11355 unformat_ip6_mask (unformat_input_t * input, va_list * args)
11357 u8 **maskp = va_arg (*args, u8 **);
11359 u8 found_something = 0;
11361 u32 ip_version_traffic_class_and_flow_label;
11363 #define _(a) u8 a=0;
11364 foreach_ip6_proto_field;
11367 u8 traffic_class = 0;
11370 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11372 if (unformat (input, "version"))
11374 else if (unformat (input, "traffic-class"))
11376 else if (unformat (input, "flow-label"))
11378 else if (unformat (input, "src"))
11380 else if (unformat (input, "dst"))
11382 else if (unformat (input, "proto"))
11385 #define _(a) else if (unformat (input, #a)) a=1;
11386 foreach_ip6_proto_field
11392 #define _(a) found_something += a;
11393 foreach_ip6_proto_field;
11396 if (found_something == 0)
11399 vec_validate (mask, sizeof (*ip) - 1);
11401 ip = (ip6_header_t *) mask;
11403 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
11404 foreach_ip6_proto_field;
11407 ip_version_traffic_class_and_flow_label = 0;
11410 ip_version_traffic_class_and_flow_label |= 0xF0000000;
11413 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
11416 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
11418 ip->ip_version_traffic_class_and_flow_label =
11419 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11426 unformat_l3_mask (unformat_input_t * input, va_list * args)
11428 u8 **maskp = va_arg (*args, u8 **);
11430 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11432 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
11434 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
11443 unformat_l2_mask (unformat_input_t * input, va_list * args)
11445 u8 **maskp = va_arg (*args, u8 **);
11452 u8 ignore_tag1 = 0;
11453 u8 ignore_tag2 = 0;
11460 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11462 if (unformat (input, "src"))
11464 else if (unformat (input, "dst"))
11466 else if (unformat (input, "proto"))
11468 else if (unformat (input, "tag1"))
11470 else if (unformat (input, "tag2"))
11472 else if (unformat (input, "ignore-tag1"))
11474 else if (unformat (input, "ignore-tag2"))
11476 else if (unformat (input, "cos1"))
11478 else if (unformat (input, "cos2"))
11480 else if (unformat (input, "dot1q"))
11482 else if (unformat (input, "dot1ad"))
11487 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
11488 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11491 if (tag1 || ignore_tag1 || cos1 || dot1q)
11493 if (tag2 || ignore_tag2 || cos2 || dot1ad)
11496 vec_validate (mask, len - 1);
11499 memset (mask, 0xff, 6);
11502 memset (mask + 6, 0xff, 6);
11504 if (tag2 || dot1ad)
11506 /* inner vlan tag */
11515 mask[21] = mask[20] = 0xff;
11536 mask[16] = mask[17] = 0xff;
11546 mask[12] = mask[13] = 0xff;
11553 unformat_classify_mask (unformat_input_t * input, va_list * args)
11555 u8 **maskp = va_arg (*args, u8 **);
11556 u32 *skipp = va_arg (*args, u32 *);
11557 u32 *matchp = va_arg (*args, u32 *);
11565 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11567 if (unformat (input, "hex %U", unformat_hex_string, &mask))
11569 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
11571 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
11573 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
11587 if (mask || l2 || l3 || l4)
11589 if (l2 || l3 || l4)
11591 /* "With a free Ethernet header in every package" */
11593 vec_validate (l2, 13);
11597 vec_append (mask, l3);
11602 vec_append (mask, l4);
11607 /* Scan forward looking for the first significant mask octet */
11608 for (i = 0; i < vec_len (mask); i++)
11612 /* compute (skip, match) params */
11613 *skipp = i / sizeof (u32x4);
11614 vec_delete (mask, *skipp * sizeof (u32x4), 0);
11616 /* Pad mask to an even multiple of the vector size */
11617 while (vec_len (mask) % sizeof (u32x4))
11618 vec_add1 (mask, 0);
11620 match = vec_len (mask) / sizeof (u32x4);
11622 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
11624 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
11625 if (*tmp || *(tmp + 1))
11630 clib_warning ("BUG: match 0");
11632 _vec_len (mask) = match * sizeof (u32x4);
11642 #endif /* VPP_API_TEST_BUILTIN */
11644 #define foreach_l2_next \
11646 _(ethernet, ETHERNET_INPUT) \
11647 _(ip4, IP4_INPUT) \
11651 unformat_l2_next_index (unformat_input_t * input, va_list * args)
11653 u32 *miss_next_indexp = va_arg (*args, u32 *);
11654 u32 next_index = 0;
11658 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
11662 if (unformat (input, "%d", &tmp))
11671 *miss_next_indexp = next_index;
11675 #define foreach_ip_next \
11678 _(rewrite, REWRITE)
11681 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
11683 u32 *miss_next_indexp = va_arg (*args, u32 *);
11684 u32 next_index = 0;
11688 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
11692 if (unformat (input, "%d", &tmp))
11701 *miss_next_indexp = next_index;
11705 #define foreach_acl_next \
11709 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
11711 u32 *miss_next_indexp = va_arg (*args, u32 *);
11712 u32 next_index = 0;
11716 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
11720 if (unformat (input, "permit"))
11725 else if (unformat (input, "%d", &tmp))
11734 *miss_next_indexp = next_index;
11739 unformat_policer_precolor (unformat_input_t * input, va_list * args)
11741 u32 *r = va_arg (*args, u32 *);
11743 if (unformat (input, "conform-color"))
11744 *r = POLICE_CONFORM;
11745 else if (unformat (input, "exceed-color"))
11746 *r = POLICE_EXCEED;
11754 api_classify_add_del_table (vat_main_t * vam)
11756 unformat_input_t *i = vam->input;
11757 vl_api_classify_add_del_table_t *mp;
11764 u32 table_index = ~0;
11765 u32 next_table_index = ~0;
11766 u32 miss_next_index = ~0;
11767 u32 memory_size = 32 << 20;
11769 u32 current_data_flag = 0;
11770 int current_data_offset = 0;
11773 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11775 if (unformat (i, "del"))
11777 else if (unformat (i, "del-chain"))
11782 else if (unformat (i, "buckets %d", &nbuckets))
11784 else if (unformat (i, "memory_size %d", &memory_size))
11786 else if (unformat (i, "skip %d", &skip))
11788 else if (unformat (i, "match %d", &match))
11790 else if (unformat (i, "table %d", &table_index))
11792 else if (unformat (i, "mask %U", unformat_classify_mask,
11793 &mask, &skip, &match))
11795 else if (unformat (i, "next-table %d", &next_table_index))
11797 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
11800 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
11803 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
11806 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
11808 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
11814 if (is_add && mask == 0)
11816 errmsg ("Mask required");
11820 if (is_add && skip == ~0)
11822 errmsg ("skip count required");
11826 if (is_add && match == ~0)
11828 errmsg ("match count required");
11832 if (!is_add && table_index == ~0)
11834 errmsg ("table index required for delete");
11838 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
11840 mp->is_add = is_add;
11841 mp->del_chain = del_chain;
11842 mp->table_index = ntohl (table_index);
11843 mp->nbuckets = ntohl (nbuckets);
11844 mp->memory_size = ntohl (memory_size);
11845 mp->skip_n_vectors = ntohl (skip);
11846 mp->match_n_vectors = ntohl (match);
11847 mp->next_table_index = ntohl (next_table_index);
11848 mp->miss_next_index = ntohl (miss_next_index);
11849 mp->current_data_flag = ntohl (current_data_flag);
11850 mp->current_data_offset = ntohl (current_data_offset);
11851 mp->mask_len = ntohl (vec_len (mask));
11852 clib_memcpy (mp->mask, mask, vec_len (mask));
11861 #if VPP_API_TEST_BUILTIN == 0
11863 unformat_l4_match (unformat_input_t * input, va_list * args)
11865 u8 **matchp = va_arg (*args, u8 **);
11867 u8 *proto_header = 0;
11873 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11875 if (unformat (input, "src_port %d", &src_port))
11877 else if (unformat (input, "dst_port %d", &dst_port))
11883 h.src_port = clib_host_to_net_u16 (src_port);
11884 h.dst_port = clib_host_to_net_u16 (dst_port);
11885 vec_validate (proto_header, sizeof (h) - 1);
11886 memcpy (proto_header, &h, sizeof (h));
11888 *matchp = proto_header;
11894 unformat_ip4_match (unformat_input_t * input, va_list * args)
11896 u8 **matchp = va_arg (*args, u8 **);
11901 int hdr_length = 0;
11902 u32 hdr_length_val;
11903 int src = 0, dst = 0;
11904 ip4_address_t src_val, dst_val;
11911 int fragment_id = 0;
11912 u32 fragment_id_val;
11918 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11920 if (unformat (input, "version %d", &version_val))
11922 else if (unformat (input, "hdr_length %d", &hdr_length_val))
11924 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
11926 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
11928 else if (unformat (input, "proto %d", &proto_val))
11930 else if (unformat (input, "tos %d", &tos_val))
11932 else if (unformat (input, "length %d", &length_val))
11934 else if (unformat (input, "fragment_id %d", &fragment_id_val))
11936 else if (unformat (input, "ttl %d", &ttl_val))
11938 else if (unformat (input, "checksum %d", &checksum_val))
11944 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
11945 + ttl + checksum == 0)
11949 * Aligned because we use the real comparison functions
11951 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11953 ip = (ip4_header_t *) match;
11955 /* These are realistically matched in practice */
11957 ip->src_address.as_u32 = src_val.as_u32;
11960 ip->dst_address.as_u32 = dst_val.as_u32;
11963 ip->protocol = proto_val;
11966 /* These are not, but they're included for completeness */
11968 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
11971 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
11977 ip->length = clib_host_to_net_u16 (length_val);
11983 ip->checksum = clib_host_to_net_u16 (checksum_val);
11990 unformat_ip6_match (unformat_input_t * input, va_list * args)
11992 u8 **matchp = va_arg (*args, u8 **);
11997 u8 traffic_class = 0;
11998 u32 traffic_class_val = 0;
12001 int src = 0, dst = 0;
12002 ip6_address_t src_val, dst_val;
12005 int payload_length = 0;
12006 u32 payload_length_val;
12009 u32 ip_version_traffic_class_and_flow_label;
12011 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12013 if (unformat (input, "version %d", &version_val))
12015 else if (unformat (input, "traffic_class %d", &traffic_class_val))
12017 else if (unformat (input, "flow_label %d", &flow_label_val))
12019 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
12021 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
12023 else if (unformat (input, "proto %d", &proto_val))
12025 else if (unformat (input, "payload_length %d", &payload_length_val))
12026 payload_length = 1;
12027 else if (unformat (input, "hop_limit %d", &hop_limit_val))
12033 if (version + traffic_class + flow_label + src + dst + proto +
12034 payload_length + hop_limit == 0)
12038 * Aligned because we use the real comparison functions
12040 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
12042 ip = (ip6_header_t *) match;
12045 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
12048 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
12051 ip->protocol = proto_val;
12053 ip_version_traffic_class_and_flow_label = 0;
12056 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
12059 ip_version_traffic_class_and_flow_label |=
12060 (traffic_class_val & 0xFF) << 20;
12063 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
12065 ip->ip_version_traffic_class_and_flow_label =
12066 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
12068 if (payload_length)
12069 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
12072 ip->hop_limit = hop_limit_val;
12079 unformat_l3_match (unformat_input_t * input, va_list * args)
12081 u8 **matchp = va_arg (*args, u8 **);
12083 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12085 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
12087 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
12096 unformat_vlan_tag (unformat_input_t * input, va_list * args)
12098 u8 *tagp = va_arg (*args, u8 *);
12101 if (unformat (input, "%d", &tag))
12103 tagp[0] = (tag >> 8) & 0x0F;
12104 tagp[1] = tag & 0xFF;
12112 unformat_l2_match (unformat_input_t * input, va_list * args)
12114 u8 **matchp = va_arg (*args, u8 **);
12127 u8 ignore_tag1 = 0;
12128 u8 ignore_tag2 = 0;
12134 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12136 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
12139 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
12141 else if (unformat (input, "proto %U",
12142 unformat_ethernet_type_host_byte_order, &proto_val))
12144 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
12146 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
12148 else if (unformat (input, "ignore-tag1"))
12150 else if (unformat (input, "ignore-tag2"))
12152 else if (unformat (input, "cos1 %d", &cos1_val))
12154 else if (unformat (input, "cos2 %d", &cos2_val))
12159 if ((src + dst + proto + tag1 + tag2 +
12160 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
12163 if (tag1 || ignore_tag1 || cos1)
12165 if (tag2 || ignore_tag2 || cos2)
12168 vec_validate_aligned (match, len - 1, sizeof (u32x4));
12171 clib_memcpy (match, dst_val, 6);
12174 clib_memcpy (match + 6, src_val, 6);
12178 /* inner vlan tag */
12179 match[19] = tag2_val[1];
12180 match[18] = tag2_val[0];
12182 match[18] |= (cos2_val & 0x7) << 5;
12185 match[21] = proto_val & 0xff;
12186 match[20] = proto_val >> 8;
12190 match[15] = tag1_val[1];
12191 match[14] = tag1_val[0];
12194 match[14] |= (cos1_val & 0x7) << 5;
12200 match[15] = tag1_val[1];
12201 match[14] = tag1_val[0];
12204 match[17] = proto_val & 0xff;
12205 match[16] = proto_val >> 8;
12208 match[14] |= (cos1_val & 0x7) << 5;
12214 match[18] |= (cos2_val & 0x7) << 5;
12216 match[14] |= (cos1_val & 0x7) << 5;
12219 match[13] = proto_val & 0xff;
12220 match[12] = proto_val >> 8;
12228 unformat_qos_source (unformat_input_t * input, va_list * args)
12230 int *qs = va_arg (*args, int *);
12232 if (unformat (input, "ip"))
12233 *qs = QOS_SOURCE_IP;
12234 else if (unformat (input, "mpls"))
12235 *qs = QOS_SOURCE_MPLS;
12236 else if (unformat (input, "ext"))
12237 *qs = QOS_SOURCE_EXT;
12238 else if (unformat (input, "vlan"))
12239 *qs = QOS_SOURCE_VLAN;
12248 api_unformat_classify_match (unformat_input_t * input, va_list * args)
12250 u8 **matchp = va_arg (*args, u8 **);
12251 u32 skip_n_vectors = va_arg (*args, u32);
12252 u32 match_n_vectors = va_arg (*args, u32);
12259 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12261 if (unformat (input, "hex %U", unformat_hex_string, &match))
12263 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
12265 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
12267 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
12281 if (match || l2 || l3 || l4)
12283 if (l2 || l3 || l4)
12285 /* "Win a free Ethernet header in every packet" */
12287 vec_validate_aligned (l2, 13, sizeof (u32x4));
12291 vec_append_aligned (match, l3, sizeof (u32x4));
12296 vec_append_aligned (match, l4, sizeof (u32x4));
12301 /* Make sure the vector is big enough even if key is all 0's */
12302 vec_validate_aligned
12303 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
12306 /* Set size, include skipped vectors */
12307 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
12318 api_classify_add_del_session (vat_main_t * vam)
12320 unformat_input_t *i = vam->input;
12321 vl_api_classify_add_del_session_t *mp;
12323 u32 table_index = ~0;
12324 u32 hit_next_index = ~0;
12325 u32 opaque_index = ~0;
12328 u32 skip_n_vectors = 0;
12329 u32 match_n_vectors = 0;
12335 * Warning: you have to supply skip_n and match_n
12336 * because the API client cant simply look at the classify
12340 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12342 if (unformat (i, "del"))
12344 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
12347 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
12350 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
12353 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
12355 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
12357 else if (unformat (i, "opaque-index %d", &opaque_index))
12359 else if (unformat (i, "skip_n %d", &skip_n_vectors))
12361 else if (unformat (i, "match_n %d", &match_n_vectors))
12363 else if (unformat (i, "match %U", api_unformat_classify_match,
12364 &match, skip_n_vectors, match_n_vectors))
12366 else if (unformat (i, "advance %d", &advance))
12368 else if (unformat (i, "table-index %d", &table_index))
12370 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
12372 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
12374 else if (unformat (i, "action %d", &action))
12376 else if (unformat (i, "metadata %d", &metadata))
12382 if (table_index == ~0)
12384 errmsg ("Table index required");
12388 if (is_add && match == 0)
12390 errmsg ("Match value required");
12394 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
12396 mp->is_add = is_add;
12397 mp->table_index = ntohl (table_index);
12398 mp->hit_next_index = ntohl (hit_next_index);
12399 mp->opaque_index = ntohl (opaque_index);
12400 mp->advance = ntohl (advance);
12401 mp->action = action;
12402 mp->metadata = ntohl (metadata);
12403 mp->match_len = ntohl (vec_len (match));
12404 clib_memcpy (mp->match, match, vec_len (match));
12413 api_classify_set_interface_ip_table (vat_main_t * vam)
12415 unformat_input_t *i = vam->input;
12416 vl_api_classify_set_interface_ip_table_t *mp;
12418 int sw_if_index_set;
12419 u32 table_index = ~0;
12423 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12425 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12426 sw_if_index_set = 1;
12427 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12428 sw_if_index_set = 1;
12429 else if (unformat (i, "table %d", &table_index))
12433 clib_warning ("parse error '%U'", format_unformat_error, i);
12438 if (sw_if_index_set == 0)
12440 errmsg ("missing interface name or sw_if_index");
12445 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
12447 mp->sw_if_index = ntohl (sw_if_index);
12448 mp->table_index = ntohl (table_index);
12449 mp->is_ipv6 = is_ipv6;
12457 api_classify_set_interface_l2_tables (vat_main_t * vam)
12459 unformat_input_t *i = vam->input;
12460 vl_api_classify_set_interface_l2_tables_t *mp;
12462 int sw_if_index_set;
12463 u32 ip4_table_index = ~0;
12464 u32 ip6_table_index = ~0;
12465 u32 other_table_index = ~0;
12469 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12471 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12472 sw_if_index_set = 1;
12473 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12474 sw_if_index_set = 1;
12475 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12477 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12479 else if (unformat (i, "other-table %d", &other_table_index))
12481 else if (unformat (i, "is-input %d", &is_input))
12485 clib_warning ("parse error '%U'", format_unformat_error, i);
12490 if (sw_if_index_set == 0)
12492 errmsg ("missing interface name or sw_if_index");
12497 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
12499 mp->sw_if_index = ntohl (sw_if_index);
12500 mp->ip4_table_index = ntohl (ip4_table_index);
12501 mp->ip6_table_index = ntohl (ip6_table_index);
12502 mp->other_table_index = ntohl (other_table_index);
12503 mp->is_input = (u8) is_input;
12511 api_set_ipfix_exporter (vat_main_t * vam)
12513 unformat_input_t *i = vam->input;
12514 vl_api_set_ipfix_exporter_t *mp;
12515 ip4_address_t collector_address;
12516 u8 collector_address_set = 0;
12517 u32 collector_port = ~0;
12518 ip4_address_t src_address;
12519 u8 src_address_set = 0;
12522 u32 template_interval = ~0;
12523 u8 udp_checksum = 0;
12526 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12528 if (unformat (i, "collector_address %U", unformat_ip4_address,
12529 &collector_address))
12530 collector_address_set = 1;
12531 else if (unformat (i, "collector_port %d", &collector_port))
12533 else if (unformat (i, "src_address %U", unformat_ip4_address,
12535 src_address_set = 1;
12536 else if (unformat (i, "vrf_id %d", &vrf_id))
12538 else if (unformat (i, "path_mtu %d", &path_mtu))
12540 else if (unformat (i, "template_interval %d", &template_interval))
12542 else if (unformat (i, "udp_checksum"))
12548 if (collector_address_set == 0)
12550 errmsg ("collector_address required");
12554 if (src_address_set == 0)
12556 errmsg ("src_address required");
12560 M (SET_IPFIX_EXPORTER, mp);
12562 memcpy (mp->collector_address, collector_address.data,
12563 sizeof (collector_address.data));
12564 mp->collector_port = htons ((u16) collector_port);
12565 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
12566 mp->vrf_id = htonl (vrf_id);
12567 mp->path_mtu = htonl (path_mtu);
12568 mp->template_interval = htonl (template_interval);
12569 mp->udp_checksum = udp_checksum;
12577 api_set_ipfix_classify_stream (vat_main_t * vam)
12579 unformat_input_t *i = vam->input;
12580 vl_api_set_ipfix_classify_stream_t *mp;
12582 u32 src_port = UDP_DST_PORT_ipfix;
12585 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12587 if (unformat (i, "domain %d", &domain_id))
12589 else if (unformat (i, "src_port %d", &src_port))
12593 errmsg ("unknown input `%U'", format_unformat_error, i);
12598 M (SET_IPFIX_CLASSIFY_STREAM, mp);
12600 mp->domain_id = htonl (domain_id);
12601 mp->src_port = htons ((u16) src_port);
12609 api_ipfix_classify_table_add_del (vat_main_t * vam)
12611 unformat_input_t *i = vam->input;
12612 vl_api_ipfix_classify_table_add_del_t *mp;
12614 u32 classify_table_index = ~0;
12616 u8 transport_protocol = 255;
12619 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12621 if (unformat (i, "add"))
12623 else if (unformat (i, "del"))
12625 else if (unformat (i, "table %d", &classify_table_index))
12627 else if (unformat (i, "ip4"))
12629 else if (unformat (i, "ip6"))
12631 else if (unformat (i, "tcp"))
12632 transport_protocol = 6;
12633 else if (unformat (i, "udp"))
12634 transport_protocol = 17;
12637 errmsg ("unknown input `%U'", format_unformat_error, i);
12644 errmsg ("expecting: add|del");
12647 if (classify_table_index == ~0)
12649 errmsg ("classifier table not specified");
12652 if (ip_version == 0)
12654 errmsg ("IP version not specified");
12658 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
12660 mp->is_add = is_add;
12661 mp->table_id = htonl (classify_table_index);
12662 mp->ip_version = ip_version;
12663 mp->transport_protocol = transport_protocol;
12671 api_get_node_index (vat_main_t * vam)
12673 unformat_input_t *i = vam->input;
12674 vl_api_get_node_index_t *mp;
12678 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12680 if (unformat (i, "node %s", &name))
12687 errmsg ("node name required");
12690 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12692 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12696 M (GET_NODE_INDEX, mp);
12697 clib_memcpy (mp->node_name, name, vec_len (name));
12706 api_get_next_index (vat_main_t * vam)
12708 unformat_input_t *i = vam->input;
12709 vl_api_get_next_index_t *mp;
12710 u8 *node_name = 0, *next_node_name = 0;
12713 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12715 if (unformat (i, "node-name %s", &node_name))
12717 else if (unformat (i, "next-node-name %s", &next_node_name))
12721 if (node_name == 0)
12723 errmsg ("node name required");
12726 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
12728 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12732 if (next_node_name == 0)
12734 errmsg ("next node name required");
12737 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
12739 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
12743 M (GET_NEXT_INDEX, mp);
12744 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
12745 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
12746 vec_free (node_name);
12747 vec_free (next_node_name);
12755 api_add_node_next (vat_main_t * vam)
12757 unformat_input_t *i = vam->input;
12758 vl_api_add_node_next_t *mp;
12763 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12765 if (unformat (i, "node %s", &name))
12767 else if (unformat (i, "next %s", &next))
12774 errmsg ("node name required");
12777 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12779 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12784 errmsg ("next node required");
12787 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
12789 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
12793 M (ADD_NODE_NEXT, mp);
12794 clib_memcpy (mp->node_name, name, vec_len (name));
12795 clib_memcpy (mp->next_name, next, vec_len (next));
12805 api_l2tpv3_create_tunnel (vat_main_t * vam)
12807 unformat_input_t *i = vam->input;
12808 ip6_address_t client_address, our_address;
12809 int client_address_set = 0;
12810 int our_address_set = 0;
12811 u32 local_session_id = 0;
12812 u32 remote_session_id = 0;
12813 u64 local_cookie = 0;
12814 u64 remote_cookie = 0;
12815 u8 l2_sublayer_present = 0;
12816 vl_api_l2tpv3_create_tunnel_t *mp;
12819 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12821 if (unformat (i, "client_address %U", unformat_ip6_address,
12823 client_address_set = 1;
12824 else if (unformat (i, "our_address %U", unformat_ip6_address,
12826 our_address_set = 1;
12827 else if (unformat (i, "local_session_id %d", &local_session_id))
12829 else if (unformat (i, "remote_session_id %d", &remote_session_id))
12831 else if (unformat (i, "local_cookie %lld", &local_cookie))
12833 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
12835 else if (unformat (i, "l2-sublayer-present"))
12836 l2_sublayer_present = 1;
12841 if (client_address_set == 0)
12843 errmsg ("client_address required");
12847 if (our_address_set == 0)
12849 errmsg ("our_address required");
12853 M (L2TPV3_CREATE_TUNNEL, mp);
12855 clib_memcpy (mp->client_address, client_address.as_u8,
12856 sizeof (mp->client_address));
12858 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
12860 mp->local_session_id = ntohl (local_session_id);
12861 mp->remote_session_id = ntohl (remote_session_id);
12862 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
12863 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
12864 mp->l2_sublayer_present = l2_sublayer_present;
12873 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
12875 unformat_input_t *i = vam->input;
12877 u8 sw_if_index_set = 0;
12878 u64 new_local_cookie = 0;
12879 u64 new_remote_cookie = 0;
12880 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
12883 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12885 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12886 sw_if_index_set = 1;
12887 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12888 sw_if_index_set = 1;
12889 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
12891 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
12897 if (sw_if_index_set == 0)
12899 errmsg ("missing interface name or sw_if_index");
12903 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
12905 mp->sw_if_index = ntohl (sw_if_index);
12906 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
12907 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
12915 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
12917 unformat_input_t *i = vam->input;
12918 vl_api_l2tpv3_interface_enable_disable_t *mp;
12920 u8 sw_if_index_set = 0;
12921 u8 enable_disable = 1;
12924 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12926 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12927 sw_if_index_set = 1;
12928 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12929 sw_if_index_set = 1;
12930 else if (unformat (i, "enable"))
12931 enable_disable = 1;
12932 else if (unformat (i, "disable"))
12933 enable_disable = 0;
12938 if (sw_if_index_set == 0)
12940 errmsg ("missing interface name or sw_if_index");
12944 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
12946 mp->sw_if_index = ntohl (sw_if_index);
12947 mp->enable_disable = enable_disable;
12955 api_l2tpv3_set_lookup_key (vat_main_t * vam)
12957 unformat_input_t *i = vam->input;
12958 vl_api_l2tpv3_set_lookup_key_t *mp;
12962 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12964 if (unformat (i, "lookup_v6_src"))
12965 key = L2T_LOOKUP_SRC_ADDRESS;
12966 else if (unformat (i, "lookup_v6_dst"))
12967 key = L2T_LOOKUP_DST_ADDRESS;
12968 else if (unformat (i, "lookup_session_id"))
12969 key = L2T_LOOKUP_SESSION_ID;
12974 if (key == (u8) ~ 0)
12976 errmsg ("l2tp session lookup key unset");
12980 M (L2TPV3_SET_LOOKUP_KEY, mp);
12989 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
12990 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12992 vat_main_t *vam = &vat_main;
12994 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
12995 format_ip6_address, mp->our_address,
12996 format_ip6_address, mp->client_address,
12997 clib_net_to_host_u32 (mp->sw_if_index));
13000 " local cookies %016llx %016llx remote cookie %016llx",
13001 clib_net_to_host_u64 (mp->local_cookie[0]),
13002 clib_net_to_host_u64 (mp->local_cookie[1]),
13003 clib_net_to_host_u64 (mp->remote_cookie));
13005 print (vam->ofp, " local session-id %d remote session-id %d",
13006 clib_net_to_host_u32 (mp->local_session_id),
13007 clib_net_to_host_u32 (mp->remote_session_id));
13009 print (vam->ofp, " l2 specific sublayer %s\n",
13010 mp->l2_sublayer_present ? "preset" : "absent");
13014 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
13015 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
13017 vat_main_t *vam = &vat_main;
13018 vat_json_node_t *node = NULL;
13019 struct in6_addr addr;
13021 if (VAT_JSON_ARRAY != vam->json_tree.type)
13023 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13024 vat_json_init_array (&vam->json_tree);
13026 node = vat_json_array_add (&vam->json_tree);
13028 vat_json_init_object (node);
13030 clib_memcpy (&addr, mp->our_address, sizeof (addr));
13031 vat_json_object_add_ip6 (node, "our_address", addr);
13032 clib_memcpy (&addr, mp->client_address, sizeof (addr));
13033 vat_json_object_add_ip6 (node, "client_address", addr);
13035 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
13036 vat_json_init_array (lc);
13037 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
13038 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
13039 vat_json_object_add_uint (node, "remote_cookie",
13040 clib_net_to_host_u64 (mp->remote_cookie));
13042 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
13043 vat_json_object_add_uint (node, "local_session_id",
13044 clib_net_to_host_u32 (mp->local_session_id));
13045 vat_json_object_add_uint (node, "remote_session_id",
13046 clib_net_to_host_u32 (mp->remote_session_id));
13047 vat_json_object_add_string_copy (node, "l2_sublayer",
13048 mp->l2_sublayer_present ? (u8 *) "present"
13049 : (u8 *) "absent");
13053 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
13055 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
13056 vl_api_control_ping_t *mp_ping;
13059 /* Get list of l2tpv3-tunnel interfaces */
13060 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
13063 /* Use a control ping for synchronization */
13064 MPING (CONTROL_PING, mp_ping);
13072 static void vl_api_sw_interface_tap_details_t_handler
13073 (vl_api_sw_interface_tap_details_t * mp)
13075 vat_main_t *vam = &vat_main;
13077 print (vam->ofp, "%-16s %d",
13078 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
13081 static void vl_api_sw_interface_tap_details_t_handler_json
13082 (vl_api_sw_interface_tap_details_t * mp)
13084 vat_main_t *vam = &vat_main;
13085 vat_json_node_t *node = NULL;
13087 if (VAT_JSON_ARRAY != vam->json_tree.type)
13089 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13090 vat_json_init_array (&vam->json_tree);
13092 node = vat_json_array_add (&vam->json_tree);
13094 vat_json_init_object (node);
13095 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13096 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
13100 api_sw_interface_tap_dump (vat_main_t * vam)
13102 vl_api_sw_interface_tap_dump_t *mp;
13103 vl_api_control_ping_t *mp_ping;
13106 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
13107 /* Get list of tap interfaces */
13108 M (SW_INTERFACE_TAP_DUMP, mp);
13111 /* Use a control ping for synchronization */
13112 MPING (CONTROL_PING, mp_ping);
13119 static void vl_api_sw_interface_tap_v2_details_t_handler
13120 (vl_api_sw_interface_tap_v2_details_t * mp)
13122 vat_main_t *vam = &vat_main;
13124 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
13125 mp->host_ip4_prefix_len);
13126 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
13127 mp->host_ip6_prefix_len);
13130 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s",
13131 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
13132 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
13133 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
13134 mp->host_bridge, ip4, ip6);
13140 static void vl_api_sw_interface_tap_v2_details_t_handler_json
13141 (vl_api_sw_interface_tap_v2_details_t * mp)
13143 vat_main_t *vam = &vat_main;
13144 vat_json_node_t *node = NULL;
13146 if (VAT_JSON_ARRAY != vam->json_tree.type)
13148 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13149 vat_json_init_array (&vam->json_tree);
13151 node = vat_json_array_add (&vam->json_tree);
13153 vat_json_init_object (node);
13154 vat_json_object_add_uint (node, "id", ntohl (mp->id));
13155 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13156 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
13157 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
13158 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
13159 vat_json_object_add_string_copy (node, "host_mac_addr",
13160 format (0, "%U", format_ethernet_address,
13161 &mp->host_mac_addr));
13162 vat_json_object_add_string_copy (node, "host_namespace",
13163 mp->host_namespace);
13164 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
13165 vat_json_object_add_string_copy (node, "host_ip4_addr",
13166 format (0, "%U/%d", format_ip4_address,
13168 mp->host_ip4_prefix_len));
13169 vat_json_object_add_string_copy (node, "host_ip6_addr",
13170 format (0, "%U/%d", format_ip6_address,
13172 mp->host_ip6_prefix_len));
13177 api_sw_interface_tap_v2_dump (vat_main_t * vam)
13179 vl_api_sw_interface_tap_v2_dump_t *mp;
13180 vl_api_control_ping_t *mp_ping;
13184 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
13185 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
13186 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
13189 /* Get list of tap interfaces */
13190 M (SW_INTERFACE_TAP_V2_DUMP, mp);
13193 /* Use a control ping for synchronization */
13194 MPING (CONTROL_PING, mp_ping);
13202 api_vxlan_offload_rx (vat_main_t * vam)
13204 unformat_input_t *line_input = vam->input;
13205 vl_api_vxlan_offload_rx_t *mp;
13206 u32 hw_if_index = ~0, rx_if_index = ~0;
13210 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13212 if (unformat (line_input, "del"))
13214 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
13217 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
13219 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
13222 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
13226 errmsg ("parse error '%U'", format_unformat_error, line_input);
13231 if (hw_if_index == ~0)
13233 errmsg ("no hw interface");
13237 if (rx_if_index == ~0)
13239 errmsg ("no rx tunnel");
13243 M (VXLAN_OFFLOAD_RX, mp);
13245 mp->hw_if_index = ntohl (hw_if_index);
13246 mp->sw_if_index = ntohl (rx_if_index);
13247 mp->enable = is_add;
13254 static uword unformat_vxlan_decap_next
13255 (unformat_input_t * input, va_list * args)
13257 u32 *result = va_arg (*args, u32 *);
13260 if (unformat (input, "l2"))
13261 *result = VXLAN_INPUT_NEXT_L2_INPUT;
13262 else if (unformat (input, "%d", &tmp))
13270 api_vxlan_add_del_tunnel (vat_main_t * vam)
13272 unformat_input_t *line_input = vam->input;
13273 vl_api_vxlan_add_del_tunnel_t *mp;
13274 ip46_address_t src, dst;
13276 u8 ipv4_set = 0, ipv6_set = 0;
13281 u32 mcast_sw_if_index = ~0;
13282 u32 encap_vrf_id = 0;
13283 u32 decap_next_index = ~0;
13287 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13288 memset (&src, 0, sizeof src);
13289 memset (&dst, 0, sizeof dst);
13291 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13293 if (unformat (line_input, "del"))
13295 else if (unformat (line_input, "instance %d", &instance))
13298 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13304 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13310 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13316 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13321 else if (unformat (line_input, "group %U %U",
13322 unformat_ip4_address, &dst.ip4,
13323 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13325 grp_set = dst_set = 1;
13328 else if (unformat (line_input, "group %U",
13329 unformat_ip4_address, &dst.ip4))
13331 grp_set = dst_set = 1;
13334 else if (unformat (line_input, "group %U %U",
13335 unformat_ip6_address, &dst.ip6,
13336 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13338 grp_set = dst_set = 1;
13341 else if (unformat (line_input, "group %U",
13342 unformat_ip6_address, &dst.ip6))
13344 grp_set = dst_set = 1;
13348 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13350 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13352 else if (unformat (line_input, "decap-next %U",
13353 unformat_vxlan_decap_next, &decap_next_index))
13355 else if (unformat (line_input, "vni %d", &vni))
13359 errmsg ("parse error '%U'", format_unformat_error, line_input);
13366 errmsg ("tunnel src address not specified");
13371 errmsg ("tunnel dst address not specified");
13375 if (grp_set && !ip46_address_is_multicast (&dst))
13377 errmsg ("tunnel group address not multicast");
13380 if (grp_set && mcast_sw_if_index == ~0)
13382 errmsg ("tunnel nonexistent multicast device");
13385 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13387 errmsg ("tunnel dst address must be unicast");
13392 if (ipv4_set && ipv6_set)
13394 errmsg ("both IPv4 and IPv6 addresses specified");
13398 if ((vni == 0) || (vni >> 24))
13400 errmsg ("vni not specified or out of range");
13404 M (VXLAN_ADD_DEL_TUNNEL, mp);
13408 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
13409 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
13413 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
13414 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
13417 mp->instance = htonl (instance);
13418 mp->encap_vrf_id = ntohl (encap_vrf_id);
13419 mp->decap_next_index = ntohl (decap_next_index);
13420 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13421 mp->vni = ntohl (vni);
13422 mp->is_add = is_add;
13423 mp->is_ipv6 = ipv6_set;
13430 static void vl_api_vxlan_tunnel_details_t_handler
13431 (vl_api_vxlan_tunnel_details_t * mp)
13433 vat_main_t *vam = &vat_main;
13434 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13435 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13437 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
13438 ntohl (mp->sw_if_index),
13439 ntohl (mp->instance),
13440 format_ip46_address, &src, IP46_TYPE_ANY,
13441 format_ip46_address, &dst, IP46_TYPE_ANY,
13442 ntohl (mp->encap_vrf_id),
13443 ntohl (mp->decap_next_index), ntohl (mp->vni),
13444 ntohl (mp->mcast_sw_if_index));
13447 static void vl_api_vxlan_tunnel_details_t_handler_json
13448 (vl_api_vxlan_tunnel_details_t * mp)
13450 vat_main_t *vam = &vat_main;
13451 vat_json_node_t *node = NULL;
13453 if (VAT_JSON_ARRAY != vam->json_tree.type)
13455 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13456 vat_json_init_array (&vam->json_tree);
13458 node = vat_json_array_add (&vam->json_tree);
13460 vat_json_init_object (node);
13461 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13463 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13467 struct in6_addr ip6;
13469 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13470 vat_json_object_add_ip6 (node, "src_address", ip6);
13471 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13472 vat_json_object_add_ip6 (node, "dst_address", ip6);
13476 struct in_addr ip4;
13478 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13479 vat_json_object_add_ip4 (node, "src_address", ip4);
13480 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13481 vat_json_object_add_ip4 (node, "dst_address", ip4);
13483 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13484 vat_json_object_add_uint (node, "decap_next_index",
13485 ntohl (mp->decap_next_index));
13486 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13487 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13488 vat_json_object_add_uint (node, "mcast_sw_if_index",
13489 ntohl (mp->mcast_sw_if_index));
13493 api_vxlan_tunnel_dump (vat_main_t * vam)
13495 unformat_input_t *i = vam->input;
13496 vl_api_vxlan_tunnel_dump_t *mp;
13497 vl_api_control_ping_t *mp_ping;
13499 u8 sw_if_index_set = 0;
13502 /* Parse args required to build the message */
13503 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13505 if (unformat (i, "sw_if_index %d", &sw_if_index))
13506 sw_if_index_set = 1;
13511 if (sw_if_index_set == 0)
13516 if (!vam->json_output)
13518 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
13519 "sw_if_index", "instance", "src_address", "dst_address",
13520 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13523 /* Get list of vxlan-tunnel interfaces */
13524 M (VXLAN_TUNNEL_DUMP, mp);
13526 mp->sw_if_index = htonl (sw_if_index);
13530 /* Use a control ping for synchronization */
13531 MPING (CONTROL_PING, mp_ping);
13538 static uword unformat_geneve_decap_next
13539 (unformat_input_t * input, va_list * args)
13541 u32 *result = va_arg (*args, u32 *);
13544 if (unformat (input, "l2"))
13545 *result = GENEVE_INPUT_NEXT_L2_INPUT;
13546 else if (unformat (input, "%d", &tmp))
13554 api_geneve_add_del_tunnel (vat_main_t * vam)
13556 unformat_input_t *line_input = vam->input;
13557 vl_api_geneve_add_del_tunnel_t *mp;
13558 ip46_address_t src, dst;
13560 u8 ipv4_set = 0, ipv6_set = 0;
13564 u32 mcast_sw_if_index = ~0;
13565 u32 encap_vrf_id = 0;
13566 u32 decap_next_index = ~0;
13570 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13571 memset (&src, 0, sizeof src);
13572 memset (&dst, 0, sizeof dst);
13574 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13576 if (unformat (line_input, "del"))
13579 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13585 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13591 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13597 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13602 else if (unformat (line_input, "group %U %U",
13603 unformat_ip4_address, &dst.ip4,
13604 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13606 grp_set = dst_set = 1;
13609 else if (unformat (line_input, "group %U",
13610 unformat_ip4_address, &dst.ip4))
13612 grp_set = dst_set = 1;
13615 else if (unformat (line_input, "group %U %U",
13616 unformat_ip6_address, &dst.ip6,
13617 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13619 grp_set = dst_set = 1;
13622 else if (unformat (line_input, "group %U",
13623 unformat_ip6_address, &dst.ip6))
13625 grp_set = dst_set = 1;
13629 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13631 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13633 else if (unformat (line_input, "decap-next %U",
13634 unformat_geneve_decap_next, &decap_next_index))
13636 else if (unformat (line_input, "vni %d", &vni))
13640 errmsg ("parse error '%U'", format_unformat_error, line_input);
13647 errmsg ("tunnel src address not specified");
13652 errmsg ("tunnel dst address not specified");
13656 if (grp_set && !ip46_address_is_multicast (&dst))
13658 errmsg ("tunnel group address not multicast");
13661 if (grp_set && mcast_sw_if_index == ~0)
13663 errmsg ("tunnel nonexistent multicast device");
13666 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13668 errmsg ("tunnel dst address must be unicast");
13673 if (ipv4_set && ipv6_set)
13675 errmsg ("both IPv4 and IPv6 addresses specified");
13679 if ((vni == 0) || (vni >> 24))
13681 errmsg ("vni not specified or out of range");
13685 M (GENEVE_ADD_DEL_TUNNEL, mp);
13689 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
13690 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
13694 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
13695 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
13697 mp->encap_vrf_id = ntohl (encap_vrf_id);
13698 mp->decap_next_index = ntohl (decap_next_index);
13699 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13700 mp->vni = ntohl (vni);
13701 mp->is_add = is_add;
13702 mp->is_ipv6 = ipv6_set;
13709 static void vl_api_geneve_tunnel_details_t_handler
13710 (vl_api_geneve_tunnel_details_t * mp)
13712 vat_main_t *vam = &vat_main;
13713 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13714 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13716 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
13717 ntohl (mp->sw_if_index),
13718 format_ip46_address, &src, IP46_TYPE_ANY,
13719 format_ip46_address, &dst, IP46_TYPE_ANY,
13720 ntohl (mp->encap_vrf_id),
13721 ntohl (mp->decap_next_index), ntohl (mp->vni),
13722 ntohl (mp->mcast_sw_if_index));
13725 static void vl_api_geneve_tunnel_details_t_handler_json
13726 (vl_api_geneve_tunnel_details_t * mp)
13728 vat_main_t *vam = &vat_main;
13729 vat_json_node_t *node = NULL;
13731 if (VAT_JSON_ARRAY != vam->json_tree.type)
13733 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13734 vat_json_init_array (&vam->json_tree);
13736 node = vat_json_array_add (&vam->json_tree);
13738 vat_json_init_object (node);
13739 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13742 struct in6_addr ip6;
13744 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13745 vat_json_object_add_ip6 (node, "src_address", ip6);
13746 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13747 vat_json_object_add_ip6 (node, "dst_address", ip6);
13751 struct in_addr ip4;
13753 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13754 vat_json_object_add_ip4 (node, "src_address", ip4);
13755 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13756 vat_json_object_add_ip4 (node, "dst_address", ip4);
13758 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13759 vat_json_object_add_uint (node, "decap_next_index",
13760 ntohl (mp->decap_next_index));
13761 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13762 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13763 vat_json_object_add_uint (node, "mcast_sw_if_index",
13764 ntohl (mp->mcast_sw_if_index));
13768 api_geneve_tunnel_dump (vat_main_t * vam)
13770 unformat_input_t *i = vam->input;
13771 vl_api_geneve_tunnel_dump_t *mp;
13772 vl_api_control_ping_t *mp_ping;
13774 u8 sw_if_index_set = 0;
13777 /* Parse args required to build the message */
13778 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13780 if (unformat (i, "sw_if_index %d", &sw_if_index))
13781 sw_if_index_set = 1;
13786 if (sw_if_index_set == 0)
13791 if (!vam->json_output)
13793 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
13794 "sw_if_index", "local_address", "remote_address",
13795 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13798 /* Get list of geneve-tunnel interfaces */
13799 M (GENEVE_TUNNEL_DUMP, mp);
13801 mp->sw_if_index = htonl (sw_if_index);
13805 /* Use a control ping for synchronization */
13806 M (CONTROL_PING, mp_ping);
13814 api_gre_add_del_tunnel (vat_main_t * vam)
13816 unformat_input_t *line_input = vam->input;
13817 vl_api_gre_add_del_tunnel_t *mp;
13818 ip4_address_t src4, dst4;
13819 ip6_address_t src6, dst6;
13823 u8 t_type = GRE_TUNNEL_TYPE_L3;
13826 u32 outer_fib_id = 0;
13827 u32 session_id = 0;
13831 memset (&src4, 0, sizeof src4);
13832 memset (&dst4, 0, sizeof dst4);
13833 memset (&src6, 0, sizeof src6);
13834 memset (&dst6, 0, sizeof dst6);
13836 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13838 if (unformat (line_input, "del"))
13840 else if (unformat (line_input, "instance %d", &instance))
13842 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
13847 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
13852 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
13857 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
13862 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
13864 else if (unformat (line_input, "teb"))
13865 t_type = GRE_TUNNEL_TYPE_TEB;
13866 else if (unformat (line_input, "erspan %d", &session_id))
13867 t_type = GRE_TUNNEL_TYPE_ERSPAN;
13870 errmsg ("parse error '%U'", format_unformat_error, line_input);
13877 errmsg ("tunnel src address not specified");
13882 errmsg ("tunnel dst address not specified");
13885 if (ipv4_set && ipv6_set)
13887 errmsg ("both IPv4 and IPv6 addresses specified");
13892 M (GRE_ADD_DEL_TUNNEL, mp);
13896 clib_memcpy (&mp->src_address, &src4, 4);
13897 clib_memcpy (&mp->dst_address, &dst4, 4);
13901 clib_memcpy (&mp->src_address, &src6, 16);
13902 clib_memcpy (&mp->dst_address, &dst6, 16);
13904 mp->instance = htonl (instance);
13905 mp->outer_fib_id = htonl (outer_fib_id);
13906 mp->is_add = is_add;
13907 mp->session_id = htons ((u16) session_id);
13908 mp->tunnel_type = t_type;
13909 mp->is_ipv6 = ipv6_set;
13916 static void vl_api_gre_tunnel_details_t_handler
13917 (vl_api_gre_tunnel_details_t * mp)
13919 vat_main_t *vam = &vat_main;
13920 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
13921 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
13923 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
13924 ntohl (mp->sw_if_index),
13925 ntohl (mp->instance),
13926 format_ip46_address, &src, IP46_TYPE_ANY,
13927 format_ip46_address, &dst, IP46_TYPE_ANY,
13928 mp->tunnel_type, ntohl (mp->outer_fib_id), ntohl (mp->session_id));
13931 static void vl_api_gre_tunnel_details_t_handler_json
13932 (vl_api_gre_tunnel_details_t * mp)
13934 vat_main_t *vam = &vat_main;
13935 vat_json_node_t *node = NULL;
13936 struct in_addr ip4;
13937 struct in6_addr ip6;
13939 if (VAT_JSON_ARRAY != vam->json_tree.type)
13941 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13942 vat_json_init_array (&vam->json_tree);
13944 node = vat_json_array_add (&vam->json_tree);
13946 vat_json_init_object (node);
13947 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13948 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13951 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
13952 vat_json_object_add_ip4 (node, "src_address", ip4);
13953 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
13954 vat_json_object_add_ip4 (node, "dst_address", ip4);
13958 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
13959 vat_json_object_add_ip6 (node, "src_address", ip6);
13960 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
13961 vat_json_object_add_ip6 (node, "dst_address", ip6);
13963 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel_type);
13964 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
13965 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
13966 vat_json_object_add_uint (node, "session_id", mp->session_id);
13970 api_gre_tunnel_dump (vat_main_t * vam)
13972 unformat_input_t *i = vam->input;
13973 vl_api_gre_tunnel_dump_t *mp;
13974 vl_api_control_ping_t *mp_ping;
13976 u8 sw_if_index_set = 0;
13979 /* Parse args required to build the message */
13980 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13982 if (unformat (i, "sw_if_index %d", &sw_if_index))
13983 sw_if_index_set = 1;
13988 if (sw_if_index_set == 0)
13993 if (!vam->json_output)
13995 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
13996 "sw_if_index", "instance", "src_address", "dst_address",
13997 "tunnel_type", "outer_fib_id", "session_id");
14000 /* Get list of gre-tunnel interfaces */
14001 M (GRE_TUNNEL_DUMP, mp);
14003 mp->sw_if_index = htonl (sw_if_index);
14007 /* Use a control ping for synchronization */
14008 MPING (CONTROL_PING, mp_ping);
14016 api_l2_fib_clear_table (vat_main_t * vam)
14018 // unformat_input_t * i = vam->input;
14019 vl_api_l2_fib_clear_table_t *mp;
14022 M (L2_FIB_CLEAR_TABLE, mp);
14030 api_l2_interface_efp_filter (vat_main_t * vam)
14032 unformat_input_t *i = vam->input;
14033 vl_api_l2_interface_efp_filter_t *mp;
14036 u8 sw_if_index_set = 0;
14039 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14041 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14042 sw_if_index_set = 1;
14043 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14044 sw_if_index_set = 1;
14045 else if (unformat (i, "enable"))
14047 else if (unformat (i, "disable"))
14051 clib_warning ("parse error '%U'", format_unformat_error, i);
14056 if (sw_if_index_set == 0)
14058 errmsg ("missing sw_if_index");
14062 M (L2_INTERFACE_EFP_FILTER, mp);
14064 mp->sw_if_index = ntohl (sw_if_index);
14065 mp->enable_disable = enable;
14072 #define foreach_vtr_op \
14073 _("disable", L2_VTR_DISABLED) \
14074 _("push-1", L2_VTR_PUSH_1) \
14075 _("push-2", L2_VTR_PUSH_2) \
14076 _("pop-1", L2_VTR_POP_1) \
14077 _("pop-2", L2_VTR_POP_2) \
14078 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
14079 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
14080 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
14081 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
14084 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
14086 unformat_input_t *i = vam->input;
14087 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
14089 u8 sw_if_index_set = 0;
14092 u32 push_dot1q = 1;
14097 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14099 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14100 sw_if_index_set = 1;
14101 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14102 sw_if_index_set = 1;
14103 else if (unformat (i, "vtr_op %d", &vtr_op))
14105 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
14108 else if (unformat (i, "push_dot1q %d", &push_dot1q))
14110 else if (unformat (i, "tag1 %d", &tag1))
14112 else if (unformat (i, "tag2 %d", &tag2))
14116 clib_warning ("parse error '%U'", format_unformat_error, i);
14121 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
14123 errmsg ("missing vtr operation or sw_if_index");
14127 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
14128 mp->sw_if_index = ntohl (sw_if_index);
14129 mp->vtr_op = ntohl (vtr_op);
14130 mp->push_dot1q = ntohl (push_dot1q);
14131 mp->tag1 = ntohl (tag1);
14132 mp->tag2 = ntohl (tag2);
14140 api_create_vhost_user_if (vat_main_t * vam)
14142 unformat_input_t *i = vam->input;
14143 vl_api_create_vhost_user_if_t *mp;
14146 u8 file_name_set = 0;
14147 u32 custom_dev_instance = ~0;
14149 u8 use_custom_mac = 0;
14150 u8 disable_mrg_rxbuf = 0;
14151 u8 disable_indirect_desc = 0;
14155 /* Shut up coverity */
14156 memset (hwaddr, 0, sizeof (hwaddr));
14158 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14160 if (unformat (i, "socket %s", &file_name))
14164 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
14166 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
14167 use_custom_mac = 1;
14168 else if (unformat (i, "server"))
14170 else if (unformat (i, "disable_mrg_rxbuf"))
14171 disable_mrg_rxbuf = 1;
14172 else if (unformat (i, "disable_indirect_desc"))
14173 disable_indirect_desc = 1;
14174 else if (unformat (i, "tag %s", &tag))
14180 if (file_name_set == 0)
14182 errmsg ("missing socket file name");
14186 if (vec_len (file_name) > 255)
14188 errmsg ("socket file name too long");
14191 vec_add1 (file_name, 0);
14193 M (CREATE_VHOST_USER_IF, mp);
14195 mp->is_server = is_server;
14196 mp->disable_mrg_rxbuf = disable_mrg_rxbuf;
14197 mp->disable_indirect_desc = disable_indirect_desc;
14198 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
14199 vec_free (file_name);
14200 if (custom_dev_instance != ~0)
14203 mp->custom_dev_instance = ntohl (custom_dev_instance);
14206 mp->use_custom_mac = use_custom_mac;
14207 clib_memcpy (mp->mac_address, hwaddr, 6);
14209 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
14218 api_modify_vhost_user_if (vat_main_t * vam)
14220 unformat_input_t *i = vam->input;
14221 vl_api_modify_vhost_user_if_t *mp;
14224 u8 file_name_set = 0;
14225 u32 custom_dev_instance = ~0;
14226 u8 sw_if_index_set = 0;
14227 u32 sw_if_index = (u32) ~ 0;
14230 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14232 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14233 sw_if_index_set = 1;
14234 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14235 sw_if_index_set = 1;
14236 else if (unformat (i, "socket %s", &file_name))
14240 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
14242 else if (unformat (i, "server"))
14248 if (sw_if_index_set == 0)
14250 errmsg ("missing sw_if_index or interface name");
14254 if (file_name_set == 0)
14256 errmsg ("missing socket file name");
14260 if (vec_len (file_name) > 255)
14262 errmsg ("socket file name too long");
14265 vec_add1 (file_name, 0);
14267 M (MODIFY_VHOST_USER_IF, mp);
14269 mp->sw_if_index = ntohl (sw_if_index);
14270 mp->is_server = is_server;
14271 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
14272 vec_free (file_name);
14273 if (custom_dev_instance != ~0)
14276 mp->custom_dev_instance = ntohl (custom_dev_instance);
14285 api_delete_vhost_user_if (vat_main_t * vam)
14287 unformat_input_t *i = vam->input;
14288 vl_api_delete_vhost_user_if_t *mp;
14289 u32 sw_if_index = ~0;
14290 u8 sw_if_index_set = 0;
14293 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14295 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14296 sw_if_index_set = 1;
14297 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14298 sw_if_index_set = 1;
14303 if (sw_if_index_set == 0)
14305 errmsg ("missing sw_if_index or interface name");
14310 M (DELETE_VHOST_USER_IF, mp);
14312 mp->sw_if_index = ntohl (sw_if_index);
14319 static void vl_api_sw_interface_vhost_user_details_t_handler
14320 (vl_api_sw_interface_vhost_user_details_t * mp)
14322 vat_main_t *vam = &vat_main;
14324 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
14325 (char *) mp->interface_name,
14326 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
14327 clib_net_to_host_u64 (mp->features), mp->is_server,
14328 ntohl (mp->num_regions), (char *) mp->sock_filename);
14329 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
14332 static void vl_api_sw_interface_vhost_user_details_t_handler_json
14333 (vl_api_sw_interface_vhost_user_details_t * mp)
14335 vat_main_t *vam = &vat_main;
14336 vat_json_node_t *node = NULL;
14338 if (VAT_JSON_ARRAY != vam->json_tree.type)
14340 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14341 vat_json_init_array (&vam->json_tree);
14343 node = vat_json_array_add (&vam->json_tree);
14345 vat_json_init_object (node);
14346 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14347 vat_json_object_add_string_copy (node, "interface_name",
14348 mp->interface_name);
14349 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
14350 ntohl (mp->virtio_net_hdr_sz));
14351 vat_json_object_add_uint (node, "features",
14352 clib_net_to_host_u64 (mp->features));
14353 vat_json_object_add_uint (node, "is_server", mp->is_server);
14354 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
14355 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
14356 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
14360 api_sw_interface_vhost_user_dump (vat_main_t * vam)
14362 vl_api_sw_interface_vhost_user_dump_t *mp;
14363 vl_api_control_ping_t *mp_ping;
14366 "Interface name idx hdr_sz features server regions filename");
14368 /* Get list of vhost-user interfaces */
14369 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
14372 /* Use a control ping for synchronization */
14373 MPING (CONTROL_PING, mp_ping);
14381 api_show_version (vat_main_t * vam)
14383 vl_api_show_version_t *mp;
14386 M (SHOW_VERSION, mp);
14395 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
14397 unformat_input_t *line_input = vam->input;
14398 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
14399 ip4_address_t local4, remote4;
14400 ip6_address_t local6, remote6;
14402 u8 ipv4_set = 0, ipv6_set = 0;
14406 u32 mcast_sw_if_index = ~0;
14407 u32 encap_vrf_id = 0;
14408 u32 decap_vrf_id = 0;
14414 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
14415 memset (&local4, 0, sizeof local4);
14416 memset (&remote4, 0, sizeof remote4);
14417 memset (&local6, 0, sizeof local6);
14418 memset (&remote6, 0, sizeof remote6);
14420 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14422 if (unformat (line_input, "del"))
14424 else if (unformat (line_input, "local %U",
14425 unformat_ip4_address, &local4))
14430 else if (unformat (line_input, "remote %U",
14431 unformat_ip4_address, &remote4))
14436 else if (unformat (line_input, "local %U",
14437 unformat_ip6_address, &local6))
14442 else if (unformat (line_input, "remote %U",
14443 unformat_ip6_address, &remote6))
14448 else if (unformat (line_input, "group %U %U",
14449 unformat_ip4_address, &remote4,
14450 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14452 grp_set = remote_set = 1;
14455 else if (unformat (line_input, "group %U",
14456 unformat_ip4_address, &remote4))
14458 grp_set = remote_set = 1;
14461 else if (unformat (line_input, "group %U %U",
14462 unformat_ip6_address, &remote6,
14463 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14465 grp_set = remote_set = 1;
14468 else if (unformat (line_input, "group %U",
14469 unformat_ip6_address, &remote6))
14471 grp_set = remote_set = 1;
14475 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
14477 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
14479 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
14481 else if (unformat (line_input, "vni %d", &vni))
14483 else if (unformat (line_input, "next-ip4"))
14485 else if (unformat (line_input, "next-ip6"))
14487 else if (unformat (line_input, "next-ethernet"))
14489 else if (unformat (line_input, "next-nsh"))
14493 errmsg ("parse error '%U'", format_unformat_error, line_input);
14498 if (local_set == 0)
14500 errmsg ("tunnel local address not specified");
14503 if (remote_set == 0)
14505 errmsg ("tunnel remote address not specified");
14508 if (grp_set && mcast_sw_if_index == ~0)
14510 errmsg ("tunnel nonexistent multicast device");
14513 if (ipv4_set && ipv6_set)
14515 errmsg ("both IPv4 and IPv6 addresses specified");
14521 errmsg ("vni not specified");
14525 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
14530 clib_memcpy (&mp->local, &local6, sizeof (local6));
14531 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
14535 clib_memcpy (&mp->local, &local4, sizeof (local4));
14536 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
14539 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
14540 mp->encap_vrf_id = ntohl (encap_vrf_id);
14541 mp->decap_vrf_id = ntohl (decap_vrf_id);
14542 mp->protocol = protocol;
14543 mp->vni = ntohl (vni);
14544 mp->is_add = is_add;
14545 mp->is_ipv6 = ipv6_set;
14552 static void vl_api_vxlan_gpe_tunnel_details_t_handler
14553 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14555 vat_main_t *vam = &vat_main;
14556 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
14557 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
14559 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
14560 ntohl (mp->sw_if_index),
14561 format_ip46_address, &local, IP46_TYPE_ANY,
14562 format_ip46_address, &remote, IP46_TYPE_ANY,
14563 ntohl (mp->vni), mp->protocol,
14564 ntohl (mp->mcast_sw_if_index),
14565 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
14569 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
14570 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14572 vat_main_t *vam = &vat_main;
14573 vat_json_node_t *node = NULL;
14574 struct in_addr ip4;
14575 struct in6_addr ip6;
14577 if (VAT_JSON_ARRAY != vam->json_tree.type)
14579 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14580 vat_json_init_array (&vam->json_tree);
14582 node = vat_json_array_add (&vam->json_tree);
14584 vat_json_init_object (node);
14585 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14588 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
14589 vat_json_object_add_ip6 (node, "local", ip6);
14590 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
14591 vat_json_object_add_ip6 (node, "remote", ip6);
14595 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
14596 vat_json_object_add_ip4 (node, "local", ip4);
14597 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
14598 vat_json_object_add_ip4 (node, "remote", ip4);
14600 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
14601 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
14602 vat_json_object_add_uint (node, "mcast_sw_if_index",
14603 ntohl (mp->mcast_sw_if_index));
14604 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
14605 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
14606 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
14610 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
14612 unformat_input_t *i = vam->input;
14613 vl_api_vxlan_gpe_tunnel_dump_t *mp;
14614 vl_api_control_ping_t *mp_ping;
14616 u8 sw_if_index_set = 0;
14619 /* Parse args required to build the message */
14620 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14622 if (unformat (i, "sw_if_index %d", &sw_if_index))
14623 sw_if_index_set = 1;
14628 if (sw_if_index_set == 0)
14633 if (!vam->json_output)
14635 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
14636 "sw_if_index", "local", "remote", "vni",
14637 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
14640 /* Get list of vxlan-tunnel interfaces */
14641 M (VXLAN_GPE_TUNNEL_DUMP, mp);
14643 mp->sw_if_index = htonl (sw_if_index);
14647 /* Use a control ping for synchronization */
14648 MPING (CONTROL_PING, mp_ping);
14655 static void vl_api_l2_fib_table_details_t_handler
14656 (vl_api_l2_fib_table_details_t * mp)
14658 vat_main_t *vam = &vat_main;
14660 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
14662 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
14663 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
14667 static void vl_api_l2_fib_table_details_t_handler_json
14668 (vl_api_l2_fib_table_details_t * mp)
14670 vat_main_t *vam = &vat_main;
14671 vat_json_node_t *node = NULL;
14673 if (VAT_JSON_ARRAY != vam->json_tree.type)
14675 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14676 vat_json_init_array (&vam->json_tree);
14678 node = vat_json_array_add (&vam->json_tree);
14680 vat_json_init_object (node);
14681 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
14682 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
14683 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14684 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
14685 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
14686 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
14690 api_l2_fib_table_dump (vat_main_t * vam)
14692 unformat_input_t *i = vam->input;
14693 vl_api_l2_fib_table_dump_t *mp;
14694 vl_api_control_ping_t *mp_ping;
14699 /* Parse args required to build the message */
14700 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14702 if (unformat (i, "bd_id %d", &bd_id))
14708 if (bd_id_set == 0)
14710 errmsg ("missing bridge domain");
14714 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
14716 /* Get list of l2 fib entries */
14717 M (L2_FIB_TABLE_DUMP, mp);
14719 mp->bd_id = ntohl (bd_id);
14722 /* Use a control ping for synchronization */
14723 MPING (CONTROL_PING, mp_ping);
14732 api_interface_name_renumber (vat_main_t * vam)
14734 unformat_input_t *line_input = vam->input;
14735 vl_api_interface_name_renumber_t *mp;
14736 u32 sw_if_index = ~0;
14737 u32 new_show_dev_instance = ~0;
14740 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14742 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
14745 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14747 else if (unformat (line_input, "new_show_dev_instance %d",
14748 &new_show_dev_instance))
14754 if (sw_if_index == ~0)
14756 errmsg ("missing interface name or sw_if_index");
14760 if (new_show_dev_instance == ~0)
14762 errmsg ("missing new_show_dev_instance");
14766 M (INTERFACE_NAME_RENUMBER, mp);
14768 mp->sw_if_index = ntohl (sw_if_index);
14769 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
14777 api_ip_probe_neighbor (vat_main_t * vam)
14779 unformat_input_t *i = vam->input;
14780 vl_api_ip_probe_neighbor_t *mp;
14788 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14790 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14792 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14794 else if (unformat (i, "address %U", unformat_ip4_address, dst_adr))
14796 else if (unformat (i, "address %U", unformat_ip6_address, dst_adr))
14807 errmsg ("missing interface");
14813 errmsg ("missing addresses");
14817 M (IP_PROBE_NEIGHBOR, mp);
14819 mp->sw_if_index = ntohl (sw_if_index);
14820 mp->is_ipv6 = is_ipv6;
14821 clib_memcpy (mp->dst_address, dst_adr, sizeof (dst_adr));
14829 api_ip_scan_neighbor_enable_disable (vat_main_t * vam)
14831 unformat_input_t *i = vam->input;
14832 vl_api_ip_scan_neighbor_enable_disable_t *mp;
14833 u8 mode = IP_SCAN_V46_NEIGHBORS;
14834 u32 interval = 0, time = 0, update = 0, delay = 0, stale = 0;
14837 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14839 if (unformat (i, "ip4"))
14840 mode = IP_SCAN_V4_NEIGHBORS;
14841 else if (unformat (i, "ip6"))
14842 mode = IP_SCAN_V6_NEIGHBORS;
14843 if (unformat (i, "both"))
14844 mode = IP_SCAN_V46_NEIGHBORS;
14845 else if (unformat (i, "disable"))
14846 mode = IP_SCAN_DISABLED;
14847 else if (unformat (i, "interval %d", &interval))
14849 else if (unformat (i, "max-time %d", &time))
14851 else if (unformat (i, "max-update %d", &update))
14853 else if (unformat (i, "delay %d", &delay))
14855 else if (unformat (i, "stale %d", &stale))
14861 if (interval > 255)
14863 errmsg ("interval cannot exceed 255 minutes.");
14868 errmsg ("max-time cannot exceed 255 usec.");
14873 errmsg ("max-update cannot exceed 255.");
14878 errmsg ("delay cannot exceed 255 msec.");
14883 errmsg ("stale cannot exceed 255 minutes.");
14887 M (IP_SCAN_NEIGHBOR_ENABLE_DISABLE, mp);
14889 mp->scan_interval = interval;
14890 mp->max_proc_time = time;
14891 mp->max_update = update;
14892 mp->scan_int_delay = delay;
14893 mp->stale_threshold = stale;
14901 api_want_ip4_arp_events (vat_main_t * vam)
14903 unformat_input_t *line_input = vam->input;
14904 vl_api_want_ip4_arp_events_t *mp;
14905 ip4_address_t address;
14906 int address_set = 0;
14907 u32 enable_disable = 1;
14910 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14912 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
14914 else if (unformat (line_input, "del"))
14915 enable_disable = 0;
14920 if (address_set == 0)
14922 errmsg ("missing addresses");
14926 M (WANT_IP4_ARP_EVENTS, mp);
14927 mp->enable_disable = enable_disable;
14928 mp->pid = htonl (getpid ());
14929 mp->address = address.as_u32;
14937 api_want_ip6_nd_events (vat_main_t * vam)
14939 unformat_input_t *line_input = vam->input;
14940 vl_api_want_ip6_nd_events_t *mp;
14941 ip6_address_t address;
14942 int address_set = 0;
14943 u32 enable_disable = 1;
14946 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14948 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
14950 else if (unformat (line_input, "del"))
14951 enable_disable = 0;
14956 if (address_set == 0)
14958 errmsg ("missing addresses");
14962 M (WANT_IP6_ND_EVENTS, mp);
14963 mp->enable_disable = enable_disable;
14964 mp->pid = htonl (getpid ());
14965 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
14973 api_want_l2_macs_events (vat_main_t * vam)
14975 unformat_input_t *line_input = vam->input;
14976 vl_api_want_l2_macs_events_t *mp;
14977 u8 enable_disable = 1;
14978 u32 scan_delay = 0;
14979 u32 max_macs_in_event = 0;
14980 u32 learn_limit = 0;
14983 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14985 if (unformat (line_input, "learn-limit %d", &learn_limit))
14987 else if (unformat (line_input, "scan-delay %d", &scan_delay))
14989 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
14991 else if (unformat (line_input, "disable"))
14992 enable_disable = 0;
14997 M (WANT_L2_MACS_EVENTS, mp);
14998 mp->enable_disable = enable_disable;
14999 mp->pid = htonl (getpid ());
15000 mp->learn_limit = htonl (learn_limit);
15001 mp->scan_delay = (u8) scan_delay;
15002 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
15009 api_input_acl_set_interface (vat_main_t * vam)
15011 unformat_input_t *i = vam->input;
15012 vl_api_input_acl_set_interface_t *mp;
15014 int sw_if_index_set;
15015 u32 ip4_table_index = ~0;
15016 u32 ip6_table_index = ~0;
15017 u32 l2_table_index = ~0;
15021 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15023 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15024 sw_if_index_set = 1;
15025 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15026 sw_if_index_set = 1;
15027 else if (unformat (i, "del"))
15029 else if (unformat (i, "ip4-table %d", &ip4_table_index))
15031 else if (unformat (i, "ip6-table %d", &ip6_table_index))
15033 else if (unformat (i, "l2-table %d", &l2_table_index))
15037 clib_warning ("parse error '%U'", format_unformat_error, i);
15042 if (sw_if_index_set == 0)
15044 errmsg ("missing interface name or sw_if_index");
15048 M (INPUT_ACL_SET_INTERFACE, mp);
15050 mp->sw_if_index = ntohl (sw_if_index);
15051 mp->ip4_table_index = ntohl (ip4_table_index);
15052 mp->ip6_table_index = ntohl (ip6_table_index);
15053 mp->l2_table_index = ntohl (l2_table_index);
15054 mp->is_add = is_add;
15062 api_output_acl_set_interface (vat_main_t * vam)
15064 unformat_input_t *i = vam->input;
15065 vl_api_output_acl_set_interface_t *mp;
15067 int sw_if_index_set;
15068 u32 ip4_table_index = ~0;
15069 u32 ip6_table_index = ~0;
15070 u32 l2_table_index = ~0;
15074 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15076 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15077 sw_if_index_set = 1;
15078 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15079 sw_if_index_set = 1;
15080 else if (unformat (i, "del"))
15082 else if (unformat (i, "ip4-table %d", &ip4_table_index))
15084 else if (unformat (i, "ip6-table %d", &ip6_table_index))
15086 else if (unformat (i, "l2-table %d", &l2_table_index))
15090 clib_warning ("parse error '%U'", format_unformat_error, i);
15095 if (sw_if_index_set == 0)
15097 errmsg ("missing interface name or sw_if_index");
15101 M (OUTPUT_ACL_SET_INTERFACE, mp);
15103 mp->sw_if_index = ntohl (sw_if_index);
15104 mp->ip4_table_index = ntohl (ip4_table_index);
15105 mp->ip6_table_index = ntohl (ip6_table_index);
15106 mp->l2_table_index = ntohl (l2_table_index);
15107 mp->is_add = is_add;
15115 api_ip_address_dump (vat_main_t * vam)
15117 unformat_input_t *i = vam->input;
15118 vl_api_ip_address_dump_t *mp;
15119 vl_api_control_ping_t *mp_ping;
15120 u32 sw_if_index = ~0;
15121 u8 sw_if_index_set = 0;
15126 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15128 if (unformat (i, "sw_if_index %d", &sw_if_index))
15129 sw_if_index_set = 1;
15131 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15132 sw_if_index_set = 1;
15133 else if (unformat (i, "ipv4"))
15135 else if (unformat (i, "ipv6"))
15141 if (ipv4_set && ipv6_set)
15143 errmsg ("ipv4 and ipv6 flags cannot be both set");
15147 if ((!ipv4_set) && (!ipv6_set))
15149 errmsg ("no ipv4 nor ipv6 flag set");
15153 if (sw_if_index_set == 0)
15155 errmsg ("missing interface name or sw_if_index");
15159 vam->current_sw_if_index = sw_if_index;
15160 vam->is_ipv6 = ipv6_set;
15162 M (IP_ADDRESS_DUMP, mp);
15163 mp->sw_if_index = ntohl (sw_if_index);
15164 mp->is_ipv6 = ipv6_set;
15167 /* Use a control ping for synchronization */
15168 MPING (CONTROL_PING, mp_ping);
15176 api_ip_dump (vat_main_t * vam)
15178 vl_api_ip_dump_t *mp;
15179 vl_api_control_ping_t *mp_ping;
15180 unformat_input_t *in = vam->input;
15187 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
15189 if (unformat (in, "ipv4"))
15191 else if (unformat (in, "ipv6"))
15197 if (ipv4_set && ipv6_set)
15199 errmsg ("ipv4 and ipv6 flags cannot be both set");
15203 if ((!ipv4_set) && (!ipv6_set))
15205 errmsg ("no ipv4 nor ipv6 flag set");
15209 is_ipv6 = ipv6_set;
15210 vam->is_ipv6 = is_ipv6;
15212 /* free old data */
15213 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
15215 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
15217 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
15220 mp->is_ipv6 = ipv6_set;
15223 /* Use a control ping for synchronization */
15224 MPING (CONTROL_PING, mp_ping);
15232 api_ipsec_spd_add_del (vat_main_t * vam)
15234 unformat_input_t *i = vam->input;
15235 vl_api_ipsec_spd_add_del_t *mp;
15240 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15242 if (unformat (i, "spd_id %d", &spd_id))
15244 else if (unformat (i, "del"))
15248 clib_warning ("parse error '%U'", format_unformat_error, i);
15254 errmsg ("spd_id must be set");
15258 M (IPSEC_SPD_ADD_DEL, mp);
15260 mp->spd_id = ntohl (spd_id);
15261 mp->is_add = is_add;
15269 api_ipsec_interface_add_del_spd (vat_main_t * vam)
15271 unformat_input_t *i = vam->input;
15272 vl_api_ipsec_interface_add_del_spd_t *mp;
15274 u8 sw_if_index_set = 0;
15275 u32 spd_id = (u32) ~ 0;
15279 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15281 if (unformat (i, "del"))
15283 else if (unformat (i, "spd_id %d", &spd_id))
15286 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15287 sw_if_index_set = 1;
15288 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15289 sw_if_index_set = 1;
15292 clib_warning ("parse error '%U'", format_unformat_error, i);
15298 if (spd_id == (u32) ~ 0)
15300 errmsg ("spd_id must be set");
15304 if (sw_if_index_set == 0)
15306 errmsg ("missing interface name or sw_if_index");
15310 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
15312 mp->spd_id = ntohl (spd_id);
15313 mp->sw_if_index = ntohl (sw_if_index);
15314 mp->is_add = is_add;
15322 api_ipsec_spd_add_del_entry (vat_main_t * vam)
15324 unformat_input_t *i = vam->input;
15325 vl_api_ipsec_spd_add_del_entry_t *mp;
15326 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
15327 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
15329 u32 rport_start = 0, rport_stop = (u32) ~ 0;
15330 u32 lport_start = 0, lport_stop = (u32) ~ 0;
15331 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
15332 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
15335 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
15336 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
15337 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
15338 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
15339 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
15340 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
15342 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15344 if (unformat (i, "del"))
15346 if (unformat (i, "outbound"))
15348 if (unformat (i, "inbound"))
15350 else if (unformat (i, "spd_id %d", &spd_id))
15352 else if (unformat (i, "sa_id %d", &sa_id))
15354 else if (unformat (i, "priority %d", &priority))
15356 else if (unformat (i, "protocol %d", &protocol))
15358 else if (unformat (i, "lport_start %d", &lport_start))
15360 else if (unformat (i, "lport_stop %d", &lport_stop))
15362 else if (unformat (i, "rport_start %d", &rport_start))
15364 else if (unformat (i, "rport_stop %d", &rport_stop))
15368 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
15374 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
15381 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
15387 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
15394 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
15400 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
15407 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
15413 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
15419 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
15421 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
15423 clib_warning ("unsupported action: 'resolve'");
15429 clib_warning ("parse error '%U'", format_unformat_error, i);
15435 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
15437 mp->spd_id = ntohl (spd_id);
15438 mp->priority = ntohl (priority);
15439 mp->is_outbound = is_outbound;
15441 mp->is_ipv6 = is_ipv6;
15442 if (is_ipv6 || is_ip_any)
15444 clib_memcpy (mp->remote_address_start, &raddr6_start,
15445 sizeof (ip6_address_t));
15446 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
15447 sizeof (ip6_address_t));
15448 clib_memcpy (mp->local_address_start, &laddr6_start,
15449 sizeof (ip6_address_t));
15450 clib_memcpy (mp->local_address_stop, &laddr6_stop,
15451 sizeof (ip6_address_t));
15455 clib_memcpy (mp->remote_address_start, &raddr4_start,
15456 sizeof (ip4_address_t));
15457 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
15458 sizeof (ip4_address_t));
15459 clib_memcpy (mp->local_address_start, &laddr4_start,
15460 sizeof (ip4_address_t));
15461 clib_memcpy (mp->local_address_stop, &laddr4_stop,
15462 sizeof (ip4_address_t));
15464 mp->protocol = (u8) protocol;
15465 mp->local_port_start = ntohs ((u16) lport_start);
15466 mp->local_port_stop = ntohs ((u16) lport_stop);
15467 mp->remote_port_start = ntohs ((u16) rport_start);
15468 mp->remote_port_stop = ntohs ((u16) rport_stop);
15469 mp->policy = (u8) policy;
15470 mp->sa_id = ntohl (sa_id);
15471 mp->is_add = is_add;
15472 mp->is_ip_any = is_ip_any;
15479 api_ipsec_sad_add_del_entry (vat_main_t * vam)
15481 unformat_input_t *i = vam->input;
15482 vl_api_ipsec_sad_add_del_entry_t *mp;
15483 u32 sad_id = 0, spi = 0;
15484 u8 *ck = 0, *ik = 0;
15487 u8 protocol = IPSEC_PROTOCOL_AH;
15488 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
15489 u32 crypto_alg = 0, integ_alg = 0;
15490 ip4_address_t tun_src4;
15491 ip4_address_t tun_dst4;
15492 ip6_address_t tun_src6;
15493 ip6_address_t tun_dst6;
15496 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15498 if (unformat (i, "del"))
15500 else if (unformat (i, "sad_id %d", &sad_id))
15502 else if (unformat (i, "spi %d", &spi))
15504 else if (unformat (i, "esp"))
15505 protocol = IPSEC_PROTOCOL_ESP;
15506 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
15509 is_tunnel_ipv6 = 0;
15511 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
15514 is_tunnel_ipv6 = 0;
15516 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
15519 is_tunnel_ipv6 = 1;
15521 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
15524 is_tunnel_ipv6 = 1;
15528 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15530 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
15532 clib_warning ("unsupported crypto-alg: '%U'",
15533 format_ipsec_crypto_alg, crypto_alg);
15537 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15541 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15543 if (integ_alg >= IPSEC_INTEG_N_ALG)
15545 clib_warning ("unsupported integ-alg: '%U'",
15546 format_ipsec_integ_alg, integ_alg);
15550 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15554 clib_warning ("parse error '%U'", format_unformat_error, i);
15560 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
15562 mp->sad_id = ntohl (sad_id);
15563 mp->is_add = is_add;
15564 mp->protocol = protocol;
15565 mp->spi = ntohl (spi);
15566 mp->is_tunnel = is_tunnel;
15567 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
15568 mp->crypto_algorithm = crypto_alg;
15569 mp->integrity_algorithm = integ_alg;
15570 mp->crypto_key_length = vec_len (ck);
15571 mp->integrity_key_length = vec_len (ik);
15573 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15574 mp->crypto_key_length = sizeof (mp->crypto_key);
15576 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15577 mp->integrity_key_length = sizeof (mp->integrity_key);
15580 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15582 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15586 if (is_tunnel_ipv6)
15588 clib_memcpy (mp->tunnel_src_address, &tun_src6,
15589 sizeof (ip6_address_t));
15590 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
15591 sizeof (ip6_address_t));
15595 clib_memcpy (mp->tunnel_src_address, &tun_src4,
15596 sizeof (ip4_address_t));
15597 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
15598 sizeof (ip4_address_t));
15608 api_ipsec_sa_set_key (vat_main_t * vam)
15610 unformat_input_t *i = vam->input;
15611 vl_api_ipsec_sa_set_key_t *mp;
15613 u8 *ck = 0, *ik = 0;
15616 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15618 if (unformat (i, "sa_id %d", &sa_id))
15620 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15622 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15626 clib_warning ("parse error '%U'", format_unformat_error, i);
15631 M (IPSEC_SA_SET_KEY, mp);
15633 mp->sa_id = ntohl (sa_id);
15634 mp->crypto_key_length = vec_len (ck);
15635 mp->integrity_key_length = vec_len (ik);
15637 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15638 mp->crypto_key_length = sizeof (mp->crypto_key);
15640 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15641 mp->integrity_key_length = sizeof (mp->integrity_key);
15644 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15646 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15654 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
15656 unformat_input_t *i = vam->input;
15657 vl_api_ipsec_tunnel_if_add_del_t *mp;
15658 u32 local_spi = 0, remote_spi = 0;
15659 u32 crypto_alg = 0, integ_alg = 0;
15660 u8 *lck = NULL, *rck = NULL;
15661 u8 *lik = NULL, *rik = NULL;
15662 ip4_address_t local_ip = { {0} };
15663 ip4_address_t remote_ip = { {0} };
15666 u8 anti_replay = 0;
15671 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15673 if (unformat (i, "del"))
15675 else if (unformat (i, "esn"))
15677 else if (unformat (i, "anti_replay"))
15679 else if (unformat (i, "local_spi %d", &local_spi))
15681 else if (unformat (i, "remote_spi %d", &remote_spi))
15683 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
15685 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
15687 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
15690 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
15692 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
15694 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
15698 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15700 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
15702 errmsg ("unsupported crypto-alg: '%U'\n",
15703 format_ipsec_crypto_alg, crypto_alg);
15709 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15711 if (integ_alg >= IPSEC_INTEG_N_ALG)
15713 errmsg ("unsupported integ-alg: '%U'\n",
15714 format_ipsec_integ_alg, integ_alg);
15718 else if (unformat (i, "instance %u", &instance))
15722 errmsg ("parse error '%U'\n", format_unformat_error, i);
15727 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
15729 mp->is_add = is_add;
15731 mp->anti_replay = anti_replay;
15733 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
15734 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
15736 mp->local_spi = htonl (local_spi);
15737 mp->remote_spi = htonl (remote_spi);
15738 mp->crypto_alg = (u8) crypto_alg;
15740 mp->local_crypto_key_len = 0;
15743 mp->local_crypto_key_len = vec_len (lck);
15744 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
15745 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
15746 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
15749 mp->remote_crypto_key_len = 0;
15752 mp->remote_crypto_key_len = vec_len (rck);
15753 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
15754 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
15755 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
15758 mp->integ_alg = (u8) integ_alg;
15760 mp->local_integ_key_len = 0;
15763 mp->local_integ_key_len = vec_len (lik);
15764 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
15765 mp->local_integ_key_len = sizeof (mp->local_integ_key);
15766 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
15769 mp->remote_integ_key_len = 0;
15772 mp->remote_integ_key_len = vec_len (rik);
15773 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
15774 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
15775 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
15780 mp->renumber = renumber;
15781 mp->show_instance = ntohl (instance);
15790 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
15792 vat_main_t *vam = &vat_main;
15794 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
15795 "crypto_key %U integ_alg %u integ_key %U use_esn %u "
15796 "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u "
15797 "tunnel_src_addr %U tunnel_dst_addr %U "
15798 "salt %u seq_outbound %lu last_seq_inbound %lu "
15799 "replay_window %lu total_data_size %lu\n",
15800 ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi),
15802 mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len,
15803 mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len,
15804 mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6,
15805 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15806 mp->tunnel_src_addr,
15807 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15808 mp->tunnel_dst_addr,
15810 clib_net_to_host_u64 (mp->seq_outbound),
15811 clib_net_to_host_u64 (mp->last_seq_inbound),
15812 clib_net_to_host_u64 (mp->replay_window),
15813 clib_net_to_host_u64 (mp->total_data_size));
15816 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
15817 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
15819 static void vl_api_ipsec_sa_details_t_handler_json
15820 (vl_api_ipsec_sa_details_t * mp)
15822 vat_main_t *vam = &vat_main;
15823 vat_json_node_t *node = NULL;
15824 struct in_addr src_ip4, dst_ip4;
15825 struct in6_addr src_ip6, dst_ip6;
15827 if (VAT_JSON_ARRAY != vam->json_tree.type)
15829 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15830 vat_json_init_array (&vam->json_tree);
15832 node = vat_json_array_add (&vam->json_tree);
15834 vat_json_init_object (node);
15835 vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id));
15836 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
15837 vat_json_object_add_uint (node, "spi", ntohl (mp->spi));
15838 vat_json_object_add_uint (node, "proto", mp->protocol);
15839 vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg);
15840 vat_json_object_add_uint (node, "integ_alg", mp->integ_alg);
15841 vat_json_object_add_uint (node, "use_esn", mp->use_esn);
15842 vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay);
15843 vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel);
15844 vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6);
15845 vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key,
15846 mp->crypto_key_len);
15847 vat_json_object_add_bytes (node, "integ_key", mp->integ_key,
15848 mp->integ_key_len);
15849 if (mp->is_tunnel_ip6)
15851 clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6));
15852 vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6);
15853 clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6));
15854 vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6);
15858 clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4));
15859 vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4);
15860 clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4));
15861 vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4);
15863 vat_json_object_add_uint (node, "replay_window",
15864 clib_net_to_host_u64 (mp->replay_window));
15865 vat_json_object_add_uint (node, "total_data_size",
15866 clib_net_to_host_u64 (mp->total_data_size));
15871 api_ipsec_sa_dump (vat_main_t * vam)
15873 unformat_input_t *i = vam->input;
15874 vl_api_ipsec_sa_dump_t *mp;
15875 vl_api_control_ping_t *mp_ping;
15879 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15881 if (unformat (i, "sa_id %d", &sa_id))
15885 clib_warning ("parse error '%U'", format_unformat_error, i);
15890 M (IPSEC_SA_DUMP, mp);
15892 mp->sa_id = ntohl (sa_id);
15896 /* Use a control ping for synchronization */
15897 M (CONTROL_PING, mp_ping);
15905 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
15907 unformat_input_t *i = vam->input;
15908 vl_api_ipsec_tunnel_if_set_key_t *mp;
15909 u32 sw_if_index = ~0;
15910 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
15915 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15917 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15920 if (unformat (i, "local crypto %U", unformat_ipsec_crypto_alg, &alg))
15921 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
15923 if (unformat (i, "remote crypto %U", unformat_ipsec_crypto_alg, &alg))
15924 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
15925 else if (unformat (i, "local integ %U", unformat_ipsec_integ_alg, &alg))
15926 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
15928 if (unformat (i, "remote integ %U", unformat_ipsec_integ_alg, &alg))
15929 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
15930 else if (unformat (i, "%U", unformat_hex_string, &key))
15934 clib_warning ("parse error '%U'", format_unformat_error, i);
15939 if (sw_if_index == ~0)
15941 errmsg ("interface must be specified");
15945 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
15947 errmsg ("key type must be specified");
15953 errmsg ("algorithm must be specified");
15957 if (vec_len (key) == 0)
15959 errmsg ("key must be specified");
15963 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
15965 mp->sw_if_index = htonl (sw_if_index);
15967 mp->key_type = key_type;
15968 mp->key_len = vec_len (key);
15969 clib_memcpy (mp->key, key, vec_len (key));
15978 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
15980 unformat_input_t *i = vam->input;
15981 vl_api_ipsec_tunnel_if_set_sa_t *mp;
15982 u32 sw_if_index = ~0;
15984 u8 is_outbound = (u8) ~ 0;
15987 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15989 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15991 else if (unformat (i, "sa_id %d", &sa_id))
15993 else if (unformat (i, "outbound"))
15995 else if (unformat (i, "inbound"))
15999 clib_warning ("parse error '%U'", format_unformat_error, i);
16004 if (sw_if_index == ~0)
16006 errmsg ("interface must be specified");
16012 errmsg ("SA ID must be specified");
16016 M (IPSEC_TUNNEL_IF_SET_SA, mp);
16018 mp->sw_if_index = htonl (sw_if_index);
16019 mp->sa_id = htonl (sa_id);
16020 mp->is_outbound = is_outbound;
16029 api_ikev2_profile_add_del (vat_main_t * vam)
16031 unformat_input_t *i = vam->input;
16032 vl_api_ikev2_profile_add_del_t *mp;
16037 const char *valid_chars = "a-zA-Z0-9_";
16039 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16041 if (unformat (i, "del"))
16043 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
16044 vec_add1 (name, 0);
16047 errmsg ("parse error '%U'", format_unformat_error, i);
16052 if (!vec_len (name))
16054 errmsg ("profile name must be specified");
16058 if (vec_len (name) > 64)
16060 errmsg ("profile name too long");
16064 M (IKEV2_PROFILE_ADD_DEL, mp);
16066 clib_memcpy (mp->name, name, vec_len (name));
16067 mp->is_add = is_add;
16076 api_ikev2_profile_set_auth (vat_main_t * vam)
16078 unformat_input_t *i = vam->input;
16079 vl_api_ikev2_profile_set_auth_t *mp;
16082 u32 auth_method = 0;
16086 const char *valid_chars = "a-zA-Z0-9_";
16088 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16090 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
16091 vec_add1 (name, 0);
16092 else if (unformat (i, "auth_method %U",
16093 unformat_ikev2_auth_method, &auth_method))
16095 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
16097 else if (unformat (i, "auth_data %v", &data))
16101 errmsg ("parse error '%U'", format_unformat_error, i);
16106 if (!vec_len (name))
16108 errmsg ("profile name must be specified");
16112 if (vec_len (name) > 64)
16114 errmsg ("profile name too long");
16118 if (!vec_len (data))
16120 errmsg ("auth_data must be specified");
16126 errmsg ("auth_method must be specified");
16130 M (IKEV2_PROFILE_SET_AUTH, mp);
16132 mp->is_hex = is_hex;
16133 mp->auth_method = (u8) auth_method;
16134 mp->data_len = vec_len (data);
16135 clib_memcpy (mp->name, name, vec_len (name));
16136 clib_memcpy (mp->data, data, vec_len (data));
16146 api_ikev2_profile_set_id (vat_main_t * vam)
16148 unformat_input_t *i = vam->input;
16149 vl_api_ikev2_profile_set_id_t *mp;
16157 const char *valid_chars = "a-zA-Z0-9_";
16159 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16161 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
16162 vec_add1 (name, 0);
16163 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
16165 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
16167 data = vec_new (u8, 4);
16168 clib_memcpy (data, ip4.as_u8, 4);
16170 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
16172 else if (unformat (i, "id_data %v", &data))
16174 else if (unformat (i, "local"))
16176 else if (unformat (i, "remote"))
16180 errmsg ("parse error '%U'", format_unformat_error, i);
16185 if (!vec_len (name))
16187 errmsg ("profile name must be specified");
16191 if (vec_len (name) > 64)
16193 errmsg ("profile name too long");
16197 if (!vec_len (data))
16199 errmsg ("id_data must be specified");
16205 errmsg ("id_type must be specified");
16209 M (IKEV2_PROFILE_SET_ID, mp);
16211 mp->is_local = is_local;
16212 mp->id_type = (u8) id_type;
16213 mp->data_len = vec_len (data);
16214 clib_memcpy (mp->name, name, vec_len (name));
16215 clib_memcpy (mp->data, data, vec_len (data));
16225 api_ikev2_profile_set_ts (vat_main_t * vam)
16227 unformat_input_t *i = vam->input;
16228 vl_api_ikev2_profile_set_ts_t *mp;
16231 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
16232 ip4_address_t start_addr, end_addr;
16234 const char *valid_chars = "a-zA-Z0-9_";
16237 start_addr.as_u32 = 0;
16238 end_addr.as_u32 = (u32) ~ 0;
16240 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16242 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
16243 vec_add1 (name, 0);
16244 else if (unformat (i, "protocol %d", &proto))
16246 else if (unformat (i, "start_port %d", &start_port))
16248 else if (unformat (i, "end_port %d", &end_port))
16251 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
16253 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
16255 else if (unformat (i, "local"))
16257 else if (unformat (i, "remote"))
16261 errmsg ("parse error '%U'", format_unformat_error, i);
16266 if (!vec_len (name))
16268 errmsg ("profile name must be specified");
16272 if (vec_len (name) > 64)
16274 errmsg ("profile name too long");
16278 M (IKEV2_PROFILE_SET_TS, mp);
16280 mp->is_local = is_local;
16281 mp->proto = (u8) proto;
16282 mp->start_port = (u16) start_port;
16283 mp->end_port = (u16) end_port;
16284 mp->start_addr = start_addr.as_u32;
16285 mp->end_addr = end_addr.as_u32;
16286 clib_memcpy (mp->name, name, vec_len (name));
16295 api_ikev2_set_local_key (vat_main_t * vam)
16297 unformat_input_t *i = vam->input;
16298 vl_api_ikev2_set_local_key_t *mp;
16302 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16304 if (unformat (i, "file %v", &file))
16305 vec_add1 (file, 0);
16308 errmsg ("parse error '%U'", format_unformat_error, i);
16313 if (!vec_len (file))
16315 errmsg ("RSA key file must be specified");
16319 if (vec_len (file) > 256)
16321 errmsg ("file name too long");
16325 M (IKEV2_SET_LOCAL_KEY, mp);
16327 clib_memcpy (mp->key_file, file, vec_len (file));
16336 api_ikev2_set_responder (vat_main_t * vam)
16338 unformat_input_t *i = vam->input;
16339 vl_api_ikev2_set_responder_t *mp;
16342 u32 sw_if_index = ~0;
16343 ip4_address_t address;
16345 const char *valid_chars = "a-zA-Z0-9_";
16347 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16350 (i, "%U interface %d address %U", unformat_token, valid_chars,
16351 &name, &sw_if_index, unformat_ip4_address, &address))
16352 vec_add1 (name, 0);
16355 errmsg ("parse error '%U'", format_unformat_error, i);
16360 if (!vec_len (name))
16362 errmsg ("profile name must be specified");
16366 if (vec_len (name) > 64)
16368 errmsg ("profile name too long");
16372 M (IKEV2_SET_RESPONDER, mp);
16374 clib_memcpy (mp->name, name, vec_len (name));
16377 mp->sw_if_index = sw_if_index;
16378 clib_memcpy (mp->address, &address, sizeof (address));
16386 api_ikev2_set_ike_transforms (vat_main_t * vam)
16388 unformat_input_t *i = vam->input;
16389 vl_api_ikev2_set_ike_transforms_t *mp;
16392 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
16394 const char *valid_chars = "a-zA-Z0-9_";
16396 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16398 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
16399 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
16400 vec_add1 (name, 0);
16403 errmsg ("parse error '%U'", format_unformat_error, i);
16408 if (!vec_len (name))
16410 errmsg ("profile name must be specified");
16414 if (vec_len (name) > 64)
16416 errmsg ("profile name too long");
16420 M (IKEV2_SET_IKE_TRANSFORMS, mp);
16422 clib_memcpy (mp->name, name, vec_len (name));
16424 mp->crypto_alg = crypto_alg;
16425 mp->crypto_key_size = crypto_key_size;
16426 mp->integ_alg = integ_alg;
16427 mp->dh_group = dh_group;
16436 api_ikev2_set_esp_transforms (vat_main_t * vam)
16438 unformat_input_t *i = vam->input;
16439 vl_api_ikev2_set_esp_transforms_t *mp;
16442 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
16444 const char *valid_chars = "a-zA-Z0-9_";
16446 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16448 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
16449 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
16450 vec_add1 (name, 0);
16453 errmsg ("parse error '%U'", format_unformat_error, i);
16458 if (!vec_len (name))
16460 errmsg ("profile name must be specified");
16464 if (vec_len (name) > 64)
16466 errmsg ("profile name too long");
16470 M (IKEV2_SET_ESP_TRANSFORMS, mp);
16472 clib_memcpy (mp->name, name, vec_len (name));
16474 mp->crypto_alg = crypto_alg;
16475 mp->crypto_key_size = crypto_key_size;
16476 mp->integ_alg = integ_alg;
16477 mp->dh_group = dh_group;
16485 api_ikev2_set_sa_lifetime (vat_main_t * vam)
16487 unformat_input_t *i = vam->input;
16488 vl_api_ikev2_set_sa_lifetime_t *mp;
16491 u64 lifetime, lifetime_maxdata;
16492 u32 lifetime_jitter, handover;
16494 const char *valid_chars = "a-zA-Z0-9_";
16496 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16498 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
16499 &lifetime, &lifetime_jitter, &handover,
16500 &lifetime_maxdata))
16501 vec_add1 (name, 0);
16504 errmsg ("parse error '%U'", format_unformat_error, i);
16509 if (!vec_len (name))
16511 errmsg ("profile name must be specified");
16515 if (vec_len (name) > 64)
16517 errmsg ("profile name too long");
16521 M (IKEV2_SET_SA_LIFETIME, mp);
16523 clib_memcpy (mp->name, name, vec_len (name));
16525 mp->lifetime = lifetime;
16526 mp->lifetime_jitter = lifetime_jitter;
16527 mp->handover = handover;
16528 mp->lifetime_maxdata = lifetime_maxdata;
16536 api_ikev2_initiate_sa_init (vat_main_t * vam)
16538 unformat_input_t *i = vam->input;
16539 vl_api_ikev2_initiate_sa_init_t *mp;
16543 const char *valid_chars = "a-zA-Z0-9_";
16545 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16547 if (unformat (i, "%U", unformat_token, valid_chars, &name))
16548 vec_add1 (name, 0);
16551 errmsg ("parse error '%U'", format_unformat_error, i);
16556 if (!vec_len (name))
16558 errmsg ("profile name must be specified");
16562 if (vec_len (name) > 64)
16564 errmsg ("profile name too long");
16568 M (IKEV2_INITIATE_SA_INIT, mp);
16570 clib_memcpy (mp->name, name, vec_len (name));
16579 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
16581 unformat_input_t *i = vam->input;
16582 vl_api_ikev2_initiate_del_ike_sa_t *mp;
16587 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16589 if (unformat (i, "%lx", &ispi))
16593 errmsg ("parse error '%U'", format_unformat_error, i);
16598 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
16608 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
16610 unformat_input_t *i = vam->input;
16611 vl_api_ikev2_initiate_del_child_sa_t *mp;
16616 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16618 if (unformat (i, "%x", &ispi))
16622 errmsg ("parse error '%U'", format_unformat_error, i);
16627 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
16637 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
16639 unformat_input_t *i = vam->input;
16640 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
16645 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16647 if (unformat (i, "%x", &ispi))
16651 errmsg ("parse error '%U'", format_unformat_error, i);
16656 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
16666 api_get_first_msg_id (vat_main_t * vam)
16668 vl_api_get_first_msg_id_t *mp;
16669 unformat_input_t *i = vam->input;
16674 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16676 if (unformat (i, "client %s", &name))
16684 errmsg ("missing client name");
16687 vec_add1 (name, 0);
16689 if (vec_len (name) > 63)
16691 errmsg ("client name too long");
16695 M (GET_FIRST_MSG_ID, mp);
16696 clib_memcpy (mp->name, name, vec_len (name));
16703 api_cop_interface_enable_disable (vat_main_t * vam)
16705 unformat_input_t *line_input = vam->input;
16706 vl_api_cop_interface_enable_disable_t *mp;
16707 u32 sw_if_index = ~0;
16708 u8 enable_disable = 1;
16711 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16713 if (unformat (line_input, "disable"))
16714 enable_disable = 0;
16715 if (unformat (line_input, "enable"))
16716 enable_disable = 1;
16717 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16718 vam, &sw_if_index))
16720 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16726 if (sw_if_index == ~0)
16728 errmsg ("missing interface name or sw_if_index");
16732 /* Construct the API message */
16733 M (COP_INTERFACE_ENABLE_DISABLE, mp);
16734 mp->sw_if_index = ntohl (sw_if_index);
16735 mp->enable_disable = enable_disable;
16739 /* Wait for the reply */
16745 api_cop_whitelist_enable_disable (vat_main_t * vam)
16747 unformat_input_t *line_input = vam->input;
16748 vl_api_cop_whitelist_enable_disable_t *mp;
16749 u32 sw_if_index = ~0;
16750 u8 ip4 = 0, ip6 = 0, default_cop = 0;
16754 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16756 if (unformat (line_input, "ip4"))
16758 else if (unformat (line_input, "ip6"))
16760 else if (unformat (line_input, "default"))
16762 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16763 vam, &sw_if_index))
16765 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16767 else if (unformat (line_input, "fib-id %d", &fib_id))
16773 if (sw_if_index == ~0)
16775 errmsg ("missing interface name or sw_if_index");
16779 /* Construct the API message */
16780 M (COP_WHITELIST_ENABLE_DISABLE, mp);
16781 mp->sw_if_index = ntohl (sw_if_index);
16782 mp->fib_id = ntohl (fib_id);
16785 mp->default_cop = default_cop;
16789 /* Wait for the reply */
16795 api_get_node_graph (vat_main_t * vam)
16797 vl_api_get_node_graph_t *mp;
16800 M (GET_NODE_GRAPH, mp);
16804 /* Wait for the reply */
16810 /** Used for parsing LISP eids */
16811 typedef CLIB_PACKED(struct{
16812 u8 addr[16]; /**< eid address */
16813 u32 len; /**< prefix length if IP */
16814 u8 type; /**< type of eid */
16819 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
16821 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
16823 memset (a, 0, sizeof (a[0]));
16825 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
16827 a->type = 0; /* ipv4 type */
16829 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
16831 a->type = 1; /* ipv6 type */
16833 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
16835 a->type = 2; /* mac type */
16837 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
16839 a->type = 3; /* NSH type */
16840 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
16841 nsh->spi = clib_host_to_net_u32 (nsh->spi);
16848 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
16857 lisp_eid_size_vat (u8 type)
16874 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
16876 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
16880 api_one_add_del_locator_set (vat_main_t * vam)
16882 unformat_input_t *input = vam->input;
16883 vl_api_one_add_del_locator_set_t *mp;
16885 u8 *locator_set_name = NULL;
16886 u8 locator_set_name_set = 0;
16887 vl_api_local_locator_t locator, *locators = 0;
16888 u32 sw_if_index, priority, weight;
16892 /* Parse args required to build the message */
16893 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16895 if (unformat (input, "del"))
16899 else if (unformat (input, "locator-set %s", &locator_set_name))
16901 locator_set_name_set = 1;
16903 else if (unformat (input, "sw_if_index %u p %u w %u",
16904 &sw_if_index, &priority, &weight))
16906 locator.sw_if_index = htonl (sw_if_index);
16907 locator.priority = priority;
16908 locator.weight = weight;
16909 vec_add1 (locators, locator);
16913 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
16914 &sw_if_index, &priority, &weight))
16916 locator.sw_if_index = htonl (sw_if_index);
16917 locator.priority = priority;
16918 locator.weight = weight;
16919 vec_add1 (locators, locator);
16925 if (locator_set_name_set == 0)
16927 errmsg ("missing locator-set name");
16928 vec_free (locators);
16932 if (vec_len (locator_set_name) > 64)
16934 errmsg ("locator-set name too long");
16935 vec_free (locator_set_name);
16936 vec_free (locators);
16939 vec_add1 (locator_set_name, 0);
16941 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
16943 /* Construct the API message */
16944 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
16946 mp->is_add = is_add;
16947 clib_memcpy (mp->locator_set_name, locator_set_name,
16948 vec_len (locator_set_name));
16949 vec_free (locator_set_name);
16951 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
16953 clib_memcpy (mp->locators, locators, data_len);
16954 vec_free (locators);
16959 /* Wait for a reply... */
16964 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
16967 api_one_add_del_locator (vat_main_t * vam)
16969 unformat_input_t *input = vam->input;
16970 vl_api_one_add_del_locator_t *mp;
16971 u32 tmp_if_index = ~0;
16972 u32 sw_if_index = ~0;
16973 u8 sw_if_index_set = 0;
16974 u8 sw_if_index_if_name_set = 0;
16976 u8 priority_set = 0;
16980 u8 *locator_set_name = NULL;
16981 u8 locator_set_name_set = 0;
16984 /* Parse args required to build the message */
16985 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16987 if (unformat (input, "del"))
16991 else if (unformat (input, "locator-set %s", &locator_set_name))
16993 locator_set_name_set = 1;
16995 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
16998 sw_if_index_if_name_set = 1;
16999 sw_if_index = tmp_if_index;
17001 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
17003 sw_if_index_set = 1;
17004 sw_if_index = tmp_if_index;
17006 else if (unformat (input, "p %d", &priority))
17010 else if (unformat (input, "w %d", &weight))
17018 if (locator_set_name_set == 0)
17020 errmsg ("missing locator-set name");
17024 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
17026 errmsg ("missing sw_if_index");
17027 vec_free (locator_set_name);
17031 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
17033 errmsg ("cannot use both params interface name and sw_if_index");
17034 vec_free (locator_set_name);
17038 if (priority_set == 0)
17040 errmsg ("missing locator-set priority");
17041 vec_free (locator_set_name);
17045 if (weight_set == 0)
17047 errmsg ("missing locator-set weight");
17048 vec_free (locator_set_name);
17052 if (vec_len (locator_set_name) > 64)
17054 errmsg ("locator-set name too long");
17055 vec_free (locator_set_name);
17058 vec_add1 (locator_set_name, 0);
17060 /* Construct the API message */
17061 M (ONE_ADD_DEL_LOCATOR, mp);
17063 mp->is_add = is_add;
17064 mp->sw_if_index = ntohl (sw_if_index);
17065 mp->priority = priority;
17066 mp->weight = weight;
17067 clib_memcpy (mp->locator_set_name, locator_set_name,
17068 vec_len (locator_set_name));
17069 vec_free (locator_set_name);
17074 /* Wait for a reply... */
17079 #define api_lisp_add_del_locator api_one_add_del_locator
17082 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
17084 u32 *key_id = va_arg (*args, u32 *);
17087 if (unformat (input, "%s", &s))
17089 if (!strcmp ((char *) s, "sha1"))
17090 key_id[0] = HMAC_SHA_1_96;
17091 else if (!strcmp ((char *) s, "sha256"))
17092 key_id[0] = HMAC_SHA_256_128;
17095 clib_warning ("invalid key_id: '%s'", s);
17096 key_id[0] = HMAC_NO_KEY;
17107 api_one_add_del_local_eid (vat_main_t * vam)
17109 unformat_input_t *input = vam->input;
17110 vl_api_one_add_del_local_eid_t *mp;
17113 lisp_eid_vat_t _eid, *eid = &_eid;
17114 u8 *locator_set_name = 0;
17115 u8 locator_set_name_set = 0;
17121 /* Parse args required to build the message */
17122 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17124 if (unformat (input, "del"))
17128 else if (unformat (input, "vni %d", &vni))
17132 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
17136 else if (unformat (input, "locator-set %s", &locator_set_name))
17138 locator_set_name_set = 1;
17140 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
17142 else if (unformat (input, "secret-key %_%v%_", &key))
17148 if (locator_set_name_set == 0)
17150 errmsg ("missing locator-set name");
17156 errmsg ("EID address not set!");
17157 vec_free (locator_set_name);
17161 if (key && (0 == key_id))
17163 errmsg ("invalid key_id!");
17167 if (vec_len (key) > 64)
17169 errmsg ("key too long");
17174 if (vec_len (locator_set_name) > 64)
17176 errmsg ("locator-set name too long");
17177 vec_free (locator_set_name);
17180 vec_add1 (locator_set_name, 0);
17182 /* Construct the API message */
17183 M (ONE_ADD_DEL_LOCAL_EID, mp);
17185 mp->is_add = is_add;
17186 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
17187 mp->eid_type = eid->type;
17188 mp->prefix_len = eid->len;
17189 mp->vni = clib_host_to_net_u32 (vni);
17190 mp->key_id = clib_host_to_net_u16 (key_id);
17191 clib_memcpy (mp->locator_set_name, locator_set_name,
17192 vec_len (locator_set_name));
17193 clib_memcpy (mp->key, key, vec_len (key));
17195 vec_free (locator_set_name);
17201 /* Wait for a reply... */
17206 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
17209 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
17211 u32 dp_table = 0, vni = 0;;
17212 unformat_input_t *input = vam->input;
17213 vl_api_gpe_add_del_fwd_entry_t *mp;
17215 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
17216 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
17217 u8 rmt_eid_set = 0, lcl_eid_set = 0;
17218 u32 action = ~0, w;
17219 ip4_address_t rmt_rloc4, lcl_rloc4;
17220 ip6_address_t rmt_rloc6, lcl_rloc6;
17221 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
17224 memset (&rloc, 0, sizeof (rloc));
17226 /* Parse args required to build the message */
17227 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17229 if (unformat (input, "del"))
17231 else if (unformat (input, "add"))
17233 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
17237 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
17241 else if (unformat (input, "vrf %d", &dp_table))
17243 else if (unformat (input, "bd %d", &dp_table))
17245 else if (unformat (input, "vni %d", &vni))
17247 else if (unformat (input, "w %d", &w))
17251 errmsg ("No RLOC configured for setting priority/weight!");
17254 curr_rloc->weight = w;
17256 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
17257 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
17261 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
17263 vec_add1 (lcl_locs, rloc);
17265 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
17266 vec_add1 (rmt_locs, rloc);
17267 /* weight saved in rmt loc */
17268 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
17270 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
17271 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
17274 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
17276 vec_add1 (lcl_locs, rloc);
17278 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
17279 vec_add1 (rmt_locs, rloc);
17280 /* weight saved in rmt loc */
17281 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
17283 else if (unformat (input, "action %d", &action))
17289 clib_warning ("parse error '%U'", format_unformat_error, input);
17296 errmsg ("remote eid addresses not set");
17300 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
17302 errmsg ("eid types don't match");
17306 if (0 == rmt_locs && (u32) ~ 0 == action)
17308 errmsg ("action not set for negative mapping");
17312 /* Construct the API message */
17313 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
17314 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
17316 mp->is_add = is_add;
17317 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
17318 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
17319 mp->eid_type = rmt_eid->type;
17320 mp->dp_table = clib_host_to_net_u32 (dp_table);
17321 mp->vni = clib_host_to_net_u32 (vni);
17322 mp->rmt_len = rmt_eid->len;
17323 mp->lcl_len = lcl_eid->len;
17324 mp->action = action;
17326 if (0 != rmt_locs && 0 != lcl_locs)
17328 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
17329 clib_memcpy (mp->locs, lcl_locs,
17330 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
17332 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
17333 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
17334 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
17336 vec_free (lcl_locs);
17337 vec_free (rmt_locs);
17342 /* Wait for a reply... */
17348 api_one_add_del_map_server (vat_main_t * vam)
17350 unformat_input_t *input = vam->input;
17351 vl_api_one_add_del_map_server_t *mp;
17355 ip4_address_t ipv4;
17356 ip6_address_t ipv6;
17359 /* Parse args required to build the message */
17360 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17362 if (unformat (input, "del"))
17366 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17370 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17378 if (ipv4_set && ipv6_set)
17380 errmsg ("both eid v4 and v6 addresses set");
17384 if (!ipv4_set && !ipv6_set)
17386 errmsg ("eid addresses not set");
17390 /* Construct the API message */
17391 M (ONE_ADD_DEL_MAP_SERVER, mp);
17393 mp->is_add = is_add;
17397 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17402 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17408 /* Wait for a reply... */
17413 #define api_lisp_add_del_map_server api_one_add_del_map_server
17416 api_one_add_del_map_resolver (vat_main_t * vam)
17418 unformat_input_t *input = vam->input;
17419 vl_api_one_add_del_map_resolver_t *mp;
17423 ip4_address_t ipv4;
17424 ip6_address_t ipv6;
17427 /* Parse args required to build the message */
17428 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17430 if (unformat (input, "del"))
17434 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17438 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17446 if (ipv4_set && ipv6_set)
17448 errmsg ("both eid v4 and v6 addresses set");
17452 if (!ipv4_set && !ipv6_set)
17454 errmsg ("eid addresses not set");
17458 /* Construct the API message */
17459 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
17461 mp->is_add = is_add;
17465 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17470 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17476 /* Wait for a reply... */
17481 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
17484 api_lisp_gpe_enable_disable (vat_main_t * vam)
17486 unformat_input_t *input = vam->input;
17487 vl_api_gpe_enable_disable_t *mp;
17492 /* Parse args required to build the message */
17493 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17495 if (unformat (input, "enable"))
17500 else if (unformat (input, "disable"))
17511 errmsg ("Value not set");
17515 /* Construct the API message */
17516 M (GPE_ENABLE_DISABLE, mp);
17523 /* Wait for a reply... */
17529 api_one_rloc_probe_enable_disable (vat_main_t * vam)
17531 unformat_input_t *input = vam->input;
17532 vl_api_one_rloc_probe_enable_disable_t *mp;
17537 /* Parse args required to build the message */
17538 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17540 if (unformat (input, "enable"))
17545 else if (unformat (input, "disable"))
17553 errmsg ("Value not set");
17557 /* Construct the API message */
17558 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
17560 mp->is_enabled = is_en;
17565 /* Wait for a reply... */
17570 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
17573 api_one_map_register_enable_disable (vat_main_t * vam)
17575 unformat_input_t *input = vam->input;
17576 vl_api_one_map_register_enable_disable_t *mp;
17581 /* Parse args required to build the message */
17582 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17584 if (unformat (input, "enable"))
17589 else if (unformat (input, "disable"))
17597 errmsg ("Value not set");
17601 /* Construct the API message */
17602 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
17604 mp->is_enabled = is_en;
17609 /* Wait for a reply... */
17614 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
17617 api_one_enable_disable (vat_main_t * vam)
17619 unformat_input_t *input = vam->input;
17620 vl_api_one_enable_disable_t *mp;
17625 /* Parse args required to build the message */
17626 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17628 if (unformat (input, "enable"))
17633 else if (unformat (input, "disable"))
17643 errmsg ("Value not set");
17647 /* Construct the API message */
17648 M (ONE_ENABLE_DISABLE, mp);
17655 /* Wait for a reply... */
17660 #define api_lisp_enable_disable api_one_enable_disable
17663 api_one_enable_disable_xtr_mode (vat_main_t * vam)
17665 unformat_input_t *input = vam->input;
17666 vl_api_one_enable_disable_xtr_mode_t *mp;
17671 /* Parse args required to build the message */
17672 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17674 if (unformat (input, "enable"))
17679 else if (unformat (input, "disable"))
17689 errmsg ("Value not set");
17693 /* Construct the API message */
17694 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
17701 /* Wait for a reply... */
17707 api_one_show_xtr_mode (vat_main_t * vam)
17709 vl_api_one_show_xtr_mode_t *mp;
17712 /* Construct the API message */
17713 M (ONE_SHOW_XTR_MODE, mp);
17718 /* Wait for a reply... */
17724 api_one_enable_disable_pitr_mode (vat_main_t * vam)
17726 unformat_input_t *input = vam->input;
17727 vl_api_one_enable_disable_pitr_mode_t *mp;
17732 /* Parse args required to build the message */
17733 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17735 if (unformat (input, "enable"))
17740 else if (unformat (input, "disable"))
17750 errmsg ("Value not set");
17754 /* Construct the API message */
17755 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
17762 /* Wait for a reply... */
17768 api_one_show_pitr_mode (vat_main_t * vam)
17770 vl_api_one_show_pitr_mode_t *mp;
17773 /* Construct the API message */
17774 M (ONE_SHOW_PITR_MODE, mp);
17779 /* Wait for a reply... */
17785 api_one_enable_disable_petr_mode (vat_main_t * vam)
17787 unformat_input_t *input = vam->input;
17788 vl_api_one_enable_disable_petr_mode_t *mp;
17793 /* Parse args required to build the message */
17794 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17796 if (unformat (input, "enable"))
17801 else if (unformat (input, "disable"))
17811 errmsg ("Value not set");
17815 /* Construct the API message */
17816 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
17823 /* Wait for a reply... */
17829 api_one_show_petr_mode (vat_main_t * vam)
17831 vl_api_one_show_petr_mode_t *mp;
17834 /* Construct the API message */
17835 M (ONE_SHOW_PETR_MODE, mp);
17840 /* Wait for a reply... */
17846 api_show_one_map_register_state (vat_main_t * vam)
17848 vl_api_show_one_map_register_state_t *mp;
17851 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
17856 /* wait for reply */
17861 #define api_show_lisp_map_register_state api_show_one_map_register_state
17864 api_show_one_rloc_probe_state (vat_main_t * vam)
17866 vl_api_show_one_rloc_probe_state_t *mp;
17869 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
17874 /* wait for reply */
17879 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
17882 api_one_add_del_ndp_entry (vat_main_t * vam)
17884 vl_api_one_add_del_ndp_entry_t *mp;
17885 unformat_input_t *input = vam->input;
17890 u8 mac[6] = { 0, };
17891 u8 ip6[16] = { 0, };
17895 /* Parse args required to build the message */
17896 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17898 if (unformat (input, "del"))
17900 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17902 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
17904 else if (unformat (input, "bd %d", &bd))
17908 errmsg ("parse error '%U'", format_unformat_error, input);
17913 if (!bd_set || !ip_set || (!mac_set && is_add))
17915 errmsg ("Missing BD, IP or MAC!");
17919 M (ONE_ADD_DEL_NDP_ENTRY, mp);
17920 mp->is_add = is_add;
17921 clib_memcpy (mp->mac, mac, 6);
17922 mp->bd = clib_host_to_net_u32 (bd);
17923 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
17928 /* wait for reply */
17934 api_one_add_del_l2_arp_entry (vat_main_t * vam)
17936 vl_api_one_add_del_l2_arp_entry_t *mp;
17937 unformat_input_t *input = vam->input;
17942 u8 mac[6] = { 0, };
17943 u32 ip4 = 0, bd = ~0;
17946 /* Parse args required to build the message */
17947 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17949 if (unformat (input, "del"))
17951 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17953 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
17955 else if (unformat (input, "bd %d", &bd))
17959 errmsg ("parse error '%U'", format_unformat_error, input);
17964 if (!bd_set || !ip_set || (!mac_set && is_add))
17966 errmsg ("Missing BD, IP or MAC!");
17970 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
17971 mp->is_add = is_add;
17972 clib_memcpy (mp->mac, mac, 6);
17973 mp->bd = clib_host_to_net_u32 (bd);
17979 /* wait for reply */
17985 api_one_ndp_bd_get (vat_main_t * vam)
17987 vl_api_one_ndp_bd_get_t *mp;
17990 M (ONE_NDP_BD_GET, mp);
17995 /* wait for reply */
18001 api_one_ndp_entries_get (vat_main_t * vam)
18003 vl_api_one_ndp_entries_get_t *mp;
18004 unformat_input_t *input = vam->input;
18009 /* Parse args required to build the message */
18010 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18012 if (unformat (input, "bd %d", &bd))
18016 errmsg ("parse error '%U'", format_unformat_error, input);
18023 errmsg ("Expected bridge domain!");
18027 M (ONE_NDP_ENTRIES_GET, mp);
18028 mp->bd = clib_host_to_net_u32 (bd);
18033 /* wait for reply */
18039 api_one_l2_arp_bd_get (vat_main_t * vam)
18041 vl_api_one_l2_arp_bd_get_t *mp;
18044 M (ONE_L2_ARP_BD_GET, mp);
18049 /* wait for reply */
18055 api_one_l2_arp_entries_get (vat_main_t * vam)
18057 vl_api_one_l2_arp_entries_get_t *mp;
18058 unformat_input_t *input = vam->input;
18063 /* Parse args required to build the message */
18064 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18066 if (unformat (input, "bd %d", &bd))
18070 errmsg ("parse error '%U'", format_unformat_error, input);
18077 errmsg ("Expected bridge domain!");
18081 M (ONE_L2_ARP_ENTRIES_GET, mp);
18082 mp->bd = clib_host_to_net_u32 (bd);
18087 /* wait for reply */
18093 api_one_stats_enable_disable (vat_main_t * vam)
18095 vl_api_one_stats_enable_disable_t *mp;
18096 unformat_input_t *input = vam->input;
18101 /* Parse args required to build the message */
18102 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18104 if (unformat (input, "enable"))
18109 else if (unformat (input, "disable"))
18119 errmsg ("Value not set");
18123 M (ONE_STATS_ENABLE_DISABLE, mp);
18129 /* wait for reply */
18135 api_show_one_stats_enable_disable (vat_main_t * vam)
18137 vl_api_show_one_stats_enable_disable_t *mp;
18140 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
18145 /* wait for reply */
18151 api_show_one_map_request_mode (vat_main_t * vam)
18153 vl_api_show_one_map_request_mode_t *mp;
18156 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
18161 /* wait for reply */
18166 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
18169 api_one_map_request_mode (vat_main_t * vam)
18171 unformat_input_t *input = vam->input;
18172 vl_api_one_map_request_mode_t *mp;
18176 /* Parse args required to build the message */
18177 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18179 if (unformat (input, "dst-only"))
18181 else if (unformat (input, "src-dst"))
18185 errmsg ("parse error '%U'", format_unformat_error, input);
18190 M (ONE_MAP_REQUEST_MODE, mp);
18197 /* wait for reply */
18202 #define api_lisp_map_request_mode api_one_map_request_mode
18205 * Enable/disable ONE proxy ITR.
18207 * @param vam vpp API test context
18208 * @return return code
18211 api_one_pitr_set_locator_set (vat_main_t * vam)
18213 u8 ls_name_set = 0;
18214 unformat_input_t *input = vam->input;
18215 vl_api_one_pitr_set_locator_set_t *mp;
18220 /* Parse args required to build the message */
18221 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18223 if (unformat (input, "del"))
18225 else if (unformat (input, "locator-set %s", &ls_name))
18229 errmsg ("parse error '%U'", format_unformat_error, input);
18236 errmsg ("locator-set name not set!");
18240 M (ONE_PITR_SET_LOCATOR_SET, mp);
18242 mp->is_add = is_add;
18243 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
18244 vec_free (ls_name);
18249 /* wait for reply */
18254 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
18257 api_one_nsh_set_locator_set (vat_main_t * vam)
18259 u8 ls_name_set = 0;
18260 unformat_input_t *input = vam->input;
18261 vl_api_one_nsh_set_locator_set_t *mp;
18266 /* Parse args required to build the message */
18267 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18269 if (unformat (input, "del"))
18271 else if (unformat (input, "ls %s", &ls_name))
18275 errmsg ("parse error '%U'", format_unformat_error, input);
18280 if (!ls_name_set && is_add)
18282 errmsg ("locator-set name not set!");
18286 M (ONE_NSH_SET_LOCATOR_SET, mp);
18288 mp->is_add = is_add;
18289 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
18290 vec_free (ls_name);
18295 /* wait for reply */
18301 api_show_one_pitr (vat_main_t * vam)
18303 vl_api_show_one_pitr_t *mp;
18306 if (!vam->json_output)
18308 print (vam->ofp, "%=20s", "lisp status:");
18311 M (SHOW_ONE_PITR, mp);
18315 /* Wait for a reply... */
18320 #define api_show_lisp_pitr api_show_one_pitr
18323 api_one_use_petr (vat_main_t * vam)
18325 unformat_input_t *input = vam->input;
18326 vl_api_one_use_petr_t *mp;
18331 memset (&ip, 0, sizeof (ip));
18333 /* Parse args required to build the message */
18334 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18336 if (unformat (input, "disable"))
18339 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
18342 ip_addr_version (&ip) = IP4;
18345 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
18348 ip_addr_version (&ip) = IP6;
18352 errmsg ("parse error '%U'", format_unformat_error, input);
18357 M (ONE_USE_PETR, mp);
18359 mp->is_add = is_add;
18362 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
18364 clib_memcpy (mp->address, &ip, 4);
18366 clib_memcpy (mp->address, &ip, 16);
18372 /* wait for reply */
18377 #define api_lisp_use_petr api_one_use_petr
18380 api_show_one_nsh_mapping (vat_main_t * vam)
18382 vl_api_show_one_use_petr_t *mp;
18385 if (!vam->json_output)
18387 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
18390 M (SHOW_ONE_NSH_MAPPING, mp);
18394 /* Wait for a reply... */
18400 api_show_one_use_petr (vat_main_t * vam)
18402 vl_api_show_one_use_petr_t *mp;
18405 if (!vam->json_output)
18407 print (vam->ofp, "%=20s", "Proxy-ETR status:");
18410 M (SHOW_ONE_USE_PETR, mp);
18414 /* Wait for a reply... */
18419 #define api_show_lisp_use_petr api_show_one_use_petr
18422 * Add/delete mapping between vni and vrf
18425 api_one_eid_table_add_del_map (vat_main_t * vam)
18427 unformat_input_t *input = vam->input;
18428 vl_api_one_eid_table_add_del_map_t *mp;
18429 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
18430 u32 vni, vrf, bd_index;
18433 /* Parse args required to build the message */
18434 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18436 if (unformat (input, "del"))
18438 else if (unformat (input, "vrf %d", &vrf))
18440 else if (unformat (input, "bd_index %d", &bd_index))
18442 else if (unformat (input, "vni %d", &vni))
18448 if (!vni_set || (!vrf_set && !bd_index_set))
18450 errmsg ("missing arguments!");
18454 if (vrf_set && bd_index_set)
18456 errmsg ("error: both vrf and bd entered!");
18460 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
18462 mp->is_add = is_add;
18463 mp->vni = htonl (vni);
18464 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
18465 mp->is_l2 = bd_index_set;
18470 /* wait for reply */
18475 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
18478 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
18480 u32 *action = va_arg (*args, u32 *);
18483 if (unformat (input, "%s", &s))
18485 if (!strcmp ((char *) s, "no-action"))
18487 else if (!strcmp ((char *) s, "natively-forward"))
18489 else if (!strcmp ((char *) s, "send-map-request"))
18491 else if (!strcmp ((char *) s, "drop"))
18495 clib_warning ("invalid action: '%s'", s);
18507 * Add/del remote mapping to/from ONE control plane
18509 * @param vam vpp API test context
18510 * @return return code
18513 api_one_add_del_remote_mapping (vat_main_t * vam)
18515 unformat_input_t *input = vam->input;
18516 vl_api_one_add_del_remote_mapping_t *mp;
18518 lisp_eid_vat_t _eid, *eid = &_eid;
18519 lisp_eid_vat_t _seid, *seid = &_seid;
18520 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
18521 u32 action = ~0, p, w, data_len;
18522 ip4_address_t rloc4;
18523 ip6_address_t rloc6;
18524 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
18527 memset (&rloc, 0, sizeof (rloc));
18529 /* Parse args required to build the message */
18530 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18532 if (unformat (input, "del-all"))
18536 else if (unformat (input, "del"))
18540 else if (unformat (input, "add"))
18544 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
18548 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
18552 else if (unformat (input, "vni %d", &vni))
18556 else if (unformat (input, "p %d w %d", &p, &w))
18560 errmsg ("No RLOC configured for setting priority/weight!");
18563 curr_rloc->priority = p;
18564 curr_rloc->weight = w;
18566 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
18569 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
18570 vec_add1 (rlocs, rloc);
18571 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18573 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
18576 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
18577 vec_add1 (rlocs, rloc);
18578 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18580 else if (unformat (input, "action %U",
18581 unformat_negative_mapping_action, &action))
18587 clib_warning ("parse error '%U'", format_unformat_error, input);
18594 errmsg ("missing params!");
18598 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
18600 errmsg ("no action set for negative map-reply!");
18604 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
18606 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
18607 mp->is_add = is_add;
18608 mp->vni = htonl (vni);
18609 mp->action = (u8) action;
18610 mp->is_src_dst = seid_set;
18611 mp->eid_len = eid->len;
18612 mp->seid_len = seid->len;
18613 mp->del_all = del_all;
18614 mp->eid_type = eid->type;
18615 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
18616 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
18618 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
18619 clib_memcpy (mp->rlocs, rlocs, data_len);
18625 /* Wait for a reply... */
18630 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
18633 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
18634 * forwarding entries in data-plane accordingly.
18636 * @param vam vpp API test context
18637 * @return return code
18640 api_one_add_del_adjacency (vat_main_t * vam)
18642 unformat_input_t *input = vam->input;
18643 vl_api_one_add_del_adjacency_t *mp;
18645 ip4_address_t leid4, reid4;
18646 ip6_address_t leid6, reid6;
18647 u8 reid_mac[6] = { 0 };
18648 u8 leid_mac[6] = { 0 };
18649 u8 reid_type, leid_type;
18650 u32 leid_len = 0, reid_len = 0, len;
18654 leid_type = reid_type = (u8) ~ 0;
18656 /* Parse args required to build the message */
18657 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18659 if (unformat (input, "del"))
18663 else if (unformat (input, "add"))
18667 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
18670 reid_type = 0; /* ipv4 */
18673 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
18676 reid_type = 1; /* ipv6 */
18679 else if (unformat (input, "reid %U", unformat_ethernet_address,
18682 reid_type = 2; /* mac */
18684 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
18687 leid_type = 0; /* ipv4 */
18690 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
18693 leid_type = 1; /* ipv6 */
18696 else if (unformat (input, "leid %U", unformat_ethernet_address,
18699 leid_type = 2; /* mac */
18701 else if (unformat (input, "vni %d", &vni))
18707 errmsg ("parse error '%U'", format_unformat_error, input);
18712 if ((u8) ~ 0 == reid_type)
18714 errmsg ("missing params!");
18718 if (leid_type != reid_type)
18720 errmsg ("remote and local EIDs are of different types!");
18724 M (ONE_ADD_DEL_ADJACENCY, mp);
18725 mp->is_add = is_add;
18726 mp->vni = htonl (vni);
18727 mp->leid_len = leid_len;
18728 mp->reid_len = reid_len;
18729 mp->eid_type = reid_type;
18731 switch (mp->eid_type)
18734 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
18735 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
18738 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
18739 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
18742 clib_memcpy (mp->leid, leid_mac, 6);
18743 clib_memcpy (mp->reid, reid_mac, 6);
18746 errmsg ("unknown EID type %d!", mp->eid_type);
18753 /* Wait for a reply... */
18758 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
18761 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
18763 u32 *mode = va_arg (*args, u32 *);
18765 if (unformat (input, "lisp"))
18767 else if (unformat (input, "vxlan"))
18776 api_gpe_get_encap_mode (vat_main_t * vam)
18778 vl_api_gpe_get_encap_mode_t *mp;
18781 /* Construct the API message */
18782 M (GPE_GET_ENCAP_MODE, mp);
18787 /* Wait for a reply... */
18793 api_gpe_set_encap_mode (vat_main_t * vam)
18795 unformat_input_t *input = vam->input;
18796 vl_api_gpe_set_encap_mode_t *mp;
18800 /* Parse args required to build the message */
18801 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18803 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
18809 /* Construct the API message */
18810 M (GPE_SET_ENCAP_MODE, mp);
18817 /* Wait for a reply... */
18823 api_lisp_gpe_add_del_iface (vat_main_t * vam)
18825 unformat_input_t *input = vam->input;
18826 vl_api_gpe_add_del_iface_t *mp;
18827 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
18828 u32 dp_table = 0, vni = 0;
18831 /* Parse args required to build the message */
18832 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18834 if (unformat (input, "up"))
18839 else if (unformat (input, "down"))
18844 else if (unformat (input, "table_id %d", &dp_table))
18848 else if (unformat (input, "bd_id %d", &dp_table))
18853 else if (unformat (input, "vni %d", &vni))
18861 if (action_set == 0)
18863 errmsg ("Action not set");
18866 if (dp_table_set == 0 || vni_set == 0)
18868 errmsg ("vni and dp_table must be set");
18872 /* Construct the API message */
18873 M (GPE_ADD_DEL_IFACE, mp);
18875 mp->is_add = is_add;
18876 mp->dp_table = clib_host_to_net_u32 (dp_table);
18878 mp->vni = clib_host_to_net_u32 (vni);
18883 /* Wait for a reply... */
18889 api_one_map_register_fallback_threshold (vat_main_t * vam)
18891 unformat_input_t *input = vam->input;
18892 vl_api_one_map_register_fallback_threshold_t *mp;
18897 /* Parse args required to build the message */
18898 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18900 if (unformat (input, "%u", &value))
18904 clib_warning ("parse error '%U'", format_unformat_error, input);
18911 errmsg ("fallback threshold value is missing!");
18915 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18916 mp->value = clib_host_to_net_u32 (value);
18921 /* Wait for a reply... */
18927 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
18929 vl_api_show_one_map_register_fallback_threshold_t *mp;
18932 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18937 /* Wait for a reply... */
18943 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
18945 u32 *proto = va_arg (*args, u32 *);
18947 if (unformat (input, "udp"))
18949 else if (unformat (input, "api"))
18958 api_one_set_transport_protocol (vat_main_t * vam)
18960 unformat_input_t *input = vam->input;
18961 vl_api_one_set_transport_protocol_t *mp;
18966 /* Parse args required to build the message */
18967 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18969 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
18973 clib_warning ("parse error '%U'", format_unformat_error, input);
18980 errmsg ("Transport protocol missing!");
18984 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
18985 mp->protocol = (u8) protocol;
18990 /* Wait for a reply... */
18996 api_one_get_transport_protocol (vat_main_t * vam)
18998 vl_api_one_get_transport_protocol_t *mp;
19001 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
19006 /* Wait for a reply... */
19012 api_one_map_register_set_ttl (vat_main_t * vam)
19014 unformat_input_t *input = vam->input;
19015 vl_api_one_map_register_set_ttl_t *mp;
19020 /* Parse args required to build the message */
19021 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19023 if (unformat (input, "%u", &ttl))
19027 clib_warning ("parse error '%U'", format_unformat_error, input);
19034 errmsg ("TTL value missing!");
19038 M (ONE_MAP_REGISTER_SET_TTL, mp);
19039 mp->ttl = clib_host_to_net_u32 (ttl);
19044 /* Wait for a reply... */
19050 api_show_one_map_register_ttl (vat_main_t * vam)
19052 vl_api_show_one_map_register_ttl_t *mp;
19055 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
19060 /* Wait for a reply... */
19066 * Add/del map request itr rlocs from ONE control plane and updates
19068 * @param vam vpp API test context
19069 * @return return code
19072 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
19074 unformat_input_t *input = vam->input;
19075 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
19076 u8 *locator_set_name = 0;
19077 u8 locator_set_name_set = 0;
19081 /* Parse args required to build the message */
19082 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19084 if (unformat (input, "del"))
19088 else if (unformat (input, "%_%v%_", &locator_set_name))
19090 locator_set_name_set = 1;
19094 clib_warning ("parse error '%U'", format_unformat_error, input);
19099 if (is_add && !locator_set_name_set)
19101 errmsg ("itr-rloc is not set!");
19105 if (is_add && vec_len (locator_set_name) > 64)
19107 errmsg ("itr-rloc locator-set name too long");
19108 vec_free (locator_set_name);
19112 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
19113 mp->is_add = is_add;
19116 clib_memcpy (mp->locator_set_name, locator_set_name,
19117 vec_len (locator_set_name));
19121 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
19123 vec_free (locator_set_name);
19128 /* Wait for a reply... */
19133 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
19136 api_one_locator_dump (vat_main_t * vam)
19138 unformat_input_t *input = vam->input;
19139 vl_api_one_locator_dump_t *mp;
19140 vl_api_control_ping_t *mp_ping;
19141 u8 is_index_set = 0, is_name_set = 0;
19146 /* Parse args required to build the message */
19147 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19149 if (unformat (input, "ls_name %_%v%_", &ls_name))
19153 else if (unformat (input, "ls_index %d", &ls_index))
19159 errmsg ("parse error '%U'", format_unformat_error, input);
19164 if (!is_index_set && !is_name_set)
19166 errmsg ("error: expected one of index or name!");
19170 if (is_index_set && is_name_set)
19172 errmsg ("error: only one param expected!");
19176 if (vec_len (ls_name) > 62)
19178 errmsg ("error: locator set name too long!");
19182 if (!vam->json_output)
19184 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
19187 M (ONE_LOCATOR_DUMP, mp);
19188 mp->is_index_set = is_index_set;
19191 mp->ls_index = clib_host_to_net_u32 (ls_index);
19194 vec_add1 (ls_name, 0);
19195 strncpy ((char *) mp->ls_name, (char *) ls_name,
19196 sizeof (mp->ls_name) - 1);
19202 /* Use a control ping for synchronization */
19203 MPING (CONTROL_PING, mp_ping);
19206 /* Wait for a reply... */
19211 #define api_lisp_locator_dump api_one_locator_dump
19214 api_one_locator_set_dump (vat_main_t * vam)
19216 vl_api_one_locator_set_dump_t *mp;
19217 vl_api_control_ping_t *mp_ping;
19218 unformat_input_t *input = vam->input;
19222 /* Parse args required to build the message */
19223 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19225 if (unformat (input, "local"))
19229 else if (unformat (input, "remote"))
19235 errmsg ("parse error '%U'", format_unformat_error, input);
19240 if (!vam->json_output)
19242 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
19245 M (ONE_LOCATOR_SET_DUMP, mp);
19247 mp->filter = filter;
19252 /* Use a control ping for synchronization */
19253 MPING (CONTROL_PING, mp_ping);
19256 /* Wait for a reply... */
19261 #define api_lisp_locator_set_dump api_one_locator_set_dump
19264 api_one_eid_table_map_dump (vat_main_t * vam)
19268 unformat_input_t *input = vam->input;
19269 vl_api_one_eid_table_map_dump_t *mp;
19270 vl_api_control_ping_t *mp_ping;
19273 /* Parse args required to build the message */
19274 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19276 if (unformat (input, "l2"))
19281 else if (unformat (input, "l3"))
19288 errmsg ("parse error '%U'", format_unformat_error, input);
19295 errmsg ("expected one of 'l2' or 'l3' parameter!");
19299 if (!vam->json_output)
19301 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
19304 M (ONE_EID_TABLE_MAP_DUMP, mp);
19310 /* Use a control ping for synchronization */
19311 MPING (CONTROL_PING, mp_ping);
19314 /* Wait for a reply... */
19319 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
19322 api_one_eid_table_vni_dump (vat_main_t * vam)
19324 vl_api_one_eid_table_vni_dump_t *mp;
19325 vl_api_control_ping_t *mp_ping;
19328 if (!vam->json_output)
19330 print (vam->ofp, "VNI");
19333 M (ONE_EID_TABLE_VNI_DUMP, mp);
19338 /* Use a control ping for synchronization */
19339 MPING (CONTROL_PING, mp_ping);
19342 /* Wait for a reply... */
19347 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
19350 api_one_eid_table_dump (vat_main_t * vam)
19352 unformat_input_t *i = vam->input;
19353 vl_api_one_eid_table_dump_t *mp;
19354 vl_api_control_ping_t *mp_ping;
19355 struct in_addr ip4;
19356 struct in6_addr ip6;
19358 u8 eid_type = ~0, eid_set = 0;
19359 u32 prefix_length = ~0, t, vni = 0;
19362 lisp_nsh_api_t nsh;
19364 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19366 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
19372 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
19378 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
19383 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
19388 else if (unformat (i, "vni %d", &t))
19392 else if (unformat (i, "local"))
19396 else if (unformat (i, "remote"))
19402 errmsg ("parse error '%U'", format_unformat_error, i);
19407 if (!vam->json_output)
19409 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
19410 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
19413 M (ONE_EID_TABLE_DUMP, mp);
19415 mp->filter = filter;
19419 mp->vni = htonl (vni);
19420 mp->eid_type = eid_type;
19424 mp->prefix_length = prefix_length;
19425 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
19428 mp->prefix_length = prefix_length;
19429 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
19432 clib_memcpy (mp->eid, mac, sizeof (mac));
19435 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
19438 errmsg ("unknown EID type %d!", eid_type);
19446 /* Use a control ping for synchronization */
19447 MPING (CONTROL_PING, mp_ping);
19450 /* Wait for a reply... */
19455 #define api_lisp_eid_table_dump api_one_eid_table_dump
19458 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
19460 unformat_input_t *i = vam->input;
19461 vl_api_gpe_fwd_entries_get_t *mp;
19466 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19468 if (unformat (i, "vni %d", &vni))
19474 errmsg ("parse error '%U'", format_unformat_error, i);
19481 errmsg ("vni not set!");
19485 if (!vam->json_output)
19487 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
19491 M (GPE_FWD_ENTRIES_GET, mp);
19492 mp->vni = clib_host_to_net_u32 (vni);
19497 /* Wait for a reply... */
19502 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
19503 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
19504 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
19505 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
19506 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
19507 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
19508 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
19509 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
19512 api_one_adjacencies_get (vat_main_t * vam)
19514 unformat_input_t *i = vam->input;
19515 vl_api_one_adjacencies_get_t *mp;
19520 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19522 if (unformat (i, "vni %d", &vni))
19528 errmsg ("parse error '%U'", format_unformat_error, i);
19535 errmsg ("vni not set!");
19539 if (!vam->json_output)
19541 print (vam->ofp, "%s %40s", "leid", "reid");
19544 M (ONE_ADJACENCIES_GET, mp);
19545 mp->vni = clib_host_to_net_u32 (vni);
19550 /* Wait for a reply... */
19555 #define api_lisp_adjacencies_get api_one_adjacencies_get
19558 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
19560 unformat_input_t *i = vam->input;
19561 vl_api_gpe_native_fwd_rpaths_get_t *mp;
19563 u8 ip_family_set = 0, is_ip4 = 1;
19565 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19567 if (unformat (i, "ip4"))
19572 else if (unformat (i, "ip6"))
19579 errmsg ("parse error '%U'", format_unformat_error, i);
19584 if (!ip_family_set)
19586 errmsg ("ip family not set!");
19590 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
19591 mp->is_ip4 = is_ip4;
19596 /* Wait for a reply... */
19602 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
19604 vl_api_gpe_fwd_entry_vnis_get_t *mp;
19607 if (!vam->json_output)
19609 print (vam->ofp, "VNIs");
19612 M (GPE_FWD_ENTRY_VNIS_GET, mp);
19617 /* Wait for a reply... */
19623 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
19625 unformat_input_t *i = vam->input;
19626 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
19628 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
19629 struct in_addr ip4;
19630 struct in6_addr ip6;
19631 u32 table_id = 0, nh_sw_if_index = ~0;
19633 memset (&ip4, 0, sizeof (ip4));
19634 memset (&ip6, 0, sizeof (ip6));
19636 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19638 if (unformat (i, "del"))
19640 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
19641 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19646 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
19647 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19652 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
19656 nh_sw_if_index = ~0;
19658 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
19662 nh_sw_if_index = ~0;
19664 else if (unformat (i, "table %d", &table_id))
19668 errmsg ("parse error '%U'", format_unformat_error, i);
19675 errmsg ("nh addr not set!");
19679 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
19680 mp->is_add = is_add;
19681 mp->table_id = clib_host_to_net_u32 (table_id);
19682 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
19683 mp->is_ip4 = is_ip4;
19685 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
19687 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
19692 /* Wait for a reply... */
19698 api_one_map_server_dump (vat_main_t * vam)
19700 vl_api_one_map_server_dump_t *mp;
19701 vl_api_control_ping_t *mp_ping;
19704 if (!vam->json_output)
19706 print (vam->ofp, "%=20s", "Map server");
19709 M (ONE_MAP_SERVER_DUMP, mp);
19713 /* Use a control ping for synchronization */
19714 MPING (CONTROL_PING, mp_ping);
19717 /* Wait for a reply... */
19722 #define api_lisp_map_server_dump api_one_map_server_dump
19725 api_one_map_resolver_dump (vat_main_t * vam)
19727 vl_api_one_map_resolver_dump_t *mp;
19728 vl_api_control_ping_t *mp_ping;
19731 if (!vam->json_output)
19733 print (vam->ofp, "%=20s", "Map resolver");
19736 M (ONE_MAP_RESOLVER_DUMP, mp);
19740 /* Use a control ping for synchronization */
19741 MPING (CONTROL_PING, mp_ping);
19744 /* Wait for a reply... */
19749 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
19752 api_one_stats_flush (vat_main_t * vam)
19754 vl_api_one_stats_flush_t *mp;
19757 M (ONE_STATS_FLUSH, mp);
19764 api_one_stats_dump (vat_main_t * vam)
19766 vl_api_one_stats_dump_t *mp;
19767 vl_api_control_ping_t *mp_ping;
19770 M (ONE_STATS_DUMP, mp);
19774 /* Use a control ping for synchronization */
19775 MPING (CONTROL_PING, mp_ping);
19778 /* Wait for a reply... */
19784 api_show_one_status (vat_main_t * vam)
19786 vl_api_show_one_status_t *mp;
19789 if (!vam->json_output)
19791 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
19794 M (SHOW_ONE_STATUS, mp);
19797 /* Wait for a reply... */
19802 #define api_show_lisp_status api_show_one_status
19805 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
19807 vl_api_gpe_fwd_entry_path_dump_t *mp;
19808 vl_api_control_ping_t *mp_ping;
19809 unformat_input_t *i = vam->input;
19810 u32 fwd_entry_index = ~0;
19813 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19815 if (unformat (i, "index %d", &fwd_entry_index))
19821 if (~0 == fwd_entry_index)
19823 errmsg ("no index specified!");
19827 if (!vam->json_output)
19829 print (vam->ofp, "first line");
19832 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
19836 /* Use a control ping for synchronization */
19837 MPING (CONTROL_PING, mp_ping);
19840 /* Wait for a reply... */
19846 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
19848 vl_api_one_get_map_request_itr_rlocs_t *mp;
19851 if (!vam->json_output)
19853 print (vam->ofp, "%=20s", "itr-rlocs:");
19856 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
19859 /* Wait for a reply... */
19864 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
19867 api_af_packet_create (vat_main_t * vam)
19869 unformat_input_t *i = vam->input;
19870 vl_api_af_packet_create_t *mp;
19871 u8 *host_if_name = 0;
19873 u8 random_hw_addr = 1;
19876 memset (hw_addr, 0, sizeof (hw_addr));
19878 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19880 if (unformat (i, "name %s", &host_if_name))
19881 vec_add1 (host_if_name, 0);
19882 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19883 random_hw_addr = 0;
19888 if (!vec_len (host_if_name))
19890 errmsg ("host-interface name must be specified");
19894 if (vec_len (host_if_name) > 64)
19896 errmsg ("host-interface name too long");
19900 M (AF_PACKET_CREATE, mp);
19902 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19903 clib_memcpy (mp->hw_addr, hw_addr, 6);
19904 mp->use_random_hw_addr = random_hw_addr;
19905 vec_free (host_if_name);
19913 fprintf (vam->ofp ? vam->ofp : stderr,
19914 " new sw_if_index = %d\n", vam->sw_if_index);
19921 api_af_packet_delete (vat_main_t * vam)
19923 unformat_input_t *i = vam->input;
19924 vl_api_af_packet_delete_t *mp;
19925 u8 *host_if_name = 0;
19928 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19930 if (unformat (i, "name %s", &host_if_name))
19931 vec_add1 (host_if_name, 0);
19936 if (!vec_len (host_if_name))
19938 errmsg ("host-interface name must be specified");
19942 if (vec_len (host_if_name) > 64)
19944 errmsg ("host-interface name too long");
19948 M (AF_PACKET_DELETE, mp);
19950 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19951 vec_free (host_if_name);
19958 static void vl_api_af_packet_details_t_handler
19959 (vl_api_af_packet_details_t * mp)
19961 vat_main_t *vam = &vat_main;
19963 print (vam->ofp, "%-16s %d",
19964 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
19967 static void vl_api_af_packet_details_t_handler_json
19968 (vl_api_af_packet_details_t * mp)
19970 vat_main_t *vam = &vat_main;
19971 vat_json_node_t *node = NULL;
19973 if (VAT_JSON_ARRAY != vam->json_tree.type)
19975 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19976 vat_json_init_array (&vam->json_tree);
19978 node = vat_json_array_add (&vam->json_tree);
19980 vat_json_init_object (node);
19981 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
19982 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
19986 api_af_packet_dump (vat_main_t * vam)
19988 vl_api_af_packet_dump_t *mp;
19989 vl_api_control_ping_t *mp_ping;
19992 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
19993 /* Get list of tap interfaces */
19994 M (AF_PACKET_DUMP, mp);
19997 /* Use a control ping for synchronization */
19998 MPING (CONTROL_PING, mp_ping);
20006 api_policer_add_del (vat_main_t * vam)
20008 unformat_input_t *i = vam->input;
20009 vl_api_policer_add_del_t *mp;
20019 u8 color_aware = 0;
20020 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
20023 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
20024 conform_action.dscp = 0;
20025 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
20026 exceed_action.dscp = 0;
20027 violate_action.action_type = SSE2_QOS_ACTION_DROP;
20028 violate_action.dscp = 0;
20030 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20032 if (unformat (i, "del"))
20034 else if (unformat (i, "name %s", &name))
20035 vec_add1 (name, 0);
20036 else if (unformat (i, "cir %u", &cir))
20038 else if (unformat (i, "eir %u", &eir))
20040 else if (unformat (i, "cb %u", &cb))
20042 else if (unformat (i, "eb %u", &eb))
20044 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
20047 else if (unformat (i, "round_type %U", unformat_policer_round_type,
20050 else if (unformat (i, "type %U", unformat_policer_type, &type))
20052 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
20055 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
20058 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
20061 else if (unformat (i, "color-aware"))
20067 if (!vec_len (name))
20069 errmsg ("policer name must be specified");
20073 if (vec_len (name) > 64)
20075 errmsg ("policer name too long");
20079 M (POLICER_ADD_DEL, mp);
20081 clib_memcpy (mp->name, name, vec_len (name));
20083 mp->is_add = is_add;
20084 mp->cir = ntohl (cir);
20085 mp->eir = ntohl (eir);
20086 mp->cb = clib_net_to_host_u64 (cb);
20087 mp->eb = clib_net_to_host_u64 (eb);
20088 mp->rate_type = rate_type;
20089 mp->round_type = round_type;
20091 mp->conform_action_type = conform_action.action_type;
20092 mp->conform_dscp = conform_action.dscp;
20093 mp->exceed_action_type = exceed_action.action_type;
20094 mp->exceed_dscp = exceed_action.dscp;
20095 mp->violate_action_type = violate_action.action_type;
20096 mp->violate_dscp = violate_action.dscp;
20097 mp->color_aware = color_aware;
20105 api_policer_dump (vat_main_t * vam)
20107 unformat_input_t *i = vam->input;
20108 vl_api_policer_dump_t *mp;
20109 vl_api_control_ping_t *mp_ping;
20110 u8 *match_name = 0;
20111 u8 match_name_valid = 0;
20114 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20116 if (unformat (i, "name %s", &match_name))
20118 vec_add1 (match_name, 0);
20119 match_name_valid = 1;
20125 M (POLICER_DUMP, mp);
20126 mp->match_name_valid = match_name_valid;
20127 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
20128 vec_free (match_name);
20132 /* Use a control ping for synchronization */
20133 MPING (CONTROL_PING, mp_ping);
20136 /* Wait for a reply... */
20142 api_policer_classify_set_interface (vat_main_t * vam)
20144 unformat_input_t *i = vam->input;
20145 vl_api_policer_classify_set_interface_t *mp;
20147 int sw_if_index_set;
20148 u32 ip4_table_index = ~0;
20149 u32 ip6_table_index = ~0;
20150 u32 l2_table_index = ~0;
20154 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20156 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20157 sw_if_index_set = 1;
20158 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20159 sw_if_index_set = 1;
20160 else if (unformat (i, "del"))
20162 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20164 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20166 else if (unformat (i, "l2-table %d", &l2_table_index))
20170 clib_warning ("parse error '%U'", format_unformat_error, i);
20175 if (sw_if_index_set == 0)
20177 errmsg ("missing interface name or sw_if_index");
20181 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
20183 mp->sw_if_index = ntohl (sw_if_index);
20184 mp->ip4_table_index = ntohl (ip4_table_index);
20185 mp->ip6_table_index = ntohl (ip6_table_index);
20186 mp->l2_table_index = ntohl (l2_table_index);
20187 mp->is_add = is_add;
20195 api_policer_classify_dump (vat_main_t * vam)
20197 unformat_input_t *i = vam->input;
20198 vl_api_policer_classify_dump_t *mp;
20199 vl_api_control_ping_t *mp_ping;
20200 u8 type = POLICER_CLASSIFY_N_TABLES;
20203 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
20207 errmsg ("classify table type must be specified");
20211 if (!vam->json_output)
20213 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20216 M (POLICER_CLASSIFY_DUMP, mp);
20221 /* Use a control ping for synchronization */
20222 MPING (CONTROL_PING, mp_ping);
20225 /* Wait for a reply... */
20231 api_netmap_create (vat_main_t * vam)
20233 unformat_input_t *i = vam->input;
20234 vl_api_netmap_create_t *mp;
20237 u8 random_hw_addr = 1;
20242 memset (hw_addr, 0, sizeof (hw_addr));
20244 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20246 if (unformat (i, "name %s", &if_name))
20247 vec_add1 (if_name, 0);
20248 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
20249 random_hw_addr = 0;
20250 else if (unformat (i, "pipe"))
20252 else if (unformat (i, "master"))
20254 else if (unformat (i, "slave"))
20260 if (!vec_len (if_name))
20262 errmsg ("interface name must be specified");
20266 if (vec_len (if_name) > 64)
20268 errmsg ("interface name too long");
20272 M (NETMAP_CREATE, mp);
20274 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20275 clib_memcpy (mp->hw_addr, hw_addr, 6);
20276 mp->use_random_hw_addr = random_hw_addr;
20277 mp->is_pipe = is_pipe;
20278 mp->is_master = is_master;
20279 vec_free (if_name);
20287 api_netmap_delete (vat_main_t * vam)
20289 unformat_input_t *i = vam->input;
20290 vl_api_netmap_delete_t *mp;
20294 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20296 if (unformat (i, "name %s", &if_name))
20297 vec_add1 (if_name, 0);
20302 if (!vec_len (if_name))
20304 errmsg ("interface name must be specified");
20308 if (vec_len (if_name) > 64)
20310 errmsg ("interface name too long");
20314 M (NETMAP_DELETE, mp);
20316 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20317 vec_free (if_name);
20325 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
20327 if (fp->afi == IP46_TYPE_IP6)
20329 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20330 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20331 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20332 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20333 format_ip6_address, fp->next_hop);
20334 else if (fp->afi == IP46_TYPE_IP4)
20336 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20337 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20338 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20339 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20340 format_ip4_address, fp->next_hop);
20344 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
20345 vl_api_fib_path_t * fp)
20347 struct in_addr ip4;
20348 struct in6_addr ip6;
20350 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20351 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20352 vat_json_object_add_uint (node, "is_local", fp->is_local);
20353 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20354 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20355 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20356 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20357 if (fp->afi == IP46_TYPE_IP4)
20359 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20360 vat_json_object_add_ip4 (node, "next_hop", ip4);
20362 else if (fp->afi == IP46_TYPE_IP6)
20364 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20365 vat_json_object_add_ip6 (node, "next_hop", ip6);
20370 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
20372 vat_main_t *vam = &vat_main;
20373 int count = ntohl (mp->mt_count);
20374 vl_api_fib_path_t *fp;
20377 print (vam->ofp, "[%d]: sw_if_index %d via:",
20378 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
20380 for (i = 0; i < count; i++)
20382 vl_api_mpls_fib_path_print (vam, fp);
20386 print (vam->ofp, "");
20389 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
20390 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
20393 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
20395 vat_main_t *vam = &vat_main;
20396 vat_json_node_t *node = NULL;
20397 int count = ntohl (mp->mt_count);
20398 vl_api_fib_path_t *fp;
20401 if (VAT_JSON_ARRAY != vam->json_tree.type)
20403 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20404 vat_json_init_array (&vam->json_tree);
20406 node = vat_json_array_add (&vam->json_tree);
20408 vat_json_init_object (node);
20409 vat_json_object_add_uint (node, "tunnel_index",
20410 ntohl (mp->mt_tunnel_index));
20411 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
20413 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
20416 for (i = 0; i < count; i++)
20418 vl_api_mpls_fib_path_json_print (node, fp);
20424 api_mpls_tunnel_dump (vat_main_t * vam)
20426 vl_api_mpls_tunnel_dump_t *mp;
20427 vl_api_control_ping_t *mp_ping;
20428 u32 sw_if_index = ~0;
20431 /* Parse args required to build the message */
20432 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
20434 if (unformat (vam->input, "sw_if_index %d", &sw_if_index))
20438 print (vam->ofp, " sw_if_index %d", sw_if_index);
20440 M (MPLS_TUNNEL_DUMP, mp);
20441 mp->sw_if_index = htonl (sw_if_index);
20444 /* Use a control ping for synchronization */
20445 MPING (CONTROL_PING, mp_ping);
20452 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
20453 #define vl_api_mpls_fib_details_t_print vl_noop_handler
20457 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
20459 vat_main_t *vam = &vat_main;
20460 int count = ntohl (mp->count);
20461 vl_api_fib_path_t *fp;
20465 "table-id %d, label %u, ess_bit %u",
20466 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
20468 for (i = 0; i < count; i++)
20470 vl_api_mpls_fib_path_print (vam, fp);
20475 static void vl_api_mpls_fib_details_t_handler_json
20476 (vl_api_mpls_fib_details_t * mp)
20478 vat_main_t *vam = &vat_main;
20479 int count = ntohl (mp->count);
20480 vat_json_node_t *node = NULL;
20481 vl_api_fib_path_t *fp;
20484 if (VAT_JSON_ARRAY != vam->json_tree.type)
20486 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20487 vat_json_init_array (&vam->json_tree);
20489 node = vat_json_array_add (&vam->json_tree);
20491 vat_json_init_object (node);
20492 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20493 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
20494 vat_json_object_add_uint (node, "label", ntohl (mp->label));
20495 vat_json_object_add_uint (node, "path_count", count);
20497 for (i = 0; i < count; i++)
20499 vl_api_mpls_fib_path_json_print (node, fp);
20505 api_mpls_fib_dump (vat_main_t * vam)
20507 vl_api_mpls_fib_dump_t *mp;
20508 vl_api_control_ping_t *mp_ping;
20511 M (MPLS_FIB_DUMP, mp);
20514 /* Use a control ping for synchronization */
20515 MPING (CONTROL_PING, mp_ping);
20522 #define vl_api_ip_fib_details_t_endian vl_noop_handler
20523 #define vl_api_ip_fib_details_t_print vl_noop_handler
20526 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
20528 vat_main_t *vam = &vat_main;
20529 int count = ntohl (mp->count);
20530 vl_api_fib_path_t *fp;
20534 "table-id %d, prefix %U/%d stats-index %d",
20535 ntohl (mp->table_id), format_ip4_address, mp->address,
20536 mp->address_length, ntohl (mp->stats_index));
20538 for (i = 0; i < count; i++)
20540 if (fp->afi == IP46_TYPE_IP6)
20542 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20543 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U, "
20544 "next_hop_table %d",
20545 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20546 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20547 format_ip6_address, fp->next_hop, ntohl (fp->table_id));
20548 else if (fp->afi == IP46_TYPE_IP4)
20550 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20551 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U, "
20552 "next_hop_table %d",
20553 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20554 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20555 format_ip4_address, fp->next_hop, ntohl (fp->table_id));
20560 static void vl_api_ip_fib_details_t_handler_json
20561 (vl_api_ip_fib_details_t * mp)
20563 vat_main_t *vam = &vat_main;
20564 int count = ntohl (mp->count);
20565 vat_json_node_t *node = NULL;
20566 struct in_addr ip4;
20567 struct in6_addr ip6;
20568 vl_api_fib_path_t *fp;
20571 if (VAT_JSON_ARRAY != vam->json_tree.type)
20573 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20574 vat_json_init_array (&vam->json_tree);
20576 node = vat_json_array_add (&vam->json_tree);
20578 vat_json_init_object (node);
20579 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20580 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
20581 vat_json_object_add_ip4 (node, "prefix", ip4);
20582 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20583 vat_json_object_add_uint (node, "path_count", count);
20585 for (i = 0; i < count; i++)
20587 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20588 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20589 vat_json_object_add_uint (node, "is_local", fp->is_local);
20590 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20591 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20592 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20593 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20594 if (fp->afi == IP46_TYPE_IP4)
20596 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20597 vat_json_object_add_ip4 (node, "next_hop", ip4);
20599 else if (fp->afi == IP46_TYPE_IP6)
20601 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20602 vat_json_object_add_ip6 (node, "next_hop", ip6);
20608 api_ip_fib_dump (vat_main_t * vam)
20610 vl_api_ip_fib_dump_t *mp;
20611 vl_api_control_ping_t *mp_ping;
20614 M (IP_FIB_DUMP, mp);
20617 /* Use a control ping for synchronization */
20618 MPING (CONTROL_PING, mp_ping);
20626 api_ip_mfib_dump (vat_main_t * vam)
20628 vl_api_ip_mfib_dump_t *mp;
20629 vl_api_control_ping_t *mp_ping;
20632 M (IP_MFIB_DUMP, mp);
20635 /* Use a control ping for synchronization */
20636 MPING (CONTROL_PING, mp_ping);
20643 static void vl_api_ip_neighbor_details_t_handler
20644 (vl_api_ip_neighbor_details_t * mp)
20646 vat_main_t *vam = &vat_main;
20648 print (vam->ofp, "%c %U %U",
20649 (mp->is_static) ? 'S' : 'D',
20650 format_ethernet_address, &mp->mac_address,
20651 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
20655 static void vl_api_ip_neighbor_details_t_handler_json
20656 (vl_api_ip_neighbor_details_t * mp)
20659 vat_main_t *vam = &vat_main;
20660 vat_json_node_t *node;
20661 struct in_addr ip4;
20662 struct in6_addr ip6;
20664 if (VAT_JSON_ARRAY != vam->json_tree.type)
20666 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20667 vat_json_init_array (&vam->json_tree);
20669 node = vat_json_array_add (&vam->json_tree);
20671 vat_json_init_object (node);
20672 vat_json_object_add_string_copy (node, "flag",
20673 (mp->is_static) ? (u8 *) "static" : (u8 *)
20676 vat_json_object_add_string_copy (node, "link_layer",
20677 format (0, "%U", format_ethernet_address,
20678 &mp->mac_address));
20682 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
20683 vat_json_object_add_ip6 (node, "ip_address", ip6);
20687 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
20688 vat_json_object_add_ip4 (node, "ip_address", ip4);
20693 api_ip_neighbor_dump (vat_main_t * vam)
20695 unformat_input_t *i = vam->input;
20696 vl_api_ip_neighbor_dump_t *mp;
20697 vl_api_control_ping_t *mp_ping;
20699 u32 sw_if_index = ~0;
20702 /* Parse args required to build the message */
20703 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20705 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20707 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20709 else if (unformat (i, "ip6"))
20715 if (sw_if_index == ~0)
20717 errmsg ("missing interface name or sw_if_index");
20721 M (IP_NEIGHBOR_DUMP, mp);
20722 mp->is_ipv6 = (u8) is_ipv6;
20723 mp->sw_if_index = ntohl (sw_if_index);
20726 /* Use a control ping for synchronization */
20727 MPING (CONTROL_PING, mp_ping);
20734 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
20735 #define vl_api_ip6_fib_details_t_print vl_noop_handler
20738 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
20740 vat_main_t *vam = &vat_main;
20741 int count = ntohl (mp->count);
20742 vl_api_fib_path_t *fp;
20746 "table-id %d, prefix %U/%d stats-index %d",
20747 ntohl (mp->table_id), format_ip6_address, mp->address,
20748 mp->address_length, ntohl (mp->stats_index));
20750 for (i = 0; i < count; i++)
20752 if (fp->afi == IP46_TYPE_IP6)
20754 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20755 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20756 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20757 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20758 format_ip6_address, fp->next_hop);
20759 else if (fp->afi == IP46_TYPE_IP4)
20761 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20762 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20763 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20764 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20765 format_ip4_address, fp->next_hop);
20770 static void vl_api_ip6_fib_details_t_handler_json
20771 (vl_api_ip6_fib_details_t * mp)
20773 vat_main_t *vam = &vat_main;
20774 int count = ntohl (mp->count);
20775 vat_json_node_t *node = NULL;
20776 struct in_addr ip4;
20777 struct in6_addr ip6;
20778 vl_api_fib_path_t *fp;
20781 if (VAT_JSON_ARRAY != vam->json_tree.type)
20783 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20784 vat_json_init_array (&vam->json_tree);
20786 node = vat_json_array_add (&vam->json_tree);
20788 vat_json_init_object (node);
20789 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20790 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
20791 vat_json_object_add_ip6 (node, "prefix", ip6);
20792 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20793 vat_json_object_add_uint (node, "path_count", count);
20795 for (i = 0; i < count; i++)
20797 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20798 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20799 vat_json_object_add_uint (node, "is_local", fp->is_local);
20800 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20801 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20802 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20803 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20804 if (fp->afi == IP46_TYPE_IP4)
20806 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20807 vat_json_object_add_ip4 (node, "next_hop", ip4);
20809 else if (fp->afi == IP46_TYPE_IP6)
20811 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20812 vat_json_object_add_ip6 (node, "next_hop", ip6);
20818 api_ip6_fib_dump (vat_main_t * vam)
20820 vl_api_ip6_fib_dump_t *mp;
20821 vl_api_control_ping_t *mp_ping;
20824 M (IP6_FIB_DUMP, mp);
20827 /* Use a control ping for synchronization */
20828 MPING (CONTROL_PING, mp_ping);
20836 api_ip6_mfib_dump (vat_main_t * vam)
20838 vl_api_ip6_mfib_dump_t *mp;
20839 vl_api_control_ping_t *mp_ping;
20842 M (IP6_MFIB_DUMP, mp);
20845 /* Use a control ping for synchronization */
20846 MPING (CONTROL_PING, mp_ping);
20854 api_classify_table_ids (vat_main_t * vam)
20856 vl_api_classify_table_ids_t *mp;
20859 /* Construct the API message */
20860 M (CLASSIFY_TABLE_IDS, mp);
20869 api_classify_table_by_interface (vat_main_t * vam)
20871 unformat_input_t *input = vam->input;
20872 vl_api_classify_table_by_interface_t *mp;
20874 u32 sw_if_index = ~0;
20876 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20878 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20880 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20885 if (sw_if_index == ~0)
20887 errmsg ("missing interface name or sw_if_index");
20891 /* Construct the API message */
20892 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
20894 mp->sw_if_index = ntohl (sw_if_index);
20902 api_classify_table_info (vat_main_t * vam)
20904 unformat_input_t *input = vam->input;
20905 vl_api_classify_table_info_t *mp;
20909 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20911 if (unformat (input, "table_id %d", &table_id))
20916 if (table_id == ~0)
20918 errmsg ("missing table id");
20922 /* Construct the API message */
20923 M (CLASSIFY_TABLE_INFO, mp);
20925 mp->table_id = ntohl (table_id);
20933 api_classify_session_dump (vat_main_t * vam)
20935 unformat_input_t *input = vam->input;
20936 vl_api_classify_session_dump_t *mp;
20937 vl_api_control_ping_t *mp_ping;
20941 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20943 if (unformat (input, "table_id %d", &table_id))
20948 if (table_id == ~0)
20950 errmsg ("missing table id");
20954 /* Construct the API message */
20955 M (CLASSIFY_SESSION_DUMP, mp);
20957 mp->table_id = ntohl (table_id);
20960 /* Use a control ping for synchronization */
20961 MPING (CONTROL_PING, mp_ping);
20969 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
20971 vat_main_t *vam = &vat_main;
20973 print (vam->ofp, "collector_address %U, collector_port %d, "
20974 "src_address %U, vrf_id %d, path_mtu %u, "
20975 "template_interval %u, udp_checksum %d",
20976 format_ip4_address, mp->collector_address,
20977 ntohs (mp->collector_port),
20978 format_ip4_address, mp->src_address,
20979 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
20980 ntohl (mp->template_interval), mp->udp_checksum);
20983 vam->result_ready = 1;
20987 vl_api_ipfix_exporter_details_t_handler_json
20988 (vl_api_ipfix_exporter_details_t * mp)
20990 vat_main_t *vam = &vat_main;
20991 vat_json_node_t node;
20992 struct in_addr collector_address;
20993 struct in_addr src_address;
20995 vat_json_init_object (&node);
20996 clib_memcpy (&collector_address, &mp->collector_address,
20997 sizeof (collector_address));
20998 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
20999 vat_json_object_add_uint (&node, "collector_port",
21000 ntohs (mp->collector_port));
21001 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
21002 vat_json_object_add_ip4 (&node, "src_address", src_address);
21003 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
21004 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
21005 vat_json_object_add_uint (&node, "template_interval",
21006 ntohl (mp->template_interval));
21007 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
21009 vat_json_print (vam->ofp, &node);
21010 vat_json_free (&node);
21012 vam->result_ready = 1;
21016 api_ipfix_exporter_dump (vat_main_t * vam)
21018 vl_api_ipfix_exporter_dump_t *mp;
21021 /* Construct the API message */
21022 M (IPFIX_EXPORTER_DUMP, mp);
21031 api_ipfix_classify_stream_dump (vat_main_t * vam)
21033 vl_api_ipfix_classify_stream_dump_t *mp;
21036 /* Construct the API message */
21037 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
21048 vl_api_ipfix_classify_stream_details_t_handler
21049 (vl_api_ipfix_classify_stream_details_t * mp)
21051 vat_main_t *vam = &vat_main;
21052 print (vam->ofp, "domain_id %d, src_port %d",
21053 ntohl (mp->domain_id), ntohs (mp->src_port));
21055 vam->result_ready = 1;
21059 vl_api_ipfix_classify_stream_details_t_handler_json
21060 (vl_api_ipfix_classify_stream_details_t * mp)
21062 vat_main_t *vam = &vat_main;
21063 vat_json_node_t node;
21065 vat_json_init_object (&node);
21066 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
21067 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
21069 vat_json_print (vam->ofp, &node);
21070 vat_json_free (&node);
21072 vam->result_ready = 1;
21076 api_ipfix_classify_table_dump (vat_main_t * vam)
21078 vl_api_ipfix_classify_table_dump_t *mp;
21079 vl_api_control_ping_t *mp_ping;
21082 if (!vam->json_output)
21084 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
21085 "transport_protocol");
21088 /* Construct the API message */
21089 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
21094 /* Use a control ping for synchronization */
21095 MPING (CONTROL_PING, mp_ping);
21103 vl_api_ipfix_classify_table_details_t_handler
21104 (vl_api_ipfix_classify_table_details_t * mp)
21106 vat_main_t *vam = &vat_main;
21107 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
21108 mp->transport_protocol);
21112 vl_api_ipfix_classify_table_details_t_handler_json
21113 (vl_api_ipfix_classify_table_details_t * mp)
21115 vat_json_node_t *node = NULL;
21116 vat_main_t *vam = &vat_main;
21118 if (VAT_JSON_ARRAY != vam->json_tree.type)
21120 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21121 vat_json_init_array (&vam->json_tree);
21124 node = vat_json_array_add (&vam->json_tree);
21125 vat_json_init_object (node);
21127 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
21128 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
21129 vat_json_object_add_uint (node, "transport_protocol",
21130 mp->transport_protocol);
21134 api_sw_interface_span_enable_disable (vat_main_t * vam)
21136 unformat_input_t *i = vam->input;
21137 vl_api_sw_interface_span_enable_disable_t *mp;
21138 u32 src_sw_if_index = ~0;
21139 u32 dst_sw_if_index = ~0;
21144 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21147 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
21149 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
21153 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
21155 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
21157 else if (unformat (i, "disable"))
21159 else if (unformat (i, "rx"))
21161 else if (unformat (i, "tx"))
21163 else if (unformat (i, "both"))
21165 else if (unformat (i, "l2"))
21171 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
21173 mp->sw_if_index_from = htonl (src_sw_if_index);
21174 mp->sw_if_index_to = htonl (dst_sw_if_index);
21184 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
21187 vat_main_t *vam = &vat_main;
21188 u8 *sw_if_from_name = 0;
21189 u8 *sw_if_to_name = 0;
21190 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
21191 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
21192 char *states[] = { "none", "rx", "tx", "both" };
21196 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
21198 if ((u32) p->value[0] == sw_if_index_from)
21200 sw_if_from_name = (u8 *)(p->key);
21204 if ((u32) p->value[0] == sw_if_index_to)
21206 sw_if_to_name = (u8 *)(p->key);
21207 if (sw_if_from_name)
21212 print (vam->ofp, "%20s => %20s (%s) %s",
21213 sw_if_from_name, sw_if_to_name, states[mp->state],
21214 mp->is_l2 ? "l2" : "device");
21218 vl_api_sw_interface_span_details_t_handler_json
21219 (vl_api_sw_interface_span_details_t * mp)
21221 vat_main_t *vam = &vat_main;
21222 vat_json_node_t *node = NULL;
21223 u8 *sw_if_from_name = 0;
21224 u8 *sw_if_to_name = 0;
21225 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
21226 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
21230 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
21232 if ((u32) p->value[0] == sw_if_index_from)
21234 sw_if_from_name = (u8 *)(p->key);
21238 if ((u32) p->value[0] == sw_if_index_to)
21240 sw_if_to_name = (u8 *)(p->key);
21241 if (sw_if_from_name)
21247 if (VAT_JSON_ARRAY != vam->json_tree.type)
21249 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21250 vat_json_init_array (&vam->json_tree);
21252 node = vat_json_array_add (&vam->json_tree);
21254 vat_json_init_object (node);
21255 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
21256 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
21257 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
21258 if (0 != sw_if_to_name)
21260 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
21262 vat_json_object_add_uint (node, "state", mp->state);
21263 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
21267 api_sw_interface_span_dump (vat_main_t * vam)
21269 unformat_input_t *input = vam->input;
21270 vl_api_sw_interface_span_dump_t *mp;
21271 vl_api_control_ping_t *mp_ping;
21275 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21277 if (unformat (input, "l2"))
21283 M (SW_INTERFACE_SPAN_DUMP, mp);
21287 /* Use a control ping for synchronization */
21288 MPING (CONTROL_PING, mp_ping);
21296 api_pg_create_interface (vat_main_t * vam)
21298 unformat_input_t *input = vam->input;
21299 vl_api_pg_create_interface_t *mp;
21303 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21305 if (unformat (input, "if_id %d", &if_id))
21312 errmsg ("missing pg interface index");
21316 /* Construct the API message */
21317 M (PG_CREATE_INTERFACE, mp);
21319 mp->interface_id = ntohl (if_id);
21327 api_pg_capture (vat_main_t * vam)
21329 unformat_input_t *input = vam->input;
21330 vl_api_pg_capture_t *mp;
21335 u8 pcap_file_set = 0;
21338 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21340 if (unformat (input, "if_id %d", &if_id))
21342 else if (unformat (input, "pcap %s", &pcap_file))
21344 else if (unformat (input, "count %d", &count))
21346 else if (unformat (input, "disable"))
21353 errmsg ("missing pg interface index");
21356 if (pcap_file_set > 0)
21358 if (vec_len (pcap_file) > 255)
21360 errmsg ("pcap file name is too long");
21365 u32 name_len = vec_len (pcap_file);
21366 /* Construct the API message */
21367 M (PG_CAPTURE, mp);
21369 mp->interface_id = ntohl (if_id);
21370 mp->is_enabled = enable;
21371 mp->count = ntohl (count);
21372 mp->pcap_name_length = ntohl (name_len);
21373 if (pcap_file_set != 0)
21375 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
21377 vec_free (pcap_file);
21385 api_pg_enable_disable (vat_main_t * vam)
21387 unformat_input_t *input = vam->input;
21388 vl_api_pg_enable_disable_t *mp;
21391 u8 stream_name_set = 0;
21392 u8 *stream_name = 0;
21394 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21396 if (unformat (input, "stream %s", &stream_name))
21397 stream_name_set = 1;
21398 else if (unformat (input, "disable"))
21404 if (stream_name_set > 0)
21406 if (vec_len (stream_name) > 255)
21408 errmsg ("stream name too long");
21413 u32 name_len = vec_len (stream_name);
21414 /* Construct the API message */
21415 M (PG_ENABLE_DISABLE, mp);
21417 mp->is_enabled = enable;
21418 if (stream_name_set != 0)
21420 mp->stream_name_length = ntohl (name_len);
21421 clib_memcpy (mp->stream_name, stream_name, name_len);
21423 vec_free (stream_name);
21431 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
21433 unformat_input_t *input = vam->input;
21434 vl_api_ip_source_and_port_range_check_add_del_t *mp;
21436 u16 *low_ports = 0;
21437 u16 *high_ports = 0;
21440 ip4_address_t ip4_addr;
21441 ip6_address_t ip6_addr;
21450 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21452 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
21458 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
21463 else if (unformat (input, "vrf %d", &vrf_id))
21465 else if (unformat (input, "del"))
21467 else if (unformat (input, "port %d", &tmp))
21469 if (tmp == 0 || tmp > 65535)
21471 errmsg ("port %d out of range", tmp);
21475 this_hi = this_low + 1;
21476 vec_add1 (low_ports, this_low);
21477 vec_add1 (high_ports, this_hi);
21479 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
21481 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
21483 errmsg ("incorrect range parameters");
21487 /* Note: in debug CLI +1 is added to high before
21488 passing to real fn that does "the work"
21489 (ip_source_and_port_range_check_add_del).
21490 This fn is a wrapper around the binary API fn a
21491 control plane will call, which expects this increment
21492 to have occurred. Hence letting the binary API control
21493 plane fn do the increment for consistency between VAT
21494 and other control planes.
21497 vec_add1 (low_ports, this_low);
21498 vec_add1 (high_ports, this_hi);
21504 if (prefix_set == 0)
21506 errmsg ("<address>/<mask> not specified");
21512 errmsg ("VRF ID required, not specified");
21519 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21523 if (vec_len (low_ports) == 0)
21525 errmsg ("At least one port or port range required");
21529 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
21531 mp->is_add = is_add;
21536 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
21541 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
21544 mp->mask_length = length;
21545 mp->number_of_ranges = vec_len (low_ports);
21547 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
21548 vec_free (low_ports);
21550 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
21551 vec_free (high_ports);
21553 mp->vrf_id = ntohl (vrf_id);
21561 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
21563 unformat_input_t *input = vam->input;
21564 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
21565 u32 sw_if_index = ~0;
21567 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
21568 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
21572 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21574 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21576 else if (unformat (input, "sw_if_index %d", &sw_if_index))
21578 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
21580 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
21582 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
21584 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
21586 else if (unformat (input, "del"))
21592 if (sw_if_index == ~0)
21594 errmsg ("Interface required but not specified");
21600 errmsg ("VRF ID required but not specified");
21604 if (tcp_out_vrf_id == 0
21605 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
21608 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21612 /* Construct the API message */
21613 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
21615 mp->sw_if_index = ntohl (sw_if_index);
21616 mp->is_add = is_add;
21617 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
21618 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
21619 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
21620 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
21625 /* Wait for a reply... */
21631 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
21633 unformat_input_t *i = vam->input;
21634 vl_api_ipsec_gre_add_del_tunnel_t *mp;
21635 u32 local_sa_id = 0;
21636 u32 remote_sa_id = 0;
21637 ip4_address_t src_address;
21638 ip4_address_t dst_address;
21642 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21644 if (unformat (i, "local_sa %d", &local_sa_id))
21646 else if (unformat (i, "remote_sa %d", &remote_sa_id))
21648 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
21650 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
21652 else if (unformat (i, "del"))
21656 clib_warning ("parse error '%U'", format_unformat_error, i);
21661 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
21663 mp->local_sa_id = ntohl (local_sa_id);
21664 mp->remote_sa_id = ntohl (remote_sa_id);
21665 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
21666 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
21667 mp->is_add = is_add;
21675 api_punt (vat_main_t * vam)
21677 unformat_input_t *i = vam->input;
21685 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21687 if (unformat (i, "ip %d", &ipv))
21689 else if (unformat (i, "protocol %d", &protocol))
21691 else if (unformat (i, "port %d", &port))
21693 else if (unformat (i, "del"))
21697 clib_warning ("parse error '%U'", format_unformat_error, i);
21704 mp->is_add = (u8) is_add;
21705 mp->ipv = (u8) ipv;
21706 mp->l4_protocol = (u8) protocol;
21707 mp->l4_port = htons ((u16) port);
21714 static void vl_api_ipsec_gre_tunnel_details_t_handler
21715 (vl_api_ipsec_gre_tunnel_details_t * mp)
21717 vat_main_t *vam = &vat_main;
21719 print (vam->ofp, "%11d%15U%15U%14d%14d",
21720 ntohl (mp->sw_if_index),
21721 format_ip4_address, &mp->src_address,
21722 format_ip4_address, &mp->dst_address,
21723 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
21726 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
21727 (vl_api_ipsec_gre_tunnel_details_t * mp)
21729 vat_main_t *vam = &vat_main;
21730 vat_json_node_t *node = NULL;
21731 struct in_addr ip4;
21733 if (VAT_JSON_ARRAY != vam->json_tree.type)
21735 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21736 vat_json_init_array (&vam->json_tree);
21738 node = vat_json_array_add (&vam->json_tree);
21740 vat_json_init_object (node);
21741 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
21742 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
21743 vat_json_object_add_ip4 (node, "src_address", ip4);
21744 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
21745 vat_json_object_add_ip4 (node, "dst_address", ip4);
21746 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
21747 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
21751 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
21753 unformat_input_t *i = vam->input;
21754 vl_api_ipsec_gre_tunnel_dump_t *mp;
21755 vl_api_control_ping_t *mp_ping;
21757 u8 sw_if_index_set = 0;
21760 /* Parse args required to build the message */
21761 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21763 if (unformat (i, "sw_if_index %d", &sw_if_index))
21764 sw_if_index_set = 1;
21769 if (sw_if_index_set == 0)
21774 if (!vam->json_output)
21776 print (vam->ofp, "%11s%15s%15s%14s%14s",
21777 "sw_if_index", "src_address", "dst_address",
21778 "local_sa_id", "remote_sa_id");
21781 /* Get list of gre-tunnel interfaces */
21782 M (IPSEC_GRE_TUNNEL_DUMP, mp);
21784 mp->sw_if_index = htonl (sw_if_index);
21788 /* Use a control ping for synchronization */
21789 MPING (CONTROL_PING, mp_ping);
21797 api_delete_subif (vat_main_t * vam)
21799 unformat_input_t *i = vam->input;
21800 vl_api_delete_subif_t *mp;
21801 u32 sw_if_index = ~0;
21804 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21806 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21808 if (unformat (i, "sw_if_index %d", &sw_if_index))
21814 if (sw_if_index == ~0)
21816 errmsg ("missing sw_if_index");
21820 /* Construct the API message */
21821 M (DELETE_SUBIF, mp);
21822 mp->sw_if_index = ntohl (sw_if_index);
21829 #define foreach_pbb_vtr_op \
21830 _("disable", L2_VTR_DISABLED) \
21831 _("pop", L2_VTR_POP_2) \
21832 _("push", L2_VTR_PUSH_2)
21835 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
21837 unformat_input_t *i = vam->input;
21838 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
21839 u32 sw_if_index = ~0, vtr_op = ~0;
21840 u16 outer_tag = ~0;
21841 u8 dmac[6], smac[6];
21842 u8 dmac_set = 0, smac_set = 0;
21848 /* Shut up coverity */
21849 memset (dmac, 0, sizeof (dmac));
21850 memset (smac, 0, sizeof (smac));
21852 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21854 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21856 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21858 else if (unformat (i, "vtr_op %d", &vtr_op))
21860 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
21863 else if (unformat (i, "translate_pbb_stag"))
21865 if (unformat (i, "%d", &tmp))
21867 vtr_op = L2_VTR_TRANSLATE_2_1;
21873 ("translate_pbb_stag operation requires outer tag definition");
21877 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
21879 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
21881 else if (unformat (i, "sid %d", &sid))
21883 else if (unformat (i, "vlanid %d", &tmp))
21887 clib_warning ("parse error '%U'", format_unformat_error, i);
21892 if ((sw_if_index == ~0) || (vtr_op == ~0))
21894 errmsg ("missing sw_if_index or vtr operation");
21897 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
21898 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
21901 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
21905 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
21906 mp->sw_if_index = ntohl (sw_if_index);
21907 mp->vtr_op = ntohl (vtr_op);
21908 mp->outer_tag = ntohs (outer_tag);
21909 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
21910 clib_memcpy (mp->b_smac, smac, sizeof (smac));
21911 mp->b_vlanid = ntohs (vlanid);
21912 mp->i_sid = ntohl (sid);
21920 api_flow_classify_set_interface (vat_main_t * vam)
21922 unformat_input_t *i = vam->input;
21923 vl_api_flow_classify_set_interface_t *mp;
21925 int sw_if_index_set;
21926 u32 ip4_table_index = ~0;
21927 u32 ip6_table_index = ~0;
21931 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21933 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21934 sw_if_index_set = 1;
21935 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21936 sw_if_index_set = 1;
21937 else if (unformat (i, "del"))
21939 else if (unformat (i, "ip4-table %d", &ip4_table_index))
21941 else if (unformat (i, "ip6-table %d", &ip6_table_index))
21945 clib_warning ("parse error '%U'", format_unformat_error, i);
21950 if (sw_if_index_set == 0)
21952 errmsg ("missing interface name or sw_if_index");
21956 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
21958 mp->sw_if_index = ntohl (sw_if_index);
21959 mp->ip4_table_index = ntohl (ip4_table_index);
21960 mp->ip6_table_index = ntohl (ip6_table_index);
21961 mp->is_add = is_add;
21969 api_flow_classify_dump (vat_main_t * vam)
21971 unformat_input_t *i = vam->input;
21972 vl_api_flow_classify_dump_t *mp;
21973 vl_api_control_ping_t *mp_ping;
21974 u8 type = FLOW_CLASSIFY_N_TABLES;
21977 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
21981 errmsg ("classify table type must be specified");
21985 if (!vam->json_output)
21987 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
21990 M (FLOW_CLASSIFY_DUMP, mp);
21995 /* Use a control ping for synchronization */
21996 MPING (CONTROL_PING, mp_ping);
21999 /* Wait for a reply... */
22005 api_feature_enable_disable (vat_main_t * vam)
22007 unformat_input_t *i = vam->input;
22008 vl_api_feature_enable_disable_t *mp;
22010 u8 *feature_name = 0;
22011 u32 sw_if_index = ~0;
22015 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22017 if (unformat (i, "arc_name %s", &arc_name))
22019 else if (unformat (i, "feature_name %s", &feature_name))
22022 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22024 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22026 else if (unformat (i, "disable"))
22034 errmsg ("missing arc name");
22037 if (vec_len (arc_name) > 63)
22039 errmsg ("arc name too long");
22042 if (feature_name == 0)
22044 errmsg ("missing feature name");
22047 if (vec_len (feature_name) > 63)
22049 errmsg ("feature name too long");
22052 if (sw_if_index == ~0)
22054 errmsg ("missing interface name or sw_if_index");
22058 /* Construct the API message */
22059 M (FEATURE_ENABLE_DISABLE, mp);
22060 mp->sw_if_index = ntohl (sw_if_index);
22061 mp->enable = enable;
22062 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
22063 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
22064 vec_free (arc_name);
22065 vec_free (feature_name);
22073 api_sw_interface_tag_add_del (vat_main_t * vam)
22075 unformat_input_t *i = vam->input;
22076 vl_api_sw_interface_tag_add_del_t *mp;
22077 u32 sw_if_index = ~0;
22082 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22084 if (unformat (i, "tag %s", &tag))
22086 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22088 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22090 else if (unformat (i, "del"))
22096 if (sw_if_index == ~0)
22098 errmsg ("missing interface name or sw_if_index");
22102 if (enable && (tag == 0))
22104 errmsg ("no tag specified");
22108 /* Construct the API message */
22109 M (SW_INTERFACE_TAG_ADD_DEL, mp);
22110 mp->sw_if_index = ntohl (sw_if_index);
22111 mp->is_add = enable;
22113 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
22121 static void vl_api_l2_xconnect_details_t_handler
22122 (vl_api_l2_xconnect_details_t * mp)
22124 vat_main_t *vam = &vat_main;
22126 print (vam->ofp, "%15d%15d",
22127 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
22130 static void vl_api_l2_xconnect_details_t_handler_json
22131 (vl_api_l2_xconnect_details_t * mp)
22133 vat_main_t *vam = &vat_main;
22134 vat_json_node_t *node = NULL;
22136 if (VAT_JSON_ARRAY != vam->json_tree.type)
22138 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22139 vat_json_init_array (&vam->json_tree);
22141 node = vat_json_array_add (&vam->json_tree);
22143 vat_json_init_object (node);
22144 vat_json_object_add_uint (node, "rx_sw_if_index",
22145 ntohl (mp->rx_sw_if_index));
22146 vat_json_object_add_uint (node, "tx_sw_if_index",
22147 ntohl (mp->tx_sw_if_index));
22151 api_l2_xconnect_dump (vat_main_t * vam)
22153 vl_api_l2_xconnect_dump_t *mp;
22154 vl_api_control_ping_t *mp_ping;
22157 if (!vam->json_output)
22159 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
22162 M (L2_XCONNECT_DUMP, mp);
22166 /* Use a control ping for synchronization */
22167 MPING (CONTROL_PING, mp_ping);
22175 api_hw_interface_set_mtu (vat_main_t * vam)
22177 unformat_input_t *i = vam->input;
22178 vl_api_hw_interface_set_mtu_t *mp;
22179 u32 sw_if_index = ~0;
22183 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22185 if (unformat (i, "mtu %d", &mtu))
22187 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22189 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22195 if (sw_if_index == ~0)
22197 errmsg ("missing interface name or sw_if_index");
22203 errmsg ("no mtu specified");
22207 /* Construct the API message */
22208 M (HW_INTERFACE_SET_MTU, mp);
22209 mp->sw_if_index = ntohl (sw_if_index);
22210 mp->mtu = ntohs ((u16) mtu);
22218 api_p2p_ethernet_add (vat_main_t * vam)
22220 unformat_input_t *i = vam->input;
22221 vl_api_p2p_ethernet_add_t *mp;
22222 u32 parent_if_index = ~0;
22228 memset (remote_mac, 0, sizeof (remote_mac));
22229 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22231 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
22233 else if (unformat (i, "sw_if_index %d", &parent_if_index))
22237 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
22239 else if (unformat (i, "sub_id %d", &sub_id))
22243 clib_warning ("parse error '%U'", format_unformat_error, i);
22248 if (parent_if_index == ~0)
22250 errmsg ("missing interface name or sw_if_index");
22255 errmsg ("missing remote mac address");
22260 errmsg ("missing sub-interface id");
22264 M (P2P_ETHERNET_ADD, mp);
22265 mp->parent_if_index = ntohl (parent_if_index);
22266 mp->subif_id = ntohl (sub_id);
22267 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22275 api_p2p_ethernet_del (vat_main_t * vam)
22277 unformat_input_t *i = vam->input;
22278 vl_api_p2p_ethernet_del_t *mp;
22279 u32 parent_if_index = ~0;
22284 memset (remote_mac, 0, sizeof (remote_mac));
22285 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22287 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
22289 else if (unformat (i, "sw_if_index %d", &parent_if_index))
22293 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
22297 clib_warning ("parse error '%U'", format_unformat_error, i);
22302 if (parent_if_index == ~0)
22304 errmsg ("missing interface name or sw_if_index");
22309 errmsg ("missing remote mac address");
22313 M (P2P_ETHERNET_DEL, mp);
22314 mp->parent_if_index = ntohl (parent_if_index);
22315 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22323 api_lldp_config (vat_main_t * vam)
22325 unformat_input_t *i = vam->input;
22326 vl_api_lldp_config_t *mp;
22328 int tx_interval = 0;
22329 u8 *sys_name = NULL;
22332 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22334 if (unformat (i, "system-name %s", &sys_name))
22336 else if (unformat (i, "tx-hold %d", &tx_hold))
22338 else if (unformat (i, "tx-interval %d", &tx_interval))
22342 clib_warning ("parse error '%U'", format_unformat_error, i);
22347 vec_add1 (sys_name, 0);
22349 M (LLDP_CONFIG, mp);
22350 mp->tx_hold = htonl (tx_hold);
22351 mp->tx_interval = htonl (tx_interval);
22352 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
22353 vec_free (sys_name);
22361 api_sw_interface_set_lldp (vat_main_t * vam)
22363 unformat_input_t *i = vam->input;
22364 vl_api_sw_interface_set_lldp_t *mp;
22365 u32 sw_if_index = ~0;
22367 u8 *port_desc = NULL, *mgmt_oid = NULL;
22368 ip4_address_t ip4_addr;
22369 ip6_address_t ip6_addr;
22372 memset (&ip4_addr, 0, sizeof (ip4_addr));
22373 memset (&ip6_addr, 0, sizeof (ip6_addr));
22375 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22377 if (unformat (i, "disable"))
22380 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22382 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22384 else if (unformat (i, "port-desc %s", &port_desc))
22386 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
22388 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
22390 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
22396 if (sw_if_index == ~0)
22398 errmsg ("missing interface name or sw_if_index");
22402 /* Construct the API message */
22403 vec_add1 (port_desc, 0);
22404 vec_add1 (mgmt_oid, 0);
22405 M (SW_INTERFACE_SET_LLDP, mp);
22406 mp->sw_if_index = ntohl (sw_if_index);
22407 mp->enable = enable;
22408 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
22409 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
22410 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
22411 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
22412 vec_free (port_desc);
22413 vec_free (mgmt_oid);
22421 api_tcp_configure_src_addresses (vat_main_t * vam)
22423 vl_api_tcp_configure_src_addresses_t *mp;
22424 unformat_input_t *i = vam->input;
22425 ip4_address_t v4first, v4last;
22426 ip6_address_t v6first, v6last;
22431 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22433 if (unformat (i, "%U - %U",
22434 unformat_ip4_address, &v4first,
22435 unformat_ip4_address, &v4last))
22439 errmsg ("one range per message (range already set)");
22444 else if (unformat (i, "%U - %U",
22445 unformat_ip6_address, &v6first,
22446 unformat_ip6_address, &v6last))
22450 errmsg ("one range per message (range already set)");
22455 else if (unformat (i, "vrf %d", &vrf_id))
22461 if (range_set == 0)
22463 errmsg ("address range not set");
22467 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
22468 mp->vrf_id = ntohl (vrf_id);
22470 if (range_set == 2)
22473 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
22474 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
22479 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
22480 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
22487 static void vl_api_app_namespace_add_del_reply_t_handler
22488 (vl_api_app_namespace_add_del_reply_t * mp)
22490 vat_main_t *vam = &vat_main;
22491 i32 retval = ntohl (mp->retval);
22492 if (vam->async_mode)
22494 vam->async_errors += (retval < 0);
22498 vam->retval = retval;
22500 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
22501 vam->result_ready = 1;
22505 static void vl_api_app_namespace_add_del_reply_t_handler_json
22506 (vl_api_app_namespace_add_del_reply_t * mp)
22508 vat_main_t *vam = &vat_main;
22509 vat_json_node_t node;
22511 vat_json_init_object (&node);
22512 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
22513 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
22515 vat_json_print (vam->ofp, &node);
22516 vat_json_free (&node);
22518 vam->retval = ntohl (mp->retval);
22519 vam->result_ready = 1;
22523 api_app_namespace_add_del (vat_main_t * vam)
22525 vl_api_app_namespace_add_del_t *mp;
22526 unformat_input_t *i = vam->input;
22527 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
22528 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
22532 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22534 if (unformat (i, "id %_%v%_", &ns_id))
22536 else if (unformat (i, "secret %lu", &secret))
22538 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22539 sw_if_index_set = 1;
22540 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
22542 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
22547 if (!ns_id || !secret_set || !sw_if_index_set)
22549 errmsg ("namespace id, secret and sw_if_index must be set");
22552 if (vec_len (ns_id) > 64)
22554 errmsg ("namespace id too long");
22557 M (APP_NAMESPACE_ADD_DEL, mp);
22559 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
22560 mp->namespace_id_len = vec_len (ns_id);
22561 mp->secret = clib_host_to_net_u64 (secret);
22562 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
22563 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
22564 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
22572 api_sock_init_shm (vat_main_t * vam)
22574 #if VPP_API_TEST_BUILTIN == 0
22575 unformat_input_t *i = vam->input;
22576 vl_api_shm_elem_config_t *config = 0;
22577 u64 size = 64 << 20;
22580 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22582 if (unformat (i, "size %U", unformat_memory_size, &size))
22589 * Canned custom ring allocator config.
22590 * Should probably parse all of this
22592 vec_validate (config, 6);
22593 config[0].type = VL_API_VLIB_RING;
22594 config[0].size = 256;
22595 config[0].count = 32;
22597 config[1].type = VL_API_VLIB_RING;
22598 config[1].size = 1024;
22599 config[1].count = 16;
22601 config[2].type = VL_API_VLIB_RING;
22602 config[2].size = 4096;
22603 config[2].count = 2;
22605 config[3].type = VL_API_CLIENT_RING;
22606 config[3].size = 256;
22607 config[3].count = 32;
22609 config[4].type = VL_API_CLIENT_RING;
22610 config[4].size = 1024;
22611 config[4].count = 16;
22613 config[5].type = VL_API_CLIENT_RING;
22614 config[5].size = 4096;
22615 config[5].count = 2;
22617 config[6].type = VL_API_QUEUE;
22618 config[6].count = 128;
22619 config[6].size = sizeof (uword);
22621 rv = vl_socket_client_init_shm (config);
22623 vam->client_index_invalid = 1;
22631 api_dns_enable_disable (vat_main_t * vam)
22633 unformat_input_t *line_input = vam->input;
22634 vl_api_dns_enable_disable_t *mp;
22635 u8 enable_disable = 1;
22638 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22640 if (unformat (line_input, "disable"))
22641 enable_disable = 0;
22642 if (unformat (line_input, "enable"))
22643 enable_disable = 1;
22648 /* Construct the API message */
22649 M (DNS_ENABLE_DISABLE, mp);
22650 mp->enable = enable_disable;
22654 /* Wait for the reply */
22660 api_dns_resolve_name (vat_main_t * vam)
22662 unformat_input_t *line_input = vam->input;
22663 vl_api_dns_resolve_name_t *mp;
22667 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22669 if (unformat (line_input, "%s", &name))
22675 if (vec_len (name) > 127)
22677 errmsg ("name too long");
22681 /* Construct the API message */
22682 M (DNS_RESOLVE_NAME, mp);
22683 memcpy (mp->name, name, vec_len (name));
22688 /* Wait for the reply */
22694 api_dns_resolve_ip (vat_main_t * vam)
22696 unformat_input_t *line_input = vam->input;
22697 vl_api_dns_resolve_ip_t *mp;
22699 ip4_address_t addr4;
22700 ip6_address_t addr6;
22703 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22705 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
22707 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
22715 errmsg ("missing address");
22719 /* Construct the API message */
22720 M (DNS_RESOLVE_IP, mp);
22721 mp->is_ip6 = is_ip6;
22723 memcpy (mp->address, &addr6, sizeof (addr6));
22725 memcpy (mp->address, &addr4, sizeof (addr4));
22729 /* Wait for the reply */
22735 api_dns_name_server_add_del (vat_main_t * vam)
22737 unformat_input_t *i = vam->input;
22738 vl_api_dns_name_server_add_del_t *mp;
22740 ip6_address_t ip6_server;
22741 ip4_address_t ip4_server;
22746 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22748 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
22750 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
22752 else if (unformat (i, "del"))
22756 clib_warning ("parse error '%U'", format_unformat_error, i);
22761 if (ip4_set && ip6_set)
22763 errmsg ("Only one server address allowed per message");
22766 if ((ip4_set + ip6_set) == 0)
22768 errmsg ("Server address required");
22772 /* Construct the API message */
22773 M (DNS_NAME_SERVER_ADD_DEL, mp);
22777 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
22782 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
22786 mp->is_add = is_add;
22791 /* Wait for a reply, return good/bad news */
22797 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
22799 vat_main_t *vam = &vat_main;
22804 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22805 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22806 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
22807 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
22808 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22809 clib_net_to_host_u32 (mp->action_index), mp->tag);
22814 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22815 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22816 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
22817 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
22818 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22819 clib_net_to_host_u32 (mp->action_index), mp->tag);
22824 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
22827 vat_main_t *vam = &vat_main;
22828 vat_json_node_t *node = NULL;
22829 struct in6_addr ip6;
22830 struct in_addr ip4;
22832 if (VAT_JSON_ARRAY != vam->json_tree.type)
22834 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22835 vat_json_init_array (&vam->json_tree);
22837 node = vat_json_array_add (&vam->json_tree);
22838 vat_json_init_object (node);
22840 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
22841 vat_json_object_add_uint (node, "appns_index",
22842 clib_net_to_host_u32 (mp->appns_index));
22843 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
22844 vat_json_object_add_uint (node, "scope", mp->scope);
22845 vat_json_object_add_uint (node, "action_index",
22846 clib_net_to_host_u32 (mp->action_index));
22847 vat_json_object_add_uint (node, "lcl_port",
22848 clib_net_to_host_u16 (mp->lcl_port));
22849 vat_json_object_add_uint (node, "rmt_port",
22850 clib_net_to_host_u16 (mp->rmt_port));
22851 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
22852 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
22853 vat_json_object_add_string_copy (node, "tag", mp->tag);
22856 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
22857 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
22858 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
22859 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
22863 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
22864 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
22865 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
22866 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
22871 api_session_rule_add_del (vat_main_t * vam)
22873 vl_api_session_rule_add_del_t *mp;
22874 unformat_input_t *i = vam->input;
22875 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
22876 u32 appns_index = 0, scope = 0;
22877 ip4_address_t lcl_ip4, rmt_ip4;
22878 ip6_address_t lcl_ip6, rmt_ip6;
22879 u8 is_ip4 = 1, conn_set = 0;
22880 u8 is_add = 1, *tag = 0;
22883 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22885 if (unformat (i, "del"))
22887 else if (unformat (i, "add"))
22889 else if (unformat (i, "proto tcp"))
22891 else if (unformat (i, "proto udp"))
22893 else if (unformat (i, "appns %d", &appns_index))
22895 else if (unformat (i, "scope %d", &scope))
22897 else if (unformat (i, "tag %_%v%_", &tag))
22901 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
22902 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
22910 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
22911 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
22917 else if (unformat (i, "action %d", &action))
22922 if (proto == ~0 || !conn_set || action == ~0)
22924 errmsg ("transport proto, connection and action must be set");
22930 errmsg ("scope should be 0-3");
22934 M (SESSION_RULE_ADD_DEL, mp);
22936 mp->is_ip4 = is_ip4;
22937 mp->transport_proto = proto;
22938 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
22939 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
22940 mp->lcl_plen = lcl_plen;
22941 mp->rmt_plen = rmt_plen;
22942 mp->action_index = clib_host_to_net_u32 (action);
22943 mp->appns_index = clib_host_to_net_u32 (appns_index);
22945 mp->is_add = is_add;
22948 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
22949 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
22953 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
22954 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
22958 clib_memcpy (mp->tag, tag, vec_len (tag));
22968 api_session_rules_dump (vat_main_t * vam)
22970 vl_api_session_rules_dump_t *mp;
22971 vl_api_control_ping_t *mp_ping;
22974 if (!vam->json_output)
22976 print (vam->ofp, "%=20s", "Session Rules");
22979 M (SESSION_RULES_DUMP, mp);
22983 /* Use a control ping for synchronization */
22984 MPING (CONTROL_PING, mp_ping);
22987 /* Wait for a reply... */
22993 api_ip_container_proxy_add_del (vat_main_t * vam)
22995 vl_api_ip_container_proxy_add_del_t *mp;
22996 unformat_input_t *i = vam->input;
22997 u32 plen = ~0, sw_if_index = ~0;
23004 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
23006 if (unformat (i, "del"))
23008 else if (unformat (i, "add"))
23010 if (unformat (i, "%U", unformat_ip4_address, &ip4))
23015 else if (unformat (i, "%U", unformat_ip6_address, &ip6))
23020 else if (unformat (i, "sw_if_index %u", &sw_if_index))
23025 if (sw_if_index == ~0 || plen == ~0)
23027 errmsg ("address and sw_if_index must be set");
23031 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
23033 mp->is_ip4 = is_ip4;
23034 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
23036 mp->is_add = is_add;
23038 clib_memcpy (mp->ip, &ip4, sizeof (ip4));
23040 clib_memcpy (mp->ip, &ip6, sizeof (ip6));
23048 api_qos_record_enable_disable (vat_main_t * vam)
23050 unformat_input_t *i = vam->input;
23051 vl_api_qos_record_enable_disable_t *mp;
23052 u32 sw_if_index, qs = 0xff;
23053 u8 sw_if_index_set = 0;
23057 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
23059 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
23060 sw_if_index_set = 1;
23061 else if (unformat (i, "sw_if_index %d", &sw_if_index))
23062 sw_if_index_set = 1;
23063 else if (unformat (i, "%U", unformat_qos_source, &qs))
23065 else if (unformat (i, "disable"))
23069 clib_warning ("parse error '%U'", format_unformat_error, i);
23074 if (sw_if_index_set == 0)
23076 errmsg ("missing interface name or sw_if_index");
23081 errmsg ("input location must be specified");
23085 M (QOS_RECORD_ENABLE_DISABLE, mp);
23087 mp->sw_if_index = ntohl (sw_if_index);
23088 mp->input_source = qs;
23089 mp->enable = enable;
23098 q_or_quit (vat_main_t * vam)
23100 #if VPP_API_TEST_BUILTIN == 0
23101 longjmp (vam->jump_buf, 1);
23103 return 0; /* not so much */
23107 q (vat_main_t * vam)
23109 return q_or_quit (vam);
23113 quit (vat_main_t * vam)
23115 return q_or_quit (vam);
23119 comment (vat_main_t * vam)
23125 statseg (vat_main_t * vam)
23127 ssvm_private_t *ssvmp = &vam->stat_segment;
23128 ssvm_shared_header_t *shared_header = ssvmp->sh;
23129 vlib_counter_t **counters;
23130 u64 thread0_index1_packets;
23131 u64 thread0_index1_bytes;
23132 f64 vector_rate, input_rate;
23135 uword *counter_vector_by_name;
23136 if (vam->stat_segment_lockp == 0)
23138 errmsg ("Stat segment not mapped...");
23142 /* look up "/if/rx for sw_if_index 1 as a test */
23144 clib_spinlock_lock (vam->stat_segment_lockp);
23146 counter_vector_by_name = (uword *) shared_header->opaque[1];
23148 p = hash_get_mem (counter_vector_by_name, "/if/rx");
23151 clib_spinlock_unlock (vam->stat_segment_lockp);
23152 errmsg ("/if/tx not found?");
23156 /* Fish per-thread vector of combined counters from shared memory */
23157 counters = (vlib_counter_t **) p[0];
23159 if (vec_len (counters[0]) < 2)
23161 clib_spinlock_unlock (vam->stat_segment_lockp);
23162 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
23166 /* Read thread 0 sw_if_index 1 counter */
23167 thread0_index1_packets = counters[0][1].packets;
23168 thread0_index1_bytes = counters[0][1].bytes;
23170 p = hash_get_mem (counter_vector_by_name, "vector_rate");
23173 clib_spinlock_unlock (vam->stat_segment_lockp);
23174 errmsg ("vector_rate not found?");
23178 vector_rate = *(f64 *) (p[0]);
23179 p = hash_get_mem (counter_vector_by_name, "input_rate");
23182 clib_spinlock_unlock (vam->stat_segment_lockp);
23183 errmsg ("input_rate not found?");
23186 input_rate = *(f64 *) (p[0]);
23188 clib_spinlock_unlock (vam->stat_segment_lockp);
23190 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
23191 vector_rate, input_rate);
23192 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
23193 thread0_index1_packets, thread0_index1_bytes);
23199 cmd_cmp (void *a1, void *a2)
23204 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
23208 help (vat_main_t * vam)
23213 unformat_input_t *i = vam->input;
23216 if (unformat (i, "%s", &name))
23220 vec_add1 (name, 0);
23222 hs = hash_get_mem (vam->help_by_name, name);
23224 print (vam->ofp, "usage: %s %s", name, hs[0]);
23226 print (vam->ofp, "No such msg / command '%s'", name);
23231 print (vam->ofp, "Help is available for the following:");
23234 hash_foreach_pair (p, vam->function_by_name,
23236 vec_add1 (cmds, (u8 *)(p->key));
23240 vec_sort_with_function (cmds, cmd_cmp);
23242 for (j = 0; j < vec_len (cmds); j++)
23243 print (vam->ofp, "%s", cmds[j]);
23250 set (vat_main_t * vam)
23252 u8 *name = 0, *value = 0;
23253 unformat_input_t *i = vam->input;
23255 if (unformat (i, "%s", &name))
23257 /* The input buffer is a vector, not a string. */
23258 value = vec_dup (i->buffer);
23259 vec_delete (value, i->index, 0);
23260 /* Almost certainly has a trailing newline */
23261 if (value[vec_len (value) - 1] == '\n')
23262 value[vec_len (value) - 1] = 0;
23263 /* Make sure it's a proper string, one way or the other */
23264 vec_add1 (value, 0);
23265 (void) clib_macro_set_value (&vam->macro_main,
23266 (char *) name, (char *) value);
23269 errmsg ("usage: set <name> <value>");
23277 unset (vat_main_t * vam)
23281 if (unformat (vam->input, "%s", &name))
23282 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
23283 errmsg ("unset: %s wasn't set", name);
23296 macro_sort_cmp (void *a1, void *a2)
23298 macro_sort_t *s1 = a1;
23299 macro_sort_t *s2 = a2;
23301 return strcmp ((char *) (s1->name), (char *) (s2->name));
23305 dump_macro_table (vat_main_t * vam)
23307 macro_sort_t *sort_me = 0, *sm;
23312 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
23314 vec_add2 (sort_me, sm, 1);
23315 sm->name = (u8 *)(p->key);
23316 sm->value = (u8 *) (p->value[0]);
23320 vec_sort_with_function (sort_me, macro_sort_cmp);
23322 if (vec_len (sort_me))
23323 print (vam->ofp, "%-15s%s", "Name", "Value");
23325 print (vam->ofp, "The macro table is empty...");
23327 for (i = 0; i < vec_len (sort_me); i++)
23328 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
23333 dump_node_table (vat_main_t * vam)
23336 vlib_node_t *node, *next_node;
23338 if (vec_len (vam->graph_nodes) == 0)
23340 print (vam->ofp, "Node table empty, issue get_node_graph...");
23344 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
23346 node = vam->graph_nodes[0][i];
23347 print (vam->ofp, "[%d] %s", i, node->name);
23348 for (j = 0; j < vec_len (node->next_nodes); j++)
23350 if (node->next_nodes[j] != ~0)
23352 next_node = vam->graph_nodes[0][node->next_nodes[j]];
23353 print (vam->ofp, " [%d] %s", j, next_node->name);
23361 value_sort_cmp (void *a1, void *a2)
23363 name_sort_t *n1 = a1;
23364 name_sort_t *n2 = a2;
23366 if (n1->value < n2->value)
23368 if (n1->value > n2->value)
23375 dump_msg_api_table (vat_main_t * vam)
23377 api_main_t *am = &api_main;
23378 name_sort_t *nses = 0, *ns;
23383 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
23385 vec_add2 (nses, ns, 1);
23386 ns->name = (u8 *)(hp->key);
23387 ns->value = (u32) hp->value[0];
23391 vec_sort_with_function (nses, value_sort_cmp);
23393 for (i = 0; i < vec_len (nses); i++)
23394 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
23400 get_msg_id (vat_main_t * vam)
23405 if (unformat (vam->input, "%s", &name_and_crc))
23407 message_index = vl_msg_api_get_msg_index (name_and_crc);
23408 if (message_index == ~0)
23410 print (vam->ofp, " '%s' not found", name_and_crc);
23413 print (vam->ofp, " '%s' has message index %d",
23414 name_and_crc, message_index);
23417 errmsg ("name_and_crc required...");
23422 search_node_table (vat_main_t * vam)
23424 unformat_input_t *line_input = vam->input;
23427 vlib_node_t *node, *next_node;
23430 if (vam->graph_node_index_by_name == 0)
23432 print (vam->ofp, "Node table empty, issue get_node_graph...");
23436 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
23438 if (unformat (line_input, "%s", &node_to_find))
23440 vec_add1 (node_to_find, 0);
23441 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
23444 print (vam->ofp, "%s not found...", node_to_find);
23447 node = vam->graph_nodes[0][p[0]];
23448 print (vam->ofp, "[%d] %s", p[0], node->name);
23449 for (j = 0; j < vec_len (node->next_nodes); j++)
23451 if (node->next_nodes[j] != ~0)
23453 next_node = vam->graph_nodes[0][node->next_nodes[j]];
23454 print (vam->ofp, " [%d] %s", j, next_node->name);
23461 clib_warning ("parse error '%U'", format_unformat_error,
23467 vec_free (node_to_find);
23476 script (vat_main_t * vam)
23478 #if (VPP_API_TEST_BUILTIN==0)
23480 char *save_current_file;
23481 unformat_input_t save_input;
23482 jmp_buf save_jump_buf;
23483 u32 save_line_number;
23485 FILE *new_fp, *save_ifp;
23487 if (unformat (vam->input, "%s", &s))
23489 new_fp = fopen ((char *) s, "r");
23492 errmsg ("Couldn't open script file %s", s);
23499 errmsg ("Missing script name");
23503 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
23504 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
23505 save_ifp = vam->ifp;
23506 save_line_number = vam->input_line_number;
23507 save_current_file = (char *) vam->current_file;
23509 vam->input_line_number = 0;
23511 vam->current_file = s;
23514 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
23515 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
23516 vam->ifp = save_ifp;
23517 vam->input_line_number = save_line_number;
23518 vam->current_file = (u8 *) save_current_file;
23523 clib_warning ("use the exec command...");
23529 echo (vat_main_t * vam)
23531 print (vam->ofp, "%v", vam->input->buffer);
23535 /* List of API message constructors, CLI names map to api_xxx */
23536 #define foreach_vpe_api_msg \
23537 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
23538 _(sw_interface_dump,"") \
23539 _(sw_interface_set_flags, \
23540 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
23541 _(sw_interface_add_del_address, \
23542 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
23543 _(sw_interface_set_rx_mode, \
23544 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
23545 _(sw_interface_set_rx_placement, \
23546 "<intfc> | sw_if_index <id> [queue <id>] [worker <id> | main]") \
23547 _(sw_interface_rx_placement_dump, \
23548 "[<intfc> | sw_if_index <id>]") \
23549 _(sw_interface_set_table, \
23550 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
23551 _(sw_interface_set_mpls_enable, \
23552 "<intfc> | sw_if_index [disable | dis]") \
23553 _(sw_interface_set_vpath, \
23554 "<intfc> | sw_if_index <id> enable | disable") \
23555 _(sw_interface_set_vxlan_bypass, \
23556 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23557 _(sw_interface_set_geneve_bypass, \
23558 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23559 _(sw_interface_set_l2_xconnect, \
23560 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23561 "enable | disable") \
23562 _(sw_interface_set_l2_bridge, \
23563 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
23564 "[shg <split-horizon-group>] [bvi]\n" \
23565 "enable | disable") \
23566 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
23567 _(bridge_domain_add_del, \
23568 "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") \
23569 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
23571 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
23572 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
23573 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
23575 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23577 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23579 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
23581 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
23583 "<vpp-if-name> | sw_if_index <id>") \
23584 _(sw_interface_tap_dump, "") \
23586 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>]") \
23588 "<vpp-if-name> | sw_if_index <id>") \
23589 _(sw_interface_tap_v2_dump, "") \
23591 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
23592 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]}") \
23594 "<vpp-if-name> | sw_if_index <id>") \
23596 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
23597 _(bond_detach_slave, \
23598 "sw_if_index <n>") \
23599 _(sw_interface_bond_dump, "") \
23600 _(sw_interface_slave_dump, \
23601 "<vpp-if-name> | sw_if_index <id>") \
23602 _(ip_table_add_del, \
23603 "table <n> [ipv6] [add | del]\n") \
23604 _(ip_add_del_route, \
23605 "<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
23606 "[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
23607 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
23608 "[multipath] [count <n>]") \
23609 _(ip_mroute_add_del, \
23610 "<src> <grp>/<mask> [table-id <n>]\n" \
23611 "[<intfc> | sw_if_index <id>] [local] [del]") \
23612 _(mpls_table_add_del, \
23613 "table <n> [add | del]\n") \
23614 _(mpls_route_add_del, \
23615 "<label> <eos> via <addr | next-hop-table <n> | via-label <n> |\n" \
23616 "lookup-ip4-table <n> | lookup-in-ip6-table <n> |\n" \
23617 "l2-input-on <intfc> | l2-input-on sw_if_index <id>>\n" \
23618 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>] [weight <n>]\n" \
23619 "[drop] [local] [classify <n>] [multipath] [count <n>] [del]") \
23620 _(mpls_ip_bind_unbind, \
23621 "<label> <addr/len>") \
23622 _(mpls_tunnel_add_del, \
23623 " via <addr> [table-id <n>]\n" \
23624 "sw_if_index <id>] [l2] [del]") \
23625 _(sr_mpls_policy_add, \
23626 "bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
23627 _(sr_mpls_policy_del, \
23629 _(bier_table_add_del, \
23630 "<label> <sub-domain> <set> <bsl> [del]") \
23631 _(bier_route_add_del, \
23632 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
23633 "[<intfc> | sw_if_index <id>]" \
23634 "[weight <n>] [del] [multipath]") \
23635 _(proxy_arp_add_del, \
23636 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
23637 _(proxy_arp_intfc_enable_disable, \
23638 "<intfc> | sw_if_index <id> enable | disable") \
23639 _(sw_interface_set_unnumbered, \
23640 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
23641 _(ip_neighbor_add_del, \
23642 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
23643 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
23644 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
23645 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
23646 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
23647 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
23648 "[outer_vlan_id_any][inner_vlan_id_any]") \
23649 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
23650 _(reset_fib, "vrf <n> [ipv6]") \
23651 _(dhcp_proxy_config, \
23652 "svr <v46-address> src <v46-address>\n" \
23653 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
23654 _(dhcp_proxy_set_vss, \
23655 "tbl_id <n> [fib_id <n> oui <n> | vpn_ascii_id <text>] [ipv6] [del]") \
23656 _(dhcp_proxy_dump, "ip6") \
23657 _(dhcp_client_config, \
23658 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
23659 _(set_ip_flow_hash, \
23660 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
23661 _(sw_interface_ip6_enable_disable, \
23662 "<intfc> | sw_if_index <id> enable | disable") \
23663 _(sw_interface_ip6_set_link_local_address, \
23664 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
23665 _(ip6nd_proxy_add_del, \
23666 "<intfc> | sw_if_index <id> <ip6-address>") \
23667 _(ip6nd_proxy_dump, "") \
23668 _(sw_interface_ip6nd_ra_prefix, \
23669 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
23670 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
23671 "[nolink] [isno]") \
23672 _(sw_interface_ip6nd_ra_config, \
23673 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
23674 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
23675 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
23676 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
23677 _(l2_patch_add_del, \
23678 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23679 "enable | disable") \
23680 _(sr_localsid_add_del, \
23681 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
23682 "fib-table <num> (end.psp) sw_if_index <num>") \
23683 _(classify_add_del_table, \
23684 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
23685 " [del] [del-chain] mask <mask-value>\n" \
23686 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
23687 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
23688 _(classify_add_del_session, \
23689 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
23690 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
23691 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
23692 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
23693 _(classify_set_interface_ip_table, \
23694 "<intfc> | sw_if_index <nn> table <nn>") \
23695 _(classify_set_interface_l2_tables, \
23696 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23697 " [other-table <nn>]") \
23698 _(get_node_index, "node <node-name") \
23699 _(add_node_next, "node <node-name> next <next-node-name>") \
23700 _(l2tpv3_create_tunnel, \
23701 "client_address <ip6-addr> our_address <ip6-addr>\n" \
23702 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
23703 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
23704 _(l2tpv3_set_tunnel_cookies, \
23705 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
23706 "[new_remote_cookie <nn>]\n") \
23707 _(l2tpv3_interface_enable_disable, \
23708 "<intfc> | sw_if_index <nn> enable | disable") \
23709 _(l2tpv3_set_lookup_key, \
23710 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
23711 _(sw_if_l2tpv3_tunnel_dump, "") \
23712 _(vxlan_offload_rx, \
23713 "hw { <interface name> | hw_if_index <nn>} " \
23714 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
23715 _(vxlan_add_del_tunnel, \
23716 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23717 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
23718 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23719 _(geneve_add_del_tunnel, \
23720 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23721 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23722 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23723 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23724 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23725 _(gre_add_del_tunnel, \
23726 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
23727 "[teb | erspan <session-id>] [del]") \
23728 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23729 _(l2_fib_clear_table, "") \
23730 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
23731 _(l2_interface_vlan_tag_rewrite, \
23732 "<intfc> | sw_if_index <nn> \n" \
23733 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
23734 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
23735 _(create_vhost_user_if, \
23736 "socket <filename> [server] [renumber <dev_instance>] " \
23737 "[disable_mrg_rxbuf] [disable_indirect_desc] " \
23738 "[mac <mac_address>]") \
23739 _(modify_vhost_user_if, \
23740 "<intfc> | sw_if_index <nn> socket <filename>\n" \
23741 "[server] [renumber <dev_instance>]") \
23742 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
23743 _(sw_interface_vhost_user_dump, "") \
23744 _(show_version, "") \
23745 _(vxlan_gpe_add_del_tunnel, \
23746 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
23747 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23748 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
23749 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
23750 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23751 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
23752 _(interface_name_renumber, \
23753 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
23754 _(input_acl_set_interface, \
23755 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23756 " [l2-table <nn>] [del]") \
23757 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
23758 _(ip_scan_neighbor_enable_disable, "[ip4|ip6|both|disable] [interval <n-min>]\n" \
23759 " [max-time <n-usec>] [max-update <n>] [delay <n-msec>] [stale <n-min>]") \
23760 _(want_ip4_arp_events, "address <ip4-address> [del]") \
23761 _(want_ip6_nd_events, "address <ip6-address> [del]") \
23762 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
23763 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
23764 _(ip_dump, "ipv4 | ipv6") \
23765 _(ipsec_spd_add_del, "spd_id <n> [del]") \
23766 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
23768 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
23769 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
23770 " integ_alg <alg> integ_key <hex>") \
23771 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
23772 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
23773 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
23774 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
23775 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
23776 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
23777 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
23778 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
23779 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
23780 " [instance <n>]") \
23781 _(ipsec_sa_dump, "[sa_id <n>]") \
23782 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
23783 " <alg> <hex>\n") \
23784 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
23785 _(ikev2_profile_add_del, "name <profile_name> [del]") \
23786 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
23787 "(auth_data 0x<data> | auth_data <data>)") \
23788 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
23789 "(id_data 0x<data> | id_data <data>) (local|remote)") \
23790 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
23791 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
23792 "(local|remote)") \
23793 _(ikev2_set_local_key, "file <absolute_file_path>") \
23794 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
23795 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23796 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23797 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
23798 _(ikev2_initiate_sa_init, "<profile_name>") \
23799 _(ikev2_initiate_del_ike_sa, "<ispi>") \
23800 _(ikev2_initiate_del_child_sa, "<ispi>") \
23801 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
23802 _(delete_loopback,"sw_if_index <nn>") \
23803 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
23804 _(bd_ip_mac_dump, "[bd_id] <id>") \
23805 _(want_interface_events, "enable|disable") \
23806 _(want_stats,"enable|disable") \
23807 _(get_first_msg_id, "client <name>") \
23808 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
23809 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
23810 "fib-id <nn> [ip4][ip6][default]") \
23811 _(get_node_graph, " ") \
23812 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
23813 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
23814 _(ioam_disable, "") \
23815 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
23816 " sw_if_index <sw_if_index> p <priority> " \
23817 "w <weight>] [del]") \
23818 _(one_add_del_locator, "locator-set <locator_name> " \
23819 "iface <intf> | sw_if_index <sw_if_index> " \
23820 "p <priority> w <weight> [del]") \
23821 _(one_add_del_local_eid,"vni <vni> eid " \
23822 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23823 "locator-set <locator_name> [del]" \
23824 "[key-id sha1|sha256 secret-key <secret-key>]")\
23825 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
23826 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
23827 _(one_enable_disable, "enable|disable") \
23828 _(one_map_register_enable_disable, "enable|disable") \
23829 _(one_map_register_fallback_threshold, "<value>") \
23830 _(one_rloc_probe_enable_disable, "enable|disable") \
23831 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23833 "rloc <locator> p <prio> " \
23834 "w <weight> [rloc <loc> ... ] " \
23835 "action <action> [del-all]") \
23836 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23838 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23839 _(one_use_petr, "ip-address> | disable") \
23840 _(one_map_request_mode, "src-dst|dst-only") \
23841 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23842 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23843 _(one_locator_set_dump, "[local | remote]") \
23844 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
23845 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23846 "[local] | [remote]") \
23847 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
23848 _(one_ndp_bd_get, "") \
23849 _(one_ndp_entries_get, "bd <bridge-domain>") \
23850 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
23851 _(one_l2_arp_bd_get, "") \
23852 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
23853 _(one_stats_enable_disable, "enable|disable") \
23854 _(show_one_stats_enable_disable, "") \
23855 _(one_eid_table_vni_dump, "") \
23856 _(one_eid_table_map_dump, "l2|l3") \
23857 _(one_map_resolver_dump, "") \
23858 _(one_map_server_dump, "") \
23859 _(one_adjacencies_get, "vni <vni>") \
23860 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
23861 _(show_one_rloc_probe_state, "") \
23862 _(show_one_map_register_state, "") \
23863 _(show_one_status, "") \
23864 _(one_stats_dump, "") \
23865 _(one_stats_flush, "") \
23866 _(one_get_map_request_itr_rlocs, "") \
23867 _(one_map_register_set_ttl, "<ttl>") \
23868 _(one_set_transport_protocol, "udp|api") \
23869 _(one_get_transport_protocol, "") \
23870 _(one_enable_disable_xtr_mode, "enable|disable") \
23871 _(one_show_xtr_mode, "") \
23872 _(one_enable_disable_pitr_mode, "enable|disable") \
23873 _(one_show_pitr_mode, "") \
23874 _(one_enable_disable_petr_mode, "enable|disable") \
23875 _(one_show_petr_mode, "") \
23876 _(show_one_nsh_mapping, "") \
23877 _(show_one_pitr, "") \
23878 _(show_one_use_petr, "") \
23879 _(show_one_map_request_mode, "") \
23880 _(show_one_map_register_ttl, "") \
23881 _(show_one_map_register_fallback_threshold, "") \
23882 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
23883 " sw_if_index <sw_if_index> p <priority> " \
23884 "w <weight>] [del]") \
23885 _(lisp_add_del_locator, "locator-set <locator_name> " \
23886 "iface <intf> | sw_if_index <sw_if_index> " \
23887 "p <priority> w <weight> [del]") \
23888 _(lisp_add_del_local_eid,"vni <vni> eid " \
23889 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23890 "locator-set <locator_name> [del]" \
23891 "[key-id sha1|sha256 secret-key <secret-key>]") \
23892 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
23893 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
23894 _(lisp_enable_disable, "enable|disable") \
23895 _(lisp_map_register_enable_disable, "enable|disable") \
23896 _(lisp_rloc_probe_enable_disable, "enable|disable") \
23897 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23899 "rloc <locator> p <prio> " \
23900 "w <weight> [rloc <loc> ... ] " \
23901 "action <action> [del-all]") \
23902 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23904 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23905 _(lisp_use_petr, "<ip-address> | disable") \
23906 _(lisp_map_request_mode, "src-dst|dst-only") \
23907 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23908 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23909 _(lisp_locator_set_dump, "[local | remote]") \
23910 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
23911 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23912 "[local] | [remote]") \
23913 _(lisp_eid_table_vni_dump, "") \
23914 _(lisp_eid_table_map_dump, "l2|l3") \
23915 _(lisp_map_resolver_dump, "") \
23916 _(lisp_map_server_dump, "") \
23917 _(lisp_adjacencies_get, "vni <vni>") \
23918 _(gpe_fwd_entry_vnis_get, "") \
23919 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
23920 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
23921 "[table <table-id>]") \
23922 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
23923 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
23924 _(gpe_set_encap_mode, "lisp|vxlan") \
23925 _(gpe_get_encap_mode, "") \
23926 _(lisp_gpe_add_del_iface, "up|down") \
23927 _(lisp_gpe_enable_disable, "enable|disable") \
23928 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
23929 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
23930 _(show_lisp_rloc_probe_state, "") \
23931 _(show_lisp_map_register_state, "") \
23932 _(show_lisp_status, "") \
23933 _(lisp_get_map_request_itr_rlocs, "") \
23934 _(show_lisp_pitr, "") \
23935 _(show_lisp_use_petr, "") \
23936 _(show_lisp_map_request_mode, "") \
23937 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
23938 _(af_packet_delete, "name <host interface name>") \
23939 _(af_packet_dump, "") \
23940 _(policer_add_del, "name <policer name> <params> [del]") \
23941 _(policer_dump, "[name <policer name>]") \
23942 _(policer_classify_set_interface, \
23943 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23944 " [l2-table <nn>] [del]") \
23945 _(policer_classify_dump, "type [ip4|ip6|l2]") \
23946 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
23947 "[master|slave]") \
23948 _(netmap_delete, "name <interface name>") \
23949 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
23950 _(mpls_fib_dump, "") \
23951 _(classify_table_ids, "") \
23952 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
23953 _(classify_table_info, "table_id <nn>") \
23954 _(classify_session_dump, "table_id <nn>") \
23955 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
23956 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
23957 "[template_interval <nn>] [udp_checksum]") \
23958 _(ipfix_exporter_dump, "") \
23959 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
23960 _(ipfix_classify_stream_dump, "") \
23961 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
23962 _(ipfix_classify_table_dump, "") \
23963 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
23964 _(sw_interface_span_dump, "[l2]") \
23965 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
23966 _(pg_create_interface, "if_id <nn>") \
23967 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
23968 _(pg_enable_disable, "[stream <id>] disable") \
23969 _(ip_source_and_port_range_check_add_del, \
23970 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
23971 _(ip_source_and_port_range_check_interface_add_del, \
23972 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
23973 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
23974 _(ipsec_gre_add_del_tunnel, \
23975 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
23976 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
23977 _(delete_subif,"<intfc> | sw_if_index <nn>") \
23978 _(l2_interface_pbb_tag_rewrite, \
23979 "<intfc> | sw_if_index <nn> \n" \
23980 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
23981 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
23982 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
23983 _(flow_classify_set_interface, \
23984 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
23985 _(flow_classify_dump, "type [ip4|ip6]") \
23986 _(ip_fib_dump, "") \
23987 _(ip_mfib_dump, "") \
23988 _(ip6_fib_dump, "") \
23989 _(ip6_mfib_dump, "") \
23990 _(feature_enable_disable, "arc_name <arc_name> " \
23991 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
23992 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
23994 _(l2_xconnect_dump, "") \
23995 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
23996 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
23997 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
23998 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
23999 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
24000 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
24001 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
24002 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
24003 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
24004 _(sock_init_shm, "size <nnn>") \
24005 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
24006 _(dns_enable_disable, "[enable][disable]") \
24007 _(dns_name_server_add_del, "<ip-address> [del]") \
24008 _(dns_resolve_name, "<hostname>") \
24009 _(dns_resolve_ip, "<ip4|ip6>") \
24010 _(dns_name_server_add_del, "<ip-address> [del]") \
24011 _(dns_resolve_name, "<hostname>") \
24012 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
24013 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
24014 _(session_rules_dump, "") \
24015 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
24016 _(output_acl_set_interface, \
24017 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
24018 " [l2-table <nn>] [del]") \
24019 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
24021 /* List of command functions, CLI names map directly to functions */
24022 #define foreach_cli_function \
24023 _(comment, "usage: comment <ignore-rest-of-line>") \
24024 _(dump_interface_table, "usage: dump_interface_table") \
24025 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
24026 _(dump_ipv4_table, "usage: dump_ipv4_table") \
24027 _(dump_ipv6_table, "usage: dump_ipv6_table") \
24028 _(dump_stats_table, "usage: dump_stats_table") \
24029 _(dump_macro_table, "usage: dump_macro_table ") \
24030 _(dump_node_table, "usage: dump_node_table") \
24031 _(dump_msg_api_table, "usage: dump_msg_api_table") \
24032 _(get_msg_id, "usage: get_msg_id name_and_crc") \
24033 _(echo, "usage: echo <message>") \
24034 _(exec, "usage: exec <vpe-debug-CLI-command>") \
24035 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
24036 _(help, "usage: help") \
24037 _(q, "usage: quit") \
24038 _(quit, "usage: quit") \
24039 _(search_node_table, "usage: search_node_table <name>...") \
24040 _(set, "usage: set <variable-name> <value>") \
24041 _(script, "usage: script <file-name>") \
24042 _(statseg, "usage: statseg"); \
24043 _(unset, "usage: unset <variable-name>")
24046 static void vl_api_##n##_t_handler_uni \
24047 (vl_api_##n##_t * mp) \
24049 vat_main_t * vam = &vat_main; \
24050 if (vam->json_output) { \
24051 vl_api_##n##_t_handler_json(mp); \
24053 vl_api_##n##_t_handler(mp); \
24056 foreach_vpe_api_reply_msg;
24057 #if VPP_API_TEST_BUILTIN == 0
24058 foreach_standalone_reply_msg;
24063 vat_api_hookup (vat_main_t * vam)
24066 vl_msg_api_set_handlers(VL_API_##N, #n, \
24067 vl_api_##n##_t_handler_uni, \
24069 vl_api_##n##_t_endian, \
24070 vl_api_##n##_t_print, \
24071 sizeof(vl_api_##n##_t), 1);
24072 foreach_vpe_api_reply_msg;
24073 #if VPP_API_TEST_BUILTIN == 0
24074 foreach_standalone_reply_msg;
24078 #if (VPP_API_TEST_BUILTIN==0)
24079 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
24081 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
24083 vam->function_by_name = hash_create_string (0, sizeof (uword));
24085 vam->help_by_name = hash_create_string (0, sizeof (uword));
24088 /* API messages we can send */
24089 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
24090 foreach_vpe_api_msg;
24094 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
24095 foreach_vpe_api_msg;
24098 /* CLI functions */
24099 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
24100 foreach_cli_function;
24104 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
24105 foreach_cli_function;
24109 #if VPP_API_TEST_BUILTIN
24110 static clib_error_t *
24111 vat_api_hookup_shim (vlib_main_t * vm)
24113 vat_api_hookup (&vat_main);
24117 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
24121 * fd.io coding-style-patch-verification: ON
24124 * eval: (c-set-style "gnu")