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/in_out_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>
53 #include <vnet/bonding/node.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 action %d \n",
1352 i + 1, ntohl (mac->sw_if_index),
1353 format_ethernet_address, mac->mac_addr, mac->action);
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;
1779 vl_api_bond_create_reply_t_handler (vl_api_bond_create_reply_t * mp)
1781 vat_main_t *vam = &vat_main;
1782 i32 retval = ntohl (mp->retval);
1784 if (vam->async_mode)
1786 vam->async_errors += (retval < 0);
1790 vam->retval = retval;
1791 vam->sw_if_index = ntohl (mp->sw_if_index);
1792 vam->result_ready = 1;
1796 static void vl_api_bond_create_reply_t_handler_json
1797 (vl_api_bond_create_reply_t * mp)
1799 vat_main_t *vam = &vat_main;
1800 vat_json_node_t node;
1802 vat_json_init_object (&node);
1803 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1804 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1806 vat_json_print (vam->ofp, &node);
1807 vat_json_free (&node);
1809 vam->retval = ntohl (mp->retval);
1810 vam->result_ready = 1;
1814 vl_api_bond_delete_reply_t_handler (vl_api_bond_delete_reply_t * mp)
1816 vat_main_t *vam = &vat_main;
1817 i32 retval = ntohl (mp->retval);
1819 if (vam->async_mode)
1821 vam->async_errors += (retval < 0);
1825 vam->retval = retval;
1826 vam->result_ready = 1;
1830 static void vl_api_bond_delete_reply_t_handler_json
1831 (vl_api_bond_delete_reply_t * mp)
1833 vat_main_t *vam = &vat_main;
1834 vat_json_node_t node;
1836 vat_json_init_object (&node);
1837 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1839 vat_json_print (vam->ofp, &node);
1840 vat_json_free (&node);
1842 vam->retval = ntohl (mp->retval);
1843 vam->result_ready = 1;
1847 vl_api_bond_enslave_reply_t_handler (vl_api_bond_enslave_reply_t * mp)
1849 vat_main_t *vam = &vat_main;
1850 i32 retval = ntohl (mp->retval);
1852 if (vam->async_mode)
1854 vam->async_errors += (retval < 0);
1858 vam->retval = retval;
1859 vam->result_ready = 1;
1863 static void vl_api_bond_enslave_reply_t_handler_json
1864 (vl_api_bond_enslave_reply_t * mp)
1866 vat_main_t *vam = &vat_main;
1867 vat_json_node_t node;
1869 vat_json_init_object (&node);
1870 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1872 vat_json_print (vam->ofp, &node);
1873 vat_json_free (&node);
1875 vam->retval = ntohl (mp->retval);
1876 vam->result_ready = 1;
1880 vl_api_bond_detach_slave_reply_t_handler (vl_api_bond_detach_slave_reply_t *
1883 vat_main_t *vam = &vat_main;
1884 i32 retval = ntohl (mp->retval);
1886 if (vam->async_mode)
1888 vam->async_errors += (retval < 0);
1892 vam->retval = retval;
1893 vam->result_ready = 1;
1897 static void vl_api_bond_detach_slave_reply_t_handler_json
1898 (vl_api_bond_detach_slave_reply_t * mp)
1900 vat_main_t *vam = &vat_main;
1901 vat_json_node_t node;
1903 vat_json_init_object (&node);
1904 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1906 vat_json_print (vam->ofp, &node);
1907 vat_json_free (&node);
1909 vam->retval = ntohl (mp->retval);
1910 vam->result_ready = 1;
1913 static void vl_api_sw_interface_bond_details_t_handler
1914 (vl_api_sw_interface_bond_details_t * mp)
1916 vat_main_t *vam = &vat_main;
1919 "%-16s %-12d %-12U %-13U %-14u %-14u",
1920 mp->interface_name, ntohl (mp->sw_if_index),
1921 format_bond_mode, mp->mode, format_bond_load_balance, mp->lb,
1922 ntohl (mp->active_slaves), ntohl (mp->slaves));
1925 static void vl_api_sw_interface_bond_details_t_handler_json
1926 (vl_api_sw_interface_bond_details_t * mp)
1928 vat_main_t *vam = &vat_main;
1929 vat_json_node_t *node = NULL;
1931 if (VAT_JSON_ARRAY != vam->json_tree.type)
1933 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1934 vat_json_init_array (&vam->json_tree);
1936 node = vat_json_array_add (&vam->json_tree);
1938 vat_json_init_object (node);
1939 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1940 vat_json_object_add_string_copy (node, "interface_name",
1941 mp->interface_name);
1942 vat_json_object_add_uint (node, "mode", mp->mode);
1943 vat_json_object_add_uint (node, "load_balance", mp->lb);
1944 vat_json_object_add_uint (node, "active_slaves", ntohl (mp->active_slaves));
1945 vat_json_object_add_uint (node, "slaves", ntohl (mp->slaves));
1949 api_sw_interface_bond_dump (vat_main_t * vam)
1951 vl_api_sw_interface_bond_dump_t *mp;
1952 vl_api_control_ping_t *mp_ping;
1956 "\n%-16s %-12s %-12s %-13s %-14s %-14s",
1957 "interface name", "sw_if_index", "mode", "load balance",
1958 "active slaves", "slaves");
1960 /* Get list of bond interfaces */
1961 M (SW_INTERFACE_BOND_DUMP, mp);
1964 /* Use a control ping for synchronization */
1965 MPING (CONTROL_PING, mp_ping);
1972 static void vl_api_sw_interface_slave_details_t_handler
1973 (vl_api_sw_interface_slave_details_t * mp)
1975 vat_main_t *vam = &vat_main;
1978 "%-25s %-12d %-12d %d", mp->interface_name,
1979 ntohl (mp->sw_if_index), mp->is_passive, mp->is_long_timeout);
1982 static void vl_api_sw_interface_slave_details_t_handler_json
1983 (vl_api_sw_interface_slave_details_t * mp)
1985 vat_main_t *vam = &vat_main;
1986 vat_json_node_t *node = NULL;
1988 if (VAT_JSON_ARRAY != vam->json_tree.type)
1990 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1991 vat_json_init_array (&vam->json_tree);
1993 node = vat_json_array_add (&vam->json_tree);
1995 vat_json_init_object (node);
1996 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1997 vat_json_object_add_string_copy (node, "interface_name",
1998 mp->interface_name);
1999 vat_json_object_add_uint (node, "passive", mp->is_passive);
2000 vat_json_object_add_uint (node, "long_timeout", mp->is_long_timeout);
2004 api_sw_interface_slave_dump (vat_main_t * vam)
2006 unformat_input_t *i = vam->input;
2007 vl_api_sw_interface_slave_dump_t *mp;
2008 vl_api_control_ping_t *mp_ping;
2009 u32 sw_if_index = ~0;
2010 u8 sw_if_index_set = 0;
2013 /* Parse args required to build the message */
2014 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2016 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2017 sw_if_index_set = 1;
2018 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2019 sw_if_index_set = 1;
2024 if (sw_if_index_set == 0)
2026 errmsg ("missing vpp interface name. ");
2031 "\n%-25s %-12s %-12s %s",
2032 "slave interface name", "sw_if_index", "passive", "long_timeout");
2034 /* Get list of bond interfaces */
2035 M (SW_INTERFACE_SLAVE_DUMP, mp);
2036 mp->sw_if_index = ntohl (sw_if_index);
2039 /* Use a control ping for synchronization */
2040 MPING (CONTROL_PING, mp_ping);
2047 static void vl_api_mpls_tunnel_add_del_reply_t_handler
2048 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2050 vat_main_t *vam = &vat_main;
2051 i32 retval = ntohl (mp->retval);
2052 if (vam->async_mode)
2054 vam->async_errors += (retval < 0);
2058 vam->retval = retval;
2059 vam->result_ready = 1;
2063 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
2064 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2066 vat_main_t *vam = &vat_main;
2067 vat_json_node_t node;
2069 vat_json_init_object (&node);
2070 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2071 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
2072 ntohl (mp->sw_if_index));
2074 vat_json_print (vam->ofp, &node);
2075 vat_json_free (&node);
2077 vam->retval = ntohl (mp->retval);
2078 vam->result_ready = 1;
2081 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
2082 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2084 vat_main_t *vam = &vat_main;
2085 i32 retval = ntohl (mp->retval);
2086 if (vam->async_mode)
2088 vam->async_errors += (retval < 0);
2092 vam->retval = retval;
2093 vam->sw_if_index = ntohl (mp->sw_if_index);
2094 vam->result_ready = 1;
2098 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
2099 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2101 vat_main_t *vam = &vat_main;
2102 vat_json_node_t node;
2104 vat_json_init_object (&node);
2105 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2106 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2108 vat_json_print (vam->ofp, &node);
2109 vat_json_free (&node);
2111 vam->retval = ntohl (mp->retval);
2112 vam->result_ready = 1;
2115 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
2116 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2118 vat_main_t *vam = &vat_main;
2119 i32 retval = ntohl (mp->retval);
2120 if (vam->async_mode)
2122 vam->async_errors += (retval < 0);
2126 vam->retval = retval;
2127 vam->result_ready = 1;
2131 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
2132 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2134 vat_main_t *vam = &vat_main;
2135 vat_json_node_t node;
2137 vat_json_init_object (&node);
2138 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2139 vat_json_object_add_uint (&node, "fwd_entry_index",
2140 clib_net_to_host_u32 (mp->fwd_entry_index));
2142 vat_json_print (vam->ofp, &node);
2143 vat_json_free (&node);
2145 vam->retval = ntohl (mp->retval);
2146 vam->result_ready = 1;
2150 format_lisp_transport_protocol (u8 * s, va_list * args)
2152 u32 proto = va_arg (*args, u32);
2157 return format (s, "udp");
2159 return format (s, "api");
2166 static void vl_api_one_get_transport_protocol_reply_t_handler
2167 (vl_api_one_get_transport_protocol_reply_t * mp)
2169 vat_main_t *vam = &vat_main;
2170 i32 retval = ntohl (mp->retval);
2171 if (vam->async_mode)
2173 vam->async_errors += (retval < 0);
2177 u32 proto = mp->protocol;
2178 print (vam->ofp, "Transport protocol: %U",
2179 format_lisp_transport_protocol, proto);
2180 vam->retval = retval;
2181 vam->result_ready = 1;
2185 static void vl_api_one_get_transport_protocol_reply_t_handler_json
2186 (vl_api_one_get_transport_protocol_reply_t * mp)
2188 vat_main_t *vam = &vat_main;
2189 vat_json_node_t node;
2192 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
2195 vat_json_init_object (&node);
2196 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2197 vat_json_object_add_string_copy (&node, "transport-protocol", s);
2200 vat_json_print (vam->ofp, &node);
2201 vat_json_free (&node);
2203 vam->retval = ntohl (mp->retval);
2204 vam->result_ready = 1;
2207 static void vl_api_one_add_del_locator_set_reply_t_handler
2208 (vl_api_one_add_del_locator_set_reply_t * mp)
2210 vat_main_t *vam = &vat_main;
2211 i32 retval = ntohl (mp->retval);
2212 if (vam->async_mode)
2214 vam->async_errors += (retval < 0);
2218 vam->retval = retval;
2219 vam->result_ready = 1;
2223 static void vl_api_one_add_del_locator_set_reply_t_handler_json
2224 (vl_api_one_add_del_locator_set_reply_t * mp)
2226 vat_main_t *vam = &vat_main;
2227 vat_json_node_t node;
2229 vat_json_init_object (&node);
2230 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2231 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
2233 vat_json_print (vam->ofp, &node);
2234 vat_json_free (&node);
2236 vam->retval = ntohl (mp->retval);
2237 vam->result_ready = 1;
2240 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
2241 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2243 vat_main_t *vam = &vat_main;
2244 i32 retval = ntohl (mp->retval);
2245 if (vam->async_mode)
2247 vam->async_errors += (retval < 0);
2251 vam->retval = retval;
2252 vam->sw_if_index = ntohl (mp->sw_if_index);
2253 vam->result_ready = 1;
2255 vam->regenerate_interface_table = 1;
2258 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
2259 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2261 vat_main_t *vam = &vat_main;
2262 vat_json_node_t node;
2264 vat_json_init_object (&node);
2265 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2266 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2268 vat_json_print (vam->ofp, &node);
2269 vat_json_free (&node);
2271 vam->retval = ntohl (mp->retval);
2272 vam->result_ready = 1;
2275 static void vl_api_geneve_add_del_tunnel_reply_t_handler
2276 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2278 vat_main_t *vam = &vat_main;
2279 i32 retval = ntohl (mp->retval);
2280 if (vam->async_mode)
2282 vam->async_errors += (retval < 0);
2286 vam->retval = retval;
2287 vam->sw_if_index = ntohl (mp->sw_if_index);
2288 vam->result_ready = 1;
2292 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
2293 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2295 vat_main_t *vam = &vat_main;
2296 vat_json_node_t node;
2298 vat_json_init_object (&node);
2299 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2300 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2302 vat_json_print (vam->ofp, &node);
2303 vat_json_free (&node);
2305 vam->retval = ntohl (mp->retval);
2306 vam->result_ready = 1;
2309 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
2310 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2312 vat_main_t *vam = &vat_main;
2313 i32 retval = ntohl (mp->retval);
2314 if (vam->async_mode)
2316 vam->async_errors += (retval < 0);
2320 vam->retval = retval;
2321 vam->sw_if_index = ntohl (mp->sw_if_index);
2322 vam->result_ready = 1;
2324 vam->regenerate_interface_table = 1;
2327 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
2328 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2330 vat_main_t *vam = &vat_main;
2331 vat_json_node_t node;
2333 vat_json_init_object (&node);
2334 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2335 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2337 vat_json_print (vam->ofp, &node);
2338 vat_json_free (&node);
2340 vam->retval = ntohl (mp->retval);
2341 vam->result_ready = 1;
2344 static void vl_api_gre_add_del_tunnel_reply_t_handler
2345 (vl_api_gre_add_del_tunnel_reply_t * mp)
2347 vat_main_t *vam = &vat_main;
2348 i32 retval = ntohl (mp->retval);
2349 if (vam->async_mode)
2351 vam->async_errors += (retval < 0);
2355 vam->retval = retval;
2356 vam->sw_if_index = ntohl (mp->sw_if_index);
2357 vam->result_ready = 1;
2361 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
2362 (vl_api_gre_add_del_tunnel_reply_t * mp)
2364 vat_main_t *vam = &vat_main;
2365 vat_json_node_t node;
2367 vat_json_init_object (&node);
2368 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2369 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2371 vat_json_print (vam->ofp, &node);
2372 vat_json_free (&node);
2374 vam->retval = ntohl (mp->retval);
2375 vam->result_ready = 1;
2378 static void vl_api_create_vhost_user_if_reply_t_handler
2379 (vl_api_create_vhost_user_if_reply_t * mp)
2381 vat_main_t *vam = &vat_main;
2382 i32 retval = ntohl (mp->retval);
2383 if (vam->async_mode)
2385 vam->async_errors += (retval < 0);
2389 vam->retval = retval;
2390 vam->sw_if_index = ntohl (mp->sw_if_index);
2391 vam->result_ready = 1;
2393 vam->regenerate_interface_table = 1;
2396 static void vl_api_create_vhost_user_if_reply_t_handler_json
2397 (vl_api_create_vhost_user_if_reply_t * mp)
2399 vat_main_t *vam = &vat_main;
2400 vat_json_node_t node;
2402 vat_json_init_object (&node);
2403 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2404 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2406 vat_json_print (vam->ofp, &node);
2407 vat_json_free (&node);
2409 vam->retval = ntohl (mp->retval);
2410 vam->result_ready = 1;
2413 static clib_error_t *
2414 receive_fd_msg (int socket_fd, int *my_fd)
2417 char ctl[CMSG_SPACE (sizeof (int)) + CMSG_SPACE (sizeof (struct ucred))];
2418 struct msghdr mh = { 0 };
2419 struct iovec iov[1];
2421 struct ucred *cr = 0;
2422 struct cmsghdr *cmsg;
2423 pid_t pid __attribute__ ((unused));
2424 uid_t uid __attribute__ ((unused));
2425 gid_t gid __attribute__ ((unused));
2427 iov[0].iov_base = msgbuf;
2431 mh.msg_control = ctl;
2432 mh.msg_controllen = sizeof (ctl);
2434 memset (ctl, 0, sizeof (ctl));
2436 /* receive the incoming message */
2437 size = recvmsg (socket_fd, &mh, 0);
2440 return (size == 0) ? clib_error_return (0, "disconnected") :
2441 clib_error_return_unix (0, "recvmsg: malformed message (fd %d)",
2445 cmsg = CMSG_FIRSTHDR (&mh);
2448 if (cmsg->cmsg_level == SOL_SOCKET)
2450 if (cmsg->cmsg_type == SCM_CREDENTIALS)
2452 cr = (struct ucred *) CMSG_DATA (cmsg);
2457 else if (cmsg->cmsg_type == SCM_RIGHTS)
2459 clib_memcpy (my_fd, CMSG_DATA (cmsg), sizeof (int));
2462 cmsg = CMSG_NXTHDR (&mh, cmsg);
2467 static void vl_api_memfd_segment_create_reply_t_handler
2468 (vl_api_memfd_segment_create_reply_t * mp)
2470 /* Dont bother in the builtin version */
2471 #if VPP_API_TEST_BUILTIN == 0
2472 vat_main_t *vam = &vat_main;
2473 api_main_t *am = &api_main;
2474 socket_client_main_t *scm = vam->socket_client_main;
2476 clib_error_t *error;
2477 ssvm_private_t memfd;
2478 i32 retval = ntohl (mp->retval);
2482 error = receive_fd_msg (scm->socket_fd, &my_fd);
2489 memset (&memfd, 0, sizeof (memfd));
2492 vam->client_index_invalid = 1;
2494 /* Note: this closes memfd.fd */
2495 retval = ssvm_slave_init_memfd (&memfd);
2497 clib_warning ("WARNING: segment map returned %d", retval);
2499 /* Pivot to the memory client segment that vpp just created */
2501 am->vlib_rp = (void *) (memfd.requested_va + MMAP_PAGESIZE);
2503 am->shmem_hdr = (void *) am->vlib_rp->user_ctx;
2505 vl_client_install_client_message_handlers ();
2507 vl_client_connect_to_vlib_no_map ("pvt",
2509 32 /* input_queue_length */ );
2510 vam->vl_input_queue = am->shmem_hdr->vl_input_queue;
2512 vl_socket_client_enable_disable (0 /* disable socket */ );
2516 if (vam->async_mode)
2518 vam->async_errors += (retval < 0);
2522 vam->retval = retval;
2523 vam->result_ready = 1;
2528 static void vl_api_memfd_segment_create_reply_t_handler_json
2529 (vl_api_memfd_segment_create_reply_t * mp)
2531 clib_warning ("no");
2534 static void vl_api_dns_resolve_name_reply_t_handler
2535 (vl_api_dns_resolve_name_reply_t * mp)
2537 vat_main_t *vam = &vat_main;
2538 i32 retval = ntohl (mp->retval);
2539 if (vam->async_mode)
2541 vam->async_errors += (retval < 0);
2545 vam->retval = retval;
2546 vam->result_ready = 1;
2551 clib_warning ("ip4 address %U", format_ip4_address,
2552 (ip4_address_t *) mp->ip4_address);
2554 clib_warning ("ip6 address %U", format_ip6_address,
2555 (ip6_address_t *) mp->ip6_address);
2558 clib_warning ("retval %d", retval);
2562 static void vl_api_dns_resolve_name_reply_t_handler_json
2563 (vl_api_dns_resolve_name_reply_t * mp)
2565 clib_warning ("not implemented");
2568 static void vl_api_dns_resolve_ip_reply_t_handler
2569 (vl_api_dns_resolve_ip_reply_t * mp)
2571 vat_main_t *vam = &vat_main;
2572 i32 retval = ntohl (mp->retval);
2573 if (vam->async_mode)
2575 vam->async_errors += (retval < 0);
2579 vam->retval = retval;
2580 vam->result_ready = 1;
2584 clib_warning ("canonical name %s", mp->name);
2587 clib_warning ("retval %d", retval);
2591 static void vl_api_dns_resolve_ip_reply_t_handler_json
2592 (vl_api_dns_resolve_ip_reply_t * mp)
2594 clib_warning ("not implemented");
2598 static void vl_api_ip_address_details_t_handler
2599 (vl_api_ip_address_details_t * mp)
2601 vat_main_t *vam = &vat_main;
2602 static ip_address_details_t empty_ip_address_details = { {0} };
2603 ip_address_details_t *address = NULL;
2604 ip_details_t *current_ip_details = NULL;
2605 ip_details_t *details = NULL;
2607 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2609 if (!details || vam->current_sw_if_index >= vec_len (details)
2610 || !details[vam->current_sw_if_index].present)
2612 errmsg ("ip address details arrived but not stored");
2613 errmsg ("ip_dump should be called first");
2617 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2619 #define addresses (current_ip_details->addr)
2621 vec_validate_init_empty (addresses, vec_len (addresses),
2622 empty_ip_address_details);
2624 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2626 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
2627 address->prefix_length = mp->prefix_length;
2631 static void vl_api_ip_address_details_t_handler_json
2632 (vl_api_ip_address_details_t * mp)
2634 vat_main_t *vam = &vat_main;
2635 vat_json_node_t *node = NULL;
2636 struct in6_addr ip6;
2639 if (VAT_JSON_ARRAY != vam->json_tree.type)
2641 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2642 vat_json_init_array (&vam->json_tree);
2644 node = vat_json_array_add (&vam->json_tree);
2646 vat_json_init_object (node);
2649 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
2650 vat_json_object_add_ip6 (node, "ip", ip6);
2654 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
2655 vat_json_object_add_ip4 (node, "ip", ip4);
2657 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
2661 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2663 vat_main_t *vam = &vat_main;
2664 static ip_details_t empty_ip_details = { 0 };
2665 ip_details_t *ip = NULL;
2666 u32 sw_if_index = ~0;
2668 sw_if_index = ntohl (mp->sw_if_index);
2670 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2671 sw_if_index, empty_ip_details);
2673 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2680 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2682 vat_main_t *vam = &vat_main;
2684 if (VAT_JSON_ARRAY != vam->json_tree.type)
2686 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2687 vat_json_init_array (&vam->json_tree);
2689 vat_json_array_add_uint (&vam->json_tree,
2690 clib_net_to_host_u32 (mp->sw_if_index));
2693 static void vl_api_map_domain_details_t_handler_json
2694 (vl_api_map_domain_details_t * mp)
2696 vat_json_node_t *node = NULL;
2697 vat_main_t *vam = &vat_main;
2698 struct in6_addr ip6;
2701 if (VAT_JSON_ARRAY != vam->json_tree.type)
2703 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2704 vat_json_init_array (&vam->json_tree);
2707 node = vat_json_array_add (&vam->json_tree);
2708 vat_json_init_object (node);
2710 vat_json_object_add_uint (node, "domain_index",
2711 clib_net_to_host_u32 (mp->domain_index));
2712 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
2713 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
2714 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
2715 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
2716 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
2717 vat_json_object_add_ip6 (node, "ip6_src", ip6);
2718 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
2719 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
2720 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
2721 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
2722 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
2723 vat_json_object_add_int (node, "psid_length", mp->psid_length);
2724 vat_json_object_add_uint (node, "flags", mp->flags);
2725 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
2726 vat_json_object_add_int (node, "is_translation", mp->is_translation);
2729 static void vl_api_map_domain_details_t_handler
2730 (vl_api_map_domain_details_t * mp)
2732 vat_main_t *vam = &vat_main;
2734 if (mp->is_translation)
2737 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
2738 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2739 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2740 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
2741 clib_net_to_host_u32 (mp->domain_index));
2746 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
2747 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2748 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2749 format_ip6_address, mp->ip6_src,
2750 clib_net_to_host_u32 (mp->domain_index));
2752 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
2753 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
2754 mp->is_translation ? "map-t" : "");
2757 static void vl_api_map_rule_details_t_handler_json
2758 (vl_api_map_rule_details_t * mp)
2760 struct in6_addr ip6;
2761 vat_json_node_t *node = NULL;
2762 vat_main_t *vam = &vat_main;
2764 if (VAT_JSON_ARRAY != vam->json_tree.type)
2766 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2767 vat_json_init_array (&vam->json_tree);
2770 node = vat_json_array_add (&vam->json_tree);
2771 vat_json_init_object (node);
2773 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
2774 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
2775 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
2779 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
2781 vat_main_t *vam = &vat_main;
2782 print (vam->ofp, " %d (psid) %U (ip6-dst)",
2783 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
2787 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2789 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2790 "router_addr %U host_mac %U",
2791 ntohl (mp->pid), mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
2792 format_ip4_address, &mp->host_address,
2793 format_ip4_address, &mp->router_address,
2794 format_ethernet_address, mp->host_mac);
2797 static void vl_api_dhcp_compl_event_t_handler_json
2798 (vl_api_dhcp_compl_event_t * mp)
2800 /* JSON output not supported */
2804 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2807 vat_main_t *vam = &vat_main;
2808 static u64 default_counter = 0;
2810 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2812 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2813 sw_if_index, default_counter);
2814 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2818 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2819 interface_counter_t counter)
2821 vat_main_t *vam = &vat_main;
2822 static interface_counter_t default_counter = { 0, };
2824 vec_validate_init_empty (vam->combined_interface_counters,
2825 vnet_counter_type, NULL);
2826 vec_validate_init_empty (vam->combined_interface_counters
2827 [vnet_counter_type], sw_if_index, default_counter);
2828 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2831 static void vl_api_vnet_interface_simple_counters_t_handler
2832 (vl_api_vnet_interface_simple_counters_t * mp)
2837 static void vl_api_vnet_interface_combined_counters_t_handler
2838 (vl_api_vnet_interface_combined_counters_t * mp)
2843 static void vl_api_vnet_interface_simple_counters_t_handler_json
2844 (vl_api_vnet_interface_simple_counters_t * mp)
2849 u32 first_sw_if_index;
2852 count = ntohl (mp->count);
2853 first_sw_if_index = ntohl (mp->first_sw_if_index);
2855 v_packets = (u64 *) & mp->data;
2856 for (i = 0; i < count; i++)
2858 packets = clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2859 set_simple_interface_counter (mp->vnet_counter_type,
2860 first_sw_if_index + i, packets);
2865 static void vl_api_vnet_interface_combined_counters_t_handler_json
2866 (vl_api_vnet_interface_combined_counters_t * mp)
2868 interface_counter_t counter;
2870 u32 first_sw_if_index;
2874 count = ntohl (mp->count);
2875 first_sw_if_index = ntohl (mp->first_sw_if_index);
2877 v = (vlib_counter_t *) & mp->data;
2878 for (i = 0; i < count; i++)
2881 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2883 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2884 set_combined_interface_counter (mp->vnet_counter_type,
2885 first_sw_if_index + i, counter);
2891 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2893 vat_main_t *vam = &vat_main;
2896 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2898 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2907 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2909 vat_main_t *vam = &vat_main;
2912 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2914 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2922 static void vl_api_vnet_ip4_fib_counters_t_handler
2923 (vl_api_vnet_ip4_fib_counters_t * mp)
2928 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2929 (vl_api_vnet_ip4_fib_counters_t * mp)
2931 vat_main_t *vam = &vat_main;
2932 vl_api_ip4_fib_counter_t *v;
2933 ip4_fib_counter_t *counter;
2940 vrf_id = ntohl (mp->vrf_id);
2941 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2942 if (~0 == vrf_index)
2944 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2945 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2946 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2947 vec_validate (vam->ip4_fib_counters, vrf_index);
2948 vam->ip4_fib_counters[vrf_index] = NULL;
2951 vec_free (vam->ip4_fib_counters[vrf_index]);
2952 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2953 count = ntohl (mp->count);
2954 for (i = 0; i < count; i++)
2956 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2957 counter = &vam->ip4_fib_counters[vrf_index][i];
2958 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2959 counter->address = ip4;
2960 counter->address_length = v->address_length;
2961 counter->packets = clib_net_to_host_u64 (v->packets);
2962 counter->bytes = clib_net_to_host_u64 (v->bytes);
2967 static void vl_api_vnet_ip4_nbr_counters_t_handler
2968 (vl_api_vnet_ip4_nbr_counters_t * mp)
2973 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2974 (vl_api_vnet_ip4_nbr_counters_t * mp)
2976 vat_main_t *vam = &vat_main;
2977 vl_api_ip4_nbr_counter_t *v;
2978 ip4_nbr_counter_t *counter;
2983 sw_if_index = ntohl (mp->sw_if_index);
2984 count = ntohl (mp->count);
2985 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2988 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2990 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2991 for (i = 0; i < count; i++)
2993 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2994 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2995 counter->address.s_addr = v->address;
2996 counter->packets = clib_net_to_host_u64 (v->packets);
2997 counter->bytes = clib_net_to_host_u64 (v->bytes);
2998 counter->linkt = v->link_type;
3003 static void vl_api_vnet_ip6_fib_counters_t_handler
3004 (vl_api_vnet_ip6_fib_counters_t * mp)
3009 static void vl_api_vnet_ip6_fib_counters_t_handler_json
3010 (vl_api_vnet_ip6_fib_counters_t * mp)
3012 vat_main_t *vam = &vat_main;
3013 vl_api_ip6_fib_counter_t *v;
3014 ip6_fib_counter_t *counter;
3015 struct in6_addr ip6;
3021 vrf_id = ntohl (mp->vrf_id);
3022 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
3023 if (~0 == vrf_index)
3025 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
3026 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
3027 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
3028 vec_validate (vam->ip6_fib_counters, vrf_index);
3029 vam->ip6_fib_counters[vrf_index] = NULL;
3032 vec_free (vam->ip6_fib_counters[vrf_index]);
3033 v = (vl_api_ip6_fib_counter_t *) & mp->c;
3034 count = ntohl (mp->count);
3035 for (i = 0; i < count; i++)
3037 vec_validate (vam->ip6_fib_counters[vrf_index], i);
3038 counter = &vam->ip6_fib_counters[vrf_index][i];
3039 clib_memcpy (&ip6, &v->address, sizeof (ip6));
3040 counter->address = ip6;
3041 counter->address_length = v->address_length;
3042 counter->packets = clib_net_to_host_u64 (v->packets);
3043 counter->bytes = clib_net_to_host_u64 (v->bytes);
3048 static void vl_api_vnet_ip6_nbr_counters_t_handler
3049 (vl_api_vnet_ip6_nbr_counters_t * mp)
3054 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
3055 (vl_api_vnet_ip6_nbr_counters_t * mp)
3057 vat_main_t *vam = &vat_main;
3058 vl_api_ip6_nbr_counter_t *v;
3059 ip6_nbr_counter_t *counter;
3060 struct in6_addr ip6;
3065 sw_if_index = ntohl (mp->sw_if_index);
3066 count = ntohl (mp->count);
3067 vec_validate (vam->ip6_nbr_counters, sw_if_index);
3070 vec_free (vam->ip6_nbr_counters[sw_if_index]);
3072 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
3073 for (i = 0; i < count; i++)
3075 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
3076 counter = &vam->ip6_nbr_counters[sw_if_index][i];
3077 clib_memcpy (&ip6, &v->address, sizeof (ip6));
3078 counter->address = ip6;
3079 counter->packets = clib_net_to_host_u64 (v->packets);
3080 counter->bytes = clib_net_to_host_u64 (v->bytes);
3085 static void vl_api_get_first_msg_id_reply_t_handler
3086 (vl_api_get_first_msg_id_reply_t * mp)
3088 vat_main_t *vam = &vat_main;
3089 i32 retval = ntohl (mp->retval);
3091 if (vam->async_mode)
3093 vam->async_errors += (retval < 0);
3097 vam->retval = retval;
3098 vam->result_ready = 1;
3102 errmsg ("first message id %d", ntohs (mp->first_msg_id));
3106 static void vl_api_get_first_msg_id_reply_t_handler_json
3107 (vl_api_get_first_msg_id_reply_t * mp)
3109 vat_main_t *vam = &vat_main;
3110 vat_json_node_t node;
3112 vat_json_init_object (&node);
3113 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3114 vat_json_object_add_uint (&node, "first_msg_id",
3115 (uint) ntohs (mp->first_msg_id));
3117 vat_json_print (vam->ofp, &node);
3118 vat_json_free (&node);
3120 vam->retval = ntohl (mp->retval);
3121 vam->result_ready = 1;
3124 static void vl_api_get_node_graph_reply_t_handler
3125 (vl_api_get_node_graph_reply_t * mp)
3127 vat_main_t *vam = &vat_main;
3128 api_main_t *am = &api_main;
3129 i32 retval = ntohl (mp->retval);
3130 u8 *pvt_copy, *reply;
3135 if (vam->async_mode)
3137 vam->async_errors += (retval < 0);
3141 vam->retval = retval;
3142 vam->result_ready = 1;
3145 /* "Should never happen..." */
3149 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
3150 pvt_copy = vec_dup (reply);
3152 /* Toss the shared-memory original... */
3153 pthread_mutex_lock (&am->vlib_rp->mutex);
3154 oldheap = svm_push_data_heap (am->vlib_rp);
3158 svm_pop_heap (oldheap);
3159 pthread_mutex_unlock (&am->vlib_rp->mutex);
3161 if (vam->graph_nodes)
3163 hash_free (vam->graph_node_index_by_name);
3165 for (i = 0; i < vec_len (vam->graph_nodes); i++)
3167 node = vam->graph_nodes[i];
3168 vec_free (node->name);
3169 vec_free (node->next_nodes);
3172 vec_free (vam->graph_nodes);
3175 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
3176 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
3177 vec_free (pvt_copy);
3179 for (i = 0; i < vec_len (vam->graph_nodes); i++)
3181 node = vam->graph_nodes[i];
3182 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
3186 static void vl_api_get_node_graph_reply_t_handler_json
3187 (vl_api_get_node_graph_reply_t * mp)
3189 vat_main_t *vam = &vat_main;
3190 api_main_t *am = &api_main;
3192 vat_json_node_t node;
3195 /* $$$$ make this real? */
3196 vat_json_init_object (&node);
3197 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3198 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
3200 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
3202 /* Toss the shared-memory original... */
3203 pthread_mutex_lock (&am->vlib_rp->mutex);
3204 oldheap = svm_push_data_heap (am->vlib_rp);
3208 svm_pop_heap (oldheap);
3209 pthread_mutex_unlock (&am->vlib_rp->mutex);
3211 vat_json_print (vam->ofp, &node);
3212 vat_json_free (&node);
3214 vam->retval = ntohl (mp->retval);
3215 vam->result_ready = 1;
3219 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
3221 vat_main_t *vam = &vat_main;
3226 s = format (s, "%=16d%=16d%=16d",
3227 ntohl (mp->sw_if_index), mp->priority, mp->weight);
3231 s = format (s, "%=16U%=16d%=16d",
3232 mp->is_ipv6 ? format_ip6_address :
3234 mp->ip_address, mp->priority, mp->weight);
3237 print (vam->ofp, "%v", s);
3242 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
3244 vat_main_t *vam = &vat_main;
3245 vat_json_node_t *node = NULL;
3246 struct in6_addr ip6;
3249 if (VAT_JSON_ARRAY != vam->json_tree.type)
3251 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3252 vat_json_init_array (&vam->json_tree);
3254 node = vat_json_array_add (&vam->json_tree);
3255 vat_json_init_object (node);
3257 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
3258 vat_json_object_add_uint (node, "priority", mp->priority);
3259 vat_json_object_add_uint (node, "weight", mp->weight);
3262 vat_json_object_add_uint (node, "sw_if_index",
3263 clib_net_to_host_u32 (mp->sw_if_index));
3268 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3269 vat_json_object_add_ip6 (node, "address", ip6);
3273 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3274 vat_json_object_add_ip4 (node, "address", ip4);
3280 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
3283 vat_main_t *vam = &vat_main;
3286 ls_name = format (0, "%s", mp->ls_name);
3288 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
3294 vl_api_one_locator_set_details_t_handler_json
3295 (vl_api_one_locator_set_details_t * mp)
3297 vat_main_t *vam = &vat_main;
3298 vat_json_node_t *node = 0;
3301 ls_name = format (0, "%s", mp->ls_name);
3302 vec_add1 (ls_name, 0);
3304 if (VAT_JSON_ARRAY != vam->json_tree.type)
3306 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3307 vat_json_init_array (&vam->json_tree);
3309 node = vat_json_array_add (&vam->json_tree);
3311 vat_json_init_object (node);
3312 vat_json_object_add_string_copy (node, "ls_name", ls_name);
3313 vat_json_object_add_uint (node, "ls_index",
3314 clib_net_to_host_u32 (mp->ls_index));
3322 } __attribute__ ((__packed__)) lisp_nsh_api_t;
3325 unformat_nsh_address (unformat_input_t * input, va_list * args)
3327 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
3328 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
3332 format_nsh_address_vat (u8 * s, va_list * args)
3334 nsh_t *a = va_arg (*args, nsh_t *);
3335 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
3339 format_lisp_flat_eid (u8 * s, va_list * args)
3341 u32 type = va_arg (*args, u32);
3342 u8 *eid = va_arg (*args, u8 *);
3343 u32 eid_len = va_arg (*args, u32);
3348 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
3350 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
3352 return format (s, "%U", format_ethernet_address, eid);
3354 return format (s, "%U", format_nsh_address_vat, eid);
3360 format_lisp_eid_vat (u8 * s, va_list * args)
3362 u32 type = va_arg (*args, u32);
3363 u8 *eid = va_arg (*args, u8 *);
3364 u32 eid_len = va_arg (*args, u32);
3365 u8 *seid = va_arg (*args, u8 *);
3366 u32 seid_len = va_arg (*args, u32);
3367 u32 is_src_dst = va_arg (*args, u32);
3370 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
3372 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
3378 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
3380 vat_main_t *vam = &vat_main;
3381 u8 *s = 0, *eid = 0;
3383 if (~0 == mp->locator_set_index)
3384 s = format (0, "action: %d", mp->action);
3386 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3388 eid = format (0, "%U", format_lisp_eid_vat,
3392 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3395 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3396 clib_net_to_host_u32 (mp->vni),
3398 mp->is_local ? "local" : "remote",
3399 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3400 clib_net_to_host_u16 (mp->key_id), mp->key);
3407 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3410 vat_main_t *vam = &vat_main;
3411 vat_json_node_t *node = 0;
3414 if (VAT_JSON_ARRAY != vam->json_tree.type)
3416 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3417 vat_json_init_array (&vam->json_tree);
3419 node = vat_json_array_add (&vam->json_tree);
3421 vat_json_init_object (node);
3422 if (~0 == mp->locator_set_index)
3423 vat_json_object_add_uint (node, "action", mp->action);
3425 vat_json_object_add_uint (node, "locator_set_index",
3426 clib_net_to_host_u32 (mp->locator_set_index));
3428 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3429 if (mp->eid_type == 3)
3431 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3432 vat_json_init_object (nsh_json);
3433 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3434 vat_json_object_add_uint (nsh_json, "spi",
3435 clib_net_to_host_u32 (nsh->spi));
3436 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3440 eid = format (0, "%U", format_lisp_eid_vat,
3444 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3446 vat_json_object_add_string_copy (node, "eid", eid);
3449 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3450 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3451 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3455 vat_json_object_add_uint (node, "key_id",
3456 clib_net_to_host_u16 (mp->key_id));
3457 vat_json_object_add_string_copy (node, "key", mp->key);
3462 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3464 vat_main_t *vam = &vat_main;
3465 u8 *seid = 0, *deid = 0;
3466 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3468 deid = format (0, "%U", format_lisp_eid_vat,
3469 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3471 seid = format (0, "%U", format_lisp_eid_vat,
3472 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3478 format_ip_address_fcn = format_ip4_address;
3480 format_ip_address_fcn = format_ip6_address;
3483 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3484 clib_net_to_host_u32 (mp->vni),
3486 format_ip_address_fcn, mp->lloc,
3487 format_ip_address_fcn, mp->rloc,
3488 clib_net_to_host_u32 (mp->pkt_count),
3489 clib_net_to_host_u32 (mp->bytes));
3496 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3498 struct in6_addr ip6;
3500 vat_main_t *vam = &vat_main;
3501 vat_json_node_t *node = 0;
3502 u8 *deid = 0, *seid = 0;
3504 if (VAT_JSON_ARRAY != vam->json_tree.type)
3506 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3507 vat_json_init_array (&vam->json_tree);
3509 node = vat_json_array_add (&vam->json_tree);
3511 vat_json_init_object (node);
3512 deid = format (0, "%U", format_lisp_eid_vat,
3513 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3515 seid = format (0, "%U", format_lisp_eid_vat,
3516 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3521 vat_json_object_add_string_copy (node, "seid", seid);
3522 vat_json_object_add_string_copy (node, "deid", deid);
3523 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3527 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3528 vat_json_object_add_ip4 (node, "lloc", ip4);
3529 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3530 vat_json_object_add_ip4 (node, "rloc", ip4);
3534 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3535 vat_json_object_add_ip6 (node, "lloc", ip6);
3536 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3537 vat_json_object_add_ip6 (node, "rloc", ip6);
3539 vat_json_object_add_uint (node, "pkt_count",
3540 clib_net_to_host_u32 (mp->pkt_count));
3541 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3548 vl_api_one_eid_table_map_details_t_handler
3549 (vl_api_one_eid_table_map_details_t * mp)
3551 vat_main_t *vam = &vat_main;
3553 u8 *line = format (0, "%=10d%=10d",
3554 clib_net_to_host_u32 (mp->vni),
3555 clib_net_to_host_u32 (mp->dp_table));
3556 print (vam->ofp, "%v", line);
3561 vl_api_one_eid_table_map_details_t_handler_json
3562 (vl_api_one_eid_table_map_details_t * mp)
3564 vat_main_t *vam = &vat_main;
3565 vat_json_node_t *node = NULL;
3567 if (VAT_JSON_ARRAY != vam->json_tree.type)
3569 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3570 vat_json_init_array (&vam->json_tree);
3572 node = vat_json_array_add (&vam->json_tree);
3573 vat_json_init_object (node);
3574 vat_json_object_add_uint (node, "dp_table",
3575 clib_net_to_host_u32 (mp->dp_table));
3576 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3580 vl_api_one_eid_table_vni_details_t_handler
3581 (vl_api_one_eid_table_vni_details_t * mp)
3583 vat_main_t *vam = &vat_main;
3585 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3586 print (vam->ofp, "%v", line);
3591 vl_api_one_eid_table_vni_details_t_handler_json
3592 (vl_api_one_eid_table_vni_details_t * mp)
3594 vat_main_t *vam = &vat_main;
3595 vat_json_node_t *node = NULL;
3597 if (VAT_JSON_ARRAY != vam->json_tree.type)
3599 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3600 vat_json_init_array (&vam->json_tree);
3602 node = vat_json_array_add (&vam->json_tree);
3603 vat_json_init_object (node);
3604 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3608 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3609 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3611 vat_main_t *vam = &vat_main;
3612 int retval = clib_net_to_host_u32 (mp->retval);
3614 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3615 print (vam->ofp, "fallback threshold value: %d", mp->value);
3617 vam->retval = retval;
3618 vam->result_ready = 1;
3622 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3623 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3625 vat_main_t *vam = &vat_main;
3626 vat_json_node_t _node, *node = &_node;
3627 int retval = clib_net_to_host_u32 (mp->retval);
3629 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3630 vat_json_init_object (node);
3631 vat_json_object_add_uint (node, "value", mp->value);
3633 vat_json_print (vam->ofp, node);
3634 vat_json_free (node);
3636 vam->retval = retval;
3637 vam->result_ready = 1;
3641 vl_api_show_one_map_register_state_reply_t_handler
3642 (vl_api_show_one_map_register_state_reply_t * mp)
3644 vat_main_t *vam = &vat_main;
3645 int retval = clib_net_to_host_u32 (mp->retval);
3647 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3649 vam->retval = retval;
3650 vam->result_ready = 1;
3654 vl_api_show_one_map_register_state_reply_t_handler_json
3655 (vl_api_show_one_map_register_state_reply_t * mp)
3657 vat_main_t *vam = &vat_main;
3658 vat_json_node_t _node, *node = &_node;
3659 int retval = clib_net_to_host_u32 (mp->retval);
3661 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3663 vat_json_init_object (node);
3664 vat_json_object_add_string_copy (node, "state", s);
3666 vat_json_print (vam->ofp, node);
3667 vat_json_free (node);
3669 vam->retval = retval;
3670 vam->result_ready = 1;
3675 vl_api_show_one_rloc_probe_state_reply_t_handler
3676 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3678 vat_main_t *vam = &vat_main;
3679 int retval = clib_net_to_host_u32 (mp->retval);
3684 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3686 vam->retval = retval;
3687 vam->result_ready = 1;
3691 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3692 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3694 vat_main_t *vam = &vat_main;
3695 vat_json_node_t _node, *node = &_node;
3696 int retval = clib_net_to_host_u32 (mp->retval);
3698 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3699 vat_json_init_object (node);
3700 vat_json_object_add_string_copy (node, "state", s);
3702 vat_json_print (vam->ofp, node);
3703 vat_json_free (node);
3705 vam->retval = retval;
3706 vam->result_ready = 1;
3711 vl_api_show_one_stats_enable_disable_reply_t_handler
3712 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3714 vat_main_t *vam = &vat_main;
3715 int retval = clib_net_to_host_u32 (mp->retval);
3720 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3722 vam->retval = retval;
3723 vam->result_ready = 1;
3727 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3728 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3730 vat_main_t *vam = &vat_main;
3731 vat_json_node_t _node, *node = &_node;
3732 int retval = clib_net_to_host_u32 (mp->retval);
3734 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3735 vat_json_init_object (node);
3736 vat_json_object_add_string_copy (node, "state", s);
3738 vat_json_print (vam->ofp, node);
3739 vat_json_free (node);
3741 vam->retval = retval;
3742 vam->result_ready = 1;
3747 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3749 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3750 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3751 e->vni = clib_net_to_host_u32 (e->vni);
3755 gpe_fwd_entries_get_reply_t_net_to_host
3756 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3760 mp->count = clib_net_to_host_u32 (mp->count);
3761 for (i = 0; i < mp->count; i++)
3763 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3768 format_gpe_encap_mode (u8 * s, va_list * args)
3770 u32 mode = va_arg (*args, u32);
3775 return format (s, "lisp");
3777 return format (s, "vxlan");
3783 vl_api_gpe_get_encap_mode_reply_t_handler
3784 (vl_api_gpe_get_encap_mode_reply_t * mp)
3786 vat_main_t *vam = &vat_main;
3788 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3789 vam->retval = ntohl (mp->retval);
3790 vam->result_ready = 1;
3794 vl_api_gpe_get_encap_mode_reply_t_handler_json
3795 (vl_api_gpe_get_encap_mode_reply_t * mp)
3797 vat_main_t *vam = &vat_main;
3798 vat_json_node_t node;
3800 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3801 vec_add1 (encap_mode, 0);
3803 vat_json_init_object (&node);
3804 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3806 vec_free (encap_mode);
3807 vat_json_print (vam->ofp, &node);
3808 vat_json_free (&node);
3810 vam->retval = ntohl (mp->retval);
3811 vam->result_ready = 1;
3815 vl_api_gpe_fwd_entry_path_details_t_handler
3816 (vl_api_gpe_fwd_entry_path_details_t * mp)
3818 vat_main_t *vam = &vat_main;
3819 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3821 if (mp->lcl_loc.is_ip4)
3822 format_ip_address_fcn = format_ip4_address;
3824 format_ip_address_fcn = format_ip6_address;
3826 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3827 format_ip_address_fcn, &mp->lcl_loc,
3828 format_ip_address_fcn, &mp->rmt_loc);
3832 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3834 struct in6_addr ip6;
3839 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3840 vat_json_object_add_ip4 (n, "address", ip4);
3844 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3845 vat_json_object_add_ip6 (n, "address", ip6);
3847 vat_json_object_add_uint (n, "weight", loc->weight);
3851 vl_api_gpe_fwd_entry_path_details_t_handler_json
3852 (vl_api_gpe_fwd_entry_path_details_t * mp)
3854 vat_main_t *vam = &vat_main;
3855 vat_json_node_t *node = NULL;
3856 vat_json_node_t *loc_node;
3858 if (VAT_JSON_ARRAY != vam->json_tree.type)
3860 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3861 vat_json_init_array (&vam->json_tree);
3863 node = vat_json_array_add (&vam->json_tree);
3864 vat_json_init_object (node);
3866 loc_node = vat_json_object_add (node, "local_locator");
3867 vat_json_init_object (loc_node);
3868 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3870 loc_node = vat_json_object_add (node, "remote_locator");
3871 vat_json_init_object (loc_node);
3872 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3876 vl_api_gpe_fwd_entries_get_reply_t_handler
3877 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3879 vat_main_t *vam = &vat_main;
3881 int retval = clib_net_to_host_u32 (mp->retval);
3882 vl_api_gpe_fwd_entry_t *e;
3887 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3889 for (i = 0; i < mp->count; i++)
3891 e = &mp->entries[i];
3892 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3893 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3894 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3898 vam->retval = retval;
3899 vam->result_ready = 1;
3903 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3904 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3907 vat_main_t *vam = &vat_main;
3908 vat_json_node_t *e = 0, root;
3910 int retval = clib_net_to_host_u32 (mp->retval);
3911 vl_api_gpe_fwd_entry_t *fwd;
3916 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3917 vat_json_init_array (&root);
3919 for (i = 0; i < mp->count; i++)
3921 e = vat_json_array_add (&root);
3922 fwd = &mp->entries[i];
3924 vat_json_init_object (e);
3925 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3926 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3927 vat_json_object_add_int (e, "vni", fwd->vni);
3928 vat_json_object_add_int (e, "action", fwd->action);
3930 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3931 fwd->leid_prefix_len);
3933 vat_json_object_add_string_copy (e, "leid", s);
3936 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3937 fwd->reid_prefix_len);
3939 vat_json_object_add_string_copy (e, "reid", s);
3943 vat_json_print (vam->ofp, &root);
3944 vat_json_free (&root);
3947 vam->retval = retval;
3948 vam->result_ready = 1;
3952 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3953 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3955 vat_main_t *vam = &vat_main;
3957 int retval = clib_net_to_host_u32 (mp->retval);
3958 vl_api_gpe_native_fwd_rpath_t *r;
3963 n = clib_net_to_host_u32 (mp->count);
3965 for (i = 0; i < n; i++)
3967 r = &mp->entries[i];
3968 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3969 clib_net_to_host_u32 (r->fib_index),
3970 clib_net_to_host_u32 (r->nh_sw_if_index),
3971 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3975 vam->retval = retval;
3976 vam->result_ready = 1;
3980 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3981 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3983 vat_main_t *vam = &vat_main;
3984 vat_json_node_t root, *e;
3986 int retval = clib_net_to_host_u32 (mp->retval);
3987 vl_api_gpe_native_fwd_rpath_t *r;
3993 n = clib_net_to_host_u32 (mp->count);
3994 vat_json_init_array (&root);
3996 for (i = 0; i < n; i++)
3998 e = vat_json_array_add (&root);
3999 vat_json_init_object (e);
4000 r = &mp->entries[i];
4002 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
4005 vat_json_object_add_string_copy (e, "ip4", s);
4008 vat_json_object_add_uint (e, "fib_index",
4009 clib_net_to_host_u32 (r->fib_index));
4010 vat_json_object_add_uint (e, "nh_sw_if_index",
4011 clib_net_to_host_u32 (r->nh_sw_if_index));
4014 vat_json_print (vam->ofp, &root);
4015 vat_json_free (&root);
4018 vam->retval = retval;
4019 vam->result_ready = 1;
4023 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
4024 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
4026 vat_main_t *vam = &vat_main;
4028 int retval = clib_net_to_host_u32 (mp->retval);
4033 n = clib_net_to_host_u32 (mp->count);
4035 for (i = 0; i < n; i++)
4036 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
4039 vam->retval = retval;
4040 vam->result_ready = 1;
4044 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
4045 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
4047 vat_main_t *vam = &vat_main;
4048 vat_json_node_t root;
4050 int retval = clib_net_to_host_u32 (mp->retval);
4055 n = clib_net_to_host_u32 (mp->count);
4056 vat_json_init_array (&root);
4058 for (i = 0; i < n; i++)
4059 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
4061 vat_json_print (vam->ofp, &root);
4062 vat_json_free (&root);
4065 vam->retval = retval;
4066 vam->result_ready = 1;
4070 vl_api_one_ndp_entries_get_reply_t_handler
4071 (vl_api_one_ndp_entries_get_reply_t * mp)
4073 vat_main_t *vam = &vat_main;
4075 int retval = clib_net_to_host_u32 (mp->retval);
4080 n = clib_net_to_host_u32 (mp->count);
4082 for (i = 0; i < n; i++)
4083 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
4084 format_ethernet_address, mp->entries[i].mac);
4087 vam->retval = retval;
4088 vam->result_ready = 1;
4092 vl_api_one_ndp_entries_get_reply_t_handler_json
4093 (vl_api_one_ndp_entries_get_reply_t * mp)
4096 vat_main_t *vam = &vat_main;
4097 vat_json_node_t *e = 0, root;
4099 int retval = clib_net_to_host_u32 (mp->retval);
4100 vl_api_one_ndp_entry_t *arp_entry;
4105 n = clib_net_to_host_u32 (mp->count);
4106 vat_json_init_array (&root);
4108 for (i = 0; i < n; i++)
4110 e = vat_json_array_add (&root);
4111 arp_entry = &mp->entries[i];
4113 vat_json_init_object (e);
4114 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
4117 vat_json_object_add_string_copy (e, "mac", s);
4120 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
4122 vat_json_object_add_string_copy (e, "ip6", s);
4126 vat_json_print (vam->ofp, &root);
4127 vat_json_free (&root);
4130 vam->retval = retval;
4131 vam->result_ready = 1;
4135 vl_api_one_l2_arp_entries_get_reply_t_handler
4136 (vl_api_one_l2_arp_entries_get_reply_t * mp)
4138 vat_main_t *vam = &vat_main;
4140 int retval = clib_net_to_host_u32 (mp->retval);
4145 n = clib_net_to_host_u32 (mp->count);
4147 for (i = 0; i < n; i++)
4148 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
4149 format_ethernet_address, mp->entries[i].mac);
4152 vam->retval = retval;
4153 vam->result_ready = 1;
4157 vl_api_one_l2_arp_entries_get_reply_t_handler_json
4158 (vl_api_one_l2_arp_entries_get_reply_t * mp)
4161 vat_main_t *vam = &vat_main;
4162 vat_json_node_t *e = 0, root;
4164 int retval = clib_net_to_host_u32 (mp->retval);
4165 vl_api_one_l2_arp_entry_t *arp_entry;
4170 n = clib_net_to_host_u32 (mp->count);
4171 vat_json_init_array (&root);
4173 for (i = 0; i < n; i++)
4175 e = vat_json_array_add (&root);
4176 arp_entry = &mp->entries[i];
4178 vat_json_init_object (e);
4179 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
4182 vat_json_object_add_string_copy (e, "mac", s);
4185 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
4187 vat_json_object_add_string_copy (e, "ip4", s);
4191 vat_json_print (vam->ofp, &root);
4192 vat_json_free (&root);
4195 vam->retval = retval;
4196 vam->result_ready = 1;
4200 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
4202 vat_main_t *vam = &vat_main;
4204 int retval = clib_net_to_host_u32 (mp->retval);
4209 n = clib_net_to_host_u32 (mp->count);
4211 for (i = 0; i < n; i++)
4213 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
4217 vam->retval = retval;
4218 vam->result_ready = 1;
4222 vl_api_one_ndp_bd_get_reply_t_handler_json
4223 (vl_api_one_ndp_bd_get_reply_t * mp)
4225 vat_main_t *vam = &vat_main;
4226 vat_json_node_t root;
4228 int retval = clib_net_to_host_u32 (mp->retval);
4233 n = clib_net_to_host_u32 (mp->count);
4234 vat_json_init_array (&root);
4236 for (i = 0; i < n; i++)
4238 vat_json_array_add_uint (&root,
4239 clib_net_to_host_u32 (mp->bridge_domains[i]));
4242 vat_json_print (vam->ofp, &root);
4243 vat_json_free (&root);
4246 vam->retval = retval;
4247 vam->result_ready = 1;
4251 vl_api_one_l2_arp_bd_get_reply_t_handler
4252 (vl_api_one_l2_arp_bd_get_reply_t * mp)
4254 vat_main_t *vam = &vat_main;
4256 int retval = clib_net_to_host_u32 (mp->retval);
4261 n = clib_net_to_host_u32 (mp->count);
4263 for (i = 0; i < n; i++)
4265 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
4269 vam->retval = retval;
4270 vam->result_ready = 1;
4274 vl_api_one_l2_arp_bd_get_reply_t_handler_json
4275 (vl_api_one_l2_arp_bd_get_reply_t * mp)
4277 vat_main_t *vam = &vat_main;
4278 vat_json_node_t root;
4280 int retval = clib_net_to_host_u32 (mp->retval);
4285 n = clib_net_to_host_u32 (mp->count);
4286 vat_json_init_array (&root);
4288 for (i = 0; i < n; i++)
4290 vat_json_array_add_uint (&root,
4291 clib_net_to_host_u32 (mp->bridge_domains[i]));
4294 vat_json_print (vam->ofp, &root);
4295 vat_json_free (&root);
4298 vam->retval = retval;
4299 vam->result_ready = 1;
4303 vl_api_one_adjacencies_get_reply_t_handler
4304 (vl_api_one_adjacencies_get_reply_t * mp)
4306 vat_main_t *vam = &vat_main;
4308 int retval = clib_net_to_host_u32 (mp->retval);
4309 vl_api_one_adjacency_t *a;
4314 n = clib_net_to_host_u32 (mp->count);
4316 for (i = 0; i < n; i++)
4318 a = &mp->adjacencies[i];
4319 print (vam->ofp, "%U %40U",
4320 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
4321 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
4325 vam->retval = retval;
4326 vam->result_ready = 1;
4330 vl_api_one_adjacencies_get_reply_t_handler_json
4331 (vl_api_one_adjacencies_get_reply_t * mp)
4334 vat_main_t *vam = &vat_main;
4335 vat_json_node_t *e = 0, root;
4337 int retval = clib_net_to_host_u32 (mp->retval);
4338 vl_api_one_adjacency_t *a;
4343 n = clib_net_to_host_u32 (mp->count);
4344 vat_json_init_array (&root);
4346 for (i = 0; i < n; i++)
4348 e = vat_json_array_add (&root);
4349 a = &mp->adjacencies[i];
4351 vat_json_init_object (e);
4352 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
4353 a->leid_prefix_len);
4355 vat_json_object_add_string_copy (e, "leid", s);
4358 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
4359 a->reid_prefix_len);
4361 vat_json_object_add_string_copy (e, "reid", s);
4365 vat_json_print (vam->ofp, &root);
4366 vat_json_free (&root);
4369 vam->retval = retval;
4370 vam->result_ready = 1;
4374 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
4376 vat_main_t *vam = &vat_main;
4378 print (vam->ofp, "%=20U",
4379 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4384 vl_api_one_map_server_details_t_handler_json
4385 (vl_api_one_map_server_details_t * mp)
4387 vat_main_t *vam = &vat_main;
4388 vat_json_node_t *node = NULL;
4389 struct in6_addr ip6;
4392 if (VAT_JSON_ARRAY != vam->json_tree.type)
4394 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4395 vat_json_init_array (&vam->json_tree);
4397 node = vat_json_array_add (&vam->json_tree);
4399 vat_json_init_object (node);
4402 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4403 vat_json_object_add_ip6 (node, "map-server", ip6);
4407 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4408 vat_json_object_add_ip4 (node, "map-server", ip4);
4413 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4416 vat_main_t *vam = &vat_main;
4418 print (vam->ofp, "%=20U",
4419 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4424 vl_api_one_map_resolver_details_t_handler_json
4425 (vl_api_one_map_resolver_details_t * mp)
4427 vat_main_t *vam = &vat_main;
4428 vat_json_node_t *node = NULL;
4429 struct in6_addr ip6;
4432 if (VAT_JSON_ARRAY != vam->json_tree.type)
4434 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4435 vat_json_init_array (&vam->json_tree);
4437 node = vat_json_array_add (&vam->json_tree);
4439 vat_json_init_object (node);
4442 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4443 vat_json_object_add_ip6 (node, "map resolver", ip6);
4447 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4448 vat_json_object_add_ip4 (node, "map resolver", ip4);
4453 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4455 vat_main_t *vam = &vat_main;
4456 i32 retval = ntohl (mp->retval);
4460 print (vam->ofp, "feature: %s\ngpe: %s",
4461 mp->feature_status ? "enabled" : "disabled",
4462 mp->gpe_status ? "enabled" : "disabled");
4465 vam->retval = retval;
4466 vam->result_ready = 1;
4470 vl_api_show_one_status_reply_t_handler_json
4471 (vl_api_show_one_status_reply_t * mp)
4473 vat_main_t *vam = &vat_main;
4474 vat_json_node_t node;
4475 u8 *gpe_status = NULL;
4476 u8 *feature_status = NULL;
4478 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4479 feature_status = format (0, "%s",
4480 mp->feature_status ? "enabled" : "disabled");
4481 vec_add1 (gpe_status, 0);
4482 vec_add1 (feature_status, 0);
4484 vat_json_init_object (&node);
4485 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4486 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4488 vec_free (gpe_status);
4489 vec_free (feature_status);
4491 vat_json_print (vam->ofp, &node);
4492 vat_json_free (&node);
4494 vam->retval = ntohl (mp->retval);
4495 vam->result_ready = 1;
4499 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4500 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4502 vat_main_t *vam = &vat_main;
4503 i32 retval = ntohl (mp->retval);
4507 print (vam->ofp, "%=20s", mp->locator_set_name);
4510 vam->retval = retval;
4511 vam->result_ready = 1;
4515 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4516 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4518 vat_main_t *vam = &vat_main;
4519 vat_json_node_t *node = NULL;
4521 if (VAT_JSON_ARRAY != vam->json_tree.type)
4523 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4524 vat_json_init_array (&vam->json_tree);
4526 node = vat_json_array_add (&vam->json_tree);
4528 vat_json_init_object (node);
4529 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4531 vat_json_print (vam->ofp, node);
4532 vat_json_free (node);
4534 vam->retval = ntohl (mp->retval);
4535 vam->result_ready = 1;
4539 format_lisp_map_request_mode (u8 * s, va_list * args)
4541 u32 mode = va_arg (*args, u32);
4546 return format (0, "dst-only");
4548 return format (0, "src-dst");
4554 vl_api_show_one_map_request_mode_reply_t_handler
4555 (vl_api_show_one_map_request_mode_reply_t * mp)
4557 vat_main_t *vam = &vat_main;
4558 i32 retval = ntohl (mp->retval);
4562 u32 mode = mp->mode;
4563 print (vam->ofp, "map_request_mode: %U",
4564 format_lisp_map_request_mode, mode);
4567 vam->retval = retval;
4568 vam->result_ready = 1;
4572 vl_api_show_one_map_request_mode_reply_t_handler_json
4573 (vl_api_show_one_map_request_mode_reply_t * mp)
4575 vat_main_t *vam = &vat_main;
4576 vat_json_node_t node;
4581 s = format (0, "%U", format_lisp_map_request_mode, mode);
4584 vat_json_init_object (&node);
4585 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4586 vat_json_print (vam->ofp, &node);
4587 vat_json_free (&node);
4590 vam->retval = ntohl (mp->retval);
4591 vam->result_ready = 1;
4595 vl_api_one_show_xtr_mode_reply_t_handler
4596 (vl_api_one_show_xtr_mode_reply_t * mp)
4598 vat_main_t *vam = &vat_main;
4599 i32 retval = ntohl (mp->retval);
4603 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4606 vam->retval = retval;
4607 vam->result_ready = 1;
4611 vl_api_one_show_xtr_mode_reply_t_handler_json
4612 (vl_api_one_show_xtr_mode_reply_t * mp)
4614 vat_main_t *vam = &vat_main;
4615 vat_json_node_t node;
4618 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4619 vec_add1 (status, 0);
4621 vat_json_init_object (&node);
4622 vat_json_object_add_string_copy (&node, "status", status);
4626 vat_json_print (vam->ofp, &node);
4627 vat_json_free (&node);
4629 vam->retval = ntohl (mp->retval);
4630 vam->result_ready = 1;
4634 vl_api_one_show_pitr_mode_reply_t_handler
4635 (vl_api_one_show_pitr_mode_reply_t * mp)
4637 vat_main_t *vam = &vat_main;
4638 i32 retval = ntohl (mp->retval);
4642 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4645 vam->retval = retval;
4646 vam->result_ready = 1;
4650 vl_api_one_show_pitr_mode_reply_t_handler_json
4651 (vl_api_one_show_pitr_mode_reply_t * mp)
4653 vat_main_t *vam = &vat_main;
4654 vat_json_node_t node;
4657 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4658 vec_add1 (status, 0);
4660 vat_json_init_object (&node);
4661 vat_json_object_add_string_copy (&node, "status", status);
4665 vat_json_print (vam->ofp, &node);
4666 vat_json_free (&node);
4668 vam->retval = ntohl (mp->retval);
4669 vam->result_ready = 1;
4673 vl_api_one_show_petr_mode_reply_t_handler
4674 (vl_api_one_show_petr_mode_reply_t * mp)
4676 vat_main_t *vam = &vat_main;
4677 i32 retval = ntohl (mp->retval);
4681 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4684 vam->retval = retval;
4685 vam->result_ready = 1;
4689 vl_api_one_show_petr_mode_reply_t_handler_json
4690 (vl_api_one_show_petr_mode_reply_t * mp)
4692 vat_main_t *vam = &vat_main;
4693 vat_json_node_t node;
4696 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4697 vec_add1 (status, 0);
4699 vat_json_init_object (&node);
4700 vat_json_object_add_string_copy (&node, "status", status);
4704 vat_json_print (vam->ofp, &node);
4705 vat_json_free (&node);
4707 vam->retval = ntohl (mp->retval);
4708 vam->result_ready = 1;
4712 vl_api_show_one_use_petr_reply_t_handler
4713 (vl_api_show_one_use_petr_reply_t * mp)
4715 vat_main_t *vam = &vat_main;
4716 i32 retval = ntohl (mp->retval);
4720 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4723 print (vam->ofp, "Proxy-ETR address; %U",
4724 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4729 vam->retval = retval;
4730 vam->result_ready = 1;
4734 vl_api_show_one_use_petr_reply_t_handler_json
4735 (vl_api_show_one_use_petr_reply_t * mp)
4737 vat_main_t *vam = &vat_main;
4738 vat_json_node_t node;
4741 struct in6_addr ip6;
4743 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4744 vec_add1 (status, 0);
4746 vat_json_init_object (&node);
4747 vat_json_object_add_string_copy (&node, "status", status);
4752 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4753 vat_json_object_add_ip6 (&node, "address", ip6);
4757 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4758 vat_json_object_add_ip4 (&node, "address", ip4);
4764 vat_json_print (vam->ofp, &node);
4765 vat_json_free (&node);
4767 vam->retval = ntohl (mp->retval);
4768 vam->result_ready = 1;
4772 vl_api_show_one_nsh_mapping_reply_t_handler
4773 (vl_api_show_one_nsh_mapping_reply_t * mp)
4775 vat_main_t *vam = &vat_main;
4776 i32 retval = ntohl (mp->retval);
4780 print (vam->ofp, "%-20s%-16s",
4781 mp->is_set ? "set" : "not-set",
4782 mp->is_set ? (char *) mp->locator_set_name : "");
4785 vam->retval = retval;
4786 vam->result_ready = 1;
4790 vl_api_show_one_nsh_mapping_reply_t_handler_json
4791 (vl_api_show_one_nsh_mapping_reply_t * mp)
4793 vat_main_t *vam = &vat_main;
4794 vat_json_node_t node;
4797 status = format (0, "%s", mp->is_set ? "yes" : "no");
4798 vec_add1 (status, 0);
4800 vat_json_init_object (&node);
4801 vat_json_object_add_string_copy (&node, "is_set", status);
4804 vat_json_object_add_string_copy (&node, "locator_set",
4805 mp->locator_set_name);
4810 vat_json_print (vam->ofp, &node);
4811 vat_json_free (&node);
4813 vam->retval = ntohl (mp->retval);
4814 vam->result_ready = 1;
4818 vl_api_show_one_map_register_ttl_reply_t_handler
4819 (vl_api_show_one_map_register_ttl_reply_t * mp)
4821 vat_main_t *vam = &vat_main;
4822 i32 retval = ntohl (mp->retval);
4824 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4828 print (vam->ofp, "ttl: %u", mp->ttl);
4831 vam->retval = retval;
4832 vam->result_ready = 1;
4836 vl_api_show_one_map_register_ttl_reply_t_handler_json
4837 (vl_api_show_one_map_register_ttl_reply_t * mp)
4839 vat_main_t *vam = &vat_main;
4840 vat_json_node_t node;
4842 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4843 vat_json_init_object (&node);
4844 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4846 vat_json_print (vam->ofp, &node);
4847 vat_json_free (&node);
4849 vam->retval = ntohl (mp->retval);
4850 vam->result_ready = 1;
4854 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4856 vat_main_t *vam = &vat_main;
4857 i32 retval = ntohl (mp->retval);
4861 print (vam->ofp, "%-20s%-16s",
4862 mp->status ? "enabled" : "disabled",
4863 mp->status ? (char *) mp->locator_set_name : "");
4866 vam->retval = retval;
4867 vam->result_ready = 1;
4871 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4873 vat_main_t *vam = &vat_main;
4874 vat_json_node_t node;
4877 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4878 vec_add1 (status, 0);
4880 vat_json_init_object (&node);
4881 vat_json_object_add_string_copy (&node, "status", status);
4884 vat_json_object_add_string_copy (&node, "locator_set",
4885 mp->locator_set_name);
4890 vat_json_print (vam->ofp, &node);
4891 vat_json_free (&node);
4893 vam->retval = ntohl (mp->retval);
4894 vam->result_ready = 1;
4898 format_policer_type (u8 * s, va_list * va)
4900 u32 i = va_arg (*va, u32);
4902 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4903 s = format (s, "1r2c");
4904 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4905 s = format (s, "1r3c");
4906 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4907 s = format (s, "2r3c-2698");
4908 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4909 s = format (s, "2r3c-4115");
4910 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4911 s = format (s, "2r3c-mef5cf1");
4913 s = format (s, "ILLEGAL");
4918 format_policer_rate_type (u8 * s, va_list * va)
4920 u32 i = va_arg (*va, u32);
4922 if (i == SSE2_QOS_RATE_KBPS)
4923 s = format (s, "kbps");
4924 else if (i == SSE2_QOS_RATE_PPS)
4925 s = format (s, "pps");
4927 s = format (s, "ILLEGAL");
4932 format_policer_round_type (u8 * s, va_list * va)
4934 u32 i = va_arg (*va, u32);
4936 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4937 s = format (s, "closest");
4938 else if (i == SSE2_QOS_ROUND_TO_UP)
4939 s = format (s, "up");
4940 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4941 s = format (s, "down");
4943 s = format (s, "ILLEGAL");
4948 format_policer_action_type (u8 * s, va_list * va)
4950 u32 i = va_arg (*va, u32);
4952 if (i == SSE2_QOS_ACTION_DROP)
4953 s = format (s, "drop");
4954 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4955 s = format (s, "transmit");
4956 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4957 s = format (s, "mark-and-transmit");
4959 s = format (s, "ILLEGAL");
4964 format_dscp (u8 * s, va_list * va)
4966 u32 i = va_arg (*va, u32);
4971 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4975 return format (s, "ILLEGAL");
4977 s = format (s, "%s", t);
4982 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4984 vat_main_t *vam = &vat_main;
4985 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4987 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4988 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4990 conform_dscp_str = format (0, "");
4992 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4993 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4995 exceed_dscp_str = format (0, "");
4997 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4998 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
5000 violate_dscp_str = format (0, "");
5002 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
5003 "rate type %U, round type %U, %s rate, %s color-aware, "
5004 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
5005 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
5006 "conform action %U%s, exceed action %U%s, violate action %U%s",
5008 format_policer_type, mp->type,
5011 clib_net_to_host_u64 (mp->cb),
5012 clib_net_to_host_u64 (mp->eb),
5013 format_policer_rate_type, mp->rate_type,
5014 format_policer_round_type, mp->round_type,
5015 mp->single_rate ? "single" : "dual",
5016 mp->color_aware ? "is" : "not",
5017 ntohl (mp->cir_tokens_per_period),
5018 ntohl (mp->pir_tokens_per_period),
5020 ntohl (mp->current_limit),
5021 ntohl (mp->current_bucket),
5022 ntohl (mp->extended_limit),
5023 ntohl (mp->extended_bucket),
5024 clib_net_to_host_u64 (mp->last_update_time),
5025 format_policer_action_type, mp->conform_action_type,
5027 format_policer_action_type, mp->exceed_action_type,
5029 format_policer_action_type, mp->violate_action_type,
5032 vec_free (conform_dscp_str);
5033 vec_free (exceed_dscp_str);
5034 vec_free (violate_dscp_str);
5037 static void vl_api_policer_details_t_handler_json
5038 (vl_api_policer_details_t * mp)
5040 vat_main_t *vam = &vat_main;
5041 vat_json_node_t *node;
5042 u8 *rate_type_str, *round_type_str, *type_str;
5043 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
5045 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
5047 format (0, "%U", format_policer_round_type, mp->round_type);
5048 type_str = format (0, "%U", format_policer_type, mp->type);
5049 conform_action_str = format (0, "%U", format_policer_action_type,
5050 mp->conform_action_type);
5051 exceed_action_str = format (0, "%U", format_policer_action_type,
5052 mp->exceed_action_type);
5053 violate_action_str = format (0, "%U", format_policer_action_type,
5054 mp->violate_action_type);
5056 if (VAT_JSON_ARRAY != vam->json_tree.type)
5058 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5059 vat_json_init_array (&vam->json_tree);
5061 node = vat_json_array_add (&vam->json_tree);
5063 vat_json_init_object (node);
5064 vat_json_object_add_string_copy (node, "name", mp->name);
5065 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
5066 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
5067 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
5068 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
5069 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
5070 vat_json_object_add_string_copy (node, "round_type", round_type_str);
5071 vat_json_object_add_string_copy (node, "type", type_str);
5072 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
5073 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
5074 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
5075 vat_json_object_add_uint (node, "cir_tokens_per_period",
5076 ntohl (mp->cir_tokens_per_period));
5077 vat_json_object_add_uint (node, "eir_tokens_per_period",
5078 ntohl (mp->pir_tokens_per_period));
5079 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
5080 vat_json_object_add_uint (node, "current_bucket",
5081 ntohl (mp->current_bucket));
5082 vat_json_object_add_uint (node, "extended_limit",
5083 ntohl (mp->extended_limit));
5084 vat_json_object_add_uint (node, "extended_bucket",
5085 ntohl (mp->extended_bucket));
5086 vat_json_object_add_uint (node, "last_update_time",
5087 ntohl (mp->last_update_time));
5088 vat_json_object_add_string_copy (node, "conform_action",
5089 conform_action_str);
5090 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
5092 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
5093 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
5094 vec_free (dscp_str);
5096 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
5097 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
5099 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
5100 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
5101 vec_free (dscp_str);
5103 vat_json_object_add_string_copy (node, "violate_action",
5104 violate_action_str);
5105 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
5107 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
5108 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
5109 vec_free (dscp_str);
5112 vec_free (rate_type_str);
5113 vec_free (round_type_str);
5114 vec_free (type_str);
5115 vec_free (conform_action_str);
5116 vec_free (exceed_action_str);
5117 vec_free (violate_action_str);
5121 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
5124 vat_main_t *vam = &vat_main;
5125 int i, count = ntohl (mp->count);
5128 print (vam->ofp, "classify table ids (%d) : ", count);
5129 for (i = 0; i < count; i++)
5131 print (vam->ofp, "%d", ntohl (mp->ids[i]));
5132 print (vam->ofp, (i < count - 1) ? "," : "");
5134 vam->retval = ntohl (mp->retval);
5135 vam->result_ready = 1;
5139 vl_api_classify_table_ids_reply_t_handler_json
5140 (vl_api_classify_table_ids_reply_t * mp)
5142 vat_main_t *vam = &vat_main;
5143 int i, count = ntohl (mp->count);
5147 vat_json_node_t node;
5149 vat_json_init_object (&node);
5150 for (i = 0; i < count; i++)
5152 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
5154 vat_json_print (vam->ofp, &node);
5155 vat_json_free (&node);
5157 vam->retval = ntohl (mp->retval);
5158 vam->result_ready = 1;
5162 vl_api_classify_table_by_interface_reply_t_handler
5163 (vl_api_classify_table_by_interface_reply_t * mp)
5165 vat_main_t *vam = &vat_main;
5168 table_id = ntohl (mp->l2_table_id);
5170 print (vam->ofp, "l2 table id : %d", table_id);
5172 print (vam->ofp, "l2 table id : No input ACL tables configured");
5173 table_id = ntohl (mp->ip4_table_id);
5175 print (vam->ofp, "ip4 table id : %d", table_id);
5177 print (vam->ofp, "ip4 table id : No input ACL tables configured");
5178 table_id = ntohl (mp->ip6_table_id);
5180 print (vam->ofp, "ip6 table id : %d", table_id);
5182 print (vam->ofp, "ip6 table id : No input ACL tables configured");
5183 vam->retval = ntohl (mp->retval);
5184 vam->result_ready = 1;
5188 vl_api_classify_table_by_interface_reply_t_handler_json
5189 (vl_api_classify_table_by_interface_reply_t * mp)
5191 vat_main_t *vam = &vat_main;
5192 vat_json_node_t node;
5194 vat_json_init_object (&node);
5196 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
5197 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
5198 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
5200 vat_json_print (vam->ofp, &node);
5201 vat_json_free (&node);
5203 vam->retval = ntohl (mp->retval);
5204 vam->result_ready = 1;
5207 static void vl_api_policer_add_del_reply_t_handler
5208 (vl_api_policer_add_del_reply_t * mp)
5210 vat_main_t *vam = &vat_main;
5211 i32 retval = ntohl (mp->retval);
5212 if (vam->async_mode)
5214 vam->async_errors += (retval < 0);
5218 vam->retval = retval;
5219 vam->result_ready = 1;
5220 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
5222 * Note: this is just barely thread-safe, depends on
5223 * the main thread spinning waiting for an answer...
5225 errmsg ("policer index %d", ntohl (mp->policer_index));
5229 static void vl_api_policer_add_del_reply_t_handler_json
5230 (vl_api_policer_add_del_reply_t * mp)
5232 vat_main_t *vam = &vat_main;
5233 vat_json_node_t node;
5235 vat_json_init_object (&node);
5236 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5237 vat_json_object_add_uint (&node, "policer_index",
5238 ntohl (mp->policer_index));
5240 vat_json_print (vam->ofp, &node);
5241 vat_json_free (&node);
5243 vam->retval = ntohl (mp->retval);
5244 vam->result_ready = 1;
5247 /* Format hex dump. */
5249 format_hex_bytes (u8 * s, va_list * va)
5251 u8 *bytes = va_arg (*va, u8 *);
5252 int n_bytes = va_arg (*va, int);
5255 /* Print short or long form depending on byte count. */
5256 uword short_form = n_bytes <= 32;
5257 u32 indent = format_get_indent (s);
5262 for (i = 0; i < n_bytes; i++)
5264 if (!short_form && (i % 32) == 0)
5265 s = format (s, "%08x: ", i);
5266 s = format (s, "%02x", bytes[i]);
5267 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
5268 s = format (s, "\n%U", format_white_space, indent);
5275 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
5278 vat_main_t *vam = &vat_main;
5279 i32 retval = ntohl (mp->retval);
5282 print (vam->ofp, "classify table info :");
5283 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
5284 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
5285 ntohl (mp->miss_next_index));
5286 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
5287 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
5288 ntohl (mp->match_n_vectors));
5289 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
5290 ntohl (mp->mask_length));
5292 vam->retval = retval;
5293 vam->result_ready = 1;
5297 vl_api_classify_table_info_reply_t_handler_json
5298 (vl_api_classify_table_info_reply_t * mp)
5300 vat_main_t *vam = &vat_main;
5301 vat_json_node_t node;
5303 i32 retval = ntohl (mp->retval);
5306 vat_json_init_object (&node);
5308 vat_json_object_add_int (&node, "sessions",
5309 ntohl (mp->active_sessions));
5310 vat_json_object_add_int (&node, "nexttbl",
5311 ntohl (mp->next_table_index));
5312 vat_json_object_add_int (&node, "nextnode",
5313 ntohl (mp->miss_next_index));
5314 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
5315 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
5316 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
5317 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
5318 ntohl (mp->mask_length), 0);
5319 vat_json_object_add_string_copy (&node, "mask", s);
5321 vat_json_print (vam->ofp, &node);
5322 vat_json_free (&node);
5324 vam->retval = ntohl (mp->retval);
5325 vam->result_ready = 1;
5329 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
5332 vat_main_t *vam = &vat_main;
5334 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
5335 ntohl (mp->hit_next_index), ntohl (mp->advance),
5336 ntohl (mp->opaque_index));
5337 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
5338 ntohl (mp->match_length));
5342 vl_api_classify_session_details_t_handler_json
5343 (vl_api_classify_session_details_t * mp)
5345 vat_main_t *vam = &vat_main;
5346 vat_json_node_t *node = NULL;
5348 if (VAT_JSON_ARRAY != vam->json_tree.type)
5350 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5351 vat_json_init_array (&vam->json_tree);
5353 node = vat_json_array_add (&vam->json_tree);
5355 vat_json_init_object (node);
5356 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
5357 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
5358 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
5360 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
5362 vat_json_object_add_string_copy (node, "match", s);
5365 static void vl_api_pg_create_interface_reply_t_handler
5366 (vl_api_pg_create_interface_reply_t * mp)
5368 vat_main_t *vam = &vat_main;
5370 vam->retval = ntohl (mp->retval);
5371 vam->result_ready = 1;
5374 static void vl_api_pg_create_interface_reply_t_handler_json
5375 (vl_api_pg_create_interface_reply_t * mp)
5377 vat_main_t *vam = &vat_main;
5378 vat_json_node_t node;
5380 i32 retval = ntohl (mp->retval);
5383 vat_json_init_object (&node);
5385 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
5387 vat_json_print (vam->ofp, &node);
5388 vat_json_free (&node);
5390 vam->retval = ntohl (mp->retval);
5391 vam->result_ready = 1;
5394 static void vl_api_policer_classify_details_t_handler
5395 (vl_api_policer_classify_details_t * mp)
5397 vat_main_t *vam = &vat_main;
5399 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5400 ntohl (mp->table_index));
5403 static void vl_api_policer_classify_details_t_handler_json
5404 (vl_api_policer_classify_details_t * mp)
5406 vat_main_t *vam = &vat_main;
5407 vat_json_node_t *node;
5409 if (VAT_JSON_ARRAY != vam->json_tree.type)
5411 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5412 vat_json_init_array (&vam->json_tree);
5414 node = vat_json_array_add (&vam->json_tree);
5416 vat_json_init_object (node);
5417 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5418 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5421 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
5422 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5424 vat_main_t *vam = &vat_main;
5425 i32 retval = ntohl (mp->retval);
5426 if (vam->async_mode)
5428 vam->async_errors += (retval < 0);
5432 vam->retval = retval;
5433 vam->sw_if_index = ntohl (mp->sw_if_index);
5434 vam->result_ready = 1;
5436 vam->regenerate_interface_table = 1;
5439 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
5440 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5442 vat_main_t *vam = &vat_main;
5443 vat_json_node_t node;
5445 vat_json_init_object (&node);
5446 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5447 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
5449 vat_json_print (vam->ofp, &node);
5450 vat_json_free (&node);
5452 vam->retval = ntohl (mp->retval);
5453 vam->result_ready = 1;
5456 static void vl_api_flow_classify_details_t_handler
5457 (vl_api_flow_classify_details_t * mp)
5459 vat_main_t *vam = &vat_main;
5461 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5462 ntohl (mp->table_index));
5465 static void vl_api_flow_classify_details_t_handler_json
5466 (vl_api_flow_classify_details_t * mp)
5468 vat_main_t *vam = &vat_main;
5469 vat_json_node_t *node;
5471 if (VAT_JSON_ARRAY != vam->json_tree.type)
5473 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5474 vat_json_init_array (&vam->json_tree);
5476 node = vat_json_array_add (&vam->json_tree);
5478 vat_json_init_object (node);
5479 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5480 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5483 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
5484 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
5485 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
5486 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
5487 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
5488 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
5489 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
5490 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
5491 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
5492 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
5493 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
5494 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
5495 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5496 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5497 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5498 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5499 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5500 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5501 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5502 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5503 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5504 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5507 * Generate boilerplate reply handlers, which
5508 * dig the return value out of the xxx_reply_t API message,
5509 * stick it into vam->retval, and set vam->result_ready
5511 * Could also do this by pointing N message decode slots at
5512 * a single function, but that could break in subtle ways.
5515 #define foreach_standard_reply_retval_handler \
5516 _(sw_interface_set_flags_reply) \
5517 _(sw_interface_add_del_address_reply) \
5518 _(sw_interface_set_rx_mode_reply) \
5519 _(sw_interface_set_table_reply) \
5520 _(sw_interface_set_mpls_enable_reply) \
5521 _(sw_interface_set_vpath_reply) \
5522 _(sw_interface_set_vxlan_bypass_reply) \
5523 _(sw_interface_set_geneve_bypass_reply) \
5524 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5525 _(sw_interface_set_l2_bridge_reply) \
5526 _(bridge_domain_add_del_reply) \
5527 _(sw_interface_set_l2_xconnect_reply) \
5528 _(l2fib_add_del_reply) \
5529 _(l2fib_flush_int_reply) \
5530 _(l2fib_flush_bd_reply) \
5531 _(ip_add_del_route_reply) \
5532 _(ip_table_add_del_reply) \
5533 _(ip_mroute_add_del_reply) \
5534 _(mpls_route_add_del_reply) \
5535 _(mpls_table_add_del_reply) \
5536 _(mpls_ip_bind_unbind_reply) \
5537 _(bier_route_add_del_reply) \
5538 _(bier_table_add_del_reply) \
5539 _(proxy_arp_add_del_reply) \
5540 _(proxy_arp_intfc_enable_disable_reply) \
5541 _(sw_interface_set_unnumbered_reply) \
5542 _(ip_neighbor_add_del_reply) \
5543 _(oam_add_del_reply) \
5544 _(reset_fib_reply) \
5545 _(dhcp_proxy_config_reply) \
5546 _(dhcp_proxy_set_vss_reply) \
5547 _(dhcp_client_config_reply) \
5548 _(set_ip_flow_hash_reply) \
5549 _(sw_interface_ip6_enable_disable_reply) \
5550 _(sw_interface_ip6_set_link_local_address_reply) \
5551 _(ip6nd_proxy_add_del_reply) \
5552 _(sw_interface_ip6nd_ra_prefix_reply) \
5553 _(sw_interface_ip6nd_ra_config_reply) \
5554 _(set_arp_neighbor_limit_reply) \
5555 _(l2_patch_add_del_reply) \
5556 _(sr_policy_add_reply) \
5557 _(sr_policy_mod_reply) \
5558 _(sr_policy_del_reply) \
5559 _(sr_localsid_add_del_reply) \
5560 _(sr_steering_add_del_reply) \
5561 _(classify_add_del_session_reply) \
5562 _(classify_set_interface_ip_table_reply) \
5563 _(classify_set_interface_l2_tables_reply) \
5564 _(l2tpv3_set_tunnel_cookies_reply) \
5565 _(l2tpv3_interface_enable_disable_reply) \
5566 _(l2tpv3_set_lookup_key_reply) \
5567 _(l2_fib_clear_table_reply) \
5568 _(l2_interface_efp_filter_reply) \
5569 _(l2_interface_vlan_tag_rewrite_reply) \
5570 _(modify_vhost_user_if_reply) \
5571 _(delete_vhost_user_if_reply) \
5572 _(ip_probe_neighbor_reply) \
5573 _(want_ip4_arp_events_reply) \
5574 _(want_ip6_nd_events_reply) \
5575 _(want_l2_macs_events_reply) \
5576 _(input_acl_set_interface_reply) \
5577 _(ipsec_spd_add_del_reply) \
5578 _(ipsec_interface_add_del_spd_reply) \
5579 _(ipsec_spd_add_del_entry_reply) \
5580 _(ipsec_sad_add_del_entry_reply) \
5581 _(ipsec_sa_set_key_reply) \
5582 _(ipsec_tunnel_if_add_del_reply) \
5583 _(ipsec_tunnel_if_set_key_reply) \
5584 _(ipsec_tunnel_if_set_sa_reply) \
5585 _(ikev2_profile_add_del_reply) \
5586 _(ikev2_profile_set_auth_reply) \
5587 _(ikev2_profile_set_id_reply) \
5588 _(ikev2_profile_set_ts_reply) \
5589 _(ikev2_set_local_key_reply) \
5590 _(ikev2_set_responder_reply) \
5591 _(ikev2_set_ike_transforms_reply) \
5592 _(ikev2_set_esp_transforms_reply) \
5593 _(ikev2_set_sa_lifetime_reply) \
5594 _(ikev2_initiate_sa_init_reply) \
5595 _(ikev2_initiate_del_ike_sa_reply) \
5596 _(ikev2_initiate_del_child_sa_reply) \
5597 _(ikev2_initiate_rekey_child_sa_reply) \
5598 _(delete_loopback_reply) \
5599 _(bd_ip_mac_add_del_reply) \
5600 _(map_del_domain_reply) \
5601 _(map_add_del_rule_reply) \
5602 _(want_interface_events_reply) \
5603 _(want_stats_reply) \
5604 _(cop_interface_enable_disable_reply) \
5605 _(cop_whitelist_enable_disable_reply) \
5606 _(sw_interface_clear_stats_reply) \
5607 _(ioam_enable_reply) \
5608 _(ioam_disable_reply) \
5609 _(one_add_del_locator_reply) \
5610 _(one_add_del_local_eid_reply) \
5611 _(one_add_del_remote_mapping_reply) \
5612 _(one_add_del_adjacency_reply) \
5613 _(one_add_del_map_resolver_reply) \
5614 _(one_add_del_map_server_reply) \
5615 _(one_enable_disable_reply) \
5616 _(one_rloc_probe_enable_disable_reply) \
5617 _(one_map_register_enable_disable_reply) \
5618 _(one_map_register_set_ttl_reply) \
5619 _(one_set_transport_protocol_reply) \
5620 _(one_map_register_fallback_threshold_reply) \
5621 _(one_pitr_set_locator_set_reply) \
5622 _(one_map_request_mode_reply) \
5623 _(one_add_del_map_request_itr_rlocs_reply) \
5624 _(one_eid_table_add_del_map_reply) \
5625 _(one_use_petr_reply) \
5626 _(one_stats_enable_disable_reply) \
5627 _(one_add_del_l2_arp_entry_reply) \
5628 _(one_add_del_ndp_entry_reply) \
5629 _(one_stats_flush_reply) \
5630 _(one_enable_disable_xtr_mode_reply) \
5631 _(one_enable_disable_pitr_mode_reply) \
5632 _(one_enable_disable_petr_mode_reply) \
5633 _(gpe_enable_disable_reply) \
5634 _(gpe_set_encap_mode_reply) \
5635 _(gpe_add_del_iface_reply) \
5636 _(gpe_add_del_native_fwd_rpath_reply) \
5637 _(af_packet_delete_reply) \
5638 _(policer_classify_set_interface_reply) \
5639 _(netmap_create_reply) \
5640 _(netmap_delete_reply) \
5641 _(set_ipfix_exporter_reply) \
5642 _(set_ipfix_classify_stream_reply) \
5643 _(ipfix_classify_table_add_del_reply) \
5644 _(flow_classify_set_interface_reply) \
5645 _(sw_interface_span_enable_disable_reply) \
5646 _(pg_capture_reply) \
5647 _(pg_enable_disable_reply) \
5648 _(ip_source_and_port_range_check_add_del_reply) \
5649 _(ip_source_and_port_range_check_interface_add_del_reply)\
5650 _(delete_subif_reply) \
5651 _(l2_interface_pbb_tag_rewrite_reply) \
5653 _(feature_enable_disable_reply) \
5654 _(sw_interface_tag_add_del_reply) \
5655 _(sw_interface_set_mtu_reply) \
5656 _(p2p_ethernet_add_reply) \
5657 _(p2p_ethernet_del_reply) \
5658 _(lldp_config_reply) \
5659 _(sw_interface_set_lldp_reply) \
5660 _(tcp_configure_src_addresses_reply) \
5661 _(dns_enable_disable_reply) \
5662 _(dns_name_server_add_del_reply) \
5663 _(session_rule_add_del_reply) \
5664 _(ip_container_proxy_add_del_reply) \
5665 _(output_acl_set_interface_reply)
5668 static void vl_api_##n##_t_handler \
5669 (vl_api_##n##_t * mp) \
5671 vat_main_t * vam = &vat_main; \
5672 i32 retval = ntohl(mp->retval); \
5673 if (vam->async_mode) { \
5674 vam->async_errors += (retval < 0); \
5676 vam->retval = retval; \
5677 vam->result_ready = 1; \
5680 foreach_standard_reply_retval_handler;
5684 static void vl_api_##n##_t_handler_json \
5685 (vl_api_##n##_t * mp) \
5687 vat_main_t * vam = &vat_main; \
5688 vat_json_node_t node; \
5689 vat_json_init_object(&node); \
5690 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5691 vat_json_print(vam->ofp, &node); \
5692 vam->retval = ntohl(mp->retval); \
5693 vam->result_ready = 1; \
5695 foreach_standard_reply_retval_handler;
5699 * Table of message reply handlers, must include boilerplate handlers
5703 #define foreach_vpe_api_reply_msg \
5704 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5705 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5706 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5707 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5708 _(CONTROL_PING_REPLY, control_ping_reply) \
5709 _(CLI_REPLY, cli_reply) \
5710 _(CLI_INBAND_REPLY, cli_inband_reply) \
5711 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5712 sw_interface_add_del_address_reply) \
5713 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5714 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5715 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5716 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5717 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5718 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5719 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5720 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5721 sw_interface_set_l2_xconnect_reply) \
5722 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5723 sw_interface_set_l2_bridge_reply) \
5724 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5725 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5726 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5727 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5728 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5729 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5730 _(L2_FLAGS_REPLY, l2_flags_reply) \
5731 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5732 _(TAP_CONNECT_REPLY, tap_connect_reply) \
5733 _(TAP_MODIFY_REPLY, tap_modify_reply) \
5734 _(TAP_DELETE_REPLY, tap_delete_reply) \
5735 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
5736 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5737 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5738 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5739 _(BOND_CREATE_REPLY, bond_create_reply) \
5740 _(BOND_DELETE_REPLY, bond_delete_reply) \
5741 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5742 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5743 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5744 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5745 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5746 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5747 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5748 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5749 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5750 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5751 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5752 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5753 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5754 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5755 proxy_arp_intfc_enable_disable_reply) \
5756 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5757 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5758 sw_interface_set_unnumbered_reply) \
5759 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5760 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5761 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5762 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5763 _(RESET_FIB_REPLY, reset_fib_reply) \
5764 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5765 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5766 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5767 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5768 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5769 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5770 sw_interface_ip6_enable_disable_reply) \
5771 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
5772 sw_interface_ip6_set_link_local_address_reply) \
5773 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5774 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5775 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5776 sw_interface_ip6nd_ra_prefix_reply) \
5777 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5778 sw_interface_ip6nd_ra_config_reply) \
5779 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5780 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5781 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5782 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5783 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5784 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5785 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5786 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5787 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5788 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5789 classify_set_interface_ip_table_reply) \
5790 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5791 classify_set_interface_l2_tables_reply) \
5792 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5793 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5794 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5795 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5796 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5797 l2tpv3_interface_enable_disable_reply) \
5798 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5799 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5800 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5801 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5802 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5803 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5804 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5805 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5806 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5807 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5808 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5809 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5810 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5811 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5812 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5813 _(SHOW_VERSION_REPLY, show_version_reply) \
5814 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5815 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5816 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5817 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5818 _(IP_PROBE_NEIGHBOR_REPLY, ip_probe_neighbor_reply) \
5819 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5820 _(IP4_ARP_EVENT, ip4_arp_event) \
5821 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5822 _(IP6_ND_EVENT, ip6_nd_event) \
5823 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5824 _(L2_MACS_EVENT, l2_macs_event) \
5825 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5826 _(IP_ADDRESS_DETAILS, ip_address_details) \
5827 _(IP_DETAILS, ip_details) \
5828 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5829 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5830 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
5831 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
5832 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5833 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5834 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5835 _(IPSEC_TUNNEL_IF_SET_KEY_REPLY, ipsec_tunnel_if_set_key_reply) \
5836 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5837 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
5838 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
5839 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
5840 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
5841 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
5842 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
5843 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
5844 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
5845 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
5846 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
5847 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
5848 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
5849 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
5850 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5851 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5852 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5853 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
5854 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
5855 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
5856 _(MAP_DOMAIN_DETAILS, map_domain_details) \
5857 _(MAP_RULE_DETAILS, map_rule_details) \
5858 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5859 _(WANT_STATS_REPLY, want_stats_reply) \
5860 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5861 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5862 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5863 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5864 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5865 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5866 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5867 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5868 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5869 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5870 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5871 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5872 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5873 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5874 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5875 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5876 one_map_register_enable_disable_reply) \
5877 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5878 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5879 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5880 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5881 one_map_register_fallback_threshold_reply) \
5882 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5883 one_rloc_probe_enable_disable_reply) \
5884 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5885 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5886 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5887 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5888 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5889 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5890 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5891 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5892 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5893 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5894 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5895 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5896 _(ONE_STATS_DETAILS, one_stats_details) \
5897 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5898 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5899 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5900 show_one_stats_enable_disable_reply) \
5901 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5902 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5903 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5904 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5905 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5906 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5907 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5908 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5909 one_enable_disable_pitr_mode_reply) \
5910 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5911 one_enable_disable_petr_mode_reply) \
5912 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5913 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5914 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5915 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5916 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5917 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5918 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5919 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5920 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5921 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5922 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5923 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5924 gpe_add_del_native_fwd_rpath_reply) \
5925 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5926 gpe_fwd_entry_path_details) \
5927 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5928 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5929 one_add_del_map_request_itr_rlocs_reply) \
5930 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5931 one_get_map_request_itr_rlocs_reply) \
5932 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5933 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5934 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5935 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5936 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5937 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5938 show_one_map_register_state_reply) \
5939 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5940 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5941 show_one_map_register_fallback_threshold_reply) \
5942 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5943 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5944 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5945 _(POLICER_DETAILS, policer_details) \
5946 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5947 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5948 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5949 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5950 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5951 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5952 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5953 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5954 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5955 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5956 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5957 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5958 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5959 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5960 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5961 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5962 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5963 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5964 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5965 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5966 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5967 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5968 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5969 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5970 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5971 ip_source_and_port_range_check_add_del_reply) \
5972 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5973 ip_source_and_port_range_check_interface_add_del_reply) \
5974 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5975 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5976 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5977 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5978 _(PUNT_REPLY, punt_reply) \
5979 _(IP_FIB_DETAILS, ip_fib_details) \
5980 _(IP6_FIB_DETAILS, ip6_fib_details) \
5981 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5982 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5983 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5984 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
5985 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5986 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5987 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5988 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5989 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5990 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5991 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5992 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5993 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5994 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5995 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
5996 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \
5997 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5998 _(SESSION_RULES_DETAILS, session_rules_details) \
5999 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
6000 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
6002 #define foreach_standalone_reply_msg \
6003 _(SW_INTERFACE_EVENT, sw_interface_event) \
6004 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
6005 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
6006 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
6007 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
6008 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
6009 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters) \
6010 _(MEMFD_SEGMENT_CREATE_REPLY, memfd_segment_create_reply) \
6019 #define STR_VTR_OP_CASE(op) \
6020 case L2_VTR_ ## op: \
6024 str_vtr_op (u32 vtr_op)
6028 STR_VTR_OP_CASE (DISABLED);
6029 STR_VTR_OP_CASE (PUSH_1);
6030 STR_VTR_OP_CASE (PUSH_2);
6031 STR_VTR_OP_CASE (POP_1);
6032 STR_VTR_OP_CASE (POP_2);
6033 STR_VTR_OP_CASE (TRANSLATE_1_1);
6034 STR_VTR_OP_CASE (TRANSLATE_1_2);
6035 STR_VTR_OP_CASE (TRANSLATE_2_1);
6036 STR_VTR_OP_CASE (TRANSLATE_2_2);
6043 dump_sub_interface_table (vat_main_t * vam)
6045 const sw_interface_subif_t *sub = NULL;
6047 if (vam->json_output)
6050 ("JSON output supported only for VPE API calls and dump_stats_table");
6055 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
6056 "Interface", "sw_if_index",
6057 "sub id", "dot1ad", "tags", "outer id",
6058 "inner id", "exact", "default", "outer any", "inner any");
6060 vec_foreach (sub, vam->sw_if_subif_table)
6063 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
6064 sub->interface_name,
6066 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
6067 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
6068 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
6069 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
6070 if (sub->vtr_op != L2_VTR_DISABLED)
6073 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
6074 "tag1: %d tag2: %d ]",
6075 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
6076 sub->vtr_tag1, sub->vtr_tag2);
6084 name_sort_cmp (void *a1, void *a2)
6086 name_sort_t *n1 = a1;
6087 name_sort_t *n2 = a2;
6089 return strcmp ((char *) n1->name, (char *) n2->name);
6093 dump_interface_table (vat_main_t * vam)
6096 name_sort_t *nses = 0, *ns;
6098 if (vam->json_output)
6101 ("JSON output supported only for VPE API calls and dump_stats_table");
6106 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6108 vec_add2 (nses, ns, 1);
6109 ns->name = (u8 *)(p->key);
6110 ns->value = (u32) p->value[0];
6114 vec_sort_with_function (nses, name_sort_cmp);
6116 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
6117 vec_foreach (ns, nses)
6119 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
6126 dump_ip_table (vat_main_t * vam, int is_ipv6)
6128 const ip_details_t *det = NULL;
6129 const ip_address_details_t *address = NULL;
6132 print (vam->ofp, "%-12s", "sw_if_index");
6134 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
6141 print (vam->ofp, "%-12d", i);
6142 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
6147 vec_foreach (address, det->addr)
6151 is_ipv6 ? format_ip6_address : format_ip4_address,
6152 address->ip, address->prefix_length);
6160 dump_ipv4_table (vat_main_t * vam)
6162 if (vam->json_output)
6165 ("JSON output supported only for VPE API calls and dump_stats_table");
6169 return dump_ip_table (vam, 0);
6173 dump_ipv6_table (vat_main_t * vam)
6175 if (vam->json_output)
6178 ("JSON output supported only for VPE API calls and dump_stats_table");
6182 return dump_ip_table (vam, 1);
6186 counter_type_to_str (u8 counter_type, u8 is_combined)
6190 switch (counter_type)
6192 case VNET_INTERFACE_COUNTER_DROP:
6194 case VNET_INTERFACE_COUNTER_PUNT:
6196 case VNET_INTERFACE_COUNTER_IP4:
6198 case VNET_INTERFACE_COUNTER_IP6:
6200 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
6202 case VNET_INTERFACE_COUNTER_RX_MISS:
6204 case VNET_INTERFACE_COUNTER_RX_ERROR:
6206 case VNET_INTERFACE_COUNTER_TX_ERROR:
6209 return "INVALID-COUNTER-TYPE";
6214 switch (counter_type)
6216 case VNET_INTERFACE_COUNTER_RX:
6218 case VNET_INTERFACE_COUNTER_TX:
6221 return "INVALID-COUNTER-TYPE";
6227 dump_stats_table (vat_main_t * vam)
6229 vat_json_node_t node;
6230 vat_json_node_t *msg_array;
6231 vat_json_node_t *msg;
6232 vat_json_node_t *counter_array;
6233 vat_json_node_t *counter;
6234 interface_counter_t c;
6236 ip4_fib_counter_t *c4;
6237 ip6_fib_counter_t *c6;
6238 ip4_nbr_counter_t *n4;
6239 ip6_nbr_counter_t *n6;
6242 if (!vam->json_output)
6244 clib_warning ("dump_stats_table supported only in JSON format");
6248 vat_json_init_object (&node);
6250 /* interface counters */
6251 msg_array = vat_json_object_add (&node, "interface_counters");
6252 vat_json_init_array (msg_array);
6253 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
6255 msg = vat_json_array_add (msg_array);
6256 vat_json_init_object (msg);
6257 vat_json_object_add_string_copy (msg, "vnet_counter_type",
6258 (u8 *) counter_type_to_str (i, 0));
6259 vat_json_object_add_int (msg, "is_combined", 0);
6260 counter_array = vat_json_object_add (msg, "data");
6261 vat_json_init_array (counter_array);
6262 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
6264 packets = vam->simple_interface_counters[i][j];
6265 vat_json_array_add_uint (counter_array, packets);
6268 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
6270 msg = vat_json_array_add (msg_array);
6271 vat_json_init_object (msg);
6272 vat_json_object_add_string_copy (msg, "vnet_counter_type",
6273 (u8 *) counter_type_to_str (i, 1));
6274 vat_json_object_add_int (msg, "is_combined", 1);
6275 counter_array = vat_json_object_add (msg, "data");
6276 vat_json_init_array (counter_array);
6277 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
6279 c = vam->combined_interface_counters[i][j];
6280 counter = vat_json_array_add (counter_array);
6281 vat_json_init_object (counter);
6282 vat_json_object_add_uint (counter, "packets", c.packets);
6283 vat_json_object_add_uint (counter, "bytes", c.bytes);
6287 /* ip4 fib counters */
6288 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
6289 vat_json_init_array (msg_array);
6290 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
6292 msg = vat_json_array_add (msg_array);
6293 vat_json_init_object (msg);
6294 vat_json_object_add_uint (msg, "vrf_id",
6295 vam->ip4_fib_counters_vrf_id_by_index[i]);
6296 counter_array = vat_json_object_add (msg, "c");
6297 vat_json_init_array (counter_array);
6298 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
6300 counter = vat_json_array_add (counter_array);
6301 vat_json_init_object (counter);
6302 c4 = &vam->ip4_fib_counters[i][j];
6303 vat_json_object_add_ip4 (counter, "address", c4->address);
6304 vat_json_object_add_uint (counter, "address_length",
6305 c4->address_length);
6306 vat_json_object_add_uint (counter, "packets", c4->packets);
6307 vat_json_object_add_uint (counter, "bytes", c4->bytes);
6311 /* ip6 fib counters */
6312 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
6313 vat_json_init_array (msg_array);
6314 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
6316 msg = vat_json_array_add (msg_array);
6317 vat_json_init_object (msg);
6318 vat_json_object_add_uint (msg, "vrf_id",
6319 vam->ip6_fib_counters_vrf_id_by_index[i]);
6320 counter_array = vat_json_object_add (msg, "c");
6321 vat_json_init_array (counter_array);
6322 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
6324 counter = vat_json_array_add (counter_array);
6325 vat_json_init_object (counter);
6326 c6 = &vam->ip6_fib_counters[i][j];
6327 vat_json_object_add_ip6 (counter, "address", c6->address);
6328 vat_json_object_add_uint (counter, "address_length",
6329 c6->address_length);
6330 vat_json_object_add_uint (counter, "packets", c6->packets);
6331 vat_json_object_add_uint (counter, "bytes", c6->bytes);
6335 /* ip4 nbr counters */
6336 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
6337 vat_json_init_array (msg_array);
6338 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
6340 msg = vat_json_array_add (msg_array);
6341 vat_json_init_object (msg);
6342 vat_json_object_add_uint (msg, "sw_if_index", i);
6343 counter_array = vat_json_object_add (msg, "c");
6344 vat_json_init_array (counter_array);
6345 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
6347 counter = vat_json_array_add (counter_array);
6348 vat_json_init_object (counter);
6349 n4 = &vam->ip4_nbr_counters[i][j];
6350 vat_json_object_add_ip4 (counter, "address", n4->address);
6351 vat_json_object_add_uint (counter, "link-type", n4->linkt);
6352 vat_json_object_add_uint (counter, "packets", n4->packets);
6353 vat_json_object_add_uint (counter, "bytes", n4->bytes);
6357 /* ip6 nbr counters */
6358 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
6359 vat_json_init_array (msg_array);
6360 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
6362 msg = vat_json_array_add (msg_array);
6363 vat_json_init_object (msg);
6364 vat_json_object_add_uint (msg, "sw_if_index", i);
6365 counter_array = vat_json_object_add (msg, "c");
6366 vat_json_init_array (counter_array);
6367 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
6369 counter = vat_json_array_add (counter_array);
6370 vat_json_init_object (counter);
6371 n6 = &vam->ip6_nbr_counters[i][j];
6372 vat_json_object_add_ip6 (counter, "address", n6->address);
6373 vat_json_object_add_uint (counter, "packets", n6->packets);
6374 vat_json_object_add_uint (counter, "bytes", n6->bytes);
6378 vat_json_print (vam->ofp, &node);
6379 vat_json_free (&node);
6385 * Pass CLI buffers directly in the CLI_INBAND API message,
6386 * instead of an additional shared memory area.
6389 exec_inband (vat_main_t * vam)
6391 vl_api_cli_inband_t *mp;
6392 unformat_input_t *i = vam->input;
6395 if (vec_len (i->buffer) == 0)
6398 if (vam->exec_mode == 0 && unformat (i, "mode"))
6403 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
6410 * In order for the CLI command to work, it
6411 * must be a vector ending in \n, not a C-string ending
6414 u32 len = vec_len (vam->input->buffer);
6415 M2 (CLI_INBAND, mp, len);
6416 clib_memcpy (mp->cmd, vam->input->buffer, len);
6417 mp->length = htonl (len);
6421 /* json responses may or may not include a useful reply... */
6422 if (vec_len (vam->cmd_reply))
6423 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
6428 exec (vat_main_t * vam)
6430 return exec_inband (vam);
6434 api_create_loopback (vat_main_t * vam)
6436 unformat_input_t *i = vam->input;
6437 vl_api_create_loopback_t *mp;
6438 vl_api_create_loopback_instance_t *mp_lbi;
6441 u8 is_specified = 0;
6442 u32 user_instance = 0;
6445 memset (mac_address, 0, sizeof (mac_address));
6447 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6449 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6451 if (unformat (i, "instance %d", &user_instance))
6459 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
6460 mp_lbi->is_specified = is_specified;
6462 mp_lbi->user_instance = htonl (user_instance);
6464 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
6469 /* Construct the API message */
6470 M (CREATE_LOOPBACK, mp);
6472 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
6481 api_delete_loopback (vat_main_t * vam)
6483 unformat_input_t *i = vam->input;
6484 vl_api_delete_loopback_t *mp;
6485 u32 sw_if_index = ~0;
6488 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6490 if (unformat (i, "sw_if_index %d", &sw_if_index))
6496 if (sw_if_index == ~0)
6498 errmsg ("missing sw_if_index");
6502 /* Construct the API message */
6503 M (DELETE_LOOPBACK, mp);
6504 mp->sw_if_index = ntohl (sw_if_index);
6512 api_want_stats (vat_main_t * vam)
6514 unformat_input_t *i = vam->input;
6515 vl_api_want_stats_t *mp;
6519 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6521 if (unformat (i, "enable"))
6523 else if (unformat (i, "disable"))
6531 errmsg ("missing enable|disable");
6536 mp->enable_disable = enable;
6544 api_want_interface_events (vat_main_t * vam)
6546 unformat_input_t *i = vam->input;
6547 vl_api_want_interface_events_t *mp;
6551 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6553 if (unformat (i, "enable"))
6555 else if (unformat (i, "disable"))
6563 errmsg ("missing enable|disable");
6567 M (WANT_INTERFACE_EVENTS, mp);
6568 mp->enable_disable = enable;
6570 vam->interface_event_display = enable;
6578 /* Note: non-static, called once to set up the initial intfc table */
6580 api_sw_interface_dump (vat_main_t * vam)
6582 vl_api_sw_interface_dump_t *mp;
6583 vl_api_control_ping_t *mp_ping;
6585 name_sort_t *nses = 0, *ns;
6586 sw_interface_subif_t *sub = NULL;
6589 /* Toss the old name table */
6591 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6593 vec_add2 (nses, ns, 1);
6594 ns->name = (u8 *)(p->key);
6595 ns->value = (u32) p->value[0];
6599 hash_free (vam->sw_if_index_by_interface_name);
6601 vec_foreach (ns, nses) vec_free (ns->name);
6605 vec_foreach (sub, vam->sw_if_subif_table)
6607 vec_free (sub->interface_name);
6609 vec_free (vam->sw_if_subif_table);
6611 /* recreate the interface name hash table */
6612 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
6615 * Ask for all interface names. Otherwise, the epic catalog of
6616 * name filters becomes ridiculously long, and vat ends up needing
6617 * to be taught about new interface types.
6619 M (SW_INTERFACE_DUMP, mp);
6622 /* Use a control ping for synchronization */
6623 MPING (CONTROL_PING, mp_ping);
6631 api_sw_interface_set_flags (vat_main_t * vam)
6633 unformat_input_t *i = vam->input;
6634 vl_api_sw_interface_set_flags_t *mp;
6636 u8 sw_if_index_set = 0;
6640 /* Parse args required to build the message */
6641 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6643 if (unformat (i, "admin-up"))
6645 else if (unformat (i, "admin-down"))
6648 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6649 sw_if_index_set = 1;
6650 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6651 sw_if_index_set = 1;
6656 if (sw_if_index_set == 0)
6658 errmsg ("missing interface name or sw_if_index");
6662 /* Construct the API message */
6663 M (SW_INTERFACE_SET_FLAGS, mp);
6664 mp->sw_if_index = ntohl (sw_if_index);
6665 mp->admin_up_down = admin_up;
6670 /* Wait for a reply, return the good/bad news... */
6676 api_sw_interface_set_rx_mode (vat_main_t * vam)
6678 unformat_input_t *i = vam->input;
6679 vl_api_sw_interface_set_rx_mode_t *mp;
6681 u8 sw_if_index_set = 0;
6683 u8 queue_id_valid = 0;
6685 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
6687 /* Parse args required to build the message */
6688 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6690 if (unformat (i, "queue %d", &queue_id))
6692 else if (unformat (i, "polling"))
6693 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
6694 else if (unformat (i, "interrupt"))
6695 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
6696 else if (unformat (i, "adaptive"))
6697 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
6699 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6700 sw_if_index_set = 1;
6701 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6702 sw_if_index_set = 1;
6707 if (sw_if_index_set == 0)
6709 errmsg ("missing interface name or sw_if_index");
6712 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6714 errmsg ("missing rx-mode");
6718 /* Construct the API message */
6719 M (SW_INTERFACE_SET_RX_MODE, mp);
6720 mp->sw_if_index = ntohl (sw_if_index);
6722 mp->queue_id_valid = queue_id_valid;
6723 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6728 /* Wait for a reply, return the good/bad news... */
6734 api_sw_interface_clear_stats (vat_main_t * vam)
6736 unformat_input_t *i = vam->input;
6737 vl_api_sw_interface_clear_stats_t *mp;
6739 u8 sw_if_index_set = 0;
6742 /* Parse args required to build the message */
6743 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6745 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6746 sw_if_index_set = 1;
6747 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6748 sw_if_index_set = 1;
6753 /* Construct the API message */
6754 M (SW_INTERFACE_CLEAR_STATS, mp);
6756 if (sw_if_index_set == 1)
6757 mp->sw_if_index = ntohl (sw_if_index);
6759 mp->sw_if_index = ~0;
6764 /* Wait for a reply, return the good/bad news... */
6770 api_sw_interface_add_del_address (vat_main_t * vam)
6772 unformat_input_t *i = vam->input;
6773 vl_api_sw_interface_add_del_address_t *mp;
6775 u8 sw_if_index_set = 0;
6776 u8 is_add = 1, del_all = 0;
6777 u32 address_length = 0;
6778 u8 v4_address_set = 0;
6779 u8 v6_address_set = 0;
6780 ip4_address_t v4address;
6781 ip6_address_t v6address;
6784 /* Parse args required to build the message */
6785 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6787 if (unformat (i, "del-all"))
6789 else if (unformat (i, "del"))
6792 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6793 sw_if_index_set = 1;
6794 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6795 sw_if_index_set = 1;
6796 else if (unformat (i, "%U/%d",
6797 unformat_ip4_address, &v4address, &address_length))
6799 else if (unformat (i, "%U/%d",
6800 unformat_ip6_address, &v6address, &address_length))
6806 if (sw_if_index_set == 0)
6808 errmsg ("missing interface name or sw_if_index");
6811 if (v4_address_set && v6_address_set)
6813 errmsg ("both v4 and v6 addresses set");
6816 if (!v4_address_set && !v6_address_set && !del_all)
6818 errmsg ("no addresses set");
6822 /* Construct the API message */
6823 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6825 mp->sw_if_index = ntohl (sw_if_index);
6826 mp->is_add = is_add;
6827 mp->del_all = del_all;
6831 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6835 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6837 mp->address_length = address_length;
6842 /* Wait for a reply, return good/bad news */
6848 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6850 unformat_input_t *i = vam->input;
6851 vl_api_sw_interface_set_mpls_enable_t *mp;
6853 u8 sw_if_index_set = 0;
6857 /* Parse args required to build the message */
6858 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6860 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6861 sw_if_index_set = 1;
6862 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6863 sw_if_index_set = 1;
6864 else if (unformat (i, "disable"))
6866 else if (unformat (i, "dis"))
6872 if (sw_if_index_set == 0)
6874 errmsg ("missing interface name or sw_if_index");
6878 /* Construct the API message */
6879 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6881 mp->sw_if_index = ntohl (sw_if_index);
6882 mp->enable = enable;
6887 /* Wait for a reply... */
6893 api_sw_interface_set_table (vat_main_t * vam)
6895 unformat_input_t *i = vam->input;
6896 vl_api_sw_interface_set_table_t *mp;
6897 u32 sw_if_index, vrf_id = 0;
6898 u8 sw_if_index_set = 0;
6902 /* Parse args required to build the message */
6903 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6905 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6906 sw_if_index_set = 1;
6907 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6908 sw_if_index_set = 1;
6909 else if (unformat (i, "vrf %d", &vrf_id))
6911 else if (unformat (i, "ipv6"))
6917 if (sw_if_index_set == 0)
6919 errmsg ("missing interface name or sw_if_index");
6923 /* Construct the API message */
6924 M (SW_INTERFACE_SET_TABLE, mp);
6926 mp->sw_if_index = ntohl (sw_if_index);
6927 mp->is_ipv6 = is_ipv6;
6928 mp->vrf_id = ntohl (vrf_id);
6933 /* Wait for a reply... */
6938 static void vl_api_sw_interface_get_table_reply_t_handler
6939 (vl_api_sw_interface_get_table_reply_t * mp)
6941 vat_main_t *vam = &vat_main;
6943 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6945 vam->retval = ntohl (mp->retval);
6946 vam->result_ready = 1;
6950 static void vl_api_sw_interface_get_table_reply_t_handler_json
6951 (vl_api_sw_interface_get_table_reply_t * mp)
6953 vat_main_t *vam = &vat_main;
6954 vat_json_node_t node;
6956 vat_json_init_object (&node);
6957 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6958 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6960 vat_json_print (vam->ofp, &node);
6961 vat_json_free (&node);
6963 vam->retval = ntohl (mp->retval);
6964 vam->result_ready = 1;
6968 api_sw_interface_get_table (vat_main_t * vam)
6970 unformat_input_t *i = vam->input;
6971 vl_api_sw_interface_get_table_t *mp;
6973 u8 sw_if_index_set = 0;
6977 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6979 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6980 sw_if_index_set = 1;
6981 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6982 sw_if_index_set = 1;
6983 else if (unformat (i, "ipv6"))
6989 if (sw_if_index_set == 0)
6991 errmsg ("missing interface name or sw_if_index");
6995 M (SW_INTERFACE_GET_TABLE, mp);
6996 mp->sw_if_index = htonl (sw_if_index);
6997 mp->is_ipv6 = is_ipv6;
7005 api_sw_interface_set_vpath (vat_main_t * vam)
7007 unformat_input_t *i = vam->input;
7008 vl_api_sw_interface_set_vpath_t *mp;
7009 u32 sw_if_index = 0;
7010 u8 sw_if_index_set = 0;
7014 /* Parse args required to build the message */
7015 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7017 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7018 sw_if_index_set = 1;
7019 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7020 sw_if_index_set = 1;
7021 else if (unformat (i, "enable"))
7023 else if (unformat (i, "disable"))
7029 if (sw_if_index_set == 0)
7031 errmsg ("missing interface name or sw_if_index");
7035 /* Construct the API message */
7036 M (SW_INTERFACE_SET_VPATH, mp);
7038 mp->sw_if_index = ntohl (sw_if_index);
7039 mp->enable = is_enable;
7044 /* Wait for a reply... */
7050 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
7052 unformat_input_t *i = vam->input;
7053 vl_api_sw_interface_set_vxlan_bypass_t *mp;
7054 u32 sw_if_index = 0;
7055 u8 sw_if_index_set = 0;
7060 /* Parse args required to build the message */
7061 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7063 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7064 sw_if_index_set = 1;
7065 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7066 sw_if_index_set = 1;
7067 else if (unformat (i, "enable"))
7069 else if (unformat (i, "disable"))
7071 else if (unformat (i, "ip4"))
7073 else if (unformat (i, "ip6"))
7079 if (sw_if_index_set == 0)
7081 errmsg ("missing interface name or sw_if_index");
7085 /* Construct the API message */
7086 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
7088 mp->sw_if_index = ntohl (sw_if_index);
7089 mp->enable = is_enable;
7090 mp->is_ipv6 = is_ipv6;
7095 /* Wait for a reply... */
7101 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
7103 unformat_input_t *i = vam->input;
7104 vl_api_sw_interface_set_geneve_bypass_t *mp;
7105 u32 sw_if_index = 0;
7106 u8 sw_if_index_set = 0;
7111 /* Parse args required to build the message */
7112 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7114 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7115 sw_if_index_set = 1;
7116 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7117 sw_if_index_set = 1;
7118 else if (unformat (i, "enable"))
7120 else if (unformat (i, "disable"))
7122 else if (unformat (i, "ip4"))
7124 else if (unformat (i, "ip6"))
7130 if (sw_if_index_set == 0)
7132 errmsg ("missing interface name or sw_if_index");
7136 /* Construct the API message */
7137 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
7139 mp->sw_if_index = ntohl (sw_if_index);
7140 mp->enable = is_enable;
7141 mp->is_ipv6 = is_ipv6;
7146 /* Wait for a reply... */
7152 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
7154 unformat_input_t *i = vam->input;
7155 vl_api_sw_interface_set_l2_xconnect_t *mp;
7157 u8 rx_sw_if_index_set = 0;
7159 u8 tx_sw_if_index_set = 0;
7163 /* Parse args required to build the message */
7164 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7166 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
7167 rx_sw_if_index_set = 1;
7168 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
7169 tx_sw_if_index_set = 1;
7170 else if (unformat (i, "rx"))
7172 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7174 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7176 rx_sw_if_index_set = 1;
7181 else if (unformat (i, "tx"))
7183 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7185 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7187 tx_sw_if_index_set = 1;
7192 else if (unformat (i, "enable"))
7194 else if (unformat (i, "disable"))
7200 if (rx_sw_if_index_set == 0)
7202 errmsg ("missing rx interface name or rx_sw_if_index");
7206 if (enable && (tx_sw_if_index_set == 0))
7208 errmsg ("missing tx interface name or tx_sw_if_index");
7212 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
7214 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7215 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
7216 mp->enable = enable;
7224 api_sw_interface_set_l2_bridge (vat_main_t * vam)
7226 unformat_input_t *i = vam->input;
7227 vl_api_sw_interface_set_l2_bridge_t *mp;
7229 u8 rx_sw_if_index_set = 0;
7237 /* Parse args required to build the message */
7238 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7240 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
7241 rx_sw_if_index_set = 1;
7242 else if (unformat (i, "bd_id %d", &bd_id))
7246 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
7247 rx_sw_if_index_set = 1;
7248 else if (unformat (i, "shg %d", &shg))
7250 else if (unformat (i, "bvi"))
7252 else if (unformat (i, "enable"))
7254 else if (unformat (i, "disable"))
7260 if (rx_sw_if_index_set == 0)
7262 errmsg ("missing rx interface name or sw_if_index");
7266 if (enable && (bd_id_set == 0))
7268 errmsg ("missing bridge domain");
7272 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
7274 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7275 mp->bd_id = ntohl (bd_id);
7278 mp->enable = enable;
7286 api_bridge_domain_dump (vat_main_t * vam)
7288 unformat_input_t *i = vam->input;
7289 vl_api_bridge_domain_dump_t *mp;
7290 vl_api_control_ping_t *mp_ping;
7294 /* Parse args required to build the message */
7295 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7297 if (unformat (i, "bd_id %d", &bd_id))
7303 M (BRIDGE_DOMAIN_DUMP, mp);
7304 mp->bd_id = ntohl (bd_id);
7307 /* Use a control ping for synchronization */
7308 MPING (CONTROL_PING, mp_ping);
7316 api_bridge_domain_add_del (vat_main_t * vam)
7318 unformat_input_t *i = vam->input;
7319 vl_api_bridge_domain_add_del_t *mp;
7322 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
7327 /* Parse args required to build the message */
7328 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7330 if (unformat (i, "bd_id %d", &bd_id))
7332 else if (unformat (i, "flood %d", &flood))
7334 else if (unformat (i, "uu-flood %d", &uu_flood))
7336 else if (unformat (i, "forward %d", &forward))
7338 else if (unformat (i, "learn %d", &learn))
7340 else if (unformat (i, "arp-term %d", &arp_term))
7342 else if (unformat (i, "mac-age %d", &mac_age))
7344 else if (unformat (i, "bd-tag %s", &bd_tag))
7346 else if (unformat (i, "del"))
7349 flood = uu_flood = forward = learn = 0;
7357 errmsg ("missing bridge domain");
7364 errmsg ("mac age must be less than 256 ");
7369 if ((bd_tag) && (vec_len (bd_tag) > 63))
7371 errmsg ("bd-tag cannot be longer than 63");
7376 M (BRIDGE_DOMAIN_ADD_DEL, mp);
7378 mp->bd_id = ntohl (bd_id);
7380 mp->uu_flood = uu_flood;
7381 mp->forward = forward;
7383 mp->arp_term = arp_term;
7384 mp->is_add = is_add;
7385 mp->mac_age = (u8) mac_age;
7388 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
7389 mp->bd_tag[vec_len (bd_tag)] = 0;
7400 api_l2fib_flush_bd (vat_main_t * vam)
7402 unformat_input_t *i = vam->input;
7403 vl_api_l2fib_flush_bd_t *mp;
7407 /* Parse args required to build the message */
7408 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7410 if (unformat (i, "bd_id %d", &bd_id));
7417 errmsg ("missing bridge domain");
7421 M (L2FIB_FLUSH_BD, mp);
7423 mp->bd_id = htonl (bd_id);
7431 api_l2fib_flush_int (vat_main_t * vam)
7433 unformat_input_t *i = vam->input;
7434 vl_api_l2fib_flush_int_t *mp;
7435 u32 sw_if_index = ~0;
7438 /* Parse args required to build the message */
7439 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7441 if (unformat (i, "sw_if_index %d", &sw_if_index));
7443 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
7448 if (sw_if_index == ~0)
7450 errmsg ("missing interface name or sw_if_index");
7454 M (L2FIB_FLUSH_INT, mp);
7456 mp->sw_if_index = ntohl (sw_if_index);
7464 api_l2fib_add_del (vat_main_t * vam)
7466 unformat_input_t *i = vam->input;
7467 vl_api_l2fib_add_del_t *mp;
7473 u32 sw_if_index = ~0;
7474 u8 sw_if_index_set = 0;
7483 /* Parse args required to build the message */
7484 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7486 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
7488 else if (unformat (i, "bd_id %d", &bd_id))
7490 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7491 sw_if_index_set = 1;
7492 else if (unformat (i, "sw_if"))
7494 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7497 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7498 sw_if_index_set = 1;
7503 else if (unformat (i, "static"))
7505 else if (unformat (i, "filter"))
7510 else if (unformat (i, "bvi"))
7515 else if (unformat (i, "del"))
7517 else if (unformat (i, "count %d", &count))
7525 errmsg ("missing mac address");
7531 errmsg ("missing bridge domain");
7535 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7537 errmsg ("missing interface name or sw_if_index");
7543 /* Turn on async mode */
7544 vam->async_mode = 1;
7545 vam->async_errors = 0;
7546 before = vat_time_now (vam);
7549 for (j = 0; j < count; j++)
7551 M (L2FIB_ADD_DEL, mp);
7553 clib_memcpy (mp->mac, mac, 6);
7554 mp->bd_id = ntohl (bd_id);
7555 mp->is_add = is_add;
7559 mp->sw_if_index = ntohl (sw_if_index);
7560 mp->static_mac = static_mac;
7561 mp->filter_mac = filter_mac;
7562 mp->bvi_mac = bvi_mac;
7564 increment_mac_address (mac);
7571 vl_api_control_ping_t *mp_ping;
7574 /* Shut off async mode */
7575 vam->async_mode = 0;
7577 MPING (CONTROL_PING, mp_ping);
7580 timeout = vat_time_now (vam) + 1.0;
7581 while (vat_time_now (vam) < timeout)
7582 if (vam->result_ready == 1)
7587 if (vam->retval == -99)
7590 if (vam->async_errors > 0)
7592 errmsg ("%d asynchronous errors", vam->async_errors);
7595 vam->async_errors = 0;
7596 after = vat_time_now (vam);
7598 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7599 count, after - before, count / (after - before));
7605 /* Wait for a reply... */
7609 /* Return the good/bad news */
7610 return (vam->retval);
7614 api_bridge_domain_set_mac_age (vat_main_t * vam)
7616 unformat_input_t *i = vam->input;
7617 vl_api_bridge_domain_set_mac_age_t *mp;
7622 /* Parse args required to build the message */
7623 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7625 if (unformat (i, "bd_id %d", &bd_id));
7626 else if (unformat (i, "mac-age %d", &mac_age));
7633 errmsg ("missing bridge domain");
7639 errmsg ("mac age must be less than 256 ");
7643 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7645 mp->bd_id = htonl (bd_id);
7646 mp->mac_age = (u8) mac_age;
7654 api_l2_flags (vat_main_t * vam)
7656 unformat_input_t *i = vam->input;
7657 vl_api_l2_flags_t *mp;
7660 u8 sw_if_index_set = 0;
7664 /* Parse args required to build the message */
7665 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7667 if (unformat (i, "sw_if_index %d", &sw_if_index))
7668 sw_if_index_set = 1;
7669 else if (unformat (i, "sw_if"))
7671 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7674 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7675 sw_if_index_set = 1;
7680 else if (unformat (i, "learn"))
7682 else if (unformat (i, "forward"))
7684 else if (unformat (i, "flood"))
7686 else if (unformat (i, "uu-flood"))
7687 flags |= L2_UU_FLOOD;
7688 else if (unformat (i, "arp-term"))
7689 flags |= L2_ARP_TERM;
7690 else if (unformat (i, "off"))
7692 else if (unformat (i, "disable"))
7698 if (sw_if_index_set == 0)
7700 errmsg ("missing interface name or sw_if_index");
7706 mp->sw_if_index = ntohl (sw_if_index);
7707 mp->feature_bitmap = ntohl (flags);
7708 mp->is_set = is_set;
7716 api_bridge_flags (vat_main_t * vam)
7718 unformat_input_t *i = vam->input;
7719 vl_api_bridge_flags_t *mp;
7726 /* Parse args required to build the message */
7727 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7729 if (unformat (i, "bd_id %d", &bd_id))
7731 else if (unformat (i, "learn"))
7733 else if (unformat (i, "forward"))
7735 else if (unformat (i, "flood"))
7737 else if (unformat (i, "uu-flood"))
7738 flags |= L2_UU_FLOOD;
7739 else if (unformat (i, "arp-term"))
7740 flags |= L2_ARP_TERM;
7741 else if (unformat (i, "off"))
7743 else if (unformat (i, "disable"))
7751 errmsg ("missing bridge domain");
7755 M (BRIDGE_FLAGS, mp);
7757 mp->bd_id = ntohl (bd_id);
7758 mp->feature_bitmap = ntohl (flags);
7759 mp->is_set = is_set;
7767 api_bd_ip_mac_add_del (vat_main_t * vam)
7769 unformat_input_t *i = vam->input;
7770 vl_api_bd_ip_mac_add_del_t *mp;
7777 ip4_address_t v4addr;
7778 ip6_address_t v6addr;
7783 /* Parse args required to build the message */
7784 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7786 if (unformat (i, "bd_id %d", &bd_id))
7790 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
7794 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
7799 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
7803 else if (unformat (i, "del"))
7811 errmsg ("missing bridge domain");
7814 else if (ip_set == 0)
7816 errmsg ("missing IP address");
7819 else if (mac_set == 0)
7821 errmsg ("missing MAC address");
7825 M (BD_IP_MAC_ADD_DEL, mp);
7827 mp->bd_id = ntohl (bd_id);
7828 mp->is_ipv6 = is_ipv6;
7829 mp->is_add = is_add;
7831 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
7833 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
7834 clib_memcpy (mp->mac_address, macaddr, 6);
7841 api_tap_connect (vat_main_t * vam)
7843 unformat_input_t *i = vam->input;
7844 vl_api_tap_connect_t *mp;
7850 ip4_address_t ip4_address;
7852 int ip4_address_set = 0;
7853 ip6_address_t ip6_address;
7855 int ip6_address_set = 0;
7858 memset (mac_address, 0, sizeof (mac_address));
7860 /* Parse args required to build the message */
7861 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7863 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7867 else if (unformat (i, "random-mac"))
7869 else if (unformat (i, "tapname %s", &tap_name))
7871 else if (unformat (i, "tag %s", &tag))
7873 else if (unformat (i, "address %U/%d",
7874 unformat_ip4_address, &ip4_address, &ip4_mask_width))
7875 ip4_address_set = 1;
7876 else if (unformat (i, "address %U/%d",
7877 unformat_ip6_address, &ip6_address, &ip6_mask_width))
7878 ip6_address_set = 1;
7885 errmsg ("missing tap name");
7888 if (vec_len (tap_name) > 63)
7890 errmsg ("tap name too long");
7893 vec_add1 (tap_name, 0);
7895 if (vec_len (tag) > 63)
7897 errmsg ("tag too long");
7901 /* Construct the API message */
7902 M (TAP_CONNECT, mp);
7904 mp->use_random_mac = random_mac;
7905 clib_memcpy (mp->mac_address, mac_address, 6);
7906 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7908 clib_memcpy (mp->tag, tag, vec_len (tag));
7910 if (ip4_address_set)
7912 mp->ip4_address_set = 1;
7913 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
7914 mp->ip4_mask_width = ip4_mask_width;
7916 if (ip6_address_set)
7918 mp->ip6_address_set = 1;
7919 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
7920 mp->ip6_mask_width = ip6_mask_width;
7923 vec_free (tap_name);
7929 /* Wait for a reply... */
7935 api_tap_modify (vat_main_t * vam)
7937 unformat_input_t *i = vam->input;
7938 vl_api_tap_modify_t *mp;
7943 u32 sw_if_index = ~0;
7944 u8 sw_if_index_set = 0;
7947 memset (mac_address, 0, sizeof (mac_address));
7949 /* Parse args required to build the message */
7950 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7952 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7953 sw_if_index_set = 1;
7954 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7955 sw_if_index_set = 1;
7956 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7960 else if (unformat (i, "random-mac"))
7962 else if (unformat (i, "tapname %s", &tap_name))
7968 if (sw_if_index_set == 0)
7970 errmsg ("missing vpp interface name");
7975 errmsg ("missing tap name");
7978 if (vec_len (tap_name) > 63)
7980 errmsg ("tap name too long");
7982 vec_add1 (tap_name, 0);
7984 /* Construct the API message */
7987 mp->use_random_mac = random_mac;
7988 mp->sw_if_index = ntohl (sw_if_index);
7989 clib_memcpy (mp->mac_address, mac_address, 6);
7990 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7991 vec_free (tap_name);
7996 /* Wait for a reply... */
8002 api_tap_delete (vat_main_t * vam)
8004 unformat_input_t *i = vam->input;
8005 vl_api_tap_delete_t *mp;
8006 u32 sw_if_index = ~0;
8007 u8 sw_if_index_set = 0;
8010 /* Parse args required to build the message */
8011 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8013 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8014 sw_if_index_set = 1;
8015 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8016 sw_if_index_set = 1;
8021 if (sw_if_index_set == 0)
8023 errmsg ("missing vpp interface name");
8027 /* Construct the API message */
8030 mp->sw_if_index = ntohl (sw_if_index);
8035 /* Wait for a reply... */
8041 api_tap_create_v2 (vat_main_t * vam)
8043 unformat_input_t *i = vam->input;
8044 vl_api_tap_create_v2_t *mp;
8048 u8 *host_if_name = 0;
8050 u8 host_mac_addr[6];
8051 u8 host_mac_addr_set = 0;
8052 u8 *host_bridge = 0;
8053 ip4_address_t host_ip4_addr;
8054 ip4_address_t host_ip4_gw;
8055 u8 host_ip4_gw_set = 0;
8056 u32 host_ip4_prefix_len = 0;
8057 ip6_address_t host_ip6_addr;
8058 ip6_address_t host_ip6_gw;
8059 u8 host_ip6_gw_set = 0;
8060 u32 host_ip6_prefix_len = 0;
8062 u32 rx_ring_sz = 0, tx_ring_sz = 0;
8064 memset (mac_address, 0, sizeof (mac_address));
8066 /* Parse args required to build the message */
8067 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8069 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
8073 else if (unformat (i, "id %u", &id))
8075 else if (unformat (i, "host-if-name %s", &host_if_name))
8077 else if (unformat (i, "host-ns %s", &host_ns))
8079 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
8081 host_mac_addr_set = 1;
8082 else if (unformat (i, "host-bridge %s", &host_bridge))
8084 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
8085 &host_ip4_addr, &host_ip4_prefix_len))
8087 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
8088 &host_ip6_addr, &host_ip6_prefix_len))
8090 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
8092 host_ip4_gw_set = 1;
8093 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
8095 host_ip6_gw_set = 1;
8096 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
8098 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
8104 if (vec_len (host_if_name) > 63)
8106 errmsg ("tap name too long. ");
8109 if (vec_len (host_ns) > 63)
8111 errmsg ("host name space too long. ");
8114 if (vec_len (host_bridge) > 63)
8116 errmsg ("host bridge name too long. ");
8119 if (host_ip4_prefix_len > 32)
8121 errmsg ("host ip4 prefix length not valid. ");
8124 if (host_ip6_prefix_len > 128)
8126 errmsg ("host ip6 prefix length not valid. ");
8129 if (!is_pow2 (rx_ring_sz))
8131 errmsg ("rx ring size must be power of 2. ");
8134 if (rx_ring_sz > 32768)
8136 errmsg ("rx ring size must be 32768 or lower. ");
8139 if (!is_pow2 (tx_ring_sz))
8141 errmsg ("tx ring size must be power of 2. ");
8144 if (tx_ring_sz > 32768)
8146 errmsg ("tx ring size must be 32768 or lower. ");
8150 /* Construct the API message */
8151 M (TAP_CREATE_V2, mp);
8153 mp->use_random_mac = random_mac;
8155 mp->id = ntohl (id);
8156 mp->host_namespace_set = host_ns != 0;
8157 mp->host_bridge_set = host_bridge != 0;
8158 mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
8159 mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
8160 mp->rx_ring_sz = ntohs (rx_ring_sz);
8161 mp->tx_ring_sz = ntohs (tx_ring_sz);
8163 if (random_mac == 0)
8164 clib_memcpy (mp->mac_address, mac_address, 6);
8165 if (host_mac_addr_set)
8166 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
8168 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
8170 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
8172 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
8173 if (host_ip4_prefix_len)
8174 clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
8175 if (host_ip4_prefix_len)
8176 clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
8177 if (host_ip4_gw_set)
8178 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
8179 if (host_ip6_gw_set)
8180 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
8183 vec_free (host_if_name);
8184 vec_free (host_bridge);
8189 /* Wait for a reply... */
8195 api_tap_delete_v2 (vat_main_t * vam)
8197 unformat_input_t *i = vam->input;
8198 vl_api_tap_delete_v2_t *mp;
8199 u32 sw_if_index = ~0;
8200 u8 sw_if_index_set = 0;
8203 /* Parse args required to build the message */
8204 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8206 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8207 sw_if_index_set = 1;
8208 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8209 sw_if_index_set = 1;
8214 if (sw_if_index_set == 0)
8216 errmsg ("missing vpp interface name. ");
8220 /* Construct the API message */
8221 M (TAP_DELETE_V2, mp);
8223 mp->sw_if_index = ntohl (sw_if_index);
8228 /* Wait for a reply... */
8234 api_bond_create (vat_main_t * vam)
8236 unformat_input_t *i = vam->input;
8237 vl_api_bond_create_t *mp;
8245 memset (mac_address, 0, sizeof (mac_address));
8248 /* Parse args required to build the message */
8249 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8251 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
8253 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
8254 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
8256 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
8263 if (mode_is_set == 0)
8265 errmsg ("Missing bond mode. ");
8269 /* Construct the API message */
8270 M (BOND_CREATE, mp);
8272 mp->use_custom_mac = custom_mac;
8278 clib_memcpy (mp->mac_address, mac_address, 6);
8283 /* Wait for a reply... */
8289 api_bond_delete (vat_main_t * vam)
8291 unformat_input_t *i = vam->input;
8292 vl_api_bond_delete_t *mp;
8293 u32 sw_if_index = ~0;
8294 u8 sw_if_index_set = 0;
8297 /* Parse args required to build the message */
8298 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8300 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8301 sw_if_index_set = 1;
8302 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8303 sw_if_index_set = 1;
8308 if (sw_if_index_set == 0)
8310 errmsg ("missing vpp interface name. ");
8314 /* Construct the API message */
8315 M (BOND_DELETE, mp);
8317 mp->sw_if_index = ntohl (sw_if_index);
8322 /* Wait for a reply... */
8328 api_bond_enslave (vat_main_t * vam)
8330 unformat_input_t *i = vam->input;
8331 vl_api_bond_enslave_t *mp;
8332 u32 bond_sw_if_index;
8336 u32 bond_sw_if_index_is_set = 0;
8338 u8 sw_if_index_is_set = 0;
8340 /* Parse args required to build the message */
8341 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8343 if (unformat (i, "sw_if_index %d", &sw_if_index))
8344 sw_if_index_is_set = 1;
8345 else if (unformat (i, "bond %u", &bond_sw_if_index))
8346 bond_sw_if_index_is_set = 1;
8347 else if (unformat (i, "passive %d", &is_passive))
8349 else if (unformat (i, "long-timeout %d", &is_long_timeout))
8355 if (bond_sw_if_index_is_set == 0)
8357 errmsg ("Missing bond sw_if_index. ");
8360 if (sw_if_index_is_set == 0)
8362 errmsg ("Missing slave sw_if_index. ");
8366 /* Construct the API message */
8367 M (BOND_ENSLAVE, mp);
8369 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
8370 mp->sw_if_index = ntohl (sw_if_index);
8371 mp->is_long_timeout = is_long_timeout;
8372 mp->is_passive = is_passive;
8377 /* Wait for a reply... */
8383 api_bond_detach_slave (vat_main_t * vam)
8385 unformat_input_t *i = vam->input;
8386 vl_api_bond_detach_slave_t *mp;
8387 u32 sw_if_index = ~0;
8388 u8 sw_if_index_set = 0;
8391 /* Parse args required to build the message */
8392 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8394 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8395 sw_if_index_set = 1;
8396 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8397 sw_if_index_set = 1;
8402 if (sw_if_index_set == 0)
8404 errmsg ("missing vpp interface name. ");
8408 /* Construct the API message */
8409 M (BOND_DETACH_SLAVE, mp);
8411 mp->sw_if_index = ntohl (sw_if_index);
8416 /* Wait for a reply... */
8422 api_ip_table_add_del (vat_main_t * vam)
8424 unformat_input_t *i = vam->input;
8425 vl_api_ip_table_add_del_t *mp;
8431 /* Parse args required to build the message */
8432 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8434 if (unformat (i, "ipv6"))
8436 else if (unformat (i, "del"))
8438 else if (unformat (i, "add"))
8440 else if (unformat (i, "table %d", &table_id))
8444 clib_warning ("parse error '%U'", format_unformat_error, i);
8451 errmsg ("missing table-ID");
8455 /* Construct the API message */
8456 M (IP_TABLE_ADD_DEL, mp);
8458 mp->table_id = ntohl (table_id);
8459 mp->is_ipv6 = is_ipv6;
8460 mp->is_add = is_add;
8465 /* Wait for a reply... */
8472 api_ip_add_del_route (vat_main_t * vam)
8474 unformat_input_t *i = vam->input;
8475 vl_api_ip_add_del_route_t *mp;
8476 u32 sw_if_index = ~0, vrf_id = 0;
8478 u8 is_local = 0, is_drop = 0;
8479 u8 is_unreach = 0, is_prohibit = 0;
8481 u32 next_hop_weight = 1;
8482 u8 is_multipath = 0;
8484 u8 address_length_set = 0;
8485 u32 next_hop_table_id = 0;
8486 u32 resolve_attempts = 0;
8487 u32 dst_address_length = 0;
8488 u8 next_hop_set = 0;
8489 ip4_address_t v4_dst_address, v4_next_hop_address;
8490 ip6_address_t v6_dst_address, v6_next_hop_address;
8494 u32 random_add_del = 0;
8495 u32 *random_vector = 0;
8497 u32 random_seed = 0xdeaddabe;
8498 u32 classify_table_index = ~0;
8500 u8 resolve_host = 0, resolve_attached = 0;
8501 mpls_label_t *next_hop_out_label_stack = NULL;
8502 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8503 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8505 /* Parse args required to build the message */
8506 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8508 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8510 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8512 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
8517 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
8522 else if (unformat (i, "/%d", &dst_address_length))
8524 address_length_set = 1;
8527 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
8528 &v4_next_hop_address))
8532 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
8533 &v6_next_hop_address))
8537 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
8539 else if (unformat (i, "weight %d", &next_hop_weight))
8541 else if (unformat (i, "drop"))
8545 else if (unformat (i, "null-send-unreach"))
8549 else if (unformat (i, "null-send-prohibit"))
8553 else if (unformat (i, "local"))
8557 else if (unformat (i, "classify %d", &classify_table_index))
8561 else if (unformat (i, "del"))
8563 else if (unformat (i, "add"))
8565 else if (unformat (i, "resolve-via-host"))
8567 else if (unformat (i, "resolve-via-attached"))
8568 resolve_attached = 1;
8569 else if (unformat (i, "multipath"))
8571 else if (unformat (i, "vrf %d", &vrf_id))
8573 else if (unformat (i, "count %d", &count))
8575 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
8577 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8579 else if (unformat (i, "out-label %d", &next_hop_out_label))
8580 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
8581 else if (unformat (i, "via-label %d", &next_hop_via_label))
8583 else if (unformat (i, "random"))
8585 else if (unformat (i, "seed %d", &random_seed))
8589 clib_warning ("parse error '%U'", format_unformat_error, i);
8594 if (!next_hop_set && !is_drop && !is_local &&
8595 !is_classify && !is_unreach && !is_prohibit &&
8596 MPLS_LABEL_INVALID == next_hop_via_label)
8599 ("next hop / local / drop / unreach / prohibit / classify not set");
8603 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
8605 errmsg ("next hop and next-hop via label set");
8608 if (address_set == 0)
8610 errmsg ("missing addresses");
8614 if (address_length_set == 0)
8616 errmsg ("missing address length");
8620 /* Generate a pile of unique, random routes */
8623 u32 this_random_address;
8624 random_hash = hash_create (count, sizeof (uword));
8626 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
8627 for (j = 0; j <= count; j++)
8631 this_random_address = random_u32 (&random_seed);
8632 this_random_address =
8633 clib_host_to_net_u32 (this_random_address);
8635 while (hash_get (random_hash, this_random_address));
8636 vec_add1 (random_vector, this_random_address);
8637 hash_set (random_hash, this_random_address, 1);
8639 hash_free (random_hash);
8640 v4_dst_address.as_u32 = random_vector[0];
8645 /* Turn on async mode */
8646 vam->async_mode = 1;
8647 vam->async_errors = 0;
8648 before = vat_time_now (vam);
8651 for (j = 0; j < count; j++)
8653 /* Construct the API message */
8654 M2 (IP_ADD_DEL_ROUTE, mp,
8655 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
8657 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8658 mp->table_id = ntohl (vrf_id);
8660 mp->is_add = is_add;
8661 mp->is_drop = is_drop;
8662 mp->is_unreach = is_unreach;
8663 mp->is_prohibit = is_prohibit;
8664 mp->is_ipv6 = is_ipv6;
8665 mp->is_local = is_local;
8666 mp->is_classify = is_classify;
8667 mp->is_multipath = is_multipath;
8668 mp->is_resolve_host = resolve_host;
8669 mp->is_resolve_attached = resolve_attached;
8670 mp->next_hop_weight = next_hop_weight;
8671 mp->dst_address_length = dst_address_length;
8672 mp->next_hop_table_id = ntohl (next_hop_table_id);
8673 mp->classify_table_index = ntohl (classify_table_index);
8674 mp->next_hop_via_label = ntohl (next_hop_via_label);
8675 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8676 if (0 != mp->next_hop_n_out_labels)
8678 memcpy (mp->next_hop_out_label_stack,
8679 next_hop_out_label_stack,
8680 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
8681 vec_free (next_hop_out_label_stack);
8686 clib_memcpy (mp->dst_address, &v6_dst_address,
8687 sizeof (v6_dst_address));
8689 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
8690 sizeof (v6_next_hop_address));
8691 increment_v6_address (&v6_dst_address);
8695 clib_memcpy (mp->dst_address, &v4_dst_address,
8696 sizeof (v4_dst_address));
8698 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
8699 sizeof (v4_next_hop_address));
8701 v4_dst_address.as_u32 = random_vector[j + 1];
8703 increment_v4_address (&v4_dst_address);
8707 /* If we receive SIGTERM, stop now... */
8712 /* When testing multiple add/del ops, use a control-ping to sync */
8715 vl_api_control_ping_t *mp_ping;
8719 /* Shut off async mode */
8720 vam->async_mode = 0;
8722 MPING (CONTROL_PING, mp_ping);
8725 timeout = vat_time_now (vam) + 1.0;
8726 while (vat_time_now (vam) < timeout)
8727 if (vam->result_ready == 1)
8732 if (vam->retval == -99)
8735 if (vam->async_errors > 0)
8737 errmsg ("%d asynchronous errors", vam->async_errors);
8740 vam->async_errors = 0;
8741 after = vat_time_now (vam);
8743 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8747 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8748 count, after - before, count / (after - before));
8754 /* Wait for a reply... */
8759 /* Return the good/bad news */
8760 return (vam->retval);
8764 api_ip_mroute_add_del (vat_main_t * vam)
8766 unformat_input_t *i = vam->input;
8767 vl_api_ip_mroute_add_del_t *mp;
8768 u32 sw_if_index = ~0, vrf_id = 0;
8773 u32 grp_address_length = 0;
8774 ip4_address_t v4_grp_address, v4_src_address;
8775 ip6_address_t v6_grp_address, v6_src_address;
8776 mfib_itf_flags_t iflags = 0;
8777 mfib_entry_flags_t eflags = 0;
8780 /* Parse args required to build the message */
8781 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8783 if (unformat (i, "sw_if_index %d", &sw_if_index))
8785 else if (unformat (i, "%U %U",
8786 unformat_ip4_address, &v4_src_address,
8787 unformat_ip4_address, &v4_grp_address))
8789 grp_address_length = 64;
8793 else if (unformat (i, "%U %U",
8794 unformat_ip6_address, &v6_src_address,
8795 unformat_ip6_address, &v6_grp_address))
8797 grp_address_length = 256;
8801 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
8803 memset (&v4_src_address, 0, sizeof (v4_src_address));
8804 grp_address_length = 32;
8808 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
8810 memset (&v6_src_address, 0, sizeof (v6_src_address));
8811 grp_address_length = 128;
8815 else if (unformat (i, "/%d", &grp_address_length))
8817 else if (unformat (i, "local"))
8821 else if (unformat (i, "del"))
8823 else if (unformat (i, "add"))
8825 else if (unformat (i, "vrf %d", &vrf_id))
8827 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
8829 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8833 clib_warning ("parse error '%U'", format_unformat_error, i);
8838 if (address_set == 0)
8840 errmsg ("missing addresses\n");
8844 /* Construct the API message */
8845 M (IP_MROUTE_ADD_DEL, mp);
8847 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8848 mp->table_id = ntohl (vrf_id);
8850 mp->is_add = is_add;
8851 mp->is_ipv6 = is_ipv6;
8852 mp->is_local = is_local;
8853 mp->itf_flags = ntohl (iflags);
8854 mp->entry_flags = ntohl (eflags);
8855 mp->grp_address_length = grp_address_length;
8856 mp->grp_address_length = ntohs (mp->grp_address_length);
8860 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
8861 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
8865 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
8866 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
8872 /* Wait for a reply... */
8878 api_mpls_table_add_del (vat_main_t * vam)
8880 unformat_input_t *i = vam->input;
8881 vl_api_mpls_table_add_del_t *mp;
8886 /* Parse args required to build the message */
8887 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8889 if (unformat (i, "table %d", &table_id))
8891 else if (unformat (i, "del"))
8893 else if (unformat (i, "add"))
8897 clib_warning ("parse error '%U'", format_unformat_error, i);
8904 errmsg ("missing table-ID");
8908 /* Construct the API message */
8909 M (MPLS_TABLE_ADD_DEL, mp);
8911 mp->mt_table_id = ntohl (table_id);
8912 mp->mt_is_add = is_add;
8917 /* Wait for a reply... */
8924 api_mpls_route_add_del (vat_main_t * vam)
8926 unformat_input_t *i = vam->input;
8927 vl_api_mpls_route_add_del_t *mp;
8928 u32 sw_if_index = ~0, table_id = 0;
8930 u32 next_hop_weight = 1;
8931 u8 is_multipath = 0;
8932 u32 next_hop_table_id = 0;
8933 u8 next_hop_set = 0;
8934 ip4_address_t v4_next_hop_address = {
8937 ip6_address_t v6_next_hop_address = { {0} };
8941 u32 classify_table_index = ~0;
8943 u8 resolve_host = 0, resolve_attached = 0;
8944 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8945 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8946 mpls_label_t *next_hop_out_label_stack = NULL;
8947 mpls_label_t local_label = MPLS_LABEL_INVALID;
8949 dpo_proto_t next_hop_proto = DPO_PROTO_IP4;
8951 /* Parse args required to build the message */
8952 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8954 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8956 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8958 else if (unformat (i, "%d", &local_label))
8960 else if (unformat (i, "eos"))
8962 else if (unformat (i, "non-eos"))
8964 else if (unformat (i, "via %U", unformat_ip4_address,
8965 &v4_next_hop_address))
8968 next_hop_proto = DPO_PROTO_IP4;
8970 else if (unformat (i, "via %U", unformat_ip6_address,
8971 &v6_next_hop_address))
8974 next_hop_proto = DPO_PROTO_IP6;
8976 else if (unformat (i, "weight %d", &next_hop_weight))
8978 else if (unformat (i, "classify %d", &classify_table_index))
8982 else if (unformat (i, "del"))
8984 else if (unformat (i, "add"))
8986 else if (unformat (i, "resolve-via-host"))
8988 else if (unformat (i, "resolve-via-attached"))
8989 resolve_attached = 1;
8990 else if (unformat (i, "multipath"))
8992 else if (unformat (i, "count %d", &count))
8994 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
8997 next_hop_proto = DPO_PROTO_IP4;
8999 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
9002 next_hop_proto = DPO_PROTO_IP6;
9004 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
9006 else if (unformat (i, "via-label %d", &next_hop_via_label))
9008 else if (unformat (i, "out-label %d", &next_hop_out_label))
9009 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
9012 clib_warning ("parse error '%U'", format_unformat_error, i);
9017 if (!next_hop_set && !is_classify)
9019 errmsg ("next hop / classify not set");
9023 if (MPLS_LABEL_INVALID == local_label)
9025 errmsg ("missing label");
9031 /* Turn on async mode */
9032 vam->async_mode = 1;
9033 vam->async_errors = 0;
9034 before = vat_time_now (vam);
9037 for (j = 0; j < count; j++)
9039 /* Construct the API message */
9040 M2 (MPLS_ROUTE_ADD_DEL, mp,
9041 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
9043 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
9044 mp->mr_table_id = ntohl (table_id);
9046 mp->mr_is_add = is_add;
9047 mp->mr_next_hop_proto = next_hop_proto;
9048 mp->mr_is_classify = is_classify;
9049 mp->mr_is_multipath = is_multipath;
9050 mp->mr_is_resolve_host = resolve_host;
9051 mp->mr_is_resolve_attached = resolve_attached;
9052 mp->mr_next_hop_weight = next_hop_weight;
9053 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
9054 mp->mr_classify_table_index = ntohl (classify_table_index);
9055 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
9056 mp->mr_label = ntohl (local_label);
9057 mp->mr_eos = is_eos;
9059 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
9060 if (0 != mp->mr_next_hop_n_out_labels)
9062 memcpy (mp->mr_next_hop_out_label_stack,
9063 next_hop_out_label_stack,
9064 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
9065 vec_free (next_hop_out_label_stack);
9070 if (DPO_PROTO_IP4 == next_hop_proto)
9072 clib_memcpy (mp->mr_next_hop,
9073 &v4_next_hop_address,
9074 sizeof (v4_next_hop_address));
9076 else if (DPO_PROTO_IP6 == next_hop_proto)
9079 clib_memcpy (mp->mr_next_hop,
9080 &v6_next_hop_address,
9081 sizeof (v6_next_hop_address));
9088 /* If we receive SIGTERM, stop now... */
9093 /* When testing multiple add/del ops, use a control-ping to sync */
9096 vl_api_control_ping_t *mp_ping;
9100 /* Shut off async mode */
9101 vam->async_mode = 0;
9103 MPING (CONTROL_PING, mp_ping);
9106 timeout = vat_time_now (vam) + 1.0;
9107 while (vat_time_now (vam) < timeout)
9108 if (vam->result_ready == 1)
9113 if (vam->retval == -99)
9116 if (vam->async_errors > 0)
9118 errmsg ("%d asynchronous errors", vam->async_errors);
9121 vam->async_errors = 0;
9122 after = vat_time_now (vam);
9124 /* slim chance, but we might have eaten SIGTERM on the first iteration */
9128 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
9129 count, after - before, count / (after - before));
9135 /* Wait for a reply... */
9140 /* Return the good/bad news */
9141 return (vam->retval);
9145 api_mpls_ip_bind_unbind (vat_main_t * vam)
9147 unformat_input_t *i = vam->input;
9148 vl_api_mpls_ip_bind_unbind_t *mp;
9149 u32 ip_table_id = 0;
9152 ip4_address_t v4_address;
9153 ip6_address_t v6_address;
9156 mpls_label_t local_label = MPLS_LABEL_INVALID;
9159 /* Parse args required to build the message */
9160 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9162 if (unformat (i, "%U/%d", unformat_ip4_address,
9163 &v4_address, &address_length))
9168 else if (unformat (i, "%U/%d", unformat_ip6_address,
9169 &v6_address, &address_length))
9174 else if (unformat (i, "%d", &local_label))
9176 else if (unformat (i, "table-id %d", &ip_table_id))
9178 else if (unformat (i, "unbind"))
9180 else if (unformat (i, "bind"))
9184 clib_warning ("parse error '%U'", format_unformat_error, i);
9191 errmsg ("IP addres not set");
9195 if (MPLS_LABEL_INVALID == local_label)
9197 errmsg ("missing label");
9201 /* Construct the API message */
9202 M (MPLS_IP_BIND_UNBIND, mp);
9204 mp->mb_is_bind = is_bind;
9205 mp->mb_is_ip4 = is_ip4;
9206 mp->mb_ip_table_id = ntohl (ip_table_id);
9207 mp->mb_mpls_table_id = 0;
9208 mp->mb_label = ntohl (local_label);
9209 mp->mb_address_length = address_length;
9212 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
9214 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
9219 /* Wait for a reply... */
9225 api_bier_table_add_del (vat_main_t * vam)
9227 unformat_input_t *i = vam->input;
9228 vl_api_bier_table_add_del_t *mp;
9230 u32 set = 0, sub_domain = 0, hdr_len = 3;
9231 mpls_label_t local_label = MPLS_LABEL_INVALID;
9234 /* Parse args required to build the message */
9235 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9237 if (unformat (i, "sub-domain %d", &sub_domain))
9239 else if (unformat (i, "set %d", &set))
9241 else if (unformat (i, "label %d", &local_label))
9243 else if (unformat (i, "hdr-len %d", &hdr_len))
9245 else if (unformat (i, "add"))
9247 else if (unformat (i, "del"))
9251 clib_warning ("parse error '%U'", format_unformat_error, i);
9256 if (MPLS_LABEL_INVALID == local_label)
9258 errmsg ("missing label\n");
9262 /* Construct the API message */
9263 M (BIER_TABLE_ADD_DEL, mp);
9265 mp->bt_is_add = is_add;
9266 mp->bt_label = ntohl (local_label);
9267 mp->bt_tbl_id.bt_set = set;
9268 mp->bt_tbl_id.bt_sub_domain = sub_domain;
9269 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
9274 /* Wait for a reply... */
9281 api_bier_route_add_del (vat_main_t * vam)
9283 unformat_input_t *i = vam->input;
9284 vl_api_bier_route_add_del_t *mp;
9286 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
9287 ip4_address_t v4_next_hop_address;
9288 ip6_address_t v6_next_hop_address;
9289 u8 next_hop_set = 0;
9290 u8 next_hop_proto_is_ip4 = 1;
9291 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9294 /* Parse args required to build the message */
9295 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9297 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
9299 next_hop_proto_is_ip4 = 1;
9302 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
9304 next_hop_proto_is_ip4 = 0;
9307 if (unformat (i, "sub-domain %d", &sub_domain))
9309 else if (unformat (i, "set %d", &set))
9311 else if (unformat (i, "hdr-len %d", &hdr_len))
9313 else if (unformat (i, "bp %d", &bp))
9315 else if (unformat (i, "add"))
9317 else if (unformat (i, "del"))
9319 else if (unformat (i, "out-label %d", &next_hop_out_label))
9323 clib_warning ("parse error '%U'", format_unformat_error, i);
9328 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
9330 errmsg ("next hop / label set\n");
9335 errmsg ("bit=position not set\n");
9339 /* Construct the API message */
9340 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
9342 mp->br_is_add = is_add;
9343 mp->br_tbl_id.bt_set = set;
9344 mp->br_tbl_id.bt_sub_domain = sub_domain;
9345 mp->br_tbl_id.bt_hdr_len_id = hdr_len;
9346 mp->br_bp = ntohs (bp);
9348 mp->br_paths[0].n_labels = 1;
9349 mp->br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
9350 mp->br_paths[0].afi = (next_hop_proto_is_ip4 ? 0 : 1);
9352 if (next_hop_proto_is_ip4)
9354 clib_memcpy (mp->br_paths[0].next_hop,
9355 &v4_next_hop_address, sizeof (v4_next_hop_address));
9359 clib_memcpy (mp->br_paths[0].next_hop,
9360 &v6_next_hop_address, sizeof (v6_next_hop_address));
9366 /* Wait for a reply... */
9373 api_proxy_arp_add_del (vat_main_t * vam)
9375 unformat_input_t *i = vam->input;
9376 vl_api_proxy_arp_add_del_t *mp;
9379 ip4_address_t lo, hi;
9383 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9385 if (unformat (i, "vrf %d", &vrf_id))
9387 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
9388 unformat_ip4_address, &hi))
9390 else if (unformat (i, "del"))
9394 clib_warning ("parse error '%U'", format_unformat_error, i);
9401 errmsg ("address range not set");
9405 M (PROXY_ARP_ADD_DEL, mp);
9407 mp->vrf_id = ntohl (vrf_id);
9408 mp->is_add = is_add;
9409 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
9410 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
9418 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
9420 unformat_input_t *i = vam->input;
9421 vl_api_proxy_arp_intfc_enable_disable_t *mp;
9424 u8 sw_if_index_set = 0;
9427 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9429 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9430 sw_if_index_set = 1;
9431 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9432 sw_if_index_set = 1;
9433 else if (unformat (i, "enable"))
9435 else if (unformat (i, "disable"))
9439 clib_warning ("parse error '%U'", format_unformat_error, i);
9444 if (sw_if_index_set == 0)
9446 errmsg ("missing interface name or sw_if_index");
9450 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
9452 mp->sw_if_index = ntohl (sw_if_index);
9453 mp->enable_disable = enable;
9461 api_mpls_tunnel_add_del (vat_main_t * vam)
9463 unformat_input_t *i = vam->input;
9464 vl_api_mpls_tunnel_add_del_t *mp;
9468 u32 sw_if_index = ~0;
9469 u32 next_hop_sw_if_index = ~0;
9470 u32 next_hop_proto_is_ip4 = 1;
9472 u32 next_hop_table_id = 0;
9473 ip4_address_t v4_next_hop_address = {
9476 ip6_address_t v6_next_hop_address = { {0} };
9477 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
9480 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9482 if (unformat (i, "add"))
9484 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
9486 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
9488 else if (unformat (i, "via %U",
9489 unformat_ip4_address, &v4_next_hop_address))
9491 next_hop_proto_is_ip4 = 1;
9493 else if (unformat (i, "via %U",
9494 unformat_ip6_address, &v6_next_hop_address))
9496 next_hop_proto_is_ip4 = 0;
9498 else if (unformat (i, "l2-only"))
9500 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
9502 else if (unformat (i, "out-label %d", &next_hop_out_label))
9503 vec_add1 (labels, ntohl (next_hop_out_label));
9506 clib_warning ("parse error '%U'", format_unformat_error, i);
9511 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
9513 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
9514 mp->mt_sw_if_index = ntohl (sw_if_index);
9515 mp->mt_is_add = is_add;
9516 mp->mt_l2_only = l2_only;
9517 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
9518 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
9520 mp->mt_next_hop_n_out_labels = vec_len (labels);
9522 if (0 != mp->mt_next_hop_n_out_labels)
9524 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
9525 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
9529 if (next_hop_proto_is_ip4)
9531 clib_memcpy (mp->mt_next_hop,
9532 &v4_next_hop_address, sizeof (v4_next_hop_address));
9536 clib_memcpy (mp->mt_next_hop,
9537 &v6_next_hop_address, sizeof (v6_next_hop_address));
9546 api_sw_interface_set_unnumbered (vat_main_t * vam)
9548 unformat_input_t *i = vam->input;
9549 vl_api_sw_interface_set_unnumbered_t *mp;
9551 u32 unnum_sw_index = ~0;
9553 u8 sw_if_index_set = 0;
9556 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9558 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9559 sw_if_index_set = 1;
9560 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9561 sw_if_index_set = 1;
9562 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
9564 else if (unformat (i, "del"))
9568 clib_warning ("parse error '%U'", format_unformat_error, i);
9573 if (sw_if_index_set == 0)
9575 errmsg ("missing interface name or sw_if_index");
9579 M (SW_INTERFACE_SET_UNNUMBERED, mp);
9581 mp->sw_if_index = ntohl (sw_if_index);
9582 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
9583 mp->is_add = is_add;
9591 api_ip_neighbor_add_del (vat_main_t * vam)
9593 unformat_input_t *i = vam->input;
9594 vl_api_ip_neighbor_add_del_t *mp;
9596 u8 sw_if_index_set = 0;
9599 u8 is_no_fib_entry = 0;
9602 u8 v4_address_set = 0;
9603 u8 v6_address_set = 0;
9604 ip4_address_t v4address;
9605 ip6_address_t v6address;
9608 memset (mac_address, 0, sizeof (mac_address));
9610 /* Parse args required to build the message */
9611 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9613 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
9617 else if (unformat (i, "del"))
9620 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9621 sw_if_index_set = 1;
9622 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9623 sw_if_index_set = 1;
9624 else if (unformat (i, "is_static"))
9626 else if (unformat (i, "no-fib-entry"))
9627 is_no_fib_entry = 1;
9628 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
9630 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
9634 clib_warning ("parse error '%U'", format_unformat_error, i);
9639 if (sw_if_index_set == 0)
9641 errmsg ("missing interface name or sw_if_index");
9644 if (v4_address_set && v6_address_set)
9646 errmsg ("both v4 and v6 addresses set");
9649 if (!v4_address_set && !v6_address_set)
9651 errmsg ("no address set");
9655 /* Construct the API message */
9656 M (IP_NEIGHBOR_ADD_DEL, mp);
9658 mp->sw_if_index = ntohl (sw_if_index);
9659 mp->is_add = is_add;
9660 mp->is_static = is_static;
9661 mp->is_no_adj_fib = is_no_fib_entry;
9663 clib_memcpy (mp->mac_address, mac_address, 6);
9667 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
9671 /* mp->is_ipv6 = 0; via memset in M macro above */
9672 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
9678 /* Wait for a reply, return good/bad news */
9684 api_create_vlan_subif (vat_main_t * vam)
9686 unformat_input_t *i = vam->input;
9687 vl_api_create_vlan_subif_t *mp;
9689 u8 sw_if_index_set = 0;
9694 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9696 if (unformat (i, "sw_if_index %d", &sw_if_index))
9697 sw_if_index_set = 1;
9699 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9700 sw_if_index_set = 1;
9701 else if (unformat (i, "vlan %d", &vlan_id))
9705 clib_warning ("parse error '%U'", format_unformat_error, i);
9710 if (sw_if_index_set == 0)
9712 errmsg ("missing interface name or sw_if_index");
9716 if (vlan_id_set == 0)
9718 errmsg ("missing vlan_id");
9721 M (CREATE_VLAN_SUBIF, mp);
9723 mp->sw_if_index = ntohl (sw_if_index);
9724 mp->vlan_id = ntohl (vlan_id);
9731 #define foreach_create_subif_bit \
9738 _(outer_vlan_id_any) \
9739 _(inner_vlan_id_any)
9742 api_create_subif (vat_main_t * vam)
9744 unformat_input_t *i = vam->input;
9745 vl_api_create_subif_t *mp;
9747 u8 sw_if_index_set = 0;
9754 u32 exact_match = 0;
9755 u32 default_sub = 0;
9756 u32 outer_vlan_id_any = 0;
9757 u32 inner_vlan_id_any = 0;
9759 u16 outer_vlan_id = 0;
9760 u16 inner_vlan_id = 0;
9763 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9765 if (unformat (i, "sw_if_index %d", &sw_if_index))
9766 sw_if_index_set = 1;
9768 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9769 sw_if_index_set = 1;
9770 else if (unformat (i, "sub_id %d", &sub_id))
9772 else if (unformat (i, "outer_vlan_id %d", &tmp))
9773 outer_vlan_id = tmp;
9774 else if (unformat (i, "inner_vlan_id %d", &tmp))
9775 inner_vlan_id = tmp;
9777 #define _(a) else if (unformat (i, #a)) a = 1 ;
9778 foreach_create_subif_bit
9782 clib_warning ("parse error '%U'", format_unformat_error, i);
9787 if (sw_if_index_set == 0)
9789 errmsg ("missing interface name or sw_if_index");
9793 if (sub_id_set == 0)
9795 errmsg ("missing sub_id");
9798 M (CREATE_SUBIF, mp);
9800 mp->sw_if_index = ntohl (sw_if_index);
9801 mp->sub_id = ntohl (sub_id);
9803 #define _(a) mp->a = a;
9804 foreach_create_subif_bit;
9807 mp->outer_vlan_id = ntohs (outer_vlan_id);
9808 mp->inner_vlan_id = ntohs (inner_vlan_id);
9816 api_oam_add_del (vat_main_t * vam)
9818 unformat_input_t *i = vam->input;
9819 vl_api_oam_add_del_t *mp;
9822 ip4_address_t src, dst;
9827 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9829 if (unformat (i, "vrf %d", &vrf_id))
9831 else if (unformat (i, "src %U", unformat_ip4_address, &src))
9833 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
9835 else if (unformat (i, "del"))
9839 clib_warning ("parse error '%U'", format_unformat_error, i);
9846 errmsg ("missing src addr");
9852 errmsg ("missing dst addr");
9856 M (OAM_ADD_DEL, mp);
9858 mp->vrf_id = ntohl (vrf_id);
9859 mp->is_add = is_add;
9860 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
9861 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
9869 api_reset_fib (vat_main_t * vam)
9871 unformat_input_t *i = vam->input;
9872 vl_api_reset_fib_t *mp;
9878 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9880 if (unformat (i, "vrf %d", &vrf_id))
9882 else if (unformat (i, "ipv6"))
9886 clib_warning ("parse error '%U'", format_unformat_error, i);
9891 if (vrf_id_set == 0)
9893 errmsg ("missing vrf id");
9899 mp->vrf_id = ntohl (vrf_id);
9900 mp->is_ipv6 = is_ipv6;
9908 api_dhcp_proxy_config (vat_main_t * vam)
9910 unformat_input_t *i = vam->input;
9911 vl_api_dhcp_proxy_config_t *mp;
9913 u32 server_vrf_id = 0;
9915 u8 v4_address_set = 0;
9916 u8 v6_address_set = 0;
9917 ip4_address_t v4address;
9918 ip6_address_t v6address;
9919 u8 v4_src_address_set = 0;
9920 u8 v6_src_address_set = 0;
9921 ip4_address_t v4srcaddress;
9922 ip6_address_t v6srcaddress;
9925 /* Parse args required to build the message */
9926 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9928 if (unformat (i, "del"))
9930 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
9932 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
9934 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
9936 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
9938 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
9939 v4_src_address_set = 1;
9940 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
9941 v6_src_address_set = 1;
9946 if (v4_address_set && v6_address_set)
9948 errmsg ("both v4 and v6 server addresses set");
9951 if (!v4_address_set && !v6_address_set)
9953 errmsg ("no server addresses set");
9957 if (v4_src_address_set && v6_src_address_set)
9959 errmsg ("both v4 and v6 src addresses set");
9962 if (!v4_src_address_set && !v6_src_address_set)
9964 errmsg ("no src addresses set");
9968 if (!(v4_src_address_set && v4_address_set) &&
9969 !(v6_src_address_set && v6_address_set))
9971 errmsg ("no matching server and src addresses set");
9975 /* Construct the API message */
9976 M (DHCP_PROXY_CONFIG, mp);
9978 mp->is_add = is_add;
9979 mp->rx_vrf_id = ntohl (rx_vrf_id);
9980 mp->server_vrf_id = ntohl (server_vrf_id);
9984 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
9985 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
9989 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
9990 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
9996 /* Wait for a reply, return good/bad news */
10001 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
10002 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
10005 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
10007 vat_main_t *vam = &vat_main;
10008 u32 i, count = mp->count;
10009 vl_api_dhcp_server_t *s;
10013 "RX Table-ID %d, Source Address %U, VSS Type %d, "
10014 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
10015 ntohl (mp->rx_vrf_id),
10016 format_ip6_address, mp->dhcp_src_address,
10017 mp->vss_type, mp->vss_vpn_ascii_id,
10018 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
10021 "RX Table-ID %d, Source Address %U, VSS Type %d, "
10022 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
10023 ntohl (mp->rx_vrf_id),
10024 format_ip4_address, mp->dhcp_src_address,
10025 mp->vss_type, mp->vss_vpn_ascii_id,
10026 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
10028 for (i = 0; i < count; i++)
10030 s = &mp->servers[i];
10034 " Server Table-ID %d, Server Address %U",
10035 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
10038 " Server Table-ID %d, Server Address %U",
10039 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
10043 static void vl_api_dhcp_proxy_details_t_handler_json
10044 (vl_api_dhcp_proxy_details_t * mp)
10046 vat_main_t *vam = &vat_main;
10047 vat_json_node_t *node = NULL;
10048 u32 i, count = mp->count;
10049 struct in_addr ip4;
10050 struct in6_addr ip6;
10051 vl_api_dhcp_server_t *s;
10053 if (VAT_JSON_ARRAY != vam->json_tree.type)
10055 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10056 vat_json_init_array (&vam->json_tree);
10058 node = vat_json_array_add (&vam->json_tree);
10060 vat_json_init_object (node);
10061 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
10062 vat_json_object_add_bytes (node, "vss-type", &mp->vss_type,
10063 sizeof (mp->vss_type));
10064 vat_json_object_add_string_copy (node, "vss-vpn-ascii-id",
10065 mp->vss_vpn_ascii_id);
10066 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
10067 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
10071 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
10072 vat_json_object_add_ip6 (node, "src_address", ip6);
10076 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
10077 vat_json_object_add_ip4 (node, "src_address", ip4);
10080 for (i = 0; i < count; i++)
10082 s = &mp->servers[i];
10084 vat_json_object_add_uint (node, "server-table-id",
10085 ntohl (s->server_vrf_id));
10089 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
10090 vat_json_object_add_ip4 (node, "src_address", ip4);
10094 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
10095 vat_json_object_add_ip6 (node, "server_address", ip6);
10101 api_dhcp_proxy_dump (vat_main_t * vam)
10103 unformat_input_t *i = vam->input;
10104 vl_api_control_ping_t *mp_ping;
10105 vl_api_dhcp_proxy_dump_t *mp;
10109 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10111 if (unformat (i, "ipv6"))
10115 clib_warning ("parse error '%U'", format_unformat_error, i);
10120 M (DHCP_PROXY_DUMP, mp);
10122 mp->is_ip6 = is_ipv6;
10125 /* Use a control ping for synchronization */
10126 MPING (CONTROL_PING, mp_ping);
10134 api_dhcp_proxy_set_vss (vat_main_t * vam)
10136 unformat_input_t *i = vam->input;
10137 vl_api_dhcp_proxy_set_vss_t *mp;
10141 u8 vss_type = VSS_TYPE_DEFAULT;
10142 u8 *vpn_ascii_id = 0;
10147 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10149 if (unformat (i, "tbl_id %d", &tbl_id))
10151 else if (unformat (i, "vpn_ascii_id %s", &vpn_ascii_id))
10152 vss_type = VSS_TYPE_ASCII;
10153 else if (unformat (i, "fib_id %d", &fib_id))
10154 vss_type = VSS_TYPE_VPN_ID;
10155 else if (unformat (i, "oui %d", &oui))
10156 vss_type = VSS_TYPE_VPN_ID;
10157 else if (unformat (i, "ipv6"))
10159 else if (unformat (i, "del"))
10167 errmsg ("missing tbl_id ");
10168 vec_free (vpn_ascii_id);
10172 if ((vpn_ascii_id) && (vec_len (vpn_ascii_id) > 128))
10174 errmsg ("vpn_ascii_id cannot be longer than 128 ");
10175 vec_free (vpn_ascii_id);
10179 M (DHCP_PROXY_SET_VSS, mp);
10180 mp->tbl_id = ntohl (tbl_id);
10181 mp->vss_type = vss_type;
10184 clib_memcpy (mp->vpn_ascii_id, vpn_ascii_id, vec_len (vpn_ascii_id));
10185 mp->vpn_ascii_id[vec_len (vpn_ascii_id)] = 0;
10187 mp->vpn_index = ntohl (fib_id);
10188 mp->oui = ntohl (oui);
10189 mp->is_ipv6 = is_ipv6;
10190 mp->is_add = is_add;
10195 vec_free (vpn_ascii_id);
10200 api_dhcp_client_config (vat_main_t * vam)
10202 unformat_input_t *i = vam->input;
10203 vl_api_dhcp_client_config_t *mp;
10205 u8 sw_if_index_set = 0;
10208 u8 disable_event = 0;
10211 /* Parse args required to build the message */
10212 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10214 if (unformat (i, "del"))
10217 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10218 sw_if_index_set = 1;
10219 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10220 sw_if_index_set = 1;
10221 else if (unformat (i, "hostname %s", &hostname))
10223 else if (unformat (i, "disable_event"))
10229 if (sw_if_index_set == 0)
10231 errmsg ("missing interface name or sw_if_index");
10235 if (vec_len (hostname) > 63)
10237 errmsg ("hostname too long");
10239 vec_add1 (hostname, 0);
10241 /* Construct the API message */
10242 M (DHCP_CLIENT_CONFIG, mp);
10244 mp->sw_if_index = htonl (sw_if_index);
10245 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
10246 vec_free (hostname);
10247 mp->is_add = is_add;
10248 mp->want_dhcp_event = disable_event ? 0 : 1;
10249 mp->pid = htonl (getpid ());
10254 /* Wait for a reply, return good/bad news */
10260 api_set_ip_flow_hash (vat_main_t * vam)
10262 unformat_input_t *i = vam->input;
10263 vl_api_set_ip_flow_hash_t *mp;
10275 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10277 if (unformat (i, "vrf %d", &vrf_id))
10279 else if (unformat (i, "ipv6"))
10281 else if (unformat (i, "src"))
10283 else if (unformat (i, "dst"))
10285 else if (unformat (i, "sport"))
10287 else if (unformat (i, "dport"))
10289 else if (unformat (i, "proto"))
10291 else if (unformat (i, "reverse"))
10296 clib_warning ("parse error '%U'", format_unformat_error, i);
10301 if (vrf_id_set == 0)
10303 errmsg ("missing vrf id");
10307 M (SET_IP_FLOW_HASH, mp);
10313 mp->reverse = reverse;
10314 mp->vrf_id = ntohl (vrf_id);
10315 mp->is_ipv6 = is_ipv6;
10323 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
10325 unformat_input_t *i = vam->input;
10326 vl_api_sw_interface_ip6_enable_disable_t *mp;
10328 u8 sw_if_index_set = 0;
10332 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10334 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10335 sw_if_index_set = 1;
10336 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10337 sw_if_index_set = 1;
10338 else if (unformat (i, "enable"))
10340 else if (unformat (i, "disable"))
10344 clib_warning ("parse error '%U'", format_unformat_error, i);
10349 if (sw_if_index_set == 0)
10351 errmsg ("missing interface name or sw_if_index");
10355 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
10357 mp->sw_if_index = ntohl (sw_if_index);
10358 mp->enable = enable;
10366 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
10368 unformat_input_t *i = vam->input;
10369 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
10371 u8 sw_if_index_set = 0;
10372 u8 v6_address_set = 0;
10373 ip6_address_t v6address;
10376 /* Parse args required to build the message */
10377 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10379 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10380 sw_if_index_set = 1;
10381 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10382 sw_if_index_set = 1;
10383 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10384 v6_address_set = 1;
10389 if (sw_if_index_set == 0)
10391 errmsg ("missing interface name or sw_if_index");
10394 if (!v6_address_set)
10396 errmsg ("no address set");
10400 /* Construct the API message */
10401 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
10403 mp->sw_if_index = ntohl (sw_if_index);
10404 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10409 /* Wait for a reply, return good/bad news */
10415 api_ip6nd_proxy_add_del (vat_main_t * vam)
10417 unformat_input_t *i = vam->input;
10418 vl_api_ip6nd_proxy_add_del_t *mp;
10419 u32 sw_if_index = ~0;
10420 u8 v6_address_set = 0;
10421 ip6_address_t v6address;
10425 /* Parse args required to build the message */
10426 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10428 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10430 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10432 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10433 v6_address_set = 1;
10434 if (unformat (i, "del"))
10438 clib_warning ("parse error '%U'", format_unformat_error, i);
10443 if (sw_if_index == ~0)
10445 errmsg ("missing interface name or sw_if_index");
10448 if (!v6_address_set)
10450 errmsg ("no address set");
10454 /* Construct the API message */
10455 M (IP6ND_PROXY_ADD_DEL, mp);
10457 mp->is_del = is_del;
10458 mp->sw_if_index = ntohl (sw_if_index);
10459 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10464 /* Wait for a reply, return good/bad news */
10470 api_ip6nd_proxy_dump (vat_main_t * vam)
10472 vl_api_ip6nd_proxy_dump_t *mp;
10473 vl_api_control_ping_t *mp_ping;
10476 M (IP6ND_PROXY_DUMP, mp);
10480 /* Use a control ping for synchronization */
10481 MPING (CONTROL_PING, mp_ping);
10488 static void vl_api_ip6nd_proxy_details_t_handler
10489 (vl_api_ip6nd_proxy_details_t * mp)
10491 vat_main_t *vam = &vat_main;
10493 print (vam->ofp, "host %U sw_if_index %d",
10494 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
10497 static void vl_api_ip6nd_proxy_details_t_handler_json
10498 (vl_api_ip6nd_proxy_details_t * mp)
10500 vat_main_t *vam = &vat_main;
10501 struct in6_addr ip6;
10502 vat_json_node_t *node = NULL;
10504 if (VAT_JSON_ARRAY != vam->json_tree.type)
10506 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10507 vat_json_init_array (&vam->json_tree);
10509 node = vat_json_array_add (&vam->json_tree);
10511 vat_json_init_object (node);
10512 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10514 clib_memcpy (&ip6, mp->address, sizeof (ip6));
10515 vat_json_object_add_ip6 (node, "host", ip6);
10519 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
10521 unformat_input_t *i = vam->input;
10522 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
10524 u8 sw_if_index_set = 0;
10525 u32 address_length = 0;
10526 u8 v6_address_set = 0;
10527 ip6_address_t v6address;
10528 u8 use_default = 0;
10529 u8 no_advertise = 0;
10531 u8 no_autoconfig = 0;
10534 u32 val_lifetime = 0;
10535 u32 pref_lifetime = 0;
10538 /* Parse args required to build the message */
10539 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10541 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10542 sw_if_index_set = 1;
10543 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10544 sw_if_index_set = 1;
10545 else if (unformat (i, "%U/%d",
10546 unformat_ip6_address, &v6address, &address_length))
10547 v6_address_set = 1;
10548 else if (unformat (i, "val_life %d", &val_lifetime))
10550 else if (unformat (i, "pref_life %d", &pref_lifetime))
10552 else if (unformat (i, "def"))
10554 else if (unformat (i, "noadv"))
10556 else if (unformat (i, "offl"))
10558 else if (unformat (i, "noauto"))
10560 else if (unformat (i, "nolink"))
10562 else if (unformat (i, "isno"))
10566 clib_warning ("parse error '%U'", format_unformat_error, i);
10571 if (sw_if_index_set == 0)
10573 errmsg ("missing interface name or sw_if_index");
10576 if (!v6_address_set)
10578 errmsg ("no address set");
10582 /* Construct the API message */
10583 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
10585 mp->sw_if_index = ntohl (sw_if_index);
10586 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10587 mp->address_length = address_length;
10588 mp->use_default = use_default;
10589 mp->no_advertise = no_advertise;
10590 mp->off_link = off_link;
10591 mp->no_autoconfig = no_autoconfig;
10592 mp->no_onlink = no_onlink;
10594 mp->val_lifetime = ntohl (val_lifetime);
10595 mp->pref_lifetime = ntohl (pref_lifetime);
10600 /* Wait for a reply, return good/bad news */
10606 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
10608 unformat_input_t *i = vam->input;
10609 vl_api_sw_interface_ip6nd_ra_config_t *mp;
10611 u8 sw_if_index_set = 0;
10616 u8 send_unicast = 0;
10619 u8 default_router = 0;
10620 u32 max_interval = 0;
10621 u32 min_interval = 0;
10623 u32 initial_count = 0;
10624 u32 initial_interval = 0;
10628 /* Parse args required to build the message */
10629 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10631 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10632 sw_if_index_set = 1;
10633 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10634 sw_if_index_set = 1;
10635 else if (unformat (i, "maxint %d", &max_interval))
10637 else if (unformat (i, "minint %d", &min_interval))
10639 else if (unformat (i, "life %d", &lifetime))
10641 else if (unformat (i, "count %d", &initial_count))
10643 else if (unformat (i, "interval %d", &initial_interval))
10645 else if (unformat (i, "suppress") || unformat (i, "surpress"))
10647 else if (unformat (i, "managed"))
10649 else if (unformat (i, "other"))
10651 else if (unformat (i, "ll"))
10653 else if (unformat (i, "send"))
10655 else if (unformat (i, "cease"))
10657 else if (unformat (i, "isno"))
10659 else if (unformat (i, "def"))
10660 default_router = 1;
10663 clib_warning ("parse error '%U'", format_unformat_error, i);
10668 if (sw_if_index_set == 0)
10670 errmsg ("missing interface name or sw_if_index");
10674 /* Construct the API message */
10675 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
10677 mp->sw_if_index = ntohl (sw_if_index);
10678 mp->max_interval = ntohl (max_interval);
10679 mp->min_interval = ntohl (min_interval);
10680 mp->lifetime = ntohl (lifetime);
10681 mp->initial_count = ntohl (initial_count);
10682 mp->initial_interval = ntohl (initial_interval);
10683 mp->suppress = suppress;
10684 mp->managed = managed;
10686 mp->ll_option = ll_option;
10687 mp->send_unicast = send_unicast;
10690 mp->default_router = default_router;
10695 /* Wait for a reply, return good/bad news */
10701 api_set_arp_neighbor_limit (vat_main_t * vam)
10703 unformat_input_t *i = vam->input;
10704 vl_api_set_arp_neighbor_limit_t *mp;
10710 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10712 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
10714 else if (unformat (i, "ipv6"))
10718 clib_warning ("parse error '%U'", format_unformat_error, i);
10723 if (limit_set == 0)
10725 errmsg ("missing limit value");
10729 M (SET_ARP_NEIGHBOR_LIMIT, mp);
10731 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
10732 mp->is_ipv6 = is_ipv6;
10740 api_l2_patch_add_del (vat_main_t * vam)
10742 unformat_input_t *i = vam->input;
10743 vl_api_l2_patch_add_del_t *mp;
10744 u32 rx_sw_if_index;
10745 u8 rx_sw_if_index_set = 0;
10746 u32 tx_sw_if_index;
10747 u8 tx_sw_if_index_set = 0;
10751 /* Parse args required to build the message */
10752 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10754 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
10755 rx_sw_if_index_set = 1;
10756 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
10757 tx_sw_if_index_set = 1;
10758 else if (unformat (i, "rx"))
10760 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10762 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10764 rx_sw_if_index_set = 1;
10769 else if (unformat (i, "tx"))
10771 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10773 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10775 tx_sw_if_index_set = 1;
10780 else if (unformat (i, "del"))
10786 if (rx_sw_if_index_set == 0)
10788 errmsg ("missing rx interface name or rx_sw_if_index");
10792 if (tx_sw_if_index_set == 0)
10794 errmsg ("missing tx interface name or tx_sw_if_index");
10798 M (L2_PATCH_ADD_DEL, mp);
10800 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
10801 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
10802 mp->is_add = is_add;
10810 u8 localsid_addr[16];
10819 api_sr_localsid_add_del (vat_main_t * vam)
10821 unformat_input_t *i = vam->input;
10822 vl_api_sr_localsid_add_del_t *mp;
10825 ip6_address_t localsid;
10829 u32 fib_table = ~(u32) 0;
10830 ip6_address_t next_hop;
10832 bool nexthop_set = 0;
10836 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10838 if (unformat (i, "del"))
10840 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
10841 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
10843 else if (unformat (i, "behavior %u", &behavior));
10844 else if (unformat (i, "sw_if_index %u", &sw_if_index));
10845 else if (unformat (i, "fib-table %u", &fib_table));
10846 else if (unformat (i, "end.psp %u", &behavior));
10851 M (SR_LOCALSID_ADD_DEL, mp);
10853 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
10855 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
10856 mp->behavior = behavior;
10857 mp->sw_if_index = ntohl (sw_if_index);
10858 mp->fib_table = ntohl (fib_table);
10859 mp->end_psp = end_psp;
10860 mp->is_del = is_del;
10868 api_ioam_enable (vat_main_t * vam)
10870 unformat_input_t *input = vam->input;
10871 vl_api_ioam_enable_t *mp;
10873 int has_trace_option = 0;
10874 int has_pot_option = 0;
10875 int has_seqno_option = 0;
10876 int has_analyse_option = 0;
10879 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10881 if (unformat (input, "trace"))
10882 has_trace_option = 1;
10883 else if (unformat (input, "pot"))
10884 has_pot_option = 1;
10885 else if (unformat (input, "seqno"))
10886 has_seqno_option = 1;
10887 else if (unformat (input, "analyse"))
10888 has_analyse_option = 1;
10892 M (IOAM_ENABLE, mp);
10893 mp->id = htons (id);
10894 mp->seqno = has_seqno_option;
10895 mp->analyse = has_analyse_option;
10896 mp->pot_enable = has_pot_option;
10897 mp->trace_enable = has_trace_option;
10906 api_ioam_disable (vat_main_t * vam)
10908 vl_api_ioam_disable_t *mp;
10911 M (IOAM_DISABLE, mp);
10917 #define foreach_tcp_proto_field \
10921 #define foreach_udp_proto_field \
10925 #define foreach_ip4_proto_field \
10937 u16 src_port, dst_port;
10940 #if VPP_API_TEST_BUILTIN == 0
10942 unformat_tcp_mask (unformat_input_t * input, va_list * args)
10944 u8 **maskp = va_arg (*args, u8 **);
10946 u8 found_something = 0;
10949 #define _(a) u8 a=0;
10950 foreach_tcp_proto_field;
10953 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10956 #define _(a) else if (unformat (input, #a)) a=1;
10957 foreach_tcp_proto_field
10963 #define _(a) found_something += a;
10964 foreach_tcp_proto_field;
10967 if (found_something == 0)
10970 vec_validate (mask, sizeof (*tcp) - 1);
10972 tcp = (tcp_header_t *) mask;
10974 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
10975 foreach_tcp_proto_field;
10983 unformat_udp_mask (unformat_input_t * input, va_list * args)
10985 u8 **maskp = va_arg (*args, u8 **);
10987 u8 found_something = 0;
10990 #define _(a) u8 a=0;
10991 foreach_udp_proto_field;
10994 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10997 #define _(a) else if (unformat (input, #a)) a=1;
10998 foreach_udp_proto_field
11004 #define _(a) found_something += a;
11005 foreach_udp_proto_field;
11008 if (found_something == 0)
11011 vec_validate (mask, sizeof (*udp) - 1);
11013 udp = (udp_header_t *) mask;
11015 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
11016 foreach_udp_proto_field;
11024 unformat_l4_mask (unformat_input_t * input, va_list * args)
11026 u8 **maskp = va_arg (*args, u8 **);
11027 u16 src_port = 0, dst_port = 0;
11028 tcpudp_header_t *tcpudp;
11030 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11032 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
11034 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
11036 else if (unformat (input, "src_port"))
11038 else if (unformat (input, "dst_port"))
11044 if (!src_port && !dst_port)
11048 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
11050 tcpudp = (tcpudp_header_t *) mask;
11051 tcpudp->src_port = src_port;
11052 tcpudp->dst_port = dst_port;
11060 unformat_ip4_mask (unformat_input_t * input, va_list * args)
11062 u8 **maskp = va_arg (*args, u8 **);
11064 u8 found_something = 0;
11067 #define _(a) u8 a=0;
11068 foreach_ip4_proto_field;
11074 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11076 if (unformat (input, "version"))
11078 else if (unformat (input, "hdr_length"))
11080 else if (unformat (input, "src"))
11082 else if (unformat (input, "dst"))
11084 else if (unformat (input, "proto"))
11087 #define _(a) else if (unformat (input, #a)) a=1;
11088 foreach_ip4_proto_field
11094 #define _(a) found_something += a;
11095 foreach_ip4_proto_field;
11098 if (found_something == 0)
11101 vec_validate (mask, sizeof (*ip) - 1);
11103 ip = (ip4_header_t *) mask;
11105 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
11106 foreach_ip4_proto_field;
11109 ip->ip_version_and_header_length = 0;
11112 ip->ip_version_and_header_length |= 0xF0;
11115 ip->ip_version_and_header_length |= 0x0F;
11121 #define foreach_ip6_proto_field \
11124 _(payload_length) \
11129 unformat_ip6_mask (unformat_input_t * input, va_list * args)
11131 u8 **maskp = va_arg (*args, u8 **);
11133 u8 found_something = 0;
11135 u32 ip_version_traffic_class_and_flow_label;
11137 #define _(a) u8 a=0;
11138 foreach_ip6_proto_field;
11141 u8 traffic_class = 0;
11144 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11146 if (unformat (input, "version"))
11148 else if (unformat (input, "traffic-class"))
11150 else if (unformat (input, "flow-label"))
11152 else if (unformat (input, "src"))
11154 else if (unformat (input, "dst"))
11156 else if (unformat (input, "proto"))
11159 #define _(a) else if (unformat (input, #a)) a=1;
11160 foreach_ip6_proto_field
11166 #define _(a) found_something += a;
11167 foreach_ip6_proto_field;
11170 if (found_something == 0)
11173 vec_validate (mask, sizeof (*ip) - 1);
11175 ip = (ip6_header_t *) mask;
11177 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
11178 foreach_ip6_proto_field;
11181 ip_version_traffic_class_and_flow_label = 0;
11184 ip_version_traffic_class_and_flow_label |= 0xF0000000;
11187 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
11190 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
11192 ip->ip_version_traffic_class_and_flow_label =
11193 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11200 unformat_l3_mask (unformat_input_t * input, va_list * args)
11202 u8 **maskp = va_arg (*args, u8 **);
11204 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11206 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
11208 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
11217 unformat_l2_mask (unformat_input_t * input, va_list * args)
11219 u8 **maskp = va_arg (*args, u8 **);
11226 u8 ignore_tag1 = 0;
11227 u8 ignore_tag2 = 0;
11234 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11236 if (unformat (input, "src"))
11238 else if (unformat (input, "dst"))
11240 else if (unformat (input, "proto"))
11242 else if (unformat (input, "tag1"))
11244 else if (unformat (input, "tag2"))
11246 else if (unformat (input, "ignore-tag1"))
11248 else if (unformat (input, "ignore-tag2"))
11250 else if (unformat (input, "cos1"))
11252 else if (unformat (input, "cos2"))
11254 else if (unformat (input, "dot1q"))
11256 else if (unformat (input, "dot1ad"))
11261 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
11262 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11265 if (tag1 || ignore_tag1 || cos1 || dot1q)
11267 if (tag2 || ignore_tag2 || cos2 || dot1ad)
11270 vec_validate (mask, len - 1);
11273 memset (mask, 0xff, 6);
11276 memset (mask + 6, 0xff, 6);
11278 if (tag2 || dot1ad)
11280 /* inner vlan tag */
11289 mask[21] = mask[20] = 0xff;
11310 mask[16] = mask[17] = 0xff;
11320 mask[12] = mask[13] = 0xff;
11327 unformat_classify_mask (unformat_input_t * input, va_list * args)
11329 u8 **maskp = va_arg (*args, u8 **);
11330 u32 *skipp = va_arg (*args, u32 *);
11331 u32 *matchp = va_arg (*args, u32 *);
11339 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11341 if (unformat (input, "hex %U", unformat_hex_string, &mask))
11343 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
11345 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
11347 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
11361 if (mask || l2 || l3 || l4)
11363 if (l2 || l3 || l4)
11365 /* "With a free Ethernet header in every package" */
11367 vec_validate (l2, 13);
11371 vec_append (mask, l3);
11376 vec_append (mask, l4);
11381 /* Scan forward looking for the first significant mask octet */
11382 for (i = 0; i < vec_len (mask); i++)
11386 /* compute (skip, match) params */
11387 *skipp = i / sizeof (u32x4);
11388 vec_delete (mask, *skipp * sizeof (u32x4), 0);
11390 /* Pad mask to an even multiple of the vector size */
11391 while (vec_len (mask) % sizeof (u32x4))
11392 vec_add1 (mask, 0);
11394 match = vec_len (mask) / sizeof (u32x4);
11396 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
11398 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
11399 if (*tmp || *(tmp + 1))
11404 clib_warning ("BUG: match 0");
11406 _vec_len (mask) = match * sizeof (u32x4);
11416 #endif /* VPP_API_TEST_BUILTIN */
11418 #define foreach_l2_next \
11420 _(ethernet, ETHERNET_INPUT) \
11421 _(ip4, IP4_INPUT) \
11425 unformat_l2_next_index (unformat_input_t * input, va_list * args)
11427 u32 *miss_next_indexp = va_arg (*args, u32 *);
11428 u32 next_index = 0;
11432 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
11436 if (unformat (input, "%d", &tmp))
11445 *miss_next_indexp = next_index;
11449 #define foreach_ip_next \
11452 _(rewrite, REWRITE)
11455 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
11457 u32 *miss_next_indexp = va_arg (*args, u32 *);
11458 u32 next_index = 0;
11462 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
11466 if (unformat (input, "%d", &tmp))
11475 *miss_next_indexp = next_index;
11479 #define foreach_acl_next \
11483 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
11485 u32 *miss_next_indexp = va_arg (*args, u32 *);
11486 u32 next_index = 0;
11490 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
11494 if (unformat (input, "permit"))
11499 else if (unformat (input, "%d", &tmp))
11508 *miss_next_indexp = next_index;
11513 unformat_policer_precolor (unformat_input_t * input, va_list * args)
11515 u32 *r = va_arg (*args, u32 *);
11517 if (unformat (input, "conform-color"))
11518 *r = POLICE_CONFORM;
11519 else if (unformat (input, "exceed-color"))
11520 *r = POLICE_EXCEED;
11528 api_classify_add_del_table (vat_main_t * vam)
11530 unformat_input_t *i = vam->input;
11531 vl_api_classify_add_del_table_t *mp;
11538 u32 table_index = ~0;
11539 u32 next_table_index = ~0;
11540 u32 miss_next_index = ~0;
11541 u32 memory_size = 32 << 20;
11543 u32 current_data_flag = 0;
11544 int current_data_offset = 0;
11547 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11549 if (unformat (i, "del"))
11551 else if (unformat (i, "del-chain"))
11556 else if (unformat (i, "buckets %d", &nbuckets))
11558 else if (unformat (i, "memory_size %d", &memory_size))
11560 else if (unformat (i, "skip %d", &skip))
11562 else if (unformat (i, "match %d", &match))
11564 else if (unformat (i, "table %d", &table_index))
11566 else if (unformat (i, "mask %U", unformat_classify_mask,
11567 &mask, &skip, &match))
11569 else if (unformat (i, "next-table %d", &next_table_index))
11571 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
11574 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
11577 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
11580 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
11582 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
11588 if (is_add && mask == 0)
11590 errmsg ("Mask required");
11594 if (is_add && skip == ~0)
11596 errmsg ("skip count required");
11600 if (is_add && match == ~0)
11602 errmsg ("match count required");
11606 if (!is_add && table_index == ~0)
11608 errmsg ("table index required for delete");
11612 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
11614 mp->is_add = is_add;
11615 mp->del_chain = del_chain;
11616 mp->table_index = ntohl (table_index);
11617 mp->nbuckets = ntohl (nbuckets);
11618 mp->memory_size = ntohl (memory_size);
11619 mp->skip_n_vectors = ntohl (skip);
11620 mp->match_n_vectors = ntohl (match);
11621 mp->next_table_index = ntohl (next_table_index);
11622 mp->miss_next_index = ntohl (miss_next_index);
11623 mp->current_data_flag = ntohl (current_data_flag);
11624 mp->current_data_offset = ntohl (current_data_offset);
11625 clib_memcpy (mp->mask, mask, vec_len (mask));
11634 #if VPP_API_TEST_BUILTIN == 0
11636 unformat_l4_match (unformat_input_t * input, va_list * args)
11638 u8 **matchp = va_arg (*args, u8 **);
11640 u8 *proto_header = 0;
11646 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11648 if (unformat (input, "src_port %d", &src_port))
11650 else if (unformat (input, "dst_port %d", &dst_port))
11656 h.src_port = clib_host_to_net_u16 (src_port);
11657 h.dst_port = clib_host_to_net_u16 (dst_port);
11658 vec_validate (proto_header, sizeof (h) - 1);
11659 memcpy (proto_header, &h, sizeof (h));
11661 *matchp = proto_header;
11667 unformat_ip4_match (unformat_input_t * input, va_list * args)
11669 u8 **matchp = va_arg (*args, u8 **);
11674 int hdr_length = 0;
11675 u32 hdr_length_val;
11676 int src = 0, dst = 0;
11677 ip4_address_t src_val, dst_val;
11684 int fragment_id = 0;
11685 u32 fragment_id_val;
11691 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11693 if (unformat (input, "version %d", &version_val))
11695 else if (unformat (input, "hdr_length %d", &hdr_length_val))
11697 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
11699 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
11701 else if (unformat (input, "proto %d", &proto_val))
11703 else if (unformat (input, "tos %d", &tos_val))
11705 else if (unformat (input, "length %d", &length_val))
11707 else if (unformat (input, "fragment_id %d", &fragment_id_val))
11709 else if (unformat (input, "ttl %d", &ttl_val))
11711 else if (unformat (input, "checksum %d", &checksum_val))
11717 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
11718 + ttl + checksum == 0)
11722 * Aligned because we use the real comparison functions
11724 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11726 ip = (ip4_header_t *) match;
11728 /* These are realistically matched in practice */
11730 ip->src_address.as_u32 = src_val.as_u32;
11733 ip->dst_address.as_u32 = dst_val.as_u32;
11736 ip->protocol = proto_val;
11739 /* These are not, but they're included for completeness */
11741 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
11744 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
11750 ip->length = clib_host_to_net_u16 (length_val);
11756 ip->checksum = clib_host_to_net_u16 (checksum_val);
11763 unformat_ip6_match (unformat_input_t * input, va_list * args)
11765 u8 **matchp = va_arg (*args, u8 **);
11770 u8 traffic_class = 0;
11771 u32 traffic_class_val = 0;
11774 int src = 0, dst = 0;
11775 ip6_address_t src_val, dst_val;
11778 int payload_length = 0;
11779 u32 payload_length_val;
11782 u32 ip_version_traffic_class_and_flow_label;
11784 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11786 if (unformat (input, "version %d", &version_val))
11788 else if (unformat (input, "traffic_class %d", &traffic_class_val))
11790 else if (unformat (input, "flow_label %d", &flow_label_val))
11792 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
11794 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
11796 else if (unformat (input, "proto %d", &proto_val))
11798 else if (unformat (input, "payload_length %d", &payload_length_val))
11799 payload_length = 1;
11800 else if (unformat (input, "hop_limit %d", &hop_limit_val))
11806 if (version + traffic_class + flow_label + src + dst + proto +
11807 payload_length + hop_limit == 0)
11811 * Aligned because we use the real comparison functions
11813 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11815 ip = (ip6_header_t *) match;
11818 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
11821 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
11824 ip->protocol = proto_val;
11826 ip_version_traffic_class_and_flow_label = 0;
11829 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
11832 ip_version_traffic_class_and_flow_label |=
11833 (traffic_class_val & 0xFF) << 20;
11836 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
11838 ip->ip_version_traffic_class_and_flow_label =
11839 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11841 if (payload_length)
11842 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
11845 ip->hop_limit = hop_limit_val;
11852 unformat_l3_match (unformat_input_t * input, va_list * args)
11854 u8 **matchp = va_arg (*args, u8 **);
11856 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11858 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
11860 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
11869 unformat_vlan_tag (unformat_input_t * input, va_list * args)
11871 u8 *tagp = va_arg (*args, u8 *);
11874 if (unformat (input, "%d", &tag))
11876 tagp[0] = (tag >> 8) & 0x0F;
11877 tagp[1] = tag & 0xFF;
11885 unformat_l2_match (unformat_input_t * input, va_list * args)
11887 u8 **matchp = va_arg (*args, u8 **);
11900 u8 ignore_tag1 = 0;
11901 u8 ignore_tag2 = 0;
11907 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11909 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
11912 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
11914 else if (unformat (input, "proto %U",
11915 unformat_ethernet_type_host_byte_order, &proto_val))
11917 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
11919 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
11921 else if (unformat (input, "ignore-tag1"))
11923 else if (unformat (input, "ignore-tag2"))
11925 else if (unformat (input, "cos1 %d", &cos1_val))
11927 else if (unformat (input, "cos2 %d", &cos2_val))
11932 if ((src + dst + proto + tag1 + tag2 +
11933 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11936 if (tag1 || ignore_tag1 || cos1)
11938 if (tag2 || ignore_tag2 || cos2)
11941 vec_validate_aligned (match, len - 1, sizeof (u32x4));
11944 clib_memcpy (match, dst_val, 6);
11947 clib_memcpy (match + 6, src_val, 6);
11951 /* inner vlan tag */
11952 match[19] = tag2_val[1];
11953 match[18] = tag2_val[0];
11955 match[18] |= (cos2_val & 0x7) << 5;
11958 match[21] = proto_val & 0xff;
11959 match[20] = proto_val >> 8;
11963 match[15] = tag1_val[1];
11964 match[14] = tag1_val[0];
11967 match[14] |= (cos1_val & 0x7) << 5;
11973 match[15] = tag1_val[1];
11974 match[14] = tag1_val[0];
11977 match[17] = proto_val & 0xff;
11978 match[16] = proto_val >> 8;
11981 match[14] |= (cos1_val & 0x7) << 5;
11987 match[18] |= (cos2_val & 0x7) << 5;
11989 match[14] |= (cos1_val & 0x7) << 5;
11992 match[13] = proto_val & 0xff;
11993 match[12] = proto_val >> 8;
12002 api_unformat_classify_match (unformat_input_t * input, va_list * args)
12004 u8 **matchp = va_arg (*args, u8 **);
12005 u32 skip_n_vectors = va_arg (*args, u32);
12006 u32 match_n_vectors = va_arg (*args, u32);
12013 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12015 if (unformat (input, "hex %U", unformat_hex_string, &match))
12017 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
12019 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
12021 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
12035 if (match || l2 || l3 || l4)
12037 if (l2 || l3 || l4)
12039 /* "Win a free Ethernet header in every packet" */
12041 vec_validate_aligned (l2, 13, sizeof (u32x4));
12045 vec_append_aligned (match, l3, sizeof (u32x4));
12050 vec_append_aligned (match, l4, sizeof (u32x4));
12055 /* Make sure the vector is big enough even if key is all 0's */
12056 vec_validate_aligned
12057 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
12060 /* Set size, include skipped vectors */
12061 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
12072 api_classify_add_del_session (vat_main_t * vam)
12074 unformat_input_t *i = vam->input;
12075 vl_api_classify_add_del_session_t *mp;
12077 u32 table_index = ~0;
12078 u32 hit_next_index = ~0;
12079 u32 opaque_index = ~0;
12082 u32 skip_n_vectors = 0;
12083 u32 match_n_vectors = 0;
12089 * Warning: you have to supply skip_n and match_n
12090 * because the API client cant simply look at the classify
12094 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12096 if (unformat (i, "del"))
12098 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
12101 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
12104 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
12107 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
12109 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
12111 else if (unformat (i, "opaque-index %d", &opaque_index))
12113 else if (unformat (i, "skip_n %d", &skip_n_vectors))
12115 else if (unformat (i, "match_n %d", &match_n_vectors))
12117 else if (unformat (i, "match %U", api_unformat_classify_match,
12118 &match, skip_n_vectors, match_n_vectors))
12120 else if (unformat (i, "advance %d", &advance))
12122 else if (unformat (i, "table-index %d", &table_index))
12124 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
12126 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
12128 else if (unformat (i, "action %d", &action))
12130 else if (unformat (i, "metadata %d", &metadata))
12136 if (table_index == ~0)
12138 errmsg ("Table index required");
12142 if (is_add && match == 0)
12144 errmsg ("Match value required");
12148 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
12150 mp->is_add = is_add;
12151 mp->table_index = ntohl (table_index);
12152 mp->hit_next_index = ntohl (hit_next_index);
12153 mp->opaque_index = ntohl (opaque_index);
12154 mp->advance = ntohl (advance);
12155 mp->action = action;
12156 mp->metadata = ntohl (metadata);
12157 clib_memcpy (mp->match, match, vec_len (match));
12166 api_classify_set_interface_ip_table (vat_main_t * vam)
12168 unformat_input_t *i = vam->input;
12169 vl_api_classify_set_interface_ip_table_t *mp;
12171 int sw_if_index_set;
12172 u32 table_index = ~0;
12176 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12178 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12179 sw_if_index_set = 1;
12180 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12181 sw_if_index_set = 1;
12182 else if (unformat (i, "table %d", &table_index))
12186 clib_warning ("parse error '%U'", format_unformat_error, i);
12191 if (sw_if_index_set == 0)
12193 errmsg ("missing interface name or sw_if_index");
12198 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
12200 mp->sw_if_index = ntohl (sw_if_index);
12201 mp->table_index = ntohl (table_index);
12202 mp->is_ipv6 = is_ipv6;
12210 api_classify_set_interface_l2_tables (vat_main_t * vam)
12212 unformat_input_t *i = vam->input;
12213 vl_api_classify_set_interface_l2_tables_t *mp;
12215 int sw_if_index_set;
12216 u32 ip4_table_index = ~0;
12217 u32 ip6_table_index = ~0;
12218 u32 other_table_index = ~0;
12222 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12224 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12225 sw_if_index_set = 1;
12226 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12227 sw_if_index_set = 1;
12228 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12230 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12232 else if (unformat (i, "other-table %d", &other_table_index))
12234 else if (unformat (i, "is-input %d", &is_input))
12238 clib_warning ("parse error '%U'", format_unformat_error, i);
12243 if (sw_if_index_set == 0)
12245 errmsg ("missing interface name or sw_if_index");
12250 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
12252 mp->sw_if_index = ntohl (sw_if_index);
12253 mp->ip4_table_index = ntohl (ip4_table_index);
12254 mp->ip6_table_index = ntohl (ip6_table_index);
12255 mp->other_table_index = ntohl (other_table_index);
12256 mp->is_input = (u8) is_input;
12264 api_set_ipfix_exporter (vat_main_t * vam)
12266 unformat_input_t *i = vam->input;
12267 vl_api_set_ipfix_exporter_t *mp;
12268 ip4_address_t collector_address;
12269 u8 collector_address_set = 0;
12270 u32 collector_port = ~0;
12271 ip4_address_t src_address;
12272 u8 src_address_set = 0;
12275 u32 template_interval = ~0;
12276 u8 udp_checksum = 0;
12279 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12281 if (unformat (i, "collector_address %U", unformat_ip4_address,
12282 &collector_address))
12283 collector_address_set = 1;
12284 else if (unformat (i, "collector_port %d", &collector_port))
12286 else if (unformat (i, "src_address %U", unformat_ip4_address,
12288 src_address_set = 1;
12289 else if (unformat (i, "vrf_id %d", &vrf_id))
12291 else if (unformat (i, "path_mtu %d", &path_mtu))
12293 else if (unformat (i, "template_interval %d", &template_interval))
12295 else if (unformat (i, "udp_checksum"))
12301 if (collector_address_set == 0)
12303 errmsg ("collector_address required");
12307 if (src_address_set == 0)
12309 errmsg ("src_address required");
12313 M (SET_IPFIX_EXPORTER, mp);
12315 memcpy (mp->collector_address, collector_address.data,
12316 sizeof (collector_address.data));
12317 mp->collector_port = htons ((u16) collector_port);
12318 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
12319 mp->vrf_id = htonl (vrf_id);
12320 mp->path_mtu = htonl (path_mtu);
12321 mp->template_interval = htonl (template_interval);
12322 mp->udp_checksum = udp_checksum;
12330 api_set_ipfix_classify_stream (vat_main_t * vam)
12332 unformat_input_t *i = vam->input;
12333 vl_api_set_ipfix_classify_stream_t *mp;
12335 u32 src_port = UDP_DST_PORT_ipfix;
12338 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12340 if (unformat (i, "domain %d", &domain_id))
12342 else if (unformat (i, "src_port %d", &src_port))
12346 errmsg ("unknown input `%U'", format_unformat_error, i);
12351 M (SET_IPFIX_CLASSIFY_STREAM, mp);
12353 mp->domain_id = htonl (domain_id);
12354 mp->src_port = htons ((u16) src_port);
12362 api_ipfix_classify_table_add_del (vat_main_t * vam)
12364 unformat_input_t *i = vam->input;
12365 vl_api_ipfix_classify_table_add_del_t *mp;
12367 u32 classify_table_index = ~0;
12369 u8 transport_protocol = 255;
12372 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12374 if (unformat (i, "add"))
12376 else if (unformat (i, "del"))
12378 else if (unformat (i, "table %d", &classify_table_index))
12380 else if (unformat (i, "ip4"))
12382 else if (unformat (i, "ip6"))
12384 else if (unformat (i, "tcp"))
12385 transport_protocol = 6;
12386 else if (unformat (i, "udp"))
12387 transport_protocol = 17;
12390 errmsg ("unknown input `%U'", format_unformat_error, i);
12397 errmsg ("expecting: add|del");
12400 if (classify_table_index == ~0)
12402 errmsg ("classifier table not specified");
12405 if (ip_version == 0)
12407 errmsg ("IP version not specified");
12411 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
12413 mp->is_add = is_add;
12414 mp->table_id = htonl (classify_table_index);
12415 mp->ip_version = ip_version;
12416 mp->transport_protocol = transport_protocol;
12424 api_get_node_index (vat_main_t * vam)
12426 unformat_input_t *i = vam->input;
12427 vl_api_get_node_index_t *mp;
12431 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12433 if (unformat (i, "node %s", &name))
12440 errmsg ("node name required");
12443 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12445 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12449 M (GET_NODE_INDEX, mp);
12450 clib_memcpy (mp->node_name, name, vec_len (name));
12459 api_get_next_index (vat_main_t * vam)
12461 unformat_input_t *i = vam->input;
12462 vl_api_get_next_index_t *mp;
12463 u8 *node_name = 0, *next_node_name = 0;
12466 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12468 if (unformat (i, "node-name %s", &node_name))
12470 else if (unformat (i, "next-node-name %s", &next_node_name))
12474 if (node_name == 0)
12476 errmsg ("node name required");
12479 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
12481 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12485 if (next_node_name == 0)
12487 errmsg ("next node name required");
12490 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
12492 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
12496 M (GET_NEXT_INDEX, mp);
12497 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
12498 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
12499 vec_free (node_name);
12500 vec_free (next_node_name);
12508 api_add_node_next (vat_main_t * vam)
12510 unformat_input_t *i = vam->input;
12511 vl_api_add_node_next_t *mp;
12516 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12518 if (unformat (i, "node %s", &name))
12520 else if (unformat (i, "next %s", &next))
12527 errmsg ("node name required");
12530 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12532 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12537 errmsg ("next node required");
12540 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
12542 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
12546 M (ADD_NODE_NEXT, mp);
12547 clib_memcpy (mp->node_name, name, vec_len (name));
12548 clib_memcpy (mp->next_name, next, vec_len (next));
12558 api_l2tpv3_create_tunnel (vat_main_t * vam)
12560 unformat_input_t *i = vam->input;
12561 ip6_address_t client_address, our_address;
12562 int client_address_set = 0;
12563 int our_address_set = 0;
12564 u32 local_session_id = 0;
12565 u32 remote_session_id = 0;
12566 u64 local_cookie = 0;
12567 u64 remote_cookie = 0;
12568 u8 l2_sublayer_present = 0;
12569 vl_api_l2tpv3_create_tunnel_t *mp;
12572 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12574 if (unformat (i, "client_address %U", unformat_ip6_address,
12576 client_address_set = 1;
12577 else if (unformat (i, "our_address %U", unformat_ip6_address,
12579 our_address_set = 1;
12580 else if (unformat (i, "local_session_id %d", &local_session_id))
12582 else if (unformat (i, "remote_session_id %d", &remote_session_id))
12584 else if (unformat (i, "local_cookie %lld", &local_cookie))
12586 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
12588 else if (unformat (i, "l2-sublayer-present"))
12589 l2_sublayer_present = 1;
12594 if (client_address_set == 0)
12596 errmsg ("client_address required");
12600 if (our_address_set == 0)
12602 errmsg ("our_address required");
12606 M (L2TPV3_CREATE_TUNNEL, mp);
12608 clib_memcpy (mp->client_address, client_address.as_u8,
12609 sizeof (mp->client_address));
12611 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
12613 mp->local_session_id = ntohl (local_session_id);
12614 mp->remote_session_id = ntohl (remote_session_id);
12615 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
12616 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
12617 mp->l2_sublayer_present = l2_sublayer_present;
12626 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
12628 unformat_input_t *i = vam->input;
12630 u8 sw_if_index_set = 0;
12631 u64 new_local_cookie = 0;
12632 u64 new_remote_cookie = 0;
12633 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
12636 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12638 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12639 sw_if_index_set = 1;
12640 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12641 sw_if_index_set = 1;
12642 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
12644 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
12650 if (sw_if_index_set == 0)
12652 errmsg ("missing interface name or sw_if_index");
12656 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
12658 mp->sw_if_index = ntohl (sw_if_index);
12659 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
12660 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
12668 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
12670 unformat_input_t *i = vam->input;
12671 vl_api_l2tpv3_interface_enable_disable_t *mp;
12673 u8 sw_if_index_set = 0;
12674 u8 enable_disable = 1;
12677 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12679 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12680 sw_if_index_set = 1;
12681 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12682 sw_if_index_set = 1;
12683 else if (unformat (i, "enable"))
12684 enable_disable = 1;
12685 else if (unformat (i, "disable"))
12686 enable_disable = 0;
12691 if (sw_if_index_set == 0)
12693 errmsg ("missing interface name or sw_if_index");
12697 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
12699 mp->sw_if_index = ntohl (sw_if_index);
12700 mp->enable_disable = enable_disable;
12708 api_l2tpv3_set_lookup_key (vat_main_t * vam)
12710 unformat_input_t *i = vam->input;
12711 vl_api_l2tpv3_set_lookup_key_t *mp;
12715 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12717 if (unformat (i, "lookup_v6_src"))
12718 key = L2T_LOOKUP_SRC_ADDRESS;
12719 else if (unformat (i, "lookup_v6_dst"))
12720 key = L2T_LOOKUP_DST_ADDRESS;
12721 else if (unformat (i, "lookup_session_id"))
12722 key = L2T_LOOKUP_SESSION_ID;
12727 if (key == (u8) ~ 0)
12729 errmsg ("l2tp session lookup key unset");
12733 M (L2TPV3_SET_LOOKUP_KEY, mp);
12742 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
12743 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12745 vat_main_t *vam = &vat_main;
12747 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
12748 format_ip6_address, mp->our_address,
12749 format_ip6_address, mp->client_address,
12750 clib_net_to_host_u32 (mp->sw_if_index));
12753 " local cookies %016llx %016llx remote cookie %016llx",
12754 clib_net_to_host_u64 (mp->local_cookie[0]),
12755 clib_net_to_host_u64 (mp->local_cookie[1]),
12756 clib_net_to_host_u64 (mp->remote_cookie));
12758 print (vam->ofp, " local session-id %d remote session-id %d",
12759 clib_net_to_host_u32 (mp->local_session_id),
12760 clib_net_to_host_u32 (mp->remote_session_id));
12762 print (vam->ofp, " l2 specific sublayer %s\n",
12763 mp->l2_sublayer_present ? "preset" : "absent");
12767 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
12768 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12770 vat_main_t *vam = &vat_main;
12771 vat_json_node_t *node = NULL;
12772 struct in6_addr addr;
12774 if (VAT_JSON_ARRAY != vam->json_tree.type)
12776 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12777 vat_json_init_array (&vam->json_tree);
12779 node = vat_json_array_add (&vam->json_tree);
12781 vat_json_init_object (node);
12783 clib_memcpy (&addr, mp->our_address, sizeof (addr));
12784 vat_json_object_add_ip6 (node, "our_address", addr);
12785 clib_memcpy (&addr, mp->client_address, sizeof (addr));
12786 vat_json_object_add_ip6 (node, "client_address", addr);
12788 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
12789 vat_json_init_array (lc);
12790 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
12791 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
12792 vat_json_object_add_uint (node, "remote_cookie",
12793 clib_net_to_host_u64 (mp->remote_cookie));
12795 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
12796 vat_json_object_add_uint (node, "local_session_id",
12797 clib_net_to_host_u32 (mp->local_session_id));
12798 vat_json_object_add_uint (node, "remote_session_id",
12799 clib_net_to_host_u32 (mp->remote_session_id));
12800 vat_json_object_add_string_copy (node, "l2_sublayer",
12801 mp->l2_sublayer_present ? (u8 *) "present"
12802 : (u8 *) "absent");
12806 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
12808 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
12809 vl_api_control_ping_t *mp_ping;
12812 /* Get list of l2tpv3-tunnel interfaces */
12813 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
12816 /* Use a control ping for synchronization */
12817 MPING (CONTROL_PING, mp_ping);
12825 static void vl_api_sw_interface_tap_details_t_handler
12826 (vl_api_sw_interface_tap_details_t * mp)
12828 vat_main_t *vam = &vat_main;
12830 print (vam->ofp, "%-16s %d",
12831 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
12834 static void vl_api_sw_interface_tap_details_t_handler_json
12835 (vl_api_sw_interface_tap_details_t * mp)
12837 vat_main_t *vam = &vat_main;
12838 vat_json_node_t *node = NULL;
12840 if (VAT_JSON_ARRAY != vam->json_tree.type)
12842 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12843 vat_json_init_array (&vam->json_tree);
12845 node = vat_json_array_add (&vam->json_tree);
12847 vat_json_init_object (node);
12848 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12849 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12853 api_sw_interface_tap_dump (vat_main_t * vam)
12855 vl_api_sw_interface_tap_dump_t *mp;
12856 vl_api_control_ping_t *mp_ping;
12859 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
12860 /* Get list of tap interfaces */
12861 M (SW_INTERFACE_TAP_DUMP, mp);
12864 /* Use a control ping for synchronization */
12865 MPING (CONTROL_PING, mp_ping);
12872 static void vl_api_sw_interface_tap_v2_details_t_handler
12873 (vl_api_sw_interface_tap_v2_details_t * mp)
12875 vat_main_t *vam = &vat_main;
12877 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
12878 mp->host_ip4_prefix_len);
12879 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
12880 mp->host_ip6_prefix_len);
12883 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s",
12884 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
12885 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12886 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
12887 mp->host_bridge, ip4, ip6);
12893 static void vl_api_sw_interface_tap_v2_details_t_handler_json
12894 (vl_api_sw_interface_tap_v2_details_t * mp)
12896 vat_main_t *vam = &vat_main;
12897 vat_json_node_t *node = NULL;
12899 if (VAT_JSON_ARRAY != vam->json_tree.type)
12901 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12902 vat_json_init_array (&vam->json_tree);
12904 node = vat_json_array_add (&vam->json_tree);
12906 vat_json_init_object (node);
12907 vat_json_object_add_uint (node, "id", ntohl (mp->id));
12908 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12909 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12910 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12911 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12912 vat_json_object_add_string_copy (node, "host_mac_addr",
12913 format (0, "%U", format_ethernet_address,
12914 &mp->host_mac_addr));
12915 vat_json_object_add_string_copy (node, "host_namespace",
12916 mp->host_namespace);
12917 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
12918 vat_json_object_add_string_copy (node, "host_ip4_addr",
12919 format (0, "%U/%d", format_ip4_address,
12921 mp->host_ip4_prefix_len));
12922 vat_json_object_add_string_copy (node, "host_ip6_addr",
12923 format (0, "%U/%d", format_ip6_address,
12925 mp->host_ip6_prefix_len));
12930 api_sw_interface_tap_v2_dump (vat_main_t * vam)
12932 vl_api_sw_interface_tap_v2_dump_t *mp;
12933 vl_api_control_ping_t *mp_ping;
12937 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
12938 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
12939 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
12942 /* Get list of tap interfaces */
12943 M (SW_INTERFACE_TAP_V2_DUMP, mp);
12946 /* Use a control ping for synchronization */
12947 MPING (CONTROL_PING, mp_ping);
12954 static uword unformat_vxlan_decap_next
12955 (unformat_input_t * input, va_list * args)
12957 u32 *result = va_arg (*args, u32 *);
12960 if (unformat (input, "l2"))
12961 *result = VXLAN_INPUT_NEXT_L2_INPUT;
12962 else if (unformat (input, "%d", &tmp))
12970 api_vxlan_add_del_tunnel (vat_main_t * vam)
12972 unformat_input_t *line_input = vam->input;
12973 vl_api_vxlan_add_del_tunnel_t *mp;
12974 ip46_address_t src, dst;
12976 u8 ipv4_set = 0, ipv6_set = 0;
12981 u32 mcast_sw_if_index = ~0;
12982 u32 encap_vrf_id = 0;
12983 u32 decap_next_index = ~0;
12987 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12988 memset (&src, 0, sizeof src);
12989 memset (&dst, 0, sizeof dst);
12991 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12993 if (unformat (line_input, "del"))
12995 else if (unformat (line_input, "instance %d", &instance))
12998 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13004 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13010 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13016 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13021 else if (unformat (line_input, "group %U %U",
13022 unformat_ip4_address, &dst.ip4,
13023 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13025 grp_set = dst_set = 1;
13028 else if (unformat (line_input, "group %U",
13029 unformat_ip4_address, &dst.ip4))
13031 grp_set = dst_set = 1;
13034 else if (unformat (line_input, "group %U %U",
13035 unformat_ip6_address, &dst.ip6,
13036 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13038 grp_set = dst_set = 1;
13041 else if (unformat (line_input, "group %U",
13042 unformat_ip6_address, &dst.ip6))
13044 grp_set = dst_set = 1;
13048 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13050 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13052 else if (unformat (line_input, "decap-next %U",
13053 unformat_vxlan_decap_next, &decap_next_index))
13055 else if (unformat (line_input, "vni %d", &vni))
13059 errmsg ("parse error '%U'", format_unformat_error, line_input);
13066 errmsg ("tunnel src address not specified");
13071 errmsg ("tunnel dst address not specified");
13075 if (grp_set && !ip46_address_is_multicast (&dst))
13077 errmsg ("tunnel group address not multicast");
13080 if (grp_set && mcast_sw_if_index == ~0)
13082 errmsg ("tunnel nonexistent multicast device");
13085 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13087 errmsg ("tunnel dst address must be unicast");
13092 if (ipv4_set && ipv6_set)
13094 errmsg ("both IPv4 and IPv6 addresses specified");
13098 if ((vni == 0) || (vni >> 24))
13100 errmsg ("vni not specified or out of range");
13104 M (VXLAN_ADD_DEL_TUNNEL, mp);
13108 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
13109 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
13113 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
13114 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
13117 mp->instance = htonl (instance);
13118 mp->encap_vrf_id = ntohl (encap_vrf_id);
13119 mp->decap_next_index = ntohl (decap_next_index);
13120 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13121 mp->vni = ntohl (vni);
13122 mp->is_add = is_add;
13123 mp->is_ipv6 = ipv6_set;
13130 static void vl_api_vxlan_tunnel_details_t_handler
13131 (vl_api_vxlan_tunnel_details_t * mp)
13133 vat_main_t *vam = &vat_main;
13134 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13135 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13137 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
13138 ntohl (mp->sw_if_index),
13139 ntohl (mp->instance),
13140 format_ip46_address, &src, IP46_TYPE_ANY,
13141 format_ip46_address, &dst, IP46_TYPE_ANY,
13142 ntohl (mp->encap_vrf_id),
13143 ntohl (mp->decap_next_index), ntohl (mp->vni),
13144 ntohl (mp->mcast_sw_if_index));
13147 static void vl_api_vxlan_tunnel_details_t_handler_json
13148 (vl_api_vxlan_tunnel_details_t * mp)
13150 vat_main_t *vam = &vat_main;
13151 vat_json_node_t *node = NULL;
13153 if (VAT_JSON_ARRAY != vam->json_tree.type)
13155 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13156 vat_json_init_array (&vam->json_tree);
13158 node = vat_json_array_add (&vam->json_tree);
13160 vat_json_init_object (node);
13161 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13163 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13167 struct in6_addr ip6;
13169 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13170 vat_json_object_add_ip6 (node, "src_address", ip6);
13171 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13172 vat_json_object_add_ip6 (node, "dst_address", ip6);
13176 struct in_addr ip4;
13178 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13179 vat_json_object_add_ip4 (node, "src_address", ip4);
13180 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13181 vat_json_object_add_ip4 (node, "dst_address", ip4);
13183 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13184 vat_json_object_add_uint (node, "decap_next_index",
13185 ntohl (mp->decap_next_index));
13186 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13187 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13188 vat_json_object_add_uint (node, "mcast_sw_if_index",
13189 ntohl (mp->mcast_sw_if_index));
13193 api_vxlan_tunnel_dump (vat_main_t * vam)
13195 unformat_input_t *i = vam->input;
13196 vl_api_vxlan_tunnel_dump_t *mp;
13197 vl_api_control_ping_t *mp_ping;
13199 u8 sw_if_index_set = 0;
13202 /* Parse args required to build the message */
13203 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13205 if (unformat (i, "sw_if_index %d", &sw_if_index))
13206 sw_if_index_set = 1;
13211 if (sw_if_index_set == 0)
13216 if (!vam->json_output)
13218 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
13219 "sw_if_index", "instance", "src_address", "dst_address",
13220 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13223 /* Get list of vxlan-tunnel interfaces */
13224 M (VXLAN_TUNNEL_DUMP, mp);
13226 mp->sw_if_index = htonl (sw_if_index);
13230 /* Use a control ping for synchronization */
13231 MPING (CONTROL_PING, mp_ping);
13238 static uword unformat_geneve_decap_next
13239 (unformat_input_t * input, va_list * args)
13241 u32 *result = va_arg (*args, u32 *);
13244 if (unformat (input, "l2"))
13245 *result = GENEVE_INPUT_NEXT_L2_INPUT;
13246 else if (unformat (input, "%d", &tmp))
13254 api_geneve_add_del_tunnel (vat_main_t * vam)
13256 unformat_input_t *line_input = vam->input;
13257 vl_api_geneve_add_del_tunnel_t *mp;
13258 ip46_address_t src, dst;
13260 u8 ipv4_set = 0, ipv6_set = 0;
13264 u32 mcast_sw_if_index = ~0;
13265 u32 encap_vrf_id = 0;
13266 u32 decap_next_index = ~0;
13270 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13271 memset (&src, 0, sizeof src);
13272 memset (&dst, 0, sizeof dst);
13274 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13276 if (unformat (line_input, "del"))
13279 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13285 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13291 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13297 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13302 else if (unformat (line_input, "group %U %U",
13303 unformat_ip4_address, &dst.ip4,
13304 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13306 grp_set = dst_set = 1;
13309 else if (unformat (line_input, "group %U",
13310 unformat_ip4_address, &dst.ip4))
13312 grp_set = dst_set = 1;
13315 else if (unformat (line_input, "group %U %U",
13316 unformat_ip6_address, &dst.ip6,
13317 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13319 grp_set = dst_set = 1;
13322 else if (unformat (line_input, "group %U",
13323 unformat_ip6_address, &dst.ip6))
13325 grp_set = dst_set = 1;
13329 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13331 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13333 else if (unformat (line_input, "decap-next %U",
13334 unformat_geneve_decap_next, &decap_next_index))
13336 else if (unformat (line_input, "vni %d", &vni))
13340 errmsg ("parse error '%U'", format_unformat_error, line_input);
13347 errmsg ("tunnel src address not specified");
13352 errmsg ("tunnel dst address not specified");
13356 if (grp_set && !ip46_address_is_multicast (&dst))
13358 errmsg ("tunnel group address not multicast");
13361 if (grp_set && mcast_sw_if_index == ~0)
13363 errmsg ("tunnel nonexistent multicast device");
13366 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13368 errmsg ("tunnel dst address must be unicast");
13373 if (ipv4_set && ipv6_set)
13375 errmsg ("both IPv4 and IPv6 addresses specified");
13379 if ((vni == 0) || (vni >> 24))
13381 errmsg ("vni not specified or out of range");
13385 M (GENEVE_ADD_DEL_TUNNEL, mp);
13389 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
13390 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
13394 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
13395 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
13397 mp->encap_vrf_id = ntohl (encap_vrf_id);
13398 mp->decap_next_index = ntohl (decap_next_index);
13399 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13400 mp->vni = ntohl (vni);
13401 mp->is_add = is_add;
13402 mp->is_ipv6 = ipv6_set;
13409 static void vl_api_geneve_tunnel_details_t_handler
13410 (vl_api_geneve_tunnel_details_t * mp)
13412 vat_main_t *vam = &vat_main;
13413 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13414 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13416 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
13417 ntohl (mp->sw_if_index),
13418 format_ip46_address, &src, IP46_TYPE_ANY,
13419 format_ip46_address, &dst, IP46_TYPE_ANY,
13420 ntohl (mp->encap_vrf_id),
13421 ntohl (mp->decap_next_index), ntohl (mp->vni),
13422 ntohl (mp->mcast_sw_if_index));
13425 static void vl_api_geneve_tunnel_details_t_handler_json
13426 (vl_api_geneve_tunnel_details_t * mp)
13428 vat_main_t *vam = &vat_main;
13429 vat_json_node_t *node = NULL;
13431 if (VAT_JSON_ARRAY != vam->json_tree.type)
13433 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13434 vat_json_init_array (&vam->json_tree);
13436 node = vat_json_array_add (&vam->json_tree);
13438 vat_json_init_object (node);
13439 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13442 struct in6_addr ip6;
13444 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13445 vat_json_object_add_ip6 (node, "src_address", ip6);
13446 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13447 vat_json_object_add_ip6 (node, "dst_address", ip6);
13451 struct in_addr ip4;
13453 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13454 vat_json_object_add_ip4 (node, "src_address", ip4);
13455 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13456 vat_json_object_add_ip4 (node, "dst_address", ip4);
13458 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13459 vat_json_object_add_uint (node, "decap_next_index",
13460 ntohl (mp->decap_next_index));
13461 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13462 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13463 vat_json_object_add_uint (node, "mcast_sw_if_index",
13464 ntohl (mp->mcast_sw_if_index));
13468 api_geneve_tunnel_dump (vat_main_t * vam)
13470 unformat_input_t *i = vam->input;
13471 vl_api_geneve_tunnel_dump_t *mp;
13472 vl_api_control_ping_t *mp_ping;
13474 u8 sw_if_index_set = 0;
13477 /* Parse args required to build the message */
13478 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13480 if (unformat (i, "sw_if_index %d", &sw_if_index))
13481 sw_if_index_set = 1;
13486 if (sw_if_index_set == 0)
13491 if (!vam->json_output)
13493 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
13494 "sw_if_index", "local_address", "remote_address",
13495 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13498 /* Get list of geneve-tunnel interfaces */
13499 M (GENEVE_TUNNEL_DUMP, mp);
13501 mp->sw_if_index = htonl (sw_if_index);
13505 /* Use a control ping for synchronization */
13506 M (CONTROL_PING, mp_ping);
13514 api_gre_add_del_tunnel (vat_main_t * vam)
13516 unformat_input_t *line_input = vam->input;
13517 vl_api_gre_add_del_tunnel_t *mp;
13518 ip4_address_t src4, dst4;
13519 ip6_address_t src6, dst6;
13523 u8 t_type = GRE_TUNNEL_TYPE_L3;
13526 u32 outer_fib_id = 0;
13527 u32 session_id = 0;
13531 memset (&src4, 0, sizeof src4);
13532 memset (&dst4, 0, sizeof dst4);
13533 memset (&src6, 0, sizeof src6);
13534 memset (&dst6, 0, sizeof dst6);
13536 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13538 if (unformat (line_input, "del"))
13540 else if (unformat (line_input, "instance %d", &instance))
13542 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
13547 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
13552 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
13557 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
13562 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
13564 else if (unformat (line_input, "teb"))
13565 t_type = GRE_TUNNEL_TYPE_TEB;
13566 else if (unformat (line_input, "erspan %d", &session_id))
13567 t_type = GRE_TUNNEL_TYPE_ERSPAN;
13570 errmsg ("parse error '%U'", format_unformat_error, line_input);
13577 errmsg ("tunnel src address not specified");
13582 errmsg ("tunnel dst address not specified");
13585 if (ipv4_set && ipv6_set)
13587 errmsg ("both IPv4 and IPv6 addresses specified");
13592 M (GRE_ADD_DEL_TUNNEL, mp);
13596 clib_memcpy (&mp->src_address, &src4, 4);
13597 clib_memcpy (&mp->dst_address, &dst4, 4);
13601 clib_memcpy (&mp->src_address, &src6, 16);
13602 clib_memcpy (&mp->dst_address, &dst6, 16);
13604 mp->instance = htonl (instance);
13605 mp->outer_fib_id = htonl (outer_fib_id);
13606 mp->is_add = is_add;
13607 mp->session_id = htons ((u16) session_id);
13608 mp->tunnel_type = t_type;
13609 mp->is_ipv6 = ipv6_set;
13616 static void vl_api_gre_tunnel_details_t_handler
13617 (vl_api_gre_tunnel_details_t * mp)
13619 vat_main_t *vam = &vat_main;
13620 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
13621 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
13623 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
13624 ntohl (mp->sw_if_index),
13625 ntohl (mp->instance),
13626 format_ip46_address, &src, IP46_TYPE_ANY,
13627 format_ip46_address, &dst, IP46_TYPE_ANY,
13628 mp->tunnel_type, ntohl (mp->outer_fib_id), ntohl (mp->session_id));
13631 static void vl_api_gre_tunnel_details_t_handler_json
13632 (vl_api_gre_tunnel_details_t * mp)
13634 vat_main_t *vam = &vat_main;
13635 vat_json_node_t *node = NULL;
13636 struct in_addr ip4;
13637 struct in6_addr ip6;
13639 if (VAT_JSON_ARRAY != vam->json_tree.type)
13641 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13642 vat_json_init_array (&vam->json_tree);
13644 node = vat_json_array_add (&vam->json_tree);
13646 vat_json_init_object (node);
13647 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13648 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13651 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
13652 vat_json_object_add_ip4 (node, "src_address", ip4);
13653 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
13654 vat_json_object_add_ip4 (node, "dst_address", ip4);
13658 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
13659 vat_json_object_add_ip6 (node, "src_address", ip6);
13660 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
13661 vat_json_object_add_ip6 (node, "dst_address", ip6);
13663 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel_type);
13664 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
13665 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
13666 vat_json_object_add_uint (node, "session_id", mp->session_id);
13670 api_gre_tunnel_dump (vat_main_t * vam)
13672 unformat_input_t *i = vam->input;
13673 vl_api_gre_tunnel_dump_t *mp;
13674 vl_api_control_ping_t *mp_ping;
13676 u8 sw_if_index_set = 0;
13679 /* Parse args required to build the message */
13680 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13682 if (unformat (i, "sw_if_index %d", &sw_if_index))
13683 sw_if_index_set = 1;
13688 if (sw_if_index_set == 0)
13693 if (!vam->json_output)
13695 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
13696 "sw_if_index", "instance", "src_address", "dst_address",
13697 "tunnel_type", "outer_fib_id", "session_id");
13700 /* Get list of gre-tunnel interfaces */
13701 M (GRE_TUNNEL_DUMP, mp);
13703 mp->sw_if_index = htonl (sw_if_index);
13707 /* Use a control ping for synchronization */
13708 MPING (CONTROL_PING, mp_ping);
13716 api_l2_fib_clear_table (vat_main_t * vam)
13718 // unformat_input_t * i = vam->input;
13719 vl_api_l2_fib_clear_table_t *mp;
13722 M (L2_FIB_CLEAR_TABLE, mp);
13730 api_l2_interface_efp_filter (vat_main_t * vam)
13732 unformat_input_t *i = vam->input;
13733 vl_api_l2_interface_efp_filter_t *mp;
13736 u8 sw_if_index_set = 0;
13739 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13741 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13742 sw_if_index_set = 1;
13743 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13744 sw_if_index_set = 1;
13745 else if (unformat (i, "enable"))
13747 else if (unformat (i, "disable"))
13751 clib_warning ("parse error '%U'", format_unformat_error, i);
13756 if (sw_if_index_set == 0)
13758 errmsg ("missing sw_if_index");
13762 M (L2_INTERFACE_EFP_FILTER, mp);
13764 mp->sw_if_index = ntohl (sw_if_index);
13765 mp->enable_disable = enable;
13772 #define foreach_vtr_op \
13773 _("disable", L2_VTR_DISABLED) \
13774 _("push-1", L2_VTR_PUSH_1) \
13775 _("push-2", L2_VTR_PUSH_2) \
13776 _("pop-1", L2_VTR_POP_1) \
13777 _("pop-2", L2_VTR_POP_2) \
13778 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
13779 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
13780 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
13781 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
13784 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
13786 unformat_input_t *i = vam->input;
13787 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
13789 u8 sw_if_index_set = 0;
13792 u32 push_dot1q = 1;
13797 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13799 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13800 sw_if_index_set = 1;
13801 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13802 sw_if_index_set = 1;
13803 else if (unformat (i, "vtr_op %d", &vtr_op))
13805 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
13808 else if (unformat (i, "push_dot1q %d", &push_dot1q))
13810 else if (unformat (i, "tag1 %d", &tag1))
13812 else if (unformat (i, "tag2 %d", &tag2))
13816 clib_warning ("parse error '%U'", format_unformat_error, i);
13821 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
13823 errmsg ("missing vtr operation or sw_if_index");
13827 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
13828 mp->sw_if_index = ntohl (sw_if_index);
13829 mp->vtr_op = ntohl (vtr_op);
13830 mp->push_dot1q = ntohl (push_dot1q);
13831 mp->tag1 = ntohl (tag1);
13832 mp->tag2 = ntohl (tag2);
13840 api_create_vhost_user_if (vat_main_t * vam)
13842 unformat_input_t *i = vam->input;
13843 vl_api_create_vhost_user_if_t *mp;
13846 u8 file_name_set = 0;
13847 u32 custom_dev_instance = ~0;
13849 u8 use_custom_mac = 0;
13853 /* Shut up coverity */
13854 memset (hwaddr, 0, sizeof (hwaddr));
13856 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13858 if (unformat (i, "socket %s", &file_name))
13862 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13864 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
13865 use_custom_mac = 1;
13866 else if (unformat (i, "server"))
13868 else if (unformat (i, "tag %s", &tag))
13874 if (file_name_set == 0)
13876 errmsg ("missing socket file name");
13880 if (vec_len (file_name) > 255)
13882 errmsg ("socket file name too long");
13885 vec_add1 (file_name, 0);
13887 M (CREATE_VHOST_USER_IF, mp);
13889 mp->is_server = is_server;
13890 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13891 vec_free (file_name);
13892 if (custom_dev_instance != ~0)
13895 mp->custom_dev_instance = ntohl (custom_dev_instance);
13897 mp->use_custom_mac = use_custom_mac;
13898 clib_memcpy (mp->mac_address, hwaddr, 6);
13900 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
13909 api_modify_vhost_user_if (vat_main_t * vam)
13911 unformat_input_t *i = vam->input;
13912 vl_api_modify_vhost_user_if_t *mp;
13915 u8 file_name_set = 0;
13916 u32 custom_dev_instance = ~0;
13917 u8 sw_if_index_set = 0;
13918 u32 sw_if_index = (u32) ~ 0;
13921 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13923 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13924 sw_if_index_set = 1;
13925 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13926 sw_if_index_set = 1;
13927 else if (unformat (i, "socket %s", &file_name))
13931 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13933 else if (unformat (i, "server"))
13939 if (sw_if_index_set == 0)
13941 errmsg ("missing sw_if_index or interface name");
13945 if (file_name_set == 0)
13947 errmsg ("missing socket file name");
13951 if (vec_len (file_name) > 255)
13953 errmsg ("socket file name too long");
13956 vec_add1 (file_name, 0);
13958 M (MODIFY_VHOST_USER_IF, mp);
13960 mp->sw_if_index = ntohl (sw_if_index);
13961 mp->is_server = is_server;
13962 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13963 vec_free (file_name);
13964 if (custom_dev_instance != ~0)
13967 mp->custom_dev_instance = ntohl (custom_dev_instance);
13976 api_delete_vhost_user_if (vat_main_t * vam)
13978 unformat_input_t *i = vam->input;
13979 vl_api_delete_vhost_user_if_t *mp;
13980 u32 sw_if_index = ~0;
13981 u8 sw_if_index_set = 0;
13984 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13986 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13987 sw_if_index_set = 1;
13988 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13989 sw_if_index_set = 1;
13994 if (sw_if_index_set == 0)
13996 errmsg ("missing sw_if_index or interface name");
14001 M (DELETE_VHOST_USER_IF, mp);
14003 mp->sw_if_index = ntohl (sw_if_index);
14010 static void vl_api_sw_interface_vhost_user_details_t_handler
14011 (vl_api_sw_interface_vhost_user_details_t * mp)
14013 vat_main_t *vam = &vat_main;
14015 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
14016 (char *) mp->interface_name,
14017 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
14018 clib_net_to_host_u64 (mp->features), mp->is_server,
14019 ntohl (mp->num_regions), (char *) mp->sock_filename);
14020 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
14023 static void vl_api_sw_interface_vhost_user_details_t_handler_json
14024 (vl_api_sw_interface_vhost_user_details_t * mp)
14026 vat_main_t *vam = &vat_main;
14027 vat_json_node_t *node = NULL;
14029 if (VAT_JSON_ARRAY != vam->json_tree.type)
14031 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14032 vat_json_init_array (&vam->json_tree);
14034 node = vat_json_array_add (&vam->json_tree);
14036 vat_json_init_object (node);
14037 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14038 vat_json_object_add_string_copy (node, "interface_name",
14039 mp->interface_name);
14040 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
14041 ntohl (mp->virtio_net_hdr_sz));
14042 vat_json_object_add_uint (node, "features",
14043 clib_net_to_host_u64 (mp->features));
14044 vat_json_object_add_uint (node, "is_server", mp->is_server);
14045 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
14046 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
14047 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
14051 api_sw_interface_vhost_user_dump (vat_main_t * vam)
14053 vl_api_sw_interface_vhost_user_dump_t *mp;
14054 vl_api_control_ping_t *mp_ping;
14057 "Interface name idx hdr_sz features server regions filename");
14059 /* Get list of vhost-user interfaces */
14060 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
14063 /* Use a control ping for synchronization */
14064 MPING (CONTROL_PING, mp_ping);
14072 api_show_version (vat_main_t * vam)
14074 vl_api_show_version_t *mp;
14077 M (SHOW_VERSION, mp);
14086 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
14088 unformat_input_t *line_input = vam->input;
14089 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
14090 ip4_address_t local4, remote4;
14091 ip6_address_t local6, remote6;
14093 u8 ipv4_set = 0, ipv6_set = 0;
14097 u32 mcast_sw_if_index = ~0;
14098 u32 encap_vrf_id = 0;
14099 u32 decap_vrf_id = 0;
14105 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
14106 memset (&local4, 0, sizeof local4);
14107 memset (&remote4, 0, sizeof remote4);
14108 memset (&local6, 0, sizeof local6);
14109 memset (&remote6, 0, sizeof remote6);
14111 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14113 if (unformat (line_input, "del"))
14115 else if (unformat (line_input, "local %U",
14116 unformat_ip4_address, &local4))
14121 else if (unformat (line_input, "remote %U",
14122 unformat_ip4_address, &remote4))
14127 else if (unformat (line_input, "local %U",
14128 unformat_ip6_address, &local6))
14133 else if (unformat (line_input, "remote %U",
14134 unformat_ip6_address, &remote6))
14139 else if (unformat (line_input, "group %U %U",
14140 unformat_ip4_address, &remote4,
14141 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14143 grp_set = remote_set = 1;
14146 else if (unformat (line_input, "group %U",
14147 unformat_ip4_address, &remote4))
14149 grp_set = remote_set = 1;
14152 else if (unformat (line_input, "group %U %U",
14153 unformat_ip6_address, &remote6,
14154 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14156 grp_set = remote_set = 1;
14159 else if (unformat (line_input, "group %U",
14160 unformat_ip6_address, &remote6))
14162 grp_set = remote_set = 1;
14166 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
14168 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
14170 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
14172 else if (unformat (line_input, "vni %d", &vni))
14174 else if (unformat (line_input, "next-ip4"))
14176 else if (unformat (line_input, "next-ip6"))
14178 else if (unformat (line_input, "next-ethernet"))
14180 else if (unformat (line_input, "next-nsh"))
14184 errmsg ("parse error '%U'", format_unformat_error, line_input);
14189 if (local_set == 0)
14191 errmsg ("tunnel local address not specified");
14194 if (remote_set == 0)
14196 errmsg ("tunnel remote address not specified");
14199 if (grp_set && mcast_sw_if_index == ~0)
14201 errmsg ("tunnel nonexistent multicast device");
14204 if (ipv4_set && ipv6_set)
14206 errmsg ("both IPv4 and IPv6 addresses specified");
14212 errmsg ("vni not specified");
14216 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
14221 clib_memcpy (&mp->local, &local6, sizeof (local6));
14222 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
14226 clib_memcpy (&mp->local, &local4, sizeof (local4));
14227 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
14230 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
14231 mp->encap_vrf_id = ntohl (encap_vrf_id);
14232 mp->decap_vrf_id = ntohl (decap_vrf_id);
14233 mp->protocol = protocol;
14234 mp->vni = ntohl (vni);
14235 mp->is_add = is_add;
14236 mp->is_ipv6 = ipv6_set;
14243 static void vl_api_vxlan_gpe_tunnel_details_t_handler
14244 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14246 vat_main_t *vam = &vat_main;
14247 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
14248 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
14250 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
14251 ntohl (mp->sw_if_index),
14252 format_ip46_address, &local, IP46_TYPE_ANY,
14253 format_ip46_address, &remote, IP46_TYPE_ANY,
14254 ntohl (mp->vni), mp->protocol,
14255 ntohl (mp->mcast_sw_if_index),
14256 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
14260 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
14261 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14263 vat_main_t *vam = &vat_main;
14264 vat_json_node_t *node = NULL;
14265 struct in_addr ip4;
14266 struct in6_addr ip6;
14268 if (VAT_JSON_ARRAY != vam->json_tree.type)
14270 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14271 vat_json_init_array (&vam->json_tree);
14273 node = vat_json_array_add (&vam->json_tree);
14275 vat_json_init_object (node);
14276 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14279 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
14280 vat_json_object_add_ip6 (node, "local", ip6);
14281 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
14282 vat_json_object_add_ip6 (node, "remote", ip6);
14286 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
14287 vat_json_object_add_ip4 (node, "local", ip4);
14288 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
14289 vat_json_object_add_ip4 (node, "remote", ip4);
14291 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
14292 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
14293 vat_json_object_add_uint (node, "mcast_sw_if_index",
14294 ntohl (mp->mcast_sw_if_index));
14295 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
14296 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
14297 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
14301 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
14303 unformat_input_t *i = vam->input;
14304 vl_api_vxlan_gpe_tunnel_dump_t *mp;
14305 vl_api_control_ping_t *mp_ping;
14307 u8 sw_if_index_set = 0;
14310 /* Parse args required to build the message */
14311 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14313 if (unformat (i, "sw_if_index %d", &sw_if_index))
14314 sw_if_index_set = 1;
14319 if (sw_if_index_set == 0)
14324 if (!vam->json_output)
14326 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
14327 "sw_if_index", "local", "remote", "vni",
14328 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
14331 /* Get list of vxlan-tunnel interfaces */
14332 M (VXLAN_GPE_TUNNEL_DUMP, mp);
14334 mp->sw_if_index = htonl (sw_if_index);
14338 /* Use a control ping for synchronization */
14339 MPING (CONTROL_PING, mp_ping);
14346 static void vl_api_l2_fib_table_details_t_handler
14347 (vl_api_l2_fib_table_details_t * mp)
14349 vat_main_t *vam = &vat_main;
14351 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
14353 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
14354 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
14358 static void vl_api_l2_fib_table_details_t_handler_json
14359 (vl_api_l2_fib_table_details_t * mp)
14361 vat_main_t *vam = &vat_main;
14362 vat_json_node_t *node = NULL;
14364 if (VAT_JSON_ARRAY != vam->json_tree.type)
14366 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14367 vat_json_init_array (&vam->json_tree);
14369 node = vat_json_array_add (&vam->json_tree);
14371 vat_json_init_object (node);
14372 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
14373 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
14374 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14375 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
14376 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
14377 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
14381 api_l2_fib_table_dump (vat_main_t * vam)
14383 unformat_input_t *i = vam->input;
14384 vl_api_l2_fib_table_dump_t *mp;
14385 vl_api_control_ping_t *mp_ping;
14390 /* Parse args required to build the message */
14391 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14393 if (unformat (i, "bd_id %d", &bd_id))
14399 if (bd_id_set == 0)
14401 errmsg ("missing bridge domain");
14405 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
14407 /* Get list of l2 fib entries */
14408 M (L2_FIB_TABLE_DUMP, mp);
14410 mp->bd_id = ntohl (bd_id);
14413 /* Use a control ping for synchronization */
14414 MPING (CONTROL_PING, mp_ping);
14423 api_interface_name_renumber (vat_main_t * vam)
14425 unformat_input_t *line_input = vam->input;
14426 vl_api_interface_name_renumber_t *mp;
14427 u32 sw_if_index = ~0;
14428 u32 new_show_dev_instance = ~0;
14431 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14433 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
14436 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14438 else if (unformat (line_input, "new_show_dev_instance %d",
14439 &new_show_dev_instance))
14445 if (sw_if_index == ~0)
14447 errmsg ("missing interface name or sw_if_index");
14451 if (new_show_dev_instance == ~0)
14453 errmsg ("missing new_show_dev_instance");
14457 M (INTERFACE_NAME_RENUMBER, mp);
14459 mp->sw_if_index = ntohl (sw_if_index);
14460 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
14468 api_ip_probe_neighbor (vat_main_t * vam)
14470 unformat_input_t *i = vam->input;
14471 vl_api_ip_probe_neighbor_t *mp;
14479 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14481 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14483 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14485 else if (unformat (i, "address %U", unformat_ip4_address, dst_adr))
14487 else if (unformat (i, "address %U", unformat_ip6_address, dst_adr))
14498 errmsg ("missing interface");
14504 errmsg ("missing addresses");
14508 M (IP_PROBE_NEIGHBOR, mp);
14510 mp->sw_if_index = ntohl (sw_if_index);
14511 mp->is_ipv6 = is_ipv6;
14512 clib_memcpy (mp->dst_address, dst_adr, sizeof (dst_adr));
14520 api_want_ip4_arp_events (vat_main_t * vam)
14522 unformat_input_t *line_input = vam->input;
14523 vl_api_want_ip4_arp_events_t *mp;
14524 ip4_address_t address;
14525 int address_set = 0;
14526 u32 enable_disable = 1;
14529 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14531 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
14533 else if (unformat (line_input, "del"))
14534 enable_disable = 0;
14539 if (address_set == 0)
14541 errmsg ("missing addresses");
14545 M (WANT_IP4_ARP_EVENTS, mp);
14546 mp->enable_disable = enable_disable;
14547 mp->pid = htonl (getpid ());
14548 mp->address = address.as_u32;
14556 api_want_ip6_nd_events (vat_main_t * vam)
14558 unformat_input_t *line_input = vam->input;
14559 vl_api_want_ip6_nd_events_t *mp;
14560 ip6_address_t address;
14561 int address_set = 0;
14562 u32 enable_disable = 1;
14565 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14567 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
14569 else if (unformat (line_input, "del"))
14570 enable_disable = 0;
14575 if (address_set == 0)
14577 errmsg ("missing addresses");
14581 M (WANT_IP6_ND_EVENTS, mp);
14582 mp->enable_disable = enable_disable;
14583 mp->pid = htonl (getpid ());
14584 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
14592 api_want_l2_macs_events (vat_main_t * vam)
14594 unformat_input_t *line_input = vam->input;
14595 vl_api_want_l2_macs_events_t *mp;
14596 u8 enable_disable = 1;
14597 u32 scan_delay = 0;
14598 u32 max_macs_in_event = 0;
14599 u32 learn_limit = 0;
14602 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14604 if (unformat (line_input, "learn-limit %d", &learn_limit))
14606 else if (unformat (line_input, "scan-delay %d", &scan_delay))
14608 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
14610 else if (unformat (line_input, "disable"))
14611 enable_disable = 0;
14616 M (WANT_L2_MACS_EVENTS, mp);
14617 mp->enable_disable = enable_disable;
14618 mp->pid = htonl (getpid ());
14619 mp->learn_limit = htonl (learn_limit);
14620 mp->scan_delay = (u8) scan_delay;
14621 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
14628 api_input_acl_set_interface (vat_main_t * vam)
14630 unformat_input_t *i = vam->input;
14631 vl_api_input_acl_set_interface_t *mp;
14633 int sw_if_index_set;
14634 u32 ip4_table_index = ~0;
14635 u32 ip6_table_index = ~0;
14636 u32 l2_table_index = ~0;
14640 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14642 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14643 sw_if_index_set = 1;
14644 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14645 sw_if_index_set = 1;
14646 else if (unformat (i, "del"))
14648 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14650 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14652 else if (unformat (i, "l2-table %d", &l2_table_index))
14656 clib_warning ("parse error '%U'", format_unformat_error, i);
14661 if (sw_if_index_set == 0)
14663 errmsg ("missing interface name or sw_if_index");
14667 M (INPUT_ACL_SET_INTERFACE, mp);
14669 mp->sw_if_index = ntohl (sw_if_index);
14670 mp->ip4_table_index = ntohl (ip4_table_index);
14671 mp->ip6_table_index = ntohl (ip6_table_index);
14672 mp->l2_table_index = ntohl (l2_table_index);
14673 mp->is_add = is_add;
14681 api_output_acl_set_interface (vat_main_t * vam)
14683 unformat_input_t *i = vam->input;
14684 vl_api_output_acl_set_interface_t *mp;
14686 int sw_if_index_set;
14687 u32 ip4_table_index = ~0;
14688 u32 ip6_table_index = ~0;
14689 u32 l2_table_index = ~0;
14693 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14695 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14696 sw_if_index_set = 1;
14697 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14698 sw_if_index_set = 1;
14699 else if (unformat (i, "del"))
14701 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14703 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14705 else if (unformat (i, "l2-table %d", &l2_table_index))
14709 clib_warning ("parse error '%U'", format_unformat_error, i);
14714 if (sw_if_index_set == 0)
14716 errmsg ("missing interface name or sw_if_index");
14720 M (OUTPUT_ACL_SET_INTERFACE, mp);
14722 mp->sw_if_index = ntohl (sw_if_index);
14723 mp->ip4_table_index = ntohl (ip4_table_index);
14724 mp->ip6_table_index = ntohl (ip6_table_index);
14725 mp->l2_table_index = ntohl (l2_table_index);
14726 mp->is_add = is_add;
14734 api_ip_address_dump (vat_main_t * vam)
14736 unformat_input_t *i = vam->input;
14737 vl_api_ip_address_dump_t *mp;
14738 vl_api_control_ping_t *mp_ping;
14739 u32 sw_if_index = ~0;
14740 u8 sw_if_index_set = 0;
14745 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14747 if (unformat (i, "sw_if_index %d", &sw_if_index))
14748 sw_if_index_set = 1;
14750 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14751 sw_if_index_set = 1;
14752 else if (unformat (i, "ipv4"))
14754 else if (unformat (i, "ipv6"))
14760 if (ipv4_set && ipv6_set)
14762 errmsg ("ipv4 and ipv6 flags cannot be both set");
14766 if ((!ipv4_set) && (!ipv6_set))
14768 errmsg ("no ipv4 nor ipv6 flag set");
14772 if (sw_if_index_set == 0)
14774 errmsg ("missing interface name or sw_if_index");
14778 vam->current_sw_if_index = sw_if_index;
14779 vam->is_ipv6 = ipv6_set;
14781 M (IP_ADDRESS_DUMP, mp);
14782 mp->sw_if_index = ntohl (sw_if_index);
14783 mp->is_ipv6 = ipv6_set;
14786 /* Use a control ping for synchronization */
14787 MPING (CONTROL_PING, mp_ping);
14795 api_ip_dump (vat_main_t * vam)
14797 vl_api_ip_dump_t *mp;
14798 vl_api_control_ping_t *mp_ping;
14799 unformat_input_t *in = vam->input;
14806 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
14808 if (unformat (in, "ipv4"))
14810 else if (unformat (in, "ipv6"))
14816 if (ipv4_set && ipv6_set)
14818 errmsg ("ipv4 and ipv6 flags cannot be both set");
14822 if ((!ipv4_set) && (!ipv6_set))
14824 errmsg ("no ipv4 nor ipv6 flag set");
14828 is_ipv6 = ipv6_set;
14829 vam->is_ipv6 = is_ipv6;
14831 /* free old data */
14832 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
14834 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
14836 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
14839 mp->is_ipv6 = ipv6_set;
14842 /* Use a control ping for synchronization */
14843 MPING (CONTROL_PING, mp_ping);
14851 api_ipsec_spd_add_del (vat_main_t * vam)
14853 unformat_input_t *i = vam->input;
14854 vl_api_ipsec_spd_add_del_t *mp;
14859 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14861 if (unformat (i, "spd_id %d", &spd_id))
14863 else if (unformat (i, "del"))
14867 clib_warning ("parse error '%U'", format_unformat_error, i);
14873 errmsg ("spd_id must be set");
14877 M (IPSEC_SPD_ADD_DEL, mp);
14879 mp->spd_id = ntohl (spd_id);
14880 mp->is_add = is_add;
14888 api_ipsec_interface_add_del_spd (vat_main_t * vam)
14890 unformat_input_t *i = vam->input;
14891 vl_api_ipsec_interface_add_del_spd_t *mp;
14893 u8 sw_if_index_set = 0;
14894 u32 spd_id = (u32) ~ 0;
14898 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14900 if (unformat (i, "del"))
14902 else if (unformat (i, "spd_id %d", &spd_id))
14905 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14906 sw_if_index_set = 1;
14907 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14908 sw_if_index_set = 1;
14911 clib_warning ("parse error '%U'", format_unformat_error, i);
14917 if (spd_id == (u32) ~ 0)
14919 errmsg ("spd_id must be set");
14923 if (sw_if_index_set == 0)
14925 errmsg ("missing interface name or sw_if_index");
14929 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
14931 mp->spd_id = ntohl (spd_id);
14932 mp->sw_if_index = ntohl (sw_if_index);
14933 mp->is_add = is_add;
14941 api_ipsec_spd_add_del_entry (vat_main_t * vam)
14943 unformat_input_t *i = vam->input;
14944 vl_api_ipsec_spd_add_del_entry_t *mp;
14945 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
14946 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
14948 u32 rport_start = 0, rport_stop = (u32) ~ 0;
14949 u32 lport_start = 0, lport_stop = (u32) ~ 0;
14950 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
14951 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
14954 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
14955 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
14956 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
14957 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
14958 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
14959 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
14961 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14963 if (unformat (i, "del"))
14965 if (unformat (i, "outbound"))
14967 if (unformat (i, "inbound"))
14969 else if (unformat (i, "spd_id %d", &spd_id))
14971 else if (unformat (i, "sa_id %d", &sa_id))
14973 else if (unformat (i, "priority %d", &priority))
14975 else if (unformat (i, "protocol %d", &protocol))
14977 else if (unformat (i, "lport_start %d", &lport_start))
14979 else if (unformat (i, "lport_stop %d", &lport_stop))
14981 else if (unformat (i, "rport_start %d", &rport_start))
14983 else if (unformat (i, "rport_stop %d", &rport_stop))
14987 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
14993 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
15000 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
15006 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
15013 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
15019 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
15026 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
15032 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
15038 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
15040 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
15042 clib_warning ("unsupported action: 'resolve'");
15048 clib_warning ("parse error '%U'", format_unformat_error, i);
15054 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
15056 mp->spd_id = ntohl (spd_id);
15057 mp->priority = ntohl (priority);
15058 mp->is_outbound = is_outbound;
15060 mp->is_ipv6 = is_ipv6;
15061 if (is_ipv6 || is_ip_any)
15063 clib_memcpy (mp->remote_address_start, &raddr6_start,
15064 sizeof (ip6_address_t));
15065 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
15066 sizeof (ip6_address_t));
15067 clib_memcpy (mp->local_address_start, &laddr6_start,
15068 sizeof (ip6_address_t));
15069 clib_memcpy (mp->local_address_stop, &laddr6_stop,
15070 sizeof (ip6_address_t));
15074 clib_memcpy (mp->remote_address_start, &raddr4_start,
15075 sizeof (ip4_address_t));
15076 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
15077 sizeof (ip4_address_t));
15078 clib_memcpy (mp->local_address_start, &laddr4_start,
15079 sizeof (ip4_address_t));
15080 clib_memcpy (mp->local_address_stop, &laddr4_stop,
15081 sizeof (ip4_address_t));
15083 mp->protocol = (u8) protocol;
15084 mp->local_port_start = ntohs ((u16) lport_start);
15085 mp->local_port_stop = ntohs ((u16) lport_stop);
15086 mp->remote_port_start = ntohs ((u16) rport_start);
15087 mp->remote_port_stop = ntohs ((u16) rport_stop);
15088 mp->policy = (u8) policy;
15089 mp->sa_id = ntohl (sa_id);
15090 mp->is_add = is_add;
15091 mp->is_ip_any = is_ip_any;
15098 api_ipsec_sad_add_del_entry (vat_main_t * vam)
15100 unformat_input_t *i = vam->input;
15101 vl_api_ipsec_sad_add_del_entry_t *mp;
15102 u32 sad_id = 0, spi = 0;
15103 u8 *ck = 0, *ik = 0;
15106 u8 protocol = IPSEC_PROTOCOL_AH;
15107 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
15108 u32 crypto_alg = 0, integ_alg = 0;
15109 ip4_address_t tun_src4;
15110 ip4_address_t tun_dst4;
15111 ip6_address_t tun_src6;
15112 ip6_address_t tun_dst6;
15115 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15117 if (unformat (i, "del"))
15119 else if (unformat (i, "sad_id %d", &sad_id))
15121 else if (unformat (i, "spi %d", &spi))
15123 else if (unformat (i, "esp"))
15124 protocol = IPSEC_PROTOCOL_ESP;
15125 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
15128 is_tunnel_ipv6 = 0;
15130 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
15133 is_tunnel_ipv6 = 0;
15135 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
15138 is_tunnel_ipv6 = 1;
15140 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
15143 is_tunnel_ipv6 = 1;
15147 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15149 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
15150 crypto_alg >= IPSEC_CRYPTO_N_ALG)
15152 clib_warning ("unsupported crypto-alg: '%U'",
15153 format_ipsec_crypto_alg, crypto_alg);
15157 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15161 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15163 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
15164 integ_alg >= IPSEC_INTEG_N_ALG)
15166 clib_warning ("unsupported integ-alg: '%U'",
15167 format_ipsec_integ_alg, integ_alg);
15171 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15175 clib_warning ("parse error '%U'", format_unformat_error, i);
15181 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
15183 mp->sad_id = ntohl (sad_id);
15184 mp->is_add = is_add;
15185 mp->protocol = protocol;
15186 mp->spi = ntohl (spi);
15187 mp->is_tunnel = is_tunnel;
15188 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
15189 mp->crypto_algorithm = crypto_alg;
15190 mp->integrity_algorithm = integ_alg;
15191 mp->crypto_key_length = vec_len (ck);
15192 mp->integrity_key_length = vec_len (ik);
15194 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15195 mp->crypto_key_length = sizeof (mp->crypto_key);
15197 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15198 mp->integrity_key_length = sizeof (mp->integrity_key);
15201 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15203 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15207 if (is_tunnel_ipv6)
15209 clib_memcpy (mp->tunnel_src_address, &tun_src6,
15210 sizeof (ip6_address_t));
15211 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
15212 sizeof (ip6_address_t));
15216 clib_memcpy (mp->tunnel_src_address, &tun_src4,
15217 sizeof (ip4_address_t));
15218 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
15219 sizeof (ip4_address_t));
15229 api_ipsec_sa_set_key (vat_main_t * vam)
15231 unformat_input_t *i = vam->input;
15232 vl_api_ipsec_sa_set_key_t *mp;
15234 u8 *ck = 0, *ik = 0;
15237 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15239 if (unformat (i, "sa_id %d", &sa_id))
15241 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15243 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15247 clib_warning ("parse error '%U'", format_unformat_error, i);
15252 M (IPSEC_SA_SET_KEY, mp);
15254 mp->sa_id = ntohl (sa_id);
15255 mp->crypto_key_length = vec_len (ck);
15256 mp->integrity_key_length = vec_len (ik);
15258 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15259 mp->crypto_key_length = sizeof (mp->crypto_key);
15261 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15262 mp->integrity_key_length = sizeof (mp->integrity_key);
15265 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15267 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15275 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
15277 unformat_input_t *i = vam->input;
15278 vl_api_ipsec_tunnel_if_add_del_t *mp;
15279 u32 local_spi = 0, remote_spi = 0;
15280 u32 crypto_alg = 0, integ_alg = 0;
15281 u8 *lck = NULL, *rck = NULL;
15282 u8 *lik = NULL, *rik = NULL;
15283 ip4_address_t local_ip = { {0} };
15284 ip4_address_t remote_ip = { {0} };
15287 u8 anti_replay = 0;
15292 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15294 if (unformat (i, "del"))
15296 else if (unformat (i, "esn"))
15298 else if (unformat (i, "anti_replay"))
15300 else if (unformat (i, "local_spi %d", &local_spi))
15302 else if (unformat (i, "remote_spi %d", &remote_spi))
15304 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
15306 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
15308 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
15311 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
15313 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
15315 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
15319 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15321 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
15322 crypto_alg >= IPSEC_CRYPTO_N_ALG)
15324 errmsg ("unsupported crypto-alg: '%U'\n",
15325 format_ipsec_crypto_alg, crypto_alg);
15331 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15333 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
15334 integ_alg >= IPSEC_INTEG_N_ALG)
15336 errmsg ("unsupported integ-alg: '%U'\n",
15337 format_ipsec_integ_alg, integ_alg);
15341 else if (unformat (i, "instance %u", &instance))
15345 errmsg ("parse error '%U'\n", format_unformat_error, i);
15350 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
15352 mp->is_add = is_add;
15354 mp->anti_replay = anti_replay;
15356 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
15357 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
15359 mp->local_spi = htonl (local_spi);
15360 mp->remote_spi = htonl (remote_spi);
15361 mp->crypto_alg = (u8) crypto_alg;
15363 mp->local_crypto_key_len = 0;
15366 mp->local_crypto_key_len = vec_len (lck);
15367 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
15368 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
15369 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
15372 mp->remote_crypto_key_len = 0;
15375 mp->remote_crypto_key_len = vec_len (rck);
15376 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
15377 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
15378 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
15381 mp->integ_alg = (u8) integ_alg;
15383 mp->local_integ_key_len = 0;
15386 mp->local_integ_key_len = vec_len (lik);
15387 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
15388 mp->local_integ_key_len = sizeof (mp->local_integ_key);
15389 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
15392 mp->remote_integ_key_len = 0;
15395 mp->remote_integ_key_len = vec_len (rik);
15396 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
15397 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
15398 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
15403 mp->renumber = renumber;
15404 mp->show_instance = ntohl (instance);
15413 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
15415 vat_main_t *vam = &vat_main;
15417 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
15418 "crypto_key %U integ_alg %u integ_key %U use_esn %u "
15419 "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u "
15420 "tunnel_src_addr %U tunnel_dst_addr %U "
15421 "salt %u seq_outbound %lu last_seq_inbound %lu "
15422 "replay_window %lu total_data_size %lu\n",
15423 ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi),
15425 mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len,
15426 mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len,
15427 mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6,
15428 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15429 mp->tunnel_src_addr,
15430 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15431 mp->tunnel_dst_addr,
15433 clib_net_to_host_u64 (mp->seq_outbound),
15434 clib_net_to_host_u64 (mp->last_seq_inbound),
15435 clib_net_to_host_u64 (mp->replay_window),
15436 clib_net_to_host_u64 (mp->total_data_size));
15439 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
15440 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
15442 static void vl_api_ipsec_sa_details_t_handler_json
15443 (vl_api_ipsec_sa_details_t * mp)
15445 vat_main_t *vam = &vat_main;
15446 vat_json_node_t *node = NULL;
15447 struct in_addr src_ip4, dst_ip4;
15448 struct in6_addr src_ip6, dst_ip6;
15450 if (VAT_JSON_ARRAY != vam->json_tree.type)
15452 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15453 vat_json_init_array (&vam->json_tree);
15455 node = vat_json_array_add (&vam->json_tree);
15457 vat_json_init_object (node);
15458 vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id));
15459 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
15460 vat_json_object_add_uint (node, "spi", ntohl (mp->spi));
15461 vat_json_object_add_uint (node, "proto", mp->protocol);
15462 vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg);
15463 vat_json_object_add_uint (node, "integ_alg", mp->integ_alg);
15464 vat_json_object_add_uint (node, "use_esn", mp->use_esn);
15465 vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay);
15466 vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel);
15467 vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6);
15468 vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key,
15469 mp->crypto_key_len);
15470 vat_json_object_add_bytes (node, "integ_key", mp->integ_key,
15471 mp->integ_key_len);
15472 if (mp->is_tunnel_ip6)
15474 clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6));
15475 vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6);
15476 clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6));
15477 vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6);
15481 clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4));
15482 vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4);
15483 clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4));
15484 vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4);
15486 vat_json_object_add_uint (node, "replay_window",
15487 clib_net_to_host_u64 (mp->replay_window));
15488 vat_json_object_add_uint (node, "total_data_size",
15489 clib_net_to_host_u64 (mp->total_data_size));
15494 api_ipsec_sa_dump (vat_main_t * vam)
15496 unformat_input_t *i = vam->input;
15497 vl_api_ipsec_sa_dump_t *mp;
15498 vl_api_control_ping_t *mp_ping;
15502 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15504 if (unformat (i, "sa_id %d", &sa_id))
15508 clib_warning ("parse error '%U'", format_unformat_error, i);
15513 M (IPSEC_SA_DUMP, mp);
15515 mp->sa_id = ntohl (sa_id);
15519 /* Use a control ping for synchronization */
15520 M (CONTROL_PING, mp_ping);
15528 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
15530 unformat_input_t *i = vam->input;
15531 vl_api_ipsec_tunnel_if_set_key_t *mp;
15532 u32 sw_if_index = ~0;
15533 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
15538 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15540 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15543 if (unformat (i, "local crypto %U", unformat_ipsec_crypto_alg, &alg))
15544 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
15546 if (unformat (i, "remote crypto %U", unformat_ipsec_crypto_alg, &alg))
15547 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
15548 else if (unformat (i, "local integ %U", unformat_ipsec_integ_alg, &alg))
15549 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
15551 if (unformat (i, "remote integ %U", unformat_ipsec_integ_alg, &alg))
15552 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
15553 else if (unformat (i, "%U", unformat_hex_string, &key))
15557 clib_warning ("parse error '%U'", format_unformat_error, i);
15562 if (sw_if_index == ~0)
15564 errmsg ("interface must be specified");
15568 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
15570 errmsg ("key type must be specified");
15576 errmsg ("algorithm must be specified");
15580 if (vec_len (key) == 0)
15582 errmsg ("key must be specified");
15586 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
15588 mp->sw_if_index = htonl (sw_if_index);
15590 mp->key_type = key_type;
15591 mp->key_len = vec_len (key);
15592 clib_memcpy (mp->key, key, vec_len (key));
15601 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
15603 unformat_input_t *i = vam->input;
15604 vl_api_ipsec_tunnel_if_set_sa_t *mp;
15605 u32 sw_if_index = ~0;
15607 u8 is_outbound = (u8) ~ 0;
15610 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15612 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15614 else if (unformat (i, "sa_id %d", &sa_id))
15616 else if (unformat (i, "outbound"))
15618 else if (unformat (i, "inbound"))
15622 clib_warning ("parse error '%U'", format_unformat_error, i);
15627 if (sw_if_index == ~0)
15629 errmsg ("interface must be specified");
15635 errmsg ("SA ID must be specified");
15639 M (IPSEC_TUNNEL_IF_SET_SA, mp);
15641 mp->sw_if_index = htonl (sw_if_index);
15642 mp->sa_id = htonl (sa_id);
15643 mp->is_outbound = is_outbound;
15652 api_ikev2_profile_add_del (vat_main_t * vam)
15654 unformat_input_t *i = vam->input;
15655 vl_api_ikev2_profile_add_del_t *mp;
15660 const char *valid_chars = "a-zA-Z0-9_";
15662 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15664 if (unformat (i, "del"))
15666 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15667 vec_add1 (name, 0);
15670 errmsg ("parse error '%U'", format_unformat_error, i);
15675 if (!vec_len (name))
15677 errmsg ("profile name must be specified");
15681 if (vec_len (name) > 64)
15683 errmsg ("profile name too long");
15687 M (IKEV2_PROFILE_ADD_DEL, mp);
15689 clib_memcpy (mp->name, name, vec_len (name));
15690 mp->is_add = is_add;
15699 api_ikev2_profile_set_auth (vat_main_t * vam)
15701 unformat_input_t *i = vam->input;
15702 vl_api_ikev2_profile_set_auth_t *mp;
15705 u32 auth_method = 0;
15709 const char *valid_chars = "a-zA-Z0-9_";
15711 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15713 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15714 vec_add1 (name, 0);
15715 else if (unformat (i, "auth_method %U",
15716 unformat_ikev2_auth_method, &auth_method))
15718 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
15720 else if (unformat (i, "auth_data %v", &data))
15724 errmsg ("parse error '%U'", format_unformat_error, i);
15729 if (!vec_len (name))
15731 errmsg ("profile name must be specified");
15735 if (vec_len (name) > 64)
15737 errmsg ("profile name too long");
15741 if (!vec_len (data))
15743 errmsg ("auth_data must be specified");
15749 errmsg ("auth_method must be specified");
15753 M (IKEV2_PROFILE_SET_AUTH, mp);
15755 mp->is_hex = is_hex;
15756 mp->auth_method = (u8) auth_method;
15757 mp->data_len = vec_len (data);
15758 clib_memcpy (mp->name, name, vec_len (name));
15759 clib_memcpy (mp->data, data, vec_len (data));
15769 api_ikev2_profile_set_id (vat_main_t * vam)
15771 unformat_input_t *i = vam->input;
15772 vl_api_ikev2_profile_set_id_t *mp;
15780 const char *valid_chars = "a-zA-Z0-9_";
15782 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15784 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15785 vec_add1 (name, 0);
15786 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
15788 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
15790 data = vec_new (u8, 4);
15791 clib_memcpy (data, ip4.as_u8, 4);
15793 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
15795 else if (unformat (i, "id_data %v", &data))
15797 else if (unformat (i, "local"))
15799 else if (unformat (i, "remote"))
15803 errmsg ("parse error '%U'", format_unformat_error, i);
15808 if (!vec_len (name))
15810 errmsg ("profile name must be specified");
15814 if (vec_len (name) > 64)
15816 errmsg ("profile name too long");
15820 if (!vec_len (data))
15822 errmsg ("id_data must be specified");
15828 errmsg ("id_type must be specified");
15832 M (IKEV2_PROFILE_SET_ID, mp);
15834 mp->is_local = is_local;
15835 mp->id_type = (u8) id_type;
15836 mp->data_len = vec_len (data);
15837 clib_memcpy (mp->name, name, vec_len (name));
15838 clib_memcpy (mp->data, data, vec_len (data));
15848 api_ikev2_profile_set_ts (vat_main_t * vam)
15850 unformat_input_t *i = vam->input;
15851 vl_api_ikev2_profile_set_ts_t *mp;
15854 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
15855 ip4_address_t start_addr, end_addr;
15857 const char *valid_chars = "a-zA-Z0-9_";
15860 start_addr.as_u32 = 0;
15861 end_addr.as_u32 = (u32) ~ 0;
15863 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15865 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15866 vec_add1 (name, 0);
15867 else if (unformat (i, "protocol %d", &proto))
15869 else if (unformat (i, "start_port %d", &start_port))
15871 else if (unformat (i, "end_port %d", &end_port))
15874 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
15876 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
15878 else if (unformat (i, "local"))
15880 else if (unformat (i, "remote"))
15884 errmsg ("parse error '%U'", format_unformat_error, i);
15889 if (!vec_len (name))
15891 errmsg ("profile name must be specified");
15895 if (vec_len (name) > 64)
15897 errmsg ("profile name too long");
15901 M (IKEV2_PROFILE_SET_TS, mp);
15903 mp->is_local = is_local;
15904 mp->proto = (u8) proto;
15905 mp->start_port = (u16) start_port;
15906 mp->end_port = (u16) end_port;
15907 mp->start_addr = start_addr.as_u32;
15908 mp->end_addr = end_addr.as_u32;
15909 clib_memcpy (mp->name, name, vec_len (name));
15918 api_ikev2_set_local_key (vat_main_t * vam)
15920 unformat_input_t *i = vam->input;
15921 vl_api_ikev2_set_local_key_t *mp;
15925 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15927 if (unformat (i, "file %v", &file))
15928 vec_add1 (file, 0);
15931 errmsg ("parse error '%U'", format_unformat_error, i);
15936 if (!vec_len (file))
15938 errmsg ("RSA key file must be specified");
15942 if (vec_len (file) > 256)
15944 errmsg ("file name too long");
15948 M (IKEV2_SET_LOCAL_KEY, mp);
15950 clib_memcpy (mp->key_file, file, vec_len (file));
15959 api_ikev2_set_responder (vat_main_t * vam)
15961 unformat_input_t *i = vam->input;
15962 vl_api_ikev2_set_responder_t *mp;
15965 u32 sw_if_index = ~0;
15966 ip4_address_t address;
15968 const char *valid_chars = "a-zA-Z0-9_";
15970 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15973 (i, "%U interface %d address %U", unformat_token, valid_chars,
15974 &name, &sw_if_index, unformat_ip4_address, &address))
15975 vec_add1 (name, 0);
15978 errmsg ("parse error '%U'", format_unformat_error, i);
15983 if (!vec_len (name))
15985 errmsg ("profile name must be specified");
15989 if (vec_len (name) > 64)
15991 errmsg ("profile name too long");
15995 M (IKEV2_SET_RESPONDER, mp);
15997 clib_memcpy (mp->name, name, vec_len (name));
16000 mp->sw_if_index = sw_if_index;
16001 clib_memcpy (mp->address, &address, sizeof (address));
16009 api_ikev2_set_ike_transforms (vat_main_t * vam)
16011 unformat_input_t *i = vam->input;
16012 vl_api_ikev2_set_ike_transforms_t *mp;
16015 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
16017 const char *valid_chars = "a-zA-Z0-9_";
16019 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16021 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
16022 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
16023 vec_add1 (name, 0);
16026 errmsg ("parse error '%U'", format_unformat_error, i);
16031 if (!vec_len (name))
16033 errmsg ("profile name must be specified");
16037 if (vec_len (name) > 64)
16039 errmsg ("profile name too long");
16043 M (IKEV2_SET_IKE_TRANSFORMS, mp);
16045 clib_memcpy (mp->name, name, vec_len (name));
16047 mp->crypto_alg = crypto_alg;
16048 mp->crypto_key_size = crypto_key_size;
16049 mp->integ_alg = integ_alg;
16050 mp->dh_group = dh_group;
16059 api_ikev2_set_esp_transforms (vat_main_t * vam)
16061 unformat_input_t *i = vam->input;
16062 vl_api_ikev2_set_esp_transforms_t *mp;
16065 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
16067 const char *valid_chars = "a-zA-Z0-9_";
16069 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16071 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
16072 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
16073 vec_add1 (name, 0);
16076 errmsg ("parse error '%U'", format_unformat_error, i);
16081 if (!vec_len (name))
16083 errmsg ("profile name must be specified");
16087 if (vec_len (name) > 64)
16089 errmsg ("profile name too long");
16093 M (IKEV2_SET_ESP_TRANSFORMS, mp);
16095 clib_memcpy (mp->name, name, vec_len (name));
16097 mp->crypto_alg = crypto_alg;
16098 mp->crypto_key_size = crypto_key_size;
16099 mp->integ_alg = integ_alg;
16100 mp->dh_group = dh_group;
16108 api_ikev2_set_sa_lifetime (vat_main_t * vam)
16110 unformat_input_t *i = vam->input;
16111 vl_api_ikev2_set_sa_lifetime_t *mp;
16114 u64 lifetime, lifetime_maxdata;
16115 u32 lifetime_jitter, handover;
16117 const char *valid_chars = "a-zA-Z0-9_";
16119 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16121 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
16122 &lifetime, &lifetime_jitter, &handover,
16123 &lifetime_maxdata))
16124 vec_add1 (name, 0);
16127 errmsg ("parse error '%U'", format_unformat_error, i);
16132 if (!vec_len (name))
16134 errmsg ("profile name must be specified");
16138 if (vec_len (name) > 64)
16140 errmsg ("profile name too long");
16144 M (IKEV2_SET_SA_LIFETIME, mp);
16146 clib_memcpy (mp->name, name, vec_len (name));
16148 mp->lifetime = lifetime;
16149 mp->lifetime_jitter = lifetime_jitter;
16150 mp->handover = handover;
16151 mp->lifetime_maxdata = lifetime_maxdata;
16159 api_ikev2_initiate_sa_init (vat_main_t * vam)
16161 unformat_input_t *i = vam->input;
16162 vl_api_ikev2_initiate_sa_init_t *mp;
16166 const char *valid_chars = "a-zA-Z0-9_";
16168 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16170 if (unformat (i, "%U", unformat_token, valid_chars, &name))
16171 vec_add1 (name, 0);
16174 errmsg ("parse error '%U'", format_unformat_error, i);
16179 if (!vec_len (name))
16181 errmsg ("profile name must be specified");
16185 if (vec_len (name) > 64)
16187 errmsg ("profile name too long");
16191 M (IKEV2_INITIATE_SA_INIT, mp);
16193 clib_memcpy (mp->name, name, vec_len (name));
16202 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
16204 unformat_input_t *i = vam->input;
16205 vl_api_ikev2_initiate_del_ike_sa_t *mp;
16210 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16212 if (unformat (i, "%lx", &ispi))
16216 errmsg ("parse error '%U'", format_unformat_error, i);
16221 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
16231 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
16233 unformat_input_t *i = vam->input;
16234 vl_api_ikev2_initiate_del_child_sa_t *mp;
16239 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16241 if (unformat (i, "%x", &ispi))
16245 errmsg ("parse error '%U'", format_unformat_error, i);
16250 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
16260 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
16262 unformat_input_t *i = vam->input;
16263 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
16268 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16270 if (unformat (i, "%x", &ispi))
16274 errmsg ("parse error '%U'", format_unformat_error, i);
16279 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
16292 api_map_add_domain (vat_main_t * vam)
16294 unformat_input_t *i = vam->input;
16295 vl_api_map_add_domain_t *mp;
16297 ip4_address_t ip4_prefix;
16298 ip6_address_t ip6_prefix;
16299 ip6_address_t ip6_src;
16300 u32 num_m_args = 0;
16301 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
16302 0, psid_length = 0;
16303 u8 is_translation = 0;
16305 u32 ip6_src_len = 128;
16308 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16310 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
16311 &ip4_prefix, &ip4_prefix_len))
16313 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
16314 &ip6_prefix, &ip6_prefix_len))
16318 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
16321 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
16323 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
16325 else if (unformat (i, "psid-offset %d", &psid_offset))
16327 else if (unformat (i, "psid-len %d", &psid_length))
16329 else if (unformat (i, "mtu %d", &mtu))
16331 else if (unformat (i, "map-t"))
16332 is_translation = 1;
16335 clib_warning ("parse error '%U'", format_unformat_error, i);
16340 if (num_m_args < 3)
16342 errmsg ("mandatory argument(s) missing");
16346 /* Construct the API message */
16347 M (MAP_ADD_DOMAIN, mp);
16349 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
16350 mp->ip4_prefix_len = ip4_prefix_len;
16352 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
16353 mp->ip6_prefix_len = ip6_prefix_len;
16355 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
16356 mp->ip6_src_prefix_len = ip6_src_len;
16358 mp->ea_bits_len = ea_bits_len;
16359 mp->psid_offset = psid_offset;
16360 mp->psid_length = psid_length;
16361 mp->is_translation = is_translation;
16362 mp->mtu = htons (mtu);
16367 /* Wait for a reply, return good/bad news */
16373 api_map_del_domain (vat_main_t * vam)
16375 unformat_input_t *i = vam->input;
16376 vl_api_map_del_domain_t *mp;
16378 u32 num_m_args = 0;
16382 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16384 if (unformat (i, "index %d", &index))
16388 clib_warning ("parse error '%U'", format_unformat_error, i);
16393 if (num_m_args != 1)
16395 errmsg ("mandatory argument(s) missing");
16399 /* Construct the API message */
16400 M (MAP_DEL_DOMAIN, mp);
16402 mp->index = ntohl (index);
16407 /* Wait for a reply, return good/bad news */
16413 api_map_add_del_rule (vat_main_t * vam)
16415 unformat_input_t *i = vam->input;
16416 vl_api_map_add_del_rule_t *mp;
16418 ip6_address_t ip6_dst;
16419 u32 num_m_args = 0, index, psid = 0;
16422 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16424 if (unformat (i, "index %d", &index))
16426 else if (unformat (i, "psid %d", &psid))
16428 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
16430 else if (unformat (i, "del"))
16436 clib_warning ("parse error '%U'", format_unformat_error, i);
16441 /* Construct the API message */
16442 M (MAP_ADD_DEL_RULE, mp);
16444 mp->index = ntohl (index);
16445 mp->is_add = is_add;
16446 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
16447 mp->psid = ntohs (psid);
16452 /* Wait for a reply, return good/bad news */
16458 api_map_domain_dump (vat_main_t * vam)
16460 vl_api_map_domain_dump_t *mp;
16461 vl_api_control_ping_t *mp_ping;
16464 /* Construct the API message */
16465 M (MAP_DOMAIN_DUMP, mp);
16470 /* Use a control ping for synchronization */
16471 MPING (CONTROL_PING, mp_ping);
16479 api_map_rule_dump (vat_main_t * vam)
16481 unformat_input_t *i = vam->input;
16482 vl_api_map_rule_dump_t *mp;
16483 vl_api_control_ping_t *mp_ping;
16484 u32 domain_index = ~0;
16487 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16489 if (unformat (i, "index %u", &domain_index))
16495 if (domain_index == ~0)
16497 clib_warning ("parse error: domain index expected");
16501 /* Construct the API message */
16502 M (MAP_RULE_DUMP, mp);
16504 mp->domain_index = htonl (domain_index);
16509 /* Use a control ping for synchronization */
16510 MPING (CONTROL_PING, mp_ping);
16517 static void vl_api_map_add_domain_reply_t_handler
16518 (vl_api_map_add_domain_reply_t * mp)
16520 vat_main_t *vam = &vat_main;
16521 i32 retval = ntohl (mp->retval);
16523 if (vam->async_mode)
16525 vam->async_errors += (retval < 0);
16529 vam->retval = retval;
16530 vam->result_ready = 1;
16534 static void vl_api_map_add_domain_reply_t_handler_json
16535 (vl_api_map_add_domain_reply_t * mp)
16537 vat_main_t *vam = &vat_main;
16538 vat_json_node_t node;
16540 vat_json_init_object (&node);
16541 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
16542 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
16544 vat_json_print (vam->ofp, &node);
16545 vat_json_free (&node);
16547 vam->retval = ntohl (mp->retval);
16548 vam->result_ready = 1;
16552 api_get_first_msg_id (vat_main_t * vam)
16554 vl_api_get_first_msg_id_t *mp;
16555 unformat_input_t *i = vam->input;
16560 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16562 if (unformat (i, "client %s", &name))
16570 errmsg ("missing client name");
16573 vec_add1 (name, 0);
16575 if (vec_len (name) > 63)
16577 errmsg ("client name too long");
16581 M (GET_FIRST_MSG_ID, mp);
16582 clib_memcpy (mp->name, name, vec_len (name));
16589 api_cop_interface_enable_disable (vat_main_t * vam)
16591 unformat_input_t *line_input = vam->input;
16592 vl_api_cop_interface_enable_disable_t *mp;
16593 u32 sw_if_index = ~0;
16594 u8 enable_disable = 1;
16597 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16599 if (unformat (line_input, "disable"))
16600 enable_disable = 0;
16601 if (unformat (line_input, "enable"))
16602 enable_disable = 1;
16603 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16604 vam, &sw_if_index))
16606 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16612 if (sw_if_index == ~0)
16614 errmsg ("missing interface name or sw_if_index");
16618 /* Construct the API message */
16619 M (COP_INTERFACE_ENABLE_DISABLE, mp);
16620 mp->sw_if_index = ntohl (sw_if_index);
16621 mp->enable_disable = enable_disable;
16625 /* Wait for the reply */
16631 api_cop_whitelist_enable_disable (vat_main_t * vam)
16633 unformat_input_t *line_input = vam->input;
16634 vl_api_cop_whitelist_enable_disable_t *mp;
16635 u32 sw_if_index = ~0;
16636 u8 ip4 = 0, ip6 = 0, default_cop = 0;
16640 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16642 if (unformat (line_input, "ip4"))
16644 else if (unformat (line_input, "ip6"))
16646 else if (unformat (line_input, "default"))
16648 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16649 vam, &sw_if_index))
16651 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16653 else if (unformat (line_input, "fib-id %d", &fib_id))
16659 if (sw_if_index == ~0)
16661 errmsg ("missing interface name or sw_if_index");
16665 /* Construct the API message */
16666 M (COP_WHITELIST_ENABLE_DISABLE, mp);
16667 mp->sw_if_index = ntohl (sw_if_index);
16668 mp->fib_id = ntohl (fib_id);
16671 mp->default_cop = default_cop;
16675 /* Wait for the reply */
16681 api_get_node_graph (vat_main_t * vam)
16683 vl_api_get_node_graph_t *mp;
16686 M (GET_NODE_GRAPH, mp);
16690 /* Wait for the reply */
16696 /** Used for parsing LISP eids */
16697 typedef CLIB_PACKED(struct{
16698 u8 addr[16]; /**< eid address */
16699 u32 len; /**< prefix length if IP */
16700 u8 type; /**< type of eid */
16705 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
16707 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
16709 memset (a, 0, sizeof (a[0]));
16711 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
16713 a->type = 0; /* ipv4 type */
16715 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
16717 a->type = 1; /* ipv6 type */
16719 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
16721 a->type = 2; /* mac type */
16723 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
16725 a->type = 3; /* NSH type */
16726 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
16727 nsh->spi = clib_host_to_net_u32 (nsh->spi);
16734 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
16743 lisp_eid_size_vat (u8 type)
16760 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
16762 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
16766 api_one_add_del_locator_set (vat_main_t * vam)
16768 unformat_input_t *input = vam->input;
16769 vl_api_one_add_del_locator_set_t *mp;
16771 u8 *locator_set_name = NULL;
16772 u8 locator_set_name_set = 0;
16773 vl_api_local_locator_t locator, *locators = 0;
16774 u32 sw_if_index, priority, weight;
16778 /* Parse args required to build the message */
16779 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16781 if (unformat (input, "del"))
16785 else if (unformat (input, "locator-set %s", &locator_set_name))
16787 locator_set_name_set = 1;
16789 else if (unformat (input, "sw_if_index %u p %u w %u",
16790 &sw_if_index, &priority, &weight))
16792 locator.sw_if_index = htonl (sw_if_index);
16793 locator.priority = priority;
16794 locator.weight = weight;
16795 vec_add1 (locators, locator);
16799 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
16800 &sw_if_index, &priority, &weight))
16802 locator.sw_if_index = htonl (sw_if_index);
16803 locator.priority = priority;
16804 locator.weight = weight;
16805 vec_add1 (locators, locator);
16811 if (locator_set_name_set == 0)
16813 errmsg ("missing locator-set name");
16814 vec_free (locators);
16818 if (vec_len (locator_set_name) > 64)
16820 errmsg ("locator-set name too long");
16821 vec_free (locator_set_name);
16822 vec_free (locators);
16825 vec_add1 (locator_set_name, 0);
16827 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
16829 /* Construct the API message */
16830 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
16832 mp->is_add = is_add;
16833 clib_memcpy (mp->locator_set_name, locator_set_name,
16834 vec_len (locator_set_name));
16835 vec_free (locator_set_name);
16837 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
16839 clib_memcpy (mp->locators, locators, data_len);
16840 vec_free (locators);
16845 /* Wait for a reply... */
16850 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
16853 api_one_add_del_locator (vat_main_t * vam)
16855 unformat_input_t *input = vam->input;
16856 vl_api_one_add_del_locator_t *mp;
16857 u32 tmp_if_index = ~0;
16858 u32 sw_if_index = ~0;
16859 u8 sw_if_index_set = 0;
16860 u8 sw_if_index_if_name_set = 0;
16862 u8 priority_set = 0;
16866 u8 *locator_set_name = NULL;
16867 u8 locator_set_name_set = 0;
16870 /* Parse args required to build the message */
16871 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16873 if (unformat (input, "del"))
16877 else if (unformat (input, "locator-set %s", &locator_set_name))
16879 locator_set_name_set = 1;
16881 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
16884 sw_if_index_if_name_set = 1;
16885 sw_if_index = tmp_if_index;
16887 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
16889 sw_if_index_set = 1;
16890 sw_if_index = tmp_if_index;
16892 else if (unformat (input, "p %d", &priority))
16896 else if (unformat (input, "w %d", &weight))
16904 if (locator_set_name_set == 0)
16906 errmsg ("missing locator-set name");
16910 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
16912 errmsg ("missing sw_if_index");
16913 vec_free (locator_set_name);
16917 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
16919 errmsg ("cannot use both params interface name and sw_if_index");
16920 vec_free (locator_set_name);
16924 if (priority_set == 0)
16926 errmsg ("missing locator-set priority");
16927 vec_free (locator_set_name);
16931 if (weight_set == 0)
16933 errmsg ("missing locator-set weight");
16934 vec_free (locator_set_name);
16938 if (vec_len (locator_set_name) > 64)
16940 errmsg ("locator-set name too long");
16941 vec_free (locator_set_name);
16944 vec_add1 (locator_set_name, 0);
16946 /* Construct the API message */
16947 M (ONE_ADD_DEL_LOCATOR, mp);
16949 mp->is_add = is_add;
16950 mp->sw_if_index = ntohl (sw_if_index);
16951 mp->priority = priority;
16952 mp->weight = weight;
16953 clib_memcpy (mp->locator_set_name, locator_set_name,
16954 vec_len (locator_set_name));
16955 vec_free (locator_set_name);
16960 /* Wait for a reply... */
16965 #define api_lisp_add_del_locator api_one_add_del_locator
16968 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
16970 u32 *key_id = va_arg (*args, u32 *);
16973 if (unformat (input, "%s", &s))
16975 if (!strcmp ((char *) s, "sha1"))
16976 key_id[0] = HMAC_SHA_1_96;
16977 else if (!strcmp ((char *) s, "sha256"))
16978 key_id[0] = HMAC_SHA_256_128;
16981 clib_warning ("invalid key_id: '%s'", s);
16982 key_id[0] = HMAC_NO_KEY;
16993 api_one_add_del_local_eid (vat_main_t * vam)
16995 unformat_input_t *input = vam->input;
16996 vl_api_one_add_del_local_eid_t *mp;
16999 lisp_eid_vat_t _eid, *eid = &_eid;
17000 u8 *locator_set_name = 0;
17001 u8 locator_set_name_set = 0;
17007 /* Parse args required to build the message */
17008 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17010 if (unformat (input, "del"))
17014 else if (unformat (input, "vni %d", &vni))
17018 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
17022 else if (unformat (input, "locator-set %s", &locator_set_name))
17024 locator_set_name_set = 1;
17026 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
17028 else if (unformat (input, "secret-key %_%v%_", &key))
17034 if (locator_set_name_set == 0)
17036 errmsg ("missing locator-set name");
17042 errmsg ("EID address not set!");
17043 vec_free (locator_set_name);
17047 if (key && (0 == key_id))
17049 errmsg ("invalid key_id!");
17053 if (vec_len (key) > 64)
17055 errmsg ("key too long");
17060 if (vec_len (locator_set_name) > 64)
17062 errmsg ("locator-set name too long");
17063 vec_free (locator_set_name);
17066 vec_add1 (locator_set_name, 0);
17068 /* Construct the API message */
17069 M (ONE_ADD_DEL_LOCAL_EID, mp);
17071 mp->is_add = is_add;
17072 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
17073 mp->eid_type = eid->type;
17074 mp->prefix_len = eid->len;
17075 mp->vni = clib_host_to_net_u32 (vni);
17076 mp->key_id = clib_host_to_net_u16 (key_id);
17077 clib_memcpy (mp->locator_set_name, locator_set_name,
17078 vec_len (locator_set_name));
17079 clib_memcpy (mp->key, key, vec_len (key));
17081 vec_free (locator_set_name);
17087 /* Wait for a reply... */
17092 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
17095 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
17097 u32 dp_table = 0, vni = 0;;
17098 unformat_input_t *input = vam->input;
17099 vl_api_gpe_add_del_fwd_entry_t *mp;
17101 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
17102 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
17103 u8 rmt_eid_set = 0, lcl_eid_set = 0;
17104 u32 action = ~0, w;
17105 ip4_address_t rmt_rloc4, lcl_rloc4;
17106 ip6_address_t rmt_rloc6, lcl_rloc6;
17107 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
17110 memset (&rloc, 0, sizeof (rloc));
17112 /* Parse args required to build the message */
17113 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17115 if (unformat (input, "del"))
17117 else if (unformat (input, "add"))
17119 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
17123 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
17127 else if (unformat (input, "vrf %d", &dp_table))
17129 else if (unformat (input, "bd %d", &dp_table))
17131 else if (unformat (input, "vni %d", &vni))
17133 else if (unformat (input, "w %d", &w))
17137 errmsg ("No RLOC configured for setting priority/weight!");
17140 curr_rloc->weight = w;
17142 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
17143 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
17147 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
17149 vec_add1 (lcl_locs, rloc);
17151 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
17152 vec_add1 (rmt_locs, rloc);
17153 /* weight saved in rmt loc */
17154 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
17156 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
17157 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
17160 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
17162 vec_add1 (lcl_locs, rloc);
17164 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
17165 vec_add1 (rmt_locs, rloc);
17166 /* weight saved in rmt loc */
17167 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
17169 else if (unformat (input, "action %d", &action))
17175 clib_warning ("parse error '%U'", format_unformat_error, input);
17182 errmsg ("remote eid addresses not set");
17186 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
17188 errmsg ("eid types don't match");
17192 if (0 == rmt_locs && (u32) ~ 0 == action)
17194 errmsg ("action not set for negative mapping");
17198 /* Construct the API message */
17199 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
17200 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
17202 mp->is_add = is_add;
17203 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
17204 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
17205 mp->eid_type = rmt_eid->type;
17206 mp->dp_table = clib_host_to_net_u32 (dp_table);
17207 mp->vni = clib_host_to_net_u32 (vni);
17208 mp->rmt_len = rmt_eid->len;
17209 mp->lcl_len = lcl_eid->len;
17210 mp->action = action;
17212 if (0 != rmt_locs && 0 != lcl_locs)
17214 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
17215 clib_memcpy (mp->locs, lcl_locs,
17216 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
17218 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
17219 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
17220 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
17222 vec_free (lcl_locs);
17223 vec_free (rmt_locs);
17228 /* Wait for a reply... */
17234 api_one_add_del_map_server (vat_main_t * vam)
17236 unformat_input_t *input = vam->input;
17237 vl_api_one_add_del_map_server_t *mp;
17241 ip4_address_t ipv4;
17242 ip6_address_t ipv6;
17245 /* Parse args required to build the message */
17246 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17248 if (unformat (input, "del"))
17252 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17256 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17264 if (ipv4_set && ipv6_set)
17266 errmsg ("both eid v4 and v6 addresses set");
17270 if (!ipv4_set && !ipv6_set)
17272 errmsg ("eid addresses not set");
17276 /* Construct the API message */
17277 M (ONE_ADD_DEL_MAP_SERVER, mp);
17279 mp->is_add = is_add;
17283 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17288 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17294 /* Wait for a reply... */
17299 #define api_lisp_add_del_map_server api_one_add_del_map_server
17302 api_one_add_del_map_resolver (vat_main_t * vam)
17304 unformat_input_t *input = vam->input;
17305 vl_api_one_add_del_map_resolver_t *mp;
17309 ip4_address_t ipv4;
17310 ip6_address_t ipv6;
17313 /* Parse args required to build the message */
17314 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17316 if (unformat (input, "del"))
17320 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17324 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17332 if (ipv4_set && ipv6_set)
17334 errmsg ("both eid v4 and v6 addresses set");
17338 if (!ipv4_set && !ipv6_set)
17340 errmsg ("eid addresses not set");
17344 /* Construct the API message */
17345 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
17347 mp->is_add = is_add;
17351 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17356 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17362 /* Wait for a reply... */
17367 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
17370 api_lisp_gpe_enable_disable (vat_main_t * vam)
17372 unformat_input_t *input = vam->input;
17373 vl_api_gpe_enable_disable_t *mp;
17378 /* Parse args required to build the message */
17379 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17381 if (unformat (input, "enable"))
17386 else if (unformat (input, "disable"))
17397 errmsg ("Value not set");
17401 /* Construct the API message */
17402 M (GPE_ENABLE_DISABLE, mp);
17409 /* Wait for a reply... */
17415 api_one_rloc_probe_enable_disable (vat_main_t * vam)
17417 unformat_input_t *input = vam->input;
17418 vl_api_one_rloc_probe_enable_disable_t *mp;
17423 /* Parse args required to build the message */
17424 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17426 if (unformat (input, "enable"))
17431 else if (unformat (input, "disable"))
17439 errmsg ("Value not set");
17443 /* Construct the API message */
17444 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
17446 mp->is_enabled = is_en;
17451 /* Wait for a reply... */
17456 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
17459 api_one_map_register_enable_disable (vat_main_t * vam)
17461 unformat_input_t *input = vam->input;
17462 vl_api_one_map_register_enable_disable_t *mp;
17467 /* Parse args required to build the message */
17468 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17470 if (unformat (input, "enable"))
17475 else if (unformat (input, "disable"))
17483 errmsg ("Value not set");
17487 /* Construct the API message */
17488 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
17490 mp->is_enabled = is_en;
17495 /* Wait for a reply... */
17500 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
17503 api_one_enable_disable (vat_main_t * vam)
17505 unformat_input_t *input = vam->input;
17506 vl_api_one_enable_disable_t *mp;
17511 /* Parse args required to build the message */
17512 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17514 if (unformat (input, "enable"))
17519 else if (unformat (input, "disable"))
17529 errmsg ("Value not set");
17533 /* Construct the API message */
17534 M (ONE_ENABLE_DISABLE, mp);
17541 /* Wait for a reply... */
17546 #define api_lisp_enable_disable api_one_enable_disable
17549 api_one_enable_disable_xtr_mode (vat_main_t * vam)
17551 unformat_input_t *input = vam->input;
17552 vl_api_one_enable_disable_xtr_mode_t *mp;
17557 /* Parse args required to build the message */
17558 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17560 if (unformat (input, "enable"))
17565 else if (unformat (input, "disable"))
17575 errmsg ("Value not set");
17579 /* Construct the API message */
17580 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
17587 /* Wait for a reply... */
17593 api_one_show_xtr_mode (vat_main_t * vam)
17595 vl_api_one_show_xtr_mode_t *mp;
17598 /* Construct the API message */
17599 M (ONE_SHOW_XTR_MODE, mp);
17604 /* Wait for a reply... */
17610 api_one_enable_disable_pitr_mode (vat_main_t * vam)
17612 unformat_input_t *input = vam->input;
17613 vl_api_one_enable_disable_pitr_mode_t *mp;
17618 /* Parse args required to build the message */
17619 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17621 if (unformat (input, "enable"))
17626 else if (unformat (input, "disable"))
17636 errmsg ("Value not set");
17640 /* Construct the API message */
17641 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
17648 /* Wait for a reply... */
17654 api_one_show_pitr_mode (vat_main_t * vam)
17656 vl_api_one_show_pitr_mode_t *mp;
17659 /* Construct the API message */
17660 M (ONE_SHOW_PITR_MODE, mp);
17665 /* Wait for a reply... */
17671 api_one_enable_disable_petr_mode (vat_main_t * vam)
17673 unformat_input_t *input = vam->input;
17674 vl_api_one_enable_disable_petr_mode_t *mp;
17679 /* Parse args required to build the message */
17680 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17682 if (unformat (input, "enable"))
17687 else if (unformat (input, "disable"))
17697 errmsg ("Value not set");
17701 /* Construct the API message */
17702 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
17709 /* Wait for a reply... */
17715 api_one_show_petr_mode (vat_main_t * vam)
17717 vl_api_one_show_petr_mode_t *mp;
17720 /* Construct the API message */
17721 M (ONE_SHOW_PETR_MODE, mp);
17726 /* Wait for a reply... */
17732 api_show_one_map_register_state (vat_main_t * vam)
17734 vl_api_show_one_map_register_state_t *mp;
17737 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
17742 /* wait for reply */
17747 #define api_show_lisp_map_register_state api_show_one_map_register_state
17750 api_show_one_rloc_probe_state (vat_main_t * vam)
17752 vl_api_show_one_rloc_probe_state_t *mp;
17755 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
17760 /* wait for reply */
17765 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
17768 api_one_add_del_ndp_entry (vat_main_t * vam)
17770 vl_api_one_add_del_ndp_entry_t *mp;
17771 unformat_input_t *input = vam->input;
17776 u8 mac[6] = { 0, };
17777 u8 ip6[16] = { 0, };
17781 /* Parse args required to build the message */
17782 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17784 if (unformat (input, "del"))
17786 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17788 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
17790 else if (unformat (input, "bd %d", &bd))
17794 errmsg ("parse error '%U'", format_unformat_error, input);
17799 if (!bd_set || !ip_set || (!mac_set && is_add))
17801 errmsg ("Missing BD, IP or MAC!");
17805 M (ONE_ADD_DEL_NDP_ENTRY, mp);
17806 mp->is_add = is_add;
17807 clib_memcpy (mp->mac, mac, 6);
17808 mp->bd = clib_host_to_net_u32 (bd);
17809 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
17814 /* wait for reply */
17820 api_one_add_del_l2_arp_entry (vat_main_t * vam)
17822 vl_api_one_add_del_l2_arp_entry_t *mp;
17823 unformat_input_t *input = vam->input;
17828 u8 mac[6] = { 0, };
17829 u32 ip4 = 0, bd = ~0;
17832 /* Parse args required to build the message */
17833 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17835 if (unformat (input, "del"))
17837 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17839 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
17841 else if (unformat (input, "bd %d", &bd))
17845 errmsg ("parse error '%U'", format_unformat_error, input);
17850 if (!bd_set || !ip_set || (!mac_set && is_add))
17852 errmsg ("Missing BD, IP or MAC!");
17856 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
17857 mp->is_add = is_add;
17858 clib_memcpy (mp->mac, mac, 6);
17859 mp->bd = clib_host_to_net_u32 (bd);
17865 /* wait for reply */
17871 api_one_ndp_bd_get (vat_main_t * vam)
17873 vl_api_one_ndp_bd_get_t *mp;
17876 M (ONE_NDP_BD_GET, mp);
17881 /* wait for reply */
17887 api_one_ndp_entries_get (vat_main_t * vam)
17889 vl_api_one_ndp_entries_get_t *mp;
17890 unformat_input_t *input = vam->input;
17895 /* Parse args required to build the message */
17896 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17898 if (unformat (input, "bd %d", &bd))
17902 errmsg ("parse error '%U'", format_unformat_error, input);
17909 errmsg ("Expected bridge domain!");
17913 M (ONE_NDP_ENTRIES_GET, mp);
17914 mp->bd = clib_host_to_net_u32 (bd);
17919 /* wait for reply */
17925 api_one_l2_arp_bd_get (vat_main_t * vam)
17927 vl_api_one_l2_arp_bd_get_t *mp;
17930 M (ONE_L2_ARP_BD_GET, mp);
17935 /* wait for reply */
17941 api_one_l2_arp_entries_get (vat_main_t * vam)
17943 vl_api_one_l2_arp_entries_get_t *mp;
17944 unformat_input_t *input = vam->input;
17949 /* Parse args required to build the message */
17950 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17952 if (unformat (input, "bd %d", &bd))
17956 errmsg ("parse error '%U'", format_unformat_error, input);
17963 errmsg ("Expected bridge domain!");
17967 M (ONE_L2_ARP_ENTRIES_GET, mp);
17968 mp->bd = clib_host_to_net_u32 (bd);
17973 /* wait for reply */
17979 api_one_stats_enable_disable (vat_main_t * vam)
17981 vl_api_one_stats_enable_disable_t *mp;
17982 unformat_input_t *input = vam->input;
17987 /* Parse args required to build the message */
17988 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17990 if (unformat (input, "enable"))
17995 else if (unformat (input, "disable"))
18005 errmsg ("Value not set");
18009 M (ONE_STATS_ENABLE_DISABLE, mp);
18015 /* wait for reply */
18021 api_show_one_stats_enable_disable (vat_main_t * vam)
18023 vl_api_show_one_stats_enable_disable_t *mp;
18026 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
18031 /* wait for reply */
18037 api_show_one_map_request_mode (vat_main_t * vam)
18039 vl_api_show_one_map_request_mode_t *mp;
18042 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
18047 /* wait for reply */
18052 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
18055 api_one_map_request_mode (vat_main_t * vam)
18057 unformat_input_t *input = vam->input;
18058 vl_api_one_map_request_mode_t *mp;
18062 /* Parse args required to build the message */
18063 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18065 if (unformat (input, "dst-only"))
18067 else if (unformat (input, "src-dst"))
18071 errmsg ("parse error '%U'", format_unformat_error, input);
18076 M (ONE_MAP_REQUEST_MODE, mp);
18083 /* wait for reply */
18088 #define api_lisp_map_request_mode api_one_map_request_mode
18091 * Enable/disable ONE proxy ITR.
18093 * @param vam vpp API test context
18094 * @return return code
18097 api_one_pitr_set_locator_set (vat_main_t * vam)
18099 u8 ls_name_set = 0;
18100 unformat_input_t *input = vam->input;
18101 vl_api_one_pitr_set_locator_set_t *mp;
18106 /* Parse args required to build the message */
18107 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18109 if (unformat (input, "del"))
18111 else if (unformat (input, "locator-set %s", &ls_name))
18115 errmsg ("parse error '%U'", format_unformat_error, input);
18122 errmsg ("locator-set name not set!");
18126 M (ONE_PITR_SET_LOCATOR_SET, mp);
18128 mp->is_add = is_add;
18129 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
18130 vec_free (ls_name);
18135 /* wait for reply */
18140 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
18143 api_one_nsh_set_locator_set (vat_main_t * vam)
18145 u8 ls_name_set = 0;
18146 unformat_input_t *input = vam->input;
18147 vl_api_one_nsh_set_locator_set_t *mp;
18152 /* Parse args required to build the message */
18153 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18155 if (unformat (input, "del"))
18157 else if (unformat (input, "ls %s", &ls_name))
18161 errmsg ("parse error '%U'", format_unformat_error, input);
18166 if (!ls_name_set && is_add)
18168 errmsg ("locator-set name not set!");
18172 M (ONE_NSH_SET_LOCATOR_SET, mp);
18174 mp->is_add = is_add;
18175 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
18176 vec_free (ls_name);
18181 /* wait for reply */
18187 api_show_one_pitr (vat_main_t * vam)
18189 vl_api_show_one_pitr_t *mp;
18192 if (!vam->json_output)
18194 print (vam->ofp, "%=20s", "lisp status:");
18197 M (SHOW_ONE_PITR, mp);
18201 /* Wait for a reply... */
18206 #define api_show_lisp_pitr api_show_one_pitr
18209 api_one_use_petr (vat_main_t * vam)
18211 unformat_input_t *input = vam->input;
18212 vl_api_one_use_petr_t *mp;
18217 memset (&ip, 0, sizeof (ip));
18219 /* Parse args required to build the message */
18220 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18222 if (unformat (input, "disable"))
18225 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
18228 ip_addr_version (&ip) = IP4;
18231 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
18234 ip_addr_version (&ip) = IP6;
18238 errmsg ("parse error '%U'", format_unformat_error, input);
18243 M (ONE_USE_PETR, mp);
18245 mp->is_add = is_add;
18248 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
18250 clib_memcpy (mp->address, &ip, 4);
18252 clib_memcpy (mp->address, &ip, 16);
18258 /* wait for reply */
18263 #define api_lisp_use_petr api_one_use_petr
18266 api_show_one_nsh_mapping (vat_main_t * vam)
18268 vl_api_show_one_use_petr_t *mp;
18271 if (!vam->json_output)
18273 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
18276 M (SHOW_ONE_NSH_MAPPING, mp);
18280 /* Wait for a reply... */
18286 api_show_one_use_petr (vat_main_t * vam)
18288 vl_api_show_one_use_petr_t *mp;
18291 if (!vam->json_output)
18293 print (vam->ofp, "%=20s", "Proxy-ETR status:");
18296 M (SHOW_ONE_USE_PETR, mp);
18300 /* Wait for a reply... */
18305 #define api_show_lisp_use_petr api_show_one_use_petr
18308 * Add/delete mapping between vni and vrf
18311 api_one_eid_table_add_del_map (vat_main_t * vam)
18313 unformat_input_t *input = vam->input;
18314 vl_api_one_eid_table_add_del_map_t *mp;
18315 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
18316 u32 vni, vrf, bd_index;
18319 /* Parse args required to build the message */
18320 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18322 if (unformat (input, "del"))
18324 else if (unformat (input, "vrf %d", &vrf))
18326 else if (unformat (input, "bd_index %d", &bd_index))
18328 else if (unformat (input, "vni %d", &vni))
18334 if (!vni_set || (!vrf_set && !bd_index_set))
18336 errmsg ("missing arguments!");
18340 if (vrf_set && bd_index_set)
18342 errmsg ("error: both vrf and bd entered!");
18346 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
18348 mp->is_add = is_add;
18349 mp->vni = htonl (vni);
18350 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
18351 mp->is_l2 = bd_index_set;
18356 /* wait for reply */
18361 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
18364 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
18366 u32 *action = va_arg (*args, u32 *);
18369 if (unformat (input, "%s", &s))
18371 if (!strcmp ((char *) s, "no-action"))
18373 else if (!strcmp ((char *) s, "natively-forward"))
18375 else if (!strcmp ((char *) s, "send-map-request"))
18377 else if (!strcmp ((char *) s, "drop"))
18381 clib_warning ("invalid action: '%s'", s);
18393 * Add/del remote mapping to/from ONE control plane
18395 * @param vam vpp API test context
18396 * @return return code
18399 api_one_add_del_remote_mapping (vat_main_t * vam)
18401 unformat_input_t *input = vam->input;
18402 vl_api_one_add_del_remote_mapping_t *mp;
18404 lisp_eid_vat_t _eid, *eid = &_eid;
18405 lisp_eid_vat_t _seid, *seid = &_seid;
18406 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
18407 u32 action = ~0, p, w, data_len;
18408 ip4_address_t rloc4;
18409 ip6_address_t rloc6;
18410 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
18413 memset (&rloc, 0, sizeof (rloc));
18415 /* Parse args required to build the message */
18416 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18418 if (unformat (input, "del-all"))
18422 else if (unformat (input, "del"))
18426 else if (unformat (input, "add"))
18430 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
18434 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
18438 else if (unformat (input, "vni %d", &vni))
18442 else if (unformat (input, "p %d w %d", &p, &w))
18446 errmsg ("No RLOC configured for setting priority/weight!");
18449 curr_rloc->priority = p;
18450 curr_rloc->weight = w;
18452 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
18455 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
18456 vec_add1 (rlocs, rloc);
18457 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18459 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
18462 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
18463 vec_add1 (rlocs, rloc);
18464 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18466 else if (unformat (input, "action %U",
18467 unformat_negative_mapping_action, &action))
18473 clib_warning ("parse error '%U'", format_unformat_error, input);
18480 errmsg ("missing params!");
18484 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
18486 errmsg ("no action set for negative map-reply!");
18490 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
18492 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
18493 mp->is_add = is_add;
18494 mp->vni = htonl (vni);
18495 mp->action = (u8) action;
18496 mp->is_src_dst = seid_set;
18497 mp->eid_len = eid->len;
18498 mp->seid_len = seid->len;
18499 mp->del_all = del_all;
18500 mp->eid_type = eid->type;
18501 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
18502 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
18504 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
18505 clib_memcpy (mp->rlocs, rlocs, data_len);
18511 /* Wait for a reply... */
18516 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
18519 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
18520 * forwarding entries in data-plane accordingly.
18522 * @param vam vpp API test context
18523 * @return return code
18526 api_one_add_del_adjacency (vat_main_t * vam)
18528 unformat_input_t *input = vam->input;
18529 vl_api_one_add_del_adjacency_t *mp;
18531 ip4_address_t leid4, reid4;
18532 ip6_address_t leid6, reid6;
18533 u8 reid_mac[6] = { 0 };
18534 u8 leid_mac[6] = { 0 };
18535 u8 reid_type, leid_type;
18536 u32 leid_len = 0, reid_len = 0, len;
18540 leid_type = reid_type = (u8) ~ 0;
18542 /* Parse args required to build the message */
18543 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18545 if (unformat (input, "del"))
18549 else if (unformat (input, "add"))
18553 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
18556 reid_type = 0; /* ipv4 */
18559 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
18562 reid_type = 1; /* ipv6 */
18565 else if (unformat (input, "reid %U", unformat_ethernet_address,
18568 reid_type = 2; /* mac */
18570 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
18573 leid_type = 0; /* ipv4 */
18576 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
18579 leid_type = 1; /* ipv6 */
18582 else if (unformat (input, "leid %U", unformat_ethernet_address,
18585 leid_type = 2; /* mac */
18587 else if (unformat (input, "vni %d", &vni))
18593 errmsg ("parse error '%U'", format_unformat_error, input);
18598 if ((u8) ~ 0 == reid_type)
18600 errmsg ("missing params!");
18604 if (leid_type != reid_type)
18606 errmsg ("remote and local EIDs are of different types!");
18610 M (ONE_ADD_DEL_ADJACENCY, mp);
18611 mp->is_add = is_add;
18612 mp->vni = htonl (vni);
18613 mp->leid_len = leid_len;
18614 mp->reid_len = reid_len;
18615 mp->eid_type = reid_type;
18617 switch (mp->eid_type)
18620 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
18621 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
18624 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
18625 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
18628 clib_memcpy (mp->leid, leid_mac, 6);
18629 clib_memcpy (mp->reid, reid_mac, 6);
18632 errmsg ("unknown EID type %d!", mp->eid_type);
18639 /* Wait for a reply... */
18644 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
18647 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
18649 u32 *mode = va_arg (*args, u32 *);
18651 if (unformat (input, "lisp"))
18653 else if (unformat (input, "vxlan"))
18662 api_gpe_get_encap_mode (vat_main_t * vam)
18664 vl_api_gpe_get_encap_mode_t *mp;
18667 /* Construct the API message */
18668 M (GPE_GET_ENCAP_MODE, mp);
18673 /* Wait for a reply... */
18679 api_gpe_set_encap_mode (vat_main_t * vam)
18681 unformat_input_t *input = vam->input;
18682 vl_api_gpe_set_encap_mode_t *mp;
18686 /* Parse args required to build the message */
18687 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18689 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
18695 /* Construct the API message */
18696 M (GPE_SET_ENCAP_MODE, mp);
18703 /* Wait for a reply... */
18709 api_lisp_gpe_add_del_iface (vat_main_t * vam)
18711 unformat_input_t *input = vam->input;
18712 vl_api_gpe_add_del_iface_t *mp;
18713 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
18714 u32 dp_table = 0, vni = 0;
18717 /* Parse args required to build the message */
18718 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18720 if (unformat (input, "up"))
18725 else if (unformat (input, "down"))
18730 else if (unformat (input, "table_id %d", &dp_table))
18734 else if (unformat (input, "bd_id %d", &dp_table))
18739 else if (unformat (input, "vni %d", &vni))
18747 if (action_set == 0)
18749 errmsg ("Action not set");
18752 if (dp_table_set == 0 || vni_set == 0)
18754 errmsg ("vni and dp_table must be set");
18758 /* Construct the API message */
18759 M (GPE_ADD_DEL_IFACE, mp);
18761 mp->is_add = is_add;
18762 mp->dp_table = clib_host_to_net_u32 (dp_table);
18764 mp->vni = clib_host_to_net_u32 (vni);
18769 /* Wait for a reply... */
18775 api_one_map_register_fallback_threshold (vat_main_t * vam)
18777 unformat_input_t *input = vam->input;
18778 vl_api_one_map_register_fallback_threshold_t *mp;
18783 /* Parse args required to build the message */
18784 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18786 if (unformat (input, "%u", &value))
18790 clib_warning ("parse error '%U'", format_unformat_error, input);
18797 errmsg ("fallback threshold value is missing!");
18801 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18802 mp->value = clib_host_to_net_u32 (value);
18807 /* Wait for a reply... */
18813 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
18815 vl_api_show_one_map_register_fallback_threshold_t *mp;
18818 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18823 /* Wait for a reply... */
18829 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
18831 u32 *proto = va_arg (*args, u32 *);
18833 if (unformat (input, "udp"))
18835 else if (unformat (input, "api"))
18844 api_one_set_transport_protocol (vat_main_t * vam)
18846 unformat_input_t *input = vam->input;
18847 vl_api_one_set_transport_protocol_t *mp;
18852 /* Parse args required to build the message */
18853 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18855 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
18859 clib_warning ("parse error '%U'", format_unformat_error, input);
18866 errmsg ("Transport protocol missing!");
18870 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
18871 mp->protocol = (u8) protocol;
18876 /* Wait for a reply... */
18882 api_one_get_transport_protocol (vat_main_t * vam)
18884 vl_api_one_get_transport_protocol_t *mp;
18887 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
18892 /* Wait for a reply... */
18898 api_one_map_register_set_ttl (vat_main_t * vam)
18900 unformat_input_t *input = vam->input;
18901 vl_api_one_map_register_set_ttl_t *mp;
18906 /* Parse args required to build the message */
18907 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18909 if (unformat (input, "%u", &ttl))
18913 clib_warning ("parse error '%U'", format_unformat_error, input);
18920 errmsg ("TTL value missing!");
18924 M (ONE_MAP_REGISTER_SET_TTL, mp);
18925 mp->ttl = clib_host_to_net_u32 (ttl);
18930 /* Wait for a reply... */
18936 api_show_one_map_register_ttl (vat_main_t * vam)
18938 vl_api_show_one_map_register_ttl_t *mp;
18941 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
18946 /* Wait for a reply... */
18952 * Add/del map request itr rlocs from ONE control plane and updates
18954 * @param vam vpp API test context
18955 * @return return code
18958 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
18960 unformat_input_t *input = vam->input;
18961 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
18962 u8 *locator_set_name = 0;
18963 u8 locator_set_name_set = 0;
18967 /* Parse args required to build the message */
18968 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18970 if (unformat (input, "del"))
18974 else if (unformat (input, "%_%v%_", &locator_set_name))
18976 locator_set_name_set = 1;
18980 clib_warning ("parse error '%U'", format_unformat_error, input);
18985 if (is_add && !locator_set_name_set)
18987 errmsg ("itr-rloc is not set!");
18991 if (is_add && vec_len (locator_set_name) > 64)
18993 errmsg ("itr-rloc locator-set name too long");
18994 vec_free (locator_set_name);
18998 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
18999 mp->is_add = is_add;
19002 clib_memcpy (mp->locator_set_name, locator_set_name,
19003 vec_len (locator_set_name));
19007 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
19009 vec_free (locator_set_name);
19014 /* Wait for a reply... */
19019 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
19022 api_one_locator_dump (vat_main_t * vam)
19024 unformat_input_t *input = vam->input;
19025 vl_api_one_locator_dump_t *mp;
19026 vl_api_control_ping_t *mp_ping;
19027 u8 is_index_set = 0, is_name_set = 0;
19032 /* Parse args required to build the message */
19033 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19035 if (unformat (input, "ls_name %_%v%_", &ls_name))
19039 else if (unformat (input, "ls_index %d", &ls_index))
19045 errmsg ("parse error '%U'", format_unformat_error, input);
19050 if (!is_index_set && !is_name_set)
19052 errmsg ("error: expected one of index or name!");
19056 if (is_index_set && is_name_set)
19058 errmsg ("error: only one param expected!");
19062 if (vec_len (ls_name) > 62)
19064 errmsg ("error: locator set name too long!");
19068 if (!vam->json_output)
19070 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
19073 M (ONE_LOCATOR_DUMP, mp);
19074 mp->is_index_set = is_index_set;
19077 mp->ls_index = clib_host_to_net_u32 (ls_index);
19080 vec_add1 (ls_name, 0);
19081 strncpy ((char *) mp->ls_name, (char *) ls_name,
19082 sizeof (mp->ls_name) - 1);
19088 /* Use a control ping for synchronization */
19089 MPING (CONTROL_PING, mp_ping);
19092 /* Wait for a reply... */
19097 #define api_lisp_locator_dump api_one_locator_dump
19100 api_one_locator_set_dump (vat_main_t * vam)
19102 vl_api_one_locator_set_dump_t *mp;
19103 vl_api_control_ping_t *mp_ping;
19104 unformat_input_t *input = vam->input;
19108 /* Parse args required to build the message */
19109 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19111 if (unformat (input, "local"))
19115 else if (unformat (input, "remote"))
19121 errmsg ("parse error '%U'", format_unformat_error, input);
19126 if (!vam->json_output)
19128 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
19131 M (ONE_LOCATOR_SET_DUMP, mp);
19133 mp->filter = filter;
19138 /* Use a control ping for synchronization */
19139 MPING (CONTROL_PING, mp_ping);
19142 /* Wait for a reply... */
19147 #define api_lisp_locator_set_dump api_one_locator_set_dump
19150 api_one_eid_table_map_dump (vat_main_t * vam)
19154 unformat_input_t *input = vam->input;
19155 vl_api_one_eid_table_map_dump_t *mp;
19156 vl_api_control_ping_t *mp_ping;
19159 /* Parse args required to build the message */
19160 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19162 if (unformat (input, "l2"))
19167 else if (unformat (input, "l3"))
19174 errmsg ("parse error '%U'", format_unformat_error, input);
19181 errmsg ("expected one of 'l2' or 'l3' parameter!");
19185 if (!vam->json_output)
19187 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
19190 M (ONE_EID_TABLE_MAP_DUMP, mp);
19196 /* Use a control ping for synchronization */
19197 MPING (CONTROL_PING, mp_ping);
19200 /* Wait for a reply... */
19205 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
19208 api_one_eid_table_vni_dump (vat_main_t * vam)
19210 vl_api_one_eid_table_vni_dump_t *mp;
19211 vl_api_control_ping_t *mp_ping;
19214 if (!vam->json_output)
19216 print (vam->ofp, "VNI");
19219 M (ONE_EID_TABLE_VNI_DUMP, mp);
19224 /* Use a control ping for synchronization */
19225 MPING (CONTROL_PING, mp_ping);
19228 /* Wait for a reply... */
19233 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
19236 api_one_eid_table_dump (vat_main_t * vam)
19238 unformat_input_t *i = vam->input;
19239 vl_api_one_eid_table_dump_t *mp;
19240 vl_api_control_ping_t *mp_ping;
19241 struct in_addr ip4;
19242 struct in6_addr ip6;
19244 u8 eid_type = ~0, eid_set = 0;
19245 u32 prefix_length = ~0, t, vni = 0;
19248 lisp_nsh_api_t nsh;
19250 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19252 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
19258 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
19264 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
19269 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
19274 else if (unformat (i, "vni %d", &t))
19278 else if (unformat (i, "local"))
19282 else if (unformat (i, "remote"))
19288 errmsg ("parse error '%U'", format_unformat_error, i);
19293 if (!vam->json_output)
19295 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
19296 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
19299 M (ONE_EID_TABLE_DUMP, mp);
19301 mp->filter = filter;
19305 mp->vni = htonl (vni);
19306 mp->eid_type = eid_type;
19310 mp->prefix_length = prefix_length;
19311 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
19314 mp->prefix_length = prefix_length;
19315 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
19318 clib_memcpy (mp->eid, mac, sizeof (mac));
19321 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
19324 errmsg ("unknown EID type %d!", eid_type);
19332 /* Use a control ping for synchronization */
19333 MPING (CONTROL_PING, mp_ping);
19336 /* Wait for a reply... */
19341 #define api_lisp_eid_table_dump api_one_eid_table_dump
19344 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
19346 unformat_input_t *i = vam->input;
19347 vl_api_gpe_fwd_entries_get_t *mp;
19352 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19354 if (unformat (i, "vni %d", &vni))
19360 errmsg ("parse error '%U'", format_unformat_error, i);
19367 errmsg ("vni not set!");
19371 if (!vam->json_output)
19373 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
19377 M (GPE_FWD_ENTRIES_GET, mp);
19378 mp->vni = clib_host_to_net_u32 (vni);
19383 /* Wait for a reply... */
19388 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
19389 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
19390 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
19391 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
19392 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
19393 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
19394 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
19395 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
19398 api_one_adjacencies_get (vat_main_t * vam)
19400 unformat_input_t *i = vam->input;
19401 vl_api_one_adjacencies_get_t *mp;
19406 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19408 if (unformat (i, "vni %d", &vni))
19414 errmsg ("parse error '%U'", format_unformat_error, i);
19421 errmsg ("vni not set!");
19425 if (!vam->json_output)
19427 print (vam->ofp, "%s %40s", "leid", "reid");
19430 M (ONE_ADJACENCIES_GET, mp);
19431 mp->vni = clib_host_to_net_u32 (vni);
19436 /* Wait for a reply... */
19441 #define api_lisp_adjacencies_get api_one_adjacencies_get
19444 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
19446 unformat_input_t *i = vam->input;
19447 vl_api_gpe_native_fwd_rpaths_get_t *mp;
19449 u8 ip_family_set = 0, is_ip4 = 1;
19451 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19453 if (unformat (i, "ip4"))
19458 else if (unformat (i, "ip6"))
19465 errmsg ("parse error '%U'", format_unformat_error, i);
19470 if (!ip_family_set)
19472 errmsg ("ip family not set!");
19476 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
19477 mp->is_ip4 = is_ip4;
19482 /* Wait for a reply... */
19488 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
19490 vl_api_gpe_fwd_entry_vnis_get_t *mp;
19493 if (!vam->json_output)
19495 print (vam->ofp, "VNIs");
19498 M (GPE_FWD_ENTRY_VNIS_GET, mp);
19503 /* Wait for a reply... */
19509 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
19511 unformat_input_t *i = vam->input;
19512 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
19514 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
19515 struct in_addr ip4;
19516 struct in6_addr ip6;
19517 u32 table_id = 0, nh_sw_if_index = ~0;
19519 memset (&ip4, 0, sizeof (ip4));
19520 memset (&ip6, 0, sizeof (ip6));
19522 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19524 if (unformat (i, "del"))
19526 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
19527 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19532 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
19533 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19538 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
19542 nh_sw_if_index = ~0;
19544 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
19548 nh_sw_if_index = ~0;
19550 else if (unformat (i, "table %d", &table_id))
19554 errmsg ("parse error '%U'", format_unformat_error, i);
19561 errmsg ("nh addr not set!");
19565 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
19566 mp->is_add = is_add;
19567 mp->table_id = clib_host_to_net_u32 (table_id);
19568 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
19569 mp->is_ip4 = is_ip4;
19571 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
19573 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
19578 /* Wait for a reply... */
19584 api_one_map_server_dump (vat_main_t * vam)
19586 vl_api_one_map_server_dump_t *mp;
19587 vl_api_control_ping_t *mp_ping;
19590 if (!vam->json_output)
19592 print (vam->ofp, "%=20s", "Map server");
19595 M (ONE_MAP_SERVER_DUMP, mp);
19599 /* Use a control ping for synchronization */
19600 MPING (CONTROL_PING, mp_ping);
19603 /* Wait for a reply... */
19608 #define api_lisp_map_server_dump api_one_map_server_dump
19611 api_one_map_resolver_dump (vat_main_t * vam)
19613 vl_api_one_map_resolver_dump_t *mp;
19614 vl_api_control_ping_t *mp_ping;
19617 if (!vam->json_output)
19619 print (vam->ofp, "%=20s", "Map resolver");
19622 M (ONE_MAP_RESOLVER_DUMP, mp);
19626 /* Use a control ping for synchronization */
19627 MPING (CONTROL_PING, mp_ping);
19630 /* Wait for a reply... */
19635 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
19638 api_one_stats_flush (vat_main_t * vam)
19640 vl_api_one_stats_flush_t *mp;
19643 M (ONE_STATS_FLUSH, mp);
19650 api_one_stats_dump (vat_main_t * vam)
19652 vl_api_one_stats_dump_t *mp;
19653 vl_api_control_ping_t *mp_ping;
19656 M (ONE_STATS_DUMP, mp);
19660 /* Use a control ping for synchronization */
19661 MPING (CONTROL_PING, mp_ping);
19664 /* Wait for a reply... */
19670 api_show_one_status (vat_main_t * vam)
19672 vl_api_show_one_status_t *mp;
19675 if (!vam->json_output)
19677 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
19680 M (SHOW_ONE_STATUS, mp);
19683 /* Wait for a reply... */
19688 #define api_show_lisp_status api_show_one_status
19691 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
19693 vl_api_gpe_fwd_entry_path_dump_t *mp;
19694 vl_api_control_ping_t *mp_ping;
19695 unformat_input_t *i = vam->input;
19696 u32 fwd_entry_index = ~0;
19699 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19701 if (unformat (i, "index %d", &fwd_entry_index))
19707 if (~0 == fwd_entry_index)
19709 errmsg ("no index specified!");
19713 if (!vam->json_output)
19715 print (vam->ofp, "first line");
19718 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
19722 /* Use a control ping for synchronization */
19723 MPING (CONTROL_PING, mp_ping);
19726 /* Wait for a reply... */
19732 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
19734 vl_api_one_get_map_request_itr_rlocs_t *mp;
19737 if (!vam->json_output)
19739 print (vam->ofp, "%=20s", "itr-rlocs:");
19742 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
19745 /* Wait for a reply... */
19750 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
19753 api_af_packet_create (vat_main_t * vam)
19755 unformat_input_t *i = vam->input;
19756 vl_api_af_packet_create_t *mp;
19757 u8 *host_if_name = 0;
19759 u8 random_hw_addr = 1;
19762 memset (hw_addr, 0, sizeof (hw_addr));
19764 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19766 if (unformat (i, "name %s", &host_if_name))
19767 vec_add1 (host_if_name, 0);
19768 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19769 random_hw_addr = 0;
19774 if (!vec_len (host_if_name))
19776 errmsg ("host-interface name must be specified");
19780 if (vec_len (host_if_name) > 64)
19782 errmsg ("host-interface name too long");
19786 M (AF_PACKET_CREATE, mp);
19788 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19789 clib_memcpy (mp->hw_addr, hw_addr, 6);
19790 mp->use_random_hw_addr = random_hw_addr;
19791 vec_free (host_if_name);
19799 fprintf (vam->ofp ? vam->ofp : stderr,
19800 " new sw_if_index = %d\n", vam->sw_if_index);
19807 api_af_packet_delete (vat_main_t * vam)
19809 unformat_input_t *i = vam->input;
19810 vl_api_af_packet_delete_t *mp;
19811 u8 *host_if_name = 0;
19814 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19816 if (unformat (i, "name %s", &host_if_name))
19817 vec_add1 (host_if_name, 0);
19822 if (!vec_len (host_if_name))
19824 errmsg ("host-interface name must be specified");
19828 if (vec_len (host_if_name) > 64)
19830 errmsg ("host-interface name too long");
19834 M (AF_PACKET_DELETE, mp);
19836 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19837 vec_free (host_if_name);
19845 api_policer_add_del (vat_main_t * vam)
19847 unformat_input_t *i = vam->input;
19848 vl_api_policer_add_del_t *mp;
19858 u8 color_aware = 0;
19859 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
19862 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
19863 conform_action.dscp = 0;
19864 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
19865 exceed_action.dscp = 0;
19866 violate_action.action_type = SSE2_QOS_ACTION_DROP;
19867 violate_action.dscp = 0;
19869 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19871 if (unformat (i, "del"))
19873 else if (unformat (i, "name %s", &name))
19874 vec_add1 (name, 0);
19875 else if (unformat (i, "cir %u", &cir))
19877 else if (unformat (i, "eir %u", &eir))
19879 else if (unformat (i, "cb %u", &cb))
19881 else if (unformat (i, "eb %u", &eb))
19883 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
19886 else if (unformat (i, "round_type %U", unformat_policer_round_type,
19889 else if (unformat (i, "type %U", unformat_policer_type, &type))
19891 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
19894 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
19897 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
19900 else if (unformat (i, "color-aware"))
19906 if (!vec_len (name))
19908 errmsg ("policer name must be specified");
19912 if (vec_len (name) > 64)
19914 errmsg ("policer name too long");
19918 M (POLICER_ADD_DEL, mp);
19920 clib_memcpy (mp->name, name, vec_len (name));
19922 mp->is_add = is_add;
19923 mp->cir = ntohl (cir);
19924 mp->eir = ntohl (eir);
19925 mp->cb = clib_net_to_host_u64 (cb);
19926 mp->eb = clib_net_to_host_u64 (eb);
19927 mp->rate_type = rate_type;
19928 mp->round_type = round_type;
19930 mp->conform_action_type = conform_action.action_type;
19931 mp->conform_dscp = conform_action.dscp;
19932 mp->exceed_action_type = exceed_action.action_type;
19933 mp->exceed_dscp = exceed_action.dscp;
19934 mp->violate_action_type = violate_action.action_type;
19935 mp->violate_dscp = violate_action.dscp;
19936 mp->color_aware = color_aware;
19944 api_policer_dump (vat_main_t * vam)
19946 unformat_input_t *i = vam->input;
19947 vl_api_policer_dump_t *mp;
19948 vl_api_control_ping_t *mp_ping;
19949 u8 *match_name = 0;
19950 u8 match_name_valid = 0;
19953 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19955 if (unformat (i, "name %s", &match_name))
19957 vec_add1 (match_name, 0);
19958 match_name_valid = 1;
19964 M (POLICER_DUMP, mp);
19965 mp->match_name_valid = match_name_valid;
19966 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
19967 vec_free (match_name);
19971 /* Use a control ping for synchronization */
19972 MPING (CONTROL_PING, mp_ping);
19975 /* Wait for a reply... */
19981 api_policer_classify_set_interface (vat_main_t * vam)
19983 unformat_input_t *i = vam->input;
19984 vl_api_policer_classify_set_interface_t *mp;
19986 int sw_if_index_set;
19987 u32 ip4_table_index = ~0;
19988 u32 ip6_table_index = ~0;
19989 u32 l2_table_index = ~0;
19993 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19995 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19996 sw_if_index_set = 1;
19997 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19998 sw_if_index_set = 1;
19999 else if (unformat (i, "del"))
20001 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20003 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20005 else if (unformat (i, "l2-table %d", &l2_table_index))
20009 clib_warning ("parse error '%U'", format_unformat_error, i);
20014 if (sw_if_index_set == 0)
20016 errmsg ("missing interface name or sw_if_index");
20020 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
20022 mp->sw_if_index = ntohl (sw_if_index);
20023 mp->ip4_table_index = ntohl (ip4_table_index);
20024 mp->ip6_table_index = ntohl (ip6_table_index);
20025 mp->l2_table_index = ntohl (l2_table_index);
20026 mp->is_add = is_add;
20034 api_policer_classify_dump (vat_main_t * vam)
20036 unformat_input_t *i = vam->input;
20037 vl_api_policer_classify_dump_t *mp;
20038 vl_api_control_ping_t *mp_ping;
20039 u8 type = POLICER_CLASSIFY_N_TABLES;
20042 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
20046 errmsg ("classify table type must be specified");
20050 if (!vam->json_output)
20052 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20055 M (POLICER_CLASSIFY_DUMP, mp);
20060 /* Use a control ping for synchronization */
20061 MPING (CONTROL_PING, mp_ping);
20064 /* Wait for a reply... */
20070 api_netmap_create (vat_main_t * vam)
20072 unformat_input_t *i = vam->input;
20073 vl_api_netmap_create_t *mp;
20076 u8 random_hw_addr = 1;
20081 memset (hw_addr, 0, sizeof (hw_addr));
20083 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20085 if (unformat (i, "name %s", &if_name))
20086 vec_add1 (if_name, 0);
20087 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
20088 random_hw_addr = 0;
20089 else if (unformat (i, "pipe"))
20091 else if (unformat (i, "master"))
20093 else if (unformat (i, "slave"))
20099 if (!vec_len (if_name))
20101 errmsg ("interface name must be specified");
20105 if (vec_len (if_name) > 64)
20107 errmsg ("interface name too long");
20111 M (NETMAP_CREATE, mp);
20113 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20114 clib_memcpy (mp->hw_addr, hw_addr, 6);
20115 mp->use_random_hw_addr = random_hw_addr;
20116 mp->is_pipe = is_pipe;
20117 mp->is_master = is_master;
20118 vec_free (if_name);
20126 api_netmap_delete (vat_main_t * vam)
20128 unformat_input_t *i = vam->input;
20129 vl_api_netmap_delete_t *mp;
20133 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20135 if (unformat (i, "name %s", &if_name))
20136 vec_add1 (if_name, 0);
20141 if (!vec_len (if_name))
20143 errmsg ("interface name must be specified");
20147 if (vec_len (if_name) > 64)
20149 errmsg ("interface name too long");
20153 M (NETMAP_DELETE, mp);
20155 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20156 vec_free (if_name);
20164 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
20166 if (fp->afi == IP46_TYPE_IP6)
20168 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20169 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20170 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20171 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20172 format_ip6_address, fp->next_hop);
20173 else if (fp->afi == IP46_TYPE_IP4)
20175 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20176 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20177 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20178 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20179 format_ip4_address, fp->next_hop);
20183 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
20184 vl_api_fib_path_t * fp)
20186 struct in_addr ip4;
20187 struct in6_addr ip6;
20189 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20190 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20191 vat_json_object_add_uint (node, "is_local", fp->is_local);
20192 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20193 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20194 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20195 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20196 if (fp->afi == IP46_TYPE_IP4)
20198 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20199 vat_json_object_add_ip4 (node, "next_hop", ip4);
20201 else if (fp->afi == IP46_TYPE_IP6)
20203 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20204 vat_json_object_add_ip6 (node, "next_hop", ip6);
20209 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
20211 vat_main_t *vam = &vat_main;
20212 int count = ntohl (mp->mt_count);
20213 vl_api_fib_path_t *fp;
20216 print (vam->ofp, "[%d]: sw_if_index %d via:",
20217 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
20219 for (i = 0; i < count; i++)
20221 vl_api_mpls_fib_path_print (vam, fp);
20225 print (vam->ofp, "");
20228 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
20229 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
20232 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
20234 vat_main_t *vam = &vat_main;
20235 vat_json_node_t *node = NULL;
20236 int count = ntohl (mp->mt_count);
20237 vl_api_fib_path_t *fp;
20240 if (VAT_JSON_ARRAY != vam->json_tree.type)
20242 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20243 vat_json_init_array (&vam->json_tree);
20245 node = vat_json_array_add (&vam->json_tree);
20247 vat_json_init_object (node);
20248 vat_json_object_add_uint (node, "tunnel_index",
20249 ntohl (mp->mt_tunnel_index));
20250 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
20252 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
20255 for (i = 0; i < count; i++)
20257 vl_api_mpls_fib_path_json_print (node, fp);
20263 api_mpls_tunnel_dump (vat_main_t * vam)
20265 vl_api_mpls_tunnel_dump_t *mp;
20266 vl_api_control_ping_t *mp_ping;
20270 /* Parse args required to build the message */
20271 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
20273 if (!unformat (vam->input, "tunnel_index %d", &index))
20280 print (vam->ofp, " tunnel_index %d", index);
20282 M (MPLS_TUNNEL_DUMP, mp);
20283 mp->tunnel_index = htonl (index);
20286 /* Use a control ping for synchronization */
20287 MPING (CONTROL_PING, mp_ping);
20294 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
20295 #define vl_api_mpls_fib_details_t_print vl_noop_handler
20299 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
20301 vat_main_t *vam = &vat_main;
20302 int count = ntohl (mp->count);
20303 vl_api_fib_path_t *fp;
20307 "table-id %d, label %u, ess_bit %u",
20308 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
20310 for (i = 0; i < count; i++)
20312 vl_api_mpls_fib_path_print (vam, fp);
20317 static void vl_api_mpls_fib_details_t_handler_json
20318 (vl_api_mpls_fib_details_t * mp)
20320 vat_main_t *vam = &vat_main;
20321 int count = ntohl (mp->count);
20322 vat_json_node_t *node = NULL;
20323 vl_api_fib_path_t *fp;
20326 if (VAT_JSON_ARRAY != vam->json_tree.type)
20328 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20329 vat_json_init_array (&vam->json_tree);
20331 node = vat_json_array_add (&vam->json_tree);
20333 vat_json_init_object (node);
20334 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20335 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
20336 vat_json_object_add_uint (node, "label", ntohl (mp->label));
20337 vat_json_object_add_uint (node, "path_count", count);
20339 for (i = 0; i < count; i++)
20341 vl_api_mpls_fib_path_json_print (node, fp);
20347 api_mpls_fib_dump (vat_main_t * vam)
20349 vl_api_mpls_fib_dump_t *mp;
20350 vl_api_control_ping_t *mp_ping;
20353 M (MPLS_FIB_DUMP, mp);
20356 /* Use a control ping for synchronization */
20357 MPING (CONTROL_PING, mp_ping);
20364 #define vl_api_ip_fib_details_t_endian vl_noop_handler
20365 #define vl_api_ip_fib_details_t_print vl_noop_handler
20368 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
20370 vat_main_t *vam = &vat_main;
20371 int count = ntohl (mp->count);
20372 vl_api_fib_path_t *fp;
20376 "table-id %d, prefix %U/%d",
20377 ntohl (mp->table_id), format_ip4_address, mp->address,
20378 mp->address_length);
20380 for (i = 0; i < count; i++)
20382 if (fp->afi == IP46_TYPE_IP6)
20384 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20385 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20386 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20387 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20388 format_ip6_address, fp->next_hop);
20389 else if (fp->afi == IP46_TYPE_IP4)
20391 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20392 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20393 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20394 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20395 format_ip4_address, fp->next_hop);
20400 static void vl_api_ip_fib_details_t_handler_json
20401 (vl_api_ip_fib_details_t * mp)
20403 vat_main_t *vam = &vat_main;
20404 int count = ntohl (mp->count);
20405 vat_json_node_t *node = NULL;
20406 struct in_addr ip4;
20407 struct in6_addr ip6;
20408 vl_api_fib_path_t *fp;
20411 if (VAT_JSON_ARRAY != vam->json_tree.type)
20413 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20414 vat_json_init_array (&vam->json_tree);
20416 node = vat_json_array_add (&vam->json_tree);
20418 vat_json_init_object (node);
20419 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20420 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
20421 vat_json_object_add_ip4 (node, "prefix", ip4);
20422 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20423 vat_json_object_add_uint (node, "path_count", count);
20425 for (i = 0; i < count; i++)
20427 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20428 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20429 vat_json_object_add_uint (node, "is_local", fp->is_local);
20430 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20431 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20432 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20433 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20434 if (fp->afi == IP46_TYPE_IP4)
20436 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20437 vat_json_object_add_ip4 (node, "next_hop", ip4);
20439 else if (fp->afi == IP46_TYPE_IP6)
20441 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20442 vat_json_object_add_ip6 (node, "next_hop", ip6);
20448 api_ip_fib_dump (vat_main_t * vam)
20450 vl_api_ip_fib_dump_t *mp;
20451 vl_api_control_ping_t *mp_ping;
20454 M (IP_FIB_DUMP, mp);
20457 /* Use a control ping for synchronization */
20458 MPING (CONTROL_PING, mp_ping);
20466 api_ip_mfib_dump (vat_main_t * vam)
20468 vl_api_ip_mfib_dump_t *mp;
20469 vl_api_control_ping_t *mp_ping;
20472 M (IP_MFIB_DUMP, mp);
20475 /* Use a control ping for synchronization */
20476 MPING (CONTROL_PING, mp_ping);
20483 static void vl_api_ip_neighbor_details_t_handler
20484 (vl_api_ip_neighbor_details_t * mp)
20486 vat_main_t *vam = &vat_main;
20488 print (vam->ofp, "%c %U %U",
20489 (mp->is_static) ? 'S' : 'D',
20490 format_ethernet_address, &mp->mac_address,
20491 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
20495 static void vl_api_ip_neighbor_details_t_handler_json
20496 (vl_api_ip_neighbor_details_t * mp)
20499 vat_main_t *vam = &vat_main;
20500 vat_json_node_t *node;
20501 struct in_addr ip4;
20502 struct in6_addr ip6;
20504 if (VAT_JSON_ARRAY != vam->json_tree.type)
20506 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20507 vat_json_init_array (&vam->json_tree);
20509 node = vat_json_array_add (&vam->json_tree);
20511 vat_json_init_object (node);
20512 vat_json_object_add_string_copy (node, "flag",
20513 (mp->is_static) ? (u8 *) "static" : (u8 *)
20516 vat_json_object_add_string_copy (node, "link_layer",
20517 format (0, "%U", format_ethernet_address,
20518 &mp->mac_address));
20522 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
20523 vat_json_object_add_ip6 (node, "ip_address", ip6);
20527 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
20528 vat_json_object_add_ip4 (node, "ip_address", ip4);
20533 api_ip_neighbor_dump (vat_main_t * vam)
20535 unformat_input_t *i = vam->input;
20536 vl_api_ip_neighbor_dump_t *mp;
20537 vl_api_control_ping_t *mp_ping;
20539 u32 sw_if_index = ~0;
20542 /* Parse args required to build the message */
20543 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20545 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20547 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20549 else if (unformat (i, "ip6"))
20555 if (sw_if_index == ~0)
20557 errmsg ("missing interface name or sw_if_index");
20561 M (IP_NEIGHBOR_DUMP, mp);
20562 mp->is_ipv6 = (u8) is_ipv6;
20563 mp->sw_if_index = ntohl (sw_if_index);
20566 /* Use a control ping for synchronization */
20567 MPING (CONTROL_PING, mp_ping);
20574 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
20575 #define vl_api_ip6_fib_details_t_print vl_noop_handler
20578 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
20580 vat_main_t *vam = &vat_main;
20581 int count = ntohl (mp->count);
20582 vl_api_fib_path_t *fp;
20586 "table-id %d, prefix %U/%d",
20587 ntohl (mp->table_id), format_ip6_address, mp->address,
20588 mp->address_length);
20590 for (i = 0; i < count; i++)
20592 if (fp->afi == IP46_TYPE_IP6)
20594 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20595 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20596 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20597 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20598 format_ip6_address, fp->next_hop);
20599 else if (fp->afi == IP46_TYPE_IP4)
20601 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20602 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20603 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20604 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20605 format_ip4_address, fp->next_hop);
20610 static void vl_api_ip6_fib_details_t_handler_json
20611 (vl_api_ip6_fib_details_t * mp)
20613 vat_main_t *vam = &vat_main;
20614 int count = ntohl (mp->count);
20615 vat_json_node_t *node = NULL;
20616 struct in_addr ip4;
20617 struct in6_addr ip6;
20618 vl_api_fib_path_t *fp;
20621 if (VAT_JSON_ARRAY != vam->json_tree.type)
20623 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20624 vat_json_init_array (&vam->json_tree);
20626 node = vat_json_array_add (&vam->json_tree);
20628 vat_json_init_object (node);
20629 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20630 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
20631 vat_json_object_add_ip6 (node, "prefix", ip6);
20632 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20633 vat_json_object_add_uint (node, "path_count", count);
20635 for (i = 0; i < count; i++)
20637 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20638 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20639 vat_json_object_add_uint (node, "is_local", fp->is_local);
20640 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20641 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20642 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20643 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20644 if (fp->afi == IP46_TYPE_IP4)
20646 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20647 vat_json_object_add_ip4 (node, "next_hop", ip4);
20649 else if (fp->afi == IP46_TYPE_IP6)
20651 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20652 vat_json_object_add_ip6 (node, "next_hop", ip6);
20658 api_ip6_fib_dump (vat_main_t * vam)
20660 vl_api_ip6_fib_dump_t *mp;
20661 vl_api_control_ping_t *mp_ping;
20664 M (IP6_FIB_DUMP, mp);
20667 /* Use a control ping for synchronization */
20668 MPING (CONTROL_PING, mp_ping);
20676 api_ip6_mfib_dump (vat_main_t * vam)
20678 vl_api_ip6_mfib_dump_t *mp;
20679 vl_api_control_ping_t *mp_ping;
20682 M (IP6_MFIB_DUMP, mp);
20685 /* Use a control ping for synchronization */
20686 MPING (CONTROL_PING, mp_ping);
20694 api_classify_table_ids (vat_main_t * vam)
20696 vl_api_classify_table_ids_t *mp;
20699 /* Construct the API message */
20700 M (CLASSIFY_TABLE_IDS, mp);
20709 api_classify_table_by_interface (vat_main_t * vam)
20711 unformat_input_t *input = vam->input;
20712 vl_api_classify_table_by_interface_t *mp;
20714 u32 sw_if_index = ~0;
20716 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20718 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20720 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20725 if (sw_if_index == ~0)
20727 errmsg ("missing interface name or sw_if_index");
20731 /* Construct the API message */
20732 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
20734 mp->sw_if_index = ntohl (sw_if_index);
20742 api_classify_table_info (vat_main_t * vam)
20744 unformat_input_t *input = vam->input;
20745 vl_api_classify_table_info_t *mp;
20749 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20751 if (unformat (input, "table_id %d", &table_id))
20756 if (table_id == ~0)
20758 errmsg ("missing table id");
20762 /* Construct the API message */
20763 M (CLASSIFY_TABLE_INFO, mp);
20765 mp->table_id = ntohl (table_id);
20773 api_classify_session_dump (vat_main_t * vam)
20775 unformat_input_t *input = vam->input;
20776 vl_api_classify_session_dump_t *mp;
20777 vl_api_control_ping_t *mp_ping;
20781 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20783 if (unformat (input, "table_id %d", &table_id))
20788 if (table_id == ~0)
20790 errmsg ("missing table id");
20794 /* Construct the API message */
20795 M (CLASSIFY_SESSION_DUMP, mp);
20797 mp->table_id = ntohl (table_id);
20800 /* Use a control ping for synchronization */
20801 MPING (CONTROL_PING, mp_ping);
20809 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
20811 vat_main_t *vam = &vat_main;
20813 print (vam->ofp, "collector_address %U, collector_port %d, "
20814 "src_address %U, vrf_id %d, path_mtu %u, "
20815 "template_interval %u, udp_checksum %d",
20816 format_ip4_address, mp->collector_address,
20817 ntohs (mp->collector_port),
20818 format_ip4_address, mp->src_address,
20819 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
20820 ntohl (mp->template_interval), mp->udp_checksum);
20823 vam->result_ready = 1;
20827 vl_api_ipfix_exporter_details_t_handler_json
20828 (vl_api_ipfix_exporter_details_t * mp)
20830 vat_main_t *vam = &vat_main;
20831 vat_json_node_t node;
20832 struct in_addr collector_address;
20833 struct in_addr src_address;
20835 vat_json_init_object (&node);
20836 clib_memcpy (&collector_address, &mp->collector_address,
20837 sizeof (collector_address));
20838 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
20839 vat_json_object_add_uint (&node, "collector_port",
20840 ntohs (mp->collector_port));
20841 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
20842 vat_json_object_add_ip4 (&node, "src_address", src_address);
20843 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
20844 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
20845 vat_json_object_add_uint (&node, "template_interval",
20846 ntohl (mp->template_interval));
20847 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
20849 vat_json_print (vam->ofp, &node);
20850 vat_json_free (&node);
20852 vam->result_ready = 1;
20856 api_ipfix_exporter_dump (vat_main_t * vam)
20858 vl_api_ipfix_exporter_dump_t *mp;
20861 /* Construct the API message */
20862 M (IPFIX_EXPORTER_DUMP, mp);
20871 api_ipfix_classify_stream_dump (vat_main_t * vam)
20873 vl_api_ipfix_classify_stream_dump_t *mp;
20876 /* Construct the API message */
20877 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
20888 vl_api_ipfix_classify_stream_details_t_handler
20889 (vl_api_ipfix_classify_stream_details_t * mp)
20891 vat_main_t *vam = &vat_main;
20892 print (vam->ofp, "domain_id %d, src_port %d",
20893 ntohl (mp->domain_id), ntohs (mp->src_port));
20895 vam->result_ready = 1;
20899 vl_api_ipfix_classify_stream_details_t_handler_json
20900 (vl_api_ipfix_classify_stream_details_t * mp)
20902 vat_main_t *vam = &vat_main;
20903 vat_json_node_t node;
20905 vat_json_init_object (&node);
20906 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
20907 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
20909 vat_json_print (vam->ofp, &node);
20910 vat_json_free (&node);
20912 vam->result_ready = 1;
20916 api_ipfix_classify_table_dump (vat_main_t * vam)
20918 vl_api_ipfix_classify_table_dump_t *mp;
20919 vl_api_control_ping_t *mp_ping;
20922 if (!vam->json_output)
20924 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
20925 "transport_protocol");
20928 /* Construct the API message */
20929 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
20934 /* Use a control ping for synchronization */
20935 MPING (CONTROL_PING, mp_ping);
20943 vl_api_ipfix_classify_table_details_t_handler
20944 (vl_api_ipfix_classify_table_details_t * mp)
20946 vat_main_t *vam = &vat_main;
20947 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
20948 mp->transport_protocol);
20952 vl_api_ipfix_classify_table_details_t_handler_json
20953 (vl_api_ipfix_classify_table_details_t * mp)
20955 vat_json_node_t *node = NULL;
20956 vat_main_t *vam = &vat_main;
20958 if (VAT_JSON_ARRAY != vam->json_tree.type)
20960 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20961 vat_json_init_array (&vam->json_tree);
20964 node = vat_json_array_add (&vam->json_tree);
20965 vat_json_init_object (node);
20967 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
20968 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
20969 vat_json_object_add_uint (node, "transport_protocol",
20970 mp->transport_protocol);
20974 api_sw_interface_span_enable_disable (vat_main_t * vam)
20976 unformat_input_t *i = vam->input;
20977 vl_api_sw_interface_span_enable_disable_t *mp;
20978 u32 src_sw_if_index = ~0;
20979 u32 dst_sw_if_index = ~0;
20984 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20987 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
20989 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
20993 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
20995 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
20997 else if (unformat (i, "disable"))
20999 else if (unformat (i, "rx"))
21001 else if (unformat (i, "tx"))
21003 else if (unformat (i, "both"))
21005 else if (unformat (i, "l2"))
21011 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
21013 mp->sw_if_index_from = htonl (src_sw_if_index);
21014 mp->sw_if_index_to = htonl (dst_sw_if_index);
21024 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
21027 vat_main_t *vam = &vat_main;
21028 u8 *sw_if_from_name = 0;
21029 u8 *sw_if_to_name = 0;
21030 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
21031 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
21032 char *states[] = { "none", "rx", "tx", "both" };
21036 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
21038 if ((u32) p->value[0] == sw_if_index_from)
21040 sw_if_from_name = (u8 *)(p->key);
21044 if ((u32) p->value[0] == sw_if_index_to)
21046 sw_if_to_name = (u8 *)(p->key);
21047 if (sw_if_from_name)
21052 print (vam->ofp, "%20s => %20s (%s) %s",
21053 sw_if_from_name, sw_if_to_name, states[mp->state],
21054 mp->is_l2 ? "l2" : "device");
21058 vl_api_sw_interface_span_details_t_handler_json
21059 (vl_api_sw_interface_span_details_t * mp)
21061 vat_main_t *vam = &vat_main;
21062 vat_json_node_t *node = NULL;
21063 u8 *sw_if_from_name = 0;
21064 u8 *sw_if_to_name = 0;
21065 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
21066 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
21070 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
21072 if ((u32) p->value[0] == sw_if_index_from)
21074 sw_if_from_name = (u8 *)(p->key);
21078 if ((u32) p->value[0] == sw_if_index_to)
21080 sw_if_to_name = (u8 *)(p->key);
21081 if (sw_if_from_name)
21087 if (VAT_JSON_ARRAY != vam->json_tree.type)
21089 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21090 vat_json_init_array (&vam->json_tree);
21092 node = vat_json_array_add (&vam->json_tree);
21094 vat_json_init_object (node);
21095 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
21096 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
21097 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
21098 if (0 != sw_if_to_name)
21100 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
21102 vat_json_object_add_uint (node, "state", mp->state);
21103 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
21107 api_sw_interface_span_dump (vat_main_t * vam)
21109 unformat_input_t *input = vam->input;
21110 vl_api_sw_interface_span_dump_t *mp;
21111 vl_api_control_ping_t *mp_ping;
21115 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21117 if (unformat (input, "l2"))
21123 M (SW_INTERFACE_SPAN_DUMP, mp);
21127 /* Use a control ping for synchronization */
21128 MPING (CONTROL_PING, mp_ping);
21136 api_pg_create_interface (vat_main_t * vam)
21138 unformat_input_t *input = vam->input;
21139 vl_api_pg_create_interface_t *mp;
21143 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21145 if (unformat (input, "if_id %d", &if_id))
21152 errmsg ("missing pg interface index");
21156 /* Construct the API message */
21157 M (PG_CREATE_INTERFACE, mp);
21159 mp->interface_id = ntohl (if_id);
21167 api_pg_capture (vat_main_t * vam)
21169 unformat_input_t *input = vam->input;
21170 vl_api_pg_capture_t *mp;
21175 u8 pcap_file_set = 0;
21178 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21180 if (unformat (input, "if_id %d", &if_id))
21182 else if (unformat (input, "pcap %s", &pcap_file))
21184 else if (unformat (input, "count %d", &count))
21186 else if (unformat (input, "disable"))
21193 errmsg ("missing pg interface index");
21196 if (pcap_file_set > 0)
21198 if (vec_len (pcap_file) > 255)
21200 errmsg ("pcap file name is too long");
21205 u32 name_len = vec_len (pcap_file);
21206 /* Construct the API message */
21207 M (PG_CAPTURE, mp);
21209 mp->interface_id = ntohl (if_id);
21210 mp->is_enabled = enable;
21211 mp->count = ntohl (count);
21212 mp->pcap_name_length = ntohl (name_len);
21213 if (pcap_file_set != 0)
21215 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
21217 vec_free (pcap_file);
21225 api_pg_enable_disable (vat_main_t * vam)
21227 unformat_input_t *input = vam->input;
21228 vl_api_pg_enable_disable_t *mp;
21231 u8 stream_name_set = 0;
21232 u8 *stream_name = 0;
21234 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21236 if (unformat (input, "stream %s", &stream_name))
21237 stream_name_set = 1;
21238 else if (unformat (input, "disable"))
21244 if (stream_name_set > 0)
21246 if (vec_len (stream_name) > 255)
21248 errmsg ("stream name too long");
21253 u32 name_len = vec_len (stream_name);
21254 /* Construct the API message */
21255 M (PG_ENABLE_DISABLE, mp);
21257 mp->is_enabled = enable;
21258 if (stream_name_set != 0)
21260 mp->stream_name_length = ntohl (name_len);
21261 clib_memcpy (mp->stream_name, stream_name, name_len);
21263 vec_free (stream_name);
21271 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
21273 unformat_input_t *input = vam->input;
21274 vl_api_ip_source_and_port_range_check_add_del_t *mp;
21276 u16 *low_ports = 0;
21277 u16 *high_ports = 0;
21280 ip4_address_t ip4_addr;
21281 ip6_address_t ip6_addr;
21290 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21292 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
21298 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
21303 else if (unformat (input, "vrf %d", &vrf_id))
21305 else if (unformat (input, "del"))
21307 else if (unformat (input, "port %d", &tmp))
21309 if (tmp == 0 || tmp > 65535)
21311 errmsg ("port %d out of range", tmp);
21315 this_hi = this_low + 1;
21316 vec_add1 (low_ports, this_low);
21317 vec_add1 (high_ports, this_hi);
21319 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
21321 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
21323 errmsg ("incorrect range parameters");
21327 /* Note: in debug CLI +1 is added to high before
21328 passing to real fn that does "the work"
21329 (ip_source_and_port_range_check_add_del).
21330 This fn is a wrapper around the binary API fn a
21331 control plane will call, which expects this increment
21332 to have occurred. Hence letting the binary API control
21333 plane fn do the increment for consistency between VAT
21334 and other control planes.
21337 vec_add1 (low_ports, this_low);
21338 vec_add1 (high_ports, this_hi);
21344 if (prefix_set == 0)
21346 errmsg ("<address>/<mask> not specified");
21352 errmsg ("VRF ID required, not specified");
21359 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21363 if (vec_len (low_ports) == 0)
21365 errmsg ("At least one port or port range required");
21369 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
21371 mp->is_add = is_add;
21376 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
21381 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
21384 mp->mask_length = length;
21385 mp->number_of_ranges = vec_len (low_ports);
21387 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
21388 vec_free (low_ports);
21390 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
21391 vec_free (high_ports);
21393 mp->vrf_id = ntohl (vrf_id);
21401 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
21403 unformat_input_t *input = vam->input;
21404 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
21405 u32 sw_if_index = ~0;
21407 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
21408 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
21412 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21414 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21416 else if (unformat (input, "sw_if_index %d", &sw_if_index))
21418 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
21420 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
21422 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
21424 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
21426 else if (unformat (input, "del"))
21432 if (sw_if_index == ~0)
21434 errmsg ("Interface required but not specified");
21440 errmsg ("VRF ID required but not specified");
21444 if (tcp_out_vrf_id == 0
21445 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
21448 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21452 /* Construct the API message */
21453 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
21455 mp->sw_if_index = ntohl (sw_if_index);
21456 mp->is_add = is_add;
21457 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
21458 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
21459 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
21460 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
21465 /* Wait for a reply... */
21471 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
21473 unformat_input_t *i = vam->input;
21474 vl_api_ipsec_gre_add_del_tunnel_t *mp;
21475 u32 local_sa_id = 0;
21476 u32 remote_sa_id = 0;
21477 ip4_address_t src_address;
21478 ip4_address_t dst_address;
21482 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21484 if (unformat (i, "local_sa %d", &local_sa_id))
21486 else if (unformat (i, "remote_sa %d", &remote_sa_id))
21488 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
21490 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
21492 else if (unformat (i, "del"))
21496 clib_warning ("parse error '%U'", format_unformat_error, i);
21501 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
21503 mp->local_sa_id = ntohl (local_sa_id);
21504 mp->remote_sa_id = ntohl (remote_sa_id);
21505 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
21506 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
21507 mp->is_add = is_add;
21515 api_punt (vat_main_t * vam)
21517 unformat_input_t *i = vam->input;
21525 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21527 if (unformat (i, "ip %d", &ipv))
21529 else if (unformat (i, "protocol %d", &protocol))
21531 else if (unformat (i, "port %d", &port))
21533 else if (unformat (i, "del"))
21537 clib_warning ("parse error '%U'", format_unformat_error, i);
21544 mp->is_add = (u8) is_add;
21545 mp->ipv = (u8) ipv;
21546 mp->l4_protocol = (u8) protocol;
21547 mp->l4_port = htons ((u16) port);
21554 static void vl_api_ipsec_gre_tunnel_details_t_handler
21555 (vl_api_ipsec_gre_tunnel_details_t * mp)
21557 vat_main_t *vam = &vat_main;
21559 print (vam->ofp, "%11d%15U%15U%14d%14d",
21560 ntohl (mp->sw_if_index),
21561 format_ip4_address, &mp->src_address,
21562 format_ip4_address, &mp->dst_address,
21563 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
21566 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
21567 (vl_api_ipsec_gre_tunnel_details_t * mp)
21569 vat_main_t *vam = &vat_main;
21570 vat_json_node_t *node = NULL;
21571 struct in_addr ip4;
21573 if (VAT_JSON_ARRAY != vam->json_tree.type)
21575 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21576 vat_json_init_array (&vam->json_tree);
21578 node = vat_json_array_add (&vam->json_tree);
21580 vat_json_init_object (node);
21581 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
21582 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
21583 vat_json_object_add_ip4 (node, "src_address", ip4);
21584 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
21585 vat_json_object_add_ip4 (node, "dst_address", ip4);
21586 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
21587 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
21591 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
21593 unformat_input_t *i = vam->input;
21594 vl_api_ipsec_gre_tunnel_dump_t *mp;
21595 vl_api_control_ping_t *mp_ping;
21597 u8 sw_if_index_set = 0;
21600 /* Parse args required to build the message */
21601 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21603 if (unformat (i, "sw_if_index %d", &sw_if_index))
21604 sw_if_index_set = 1;
21609 if (sw_if_index_set == 0)
21614 if (!vam->json_output)
21616 print (vam->ofp, "%11s%15s%15s%14s%14s",
21617 "sw_if_index", "src_address", "dst_address",
21618 "local_sa_id", "remote_sa_id");
21621 /* Get list of gre-tunnel interfaces */
21622 M (IPSEC_GRE_TUNNEL_DUMP, mp);
21624 mp->sw_if_index = htonl (sw_if_index);
21628 /* Use a control ping for synchronization */
21629 MPING (CONTROL_PING, mp_ping);
21637 api_delete_subif (vat_main_t * vam)
21639 unformat_input_t *i = vam->input;
21640 vl_api_delete_subif_t *mp;
21641 u32 sw_if_index = ~0;
21644 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21646 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21648 if (unformat (i, "sw_if_index %d", &sw_if_index))
21654 if (sw_if_index == ~0)
21656 errmsg ("missing sw_if_index");
21660 /* Construct the API message */
21661 M (DELETE_SUBIF, mp);
21662 mp->sw_if_index = ntohl (sw_if_index);
21669 #define foreach_pbb_vtr_op \
21670 _("disable", L2_VTR_DISABLED) \
21671 _("pop", L2_VTR_POP_2) \
21672 _("push", L2_VTR_PUSH_2)
21675 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
21677 unformat_input_t *i = vam->input;
21678 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
21679 u32 sw_if_index = ~0, vtr_op = ~0;
21680 u16 outer_tag = ~0;
21681 u8 dmac[6], smac[6];
21682 u8 dmac_set = 0, smac_set = 0;
21688 /* Shut up coverity */
21689 memset (dmac, 0, sizeof (dmac));
21690 memset (smac, 0, sizeof (smac));
21692 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21694 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21696 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21698 else if (unformat (i, "vtr_op %d", &vtr_op))
21700 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
21703 else if (unformat (i, "translate_pbb_stag"))
21705 if (unformat (i, "%d", &tmp))
21707 vtr_op = L2_VTR_TRANSLATE_2_1;
21713 ("translate_pbb_stag operation requires outer tag definition");
21717 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
21719 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
21721 else if (unformat (i, "sid %d", &sid))
21723 else if (unformat (i, "vlanid %d", &tmp))
21727 clib_warning ("parse error '%U'", format_unformat_error, i);
21732 if ((sw_if_index == ~0) || (vtr_op == ~0))
21734 errmsg ("missing sw_if_index or vtr operation");
21737 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
21738 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
21741 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
21745 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
21746 mp->sw_if_index = ntohl (sw_if_index);
21747 mp->vtr_op = ntohl (vtr_op);
21748 mp->outer_tag = ntohs (outer_tag);
21749 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
21750 clib_memcpy (mp->b_smac, smac, sizeof (smac));
21751 mp->b_vlanid = ntohs (vlanid);
21752 mp->i_sid = ntohl (sid);
21760 api_flow_classify_set_interface (vat_main_t * vam)
21762 unformat_input_t *i = vam->input;
21763 vl_api_flow_classify_set_interface_t *mp;
21765 int sw_if_index_set;
21766 u32 ip4_table_index = ~0;
21767 u32 ip6_table_index = ~0;
21771 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21773 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21774 sw_if_index_set = 1;
21775 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21776 sw_if_index_set = 1;
21777 else if (unformat (i, "del"))
21779 else if (unformat (i, "ip4-table %d", &ip4_table_index))
21781 else if (unformat (i, "ip6-table %d", &ip6_table_index))
21785 clib_warning ("parse error '%U'", format_unformat_error, i);
21790 if (sw_if_index_set == 0)
21792 errmsg ("missing interface name or sw_if_index");
21796 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
21798 mp->sw_if_index = ntohl (sw_if_index);
21799 mp->ip4_table_index = ntohl (ip4_table_index);
21800 mp->ip6_table_index = ntohl (ip6_table_index);
21801 mp->is_add = is_add;
21809 api_flow_classify_dump (vat_main_t * vam)
21811 unformat_input_t *i = vam->input;
21812 vl_api_flow_classify_dump_t *mp;
21813 vl_api_control_ping_t *mp_ping;
21814 u8 type = FLOW_CLASSIFY_N_TABLES;
21817 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
21821 errmsg ("classify table type must be specified");
21825 if (!vam->json_output)
21827 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
21830 M (FLOW_CLASSIFY_DUMP, mp);
21835 /* Use a control ping for synchronization */
21836 MPING (CONTROL_PING, mp_ping);
21839 /* Wait for a reply... */
21845 api_feature_enable_disable (vat_main_t * vam)
21847 unformat_input_t *i = vam->input;
21848 vl_api_feature_enable_disable_t *mp;
21850 u8 *feature_name = 0;
21851 u32 sw_if_index = ~0;
21855 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21857 if (unformat (i, "arc_name %s", &arc_name))
21859 else if (unformat (i, "feature_name %s", &feature_name))
21862 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21864 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21866 else if (unformat (i, "disable"))
21874 errmsg ("missing arc name");
21877 if (vec_len (arc_name) > 63)
21879 errmsg ("arc name too long");
21882 if (feature_name == 0)
21884 errmsg ("missing feature name");
21887 if (vec_len (feature_name) > 63)
21889 errmsg ("feature name too long");
21892 if (sw_if_index == ~0)
21894 errmsg ("missing interface name or sw_if_index");
21898 /* Construct the API message */
21899 M (FEATURE_ENABLE_DISABLE, mp);
21900 mp->sw_if_index = ntohl (sw_if_index);
21901 mp->enable = enable;
21902 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
21903 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
21904 vec_free (arc_name);
21905 vec_free (feature_name);
21913 api_sw_interface_tag_add_del (vat_main_t * vam)
21915 unformat_input_t *i = vam->input;
21916 vl_api_sw_interface_tag_add_del_t *mp;
21917 u32 sw_if_index = ~0;
21922 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21924 if (unformat (i, "tag %s", &tag))
21926 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21928 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21930 else if (unformat (i, "del"))
21936 if (sw_if_index == ~0)
21938 errmsg ("missing interface name or sw_if_index");
21942 if (enable && (tag == 0))
21944 errmsg ("no tag specified");
21948 /* Construct the API message */
21949 M (SW_INTERFACE_TAG_ADD_DEL, mp);
21950 mp->sw_if_index = ntohl (sw_if_index);
21951 mp->is_add = enable;
21953 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
21961 static void vl_api_l2_xconnect_details_t_handler
21962 (vl_api_l2_xconnect_details_t * mp)
21964 vat_main_t *vam = &vat_main;
21966 print (vam->ofp, "%15d%15d",
21967 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
21970 static void vl_api_l2_xconnect_details_t_handler_json
21971 (vl_api_l2_xconnect_details_t * mp)
21973 vat_main_t *vam = &vat_main;
21974 vat_json_node_t *node = NULL;
21976 if (VAT_JSON_ARRAY != vam->json_tree.type)
21978 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21979 vat_json_init_array (&vam->json_tree);
21981 node = vat_json_array_add (&vam->json_tree);
21983 vat_json_init_object (node);
21984 vat_json_object_add_uint (node, "rx_sw_if_index",
21985 ntohl (mp->rx_sw_if_index));
21986 vat_json_object_add_uint (node, "tx_sw_if_index",
21987 ntohl (mp->tx_sw_if_index));
21991 api_l2_xconnect_dump (vat_main_t * vam)
21993 vl_api_l2_xconnect_dump_t *mp;
21994 vl_api_control_ping_t *mp_ping;
21997 if (!vam->json_output)
21999 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
22002 M (L2_XCONNECT_DUMP, mp);
22006 /* Use a control ping for synchronization */
22007 MPING (CONTROL_PING, mp_ping);
22015 api_sw_interface_set_mtu (vat_main_t * vam)
22017 unformat_input_t *i = vam->input;
22018 vl_api_sw_interface_set_mtu_t *mp;
22019 u32 sw_if_index = ~0;
22023 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22025 if (unformat (i, "mtu %d", &mtu))
22027 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22029 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22035 if (sw_if_index == ~0)
22037 errmsg ("missing interface name or sw_if_index");
22043 errmsg ("no mtu specified");
22047 /* Construct the API message */
22048 M (SW_INTERFACE_SET_MTU, mp);
22049 mp->sw_if_index = ntohl (sw_if_index);
22050 mp->mtu = ntohs ((u16) mtu);
22058 api_p2p_ethernet_add (vat_main_t * vam)
22060 unformat_input_t *i = vam->input;
22061 vl_api_p2p_ethernet_add_t *mp;
22062 u32 parent_if_index = ~0;
22068 memset (remote_mac, 0, sizeof (remote_mac));
22069 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22071 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
22073 else if (unformat (i, "sw_if_index %d", &parent_if_index))
22077 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
22079 else if (unformat (i, "sub_id %d", &sub_id))
22083 clib_warning ("parse error '%U'", format_unformat_error, i);
22088 if (parent_if_index == ~0)
22090 errmsg ("missing interface name or sw_if_index");
22095 errmsg ("missing remote mac address");
22100 errmsg ("missing sub-interface id");
22104 M (P2P_ETHERNET_ADD, mp);
22105 mp->parent_if_index = ntohl (parent_if_index);
22106 mp->subif_id = ntohl (sub_id);
22107 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22115 api_p2p_ethernet_del (vat_main_t * vam)
22117 unformat_input_t *i = vam->input;
22118 vl_api_p2p_ethernet_del_t *mp;
22119 u32 parent_if_index = ~0;
22124 memset (remote_mac, 0, sizeof (remote_mac));
22125 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22127 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
22129 else if (unformat (i, "sw_if_index %d", &parent_if_index))
22133 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
22137 clib_warning ("parse error '%U'", format_unformat_error, i);
22142 if (parent_if_index == ~0)
22144 errmsg ("missing interface name or sw_if_index");
22149 errmsg ("missing remote mac address");
22153 M (P2P_ETHERNET_DEL, mp);
22154 mp->parent_if_index = ntohl (parent_if_index);
22155 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22163 api_lldp_config (vat_main_t * vam)
22165 unformat_input_t *i = vam->input;
22166 vl_api_lldp_config_t *mp;
22168 int tx_interval = 0;
22169 u8 *sys_name = NULL;
22172 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22174 if (unformat (i, "system-name %s", &sys_name))
22176 else if (unformat (i, "tx-hold %d", &tx_hold))
22178 else if (unformat (i, "tx-interval %d", &tx_interval))
22182 clib_warning ("parse error '%U'", format_unformat_error, i);
22187 vec_add1 (sys_name, 0);
22189 M (LLDP_CONFIG, mp);
22190 mp->tx_hold = htonl (tx_hold);
22191 mp->tx_interval = htonl (tx_interval);
22192 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
22193 vec_free (sys_name);
22201 api_sw_interface_set_lldp (vat_main_t * vam)
22203 unformat_input_t *i = vam->input;
22204 vl_api_sw_interface_set_lldp_t *mp;
22205 u32 sw_if_index = ~0;
22207 u8 *port_desc = NULL, *mgmt_oid = NULL;
22208 ip4_address_t ip4_addr;
22209 ip6_address_t ip6_addr;
22212 memset (&ip4_addr, 0, sizeof (ip4_addr));
22213 memset (&ip6_addr, 0, sizeof (ip6_addr));
22215 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22217 if (unformat (i, "disable"))
22220 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22222 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22224 else if (unformat (i, "port-desc %s", &port_desc))
22226 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
22228 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
22230 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
22236 if (sw_if_index == ~0)
22238 errmsg ("missing interface name or sw_if_index");
22242 /* Construct the API message */
22243 vec_add1 (port_desc, 0);
22244 vec_add1 (mgmt_oid, 0);
22245 M (SW_INTERFACE_SET_LLDP, mp);
22246 mp->sw_if_index = ntohl (sw_if_index);
22247 mp->enable = enable;
22248 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
22249 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
22250 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
22251 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
22252 vec_free (port_desc);
22253 vec_free (mgmt_oid);
22261 api_tcp_configure_src_addresses (vat_main_t * vam)
22263 vl_api_tcp_configure_src_addresses_t *mp;
22264 unformat_input_t *i = vam->input;
22265 ip4_address_t v4first, v4last;
22266 ip6_address_t v6first, v6last;
22271 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22273 if (unformat (i, "%U - %U",
22274 unformat_ip4_address, &v4first,
22275 unformat_ip4_address, &v4last))
22279 errmsg ("one range per message (range already set)");
22284 else if (unformat (i, "%U - %U",
22285 unformat_ip6_address, &v6first,
22286 unformat_ip6_address, &v6last))
22290 errmsg ("one range per message (range already set)");
22295 else if (unformat (i, "vrf %d", &vrf_id))
22301 if (range_set == 0)
22303 errmsg ("address range not set");
22307 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
22308 mp->vrf_id = ntohl (vrf_id);
22310 if (range_set == 2)
22313 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
22314 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
22319 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
22320 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
22327 static void vl_api_app_namespace_add_del_reply_t_handler
22328 (vl_api_app_namespace_add_del_reply_t * mp)
22330 vat_main_t *vam = &vat_main;
22331 i32 retval = ntohl (mp->retval);
22332 if (vam->async_mode)
22334 vam->async_errors += (retval < 0);
22338 vam->retval = retval;
22340 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
22341 vam->result_ready = 1;
22345 static void vl_api_app_namespace_add_del_reply_t_handler_json
22346 (vl_api_app_namespace_add_del_reply_t * mp)
22348 vat_main_t *vam = &vat_main;
22349 vat_json_node_t node;
22351 vat_json_init_object (&node);
22352 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
22353 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
22355 vat_json_print (vam->ofp, &node);
22356 vat_json_free (&node);
22358 vam->retval = ntohl (mp->retval);
22359 vam->result_ready = 1;
22363 api_app_namespace_add_del (vat_main_t * vam)
22365 vl_api_app_namespace_add_del_t *mp;
22366 unformat_input_t *i = vam->input;
22367 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
22368 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
22372 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22374 if (unformat (i, "id %_%v%_", &ns_id))
22376 else if (unformat (i, "secret %lu", &secret))
22378 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22379 sw_if_index_set = 1;
22380 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
22382 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
22387 if (!ns_id || !secret_set || !sw_if_index_set)
22389 errmsg ("namespace id, secret and sw_if_index must be set");
22392 if (vec_len (ns_id) > 64)
22394 errmsg ("namespace id too long");
22397 M (APP_NAMESPACE_ADD_DEL, mp);
22399 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
22400 mp->namespace_id_len = vec_len (ns_id);
22401 mp->secret = clib_host_to_net_u64 (secret);
22402 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
22403 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
22404 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
22412 api_memfd_segment_create (vat_main_t * vam)
22414 #if VPP_API_TEST_BUILTIN == 0
22415 unformat_input_t *i = vam->input;
22416 vl_api_memfd_segment_create_t *mp;
22417 u64 size = 64 << 20;
22420 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22422 if (unformat (i, "size %U", unformat_memory_size, &size))
22428 M (MEMFD_SEGMENT_CREATE, mp);
22429 mp->requested_size = size;
22435 errmsg ("memfd_segment_create (builtin) not supported");
22441 api_sock_init_shm (vat_main_t * vam)
22443 #if VPP_API_TEST_BUILTIN == 0
22444 unformat_input_t *i = vam->input;
22445 vl_api_shm_elem_config_t *config = 0;
22446 u64 size = 64 << 20;
22449 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22451 if (unformat (i, "size %U", unformat_memory_size, &size))
22457 /* Try customized config to see if it works */
22458 vec_validate (config, 3);
22459 config[0].type = VL_API_VLIB_RING;
22460 config[0].count = 256;
22461 config[0].size = 256;
22462 config[1].type = VL_API_CLIENT_RING;
22463 config[1].count = 256;
22464 config[1].size = 1024;
22465 config[2].type = VL_API_CLIENT_RING;
22466 config[2].count = 8;
22467 config[2].size = 4096;
22468 config[3].type = VL_API_QUEUE;
22469 config[3].count = 256;
22470 config[3].size = sizeof (uword);
22471 rv = vl_socket_client_init_shm (config);
22473 vam->client_index_invalid = 1;
22481 api_dns_enable_disable (vat_main_t * vam)
22483 unformat_input_t *line_input = vam->input;
22484 vl_api_dns_enable_disable_t *mp;
22485 u8 enable_disable = 1;
22488 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22490 if (unformat (line_input, "disable"))
22491 enable_disable = 0;
22492 if (unformat (line_input, "enable"))
22493 enable_disable = 1;
22498 /* Construct the API message */
22499 M (DNS_ENABLE_DISABLE, mp);
22500 mp->enable = enable_disable;
22504 /* Wait for the reply */
22510 api_dns_resolve_name (vat_main_t * vam)
22512 unformat_input_t *line_input = vam->input;
22513 vl_api_dns_resolve_name_t *mp;
22517 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22519 if (unformat (line_input, "%s", &name))
22525 if (vec_len (name) > 127)
22527 errmsg ("name too long");
22531 /* Construct the API message */
22532 M (DNS_RESOLVE_NAME, mp);
22533 memcpy (mp->name, name, vec_len (name));
22538 /* Wait for the reply */
22544 api_dns_resolve_ip (vat_main_t * vam)
22546 unformat_input_t *line_input = vam->input;
22547 vl_api_dns_resolve_ip_t *mp;
22549 ip4_address_t addr4;
22550 ip6_address_t addr6;
22553 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22555 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
22557 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
22565 errmsg ("missing address");
22569 /* Construct the API message */
22570 M (DNS_RESOLVE_IP, mp);
22571 mp->is_ip6 = is_ip6;
22573 memcpy (mp->address, &addr6, sizeof (addr6));
22575 memcpy (mp->address, &addr4, sizeof (addr4));
22579 /* Wait for the reply */
22585 api_dns_name_server_add_del (vat_main_t * vam)
22587 unformat_input_t *i = vam->input;
22588 vl_api_dns_name_server_add_del_t *mp;
22590 ip6_address_t ip6_server;
22591 ip4_address_t ip4_server;
22596 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22598 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
22600 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
22602 else if (unformat (i, "del"))
22606 clib_warning ("parse error '%U'", format_unformat_error, i);
22611 if (ip4_set && ip6_set)
22613 errmsg ("Only one server address allowed per message");
22616 if ((ip4_set + ip6_set) == 0)
22618 errmsg ("Server address required");
22622 /* Construct the API message */
22623 M (DNS_NAME_SERVER_ADD_DEL, mp);
22627 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
22632 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
22636 mp->is_add = is_add;
22641 /* Wait for a reply, return good/bad news */
22647 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
22649 vat_main_t *vam = &vat_main;
22654 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22655 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22656 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
22657 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
22658 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22659 clib_net_to_host_u32 (mp->action_index), mp->tag);
22664 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22665 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22666 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
22667 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
22668 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22669 clib_net_to_host_u32 (mp->action_index), mp->tag);
22674 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
22677 vat_main_t *vam = &vat_main;
22678 vat_json_node_t *node = NULL;
22679 struct in6_addr ip6;
22680 struct in_addr ip4;
22682 if (VAT_JSON_ARRAY != vam->json_tree.type)
22684 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22685 vat_json_init_array (&vam->json_tree);
22687 node = vat_json_array_add (&vam->json_tree);
22688 vat_json_init_object (node);
22690 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
22691 vat_json_object_add_uint (node, "appns_index",
22692 clib_net_to_host_u32 (mp->appns_index));
22693 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
22694 vat_json_object_add_uint (node, "scope", mp->scope);
22695 vat_json_object_add_uint (node, "action_index",
22696 clib_net_to_host_u32 (mp->action_index));
22697 vat_json_object_add_uint (node, "lcl_port",
22698 clib_net_to_host_u16 (mp->lcl_port));
22699 vat_json_object_add_uint (node, "rmt_port",
22700 clib_net_to_host_u16 (mp->rmt_port));
22701 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
22702 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
22703 vat_json_object_add_string_copy (node, "tag", mp->tag);
22706 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
22707 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
22708 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
22709 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
22713 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
22714 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
22715 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
22716 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
22721 api_session_rule_add_del (vat_main_t * vam)
22723 vl_api_session_rule_add_del_t *mp;
22724 unformat_input_t *i = vam->input;
22725 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
22726 u32 appns_index = 0, scope = 0;
22727 ip4_address_t lcl_ip4, rmt_ip4;
22728 ip6_address_t lcl_ip6, rmt_ip6;
22729 u8 is_ip4 = 1, conn_set = 0;
22730 u8 is_add = 1, *tag = 0;
22733 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22735 if (unformat (i, "del"))
22737 else if (unformat (i, "add"))
22739 else if (unformat (i, "proto tcp"))
22741 else if (unformat (i, "proto udp"))
22743 else if (unformat (i, "appns %d", &appns_index))
22745 else if (unformat (i, "scope %d", &scope))
22747 else if (unformat (i, "tag %_%v%_", &tag))
22751 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
22752 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
22760 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
22761 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
22767 else if (unformat (i, "action %d", &action))
22772 if (proto == ~0 || !conn_set || action == ~0)
22774 errmsg ("transport proto, connection and action must be set");
22780 errmsg ("scope should be 0-3");
22784 M (SESSION_RULE_ADD_DEL, mp);
22786 mp->is_ip4 = is_ip4;
22787 mp->transport_proto = proto;
22788 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
22789 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
22790 mp->lcl_plen = lcl_plen;
22791 mp->rmt_plen = rmt_plen;
22792 mp->action_index = clib_host_to_net_u32 (action);
22793 mp->appns_index = clib_host_to_net_u32 (appns_index);
22795 mp->is_add = is_add;
22798 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
22799 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
22803 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
22804 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
22808 clib_memcpy (mp->tag, tag, vec_len (tag));
22818 api_session_rules_dump (vat_main_t * vam)
22820 vl_api_session_rules_dump_t *mp;
22821 vl_api_control_ping_t *mp_ping;
22824 if (!vam->json_output)
22826 print (vam->ofp, "%=20s", "Session Rules");
22829 M (SESSION_RULES_DUMP, mp);
22833 /* Use a control ping for synchronization */
22834 MPING (CONTROL_PING, mp_ping);
22837 /* Wait for a reply... */
22843 api_ip_container_proxy_add_del (vat_main_t * vam)
22845 vl_api_ip_container_proxy_add_del_t *mp;
22846 unformat_input_t *i = vam->input;
22847 u32 plen = ~0, sw_if_index = ~0;
22854 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22856 if (unformat (i, "del"))
22858 else if (unformat (i, "add"))
22860 if (unformat (i, "%U", unformat_ip4_address, &ip4))
22865 else if (unformat (i, "%U", unformat_ip6_address, &ip6))
22870 else if (unformat (i, "sw_if_index %u", &sw_if_index))
22875 if (sw_if_index == ~0 || plen == ~0)
22877 errmsg ("address and sw_if_index must be set");
22881 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
22883 mp->is_ip4 = is_ip4;
22884 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
22886 mp->is_add = is_add;
22888 clib_memcpy (mp->ip, &ip4, sizeof (ip4));
22890 clib_memcpy (mp->ip, &ip6, sizeof (ip6));
22898 q_or_quit (vat_main_t * vam)
22900 #if VPP_API_TEST_BUILTIN == 0
22901 longjmp (vam->jump_buf, 1);
22903 return 0; /* not so much */
22907 q (vat_main_t * vam)
22909 return q_or_quit (vam);
22913 quit (vat_main_t * vam)
22915 return q_or_quit (vam);
22919 comment (vat_main_t * vam)
22925 cmd_cmp (void *a1, void *a2)
22930 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
22934 help (vat_main_t * vam)
22939 unformat_input_t *i = vam->input;
22942 if (unformat (i, "%s", &name))
22946 vec_add1 (name, 0);
22948 hs = hash_get_mem (vam->help_by_name, name);
22950 print (vam->ofp, "usage: %s %s", name, hs[0]);
22952 print (vam->ofp, "No such msg / command '%s'", name);
22957 print (vam->ofp, "Help is available for the following:");
22960 hash_foreach_pair (p, vam->function_by_name,
22962 vec_add1 (cmds, (u8 *)(p->key));
22966 vec_sort_with_function (cmds, cmd_cmp);
22968 for (j = 0; j < vec_len (cmds); j++)
22969 print (vam->ofp, "%s", cmds[j]);
22976 set (vat_main_t * vam)
22978 u8 *name = 0, *value = 0;
22979 unformat_input_t *i = vam->input;
22981 if (unformat (i, "%s", &name))
22983 /* The input buffer is a vector, not a string. */
22984 value = vec_dup (i->buffer);
22985 vec_delete (value, i->index, 0);
22986 /* Almost certainly has a trailing newline */
22987 if (value[vec_len (value) - 1] == '\n')
22988 value[vec_len (value) - 1] = 0;
22989 /* Make sure it's a proper string, one way or the other */
22990 vec_add1 (value, 0);
22991 (void) clib_macro_set_value (&vam->macro_main,
22992 (char *) name, (char *) value);
22995 errmsg ("usage: set <name> <value>");
23003 unset (vat_main_t * vam)
23007 if (unformat (vam->input, "%s", &name))
23008 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
23009 errmsg ("unset: %s wasn't set", name);
23022 macro_sort_cmp (void *a1, void *a2)
23024 macro_sort_t *s1 = a1;
23025 macro_sort_t *s2 = a2;
23027 return strcmp ((char *) (s1->name), (char *) (s2->name));
23031 dump_macro_table (vat_main_t * vam)
23033 macro_sort_t *sort_me = 0, *sm;
23038 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
23040 vec_add2 (sort_me, sm, 1);
23041 sm->name = (u8 *)(p->key);
23042 sm->value = (u8 *) (p->value[0]);
23046 vec_sort_with_function (sort_me, macro_sort_cmp);
23048 if (vec_len (sort_me))
23049 print (vam->ofp, "%-15s%s", "Name", "Value");
23051 print (vam->ofp, "The macro table is empty...");
23053 for (i = 0; i < vec_len (sort_me); i++)
23054 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
23059 dump_node_table (vat_main_t * vam)
23062 vlib_node_t *node, *next_node;
23064 if (vec_len (vam->graph_nodes) == 0)
23066 print (vam->ofp, "Node table empty, issue get_node_graph...");
23070 for (i = 0; i < vec_len (vam->graph_nodes); i++)
23072 node = vam->graph_nodes[i];
23073 print (vam->ofp, "[%d] %s", i, node->name);
23074 for (j = 0; j < vec_len (node->next_nodes); j++)
23076 if (node->next_nodes[j] != ~0)
23078 next_node = vam->graph_nodes[node->next_nodes[j]];
23079 print (vam->ofp, " [%d] %s", j, next_node->name);
23087 value_sort_cmp (void *a1, void *a2)
23089 name_sort_t *n1 = a1;
23090 name_sort_t *n2 = a2;
23092 if (n1->value < n2->value)
23094 if (n1->value > n2->value)
23101 dump_msg_api_table (vat_main_t * vam)
23103 api_main_t *am = &api_main;
23104 name_sort_t *nses = 0, *ns;
23109 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
23111 vec_add2 (nses, ns, 1);
23112 ns->name = (u8 *)(hp->key);
23113 ns->value = (u32) hp->value[0];
23117 vec_sort_with_function (nses, value_sort_cmp);
23119 for (i = 0; i < vec_len (nses); i++)
23120 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
23126 get_msg_id (vat_main_t * vam)
23131 if (unformat (vam->input, "%s", &name_and_crc))
23133 message_index = vl_msg_api_get_msg_index (name_and_crc);
23134 if (message_index == ~0)
23136 print (vam->ofp, " '%s' not found", name_and_crc);
23139 print (vam->ofp, " '%s' has message index %d",
23140 name_and_crc, message_index);
23143 errmsg ("name_and_crc required...");
23148 search_node_table (vat_main_t * vam)
23150 unformat_input_t *line_input = vam->input;
23153 vlib_node_t *node, *next_node;
23156 if (vam->graph_node_index_by_name == 0)
23158 print (vam->ofp, "Node table empty, issue get_node_graph...");
23162 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
23164 if (unformat (line_input, "%s", &node_to_find))
23166 vec_add1 (node_to_find, 0);
23167 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
23170 print (vam->ofp, "%s not found...", node_to_find);
23173 node = vam->graph_nodes[p[0]];
23174 print (vam->ofp, "[%d] %s", p[0], node->name);
23175 for (j = 0; j < vec_len (node->next_nodes); j++)
23177 if (node->next_nodes[j] != ~0)
23179 next_node = vam->graph_nodes[node->next_nodes[j]];
23180 print (vam->ofp, " [%d] %s", j, next_node->name);
23187 clib_warning ("parse error '%U'", format_unformat_error,
23193 vec_free (node_to_find);
23202 script (vat_main_t * vam)
23204 #if (VPP_API_TEST_BUILTIN==0)
23206 char *save_current_file;
23207 unformat_input_t save_input;
23208 jmp_buf save_jump_buf;
23209 u32 save_line_number;
23211 FILE *new_fp, *save_ifp;
23213 if (unformat (vam->input, "%s", &s))
23215 new_fp = fopen ((char *) s, "r");
23218 errmsg ("Couldn't open script file %s", s);
23225 errmsg ("Missing script name");
23229 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
23230 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
23231 save_ifp = vam->ifp;
23232 save_line_number = vam->input_line_number;
23233 save_current_file = (char *) vam->current_file;
23235 vam->input_line_number = 0;
23237 vam->current_file = s;
23240 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
23241 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
23242 vam->ifp = save_ifp;
23243 vam->input_line_number = save_line_number;
23244 vam->current_file = (u8 *) save_current_file;
23249 clib_warning ("use the exec command...");
23255 echo (vat_main_t * vam)
23257 print (vam->ofp, "%v", vam->input->buffer);
23261 /* List of API message constructors, CLI names map to api_xxx */
23262 #define foreach_vpe_api_msg \
23263 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
23264 _(sw_interface_dump,"") \
23265 _(sw_interface_set_flags, \
23266 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
23267 _(sw_interface_add_del_address, \
23268 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
23269 _(sw_interface_set_rx_mode, \
23270 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
23271 _(sw_interface_set_table, \
23272 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
23273 _(sw_interface_set_mpls_enable, \
23274 "<intfc> | sw_if_index [disable | dis]") \
23275 _(sw_interface_set_vpath, \
23276 "<intfc> | sw_if_index <id> enable | disable") \
23277 _(sw_interface_set_vxlan_bypass, \
23278 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23279 _(sw_interface_set_geneve_bypass, \
23280 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23281 _(sw_interface_set_l2_xconnect, \
23282 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23283 "enable | disable") \
23284 _(sw_interface_set_l2_bridge, \
23285 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
23286 "[shg <split-horizon-group>] [bvi]\n" \
23287 "enable | disable") \
23288 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
23289 _(bridge_domain_add_del, \
23290 "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") \
23291 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
23293 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
23294 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
23295 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
23297 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23299 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23301 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
23303 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
23305 "<vpp-if-name> | sw_if_index <id>") \
23306 _(sw_interface_tap_dump, "") \
23308 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>]") \
23310 "<vpp-if-name> | sw_if_index <id>") \
23311 _(sw_interface_tap_v2_dump, "") \
23313 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
23314 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]}") \
23316 "<vpp-if-name> | sw_if_index <id>") \
23318 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
23319 _(bond_detach_slave, \
23320 "sw_if_index <n>") \
23321 _(sw_interface_bond_dump, "") \
23322 _(sw_interface_slave_dump, \
23323 "<vpp-if-name> | sw_if_index <id>") \
23324 _(ip_table_add_del, \
23325 "table-id <n> [ipv6]\n") \
23326 _(ip_add_del_route, \
23327 "<addr>/<mask> via <addr> [table-id <n>]\n" \
23328 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
23329 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
23330 "[multipath] [count <n>]") \
23331 _(ip_mroute_add_del, \
23332 "<src> <grp>/<mask> [table-id <n>]\n" \
23333 "[<intfc> | sw_if_index <id>] [local] [del]") \
23334 _(mpls_table_add_del, \
23335 "table-id <n>\n") \
23336 _(mpls_route_add_del, \
23337 "<label> <eos> via <addr> [table-id <n>]\n" \
23338 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
23339 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
23340 "[multipath] [count <n>]") \
23341 _(mpls_ip_bind_unbind, \
23342 "<label> <addr/len>") \
23343 _(mpls_tunnel_add_del, \
23344 " via <addr> [table-id <n>]\n" \
23345 "sw_if_index <id>] [l2] [del]") \
23346 _(bier_table_add_del, \
23347 "<label> <sub-domain> <set> <bsl> [del]") \
23348 _(bier_route_add_del, \
23349 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
23350 "[<intfc> | sw_if_index <id>]" \
23351 "[weight <n>] [del] [multipath]") \
23352 _(proxy_arp_add_del, \
23353 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
23354 _(proxy_arp_intfc_enable_disable, \
23355 "<intfc> | sw_if_index <id> enable | disable") \
23356 _(sw_interface_set_unnumbered, \
23357 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
23358 _(ip_neighbor_add_del, \
23359 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
23360 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
23361 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
23362 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
23363 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
23364 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
23365 "[outer_vlan_id_any][inner_vlan_id_any]") \
23366 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
23367 _(reset_fib, "vrf <n> [ipv6]") \
23368 _(dhcp_proxy_config, \
23369 "svr <v46-address> src <v46-address>\n" \
23370 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
23371 _(dhcp_proxy_set_vss, \
23372 "tbl_id <n> [fib_id <n> oui <n> | vpn_ascii_id <text>] [ipv6] [del]") \
23373 _(dhcp_proxy_dump, "ip6") \
23374 _(dhcp_client_config, \
23375 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
23376 _(set_ip_flow_hash, \
23377 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
23378 _(sw_interface_ip6_enable_disable, \
23379 "<intfc> | sw_if_index <id> enable | disable") \
23380 _(sw_interface_ip6_set_link_local_address, \
23381 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
23382 _(ip6nd_proxy_add_del, \
23383 "<intfc> | sw_if_index <id> <ip6-address>") \
23384 _(ip6nd_proxy_dump, "") \
23385 _(sw_interface_ip6nd_ra_prefix, \
23386 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
23387 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
23388 "[nolink] [isno]") \
23389 _(sw_interface_ip6nd_ra_config, \
23390 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
23391 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
23392 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
23393 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
23394 _(l2_patch_add_del, \
23395 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23396 "enable | disable") \
23397 _(sr_localsid_add_del, \
23398 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
23399 "fib-table <num> (end.psp) sw_if_index <num>") \
23400 _(classify_add_del_table, \
23401 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
23402 " [del] [del-chain] mask <mask-value>\n" \
23403 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
23404 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
23405 _(classify_add_del_session, \
23406 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
23407 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
23408 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
23409 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
23410 _(classify_set_interface_ip_table, \
23411 "<intfc> | sw_if_index <nn> table <nn>") \
23412 _(classify_set_interface_l2_tables, \
23413 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23414 " [other-table <nn>]") \
23415 _(get_node_index, "node <node-name") \
23416 _(add_node_next, "node <node-name> next <next-node-name>") \
23417 _(l2tpv3_create_tunnel, \
23418 "client_address <ip6-addr> our_address <ip6-addr>\n" \
23419 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
23420 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
23421 _(l2tpv3_set_tunnel_cookies, \
23422 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
23423 "[new_remote_cookie <nn>]\n") \
23424 _(l2tpv3_interface_enable_disable, \
23425 "<intfc> | sw_if_index <nn> enable | disable") \
23426 _(l2tpv3_set_lookup_key, \
23427 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
23428 _(sw_if_l2tpv3_tunnel_dump, "") \
23429 _(vxlan_add_del_tunnel, \
23430 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23431 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
23432 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23433 _(geneve_add_del_tunnel, \
23434 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23435 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23436 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23437 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23438 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23439 _(gre_add_del_tunnel, \
23440 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
23441 "[teb | erspan <session-id>] [del]") \
23442 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23443 _(l2_fib_clear_table, "") \
23444 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
23445 _(l2_interface_vlan_tag_rewrite, \
23446 "<intfc> | sw_if_index <nn> \n" \
23447 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
23448 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
23449 _(create_vhost_user_if, \
23450 "socket <filename> [server] [renumber <dev_instance>] " \
23451 "[mac <mac_address>]") \
23452 _(modify_vhost_user_if, \
23453 "<intfc> | sw_if_index <nn> socket <filename>\n" \
23454 "[server] [renumber <dev_instance>]") \
23455 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
23456 _(sw_interface_vhost_user_dump, "") \
23457 _(show_version, "") \
23458 _(vxlan_gpe_add_del_tunnel, \
23459 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
23460 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23461 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
23462 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
23463 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23464 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
23465 _(interface_name_renumber, \
23466 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
23467 _(input_acl_set_interface, \
23468 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23469 " [l2-table <nn>] [del]") \
23470 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
23471 _(want_ip4_arp_events, "address <ip4-address> [del]") \
23472 _(want_ip6_nd_events, "address <ip6-address> [del]") \
23473 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
23474 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
23475 _(ip_dump, "ipv4 | ipv6") \
23476 _(ipsec_spd_add_del, "spd_id <n> [del]") \
23477 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
23479 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
23480 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
23481 " integ_alg <alg> integ_key <hex>") \
23482 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
23483 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
23484 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
23485 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
23486 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
23487 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
23488 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
23489 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
23490 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
23491 " [instance <n>]") \
23492 _(ipsec_sa_dump, "[sa_id <n>]") \
23493 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
23494 " <alg> <hex>\n") \
23495 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
23496 _(ikev2_profile_add_del, "name <profile_name> [del]") \
23497 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
23498 "(auth_data 0x<data> | auth_data <data>)") \
23499 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
23500 "(id_data 0x<data> | id_data <data>) (local|remote)") \
23501 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
23502 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
23503 "(local|remote)") \
23504 _(ikev2_set_local_key, "file <absolute_file_path>") \
23505 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
23506 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23507 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23508 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
23509 _(ikev2_initiate_sa_init, "<profile_name>") \
23510 _(ikev2_initiate_del_ike_sa, "<ispi>") \
23511 _(ikev2_initiate_del_child_sa, "<ispi>") \
23512 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
23513 _(delete_loopback,"sw_if_index <nn>") \
23514 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
23515 _(map_add_domain, \
23516 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
23517 "ip6-src <ip6addr> " \
23518 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
23519 _(map_del_domain, "index <n>") \
23520 _(map_add_del_rule, \
23521 "index <n> psid <n> dst <ip6addr> [del]") \
23522 _(map_domain_dump, "") \
23523 _(map_rule_dump, "index <map-domain>") \
23524 _(want_interface_events, "enable|disable") \
23525 _(want_stats,"enable|disable") \
23526 _(get_first_msg_id, "client <name>") \
23527 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
23528 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
23529 "fib-id <nn> [ip4][ip6][default]") \
23530 _(get_node_graph, " ") \
23531 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
23532 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
23533 _(ioam_disable, "") \
23534 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
23535 " sw_if_index <sw_if_index> p <priority> " \
23536 "w <weight>] [del]") \
23537 _(one_add_del_locator, "locator-set <locator_name> " \
23538 "iface <intf> | sw_if_index <sw_if_index> " \
23539 "p <priority> w <weight> [del]") \
23540 _(one_add_del_local_eid,"vni <vni> eid " \
23541 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23542 "locator-set <locator_name> [del]" \
23543 "[key-id sha1|sha256 secret-key <secret-key>]")\
23544 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
23545 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
23546 _(one_enable_disable, "enable|disable") \
23547 _(one_map_register_enable_disable, "enable|disable") \
23548 _(one_map_register_fallback_threshold, "<value>") \
23549 _(one_rloc_probe_enable_disable, "enable|disable") \
23550 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23552 "rloc <locator> p <prio> " \
23553 "w <weight> [rloc <loc> ... ] " \
23554 "action <action> [del-all]") \
23555 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23557 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23558 _(one_use_petr, "ip-address> | disable") \
23559 _(one_map_request_mode, "src-dst|dst-only") \
23560 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23561 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23562 _(one_locator_set_dump, "[local | remote]") \
23563 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
23564 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23565 "[local] | [remote]") \
23566 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
23567 _(one_ndp_bd_get, "") \
23568 _(one_ndp_entries_get, "bd <bridge-domain>") \
23569 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
23570 _(one_l2_arp_bd_get, "") \
23571 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
23572 _(one_stats_enable_disable, "enable|disalbe") \
23573 _(show_one_stats_enable_disable, "") \
23574 _(one_eid_table_vni_dump, "") \
23575 _(one_eid_table_map_dump, "l2|l3") \
23576 _(one_map_resolver_dump, "") \
23577 _(one_map_server_dump, "") \
23578 _(one_adjacencies_get, "vni <vni>") \
23579 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
23580 _(show_one_rloc_probe_state, "") \
23581 _(show_one_map_register_state, "") \
23582 _(show_one_status, "") \
23583 _(one_stats_dump, "") \
23584 _(one_stats_flush, "") \
23585 _(one_get_map_request_itr_rlocs, "") \
23586 _(one_map_register_set_ttl, "<ttl>") \
23587 _(one_set_transport_protocol, "udp|api") \
23588 _(one_get_transport_protocol, "") \
23589 _(one_enable_disable_xtr_mode, "enable|disable") \
23590 _(one_show_xtr_mode, "") \
23591 _(one_enable_disable_pitr_mode, "enable|disable") \
23592 _(one_show_pitr_mode, "") \
23593 _(one_enable_disable_petr_mode, "enable|disable") \
23594 _(one_show_petr_mode, "") \
23595 _(show_one_nsh_mapping, "") \
23596 _(show_one_pitr, "") \
23597 _(show_one_use_petr, "") \
23598 _(show_one_map_request_mode, "") \
23599 _(show_one_map_register_ttl, "") \
23600 _(show_one_map_register_fallback_threshold, "") \
23601 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
23602 " sw_if_index <sw_if_index> p <priority> " \
23603 "w <weight>] [del]") \
23604 _(lisp_add_del_locator, "locator-set <locator_name> " \
23605 "iface <intf> | sw_if_index <sw_if_index> " \
23606 "p <priority> w <weight> [del]") \
23607 _(lisp_add_del_local_eid,"vni <vni> eid " \
23608 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23609 "locator-set <locator_name> [del]" \
23610 "[key-id sha1|sha256 secret-key <secret-key>]") \
23611 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
23612 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
23613 _(lisp_enable_disable, "enable|disable") \
23614 _(lisp_map_register_enable_disable, "enable|disable") \
23615 _(lisp_rloc_probe_enable_disable, "enable|disable") \
23616 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23618 "rloc <locator> p <prio> " \
23619 "w <weight> [rloc <loc> ... ] " \
23620 "action <action> [del-all]") \
23621 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23623 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23624 _(lisp_use_petr, "<ip-address> | disable") \
23625 _(lisp_map_request_mode, "src-dst|dst-only") \
23626 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23627 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23628 _(lisp_locator_set_dump, "[local | remote]") \
23629 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
23630 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23631 "[local] | [remote]") \
23632 _(lisp_eid_table_vni_dump, "") \
23633 _(lisp_eid_table_map_dump, "l2|l3") \
23634 _(lisp_map_resolver_dump, "") \
23635 _(lisp_map_server_dump, "") \
23636 _(lisp_adjacencies_get, "vni <vni>") \
23637 _(gpe_fwd_entry_vnis_get, "") \
23638 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
23639 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
23640 "[table <table-id>]") \
23641 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
23642 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
23643 _(gpe_set_encap_mode, "lisp|vxlan") \
23644 _(gpe_get_encap_mode, "") \
23645 _(lisp_gpe_add_del_iface, "up|down") \
23646 _(lisp_gpe_enable_disable, "enable|disable") \
23647 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
23648 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
23649 _(show_lisp_rloc_probe_state, "") \
23650 _(show_lisp_map_register_state, "") \
23651 _(show_lisp_status, "") \
23652 _(lisp_get_map_request_itr_rlocs, "") \
23653 _(show_lisp_pitr, "") \
23654 _(show_lisp_use_petr, "") \
23655 _(show_lisp_map_request_mode, "") \
23656 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
23657 _(af_packet_delete, "name <host interface name>") \
23658 _(policer_add_del, "name <policer name> <params> [del]") \
23659 _(policer_dump, "[name <policer name>]") \
23660 _(policer_classify_set_interface, \
23661 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23662 " [l2-table <nn>] [del]") \
23663 _(policer_classify_dump, "type [ip4|ip6|l2]") \
23664 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
23665 "[master|slave]") \
23666 _(netmap_delete, "name <interface name>") \
23667 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
23668 _(mpls_fib_dump, "") \
23669 _(classify_table_ids, "") \
23670 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
23671 _(classify_table_info, "table_id <nn>") \
23672 _(classify_session_dump, "table_id <nn>") \
23673 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
23674 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
23675 "[template_interval <nn>] [udp_checksum]") \
23676 _(ipfix_exporter_dump, "") \
23677 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
23678 _(ipfix_classify_stream_dump, "") \
23679 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
23680 _(ipfix_classify_table_dump, "") \
23681 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
23682 _(sw_interface_span_dump, "[l2]") \
23683 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
23684 _(pg_create_interface, "if_id <nn>") \
23685 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
23686 _(pg_enable_disable, "[stream <id>] disable") \
23687 _(ip_source_and_port_range_check_add_del, \
23688 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
23689 _(ip_source_and_port_range_check_interface_add_del, \
23690 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
23691 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
23692 _(ipsec_gre_add_del_tunnel, \
23693 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
23694 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
23695 _(delete_subif,"<intfc> | sw_if_index <nn>") \
23696 _(l2_interface_pbb_tag_rewrite, \
23697 "<intfc> | sw_if_index <nn> \n" \
23698 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
23699 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
23700 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
23701 _(flow_classify_set_interface, \
23702 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
23703 _(flow_classify_dump, "type [ip4|ip6]") \
23704 _(ip_fib_dump, "") \
23705 _(ip_mfib_dump, "") \
23706 _(ip6_fib_dump, "") \
23707 _(ip6_mfib_dump, "") \
23708 _(feature_enable_disable, "arc_name <arc_name> " \
23709 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
23710 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
23712 _(l2_xconnect_dump, "") \
23713 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
23714 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
23715 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
23716 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
23717 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
23718 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
23719 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
23720 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
23721 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
23722 _(memfd_segment_create,"size <nnn>") \
23723 _(sock_init_shm, "size <nnn>") \
23724 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
23725 _(dns_enable_disable, "[enable][disable]") \
23726 _(dns_name_server_add_del, "<ip-address> [del]") \
23727 _(dns_resolve_name, "<hostname>") \
23728 _(dns_resolve_ip, "<ip4|ip6>") \
23729 _(dns_name_server_add_del, "<ip-address> [del]") \
23730 _(dns_resolve_name, "<hostname>") \
23731 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
23732 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
23733 _(session_rules_dump, "") \
23734 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
23735 _(output_acl_set_interface, \
23736 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23737 " [l2-table <nn>] [del]") \
23739 /* List of command functions, CLI names map directly to functions */
23740 #define foreach_cli_function \
23741 _(comment, "usage: comment <ignore-rest-of-line>") \
23742 _(dump_interface_table, "usage: dump_interface_table") \
23743 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
23744 _(dump_ipv4_table, "usage: dump_ipv4_table") \
23745 _(dump_ipv6_table, "usage: dump_ipv6_table") \
23746 _(dump_stats_table, "usage: dump_stats_table") \
23747 _(dump_macro_table, "usage: dump_macro_table ") \
23748 _(dump_node_table, "usage: dump_node_table") \
23749 _(dump_msg_api_table, "usage: dump_msg_api_table") \
23750 _(get_msg_id, "usage: get_msg_id name_and_crc") \
23751 _(echo, "usage: echo <message>") \
23752 _(exec, "usage: exec <vpe-debug-CLI-command>") \
23753 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
23754 _(help, "usage: help") \
23755 _(q, "usage: quit") \
23756 _(quit, "usage: quit") \
23757 _(search_node_table, "usage: search_node_table <name>...") \
23758 _(set, "usage: set <variable-name> <value>") \
23759 _(script, "usage: script <file-name>") \
23760 _(unset, "usage: unset <variable-name>")
23762 static void vl_api_##n##_t_handler_uni \
23763 (vl_api_##n##_t * mp) \
23765 vat_main_t * vam = &vat_main; \
23766 if (vam->json_output) { \
23767 vl_api_##n##_t_handler_json(mp); \
23769 vl_api_##n##_t_handler(mp); \
23772 foreach_vpe_api_reply_msg;
23773 #if VPP_API_TEST_BUILTIN == 0
23774 foreach_standalone_reply_msg;
23779 vat_api_hookup (vat_main_t * vam)
23782 vl_msg_api_set_handlers(VL_API_##N, #n, \
23783 vl_api_##n##_t_handler_uni, \
23785 vl_api_##n##_t_endian, \
23786 vl_api_##n##_t_print, \
23787 sizeof(vl_api_##n##_t), 1);
23788 foreach_vpe_api_reply_msg;
23789 #if VPP_API_TEST_BUILTIN == 0
23790 foreach_standalone_reply_msg;
23794 #if (VPP_API_TEST_BUILTIN==0)
23795 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
23797 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
23799 vam->function_by_name = hash_create_string (0, sizeof (uword));
23801 vam->help_by_name = hash_create_string (0, sizeof (uword));
23804 /* API messages we can send */
23805 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
23806 foreach_vpe_api_msg;
23810 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
23811 foreach_vpe_api_msg;
23814 /* CLI functions */
23815 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
23816 foreach_cli_function;
23820 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
23821 foreach_cli_function;
23825 #if VPP_API_TEST_BUILTIN
23826 static clib_error_t *
23827 vat_api_hookup_shim (vlib_main_t * vm)
23829 vat_api_hookup (&vat_main);
23833 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
23837 * fd.io coding-style-patch-verification: ON
23840 * eval: (c-set-style "gnu")