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/l2/l2_input.h>
26 #include <vnet/l2tp/l2tp.h>
27 #include <vnet/vxlan/vxlan.h>
28 #include <vnet/geneve/geneve.h>
29 #include <vnet/gre/gre.h>
30 #include <vnet/vxlan-gpe/vxlan_gpe.h>
31 #include <vnet/lisp-gpe/lisp_gpe.h>
33 #include <vpp/api/vpe_msg_enum.h>
34 #include <vnet/l2/l2_classify.h>
35 #include <vnet/l2/l2_vtr.h>
36 #include <vnet/classify/input_acl.h>
37 #include <vnet/classify/policer_classify.h>
38 #include <vnet/classify/flow_classify.h>
39 #include <vnet/mpls/mpls.h>
40 #include <vnet/ipsec/ipsec.h>
41 #include <vnet/ipsec/ikev2.h>
43 #include <vnet/map/map.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>
54 #include "vat/json_format.h"
59 #define vl_typedefs /* define message structures */
60 #include <vpp/api/vpe_all_api_h.h>
63 /* declare message handlers for each api */
65 #define vl_endianfun /* define message structures */
66 #include <vpp/api/vpe_all_api_h.h>
69 /* instantiate all the print functions we know about */
70 #define vl_print(handle, ...)
72 #include <vpp/api/vpe_all_api_h.h>
75 #define __plugin_msg_base 0
76 #include <vlibapi/vat_helper_macros.h>
78 #if VPP_API_TEST_BUILTIN == 0
88 vat_socket_connect (vat_main_t * vam)
90 vam->socket_client_main = &socket_client_main;
91 return vl_socket_client_connect ((char *) vam->socket_name, "vpp_api_test",
92 0 /* default socket rx, tx buffer */ );
94 #else /* vpp built-in case, we don't do sockets... */
96 vat_socket_connect (vat_main_t * vam)
102 vl_socket_client_read (int wait)
108 vl_socket_client_write ()
114 vl_socket_client_msg_alloc (int nbytes)
122 vat_time_now (vat_main_t * vam)
124 #if VPP_API_TEST_BUILTIN
125 return vlib_time_now (vam->vlib_main);
127 return clib_time_now (&vam->clib_time);
132 errmsg (char *fmt, ...)
134 vat_main_t *vam = &vat_main;
139 s = va_format (0, fmt, &va);
144 #if VPP_API_TEST_BUILTIN
145 vlib_cli_output (vam->vlib_main, (char *) s);
148 if (vam->ifp != stdin)
149 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
150 vam->input_line_number);
151 fformat (vam->ofp, (char *) s);
159 #if VPP_API_TEST_BUILTIN == 0
161 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
163 vat_main_t *vam = va_arg (*args, vat_main_t *);
164 u32 *result = va_arg (*args, u32 *);
168 if (!unformat (input, "%s", &if_name))
171 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
178 /* Parse an IP4 address %d.%d.%d.%d. */
180 unformat_ip4_address (unformat_input_t * input, va_list * args)
182 u8 *result = va_arg (*args, u8 *);
185 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
188 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
200 unformat_ethernet_address (unformat_input_t * input, va_list * args)
202 u8 *result = va_arg (*args, u8 *);
205 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
206 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
210 for (i = 0; i < 6; i++)
211 if (a[i] >= (1 << 8))
214 for (i = 0; i < 6; i++)
220 /* Returns ethernet type as an int in host byte order. */
222 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
225 u16 *result = va_arg (*args, u16 *);
229 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
231 if (type >= (1 << 16))
239 /* Parse an IP6 address. */
241 unformat_ip6_address (unformat_input_t * input, va_list * args)
243 ip6_address_t *result = va_arg (*args, ip6_address_t *);
245 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
246 uword c, n_colon, double_colon_index;
248 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
249 double_colon_index = ARRAY_LEN (hex_quads);
250 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
253 if (c >= '0' && c <= '9')
255 else if (c >= 'a' && c <= 'f')
256 hex_digit = c + 10 - 'a';
257 else if (c >= 'A' && c <= 'F')
258 hex_digit = c + 10 - 'A';
259 else if (c == ':' && n_colon < 2)
263 unformat_put_input (input);
267 /* Too many hex quads. */
268 if (n_hex_quads >= ARRAY_LEN (hex_quads))
273 hex_quad = (hex_quad << 4) | hex_digit;
275 /* Hex quad must fit in 16 bits. */
276 if (n_hex_digits >= 4)
283 /* Save position of :: */
286 /* More than one :: ? */
287 if (double_colon_index < ARRAY_LEN (hex_quads))
289 double_colon_index = n_hex_quads;
292 if (n_colon > 0 && n_hex_digits > 0)
294 hex_quads[n_hex_quads++] = hex_quad;
300 if (n_hex_digits > 0)
301 hex_quads[n_hex_quads++] = hex_quad;
306 /* Expand :: to appropriate number of zero hex quads. */
307 if (double_colon_index < ARRAY_LEN (hex_quads))
309 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
311 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
312 hex_quads[n_zero + i] = hex_quads[i];
314 for (i = 0; i < n_zero; i++)
315 hex_quads[double_colon_index + i] = 0;
317 n_hex_quads = ARRAY_LEN (hex_quads);
320 /* Too few hex quads given. */
321 if (n_hex_quads < ARRAY_LEN (hex_quads))
324 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
325 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
332 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
334 u32 *r = va_arg (*args, u32 *);
337 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
338 foreach_ipsec_policy_action
346 unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args)
348 u32 *r = va_arg (*args, u32 *);
351 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
352 foreach_ipsec_crypto_alg
360 format_ipsec_crypto_alg (u8 * s, va_list * args)
362 u32 i = va_arg (*args, u32);
367 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
368 foreach_ipsec_crypto_alg
371 return format (s, "unknown");
373 return format (s, "%s", t);
377 unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args)
379 u32 *r = va_arg (*args, u32 *);
382 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f;
383 foreach_ipsec_integ_alg
391 format_ipsec_integ_alg (u8 * s, va_list * args)
393 u32 i = va_arg (*args, u32);
398 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
399 foreach_ipsec_integ_alg
402 return format (s, "unknown");
404 return format (s, "%s", t);
408 unformat_ikev2_auth_method (unformat_input_t * input, va_list * args)
410 u32 *r = va_arg (*args, u32 *);
413 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f;
414 foreach_ikev2_auth_method
422 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
424 u32 *r = va_arg (*args, u32 *);
427 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
428 foreach_ikev2_id_type
434 #else /* VPP_API_TEST_BUILTIN == 1 */
436 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
438 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
439 vnet_main_t *vnm = vnet_get_main ();
440 u32 *result = va_arg (*args, u32 *);
443 if (!unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
446 *result = sw_if_index;
449 #endif /* VPP_API_TEST_BUILTIN */
452 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
454 u8 *r = va_arg (*args, u8 *);
456 if (unformat (input, "kbps"))
457 *r = SSE2_QOS_RATE_KBPS;
458 else if (unformat (input, "pps"))
459 *r = SSE2_QOS_RATE_PPS;
466 unformat_policer_round_type (unformat_input_t * input, va_list * args)
468 u8 *r = va_arg (*args, u8 *);
470 if (unformat (input, "closest"))
471 *r = SSE2_QOS_ROUND_TO_CLOSEST;
472 else if (unformat (input, "up"))
473 *r = SSE2_QOS_ROUND_TO_UP;
474 else if (unformat (input, "down"))
475 *r = SSE2_QOS_ROUND_TO_DOWN;
482 unformat_policer_type (unformat_input_t * input, va_list * args)
484 u8 *r = va_arg (*args, u8 *);
486 if (unformat (input, "1r2c"))
487 *r = SSE2_QOS_POLICER_TYPE_1R2C;
488 else if (unformat (input, "1r3c"))
489 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
490 else if (unformat (input, "2r3c-2698"))
491 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
492 else if (unformat (input, "2r3c-4115"))
493 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
494 else if (unformat (input, "2r3c-mef5cf1"))
495 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
502 unformat_dscp (unformat_input_t * input, va_list * va)
504 u8 *r = va_arg (*va, u8 *);
507 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
516 unformat_policer_action_type (unformat_input_t * input, va_list * va)
518 sse2_qos_pol_action_params_st *a
519 = va_arg (*va, sse2_qos_pol_action_params_st *);
521 if (unformat (input, "drop"))
522 a->action_type = SSE2_QOS_ACTION_DROP;
523 else if (unformat (input, "transmit"))
524 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
525 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
526 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
533 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
535 u32 *r = va_arg (*va, u32 *);
538 if (unformat (input, "ip4"))
539 tid = POLICER_CLASSIFY_TABLE_IP4;
540 else if (unformat (input, "ip6"))
541 tid = POLICER_CLASSIFY_TABLE_IP6;
542 else if (unformat (input, "l2"))
543 tid = POLICER_CLASSIFY_TABLE_L2;
552 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
554 u32 *r = va_arg (*va, u32 *);
557 if (unformat (input, "ip4"))
558 tid = FLOW_CLASSIFY_TABLE_IP4;
559 else if (unformat (input, "ip6"))
560 tid = FLOW_CLASSIFY_TABLE_IP6;
568 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
569 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
570 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
571 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
573 #if (VPP_API_TEST_BUILTIN==0)
575 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
577 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
578 mfib_itf_attribute_t attr;
581 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
583 if (unformat (input, mfib_itf_flag_long_names[attr]))
584 *iflags |= (1 << attr);
586 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
588 if (unformat (input, mfib_itf_flag_names[attr]))
589 *iflags |= (1 << attr);
592 return (old == *iflags ? 0 : 1);
596 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
598 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
599 mfib_entry_attribute_t attr;
602 FOR_EACH_MFIB_ATTRIBUTE (attr)
604 if (unformat (input, mfib_flag_long_names[attr]))
605 *eflags |= (1 << attr);
607 FOR_EACH_MFIB_ATTRIBUTE (attr)
609 if (unformat (input, mfib_flag_names[attr]))
610 *eflags |= (1 << attr);
613 return (old == *eflags ? 0 : 1);
617 format_ip4_address (u8 * s, va_list * args)
619 u8 *a = va_arg (*args, u8 *);
620 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
624 format_ip6_address (u8 * s, va_list * args)
626 ip6_address_t *a = va_arg (*args, ip6_address_t *);
627 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
629 i_max_n_zero = ARRAY_LEN (a->as_u16);
631 i_first_zero = i_max_n_zero;
633 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
635 u32 is_zero = a->as_u16[i] == 0;
636 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
642 if ((!is_zero && n_zeros > max_n_zeros)
643 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
645 i_max_n_zero = i_first_zero;
646 max_n_zeros = n_zeros;
647 i_first_zero = ARRAY_LEN (a->as_u16);
652 last_double_colon = 0;
653 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
655 if (i == i_max_n_zero && max_n_zeros > 1)
657 s = format (s, "::");
658 i += max_n_zeros - 1;
659 last_double_colon = 1;
663 s = format (s, "%s%x",
664 (last_double_colon || i == 0) ? "" : ":",
665 clib_net_to_host_u16 (a->as_u16[i]));
666 last_double_colon = 0;
673 /* Format an IP46 address. */
675 format_ip46_address (u8 * s, va_list * args)
677 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
678 ip46_type_t type = va_arg (*args, ip46_type_t);
684 is_ip4 = ip46_address_is_ip4 (ip46);
695 format (s, "%U", format_ip4_address, &ip46->ip4) :
696 format (s, "%U", format_ip6_address, &ip46->ip6);
700 format_ethernet_address (u8 * s, va_list * args)
702 u8 *a = va_arg (*args, u8 *);
704 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
705 a[0], a[1], a[2], a[3], a[4], a[5]);
710 increment_v4_address (ip4_address_t * a)
714 v = ntohl (a->as_u32) + 1;
715 a->as_u32 = ntohl (v);
719 increment_v6_address (ip6_address_t * a)
723 v0 = clib_net_to_host_u64 (a->as_u64[0]);
724 v1 = clib_net_to_host_u64 (a->as_u64[1]);
729 a->as_u64[0] = clib_net_to_host_u64 (v0);
730 a->as_u64[1] = clib_net_to_host_u64 (v1);
734 increment_mac_address (u8 * mac)
736 u64 tmp = *((u64 *) mac);
737 tmp = clib_net_to_host_u64 (tmp);
738 tmp += 1 << 16; /* skip unused (least significant) octets */
739 tmp = clib_host_to_net_u64 (tmp);
741 clib_memcpy (mac, &tmp, 6);
744 static void vl_api_create_loopback_reply_t_handler
745 (vl_api_create_loopback_reply_t * mp)
747 vat_main_t *vam = &vat_main;
748 i32 retval = ntohl (mp->retval);
750 vam->retval = retval;
751 vam->regenerate_interface_table = 1;
752 vam->sw_if_index = ntohl (mp->sw_if_index);
753 vam->result_ready = 1;
756 static void vl_api_create_loopback_reply_t_handler_json
757 (vl_api_create_loopback_reply_t * mp)
759 vat_main_t *vam = &vat_main;
760 vat_json_node_t node;
762 vat_json_init_object (&node);
763 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
764 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
766 vat_json_print (vam->ofp, &node);
767 vat_json_free (&node);
768 vam->retval = ntohl (mp->retval);
769 vam->result_ready = 1;
772 static void vl_api_create_loopback_instance_reply_t_handler
773 (vl_api_create_loopback_instance_reply_t * mp)
775 vat_main_t *vam = &vat_main;
776 i32 retval = ntohl (mp->retval);
778 vam->retval = retval;
779 vam->regenerate_interface_table = 1;
780 vam->sw_if_index = ntohl (mp->sw_if_index);
781 vam->result_ready = 1;
784 static void vl_api_create_loopback_instance_reply_t_handler_json
785 (vl_api_create_loopback_instance_reply_t * mp)
787 vat_main_t *vam = &vat_main;
788 vat_json_node_t node;
790 vat_json_init_object (&node);
791 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
792 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
794 vat_json_print (vam->ofp, &node);
795 vat_json_free (&node);
796 vam->retval = ntohl (mp->retval);
797 vam->result_ready = 1;
800 static void vl_api_af_packet_create_reply_t_handler
801 (vl_api_af_packet_create_reply_t * mp)
803 vat_main_t *vam = &vat_main;
804 i32 retval = ntohl (mp->retval);
806 vam->retval = retval;
807 vam->regenerate_interface_table = 1;
808 vam->sw_if_index = ntohl (mp->sw_if_index);
809 vam->result_ready = 1;
812 static void vl_api_af_packet_create_reply_t_handler_json
813 (vl_api_af_packet_create_reply_t * mp)
815 vat_main_t *vam = &vat_main;
816 vat_json_node_t node;
818 vat_json_init_object (&node);
819 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
820 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
822 vat_json_print (vam->ofp, &node);
823 vat_json_free (&node);
825 vam->retval = ntohl (mp->retval);
826 vam->result_ready = 1;
829 static void vl_api_create_vlan_subif_reply_t_handler
830 (vl_api_create_vlan_subif_reply_t * mp)
832 vat_main_t *vam = &vat_main;
833 i32 retval = ntohl (mp->retval);
835 vam->retval = retval;
836 vam->regenerate_interface_table = 1;
837 vam->sw_if_index = ntohl (mp->sw_if_index);
838 vam->result_ready = 1;
841 static void vl_api_create_vlan_subif_reply_t_handler_json
842 (vl_api_create_vlan_subif_reply_t * mp)
844 vat_main_t *vam = &vat_main;
845 vat_json_node_t node;
847 vat_json_init_object (&node);
848 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
849 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
851 vat_json_print (vam->ofp, &node);
852 vat_json_free (&node);
854 vam->retval = ntohl (mp->retval);
855 vam->result_ready = 1;
858 static void vl_api_create_subif_reply_t_handler
859 (vl_api_create_subif_reply_t * mp)
861 vat_main_t *vam = &vat_main;
862 i32 retval = ntohl (mp->retval);
864 vam->retval = retval;
865 vam->regenerate_interface_table = 1;
866 vam->sw_if_index = ntohl (mp->sw_if_index);
867 vam->result_ready = 1;
870 static void vl_api_create_subif_reply_t_handler_json
871 (vl_api_create_subif_reply_t * mp)
873 vat_main_t *vam = &vat_main;
874 vat_json_node_t node;
876 vat_json_init_object (&node);
877 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
878 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
880 vat_json_print (vam->ofp, &node);
881 vat_json_free (&node);
883 vam->retval = ntohl (mp->retval);
884 vam->result_ready = 1;
887 static void vl_api_interface_name_renumber_reply_t_handler
888 (vl_api_interface_name_renumber_reply_t * mp)
890 vat_main_t *vam = &vat_main;
891 i32 retval = ntohl (mp->retval);
893 vam->retval = retval;
894 vam->regenerate_interface_table = 1;
895 vam->result_ready = 1;
898 static void vl_api_interface_name_renumber_reply_t_handler_json
899 (vl_api_interface_name_renumber_reply_t * mp)
901 vat_main_t *vam = &vat_main;
902 vat_json_node_t node;
904 vat_json_init_object (&node);
905 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
907 vat_json_print (vam->ofp, &node);
908 vat_json_free (&node);
910 vam->retval = ntohl (mp->retval);
911 vam->result_ready = 1;
915 * Special-case: build the interface table, maintain
916 * the next loopback sw_if_index vbl.
918 static void vl_api_sw_interface_details_t_handler
919 (vl_api_sw_interface_details_t * mp)
921 vat_main_t *vam = &vat_main;
922 u8 *s = format (0, "%s%c", mp->interface_name, 0);
924 hash_set_mem (vam->sw_if_index_by_interface_name, s,
925 ntohl (mp->sw_if_index));
927 /* In sub interface case, fill the sub interface table entry */
928 if (mp->sw_if_index != mp->sup_sw_if_index)
930 sw_interface_subif_t *sub = NULL;
932 vec_add2 (vam->sw_if_subif_table, sub, 1);
934 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
935 strncpy ((char *) sub->interface_name, (char *) s,
936 vec_len (sub->interface_name));
937 sub->sw_if_index = ntohl (mp->sw_if_index);
938 sub->sub_id = ntohl (mp->sub_id);
940 sub->sub_dot1ad = mp->sub_dot1ad;
941 sub->sub_number_of_tags = mp->sub_number_of_tags;
942 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
943 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
944 sub->sub_exact_match = mp->sub_exact_match;
945 sub->sub_default = mp->sub_default;
946 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
947 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
949 /* vlan tag rewrite */
950 sub->vtr_op = ntohl (mp->vtr_op);
951 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
952 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
953 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
957 static void vl_api_sw_interface_details_t_handler_json
958 (vl_api_sw_interface_details_t * mp)
960 vat_main_t *vam = &vat_main;
961 vat_json_node_t *node = NULL;
963 if (VAT_JSON_ARRAY != vam->json_tree.type)
965 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
966 vat_json_init_array (&vam->json_tree);
968 node = vat_json_array_add (&vam->json_tree);
970 vat_json_init_object (node);
971 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
972 vat_json_object_add_uint (node, "sup_sw_if_index",
973 ntohl (mp->sup_sw_if_index));
974 vat_json_object_add_uint (node, "l2_address_length",
975 ntohl (mp->l2_address_length));
976 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
977 sizeof (mp->l2_address));
978 vat_json_object_add_string_copy (node, "interface_name",
980 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
981 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
982 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
983 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
984 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
985 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
986 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
987 vat_json_object_add_uint (node, "sub_number_of_tags",
988 mp->sub_number_of_tags);
989 vat_json_object_add_uint (node, "sub_outer_vlan_id",
990 ntohs (mp->sub_outer_vlan_id));
991 vat_json_object_add_uint (node, "sub_inner_vlan_id",
992 ntohs (mp->sub_inner_vlan_id));
993 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
994 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
995 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
996 mp->sub_outer_vlan_id_any);
997 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
998 mp->sub_inner_vlan_id_any);
999 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
1000 vat_json_object_add_uint (node, "vtr_push_dot1q",
1001 ntohl (mp->vtr_push_dot1q));
1002 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
1003 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
1006 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
1008 format_ethernet_address,
1010 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
1012 format_ethernet_address,
1014 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
1015 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
1019 #if VPP_API_TEST_BUILTIN == 0
1020 static void vl_api_sw_interface_event_t_handler
1021 (vl_api_sw_interface_event_t * mp)
1023 vat_main_t *vam = &vat_main;
1024 if (vam->interface_event_display)
1025 errmsg ("interface flags: sw_if_index %d %s %s",
1026 ntohl (mp->sw_if_index),
1027 mp->admin_up_down ? "admin-up" : "admin-down",
1028 mp->link_up_down ? "link-up" : "link-down");
1032 static void vl_api_sw_interface_event_t_handler_json
1033 (vl_api_sw_interface_event_t * mp)
1035 /* JSON output not supported */
1039 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
1041 vat_main_t *vam = &vat_main;
1042 i32 retval = ntohl (mp->retval);
1044 vam->retval = retval;
1045 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1046 vam->result_ready = 1;
1050 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1052 vat_main_t *vam = &vat_main;
1053 vat_json_node_t node;
1054 api_main_t *am = &api_main;
1058 vat_json_init_object (&node);
1059 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1060 vat_json_object_add_uint (&node, "reply_in_shmem",
1061 ntohl (mp->reply_in_shmem));
1062 /* Toss the shared-memory original... */
1063 pthread_mutex_lock (&am->vlib_rp->mutex);
1064 oldheap = svm_push_data_heap (am->vlib_rp);
1066 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1069 svm_pop_heap (oldheap);
1070 pthread_mutex_unlock (&am->vlib_rp->mutex);
1072 vat_json_print (vam->ofp, &node);
1073 vat_json_free (&node);
1075 vam->retval = ntohl (mp->retval);
1076 vam->result_ready = 1;
1080 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1082 vat_main_t *vam = &vat_main;
1083 i32 retval = ntohl (mp->retval);
1084 u32 length = ntohl (mp->length);
1086 vec_reset_length (vam->cmd_reply);
1088 vam->retval = retval;
1091 vec_validate (vam->cmd_reply, length);
1092 clib_memcpy ((char *) (vam->cmd_reply), mp->reply, length);
1093 vam->cmd_reply[length] = 0;
1095 vam->result_ready = 1;
1099 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1101 vat_main_t *vam = &vat_main;
1102 vat_json_node_t node;
1104 vec_reset_length (vam->cmd_reply);
1106 vat_json_init_object (&node);
1107 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1108 vat_json_object_add_string_copy (&node, "reply", mp->reply);
1110 vat_json_print (vam->ofp, &node);
1111 vat_json_free (&node);
1113 vam->retval = ntohl (mp->retval);
1114 vam->result_ready = 1;
1117 static void vl_api_classify_add_del_table_reply_t_handler
1118 (vl_api_classify_add_del_table_reply_t * mp)
1120 vat_main_t *vam = &vat_main;
1121 i32 retval = ntohl (mp->retval);
1122 if (vam->async_mode)
1124 vam->async_errors += (retval < 0);
1128 vam->retval = retval;
1130 ((mp->new_table_index != 0xFFFFFFFF) ||
1131 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1132 (mp->match_n_vectors != 0xFFFFFFFF)))
1134 * Note: this is just barely thread-safe, depends on
1135 * the main thread spinning waiting for an answer...
1137 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1138 ntohl (mp->new_table_index),
1139 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1140 vam->result_ready = 1;
1144 static void vl_api_classify_add_del_table_reply_t_handler_json
1145 (vl_api_classify_add_del_table_reply_t * mp)
1147 vat_main_t *vam = &vat_main;
1148 vat_json_node_t node;
1150 vat_json_init_object (&node);
1151 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1152 vat_json_object_add_uint (&node, "new_table_index",
1153 ntohl (mp->new_table_index));
1154 vat_json_object_add_uint (&node, "skip_n_vectors",
1155 ntohl (mp->skip_n_vectors));
1156 vat_json_object_add_uint (&node, "match_n_vectors",
1157 ntohl (mp->match_n_vectors));
1159 vat_json_print (vam->ofp, &node);
1160 vat_json_free (&node);
1162 vam->retval = ntohl (mp->retval);
1163 vam->result_ready = 1;
1166 static void vl_api_get_node_index_reply_t_handler
1167 (vl_api_get_node_index_reply_t * mp)
1169 vat_main_t *vam = &vat_main;
1170 i32 retval = ntohl (mp->retval);
1171 if (vam->async_mode)
1173 vam->async_errors += (retval < 0);
1177 vam->retval = retval;
1179 errmsg ("node index %d", ntohl (mp->node_index));
1180 vam->result_ready = 1;
1184 static void vl_api_get_node_index_reply_t_handler_json
1185 (vl_api_get_node_index_reply_t * mp)
1187 vat_main_t *vam = &vat_main;
1188 vat_json_node_t node;
1190 vat_json_init_object (&node);
1191 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1192 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1194 vat_json_print (vam->ofp, &node);
1195 vat_json_free (&node);
1197 vam->retval = ntohl (mp->retval);
1198 vam->result_ready = 1;
1201 static void vl_api_get_next_index_reply_t_handler
1202 (vl_api_get_next_index_reply_t * mp)
1204 vat_main_t *vam = &vat_main;
1205 i32 retval = ntohl (mp->retval);
1206 if (vam->async_mode)
1208 vam->async_errors += (retval < 0);
1212 vam->retval = retval;
1214 errmsg ("next node index %d", ntohl (mp->next_index));
1215 vam->result_ready = 1;
1219 static void vl_api_get_next_index_reply_t_handler_json
1220 (vl_api_get_next_index_reply_t * mp)
1222 vat_main_t *vam = &vat_main;
1223 vat_json_node_t node;
1225 vat_json_init_object (&node);
1226 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1227 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1229 vat_json_print (vam->ofp, &node);
1230 vat_json_free (&node);
1232 vam->retval = ntohl (mp->retval);
1233 vam->result_ready = 1;
1236 static void vl_api_add_node_next_reply_t_handler
1237 (vl_api_add_node_next_reply_t * mp)
1239 vat_main_t *vam = &vat_main;
1240 i32 retval = ntohl (mp->retval);
1241 if (vam->async_mode)
1243 vam->async_errors += (retval < 0);
1247 vam->retval = retval;
1249 errmsg ("next index %d", ntohl (mp->next_index));
1250 vam->result_ready = 1;
1254 static void vl_api_add_node_next_reply_t_handler_json
1255 (vl_api_add_node_next_reply_t * mp)
1257 vat_main_t *vam = &vat_main;
1258 vat_json_node_t node;
1260 vat_json_init_object (&node);
1261 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1262 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1264 vat_json_print (vam->ofp, &node);
1265 vat_json_free (&node);
1267 vam->retval = ntohl (mp->retval);
1268 vam->result_ready = 1;
1271 static void vl_api_show_version_reply_t_handler
1272 (vl_api_show_version_reply_t * mp)
1274 vat_main_t *vam = &vat_main;
1275 i32 retval = ntohl (mp->retval);
1279 errmsg (" program: %s", mp->program);
1280 errmsg (" version: %s", mp->version);
1281 errmsg (" build date: %s", mp->build_date);
1282 errmsg ("build directory: %s", mp->build_directory);
1284 vam->retval = retval;
1285 vam->result_ready = 1;
1288 static void vl_api_show_version_reply_t_handler_json
1289 (vl_api_show_version_reply_t * mp)
1291 vat_main_t *vam = &vat_main;
1292 vat_json_node_t node;
1294 vat_json_init_object (&node);
1295 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1296 vat_json_object_add_string_copy (&node, "program", mp->program);
1297 vat_json_object_add_string_copy (&node, "version", mp->version);
1298 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1299 vat_json_object_add_string_copy (&node, "build_directory",
1300 mp->build_directory);
1302 vat_json_print (vam->ofp, &node);
1303 vat_json_free (&node);
1305 vam->retval = ntohl (mp->retval);
1306 vam->result_ready = 1;
1310 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1312 u32 sw_if_index = ntohl (mp->sw_if_index);
1313 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1314 mp->mac_ip ? "mac/ip binding" : "address resolution",
1315 ntohl (mp->pid), format_ip4_address, &mp->address,
1316 format_ethernet_address, mp->new_mac, sw_if_index);
1320 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1322 /* JSON output not supported */
1326 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1328 u32 sw_if_index = ntohl (mp->sw_if_index);
1329 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1330 mp->mac_ip ? "mac/ip binding" : "address resolution",
1331 ntohl (mp->pid), format_ip6_address, mp->address,
1332 format_ethernet_address, mp->new_mac, sw_if_index);
1336 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1338 /* JSON output not supported */
1342 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1344 u32 n_macs = ntohl (mp->n_macs);
1345 errmsg ("L2MAC event recived with pid %d cl-idx %d for %d macs: \n",
1346 ntohl (mp->pid), mp->client_index, n_macs);
1348 for (i = 0; i < n_macs; i++)
1350 vl_api_mac_entry_t *mac = &mp->mac[i];
1351 errmsg (" [%d] sw_if_index %d mac_addr %U is_del %d \n",
1352 i + 1, ntohl (mac->sw_if_index),
1353 format_ethernet_address, mac->mac_addr, mac->is_del);
1360 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1362 /* JSON output not supported */
1365 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1366 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1369 * Special-case: build the bridge domain table, maintain
1370 * the next bd id vbl.
1372 static void vl_api_bridge_domain_details_t_handler
1373 (vl_api_bridge_domain_details_t * mp)
1375 vat_main_t *vam = &vat_main;
1376 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1379 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1380 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1382 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1383 ntohl (mp->bd_id), mp->learn, mp->forward,
1384 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1388 vl_api_bridge_domain_sw_if_t *sw_ifs;
1389 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1392 sw_ifs = mp->sw_if_details;
1393 for (i = 0; i < n_sw_ifs; i++)
1399 sw_if_index = ntohl (sw_ifs->sw_if_index);
1402 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1404 if ((u32) p->value[0] == sw_if_index)
1406 sw_if_name = (u8 *)(p->key);
1411 print (vam->ofp, "%7d %3d %s", sw_if_index,
1412 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1413 "sw_if_index not found!");
1420 static void vl_api_bridge_domain_details_t_handler_json
1421 (vl_api_bridge_domain_details_t * mp)
1423 vat_main_t *vam = &vat_main;
1424 vat_json_node_t *node, *array = NULL;
1425 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1427 if (VAT_JSON_ARRAY != vam->json_tree.type)
1429 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1430 vat_json_init_array (&vam->json_tree);
1432 node = vat_json_array_add (&vam->json_tree);
1434 vat_json_init_object (node);
1435 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1436 vat_json_object_add_uint (node, "flood", mp->flood);
1437 vat_json_object_add_uint (node, "forward", mp->forward);
1438 vat_json_object_add_uint (node, "learn", mp->learn);
1439 vat_json_object_add_uint (node, "bvi_sw_if_index",
1440 ntohl (mp->bvi_sw_if_index));
1441 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1442 array = vat_json_object_add (node, "sw_if");
1443 vat_json_init_array (array);
1449 vl_api_bridge_domain_sw_if_t *sw_ifs;
1452 sw_ifs = mp->sw_if_details;
1453 for (i = 0; i < n_sw_ifs; i++)
1455 node = vat_json_array_add (array);
1456 vat_json_init_object (node);
1457 vat_json_object_add_uint (node, "sw_if_index",
1458 ntohl (sw_ifs->sw_if_index));
1459 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1465 static void vl_api_control_ping_reply_t_handler
1466 (vl_api_control_ping_reply_t * mp)
1468 vat_main_t *vam = &vat_main;
1469 i32 retval = ntohl (mp->retval);
1470 if (vam->async_mode)
1472 vam->async_errors += (retval < 0);
1476 vam->retval = retval;
1477 vam->result_ready = 1;
1479 if (vam->socket_client_main)
1480 vam->socket_client_main->control_pings_outstanding--;
1483 static void vl_api_control_ping_reply_t_handler_json
1484 (vl_api_control_ping_reply_t * mp)
1486 vat_main_t *vam = &vat_main;
1487 i32 retval = ntohl (mp->retval);
1489 if (VAT_JSON_NONE != vam->json_tree.type)
1491 vat_json_print (vam->ofp, &vam->json_tree);
1492 vat_json_free (&vam->json_tree);
1493 vam->json_tree.type = VAT_JSON_NONE;
1498 vat_json_init_array (&vam->json_tree);
1499 vat_json_print (vam->ofp, &vam->json_tree);
1500 vam->json_tree.type = VAT_JSON_NONE;
1503 vam->retval = retval;
1504 vam->result_ready = 1;
1508 vl_api_bridge_domain_set_mac_age_reply_t_handler
1509 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1511 vat_main_t *vam = &vat_main;
1512 i32 retval = ntohl (mp->retval);
1513 if (vam->async_mode)
1515 vam->async_errors += (retval < 0);
1519 vam->retval = retval;
1520 vam->result_ready = 1;
1524 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1525 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1527 vat_main_t *vam = &vat_main;
1528 vat_json_node_t node;
1530 vat_json_init_object (&node);
1531 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1533 vat_json_print (vam->ofp, &node);
1534 vat_json_free (&node);
1536 vam->retval = ntohl (mp->retval);
1537 vam->result_ready = 1;
1541 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1543 vat_main_t *vam = &vat_main;
1544 i32 retval = ntohl (mp->retval);
1545 if (vam->async_mode)
1547 vam->async_errors += (retval < 0);
1551 vam->retval = retval;
1552 vam->result_ready = 1;
1556 static void vl_api_l2_flags_reply_t_handler_json
1557 (vl_api_l2_flags_reply_t * mp)
1559 vat_main_t *vam = &vat_main;
1560 vat_json_node_t node;
1562 vat_json_init_object (&node);
1563 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1564 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1565 ntohl (mp->resulting_feature_bitmap));
1567 vat_json_print (vam->ofp, &node);
1568 vat_json_free (&node);
1570 vam->retval = ntohl (mp->retval);
1571 vam->result_ready = 1;
1574 static void vl_api_bridge_flags_reply_t_handler
1575 (vl_api_bridge_flags_reply_t * mp)
1577 vat_main_t *vam = &vat_main;
1578 i32 retval = ntohl (mp->retval);
1579 if (vam->async_mode)
1581 vam->async_errors += (retval < 0);
1585 vam->retval = retval;
1586 vam->result_ready = 1;
1590 static void vl_api_bridge_flags_reply_t_handler_json
1591 (vl_api_bridge_flags_reply_t * mp)
1593 vat_main_t *vam = &vat_main;
1594 vat_json_node_t node;
1596 vat_json_init_object (&node);
1597 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1598 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1599 ntohl (mp->resulting_feature_bitmap));
1601 vat_json_print (vam->ofp, &node);
1602 vat_json_free (&node);
1604 vam->retval = ntohl (mp->retval);
1605 vam->result_ready = 1;
1608 static void vl_api_tap_connect_reply_t_handler
1609 (vl_api_tap_connect_reply_t * mp)
1611 vat_main_t *vam = &vat_main;
1612 i32 retval = ntohl (mp->retval);
1613 if (vam->async_mode)
1615 vam->async_errors += (retval < 0);
1619 vam->retval = retval;
1620 vam->sw_if_index = ntohl (mp->sw_if_index);
1621 vam->result_ready = 1;
1626 static void vl_api_tap_connect_reply_t_handler_json
1627 (vl_api_tap_connect_reply_t * mp)
1629 vat_main_t *vam = &vat_main;
1630 vat_json_node_t node;
1632 vat_json_init_object (&node);
1633 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1634 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1636 vat_json_print (vam->ofp, &node);
1637 vat_json_free (&node);
1639 vam->retval = ntohl (mp->retval);
1640 vam->result_ready = 1;
1645 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1647 vat_main_t *vam = &vat_main;
1648 i32 retval = ntohl (mp->retval);
1649 if (vam->async_mode)
1651 vam->async_errors += (retval < 0);
1655 vam->retval = retval;
1656 vam->sw_if_index = ntohl (mp->sw_if_index);
1657 vam->result_ready = 1;
1661 static void vl_api_tap_modify_reply_t_handler_json
1662 (vl_api_tap_modify_reply_t * mp)
1664 vat_main_t *vam = &vat_main;
1665 vat_json_node_t node;
1667 vat_json_init_object (&node);
1668 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1669 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1671 vat_json_print (vam->ofp, &node);
1672 vat_json_free (&node);
1674 vam->retval = ntohl (mp->retval);
1675 vam->result_ready = 1;
1679 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1681 vat_main_t *vam = &vat_main;
1682 i32 retval = ntohl (mp->retval);
1683 if (vam->async_mode)
1685 vam->async_errors += (retval < 0);
1689 vam->retval = retval;
1690 vam->result_ready = 1;
1694 static void vl_api_tap_delete_reply_t_handler_json
1695 (vl_api_tap_delete_reply_t * mp)
1697 vat_main_t *vam = &vat_main;
1698 vat_json_node_t node;
1700 vat_json_init_object (&node);
1701 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1703 vat_json_print (vam->ofp, &node);
1704 vat_json_free (&node);
1706 vam->retval = ntohl (mp->retval);
1707 vam->result_ready = 1;
1711 vl_api_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_reply_t * mp)
1713 vat_main_t *vam = &vat_main;
1714 i32 retval = ntohl (mp->retval);
1715 if (vam->async_mode)
1717 vam->async_errors += (retval < 0);
1721 vam->retval = retval;
1722 vam->sw_if_index = ntohl (mp->sw_if_index);
1723 vam->result_ready = 1;
1728 static void vl_api_tap_create_v2_reply_t_handler_json
1729 (vl_api_tap_create_v2_reply_t * mp)
1731 vat_main_t *vam = &vat_main;
1732 vat_json_node_t node;
1734 vat_json_init_object (&node);
1735 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1736 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1738 vat_json_print (vam->ofp, &node);
1739 vat_json_free (&node);
1741 vam->retval = ntohl (mp->retval);
1742 vam->result_ready = 1;
1747 vl_api_tap_delete_v2_reply_t_handler (vl_api_tap_delete_v2_reply_t * mp)
1749 vat_main_t *vam = &vat_main;
1750 i32 retval = ntohl (mp->retval);
1751 if (vam->async_mode)
1753 vam->async_errors += (retval < 0);
1757 vam->retval = retval;
1758 vam->result_ready = 1;
1762 static void vl_api_tap_delete_v2_reply_t_handler_json
1763 (vl_api_tap_delete_v2_reply_t * mp)
1765 vat_main_t *vam = &vat_main;
1766 vat_json_node_t node;
1768 vat_json_init_object (&node);
1769 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1771 vat_json_print (vam->ofp, &node);
1772 vat_json_free (&node);
1774 vam->retval = ntohl (mp->retval);
1775 vam->result_ready = 1;
1778 static void vl_api_mpls_tunnel_add_del_reply_t_handler
1779 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1781 vat_main_t *vam = &vat_main;
1782 i32 retval = ntohl (mp->retval);
1783 if (vam->async_mode)
1785 vam->async_errors += (retval < 0);
1789 vam->retval = retval;
1790 vam->result_ready = 1;
1794 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
1795 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1797 vat_main_t *vam = &vat_main;
1798 vat_json_node_t node;
1800 vat_json_init_object (&node);
1801 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1802 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1803 ntohl (mp->sw_if_index));
1805 vat_json_print (vam->ofp, &node);
1806 vat_json_free (&node);
1808 vam->retval = ntohl (mp->retval);
1809 vam->result_ready = 1;
1812 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1813 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1815 vat_main_t *vam = &vat_main;
1816 i32 retval = ntohl (mp->retval);
1817 if (vam->async_mode)
1819 vam->async_errors += (retval < 0);
1823 vam->retval = retval;
1824 vam->sw_if_index = ntohl (mp->sw_if_index);
1825 vam->result_ready = 1;
1829 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1830 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1832 vat_main_t *vam = &vat_main;
1833 vat_json_node_t node;
1835 vat_json_init_object (&node);
1836 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1837 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1839 vat_json_print (vam->ofp, &node);
1840 vat_json_free (&node);
1842 vam->retval = ntohl (mp->retval);
1843 vam->result_ready = 1;
1846 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
1847 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
1849 vat_main_t *vam = &vat_main;
1850 i32 retval = ntohl (mp->retval);
1851 if (vam->async_mode)
1853 vam->async_errors += (retval < 0);
1857 vam->retval = retval;
1858 vam->result_ready = 1;
1862 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
1863 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
1865 vat_main_t *vam = &vat_main;
1866 vat_json_node_t node;
1868 vat_json_init_object (&node);
1869 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1870 vat_json_object_add_uint (&node, "fwd_entry_index",
1871 clib_net_to_host_u32 (mp->fwd_entry_index));
1873 vat_json_print (vam->ofp, &node);
1874 vat_json_free (&node);
1876 vam->retval = ntohl (mp->retval);
1877 vam->result_ready = 1;
1881 format_lisp_transport_protocol (u8 * s, va_list * args)
1883 u32 proto = va_arg (*args, u32);
1888 return format (s, "udp");
1890 return format (s, "api");
1897 static void vl_api_one_get_transport_protocol_reply_t_handler
1898 (vl_api_one_get_transport_protocol_reply_t * mp)
1900 vat_main_t *vam = &vat_main;
1901 i32 retval = ntohl (mp->retval);
1902 if (vam->async_mode)
1904 vam->async_errors += (retval < 0);
1908 u32 proto = mp->protocol;
1909 print (vam->ofp, "Transport protocol: %U",
1910 format_lisp_transport_protocol, proto);
1911 vam->retval = retval;
1912 vam->result_ready = 1;
1916 static void vl_api_one_get_transport_protocol_reply_t_handler_json
1917 (vl_api_one_get_transport_protocol_reply_t * mp)
1919 vat_main_t *vam = &vat_main;
1920 vat_json_node_t node;
1923 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
1926 vat_json_init_object (&node);
1927 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1928 vat_json_object_add_string_copy (&node, "transport-protocol", s);
1931 vat_json_print (vam->ofp, &node);
1932 vat_json_free (&node);
1934 vam->retval = ntohl (mp->retval);
1935 vam->result_ready = 1;
1938 static void vl_api_one_add_del_locator_set_reply_t_handler
1939 (vl_api_one_add_del_locator_set_reply_t * mp)
1941 vat_main_t *vam = &vat_main;
1942 i32 retval = ntohl (mp->retval);
1943 if (vam->async_mode)
1945 vam->async_errors += (retval < 0);
1949 vam->retval = retval;
1950 vam->result_ready = 1;
1954 static void vl_api_one_add_del_locator_set_reply_t_handler_json
1955 (vl_api_one_add_del_locator_set_reply_t * mp)
1957 vat_main_t *vam = &vat_main;
1958 vat_json_node_t node;
1960 vat_json_init_object (&node);
1961 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1962 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1964 vat_json_print (vam->ofp, &node);
1965 vat_json_free (&node);
1967 vam->retval = ntohl (mp->retval);
1968 vam->result_ready = 1;
1971 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1972 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1974 vat_main_t *vam = &vat_main;
1975 i32 retval = ntohl (mp->retval);
1976 if (vam->async_mode)
1978 vam->async_errors += (retval < 0);
1982 vam->retval = retval;
1983 vam->sw_if_index = ntohl (mp->sw_if_index);
1984 vam->result_ready = 1;
1988 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1989 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1991 vat_main_t *vam = &vat_main;
1992 vat_json_node_t node;
1994 vat_json_init_object (&node);
1995 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1996 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1998 vat_json_print (vam->ofp, &node);
1999 vat_json_free (&node);
2001 vam->retval = ntohl (mp->retval);
2002 vam->result_ready = 1;
2005 static void vl_api_geneve_add_del_tunnel_reply_t_handler
2006 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2008 vat_main_t *vam = &vat_main;
2009 i32 retval = ntohl (mp->retval);
2010 if (vam->async_mode)
2012 vam->async_errors += (retval < 0);
2016 vam->retval = retval;
2017 vam->sw_if_index = ntohl (mp->sw_if_index);
2018 vam->result_ready = 1;
2022 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
2023 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2025 vat_main_t *vam = &vat_main;
2026 vat_json_node_t node;
2028 vat_json_init_object (&node);
2029 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2030 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2032 vat_json_print (vam->ofp, &node);
2033 vat_json_free (&node);
2035 vam->retval = ntohl (mp->retval);
2036 vam->result_ready = 1;
2039 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
2040 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2042 vat_main_t *vam = &vat_main;
2043 i32 retval = ntohl (mp->retval);
2044 if (vam->async_mode)
2046 vam->async_errors += (retval < 0);
2050 vam->retval = retval;
2051 vam->sw_if_index = ntohl (mp->sw_if_index);
2052 vam->result_ready = 1;
2056 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
2057 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2059 vat_main_t *vam = &vat_main;
2060 vat_json_node_t node;
2062 vat_json_init_object (&node);
2063 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2064 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2066 vat_json_print (vam->ofp, &node);
2067 vat_json_free (&node);
2069 vam->retval = ntohl (mp->retval);
2070 vam->result_ready = 1;
2073 static void vl_api_gre_add_del_tunnel_reply_t_handler
2074 (vl_api_gre_add_del_tunnel_reply_t * mp)
2076 vat_main_t *vam = &vat_main;
2077 i32 retval = ntohl (mp->retval);
2078 if (vam->async_mode)
2080 vam->async_errors += (retval < 0);
2084 vam->retval = retval;
2085 vam->sw_if_index = ntohl (mp->sw_if_index);
2086 vam->result_ready = 1;
2090 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
2091 (vl_api_gre_add_del_tunnel_reply_t * mp)
2093 vat_main_t *vam = &vat_main;
2094 vat_json_node_t node;
2096 vat_json_init_object (&node);
2097 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2098 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2100 vat_json_print (vam->ofp, &node);
2101 vat_json_free (&node);
2103 vam->retval = ntohl (mp->retval);
2104 vam->result_ready = 1;
2107 static void vl_api_create_vhost_user_if_reply_t_handler
2108 (vl_api_create_vhost_user_if_reply_t * mp)
2110 vat_main_t *vam = &vat_main;
2111 i32 retval = ntohl (mp->retval);
2112 if (vam->async_mode)
2114 vam->async_errors += (retval < 0);
2118 vam->retval = retval;
2119 vam->sw_if_index = ntohl (mp->sw_if_index);
2120 vam->result_ready = 1;
2124 static void vl_api_create_vhost_user_if_reply_t_handler_json
2125 (vl_api_create_vhost_user_if_reply_t * mp)
2127 vat_main_t *vam = &vat_main;
2128 vat_json_node_t node;
2130 vat_json_init_object (&node);
2131 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2132 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2134 vat_json_print (vam->ofp, &node);
2135 vat_json_free (&node);
2137 vam->retval = ntohl (mp->retval);
2138 vam->result_ready = 1;
2141 static clib_error_t *
2142 receive_fd_msg (int socket_fd, int *my_fd)
2145 char ctl[CMSG_SPACE (sizeof (int)) + CMSG_SPACE (sizeof (struct ucred))];
2146 struct msghdr mh = { 0 };
2147 struct iovec iov[1];
2149 struct ucred *cr = 0;
2150 struct cmsghdr *cmsg;
2151 pid_t pid __attribute__ ((unused));
2152 uid_t uid __attribute__ ((unused));
2153 gid_t gid __attribute__ ((unused));
2155 iov[0].iov_base = msgbuf;
2159 mh.msg_control = ctl;
2160 mh.msg_controllen = sizeof (ctl);
2162 memset (ctl, 0, sizeof (ctl));
2164 /* receive the incoming message */
2165 size = recvmsg (socket_fd, &mh, 0);
2168 return (size == 0) ? clib_error_return (0, "disconnected") :
2169 clib_error_return_unix (0, "recvmsg: malformed message (fd %d)",
2173 cmsg = CMSG_FIRSTHDR (&mh);
2176 if (cmsg->cmsg_level == SOL_SOCKET)
2178 if (cmsg->cmsg_type == SCM_CREDENTIALS)
2180 cr = (struct ucred *) CMSG_DATA (cmsg);
2185 else if (cmsg->cmsg_type == SCM_RIGHTS)
2187 clib_memcpy (my_fd, CMSG_DATA (cmsg), sizeof (int));
2190 cmsg = CMSG_NXTHDR (&mh, cmsg);
2195 static void vl_api_memfd_segment_create_reply_t_handler
2196 (vl_api_memfd_segment_create_reply_t * mp)
2198 /* Dont bother in the builtin version */
2199 #if VPP_API_TEST_BUILTIN == 0
2200 vat_main_t *vam = &vat_main;
2201 api_main_t *am = &api_main;
2202 socket_client_main_t *scm = vam->socket_client_main;
2204 clib_error_t *error;
2205 ssvm_private_t memfd;
2206 i32 retval = ntohl (mp->retval);
2210 error = receive_fd_msg (scm->socket_fd, &my_fd);
2217 memset (&memfd, 0, sizeof (memfd));
2220 vam->client_index_invalid = 1;
2222 /* Note: this closes memfd.fd */
2223 retval = ssvm_slave_init_memfd (&memfd);
2225 clib_warning ("WARNING: segment map returned %d", retval);
2227 /* Pivot to the memory client segment that vpp just created */
2229 am->vlib_rp = (void *) (memfd.requested_va + MMAP_PAGESIZE);
2231 am->shmem_hdr = (void *) am->vlib_rp->user_ctx;
2233 vl_client_install_client_message_handlers ();
2235 vl_client_connect_to_vlib_no_map ("pvt",
2237 32 /* input_queue_length */ );
2238 vam->vl_input_queue = am->shmem_hdr->vl_input_queue;
2240 vl_socket_client_enable_disable (0 /* disable socket */ );
2244 if (vam->async_mode)
2246 vam->async_errors += (retval < 0);
2250 vam->retval = retval;
2251 vam->result_ready = 1;
2256 static void vl_api_memfd_segment_create_reply_t_handler_json
2257 (vl_api_memfd_segment_create_reply_t * mp)
2259 clib_warning ("no");
2262 static void vl_api_dns_resolve_name_reply_t_handler
2263 (vl_api_dns_resolve_name_reply_t * mp)
2265 vat_main_t *vam = &vat_main;
2266 i32 retval = ntohl (mp->retval);
2267 if (vam->async_mode)
2269 vam->async_errors += (retval < 0);
2273 vam->retval = retval;
2274 vam->result_ready = 1;
2279 clib_warning ("ip4 address %U", format_ip4_address,
2280 (ip4_address_t *) mp->ip4_address);
2282 clib_warning ("ip6 address %U", format_ip6_address,
2283 (ip6_address_t *) mp->ip6_address);
2286 clib_warning ("retval %d", retval);
2290 static void vl_api_dns_resolve_name_reply_t_handler_json
2291 (vl_api_dns_resolve_name_reply_t * mp)
2293 clib_warning ("not implemented");
2296 static void vl_api_dns_resolve_ip_reply_t_handler
2297 (vl_api_dns_resolve_ip_reply_t * mp)
2299 vat_main_t *vam = &vat_main;
2300 i32 retval = ntohl (mp->retval);
2301 if (vam->async_mode)
2303 vam->async_errors += (retval < 0);
2307 vam->retval = retval;
2308 vam->result_ready = 1;
2312 clib_warning ("canonical name %s", mp->name);
2315 clib_warning ("retval %d", retval);
2319 static void vl_api_dns_resolve_ip_reply_t_handler_json
2320 (vl_api_dns_resolve_ip_reply_t * mp)
2322 clib_warning ("not implemented");
2326 static void vl_api_ip_address_details_t_handler
2327 (vl_api_ip_address_details_t * mp)
2329 vat_main_t *vam = &vat_main;
2330 static ip_address_details_t empty_ip_address_details = { {0} };
2331 ip_address_details_t *address = NULL;
2332 ip_details_t *current_ip_details = NULL;
2333 ip_details_t *details = NULL;
2335 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2337 if (!details || vam->current_sw_if_index >= vec_len (details)
2338 || !details[vam->current_sw_if_index].present)
2340 errmsg ("ip address details arrived but not stored");
2341 errmsg ("ip_dump should be called first");
2345 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2347 #define addresses (current_ip_details->addr)
2349 vec_validate_init_empty (addresses, vec_len (addresses),
2350 empty_ip_address_details);
2352 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2354 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
2355 address->prefix_length = mp->prefix_length;
2359 static void vl_api_ip_address_details_t_handler_json
2360 (vl_api_ip_address_details_t * mp)
2362 vat_main_t *vam = &vat_main;
2363 vat_json_node_t *node = NULL;
2364 struct in6_addr ip6;
2367 if (VAT_JSON_ARRAY != vam->json_tree.type)
2369 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2370 vat_json_init_array (&vam->json_tree);
2372 node = vat_json_array_add (&vam->json_tree);
2374 vat_json_init_object (node);
2377 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
2378 vat_json_object_add_ip6 (node, "ip", ip6);
2382 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
2383 vat_json_object_add_ip4 (node, "ip", ip4);
2385 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
2389 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2391 vat_main_t *vam = &vat_main;
2392 static ip_details_t empty_ip_details = { 0 };
2393 ip_details_t *ip = NULL;
2394 u32 sw_if_index = ~0;
2396 sw_if_index = ntohl (mp->sw_if_index);
2398 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2399 sw_if_index, empty_ip_details);
2401 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2408 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2410 vat_main_t *vam = &vat_main;
2412 if (VAT_JSON_ARRAY != vam->json_tree.type)
2414 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2415 vat_json_init_array (&vam->json_tree);
2417 vat_json_array_add_uint (&vam->json_tree,
2418 clib_net_to_host_u32 (mp->sw_if_index));
2421 static void vl_api_map_domain_details_t_handler_json
2422 (vl_api_map_domain_details_t * mp)
2424 vat_json_node_t *node = NULL;
2425 vat_main_t *vam = &vat_main;
2426 struct in6_addr ip6;
2429 if (VAT_JSON_ARRAY != vam->json_tree.type)
2431 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2432 vat_json_init_array (&vam->json_tree);
2435 node = vat_json_array_add (&vam->json_tree);
2436 vat_json_init_object (node);
2438 vat_json_object_add_uint (node, "domain_index",
2439 clib_net_to_host_u32 (mp->domain_index));
2440 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
2441 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
2442 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
2443 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
2444 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
2445 vat_json_object_add_ip6 (node, "ip6_src", ip6);
2446 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
2447 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
2448 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
2449 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
2450 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
2451 vat_json_object_add_int (node, "psid_length", mp->psid_length);
2452 vat_json_object_add_uint (node, "flags", mp->flags);
2453 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
2454 vat_json_object_add_int (node, "is_translation", mp->is_translation);
2457 static void vl_api_map_domain_details_t_handler
2458 (vl_api_map_domain_details_t * mp)
2460 vat_main_t *vam = &vat_main;
2462 if (mp->is_translation)
2465 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
2466 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2467 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2468 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
2469 clib_net_to_host_u32 (mp->domain_index));
2474 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
2475 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2476 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2477 format_ip6_address, mp->ip6_src,
2478 clib_net_to_host_u32 (mp->domain_index));
2480 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
2481 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
2482 mp->is_translation ? "map-t" : "");
2485 static void vl_api_map_rule_details_t_handler_json
2486 (vl_api_map_rule_details_t * mp)
2488 struct in6_addr ip6;
2489 vat_json_node_t *node = NULL;
2490 vat_main_t *vam = &vat_main;
2492 if (VAT_JSON_ARRAY != vam->json_tree.type)
2494 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2495 vat_json_init_array (&vam->json_tree);
2498 node = vat_json_array_add (&vam->json_tree);
2499 vat_json_init_object (node);
2501 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
2502 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
2503 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
2507 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
2509 vat_main_t *vam = &vat_main;
2510 print (vam->ofp, " %d (psid) %U (ip6-dst)",
2511 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
2515 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2517 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2518 "router_addr %U host_mac %U",
2519 ntohl (mp->pid), mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
2520 format_ip4_address, &mp->host_address,
2521 format_ip4_address, &mp->router_address,
2522 format_ethernet_address, mp->host_mac);
2525 static void vl_api_dhcp_compl_event_t_handler_json
2526 (vl_api_dhcp_compl_event_t * mp)
2528 /* JSON output not supported */
2532 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2535 vat_main_t *vam = &vat_main;
2536 static u64 default_counter = 0;
2538 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2540 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2541 sw_if_index, default_counter);
2542 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2546 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2547 interface_counter_t counter)
2549 vat_main_t *vam = &vat_main;
2550 static interface_counter_t default_counter = { 0, };
2552 vec_validate_init_empty (vam->combined_interface_counters,
2553 vnet_counter_type, NULL);
2554 vec_validate_init_empty (vam->combined_interface_counters
2555 [vnet_counter_type], sw_if_index, default_counter);
2556 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2559 static void vl_api_vnet_interface_simple_counters_t_handler
2560 (vl_api_vnet_interface_simple_counters_t * mp)
2565 static void vl_api_vnet_interface_combined_counters_t_handler
2566 (vl_api_vnet_interface_combined_counters_t * mp)
2571 static void vl_api_vnet_interface_simple_counters_t_handler_json
2572 (vl_api_vnet_interface_simple_counters_t * mp)
2577 u32 first_sw_if_index;
2580 count = ntohl (mp->count);
2581 first_sw_if_index = ntohl (mp->first_sw_if_index);
2583 v_packets = (u64 *) & mp->data;
2584 for (i = 0; i < count; i++)
2586 packets = clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2587 set_simple_interface_counter (mp->vnet_counter_type,
2588 first_sw_if_index + i, packets);
2593 static void vl_api_vnet_interface_combined_counters_t_handler_json
2594 (vl_api_vnet_interface_combined_counters_t * mp)
2596 interface_counter_t counter;
2598 u32 first_sw_if_index;
2602 count = ntohl (mp->count);
2603 first_sw_if_index = ntohl (mp->first_sw_if_index);
2605 v = (vlib_counter_t *) & mp->data;
2606 for (i = 0; i < count; i++)
2609 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2611 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2612 set_combined_interface_counter (mp->vnet_counter_type,
2613 first_sw_if_index + i, counter);
2619 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2621 vat_main_t *vam = &vat_main;
2624 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2626 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2635 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2637 vat_main_t *vam = &vat_main;
2640 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2642 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2650 static void vl_api_vnet_ip4_fib_counters_t_handler
2651 (vl_api_vnet_ip4_fib_counters_t * mp)
2656 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2657 (vl_api_vnet_ip4_fib_counters_t * mp)
2659 vat_main_t *vam = &vat_main;
2660 vl_api_ip4_fib_counter_t *v;
2661 ip4_fib_counter_t *counter;
2668 vrf_id = ntohl (mp->vrf_id);
2669 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2670 if (~0 == vrf_index)
2672 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2673 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2674 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2675 vec_validate (vam->ip4_fib_counters, vrf_index);
2676 vam->ip4_fib_counters[vrf_index] = NULL;
2679 vec_free (vam->ip4_fib_counters[vrf_index]);
2680 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2681 count = ntohl (mp->count);
2682 for (i = 0; i < count; i++)
2684 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2685 counter = &vam->ip4_fib_counters[vrf_index][i];
2686 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2687 counter->address = ip4;
2688 counter->address_length = v->address_length;
2689 counter->packets = clib_net_to_host_u64 (v->packets);
2690 counter->bytes = clib_net_to_host_u64 (v->bytes);
2695 static void vl_api_vnet_ip4_nbr_counters_t_handler
2696 (vl_api_vnet_ip4_nbr_counters_t * mp)
2701 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2702 (vl_api_vnet_ip4_nbr_counters_t * mp)
2704 vat_main_t *vam = &vat_main;
2705 vl_api_ip4_nbr_counter_t *v;
2706 ip4_nbr_counter_t *counter;
2711 sw_if_index = ntohl (mp->sw_if_index);
2712 count = ntohl (mp->count);
2713 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2716 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2718 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2719 for (i = 0; i < count; i++)
2721 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2722 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2723 counter->address.s_addr = v->address;
2724 counter->packets = clib_net_to_host_u64 (v->packets);
2725 counter->bytes = clib_net_to_host_u64 (v->bytes);
2726 counter->linkt = v->link_type;
2731 static void vl_api_vnet_ip6_fib_counters_t_handler
2732 (vl_api_vnet_ip6_fib_counters_t * mp)
2737 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2738 (vl_api_vnet_ip6_fib_counters_t * mp)
2740 vat_main_t *vam = &vat_main;
2741 vl_api_ip6_fib_counter_t *v;
2742 ip6_fib_counter_t *counter;
2743 struct in6_addr ip6;
2749 vrf_id = ntohl (mp->vrf_id);
2750 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2751 if (~0 == vrf_index)
2753 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2754 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2755 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2756 vec_validate (vam->ip6_fib_counters, vrf_index);
2757 vam->ip6_fib_counters[vrf_index] = NULL;
2760 vec_free (vam->ip6_fib_counters[vrf_index]);
2761 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2762 count = ntohl (mp->count);
2763 for (i = 0; i < count; i++)
2765 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2766 counter = &vam->ip6_fib_counters[vrf_index][i];
2767 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2768 counter->address = ip6;
2769 counter->address_length = v->address_length;
2770 counter->packets = clib_net_to_host_u64 (v->packets);
2771 counter->bytes = clib_net_to_host_u64 (v->bytes);
2776 static void vl_api_vnet_ip6_nbr_counters_t_handler
2777 (vl_api_vnet_ip6_nbr_counters_t * mp)
2782 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2783 (vl_api_vnet_ip6_nbr_counters_t * mp)
2785 vat_main_t *vam = &vat_main;
2786 vl_api_ip6_nbr_counter_t *v;
2787 ip6_nbr_counter_t *counter;
2788 struct in6_addr ip6;
2793 sw_if_index = ntohl (mp->sw_if_index);
2794 count = ntohl (mp->count);
2795 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2798 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2800 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2801 for (i = 0; i < count; i++)
2803 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2804 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2805 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2806 counter->address = ip6;
2807 counter->packets = clib_net_to_host_u64 (v->packets);
2808 counter->bytes = clib_net_to_host_u64 (v->bytes);
2813 static void vl_api_get_first_msg_id_reply_t_handler
2814 (vl_api_get_first_msg_id_reply_t * mp)
2816 vat_main_t *vam = &vat_main;
2817 i32 retval = ntohl (mp->retval);
2819 if (vam->async_mode)
2821 vam->async_errors += (retval < 0);
2825 vam->retval = retval;
2826 vam->result_ready = 1;
2830 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2834 static void vl_api_get_first_msg_id_reply_t_handler_json
2835 (vl_api_get_first_msg_id_reply_t * mp)
2837 vat_main_t *vam = &vat_main;
2838 vat_json_node_t node;
2840 vat_json_init_object (&node);
2841 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2842 vat_json_object_add_uint (&node, "first_msg_id",
2843 (uint) ntohs (mp->first_msg_id));
2845 vat_json_print (vam->ofp, &node);
2846 vat_json_free (&node);
2848 vam->retval = ntohl (mp->retval);
2849 vam->result_ready = 1;
2852 static void vl_api_get_node_graph_reply_t_handler
2853 (vl_api_get_node_graph_reply_t * mp)
2855 vat_main_t *vam = &vat_main;
2856 api_main_t *am = &api_main;
2857 i32 retval = ntohl (mp->retval);
2858 u8 *pvt_copy, *reply;
2863 if (vam->async_mode)
2865 vam->async_errors += (retval < 0);
2869 vam->retval = retval;
2870 vam->result_ready = 1;
2873 /* "Should never happen..." */
2877 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2878 pvt_copy = vec_dup (reply);
2880 /* Toss the shared-memory original... */
2881 pthread_mutex_lock (&am->vlib_rp->mutex);
2882 oldheap = svm_push_data_heap (am->vlib_rp);
2886 svm_pop_heap (oldheap);
2887 pthread_mutex_unlock (&am->vlib_rp->mutex);
2889 if (vam->graph_nodes)
2891 hash_free (vam->graph_node_index_by_name);
2893 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2895 node = vam->graph_nodes[i];
2896 vec_free (node->name);
2897 vec_free (node->next_nodes);
2900 vec_free (vam->graph_nodes);
2903 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2904 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2905 vec_free (pvt_copy);
2907 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2909 node = vam->graph_nodes[i];
2910 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2914 static void vl_api_get_node_graph_reply_t_handler_json
2915 (vl_api_get_node_graph_reply_t * mp)
2917 vat_main_t *vam = &vat_main;
2918 api_main_t *am = &api_main;
2920 vat_json_node_t node;
2923 /* $$$$ make this real? */
2924 vat_json_init_object (&node);
2925 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2926 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2928 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2930 /* Toss the shared-memory original... */
2931 pthread_mutex_lock (&am->vlib_rp->mutex);
2932 oldheap = svm_push_data_heap (am->vlib_rp);
2936 svm_pop_heap (oldheap);
2937 pthread_mutex_unlock (&am->vlib_rp->mutex);
2939 vat_json_print (vam->ofp, &node);
2940 vat_json_free (&node);
2942 vam->retval = ntohl (mp->retval);
2943 vam->result_ready = 1;
2947 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2949 vat_main_t *vam = &vat_main;
2954 s = format (s, "%=16d%=16d%=16d",
2955 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2959 s = format (s, "%=16U%=16d%=16d",
2960 mp->is_ipv6 ? format_ip6_address :
2962 mp->ip_address, mp->priority, mp->weight);
2965 print (vam->ofp, "%v", s);
2970 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2972 vat_main_t *vam = &vat_main;
2973 vat_json_node_t *node = NULL;
2974 struct in6_addr ip6;
2977 if (VAT_JSON_ARRAY != vam->json_tree.type)
2979 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2980 vat_json_init_array (&vam->json_tree);
2982 node = vat_json_array_add (&vam->json_tree);
2983 vat_json_init_object (node);
2985 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2986 vat_json_object_add_uint (node, "priority", mp->priority);
2987 vat_json_object_add_uint (node, "weight", mp->weight);
2990 vat_json_object_add_uint (node, "sw_if_index",
2991 clib_net_to_host_u32 (mp->sw_if_index));
2996 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2997 vat_json_object_add_ip6 (node, "address", ip6);
3001 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3002 vat_json_object_add_ip4 (node, "address", ip4);
3008 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
3011 vat_main_t *vam = &vat_main;
3014 ls_name = format (0, "%s", mp->ls_name);
3016 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
3022 vl_api_one_locator_set_details_t_handler_json
3023 (vl_api_one_locator_set_details_t * mp)
3025 vat_main_t *vam = &vat_main;
3026 vat_json_node_t *node = 0;
3029 ls_name = format (0, "%s", mp->ls_name);
3030 vec_add1 (ls_name, 0);
3032 if (VAT_JSON_ARRAY != vam->json_tree.type)
3034 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3035 vat_json_init_array (&vam->json_tree);
3037 node = vat_json_array_add (&vam->json_tree);
3039 vat_json_init_object (node);
3040 vat_json_object_add_string_copy (node, "ls_name", ls_name);
3041 vat_json_object_add_uint (node, "ls_index",
3042 clib_net_to_host_u32 (mp->ls_index));
3050 } __attribute__ ((__packed__)) lisp_nsh_api_t;
3053 unformat_nsh_address (unformat_input_t * input, va_list * args)
3055 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
3056 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
3060 format_nsh_address_vat (u8 * s, va_list * args)
3062 nsh_t *a = va_arg (*args, nsh_t *);
3063 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
3067 format_lisp_flat_eid (u8 * s, va_list * args)
3069 u32 type = va_arg (*args, u32);
3070 u8 *eid = va_arg (*args, u8 *);
3071 u32 eid_len = va_arg (*args, u32);
3076 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
3078 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
3080 return format (s, "%U", format_ethernet_address, eid);
3082 return format (s, "%U", format_nsh_address_vat, eid);
3088 format_lisp_eid_vat (u8 * s, va_list * args)
3090 u32 type = va_arg (*args, u32);
3091 u8 *eid = va_arg (*args, u8 *);
3092 u32 eid_len = va_arg (*args, u32);
3093 u8 *seid = va_arg (*args, u8 *);
3094 u32 seid_len = va_arg (*args, u32);
3095 u32 is_src_dst = va_arg (*args, u32);
3098 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
3100 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
3106 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
3108 vat_main_t *vam = &vat_main;
3109 u8 *s = 0, *eid = 0;
3111 if (~0 == mp->locator_set_index)
3112 s = format (0, "action: %d", mp->action);
3114 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3116 eid = format (0, "%U", format_lisp_eid_vat,
3120 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3123 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3124 clib_net_to_host_u32 (mp->vni),
3126 mp->is_local ? "local" : "remote",
3127 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3128 clib_net_to_host_u16 (mp->key_id), mp->key);
3135 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3138 vat_main_t *vam = &vat_main;
3139 vat_json_node_t *node = 0;
3142 if (VAT_JSON_ARRAY != vam->json_tree.type)
3144 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3145 vat_json_init_array (&vam->json_tree);
3147 node = vat_json_array_add (&vam->json_tree);
3149 vat_json_init_object (node);
3150 if (~0 == mp->locator_set_index)
3151 vat_json_object_add_uint (node, "action", mp->action);
3153 vat_json_object_add_uint (node, "locator_set_index",
3154 clib_net_to_host_u32 (mp->locator_set_index));
3156 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3157 if (mp->eid_type == 3)
3159 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3160 vat_json_init_object (nsh_json);
3161 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3162 vat_json_object_add_uint (nsh_json, "spi",
3163 clib_net_to_host_u32 (nsh->spi));
3164 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3168 eid = format (0, "%U", format_lisp_eid_vat,
3172 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3174 vat_json_object_add_string_copy (node, "eid", eid);
3177 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3178 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3179 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3183 vat_json_object_add_uint (node, "key_id",
3184 clib_net_to_host_u16 (mp->key_id));
3185 vat_json_object_add_string_copy (node, "key", mp->key);
3190 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3192 vat_main_t *vam = &vat_main;
3193 u8 *seid = 0, *deid = 0;
3194 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3196 deid = format (0, "%U", format_lisp_eid_vat,
3197 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3199 seid = format (0, "%U", format_lisp_eid_vat,
3200 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3206 format_ip_address_fcn = format_ip4_address;
3208 format_ip_address_fcn = format_ip6_address;
3211 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3212 clib_net_to_host_u32 (mp->vni),
3214 format_ip_address_fcn, mp->lloc,
3215 format_ip_address_fcn, mp->rloc,
3216 clib_net_to_host_u32 (mp->pkt_count),
3217 clib_net_to_host_u32 (mp->bytes));
3224 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3226 struct in6_addr ip6;
3228 vat_main_t *vam = &vat_main;
3229 vat_json_node_t *node = 0;
3230 u8 *deid = 0, *seid = 0;
3232 if (VAT_JSON_ARRAY != vam->json_tree.type)
3234 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3235 vat_json_init_array (&vam->json_tree);
3237 node = vat_json_array_add (&vam->json_tree);
3239 vat_json_init_object (node);
3240 deid = format (0, "%U", format_lisp_eid_vat,
3241 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3243 seid = format (0, "%U", format_lisp_eid_vat,
3244 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3249 vat_json_object_add_string_copy (node, "seid", seid);
3250 vat_json_object_add_string_copy (node, "deid", deid);
3251 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3255 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3256 vat_json_object_add_ip4 (node, "lloc", ip4);
3257 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3258 vat_json_object_add_ip4 (node, "rloc", ip4);
3262 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3263 vat_json_object_add_ip6 (node, "lloc", ip6);
3264 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3265 vat_json_object_add_ip6 (node, "rloc", ip6);
3267 vat_json_object_add_uint (node, "pkt_count",
3268 clib_net_to_host_u32 (mp->pkt_count));
3269 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3276 vl_api_one_eid_table_map_details_t_handler
3277 (vl_api_one_eid_table_map_details_t * mp)
3279 vat_main_t *vam = &vat_main;
3281 u8 *line = format (0, "%=10d%=10d",
3282 clib_net_to_host_u32 (mp->vni),
3283 clib_net_to_host_u32 (mp->dp_table));
3284 print (vam->ofp, "%v", line);
3289 vl_api_one_eid_table_map_details_t_handler_json
3290 (vl_api_one_eid_table_map_details_t * mp)
3292 vat_main_t *vam = &vat_main;
3293 vat_json_node_t *node = NULL;
3295 if (VAT_JSON_ARRAY != vam->json_tree.type)
3297 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3298 vat_json_init_array (&vam->json_tree);
3300 node = vat_json_array_add (&vam->json_tree);
3301 vat_json_init_object (node);
3302 vat_json_object_add_uint (node, "dp_table",
3303 clib_net_to_host_u32 (mp->dp_table));
3304 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3308 vl_api_one_eid_table_vni_details_t_handler
3309 (vl_api_one_eid_table_vni_details_t * mp)
3311 vat_main_t *vam = &vat_main;
3313 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3314 print (vam->ofp, "%v", line);
3319 vl_api_one_eid_table_vni_details_t_handler_json
3320 (vl_api_one_eid_table_vni_details_t * mp)
3322 vat_main_t *vam = &vat_main;
3323 vat_json_node_t *node = NULL;
3325 if (VAT_JSON_ARRAY != vam->json_tree.type)
3327 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3328 vat_json_init_array (&vam->json_tree);
3330 node = vat_json_array_add (&vam->json_tree);
3331 vat_json_init_object (node);
3332 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3336 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3337 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3339 vat_main_t *vam = &vat_main;
3340 int retval = clib_net_to_host_u32 (mp->retval);
3342 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3343 print (vam->ofp, "fallback threshold value: %d", mp->value);
3345 vam->retval = retval;
3346 vam->result_ready = 1;
3350 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3351 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3353 vat_main_t *vam = &vat_main;
3354 vat_json_node_t _node, *node = &_node;
3355 int retval = clib_net_to_host_u32 (mp->retval);
3357 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3358 vat_json_init_object (node);
3359 vat_json_object_add_uint (node, "value", mp->value);
3361 vat_json_print (vam->ofp, node);
3362 vat_json_free (node);
3364 vam->retval = retval;
3365 vam->result_ready = 1;
3369 vl_api_show_one_map_register_state_reply_t_handler
3370 (vl_api_show_one_map_register_state_reply_t * mp)
3372 vat_main_t *vam = &vat_main;
3373 int retval = clib_net_to_host_u32 (mp->retval);
3375 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3377 vam->retval = retval;
3378 vam->result_ready = 1;
3382 vl_api_show_one_map_register_state_reply_t_handler_json
3383 (vl_api_show_one_map_register_state_reply_t * mp)
3385 vat_main_t *vam = &vat_main;
3386 vat_json_node_t _node, *node = &_node;
3387 int retval = clib_net_to_host_u32 (mp->retval);
3389 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3391 vat_json_init_object (node);
3392 vat_json_object_add_string_copy (node, "state", s);
3394 vat_json_print (vam->ofp, node);
3395 vat_json_free (node);
3397 vam->retval = retval;
3398 vam->result_ready = 1;
3403 vl_api_show_one_rloc_probe_state_reply_t_handler
3404 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3406 vat_main_t *vam = &vat_main;
3407 int retval = clib_net_to_host_u32 (mp->retval);
3412 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3414 vam->retval = retval;
3415 vam->result_ready = 1;
3419 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3420 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3422 vat_main_t *vam = &vat_main;
3423 vat_json_node_t _node, *node = &_node;
3424 int retval = clib_net_to_host_u32 (mp->retval);
3426 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3427 vat_json_init_object (node);
3428 vat_json_object_add_string_copy (node, "state", s);
3430 vat_json_print (vam->ofp, node);
3431 vat_json_free (node);
3433 vam->retval = retval;
3434 vam->result_ready = 1;
3439 vl_api_show_one_stats_enable_disable_reply_t_handler
3440 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3442 vat_main_t *vam = &vat_main;
3443 int retval = clib_net_to_host_u32 (mp->retval);
3448 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3450 vam->retval = retval;
3451 vam->result_ready = 1;
3455 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3456 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3458 vat_main_t *vam = &vat_main;
3459 vat_json_node_t _node, *node = &_node;
3460 int retval = clib_net_to_host_u32 (mp->retval);
3462 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3463 vat_json_init_object (node);
3464 vat_json_object_add_string_copy (node, "state", s);
3466 vat_json_print (vam->ofp, node);
3467 vat_json_free (node);
3469 vam->retval = retval;
3470 vam->result_ready = 1;
3475 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3477 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3478 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3479 e->vni = clib_net_to_host_u32 (e->vni);
3483 gpe_fwd_entries_get_reply_t_net_to_host
3484 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3488 mp->count = clib_net_to_host_u32 (mp->count);
3489 for (i = 0; i < mp->count; i++)
3491 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3496 format_gpe_encap_mode (u8 * s, va_list * args)
3498 u32 mode = va_arg (*args, u32);
3503 return format (s, "lisp");
3505 return format (s, "vxlan");
3511 vl_api_gpe_get_encap_mode_reply_t_handler
3512 (vl_api_gpe_get_encap_mode_reply_t * mp)
3514 vat_main_t *vam = &vat_main;
3516 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3517 vam->retval = ntohl (mp->retval);
3518 vam->result_ready = 1;
3522 vl_api_gpe_get_encap_mode_reply_t_handler_json
3523 (vl_api_gpe_get_encap_mode_reply_t * mp)
3525 vat_main_t *vam = &vat_main;
3526 vat_json_node_t node;
3528 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3529 vec_add1 (encap_mode, 0);
3531 vat_json_init_object (&node);
3532 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3534 vec_free (encap_mode);
3535 vat_json_print (vam->ofp, &node);
3536 vat_json_free (&node);
3538 vam->retval = ntohl (mp->retval);
3539 vam->result_ready = 1;
3543 vl_api_gpe_fwd_entry_path_details_t_handler
3544 (vl_api_gpe_fwd_entry_path_details_t * mp)
3546 vat_main_t *vam = &vat_main;
3547 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3549 if (mp->lcl_loc.is_ip4)
3550 format_ip_address_fcn = format_ip4_address;
3552 format_ip_address_fcn = format_ip6_address;
3554 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3555 format_ip_address_fcn, &mp->lcl_loc,
3556 format_ip_address_fcn, &mp->rmt_loc);
3560 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3562 struct in6_addr ip6;
3567 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3568 vat_json_object_add_ip4 (n, "address", ip4);
3572 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3573 vat_json_object_add_ip6 (n, "address", ip6);
3575 vat_json_object_add_uint (n, "weight", loc->weight);
3579 vl_api_gpe_fwd_entry_path_details_t_handler_json
3580 (vl_api_gpe_fwd_entry_path_details_t * mp)
3582 vat_main_t *vam = &vat_main;
3583 vat_json_node_t *node = NULL;
3584 vat_json_node_t *loc_node;
3586 if (VAT_JSON_ARRAY != vam->json_tree.type)
3588 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3589 vat_json_init_array (&vam->json_tree);
3591 node = vat_json_array_add (&vam->json_tree);
3592 vat_json_init_object (node);
3594 loc_node = vat_json_object_add (node, "local_locator");
3595 vat_json_init_object (loc_node);
3596 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3598 loc_node = vat_json_object_add (node, "remote_locator");
3599 vat_json_init_object (loc_node);
3600 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3604 vl_api_gpe_fwd_entries_get_reply_t_handler
3605 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3607 vat_main_t *vam = &vat_main;
3609 int retval = clib_net_to_host_u32 (mp->retval);
3610 vl_api_gpe_fwd_entry_t *e;
3615 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3617 for (i = 0; i < mp->count; i++)
3619 e = &mp->entries[i];
3620 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3621 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3622 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3626 vam->retval = retval;
3627 vam->result_ready = 1;
3631 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3632 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3635 vat_main_t *vam = &vat_main;
3636 vat_json_node_t *e = 0, root;
3638 int retval = clib_net_to_host_u32 (mp->retval);
3639 vl_api_gpe_fwd_entry_t *fwd;
3644 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3645 vat_json_init_array (&root);
3647 for (i = 0; i < mp->count; i++)
3649 e = vat_json_array_add (&root);
3650 fwd = &mp->entries[i];
3652 vat_json_init_object (e);
3653 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3654 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3655 vat_json_object_add_int (e, "vni", fwd->vni);
3656 vat_json_object_add_int (e, "action", fwd->action);
3658 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3659 fwd->leid_prefix_len);
3661 vat_json_object_add_string_copy (e, "leid", s);
3664 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3665 fwd->reid_prefix_len);
3667 vat_json_object_add_string_copy (e, "reid", s);
3671 vat_json_print (vam->ofp, &root);
3672 vat_json_free (&root);
3675 vam->retval = retval;
3676 vam->result_ready = 1;
3680 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3681 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3683 vat_main_t *vam = &vat_main;
3685 int retval = clib_net_to_host_u32 (mp->retval);
3686 vl_api_gpe_native_fwd_rpath_t *r;
3691 n = clib_net_to_host_u32 (mp->count);
3693 for (i = 0; i < n; i++)
3695 r = &mp->entries[i];
3696 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3697 clib_net_to_host_u32 (r->fib_index),
3698 clib_net_to_host_u32 (r->nh_sw_if_index),
3699 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3703 vam->retval = retval;
3704 vam->result_ready = 1;
3708 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3709 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3711 vat_main_t *vam = &vat_main;
3712 vat_json_node_t root, *e;
3714 int retval = clib_net_to_host_u32 (mp->retval);
3715 vl_api_gpe_native_fwd_rpath_t *r;
3721 n = clib_net_to_host_u32 (mp->count);
3722 vat_json_init_array (&root);
3724 for (i = 0; i < n; i++)
3726 e = vat_json_array_add (&root);
3727 vat_json_init_object (e);
3728 r = &mp->entries[i];
3730 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3733 vat_json_object_add_string_copy (e, "ip4", s);
3736 vat_json_object_add_uint (e, "fib_index",
3737 clib_net_to_host_u32 (r->fib_index));
3738 vat_json_object_add_uint (e, "nh_sw_if_index",
3739 clib_net_to_host_u32 (r->nh_sw_if_index));
3742 vat_json_print (vam->ofp, &root);
3743 vat_json_free (&root);
3746 vam->retval = retval;
3747 vam->result_ready = 1;
3751 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3752 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3754 vat_main_t *vam = &vat_main;
3756 int retval = clib_net_to_host_u32 (mp->retval);
3761 n = clib_net_to_host_u32 (mp->count);
3763 for (i = 0; i < n; i++)
3764 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3767 vam->retval = retval;
3768 vam->result_ready = 1;
3772 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3773 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3775 vat_main_t *vam = &vat_main;
3776 vat_json_node_t root;
3778 int retval = clib_net_to_host_u32 (mp->retval);
3783 n = clib_net_to_host_u32 (mp->count);
3784 vat_json_init_array (&root);
3786 for (i = 0; i < n; i++)
3787 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3789 vat_json_print (vam->ofp, &root);
3790 vat_json_free (&root);
3793 vam->retval = retval;
3794 vam->result_ready = 1;
3798 vl_api_one_ndp_entries_get_reply_t_handler
3799 (vl_api_one_ndp_entries_get_reply_t * mp)
3801 vat_main_t *vam = &vat_main;
3803 int retval = clib_net_to_host_u32 (mp->retval);
3808 n = clib_net_to_host_u32 (mp->count);
3810 for (i = 0; i < n; i++)
3811 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3812 format_ethernet_address, mp->entries[i].mac);
3815 vam->retval = retval;
3816 vam->result_ready = 1;
3820 vl_api_one_ndp_entries_get_reply_t_handler_json
3821 (vl_api_one_ndp_entries_get_reply_t * mp)
3824 vat_main_t *vam = &vat_main;
3825 vat_json_node_t *e = 0, root;
3827 int retval = clib_net_to_host_u32 (mp->retval);
3828 vl_api_one_ndp_entry_t *arp_entry;
3833 n = clib_net_to_host_u32 (mp->count);
3834 vat_json_init_array (&root);
3836 for (i = 0; i < n; i++)
3838 e = vat_json_array_add (&root);
3839 arp_entry = &mp->entries[i];
3841 vat_json_init_object (e);
3842 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3845 vat_json_object_add_string_copy (e, "mac", s);
3848 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3850 vat_json_object_add_string_copy (e, "ip6", s);
3854 vat_json_print (vam->ofp, &root);
3855 vat_json_free (&root);
3858 vam->retval = retval;
3859 vam->result_ready = 1;
3863 vl_api_one_l2_arp_entries_get_reply_t_handler
3864 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3866 vat_main_t *vam = &vat_main;
3868 int retval = clib_net_to_host_u32 (mp->retval);
3873 n = clib_net_to_host_u32 (mp->count);
3875 for (i = 0; i < n; i++)
3876 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3877 format_ethernet_address, mp->entries[i].mac);
3880 vam->retval = retval;
3881 vam->result_ready = 1;
3885 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3886 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3889 vat_main_t *vam = &vat_main;
3890 vat_json_node_t *e = 0, root;
3892 int retval = clib_net_to_host_u32 (mp->retval);
3893 vl_api_one_l2_arp_entry_t *arp_entry;
3898 n = clib_net_to_host_u32 (mp->count);
3899 vat_json_init_array (&root);
3901 for (i = 0; i < n; i++)
3903 e = vat_json_array_add (&root);
3904 arp_entry = &mp->entries[i];
3906 vat_json_init_object (e);
3907 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3910 vat_json_object_add_string_copy (e, "mac", s);
3913 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3915 vat_json_object_add_string_copy (e, "ip4", s);
3919 vat_json_print (vam->ofp, &root);
3920 vat_json_free (&root);
3923 vam->retval = retval;
3924 vam->result_ready = 1;
3928 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
3930 vat_main_t *vam = &vat_main;
3932 int retval = clib_net_to_host_u32 (mp->retval);
3937 n = clib_net_to_host_u32 (mp->count);
3939 for (i = 0; i < n; i++)
3941 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3945 vam->retval = retval;
3946 vam->result_ready = 1;
3950 vl_api_one_ndp_bd_get_reply_t_handler_json
3951 (vl_api_one_ndp_bd_get_reply_t * mp)
3953 vat_main_t *vam = &vat_main;
3954 vat_json_node_t root;
3956 int retval = clib_net_to_host_u32 (mp->retval);
3961 n = clib_net_to_host_u32 (mp->count);
3962 vat_json_init_array (&root);
3964 for (i = 0; i < n; i++)
3966 vat_json_array_add_uint (&root,
3967 clib_net_to_host_u32 (mp->bridge_domains[i]));
3970 vat_json_print (vam->ofp, &root);
3971 vat_json_free (&root);
3974 vam->retval = retval;
3975 vam->result_ready = 1;
3979 vl_api_one_l2_arp_bd_get_reply_t_handler
3980 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3982 vat_main_t *vam = &vat_main;
3984 int retval = clib_net_to_host_u32 (mp->retval);
3989 n = clib_net_to_host_u32 (mp->count);
3991 for (i = 0; i < n; i++)
3993 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3997 vam->retval = retval;
3998 vam->result_ready = 1;
4002 vl_api_one_l2_arp_bd_get_reply_t_handler_json
4003 (vl_api_one_l2_arp_bd_get_reply_t * mp)
4005 vat_main_t *vam = &vat_main;
4006 vat_json_node_t root;
4008 int retval = clib_net_to_host_u32 (mp->retval);
4013 n = clib_net_to_host_u32 (mp->count);
4014 vat_json_init_array (&root);
4016 for (i = 0; i < n; i++)
4018 vat_json_array_add_uint (&root,
4019 clib_net_to_host_u32 (mp->bridge_domains[i]));
4022 vat_json_print (vam->ofp, &root);
4023 vat_json_free (&root);
4026 vam->retval = retval;
4027 vam->result_ready = 1;
4031 vl_api_one_adjacencies_get_reply_t_handler
4032 (vl_api_one_adjacencies_get_reply_t * mp)
4034 vat_main_t *vam = &vat_main;
4036 int retval = clib_net_to_host_u32 (mp->retval);
4037 vl_api_one_adjacency_t *a;
4042 n = clib_net_to_host_u32 (mp->count);
4044 for (i = 0; i < n; i++)
4046 a = &mp->adjacencies[i];
4047 print (vam->ofp, "%U %40U",
4048 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
4049 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
4053 vam->retval = retval;
4054 vam->result_ready = 1;
4058 vl_api_one_adjacencies_get_reply_t_handler_json
4059 (vl_api_one_adjacencies_get_reply_t * mp)
4062 vat_main_t *vam = &vat_main;
4063 vat_json_node_t *e = 0, root;
4065 int retval = clib_net_to_host_u32 (mp->retval);
4066 vl_api_one_adjacency_t *a;
4071 n = clib_net_to_host_u32 (mp->count);
4072 vat_json_init_array (&root);
4074 for (i = 0; i < n; i++)
4076 e = vat_json_array_add (&root);
4077 a = &mp->adjacencies[i];
4079 vat_json_init_object (e);
4080 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
4081 a->leid_prefix_len);
4083 vat_json_object_add_string_copy (e, "leid", s);
4086 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
4087 a->reid_prefix_len);
4089 vat_json_object_add_string_copy (e, "reid", s);
4093 vat_json_print (vam->ofp, &root);
4094 vat_json_free (&root);
4097 vam->retval = retval;
4098 vam->result_ready = 1;
4102 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
4104 vat_main_t *vam = &vat_main;
4106 print (vam->ofp, "%=20U",
4107 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4112 vl_api_one_map_server_details_t_handler_json
4113 (vl_api_one_map_server_details_t * mp)
4115 vat_main_t *vam = &vat_main;
4116 vat_json_node_t *node = NULL;
4117 struct in6_addr ip6;
4120 if (VAT_JSON_ARRAY != vam->json_tree.type)
4122 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4123 vat_json_init_array (&vam->json_tree);
4125 node = vat_json_array_add (&vam->json_tree);
4127 vat_json_init_object (node);
4130 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4131 vat_json_object_add_ip6 (node, "map-server", ip6);
4135 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4136 vat_json_object_add_ip4 (node, "map-server", ip4);
4141 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4144 vat_main_t *vam = &vat_main;
4146 print (vam->ofp, "%=20U",
4147 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4152 vl_api_one_map_resolver_details_t_handler_json
4153 (vl_api_one_map_resolver_details_t * mp)
4155 vat_main_t *vam = &vat_main;
4156 vat_json_node_t *node = NULL;
4157 struct in6_addr ip6;
4160 if (VAT_JSON_ARRAY != vam->json_tree.type)
4162 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4163 vat_json_init_array (&vam->json_tree);
4165 node = vat_json_array_add (&vam->json_tree);
4167 vat_json_init_object (node);
4170 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4171 vat_json_object_add_ip6 (node, "map resolver", ip6);
4175 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4176 vat_json_object_add_ip4 (node, "map resolver", ip4);
4181 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4183 vat_main_t *vam = &vat_main;
4184 i32 retval = ntohl (mp->retval);
4188 print (vam->ofp, "feature: %s\ngpe: %s",
4189 mp->feature_status ? "enabled" : "disabled",
4190 mp->gpe_status ? "enabled" : "disabled");
4193 vam->retval = retval;
4194 vam->result_ready = 1;
4198 vl_api_show_one_status_reply_t_handler_json
4199 (vl_api_show_one_status_reply_t * mp)
4201 vat_main_t *vam = &vat_main;
4202 vat_json_node_t node;
4203 u8 *gpe_status = NULL;
4204 u8 *feature_status = NULL;
4206 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4207 feature_status = format (0, "%s",
4208 mp->feature_status ? "enabled" : "disabled");
4209 vec_add1 (gpe_status, 0);
4210 vec_add1 (feature_status, 0);
4212 vat_json_init_object (&node);
4213 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4214 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4216 vec_free (gpe_status);
4217 vec_free (feature_status);
4219 vat_json_print (vam->ofp, &node);
4220 vat_json_free (&node);
4222 vam->retval = ntohl (mp->retval);
4223 vam->result_ready = 1;
4227 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4228 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4230 vat_main_t *vam = &vat_main;
4231 i32 retval = ntohl (mp->retval);
4235 print (vam->ofp, "%=20s", mp->locator_set_name);
4238 vam->retval = retval;
4239 vam->result_ready = 1;
4243 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4244 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4246 vat_main_t *vam = &vat_main;
4247 vat_json_node_t *node = NULL;
4249 if (VAT_JSON_ARRAY != vam->json_tree.type)
4251 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4252 vat_json_init_array (&vam->json_tree);
4254 node = vat_json_array_add (&vam->json_tree);
4256 vat_json_init_object (node);
4257 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4259 vat_json_print (vam->ofp, node);
4260 vat_json_free (node);
4262 vam->retval = ntohl (mp->retval);
4263 vam->result_ready = 1;
4267 format_lisp_map_request_mode (u8 * s, va_list * args)
4269 u32 mode = va_arg (*args, u32);
4274 return format (0, "dst-only");
4276 return format (0, "src-dst");
4282 vl_api_show_one_map_request_mode_reply_t_handler
4283 (vl_api_show_one_map_request_mode_reply_t * mp)
4285 vat_main_t *vam = &vat_main;
4286 i32 retval = ntohl (mp->retval);
4290 u32 mode = mp->mode;
4291 print (vam->ofp, "map_request_mode: %U",
4292 format_lisp_map_request_mode, mode);
4295 vam->retval = retval;
4296 vam->result_ready = 1;
4300 vl_api_show_one_map_request_mode_reply_t_handler_json
4301 (vl_api_show_one_map_request_mode_reply_t * mp)
4303 vat_main_t *vam = &vat_main;
4304 vat_json_node_t node;
4309 s = format (0, "%U", format_lisp_map_request_mode, mode);
4312 vat_json_init_object (&node);
4313 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4314 vat_json_print (vam->ofp, &node);
4315 vat_json_free (&node);
4318 vam->retval = ntohl (mp->retval);
4319 vam->result_ready = 1;
4323 vl_api_one_show_xtr_mode_reply_t_handler
4324 (vl_api_one_show_xtr_mode_reply_t * mp)
4326 vat_main_t *vam = &vat_main;
4327 i32 retval = ntohl (mp->retval);
4331 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4334 vam->retval = retval;
4335 vam->result_ready = 1;
4339 vl_api_one_show_xtr_mode_reply_t_handler_json
4340 (vl_api_one_show_xtr_mode_reply_t * mp)
4342 vat_main_t *vam = &vat_main;
4343 vat_json_node_t node;
4346 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4347 vec_add1 (status, 0);
4349 vat_json_init_object (&node);
4350 vat_json_object_add_string_copy (&node, "status", status);
4354 vat_json_print (vam->ofp, &node);
4355 vat_json_free (&node);
4357 vam->retval = ntohl (mp->retval);
4358 vam->result_ready = 1;
4362 vl_api_one_show_pitr_mode_reply_t_handler
4363 (vl_api_one_show_pitr_mode_reply_t * mp)
4365 vat_main_t *vam = &vat_main;
4366 i32 retval = ntohl (mp->retval);
4370 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4373 vam->retval = retval;
4374 vam->result_ready = 1;
4378 vl_api_one_show_pitr_mode_reply_t_handler_json
4379 (vl_api_one_show_pitr_mode_reply_t * mp)
4381 vat_main_t *vam = &vat_main;
4382 vat_json_node_t node;
4385 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4386 vec_add1 (status, 0);
4388 vat_json_init_object (&node);
4389 vat_json_object_add_string_copy (&node, "status", status);
4393 vat_json_print (vam->ofp, &node);
4394 vat_json_free (&node);
4396 vam->retval = ntohl (mp->retval);
4397 vam->result_ready = 1;
4401 vl_api_one_show_petr_mode_reply_t_handler
4402 (vl_api_one_show_petr_mode_reply_t * mp)
4404 vat_main_t *vam = &vat_main;
4405 i32 retval = ntohl (mp->retval);
4409 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4412 vam->retval = retval;
4413 vam->result_ready = 1;
4417 vl_api_one_show_petr_mode_reply_t_handler_json
4418 (vl_api_one_show_petr_mode_reply_t * mp)
4420 vat_main_t *vam = &vat_main;
4421 vat_json_node_t node;
4424 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4425 vec_add1 (status, 0);
4427 vat_json_init_object (&node);
4428 vat_json_object_add_string_copy (&node, "status", status);
4432 vat_json_print (vam->ofp, &node);
4433 vat_json_free (&node);
4435 vam->retval = ntohl (mp->retval);
4436 vam->result_ready = 1;
4440 vl_api_show_one_use_petr_reply_t_handler
4441 (vl_api_show_one_use_petr_reply_t * mp)
4443 vat_main_t *vam = &vat_main;
4444 i32 retval = ntohl (mp->retval);
4448 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4451 print (vam->ofp, "Proxy-ETR address; %U",
4452 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4457 vam->retval = retval;
4458 vam->result_ready = 1;
4462 vl_api_show_one_use_petr_reply_t_handler_json
4463 (vl_api_show_one_use_petr_reply_t * mp)
4465 vat_main_t *vam = &vat_main;
4466 vat_json_node_t node;
4469 struct in6_addr ip6;
4471 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4472 vec_add1 (status, 0);
4474 vat_json_init_object (&node);
4475 vat_json_object_add_string_copy (&node, "status", status);
4480 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4481 vat_json_object_add_ip6 (&node, "address", ip6);
4485 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4486 vat_json_object_add_ip4 (&node, "address", ip4);
4492 vat_json_print (vam->ofp, &node);
4493 vat_json_free (&node);
4495 vam->retval = ntohl (mp->retval);
4496 vam->result_ready = 1;
4500 vl_api_show_one_nsh_mapping_reply_t_handler
4501 (vl_api_show_one_nsh_mapping_reply_t * mp)
4503 vat_main_t *vam = &vat_main;
4504 i32 retval = ntohl (mp->retval);
4508 print (vam->ofp, "%-20s%-16s",
4509 mp->is_set ? "set" : "not-set",
4510 mp->is_set ? (char *) mp->locator_set_name : "");
4513 vam->retval = retval;
4514 vam->result_ready = 1;
4518 vl_api_show_one_nsh_mapping_reply_t_handler_json
4519 (vl_api_show_one_nsh_mapping_reply_t * mp)
4521 vat_main_t *vam = &vat_main;
4522 vat_json_node_t node;
4525 status = format (0, "%s", mp->is_set ? "yes" : "no");
4526 vec_add1 (status, 0);
4528 vat_json_init_object (&node);
4529 vat_json_object_add_string_copy (&node, "is_set", status);
4532 vat_json_object_add_string_copy (&node, "locator_set",
4533 mp->locator_set_name);
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_map_register_ttl_reply_t_handler
4547 (vl_api_show_one_map_register_ttl_reply_t * mp)
4549 vat_main_t *vam = &vat_main;
4550 i32 retval = ntohl (mp->retval);
4552 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4556 print (vam->ofp, "ttl: %u", mp->ttl);
4559 vam->retval = retval;
4560 vam->result_ready = 1;
4564 vl_api_show_one_map_register_ttl_reply_t_handler_json
4565 (vl_api_show_one_map_register_ttl_reply_t * mp)
4567 vat_main_t *vam = &vat_main;
4568 vat_json_node_t node;
4570 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4571 vat_json_init_object (&node);
4572 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4574 vat_json_print (vam->ofp, &node);
4575 vat_json_free (&node);
4577 vam->retval = ntohl (mp->retval);
4578 vam->result_ready = 1;
4582 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4584 vat_main_t *vam = &vat_main;
4585 i32 retval = ntohl (mp->retval);
4589 print (vam->ofp, "%-20s%-16s",
4590 mp->status ? "enabled" : "disabled",
4591 mp->status ? (char *) mp->locator_set_name : "");
4594 vam->retval = retval;
4595 vam->result_ready = 1;
4599 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4601 vat_main_t *vam = &vat_main;
4602 vat_json_node_t node;
4605 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4606 vec_add1 (status, 0);
4608 vat_json_init_object (&node);
4609 vat_json_object_add_string_copy (&node, "status", status);
4612 vat_json_object_add_string_copy (&node, "locator_set",
4613 mp->locator_set_name);
4618 vat_json_print (vam->ofp, &node);
4619 vat_json_free (&node);
4621 vam->retval = ntohl (mp->retval);
4622 vam->result_ready = 1;
4626 format_policer_type (u8 * s, va_list * va)
4628 u32 i = va_arg (*va, u32);
4630 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4631 s = format (s, "1r2c");
4632 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4633 s = format (s, "1r3c");
4634 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4635 s = format (s, "2r3c-2698");
4636 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4637 s = format (s, "2r3c-4115");
4638 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4639 s = format (s, "2r3c-mef5cf1");
4641 s = format (s, "ILLEGAL");
4646 format_policer_rate_type (u8 * s, va_list * va)
4648 u32 i = va_arg (*va, u32);
4650 if (i == SSE2_QOS_RATE_KBPS)
4651 s = format (s, "kbps");
4652 else if (i == SSE2_QOS_RATE_PPS)
4653 s = format (s, "pps");
4655 s = format (s, "ILLEGAL");
4660 format_policer_round_type (u8 * s, va_list * va)
4662 u32 i = va_arg (*va, u32);
4664 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4665 s = format (s, "closest");
4666 else if (i == SSE2_QOS_ROUND_TO_UP)
4667 s = format (s, "up");
4668 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4669 s = format (s, "down");
4671 s = format (s, "ILLEGAL");
4676 format_policer_action_type (u8 * s, va_list * va)
4678 u32 i = va_arg (*va, u32);
4680 if (i == SSE2_QOS_ACTION_DROP)
4681 s = format (s, "drop");
4682 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4683 s = format (s, "transmit");
4684 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4685 s = format (s, "mark-and-transmit");
4687 s = format (s, "ILLEGAL");
4692 format_dscp (u8 * s, va_list * va)
4694 u32 i = va_arg (*va, u32);
4699 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4703 return format (s, "ILLEGAL");
4705 s = format (s, "%s", t);
4710 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4712 vat_main_t *vam = &vat_main;
4713 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4715 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4716 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4718 conform_dscp_str = format (0, "");
4720 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4721 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4723 exceed_dscp_str = format (0, "");
4725 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4726 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4728 violate_dscp_str = format (0, "");
4730 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4731 "rate type %U, round type %U, %s rate, %s color-aware, "
4732 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4733 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4734 "conform action %U%s, exceed action %U%s, violate action %U%s",
4736 format_policer_type, mp->type,
4739 clib_net_to_host_u64 (mp->cb),
4740 clib_net_to_host_u64 (mp->eb),
4741 format_policer_rate_type, mp->rate_type,
4742 format_policer_round_type, mp->round_type,
4743 mp->single_rate ? "single" : "dual",
4744 mp->color_aware ? "is" : "not",
4745 ntohl (mp->cir_tokens_per_period),
4746 ntohl (mp->pir_tokens_per_period),
4748 ntohl (mp->current_limit),
4749 ntohl (mp->current_bucket),
4750 ntohl (mp->extended_limit),
4751 ntohl (mp->extended_bucket),
4752 clib_net_to_host_u64 (mp->last_update_time),
4753 format_policer_action_type, mp->conform_action_type,
4755 format_policer_action_type, mp->exceed_action_type,
4757 format_policer_action_type, mp->violate_action_type,
4760 vec_free (conform_dscp_str);
4761 vec_free (exceed_dscp_str);
4762 vec_free (violate_dscp_str);
4765 static void vl_api_policer_details_t_handler_json
4766 (vl_api_policer_details_t * mp)
4768 vat_main_t *vam = &vat_main;
4769 vat_json_node_t *node;
4770 u8 *rate_type_str, *round_type_str, *type_str;
4771 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4773 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4775 format (0, "%U", format_policer_round_type, mp->round_type);
4776 type_str = format (0, "%U", format_policer_type, mp->type);
4777 conform_action_str = format (0, "%U", format_policer_action_type,
4778 mp->conform_action_type);
4779 exceed_action_str = format (0, "%U", format_policer_action_type,
4780 mp->exceed_action_type);
4781 violate_action_str = format (0, "%U", format_policer_action_type,
4782 mp->violate_action_type);
4784 if (VAT_JSON_ARRAY != vam->json_tree.type)
4786 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4787 vat_json_init_array (&vam->json_tree);
4789 node = vat_json_array_add (&vam->json_tree);
4791 vat_json_init_object (node);
4792 vat_json_object_add_string_copy (node, "name", mp->name);
4793 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4794 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4795 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4796 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4797 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4798 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4799 vat_json_object_add_string_copy (node, "type", type_str);
4800 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4801 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4802 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4803 vat_json_object_add_uint (node, "cir_tokens_per_period",
4804 ntohl (mp->cir_tokens_per_period));
4805 vat_json_object_add_uint (node, "eir_tokens_per_period",
4806 ntohl (mp->pir_tokens_per_period));
4807 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4808 vat_json_object_add_uint (node, "current_bucket",
4809 ntohl (mp->current_bucket));
4810 vat_json_object_add_uint (node, "extended_limit",
4811 ntohl (mp->extended_limit));
4812 vat_json_object_add_uint (node, "extended_bucket",
4813 ntohl (mp->extended_bucket));
4814 vat_json_object_add_uint (node, "last_update_time",
4815 ntohl (mp->last_update_time));
4816 vat_json_object_add_string_copy (node, "conform_action",
4817 conform_action_str);
4818 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4820 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4821 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4822 vec_free (dscp_str);
4824 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4825 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4827 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4828 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4829 vec_free (dscp_str);
4831 vat_json_object_add_string_copy (node, "violate_action",
4832 violate_action_str);
4833 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4835 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4836 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4837 vec_free (dscp_str);
4840 vec_free (rate_type_str);
4841 vec_free (round_type_str);
4842 vec_free (type_str);
4843 vec_free (conform_action_str);
4844 vec_free (exceed_action_str);
4845 vec_free (violate_action_str);
4849 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4852 vat_main_t *vam = &vat_main;
4853 int i, count = ntohl (mp->count);
4856 print (vam->ofp, "classify table ids (%d) : ", count);
4857 for (i = 0; i < count; i++)
4859 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4860 print (vam->ofp, (i < count - 1) ? "," : "");
4862 vam->retval = ntohl (mp->retval);
4863 vam->result_ready = 1;
4867 vl_api_classify_table_ids_reply_t_handler_json
4868 (vl_api_classify_table_ids_reply_t * mp)
4870 vat_main_t *vam = &vat_main;
4871 int i, count = ntohl (mp->count);
4875 vat_json_node_t node;
4877 vat_json_init_object (&node);
4878 for (i = 0; i < count; i++)
4880 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4882 vat_json_print (vam->ofp, &node);
4883 vat_json_free (&node);
4885 vam->retval = ntohl (mp->retval);
4886 vam->result_ready = 1;
4890 vl_api_classify_table_by_interface_reply_t_handler
4891 (vl_api_classify_table_by_interface_reply_t * mp)
4893 vat_main_t *vam = &vat_main;
4896 table_id = ntohl (mp->l2_table_id);
4898 print (vam->ofp, "l2 table id : %d", table_id);
4900 print (vam->ofp, "l2 table id : No input ACL tables configured");
4901 table_id = ntohl (mp->ip4_table_id);
4903 print (vam->ofp, "ip4 table id : %d", table_id);
4905 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4906 table_id = ntohl (mp->ip6_table_id);
4908 print (vam->ofp, "ip6 table id : %d", table_id);
4910 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4911 vam->retval = ntohl (mp->retval);
4912 vam->result_ready = 1;
4916 vl_api_classify_table_by_interface_reply_t_handler_json
4917 (vl_api_classify_table_by_interface_reply_t * mp)
4919 vat_main_t *vam = &vat_main;
4920 vat_json_node_t node;
4922 vat_json_init_object (&node);
4924 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4925 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4926 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4928 vat_json_print (vam->ofp, &node);
4929 vat_json_free (&node);
4931 vam->retval = ntohl (mp->retval);
4932 vam->result_ready = 1;
4935 static void vl_api_policer_add_del_reply_t_handler
4936 (vl_api_policer_add_del_reply_t * mp)
4938 vat_main_t *vam = &vat_main;
4939 i32 retval = ntohl (mp->retval);
4940 if (vam->async_mode)
4942 vam->async_errors += (retval < 0);
4946 vam->retval = retval;
4947 vam->result_ready = 1;
4948 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4950 * Note: this is just barely thread-safe, depends on
4951 * the main thread spinning waiting for an answer...
4953 errmsg ("policer index %d", ntohl (mp->policer_index));
4957 static void vl_api_policer_add_del_reply_t_handler_json
4958 (vl_api_policer_add_del_reply_t * mp)
4960 vat_main_t *vam = &vat_main;
4961 vat_json_node_t node;
4963 vat_json_init_object (&node);
4964 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4965 vat_json_object_add_uint (&node, "policer_index",
4966 ntohl (mp->policer_index));
4968 vat_json_print (vam->ofp, &node);
4969 vat_json_free (&node);
4971 vam->retval = ntohl (mp->retval);
4972 vam->result_ready = 1;
4975 /* Format hex dump. */
4977 format_hex_bytes (u8 * s, va_list * va)
4979 u8 *bytes = va_arg (*va, u8 *);
4980 int n_bytes = va_arg (*va, int);
4983 /* Print short or long form depending on byte count. */
4984 uword short_form = n_bytes <= 32;
4985 u32 indent = format_get_indent (s);
4990 for (i = 0; i < n_bytes; i++)
4992 if (!short_form && (i % 32) == 0)
4993 s = format (s, "%08x: ", i);
4994 s = format (s, "%02x", bytes[i]);
4995 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4996 s = format (s, "\n%U", format_white_space, indent);
5003 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
5006 vat_main_t *vam = &vat_main;
5007 i32 retval = ntohl (mp->retval);
5010 print (vam->ofp, "classify table info :");
5011 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
5012 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
5013 ntohl (mp->miss_next_index));
5014 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
5015 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
5016 ntohl (mp->match_n_vectors));
5017 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
5018 ntohl (mp->mask_length));
5020 vam->retval = retval;
5021 vam->result_ready = 1;
5025 vl_api_classify_table_info_reply_t_handler_json
5026 (vl_api_classify_table_info_reply_t * mp)
5028 vat_main_t *vam = &vat_main;
5029 vat_json_node_t node;
5031 i32 retval = ntohl (mp->retval);
5034 vat_json_init_object (&node);
5036 vat_json_object_add_int (&node, "sessions",
5037 ntohl (mp->active_sessions));
5038 vat_json_object_add_int (&node, "nexttbl",
5039 ntohl (mp->next_table_index));
5040 vat_json_object_add_int (&node, "nextnode",
5041 ntohl (mp->miss_next_index));
5042 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
5043 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
5044 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
5045 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
5046 ntohl (mp->mask_length), 0);
5047 vat_json_object_add_string_copy (&node, "mask", s);
5049 vat_json_print (vam->ofp, &node);
5050 vat_json_free (&node);
5052 vam->retval = ntohl (mp->retval);
5053 vam->result_ready = 1;
5057 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
5060 vat_main_t *vam = &vat_main;
5062 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
5063 ntohl (mp->hit_next_index), ntohl (mp->advance),
5064 ntohl (mp->opaque_index));
5065 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
5066 ntohl (mp->match_length));
5070 vl_api_classify_session_details_t_handler_json
5071 (vl_api_classify_session_details_t * mp)
5073 vat_main_t *vam = &vat_main;
5074 vat_json_node_t *node = NULL;
5076 if (VAT_JSON_ARRAY != vam->json_tree.type)
5078 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5079 vat_json_init_array (&vam->json_tree);
5081 node = vat_json_array_add (&vam->json_tree);
5083 vat_json_init_object (node);
5084 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
5085 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
5086 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
5088 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
5090 vat_json_object_add_string_copy (node, "match", s);
5093 static void vl_api_pg_create_interface_reply_t_handler
5094 (vl_api_pg_create_interface_reply_t * mp)
5096 vat_main_t *vam = &vat_main;
5098 vam->retval = ntohl (mp->retval);
5099 vam->result_ready = 1;
5102 static void vl_api_pg_create_interface_reply_t_handler_json
5103 (vl_api_pg_create_interface_reply_t * mp)
5105 vat_main_t *vam = &vat_main;
5106 vat_json_node_t node;
5108 i32 retval = ntohl (mp->retval);
5111 vat_json_init_object (&node);
5113 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
5115 vat_json_print (vam->ofp, &node);
5116 vat_json_free (&node);
5118 vam->retval = ntohl (mp->retval);
5119 vam->result_ready = 1;
5122 static void vl_api_policer_classify_details_t_handler
5123 (vl_api_policer_classify_details_t * mp)
5125 vat_main_t *vam = &vat_main;
5127 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5128 ntohl (mp->table_index));
5131 static void vl_api_policer_classify_details_t_handler_json
5132 (vl_api_policer_classify_details_t * mp)
5134 vat_main_t *vam = &vat_main;
5135 vat_json_node_t *node;
5137 if (VAT_JSON_ARRAY != vam->json_tree.type)
5139 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5140 vat_json_init_array (&vam->json_tree);
5142 node = vat_json_array_add (&vam->json_tree);
5144 vat_json_init_object (node);
5145 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5146 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5149 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
5150 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5152 vat_main_t *vam = &vat_main;
5153 i32 retval = ntohl (mp->retval);
5154 if (vam->async_mode)
5156 vam->async_errors += (retval < 0);
5160 vam->retval = retval;
5161 vam->sw_if_index = ntohl (mp->sw_if_index);
5162 vam->result_ready = 1;
5166 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
5167 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5169 vat_main_t *vam = &vat_main;
5170 vat_json_node_t node;
5172 vat_json_init_object (&node);
5173 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5174 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
5176 vat_json_print (vam->ofp, &node);
5177 vat_json_free (&node);
5179 vam->retval = ntohl (mp->retval);
5180 vam->result_ready = 1;
5183 static void vl_api_flow_classify_details_t_handler
5184 (vl_api_flow_classify_details_t * mp)
5186 vat_main_t *vam = &vat_main;
5188 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5189 ntohl (mp->table_index));
5192 static void vl_api_flow_classify_details_t_handler_json
5193 (vl_api_flow_classify_details_t * mp)
5195 vat_main_t *vam = &vat_main;
5196 vat_json_node_t *node;
5198 if (VAT_JSON_ARRAY != vam->json_tree.type)
5200 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5201 vat_json_init_array (&vam->json_tree);
5203 node = vat_json_array_add (&vam->json_tree);
5205 vat_json_init_object (node);
5206 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5207 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5210 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
5211 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
5212 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
5213 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
5214 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
5215 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
5216 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
5217 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
5218 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
5219 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
5220 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
5221 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
5222 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5223 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5224 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5225 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5226 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5227 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5228 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5229 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5230 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5231 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5234 * Generate boilerplate reply handlers, which
5235 * dig the return value out of the xxx_reply_t API message,
5236 * stick it into vam->retval, and set vam->result_ready
5238 * Could also do this by pointing N message decode slots at
5239 * a single function, but that could break in subtle ways.
5242 #define foreach_standard_reply_retval_handler \
5243 _(sw_interface_set_flags_reply) \
5244 _(sw_interface_add_del_address_reply) \
5245 _(sw_interface_set_rx_mode_reply) \
5246 _(sw_interface_set_table_reply) \
5247 _(sw_interface_set_mpls_enable_reply) \
5248 _(sw_interface_set_vpath_reply) \
5249 _(sw_interface_set_vxlan_bypass_reply) \
5250 _(sw_interface_set_geneve_bypass_reply) \
5251 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5252 _(sw_interface_set_l2_bridge_reply) \
5253 _(bridge_domain_add_del_reply) \
5254 _(sw_interface_set_l2_xconnect_reply) \
5255 _(l2fib_add_del_reply) \
5256 _(l2fib_flush_int_reply) \
5257 _(l2fib_flush_bd_reply) \
5258 _(ip_add_del_route_reply) \
5259 _(ip_table_add_del_reply) \
5260 _(ip_mroute_add_del_reply) \
5261 _(mpls_route_add_del_reply) \
5262 _(mpls_table_add_del_reply) \
5263 _(mpls_ip_bind_unbind_reply) \
5264 _(bier_route_add_del_reply) \
5265 _(bier_table_add_del_reply) \
5266 _(proxy_arp_add_del_reply) \
5267 _(proxy_arp_intfc_enable_disable_reply) \
5268 _(sw_interface_set_unnumbered_reply) \
5269 _(ip_neighbor_add_del_reply) \
5270 _(oam_add_del_reply) \
5271 _(reset_fib_reply) \
5272 _(dhcp_proxy_config_reply) \
5273 _(dhcp_proxy_set_vss_reply) \
5274 _(dhcp_client_config_reply) \
5275 _(set_ip_flow_hash_reply) \
5276 _(sw_interface_ip6_enable_disable_reply) \
5277 _(sw_interface_ip6_set_link_local_address_reply) \
5278 _(ip6nd_proxy_add_del_reply) \
5279 _(sw_interface_ip6nd_ra_prefix_reply) \
5280 _(sw_interface_ip6nd_ra_config_reply) \
5281 _(set_arp_neighbor_limit_reply) \
5282 _(l2_patch_add_del_reply) \
5283 _(sr_policy_add_reply) \
5284 _(sr_policy_mod_reply) \
5285 _(sr_policy_del_reply) \
5286 _(sr_localsid_add_del_reply) \
5287 _(sr_steering_add_del_reply) \
5288 _(classify_add_del_session_reply) \
5289 _(classify_set_interface_ip_table_reply) \
5290 _(classify_set_interface_l2_tables_reply) \
5291 _(l2tpv3_set_tunnel_cookies_reply) \
5292 _(l2tpv3_interface_enable_disable_reply) \
5293 _(l2tpv3_set_lookup_key_reply) \
5294 _(l2_fib_clear_table_reply) \
5295 _(l2_interface_efp_filter_reply) \
5296 _(l2_interface_vlan_tag_rewrite_reply) \
5297 _(modify_vhost_user_if_reply) \
5298 _(delete_vhost_user_if_reply) \
5299 _(want_ip4_arp_events_reply) \
5300 _(want_ip6_nd_events_reply) \
5301 _(want_l2_macs_events_reply) \
5302 _(input_acl_set_interface_reply) \
5303 _(ipsec_spd_add_del_reply) \
5304 _(ipsec_interface_add_del_spd_reply) \
5305 _(ipsec_spd_add_del_entry_reply) \
5306 _(ipsec_sad_add_del_entry_reply) \
5307 _(ipsec_sa_set_key_reply) \
5308 _(ipsec_tunnel_if_add_del_reply) \
5309 _(ipsec_tunnel_if_set_key_reply) \
5310 _(ipsec_tunnel_if_set_sa_reply) \
5311 _(ikev2_profile_add_del_reply) \
5312 _(ikev2_profile_set_auth_reply) \
5313 _(ikev2_profile_set_id_reply) \
5314 _(ikev2_profile_set_ts_reply) \
5315 _(ikev2_set_local_key_reply) \
5316 _(ikev2_set_responder_reply) \
5317 _(ikev2_set_ike_transforms_reply) \
5318 _(ikev2_set_esp_transforms_reply) \
5319 _(ikev2_set_sa_lifetime_reply) \
5320 _(ikev2_initiate_sa_init_reply) \
5321 _(ikev2_initiate_del_ike_sa_reply) \
5322 _(ikev2_initiate_del_child_sa_reply) \
5323 _(ikev2_initiate_rekey_child_sa_reply) \
5324 _(delete_loopback_reply) \
5325 _(bd_ip_mac_add_del_reply) \
5326 _(map_del_domain_reply) \
5327 _(map_add_del_rule_reply) \
5328 _(want_interface_events_reply) \
5329 _(want_stats_reply) \
5330 _(cop_interface_enable_disable_reply) \
5331 _(cop_whitelist_enable_disable_reply) \
5332 _(sw_interface_clear_stats_reply) \
5333 _(ioam_enable_reply) \
5334 _(ioam_disable_reply) \
5335 _(one_add_del_locator_reply) \
5336 _(one_add_del_local_eid_reply) \
5337 _(one_add_del_remote_mapping_reply) \
5338 _(one_add_del_adjacency_reply) \
5339 _(one_add_del_map_resolver_reply) \
5340 _(one_add_del_map_server_reply) \
5341 _(one_enable_disable_reply) \
5342 _(one_rloc_probe_enable_disable_reply) \
5343 _(one_map_register_enable_disable_reply) \
5344 _(one_map_register_set_ttl_reply) \
5345 _(one_set_transport_protocol_reply) \
5346 _(one_map_register_fallback_threshold_reply) \
5347 _(one_pitr_set_locator_set_reply) \
5348 _(one_map_request_mode_reply) \
5349 _(one_add_del_map_request_itr_rlocs_reply) \
5350 _(one_eid_table_add_del_map_reply) \
5351 _(one_use_petr_reply) \
5352 _(one_stats_enable_disable_reply) \
5353 _(one_add_del_l2_arp_entry_reply) \
5354 _(one_add_del_ndp_entry_reply) \
5355 _(one_stats_flush_reply) \
5356 _(one_enable_disable_xtr_mode_reply) \
5357 _(one_enable_disable_pitr_mode_reply) \
5358 _(one_enable_disable_petr_mode_reply) \
5359 _(gpe_enable_disable_reply) \
5360 _(gpe_set_encap_mode_reply) \
5361 _(gpe_add_del_iface_reply) \
5362 _(gpe_add_del_native_fwd_rpath_reply) \
5363 _(af_packet_delete_reply) \
5364 _(policer_classify_set_interface_reply) \
5365 _(netmap_create_reply) \
5366 _(netmap_delete_reply) \
5367 _(set_ipfix_exporter_reply) \
5368 _(set_ipfix_classify_stream_reply) \
5369 _(ipfix_classify_table_add_del_reply) \
5370 _(flow_classify_set_interface_reply) \
5371 _(sw_interface_span_enable_disable_reply) \
5372 _(pg_capture_reply) \
5373 _(pg_enable_disable_reply) \
5374 _(ip_source_and_port_range_check_add_del_reply) \
5375 _(ip_source_and_port_range_check_interface_add_del_reply)\
5376 _(delete_subif_reply) \
5377 _(l2_interface_pbb_tag_rewrite_reply) \
5379 _(feature_enable_disable_reply) \
5380 _(sw_interface_tag_add_del_reply) \
5381 _(sw_interface_set_mtu_reply) \
5382 _(p2p_ethernet_add_reply) \
5383 _(p2p_ethernet_del_reply) \
5384 _(lldp_config_reply) \
5385 _(sw_interface_set_lldp_reply) \
5386 _(tcp_configure_src_addresses_reply) \
5387 _(dns_enable_disable_reply) \
5388 _(dns_name_server_add_del_reply) \
5389 _(session_rule_add_del_reply) \
5390 _(ip_container_proxy_add_del_reply)
5393 static void vl_api_##n##_t_handler \
5394 (vl_api_##n##_t * mp) \
5396 vat_main_t * vam = &vat_main; \
5397 i32 retval = ntohl(mp->retval); \
5398 if (vam->async_mode) { \
5399 vam->async_errors += (retval < 0); \
5401 vam->retval = retval; \
5402 vam->result_ready = 1; \
5405 foreach_standard_reply_retval_handler;
5409 static void vl_api_##n##_t_handler_json \
5410 (vl_api_##n##_t * mp) \
5412 vat_main_t * vam = &vat_main; \
5413 vat_json_node_t node; \
5414 vat_json_init_object(&node); \
5415 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5416 vat_json_print(vam->ofp, &node); \
5417 vam->retval = ntohl(mp->retval); \
5418 vam->result_ready = 1; \
5420 foreach_standard_reply_retval_handler;
5424 * Table of message reply handlers, must include boilerplate handlers
5428 #define foreach_vpe_api_reply_msg \
5429 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5430 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5431 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5432 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5433 _(CONTROL_PING_REPLY, control_ping_reply) \
5434 _(CLI_REPLY, cli_reply) \
5435 _(CLI_INBAND_REPLY, cli_inband_reply) \
5436 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5437 sw_interface_add_del_address_reply) \
5438 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5439 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5440 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5441 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5442 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5443 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5444 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5445 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5446 sw_interface_set_l2_xconnect_reply) \
5447 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5448 sw_interface_set_l2_bridge_reply) \
5449 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5450 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5451 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5452 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5453 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5454 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5455 _(L2_FLAGS_REPLY, l2_flags_reply) \
5456 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5457 _(TAP_CONNECT_REPLY, tap_connect_reply) \
5458 _(TAP_MODIFY_REPLY, tap_modify_reply) \
5459 _(TAP_DELETE_REPLY, tap_delete_reply) \
5460 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
5461 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5462 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5463 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5464 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5465 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5466 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5467 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5468 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5469 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5470 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5471 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5472 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5473 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5474 proxy_arp_intfc_enable_disable_reply) \
5475 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5476 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5477 sw_interface_set_unnumbered_reply) \
5478 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5479 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5480 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5481 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5482 _(RESET_FIB_REPLY, reset_fib_reply) \
5483 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5484 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5485 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5486 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5487 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5488 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5489 sw_interface_ip6_enable_disable_reply) \
5490 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
5491 sw_interface_ip6_set_link_local_address_reply) \
5492 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5493 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5494 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5495 sw_interface_ip6nd_ra_prefix_reply) \
5496 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5497 sw_interface_ip6nd_ra_config_reply) \
5498 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5499 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5500 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5501 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5502 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5503 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5504 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5505 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5506 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5507 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5508 classify_set_interface_ip_table_reply) \
5509 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5510 classify_set_interface_l2_tables_reply) \
5511 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5512 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5513 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5514 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5515 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5516 l2tpv3_interface_enable_disable_reply) \
5517 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5518 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5519 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5520 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5521 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5522 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5523 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5524 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5525 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5526 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5527 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5528 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5529 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5530 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5531 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5532 _(SHOW_VERSION_REPLY, show_version_reply) \
5533 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5534 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5535 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5536 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5537 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5538 _(IP4_ARP_EVENT, ip4_arp_event) \
5539 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5540 _(IP6_ND_EVENT, ip6_nd_event) \
5541 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5542 _(L2_MACS_EVENT, l2_macs_event) \
5543 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5544 _(IP_ADDRESS_DETAILS, ip_address_details) \
5545 _(IP_DETAILS, ip_details) \
5546 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5547 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5548 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
5549 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
5550 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5551 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5552 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5553 _(IPSEC_TUNNEL_IF_SET_KEY_REPLY, ipsec_tunnel_if_set_key_reply) \
5554 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5555 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
5556 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
5557 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
5558 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
5559 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
5560 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
5561 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
5562 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
5563 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
5564 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
5565 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
5566 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
5567 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
5568 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5569 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5570 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5571 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
5572 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
5573 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
5574 _(MAP_DOMAIN_DETAILS, map_domain_details) \
5575 _(MAP_RULE_DETAILS, map_rule_details) \
5576 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5577 _(WANT_STATS_REPLY, want_stats_reply) \
5578 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5579 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5580 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5581 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5582 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5583 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5584 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5585 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5586 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5587 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5588 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5589 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5590 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5591 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5592 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5593 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5594 one_map_register_enable_disable_reply) \
5595 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5596 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5597 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5598 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5599 one_map_register_fallback_threshold_reply) \
5600 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5601 one_rloc_probe_enable_disable_reply) \
5602 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5603 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5604 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5605 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5606 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5607 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5608 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5609 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5610 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5611 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5612 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5613 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5614 _(ONE_STATS_DETAILS, one_stats_details) \
5615 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5616 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5617 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5618 show_one_stats_enable_disable_reply) \
5619 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5620 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5621 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5622 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5623 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5624 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5625 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5626 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5627 one_enable_disable_pitr_mode_reply) \
5628 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5629 one_enable_disable_petr_mode_reply) \
5630 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5631 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5632 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5633 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5634 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5635 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5636 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5637 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5638 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5639 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5640 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5641 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5642 gpe_add_del_native_fwd_rpath_reply) \
5643 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5644 gpe_fwd_entry_path_details) \
5645 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5646 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5647 one_add_del_map_request_itr_rlocs_reply) \
5648 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5649 one_get_map_request_itr_rlocs_reply) \
5650 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5651 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5652 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5653 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5654 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5655 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5656 show_one_map_register_state_reply) \
5657 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5658 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5659 show_one_map_register_fallback_threshold_reply) \
5660 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5661 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5662 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5663 _(POLICER_DETAILS, policer_details) \
5664 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5665 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5666 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5667 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5668 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5669 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5670 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5671 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5672 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5673 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5674 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5675 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5676 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5677 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5678 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5679 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5680 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5681 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5682 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5683 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5684 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5685 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5686 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5687 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5688 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5689 ip_source_and_port_range_check_add_del_reply) \
5690 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5691 ip_source_and_port_range_check_interface_add_del_reply) \
5692 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5693 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5694 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5695 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5696 _(PUNT_REPLY, punt_reply) \
5697 _(IP_FIB_DETAILS, ip_fib_details) \
5698 _(IP6_FIB_DETAILS, ip6_fib_details) \
5699 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5700 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5701 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5702 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
5703 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5704 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5705 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5706 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5707 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5708 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5709 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5710 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5711 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5712 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5713 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
5714 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \
5715 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5716 _(SESSION_RULES_DETAILS, session_rules_details) \
5717 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5719 #define foreach_standalone_reply_msg \
5720 _(SW_INTERFACE_EVENT, sw_interface_event) \
5721 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
5722 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
5723 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
5724 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
5725 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
5726 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters) \
5727 _(MEMFD_SEGMENT_CREATE_REPLY, memfd_segment_create_reply) \
5736 #define STR_VTR_OP_CASE(op) \
5737 case L2_VTR_ ## op: \
5741 str_vtr_op (u32 vtr_op)
5745 STR_VTR_OP_CASE (DISABLED);
5746 STR_VTR_OP_CASE (PUSH_1);
5747 STR_VTR_OP_CASE (PUSH_2);
5748 STR_VTR_OP_CASE (POP_1);
5749 STR_VTR_OP_CASE (POP_2);
5750 STR_VTR_OP_CASE (TRANSLATE_1_1);
5751 STR_VTR_OP_CASE (TRANSLATE_1_2);
5752 STR_VTR_OP_CASE (TRANSLATE_2_1);
5753 STR_VTR_OP_CASE (TRANSLATE_2_2);
5760 dump_sub_interface_table (vat_main_t * vam)
5762 const sw_interface_subif_t *sub = NULL;
5764 if (vam->json_output)
5767 ("JSON output supported only for VPE API calls and dump_stats_table");
5772 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5773 "Interface", "sw_if_index",
5774 "sub id", "dot1ad", "tags", "outer id",
5775 "inner id", "exact", "default", "outer any", "inner any");
5777 vec_foreach (sub, vam->sw_if_subif_table)
5780 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5781 sub->interface_name,
5783 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5784 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5785 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5786 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5787 if (sub->vtr_op != L2_VTR_DISABLED)
5790 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5791 "tag1: %d tag2: %d ]",
5792 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5793 sub->vtr_tag1, sub->vtr_tag2);
5801 name_sort_cmp (void *a1, void *a2)
5803 name_sort_t *n1 = a1;
5804 name_sort_t *n2 = a2;
5806 return strcmp ((char *) n1->name, (char *) n2->name);
5810 dump_interface_table (vat_main_t * vam)
5813 name_sort_t *nses = 0, *ns;
5815 if (vam->json_output)
5818 ("JSON output supported only for VPE API calls and dump_stats_table");
5823 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5825 vec_add2 (nses, ns, 1);
5826 ns->name = (u8 *)(p->key);
5827 ns->value = (u32) p->value[0];
5831 vec_sort_with_function (nses, name_sort_cmp);
5833 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5834 vec_foreach (ns, nses)
5836 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5843 dump_ip_table (vat_main_t * vam, int is_ipv6)
5845 const ip_details_t *det = NULL;
5846 const ip_address_details_t *address = NULL;
5849 print (vam->ofp, "%-12s", "sw_if_index");
5851 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5858 print (vam->ofp, "%-12d", i);
5859 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5864 vec_foreach (address, det->addr)
5868 is_ipv6 ? format_ip6_address : format_ip4_address,
5869 address->ip, address->prefix_length);
5877 dump_ipv4_table (vat_main_t * vam)
5879 if (vam->json_output)
5882 ("JSON output supported only for VPE API calls and dump_stats_table");
5886 return dump_ip_table (vam, 0);
5890 dump_ipv6_table (vat_main_t * vam)
5892 if (vam->json_output)
5895 ("JSON output supported only for VPE API calls and dump_stats_table");
5899 return dump_ip_table (vam, 1);
5903 counter_type_to_str (u8 counter_type, u8 is_combined)
5907 switch (counter_type)
5909 case VNET_INTERFACE_COUNTER_DROP:
5911 case VNET_INTERFACE_COUNTER_PUNT:
5913 case VNET_INTERFACE_COUNTER_IP4:
5915 case VNET_INTERFACE_COUNTER_IP6:
5917 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
5919 case VNET_INTERFACE_COUNTER_RX_MISS:
5921 case VNET_INTERFACE_COUNTER_RX_ERROR:
5923 case VNET_INTERFACE_COUNTER_TX_ERROR:
5926 return "INVALID-COUNTER-TYPE";
5931 switch (counter_type)
5933 case VNET_INTERFACE_COUNTER_RX:
5935 case VNET_INTERFACE_COUNTER_TX:
5938 return "INVALID-COUNTER-TYPE";
5944 dump_stats_table (vat_main_t * vam)
5946 vat_json_node_t node;
5947 vat_json_node_t *msg_array;
5948 vat_json_node_t *msg;
5949 vat_json_node_t *counter_array;
5950 vat_json_node_t *counter;
5951 interface_counter_t c;
5953 ip4_fib_counter_t *c4;
5954 ip6_fib_counter_t *c6;
5955 ip4_nbr_counter_t *n4;
5956 ip6_nbr_counter_t *n6;
5959 if (!vam->json_output)
5961 clib_warning ("dump_stats_table supported only in JSON format");
5965 vat_json_init_object (&node);
5967 /* interface counters */
5968 msg_array = vat_json_object_add (&node, "interface_counters");
5969 vat_json_init_array (msg_array);
5970 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
5972 msg = vat_json_array_add (msg_array);
5973 vat_json_init_object (msg);
5974 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5975 (u8 *) counter_type_to_str (i, 0));
5976 vat_json_object_add_int (msg, "is_combined", 0);
5977 counter_array = vat_json_object_add (msg, "data");
5978 vat_json_init_array (counter_array);
5979 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
5981 packets = vam->simple_interface_counters[i][j];
5982 vat_json_array_add_uint (counter_array, packets);
5985 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
5987 msg = vat_json_array_add (msg_array);
5988 vat_json_init_object (msg);
5989 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5990 (u8 *) counter_type_to_str (i, 1));
5991 vat_json_object_add_int (msg, "is_combined", 1);
5992 counter_array = vat_json_object_add (msg, "data");
5993 vat_json_init_array (counter_array);
5994 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
5996 c = vam->combined_interface_counters[i][j];
5997 counter = vat_json_array_add (counter_array);
5998 vat_json_init_object (counter);
5999 vat_json_object_add_uint (counter, "packets", c.packets);
6000 vat_json_object_add_uint (counter, "bytes", c.bytes);
6004 /* ip4 fib counters */
6005 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
6006 vat_json_init_array (msg_array);
6007 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
6009 msg = vat_json_array_add (msg_array);
6010 vat_json_init_object (msg);
6011 vat_json_object_add_uint (msg, "vrf_id",
6012 vam->ip4_fib_counters_vrf_id_by_index[i]);
6013 counter_array = vat_json_object_add (msg, "c");
6014 vat_json_init_array (counter_array);
6015 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
6017 counter = vat_json_array_add (counter_array);
6018 vat_json_init_object (counter);
6019 c4 = &vam->ip4_fib_counters[i][j];
6020 vat_json_object_add_ip4 (counter, "address", c4->address);
6021 vat_json_object_add_uint (counter, "address_length",
6022 c4->address_length);
6023 vat_json_object_add_uint (counter, "packets", c4->packets);
6024 vat_json_object_add_uint (counter, "bytes", c4->bytes);
6028 /* ip6 fib counters */
6029 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
6030 vat_json_init_array (msg_array);
6031 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
6033 msg = vat_json_array_add (msg_array);
6034 vat_json_init_object (msg);
6035 vat_json_object_add_uint (msg, "vrf_id",
6036 vam->ip6_fib_counters_vrf_id_by_index[i]);
6037 counter_array = vat_json_object_add (msg, "c");
6038 vat_json_init_array (counter_array);
6039 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
6041 counter = vat_json_array_add (counter_array);
6042 vat_json_init_object (counter);
6043 c6 = &vam->ip6_fib_counters[i][j];
6044 vat_json_object_add_ip6 (counter, "address", c6->address);
6045 vat_json_object_add_uint (counter, "address_length",
6046 c6->address_length);
6047 vat_json_object_add_uint (counter, "packets", c6->packets);
6048 vat_json_object_add_uint (counter, "bytes", c6->bytes);
6052 /* ip4 nbr counters */
6053 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
6054 vat_json_init_array (msg_array);
6055 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
6057 msg = vat_json_array_add (msg_array);
6058 vat_json_init_object (msg);
6059 vat_json_object_add_uint (msg, "sw_if_index", i);
6060 counter_array = vat_json_object_add (msg, "c");
6061 vat_json_init_array (counter_array);
6062 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
6064 counter = vat_json_array_add (counter_array);
6065 vat_json_init_object (counter);
6066 n4 = &vam->ip4_nbr_counters[i][j];
6067 vat_json_object_add_ip4 (counter, "address", n4->address);
6068 vat_json_object_add_uint (counter, "link-type", n4->linkt);
6069 vat_json_object_add_uint (counter, "packets", n4->packets);
6070 vat_json_object_add_uint (counter, "bytes", n4->bytes);
6074 /* ip6 nbr counters */
6075 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
6076 vat_json_init_array (msg_array);
6077 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
6079 msg = vat_json_array_add (msg_array);
6080 vat_json_init_object (msg);
6081 vat_json_object_add_uint (msg, "sw_if_index", i);
6082 counter_array = vat_json_object_add (msg, "c");
6083 vat_json_init_array (counter_array);
6084 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
6086 counter = vat_json_array_add (counter_array);
6087 vat_json_init_object (counter);
6088 n6 = &vam->ip6_nbr_counters[i][j];
6089 vat_json_object_add_ip6 (counter, "address", n6->address);
6090 vat_json_object_add_uint (counter, "packets", n6->packets);
6091 vat_json_object_add_uint (counter, "bytes", n6->bytes);
6095 vat_json_print (vam->ofp, &node);
6096 vat_json_free (&node);
6102 * Pass CLI buffers directly in the CLI_INBAND API message,
6103 * instead of an additional shared memory area.
6106 exec_inband (vat_main_t * vam)
6108 vl_api_cli_inband_t *mp;
6109 unformat_input_t *i = vam->input;
6112 if (vec_len (i->buffer) == 0)
6115 if (vam->exec_mode == 0 && unformat (i, "mode"))
6120 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
6127 * In order for the CLI command to work, it
6128 * must be a vector ending in \n, not a C-string ending
6131 u32 len = vec_len (vam->input->buffer);
6132 M2 (CLI_INBAND, mp, len);
6133 clib_memcpy (mp->cmd, vam->input->buffer, len);
6134 mp->length = htonl (len);
6138 /* json responses may or may not include a useful reply... */
6139 if (vec_len (vam->cmd_reply))
6140 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
6145 exec (vat_main_t * vam)
6147 return exec_inband (vam);
6151 api_create_loopback (vat_main_t * vam)
6153 unformat_input_t *i = vam->input;
6154 vl_api_create_loopback_t *mp;
6155 vl_api_create_loopback_instance_t *mp_lbi;
6158 u8 is_specified = 0;
6159 u32 user_instance = 0;
6162 memset (mac_address, 0, sizeof (mac_address));
6164 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6166 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6168 if (unformat (i, "instance %d", &user_instance))
6176 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
6177 mp_lbi->is_specified = is_specified;
6179 mp_lbi->user_instance = htonl (user_instance);
6181 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
6186 /* Construct the API message */
6187 M (CREATE_LOOPBACK, mp);
6189 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
6198 api_delete_loopback (vat_main_t * vam)
6200 unformat_input_t *i = vam->input;
6201 vl_api_delete_loopback_t *mp;
6202 u32 sw_if_index = ~0;
6205 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6207 if (unformat (i, "sw_if_index %d", &sw_if_index))
6213 if (sw_if_index == ~0)
6215 errmsg ("missing sw_if_index");
6219 /* Construct the API message */
6220 M (DELETE_LOOPBACK, mp);
6221 mp->sw_if_index = ntohl (sw_if_index);
6229 api_want_stats (vat_main_t * vam)
6231 unformat_input_t *i = vam->input;
6232 vl_api_want_stats_t *mp;
6236 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6238 if (unformat (i, "enable"))
6240 else if (unformat (i, "disable"))
6248 errmsg ("missing enable|disable");
6253 mp->enable_disable = enable;
6261 api_want_interface_events (vat_main_t * vam)
6263 unformat_input_t *i = vam->input;
6264 vl_api_want_interface_events_t *mp;
6268 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6270 if (unformat (i, "enable"))
6272 else if (unformat (i, "disable"))
6280 errmsg ("missing enable|disable");
6284 M (WANT_INTERFACE_EVENTS, mp);
6285 mp->enable_disable = enable;
6287 vam->interface_event_display = enable;
6295 /* Note: non-static, called once to set up the initial intfc table */
6297 api_sw_interface_dump (vat_main_t * vam)
6299 vl_api_sw_interface_dump_t *mp;
6300 vl_api_control_ping_t *mp_ping;
6302 name_sort_t *nses = 0, *ns;
6303 sw_interface_subif_t *sub = NULL;
6306 /* Toss the old name table */
6308 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6310 vec_add2 (nses, ns, 1);
6311 ns->name = (u8 *)(p->key);
6312 ns->value = (u32) p->value[0];
6316 hash_free (vam->sw_if_index_by_interface_name);
6318 vec_foreach (ns, nses) vec_free (ns->name);
6322 vec_foreach (sub, vam->sw_if_subif_table)
6324 vec_free (sub->interface_name);
6326 vec_free (vam->sw_if_subif_table);
6328 /* recreate the interface name hash table */
6329 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
6331 /* Get list of ethernets */
6332 M (SW_INTERFACE_DUMP, mp);
6333 mp->name_filter_valid = 1;
6334 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
6337 /* and local / loopback interfaces */
6338 M (SW_INTERFACE_DUMP, mp);
6339 mp->name_filter_valid = 1;
6340 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
6343 /* and packet-generator interfaces */
6344 M (SW_INTERFACE_DUMP, mp);
6345 mp->name_filter_valid = 1;
6346 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
6349 /* and vxlan-gpe tunnel interfaces */
6350 M (SW_INTERFACE_DUMP, mp);
6351 mp->name_filter_valid = 1;
6352 strncpy ((char *) mp->name_filter, "vxlan_gpe",
6353 sizeof (mp->name_filter) - 1);
6356 /* and vxlan tunnel interfaces */
6357 M (SW_INTERFACE_DUMP, mp);
6358 mp->name_filter_valid = 1;
6359 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
6362 /* and geneve tunnel interfaces */
6363 M (SW_INTERFACE_DUMP, mp);
6364 mp->name_filter_valid = 1;
6365 strncpy ((char *) mp->name_filter, "geneve", sizeof (mp->name_filter) - 1);
6368 /* and host (af_packet) interfaces */
6369 M (SW_INTERFACE_DUMP, mp);
6370 mp->name_filter_valid = 1;
6371 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
6374 /* and l2tpv3 tunnel interfaces */
6375 M (SW_INTERFACE_DUMP, mp);
6376 mp->name_filter_valid = 1;
6377 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
6378 sizeof (mp->name_filter) - 1);
6381 /* and GRE tunnel interfaces */
6382 M (SW_INTERFACE_DUMP, mp);
6383 mp->name_filter_valid = 1;
6384 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
6387 /* and LISP-GPE interfaces */
6388 M (SW_INTERFACE_DUMP, mp);
6389 mp->name_filter_valid = 1;
6390 strncpy ((char *) mp->name_filter, "lisp_gpe",
6391 sizeof (mp->name_filter) - 1);
6394 /* and IPSEC tunnel interfaces */
6395 M (SW_INTERFACE_DUMP, mp);
6396 mp->name_filter_valid = 1;
6397 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
6400 /* Use a control ping for synchronization */
6401 MPING (CONTROL_PING, mp_ping);
6409 api_sw_interface_set_flags (vat_main_t * vam)
6411 unformat_input_t *i = vam->input;
6412 vl_api_sw_interface_set_flags_t *mp;
6414 u8 sw_if_index_set = 0;
6418 /* Parse args required to build the message */
6419 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6421 if (unformat (i, "admin-up"))
6423 else if (unformat (i, "admin-down"))
6426 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6427 sw_if_index_set = 1;
6428 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6429 sw_if_index_set = 1;
6434 if (sw_if_index_set == 0)
6436 errmsg ("missing interface name or sw_if_index");
6440 /* Construct the API message */
6441 M (SW_INTERFACE_SET_FLAGS, mp);
6442 mp->sw_if_index = ntohl (sw_if_index);
6443 mp->admin_up_down = admin_up;
6448 /* Wait for a reply, return the good/bad news... */
6454 api_sw_interface_set_rx_mode (vat_main_t * vam)
6456 unformat_input_t *i = vam->input;
6457 vl_api_sw_interface_set_rx_mode_t *mp;
6459 u8 sw_if_index_set = 0;
6461 u8 queue_id_valid = 0;
6463 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
6465 /* Parse args required to build the message */
6466 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6468 if (unformat (i, "queue %d", &queue_id))
6470 else if (unformat (i, "polling"))
6471 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
6472 else if (unformat (i, "interrupt"))
6473 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
6474 else if (unformat (i, "adaptive"))
6475 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
6477 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6478 sw_if_index_set = 1;
6479 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6480 sw_if_index_set = 1;
6485 if (sw_if_index_set == 0)
6487 errmsg ("missing interface name or sw_if_index");
6490 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6492 errmsg ("missing rx-mode");
6496 /* Construct the API message */
6497 M (SW_INTERFACE_SET_RX_MODE, mp);
6498 mp->sw_if_index = ntohl (sw_if_index);
6500 mp->queue_id_valid = queue_id_valid;
6501 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6506 /* Wait for a reply, return the good/bad news... */
6512 api_sw_interface_clear_stats (vat_main_t * vam)
6514 unformat_input_t *i = vam->input;
6515 vl_api_sw_interface_clear_stats_t *mp;
6517 u8 sw_if_index_set = 0;
6520 /* Parse args required to build the message */
6521 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6523 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6524 sw_if_index_set = 1;
6525 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6526 sw_if_index_set = 1;
6531 /* Construct the API message */
6532 M (SW_INTERFACE_CLEAR_STATS, mp);
6534 if (sw_if_index_set == 1)
6535 mp->sw_if_index = ntohl (sw_if_index);
6537 mp->sw_if_index = ~0;
6542 /* Wait for a reply, return the good/bad news... */
6548 api_sw_interface_add_del_address (vat_main_t * vam)
6550 unformat_input_t *i = vam->input;
6551 vl_api_sw_interface_add_del_address_t *mp;
6553 u8 sw_if_index_set = 0;
6554 u8 is_add = 1, del_all = 0;
6555 u32 address_length = 0;
6556 u8 v4_address_set = 0;
6557 u8 v6_address_set = 0;
6558 ip4_address_t v4address;
6559 ip6_address_t v6address;
6562 /* Parse args required to build the message */
6563 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6565 if (unformat (i, "del-all"))
6567 else if (unformat (i, "del"))
6570 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6571 sw_if_index_set = 1;
6572 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6573 sw_if_index_set = 1;
6574 else if (unformat (i, "%U/%d",
6575 unformat_ip4_address, &v4address, &address_length))
6577 else if (unformat (i, "%U/%d",
6578 unformat_ip6_address, &v6address, &address_length))
6584 if (sw_if_index_set == 0)
6586 errmsg ("missing interface name or sw_if_index");
6589 if (v4_address_set && v6_address_set)
6591 errmsg ("both v4 and v6 addresses set");
6594 if (!v4_address_set && !v6_address_set && !del_all)
6596 errmsg ("no addresses set");
6600 /* Construct the API message */
6601 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6603 mp->sw_if_index = ntohl (sw_if_index);
6604 mp->is_add = is_add;
6605 mp->del_all = del_all;
6609 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6613 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6615 mp->address_length = address_length;
6620 /* Wait for a reply, return good/bad news */
6626 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6628 unformat_input_t *i = vam->input;
6629 vl_api_sw_interface_set_mpls_enable_t *mp;
6631 u8 sw_if_index_set = 0;
6635 /* Parse args required to build the message */
6636 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6638 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6639 sw_if_index_set = 1;
6640 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6641 sw_if_index_set = 1;
6642 else if (unformat (i, "disable"))
6644 else if (unformat (i, "dis"))
6650 if (sw_if_index_set == 0)
6652 errmsg ("missing interface name or sw_if_index");
6656 /* Construct the API message */
6657 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6659 mp->sw_if_index = ntohl (sw_if_index);
6660 mp->enable = enable;
6665 /* Wait for a reply... */
6671 api_sw_interface_set_table (vat_main_t * vam)
6673 unformat_input_t *i = vam->input;
6674 vl_api_sw_interface_set_table_t *mp;
6675 u32 sw_if_index, vrf_id = 0;
6676 u8 sw_if_index_set = 0;
6680 /* Parse args required to build the message */
6681 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6683 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6684 sw_if_index_set = 1;
6685 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6686 sw_if_index_set = 1;
6687 else if (unformat (i, "vrf %d", &vrf_id))
6689 else if (unformat (i, "ipv6"))
6695 if (sw_if_index_set == 0)
6697 errmsg ("missing interface name or sw_if_index");
6701 /* Construct the API message */
6702 M (SW_INTERFACE_SET_TABLE, mp);
6704 mp->sw_if_index = ntohl (sw_if_index);
6705 mp->is_ipv6 = is_ipv6;
6706 mp->vrf_id = ntohl (vrf_id);
6711 /* Wait for a reply... */
6716 static void vl_api_sw_interface_get_table_reply_t_handler
6717 (vl_api_sw_interface_get_table_reply_t * mp)
6719 vat_main_t *vam = &vat_main;
6721 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6723 vam->retval = ntohl (mp->retval);
6724 vam->result_ready = 1;
6728 static void vl_api_sw_interface_get_table_reply_t_handler_json
6729 (vl_api_sw_interface_get_table_reply_t * mp)
6731 vat_main_t *vam = &vat_main;
6732 vat_json_node_t node;
6734 vat_json_init_object (&node);
6735 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6736 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6738 vat_json_print (vam->ofp, &node);
6739 vat_json_free (&node);
6741 vam->retval = ntohl (mp->retval);
6742 vam->result_ready = 1;
6746 api_sw_interface_get_table (vat_main_t * vam)
6748 unformat_input_t *i = vam->input;
6749 vl_api_sw_interface_get_table_t *mp;
6751 u8 sw_if_index_set = 0;
6755 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6757 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6758 sw_if_index_set = 1;
6759 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6760 sw_if_index_set = 1;
6761 else if (unformat (i, "ipv6"))
6767 if (sw_if_index_set == 0)
6769 errmsg ("missing interface name or sw_if_index");
6773 M (SW_INTERFACE_GET_TABLE, mp);
6774 mp->sw_if_index = htonl (sw_if_index);
6775 mp->is_ipv6 = is_ipv6;
6783 api_sw_interface_set_vpath (vat_main_t * vam)
6785 unformat_input_t *i = vam->input;
6786 vl_api_sw_interface_set_vpath_t *mp;
6787 u32 sw_if_index = 0;
6788 u8 sw_if_index_set = 0;
6792 /* Parse args required to build the message */
6793 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6795 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6796 sw_if_index_set = 1;
6797 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6798 sw_if_index_set = 1;
6799 else if (unformat (i, "enable"))
6801 else if (unformat (i, "disable"))
6807 if (sw_if_index_set == 0)
6809 errmsg ("missing interface name or sw_if_index");
6813 /* Construct the API message */
6814 M (SW_INTERFACE_SET_VPATH, mp);
6816 mp->sw_if_index = ntohl (sw_if_index);
6817 mp->enable = is_enable;
6822 /* Wait for a reply... */
6828 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6830 unformat_input_t *i = vam->input;
6831 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6832 u32 sw_if_index = 0;
6833 u8 sw_if_index_set = 0;
6838 /* Parse args required to build the message */
6839 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6841 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6842 sw_if_index_set = 1;
6843 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6844 sw_if_index_set = 1;
6845 else if (unformat (i, "enable"))
6847 else if (unformat (i, "disable"))
6849 else if (unformat (i, "ip4"))
6851 else if (unformat (i, "ip6"))
6857 if (sw_if_index_set == 0)
6859 errmsg ("missing interface name or sw_if_index");
6863 /* Construct the API message */
6864 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6866 mp->sw_if_index = ntohl (sw_if_index);
6867 mp->enable = is_enable;
6868 mp->is_ipv6 = is_ipv6;
6873 /* Wait for a reply... */
6879 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6881 unformat_input_t *i = vam->input;
6882 vl_api_sw_interface_set_geneve_bypass_t *mp;
6883 u32 sw_if_index = 0;
6884 u8 sw_if_index_set = 0;
6889 /* Parse args required to build the message */
6890 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6892 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6893 sw_if_index_set = 1;
6894 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6895 sw_if_index_set = 1;
6896 else if (unformat (i, "enable"))
6898 else if (unformat (i, "disable"))
6900 else if (unformat (i, "ip4"))
6902 else if (unformat (i, "ip6"))
6908 if (sw_if_index_set == 0)
6910 errmsg ("missing interface name or sw_if_index");
6914 /* Construct the API message */
6915 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6917 mp->sw_if_index = ntohl (sw_if_index);
6918 mp->enable = is_enable;
6919 mp->is_ipv6 = is_ipv6;
6924 /* Wait for a reply... */
6930 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6932 unformat_input_t *i = vam->input;
6933 vl_api_sw_interface_set_l2_xconnect_t *mp;
6935 u8 rx_sw_if_index_set = 0;
6937 u8 tx_sw_if_index_set = 0;
6941 /* Parse args required to build the message */
6942 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6944 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6945 rx_sw_if_index_set = 1;
6946 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6947 tx_sw_if_index_set = 1;
6948 else if (unformat (i, "rx"))
6950 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6952 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6954 rx_sw_if_index_set = 1;
6959 else if (unformat (i, "tx"))
6961 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6963 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6965 tx_sw_if_index_set = 1;
6970 else if (unformat (i, "enable"))
6972 else if (unformat (i, "disable"))
6978 if (rx_sw_if_index_set == 0)
6980 errmsg ("missing rx interface name or rx_sw_if_index");
6984 if (enable && (tx_sw_if_index_set == 0))
6986 errmsg ("missing tx interface name or tx_sw_if_index");
6990 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6992 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6993 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6994 mp->enable = enable;
7002 api_sw_interface_set_l2_bridge (vat_main_t * vam)
7004 unformat_input_t *i = vam->input;
7005 vl_api_sw_interface_set_l2_bridge_t *mp;
7007 u8 rx_sw_if_index_set = 0;
7015 /* Parse args required to build the message */
7016 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7018 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
7019 rx_sw_if_index_set = 1;
7020 else if (unformat (i, "bd_id %d", &bd_id))
7024 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
7025 rx_sw_if_index_set = 1;
7026 else if (unformat (i, "shg %d", &shg))
7028 else if (unformat (i, "bvi"))
7030 else if (unformat (i, "enable"))
7032 else if (unformat (i, "disable"))
7038 if (rx_sw_if_index_set == 0)
7040 errmsg ("missing rx interface name or sw_if_index");
7044 if (enable && (bd_id_set == 0))
7046 errmsg ("missing bridge domain");
7050 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
7052 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7053 mp->bd_id = ntohl (bd_id);
7056 mp->enable = enable;
7064 api_bridge_domain_dump (vat_main_t * vam)
7066 unformat_input_t *i = vam->input;
7067 vl_api_bridge_domain_dump_t *mp;
7068 vl_api_control_ping_t *mp_ping;
7072 /* Parse args required to build the message */
7073 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7075 if (unformat (i, "bd_id %d", &bd_id))
7081 M (BRIDGE_DOMAIN_DUMP, mp);
7082 mp->bd_id = ntohl (bd_id);
7085 /* Use a control ping for synchronization */
7086 MPING (CONTROL_PING, mp_ping);
7094 api_bridge_domain_add_del (vat_main_t * vam)
7096 unformat_input_t *i = vam->input;
7097 vl_api_bridge_domain_add_del_t *mp;
7100 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
7105 /* Parse args required to build the message */
7106 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7108 if (unformat (i, "bd_id %d", &bd_id))
7110 else if (unformat (i, "flood %d", &flood))
7112 else if (unformat (i, "uu-flood %d", &uu_flood))
7114 else if (unformat (i, "forward %d", &forward))
7116 else if (unformat (i, "learn %d", &learn))
7118 else if (unformat (i, "arp-term %d", &arp_term))
7120 else if (unformat (i, "mac-age %d", &mac_age))
7122 else if (unformat (i, "bd-tag %s", &bd_tag))
7124 else if (unformat (i, "del"))
7127 flood = uu_flood = forward = learn = 0;
7135 errmsg ("missing bridge domain");
7142 errmsg ("mac age must be less than 256 ");
7147 if ((bd_tag) && (vec_len (bd_tag) > 63))
7149 errmsg ("bd-tag cannot be longer than 63");
7154 M (BRIDGE_DOMAIN_ADD_DEL, mp);
7156 mp->bd_id = ntohl (bd_id);
7158 mp->uu_flood = uu_flood;
7159 mp->forward = forward;
7161 mp->arp_term = arp_term;
7162 mp->is_add = is_add;
7163 mp->mac_age = (u8) mac_age;
7166 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
7167 mp->bd_tag[vec_len (bd_tag)] = 0;
7178 api_l2fib_flush_bd (vat_main_t * vam)
7180 unformat_input_t *i = vam->input;
7181 vl_api_l2fib_flush_bd_t *mp;
7185 /* Parse args required to build the message */
7186 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7188 if (unformat (i, "bd_id %d", &bd_id));
7195 errmsg ("missing bridge domain");
7199 M (L2FIB_FLUSH_BD, mp);
7201 mp->bd_id = htonl (bd_id);
7209 api_l2fib_flush_int (vat_main_t * vam)
7211 unformat_input_t *i = vam->input;
7212 vl_api_l2fib_flush_int_t *mp;
7213 u32 sw_if_index = ~0;
7216 /* Parse args required to build the message */
7217 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7219 if (unformat (i, "sw_if_index %d", &sw_if_index));
7221 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
7226 if (sw_if_index == ~0)
7228 errmsg ("missing interface name or sw_if_index");
7232 M (L2FIB_FLUSH_INT, mp);
7234 mp->sw_if_index = ntohl (sw_if_index);
7242 api_l2fib_add_del (vat_main_t * vam)
7244 unformat_input_t *i = vam->input;
7245 vl_api_l2fib_add_del_t *mp;
7251 u32 sw_if_index = ~0;
7252 u8 sw_if_index_set = 0;
7261 /* Parse args required to build the message */
7262 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7264 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
7266 else if (unformat (i, "bd_id %d", &bd_id))
7268 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7269 sw_if_index_set = 1;
7270 else if (unformat (i, "sw_if"))
7272 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7275 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7276 sw_if_index_set = 1;
7281 else if (unformat (i, "static"))
7283 else if (unformat (i, "filter"))
7288 else if (unformat (i, "bvi"))
7293 else if (unformat (i, "del"))
7295 else if (unformat (i, "count %d", &count))
7303 errmsg ("missing mac address");
7309 errmsg ("missing bridge domain");
7313 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7315 errmsg ("missing interface name or sw_if_index");
7321 /* Turn on async mode */
7322 vam->async_mode = 1;
7323 vam->async_errors = 0;
7324 before = vat_time_now (vam);
7327 for (j = 0; j < count; j++)
7329 M (L2FIB_ADD_DEL, mp);
7331 clib_memcpy (mp->mac, mac, 6);
7332 mp->bd_id = ntohl (bd_id);
7333 mp->is_add = is_add;
7337 mp->sw_if_index = ntohl (sw_if_index);
7338 mp->static_mac = static_mac;
7339 mp->filter_mac = filter_mac;
7340 mp->bvi_mac = bvi_mac;
7342 increment_mac_address (mac);
7349 vl_api_control_ping_t *mp_ping;
7352 /* Shut off async mode */
7353 vam->async_mode = 0;
7355 MPING (CONTROL_PING, mp_ping);
7358 timeout = vat_time_now (vam) + 1.0;
7359 while (vat_time_now (vam) < timeout)
7360 if (vam->result_ready == 1)
7365 if (vam->retval == -99)
7368 if (vam->async_errors > 0)
7370 errmsg ("%d asynchronous errors", vam->async_errors);
7373 vam->async_errors = 0;
7374 after = vat_time_now (vam);
7376 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7377 count, after - before, count / (after - before));
7383 /* Wait for a reply... */
7387 /* Return the good/bad news */
7388 return (vam->retval);
7392 api_bridge_domain_set_mac_age (vat_main_t * vam)
7394 unformat_input_t *i = vam->input;
7395 vl_api_bridge_domain_set_mac_age_t *mp;
7400 /* Parse args required to build the message */
7401 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7403 if (unformat (i, "bd_id %d", &bd_id));
7404 else if (unformat (i, "mac-age %d", &mac_age));
7411 errmsg ("missing bridge domain");
7417 errmsg ("mac age must be less than 256 ");
7421 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7423 mp->bd_id = htonl (bd_id);
7424 mp->mac_age = (u8) mac_age;
7432 api_l2_flags (vat_main_t * vam)
7434 unformat_input_t *i = vam->input;
7435 vl_api_l2_flags_t *mp;
7438 u8 sw_if_index_set = 0;
7442 /* Parse args required to build the message */
7443 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7445 if (unformat (i, "sw_if_index %d", &sw_if_index))
7446 sw_if_index_set = 1;
7447 else if (unformat (i, "sw_if"))
7449 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7452 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7453 sw_if_index_set = 1;
7458 else if (unformat (i, "learn"))
7460 else if (unformat (i, "forward"))
7462 else if (unformat (i, "flood"))
7464 else if (unformat (i, "uu-flood"))
7465 flags |= L2_UU_FLOOD;
7466 else if (unformat (i, "arp-term"))
7467 flags |= L2_ARP_TERM;
7468 else if (unformat (i, "off"))
7470 else if (unformat (i, "disable"))
7476 if (sw_if_index_set == 0)
7478 errmsg ("missing interface name or sw_if_index");
7484 mp->sw_if_index = ntohl (sw_if_index);
7485 mp->feature_bitmap = ntohl (flags);
7486 mp->is_set = is_set;
7494 api_bridge_flags (vat_main_t * vam)
7496 unformat_input_t *i = vam->input;
7497 vl_api_bridge_flags_t *mp;
7504 /* Parse args required to build the message */
7505 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7507 if (unformat (i, "bd_id %d", &bd_id))
7509 else if (unformat (i, "learn"))
7511 else if (unformat (i, "forward"))
7513 else if (unformat (i, "flood"))
7515 else if (unformat (i, "uu-flood"))
7516 flags |= L2_UU_FLOOD;
7517 else if (unformat (i, "arp-term"))
7518 flags |= L2_ARP_TERM;
7519 else if (unformat (i, "off"))
7521 else if (unformat (i, "disable"))
7529 errmsg ("missing bridge domain");
7533 M (BRIDGE_FLAGS, mp);
7535 mp->bd_id = ntohl (bd_id);
7536 mp->feature_bitmap = ntohl (flags);
7537 mp->is_set = is_set;
7545 api_bd_ip_mac_add_del (vat_main_t * vam)
7547 unformat_input_t *i = vam->input;
7548 vl_api_bd_ip_mac_add_del_t *mp;
7555 ip4_address_t v4addr;
7556 ip6_address_t v6addr;
7561 /* Parse args required to build the message */
7562 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7564 if (unformat (i, "bd_id %d", &bd_id))
7568 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
7572 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
7577 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
7581 else if (unformat (i, "del"))
7589 errmsg ("missing bridge domain");
7592 else if (ip_set == 0)
7594 errmsg ("missing IP address");
7597 else if (mac_set == 0)
7599 errmsg ("missing MAC address");
7603 M (BD_IP_MAC_ADD_DEL, mp);
7605 mp->bd_id = ntohl (bd_id);
7606 mp->is_ipv6 = is_ipv6;
7607 mp->is_add = is_add;
7609 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
7611 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
7612 clib_memcpy (mp->mac_address, macaddr, 6);
7619 api_tap_connect (vat_main_t * vam)
7621 unformat_input_t *i = vam->input;
7622 vl_api_tap_connect_t *mp;
7628 ip4_address_t ip4_address;
7630 int ip4_address_set = 0;
7631 ip6_address_t ip6_address;
7633 int ip6_address_set = 0;
7636 memset (mac_address, 0, sizeof (mac_address));
7638 /* Parse args required to build the message */
7639 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7641 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7645 else if (unformat (i, "random-mac"))
7647 else if (unformat (i, "tapname %s", &tap_name))
7649 else if (unformat (i, "tag %s", &tag))
7651 else if (unformat (i, "address %U/%d",
7652 unformat_ip4_address, &ip4_address, &ip4_mask_width))
7653 ip4_address_set = 1;
7654 else if (unformat (i, "address %U/%d",
7655 unformat_ip6_address, &ip6_address, &ip6_mask_width))
7656 ip6_address_set = 1;
7663 errmsg ("missing tap name");
7666 if (vec_len (tap_name) > 63)
7668 errmsg ("tap name too long");
7671 vec_add1 (tap_name, 0);
7673 if (vec_len (tag) > 63)
7675 errmsg ("tag too long");
7679 /* Construct the API message */
7680 M (TAP_CONNECT, mp);
7682 mp->use_random_mac = random_mac;
7683 clib_memcpy (mp->mac_address, mac_address, 6);
7684 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7686 clib_memcpy (mp->tag, tag, vec_len (tag));
7688 if (ip4_address_set)
7690 mp->ip4_address_set = 1;
7691 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
7692 mp->ip4_mask_width = ip4_mask_width;
7694 if (ip6_address_set)
7696 mp->ip6_address_set = 1;
7697 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
7698 mp->ip6_mask_width = ip6_mask_width;
7701 vec_free (tap_name);
7707 /* Wait for a reply... */
7713 api_tap_modify (vat_main_t * vam)
7715 unformat_input_t *i = vam->input;
7716 vl_api_tap_modify_t *mp;
7721 u32 sw_if_index = ~0;
7722 u8 sw_if_index_set = 0;
7725 memset (mac_address, 0, sizeof (mac_address));
7727 /* Parse args required to build the message */
7728 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7730 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7731 sw_if_index_set = 1;
7732 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7733 sw_if_index_set = 1;
7734 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7738 else if (unformat (i, "random-mac"))
7740 else if (unformat (i, "tapname %s", &tap_name))
7746 if (sw_if_index_set == 0)
7748 errmsg ("missing vpp interface name");
7753 errmsg ("missing tap name");
7756 if (vec_len (tap_name) > 63)
7758 errmsg ("tap name too long");
7760 vec_add1 (tap_name, 0);
7762 /* Construct the API message */
7765 mp->use_random_mac = random_mac;
7766 mp->sw_if_index = ntohl (sw_if_index);
7767 clib_memcpy (mp->mac_address, mac_address, 6);
7768 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7769 vec_free (tap_name);
7774 /* Wait for a reply... */
7780 api_tap_delete (vat_main_t * vam)
7782 unformat_input_t *i = vam->input;
7783 vl_api_tap_delete_t *mp;
7784 u32 sw_if_index = ~0;
7785 u8 sw_if_index_set = 0;
7788 /* Parse args required to build the message */
7789 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7791 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7792 sw_if_index_set = 1;
7793 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7794 sw_if_index_set = 1;
7799 if (sw_if_index_set == 0)
7801 errmsg ("missing vpp interface name");
7805 /* Construct the API message */
7808 mp->sw_if_index = ntohl (sw_if_index);
7813 /* Wait for a reply... */
7819 api_tap_create_v2 (vat_main_t * vam)
7821 unformat_input_t *i = vam->input;
7822 vl_api_tap_create_v2_t *mp;
7826 u8 *host_if_name = 0;
7828 u8 host_mac_addr[6];
7829 u8 host_mac_addr_set = 0;
7830 u8 *host_bridge = 0;
7831 ip4_address_t host_ip4_addr;
7832 u32 host_ip4_prefix_len = 0;
7833 ip6_address_t host_ip6_addr;
7834 u32 host_ip6_prefix_len = 0;
7836 int rx_ring_sz = 0, tx_ring_sz = 0;
7838 memset (mac_address, 0, sizeof (mac_address));
7840 /* Parse args required to build the message */
7841 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7843 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7847 else if (unformat (i, "id %s", &id))
7849 else if (unformat (i, "host-if-name %s", &host_if_name))
7851 else if (unformat (i, "host-ns %s", &host_ns))
7853 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
7855 host_mac_addr_set = 1;
7856 else if (unformat (i, "host-bridge %s", &host_bridge))
7858 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
7859 &host_ip4_addr, &host_ip4_prefix_len))
7861 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
7862 &host_ip6_addr, &host_ip6_prefix_len))
7864 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
7866 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
7872 if (vec_len (host_if_name) > 63)
7874 errmsg ("tap name too long. ");
7877 if (vec_len (host_ns) > 63)
7879 errmsg ("host name space too long. ");
7882 if (vec_len (host_bridge) > 63)
7884 errmsg ("host bridge name too long. ");
7887 if (host_ip4_prefix_len > 32)
7889 errmsg ("host ip4 prefix length not valid. ");
7892 if (host_ip6_prefix_len > 128)
7894 errmsg ("host ip6 prefix length not valid. ");
7897 if (!is_pow2 (rx_ring_sz))
7899 errmsg ("rx ring size must be power of 2. ");
7902 if (rx_ring_sz > 32768)
7904 errmsg ("rx ring size must be 32768 or lower. ");
7907 if (!is_pow2 (tx_ring_sz))
7909 errmsg ("tx ring size must be power of 2. ");
7912 if (tx_ring_sz > 32768)
7914 errmsg ("tx ring size must be 32768 or lower. ");
7918 /* Construct the API message */
7919 M (TAP_CREATE_V2, mp);
7921 mp->use_random_mac = random_mac;
7924 mp->host_namespace_set = host_ns != 0;
7925 mp->host_bridge_set = host_bridge != 0;
7926 mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
7927 mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
7928 mp->rx_ring_sz = rx_ring_sz;
7929 mp->tx_ring_sz = tx_ring_sz;
7932 clib_memcpy (mp->mac_address, mac_address, 6);
7933 if (host_mac_addr_set)
7934 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
7936 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
7938 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
7940 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
7941 if (host_ip4_prefix_len)
7942 clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
7943 if (host_ip4_prefix_len)
7944 clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
7948 vec_free (host_if_name);
7949 vec_free (host_bridge);
7954 /* Wait for a reply... */
7960 api_tap_delete_v2 (vat_main_t * vam)
7962 unformat_input_t *i = vam->input;
7963 vl_api_tap_delete_v2_t *mp;
7964 u32 sw_if_index = ~0;
7965 u8 sw_if_index_set = 0;
7968 /* Parse args required to build the message */
7969 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7971 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7972 sw_if_index_set = 1;
7973 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7974 sw_if_index_set = 1;
7979 if (sw_if_index_set == 0)
7981 errmsg ("missing vpp interface name. ");
7985 /* Construct the API message */
7986 M (TAP_DELETE_V2, mp);
7988 mp->sw_if_index = ntohl (sw_if_index);
7993 /* Wait for a reply... */
7999 api_ip_table_add_del (vat_main_t * vam)
8001 unformat_input_t *i = vam->input;
8002 vl_api_ip_table_add_del_t *mp;
8008 /* Parse args required to build the message */
8009 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8011 if (unformat (i, "ipv6"))
8013 else if (unformat (i, "del"))
8015 else if (unformat (i, "add"))
8017 else if (unformat (i, "table %d", &table_id))
8021 clib_warning ("parse error '%U'", format_unformat_error, i);
8028 errmsg ("missing table-ID");
8032 /* Construct the API message */
8033 M (IP_TABLE_ADD_DEL, mp);
8035 mp->table_id = ntohl (table_id);
8036 mp->is_ipv6 = is_ipv6;
8037 mp->is_add = is_add;
8042 /* Wait for a reply... */
8049 api_ip_add_del_route (vat_main_t * vam)
8051 unformat_input_t *i = vam->input;
8052 vl_api_ip_add_del_route_t *mp;
8053 u32 sw_if_index = ~0, vrf_id = 0;
8055 u8 is_local = 0, is_drop = 0;
8056 u8 is_unreach = 0, is_prohibit = 0;
8058 u32 next_hop_weight = 1;
8059 u8 is_multipath = 0;
8061 u8 address_length_set = 0;
8062 u32 next_hop_table_id = 0;
8063 u32 resolve_attempts = 0;
8064 u32 dst_address_length = 0;
8065 u8 next_hop_set = 0;
8066 ip4_address_t v4_dst_address, v4_next_hop_address;
8067 ip6_address_t v6_dst_address, v6_next_hop_address;
8071 u32 random_add_del = 0;
8072 u32 *random_vector = 0;
8074 u32 random_seed = 0xdeaddabe;
8075 u32 classify_table_index = ~0;
8077 u8 resolve_host = 0, resolve_attached = 0;
8078 mpls_label_t *next_hop_out_label_stack = NULL;
8079 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8080 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8082 /* Parse args required to build the message */
8083 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8085 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8087 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8089 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
8094 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
8099 else if (unformat (i, "/%d", &dst_address_length))
8101 address_length_set = 1;
8104 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
8105 &v4_next_hop_address))
8109 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
8110 &v6_next_hop_address))
8114 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
8116 else if (unformat (i, "weight %d", &next_hop_weight))
8118 else if (unformat (i, "drop"))
8122 else if (unformat (i, "null-send-unreach"))
8126 else if (unformat (i, "null-send-prohibit"))
8130 else if (unformat (i, "local"))
8134 else if (unformat (i, "classify %d", &classify_table_index))
8138 else if (unformat (i, "del"))
8140 else if (unformat (i, "add"))
8142 else if (unformat (i, "resolve-via-host"))
8144 else if (unformat (i, "resolve-via-attached"))
8145 resolve_attached = 1;
8146 else if (unformat (i, "multipath"))
8148 else if (unformat (i, "vrf %d", &vrf_id))
8150 else if (unformat (i, "count %d", &count))
8152 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
8154 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8156 else if (unformat (i, "out-label %d", &next_hop_out_label))
8157 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
8158 else if (unformat (i, "via-label %d", &next_hop_via_label))
8160 else if (unformat (i, "random"))
8162 else if (unformat (i, "seed %d", &random_seed))
8166 clib_warning ("parse error '%U'", format_unformat_error, i);
8171 if (!next_hop_set && !is_drop && !is_local &&
8172 !is_classify && !is_unreach && !is_prohibit &&
8173 MPLS_LABEL_INVALID == next_hop_via_label)
8176 ("next hop / local / drop / unreach / prohibit / classify not set");
8180 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
8182 errmsg ("next hop and next-hop via label set");
8185 if (address_set == 0)
8187 errmsg ("missing addresses");
8191 if (address_length_set == 0)
8193 errmsg ("missing address length");
8197 /* Generate a pile of unique, random routes */
8200 u32 this_random_address;
8201 random_hash = hash_create (count, sizeof (uword));
8203 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
8204 for (j = 0; j <= count; j++)
8208 this_random_address = random_u32 (&random_seed);
8209 this_random_address =
8210 clib_host_to_net_u32 (this_random_address);
8212 while (hash_get (random_hash, this_random_address));
8213 vec_add1 (random_vector, this_random_address);
8214 hash_set (random_hash, this_random_address, 1);
8216 hash_free (random_hash);
8217 v4_dst_address.as_u32 = random_vector[0];
8222 /* Turn on async mode */
8223 vam->async_mode = 1;
8224 vam->async_errors = 0;
8225 before = vat_time_now (vam);
8228 for (j = 0; j < count; j++)
8230 /* Construct the API message */
8231 M2 (IP_ADD_DEL_ROUTE, mp,
8232 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
8234 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8235 mp->table_id = ntohl (vrf_id);
8237 mp->is_add = is_add;
8238 mp->is_drop = is_drop;
8239 mp->is_unreach = is_unreach;
8240 mp->is_prohibit = is_prohibit;
8241 mp->is_ipv6 = is_ipv6;
8242 mp->is_local = is_local;
8243 mp->is_classify = is_classify;
8244 mp->is_multipath = is_multipath;
8245 mp->is_resolve_host = resolve_host;
8246 mp->is_resolve_attached = resolve_attached;
8247 mp->next_hop_weight = next_hop_weight;
8248 mp->dst_address_length = dst_address_length;
8249 mp->next_hop_table_id = ntohl (next_hop_table_id);
8250 mp->classify_table_index = ntohl (classify_table_index);
8251 mp->next_hop_via_label = ntohl (next_hop_via_label);
8252 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8253 if (0 != mp->next_hop_n_out_labels)
8255 memcpy (mp->next_hop_out_label_stack,
8256 next_hop_out_label_stack,
8257 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
8258 vec_free (next_hop_out_label_stack);
8263 clib_memcpy (mp->dst_address, &v6_dst_address,
8264 sizeof (v6_dst_address));
8266 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
8267 sizeof (v6_next_hop_address));
8268 increment_v6_address (&v6_dst_address);
8272 clib_memcpy (mp->dst_address, &v4_dst_address,
8273 sizeof (v4_dst_address));
8275 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
8276 sizeof (v4_next_hop_address));
8278 v4_dst_address.as_u32 = random_vector[j + 1];
8280 increment_v4_address (&v4_dst_address);
8284 /* If we receive SIGTERM, stop now... */
8289 /* When testing multiple add/del ops, use a control-ping to sync */
8292 vl_api_control_ping_t *mp_ping;
8296 /* Shut off async mode */
8297 vam->async_mode = 0;
8299 MPING (CONTROL_PING, mp_ping);
8302 timeout = vat_time_now (vam) + 1.0;
8303 while (vat_time_now (vam) < timeout)
8304 if (vam->result_ready == 1)
8309 if (vam->retval == -99)
8312 if (vam->async_errors > 0)
8314 errmsg ("%d asynchronous errors", vam->async_errors);
8317 vam->async_errors = 0;
8318 after = vat_time_now (vam);
8320 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8324 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8325 count, after - before, count / (after - before));
8331 /* Wait for a reply... */
8336 /* Return the good/bad news */
8337 return (vam->retval);
8341 api_ip_mroute_add_del (vat_main_t * vam)
8343 unformat_input_t *i = vam->input;
8344 vl_api_ip_mroute_add_del_t *mp;
8345 u32 sw_if_index = ~0, vrf_id = 0;
8350 u32 grp_address_length = 0;
8351 ip4_address_t v4_grp_address, v4_src_address;
8352 ip6_address_t v6_grp_address, v6_src_address;
8353 mfib_itf_flags_t iflags = 0;
8354 mfib_entry_flags_t eflags = 0;
8357 /* Parse args required to build the message */
8358 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8360 if (unformat (i, "sw_if_index %d", &sw_if_index))
8362 else if (unformat (i, "%U %U",
8363 unformat_ip4_address, &v4_src_address,
8364 unformat_ip4_address, &v4_grp_address))
8366 grp_address_length = 64;
8370 else if (unformat (i, "%U %U",
8371 unformat_ip6_address, &v6_src_address,
8372 unformat_ip6_address, &v6_grp_address))
8374 grp_address_length = 256;
8378 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
8380 memset (&v4_src_address, 0, sizeof (v4_src_address));
8381 grp_address_length = 32;
8385 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
8387 memset (&v6_src_address, 0, sizeof (v6_src_address));
8388 grp_address_length = 128;
8392 else if (unformat (i, "/%d", &grp_address_length))
8394 else if (unformat (i, "local"))
8398 else if (unformat (i, "del"))
8400 else if (unformat (i, "add"))
8402 else if (unformat (i, "vrf %d", &vrf_id))
8404 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
8406 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8410 clib_warning ("parse error '%U'", format_unformat_error, i);
8415 if (address_set == 0)
8417 errmsg ("missing addresses\n");
8421 /* Construct the API message */
8422 M (IP_MROUTE_ADD_DEL, mp);
8424 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8425 mp->table_id = ntohl (vrf_id);
8427 mp->is_add = is_add;
8428 mp->is_ipv6 = is_ipv6;
8429 mp->is_local = is_local;
8430 mp->itf_flags = ntohl (iflags);
8431 mp->entry_flags = ntohl (eflags);
8432 mp->grp_address_length = grp_address_length;
8433 mp->grp_address_length = ntohs (mp->grp_address_length);
8437 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
8438 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
8442 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
8443 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
8449 /* Wait for a reply... */
8455 api_mpls_table_add_del (vat_main_t * vam)
8457 unformat_input_t *i = vam->input;
8458 vl_api_mpls_table_add_del_t *mp;
8463 /* Parse args required to build the message */
8464 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8466 if (unformat (i, "table %d", &table_id))
8468 else if (unformat (i, "del"))
8470 else if (unformat (i, "add"))
8474 clib_warning ("parse error '%U'", format_unformat_error, i);
8481 errmsg ("missing table-ID");
8485 /* Construct the API message */
8486 M (MPLS_TABLE_ADD_DEL, mp);
8488 mp->mt_table_id = ntohl (table_id);
8489 mp->mt_is_add = is_add;
8494 /* Wait for a reply... */
8501 api_mpls_route_add_del (vat_main_t * vam)
8503 unformat_input_t *i = vam->input;
8504 vl_api_mpls_route_add_del_t *mp;
8505 u32 sw_if_index = ~0, table_id = 0;
8507 u32 next_hop_weight = 1;
8508 u8 is_multipath = 0;
8509 u32 next_hop_table_id = 0;
8510 u8 next_hop_set = 0;
8511 ip4_address_t v4_next_hop_address = {
8514 ip6_address_t v6_next_hop_address = { {0} };
8518 u32 classify_table_index = ~0;
8520 u8 resolve_host = 0, resolve_attached = 0;
8521 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8522 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8523 mpls_label_t *next_hop_out_label_stack = NULL;
8524 mpls_label_t local_label = MPLS_LABEL_INVALID;
8526 dpo_proto_t next_hop_proto = DPO_PROTO_IP4;
8528 /* Parse args required to build the message */
8529 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8531 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8533 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8535 else if (unformat (i, "%d", &local_label))
8537 else if (unformat (i, "eos"))
8539 else if (unformat (i, "non-eos"))
8541 else if (unformat (i, "via %U", unformat_ip4_address,
8542 &v4_next_hop_address))
8545 next_hop_proto = DPO_PROTO_IP4;
8547 else if (unformat (i, "via %U", unformat_ip6_address,
8548 &v6_next_hop_address))
8551 next_hop_proto = DPO_PROTO_IP6;
8553 else if (unformat (i, "weight %d", &next_hop_weight))
8555 else if (unformat (i, "classify %d", &classify_table_index))
8559 else if (unformat (i, "del"))
8561 else if (unformat (i, "add"))
8563 else if (unformat (i, "resolve-via-host"))
8565 else if (unformat (i, "resolve-via-attached"))
8566 resolve_attached = 1;
8567 else if (unformat (i, "multipath"))
8569 else if (unformat (i, "count %d", &count))
8571 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
8574 next_hop_proto = DPO_PROTO_IP4;
8576 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
8579 next_hop_proto = DPO_PROTO_IP6;
8581 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8583 else if (unformat (i, "via-label %d", &next_hop_via_label))
8585 else if (unformat (i, "out-label %d", &next_hop_out_label))
8586 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
8589 clib_warning ("parse error '%U'", format_unformat_error, i);
8594 if (!next_hop_set && !is_classify)
8596 errmsg ("next hop / classify not set");
8600 if (MPLS_LABEL_INVALID == local_label)
8602 errmsg ("missing label");
8608 /* Turn on async mode */
8609 vam->async_mode = 1;
8610 vam->async_errors = 0;
8611 before = vat_time_now (vam);
8614 for (j = 0; j < count; j++)
8616 /* Construct the API message */
8617 M2 (MPLS_ROUTE_ADD_DEL, mp,
8618 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
8620 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
8621 mp->mr_table_id = ntohl (table_id);
8623 mp->mr_is_add = is_add;
8624 mp->mr_next_hop_proto = next_hop_proto;
8625 mp->mr_is_classify = is_classify;
8626 mp->mr_is_multipath = is_multipath;
8627 mp->mr_is_resolve_host = resolve_host;
8628 mp->mr_is_resolve_attached = resolve_attached;
8629 mp->mr_next_hop_weight = next_hop_weight;
8630 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
8631 mp->mr_classify_table_index = ntohl (classify_table_index);
8632 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
8633 mp->mr_label = ntohl (local_label);
8634 mp->mr_eos = is_eos;
8636 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8637 if (0 != mp->mr_next_hop_n_out_labels)
8639 memcpy (mp->mr_next_hop_out_label_stack,
8640 next_hop_out_label_stack,
8641 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
8642 vec_free (next_hop_out_label_stack);
8647 if (DPO_PROTO_IP4 == next_hop_proto)
8649 clib_memcpy (mp->mr_next_hop,
8650 &v4_next_hop_address,
8651 sizeof (v4_next_hop_address));
8653 else if (DPO_PROTO_IP6 == next_hop_proto)
8656 clib_memcpy (mp->mr_next_hop,
8657 &v6_next_hop_address,
8658 sizeof (v6_next_hop_address));
8665 /* If we receive SIGTERM, stop now... */
8670 /* When testing multiple add/del ops, use a control-ping to sync */
8673 vl_api_control_ping_t *mp_ping;
8677 /* Shut off async mode */
8678 vam->async_mode = 0;
8680 MPING (CONTROL_PING, mp_ping);
8683 timeout = vat_time_now (vam) + 1.0;
8684 while (vat_time_now (vam) < timeout)
8685 if (vam->result_ready == 1)
8690 if (vam->retval == -99)
8693 if (vam->async_errors > 0)
8695 errmsg ("%d asynchronous errors", vam->async_errors);
8698 vam->async_errors = 0;
8699 after = vat_time_now (vam);
8701 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8705 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8706 count, after - before, count / (after - before));
8712 /* Wait for a reply... */
8717 /* Return the good/bad news */
8718 return (vam->retval);
8722 api_mpls_ip_bind_unbind (vat_main_t * vam)
8724 unformat_input_t *i = vam->input;
8725 vl_api_mpls_ip_bind_unbind_t *mp;
8726 u32 ip_table_id = 0;
8729 ip4_address_t v4_address;
8730 ip6_address_t v6_address;
8733 mpls_label_t local_label = MPLS_LABEL_INVALID;
8736 /* Parse args required to build the message */
8737 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8739 if (unformat (i, "%U/%d", unformat_ip4_address,
8740 &v4_address, &address_length))
8745 else if (unformat (i, "%U/%d", unformat_ip6_address,
8746 &v6_address, &address_length))
8751 else if (unformat (i, "%d", &local_label))
8753 else if (unformat (i, "table-id %d", &ip_table_id))
8755 else if (unformat (i, "unbind"))
8757 else if (unformat (i, "bind"))
8761 clib_warning ("parse error '%U'", format_unformat_error, i);
8768 errmsg ("IP addres not set");
8772 if (MPLS_LABEL_INVALID == local_label)
8774 errmsg ("missing label");
8778 /* Construct the API message */
8779 M (MPLS_IP_BIND_UNBIND, mp);
8781 mp->mb_is_bind = is_bind;
8782 mp->mb_is_ip4 = is_ip4;
8783 mp->mb_ip_table_id = ntohl (ip_table_id);
8784 mp->mb_mpls_table_id = 0;
8785 mp->mb_label = ntohl (local_label);
8786 mp->mb_address_length = address_length;
8789 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
8791 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
8796 /* Wait for a reply... */
8802 api_bier_table_add_del (vat_main_t * vam)
8804 unformat_input_t *i = vam->input;
8805 vl_api_bier_table_add_del_t *mp;
8807 u32 set = 0, sub_domain = 0, hdr_len = 3;
8808 mpls_label_t local_label = MPLS_LABEL_INVALID;
8811 /* Parse args required to build the message */
8812 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8814 if (unformat (i, "sub-domain %d", &sub_domain))
8816 else if (unformat (i, "set %d", &set))
8818 else if (unformat (i, "label %d", &local_label))
8820 else if (unformat (i, "hdr-len %d", &hdr_len))
8822 else if (unformat (i, "add"))
8824 else if (unformat (i, "del"))
8828 clib_warning ("parse error '%U'", format_unformat_error, i);
8833 if (MPLS_LABEL_INVALID == local_label)
8835 errmsg ("missing label\n");
8839 /* Construct the API message */
8840 M (BIER_TABLE_ADD_DEL, mp);
8842 mp->bt_is_add = is_add;
8843 mp->bt_label = ntohl (local_label);
8844 mp->bt_tbl_id.bt_set = set;
8845 mp->bt_tbl_id.bt_sub_domain = sub_domain;
8846 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
8851 /* Wait for a reply... */
8858 api_bier_route_add_del (vat_main_t * vam)
8860 unformat_input_t *i = vam->input;
8861 vl_api_bier_route_add_del_t *mp;
8863 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
8864 ip4_address_t v4_next_hop_address;
8865 ip6_address_t v6_next_hop_address;
8866 u8 next_hop_set = 0;
8867 u8 next_hop_proto_is_ip4 = 1;
8868 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8871 /* Parse args required to build the message */
8872 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8874 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
8876 next_hop_proto_is_ip4 = 1;
8879 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
8881 next_hop_proto_is_ip4 = 0;
8884 if (unformat (i, "sub-domain %d", &sub_domain))
8886 else if (unformat (i, "set %d", &set))
8888 else if (unformat (i, "hdr-len %d", &hdr_len))
8890 else if (unformat (i, "bp %d", &bp))
8892 else if (unformat (i, "add"))
8894 else if (unformat (i, "del"))
8896 else if (unformat (i, "out-label %d", &next_hop_out_label))
8900 clib_warning ("parse error '%U'", format_unformat_error, i);
8905 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
8907 errmsg ("next hop / label set\n");
8912 errmsg ("bit=position not set\n");
8916 /* Construct the API message */
8917 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path3_t));
8919 mp->br_is_add = is_add;
8920 mp->br_tbl_id.bt_set = set;
8921 mp->br_tbl_id.bt_sub_domain = sub_domain;
8922 mp->br_tbl_id.bt_hdr_len_id = hdr_len;
8923 mp->br_bp = ntohs (bp);
8925 mp->br_paths[0].n_labels = 1;
8926 mp->br_paths[0].label_stack[0] = ntohl (next_hop_out_label);
8927 mp->br_paths[0].afi = (next_hop_proto_is_ip4 ? 0 : 1);
8929 if (next_hop_proto_is_ip4)
8931 clib_memcpy (mp->br_paths[0].next_hop,
8932 &v4_next_hop_address, sizeof (v4_next_hop_address));
8936 clib_memcpy (mp->br_paths[0].next_hop,
8937 &v6_next_hop_address, sizeof (v6_next_hop_address));
8943 /* Wait for a reply... */
8950 api_proxy_arp_add_del (vat_main_t * vam)
8952 unformat_input_t *i = vam->input;
8953 vl_api_proxy_arp_add_del_t *mp;
8956 ip4_address_t lo, hi;
8960 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8962 if (unformat (i, "vrf %d", &vrf_id))
8964 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
8965 unformat_ip4_address, &hi))
8967 else if (unformat (i, "del"))
8971 clib_warning ("parse error '%U'", format_unformat_error, i);
8978 errmsg ("address range not set");
8982 M (PROXY_ARP_ADD_DEL, mp);
8984 mp->vrf_id = ntohl (vrf_id);
8985 mp->is_add = is_add;
8986 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
8987 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
8995 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
8997 unformat_input_t *i = vam->input;
8998 vl_api_proxy_arp_intfc_enable_disable_t *mp;
9001 u8 sw_if_index_set = 0;
9004 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9006 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9007 sw_if_index_set = 1;
9008 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9009 sw_if_index_set = 1;
9010 else if (unformat (i, "enable"))
9012 else if (unformat (i, "disable"))
9016 clib_warning ("parse error '%U'", format_unformat_error, i);
9021 if (sw_if_index_set == 0)
9023 errmsg ("missing interface name or sw_if_index");
9027 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
9029 mp->sw_if_index = ntohl (sw_if_index);
9030 mp->enable_disable = enable;
9038 api_mpls_tunnel_add_del (vat_main_t * vam)
9040 unformat_input_t *i = vam->input;
9041 vl_api_mpls_tunnel_add_del_t *mp;
9045 u32 sw_if_index = ~0;
9046 u32 next_hop_sw_if_index = ~0;
9047 u32 next_hop_proto_is_ip4 = 1;
9049 u32 next_hop_table_id = 0;
9050 ip4_address_t v4_next_hop_address = {
9053 ip6_address_t v6_next_hop_address = { {0} };
9054 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
9057 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9059 if (unformat (i, "add"))
9061 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
9063 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
9065 else if (unformat (i, "via %U",
9066 unformat_ip4_address, &v4_next_hop_address))
9068 next_hop_proto_is_ip4 = 1;
9070 else if (unformat (i, "via %U",
9071 unformat_ip6_address, &v6_next_hop_address))
9073 next_hop_proto_is_ip4 = 0;
9075 else if (unformat (i, "l2-only"))
9077 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
9079 else if (unformat (i, "out-label %d", &next_hop_out_label))
9080 vec_add1 (labels, ntohl (next_hop_out_label));
9083 clib_warning ("parse error '%U'", format_unformat_error, i);
9088 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
9090 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
9091 mp->mt_sw_if_index = ntohl (sw_if_index);
9092 mp->mt_is_add = is_add;
9093 mp->mt_l2_only = l2_only;
9094 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
9095 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
9097 mp->mt_next_hop_n_out_labels = vec_len (labels);
9099 if (0 != mp->mt_next_hop_n_out_labels)
9101 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
9102 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
9106 if (next_hop_proto_is_ip4)
9108 clib_memcpy (mp->mt_next_hop,
9109 &v4_next_hop_address, sizeof (v4_next_hop_address));
9113 clib_memcpy (mp->mt_next_hop,
9114 &v6_next_hop_address, sizeof (v6_next_hop_address));
9123 api_sw_interface_set_unnumbered (vat_main_t * vam)
9125 unformat_input_t *i = vam->input;
9126 vl_api_sw_interface_set_unnumbered_t *mp;
9128 u32 unnum_sw_index = ~0;
9130 u8 sw_if_index_set = 0;
9133 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9135 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9136 sw_if_index_set = 1;
9137 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9138 sw_if_index_set = 1;
9139 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
9141 else if (unformat (i, "del"))
9145 clib_warning ("parse error '%U'", format_unformat_error, i);
9150 if (sw_if_index_set == 0)
9152 errmsg ("missing interface name or sw_if_index");
9156 M (SW_INTERFACE_SET_UNNUMBERED, mp);
9158 mp->sw_if_index = ntohl (sw_if_index);
9159 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
9160 mp->is_add = is_add;
9168 api_ip_neighbor_add_del (vat_main_t * vam)
9170 unformat_input_t *i = vam->input;
9171 vl_api_ip_neighbor_add_del_t *mp;
9173 u8 sw_if_index_set = 0;
9176 u8 is_no_fib_entry = 0;
9179 u8 v4_address_set = 0;
9180 u8 v6_address_set = 0;
9181 ip4_address_t v4address;
9182 ip6_address_t v6address;
9185 memset (mac_address, 0, sizeof (mac_address));
9187 /* Parse args required to build the message */
9188 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9190 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
9194 else if (unformat (i, "del"))
9197 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9198 sw_if_index_set = 1;
9199 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9200 sw_if_index_set = 1;
9201 else if (unformat (i, "is_static"))
9203 else if (unformat (i, "no-fib-entry"))
9204 is_no_fib_entry = 1;
9205 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
9207 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
9211 clib_warning ("parse error '%U'", format_unformat_error, i);
9216 if (sw_if_index_set == 0)
9218 errmsg ("missing interface name or sw_if_index");
9221 if (v4_address_set && v6_address_set)
9223 errmsg ("both v4 and v6 addresses set");
9226 if (!v4_address_set && !v6_address_set)
9228 errmsg ("no address set");
9232 /* Construct the API message */
9233 M (IP_NEIGHBOR_ADD_DEL, mp);
9235 mp->sw_if_index = ntohl (sw_if_index);
9236 mp->is_add = is_add;
9237 mp->is_static = is_static;
9238 mp->is_no_adj_fib = is_no_fib_entry;
9240 clib_memcpy (mp->mac_address, mac_address, 6);
9244 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
9248 /* mp->is_ipv6 = 0; via memset in M macro above */
9249 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
9255 /* Wait for a reply, return good/bad news */
9261 api_create_vlan_subif (vat_main_t * vam)
9263 unformat_input_t *i = vam->input;
9264 vl_api_create_vlan_subif_t *mp;
9266 u8 sw_if_index_set = 0;
9271 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9273 if (unformat (i, "sw_if_index %d", &sw_if_index))
9274 sw_if_index_set = 1;
9276 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9277 sw_if_index_set = 1;
9278 else if (unformat (i, "vlan %d", &vlan_id))
9282 clib_warning ("parse error '%U'", format_unformat_error, i);
9287 if (sw_if_index_set == 0)
9289 errmsg ("missing interface name or sw_if_index");
9293 if (vlan_id_set == 0)
9295 errmsg ("missing vlan_id");
9298 M (CREATE_VLAN_SUBIF, mp);
9300 mp->sw_if_index = ntohl (sw_if_index);
9301 mp->vlan_id = ntohl (vlan_id);
9308 #define foreach_create_subif_bit \
9315 _(outer_vlan_id_any) \
9316 _(inner_vlan_id_any)
9319 api_create_subif (vat_main_t * vam)
9321 unformat_input_t *i = vam->input;
9322 vl_api_create_subif_t *mp;
9324 u8 sw_if_index_set = 0;
9331 u32 exact_match = 0;
9332 u32 default_sub = 0;
9333 u32 outer_vlan_id_any = 0;
9334 u32 inner_vlan_id_any = 0;
9336 u16 outer_vlan_id = 0;
9337 u16 inner_vlan_id = 0;
9340 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9342 if (unformat (i, "sw_if_index %d", &sw_if_index))
9343 sw_if_index_set = 1;
9345 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9346 sw_if_index_set = 1;
9347 else if (unformat (i, "sub_id %d", &sub_id))
9349 else if (unformat (i, "outer_vlan_id %d", &tmp))
9350 outer_vlan_id = tmp;
9351 else if (unformat (i, "inner_vlan_id %d", &tmp))
9352 inner_vlan_id = tmp;
9354 #define _(a) else if (unformat (i, #a)) a = 1 ;
9355 foreach_create_subif_bit
9359 clib_warning ("parse error '%U'", format_unformat_error, i);
9364 if (sw_if_index_set == 0)
9366 errmsg ("missing interface name or sw_if_index");
9370 if (sub_id_set == 0)
9372 errmsg ("missing sub_id");
9375 M (CREATE_SUBIF, mp);
9377 mp->sw_if_index = ntohl (sw_if_index);
9378 mp->sub_id = ntohl (sub_id);
9380 #define _(a) mp->a = a;
9381 foreach_create_subif_bit;
9384 mp->outer_vlan_id = ntohs (outer_vlan_id);
9385 mp->inner_vlan_id = ntohs (inner_vlan_id);
9393 api_oam_add_del (vat_main_t * vam)
9395 unformat_input_t *i = vam->input;
9396 vl_api_oam_add_del_t *mp;
9399 ip4_address_t src, dst;
9404 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9406 if (unformat (i, "vrf %d", &vrf_id))
9408 else if (unformat (i, "src %U", unformat_ip4_address, &src))
9410 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
9412 else if (unformat (i, "del"))
9416 clib_warning ("parse error '%U'", format_unformat_error, i);
9423 errmsg ("missing src addr");
9429 errmsg ("missing dst addr");
9433 M (OAM_ADD_DEL, mp);
9435 mp->vrf_id = ntohl (vrf_id);
9436 mp->is_add = is_add;
9437 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
9438 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
9446 api_reset_fib (vat_main_t * vam)
9448 unformat_input_t *i = vam->input;
9449 vl_api_reset_fib_t *mp;
9455 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9457 if (unformat (i, "vrf %d", &vrf_id))
9459 else if (unformat (i, "ipv6"))
9463 clib_warning ("parse error '%U'", format_unformat_error, i);
9468 if (vrf_id_set == 0)
9470 errmsg ("missing vrf id");
9476 mp->vrf_id = ntohl (vrf_id);
9477 mp->is_ipv6 = is_ipv6;
9485 api_dhcp_proxy_config (vat_main_t * vam)
9487 unformat_input_t *i = vam->input;
9488 vl_api_dhcp_proxy_config_t *mp;
9490 u32 server_vrf_id = 0;
9492 u8 v4_address_set = 0;
9493 u8 v6_address_set = 0;
9494 ip4_address_t v4address;
9495 ip6_address_t v6address;
9496 u8 v4_src_address_set = 0;
9497 u8 v6_src_address_set = 0;
9498 ip4_address_t v4srcaddress;
9499 ip6_address_t v6srcaddress;
9502 /* Parse args required to build the message */
9503 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9505 if (unformat (i, "del"))
9507 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
9509 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
9511 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
9513 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
9515 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
9516 v4_src_address_set = 1;
9517 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
9518 v6_src_address_set = 1;
9523 if (v4_address_set && v6_address_set)
9525 errmsg ("both v4 and v6 server addresses set");
9528 if (!v4_address_set && !v6_address_set)
9530 errmsg ("no server addresses set");
9534 if (v4_src_address_set && v6_src_address_set)
9536 errmsg ("both v4 and v6 src addresses set");
9539 if (!v4_src_address_set && !v6_src_address_set)
9541 errmsg ("no src addresses set");
9545 if (!(v4_src_address_set && v4_address_set) &&
9546 !(v6_src_address_set && v6_address_set))
9548 errmsg ("no matching server and src addresses set");
9552 /* Construct the API message */
9553 M (DHCP_PROXY_CONFIG, mp);
9555 mp->is_add = is_add;
9556 mp->rx_vrf_id = ntohl (rx_vrf_id);
9557 mp->server_vrf_id = ntohl (server_vrf_id);
9561 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
9562 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
9566 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
9567 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
9573 /* Wait for a reply, return good/bad news */
9578 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
9579 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
9582 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
9584 vat_main_t *vam = &vat_main;
9585 u32 i, count = mp->count;
9586 vl_api_dhcp_server_t *s;
9590 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9591 "VSS VPN-ID '%s', VSS FIB-ID %d, VSS OUI %d",
9592 ntohl (mp->rx_vrf_id),
9593 format_ip6_address, mp->dhcp_src_address,
9594 mp->vss_type, mp->vss_vpn_ascii_id,
9595 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9598 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9599 "VSS VPN-ID '%s', VSS FIB-ID %d, VSS OUI %d",
9600 ntohl (mp->rx_vrf_id),
9601 format_ip4_address, mp->dhcp_src_address,
9602 mp->vss_type, mp->vss_vpn_ascii_id,
9603 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9605 for (i = 0; i < count; i++)
9607 s = &mp->servers[i];
9611 " Server Table-ID %d, Server Address %U",
9612 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
9615 " Server Table-ID %d, Server Address %U",
9616 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
9620 static void vl_api_dhcp_proxy_details_t_handler_json
9621 (vl_api_dhcp_proxy_details_t * mp)
9623 vat_main_t *vam = &vat_main;
9624 vat_json_node_t *node = NULL;
9625 u32 i, count = mp->count;
9627 struct in6_addr ip6;
9628 vl_api_dhcp_server_t *s;
9630 if (VAT_JSON_ARRAY != vam->json_tree.type)
9632 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9633 vat_json_init_array (&vam->json_tree);
9635 node = vat_json_array_add (&vam->json_tree);
9637 vat_json_init_object (node);
9638 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
9639 vat_json_object_add_bytes (node, "vss-type", &mp->vss_type,
9640 sizeof (mp->vss_type));
9641 vat_json_object_add_string_copy (node, "vss-vpn-ascii-id",
9642 mp->vss_vpn_ascii_id);
9643 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
9644 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
9648 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
9649 vat_json_object_add_ip6 (node, "src_address", ip6);
9653 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
9654 vat_json_object_add_ip4 (node, "src_address", ip4);
9657 for (i = 0; i < count; i++)
9659 s = &mp->servers[i];
9661 vat_json_object_add_uint (node, "server-table-id",
9662 ntohl (s->server_vrf_id));
9666 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
9667 vat_json_object_add_ip4 (node, "src_address", ip4);
9671 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
9672 vat_json_object_add_ip6 (node, "server_address", ip6);
9678 api_dhcp_proxy_dump (vat_main_t * vam)
9680 unformat_input_t *i = vam->input;
9681 vl_api_control_ping_t *mp_ping;
9682 vl_api_dhcp_proxy_dump_t *mp;
9686 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9688 if (unformat (i, "ipv6"))
9692 clib_warning ("parse error '%U'", format_unformat_error, i);
9697 M (DHCP_PROXY_DUMP, mp);
9699 mp->is_ip6 = is_ipv6;
9702 /* Use a control ping for synchronization */
9703 MPING (CONTROL_PING, mp_ping);
9711 api_dhcp_proxy_set_vss (vat_main_t * vam)
9713 unformat_input_t *i = vam->input;
9714 vl_api_dhcp_proxy_set_vss_t *mp;
9718 u8 vss_type = VSS_TYPE_DEFAULT;
9719 u8 *vpn_ascii_id = 0;
9724 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9726 if (unformat (i, "tbl_id %d", &tbl_id))
9728 else if (unformat (i, "vpn_ascii_id %s", &vpn_ascii_id))
9729 vss_type = VSS_TYPE_ASCII;
9730 else if (unformat (i, "fib_id %d", &fib_id))
9731 vss_type = VSS_TYPE_VPN_ID;
9732 else if (unformat (i, "oui %d", &oui))
9733 vss_type = VSS_TYPE_VPN_ID;
9734 else if (unformat (i, "ipv6"))
9736 else if (unformat (i, "del"))
9744 errmsg ("missing tbl_id ");
9745 vec_free (vpn_ascii_id);
9749 if ((vpn_ascii_id) && (vec_len (vpn_ascii_id) > 128))
9751 errmsg ("vpn_ascii_id cannot be longer than 128 ");
9752 vec_free (vpn_ascii_id);
9756 M (DHCP_PROXY_SET_VSS, mp);
9757 mp->tbl_id = ntohl (tbl_id);
9758 mp->vss_type = vss_type;
9761 clib_memcpy (mp->vpn_ascii_id, vpn_ascii_id, vec_len (vpn_ascii_id));
9762 mp->vpn_ascii_id[vec_len (vpn_ascii_id)] = 0;
9764 mp->vpn_index = ntohl (fib_id);
9765 mp->oui = ntohl (oui);
9766 mp->is_ipv6 = is_ipv6;
9767 mp->is_add = is_add;
9772 vec_free (vpn_ascii_id);
9777 api_dhcp_client_config (vat_main_t * vam)
9779 unformat_input_t *i = vam->input;
9780 vl_api_dhcp_client_config_t *mp;
9782 u8 sw_if_index_set = 0;
9785 u8 disable_event = 0;
9788 /* Parse args required to build the message */
9789 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9791 if (unformat (i, "del"))
9794 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9795 sw_if_index_set = 1;
9796 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9797 sw_if_index_set = 1;
9798 else if (unformat (i, "hostname %s", &hostname))
9800 else if (unformat (i, "disable_event"))
9806 if (sw_if_index_set == 0)
9808 errmsg ("missing interface name or sw_if_index");
9812 if (vec_len (hostname) > 63)
9814 errmsg ("hostname too long");
9816 vec_add1 (hostname, 0);
9818 /* Construct the API message */
9819 M (DHCP_CLIENT_CONFIG, mp);
9821 mp->sw_if_index = htonl (sw_if_index);
9822 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
9823 vec_free (hostname);
9824 mp->is_add = is_add;
9825 mp->want_dhcp_event = disable_event ? 0 : 1;
9826 mp->pid = htonl (getpid ());
9831 /* Wait for a reply, return good/bad news */
9837 api_set_ip_flow_hash (vat_main_t * vam)
9839 unformat_input_t *i = vam->input;
9840 vl_api_set_ip_flow_hash_t *mp;
9852 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9854 if (unformat (i, "vrf %d", &vrf_id))
9856 else if (unformat (i, "ipv6"))
9858 else if (unformat (i, "src"))
9860 else if (unformat (i, "dst"))
9862 else if (unformat (i, "sport"))
9864 else if (unformat (i, "dport"))
9866 else if (unformat (i, "proto"))
9868 else if (unformat (i, "reverse"))
9873 clib_warning ("parse error '%U'", format_unformat_error, i);
9878 if (vrf_id_set == 0)
9880 errmsg ("missing vrf id");
9884 M (SET_IP_FLOW_HASH, mp);
9890 mp->reverse = reverse;
9891 mp->vrf_id = ntohl (vrf_id);
9892 mp->is_ipv6 = is_ipv6;
9900 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
9902 unformat_input_t *i = vam->input;
9903 vl_api_sw_interface_ip6_enable_disable_t *mp;
9905 u8 sw_if_index_set = 0;
9909 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9911 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9912 sw_if_index_set = 1;
9913 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9914 sw_if_index_set = 1;
9915 else if (unformat (i, "enable"))
9917 else if (unformat (i, "disable"))
9921 clib_warning ("parse error '%U'", format_unformat_error, i);
9926 if (sw_if_index_set == 0)
9928 errmsg ("missing interface name or sw_if_index");
9932 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
9934 mp->sw_if_index = ntohl (sw_if_index);
9935 mp->enable = enable;
9943 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
9945 unformat_input_t *i = vam->input;
9946 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
9948 u8 sw_if_index_set = 0;
9949 u8 v6_address_set = 0;
9950 ip6_address_t v6address;
9953 /* Parse args required to build the message */
9954 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9956 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9957 sw_if_index_set = 1;
9958 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9959 sw_if_index_set = 1;
9960 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
9966 if (sw_if_index_set == 0)
9968 errmsg ("missing interface name or sw_if_index");
9971 if (!v6_address_set)
9973 errmsg ("no address set");
9977 /* Construct the API message */
9978 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
9980 mp->sw_if_index = ntohl (sw_if_index);
9981 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9986 /* Wait for a reply, return good/bad news */
9992 api_ip6nd_proxy_add_del (vat_main_t * vam)
9994 unformat_input_t *i = vam->input;
9995 vl_api_ip6nd_proxy_add_del_t *mp;
9996 u32 sw_if_index = ~0;
9997 u8 v6_address_set = 0;
9998 ip6_address_t v6address;
10002 /* Parse args required to build the message */
10003 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10005 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10007 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10009 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10010 v6_address_set = 1;
10011 if (unformat (i, "del"))
10015 clib_warning ("parse error '%U'", format_unformat_error, i);
10020 if (sw_if_index == ~0)
10022 errmsg ("missing interface name or sw_if_index");
10025 if (!v6_address_set)
10027 errmsg ("no address set");
10031 /* Construct the API message */
10032 M (IP6ND_PROXY_ADD_DEL, mp);
10034 mp->is_del = is_del;
10035 mp->sw_if_index = ntohl (sw_if_index);
10036 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10041 /* Wait for a reply, return good/bad news */
10047 api_ip6nd_proxy_dump (vat_main_t * vam)
10049 vl_api_ip6nd_proxy_dump_t *mp;
10050 vl_api_control_ping_t *mp_ping;
10053 M (IP6ND_PROXY_DUMP, mp);
10057 /* Use a control ping for synchronization */
10058 MPING (CONTROL_PING, mp_ping);
10065 static void vl_api_ip6nd_proxy_details_t_handler
10066 (vl_api_ip6nd_proxy_details_t * mp)
10068 vat_main_t *vam = &vat_main;
10070 print (vam->ofp, "host %U sw_if_index %d",
10071 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
10074 static void vl_api_ip6nd_proxy_details_t_handler_json
10075 (vl_api_ip6nd_proxy_details_t * mp)
10077 vat_main_t *vam = &vat_main;
10078 struct in6_addr ip6;
10079 vat_json_node_t *node = NULL;
10081 if (VAT_JSON_ARRAY != vam->json_tree.type)
10083 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10084 vat_json_init_array (&vam->json_tree);
10086 node = vat_json_array_add (&vam->json_tree);
10088 vat_json_init_object (node);
10089 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10091 clib_memcpy (&ip6, mp->address, sizeof (ip6));
10092 vat_json_object_add_ip6 (node, "host", ip6);
10096 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
10098 unformat_input_t *i = vam->input;
10099 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
10101 u8 sw_if_index_set = 0;
10102 u32 address_length = 0;
10103 u8 v6_address_set = 0;
10104 ip6_address_t v6address;
10105 u8 use_default = 0;
10106 u8 no_advertise = 0;
10108 u8 no_autoconfig = 0;
10111 u32 val_lifetime = 0;
10112 u32 pref_lifetime = 0;
10115 /* Parse args required to build the message */
10116 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10118 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10119 sw_if_index_set = 1;
10120 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10121 sw_if_index_set = 1;
10122 else if (unformat (i, "%U/%d",
10123 unformat_ip6_address, &v6address, &address_length))
10124 v6_address_set = 1;
10125 else if (unformat (i, "val_life %d", &val_lifetime))
10127 else if (unformat (i, "pref_life %d", &pref_lifetime))
10129 else if (unformat (i, "def"))
10131 else if (unformat (i, "noadv"))
10133 else if (unformat (i, "offl"))
10135 else if (unformat (i, "noauto"))
10137 else if (unformat (i, "nolink"))
10139 else if (unformat (i, "isno"))
10143 clib_warning ("parse error '%U'", format_unformat_error, i);
10148 if (sw_if_index_set == 0)
10150 errmsg ("missing interface name or sw_if_index");
10153 if (!v6_address_set)
10155 errmsg ("no address set");
10159 /* Construct the API message */
10160 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
10162 mp->sw_if_index = ntohl (sw_if_index);
10163 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10164 mp->address_length = address_length;
10165 mp->use_default = use_default;
10166 mp->no_advertise = no_advertise;
10167 mp->off_link = off_link;
10168 mp->no_autoconfig = no_autoconfig;
10169 mp->no_onlink = no_onlink;
10171 mp->val_lifetime = ntohl (val_lifetime);
10172 mp->pref_lifetime = ntohl (pref_lifetime);
10177 /* Wait for a reply, return good/bad news */
10183 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
10185 unformat_input_t *i = vam->input;
10186 vl_api_sw_interface_ip6nd_ra_config_t *mp;
10188 u8 sw_if_index_set = 0;
10193 u8 send_unicast = 0;
10196 u8 default_router = 0;
10197 u32 max_interval = 0;
10198 u32 min_interval = 0;
10200 u32 initial_count = 0;
10201 u32 initial_interval = 0;
10205 /* Parse args required to build the message */
10206 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10208 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10209 sw_if_index_set = 1;
10210 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10211 sw_if_index_set = 1;
10212 else if (unformat (i, "maxint %d", &max_interval))
10214 else if (unformat (i, "minint %d", &min_interval))
10216 else if (unformat (i, "life %d", &lifetime))
10218 else if (unformat (i, "count %d", &initial_count))
10220 else if (unformat (i, "interval %d", &initial_interval))
10222 else if (unformat (i, "suppress") || unformat (i, "surpress"))
10224 else if (unformat (i, "managed"))
10226 else if (unformat (i, "other"))
10228 else if (unformat (i, "ll"))
10230 else if (unformat (i, "send"))
10232 else if (unformat (i, "cease"))
10234 else if (unformat (i, "isno"))
10236 else if (unformat (i, "def"))
10237 default_router = 1;
10240 clib_warning ("parse error '%U'", format_unformat_error, i);
10245 if (sw_if_index_set == 0)
10247 errmsg ("missing interface name or sw_if_index");
10251 /* Construct the API message */
10252 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
10254 mp->sw_if_index = ntohl (sw_if_index);
10255 mp->max_interval = ntohl (max_interval);
10256 mp->min_interval = ntohl (min_interval);
10257 mp->lifetime = ntohl (lifetime);
10258 mp->initial_count = ntohl (initial_count);
10259 mp->initial_interval = ntohl (initial_interval);
10260 mp->suppress = suppress;
10261 mp->managed = managed;
10263 mp->ll_option = ll_option;
10264 mp->send_unicast = send_unicast;
10267 mp->default_router = default_router;
10272 /* Wait for a reply, return good/bad news */
10278 api_set_arp_neighbor_limit (vat_main_t * vam)
10280 unformat_input_t *i = vam->input;
10281 vl_api_set_arp_neighbor_limit_t *mp;
10287 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10289 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
10291 else if (unformat (i, "ipv6"))
10295 clib_warning ("parse error '%U'", format_unformat_error, i);
10300 if (limit_set == 0)
10302 errmsg ("missing limit value");
10306 M (SET_ARP_NEIGHBOR_LIMIT, mp);
10308 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
10309 mp->is_ipv6 = is_ipv6;
10317 api_l2_patch_add_del (vat_main_t * vam)
10319 unformat_input_t *i = vam->input;
10320 vl_api_l2_patch_add_del_t *mp;
10321 u32 rx_sw_if_index;
10322 u8 rx_sw_if_index_set = 0;
10323 u32 tx_sw_if_index;
10324 u8 tx_sw_if_index_set = 0;
10328 /* Parse args required to build the message */
10329 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10331 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
10332 rx_sw_if_index_set = 1;
10333 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
10334 tx_sw_if_index_set = 1;
10335 else if (unformat (i, "rx"))
10337 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10339 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10341 rx_sw_if_index_set = 1;
10346 else if (unformat (i, "tx"))
10348 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10350 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10352 tx_sw_if_index_set = 1;
10357 else if (unformat (i, "del"))
10363 if (rx_sw_if_index_set == 0)
10365 errmsg ("missing rx interface name or rx_sw_if_index");
10369 if (tx_sw_if_index_set == 0)
10371 errmsg ("missing tx interface name or tx_sw_if_index");
10375 M (L2_PATCH_ADD_DEL, mp);
10377 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
10378 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
10379 mp->is_add = is_add;
10387 u8 localsid_addr[16];
10396 api_sr_localsid_add_del (vat_main_t * vam)
10398 unformat_input_t *i = vam->input;
10399 vl_api_sr_localsid_add_del_t *mp;
10402 ip6_address_t localsid;
10406 u32 fib_table = ~(u32) 0;
10407 ip6_address_t next_hop;
10409 bool nexthop_set = 0;
10413 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10415 if (unformat (i, "del"))
10417 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
10418 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
10420 else if (unformat (i, "behavior %u", &behavior));
10421 else if (unformat (i, "sw_if_index %u", &sw_if_index));
10422 else if (unformat (i, "fib-table %u", &fib_table));
10423 else if (unformat (i, "end.psp %u", &behavior));
10428 M (SR_LOCALSID_ADD_DEL, mp);
10430 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
10432 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
10433 mp->behavior = behavior;
10434 mp->sw_if_index = ntohl (sw_if_index);
10435 mp->fib_table = ntohl (fib_table);
10436 mp->end_psp = end_psp;
10437 mp->is_del = is_del;
10445 api_ioam_enable (vat_main_t * vam)
10447 unformat_input_t *input = vam->input;
10448 vl_api_ioam_enable_t *mp;
10450 int has_trace_option = 0;
10451 int has_pot_option = 0;
10452 int has_seqno_option = 0;
10453 int has_analyse_option = 0;
10456 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10458 if (unformat (input, "trace"))
10459 has_trace_option = 1;
10460 else if (unformat (input, "pot"))
10461 has_pot_option = 1;
10462 else if (unformat (input, "seqno"))
10463 has_seqno_option = 1;
10464 else if (unformat (input, "analyse"))
10465 has_analyse_option = 1;
10469 M (IOAM_ENABLE, mp);
10470 mp->id = htons (id);
10471 mp->seqno = has_seqno_option;
10472 mp->analyse = has_analyse_option;
10473 mp->pot_enable = has_pot_option;
10474 mp->trace_enable = has_trace_option;
10483 api_ioam_disable (vat_main_t * vam)
10485 vl_api_ioam_disable_t *mp;
10488 M (IOAM_DISABLE, mp);
10494 #define foreach_tcp_proto_field \
10498 #define foreach_udp_proto_field \
10502 #define foreach_ip4_proto_field \
10514 u16 src_port, dst_port;
10517 #if VPP_API_TEST_BUILTIN == 0
10519 unformat_tcp_mask (unformat_input_t * input, va_list * args)
10521 u8 **maskp = va_arg (*args, u8 **);
10523 u8 found_something = 0;
10526 #define _(a) u8 a=0;
10527 foreach_tcp_proto_field;
10530 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10533 #define _(a) else if (unformat (input, #a)) a=1;
10534 foreach_tcp_proto_field
10540 #define _(a) found_something += a;
10541 foreach_tcp_proto_field;
10544 if (found_something == 0)
10547 vec_validate (mask, sizeof (*tcp) - 1);
10549 tcp = (tcp_header_t *) mask;
10551 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
10552 foreach_tcp_proto_field;
10560 unformat_udp_mask (unformat_input_t * input, va_list * args)
10562 u8 **maskp = va_arg (*args, u8 **);
10564 u8 found_something = 0;
10567 #define _(a) u8 a=0;
10568 foreach_udp_proto_field;
10571 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10574 #define _(a) else if (unformat (input, #a)) a=1;
10575 foreach_udp_proto_field
10581 #define _(a) found_something += a;
10582 foreach_udp_proto_field;
10585 if (found_something == 0)
10588 vec_validate (mask, sizeof (*udp) - 1);
10590 udp = (udp_header_t *) mask;
10592 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
10593 foreach_udp_proto_field;
10601 unformat_l4_mask (unformat_input_t * input, va_list * args)
10603 u8 **maskp = va_arg (*args, u8 **);
10604 u16 src_port = 0, dst_port = 0;
10605 tcpudp_header_t *tcpudp;
10607 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10609 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
10611 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
10613 else if (unformat (input, "src_port"))
10615 else if (unformat (input, "dst_port"))
10621 if (!src_port && !dst_port)
10625 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
10627 tcpudp = (tcpudp_header_t *) mask;
10628 tcpudp->src_port = src_port;
10629 tcpudp->dst_port = dst_port;
10637 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10639 u8 **maskp = va_arg (*args, u8 **);
10641 u8 found_something = 0;
10644 #define _(a) u8 a=0;
10645 foreach_ip4_proto_field;
10651 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10653 if (unformat (input, "version"))
10655 else if (unformat (input, "hdr_length"))
10657 else if (unformat (input, "src"))
10659 else if (unformat (input, "dst"))
10661 else if (unformat (input, "proto"))
10664 #define _(a) else if (unformat (input, #a)) a=1;
10665 foreach_ip4_proto_field
10671 #define _(a) found_something += a;
10672 foreach_ip4_proto_field;
10675 if (found_something == 0)
10678 vec_validate (mask, sizeof (*ip) - 1);
10680 ip = (ip4_header_t *) mask;
10682 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
10683 foreach_ip4_proto_field;
10686 ip->ip_version_and_header_length = 0;
10689 ip->ip_version_and_header_length |= 0xF0;
10692 ip->ip_version_and_header_length |= 0x0F;
10698 #define foreach_ip6_proto_field \
10701 _(payload_length) \
10706 unformat_ip6_mask (unformat_input_t * input, va_list * args)
10708 u8 **maskp = va_arg (*args, u8 **);
10710 u8 found_something = 0;
10712 u32 ip_version_traffic_class_and_flow_label;
10714 #define _(a) u8 a=0;
10715 foreach_ip6_proto_field;
10718 u8 traffic_class = 0;
10721 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10723 if (unformat (input, "version"))
10725 else if (unformat (input, "traffic-class"))
10727 else if (unformat (input, "flow-label"))
10729 else if (unformat (input, "src"))
10731 else if (unformat (input, "dst"))
10733 else if (unformat (input, "proto"))
10736 #define _(a) else if (unformat (input, #a)) a=1;
10737 foreach_ip6_proto_field
10743 #define _(a) found_something += a;
10744 foreach_ip6_proto_field;
10747 if (found_something == 0)
10750 vec_validate (mask, sizeof (*ip) - 1);
10752 ip = (ip6_header_t *) mask;
10754 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
10755 foreach_ip6_proto_field;
10758 ip_version_traffic_class_and_flow_label = 0;
10761 ip_version_traffic_class_and_flow_label |= 0xF0000000;
10764 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
10767 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
10769 ip->ip_version_traffic_class_and_flow_label =
10770 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10777 unformat_l3_mask (unformat_input_t * input, va_list * args)
10779 u8 **maskp = va_arg (*args, u8 **);
10781 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10783 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
10785 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
10794 unformat_l2_mask (unformat_input_t * input, va_list * args)
10796 u8 **maskp = va_arg (*args, u8 **);
10803 u8 ignore_tag1 = 0;
10804 u8 ignore_tag2 = 0;
10811 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10813 if (unformat (input, "src"))
10815 else if (unformat (input, "dst"))
10817 else if (unformat (input, "proto"))
10819 else if (unformat (input, "tag1"))
10821 else if (unformat (input, "tag2"))
10823 else if (unformat (input, "ignore-tag1"))
10825 else if (unformat (input, "ignore-tag2"))
10827 else if (unformat (input, "cos1"))
10829 else if (unformat (input, "cos2"))
10831 else if (unformat (input, "dot1q"))
10833 else if (unformat (input, "dot1ad"))
10838 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
10839 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10842 if (tag1 || ignore_tag1 || cos1 || dot1q)
10844 if (tag2 || ignore_tag2 || cos2 || dot1ad)
10847 vec_validate (mask, len - 1);
10850 memset (mask, 0xff, 6);
10853 memset (mask + 6, 0xff, 6);
10855 if (tag2 || dot1ad)
10857 /* inner vlan tag */
10866 mask[21] = mask[20] = 0xff;
10887 mask[16] = mask[17] = 0xff;
10897 mask[12] = mask[13] = 0xff;
10904 unformat_classify_mask (unformat_input_t * input, va_list * args)
10906 u8 **maskp = va_arg (*args, u8 **);
10907 u32 *skipp = va_arg (*args, u32 *);
10908 u32 *matchp = va_arg (*args, u32 *);
10916 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10918 if (unformat (input, "hex %U", unformat_hex_string, &mask))
10920 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
10922 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
10924 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
10938 if (mask || l2 || l3 || l4)
10940 if (l2 || l3 || l4)
10942 /* "With a free Ethernet header in every package" */
10944 vec_validate (l2, 13);
10948 vec_append (mask, l3);
10953 vec_append (mask, l4);
10958 /* Scan forward looking for the first significant mask octet */
10959 for (i = 0; i < vec_len (mask); i++)
10963 /* compute (skip, match) params */
10964 *skipp = i / sizeof (u32x4);
10965 vec_delete (mask, *skipp * sizeof (u32x4), 0);
10967 /* Pad mask to an even multiple of the vector size */
10968 while (vec_len (mask) % sizeof (u32x4))
10969 vec_add1 (mask, 0);
10971 match = vec_len (mask) / sizeof (u32x4);
10973 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
10975 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
10976 if (*tmp || *(tmp + 1))
10981 clib_warning ("BUG: match 0");
10983 _vec_len (mask) = match * sizeof (u32x4);
10993 #endif /* VPP_API_TEST_BUILTIN */
10995 #define foreach_l2_next \
10997 _(ethernet, ETHERNET_INPUT) \
10998 _(ip4, IP4_INPUT) \
11002 unformat_l2_next_index (unformat_input_t * input, va_list * args)
11004 u32 *miss_next_indexp = va_arg (*args, u32 *);
11005 u32 next_index = 0;
11009 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
11013 if (unformat (input, "%d", &tmp))
11022 *miss_next_indexp = next_index;
11026 #define foreach_ip_next \
11029 _(rewrite, REWRITE)
11032 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
11034 u32 *miss_next_indexp = va_arg (*args, u32 *);
11035 u32 next_index = 0;
11039 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
11043 if (unformat (input, "%d", &tmp))
11052 *miss_next_indexp = next_index;
11056 #define foreach_acl_next \
11060 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
11062 u32 *miss_next_indexp = va_arg (*args, u32 *);
11063 u32 next_index = 0;
11067 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
11071 if (unformat (input, "permit"))
11076 else if (unformat (input, "%d", &tmp))
11085 *miss_next_indexp = next_index;
11090 unformat_policer_precolor (unformat_input_t * input, va_list * args)
11092 u32 *r = va_arg (*args, u32 *);
11094 if (unformat (input, "conform-color"))
11095 *r = POLICE_CONFORM;
11096 else if (unformat (input, "exceed-color"))
11097 *r = POLICE_EXCEED;
11105 api_classify_add_del_table (vat_main_t * vam)
11107 unformat_input_t *i = vam->input;
11108 vl_api_classify_add_del_table_t *mp;
11115 u32 table_index = ~0;
11116 u32 next_table_index = ~0;
11117 u32 miss_next_index = ~0;
11118 u32 memory_size = 32 << 20;
11120 u32 current_data_flag = 0;
11121 int current_data_offset = 0;
11124 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11126 if (unformat (i, "del"))
11128 else if (unformat (i, "del-chain"))
11133 else if (unformat (i, "buckets %d", &nbuckets))
11135 else if (unformat (i, "memory_size %d", &memory_size))
11137 else if (unformat (i, "skip %d", &skip))
11139 else if (unformat (i, "match %d", &match))
11141 else if (unformat (i, "table %d", &table_index))
11143 else if (unformat (i, "mask %U", unformat_classify_mask,
11144 &mask, &skip, &match))
11146 else if (unformat (i, "next-table %d", &next_table_index))
11148 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
11151 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
11154 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
11157 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
11159 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
11165 if (is_add && mask == 0)
11167 errmsg ("Mask required");
11171 if (is_add && skip == ~0)
11173 errmsg ("skip count required");
11177 if (is_add && match == ~0)
11179 errmsg ("match count required");
11183 if (!is_add && table_index == ~0)
11185 errmsg ("table index required for delete");
11189 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
11191 mp->is_add = is_add;
11192 mp->del_chain = del_chain;
11193 mp->table_index = ntohl (table_index);
11194 mp->nbuckets = ntohl (nbuckets);
11195 mp->memory_size = ntohl (memory_size);
11196 mp->skip_n_vectors = ntohl (skip);
11197 mp->match_n_vectors = ntohl (match);
11198 mp->next_table_index = ntohl (next_table_index);
11199 mp->miss_next_index = ntohl (miss_next_index);
11200 mp->current_data_flag = ntohl (current_data_flag);
11201 mp->current_data_offset = ntohl (current_data_offset);
11202 clib_memcpy (mp->mask, mask, vec_len (mask));
11211 #if VPP_API_TEST_BUILTIN == 0
11213 unformat_l4_match (unformat_input_t * input, va_list * args)
11215 u8 **matchp = va_arg (*args, u8 **);
11217 u8 *proto_header = 0;
11223 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11225 if (unformat (input, "src_port %d", &src_port))
11227 else if (unformat (input, "dst_port %d", &dst_port))
11233 h.src_port = clib_host_to_net_u16 (src_port);
11234 h.dst_port = clib_host_to_net_u16 (dst_port);
11235 vec_validate (proto_header, sizeof (h) - 1);
11236 memcpy (proto_header, &h, sizeof (h));
11238 *matchp = proto_header;
11244 unformat_ip4_match (unformat_input_t * input, va_list * args)
11246 u8 **matchp = va_arg (*args, u8 **);
11251 int hdr_length = 0;
11252 u32 hdr_length_val;
11253 int src = 0, dst = 0;
11254 ip4_address_t src_val, dst_val;
11261 int fragment_id = 0;
11262 u32 fragment_id_val;
11268 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11270 if (unformat (input, "version %d", &version_val))
11272 else if (unformat (input, "hdr_length %d", &hdr_length_val))
11274 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
11276 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
11278 else if (unformat (input, "proto %d", &proto_val))
11280 else if (unformat (input, "tos %d", &tos_val))
11282 else if (unformat (input, "length %d", &length_val))
11284 else if (unformat (input, "fragment_id %d", &fragment_id_val))
11286 else if (unformat (input, "ttl %d", &ttl_val))
11288 else if (unformat (input, "checksum %d", &checksum_val))
11294 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
11295 + ttl + checksum == 0)
11299 * Aligned because we use the real comparison functions
11301 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11303 ip = (ip4_header_t *) match;
11305 /* These are realistically matched in practice */
11307 ip->src_address.as_u32 = src_val.as_u32;
11310 ip->dst_address.as_u32 = dst_val.as_u32;
11313 ip->protocol = proto_val;
11316 /* These are not, but they're included for completeness */
11318 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
11321 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
11327 ip->length = clib_host_to_net_u16 (length_val);
11333 ip->checksum = clib_host_to_net_u16 (checksum_val);
11340 unformat_ip6_match (unformat_input_t * input, va_list * args)
11342 u8 **matchp = va_arg (*args, u8 **);
11347 u8 traffic_class = 0;
11348 u32 traffic_class_val = 0;
11351 int src = 0, dst = 0;
11352 ip6_address_t src_val, dst_val;
11355 int payload_length = 0;
11356 u32 payload_length_val;
11359 u32 ip_version_traffic_class_and_flow_label;
11361 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11363 if (unformat (input, "version %d", &version_val))
11365 else if (unformat (input, "traffic_class %d", &traffic_class_val))
11367 else if (unformat (input, "flow_label %d", &flow_label_val))
11369 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
11371 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
11373 else if (unformat (input, "proto %d", &proto_val))
11375 else if (unformat (input, "payload_length %d", &payload_length_val))
11376 payload_length = 1;
11377 else if (unformat (input, "hop_limit %d", &hop_limit_val))
11383 if (version + traffic_class + flow_label + src + dst + proto +
11384 payload_length + hop_limit == 0)
11388 * Aligned because we use the real comparison functions
11390 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11392 ip = (ip6_header_t *) match;
11395 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
11398 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
11401 ip->protocol = proto_val;
11403 ip_version_traffic_class_and_flow_label = 0;
11406 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
11409 ip_version_traffic_class_and_flow_label |=
11410 (traffic_class_val & 0xFF) << 20;
11413 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
11415 ip->ip_version_traffic_class_and_flow_label =
11416 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11418 if (payload_length)
11419 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
11422 ip->hop_limit = hop_limit_val;
11429 unformat_l3_match (unformat_input_t * input, va_list * args)
11431 u8 **matchp = va_arg (*args, u8 **);
11433 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11435 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
11437 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
11446 unformat_vlan_tag (unformat_input_t * input, va_list * args)
11448 u8 *tagp = va_arg (*args, u8 *);
11451 if (unformat (input, "%d", &tag))
11453 tagp[0] = (tag >> 8) & 0x0F;
11454 tagp[1] = tag & 0xFF;
11462 unformat_l2_match (unformat_input_t * input, va_list * args)
11464 u8 **matchp = va_arg (*args, u8 **);
11477 u8 ignore_tag1 = 0;
11478 u8 ignore_tag2 = 0;
11484 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11486 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
11489 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
11491 else if (unformat (input, "proto %U",
11492 unformat_ethernet_type_host_byte_order, &proto_val))
11494 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
11496 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
11498 else if (unformat (input, "ignore-tag1"))
11500 else if (unformat (input, "ignore-tag2"))
11502 else if (unformat (input, "cos1 %d", &cos1_val))
11504 else if (unformat (input, "cos2 %d", &cos2_val))
11509 if ((src + dst + proto + tag1 + tag2 +
11510 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11513 if (tag1 || ignore_tag1 || cos1)
11515 if (tag2 || ignore_tag2 || cos2)
11518 vec_validate_aligned (match, len - 1, sizeof (u32x4));
11521 clib_memcpy (match, dst_val, 6);
11524 clib_memcpy (match + 6, src_val, 6);
11528 /* inner vlan tag */
11529 match[19] = tag2_val[1];
11530 match[18] = tag2_val[0];
11532 match[18] |= (cos2_val & 0x7) << 5;
11535 match[21] = proto_val & 0xff;
11536 match[20] = proto_val >> 8;
11540 match[15] = tag1_val[1];
11541 match[14] = tag1_val[0];
11544 match[14] |= (cos1_val & 0x7) << 5;
11550 match[15] = tag1_val[1];
11551 match[14] = tag1_val[0];
11554 match[17] = proto_val & 0xff;
11555 match[16] = proto_val >> 8;
11558 match[14] |= (cos1_val & 0x7) << 5;
11564 match[18] |= (cos2_val & 0x7) << 5;
11566 match[14] |= (cos1_val & 0x7) << 5;
11569 match[13] = proto_val & 0xff;
11570 match[12] = proto_val >> 8;
11579 api_unformat_classify_match (unformat_input_t * input, va_list * args)
11581 u8 **matchp = va_arg (*args, u8 **);
11582 u32 skip_n_vectors = va_arg (*args, u32);
11583 u32 match_n_vectors = va_arg (*args, u32);
11590 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11592 if (unformat (input, "hex %U", unformat_hex_string, &match))
11594 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
11596 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
11598 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11612 if (match || l2 || l3 || l4)
11614 if (l2 || l3 || l4)
11616 /* "Win a free Ethernet header in every packet" */
11618 vec_validate_aligned (l2, 13, sizeof (u32x4));
11622 vec_append_aligned (match, l3, sizeof (u32x4));
11627 vec_append_aligned (match, l4, sizeof (u32x4));
11632 /* Make sure the vector is big enough even if key is all 0's */
11633 vec_validate_aligned
11634 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11637 /* Set size, include skipped vectors */
11638 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11649 api_classify_add_del_session (vat_main_t * vam)
11651 unformat_input_t *i = vam->input;
11652 vl_api_classify_add_del_session_t *mp;
11654 u32 table_index = ~0;
11655 u32 hit_next_index = ~0;
11656 u32 opaque_index = ~0;
11659 u32 skip_n_vectors = 0;
11660 u32 match_n_vectors = 0;
11666 * Warning: you have to supply skip_n and match_n
11667 * because the API client cant simply look at the classify
11671 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11673 if (unformat (i, "del"))
11675 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
11678 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
11681 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
11684 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
11686 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
11688 else if (unformat (i, "opaque-index %d", &opaque_index))
11690 else if (unformat (i, "skip_n %d", &skip_n_vectors))
11692 else if (unformat (i, "match_n %d", &match_n_vectors))
11694 else if (unformat (i, "match %U", api_unformat_classify_match,
11695 &match, skip_n_vectors, match_n_vectors))
11697 else if (unformat (i, "advance %d", &advance))
11699 else if (unformat (i, "table-index %d", &table_index))
11701 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
11703 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
11705 else if (unformat (i, "action %d", &action))
11707 else if (unformat (i, "metadata %d", &metadata))
11713 if (table_index == ~0)
11715 errmsg ("Table index required");
11719 if (is_add && match == 0)
11721 errmsg ("Match value required");
11725 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
11727 mp->is_add = is_add;
11728 mp->table_index = ntohl (table_index);
11729 mp->hit_next_index = ntohl (hit_next_index);
11730 mp->opaque_index = ntohl (opaque_index);
11731 mp->advance = ntohl (advance);
11732 mp->action = action;
11733 mp->metadata = ntohl (metadata);
11734 clib_memcpy (mp->match, match, vec_len (match));
11743 api_classify_set_interface_ip_table (vat_main_t * vam)
11745 unformat_input_t *i = vam->input;
11746 vl_api_classify_set_interface_ip_table_t *mp;
11748 int sw_if_index_set;
11749 u32 table_index = ~0;
11753 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11755 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11756 sw_if_index_set = 1;
11757 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11758 sw_if_index_set = 1;
11759 else if (unformat (i, "table %d", &table_index))
11763 clib_warning ("parse error '%U'", format_unformat_error, i);
11768 if (sw_if_index_set == 0)
11770 errmsg ("missing interface name or sw_if_index");
11775 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
11777 mp->sw_if_index = ntohl (sw_if_index);
11778 mp->table_index = ntohl (table_index);
11779 mp->is_ipv6 = is_ipv6;
11787 api_classify_set_interface_l2_tables (vat_main_t * vam)
11789 unformat_input_t *i = vam->input;
11790 vl_api_classify_set_interface_l2_tables_t *mp;
11792 int sw_if_index_set;
11793 u32 ip4_table_index = ~0;
11794 u32 ip6_table_index = ~0;
11795 u32 other_table_index = ~0;
11799 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11801 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11802 sw_if_index_set = 1;
11803 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11804 sw_if_index_set = 1;
11805 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11807 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11809 else if (unformat (i, "other-table %d", &other_table_index))
11811 else if (unformat (i, "is-input %d", &is_input))
11815 clib_warning ("parse error '%U'", format_unformat_error, i);
11820 if (sw_if_index_set == 0)
11822 errmsg ("missing interface name or sw_if_index");
11827 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
11829 mp->sw_if_index = ntohl (sw_if_index);
11830 mp->ip4_table_index = ntohl (ip4_table_index);
11831 mp->ip6_table_index = ntohl (ip6_table_index);
11832 mp->other_table_index = ntohl (other_table_index);
11833 mp->is_input = (u8) is_input;
11841 api_set_ipfix_exporter (vat_main_t * vam)
11843 unformat_input_t *i = vam->input;
11844 vl_api_set_ipfix_exporter_t *mp;
11845 ip4_address_t collector_address;
11846 u8 collector_address_set = 0;
11847 u32 collector_port = ~0;
11848 ip4_address_t src_address;
11849 u8 src_address_set = 0;
11852 u32 template_interval = ~0;
11853 u8 udp_checksum = 0;
11856 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11858 if (unformat (i, "collector_address %U", unformat_ip4_address,
11859 &collector_address))
11860 collector_address_set = 1;
11861 else if (unformat (i, "collector_port %d", &collector_port))
11863 else if (unformat (i, "src_address %U", unformat_ip4_address,
11865 src_address_set = 1;
11866 else if (unformat (i, "vrf_id %d", &vrf_id))
11868 else if (unformat (i, "path_mtu %d", &path_mtu))
11870 else if (unformat (i, "template_interval %d", &template_interval))
11872 else if (unformat (i, "udp_checksum"))
11878 if (collector_address_set == 0)
11880 errmsg ("collector_address required");
11884 if (src_address_set == 0)
11886 errmsg ("src_address required");
11890 M (SET_IPFIX_EXPORTER, mp);
11892 memcpy (mp->collector_address, collector_address.data,
11893 sizeof (collector_address.data));
11894 mp->collector_port = htons ((u16) collector_port);
11895 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
11896 mp->vrf_id = htonl (vrf_id);
11897 mp->path_mtu = htonl (path_mtu);
11898 mp->template_interval = htonl (template_interval);
11899 mp->udp_checksum = udp_checksum;
11907 api_set_ipfix_classify_stream (vat_main_t * vam)
11909 unformat_input_t *i = vam->input;
11910 vl_api_set_ipfix_classify_stream_t *mp;
11912 u32 src_port = UDP_DST_PORT_ipfix;
11915 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11917 if (unformat (i, "domain %d", &domain_id))
11919 else if (unformat (i, "src_port %d", &src_port))
11923 errmsg ("unknown input `%U'", format_unformat_error, i);
11928 M (SET_IPFIX_CLASSIFY_STREAM, mp);
11930 mp->domain_id = htonl (domain_id);
11931 mp->src_port = htons ((u16) src_port);
11939 api_ipfix_classify_table_add_del (vat_main_t * vam)
11941 unformat_input_t *i = vam->input;
11942 vl_api_ipfix_classify_table_add_del_t *mp;
11944 u32 classify_table_index = ~0;
11946 u8 transport_protocol = 255;
11949 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11951 if (unformat (i, "add"))
11953 else if (unformat (i, "del"))
11955 else if (unformat (i, "table %d", &classify_table_index))
11957 else if (unformat (i, "ip4"))
11959 else if (unformat (i, "ip6"))
11961 else if (unformat (i, "tcp"))
11962 transport_protocol = 6;
11963 else if (unformat (i, "udp"))
11964 transport_protocol = 17;
11967 errmsg ("unknown input `%U'", format_unformat_error, i);
11974 errmsg ("expecting: add|del");
11977 if (classify_table_index == ~0)
11979 errmsg ("classifier table not specified");
11982 if (ip_version == 0)
11984 errmsg ("IP version not specified");
11988 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
11990 mp->is_add = is_add;
11991 mp->table_id = htonl (classify_table_index);
11992 mp->ip_version = ip_version;
11993 mp->transport_protocol = transport_protocol;
12001 api_get_node_index (vat_main_t * vam)
12003 unformat_input_t *i = vam->input;
12004 vl_api_get_node_index_t *mp;
12008 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12010 if (unformat (i, "node %s", &name))
12017 errmsg ("node name required");
12020 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12022 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12026 M (GET_NODE_INDEX, mp);
12027 clib_memcpy (mp->node_name, name, vec_len (name));
12036 api_get_next_index (vat_main_t * vam)
12038 unformat_input_t *i = vam->input;
12039 vl_api_get_next_index_t *mp;
12040 u8 *node_name = 0, *next_node_name = 0;
12043 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12045 if (unformat (i, "node-name %s", &node_name))
12047 else if (unformat (i, "next-node-name %s", &next_node_name))
12051 if (node_name == 0)
12053 errmsg ("node name required");
12056 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
12058 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12062 if (next_node_name == 0)
12064 errmsg ("next node name required");
12067 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
12069 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
12073 M (GET_NEXT_INDEX, mp);
12074 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
12075 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
12076 vec_free (node_name);
12077 vec_free (next_node_name);
12085 api_add_node_next (vat_main_t * vam)
12087 unformat_input_t *i = vam->input;
12088 vl_api_add_node_next_t *mp;
12093 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12095 if (unformat (i, "node %s", &name))
12097 else if (unformat (i, "next %s", &next))
12104 errmsg ("node name required");
12107 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12109 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12114 errmsg ("next node required");
12117 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
12119 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
12123 M (ADD_NODE_NEXT, mp);
12124 clib_memcpy (mp->node_name, name, vec_len (name));
12125 clib_memcpy (mp->next_name, next, vec_len (next));
12135 api_l2tpv3_create_tunnel (vat_main_t * vam)
12137 unformat_input_t *i = vam->input;
12138 ip6_address_t client_address, our_address;
12139 int client_address_set = 0;
12140 int our_address_set = 0;
12141 u32 local_session_id = 0;
12142 u32 remote_session_id = 0;
12143 u64 local_cookie = 0;
12144 u64 remote_cookie = 0;
12145 u8 l2_sublayer_present = 0;
12146 vl_api_l2tpv3_create_tunnel_t *mp;
12149 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12151 if (unformat (i, "client_address %U", unformat_ip6_address,
12153 client_address_set = 1;
12154 else if (unformat (i, "our_address %U", unformat_ip6_address,
12156 our_address_set = 1;
12157 else if (unformat (i, "local_session_id %d", &local_session_id))
12159 else if (unformat (i, "remote_session_id %d", &remote_session_id))
12161 else if (unformat (i, "local_cookie %lld", &local_cookie))
12163 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
12165 else if (unformat (i, "l2-sublayer-present"))
12166 l2_sublayer_present = 1;
12171 if (client_address_set == 0)
12173 errmsg ("client_address required");
12177 if (our_address_set == 0)
12179 errmsg ("our_address required");
12183 M (L2TPV3_CREATE_TUNNEL, mp);
12185 clib_memcpy (mp->client_address, client_address.as_u8,
12186 sizeof (mp->client_address));
12188 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
12190 mp->local_session_id = ntohl (local_session_id);
12191 mp->remote_session_id = ntohl (remote_session_id);
12192 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
12193 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
12194 mp->l2_sublayer_present = l2_sublayer_present;
12203 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
12205 unformat_input_t *i = vam->input;
12207 u8 sw_if_index_set = 0;
12208 u64 new_local_cookie = 0;
12209 u64 new_remote_cookie = 0;
12210 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
12213 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12215 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12216 sw_if_index_set = 1;
12217 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12218 sw_if_index_set = 1;
12219 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
12221 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
12227 if (sw_if_index_set == 0)
12229 errmsg ("missing interface name or sw_if_index");
12233 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
12235 mp->sw_if_index = ntohl (sw_if_index);
12236 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
12237 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
12245 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
12247 unformat_input_t *i = vam->input;
12248 vl_api_l2tpv3_interface_enable_disable_t *mp;
12250 u8 sw_if_index_set = 0;
12251 u8 enable_disable = 1;
12254 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12256 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12257 sw_if_index_set = 1;
12258 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12259 sw_if_index_set = 1;
12260 else if (unformat (i, "enable"))
12261 enable_disable = 1;
12262 else if (unformat (i, "disable"))
12263 enable_disable = 0;
12268 if (sw_if_index_set == 0)
12270 errmsg ("missing interface name or sw_if_index");
12274 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
12276 mp->sw_if_index = ntohl (sw_if_index);
12277 mp->enable_disable = enable_disable;
12285 api_l2tpv3_set_lookup_key (vat_main_t * vam)
12287 unformat_input_t *i = vam->input;
12288 vl_api_l2tpv3_set_lookup_key_t *mp;
12292 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12294 if (unformat (i, "lookup_v6_src"))
12295 key = L2T_LOOKUP_SRC_ADDRESS;
12296 else if (unformat (i, "lookup_v6_dst"))
12297 key = L2T_LOOKUP_DST_ADDRESS;
12298 else if (unformat (i, "lookup_session_id"))
12299 key = L2T_LOOKUP_SESSION_ID;
12304 if (key == (u8) ~ 0)
12306 errmsg ("l2tp session lookup key unset");
12310 M (L2TPV3_SET_LOOKUP_KEY, mp);
12319 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
12320 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12322 vat_main_t *vam = &vat_main;
12324 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
12325 format_ip6_address, mp->our_address,
12326 format_ip6_address, mp->client_address,
12327 clib_net_to_host_u32 (mp->sw_if_index));
12330 " local cookies %016llx %016llx remote cookie %016llx",
12331 clib_net_to_host_u64 (mp->local_cookie[0]),
12332 clib_net_to_host_u64 (mp->local_cookie[1]),
12333 clib_net_to_host_u64 (mp->remote_cookie));
12335 print (vam->ofp, " local session-id %d remote session-id %d",
12336 clib_net_to_host_u32 (mp->local_session_id),
12337 clib_net_to_host_u32 (mp->remote_session_id));
12339 print (vam->ofp, " l2 specific sublayer %s\n",
12340 mp->l2_sublayer_present ? "preset" : "absent");
12344 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
12345 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12347 vat_main_t *vam = &vat_main;
12348 vat_json_node_t *node = NULL;
12349 struct in6_addr addr;
12351 if (VAT_JSON_ARRAY != vam->json_tree.type)
12353 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12354 vat_json_init_array (&vam->json_tree);
12356 node = vat_json_array_add (&vam->json_tree);
12358 vat_json_init_object (node);
12360 clib_memcpy (&addr, mp->our_address, sizeof (addr));
12361 vat_json_object_add_ip6 (node, "our_address", addr);
12362 clib_memcpy (&addr, mp->client_address, sizeof (addr));
12363 vat_json_object_add_ip6 (node, "client_address", addr);
12365 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
12366 vat_json_init_array (lc);
12367 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
12368 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
12369 vat_json_object_add_uint (node, "remote_cookie",
12370 clib_net_to_host_u64 (mp->remote_cookie));
12372 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
12373 vat_json_object_add_uint (node, "local_session_id",
12374 clib_net_to_host_u32 (mp->local_session_id));
12375 vat_json_object_add_uint (node, "remote_session_id",
12376 clib_net_to_host_u32 (mp->remote_session_id));
12377 vat_json_object_add_string_copy (node, "l2_sublayer",
12378 mp->l2_sublayer_present ? (u8 *) "present"
12379 : (u8 *) "absent");
12383 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
12385 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
12386 vl_api_control_ping_t *mp_ping;
12389 /* Get list of l2tpv3-tunnel interfaces */
12390 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
12393 /* Use a control ping for synchronization */
12394 MPING (CONTROL_PING, mp_ping);
12402 static void vl_api_sw_interface_tap_details_t_handler
12403 (vl_api_sw_interface_tap_details_t * mp)
12405 vat_main_t *vam = &vat_main;
12407 print (vam->ofp, "%-16s %d",
12408 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
12411 static void vl_api_sw_interface_tap_details_t_handler_json
12412 (vl_api_sw_interface_tap_details_t * mp)
12414 vat_main_t *vam = &vat_main;
12415 vat_json_node_t *node = NULL;
12417 if (VAT_JSON_ARRAY != vam->json_tree.type)
12419 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12420 vat_json_init_array (&vam->json_tree);
12422 node = vat_json_array_add (&vam->json_tree);
12424 vat_json_init_object (node);
12425 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12426 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12430 api_sw_interface_tap_dump (vat_main_t * vam)
12432 vl_api_sw_interface_tap_dump_t *mp;
12433 vl_api_control_ping_t *mp_ping;
12436 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
12437 /* Get list of tap interfaces */
12438 M (SW_INTERFACE_TAP_DUMP, mp);
12441 /* Use a control ping for synchronization */
12442 MPING (CONTROL_PING, mp_ping);
12449 static void vl_api_sw_interface_tap_v2_details_t_handler
12450 (vl_api_sw_interface_tap_v2_details_t * mp)
12452 vat_main_t *vam = &vat_main;
12454 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
12455 mp->host_ip4_prefix_len);
12456 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
12457 mp->host_ip6_prefix_len);
12460 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s",
12461 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
12462 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12463 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
12464 mp->host_bridge, ip4, ip6);
12470 static void vl_api_sw_interface_tap_v2_details_t_handler_json
12471 (vl_api_sw_interface_tap_v2_details_t * mp)
12473 vat_main_t *vam = &vat_main;
12474 vat_json_node_t *node = NULL;
12476 if (VAT_JSON_ARRAY != vam->json_tree.type)
12478 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12479 vat_json_init_array (&vam->json_tree);
12481 node = vat_json_array_add (&vam->json_tree);
12483 vat_json_init_object (node);
12484 vat_json_object_add_uint (node, "id", ntohl (mp->id));
12485 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12486 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12487 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12488 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12489 vat_json_object_add_string_copy (node, "host_mac_addr",
12490 format (0, "%U", format_ethernet_address,
12491 &mp->host_mac_addr));
12492 vat_json_object_add_string_copy (node, "host_namespace",
12493 mp->host_namespace);
12494 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
12495 vat_json_object_add_string_copy (node, "host_ip4_addr",
12496 format (0, "%U/%d", format_ip4_address,
12498 mp->host_ip4_prefix_len));
12499 vat_json_object_add_string_copy (node, "host_ip6_addr",
12500 format (0, "%U/%d", format_ip6_address,
12502 mp->host_ip6_prefix_len));
12507 api_sw_interface_tap_v2_dump (vat_main_t * vam)
12509 vl_api_sw_interface_tap_v2_dump_t *mp;
12510 vl_api_control_ping_t *mp_ping;
12514 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
12515 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
12516 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
12519 /* Get list of tap interfaces */
12520 M (SW_INTERFACE_TAP_V2_DUMP, mp);
12523 /* Use a control ping for synchronization */
12524 MPING (CONTROL_PING, mp_ping);
12531 static uword unformat_vxlan_decap_next
12532 (unformat_input_t * input, va_list * args)
12534 u32 *result = va_arg (*args, u32 *);
12537 if (unformat (input, "l2"))
12538 *result = VXLAN_INPUT_NEXT_L2_INPUT;
12539 else if (unformat (input, "%d", &tmp))
12547 api_vxlan_add_del_tunnel (vat_main_t * vam)
12549 unformat_input_t *line_input = vam->input;
12550 vl_api_vxlan_add_del_tunnel_t *mp;
12551 ip46_address_t src, dst;
12553 u8 ipv4_set = 0, ipv6_set = 0;
12557 u32 mcast_sw_if_index = ~0;
12558 u32 encap_vrf_id = 0;
12559 u32 decap_next_index = ~0;
12563 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12564 memset (&src, 0, sizeof src);
12565 memset (&dst, 0, sizeof dst);
12567 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12569 if (unformat (line_input, "del"))
12572 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12578 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12584 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12590 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12595 else if (unformat (line_input, "group %U %U",
12596 unformat_ip4_address, &dst.ip4,
12597 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12599 grp_set = dst_set = 1;
12602 else if (unformat (line_input, "group %U",
12603 unformat_ip4_address, &dst.ip4))
12605 grp_set = dst_set = 1;
12608 else if (unformat (line_input, "group %U %U",
12609 unformat_ip6_address, &dst.ip6,
12610 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12612 grp_set = dst_set = 1;
12615 else if (unformat (line_input, "group %U",
12616 unformat_ip6_address, &dst.ip6))
12618 grp_set = dst_set = 1;
12622 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12624 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12626 else if (unformat (line_input, "decap-next %U",
12627 unformat_vxlan_decap_next, &decap_next_index))
12629 else if (unformat (line_input, "vni %d", &vni))
12633 errmsg ("parse error '%U'", format_unformat_error, line_input);
12640 errmsg ("tunnel src address not specified");
12645 errmsg ("tunnel dst address not specified");
12649 if (grp_set && !ip46_address_is_multicast (&dst))
12651 errmsg ("tunnel group address not multicast");
12654 if (grp_set && mcast_sw_if_index == ~0)
12656 errmsg ("tunnel nonexistent multicast device");
12659 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12661 errmsg ("tunnel dst address must be unicast");
12666 if (ipv4_set && ipv6_set)
12668 errmsg ("both IPv4 and IPv6 addresses specified");
12672 if ((vni == 0) || (vni >> 24))
12674 errmsg ("vni not specified or out of range");
12678 M (VXLAN_ADD_DEL_TUNNEL, mp);
12682 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
12683 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
12687 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
12688 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
12690 mp->encap_vrf_id = ntohl (encap_vrf_id);
12691 mp->decap_next_index = ntohl (decap_next_index);
12692 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12693 mp->vni = ntohl (vni);
12694 mp->is_add = is_add;
12695 mp->is_ipv6 = ipv6_set;
12702 static void vl_api_vxlan_tunnel_details_t_handler
12703 (vl_api_vxlan_tunnel_details_t * mp)
12705 vat_main_t *vam = &vat_main;
12706 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12707 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12709 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12710 ntohl (mp->sw_if_index),
12711 format_ip46_address, &src, IP46_TYPE_ANY,
12712 format_ip46_address, &dst, IP46_TYPE_ANY,
12713 ntohl (mp->encap_vrf_id),
12714 ntohl (mp->decap_next_index), ntohl (mp->vni),
12715 ntohl (mp->mcast_sw_if_index));
12718 static void vl_api_vxlan_tunnel_details_t_handler_json
12719 (vl_api_vxlan_tunnel_details_t * mp)
12721 vat_main_t *vam = &vat_main;
12722 vat_json_node_t *node = NULL;
12724 if (VAT_JSON_ARRAY != vam->json_tree.type)
12726 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12727 vat_json_init_array (&vam->json_tree);
12729 node = vat_json_array_add (&vam->json_tree);
12731 vat_json_init_object (node);
12732 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12735 struct in6_addr ip6;
12737 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12738 vat_json_object_add_ip6 (node, "src_address", ip6);
12739 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12740 vat_json_object_add_ip6 (node, "dst_address", ip6);
12744 struct in_addr ip4;
12746 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12747 vat_json_object_add_ip4 (node, "src_address", ip4);
12748 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12749 vat_json_object_add_ip4 (node, "dst_address", ip4);
12751 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12752 vat_json_object_add_uint (node, "decap_next_index",
12753 ntohl (mp->decap_next_index));
12754 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12755 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12756 vat_json_object_add_uint (node, "mcast_sw_if_index",
12757 ntohl (mp->mcast_sw_if_index));
12761 api_vxlan_tunnel_dump (vat_main_t * vam)
12763 unformat_input_t *i = vam->input;
12764 vl_api_vxlan_tunnel_dump_t *mp;
12765 vl_api_control_ping_t *mp_ping;
12767 u8 sw_if_index_set = 0;
12770 /* Parse args required to build the message */
12771 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12773 if (unformat (i, "sw_if_index %d", &sw_if_index))
12774 sw_if_index_set = 1;
12779 if (sw_if_index_set == 0)
12784 if (!vam->json_output)
12786 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12787 "sw_if_index", "src_address", "dst_address",
12788 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12791 /* Get list of vxlan-tunnel interfaces */
12792 M (VXLAN_TUNNEL_DUMP, mp);
12794 mp->sw_if_index = htonl (sw_if_index);
12798 /* Use a control ping for synchronization */
12799 MPING (CONTROL_PING, mp_ping);
12806 static uword unformat_geneve_decap_next
12807 (unformat_input_t * input, va_list * args)
12809 u32 *result = va_arg (*args, u32 *);
12812 if (unformat (input, "l2"))
12813 *result = GENEVE_INPUT_NEXT_L2_INPUT;
12814 else if (unformat (input, "%d", &tmp))
12822 api_geneve_add_del_tunnel (vat_main_t * vam)
12824 unformat_input_t *line_input = vam->input;
12825 vl_api_geneve_add_del_tunnel_t *mp;
12826 ip46_address_t src, dst;
12828 u8 ipv4_set = 0, ipv6_set = 0;
12832 u32 mcast_sw_if_index = ~0;
12833 u32 encap_vrf_id = 0;
12834 u32 decap_next_index = ~0;
12838 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12839 memset (&src, 0, sizeof src);
12840 memset (&dst, 0, sizeof dst);
12842 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12844 if (unformat (line_input, "del"))
12847 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12853 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12859 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12865 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12870 else if (unformat (line_input, "group %U %U",
12871 unformat_ip4_address, &dst.ip4,
12872 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12874 grp_set = dst_set = 1;
12877 else if (unformat (line_input, "group %U",
12878 unformat_ip4_address, &dst.ip4))
12880 grp_set = dst_set = 1;
12883 else if (unformat (line_input, "group %U %U",
12884 unformat_ip6_address, &dst.ip6,
12885 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12887 grp_set = dst_set = 1;
12890 else if (unformat (line_input, "group %U",
12891 unformat_ip6_address, &dst.ip6))
12893 grp_set = dst_set = 1;
12897 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12899 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12901 else if (unformat (line_input, "decap-next %U",
12902 unformat_geneve_decap_next, &decap_next_index))
12904 else if (unformat (line_input, "vni %d", &vni))
12908 errmsg ("parse error '%U'", format_unformat_error, line_input);
12915 errmsg ("tunnel src address not specified");
12920 errmsg ("tunnel dst address not specified");
12924 if (grp_set && !ip46_address_is_multicast (&dst))
12926 errmsg ("tunnel group address not multicast");
12929 if (grp_set && mcast_sw_if_index == ~0)
12931 errmsg ("tunnel nonexistent multicast device");
12934 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12936 errmsg ("tunnel dst address must be unicast");
12941 if (ipv4_set && ipv6_set)
12943 errmsg ("both IPv4 and IPv6 addresses specified");
12947 if ((vni == 0) || (vni >> 24))
12949 errmsg ("vni not specified or out of range");
12953 M (GENEVE_ADD_DEL_TUNNEL, mp);
12957 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
12958 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
12962 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
12963 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
12965 mp->encap_vrf_id = ntohl (encap_vrf_id);
12966 mp->decap_next_index = ntohl (decap_next_index);
12967 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12968 mp->vni = ntohl (vni);
12969 mp->is_add = is_add;
12970 mp->is_ipv6 = ipv6_set;
12977 static void vl_api_geneve_tunnel_details_t_handler
12978 (vl_api_geneve_tunnel_details_t * mp)
12980 vat_main_t *vam = &vat_main;
12981 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12982 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12984 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12985 ntohl (mp->sw_if_index),
12986 format_ip46_address, &src, IP46_TYPE_ANY,
12987 format_ip46_address, &dst, IP46_TYPE_ANY,
12988 ntohl (mp->encap_vrf_id),
12989 ntohl (mp->decap_next_index), ntohl (mp->vni),
12990 ntohl (mp->mcast_sw_if_index));
12993 static void vl_api_geneve_tunnel_details_t_handler_json
12994 (vl_api_geneve_tunnel_details_t * mp)
12996 vat_main_t *vam = &vat_main;
12997 vat_json_node_t *node = NULL;
12999 if (VAT_JSON_ARRAY != vam->json_tree.type)
13001 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13002 vat_json_init_array (&vam->json_tree);
13004 node = vat_json_array_add (&vam->json_tree);
13006 vat_json_init_object (node);
13007 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13010 struct in6_addr ip6;
13012 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13013 vat_json_object_add_ip6 (node, "src_address", ip6);
13014 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13015 vat_json_object_add_ip6 (node, "dst_address", ip6);
13019 struct in_addr ip4;
13021 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13022 vat_json_object_add_ip4 (node, "src_address", ip4);
13023 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13024 vat_json_object_add_ip4 (node, "dst_address", ip4);
13026 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13027 vat_json_object_add_uint (node, "decap_next_index",
13028 ntohl (mp->decap_next_index));
13029 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13030 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13031 vat_json_object_add_uint (node, "mcast_sw_if_index",
13032 ntohl (mp->mcast_sw_if_index));
13036 api_geneve_tunnel_dump (vat_main_t * vam)
13038 unformat_input_t *i = vam->input;
13039 vl_api_geneve_tunnel_dump_t *mp;
13040 vl_api_control_ping_t *mp_ping;
13042 u8 sw_if_index_set = 0;
13045 /* Parse args required to build the message */
13046 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13048 if (unformat (i, "sw_if_index %d", &sw_if_index))
13049 sw_if_index_set = 1;
13054 if (sw_if_index_set == 0)
13059 if (!vam->json_output)
13061 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
13062 "sw_if_index", "local_address", "remote_address",
13063 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13066 /* Get list of geneve-tunnel interfaces */
13067 M (GENEVE_TUNNEL_DUMP, mp);
13069 mp->sw_if_index = htonl (sw_if_index);
13073 /* Use a control ping for synchronization */
13074 M (CONTROL_PING, mp_ping);
13082 api_gre_add_del_tunnel (vat_main_t * vam)
13084 unformat_input_t *line_input = vam->input;
13085 vl_api_gre_add_del_tunnel_t *mp;
13086 ip4_address_t src4, dst4;
13087 ip6_address_t src6, dst6;
13094 u32 outer_fib_id = 0;
13097 memset (&src4, 0, sizeof src4);
13098 memset (&dst4, 0, sizeof dst4);
13099 memset (&src6, 0, sizeof src6);
13100 memset (&dst6, 0, sizeof dst6);
13102 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13104 if (unformat (line_input, "del"))
13106 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
13111 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
13116 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
13121 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
13126 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
13128 else if (unformat (line_input, "teb"))
13132 errmsg ("parse error '%U'", format_unformat_error, line_input);
13139 errmsg ("tunnel src address not specified");
13144 errmsg ("tunnel dst address not specified");
13147 if (ipv4_set && ipv6_set)
13149 errmsg ("both IPv4 and IPv6 addresses specified");
13154 M (GRE_ADD_DEL_TUNNEL, mp);
13158 clib_memcpy (&mp->src_address, &src4, 4);
13159 clib_memcpy (&mp->dst_address, &dst4, 4);
13163 clib_memcpy (&mp->src_address, &src6, 16);
13164 clib_memcpy (&mp->dst_address, &dst6, 16);
13166 mp->outer_fib_id = ntohl (outer_fib_id);
13167 mp->is_add = is_add;
13169 mp->is_ipv6 = ipv6_set;
13176 static void vl_api_gre_tunnel_details_t_handler
13177 (vl_api_gre_tunnel_details_t * mp)
13179 vat_main_t *vam = &vat_main;
13180 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
13181 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
13183 print (vam->ofp, "%11d%24U%24U%6d%14d",
13184 ntohl (mp->sw_if_index),
13185 format_ip46_address, &src, IP46_TYPE_ANY,
13186 format_ip46_address, &dst, IP46_TYPE_ANY,
13187 mp->teb, ntohl (mp->outer_fib_id));
13190 static void vl_api_gre_tunnel_details_t_handler_json
13191 (vl_api_gre_tunnel_details_t * mp)
13193 vat_main_t *vam = &vat_main;
13194 vat_json_node_t *node = NULL;
13195 struct in_addr ip4;
13196 struct in6_addr ip6;
13198 if (VAT_JSON_ARRAY != vam->json_tree.type)
13200 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13201 vat_json_init_array (&vam->json_tree);
13203 node = vat_json_array_add (&vam->json_tree);
13205 vat_json_init_object (node);
13206 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13209 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
13210 vat_json_object_add_ip4 (node, "src_address", ip4);
13211 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
13212 vat_json_object_add_ip4 (node, "dst_address", ip4);
13216 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
13217 vat_json_object_add_ip6 (node, "src_address", ip6);
13218 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
13219 vat_json_object_add_ip6 (node, "dst_address", ip6);
13221 vat_json_object_add_uint (node, "teb", mp->teb);
13222 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
13223 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
13227 api_gre_tunnel_dump (vat_main_t * vam)
13229 unformat_input_t *i = vam->input;
13230 vl_api_gre_tunnel_dump_t *mp;
13231 vl_api_control_ping_t *mp_ping;
13233 u8 sw_if_index_set = 0;
13236 /* Parse args required to build the message */
13237 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13239 if (unformat (i, "sw_if_index %d", &sw_if_index))
13240 sw_if_index_set = 1;
13245 if (sw_if_index_set == 0)
13250 if (!vam->json_output)
13252 print (vam->ofp, "%11s%24s%24s%6s%14s",
13253 "sw_if_index", "src_address", "dst_address", "teb",
13257 /* Get list of gre-tunnel interfaces */
13258 M (GRE_TUNNEL_DUMP, mp);
13260 mp->sw_if_index = htonl (sw_if_index);
13264 /* Use a control ping for synchronization */
13265 MPING (CONTROL_PING, mp_ping);
13273 api_l2_fib_clear_table (vat_main_t * vam)
13275 // unformat_input_t * i = vam->input;
13276 vl_api_l2_fib_clear_table_t *mp;
13279 M (L2_FIB_CLEAR_TABLE, mp);
13287 api_l2_interface_efp_filter (vat_main_t * vam)
13289 unformat_input_t *i = vam->input;
13290 vl_api_l2_interface_efp_filter_t *mp;
13293 u8 sw_if_index_set = 0;
13296 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13298 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13299 sw_if_index_set = 1;
13300 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13301 sw_if_index_set = 1;
13302 else if (unformat (i, "enable"))
13304 else if (unformat (i, "disable"))
13308 clib_warning ("parse error '%U'", format_unformat_error, i);
13313 if (sw_if_index_set == 0)
13315 errmsg ("missing sw_if_index");
13319 M (L2_INTERFACE_EFP_FILTER, mp);
13321 mp->sw_if_index = ntohl (sw_if_index);
13322 mp->enable_disable = enable;
13329 #define foreach_vtr_op \
13330 _("disable", L2_VTR_DISABLED) \
13331 _("push-1", L2_VTR_PUSH_1) \
13332 _("push-2", L2_VTR_PUSH_2) \
13333 _("pop-1", L2_VTR_POP_1) \
13334 _("pop-2", L2_VTR_POP_2) \
13335 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
13336 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
13337 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
13338 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
13341 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
13343 unformat_input_t *i = vam->input;
13344 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
13346 u8 sw_if_index_set = 0;
13349 u32 push_dot1q = 1;
13354 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13356 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13357 sw_if_index_set = 1;
13358 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13359 sw_if_index_set = 1;
13360 else if (unformat (i, "vtr_op %d", &vtr_op))
13362 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
13365 else if (unformat (i, "push_dot1q %d", &push_dot1q))
13367 else if (unformat (i, "tag1 %d", &tag1))
13369 else if (unformat (i, "tag2 %d", &tag2))
13373 clib_warning ("parse error '%U'", format_unformat_error, i);
13378 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
13380 errmsg ("missing vtr operation or sw_if_index");
13384 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
13385 mp->sw_if_index = ntohl (sw_if_index);
13386 mp->vtr_op = ntohl (vtr_op);
13387 mp->push_dot1q = ntohl (push_dot1q);
13388 mp->tag1 = ntohl (tag1);
13389 mp->tag2 = ntohl (tag2);
13397 api_create_vhost_user_if (vat_main_t * vam)
13399 unformat_input_t *i = vam->input;
13400 vl_api_create_vhost_user_if_t *mp;
13403 u8 file_name_set = 0;
13404 u32 custom_dev_instance = ~0;
13406 u8 use_custom_mac = 0;
13410 /* Shut up coverity */
13411 memset (hwaddr, 0, sizeof (hwaddr));
13413 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13415 if (unformat (i, "socket %s", &file_name))
13419 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13421 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
13422 use_custom_mac = 1;
13423 else if (unformat (i, "server"))
13425 else if (unformat (i, "tag %s", &tag))
13431 if (file_name_set == 0)
13433 errmsg ("missing socket file name");
13437 if (vec_len (file_name) > 255)
13439 errmsg ("socket file name too long");
13442 vec_add1 (file_name, 0);
13444 M (CREATE_VHOST_USER_IF, mp);
13446 mp->is_server = is_server;
13447 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13448 vec_free (file_name);
13449 if (custom_dev_instance != ~0)
13452 mp->custom_dev_instance = ntohl (custom_dev_instance);
13454 mp->use_custom_mac = use_custom_mac;
13455 clib_memcpy (mp->mac_address, hwaddr, 6);
13457 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
13466 api_modify_vhost_user_if (vat_main_t * vam)
13468 unformat_input_t *i = vam->input;
13469 vl_api_modify_vhost_user_if_t *mp;
13472 u8 file_name_set = 0;
13473 u32 custom_dev_instance = ~0;
13474 u8 sw_if_index_set = 0;
13475 u32 sw_if_index = (u32) ~ 0;
13478 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13480 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13481 sw_if_index_set = 1;
13482 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13483 sw_if_index_set = 1;
13484 else if (unformat (i, "socket %s", &file_name))
13488 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13490 else if (unformat (i, "server"))
13496 if (sw_if_index_set == 0)
13498 errmsg ("missing sw_if_index or interface name");
13502 if (file_name_set == 0)
13504 errmsg ("missing socket file name");
13508 if (vec_len (file_name) > 255)
13510 errmsg ("socket file name too long");
13513 vec_add1 (file_name, 0);
13515 M (MODIFY_VHOST_USER_IF, mp);
13517 mp->sw_if_index = ntohl (sw_if_index);
13518 mp->is_server = is_server;
13519 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13520 vec_free (file_name);
13521 if (custom_dev_instance != ~0)
13524 mp->custom_dev_instance = ntohl (custom_dev_instance);
13533 api_delete_vhost_user_if (vat_main_t * vam)
13535 unformat_input_t *i = vam->input;
13536 vl_api_delete_vhost_user_if_t *mp;
13537 u32 sw_if_index = ~0;
13538 u8 sw_if_index_set = 0;
13541 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13543 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13544 sw_if_index_set = 1;
13545 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13546 sw_if_index_set = 1;
13551 if (sw_if_index_set == 0)
13553 errmsg ("missing sw_if_index or interface name");
13558 M (DELETE_VHOST_USER_IF, mp);
13560 mp->sw_if_index = ntohl (sw_if_index);
13567 static void vl_api_sw_interface_vhost_user_details_t_handler
13568 (vl_api_sw_interface_vhost_user_details_t * mp)
13570 vat_main_t *vam = &vat_main;
13572 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
13573 (char *) mp->interface_name,
13574 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
13575 clib_net_to_host_u64 (mp->features), mp->is_server,
13576 ntohl (mp->num_regions), (char *) mp->sock_filename);
13577 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
13580 static void vl_api_sw_interface_vhost_user_details_t_handler_json
13581 (vl_api_sw_interface_vhost_user_details_t * mp)
13583 vat_main_t *vam = &vat_main;
13584 vat_json_node_t *node = NULL;
13586 if (VAT_JSON_ARRAY != vam->json_tree.type)
13588 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13589 vat_json_init_array (&vam->json_tree);
13591 node = vat_json_array_add (&vam->json_tree);
13593 vat_json_init_object (node);
13594 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13595 vat_json_object_add_string_copy (node, "interface_name",
13596 mp->interface_name);
13597 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
13598 ntohl (mp->virtio_net_hdr_sz));
13599 vat_json_object_add_uint (node, "features",
13600 clib_net_to_host_u64 (mp->features));
13601 vat_json_object_add_uint (node, "is_server", mp->is_server);
13602 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
13603 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
13604 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
13608 api_sw_interface_vhost_user_dump (vat_main_t * vam)
13610 vl_api_sw_interface_vhost_user_dump_t *mp;
13611 vl_api_control_ping_t *mp_ping;
13614 "Interface name idx hdr_sz features server regions filename");
13616 /* Get list of vhost-user interfaces */
13617 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
13620 /* Use a control ping for synchronization */
13621 MPING (CONTROL_PING, mp_ping);
13629 api_show_version (vat_main_t * vam)
13631 vl_api_show_version_t *mp;
13634 M (SHOW_VERSION, mp);
13643 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
13645 unformat_input_t *line_input = vam->input;
13646 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
13647 ip4_address_t local4, remote4;
13648 ip6_address_t local6, remote6;
13650 u8 ipv4_set = 0, ipv6_set = 0;
13654 u32 mcast_sw_if_index = ~0;
13655 u32 encap_vrf_id = 0;
13656 u32 decap_vrf_id = 0;
13662 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13663 memset (&local4, 0, sizeof local4);
13664 memset (&remote4, 0, sizeof remote4);
13665 memset (&local6, 0, sizeof local6);
13666 memset (&remote6, 0, sizeof remote6);
13668 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13670 if (unformat (line_input, "del"))
13672 else if (unformat (line_input, "local %U",
13673 unformat_ip4_address, &local4))
13678 else if (unformat (line_input, "remote %U",
13679 unformat_ip4_address, &remote4))
13684 else if (unformat (line_input, "local %U",
13685 unformat_ip6_address, &local6))
13690 else if (unformat (line_input, "remote %U",
13691 unformat_ip6_address, &remote6))
13696 else if (unformat (line_input, "group %U %U",
13697 unformat_ip4_address, &remote4,
13698 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13700 grp_set = remote_set = 1;
13703 else if (unformat (line_input, "group %U",
13704 unformat_ip4_address, &remote4))
13706 grp_set = remote_set = 1;
13709 else if (unformat (line_input, "group %U %U",
13710 unformat_ip6_address, &remote6,
13711 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13713 grp_set = remote_set = 1;
13716 else if (unformat (line_input, "group %U",
13717 unformat_ip6_address, &remote6))
13719 grp_set = remote_set = 1;
13723 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13725 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13727 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
13729 else if (unformat (line_input, "vni %d", &vni))
13731 else if (unformat (line_input, "next-ip4"))
13733 else if (unformat (line_input, "next-ip6"))
13735 else if (unformat (line_input, "next-ethernet"))
13737 else if (unformat (line_input, "next-nsh"))
13741 errmsg ("parse error '%U'", format_unformat_error, line_input);
13746 if (local_set == 0)
13748 errmsg ("tunnel local address not specified");
13751 if (remote_set == 0)
13753 errmsg ("tunnel remote address not specified");
13756 if (grp_set && mcast_sw_if_index == ~0)
13758 errmsg ("tunnel nonexistent multicast device");
13761 if (ipv4_set && ipv6_set)
13763 errmsg ("both IPv4 and IPv6 addresses specified");
13769 errmsg ("vni not specified");
13773 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
13778 clib_memcpy (&mp->local, &local6, sizeof (local6));
13779 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
13783 clib_memcpy (&mp->local, &local4, sizeof (local4));
13784 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
13787 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13788 mp->encap_vrf_id = ntohl (encap_vrf_id);
13789 mp->decap_vrf_id = ntohl (decap_vrf_id);
13790 mp->protocol = protocol;
13791 mp->vni = ntohl (vni);
13792 mp->is_add = is_add;
13793 mp->is_ipv6 = ipv6_set;
13800 static void vl_api_vxlan_gpe_tunnel_details_t_handler
13801 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13803 vat_main_t *vam = &vat_main;
13804 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
13805 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
13807 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
13808 ntohl (mp->sw_if_index),
13809 format_ip46_address, &local, IP46_TYPE_ANY,
13810 format_ip46_address, &remote, IP46_TYPE_ANY,
13811 ntohl (mp->vni), mp->protocol,
13812 ntohl (mp->mcast_sw_if_index),
13813 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
13817 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
13818 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13820 vat_main_t *vam = &vat_main;
13821 vat_json_node_t *node = NULL;
13822 struct in_addr ip4;
13823 struct in6_addr ip6;
13825 if (VAT_JSON_ARRAY != vam->json_tree.type)
13827 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13828 vat_json_init_array (&vam->json_tree);
13830 node = vat_json_array_add (&vam->json_tree);
13832 vat_json_init_object (node);
13833 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13836 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
13837 vat_json_object_add_ip6 (node, "local", ip6);
13838 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
13839 vat_json_object_add_ip6 (node, "remote", ip6);
13843 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
13844 vat_json_object_add_ip4 (node, "local", ip4);
13845 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
13846 vat_json_object_add_ip4 (node, "remote", ip4);
13848 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13849 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
13850 vat_json_object_add_uint (node, "mcast_sw_if_index",
13851 ntohl (mp->mcast_sw_if_index));
13852 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13853 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
13854 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13858 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
13860 unformat_input_t *i = vam->input;
13861 vl_api_vxlan_gpe_tunnel_dump_t *mp;
13862 vl_api_control_ping_t *mp_ping;
13864 u8 sw_if_index_set = 0;
13867 /* Parse args required to build the message */
13868 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13870 if (unformat (i, "sw_if_index %d", &sw_if_index))
13871 sw_if_index_set = 1;
13876 if (sw_if_index_set == 0)
13881 if (!vam->json_output)
13883 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
13884 "sw_if_index", "local", "remote", "vni",
13885 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
13888 /* Get list of vxlan-tunnel interfaces */
13889 M (VXLAN_GPE_TUNNEL_DUMP, mp);
13891 mp->sw_if_index = htonl (sw_if_index);
13895 /* Use a control ping for synchronization */
13896 MPING (CONTROL_PING, mp_ping);
13903 static void vl_api_l2_fib_table_details_t_handler
13904 (vl_api_l2_fib_table_details_t * mp)
13906 vat_main_t *vam = &vat_main;
13908 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
13910 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
13911 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
13915 static void vl_api_l2_fib_table_details_t_handler_json
13916 (vl_api_l2_fib_table_details_t * mp)
13918 vat_main_t *vam = &vat_main;
13919 vat_json_node_t *node = NULL;
13921 if (VAT_JSON_ARRAY != vam->json_tree.type)
13923 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13924 vat_json_init_array (&vam->json_tree);
13926 node = vat_json_array_add (&vam->json_tree);
13928 vat_json_init_object (node);
13929 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
13930 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
13931 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13932 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
13933 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
13934 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
13938 api_l2_fib_table_dump (vat_main_t * vam)
13940 unformat_input_t *i = vam->input;
13941 vl_api_l2_fib_table_dump_t *mp;
13942 vl_api_control_ping_t *mp_ping;
13947 /* Parse args required to build the message */
13948 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13950 if (unformat (i, "bd_id %d", &bd_id))
13956 if (bd_id_set == 0)
13958 errmsg ("missing bridge domain");
13962 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
13964 /* Get list of l2 fib entries */
13965 M (L2_FIB_TABLE_DUMP, mp);
13967 mp->bd_id = ntohl (bd_id);
13970 /* Use a control ping for synchronization */
13971 MPING (CONTROL_PING, mp_ping);
13980 api_interface_name_renumber (vat_main_t * vam)
13982 unformat_input_t *line_input = vam->input;
13983 vl_api_interface_name_renumber_t *mp;
13984 u32 sw_if_index = ~0;
13985 u32 new_show_dev_instance = ~0;
13988 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13990 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
13993 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13995 else if (unformat (line_input, "new_show_dev_instance %d",
13996 &new_show_dev_instance))
14002 if (sw_if_index == ~0)
14004 errmsg ("missing interface name or sw_if_index");
14008 if (new_show_dev_instance == ~0)
14010 errmsg ("missing new_show_dev_instance");
14014 M (INTERFACE_NAME_RENUMBER, mp);
14016 mp->sw_if_index = ntohl (sw_if_index);
14017 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
14025 api_want_ip4_arp_events (vat_main_t * vam)
14027 unformat_input_t *line_input = vam->input;
14028 vl_api_want_ip4_arp_events_t *mp;
14029 ip4_address_t address;
14030 int address_set = 0;
14031 u32 enable_disable = 1;
14034 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14036 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
14038 else if (unformat (line_input, "del"))
14039 enable_disable = 0;
14044 if (address_set == 0)
14046 errmsg ("missing addresses");
14050 M (WANT_IP4_ARP_EVENTS, mp);
14051 mp->enable_disable = enable_disable;
14052 mp->pid = htonl (getpid ());
14053 mp->address = address.as_u32;
14061 api_want_ip6_nd_events (vat_main_t * vam)
14063 unformat_input_t *line_input = vam->input;
14064 vl_api_want_ip6_nd_events_t *mp;
14065 ip6_address_t address;
14066 int address_set = 0;
14067 u32 enable_disable = 1;
14070 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14072 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
14074 else if (unformat (line_input, "del"))
14075 enable_disable = 0;
14080 if (address_set == 0)
14082 errmsg ("missing addresses");
14086 M (WANT_IP6_ND_EVENTS, mp);
14087 mp->enable_disable = enable_disable;
14088 mp->pid = htonl (getpid ());
14089 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
14097 api_want_l2_macs_events (vat_main_t * vam)
14099 unformat_input_t *line_input = vam->input;
14100 vl_api_want_l2_macs_events_t *mp;
14101 u8 enable_disable = 1;
14102 u32 scan_delay = 0;
14103 u32 max_macs_in_event = 0;
14104 u32 learn_limit = 0;
14107 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14109 if (unformat (line_input, "learn-limit %d", &learn_limit))
14111 else if (unformat (line_input, "scan-delay %d", &scan_delay))
14113 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
14115 else if (unformat (line_input, "disable"))
14116 enable_disable = 0;
14121 M (WANT_L2_MACS_EVENTS, mp);
14122 mp->enable_disable = enable_disable;
14123 mp->pid = htonl (getpid ());
14124 mp->learn_limit = htonl (learn_limit);
14125 mp->scan_delay = (u8) scan_delay;
14126 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
14133 api_input_acl_set_interface (vat_main_t * vam)
14135 unformat_input_t *i = vam->input;
14136 vl_api_input_acl_set_interface_t *mp;
14138 int sw_if_index_set;
14139 u32 ip4_table_index = ~0;
14140 u32 ip6_table_index = ~0;
14141 u32 l2_table_index = ~0;
14145 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14147 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14148 sw_if_index_set = 1;
14149 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14150 sw_if_index_set = 1;
14151 else if (unformat (i, "del"))
14153 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14155 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14157 else if (unformat (i, "l2-table %d", &l2_table_index))
14161 clib_warning ("parse error '%U'", format_unformat_error, i);
14166 if (sw_if_index_set == 0)
14168 errmsg ("missing interface name or sw_if_index");
14172 M (INPUT_ACL_SET_INTERFACE, mp);
14174 mp->sw_if_index = ntohl (sw_if_index);
14175 mp->ip4_table_index = ntohl (ip4_table_index);
14176 mp->ip6_table_index = ntohl (ip6_table_index);
14177 mp->l2_table_index = ntohl (l2_table_index);
14178 mp->is_add = is_add;
14186 api_ip_address_dump (vat_main_t * vam)
14188 unformat_input_t *i = vam->input;
14189 vl_api_ip_address_dump_t *mp;
14190 vl_api_control_ping_t *mp_ping;
14191 u32 sw_if_index = ~0;
14192 u8 sw_if_index_set = 0;
14197 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14199 if (unformat (i, "sw_if_index %d", &sw_if_index))
14200 sw_if_index_set = 1;
14202 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14203 sw_if_index_set = 1;
14204 else if (unformat (i, "ipv4"))
14206 else if (unformat (i, "ipv6"))
14212 if (ipv4_set && ipv6_set)
14214 errmsg ("ipv4 and ipv6 flags cannot be both set");
14218 if ((!ipv4_set) && (!ipv6_set))
14220 errmsg ("no ipv4 nor ipv6 flag set");
14224 if (sw_if_index_set == 0)
14226 errmsg ("missing interface name or sw_if_index");
14230 vam->current_sw_if_index = sw_if_index;
14231 vam->is_ipv6 = ipv6_set;
14233 M (IP_ADDRESS_DUMP, mp);
14234 mp->sw_if_index = ntohl (sw_if_index);
14235 mp->is_ipv6 = ipv6_set;
14238 /* Use a control ping for synchronization */
14239 MPING (CONTROL_PING, mp_ping);
14247 api_ip_dump (vat_main_t * vam)
14249 vl_api_ip_dump_t *mp;
14250 vl_api_control_ping_t *mp_ping;
14251 unformat_input_t *in = vam->input;
14258 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
14260 if (unformat (in, "ipv4"))
14262 else if (unformat (in, "ipv6"))
14268 if (ipv4_set && ipv6_set)
14270 errmsg ("ipv4 and ipv6 flags cannot be both set");
14274 if ((!ipv4_set) && (!ipv6_set))
14276 errmsg ("no ipv4 nor ipv6 flag set");
14280 is_ipv6 = ipv6_set;
14281 vam->is_ipv6 = is_ipv6;
14283 /* free old data */
14284 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
14286 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
14288 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
14291 mp->is_ipv6 = ipv6_set;
14294 /* Use a control ping for synchronization */
14295 MPING (CONTROL_PING, mp_ping);
14303 api_ipsec_spd_add_del (vat_main_t * vam)
14305 unformat_input_t *i = vam->input;
14306 vl_api_ipsec_spd_add_del_t *mp;
14311 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14313 if (unformat (i, "spd_id %d", &spd_id))
14315 else if (unformat (i, "del"))
14319 clib_warning ("parse error '%U'", format_unformat_error, i);
14325 errmsg ("spd_id must be set");
14329 M (IPSEC_SPD_ADD_DEL, mp);
14331 mp->spd_id = ntohl (spd_id);
14332 mp->is_add = is_add;
14340 api_ipsec_interface_add_del_spd (vat_main_t * vam)
14342 unformat_input_t *i = vam->input;
14343 vl_api_ipsec_interface_add_del_spd_t *mp;
14345 u8 sw_if_index_set = 0;
14346 u32 spd_id = (u32) ~ 0;
14350 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14352 if (unformat (i, "del"))
14354 else if (unformat (i, "spd_id %d", &spd_id))
14357 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14358 sw_if_index_set = 1;
14359 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14360 sw_if_index_set = 1;
14363 clib_warning ("parse error '%U'", format_unformat_error, i);
14369 if (spd_id == (u32) ~ 0)
14371 errmsg ("spd_id must be set");
14375 if (sw_if_index_set == 0)
14377 errmsg ("missing interface name or sw_if_index");
14381 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
14383 mp->spd_id = ntohl (spd_id);
14384 mp->sw_if_index = ntohl (sw_if_index);
14385 mp->is_add = is_add;
14393 api_ipsec_spd_add_del_entry (vat_main_t * vam)
14395 unformat_input_t *i = vam->input;
14396 vl_api_ipsec_spd_add_del_entry_t *mp;
14397 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
14398 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
14400 u32 rport_start = 0, rport_stop = (u32) ~ 0;
14401 u32 lport_start = 0, lport_stop = (u32) ~ 0;
14402 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
14403 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
14406 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
14407 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
14408 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
14409 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
14410 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
14411 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
14413 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14415 if (unformat (i, "del"))
14417 if (unformat (i, "outbound"))
14419 if (unformat (i, "inbound"))
14421 else if (unformat (i, "spd_id %d", &spd_id))
14423 else if (unformat (i, "sa_id %d", &sa_id))
14425 else if (unformat (i, "priority %d", &priority))
14427 else if (unformat (i, "protocol %d", &protocol))
14429 else if (unformat (i, "lport_start %d", &lport_start))
14431 else if (unformat (i, "lport_stop %d", &lport_stop))
14433 else if (unformat (i, "rport_start %d", &rport_start))
14435 else if (unformat (i, "rport_stop %d", &rport_stop))
14439 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
14445 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
14452 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
14458 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
14465 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
14471 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
14478 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
14484 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
14490 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
14492 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
14494 clib_warning ("unsupported action: 'resolve'");
14500 clib_warning ("parse error '%U'", format_unformat_error, i);
14506 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
14508 mp->spd_id = ntohl (spd_id);
14509 mp->priority = ntohl (priority);
14510 mp->is_outbound = is_outbound;
14512 mp->is_ipv6 = is_ipv6;
14513 if (is_ipv6 || is_ip_any)
14515 clib_memcpy (mp->remote_address_start, &raddr6_start,
14516 sizeof (ip6_address_t));
14517 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
14518 sizeof (ip6_address_t));
14519 clib_memcpy (mp->local_address_start, &laddr6_start,
14520 sizeof (ip6_address_t));
14521 clib_memcpy (mp->local_address_stop, &laddr6_stop,
14522 sizeof (ip6_address_t));
14526 clib_memcpy (mp->remote_address_start, &raddr4_start,
14527 sizeof (ip4_address_t));
14528 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
14529 sizeof (ip4_address_t));
14530 clib_memcpy (mp->local_address_start, &laddr4_start,
14531 sizeof (ip4_address_t));
14532 clib_memcpy (mp->local_address_stop, &laddr4_stop,
14533 sizeof (ip4_address_t));
14535 mp->protocol = (u8) protocol;
14536 mp->local_port_start = ntohs ((u16) lport_start);
14537 mp->local_port_stop = ntohs ((u16) lport_stop);
14538 mp->remote_port_start = ntohs ((u16) rport_start);
14539 mp->remote_port_stop = ntohs ((u16) rport_stop);
14540 mp->policy = (u8) policy;
14541 mp->sa_id = ntohl (sa_id);
14542 mp->is_add = is_add;
14543 mp->is_ip_any = is_ip_any;
14550 api_ipsec_sad_add_del_entry (vat_main_t * vam)
14552 unformat_input_t *i = vam->input;
14553 vl_api_ipsec_sad_add_del_entry_t *mp;
14554 u32 sad_id = 0, spi = 0;
14555 u8 *ck = 0, *ik = 0;
14558 u8 protocol = IPSEC_PROTOCOL_AH;
14559 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
14560 u32 crypto_alg = 0, integ_alg = 0;
14561 ip4_address_t tun_src4;
14562 ip4_address_t tun_dst4;
14563 ip6_address_t tun_src6;
14564 ip6_address_t tun_dst6;
14567 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14569 if (unformat (i, "del"))
14571 else if (unformat (i, "sad_id %d", &sad_id))
14573 else if (unformat (i, "spi %d", &spi))
14575 else if (unformat (i, "esp"))
14576 protocol = IPSEC_PROTOCOL_ESP;
14577 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
14580 is_tunnel_ipv6 = 0;
14582 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
14585 is_tunnel_ipv6 = 0;
14587 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
14590 is_tunnel_ipv6 = 1;
14592 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
14595 is_tunnel_ipv6 = 1;
14599 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
14601 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
14602 crypto_alg >= IPSEC_CRYPTO_N_ALG)
14604 clib_warning ("unsupported crypto-alg: '%U'",
14605 format_ipsec_crypto_alg, crypto_alg);
14609 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14613 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
14615 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
14616 integ_alg >= IPSEC_INTEG_N_ALG)
14618 clib_warning ("unsupported integ-alg: '%U'",
14619 format_ipsec_integ_alg, integ_alg);
14623 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14627 clib_warning ("parse error '%U'", format_unformat_error, i);
14633 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
14635 mp->sad_id = ntohl (sad_id);
14636 mp->is_add = is_add;
14637 mp->protocol = protocol;
14638 mp->spi = ntohl (spi);
14639 mp->is_tunnel = is_tunnel;
14640 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
14641 mp->crypto_algorithm = crypto_alg;
14642 mp->integrity_algorithm = integ_alg;
14643 mp->crypto_key_length = vec_len (ck);
14644 mp->integrity_key_length = vec_len (ik);
14646 if (mp->crypto_key_length > sizeof (mp->crypto_key))
14647 mp->crypto_key_length = sizeof (mp->crypto_key);
14649 if (mp->integrity_key_length > sizeof (mp->integrity_key))
14650 mp->integrity_key_length = sizeof (mp->integrity_key);
14653 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
14655 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
14659 if (is_tunnel_ipv6)
14661 clib_memcpy (mp->tunnel_src_address, &tun_src6,
14662 sizeof (ip6_address_t));
14663 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
14664 sizeof (ip6_address_t));
14668 clib_memcpy (mp->tunnel_src_address, &tun_src4,
14669 sizeof (ip4_address_t));
14670 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
14671 sizeof (ip4_address_t));
14681 api_ipsec_sa_set_key (vat_main_t * vam)
14683 unformat_input_t *i = vam->input;
14684 vl_api_ipsec_sa_set_key_t *mp;
14686 u8 *ck = 0, *ik = 0;
14689 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14691 if (unformat (i, "sa_id %d", &sa_id))
14693 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14695 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14699 clib_warning ("parse error '%U'", format_unformat_error, i);
14704 M (IPSEC_SA_SET_KEY, mp);
14706 mp->sa_id = ntohl (sa_id);
14707 mp->crypto_key_length = vec_len (ck);
14708 mp->integrity_key_length = vec_len (ik);
14710 if (mp->crypto_key_length > sizeof (mp->crypto_key))
14711 mp->crypto_key_length = sizeof (mp->crypto_key);
14713 if (mp->integrity_key_length > sizeof (mp->integrity_key))
14714 mp->integrity_key_length = sizeof (mp->integrity_key);
14717 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
14719 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
14727 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
14729 unformat_input_t *i = vam->input;
14730 vl_api_ipsec_tunnel_if_add_del_t *mp;
14731 u32 local_spi = 0, remote_spi = 0;
14732 u32 crypto_alg = 0, integ_alg = 0;
14733 u8 *lck = NULL, *rck = NULL;
14734 u8 *lik = NULL, *rik = NULL;
14735 ip4_address_t local_ip = { {0} };
14736 ip4_address_t remote_ip = { {0} };
14739 u8 anti_replay = 0;
14742 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14744 if (unformat (i, "del"))
14746 else if (unformat (i, "esn"))
14748 else if (unformat (i, "anti_replay"))
14750 else if (unformat (i, "local_spi %d", &local_spi))
14752 else if (unformat (i, "remote_spi %d", &remote_spi))
14754 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
14756 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
14758 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
14761 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
14763 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
14765 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
14769 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
14771 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
14772 crypto_alg >= IPSEC_CRYPTO_N_ALG)
14774 errmsg ("unsupported crypto-alg: '%U'\n",
14775 format_ipsec_crypto_alg, crypto_alg);
14781 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
14783 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
14784 integ_alg >= IPSEC_INTEG_N_ALG)
14786 errmsg ("unsupported integ-alg: '%U'\n",
14787 format_ipsec_integ_alg, integ_alg);
14793 errmsg ("parse error '%U'\n", format_unformat_error, i);
14798 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
14800 mp->is_add = is_add;
14802 mp->anti_replay = anti_replay;
14804 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
14805 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
14807 mp->local_spi = htonl (local_spi);
14808 mp->remote_spi = htonl (remote_spi);
14809 mp->crypto_alg = (u8) crypto_alg;
14811 mp->local_crypto_key_len = 0;
14814 mp->local_crypto_key_len = vec_len (lck);
14815 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
14816 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
14817 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
14820 mp->remote_crypto_key_len = 0;
14823 mp->remote_crypto_key_len = vec_len (rck);
14824 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
14825 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
14826 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
14829 mp->integ_alg = (u8) integ_alg;
14831 mp->local_integ_key_len = 0;
14834 mp->local_integ_key_len = vec_len (lik);
14835 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
14836 mp->local_integ_key_len = sizeof (mp->local_integ_key);
14837 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
14840 mp->remote_integ_key_len = 0;
14843 mp->remote_integ_key_len = vec_len (rik);
14844 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
14845 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
14846 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
14855 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
14857 vat_main_t *vam = &vat_main;
14859 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
14860 "crypto_key %U integ_alg %u integ_key %U use_esn %u "
14861 "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u "
14862 "tunnel_src_addr %U tunnel_dst_addr %U "
14863 "salt %u seq_outbound %lu last_seq_inbound %lu "
14864 "replay_window %lu total_data_size %lu\n",
14865 ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi),
14867 mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len,
14868 mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len,
14869 mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6,
14870 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
14871 mp->tunnel_src_addr,
14872 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
14873 mp->tunnel_dst_addr,
14875 clib_net_to_host_u64 (mp->seq_outbound),
14876 clib_net_to_host_u64 (mp->last_seq_inbound),
14877 clib_net_to_host_u64 (mp->replay_window),
14878 clib_net_to_host_u64 (mp->total_data_size));
14881 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
14882 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
14884 static void vl_api_ipsec_sa_details_t_handler_json
14885 (vl_api_ipsec_sa_details_t * mp)
14887 vat_main_t *vam = &vat_main;
14888 vat_json_node_t *node = NULL;
14889 struct in_addr src_ip4, dst_ip4;
14890 struct in6_addr src_ip6, dst_ip6;
14892 if (VAT_JSON_ARRAY != vam->json_tree.type)
14894 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14895 vat_json_init_array (&vam->json_tree);
14897 node = vat_json_array_add (&vam->json_tree);
14899 vat_json_init_object (node);
14900 vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id));
14901 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14902 vat_json_object_add_uint (node, "spi", ntohl (mp->spi));
14903 vat_json_object_add_uint (node, "proto", mp->protocol);
14904 vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg);
14905 vat_json_object_add_uint (node, "integ_alg", mp->integ_alg);
14906 vat_json_object_add_uint (node, "use_esn", mp->use_esn);
14907 vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay);
14908 vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel);
14909 vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6);
14910 vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key,
14911 mp->crypto_key_len);
14912 vat_json_object_add_bytes (node, "integ_key", mp->integ_key,
14913 mp->integ_key_len);
14914 if (mp->is_tunnel_ip6)
14916 clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6));
14917 vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6);
14918 clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6));
14919 vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6);
14923 clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4));
14924 vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4);
14925 clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4));
14926 vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4);
14928 vat_json_object_add_uint (node, "replay_window",
14929 clib_net_to_host_u64 (mp->replay_window));
14930 vat_json_object_add_uint (node, "total_data_size",
14931 clib_net_to_host_u64 (mp->total_data_size));
14936 api_ipsec_sa_dump (vat_main_t * vam)
14938 unformat_input_t *i = vam->input;
14939 vl_api_ipsec_sa_dump_t *mp;
14940 vl_api_control_ping_t *mp_ping;
14944 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14946 if (unformat (i, "sa_id %d", &sa_id))
14950 clib_warning ("parse error '%U'", format_unformat_error, i);
14955 M (IPSEC_SA_DUMP, mp);
14957 mp->sa_id = ntohl (sa_id);
14961 /* Use a control ping for synchronization */
14962 M (CONTROL_PING, mp_ping);
14970 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
14972 unformat_input_t *i = vam->input;
14973 vl_api_ipsec_tunnel_if_set_key_t *mp;
14974 u32 sw_if_index = ~0;
14975 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
14980 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14982 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14985 if (unformat (i, "local crypto %U", unformat_ipsec_crypto_alg, &alg))
14986 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
14988 if (unformat (i, "remote crypto %U", unformat_ipsec_crypto_alg, &alg))
14989 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
14990 else if (unformat (i, "local integ %U", unformat_ipsec_integ_alg, &alg))
14991 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
14993 if (unformat (i, "remote integ %U", unformat_ipsec_integ_alg, &alg))
14994 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
14995 else if (unformat (i, "%U", unformat_hex_string, &key))
14999 clib_warning ("parse error '%U'", format_unformat_error, i);
15004 if (sw_if_index == ~0)
15006 errmsg ("interface must be specified");
15010 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
15012 errmsg ("key type must be specified");
15018 errmsg ("algorithm must be specified");
15022 if (vec_len (key) == 0)
15024 errmsg ("key must be specified");
15028 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
15030 mp->sw_if_index = htonl (sw_if_index);
15032 mp->key_type = key_type;
15033 mp->key_len = vec_len (key);
15034 clib_memcpy (mp->key, key, vec_len (key));
15043 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
15045 unformat_input_t *i = vam->input;
15046 vl_api_ipsec_tunnel_if_set_sa_t *mp;
15047 u32 sw_if_index = ~0;
15049 u8 is_outbound = (u8) ~ 0;
15052 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15054 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15056 else if (unformat (i, "sa_id %d", &sa_id))
15058 else if (unformat (i, "outbound"))
15060 else if (unformat (i, "inbound"))
15064 clib_warning ("parse error '%U'", format_unformat_error, i);
15069 if (sw_if_index == ~0)
15071 errmsg ("interface must be specified");
15077 errmsg ("SA ID must be specified");
15081 M (IPSEC_TUNNEL_IF_SET_SA, mp);
15083 mp->sw_if_index = htonl (sw_if_index);
15084 mp->sa_id = htonl (sa_id);
15085 mp->is_outbound = is_outbound;
15094 api_ikev2_profile_add_del (vat_main_t * vam)
15096 unformat_input_t *i = vam->input;
15097 vl_api_ikev2_profile_add_del_t *mp;
15102 const char *valid_chars = "a-zA-Z0-9_";
15104 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15106 if (unformat (i, "del"))
15108 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15109 vec_add1 (name, 0);
15112 errmsg ("parse error '%U'", format_unformat_error, i);
15117 if (!vec_len (name))
15119 errmsg ("profile name must be specified");
15123 if (vec_len (name) > 64)
15125 errmsg ("profile name too long");
15129 M (IKEV2_PROFILE_ADD_DEL, mp);
15131 clib_memcpy (mp->name, name, vec_len (name));
15132 mp->is_add = is_add;
15141 api_ikev2_profile_set_auth (vat_main_t * vam)
15143 unformat_input_t *i = vam->input;
15144 vl_api_ikev2_profile_set_auth_t *mp;
15147 u32 auth_method = 0;
15151 const char *valid_chars = "a-zA-Z0-9_";
15153 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15155 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15156 vec_add1 (name, 0);
15157 else if (unformat (i, "auth_method %U",
15158 unformat_ikev2_auth_method, &auth_method))
15160 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
15162 else if (unformat (i, "auth_data %v", &data))
15166 errmsg ("parse error '%U'", format_unformat_error, i);
15171 if (!vec_len (name))
15173 errmsg ("profile name must be specified");
15177 if (vec_len (name) > 64)
15179 errmsg ("profile name too long");
15183 if (!vec_len (data))
15185 errmsg ("auth_data must be specified");
15191 errmsg ("auth_method must be specified");
15195 M (IKEV2_PROFILE_SET_AUTH, mp);
15197 mp->is_hex = is_hex;
15198 mp->auth_method = (u8) auth_method;
15199 mp->data_len = vec_len (data);
15200 clib_memcpy (mp->name, name, vec_len (name));
15201 clib_memcpy (mp->data, data, vec_len (data));
15211 api_ikev2_profile_set_id (vat_main_t * vam)
15213 unformat_input_t *i = vam->input;
15214 vl_api_ikev2_profile_set_id_t *mp;
15222 const char *valid_chars = "a-zA-Z0-9_";
15224 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15226 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15227 vec_add1 (name, 0);
15228 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
15230 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
15232 data = vec_new (u8, 4);
15233 clib_memcpy (data, ip4.as_u8, 4);
15235 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
15237 else if (unformat (i, "id_data %v", &data))
15239 else if (unformat (i, "local"))
15241 else if (unformat (i, "remote"))
15245 errmsg ("parse error '%U'", format_unformat_error, i);
15250 if (!vec_len (name))
15252 errmsg ("profile name must be specified");
15256 if (vec_len (name) > 64)
15258 errmsg ("profile name too long");
15262 if (!vec_len (data))
15264 errmsg ("id_data must be specified");
15270 errmsg ("id_type must be specified");
15274 M (IKEV2_PROFILE_SET_ID, mp);
15276 mp->is_local = is_local;
15277 mp->id_type = (u8) id_type;
15278 mp->data_len = vec_len (data);
15279 clib_memcpy (mp->name, name, vec_len (name));
15280 clib_memcpy (mp->data, data, vec_len (data));
15290 api_ikev2_profile_set_ts (vat_main_t * vam)
15292 unformat_input_t *i = vam->input;
15293 vl_api_ikev2_profile_set_ts_t *mp;
15296 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
15297 ip4_address_t start_addr, end_addr;
15299 const char *valid_chars = "a-zA-Z0-9_";
15302 start_addr.as_u32 = 0;
15303 end_addr.as_u32 = (u32) ~ 0;
15305 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15307 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15308 vec_add1 (name, 0);
15309 else if (unformat (i, "protocol %d", &proto))
15311 else if (unformat (i, "start_port %d", &start_port))
15313 else if (unformat (i, "end_port %d", &end_port))
15316 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
15318 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
15320 else if (unformat (i, "local"))
15322 else if (unformat (i, "remote"))
15326 errmsg ("parse error '%U'", format_unformat_error, i);
15331 if (!vec_len (name))
15333 errmsg ("profile name must be specified");
15337 if (vec_len (name) > 64)
15339 errmsg ("profile name too long");
15343 M (IKEV2_PROFILE_SET_TS, mp);
15345 mp->is_local = is_local;
15346 mp->proto = (u8) proto;
15347 mp->start_port = (u16) start_port;
15348 mp->end_port = (u16) end_port;
15349 mp->start_addr = start_addr.as_u32;
15350 mp->end_addr = end_addr.as_u32;
15351 clib_memcpy (mp->name, name, vec_len (name));
15360 api_ikev2_set_local_key (vat_main_t * vam)
15362 unformat_input_t *i = vam->input;
15363 vl_api_ikev2_set_local_key_t *mp;
15367 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15369 if (unformat (i, "file %v", &file))
15370 vec_add1 (file, 0);
15373 errmsg ("parse error '%U'", format_unformat_error, i);
15378 if (!vec_len (file))
15380 errmsg ("RSA key file must be specified");
15384 if (vec_len (file) > 256)
15386 errmsg ("file name too long");
15390 M (IKEV2_SET_LOCAL_KEY, mp);
15392 clib_memcpy (mp->key_file, file, vec_len (file));
15401 api_ikev2_set_responder (vat_main_t * vam)
15403 unformat_input_t *i = vam->input;
15404 vl_api_ikev2_set_responder_t *mp;
15407 u32 sw_if_index = ~0;
15408 ip4_address_t address;
15410 const char *valid_chars = "a-zA-Z0-9_";
15412 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15415 (i, "%U interface %d address %U", unformat_token, valid_chars,
15416 &name, &sw_if_index, unformat_ip4_address, &address))
15417 vec_add1 (name, 0);
15420 errmsg ("parse error '%U'", format_unformat_error, i);
15425 if (!vec_len (name))
15427 errmsg ("profile name must be specified");
15431 if (vec_len (name) > 64)
15433 errmsg ("profile name too long");
15437 M (IKEV2_SET_RESPONDER, mp);
15439 clib_memcpy (mp->name, name, vec_len (name));
15442 mp->sw_if_index = sw_if_index;
15443 clib_memcpy (mp->address, &address, sizeof (address));
15451 api_ikev2_set_ike_transforms (vat_main_t * vam)
15453 unformat_input_t *i = vam->input;
15454 vl_api_ikev2_set_ike_transforms_t *mp;
15457 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
15459 const char *valid_chars = "a-zA-Z0-9_";
15461 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15463 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
15464 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
15465 vec_add1 (name, 0);
15468 errmsg ("parse error '%U'", format_unformat_error, i);
15473 if (!vec_len (name))
15475 errmsg ("profile name must be specified");
15479 if (vec_len (name) > 64)
15481 errmsg ("profile name too long");
15485 M (IKEV2_SET_IKE_TRANSFORMS, mp);
15487 clib_memcpy (mp->name, name, vec_len (name));
15489 mp->crypto_alg = crypto_alg;
15490 mp->crypto_key_size = crypto_key_size;
15491 mp->integ_alg = integ_alg;
15492 mp->dh_group = dh_group;
15501 api_ikev2_set_esp_transforms (vat_main_t * vam)
15503 unformat_input_t *i = vam->input;
15504 vl_api_ikev2_set_esp_transforms_t *mp;
15507 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
15509 const char *valid_chars = "a-zA-Z0-9_";
15511 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15513 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
15514 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
15515 vec_add1 (name, 0);
15518 errmsg ("parse error '%U'", format_unformat_error, i);
15523 if (!vec_len (name))
15525 errmsg ("profile name must be specified");
15529 if (vec_len (name) > 64)
15531 errmsg ("profile name too long");
15535 M (IKEV2_SET_ESP_TRANSFORMS, mp);
15537 clib_memcpy (mp->name, name, vec_len (name));
15539 mp->crypto_alg = crypto_alg;
15540 mp->crypto_key_size = crypto_key_size;
15541 mp->integ_alg = integ_alg;
15542 mp->dh_group = dh_group;
15550 api_ikev2_set_sa_lifetime (vat_main_t * vam)
15552 unformat_input_t *i = vam->input;
15553 vl_api_ikev2_set_sa_lifetime_t *mp;
15556 u64 lifetime, lifetime_maxdata;
15557 u32 lifetime_jitter, handover;
15559 const char *valid_chars = "a-zA-Z0-9_";
15561 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15563 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
15564 &lifetime, &lifetime_jitter, &handover,
15565 &lifetime_maxdata))
15566 vec_add1 (name, 0);
15569 errmsg ("parse error '%U'", format_unformat_error, i);
15574 if (!vec_len (name))
15576 errmsg ("profile name must be specified");
15580 if (vec_len (name) > 64)
15582 errmsg ("profile name too long");
15586 M (IKEV2_SET_SA_LIFETIME, mp);
15588 clib_memcpy (mp->name, name, vec_len (name));
15590 mp->lifetime = lifetime;
15591 mp->lifetime_jitter = lifetime_jitter;
15592 mp->handover = handover;
15593 mp->lifetime_maxdata = lifetime_maxdata;
15601 api_ikev2_initiate_sa_init (vat_main_t * vam)
15603 unformat_input_t *i = vam->input;
15604 vl_api_ikev2_initiate_sa_init_t *mp;
15608 const char *valid_chars = "a-zA-Z0-9_";
15610 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15612 if (unformat (i, "%U", unformat_token, valid_chars, &name))
15613 vec_add1 (name, 0);
15616 errmsg ("parse error '%U'", format_unformat_error, i);
15621 if (!vec_len (name))
15623 errmsg ("profile name must be specified");
15627 if (vec_len (name) > 64)
15629 errmsg ("profile name too long");
15633 M (IKEV2_INITIATE_SA_INIT, mp);
15635 clib_memcpy (mp->name, name, vec_len (name));
15644 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
15646 unformat_input_t *i = vam->input;
15647 vl_api_ikev2_initiate_del_ike_sa_t *mp;
15652 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15654 if (unformat (i, "%lx", &ispi))
15658 errmsg ("parse error '%U'", format_unformat_error, i);
15663 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
15673 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
15675 unformat_input_t *i = vam->input;
15676 vl_api_ikev2_initiate_del_child_sa_t *mp;
15681 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15683 if (unformat (i, "%x", &ispi))
15687 errmsg ("parse error '%U'", format_unformat_error, i);
15692 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
15702 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
15704 unformat_input_t *i = vam->input;
15705 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
15710 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15712 if (unformat (i, "%x", &ispi))
15716 errmsg ("parse error '%U'", format_unformat_error, i);
15721 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
15734 api_map_add_domain (vat_main_t * vam)
15736 unformat_input_t *i = vam->input;
15737 vl_api_map_add_domain_t *mp;
15739 ip4_address_t ip4_prefix;
15740 ip6_address_t ip6_prefix;
15741 ip6_address_t ip6_src;
15742 u32 num_m_args = 0;
15743 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
15744 0, psid_length = 0;
15745 u8 is_translation = 0;
15747 u32 ip6_src_len = 128;
15750 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15752 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
15753 &ip4_prefix, &ip4_prefix_len))
15755 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
15756 &ip6_prefix, &ip6_prefix_len))
15760 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
15763 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
15765 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
15767 else if (unformat (i, "psid-offset %d", &psid_offset))
15769 else if (unformat (i, "psid-len %d", &psid_length))
15771 else if (unformat (i, "mtu %d", &mtu))
15773 else if (unformat (i, "map-t"))
15774 is_translation = 1;
15777 clib_warning ("parse error '%U'", format_unformat_error, i);
15782 if (num_m_args < 3)
15784 errmsg ("mandatory argument(s) missing");
15788 /* Construct the API message */
15789 M (MAP_ADD_DOMAIN, mp);
15791 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
15792 mp->ip4_prefix_len = ip4_prefix_len;
15794 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
15795 mp->ip6_prefix_len = ip6_prefix_len;
15797 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
15798 mp->ip6_src_prefix_len = ip6_src_len;
15800 mp->ea_bits_len = ea_bits_len;
15801 mp->psid_offset = psid_offset;
15802 mp->psid_length = psid_length;
15803 mp->is_translation = is_translation;
15804 mp->mtu = htons (mtu);
15809 /* Wait for a reply, return good/bad news */
15815 api_map_del_domain (vat_main_t * vam)
15817 unformat_input_t *i = vam->input;
15818 vl_api_map_del_domain_t *mp;
15820 u32 num_m_args = 0;
15824 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15826 if (unformat (i, "index %d", &index))
15830 clib_warning ("parse error '%U'", format_unformat_error, i);
15835 if (num_m_args != 1)
15837 errmsg ("mandatory argument(s) missing");
15841 /* Construct the API message */
15842 M (MAP_DEL_DOMAIN, mp);
15844 mp->index = ntohl (index);
15849 /* Wait for a reply, return good/bad news */
15855 api_map_add_del_rule (vat_main_t * vam)
15857 unformat_input_t *i = vam->input;
15858 vl_api_map_add_del_rule_t *mp;
15860 ip6_address_t ip6_dst;
15861 u32 num_m_args = 0, index, psid = 0;
15864 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15866 if (unformat (i, "index %d", &index))
15868 else if (unformat (i, "psid %d", &psid))
15870 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
15872 else if (unformat (i, "del"))
15878 clib_warning ("parse error '%U'", format_unformat_error, i);
15883 /* Construct the API message */
15884 M (MAP_ADD_DEL_RULE, mp);
15886 mp->index = ntohl (index);
15887 mp->is_add = is_add;
15888 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
15889 mp->psid = ntohs (psid);
15894 /* Wait for a reply, return good/bad news */
15900 api_map_domain_dump (vat_main_t * vam)
15902 vl_api_map_domain_dump_t *mp;
15903 vl_api_control_ping_t *mp_ping;
15906 /* Construct the API message */
15907 M (MAP_DOMAIN_DUMP, mp);
15912 /* Use a control ping for synchronization */
15913 MPING (CONTROL_PING, mp_ping);
15921 api_map_rule_dump (vat_main_t * vam)
15923 unformat_input_t *i = vam->input;
15924 vl_api_map_rule_dump_t *mp;
15925 vl_api_control_ping_t *mp_ping;
15926 u32 domain_index = ~0;
15929 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15931 if (unformat (i, "index %u", &domain_index))
15937 if (domain_index == ~0)
15939 clib_warning ("parse error: domain index expected");
15943 /* Construct the API message */
15944 M (MAP_RULE_DUMP, mp);
15946 mp->domain_index = htonl (domain_index);
15951 /* Use a control ping for synchronization */
15952 MPING (CONTROL_PING, mp_ping);
15959 static void vl_api_map_add_domain_reply_t_handler
15960 (vl_api_map_add_domain_reply_t * mp)
15962 vat_main_t *vam = &vat_main;
15963 i32 retval = ntohl (mp->retval);
15965 if (vam->async_mode)
15967 vam->async_errors += (retval < 0);
15971 vam->retval = retval;
15972 vam->result_ready = 1;
15976 static void vl_api_map_add_domain_reply_t_handler_json
15977 (vl_api_map_add_domain_reply_t * mp)
15979 vat_main_t *vam = &vat_main;
15980 vat_json_node_t node;
15982 vat_json_init_object (&node);
15983 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
15984 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
15986 vat_json_print (vam->ofp, &node);
15987 vat_json_free (&node);
15989 vam->retval = ntohl (mp->retval);
15990 vam->result_ready = 1;
15994 api_get_first_msg_id (vat_main_t * vam)
15996 vl_api_get_first_msg_id_t *mp;
15997 unformat_input_t *i = vam->input;
16002 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16004 if (unformat (i, "client %s", &name))
16012 errmsg ("missing client name");
16015 vec_add1 (name, 0);
16017 if (vec_len (name) > 63)
16019 errmsg ("client name too long");
16023 M (GET_FIRST_MSG_ID, mp);
16024 clib_memcpy (mp->name, name, vec_len (name));
16031 api_cop_interface_enable_disable (vat_main_t * vam)
16033 unformat_input_t *line_input = vam->input;
16034 vl_api_cop_interface_enable_disable_t *mp;
16035 u32 sw_if_index = ~0;
16036 u8 enable_disable = 1;
16039 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16041 if (unformat (line_input, "disable"))
16042 enable_disable = 0;
16043 if (unformat (line_input, "enable"))
16044 enable_disable = 1;
16045 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16046 vam, &sw_if_index))
16048 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16054 if (sw_if_index == ~0)
16056 errmsg ("missing interface name or sw_if_index");
16060 /* Construct the API message */
16061 M (COP_INTERFACE_ENABLE_DISABLE, mp);
16062 mp->sw_if_index = ntohl (sw_if_index);
16063 mp->enable_disable = enable_disable;
16067 /* Wait for the reply */
16073 api_cop_whitelist_enable_disable (vat_main_t * vam)
16075 unformat_input_t *line_input = vam->input;
16076 vl_api_cop_whitelist_enable_disable_t *mp;
16077 u32 sw_if_index = ~0;
16078 u8 ip4 = 0, ip6 = 0, default_cop = 0;
16082 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16084 if (unformat (line_input, "ip4"))
16086 else if (unformat (line_input, "ip6"))
16088 else if (unformat (line_input, "default"))
16090 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16091 vam, &sw_if_index))
16093 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16095 else if (unformat (line_input, "fib-id %d", &fib_id))
16101 if (sw_if_index == ~0)
16103 errmsg ("missing interface name or sw_if_index");
16107 /* Construct the API message */
16108 M (COP_WHITELIST_ENABLE_DISABLE, mp);
16109 mp->sw_if_index = ntohl (sw_if_index);
16110 mp->fib_id = ntohl (fib_id);
16113 mp->default_cop = default_cop;
16117 /* Wait for the reply */
16123 api_get_node_graph (vat_main_t * vam)
16125 vl_api_get_node_graph_t *mp;
16128 M (GET_NODE_GRAPH, mp);
16132 /* Wait for the reply */
16138 /** Used for parsing LISP eids */
16139 typedef CLIB_PACKED(struct{
16140 u8 addr[16]; /**< eid address */
16141 u32 len; /**< prefix length if IP */
16142 u8 type; /**< type of eid */
16147 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
16149 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
16151 memset (a, 0, sizeof (a[0]));
16153 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
16155 a->type = 0; /* ipv4 type */
16157 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
16159 a->type = 1; /* ipv6 type */
16161 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
16163 a->type = 2; /* mac type */
16165 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
16167 a->type = 3; /* NSH type */
16168 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
16169 nsh->spi = clib_host_to_net_u32 (nsh->spi);
16176 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
16185 lisp_eid_size_vat (u8 type)
16202 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
16204 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
16208 api_one_add_del_locator_set (vat_main_t * vam)
16210 unformat_input_t *input = vam->input;
16211 vl_api_one_add_del_locator_set_t *mp;
16213 u8 *locator_set_name = NULL;
16214 u8 locator_set_name_set = 0;
16215 vl_api_local_locator_t locator, *locators = 0;
16216 u32 sw_if_index, priority, weight;
16220 /* Parse args required to build the message */
16221 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16223 if (unformat (input, "del"))
16227 else if (unformat (input, "locator-set %s", &locator_set_name))
16229 locator_set_name_set = 1;
16231 else if (unformat (input, "sw_if_index %u p %u w %u",
16232 &sw_if_index, &priority, &weight))
16234 locator.sw_if_index = htonl (sw_if_index);
16235 locator.priority = priority;
16236 locator.weight = weight;
16237 vec_add1 (locators, locator);
16241 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
16242 &sw_if_index, &priority, &weight))
16244 locator.sw_if_index = htonl (sw_if_index);
16245 locator.priority = priority;
16246 locator.weight = weight;
16247 vec_add1 (locators, locator);
16253 if (locator_set_name_set == 0)
16255 errmsg ("missing locator-set name");
16256 vec_free (locators);
16260 if (vec_len (locator_set_name) > 64)
16262 errmsg ("locator-set name too long");
16263 vec_free (locator_set_name);
16264 vec_free (locators);
16267 vec_add1 (locator_set_name, 0);
16269 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
16271 /* Construct the API message */
16272 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
16274 mp->is_add = is_add;
16275 clib_memcpy (mp->locator_set_name, locator_set_name,
16276 vec_len (locator_set_name));
16277 vec_free (locator_set_name);
16279 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
16281 clib_memcpy (mp->locators, locators, data_len);
16282 vec_free (locators);
16287 /* Wait for a reply... */
16292 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
16295 api_one_add_del_locator (vat_main_t * vam)
16297 unformat_input_t *input = vam->input;
16298 vl_api_one_add_del_locator_t *mp;
16299 u32 tmp_if_index = ~0;
16300 u32 sw_if_index = ~0;
16301 u8 sw_if_index_set = 0;
16302 u8 sw_if_index_if_name_set = 0;
16304 u8 priority_set = 0;
16308 u8 *locator_set_name = NULL;
16309 u8 locator_set_name_set = 0;
16312 /* Parse args required to build the message */
16313 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16315 if (unformat (input, "del"))
16319 else if (unformat (input, "locator-set %s", &locator_set_name))
16321 locator_set_name_set = 1;
16323 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
16326 sw_if_index_if_name_set = 1;
16327 sw_if_index = tmp_if_index;
16329 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
16331 sw_if_index_set = 1;
16332 sw_if_index = tmp_if_index;
16334 else if (unformat (input, "p %d", &priority))
16338 else if (unformat (input, "w %d", &weight))
16346 if (locator_set_name_set == 0)
16348 errmsg ("missing locator-set name");
16352 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
16354 errmsg ("missing sw_if_index");
16355 vec_free (locator_set_name);
16359 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
16361 errmsg ("cannot use both params interface name and sw_if_index");
16362 vec_free (locator_set_name);
16366 if (priority_set == 0)
16368 errmsg ("missing locator-set priority");
16369 vec_free (locator_set_name);
16373 if (weight_set == 0)
16375 errmsg ("missing locator-set weight");
16376 vec_free (locator_set_name);
16380 if (vec_len (locator_set_name) > 64)
16382 errmsg ("locator-set name too long");
16383 vec_free (locator_set_name);
16386 vec_add1 (locator_set_name, 0);
16388 /* Construct the API message */
16389 M (ONE_ADD_DEL_LOCATOR, mp);
16391 mp->is_add = is_add;
16392 mp->sw_if_index = ntohl (sw_if_index);
16393 mp->priority = priority;
16394 mp->weight = weight;
16395 clib_memcpy (mp->locator_set_name, locator_set_name,
16396 vec_len (locator_set_name));
16397 vec_free (locator_set_name);
16402 /* Wait for a reply... */
16407 #define api_lisp_add_del_locator api_one_add_del_locator
16410 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
16412 u32 *key_id = va_arg (*args, u32 *);
16415 if (unformat (input, "%s", &s))
16417 if (!strcmp ((char *) s, "sha1"))
16418 key_id[0] = HMAC_SHA_1_96;
16419 else if (!strcmp ((char *) s, "sha256"))
16420 key_id[0] = HMAC_SHA_256_128;
16423 clib_warning ("invalid key_id: '%s'", s);
16424 key_id[0] = HMAC_NO_KEY;
16435 api_one_add_del_local_eid (vat_main_t * vam)
16437 unformat_input_t *input = vam->input;
16438 vl_api_one_add_del_local_eid_t *mp;
16441 lisp_eid_vat_t _eid, *eid = &_eid;
16442 u8 *locator_set_name = 0;
16443 u8 locator_set_name_set = 0;
16449 /* Parse args required to build the message */
16450 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16452 if (unformat (input, "del"))
16456 else if (unformat (input, "vni %d", &vni))
16460 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
16464 else if (unformat (input, "locator-set %s", &locator_set_name))
16466 locator_set_name_set = 1;
16468 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
16470 else if (unformat (input, "secret-key %_%v%_", &key))
16476 if (locator_set_name_set == 0)
16478 errmsg ("missing locator-set name");
16484 errmsg ("EID address not set!");
16485 vec_free (locator_set_name);
16489 if (key && (0 == key_id))
16491 errmsg ("invalid key_id!");
16495 if (vec_len (key) > 64)
16497 errmsg ("key too long");
16502 if (vec_len (locator_set_name) > 64)
16504 errmsg ("locator-set name too long");
16505 vec_free (locator_set_name);
16508 vec_add1 (locator_set_name, 0);
16510 /* Construct the API message */
16511 M (ONE_ADD_DEL_LOCAL_EID, mp);
16513 mp->is_add = is_add;
16514 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
16515 mp->eid_type = eid->type;
16516 mp->prefix_len = eid->len;
16517 mp->vni = clib_host_to_net_u32 (vni);
16518 mp->key_id = clib_host_to_net_u16 (key_id);
16519 clib_memcpy (mp->locator_set_name, locator_set_name,
16520 vec_len (locator_set_name));
16521 clib_memcpy (mp->key, key, vec_len (key));
16523 vec_free (locator_set_name);
16529 /* Wait for a reply... */
16534 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
16537 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
16539 u32 dp_table = 0, vni = 0;;
16540 unformat_input_t *input = vam->input;
16541 vl_api_gpe_add_del_fwd_entry_t *mp;
16543 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
16544 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
16545 u8 rmt_eid_set = 0, lcl_eid_set = 0;
16546 u32 action = ~0, w;
16547 ip4_address_t rmt_rloc4, lcl_rloc4;
16548 ip6_address_t rmt_rloc6, lcl_rloc6;
16549 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
16552 memset (&rloc, 0, sizeof (rloc));
16554 /* Parse args required to build the message */
16555 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16557 if (unformat (input, "del"))
16559 else if (unformat (input, "add"))
16561 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
16565 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
16569 else if (unformat (input, "vrf %d", &dp_table))
16571 else if (unformat (input, "bd %d", &dp_table))
16573 else if (unformat (input, "vni %d", &vni))
16575 else if (unformat (input, "w %d", &w))
16579 errmsg ("No RLOC configured for setting priority/weight!");
16582 curr_rloc->weight = w;
16584 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
16585 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
16589 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
16591 vec_add1 (lcl_locs, rloc);
16593 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
16594 vec_add1 (rmt_locs, rloc);
16595 /* weight saved in rmt loc */
16596 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
16598 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
16599 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
16602 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
16604 vec_add1 (lcl_locs, rloc);
16606 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
16607 vec_add1 (rmt_locs, rloc);
16608 /* weight saved in rmt loc */
16609 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
16611 else if (unformat (input, "action %d", &action))
16617 clib_warning ("parse error '%U'", format_unformat_error, input);
16624 errmsg ("remote eid addresses not set");
16628 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
16630 errmsg ("eid types don't match");
16634 if (0 == rmt_locs && (u32) ~ 0 == action)
16636 errmsg ("action not set for negative mapping");
16640 /* Construct the API message */
16641 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
16642 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
16644 mp->is_add = is_add;
16645 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
16646 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
16647 mp->eid_type = rmt_eid->type;
16648 mp->dp_table = clib_host_to_net_u32 (dp_table);
16649 mp->vni = clib_host_to_net_u32 (vni);
16650 mp->rmt_len = rmt_eid->len;
16651 mp->lcl_len = lcl_eid->len;
16652 mp->action = action;
16654 if (0 != rmt_locs && 0 != lcl_locs)
16656 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
16657 clib_memcpy (mp->locs, lcl_locs,
16658 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
16660 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
16661 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
16662 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
16664 vec_free (lcl_locs);
16665 vec_free (rmt_locs);
16670 /* Wait for a reply... */
16676 api_one_add_del_map_server (vat_main_t * vam)
16678 unformat_input_t *input = vam->input;
16679 vl_api_one_add_del_map_server_t *mp;
16683 ip4_address_t ipv4;
16684 ip6_address_t ipv6;
16687 /* Parse args required to build the message */
16688 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16690 if (unformat (input, "del"))
16694 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
16698 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
16706 if (ipv4_set && ipv6_set)
16708 errmsg ("both eid v4 and v6 addresses set");
16712 if (!ipv4_set && !ipv6_set)
16714 errmsg ("eid addresses not set");
16718 /* Construct the API message */
16719 M (ONE_ADD_DEL_MAP_SERVER, mp);
16721 mp->is_add = is_add;
16725 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
16730 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
16736 /* Wait for a reply... */
16741 #define api_lisp_add_del_map_server api_one_add_del_map_server
16744 api_one_add_del_map_resolver (vat_main_t * vam)
16746 unformat_input_t *input = vam->input;
16747 vl_api_one_add_del_map_resolver_t *mp;
16751 ip4_address_t ipv4;
16752 ip6_address_t ipv6;
16755 /* Parse args required to build the message */
16756 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16758 if (unformat (input, "del"))
16762 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
16766 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
16774 if (ipv4_set && ipv6_set)
16776 errmsg ("both eid v4 and v6 addresses set");
16780 if (!ipv4_set && !ipv6_set)
16782 errmsg ("eid addresses not set");
16786 /* Construct the API message */
16787 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
16789 mp->is_add = is_add;
16793 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
16798 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
16804 /* Wait for a reply... */
16809 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
16812 api_lisp_gpe_enable_disable (vat_main_t * vam)
16814 unformat_input_t *input = vam->input;
16815 vl_api_gpe_enable_disable_t *mp;
16820 /* Parse args required to build the message */
16821 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16823 if (unformat (input, "enable"))
16828 else if (unformat (input, "disable"))
16839 errmsg ("Value not set");
16843 /* Construct the API message */
16844 M (GPE_ENABLE_DISABLE, mp);
16851 /* Wait for a reply... */
16857 api_one_rloc_probe_enable_disable (vat_main_t * vam)
16859 unformat_input_t *input = vam->input;
16860 vl_api_one_rloc_probe_enable_disable_t *mp;
16865 /* Parse args required to build the message */
16866 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16868 if (unformat (input, "enable"))
16873 else if (unformat (input, "disable"))
16881 errmsg ("Value not set");
16885 /* Construct the API message */
16886 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
16888 mp->is_enabled = is_en;
16893 /* Wait for a reply... */
16898 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
16901 api_one_map_register_enable_disable (vat_main_t * vam)
16903 unformat_input_t *input = vam->input;
16904 vl_api_one_map_register_enable_disable_t *mp;
16909 /* Parse args required to build the message */
16910 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16912 if (unformat (input, "enable"))
16917 else if (unformat (input, "disable"))
16925 errmsg ("Value not set");
16929 /* Construct the API message */
16930 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
16932 mp->is_enabled = is_en;
16937 /* Wait for a reply... */
16942 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
16945 api_one_enable_disable (vat_main_t * vam)
16947 unformat_input_t *input = vam->input;
16948 vl_api_one_enable_disable_t *mp;
16953 /* Parse args required to build the message */
16954 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16956 if (unformat (input, "enable"))
16961 else if (unformat (input, "disable"))
16971 errmsg ("Value not set");
16975 /* Construct the API message */
16976 M (ONE_ENABLE_DISABLE, mp);
16983 /* Wait for a reply... */
16988 #define api_lisp_enable_disable api_one_enable_disable
16991 api_one_enable_disable_xtr_mode (vat_main_t * vam)
16993 unformat_input_t *input = vam->input;
16994 vl_api_one_enable_disable_xtr_mode_t *mp;
16999 /* Parse args required to build the message */
17000 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17002 if (unformat (input, "enable"))
17007 else if (unformat (input, "disable"))
17017 errmsg ("Value not set");
17021 /* Construct the API message */
17022 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
17029 /* Wait for a reply... */
17035 api_one_show_xtr_mode (vat_main_t * vam)
17037 vl_api_one_show_xtr_mode_t *mp;
17040 /* Construct the API message */
17041 M (ONE_SHOW_XTR_MODE, mp);
17046 /* Wait for a reply... */
17052 api_one_enable_disable_pitr_mode (vat_main_t * vam)
17054 unformat_input_t *input = vam->input;
17055 vl_api_one_enable_disable_pitr_mode_t *mp;
17060 /* Parse args required to build the message */
17061 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17063 if (unformat (input, "enable"))
17068 else if (unformat (input, "disable"))
17078 errmsg ("Value not set");
17082 /* Construct the API message */
17083 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
17090 /* Wait for a reply... */
17096 api_one_show_pitr_mode (vat_main_t * vam)
17098 vl_api_one_show_pitr_mode_t *mp;
17101 /* Construct the API message */
17102 M (ONE_SHOW_PITR_MODE, mp);
17107 /* Wait for a reply... */
17113 api_one_enable_disable_petr_mode (vat_main_t * vam)
17115 unformat_input_t *input = vam->input;
17116 vl_api_one_enable_disable_petr_mode_t *mp;
17121 /* Parse args required to build the message */
17122 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17124 if (unformat (input, "enable"))
17129 else if (unformat (input, "disable"))
17139 errmsg ("Value not set");
17143 /* Construct the API message */
17144 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
17151 /* Wait for a reply... */
17157 api_one_show_petr_mode (vat_main_t * vam)
17159 vl_api_one_show_petr_mode_t *mp;
17162 /* Construct the API message */
17163 M (ONE_SHOW_PETR_MODE, mp);
17168 /* Wait for a reply... */
17174 api_show_one_map_register_state (vat_main_t * vam)
17176 vl_api_show_one_map_register_state_t *mp;
17179 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
17184 /* wait for reply */
17189 #define api_show_lisp_map_register_state api_show_one_map_register_state
17192 api_show_one_rloc_probe_state (vat_main_t * vam)
17194 vl_api_show_one_rloc_probe_state_t *mp;
17197 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
17202 /* wait for reply */
17207 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
17210 api_one_add_del_ndp_entry (vat_main_t * vam)
17212 vl_api_one_add_del_ndp_entry_t *mp;
17213 unformat_input_t *input = vam->input;
17218 u8 mac[6] = { 0, };
17219 u8 ip6[16] = { 0, };
17223 /* Parse args required to build the message */
17224 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17226 if (unformat (input, "del"))
17228 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17230 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
17232 else if (unformat (input, "bd %d", &bd))
17236 errmsg ("parse error '%U'", format_unformat_error, input);
17241 if (!bd_set || !ip_set || (!mac_set && is_add))
17243 errmsg ("Missing BD, IP or MAC!");
17247 M (ONE_ADD_DEL_NDP_ENTRY, mp);
17248 mp->is_add = is_add;
17249 clib_memcpy (mp->mac, mac, 6);
17250 mp->bd = clib_host_to_net_u32 (bd);
17251 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
17256 /* wait for reply */
17262 api_one_add_del_l2_arp_entry (vat_main_t * vam)
17264 vl_api_one_add_del_l2_arp_entry_t *mp;
17265 unformat_input_t *input = vam->input;
17270 u8 mac[6] = { 0, };
17271 u32 ip4 = 0, bd = ~0;
17274 /* Parse args required to build the message */
17275 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17277 if (unformat (input, "del"))
17279 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17281 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
17283 else if (unformat (input, "bd %d", &bd))
17287 errmsg ("parse error '%U'", format_unformat_error, input);
17292 if (!bd_set || !ip_set || (!mac_set && is_add))
17294 errmsg ("Missing BD, IP or MAC!");
17298 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
17299 mp->is_add = is_add;
17300 clib_memcpy (mp->mac, mac, 6);
17301 mp->bd = clib_host_to_net_u32 (bd);
17307 /* wait for reply */
17313 api_one_ndp_bd_get (vat_main_t * vam)
17315 vl_api_one_ndp_bd_get_t *mp;
17318 M (ONE_NDP_BD_GET, mp);
17323 /* wait for reply */
17329 api_one_ndp_entries_get (vat_main_t * vam)
17331 vl_api_one_ndp_entries_get_t *mp;
17332 unformat_input_t *input = vam->input;
17337 /* Parse args required to build the message */
17338 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17340 if (unformat (input, "bd %d", &bd))
17344 errmsg ("parse error '%U'", format_unformat_error, input);
17351 errmsg ("Expected bridge domain!");
17355 M (ONE_NDP_ENTRIES_GET, mp);
17356 mp->bd = clib_host_to_net_u32 (bd);
17361 /* wait for reply */
17367 api_one_l2_arp_bd_get (vat_main_t * vam)
17369 vl_api_one_l2_arp_bd_get_t *mp;
17372 M (ONE_L2_ARP_BD_GET, mp);
17377 /* wait for reply */
17383 api_one_l2_arp_entries_get (vat_main_t * vam)
17385 vl_api_one_l2_arp_entries_get_t *mp;
17386 unformat_input_t *input = vam->input;
17391 /* Parse args required to build the message */
17392 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17394 if (unformat (input, "bd %d", &bd))
17398 errmsg ("parse error '%U'", format_unformat_error, input);
17405 errmsg ("Expected bridge domain!");
17409 M (ONE_L2_ARP_ENTRIES_GET, mp);
17410 mp->bd = clib_host_to_net_u32 (bd);
17415 /* wait for reply */
17421 api_one_stats_enable_disable (vat_main_t * vam)
17423 vl_api_one_stats_enable_disable_t *mp;
17424 unformat_input_t *input = vam->input;
17429 /* Parse args required to build the message */
17430 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17432 if (unformat (input, "enable"))
17437 else if (unformat (input, "disable"))
17447 errmsg ("Value not set");
17451 M (ONE_STATS_ENABLE_DISABLE, mp);
17457 /* wait for reply */
17463 api_show_one_stats_enable_disable (vat_main_t * vam)
17465 vl_api_show_one_stats_enable_disable_t *mp;
17468 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
17473 /* wait for reply */
17479 api_show_one_map_request_mode (vat_main_t * vam)
17481 vl_api_show_one_map_request_mode_t *mp;
17484 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
17489 /* wait for reply */
17494 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
17497 api_one_map_request_mode (vat_main_t * vam)
17499 unformat_input_t *input = vam->input;
17500 vl_api_one_map_request_mode_t *mp;
17504 /* Parse args required to build the message */
17505 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17507 if (unformat (input, "dst-only"))
17509 else if (unformat (input, "src-dst"))
17513 errmsg ("parse error '%U'", format_unformat_error, input);
17518 M (ONE_MAP_REQUEST_MODE, mp);
17525 /* wait for reply */
17530 #define api_lisp_map_request_mode api_one_map_request_mode
17533 * Enable/disable ONE proxy ITR.
17535 * @param vam vpp API test context
17536 * @return return code
17539 api_one_pitr_set_locator_set (vat_main_t * vam)
17541 u8 ls_name_set = 0;
17542 unformat_input_t *input = vam->input;
17543 vl_api_one_pitr_set_locator_set_t *mp;
17548 /* Parse args required to build the message */
17549 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17551 if (unformat (input, "del"))
17553 else if (unformat (input, "locator-set %s", &ls_name))
17557 errmsg ("parse error '%U'", format_unformat_error, input);
17564 errmsg ("locator-set name not set!");
17568 M (ONE_PITR_SET_LOCATOR_SET, mp);
17570 mp->is_add = is_add;
17571 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
17572 vec_free (ls_name);
17577 /* wait for reply */
17582 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
17585 api_one_nsh_set_locator_set (vat_main_t * vam)
17587 u8 ls_name_set = 0;
17588 unformat_input_t *input = vam->input;
17589 vl_api_one_nsh_set_locator_set_t *mp;
17594 /* Parse args required to build the message */
17595 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17597 if (unformat (input, "del"))
17599 else if (unformat (input, "ls %s", &ls_name))
17603 errmsg ("parse error '%U'", format_unformat_error, input);
17608 if (!ls_name_set && is_add)
17610 errmsg ("locator-set name not set!");
17614 M (ONE_NSH_SET_LOCATOR_SET, mp);
17616 mp->is_add = is_add;
17617 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
17618 vec_free (ls_name);
17623 /* wait for reply */
17629 api_show_one_pitr (vat_main_t * vam)
17631 vl_api_show_one_pitr_t *mp;
17634 if (!vam->json_output)
17636 print (vam->ofp, "%=20s", "lisp status:");
17639 M (SHOW_ONE_PITR, mp);
17643 /* Wait for a reply... */
17648 #define api_show_lisp_pitr api_show_one_pitr
17651 api_one_use_petr (vat_main_t * vam)
17653 unformat_input_t *input = vam->input;
17654 vl_api_one_use_petr_t *mp;
17659 memset (&ip, 0, sizeof (ip));
17661 /* Parse args required to build the message */
17662 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17664 if (unformat (input, "disable"))
17667 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
17670 ip_addr_version (&ip) = IP4;
17673 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
17676 ip_addr_version (&ip) = IP6;
17680 errmsg ("parse error '%U'", format_unformat_error, input);
17685 M (ONE_USE_PETR, mp);
17687 mp->is_add = is_add;
17690 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
17692 clib_memcpy (mp->address, &ip, 4);
17694 clib_memcpy (mp->address, &ip, 16);
17700 /* wait for reply */
17705 #define api_lisp_use_petr api_one_use_petr
17708 api_show_one_nsh_mapping (vat_main_t * vam)
17710 vl_api_show_one_use_petr_t *mp;
17713 if (!vam->json_output)
17715 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
17718 M (SHOW_ONE_NSH_MAPPING, mp);
17722 /* Wait for a reply... */
17728 api_show_one_use_petr (vat_main_t * vam)
17730 vl_api_show_one_use_petr_t *mp;
17733 if (!vam->json_output)
17735 print (vam->ofp, "%=20s", "Proxy-ETR status:");
17738 M (SHOW_ONE_USE_PETR, mp);
17742 /* Wait for a reply... */
17747 #define api_show_lisp_use_petr api_show_one_use_petr
17750 * Add/delete mapping between vni and vrf
17753 api_one_eid_table_add_del_map (vat_main_t * vam)
17755 unformat_input_t *input = vam->input;
17756 vl_api_one_eid_table_add_del_map_t *mp;
17757 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
17758 u32 vni, vrf, bd_index;
17761 /* Parse args required to build the message */
17762 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17764 if (unformat (input, "del"))
17766 else if (unformat (input, "vrf %d", &vrf))
17768 else if (unformat (input, "bd_index %d", &bd_index))
17770 else if (unformat (input, "vni %d", &vni))
17776 if (!vni_set || (!vrf_set && !bd_index_set))
17778 errmsg ("missing arguments!");
17782 if (vrf_set && bd_index_set)
17784 errmsg ("error: both vrf and bd entered!");
17788 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
17790 mp->is_add = is_add;
17791 mp->vni = htonl (vni);
17792 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
17793 mp->is_l2 = bd_index_set;
17798 /* wait for reply */
17803 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
17806 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
17808 u32 *action = va_arg (*args, u32 *);
17811 if (unformat (input, "%s", &s))
17813 if (!strcmp ((char *) s, "no-action"))
17815 else if (!strcmp ((char *) s, "natively-forward"))
17817 else if (!strcmp ((char *) s, "send-map-request"))
17819 else if (!strcmp ((char *) s, "drop"))
17823 clib_warning ("invalid action: '%s'", s);
17835 * Add/del remote mapping to/from ONE control plane
17837 * @param vam vpp API test context
17838 * @return return code
17841 api_one_add_del_remote_mapping (vat_main_t * vam)
17843 unformat_input_t *input = vam->input;
17844 vl_api_one_add_del_remote_mapping_t *mp;
17846 lisp_eid_vat_t _eid, *eid = &_eid;
17847 lisp_eid_vat_t _seid, *seid = &_seid;
17848 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
17849 u32 action = ~0, p, w, data_len;
17850 ip4_address_t rloc4;
17851 ip6_address_t rloc6;
17852 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
17855 memset (&rloc, 0, sizeof (rloc));
17857 /* Parse args required to build the message */
17858 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17860 if (unformat (input, "del-all"))
17864 else if (unformat (input, "del"))
17868 else if (unformat (input, "add"))
17872 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
17876 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
17880 else if (unformat (input, "vni %d", &vni))
17884 else if (unformat (input, "p %d w %d", &p, &w))
17888 errmsg ("No RLOC configured for setting priority/weight!");
17891 curr_rloc->priority = p;
17892 curr_rloc->weight = w;
17894 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
17897 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
17898 vec_add1 (rlocs, rloc);
17899 curr_rloc = &rlocs[vec_len (rlocs) - 1];
17901 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
17904 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
17905 vec_add1 (rlocs, rloc);
17906 curr_rloc = &rlocs[vec_len (rlocs) - 1];
17908 else if (unformat (input, "action %U",
17909 unformat_negative_mapping_action, &action))
17915 clib_warning ("parse error '%U'", format_unformat_error, input);
17922 errmsg ("missing params!");
17926 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
17928 errmsg ("no action set for negative map-reply!");
17932 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
17934 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
17935 mp->is_add = is_add;
17936 mp->vni = htonl (vni);
17937 mp->action = (u8) action;
17938 mp->is_src_dst = seid_set;
17939 mp->eid_len = eid->len;
17940 mp->seid_len = seid->len;
17941 mp->del_all = del_all;
17942 mp->eid_type = eid->type;
17943 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
17944 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
17946 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
17947 clib_memcpy (mp->rlocs, rlocs, data_len);
17953 /* Wait for a reply... */
17958 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
17961 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
17962 * forwarding entries in data-plane accordingly.
17964 * @param vam vpp API test context
17965 * @return return code
17968 api_one_add_del_adjacency (vat_main_t * vam)
17970 unformat_input_t *input = vam->input;
17971 vl_api_one_add_del_adjacency_t *mp;
17973 ip4_address_t leid4, reid4;
17974 ip6_address_t leid6, reid6;
17975 u8 reid_mac[6] = { 0 };
17976 u8 leid_mac[6] = { 0 };
17977 u8 reid_type, leid_type;
17978 u32 leid_len = 0, reid_len = 0, len;
17982 leid_type = reid_type = (u8) ~ 0;
17984 /* Parse args required to build the message */
17985 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17987 if (unformat (input, "del"))
17991 else if (unformat (input, "add"))
17995 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
17998 reid_type = 0; /* ipv4 */
18001 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
18004 reid_type = 1; /* ipv6 */
18007 else if (unformat (input, "reid %U", unformat_ethernet_address,
18010 reid_type = 2; /* mac */
18012 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
18015 leid_type = 0; /* ipv4 */
18018 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
18021 leid_type = 1; /* ipv6 */
18024 else if (unformat (input, "leid %U", unformat_ethernet_address,
18027 leid_type = 2; /* mac */
18029 else if (unformat (input, "vni %d", &vni))
18035 errmsg ("parse error '%U'", format_unformat_error, input);
18040 if ((u8) ~ 0 == reid_type)
18042 errmsg ("missing params!");
18046 if (leid_type != reid_type)
18048 errmsg ("remote and local EIDs are of different types!");
18052 M (ONE_ADD_DEL_ADJACENCY, mp);
18053 mp->is_add = is_add;
18054 mp->vni = htonl (vni);
18055 mp->leid_len = leid_len;
18056 mp->reid_len = reid_len;
18057 mp->eid_type = reid_type;
18059 switch (mp->eid_type)
18062 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
18063 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
18066 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
18067 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
18070 clib_memcpy (mp->leid, leid_mac, 6);
18071 clib_memcpy (mp->reid, reid_mac, 6);
18074 errmsg ("unknown EID type %d!", mp->eid_type);
18081 /* Wait for a reply... */
18086 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
18089 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
18091 u32 *mode = va_arg (*args, u32 *);
18093 if (unformat (input, "lisp"))
18095 else if (unformat (input, "vxlan"))
18104 api_gpe_get_encap_mode (vat_main_t * vam)
18106 vl_api_gpe_get_encap_mode_t *mp;
18109 /* Construct the API message */
18110 M (GPE_GET_ENCAP_MODE, mp);
18115 /* Wait for a reply... */
18121 api_gpe_set_encap_mode (vat_main_t * vam)
18123 unformat_input_t *input = vam->input;
18124 vl_api_gpe_set_encap_mode_t *mp;
18128 /* Parse args required to build the message */
18129 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18131 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
18137 /* Construct the API message */
18138 M (GPE_SET_ENCAP_MODE, mp);
18145 /* Wait for a reply... */
18151 api_lisp_gpe_add_del_iface (vat_main_t * vam)
18153 unformat_input_t *input = vam->input;
18154 vl_api_gpe_add_del_iface_t *mp;
18155 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
18156 u32 dp_table = 0, vni = 0;
18159 /* Parse args required to build the message */
18160 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18162 if (unformat (input, "up"))
18167 else if (unformat (input, "down"))
18172 else if (unformat (input, "table_id %d", &dp_table))
18176 else if (unformat (input, "bd_id %d", &dp_table))
18181 else if (unformat (input, "vni %d", &vni))
18189 if (action_set == 0)
18191 errmsg ("Action not set");
18194 if (dp_table_set == 0 || vni_set == 0)
18196 errmsg ("vni and dp_table must be set");
18200 /* Construct the API message */
18201 M (GPE_ADD_DEL_IFACE, mp);
18203 mp->is_add = is_add;
18204 mp->dp_table = clib_host_to_net_u32 (dp_table);
18206 mp->vni = clib_host_to_net_u32 (vni);
18211 /* Wait for a reply... */
18217 api_one_map_register_fallback_threshold (vat_main_t * vam)
18219 unformat_input_t *input = vam->input;
18220 vl_api_one_map_register_fallback_threshold_t *mp;
18225 /* Parse args required to build the message */
18226 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18228 if (unformat (input, "%u", &value))
18232 clib_warning ("parse error '%U'", format_unformat_error, input);
18239 errmsg ("fallback threshold value is missing!");
18243 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18244 mp->value = clib_host_to_net_u32 (value);
18249 /* Wait for a reply... */
18255 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
18257 vl_api_show_one_map_register_fallback_threshold_t *mp;
18260 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18265 /* Wait for a reply... */
18271 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
18273 u32 *proto = va_arg (*args, u32 *);
18275 if (unformat (input, "udp"))
18277 else if (unformat (input, "api"))
18286 api_one_set_transport_protocol (vat_main_t * vam)
18288 unformat_input_t *input = vam->input;
18289 vl_api_one_set_transport_protocol_t *mp;
18294 /* Parse args required to build the message */
18295 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18297 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
18301 clib_warning ("parse error '%U'", format_unformat_error, input);
18308 errmsg ("Transport protocol missing!");
18312 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
18313 mp->protocol = (u8) protocol;
18318 /* Wait for a reply... */
18324 api_one_get_transport_protocol (vat_main_t * vam)
18326 vl_api_one_get_transport_protocol_t *mp;
18329 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
18334 /* Wait for a reply... */
18340 api_one_map_register_set_ttl (vat_main_t * vam)
18342 unformat_input_t *input = vam->input;
18343 vl_api_one_map_register_set_ttl_t *mp;
18348 /* Parse args required to build the message */
18349 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18351 if (unformat (input, "%u", &ttl))
18355 clib_warning ("parse error '%U'", format_unformat_error, input);
18362 errmsg ("TTL value missing!");
18366 M (ONE_MAP_REGISTER_SET_TTL, mp);
18367 mp->ttl = clib_host_to_net_u32 (ttl);
18372 /* Wait for a reply... */
18378 api_show_one_map_register_ttl (vat_main_t * vam)
18380 vl_api_show_one_map_register_ttl_t *mp;
18383 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
18388 /* Wait for a reply... */
18394 * Add/del map request itr rlocs from ONE control plane and updates
18396 * @param vam vpp API test context
18397 * @return return code
18400 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
18402 unformat_input_t *input = vam->input;
18403 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
18404 u8 *locator_set_name = 0;
18405 u8 locator_set_name_set = 0;
18409 /* Parse args required to build the message */
18410 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18412 if (unformat (input, "del"))
18416 else if (unformat (input, "%_%v%_", &locator_set_name))
18418 locator_set_name_set = 1;
18422 clib_warning ("parse error '%U'", format_unformat_error, input);
18427 if (is_add && !locator_set_name_set)
18429 errmsg ("itr-rloc is not set!");
18433 if (is_add && vec_len (locator_set_name) > 64)
18435 errmsg ("itr-rloc locator-set name too long");
18436 vec_free (locator_set_name);
18440 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
18441 mp->is_add = is_add;
18444 clib_memcpy (mp->locator_set_name, locator_set_name,
18445 vec_len (locator_set_name));
18449 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
18451 vec_free (locator_set_name);
18456 /* Wait for a reply... */
18461 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
18464 api_one_locator_dump (vat_main_t * vam)
18466 unformat_input_t *input = vam->input;
18467 vl_api_one_locator_dump_t *mp;
18468 vl_api_control_ping_t *mp_ping;
18469 u8 is_index_set = 0, is_name_set = 0;
18474 /* Parse args required to build the message */
18475 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18477 if (unformat (input, "ls_name %_%v%_", &ls_name))
18481 else if (unformat (input, "ls_index %d", &ls_index))
18487 errmsg ("parse error '%U'", format_unformat_error, input);
18492 if (!is_index_set && !is_name_set)
18494 errmsg ("error: expected one of index or name!");
18498 if (is_index_set && is_name_set)
18500 errmsg ("error: only one param expected!");
18504 if (vec_len (ls_name) > 62)
18506 errmsg ("error: locator set name too long!");
18510 if (!vam->json_output)
18512 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
18515 M (ONE_LOCATOR_DUMP, mp);
18516 mp->is_index_set = is_index_set;
18519 mp->ls_index = clib_host_to_net_u32 (ls_index);
18522 vec_add1 (ls_name, 0);
18523 strncpy ((char *) mp->ls_name, (char *) ls_name,
18524 sizeof (mp->ls_name) - 1);
18530 /* Use a control ping for synchronization */
18531 MPING (CONTROL_PING, mp_ping);
18534 /* Wait for a reply... */
18539 #define api_lisp_locator_dump api_one_locator_dump
18542 api_one_locator_set_dump (vat_main_t * vam)
18544 vl_api_one_locator_set_dump_t *mp;
18545 vl_api_control_ping_t *mp_ping;
18546 unformat_input_t *input = vam->input;
18550 /* Parse args required to build the message */
18551 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18553 if (unformat (input, "local"))
18557 else if (unformat (input, "remote"))
18563 errmsg ("parse error '%U'", format_unformat_error, input);
18568 if (!vam->json_output)
18570 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
18573 M (ONE_LOCATOR_SET_DUMP, mp);
18575 mp->filter = filter;
18580 /* Use a control ping for synchronization */
18581 MPING (CONTROL_PING, mp_ping);
18584 /* Wait for a reply... */
18589 #define api_lisp_locator_set_dump api_one_locator_set_dump
18592 api_one_eid_table_map_dump (vat_main_t * vam)
18596 unformat_input_t *input = vam->input;
18597 vl_api_one_eid_table_map_dump_t *mp;
18598 vl_api_control_ping_t *mp_ping;
18601 /* Parse args required to build the message */
18602 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18604 if (unformat (input, "l2"))
18609 else if (unformat (input, "l3"))
18616 errmsg ("parse error '%U'", format_unformat_error, input);
18623 errmsg ("expected one of 'l2' or 'l3' parameter!");
18627 if (!vam->json_output)
18629 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
18632 M (ONE_EID_TABLE_MAP_DUMP, mp);
18638 /* Use a control ping for synchronization */
18639 MPING (CONTROL_PING, mp_ping);
18642 /* Wait for a reply... */
18647 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
18650 api_one_eid_table_vni_dump (vat_main_t * vam)
18652 vl_api_one_eid_table_vni_dump_t *mp;
18653 vl_api_control_ping_t *mp_ping;
18656 if (!vam->json_output)
18658 print (vam->ofp, "VNI");
18661 M (ONE_EID_TABLE_VNI_DUMP, mp);
18666 /* Use a control ping for synchronization */
18667 MPING (CONTROL_PING, mp_ping);
18670 /* Wait for a reply... */
18675 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
18678 api_one_eid_table_dump (vat_main_t * vam)
18680 unformat_input_t *i = vam->input;
18681 vl_api_one_eid_table_dump_t *mp;
18682 vl_api_control_ping_t *mp_ping;
18683 struct in_addr ip4;
18684 struct in6_addr ip6;
18686 u8 eid_type = ~0, eid_set = 0;
18687 u32 prefix_length = ~0, t, vni = 0;
18690 lisp_nsh_api_t nsh;
18692 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18694 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
18700 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
18706 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
18711 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
18716 else if (unformat (i, "vni %d", &t))
18720 else if (unformat (i, "local"))
18724 else if (unformat (i, "remote"))
18730 errmsg ("parse error '%U'", format_unformat_error, i);
18735 if (!vam->json_output)
18737 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
18738 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
18741 M (ONE_EID_TABLE_DUMP, mp);
18743 mp->filter = filter;
18747 mp->vni = htonl (vni);
18748 mp->eid_type = eid_type;
18752 mp->prefix_length = prefix_length;
18753 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
18756 mp->prefix_length = prefix_length;
18757 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
18760 clib_memcpy (mp->eid, mac, sizeof (mac));
18763 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
18766 errmsg ("unknown EID type %d!", eid_type);
18774 /* Use a control ping for synchronization */
18775 MPING (CONTROL_PING, mp_ping);
18778 /* Wait for a reply... */
18783 #define api_lisp_eid_table_dump api_one_eid_table_dump
18786 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
18788 unformat_input_t *i = vam->input;
18789 vl_api_gpe_fwd_entries_get_t *mp;
18794 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18796 if (unformat (i, "vni %d", &vni))
18802 errmsg ("parse error '%U'", format_unformat_error, i);
18809 errmsg ("vni not set!");
18813 if (!vam->json_output)
18815 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
18819 M (GPE_FWD_ENTRIES_GET, mp);
18820 mp->vni = clib_host_to_net_u32 (vni);
18825 /* Wait for a reply... */
18830 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
18831 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
18832 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
18833 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
18834 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
18835 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
18836 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
18837 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
18840 api_one_adjacencies_get (vat_main_t * vam)
18842 unformat_input_t *i = vam->input;
18843 vl_api_one_adjacencies_get_t *mp;
18848 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18850 if (unformat (i, "vni %d", &vni))
18856 errmsg ("parse error '%U'", format_unformat_error, i);
18863 errmsg ("vni not set!");
18867 if (!vam->json_output)
18869 print (vam->ofp, "%s %40s", "leid", "reid");
18872 M (ONE_ADJACENCIES_GET, mp);
18873 mp->vni = clib_host_to_net_u32 (vni);
18878 /* Wait for a reply... */
18883 #define api_lisp_adjacencies_get api_one_adjacencies_get
18886 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
18888 unformat_input_t *i = vam->input;
18889 vl_api_gpe_native_fwd_rpaths_get_t *mp;
18891 u8 ip_family_set = 0, is_ip4 = 1;
18893 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18895 if (unformat (i, "ip4"))
18900 else if (unformat (i, "ip6"))
18907 errmsg ("parse error '%U'", format_unformat_error, i);
18912 if (!ip_family_set)
18914 errmsg ("ip family not set!");
18918 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
18919 mp->is_ip4 = is_ip4;
18924 /* Wait for a reply... */
18930 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
18932 vl_api_gpe_fwd_entry_vnis_get_t *mp;
18935 if (!vam->json_output)
18937 print (vam->ofp, "VNIs");
18940 M (GPE_FWD_ENTRY_VNIS_GET, mp);
18945 /* Wait for a reply... */
18951 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
18953 unformat_input_t *i = vam->input;
18954 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
18956 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
18957 struct in_addr ip4;
18958 struct in6_addr ip6;
18959 u32 table_id = 0, nh_sw_if_index = ~0;
18961 memset (&ip4, 0, sizeof (ip4));
18962 memset (&ip6, 0, sizeof (ip6));
18964 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18966 if (unformat (i, "del"))
18968 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
18969 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18974 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
18975 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18980 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
18984 nh_sw_if_index = ~0;
18986 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
18990 nh_sw_if_index = ~0;
18992 else if (unformat (i, "table %d", &table_id))
18996 errmsg ("parse error '%U'", format_unformat_error, i);
19003 errmsg ("nh addr not set!");
19007 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
19008 mp->is_add = is_add;
19009 mp->table_id = clib_host_to_net_u32 (table_id);
19010 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
19011 mp->is_ip4 = is_ip4;
19013 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
19015 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
19020 /* Wait for a reply... */
19026 api_one_map_server_dump (vat_main_t * vam)
19028 vl_api_one_map_server_dump_t *mp;
19029 vl_api_control_ping_t *mp_ping;
19032 if (!vam->json_output)
19034 print (vam->ofp, "%=20s", "Map server");
19037 M (ONE_MAP_SERVER_DUMP, mp);
19041 /* Use a control ping for synchronization */
19042 MPING (CONTROL_PING, mp_ping);
19045 /* Wait for a reply... */
19050 #define api_lisp_map_server_dump api_one_map_server_dump
19053 api_one_map_resolver_dump (vat_main_t * vam)
19055 vl_api_one_map_resolver_dump_t *mp;
19056 vl_api_control_ping_t *mp_ping;
19059 if (!vam->json_output)
19061 print (vam->ofp, "%=20s", "Map resolver");
19064 M (ONE_MAP_RESOLVER_DUMP, mp);
19068 /* Use a control ping for synchronization */
19069 MPING (CONTROL_PING, mp_ping);
19072 /* Wait for a reply... */
19077 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
19080 api_one_stats_flush (vat_main_t * vam)
19082 vl_api_one_stats_flush_t *mp;
19085 M (ONE_STATS_FLUSH, mp);
19092 api_one_stats_dump (vat_main_t * vam)
19094 vl_api_one_stats_dump_t *mp;
19095 vl_api_control_ping_t *mp_ping;
19098 M (ONE_STATS_DUMP, mp);
19102 /* Use a control ping for synchronization */
19103 MPING (CONTROL_PING, mp_ping);
19106 /* Wait for a reply... */
19112 api_show_one_status (vat_main_t * vam)
19114 vl_api_show_one_status_t *mp;
19117 if (!vam->json_output)
19119 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
19122 M (SHOW_ONE_STATUS, mp);
19125 /* Wait for a reply... */
19130 #define api_show_lisp_status api_show_one_status
19133 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
19135 vl_api_gpe_fwd_entry_path_dump_t *mp;
19136 vl_api_control_ping_t *mp_ping;
19137 unformat_input_t *i = vam->input;
19138 u32 fwd_entry_index = ~0;
19141 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19143 if (unformat (i, "index %d", &fwd_entry_index))
19149 if (~0 == fwd_entry_index)
19151 errmsg ("no index specified!");
19155 if (!vam->json_output)
19157 print (vam->ofp, "first line");
19160 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
19164 /* Use a control ping for synchronization */
19165 MPING (CONTROL_PING, mp_ping);
19168 /* Wait for a reply... */
19174 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
19176 vl_api_one_get_map_request_itr_rlocs_t *mp;
19179 if (!vam->json_output)
19181 print (vam->ofp, "%=20s", "itr-rlocs:");
19184 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
19187 /* Wait for a reply... */
19192 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
19195 api_af_packet_create (vat_main_t * vam)
19197 unformat_input_t *i = vam->input;
19198 vl_api_af_packet_create_t *mp;
19199 u8 *host_if_name = 0;
19201 u8 random_hw_addr = 1;
19204 memset (hw_addr, 0, sizeof (hw_addr));
19206 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19208 if (unformat (i, "name %s", &host_if_name))
19209 vec_add1 (host_if_name, 0);
19210 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19211 random_hw_addr = 0;
19216 if (!vec_len (host_if_name))
19218 errmsg ("host-interface name must be specified");
19222 if (vec_len (host_if_name) > 64)
19224 errmsg ("host-interface name too long");
19228 M (AF_PACKET_CREATE, mp);
19230 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19231 clib_memcpy (mp->hw_addr, hw_addr, 6);
19232 mp->use_random_hw_addr = random_hw_addr;
19233 vec_free (host_if_name);
19241 fprintf (vam->ofp ? vam->ofp : stderr,
19242 " new sw_if_index = %d\n", vam->sw_if_index);
19249 api_af_packet_delete (vat_main_t * vam)
19251 unformat_input_t *i = vam->input;
19252 vl_api_af_packet_delete_t *mp;
19253 u8 *host_if_name = 0;
19256 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19258 if (unformat (i, "name %s", &host_if_name))
19259 vec_add1 (host_if_name, 0);
19264 if (!vec_len (host_if_name))
19266 errmsg ("host-interface name must be specified");
19270 if (vec_len (host_if_name) > 64)
19272 errmsg ("host-interface name too long");
19276 M (AF_PACKET_DELETE, mp);
19278 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19279 vec_free (host_if_name);
19287 api_policer_add_del (vat_main_t * vam)
19289 unformat_input_t *i = vam->input;
19290 vl_api_policer_add_del_t *mp;
19300 u8 color_aware = 0;
19301 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
19304 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
19305 conform_action.dscp = 0;
19306 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
19307 exceed_action.dscp = 0;
19308 violate_action.action_type = SSE2_QOS_ACTION_DROP;
19309 violate_action.dscp = 0;
19311 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19313 if (unformat (i, "del"))
19315 else if (unformat (i, "name %s", &name))
19316 vec_add1 (name, 0);
19317 else if (unformat (i, "cir %u", &cir))
19319 else if (unformat (i, "eir %u", &eir))
19321 else if (unformat (i, "cb %u", &cb))
19323 else if (unformat (i, "eb %u", &eb))
19325 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
19328 else if (unformat (i, "round_type %U", unformat_policer_round_type,
19331 else if (unformat (i, "type %U", unformat_policer_type, &type))
19333 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
19336 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
19339 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
19342 else if (unformat (i, "color-aware"))
19348 if (!vec_len (name))
19350 errmsg ("policer name must be specified");
19354 if (vec_len (name) > 64)
19356 errmsg ("policer name too long");
19360 M (POLICER_ADD_DEL, mp);
19362 clib_memcpy (mp->name, name, vec_len (name));
19364 mp->is_add = is_add;
19365 mp->cir = ntohl (cir);
19366 mp->eir = ntohl (eir);
19367 mp->cb = clib_net_to_host_u64 (cb);
19368 mp->eb = clib_net_to_host_u64 (eb);
19369 mp->rate_type = rate_type;
19370 mp->round_type = round_type;
19372 mp->conform_action_type = conform_action.action_type;
19373 mp->conform_dscp = conform_action.dscp;
19374 mp->exceed_action_type = exceed_action.action_type;
19375 mp->exceed_dscp = exceed_action.dscp;
19376 mp->violate_action_type = violate_action.action_type;
19377 mp->violate_dscp = violate_action.dscp;
19378 mp->color_aware = color_aware;
19386 api_policer_dump (vat_main_t * vam)
19388 unformat_input_t *i = vam->input;
19389 vl_api_policer_dump_t *mp;
19390 vl_api_control_ping_t *mp_ping;
19391 u8 *match_name = 0;
19392 u8 match_name_valid = 0;
19395 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19397 if (unformat (i, "name %s", &match_name))
19399 vec_add1 (match_name, 0);
19400 match_name_valid = 1;
19406 M (POLICER_DUMP, mp);
19407 mp->match_name_valid = match_name_valid;
19408 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
19409 vec_free (match_name);
19413 /* Use a control ping for synchronization */
19414 MPING (CONTROL_PING, mp_ping);
19417 /* Wait for a reply... */
19423 api_policer_classify_set_interface (vat_main_t * vam)
19425 unformat_input_t *i = vam->input;
19426 vl_api_policer_classify_set_interface_t *mp;
19428 int sw_if_index_set;
19429 u32 ip4_table_index = ~0;
19430 u32 ip6_table_index = ~0;
19431 u32 l2_table_index = ~0;
19435 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19437 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19438 sw_if_index_set = 1;
19439 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19440 sw_if_index_set = 1;
19441 else if (unformat (i, "del"))
19443 else if (unformat (i, "ip4-table %d", &ip4_table_index))
19445 else if (unformat (i, "ip6-table %d", &ip6_table_index))
19447 else if (unformat (i, "l2-table %d", &l2_table_index))
19451 clib_warning ("parse error '%U'", format_unformat_error, i);
19456 if (sw_if_index_set == 0)
19458 errmsg ("missing interface name or sw_if_index");
19462 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
19464 mp->sw_if_index = ntohl (sw_if_index);
19465 mp->ip4_table_index = ntohl (ip4_table_index);
19466 mp->ip6_table_index = ntohl (ip6_table_index);
19467 mp->l2_table_index = ntohl (l2_table_index);
19468 mp->is_add = is_add;
19476 api_policer_classify_dump (vat_main_t * vam)
19478 unformat_input_t *i = vam->input;
19479 vl_api_policer_classify_dump_t *mp;
19480 vl_api_control_ping_t *mp_ping;
19481 u8 type = POLICER_CLASSIFY_N_TABLES;
19484 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
19488 errmsg ("classify table type must be specified");
19492 if (!vam->json_output)
19494 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
19497 M (POLICER_CLASSIFY_DUMP, mp);
19502 /* Use a control ping for synchronization */
19503 MPING (CONTROL_PING, mp_ping);
19506 /* Wait for a reply... */
19512 api_netmap_create (vat_main_t * vam)
19514 unformat_input_t *i = vam->input;
19515 vl_api_netmap_create_t *mp;
19518 u8 random_hw_addr = 1;
19523 memset (hw_addr, 0, sizeof (hw_addr));
19525 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19527 if (unformat (i, "name %s", &if_name))
19528 vec_add1 (if_name, 0);
19529 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19530 random_hw_addr = 0;
19531 else if (unformat (i, "pipe"))
19533 else if (unformat (i, "master"))
19535 else if (unformat (i, "slave"))
19541 if (!vec_len (if_name))
19543 errmsg ("interface name must be specified");
19547 if (vec_len (if_name) > 64)
19549 errmsg ("interface name too long");
19553 M (NETMAP_CREATE, mp);
19555 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
19556 clib_memcpy (mp->hw_addr, hw_addr, 6);
19557 mp->use_random_hw_addr = random_hw_addr;
19558 mp->is_pipe = is_pipe;
19559 mp->is_master = is_master;
19560 vec_free (if_name);
19568 api_netmap_delete (vat_main_t * vam)
19570 unformat_input_t *i = vam->input;
19571 vl_api_netmap_delete_t *mp;
19575 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19577 if (unformat (i, "name %s", &if_name))
19578 vec_add1 (if_name, 0);
19583 if (!vec_len (if_name))
19585 errmsg ("interface name must be specified");
19589 if (vec_len (if_name) > 64)
19591 errmsg ("interface name too long");
19595 M (NETMAP_DELETE, mp);
19597 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
19598 vec_free (if_name);
19606 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path2_t * fp)
19608 if (fp->afi == IP46_TYPE_IP6)
19610 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19611 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19612 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19613 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19614 format_ip6_address, fp->next_hop);
19615 else if (fp->afi == IP46_TYPE_IP4)
19617 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19618 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19619 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19620 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19621 format_ip4_address, fp->next_hop);
19625 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
19626 vl_api_fib_path2_t * fp)
19628 struct in_addr ip4;
19629 struct in6_addr ip6;
19631 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19632 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19633 vat_json_object_add_uint (node, "is_local", fp->is_local);
19634 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19635 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19636 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19637 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19638 if (fp->afi == IP46_TYPE_IP4)
19640 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19641 vat_json_object_add_ip4 (node, "next_hop", ip4);
19643 else if (fp->afi == IP46_TYPE_IP6)
19645 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19646 vat_json_object_add_ip6 (node, "next_hop", ip6);
19651 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
19653 vat_main_t *vam = &vat_main;
19654 int count = ntohl (mp->mt_count);
19655 vl_api_fib_path2_t *fp;
19658 print (vam->ofp, "[%d]: sw_if_index %d via:",
19659 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
19661 for (i = 0; i < count; i++)
19663 vl_api_mpls_fib_path_print (vam, fp);
19667 print (vam->ofp, "");
19670 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
19671 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
19674 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
19676 vat_main_t *vam = &vat_main;
19677 vat_json_node_t *node = NULL;
19678 int count = ntohl (mp->mt_count);
19679 vl_api_fib_path2_t *fp;
19682 if (VAT_JSON_ARRAY != vam->json_tree.type)
19684 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19685 vat_json_init_array (&vam->json_tree);
19687 node = vat_json_array_add (&vam->json_tree);
19689 vat_json_init_object (node);
19690 vat_json_object_add_uint (node, "tunnel_index",
19691 ntohl (mp->mt_tunnel_index));
19692 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
19694 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
19697 for (i = 0; i < count; i++)
19699 vl_api_mpls_fib_path_json_print (node, fp);
19705 api_mpls_tunnel_dump (vat_main_t * vam)
19707 vl_api_mpls_tunnel_dump_t *mp;
19708 vl_api_control_ping_t *mp_ping;
19712 /* Parse args required to build the message */
19713 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
19715 if (!unformat (vam->input, "tunnel_index %d", &index))
19722 print (vam->ofp, " tunnel_index %d", index);
19724 M (MPLS_TUNNEL_DUMP, mp);
19725 mp->tunnel_index = htonl (index);
19728 /* Use a control ping for synchronization */
19729 MPING (CONTROL_PING, mp_ping);
19736 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
19737 #define vl_api_mpls_fib_details_t_print vl_noop_handler
19741 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
19743 vat_main_t *vam = &vat_main;
19744 int count = ntohl (mp->count);
19745 vl_api_fib_path2_t *fp;
19749 "table-id %d, label %u, ess_bit %u",
19750 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
19752 for (i = 0; i < count; i++)
19754 vl_api_mpls_fib_path_print (vam, fp);
19759 static void vl_api_mpls_fib_details_t_handler_json
19760 (vl_api_mpls_fib_details_t * mp)
19762 vat_main_t *vam = &vat_main;
19763 int count = ntohl (mp->count);
19764 vat_json_node_t *node = NULL;
19765 vl_api_fib_path2_t *fp;
19768 if (VAT_JSON_ARRAY != vam->json_tree.type)
19770 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19771 vat_json_init_array (&vam->json_tree);
19773 node = vat_json_array_add (&vam->json_tree);
19775 vat_json_init_object (node);
19776 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19777 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
19778 vat_json_object_add_uint (node, "label", ntohl (mp->label));
19779 vat_json_object_add_uint (node, "path_count", count);
19781 for (i = 0; i < count; i++)
19783 vl_api_mpls_fib_path_json_print (node, fp);
19789 api_mpls_fib_dump (vat_main_t * vam)
19791 vl_api_mpls_fib_dump_t *mp;
19792 vl_api_control_ping_t *mp_ping;
19795 M (MPLS_FIB_DUMP, mp);
19798 /* Use a control ping for synchronization */
19799 MPING (CONTROL_PING, mp_ping);
19806 #define vl_api_ip_fib_details_t_endian vl_noop_handler
19807 #define vl_api_ip_fib_details_t_print vl_noop_handler
19810 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
19812 vat_main_t *vam = &vat_main;
19813 int count = ntohl (mp->count);
19814 vl_api_fib_path_t *fp;
19818 "table-id %d, prefix %U/%d",
19819 ntohl (mp->table_id), format_ip4_address, mp->address,
19820 mp->address_length);
19822 for (i = 0; i < count; i++)
19824 if (fp->afi == IP46_TYPE_IP6)
19826 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19827 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19828 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19829 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19830 format_ip6_address, fp->next_hop);
19831 else if (fp->afi == IP46_TYPE_IP4)
19833 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19834 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19835 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19836 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19837 format_ip4_address, fp->next_hop);
19842 static void vl_api_ip_fib_details_t_handler_json
19843 (vl_api_ip_fib_details_t * mp)
19845 vat_main_t *vam = &vat_main;
19846 int count = ntohl (mp->count);
19847 vat_json_node_t *node = NULL;
19848 struct in_addr ip4;
19849 struct in6_addr ip6;
19850 vl_api_fib_path_t *fp;
19853 if (VAT_JSON_ARRAY != vam->json_tree.type)
19855 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19856 vat_json_init_array (&vam->json_tree);
19858 node = vat_json_array_add (&vam->json_tree);
19860 vat_json_init_object (node);
19861 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19862 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
19863 vat_json_object_add_ip4 (node, "prefix", ip4);
19864 vat_json_object_add_uint (node, "mask_length", mp->address_length);
19865 vat_json_object_add_uint (node, "path_count", count);
19867 for (i = 0; i < count; i++)
19869 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19870 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19871 vat_json_object_add_uint (node, "is_local", fp->is_local);
19872 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19873 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19874 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19875 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19876 if (fp->afi == IP46_TYPE_IP4)
19878 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19879 vat_json_object_add_ip4 (node, "next_hop", ip4);
19881 else if (fp->afi == IP46_TYPE_IP6)
19883 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19884 vat_json_object_add_ip6 (node, "next_hop", ip6);
19890 api_ip_fib_dump (vat_main_t * vam)
19892 vl_api_ip_fib_dump_t *mp;
19893 vl_api_control_ping_t *mp_ping;
19896 M (IP_FIB_DUMP, mp);
19899 /* Use a control ping for synchronization */
19900 MPING (CONTROL_PING, mp_ping);
19908 api_ip_mfib_dump (vat_main_t * vam)
19910 vl_api_ip_mfib_dump_t *mp;
19911 vl_api_control_ping_t *mp_ping;
19914 M (IP_MFIB_DUMP, mp);
19917 /* Use a control ping for synchronization */
19918 MPING (CONTROL_PING, mp_ping);
19925 static void vl_api_ip_neighbor_details_t_handler
19926 (vl_api_ip_neighbor_details_t * mp)
19928 vat_main_t *vam = &vat_main;
19930 print (vam->ofp, "%c %U %U",
19931 (mp->is_static) ? 'S' : 'D',
19932 format_ethernet_address, &mp->mac_address,
19933 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
19937 static void vl_api_ip_neighbor_details_t_handler_json
19938 (vl_api_ip_neighbor_details_t * mp)
19941 vat_main_t *vam = &vat_main;
19942 vat_json_node_t *node;
19943 struct in_addr ip4;
19944 struct in6_addr ip6;
19946 if (VAT_JSON_ARRAY != vam->json_tree.type)
19948 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19949 vat_json_init_array (&vam->json_tree);
19951 node = vat_json_array_add (&vam->json_tree);
19953 vat_json_init_object (node);
19954 vat_json_object_add_string_copy (node, "flag",
19955 (mp->is_static) ? (u8 *) "static" : (u8 *)
19958 vat_json_object_add_string_copy (node, "link_layer",
19959 format (0, "%U", format_ethernet_address,
19960 &mp->mac_address));
19964 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
19965 vat_json_object_add_ip6 (node, "ip_address", ip6);
19969 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
19970 vat_json_object_add_ip4 (node, "ip_address", ip4);
19975 api_ip_neighbor_dump (vat_main_t * vam)
19977 unformat_input_t *i = vam->input;
19978 vl_api_ip_neighbor_dump_t *mp;
19979 vl_api_control_ping_t *mp_ping;
19981 u32 sw_if_index = ~0;
19984 /* Parse args required to build the message */
19985 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19987 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19989 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19991 else if (unformat (i, "ip6"))
19997 if (sw_if_index == ~0)
19999 errmsg ("missing interface name or sw_if_index");
20003 M (IP_NEIGHBOR_DUMP, mp);
20004 mp->is_ipv6 = (u8) is_ipv6;
20005 mp->sw_if_index = ntohl (sw_if_index);
20008 /* Use a control ping for synchronization */
20009 MPING (CONTROL_PING, mp_ping);
20016 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
20017 #define vl_api_ip6_fib_details_t_print vl_noop_handler
20020 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
20022 vat_main_t *vam = &vat_main;
20023 int count = ntohl (mp->count);
20024 vl_api_fib_path_t *fp;
20028 "table-id %d, prefix %U/%d",
20029 ntohl (mp->table_id), format_ip6_address, mp->address,
20030 mp->address_length);
20032 for (i = 0; i < count; i++)
20034 if (fp->afi == IP46_TYPE_IP6)
20036 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20037 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20038 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20039 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20040 format_ip6_address, fp->next_hop);
20041 else if (fp->afi == IP46_TYPE_IP4)
20043 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20044 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20045 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20046 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20047 format_ip4_address, fp->next_hop);
20052 static void vl_api_ip6_fib_details_t_handler_json
20053 (vl_api_ip6_fib_details_t * mp)
20055 vat_main_t *vam = &vat_main;
20056 int count = ntohl (mp->count);
20057 vat_json_node_t *node = NULL;
20058 struct in_addr ip4;
20059 struct in6_addr ip6;
20060 vl_api_fib_path_t *fp;
20063 if (VAT_JSON_ARRAY != vam->json_tree.type)
20065 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20066 vat_json_init_array (&vam->json_tree);
20068 node = vat_json_array_add (&vam->json_tree);
20070 vat_json_init_object (node);
20071 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20072 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
20073 vat_json_object_add_ip6 (node, "prefix", ip6);
20074 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20075 vat_json_object_add_uint (node, "path_count", count);
20077 for (i = 0; i < count; i++)
20079 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20080 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20081 vat_json_object_add_uint (node, "is_local", fp->is_local);
20082 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20083 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20084 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20085 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20086 if (fp->afi == IP46_TYPE_IP4)
20088 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20089 vat_json_object_add_ip4 (node, "next_hop", ip4);
20091 else if (fp->afi == IP46_TYPE_IP6)
20093 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20094 vat_json_object_add_ip6 (node, "next_hop", ip6);
20100 api_ip6_fib_dump (vat_main_t * vam)
20102 vl_api_ip6_fib_dump_t *mp;
20103 vl_api_control_ping_t *mp_ping;
20106 M (IP6_FIB_DUMP, mp);
20109 /* Use a control ping for synchronization */
20110 MPING (CONTROL_PING, mp_ping);
20118 api_ip6_mfib_dump (vat_main_t * vam)
20120 vl_api_ip6_mfib_dump_t *mp;
20121 vl_api_control_ping_t *mp_ping;
20124 M (IP6_MFIB_DUMP, mp);
20127 /* Use a control ping for synchronization */
20128 MPING (CONTROL_PING, mp_ping);
20136 api_classify_table_ids (vat_main_t * vam)
20138 vl_api_classify_table_ids_t *mp;
20141 /* Construct the API message */
20142 M (CLASSIFY_TABLE_IDS, mp);
20151 api_classify_table_by_interface (vat_main_t * vam)
20153 unformat_input_t *input = vam->input;
20154 vl_api_classify_table_by_interface_t *mp;
20156 u32 sw_if_index = ~0;
20158 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20160 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20162 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20167 if (sw_if_index == ~0)
20169 errmsg ("missing interface name or sw_if_index");
20173 /* Construct the API message */
20174 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
20176 mp->sw_if_index = ntohl (sw_if_index);
20184 api_classify_table_info (vat_main_t * vam)
20186 unformat_input_t *input = vam->input;
20187 vl_api_classify_table_info_t *mp;
20191 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20193 if (unformat (input, "table_id %d", &table_id))
20198 if (table_id == ~0)
20200 errmsg ("missing table id");
20204 /* Construct the API message */
20205 M (CLASSIFY_TABLE_INFO, mp);
20207 mp->table_id = ntohl (table_id);
20215 api_classify_session_dump (vat_main_t * vam)
20217 unformat_input_t *input = vam->input;
20218 vl_api_classify_session_dump_t *mp;
20219 vl_api_control_ping_t *mp_ping;
20223 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20225 if (unformat (input, "table_id %d", &table_id))
20230 if (table_id == ~0)
20232 errmsg ("missing table id");
20236 /* Construct the API message */
20237 M (CLASSIFY_SESSION_DUMP, mp);
20239 mp->table_id = ntohl (table_id);
20242 /* Use a control ping for synchronization */
20243 MPING (CONTROL_PING, mp_ping);
20251 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
20253 vat_main_t *vam = &vat_main;
20255 print (vam->ofp, "collector_address %U, collector_port %d, "
20256 "src_address %U, vrf_id %d, path_mtu %u, "
20257 "template_interval %u, udp_checksum %d",
20258 format_ip4_address, mp->collector_address,
20259 ntohs (mp->collector_port),
20260 format_ip4_address, mp->src_address,
20261 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
20262 ntohl (mp->template_interval), mp->udp_checksum);
20265 vam->result_ready = 1;
20269 vl_api_ipfix_exporter_details_t_handler_json
20270 (vl_api_ipfix_exporter_details_t * mp)
20272 vat_main_t *vam = &vat_main;
20273 vat_json_node_t node;
20274 struct in_addr collector_address;
20275 struct in_addr src_address;
20277 vat_json_init_object (&node);
20278 clib_memcpy (&collector_address, &mp->collector_address,
20279 sizeof (collector_address));
20280 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
20281 vat_json_object_add_uint (&node, "collector_port",
20282 ntohs (mp->collector_port));
20283 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
20284 vat_json_object_add_ip4 (&node, "src_address", src_address);
20285 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
20286 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
20287 vat_json_object_add_uint (&node, "template_interval",
20288 ntohl (mp->template_interval));
20289 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
20291 vat_json_print (vam->ofp, &node);
20292 vat_json_free (&node);
20294 vam->result_ready = 1;
20298 api_ipfix_exporter_dump (vat_main_t * vam)
20300 vl_api_ipfix_exporter_dump_t *mp;
20303 /* Construct the API message */
20304 M (IPFIX_EXPORTER_DUMP, mp);
20313 api_ipfix_classify_stream_dump (vat_main_t * vam)
20315 vl_api_ipfix_classify_stream_dump_t *mp;
20318 /* Construct the API message */
20319 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
20330 vl_api_ipfix_classify_stream_details_t_handler
20331 (vl_api_ipfix_classify_stream_details_t * mp)
20333 vat_main_t *vam = &vat_main;
20334 print (vam->ofp, "domain_id %d, src_port %d",
20335 ntohl (mp->domain_id), ntohs (mp->src_port));
20337 vam->result_ready = 1;
20341 vl_api_ipfix_classify_stream_details_t_handler_json
20342 (vl_api_ipfix_classify_stream_details_t * mp)
20344 vat_main_t *vam = &vat_main;
20345 vat_json_node_t node;
20347 vat_json_init_object (&node);
20348 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
20349 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
20351 vat_json_print (vam->ofp, &node);
20352 vat_json_free (&node);
20354 vam->result_ready = 1;
20358 api_ipfix_classify_table_dump (vat_main_t * vam)
20360 vl_api_ipfix_classify_table_dump_t *mp;
20361 vl_api_control_ping_t *mp_ping;
20364 if (!vam->json_output)
20366 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
20367 "transport_protocol");
20370 /* Construct the API message */
20371 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
20376 /* Use a control ping for synchronization */
20377 MPING (CONTROL_PING, mp_ping);
20385 vl_api_ipfix_classify_table_details_t_handler
20386 (vl_api_ipfix_classify_table_details_t * mp)
20388 vat_main_t *vam = &vat_main;
20389 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
20390 mp->transport_protocol);
20394 vl_api_ipfix_classify_table_details_t_handler_json
20395 (vl_api_ipfix_classify_table_details_t * mp)
20397 vat_json_node_t *node = NULL;
20398 vat_main_t *vam = &vat_main;
20400 if (VAT_JSON_ARRAY != vam->json_tree.type)
20402 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20403 vat_json_init_array (&vam->json_tree);
20406 node = vat_json_array_add (&vam->json_tree);
20407 vat_json_init_object (node);
20409 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
20410 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
20411 vat_json_object_add_uint (node, "transport_protocol",
20412 mp->transport_protocol);
20416 api_sw_interface_span_enable_disable (vat_main_t * vam)
20418 unformat_input_t *i = vam->input;
20419 vl_api_sw_interface_span_enable_disable_t *mp;
20420 u32 src_sw_if_index = ~0;
20421 u32 dst_sw_if_index = ~0;
20426 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20429 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
20431 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
20435 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
20437 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
20439 else if (unformat (i, "disable"))
20441 else if (unformat (i, "rx"))
20443 else if (unformat (i, "tx"))
20445 else if (unformat (i, "both"))
20447 else if (unformat (i, "l2"))
20453 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
20455 mp->sw_if_index_from = htonl (src_sw_if_index);
20456 mp->sw_if_index_to = htonl (dst_sw_if_index);
20466 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
20469 vat_main_t *vam = &vat_main;
20470 u8 *sw_if_from_name = 0;
20471 u8 *sw_if_to_name = 0;
20472 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
20473 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
20474 char *states[] = { "none", "rx", "tx", "both" };
20478 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
20480 if ((u32) p->value[0] == sw_if_index_from)
20482 sw_if_from_name = (u8 *)(p->key);
20486 if ((u32) p->value[0] == sw_if_index_to)
20488 sw_if_to_name = (u8 *)(p->key);
20489 if (sw_if_from_name)
20494 print (vam->ofp, "%20s => %20s (%s)",
20495 sw_if_from_name, sw_if_to_name, states[mp->state]);
20499 vl_api_sw_interface_span_details_t_handler_json
20500 (vl_api_sw_interface_span_details_t * mp)
20502 vat_main_t *vam = &vat_main;
20503 vat_json_node_t *node = NULL;
20504 u8 *sw_if_from_name = 0;
20505 u8 *sw_if_to_name = 0;
20506 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
20507 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
20511 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
20513 if ((u32) p->value[0] == sw_if_index_from)
20515 sw_if_from_name = (u8 *)(p->key);
20519 if ((u32) p->value[0] == sw_if_index_to)
20521 sw_if_to_name = (u8 *)(p->key);
20522 if (sw_if_from_name)
20528 if (VAT_JSON_ARRAY != vam->json_tree.type)
20530 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20531 vat_json_init_array (&vam->json_tree);
20533 node = vat_json_array_add (&vam->json_tree);
20535 vat_json_init_object (node);
20536 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
20537 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
20538 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
20539 if (0 != sw_if_to_name)
20541 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
20543 vat_json_object_add_uint (node, "state", mp->state);
20547 api_sw_interface_span_dump (vat_main_t * vam)
20549 unformat_input_t *input = vam->input;
20550 vl_api_sw_interface_span_dump_t *mp;
20551 vl_api_control_ping_t *mp_ping;
20555 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20557 if (unformat (input, "l2"))
20563 M (SW_INTERFACE_SPAN_DUMP, mp);
20567 /* Use a control ping for synchronization */
20568 MPING (CONTROL_PING, mp_ping);
20576 api_pg_create_interface (vat_main_t * vam)
20578 unformat_input_t *input = vam->input;
20579 vl_api_pg_create_interface_t *mp;
20583 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20585 if (unformat (input, "if_id %d", &if_id))
20592 errmsg ("missing pg interface index");
20596 /* Construct the API message */
20597 M (PG_CREATE_INTERFACE, mp);
20599 mp->interface_id = ntohl (if_id);
20607 api_pg_capture (vat_main_t * vam)
20609 unformat_input_t *input = vam->input;
20610 vl_api_pg_capture_t *mp;
20615 u8 pcap_file_set = 0;
20618 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20620 if (unformat (input, "if_id %d", &if_id))
20622 else if (unformat (input, "pcap %s", &pcap_file))
20624 else if (unformat (input, "count %d", &count))
20626 else if (unformat (input, "disable"))
20633 errmsg ("missing pg interface index");
20636 if (pcap_file_set > 0)
20638 if (vec_len (pcap_file) > 255)
20640 errmsg ("pcap file name is too long");
20645 u32 name_len = vec_len (pcap_file);
20646 /* Construct the API message */
20647 M (PG_CAPTURE, mp);
20649 mp->interface_id = ntohl (if_id);
20650 mp->is_enabled = enable;
20651 mp->count = ntohl (count);
20652 mp->pcap_name_length = ntohl (name_len);
20653 if (pcap_file_set != 0)
20655 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
20657 vec_free (pcap_file);
20665 api_pg_enable_disable (vat_main_t * vam)
20667 unformat_input_t *input = vam->input;
20668 vl_api_pg_enable_disable_t *mp;
20671 u8 stream_name_set = 0;
20672 u8 *stream_name = 0;
20674 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20676 if (unformat (input, "stream %s", &stream_name))
20677 stream_name_set = 1;
20678 else if (unformat (input, "disable"))
20684 if (stream_name_set > 0)
20686 if (vec_len (stream_name) > 255)
20688 errmsg ("stream name too long");
20693 u32 name_len = vec_len (stream_name);
20694 /* Construct the API message */
20695 M (PG_ENABLE_DISABLE, mp);
20697 mp->is_enabled = enable;
20698 if (stream_name_set != 0)
20700 mp->stream_name_length = ntohl (name_len);
20701 clib_memcpy (mp->stream_name, stream_name, name_len);
20703 vec_free (stream_name);
20711 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
20713 unformat_input_t *input = vam->input;
20714 vl_api_ip_source_and_port_range_check_add_del_t *mp;
20716 u16 *low_ports = 0;
20717 u16 *high_ports = 0;
20720 ip4_address_t ip4_addr;
20721 ip6_address_t ip6_addr;
20730 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20732 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
20738 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
20743 else if (unformat (input, "vrf %d", &vrf_id))
20745 else if (unformat (input, "del"))
20747 else if (unformat (input, "port %d", &tmp))
20749 if (tmp == 0 || tmp > 65535)
20751 errmsg ("port %d out of range", tmp);
20755 this_hi = this_low + 1;
20756 vec_add1 (low_ports, this_low);
20757 vec_add1 (high_ports, this_hi);
20759 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
20761 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
20763 errmsg ("incorrect range parameters");
20767 /* Note: in debug CLI +1 is added to high before
20768 passing to real fn that does "the work"
20769 (ip_source_and_port_range_check_add_del).
20770 This fn is a wrapper around the binary API fn a
20771 control plane will call, which expects this increment
20772 to have occurred. Hence letting the binary API control
20773 plane fn do the increment for consistency between VAT
20774 and other control planes.
20777 vec_add1 (low_ports, this_low);
20778 vec_add1 (high_ports, this_hi);
20784 if (prefix_set == 0)
20786 errmsg ("<address>/<mask> not specified");
20792 errmsg ("VRF ID required, not specified");
20799 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
20803 if (vec_len (low_ports) == 0)
20805 errmsg ("At least one port or port range required");
20809 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
20811 mp->is_add = is_add;
20816 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
20821 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
20824 mp->mask_length = length;
20825 mp->number_of_ranges = vec_len (low_ports);
20827 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
20828 vec_free (low_ports);
20830 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
20831 vec_free (high_ports);
20833 mp->vrf_id = ntohl (vrf_id);
20841 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
20843 unformat_input_t *input = vam->input;
20844 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
20845 u32 sw_if_index = ~0;
20847 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
20848 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
20852 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20854 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20856 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20858 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
20860 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
20862 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
20864 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
20866 else if (unformat (input, "del"))
20872 if (sw_if_index == ~0)
20874 errmsg ("Interface required but not specified");
20880 errmsg ("VRF ID required but not specified");
20884 if (tcp_out_vrf_id == 0
20885 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
20888 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
20892 /* Construct the API message */
20893 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
20895 mp->sw_if_index = ntohl (sw_if_index);
20896 mp->is_add = is_add;
20897 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
20898 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
20899 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
20900 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
20905 /* Wait for a reply... */
20911 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
20913 unformat_input_t *i = vam->input;
20914 vl_api_ipsec_gre_add_del_tunnel_t *mp;
20915 u32 local_sa_id = 0;
20916 u32 remote_sa_id = 0;
20917 ip4_address_t src_address;
20918 ip4_address_t dst_address;
20922 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20924 if (unformat (i, "local_sa %d", &local_sa_id))
20926 else if (unformat (i, "remote_sa %d", &remote_sa_id))
20928 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
20930 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
20932 else if (unformat (i, "del"))
20936 clib_warning ("parse error '%U'", format_unformat_error, i);
20941 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
20943 mp->local_sa_id = ntohl (local_sa_id);
20944 mp->remote_sa_id = ntohl (remote_sa_id);
20945 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
20946 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
20947 mp->is_add = is_add;
20955 api_punt (vat_main_t * vam)
20957 unformat_input_t *i = vam->input;
20965 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20967 if (unformat (i, "ip %d", &ipv))
20969 else if (unformat (i, "protocol %d", &protocol))
20971 else if (unformat (i, "port %d", &port))
20973 else if (unformat (i, "del"))
20977 clib_warning ("parse error '%U'", format_unformat_error, i);
20984 mp->is_add = (u8) is_add;
20985 mp->ipv = (u8) ipv;
20986 mp->l4_protocol = (u8) protocol;
20987 mp->l4_port = htons ((u16) port);
20994 static void vl_api_ipsec_gre_tunnel_details_t_handler
20995 (vl_api_ipsec_gre_tunnel_details_t * mp)
20997 vat_main_t *vam = &vat_main;
20999 print (vam->ofp, "%11d%15U%15U%14d%14d",
21000 ntohl (mp->sw_if_index),
21001 format_ip4_address, &mp->src_address,
21002 format_ip4_address, &mp->dst_address,
21003 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
21006 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
21007 (vl_api_ipsec_gre_tunnel_details_t * mp)
21009 vat_main_t *vam = &vat_main;
21010 vat_json_node_t *node = NULL;
21011 struct in_addr ip4;
21013 if (VAT_JSON_ARRAY != vam->json_tree.type)
21015 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21016 vat_json_init_array (&vam->json_tree);
21018 node = vat_json_array_add (&vam->json_tree);
21020 vat_json_init_object (node);
21021 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
21022 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
21023 vat_json_object_add_ip4 (node, "src_address", ip4);
21024 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
21025 vat_json_object_add_ip4 (node, "dst_address", ip4);
21026 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
21027 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
21031 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
21033 unformat_input_t *i = vam->input;
21034 vl_api_ipsec_gre_tunnel_dump_t *mp;
21035 vl_api_control_ping_t *mp_ping;
21037 u8 sw_if_index_set = 0;
21040 /* Parse args required to build the message */
21041 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21043 if (unformat (i, "sw_if_index %d", &sw_if_index))
21044 sw_if_index_set = 1;
21049 if (sw_if_index_set == 0)
21054 if (!vam->json_output)
21056 print (vam->ofp, "%11s%15s%15s%14s%14s",
21057 "sw_if_index", "src_address", "dst_address",
21058 "local_sa_id", "remote_sa_id");
21061 /* Get list of gre-tunnel interfaces */
21062 M (IPSEC_GRE_TUNNEL_DUMP, mp);
21064 mp->sw_if_index = htonl (sw_if_index);
21068 /* Use a control ping for synchronization */
21069 MPING (CONTROL_PING, mp_ping);
21077 api_delete_subif (vat_main_t * vam)
21079 unformat_input_t *i = vam->input;
21080 vl_api_delete_subif_t *mp;
21081 u32 sw_if_index = ~0;
21084 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21086 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21088 if (unformat (i, "sw_if_index %d", &sw_if_index))
21094 if (sw_if_index == ~0)
21096 errmsg ("missing sw_if_index");
21100 /* Construct the API message */
21101 M (DELETE_SUBIF, mp);
21102 mp->sw_if_index = ntohl (sw_if_index);
21109 #define foreach_pbb_vtr_op \
21110 _("disable", L2_VTR_DISABLED) \
21111 _("pop", L2_VTR_POP_2) \
21112 _("push", L2_VTR_PUSH_2)
21115 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
21117 unformat_input_t *i = vam->input;
21118 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
21119 u32 sw_if_index = ~0, vtr_op = ~0;
21120 u16 outer_tag = ~0;
21121 u8 dmac[6], smac[6];
21122 u8 dmac_set = 0, smac_set = 0;
21128 /* Shut up coverity */
21129 memset (dmac, 0, sizeof (dmac));
21130 memset (smac, 0, sizeof (smac));
21132 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21134 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21136 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21138 else if (unformat (i, "vtr_op %d", &vtr_op))
21140 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
21143 else if (unformat (i, "translate_pbb_stag"))
21145 if (unformat (i, "%d", &tmp))
21147 vtr_op = L2_VTR_TRANSLATE_2_1;
21153 ("translate_pbb_stag operation requires outer tag definition");
21157 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
21159 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
21161 else if (unformat (i, "sid %d", &sid))
21163 else if (unformat (i, "vlanid %d", &tmp))
21167 clib_warning ("parse error '%U'", format_unformat_error, i);
21172 if ((sw_if_index == ~0) || (vtr_op == ~0))
21174 errmsg ("missing sw_if_index or vtr operation");
21177 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
21178 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
21181 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
21185 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
21186 mp->sw_if_index = ntohl (sw_if_index);
21187 mp->vtr_op = ntohl (vtr_op);
21188 mp->outer_tag = ntohs (outer_tag);
21189 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
21190 clib_memcpy (mp->b_smac, smac, sizeof (smac));
21191 mp->b_vlanid = ntohs (vlanid);
21192 mp->i_sid = ntohl (sid);
21200 api_flow_classify_set_interface (vat_main_t * vam)
21202 unformat_input_t *i = vam->input;
21203 vl_api_flow_classify_set_interface_t *mp;
21205 int sw_if_index_set;
21206 u32 ip4_table_index = ~0;
21207 u32 ip6_table_index = ~0;
21211 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21213 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21214 sw_if_index_set = 1;
21215 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21216 sw_if_index_set = 1;
21217 else if (unformat (i, "del"))
21219 else if (unformat (i, "ip4-table %d", &ip4_table_index))
21221 else if (unformat (i, "ip6-table %d", &ip6_table_index))
21225 clib_warning ("parse error '%U'", format_unformat_error, i);
21230 if (sw_if_index_set == 0)
21232 errmsg ("missing interface name or sw_if_index");
21236 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
21238 mp->sw_if_index = ntohl (sw_if_index);
21239 mp->ip4_table_index = ntohl (ip4_table_index);
21240 mp->ip6_table_index = ntohl (ip6_table_index);
21241 mp->is_add = is_add;
21249 api_flow_classify_dump (vat_main_t * vam)
21251 unformat_input_t *i = vam->input;
21252 vl_api_flow_classify_dump_t *mp;
21253 vl_api_control_ping_t *mp_ping;
21254 u8 type = FLOW_CLASSIFY_N_TABLES;
21257 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
21261 errmsg ("classify table type must be specified");
21265 if (!vam->json_output)
21267 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
21270 M (FLOW_CLASSIFY_DUMP, mp);
21275 /* Use a control ping for synchronization */
21276 MPING (CONTROL_PING, mp_ping);
21279 /* Wait for a reply... */
21285 api_feature_enable_disable (vat_main_t * vam)
21287 unformat_input_t *i = vam->input;
21288 vl_api_feature_enable_disable_t *mp;
21290 u8 *feature_name = 0;
21291 u32 sw_if_index = ~0;
21295 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21297 if (unformat (i, "arc_name %s", &arc_name))
21299 else if (unformat (i, "feature_name %s", &feature_name))
21302 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21304 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21306 else if (unformat (i, "disable"))
21314 errmsg ("missing arc name");
21317 if (vec_len (arc_name) > 63)
21319 errmsg ("arc name too long");
21322 if (feature_name == 0)
21324 errmsg ("missing feature name");
21327 if (vec_len (feature_name) > 63)
21329 errmsg ("feature name too long");
21332 if (sw_if_index == ~0)
21334 errmsg ("missing interface name or sw_if_index");
21338 /* Construct the API message */
21339 M (FEATURE_ENABLE_DISABLE, mp);
21340 mp->sw_if_index = ntohl (sw_if_index);
21341 mp->enable = enable;
21342 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
21343 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
21344 vec_free (arc_name);
21345 vec_free (feature_name);
21353 api_sw_interface_tag_add_del (vat_main_t * vam)
21355 unformat_input_t *i = vam->input;
21356 vl_api_sw_interface_tag_add_del_t *mp;
21357 u32 sw_if_index = ~0;
21362 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21364 if (unformat (i, "tag %s", &tag))
21366 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21368 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21370 else if (unformat (i, "del"))
21376 if (sw_if_index == ~0)
21378 errmsg ("missing interface name or sw_if_index");
21382 if (enable && (tag == 0))
21384 errmsg ("no tag specified");
21388 /* Construct the API message */
21389 M (SW_INTERFACE_TAG_ADD_DEL, mp);
21390 mp->sw_if_index = ntohl (sw_if_index);
21391 mp->is_add = enable;
21393 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
21401 static void vl_api_l2_xconnect_details_t_handler
21402 (vl_api_l2_xconnect_details_t * mp)
21404 vat_main_t *vam = &vat_main;
21406 print (vam->ofp, "%15d%15d",
21407 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
21410 static void vl_api_l2_xconnect_details_t_handler_json
21411 (vl_api_l2_xconnect_details_t * mp)
21413 vat_main_t *vam = &vat_main;
21414 vat_json_node_t *node = NULL;
21416 if (VAT_JSON_ARRAY != vam->json_tree.type)
21418 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21419 vat_json_init_array (&vam->json_tree);
21421 node = vat_json_array_add (&vam->json_tree);
21423 vat_json_init_object (node);
21424 vat_json_object_add_uint (node, "rx_sw_if_index",
21425 ntohl (mp->rx_sw_if_index));
21426 vat_json_object_add_uint (node, "tx_sw_if_index",
21427 ntohl (mp->tx_sw_if_index));
21431 api_l2_xconnect_dump (vat_main_t * vam)
21433 vl_api_l2_xconnect_dump_t *mp;
21434 vl_api_control_ping_t *mp_ping;
21437 if (!vam->json_output)
21439 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
21442 M (L2_XCONNECT_DUMP, mp);
21446 /* Use a control ping for synchronization */
21447 MPING (CONTROL_PING, mp_ping);
21455 api_sw_interface_set_mtu (vat_main_t * vam)
21457 unformat_input_t *i = vam->input;
21458 vl_api_sw_interface_set_mtu_t *mp;
21459 u32 sw_if_index = ~0;
21463 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21465 if (unformat (i, "mtu %d", &mtu))
21467 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21469 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21475 if (sw_if_index == ~0)
21477 errmsg ("missing interface name or sw_if_index");
21483 errmsg ("no mtu specified");
21487 /* Construct the API message */
21488 M (SW_INTERFACE_SET_MTU, mp);
21489 mp->sw_if_index = ntohl (sw_if_index);
21490 mp->mtu = ntohs ((u16) mtu);
21498 api_p2p_ethernet_add (vat_main_t * vam)
21500 unformat_input_t *i = vam->input;
21501 vl_api_p2p_ethernet_add_t *mp;
21502 u32 parent_if_index = ~0;
21508 memset (remote_mac, 0, sizeof (remote_mac));
21509 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21511 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
21513 else if (unformat (i, "sw_if_index %d", &parent_if_index))
21517 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
21519 else if (unformat (i, "sub_id %d", &sub_id))
21523 clib_warning ("parse error '%U'", format_unformat_error, i);
21528 if (parent_if_index == ~0)
21530 errmsg ("missing interface name or sw_if_index");
21535 errmsg ("missing remote mac address");
21540 errmsg ("missing sub-interface id");
21544 M (P2P_ETHERNET_ADD, mp);
21545 mp->parent_if_index = ntohl (parent_if_index);
21546 mp->subif_id = ntohl (sub_id);
21547 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
21555 api_p2p_ethernet_del (vat_main_t * vam)
21557 unformat_input_t *i = vam->input;
21558 vl_api_p2p_ethernet_del_t *mp;
21559 u32 parent_if_index = ~0;
21564 memset (remote_mac, 0, sizeof (remote_mac));
21565 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21567 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
21569 else if (unformat (i, "sw_if_index %d", &parent_if_index))
21573 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
21577 clib_warning ("parse error '%U'", format_unformat_error, i);
21582 if (parent_if_index == ~0)
21584 errmsg ("missing interface name or sw_if_index");
21589 errmsg ("missing remote mac address");
21593 M (P2P_ETHERNET_DEL, mp);
21594 mp->parent_if_index = ntohl (parent_if_index);
21595 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
21603 api_lldp_config (vat_main_t * vam)
21605 unformat_input_t *i = vam->input;
21606 vl_api_lldp_config_t *mp;
21608 int tx_interval = 0;
21609 u8 *sys_name = NULL;
21612 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21614 if (unformat (i, "system-name %s", &sys_name))
21616 else if (unformat (i, "tx-hold %d", &tx_hold))
21618 else if (unformat (i, "tx-interval %d", &tx_interval))
21622 clib_warning ("parse error '%U'", format_unformat_error, i);
21627 vec_add1 (sys_name, 0);
21629 M (LLDP_CONFIG, mp);
21630 mp->tx_hold = htonl (tx_hold);
21631 mp->tx_interval = htonl (tx_interval);
21632 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
21633 vec_free (sys_name);
21641 api_sw_interface_set_lldp (vat_main_t * vam)
21643 unformat_input_t *i = vam->input;
21644 vl_api_sw_interface_set_lldp_t *mp;
21645 u32 sw_if_index = ~0;
21647 u8 *port_desc = NULL, *mgmt_oid = NULL;
21648 ip4_address_t ip4_addr;
21649 ip6_address_t ip6_addr;
21652 memset (&ip4_addr, 0, sizeof (ip4_addr));
21653 memset (&ip6_addr, 0, sizeof (ip6_addr));
21655 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21657 if (unformat (i, "disable"))
21660 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21662 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21664 else if (unformat (i, "port-desc %s", &port_desc))
21666 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
21668 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
21670 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
21676 if (sw_if_index == ~0)
21678 errmsg ("missing interface name or sw_if_index");
21682 /* Construct the API message */
21683 vec_add1 (port_desc, 0);
21684 vec_add1 (mgmt_oid, 0);
21685 M (SW_INTERFACE_SET_LLDP, mp);
21686 mp->sw_if_index = ntohl (sw_if_index);
21687 mp->enable = enable;
21688 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
21689 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
21690 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
21691 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
21692 vec_free (port_desc);
21693 vec_free (mgmt_oid);
21701 api_tcp_configure_src_addresses (vat_main_t * vam)
21703 vl_api_tcp_configure_src_addresses_t *mp;
21704 unformat_input_t *i = vam->input;
21705 ip4_address_t v4first, v4last;
21706 ip6_address_t v6first, v6last;
21711 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21713 if (unformat (i, "%U - %U",
21714 unformat_ip4_address, &v4first,
21715 unformat_ip4_address, &v4last))
21719 errmsg ("one range per message (range already set)");
21724 else if (unformat (i, "%U - %U",
21725 unformat_ip6_address, &v6first,
21726 unformat_ip6_address, &v6last))
21730 errmsg ("one range per message (range already set)");
21735 else if (unformat (i, "vrf %d", &vrf_id))
21741 if (range_set == 0)
21743 errmsg ("address range not set");
21747 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
21748 mp->vrf_id = ntohl (vrf_id);
21750 if (range_set == 2)
21753 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
21754 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
21759 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
21760 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
21767 static void vl_api_app_namespace_add_del_reply_t_handler
21768 (vl_api_app_namespace_add_del_reply_t * mp)
21770 vat_main_t *vam = &vat_main;
21771 i32 retval = ntohl (mp->retval);
21772 if (vam->async_mode)
21774 vam->async_errors += (retval < 0);
21778 vam->retval = retval;
21780 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
21781 vam->result_ready = 1;
21785 static void vl_api_app_namespace_add_del_reply_t_handler_json
21786 (vl_api_app_namespace_add_del_reply_t * mp)
21788 vat_main_t *vam = &vat_main;
21789 vat_json_node_t node;
21791 vat_json_init_object (&node);
21792 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
21793 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
21795 vat_json_print (vam->ofp, &node);
21796 vat_json_free (&node);
21798 vam->retval = ntohl (mp->retval);
21799 vam->result_ready = 1;
21803 api_app_namespace_add_del (vat_main_t * vam)
21805 vl_api_app_namespace_add_del_t *mp;
21806 unformat_input_t *i = vam->input;
21807 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
21808 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
21812 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21814 if (unformat (i, "id %_%v%_", &ns_id))
21816 else if (unformat (i, "secret %lu", &secret))
21818 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21819 sw_if_index_set = 1;
21820 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
21822 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
21827 if (!ns_id || !secret_set || !sw_if_index_set)
21829 errmsg ("namespace id, secret and sw_if_index must be set");
21832 if (vec_len (ns_id) > 64)
21834 errmsg ("namespace id too long");
21837 M (APP_NAMESPACE_ADD_DEL, mp);
21839 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
21840 mp->namespace_id_len = vec_len (ns_id);
21841 mp->secret = clib_host_to_net_u64 (secret);
21842 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
21843 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
21844 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
21852 api_memfd_segment_create (vat_main_t * vam)
21854 #if VPP_API_TEST_BUILTIN == 0
21855 unformat_input_t *i = vam->input;
21856 vl_api_memfd_segment_create_t *mp;
21857 u64 size = 64 << 20;
21860 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21862 if (unformat (i, "size %U", unformat_memory_size, &size))
21868 M (MEMFD_SEGMENT_CREATE, mp);
21869 mp->requested_size = size;
21875 errmsg ("memfd_segment_create (builtin) not supported");
21881 api_sock_init_shm (vat_main_t * vam)
21883 #if VPP_API_TEST_BUILTIN == 0
21884 unformat_input_t *i = vam->input;
21885 vl_api_shm_elem_config_t *config = 0;
21886 u64 size = 64 << 20;
21889 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21891 if (unformat (i, "size %U", unformat_memory_size, &size))
21897 /* Try customized config to see if it works */
21898 vec_validate (config, 3);
21899 config[0].type = VL_API_VLIB_RING;
21900 config[0].count = 256;
21901 config[0].size = 256;
21902 config[1].type = VL_API_CLIENT_RING;
21903 config[1].count = 256;
21904 config[1].size = 1024;
21905 config[2].type = VL_API_CLIENT_RING;
21906 config[2].count = 8;
21907 config[2].size = 4096;
21908 config[3].type = VL_API_QUEUE;
21909 config[3].count = 256;
21910 config[3].size = sizeof (uword);
21911 rv = vl_socket_client_init_shm (config);
21913 vam->client_index_invalid = 1;
21921 api_dns_enable_disable (vat_main_t * vam)
21923 unformat_input_t *line_input = vam->input;
21924 vl_api_dns_enable_disable_t *mp;
21925 u8 enable_disable = 1;
21928 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21930 if (unformat (line_input, "disable"))
21931 enable_disable = 0;
21932 if (unformat (line_input, "enable"))
21933 enable_disable = 1;
21938 /* Construct the API message */
21939 M (DNS_ENABLE_DISABLE, mp);
21940 mp->enable = enable_disable;
21944 /* Wait for the reply */
21950 api_dns_resolve_name (vat_main_t * vam)
21952 unformat_input_t *line_input = vam->input;
21953 vl_api_dns_resolve_name_t *mp;
21957 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21959 if (unformat (line_input, "%s", &name))
21965 if (vec_len (name) > 127)
21967 errmsg ("name too long");
21971 /* Construct the API message */
21972 M (DNS_RESOLVE_NAME, mp);
21973 memcpy (mp->name, name, vec_len (name));
21978 /* Wait for the reply */
21984 api_dns_resolve_ip (vat_main_t * vam)
21986 unformat_input_t *line_input = vam->input;
21987 vl_api_dns_resolve_ip_t *mp;
21989 ip4_address_t addr4;
21990 ip6_address_t addr6;
21993 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21995 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
21997 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
22005 errmsg ("missing address");
22009 /* Construct the API message */
22010 M (DNS_RESOLVE_IP, mp);
22011 mp->is_ip6 = is_ip6;
22013 memcpy (mp->address, &addr6, sizeof (addr6));
22015 memcpy (mp->address, &addr4, sizeof (addr4));
22019 /* Wait for the reply */
22025 api_dns_name_server_add_del (vat_main_t * vam)
22027 unformat_input_t *i = vam->input;
22028 vl_api_dns_name_server_add_del_t *mp;
22030 ip6_address_t ip6_server;
22031 ip4_address_t ip4_server;
22036 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22038 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
22040 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
22042 else if (unformat (i, "del"))
22046 clib_warning ("parse error '%U'", format_unformat_error, i);
22051 if (ip4_set && ip6_set)
22053 errmsg ("Only one server address allowed per message");
22056 if ((ip4_set + ip6_set) == 0)
22058 errmsg ("Server address required");
22062 /* Construct the API message */
22063 M (DNS_NAME_SERVER_ADD_DEL, mp);
22067 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
22072 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
22076 mp->is_add = is_add;
22081 /* Wait for a reply, return good/bad news */
22087 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
22089 vat_main_t *vam = &vat_main;
22094 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22095 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22096 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
22097 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
22098 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22099 clib_net_to_host_u32 (mp->action_index), mp->tag);
22104 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22105 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22106 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
22107 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
22108 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22109 clib_net_to_host_u32 (mp->action_index), mp->tag);
22114 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
22117 vat_main_t *vam = &vat_main;
22118 vat_json_node_t *node = NULL;
22119 struct in6_addr ip6;
22120 struct in_addr ip4;
22122 if (VAT_JSON_ARRAY != vam->json_tree.type)
22124 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22125 vat_json_init_array (&vam->json_tree);
22127 node = vat_json_array_add (&vam->json_tree);
22128 vat_json_init_object (node);
22130 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
22131 vat_json_object_add_uint (node, "appns_index",
22132 clib_net_to_host_u32 (mp->appns_index));
22133 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
22134 vat_json_object_add_uint (node, "scope", mp->scope);
22135 vat_json_object_add_uint (node, "action_index",
22136 clib_net_to_host_u32 (mp->action_index));
22137 vat_json_object_add_uint (node, "lcl_port",
22138 clib_net_to_host_u16 (mp->lcl_port));
22139 vat_json_object_add_uint (node, "rmt_port",
22140 clib_net_to_host_u16 (mp->rmt_port));
22141 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
22142 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
22143 vat_json_object_add_string_copy (node, "tag", mp->tag);
22146 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
22147 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
22148 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
22149 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
22153 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
22154 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
22155 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
22156 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
22161 api_session_rule_add_del (vat_main_t * vam)
22163 vl_api_session_rule_add_del_t *mp;
22164 unformat_input_t *i = vam->input;
22165 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
22166 u32 appns_index = 0, scope = 0;
22167 ip4_address_t lcl_ip4, rmt_ip4;
22168 ip6_address_t lcl_ip6, rmt_ip6;
22169 u8 is_ip4 = 1, conn_set = 0;
22170 u8 is_add = 1, *tag = 0;
22173 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22175 if (unformat (i, "del"))
22177 else if (unformat (i, "add"))
22179 else if (unformat (i, "proto tcp"))
22181 else if (unformat (i, "proto udp"))
22183 else if (unformat (i, "appns %d", &appns_index))
22185 else if (unformat (i, "scope %d", &scope))
22187 else if (unformat (i, "tag %_%v%_", &tag))
22191 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
22192 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
22200 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
22201 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
22207 else if (unformat (i, "action %d", &action))
22212 if (proto == ~0 || !conn_set || action == ~0)
22214 errmsg ("transport proto, connection and action must be set");
22220 errmsg ("scope should be 0-3");
22224 M (SESSION_RULE_ADD_DEL, mp);
22226 mp->is_ip4 = is_ip4;
22227 mp->transport_proto = proto;
22228 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
22229 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
22230 mp->lcl_plen = lcl_plen;
22231 mp->rmt_plen = rmt_plen;
22232 mp->action_index = clib_host_to_net_u32 (action);
22233 mp->appns_index = clib_host_to_net_u32 (appns_index);
22235 mp->is_add = is_add;
22238 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
22239 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
22243 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
22244 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
22248 clib_memcpy (mp->tag, tag, vec_len (tag));
22258 api_session_rules_dump (vat_main_t * vam)
22260 vl_api_session_rules_dump_t *mp;
22261 vl_api_control_ping_t *mp_ping;
22264 if (!vam->json_output)
22266 print (vam->ofp, "%=20s", "Session Rules");
22269 M (SESSION_RULES_DUMP, mp);
22273 /* Use a control ping for synchronization */
22274 MPING (CONTROL_PING, mp_ping);
22277 /* Wait for a reply... */
22283 api_ip_container_proxy_add_del (vat_main_t * vam)
22285 vl_api_ip_container_proxy_add_del_t *mp;
22286 unformat_input_t *i = vam->input;
22287 u32 plen = ~0, sw_if_index = ~0;
22294 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22296 if (unformat (i, "del"))
22298 else if (unformat (i, "add"))
22300 if (unformat (i, "%U", unformat_ip4_address, &ip4))
22305 else if (unformat (i, "%U", unformat_ip6_address, &ip6))
22310 else if (unformat (i, "sw_if_index %u", &sw_if_index))
22315 if (sw_if_index == ~0 || plen == ~0)
22317 errmsg ("address and sw_if_index must be set");
22321 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
22323 mp->is_ip4 = is_ip4;
22324 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
22326 mp->is_add = is_add;
22328 clib_memcpy (mp->ip, &ip4, sizeof (ip4));
22330 clib_memcpy (mp->ip, &ip6, sizeof (ip6));
22338 q_or_quit (vat_main_t * vam)
22340 #if VPP_API_TEST_BUILTIN == 0
22341 longjmp (vam->jump_buf, 1);
22343 return 0; /* not so much */
22347 q (vat_main_t * vam)
22349 return q_or_quit (vam);
22353 quit (vat_main_t * vam)
22355 return q_or_quit (vam);
22359 comment (vat_main_t * vam)
22365 cmd_cmp (void *a1, void *a2)
22370 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
22374 help (vat_main_t * vam)
22379 unformat_input_t *i = vam->input;
22382 if (unformat (i, "%s", &name))
22386 vec_add1 (name, 0);
22388 hs = hash_get_mem (vam->help_by_name, name);
22390 print (vam->ofp, "usage: %s %s", name, hs[0]);
22392 print (vam->ofp, "No such msg / command '%s'", name);
22397 print (vam->ofp, "Help is available for the following:");
22400 hash_foreach_pair (p, vam->function_by_name,
22402 vec_add1 (cmds, (u8 *)(p->key));
22406 vec_sort_with_function (cmds, cmd_cmp);
22408 for (j = 0; j < vec_len (cmds); j++)
22409 print (vam->ofp, "%s", cmds[j]);
22416 set (vat_main_t * vam)
22418 u8 *name = 0, *value = 0;
22419 unformat_input_t *i = vam->input;
22421 if (unformat (i, "%s", &name))
22423 /* The input buffer is a vector, not a string. */
22424 value = vec_dup (i->buffer);
22425 vec_delete (value, i->index, 0);
22426 /* Almost certainly has a trailing newline */
22427 if (value[vec_len (value) - 1] == '\n')
22428 value[vec_len (value) - 1] = 0;
22429 /* Make sure it's a proper string, one way or the other */
22430 vec_add1 (value, 0);
22431 (void) clib_macro_set_value (&vam->macro_main,
22432 (char *) name, (char *) value);
22435 errmsg ("usage: set <name> <value>");
22443 unset (vat_main_t * vam)
22447 if (unformat (vam->input, "%s", &name))
22448 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
22449 errmsg ("unset: %s wasn't set", name);
22462 macro_sort_cmp (void *a1, void *a2)
22464 macro_sort_t *s1 = a1;
22465 macro_sort_t *s2 = a2;
22467 return strcmp ((char *) (s1->name), (char *) (s2->name));
22471 dump_macro_table (vat_main_t * vam)
22473 macro_sort_t *sort_me = 0, *sm;
22478 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
22480 vec_add2 (sort_me, sm, 1);
22481 sm->name = (u8 *)(p->key);
22482 sm->value = (u8 *) (p->value[0]);
22486 vec_sort_with_function (sort_me, macro_sort_cmp);
22488 if (vec_len (sort_me))
22489 print (vam->ofp, "%-15s%s", "Name", "Value");
22491 print (vam->ofp, "The macro table is empty...");
22493 for (i = 0; i < vec_len (sort_me); i++)
22494 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
22499 dump_node_table (vat_main_t * vam)
22502 vlib_node_t *node, *next_node;
22504 if (vec_len (vam->graph_nodes) == 0)
22506 print (vam->ofp, "Node table empty, issue get_node_graph...");
22510 for (i = 0; i < vec_len (vam->graph_nodes); i++)
22512 node = vam->graph_nodes[i];
22513 print (vam->ofp, "[%d] %s", i, node->name);
22514 for (j = 0; j < vec_len (node->next_nodes); j++)
22516 if (node->next_nodes[j] != ~0)
22518 next_node = vam->graph_nodes[node->next_nodes[j]];
22519 print (vam->ofp, " [%d] %s", j, next_node->name);
22527 value_sort_cmp (void *a1, void *a2)
22529 name_sort_t *n1 = a1;
22530 name_sort_t *n2 = a2;
22532 if (n1->value < n2->value)
22534 if (n1->value > n2->value)
22541 dump_msg_api_table (vat_main_t * vam)
22543 api_main_t *am = &api_main;
22544 name_sort_t *nses = 0, *ns;
22549 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
22551 vec_add2 (nses, ns, 1);
22552 ns->name = (u8 *)(hp->key);
22553 ns->value = (u32) hp->value[0];
22557 vec_sort_with_function (nses, value_sort_cmp);
22559 for (i = 0; i < vec_len (nses); i++)
22560 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
22566 get_msg_id (vat_main_t * vam)
22571 if (unformat (vam->input, "%s", &name_and_crc))
22573 message_index = vl_msg_api_get_msg_index (name_and_crc);
22574 if (message_index == ~0)
22576 print (vam->ofp, " '%s' not found", name_and_crc);
22579 print (vam->ofp, " '%s' has message index %d",
22580 name_and_crc, message_index);
22583 errmsg ("name_and_crc required...");
22588 search_node_table (vat_main_t * vam)
22590 unformat_input_t *line_input = vam->input;
22593 vlib_node_t *node, *next_node;
22596 if (vam->graph_node_index_by_name == 0)
22598 print (vam->ofp, "Node table empty, issue get_node_graph...");
22602 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22604 if (unformat (line_input, "%s", &node_to_find))
22606 vec_add1 (node_to_find, 0);
22607 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
22610 print (vam->ofp, "%s not found...", node_to_find);
22613 node = vam->graph_nodes[p[0]];
22614 print (vam->ofp, "[%d] %s", p[0], node->name);
22615 for (j = 0; j < vec_len (node->next_nodes); j++)
22617 if (node->next_nodes[j] != ~0)
22619 next_node = vam->graph_nodes[node->next_nodes[j]];
22620 print (vam->ofp, " [%d] %s", j, next_node->name);
22627 clib_warning ("parse error '%U'", format_unformat_error,
22633 vec_free (node_to_find);
22642 script (vat_main_t * vam)
22644 #if (VPP_API_TEST_BUILTIN==0)
22646 char *save_current_file;
22647 unformat_input_t save_input;
22648 jmp_buf save_jump_buf;
22649 u32 save_line_number;
22651 FILE *new_fp, *save_ifp;
22653 if (unformat (vam->input, "%s", &s))
22655 new_fp = fopen ((char *) s, "r");
22658 errmsg ("Couldn't open script file %s", s);
22665 errmsg ("Missing script name");
22669 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
22670 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
22671 save_ifp = vam->ifp;
22672 save_line_number = vam->input_line_number;
22673 save_current_file = (char *) vam->current_file;
22675 vam->input_line_number = 0;
22677 vam->current_file = s;
22680 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
22681 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
22682 vam->ifp = save_ifp;
22683 vam->input_line_number = save_line_number;
22684 vam->current_file = (u8 *) save_current_file;
22689 clib_warning ("use the exec command...");
22695 echo (vat_main_t * vam)
22697 print (vam->ofp, "%v", vam->input->buffer);
22701 /* List of API message constructors, CLI names map to api_xxx */
22702 #define foreach_vpe_api_msg \
22703 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
22704 _(sw_interface_dump,"") \
22705 _(sw_interface_set_flags, \
22706 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
22707 _(sw_interface_add_del_address, \
22708 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
22709 _(sw_interface_set_rx_mode, \
22710 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
22711 _(sw_interface_set_table, \
22712 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
22713 _(sw_interface_set_mpls_enable, \
22714 "<intfc> | sw_if_index [disable | dis]") \
22715 _(sw_interface_set_vpath, \
22716 "<intfc> | sw_if_index <id> enable | disable") \
22717 _(sw_interface_set_vxlan_bypass, \
22718 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
22719 _(sw_interface_set_geneve_bypass, \
22720 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
22721 _(sw_interface_set_l2_xconnect, \
22722 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
22723 "enable | disable") \
22724 _(sw_interface_set_l2_bridge, \
22725 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
22726 "[shg <split-horizon-group>] [bvi]\n" \
22727 "enable | disable") \
22728 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
22729 _(bridge_domain_add_del, \
22730 "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") \
22731 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
22733 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
22734 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
22735 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
22737 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
22739 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
22741 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
22743 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
22745 "<vpp-if-name> | sw_if_index <id>") \
22746 _(sw_interface_tap_dump, "") \
22748 "name <name> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>]") \
22750 "<vpp-if-name> | sw_if_index <id>") \
22751 _(sw_interface_tap_v2_dump, "") \
22752 _(ip_table_add_del, \
22753 "table-id <n> [ipv6]\n") \
22754 _(ip_add_del_route, \
22755 "<addr>/<mask> via <addr> [table-id <n>]\n" \
22756 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
22757 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
22758 "[multipath] [count <n>]") \
22759 _(ip_mroute_add_del, \
22760 "<src> <grp>/<mask> [table-id <n>]\n" \
22761 "[<intfc> | sw_if_index <id>] [local] [del]") \
22762 _(mpls_table_add_del, \
22763 "table-id <n>\n") \
22764 _(mpls_route_add_del, \
22765 "<label> <eos> via <addr> [table-id <n>]\n" \
22766 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
22767 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
22768 "[multipath] [count <n>]") \
22769 _(mpls_ip_bind_unbind, \
22770 "<label> <addr/len>") \
22771 _(mpls_tunnel_add_del, \
22772 " via <addr> [table-id <n>]\n" \
22773 "sw_if_index <id>] [l2] [del]") \
22774 _(bier_table_add_del, \
22775 "<label> <sub-domain> <set> <bsl> [del]") \
22776 _(bier_route_add_del, \
22777 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
22778 "[<intfc> | sw_if_index <id>]" \
22779 "[weight <n>] [del] [multipath]") \
22780 _(proxy_arp_add_del, \
22781 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
22782 _(proxy_arp_intfc_enable_disable, \
22783 "<intfc> | sw_if_index <id> enable | disable") \
22784 _(sw_interface_set_unnumbered, \
22785 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
22786 _(ip_neighbor_add_del, \
22787 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
22788 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
22789 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
22790 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
22791 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
22792 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
22793 "[outer_vlan_id_any][inner_vlan_id_any]") \
22794 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
22795 _(reset_fib, "vrf <n> [ipv6]") \
22796 _(dhcp_proxy_config, \
22797 "svr <v46-address> src <v46-address>\n" \
22798 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
22799 _(dhcp_proxy_set_vss, \
22800 "tbl_id <n> [fib_id <n> oui <n> | vpn_ascii_id <text>] [ipv6] [del]") \
22801 _(dhcp_proxy_dump, "ip6") \
22802 _(dhcp_client_config, \
22803 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
22804 _(set_ip_flow_hash, \
22805 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
22806 _(sw_interface_ip6_enable_disable, \
22807 "<intfc> | sw_if_index <id> enable | disable") \
22808 _(sw_interface_ip6_set_link_local_address, \
22809 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
22810 _(ip6nd_proxy_add_del, \
22811 "<intfc> | sw_if_index <id> <ip6-address>") \
22812 _(ip6nd_proxy_dump, "") \
22813 _(sw_interface_ip6nd_ra_prefix, \
22814 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
22815 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
22816 "[nolink] [isno]") \
22817 _(sw_interface_ip6nd_ra_config, \
22818 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
22819 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
22820 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
22821 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
22822 _(l2_patch_add_del, \
22823 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
22824 "enable | disable") \
22825 _(sr_localsid_add_del, \
22826 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
22827 "fib-table <num> (end.psp) sw_if_index <num>") \
22828 _(classify_add_del_table, \
22829 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
22830 " [del] [del-chain] mask <mask-value>\n" \
22831 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
22832 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
22833 _(classify_add_del_session, \
22834 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
22835 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
22836 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
22837 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
22838 _(classify_set_interface_ip_table, \
22839 "<intfc> | sw_if_index <nn> table <nn>") \
22840 _(classify_set_interface_l2_tables, \
22841 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22842 " [other-table <nn>]") \
22843 _(get_node_index, "node <node-name") \
22844 _(add_node_next, "node <node-name> next <next-node-name>") \
22845 _(l2tpv3_create_tunnel, \
22846 "client_address <ip6-addr> our_address <ip6-addr>\n" \
22847 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
22848 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
22849 _(l2tpv3_set_tunnel_cookies, \
22850 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
22851 "[new_remote_cookie <nn>]\n") \
22852 _(l2tpv3_interface_enable_disable, \
22853 "<intfc> | sw_if_index <nn> enable | disable") \
22854 _(l2tpv3_set_lookup_key, \
22855 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
22856 _(sw_if_l2tpv3_tunnel_dump, "") \
22857 _(vxlan_add_del_tunnel, \
22858 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
22859 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
22860 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
22861 _(geneve_add_del_tunnel, \
22862 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
22863 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
22864 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
22865 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22866 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22867 _(gre_add_del_tunnel, \
22868 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [teb] [del]\n") \
22869 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22870 _(l2_fib_clear_table, "") \
22871 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
22872 _(l2_interface_vlan_tag_rewrite, \
22873 "<intfc> | sw_if_index <nn> \n" \
22874 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
22875 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
22876 _(create_vhost_user_if, \
22877 "socket <filename> [server] [renumber <dev_instance>] " \
22878 "[mac <mac_address>]") \
22879 _(modify_vhost_user_if, \
22880 "<intfc> | sw_if_index <nn> socket <filename>\n" \
22881 "[server] [renumber <dev_instance>]") \
22882 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
22883 _(sw_interface_vhost_user_dump, "") \
22884 _(show_version, "") \
22885 _(vxlan_gpe_add_del_tunnel, \
22886 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
22887 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
22888 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
22889 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
22890 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22891 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
22892 _(interface_name_renumber, \
22893 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
22894 _(input_acl_set_interface, \
22895 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22896 " [l2-table <nn>] [del]") \
22897 _(want_ip4_arp_events, "address <ip4-address> [del]") \
22898 _(want_ip6_nd_events, "address <ip6-address> [del]") \
22899 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
22900 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
22901 _(ip_dump, "ipv4 | ipv6") \
22902 _(ipsec_spd_add_del, "spd_id <n> [del]") \
22903 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
22905 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
22906 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
22907 " integ_alg <alg> integ_key <hex>") \
22908 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
22909 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
22910 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
22911 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
22912 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
22913 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
22914 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
22915 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
22916 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n") \
22917 _(ipsec_sa_dump, "[sa_id <n>]") \
22918 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
22919 " <alg> <hex>\n") \
22920 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
22921 _(ikev2_profile_add_del, "name <profile_name> [del]") \
22922 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
22923 "(auth_data 0x<data> | auth_data <data>)") \
22924 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
22925 "(id_data 0x<data> | id_data <data>) (local|remote)") \
22926 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
22927 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
22928 "(local|remote)") \
22929 _(ikev2_set_local_key, "file <absolute_file_path>") \
22930 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
22931 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
22932 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
22933 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
22934 _(ikev2_initiate_sa_init, "<profile_name>") \
22935 _(ikev2_initiate_del_ike_sa, "<ispi>") \
22936 _(ikev2_initiate_del_child_sa, "<ispi>") \
22937 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
22938 _(delete_loopback,"sw_if_index <nn>") \
22939 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
22940 _(map_add_domain, \
22941 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
22942 "ip6-src <ip6addr> " \
22943 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
22944 _(map_del_domain, "index <n>") \
22945 _(map_add_del_rule, \
22946 "index <n> psid <n> dst <ip6addr> [del]") \
22947 _(map_domain_dump, "") \
22948 _(map_rule_dump, "index <map-domain>") \
22949 _(want_interface_events, "enable|disable") \
22950 _(want_stats,"enable|disable") \
22951 _(get_first_msg_id, "client <name>") \
22952 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
22953 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
22954 "fib-id <nn> [ip4][ip6][default]") \
22955 _(get_node_graph, " ") \
22956 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
22957 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
22958 _(ioam_disable, "") \
22959 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
22960 " sw_if_index <sw_if_index> p <priority> " \
22961 "w <weight>] [del]") \
22962 _(one_add_del_locator, "locator-set <locator_name> " \
22963 "iface <intf> | sw_if_index <sw_if_index> " \
22964 "p <priority> w <weight> [del]") \
22965 _(one_add_del_local_eid,"vni <vni> eid " \
22966 "<ipv4|ipv6>/<prefix> | <L2 address> " \
22967 "locator-set <locator_name> [del]" \
22968 "[key-id sha1|sha256 secret-key <secret-key>]")\
22969 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
22970 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
22971 _(one_enable_disable, "enable|disable") \
22972 _(one_map_register_enable_disable, "enable|disable") \
22973 _(one_map_register_fallback_threshold, "<value>") \
22974 _(one_rloc_probe_enable_disable, "enable|disable") \
22975 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
22977 "rloc <locator> p <prio> " \
22978 "w <weight> [rloc <loc> ... ] " \
22979 "action <action> [del-all]") \
22980 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
22982 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
22983 _(one_use_petr, "ip-address> | disable") \
22984 _(one_map_request_mode, "src-dst|dst-only") \
22985 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
22986 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
22987 _(one_locator_set_dump, "[local | remote]") \
22988 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
22989 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
22990 "[local] | [remote]") \
22991 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
22992 _(one_ndp_bd_get, "") \
22993 _(one_ndp_entries_get, "bd <bridge-domain>") \
22994 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
22995 _(one_l2_arp_bd_get, "") \
22996 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
22997 _(one_stats_enable_disable, "enable|disalbe") \
22998 _(show_one_stats_enable_disable, "") \
22999 _(one_eid_table_vni_dump, "") \
23000 _(one_eid_table_map_dump, "l2|l3") \
23001 _(one_map_resolver_dump, "") \
23002 _(one_map_server_dump, "") \
23003 _(one_adjacencies_get, "vni <vni>") \
23004 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
23005 _(show_one_rloc_probe_state, "") \
23006 _(show_one_map_register_state, "") \
23007 _(show_one_status, "") \
23008 _(one_stats_dump, "") \
23009 _(one_stats_flush, "") \
23010 _(one_get_map_request_itr_rlocs, "") \
23011 _(one_map_register_set_ttl, "<ttl>") \
23012 _(one_set_transport_protocol, "udp|api") \
23013 _(one_get_transport_protocol, "") \
23014 _(one_enable_disable_xtr_mode, "enable|disable") \
23015 _(one_show_xtr_mode, "") \
23016 _(one_enable_disable_pitr_mode, "enable|disable") \
23017 _(one_show_pitr_mode, "") \
23018 _(one_enable_disable_petr_mode, "enable|disable") \
23019 _(one_show_petr_mode, "") \
23020 _(show_one_nsh_mapping, "") \
23021 _(show_one_pitr, "") \
23022 _(show_one_use_petr, "") \
23023 _(show_one_map_request_mode, "") \
23024 _(show_one_map_register_ttl, "") \
23025 _(show_one_map_register_fallback_threshold, "") \
23026 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
23027 " sw_if_index <sw_if_index> p <priority> " \
23028 "w <weight>] [del]") \
23029 _(lisp_add_del_locator, "locator-set <locator_name> " \
23030 "iface <intf> | sw_if_index <sw_if_index> " \
23031 "p <priority> w <weight> [del]") \
23032 _(lisp_add_del_local_eid,"vni <vni> eid " \
23033 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23034 "locator-set <locator_name> [del]" \
23035 "[key-id sha1|sha256 secret-key <secret-key>]") \
23036 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
23037 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
23038 _(lisp_enable_disable, "enable|disable") \
23039 _(lisp_map_register_enable_disable, "enable|disable") \
23040 _(lisp_rloc_probe_enable_disable, "enable|disable") \
23041 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23043 "rloc <locator> p <prio> " \
23044 "w <weight> [rloc <loc> ... ] " \
23045 "action <action> [del-all]") \
23046 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23048 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23049 _(lisp_use_petr, "<ip-address> | disable") \
23050 _(lisp_map_request_mode, "src-dst|dst-only") \
23051 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23052 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23053 _(lisp_locator_set_dump, "[local | remote]") \
23054 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
23055 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23056 "[local] | [remote]") \
23057 _(lisp_eid_table_vni_dump, "") \
23058 _(lisp_eid_table_map_dump, "l2|l3") \
23059 _(lisp_map_resolver_dump, "") \
23060 _(lisp_map_server_dump, "") \
23061 _(lisp_adjacencies_get, "vni <vni>") \
23062 _(gpe_fwd_entry_vnis_get, "") \
23063 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
23064 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
23065 "[table <table-id>]") \
23066 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
23067 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
23068 _(gpe_set_encap_mode, "lisp|vxlan") \
23069 _(gpe_get_encap_mode, "") \
23070 _(lisp_gpe_add_del_iface, "up|down") \
23071 _(lisp_gpe_enable_disable, "enable|disable") \
23072 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
23073 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
23074 _(show_lisp_rloc_probe_state, "") \
23075 _(show_lisp_map_register_state, "") \
23076 _(show_lisp_status, "") \
23077 _(lisp_get_map_request_itr_rlocs, "") \
23078 _(show_lisp_pitr, "") \
23079 _(show_lisp_use_petr, "") \
23080 _(show_lisp_map_request_mode, "") \
23081 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
23082 _(af_packet_delete, "name <host interface name>") \
23083 _(policer_add_del, "name <policer name> <params> [del]") \
23084 _(policer_dump, "[name <policer name>]") \
23085 _(policer_classify_set_interface, \
23086 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23087 " [l2-table <nn>] [del]") \
23088 _(policer_classify_dump, "type [ip4|ip6|l2]") \
23089 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
23090 "[master|slave]") \
23091 _(netmap_delete, "name <interface name>") \
23092 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
23093 _(mpls_fib_dump, "") \
23094 _(classify_table_ids, "") \
23095 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
23096 _(classify_table_info, "table_id <nn>") \
23097 _(classify_session_dump, "table_id <nn>") \
23098 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
23099 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
23100 "[template_interval <nn>] [udp_checksum]") \
23101 _(ipfix_exporter_dump, "") \
23102 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
23103 _(ipfix_classify_stream_dump, "") \
23104 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
23105 _(ipfix_classify_table_dump, "") \
23106 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
23107 _(sw_interface_span_dump, "[l2]") \
23108 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
23109 _(pg_create_interface, "if_id <nn>") \
23110 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
23111 _(pg_enable_disable, "[stream <id>] disable") \
23112 _(ip_source_and_port_range_check_add_del, \
23113 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
23114 _(ip_source_and_port_range_check_interface_add_del, \
23115 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
23116 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
23117 _(ipsec_gre_add_del_tunnel, \
23118 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
23119 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
23120 _(delete_subif,"<intfc> | sw_if_index <nn>") \
23121 _(l2_interface_pbb_tag_rewrite, \
23122 "<intfc> | sw_if_index <nn> \n" \
23123 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
23124 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
23125 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
23126 _(flow_classify_set_interface, \
23127 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
23128 _(flow_classify_dump, "type [ip4|ip6]") \
23129 _(ip_fib_dump, "") \
23130 _(ip_mfib_dump, "") \
23131 _(ip6_fib_dump, "") \
23132 _(ip6_mfib_dump, "") \
23133 _(feature_enable_disable, "arc_name <arc_name> " \
23134 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
23135 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
23137 _(l2_xconnect_dump, "") \
23138 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
23139 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
23140 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
23141 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
23142 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
23143 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
23144 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
23145 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
23146 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
23147 _(memfd_segment_create,"size <nnn>") \
23148 _(sock_init_shm, "size <nnn>") \
23149 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
23150 _(dns_enable_disable, "[enable][disable]") \
23151 _(dns_name_server_add_del, "<ip-address> [del]") \
23152 _(dns_resolve_name, "<hostname>") \
23153 _(dns_resolve_ip, "<ip4|ip6>") \
23154 _(dns_name_server_add_del, "<ip-address> [del]") \
23155 _(dns_resolve_name, "<hostname>") \
23156 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
23157 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
23158 _(session_rules_dump, "") \
23159 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
23161 /* List of command functions, CLI names map directly to functions */
23162 #define foreach_cli_function \
23163 _(comment, "usage: comment <ignore-rest-of-line>") \
23164 _(dump_interface_table, "usage: dump_interface_table") \
23165 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
23166 _(dump_ipv4_table, "usage: dump_ipv4_table") \
23167 _(dump_ipv6_table, "usage: dump_ipv6_table") \
23168 _(dump_stats_table, "usage: dump_stats_table") \
23169 _(dump_macro_table, "usage: dump_macro_table ") \
23170 _(dump_node_table, "usage: dump_node_table") \
23171 _(dump_msg_api_table, "usage: dump_msg_api_table") \
23172 _(get_msg_id, "usage: get_msg_id name_and_crc") \
23173 _(echo, "usage: echo <message>") \
23174 _(exec, "usage: exec <vpe-debug-CLI-command>") \
23175 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
23176 _(help, "usage: help") \
23177 _(q, "usage: quit") \
23178 _(quit, "usage: quit") \
23179 _(search_node_table, "usage: search_node_table <name>...") \
23180 _(set, "usage: set <variable-name> <value>") \
23181 _(script, "usage: script <file-name>") \
23182 _(unset, "usage: unset <variable-name>")
23184 static void vl_api_##n##_t_handler_uni \
23185 (vl_api_##n##_t * mp) \
23187 vat_main_t * vam = &vat_main; \
23188 if (vam->json_output) { \
23189 vl_api_##n##_t_handler_json(mp); \
23191 vl_api_##n##_t_handler(mp); \
23194 foreach_vpe_api_reply_msg;
23195 #if VPP_API_TEST_BUILTIN == 0
23196 foreach_standalone_reply_msg;
23201 vat_api_hookup (vat_main_t * vam)
23204 vl_msg_api_set_handlers(VL_API_##N, #n, \
23205 vl_api_##n##_t_handler_uni, \
23207 vl_api_##n##_t_endian, \
23208 vl_api_##n##_t_print, \
23209 sizeof(vl_api_##n##_t), 1);
23210 foreach_vpe_api_reply_msg;
23211 #if VPP_API_TEST_BUILTIN == 0
23212 foreach_standalone_reply_msg;
23216 #if (VPP_API_TEST_BUILTIN==0)
23217 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
23219 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
23221 vam->function_by_name = hash_create_string (0, sizeof (uword));
23223 vam->help_by_name = hash_create_string (0, sizeof (uword));
23226 /* API messages we can send */
23227 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
23228 foreach_vpe_api_msg;
23232 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
23233 foreach_vpe_api_msg;
23236 /* CLI functions */
23237 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
23238 foreach_cli_function;
23242 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
23243 foreach_cli_function;
23247 #if VPP_API_TEST_BUILTIN
23248 static clib_error_t *
23249 vat_api_hookup_shim (vlib_main_t * vm)
23251 vat_api_hookup (&vat_main);
23255 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
23259 * fd.io coding-style-patch-verification: ON
23262 * eval: (c-set-style "gnu")